@descope/react-sdk 3.5.6 → 3.6.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/index.umd.js CHANGED
@@ -1,3 +1,3 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Descope={},e.React)}(this,(function(e,t){"use strict";const n=t.createContext(void 0),i=e=>(...t)=>{if(!e)throw Error("You can only use this function after sdk initialization. Make sure to supply 'projectId' to <AuthProvider /> component");return e(...t)},o=e=>(...t)=>{let n;try{n=e(...t)}catch(e){console.error(e)}return n},r=()=>"undefined"!=typeof window&&!!window.descopeBridge,s={"x-descope-sdk-name":"react","x-descope-sdk-version":"3.5.6"},a="undefined"!=typeof window;var d=function(){return d=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},d.apply(this,arguments)};function l(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(i=Object.getOwnPropertySymbols(e);o<i.length;o++)t.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(e,i[o])&&(n[i[o]]=e[i[o]])}return n}function c(e,t,n,i){return new(n||(n=Promise))((function(o,r){function s(e){try{d(i.next(e))}catch(e){r(e)}}function a(e){try{d(i.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}d((i=i.apply(e,t||[])).next())}))}function u(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)}function h(e,t,n,i,o){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?o.call(e,n):o?o.value=n:t.set(e,n),n}"function"==typeof SuppressedError&&SuppressedError;class f extends Error{}function p(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return function(e){return decodeURIComponent(atob(e).replace(/(.)/g,((e,t)=>{let n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(t)}catch(e){return atob(t)}}function v(e,t){if("string"!=typeof e)throw new f("Invalid token specified: must be a string");t||(t={});const n=!0===t.header?0:1,i=e.split(".")[n];if("string"!=typeof i)throw new f(`Invalid token specified: missing part #${n+1}`);let o;try{o=p(i)}catch(e){throw new f(`Invalid token specified: invalid base64 for part #${n+1} (${e.message})`)}try{return JSON.parse(o)}catch(e){throw new f(`Invalid token specified: invalid json for part #${n+1} (${e.message})`)}}f.prototype.name="InvalidTokenError";var g={accessKey:{exchange:"/v1/auth/accesskey/exchange"},otp:{verify:"/v1/auth/otp/verify",signIn:"/v1/auth/otp/signin",signUp:"/v1/auth/otp/signup",update:{email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},signUpOrIn:"/v1/auth/otp/signup-in"},magicLink:{verify:"/v1/auth/magiclink/verify",signIn:"/v1/auth/magiclink/signin",signUp:"/v1/auth/magiclink/signup",update:{email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},signUpOrIn:"/v1/auth/magiclink/signup-in"},enchantedLink:{verify:"/v1/auth/enchantedlink/verify",signIn:"/v1/auth/enchantedlink/signin",signUp:"/v1/auth/enchantedlink/signup",session:"/v1/auth/enchantedlink/pending-session",update:{email:"/v1/auth/enchantedlink/update/email",phone:"/v1/auth/enchantedlink/update/phone"},signUpOrIn:"/v1/auth/enchantedlink/signup-in"},oauth:{start:"/v1/auth/oauth/authorize",exchange:"/v1/auth/oauth/exchange",startNative:"v1/auth/oauth/native/start",finishNative:"v1/auth/oauth/native/finish",oneTap:{getOneTapClientId:"/v1/auth/onetap/clientid/{provider}",exchangeOneTapIDToken:"/v1/auth/onetap/idtoken/exchange",verifyOneTapIDToken:"/v1/auth/onetap/idtoken/verify"}},outbound:{connect:"/v1/outbound/oauth/connect"},sso:{start:"/v1/auth/saml/authorize",exchange:"/v1/auth/saml/exchange"},totp:{verify:"/v1/auth/totp/verify",signUp:"/v1/auth/totp/signup",update:"/v1/auth/totp/update"},notp:{signIn:"/v1/auth/notp/whatsapp/signin",signUp:"/v1/auth/notp/whatsapp/signup",signUpOrIn:"/v1/auth/notp/whatsapp/signup-in",session:"/v1/auth/notp/pending-session"},webauthn:{signUp:{start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},signIn:{start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},signUpOrIn:{start:"/v1/auth/webauthn/signup-in/start"},update:{start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"}},password:{signUp:"/v1/auth/password/signup",signIn:"/v1/auth/password/signin",sendReset:"/v1/auth/password/reset",update:"/v1/auth/password/update",replace:"/v1/auth/password/replace",policy:"/v1/auth/password/policy"},emailVerification:{start:"/v1/auth/emailverification/start"},refresh:"/v1/auth/refresh",tryRefresh:"/v1/auth/try-refresh",selectTenant:"/v1/auth/tenant/select",logout:"/v1/auth/logout",logoutAll:"/v1/auth/logoutall",me:"/v1/auth/me",myTenants:"/v1/auth/me/tenants",history:"/v1/auth/me/history",flow:{start:"/v1/flow/start",next:"/v1/flow/next",event:"/v1/flow/event"}};const m="<region>",y=`https://api.${m}descope.com`,b=6e5,w=()=>{const e={};return{headers(t){const n="function"==typeof t.entries?Object.fromEntries(t.entries()):t;return e.Headers=JSON.stringify(n),this},body(t){return e.Body=t,this},url(t){return e.Url=t.toString(),this},method(t){return e.Method=t,this},title(t){return e.Title=t,this},status(t){return e.Status=t,this},retries(t){return e.Retries=t,this},build:()=>Object.keys(e).flatMap((t=>e[t]?[`${"Title"!==t?`${t}: `:""}${e[t]}`]:[])).join("\n")}},$=[503,520,521,522,524,530],k=[100,5e3,5e3],C=e=>new Promise((t=>setTimeout(t,e))),S=e=>async function(...t){let n=await e(...t);const i=!!(null==(o=t[1])?void 0:o.disableRetry);var o;let r=0;for(;!i&&$.includes(n.status)&&r<k.length;)await C(k[r]),n=await e(...t),r++;r>0&&(n.retries=r);const s=await n.text();return n.text=()=>Promise.resolve(s),n.json=()=>Promise.resolve(JSON.parse(s)),n.clone=()=>n,n};let I;const R=()=>{if(I)return I;const e=new Date,t=`${e.getUTCFullYear().toString()}-${(e.getUTCMonth()+1).toString().padStart(2,"0")}-${e.getUTCDate().toString().padStart(2,"0")}-${e.getUTCHours().toString().padStart(2,"0")}:${e.getUTCMinutes().toString().padStart(2,"0")}:${e.getUTCSeconds().toString().padStart(2,"0")}:${e.getUTCMilliseconds().toString()}`,n=Math.floor(1e3+9e3*Math.random());return I=`${t}-${n}`,I};var E;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT",e.patch="PATCH"}(E||(E={}));const x=({path:e,baseUrl:t,queryParams:n,projectId:i})=>{const o=i.slice(1,-27);t=t.replace(m,o?o+".":"");let r=e?`${t.replace(/\/$/,"")}/${null==e?void 0:e.replace(/^\//,"")}`:t;if(n){const e=Object.keys(n);e.forEach(((t,i)=>{r=`${r}${0===i?"?":""}${t}=${encodeURIComponent(n[t])}${i===e.length-1?"":"&"}`}))}return r},O=(...e)=>new Headers(e.reduce(((e,t)=>((e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t).forEach((([t,n])=>{e[t]="function"==typeof n?n():n})),e)),{})),A={"Content-Type":"application/json"},N=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},j=(e,t)=>{const n={"x-descope-sdk-session-id":R(),"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.78.0","x-descope-project-id":e};return t&&(n["x-descope-refresh-cookie-name"]=t),n},M=e=>{try{e=JSON.parse(e)}catch(e){return!1}return"object"==typeof e&&null!==e};var P=e=>{var t;return(({baseUrl:e,projectId:t,baseConfig:n,refreshCookieName:i,logger:o,hooks:r,cookiePolicy:s,fetch:a})=>{const d=e||y,l=((e,t)=>{const n=t||fetch;return n||null==e||e.warn("Fetch is not defined, you will not be able to send http requests, if you are running in a test, make sure fetch is defined globally"),e?async function(...t){if(!n)throw Error("Cannot send http request, fetch is not defined, if you are running in a test, make sure fetch is defined globally");e.log((e=>w().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const i=await S(n)(...t);return e[i.ok?"log":"error"](await(async e=>{const t=await e.text();return w().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).retries(e.retries).build()})(i)),i}:S(n)})(o,a),c=async e=>{var o;const a=(null==r?void 0:r.beforeRequest)?r.beforeRequest(e):e,{path:c,body:u,headers:h,queryParams:f,method:p,token:v,keepalive:g,disableRetry:m}=a,y=(e=>void 0===e?void 0:JSON.stringify(e))(u),b=Object.assign(Object.assign({headers:O(N(t,v),j(t,i),(null==n?void 0:n.baseHeaders)||{},M(y)?A:{},h),method:p,body:y},g?{keepalive:!0}:{}),m?{disableRetry:!0}:{});null!==s&&(b.credentials=s||"include");const w=await l(x({path:c,baseUrl:d,queryParams:f,projectId:t}),b);if((null==r?void 0:r.afterRequest)&&await r.afterRequest(e,null==w?void 0:w.clone()),null==r?void 0:r.transformResponse){const e=await w.json(),t=($=(null===(o=w.headers)||void 0===o?void 0:o.get("set-cookie"))||"",Object.fromEntries(function(e){if(!e)return[];const t=[];let n=0;function i(){for(;n<e.length&&/\s/.test(e.charAt(n));)n+=1;return n<e.length}function o(){const t=e.charAt(n);return"="!==t&&";"!==t&&","!==t}for(;n<e.length;){const r=n;let s,a,d=!1;for(;i();)if(","===e.charAt(n)){for(s=n,n+=1,i(),a=n;n<e.length&&o();)n+=1;if(n<e.length&&"="===e.charAt(n)){d=!0,n=a,t.push(e.substring(r,s));break}n=s+1}else n+=1;(!d||n>=e.length)&&t.push(e.substring(r,e.length))}return t}($).map((e=>{const t=e.split(";")[0],n=t.indexOf("=");return n<1?null:[t.substring(0,n).trim(),t.substring(n+1).trim()]})).filter(Boolean))),n=Object.assign(Object.create(null),{json:()=>Promise.resolve(e),cookies:t}),i=new Proxy(w,{get:(e,t)=>{if(t in n)return n[t];const i=e[t];return"function"==typeof i?i.bind(e):i},set:(e,t,i)=>(n[t]=i,!0),has:(e,t)=>t in n||t in e});return n.clone=()=>i,r.transformResponse(i)}var $;return w};return{get:(e,{headers:t,queryParams:n,token:i,keepalive:o,disableRetry:r}={})=>c({path:e,headers:t,queryParams:n,body:void 0,method:E.get,token:i,keepalive:o,disableRetry:r}),post:(e,t,{headers:n,queryParams:i,token:o,keepalive:r,disableRetry:s}={})=>c({path:e,headers:n,queryParams:i,body:t,method:E.post,token:o,keepalive:r,disableRetry:s}),patch:(e,t,{headers:n,queryParams:i,token:o,keepalive:r,disableRetry:s}={})=>c({path:e,headers:n,queryParams:i,body:t,method:E.patch,token:o,keepalive:r,disableRetry:s}),put:(e,t,{headers:n,queryParams:i,token:o,keepalive:r,disableRetry:s}={})=>c({path:e,headers:n,queryParams:i,body:t,method:E.put,token:o,keepalive:r,disableRetry:s}),delete:(e,{headers:t,queryParams:n,token:i,keepalive:o,disableRetry:r}={})=>c({path:e,headers:t,queryParams:n,body:void 0,method:E.delete,token:i,keepalive:o,disableRetry:r}),hooks:r,buildUrl:(e,n)=>x({projectId:t,baseUrl:d,path:e,queryParams:n})}})(Object.assign(Object.assign({},e),{hooks:{beforeRequest:t=>{var n;const i=[].concat((null===(n=e.hooks)||void 0===n?void 0:n.beforeRequest)||[]);return null==i?void 0:i.reduce(((e,t)=>t(e)),t)},afterRequest:async(t,n)=>{var i;const o=[].concat((null===(i=e.hooks)||void 0===i?void 0:i.afterRequest)||[]);0!=o.length&&(await Promise.allSettled(null==o?void 0:o.map((e=>e(t,null==n?void 0:n.clone()))))).forEach((t=>{var n;return"rejected"===t.status&&(null===(n=e.logger)||void 0===n?void 0:n.error(t.reason))}))},transformResponse:null===(t=e.hooks)||void 0===t?void 0:t.transformResponse}}))},T=429;function W(e,t,n){var i;let o=L(e);if(t){if(!(null==o?void 0:o.tenants)&&(null==o?void 0:o.dct)===t)return(null==o?void 0:o[n])||[];o=null===(i=null==o?void 0:o.tenants)||void 0===i?void 0:i[t]}const r=null==o?void 0:o[n];return Array.isArray(r)?r:[]}function L(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return v(e)}function U(e){const{exp:t}=L(e);return(new Date).getTime()/1e3>t}function D(e){let t=L(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function F(e,t){return W(e,t,"permissions")}function _(e,t){return W(e,t,"roles")}const q=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function B(e,t){var n,i;const o=await e,r={code:o.status,ok:o.ok,response:o},s=await o.clone().json();if(o.ok)r.data=s;else{r.error=s,o.status===T&&Object.assign(r.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0});const e=null===(i=o.headers)||void 0===i?void 0:i.get("cf-ray");e&&r.error&&Object.assign(r.error,{traceId:e})}return r}function V(e){var t;return(null===(t=L(e))||void 0===t?void 0:t.dct)||""}const K=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),H=(e,t)=>(n=t)=>t=>{const i=e.filter((e=>e(t)));return!(i.length<e.length)&&(n?n.replace("{val}",t):i.join(" OR "))},z=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),J=e=>t=>e.test(t),G=J(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),Z=J(/^\+[1-9]{1}[0-9]{3,14}$/),Y=K(G,'"{val}" is not a valid email'),X=K(Z,'"{val}" is not a valid phone number'),Q=K((e=>e.length>=1),"Minimum length is 1");const ee=K((e=>"string"==typeof e),"Input is not a string"),te=K((e=>Array.isArray(e)),"Input is not an array"),ne=K((e=>"boolean"==typeof e),"Input is not a boolean"),ie=K((e=>void 0===e),"Input is defined"),oe=H([ee(),ie()],"Input is not a string or undefined"),re=H([te(),ne()],"Input is not an array or boolean"),se=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>z(...e).validate(n[t]))),t(...n)),ae=e=>[ee(`"${e}" must be a string`)],de=e=>[oe(`"${e}" must be string or undefined`)],le=e=>[ee(`"${e}" must be a string`),Q(`"${e}" must not be empty`)],ce=e=>[ee(`"${e}" must be a string`),Y()],ue=e=>[ee(`"${e}" must be a string`),X()],he=se(le("accessKey")),fe=e=>({exchange:he(((t,n)=>B(e.post(g.accessKey.exchange,{loginOptions:n},{token:t}))))}),pe=(e,t,n)=>(t.forEach((t=>{const i=t.split(".");let o=i.shift(),r=e;for(;i.length>0;){if(r=r[o],!o||!r)throw Error(`Invalid path "${t}", "${o}" is missing or has no value`);o=i.shift()}if("function"!=typeof r[o])throw Error(`"${t}" is not a function`);const s=r[o];r[o]=n(s)})),e),ve=({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||b,b)});var ge,me;!function(e){e.sms="sms",e.voice="voice",e.whatsapp="whatsapp",e.im="im"}(ge||(ge={})),function(e){e.email="email"}(me||(me={}));const ye=Object.assign(Object.assign({},ge),me);var be;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(be||(be={}));const we=le("loginId"),$e=se(le("token")),ke=se(we),Ce=se(le("pendingRef")),Se=se(we,ue("phone")),Ie=se(we,ce("email")),Re=e=>{const t=t=>(n,i,o={},r)=>{var{providerId:s}=o,a=l(o,["providerId"]);return B(e.post(q(g.enchantedLink.signIn,t),{loginId:n,URI:i,loginOptions:a,providerId:s},{token:r}))},n=t=>(n,i,o={})=>{var{providerId:r}=o,s=l(o,["providerId"]);return B(e.post(q(g.enchantedLink.signUpOrIn,t),{loginId:n,URI:i,loginOptions:s,providerId:r}))},i=t=>(n,i,o,r={})=>{var{providerId:s}=r,a=l(r,["providerId"]);return B(e.post(q(g.enchantedLink.signUp,t),{loginId:n,URI:i,user:o,loginOptions:a,providerId:s}))};return{verify:$e((t=>B(e.post(g.enchantedLink.verify,{token:t})))),signIn:ke(t(ye.email)),signInWithPhone:ke(t(ge.sms)),signUpOrIn:ke(n(ye.email)),signUpOrInWithPhone:ke(n(ge.sms)),signUp:ke(i(ye.email)),signUpWithPhone:ke(i(ge.sms)),waitForSession:Ce(((t,n)=>new Promise((i=>{const{pollingIntervalMs:o,timeoutMs:r}=ve(n);let s;const a=setInterval((async()=>{const n=await e.post(g.enchantedLink.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),i(B(Promise.resolve(n))))}),o);s=setTimeout((()=>{i({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:Ie(((t,n,i,o,r)=>B(e.post(g.enchantedLink.update.email,Object.assign({loginId:t,email:n,URI:i},r),{token:o})))),phone:{sms:Se(((t,n,i,o,r)=>B(e.post(q(g.enchantedLink.update.phone,ge.sms),Object.assign({loginId:t,phone:n,URI:i},r),{token:o}))))}}}},Ee=se(le("flowId")),xe=se(le("executionId"),le("stepId"),le("interactionId")),Oe=se(le("executionId")),Ae=e=>({start:Ee(((t,n,i,o,r,s,a,d=!1)=>B(e.post(g.flow.start,{flowId:t,options:n,conditionInteractionId:i,interactionId:o,componentsVersion:r,flowVersions:s,input:a,isCustomScreen:d})))),next:xe(((t,n,i,o,r,s,a=!1,d)=>B(e.post(g.flow.next,{executionId:t,stepId:n,interactionId:i,version:o,componentsVersion:r,input:s,isCustomScreen:a,options:d})))),event:Oe(((t,n,i)=>B(e.post(g.flow.event,{executionId:t,events:n},{keepalive:i,disableRetry:!0}))))}),Ne=le("loginId"),je=se(le("token")),Me=se(Ne);se(le("pendingRef"));const Pe=se(Ne,ue("phone")),Te=se(Ne,ce("email")),We=Object.keys(ye).filter((e=>e!==ge.voice&&e!==ge.im)),Le=e=>({verify:je((t=>B(e.post(g.magicLink.verify,{token:t})))),signIn:We.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Me(((t,i,o={},r)=>{var{providerId:s}=o,a=l(o,["providerId"]);return B(e.post(q(g.magicLink.signIn,n),{loginId:t,URI:i,loginOptions:a,providerId:s},{token:r}))}))})),{}),signUp:We.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Me(((t,i,o,r={})=>{var{providerId:s}=r,a=l(r,["providerId"]);return B(e.post(q(g.magicLink.signUp,n),{loginId:t,URI:i,user:o,loginOptions:a,providerId:s}))}))})),{}),signUpOrIn:We.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Me(((t,i,o={})=>{var{providerId:r}=o,s=l(o,["providerId"]);return B(e.post(q(g.magicLink.signUpOrIn,n),{loginId:t,URI:i,loginOptions:s,providerId:r}))}))})),{}),update:{email:Te(((t,n,i,o,r)=>B(e.post(g.magicLink.update.email,Object.assign({loginId:t,email:n,URI:i},r),{token:o})))),phone:Object.keys(ge).filter((e=>e!==ge.voice)).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Pe(((t,i,o,r,s)=>B(e.post(q(g.magicLink.update.phone,n),Object.assign({loginId:t,phone:i,URI:o},s),{token:r}))))})),{})}});var Ue;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple",e.discord="discord",e.linkedin="linkedin",e.slack="slack"}(Ue||(Ue={}));const De=se(le("code")),Fe=e=>({start:Object.assign(((t,n,i,o,r)=>B(e.post(g.oauth.start,i||{},{queryParams:Object.assign(Object.assign({provider:t},n&&{redirectURL:n}),r&&{loginHint:r}),token:o}))),Object.keys(Ue).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,i,o,r)=>B(e.post(g.oauth.start,i||{},{queryParams:Object.assign(Object.assign({provider:n},t&&{redirectURL:t}),r&&{loginHint:r}),token:o}))})),{})),exchange:De((t=>B(e.post(g.oauth.exchange,{code:t})))),startNative:(t,n,i)=>B(e.post(g.oauth.startNative,{provider:t,loginOptions:n,implicit:i})),finishNative:(t,n,i,o,r)=>B(e.post(g.oauth.finishNative,{provider:t,stateId:n,user:i,code:o,idToken:r})),getOneTapClientId:t=>B(e.get(g.oauth.oneTap.getOneTapClientId.replace("{provider}",t))),verifyOneTapIDToken:(t,n,i,o)=>B(e.post(g.oauth.oneTap.verifyOneTapIDToken,{provider:t,idToken:n,nonce:i,loginOptions:o})),exchangeOneTapIDToken:(t,n,i,o)=>B(e.post(g.oauth.oneTap.exchangeOneTapIDToken,{provider:t,idToken:n,nonce:i,loginOptions:o}))}),_e=le("appId"),qe=se(_e),Be=e=>({connect:qe(((t,n,i)=>{const o=null==n?void 0:n.tenantId,r=null==n?void 0:n.tenantLevel;return null==n||delete n.tenantId,null==n||delete n.tenantLevel,B(e.post(g.outbound.connect,{appId:t,tenantId:o,tenantLevel:r,options:n},{token:i}))}))}),Ve=le("loginId"),Ke=se(Ve,le("code")),He=se(Ve),ze=se(Ve,ue("phone")),Je=se(Ve,ce("email")),Ge=e=>({verify:Object.keys(ye).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ke(((t,i)=>B(e.post(q(g.otp.verify,n),{code:i,loginId:t}))))})),{}),signIn:Object.keys(ye).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:He(((t,i={},o)=>{var{providerId:r}=i,s=l(i,["providerId"]);return B(e.post(q(g.otp.signIn,n),{loginId:t,loginOptions:s,providerId:r},{token:o}))}))})),{}),signUp:Object.keys(ye).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:He(((t,i,o={})=>{var{providerId:r}=o,s=l(o,["providerId"]);return B(e.post(q(g.otp.signUp,n),{loginId:t,user:i,loginOptions:s,providerId:r}))}))})),{}),signUpOrIn:Object.keys(ye).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:He(((t,i={})=>{var{providerId:o}=i,r=l(i,["providerId"]);return B(e.post(q(g.otp.signUpOrIn,n),{loginId:t,loginOptions:r,providerId:o}))}))})),{}),update:{email:Je(((t,n,i,o)=>B(e.post(g.otp.update.email,Object.assign({loginId:t,email:n},o),{token:i})))),phone:Object.keys(ge).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ze(((t,i,o,r)=>B(e.post(q(g.otp.update.phone,n),Object.assign({loginId:t,phone:i},r),{token:o}))))})),{})}}),Ze=se(le("tenant")),Ye=se(le("code")),Xe=e=>({start:Ze(((t,n,i,o,r,s,a,d)=>B(e.post(g.sso.start,i||{},Object.assign({queryParams:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({tenant:t},n&&{redirectURL:n}),r&&{ssoId:r}),s&&{forceAuthn:"true"}),a&&{loginHint:a}),d&&{initiatedEmail:t})},o&&{token:o}))))),exchange:Ye((t=>B(e.post(g.sso.exchange,{code:t}))))}),Qe=le("loginId"),et=se(Qe,le("code")),tt=se(Qe),nt=se(Qe),it=e=>({signUp:tt(((t,n)=>B(e.post(g.totp.signUp,{loginId:t,user:n})))),verify:et(((t,n,i,o)=>B(e.post(g.totp.verify,{loginId:t,code:n,loginOptions:i},{token:o})))),update:nt(((t,n)=>B(e.post(g.totp.update,{loginId:t},{token:n}))))}),ot=e=>({start:()=>B(e.post(g.emailVerification.start,{}))}),rt=le("loginId"),st=le("newPassword"),at=se(rt,le("password")),dt=se(rt),lt=se(rt,st),ct=se(rt,le("oldPassword"),st),ut=e=>({signUp:at(((t,n,i,o={})=>{var{providerId:r}=o,s=l(o,["providerId"]);return B(e.post(g.password.signUp,{loginId:t,password:n,user:i,loginOptions:s,providerId:r}))})),signIn:at(((t,n,i={})=>{var{providerId:o}=i,r=l(i,["providerId"]);return B(e.post(g.password.signIn,{loginId:t,password:n,loginOptions:r,providerId:o}))})),sendReset:dt(((t,n,i)=>B(e.post(g.password.sendReset,{loginId:t,redirectUrl:n,templateOptions:i})))),update:lt(((t,n,i)=>B(e.post(g.password.update,{loginId:t,newPassword:n},{token:i})))),replace:ct(((t,n,i)=>B(e.post(g.password.replace,{loginId:t,oldPassword:n,newPassword:i})))),policy:()=>B(e.get(g.password.policy))}),ht=ae("loginId"),ft=le("loginId"),pt=ae("origin"),vt=se(ft,pt,le("name")),gt=se(ft,pt),mt=se(ht,pt),yt=se(ft,pt,de("token")),bt=se(le("transactionId"),le("response")),wt=e=>({signUp:{start:vt(((t,n,i,o,r)=>B(e.post(g.webauthn.signUp.start,{user:{loginId:t,name:i},origin:n,loginOptions:r,passkeyOptions:o})))),finish:bt(((t,n)=>B(e.post(g.webauthn.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:mt(((t,n,i,o,r)=>B(e.post(g.webauthn.signIn.start,{loginId:t,origin:n,loginOptions:i,passkeyOptions:r},{token:o})))),finish:bt(((t,n)=>B(e.post(g.webauthn.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:gt(((t,n,i,o)=>B(e.post(g.webauthn.signUpOrIn.start,{loginId:t,origin:n,loginOptions:o,passkeyOptions:i}))))},update:{start:yt(((t,n,i,o,r)=>B(e.post(g.webauthn.update.start,{loginId:t,origin:n,passkeyOptions:o,mfa:r},{token:i})))),finish:bt(((t,n)=>B(e.post(g.webauthn.update.finish,{transactionId:t,response:n}))))}}),$t=ae("loginId"),kt=se($t),Ct=se(le("pendingRef")),St=e=>({signUpOrIn:kt(((t,n={})=>{var{providerId:i}=n,o=l(n,["providerId"]);return B(e.post(g.notp.signUpOrIn,{loginId:t,loginOptions:o,providerId:i}))})),signUp:kt(((t,n,i={})=>{var{providerId:o}=i,r=l(i,["providerId"]);return B(e.post(g.notp.signUp,{loginId:t,user:n,providerId:o,loginOptions:r}))})),signIn:kt(((t,n={},i)=>{var{providerId:o}=n,r=l(n,["providerId"]);return B(e.post(g.notp.signIn,{loginId:t,loginOptions:r,providerId:o},{token:i}))})),waitForSession:Ct(((t,n)=>new Promise((i=>{const{pollingIntervalMs:o,timeoutMs:r}=ve(n);let s;const a=setInterval((async()=>{const n=await e.post(g.notp.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),i(B(Promise.resolve(n))))}),o);s=setTimeout((()=>{i({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)}))))}),It=se(le("token")),Rt=se(de("token"));var Et,xt=se([(Et=le("projectId"),K(((e,t)=>n=>z(...t).validate(((e,t)=>{const n=(Array.isArray(t)?t.join("."):String(t)).replace(/\[\\?("|')?(\w|d)+\\?("|')?\]/g,((e,t,n)=>"."+n)).split("."),i=n.length;let o=0,r=e===Object(e)?e:void 0;for(;null!=r&&o<i;)r=r[n[o++]];return o&&o===i&&void 0!==r?r:void 0})(n,e)))("projectId",Et))())])((e=>{const{projectId:t,logger:n,baseUrl:i,cookiePolicy:o,baseHeaders:r={},refreshCookieName:s,fetch:a}=e;return d=P({baseUrl:i,projectId:t,logger:n,hooks:{get beforeRequest(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.beforeRequest},get afterRequest(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.afterRequest},get transformResponse(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.transformResponse}},cookiePolicy:o,baseConfig:{baseHeaders:r},refreshCookieName:s,fetch:a}),{accessKey:fe(d),otp:Ge(d),magicLink:Le(d),enchantedLink:Re(d),oauth:Fe(d),outbound:Be(d),sso:Xe(d),saml:Xe(d),totp:it(d),notp:St(d),webauthn:wt(d),password:ut(d),flow:Ae(d),emailVerification:ot(d),refresh:Rt(((e,t,n,i)=>{const o={};n&&(o.externalToken=n);const r=i?g.tryRefresh:g.refresh;return B(d.post(r,o,{token:e,queryParams:t}))})),selectTenant:se([ee("tenantId")],[oe('"token" must be string or undefined')])(((e,t)=>B(d.post(g.selectTenant,{tenant:e},{token:t})))),logout:Rt((e=>B(d.post(g.logout,{},{token:e})))),logoutAll:Rt((e=>B(d.post(g.logoutAll,{},{token:e})))),me:Rt((e=>B(d.get(g.me,{token:e})))),myTenants:se([re('"tenants" must a string array or a boolean')],[oe('"token" must be string or undefined')])(((e,t)=>{const n={};return"boolean"==typeof e?n.dct=e:n.ids=e,B(d.post(g.myTenants,n,{token:t}))})),history:Rt((e=>B(d.get(g.history,{token:e})))),isJwtExpired:It(U),getTenants:It(D),getJwtPermissions:It(F),getJwtRoles:It(_),getCurrentTenant:It(V),httpClient:d};var d})),Ot=Object.assign(xt,{DeliveryMethods:ye});
2
- /*! js-cookie v3.0.8 | MIT */function At(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)"__proto__"!==i&&(e[i]=n[i])}return e}var Nt=function e(t,n){function i(e,i,o){if("undefined"!=typeof document){"number"==typeof(o=At({},n,o)).expires&&(o.expires=new Date(Date.now()+864e5*o.expires)),o.expires&&(o.expires=o.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var r="";for(var s in o)o[s]&&(r+="; "+s,!0!==o[s]&&(r+="="+o[s].split(";")[0]));return document.cookie=e+"="+t.write(i,e)+r}}return Object.create({set:i,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],i={},o=0;o<n.length;o++){var r=n[o].split("="),s=r.slice(1).join("=");try{var a=decodeURIComponent(r[0]);if(a in i||(i[a]=t.read(s,a)),e===a)break}catch(e){}}return e?i[e]:i}},remove:function(e,t){i(e,"",At({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,At({},this.attributes,t))},withConverter:function(t){return e(At({},this.converter,t),this.attributes)}},{attributes:{value:Object.freeze(n)},converter:{value:Object.freeze(t)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"});var jt={default:"endpoint"},Mt="Blocked by CSP",Pt="The endpoint parameter is not a valid URL",Tt="Failed to load the JS script of the agent",Wt="9319";function Lt(e,t){var n,i,o,r,s,a=[],d=(n=function(e){var t=function(e,t,n){if(n||2===arguments.length)for(var i,o=0,r=t.length;o<r;o++)!i&&o in t||(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))}([],e,!0);return{current:function(){return t[0]},postpone:function(){var e=t.shift();void 0!==e&&t.push(e)},exclude:function(){t.shift()}}}(e),r=0,i=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,r++))},o=new Set,[n.current(),function(e,t){var r,s=t instanceof Error?t.message:"";if(s===Mt||s===Pt)n.exclude(),r=0;else if(s===Wt)n.exclude();else if(s===Tt){var a=Date.now()-e.getTime()<50,d=n.current();d&&a&&!o.has(d)&&(o.add(d),r=0),n.postpone()}else n.postpone();var l=n.current();return void 0===l?void 0:[l,null!=r?r:e.getTime()+i()-Date.now()]}]),l=d[0],c=d[1];if(void 0===l)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var u=function(e){var n=new Date,i=function(t){return a.push({url:e,startedAt:n,finishedAt:new Date,error:t})},o=t(e);return o.then((function(){return i()}),i),o.catch((function(e){if(null!=s||(s=e),a.length>=5)throw s;var t=c(n,e);if(!t)throw s;var i,o=t[0],r=t[1];return(i=r,new Promise((function(e){return setTimeout(e,i)}))).then((function(){return u(o)}))}))};return u(l).then((function(e){return[e,a]}))}var Ut="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",Dt=Ut;function Ft(e){var t;e.scriptUrlPattern;var n=e.token,i=e.apiKey,o=void 0===i?n:i,r=l(e,["scriptUrlPattern","token","apiKey"]),s=null!==(t=function(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)?e[t]:void 0}(e,"scriptUrlPattern"))&&void 0!==t?t:Ut,a=function(){var e=[],t=function(){e.push({time:new Date,state:document.visibilityState})},n=function(e,t,n,i){return e.addEventListener(t,n,i),function(){return e.removeEventListener(t,n,i)}}(document,"visibilitychange",t);return t(),[e,n]}(),c=a[0],u=a[1];return Promise.resolve().then((function(){if(!o||"string"!=typeof o)throw new Error("API key required");var e=function(e,t){return(Array.isArray(e)?e:[e]).map((function(e){return function(e,t){var n=encodeURIComponent;return e.replace(/<[^<>]+>/g,(function(e){return"<version>"===e?"3":"<apiKey>"===e?n(t):"<loaderVersion>"===e?n("3.11.6"):e}))}(String(e),t)}))}(s,o);return Lt(e,_t)})).catch((function(e){throw u(),function(e){return e instanceof Error&&e.message===Wt?new Error(Tt):e}(e)})).then((function(e){var t=e[0],n=e[1];return u(),t.load(d(d({},r),{ldi:{attempts:n,visibilityStates:c}}))}))}function _t(e){return function(e,t,n){var i,o=document,r="securitypolicyviolation",s=function(t){var n=new URL(e,location.href),o=t.blockedURI;o!==n.href&&o!==n.protocol.slice(0,-1)&&o!==n.origin||(i=t,a())};o.addEventListener(r,s);var a=function(){return o.removeEventListener(r,s)};return Promise.resolve().then(t).then((function(e){return a(),e}),(function(e){return new Promise((function(e){var t=new MessageChannel;t.port1.onmessage=function(){return e()},t.port2.postMessage(null)})).then((function(){if(a(),i)return n(i);throw e}))}))}(e,(function(){return function(e){return new Promise((function(t,n){if(function(e){if(URL.prototype)try{return new URL(e,location.href),!1}catch(e){if(e instanceof Error&&"TypeError"===e.name)return!0;throw e}}(e))throw new Error(Pt);var i=document.createElement("script"),o=function(){var e;return null===(e=i.parentNode)||void 0===e?void 0:e.removeChild(i)},r=document.head||document.getElementsByTagName("head")[0];i.onload=function(){o(),t()},i.onerror=function(){o(),n(new Error(Tt))},i.async=!0,i.src=e,r.appendChild(i)}))}(e)}),(function(){throw new Error(Mt)})).then(qt)}function qt(){var e=window,t="__fpjs_p_l_b",n=e[t];if(function(e,t){var n,i=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,e,t);(null==i?void 0:i.configurable)?delete e[t]:i&&!i.writable||(e[t]=void 0)}(e,t),"function"!=typeof(null==n?void 0:n.load))throw new Error(Wt);return n}const Bt="3.2.0",Vt="undefined"!=typeof window,Kt=Math.pow(2,31)-1,Ht=2e4,zt=`https://descopecdn.com/npm/oidc-client-ts@${Bt}/dist/browser/oidc-client-ts.min.js`,Jt=`https://cdn.jsdelivr.net/npm/oidc-client-ts@${Bt}/dist/browser/oidc-client-ts.min.js`,Gt=["/v1/auth/refresh","/v1/auth/try-refresh","/v1/auth/me","/v1/auth/me/tenants","/v1/auth/me/history"];let Zt;const Yt=e=>{try{return v(e).exp}catch(e){return null}},Xt=e=>{const{refresh_expire_in:t,refresh_token:n}=e;return t?Math.floor(Date.now()/1e3)+t:Yt(n)},Qt=e=>{const{expires_in:t,expires_at:n,access_token:i}=e;return n||(t?Math.floor(Date.now()/1e3)+t:i?Yt(i):void 0)},en=e=>{const{access_token:t,id_token:n,refresh_token:i,refresh_expire_in:o}=e,r=l(e,["access_token","id_token","refresh_token","refresh_expire_in"]);return Object.assign({sessionJwt:e.sessionJwt||t,idToken:n,refreshJwt:e.refreshJwt||i,sessionExpiration:e.sessionExpiration||Qt(e),cookieExpiration:e.cookieExpiration||Xt(e)},r)},tn=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,i)=>{var o;return n[i]=[].concat((null===(o=e.hooks)||void 0===o?void 0:o[i])||[]).concat((null==t?void 0:t[i])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},nn=async e=>{if(!(null==e?void 0:e.ok))return{};const t=await(null==e?void 0:e.clone().json()),n=(null==t?void 0:t.authInfo)||t||{};return en(n)},on=()=>Vt&&!!window.descopeBridge,rn=(e,t)=>{if(!((null==t?void 0:t.status)>=400&&(null==t?void 0:t.status)<500))return!1;const n=(null==e?void 0:e.path)||"";return Gt.includes(n)},sn=void 0!==Zt||Vt&&void 0!==window.localStorage,an=(e,t)=>{var n,i;return null===(i=null===(n=Zt||Vt&&window.localStorage)||void 0===n?void 0:n.setItem)||void 0===i?void 0:i.call(n,e,t)},dn=e=>{var t,n;return null===(n=null===(t=Zt||Vt&&window.localStorage)||void 0===t?void 0:t.getItem)||void 0===n?void 0:n.call(t,e)},ln=e=>{var t,n;return null===(n=null===(t=Zt||Vt&&window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===n?void 0:n.call(t,e)},cn=e=>{var t,n,i,o,r;return null!==(r=null!==(n=null===(t=null==Zt?void 0:Zt.key)||void 0===t?void 0:t.call(Zt,e))&&void 0!==n?n:Vt&&(null===(o=null===(i=window.localStorage)||void 0===i?void 0:i.key)||void 0===o?void 0:o.call(i,e)))&&void 0!==r?r:null},un=e=>{var t,n;return Vt&&(null===(n=null===(t=window.localStorage)||void 0===t?void 0:t.getItem)||void 0===n?void 0:n.call(t,e))||null},hn=e=>{var t,n;try{Vt&&(null===(n=null===(t=window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===n||n.call(t,e))}catch(e){}},fn=(...e)=>{console.debug(...e)},pn=(...e)=>{console.warn(...e)},vn=e=>e?e.getTime()-(new Date).getTime():0,gn="DS",mn="DSR",yn="DSI",bn="DSRCN";function wn(e,t,n){if(t){const{cookieDomain:i,cookiePath:o,cookieSameSite:r,cookieExpiration:s,cookieSecure:a}=n,d=new Date(1e3*s),l=$n(i);Nt.set(e,t,{path:o,domain:l?i:void 0,expires:d,sameSite:r,secure:a})}}function $n(e){const t=window.location.hostname.split("."),n=null==e?void 0:e.split(".");return t.slice(-(null==n?void 0:n.length)).join(".")===e}const kn=e=>(null==e?void 0:e.cookieName)||gn,Cn=e=>(null==e?void 0:e.cookieName)||mn;function Sn(e="",t){return Nt.get(Cn(t))||dn(`${e}${mn}`)||""}function In(e="",t){return Nt.get(kn(t))||dn(`${e}${gn}`)||""}function Rn(e=""){return dn(`${e}${yn}`)||""}function En(e="",t,n,i){ln(`${e}${mn}`),ln(`${e}${gn}`),ln(`${e}${yn}`),ln(`${e}${bn}`);const o=kn(t);Nt.remove(o,null==i?void 0:i.session);const r=Cn(n);Nt.remove(r,null==i?void 0:i.refresh)}const xn=(e,t,n)=>i=>{const o=Object.assign(i,{token:i.token||Sn(e,t)});if(!n){const t=function(e=""){return dn(`${e}${bn}`)}(e);t&&(o.headers=Object.assign(Object.assign({},o.headers||{}),{"x-descope-refresh-cookie-name":t}))}const r=function(e=""){return dn(`${e}DTD`)||""}(e);r&&(o.headers=Object.assign(Object.assign({},o.headers||{}),{"x-descope-trusted-device-token":r}));const s=function(e=""){return dn(`${e}DKD`)||""}(e);return s&&(o.headers=Object.assign(Object.assign({},o.headers||{}),{"x-descope-known-device-token":s})),o},On=Vt&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",An="vsid",Nn="vrid",jn="fp",Mn=(e=!1)=>{const t=dn(jn);if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},Pn=async(e,t=On)=>{try{if(Mn())return;const n=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),i=new URL(t);i.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const o=new URL(t);o.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const r=o.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",s=Ft({apiKey:e,endpoint:[i.toString(),jt],scriptUrlPattern:[r,Dt]}),a=await s,{requestId:d}=await a.get({linkedId:n}),l=((e,t)=>({[An]:e,[Nn]:t}))(n,d);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};an(jn,JSON.stringify(t))})(l)}catch(e){console.warn("Could not load fingerprint",e)}},Tn=e=>{const t=Mn(!0);return t&&e.body&&(e.body.fpData=t),e},Wn="descopeFlowNonce",Ln="X-Descope-Flow-Nonce",Un="/v1/flow/start",Dn="/v1/flow/next",Fn=(e,t=Wn)=>`${t}${e}`,_n=(e,t=Wn)=>{try{const n=Fn(e,t),i=dn(n);if(!i)return null;const o=JSON.parse(i);return o.expiry<Date.now()?(qn(e,t),null):{value:o.value,seq:o.seq}}catch(e){return console.error("Error getting flow nonce:",e),null}},qn=(e,t=Wn)=>{try{const n=Fn(e,t);ln(n)}catch(e){console.error("Error removing flow nonce:",e)}},Bn=e=>{var t;return(null===(t=/.*\|#\|(.*)/.exec(e))||void 0===t?void 0:t[1])||null},Vn=e=>{var t;return e.path===Dn&&(null===(t=e.body)||void 0===t?void 0:t.executionId)?Bn(e.body.executionId):null},Kn="dls_last_user_login_id",Hn="dls_last_user_display_name",zn=e=>an(Kn,e),Jn=()=>dn(Kn),Gn=()=>dn(Hn),Zn=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,i={}]=t,o=Jn(),r=Gn();return o&&(null!==(n=i.lastAuth)&&void 0!==n||(i.lastAuth={}),i.lastAuth.loginId=o,i.lastAuth.name=r),await e(...t)},Yn="DSLI",Xn=e=>async(...t)=>{const n=await e(...t);return hn(Yn),n};function Qn(){const e=[];return{pub:t=>{e.forEach((e=>e(t)))},sub:t=>{const n=e.push(t)-1;return()=>e.splice(n,1)}}}async function ei(e,t){const n=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=ai(n.publicKey.challenge),n.publicKey.user.id=ai(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=ai(e.id)})),n}(e);t&&(n.signal=t.signal);try{return i=await navigator.credentials.create(n),JSON.stringify({id:i.id,rawId:di(i.rawId),type:i.type,response:{attestationObject:di(i.response.attestationObject),clientDataJSON:di(i.response.clientDataJSON)}})}catch(e){throw await ii(e,n,!0)}var i}async function ti(e,t){const n=ri(e);t&&(n.signal=t.signal);try{return si(await navigator.credentials.get(n))}catch(e){throw await ii(e,n,!1)}}async function ni(e,t){const n=ri(e);n.signal=t.signal,n.mediation="conditional";try{return si(await navigator.credentials.get(n))}catch(e){throw await ii(e,n,!1)}}async function ii(e,t,n){if(e&&"object"==typeof e)try{e.reason=await async function(e,t,n){var i,o;const r=null==e?void 0:e.name;if("AbortError"===r&&(null==t?void 0:t.signal)instanceof AbortSignal)return"aborted";if("InvalidStateError"===r&&n)return"authenticator_already_registered";if("NotSupportedError"===r)return"no_supported_algorithm";if("ConstraintError"===r)return"authenticator_constraints_unsupported";if("SecurityError"===r){const e=window.location.hostname;return"localhost"===e||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)?"invalid_rpid":"invalid_domain"}if(!await oi())return"webauthn_unsupported";const s="platform"===(null===(o=null===(i=null==t?void 0:t.publicKey)||void 0===i?void 0:i.authenticatorSelection)||void 0===o?void 0:o.authenticatorAttachment);return n&&s&&!await oi(!0)?"platform_authenticator_unsupported":"NotAllowedError"===r?"not_allowed":"unknown"}(e,t,n)}catch(e){}return e}async function oi(e=!1){var t,n;if(!Vt)return Promise.resolve(!1);if(on()){const e=null===(n=null===(t=window.descopeBridge)||void 0===t?void 0:t.hostInfo)||void 0===n?void 0:n.webauthn;if("boolean"==typeof e)return e}const i=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return i&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():i}function ri(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=ai(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=ai(e.id)})),n}function si(e){return JSON.stringify({id:e.id,rawId:di(e.rawId),type:e.type,response:{authenticatorData:di(e.response.authenticatorData),clientDataJSON:di(e.response.clientDataJSON),signature:di(e.response.signature),userHandle:e.response.userHandle?di(e.response.userHandle):void 0}})}function ai(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function di(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var li,ci=(li=e=>({async signUp(t,n,i){const o=await e.webauthn.signUp.start(t,window.location.origin,n,i);if(!o.ok)return o;const r=await ei(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,r)},async signIn(t,n){const i=await e.webauthn.signIn.start(t,window.location.origin,void 0,void 0,n);if(!i.ok)return i;const o=await ti(i.data.options);return await e.webauthn.signIn.finish(i.data.transactionId,o)},async signUpOrIn(t,n){var i;const o=await e.webauthn.signUpOrIn.start(t,window.location.origin,n);if(!o.ok)return o;if(null===(i=o.data)||void 0===i?void 0:i.create){const t=await ei(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,t)}{const t=await ti(o.data.options);return await e.webauthn.signIn.finish(o.data.transactionId,t)}},async update(t,n,i){const o=await e.webauthn.update.start(t,window.location.origin,n,i);if(!o.ok)return o;const r=await ei(o.data.options);return await e.webauthn.update.finish(o.data.transactionId,r)},helpers:{create:ei,get:ti,isSupported:oi,conditional:ni}}),(...e)=>{const t=li(...e);return Object.assign(t.signUp,e[0].webauthn.signUp),Object.assign(t.signIn,e[0].webauthn.signIn),Object.assign(t.signUpOrIn,e[0].webauthn.signUpOrIn),Object.assign(t.update,e[0].webauthn.update),t});const ui="/fedcm/config";async function hi(e,t){var n;try{await fi(e,t)}catch(e){null===(n=null==t?void 0:t.onFailed)||void 0===n||n.call(t,e)}}async function fi(e,t){var n,i;const o=await async function(e,t="google",n,i,o){const r=(()=>{if(window.crypto&&window.crypto.getRandomValues){const e=new Uint8Array(16);return window.crypto.getRandomValues(e),Array.from(e,(e=>e.toString(16).padStart(2,"0"))).join("")}return Math.random().toString(36).substring(2)})(),s=await async function(){return new Promise(((e,t)=>{if(window.google)return void e(window.google.accounts.id);let n=document.getElementById("google-gsi-client-script");n||(n=document.createElement("script"),document.head.appendChild(n),n.async=!0,n.defer=!0,n.id="google-gsi-client-script",n.src="https://accounts.google.com/gsi/client"),n.onload=function(){window.google?e(window.google.accounts.id):t("Failed to load Google GSI client script - not loaded properly")},n.onerror=function(){t("Failed to load Google GSI client script - failed to load")}}))}(),a=await e.oauth.getOneTapClientId(t);if(!a.ok)throw new Error("Failed to get OneTap client ID for provider "+t);const d=a.data.clientId;return new Promise((e=>{var a,l;const c=n=>{e({provider:t,nonce:r,credential:null==n?void 0:n.credential})};s.initialize(Object.assign(Object.assign({},n),{itp_support:null===(a=null==n?void 0:n.itp_support)||void 0===a||a,use_fedcm_for_prompt:null===(l=null==n?void 0:n.use_fedcm_for_prompt)||void 0===l||l,client_id:d,callback:c,nonce:r})),s.prompt((e=>{var t,n;if(o&&(null==e?void 0:e.isDismissedMoment())){const n=null===(t=e.getDismissedReason)||void 0===t?void 0:t.call(e);return null==o||o(n),void c()}if(i&&(null==e?void 0:e.isSkippedMoment())){const t=null===(n=e.getSkippedReason)||void 0===n?void 0:n.call(e);return null==i||i(t),void c()}}))}))}(e,t.provider,t.oneTapConfig,t.onSkipped,t.onDismissed);if(!o.credential)return null;if(null==t?void 0:t.onCodeReceived){const i=await e.oauth.verifyOneTapIDToken(o.provider,o.credential,o.nonce,null==t?void 0:t.loginOptions);if(!i.ok||!i.data)throw new Error("Failed to verify OneTap client ID for provider "+o.provider);null===(n=null==t?void 0:t.onCodeReceived)||void 0===n||n.call(t,i.data.code)}else{const n=await e.oauth.exchangeOneTapIDToken(o.provider,o.credential,o.nonce,null==t?void 0:t.loginOptions);if(!n.ok||!n.data)throw new Error("Failed to exchange OneTap client ID for provider "+o.provider);null===(i=null==t?void 0:t.onAuthenticated)||void 0===i||i.call(t,n.data)}}var pi=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await oi(),i=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return t[1]=i,e.flow.start(...t)}});let vi;const gi=(e,t)=>new Promise(((n,i)=>{if(!e.length)return i(new Error("No URLs provided to loadScriptWithFallback"));const o=t();if(o)return n(o);const r=e.shift(),s=document.createElement("script");s.src=r,s.id=(e=>{let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t).toString(16)})(r),s.onload=()=>{const e=t();if(e)return n(e);throw new Error("Could not get entry after loading script from URL")},s.addEventListener("error",(()=>{gi(e,t),s.setAttribute("data-error","true")})),document.body.appendChild(s)})),mi=(e,t,n)=>{const i=async()=>{let i,o;return i&&o||({client:i,stateUserKey:o}=await(async(e,t,n)=>{vi||(vi=(async()=>{try{return require("oidc-client-ts")}catch(e){return gi([zt,Jt],(()=>window.oidc))}})());const{OidcClient:i,WebStorageStateStore:o}=await vi;if(!i)throw new Error("oidc-client-ts is not installed. Please install it by running `npm install oidc-client-ts`");const r=(null==n?void 0:n.redirectUri)||window.location.href;let s,a,d,l;if(null==n?void 0:n.issuer){if(!n.clientId)throw new Error("clientId is required when providing a custom issuer/authority");s=n.issuer,a=n.clientId,d=`${a}_user`,l="openid"}else(null==n?void 0:n.applicationId)?(s=e.httpClient.buildUrl(t),s=`${s}/${n.applicationId}`,a=t,d=`${a}_user`,l="openid email roles descope.custom_claims offline_access"):(s=e.httpClient.buildUrl(t),a=t,d=`${a}_user`,l="openid email roles descope.custom_claims offline_access");const c={authority:s,client_id:a,redirect_uri:r,response_type:"code",scope:(null==n?void 0:n.scope)||l,stateStore:new o({store:window.localStorage,prefix:a}),loadUserInfo:!0,fetchRequestCredentials:"same-origin"};return(null==n?void 0:n.redirectUri)&&(c.redirect_uri=n.redirectUri),{client:new i(c),stateUserKey:d}})(e,t,n)),{client:i,stateUserKey:o}},o=async(t="")=>{var n;const{client:o,stateUserKey:r}=await i(),s=await o.processSigninResponse(t||window.location.href);var a;return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(s)))),an(r,JSON.stringify({id_token:(a=s).id_token,session_state:a.session_state,profile:a.profile})),(()=>{const e=new URL(window.location.href);e.searchParams.delete("code"),e.searchParams.delete("state"),window.history.replaceState({},document.title,e.toString())})(),s};return{loginWithRedirect:async(t={},n=!1)=>{var o;const{client:r}=await i(),s=await r.createSigninRequest(t),{url:a}=s;return n||(await(null===(o=e.httpClient.hooks)||void 0===o?void 0:o.afterRequest({},new Response(JSON.stringify(s)))),window.location.href=a),{ok:!0,data:s}},finishLogin:o,finishLoginIfNeed:async(e="")=>{if(window.location.search.includes("code")&&window.location.search.includes("state"))return await o(e)},refreshToken:async t=>{var n;const{client:o,stateUserKey:r}=await i(),s=(e=>{const t=dn(e);return t?JSON.parse(t):null})(r);if(!s)throw new Error("User not found in storage to refresh token");let a=t;if(!a){const t={};e.httpClient.hooks.beforeRequest(t),a=t.token}const d=await o.useRefreshToken({state:{refresh_token:a,session_state:s.session_state,profile:s.profile}});return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(d)))),d},logout:async(e,t=!1)=>{const{client:n,stateUserKey:o}=await i();e||(e={}),e.id_token_hint=e.id_token_hint||Rn(),e.post_logout_redirect_uri=e.post_logout_redirect_uri||window.location.href;const r=await n.createSignoutRequest(e),{url:s}=r;return ln(o),t||window.location.replace(s),r}}},yi=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>t=>{var n;return n=t.customStorage,Zt=n,e(t)}),(e=>t=>{var{fpKey:n,fpLoad:i}=t,o=l(t,["fpKey","fpLoad"]);return Vt?(n&&i&&Pn(n).catch((()=>null)),e(tn(o,{beforeRequest:Tn}))):e(o)}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.54.7"},t.baseHeaders)}))),(e=>t=>{const n=Qn(),i=Qn(),o=Qn(),r=Qn(),s=e(tn(t,{afterRequest:async(e,t)=>{if(rn(e,t))fn("Session invalidated, notifying subscribers with empty values"),i.pub(null),o.pub(null),n.pub(null),r.pub(null);else{const e=await(async e=>{const t=await nn(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)})(t);e&&o.pub(e);const{sessionJwt:s,sessionExpiration:a,claims:d}=await nn(t);s&&i.pub(s),d&&r.pub(d),(a||s)&&n.pub(a||42)}}})),a=pe(s,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const s=await e(...t);return i.pub(null),o.pub(null),n.pub(null),r.pub(null),s}));return Object.assign(a,{onSessionTokenChange:i.sub,onUserChange:o.sub,onClaimsChange:r.sub,onIsAuthenticatedChange:e=>n.sub((t=>{e(!!t)}))})}),(e=>t=>{var n;const{enableFlowNonce:i=!0,nonceStoragePrefix:o=Wn}=t,r=l(t,["enableFlowNonce","nonceStoragePrefix"]);if(!i)return e(r);((e=Wn)=>{try{if(!sn)return;for(let o=0;o<(void 0,n=void 0,void 0,null!==(i=null!==(t=null==Zt?void 0:Zt.length)&&void 0!==t?t:Vt&&(null===(n=window.localStorage)||void 0===n?void 0:n.length))&&void 0!==i?i:0);o++){const t=cn(o);if(t&&t.startsWith(e)){const n=dn(t);if(n)try{JSON.parse(n).expiry<Date.now()&&ln(t)}catch(e){ln(t)}}}}catch(e){console.error("Error cleaning up expired nonces:",e)}var t,n,i})(o);const s=e(tn(r,{afterRequest:async(e,t)=>{var n;if(e.path!==Un&&e.path!==Dn)return;const{nonce:i,seq:r,executionId:s}=await(async(e,t)=>{try{const n=t.headers.get(Ln),i=null===n?void 0:(e=>{const t=e.indexOf(".");if(t<=0)return;const n=e.slice(0,t);if(!/^\d+$/.test(n))return;const i=Number(n);return Number.isSafeInteger(i)?i:void 0})(n);let o=await t.clone().json().then((e=>(null==e?void 0:e.executionId)||null)).catch((()=>null));return o||(o=Vn(e)),{nonce:n,seq:i,executionId:Bn(o)}}catch(e){return{nonce:null,seq:void 0,executionId:null}}})(e,t);if(!i||!s)return;const a=e.path===Un,d=null===(n=_n(s,o))||void 0===n?void 0:n.seq;!a&&void 0!==r&&void 0!==d&&r<=d||((e,t,n,i=Wn,o)=>{try{const r=Fn(e,i),s=n?172800:10800,a={value:t,expiry:Date.now()+1e3*s,isStart:n,seq:o};an(r,JSON.stringify(a))}catch(e){console.error("Error setting flow nonce:",e)}})(s,i,a,o,null!=r?r:a?void 0:d)},beforeRequest:e=>{if(e.path===Dn){const t=Vn(e);if(t){const n=((e,t=Wn)=>{var n,i;return null!==(i=null===(n=_n(e,t))||void 0===n?void 0:n.value)&&void 0!==i?i:null})(t,o);n&&(e.headers=e.headers||{},e.headers[Ln]=n)}}return e}}));if(null===(n=s.flow)||void 0===n?void 0:n.next){let e=Promise.resolve();const t=s.flow.next.bind(s.flow);s.flow.next=async(...n)=>{const i=e;let o;e=new Promise((e=>{o=e})),await i;try{return await t(...n)}finally{o()}}}return s}),(e=>t=>{const n=e(tn(t,{afterRequest:async(e,t)=>{if(rn(e,t))return void hn(Yn);const n=await nn(t);(null==n?void 0:n.sessionExpiration)&&((e,t)=>{var n,i;try{Vt&&(null===(i=null===(n=window.localStorage)||void 0===n?void 0:n.setItem)||void 0===i||i.call(n,e,t))}catch(e){}})(Yn,String(n.sessionExpiration))}}));return pe(n,["logout","logoutAll","oidc.logout"],Xn)}),(e=>t=>{var{autoRefresh:n}=t,i=l(t,["autoRefresh"]);const o=!!n,r="object"==typeof n&&(null==n?void 0:n.customActivityTracking);if(!o||on())return Object.assign(e(i),{markUserActive:()=>{pn("markUserActive() called but has no effect")}});const{clearAllTimers:s,setTimer:a}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let d,c,u=null,h=!1,f=!1;r&&(fn("Activity-based refresh enabled"),u=(()=>{let e=!0;return{hadActivity:()=>e,reset:()=>{e=!1},markActive:()=>{e=!0}}})()),Vt&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&d&&new Date>d&&(fn("Expiration time passed, refreshing session"),g())}));const p=e(tn(i,{afterRequest:async(e,t)=>{const{sessionJwt:n,refreshJwt:i,sessionExpiration:o,nextRefreshSeconds:r}=await nn(t);if(rn(e,t))fn("Session invalidated, canceling all timers"),s(),d=void 0;else if(n||o){if(d=((e,t)=>{if(t)return new Date(1e3*t);fn("Could not extract expiration time from session token, trying to decode the token");try{const t=v(e);if(t.exp)return new Date(1e3*t.exp)}catch(e){return null}})(n,o),!d)return void fn("Could not extract expiration time from session token");c=i,h=r>0;let e=((e,t)=>{let n;return t>0?(n=1e3*t,fn(`Using provided nextRefreshSeconds: ${t}s`)):n=vn(e)-Ht,n>Kt&&(fn(`Timeout is too large (${n}ms), setting it to ${Kt}ms`),n=Kt),n})(d,r);s(),e<=Ht&&(e=Math.max(vn(d),Ht));const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});fn(`Setting refresh timer for ${t}. (${e}ms)`),u&&(u.reset(),f=!1),a((()=>{if(Vt&&"hidden"===document.visibilityState)fn("Skipping refresh due to timer - document is hidden");else{if(u&&h&&!u.hadActivity())return fn("Skipping refresh due to timer - user is idle"),void(f=!0);fn("Refreshing session due to timer"),g()}}),e)}}})),g=()=>p.refresh(Sn()||c).catch((e=>{pn("Automatic session refresh failed",e)}));return Object.assign(pe(p,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const n=await e(...t);return fn("Clearing all timers"),s(),n})),{markUserActive:u?()=>{fn("markUserActive() called"),h||fn("markUserActive() called but server does not have inactivity timeout configured (no nextRefreshSeconds)"),u.markActive(),f&&(fn("User became active after skipped refresh, triggering refresh"),f=!1,s(),g())}:()=>{pn("markUserActive() called but customActivityTracking is not enabled — this call has no effect")}})}),(e=>t=>{var{storeLastAuthenticatedUser:n=!0,keepLastAuthenticatedUserAfterLogout:i=!1}=t,o=l(t,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!n)return Object.assign(e(o),{getLastUserLoginId:Jn,getLastUserDisplayName:Gn});const r=e(tn(o,{afterRequest:async(e,t)=>{var n;const{userInfo:i,lastAuth:o}=await(async e=>{if(!(null==e?void 0:e.ok))return{userInfo:void 0,lastAuth:void 0};const t=await(null==e?void 0:e.clone().json()),n=en((null==t?void 0:t.authInfo)||t||{});return{userInfo:(null==n?void 0:n.user)||((null==n?void 0:n.hasOwnProperty("userId"))?n:void 0),lastAuth:t.lastAuth}})(t),r=null===(n=null==i?void 0:i.loginIds)||void 0===n?void 0:n[0],s=null==i?void 0:i.name;r?(zn(r),(e=>{an(Hn,e)})(s)):(null==o?void 0:o.loginId)&&zn(o.loginId)}}));let s=pe(r,["flow.start"],Zn);return s=pe(s,["logout","logoutAll"],(e=>t=>async(...n)=>{const i=await t(...n);return e||(ln(Kn),ln(Hn)),i})(i)),Object.assign(s,{getLastUserLoginId:Jn,getLastUserDisplayName:Gn})}),(e=>t=>{var{persistTokens:n,sessionTokenViaCookie:i,refreshTokenViaCookie:o,storagePrefix:r,refreshCookieName:s}=t,a=l(t,["persistTokens","sessionTokenViaCookie","refreshTokenViaCookie","storagePrefix","refreshCookieName"]);if(!n||!Vt)return e(Object.assign({refreshCookieName:s},a));let d;const c=e(tn(Object.assign({refreshCookieName:s},a),{beforeRequest:xn(r,o,s),afterRequest:async(e,t)=>{if(rn(e,t))fn("Session invalidated, clearing persisted tokens"),En(r,i,o,d);else{const e=await nn(t);e.cookieName?an(`${r||""}${bn}`,e.cookieName):e.refreshJwt&&ln(`${r||""}${bn}`);const n=((e={},t=!1,n="",i=!1)=>{var o,r,s,a;const{sessionJwt:d,refreshJwt:l,trustedDeviceJwt:c,knownDeviceJwt:u}=e;let h;if(l)if(i){ln(`${n}${mn}`);const t=i.sameSite||"Strict",s=null===(o=i.secure)||void 0===o||o,a=null!==(r=i.domain)&&void 0!==r?r:e.cookieDomain,d=Cn(i);s&&"https:"!==window.location.protocol&&pn("Refresh token cookie is configured with secure=true but the page is not using HTTPS. The cookie will not be set. To fix this, pass refreshTokenViaCookie: { secure: process.env['NODE_ENV'] !== 'development' }");const c=Object.assign(Object.assign({},e),{cookieSameSite:t,cookieSecure:s,cookieDomain:a});wn(d,l,c);const u=$n(a);h=Object.assign(Object.assign({},h),{refresh:{path:c.cookiePath,domain:u?a:void 0}})}else{const e=Cn(i);Nt.remove(e),an(`${n}${mn}`,l)}if(d)if(t){const n=t.sameSite||"Strict",i=null===(s=t.secure)||void 0===s||s,o=null!==(a=t.domain)&&void 0!==a?a:e.cookieDomain,r=kn(t);i&&"https:"!==window.location.protocol&&pn("Session token cookie is configured with secure=true but the page is not using HTTPS. The cookie will not be set. To fix this, pass sessionTokenViaCookie: { secure: process.env['NODE_ENV'] !== 'development' }");const l=Object.assign(Object.assign({},e),{cookieSameSite:n,cookieSecure:i,cookieDomain:o});wn(r,d,l);const c=$n(o);h=Object.assign(Object.assign({},h),{session:{path:l.cookiePath,domain:c?o:void 0}})}else an(`${n}${gn}`,d);return e.idToken&&an(`${n}${yn}`,e.idToken),c&&an(`${n}DTD`,c),u&&an(`${n}DKD`,u),h})(e,i,r,o);n&&(d=n)}}})),u=pe(c,["logout","logoutAll","oidc.logout"],((e,t,n,i)=>o=>async(...r)=>{const s=await o(...r);return En(e,t,n,null==i?void 0:i()),s})(r,i,o,(()=>d)));return Object.assign(u,{getRefreshToken:()=>Sn(r,o),getSessionToken:()=>In(r,i),getIdToken:()=>Rn(r)})}))((e=>{const t=Ot(e),n=mi(t,e.projectId,e.oidcConfig);return Object.assign(Object.assign({},t),{refresh:async(i,o)=>{var r;if(on())return fn(`Refresh called in native flow: ${(new Error).stack}`),Promise.resolve({ok:!1,error:{errorCode:"J171000",errorDescription:"Refresh is not supported in native flows via the web SDK"}});if(e.oidcConfig)try{return await n.refreshToken(i),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161001",errorDescription:e.toString()}})}if(o&&Vt&&void 0!==window.localStorage&&!un(Yn)&&!dn(Kn)&&!un("DSLI_DISABLED"))return Promise.resolve({ok:!0});const s=In(),a=Sn();let d="";if(e.getExternalToken)try{d=await(null===(r=e.getExternalToken)||void 0===r?void 0:r.call(e))}catch(e){fn("Error getting external token while refreshing",e)}return t.refresh(i,{dcs:s?"t":"f",dcr:a?"t":"f"},d,o)},logout:async i=>{if(e.oidcConfig)try{return await n.logout({id_token_hint:i}),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161000",errorDescription:e.toString()}})}return t.logout(i)},flow:pi(t),webauthn:ci(t),fedcm:(i=t,o=e.projectId,{onetap:{requestExchangeCode(e){hi(i,e)},requestAuthentication(e){hi(i,e)}},async oneTap(e,t,n,o,r){await fi(i,{provider:e,oneTapConfig:t,loginOptions:n,onSkipped:o,onDismissed:r})},async launch(e){var t;const n={identity:{context:e||"signin",providers:[{configURL:i.httpClient.buildUrl(o+ui),clientId:o}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(n));return i.refresh(r.token)},isSupported:()=>Vt&&"IdentityCredential"in window,async isLoggedIn(e){var t;const n=i.httpClient.buildUrl(o+ui);try{const i={identity:{context:e||"signin",providers:[{configURL:n,clientId:o}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(i));return!!r&&!!r.token}catch(e){return!1}}}),oidc:n});var i,o}));let bi;const wi=e=>{const t=yi(Object.assign({persistTokens:a,autoRefresh:a},e));return bi=t,t},$i=()=>wi({projectId:"temp pid",persistTokens:!1,autoRefresh:!1,storeLastAuthenticatedUser:!1});bi=$i();const ki=()=>a?null==bi?void 0:bi.getSessionToken():(console.warn("Get session token is not supported in SSR"),""),Ci=()=>a?null==bi?void 0:bi.getRefreshToken():(console.warn("Get refresh token is not supported in SSR"),""),Si=o(((e=ki(),t)=>null==bi?void 0:bi.getJwtPermissions(e,t))),Ii=o(((e=ki(),t)=>null==bi?void 0:bi.getJwtRoles(e,t))),Ri=o(((e=ki())=>null==bi?void 0:bi.getCurrentTenant(e)));function Ei(...e){return t=>e.reduce(((e,t)=>t(e)),t)}const xi=e=>{const t=document.createElement("template");return t.innerHTML=e,t},Oi=(e,t)=>e.length===t.length&&e.every(((e,n)=>e===t[n])),Ai=e=>{let t,n;return(...i)=>(t&&Oi(t,i)||(t=i,n=e(...i)),n)},Ni=e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_.]+/g,"-").toLowerCase(),ji=e=>(t,...n)=>t.reduce(((t,i,o)=>{var r;return`${t}${i}${(null===(r=null==n?void 0:n[o])||void 0===r?void 0:r[e>1?1:0])||""}`}),""),Mi=(e,t=500)=>{let n;return function(...i){clearTimeout(n),n=setTimeout((()=>e.apply(this,i)),t)}},Pi=(e={})=>{const t=xi("<descope-wc></descope-wc>");return Object.entries(e).forEach((([e,n])=>{t.content.querySelector("descope-wc").setAttribute(Ni(e),(e=>"string"==typeof e?e:"boolean"==typeof e?String(e):(e=>null!==e&&"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype)(e)?JSON.stringify(e):"")(n))})),t},Ti=e=>{const t=Symbol((e=>{const t=e.toString();let n=0;for(let e=0;e<t.length;e++)n=(n<<5)-n+t.charCodeAt(e),n&=n;return n.toString(16)})(e));return n=>{if(n[t])return n;const i=e(n);return i[t]=!0,i}};var Wi,Li,Ui,Di;function Fi(e,t){const n=Object.getOwnPropertyNames(e),i=Object.getOwnPropertyNames(t);if(n.length!==i.length)return!1;for(let i=0;i<n.length;i+=1){const o=n[i],r=e[o],s=t[o];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!Fi(r,s))return!1}else if(r!==s)return!1}return!0}let _i=class{constructor(e={},{forceUpdate:t=!1}={}){Wi.set(this,void 0),Li.set(this,{}),Ui.set(this,0),Di.set(this,!0),this.update=e=>{const t="function"==typeof e?e(u(this,Wi,"f")):e,n=Object.assign(Object.assign({},u(this,Wi,"f")),t);if(u(this,Di,"f")||!Fi(u(this,Wi,"f"),n)){const e=u(this,Wi,"f");h(this,Wi,n,"f"),Object.freeze(u(this,Wi,"f")),setTimeout((()=>{Object.values(u(this,Li,"f")).forEach((t=>t(n,e,((e,t)=>n=>e[n]!==t[n])(n,e))))}),0)}},h(this,Wi,e,"f"),h(this,Di,t,"f")}get current(){return Object.assign({},u(this,Wi,"f"))}subscribe(e){return h(this,Ui,u(this,Ui,"f")+1,"f"),u(this,Li,"f")[u(this,Ui,"f")]=e,u(this,Ui,"f").toString()}unsubscribe(e){const t=!!u(this,Li,"f")[e];return t&&delete u(this,Li,"f")[e],t}unsubscribeAll(){return h(this,Li,{},"f"),!0}};Wi=new WeakMap,Li=new WeakMap,Ui=new WeakMap,Di=new WeakMap;const qi=["=","+","-","@","\t","\r"],Bi=e=>{const t=(e=>e.length>0&&qi.includes(e[0])?`'${e}`:e)(Array.isArray(e)?e.join("; "):String(null!=e?e:""));return t.includes(",")||t.includes('"')||t.includes("\n")||t.includes("\r")?`"${t.replace(/"/g,'""')}"`:t},Vi=e=>String(null!=e?e:"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;");function Ki(e){if(e)return{locale:e.toLowerCase(),fallback:e.toLowerCase()};const t=navigator.language;return t?t.includes("-")?{locale:t.toLowerCase(),fallback:t.split("-")[0].toLowerCase()}:{locale:t.toLowerCase(),fallback:t.toLowerCase()}:{locale:"",fallback:""}}const Hi=e=>"string"==typeof e||null==e?e:JSON.stringify(e),zi=e=>t.forwardRef(((n,i)=>{const{prop:o,attr:r,rest:s}=t.useMemo((()=>Object.entries(n).reduce(((e,[t,n])=>{const{trimmedKey:i,category:o}=(e=>{const[,t,n]=/(.*)\.(prop|attr)$/.exec(e)||[,e,"rest"];return{trimmedKey:t,category:n}})(t);return"prop"===o?e.prop.push([i,n]):"attr"===o?e.attr.push([Ni(i),Hi(n)]):Object.assign(e.rest,{[Ni(i)]:n}),e}),{attr:[],prop:[],rest:{}})),[n]),a=t.useRef(null),d=t.useCallback((e=>{a.current=e,e&&(o.forEach((([e,t])=>{a.current[e]=t})),r.forEach((([t,n])=>{null==n?e.removeAttribute(t):e.setAttribute(t,n)})))}),[o,r,a]);return t.useImperativeHandle(i,(()=>a.current)),t.createElement(e,Object.assign({ref:d},s))})),Ji=t.lazy((async()=>{var e;return((null===(e=globalThis.customElements)||void 0===e?void 0:e.get("descope-wc"))||await Promise.resolve().then((function(){return Mh})).then((e=>e.default))).sdkConfigOverrides={baseHeaders:s,persistTokens:!1,hooks:{get beforeRequest(){return bi.httpClient.hooks.beforeRequest},set beforeRequest(e){}}},{default:zi(t.forwardRef(((e,n)=>{var{"external-request-id":i}=e,o=l(e,["external-request-id"]);return t.useMemo((()=>{var e,t;e="x-external-rid",(t=i)?s[e]=t:delete s[e]}),[i]),t.createElement("descope-wc",Object.assign({ref:n},o))})))}})),Gi=t.forwardRef((({flowId:e,onSuccess:i,onError:o,onReady:r,logger:s,tenant:a,theme:d,nonce:l,locale:c,debug:u,client:h,form:f,telemetryKey:p,redirectUrl:v,autoFocus:g,validateOnBlur:m,restartOnError:y,sendSessionToken:b,errorTransformer:w,styleId:$,onScreenUpdate:k,dismissScreenErrorOnInput:C,outboundAppId:S,outboundAppScopes:I,popupOrigin:R,children:E,externalRequestId:x,themeOverride:O},A)=>{const[N,j]=t.useState(null);t.useImperativeHandle(A,(()=>N));const{projectId:M,baseUrl:P,baseStaticUrl:T,baseCdnUrl:W,storeLastAuthenticatedUser:L,keepLastAuthenticatedUserAfterLogout:U,refreshCookieName:D,customStorage:F,sdk:_}=t.useContext(n),q=t.useCallback((async e=>{await _.httpClient.hooks.afterRequest({},new Response(JSON.stringify(e.detail))),i&&i(e)}),[i]);return t.useEffect((()=>{const e=N;return null==e||e.addEventListener("success",q),o&&(null==e||e.addEventListener("error",o)),r&&(null==e||e.addEventListener("ready",r)),()=>{o&&(null==e||e.removeEventListener("error",o)),r&&(null==e||e.removeEventListener("ready",r)),null==e||e.removeEventListener("success",q)}}),[N,o,q]),t.useEffect((()=>{const e=N;return null==e||e.addEventListener("success",q),()=>{null==e||e.removeEventListener("success",q)}}),[N,q]),t.useEffect((()=>{const e=N;return o&&(null==e||e.addEventListener("error",o)),()=>{o&&(null==e||e.removeEventListener("error",o))}}),[N,o]),t.useEffect((()=>{const e=N;return r&&(null==e||e.addEventListener("ready",r)),()=>{r&&(null==e||e.removeEventListener("error",r))}}),[N,r]),t.createElement("form",null,t.createElement(t.Suspense,{fallback:null},t.createElement(Ji,{projectId:M,flowId:e,baseUrl:P,baseStaticUrl:T,baseCdnUrl:W,ref:j,telemetryKey:p,redirectUrl:v,autoFocus:g,styleId:$,validateOnBlur:m,restartOnError:y,keepLastAuthenticatedUserAfterLogout:U,tenant:a,externalRequestId:x,customStorage:F,themeOverride:O,"theme.attr":d,"nonce.attr":l,"locale.attr":c,"form.attr":f,"client.attr":h,"debug.attr":u,"outbound-app-id.attr":S,"outbound-app-scopes.attr":I,"popup-origin.attr":R,"store-last-authenticated-user.attr":L,"send-session-token.attr":b,"refreshCookieName.attr":D,"dismiss-screen-error-on-input.attr":C,"errorTransformer.prop":w,"logger.prop":s,"onScreenUpdate.prop":k,"customStorage.prop":F},E)))}));var Zi=()=>{const e=t.useContext(n);if(!e)throw Error("You can only use this hook in the context of <AuthProvider />");return e};const Yi=e=>`You can only use this ${e} after sdk initialization. Make sure to supply 'projectId' to <AuthProvider /> component`,Xi={get(e,t){if("object"==typeof e[t]&&null!==e[t])return new Proxy(e[t],Xi);if("function"==typeof e[t])return()=>{throw Error(Yi("function"))};throw Error(Yi("attribute"))}},Qi=t.lazy((async()=>(await Promise.resolve().then((function(){return Gf})),{default:zi(t.forwardRef(((e,n)=>t.createElement("descope-access-key-management-widget",Object.assign({ref:n},e)))))}))),eo=t.forwardRef((({logger:e,tenant:i,theme:o,locale:r,debug:s,widgetId:a,styleId:d,onReady:l},c)=>{const[u,h]=t.useState(null);t.useImperativeHandle(c,(()=>u));const{projectId:f,baseUrl:p,baseStaticUrl:v,baseCdnUrl:g,refreshCookieName:m}=t.useContext(n);return t.useEffect((()=>{const e=u;return l&&(null==e||e.addEventListener("ready",l)),()=>{l&&(null==e||e.removeEventListener("ready",l))}}),[u,l]),t.createElement(t.Suspense,{fallback:null},t.createElement(Qi,{ref:h,projectId:f,widgetId:a,tenant:i,baseUrl:p,baseStaticUrl:v,baseCdnUrl:g,"theme.attr":o,"locale.attr":r,"debug.attr":s,"styleId.attr":d,"refreshCookieName.attr":m,"logger.prop":e}))})),to=t.lazy((async()=>(await Promise.resolve().then((function(){return gp})),{default:zi(t.forwardRef(((e,n)=>t.createElement("descope-applications-portal-widget",Object.assign({ref:n},e)))))}))),no=t.forwardRef((({logger:e,theme:i,locale:o,debug:r,widgetId:s,styleId:a,onReady:d},l)=>{const[c,u]=t.useState(null);t.useImperativeHandle(l,(()=>c));const{projectId:h,baseUrl:f,baseStaticUrl:p,baseCdnUrl:v,refreshCookieName:g}=t.useContext(n);return t.useEffect((()=>{const e=c;return d&&(null==e||e.addEventListener("ready",d)),()=>{d&&(null==e||e.removeEventListener("ready",d))}}),[c,d]),t.createElement(t.Suspense,{fallback:null},t.createElement(to,{ref:u,projectId:h,widgetId:s,baseUrl:f,baseStaticUrl:p,baseCdnUrl:v,"theme.attr":i,"locale.attr":o,"debug.attr":r,"styleId.attr":a,"refreshCookieName.attr":g,"logger.prop":e}))})),io=t.lazy((async()=>(await Promise.resolve().then((function(){return Lp})),{default:zi(t.forwardRef(((e,n)=>t.createElement("descope-audit-management-widget",Object.assign({ref:n},e)))))}))),oo=t.forwardRef((({logger:e,tenant:i,theme:o,locale:r,debug:s,widgetId:a,styleId:d,onReady:l},c)=>{const[u,h]=t.useState(null);t.useImperativeHandle(c,(()=>u));const{projectId:f,baseUrl:p,baseStaticUrl:v,baseCdnUrl:g,refreshCookieName:m}=t.useContext(n);return t.useEffect((()=>{const e=u;return l&&(null==e||e.addEventListener("ready",l)),()=>{l&&(null==e||e.removeEventListener("ready",l))}}),[u,l]),t.createElement(t.Suspense,{fallback:null},t.createElement(io,{ref:h,projectId:f,widgetId:a,tenant:i,baseUrl:p,baseStaticUrl:v,baseCdnUrl:g,"theme.attr":o,"locale.attr":r,"debug.attr":s,"styleId.attr":d,"refreshCookieName.attr":m,"logger.prop":e}))})),ro=t.lazy((async()=>(await Promise.resolve().then((function(){return fv})),{default:zi(t.forwardRef(((e,n)=>t.createElement("descope-outbound-applications-widget",Object.assign({ref:n},e)))))}))),so=t.forwardRef((({logger:e,tenant:i,theme:o,locale:r,debug:s,widgetId:a,styleId:d,onReady:l,client:c,form:u},h)=>{const[f,p]=t.useState(null);t.useImperativeHandle(h,(()=>f));const{projectId:v,baseUrl:g,baseStaticUrl:m,baseCdnUrl:y,refreshCookieName:b}=t.useContext(n);return t.useEffect((()=>{const e=f;return l&&(null==e||e.addEventListener("ready",l)),()=>{l&&(null==e||e.removeEventListener("ready",l))}}),[f,l]),t.createElement(t.Suspense,{fallback:null},t.createElement(ro,{ref:p,projectId:v,widgetId:a,baseUrl:g,baseStaticUrl:m,baseCdnUrl:y,"tenant.attr":i,"theme.attr":o,"locale.attr":r,"debug.attr":s,"styleId.attr":d,"refreshCookieName.attr":b,"client.attr":c,"form.attr":u,"logger.prop":e}))})),ao=t.lazy((async()=>(await Promise.resolve().then((function(){return pg})),{default:zi(t.forwardRef(((e,n)=>t.createElement("descope-role-management-widget",Object.assign({ref:n},e)))))}))),lo=t.forwardRef((({logger:e,tenant:i,theme:o,locale:r,debug:s,widgetId:a,styleId:d,onReady:l},c)=>{const[u,h]=t.useState(null);t.useImperativeHandle(c,(()=>u));const{projectId:f,baseUrl:p,baseStaticUrl:v,baseCdnUrl:g,refreshCookieName:m}=t.useContext(n);return t.useEffect((()=>{const e=u;return l&&(null==e||e.addEventListener("ready",l)),()=>{l&&(null==e||e.removeEventListener("ready",l))}}),[u,l]),t.createElement(t.Suspense,{fallback:null},t.createElement(ao,{ref:h,projectId:f,widgetId:a,tenant:i,baseUrl:p,baseStaticUrl:v,baseCdnUrl:g,"theme.attr":o,"locale.attr":r,"debug.attr":s,"styleId.attr":d,"refreshCookieName.attr":m,"logger.prop":e}))})),co=t.lazy((async()=>(await Promise.resolve().then((function(){return am})),{default:zi(t.forwardRef(((e,n)=>t.createElement("descope-tenant-profile-widget",Object.assign({ref:n},e)))))}))),uo=t.forwardRef((({logger:e,theme:i,locale:o,debug:r,widgetId:s,styleId:a,tenant:d,onReady:l,client:c,form:u},h)=>{const[f,p]=t.useState(null);t.useImperativeHandle(h,(()=>f));const{projectId:v,baseUrl:g,baseStaticUrl:m,baseCdnUrl:y,refreshCookieName:b}=t.useContext(n);return t.useEffect((()=>{const e=f;return l&&(null==e||e.addEventListener("ready",l)),()=>{l&&(null==e||e.removeEventListener("ready",l))}}),[f,l]),t.createElement(t.Suspense,{fallback:null},t.createElement(co,{projectId:v,widgetId:s,baseUrl:g,baseStaticUrl:m,baseCdnUrl:y,styleId:a,tenant:d,ref:p,"theme.attr":i,"locale.attr":o,"debug.attr":r,"styleId.attr":a,"tenant.attr":d,"refreshCookieName.attr":b,"client.attr":c,"form.attr":u,"logger.prop":e}))})),ho=t.lazy((async()=>(await Promise.resolve().then((function(){return EC})),{default:zi(t.forwardRef(((e,n)=>t.createElement("descope-user-management-widget",Object.assign({ref:n},e)))))}))),fo=t.forwardRef((({logger:e,tenant:i,theme:o,locale:r,debug:s,widgetId:a,styleId:d,onReady:l,client:c,form:u},h)=>{const[f,p]=t.useState(null);t.useImperativeHandle(h,(()=>f));const{projectId:v,baseUrl:g,baseStaticUrl:m,baseCdnUrl:y,refreshCookieName:b}=t.useContext(n);return t.useEffect((()=>{const e=f;return l&&(null==e||e.addEventListener("ready",l)),()=>{l&&(null==e||e.removeEventListener("ready",l))}}),[f,l]),t.createElement(t.Suspense,{fallback:null},t.createElement(ho,{projectId:v,widgetId:a,tenant:i,baseUrl:g,baseStaticUrl:m,baseCdnUrl:y,ref:p,"theme.attr":o,"locale.attr":r,"debug.attr":s,"styleId.attr":d,"refreshCookieName.attr":b,"client.attr":c,"form.attr":u,"logger.prop":e}))})),po=t.lazy((async()=>(await Promise.resolve().then((function(){return sI})),{default:zi(t.forwardRef(((e,n)=>t.createElement("descope-user-profile-widget",Object.assign({ref:n},e)))))}))),vo=t.forwardRef((({logger:e,theme:i,locale:o,debug:r,widgetId:s,onLogout:a,onFlowPopupUnauthenticated:d,styleId:l,onReady:c,client:u,form:h},f)=>{const[p,v]=t.useState(null);t.useImperativeHandle(f,(()=>p));const{projectId:g,baseUrl:m,baseStaticUrl:y,baseCdnUrl:b,refreshCookieName:w,sessionTokenViaCookie:$,refreshTokenViaCookie:k,setSession:C,setUser:S,setIsAuthenticated:I}=t.useContext(n),R=t.useCallback((e=>{a&&a(e),I(!1),C(""),S(null)}),[a,C,I,S]);return t.useEffect((()=>{if(p)return p.addEventListener("logout",R),()=>p.removeEventListener("logout",R)}),[p,R]),t.useEffect((()=>{const e=p;if(e&&d)return e.addEventListener("flow-popup-unauthenticated",d),()=>e.removeEventListener("flow-popup-unauthenticated",d)}),[p,d]),t.useEffect((()=>{const e=p;return c&&(null==e||e.addEventListener("ready",c)),()=>{c&&(null==e||e.removeEventListener("ready",c))}}),[p,c]),t.createElement(t.Suspense,{fallback:null},t.createElement(po,{projectId:g,widgetId:s,baseUrl:m,baseStaticUrl:y,baseCdnUrl:b,styleId:l,ref:v,"theme.attr":i,"locale.attr":o,"debug.attr":r,"styleId.attr":l,"refreshCookieName.attr":w,"sessionTokenViaCookie.attr":$,"refreshTokenViaCookie.attr":k,"client.attr":u,"form.attr":h,"logger.prop":e}))})),go="undefined"!=typeof localStorage,mo="J151000",yo="E103205",bo="E108201",wo=go&&localStorage.getItem("base.content.url")||"",$o="base.ui.components.url";go&&localStorage.getItem($o),go&&localStorage.getItem($o);const ko="descope-login-flow",Co="code",So="redirect_mode",Io="err",Ro="data-exclude-field",Eo="data-exclude-next",xo="dls_last_auth",Oo="dls_last_submitted_login_id",Ao="dls_sso_run_",No="state_id",jo="saml_idp_state_id",Mo="wsfed_idp_state_id",Po="saml_idp_username",To="descope_idp_initiated",Wo="sso_app_id",Lo="custom_app_id",Uo="third_party_app_id",Do="third_party_app_state_id",Fo="oidc_login_hint",_o="oidc_prompt",qo="oidc_resource",Bo="oidc_error_redirect_uri",Vo="application_scopes",Ko="data-type",Ho="redirect",zo="poll",Jo="webauthnCreate",Go="webauthnGet",Zo="nativeBridge",Yo="loadForm",Xo="submit",Qo="polling",er=["descope-multi-select-combo-box","descope-text-area"],tr="dls_last_auth_in_flight",nr=["cssVars","componentsConfig","inputs","errorText","errorType","clientScripts","data","totp","notp","sentTo","sso","selfProvisionDomains"],ir=["hide","disable","read-only"],or="hidden";function rr(e,t){const n=e.closest(`.${or}`);return!!n&&n!==t}const sr=/(["\\])/g;function ar(e){return"undefined"!=typeof CSS&&"function"==typeof CSS.escape?CSS.escape(e):e.replace(sr,"\\$1")}function dr(e,t){return Array.from(e.querySelectorAll(`[id="${ar(t)}"]`))}function lr(e,t,n){return Object.keys(t).forEach((i=>{const o=t[i];n[i]!==o&&dr(e,i).forEach((e=>function(e,t){switch(t){case"hide":e.classList.remove(or);break;case"disable":e.removeAttribute("disabled");break;case"read-only":e.removeAttribute("readonly")}}(e,o)))})),Object.keys(n).forEach((i=>{const o=n[i],r=t[i];o!==r&&dr(e,i).forEach((e=>function(e,t){switch(t){case"hide":e.classList.add(or);break;case"disable":e.setAttribute("disabled","true");break;case"read-only":e.setAttribute("readonly","true")}}(e,o)))})),Object.assign({},n)}var cr;!function(e){e.backward="backward",e.forward="forward"}(cr||(cr={}));const ur=new Set,hr=(e,t)=>({origin:window.location.origin,pathname:window.location.pathname,hash:window.location.hash,projectId:e,flowId:t}),fr=(e,t)=>`dls_sso_query_params_${e}_${t}`,pr=e=>Object.values(null!=e?e:{}).some(Boolean),vr=Object.keys({oidcIdpStateId:!0,samlIdpStateId:!0,wsfedIdpStateId:!0,samlIdpUsername:!0,descopeIdpInitiated:!0,ssoAppId:!0,customAppId:!0,oidcLoginHint:!0,oidcPrompt:!0,oidcErrorRedirectUri:!0,oidcResource:!0,thirdPartyAppId:!0,thirdPartyAppStateId:!0,applicationScopes:!0}),gr=e=>vr.reduce(((t,n)=>(null==e?void 0:e[n])?Object.assign(t,{[n]:e[n]}):t),{}),mr=e=>{var t,n;const i=(null===(t=null==e?void 0:e.params)||void 0===t?void 0:t.oidcIdpStateId)&&(null===(n=null==e?void 0:e.params)||void 0===n?void 0:n.oidcErrorRedirectUri)?864e5:6e5;return Date.now()-e.ts<i},yr=()=>{var e,t,n;try{const[i]=null!==(n=null===(t=null===(e=window.performance)||void 0===e?void 0:e.getEntriesByType)||void 0===t?void 0:t.call(e,"navigation"))&&void 0!==n?n:[],o=i;if("reload"!==(null==o?void 0:o.type)||!o.name)return!1;const r=new URL(o.name,window.location.href);return r.origin===window.location.origin&&r.pathname===window.location.pathname&&r.hash===window.location.hash}catch(e){return!1}},br=(e,t)=>(null==e?void 0:e.origin)===t.origin&&(null==e?void 0:e.pathname)===t.pathname&&(null==e?void 0:e.hash)===t.hash&&(null==e?void 0:e.projectId)===t.projectId&&(null==e?void 0:e.flowId)===t.flowId,wr=(e,t,n,i=Date.now())=>{var o;if(pr(e))try{const r={params:e,scope:hr(t,n),ts:i};null===(o=window.sessionStorage)||void 0===o||o.setItem(fr(t,n),JSON.stringify(r))}catch(e){}},$r=(e,t)=>{var n;try{const i=null===(n=window.sessionStorage)||void 0===n?void 0:n.getItem(fr(e,t));if(!i)return;const o=JSON.parse(i);return br(null==o?void 0:o.scope,hr(e,t))?o.ts:void 0}catch(e){return}},kr=e=>`${Ao}${e}`,Cr=()=>{var e;return null!==(e=window.localStorage)&&void 0!==e?e:null},Sr=()=>{try{const e=Cr();if(!e)return;const t=[];for(let n=0;n<e.length;n+=1){const i=e.key(n);(null==i?void 0:i.startsWith(Ao))&&t.push(i)}t.forEach((t=>{let n=!0;try{n=!mr(JSON.parse(e.getItem(t)))}catch(t){}n&&e.removeItem(t)}))}catch(e){}},Ir=(e,t)=>{var n,i;try{const o=null===(n=window.sessionStorage)||void 0===n?void 0:n.getItem(fr(e,t));if(!o)return;const r=JSON.parse(o);br(null==r?void 0:r.scope,hr(e,t))&&(null===(i=window.sessionStorage)||void 0===i||i.removeItem(fr(e,t)))}catch(e){}},Rr=(e,t)=>Ir(e,t),Er=["descope-enriched-text"];function xr(e){return new URLSearchParams(window.location.search).get(e)}function Or(e){if(window.history.replaceState&&xr(e)){const t=new URL(window.location.href),n=new URLSearchParams(t.search);n.delete(e),t.search=n.toString(),window.history.replaceState({},"",t.toString())}}const Ar=e=>{var t;return(null===(t=/.*\|#\|(.*)/.exec(e))||void 0===t?void 0:t[1])||""};function Nr(e,t){if(!t)return;const n=+e,i=+t;return Number.isNaN(n)||Number.isNaN(i)?void 0:n>i?cr.forward:n<i?cr.backward:void 0}const jr=e=>{let[t="",n=""]=(xr(ko)||"").split("_");const i=(e=>{var t;return(null===(t=/(.*)\|#\|.*/.exec(e))||void 0===t?void 0:t[1])||""})(t);return(!e||i&&i!==e)&&(t="",n=""),{executionId:t,stepId:n,executionFlowId:i}};function Mr(){Or(ko)}function Pr(e){try{const{origin:t}=new URL(e);return"null"===t?void 0:t}catch(e){return}}const Tr=e=>e.replace(/-./g,(e=>e[1].toUpperCase())),Wr=(e,t,n)=>{const{executionId:i,stepId:o,executionFlowId:r}=jr(e);if(r&&e!==r)return n.debug("Flow id does not match the execution flow id, skipping url params handling"),{ssoQueryParams:{}};(i||o)&&Mr();const s=xr("t")||void 0;s&&Or("t");const a=xr(Co)||void 0;a&&Or(Co);const d="popup"===xr(So);d&&Or(So);const l=xr(Io)||void 0;l&&Or(Io);const{redirectAuthCodeChallenge:c,redirectAuthCallbackUrl:u,redirectAuthBackupCallbackUri:h,redirectAuthInitiator:f}={redirectAuthCodeChallenge:xr("ra-challenge"),redirectAuthCallbackUrl:xr("ra-callback"),redirectAuthBackupCallbackUri:xr("ra-backup-callback"),redirectAuthInitiator:xr("ra-initiator")},p=xr(No);p&&Or(No);const v=xr(jo);v&&Or(jo);const g=xr(Mo);g&&Or(Mo);const m=xr(Po);v&&Or(Po);const y=xr(To);y&&Or(To);const b=xr(Wo);b&&Or(Wo);const w=xr(Lo);w&&Or(Lo);const $=xr(Uo);$&&Or(Uo);const k=xr(Do);k&&Or(Do);const C=xr(Vo);C&&Or(Vo);const S=xr(Fo);S&&Or(Fo);const I=xr(_o);I&&Or(_o);const R=xr(Bo);R&&Or(Bo);const E=xr(qo);E&&Or(qo);const x={oidcIdpStateId:p,samlIdpStateId:v,wsfedIdpStateId:g,samlIdpUsername:m,descopeIdpInitiated:"true"===y,ssoAppId:b,customAppId:w,oidcLoginHint:S,oidcPrompt:I,oidcErrorRedirectUri:R,oidcResource:E,thirdPartyAppId:$,thirdPartyAppStateId:k,applicationScopes:C},O=((e,t)=>{const n=[(i=hr(e,t)).origin,i.pathname,i.hash,i.projectId,i.flowId].join("|");var i;return!ur.has(n)&&(ur.add(n),!0)})(t,e);let A=x,N=null;if(Sr(),pr(x))wr(x,t,e);else if(i)N=((e,t,n)=>{var i;if(!e)return null;try{const o=null===(i=Cr())||void 0===i?void 0:i.getItem(kr(e));if(!o)return null;const r=JSON.parse(o),s=gr(null==r?void 0:r.params);return(null==r?void 0:r.projectId)===t&&pr(s)&&mr(r)?(wr(s,t,n,r.ts),s):null}catch(e){return null}})(Ar(i),t,e);else if(!r){const i=O?((e,t)=>{var n;if(!yr())return null;try{const i=null===(n=window.sessionStorage)||void 0===n?void 0:n.getItem(fr(e,t));if(!i)return null;const o=JSON.parse(i);return br(null==o?void 0:o.scope,hr(e,t))&&mr(o)?o.params:null}catch(e){return null}})(t,e):null;i?(n.debug("Restored SSO query params after a page reload"),A=i):((e,t)=>{yr()||Ir(e,t)})(t,e)}return{executionId:i,stepId:o,token:s,code:a,isPopup:d,exchangeError:l,redirectAuthCodeChallenge:c,redirectAuthCallbackUrl:u,redirectAuthBackupCallbackUri:h,redirectAuthInitiator:f,ssoQueryParams:A,adoptedSsoQueryParams:N}},Lr=e=>{let t,n;return Object.assign(((...i)=>{return t&&(r=i,(o=t).length===r.length&&o.every(((e,t)=>e===r[t])))||(t=i,n=e(...i)),n;var o,r}),{reset:()=>{t=void 0,n=void 0}})},Ur=(e,t,n)=>{if(!0===t||"skipFirstScreen"===t&&!n){const t=Array.from(e.querySelectorAll('*[name]:not([auto-focus="false"]):not([aria-hidden="true"])')).find((t=>!rr(t,e)));setTimeout((()=>{null==t||t.focus()}))}};function Dr(e,t,n){return new Promise(((i,o)=>{let r=!1;const s=setTimeout((()=>{r=!0,void 0!==n?i(n):o(new Error(`Promise timed out after ${e} ms`))}),e);t.then((e=>{r||(clearTimeout(s),i(e))})).catch((e=>{r||(clearTimeout(s),o(e))}))}))}const Fr=(e,{oidcIdpStateId:t,samlIdpStateId:n,wsfedIdpStateId:i,samlIdpUsername:o,ssoAppId:r,customAppId:s,oidcLoginHint:a,oidcPrompt:d,oidcErrorRedirectUri:l,oidcResource:c,thirdPartyAppId:u,thirdPartyAppStateId:h,applicationScopes:f})=>!(!e||t||n||i||o||r||s||a||d||l||c||u||h||f),_r=(e,t,n)=>{const i=document.createElement("input");return i.type="hidden",i.name=e,i.value=t,n&&i.setAttribute("role",n),i},qr=e=>null==e?void 0:e.submit(),Br=(e,t)=>{const n=t.find((t=>e[t]));return n?e[n]:null},Vr=(e,t=100)=>{let n;return function(...i){n||e.apply(this,i),clearTimeout(n),n=setTimeout((()=>{n=null}),t)}},Kr={minLength:"data-password-policy-value-minlength",strength:"data-password-policy-value-passwordstrength",disallowedChars:"data-password-policy-value-disallowedchars",email:"data-password-policy-value-email",reuse:"data-password-policy-value-reuse",activePolicies:"active-policies",availablePolicies:"available-policies"},Hr=(e,t)=>{var n;const i=null==e?void 0:e.componentsDynamicAttrs;if(!i)return;const o=Object.entries(i).find((([e])=>(e=>{var t;return null===(t=e.match(/\[data-name=["']([^"']+)["']\]/))||void 0===t?void 0:t[1]})(e)===t));return null===(n=null==o?void 0:o[1])||void 0===n?void 0:n.attributes},zr=[{key:"totp",from:e=>e.totp},{key:"notp",from:e=>e.notp},{key:"sentTo",from:e=>e.sentTo},{key:"sso",from:e=>e.sso},{key:"selfProvisionDomains",from:e=>e.selfProvisionDomains},{key:"inboundAppApproveScopes",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.thirdPartyAppApproveScopes)||void 0===n?void 0:n.data}},{key:"securityQuestionsSetup",from:e=>{var t;return null===(t=e.componentsConfig)||void 0===t?void 0:t.sqSetup}},{key:"securityQuestionsVerify",from:e=>{var t;return null===(t=e.componentsConfig)||void 0===t?void 0:t.sqVerify}},{key:"userTenants",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.userSelectedTenant)||void 0===n?void 0:n.data}},{key:"userRoles",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.userRoles)||void 0===n?void 0:n.data}},{key:"ssoApplications",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.ssoApplications)||void 0===n?void 0:n.data}},{key:"ssoConfigurations",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.ssoConfigurations)||void 0===n?void 0:n.data}},{key:"samlAttributeMappings",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.samlMappings)||void 0===n?void 0:n.options}},{key:"oidcAttributeMappings",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.oidcMappings)||void 0===n?void 0:n.options}},{key:"samlGroupMappings",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.samlGroupMappings)||void 0===n?void 0:n.options}},{key:"passwordPolicy",from:e=>{var t;return(e=>{if(!e)return;const t=Object.fromEntries(Object.entries(Kr).map((([t,n])=>[t,e[n]])).filter((([,e])=>void 0!==e)));return Object.keys(t).length?t:void 0})(null===(t=e.componentsConfig)||void 0===t?void 0:t.newPassword)}},{key:"recoveryCodes",from:e=>(e=>{const t=Hr(e,"recoveryCodes");if(t)return Array.isArray(t.data)?t.data.map((e=>e.value)):[]})(e.componentsConfig)},{key:"outboundApp",from:e=>(e=>{const t=Hr(e,"outboundApp");if(t)return{label:t.label,iconSrc:t["icon-src"],appId:t["data-descope-outbound-oauth-app-id"]}})(e.componentsConfig)}],Jr=e=>{const t=Object.assign({},e);return e.inboundAppApproveScopes&&(t.thirdPartyAppApproveScopes=e.inboundAppApproveScopes),t};function Gr(e,t){return`sdkScriptsResults.${t?`${e}_${t}`:e}`}var Zr,Yr,Xr,Qr;function es(e,t){const n=Object.getOwnPropertyNames(e),i=Object.getOwnPropertyNames(t);if(n.length!==i.length)return!1;for(let i=0;i<n.length;i+=1){const o=n[i],r=e[o],s=t[o];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!es(r,s))return!1}else if(r!==s)return!1}return!0}let ts=class{constructor(e={},{forceUpdate:t=!1}={}){Zr.set(this,void 0),Yr.set(this,{}),Xr.set(this,0),Qr.set(this,!0),this.update=e=>{const t="function"==typeof e?e(u(this,Zr,"f")):e,n=Object.assign(Object.assign({},u(this,Zr,"f")),t),i=u(this,Zr,"f");h(this,Zr,n,"f"),Object.freeze(u(this,Zr,"f")),setTimeout((()=>{Object.values(u(this,Yr,"f")).forEach((({cb:e,selector:t,forceUpdate:o})=>{const r=t(i),s=t(n);(u(this,Qr,"f")||o||(function(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}(s)?!es(r,s):r!==s))&&e(s,r,((e,t)=>n=>e[n]!==t[n])(s,r))}))}),0)},h(this,Zr,e,"f"),h(this,Qr,t,"f")}get current(){return Object.assign({},u(this,Zr,"f"))}set forceUpdate(e){h(this,Qr,e,"f")}subscribe(e,t=e=>e,{forceUpdate:n=!1}={}){return h(this,Xr,u(this,Xr,"f")+1,"f"),u(this,Yr,"f")[u(this,Xr,"f")]={cb:e,selector:t,forceUpdate:n},u(this,Xr,"f").toString()}unsubscribe(e){const t=!!u(this,Yr,"f")[e];return t&&delete u(this,Yr,"f")[e],t}unsubscribeAll(){return h(this,Yr,{},"f"),!0}};Zr=new WeakMap,Yr=new WeakMap,Xr=new WeakMap,Qr=new WeakMap;const ns=["*","#","/","(",")","[","]","_","<",">","`"],is=e=>"string"!=typeof e?e:e.replace((e=>{const t=ns.map((t=>`${e}${t}`)).join("|");return new RegExp(`(${t})`,"g")})("\\"),"\\$1"),os=["disabled"],rs=(e,t)=>{Object.entries(t||{}).forEach((([t,n])=>{Array.from(e.querySelectorAll(`*[name="${t}"]:not([${Ro}])`)).forEach((e=>{e.value=n}))}))},ss=(e,t)=>t.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),e),as=(e,t,n)=>e.replace(/{{(.+?)}}/g,((e,i)=>n?is(ss(t,i)):ss(t,i))),ds=(e,t,n)=>{e.querySelectorAll(`[${Ko}="${t}"]`).forEach((e=>{e.setAttribute("href",n)}))},ls=(e,t,n)=>{var i,o;const r=null===(i=customElements.get(t))||void 0===i?void 0:i.cssVarList.url;n&&r&&(null===(o=null==e?void 0:e.style)||void 0===o||o.setProperty(r,`url(data:image/jpg;base64,${n})`))},cs=(e,t,n,i)=>{var o,r;ds(e,"totp-link",null===(o=null==t?void 0:t.totp)||void 0===o?void 0:o.provisionUrl),ds(e,"notp-link",null===(r=null==t?void 0:t.notp)||void 0===r?void 0:r.redirectUrl),((e,t)=>{e.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((e=>{const n=(e=>Er.includes(e))(e.localName);e.textContent=as(e.textContent,t,n);const i=e.getAttribute("href");i&&e.setAttribute("href",as(i,t))}))})(e,t),((e,t,n)=>{if(!t)return;const{componentsDynamicAttrs:i}=t,o=l(t,["componentsDynamicAttrs"]),r=Object.keys(o).reduce(((e,t)=>(e[`[name=${t}]`]=o[t],e)),{});i&&Object.keys(i).forEach((e=>{const t=i[e];if(t){const{attributes:n}=t;n&&Object.keys(n).length&&(r[e]=n)}})),Object.keys(r).forEach((t=>{e.querySelectorAll(t).forEach((e=>{const i=r[t];Object.keys(i).forEach((t=>{let o=i[t];if("string"!=typeof o)try{o=JSON.stringify(o)}catch(e){n.error(`Could not stringify value "${o}" for "${t}"`,e.message),o=""}e.setAttribute(t,o)}))}))}))})(e,null==t?void 0:t.componentsConfig,i),((e,t)=>{e.querySelectorAll("[data-has-dynamic-attr-values]").forEach((e=>{Array.from(e.attributes).forEach((e=>{e.value=as(e.value,t)}))}))})(e,t),((e,t)=>{Object.entries(t).forEach((([t,n])=>{e.querySelectorAll(`[name="${t}"]`).forEach((e=>{Object.entries(n).forEach((([t,n])=>{os.includes(t)&&e.setAttribute(t,n)}))}))}))})(e,n)},us=Lr((()=>c(void 0,void 0,void 0,(function*(){var e,t;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return!1;try{const n=Promise.all([null===(e=window.PublicKeyCredential)||void 0===e?void 0:e.isConditionalMediationAvailable(),null===(t=window.PublicKeyCredential)||void 0===t?void 0:t.isUserVerifyingPlatformAuthenticatorAvailable()]).then((e=>e.every((e=>!!e)))),i=(()=>{var e;const t=null===(e=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===e?void 0:e.brands,n=null==t?void 0:t.find((({brand:e,version:t})=>"Chromium"===e&&parseFloat(t)));return n?n.version:0})()>=108;return yield Dr(100,n,i)}catch(e){return console.error("Conditional login check failed",e),!1}}))));let hs;const fs=(e,t)=>{hs?hs.setItem(e,t):void 0!==(null===window||void 0===window?void 0:window.localStorage)&&window.localStorage.setItem(e,t)},ps=e=>hs?hs.getItem(e):void 0!==(null===window||void 0===window?void 0:window.localStorage)?window.localStorage.getItem(e):null,vs="dls_ab_testing_id",gs={"lastAuth.loginId":{"not-empty":e=>{var t;return!!e.loginId||!!(null===(t=e.lastAuth)||void 0===t?void 0:t.loginId)},empty:e=>{var t;return!e.loginId&&!(null===(t=e.lastAuth)||void 0===t?void 0:t.loginId)}},idpInitiated:{"is-true":e=>!!e.code,"is-false":e=>!e.code},externalToken:{"is-true":e=>!!e.token,"is-false":e=>!e.token},abTestingKey:{"greater-than":(e,t)=>(e.abTestingKey||0)>t,"less-than":(e,t)=>(e.abTestingKey||0)<t,"greater-than-or-equal":(e,t)=>(e.abTestingKey||0)>=t,"less-than-or-equal":(e,t)=>(e.abTestingKey||0)<=t,"in-range":(e,t)=>{const[n,i]=t?t.split(",").map(Number):[void 0,void 0];return(e.abTestingKey||0)>=(null!=n?n:0)&&(e.abTestingKey||0)<=(null!=i?i:0)},"not-in-range":(e,t)=>{const[n,i]=t?t.split(",").map(Number):[void 0,void 0];return!(void 0!==n&&void 0!==i&&!Number.isNaN(n)&&!Number.isNaN(i))||(e.abTestingKey||0)<n||(e.abTestingKey||0)>i},"devised-by":(e,t)=>{const n=Number(t);return!Number.isNaN(n)&&(e.abTestingKey||0)%n==0}}};function ms(e,t){const n={};try{Object.assign(n,JSON.parse(ps(xo)))}catch(e){null==t||t.warn("[Descope] Failed to read last auth from storage",String(e))}return n.loginId||e?n:{}}function ys(e,t){(null==e?void 0:e.authMethod)&&(t&&!e.loginId||fs(xo,JSON.stringify(e)))}function bs(){try{return JSON.parse(ps(tr)||"{}")}catch(e){return{}}}function ws(e){try{(e=>{hs?hs.removeItem(e):void 0!==(null===window||void 0===window?void 0:window.localStorage)&&window.localStorage.removeItem(e)})(tr)}catch(t){null==e||e.warn("[Descope] Failed to clear in-flight last auth storage",String(t))}}const $s=["error","warn","info","debug"],ks={error:console.error.bind(console,"[Descope]"),warn:console.warn.bind(console,"[Descope]"),info:console.info.bind(console,"[Descope]"),debug:console.debug.bind(console,"[Descope]")},Cs=Ti((e=>{var t,n,i,o;return o=class extends e{constructor(){super(...arguments),t.add(this),n.set(this,u(this,t,"m",i).call(this,ks))}set logger(e){h(this,n,u(this,t,"m",i).call(this,e||ks),"f")}get logger(){return u(this,n,"f")}onLogEvent(e,t){}},n=new WeakMap,t=new WeakSet,i=function(e){return $s.reduce(((t,n)=>(t[n]=(...t)=>{var i;this.onLogEvent(n,t),null===(i=e[n])||void 0===i||i.call(e,...t)},t)),{})},o})),Ss="undefined"!=typeof localStorage,Is="https://static.descope.com/pages",Rs="https://static2.descope.com/pages",Es=Ss&&localStorage.getItem("base.content.url")||"",xs=(e,t)=>!t&&`${e} cannot be empty, please make sure to set this attribute`,Os=Ti((e=>{var t,n;return n=class extends e{constructor(){super(...arguments),t.set(this,!0)}connectedCallback(){var e,n;null===(e=super.connectedCallback)||void 0===e||e.call(this),(null===(n=this.shadowRoot)||void 0===n?void 0:n.isConnected)&&u(this,t,"f")&&(h(this,t,!1,"f"),this.init())}async init(){}},t=new WeakMap,n})),As=Ti((e=>{var t,n;const i=Ei(Cs,Os)(e);return n=class extends i{constructor(){super(...arguments),t.set(this,{})}async init(){var e,n,i;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),n=this,i=e=>{var n;null===(n=u(this,t,"f")[e])||void 0===n||n.forEach((t=>{t(e,this.getAttribute(e))}))},Array.from(n.attributes).forEach((e=>i(e.name))),new MutationObserver((e=>{e.forEach((e=>{"attributes"===e.type&&e.oldValue!==n.getAttribute(e.attributeName)&&i(e.attributeName)}))})).observe(n,{attributes:!0,attributeOldValue:!0})}observeAttribute(e,n){u(this,t,"f")[e]||(u(this,t,"f")[e]=[]);const i=u(this,t,"f")[e].push(n);return()=>u(this,t,"f")[e].splice(i,1)}observeAttributes(e,t){const n=e.reduce(((e,n)=>(e.push(this.observeAttribute(n,t)),e)),[]);return()=>n.forEach((e=>e()))}},t=new WeakMap,n})),Ns=e=>t=>{var n,i,o;const r=Ei(Cs,Os,As)(t),s=Object.keys(e);return o=class extends r{constructor(...e){super(...e),n.add(this),this.observeAttributes(s,u(this,n,"m",i).bind(this))}async init(){var e;s.forEach((e=>u(this,n,"m",i).call(this,e,this.getAttribute(e)))),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},n=new WeakSet,i=function(t,n){const i=e[t],o="function"==typeof i?i(t,n):i;o&&this.logger.error(o)},o};Ns.missingAttrValidator=xs;const js=Ti((e=>{const t=Ei(Ns({"project-id":xs}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),Ms=Ti((e=>class extends e{get baseUrl(){return this.getAttribute("base-url")||""}})),Ps="Trying the next fallback URL...",Ts=async(e,t,{logger:n}={})=>{try{return await fetch(e,t)}catch(i){return null==n||n.debug(`Network error fetching URL ${e} [${i.message}], retrying...`),fetch(e,t)}};const Ws=Ti((e=>{var t,n,i,o,r,s,a;const d=Ei(Cs,js,Ms)(e);return a=class extends d{constructor(){super(...arguments),t.add(this),n.set(this,void 0),i.set(this,void 0),o.set(this,new Set)}async fetchStaticResource(e,n){const s=u(this,t,"m",r).call(this,e),a=Array.isArray(s)?e=>{const{baseUrl:t}=s[e];h(this,i,t,"f");for(let t=0;t<e;t++){const e=s[t].baseUrl;u(this,o,"f").add(e)}}:null;try{const e=await(async(e,t,{logger:n,onSuccess:i}={})=>{const o=Array.isArray(e)?e:[e];for(let e=0;e<o.length;e++){const r=o[e],s=e===o.length-1;try{const o=await Ts(r.toString(),t,{logger:n});if(o.ok)return null==i||i(e),null==n||n.debug(`Successfully fetched URL ${r}`),o;const a=`Error fetching URL ${r} [${o.status}]`;if(s)throw new Error(a);null==n||n.debug(`${a}. ${Ps}`)}catch(e){const t=`Error fetching URL ${r} [${e.message}]`;if(s)throw new Error(t);null==n||n.debug(`${t}. ${Ps}`)}}})(s,{cache:"default"},{logger:this.logger,onSuccess:a});return{body:await e[n](),headers:Object.fromEntries(e.headers.entries())}}catch(e){this.logger.error(e.message)}}get baseStaticUrl(){return this.getAttribute("base-static-url")||""}},n=new WeakMap,i=new WeakMap,o=new WeakMap,t=new WeakSet,r=function(e){const r=Es||this.baseStaticUrl;if(r)return u(this,t,"m",s).call(this,e,r);u(this,n,"f")!==this.baseUrl&&(h(this,n,this.baseUrl,"f"),h(this,i,void 0,"f"),u(this,o,"f").clear());const a=[];if(u(this,i,"f"))a.push(u(this,t,"m",s).call(this,e,u(this,i,"f"))),u(this,i,"f")===Is&&a.push(u(this,t,"m",s).call(this,e,Rs));else{const n=this.baseUrl+"/pages";this.baseUrl&&!u(this,o,"f").has(n)&&a.push(u(this,t,"m",s).call(this,e,n)),u(this,o,"f").has(Is)||a.push(u(this,t,"m",s).call(this,e,Is)),a.push(u(this,t,"m",s).call(this,e,Rs))}return 1===a.length?a[0]:a},s=function(e,t){return function({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:i=Is}){const o=new URL(i);return o.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(o.pathname,e,n,t),o.baseUrl=i,o}({projectId:this.projectId,filename:e,baseUrl:t})},a})),Ls=Ti((e=>{var t,n;const i=Ei(Ns({"project-id":xs}))(e);return n=class extends i{constructor(){super(...arguments),t.set(this,new Map)}onReset(e,n){if(u(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} already exists`);return u(this,t,"f").set(e,n),()=>{u(this,t,"f").delete(e)}}async reset(...e){0===e.length?await Promise.all(Array.from(u(this,t,"f").values()).map((e=>e()))):await Promise.all(e.map((e=>{var n;if(!u(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} does not exist`);return null===(n=u(this,t,"f").get(e))||void 0===n?void 0:n()})))}},t=new WeakMap,n})),Us=Ti((e=>{var t,n,i,o,r;const s=Ei(Ws,Ls,Os)(e);return r=class extends s{constructor(){super(...arguments),t.add(this),i.set(this,void 0),o.set(this,(async()=>{try{const{body:e,headers:t}=await this.fetchStaticResource("config.json","json");return{projectConfig:e,executionContext:{geo:t["x-geo"]}}}catch(e){this.logger.error("Cannot fetch config file","make sure that your projectId & flowId are correct")}}))}async init(){await super.init(),this.onReset("config",u(this,t,"m",n).bind(this))}get config(){return u(this,i,"f")||h(this,i,u(this,o,"f").call(this),"f"),u(this,i,"f")}},i=new WeakMap,o=new WeakMap,t=new WeakSet,n=function(){h(this,i,void 0,"f")},r})),Ds=["https://descopecdn.com","https://static.descope.com","https://cdn.jsdelivr.net"],Fs=e=>{let t=0;const n=e.toString();for(let e=0;e<n.length;e++){t=(t<<5)-t+n.charCodeAt(e),t|=0}return`${Math.abs(t).toString()}`},_s=(e,t,n)=>new Promise(((i,o)=>{const r=((e,t)=>{const n=document.createElement("script");return n.id=e,t&&(n.integrity=t,n.crossOrigin="anonymous"),window.DESCOPE_NONCE&&n.setAttribute("nonce",window.DESCOPE_NONCE),n})(e,n);r.onerror=e=>{r.setAttribute("status","error"),o(e)},r.onload=()=>{r.setAttribute("status","loaded"),i(r)},r.src=t.toString(),document.body.appendChild(r)})),qs=(e,t)=>{if(t){const n=e.integrity;if(n!==t)return Promise.reject(new Error(`Integrity mismatch: expected ${t}, found ${n}`))}return"loaded"===e.getAttribute("status")?Promise.resolve(e):(e=>"error"===e.getAttribute("status"))(e)?Promise.reject():new Promise(((t,n)=>{e.addEventListener("load",(()=>{t(e)})),e.addEventListener("error",(e=>{n(e)}))}))},Bs=Ti((e=>{const t=Ei(Cs)(e);return class extends t{get baseCdnUrl(){return this.getAttribute("base-cdn-url")||""}injectNpmLib(e,t,n="",i=[],o){return this.logger.debug(`Injecting npm lib: "${e}" with version: "${t}"${o?" with SRI integrity check":""}`),(async(e,t)=>{for(const i of e){const{id:e,url:o,integrity:r}=i,s=(n=e,document.querySelector(`script#${n}`));if(s)try{return await qs(s,r),i}catch(e){t(i,!0)}else try{return await _s(e,o,r),i}catch(e){t(i,!1)}}var n;throw new Error("All scripts failed to load")})(((e,t,n,i="",o)=>e.reduce(((e,r)=>{const s=r;if(!s)return e;let a;try{a=new URL(s)}catch(e){throw new Error(`Invalid URL: ${s}`)}"/"!==a.pathname||(a.pathname=`/npm/${t}@${n}/${i}`);const d={url:a,id:`npmlib-${t.replaceAll("@","").replaceAll("/","_")}-${Fs(a)}`};return o&&(d.integrity=o),[...e,d]}),[]))([...i,this.baseCdnUrl,...Ds],e,t,n,o),((e,t)=>{t?this.logger.error(`Existing script cannot be loaded: "${e.url}"`):this.logger.error(`Cannot load script from URL, Make sure this URL is valid and return the correct script: "${e.url}"`)}))}}})),Vs="base.ui.components.url",Ks=Ss&&localStorage.getItem(Vs),Hs=Ti((e=>{var t,n,i,o,r,s,a;const d=Ei(Cs,Us,Bs)(e);return a=class extends d{constructor(){super(...arguments),t.add(this),o.set(this,void 0)}get descopeUi(){return u(this,o,"f")||h(this,o,u(this,t,"m",s).call(this),"f"),u(this,o,"f")}async loadDescopeUiComponents(e){const n=Array.isArray(e)?e:(e=>[...Array.from(e.content.querySelectorAll("*")).reduce(((e,t)=>t.localName.startsWith("descope-")?e.add(t.localName):e),new Set)])(e);return Promise.all(n.map((e=>u(this,t,"m",r).call(this,e))))}},o=new WeakMap,t=new WeakSet,n=async function(){var e;const t=await this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersion;return n?this.logger.debug(`Got component version "${n}"`):this.logger.error("Could not get components version"),n},i=async function(){var e;const t=await this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersionSri;return n&&this.logger.debug("SRI hash available for components"),n},r=async function(e){if(!!customElements.get(e))return void this.logger.debug(`Loading component "${e}" is skipped as it is already defined`);const t=await this.descopeUi;if(t[e])try{return await t[e]()}catch(t){if("NotSupportedError"!==t.name)throw t;console.debug(`Encountered an error while attempting to define the "${e}" component, it is likely that this component is already defined`)}else this.logger.error(`Cannot load UI component "${e}"`,`Descope UI does not have a component named "${e}", available components are: "${Object.keys(t).join(", ")}"`)},s=async function(){if(globalThis.DescopeUI)return globalThis.DescopeUI;try{const e=await u(this,t,"m",n).call(this),o=Ks?void 0:await u(this,t,"m",i).call(this);return await this.injectNpmLib("@descope/web-components-ui",e,"dist/umd/index.js",[Ks],o),this.logger.debug("DescopeUI was loaded"),globalThis.DescopeUI}catch(e){throw this.logger.error(e),new Error("DescopeUI was not loaded")}},a})),zs=Ti((e=>{var t,n,i;const o=Ei(Os,As)(e);return i=class extends o{constructor(){super(...arguments),t.add(this)}get nonce(){return this.getAttribute("nonce")||""}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),this.observeAttribute("nonce",u(this,t,"m",n).bind(this)),u(this,t,"m",n).call(this)}},t=new WeakSet,n=function(){this.nonce&&(window.DESCOPE_NONCE=this.nonce)},i}));class Js{constructor(e,t,{prepend:n=!1}={}){this.styleEle=document.createElement("style"),this.styleEle.setAttribute("nonce",t),this.ref=e,this.ref&&(n?this.ref.prepend(this.styleEle):this.ref.append(this.styleEle))}replaceSync(e){this.styleEle.textContent=e}get cssRules(){var e;return null===(e=this.styleEle.sheet)||void 0===e?void 0:e.cssRules}}const Gs=Ti((e=>{const t=Ei(zs)(e);return class extends t{injectStyle(e,{prepend:t=!1}={}){let n;try{n=new CSSStyleSheet}catch(e){n=new Js(this.shadowRoot,this.nonce,{prepend:t})}if(e&&n.replaceSync(e),n instanceof CSSStyleSheet){const e=this.shadowRoot;if(e&&"adoptedStyleSheets"in e){const i=[...e.adoptedStyleSheets||[]];i[t?"unshift":"push"](n),e.adoptedStyleSheets=i}}return n}}})),Zs="content-root",Ys="root",Xs=Ti((e=>{const t=Ei(Gs)(e);return class extends t{constructor(...e){var t,n;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n <div id="${Ys}">\n <div id="${Zs}"></div>\n </div>\n `,this.injectStyle(`\n #${Ys}, #${Zs} {\n height: 100%;\n }\n #${Ys} {\n position: relative;\n height: fit-content;\n }\n #${Ys}:has(> #${Zs} > #ROOT[st-host-height="100%"]) {\n height: 100%;\n }\n `),this.contentRootElement=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById(Zs),this.rootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(Ys)}}})),Qs="theme",ea=(e,t,n="")=>Object.entries(e).reduce(((e,[i,o])=>{if(!/^[a-zA-Z0-9-]+$/.test(i))return t("Ignoring invalid override-css token path segment"),e;const r=n?`${n}-${i}`:i;if("object"==typeof o&&null!==o)return e+ea(o,t,r);const s=(e=>"number"==typeof e?Number.isFinite(e)?String(e):null:"string"!=typeof e||/[;{}]/.test(e)?null:e.trim())(o);return null===s?(t("Ignoring invalid override-css token value"),e):`${e}--descope-${r}:${s};`}),""),ta=e=>{const t=document.createElement("link");t.href=e,t.rel="stylesheet",document.head.appendChild(t)};function na(e,t){const n=Object.assign({},e);for(const[e,i]of Object.entries(t||{}))if(null!=i)if("object"==typeof i){if(0===Object.keys(i).length)continue;n[e]=na(n[e]||{},i)}else n[e]="string"==typeof i?(n[e]||"")+i:i;return n}const ia=(e,t)=>null!==t&&!/^[a-zA-Z0-9_-]*$/.test(t)&&"tenant must contain only alphanumeric characters, hyphens, or underscores",oa=Ti((e=>{const t=Ei(Ns({tenant:ia}))(e);return class extends t{get tenantId(){return this.getAttribute("tenant")||void 0}}})),ra=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',sa=Ti((e=>{var t,n,i,o,r,s,a,d,l,c,f,p,v,g,m,y,b,w,$,k,C,S,I;const R=Ei(Ns({theme:ra}),oa,Ws,Os,Hs,Us,Xs,As,Gs)(e);return I=class extends R{constructor(){super(...arguments),t.add(this),n.set(this,void 0),i.set(this,void 0),o.set(this,void 0),s.set(this,void 0),a.set(this,void 0),k.set(this,(()=>{u(this,t,"m",C).call(this),u(this,S,"f").call(this,"os"===this.getAttribute("theme"))})),S.set(this,(e=>{var n,i,o;const r=e?"addEventListener":"removeEventListener";null===(o=null===(i=null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-color-scheme: dark)"))||void 0===i?void 0:i[r])||void 0===o||o.call(i,"change",(()=>u(this,t,"m",C).call(this)))}))}get theme(){var e,t;const n=this.getAttribute("theme");if("os"===n){return window.matchMedia&&(null===(t=null===(e=window.matchMedia)||void 0===e?void 0:e.call(window,"(prefers-color-scheme: dark)"))||void 0===t?void 0:t.matches)?"dark":"light"}return n||"light"}get styleId(){return this.getAttribute("style-id")||Qs}get themeOverride(){const e=this.getAttribute("theme-override");if(!e)return null;try{return JSON.parse(e)}catch(e){return this.logger.error("Failed to parse theme-override attribute. error: ",e),null}}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),u(this,k,"f").call(this),await Promise.all([u(this,t,"m",c).call(this),u(this,t,"m",v).call(this),u(this,t,"m",m).call(this)]),u(this,t,"m",g).call(this),this.observeAttributes(["theme"],u(this,k,"f")),this.observeAttributes(["theme-override"],(()=>u(this,t,"m",g).call(this))),this.observeAttributes(["tenant"],(()=>{h(this,a,null,"f"),u(this,t,"m",v).call(this),u(this,t,"m",m).call(this),u(this,t,"m",w).call(this)})),this.observeAttributes(["style-id"],(()=>{h(this,s,null,"f"),u(this,t,"m",b).call(this),u(this,t,"m",c).call(this),u(this,t,"m",m).call(this)}))}},n=new WeakMap,i=new WeakMap,o=new WeakMap,s=new WeakMap,a=new WeakMap,k=new WeakMap,S=new WeakMap,t=new WeakSet,r=function(){const e=this.themeOverride;return e?["light","dark"].map((t=>{var n,i,o,r,s,a;const d=null===(o=null===(i=null===(n=e[t])||void 0===n?void 0:n.globals)||void 0===i?void 0:i.colors)||void 0===o?void 0:o.primary,l=null===(a=null===(s=null===(r=e[t])||void 0===r?void 0:r.globals)||void 0===s?void 0:s.colors)||void 0===a?void 0:a.secondary;return d||l?`[data-theme="${t}"]{${ea({colors:{primary:d,secondary:l}},(e=>this.logger.error(e)))}}`:""})).join(""):""},d=async function(){try{const{body:e}=await this.fetchStaticResource(`${this.styleId}.json`,"json");if("development"===process.env.NODE_ENV&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(Vs)))try{this.logger.warn("You are in DEV mode, and UI components override URL was found\ntrying to merge project theme with the default theme of the UI components");const t=await(async()=>{const e=localStorage.getItem(Vs),t=null==e?void 0:e.replace(/[^\/]+$/,"DescopeDev.js");console.warn("Trying to load DescopeDev.js from",t);const n=document.createElement("script");if(n.src=t,document.body.appendChild(n),await new Promise(((e,t)=>{n.onload=e,n.onerror=t})),globalThis.DescopeDev){const{themeToStyle:e,defaultTheme:t,darkTheme:n}=globalThis.DescopeDev;return{light:e(t),dark:e(n)}}})();t&&(e.light.components=Object.assign(Object.assign({},e.light.components),t.light.components),e.dark.components=Object.assign(Object.assign({},e.dark.components),t.dark.components),this.logger.warn("Theme was merged successfully"),console.log("%cNOTICE! This is not the theme that will be used in production!\n\nMake sure to test it without the override UI components URL!","color: black; background-color:yellow; font-size: x-large"))}catch(e){this.logger.error("Failed to merge UI components theme\n",e)}return e}catch(e){this.logger.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}},l=function(){return u(this,s,"f")||(h(this,s,u(this,t,"m",d).call(this),"f"),u(this,s,"f").then((e=>this.logger.debug("Fetched theme",e)))),u(this,s,"f")},c=async function(){var e,i;const o=await u(this,t,"a",l);if(!o)return;const r=((null===(e=null==o?void 0:o.light)||void 0===e?void 0:e.globals)||"")+((null===(i=null==o?void 0:o.dark)||void 0===i?void 0:i.globals)||"");u(this,n,"f")?u(this,n,"f").replaceSync(r):h(this,n,this.injectStyle(r,{prepend:!0}),"f")},f=async function(){const e=this.tenantId;if(e)try{const{body:t}=await this.fetchStaticResource(`${e}/theme.json`,"json");return t}catch(e){this.logger.warn("No tenant style exists, using project default theme.")}},p=function(){return u(this,a,"f")||h(this,a,u(this,t,"m",f).call(this),"f"),u(this,a,"f")},v=async function(){var e,n,o,r;if(!this.tenantId)return void(null===(e=u(this,i,"f"))||void 0===e||e.replaceSync(""));const s=await u(this,t,"a",p);if(!s)return void(null===(n=u(this,i,"f"))||void 0===n||n.replaceSync(""));const a=((null===(o=s.light)||void 0===o?void 0:o.globals)||"")+((null===(r=s.dark)||void 0===r?void 0:r.globals)||"");u(this,i,"f")?u(this,i,"f").replaceSync(a):h(this,i,this.injectStyle(a),"f")},g=async function(){var e;if(!this.themeOverride)return void(null===(e=u(this,o,"f"))||void 0===e||e.replaceSync(""));const n=u(this,t,"m",r).call(this);u(this,o,"f")?u(this,o,"f").replaceSync(n):h(this,o,this.injectStyle(n),"f")},m=async function(){var e,n,i,o;const r=await u(this,t,"a",l);if(!r)return;const s=await this.descopeUi;if(!(null==s?void 0:s.componentsThemeManager))return;const a=await u(this,t,"a",p);s.componentsThemeManager.themes={light:na((null===(e=null==r?void 0:r.light)||void 0===e?void 0:e.components)||{},(null===(n=null==a?void 0:a.light)||void 0===n?void 0:n.components)||{}),dark:na((null===(i=null==r?void 0:r.dark)||void 0===i?void 0:i.components)||{},(null===(o=null==a?void 0:a.dark)||void 0===o?void 0:o.components)||{})}},y=async function(){var e,t;const{projectConfig:n}=await this.config||{},i=null===(e=null==n?void 0:n.styles)||void 0===e?void 0:e[this.styleId],o=null==n?void 0:n.cssTemplate,r=i||o;return null===(t=null==r?void 0:r[this.theme])||void 0===t?void 0:t.fonts},b=async function(){const e=await u(this,t,"m",y).call(this);e?Object.values(e).forEach((e=>{e.url&&(this.logger.debug(`Loading font from URL "${e.url}"`),ta(e.url))})):this.logger.debug("No fonts to load"),u(this,t,"m",w).call(this)},w=async function(){var e;if(!this.tenantId)return;const n=await u(this,t,"a",p),i=null===(e=null==n?void 0:n[this.theme])||void 0===e?void 0:e.fonts;Object.values(i||{}).forEach((e=>{(null==e?void 0:e.url)&&(this.logger.debug(`Loading tenant font from URL "${e.url}"`),ta(e.url))}))},$=async function(){this.rootElement.setAttribute("data-theme",this.theme);const e=await this.descopeUi;(null==e?void 0:e.componentsThemeManager)&&(e.componentsThemeManager.currentThemeName=this.theme)},C=function(){u(this,t,"m",b).call(this),u(this,t,"m",$).call(this)},I})),aa=Ss&&localStorage.getItem("base.debug.logs.url"),da=Ti((e=>{const t=Ei(Ns({"flow-id":xs}))(e);return class extends t{get flowId(){return this.getAttribute("flow-id")}}}));function la(e){const t=Math.floor(e/1e3);if(t<60)return`${t} seconds`;const n=Math.floor(t/60);if(n<60)return`${n} minutes`;const i=Math.floor(n/60);return i<24?`${i} hours`:`${Math.floor(i/24)} days`}const ca=Ti((e=>{var t,n,i,o,r,s,a,d,l,c,f,p;const v=Ei(Bs,Cs,Os,Us,js,da)(e);return p=class extends v{constructor(){super(...arguments),t.add(this),n.set(this,null),i.set(this,!1),o.set(this,null),f.set(this,null)}get telemetryManager(){return u(this,n,"f")}updateTelemetryContext(e){if(u(this,n,"f"))try{u(this,n,"f").updateContext(e)}catch(e){this.logger.error("Error updating telemetry context:",e)}}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this));const n=this.sdkVersion||"1.0.0";h(this,f,u(this,t,"m",l).call(this).then((e=>u(this,t,"m",r).call(this,e,{projectId:this.projectId,flowId:this.flowId,sdkVersion:n}))).catch((e=>{this.logger.error("Failed to start telemetry:",e)})),"f")}get telemetryReady(){var e;return null!==(e=u(this,f,"f"))&&void 0!==e?e:Promise.resolve()}disconnectedCallback(){var e;null===(e=super.disconnectedCallback)||void 0===e||e.call(this),u(this,t,"m",a).call(this)}},n=new WeakMap,i=new WeakMap,o=new WeakMap,f=new WeakMap,t=new WeakSet,r=async function(e,o){if(null==e?void 0:e.enabled)if(u(this,i,"f"))this.logger.debug("Telemetry already initialized");else if(e.expiration&&Date.now()>=e.expiration)this.logger.info(`Telemetry expiration time has passed (${new Date(e.expiration).toISOString()}), skipping initialization`);else try{this.logger.debug("Initializing telemetry...");const r=e.version||"latest";await this.injectNpmLib("@descope/debug-logs",r,"dist/index.js",[aa]);const a=window.DescopeDebugLogs;if(!a)throw new Error("DescopeDebugLogs not found after loading @descope/debug-logs. This likely means the UMD build failed to load from CDN.");if(h(this,n,new a({enabled:!0,rumConfig:e.rumConfig,capture:e.capture},{projectId:o.projectId,flowId:o.flowId,version:o.sdkVersion||"1.0.0"},this.logger),"f"),!u(this,n,"f").isReady())return this.logger.error("Telemetry manager failed to initialize (RUM client not ready)"),void h(this,n,null,"f");h(this,i,!0,"f"),this.logger.info("Telemetry initialized successfully"),e.expiration&&u(this,t,"m",s).call(this,e.expiration)}catch(e){this.logger.error("Failed to initialize telemetry:",e),h(this,i,!1,"f")}else this.logger.debug("Telemetry is disabled, skipping initialization")},s=function(e){const n=e-Date.now();if(n<=0)return this.logger.info("Telemetry expiration time reached, shutting down"),void u(this,t,"m",a).call(this);const i=864e5,r=Math.min(n,i);n>i&&this.logger.warn(`Telemetry expiration is beyond maximum timeout (${la(n)}). Setting to maximum.`),this.logger.info(`Telemetry will expire at ${new Date(e).toISOString()} (in ${la(r)})`),h(this,o,setTimeout((()=>{this.logger.info("Telemetry expiration time reached, shutting down"),u(this,t,"m",a).call(this)}),r),"f")},a=function(){if(u(this,o,"f")&&(clearTimeout(u(this,o,"f")),h(this,o,null,"f")),u(this,n,"f"))try{this.logger.debug("Shutting down telemetry..."),u(this,n,"f").shutdown(),h(this,n,null,"f"),h(this,i,!1,"f"),this.logger.info("Telemetry shutdown complete")}catch(e){this.logger.error("Error shutting down telemetry:",e)}},d=function(e){return Boolean((null==e?void 0:e.applicationId)&&(null==e?void 0:e.identityPoolId)&&(null==e?void 0:e.region))},l=async function(){var e;const n=await this.config,i=null===(e=null==n?void 0:n.projectConfig)||void 0===e?void 0:e.telemetry;let o;try{const e=Number(process.env.DESCOPE_TELEMETRY_SESSION_SAMPLE_RATE);o={enabled:"true"===(process.env.DESCOPE_TELEMETRY_ENABLED||"").toLowerCase(),rumConfig:Object.assign({applicationId:process.env.DESCOPE_TELEMETRY_APPLICATION_ID||"",identityPoolId:process.env.DESCOPE_TELEMETRY_IDENTITY_POOL_ID||"",region:process.env.DESCOPE_TELEMETRY_REGION||"",sessionSampleRate:Number.isFinite(e)&&e>0?e:1},process.env.DESCOPE_TELEMETRY_GUEST_ROLE_ARN&&{guestRoleArn:process.env.DESCOPE_TELEMETRY_GUEST_ROLE_ARN})}}catch(e){o={enabled:!1,rumConfig:{applicationId:"",identityPoolId:"",region:"",sessionSampleRate:1}}}const r=Object.assign(Object.assign(Object.assign({},o),i),{rumConfig:Object.assign(Object.assign({},o.rumConfig),null==i?void 0:i.rumConfig),capture:u(this,t,"m",c).call(this,null==i?void 0:i.capture)});return r.enabled&&!u(this,t,"m",d).call(this,r.rumConfig)&&(this.logger.warn("Telemetry enabled but rumConfig is incomplete (applicationId/identityPoolId/region required). Skipping initialization."),r.enabled=!1),i||(r.expiration=Date.now()+3e5,this.logger.debug("No backend telemetry config present; applying a 5-minute safety cap on the session.")),r},c=function(e){const t=null==e?void 0:e.dom;return!1===t?Object.assign(Object.assign({console:!0,network:!0,navigation:!0},e),{dom:!1}):Object.assign(Object.assign({console:!0,network:!0,navigation:!0},e),{dom:Object.assign(Object.assign({throttleMs:2e3},"object"==typeof t?t:{}),{rootElement:this.shadowRoot})})},p})),ua=(e,t="")=>Object.keys(e).reduce(((n,i)=>{var o;if(Array.isArray(e[i]))return Object.assign(Object.assign({},n),{[i]:{value:e[i].map((e=>"object"==typeof e&&null!==e?ua(e):e))}});if("object"==typeof e[i]&&null!==e[i]&&!(null===(o=e[i])||void 0===o?void 0:o.value))return Object.assign(Object.assign({},n),ua(e[i],`${t+i}.`));const r="object"==typeof e[i]?e[i]:{value:e[i]},s=Object.assign(Object.assign({},n),{[t+i]:r,[`form.${t}${i}`]:r});return"displayName"===i?Object.assign(Object.assign({},s),{[`${t}fullName`]:r,[`form.${t}fullName`]:r}):s}),[]),ha=Ti((e=>{var t,n,i,o;return o=class extends e{constructor(){super(...arguments),t.add(this)}connectedCallback(){var e;u(this,t,"m",n).call(this)&&u(this,t,"m",i).call(this),null===(e=super.connectedCallback)||void 0===e||e.call(this)}},t=new WeakSet,n=function(){return!this.shadowRoot.host.closest("form")&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)},i=function(){const e=this.shadowRoot.host,t=document.createElement("form");t.style.width="100%",t.style.height="100%",e.parentElement.appendChild(t),t.appendChild(e)},o})),fa=Ti((e=>{var t,n,i,o,r,s,a;return a=class extends(Ei(Os,Cs)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),this.attributeChangedCallback=(e,n,i)=>{var o;null===(o=super.attributeChangedCallback)||void 0===o||o.call(this,e,n,i),"debug"===e&&u(this,t,"m",r).call(this)}}get debug(){return"true"===this.getAttribute("debug")}onLogEvent(e,n){var i;null===(i=super.onLogEvent)||void 0===i||i.call(this,e,n),"error"===e&&u(this,t,"m",s).call(this,n[0]||"Error",n[1])}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),u(this,t,"m",r).call(this)}},n=new WeakMap,t=new WeakSet,i=function(){var e;null===(e=u(this,n,"f"))||void 0===e||e.remove(),h(this,n,null,"f")},o=async function(){h(this,n,document.createElement("descope-debugger"),"f"),Object.assign(u(this,n,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),await Promise.resolve().then((function(){return $I})),document.body.appendChild(u(this,n,"f"))},r=function(){this.debug?u(this,t,"m",o).call(this):u(this,t,"m",i).call(this)},s=function(e,t){var i;e&&(null===(i=u(this,n,"f"))||void 0===i||i.updateData({title:e,description:t}))},a})),pa="descope-modal";var va,ga,ma;let ya=class{constructor(e,t){va.set(this,void 0),this.nodeName="",h(this,va,e,"f"),this.logger=t.logger}get asyncEle(){return(async e=>new Promise((t=>{const n=setInterval((()=>{const i="function"==typeof e?e():e;i&&(clearInterval(n),t(i))}),100);setTimeout((()=>{clearInterval(n),t(null)}),1e3)})))(u(this,va,"f"))}get ele(){var e,t;const n="function"==typeof u(this,va,"f")?u(this,va,"f").call(this):u(this,va,"f");return n?(null==n?void 0:n.localName)!==this.nodeName?(null===(t=this.logger)||void 0===t||t.debug(`node name do not match, expected "${this.nodeName}", received "${n.localName}" `,Error()),null):n:(null===(e=this.logger)||void 0===e||e.debug(`Driver element is not available for ${this.nodeName}`,new Error),null)}get isExists(){return!!this.ele}};va=new WeakMap;let ba=class extends ya{constructor(){super(...arguments),this.nodeName="descope-apps-list"}set data(e){this.ele&&(this.ele.data=e)}get data(){var e;return null===(e=this.ele)||void 0===e?void 0:e.data}get ele(){return super.ele}},wa=class extends ya{constructor(){super(...arguments),this.nodeName="descope-avatar"}set displayName(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("display-name",e)}set image(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("img",e)}get flowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("flow-id")}onClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("click",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("click",e)}}},$a=class extends ya{constructor(){super(...arguments),this.nodeName="descope-filter",ga.set(this,null)}get data(){var e;try{return JSON.parse((null===(e=this.ele)||void 0===e?void 0:e.getAttribute("data"))||"[]")}catch(e){return[]}}set data(e){var t,n;h(this,ga,JSON.stringify(e),"f"),u(this,ga,"f")!==(null===(t=this.ele)||void 0===t?void 0:t.getAttribute("data"))&&(null===(n=this.ele)||void 0===n||n.setAttribute("data",u(this,ga,"f")))}get value(){var e;try{return JSON.parse((null===(e=this.ele)||void 0===e?void 0:e.getAttribute("value"))||"[]")}catch(e){return[]}}set value(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("value",JSON.stringify(e))}onApply(e){var t;const n=t=>e(t.detail);return null===(t=this.ele)||void 0===t||t.addEventListener("filter-apply",n),()=>{var e;return null===(e=this.ele)||void 0===e?void 0:e.removeEventListener("filter-apply",n)}}onClear(e){var t;const n=t=>e(t.detail);return null===(t=this.ele)||void 0===t||t.addEventListener("filter-clear",n),()=>{var e;return null===(e=this.ele)||void 0===e?void 0:e.removeEventListener("filter-clear",n)}}onDataChange(e){const t=this.ele;if(!t)return()=>{};const n=new MutationObserver((()=>{var n;(null!==(n=t.getAttribute("data"))&&void 0!==n?n:"[]")!==u(this,ga,"f")&&e()}));return n.observe(t,{attributes:!0,attributeFilter:["data"]}),()=>n.disconnect()}};ga=new WeakMap;let ka=class extends ya{constructor(){super(...arguments),this.nodeName="descope-button"}onClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("click",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("click",e)}}disable(){var e;null===(e=this.ele)||void 0===e||e.setAttribute("disabled","true")}enable(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("disabled")}},Ca=class extends ya{constructor(){super(...arguments),this.nodeName="descope-wc"}set projectId(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("project-id",e)}set baseUrl(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("base-url",e)}set flowId(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("flow-id",e)}set theme(e){var t,n;e?null===(n=this.ele)||void 0===n||n.setAttribute("theme",e):null===(t=this.ele)||void 0===t||t.removeAttribute("theme")}start(){var e,t;null===(t=null===(e=this.ele)||void 0===e?void 0:e.start)||void 0===t||t.call(e)}onSuccess(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("success",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("success",e)}}onPageUpdated(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("page-updated",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("page-updated",e)}}},Sa=class extends ka{get flowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("flow-id"))||""}get enableMode(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("enable-mode")}};const Ia=/^descope-grid-([^-]+)-column$/,Ra={text:class extends ya{constructor(){super(...arguments),this.nodeName="descope-grid-text-column"}onSortDirectionChange(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("direction-changed",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("selected-items-changed",e)}}},custom:class extends ya{constructor(){super(...arguments),this.nodeName="descope-grid-custom-column"}onSortDirectionChange(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("direction-changed",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("selected-items-changed",e)}}}};let Ea=class extends ya{constructor(){super(...arguments),this.nodeName="descope-grid",ma.set(this,void 0)}onSelectedItemsChange(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("selected-items-changed",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("selected-items-changed",e)}}get ele(){return super.ele}get data(){var e;return null===(e=this.ele)||void 0===e?void 0:e.data}set data(e){this.ele&&(this.ele.data=e)}get columns(){return this.ele?Array.from(this.ele.children).reduce(((e,t)=>{var n;const i=null===(n=Ia.exec(t.localName))||void 0===n?void 0:n[1],o=Ra[i];return o?(e.push(new o(t,{logger:this.logger})),e):e}),[]):[]}filterColumns(e){var t,n;const i=null===(t=this.ele.columns)||void 0===t?void 0:t.filter(e);i&&this.ele.columns&&(Oi(i,this.ele.columns)||(this.ele.columns=i,null===(n=u(this,ma,"f"))||void 0===n||n.call(this,i)))}onColumnsChange(e){h(this,ma,e,"f")}set renderColumn(e){this.ele.renderColumn=e}};ma=new WeakMap;let xa=class extends ya{constructor(){super(...arguments),this.nodeName="descope-link"}get ele(){return super.ele}get href(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("href")}set href(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("href",null!=e?e:"")}};var Oa,Aa,Na,ja,Ma,Pa,Ta,Wa,La,Ua,Da,Fa,_a,qa,Ba,Va,Ka,Ha,za;let Ja=class extends ya{constructor(...e){super(...e),Oa.add(this),Aa.set(this,void 0),Na.set(this,void 0),this.nodeName="descope-modal",u(this,Oa,"m",ja).call(this)}get isOpen(){var e;return"true"===(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("opened"))}get isClosed(){return!this.isOpen}close(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("opened")}async open(){var e,t;await(null===(e=this.beforeOpen)||void 0===e?void 0:e.call(this)),u(this,Oa,"m",ja).call(this),null===(t=this.ele)||void 0===t||t.setAttribute("opened","true")}reset(){var e;this.ele&&(this.ele.innerHTML=""),u(this,Aa,"f")&&(null===(e=this.ele)||void 0===e||e.append(u(this,Aa,"f").content.cloneNode(!0)))}setContent(e){h(this,Aa,e,"f"),this.reset()}remove(){var e,t;null===(e=u(this,Na,"f"))||void 0===e||e.disconnect(),null===(t=this.ele)||void 0===t||t.remove()}};Aa=new WeakMap,Na=new WeakMap,Oa=new WeakSet,ja=function(){if(u(this,Na,"f"))return;const e=this.ele;e&&(h(this,Na,new MutationObserver((t=>{t.forEach(((n,i)=>{var o;const r="true"===n.oldValue,s=t[i+1]?t[i+1].oldValue:e.getAttribute("opened");r&&"true"!==s&&(null===(o=this.afterClose)||void 0===o||o.call(this))}))})),"f"),u(this,Na,"f").observe(e,{attributes:!0,attributeFilter:["opened"],attributeOldValue:!0}))};let Ga=null,Za=class{constructor(e={}){Ma.add(this),Pa.set(this,null),Ta.set(this,""),Wa.set(this,void 0),La.set(this,void 0),Ua.set(this,!1),Da.set(this,[]),Fa.set(this,[]),_a.set(this,[]),qa.set(this,[]),Ba.set(this,void 0),Va.set(this,!1),this.logger=e.logger}onDone(e){return u(this,Da,"f").push(e),()=>{h(this,Da,u(this,Da,"f").filter((t=>t!==e)),"f")}}onClosed(e){return u(this,Fa,"f").push(e),()=>{h(this,Fa,u(this,Fa,"f").filter((t=>t!==e)),"f")}}onParentFocus(e){return u(this,qa,"f").push(e),()=>{h(this,qa,u(this,qa,"f").filter((t=>t!==e)),"f")}}onUnauthenticated(e){return u(this,_a,"f").push(e),()=>{h(this,_a,u(this,_a,"f").filter((t=>t!==e)),"f")}}get isOpen(){return!!u(this,Pa,"f")&&!u(this,Pa,"f").closed}open(e){var t,n;Ga&&Ga!==this&&Ga.standDown(),u(this,Ma,"m",za).call(this),h(this,Ua,!1,"f"),h(this,Va,!1,"f");try{h(this,Ta,new URL(e).origin,"f")}catch(n){return null===(t=this.logger)||void 0===t||t.error("Invalid flow popup url",e),!1}const i=`descope-widget-flow|${window.location.origin}`;return h(this,Pa,((e,t,n,i)=>{const o=void 0!==window.screenLeft?window.screenLeft:window.screen.left,r=void 0!==window.screenTop?window.screenTop:window.screen.top,s=((window.innerWidth||document.documentElement.clientWidth||window.screen.width)-n)/2+o,a=((window.innerHeight||document.documentElement.clientHeight||window.screen.height)-i)/2+r,d=function(){const e=navigator.userAgent||"",t=/\b(iPhone)\b/.test(e),n=/Safari/.test(e)&&!/CriOS|FxiOS|OPiOS|EdgiOS|Chrome|Chromium/.test(e);return t&&n}()?"about:blank":"",l=window.open(d,t,`width=${n},height=${i},top=${a},left=${s},scrollbars=yes,resizable=yes`);return l?(l.location.href=e,l.focus(),l):null})(e,i,480,650),"f"),u(this,Pa,"f")?(h(this,La,(e=>{var t,n,i,o,r,s;u(this,Pa,"f")&&e.source&&e.source!==u(this,Pa,"f")||(e.origin===u(this,Ta,"f")?"widget-flow-hello"!==(null===(n=e.data)||void 0===n?void 0:n.action)?"widget-flow-unauthenticated"!==(null===(r=e.data)||void 0===r?void 0:r.action)?"widget-flow-done"===(null===(s=e.data)||void 0===s?void 0:s.action)&&u(this,Ma,"m",Ha).call(this,u(this,Da,"f")):u(this,Ma,"m",Ha).call(this,u(this,_a,"f")):null===(i=e.source)||void 0===i||i.postMessage({action:"widget-flow-hello-ack",nonce:null===(o=e.data)||void 0===o?void 0:o.nonce},e.origin):null===(t=this.logger)||void 0===t||t.debug(`Ignoring popup message from unexpected origin "${e.origin}"`))}),"f"),window.addEventListener("message",u(this,La,"f")),h(this,Wa,setInterval((()=>{var e;(null===(e=u(this,Pa,"f"))||void 0===e?void 0:e.closed)&&u(this,Ma,"m",Ha).call(this,u(this,Fa,"f"))}),1e3),"f"),h(this,Ba,(()=>{"hidden"!==document.visibilityState&&(u(this,Va,"f")||u(this,Ua,"f")||(h(this,Va,!0,"f"),u(this,qa,"f").forEach((e=>e()))))}),"f"),window.addEventListener("focus",u(this,Ba,"f")),document.addEventListener("visibilitychange",u(this,Ba,"f")),Ga=this,!0):(null===(n=this.logger)||void 0===n||n.warn("Flow popup was blocked by the browser"),!1)}close(){var e;try{null===(e=u(this,Pa,"f"))||void 0===e||e.close()}catch(e){}u(this,Ma,"m",Ha).call(this,u(this,Fa,"f"))}remove(){u(this,Ma,"m",Ka).call(this)}standDown(){h(this,Ua,!0,"f"),u(this,Ma,"m",za).call(this),h(this,Pa,null,"f")}};Pa=new WeakMap,Ta=new WeakMap,Wa=new WeakMap,La=new WeakMap,Ua=new WeakMap,Da=new WeakMap,Fa=new WeakMap,_a=new WeakMap,qa=new WeakMap,Ba=new WeakMap,Va=new WeakMap,Ma=new WeakSet,Ka=function(){u(this,Ma,"m",za).call(this),Ga===this&&(Ga=null)},Ha=function(e){u(this,Ua,"f")||(h(this,Ua,!0,"f"),u(this,Ma,"m",Ka).call(this),e.forEach((e=>e())))},za=function(){u(this,Wa,"f")&&(clearInterval(u(this,Wa,"f")),h(this,Wa,void 0,"f")),u(this,La,"f")&&(window.removeEventListener("message",u(this,La,"f")),h(this,La,void 0,"f")),u(this,Ba,"f")&&(window.removeEventListener("focus",u(this,Ba,"f")),document.removeEventListener("visibilitychange",u(this,Ba,"f")),h(this,Ba,void 0,"f"))};let Ya=class extends ya{constructor(){super(...arguments),this.nodeName="descope-multi-line-mappings"}setData(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("data",JSON.stringify(e))}get value(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.value)||[]}set value(e){this.ele&&(this.ele.value=e)}get mergedValue(){return Object.entries(this.value.filter((({tenantId:e})=>!!e)).reduce(((e,{tenantId:t,roleNames:n})=>(e[t]=[...new Set([...e[t]||[],...n])],e)),{})).map((([e,t])=>({tenantId:e,roleNames:t})))}};const Xa=({label:e,value:t,description:n})=>{const i=document.createElement("span");i.setAttribute("data-name",e),i.setAttribute("data-id",t),i.style.display="flex",i.style.flexDirection="column";const o=document.createElement("span");if(o.textContent=e,i.appendChild(o),n){const e=document.createElement("span");e.textContent=n,e.style.opacity="0.6",e.style.fontSize="0.85em",i.appendChild(e)}return i.outerHTML};let Qa=class extends ya{constructor(){super(...arguments),this.nodeName="descope-multi-select-combo-box"}async setData(e){const t=await this.asyncEle;t&&(e.some((e=>e.description))&&(t.renderItem=Xa),t.setAttribute("data",JSON.stringify([...e].sort(((e,t)=>e.label.localeCompare(t.label))))))}},ed=class extends ya{constructor(){super(...arguments),this.nodeName="descope-notification"}close(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("opened")}show(){var e;null===(e=this.ele)||void 0===e||e.setAttribute("opened","true")}setContent(e){this.ele.innerHTML="",this.ele.appendChild(e.content.cloneNode(!0))}remove(){var e;null===(e=this.ele)||void 0===e||e.remove()}},td=class extends ya{constructor(){super(...arguments),this.nodeName="descope-outbound-apps"}set data(e){this.ele&&(this.ele.data=e)}get data(){var e;return null===(e=this.ele)||void 0===e?void 0:e.data}get ele(){return super.ele}get connectFlowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("connect-flow-id"))||""}get disconnectFlowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("disconnect-flow-id"))||""}onConnectClick(e){var t;const n=t=>e(t.detail);return null===(t=this.ele)||void 0===t||t.addEventListener("connect-clicked",n),()=>{var e;return null===(e=this.ele)||void 0===e?void 0:e.removeEventListener("connect-clicked",n)}}onDisconnectClick(e){var t;const n=t=>e(t.detail);return null===(t=this.ele)||void 0===t||t.addEventListener("disconnect-clicked",n),()=>{var e;return null===(e=this.ele)||void 0===e?void 0:e.removeEventListener("disconnect-clicked",n)}}},nd=class extends ya{constructor(){super(...arguments),this.nodeName="descope-combo-box"}onInput(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("input",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("input",e)}}get value(){var e;return null===(e=this.ele)||void 0===e?void 0:e.value}set value(e){this.ele&&(this.ele.value=e)}async setData(e){var t;null===(t=await this.asyncEle)||void 0===t||t.setAttribute("data",JSON.stringify(e.sort()))}setAllowCustomValue(e){this.ele&&this.ele.toggleAttribute("allow-custom-value",e)}},id=class extends ya{constructor(){super(...arguments),this.nodeName="descope-text"}get ele(){return super.ele}get text(){var e;return null===(e=this.ele)||void 0===e?void 0:e.innerText}set text(e){this.ele&&(this.ele.innerText=e)}},od=class extends ya{constructor(){super(...arguments),this.nodeName="descope-text-field"}onInput(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("input",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("input",e)}}get value(){var e;return null===(e=this.ele)||void 0===e?void 0:e.value}set value(e){this.ele&&(this.ele.value=e)}disable(){var e;null===(e=this.ele)||void 0===e||e.setAttribute("disabled","true")}enable(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("disabled")}},rd=class extends ya{constructor(){super(...arguments),this.nodeName="descope-user-attribute"}set value(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("value",e)}set badgeLabel(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("badge-label",e)}get label(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("label"))||""}get editFlowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("edit-flow-id"))||""}get deleteFlowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("delete-flow-id"))||""}onEditClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("edit-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("edit-clicked",e)}}onDeleteClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("delete-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("delete-clicked",e)}}},sd=class extends ya{constructor(){super(...arguments),this.nodeName="descope-user-auth-method"}set fulfilled(e){var t,n;e?null===(t=this.ele)||void 0===t||t.setAttribute("fulfilled","true"):null===(n=this.ele)||void 0===n||n.removeAttribute("fulfilled")}onUnfulfilledButtonClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("button-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("button-clicked",e)}}onFulfilledButtonClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("fulfilled-button-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("fulfilled-button-clicked",e)}}get flowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("flow-id")}get fulfilledFlowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("fulfilled-flow-id")}},ad=class extends ya{constructor(){super(...arguments),this.nodeName="descope-trusted-devices"}set displayName(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("display-name",e)}get ele(){return super.ele}get data(){var e;return null===(e=this.ele)||void 0===e?void 0:e.data}set data(e){this.ele&&(this.ele.data=e)}get flowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("flow-id")}onRemoveDeviceClick(e){var t;const n=t=>e(t.detail);return null===(t=this.ele)||void 0===t||t.addEventListener("remove-device-clicked",n),()=>{var e;return null===(e=this.ele)||void 0===e?void 0:e.removeEventListener("remove-device-clicked",n)}}},dd=class extends nd{get action(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("data-action"))||""}get refreshTimeout(){var e;return Number(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("data-refresh-timeout"))||500}get shouldReload(){return"reload"===this.action}},ld=class extends ya{constructor(){super(...arguments),this.nodeName="descope-user-passkeys"}get ele(){return super.ele}get data(){var e;return null===(e=this.ele)||void 0===e?void 0:e.data}set data(e){this.ele&&(this.ele.data=e)}get addPasskeyFlowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("add-passkey-flow-id")}get removePasskeyFlowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("remove-passkey-flow-id")}onAddPasskeyClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("add-passkey-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("add-passkey-clicked",e)}}onRemovePasskeyClick(e){var t;const n=t=>e(t.detail);return null===(t=this.ele)||void 0===t||t.addEventListener("remove-passkey-clicked",n),()=>{var e;return null===(e=this.ele)||void 0===e?void 0:e.removeEventListener("remove-passkey-clicked",n)}}},cd=class extends ya{constructor(){super(...arguments),this.nodeName="descope-multi-sso"}set data(e){this.ele&&(this.ele.data=e)}get data(){var e;return null===(e=this.ele)||void 0===e?void 0:e.data}get ele(){return super.ele}get createFlowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("data-create-flow-id"))||""}get deleteFlowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("data-delete-flow-id"))||""}onCreateClicked(e){var t;const n=()=>e();return null===(t=this.ele)||void 0===t||t.addEventListener("create-clicked",n),()=>{var e;return null===(e=this.ele)||void 0===e?void 0:e.removeEventListener("create-clicked",n)}}onDeleteClicked(e){var t;const n=t=>e(t.detail);return null===(t=this.ele)||void 0===t||t.addEventListener("delete-clicked",n),()=>{var e;return null===(e=this.ele)||void 0===e?void 0:e.removeEventListener("delete-clicked",n)}}};const ud=Ti((e=>{var t,n;const i=Ei(Os,Xs,Hs)(e);return n=class extends i{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends Ja{setContent(t){e(t),super.setContent(t)}}})())}get modalDriverClass(){return u(this,t,"f")}createModal(e,n=u(this,t,"f")){const i=((e={})=>{const t=document.createElement(pa);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(i),new n(i,{logger:this.logger})}async init(){var e;this.loadDescopeUiComponents([pa]),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},t=new WeakMap,n})),hd=Ti((e=>class extends(ud(e)){createFlowModal(e){const t=this.modalDriverClass;return this.createModal(e,class extends t{setContent(e){const t=e.content.querySelector("descope-wc");t&&!t.hasAttribute("lazy-start")&&t.setAttribute("lazy-start","true"),super.setContent(e)}async open(){var e,t,n;await super.open(),null===(n=null===(t=null===(e=this.ele)||void 0===e?void 0:e.querySelector("descope-wc"))||void 0===t?void 0:t.start)||void 0===n||n.call(t)}})}})),fd="descope-notification",pd=Ti((e=>{var t,n;const i=Ei(Os,Xs,Hs)(e);return n=class extends i{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends ed{setContent(t){const n="string"==typeof t?xi(t):t;e(n),super.setContent(n)}}})())}createNotification(e){const n=((e={})=>{const t=document.createElement(fd);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(u(this,t,"f"))(n,{logger:this.logger})}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),this.loadDescopeUiComponents([fd])}},t=new WeakMap,n}));function vd(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var gd=(()=>"function"==typeof Symbol&&Symbol.observable||"@@observable")(),md=()=>Math.random().toString(36).substring(7).split("").join("."),yd={INIT:`@@redux/INIT${md()}`,REPLACE:`@@redux/REPLACE${md()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${md()}`};function bd(e){if("object"!=typeof e||null===e)return!1;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||null===Object.getPrototypeOf(e)}function wd(e){if(void 0===e)return"undefined";if(null===e)return"null";const t=typeof e;switch(t){case"boolean":case"string":case"number":case"symbol":case"function":return t}if(Array.isArray(e))return"array";if(function(e){return e instanceof Date||"function"==typeof e.toDateString&&"function"==typeof e.getDate&&"function"==typeof e.setDate}(e))return"date";if(function(e){return e instanceof Error||"string"==typeof e.message&&e.constructor&&"number"==typeof e.constructor.stackTraceLimit}(e))return"error";const n=function(e){return"function"==typeof e.constructor?e.constructor.name:null}(e);switch(n){case"Symbol":case"Promise":case"WeakMap":case"WeakSet":case"Map":case"Set":return n}return Object.prototype.toString.call(e).slice(8,-1).toLowerCase().replace(/\s/g,"")}function $d(e){let t=typeof e;return"production"!==process.env.NODE_ENV&&(t=wd(e)),t}function kd(e,t,n){if("function"!=typeof e)throw new Error("production"===process.env.NODE_ENV?vd(2):`Expected the root reducer to be a function. Instead, received: '${$d(e)}'`);if("function"==typeof t&&"function"==typeof n||"function"==typeof n&&"function"==typeof arguments[3])throw new Error("production"===process.env.NODE_ENV?vd(0):"It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function. See https://redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.");if("function"==typeof t&&void 0===n&&(n=t,t=void 0),void 0!==n){if("function"!=typeof n)throw new Error("production"===process.env.NODE_ENV?vd(1):`Expected the enhancer to be a function. Instead, received: '${$d(n)}'`);return n(kd)(e,t)}let i=e,o=t,r=new Map,s=r,a=0,d=!1;function l(){s===r&&(s=new Map,r.forEach(((e,t)=>{s.set(t,e)})))}function c(){if(d)throw new Error("production"===process.env.NODE_ENV?vd(3):"You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return o}function u(e){if("function"!=typeof e)throw new Error("production"===process.env.NODE_ENV?vd(4):`Expected the listener to be a function. Instead, received: '${$d(e)}'`);if(d)throw new Error("production"===process.env.NODE_ENV?vd(5):"You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api/store#subscribelistener for more details.");let t=!0;l();const n=a++;return s.set(n,e),function(){if(t){if(d)throw new Error("production"===process.env.NODE_ENV?vd(6):"You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api/store#subscribelistener for more details.");t=!1,l(),s.delete(n),r=null}}}function h(e){if(!bd(e))throw new Error("production"===process.env.NODE_ENV?vd(7):`Actions must be plain objects. Instead, the actual type was: '${$d(e)}'. You may need to add middleware to your store setup to handle dispatching other values, such as 'redux-thunk' to handle dispatching functions. See https://redux.js.org/tutorials/fundamentals/part-4-store#middleware and https://redux.js.org/tutorials/fundamentals/part-6-async-logic#using-the-redux-thunk-middleware for examples.`);if(void 0===e.type)throw new Error("production"===process.env.NODE_ENV?vd(8):'Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');if("string"!=typeof e.type)throw new Error("production"===process.env.NODE_ENV?vd(17):`Action "type" property must be a string. Instead, the actual type was: '${$d(e.type)}'. Value was: '${e.type}' (stringified)`);if(d)throw new Error("production"===process.env.NODE_ENV?vd(9):"Reducers may not dispatch actions.");try{d=!0,o=i(o,e)}finally{d=!1}return(r=s).forEach((e=>{e()})),e}h({type:yd.INIT});return{dispatch:h,subscribe:u,getState:c,replaceReducer:function(e){if("function"!=typeof e)throw new Error("production"===process.env.NODE_ENV?vd(10):`Expected the nextReducer to be a function. Instead, received: '${$d(e)}`);i=e,h({type:yd.REPLACE})},[gd]:function(){const e=u;return{subscribe(t){if("object"!=typeof t||null===t)throw new Error("production"===process.env.NODE_ENV?vd(11):`Expected the observer to be an object. Instead, received: '${$d(t)}'`);function n(){const e=t;e.next&&e.next(c())}n();return{unsubscribe:e(n)}},[gd](){return this}}}}}function Cd(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(e){}}function Sd(e){const t=Object.keys(e),n={};for(let i=0;i<t.length;i++){const o=t[i];"production"!==process.env.NODE_ENV&&void 0===e[o]&&Cd(`No reducer provided for key "${o}"`),"function"==typeof e[o]&&(n[o]=e[o])}const i=Object.keys(n);let o,r;"production"!==process.env.NODE_ENV&&(o={});try{!function(e){Object.keys(e).forEach((t=>{const n=e[t];if(void 0===n(void 0,{type:yd.INIT}))throw new Error("production"===process.env.NODE_ENV?vd(12):`The slice reducer for key "${t}" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.`);if(void 0===n(void 0,{type:yd.PROBE_UNKNOWN_ACTION()}))throw new Error("production"===process.env.NODE_ENV?vd(13):`The slice reducer for key "${t}" returned undefined when probed with a random type. Don't try to handle '${yd.INIT}' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.`)}))}(n)}catch(e){r=e}return function(e={},t){if(r)throw r;if("production"!==process.env.NODE_ENV){const i=function(e,t,n,i){const o=Object.keys(t),r=n&&n.type===yd.INIT?"preloadedState argument passed to createStore":"previous state received by the reducer";if(0===o.length)return"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";if(!bd(e))return`The ${r} has unexpected type of "${$d(e)}". Expected argument to be an object with the following keys: "${o.join('", "')}"`;const s=Object.keys(e).filter((e=>!t.hasOwnProperty(e)&&!i[e]));return s.forEach((e=>{i[e]=!0})),n&&n.type===yd.REPLACE?void 0:s.length>0?`Unexpected ${s.length>1?"keys":"key"} "${s.join('", "')}" found in ${r}. Expected to find one of the known reducer keys instead: "${o.join('", "')}". Unexpected keys will be ignored.`:void 0}(e,n,t,o);i&&Cd(i)}let s=!1;const a={};for(let o=0;o<i.length;o++){const r=i[o],d=n[r],l=e[r],c=d(l,t);if(void 0===c){const e=t&&t.type;throw new Error("production"===process.env.NODE_ENV?vd(14):`When called with an action of type ${e?`"${String(e)}"`:"(unknown type)"}, the slice reducer for key "${r}" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.`)}a[r]=c,s=s||c!==l}return s=s||i.length!==Object.keys(e).length,s?a:e}}function Id(...e){return 0===e.length?e=>e:1===e.length?e[0]:e.reduce(((e,t)=>(...n)=>e(t(...n))))}function Rd(e){return bd(e)&&"type"in e&&"string"==typeof e.type}var Ed=Symbol.for("immer-nothing"),xd=Symbol.for("immer-draftable"),Od=Symbol.for("immer-state"),Ad="production"!==process.env.NODE_ENV?[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}]:[];function Nd(e,...t){if("production"!==process.env.NODE_ENV){const n=Ad[e],i="function"==typeof n?n.apply(null,t):n;throw new Error(`[Immer] ${i}`)}throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var jd=Object.getPrototypeOf;function Md(e){return!!e&&!!e[Od]}function Pd(e){return!!e&&(Wd(e)||Array.isArray(e)||!!e[xd]||!!e.constructor?.[xd]||_d(e)||qd(e))}var Td=Object.prototype.constructor.toString();function Wd(e){if(!e||"object"!=typeof e)return!1;const t=jd(e);if(null===t)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object||"function"==typeof n&&Function.toString.call(n)===Td}function Ld(e,t){0===Ud(e)?Object.entries(e).forEach((([n,i])=>{t(n,i,e)})):e.forEach(((n,i)=>t(i,n,e)))}function Ud(e){const t=e[Od];return t?t.type_:Array.isArray(e)?1:_d(e)?2:qd(e)?3:0}function Dd(e,t){return 2===Ud(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Fd(e,t,n){const i=Ud(e);2===i?e.set(t,n):3===i?e.add(n):e[t]=n}function _d(e){return e instanceof Map}function qd(e){return e instanceof Set}function Bd(e){return e.copy_||e.base_}function Vd(e,t){if(_d(e))return new Map(e);if(qd(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&Wd(e)){if(!jd(e)){const t=Object.create(null);return Object.assign(t,e)}return{...e}}const n=Object.getOwnPropertyDescriptors(e);delete n[Od];let i=Reflect.ownKeys(n);for(let t=0;t<i.length;t++){const o=i[t],r=n[o];!1===r.writable&&(r.writable=!0,r.configurable=!0),(r.get||r.set)&&(n[o]={configurable:!0,writable:!0,enumerable:r.enumerable,value:e[o]})}return Object.create(jd(e),n)}function Kd(e,t=!1){return zd(e)||Md(e)||!Pd(e)||(Ud(e)>1&&(e.set=e.add=e.clear=e.delete=Hd),Object.freeze(e),t&&Ld(e,((e,t)=>Kd(t,!0)))),e}function Hd(){Nd(2)}function zd(e){return Object.isFrozen(e)}var Jd,Gd={};function Zd(e){const t=Gd[e];return t||Nd(0,e),t}function Yd(){return Jd}function Xd(e,t){t&&(Zd("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Qd(e){el(e),e.drafts_.forEach(nl),e.drafts_=null}function el(e){e===Jd&&(Jd=e.parent_)}function tl(e){return Jd={drafts_:[],parent_:Jd,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function nl(e){const t=e[Od];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function il(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return void 0!==e&&e!==n?(n[Od].modified_&&(Qd(t),Nd(4)),Pd(e)&&(e=ol(t,e),t.parent_||sl(t,e)),t.patches_&&Zd("Patches").generateReplacementPatches_(n[Od].base_,e,t.patches_,t.inversePatches_)):e=ol(t,n,[]),Qd(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Ed?e:void 0}function ol(e,t,n){if(zd(t))return t;const i=t[Od];if(!i)return Ld(t,((o,r)=>rl(e,i,t,o,r,n))),t;if(i.scope_!==e)return t;if(!i.modified_)return sl(e,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;const t=i.copy_;let o=t,r=!1;3===i.type_&&(o=new Set(t),t.clear(),r=!0),Ld(o,((o,s)=>rl(e,i,t,o,s,n,r))),sl(e,t,!1),n&&e.patches_&&Zd("Patches").generatePatches_(i,n,e.patches_,e.inversePatches_)}return i.copy_}function rl(e,t,n,i,o,r,s){if("production"!==process.env.NODE_ENV&&o===n&&Nd(5),Md(o)){const s=ol(e,o,r&&t&&3!==t.type_&&!Dd(t.assigned_,i)?r.concat(i):void 0);if(Fd(n,i,s),!Md(s))return;e.canAutoFreeze_=!1}else s&&n.add(o);if(Pd(o)&&!zd(o)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;ol(e,o),t&&t.scope_.parent_||sl(e,o)}}function sl(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Kd(t,n)}var al={get(e,t){if(t===Od)return e;const n=Bd(e);if(!Dd(n,t))return function(e,t,n){const i=cl(t,n);return i?"value"in i?i.value:i.get?.call(e.draft_):void 0}(e,n,t);const i=n[t];return e.finalized_||!Pd(i)?i:i===ll(e.base_,t)?(hl(e),e.copy_[t]=fl(i,e)):i},has:(e,t)=>t in Bd(e),ownKeys:e=>Reflect.ownKeys(Bd(e)),set(e,t,n){const i=cl(Bd(e),t);if(i?.set)return i.set.call(e.draft_,n),!0;if(!e.modified_){const i=ll(Bd(e),t),o=i?.[Od];if(o&&o.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}(n,i)&&(void 0!==n||Dd(e.base_,t)))return!0;hl(e),ul(e)}return e.copy_[t]===n&&(void 0!==n||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty:(e,t)=>(void 0!==ll(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,hl(e),ul(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=Bd(e),i=Reflect.getOwnPropertyDescriptor(n,t);return i?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:i.enumerable,value:n[t]}:i},defineProperty(){Nd(11)},getPrototypeOf:e=>jd(e.base_),setPrototypeOf(){Nd(12)}},dl={};function ll(e,t){const n=e[Od];return(n?Bd(n):e)[t]}function cl(e,t){if(!(t in e))return;let n=jd(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=jd(n)}}function ul(e){e.modified_||(e.modified_=!0,e.parent_&&ul(e.parent_))}function hl(e){e.copy_||(e.copy_=Vd(e.base_,e.scope_.immer_.useStrictShallowCopy_))}Ld(al,((e,t)=>{dl[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),dl.deleteProperty=function(e,t){return"production"!==process.env.NODE_ENV&&isNaN(parseInt(t))&&Nd(13),dl.set.call(this,e,t,void 0)},dl.set=function(e,t,n){return"production"!==process.env.NODE_ENV&&"length"!==t&&isNaN(parseInt(t))&&Nd(14),al.set.call(this,e[0],t,n,e[0])};function fl(e,t){const n=_d(e)?Zd("MapSet").proxyMap_(e,t):qd(e)?Zd("MapSet").proxySet_(e,t):function(e,t){const n=Array.isArray(e),i={type_:n?1:0,scope_:t?t.scope_:Yd(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let o=i,r=al;n&&(o=[i],r=dl);const{revoke:s,proxy:a}=Proxy.revocable(o,r);return i.draft_=a,i.revoke_=s,a}(e,t);return(t?t.scope_:Yd()).drafts_.push(n),n}function pl(e){return Md(e)||Nd(10,e),vl(e)}function vl(e){if(!Pd(e)||zd(e))return e;const t=e[Od];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Vd(e,t.scope_.immer_.useStrictShallowCopy_)}else n=Vd(e,!0);return Ld(n,((e,t)=>{Fd(n,e,vl(t))})),t&&(t.finalized_=!1),n}var gl=new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(e,t,n)=>{if("function"==typeof e&&"function"!=typeof t){const n=t;t=e;const i=this;return function(e=n,...o){return i.produce(e,(e=>t.call(this,e,...o)))}}let i;if("function"!=typeof t&&Nd(6),void 0!==n&&"function"!=typeof n&&Nd(7),Pd(e)){const o=tl(this),r=fl(e,void 0);let s=!0;try{i=t(r),s=!1}finally{s?Qd(o):el(o)}return Xd(o,n),il(i,o)}if(!e||"object"!=typeof e){if(i=t(e),void 0===i&&(i=e),i===Ed&&(i=void 0),this.autoFreeze_&&Kd(i,!0),n){const t=[],o=[];Zd("Patches").generateReplacementPatches_(e,i,t,o),n(t,o)}return i}Nd(1,e)},this.produceWithPatches=(e,t)=>{if("function"==typeof e)return(t,...n)=>this.produceWithPatches(t,(t=>e(t,...n)));let n,i;const o=this.produce(e,t,((e,t)=>{n=e,i=t}));return[o,n,i]},"boolean"==typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){Pd(e)||Nd(8),Md(e)&&(e=pl(e));const t=tl(this),n=fl(e,void 0);return n[Od].isManual_=!0,el(t),n}finishDraft(e,t){const n=e&&e[Od];n&&n.isManual_||Nd(9);const{scope_:i}=n;return Xd(i,t),il(void 0,i)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const i=t[n];if(0===i.path.length&&"replace"===i.op){e=i.value;break}}n>-1&&(t=t.slice(n+1));const i=Zd("Patches").applyPatches_;return Md(e)?i(e,t):this.produce(e,(e=>i(e,t)))}},ml=gl.produce;gl.produceWithPatches.bind(gl),gl.setAutoFreeze.bind(gl),gl.setUseStrictShallowCopy.bind(gl),gl.applyPatches.bind(gl),gl.createDraft.bind(gl),gl.finishDraft.bind(gl);var yl=(e,t,n)=>{if(1===t.length&&t[0]===n){let t=!1;try{const n={};e(n)===n&&(t=!0)}catch{}if(t){let e;try{throw new Error}catch(t){({stack:e}=t)}console.warn("The result function returned its own inputs without modification. e.g\n`createSelector([state => state.todos], todos => todos)`\nThis could lead to inefficient memoization and unnecessary re-renders.\nEnsure transformation logic is in the result function, and extraction logic is in the input selectors.",{stack:e})}}},bl=(e,t,n)=>{const{memoize:i,memoizeOptions:o}=t,{inputSelectorResults:r,inputSelectorResultsCopy:s}=e,a=i((()=>({})),...o);if(!(a.apply(null,r)===a.apply(null,s))){let e;try{throw new Error}catch(t){({stack:e}=t)}console.warn("An input selector returned a different result when passed same arguments.\nThis means your output selector will likely run more frequently than intended.\nAvoid returning a new reference inside your input selector, e.g.\n`createSelector([state => state.todos.map(todo => todo.id)], todoIds => todoIds.length)`",{arguments:n,firstInputs:r,secondInputs:s,stack:e})}},wl={inputStabilityCheck:"once",identityFunctionCheck:"once"};var $l=e=>Array.isArray(e)?e:[e];function kl(e){const t=Array.isArray(e[0])?e[0]:e;return function(e,t="expected all items to be functions, instead received the following types: "){if(!e.every((e=>"function"==typeof e))){const n=e.map((e=>"function"==typeof e?`function ${e.name||"unnamed"}()`:typeof e)).join(", ");throw new TypeError(`${t}[${n}]`)}}(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function Cl(e,t){const n=[],{length:i}=e;for(let o=0;o<i;o++)n.push(e[o].apply(null,t));return n}var Sl="undefined"!=typeof WeakRef?WeakRef:class{constructor(e){this.value=e}deref(){return this.value}},Il=0,Rl=1;function El(){return{s:Il,v:void 0,o:null,p:null}}function xl(e,t={}){let n=El();const{resultEqualityCheck:i}=t;let o,r=0;function s(){let t=n;const{length:s}=arguments;for(let e=0,n=s;e<n;e++){const n=arguments[e];if("function"==typeof n||"object"==typeof n&&null!==n){let e=t.o;null===e&&(t.o=e=new WeakMap);const i=e.get(n);void 0===i?(t=El(),e.set(n,t)):t=i}else{let e=t.p;null===e&&(t.p=e=new Map);const i=e.get(n);void 0===i?(t=El(),e.set(n,t)):t=i}}const a=t;let d;if(t.s===Rl)d=t.v;else if(d=e.apply(null,arguments),r++,i){const e=o?.deref?.()??o;null!=e&&i(e,d)&&(d=e,0!==r&&r--);o="object"==typeof d&&null!==d||"function"==typeof d?new Sl(d):d}return a.s=Rl,a.v=d,d}return s.clearCache=()=>{n=El(),s.resetResultsCount()},s.resultsCount=()=>r,s.resetResultsCount=()=>{r=0},s}function Ol(e,...t){const n="function"==typeof e?{memoize:e,memoizeOptions:t}:e,i=(...e)=>{let t,i=0,o=0,r={},s=e.pop();"object"==typeof s&&(r=s,s=e.pop()),function(e,t="expected a function, instead received "+typeof e){if("function"!=typeof e)throw new TypeError(t)}(s,`createSelector expects an output function after the inputs, but received: [${typeof s}]`);const a={...n,...r},{memoize:d,memoizeOptions:l=[],argsMemoize:c=xl,argsMemoizeOptions:u=[],devModeChecks:h={}}=a,f=$l(l),p=$l(u),v=kl(e),g=d((function(){return i++,s.apply(null,arguments)}),...f);let m=!0;const y=c((function(){o++;const e=Cl(v,arguments);if(t=g.apply(null,e),"production"!==process.env.NODE_ENV){const{identityFunctionCheck:n,inputStabilityCheck:i}=((e,t)=>{const{identityFunctionCheck:n,inputStabilityCheck:i}={...wl,...t};return{identityFunctionCheck:{shouldRun:"always"===n||"once"===n&&e,run:yl},inputStabilityCheck:{shouldRun:"always"===i||"once"===i&&e,run:bl}}})(m,h);if(n.shouldRun&&n.run(s,e,t),i.shouldRun){const t=Cl(v,arguments);i.run({inputSelectorResults:e,inputSelectorResultsCopy:t},{memoize:d,memoizeOptions:f},arguments)}m&&(m=!1)}return t}),...p);return Object.assign(y,{resultFunc:s,memoizedResultFunc:g,dependencies:v,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>t,recomputations:()=>i,resetRecomputations:()=>{i=0},memoize:d,argsMemoize:c})};return Object.assign(i,{withTypes:()=>i}),i}var Al=Ol(xl),Nl=Object.assign(((e,t=Al)=>{!function(e,t="expected an object, instead received "+typeof e){if("object"!=typeof e)throw new TypeError(t)}(e,"createStructuredSelector expects first argument to be an object where each property is a selector, instead received a "+typeof e);const n=Object.keys(e),i=t(n.map((t=>e[t])),((...e)=>e.reduce(((e,t,i)=>(e[n[i]]=t,e)),{})));return i}),{withTypes:()=>Nl});function jl(e){return({dispatch:t,getState:n})=>i=>o=>"function"==typeof o?o(t,n,e):i(o)}var Ml=jl(),Pl=jl;((...e)=>{const t=Ol(...e)})(xl);var Tl="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?Id:Id.apply(null,arguments)},Wl=e=>e&&"function"==typeof e.match;function Ll(e,t){function n(...n){if(t){let i=t(...n);if(!i)throw new Error("production"===process.env.NODE_ENV?mc(0):"prepareAction did not return an object");return{type:e,payload:i.payload,..."meta"in i&&{meta:i.meta},..."error"in i&&{error:i.error}}}return{type:e,payload:n[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=t=>Rd(t)&&t.type===e,n}function Ul(e){return"function"==typeof e&&"type"in e&&Wl(e)}function Dl(e,t){let n=0;return{measureTime(e){const t=Date.now();try{return e()}finally{const e=Date.now();n+=e-t}},warnIfExceeded(){n>e&&console.warn(`${t} took ${n}ms, which is more than the warning threshold of ${e}ms. \nIf your state or actions are very large, you may want to disable the middleware as it might cause too much of a slowdown in development mode. See https://redux-toolkit.js.org/api/getDefaultMiddleware for instructions.\nIt is disabled in production builds, so you don't need to worry about that.`)}}}var Fl=class e extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,e.prototype)}static get[Symbol.species](){return e}concat(...e){return super.concat.apply(this,e)}prepend(...t){return 1===t.length&&Array.isArray(t[0])?new e(...t[0].concat(this)):new e(...t.concat(this))}};function _l(e){return Pd(e)?ml(e,(()=>{})):e}function ql(e,t,n){if(e.has(t)){let i=e.get(t);return n.update&&(i=n.update(i,t,e),e.set(t,i)),i}if(!n.insert)throw new Error("production"===process.env.NODE_ENV?mc(10):"No insert provided for key not already in map");const i=n.insert(t,e);return e.set(t,i),i}function Bl(e){return"object"!=typeof e||null==e||Object.isFrozen(e)}function Vl(e,t,n){const i=Kl(e,t,n);return{detectMutations:()=>Hl(e,t,i,n)}}function Kl(e,t=[],n,i="",o=new Set){const r={value:n};if(!e(n)&&!o.has(n)){o.add(n),r.children={};for(const o in n){const s=i?i+"."+o:o;t.length&&-1!==t.indexOf(s)||(r.children[o]=Kl(e,t,n[o],s))}}return r}function Hl(e,t=[],n,i,o=!1,r=""){const s=n?n.value:void 0,a=s===i;if(o&&!a&&!Number.isNaN(i))return{wasMutated:!0,path:r};if(e(s)||e(i))return{wasMutated:!1};const d={};for(let e in n.children)d[e]=!0;for(let e in i)d[e]=!0;const l=t.length>0;for(let o in d){const s=r?r+"."+o:o;if(l){if(t.some((e=>e instanceof RegExp?e.test(s):s===e)))continue}const d=Hl(e,t,n.children[o],i[o],a,s);if(d.wasMutated)return d}return{wasMutated:!1}}function zl(e){const t=typeof e;return null==e||"string"===t||"boolean"===t||"number"===t||Array.isArray(e)||bd(e)}function Jl(e,t="",n=zl,i,o=[],r){let s;if(!n(e))return{keyPath:t||"<root>",value:e};if("object"!=typeof e||null===e)return!1;if(r?.has(e))return!1;const a=null!=i?i(e):Object.entries(e),d=o.length>0;for(const[e,l]of a){const a=t?t+"."+e:e;if(d){if(o.some((e=>e instanceof RegExp?e.test(a):a===e)))continue}if(!n(l))return{keyPath:a,value:l};if("object"==typeof l&&(s=Jl(l,a,n,i,o,r),s))return s}return r&&Gl(e)&&r.add(e),!1}function Gl(e){if(!Object.isFrozen(e))return!1;for(const t of Object.values(e))if("object"==typeof t&&null!==t&&!Gl(t))return!1;return!0}function Zl(e){return"boolean"==typeof e}var Yl=()=>function(e){const{thunk:t=!0,immutableCheck:n=!0,serializableCheck:i=!0,actionCreatorCheck:o=!0}=e??{};let r=new Fl;if(t&&(Zl(t)?r.push(Ml):r.push(Pl(t.extraArgument))),"production"!==process.env.NODE_ENV){if(n){let e={};Zl(n)||(e=n),r.unshift(function(e={}){if("production"===process.env.NODE_ENV)return()=>e=>t=>e(t);{let t=function(e,t,i,o){return JSON.stringify(e,n(t,o),i)},n=function(e,t){let n=[],i=[];return t||(t=function(e,t){return n[0]===t?"[Circular ~]":"[Circular ~."+i.slice(0,n.indexOf(t)).join(".")+"]"}),function(o,r){if(n.length>0){var s=n.indexOf(this);~s?n.splice(s+1):n.push(this),~s?i.splice(s,1/0,o):i.push(o),~n.indexOf(r)&&(r=t.call(this,o,r))}else n.push(r);return null==e?r:e.call(this,o,r)}},{isImmutable:i=Bl,ignoredPaths:o,warnAfter:r=32}=e;const s=Vl.bind(null,i,o);return({getState:e})=>{let n,i=e(),o=s(i);return a=>d=>{const l=Dl(r,"ImmutableStateInvariantMiddleware");l.measureTime((()=>{if(i=e(),n=o.detectMutations(),o=s(i),n.wasMutated)throw new Error("production"===process.env.NODE_ENV?mc(19):`A state mutation was detected between dispatches, in the path '${n.path||""}'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)}));const c=a(d);return l.measureTime((()=>{if(i=e(),n=o.detectMutations(),o=s(i),n.wasMutated)throw new Error("production"===process.env.NODE_ENV?mc(20):`A state mutation was detected inside a dispatch, in the path: ${n.path||""}. Take a look at the reducer(s) handling the action ${t(d)}. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)})),l.warnIfExceeded(),c}}}}(e))}if(i){let e={};Zl(i)||(e=i),r.push(function(e={}){if("production"===process.env.NODE_ENV)return()=>e=>t=>e(t);{const{isSerializable:t=zl,getEntries:n,ignoredActions:i=[],ignoredActionPaths:o=["meta.arg","meta.baseQueryMeta"],ignoredPaths:r=[],warnAfter:s=32,ignoreState:a=!1,ignoreActions:d=!1,disableCache:l=!1}=e,c=!l&&WeakSet?new WeakSet:void 0;return e=>l=>u=>{if(!Rd(u))return l(u);const h=l(u),f=Dl(s,"SerializableStateInvariantMiddleware");return d||i.length&&-1!==i.indexOf(u.type)||f.measureTime((()=>{const e=Jl(u,"",t,n,o,c);if(e){const{keyPath:t,value:n}=e;console.error(`A non-serializable value was detected in an action, in the path: \`${t}\`. Value:`,n,"\nTake a look at the logic that dispatched this action: ",u,"\n(See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)","\n(To allow non-serializable values see: https://redux-toolkit.js.org/usage/usage-guide#working-with-non-serializable-data)")}})),a||(f.measureTime((()=>{const i=Jl(e.getState(),"",t,n,r,c);if(i){const{keyPath:e,value:t}=i;console.error(`A non-serializable value was detected in the state, in the path: \`${e}\`. Value:`,t,`\nTake a look at the reducer(s) handling this action type: ${u.type}.\n(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)`)}})),f.warnIfExceeded()),h}}}(e))}if(o){let e={};Zl(o)||(e=o),r.unshift(function(e={}){if("production"===process.env.NODE_ENV)return()=>e=>t=>e(t);const{isActionCreator:t=Ul}=e;return()=>e=>n=>(t(n)&&console.warn(function(e){const t=e?`${e}`.split("/"):[],n=t[t.length-1]||"actionCreator";return`Detected an action creator with type "${e||"unknown"}" being dispatched. \nMake sure you're calling the action creator before dispatching, i.e. \`dispatch(${n}())\` instead of \`dispatch(${n})\`. This is necessary even if the action has no payload.`}(n.type)),e(n))}(e))}}return r},Xl=e=>t=>{setTimeout(t,e)},Ql="undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame:Xl(10),ec=e=>function(t){const{autoBatch:n=!0}=t??{};let i=new Fl(e);return n&&i.push(((e={type:"raf"})=>t=>(...n)=>{const i=t(...n);let o=!0,r=!1,s=!1;const a=new Set,d="tick"===e.type?queueMicrotask:"raf"===e.type?Ql:"callback"===e.type?e.queueNotification:Xl(e.timeout),l=()=>{s=!1,r&&(r=!1,a.forEach((e=>e())))};return Object.assign({},i,{subscribe(e){const t=i.subscribe((()=>o&&e()));return a.add(e),()=>{t(),a.delete(e)}},dispatch(e){try{return o=!e?.meta?.RTK_autoBatch,r=!o,r&&(s||(s=!0,d(l))),i.dispatch(e)}finally{o=!0}}})})("object"==typeof n?n:void 0)),i},tc="production"===process.env.NODE_ENV;function nc(e){const t=Yl(),{reducer:n,middleware:i,devTools:o=!0,preloadedState:r,enhancers:s}=e||{};let a,d;if("function"==typeof n)a=n;else{if(!bd(n))throw new Error("production"===process.env.NODE_ENV?mc(1):"`reducer` is a required argument, and must be a function or an object of functions that can be passed to combineReducers");a=Sd(n)}if(!tc&&i&&"function"!=typeof i)throw new Error("production"===process.env.NODE_ENV?mc(2):"`middleware` field must be a callback");if("function"==typeof i){if(d=i(t),!tc&&!Array.isArray(d))throw new Error("production"===process.env.NODE_ENV?mc(3):"when using a middleware builder function, an array of middleware must be returned")}else d=t();if(!tc&&d.some((e=>"function"!=typeof e)))throw new Error("production"===process.env.NODE_ENV?mc(4):"each middleware provided to configureStore must be a function");let l=Id;o&&(l=Tl({trace:!tc,..."object"==typeof o&&o}));const c=function(...e){return t=>(n,i)=>{const o=t(n,i);let r=()=>{throw new Error("production"===process.env.NODE_ENV?vd(15):"Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")};const s={getState:o.getState,dispatch:(e,...t)=>r(e,...t)},a=e.map((e=>e(s)));return r=Id(...a)(o.dispatch),{...o,dispatch:r}}}(...d),u=ec(c);if(!tc&&s&&"function"!=typeof s)throw new Error("production"===process.env.NODE_ENV?mc(5):"`enhancers` field must be a callback");let h="function"==typeof s?s(u):u();if(!tc&&!Array.isArray(h))throw new Error("production"===process.env.NODE_ENV?mc(6):"`enhancers` callback must return an array");if(!tc&&h.some((e=>"function"!=typeof e)))throw new Error("production"===process.env.NODE_ENV?mc(7):"each enhancer provided to configureStore must be a function");tc||!d.length||h.includes(c)||console.error("middlewares were provided, but middleware enhancer was not included in final enhancers - make sure to call `getDefaultEnhancers`");return kd(a,r,l(...h))}function ic(e){const t={},n=[];let i;const o={addCase(e,r){if("production"!==process.env.NODE_ENV){if(n.length>0)throw new Error("production"===process.env.NODE_ENV?mc(26):"`builder.addCase` should only be called before calling `builder.addMatcher`");if(i)throw new Error("production"===process.env.NODE_ENV?mc(27):"`builder.addCase` should only be called before calling `builder.addDefaultCase`")}const s="string"==typeof e?e:e.type;if(!s)throw new Error("production"===process.env.NODE_ENV?mc(28):"`builder.addCase` cannot be called with an empty action type");if(s in t)throw new Error("production"===process.env.NODE_ENV?mc(29):`\`builder.addCase\` cannot be called with two reducers for the same action type '${s}'`);return t[s]=r,o},addMatcher(e,t){if("production"!==process.env.NODE_ENV&&i)throw new Error("production"===process.env.NODE_ENV?mc(30):"`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");return n.push({matcher:e,reducer:t}),o},addDefaultCase(e){if("production"!==process.env.NODE_ENV&&i)throw new Error("production"===process.env.NODE_ENV?mc(31):"`builder.addDefaultCase` can only be called once");return i=e,o}};return e(o),[t,n,i]}function oc(...e){return t=>e.some((e=>((e,t)=>Wl(e)?e.match(t):e(t))(e,t)))}var rc=["name","message","stack","code"],sc=class{constructor(e,t){this.payload=e,this.meta=t}_type},ac=class{constructor(e,t){this.payload=e,this.meta=t}_type},dc=e=>{if("object"==typeof e&&null!==e){const t={};for(const n of rc)"string"==typeof e[n]&&(t[n]=e[n]);return t}return{message:String(e)}},lc=(()=>{function e(e,t,n){const i=Ll(e+"/fulfilled",((e,t,n,i)=>({payload:e,meta:{...i||{},arg:n,requestId:t,requestStatus:"fulfilled"}}))),o=Ll(e+"/pending",((e,t,n)=>({payload:void 0,meta:{...n||{},arg:t,requestId:e,requestStatus:"pending"}}))),r=Ll(e+"/rejected",((e,t,i,o,r)=>({payload:o,error:(n&&n.serializeError||dc)(e||"Rejected"),meta:{...r||{},arg:i,requestId:t,rejectedWithValue:!!o,requestStatus:"rejected",aborted:"AbortError"===e?.name,condition:"ConditionError"===e?.name}})));return Object.assign((function(e){return(s,a,d)=>{const l=n?.idGenerator?n.idGenerator(e):((e=21)=>{let t="",n=e;for(;n--;)t+="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW"[64*Math.random()|0];return t})(),c=new AbortController;let u;function h(e){u=e,c.abort()}const f=async function(){let f;try{let r=n?.condition?.(e,{getState:a,extra:d});if(null!==(p=r)&&"object"==typeof p&&"function"==typeof p.then&&(r=await r),!1===r||c.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};const v=new Promise(((e,t)=>c.signal.addEventListener("abort",(()=>t({name:"AbortError",message:u||"Aborted"})))));s(o(l,e,n?.getPendingMeta?.({requestId:l,arg:e},{getState:a,extra:d}))),f=await Promise.race([v,Promise.resolve(t(e,{dispatch:s,getState:a,extra:d,requestId:l,signal:c.signal,abort:h,rejectWithValue:(e,t)=>new sc(e,t),fulfillWithValue:(e,t)=>new ac(e,t)})).then((t=>{if(t instanceof sc)throw t;return t instanceof ac?i(t.payload,l,e,t.meta):i(t,l,e)}))])}catch(t){f=t instanceof sc?r(null,l,e,t.payload,t.meta):r(t,l,e)}var p;return n&&!n.dispatchConditionRejection&&r.match(f)&&f.meta.condition||s(f),f}();return Object.assign(f,{abort:h,requestId:l,arg:e,unwrap:()=>f.then(cc)})}}),{pending:o,rejected:r,fulfilled:i,settled:oc(r,i),typePrefix:e})}return e.withTypes=()=>e,e})();function cc(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}var uc=Symbol.for("rtk-slice-createasyncthunk");function hc(e,t){return`${e}/${t}`}function fc(e,t,n,i){function o(o,...r){let s=n.call(e,o);if(void 0===s)if(i)s=e.getInitialState();else if("production"!==process.env.NODE_ENV)throw new Error("production"===process.env.NODE_ENV?mc(16):"selectState returned undefined for an uninjected slice reducer");return t(s,...r)}return o.unwrapped=t,o}var pc=function({creators:e}={}){const t=e?.asyncThunk?.[uc];return function(e){const{name:n,reducerPath:i=n}=e;if(!n)throw new Error("production"===process.env.NODE_ENV?mc(11):"`name` is a required option for createSlice");"undefined"!=typeof process&&"development"===process.env.NODE_ENV&&void 0===e.initialState&&console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");const o=("function"==typeof e.reducers?e.reducers(function(){function e(e,t){return{_reducerDefinitionType:"asyncThunk",payloadCreator:e,...t}}return e.withTypes=()=>e,{reducer:e=>Object.assign({[e.name]:(...t)=>e(...t)}[e.name],{_reducerDefinitionType:"reducer"}),preparedReducer:(e,t)=>({_reducerDefinitionType:"reducerWithPrepare",prepare:e,reducer:t}),asyncThunk:e}}()):e.reducers)||{},r=Object.keys(o),s={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},a={addCase(e,t){const n="string"==typeof e?e:e.type;if(!n)throw new Error("production"===process.env.NODE_ENV?mc(12):"`context.addCase` cannot be called with an empty action type");if(n in s.sliceCaseReducersByType)throw new Error("production"===process.env.NODE_ENV?mc(13):"`context.addCase` cannot be called with two reducers for the same action type: "+n);return s.sliceCaseReducersByType[n]=t,a},addMatcher:(e,t)=>(s.sliceMatchers.push({matcher:e,reducer:t}),a),exposeAction:(e,t)=>(s.actionCreators[e]=t,a),exposeCaseReducer:(e,t)=>(s.sliceCaseReducersByName[e]=t,a)};function d(){if("production"!==process.env.NODE_ENV&&"object"==typeof e.extraReducers)throw new Error("production"===process.env.NODE_ENV?mc(14):"The object notation for `createSlice.extraReducers` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createSlice");const[t={},n=[],i]="function"==typeof e.extraReducers?ic(e.extraReducers):[e.extraReducers],o={...t,...s.sliceCaseReducersByType};return function(e,t){if("production"!==process.env.NODE_ENV&&"object"==typeof t)throw new Error("production"===process.env.NODE_ENV?mc(8):"The object notation for `createReducer` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer");let n,[i,o,r]=ic(t);if(function(e){return"function"==typeof e}(e))n=()=>_l(e());else{const t=_l(e);n=()=>t}function s(e=n(),t){let s=[i[t.type],...o.filter((({matcher:e})=>e(t))).map((({reducer:e})=>e))];return 0===s.filter((e=>!!e)).length&&(s=[r]),s.reduce(((e,n)=>{if(n){if(Md(e)){const i=n(e,t);return void 0===i?e:i}if(Pd(e))return ml(e,(e=>n(e,t)));{const i=n(e,t);if(void 0===i){if(null===e)return e;throw new Error("production"===process.env.NODE_ENV?mc(9):"A case reducer on a non-draftable value must not return undefined")}return i}}return e}),e)}return s.getInitialState=n,s}(e.initialState,(e=>{for(let t in o)e.addCase(t,o[t]);for(let t of s.sliceMatchers)e.addMatcher(t.matcher,t.reducer);for(let t of n)e.addMatcher(t.matcher,t.reducer);i&&e.addDefaultCase(i)}))}r.forEach((i=>{const r=o[i],s={reducerName:i,type:hc(n,i),createNotation:"function"==typeof e.reducers};!function(e){return"asyncThunk"===e._reducerDefinitionType}(r)?function({type:e,reducerName:t,createNotation:n},i,o){let r,s;if("reducer"in i){if(n&&!function(e){return"reducerWithPrepare"===e._reducerDefinitionType}(i))throw new Error("production"===process.env.NODE_ENV?mc(17):"Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");r=i.reducer,s=i.prepare}else r=i;o.addCase(e,r).exposeCaseReducer(t,r).exposeAction(t,s?Ll(e,s):Ll(e))}(s,r,a):function({type:e,reducerName:t},n,i,o){if(!o)throw new Error("production"===process.env.NODE_ENV?mc(18):"Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`.");const{payloadCreator:r,fulfilled:s,pending:a,rejected:d,settled:l,options:c}=n,u=o(e,r,c);i.exposeAction(t,u),s&&i.addCase(u.fulfilled,s);a&&i.addCase(u.pending,a);d&&i.addCase(u.rejected,d);l&&i.addMatcher(u.settled,l);i.exposeCaseReducer(t,{fulfilled:s||vc,pending:a||vc,rejected:d||vc,settled:l||vc})}(s,r,a,t)}));const l=e=>e,c=new WeakMap;let u;const h={name:n,reducerPath:i,reducer:(e,t)=>(u||(u=d()),u(e,t)),actions:s.actionCreators,caseReducers:s.sliceCaseReducersByName,getInitialState:()=>(u||(u=d()),u.getInitialState()),getSelectors(t=l){const n=ql(c,this,{insert:()=>new WeakMap});return ql(n,t,{insert:()=>{const n={};for(const[i,o]of Object.entries(e.selectors??{}))n[i]=fc(this,o,t,this!==h);return n}})},selectSlice(e){let t=e[this.reducerPath];if(void 0===t)if(this!==h)t=this.getInitialState();else if("production"!==process.env.NODE_ENV)throw new Error("production"===process.env.NODE_ENV?mc(15):"selectSlice returned undefined for an uninjected slice reducer");return t},get selectors(){return this.getSelectors(this.selectSlice)},injectInto(e,{reducerPath:t,...n}={}){const i=t??this.reducerPath;return e.inject({reducerPath:i,reducer:this.reducer},n),{...this,reducerPath:i}}};return h}}();function vc(){}var gc="listenerMiddleware";function mc(e){return`Minified Redux Toolkit error #${e}; visit https://redux-toolkit.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}Ll(`${gc}/add`),Ll(`${gc}/removeAll`),Ll(`${gc}/remove`);const yc=e=>Ti((t=>{const n=pc(e),i=Object.assign(Object.assign({},n.actions),e.asyncActions);return class extends(Ei(Cs)(t)){constructor(...e){super(...e);const t=nc({reducer:n.reducer,middleware:e=>e({thunk:{extraArgument:this},serializableCheck:!1}),devTools:!1}),o=e=>async(...n)=>{const i=await t.dispatch(e(...n));try{cc(i)}catch(e){this.logger.error(e.message,i.type,e.stack)}return i},r=Object.keys(i).reduce(((e,t)=>(e[t]=o(i[t]),e)),{});this.actions=r,this.subscribe=(e,n=e=>e)=>t.subscribe((()=>e(n(t.getState()))))}}})),bc=Ti((e=>class extends(Cs(e)){validateForm(e){return this.getFormInputs(e).every((e=>{var t,n;return null===(t=e.reportValidity)||void 0===t||t.call(e),null===(n=e.checkValidity)||void 0===n?void 0:n.call(e)}))}getFormInputs(e){return e?Array.from(e.querySelectorAll("[name]")):(this.logger.debug("cannot get form inputs, no root element was received"),[])}getFormData(e){return this.getFormInputs(e).reduce(((e,t)=>Object.assign(e,{[t.getAttribute("name")]:t.value})),{})}setFormData(e,t){this.getFormInputs(e).forEach((e=>{t.hasOwnProperty(e.getAttribute("name"))&&(e.value=t[e.getAttribute("name")])}))}resetFormData(e){this.getFormInputs(e).forEach((e=>{e.value="",e.checked=!1}))}getFormFieldNames(e){return this.getFormInputs(e).map((e=>e.name))}disableFormField(e,t){var n;null===(n=this.getFormInputs(e).find((e=>e.name===t)))||void 0===n||n.setAttribute("disabled","true")}removeFormField(e,t){var n;null===(n=this.getFormInputs(e).find((e=>e.name===t)))||void 0===n||n.remove()}})),wc=Ti((e=>{const t=Ei(Ns({"widget-id":xs}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}}})),$c=Ti((e=>{const t=Ei(Us,wc)(e);return class extends t{async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this))}async getWidgetConfig(){var e,t;const n=await this.config;return null===(t=null===(e=null==n?void 0:n.projectConfig)||void 0===e?void 0:e.widgets)||void 0===t?void 0:t[this.widgetId]}async getHostedPageBaseUrl(){var e;const t=await this.config;return null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.hostedPageBaseUrl}}})),kc=Ti((e=>class extends e{get locale(){return this.getAttribute("locale")||""}get localeCandidates(){const{locale:e,fallback:t}=Ki(this.locale);return[...new Set([e,t].filter(Boolean))]}firstAvailableLocale(e){var t;const n=(null!=e?e:[]).map((e=>e.toLowerCase()));return null!==(t=this.localeCandidates.find((e=>n.includes(e))))&&void 0!==t?t:""}})),Cc=e=>Ti((t=>{var n,i,o;const r=Ei(Ws,wc,$c,kc)(t);return o=class extends r{constructor(){super(...arguments),n.add(this)}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this))}async fetchWidgetPage(t){const o=await u(this,n,"m",i).call(this,t);if(void 0!==o)return o;const r=await this.fetchStaticResource(`${e}/${this.widgetId}/${t}`,"text");return null==r?void 0:r.body}},n=new WeakSet,i=async function(t){var n;const i=await this.getWidgetConfig(),o=this.firstAvailableLocale(null!==(n=null==i?void 0:i.targetLocales)&&void 0!==n?n:[]);if(!o)return;const r=".html",s=t.endsWith(r)?t.slice(0,-5):t;try{const t=await this.fetchStaticResource(`${e}/${this.widgetId}/${s}-${o}${r}`,"text");return null==t?void 0:t.body}catch(e){return}},o})),Sc=Ti((e=>class extends e{get refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}})),Ic=Ti((e=>{var t,n,i;return i=class extends(sa(e)){constructor(){super(...arguments),t.add(this)}get clientInput(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(e){return{}}}get formInput(){return this.getAttribute("form")||void 0}createFlowTemplate(e){var{flowId:i,client:o,form:r}=e,s=l(e,["flowId","client","form"]);return Pi(Object.assign({projectId:this.getAttribute("project-id"),flowId:i,baseUrl:this.getAttribute("base-url")||"",baseStaticUrl:this.getAttribute("base-static-url")||"",baseCdnUrl:this.getAttribute("base-cdn-url")||"",refreshCookieName:this.getAttribute("refresh-cookie-name")||"",theme:this.theme,"style-id":this.styleId,locale:this.getAttribute("locale")||"",form:u(this,t,"m",n).call(this,r),client:Object.assign(Object.assign({},this.clientInput),o)},s))}},t=new WeakSet,n=function(e){const t=this.formInput;if(!e)return t;if(!t)return e;try{return Object.assign(Object.assign({},JSON.parse(t)),e)}catch(t){return e}},i})),Rc=/(["\\])/g;function Ec(e,t){return Array.from(e.querySelectorAll(`[data-id="${n=t,"undefined"!=typeof CSS&&"function"==typeof CSS.escape?CSS.escape(n):n.replace(Rc,"\\$1")}"]`));var n}function xc(e,t){e&&t&&Object.entries(t).forEach((([t,n])=>{Ec(e,t).forEach((e=>function(e,t){var n;switch(t){case"hide":e.setAttribute("hidden",""),null===(n=e.style)||void 0===n||n.setProperty("display","none","important");break;case"disable":e.setAttribute("disabled","true");break;case"read-only":e.setAttribute("readonly","true")}}(e,n)))}))}const Oc=Ti((e=>{var t,n,i,o,r,s;const a=Ei(Cs,Xs)(e);return s=class extends a{constructor(){super(...arguments),t.add(this),n.set(this,void 0),i.set(this,{})}async init(){var e,i;if("true"===this.getAttribute("mock"))return h(this,n,Promise.resolve({}),"f"),void await(null===(e=super.init)||void 0===e?void 0:e.call(this));const s=u(this,t,"m",o).call(this);h(this,n,u(this,t,"m",r).call(this,s),"f"),await(null===(i=super.init)||void 0===i?void 0:i.call(this))}async onWidgetRootReady(){var e,t;await(null===(e=super.onWidgetRootReady)||void 0===e?void 0:e.call(this)),h(this,i,null!==(t=await u(this,n,"f"))&&void 0!==t?t:{},"f"),xc(this.contentRootElement,u(this,i,"f"))}async reevaluateComponentsState(){const e=u(this,t,"m",o).call(this);var n,s;n=this.contentRootElement,s=u(this,i,"f"),n&&s&&Object.entries(s).forEach((([e,t])=>{Ec(n,e).forEach((e=>function(e,t){var n;switch(t){case"hide":e.removeAttribute("hidden"),null===(n=e.style)||void 0===n||n.removeProperty("display");break;case"disable":e.removeAttribute("disabled");break;case"read-only":e.removeAttribute("readonly")}}(e,t)))})),h(this,i,await u(this,t,"m",r).call(this,e),"f"),xc(this.contentRootElement,u(this,i,"f"))}},n=new WeakMap,i=new WeakMap,t=new WeakSet,o=function(){var e;const t=null===(e=this.api)||void 0===e?void 0:e.httpClient;if(!t)throw new Error("componentsConditionsMixin: the widget sdk must expose `httpClient`. Compose apiMixin and return `webSdk.httpClient` from createSdk.");return t},r=async function(e){var t;try{const n=await e.get("/v1/mgmt/widget/components-state");if(!(null==n?void 0:n.ok))return{};const i=await n.json();return null!==(t=null==i?void 0:i.componentsState)&&void 0!==t?t:{}}catch(e){return this.logger.debug("components-conditions: failed to fetch, showing all components",null==e?void 0:e.message),{}}},s})),Ac=["input","change"];function Nc(e){if("number"==typeof e&&Number.isFinite(e))return{value:e,ok:!0};if("boolean"==typeof e)return{value:e?1:0,ok:!0};if("string"==typeof e){if(""===e.trim())return{value:0,ok:!1};const t=Number(e);if(Number.isFinite(t))return{value:t,ok:!0}}return{value:0,ok:!1}}function jc(e){return null==e?"":"string"==typeof e?e:"boolean"==typeof e?e?"true":"false":"number"==typeof e?Number.isFinite(e)?String(e):"":String(e)}function Mc(e){if("boolean"==typeof e)return{value:e,ok:!0};if("string"==typeof e){if("true"===e)return{value:!0,ok:!0};if("false"===e)return{value:!1,ok:!0}}return"number"==typeof e?{value:0!==e,ok:!0}:{value:!1,ok:!1}}function Pc(e){return Array.isArray(e)?e:"string"==typeof e?e.split(","):null}function Tc(e){return null==e||("string"==typeof e?""===e:Array.isArray(e)?0===e.length:"object"==typeof e&&0===Object.keys(e).length)}const Wc=new Map,Lc={equal:(e,t)=>e===t||jc(e)===jc(t),"not-equal":(e,t)=>e!==t&&jc(e)!==jc(t),contains:(e,t)=>Array.isArray(e)?e.includes(t):"string"==typeof e&&e.includes(jc(t)),"doesnt-contains":(e,t)=>Array.isArray(e)?!e.includes(t):"string"==typeof e&&!e.includes(jc(t)),"greater-than":(e,t)=>{const n=Nc(e),i=Nc(t);return n.ok&&i.ok&&n.value>i.value},"greater-than-or-equal":(e,t)=>{const n=Nc(e),i=Nc(t);return n.ok&&i.ok&&n.value>=i.value},"less-than":(e,t)=>{const n=Nc(e),i=Nc(t);return n.ok&&i.ok&&n.value<i.value},"less-than-or-equal":(e,t)=>{const n=Nc(e),i=Nc(t);return n.ok&&i.ok&&n.value<=i.value},empty:e=>Tc(e),"not-empty":e=>!Tc(e),"is-true":e=>{const t=Mc(e);return t.ok&&t.value},"is-false":e=>{const t=Mc(e);return t.ok&&!t.value},in:(e,t)=>{const n=Pc(t);return null!==n&&n.includes(e)},"not-in":(e,t)=>{const n=Pc(t);return null!==n&&!n.includes(e)},matches:(e,t)=>{if("string"!=typeof e)return!1;const n=function(e){var t;if(Wc.has(e))return null!==(t=Wc.get(e))&&void 0!==t?t:null;let n;try{n=new RegExp(e)}catch(e){n=null}return Wc.set(e,n),n}(jc(t));return null!==n&&n.test(e)}};function Uc(e,t){var n;if(e)return"form"===e.kind&&e.form?t[e.form]:"list"===e.kind?(null!==(n=e.items)&&void 0!==n?n:[]).map((e=>Uc(e,t))):e.value}function Dc(e,t){const n=Lc[e.operator];return!!n&&n(Uc(e.target,t),Uc(e.predicate,t))}function Fc(e,t){const n={};return(null!=e?e:[]).forEach((e=>{var i;(function(e,t){var n;return(null!==(n=e.rules)&&void 0!==n?n:[]).some((e=>function(e,t){var n;const i=null!==(n=e.atomicConditions)&&void 0!==n?n:[];return!!i.length&&(e.logicalOr?i.some((e=>Dc(e,t))):i.every((e=>Dc(e,t))))}(e,t)))})(e,t)&&(null!==(i=e.componentIds)&&void 0!==i?i:[]).forEach((t=>{n[t]=e.action}))})),n}const _c="component-conditions:";function qc(e){return e instanceof HTMLInputElement?"checkbox"===e.type?e.checked:e.value:"checked"in e?e.checked:"value"in e?e.value:void 0}function Bc(e,t){const n=Object.keys(e),i=Object.keys(t);return n.length===i.length&&n.every((n=>e[n]===t[n]))}function Vc(){return{conditions:[],touchedIds:new Set,snapshot:{},applied:{},serverBaseline:{},debounceTimer:null,paused:!1,unsubscribePauseListener:null,inputHandler:()=>{},root:null}}function Kc(e,t,n){const i={};return n.forEach((n=>{e[n]?i[n]=e[n]:t[n]&&(i[n]=t[n])})),i}const Hc=Ti((e=>{var t,n,i,o,r,s;const a=Ei(Cs)(e);return s=class extends a{constructor(){super(...arguments),t.add(this),n.set(this,Vc())}applyComponentsState(e,t){t&&(Object.entries(t).forEach((([e,t])=>{ir.includes(t)||this.logger.error(`Unknown component action "${t}" for component with id "${e}"`,`Valid actions are ${ir.map((e=>`"${e}"`)).join(", ")}`)})),lr(e,{},t))}initRealtimeConditions(e,o){var s,a,d,l;u(this,t,"m",r).call(this);const c=null!==(s=null==o?void 0:o.realtimeComponentsConditions)&&void 0!==s?s:[];if(!c.length)return void this.logger.debug(`${_c} no real-time rules to apply on this screen`);this.logger.info(`${_c} found ${c.length} real-time rule(s) for this screen`);const f={};Object.entries(null!==(a=null==o?void 0:o.form)&&void 0!==a?a:{}).forEach((([e,t])=>{f[`form.${e}`]=t})),function(e){const t=new Set,n=e=>{var i;e&&("form"===e.kind&&e.form?t.add(e.form):"list"===e.kind&&(null!==(i=e.items)&&void 0!==i?i:[]).forEach(n))};return(null!=e?e:[]).forEach((e=>{var t;return(null!==(t=e.rules)&&void 0!==t?t:[]).forEach((e=>{var t;return(null!==(t=e.atomicConditions)&&void 0!==t?t:[]).forEach((e=>{n(e.target),n(e.predicate)}))}))})),t}(c).forEach((t=>{const n=function(e,t){const n=t.startsWith("form.")?t.slice(5):t;return e.querySelector(`[name="${ar(t)}"]`)||e.querySelector(`[name="${ar(n)}"]`)}(e,t);if(!n)return;const i=qc(n);void 0!==i&&(f[t]=i)}));const p=function(e){const t=new Set;return(null!=e?e:[]).forEach((e=>{var n;(null!==(n=e.componentIds)&&void 0!==n?n:[]).forEach((e=>t.add(e)))})),t}(c),v={},g={};Object.entries(null!==(d=null==o?void 0:o.componentsState)&&void 0!==d?d:{}).forEach((([e,t])=>{p.has(e)&&(g[e]=t)})),Object.entries(null!==(l=null==o?void 0:o.serverOnlyComponentsState)&&void 0!==l?l:{}).forEach((([e,t])=>{p.has(e)&&(v[e]=t)}));const m={conditions:c,touchedIds:p,snapshot:f,applied:g,serverBaseline:v,debounceTimer:null,paused:!1,unsubscribePauseListener:null,inputHandler:()=>{},root:e},y=Kc(Fc(c,f),v,p);Bc(g,y)||(m.applied=lr(e,g,y)),m.inputHandler=e=>u(this,t,"m",i).call(this,e),Ac.forEach((t=>{e.addEventListener(t,m.inputHandler,!0)})),this.logger.debug(`${_c} listening for "${Ac.join('" and "')}" events on form fields; ${Object.keys(g).length} component(s) start hidden / disabled / read-only by these rules`);const b=this.nextRequestStatus;if(null==b?void 0:b.subscribe){const e=({isLoading:e})=>{m.paused=e,e&&m.debounceTimer&&(clearTimeout(m.debounceTimer),m.debounceTimer=null)},t=b.subscribe(e);m.unsubscribePauseListener=()=>{var e;null!=t&&(null===(e=b.unsubscribe)||void 0===e||e.call(b,t))}}h(this,n,m,"f")}disconnectedCallback(){var e;null===(e=super.disconnectedCallback)||void 0===e||e.call(this),u(this,t,"m",r).call(this)}},n=new WeakMap,t=new WeakSet,i=function(e){var i,r;const s=u(this,n,"f");if(!s.root||s.paused)return;const a=e.target;if(!a)return;if(null===(i=a.hasAttribute)||void 0===i?void 0:i.call(a,Ro))return;const d=null===(r=a.getAttribute)||void 0===r?void 0:r.call(a,"name");if(!d)return;const l=function(e){return e.startsWith("form.")?e:`form.${e}`}(d);s.snapshot[l]=qc(a),s.debounceTimer&&clearTimeout(s.debounceTimer),s.debounceTimer=setTimeout((()=>{s.debounceTimer=null,u(this,t,"m",o).call(this)}),50)},o=function(){const e=u(this,n,"f");if(!e.root)return;let t;try{t=Kc(Fc(e.conditions,e.snapshot),e.serverBaseline,e.touchedIds)}catch(e){return void this.logger.error(`${_c} failed to evaluate real-time rules — keeping the previous state`,null==e?void 0:e.message)}const i=e.applied;Bc(i,t)||(this.logger.debug(`${_c} form changed — updating components: was ${JSON.stringify(i)}, now ${JSON.stringify(t)}`),e.applied=lr(e.root,i,t))},r=function(){const e=u(this,n,"f");e.debounceTimer&&clearTimeout(e.debounceTimer),e.unsubscribePauseListener&&e.unsubscribePauseListener(),e.root&&Ac.forEach((t=>{e.root.removeEventListener(t,e.inputHandler,!0)})),h(this,n,Vc(),"f")},s})),zc="project-id",Jc="flow-id",Gc=e=>{const t=(e=>{const t=e.getAttribute(zc),n=e.getAttribute(Jc);return t&&n?Array.from(e.ownerDocument.querySelectorAll("descope-wc")).filter((e=>e.getAttribute(zc)===t&&e.getAttribute(Jc)===n)):[]})(e);return t.length>1&&t[0]!==e},Zc=Ti((e=>{var t,n,i,o;const r=Ei(Cs)(e);return o=class extends r{constructor(){super(...arguments),t.add(this),n.set(this,void 0)}connectedCallback(){var e;null===(e=super.connectedCallback)||void 0===e||e.call(this),u(this,t,"m",i).call(this)}attributeChangedCallback(e,n,o){var r;null===(r=super.attributeChangedCallback)||void 0===r||r.call(this,e,n,o),n===o||e!==zc&&e!==Jc||u(this,t,"m",i).call(this)}},n=new WeakMap,t=new WeakSet,i=function(){queueMicrotask((()=>{if(!this.isConnected)return;const e=this.getAttribute(zc),t=this.getAttribute(Jc),i=`${e}|${t}`;u(this,n,"f")!==i&&Gc(this)&&(h(this,n,i,"f"),this.logger.warn("Multiple Descope flow components detected on the same page",`The same flow ("${t}") and project ("${e}") are running more than once on this page. This is not supported and may cause the flow to behave unexpectedly.`))}))},o})),Yc=["externalId","email","phone"],Xc=["newPassword","password"],Qc="data-username-anchor",eu=e=>{var t;if(!e)return"";try{const n=null===(t=window.sessionStorage)||void 0===t?void 0:t.getItem(Oo);if(!n)return"";const i=JSON.parse(n);return i.executionId===e&&i.loginId||""}catch(e){return""}},tu=Ti((e=>{var t,n,i,o,r;const s=Ei(Cs)(e);return r=class extends s{constructor(){super(...arguments),t.add(this),n.set(this,void 0)}updateScreenUser(e){var r,s,a;h(this,n,{email:null==e?void 0:e.email,loginIds:(null===(r=null==e?void 0:e.loginIds)||void 0===r?void 0:r.length)?e.loginIds:[eu(u(this,t,"a",o))||(null===(a=null===(s=u(this,t,"a",i).sdk)||void 0===s?void 0:s.getLastUserLoginId)||void 0===a?void 0:a.call(s))].filter(Boolean)},"f")}updateUsernameAnchor(){document.querySelectorAll(`[${Qc}="true"]`).forEach((e=>e.remove())),((e,t,n,i)=>{var o;const r=(null==n?void 0:n.email)||(null===(o=null==n?void 0:n.loginIds)||void 0===o?void 0:o[0]);(e=>e.querySelector("descope-new-password")||e.querySelector("descope-password"))(t)?r?(e=>{const t=['input[autocomplete="username"]',...Yc.map((e=>`[name="${e}"]`))].join(", ");return e.some((e=>e.querySelector(t)))})([e,t])?i.debug("Username anchor: screen already has an identifier field"):(i.debug("Username anchor: injecting hidden username input"),e.appendChild((e=>{const t=document.createElement("input");return t.setAttribute("autocomplete","username"),t.setAttribute("name","username"),t.setAttribute("type","email"),t.setAttribute("readonly","true"),t.setAttribute("tabindex","-1"),t.setAttribute("aria-hidden","true"),t.setAttribute(Ro,"true"),t.setAttribute(Qc,"true"),t.setAttribute("value",e),t.value=e,Object.assign(t.style,{position:"absolute",opacity:"0",pointerEvents:"none",height:"0",border:"0"}),t})(r))):i.debug("Username anchor: no user identifier available"):i.debug("Username anchor: no password component on screen")})(this,u(this,t,"a",i).contentRootElement,u(this,n,"f"),this.logger)}captureLastSubmittedLoginId(e={},n){const i=Br(e,Yc);i&&((e,t)=>{var n;if(e&&t)try{null===(n=window.sessionStorage)||void 0===n||n.setItem(Oo,JSON.stringify({executionId:t,loginId:e}))}catch(e){}})(i,n||u(this,t,"a",o))}storeCredentials(e={}){var t,i,o,r,s,a;const d=Br(e,Yc)||(null===(t=u(this,n,"f"))||void 0===t?void 0:t.email)||(null===(o=null===(i=u(this,n,"f"))||void 0===i?void 0:i.loginIds)||void 0===o?void 0:o[0]),l=Br(e,Xc);if(d&&l)try{if(!globalThis.PasswordCredential)return;const e=new globalThis.PasswordCredential({id:d,password:l});null===(a=null===(s=null===(r=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===r?void 0:r.store)||void 0===s?void 0:s.call(r,e))||void 0===a||a.catch((e=>{this.logger.debug("Could not store credentials",null==e?void 0:e.message)}))}catch(e){this.logger.warn("Could not store credentials",e.message)}}},n=new WeakMap,t=new WeakSet,i=function(){return this},o=function(){var e,n;return(null===(n=null===(e=u(this,t,"a",i).flowState)||void 0===e?void 0:e.current)||void 0===n?void 0:n.executionId)||""},r})),nu="data-evp-token",iu='descope-email-field[email-verification="true"]',ou=e=>{e.querySelectorAll(`[${nu}]`).forEach((e=>e.remove()))},ru=Ti((e=>{var t,n,i,o,r,s,a;const d=Ei(Cs)(e);return a=class extends d{constructor(){super(...arguments),t.add(this),n.set(this,void 0),i.set(this,!1),o.set(this,0),r.set(this,(e=>{(e=>e.composedPath().some((e=>e instanceof Element&&e.matches(iu))))(e)&&(h(this,i,"focusin"===e.type,"f"),"focusout"===e.type&&h(this,o,Date.now(),"f"))}))}clearEmailVerification(){h(this,n,void 0,"f"),h(this,i,!1,"f"),h(this,o,0,"f"),ou(this)}startEmailVerification(e){var i,o,a;const d=null===(i=u(this,t,"a",s).sdk)||void 0===i?void 0:i.emailVerification;if(!(d&&(()=>{var e,t;return!!(null===(t=null===(e=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===e?void 0:e.brands)||void 0===t?void 0:t.some((({brand:e})=>"Google Chrome"===e)))})()&&(l=e,l.querySelector(iu))&&this.closest("form")))return;var l;null===(o=this.shadowRoot)||void 0===o||o.addEventListener("focusin",u(this,r,"f")),null===(a=this.shadowRoot)||void 0===a||a.addEventListener("focusout",u(this,r,"f"));const c=d.start().then((e=>{var t,i;e.ok&&(null===(t=e.data)||void 0===t?void 0:t.nonce)?u(this,n,"f")===c&&((e,t)=>{const n=document.createElement("input");n.type="hidden",n.setAttribute("autocomplete","email-verification-token"),n.setAttribute(Ro,"true"),n.setAttribute(nu,"true"),n.nonce=t,n.setAttribute("nonce",t),e.appendChild(n)})(this,e.data.nonce):this.logger.warn("Email verification start failed",null===(i=e.error)||void 0===i?void 0:i.errorDescription)})).catch((e=>{this.logger.warn("Email verification start failed",null==e?void 0:e.message)}));h(this,n,c,"f")}emailVerificationToken(e){return c(this,void 0,void 0,(function*(){var t,n;if("true"===e.getAttribute("formnovalidate")||!this.querySelector(`[${nu}]`)||!(null===(n=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector(iu))||void 0===n?void 0:n.value))return"";u(this,i,"f")&&(()=>{var e;let t=document.activeElement;for(;null===(e=null==t?void 0:t.shadowRoot)||void 0===e?void 0:e.activeElement;)t=t.shadowRoot.activeElement;t instanceof HTMLElement&&t.blur()})();const r=u(this,o,"f")+900-Date.now();r>0&&(yield new Promise((e=>{setTimeout(e,r)})));const s=(e=>{const t=e.querySelector(`[${nu}]`),n=e.closest("form");if(!t||!n)return"";let i="";const o=e=>{e.target===n&&(e.preventDefault(),e.stopImmediatePropagation(),i=t.value,t.value="")};window.addEventListener("submit",o,!0);const{noValidate:r}=n;n.noValidate=!0;try{n.requestSubmit()}finally{n.noValidate=r,window.removeEventListener("submit",o,!0)}return i})(this);return s&&ou(this),s}))}},n=new WeakMap,i=new WeakMap,o=new WeakMap,r=new WeakMap,t=new WeakSet,s=function(){return this},a})),su=e=>`${e.screenId}|${e.field}|${e.rule}`,au=()=>{try{return crypto.randomUUID()}catch(e){return`${Date.now()}-${Math.round(1e9*Math.random())}`}},du=(e,t)=>e?e.badInput?"bad-input":e.valueMissing?"required":e.typeMismatch?"email"===t||"url"===t?t:"type-mismatch":e.patternMismatch?"pattern":e.tooShort?"too-short":e.tooLong?"too-long":e.rangeUnderflow||e.rangeOverflow||e.stepMismatch?"range":e.customError?"custom":"unknown":"unknown",lu=Ti((e=>{var t,n,i,o,r,s,a,d,l,c,f,p,v,g,m,y,b,w,$,k;const C=Ei(Cs)(e);return k=class extends C{constructor(){super(...arguments),t.add(this),n.set(this,[]),i.set(this,void 0),o.set(this,void 0),r.set(this,new Set),s.set(this,!1),a.set(this,0),d.set(this,void 0),l.set(this,!1),c.set(this,(()=>u(this,t,"m",y).call(this,!1))),f.set(this,(()=>{"hidden"===document.visibilityState&&u(this,t,"m",y).call(this,!0)})),p.set(this,(()=>u(this,t,"m",y).call(this,!0)))}setValidationTrackingEnabled(e){u(this,l,"f")!==e&&(h(this,l,e,"f"),e||u(this,t,"m",m).call(this))}setValidationTrackingSender(e){h(this,d,e,"f")}setValidationTrackingExecution(e){u(this,l,"f")&&e&&u(this,n,"f").length&&(h(this,i,e,"f"),u(this,t,"m",y).call(this,!1))}trackValidationErrors(e,n){var i,o;try{u(this,t,"m",v).call(this,e,n)}catch(e){null===(o=null===(i=this.logger)||void 0===i?void 0:i.debug)||void 0===o||o.call(i,"Failed to track validation errors",String(e))}}teardownValidationTracking(){u(this,t,"m",y).call(this,!1),h(this,a,u(this,a,"f")+1,"f"),u(this,r,"f").forEach(clearTimeout),u(this,r,"f").clear(),u(this,s,"f")&&(h(this,s,!1,"f"),this.removeEventListener("screen-updated",u(this,c,"f")),this.removeEventListener("success",u(this,c,"f")),this.removeEventListener("error",u(this,c,"f")),document.removeEventListener("visibilitychange",u(this,f,"f")),window.removeEventListener("pagehide",u(this,p,"f")))}},n=new WeakMap,i=new WeakMap,o=new WeakMap,r=new WeakMap,s=new WeakMap,a=new WeakMap,d=new WeakMap,l=new WeakMap,c=new WeakMap,f=new WeakMap,p=new WeakMap,t=new WeakSet,v=function(e,o){if(!u(this,l,"f")||!(null==e?void 0:e.length))return;const r=o||{};u(this,t,"m",$).call(this),e.forEach((e=>{if(u(this,n,"f").length>=20)return;const o=((e,t)=>{var n;const i=null===(n=null==e?void 0:e.getAttribute)||void 0===n?void 0:n.call(e,"name");return i?{id:au(),field:i,rule:du(e.validity,e.type),message:e.validationMessage||"",screenId:t.screenId||"",screenName:t.screenName||"",ts:Date.now()}:null})(e,r);if(!o)return;const s=su(o);u(this,n,"f").some((e=>su(e)===s))||(u(this,n,"f").push(o),h(this,i,r.executionId||u(this,i,"f"),"f"),u(this,n,"f").length>=20&&u(this,t,"m",y).call(this,!1))})),u(this,n,"f").length>=20?u(this,t,"m",y).call(this,!1):u(this,t,"m",g).call(this)},g=function(){clearTimeout(u(this,o,"f")),h(this,o,setTimeout((()=>u(this,t,"m",y).call(this,!1)),2e3),"f")},m=function(){clearTimeout(u(this,o,"f")),h(this,a,u(this,a,"f")+1,"f"),u(this,r,"f").forEach(clearTimeout),u(this,r,"f").clear(),h(this,n,[],"f"),h(this,i,void 0,"f")},y=function(e){var r,s;if(clearTimeout(u(this,o,"f")),!u(this,n,"f").length)return void h(this,i,void 0,"f");if(!u(this,i,"f"))return;if(!u(this,d,"f"))return;const l=u(this,n,"f"),c=u(this,i,"f");h(this,n,[],"f"),h(this,i,void 0,"f");try{const n={executionId:c,events:l};e?u(this,d,"f").call(this,n,{keepalive:!0}).catch((()=>{})):u(this,t,"m",b).call(this,n,2,u(this,a,"f"))}catch(e){null===(s=null===(r=this.logger)||void 0===r?void 0:r.debug)||void 0===s||s.call(r,"Failed to send validation events",String(e))}},b=function(e,n,i){u(this,d,"f").call(this,e,{keepalive:!1}).then((o=>{!o.ok&&o.retryable&&n>0&&u(this,t,"m",w).call(this,e,n,i)})).catch((()=>{n>0&&u(this,t,"m",w).call(this,e,n,i)}))},w=function(e,n,i){if(i!==u(this,a,"f"))return;const o=setTimeout((()=>{u(this,r,"f").delete(o),i===u(this,a,"f")&&u(this,t,"m",b).call(this,e,n-1,i)}),800*(2-n+1));u(this,r,"f").add(o)},$=function(){u(this,s,"f")||(h(this,s,!0,"f"),this.addEventListener("screen-updated",u(this,c,"f")),this.addEventListener("success",u(this,c,"f")),this.addEventListener("error",u(this,c,"f")),document.addEventListener("visibilitychange",u(this,f,"f")),window.addEventListener("pagehide",u(this,p,"f")))},k}));var cu,uu,hu,fu,pu,vu,gu,mu,yu,bu,wu,$u,ku,Cu,Su,Iu,Ru,Eu,xu,Ou,Au,Nu,ju,Mu,Pu,Tu,Wu;const Lu=Ei(sa,Ws,ha,Hc,Zc,tu,ru,Gs,ca,lu)(HTMLElement);let Uu=class extends Lu{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","locale","debug","storage-prefix","preview","redirect-url","auto-focus","store-last-authenticated-user","refresh-cookie-name","keep-last-authenticated-user-after-logout","validate-on-blur","send-session-token","style-id"]}get adoptedSsoQueryParams(){return u(this,pu,"f")}constructor(e){super(),cu.add(this),this.sdkVersion="4.7.4",hu.set(this,!1),fu.set(this,void 0),pu.set(this,null),this.flowStatus="initial",this.loggerWrapper={error:(e,t="")=>{this.logger.error(e,t,new Error),u(this,cu,"m",Wu).call(this,e,t)},warn:(e,t="")=>{this.logger.warn(e,t)},info:(e,t="",n={})=>{this.logger.info(e,t,n)},debug:(e,t="")=>{this.logger.debug(e,t)}},vu.set(this,new ts),gu.set(this,new ts),mu.set(this,{}),this.getComponentsContext=()=>u(this,mu,"f"),this.nextRequestStatus=new ts({isLoading:!1}),yu.set(this,void 0),bu.set(this,{popstate:u(this,cu,"m",Su).bind(this),componentsContext:u(this,cu,"m",Au).bind(this)}),wu.set(this,void 0),this.getConfig=()=>c(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),Nu.set(this,void 0),ju.set(this,void 0),h(this,wu,e,"f"),u(this,cu,"m",ku).call(this)}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(e){return{}}}get redirectUrl(){return this.getAttribute("redirect-url")||void 0}get debug(){return"true"===this.getAttribute("debug")}get locale(){return this.getAttribute("locale")||void 0}get autoFocus(){var e;const t=null!==(e=this.getAttribute("auto-focus"))&&void 0!==e?e:"true";return"skipFirstScreen"===t?t:"true"===t}get validateOnBlur(){return"true"===this.getAttribute("validate-on-blur")}get storeLastAuthenticatedUser(){var e;return"true"===(null!==(e=this.getAttribute("store-last-authenticated-user"))&&void 0!==e?e:"true")}get refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}get keepLastAuthenticatedUserAfterLogout(){return"true"===this.getAttribute("keep-last-authenticated-user-after-logout")}get storagePrefix(){return this.getAttribute("storage-prefix")||""}get sendSessionToken(){return"true"===this.getAttribute("send-session-token")}get preview(){return!!this.getAttribute("preview")}get formConfig(){return(e=>{try{return ua(JSON.parse(e))}catch(e){return{}}})(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return((e,t)=>Object.fromEntries(Object.entries(e).map((([e,n])=>[e,n[t]]))))(this.formConfig,"value")}get outboundAppId(){return this.getAttribute("outbound-app-id")}get outboundAppScopes(){try{return JSON.parse(this.getAttribute("outbound-app-scopes"))||null}catch(e){return null}}get popupOrigin(){return this.getAttribute("popup-origin")}get customStorage(){return u(this,fu,"f")}set customStorage(e){if(e&&"function"!=typeof e.getItem)throw new Error("Custom storage must have a getItem method");if(e&&"function"!=typeof e.setItem)throw new Error("Custom storage must have a setItem method");if(e&&"function"!=typeof e.removeItem)throw new Error("Custom storage must have a removeItem method");h(this,fu,e,"f"),(e=>{hs=e})(e)}get lazyStart(){return"true"===this.getAttribute("lazy-start")}start(){var e;null===(e=u(this,ju,"f"))||void 0===e||e.call(this),h(this,Nu,Promise.resolve(),"f")}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return c(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"executionContext"in e?e.executionContext:void 0}))}getProjectConfig(){return c(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"projectConfig"in e?e.projectConfig:void 0}))}getFlowConfig(){return c(this,void 0,void 0,(function*(){var e,t;const n=yield this.getProjectConfig(),i=(null===(e=null==n?void 0:n.flows)||void 0===e?void 0:e[this.flowId])||{};return null!==(t=i.version)&&void 0!==t||(i.version=0),i}))}getTargetLocales(){return c(this,void 0,void 0,(function*(){const e=yield this.getFlowConfig();return((null==e?void 0:e.targetLocales)||[]).map((e=>e.toLowerCase()))}))}handleKeyPress(){this.logger.debug("Enable key press handler"),this.rootElement.onkeydown=e=>{var t,n,i;const o=!!(null===(t=this.shadowRoot.activeElement)||void 0===t?void 0:t.getAttribute("href")),r=er.includes(null!==(i=null===(n=this.shadowRoot.activeElement)||void 0===n?void 0:n.localName)&&void 0!==i?i:"");if("Enter"!==e.key||e.defaultPrevented||o||r)return;e.preventDefault();const s=this.rootElement.querySelectorAll("descope-button");if(1===s.length&&"false"!==s[0].getAttribute("auto-submit"))return void s[0].click();const a=Array.from(s).filter((e=>"true"===e.getAttribute("auto-submit")));if(1===a.length)return void a[0].click();const d=Array.from(s).filter((e=>"button"===e.getAttribute("data-type")));if(1===d.length)"false"!==d[0].getAttribute("auto-submit")&&d[0].click();else if(0===d.length){const e=Array.from(s).filter((e=>"sso"===e.getAttribute("data-type")));1===e.length&&"false"!==e[0].getAttribute("auto-submit")&&e[0].click()}}}disableKeyPressHandler(){this.logger.debug("Disable key press handler"),this.rootElement.onkeydown=null}getComponentsVersion(){return c(this,void 0,void 0,(function*(){var e;const t=yield this.getConfig();return("projectConfig"in t?null===(e=t.projectConfig)||void 0===e?void 0:e.componentsVersion:{})||(this.logger.error("Did not get components version, using latest version"),"latest")}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;if(this.flowStatus="loading",["ready","error","success"].forEach((e=>this.addEventListener(e,(()=>{this.flowStatus=e})))),yield null===(t=e.init)||void 0===t?void 0:t.call(this),u(this,gu,"f").subscribe(u(this,cu,"m",Tu).bind(this)),u(this,gu,"f").update({isDebug:this.debug}),u(this,cu,"m",Cu).call(this),yield u(this,cu,"m",xu).call(this))return void this.loggerWrapper.error("This SDK version does not support your flows version","Make sure to upgrade your flows to the latest version or use an older SDK version");const n=yield this.getConfig();if("isMissingConfig"in n&&n.isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");const{executionId:i,stepId:o,token:r,code:s,isPopup:a,exchangeError:d,redirectAuthCallbackUrl:l,redirectAuthBackupCallbackUri:c,redirectAuthCodeChallenge:f,redirectAuthInitiator:p,ssoQueryParams:v,adoptedSsoQueryParams:g}=Wr(this.flowId,this.projectId,this.loggerWrapper);h(this,pu,null!=g?g:null,"f"),window.addEventListener("popstate",u(this,bu,"f").popstate),window.addEventListener("components-context",u(this,bu,"f").componentsContext),u(this,vu,"f").subscribe(u(this,cu,"m",Eu).bind(this)),u(this,vu,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenantId,redirectUrl:this.redirectUrl,locale:this.locale,stepId:o,executionId:i,token:r,code:s,isPopup:a,exchangeError:d,redirectAuthCallbackUrl:l,redirectAuthBackupCallbackUri:c,redirectAuthCodeChallenge:f,redirectAuthInitiator:p},v)),h(this,hu,!0,"f")}))}disconnectedCallback(){var e;u(this,vu,"f").unsubscribeAll(),u(this,gu,"f").unsubscribeAll(),u(this,cu,"m",Pu).call(this),window.removeEventListener("popstate",u(this,bu,"f").popstate),window.removeEventListener("components-context",u(this,bu,"f").componentsContext),null===(e=super.disconnectedCallback)||void 0===e||e.call(this)}attributeChangedCallback(e,t,n){var i;if(null===(i=super.attributeChangedCallback)||void 0===i||i.call(this,e,t,n),this.shadowRoot.isConnected&&u(this,hu,"f")&&t!==n&&uu.observedAttributes.includes(e)){u(this,cu,"m",Cu).call(this);const i=null===t;u(this,vu,"f").update((({stepId:t,executionId:o})=>{let r=t,s=o;return i||(s=null,r=null,Mr()),{[Tr(e)]:n,stepId:r,executionId:s}})),u(this,gu,"f").update({isDebug:this.debug})}}};var Du,Fu,_u,qu,Bu,Vu,Ku,Hu,zu,Ju,Gu,Zu,Yu,Xu,Qu,eh,th,nh,ih,oh,rh,sh,ah,dh,lh,ch,uh,hh,fh,ph,vh,gh,mh,yh,bh,wh,$h,kh,Ch,Sh,Ih,Rh,Eh,xh,Oh,Ah;uu=Uu,hu=new WeakMap,fu=new WeakMap,pu=new WeakMap,vu=new WeakMap,gu=new WeakMap,mu=new WeakMap,yu=new WeakMap,bu=new WeakMap,wu=new WeakMap,Nu=new WeakMap,ju=new WeakMap,cu=new WeakSet,$u=function(){this.injectStyle("\n :host {\n\t\t\twidth: 100%;\n display: block;\n\t\t}\n\n\t\t#root {\n\t\t\theight: 100%;\n display: flex;\n flex-direction: column;\n\t\t}\n\n #content-root {\n all: initial;\n transition: opacity 200ms ease-in-out;\n }\n\n\t\t#root[data-theme] {\n\t\t\tbackground-color: transparent;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1!important;\n\t\t}\n\n .hidden {\n display: none;\n }\n ")},ku=function(){u(this,cu,"m",$u).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},Cu=function(){const e=["base-url","tenant","locale","debug","redirect-url","auto-focus","store-last-authenticated-user","refresh-cookie-name","keep-last-authenticated-user-after-logout","preview","storage-prefix","form","client","validate-on-blur","send-session-token","style-id","outbound-app-id","outbound-app-scopes","theme-override"];uu.observedAttributes.forEach((t=>{if(!e.includes(t)&&!this[Tr(t)])throw Error(`${t} cannot be empty`)}))},Su=function(){const{stepId:e,executionId:t}=jr(this.flowId);t&&u(this,vu,"f").update({stepId:e,executionId:t})},Iu=function(e,t){yi&&"function"==typeof yi||this.logger.error("SDK was not loaded properly",yi,JSON.stringify(yi));const n=Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},uu.sdkConfigOverrides),{projectId:e,baseUrl:t});u(this,fu,"f")&&(n.customStorage=u(this,fu,"f")),this.sdk=yi(n);const i={start:1,next:7};["start","next"].forEach((e=>{const t=function(e,t,n){return(...i)=>c(this,void 0,void 0,(function*(){let o;const r=n+1;for(let s=0;s<r;s++)try{return yield e(...i)}catch(e){o=e,s<n&&(yield new Promise((e=>{setTimeout(e,t*Math.pow(2,s+1))})))}throw o}))}(this.sdk.flow[e],1e3,3);this.sdk.flow[e]=(...n)=>c(this,void 0,void 0,(function*(){const o=[...n],r=i[e],s=u(this,cu,"m",Ru).call(this,o[r]);void 0!==s&&(o[r]=s);try{return yield t(...o)}catch(t){return this.logger.error(`Error in sdk flow ${e} function`,t),{error:{errorCode:mo,errorDescription:t.toString()}}}}))}));const o=this.sdk.flow.start;this.sdk.flow.start=(...e)=>c(this,void 0,void 0,(function*(){return yield u(this,cu,"m",Mu).call(this),o.apply(this.sdk.flow,e)}))},Ru=function(e){if(!this.sendSessionToken)return e;const t=null==In?void 0:In(this.storagePrefix);return t?Object.assign(Object.assign({},null!=e?e:{}),{sessionJwt:t}):e},Eu=function(e,t,n){return c(this,void 0,void 0,(function*(){const{projectId:t,baseUrl:i}=e;if(n("projectId")||n("baseUrl")){if(!t)return;u(this,cu,"m",Iu).call(this,t,i)}u(this,wu,"f").call(this,e)}))},xu=function(){return c(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield u(this,cu,"m",Ou).call(this))}))},Ou=function(){return c(this,void 0,void 0,(function*(){const e=function({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:i}){const o=new URL(wo||i||"https://static.descope.com/pages");return o.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(o.pathname,e,n,t),o.toString()}({projectId:this.projectId,filename:"config.json",assetsFolder:"v2-alpha",baseUrl:this.baseStaticUrl});try{return yield function(e,t){return c(this,void 0,void 0,(function*(){const n=yield fetch(e,{cache:"default"});if(!n.ok)throw Error(`Error fetching URL ${e} [${n.status}]`);return{body:yield n[t](),headers:Object.fromEntries(n.headers.entries())}}))}(e,"json"),!0}catch(e){return!1}}))},Au=function(e){h(this,mu,Object.assign(Object.assign({},u(this,mu,"f")),e.detail),"f")},Mu=function(){return this.lazyStart?(u(this,Nu,"f")||h(this,Nu,new Promise((e=>{h(this,ju,e,"f")})),"f"),u(this,Nu,"f")):Promise.resolve()},Pu=function(){var e;null===(e=u(this,yu,"f"))||void 0===e||e.remove(),h(this,yu,null,"f")},Tu=function(e){return c(this,arguments,void 0,(function*({isDebug:e}){e?(h(this,yu,document.createElement("descope-debugger"),"f"),Object.assign(u(this,yu,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return UI})),document.body.appendChild(u(this,yu,"f"))):u(this,cu,"m",Pu).call(this)}))},Wu=function(e,t){var n;e&&this.debug&&(null===(n=u(this,yu,"f"))||void 0===n||n.updateData({title:e,description:t}))},Uu.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"4.7.4"}};const Nh="__descope_webauthn_timed_out__";let jh=class e extends Uu{static set sdkConfigOverrides(e){Uu.sdkConfigOverrides=e}static get sdkConfigOverrides(){return Uu.sdkConfigOverrides}constructor(){const t=new ts({deferredRedirect:!1,deferredPolling:!1});super(t.update.bind(t)),Du.add(this),this.stepState=new ts({}),Fu.set(this,void 0),_u.set(this,null),qu.set(this,null),Bu.set(this,{visibilitychange:u(this,Du,"m",Vu).bind(this)}),this.bridgeVersion=e.bridgeVersion,Ku.set(this,void 0),this.nativeCallbacks={},Qu.set(this,!1),this.handleRedirect=e=>{window.location.assign(e)},nh.set(this,(e=>{e&&this.clearEmailVerification();const t=()=>{this.contentRootElement.classList.toggle("hidden",e),this.slotElement.classList.toggle("hidden",!e),e&&(this.contentRootElement.innerHTML="")};e&&this.contentRootElement.hasChildNodes()?u(this,Du,"m",ih).call(this,t):t()})),oh.set(this,((e,t,n,i,o=!1)=>{const r=[yo,"E103202",bo];if(this.flowState.current.action===zo){if(u(this,sh,"f").call(this)&&document.hidden)return this.logger.debug("polling - Deferring polling until in foreground"),void this.flowState.update({deferredPolling:!0});this.logger.debug("polling - Scheduling polling request");const s=Date.now(),a=o?500:2e3;h(this,Fu,setTimeout((()=>c(this,void 0,void 0,(function*(){var d,l;this.logger.debug("polling - Calling next");const c=this.sdk.flow.next(e,t,Qo,n,i,{}),h=document.hidden&&!o&&Date.now()-s>a+500;let f;h&&this.logger.debug("polling - The polling seems to be throttled");try{const e=h?1e3:6e3;f=yield Dr(e,c)}catch(d){return this.logger.warn(`polling - The ${h?"throttled fetch":"fetch"} call timed out or was aborted`),void u(this,oh,"f").call(this,e,t,n,i,h)}if((null===(d=null==f?void 0:f.error)||void 0===d?void 0:d.errorCode)===mo)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void u(this,oh,"f").call(this,e,t,n,i);this.logger.debug("polling - Got a response"),(null==f?void 0:f.error)&&this.logger.debug("polling - Response has an error",JSON.stringify(f.error,null,4)),(null===(l=null==f?void 0:f.error)||void 0===l?void 0:l.errorCode)&&r.includes(f.error.errorCode)?this.logger.debug("polling - Stopping polling due to error"):u(this,oh,"f").call(this,e,t,n,i),u(this,ah,"f").call(this,f)}))),a),"f")}})),rh.set(this,(()=>{clearTimeout(u(this,Fu,"f")),h(this,Fu,null,"f")})),sh.set(this,(()=>!!window.descopeBridge||/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))),ah.set(this,(e=>{var t,n,i,o,r,s,a,d,l,c,f,p,v;if(!(null==e?void 0:e.ok)){const a=null===(t=null==e?void 0:e.response)||void 0===t?void 0:t.url,d=`${null===(n=null==e?void 0:e.response)||void 0===n?void 0:n.status} - ${null===(i=null==e?void 0:e.response)||void 0===i?void 0:i.statusText}`;u(this,Du,"m",Oh).call(this,"error",(null==e?void 0:e.error)||{errorCode:"J151001",errorDescription:d,errorMessage:a}),this.loggerWrapper.error((null===(o=null==e?void 0:e.error)||void 0===o?void 0:o.errorDescription)||a,(null===(r=null==e?void 0:e.error)||void 0===r?void 0:r.errorMessage)||d);const l=null===(s=null==e?void 0:e.error)||void 0===s?void 0:s.errorCode;return void("E102004"!==l&&l!==yo&&l!==bo||!this.isRestartOnError||u(this,Du,"m",Xu).call(this))}null===(d=null===(a=e.data)||void 0===a?void 0:a.runnerLogs)||void 0===d||d.forEach((e=>{const{level:t,title:n,log:i}=e;t&&this.loggerWrapper[t]?this.loggerWrapper[t](n,i):this.loggerWrapper.info(n,i)}));const g=null===(f=null===(c=null===(l=e.data)||void 0===l?void 0:l.screen)||void 0===c?void 0:c.state)||void 0===f?void 0:f.errorText;(null===(p=e.data)||void 0===p?void 0:p.error)?this.loggerWrapper.error(`[${e.data.error.code}]: ${e.data.error.description}`,`${g?`${g} - `:""}${e.data.error.message}`):g&&this.loggerWrapper.error(g);const{status:m,authInfo:y,lastAuth:b,action:w,openInNewTabUrl:$}=e.data;if(w!==zo&&u(this,rh,"f").call(this),"completed"===m){this.storeLastAuthenticatedUser&&ys(Object.assign(Object.assign({},b),{lastUsedPerScreen:bs()})),ws(this.loggerWrapper);const t=Object.assign({},y);return e.data.output&&Object.keys(e.data.output).length>0&&(t.flowOutput=e.data.output),this.setValidationTrackingExecution(e.data.executionId),Rr(this.projectId,this.flowId),void u(this,Du,"m",Oh).call(this,"success",t)}this.storeLastAuthenticatedUser&&ys(b,!0),$&&window.open($,"_blank");const{executionId:k,stepId:C,stepName:S,screen:I,redirect:R,webauthn:E,error:x,samlIdpResponse:O,wsFedIdpResponse:A,nativeResponse:N}=e.data,j=Date.now();w!==zo?(this.loggerWrapper.info(`Step "${S||`#${C}`}" is ${m}`,"",{screen:I,status:m,stepId:C,stepName:S,action:w,error:x}),(null===(v=I.state)||void 0===v?void 0:v.clientScripts)&&h(this,qu,this.loadSdkScripts(I.state.clientScripts),"f"),this.flowState.update({stepId:C,stepName:S,executionId:k,action:w,redirectTo:null==R?void 0:R.url,redirectIsPopup:null==R?void 0:R.isPopup,screenId:null==I?void 0:I.id,screenState:null==I?void 0:I.state,webauthnTransactionId:null==E?void 0:E.transactionId,webauthnOptions:null==E?void 0:E.options,samlIdpResponseUrl:null==O?void 0:O.url,samlIdpResponseSamlResponse:null==O?void 0:O.samlResponse,samlIdpResponseRelayState:null==O?void 0:O.relayState,wsFedIdpResponseUrl:null==A?void 0:A.url,wsFedIdpResponseWresult:null==A?void 0:A.wresult,wsFedIdpResponseWctx:null==A?void 0:A.wctx,nativeResponseType:null==N?void 0:N.type,nativePayload:null==N?void 0:N.payload,reqTimestamp:j})):this.flowState.update({action:w,reqTimestamp:j})})),dh.set(this,Lr((()=>c(this,void 0,void 0,(function*(){var e;try{const t=yield this.sdk.webauthn.signIn.start("",window.location.origin);return t.ok||this.loggerWrapper.warn("Webauthn start failed",null===(e=null==t?void 0:t.error)||void 0===e?void 0:e.errorMessage),t.data}catch(e){this.loggerWrapper.warn("Webauthn start failed",e.message)}}))))),hh.set(this,void 0),fh.set(this,void 0),bh.set(this,null),Ch.set(this,Vr(((e,t,n)=>c(this,void 0,void 0,(function*(){var i;if("true"!==e.getAttribute("loading")&&"true"!==e.getAttribute("disabled")){if("true"===e.getAttribute("formnovalidate")||u(this,Du,"m",mh).call(this)){const o=null==e?void 0:e.getAttribute("id");u(this,Du,"m",Rh).call(this,e,o,n);const r=u(this,Du,"m",wh).call(this,e);try{const n=yield u(this,Du,"m",yh).call(this),r=(e=>Array.from((null==e?void 0:e.attributes)||[]).reduce(((e,t)=>{var n;const i=null===(n=new RegExp("^data-descope-(\\S+)$").exec(t.name))||void 0===n?void 0:n[1];return i?Object.assign(e,{[i]:t.value}):e}),{}))(e);this.nextRequestStatus.update({isLoading:!0});const s=yield this.emailVerificationToken(e),a=Object.assign(Object.assign(Object.assign(Object.assign({},r),n),{origin:u(this,Du,"a",gh)}),s&&{evpToken:s}),d=yield t(o,a);this.nextRequestStatus.update({isLoading:!1}),this.captureLastSubmittedLoginId(n,null===(i=null==d?void 0:d.data)||void 0===i?void 0:i.executionId),this.storeCredentials(n)}catch(e){throw r(),e}}}else this.loggerWrapper.debug("Submit already in flight, ignoring")}))))),this.flowState=t,this.setValidationTrackingSender(((e,t)=>c(this,[e,t],void 0,(function*({executionId:e,events:t},{keepalive:n}){const i=yield this.sdk.flow.event(e,t,n);return{ok:i.ok,retryable:i.code>=500||429===i.code}}))))}nativeResume(e,t){var n,i,o,r,s,a;const d=JSON.parse(t);if("oauthWeb"===e||"sso"===e){let e,{exchangeCode:t}=d;if(!t){const o=new URL(d.url);t=null===(n=o.searchParams)||void 0===n?void 0:n.get(Co),e=(null===(i=o.searchParams)||void 0===i?void 0:i.get(Io))||void 0}null===(r=(o=this.nativeCallbacks).complete)||void 0===r||r.call(o,{exchangeCode:t,exchangeError:e,idpInitiated:!0})}else if("magicLink"===e){const e=new URL(d.url),t=e.searchParams.get("t"),n=e.searchParams.get(ko).split("_").pop();u(this,rh,"f").call(this),this.flowState.update({token:t,stepId:n,action:void 0})}else if("beforeScreen"===e){const{screenResolve:e}=this.nativeCallbacks;this.nativeCallbacks.screenResolve=null;const{override:t}=d;t||(this.nativeCallbacks.screenNext=null),null==e||e(t)}else if("resumeScreen"===e){const{interactionId:e,form:t}=d,{screenNext:n}=this.nativeCallbacks;this.nativeCallbacks.screenNext=null,null==n||n(e,t)}else null===(a=(s=this.nativeCallbacks).complete)||void 0===a||a.call(s,d)}loadSdkScriptsModules(){const e=this.shadowRoot.querySelectorAll("div[data-script-id]");return Array.from(e).map((e=>e.moduleRes)).filter((e=>!!e))}loadSdkScripts(e){if(!(null==e?void 0:e.length))return null;const t=(e,t)=>n=>{this.dispatchEvent(new CustomEvent("components-context",{detail:{[Gr(e.id,e.resultKey)]:n},bubbles:!0,composed:!0})),t(e.id)};this.loggerWrapper.debug(`Preparing to load scripts: ${e.map((e=>e.id)).join(", ")}`);const n=e=>c(this,void 0,void 0,(function*(){var n,i,o;const r=this.shadowRoot.querySelector(`[data-script-id="${e.id}"]`);if(r){this.loggerWrapper.debug("Script already loaded",e.id);const{moduleRes:t}=r;return null===(n=null==t?void 0:t.start)||void 0===n||n.call(t),t}(null===(i=globalThis.descope)||void 0===i?void 0:i[e.id])||(yield this.injectNpmLib("@descope/flow-scripts","1.0.22",`dist/${e.id}.js`));const s=null===(o=globalThis.descope)||void 0===o?void 0:o[e.id];return new Promise(((n,i)=>{try{const i=s(e.initArgs,{baseUrl:this.baseUrl,ref:this},t(e,n),this.loggerWrapper);if(i){const t=document.createElement("div");t.setAttribute("data-script-id",e.id),t.moduleRes=i,this.shadowRoot.appendChild(t);const o=this.nextRequestStatus.subscribe((()=>{var n;this.loggerWrapper.debug("Stopping script",e.id),(null===(n=i.stop)||void 0===n?void 0:n.call(i))&&(this.nextRequestStatus.unsubscribe(o),this.loggerWrapper.debug("Removing script",e.id),this.shadowRoot.removeChild(t))}));"function"==typeof i.present&&n(e.id)}}catch(e){i(e)}}))})),i=Promise.all((null!=e?e:[]).map((e=>n(e).catch((t=>(this.loggerWrapper.warn(`Sdk script ${e.id} failed to load, continuing without it`,null==t?void 0:t.message),null))))));let o;const r=new Promise((e=>{o=setTimeout((()=>{this.loggerWrapper.warn("SDK scripts loading timeout"),e(!0)}),5e3)}));return Promise.race([i,r]).finally((()=>clearTimeout(o))).catch((e=>(this.loggerWrapper.warn("Sdk scripts failed to load, continuing without them",null==e?void 0:e.message),null)))}get isDismissScreenErrorOnInput(){return"true"===this.getAttribute("dismiss-screen-error-on-input")}init(){var e,t;if(!window.descopeBridge)return this._init();this.lazyInit=this._init,h(this,Ku,null===(t=null===(e=null===window||void 0===window?void 0:window.descopeBridge)||void 0===e?void 0:e.registerFlow)||void 0===t?void 0:t.call(e,this),"f")}_init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t,n;this.shadowRoot.isConnected&&(null===(t=this.flowState)||void 0===t||t.subscribe(this.onFlowChange.bind(this)),u(this,Du,"m",Zu).call(this),window.addEventListener("visibilitychange",u(this,Bu,"f").visibilitychange)),yield null===(n=e.init)||void 0===n?void 0:n.call(this)}))}disconnectedCallback(){var e,t,n;super.disconnectedCallback(),this.teardownValidationTracking(),u(this,Ku,"f")&&(null===(t=null===(e=window.descopeBridge)||void 0===e?void 0:e.unregisterFlow)||void 0===t||t.call(e,u(this,Ku,"f")),h(this,Ku,void 0,"f")),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),u(this,rh,"f").call(this),null===(n=u(this,_u,"f"))||void 0===n||n.abort(),h(this,_u,null,"f"),this.clearEmailVerification(),window.removeEventListener("visibilitychange",u(this,Bu,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return c(this,void 0,void 0,(function*(){let n;const i=Ki(e),o=yield this.getTargetLocales();return o.includes(i.locale)?n=`${t}-${i.locale}.html`:o.includes(i.fallback)&&(n=`${t}-${i.fallback}.html`),n}))}getPageContent(e,t){return c(this,void 0,void 0,(function*(){if(t)try{const{body:e}=yield this.fetchStaticResource(t,"text");return e}catch(n){this.loggerWrapper.error(`Failed to fetch flow page from ${t}. Fallback to url ${e}`,n)}try{const{body:t}=yield this.fetchStaticResource(e,"text");return t}catch(e){this.loggerWrapper.error("Failed to fetch flow page",e.message)}return null}))}onFlowChange(e,t,n){return c(this,void 0,void 0,(function*(){var i,o;const{projectId:r,flowId:s,tenant:a,stepId:d,executionId:f,action:p,screenId:v,screenState:g,redirectTo:m,redirectIsPopup:y,redirectUrl:b,token:w,code:$,isPopup:k,exchangeError:C,webauthnTransactionId:S,webauthnOptions:I,redirectAuthCodeChallenge:R,redirectAuthCallbackUrl:E,redirectAuthBackupCallbackUri:x,redirectAuthInitiator:O,locale:A,samlIdpResponseUrl:N,samlIdpResponseSamlResponse:j,samlIdpResponseRelayState:M,wsFedIdpResponseUrl:P,wsFedIdpResponseWresult:T,wsFedIdpResponseWctx:W,nativeResponseType:L,nativePayload:U,reqTimestamp:D}=e,F=l(e,["projectId","flowId","tenant","stepId","executionId","action","screenId","screenState","redirectTo","redirectIsPopup","redirectUrl","token","code","isPopup","exchangeError","webauthnTransactionId","webauthnOptions","redirectAuthCodeChallenge","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthInitiator","locale","samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState","wsFedIdpResponseUrl","wsFedIdpResponseWresult","wsFedIdpResponseWctx","nativeResponseType","nativePayload","reqTimestamp"]);let _,q,B;n("executionId")&&f&&((e,t,n,i)=>{var o,r;const s=(e=>{const t=Object.assign({},e);return delete t.oidcLoginHint,delete t.samlIdpUsername,t})(t);if(e&&pr(s)){try{const t={params:s,ts:null!==(o=$r(n,i))&&void 0!==o?o:Date.now(),projectId:n};null===(r=Cr())||void 0===r||r.setItem(kr(e),JSON.stringify(t))}catch(e){}Sr()}})(Ar(f),gr(F),r,s);const V=(()=>{const e=ps(vs);if(!e){const e=Math.floor(100*Math.random()+1);return fs(vs,e.toString()),e}return Number(e)})(),{outboundAppId:K,outboundAppScopes:H}=this,z=this.sdk.getLastUserLoginId();n("flowId")&&this.setValidationTrackingEnabled(!1);const J=yield this.getFlowConfig();u(this,Du,"m",ph).call(this,J,f,n);const G=yield this.getProjectConfig(),Z=Object.entries(G.flows||{}).reduce(((e,[t,n])=>(e[t]=n.version,e)),{}),Y=E&&R?{callbackUrl:E,codeChallenge:R,backupCallbackUri:x}:void 0,X=this.nativeOptions?{platform:this.nativeOptions.platform,bridgeVersion:this.nativeOptions.bridgeVersion,oauthProvider:this.nativeOptions.oauthProvider,oauthRedirect:this.nativeOptions.oauthRedirect,magicLinkRedirect:this.nativeOptions.magicLinkRedirect,ssoRedirect:this.nativeOptions.ssoRedirect,externalAuthRedirect:this.nativeOptions.externalAuthRedirect}:void 0;let Q={};if(!f){ws(this.loggerWrapper);const e=[...J.clientScripts||[],...J.sdkScripts||[]];if(J.conditions){let t=[];({startScreenId:_,conditionInteractionId:B,startScreenName:q,clientScripts:t,componentsConfig:Q}=((e,t)=>{const n=null==t?void 0:t.find((({key:t,operator:n,predicate:i})=>{var o;if("ELSE"===t)return!0;const r=null===(o=gs[t])||void 0===o?void 0:o[n];return!!(null==r?void 0:r(e,i))}));return n?{startScreenId:n.met.screenId,startScreenName:n.met.screenName,conditionInteractionId:n.met.interactionId,clientScripts:n.met.clientScripts,componentsConfig:n.met.componentsConfig}:{}})({loginId:z,code:$,token:w,abTestingKey:V,lastAuth:ms(z,this.loggerWrapper)},J.conditions)),e.push(...t||[])}else J.condition?({startScreenId:_,startScreenName:q,conditionInteractionId:B}=((e,t)=>{var n;const i=null===(n=gs[null==e?void 0:e.key])||void 0===n?void 0:n[e.operator];if(!i)return{};const o=i(t,e.predicate)?e.met:e.unmet;return{startScreenId:null==o?void 0:o.screenId,startScreenName:null==o?void 0:o.screenName,conditionInteractionId:null==o?void 0:o.interactionId}})(J.condition,{loginId:z,code:$,token:w,abTestingKey:V,lastAuth:ms(z,this.loggerWrapper)})):(q=J.startScreenName,_=J.startScreenId);if(h(this,hh,_,"f"),h(this,fh,q,"f"),h(this,qu,this.loadSdkScripts(e),"f"),J.fingerprintEnabled&&J.fingerprintKey?yield Pn(J.fingerprintKey,this.baseUrl):ln(jn),!Fr(_,F)){const e=yield this.sdk.flow.start(s,Object.assign(Object.assign(Object.assign(Object.assign({tenant:a,redirectAuth:Y},F),{client:this.client}),b&&{redirectUrl:b}),{lastAuth:ms(z,this.loggerWrapper),abTestingKey:V,locale:Ki(A).locale,nativeOptions:X,outboundAppId:K,outboundAppScopes:H}),B,"",G.componentsVersion,Z,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:u(this,Du,"a",gh)},this.formConfigValues),$?{exchangeCode:$,idpInitiated:!0}:{}),F.descopeIdpInitiated&&{idpInitiated:!0}),w?{token:w}:{}),F.oidcLoginHint?{externalId:F.oidcLoginHint}:{}));return u(this,ah,"f").call(this,e),void("completed"!==(null===(i=null==e?void 0:e.data)||void 0===i?void 0:i.status)&&this.flowState.update({code:void 0,token:void 0}))}}if(this.loggerWrapper.debug("Before popup postmessage send",JSON.stringify({isPopup:k,code:$,exchangeError:C,isCodeChanged:n("code"),isExchangeErrorChanged:n("exchangeError")})),k&&(n("code")&&$||n("exchangeError")&&C))return void u(this,Du,"m",Ah).call(this,f,$,C);if(f&&(n("token")&&w||n("code")&&$||n("exchangeError")&&C)){const e=yield this.sdk.flow.next(f,d,Xo,J.version,G.componentsVersion,{token:w,exchangeCode:$,exchangeError:C,origin:u(this,Du,"a",gh)});return u(this,ah,"f").call(this,e),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(p===Yo&&N&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>n(e)))){if(!j)return void this.loggerWrapper.error("Did not get saml idp params data to load");((e,t,n,i)=>{const o=document.createElement("form");o.method="POST",o.action=e,o.appendChild(_r("SAMLResponse",t,"saml-response")),o.appendChild(_r("RelayState",n,"saml-relay-state")),document.body.appendChild(o),i(o)})(N,j,M||"",qr)}if(p===Yo&&P&&["wsFedIdpResponseUrl","wsFedIdpResponseWresult","wsFedIdpResponseWctx"].some((e=>n(e)))){if(!T)return void this.loggerWrapper.error("Did not get wsfed idp params data to load");((e,t,n,i)=>{const o=document.createElement("form");o.method="POST",o.action=e,o.appendChild(_r("wa","wsignin1.0")),o.appendChild(_r("wresult",t)),o.appendChild(_r("wctx",n)),document.body.appendChild(o),i(o)})(P,T,W||"",qr)}if(p===Ho&&(n("redirectTo")||n("deferredRedirect"))){if(!m)return void this.loggerWrapper.error("Did not get redirect url");if("no-op"===m)return;if("android"===O&&document.hidden)return void this.flowState.update({deferredRedirect:!0});if(this.loggerWrapper.debug(`Redirect is popup ${y}`),y){this.loggerWrapper.debug("Opening redirect in popup");const e=((e,t,n,i)=>{const o=void 0!==window.screenLeft?window.screenLeft:window.screen.left,r=void 0!==window.screenTop?window.screenTop:window.screen.top,s=((window.innerWidth||document.documentElement.clientWidth||window.screen.width)-n)/2+o,a=((window.innerHeight||document.documentElement.clientHeight||window.screen.height)-i)/2+r,d=function(){const e=navigator.userAgent||"",t=/\b(iPhone)\b/.test(e),n=/Safari/.test(e)&&!/CriOS|FxiOS|OPiOS|EdgiOS|Chrome|Chromium/.test(e);return t&&n}()?"about:blank":"",l=window.open(d,t,`width=${n},height=${i},top=${a},left=${s},scrollbars=yes,resizable=yes`);return l.location.href=e,l.focus(),l})(m,"?",598,700),t=this.shouldUsePopupPostMessage();t&&(e.name=`descope-wc|${window.location.origin}`),this.loggerWrapper.debug("Popup communication method: "+(t?"postMessage":"BroadcastChannel"));let n=!1;const i=e=>{this.loggerWrapper.debug("Received popup message",JSON.stringify(e.data));const i=t?this.popupOrigin:window.location.origin;if(e.origin!==i)return void this.loggerWrapper.debug(`Ignoring message from unexpected origin. received: "${e.origin}", expected: "${i}"`);const{action:o,data:r}=e.data||{};"code"===o&&(n=!0,this.flowState.update({code:r.code,exchangeError:r.exchangeError}))};let o;this.loggerWrapper.debug("Starting popup closed detection");const r=setInterval((()=>{e.closed&&(this.loggerWrapper.debug("Popup closed, dispatching popupclosed event"),clearInterval(r),u(this,Du,"m",Oh).call(this,"popupclosed",{abandoned:!n}),this.loggerWrapper.debug("Cleaning up popup listeners"),null==o||o())}),1e3);if(t)window.addEventListener("message",i),o=()=>{this.loggerWrapper.debug("Cleaning up popup postMessage listener"),window.removeEventListener("message",i)};else{this.loggerWrapper.debug("Creating broadcast channel");const e=new BroadcastChannel(f);e.onmessage=i,o=()=>{this.loggerWrapper.debug("Closing channel"),e.close()}}}else((e,t,n,i,o)=>{var r;if(null==n?void 0:n.oidcErrorRedirectUri){try{const t=new URL(e,window.location.href),i=new URL(n.oidcErrorRedirectUri);if(t.origin!==i.origin||t.pathname!==i.pathname)return}catch(e){return}Rr(i,o);try{t&&(null===(r=Cr())||void 0===r||r.removeItem(kr(t)))}catch(e){}}})(m,Ar(f),Object.assign(Object.assign({},this.adoptedSsoQueryParams),gr(F)),r,s),this.handleRedirect(m),this.flowState.update({redirectTo:"no-op"}),u(this,Du,"m",Oh).call(this,"popupclosed",{});return}if(p===Jo||p===Go){if(!S||!I)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");null===(o=u(this,_u,"f"))||void 0===o||o.abort(),h(this,_u,null,"f");const e=yield u(this,Du,"m",th).call(this,p,I),t=yield this.sdk.flow.next(f,d,Xo,J.version,G.componentsVersion,Object.assign({transactionId:S},e));u(this,ah,"f").call(this,t)}if(p===Zo)return this.nativeCallbacks.complete=e=>c(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(f,d,Xo,J.version,G.componentsVersion,e);u(this,ah,"f").call(this,t)})),u(this,Du,"m",Ju).call(this,L,U),void setTimeout((()=>{this.dispatchEvent(new Event("popupclosed"))}),500);if((n("action")||n("deferredPolling"))&&u(this,oh,"f").call(this,f,d,J.version,G.componentsVersion),!v&&!_)return void this.loggerWrapper.warn("No screen was found to show");const ee=_||v,te=yield this.getHtmlFilenameWithLocale(A,ee),{oidcLoginHint:ne,oidcPrompt:ie,oidcErrorRedirectUri:oe,oidcResource:re,samlIdpUsername:se}=F,ae={direction:Nr(d,t.stepId),screenState:Object.assign(Object.assign({},g),{form:Object.assign(Object.assign({},this.formConfigValues),null==g?void 0:g.form),lastAuth:{loginId:z,name:this.sdk.getLastUserDisplayName()||z},componentsConfig:Object.assign(Object.assign(Object.assign({},J.componentsConfig),Q),null==g?void 0:g.componentsConfig)}),htmlFilename:`${ee}.html`,htmlLocaleFilename:te,screenId:ee,stepName:e.stepName||q,samlIdpUsername:se,oidcLoginHint:ne,oidcPrompt:ie,oidcErrorRedirectUri:oe,oidcResource:re,action:p,locale:Ki(A).locale},de=ms(z,this.loggerWrapper);Fr(_,F)?ae.next=(e,t)=>c(this,void 0,void 0,(function*(){const n=(null==J?void 0:J.clientScripts)||[];yield u(this,Du,"m",Sh).call(this,n);const i=yield this.sdk.flow.start(s,Object.assign(Object.assign(Object.assign(Object.assign({tenant:a,redirectAuth:Y},F),{lastAuth:de,preview:this.preview,abTestingKey:V,client:this.client}),b&&{redirectUrl:b}),{locale:Ki(A).locale,nativeOptions:X,outboundAppId:K,outboundAppScopes:H}),B,e,G.componentsVersion,Z,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:u(this,Du,"a",gh)},this.formConfigValues),this.getComponentsContext()),Jr(t)),$&&{exchangeCode:$,idpInitiated:!0}),F.descopeIdpInitiated&&{idpInitiated:!0}),w&&{token:w}),ae.next.isCustomScreen);return u(this,ah,"f").call(this,i),i})):(n("projectId")||n("baseUrl")||n("executionId")||n("stepId"))&&(ae.next=(e,t)=>c(this,void 0,void 0,(function*(){const n=(null==g?void 0:g.clientScripts)||[];yield u(this,Du,"m",Sh).call(this,n);const i=yield this.sdk.flow.next(f,d,e,J.version,G.componentsVersion,Object.assign(Object.assign({origin:u(this,Du,"a",gh)},this.getComponentsContext()),Jr(t)),ae.next.isCustomScreen);return u(this,ah,"f").call(this,i),i}))),this.loggerWrapper.debug("Got a screen with id",ae.screenId),yield u(this,Du,"m",eh).call(this,ae),this.stepState.update(ae)}))}onStepChange(e,t){return c(this,void 0,void 0,(function*(){var n,i,o;const{htmlFilename:r,htmlLocaleFilename:s,direction:a,next:d,screenState:l,screenId:h}=e;this.loggerWrapper.debug("Rendering a flow screen"),this.clearEmailVerification(),this.updateScreenUser(null==l?void 0:l.user);const f=document.createElement("template");f.innerHTML=yield this.getPageContent(r,s);const p=f.content.cloneNode(!0),v=this.loadDescopeUiComponents(f);this.sdk.webauthn.helpers.isSupported()?yield u(this,Du,"m",ch).call(this,p,d):(e=>{e.querySelectorAll(`descope-button[${Ko}="biometrics"]`).forEach((e=>e.setAttribute("disabled","true")))})(p),!e.samlIdpUsername||(null===(n=l.form)||void 0===n?void 0:n.loginId)||(null===(i=l.form)||void 0===i?void 0:i.email)||(l.form||(l.form={}),l.form.loginId=e.samlIdpUsername,l.form.email=e.samlIdpUsername),cs(p,l,this.formConfig,this.loggerWrapper),this.applyComponentsState(p,null==l?void 0:l.componentsState),this.startEmailVerification(p);const{geo:g}=null!==(o=yield this.getExecutionContext())&&void 0!==o?o:{};((e,t)=>{Object.entries({"default-code":"autoDetect","default-country":"autoDetect"}).forEach((([n,i])=>{Array.from(e.querySelectorAll(`[${n}="${i}"]`)).forEach((e=>{e.setAttribute(n,t||i)}))}))})(p,g),((e,t)=>{let n=t;if(t)try{const[e]=Intl.getCanonicalLocales(t);e&&(n=e)}catch(e){}Object.entries({lang:"autoDetect"}).forEach((([t,i])=>{Array.from(e.querySelectorAll(`[${t}="${i}"]`)).forEach((e=>{e.setAttribute(t,n||i)}))}))})(p,e.locale);const m=()=>c(this,void 0,void 0,(function*(){var n,i;yield v;const o=this.contentRootElement;((e,t)=>{ls(e,"descope-totp-image",t)})(o,null===(n=null==l?void 0:l.totp)||void 0===n?void 0:n.image),((e,t)=>{ls(e,"descope-notp-image",t)})(o,null===(i=null==l?void 0:l.notp)||void 0===i?void 0:i.image),((e,t,n,i)=>{n&&Object.keys(n).forEach((o=>{if(!t.querySelector(o))return void i.debug(`Skipping css vars for component "${o}"`,`Got css vars for component ${o} but Could not find it on next page`);const r=customElements.get(o);r?Object.keys(n[o]).forEach((t=>{var s;const a=n[o],d=null===(s=null==r?void 0:r.cssVarList)||void 0===s?void 0:s[t];if(!d)return void i.info(`Could not find css variable name for ${t} in ${o}`,"Check if the css variable is defined in the component");const l=a[t];e.style.setProperty(d,l)})):i.debug(`Could not find component class for ${o}`,"Check if the component is registered")}))})(o,p,l.cssVars,this.loggerWrapper),o.replaceChildren(p);const r=!t.htmlFilename;setTimeout((()=>{u(this,Du,"m",$h).call(this),this.updateUsernameAnchor(),this.validateOnBlur&&((e,t)=>{e.querySelectorAll("*[name]").forEach((n=>{n.addEventListener("blur",(()=>{var i;if(rr(n,e))return;const o=()=>{var e;const i=n.focus;n.focus=()=>{};const o=null===(e=n.reportValidity)||void 0===e?void 0:e.call(n);t&&!1===o&&t(n),setTimeout((()=>{n.focus=i}))};if("true"===n.getAttribute("invalid")||(null===(i=n.value)||void 0===i?void 0:i.length))return void o();const r={timer:void 0},s=e=>{"true"===e.target.getAttribute("formnovalidate")&&(clearTimeout(r.timer),r.timer=void 0)};r.timer=setTimeout((()=>{e.removeEventListener("click",s),o(),r.timer=void 0}),150),e.addEventListener("click",s,{once:!0})}))}))})(o,(e=>this.trackValidationErrors([e],u(this,Du,"a",vh)))),((e,t)=>{rs(e,null==t?void 0:t.inputs),rs(e,null==t?void 0:t.form)})(o,l),this.initRealtimeConditions(o,l),u(this,Du,"m",uh).call(this,{isFirstScreen:r,isCustomScreen:!1,stepName:e.stepName}),Ur(o,this.autoFocus,r),u(this,Du,"m",Eh).call(this,h)})),u(this,Du,"m",xh).call(this,d,h),o.querySelector(`[${Ko}="polling"]`)&&d(Qo,{})}));a?u(this,Du,"m",ih).call(this,m):m()}))}getInputs(){return Array.from(this.shadowRoot.querySelectorAll(`*:not(slot)[name]:not([${Ro}])`))}shouldUsePopupPostMessage(){if(!this.popupOrigin)return!1;try{new URL(this.popupOrigin)}catch(e){return!1}return!0}};Fu=new WeakMap,_u=new WeakMap,qu=new WeakMap,Bu=new WeakMap,Ku=new WeakMap,Qu=new WeakMap,nh=new WeakMap,oh=new WeakMap,rh=new WeakMap,sh=new WeakMap,ah=new WeakMap,dh=new WeakMap,hh=new WeakMap,fh=new WeakMap,bh=new WeakMap,Ch=new WeakMap,Du=new WeakSet,Vu=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1,deferredPolling:!1})}),300)},Hu=function(e,t,n){return c(this,void 0,void 0,(function*(){var i;return(null===(i=this.nativeOptions)||void 0===i?void 0:i.bridgeVersion)>=2&&new Promise((i=>{this.nativeCallbacks.screenNext=n,this.nativeCallbacks.screenResolve=i,u(this,Du,"m",Ju).call(this,"beforeScreen",{screen:e,context:t})}))}))},zu=function(e){var t;(null===(t=this.nativeOptions)||void 0===t?void 0:t.bridgeVersion)>=2&&u(this,Du,"m",Ju).call(this,"afterScreen",{screen:e})},Ju=function(e,t){u(this,Du,"m",Oh).call(this,"bridge",{type:e,payload:t})},Gu=function({errorText:e,errorType:t}){const n=()=>{var n;let i=e;try{i=(null===(n=this.errorTransformer)||void 0===n?void 0:n.call(this,{text:e,type:t}))||e}catch(e){this.loggerWrapper.error("Error transforming error message",e.message)}((e,t,n="")=>{e.querySelectorAll(`[${Ko}="${t}"]`).forEach((e=>{e.textContent=n,e.classList[n?"remove":"add"]("hide")}))})(this.contentRootElement,"error-message",i)};this.addEventListener("screen-updated",n,{once:!0}),n()},Zu=function(){var e,t,n,i;null===(e=this.stepState)||void 0===e||e.subscribe(this.onStepChange.bind(this),(e=>{var t=e.screenState,n=void 0===t?{}:t,{errorText:i,errorType:o}=n,r=l(n,["errorText","errorType"]),s=l(e,["screenState"]);return Object.assign(Object.assign({},s),{screenState:r})})),null===(t=this.stepState)||void 0===t||t.subscribe(u(this,Du,"m",Gu).bind(this),(e=>{var t,n;return{errorText:null===(t=null==e?void 0:e.screenState)||void 0===t?void 0:t.errorText,errorType:null===(n=null==e?void 0:e.screenState)||void 0===n?void 0:n.errorType}}),{forceUpdate:!0}),null===(n=this.stepState)||void 0===n||n.subscribe(u(this,Du,"m",Yu).bind(this),(e=>{var t,n;return{errorText:null===(t=null==e?void 0:e.screenState)||void 0===t?void 0:t.errorText,errorType:null===(n=null==e?void 0:e.screenState)||void 0===n?void 0:n.errorType}}),{forceUpdate:!0}),null===(i=this.flowState)||void 0===i||i.subscribe((({screenId:e,executionId:t})=>{var n;try{this.updateTelemetryContext({screenId:e,executionId:t})}catch(e){null===(n=this.logger)||void 0===n||n.error("Error updating telemetry screenId:",e)}}),(e=>({screenId:e.screenId,executionId:e.executionId})))},Yu=function({errorText:e,errorType:t}){(t||e)&&(this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((e=>{e.shadowRoot.querySelectorAll("descope-text-field[data-id]").forEach((e=>{e.value=""}))})),Ur(this.contentRootElement,this.autoFocus,!1))},Xu=function(){return c(this,void 0,void 0,(function*(){this.loggerWrapper.debug("Trying to restart the flow");const e=yield this.getComponentsVersion();this.reset(),e===(yield this.getComponentsVersion())?(this.loggerWrapper.debug("Components version was not changed, restarting flow"),this.flowState.update(Object.assign({stepId:null,executionId:null},this.adoptedSsoQueryParams))):this.loggerWrapper.error("Components version mismatch, please reload the page")}))},eh=function(e){return c(this,void 0,void 0,(function*(){var t;const n=Object.assign(Object.assign({},this.stepState.current),e),{next:i,stepName:o}=n,r=(e=>{const t=(n=e.screenState,i=(e,t)=>nr.includes(t)||t.startsWith("_"),Object.fromEntries(Object.entries(n).filter((([e,t])=>!i(0,e)))));var n,i;const{screenState:{errorText:o,errorType:r}}=e;(o||r)&&(t.error={text:o,type:r}),e.action&&(t.action=e.action);const s=(e=>{if(!e)return;const t={};return zr.forEach((({key:n,from:i})=>{const o=i(e);void 0!==o&&(t[n]=o)})),Object.keys(t).length?t:void 0})(e.screenState);return s&&(t.data=s),t})(l(n,["next","stepName"]));let s=yield u(this,Du,"m",Hu).call(this,o,r,i);s||(s=Boolean(yield null===(t=this.onScreenUpdate)||void 0===t?void 0:t.call(this,o,r,i,this)));const a=!this.stepState.current.htmlFilename;if(u(this,nh,"f").call(this,s),i&&(i.isCustomScreen=s),u(this,Qu,"f")!==s){const[e,t]=["flow","custom"].sort((()=>s?-1:1));this.loggerWrapper.debug(`Switching from ${t} screen to ${e} screen`),h(this,Qu,s,"f"),s?this.stepState.unsubscribeAll():u(this,Du,"m",Zu).call(this)}s?(this.loggerWrapper.debug("Showing a custom screen"),u(this,Du,"m",uh).call(this,{isFirstScreen:a,isCustomScreen:s,stepName:e.stepName}),this.disableKeyPressHandler()):this.handleKeyPress(),this.stepState.forceUpdate=s}))},th=function(e,t){return c(this,void 0,void 0,(function*(){const n=new AbortController;try{const i=e===Jo?this.sdk.webauthn.helpers.create(t,n):this.sdk.webauthn.helpers.get(t,n),o=yield Dr(9e4,i,Nh);return o!==Nh?{response:o}:(n.abort(),this.loggerWrapper.warn("WebAuthn operation timed out after 90000ms"),{failure:"AbortError",failureReason:"aborted",failureMessage:"Passkey operation timed out"})}catch(e){return"InvalidStateError"===e.name?this.loggerWrapper.warn("WebAuthn operation failed",e.message):"NotAllowedError"!==e.name&&this.loggerWrapper.error(e.message),{failure:e.name,failureReason:e.reason,failureMessage:e.message}}}))},ih=function(e){this.contentRootElement.addEventListener("transitionend",(()=>{this.loggerWrapper.debug("page switch transition end"),this.contentRootElement.classList.remove("fade-out"),e()}),{once:!0}),this.loggerWrapper.debug("page switch transition start"),this.contentRootElement.classList.add("fade-out")},lh=function(e){const t=e.getAttribute("name");if(!["email"].includes(t)){const n=`user-${t}`;e.setAttribute("name",n),e.addEventListener("input",(()=>{e.setAttribute("name",e.value?t:n)}))}},ch=function(e,t){return c(this,void 0,void 0,(function*(){var n;null===(n=u(this,_u,"f"))||void 0===n||n.abort();const i=e.querySelector('*[autocomplete="webauthn"]');if(i&&(yield us())){const{options:e,transactionId:n}=(yield u(this,dh,"f").call(this))||{};e&&n&&(u(this,Du,"m",lh).call(this,i),h(this,_u,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(e,u(this,_u,"f")).then((e=>c(this,void 0,void 0,(function*(){t(i.id,{transactionId:n,response:e})})))).catch((e=>{"AbortError"!==e.name&&this.loggerWrapper.error("Conditional login failed",e.message)})))}}))},uh=function({isFirstScreen:e,isCustomScreen:t,stepName:n}){e&&u(this,Du,"m",Oh).call(this,"ready",{}),t||u(this,Du,"m",zu).call(this,n),u(this,Du,"m",Oh).call(this,"page-updated",{screenName:n}),u(this,Du,"m",Oh).call(this,"screen-updated",{screenName:n})},ph=function(e,t,n){this.setValidationTrackingEnabled(!!e.clientValidationTrackingEnabled),t&&n("executionId")&&this.setValidationTrackingExecution(t)},vh=function(){var e,t,n,i,o,r,s;const a=null===(e=this.flowState)||void 0===e?void 0:e.current;return(null==a?void 0:a.executionId)?{executionId:a.executionId,screenId:a.screenId,screenName:(null===(s=null===(r=this.stepState)||void 0===r?void 0:r.current)||void 0===s?void 0:s.stepName)||a.stepName}:{executionId:void 0,screenId:null!==(t=u(this,hh,"f"))&&void 0!==t?t:null==a?void 0:a.screenId,screenName:null!==(n=u(this,fh,"f"))&&void 0!==n?n:(null===(o=null===(i=this.stepState)||void 0===i?void 0:i.current)||void 0===o?void 0:o.stepName)||(null==a?void 0:a.stepName)}},gh=function(){var e;return(null===(e=this.nativeOptions)||void 0===e?void 0:e.origin)||window.location.origin},mh=function(){let e=!0;const t=[];return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((n=>{var i,o,r;"slot"===n.localName||rr(n,this.contentRootElement)||(null===(i=n.reportValidity)||void 0===i||i.call(n),n.validity&&!n.validity.valid&&t.push(n),e&&(e=null===(r=null===(o=n.checkValidity)||void 0===o?void 0:o.call(n))||void 0===r||r))})),t.length&&this.trackValidationErrors(t,u(this,Du,"a",vh)),e},yh=function(){return c(this,void 0,void 0,(function*(){const e=this.getInputs();return(yield Promise.all(e.map((e=>c(this,void 0,void 0,(function*(){return{name:e.getAttribute("name"),value:e.value}})))))).reduce(((e,t)=>Object.assign(Object.assign({},e),{[t.name]:t.value})),{})}))},wh=function(e){var t,n;const i=Array.from(this.contentRootElement.querySelectorAll(':not([disabled]), [disabled="false"]')).filter((t=>t!==e)),o=(null===(n=null===(t=this.flowState.current)||void 0===t?void 0:t.screenState)||void 0===n?void 0:n.clientScripts)||[];e.setAttribute("loading","true"),i.forEach((e=>e.setAttribute("disabled","true")));const r=()=>{e.removeAttribute("loading"),i.forEach((e=>{e.removeAttribute("disabled")}))},s=e=>c(this,void 0,void 0,(function*(){var t;if(this.loggerWrapper.debug("Restoring components state"),this.removeEventListener("popupclosed",s),!0===(null===(t=null==e?void 0:e.detail)||void 0===t?void 0:t.abandoned)&&o.length)return h(this,qu,(()=>c(this,void 0,void 0,(function*(){try{yield this.loadSdkScripts(o)}catch(e){this.loggerWrapper.warn("Failed to refresh client scripts on popup close",null==e?void 0:e.message)}})))(),"f"),void r();r();const n=yield this.getFlowConfig(),i=[...n.clientScripts||[],...n.sdkScripts||[]];this.loadSdkScripts(i)})),a=()=>{var e;window.removeEventListener("pageshow",u(this,bh,"f")),h(this,bh,(e=>{e.persisted&&(this.logger.debug("Page was loaded from cache, restoring components state"),s())}),"f"),window.addEventListener("pageshow",u(this,bh,"f"),{once:!0});const t=null===(e=this.stepState)||void 0===e?void 0:e.subscribe(((e,n)=>{e===n&&s(),this.removeEventListener("popupclosed",s),this.stepState.unsubscribe(t)}),(e=>e.screenId),{forceUpdate:!0})},d=this.nextRequestStatus.subscribe((({isLoading:e})=>{e?this.addEventListener("popupclosed",s,{once:!0}):(this.nextRequestStatus.unsubscribe(d),"success"===this.flowStatus?(this.removeEventListener("popupclosed",s),r()):a())}));return r},$h=function(){document.querySelectorAll('[data-hidden-input="true"]').forEach((e=>e.remove())),this.contentRootElement.querySelectorAll('[external-input="true"]').forEach((e=>u(this,Du,"m",kh).call(this,e)))},kh=function(e){e&&e.querySelectorAll("input").forEach((t=>{const n=t.getAttribute("slot"),i=`input-${e.id}-${n}`,o=document.createElement("slot");o.setAttribute("name",i),o.setAttribute("slot",n),e.appendChild(o),t.setAttribute("slot",i),this.appendChild(t)}))},Sh=function(e){return c(this,void 0,void 0,(function*(){if(u(this,qu,"f")){this.loggerWrapper.debug("Waiting for sdk scripts to load");const e=Date.now();yield u(this,qu,"f"),this.loggerWrapper.debug("Sdk scripts loaded for",(Date.now()-e).toString())}const t=this.loadSdkScriptsModules(),n=e.map((e=>e.id));for(const e of t)if(n.includes(e.id))try{"function"==typeof e.present&&((yield e.present())||this.loggerWrapper.debug(`Sdk script ${e.id} was cancelled`))}catch(t){this.loggerWrapper.error(`Failed to present ${e.id} script module`,t.message)}const i=[];for(const e of t)"function"==typeof e.refresh&&i.push(e.refresh());if(i.length>0)try{yield Dr(5e3,Promise.all(i),null)}catch(e){this.loggerWrapper.error("Failed to refresh script module",e.message)}}))},Ih=function(e,t){this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((n=>{n.addEventListener("input",(()=>{var i;(null===(i=n.checkValidity)||void 0===i?void 0:i.call(n))&&u(this,Ch,"f").call(this,n,e,t)}))}))},Rh=function(e,t,n){t&&n&&"true"===e.getAttribute("data-opt-in-last-used-auth")&&function(e,t,n){try{const n=bs();n[e]=t,fs(tr,JSON.stringify(n))}catch(e){null==n||n.warn("[Descope] Failed to update in-flight last auth storage",String(e))}}(n,t,this.loggerWrapper)},Eh=function(e){var t;const n=null===(t=ms(this.sdk.getLastUserLoginId(),this.loggerWrapper).lastUsedPerScreen)||void 0===t?void 0:t[e];if(!n)return;const i=this.contentRootElement.querySelector('descope-attachment[data-type="last-auth-badge"]'),o=this.contentRootElement.querySelector(`#${CSS.escape(n)}`);i&&o&&(o.replaceWith(i),i.appendChild(o))},xh=function(e,t){this.contentRootElement.querySelectorAll(`descope-button:not([${Eo}]), [data-type="button"]:not([${Eo}]`).forEach((n=>{n.onclick=()=>{u(this,Ch,"f").call(this,n,e,t)}})),u(this,Du,"m",Ih).call(this,e,t),this.isDismissScreenErrorOnInput&&this.contentRootElement.querySelectorAll(`*[name]:not([${Ro}])`).forEach((e=>{e.addEventListener("input",(()=>{this.stepState.update((e=>Object.assign(Object.assign({},e),{screenState:Object.assign(Object.assign({},e.screenState),{errorText:"",errorType:""})})))}))}))},Oh=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))},Ah=function(e,t,n){var i;const[o,r]=(null===(i=window.name)||void 0===i?void 0:i.split("|"))||[],s="descope-wc"===o&&!!r,a=s?function(e){const t=Pr(e);if(t)return t===window.location.origin||Pr(function(){const e=new URLSearchParams(window.location.search).getAll("popup_opener_origin");return 1===e.length?e[0]:void 0}())===t?t:void 0}(r):void 0;s&&!a&&this.loggerWrapper.warn("Popup opener origin is not approved for this project, add it to the approved domains to send the OAuth result to it",r);const d={data:{code:t,exchangeError:n},action:"code"};if(a){this.loggerWrapper.debug("Using postMessage fallback to notify opener in origin",a);try{window.opener.postMessage(d,a)}catch(e){this.loggerWrapper.error("Failed to send postMessage fallback (likely COOP isolation)",null==e?void 0:e.message)}}else{this.loggerWrapper.debug("Creating popup channel",e);const t=new BroadcastChannel(e);t.postMessage(d),t.close()}try{window.close()}catch(e){}},jh.bridgeVersion=3,customElements.get("descope-wc")?console.log("descope-wc is already defined"):customElements.define("descope-wc",jh);var Mh=Object.freeze({__proto__:null,default:jh});const Ph=e=>e.selectedAccessKeysIds,Th=e=>e.notifications,Wh=Al((e=>e.accessKeysList.data),(e=>e.map((e=>Object.assign(Object.assign({},e),{expireTimeFormatted:(null==e?void 0:e.expireTime)?new Date(1e3*((null==e?void 0:e.expireTime)||0)).toLocaleString():"Never",createdTimeFormatted:new Date(1e3*((null==e?void 0:e.createdTime)||0)).toLocaleString(),status:(null==e?void 0:e.expireTime)&&new Date(1e3*((null==e?void 0:e.expireTime)||0))<new Date?"expired":null==e?void 0:e.status}))))),Lh=Al(Ph,Wh,((e,t)=>t.filter((t=>e.includes(t.id))))),Uh=Al(Ph,(e=>!!e.length)),Dh=Al(Lh,(e=>e.every((e=>e.editable)))),Fh=Al(Dh,Uh,((e,t)=>e&&t)),_h=Al(Lh,(e=>e.some((e=>"expired"===e.status)))),qh=Al(Fh,_h,((e,t)=>e&&!t)),Bh=Al(Ph,(e=>1===e.length)),Vh=Al(Lh,(e=>1===e.length?e[0].name:`${e.length} access keys`)),Kh=Al(qh,Bh,Lh,((e,t,n)=>{var i;return e&&t&&"active"===(null===(i=n[0])||void 0===i?void 0:i.status)})),Hh=e=>(...t)=>n=>{n.addCase(e.pending,((e,n)=>{t.forEach((({onPending:t})=>{null==t||t(e,n)}))})),n.addCase(e.fulfilled,((e,n)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,n)}))})),n.addCase(e.rejected,((e,n)=>{t.forEach((({onRejected:t})=>{null==t||t(e,n)}))}))},zh=e=>({onFulfilled:t=>{e(t).loading=!1},onPending:t=>{e(t).loading=!0,e(t).error=null},onRejected:(t,n)=>{e(t).loading=!1,e(t).error=n.error}}),Jh=({getErrorMsg:e,getSuccessMsg:t})=>({onFulfilled:(e,n)=>{t&&e.notifications.push({type:"success",msg:t(n)})},onRejected:(t,n)=>{e&&t.notifications.push({type:"error",msg:e(n)})}}),Gh=lc("accessKeys/create",((e,{extra:{api:t}})=>t.accesskey.create(e))),Zh=Hh(Gh)({onFulfilled:(e,t)=>{e.accessKeysList.data.unshift(t.payload.key)}},zh((e=>e.createAccessKey)),Jh({getSuccessMsg:()=>"Access Key created successfully",getErrorMsg:e=>{var t;const n=null===(t=e.error)||void 0===t?void 0:t.message;return`\n <div>\n <div>Failed to create access key</div>\n ${Vi(n)}\n </div>`}})),Yh={action:Gh,reducer:Zh},Xh=lc("accessKeys/delete",((e,{extra:{api:t}})=>t.accesskey.deleteBatch(e))),Qh=Hh(Xh)({onFulfilled:(e,t)=>{e.accessKeysList.data=e.accessKeysList.data.filter((e=>!t.meta.arg.includes(e.id))),e.selectedAccessKeysIds=[]}},zh((e=>e.deleteAccessKey)),Jh({getSuccessMsg:e=>ji(e.meta.arg.length)`${["",e.meta.arg.length]} ${["A","a"]}ccess key${["","s"]} deleted successfully`,getErrorMsg:e=>ji(e.meta.arg.length)`Failed to delete access key${["","s"]}`})),ef={action:Xh,reducer:Qh},tf=lc("accessKeys/search",((e,{extra:{api:t},getState:n})=>{const i=n().searchParams;return t.accesskey.search(Object.assign(Object.assign({},i),e))})),nf=Hh(tf)({onPending:(e,t)=>{e.searchParams=Object.assign(Object.assign({},e.searchParams),t.meta.arg)},onFulfilled:(e,t)=>{e.accessKeysList.data=t.payload}},zh((e=>e.accessKeysList))),of={action:tf,reducer:nf},rf=lc("accessKeys/activate",((e,{extra:{api:t}})=>t.accesskey.activate(e))),sf=Hh(rf)({onFulfilled:(e,t)=>{e.accessKeysList.data.forEach((e=>{t.meta.arg.includes(e.id)&&(e.status="active")}))}},zh((e=>e.activateAccessKey)),Jh({getSuccessMsg:e=>ji(e.meta.arg.length)`${["",e.meta.arg.length]} ${["A","a"]}ccess key${["","s"]} activated successfully`,getErrorMsg:e=>ji(e.meta.arg.length)`Failed to activate access key${["","s"]}`})),af={action:rf,reducer:sf},df=lc("accessKeys/deactivate",((e,{extra:{api:t}})=>t.accesskey.deactivate(e))),lf=Hh(df)({onFulfilled:(e,t)=>{e.accessKeysList.data.forEach((e=>{t.meta.arg.includes(e.id)&&(e.status="inactive")}))}},zh((e=>e.deactivateAccessKey)),Jh({getSuccessMsg:e=>ji(e.meta.arg.length)`${["",e.meta.arg.length]} ${["A","a"]}ccess key${["","s"]} deactivated successfully`,getErrorMsg:e=>ji(e.meta.arg.length)`Failed to deactivate access key${["","s"]}`})),cf={action:df,reducer:lf},uf=lc("accessKeys/rotate",((e,{extra:{api:t}})=>t.accesskey.rotate(e))),hf=Hh(uf)({onFulfilled:(e,t)=>{const n=e.accessKeysList.data.findIndex((e=>e.id===t.payload.key.id));n>=0&&(e.accessKeysList.data[n]=t.payload.key)}},zh((e=>e.rotateAccessKey)),Jh({getSuccessMsg:()=>"Access key rotated successfully",getErrorMsg:e=>{var t;const n=null===(t=e.error)||void 0===t?void 0:t.message;return`\n <div>\n <div>Failed to rotate access key</div>\n ${Vi(n)}\n </div>`}})),ff={action:uf,reducer:hf},pf=lc("tenant/getTenantRoles",((e,{extra:{api:t}})=>t.tenant.getTenantRoles())),vf={action:pf,reducer:Hh(pf)({onFulfilled:(e,t)=>{e.tenantRoles.data=t.payload.roles}},zh((e=>e.tenantRoles)))},gf={accessKeysList:{data:[],loading:!1,error:null},createAccessKey:{loading:!1,error:null},activateAccessKey:{loading:!1,error:null},deactivateAccessKey:{loading:!1,error:null},deleteAccessKey:{loading:!1,error:null},rotateAccessKey:{loading:!1,error:null},tenantRoles:{loading:!1,error:null,data:[]},searchParams:{text:"",sort:[]},selectedAccessKeysIds:[],notifications:[]},mf="/v1/mgmt/accesskey/search",yf="/v1/mgmt/accesskey/delete/batch",bf="/v1/mgmt/accesskey/create",wf="/v1/mgmt/accesskey/deactivate/batch",$f="/v1/mgmt/accesskey/activate/batch",kf="/v1/mgmt/accesskey/rotate",Cf="/v1/mgmt/role/all",Sf=e=>c(void 0,void 0,void 0,(function*(){const t=yield e.text(),n=JSON.parse(t);if(!e.ok){const t=`${n.errorDescription}${n.errorMessage?`: ${n.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(n),e.text=()=>Promise.resolve(t)})),If=({httpClient:e,tenant:t,mock:n})=>({search:(...i)=>c(void 0,[...i],void 0,(function*({page:i,limit:o=1e4,text:r,sort:s}={}){if(n)return((...e)=>c(void 0,[...e],void 0,(function*({text:e,sort:t}={}){return new Promise((n=>{const i=[],o=(new Date).getTime()/1e3+2592e3,r=new Date(o).toLocaleString();for(let e=1;e<10;e+=1)i.push({id:`access-key-id-${e}`,name:`Access Key ${e}`,createdBy:`User ${e}`,editable:!0,expireTime:o,expireTimeFormatted:r,createdTime:o,createdTimeFormatted:r,roleNames:[`Role ${e}`],permittedIps:["127.1.2.3"],status:"active",clientId:`Client ID ${e}`,boundUserId:`User ${e}`});t.forEach((e=>{i.sort(((t,n)=>{var i,o;return e.desc?null===(o=n[e.field])||void 0===o?void 0:o.localeCompare(t[e.field]):null===(i=t[e.field])||void 0===i?void 0:i.localeCompare(n[e.field])}))})),n(i.filter((t=>t.name.toLowerCase().includes(e.toLowerCase())||t.createdBy.toLowerCase().includes(e.toLowerCase()))))}))})))({page:i,limit:o,text:r,sort:s});const a=yield e.post(mf,{limit:o,page:i,text:r,sort:s},{queryParams:{tenant:t}});return yield Sf(a),(yield a.json()).keys})),deleteBatch:i=>c(void 0,void 0,void 0,(function*(){if(n)return c(void 0,void 0,void 0,(function*(){}));const o=yield e.post(yf,{ids:i},{queryParams:{tenant:t}});return yield Sf(o),o.json()})),create:i=>c(void 0,[i],void 0,(function*({name:i,expiration:o,roleNames:r,userId:s,permittedIps:a}){const d=new Date;d.setDate(d.getDate()+ +o);const l="0"===o[0]?0:Math.floor(d.getTime()/1e3);if(n)return((e,t)=>c(void 0,[e,t],void 0,(function*({name:e,roleNames:t,userId:n,permittedIps:i},o){const r=Math.random().toString(10).substring(15);return new Promise((s=>{s({cleartext:Math.random().toString(20).substring(2),key:{id:`access-key-id-${r}`,name:e||`Access Key ${r}`,createdBy:n||`User ${r}`,editable:!0,expireTime:o,createdTime:(new Date).getTime()/1e3,roleNames:t,permittedIps:i,status:"active",clientId:`Client ID ${r}`,boundUserId:n||`User ${r}`}})}))})))({name:i,expiration:o,roleNames:r,userId:s,permittedIps:a},l);const u=yield e.post(bf,{name:i,expireTime:l,roleNames:r,userId:s,permittedIps:a},{queryParams:{tenant:t}});return yield Sf(u),yield u.json()})),activate:i=>c(void 0,void 0,void 0,(function*(){if(n)return c(void 0,void 0,void 0,(function*(){}));const o=yield e.post($f,{ids:i},{queryParams:{tenant:t}});return yield Sf(o),yield o.json()})),deactivate:i=>c(void 0,void 0,void 0,(function*(){if(n)return c(void 0,void 0,void 0,(function*(){}));const o=yield e.post(wf,{ids:i},{queryParams:{tenant:t}});return yield Sf(o),yield o.json()})),rotate:i=>c(void 0,[i],void 0,(function*({id:i}){if(n)return(e=>c(void 0,[e],void 0,(function*({id:e}){return new Promise((t=>{t({cleartext:Math.random().toString(20).substring(2),key:{id:e,name:`Access Key ${e}`,createdBy:"User",editable:!0,expireTime:(new Date).getTime()/1e3+2592e3,createdTime:(new Date).getTime()/1e3,roleNames:[],permittedIps:[],status:"active",clientId:`Client ID ${e}`,boundUserId:"User"}})}))})))({id:i});const o=yield e.post(kf,{id:i},{queryParams:{tenant:t}});return yield Sf(o),yield o.json()}))}),Rf=({httpClient:e,tenant:t,mock:n})=>({getTenantRoles:()=>c(void 0,void 0,void 0,(function*(){if(n)return(e=>new Promise((t=>{const n=[];for(let t=1;t<5;t+=1)n.push({name:`Role ${t}`,description:`Role description ${t}`,createdTime:new Date,permissionNames:[`Permission ${t}`],tenantId:e});t({roles:n})})))(t);const i=yield e.get(Cf,{queryParams:{tenant:t}});return yield Sf(i),i.json()}))}),Ef=Ti((e=>{var t,n,i,o;const r=Ei(js,As,Cs,Ms,Sc,Ns({tenant:Ns.missingAttrValidator}))(e);return o=class extends r{constructor(){super(...arguments),t.add(this),n.set(this,void 0)}get tenantId(){return this.getAttribute("tenant")}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get api(){return u(this,n,"f")||u(this,t,"m",i).call(this),u(this,n,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.init)||void 0===o?void 0:o.call(this),this.observeAttributes(["project-id","base-url","tenant"],(()=>{u(this,n,"f")&&u(this,t,"m",i).call(this)}))}))}},n=new WeakMap,t=new WeakSet,i=function(){this.logger.debug("creating an sdk instance"),h(this,n,((e,t,n,i)=>{const o=yi(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"access-key-management-widget","x-descope-widget-id":i,"x-descope-widget-version":"0.10.19"}}));return{accesskey:If({httpClient:o.httpClient,tenant:t,mock:n}),tenant:Rf({httpClient:o.httpClient,tenant:t,mock:n}),httpClient:o.httpClient}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},this.tenantId,"true"===this.mock,this.widgetId),"f")},o})),xf=Ti((e=>{const t=Ei(yc({name:"widget",initialState:gf,reducers:{setSelectedAccessKeysIds:(e,{payload:t})=>{e.selectedAccessKeysIds=t},clearNotifications:e=>{e.notifications=[]}},extraReducers:e=>{Yh.reducer(e),ef.reducer(e),of.reducer(e),af.reducer(e),cf.reducer(e),ff.reducer(e),vf.reducer(e)},asyncActions:{searchAccessKeys:of.action,createAccessKey:Yh.action,activateAccessKeys:af.action,deactivateAccessKeys:cf.action,deleteAccessKeys:ef.action,rotateAccessKey:ff.action,getTenantRoles:vf.action}}),Os,Cs,Ef)(e);return class extends t{constructor(...e){super(...e),this.state=gf,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),Of=Ti((e=>{var t,n,i;return i=class extends(Ei(Cs,Os,Hs,Xs,Cc("access-key-management-widget"),xf)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){return c(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.init)||void 0===i?void 0:i.call(this),yield Promise.all([u(this,t,"m",n).call(this),this.actions.searchAccessKeys(),this.actions.getTenantRoles()]),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,n=function(){return c(this,void 0,void 0,(function*(){const e=xi(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},i})),Af=Ti((e=>{var t,n,i,o,r;return r=class extends(Ei(xf,Cs,Of)(e)){constructor(){super(...arguments),t.add(this),i.set(this,Ai((e=>{this.accessKeysTable.data=e}))),o.set(this,Mi(((e,t)=>{const n=[],{value:i}=t;if(i){const t=e.path;n.push({field:t,desc:"desc"===i})}this.actions.searchAccessKeys({sort:n})})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var r;yield null===(r=e.onWidgetRootReady)||void 0===r?void 0:r.call(this),u(this,t,"m",n).call(this),this.accessKeysTable.columns.forEach((e=>{e.onSortDirectionChange((e=>{u(this,o,"f").call(this,e.target,e.detail)}))})),u(this,i,"f").call(this,Wh(this.state)),this.subscribe(u(this,i,"f").bind(this),Wh)}))}},i=new WeakMap,o=new WeakMap,t=new WeakSet,n=function(){var e;this.accessKeysTable=new Ea(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="access-keys-table"]'),{logger:this.logger}),this.accessKeysTable.onSelectedItemsChange((e=>{this.actions.setSelectedAccessKeysIds(e.detail.value.map((({id:e})=>e)))}))},r})),Nf=Ti((e=>{var t,n,i;return i=class extends(Ei(xf,ud,Cs,Of)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),yield u(this,t,"m",n).call(this)}))}},t=new WeakSet,n=function(){return c(this,void 0,void 0,(function*(){var e;this.activateAccessKeysModal=this.createModal(),this.activateAccessKeysModal.setContent(xi(yield this.fetchWidgetPage("activate-access-keys-modal.html")));const t=new ka((()=>{var e;return null===(e=this.activateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger});t.onClick((()=>this.activateAccessKeysModal.close()));const n=new ka((()=>{var e;return null===(e=this.activateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});n.onClick((()=>{const e=Lh(this.state);this.actions.activateAccessKeys(null==e?void 0:e.map((e=>e.id))),this.activateAccessKeysModal.close()}));const i=new id(null===(e=this.activateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.activateAccessKeysModal.beforeOpen=()=>{const e=Vh(this.state);i.text=`Activate ${e}?`}}))},i})),jf=Ti((e=>{var t,n,i,o;return o=class extends(Ei(Cs,Of,xf,Nf)(e)){constructor(){super(...arguments),t.add(this),i.set(this,Ai((e=>{e?this.activateButton.enable():this.activateButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),u(this,t,"m",n).call(this),this.subscribe(u(this,i,"f").bind(this),qh)}))}},i=new WeakMap,t=new WeakSet,n=function(){var e;this.activateButton=new ka(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="activate-access-keys"]'),{logger:this.logger}),this.activateButton.disable(),this.activateButton.onClick((()=>{this.activateAccessKeysModal.open()}))},o})),Mf=Ti((e=>{var t,n,i;return i=class extends(Ei(xf,ud,bc,Cs,Of)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",n).call(this)}))}},t=new WeakSet,n=function(){return c(this,void 0,void 0,(function*(){this.createdAccessKeyModal=this.createModal(),this.createdAccessKeyModal.setContent(xi(yield this.fetchWidgetPage("created-access-key-modal.html"))),new ka((()=>{var e;return null===(e=this.createdAccessKeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-close"]')}),{logger:this.logger}).onClick((()=>{navigator.clipboard.writeText(this.getFormData(this.createdAccessKeyModal.ele)["generated-key"]),this.resetFormData(this.createdAccessKeyModal.ele),this.createdAccessKeyModal.close()}))}))},i})),Pf=Ti((e=>{var t,n,i,o,r;return r=class extends(Ei(xf,ud,bc,Cs,Of,Mf)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),o.set(this,(()=>c(this,void 0,void 0,(function*(){var e,t;yield u(this,n,"f").setData(null===(t=this.state,e=t.tenantRoles.data||[])||void 0===e?void 0:e.map((({name:e})=>({value:e,label:e}))))}))))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),u(this,t,"m",i).call(this)}))}},n=new WeakMap,o=new WeakMap,t=new WeakSet,i=function e(){return c(this,void 0,void 0,(function*(){this.createAccessKeyModal=this.createModal(),this.createAccessKeyModal.setContent(xi(yield this.fetchWidgetPage("create-access-key-modal.html"))),new ka((()=>{var e;return null===(e=this.createAccessKeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger}).onClick((()=>{this.createAccessKeyModal.close(),this.resetFormData(this.createAccessKeyModal.ele)})),new ka((()=>{var e;return null===(e=this.createAccessKeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger}).onClick((()=>c(this,void 0,void 0,(function*(){var e,t;if(this.validateForm(this.createAccessKeyModal.ele)){const n=yield this.actions.createAccessKey(Object.assign({},this.getFormData(this.createAccessKeyModal.ele)));this.createAccessKeyModal.close(),(null===(e=null==n?void 0:n.payload)||void 0===e?void 0:e.cleartext)&&(this.setFormData(this.createdAccessKeyModal.ele,{"generated-key":null===(t=null==n?void 0:n.payload)||void 0===t?void 0:t.cleartext}),this.createdAccessKeyModal.open())}})))),h(this,n,new Qa((()=>{var e;return null===(e=this.createAccessKeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="roles-multiselect"]')}),{logger:this.logger}),"f"),u(this,o,"f").call(this),this.createAccessKeyModal.afterClose=()=>{u(this,t,"m",e).call(this)}}))},r})),Tf=Ti((e=>{var t,n,i;return i=class extends(Ei(Cs,Pf,Of)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",n).call(this)}))}},t=new WeakSet,n=function(){var e;this.createButton=new ka(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="create-access-key"]'),{logger:this.logger}),this.createButton.onClick((()=>this.createAccessKeyModal.open()))},i})),Wf=Ti((e=>{var t,n,i;return i=class extends(Ei(xf,ud,Cs,Of)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),yield u(this,t,"m",n).call(this)}))}},t=new WeakSet,n=function(){return c(this,void 0,void 0,(function*(){var e;this.deactivateAccessKeysModal=this.createModal(),this.deactivateAccessKeysModal.setContent(xi(yield this.fetchWidgetPage("deactivate-access-keys-modal.html")));const t=new ka((()=>{var e;return null===(e=this.deactivateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger});t.onClick((()=>this.deactivateAccessKeysModal.close()));const n=new ka((()=>{var e;return null===(e=this.deactivateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});n.onClick((()=>{const e=Lh(this.state);this.actions.deactivateAccessKeys(null==e?void 0:e.map((e=>e.id))),this.deactivateAccessKeysModal.close()}));const i=new id(null===(e=this.deactivateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.deactivateAccessKeysModal.beforeOpen=()=>{const e=Vh(this.state);i.text=`Deactivate ${e}?`}}))},i})),Lf=Ti((e=>{var t,n,i,o;return o=class extends(Ei(Cs,Of,xf,Wf)(e)){constructor(){super(...arguments),t.add(this),i.set(this,Ai((e=>{e?this.deactivateButton.enable():this.deactivateButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),u(this,t,"m",n).call(this),this.subscribe(u(this,i,"f").bind(this),qh)}))}},i=new WeakMap,t=new WeakSet,n=function(){var e;this.deactivateButton=new ka(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="deactivate-access-keys"]'),{logger:this.logger}),this.deactivateButton.disable(),this.deactivateButton.onClick((()=>{this.deactivateAccessKeysModal.open()}))},o})),Uf=Ti((e=>{var t,n,i;return i=class extends(Ei(xf,ud,Cs,Of)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),yield u(this,t,"m",n).call(this)}))}},t=new WeakSet,n=function(){return c(this,void 0,void 0,(function*(){var e;this.deleteAccessKeysModal=this.createModal(),this.deleteAccessKeysModal.setContent(xi(yield this.fetchWidgetPage("delete-access-keys-modal.html")));const t=new ka((()=>{var e;return null===(e=this.deleteAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger});t.onClick((()=>this.deleteAccessKeysModal.close()));const n=new ka((()=>{var e;return null===(e=this.deleteAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});n.onClick((()=>{const e=Lh(this.state);this.actions.deleteAccessKeys(null==e?void 0:e.map((e=>e.id))),this.deleteAccessKeysModal.close()}));const i=new id(null===(e=this.deleteAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.deleteAccessKeysModal.beforeOpen=()=>{const e=Vh(this.state);i.text=`Delete ${e}?`}}))},i})),Df=Ti((e=>{var t,n,i,o;return o=class extends(Ei(Cs,Of,xf,Uf)(e)){constructor(){super(...arguments),t.add(this),i.set(this,Ai((e=>{e?this.deleteButton.enable():this.deleteButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),u(this,t,"m",n).call(this),this.subscribe(u(this,i,"f").bind(this),Fh)}))}},i=new WeakMap,t=new WeakSet,n=function(){var e;this.deleteButton=new ka(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="delete-access-keys"]'),{logger:this.logger}),this.deleteButton.disable(),this.deleteButton.onClick((()=>{this.deleteAccessKeysModal.open()}))},o})),Ff=Ti((e=>{var t,n,i,o;return o=class extends(Ei(Cs,Of,xf)(e)){constructor(){super(...arguments),t.add(this),n.set(this,Mi((()=>{this.actions.searchAccessKeys({text:this.searchInput.value})})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),u(this,t,"m",i).call(this)}))}},n=new WeakMap,t=new WeakSet,i=function(){var e;this.searchInput=new od(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="search-input"]'),{logger:this.logger}),this.searchInput.onInput(u(this,n,"f"))},o})),_f={success:(new DOMParser).parseFromString('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Checkmark">\n<path id="Shape" d="M10.0485 15.6396C9.5799 15.171 8.8201 15.171 8.35147 15.6396C7.88284 16.1082 7.88284 16.868 8.35147 17.3367L12.7072 21.6924C13.1759 22.1611 13.9357 22.1611 14.4043 21.6924L24.7152 11.3815C25.1838 10.9129 25.1838 10.1531 24.7152 9.68448C24.2466 9.21585 23.4868 9.21585 23.0181 9.68448L13.5558 19.1469L10.0485 15.6396Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,error:(new DOMParser).parseFromString('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Icon">\n<path id="Vector" d="M15.9998 26.6558C10.1118 26.6558 5.34375 21.8878 5.34375 15.9998C5.34375 10.1118 10.1118 5.34375 15.9998 5.34375C21.8878 5.34375 26.6558 10.1118 26.6558 15.9998C26.6558 21.8878 21.8878 26.6558 15.9998 26.6558ZM15.9998 24.4798C20.6718 24.4798 24.4798 20.7038 24.4798 15.9998C24.4798 11.3278 20.7038 7.51975 15.9998 7.51975C11.3278 7.51975 7.51975 11.2958 7.51975 15.9998C7.51975 20.6718 11.2958 24.4798 15.9998 24.4798ZM15.3278 9.34375H16.6718C17.0558 9.34375 17.3438 9.63175 17.3118 9.98375L16.9598 16.9278C16.9598 17.1838 16.7678 17.3438 16.5438 17.3438H15.4558C15.2318 17.3438 15.0398 17.1518 15.0398 16.9278L14.6878 9.98375C14.6878 9.63175 14.9758 9.34375 15.3278 9.34375ZM15.4558 19.4558H16.5438C16.9278 19.4558 17.2158 19.7438 17.1838 20.1278V21.1838C17.1838 21.5678 16.8958 21.8558 16.5438 21.8558H15.4558C15.0718 21.8558 14.7838 21.5678 14.7838 21.1838V20.1278C14.7838 19.7438 15.0718 19.4558 15.4558 19.4558Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild},qf=Ti((e=>{var t,n,i,o,r;return r=class extends(Ei(Cs,xf,pd,Os)(e)){constructor(){super(...arguments),t.add(this),o.set(this,Ai((e=>{e.length&&(e.forEach((({type:e,msg:o})=>{const r=u(this,t,"m",i).call(this,e);r.setContent(u(this,t,"m",n).call(this,{type:e,msg:o})),r.show()})),setTimeout((()=>this.actions.clearNotifications())))})))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this),this.subscribe(u(this,o,"f").bind(this),Th)}))}},o=new WeakMap,t=new WeakSet,n=function({type:e,msg:t}){const n=_f[e],i=Object.assign((new DOMParser).parseFromString('<svg width="2em" height="2em" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Icon">\n<path id="Shape" d="M10.6712 12L7.27521 8.60406C6.90826 8.23711 6.90826 7.64216 7.27521 7.27521C7.64216 6.90826 8.23711 6.90826 8.60406 7.27521L12 10.6712L15.3959 7.27521C15.7629 6.90826 16.3578 6.90826 16.7248 7.27521C17.0917 7.64216 17.0917 8.23711 16.7248 8.60406L13.3288 12L16.7248 15.3959C17.0917 15.7629 17.0917 16.3578 16.7248 16.7248C16.3578 17.0917 15.7629 17.0917 15.3959 16.7248L12 13.3288L8.60406 16.7248C8.23711 17.0917 7.64216 17.0917 7.27521 16.7248C6.90826 16.3578 6.90826 15.7629 7.27521 15.3959L10.6712 12Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,{slot:"close"});return`${(null==n?void 0:n.outerHTML)||""}${t}${i.outerHTML}`},i=function(e){return this.createNotification({mode:e,duration:"error"===e?0:3e3,position:"bottom-start",size:"sm"})},r})),Bf=Ti((e=>{var t,n,i;return i=class extends(Ei(xf,ud,bc,Cs,Of)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",n).call(this)}))}},t=new WeakSet,n=function(){return c(this,void 0,void 0,(function*(){this.rotatedAccessKeyModal=this.createModal(),this.rotatedAccessKeyModal.setContent(xi(yield this.fetchWidgetPage("rotated-access-key-modal.html"))),new ka((()=>{var e;return null===(e=this.rotatedAccessKeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-close"]')}),{logger:this.logger}).onClick((()=>{navigator.clipboard.writeText(this.getFormData(this.rotatedAccessKeyModal.ele)["generated-key"]),this.resetFormData(this.rotatedAccessKeyModal.ele),this.rotatedAccessKeyModal.close()}))}))},i})),Vf=Ti((e=>{var t,n,i;return i=class extends(Ei(xf,ud,bc,Cs,Of,Bf)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),yield u(this,t,"m",n).call(this)}))}},t=new WeakSet,n=function(){return c(this,void 0,void 0,(function*(){var e;this.rotateAccessKeyModal=this.createModal(),this.rotateAccessKeyModal.setContent(xi(yield this.fetchWidgetPage("rotate-access-key-modal.html")));const t=new ka((()=>{var e;return null===(e=this.rotateAccessKeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger});t.onClick((()=>this.rotateAccessKeyModal.close()));const n=new ka((()=>{var e;return null===(e=this.rotateAccessKeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});n.onClick((()=>c(this,void 0,void 0,(function*(){var e,t;const n=null===(e=Lh(this.state))||void 0===e?void 0:e[0];if(!n)return void this.rotateAccessKeyModal.close();const i=yield this.actions.rotateAccessKey({id:n.id});this.rotateAccessKeyModal.close(),(null===(t=null==i?void 0:i.payload)||void 0===t?void 0:t.cleartext)&&(this.setFormData(this.rotatedAccessKeyModal.ele,{"generated-key":i.payload.cleartext}),this.rotatedAccessKeyModal.open())}))));const i=new id(null===(e=this.rotateAccessKeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.rotateAccessKeyModal.beforeOpen=()=>{const e=Vh(this.state);i.text=`Rotate ${e}?`}}))},i})),Kf=Ti((e=>{var t,n,i,o;return o=class extends(Ei(Cs,Of,xf,Vf)(e)){constructor(){super(...arguments),t.add(this),i.set(this,Ai((e=>{e?this.rotateButton.enable():this.rotateButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),u(this,t,"m",n).call(this),this.subscribe(u(this,i,"f").bind(this),Kh)}))}},i=new WeakMap,t=new WeakSet,n=function(){var e;this.rotateButton=new ka(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="rotate-access-keys"]'),{logger:this.logger}),this.rotateButton.disable(),this.rotateButton.onClick((()=>{this.rotateAccessKeyModal.open()}))},o})),Hf=Ti((e=>class extends(Ei(fa,sa,Af,Tf,Df,Ff,jf,Lf,Kf,qf,Oc)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),zf=Ei((e=>class extends(Hf(e)){}))(HTMLElement);customElements.define("descope-access-key-management-widget",zf);var Jf,Gf=Object.freeze({__proto__:null,default:zf});!function(e){e.oidc="oidc",e.saml="saml",e.wsfed="wsfed",e.custom="custom"}(Jf||(Jf={}));const Zf=e=>e.ssoAppsList.data,Yf=Al(Zf,(e=>{var t;return null===(t=null==e?void 0:e.filter)||void 0===t?void 0:t.call(e,(e=>e.appType===Jf.saml))})),Xf=Al(Zf,(e=>{var t;return null===(t=null==e?void 0:e.filter)||void 0===t?void 0:t.call(e,(e=>{var t;return e.appType===Jf.oidc&&(null===(t=e.oidcSettings)||void 0===t?void 0:t.customIdpInitiatedLoginPageUrl)}))})),Qf=Al(Zf,(e=>{var t;return null===(t=null==e?void 0:e.filter)||void 0===t?void 0:t.call(e,(e=>{var t;return e.appType===Jf.wsfed&&(null===(t=e.wsfedSettings)||void 0===t?void 0:t.idpInitiatedUrl)}))})),ep=Al(Zf,(e=>{var t;return null===(t=null==e?void 0:e.filter)||void 0===t?void 0:t.call(e,(e=>e.appType===Jf.custom))})),tp=e=>{var t,n,i,o;switch(e.appType){case Jf.saml:return null===(t=e.samlSettings)||void 0===t?void 0:t.idpInitiatedUrl;case Jf.oidc:return null===(n=e.oidcSettings)||void 0===n?void 0:n.customIdpInitiatedLoginPageUrl;case Jf.wsfed:return null===(i=e.wsfedSettings)||void 0===i?void 0:i.idpInitiatedUrl;case Jf.custom:return null===(o=e.customSettings)||void 0===o?void 0:o.loginPageUrl;default:return}},np=Al(Yf,Xf,Qf,ep,((e,t,n,i)=>[...e,...t,...n,...i].map((e=>({name:e.name,icon:e.logo,url:tp(e)}))))),ip=lc("ssoApps/load",((e,{extra:{api:t}})=>t.ssoApps.load())),op=(e=>(...t)=>n=>{n.addCase(e.pending,((e,n)=>{t.forEach((({onPending:t})=>{null==t||t(e,n)}))})),n.addCase(e.fulfilled,((e,n)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,n)}))})),n.addCase(e.rejected,((e,n)=>{t.forEach((({onRejected:t})=>{null==t||t(e,n)}))}))})(ip)({onFulfilled:(e,t)=>{var n;e.ssoAppsList.data=null===(n=t.payload)||void 0===n?void 0:n.apps}},(rp=e=>e.ssoAppsList,{onFulfilled:e=>{rp(e).loading=!1},onPending:e=>{rp(e).loading=!0,rp(e).error=null},onRejected:(e,t)=>{rp(e).loading=!1,rp(e).error=t.error}}));var rp;const sp={action:ip,reducer:op},ap={ssoAppsList:{data:[],loading:!1,error:null}},dp="/v1/mgmt/sso/idp/apps/load",lp=({httpClient:e,mock:t})=>({load:()=>c(void 0,void 0,void 0,(function*(){if(t)return c(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({apps:[{id:"ssoapp1",name:"App 1",description:"This is the first SAML app",enabled:!0,appType:Jf.saml,logo:"logo1",samlSettings:{idpInitiatedUrl:""}},{id:"ssoapp2",name:"App 2",description:"This is the first OIDC app",enabled:!0,appType:Jf.oidc,logo:"logo2"},{id:"ssoapp3",name:"App 3",description:"This is the second SAML app",enabled:!0,appType:Jf.saml,logo:"logo3",samlSettings:{idpInitiatedUrl:""}},{id:"ssoapp4",name:"App 4",description:"This is a WS-Fed app",enabled:!0,appType:Jf.wsfed,logo:"logo4",wsfedSettings:{idpInitiatedUrl:"http://localhost/wsfed/idp-initiated",realm:"urn:mock:realm",replyUrl:"http://localhost/reply",loginPageUrl:"http://localhost/login"}}]})}))}));const n=yield e.get(dp);return yield(e=>c(void 0,void 0,void 0,(function*(){const t=yield e.text(),n=JSON.parse(t);if(!e.ok){const t=`${n.errorDescription}${n.errorMessage?`: ${n.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(n),e.text=()=>Promise.resolve(t)})))(n),n.json()}))}),cp=Ti((e=>{var t,n,i,o;const r=Ei(js,As,Cs,Sc,Ms)(e);return o=class extends r{constructor(){super(...arguments),t.add(this),n.set(this,void 0)}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get api(){return u(this,n,"f")||u(this,t,"m",i).call(this),u(this,n,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.init)||void 0===o?void 0:o.call(this),this.observeAttributes(["project-id","base-url"],(()=>{u(this,n,"f")&&u(this,t,"m",i).call(this)}))}))}},n=new WeakMap,t=new WeakSet,i=function(){this.logger.debug("creating an sdk instance"),h(this,n,((e,t,n)=>{const i=yi(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"applications-portal-widget","x-descope-widget-id":n,"x-descope-widget-version":"0.9.19"}}));return{ssoApps:lp({httpClient:i.httpClient,mock:t}),httpClient:i.httpClient}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},"true"===this.mock,this.widgetId),"f")},o})),up=Ti((e=>{const t=Ei(yc({name:"widget",initialState:ap,reducers:{},extraReducers:e=>{sp.reducer(e)},asyncActions:{loadSSOApps:sp.action}}),Os,Cs,cp)(e);return class extends t{constructor(...e){super(...e),this.state=ap,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),hp=Ti((e=>{var t,n,i,o;return o=class extends(Ei(Cs,Os,Hs,Xs,Cc("applications-portal-widget"),up)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){return c(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.init)||void 0===o?void 0:o.call(this);const[r]=yield Promise.all([u(this,t,"m",n).call(this),this.actions.loadSSOApps()]);u(this,t,"m",i).call(this,r),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,n=function(){return c(this,void 0,void 0,(function*(){const e=xi(yield this.fetchWidgetPage("root.html"));return yield this.loadDescopeUiComponents(e),e}))},i=function(e){this.contentRootElement.append(e.content.cloneNode(!0))},o})),fp=Ti((e=>{var t,n,i;return i=class extends(Ei(up,Cs,hp)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",n).call(this,np(this.state))}))}},t=new WeakSet,n=function(e){this.appsList=new ba((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-apps-list")}),{logger:this.logger}),this.appsList.data=e},i})),pp=Ti((e=>class extends(Ei(fa,sa,fp,Oc)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),vp=Ei((e=>class extends(pp(e)){}))(HTMLElement);customElements.define("descope-applications-portal-widget",vp);var gp=Object.freeze({__proto__:null,default:vp});const mp=(e,t)=>t?{[e]:t}:{},yp=e=>{if(!e)return;const t=JSON.parse(e);return Array.isArray(t)&&0===t.length?void 0:t},bp=e=>e.selectedAuditId,wp=Al((e=>e.auditList.data),(e=>e.map((e=>{const t=e||{},{occurred:n,ID:i,type:o}=t,r=t.data,s=void 0===r?{saml_request:"",saml_response:"",saml_generated_user:"",saml_generated_roles:"",oidc_response:"",oidc_generated_user:"",scim_request:"",scim_result:"",Change:""}:r,{saml_request:a,saml_response:d,saml_generated_user:c,saml_generated_roles:u,oidc_response:h,oidc_generated_user:f,scim_request:p,scim_result:v,Change:g}=s,m=l(s,["saml_request","saml_response","saml_generated_user","saml_generated_roles","oidc_response","oidc_generated_user","scim_request","scim_result","Change"]),y=l(t,["occurred","ID","type","data"]);var b;return(e=>Object.fromEntries(Object.entries(e).filter((([e,t])=>!!t))))(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},y),{data:m}),mp("type",(b=o)&&b[0].toUpperCase()+b.slice(1))),mp("saml_request",a)),mp("saml_response",d)),mp("saml_generated_user",yp(c))),mp("saml_generated_roles",yp(u))),mp("oidc_response",yp(h))),mp("oidc_generated_user",yp(f))),mp("scim_request",p)),mp("scim_result",v)),mp("Change",g)),{occurredFormatted:n?new Date(Number(n)||0).toLocaleString():"N/A"}))}))));Al(bp,wp,((e,t)=>t.find((t=>e===t.id)))),Al(bp,(e=>!!e));const $p=lc("audit/search",((e,{extra:{api:t},getState:n})=>{const i=n().searchParams;return t.audit.search(Object.assign(Object.assign({},i),e))})),kp=(e=>(...t)=>n=>{n.addCase(e.pending,((e,n)=>{t.forEach((({onPending:t})=>{null==t||t(e,n)}))})),n.addCase(e.fulfilled,((e,n)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,n)}))})),n.addCase(e.rejected,((e,n)=>{t.forEach((({onRejected:t})=>{null==t||t(e,n)}))}))})($p)({onPending:(e,t)=>{e.searchParams=Object.assign(Object.assign({},e.searchParams),t.meta.arg)},onFulfilled:(e,t)=>{e.auditList.data=t.payload}},(Cp=e=>e.auditList,{onFulfilled:e=>{Cp(e).loading=!1},onPending:e=>{Cp(e).loading=!0,Cp(e).error=null},onRejected:(e,t)=>{Cp(e).loading=!1,Cp(e).error=t.error}}));var Cp;const Sp={action:$p,reducer:kp},Ip={auditList:{data:[],loading:!1,error:null},searchParams:{text:"",sort:[]},selectedAuditId:""},Rp="/v1/mgmt/audit/search",Ep=({httpClient:e,tenant:t,mock:n})=>({search:(...i)=>c(void 0,[...i],void 0,(function*({page:i,limit:o=1e4,text:r,sort:s,from:a}={}){if(n)return(e=>c(void 0,[e],void 0,(function*({text:e,sort:t}){return new Promise((n=>{const i=[],o=(new Date).getTime()/1e3+2592e3,r=new Date(o).toLocaleString();for(let e=1;e<9;e+=1)i.push({id:`Audit ${e}`,action:`Action ${e}`,actorId:`Actor ${e}`,type:"info",method:`Method ${e}`,userId:`User ${e}`,device:`Device ${e}`,geo:`Geo ${e}`,remoteAddress:`127.0.0.${e}`,externalIds:[`Login ID ${e}`],occurred:o,occurredFormatted:r});t.forEach((e=>{i.sort(((t,n)=>{var i,o;return e.desc?null===(o=n[e.field])||void 0===o?void 0:o.localeCompare(t[e.field]):null===(i=t[e.field])||void 0===i?void 0:i.localeCompare(n[e.field])}))})),n(i.filter((t=>t.id.toLowerCase().includes(e.toLowerCase())||t.action.toLowerCase().includes(e.toLowerCase())||t.type.toLowerCase().includes(e.toLowerCase())||t.device.toLowerCase().includes(e.toLowerCase())||t.method.toLowerCase().includes(e.toLowerCase())||t.geo.toLowerCase().includes(e.toLowerCase())||t.remoteAddress.toLowerCase().includes(e.toLowerCase())||t.externalIds.includes(e.toLowerCase())||t.userId.toLowerCase().includes(e.toLowerCase()))))}))})))({page:i,limit:o,text:r,sort:s});const d=yield e.post(Rp,{limit:o,page:i,text:r,sort:s,from:a},{queryParams:{tenant:t}});return yield(e=>c(void 0,void 0,void 0,(function*(){const t=yield e.text(),n=JSON.parse(t);if(!e.ok){const t=`${n.errorDescription}${n.errorMessage?`: ${n.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(n),e.text=()=>Promise.resolve(t)})))(d),(yield d.json()).audits}))}),xp=Ti((e=>{var t,n,i,o;const r=Ei(js,As,Cs,Ms,Sc,Ns({tenant:Ns.missingAttrValidator}))(e);return o=class extends r{constructor(){super(...arguments),t.add(this),n.set(this,void 0)}get tenantId(){return this.getAttribute("tenant")}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get api(){return u(this,n,"f")||u(this,t,"m",i).call(this),u(this,n,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.init)||void 0===o?void 0:o.call(this),this.observeAttributes(["project-id","base-url","tenant"],(()=>{u(this,n,"f")&&u(this,t,"m",i).call(this)}))}))}},n=new WeakMap,t=new WeakSet,i=function(){this.logger.debug("creating an sdk instance"),h(this,n,((e,t,n,i)=>{const o=yi(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"audit-management-widget","x-descope-widget-id":i,"x-descope-widget-version":"0.9.19"}}));return{audit:Ep({httpClient:o.httpClient,tenant:t,mock:n}),httpClient:o.httpClient}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},this.tenantId,"true"===this.mock,this.widgetId),"f")},o})),Op=Ti((e=>{const t=Ei(yc({name:"widget",initialState:Ip,reducers:{setSelectedAuditId:(e,{payload:t})=>{e.selectedAuditId=t}},extraReducers:e=>{Sp.reducer(e)},asyncActions:{searchAudit:Sp.action}}),Os,Cs,xp)(e);return class extends t{constructor(...e){super(...e),this.state=Ip,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),Ap=Ti((e=>{var t,n,i;return i=class extends(Ei(Cs,Os,Hs,Xs,Cc("audit-management-widget"),Op)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){return c(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.init)||void 0===i?void 0:i.call(this),yield Promise.all([u(this,t,"m",n).call(this)]),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,n=function(){return c(this,void 0,void 0,(function*(){const e=xi(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},i})),Np=Ti((e=>{var t,n,i,o,r;return r=class extends(Ei(Cs,Ap,Op)(e)){constructor(){super(...arguments),t.add(this),n.set(this,Mi((()=>{const e=this.rangeInput.value,t=new Date;let n;switch(e){case"minuets15":n=t.setMinutes(t.getMinutes()-15);break;case"hour":n=t.setHours(t.getHours()-1);break;case"hour6":n=t.setHours(t.getHours()-6);break;case"day":default:n=t.setDate(t.getDate()-1);break;case"day3":n=t.setDate(t.getDate()-3);break;case"week":n=t.setDate(t.getDate()-7);break;case"week2":n=t.setDate(t.getDate()-14);break;case"month":n=t.setMonth(t.getMonth()-1)}this.actions.searchAudit({text:this.searchInput.value,from:Math.floor(new Date(n).getTime())})})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),u(this,t,"m",i).call(this),u(this,t,"m",o).call(this)}))}},n=new WeakMap,t=new WeakSet,i=function(){var e;this.searchInput=new od(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="search-input"]'),{logger:this.logger}),this.searchInput.onInput(u(this,n,"f")),u(this,n,"f").call(this)},o=function(){var e;this.rangeInput=new nd(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="range-input"]'),{logger:this.logger}),this.rangeInput.onInput(u(this,n,"f"))},r})),jp=Ti((e=>{var t,n,i,o;return o=class extends(Ei(Op,Cs,Ap)(e)){constructor(){super(...arguments),t.add(this),i.set(this,Ai((e=>{this.auditTable.data=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),u(this,t,"m",n).call(this),u(this,i,"f").call(this,wp(this.state)),this.subscribe(u(this,i,"f").bind(this),wp)}))}},i=new WeakMap,t=new WeakSet,n=function(){var e;this.auditTable=new Ea(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="audit-table"]'),{logger:this.logger}),this.auditTable.onSelectedItemsChange((e=>{this.actions.setSelectedAuditId(e.detail.value.map((({id:e})=>e)))}))},o})),Mp=[{header:"Occurred",path:"occurredFormatted"},{header:"User ID",path:"userId"},{header:"Actor",path:"actorId"},{header:"Login IDs",path:"externalIds"},{header:"Remote Address",path:"remoteAddress"},{header:"Type",path:"type"},{header:"Action",path:"action"},{header:"Device",path:"device"},{header:"Method",path:"method"},{header:"Geo",path:"geo"}],Pp=Ti((e=>{var t,n,i;return i=class extends(Ei(Cs,Ap,Op)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",n).call(this)}))}},t=new WeakSet,n=function(){var e;this.exportButton=new ka(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="export-button"]'),{logger:this.logger}),this.exportButton.onClick((()=>{const e=wp(this.state);if(!e.length)return void this.logger.warn("No audit data to export");const t=((e,t)=>[t.map((e=>Bi(e.header))).join(","),...e.map((e=>t.map((t=>Bi(e[t.path]))).join(",")))].join("\n"))(e,Mp);((e,t)=>{const n=new Blob(["\ufeff"+e],{type:"text/csv;charset=utf-8;"}),i=URL.createObjectURL(n),o=document.createElement("a");o.href=i,o.setAttribute("download",t),document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(i)})(t,`audit_logs_${(new Date).toISOString().slice(0,10)}.csv`)}))},i})),Tp=Ti((e=>class extends(Ei(fa,sa,jp,Np,Pp,Oc)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),Wp=Ei((e=>class extends(Tp(e)){}))(HTMLElement);customElements.define("descope-audit-management-widget",Wp);var Lp=Object.freeze({__proto__:null,default:Wp});function Up(e){return new URLSearchParams(window.location.search).get(e)}const Dp=e=>(...t)=>n=>{n.addCase(e.pending,((e,n)=>{t.forEach((({onPending:t})=>{null==t||t(e,n)}))})),n.addCase(e.fulfilled,((e,n)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,n)}))})),n.addCase(e.rejected,((e,n)=>{t.forEach((({onRejected:t})=>{null==t||t(e,n)}))}))},Fp=e=>({onFulfilled:t=>{e(t).loading=!1},onPending:t=>{e(t).loading=!0,e(t).error=null},onRejected:(t,n)=>{e(t).loading=!1,e(t).error=n.error}}),_p=lc("outboundApps/load",((e,{extra:{api:t}})=>t.outboundApps.getAllOutboundApps())),qp=Dp(_p)({onFulfilled:(e,t)=>{var n;e.outboundAppsList.data=null===(n=t.payload)||void 0===n?void 0:n.apps}},Fp((e=>e.outboundAppsList))),Bp={action:_p,reducer:qp},Vp=lc("outboundApps/getConnectedOutboundApps",((e,{extra:{api:t}})=>t.outboundApps.getConnectedOutboundApps(e))),Kp=Dp(Vp)({onFulfilled:(e,t)=>{var n;e.connectedOutboundAppsIds.data=null===(n=t.payload)||void 0===n?void 0:n.appIds}},Fp((e=>e.connectedOutboundAppsIds))),Hp={action:Vp,reducer:Kp},zp={outboundAppsList:{data:[],loading:!1,error:null},connectedOutboundAppsIds:{data:[],loading:!1,error:null},allowedAppsIds:{data:void 0},me:{loading:!1,error:null,data:{}}},Jp="/v1/mgmt/outbound/apps",Gp="/v1/mgmt/outbound/apps-with-user-token",Zp="/v1/auth/me",Yp=e=>c(void 0,void 0,void 0,(function*(){const t=yield e.text(),n=JSON.parse(t);if(!e.ok){const t=`${n.errorDescription}${n.errorMessage?`: ${n.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(n),e.text=()=>Promise.resolve(t)})),Xp=({httpClient:e,mock:t})=>({getAllOutboundApps:()=>c(void 0,void 0,void 0,(function*(){if(t)return c(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({apps:[{id:"appId1",name:"Application 1",description:"Description"},{id:"appId2",name:"Application 2",description:"Description"},{id:"appId3",name:"Application 3",description:"Description"}]})}))}));const n=yield e.get(Jp);return yield Yp(n),n.json()})),getConnectedOutboundApps:n=>c(void 0,[n],void 0,(function*({userId:n,tenantId:i}){if(t)return c(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({apps:["outboundApp3"]})}))}));const o=yield e.get(Gp,{queryParams:i?{userId:n,tenantId:i}:{userId:n}});return yield Yp(o),o.json()}))}),Qp=({httpClient:e,mock:t})=>({me:()=>c(void 0,void 0,void 0,(function*(){if(t)return c(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({userId:"user-1"})}))}));const n=yield e.get(Zp);return yield Yp(n),n.json()}))}),ev=Ti((e=>{var t,n,i,o;const r=Ei(js,As,Cs,Sc,Ms)(e);return o=class extends r{constructor(){super(...arguments),t.add(this),n.set(this,void 0)}get tenantId(){return this.getAttribute("tenant")}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get styleId(){return this.getAttribute("style-id")||Qs}get api(){return u(this,n,"f")||u(this,t,"m",i).call(this),u(this,n,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.init)||void 0===o?void 0:o.call(this),this.observeAttributes(["project-id","base-url"],(()=>{u(this,n,"f")&&u(this,t,"m",i).call(this)}))}))}},n=new WeakMap,t=new WeakSet,i=function(){this.logger.debug("creating an sdk instance"),h(this,n,((e,t,n)=>{const i=yi(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"outbound-applications-widget","x-descope-widget-id":n,"x-descope-widget-version":"0.7.25"}}));return{outboundApps:Xp({httpClient:i.httpClient,mock:t}),user:Object.assign({},Qp({httpClient:i.httpClient,mock:t})),httpClient:i.httpClient}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},"true"===this.mock,this.widgetId),"f")},o})),tv=lc("users/me",((e,{extra:{api:t}})=>t.user.me())),nv={action:tv,reducer:Dp(tv)({onFulfilled:(e,t)=>{e.me.data=t.payload}},Fp((e=>e.me)))},iv=Ti((e=>{const t=Ei(yc({name:"widget",initialState:zp,reducers:{setAllowedAppsIds:(e,{payload:t})=>{e.allowedAppsIds.data=t}},extraReducers:e=>{nv.reducer(e),Hp.reducer(e),Bp.reducer(e)},asyncActions:{getMe:nv.action,getOutboundApps:Bp.action,getConnectedOutboundApps:Hp.action}}),Os,Cs,ev)(e);return class extends t{constructor(...e){super(...e),this.state=zp,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),ov="widget-flow",rv=Ti((e=>{var t,n,i;return i=class extends(Ei(kc,Os,hd,iv,Sc,Cs,sa,Ic)(e)){constructor(){super(...arguments),t.add(this)}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.init)||void 0===i?void 0:i.call(this);const o=Up(ov);o&&(function(e){if(window.history.replaceState&&Up(e)){const t=new URL(window.location.href),n=new URLSearchParams(t.search);n.delete(e),t.search=n.toString(),window.history.replaceState({},"",t.toString())}}(ov),u(this,t,"m",n).call(this,o))}))}},t=new WeakSet,n=function(e){const t=this.createFlowModal({"data-id":"redirect-flow"});t.setContent(this.createFlowTemplate({flowId:e})),new Ca((()=>{var e;return null===(e=t.ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}).onSuccess((()=>{t.close(),this.actions.getMe()})),t.afterClose=()=>{t.remove()},t.open()},i})),sv=Al((e=>e.outboundAppsList.data),(e=>e.connectedOutboundAppsIds.data),(e=>e.allowedAppsIds.data),((e,t,n)=>e.filter((e=>void 0===n||n.includes(e.id))).map((e=>{const n=(null==t?void 0:t.includes(e.id))||!1;return Object.assign(Object.assign({},e),{appId:e.id,isConnected:n})})).sort(((e,t)=>e.name.localeCompare(t.name))))),av=Al((e=>e.me.data),(e=>e.userId)),dv=Ti((e=>{var t,n,i,o,r;return r=class extends(Ei(Cs,Os,Hs,Xs,Cc("outbound-applications-widget"),iv)(e)){constructor(){super(...arguments),t.add(this)}static get observedAttributes(){return["allowed-outbound-apps-ids"]}attributeChangedCallback(e,n,i){"allowed-outbound-apps-ids"===e&&n!==i&&this.actions.setAllowedAppsIds(u(this,t,"a",o))}onWidgetRootReady(){return c(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var r;yield null===(r=e.init)||void 0===r?void 0:r.call(this),yield this.actions.getMe(),yield this.actions.setAllowedAppsIds(u(this,t,"a",o)),yield Promise.all([this.actions.getOutboundApps(),this.actions.getConnectedOutboundApps({userId:av(this.state),tenantId:this.tenantId})]);const s=yield u(this,t,"m",n).call(this);u(this,t,"m",i).call(this,s),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,n=function(){return c(this,void 0,void 0,(function*(){const e=xi(yield this.fetchWidgetPage("root.html"));return yield this.loadDescopeUiComponents(e),e}))},i=function(e){this.contentRootElement.append(e.content.cloneNode(!0))},o=function(){var e;if(!this.hasAttribute("allowed-outbound-apps-ids"))return;const t=null===(e=this.getAttribute("allowed-outbound-apps-ids"))||void 0===e?void 0:e.trim();return t?t.split(",").map((e=>e.trim())).filter(Boolean):[]},r})),lv=Ti((e=>class extends(Ei(sa,As)(e)){syncFlowTheme(e){e.theme=this.theme,this.observeAttributes(["theme"],(()=>{e.theme=this.theme}))}})),cv=Ti((e=>{var t,n,i,o,r,s,a,d,l,f,p,v,g,m,y,b,w;return w=class extends(Ei(kc,lv,iv,Cs,dv,hd,Ic)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),i.set(this,void 0),o.set(this,void 0),r.set(this,void 0),s.set(this,void 0),a.set(this,null),d.set(this,null),b.set(this,Ai((e=>{u(this,n,"f").data=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),u(this,t,"m",y).call(this,sv(this.state)),u(this,t,"m",l).call(this),u(this,t,"m",v).call(this),this.subscribe(u(this,b,"f").bind(this),sv)}))}},n=new WeakMap,i=new WeakMap,o=new WeakMap,r=new WeakMap,s=new WeakMap,a=new WeakMap,d=new WeakMap,b=new WeakMap,t=new WeakSet,l=function(){u(this,n,"f").connectFlowId&&(h(this,i,this.createFlowModal({"data-id":"outbound-apps-connect"}),"f"),u(this,i,"f").afterClose=()=>{var e;if(u(this,a,"f")){const t=null===(e=u(this,i,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc");null==t||t.removeEventListener("page-updated",u(this,a,"f")),h(this,a,null,"f")}},h(this,r,new Ca((()=>{var e;return null===(e=u(this,i,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(u(this,r,"f")))},f=function(e,t,n){e.open(),t.removeEventListener("page-updated",n)},p=function(e,n){var i;const o=null===(i=e.ele)||void 0===i?void 0:i.querySelector("descope-wc"),r=()=>u(this,t,"m",f).call(this,e,o,r);n=r,null==o||o.addEventListener("page-updated",n)},v=function(){h(this,o,this.createFlowModal({"data-id":"outbound-apps-disconnect"}),"f"),h(this,s,new Ca((()=>{var e;return null===(e=u(this,o,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,o,"f").afterClose=()=>{var e;if(u(this,d,"f")){const t=null===(e=u(this,o,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc");null==t||t.removeEventListener("page-updated",u(this,d,"f")),h(this,d,null,"f")}},this.syncFlowTheme(u(this,s,"f"))},g=function(e){u(this,i,"f").setContent(this.createFlowTemplate({flowId:u(this,n,"f").connectFlowId,lazyStart:!1,outboundAppId:e})),u(this,t,"m",p).call(this,u(this,i,"f"),u(this,a,"f")),u(this,r,"f").onSuccess((()=>{u(this,i,"f").close(),this.actions.getConnectedOutboundApps({userId:av(this.state),tenantId:this.tenantId})}))},m=function(e){u(this,o,"f").setContent(this.createFlowTemplate({flowId:u(this,n,"f").disconnectFlowId,lazyStart:!1,outboundAppId:e})),u(this,t,"m",p).call(this,u(this,o,"f"),u(this,d,"f")),u(this,s,"f").onSuccess((()=>{u(this,o,"f").close(),this.actions.getConnectedOutboundApps({userId:av(this.state)})}))},y=function(e){h(this,n,new td((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-outbound-apps")}),{logger:this.logger}),"f"),u(this,n,"f").onConnectClick((({id:e})=>{u(this,t,"m",g).call(this,e)})),u(this,n,"f").onDisconnectClick((({id:e})=>{u(this,t,"m",m).call(this,e)})),u(this,n,"f").data=e},w})),uv=Ti((e=>class extends(Ei(fa,sa,rv,cv,Oc)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),hv=Ei((e=>class extends(uv(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this),(customElements.get("descope-wc")||(yield Promise.resolve().then((function(){return Mh})).then((e=>e.default)))).sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"outbound-applications-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.7.25"}}}))}}))(HTMLElement);customElements.define("descope-outbound-applications-widget",hv);var fv=Object.freeze({__proto__:null,default:hv});const pv=e=>e.selectedRolesIds,vv=e=>e.notifications,gv=e=>e.tenantPermissions.data||[],mv=Al((e=>e.rolesList.data),(e=>e.map((e=>{var t;return Object.assign(Object.assign({},e),{editable:0===(null===(t=null==e?void 0:e.tenantId)||void 0===t?void 0:t.length)?"no":"yes"})})))),yv=Al(pv,mv,((e,t)=>t.filter((t=>e.includes(t.name))))),bv=Al(pv,(e=>!!e.length)),wv=Al(pv,(e=>1===e.length)),$v=Al(yv,wv,((e,t)=>t&&"yes"===e[0].editable)),kv=Al(yv,(e=>1===e.length?e[0].name:`${e.length} roles`)),Cv=e=>(...t)=>n=>{n.addCase(e.pending,((e,n)=>{t.forEach((({onPending:t})=>{null==t||t(e,n)}))})),n.addCase(e.fulfilled,((e,n)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,n)}))})),n.addCase(e.rejected,((e,n)=>{t.forEach((({onRejected:t})=>{null==t||t(e,n)}))}))},Sv=e=>({onFulfilled:t=>{e(t).loading=!1},onPending:t=>{e(t).loading=!0,e(t).error=null},onRejected:(t,n)=>{e(t).loading=!1,e(t).error=n.error}}),Iv=({getErrorMsg:e,getSuccessMsg:t})=>({onFulfilled:(e,n)=>{t&&e.notifications.push({type:"success",msg:t(n)})},onRejected:(t,n)=>{e&&t.notifications.push({type:"error",msg:e(n)})}}),Rv=lc("roles/create",((e,{extra:{api:t}})=>t.role.create(e))),Ev=Cv(Rv)({onFulfilled:(e,t)=>{e.rolesList.data.unshift(t.payload)}},Sv((e=>e.createRole)),Iv({getSuccessMsg:()=>"Role created successfully",getErrorMsg:e=>{var t;const n=null===(t=e.error)||void 0===t?void 0:t.message;return`\n <div>\n <div>Failed to create role</div>\n ${Vi(n)}\n </div>`}})),xv={action:Rv,reducer:Ev},Ov=lc("roles/delete",((e,{extra:{api:t}})=>t.role.deleteBatch(e))),Av=Cv(Ov)({onFulfilled:(e,t)=>{e.rolesList.data=e.rolesList.data.filter((e=>{var n;return 0===(null===(n=null==e?void 0:e.tenantId)||void 0===n?void 0:n.length)||!t.meta.arg.includes(e.name)})),e.selectedRolesIds=[]}},Sv((e=>e.deleteRole)),Iv({getSuccessMsg:e=>ji(e.meta.arg.length)`${["",e.meta.arg.length]} ${["R","r"]}ole${["","s"]} deleted successfully`,getErrorMsg:e=>ji(e.meta.arg.length)`Failed to delete role${["","s"]}`})),Nv={action:Ov,reducer:Av},jv=lc("roles/duplicate",((e,{extra:{api:t}})=>t.role.create(e))),Mv=Cv(jv)({onFulfilled:(e,t)=>{e.rolesList.data.unshift(t.payload)}},Sv((e=>e.duplicateRole)),Iv({getSuccessMsg:()=>"Role duplicated successfully",getErrorMsg:e=>{var t;const n=null===(t=e.error)||void 0===t?void 0:t.message;return`\n <div>\n <div>Failed to duplicate role</div>\n ${Vi(n)}\n </div>`}})),Pv={action:jv,reducer:Mv},Tv=lc("roles/search",((e,{extra:{api:t},getState:n})=>{const i=n().searchParams;return t.role.search(Object.assign(Object.assign({},i),e))})),Wv=Cv(Tv)({onPending:(e,t)=>{e.searchParams=Object.assign(Object.assign({},e.searchParams),t.meta.arg)},onFulfilled:(e,t)=>{e.rolesList.data=t.payload}},Sv((e=>e.rolesList))),Lv={action:Tv,reducer:Wv},Uv=lc("roles/update",((e,{extra:{api:t}})=>t.role.update(e))),Dv=Cv(Uv)({onFulfilled:(e,t)=>{const n=e.rolesList.data.findIndex((e=>e.name===t.payload.oldName));-1!==n&&(e.rolesList.data[n]=t.payload)}},Sv((e=>e.updateRole)),Iv({getSuccessMsg:()=>"Role updated successfully",getErrorMsg:e=>{var t;const n=null===(t=e.error)||void 0===t?void 0:t.message;return`\n <div>\n <div>Failed to update role</div>\n ${Vi(n)}\n </div>`}})),Fv={action:Uv,reducer:Dv},_v=lc("tenant/getTenantPermissions",((e,{extra:{api:t}})=>t.tenant.getTenantPermissions())),qv={action:_v,reducer:Cv(_v)({onFulfilled:(e,t)=>{e.tenantPermissions.data=t.payload.permissions}},Sv((e=>e.tenantPermissions)))},Bv={rolesList:{data:[],loading:!1,error:null},createRole:{loading:!1,error:null},duplicateRole:{loading:!1,error:null},updateRole:{loading:!1,error:null},deleteRole:{loading:!1,error:null},tenantPermissions:{loading:!1,error:null,data:[]},searchParams:{text:"",sort:[]},selectedRolesIds:[],notifications:[]},Vv="/v1/mgmt/role/search",Kv="/v1/mgmt/role/delete/batch",Hv="/v1/mgmt/role/create",zv="/v1/mgmt/role/update",Jv="/v1/mgmt/permission/all",Gv=e=>c(void 0,void 0,void 0,(function*(){const t=yield e.text(),n=JSON.parse(t);if(!e.ok){const t=`${n.errorDescription}${n.errorMessage?`: ${n.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(n),e.text=()=>Promise.resolve(t)})),Zv=({httpClient:e,tenant:t,mock:n})=>({search:(...i)=>c(void 0,[...i],void 0,(function*({page:i,limit:o=1e4,text:r,sort:s}={}){if(n)return((e,t)=>c(void 0,[e,t],void 0,(function*({text:e,sort:t},n){return new Promise((i=>{const o=[];for(let e=1;e<10;e+=1)o.push({name:`Role ${e}`,description:`Role description ${e}`,permissionNames:[`Permission ${e}`],createdTime:new Date,tenantId:n});t.forEach((e=>{o.sort(((t,n)=>{var i,o;return e.desc?null===(o=n[e.field])||void 0===o?void 0:o.localeCompare(t[e.field]):null===(i=t[e.field])||void 0===i?void 0:i.localeCompare(n[e.field])}))})),i(o.filter((t=>t.name.toLowerCase().includes(e.toLowerCase())||t.description.toLowerCase().includes(e.toLowerCase()))))}))})))({page:i,limit:o,text:r,sort:s},t);const a=yield e.post(Vv,{limit:o,page:i,text:r,sort:s},{queryParams:{tenant:t}});return yield Gv(a),(yield a.json()).roles})),deleteBatch:i=>c(void 0,void 0,void 0,(function*(){if(n)return c(void 0,void 0,void 0,(function*(){}));const o=yield e.post(Kv,{roleNames:i},{queryParams:{tenant:t}});return yield Gv(o),o.json()})),create:i=>c(void 0,[i],void 0,(function*({name:i,description:o,permissionNames:r}){if(n)return((e,t)=>c(void 0,[e,t],void 0,(function*({name:e,description:t,permissionNames:n},i){return new Promise((o=>{o({name:e,description:t,permissionNames:n,createdTime:new Date,tenantId:i})}))})))({name:i,description:o,permissionNames:r},t);const s=yield e.post(Hv,{name:i,description:o,permissionNames:r,tenantId:t},{queryParams:{tenant:t}});return yield Gv(s),yield s.json()})),update:i=>c(void 0,[i],void 0,(function*({name:i,newName:o,description:r,permissionNames:s}){if(n)return((e,t)=>c(void 0,[e,t],void 0,(function*({name:e,newName:t,description:n,permissionNames:i},o){return new Promise((r=>{r({name:t,description:n,permissionNames:i,createdTime:new Date,oldName:e,tenantId:o})}))})))({name:i,newName:o,description:r,permissionNames:s},t);const a=yield e.post(zv,{name:i,newName:o,description:r,permissionNames:s,tenantId:t},{queryParams:{tenant:t}});yield Gv(a);const d=yield a.json();return d.oldName=i,d}))}),Yv=({httpClient:e,tenant:t,mock:n})=>({getTenantPermissions:()=>c(void 0,void 0,void 0,(function*(){if(n)return new Promise((e=>{const t=[];for(let e=1;e<5;e+=1)t.push({name:`Permission ${e}`});e({permissions:t})}));const i=yield e.get(Jv,{queryParams:{tenant:t}});return yield Gv(i),i.json()}))}),Xv=Ti((e=>{var t,n,i,o;const r=Ei(js,As,Cs,Ms,Sc,Ns({tenant:Ns.missingAttrValidator}))(e);return o=class extends r{constructor(){super(...arguments),t.add(this),n.set(this,void 0)}get tenantId(){return this.getAttribute("tenant")}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get api(){return u(this,n,"f")||u(this,t,"m",i).call(this),u(this,n,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.init)||void 0===o?void 0:o.call(this),this.observeAttributes(["project-id","base-url","tenant"],(()=>{u(this,n,"f")&&u(this,t,"m",i).call(this)}))}))}},n=new WeakMap,t=new WeakSet,i=function(){this.logger.debug("creating an sdk instance"),h(this,n,((e,t,n,i)=>{const o=yi(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"role-management-widget","x-descope-widget-id":i,"x-descope-widget-version":"0.10.19"}}));return{role:Zv({httpClient:o.httpClient,tenant:t,mock:n}),tenant:Yv({httpClient:o.httpClient,tenant:t,mock:n}),httpClient:o.httpClient}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},this.tenantId,"true"===this.mock,this.widgetId),"f")},o})),Qv=Ti((e=>{const t=Ei(yc({name:"widget",initialState:Bv,reducers:{setSelectedRolesIds:(e,{payload:t})=>{e.selectedRolesIds=t},clearNotifications:e=>{e.notifications=[]}},extraReducers:e=>{xv.reducer(e),Pv.reducer(e),Fv.reducer(e),Nv.reducer(e),Lv.reducer(e),qv.reducer(e)},asyncActions:{searchRoles:Lv.action,createRole:xv.action,duplicateRole:Pv.action,updateRole:Fv.action,deleteRoles:Nv.action,getTenantPermissions:qv.action}}),Os,Cs,Xv)(e);return class extends t{constructor(...e){super(...e),this.state=Bv,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),eg=Ti((e=>{var t,n,i;return i=class extends(Ei(Cs,Os,Hs,Xs,Cc("role-management-widget"),Qv)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){return c(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.init)||void 0===i?void 0:i.call(this),yield Promise.all([u(this,t,"m",n).call(this),this.actions.searchRoles(),this.actions.getTenantPermissions()]),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,n=function(){return c(this,void 0,void 0,(function*(){const e=xi(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},i})),tg=Ti((e=>{var t,n,i,o,r,s,a;return a=class extends(Ei(Qv,ud,bc,Cs,eg)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),i.set(this,"create"),o.set(this,null),s.set(this,(()=>c(this,void 0,void 0,(function*(){var e;yield u(this,n,"f").setData(null===(e=gv(this.state))||void 0===e?void 0:e.map((({name:e})=>({value:e,label:e}))))}))))}openRoleModal(e="create",t){h(this,i,e,"f"),h(this,o,null!=t?t:null,"f"),this.roleFormModal.open()}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),u(this,t,"m",r).call(this)}))}},n=new WeakMap,i=new WeakMap,o=new WeakMap,s=new WeakMap,t=new WeakSet,r=function(){return c(this,void 0,void 0,(function*(){this.roleFormModal=this.createModal(),this.roleFormModal.setContent(xi(yield this.fetchWidgetPage("create-role-modal.html"))),new ka((()=>{var e;return null===(e=this.roleFormModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger}).onClick((()=>{this.roleFormModal.close(),this.resetFormData(this.roleFormModal.ele)})),new ka((()=>{var e;return null===(e=this.roleFormModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger}).onClick((()=>c(this,void 0,void 0,(function*(){if(this.validateForm(this.roleFormModal.ele)){const e=this.getFormData(this.roleFormModal.ele);"duplicate"===u(this,i,"f")?this.actions.duplicateRole(Object.assign({},e)):this.actions.createRole(Object.assign({},e)),this.roleFormModal.close(),this.resetFormData(this.roleFormModal.ele)}})))),h(this,n,new Qa((()=>{var e;return null===(e=this.roleFormModal.ele)||void 0===e?void 0:e.querySelector('[data-id="permissions-multiselect"]')}),{logger:this.logger}),"f"),u(this,s,"f").call(this),this.roleFormModal.beforeOpen=()=>c(this,void 0,void 0,(function*(){yield u(this,s,"f").call(this),u(this,o,"f")&&(this.setFormData(this.roleFormModal.ele,u(this,o,"f")),h(this,o,null,"f"))}))}))},a})),ng=Ti((e=>{var t,n,i;return i=class extends(Ei(Cs,tg,eg)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",n).call(this)}))}},t=new WeakSet,n=function(){var e;this.createButton=new ka(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="create-role"]'),{logger:this.logger}),this.createButton.onClick((()=>this.openRoleModal()))},i})),ig=Ti((e=>{var t,n,i;return i=class extends(Ei(Qv,ud,Cs,eg)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),yield u(this,t,"m",n).call(this)}))}},t=new WeakSet,n=function(){return c(this,void 0,void 0,(function*(){var e;this.deleteRolesModal=this.createModal(),this.deleteRolesModal.setContent(xi(yield this.fetchWidgetPage("delete-roles-modal.html")));const t=new ka((()=>{var e;return null===(e=this.deleteRolesModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger});t.onClick((()=>this.deleteRolesModal.close()));const n=new ka((()=>{var e;return null===(e=this.deleteRolesModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});n.onClick((()=>{const e=yv(this.state);this.actions.deleteRoles(null==e?void 0:e.map((e=>e.name))),this.deleteRolesModal.close()}));const i=new id(null===(e=this.deleteRolesModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.deleteRolesModal.beforeOpen=()=>{const e=kv(this.state);i.text=`Delete ${e}?`}}))},i})),og=Ti((e=>{var t,n,i,o;return o=class extends(Ei(Cs,eg,Qv,ig)(e)){constructor(){super(...arguments),t.add(this),i.set(this,Ai((e=>{e?this.deleteButton.enable():this.deleteButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),u(this,t,"m",n).call(this),this.subscribe(u(this,i,"f").bind(this),bv)}))}},i=new WeakMap,t=new WeakSet,n=function(){var e;this.deleteButton=new ka(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="delete-roles"]'),{logger:this.logger}),this.deleteButton.disable(),this.deleteButton.onClick((()=>{this.deleteRolesModal.open()}))},o})),rg=Ti((e=>{var t,n,i,o;return o=class extends(Ei(Cs,eg,Qv,tg)(e)){constructor(){super(...arguments),t.add(this),i.set(this,Ai((e=>{e?this.duplicateButton.enable():this.duplicateButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),u(this,t,"m",n).call(this),this.subscribe(u(this,i,"f").bind(this),wv)}))}},i=new WeakMap,t=new WeakSet,n=function(){var e;this.duplicateButton=new ka(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="duplicate-role"]'),{logger:this.logger}),this.duplicateButton.disable(),this.duplicateButton.onClick((()=>{var e,t,n;const i=null===(e=yv(this.state))||void 0===e?void 0:e[0];i&&this.openRoleModal("duplicate",{name:`${i.name} Copy`,description:null!==(t=i.description)&&void 0!==t?t:"",permissionNames:null!==(n=i.permissionNames)&&void 0!==n?n:[]})}))},o})),sg=Ti((e=>{var t,n,i,o,r,s,a,d;return d=class extends(Ei(Qv,ud,Cs,bc,eg)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),r.set(this,(()=>c(this,void 0,void 0,(function*(){var e;yield u(this,n,"f").setData(null===(e=gv(this.state))||void 0===e?void 0:e.map((({name:e})=>({value:e,label:e}))))})))),s.set(this,(()=>{var e;const t=null===(e=yv(this.state))||void 0===e?void 0:e[0],n={name:null==t?void 0:t.name,description:null==t?void 0:t.description,permissionNames:null==t?void 0:t.permissionNames};this.setFormData(this.editRoleModal.ele,n)}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),yield u(this,t,"m",a).call(this)}))}},n=new WeakMap,r=new WeakMap,s=new WeakMap,t=new WeakSet,i=function(){new ka((()=>{var e;return null===(e=this.editRoleModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger}).onClick((()=>this.editRoleModal.close()))},o=function(){new ka((()=>{var e;return null===(e=this.editRoleModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger}).onClick((()=>{var e;if(this.validateForm(this.editRoleModal.ele)){const t=this.getFormData(this.editRoleModal.ele),{name:n}=t,i=l(t,["name"]),o=null===(e=yv(this.state))||void 0===e?void 0:e[0];this.actions.updateRole(Object.assign({newName:n,name:o.name},i)),this.editRoleModal.close(),this.resetFormData(this.editRoleModal.ele)}}))},a=function(){return c(this,void 0,void 0,(function*(){this.editRoleModal=this.createModal(),this.editRoleModal.setContent(xi(yield this.fetchWidgetPage("edit-role-modal.html"))),u(this,t,"m",i).call(this),u(this,t,"m",o).call(this),h(this,n,new Qa((()=>{var e;return null===(e=this.editRoleModal.ele)||void 0===e?void 0:e.querySelector('[data-id="permissions-multiselect"]')}),{logger:this.logger}),"f"),this.editRoleModal.beforeOpen=()=>c(this,void 0,void 0,(function*(){yield u(this,r,"f").call(this),u(this,s,"f").call(this)}))}))},d})),ag=Ti((e=>{var t,n,i,o;return o=class extends(Ei(Cs,eg,Qv,sg,bc)(e)){constructor(){super(...arguments),t.add(this),i.set(this,Ai((e=>{e?this.editButton.enable():this.editButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),u(this,t,"m",n).call(this),this.subscribe(u(this,i,"f").bind(this),$v)}))}},i=new WeakMap,t=new WeakSet,n=function(){var e;this.editButton=new ka(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="edit-role"]'),{logger:this.logger}),this.editButton.disable(),this.editButton.onClick((()=>{this.editRoleModal.open()}))},o})),dg=Ti((e=>{var t,n,i,o;return o=class extends(Ei(Cs,eg,Qv)(e)){constructor(){super(...arguments),t.add(this),n.set(this,Mi((()=>{this.actions.searchRoles({text:this.searchInput.value})})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),u(this,t,"m",i).call(this)}))}},n=new WeakMap,t=new WeakSet,i=function(){var e;this.searchInput=new od(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="search-input"]'),{logger:this.logger}),this.searchInput.onInput(u(this,n,"f"))},o})),lg={success:(new DOMParser).parseFromString('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Checkmark">\n<path id="Shape" d="M10.0485 15.6396C9.5799 15.171 8.8201 15.171 8.35147 15.6396C7.88284 16.1082 7.88284 16.868 8.35147 17.3367L12.7072 21.6924C13.1759 22.1611 13.9357 22.1611 14.4043 21.6924L24.7152 11.3815C25.1838 10.9129 25.1838 10.1531 24.7152 9.68448C24.2466 9.21585 23.4868 9.21585 23.0181 9.68448L13.5558 19.1469L10.0485 15.6396Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,error:(new DOMParser).parseFromString('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Icon">\n<path id="Vector" d="M15.9998 26.6558C10.1118 26.6558 5.34375 21.8878 5.34375 15.9998C5.34375 10.1118 10.1118 5.34375 15.9998 5.34375C21.8878 5.34375 26.6558 10.1118 26.6558 15.9998C26.6558 21.8878 21.8878 26.6558 15.9998 26.6558ZM15.9998 24.4798C20.6718 24.4798 24.4798 20.7038 24.4798 15.9998C24.4798 11.3278 20.7038 7.51975 15.9998 7.51975C11.3278 7.51975 7.51975 11.2958 7.51975 15.9998C7.51975 20.6718 11.2958 24.4798 15.9998 24.4798ZM15.3278 9.34375H16.6718C17.0558 9.34375 17.3438 9.63175 17.3118 9.98375L16.9598 16.9278C16.9598 17.1838 16.7678 17.3438 16.5438 17.3438H15.4558C15.2318 17.3438 15.0398 17.1518 15.0398 16.9278L14.6878 9.98375C14.6878 9.63175 14.9758 9.34375 15.3278 9.34375ZM15.4558 19.4558H16.5438C16.9278 19.4558 17.2158 19.7438 17.1838 20.1278V21.1838C17.1838 21.5678 16.8958 21.8558 16.5438 21.8558H15.4558C15.0718 21.8558 14.7838 21.5678 14.7838 21.1838V20.1278C14.7838 19.7438 15.0718 19.4558 15.4558 19.4558Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild},cg=Ti((e=>{var t,n,i,o,r;return r=class extends(Ei(Cs,Qv,pd,Os)(e)){constructor(){super(...arguments),t.add(this),o.set(this,Ai((e=>{e.length&&(e.forEach((({type:e,msg:o})=>{const r=u(this,t,"m",i).call(this,e);r.setContent(u(this,t,"m",n).call(this,{type:e,msg:o})),r.show()})),setTimeout((()=>this.actions.clearNotifications())))})))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this),this.subscribe(u(this,o,"f").bind(this),vv)}))}},o=new WeakMap,t=new WeakSet,n=function({type:e,msg:t}){const n=lg[e],i=Object.assign((new DOMParser).parseFromString('<svg width="2em" height="2em" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Icon">\n<path id="Shape" d="M10.6712 12L7.27521 8.60406C6.90826 8.23711 6.90826 7.64216 7.27521 7.27521C7.64216 6.90826 8.23711 6.90826 8.60406 7.27521L12 10.6712L15.3959 7.27521C15.7629 6.90826 16.3578 6.90826 16.7248 7.27521C17.0917 7.64216 17.0917 8.23711 16.7248 8.60406L13.3288 12L16.7248 15.3959C17.0917 15.7629 17.0917 16.3578 16.7248 16.7248C16.3578 17.0917 15.7629 17.0917 15.3959 16.7248L12 13.3288L8.60406 16.7248C8.23711 17.0917 7.64216 17.0917 7.27521 16.7248C6.90826 16.3578 6.90826 15.7629 7.27521 15.3959L10.6712 12Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,{slot:"close"});return`${(null==n?void 0:n.outerHTML)||""}${t}${i.outerHTML}`},i=function(e){return this.createNotification({mode:e,duration:"error"===e?0:3e3,position:"bottom-start",size:"sm"})},r})),ug=Ti((e=>{var t,n,i,o,r;return r=class extends(Ei(Qv,Cs,eg)(e)){constructor(){super(...arguments),t.add(this),i.set(this,Ai((e=>{this.rolesTable.data=e}))),o.set(this,Mi(((e,t)=>{const n=[],{value:i}=t;if(i){const t=e.path;n.push({field:t,desc:"desc"===i})}this.actions.searchRoles({sort:n})})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var r;yield null===(r=e.onWidgetRootReady)||void 0===r?void 0:r.call(this),u(this,t,"m",n).call(this),this.rolesTable.columns.forEach((e=>{e.onSortDirectionChange((e=>{u(this,o,"f").call(this,e.target,e.detail)}))})),u(this,i,"f").call(this,mv(this.state)),this.subscribe(u(this,i,"f").bind(this),mv)}))}},i=new WeakMap,o=new WeakMap,t=new WeakSet,n=function(){var e;this.rolesTable=new Ea(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="roles-table"]'),{logger:this.logger}),this.rolesTable.onSelectedItemsChange((e=>{this.actions.setSelectedRolesIds(e.detail.value.map((({name:e})=>e)))}))},r})),hg=Ti((e=>class extends(Ei(fa,sa,ug,ng,og,rg,ag,dg,cg,Oc)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),fg=Ei((e=>class extends(hg(e)){}))(HTMLElement);customElements.define("descope-role-management-widget",fg);var pg=Object.freeze({__proto__:null,default:fg});const vg=e=>e.tenant.data,gg=e=>e.tenantAdminLinkSSO.data.defaultLink,mg={},yg=Al(vg,(e=>e.customAttributes||{})),bg=Al(vg,(e=>e.name||"")),wg=Al(vg,(e=>e.selfProvisioningDomains||[])),$g=Al(vg,(e=>e.enforceSSOExclusions||[])),kg=Al(vg,(e=>e.enforceSSO||!1)),Cg=Al(vg,gg,(e=>e.tenantAdminLinkSSO.data.ssoIdToLink),(e=>e.tenantAdminLinkSSO.data.ssoIdToAuthenticationOnly||mg),((e,t,n,i)=>[...e?[{id:"",name:"Default SSO Configuration",authType:e.authType,isDefault:!0,link:t,authOnly:i.default_ssoid||!1}]:[],...((null==e?void 0:e.additionalSSOConfigs)||[]).map((({ssoId:e,name:t,authType:o})=>({id:e,name:t,authType:o,link:n[e]||"",authOnly:i[e]||!1})))])),Sg=Al(vg,(e=>((null==e?void 0:e.additionalSSOConfigs)||[]).map((({ssoId:e})=>e))));function Ig(e){return new URLSearchParams(window.location.search).get(e)}const Rg=e=>(...t)=>n=>{n.addCase(e.pending,((e,n)=>{t.forEach((({onPending:t})=>{null==t||t(e,n)}))})),n.addCase(e.fulfilled,((e,n)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,n)}))})),n.addCase(e.rejected,((e,n)=>{t.forEach((({onRejected:t})=>{null==t||t(e,n)}))}))},Eg=e=>({onFulfilled:t=>{e(t).loading=!1},onPending:t=>{e(t).loading=!0,e(t).error=null},onRejected:(t,n)=>{e(t).loading=!1,e(t).error=n.error}}),xg=lc("users/me",((e,{extra:{api:t}})=>t.user.me())),Og=Rg(xg)({onFulfilled:(e,t)=>{e.me.data=t.payload}},Eg((e=>e.me))),Ag={action:xg,reducer:Og},Ng=lc("tenant/details",((e,{extra:{api:t}})=>t.tenant.details())),jg=Rg(Ng)({onFulfilled:(e,t)=>{e.tenant.data=t.payload}},Eg((e=>e.tenant))),Mg={action:Ng,reducer:jg},Pg=lc("tenant/adminLinkSso",(({ssoIds:e},{extra:{api:t}})=>t.tenant.adminLinkSso({ssoIds:e}))),Tg={action:Pg,reducer:Rg(Pg)({onFulfilled:(e,t)=>{var n;e.tenantAdminLinkSSO.data=null!==(n=t.payload)&&void 0!==n?n:{defaultLink:"",ssoIdToLink:{}}}},Eg((e=>e.tenantAdminLinkSSO)))},Wg={me:{loading:!1,error:null,data:{}},tenant:{loading:!1,error:null,data:{}},tenantAdminLinkSSO:{loading:!1,error:null,data:{defaultLink:"",ssoIdToLink:{}}}},Lg="/v1/auth/me",Ug="/v1/mgmt/tenant",Dg="/v1/mgmt/tenant/adminlinks/sso/authenticated/batch",Fg=e=>c(void 0,void 0,void 0,(function*(){const t=yield e.text(),n=JSON.parse(t);if(!e.ok){const t=`${n.errorDescription}${n.errorMessage?`: ${n.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(n),e.text=()=>Promise.resolve(t)})),_g=({httpClient:e,tenantId:t,mock:n})=>{const i=encodeURIComponent(t||""),o=`?tenant=${i}&id=${i}`;return{details:()=>c(void 0,void 0,void 0,(function*(){if(n)return c(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({tenantId:"tenant-1",roleNames:["admin"],id:"tenant-1",name:"Test Tenant",selfProvisioningDomains:["example1.com","example2.com"],customAttributes:{},authType:"password",domains:[],createdTime:Date.now(),disabled:!1,enforceSSO:!0})}))}));if(!t)throw new Error("tenantId is not defined");const i=`${Ug}${o}`,r=yield e.get(i);return yield Fg(r),yield r.json()})),adminLinkSso:o=>c(void 0,[o],void 0,(function*({ssoIds:o}){if(n)return c(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({defaultLink:"_blank",ssoIdToLink:{"okta-prod":"_blank?ssoId=okta-prod","entra-eu":"_blank?ssoId=entra-eu"}})}))}));if(!t)throw new Error("tenantId is not defined");const r=yield e.post(`${Dg}?tenant=${i}`,{tenantId:i,ssoIds:o},{headers:{"Content-Type":"application/json"}});return yield Fg(r),yield r.json()}))}},qg=({httpClient:e,mock:t})=>({me:()=>c(void 0,void 0,void 0,(function*(){if(t)return c(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({loginIds:["user@company.com"],externalIds:["user@company.com"],userId:"user-1",name:"Test User",email:"user@company.com",roleNames:["Role"],phone:"+1-202-555-010",verifiedEmail:!0,verifiedPhone:!0,userTenants:[],status:"enabled",editable:!0,createdTime:(new Date).getTime(),customAttributes:{},familyName:"",givenName:"",middleName:"",picture:void 0,password:!0,SAML:!1,test:!1,TOTP:!1,webauthn:!0})}))}));const n=yield e.get(Lg);return yield Fg(n),n.json()}))}),Bg=Ti((e=>{var t,n,i,o;const r=Ei(js,As,Cs,Ms,Sc)(e);return o=class extends r{constructor(){super(...arguments),t.add(this),n.set(this,void 0)}get widgetId(){return this.getAttribute("widget-id")}get tenantId(){return this.getAttribute("tenant")}get mock(){return this.getAttribute("mock")}get styleId(){return this.getAttribute("style-id")||Qs}get api(){return u(this,n,"f")||u(this,t,"m",i).call(this),u(this,n,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.init)||void 0===o?void 0:o.call(this),this.observeAttributes(["project-id","base-url","tenant","mock"],(()=>{u(this,n,"f")&&u(this,t,"m",i).call(this)}))}))}},n=new WeakMap,t=new WeakSet,i=function(){this.logger.debug("creating an sdk instance"),h(this,n,((e,t,n,i)=>{const o=yi(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"tenant-profile-widget","x-descope-widget-id":i,"x-descope-widget-version":"0.11.19"}}));return{user:qg({httpClient:o.httpClient,mock:n}),tenant:_g({httpClient:o.httpClient,tenantId:t,mock:n}),httpClient:o.httpClient}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},this.tenantId,"true"===this.mock,this.widgetId),"f")},o})),Vg=Ti((e=>{const t=Ei(yc({name:"widget",initialState:Wg,reducers:{},extraReducers:e=>{Ag.reducer(e),Mg.reducer(e),Tg.reducer(e)},asyncActions:{getMe:Ag.action,getTenant:Mg.action,getTenantAdminLinkSSO:Tg.action}}),Os,Cs,Bg)(e);return class extends t{constructor(...e){super(...e),this.state=Wg,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),Kg="widget-flow",Hg=Ti((e=>{var t,n,i;return i=class extends(Ei(kc,Os,hd,Vg,Sc,Cs,sa,Ic)(e)){constructor(){super(...arguments),t.add(this)}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.init)||void 0===i?void 0:i.call(this);const o=Ig(Kg);o&&(function(e){if(window.history.replaceState&&Ig(e)){const t=new URL(window.location.href),n=new URLSearchParams(t.search);n.delete(e),t.search=n.toString(),window.history.replaceState({},"",t.toString())}}(Kg),u(this,t,"m",n).call(this,o))}))}},t=new WeakSet,n=function(e){const t=this.createFlowModal({"data-id":"redirect-flow"});t.setContent(this.createFlowTemplate({flowId:e,tenant:this.tenantId})),new Ca((()=>{var e;return null===(e=t.ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}).onSuccess((()=>c(this,void 0,void 0,(function*(){t.close(),this.actions.getMe(),yield this.actions.getTenant();const e=Sg(this.state);yield this.actions.getTenantAdminLinkSSO({ssoIds:e})})))),t.afterClose=()=>{t.remove()},t.open()},i})),zg=Ti((e=>class extends(Ei(sa,As)(e)){syncFlowTheme(e){e.theme=this.theme,this.observeAttributes(["theme"],(()=>{e.theme=this.theme}))}})),Jg=Ti((e=>{var t,n,i;return i=class extends(Ei(Cs,Os,Hs,Xs,Cc("tenant-profile-widget"),Vg)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){return c(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.init)||void 0===i?void 0:i.call(this);try{yield Promise.all([this.actions.getMe(),this.actions.getTenant()]);const e=Sg(this.state);yield this.actions.getTenantAdminLinkSSO({ssoIds:e})}catch(i){}const o=this.state.me.error||(()=>this.state.tenant.error)()||(()=>this.state.tenantAdminLinkSSO.error)();if(o){this.contentRootElement.innerHTML="";const e="object"==typeof o&&null!==o&&"message"in o?o.message:String(o)||"An error occurred";this.contentRootElement.append(function({mainMessage:e="An error occurred"}){const t=document.createElement("div");t.setAttribute("data-id","widget-error"),t.style.display="flex",t.style.flexDirection="column",t.style.alignItems="center",t.style.justifyContent="center",t.style.padding="72px 36px",t.style.background="#fff",t.style.borderRadius="12px",t.style.boxShadow="0 2px 8px rgba(0,0,0,0.03)",t.style.margin="32px auto",t.style.maxWidth="400px";const n=document.createElement("div");n.innerHTML='\n <svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">\n <circle cx="20" cy="20" r="18" stroke="#FF3B3B" stroke-width="3" fill="#fff"/>\n <text x="20" y="27" text-anchor="middle" font-size="24" font-family="Arial, sans-serif" fill="#FF3B3B">!</text>\n </svg>\n ',n.style.marginBottom="12px",t.appendChild(n);const i=document.createElement("div");return i.textContent=e,i.style.fontWeight="bold",i.style.fontSize="20px",i.style.color="#222",i.style.textAlign="center",i.style.marginTop="8px",t.appendChild(i),t}({mainMessage:e}))}else yield u(this,t,"m",n).call(this),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,n=function(){return c(this,void 0,void 0,(function*(){const e=xi(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},i})),Gg=Ti((e=>{var t,n,i,o,r,s,a,d,l,f,p,v;return v=class extends(Ei(zg,Vg,hd,Cs,Jg,Ic)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),i.set(this,void 0),o.set(this,void 0),r.set(this,void 0),s.set(this,void 0)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),h(this,n,new cd((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-multi-sso")}),{logger:this.logger}),"f"),u(this,n,"f").isExists&&(u(this,t,"m",p).call(this),u(this,n,"f").data=Cg(this.state),this.subscribe((e=>{u(this,n,"f").data=e}),Cg))}))}},n=new WeakMap,i=new WeakMap,o=new WeakMap,r=new WeakMap,s=new WeakMap,t=new WeakSet,a=function(){h(this,i,this.createFlowModal({"data-id":"multi-sso-create-modal"}),"f"),h(this,o,new Ca((()=>{var e;return null===(e=u(this,i,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(u(this,o,"f"))},d=function(){h(this,r,this.createFlowModal({"data-id":"multi-sso-delete-modal"}),"f"),h(this,s,new Ca((()=>{var e;return null===(e=u(this,r,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(u(this,s,"f"))},l=function(e){u(this,i,"f").setContent(this.createFlowTemplate({flowId:e,tenant:this.tenantId})),u(this,i,"f").open(),u(this,o,"f").onSuccess((()=>c(this,void 0,void 0,(function*(){u(this,i,"f").close(),yield this.actions.getTenant();const e=Sg(this.state);yield this.actions.getTenantAdminLinkSSO({ssoIds:e})}))))},f=function(e,t){u(this,r,"f").setContent(this.createFlowTemplate({flowId:e,tenant:this.tenantId,form:{deleteSSOConfigurationId:t}})),u(this,r,"f").open(),u(this,s,"f").onSuccess((()=>{u(this,r,"f").close(),this.actions.getTenant()}))},p=function(){const{createFlowId:e,deleteFlowId:i}=u(this,n,"f");i&&(u(this,t,"m",d).call(this),u(this,n,"f").onDeleteClicked((({id:e})=>u(this,t,"m",f).call(this,i,e)))),e&&(u(this,t,"m",a).call(this),u(this,n,"f").onCreateClicked((()=>u(this,t,"m",l).call(this,e))))},v})),Zg=Ti((e=>{var t,n,i,o;return o=class extends(Ei(zg,Vg,Cs,Jg,Sc,ud)(e)){constructor(){super(...arguments),t.add(this),i.set(this,Ai((e=>{this.tenantAdminLinkSSODriver.href=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),u(this,t,"m",n).call(this),u(this,i,"f").call(this,gg(this.state)),this.subscribe(u(this,i,"f").bind(this),gg)}))}},i=new WeakMap,t=new WeakSet,n=function(){this.tenantAdminLinkSSODriver=new xa((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-link[data-id="tenant-admin-link-sso"]')}),{logger:this.logger})},o}));var Yg;!function(e){e.TEXT="text",e.NUMBER="number",e.BOOLEAN="boolean",e.SINGLE_SELECT="singleSelect",e.ARRAY="array",e.DATE="date"}(Yg||(Yg={}));const Xg=Ti((e=>{var t,n,i,o,r,s,a,d,l,h,f;return f=class extends(Ei(kc,zg,Vg,Cs,Jg,Sc,hd,Ic)(e)){constructor(){super(...arguments),t.add(this),n.set(this,{}),i.set(this,{}),o.set(this,{}),r.set(this,{}),d.set(this,Ai((e=>{var n;const i=null===(n=this.shadowRoot)||void 0===n?void 0:n.querySelectorAll('descope-user-attribute[data-id^="customAttributes."]');Array.from(i).forEach((n=>{const i=n.getAttribute("data-id").replace("customAttributes.",""),o=n.getAttribute("data-type")||Yg.TEXT,r=e[i],s=new rd(n,{logger:this.logger});s.value=((e,t)=>e===Yg.DATE&&t?new Date(t).toLocaleString():e===Yg.BOOLEAN&&void 0!==t?t?"True":"False":(t||"").toString())(o,r),u(this,t,"m",l).call(this,n,i,s,o,i),u(this,t,"m",h).call(this,n,i,s)}))})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.onWidgetRootReady)||void 0===t?void 0:t.call(this),u(this,d,"f").call(this,yg(this.state)),this.subscribe(u(this,d,"f").bind(this),yg)}))}},n=new WeakMap,i=new WeakMap,o=new WeakMap,r=new WeakMap,d=new WeakMap,t=new WeakSet,s=function(e,t,o){var r,s;const a=yg(this.state)[o],d=t===Yg.ARRAY?(a||[]).join(","):a;null===(r=u(this,n,"f")[e])||void 0===r||r.setContent(this.createFlowTemplate({flowId:e,tenant:this.tenantId,form:{customAttributes:{[o]:d}}})),null===(s=u(this,i,"f")[e])||void 0===s||s.onSuccess((()=>{var t;null===(t=u(this,n,"f")[e])||void 0===t||t.close(),this.actions.getTenant()}))},a=function(e){var t,n;null===(t=u(this,o,"f")[e])||void 0===t||t.setContent(this.createFlowTemplate({flowId:e,tenant:this.tenantId})),null===(n=u(this,r,"f")[e])||void 0===n||n.onSuccess((()=>{var t;null===(t=u(this,o,"f")[e])||void 0===t||t.close(),this.actions.getTenant()}))},l=function(e,o,r,a,d){const l=e.getAttribute("edit-flow-id");l&&(u(this,n,"f")[l]||(u(this,n,"f")[l]=this.createFlowModal({"data-id":`edit-${o}`}),u(this,i,"f")[l]=new Ca((()=>{var e,t;return null===(t=null===(e=u(this,n,"f")[l])||void 0===e?void 0:e.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),u(this,n,"f")[l].beforeOpen=u(this,t,"m",s).bind(this,l,a,d),r.onEditClick((()=>{var e,t;null===(t=null===(e=u(this,n,"f"))||void 0===e?void 0:e[l])||void 0===t||t.open()})),this.syncFlowTheme(u(this,i,"f")[l])))},h=function(e,n,i){const s=e.getAttribute("delete-flow-id");s&&(u(this,o,"f")[s]||(u(this,o,"f")[s]=this.createFlowModal({"data-id":`delete-${n}`}),u(this,r,"f")[s]=new Ca((()=>{var e,t;return null===(t=null===(e=u(this,o,"f")[s])||void 0===e?void 0:e.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),u(this,o,"f")[s].beforeOpen=u(this,t,"m",a).bind(this,s),i.onDeleteClick((()=>{var e,t;null===(t=null===(e=u(this,o,"f"))||void 0===e?void 0:e[s])||void 0===t||t.open()})),this.syncFlowTheme(u(this,r,"f")[s])))},f})),Qg=Ti((e=>{var t,n,i,o,r,s,a,d,l,f,p,v;return v=class extends(Ei(kc,zg,Vg,Cs,Jg,Sc,hd,Ic)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),i.set(this,void 0),o.set(this,void 0),r.set(this,void 0),p.set(this,Ai((e=>{this.tenantEmailDomainsDriver.value=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),u(this,t,"m",f).call(this),u(this,t,"m",s).call(this),u(this,t,"m",d).call(this),u(this,p,"f").call(this,wg(this.state)),this.subscribe(u(this,p,"f").bind(this),wg)}))}},n=new WeakMap,i=new WeakMap,o=new WeakMap,r=new WeakMap,p=new WeakMap,t=new WeakSet,s=function(){this.tenantEmailDomainsDriver.editFlowId&&(h(this,n,this.createFlowModal({"data-id":"edit-tenant-email-domains"}),"f"),h(this,i,new Ca((()=>{var e;return null===(e=u(this,n,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,n,"f").beforeOpen=u(this,t,"m",a).bind(this),u(this,t,"m",a).call(this),this.syncFlowTheme(u(this,i,"f")))},a=function(){u(this,n,"f").setContent(this.createFlowTemplate({flowId:this.tenantEmailDomainsDriver.editFlowId,tenant:this.tenantId,form:{tenantEmailDomains:wg(this.state)}})),u(this,i,"f").onSuccess((()=>{u(this,n,"f").close(),this.actions.getTenant()}))},d=function(){this.tenantEmailDomainsDriver.deleteFlowId&&(h(this,o,this.createFlowModal({"data-id":"delete-tenant-email-domains"}),"f"),h(this,r,new Ca((()=>{var e;return null===(e=u(this,o,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,o,"f").beforeOpen=u(this,t,"m",l).bind(this),u(this,t,"m",l).call(this),this.syncFlowTheme(u(this,r,"f")))},l=function(){u(this,o,"f").setContent(this.createFlowTemplate({flowId:this.tenantEmailDomainsDriver.deleteFlowId,tenant:this.tenantId})),u(this,r,"f").onSuccess((()=>{u(this,o,"f").close(),this.actions.getTenant()}))},f=function(){this.tenantEmailDomainsDriver=new rd((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="tenant-email-domains-edit"]')}),{logger:this.logger}),this.tenantEmailDomainsDriver.onEditClick((()=>{var e;null===(e=u(this,n,"f"))||void 0===e||e.open()})),this.tenantEmailDomainsDriver.onDeleteClick((()=>{var e;null===(e=u(this,o,"f"))||void 0===e||e.open()}))},v})),em=Ti((e=>{var t,n,i,o,r,s,a,d,l,f,p,v;return v=class extends(Ei(kc,zg,Vg,Cs,Jg,Sc,hd,Ic)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),i.set(this,void 0),o.set(this,void 0),r.set(this,void 0),p.set(this,Ai((e=>{this.tenantSSOExclusionsDriver.value=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),u(this,t,"m",f).call(this),u(this,t,"m",s).call(this),u(this,t,"m",d).call(this),u(this,p,"f").call(this,$g(this.state)),this.subscribe(u(this,p,"f").bind(this),$g)}))}},n=new WeakMap,i=new WeakMap,o=new WeakMap,r=new WeakMap,p=new WeakMap,t=new WeakSet,s=function(){this.tenantSSOExclusionsDriver.editFlowId&&(h(this,n,this.createFlowModal({"data-id":"edit-tenant-sso-exclusions"}),"f"),h(this,i,new Ca((()=>{var e;return null===(e=u(this,n,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,n,"f").beforeOpen=u(this,t,"m",a).bind(this),u(this,t,"m",a).call(this),this.syncFlowTheme(u(this,i,"f")))},a=function(){u(this,n,"f").setContent(this.createFlowTemplate({flowId:this.tenantSSOExclusionsDriver.editFlowId,tenant:this.tenantId,form:{enforceSSOExclusions:$g(this.state)}})),u(this,i,"f").onSuccess((()=>{u(this,n,"f").close(),this.actions.getTenant()}))},d=function(){this.tenantSSOExclusionsDriver.deleteFlowId&&(h(this,o,this.createFlowModal({"data-id":"delete-tenant-sso-exclusions"}),"f"),h(this,r,new Ca((()=>{var e;return null===(e=u(this,o,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,o,"f").beforeOpen=u(this,t,"m",l).bind(this),u(this,t,"m",l).call(this),this.syncFlowTheme(u(this,r,"f")))},l=function(){u(this,o,"f").setContent(this.createFlowTemplate({flowId:this.tenantSSOExclusionsDriver.deleteFlowId,tenant:this.tenantId})),u(this,r,"f").onSuccess((()=>{u(this,o,"f").close(),this.actions.getTenant()}))},f=function(){this.tenantSSOExclusionsDriver=new rd((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="tenant-force-sso-exclusions-edit"]')}),{logger:this.logger}),this.tenantSSOExclusionsDriver.onEditClick((()=>{var e;null===(e=u(this,n,"f"))||void 0===e||e.open()})),this.tenantSSOExclusionsDriver.onDeleteClick((()=>{var e;null===(e=u(this,o,"f"))||void 0===e||e.open()}))},v})),tm=Ti((e=>{var t,n,i,o,r,s,a,d,l,f,p,v;return v=class extends(Ei(kc,zg,Vg,Cs,Jg,Sc,hd,Ic)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),i.set(this,void 0),o.set(this,void 0),r.set(this,void 0),p.set(this,Ai((e=>{this.tenantEnforceSSODriver.value=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),u(this,t,"m",f).call(this),u(this,t,"m",s).call(this),u(this,t,"m",d).call(this),u(this,p,"f").call(this,kg(this.state)),this.subscribe(u(this,p,"f").bind(this),kg)}))}},n=new WeakMap,i=new WeakMap,o=new WeakMap,r=new WeakMap,p=new WeakMap,t=new WeakSet,s=function(){this.tenantEnforceSSODriver.editFlowId&&(h(this,n,this.createFlowModal({"data-id":"edit-tenant-enforce-sso"}),"f"),h(this,i,new Ca((()=>{var e;return null===(e=u(this,n,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,n,"f").beforeOpen=u(this,t,"m",a).bind(this),u(this,t,"m",a).call(this),this.syncFlowTheme(u(this,i,"f")))},a=function(){u(this,n,"f").setContent(this.createFlowTemplate({flowId:this.tenantEnforceSSODriver.editFlowId,tenant:this.tenantId,form:{enforceSSO:kg(this.state)}})),u(this,i,"f").onSuccess((()=>{u(this,n,"f").close(),this.actions.getTenant()}))},d=function(){this.tenantEnforceSSODriver.deleteFlowId&&(h(this,o,this.createFlowModal({"data-id":"delete-tenant-enforce-sso"}),"f"),h(this,r,new Ca((()=>{var e;return null===(e=u(this,o,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,o,"f").beforeOpen=u(this,t,"m",l).bind(this),u(this,t,"m",l).call(this),this.syncFlowTheme(u(this,r,"f")))},l=function(){u(this,o,"f").setContent(this.createFlowTemplate({flowId:this.tenantEnforceSSODriver.deleteFlowId,tenant:this.tenantId})),u(this,r,"f").onSuccess((()=>{u(this,o,"f").close(),this.actions.getTenant()}))},f=function(){this.tenantEnforceSSODriver=new rd((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="tenant-enforce-sso-edit"]')}),{logger:this.logger}),this.tenantEnforceSSODriver.onEditClick((()=>{var e;null===(e=u(this,n,"f"))||void 0===e||e.open()})),this.tenantEnforceSSODriver.onDeleteClick((()=>{var e;null===(e=u(this,o,"f"))||void 0===e||e.open()}))},v})),nm=Ti((e=>{var t,n,i,o,r,s,a,d;return d=class extends(Ei(kc,zg,Vg,Cs,Jg,Sc,hd,Ic)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),i.set(this,void 0),a.set(this,Ai((e=>{this.tenantNameDriver.value=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),u(this,t,"m",s).call(this),u(this,t,"m",o).call(this),u(this,a,"f").call(this,bg(this.state)),this.subscribe(u(this,a,"f").bind(this),bg)}))}},n=new WeakMap,i=new WeakMap,a=new WeakMap,t=new WeakSet,o=function(){this.tenantNameDriver.editFlowId&&(h(this,n,this.createFlowModal({"data-id":"tenant-profile-set-name"}),"f"),h(this,i,new Ca((()=>{var e;return null===(e=u(this,n,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,n,"f").beforeOpen=u(this,t,"m",r).bind(this),u(this,t,"m",r).call(this),this.syncFlowTheme(u(this,i,"f")))},r=function(){u(this,n,"f").setContent(this.createFlowTemplate({flowId:this.tenantNameDriver.editFlowId,tenant:this.tenantId,form:{tenantName:bg(this.state)}})),u(this,i,"f").onSuccess((()=>{u(this,n,"f").close(),this.actions.getTenant()}))},s=function(){this.tenantNameDriver=new rd((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="tenant-name-edit"]')}),{logger:this.logger}),this.tenantNameDriver.onEditClick((()=>{var e;null===(e=u(this,n,"f"))||void 0===e||e.open()}))},d})),im=Ti((e=>{var t,n,i,o,r,s,a;return a=class extends(Ei(kc,zg,Vg,Cs,Jg,Sc,hd,Ic)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),i.set(this,void 0)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),u(this,t,"m",s).call(this),u(this,t,"m",o).call(this)}))}},n=new WeakMap,i=new WeakMap,t=new WeakSet,o=function(){this.TenantPasswordPolicyUserAuthMethodDriver.flowId&&(h(this,n,this.createFlowModal({"data-id":"password-policy"}),"f"),h(this,i,new Ca((()=>{var e;return null===(e=u(this,n,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,n,"f").afterClose=u(this,t,"m",r).bind(this),u(this,t,"m",r).call(this),this.syncFlowTheme(u(this,i,"f")))},r=function(){u(this,n,"f").setContent(this.createFlowTemplate({flowId:this.TenantPasswordPolicyUserAuthMethodDriver.flowId,tenant:this.tenantId})),u(this,i,"f").onSuccess((()=>{u(this,n,"f").close(),this.actions.getTenant()}))},s=function(){this.TenantPasswordPolicyUserAuthMethodDriver=new sd((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="password-policy"]')}),{logger:this.logger}),this.TenantPasswordPolicyUserAuthMethodDriver.onUnfulfilledButtonClick((()=>{var e;null===(e=u(this,n,"f"))||void 0===e||e.open()}))},a})),om=Ti((e=>{var t,n,i,o,r,s,a;return a=class extends(Ei(kc,zg,Vg,Cs,Jg,Sc,hd,Ic)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),i.set(this,void 0)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),u(this,t,"m",s).call(this),u(this,t,"m",o).call(this)}))}},n=new WeakMap,i=new WeakMap,t=new WeakSet,o=function(){this.TenantSessionSettingsUserAuthMethodDriver.flowId&&(h(this,n,this.createFlowModal({"data-id":"session-settings"}),"f"),h(this,i,new Ca((()=>{var e;return null===(e=u(this,n,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,n,"f").afterClose=u(this,t,"m",r).bind(this),u(this,t,"m",r).call(this),this.syncFlowTheme(u(this,i,"f")))},r=function(){u(this,n,"f").setContent(this.createFlowTemplate({flowId:this.TenantSessionSettingsUserAuthMethodDriver.flowId,tenant:this.tenantId})),u(this,i,"f").onSuccess((()=>{u(this,n,"f").close(),this.actions.getTenant()}))},s=function(){this.TenantSessionSettingsUserAuthMethodDriver=new sd((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="session-settings"]')}),{logger:this.logger}),this.TenantSessionSettingsUserAuthMethodDriver.onUnfulfilledButtonClick((()=>{var e;null===(e=u(this,n,"f"))||void 0===e||e.open()}))},a})),rm=Ti((e=>class extends(Ei(fa,sa,Hg,Jg,nm,Qg,em,tm,Xg,Zg,im,om,Gg,Oc)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),sm=Ei((e=>class extends(rm(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this),(customElements.get("descope-wc")||(yield Promise.resolve().then((function(){return Mh})).then((e=>e.default)))).sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"tenant-profile-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.11.19"}}}))}}))(HTMLElement);customElements.define("descope-tenant-profile-widget",sm);var am=Object.freeze({__proto__:null,default:sm}),dm={version:4,country_calling_codes:{1:["US","AG","AI","AS","BB","BM","BS","CA","DM","DO","GD","GU","JM","KN","KY","LC","MP","MS","PR","SX","TC","TT","VC","VG","VI"],7:["RU","KZ"],20:["EG"],27:["ZA"],30:["GR"],31:["NL"],32:["BE"],33:["FR"],34:["ES"],36:["HU"],39:["IT","VA"],40:["RO"],41:["CH"],43:["AT"],44:["GB","GG","IM","JE"],45:["DK"],46:["SE"],47:["NO","SJ"],48:["PL"],49:["DE"],51:["PE"],52:["MX"],53:["CU"],54:["AR"],55:["BR"],56:["CL"],57:["CO"],58:["VE"],60:["MY"],61:["AU","CC","CX"],62:["ID"],63:["PH"],64:["NZ"],65:["SG"],66:["TH"],81:["JP"],82:["KR"],84:["VN"],86:["CN"],90:["TR"],91:["IN"],92:["PK"],93:["AF"],94:["LK"],95:["MM"],98:["IR"],211:["SS"],212:["MA","EH"],213:["DZ"],216:["TN"],218:["LY"],220:["GM"],221:["SN"],222:["MR"],223:["ML"],224:["GN"],225:["CI"],226:["BF"],227:["NE"],228:["TG"],229:["BJ"],230:["MU"],231:["LR"],232:["SL"],233:["GH"],234:["NG"],235:["TD"],236:["CF"],237:["CM"],238:["CV"],239:["ST"],240:["GQ"],241:["GA"],242:["CG"],243:["CD"],244:["AO"],245:["GW"],246:["IO"],247:["AC"],248:["SC"],249:["SD"],250:["RW"],251:["ET"],252:["SO"],253:["DJ"],254:["KE"],255:["TZ"],256:["UG"],257:["BI"],258:["MZ"],260:["ZM"],261:["MG"],262:["RE","YT"],263:["ZW"],264:["NA"],265:["MW"],266:["LS"],267:["BW"],268:["SZ"],269:["KM"],290:["SH","TA"],291:["ER"],297:["AW"],298:["FO"],299:["GL"],350:["GI"],351:["PT"],352:["LU"],353:["IE"],354:["IS"],355:["AL"],356:["MT"],357:["CY"],358:["FI","AX"],359:["BG"],370:["LT"],371:["LV"],372:["EE"],373:["MD"],374:["AM"],375:["BY"],376:["AD"],377:["MC"],378:["SM"],380:["UA"],381:["RS"],382:["ME"],383:["XK"],385:["HR"],386:["SI"],387:["BA"],389:["MK"],420:["CZ"],421:["SK"],423:["LI"],500:["FK"],501:["BZ"],502:["GT"],503:["SV"],504:["HN"],505:["NI"],506:["CR"],507:["PA"],508:["PM"],509:["HT"],590:["GP","BL","MF"],591:["BO"],592:["GY"],593:["EC"],594:["GF"],595:["PY"],596:["MQ"],597:["SR"],598:["UY"],599:["CW","BQ"],670:["TL"],672:["NF"],673:["BN"],674:["NR"],675:["PG"],676:["TO"],677:["SB"],678:["VU"],679:["FJ"],680:["PW"],681:["WF"],682:["CK"],683:["NU"],685:["WS"],686:["KI"],687:["NC"],688:["TV"],689:["PF"],690:["TK"],691:["FM"],692:["MH"],850:["KP"],852:["HK"],853:["MO"],855:["KH"],856:["LA"],880:["BD"],886:["TW"],960:["MV"],961:["LB"],962:["JO"],963:["SY"],964:["IQ"],965:["KW"],966:["SA"],967:["YE"],968:["OM"],970:["PS"],971:["AE"],972:["IL"],973:["BH"],974:["QA"],975:["BT"],976:["MN"],977:["NP"],992:["TJ"],993:["TM"],994:["AZ"],995:["GE"],996:["KG"],998:["UZ"]},countries:{AC:["247","00","(?:[01589]\\d|[46])\\d{4}",[5,6]],AD:["376","00","(?:1|6\\d)\\d{7}|[135-9]\\d{5}",[6,8,9],[["(\\d{3})(\\d{3})","$1 $2",["[135-9]"]],["(\\d{4})(\\d{4})","$1 $2",["1"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["6"]]]],AE:["971","00","(?:[4-7]\\d|9[0-689])\\d{7}|800\\d{2,9}|[2-4679]\\d{7}",[5,6,7,8,9,10,11,12],[["(\\d{3})(\\d{2,9})","$1 $2",["60|8"]],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[236]|[479][2-8]"],"0$1"],["(\\d{3})(\\d)(\\d{5})","$1 $2 $3",["[479]"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["5"],"0$1"]],"0"],AF:["93","00","[2-7]\\d{8}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[2-7]"],"0$1"]],"0"],AG:["1","011","(?:268|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([457]\\d{6})$|1","268$1",0,"268"],AI:["1","011","(?:264|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2457]\\d{6})$|1","264$1",0,"264"],AL:["355","00","(?:700\\d\\d|900)\\d{3}|8\\d{5,7}|(?:[2-5]|6\\d)\\d{7}",[6,7,8,9],[["(\\d{3})(\\d{3,4})","$1 $2",["80|9"],"0$1"],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["4[2-6]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[2358][2-5]|4"],"0$1"],["(\\d{3})(\\d{5})","$1 $2",["[23578]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["6"],"0$1"]],"0"],AM:["374","00","(?:[1-489]\\d|55|60|77)\\d{6}",[8],[["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["[89]0"],"0 $1"],["(\\d{3})(\\d{5})","$1 $2",["2|3[12]"],"(0$1)"],["(\\d{2})(\\d{6})","$1 $2",["1|47"],"(0$1)"],["(\\d{2})(\\d{6})","$1 $2",["[3-9]"],"0$1"]],"0"],AO:["244","00","[29]\\d{8}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[29]"]]]],AR:["54","00","(?:11|[89]\\d\\d)\\d{8}|[2368]\\d{9}",[10,11],[["(\\d{4})(\\d{2})(\\d{4})","$1 $2-$3",["2(?:2[024-9]|3[0-59]|47|6[245]|9[02-8])|3(?:3[28]|4[03-9]|5[2-46-8]|7[1-578]|8[2-9])","2(?:[23]02|6(?:[25]|4[6-8])|9(?:[02356]|4[02568]|72|8[23]))|3(?:3[28]|4(?:[04679]|3[5-8]|5[4-68]|8[2379])|5(?:[2467]|3[237]|8[2-5])|7[1-578]|8(?:[2469]|3[2578]|5[4-8]|7[36-8]|8[5-8]))|2(?:2[24-9]|3[1-59]|47)","2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3[78]|5(?:4[46]|8)|8[2379])|5(?:[2467]|3[237]|8[23])|7[1-578]|8(?:[2469]|3[278]|5[56][46]|86[3-6]))|2(?:2[24-9]|3[1-59]|47)|38(?:[58][78]|7[378])|3(?:4[35][56]|58[45]|8(?:[38]5|54|76))[4-6]","2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3(?:5(?:4[0-25689]|[56])|[78])|58|8[2379])|5(?:[2467]|3[237]|8(?:[23]|4(?:[45]|60)|5(?:4[0-39]|5|64)))|7[1-578]|8(?:[2469]|3[278]|54(?:4|5[13-7]|6[89])|86[3-6]))|2(?:2[24-9]|3[1-59]|47)|38(?:[58][78]|7[378])|3(?:454|85[56])[46]|3(?:4(?:36|5[56])|8(?:[38]5|76))[4-6]"],"0$1",1],["(\\d{2})(\\d{4})(\\d{4})","$1 $2-$3",["1"],"0$1",1],["(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["[68]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2-$3",["[23]"],"0$1",1],["(\\d)(\\d{4})(\\d{2})(\\d{4})","$2 15-$3-$4",["9(?:2[2-469]|3[3-578])","9(?:2(?:2[024-9]|3[0-59]|47|6[245]|9[02-8])|3(?:3[28]|4[03-9]|5[2-46-8]|7[1-578]|8[2-9]))","9(?:2(?:[23]02|6(?:[25]|4[6-8])|9(?:[02356]|4[02568]|72|8[23]))|3(?:3[28]|4(?:[04679]|3[5-8]|5[4-68]|8[2379])|5(?:[2467]|3[237]|8[2-5])|7[1-578]|8(?:[2469]|3[2578]|5[4-8]|7[36-8]|8[5-8])))|92(?:2[24-9]|3[1-59]|47)","9(?:2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3[78]|5(?:4[46]|8)|8[2379])|5(?:[2467]|3[237]|8[23])|7[1-578]|8(?:[2469]|3[278]|5(?:[56][46]|[78])|7[378]|8(?:6[3-6]|[78]))))|92(?:2[24-9]|3[1-59]|47)|93(?:4[35][56]|58[45]|8(?:[38]5|54|76))[4-6]","9(?:2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3(?:5(?:4[0-25689]|[56])|[78])|5(?:4[46]|8)|8[2379])|5(?:[2467]|3[237]|8(?:[23]|4(?:[45]|60)|5(?:4[0-39]|5|64)))|7[1-578]|8(?:[2469]|3[278]|5(?:4(?:4|5[13-7]|6[89])|[56][46]|[78])|7[378]|8(?:6[3-6]|[78]))))|92(?:2[24-9]|3[1-59]|47)|93(?:4(?:36|5[56])|8(?:[38]5|76))[4-6]"],"0$1",0,"$1 $2 $3-$4"],["(\\d)(\\d{2})(\\d{4})(\\d{4})","$2 15-$3-$4",["91"],"0$1",0,"$1 $2 $3-$4"],["(\\d{3})(\\d{3})(\\d{5})","$1-$2-$3",["8"],"0$1"],["(\\d)(\\d{3})(\\d{3})(\\d{4})","$2 15-$3-$4",["9"],"0$1",0,"$1 $2 $3-$4"]],"0",0,"0?(?:(11|2(?:2(?:02?|[13]|2[13-79]|4[1-6]|5[2457]|6[124-8]|7[1-4]|8[13-6]|9[1267])|3(?:02?|1[467]|2[03-6]|3[13-8]|[49][2-6]|5[2-8]|[67])|4(?:7[3-578]|9)|6(?:[0136]|2[24-6]|4[6-8]?|5[15-8])|80|9(?:0[1-3]|[19]|2\\d|3[1-6]|4[02568]?|5[2-4]|6[2-46]|72?|8[23]?))|3(?:3(?:2[79]|6|8[2578])|4(?:0[0-24-9]|[12]|3[5-8]?|4[24-7]|5[4-68]?|6[02-9]|7[126]|8[2379]?|9[1-36-8])|5(?:1|2[1245]|3[237]?|4[1-46-9]|6[2-4]|7[1-6]|8[2-5]?)|6[24]|7(?:[069]|1[1568]|2[15]|3[145]|4[13]|5[14-8]|7[2-57]|8[126])|8(?:[01]|2[15-7]|3[2578]?|4[13-6]|5[4-8]?|6[1-357-9]|7[36-8]?|8[5-8]?|9[124])))15)?","9$1"],AS:["1","011","(?:[58]\\d\\d|684|900)\\d{7}",[10],0,"1",0,"([267]\\d{6})$|1","684$1",0,"684"],AT:["43","00","1\\d{3,12}|2\\d{6,12}|43(?:(?:0\\d|5[02-9])\\d{3,9}|2\\d{4,5}|[3467]\\d{4}|8\\d{4,6}|9\\d{4,7})|5\\d{4,12}|8\\d{7,12}|9\\d{8,12}|(?:[367]\\d|4[0-24-9])\\d{4,11}",[4,5,6,7,8,9,10,11,12,13],[["(\\d)(\\d{3,12})","$1 $2",["1(?:11|[2-9])"],"0$1"],["(\\d{3})(\\d{2})","$1 $2",["517"],"0$1"],["(\\d{2})(\\d{3,5})","$1 $2",["5[079]"],"0$1"],["(\\d{3})(\\d{3,10})","$1 $2",["(?:31|4)6|51|6(?:5[0-3579]|[6-9])|7(?:20|32|8)|[89]"],"0$1"],["(\\d{4})(\\d{3,9})","$1 $2",["[2-467]|5[2-6]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["5"],"0$1"],["(\\d{2})(\\d{4})(\\d{4,7})","$1 $2 $3",["5"],"0$1"]],"0"],AU:["61","001[14-689]|14(?:1[14]|34|4[17]|[56]6|7[47]|88)0011","1(?:[0-79]\\d{7}(?:\\d(?:\\d{2})?)?|8[0-24-9]\\d{7})|[2-478]\\d{8}|1\\d{4,7}",[5,6,7,8,9,10,12],[["(\\d{2})(\\d{3,4})","$1 $2",["16"],"0$1"],["(\\d{2})(\\d{3})(\\d{2,4})","$1 $2 $3",["16"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["14|4"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["[2378]"],"(0$1)"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1(?:30|[89])"]]],"0",0,"(183[12])|0",0,0,0,[["(?:(?:(?:2(?:[0-26-9]\\d|3[0-8]|4[02-9]|5[0135-9])|7(?:[013-57-9]\\d|2[0-8]))\\d|3(?:(?:[0-3589]\\d|6[1-9]|7[0-35-9])\\d|4(?:[0-578]\\d|90)))\\d\\d|8(?:51(?:0(?:0[03-9]|[12479]\\d|3[2-9]|5[0-8]|6[1-9]|8[0-7])|1(?:[0235689]\\d|1[0-69]|4[0-589]|7[0-47-9])|2(?:0[0-79]|[18][13579]|2[14-9]|3[0-46-9]|[4-6]\\d|7[89]|9[0-4])|3\\d\\d)|(?:6[0-8]|[78]\\d)\\d{3}|9(?:[02-9]\\d{3}|1(?:(?:[0-58]\\d|6[0135-9])\\d|7(?:0[0-24-9]|[1-9]\\d)|9(?:[0-46-9]\\d|5[0-79])))))\\d{3}",[9]],["4(?:79[01]|83[0-389]|94[0-4])\\d{5}|4(?:[0-36]\\d|4[047-9]|5[0-25-9]|7[02-8]|8[0-24-9]|9[0-37-9])\\d{6}",[9]],["180(?:0\\d{3}|2)\\d{3}",[7,10]],["190[0-26]\\d{6}",[10]],0,0,0,["163\\d{2,6}",[5,6,7,8,9]],["14(?:5(?:1[0458]|[23][458])|71\\d)\\d{4}",[9]],["13(?:00\\d{6}(?:\\d{2})?|45[0-4]\\d{3})|13\\d{4}",[6,8,10,12]]],"0011"],AW:["297","00","(?:[25-79]\\d\\d|800)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[25-9]"]]]],AX:["358","00|99(?:[01469]|5(?:[14]1|3[23]|5[59]|77|88|9[09]))","2\\d{4,9}|35\\d{4,5}|(?:60\\d\\d|800)\\d{4,6}|7\\d{5,11}|(?:[14]\\d|3[0-46-9]|50)\\d{4,8}",[5,6,7,8,9,10,11,12],0,"0",0,0,0,0,"18",0,"00"],AZ:["994","00","365\\d{6}|(?:[124579]\\d|60|88)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["90"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["1[28]|2|365|46","1[28]|2|365[45]|46","1[28]|2|365(?:4|5[02])|46"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[13-9]"],"0$1"]],"0"],BA:["387","00","6\\d{8}|(?:[35689]\\d|49|70)\\d{6}",[8,9],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["6[1-3]|[7-9]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2-$3",["[3-5]|6[56]"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3 $4",["6"],"0$1"]],"0"],BB:["1","011","(?:246|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","246$1",0,"246"],BD:["880","00","[1-469]\\d{9}|8[0-79]\\d{7,8}|[2-79]\\d{8}|[2-9]\\d{7}|[3-9]\\d{6}|[57-9]\\d{5}",[6,7,8,9,10],[["(\\d{2})(\\d{4,6})","$1-$2",["31[5-8]|[459]1"],"0$1"],["(\\d{3})(\\d{3,7})","$1-$2",["3(?:[67]|8[013-9])|4(?:6[168]|7|[89][18])|5(?:6[128]|9)|6(?:[15]|28|4[14])|7[2-589]|8(?:0[014-9]|[12])|9[358]|(?:3[2-5]|4[235]|5[2-578]|6[0389]|76|8[3-7]|9[24])1|(?:44|66)[01346-9]"],"0$1"],["(\\d{4})(\\d{3,6})","$1-$2",["[13-9]|2[23]"],"0$1"],["(\\d)(\\d{7,8})","$1-$2",["2"],"0$1"]],"0"],BE:["32","00","4\\d{8}|[1-9]\\d{7}",[8,9],[["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["(?:80|9)0"],"0$1"],["(\\d)(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[239]|4[23]"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[15-8]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["4"],"0$1"]],"0"],BF:["226","00","[025-7]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[025-7]"]]]],BG:["359","00","00800\\d{7}|[2-7]\\d{6,7}|[89]\\d{6,8}|2\\d{5}",[6,7,8,9,12],[["(\\d)(\\d)(\\d{2})(\\d{2})","$1 $2 $3 $4",["2"],"0$1"],["(\\d{3})(\\d{4})","$1 $2",["43[1-6]|70[1-9]"],"0$1"],["(\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{2,3})","$1 $2 $3",["[356]|4[124-7]|7[1-9]|8[1-6]|9[1-7]"],"0$1"],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["(?:70|8)0"],"0$1"],["(\\d{3})(\\d{3})(\\d{2})","$1 $2 $3",["43[1-7]|7"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[48]|9[08]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["9"],"0$1"]],"0"],BH:["973","00","[136-9]\\d{7}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[13679]|8[02-4679]"]]]],BI:["257","00","(?:[267]\\d|31)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2367]"]]]],BJ:["229","00","(?:01\\d|[24-689])\\d{7}",[8,10],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[24-689]"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["0"]]]],BL:["590","00","(?:590\\d|7090)\\d{5}|(?:69|80|9\\d)\\d{7}",[9],0,"0",0,0,0,0,0,[["590(?:2[7-9]|3[3-7]|5[12]|87)\\d{4}"],["(?:69(?:0\\d\\d|1(?:2[2-9]|3[0-5])|4(?:0[89]|1[2-6]|9\\d)|6(?:1[016-9]|5[0-4]|[67]\\d))|7090[0-4])\\d{4}"],["80[0-5]\\d{6}"],0,0,0,0,0,["9(?:(?:39[5-7]|76[018])\\d|475[0-5])\\d{4}"]]],BM:["1","011","(?:441|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","441$1",0,"441"],BN:["673","00","[2-578]\\d{6}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[2-578]"]]]],BO:["591","00(?:1\\d)?","8001\\d{5}|(?:[2-467]\\d|50)\\d{6}",[8,9],[["(\\d)(\\d{7})","$1 $2",["[235]|4[46]"]],["(\\d{8})","$1",["[67]"]],["(\\d{3})(\\d{2})(\\d{4})","$1 $2 $3",["8"]]],"0",0,"0(1\\d)?"],BQ:["599","00","(?:[34]1|7\\d)\\d{5}",[7],0,0,0,0,0,0,"[347]"],BR:["55","00(?:1[245]|2[1-35]|31|4[13]|[56]5|99)","(?:[1-46-9]\\d\\d|5(?:[0-46-9]\\d|5[0-46-9]))\\d{8}|[1-9]\\d{9}|[3589]\\d{8}|[34]\\d{7}",[8,9,10,11],[["(\\d{4})(\\d{4})","$1-$2",["300|4(?:0[02]|37)","4(?:02|37)0|[34]00"]],["(\\d{3})(\\d{2,3})(\\d{4})","$1 $2 $3",["(?:[358]|90)0"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1 $2-$3",["(?:[14689][1-9]|2[12478]|3[1-578]|5[13-5]|7[13-579])[2-57]"],"($1)"],["(\\d{2})(\\d{5})(\\d{4})","$1 $2-$3",["[16][1-9]|[2-57-9]"],"($1)"]],"0",0,"(?:0|90)(?:(1[245]|2[1-35]|31|4[13]|[56]5|99)(\\d{10,11}))?","$2"],BS:["1","011","(?:242|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([3-8]\\d{6})$|1","242$1",0,"242"],BT:["975","00","[17]\\d{7}|[2-8]\\d{6}",[7,8],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[2-68]|7[246]"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["1[67]|7"]]]],BW:["267","00","(?:0800|(?:[37]|800)\\d)\\d{6}|(?:[2-6]\\d|90)\\d{5}",[7,8,10],[["(\\d{2})(\\d{5})","$1 $2",["90"]],["(\\d{3})(\\d{4})","$1 $2",["[24-6]|3[15-9]"]],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[37]"]],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["0"]],["(\\d{3})(\\d{4})(\\d{3})","$1 $2 $3",["8"]]]],BY:["375","810","(?:[12]\\d|33|44|902)\\d{7}|8(?:0[0-79]\\d{5,7}|[1-7]\\d{9})|8(?:1[0-489]|[5-79]\\d)\\d{7}|8[1-79]\\d{6,7}|8[0-79]\\d{5}|8\\d{5}",[6,7,8,9,10,11],[["(\\d{3})(\\d{3})","$1 $2",["800"],"8 $1"],["(\\d{3})(\\d{2})(\\d{2,4})","$1 $2 $3",["800"],"8 $1"],["(\\d{4})(\\d{2})(\\d{3})","$1 $2-$3",["1(?:5[169]|6[3-5]|7[179])|2(?:1[35]|2[34]|3[3-5])","1(?:5[169]|6(?:3[1-3]|4|5[125])|7(?:1[3-9]|7[0-24-6]|9[2-7]))|2(?:1[35]|2[34]|3[3-5])"],"8 0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2-$3-$4",["1(?:[56]|7[467])|2[1-3]"],"8 0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2-$3-$4",["[1-4]"],"8 0$1"],["(\\d{3})(\\d{3,4})(\\d{4})","$1 $2 $3",["[89]"],"8 $1"]],"8",0,"0|80?",0,0,0,0,"8~10"],BZ:["501","00","(?:0800\\d|[2-8])\\d{6}",[7,11],[["(\\d{3})(\\d{4})","$1-$2",["[2-8]"]],["(\\d)(\\d{3})(\\d{4})(\\d{3})","$1-$2-$3-$4",["0"]]]],CA:["1","011","[2-9]\\d{9}|3\\d{6}",[7,10],0,"1",0,0,0,0,0,[["(?:2(?:04|[23]6|[48]9|50|63)|3(?:06|43|54|6[578]|82)|4(?:03|1[68]|[26]8|3[178]|50|74)|5(?:06|1[49]|48|79|8[147])|6(?:04|[18]3|39|47|72)|7(?:0[59]|42|53|78|8[02])|8(?:[06]7|19|25|7[39])|9(?:0[25]|42))[2-9]\\d{6}",[10]],["",[10]],["8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",[10]],["900[2-9]\\d{6}",[10]],["52(?:3(?:[2-46-9][02-9]\\d|5(?:[02-46-9]\\d|5[0-46-9]))|4(?:[2-478][02-9]\\d|5(?:[034]\\d|2[024-9]|5[0-46-9])|6(?:0[1-9]|[2-9]\\d)|9(?:[05-9]\\d|2[0-5]|49)))\\d{4}|52[34][2-9]1[02-9]\\d{4}|(?:5(?:2[125-9]|33|44|66|77|88)|6(?:22|33))[2-9]\\d{6}",[10]],0,["310\\d{4}",[7]],0,["600[2-9]\\d{6}",[10]]]],CC:["61","001[14-689]|14(?:1[14]|34|4[17]|[56]6|7[47]|88)0011","1(?:[0-79]\\d{8}(?:\\d{2})?|8[0-24-9]\\d{7})|[148]\\d{8}|1\\d{5,7}",[6,7,8,9,10,12],0,"0",0,"([59]\\d{7})$|0","8$1",0,0,[["8(?:51(?:0(?:02|31|60|89)|1(?:18|76)|223)|91(?:0(?:1[0-2]|29)|1(?:[28]2|50|79)|2(?:10|64)|3(?:[06]8|22)|4[29]8|62\\d|70[23]|959))\\d{3}",[9]],["4(?:79[01]|83[0-389]|94[0-4])\\d{5}|4(?:[0-36]\\d|4[047-9]|5[0-25-9]|7[02-8]|8[0-24-9]|9[0-37-9])\\d{6}",[9]],["180(?:0\\d{3}|2)\\d{3}",[7,10]],["190[0-26]\\d{6}",[10]],0,0,0,0,["14(?:5(?:1[0458]|[23][458])|71\\d)\\d{4}",[9]],["13(?:00\\d{6}(?:\\d{2})?|45[0-4]\\d{3})|13\\d{4}",[6,8,10,12]]],"0011"],CD:["243","00","(?:(?:[189]|5\\d)\\d|2)\\d{7}|[1-68]\\d{6}",[7,8,9,10],[["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["88"],"0$1"],["(\\d{2})(\\d{5})","$1 $2",["[1-6]"],"0$1"],["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["1"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[89]"],"0$1"],["(\\d{2})(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3 $4",["5"],"0$1"]],"0"],CF:["236","00","(?:[27]\\d{3}|8776)\\d{4}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[278]"]]]],CG:["242","00","222\\d{6}|(?:0\\d|80)\\d{7}",[9],[["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["8"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[02]"]]]],CH:["41","00","8\\d{11}|[2-9]\\d{8}",[9,12],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8[047]|90"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-79]|81"],"0$1"],["(\\d{3})(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["8"],"0$1"]],"0"],CI:["225","00","[02]\\d{9}",[10],[["(\\d{2})(\\d{2})(\\d)(\\d{5})","$1 $2 $3 $4",["2"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3 $4",["0"]]]],CK:["682","00","[2-578]\\d{4}",[5],[["(\\d{2})(\\d{3})","$1 $2",["[2-578]"]]]],CL:["56","(?:0|1(?:1[0-69]|2[02-5]|5[13-58]|69|7[0167]|8[018]))0","12300\\d{6}|6\\d{9,10}|[2-9]\\d{8}",[9,10,11],[["(\\d{5})(\\d{4})","$1 $2",["219","2196"],"($1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["44"]],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["2[1-36]"],"($1)"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["9[2-9]"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["3[2-5]|[47]|5[1-3578]|6[13-57]|8(?:0[1-9]|[1-9])"],"($1)"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["60|8"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["1"]],["(\\d{3})(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3 $4",["60"]]]],CM:["237","00","[26]\\d{8}|88\\d{6,7}",[8,9],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["88"]],["(\\d)(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["[26]|88"]]]],CN:["86","00|1(?:[12]\\d|79)\\d\\d00","(?:(?:1[03-689]|2\\d)\\d\\d|6)\\d{8}|1\\d{10}|[126]\\d{6}(?:\\d(?:\\d{2})?)?|86\\d{5,6}|(?:[3-579]\\d|8[0-57-9])\\d{5,9}",[7,8,9,10,11,12],[["(\\d{2})(\\d{5,6})","$1 $2",["(?:10|2[0-57-9])[19]|3(?:[157]|35|49|9[1-68])|4(?:1[124-9]|2[179]|6[47-9]|7|8[23])|5(?:[1357]|2[37]|4[36]|6[1-46]|80)|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:07|1[236-8]|2[5-7]|[37]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3|4[13]|5[1-5]|7[0-79]|9[0-35-9])|(?:4[35]|59|85)[1-9]","(?:10|2[0-57-9])(?:1[02]|9[56])|8078|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))1","10(?:1(?:0|23)|9[56])|2[0-57-9](?:1(?:00|23)|9[56])|80781|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))12","10(?:1(?:0|23)|9[56])|2[0-57-9](?:1(?:00|23)|9[56])|807812|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))123","10(?:1(?:0|23)|9[56])|2[0-57-9](?:1(?:00|23)|9[56])|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:078|1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))123"],"0$1"],["(\\d{3})(\\d{5,6})","$1 $2",["3(?:[157]|35|49|9[1-68])|4(?:[17]|2[179]|6[47-9]|8[23])|5(?:[1357]|2[37]|4[36]|6[1-46]|80)|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]|4[13]|5[1-5])|(?:4[35]|59|85)[1-9]","(?:3(?:[157]\\d|35|49|9[1-68])|4(?:[17]\\d|2[179]|[35][1-9]|6[47-9]|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]\\d|4[13]|5[1-5]))[19]","85[23](?:10|95)|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:[17]\\d|2[179]|[35][1-9]|6[47-9]|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[14-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]\\d|4[13]|5[1-5]))(?:10|9[56])","85[23](?:100|95)|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:[17]\\d|2[179]|[35][1-9]|6[47-9]|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[14-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]\\d|4[13]|5[1-5]))(?:100|9[56])"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["(?:4|80)0"]],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["10|2(?:[02-57-9]|1[1-9])","10|2(?:[02-57-9]|1[1-9])","10[0-79]|2(?:[02-57-9]|1[1-79])|(?:10|21)8(?:0[1-9]|[1-9])"],"0$1",1],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["3(?:[3-59]|7[02-68])|4(?:[26-8]|3[3-9]|5[2-9])|5(?:3[03-9]|[468]|7[028]|9[2-46-9])|6|7(?:[0-247]|3[04-9]|5[0-4689]|6[2368])|8(?:[1-358]|9[1-7])|9(?:[013479]|5[1-5])|(?:[34]1|55|79|87)[02-9]"],"0$1",1],["(\\d{3})(\\d{7,8})","$1 $2",["9"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["80"],"0$1",1],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["[3-578]"],"0$1",1],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["1[3-9]"]],["(\\d{2})(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3 $4",["[12]"],"0$1",1]],"0",0,"(1(?:[12]\\d|79)\\d\\d)|0",0,0,0,0,"00"],CO:["57","00(?:4(?:[14]4|56)|[579])","(?:46|60\\d\\d)\\d{6}|(?:1\\d|[39])\\d{9}",[8,10,11],[["(\\d{4})(\\d{4})","$1 $2",["46"]],["(\\d{3})(\\d{7})","$1 $2",["6|90"],"($1)"],["(\\d{3})(\\d{7})","$1 $2",["3[0-357]|91"]],["(\\d)(\\d{3})(\\d{7})","$1-$2-$3",["1"],"0$1",0,"$1 $2 $3"]],"0",0,"0([3579]|4(?:[14]4|56))?"],CR:["506","00","(?:8\\d|90)\\d{8}|(?:[24-8]\\d{3}|3005)\\d{4}",[8,10],[["(\\d{4})(\\d{4})","$1 $2",["[2-7]|8[3-9]"]],["(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["[89]"]]],0,0,"(19(?:0[0-2468]|1[09]|20|66|77|99))"],CU:["53","119","(?:[2-7]|8\\d\\d)\\d{7}|[2-47]\\d{6}|[34]\\d{5}",[6,7,8,10],[["(\\d{2})(\\d{4,6})","$1 $2",["2[1-4]|[34]"],"(0$1)"],["(\\d)(\\d{6,7})","$1 $2",["7"],"(0$1)"],["(\\d)(\\d{7})","$1 $2",["[56]"],"0$1"],["(\\d{3})(\\d{7})","$1 $2",["8"],"0$1"]],"0"],CV:["238","0","(?:[2-59]\\d\\d|800)\\d{4}",[7],[["(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",["[2-589]"]]]],CW:["599","00","(?:[34]1|60|(?:7|9\\d)\\d)\\d{5}",[7,8],[["(\\d{3})(\\d{4})","$1 $2",["[3467]"]],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["9[4-8]"]]],0,0,0,0,0,"[69]"],CX:["61","001[14-689]|14(?:1[14]|34|4[17]|[56]6|7[47]|88)0011","1(?:[0-79]\\d{8}(?:\\d{2})?|8[0-24-9]\\d{7})|[148]\\d{8}|1\\d{5,7}",[6,7,8,9,10,12],0,"0",0,"([59]\\d{7})$|0","8$1",0,0,[["8(?:51(?:0(?:01|30|59|88)|1(?:17|46|75)|2(?:22|35))|91(?:00[6-9]|1(?:[28]1|49|78)|2(?:09|63)|3(?:12|26|75)|4(?:56|97)|64\\d|7(?:0[01]|1[0-2])|958))\\d{3}",[9]],["4(?:79[01]|83[0-389]|94[0-4])\\d{5}|4(?:[0-36]\\d|4[047-9]|5[0-25-9]|7[02-8]|8[0-24-9]|9[0-37-9])\\d{6}",[9]],["180(?:0\\d{3}|2)\\d{3}",[7,10]],["190[0-26]\\d{6}",[10]],0,0,0,0,["14(?:5(?:1[0458]|[23][458])|71\\d)\\d{4}",[9]],["13(?:00\\d{6}(?:\\d{2})?|45[0-4]\\d{3})|13\\d{4}",[6,8,10,12]]],"0011"],CY:["357","00","(?:[279]\\d|[58]0)\\d{6}",[8],[["(\\d{2})(\\d{6})","$1 $2",["[257-9]"]]]],CZ:["420","00","(?:[2-578]\\d|60)\\d{7}|9\\d{8,11}",[9,10,11,12],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[2-8]|9[015-7]"]],["(\\d{2})(\\d{3})(\\d{3})(\\d{2})","$1 $2 $3 $4",["96"]],["(\\d{2})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["9"]],["(\\d{3})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["9"]]]],DE:["49","00","[2579]\\d{5,14}|49(?:[34]0|69|8\\d)\\d\\d?|49(?:37|49|60|7[089]|9\\d)\\d{1,3}|49(?:2[024-9]|3[2-689]|7[1-7])\\d{1,8}|(?:1|[368]\\d|4[0-8])\\d{3,13}|49(?:[015]\\d|2[13]|31|[46][1-8])\\d{1,9}",[4,5,6,7,8,9,10,11,12,13,14,15],[["(\\d{2})(\\d{3,13})","$1 $2",["3[02]|40|[68]9"],"0$1"],["(\\d{3})(\\d{3,12})","$1 $2",["2(?:0[1-389]|1[124]|2[18]|3[14])|3(?:[35-9][15]|4[015])|906|(?:2[4-9]|4[2-9]|[579][1-9]|[68][1-8])1","2(?:0[1-389]|12[0-8])|3(?:[35-9][15]|4[015])|906|2(?:[13][14]|2[18])|(?:2[4-9]|4[2-9]|[579][1-9]|[68][1-8])1"],"0$1"],["(\\d{4})(\\d{2,11})","$1 $2",["[24-6]|3(?:[3569][02-46-9]|4[2-4679]|7[2-467]|8[2-46-8])|70[2-8]|8(?:0[2-9]|[1-8])|90[7-9]|[79][1-9]","[24-6]|3(?:3(?:0[1-467]|2[127-9]|3[124578]|7[1257-9]|8[1256]|9[145])|4(?:2[135]|4[13578]|9[1346])|5(?:0[14]|2[1-3589]|6[1-4]|7[13468]|8[13568])|6(?:2[1-489]|3[124-6]|6[13]|7[12579]|8[1-356]|9[135])|7(?:2[1-7]|4[145]|6[1-5]|7[1-4])|8(?:21|3[1468]|6|7[1467]|8[136])|9(?:0[12479]|2[1358]|4[134679]|6[1-9]|7[136]|8[147]|9[1468]))|70[2-8]|8(?:0[2-9]|[1-8])|90[7-9]|[79][1-9]|3[68]4[1347]|3(?:47|60)[1356]|3(?:3[46]|46|5[49])[1246]|3[4579]3[1357]"],"0$1"],["(\\d{3})(\\d{4})","$1 $2",["138"],"0$1"],["(\\d{5})(\\d{2,10})","$1 $2",["3"],"0$1"],["(\\d{3})(\\d{5,11})","$1 $2",["181"],"0$1"],["(\\d{3})(\\d)(\\d{4,10})","$1 $2 $3",["1(?:3|80)|9"],"0$1"],["(\\d{3})(\\d{7,8})","$1 $2",["1[67]"],"0$1"],["(\\d{3})(\\d{7,12})","$1 $2",["8"],"0$1"],["(\\d{5})(\\d{6})","$1 $2",["185","1850","18500"],"0$1"],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["7"],"0$1"],["(\\d{4})(\\d{7})","$1 $2",["18[68]"],"0$1"],["(\\d{4})(\\d{7})","$1 $2",["15[1279]"],"0$1"],["(\\d{5})(\\d{6})","$1 $2",["15[03568]","15(?:[0568]|31)"],"0$1"],["(\\d{3})(\\d{8})","$1 $2",["18"],"0$1"],["(\\d{3})(\\d{2})(\\d{7,8})","$1 $2 $3",["1(?:6[023]|7)"],"0$1"],["(\\d{4})(\\d{2})(\\d{7})","$1 $2 $3",["15[279]"],"0$1"],["(\\d{3})(\\d{2})(\\d{8})","$1 $2 $3",["15"],"0$1"]],"0"],DJ:["253","00","(?:2\\d|77)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[27]"]]]],DK:["45","00","[2-9]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-9]"]]]],DM:["1","011","(?:[58]\\d\\d|767|900)\\d{7}",[10],0,"1",0,"([2-7]\\d{6})$|1","767$1",0,"767"],DO:["1","011","(?:[58]\\d\\d|900)\\d{7}",[10],0,"1",0,0,0,0,"8001|8[024]9"],DZ:["213","00","(?:[1-4]|[5-79]\\d|80)\\d{7}",[8,9],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[1-4]"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["9"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-8]"],"0$1"]],"0"],EC:["593","00","1\\d{9,10}|(?:[2-7]|9\\d)\\d{7}",[8,9,10,11],[["(\\d)(\\d{3})(\\d{4})","$1 $2-$3",["[2-7]"],"(0$1)",0,"$1-$2-$3"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["9"],"0$1"],["(\\d{4})(\\d{3})(\\d{3,4})","$1 $2 $3",["1"]]],"0"],EE:["372","00","8\\d{9}|[4578]\\d{7}|(?:[3-8]\\d|90)\\d{5}",[7,8,10],[["(\\d{3})(\\d{4})","$1 $2",["[369]|4[3-8]|5(?:[0-2]|5[0-478]|6[45])|7[1-9]|88","[369]|4[3-8]|5(?:[02]|1(?:[0-8]|95)|5[0-478]|6(?:4[0-4]|5[1-589]))|7[1-9]|88"]],["(\\d{4})(\\d{3,4})","$1 $2",["[45]|8(?:00|[1-49])","[45]|8(?:00[1-9]|[1-49])"]],["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["7"]],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["8"]]]],EG:["20","00","[189]\\d{8,9}|[24-6]\\d{8}|[135]\\d{7}",[8,9,10],[["(\\d)(\\d{7,8})","$1 $2",["[23]"],"0$1"],["(\\d{2})(\\d{6,7})","$1 $2",["1[35]|[4-6]|8[2468]|9[235-7]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[89]"],"0$1"],["(\\d{2})(\\d{8})","$1 $2",["1"],"0$1"]],"0"],EH:["212","00","[5-8]\\d{8}",[9],0,"0",0,0,0,0,"528[89]"],ER:["291","00","[178]\\d{6}",[7],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[178]"],"0$1"]],"0"],ES:["34","00","[5-9]\\d{8}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[89]00"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-9]"]]]],ET:["251","00","(?:11|[2-579]\\d)\\d{7}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[1-579]"],"0$1"]],"0"],FI:["358","00|99(?:[01469]|5(?:[14]1|3[23]|5[59]|77|88|9[09]))","[1-35689]\\d{4}|7\\d{10,11}|(?:[124-7]\\d|3[0-46-9])\\d{8}|[1-9]\\d{5,8}",[5,6,7,8,9,10,11,12],[["(\\d{5})","$1",["20[2-59]"],"0$1"],["(\\d{3})(\\d{3,7})","$1 $2",["(?:[1-3]0|[68])0|70[07-9]"],"0$1"],["(\\d{2})(\\d{4,8})","$1 $2",["[14]|2[09]|50|7[135]"],"0$1"],["(\\d{2})(\\d{6,10})","$1 $2",["7"],"0$1"],["(\\d)(\\d{4,9})","$1 $2",["(?:19|[2568])[1-8]|3(?:0[1-9]|[1-9])|9"],"0$1"]],"0",0,0,0,0,"1[03-79]|[2-9]",0,"00"],FJ:["679","0(?:0|52)","45\\d{5}|(?:0800\\d|[235-9])\\d{6}",[7,11],[["(\\d{3})(\\d{4})","$1 $2",["[235-9]|45"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["0"]]],0,0,0,0,0,0,0,"00"],FK:["500","00","[2-7]\\d{4}",[5]],FM:["691","00","(?:[39]\\d\\d|820)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[389]"]]]],FO:["298","00","[2-9]\\d{5}",[6],[["(\\d{6})","$1",["[2-9]"]]],0,0,"(10(?:01|[12]0|88))"],FR:["33","00","[1-9]\\d{8}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0 $1"],["(\\d)(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["[1-79]"],"0$1"]],"0"],GA:["241","00","(?:[067]\\d|11)\\d{6}|[2-7]\\d{6}",[7,8],[["(\\d)(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-7]"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["0"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["11|[67]"],"0$1"]],0,0,"0(11\\d{6}|60\\d{6}|61\\d{6}|6[256]\\d{6}|7[467]\\d{6})","$1"],GB:["44","00","[1-357-9]\\d{9}|[18]\\d{8}|8\\d{6}",[7,9,10],[["(\\d{3})(\\d{4})","$1 $2",["800","8001","80011","800111","8001111"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",["845","8454","84546","845464"],"0$1"],["(\\d{3})(\\d{6})","$1 $2",["800"],"0$1"],["(\\d{5})(\\d{4,5})","$1 $2",["1(?:38|5[23]|69|76|94)","1(?:(?:38|69)7|5(?:24|39)|768|946)","1(?:3873|5(?:242|39[4-6])|(?:697|768)[347]|9467)"],"0$1"],["(\\d{4})(\\d{5,6})","$1 $2",["1(?:[2-69][02-9]|[78])"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["[25]|7(?:0|6[02-9])","[25]|7(?:0|6(?:[03-9]|2[356]))"],"0$1"],["(\\d{4})(\\d{6})","$1 $2",["7"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[1389]"],"0$1"]],"0",0,0,0,0,0,[["(?:1(?:1(?:3(?:[0-58]\\d\\d|73[0-35])|4(?:(?:[0-5]\\d|70)\\d|69[7-9])|(?:(?:5[0-26-9]|[78][0-49])\\d|6(?:[0-4]\\d|50))\\d)|(?:2(?:(?:0[024-9]|2[3-9]|3[3-79]|4[1-689]|[58][02-9]|6[0-47-9]|7[013-9]|9\\d)\\d|1(?:[0-7]\\d|8[0-3]))|(?:3(?:0\\d|1[0-8]|[25][02-9]|3[02-579]|[468][0-46-9]|7[1-35-79]|9[2-578])|4(?:0[03-9]|[137]\\d|[28][02-57-9]|4[02-69]|5[0-8]|[69][0-79])|5(?:0[1-35-9]|[16]\\d|2[024-9]|3[015689]|4[02-9]|5[03-9]|7[0-35-9]|8[0-468]|9[0-57-9])|6(?:0[034689]|1\\d|2[0-35689]|[38][013-9]|4[1-467]|5[0-69]|6[13-9]|7[0-8]|9[0-24578])|7(?:0[0246-9]|2\\d|3[0236-8]|4[03-9]|5[0-46-9]|6[013-9]|7[0-35-9]|8[024-9]|9[02-9])|8(?:0[35-9]|2[1-57-9]|3[02-578]|4[0-578]|5[124-9]|6[2-69]|7\\d|8[02-9]|9[02569])|9(?:0[02-589]|[18]\\d|2[02-689]|3[1-57-9]|4[2-9]|5[0-579]|6[2-47-9]|7[0-24578]|9[2-57]))\\d)\\d)|2(?:0[013478]|3[0189]|4[017]|8[0-46-9]|9[0-2])\\d{3})\\d{4}|1(?:2(?:0(?:46[1-4]|87[2-9])|545[1-79]|76(?:2\\d|3[1-8]|6[1-6])|9(?:7(?:2[0-4]|3[2-5])|8(?:2[2-8]|7[0-47-9]|8[3-5])))|3(?:6(?:38[2-5]|47[23])|8(?:47[04-9]|64[0157-9]))|4(?:044[1-7]|20(?:2[23]|8\\d)|6(?:0(?:30|5[2-57]|6[1-8]|7[2-8])|140)|8(?:052|87[1-3]))|5(?:2(?:4(?:3[2-79]|6\\d)|76\\d)|6(?:26[06-9]|686))|6(?:06(?:4\\d|7[4-79])|295[5-7]|35[34]\\d|47(?:24|61)|59(?:5[08]|6[67]|74)|9(?:55[0-4]|77[23]))|7(?:26(?:6[13-9]|7[0-7])|(?:442|688)\\d|50(?:2[0-3]|[3-68]2|76))|8(?:27[56]\\d|37(?:5[2-5]|8[239])|843[2-58])|9(?:0(?:0(?:6[1-8]|85)|52\\d)|3583|4(?:66[1-8]|9(?:2[01]|81))|63(?:23|3[1-4])|9561))\\d{3}",[9,10]],["7(?:457[0-57-9]|700[01]|911[028])\\d{5}|7(?:[1-3]\\d\\d|4(?:[0-46-9]\\d|5[0-689])|5(?:0[0-8]|[13-9]\\d|2[0-35-9])|7(?:0[1-9]|[1-7]\\d|8[02-9]|9[0-689])|8(?:[014-9]\\d|[23][0-8])|9(?:[024-9]\\d|1[02-9]|3[0-689]))\\d{6}",[10]],["80[08]\\d{7}|800\\d{6}|8001111"],["(?:8(?:4[2-5]|7[0-3])|9(?:[01]\\d|8[2-49]))\\d{7}|845464\\d",[7,10]],["70\\d{8}",[10]],0,["(?:3[0347]|55)\\d{8}",[10]],["76(?:464|652)\\d{5}|76(?:0[0-28]|2[356]|34|4[01347]|5[49]|6[0-369]|77|8[14]|9[139])\\d{6}",[10]],["56\\d{8}",[10]]],0," x"],GD:["1","011","(?:473|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","473$1",0,"473"],GE:["995","00","(?:[3-57]\\d\\d|800)\\d{6}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["70"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["32"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[57]"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[348]"],"0$1"]],"0"],GF:["594","00","(?:[56]94\\d|7093)\\d{5}|(?:80|9\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-7]|9[47]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[89]"],"0$1"]],"0"],GG:["44","00","(?:1481|[357-9]\\d{3})\\d{6}|8\\d{6}(?:\\d{2})?",[7,9,10],0,"0",0,"([25-9]\\d{5})$|0","1481$1",0,0,[["1481[25-9]\\d{5}",[10]],["7(?:(?:781|839)\\d|911[17])\\d{5}",[10]],["80[08]\\d{7}|800\\d{6}|8001111"],["(?:8(?:4[2-5]|7[0-3])|9(?:[01]\\d|8[0-3]))\\d{7}|845464\\d",[7,10]],["70\\d{8}",[10]],0,["(?:3[0347]|55)\\d{8}",[10]],["76(?:464|652)\\d{5}|76(?:0[0-28]|2[356]|34|4[01347]|5[49]|6[0-369]|77|8[14]|9[139])\\d{6}",[10]],["56\\d{8}",[10]]]],GH:["233","00","(?:[235]\\d{3}|800)\\d{5}",[8,9],[["(\\d{3})(\\d{5})","$1 $2",["8"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[235]"],"0$1"]],"0"],GI:["350","00","(?:[25]\\d|60)\\d{6}",[8],[["(\\d{3})(\\d{5})","$1 $2",["2"]]]],GL:["299","00","(?:19|[2-689]\\d|70)\\d{4}",[6],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["19|[2-9]"]]]],GM:["220","00","[2-9]\\d{6}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[2-9]"]]]],GN:["224","00","722\\d{6}|(?:3|6\\d)\\d{7}",[8,9],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["3"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[67]"]]]],GP:["590","00","(?:590\\d|7090)\\d{5}|(?:69|80|9\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-79]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0$1"]],"0",0,0,0,0,0,[["590(?:0[1-68]|[14][0-24-9]|2[0-68]|3[1-9]|5[3-579]|[68][0-689]|7[08]|9\\d)\\d{4}"],["(?:69(?:0\\d\\d|1(?:2[2-9]|3[0-5])|4(?:0[89]|1[2-6]|9\\d)|6(?:1[016-9]|5[0-4]|[67]\\d))|7090[0-4])\\d{4}"],["80[0-5]\\d{6}"],0,0,0,0,0,["9(?:(?:39[5-7]|76[018])\\d|475[0-5])\\d{4}"]]],GQ:["240","00","222\\d{6}|(?:3\\d|55|[89]0)\\d{7}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[235]"]],["(\\d{3})(\\d{6})","$1 $2",["[89]"]]]],GR:["30","00","5005000\\d{3}|8\\d{9,11}|(?:[269]\\d|70)\\d{8}",[10,11,12],[["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["21|7"]],["(\\d{4})(\\d{6})","$1 $2",["2(?:2|3[2-57-9]|4[2-469]|5[2-59]|6[2-9]|7[2-69]|8[2-49])|5"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[2689]"]],["(\\d{3})(\\d{3,4})(\\d{5})","$1 $2 $3",["8"]]]],GT:["502","00","80\\d{6}|(?:1\\d{3}|[2-7])\\d{7}",[8,11],[["(\\d{4})(\\d{4})","$1 $2",["[2-8]"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["1"]]]],GU:["1","011","(?:[58]\\d\\d|671|900)\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","671$1",0,"671"],GW:["245","00","[49]\\d{8}|4\\d{6}",[7,9],[["(\\d{3})(\\d{4})","$1 $2",["40"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[49]"]]]],GY:["592","001","(?:[2-8]\\d{3}|9008)\\d{3}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[2-9]"]]]],HK:["852","00(?:30|5[09]|[126-9]?)","8[0-46-9]\\d{6,7}|9\\d{4,7}|(?:[2-7]|9\\d{3})\\d{7}",[5,6,7,8,9,11],[["(\\d{3})(\\d{2,5})","$1 $2",["900","9003"]],["(\\d{4})(\\d{4})","$1 $2",["[2-7]|8[1-4]|9(?:0[1-9]|[1-8])"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8"]],["(\\d{3})(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3 $4",["9"]]],0,0,0,0,0,0,0,"00"],HN:["504","00","8\\d{10}|[237-9]\\d{7}",[8,11],[["(\\d{4})(\\d{4})","$1-$2",["[237-9]"]]]],HR:["385","00","(?:[24-69]\\d|3[0-79])\\d{7}|80\\d{5,7}|[1-79]\\d{7}|6\\d{5,6}",[6,7,8,9],[["(\\d{2})(\\d{2})(\\d{2,3})","$1 $2 $3",["6[01]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2,3})","$1 $2 $3",["8"],"0$1"],["(\\d)(\\d{4})(\\d{3})","$1 $2 $3",["1"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["6|7[245]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["9"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2-57]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8"],"0$1"]],"0"],HT:["509","00","(?:[2-489]\\d|55)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["[2-589]"]]]],HU:["36","00","[235-7]\\d{8}|[1-9]\\d{7}",[8,9],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["1"],"(06 $1)"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[27][2-9]|3[2-7]|4[24-9]|5[2-79]|6|8[2-57-9]|9[2-69]"],"(06 $1)"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2-9]"],"06 $1"]],"06"],ID:["62","00[89]","00[1-9]\\d{9,14}|(?:[1-36]|8\\d{5})\\d{6}|00\\d{9}|[1-9]\\d{8,10}|[2-9]\\d{7}",[7,8,9,10,11,12,13,14,15,16,17],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["15"]],["(\\d{2})(\\d{5,9})","$1 $2",["2[124]|[36]1"],"(0$1)"],["(\\d{3})(\\d{5,7})","$1 $2",["800"],"0$1"],["(\\d{3})(\\d{5,8})","$1 $2",["[2-79]"],"(0$1)"],["(\\d{3})(\\d{3,4})(\\d{3})","$1-$2-$3",["8[1-35-9]"],"0$1"],["(\\d{3})(\\d{6,8})","$1 $2",["1"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["804"],"0$1"],["(\\d{3})(\\d)(\\d{3})(\\d{3})","$1 $2 $3 $4",["80"],"0$1"],["(\\d{3})(\\d{4})(\\d{4,5})","$1-$2-$3",["8"],"0$1"]],"0"],IE:["353","00","(?:1\\d|[2569])\\d{6,8}|4\\d{6,9}|7\\d{8}|8\\d{8,9}",[7,8,9,10],[["(\\d{2})(\\d{5})","$1 $2",["2[24-9]|47|58|6[237-9]|9[35-9]"],"(0$1)"],["(\\d{3})(\\d{5})","$1 $2",["[45]0"],"(0$1)"],["(\\d)(\\d{3,4})(\\d{4})","$1 $2 $3",["1"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2569]|4[1-69]|7[14]"],"(0$1)"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["70"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["81"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[78]"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1"]],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["4"],"(0$1)"],["(\\d{2})(\\d)(\\d{3})(\\d{4})","$1 $2 $3 $4",["8"],"0$1"]],"0"],IL:["972","0(?:0|1[2-9])","1\\d{6}(?:\\d{3,5})?|[57]\\d{8}|[1-489]\\d{7}",[7,8,9,10,11,12],[["(\\d{4})(\\d{3})","$1-$2",["125"]],["(\\d{4})(\\d{2})(\\d{2})","$1-$2-$3",["121"]],["(\\d)(\\d{3})(\\d{4})","$1-$2-$3",["[2-489]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["[57]"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1-$2-$3",["12"]],["(\\d{4})(\\d{6})","$1-$2",["159"]],["(\\d)(\\d{3})(\\d{3})(\\d{3})","$1-$2-$3-$4",["1[7-9]"]],["(\\d{3})(\\d{1,2})(\\d{3})(\\d{4})","$1-$2 $3-$4",["15"]]],"0"],IM:["44","00","1624\\d{6}|(?:[3578]\\d|90)\\d{8}",[10],0,"0",0,"([25-8]\\d{5})$|0","1624$1",0,"74576|(?:16|7[56])24"],IN:["91","00","(?:000800|[2-9]\\d\\d)\\d{7}|1\\d{7,12}",[8,9,10,11,12,13],[["(\\d{8})","$1",["5(?:0|2[23]|3[03]|[67]1|88)","5(?:0|2(?:21|3)|3(?:0|3[23])|616|717|888)","5(?:0|2(?:21|3)|3(?:0|3[23])|616|717|8888)"],0,1],["(\\d{4})(\\d{4,5})","$1 $2",["180","1800"],0,1],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["140"],0,1],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["11|2[02]|33|4[04]|79[1-7]|80[2-46]","11|2[02]|33|4[04]|79(?:[1-6]|7[19])|80(?:[2-4]|6[0-589])","11|2[02]|33|4[04]|79(?:[124-6]|3(?:[02-9]|1[0-24-9])|7(?:1|9[1-6]))|80(?:[2-4]|6[0-589])"],"0$1",1],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["1(?:2[0-249]|3[0-25]|4[145]|[68]|7[1257])|2(?:1[257]|3[013]|4[01]|5[0137]|6[0158]|78|8[1568])|3(?:26|4[1-3]|5[34]|6[01489]|7[02-46]|8[159])|4(?:1[36]|2[1-47]|5[12]|6[0-26-9]|7[0-24-9]|8[013-57]|9[014-7])|5(?:1[025]|22|[36][25]|4[28]|5[12]|[78]1)|6(?:12|[2-4]1|5[17]|6[13]|80)|7(?:12|3[134]|4[47]|61|88)|8(?:16|2[014]|3[126]|6[136]|7[078]|8[34]|91)|(?:43|59|75)[15]|(?:1[59]|29|67|72)[14]","1(?:2[0-24]|3[0-25]|4[145]|[59][14]|6[1-9]|7[1257]|8[1-57-9])|2(?:1[257]|3[013]|4[01]|5[0137]|6[058]|78|8[1568]|9[14])|3(?:26|4[1-3]|5[34]|6[01489]|7[02-46]|8[159])|4(?:1[36]|2[1-47]|3[15]|5[12]|6[0-26-9]|7[0-24-9]|8[013-57]|9[014-7])|5(?:1[025]|22|[36][25]|4[28]|[578]1|9[15])|674|7(?:(?:2[14]|3[34]|5[15])[2-6]|61[346]|88[0-8])|8(?:70[2-6]|84[235-7]|91[3-7])|(?:1(?:29|60|8[06])|261|552|6(?:12|[2-47]1|5[17]|6[13]|80)|7(?:12|31|4[47])|8(?:16|2[014]|3[126]|6[136]|7[78]|83))[2-7]","1(?:2[0-24]|3[0-25]|4[145]|[59][14]|6[1-9]|7[1257]|8[1-57-9])|2(?:1[257]|3[013]|4[01]|5[0137]|6[058]|78|8[1568]|9[14])|3(?:26|4[1-3]|5[34]|6[01489]|7[02-46]|8[159])|4(?:1[36]|2[1-47]|3[15]|5[12]|6[0-26-9]|7[0-24-9]|8[013-57]|9[014-7])|5(?:1[025]|22|[36][25]|4[28]|[578]1|9[15])|6(?:12(?:[2-6]|7[0-8])|74[2-7])|7(?:(?:2[14]|5[15])[2-6]|3171|61[346]|88(?:[2-7]|82))|8(?:70[2-6]|84(?:[2356]|7[19])|91(?:[3-6]|7[19]))|73[134][2-6]|(?:74[47]|8(?:16|2[014]|3[126]|6[136]|7[78]|83))(?:[2-6]|7[19])|(?:1(?:29|60|8[06])|261|552|6(?:[2-4]1|5[17]|6[13]|7(?:1|4[0189])|80)|7(?:12|88[01]))[2-7]"],"0$1",1],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1(?:[2-479]|5[0235-9])|[2-5]|6(?:1[1358]|2[2457-9]|3[2-5]|4[235-7]|5[2-689]|6[24578]|7[235689]|8[1-6])|7(?:1[013-9]|28|3[129]|4[1-35689]|5[29]|6[02-5]|70)|807","1(?:[2-479]|5[0235-9])|[2-5]|6(?:1[1358]|2(?:[2457]|84|95)|3(?:[2-4]|55)|4[235-7]|5[2-689]|6[24578]|7[235689]|8[1-6])|7(?:1(?:[013-8]|9[6-9])|28[6-8]|3(?:17|2[0-49]|9[2-57])|4(?:1[2-4]|[29][0-7]|3[0-8]|[56]|8[0-24-7])|5(?:2[1-3]|9[0-6])|6(?:0[5689]|2[5-9]|3[02-8]|4|5[0-367])|70[13-7])|807[19]","1(?:[2-479]|5(?:[0236-9]|5[013-9]))|[2-5]|6(?:2(?:84|95)|355|83)|73179|807(?:1|9[1-3])|(?:1552|6(?:1[1358]|2[2457]|3[2-4]|4[235-7]|5[2-689]|6[24578]|7[235689]|8[124-6])\\d|7(?:1(?:[013-8]\\d|9[6-9])|28[6-8]|3(?:2[0-49]|9[2-57])|4(?:1[2-4]|[29][0-7]|3[0-8]|[56]\\d|8[0-24-7])|5(?:2[1-3]|9[0-6])|6(?:0[5689]|2[5-9]|3[02-8]|4\\d|5[0-367])|70[13-7]))[2-7]"],"0$1",1],["(\\d{5})(\\d{5})","$1 $2",["[6-9]"],"0$1",1],["(\\d{4})(\\d{2,4})(\\d{4})","$1 $2 $3",["1(?:6|8[06])","1(?:6|8[06]0)"],0,1],["(\\d{4})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["18"],0,1]],"0"],IO:["246","00","3\\d{6}",[7],[["(\\d{3})(\\d{4})","$1 $2",["3"]]]],IQ:["964","00","(?:1|7\\d\\d)\\d{7}|[2-6]\\d{7,8}",[8,9,10],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["1"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2-6]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["7"],"0$1"]],"0"],IR:["98","00","[1-9]\\d{9}|(?:[1-8]\\d\\d|9)\\d{3,4}",[4,5,6,7,10],[["(\\d{4,5})","$1",["96"],"0$1"],["(\\d{2})(\\d{4,5})","$1 $2",["(?:1[137]|2[13-68]|3[1458]|4[145]|5[1468]|6[16]|7[1467]|8[13467])[12689]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["9"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["[1-8]"],"0$1"]],"0"],IS:["354","00|1(?:0(?:01|[12]0)|100)","(?:38\\d|[4-9])\\d{6}",[7,9],[["(\\d{3})(\\d{4})","$1 $2",["[4-9]"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["3"]]],0,0,0,0,0,0,0,"00"],IT:["39","00","0\\d{5,10}|1\\d{8,10}|3(?:[0-8]\\d{7,10}|9\\d{7,8})|(?:43|55|70)\\d{8}|8\\d{5}(?:\\d{2,4})?",[6,7,8,9,10,11,12],[["(\\d{2})(\\d{4,6})","$1 $2",["0[26]"]],["(\\d{3})(\\d{3,6})","$1 $2",["0[13-57-9][0159]|8(?:03|4[17]|9[2-5])","0[13-57-9][0159]|8(?:03|4[17]|9(?:2|3[04]|[45][0-4]))"]],["(\\d{4})(\\d{2,6})","$1 $2",["0(?:[13-579][2-46-8]|8[236-8])"]],["(\\d{4})(\\d{4})","$1 $2",["894"]],["(\\d{2})(\\d{3,4})(\\d{4})","$1 $2 $3",["0[26]|5"]],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["1(?:44|[679])|[378]|43"]],["(\\d{3})(\\d{3,4})(\\d{4})","$1 $2 $3",["0[13-57-9][0159]|14"]],["(\\d{2})(\\d{4})(\\d{5})","$1 $2 $3",["0[26]"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["0"]],["(\\d{3})(\\d{4})(\\d{4,5})","$1 $2 $3",["3"]]],0,0,0,0,0,0,[["0669[0-79]\\d{1,6}|0(?:1(?:[0159]\\d|[27][1-5]|31|4[1-4]|6[1356]|8[2-57])|2\\d\\d|3(?:[0159]\\d|2[1-4]|3[12]|[48][1-6]|6[2-59]|7[1-7])|4(?:[0159]\\d|[23][1-9]|4[245]|6[1-5]|7[1-4]|81)|5(?:[0159]\\d|2[1-5]|3[2-6]|4[1-79]|6[4-6]|7[1-578]|8[3-8])|6(?:[0-57-9]\\d|6[0-8])|7(?:[0159]\\d|2[12]|3[1-7]|4[2-46]|6[13569]|7[13-6]|8[1-59])|8(?:[0159]\\d|2[3-578]|3[1-356]|[6-8][1-5])|9(?:[0159]\\d|[238][1-5]|4[12]|6[1-8]|7[1-6]))\\d{2,7}",[6,7,8,9,10,11]],["3[2-9]\\d{7,8}|(?:31|43)\\d{8}",[9,10]],["80(?:0\\d{3}|3)\\d{3}",[6,9]],["(?:0878\\d{3}|89(?:2\\d|3[04]|4(?:[0-4]|[5-9]\\d\\d)|5[0-4]))\\d\\d|(?:1(?:44|6[346])|89(?:38|5[5-9]|9))\\d{6}",[6,8,9,10]],["1(?:78\\d|99)\\d{6}",[9,10]],["3[2-8]\\d{9,10}",[11,12]],0,0,["55\\d{8}",[10]],["84(?:[08]\\d{3}|[17])\\d{3}",[6,9]]]],JE:["44","00","1534\\d{6}|(?:[3578]\\d|90)\\d{8}",[10],0,"0",0,"([0-24-8]\\d{5})$|0","1534$1",0,0,[["1534[0-24-8]\\d{5}"],["7(?:(?:(?:50|82)9|937)\\d|7(?:00[378]|97\\d))\\d{5}"],["80(?:07(?:35|81)|8901)\\d{4}"],["(?:8(?:4(?:4(?:4(?:05|42|69)|703)|5(?:041|800))|7(?:0002|1206))|90(?:066[59]|1810|71(?:07|55)))\\d{4}"],["701511\\d{4}"],0,["(?:3(?:0(?:07(?:35|81)|8901)|3\\d{4}|4(?:4(?:4(?:05|42|69)|703)|5(?:041|800))|7(?:0002|1206))|55\\d{4})\\d{4}"],["76(?:464|652)\\d{5}|76(?:0[0-28]|2[356]|34|4[01347]|5[49]|6[0-369]|77|8[14]|9[139])\\d{6}"],["56\\d{8}"]]],JM:["1","011","(?:[58]\\d\\d|658|900)\\d{7}",[10],0,"1",0,0,0,0,"658|876"],JO:["962","00","(?:(?:[2689]|7\\d)\\d|32|53)\\d{6}",[8,9],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[2356]|87"],"(0$1)"],["(\\d{3})(\\d{5,6})","$1 $2",["[89]"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["70"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["7"],"0$1"]],"0"],JP:["81","010","00[1-9]\\d{6,14}|[25-9]\\d{9}|(?:00|[1-9]\\d\\d)\\d{6}",[8,9,10,11,12,13,14,15,16,17],[["(\\d{3})(\\d{3})(\\d{3})","$1-$2-$3",["(?:12|57|99)0"],"0$1"],["(\\d{4})(\\d)(\\d{4})","$1-$2-$3",["1(?:26|3[79]|4[56]|5[4-68]|6[3-5])|499|5(?:76|97)|746|8(?:3[89]|47|51)|9(?:80|9[16])","1(?:267|3(?:7[247]|9[278])|466|5(?:47|58|64)|6(?:3[245]|48|5[4-68]))|499[2468]|5(?:76|97)9|7468|8(?:3(?:8[7-9]|96)|477|51[2-9])|9(?:802|9(?:1[23]|69))|1(?:45|58)[67]","1(?:267|3(?:7[247]|9[278])|466|5(?:47|58|64)|6(?:3[245]|48|5[4-68]))|499[2468]|5(?:769|979[2-69])|7468|8(?:3(?:8[7-9]|96[2457-9])|477|51[2-9])|9(?:802|9(?:1[23]|69))|1(?:45|58)[67]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["60"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1-$2-$3",["3|4(?:2[09]|7[01])|6[1-9]","3|4(?:2(?:0|9[02-69])|7(?:0[019]|1))|6[1-9]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["1(?:1|5[45]|77|88|9[69])|2(?:2[1-37]|3[0-269]|4[59]|5|6[24]|7[1-358]|8[1369]|9[0-38])|4(?:[28][1-9]|3[0-57]|[45]|6[248]|7[2-579]|9[29])|5(?:2|3[0459]|4[0-369]|5[29]|8[02389]|9[0-389])|7(?:2[02-46-9]|34|[58]|6[0249]|7[57]|9[2-6])|8(?:2[124589]|3[26-9]|49|51|6|7[0-468]|8[68]|9[019])|9(?:[23][1-9]|4[15]|5[138]|6[1-3]|7[156]|8[189]|9[1-489])","1(?:1|5(?:4[018]|5[017])|77|88|9[69])|2(?:2(?:[127]|3[014-9])|3[0-269]|4[59]|5(?:[1-3]|5[0-69]|9[19])|62|7(?:[1-35]|8[0189])|8(?:[16]|3[0134]|9[0-5])|9(?:[028]|17))|4(?:2(?:[13-79]|8[014-6])|3[0-57]|[45]|6[248]|7[2-47]|8[1-9]|9[29])|5(?:2|3(?:[045]|9[0-8])|4[0-369]|5[29]|8[02389]|9[0-3])|7(?:2[02-46-9]|34|[58]|6[0249]|7[57]|9(?:[23]|4[0-59]|5[01569]|6[0167]))|8(?:2(?:[1258]|4[0-39]|9[0-2469])|3(?:[29]|60)|49|51|6(?:[0-24]|36|5[0-3589]|7[23]|9[01459])|7[0-468]|8[68])|9(?:[23][1-9]|4[15]|5[138]|6[1-3]|7[156]|8[189]|9(?:[1289]|3[34]|4[0178]))|(?:264|837)[016-9]|2(?:57|93)[015-9]|(?:25[0468]|422|838)[01]|(?:47[59]|59[89]|8(?:6[68]|9))[019]","1(?:1|5(?:4[018]|5[017])|77|88|9[69])|2(?:2[127]|3[0-269]|4[59]|5(?:[1-3]|5[0-69]|9(?:17|99))|6(?:2|4[016-9])|7(?:[1-35]|8[0189])|8(?:[16]|3[0134]|9[0-5])|9(?:[028]|17))|4(?:2(?:[13-79]|8[014-6])|3[0-57]|[45]|6[248]|7[2-47]|9[29])|5(?:2|3(?:[045]|9(?:[0-58]|6[4-9]|7[0-35689]))|4[0-369]|5[29]|8[02389]|9[0-3])|7(?:2[02-46-9]|34|[58]|6[0249]|7[57]|9(?:[23]|4[0-59]|5[01569]|6[0167]))|8(?:2(?:[1258]|4[0-39]|9[0169])|3(?:[29]|60|7(?:[017-9]|6[6-8]))|49|51|6(?:[0-24]|36[2-57-9]|5(?:[0-389]|5[23])|6(?:[01]|9[178])|7(?:2[2-468]|3[78])|9[0145])|7[0-468]|8[68])|9(?:4[15]|5[138]|7[156]|8[189]|9(?:[1289]|3(?:31|4[357])|4[0178]))|(?:8294|96)[1-3]|2(?:57|93)[015-9]|(?:223|8699)[014-9]|(?:25[0468]|422|838)[01]|(?:48|8292|9[23])[1-9]|(?:47[59]|59[89]|8(?:68|9))[019]"],"0$1"],["(\\d{3})(\\d{2})(\\d{4})","$1-$2-$3",["[14]|[289][2-9]|5[3-9]|7[2-4679]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["800"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1-$2-$3",["[25-9]"],"0$1"]],"0",0,"(000[259]\\d{6})$|(?:(?:003768)0?)|0","$1"],KE:["254","000","(?:[17]\\d\\d|900)\\d{6}|(?:2|80)0\\d{6,7}|[4-6]\\d{6,8}",[7,8,9,10],[["(\\d{2})(\\d{5,7})","$1 $2",["[24-6]"],"0$1"],["(\\d{3})(\\d{6})","$1 $2",["[17]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["[89]"],"0$1"]],"0"],KG:["996","00","8\\d{9}|[235-9]\\d{8}",[9,10],[["(\\d{4})(\\d{5})","$1 $2",["3(?:1[346]|[24-79])"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[235-79]|88"],"0$1"],["(\\d{3})(\\d{3})(\\d)(\\d{2,3})","$1 $2 $3 $4",["8"],"0$1"]],"0"],KH:["855","00[14-9]","1\\d{9}|[1-9]\\d{7,8}",[8,9,10],[["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[1-9]"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1"]]],"0"],KI:["686","00","(?:[37]\\d|6[0-79])\\d{6}|(?:[2-48]\\d|50)\\d{3}",[5,8],0,"0"],KM:["269","00","[3478]\\d{6}",[7],[["(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",["[3478]"]]]],KN:["1","011","(?:[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-7]\\d{6})$|1","869$1",0,"869"],KP:["850","00|99","85\\d{6}|(?:19\\d|[2-7])\\d{7}",[8,10],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["8"],"0$1"],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[2-7]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["1"],"0$1"]],"0"],KR:["82","00(?:[125689]|3(?:[46]5|91)|7(?:00|27|3|55|6[126]))","00[1-9]\\d{8,11}|(?:[12]|5\\d{3})\\d{7}|[13-6]\\d{9}|(?:[1-6]\\d|80)\\d{7}|[3-6]\\d{4,5}|(?:00|7)0\\d{8}",[5,6,8,9,10,11,12,13,14],[["(\\d{2})(\\d{3,4})","$1-$2",["(?:3[1-3]|[46][1-4]|5[1-5])1"],"0$1"],["(\\d{4})(\\d{4})","$1-$2",["1"]],["(\\d)(\\d{3,4})(\\d{4})","$1-$2-$3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["[36]0|8"],"0$1"],["(\\d{2})(\\d{3,4})(\\d{4})","$1-$2-$3",["[1346]|5[1-5]"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1-$2-$3",["[57]"],"0$1"],["(\\d{2})(\\d{5})(\\d{4})","$1-$2-$3",["5"],"0$1"]],"0",0,"0(8(?:[1-46-8]|5\\d\\d))?"],KW:["965","00","18\\d{5}|(?:[2569]\\d|41)\\d{6}",[7,8],[["(\\d{4})(\\d{3,4})","$1 $2",["[169]|2(?:[235]|4[1-35-9])|52"]],["(\\d{3})(\\d{5})","$1 $2",["[245]"]]]],KY:["1","011","(?:345|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","345$1",0,"345"],KZ:["7","810","(?:33622|8\\d{8})\\d{5}|[78]\\d{9}",[10,14],0,"8",0,0,0,0,"33|7",0,"8~10"],LA:["856","00","[23]\\d{9}|3\\d{8}|(?:[235-8]\\d|41)\\d{6}",[8,9,10],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["2[13]|3[14]|[4-8]"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3 $4",["30[0135-9]"],"0$1"],["(\\d{2})(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3 $4",["[23]"],"0$1"]],"0"],LB:["961","00","[27-9]\\d{7}|[13-9]\\d{6}",[7,8],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[13-69]|7(?:[2-57]|62|8[0-7]|9[04-9])|8[02-9]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[27-9]"]]],"0"],LC:["1","011","(?:[58]\\d\\d|758|900)\\d{7}",[10],0,"1",0,"([2-8]\\d{6})$|1","758$1",0,"758"],LI:["423","00","[68]\\d{8}|(?:[2378]\\d|90)\\d{5}",[7,9],[["(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",["[2379]|8(?:0[09]|7)","[2379]|8(?:0(?:02|9)|7)"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["69"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["6"]]],"0",0,"(1001)|0"],LK:["94","00","[1-9]\\d{8}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["7"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[1-689]"],"0$1"]],"0"],LR:["231","00","(?:[245]\\d|33|77|88)\\d{7}|(?:2\\d|[4-6])\\d{6}",[7,8,9],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["4[67]|[56]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[2-578]"],"0$1"]],"0"],LS:["266","00","(?:[256]\\d\\d|800)\\d{5}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[2568]"]]]],LT:["370","00","(?:[3469]\\d|52|[78]0)\\d{6}",[8],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["52[0-7]"],"(0-$1)",1],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["[7-9]"],"0 $1",1],["(\\d{2})(\\d{6})","$1 $2",["37|4(?:[15]|6[1-8])"],"(0-$1)",1],["(\\d{3})(\\d{5})","$1 $2",["[3-6]"],"(0-$1)",1]],"0",0,"[08]"],LU:["352","00","35[013-9]\\d{4,8}|6\\d{8}|35\\d{2,4}|(?:[2457-9]\\d|3[0-46-9])\\d{2,9}",[4,5,6,7,8,9,10,11],[["(\\d{2})(\\d{3})","$1 $2",["2(?:0[2-689]|[2-9])|[3-57]|8(?:0[2-9]|[13-9])|9(?:0[89]|[2-579])"]],["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["2(?:0[2-689]|[2-9])|[3-57]|8(?:0[2-9]|[13-9])|9(?:0[89]|[2-579])"]],["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["20[2-689]"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{1,2})","$1 $2 $3 $4",["2(?:[0367]|4[3-8])"]],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["80[01]|90[015]"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3 $4",["20"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["6"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{1,2})","$1 $2 $3 $4 $5",["2(?:[0367]|4[3-8])"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{1,5})","$1 $2 $3 $4",["[3-57]|8[13-9]|9(?:0[89]|[2-579])|(?:2|80)[2-9]"]]],0,0,"(15(?:0[06]|1[12]|[35]5|4[04]|6[26]|77|88|99)\\d)"],LV:["371","00","(?:[268]\\d|90)\\d{6}",[8],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[269]|8[01]"]]]],LY:["218","00","[2-9]\\d{8}",[9],[["(\\d{2})(\\d{7})","$1-$2",["[2-9]"],"0$1"]],"0"],MA:["212","00","[5-8]\\d{8}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["5[45]"],"0$1"],["(\\d{4})(\\d{5})","$1-$2",["5(?:2[2-46-9]|3[3-9]|9)|8(?:0[89]|92)"],"0$1"],["(\\d{2})(\\d{7})","$1-$2",["8"],"0$1"],["(\\d{3})(\\d{6})","$1-$2",["[5-7]"],"0$1"]],"0",0,0,0,0,0,[["5(?:2(?:[0-25-79]\\d|3[1-578]|4[02-46-8]|8[0235-7])|3(?:[0-47]\\d|5[02-9]|6[02-8]|8[014-9]|9[3-9])|(?:4[067]|5[03])\\d)\\d{5}"],["(?:6(?:[0-79]\\d|8[0-247-9])|7(?:[0167]\\d|2[0-4]|5[01]|8[0-3]))\\d{6}"],["80[0-7]\\d{6}"],["89\\d{7}"],0,0,0,0,["(?:592(?:4[0-2]|93)|80[89]\\d\\d)\\d{4}"]]],MC:["377","00","(?:[3489]|6\\d)\\d{7}",[8,9],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["4"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[389]"]],["(\\d)(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["6"],"0$1"]],"0"],MD:["373","00","(?:[235-7]\\d|[89]0)\\d{6}",[8],[["(\\d{3})(\\d{5})","$1 $2",["[89]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["22|3"],"0$1"],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["[25-7]"],"0$1"]],"0"],ME:["382","00","(?:20|[3-79]\\d)\\d{6}|80\\d{6,7}",[8,9],[["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2-9]"],"0$1"]],"0"],MF:["590","00","(?:590\\d|7090)\\d{5}|(?:69|80|9\\d)\\d{7}",[9],0,"0",0,0,0,0,0,[["590(?:0[079]|[14]3|[27][79]|3[03-7]|5[0-268]|87)\\d{4}"],["(?:69(?:0\\d\\d|1(?:2[2-9]|3[0-5])|4(?:0[89]|1[2-6]|9\\d)|6(?:1[016-9]|5[0-4]|[67]\\d))|7090[0-4])\\d{4}"],["80[0-5]\\d{6}"],0,0,0,0,0,["9(?:(?:39[5-7]|76[018])\\d|475[0-5])\\d{4}"]]],MG:["261","00","[23]\\d{8}",[9],[["(\\d{2})(\\d{2})(\\d{3})(\\d{2})","$1 $2 $3 $4",["[23]"],"0$1"]],"0",0,"([24-9]\\d{6})$|0","20$1"],MH:["692","011","329\\d{4}|(?:[256]\\d|45)\\d{5}",[7],[["(\\d{3})(\\d{4})","$1-$2",["[2-6]"]]],"1"],MK:["389","00","[2-578]\\d{7}",[8],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["2|34[47]|4(?:[37]7|5[47]|64)"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[347]"],"0$1"],["(\\d{3})(\\d)(\\d{2})(\\d{2})","$1 $2 $3 $4",["[58]"],"0$1"]],"0"],ML:["223","00","[24-9]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[24-9]"]]]],MM:["95","00","1\\d{5,7}|95\\d{6}|(?:[4-7]|9[0-46-9])\\d{6,8}|(?:2|8\\d)\\d{5,8}",[6,7,8,9,10],[["(\\d)(\\d{2})(\\d{3})","$1 $2 $3",["16|2"],"0$1"],["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["4(?:[2-46]|5[3-5])|5|6(?:[1-689]|7[235-7])|7(?:[0-4]|5[2-7])|8[1-5]|(?:60|86)[23]"],"0$1"],["(\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["[12]|452|678|86","[12]|452|6788|86"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[4-7]|8[1-35]"],"0$1"],["(\\d)(\\d{3})(\\d{4,6})","$1 $2 $3",["9(?:2[0-4]|[35-9]|4[137-9])"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["2"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"],"0$1"],["(\\d)(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["92"],"0$1"],["(\\d)(\\d{5})(\\d{4})","$1 $2 $3",["9"],"0$1"]],"0"],MN:["976","001","[12]\\d{7,9}|[5-9]\\d{7}",[8,9,10],[["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["[12]1"],"0$1"],["(\\d{4})(\\d{4})","$1 $2",["[5-9]"]],["(\\d{3})(\\d{5,6})","$1 $2",["[12]2[1-3]"],"0$1"],["(\\d{4})(\\d{5,6})","$1 $2",["[12](?:27|3[2-8]|4[2-68]|5[1-4689])","[12](?:27|3[2-8]|4[2-68]|5[1-4689])[0-3]"],"0$1"],["(\\d{5})(\\d{4,5})","$1 $2",["[12]"],"0$1"]],"0"],MO:["853","00","0800\\d{3}|(?:28|[68]\\d)\\d{6}",[7,8],[["(\\d{4})(\\d{3})","$1 $2",["0"]],["(\\d{4})(\\d{4})","$1 $2",["[268]"]]]],MP:["1","011","[58]\\d{9}|(?:67|90)0\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","670$1",0,"670"],MQ:["596","00","(?:596\\d|7091)\\d{5}|(?:69|[89]\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-79]|8(?:0[6-9]|[36])"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0$1"]],"0"],MR:["222","00","(?:[2-4]\\d\\d|800)\\d{5}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-48]"]]]],MS:["1","011","(?:[58]\\d\\d|664|900)\\d{7}",[10],0,"1",0,"([34]\\d{6})$|1","664$1",0,"664"],MT:["356","00","3550\\d{4}|(?:[2579]\\d\\d|800)\\d{5}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[2357-9]"]]]],MU:["230","0(?:0|[24-7]0|3[03])","(?:[57]|8\\d\\d)\\d{7}|[2-468]\\d{6}",[7,8,10],[["(\\d{3})(\\d{4})","$1 $2",["[2-46]|8[013]"]],["(\\d{4})(\\d{4})","$1 $2",["[57]"]],["(\\d{5})(\\d{5})","$1 $2",["8"]]],0,0,0,0,0,0,0,"020"],MV:["960","0(?:0|19)","(?:800|9[0-57-9]\\d)\\d{7}|[34679]\\d{6}",[7,10],[["(\\d{3})(\\d{4})","$1-$2",["[34679]"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[89]"]]],0,0,0,0,0,0,0,"00"],MW:["265","00","(?:[1289]\\d|31|77)\\d{7}|1\\d{6}",[7,9],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["1[2-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["2"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[137-9]"],"0$1"]],"0"],MX:["52","0[09]","[2-9]\\d{9}",[10],[["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["33|5[56]|81"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[2-9]"]]],0,0,0,0,0,0,0,"00"],MY:["60","00","1\\d{8,9}|(?:3\\d|[4-9])\\d{7}",[8,9,10],[["(\\d)(\\d{3})(\\d{4})","$1-$2 $3",["[4-79]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1-$2 $3",["1(?:[02469]|[378][1-9]|53)|8","1(?:[02469]|[37][1-9]|53|8(?:[1-46-9]|5[7-9]))|8"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1-$2 $3",["3"],"0$1"],["(\\d)(\\d{3})(\\d{2})(\\d{4})","$1-$2-$3-$4",["1(?:[367]|80)"]],["(\\d{3})(\\d{3})(\\d{4})","$1-$2 $3",["15"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1-$2 $3",["1"],"0$1"]],"0"],MZ:["258","00","(?:2|8\\d)\\d{7}",[8,9],[["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["2|8[2-79]"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8"]]]],NA:["264","00","[68]\\d{7,8}",[8,9],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["88"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["6"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["87"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["8"],"0$1"]],"0"],NC:["687","00","(?:050|[2-57-9]\\d\\d)\\d{3}",[6],[["(\\d{2})(\\d{2})(\\d{2})","$1.$2.$3",["[02-57-9]"]]]],NE:["227","00","[027-9]\\d{7}",[8],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["08"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[089]|2[013]|7[0467]"]]]],NF:["672","00","[13]\\d{5}",[6],[["(\\d{2})(\\d{4})","$1 $2",["1[0-3]"]],["(\\d)(\\d{5})","$1 $2",["[13]"]]],0,0,"([0-258]\\d{4})$","3$1"],NG:["234","009","38\\d{6}|[78]\\d{9,13}|(?:20|9\\d)\\d{8}",[8,10,11,12,13,14],[["(\\d{2})(\\d{3})(\\d{2,3})","$1 $2 $3",["3"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["[7-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["20[129]"],"0$1"],["(\\d{4})(\\d{2})(\\d{4})","$1 $2 $3",["2"],"0$1"],["(\\d{3})(\\d{4})(\\d{4,5})","$1 $2 $3",["[78]"],"0$1"],["(\\d{3})(\\d{5})(\\d{5,6})","$1 $2 $3",["[78]"],"0$1"]],"0"],NI:["505","00","(?:1800|[25-8]\\d{3})\\d{4}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[125-8]"]]]],NL:["31","00","(?:[124-7]\\d\\d|3(?:[02-9]\\d|1[0-8]))\\d{6}|8\\d{6,9}|9\\d{6,10}|1\\d{4,5}",[5,6,7,8,9,10,11],[["(\\d{3})(\\d{4,7})","$1 $2",["[89]0"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["66"],"0$1"],["(\\d)(\\d{8})","$1 $2",["6"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["1[16-8]|2[259]|3[124]|4[17-9]|5[124679]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[1-578]|91"],"0$1"],["(\\d{3})(\\d{3})(\\d{5})","$1 $2 $3",["9"],"0$1"]],"0"],NO:["47","00","(?:0|[2-9]\\d{3})\\d{4}",[5,8],[["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["8"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-79]"]]],0,0,0,0,0,"[02-689]|7[0-8]"],NP:["977","00","(?:1\\d|9)\\d{9}|[1-9]\\d{7}",[8,10,11],[["(\\d)(\\d{7})","$1-$2",["1[2-6]"],"0$1"],["(\\d{2})(\\d{6})","$1-$2",["1[01]|[2-8]|9(?:[1-59]|[67][2-6])"],"0$1"],["(\\d{3})(\\d{7})","$1-$2",["9"]]],"0"],NR:["674","00","(?:444|(?:55|8\\d)\\d|666)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[4-68]"]]]],NU:["683","00","(?:[4-7]|888\\d)\\d{3}",[4,7],[["(\\d{3})(\\d{4})","$1 $2",["8"]]]],NZ:["64","0(?:0|161)","[1289]\\d{9}|50\\d{5}(?:\\d{2,3})?|[27-9]\\d{7,8}|(?:[34]\\d|6[0-35-9])\\d{6}|8\\d{4,6}",[5,6,7,8,9,10],[["(\\d{2})(\\d{3,8})","$1 $2",["8[1-79]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2,3})","$1 $2 $3",["50[036-8]|8|90","50(?:[0367]|88)|8|90"],"0$1"],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["24|[346]|7[2-57-9]|9[2-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["2(?:10|74)|[589]"],"0$1"],["(\\d{2})(\\d{3,4})(\\d{4})","$1 $2 $3",["1|2[028]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,5})","$1 $2 $3",["2(?:[169]|7[0-35-9])|7"],"0$1"]],"0",0,0,0,0,0,0,"00"],OM:["968","00","(?:1505|[279]\\d{3}|500)\\d{4}|800\\d{5,6}",[7,8,9],[["(\\d{3})(\\d{4,6})","$1 $2",["[58]"]],["(\\d{2})(\\d{6})","$1 $2",["2"]],["(\\d{4})(\\d{4})","$1 $2",["[179]"]]]],PA:["507","00","(?:00800|8\\d{3})\\d{6}|[68]\\d{7}|[1-57-9]\\d{6}",[7,8,10,11],[["(\\d{3})(\\d{4})","$1-$2",["[1-57-9]"]],["(\\d{4})(\\d{4})","$1-$2",["[68]"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"]]]],PE:["51","00|19(?:1[124]|77|90)00","(?:[14-8]|9\\d)\\d{7}",[8,9],[["(\\d{3})(\\d{5})","$1 $2",["80"],"(0$1)"],["(\\d)(\\d{7})","$1 $2",["1"],"(0$1)"],["(\\d{2})(\\d{6})","$1 $2",["[4-8]"],"(0$1)"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["9"]]],"0",0,0,0,0,0,0,"00"," Anexo "],PF:["689","00","4\\d{5}(?:\\d{2})?|8\\d{7,8}",[6,8,9],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["44"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["4|8[7-9]"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"]]]],PG:["675","00|140[1-3]","(?:180|[78]\\d{3})\\d{4}|(?:[2-589]\\d|64)\\d{5}",[7,8],[["(\\d{3})(\\d{4})","$1 $2",["18|[2-69]|85"]],["(\\d{4})(\\d{4})","$1 $2",["[78]"]]],0,0,0,0,0,0,0,"00"],PH:["63","00","(?:[2-7]|9\\d)\\d{8}|2\\d{5}|(?:1800|8)\\d{7,9}",[6,8,9,10,11,12,13],[["(\\d)(\\d{5})","$1 $2",["2"],"(0$1)"],["(\\d{4})(\\d{4,6})","$1 $2",["3(?:23|39|46)|4(?:2[3-6]|[35]9|4[26]|76)|544|88[245]|(?:52|64|86)2","3(?:230|397|461)|4(?:2(?:35|[46]4|51)|396|4(?:22|63)|59[347]|76[15])|5(?:221|446)|642[23]|8(?:622|8(?:[24]2|5[13]))"],"(0$1)"],["(\\d{5})(\\d{4})","$1 $2",["346|4(?:27|9[35])|883","3469|4(?:279|9(?:30|56))|8834"],"(0$1)"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["2"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[3-7]|8[2-8]"],"(0$1)"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[89]"],"0$1"],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["1"]],["(\\d{4})(\\d{1,2})(\\d{3})(\\d{4})","$1 $2 $3 $4",["1"]]],"0"],PK:["92","00","122\\d{6}|[24-8]\\d{10,11}|9(?:[013-9]\\d{8,10}|2(?:[01]\\d\\d|2(?:[06-8]\\d|1[01]))\\d{7})|(?:[2-8]\\d{3}|92(?:[0-7]\\d|8[1-9]))\\d{6}|[24-9]\\d{8}|[89]\\d{7}",[8,9,10,11,12],[["(\\d{3})(\\d{3})(\\d{2,7})","$1 $2 $3",["[89]0"],"0$1"],["(\\d{4})(\\d{5})","$1 $2",["1"]],["(\\d{3})(\\d{6,7})","$1 $2",["2(?:3[2358]|4[2-4]|9[2-8])|45[3479]|54[2-467]|60[468]|72[236]|8(?:2[2-689]|3[23578]|4[3478]|5[2356])|9(?:2[2-8]|3[27-9]|4[2-6]|6[3569]|9[25-8])","9(?:2[3-8]|98)|(?:2(?:3[2358]|4[2-4]|9[2-8])|45[3479]|54[2-467]|60[468]|72[236]|8(?:2[2-689]|3[23578]|4[3478]|5[2356])|9(?:22|3[27-9]|4[2-6]|6[3569]|9[25-7]))[2-9]"],"(0$1)"],["(\\d{2})(\\d{7,8})","$1 $2",["(?:2[125]|4[0-246-9]|5[1-35-7]|6[1-8]|7[14]|8[16]|91)[2-9]"],"(0$1)"],["(\\d{5})(\\d{5})","$1 $2",["58"],"(0$1)"],["(\\d{3})(\\d{7})","$1 $2",["3"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["2[125]|4[0-246-9]|5[1-35-7]|6[1-8]|7[14]|8[16]|91"],"(0$1)"],["(\\d{3})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["[24-9]"],"(0$1)"]],"0"],PL:["48","00","(?:6|8\\d\\d)\\d{7}|[1-9]\\d{6}(?:\\d{2})?|[26]\\d{5}",[6,7,8,9,10],[["(\\d{5})","$1",["19"]],["(\\d{3})(\\d{3})","$1 $2",["11|20|64"]],["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["(?:1[2-8]|2[2-69]|3[2-4]|4[1-468]|5[24-689]|6[1-3578]|7[14-7]|8[1-79]|9[145])1","(?:1[2-8]|2[2-69]|3[2-4]|4[1-468]|5[24-689]|6[1-3578]|7[14-7]|8[1-79]|9[145])19"]],["(\\d{3})(\\d{2})(\\d{2,3})","$1 $2 $3",["64"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["21|39|45|5[0137]|6[0469]|7[02389]|8(?:0[14]|8)"]],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["1[2-8]|[2-7]|8[1-79]|9[145]"]],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["8"]]]],PM:["508","00","[45]\\d{5}|(?:708|8\\d\\d)\\d{6}",[6,9],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["[45]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["7"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0$1"]],"0"],PR:["1","011","(?:[589]\\d\\d|787)\\d{7}",[10],0,"1",0,0,0,0,"787|939"],PS:["970","00","[2489]2\\d{6}|(?:1\\d|5)\\d{8}",[8,9,10],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[2489]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["5"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1"]]],"0"],PT:["351","00","1693\\d{5}|(?:[26-9]\\d|30)\\d{7}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["2[12]"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["16|[236-9]"]]]],PW:["680","01[12]","(?:[24-8]\\d\\d|345|900)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[2-9]"]]]],PY:["595","00","59\\d{4,6}|9\\d{5,10}|(?:[2-46-8]\\d|5[0-8])\\d{4,7}",[6,7,8,9,10,11],[["(\\d{3})(\\d{3,6})","$1 $2",["[2-9]0"],"0$1"],["(\\d{2})(\\d{5})","$1 $2",["[26]1|3[289]|4[1246-8]|7[1-3]|8[1-36]"],"(0$1)"],["(\\d{3})(\\d{4,5})","$1 $2",["2[279]|3[13-5]|4[359]|5|6(?:[34]|7[1-46-8])|7[46-8]|85"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["2[14-68]|3[26-9]|4[1246-8]|6(?:1|75)|7[1-35]|8[1-36]"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["87"]],["(\\d{3})(\\d{6})","$1 $2",["9(?:[5-79]|8[1-7])"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[2-8]"],"0$1"],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["9"]]],"0"],QA:["974","00","800\\d{4}|(?:2|800)\\d{6}|(?:0080|[3-7])\\d{7}",[7,8,9,11],[["(\\d{3})(\\d{4})","$1 $2",["2[16]|8"]],["(\\d{4})(\\d{4})","$1 $2",["[3-7]"]]]],RE:["262","00","709\\d{6}|(?:26|[689]\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[26-9]"],"0$1"]],"0",0,0,0,0,0,[["26(?:2\\d\\d|3(?:0\\d|1[0-6]))\\d{4}"],["(?:69(?:2\\d\\d|3(?:[06][0-6]|1[013]|2[0-2]|3[0-39]|4\\d|5[0-5]|7[0-37]|8[0-8]|9[0-479]))|7092[0-3])\\d{4}"],["80\\d{7}"],["89[1-37-9]\\d{6}"],0,0,0,0,["9(?:399[0-3]|479[0-5]|76(?:2[278]|3[0-37]))\\d{4}"],["8(?:1[019]|2[0156]|84|90)\\d{6}"]]],RO:["40","00","(?:[236-8]\\d|90)\\d{7}|[23]\\d{5}",[6,9],[["(\\d{3})(\\d{3})","$1 $2",["2[3-6]","2[3-6]\\d9"],"0$1"],["(\\d{2})(\\d{4})","$1 $2",["219|31"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[23]1"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[236-9]"],"0$1"]],"0",0,0,0,0,0,0,0," int "],RS:["381","00","38[02-9]\\d{6,9}|6\\d{7,9}|90\\d{4,8}|38\\d{5,6}|(?:7\\d\\d|800)\\d{3,9}|(?:[12]\\d|3[0-79])\\d{5,10}",[6,7,8,9,10,11,12],[["(\\d{3})(\\d{3,9})","$1 $2",["(?:2[389]|39)0|[7-9]"],"0$1"],["(\\d{2})(\\d{5,10})","$1 $2",["[1-36]"],"0$1"]],"0"],RU:["7","810","8\\d{13}|[347-9]\\d{9}",[10,14],[["(\\d{4})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["7(?:1[0-8]|2[1-9])","7(?:1(?:[0-356]2|4[29]|7|8[27])|2(?:1[23]|[2-9]2))","7(?:1(?:[0-356]2|4[29]|7|8[27])|2(?:13[03-69]|62[013-9]))|72[1-57-9]2"],"8 ($1)",1],["(\\d{5})(\\d)(\\d{2})(\\d{2})","$1 $2 $3 $4",["7(?:1[0-68]|2[1-9])","7(?:1(?:[06][3-6]|[18]|2[35]|[3-5][3-5])|2(?:[13][3-5]|[24-689]|7[457]))","7(?:1(?:0(?:[356]|4[023])|[18]|2(?:3[013-9]|5)|3[45]|43[013-79]|5(?:3[1-8]|4[1-7]|5)|6(?:3[0-35-9]|[4-6]))|2(?:1(?:3[178]|[45])|[24-689]|3[35]|7[457]))|7(?:14|23)4[0-8]|71(?:33|45)[1-79]"],"8 ($1)",1],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["7"],"8 ($1)",1],["(\\d{3})(\\d{3})(\\d{2})(\\d{2})","$1 $2-$3-$4",["[349]|8(?:[02-7]|1[1-8])"],"8 ($1)",1],["(\\d{4})(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3 $4",["8"],"8 ($1)"]],"8",0,0,0,0,"3[04-689]|[489]",0,"8~10"],RW:["250","00","(?:06|[27]\\d\\d|[89]00)\\d{6}",[8,9],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["0"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["2"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[7-9]"],"0$1"]],"0"],SA:["966","00","92\\d{7}|(?:[15]|8\\d)\\d{8}",[9,10],[["(\\d{4})(\\d{5})","$1 $2",["9"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["1"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["5"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["81"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"]]],"0"],SB:["677","0[01]","[6-9]\\d{6}|[1-6]\\d{4}",[5,7],[["(\\d{2})(\\d{5})","$1 $2",["6[89]|7|8[4-9]|9(?:[1-8]|9[0-8])"]]]],SC:["248","010|0[0-2]","(?:[2489]\\d|64)\\d{5}",[7],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[246]|9[57]"]]],0,0,0,0,0,0,0,"00"],SD:["249","00","[19]\\d{8}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[19]"],"0$1"]],"0"],SE:["46","00","(?:[26]\\d\\d|9)\\d{9}|[1-9]\\d{8}|[1-689]\\d{7}|[1-4689]\\d{6}|2\\d{5}",[6,7,8,9,10,12],[["(\\d{2})(\\d{2,3})(\\d{2})","$1-$2 $3",["20"],"0$1",0,"$1 $2 $3"],["(\\d{3})(\\d{4})","$1-$2",["9(?:00|39|44|9)"],"0$1",0,"$1 $2"],["(\\d{2})(\\d{3})(\\d{2})","$1-$2 $3",["[12][136]|3[356]|4[0246]|6[03]|90[1-9]"],"0$1",0,"$1 $2 $3"],["(\\d)(\\d{2,3})(\\d{2})(\\d{2})","$1-$2 $3 $4",["8"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2,3})(\\d{2})","$1-$2 $3",["1[2457]|2(?:[247-9]|5[0138])|3[0247-9]|4[1357-9]|5[0-35-9]|6(?:[125689]|4[02-57]|7[0-2])|9(?:[125-8]|3[02-5]|4[0-3])"],"0$1",0,"$1 $2 $3"],["(\\d{3})(\\d{2,3})(\\d{3})","$1-$2 $3",["9(?:00|39|44)"],"0$1",0,"$1 $2 $3"],["(\\d{2})(\\d{2,3})(\\d{2})(\\d{2})","$1-$2 $3 $4",["1[13689]|2[0136]|3[1356]|4[0246]|54|6[03]|90[1-9]"],"0$1",0,"$1 $2 $3 $4"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1-$2 $3 $4",["10|7"],"0$1",0,"$1 $2 $3 $4"],["(\\d)(\\d{3})(\\d{3})(\\d{2})","$1-$2 $3 $4",["8"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1-$2 $3 $4",["[13-5]|2(?:[247-9]|5[0138])|6(?:[124-689]|7[0-2])|9(?:[125-8]|3[02-5]|4[0-3])"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2})(\\d{2})(\\d{3})","$1-$2 $3 $4",["9"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1-$2 $3 $4 $5",["[26]"],"0$1",0,"$1 $2 $3 $4 $5"]],"0"],SG:["65","0[0-3]\\d","(?:(?:1\\d|8)\\d\\d|7000)\\d{7}|[3689]\\d{7}",[8,10,11],[["(\\d{4})(\\d{4})","$1 $2",["[369]|8(?:0[1-9]|[1-9])"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"]],["(\\d{4})(\\d{4})(\\d{3})","$1 $2 $3",["7"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["1"]]]],SH:["290","00","(?:[256]\\d|8)\\d{3}",[4,5],0,0,0,0,0,0,"[256]"],SI:["386","00|10(?:22|66|88|99)","[1-7]\\d{7}|8\\d{4,7}|90\\d{4,6}",[5,6,7,8],[["(\\d{2})(\\d{3,6})","$1 $2",["8[09]|9"],"0$1"],["(\\d{3})(\\d{5})","$1 $2",["59|8"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[37][01]|4[0139]|51|6"],"0$1"],["(\\d)(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[1-57]"],"(0$1)"]],"0",0,0,0,0,0,0,"00"],SJ:["47","00","0\\d{4}|(?:[489]\\d|79)\\d{6}",[5,8],0,0,0,0,0,0,"79"],SK:["421","00","[2-689]\\d{8}|[2-59]\\d{6}|[2-5]\\d{5}",[6,7,9],[["(\\d)(\\d{2})(\\d{3,4})","$1 $2 $3",["21"],"0$1"],["(\\d{2})(\\d{2})(\\d{2,3})","$1 $2 $3",["[3-5][1-8]1","[3-5][1-8]1[67]"],"0$1"],["(\\d)(\\d{3})(\\d{3})(\\d{2})","$1/$2 $3 $4",["2"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[689]"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1/$2 $3 $4",["[3-5]"],"0$1"]],"0"],SL:["232","00","(?:[237-9]\\d|66)\\d{6}",[8],[["(\\d{2})(\\d{6})","$1 $2",["[236-9]"],"(0$1)"]],"0"],SM:["378","00","(?:0549|[5-7]\\d)\\d{6}",[8,10],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-7]"]],["(\\d{4})(\\d{6})","$1 $2",["0"]]],0,0,"([89]\\d{5})$","0549$1"],SN:["221","00","(?:[378]\\d|93)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"]],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[379]"]]]],SO:["252","00","[346-9]\\d{8}|[12679]\\d{7}|[1-5]\\d{6}|[1348]\\d{5}",[6,7,8,9],[["(\\d{2})(\\d{4})","$1 $2",["8[125]"]],["(\\d{6})","$1",["[134]"]],["(\\d)(\\d{6})","$1 $2",["[15]|2[0-79]|3[0-46-8]|4[0-7]"]],["(\\d)(\\d{7})","$1 $2",["(?:2|90)4|[67]"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[348]|64|79|90"]],["(\\d{2})(\\d{5,7})","$1 $2",["1|28|6[0-35-9]|77|9[2-9]"]]],"0"],SR:["597","00","(?:[2-5]|68|[78]\\d)\\d{5}",[6,7],[["(\\d{2})(\\d{2})(\\d{2})","$1-$2-$3",["56"]],["(\\d{3})(\\d{3})","$1-$2",["[2-5]"]],["(\\d{3})(\\d{4})","$1-$2",["[6-8]"]]]],SS:["211","00","[19]\\d{8}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[19]"],"0$1"]],"0"],ST:["239","00","(?:22|9\\d)\\d{5}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[29]"]]]],SV:["503","00","[267]\\d{7}|(?:80\\d|900)\\d{4}(?:\\d{4})?",[7,8,11],[["(\\d{3})(\\d{4})","$1 $2",["[89]"]],["(\\d{4})(\\d{4})","$1 $2",["[267]"]],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["[89]"]]]],SX:["1","011","7215\\d{6}|(?:[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"(5\\d{6})$|1","721$1",0,"721"],SY:["963","00","[1-359]\\d{8}|[1-5]\\d{7}",[8,9],[["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[1-4]|5[1-3]"],"0$1",1],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[59]"],"0$1",1]],"0"],SZ:["268","00","0800\\d{4}|(?:[237]\\d|900)\\d{6}",[8,9],[["(\\d{4})(\\d{4})","$1 $2",["[0237]"]],["(\\d{5})(\\d{4})","$1 $2",["9"]]]],TA:["290","00","8\\d{3}",[4],0,0,0,0,0,0,"8"],TC:["1","011","(?:[58]\\d\\d|649|900)\\d{7}",[10],0,"1",0,"([2-479]\\d{6})$|1","649$1",0,"649"],TD:["235","00|16","(?:22|[689]\\d|77)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[26-9]"]]],0,0,0,0,0,0,0,"00"],TG:["228","00","[279]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[279]"]]]],TH:["66","00[1-9]","(?:001800|[2-57]|[689]\\d)\\d{7}|1\\d{7,9}",[8,9,10,13],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[13-9]"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1"]]],"0"],TJ:["992","810","[0-57-9]\\d{8}",[9],[["(\\d{6})(\\d)(\\d{2})","$1 $2 $3",["331","3317"]],["(\\d{3})(\\d{2})(\\d{4})","$1 $2 $3",["44[02-479]|[34]7"]],["(\\d{4})(\\d)(\\d{4})","$1 $2 $3",["3(?:[1245]|3[12])"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[0-57-9]"]]],0,0,0,0,0,0,0,"8~10"],TK:["690","00","[2-47]\\d{3,6}",[4,5,6,7]],TL:["670","00","7\\d{7}|(?:[2-47]\\d|[89]0)\\d{5}",[7,8],[["(\\d{3})(\\d{4})","$1 $2",["[2-489]|70"]],["(\\d{4})(\\d{4})","$1 $2",["7"]]]],TM:["993","810","(?:[1-6]\\d|71)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2-$3-$4",["12"],"(8 $1)"],["(\\d{3})(\\d)(\\d{2})(\\d{2})","$1 $2-$3-$4",["[1-5]"],"(8 $1)"],["(\\d{2})(\\d{6})","$1 $2",["[67]"],"8 $1"]],"8",0,0,0,0,0,0,"8~10"],TN:["216","00","[2-57-9]\\d{7}",[8],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[2-57-9]"]]]],TO:["676","00","(?:0800|(?:[5-8]\\d\\d|999)\\d)\\d{3}|[2-8]\\d{4}",[5,7],[["(\\d{2})(\\d{3})","$1-$2",["[2-4]|50|6[09]|7[0-24-69]|8[05]"]],["(\\d{4})(\\d{3})","$1 $2",["0"]],["(\\d{3})(\\d{4})","$1 $2",["[5-9]"]]]],TR:["90","00","4\\d{6}|8\\d{11,12}|(?:[2-58]\\d\\d|900)\\d{7}",[7,10,12,13],[["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["512|8[01589]|90"],"0$1",1],["(\\d{3})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["5(?:[0-59]|61)","5(?:[0-59]|61[06])","5(?:[0-59]|61[06]1)"],"0$1",1],["(\\d{3})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[24][1-8]|3[1-9]"],"(0$1)",1],["(\\d{3})(\\d{3})(\\d{6,7})","$1 $2 $3",["80"],"0$1",1]],"0"],TT:["1","011","(?:[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-46-8]\\d{6})$|1","868$1",0,"868"],TV:["688","00","(?:2|7\\d\\d|90)\\d{4}",[5,6,7],[["(\\d{2})(\\d{3})","$1 $2",["2"]],["(\\d{2})(\\d{4})","$1 $2",["90"]],["(\\d{2})(\\d{5})","$1 $2",["7"]]]],TW:["886","0(?:0[25-79]|19)","[2-689]\\d{8}|7\\d{9,10}|[2-8]\\d{7}|2\\d{6}",[7,8,9,10,11],[["(\\d{2})(\\d)(\\d{4})","$1 $2 $3",["202"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[258]0"],"0$1"],["(\\d)(\\d{3,4})(\\d{4})","$1 $2 $3",["[23568]|4(?:0[02-48]|[1-47-9])|7[1-9]","[23568]|4(?:0[2-48]|[1-47-9])|(?:400|7)[1-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[49]"],"0$1"],["(\\d{2})(\\d{4})(\\d{4,5})","$1 $2 $3",["7"],"0$1"]],"0",0,0,0,0,0,0,0,"#"],TZ:["255","00[056]","(?:[25-8]\\d|41|90)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{4})","$1 $2 $3",["[89]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[24]"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["5"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[67]"],"0$1"]],"0"],UA:["380","00","[89]\\d{9}|[3-9]\\d{8}",[9,10],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["6[12][29]|(?:3[1-8]|4[136-8]|5[12457]|6[49])2|(?:56|65)[24]","6[12][29]|(?:35|4[1378]|5[12457]|6[49])2|(?:56|65)[24]|(?:3[1-46-8]|46)2[013-9]"],"0$1"],["(\\d{4})(\\d{5})","$1 $2",["3[1-8]|4(?:[1367]|[45][6-9]|8[4-6])|5(?:[1-5]|6[0135689]|7[4-6])|6(?:[12][3-7]|[459])","3[1-8]|4(?:[1367]|[45][6-9]|8[4-6])|5(?:[1-5]|6(?:[015689]|3[02389])|7[4-6])|6(?:[12][3-7]|[459])"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[3-7]|89|9[1-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["[89]"],"0$1"]],"0",0,0,0,0,0,0,"0~0"],UG:["256","00[057]","800\\d{6}|(?:[29]0|[347]\\d)\\d{7}",[9],[["(\\d{4})(\\d{5})","$1 $2",["202","2024"],"0$1"],["(\\d{3})(\\d{6})","$1 $2",["[27-9]|4(?:6[45]|[7-9])"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["[34]"],"0$1"]],"0"],US:["1","011","[2-9]\\d{9}|3\\d{6}",[10],[["(\\d{3})(\\d{4})","$1-$2",["310"],0,1],["(\\d{3})(\\d{3})(\\d{4})","($1) $2-$3",["[2-9]"],0,1,"$1-$2-$3"]],"1",0,0,0,0,0,[["(?:3052(?:0[0-8]|[1-9]\\d)|5056(?:[0-35-9]\\d|4[468]))\\d{4}|(?:305[3-9]|472[24]|505[2-57-9]|983[2-47-9])\\d{6}|(?:2(?:0[1-35-9]|1[02-9]|2[03-57-9]|3[1459]|4[08]|5[1-46]|6[0279]|7[0269]|8[13])|3(?:0[1-47-9]|1[02-9]|2[0135-79]|3[0-24679]|4[167]|5[0-2]|6[01349]|8[056])|4(?:0[124-9]|1[02-579]|2[3-5]|3[0245]|4[023578]|58|6[349]|7[0589]|8[04])|5(?:0[1-47-9]|1[0235-8]|20|3[0149]|4[01]|5[179]|6[1-47]|7[0-5]|8[0256])|6(?:0[1-35-9]|1[024-9]|2[03689]|3[016]|4[0156]|5[01679]|6[0-279]|78|8[0-29])|7(?:0[1-46-8]|1[2-9]|2[04-8]|3[0-247]|4[037]|5[47]|6[02359]|7[0-59]|8[156])|8(?:0[1-68]|1[02-8]|2[068]|3[0-2589]|4[03578]|5[046-9]|6[02-5]|7[028])|9(?:0[1346-9]|1[02-9]|2[0589]|3[0146-8]|4[01357-9]|5[12469]|7[0-389]|8[04-69]))[2-9]\\d{6}"],[""],["8(?:00|33|44|55|66|77|88)[2-9]\\d{6}"],["900[2-9]\\d{6}"],["52(?:3(?:[2-46-9][02-9]\\d|5(?:[02-46-9]\\d|5[0-46-9]))|4(?:[2-478][02-9]\\d|5(?:[034]\\d|2[024-9]|5[0-46-9])|6(?:0[1-9]|[2-9]\\d)|9(?:[05-9]\\d|2[0-5]|49)))\\d{4}|52[34][2-9]1[02-9]\\d{4}|5(?:00|2[125-9]|33|44|66|77|88)[2-9]\\d{6}"],0,0,0,["305209\\d{4}"]]],UY:["598","0(?:0|1[3-9]\\d)","0004\\d{2,9}|[1249]\\d{7}|(?:[49]\\d|80)\\d{5}",[6,7,8,9,10,11,12,13],[["(\\d{3})(\\d{3,4})","$1 $2",["0"]],["(\\d{3})(\\d{4})","$1 $2",["[49]0|8"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["9"],"0$1"],["(\\d{4})(\\d{4})","$1 $2",["[124]"]],["(\\d{3})(\\d{3})(\\d{2,4})","$1 $2 $3",["0"]],["(\\d{3})(\\d{3})(\\d{3})(\\d{2,4})","$1 $2 $3 $4",["0"]]],"0",0,0,0,0,0,0,"00"," int. "],UZ:["998","00","(?:20|33|[5-9]\\d)\\d{7}",[9],[["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[235-9]"]]]],VA:["39","00","0\\d{5,10}|3[0-8]\\d{7,10}|55\\d{8}|8\\d{5}(?:\\d{2,4})?|(?:1\\d|39)\\d{7,8}",[6,7,8,9,10,11,12],0,0,0,0,0,0,"06698"],VC:["1","011","(?:[58]\\d\\d|784|900)\\d{7}",[10],0,"1",0,"([2-7]\\d{6})$|1","784$1",0,"784"],VE:["58","00","[68]00\\d{7}|(?:[24]\\d|[59]0)\\d{8}",[10],[["(\\d{3})(\\d{7})","$1-$2",["[24-689]"],"0$1"]],"0"],VG:["1","011","(?:284|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-578]\\d{6})$|1","284$1",0,"284"],VI:["1","011","[58]\\d{9}|(?:34|90)0\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","340$1",0,"340"],VN:["84","00","[12]\\d{9}|[135-9]\\d{8}|[16]\\d{7}|[16-8]\\d{6}",[7,8,9,10],[["(\\d{2})(\\d{5})","$1 $2",["80"],"0$1",1],["(\\d{4})(\\d{4,6})","$1 $2",["1"],0,1],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["6"],"0$1",1],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[357-9]"],"0$1",1],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["2[48]"],"0$1",1],["(\\d{3})(\\d{4})(\\d{3})","$1 $2 $3",["2"],"0$1",1]],"0"],VU:["678","00","[57-9]\\d{6}|(?:[238]\\d|48)\\d{3}",[5,7],[["(\\d{3})(\\d{4})","$1 $2",["[57-9]"]]]],WF:["681","00","(?:40|72|8\\d{4})\\d{4}|[89]\\d{5}",[6,9],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["[47-9]"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"]]]],WS:["685","0","(?:[2-6]|8\\d{5})\\d{4}|[78]\\d{6}|[68]\\d{5}",[5,6,7,10],[["(\\d{5})","$1",["[2-5]|6[1-9]"]],["(\\d{3})(\\d{3,7})","$1 $2",["[68]"]],["(\\d{2})(\\d{5})","$1 $2",["7"]]]],XK:["383","00","2\\d{7,8}|3\\d{7,11}|(?:4\\d\\d|[89]00)\\d{5}",[8,9,10,11,12],[["(\\d{3})(\\d{5})","$1 $2",["[89]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[2-4]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["2|39"],"0$1"],["(\\d{2})(\\d{7,10})","$1 $2",["3"],"0$1"]],"0"],YE:["967","00","(?:1|7\\d)\\d{7}|[1-7]\\d{6}",[7,8,9],[["(\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["[1-6]|7(?:[24-6]|8[0-7])"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["7"],"0$1"]],"0"],YT:["262","00","7093\\d{5}|(?:80|9\\d)\\d{7}|(?:26|63)9\\d{6}",[9],0,"0",0,0,0,0,0,[["269(?:0[0-467]|15|5[0-4]|6\\d|[78]0)\\d{4}"],["(?:639(?:0[0-79]|1[019]|[267]\\d|3[09]|40|5[05-9]|9[04-79])|7093[5-7])\\d{4}"],["80\\d{7}"],0,0,0,0,0,["9(?:(?:39|47)8[01]|769\\d)\\d{4}"]]],ZA:["27","00","[1-79]\\d{8}|8\\d{4,9}",[5,6,7,8,9,10],[["(\\d{2})(\\d{3,4})","$1 $2",["8[1-4]"],"0$1"],["(\\d{2})(\\d{3})(\\d{2,3})","$1 $2 $3",["8[1-4]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["860"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[1-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"],"0$1"]],"0"],ZM:["260","00","800\\d{6}|(?:21|63|[79]\\d)\\d{7}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[28]"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["[79]"],"0$1"]],"0"],ZW:["263","00","2(?:[0-57-9]\\d{6,8}|6[0-24-9]\\d{6,7})|[38]\\d{9}|[35-8]\\d{8}|[3-6]\\d{7}|[1-689]\\d{6}|[1-3569]\\d{5}|[1356]\\d{4}",[5,6,7,8,9,10],[["(\\d{3})(\\d{3,5})","$1 $2",["2(?:0[45]|2[278]|[49]8)|3(?:[09]8|17)|6(?:[29]8|37|75)|[23][78]|(?:33|5[15]|6[68])[78]"],"0$1"],["(\\d)(\\d{3})(\\d{2,4})","$1 $2 $3",["[49]"],"0$1"],["(\\d{3})(\\d{4})","$1 $2",["80"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["24|8[13-59]|(?:2[05-79]|39|5[45]|6[15-8])2","2(?:02[014]|4|[56]20|[79]2)|392|5(?:42|525)|6(?:[16-8]21|52[013])|8[13-59]"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["7"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["2(?:1[39]|2[0157]|[378]|[56][14])|3(?:12|29)","2(?:1[39]|2[0157]|[378]|[56][14])|3(?:123|29)"],"0$1"],["(\\d{4})(\\d{6})","$1 $2",["8"],"0$1"],["(\\d{2})(\\d{3,5})","$1 $2",["1|2(?:0[0-36-9]|12|29|[56])|3(?:1[0-689]|[24-6])|5(?:[0236-9]|1[2-4])|6(?:[013-59]|7[0-46-9])|(?:33|55|6[68])[0-69]|(?:29|3[09]|62)[0-79]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["29[013-9]|39|54"],"0$1"],["(\\d{4})(\\d{3,5})","$1 $2",["(?:25|54)8","258|5483"],"0$1"]],"0"]},nonGeographic:{800:["800",0,"(?:00|[1-9]\\d)\\d{6}",[8],[["(\\d{4})(\\d{4})","$1 $2",["\\d"]]],0,0,0,0,0,0,[0,0,["(?:00|[1-9]\\d)\\d{6}"]]],808:["808",0,"[1-9]\\d{7}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[1-9]"]]],0,0,0,0,0,0,[0,0,0,0,0,0,0,0,0,["[1-9]\\d{7}"]]],870:["870",0,"7\\d{11}|[235-7]\\d{8}",[9,12],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[235-7]"]]],0,0,0,0,0,0,[0,["(?:[356]|774[45])\\d{8}|7[6-8]\\d{7}"],0,0,0,0,0,0,["2\\d{8}",[9]]]],878:["878",0,"10\\d{10}",[12],[["(\\d{2})(\\d{5})(\\d{5})","$1 $2 $3",["1"]]],0,0,0,0,0,0,[0,0,0,0,0,0,0,0,["10\\d{10}"]]],881:["881",0,"6\\d{9}|[0-36-9]\\d{8}",[9,10],[["(\\d)(\\d{3})(\\d{5})","$1 $2 $3",["[0-37-9]"]],["(\\d)(\\d{3})(\\d{5,6})","$1 $2 $3",["6"]]],0,0,0,0,0,0,[0,["6\\d{9}|[0-36-9]\\d{8}"]]],882:["882",0,"[13]\\d{6}(?:\\d{2,5})?|[19]\\d{7}|(?:[25]\\d\\d|4)\\d{7}(?:\\d{2})?",[7,8,9,10,11,12],[["(\\d{2})(\\d{5})","$1 $2",["16|342"]],["(\\d{2})(\\d{6})","$1 $2",["49"]],["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["1[36]|9"]],["(\\d{2})(\\d{4})(\\d{3})","$1 $2 $3",["3[23]"]],["(\\d{2})(\\d{3,4})(\\d{4})","$1 $2 $3",["16"]],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["10|23|3(?:[15]|4[57])|4|51"]],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["34"]],["(\\d{2})(\\d{4,5})(\\d{5})","$1 $2 $3",["[1-35]"]]],0,0,0,0,0,0,[0,["342\\d{4}|(?:337|49)\\d{6}|(?:3(?:2|47|7\\d{3})|50\\d{3})\\d{7}",[7,8,9,10,12]],0,0,0,["348[57]\\d{7}",[11]],0,0,["1(?:3(?:0[0347]|[13][0139]|2[035]|4[013568]|6[0459]|7[06]|8[15-8]|9[0689])\\d{4}|6\\d{5,10})|(?:345\\d|9[89])\\d{6}|(?:10|2(?:3|85\\d)|3(?:[15]|[69]\\d\\d)|4[15-8]|51)\\d{8}"]]],883:["883",0,"(?:[1-4]\\d|51)\\d{6,10}",[8,9,10,11,12],[["(\\d{3})(\\d{3})(\\d{2,8})","$1 $2 $3",["[14]|2[24-689]|3[02-689]|51[24-9]"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["510"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["21"]],["(\\d{4})(\\d{4})(\\d{4})","$1 $2 $3",["51[13]"]],["(\\d{3})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["[235]"]]],0,0,0,0,0,0,[0,0,0,0,0,0,0,0,["(?:2(?:00\\d\\d|10)|(?:370[1-9]|51\\d0)\\d)\\d{7}|51(?:00\\d{5}|[24-9]0\\d{4,7})|(?:1[0-79]|2[24-689]|3[02-689]|4[0-4])0\\d{5,9}"]]],888:["888",0,"\\d{11}",[11],[["(\\d{3})(\\d{3})(\\d{5})","$1 $2 $3"]],0,0,0,0,0,0,[0,0,0,0,0,0,["\\d{11}"]]],979:["979",0,"[1359]\\d{8}",[9],[["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["[1359]"]]],0,0,0,0,0,0,[0,0,0,["[1359]\\d{8}"]]]}};function lm(e){return lm="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},lm(e)}function cm(e){var t=pm();return function(){var n,i=gm(e);if(t){var o=gm(this).constructor;n=Reflect.construct(i,arguments,o)}else n=i.apply(this,arguments);return function(e,t){if(t&&("object"===lm(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return um(e)}(this,n)}}function um(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function hm(e){var t="function"==typeof Map?new Map:void 0;return hm=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,i)}function i(){return fm(e,arguments,gm(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),vm(i,e)},hm(e)}function fm(e,t,n){return fm=pm()?Reflect.construct:function(e,t,n){var i=[null];i.push.apply(i,t);var o=new(Function.bind.apply(e,i));return n&&vm(o,n.prototype),o},fm.apply(null,arguments)}function pm(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function vm(e,t){return vm=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},vm(e,t)}function gm(e){return gm=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},gm(e)}var mm=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&vm(e,t)}(i,e);var t,n=cm(i);function i(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,i),t=n.call(this,e),Object.setPrototypeOf(um(t),i.prototype),t.name=t.constructor.name,t}return t=i,Object.defineProperty(t,"prototype",{writable:!1}),t}(hm(Error)),ym=2,bm=17,wm=3,$m="0-90-9٠-٩۰-۹",km="".concat("-‐-―−ー-").concat("//").concat("..").concat("  ­​⁠ ").concat("()()[]\\[\\]").concat("~⁓∼~"),Cm="++";function Sm(e,t){e=e.split("-"),t=t.split("-");for(var n=e[0].split("."),i=t[0].split("."),o=0;o<3;o++){var r=Number(n[o]),s=Number(i[o]);if(r>s)return 1;if(s>r)return-1;if(!isNaN(r)&&isNaN(s))return 1;if(isNaN(r)&&!isNaN(s))return-1}return e[1]&&t[1]?e[1]>t[1]?1:e[1]<t[1]?-1:0:!e[1]&&t[1]?1:e[1]&&!t[1]?-1:0}var Im={}.constructor;function Rm(e){return null!=e&&e.constructor===Im}function Em(e){return Em="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Em(e)}function xm(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Om(e,t,n){return t&&function(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var Am=" ext. ",Nm=/^\d+$/,jm=function(){function e(t){xm(this,e),function(e){if(!e)throw new Error("[libphonenumber-js] `metadata` argument not passed. Check your arguments.");if(!Rm(e)||!Rm(e.countries))throw new Error("[libphonenumber-js] `metadata` argument was passed but it's not a valid metadata. Must be an object having `.countries` child object property. Got ".concat(Rm(e)?"an object of shape: { "+Object.keys(e).join(", ")+" }":"a "+Um(e)+": "+e,"."))}(t),this.metadata=t,_m.call(this,t)}return Om(e,[{key:"getCountries",value:function(){return Object.keys(this.metadata.countries).filter((function(e){return"001"!==e}))}},{key:"getCountryMetadata",value:function(e){return this.metadata.countries[e]}},{key:"nonGeographic",value:function(){if(!(this.v1||this.v2||this.v3))return this.metadata.nonGeographic||this.metadata.nonGeographical}},{key:"hasCountry",value:function(e){return void 0!==this.getCountryMetadata(e)}},{key:"hasCallingCode",value:function(e){if(this.getCountryCodesForCallingCode(e))return!0;if(this.nonGeographic()){if(this.nonGeographic()[e])return!0}else{var t=this.countryCallingCodes()[e];if(t&&1===t.length&&"001"===t[0])return!0}}},{key:"isNonGeographicCallingCode",value:function(e){return this.nonGeographic()?!!this.nonGeographic()[e]:!this.getCountryCodesForCallingCode(e)}},{key:"country",value:function(e){return this.selectNumberingPlan(e)}},{key:"selectNumberingPlan",value:function(e,t){if(e&&Nm.test(e)&&(t=e,e=null),e&&"001"!==e){if(!this.hasCountry(e))throw new Error("Unknown country: ".concat(e));this.numberingPlan=new Mm(this.getCountryMetadata(e),this)}else if(t){if(!this.hasCallingCode(t))throw new Error("Unknown calling code: ".concat(t));this.numberingPlan=new Mm(this.getNumberingPlanMetadata(t),this)}else this.numberingPlan=void 0;return this}},{key:"getCountryCodesForCallingCode",value:function(e){var t=this.countryCallingCodes()[e];if(t){if(1===t.length&&3===t[0].length)return;return t}}},{key:"getCountryCodeForCallingCode",value:function(e){var t=this.getCountryCodesForCallingCode(e);if(t)return t[0]}},{key:"getNumberingPlanMetadata",value:function(e){var t=this.getCountryCodeForCallingCode(e);if(t)return this.getCountryMetadata(t);if(this.nonGeographic()){var n=this.nonGeographic()[e];if(n)return n}else{var i=this.countryCallingCodes()[e];if(i&&1===i.length&&"001"===i[0])return this.metadata.countries["001"]}}},{key:"countryCallingCode",value:function(){return this.numberingPlan.callingCode()}},{key:"IDDPrefix",value:function(){return this.numberingPlan.IDDPrefix()}},{key:"defaultIDDPrefix",value:function(){return this.numberingPlan.defaultIDDPrefix()}},{key:"nationalNumberPattern",value:function(){return this.numberingPlan.nationalNumberPattern()}},{key:"possibleLengths",value:function(){return this.numberingPlan.possibleLengths()}},{key:"formats",value:function(){return this.numberingPlan.formats()}},{key:"nationalPrefixForParsing",value:function(){return this.numberingPlan.nationalPrefixForParsing()}},{key:"nationalPrefixTransformRule",value:function(){return this.numberingPlan.nationalPrefixTransformRule()}},{key:"leadingDigits",value:function(){return this.numberingPlan.leadingDigits()}},{key:"hasTypes",value:function(){return this.numberingPlan.hasTypes()}},{key:"type",value:function(e){return this.numberingPlan.type(e)}},{key:"ext",value:function(){return this.numberingPlan.ext()}},{key:"countryCallingCodes",value:function(){return this.v1?this.metadata.country_phone_code_to_countries:this.metadata.country_calling_codes}},{key:"chooseCountryByCountryCallingCode",value:function(e){return this.selectNumberingPlan(e)}},{key:"hasSelectedNumberingPlan",value:function(){return void 0!==this.numberingPlan}}]),e}(),Mm=function(){function e(t,n){xm(this,e),this.globalMetadataObject=n,this.metadata=t,_m.call(this,n.metadata)}return Om(e,[{key:"callingCode",value:function(){return this.metadata[0]}},{key:"getDefaultCountryMetadataForRegion",value:function(){return this.globalMetadataObject.getNumberingPlanMetadata(this.callingCode())}},{key:"IDDPrefix",value:function(){if(!this.v1&&!this.v2)return this.metadata[1]}},{key:"defaultIDDPrefix",value:function(){if(!this.v1&&!this.v2)return this.metadata[12]}},{key:"nationalNumberPattern",value:function(){return this.v1||this.v2?this.metadata[1]:this.metadata[2]}},{key:"possibleLengths",value:function(){if(!this.v1)return this.metadata[this.v2?2:3]}},{key:"_getFormats",value:function(e){return e[this.v1?2:this.v2?3:4]}},{key:"formats",value:function(){var e=this,t=this._getFormats(this.metadata)||this._getFormats(this.getDefaultCountryMetadataForRegion())||[];return t.map((function(t){return new Pm(t,e)}))}},{key:"nationalPrefix",value:function(){return this.metadata[this.v1?3:this.v2?4:5]}},{key:"_getNationalPrefixFormattingRule",value:function(e){return e[this.v1?4:this.v2?5:6]}},{key:"nationalPrefixFormattingRule",value:function(){return this._getNationalPrefixFormattingRule(this.metadata)||this._getNationalPrefixFormattingRule(this.getDefaultCountryMetadataForRegion())}},{key:"_nationalPrefixForParsing",value:function(){return this.metadata[this.v1?5:this.v2?6:7]}},{key:"nationalPrefixForParsing",value:function(){return this._nationalPrefixForParsing()||this.nationalPrefix()}},{key:"nationalPrefixTransformRule",value:function(){return this.metadata[this.v1?6:this.v2?7:8]}},{key:"_getNationalPrefixIsOptionalWhenFormatting",value:function(){return!!this.metadata[this.v1?7:this.v2?8:9]}},{key:"nationalPrefixIsOptionalWhenFormattingInNationalFormat",value:function(){return this._getNationalPrefixIsOptionalWhenFormatting(this.metadata)||this._getNationalPrefixIsOptionalWhenFormatting(this.getDefaultCountryMetadataForRegion())}},{key:"leadingDigits",value:function(){return this.metadata[this.v1?8:this.v2?9:10]}},{key:"types",value:function(){return this.metadata[this.v1?9:this.v2?10:11]}},{key:"hasTypes",value:function(){return(!this.types()||0!==this.types().length)&&!!this.types()}},{key:"type",value:function(e){if(this.hasTypes()&&Lm(this.types(),e))return new Wm(Lm(this.types(),e),this)}},{key:"ext",value:function(){return this.v1||this.v2?Am:this.metadata[13]||Am}}]),e}(),Pm=function(){function e(t,n){xm(this,e),this._format=t,this.metadata=n}return Om(e,[{key:"pattern",value:function(){return this._format[0]}},{key:"format",value:function(){return this._format[1]}},{key:"leadingDigitsPatterns",value:function(){return this._format[2]||[]}},{key:"nationalPrefixFormattingRule",value:function(){return this._format[3]||this.metadata.nationalPrefixFormattingRule()}},{key:"nationalPrefixIsOptionalWhenFormattingInNationalFormat",value:function(){return!!this._format[4]||this.metadata.nationalPrefixIsOptionalWhenFormattingInNationalFormat()}},{key:"nationalPrefixIsMandatoryWhenFormattingInNationalFormat",value:function(){return this.usesNationalPrefix()&&!this.nationalPrefixIsOptionalWhenFormattingInNationalFormat()}},{key:"usesNationalPrefix",value:function(){return!(!this.nationalPrefixFormattingRule()||Tm.test(this.nationalPrefixFormattingRule()))}},{key:"internationalFormat",value:function(){return this._format[5]||this.format()}}]),e}(),Tm=/^\(?\$1\)?$/,Wm=function(){function e(t,n){xm(this,e),this.type=t,this.metadata=n}return Om(e,[{key:"pattern",value:function(){return this.metadata.v1?this.type:this.type[0]}},{key:"possibleLengths",value:function(){if(!this.metadata.v1)return this.type[1]||this.metadata.possibleLengths()}}]),e}();function Lm(e,t){switch(t){case"FIXED_LINE":return e[0];case"MOBILE":return e[1];case"TOLL_FREE":return e[2];case"PREMIUM_RATE":return e[3];case"PERSONAL_NUMBER":return e[4];case"VOICEMAIL":return e[5];case"UAN":return e[6];case"PAGER":return e[7];case"VOIP":return e[8];case"SHARED_COST":return e[9]}}var Um=function(e){return Em(e)};function Dm(e,t){if((t=new jm(t)).hasCountry(e))return t.country(e).countryCallingCode();throw new Error("Unknown country: ".concat(e))}function Fm(e,t){return t.countries.hasOwnProperty(e)}function _m(e){var t=e.version;"number"==typeof t?(this.v1=1===t,this.v2=2===t,this.v3=3===t,this.v4=4===t):t?-1===Sm(t,"1.2.0")?this.v2=!0:-1===Sm(t,"1.7.35")?this.v3=!0:this.v4=!0:this.v1=!0}var qm=function(e){return"([".concat($m,"]{1,").concat(e,"})")};function Bm(e){var t="[  \\t,]*",n="[:\\..]?[  \\t,-]*",i="#?",o="[  \\t]*";return";ext="+qm("20")+"|"+(t+"(?:e?xt(?:ensi(?:ó?|ó))?n?|e?xtn?|доб|anexo)"+n+qm("20")+i)+"|"+(t+"(?:[xx##~~]|int|int)"+n+qm("9")+i)+"|"+("[- ]+"+qm("6")+"#")+"|"+(o+"(?:,{2}|;)"+n+qm("15")+i)+"|"+(o+"(?:,)+"+n+qm("9")+i)}var Vm="["+$m+"]{"+ym+"}",Km="[++]{0,1}(?:["+km+"]*["+$m+"]){3,}["+km+$m+"]*",Hm=new RegExp("^[++]{0,1}(?:["+km+"]*["+$m+"]){1,2}$","i"),zm=Km+"(?:"+Bm()+")?",Jm=new RegExp("^"+Vm+"$|^"+zm+"$","i");var Gm=new RegExp("(?:"+Bm()+")$","i");function Zm(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Ym(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Ym(e,t)}(e))||t){n&&(e=n);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Ym(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}var Xm={0:"0",1:"1",2:"2",3:"3",4:"4",5:"5",6:"6",7:"7",8:"8",9:"9","0":"0","1":"1","2":"2","3":"3","4":"4","5":"5","6":"6","7":"7","8":"8","9":"9","٠":"0","١":"1","٢":"2","٣":"3","٤":"4","٥":"5","٦":"6","٧":"7","٨":"8","٩":"9","۰":"0","۱":"1","۲":"2","۳":"3","۴":"4","۵":"5","۶":"6","۷":"7","۸":"8","۹":"9"};function Qm(e){return Xm[e]}function ey(e){for(var t,n="",i=Zm(e.split(""));!(t=i()).done;){var o=Qm(t.value);o&&(n+=o)}return n}function ty(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return ny(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ny(e,t)}(e))||t){n&&(e=n);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function ny(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function iy(e){for(var t,n="",i=ty(e.split(""));!(t=i()).done;){n+=oy(t.value,n)||""}return n}function oy(e,t,n){if("+"===e){if(t)return;return"+"}return Qm(e)}function ry(e,t){return function(e,t,n){var i=n.type(t),o=i&&i.possibleLengths()||n.possibleLengths();if(!o)return"IS_POSSIBLE";var r=e.length,s=o[0];if(s===r)return"IS_POSSIBLE";if(s>r)return"TOO_SHORT";if(o[o.length-1]<r)return"TOO_LONG";return o.indexOf(r,1)>=0?"IS_POSSIBLE":"INVALID_LENGTH"}(e,void 0,t)}function sy(e,t){return"IS_POSSIBLE"===ry(e,t)}function ay(e,t){return e=e||"",new RegExp("^(?:"+t+")$").test(e)}function dy(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return ly(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ly(e,t)}(e))||t){n&&(e=n);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function ly(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}var cy=["MOBILE","PREMIUM_RATE","TOLL_FREE","SHARED_COST","VOIP","PERSONAL_NUMBER","PAGER","UAN","VOICEMAIL"];function uy(e,t,n){if(t=t||{},e.country||e.countryCallingCode){(n=new jm(n)).selectNumberingPlan(e.country,e.countryCallingCode);var i=t.v2?e.nationalNumber:e.phone;if(ay(i,n.nationalNumberPattern())){if(hy(i,"FIXED_LINE",n))return n.type("MOBILE")&&""===n.type("MOBILE").pattern()?"FIXED_LINE_OR_MOBILE":n.type("MOBILE")?hy(i,"MOBILE",n)?"FIXED_LINE_OR_MOBILE":"FIXED_LINE":"FIXED_LINE_OR_MOBILE";for(var o,r=dy(cy);!(o=r()).done;){var s=o.value;if(hy(i,s,n))return s}}}}function hy(e,t,n){return!(!(t=n.type(t))||!t.pattern())&&(!(t.possibleLengths()&&t.possibleLengths().indexOf(e.length)<0)&&ay(e,t.pattern()))}function fy(e,t,n){var i=new jm(n).getCountryCodesForCallingCode(e);return i?i.filter((function(e){return function(e,t,n){var i=new jm(n);if(i.selectNumberingPlan(t),i.numberingPlan.possibleLengths().indexOf(e.length)>=0)return!0;return!1}(t,e,n)})):[]}function py(e){return e.replace(new RegExp("[".concat(km,"]+"),"g")," ").trim()}var vy=/(\$\d)/;function gy(e,t,n){var i=n.useInternationalFormat,o=n.withNationalPrefix;n.carrierCode,n.metadata;var r=e.replace(new RegExp(t.pattern()),i?t.internationalFormat():o&&t.nationalPrefixFormattingRule()?t.format().replace(vy,t.nationalPrefixFormattingRule()):t.format());return i?py(r):r}var my=/^[\d]+(?:[~\u2053\u223C\uFF5E][\d]+)?$/;function yy(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return by(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return by(e,t)}(e))||t){n&&(e=n);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function by(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function wy(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function $y(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?wy(Object(n),!0).forEach((function(t){ky(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):wy(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function ky(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Cy={formatExtension:function(e,t,n){return"".concat(e).concat(n.ext()).concat(t)}};function Sy(e,t,n,i){if(n=n?$y($y({},Cy),n):Cy,i=new jm(i),e.country&&"001"!==e.country){if(!i.hasCountry(e.country))throw new Error("Unknown country: ".concat(e.country));i.country(e.country)}else{if(!e.countryCallingCode)return e.phone||"";i.selectNumberingPlan(e.countryCallingCode)}var o,r=i.countryCallingCode(),s=n.v2?e.nationalNumber:e.phone;switch(t){case"NATIONAL":return s?Ey(o=Iy(s,e.carrierCode,"NATIONAL",i,n),e.ext,i,n.formatExtension):"";case"INTERNATIONAL":return s?(o=Iy(s,null,"INTERNATIONAL",i,n),Ey(o="+".concat(r," ").concat(o),e.ext,i,n.formatExtension)):"+".concat(r);case"E.164":return"+".concat(r).concat(s);case"RFC3966":return function(e){var t=e.number,n=e.ext;if(!t)return"";if("+"!==t[0])throw new Error('"formatRFC3966()" expects "number" to be in E.164 format.');return"tel:".concat(t).concat(n?";ext="+n:"")}({number:"+".concat(r).concat(s),ext:e.ext});case"IDD":if(!n.fromCountry)return;var a=function(e,t,n,i,o){var r=Dm(i,o.metadata);if(r===n){var s=Iy(e,t,"NATIONAL",o);return"1"===n?n+" "+s:s}var a=function(e,t,n){var i=new jm(n);return i.selectNumberingPlan(e,t),i.defaultIDDPrefix()?i.defaultIDDPrefix():my.test(i.IDDPrefix())?i.IDDPrefix():void 0}(i,void 0,o.metadata);if(a)return"".concat(a," ").concat(n," ").concat(Iy(e,null,"INTERNATIONAL",o))}(s,e.carrierCode,r,n.fromCountry,i);return Ey(a,e.ext,i,n.formatExtension);default:throw new Error('Unknown "format" argument passed to "formatNumber()": "'.concat(t,'"'))}}function Iy(e,t,n,i,o){var r=Ry(i.formats(),e);return r?gy(e,r,{useInternationalFormat:"INTERNATIONAL"===n,withNationalPrefix:!r.nationalPrefixIsOptionalWhenFormattingInNationalFormat()||!o||!1!==o.nationalPrefix,carrierCode:t,metadata:i}):e}function Ry(e,t){for(var n,i=yy(e);!(n=i()).done;){var o=n.value;if(o.leadingDigitsPatterns().length>0){var r=o.leadingDigitsPatterns()[o.leadingDigitsPatterns().length-1];if(0!==t.search(r))continue}if(ay(t,o.pattern()))return o}}function Ey(e,t,n,i){return t?i(e,t,n):e}function xy(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function Oy(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?xy(Object(n),!0).forEach((function(t){Ay(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):xy(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Ay(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ny(e,t,n){return t&&function(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var jy=function(){function e(t,n,i){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),!t)throw new TypeError("`country` or `countryCallingCode` not passed");if(!n)throw new TypeError("`nationalNumber` not passed");if(!i)throw new TypeError("`metadata` not passed");var o=function(e,t){var n,i,o=new jm(t);My(e)?(n=e,o.selectNumberingPlan(n),i=o.countryCallingCode()):i=e;return{country:n,countryCallingCode:i}}(t,i),r=o.country,s=o.countryCallingCode;this.country=r,this.countryCallingCode=s,this.nationalNumber=n,this.number="+"+this.countryCallingCode+this.nationalNumber,this.getMetadata=function(){return i}}return Ny(e,[{key:"setExt",value:function(e){this.ext=e}},{key:"getPossibleCountries",value:function(){return this.country?[this.country]:fy(this.countryCallingCode,this.nationalNumber,this.getMetadata())}},{key:"isPossible",value:function(){return function(e,t,n){if(void 0===t&&(t={}),n=new jm(n),t.v2){if(!e.countryCallingCode)throw new Error("Invalid phone number object passed");n.selectNumberingPlan(e.countryCallingCode)}else{if(!e.phone)return!1;if(e.country){if(!n.hasCountry(e.country))throw new Error("Unknown country: ".concat(e.country));n.country(e.country)}else{if(!e.countryCallingCode)throw new Error("Invalid phone number object passed");n.selectNumberingPlan(e.countryCallingCode)}}if(n.possibleLengths())return sy(e.phone||e.nationalNumber,n);if(e.countryCallingCode&&n.isNonGeographicCallingCode(e.countryCallingCode))return!0;throw new Error('Missing "possibleLengths" in metadata. Perhaps the metadata has been generated before v1.0.18.')}(this,{v2:!0},this.getMetadata())}},{key:"isValid",value:function(){return function(e,t,n){return t=t||{},(n=new jm(n)).selectNumberingPlan(e.country,e.countryCallingCode),n.hasTypes()?void 0!==uy(e,t,n.metadata):ay(t.v2?e.nationalNumber:e.phone,n.nationalNumberPattern())}(this,{v2:!0},this.getMetadata())}},{key:"isNonGeographic",value:function(){return new jm(this.getMetadata()).isNonGeographicCallingCode(this.countryCallingCode)}},{key:"isEqual",value:function(e){return this.number===e.number&&this.ext===e.ext}},{key:"getType",value:function(){return uy(this,{v2:!0},this.getMetadata())}},{key:"format",value:function(e,t){return Sy(this,e,t?Oy(Oy({},t),{},{v2:!0}):{v2:!0},this.getMetadata())}},{key:"formatNational",value:function(e){return this.format("NATIONAL",e)}},{key:"formatInternational",value:function(e){return this.format("INTERNATIONAL",e)}},{key:"getURI",value:function(e){return this.format("RFC3966",e)}}]),e}(),My=function(e){return/^[A-Z]{2}$/.test(e)};var Py=new RegExp("(["+$m+"])");function Ty(e,t,n,i){if(t){var o=new jm(i);o.selectNumberingPlan(t,n);var r=new RegExp(o.IDDPrefix());if(0===e.search(r)){var s=(e=e.slice(e.match(r)[0].length)).match(Py);if(!(s&&null!=s[1]&&s[1].length>0&&"0"===s[1]))return e}}}function Wy(e,t){if(e&&t.numberingPlan.nationalPrefixForParsing()){var n=new RegExp("^(?:"+t.numberingPlan.nationalPrefixForParsing()+")"),i=n.exec(e);if(i){var o,r,s,a=i.length-1,d=a>0&&i[a];if(t.nationalPrefixTransformRule()&&d)o=e.replace(n,t.nationalPrefixTransformRule()),a>1&&(r=i[1]);else{var l=i[0];o=e.slice(l.length),d&&(r=i[1])}if(d){var c=e.indexOf(i[1]);e.slice(0,c)===t.numberingPlan.nationalPrefix()&&(s=t.numberingPlan.nationalPrefix())}else s=i[0];return{nationalNumber:o,nationalPrefix:s,carrierCode:r}}}return{nationalNumber:e}}function Ly(e,t){var n=Wy(e,t),i=n.carrierCode,o=n.nationalNumber;if(o!==e){if(!function(e,t,n){if(ay(e,n.nationalNumberPattern())&&!ay(t,n.nationalNumberPattern()))return!1;return!0}(e,o,t))return{nationalNumber:e};if(t.possibleLengths()&&!function(e,t){switch(ry(e,t)){case"TOO_SHORT":case"INVALID_LENGTH":return!1;default:return!0}}(o,t))return{nationalNumber:e}}return{nationalNumber:o,carrierCode:i}}function Uy(e,t,n,i){var o=t?Dm(t,i):n;if(0===e.indexOf(o)){(i=new jm(i)).selectNumberingPlan(t,n);var r=e.slice(o.length),s=Ly(r,i).nationalNumber,a=Ly(e,i).nationalNumber;if(!ay(a,i.nationalNumberPattern())&&ay(s,i.nationalNumberPattern())||"TOO_LONG"===ry(a,i))return{countryCallingCode:o,number:r}}return{number:e}}function Dy(e,t,n,i){if(!e)return{};var o;if("+"!==e[0]){var r=Ty(e,t,n,i);if(!r||r===e){if(t||n){var s=Uy(e,t,n,i),a=s.countryCallingCode,d=s.number;if(a)return{countryCallingCodeSource:"FROM_NUMBER_WITHOUT_PLUS_SIGN",countryCallingCode:a,number:d}}return{number:e}}o=!0,e="+"+r}if("0"===e[1])return{};i=new jm(i);for(var l=2;l-1<=wm&&l<=e.length;){var c=e.slice(1,l);if(i.hasCallingCode(c))return i.selectNumberingPlan(c),{countryCallingCodeSource:o?"FROM_NUMBER_WITH_IDD":"FROM_NUMBER_WITH_PLUS_SIGN",countryCallingCode:c,number:e.slice(l)};l++}return{}}function Fy(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return _y(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _y(e,t)}(e))||t){n&&(e=n);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _y(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function qy(e,t){var n=t.countries;t.defaultCountry;var i=t.metadata;i=new jm(i);for(var o,r=Fy(n);!(o=r()).done;){var s=o.value;if(i.country(s),i.leadingDigits()){if(e&&0===e.search(i.leadingDigits()))return s}else if(uy({phone:e,country:s},void 0,i.metadata))return s}}function By(e,t){var n=t.nationalNumber,i=t.defaultCountry,o=t.metadata,r=o.getCountryCodesForCallingCode(e);if(r)return 1===r.length?r[0]:qy(n,{countries:r,defaultCountry:i,metadata:o.metadata})}var Vy="+",Ky="(["+$m+"]|[\\-\\.\\(\\)]?)",Hy=new RegExp("^\\"+Vy+Ky+"*["+$m+"]"+Ky+"*$","g"),zy=new RegExp("^("+("["+$m+"]+((\\-)*["+$m+"])*")+"\\.)*"+("[a-zA-Z]+((\\-)*["+$m+"])*")+"\\.?$","g"),Jy="tel:",Gy=";phone-context=",Zy=";isub=";function Yy(e,t){var n,i=t.extractFormattedPhoneNumber,o=function(e){var t=e.indexOf(Gy);if(t<0)return null;var n=t+Gy.length;if(n>=e.length)return"";var i=e.indexOf(";",n);return i>=0?e.substring(n,i):e.substring(n)}(e);if(!function(e){return null===e||0!==e.length&&(Hy.test(e)||zy.test(e))}(o))throw new mm("NOT_A_NUMBER");if(null===o)n=i(e)||"";else{n="",o.charAt(0)===Vy&&(n+=o);var r,s=e.indexOf(Jy);r=s>=0?s+Jy.length:0;var a=e.indexOf(Gy);n+=e.substring(r,a)}var d=n.indexOf(Zy);if(d>0&&(n=n.substring(0,d)),""!==n)return n}var Xy=250,Qy=new RegExp("[++"+$m+"]"),eb=new RegExp("[^"+$m+"#]+$");function tb(e,t,n){if(t=t||{},n=new jm(n),t.defaultCountry&&!n.hasCountry(t.defaultCountry)){if(t.v2)throw new mm("INVALID_COUNTRY");throw new Error("Unknown country: ".concat(t.defaultCountry))}var i=function(e,t,n){var i=Yy(e,{extractFormattedPhoneNumber:function(e){return function(e,t,n){if(!e)return;if(e.length>Xy){if(n)throw new mm("TOO_LONG");return}if(!1===t)return e;var i=e.search(Qy);if(i<0)return;return e.slice(i).replace(eb,"")}(e,n,t)}});if(!i)return{};if(!function(e){return e.length>=ym&&Jm.test(e)}(i))return function(e){return Hm.test(e)}(i)?{error:"TOO_SHORT"}:{};var o=function(e){var t=e.search(Gm);if(t<0)return{};for(var n=e.slice(0,t),i=e.match(Gm),o=1;o<i.length;){if(i[o])return{number:n,ext:i[o]};o++}}(i);if(o.ext)return o;return{number:i}}(e,t.v2,t.extract),o=i.number,r=i.ext,s=i.error;if(!o){if(t.v2){if("TOO_SHORT"===s)throw new mm("TOO_SHORT");throw new mm("NOT_A_NUMBER")}return{}}var a=function(e,t,n,i){var o,r=Dy(iy(e),t,n,i.metadata),s=r.countryCallingCodeSource,a=r.countryCallingCode,d=r.number;if(a)i.selectNumberingPlan(a);else{if(!d||!t&&!n)return{};i.selectNumberingPlan(t,n),t&&(o=t),a=n||Dm(t,i.metadata)}if(!d)return{countryCallingCodeSource:s,countryCallingCode:a};var l=Ly(iy(d),i),c=l.nationalNumber,u=l.carrierCode,h=By(a,{nationalNumber:c,defaultCountry:t,metadata:i});h&&(o=h,"001"===h||i.country(o));return{country:o,countryCallingCode:a,countryCallingCodeSource:s,nationalNumber:c,carrierCode:u}}(o,t.defaultCountry,t.defaultCallingCode,n),d=a.country,l=a.nationalNumber,c=a.countryCallingCode,u=a.countryCallingCodeSource,h=a.carrierCode;if(!n.hasSelectedNumberingPlan()){if(t.v2)throw new mm("INVALID_COUNTRY");return{}}if(!l||l.length<ym){if(t.v2)throw new mm("TOO_SHORT");return{}}if(l.length>bm){if(t.v2)throw new mm("TOO_LONG");return{}}if(t.v2){var f=new jy(c,l,n.metadata);return d&&(f.country=d),h&&(f.carrierCode=h),r&&(f.ext=r),f.__countryCallingCodeSource=u,f}var p=!!(t.extended?n.hasSelectedNumberingPlan():d)&&ay(l,n.nationalNumberPattern());return t.extended?{country:d,countryCallingCode:c,carrierCode:h,valid:p,possible:!!p||!(!0!==t.extended||!n.possibleLengths()||!sy(l,n)),phone:l,ext:r}:p?function(e,t,n){var i={country:e,phone:t};n&&(i.ext=n);return i}(d,l,r):{}}function nb(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function ib(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?nb(Object(n),!0).forEach((function(t){ob(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):nb(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function ob(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function rb(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function sb(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ab(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==n)return;var i,o,r=[],s=!0,a=!1;try{for(n=n.call(e);!(s=(i=n.next()).done)&&(r.push(i.value),!t||r.length!==t);s=!0);}catch(e){a=!0,o=e}finally{try{s||null==n.return||n.return()}finally{if(a)throw o}}return r}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return db(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return db(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function db(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function lb(e){var t,n,i,o=ab(Array.prototype.slice.call(e),4),r=o[0],s=o[1],a=o[2],d=o[3];if("string"!=typeof r)throw new TypeError("A text for parsing must be a string.");if(t=r,s&&"string"!=typeof s){if(!Rm(s))throw new Error("Invalid second argument: ".concat(s));a?(n=s,i=a):i=s}else d?(n=a,i=d):(n=void 0,i=a),s&&(n=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?rb(Object(n),!0).forEach((function(t){sb(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):rb(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({defaultCountry:s},n));return{text:t,options:n,metadata:i}}function cb(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function ub(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?cb(Object(n),!0).forEach((function(t){hb(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):cb(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function hb(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function fb(e,t,n){t&&t.defaultCountry&&!Fm(t.defaultCountry,n)&&(t=ub(ub({},t),{},{defaultCountry:void 0}));try{return function(e,t,n){return tb(e,ib(ib({},t),{},{v2:!0}),n)}(e,t,n)}catch(e){if(!(e instanceof mm))throw e}}function pb(){var e=lb(arguments);return fb(e.text,e.options,e.metadata)}function vb(e,t,n){return t&&function(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function gb(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var mb=vb((function e(t,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;gb(this,e),this.key=t,this.value=n,this.next=i,this.prev=o})),yb=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10;gb(this,e),this.size=0,this.limit=t,this.head=null,this.tail=null,this.cache={}}return vb(e,[{key:"put",value:function(e,t){if(this.ensureLimit(),this.head){var n=new mb(e,t,this.head);this.head.prev=n,this.head=n}else this.head=this.tail=new mb(e,t);this.cache[e]=this.head,this.size++}},{key:"get",value:function(e){if(this.cache[e]){var t=this.cache[e].value;return this.remove(e),this.put(e,t),t}console.log("Item not available in cache for key ".concat(e))}},{key:"ensureLimit",value:function(){this.size===this.limit&&this.remove(this.tail.key)}},{key:"remove",value:function(e){var t=this.cache[e];null!==t.prev?t.prev.next=t.next:this.head=t.next,null!==t.next?t.next.prev=t.prev:this.tail=t.prev,delete this.cache[e],this.size--}},{key:"clear",value:function(){this.head=null,this.tail=null,this.size=0,this.cache={}}}]),e}();function bb(e,t,n){return t&&function(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var wb=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.cache=new yb(t)}return bb(e,[{key:"getPatternForRegExp",value:function(e){var t=this.cache.get(e);return t||(t=new RegExp("^"+e),this.cache.put(e,t)),t}}]),e}();function $b(e,t){if(e<0||t<=0||t<e)throw new TypeError;return"{".concat(e,",").concat(t,"}")}function kb(e,t){var n=t.search(e);return n>=0?t.slice(0,n):t}var Cb="   ᠎ - \u2028\u2029   ",Sb="[".concat(Cb,"]"),Ib="[^".concat(Cb,"]"),Rb="[".concat("0-9٠-٩۰-۹߀-߉०-९০-৯੦-੯૦-૯୦-୯௦-௯౦-౯೦-೯൦-൯๐-๙໐-໙༠-༩၀-၉႐-႙០-៩᠐-᠙᥆-᥏᧐-᧙᪀-᪉᪐-᪙᭐-᭙᮰-᮹᱀-᱉᱐-᱙꘠-꘩꣐-꣙꤀-꤉꧐-꧙꩐-꩙꯰-꯹0-9","]"),Eb="A-Za-zªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԧԱ-Ֆՙա-ևא-תװ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࢠࢢ-ࢬऄ-हऽॐक़-ॡॱ-ॷॹ-ॿঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-ళవ-హఽౘౙౠౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-ഐഒ-ഺഽൎൠൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡷᢀ-ᢨᢪᢰ-ᣵᤀ-ᤜᥐ-ᥭᥰ-ᥴᦀ-ᦫᧁ-ᧇᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᳩ-ᳬᳮ-ᳱᳵᳶᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎↃↄⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⸯ々〆〱-〵〻〼ぁ-ゖゝ-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿌ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚗꚠ-ꛥꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐ-ꞓꞠ-Ɦꟸ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꪀ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꯀ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",xb="[".concat(Eb,"]"),Ob=new RegExp(xb),Ab="[".concat("$¢-¥֏؋৲৳৻૱௹฿៛₠-₹꠸﷼﹩$¢£¥₩","]"),Nb=new RegExp(Ab),jb="[".concat("̀-ͯ҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-ٰٟۖ-ۜ۟-۪ۤۧۨ-ܑۭܰ-݊ަ-ް߫-߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛ࣤ-ࣾऀ-ंऺ़ु-ै्॑-ॗॢॣঁ়ু-ৄ্ৢৣਁਂ਼ੁੂੇੈੋ-੍ੑੰੱੵઁં઼ુ-ૅેૈ્ૢૣଁ଼ିୁ-ୄ୍ୖୢୣஂீ்ా-ీె-ైొ-్ౕౖౢౣ಼ಿೆೌ್ೢೣു-ൄ്ൢൣ්ි-ුූัิ-ฺ็-๎ັິ-ູົຼ່-ໍཱ༹༘༙༵༷-ཾྀ-྄྆྇ྍ-ྗྙ-ྼ࿆ိ-ူဲ-့္်ွှၘၙၞ-ၠၱ-ၴႂႅႆႍႝ፝-፟ᜒ-᜔ᜲ-᜴ᝒᝓᝲᝳ឴឵ិ-ួំ៉-៓៝᠋-᠍ᢩᤠ-ᤢᤧᤨᤲ᤹-᤻ᨘᨗᩖᩘ-ᩞ᩠ᩢᩥ-ᩬᩳ-᩿᩼ᬀ-ᬃ᬴ᬶ-ᬺᬼᭂ᭫-᭳ᮀᮁᮢ-ᮥᮨᮩ᯦᮫ᯨᯩᯭᯯ-ᯱᰬ-ᰳᰶ᰷᳐-᳔᳒-᳢᳠-᳨᳭᳴᷀-ᷦ᷼-᷿⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〭꙯ꙴ-꙽ꚟ꛰꛱ꠂ꠆ꠋꠥꠦ꣄꣠-꣱ꤦ-꤭ꥇ-ꥑꦀ-ꦂ꦳ꦶ-ꦹꦼꨩ-ꨮꨱꨲꨵꨶꩃꩌꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫬꫭ꫶ꯥꯨ꯭ﬞ︀-️︠-︦","]"),Mb=new RegExp(jb),Pb=new RegExp("[\0-€-ÿĀ-ſḀ-ỿƀ-ɏ̀-ͯ]");function Tb(e){return!(!Ob.test(e)&&!Mb.test(e))&&Pb.test(e)}function Wb(e){return"%"===e||Nb.test(e)}function Lb(e,t,n){var i=!0,o=pb(e,n);if(o||(i=!1,o=pb(e,{defaultCallingCode:t.countryCallingCode},n)),!o)return"INVALID_NUMBER";if(t.ext){if(o.ext!==t.ext)return"NO_MATCH"}else if(o.ext)return"NO_MATCH";return i&&t.countryCallingCode!==o.countryCallingCode?"NO_MATCH":t.number===o.number?i?"EXACT_MATCH":"NSN_MATCH":0===t.nationalNumber.indexOf(o.nationalNumber)||0===o.nationalNumber.indexOf(t.nationalNumber)?"SHORT_NSN_MATCH":"NO_MATCH"}var Ub={POSSIBLE:function(e,t){return t.candidate,t.metadata,!0},VALID:function(e,t){var n=t.candidate;t.defaultCountry;var i=t.metadata;return!(!e.isValid()||!Db(e,n,i))},STRICT_GROUPING:function(e,t){var n=t.candidate,i=t.defaultCountry,o=t.metadata;return t.regExpCache,!(!e.isValid()||!Db(e,n,o)||_b(e,n)||!Fb(e,{defaultCountry:i,metadata:o}))&&qb()},EXACT_GROUPING:function(e,t){var n=t.candidate,i=t.defaultCountry,o=t.metadata;return t.regExpCache,!(!e.isValid()||!Db(e,n,o)||_b(e,n)||!Fb(e,{defaultCountry:i,metadata:o}))&&qb()}};function Db(e,t,n){for(var i=0;i<t.length-1;i++){var o=t.charAt(i);if("x"===o||"X"===o){var r=t.charAt(i+1);if("x"===r||"X"===r){if(i++,"NSN_MATCH"!==Lb(t.substring(i),e,n))return!1}else{var s=ey(t.substring(i));if(s){if(e.ext!==s)return!1}else if(e.ext)return!1}}}return!0}function Fb(e,t){var n=t.defaultCountry,i=t.metadata;if("FROM_DEFAULT_COUNTRY"!==e.__countryCallingCodeSource)return!0;var o=new jm(i);o.selectNumberingPlan(e.countryCallingCode),e.country||By(e.countryCallingCode,{nationalNumber:e.nationalNumber,defaultCountry:n,metadata:o});var r=e.nationalNumber,s=Ry(o.numberingPlan.formats(),r);return!s.nationalPrefixFormattingRule()||(!!o.numberingPlan.nationalPrefixIsOptionalWhenFormattingInNationalFormat()||(!s.usesNationalPrefix()||Boolean(e.nationalPrefix)))}function _b(e,t){var n=t.indexOf("/");if(n<0)return!1;var i=t.indexOf("/",n+1);return!(i<0)&&(!("FROM_NUMBER_WITH_PLUS_SIGN"===e.__countryCallingCodeSource||"FROM_NUMBER_WITHOUT_PLUS_SIGN"===e.__countryCallingCodeSource)||ey(t.substring(0,n))!==e.countryCallingCode||t.slice(i+1).indexOf("/")>=0)}function qb(e,t,n,i,o){throw new Error("This part of code hasn't been ported")}var Bb=/[\\/] *x/;function Vb(e){return kb(Bb,e)}var Kb=/(?:(?:[0-3]?\d\/[01]?\d)|(?:[01]?\d\/[0-3]?\d))\/(?:[12]\d)?\d{2}/,Hb=/[12]\d{3}[-/]?[01]\d[-/]?[0-3]\d +[0-2]\d$/,zb=/^:[0-5]\d/;function Jb(e,t,n){if(Kb.test(e))return!1;if(Hb.test(e)){var i=n.slice(t+e.length);if(zb.test(i))return!1}return!0}var Gb="(\\[([",Zb=")\\])]",Yb="[^".concat(Gb).concat(Zb,"]"),Xb="[".concat(Gb).concat(Cm,"]"),Qb=new RegExp("^"+Xb),ew=$b(0,3),tw=new RegExp("^(?:[(\\[([])?(?:"+Yb+"+["+Zb+"])?"+Yb+"+(?:["+Gb+"]"+Yb+"+["+Zb+"])"+ew+Yb+"*$"),nw=/\d{1,5}-+\d{1,5}\s{0,4}\(\d{1,4}/;function iw(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return ow(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ow(e,t)}(e))||t){n&&(e=n);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function ow(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function rw(e,t,n){return t&&function(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var sw=Bm(),aw=["\\/+(.*)/","(\\([^(]*)","(?:".concat(Sb,"-|-").concat(Sb,")").concat(Sb,"*(.+)"),"[‒-―-]".concat(Sb,"*(.+)"),"\\.+".concat(Sb,"*([^.]+)"),"".concat(Sb,"+(").concat(Ib,"+)")],dw=$b(0,2),lw=$b(0,4),cw=bm+wm,uw=$b(0,cw),hw="[".concat(km,"]")+lw,fw=Rb+$b(1,cw),pw="(?:"+Xb+hw+")"+dw+fw+"(?:"+hw+fw+")"+uw+"(?:"+sw+")?",vw=new RegExp("[^".concat("0-9²³¹¼-¾٠-٩۰-۹߀-߉०-९০-৯৴-৹੦-੯૦-૯୦-୯୲-୷௦-௲౦-౯౸-౾೦-೯൦-൵๐-๙໐-໙༠-༳၀-၉႐-႙፩-፼ᛮ-ᛰ០-៩៰-៹᠐-᠙᥆-᥏᧐-᧚᪀-᪉᪐-᪙᭐-᭙᮰-᮹᱀-᱉᱐-᱙⁰⁴-⁹₀-₉⅐-ↂↅ-↉①-⒛⓪-⓿❶-➓⳽〇〡-〩〸-〺㆒-㆕㈠-㈩㉈-㉏㉑-㉟㊀-㊉㊱-㊿꘠-꘩ꛦ-ꛯ꠰-꠵꣐-꣙꤀-꤉꧐-꧙꩐-꩙꯰-꯹0-9").concat(Eb,"#]+$")),gw=Number.MAX_SAFE_INTEGER||Math.pow(2,53)-1,mw=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2?arguments[2]:void 0;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),!(n={v2:n.v2,defaultCallingCode:n.defaultCallingCode,defaultCountry:n.defaultCountry&&Fm(n.defaultCountry,i)?n.defaultCountry:void 0,leniency:n.leniency||(n.extended?"POSSIBLE":"VALID"),maxTries:n.maxTries||gw}).leniency)throw new TypeError("`leniency` is required");if("POSSIBLE"!==n.leniency&&"VALID"!==n.leniency)throw new TypeError('Invalid `leniency`: "'.concat(n.leniency,'". Supported values: "POSSIBLE", "VALID".'));if(n.maxTries<0)throw new TypeError("`maxTries` must be `>= 0`");if(this.text=t,this.options=n,this.metadata=i,this.leniency=Ub[n.leniency],!this.leniency)throw new TypeError('Unknown leniency: "'.concat(n.leniency,'"'));this.maxTries=n.maxTries,this.PATTERN=new RegExp(pw,"ig"),this.state="NOT_READY",this.searchIndex=0,this.regExpCache=new wb(32)}return rw(e,[{key:"find",value:function(){for(var e;this.maxTries>0&&null!==(e=this.PATTERN.exec(this.text));){var t=e[0],n=e.index;if(Jb(t=Vb(t),n,this.text)){var i=this.parseAndVerify(t,n,this.text)||this.extractInnerMatch(t,n,this.text);if(i){if(this.options.v2)return{startsAt:i.startsAt,endsAt:i.endsAt,number:i.phoneNumber};var o=i.phoneNumber,r={startsAt:i.startsAt,endsAt:i.endsAt,phone:o.nationalNumber};return o.country?r.country=o.country:r.countryCallingCode=o.countryCallingCode,o.ext&&(r.ext=o.ext),r}}this.maxTries--}}},{key:"extractInnerMatch",value:function(e,t,n){for(var i,o=iw(aw);!(i=o()).done;)for(var r=i.value,s=!0,a=void 0,d=new RegExp(r,"g");this.maxTries>0&&null!==(a=d.exec(e));){if(s){var l=kb(vw,e.slice(0,a.index)),c=this.parseAndVerify(l,t,n);if(c)return c;this.maxTries--,s=!1}var u=kb(vw,a[1]),h=e.indexOf(u,a.index),f=this.parseAndVerify(u,t+h,n);if(f)return f;this.maxTries--}}},{key:"parseAndVerify",value:function(e,t,n){if(function(e,t,n,i){if(tw.test(e)&&!nw.test(e)){if("POSSIBLE"!==i){if(t>0&&!Qb.test(e)){var o=n[t-1];if(Wb(o)||Tb(o))return!1}var r=t+e.length;if(r<n.length){var s=n[r];if(Wb(s)||Tb(s))return!1}}return!0}}(e,t,n,this.options.leniency)){var i=pb(e,{extended:!0,defaultCountry:this.options.defaultCountry,defaultCallingCode:this.options.defaultCallingCode},this.metadata);if(i&&i.isPossible())return this.leniency(i,{candidate:e,defaultCountry:this.options.defaultCountry,metadata:this.metadata,regExpCache:this.regExpCache})?{startsAt:t,endsAt:t+e.length,phoneNumber:i}:void 0}}},{key:"hasNext",value:function(){return"NOT_READY"===this.state&&(this.lastMatch=this.find(),this.lastMatch?this.state="READY":this.state="DONE"),"READY"===this.state}},{key:"next",value:function(){if(!this.hasNext())throw new Error("No next element");var e=this.lastMatch;return this.lastMatch=null,this.state="NOT_READY",e}}]),e}();function yw(e,t,n){return t&&function(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var bw=function(){function e(t){var n=t.onCountryChange,i=t.onCallingCodeChange;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.onCountryChange=n,this.onCallingCodeChange=i}return yw(e,[{key:"reset",value:function(e){var t=e.country,n=e.callingCode;this.international=!1,this.missingPlus=!1,this.IDDPrefix=void 0,this.callingCode=void 0,this.digits="",this.resetNationalSignificantNumber(),this.initCountryAndCallingCode(t,n)}},{key:"resetNationalSignificantNumber",value:function(){this.nationalSignificantNumber=this.getNationalDigits(),this.nationalSignificantNumberMatchesInput=!0,this.nationalPrefix=void 0,this.carrierCode=void 0,this.complexPrefixBeforeNationalSignificantNumber=void 0}},{key:"update",value:function(e){for(var t=0,n=Object.keys(e);t<n.length;t++){var i=n[t];this[i]=e[i]}}},{key:"initCountryAndCallingCode",value:function(e,t){this.setCountry(e),this.setCallingCode(t)}},{key:"setCountry",value:function(e){this.country=e,this.onCountryChange(e)}},{key:"setCallingCode",value:function(e){this.callingCode=e,this.onCallingCodeChange(e,this.country)}},{key:"startInternationalNumber",value:function(e,t){this.international=!0,this.initCountryAndCallingCode(e,t)}},{key:"appendDigits",value:function(e){this.digits+=e}},{key:"appendNationalSignificantNumberDigits",value:function(e){this.nationalSignificantNumber+=e}},{key:"getNationalDigits",value:function(){return this.international?this.digits.slice((this.IDDPrefix?this.IDDPrefix.length:0)+(this.callingCode?this.callingCode.length:0)):this.digits}},{key:"getDigitsWithoutInternationalPrefix",value:function(){return this.international&&this.IDDPrefix?this.digits.slice(this.IDDPrefix.length):this.digits}}]),e}();function ww(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return $w(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return $w(e,t)}(e))||t){n&&(e=n);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function $w(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}var kw="x",Cw=new RegExp(kw);function Sw(e,t){if(t<1)return"";for(var n="";t>1;)1&t&&(n+=e),t>>=1,e+=e;return n+e}function Iw(e,t){return")"===e[t]&&t++,function(e){var t=[],n=0;for(;n<e.length;)"("===e[n]?t.push(n):")"===e[n]&&t.pop(),n++;var i=0,o="";t.push(e.length);for(var r=0,s=t;r<s.length;r++){var a=s[r];o+=e.slice(i,a),i=a+1}return o}(e.slice(0,t))}function Rw(e,t,n){var i=n.metadata,o=n.shouldTryNationalPrefixFormattingRule,r=n.getSeparatorAfterNationalPrefix;if(new RegExp("^(?:".concat(t.pattern(),")$")).test(e.nationalSignificantNumber))return function(e,t,n){var i=n.metadata,o=n.shouldTryNationalPrefixFormattingRule,r=n.getSeparatorAfterNationalPrefix;if(e.nationalSignificantNumber,e.international,e.nationalPrefix,e.carrierCode,o(t)){var s=Ew(e,t,{useNationalPrefixFormattingRule:!0,getSeparatorAfterNationalPrefix:r,metadata:i});if(s)return s}return Ew(e,t,{useNationalPrefixFormattingRule:!1,getSeparatorAfterNationalPrefix:r,metadata:i})}(e,t,{metadata:i,shouldTryNationalPrefixFormattingRule:o,getSeparatorAfterNationalPrefix:r})}function Ew(e,t,n){var i=n.metadata,o=n.useNationalPrefixFormattingRule,r=n.getSeparatorAfterNationalPrefix,s=gy(e.nationalSignificantNumber,t,{carrierCode:e.carrierCode,useInternationalFormat:e.international,withNationalPrefix:o,metadata:i});if(o||(e.nationalPrefix?s=e.nationalPrefix+r(t)+s:e.complexPrefixBeforeNationalSignificantNumber&&(s=e.complexPrefixBeforeNationalSignificantNumber+" "+s)),function(e,t){return ey(e)===t.getNationalDigits()}(s,e))return s}function xw(e,t,n){return t&&function(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var Ow=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return xw(e,[{key:"parse",value:function(e){if(this.context=[{or:!0,instructions:[]}],this.parsePattern(e),1!==this.context.length)throw new Error("Non-finalized contexts left when pattern parse ended");var t=this.context[0],n=t.branches,i=t.instructions;if(n)return{op:"|",args:n.concat([Mw(i)])};if(0===i.length)throw new Error("Pattern is required");return 1===i.length?i[0]:i}},{key:"startContext",value:function(e){this.context.push(e)}},{key:"endContext",value:function(){this.context.pop()}},{key:"getContext",value:function(){return this.context[this.context.length-1]}},{key:"parsePattern",value:function(e){if(!e)throw new Error("Pattern is required");var t=e.match(jw);if(t){var n=t[1],i=e.slice(0,t.index),o=e.slice(t.index+n.length);switch(n){case"(?:":i&&this.parsePattern(i),this.startContext({or:!0,instructions:[],branches:[]});break;case")":if(!this.getContext().or)throw new Error('")" operator must be preceded by "(?:" operator');if(i&&this.parsePattern(i),0===this.getContext().instructions.length)throw new Error('No instructions found after "|" operator in an "or" group');var r=this.getContext().branches;r.push(Mw(this.getContext().instructions)),this.endContext(),this.getContext().instructions.push({op:"|",args:r});break;case"|":if(!this.getContext().or)throw new Error('"|" operator can only be used inside "or" groups');if(i&&this.parsePattern(i),!this.getContext().branches){if(1!==this.context.length)throw new Error('"branches" not found in an "or" group context');this.getContext().branches=[]}this.getContext().branches.push(Mw(this.getContext().instructions)),this.getContext().instructions=[];break;case"[":i&&this.parsePattern(i),this.startContext({oneOfSet:!0});break;case"]":if(!this.getContext().oneOfSet)throw new Error('"]" operator must be preceded by "[" operator');this.endContext(),this.getContext().instructions.push({op:"[]",args:Aw(i)});break;default:throw new Error("Unknown operator: ".concat(n))}o&&this.parsePattern(o)}else{if(Nw.test(e))throw new Error("Illegal characters found in a pattern: ".concat(e));this.getContext().instructions=this.getContext().instructions.concat(e.split(""))}}}]),e}();function Aw(e){for(var t=[],n=0;n<e.length;){if("-"===e[n]){if(0===n||n===e.length-1)throw new Error("Couldn't parse a one-of set pattern: ".concat(e));for(var i=e[n-1].charCodeAt(0)+1,o=e[n+1].charCodeAt(0)-1,r=i;r<=o;)t.push(String.fromCharCode(r)),r++}else t.push(e[n]);n++}return t}var Nw=/[\(\)\[\]\?\:\|]/,jw=new RegExp("(\\||\\(\\?\\:|\\)|\\[|\\])");function Mw(e){return 1===e.length?e[0]:e}function Pw(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Tw(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Tw(e,t)}(e))||t){n&&(e=n);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Tw(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function Ww(e,t,n){return t&&function(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var Lw=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.matchTree=(new Ow).parse(t)}return Ww(e,[{key:"match",value:function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).allowOverflow;if(!e)throw new Error("String is required");var n=Uw(e.split(""),this.matchTree,!0);if(n&&n.match&&delete n.matchedChars,!n||!n.overflow||t)return n}}]),e}();function Uw(e,t,n){if("string"==typeof t){var i=e.join("");return 0===t.indexOf(i)?e.length===t.length?{match:!0,matchedChars:e}:{partialMatch:!0}:0===i.indexOf(t)?n&&e.length>t.length?{overflow:!0}:{match:!0,matchedChars:e.slice(0,t.length)}:void 0}if(Array.isArray(t)){for(var o=e.slice(),r=0;r<t.length;){var s=Uw(o,t[r],n&&r===t.length-1);if(!s)return;if(s.overflow)return s;if(!s.match){if(s.partialMatch)return{partialMatch:!0};throw new Error("Unsupported match result:\n".concat(JSON.stringify(s,null,2)))}if(0===(o=o.slice(s.matchedChars.length)).length)return r===t.length-1?{match:!0,matchedChars:e}:{partialMatch:!0};r++}return n?{overflow:!0}:{match:!0,matchedChars:e.slice(0,e.length-o.length)}}switch(t.op){case"|":for(var a,d,l=Pw(t.args);!(d=l()).done;){var c=Uw(e,d.value,n);if(c){if(c.overflow)return c;if(c.match)return{match:!0,matchedChars:c.matchedChars};if(!c.partialMatch)throw new Error("Unsupported match result:\n".concat(JSON.stringify(c,null,2)));a=!0}}return a?{partialMatch:!0}:void 0;case"[]":for(var u,h=Pw(t.args);!(u=h()).done;){var f=u.value;if(e[0]===f)return 1===e.length?{match:!0,matchedChars:e}:n?{overflow:!0}:{match:!0,matchedChars:[f]}}return;default:throw new Error("Unsupported instruction tree: ".concat(t))}}function Dw(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Fw(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Fw(e,t)}(e))||t){n&&(e=n);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Fw(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function _w(e,t,n){return t&&function(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var qw=Sw("9",15),Bw=/[- ]/,Vw=new RegExp("["+km+"]*\\$1["+km+"]*(\\$\\d["+km+"]*)*$"),Kw=function(){function e(t){t.state;var n=t.metadata;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.metadata=n,this.resetFormat()}return _w(e,[{key:"resetFormat",value:function(){this.chosenFormat=void 0,this.template=void 0,this.nationalNumberTemplate=void 0,this.populatedNationalNumberTemplate=void 0,this.populatedNationalNumberTemplatePosition=-1}},{key:"reset",value:function(e,t){this.resetFormat(),e?(this.isNANP="1"===e.callingCode(),this.matchingFormats=e.formats(),t.nationalSignificantNumber&&this.narrowDownMatchingFormats(t)):(this.isNANP=void 0,this.matchingFormats=[])}},{key:"format",value:function(e,t){var n=this;if(function(e,t){return"IS_POSSIBLE"===ry(e,t)}(t.nationalSignificantNumber,this.metadata))for(var i,o=Dw(this.matchingFormats);!(i=o()).done;){var r=i.value,s=Rw(t,r,{metadata:this.metadata,shouldTryNationalPrefixFormattingRule:function(e){return n.shouldTryNationalPrefixFormattingRule(e,{international:t.international,nationalPrefix:t.nationalPrefix})},getSeparatorAfterNationalPrefix:function(e){return n.getSeparatorAfterNationalPrefix(e)}});if(s)return this.resetFormat(),this.chosenFormat=r,this.setNationalNumberTemplate(s.replace(/\d/g,kw),t),this.populatedNationalNumberTemplate=s,this.populatedNationalNumberTemplatePosition=this.template.lastIndexOf(kw),s}return this.formatNationalNumberWithNextDigits(e,t)}},{key:"formatNationalNumberWithNextDigits",value:function(e,t){var n=this.chosenFormat,i=this.chooseFormat(t);if(i)return i===n?this.formatNextNationalNumberDigits(e):this.formatNextNationalNumberDigits(t.getNationalDigits())}},{key:"narrowDownMatchingFormats",value:function(e){var t=this,n=e.nationalSignificantNumber,i=e.nationalPrefix,o=e.international,r=n,s=r.length-3;s<0&&(s=0),this.matchingFormats=this.matchingFormats.filter((function(e){return t.formatSuits(e,o,i)&&t.formatMatches(e,r,s)})),this.chosenFormat&&-1===this.matchingFormats.indexOf(this.chosenFormat)&&this.resetFormat()}},{key:"formatSuits",value:function(e,t,n){return!(n&&!e.usesNationalPrefix()&&!e.nationalPrefixIsOptionalWhenFormattingInNationalFormat())&&!(!t&&!n&&e.nationalPrefixIsMandatoryWhenFormattingInNationalFormat())}},{key:"formatMatches",value:function(e,t,n){var i=e.leadingDigitsPatterns().length;if(0===i)return!0;n=Math.min(n,i-1);var o=e.leadingDigitsPatterns()[n];if(t.length<3)try{return void 0!==new Lw(o).match(t,{allowOverflow:!0})}catch(e){return console.error(e),!0}return new RegExp("^(".concat(o,")")).test(t)}},{key:"getFormatFormat",value:function(e,t){return t?e.internationalFormat():e.format()}},{key:"chooseFormat",value:function(e){for(var t,n=this,i=function(){var i=t.value;return n.chosenFormat===i?"break":Vw.test(n.getFormatFormat(i,e.international))?n.createTemplateForFormat(i,e)?(n.chosenFormat=i,"break"):(n.matchingFormats=n.matchingFormats.filter((function(e){return e!==i})),"continue"):"continue"},o=Dw(this.matchingFormats.slice());!(t=o()).done;){var r=i();if("break"===r)break}return this.chosenFormat||this.resetFormat(),this.chosenFormat}},{key:"createTemplateForFormat",value:function(e,t){if(!(e.pattern().indexOf("|")>=0)){var n=this.getTemplateForFormat(e,t);return n?(this.setNationalNumberTemplate(n,t),!0):void 0}}},{key:"getSeparatorAfterNationalPrefix",value:function(e){return this.isNANP||e&&e.nationalPrefixFormattingRule()&&Bw.test(e.nationalPrefixFormattingRule())?" ":""}},{key:"getInternationalPrefixBeforeCountryCallingCode",value:function(e,t){var n=e.IDDPrefix,i=e.missingPlus;return n?t&&!1===t.spacing?n:n+" ":i?"":"+"}},{key:"getTemplate",value:function(e){if(this.template){for(var t=-1,n=0,i=e.international?this.getInternationalPrefixBeforeCountryCallingCode(e,{spacing:!1}):"";n<i.length+e.getDigitsWithoutInternationalPrefix().length;)t=this.template.indexOf(kw,t+1),n++;return Iw(this.template,t+1)}}},{key:"setNationalNumberTemplate",value:function(e,t){this.nationalNumberTemplate=e,this.populatedNationalNumberTemplate=e,this.populatedNationalNumberTemplatePosition=-1,t.international?this.template=this.getInternationalPrefixBeforeCountryCallingCode(t).replace(/[\d\+]/g,kw)+Sw(kw,t.callingCode.length)+" "+e:this.template=e}},{key:"getTemplateForFormat",value:function(e,t){var n=t.nationalSignificantNumber,i=t.international,o=t.nationalPrefix,r=t.complexPrefixBeforeNationalSignificantNumber,s=e.pattern();s=s.replace(/\[([^\[\]])*\]/g,"\\d").replace(/\d(?=[^,}][^,}])/g,"\\d");var a=qw.match(s)[0];if(!(n.length>a.length)){var d=new RegExp("^"+s+"$"),l=n.replace(/\d/g,"9");d.test(l)&&(a=l);var c,u=this.getFormatFormat(e,i);if(this.shouldTryNationalPrefixFormattingRule(e,{international:i,nationalPrefix:o})){var h=u.replace(vy,e.nationalPrefixFormattingRule());if(ey(e.nationalPrefixFormattingRule())===(o||"")+ey("$1")&&(u=h,c=!0,o))for(var f=o.length;f>0;)u=u.replace(/\d/,kw),f--}var p=a.replace(new RegExp(s),u).replace(new RegExp("9","g"),kw);return c||(r?p=Sw(kw,r.length)+" "+p:o&&(p=Sw(kw,o.length)+this.getSeparatorAfterNationalPrefix(e)+p)),i&&(p=py(p)),p}}},{key:"formatNextNationalNumberDigits",value:function(e){var t=function(e,t,n){for(var i,o=ww(n.split(""));!(i=o()).done;){var r=i.value;if(e.slice(t+1).search(Cw)<0)return;t=e.search(Cw),e=e.replace(Cw,r)}return[e,t]}(this.populatedNationalNumberTemplate,this.populatedNationalNumberTemplatePosition,e);if(t)return this.populatedNationalNumberTemplate=t[0],this.populatedNationalNumberTemplatePosition=t[1],Iw(this.populatedNationalNumberTemplate,this.populatedNationalNumberTemplatePosition+1);this.resetFormat()}},{key:"shouldTryNationalPrefixFormattingRule",value:function(e,t){var n=t.international,i=t.nationalPrefix;if(e.nationalPrefixFormattingRule()){var o=e.usesNationalPrefix();if(o&&i||!o&&!n)return!0}}}]),e}();function Hw(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==n)return;var i,o,r=[],s=!0,a=!1;try{for(n=n.call(e);!(s=(i=n.next()).done)&&(r.push(i.value),!t||r.length!==t);s=!0);}catch(e){a=!0,o=e}finally{try{s||null==n.return||n.return()}finally{if(a)throw o}}return r}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return zw(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return zw(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function zw(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function Jw(e,t,n){return t&&function(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var Gw=new RegExp("^"+("["+km+$m+"]+")+"$","i"),Zw="(?:[++]["+km+$m+"]*|["+km+$m+"]+)",Yw=new RegExp("[^"+km+$m+"]+.*$"),Xw=/[^\d\[\]]/,Qw=function(){function e(t){var n=t.defaultCountry,i=t.defaultCallingCode,o=t.metadata,r=t.onNationalSignificantNumberChange;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.defaultCountry=n,this.defaultCallingCode=i,this.metadata=o,this.onNationalSignificantNumberChange=r}return Jw(e,[{key:"input",value:function(e,t){var n,i=function(e){var t=function(e){var t=function(e){var t,n=e.search(Zw);if(n<0)return;e=e.slice(n),"+"===e[0]&&(t=!0,e=e.slice(1));e=e.replace(Yw,""),t&&(e="+"+e);return e}(e)||"";if("+"===t[0])return[t.slice(1),!0];return[t]}(e),n=Hw(t,2),i=n[0],o=n[1];Gw.test(i)||(i="");return[i,o]}(e),o=Hw(i,2),r=o[0],s=o[1],a=ey(r);return s&&(t.digits||(t.startInternationalNumber(),a||(n=!0))),a&&this.inputDigits(a,t),{digits:a,justLeadingPlus:n}}},{key:"inputDigits",value:function(e,t){var n=t.digits,i=n.length<3&&n.length+e.length>=3;if(t.appendDigits(e),i&&this.extractIddPrefix(t),this.isWaitingForCountryCallingCode(t)){if(!this.extractCountryCallingCode(t))return}else t.appendNationalSignificantNumberDigits(e);t.international||this.hasExtractedNationalSignificantNumber||this.extractNationalSignificantNumber(t.getNationalDigits(),(function(e){return t.update(e)}))}},{key:"isWaitingForCountryCallingCode",value:function(e){var t=e.international,n=e.callingCode;return t&&!n}},{key:"extractCountryCallingCode",value:function(e){var t=Dy("+"+e.getDigitsWithoutInternationalPrefix(),this.defaultCountry,this.defaultCallingCode,this.metadata.metadata),n=t.countryCallingCode,i=t.number;if(n)return e.setCallingCode(n),e.update({nationalSignificantNumber:i}),!0}},{key:"reset",value:function(e){if(e){this.hasSelectedNumberingPlan=!0;var t=e._nationalPrefixForParsing();this.couldPossiblyExtractAnotherNationalSignificantNumber=t&&Xw.test(t)}else this.hasSelectedNumberingPlan=void 0,this.couldPossiblyExtractAnotherNationalSignificantNumber=void 0}},{key:"extractNationalSignificantNumber",value:function(e,t){if(this.hasSelectedNumberingPlan){var n=Wy(e,this.metadata),i=n.nationalPrefix,o=n.nationalNumber,r=n.carrierCode;if(o!==e)return this.onExtractedNationalNumber(i,r,o,e,t),!0}}},{key:"extractAnotherNationalSignificantNumber",value:function(e,t,n){if(!this.hasExtractedNationalSignificantNumber)return this.extractNationalSignificantNumber(e,n);if(this.couldPossiblyExtractAnotherNationalSignificantNumber){var i=Wy(e,this.metadata),o=i.nationalPrefix,r=i.nationalNumber,s=i.carrierCode;if(r!==t)return this.onExtractedNationalNumber(o,s,r,e,n),!0}}},{key:"onExtractedNationalNumber",value:function(e,t,n,i,o){var r,s,a=i.lastIndexOf(n);if(a>=0&&a===i.length-n.length){s=!0;var d=i.slice(0,a);d!==e&&(r=d)}o({nationalPrefix:e,carrierCode:t,nationalSignificantNumber:n,nationalSignificantNumberMatchesInput:s,complexPrefixBeforeNationalSignificantNumber:r}),this.hasExtractedNationalSignificantNumber=!0,this.onNationalSignificantNumberChange()}},{key:"reExtractNationalSignificantNumber",value:function(e){return!!this.extractAnotherNationalSignificantNumber(e.getNationalDigits(),e.nationalSignificantNumber,(function(t){return e.update(t)}))||(this.extractIddPrefix(e)||this.fixMissingPlus(e)?(this.extractCallingCodeAndNationalSignificantNumber(e),!0):void 0)}},{key:"extractIddPrefix",value:function(e){var t=e.international,n=e.IDDPrefix,i=e.digits;if(e.nationalSignificantNumber,!t&&!n){var o=Ty(i,this.defaultCountry,this.defaultCallingCode,this.metadata.metadata);return void 0!==o&&o!==i?(e.update({IDDPrefix:i.slice(0,i.length-o.length)}),this.startInternationalNumber(e,{country:void 0,callingCode:void 0}),!0):void 0}}},{key:"fixMissingPlus",value:function(e){if(!e.international){var t=Uy(e.digits,this.defaultCountry,this.defaultCallingCode,this.metadata.metadata),n=t.countryCallingCode;if(t.number,n)return e.update({missingPlus:!0}),this.startInternationalNumber(e,{country:e.country,callingCode:n}),!0}}},{key:"startInternationalNumber",value:function(e,t){var n=t.country,i=t.callingCode;e.startInternationalNumber(n,i),e.nationalSignificantNumber&&(e.resetNationalSignificantNumber(),this.onNationalSignificantNumberChange(),this.hasExtractedNationalSignificantNumber=void 0)}},{key:"extractCallingCodeAndNationalSignificantNumber",value:function(e){this.extractCountryCallingCode(e)&&this.extractNationalSignificantNumber(e.getNationalDigits(),(function(t){return e.update(t)}))}}]),e}();function e$(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==n)return;var i,o,r=[],s=!0,a=!1;try{for(n=n.call(e);!(s=(i=n.next()).done)&&(r.push(i.value),!t||r.length!==t);s=!0);}catch(e){a=!0,o=e}finally{try{s||null==n.return||n.return()}finally{if(a)throw o}}return r}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return t$(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return t$(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function t$(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function n$(e,t,n){return t&&function(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var i$,o$=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.metadata=new jm(n);var i=e$(this.getCountryAndCallingCode(t),2),o=i[0],r=i[1];this.defaultCountry=o,this.defaultCallingCode=r,this.reset()}return n$(e,[{key:"getCountryAndCallingCode",value:function(e){var t,n;return e&&(Rm(e)?(t=e.defaultCountry,n=e.defaultCallingCode):t=e),t&&!this.metadata.hasCountry(t)&&(t=void 0),[t,n]}},{key:"input",value:function(e){var t=this.parser.input(e,this.state),n=t.digits;if(t.justLeadingPlus)this.formattedOutput="+";else if(n){var i;if(this.determineTheCountryIfNeeded(),this.state.nationalSignificantNumber&&this.formatter.narrowDownMatchingFormats(this.state),this.metadata.hasSelectedNumberingPlan()&&(i=this.formatter.format(n,this.state)),void 0===i&&this.parser.reExtractNationalSignificantNumber(this.state)){this.determineTheCountryIfNeeded();var o=this.state.getNationalDigits();o&&(i=this.formatter.format(o,this.state))}this.formattedOutput=i?this.getFullNumber(i):this.getNonFormattedNumber()}return this.formattedOutput}},{key:"reset",value:function(){var e=this;return this.state=new bw({onCountryChange:function(t){e.country=t},onCallingCodeChange:function(t,n){e.metadata.selectNumberingPlan(n,t),e.formatter.reset(e.metadata.numberingPlan,e.state),e.parser.reset(e.metadata.numberingPlan)}}),this.formatter=new Kw({state:this.state,metadata:this.metadata}),this.parser=new Qw({defaultCountry:this.defaultCountry,defaultCallingCode:this.defaultCallingCode,metadata:this.metadata,state:this.state,onNationalSignificantNumberChange:function(){e.determineTheCountryIfNeeded(),e.formatter.reset(e.metadata.numberingPlan,e.state)}}),this.state.reset({country:this.defaultCountry,callingCode:this.defaultCallingCode}),this.formattedOutput="",this}},{key:"isInternational",value:function(){return this.state.international}},{key:"getCallingCode",value:function(){if(this.isInternational())return this.state.callingCode}},{key:"getCountryCallingCode",value:function(){return this.getCallingCode()}},{key:"getCountry",value:function(){if(this.state.digits)return this._getCountry()}},{key:"_getCountry",value:function(){return this.state.country}},{key:"determineTheCountryIfNeeded",value:function(){this.state.country&&!this.isCountryCallingCodeAmbiguous()||this.determineTheCountry()}},{key:"getFullNumber",value:function(e){var t=this;if(this.isInternational()){var n=function(e){return t.formatter.getInternationalPrefixBeforeCountryCallingCode(t.state,{spacing:!!e})+e},i=this.state.callingCode;return n(i?e?"".concat(i," ").concat(e):i:"".concat(this.state.getDigitsWithoutInternationalPrefix()))}return e}},{key:"getNonFormattedNationalNumberWithPrefix",value:function(){var e=this.state,t=e.nationalSignificantNumber,n=e.complexPrefixBeforeNationalSignificantNumber,i=e.nationalPrefix,o=t,r=n||i;return r&&(o=r+o),o}},{key:"getNonFormattedNumber",value:function(){var e=this.state.nationalSignificantNumberMatchesInput;return this.getFullNumber(e?this.getNonFormattedNationalNumberWithPrefix():this.state.getNationalDigits())}},{key:"getNonFormattedTemplate",value:function(){var e=this.getNonFormattedNumber();if(e)return e.replace(/[\+\d]/g,kw)}},{key:"isCountryCallingCodeAmbiguous",value:function(){var e=this.state.callingCode,t=this.metadata.getCountryCodesForCallingCode(e);return t&&t.length>1}},{key:"determineTheCountry",value:function(){this.state.setCountry(By(this.isInternational()?this.state.callingCode:this.defaultCallingCode,{nationalNumber:this.state.nationalSignificantNumber,defaultCountry:this.defaultCountry,metadata:this.metadata}))}},{key:"getNumberValue",value:function(){var e=this.state,t=e.digits,n=e.callingCode,i=e.country,o=e.nationalSignificantNumber;if(t)return this.isInternational()?n?"+"+n+o:"+"+t:i||n?"+"+(i?this.metadata.countryCallingCode():n)+o:void 0}},{key:"getNumber",value:function(){var e=this.state,t=e.nationalSignificantNumber,n=e.carrierCode,i=e.callingCode,o=this._getCountry();if(t&&(o||i)){if(o&&o===this.defaultCountry){var r=new jm(this.metadata.metadata);r.selectNumberingPlan(o);var s=r.numberingPlan.callingCode(),a=this.metadata.getCountryCodesForCallingCode(s);if(a.length>1){var d=qy(t,{countries:a,defaultCountry:this.defaultCountry,metadata:this.metadata.metadata});d&&(o=d)}}var l=new jy(o||i,t,this.metadata.metadata);return n&&(l.carrierCode=n),l}}},{key:"isPossible",value:function(){var e=this.getNumber();return!!e&&e.isPossible()}},{key:"isValid",value:function(){var e=this.getNumber();return!!e&&e.isValid()}},{key:"getNationalNumber",value:function(){return this.state.nationalSignificantNumber}},{key:"getChars",value:function(){return(this.state.international?"+":"")+this.state.digits}},{key:"getTemplate",value:function(){return this.formatter.getTemplate(this.state)||this.getNonFormattedTemplate()||""}}]),e}();function r$(){return function(e,t){var n=Array.prototype.slice.call(t);return n.push(dm),e.apply(this,n)}(pb,arguments)}function s$(e,t){return mw.call(this,e,t,dm)}function a$(e){return o$.call(this,e,dm)}function d$(){return jm.call(this,dm)}s$.prototype=Object.create(mw.prototype,{}),s$.prototype.constructor=s$,a$.prototype=Object.create(o$.prototype,{}),a$.prototype.constructor=a$,d$.prototype=Object.create(jm.prototype,{}),d$.prototype.constructor=d$,function(e){e[e.text=1]="text",e[e.numeric=2]="numeric",e[e.bool=3]="bool",e[e.singleSelect=4]="singleSelect",e[e.array=5]="array",e[e.date=6]="date"}(i$||(i$={}));const l$=(e,t)=>Object.entries(e).reduce(((e,[n,i])=>{const[o,...r]=n.split(".");return t!==o?Object.assign(e,{[n]:i}):(e[o]||(e[o]={}),e[o][r.join(".")]=i,e)}),{}),c$=(e,t)=>Object.fromEntries(Object.entries(e||{}).map((([e,n])=>[`${t}.${e}`,n]))),u$=(e,t)=>e===i$.date?(e=>new Date(Number(e)).toLocaleDateString("en-US"))(`${t}`):t;function h$(e){return new URLSearchParams(window.location.search).get(e)}const f$={enabled:"active",disabled:"disabled",invited:"invited"},p$={password:"Passwords",totp:"TOTP",recovery_codes:"Recovery Codes",security_questions:"Security Questions"},v$=e=>e.tenantRoles.data,g$=e=>e.selectedUsersLoginIds,m$=e=>e.notifications,y$=e=>e.customAttributes.data,b$=Al((e=>e.subTenantRoles.data),(e=>Object.fromEntries(e.map((({tenantId:e,tenantName:t,roleNames:n})=>[e,t?{label:t,options:n}:n]))))),w$=Al(b$,(e=>Object.keys(e).length>0)),$$=Al(y$,(e=>Object.fromEntries(e.map((e=>[e.name,e.type]))))),k$=Al((e=>e.usersList.data),$$,((e,t)=>e.map((e=>Object.assign(Object.assign({},e),{customAttributes:Object.fromEntries(Object.entries(e.customAttributes||{}).map((([e,n])=>[e,u$(t[e],n)])))}))))),C$=e=>{const t=[e.roleNames||[],...(e.userTenants||[]).map((e=>e.roleNames||[]))].filter((e=>e.length>0));if(0===t.length)return e.roleNames||[];const n=t.map((e=>[...e].sort().join("\0")));return n.every((e=>e===n[0]))?t[0]:"Multiple roles"},S$=e=>{if(!(null==e?void 0:e.lockReason))return"";const t=p$[e.lockReason]||e.lockReason,n=e.tempLockExpiration||0;return 1e3*n>Date.now()?`Temp. Locked - ${t}`:"disabled"===e.status&&0===n?`Locked - ${t}`:""},I$=Al(k$,(e=>e.map((e=>{var t;return Object.assign(Object.assign(Object.assign({},e),c$(null==e?void 0:e.customAttributes,"customAttributes")),{createdTimeFormatted:new Date(1e3*((null==e?void 0:e.createdTime)||0)).toLocaleString(),status:f$[e.status]||e.status,lockReasonFormatted:S$(e),roles:C$(e),tenants:null===(t=e.userTenants)||void 0===t?void 0:t.map((e=>e.tenantName||e.tenantId))})})))),R$=Al(g$,I$,((e,t)=>t.filter((t=>e.includes(t.loginIds))))),E$=Al(R$,(e=>e.map((e=>e.userId)))),x$=Al(R$,(e=>e.map((({userId:e,loginIds:t})=>({userId:e,loginIds:t}))))),O$=Al(R$,(e=>e.map((e=>({userId:e.userId,roles:e.roleNames}))))),A$=Al(R$,(e=>e.map((e=>e.status)))),N$=Al(R$,(e=>e.every((e=>e.editable)))),j$=Al(g$,(e=>!!e.length)),M$=Al(g$,(e=>1===e.length)),P$=Al(g$,(e=>{var t;return null===(t=null==e?void 0:e[0])||void 0===t?void 0:t[0]})),T$=Al(M$,A$,((e,t)=>e&&t.every((e=>e===f$.enabled)))),W$=Al(A$,(e=>e.every((e=>e===f$.disabled)))),L$=Al(R$,(e=>{var t;return 1===e.length?e[0].name||e[0].email||(null===(t=e[0].loginIds)||void 0===t?void 0:t[0]):`${e.length} users`})),U$=Al(M$,W$,N$,((e,t,n)=>e&&t&&n)),D$=Al(M$,T$,N$,((e,t,n)=>e&&t&&n)),F$=Al(M$,N$,((e,t)=>e&&t)),_$=Al(M$,N$,((e,t)=>e&&t)),q$=Al(M$,N$,((e,t)=>e&&t)),B$=j$,V$=e=>(...t)=>n=>{n.addCase(e.pending,((e,n)=>{t.forEach((({onPending:t})=>{null==t||t(e,n)}))})),n.addCase(e.fulfilled,((e,n)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,n)}))})),n.addCase(e.rejected,((e,n)=>{t.forEach((({onRejected:t})=>{null==t||t(e,n)}))}))},K$=e=>({onFulfilled:t=>{e(t).loading=!1},onPending:t=>{e(t).loading=!0,e(t).error=null},onRejected:(t,n)=>{e(t).loading=!1,e(t).error=n.error}}),H$=({getErrorMsg:e,getSuccessMsg:t})=>({onFulfilled:(e,n)=>{t&&e.notifications.push({type:"success",msg:t(n)})},onRejected:(t,n)=>{e&&t.notifications.push({type:"error",msg:e(n)})}}),z$=lc("users/create",((e,{extra:{api:t}})=>t.user.create(e))),J$=V$(z$)({onFulfilled:(e,t)=>{var n;const i=(null===(n=t.payload)||void 0===n?void 0:n.userId)?e.usersList.data.findIndex((e=>e.userId===t.payload.userId)):-1;-1!==i?e.usersList.data[i]=t.payload:e.usersList.data.unshift(t.payload)}},K$((e=>e.createUser)),H$({getSuccessMsg:()=>"User created successfully",getErrorMsg:e=>{var t;const n=null===(t=e.error)||void 0===t?void 0:t.message;return`\n <div>\n <div>Failed to create user</div>\n ${Vi(n)}\n </div>`}})),G$={action:z$,reducer:J$},Z$=lc("users/delete",((e,{extra:{api:t}})=>t.user.deleteBatch(e))),Y$=V$(Z$)({onFulfilled:(e,t)=>{e.usersList.data=e.usersList.data.filter((e=>!t.meta.arg.includes(e.userId))),e.selectedUsersLoginIds=[]}},K$((e=>e.deleteUser)),H$({getSuccessMsg:e=>ji(e.meta.arg.length)`${["",e.meta.arg.length]} ${["U","u"]}ser${["","s"]} deleted successfully`,getErrorMsg:e=>ji(e.meta.arg.length)`Failed to delete user${["","s"]}`})),X$={action:Z$,reducer:Y$},Q$=lc("users/setTempPassword",((e,{extra:{api:t}})=>t.user.setTempPassword(e))),ek=V$(Q$)(K$((e=>e.setTempUserPassword)),H$({getSuccessMsg:()=>"Successfully reset user password",getErrorMsg:e=>{var t;const n=null===(t=e.error)||void 0===t?void 0:t.message;return`\n <div>\n <div>Failed to reset user's password</div>\n ${Vi(n)}\n </div>`}})),tk={action:Q$,reducer:ek},nk=lc("users/getCustomAttributes",((e,{extra:{api:t}})=>t.user.getCustomAttributes())),ik=V$(nk)({onFulfilled:(e,t)=>{e.customAttributes.data=t.payload}},K$((e=>e.customAttributes))),ok={action:nk,reducer:ik},rk=lc("users/search",((e,{extra:{api:t},getState:n})=>{const i=n().searchParams;return t.user.search(Object.assign(Object.assign({},i),e))})),sk=V$(rk)({onPending:(e,t)=>{e.searchParams=Object.assign(Object.assign({},e.searchParams),t.meta.arg)},onFulfilled:(e,t)=>{e.usersList.data=t.payload}},K$((e=>e.usersList))),ak={action:rk,reducer:sk},dk=lc("tenant/getTenantRoles",((e,{extra:{api:t}})=>t.tenant.getTenantRoles())),lk=V$(dk)({onFulfilled:(e,t)=>{e.tenantRoles.data=t.payload.roles}},K$((e=>e.tenantRoles))),ck={action:dk,reducer:lk},uk=lc("tenant/getSubTenantRoles",((e,{extra:{api:t}})=>t.tenant.getSubTenantRoles())),hk=V$(uk)({onFulfilled:(e,t)=>{e.subTenantRoles.data=t.payload.roles},onRejected:e=>{e.subTenantRoles.data=[]}},K$((e=>e.subTenantRoles))),fk={action:uk,reducer:hk},pk=lc("users/update",((e,{extra:{api:t}})=>t.user.update(e))),vk=V$(pk)({onFulfilled:(e,t)=>{const n=e.usersList.data.findIndex((e=>Oi(e.loginIds,t.payload.loginIds)));-1!==n&&(e.usersList.data[n]=t.payload)}},K$((e=>e.updateUser)),H$({getSuccessMsg:()=>"User updated successfully",getErrorMsg:e=>{var t;const n=null===(t=e.error)||void 0===t?void 0:t.message;return`\n <div>\n <div>Failed to update user</div>\n ${Vi(n)}\n </div>`}})),gk={action:pk,reducer:vk},mk=lc("users/enable",((e,{extra:{api:t}})=>t.user.enable(e))),yk=V$(mk)({onFulfilled:(e,t)=>{var n;const i=e.usersList.data.findIndex((e=>{var n;return Oi(e.loginIds,null===(n=t.payload.user)||void 0===n?void 0:n.loginIds)}));-1!==i&&(e.usersList.data[i].status=null===(n=t.payload.user)||void 0===n?void 0:n.status)}},K$((e=>e.enableUser)),H$({getSuccessMsg:()=>"User enabled successfully",getErrorMsg:e=>{var t;const n=null===(t=e.error)||void 0===t?void 0:t.message;return`\n <div>\n <div>Failed to enable user</div>\n ${Vi(n)}\n </div>`}})),bk={action:mk,reducer:yk},wk=lc("users/disable",((e,{extra:{api:t}})=>t.user.disable(e))),$k=V$(wk)({onFulfilled:(e,t)=>{var n;const i=e.usersList.data.findIndex((e=>{var n;return Oi(e.loginIds,null===(n=t.payload.user)||void 0===n?void 0:n.loginIds)}));-1!==i&&(e.usersList.data[i].status=null===(n=t.payload.user)||void 0===n?void 0:n.status)}},K$((e=>e.disableUser)),H$({getSuccessMsg:()=>"User disabled successfully",getErrorMsg:e=>{var t;const n=null===(t=e.error)||void 0===t?void 0:t.message;return`\n <div>\n <div>Failed to disable user</div>\n ${Vi(n)}\n </div>`}})),kk={action:wk,reducer:$k},Ck=lc("users/removePasskey",((e,{extra:{api:t}})=>t.user.removePasskey(e))),Sk={action:Ck,reducer:V$(Ck)(K$((e=>e.removePasskey)),H$({getSuccessMsg:()=>"Successfully removed user's passkey",getErrorMsg:e=>{var t;const n=null===(t=e.error)||void 0===t?void 0:t.message;return`\n <div>\n <div>Failed to remove user's passkey</div>\n ${Vi(n)}\n </div>`}}))},Ik={usersList:{data:[],loading:!1,error:null},createUser:{loading:!1,error:null},updateUser:{loading:!1,error:null},deleteUser:{loading:!1,error:null},enableUser:{loading:!1,error:null},disableUser:{loading:!1,error:null},removePasskey:{loading:!1,error:null},setTempUserPassword:{loading:!1,error:null},customAttributes:{loading:!1,error:null,data:[]},tenantRoles:{loading:!1,error:null,data:[]},subTenantRoles:{loading:!1,error:null,data:[]},searchParams:{text:"",sort:[]},selectedUsersLoginIds:[],notifications:[]},Rk="/v1/mgmt/user/search",Ek="/v1/mgmt/user/delete/batch",xk="/v1/mgmt/user/create",Ok="/v1/mgmt/user/patch",Ak="/v1/mgmt/user/update/status",Nk="/v1/mgmt/user/password/set/temporary",jk="/v1/mgmt/user/passkeys/delete",Mk="/v1/mgmt/user/customattributes",Pk="/v1/mgmt/role/all",Tk="/v1/mgmt/role/subtenant/all",Wk=e=>c(void 0,void 0,void 0,(function*(){const t=yield e.text(),n=JSON.parse(t);if(!e.ok){const t=`${n.errorDescription}${n.errorMessage?`: ${n.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(n),e.text=()=>Promise.resolve(t)})),Lk=({httpClient:e,tenant:t,mock:n})=>({search:(...i)=>c(void 0,[...i],void 0,(function*(i={}){const{limit:o=1e4}=i,r=l(i,["limit"]);if(n)return(e=>c(void 0,[e],void 0,(function*({text:e,sort:t}){return new Promise((n=>{const i=[],o=(new Date).getTime();for(let e=1;e<10;e+=1)i.push({loginIds:[`user${e}@company.com`],externalIds:[`user${e}@company.com`],userId:`user-${e}`,name:`User ${e}`,email:`user${e}@company.com`,roleNames:[`Role ${e}`],phone:`+1-202-555-010${e}`,recoveryEmail:`recovery${e}@company.com`,recoveryPhone:`+1-202-555-020${e}`,verifiedEmail:!0,verifiedPhone:!0,verifiedRecoveryEmail:!0,verifiedRecoveryPhone:!0,userTenants:[{tenantId:"sub-tenant-1",tenantName:"Hurray",roleNames:["Role 1","Role 2"]}],status:"enabled",editable:!0,createdTime:o,createdTimeFormatted:new Date(1e3*(o||0)).toLocaleString(),customAttributes:{},familyName:"",givenName:"",middleName:"",picture:"",password:!0,SAML:e%3==0,OIDC:e%3==1,SCIM:e%3==2,test:!1,TOTP:!1,webauthn:!1});t.forEach((e=>{i.sort(((t,n)=>((e,t,n)=>{if("boolean"==typeof e&&"boolean"==typeof t){const i=e?1:0,o=t?1:0;return n?i-o:o-i}const i=(null==e?void 0:e.toString())||"",o=(null==t?void 0:t.toString())||"";return n?o.localeCompare(i):i.localeCompare(o)})(t[e.field],n[e.field],e.desc)))})),n(i.filter((t=>t.name.toLowerCase().includes(e.toLowerCase())||t.phone.toLowerCase().includes(e.toLowerCase())||t.status.toLowerCase().includes(e.toLowerCase())||"active"===e.toLowerCase()||t.familyName.toLowerCase().includes(e.toLowerCase())||t.givenName.toLowerCase().includes(e.toLowerCase())||t.middleName.toLowerCase().includes(e.toLowerCase())||t.email.toLowerCase().includes(e.toLowerCase()))))}))})))(Object.assign(Object.assign({},r),{limit:o}));const s=yield e.post(Rk,Object.assign(Object.assign({},r),{limit:o,withTestUser:!1}),{queryParams:{tenant:t}});return yield Wk(s),(yield s.json()).users})),deleteBatch:i=>c(void 0,void 0,void 0,(function*(){if(n)return c(void 0,void 0,void 0,(function*(){}));const o=yield e.post(Ek,{userIds:i},{queryParams:{tenant:t}});return yield Wk(o),o.json()})),create:i=>c(void 0,[i],void 0,(function*({loginId:i,email:o,phone:r,recoveryEmail:s,recoveryPhone:a,displayName:d,roles:l,customAttributes:u,picture:h,verifiedEmail:f,verifiedPhone:p,givenName:v,middleName:g,familyName:m,additionalLoginIds:y,sendSMS:b,sendMail:w,inviteUrl:$,invite:k,userTenants:C}){if(n)return(e=>c(void 0,[e],void 0,(function*({loginId:e,email:t,phone:n,displayName:i,roles:o,customAttributes:r,picture:s,verifiedEmail:a,verifiedPhone:d,givenName:l,middleName:c,familyName:u,userTenants:h}){return new Promise((f=>{const p=Math.random().toString(10).substring(15);f({loginIds:[e],externalIds:[e],userId:`user-${p}`,email:t,phone:n,name:i,roleNames:o,customAttributes:r,picture:s,recoveryEmail:"",recoveryPhone:"",verifiedEmail:a,verifiedPhone:d,verifiedRecoveryEmail:!1,verifiedRecoveryPhone:!1,givenName:l,middleName:c,familyName:u,createdTime:(new Date).getTime(),editable:!0,password:!0,SAML:!1,SCIM:!1,OIDC:!1,status:"enabled",test:!1,TOTP:!1,userTenants:h||[],webauthn:!1})}))})))({loginId:i,email:o,phone:r,recoveryEmail:s,recoveryPhone:a,displayName:d,roles:l,customAttributes:u,picture:h,verifiedEmail:f,verifiedPhone:p,givenName:v,middleName:g,familyName:m,additionalLoginIds:y,sendSMS:b,sendMail:w,inviteUrl:$,invite:k,userTenants:C});const S=yield e.post(xk,{loginId:i,email:o,phone:r,recoveryEmail:s,recoveryPhone:a,displayName:d,givenName:v,middleName:g,familyName:m,roleNames:l,userTenants:C,customAttributes:u,picture:h,verifiedEmail:f,verifiedPhone:p,verifiedRecoveryEmail:!!s||void 0,verifiedRecoveryPhone:!!a||void 0,additionalLoginIds:y,sendSMS:b,sendMail:w,inviteUrl:$,invite:k},{queryParams:{tenant:t}});return yield Wk(S),(yield S.json()).user})),update:i=>c(void 0,[i],void 0,(function*({loginId:i,email:o,phone:r,recoveryEmail:s,recoveryPhone:a,displayName:d,roles:l,customAttributes:u,picture:h,verifiedEmail:f,verifiedPhone:p,givenName:v,middleName:g,familyName:m,additionalLoginIds:y,userTenants:b}){if(n)return(e=>c(void 0,[e],void 0,(function*({loginId:e,email:t,phone:n,displayName:i,roles:o,customAttributes:r,picture:s,verifiedEmail:a,verifiedPhone:d,givenName:l,middleName:c,familyName:u,userTenants:h}){return new Promise((f=>{f({loginIds:[e],externalIds:[e],userId:e,email:t,phone:n,name:i,roleNames:o,customAttributes:r||{},picture:s,recoveryEmail:"",recoveryPhone:"",verifiedEmail:a,verifiedPhone:d,verifiedRecoveryEmail:!1,verifiedRecoveryPhone:!1,givenName:l,middleName:c,familyName:u,createdTime:(new Date).getTime(),editable:!0,password:!0,SAML:!1,SCIM:!1,OIDC:!1,status:"enabled",test:!1,TOTP:!1,userTenants:h||[],webauthn:!1})}))})))({loginId:i,email:o,phone:r,recoveryEmail:s,recoveryPhone:a,displayName:d,roles:l,customAttributes:u,picture:h,verifiedEmail:f,verifiedPhone:p,givenName:v,middleName:g,familyName:m,additionalLoginIds:y,userTenants:b});const w=yield e.patch(Ok,{loginId:i,email:o,phone:r,recoveryEmail:s,recoveryPhone:a,displayName:d,givenName:v,middleName:g,familyName:m,roleNames:l,userTenants:b,customAttributes:u,picture:h,verifiedEmail:f,verifiedPhone:p,verifiedRecoveryEmail:!!s||void 0,verifiedRecoveryPhone:!!a||void 0,additionalLoginIds:y},{queryParams:{tenant:t}});return yield Wk(w),(yield w.json()).user})),enable:i=>c(void 0,void 0,void 0,(function*(){if(n)return(e=>c(void 0,void 0,void 0,(function*(){return new Promise((t=>{t({user:{loginIds:[e],status:"enabled"}})}))})))(i);const o=yield e.post(Ak,{loginId:i,status:"enabled"},{queryParams:{tenant:t}});return yield Wk(o),o.json()})),disable:i=>c(void 0,void 0,void 0,(function*(){if(n)return(e=>c(void 0,void 0,void 0,(function*(){return new Promise((t=>{t({user:{loginIds:[e],status:"disabled"}})}))})))(i);const o=yield e.post(Ak,{loginId:i,status:"disabled"},{queryParams:{tenant:t}});return yield Wk(o),o.json()})),removePasskey:i=>c(void 0,void 0,void 0,(function*(){if(n)return c(void 0,void 0,void 0,(function*(){}));const o=yield e.post(jk,{loginId:i},{queryParams:{tenant:t}});return yield Wk(o),o.json()})),setTempPassword:i=>c(void 0,void 0,void 0,(function*(){if(n)return c(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({cleartext:Math.random().toString(20).substring(2)})}))}));const o=yield e.post(Nk,{loginId:i},{queryParams:{tenant:t}});return yield Wk(o),o.json()})),getCustomAttributes:()=>c(void 0,void 0,void 0,(function*(){if(n)return c(void 0,void 0,void 0,(function*(){return new Promise((e=>{e([])}))}));const i=yield e.get(Mk,{queryParams:{tenant:t}});return yield Wk(i),(yield i.json()).data}))}),Uk=({httpClient:e,tenant:t,mock:n})=>({getTenantRoles:()=>c(void 0,void 0,void 0,(function*(){if(n)return(e=>new Promise((t=>{const n=[];for(let t=1;t<5;t+=1)n.push({name:`Role ${t}`,description:`Role description ${t}`,createdTime:new Date,permissionNames:[`Permission ${t}`],tenantId:e});t({roles:n})})))(t);const i=yield e.get(Pk,{queryParams:{tenant:t}});return yield Wk(i),i.json()})),getSubTenantRoles:()=>c(void 0,void 0,void 0,(function*(){if(n)return new Promise((e=>{e({roles:[{tenantId:"sub-tenant-1",tenantName:"Sub Tenant 1",roleNames:["Role 1","Role 2"]},{tenantId:"sub-tenant-2",tenantName:"Sub Tenant 2",roleNames:["Role 1","Role 3"]},{tenantId:"sub-tenant-3",tenantName:"Sub Tenant 3",roleNames:["Role 2"]}]})}));const i=yield e.get(Tk,{queryParams:{tenant:t}});return yield Wk(i),i.json()}))}),Dk=Ti((e=>{var t,n,i,o;const r=Ei(js,wc,As,Cs,Ms,Sc,Ns({tenant:Ns.missingAttrValidator}))(e);return o=class extends r{constructor(){super(...arguments),t.add(this),n.set(this,void 0)}get tenantId(){return this.getAttribute("tenant")}get mock(){return this.getAttribute("mock")}get styleId(){return this.getAttribute("style-id")||Qs}get api(){return u(this,n,"f")||u(this,t,"m",i).call(this),u(this,n,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.init)||void 0===o?void 0:o.call(this),this.observeAttributes(["project-id","base-url","tenant"],(()=>{u(this,n,"f")&&u(this,t,"m",i).call(this)}))}))}},n=new WeakMap,t=new WeakSet,i=function(){this.logger.debug("creating an sdk instance"),h(this,n,((e,t,n,i)=>{const o=yi(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"user-management-widget","x-descope-widget-id":i,"x-descope-widget-version":"0.21.16"}}));return{user:Lk({httpClient:o.httpClient,tenant:t,mock:n}),tenant:Uk({httpClient:o.httpClient,tenant:t,mock:n}),httpClient:o.httpClient}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},this.tenantId,"true"===this.mock,this.widgetId),"f")},o})),Fk=Ti((e=>{const t=Ei(yc({name:"widget",initialState:Ik,reducers:{setSelectedUsersIds:(e,{payload:t})=>{e.selectedUsersLoginIds=t},clearNotifications:e=>{e.notifications=[]}},extraReducers:e=>{G$.reducer(e),gk.reducer(e),bk.reducer(e),kk.reducer(e),X$.reducer(e),ak.reducer(e),tk.reducer(e),Sk.reducer(e),ok.reducer(e),ck.reducer(e),fk.reducer(e)},asyncActions:{searchUsers:ak.action,createUser:G$.action,updateUser:gk.action,enableUser:bk.action,disableUser:kk.action,deleteUsers:X$.action,removePasskey:Sk.action,getCustomAttributes:ok.action,getTenantRoles:ck.action,getSubTenantRoles:fk.action,setTempUserPassword:tk.action}}),Os,Cs,Dk)(e);return class extends t{constructor(...e){super(...e),this.state=Ik,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),_k=Ti((e=>{var t,n,i;return i=class extends(Ei(Cs,Os,Hs,Xs,Cc("user-management-widget"),Fk,$c)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){return c(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.init)||void 0===i?void 0:i.call(this),this.injectStyle(".hidden { display: none; }");const o=this.getWidgetConfig().then((e=>(null==e?void 0:e.allowSubTenants)?this.actions.getSubTenantRoles():void 0));yield Promise.all([u(this,t,"m",n).call(this),this.actions.searchUsers(),this.actions.getTenantRoles(),this.actions.getCustomAttributes(),o]),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,n=function(){return c(this,void 0,void 0,(function*(){const e=xi(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},i})),qk=Ti((e=>{var t,n,i,o,r,s,a,d,l;return l=class extends(Ei(Fk,ud,bc,Cs,$c,_k)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),i.set(this,void 0),o.set(this,void 0),a.set(this,(()=>c(this,void 0,void 0,(function*(){yield u(this,n,"f").setData(v$(this.state).map((({name:e,description:t})=>({value:e,label:e,description:t}))))})))),d.set(this,(()=>{var e;const t=w$(this.state);null===(e=u(this,i,"f"))||void 0===e||e.classList.toggle("hidden",!t),t&&u(this,o,"f").setData(b$(this.state))}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),u(this,t,"m",r).call(this)}))}},n=new WeakMap,i=new WeakMap,o=new WeakMap,a=new WeakMap,d=new WeakMap,t=new WeakSet,r=function(){return c(this,void 0,void 0,(function*(){var e;this.createUserModal=this.createModal(),this.createUserModal.setContent(xi(yield this.fetchWidgetPage("create-user-modal.html")));const r=new ka((()=>{var e;return null===(e=this.createUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger}),l=()=>{this.resetFormData(this.createUserModal.ele),u(this,o,"f").value=[]};r.onClick((()=>{this.createUserModal.close(),l()}));const f=new ka((()=>{var e;return null===(e=this.createUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});f.onClick((()=>c(this,void 0,void 0,(function*(){if(this.validateForm(this.createUserModal.ele)){const e=this.getFormData(this.createUserModal.ele),t=u(this,o,"f").mergedValue;this.actions.createUser(Object.assign(Object.assign({},l$(e,"customAttributes")),{userTenants:t,invite:!0,verifiedEmail:!0,verifiedPhone:!0})),this.createUserModal.close(),l()}})))),h(this,n,new Qa((()=>{var e;return null===(e=this.createUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="roles-multiselect"]')}),{logger:this.logger}),"f"),h(this,i,null===(e=this.createUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="sub-tenant-section"]'),"f"),h(this,o,new Ya((()=>{var e;return null===(e=this.createUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="sub-tenant-mappings"]')}),{logger:this.logger}),"f"),u(this,a,"f").call(this),this.createUserModal.beforeOpen=()=>c(this,void 0,void 0,(function*(){const e=this.getWidgetConfig().then((e=>(null==e?void 0:e.allowSubTenants)?this.actions.getSubTenantRoles():void 0));yield Promise.all([this.actions.getTenantRoles(),e]),yield u(this,a,"f").call(this),u(this,d,"f").call(this),u(this,t,"m",s).call(this)}))}))},s=function(){const e=y$(this.state);this.getFormFieldNames(this.createUserModal.ele).forEach((t=>{const[n,i]=t.split(".");if("customAttributes"!==n)return;const o=e.find((e=>e.name===i));o?o.editable||this.disableFormField(this.createUserModal.ele,t):this.removeFormField(this.createUserModal.ele,t)}))},l})),Bk=Ti((e=>{var t,n,i;return i=class extends(Ei(Cs,qk,_k)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",n).call(this)}))}},t=new WeakSet,n=function(){var e;this.createButton=new ka(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="create-user"]'),{logger:this.logger}),this.createButton.onClick((()=>this.createUserModal.open()))},i})),Vk=Ti((e=>{var t,n,i;return i=class extends(Ei(Fk,ud,Cs,_k)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),yield u(this,t,"m",n).call(this)}))}},t=new WeakSet,n=function(){return c(this,void 0,void 0,(function*(){var e;this.deleteUsersModal=this.createModal(),this.deleteUsersModal.setContent(xi(yield this.fetchWidgetPage("delete-users-modal.html")));const t=new ka((()=>{var e;return null===(e=this.deleteUsersModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger});t.onClick((()=>this.deleteUsersModal.close()));const n=new ka((()=>{var e;return null===(e=this.deleteUsersModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});n.onClick((()=>{const e=E$(this.state);this.actions.deleteUsers(e),this.deleteUsersModal.close()}));const i=new id(null===(e=this.deleteUsersModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.deleteUsersModal.beforeOpen=()=>{const e=L$(this.state);i.text=`Delete ${e}?`}}))},i})),Kk=Ti((e=>{var t,n,i,o;return o=class extends(Ei(Cs,_k,Fk,Vk)(e)){constructor(){super(...arguments),t.add(this),i.set(this,Ai((e=>{e?this.deleteButton.enable():this.deleteButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;u(this,t,"m",n).call(this),yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),this.subscribe(u(this,i,"f").bind(this),B$)}))}},i=new WeakMap,t=new WeakSet,n=function(){var e;this.deleteButton=new ka(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="delete-users"]'),{logger:this.logger}),this.deleteButton.disable(),this.deleteButton.onClick((()=>{this.deleteUsersModal.open()}))},o})),Hk=Ti((e=>{var t,n,i,o,r;return r=class extends(Ei(Fk,ud,Cs,bc,_k)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),yield u(this,t,"m",o).call(this)}))}},t=new WeakSet,n=function(){new ka((()=>{var e;return null===(e=this.disableUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger}).onClick((()=>this.disableUserModal.close()))},i=function(){new ka((()=>{var e;return null===(e=this.disableUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger}).onClick((()=>{const e=P$(this.state);this.actions.disableUser(e),this.disableUserModal.close()}))},o=function(){return c(this,void 0,void 0,(function*(){var e;this.disableUserModal=this.createModal(),this.disableUserModal.setContent(xi(yield this.fetchWidgetPage("disable-user-modal.html"))),u(this,t,"m",n).call(this),u(this,t,"m",i).call(this);const o=new id(null===(e=this.disableUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.disableUserModal.beforeOpen=()=>c(this,void 0,void 0,(function*(){const e=L$(this.state);o.text=`Disable ${e}?`}))}))},r})),zk=Ti((e=>{var t,n,i,o;return o=class extends(Ei(Cs,_k,Fk,Hk,bc)(e)){constructor(){super(...arguments),t.add(this),i.set(this,Ai((e=>{e?this.disableButton.enable():this.disableButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;u(this,t,"m",n).call(this),yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),this.subscribe(u(this,i,"f").bind(this),D$)}))}},i=new WeakMap,t=new WeakSet,n=function(){var e;this.disableButton=new ka(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="disable-user"]'),{logger:this.logger}),this.disableButton.disable(),this.disableButton.onClick((()=>{this.disableUserModal.open()}))},o})),Jk=e=>{if(!e)return e;const t=r$(e.startsWith("+")?e:`+${e}`);if(!t)return e;const n=new RegExp(`(\\+?${null==t?void 0:t.countryCallingCode})(.*)`);return(null==t?void 0:t.number.replace(n,"$1-$2"))||e},Gk=Ti((e=>{var t,n,i,o,r,s,a,d,f,p,v,g,m;return m=class extends(Ei(Fk,ud,Cs,bc,$c,_k)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),i.set(this,void 0),o.set(this,void 0),r.set(this,void 0),d.set(this,(()=>c(this,void 0,void 0,(function*(){yield u(this,i,"f").setData(v$(this.state).map((({name:e,description:t})=>({value:e,label:e,description:t}))))})))),f.set(this,(()=>{var e;const t=w$(this.state);null===(e=u(this,o,"f"))||void 0===e||e.classList.toggle("hidden",!t),t&&u(this,r,"f").setData(b$(this.state))})),v.set(this,(()=>{var e,t;const n=null===(e=R$(this.state))||void 0===e?void 0:e[0],i=Object.assign({loginId:null===(t=null==n?void 0:n.loginIds)||void 0===t?void 0:t.join(", "),displayName:null==n?void 0:n.name,email:null==n?void 0:n.email,phone:Jk(null==n?void 0:n.phone),recoveryEmail:null==n?void 0:n.recoveryEmail,recoveryPhone:Jk(null==n?void 0:n.recoveryPhone),roles:null==n?void 0:n.roleNames,givenName:null==n?void 0:n.givenName,familyName:null==n?void 0:n.familyName,middleName:null==n?void 0:n.middleName},c$(n.customAttributes,"customAttributes"));this.setFormData(this.editUserModal.ele,i),u(this,r,"f").value=(null==n?void 0:n.userTenants)||[]}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),yield u(this,t,"m",g).call(this)}))}},n=new WeakMap,i=new WeakMap,o=new WeakMap,r=new WeakMap,d=new WeakMap,f=new WeakMap,v=new WeakMap,t=new WeakSet,s=function(){new ka((()=>{var e;return null===(e=this.editUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger}).onClick((()=>this.editUserModal.close()))},a=function(){new ka((()=>{var e;return null===(e=this.editUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger}).onClick((()=>{if(this.validateForm(this.editUserModal.ele)){const e=this.getFormData(this.editUserModal.ele),{loginId:t}=e,n=l(e,["loginId"]),i=u(this,o,"f")&&!u(this,o,"f").classList.contains("hidden")?u(this,r,"f").mergedValue:void 0;this.actions.updateUser(Object.assign(Object.assign({loginId:t.split(", ")[0]},l$(n,"customAttributes")),void 0!==i&&{userTenants:i})),this.editUserModal.close(),this.resetFormData(this.editUserModal.ele)}}))},p=function(){const e=y$(this.state);this.getFormFieldNames(this.editUserModal.ele).forEach((t=>{const[n,i]=t.split(".");if("customAttributes"!==n)return;const o=e.find((e=>e.name===i));o?o.editable||this.disableFormField(this.editUserModal.ele,t):this.removeFormField(this.editUserModal.ele,t)}))},g=function(){return c(this,void 0,void 0,(function*(){var e,l;this.editUserModal=this.createModal(),this.editUserModal.setContent(xi(yield this.fetchWidgetPage("edit-user-modal.html"))),u(this,t,"m",s).call(this),u(this,t,"m",a).call(this),h(this,n,new od(null===(e=this.editUserModal.ele)||void 0===e?void 0:e.querySelector('[name="loginId"]'),{logger:this.logger}),"f"),h(this,i,new Qa((()=>{var e;return null===(e=this.editUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="roles-multiselect"]')}),{logger:this.logger}),"f"),h(this,o,null===(l=this.editUserModal.ele)||void 0===l?void 0:l.querySelector('[data-id="sub-tenant-section"]'),"f"),h(this,r,new Ya((()=>{var e;return null===(e=this.editUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="sub-tenant-mappings"]')}),{logger:this.logger}),"f"),this.editUserModal.beforeOpen=()=>c(this,void 0,void 0,(function*(){const e=this.getWidgetConfig().then((e=>(null==e?void 0:e.allowSubTenants)?this.actions.getSubTenantRoles():void 0));yield Promise.all([this.actions.getTenantRoles(),e]),yield u(this,d,"f").call(this),u(this,n,"f").disable(),u(this,f,"f").call(this),u(this,v,"f").call(this),u(this,t,"m",p).call(this)}))}))},m})),Zk=Ti((e=>{var t,n,i,o;return o=class extends(Ei(Cs,_k,Fk,Gk,bc)(e)){constructor(){super(...arguments),t.add(this),i.set(this,Ai((e=>{e?this.editButton.enable():this.editButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;u(this,t,"m",n).call(this),yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),this.subscribe(u(this,i,"f").bind(this),F$)}))}},i=new WeakMap,t=new WeakSet,n=function(){var e;this.editButton=new ka(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="edit-user"]'),{logger:this.logger}),this.editButton.disable(),this.editButton.onClick((()=>{this.editUserModal.open()}))},o})),Yk=Ti((e=>{var t,n,i,o,r;return r=class extends(Ei(Fk,ud,Cs,bc,_k)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),yield u(this,t,"m",o).call(this)}))}},t=new WeakSet,n=function(){new ka((()=>{var e;return null===(e=this.enableUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger}).onClick((()=>this.enableUserModal.close()))},i=function(){new ka((()=>{var e;return null===(e=this.enableUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger}).onClick((()=>{const e=P$(this.state);this.actions.enableUser(e),this.enableUserModal.close()}))},o=function(){return c(this,void 0,void 0,(function*(){var e;this.enableUserModal=this.createModal(),this.enableUserModal.setContent(xi(yield this.fetchWidgetPage("enable-user-modal.html"))),u(this,t,"m",n).call(this),u(this,t,"m",i).call(this);const o=new id(null===(e=this.enableUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.enableUserModal.beforeOpen=()=>c(this,void 0,void 0,(function*(){const e=L$(this.state);o.text=`Activate ${e}?`}))}))},r})),Xk=Ti((e=>{var t,n,i,o;return o=class extends(Ei(Cs,_k,Fk,Yk,bc)(e)){constructor(){super(...arguments),t.add(this),i.set(this,Ai((e=>{e?this.enableButton.enable():this.enableButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;u(this,t,"m",n).call(this),yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),this.subscribe(u(this,i,"f").bind(this),U$)}))}},i=new WeakMap,t=new WeakSet,n=function(){var e;this.enableButton=new ka(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="enable-user"]'),{logger:this.logger}),this.enableButton.disable(),this.enableButton.onClick((()=>{this.enableUserModal.open()}))},o})),Qk=Ti((e=>{var t,n,i,o;return o=class extends(Ei(Cs,_k,Fk)(e)){constructor(){super(...arguments),t.add(this),n.set(this,Mi((()=>{this.actions.searchUsers({text:this.searchInput.value})})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),u(this,t,"m",i).call(this)}))}},n=new WeakMap,t=new WeakSet,i=function(){var e;this.searchInput=new od(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="search-input"]'),{logger:this.logger}),this.searchInput.onInput(u(this,n,"f"))},o})),eC=new Set(["contains","not-contains","starts-with","ends-with","not-equal"]),tC=e=>{const t=Array.isArray(e)?e[0]:e;return null==t||""===t?null:String(t)},nC=e=>Array.isArray(e)?e:null==e||""===e?[]:[String(e)],iC=(e,t)=>({[e]:t}),oC=(e,t)=>({customAttributes:{[e]:t}}),rC=(e,t)=>((e,t)=>"equal"===t.operator&&null!=e.exactField)(e,t)?((e,t)=>{const n=nC(t.value);return n.length?iC(e,n):{}})(e.exactField,t):((e,t)=>eC.has(t.operator)&&null!=e.likeField)(e,t)?((e,t)=>{var n,i;const o=tC(t.value);return null===o?{}:((e,t,n)=>({searchFields:[Object.assign({field:e,valStr:t},n?{negative:!0}:{})]}))(e,`${null!==(n=t.prefix)&&void 0!==n?n:""}${o}${null!==(i=t.suffix)&&void 0!==i?i:""}`,t.operator.startsWith("not-"))})(e.likeField,t):null,sC=(e,t)=>{const{mapping:n}=e;if(!n)return null;switch(n.kind){case"array":return((e,t)=>{if("is-any-of"!==t.operator)return null;const n=nC(t.value);if(!n.length)return{};const i=e.valueMap?n.map((t=>{var n;return null!==(n=e.valueMap[t])&&void 0!==n?n:t})):n;return iC(e.field,i)})(n,t);case"boolean":return((e,t)=>{if("equal"!==t.operator)return null;const n=tC(t.value);return"true"===n?iC(e.field,!0):"false"===n?iC(e.field,!1):{}})(n,t);case"text":return rC(n,t);case"customAttribute":return((e,t,n)=>{if((e=>"is-empty"===e.operator)(t))return oC(e.name,null);if(!(e=>"equal"===e.operator||"is-any-of"===e.operator)(t))return{};const i=((e,t)=>{if(Array.isArray(e))return e.length?e:void 0;if(null!=e&&""!==e){if("boolean"===t)return"true"===e||"false"!==e&&void 0;if("number"===t){const t=Number(e);return Number.isFinite(t)?t:void 0}return e}})(t.value,n);return void 0===i?{}:oC(e.name,i)})(n,t,e.inputType);default:return null}},aC=(e,t=[])=>{const n={};(e=>{const t=new Set(["searchFields","customAttributes"]);return e.forEach((e=>{const n=null==e?void 0:e.mapping;n&&("array"===n.kind||"boolean"===n.kind?t.add(n.field):"text"===n.kind&&n.exactField&&t.add(n.exactField))})),t})(t).forEach((e=>{n[e]=void 0}));const i=new Map(t.filter((e=>Boolean(e))).map((e=>[e.id,e])));return e.reduce(((e,t)=>{const n=((e,t)=>{if(e.column&&e.operator)return t.get(e.column)})(t,i);if(!n)return e;const o=sC(n,t);return o?((e,t)=>{const{searchFields:n,customAttributes:i}=t,o=l(t,["searchFields","customAttributes"]),r=n?(a=n,[...null!=(s=e.searchFields)?s:[],...a]):e.searchFields;var s,a;const d=i?((e,t)=>Object.assign(Object.assign({},null!=e?e:{}),t))(e.customAttributes,i):e.customAttributes,c=Object.assign({},e);return Object.entries(o).forEach((([e,t])=>{var n,i;c[e]=(n=c[e],i=t,Array.isArray(n)&&Array.isArray(i)?[...n,...i.filter((e=>!n.includes(e)))]:i)})),Object.assign(Object.assign({},c),{searchFields:r,customAttributes:d})})(e,o):e}),n)},dC="customAttributes.",lC="roles",cC=e=>{if("string"==typeof e)return{value:e,label:e};const{value:t,label:n}=e;return{value:t,label:n||t}},uC=(e,t,n)=>{var i;const o=((e,t)=>{if(!(null==t?void 0:t.length))return e.filter((e=>(null==e?void 0:e.id)!==lC));const n=t.map((e=>({value:e.name,label:e.name})));return e.map((e=>(null==e?void 0:e.id)===lC?Object.assign(Object.assign({},e),{options:n}):e))})(null!==(i=null==e?void 0:e.slice())&&void 0!==i?i:[],t);return((e,t)=>e.filter((e=>{var n;if(!(null===(n=null==e?void 0:e.id)||void 0===n?void 0:n.startsWith(dC))||!(null==t?void 0:t.length))return!0;const i=e.id.slice(17);return t.some((e=>e.name===i))})).map((e=>{var n;return(null===(n=null==e?void 0:e.id)||void 0===n?void 0:n.startsWith(dC))?((e,t)=>{const n=e.id.slice(17),i=null==t?void 0:t.find((e=>e.name===n));if(!i)return e;const o=e.label||i.displayName||n,r=(e=>Array.isArray(e.options)&&e.options.length?e.options.map(cC):void 0)(i),s=Object.assign(Object.assign({},e),{label:o});return r&&(s.options=r),s})(e,t):e})))(o,n)},hC=Ti((e=>{var t,n,i,o,r,s,a,d;return d=class extends(Ei(Cs,_k,Fk)(e)){constructor(){super(...arguments),t.set(this,null),n.set(this,(()=>u(this,t,"f")?[...u(this,t,"f")]:this.filter.data)),i.set(this,(e=>{const t=Array.isArray(null==e?void 0:e.value)?e.value:[];this.actions.searchUsers(Object.assign(Object.assign({},aC(t,u(this,n,"f").call(this))),{page:0}))})),o.set(this,(()=>{this.actions.searchUsers(Object.assign(Object.assign({},aC([],u(this,n,"f").call(this))),{page:0}))})),r.set(this,Ai(((e,t,n)=>{this.filter.data=uC(e,t,n)}))),s.set(this,(()=>{var e;(null===(e=this.filter)||void 0===e?void 0:e.isExists)&&u(this,r,"f").call(this,u(this,t,"f"),v$(this.state),y$(this.state))})),a.set(this,(()=>{h(this,t,Object.freeze(this.filter.data.slice()),"f"),u(this,s,"f").call(this)}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var t,n;yield null===(t=e.onWidgetRootReady)||void 0===t?void 0:t.call(this);const r=null===(n=this.shadowRoot)||void 0===n?void 0:n.querySelector("descope-filter");this.filter=new $a(r,{logger:this.logger}),this.filter.isExists&&(this.filter.onDataChange(u(this,a,"f")),u(this,a,"f").call(this),this.subscribe(u(this,s,"f"),v$),this.subscribe(u(this,s,"f"),y$),this.filter.onApply(u(this,i,"f")),this.filter.onClear(u(this,o,"f")))}))}},t=new WeakMap,n=new WeakMap,i=new WeakMap,o=new WeakMap,r=new WeakMap,s=new WeakMap,a=new WeakMap,d})),fC={success:(new DOMParser).parseFromString('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Checkmark">\n<path id="Shape" d="M10.0485 15.6396C9.5799 15.171 8.8201 15.171 8.35147 15.6396C7.88284 16.1082 7.88284 16.868 8.35147 17.3367L12.7072 21.6924C13.1759 22.1611 13.9357 22.1611 14.4043 21.6924L24.7152 11.3815C25.1838 10.9129 25.1838 10.1531 24.7152 9.68448C24.2466 9.21585 23.4868 9.21585 23.0181 9.68448L13.5558 19.1469L10.0485 15.6396Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,error:(new DOMParser).parseFromString('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Icon">\n<path id="Vector" d="M15.9998 26.6558C10.1118 26.6558 5.34375 21.8878 5.34375 15.9998C5.34375 10.1118 10.1118 5.34375 15.9998 5.34375C21.8878 5.34375 26.6558 10.1118 26.6558 15.9998C26.6558 21.8878 21.8878 26.6558 15.9998 26.6558ZM15.9998 24.4798C20.6718 24.4798 24.4798 20.7038 24.4798 15.9998C24.4798 11.3278 20.7038 7.51975 15.9998 7.51975C11.3278 7.51975 7.51975 11.2958 7.51975 15.9998C7.51975 20.6718 11.2958 24.4798 15.9998 24.4798ZM15.3278 9.34375H16.6718C17.0558 9.34375 17.3438 9.63175 17.3118 9.98375L16.9598 16.9278C16.9598 17.1838 16.7678 17.3438 16.5438 17.3438H15.4558C15.2318 17.3438 15.0398 17.1518 15.0398 16.9278L14.6878 9.98375C14.6878 9.63175 14.9758 9.34375 15.3278 9.34375ZM15.4558 19.4558H16.5438C16.9278 19.4558 17.2158 19.7438 17.1838 20.1278V21.1838C17.1838 21.5678 16.8958 21.8558 16.5438 21.8558H15.4558C15.0718 21.8558 14.7838 21.5678 14.7838 21.1838V20.1278C14.7838 19.7438 15.0718 19.4558 15.4558 19.4558Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild},pC=Ti((e=>{var t,n,i,o,r;return r=class extends(Ei(Cs,Fk,pd,Os)(e)){constructor(){super(...arguments),t.add(this),o.set(this,Ai((e=>{e.length&&(e.forEach((({type:e,msg:o})=>{const r=u(this,t,"m",i).call(this,e);r.setContent(u(this,t,"m",n).call(this,{type:e,msg:o})),r.show()})),setTimeout((()=>this.actions.clearNotifications())))})))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this),this.subscribe(u(this,o,"f").bind(this),m$)}))}},o=new WeakMap,t=new WeakSet,n=function({type:e,msg:t}){const n=fC[e],i=Object.assign((new DOMParser).parseFromString('<svg width="2em" height="2em" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Icon">\n<path id="Shape" d="M10.6712 12L7.27521 8.60406C6.90826 8.23711 6.90826 7.64216 7.27521 7.27521C7.64216 6.90826 8.23711 6.90826 8.60406 7.27521L12 10.6712L15.3959 7.27521C15.7629 6.90826 16.3578 6.90826 16.7248 7.27521C17.0917 7.64216 17.0917 8.23711 16.7248 8.60406L13.3288 12L16.7248 15.3959C17.0917 15.7629 17.0917 16.3578 16.7248 16.7248C16.3578 17.0917 15.7629 17.0917 15.3959 16.7248L12 13.3288L8.60406 16.7248C8.23711 17.0917 7.64216 17.0917 7.27521 16.7248C6.90826 16.3578 6.90826 15.7629 7.27521 15.3959L10.6712 12Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,{slot:"close"});return`${(null==n?void 0:n.outerHTML)||""}${t}${i.outerHTML}`},i=function(e){return this.createNotification({mode:e,duration:"error"===e?0:3e3,position:"bottom-start",size:"sm"})},r})),vC=Ti((e=>{var t,n,i,o,r;return r=class extends(Ei(Fk,ud,Cs,bc,_k)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),yield u(this,t,"m",o).call(this)}))}},t=new WeakSet,n=function(){new ka((()=>{var e;return null===(e=this.removePasskeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger}).onClick((()=>this.removePasskeyModal.close()))},i=function(){new ka((()=>{var e;return null===(e=this.removePasskeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger}).onClick((()=>{const e=P$(this.state);this.actions.removePasskey(e),this.removePasskeyModal.close()}))},o=function(){return c(this,void 0,void 0,(function*(){var e;this.removePasskeyModal=this.createModal(),this.removePasskeyModal.setContent(xi(yield this.fetchWidgetPage("remove-passkey-modal.html"))),u(this,t,"m",n).call(this),u(this,t,"m",i).call(this);const o=new id(null===(e=this.removePasskeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.removePasskeyModal.beforeOpen=()=>c(this,void 0,void 0,(function*(){const e=L$(this.state);o.text=`Remove passkey for ${e}?`}))}))},r})),gC=Ti((e=>{var t,n,i,o;return o=class extends(Ei(Cs,_k,Fk,vC,bc)(e)){constructor(){super(...arguments),t.add(this),i.set(this,Ai((e=>{e?this.removePasskeyButton.enable():this.removePasskeyButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;u(this,t,"m",n).call(this),yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),this.subscribe(u(this,i,"f").bind(this),_$)}))}},i=new WeakMap,t=new WeakSet,n=function(){var e;this.removePasskeyButton=new ka(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="remove-passkey"]'),{logger:this.logger}),this.removePasskeyButton.disable(),this.removePasskeyButton.onClick((()=>{this.removePasskeyModal.open()}))},o})),mC=Ti((e=>{var t,n,i,o,r,s,a,d;return d=class extends(Ei(Fk,Cs,_k)(e)){constructor(){super(...arguments),t.add(this),o.set(this,Ai((e=>{this.usersTable.data=e}))),r.set(this,Mi(((e,t)=>{const n=[],{value:i}=t;if(i){const t=e.path;n.push({field:t,desc:"desc"===i})}this.actions.searchUsers({sort:n})}))),s.set(this,Ai((e=>{this.usersTable.filterColumns((t=>{var n;const[i,o]=(null===(n=t.path)||void 0===n?void 0:n.split("."))||[];return"customAttributes"!==i||!!(null==e?void 0:e.find((e=>e.name===o)))}))})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),u(this,t,"m",i).call(this),u(this,o,"f").call(this,I$(this.state)),u(this,s,"f").call(this,y$(this.state)),this.subscribe(u(this,s,"f").bind(this),y$),this.subscribe(u(this,o,"f").bind(this),I$)}))}},o=new WeakMap,r=new WeakMap,s=new WeakMap,t=new WeakSet,n=function(){const e=e=>{var t;return null===(t=this.usersTable.ele)||void 0===t?void 0:t.querySelector(`[path="${e}"]`)},t=e=>{var t;const n=`descope-grid-${e}-column`;return null===(t=this.usersTable.ele)||void 0===t?void 0:t.querySelector(n)},n=this.usersTable.renderColumn;this.usersTable.renderColumn=({path:i,header:o,type:r,attrs:s})=>{const a=e(i)||t(r);if(!a)return n({path:i,header:o,type:r,attrs:s});const d=a.cloneNode(!0),l=Object.assign(Object.assign({},s),{header:o});return Object.entries(l).forEach((([e,t])=>{d.setAttribute(e,t)})),d.outerHTML}},i=function(){var e;this.usersTable=new Ea(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="users-table"]'),{logger:this.logger}),this.usersTable.onSelectedItemsChange((e=>{this.actions.setSelectedUsersIds(e.detail.value.map((({loginIds:e})=>e)))})),this.usersTable.onColumnsChange(u(this,t,"m",a).bind(this)),u(this,t,"m",n).call(this),u(this,t,"m",a).call(this)},a=function(){this.usersTable.columns.forEach((e=>{e.onSortDirectionChange((e=>{u(this,r,"f").call(this,e.target,e.detail)}))}))},d})),yC=Ti((e=>{var t,n,i;return i=class extends(Ei(Fk,ud,Cs,bc,_k)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),yield u(this,t,"m",n).call(this)}))}},t=new WeakSet,n=function(){return c(this,void 0,void 0,(function*(){this.generatedPasswordModal=this.createModal(),this.generatedPasswordModal.setContent(xi(yield this.fetchWidgetPage("generated-password-modal.html"))),new ka((()=>{var e;return null===(e=this.generatedPasswordModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-close"]')}),{logger:this.logger}).onClick((()=>{navigator.clipboard.writeText(this.getFormData(this.generatedPasswordModal.ele)["generated-password"]),this.resetFormData(this.generatedPasswordModal.ele),this.generatedPasswordModal.close()}))}))},i})),bC=Ti((e=>{var t,n,i,o,r;return r=class extends(Ei(Fk,ud,Cs,bc,_k,yC)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),yield u(this,t,"m",o).call(this)}))}},t=new WeakSet,n=function(){new ka((()=>{var e;return null===(e=this.resetPasswordModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger}).onClick((()=>this.resetPasswordModal.close()))},i=function(){new ka((()=>{var e;return null===(e=this.resetPasswordModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger}).onClick((()=>c(this,void 0,void 0,(function*(){var e;const t=P$(this.state),n=yield this.actions.setTempUserPassword(t);this.resetPasswordModal.close(),this.setFormData(this.generatedPasswordModal.ele,{"generated-password":null===(e=null==n?void 0:n.payload)||void 0===e?void 0:e.cleartext}),this.generatedPasswordModal.open()}))))},o=function(){return c(this,void 0,void 0,(function*(){var e;this.resetPasswordModal=this.createModal(),this.resetPasswordModal.setContent(xi(yield this.fetchWidgetPage("reset-password-modal.html"))),u(this,t,"m",n).call(this),u(this,t,"m",i).call(this);const o=new id(null===(e=this.resetPasswordModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.resetPasswordModal.beforeOpen=()=>c(this,void 0,void 0,(function*(){const e=L$(this.state);o.text=`This will generate a new temporary password for ${e}?`}))}))},r})),wC=Ti((e=>{var t,n,i,o;return o=class extends(Ei(Cs,_k,Fk,bC,bc)(e)){constructor(){super(...arguments),t.add(this),i.set(this,Ai((e=>{e?this.resetPasswordButton.enable():this.resetPasswordButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;u(this,t,"m",n).call(this),yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),this.subscribe(u(this,i,"f").bind(this),q$)}))}},i=new WeakMap,t=new WeakSet,n=function(){var e;this.resetPasswordButton=new ka(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="reset-password"]'),{logger:this.logger}),this.resetPasswordButton.disable(),this.resetPasswordButton.onClick((()=>{this.resetPasswordModal.open()}))},o})),$C=Ti((e=>class extends(Ei(sa,As)(e)){syncFlowTheme(e){e.theme=this.theme,this.observeAttributes(["theme"],(()=>{e.theme=this.theme}))}})),kC=Ti((e=>{var t,n,i,o,r,s,a,d,l,f,p,v,g,m;return m=class extends(Ei(kc,$C,Fk,hd,Cs,bc,_k,Ic)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),i.set(this,void 0),o.set(this,[]),r.set(this,null),s.set(this,null),g.set(this,Ai((e=>{u(this,o,"f").forEach((t=>{"onlyOne"===t.enableMode&&1===e.length||"oneOrMore"===t.enableMode&&e.length>0||"always"===t.enableMode?t.enable():t.disable()}))})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),u(this,t,"m",l).call(this),u(this,t,"m",d).call(this),u(this,g,"f").call(this,g$(this.state))}))}},n=new WeakMap,i=new WeakMap,o=new WeakMap,r=new WeakMap,s=new WeakMap,g=new WeakMap,t=new WeakSet,a=function(e){const n=new Sa(e,{logger:this.logger});n.onClick((()=>{u(this,t,"m",v).call(this,n.flowId)})),this.subscribe(u(this,g,"f").bind(this),g$),u(this,o,"f").push(n)},d=function(){var e;const n=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelectorAll("[data-generic-flow-button-id]");Array.from(n).forEach((e=>{u(this,t,"m",a).call(this,e)}))},l=function(){h(this,n,this.createFlowModal({"data-id":"generic-flow-modal"}),"f"),u(this,n,"f").afterClose=()=>{var e;u(this,r,"f")&&(null===(e=u(this,s,"f"))||void 0===e||e.call(this),h(this,r,null,"f"))},h(this,i,new Ca((()=>{var e;return null===(e=u(this,n,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(u(this,i,"f"))},f=function(){var e;u(this,n,"f").open(),null===(e=u(this,s,"f"))||void 0===e||e.call(this)},p=function(e,n){n=()=>u(this,t,"m",f).call(this),h(this,s,u(this,i,"f").onPageUpdated(n),"f")},v=function(e){u(this,n,"f").setContent(this.createFlowTemplate({flowId:e,lazyStart:!1,client:{userIds:E$(this.state),loginIds:x$(this.state),usersAndRoles:O$(this.state)},tenant:this.tenantId})),u(this,t,"m",p).call(this,u(this,n,"f"),u(this,r,"f")),u(this,i,"f").onSuccess((()=>{u(this,n,"f").close(),this.actions.searchUsers()}))},m})),CC="widget-flow",SC=Ti((e=>{var t,n,i;return i=class extends(Ei(kc,Os,hd,Fk,Sc,Cs,sa,Ic)(e)){constructor(){super(...arguments),t.add(this)}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.init)||void 0===i?void 0:i.call(this);const o=h$(CC);o&&(function(e){if(window.history.replaceState&&h$(e)){const t=new URL(window.location.href),n=new URLSearchParams(t.search);n.delete(e),t.search=n.toString(),window.history.replaceState({},"",t.toString())}}(CC),u(this,t,"m",n).call(this,o))}))}},t=new WeakSet,n=function(e){const t=this.createFlowModal({"data-id":"redirect-flow"});t.setContent(this.createFlowTemplate({flowId:e})),new Ca((()=>{var e;return null===(e=t.ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}).onSuccess((()=>{t.close()})),t.afterClose=()=>{t.remove()},t.open()},i})),IC=Ti((e=>class extends(Ei(fa,sa,SC,mC,Bk,Kk,Zk,Xk,zk,wC,gC,Qk,hC,pC,kC,Oc)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),RC=Ei((e=>class extends(IC(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this),(customElements.get("descope-wc")||(yield Promise.resolve().then((function(){return Mh})).then((e=>e.default)))).sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"user-management-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.21.16"}}}))}}))(HTMLElement);customElements.define("descope-user-management-widget",RC);var EC=Object.freeze({__proto__:null,default:RC});function xC(e){return new URLSearchParams(window.location.search).get(e)}const OC=e=>(...t)=>n=>{n.addCase(e.pending,((e,n)=>{t.forEach((({onPending:t})=>{null==t||t(e,n)}))})),n.addCase(e.fulfilled,((e,n)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,n)}))})),n.addCase(e.rejected,((e,n)=>{t.forEach((({onRejected:t})=>{null==t||t(e,n)}))}))},AC=e=>({onFulfilled:t=>{e(t).loading=!1},onPending:t=>{e(t).loading=!0,e(t).error=null},onRejected:(t,n)=>{e(t).loading=!1,e(t).error=n.error}}),NC=lc("users/me",((e,{extra:{api:t}})=>t.user.me())),jC=OC(NC)({onFulfilled:(e,t)=>{e.me.data=t.payload}},AC((e=>e.me))),MC={action:NC,reducer:jC},PC=lc("users/devices",((e,{extra:{api:t}})=>t.device.devices(e))),TC=OC(PC)({onFulfilled:(e,t)=>{e.devices.data=t.payload.devices}},AC((e=>e.devices))),WC={action:PC,reducer:TC},LC=lc("users/passkeys",((e,{extra:{api:t}})=>t.passkey.listPasskeys(e))),UC=OC(LC)({onFulfilled:(e,t)=>{e.passkeys.data=t.payload.passkeys}},AC((e=>e.passkeys))),DC={action:LC,reducer:UC},FC=lc("users/logout",((e,{extra:{api:t}})=>t.user.logout())),_C={action:FC,reducer:OC(FC)({})},qC=e=>{if(!e)return null;const t=(e=>{try{const t=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),n=decodeURIComponent(atob(t).split("").map((e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2))).join(""));return JSON.parse(n)}catch(e){return null}})(e);return(null==t?void 0:t.dct)||null},BC=e=>e.me.data,VC=Al(BC,(e=>e.userId)),KC=Al(BC,(e=>e.picture)),HC=Al(BC,(e=>e.email)),zC=Al(BC,(e=>e.verifiedEmail)),JC=Al(BC,(e=>e.name)),GC=Al(BC,(e=>e.phone)),ZC=Al(BC,(e=>e.verifiedPhone)),YC=Al(HC,zC,((e,t)=>e&&""!==e.trim()&&!t?"Unverified":"")),XC=Al(GC,ZC,((e,t)=>e&&""!==e.trim()&&!t?"Unverified":"")),QC=Al(BC,(e=>e.recoveryEmail)),eS=Al(BC,(e=>e.verifiedRecoveryEmail)),tS=Al(BC,(e=>e.recoveryPhone)),nS=Al(BC,(e=>e.verifiedRecoveryPhone)),iS=Al(QC,eS,((e,t)=>t?e:"")),oS=Al(tS,nS,((e,t)=>t?e:"")),rS=Al(BC,(e=>e.webauthn));Al(BC,(e=>e.password));const sS=Al(BC,(e=>e.TOTP)),aS={},dS=Al(BC,(e=>{var t;return null!==(t=e.customAttributes)&&void 0!==t?t:aS})),lS=Al(BC,(e=>({givenName:e.givenName,middleName:e.middleName,familyName:e.familyName}))),cS=Al((e=>e.devices.data),(e=>e.map((({id:e,name:t,deviceType:n,lastLoginTime:i,isCurrentDevice:o})=>({id:e,name:t,deviceType:n,lastLoginDate:1e3*parseInt(i,10),isCurrent:o}))))),uS=Al((e=>e.passkeys.data),(e=>e.map((({id:e,displayName:t,kind:n,createdTime:i})=>({id:e,name:t,passkeyType:n,createdAt:1e3*i}))))),hS=e=>e.notifications,fS=Al(BC,(e=>e.userTenants||[])),pS=e=>e.tenant.currentTenantId,vS=lc("tenant/select",((e,t)=>c(void 0,[e,t],void 0,(function*(e,{extra:{api:t},getState:n}){if(e===pS(n()))return null;const i=yield t.user.setCurrentTenant(e),o=i.sessionJwt||i.sessionToken;try{return{tenantId:qC(o)}}catch(e){return console.error("Failed to switch tenant:",e),null}})))),gS={action:vS,reducer:OC(vS)({onPending:e=>{e.tenant.previousTenantId=e.tenant.currentTenantId},onFulfilled:(e,t)=>{var n;e.tenant.currentTenantId=null===(n=t.payload)||void 0===n?void 0:n.tenantId,e.tenant.previousTenantId=null},onRejected:e=>{e.tenant.currentTenantId=e.tenant.previousTenantId,e.tenant.previousTenantId=null}},AC((e=>e.selectTenant)),(({getErrorMsg:e,getSuccessMsg:t})=>({onFulfilled:(e,n)=>{if(t){const i=t(n);i&&e.notifications.push({type:"success",msg:i})}},onRejected:(t,n)=>{if(e){const i=e(n);i&&t.notifications.push({type:"error",msg:i})}}}))({getErrorMsg:e=>{var t;return Vi(null===(t=e.error)||void 0===t?void 0:t.message).trim()||"Error"}}))},mS={me:{loading:!1,error:null,data:{}},devices:{loading:!1,error:null,data:[]},passkeys:{loading:!1,error:null,data:[]},tenant:{currentTenantId:null,previousTenantId:null},selectTenant:{loading:!1,error:null},notifications:[]},yS="/v1/auth/me",bS="/v1/mgmt/user/trusteddevices/list",wS="/v1/mgmt/user/passkeys/list",$S="/v1/auth/tenant/select",kS=e=>c(void 0,void 0,void 0,(function*(){const t=yield e.text(),n=JSON.parse(t);if(!e.ok){const t=`${n.errorDescription}${n.errorMessage?`: ${n.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(n),e.text=()=>Promise.resolve(t)})),CS=[{tenantName:"Tenant 1",tenantId:"tn1",roleNames:["Role"]},{tenantName:"Tenant 2",tenantId:"tn2",roleNames:["Role"]}],SS=({httpClient:e,mock:t})=>({me:()=>c(void 0,void 0,void 0,(function*(){if(t)return c(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({loginIds:["user@company.com"],externalIds:["user@company.com"],userId:"user-1",name:"Test User",email:"user@company.com",roleNames:["Role"],phone:"+1-202-555-010",recoveryEmail:"recovery@company.com",recoveryPhone:"+1-202-555-020",verifiedEmail:!0,verifiedPhone:!0,verifiedRecoveryEmail:!0,verifiedRecoveryPhone:!0,userTenants:CS,status:"enabled",editable:!0,createdTime:(new Date).getTime(),customAttributes:{},familyName:"",givenName:"",middleName:"",picture:void 0,password:!0,SAML:!1,test:!1,TOTP:!1,webauthn:!0})}))}));const n=yield e.get(yS);return yield kS(n),n.json()})),setCurrentTenant:t=>c(void 0,void 0,void 0,(function*(){const n=yield e.post($S,{tenant:t});return yield kS(n),n.json()}))}),IS=({httpClient:e,mock:t})=>({devices:n=>c(void 0,[n],void 0,(function*({userId:n}){if(t)return{devices:[{id:"device-id-1",name:"Device 1",deviceType:"desktop",lastLoginDate:17359776e5,isCurrent:!1},{id:"device-id-2",name:"Device 2",deviceType:"mobile",lastLoginDate:17387505e5,isCurrentDevice:!0},{id:"device-id-3",name:"Device 3",deviceType:"tablet",lastLoginDate:17412642e5,isCurrent:!1},{id:"device-id-4",name:"Device 4",deviceType:"unknown",lastLoginDate:17440371e5,isCurrent:!1},{id:"device-id-5",name:"Device 5",deviceType:"desktop",lastLoginDate:174672e7,isCurrent:!1}]};const i=yield e.post(bS,{identifiers:[n]});return yield kS(i),i.json()}))}),RS=({httpClient:e,mock:t})=>({listPasskeys:n=>c(void 0,[n],void 0,(function*({userId:n}){if(t)return{passkeys:[{id:"vendor-id-1",displayName:"Device 1",kind:"google",createdTime:1735977600,rpId:"example.com"},{id:"vendor-id-2",displayName:"Device 2",kind:"edge",createdTime:1738750500,rpId:"example.com"},{id:"vendor-id-3",displayName:"Device 3",kind:"apple",createdTime:1741264200,rpId:"example.com"}]};const i=yield e.post(wS,{loginId:n});return yield kS(i),i.json()}))}),ES=Ti((e=>{var t,n,i,o,r;const s=Ei(js,As,Cs,Ms,Sc)(e);return r=class extends s{constructor(){super(...arguments),t.add(this),n.set(this,void 0)}get sessionTokenViaCookie(){return u(this,t,"m",o).call(this,"session-token-via-cookie")}get refreshTokenViaCookie(){return u(this,t,"m",o).call(this,"refresh-token-via-cookie")}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get styleId(){return this.getAttribute("style-id")||Qs}get api(){return u(this,n,"f")||u(this,t,"m",i).call(this),u(this,n,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.init)||void 0===o?void 0:o.call(this),this.observeAttributes(["project-id","base-url","session-token-via-cookie","refresh-token-via-cookie"],(()=>{u(this,n,"f")&&u(this,t,"m",i).call(this)}))}))}},n=new WeakMap,t=new WeakSet,i=function(){this.logger.debug("creating an sdk instance"),h(this,n,((e,t,n)=>{const i=yi(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"user-profile-widget","x-descope-widget-id":n,"x-descope-widget-version":"0.21.5"}}));return{user:Object.assign(Object.assign({},SS({httpClient:i.httpClient,mock:t})),{logout:t?()=>c(void 0,void 0,void 0,(function*(){})):i.logout}),device:Object.assign({},IS({httpClient:i.httpClient,mock:t})),passkey:Object.assign({},RS({httpClient:i.httpClient,mock:t})),refresh:t?()=>c(void 0,void 0,void 0,(function*(){return{ok:!0}})):i.refresh,httpClient:i.httpClient}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName,sessionTokenViaCookie:this.sessionTokenViaCookie,refreshTokenViaCookie:this.refreshTokenViaCookie},"true"===this.mock,this.widgetId),"f")},o=function(e){var t;try{return null!==(t=JSON.parse(this.getAttribute(e)))&&void 0!==t?t:void 0}catch(t){return void this.logger.warn(`invalid JSON in "${e}" attribute, ignoring it`)}},r})),xS=Ti((e=>{const t=Ei(yc({name:"widget",initialState:mS,reducers:{clearNotifications:e=>{e.notifications=[]},setCurrentTenantId:(e,{payload:t})=>{e.tenant.currentTenantId=t}},extraReducers:e=>{MC.reducer(e),WC.reducer(e),DC.reducer(e),_C.reducer(e),gS.reducer(e)},asyncActions:{getMe:MC.action,listDevices:WC.action,listPasskeys:DC.action,logout:_C.action,selectTenant:gS.action}}),Os,Cs,ES)(e);return class extends t{constructor(...e){super(...e),this.state=mS,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),OS="widget-flow",AS=Ti((e=>{var t,n,i;return i=class extends(Ei(kc,Os,hd,xS,Sc,Cs,sa,Ic)(e)){constructor(){super(...arguments),t.add(this)}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.init)||void 0===i?void 0:i.call(this);const o=xC(OS);o&&(function(e){if(window.history.replaceState&&xC(e)){const t=new URL(window.location.href),n=new URLSearchParams(t.search);n.delete(e),t.search=n.toString(),window.history.replaceState({},"",t.toString())}}(OS),u(this,t,"m",n).call(this,o))}))}},t=new WeakSet,n=function(e){const t=this.createFlowModal({"data-id":"redirect-flow"});t.setContent(this.createFlowTemplate({flowId:e})),new Ca((()=>{var e;return null===(e=t.ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}).onSuccess((()=>{t.close(),this.actions.getMe()})),t.afterClose=()=>{t.remove()},t.open()},i})),NS=()=>{var e;return"function"==typeof(null===(e=window.descopeBridge)||void 0===e?void 0:e.registerWidget)},jS=Ti((e=>{const t=e;return class extends t{init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;NS()&&window.descopeBridge.registerWidget(this),yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}handleLogout(){const e=Object.create(null,{handleLogout:{get:()=>super.handleLogout}});return c(this,void 0,void 0,(function*(){var t;NS()?this.dispatchEvent(new CustomEvent("widget-logout")):yield null===(t=e.handleLogout)||void 0===t?void 0:t.call(this)}))}}})),MS=Ti((e=>{var t,n,i;return i=class extends(Ei(Cs,Os,Hs,Xs,Cc("user-profile-widget"),xS)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){return c(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.init)||void 0===i?void 0:i.call(this);try{yield this.actions.getMe(),yield u(this,t,"m",n).call(this),yield this.onWidgetRootReady()}catch(i){const e=null==i?void 0:i.code,t=(null==i?void 0:i.message)||("string"==typeof i?i:"Widget failed to initialize");throw this.dispatchEvent(new CustomEvent("error",{detail:{code:e,description:"Widget failed to initialize",message:t}})),i}this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,n=function(){return c(this,void 0,void 0,(function*(){const e=xi(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},i})),PS=Ti((e=>class extends(Ei(sa,As)(e)){syncFlowTheme(e){e.theme=this.theme,this.observeAttributes(["theme"],(()=>{e.theme=this.theme}))}})),TS=Ti((e=>{var t,n,i,o,r;return r=class extends(Ei(Cs,xS)(e)){constructor(){super(...arguments),t.add(this),i.set(this,null)}onFlowPopupClosed(){return c(this,void 0,void 0,(function*(){var e;return h(this,i,null!==(e=u(this,i,"f"))&&void 0!==e?e:u(this,t,"m",o).call(this).finally((()=>{h(this,i,null,"f")})),"f"),u(this,i,"f")}))}},i=new WeakMap,t=new WeakSet,n=function(){return c(this,void 0,void 0,(function*(){var e;try{const e=yield this.api.refresh();return(null==e?void 0:e.ok)?"ok":401===(null==e?void 0:e.code)?"unauthenticated":"failed"}catch(t){return null===(e=this.logger)||void 0===e||e.debug("Session refresh threw",t),"failed"}}))},o=function(){return c(this,void 0,void 0,(function*(){var e;let i=yield u(this,t,"m",n).call(this);if("failed"===i&&(i=yield u(this,t,"m",n).call(this)),"unauthenticated"!==i)return"failed"===i?(null===(e=this.logger)||void 0===e||e.error("Could not refresh the session after a popup flow; the widget may be showing stale data"),void this.dispatchEvent(new CustomEvent("error",{detail:{message:"session-refresh-failed"}}))):void this.actions.getMe();this.dispatchEvent(new CustomEvent("logout"))}))},r})),WS={"flow-id":"flow",theme:"theme","style-id":"style",locale:"locale",tenant:"tenant"},LS=["client","form"],US=Ti((e=>{var t,n,i,o,r,s,a,d;return d=class extends(Ei(Cs,hd,Ic,PS,$c,TS,MS)(e)){constructor(){super(...arguments),t.add(this),n.set(this,"modal"),i.set(this,""),o.set(this,void 0)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n,i;h(this,o,null!==(n=u(this,o,"f"))&&void 0!==n?n:u(this,t,"m",r).call(this),"f"),yield u(this,o,"f"),yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this)}))}createFlowRunner({dataId:e,flowId:i,closeOnOutsideClick:o=!0,presetContent:r=!0,deferOpenUntilFirstPage:s=!1,onSuccess:d}){if(!i)return;if("popup"===u(this,n,"f")){const e=u(this,t,"m",a).call(this,i,d);if(e)return e}const l=this.createFlowModal(Object.assign({"data-id":e},o?{"close-on-outside-click":"true"}:{})),c=new Ca((()=>{var e;return null===(e=l.ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger});this.syncFlowTheme(c);let h=null;const f=()=>{null==h||h(),h=null},p=e=>{l.setContent(this.createFlowTemplate(Object.assign(Object.assign({flowId:i},s?{lazyStart:!1}:{}),e))),s&&(f(),h=c.onPageUpdated((()=>{l.open(),f()}))),c.onSuccess((()=>{l.close(),null==d||d()}))};return s?l.afterClose=f:r&&(l.afterClose=()=>p(),p()),{open:e=>{(e||!r||s)&&p(e),s||l.open()},close:()=>l.close(),remove:()=>l.remove(),refresh:()=>{r&&!s&&l.isClosed&&p()}}}},n=new WeakMap,i=new WeakMap,o=new WeakMap,t=new WeakSet,r=function(){return c(this,void 0,void 0,(function*(){const e=yield this.getWidgetConfig(),t=yield this.getHostedPageBaseUrl();h(this,n,((e,t,n)=>"popup"!==e?"modal":t?"popup":(null==n||n(),"modal"))(null==e?void 0:e.flowTarget,t,(()=>{var e;return null===(e=this.logger)||void 0===e?void 0:e.error("Flows are configured to open in a popup, but this project has no custom domain, so they will open in a modal instead")})),"f"),h(this,i,t||"","f")}))},s=function(e,t){const n=this.createFlowTemplate(Object.assign({flowId:e},t));return((e,t,n,i,o)=>{const r=(null==t?void 0:t.getAttribute("project-id"))||"",s=new URL(`${e.replace(/\/$/,"")}/${r}`);Object.entries(WS).forEach((([e,n])=>{const i=null==t?void 0:t.getAttribute(e);i&&s.searchParams.set(n,i)})),LS.forEach((e=>{const i=null==t?void 0:t.getAttribute(e);if(i)try{Object.entries(JSON.parse(i)).forEach((([t,n])=>{null===n||"object"!=typeof n?s.searchParams.set(`${e}.${t}`,String(n)):null==o||o(e,t)}))}catch(t){null==n||n(e,i)}}));const a=s.toString();return a.length>2e3&&(null==i||i(a.length)),a})(u(this,i,"f"),n.content.querySelector("descope-wc"),((e,t)=>{var n;return null===(n=this.logger)||void 0===n?void 0:n.error(`Could not parse flow ${e} inputs`,t)}),(e=>{var t;return null===(t=this.logger)||void 0===t?void 0:t.error(`The flow popup url is ${e} characters, past the 2000 that is safe everywhere, so the popup may be refused before the flow starts. Pass identifiers in form and client inputs rather than data.`)}),((e,t)=>{var n;return null===(n=this.logger)||void 0===n?void 0:n.error(`The flow ${e} input "${t}" is an object, and a popup flow can only take text, so it was not sent. Pass an id instead.`)}))},a=function(e,n){if(!u(this,i,"f"))return;const o=new Za({logger:this.logger}),r=()=>{var e;return null===(e=this.onFlowPopupClosed)||void 0===e?void 0:e.call(this)};o.onUnauthenticated((()=>{var e;null===(e=this.logger)||void 0===e||e.info("The auth domain does not recognise this user; asking the app to sign in again"),this.dispatchEvent(new CustomEvent("flow-popup-unauthenticated"))}));const a=()=>{null==n||n(),r()};return o.onDone(a),o.onClosed(a),o.onParentFocus(a),{open:n=>{var i;o.open(u(this,t,"m",s).call(this,e,n))||(null===(i=this.logger)||void 0===i||i.error("The browser blocked the flow popup, so the flow did not start"),this.dispatchEvent(new CustomEvent("error",{detail:{message:"flow-popup-blocked"}})))},close:()=>o.close(),remove:()=>o.remove(),refresh:()=>{}}},d})),DS=Ti((e=>{var t,n,i,o,r,s;return s=class extends(Ei(kc,sa,xS,Cs,MS,US)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),o.set(this,Ai((e=>{this.avatar.image=e}))),r.set(this,Ai((e=>{this.avatar.displayName=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var s;yield null===(s=e.onWidgetRootReady)||void 0===s?void 0:s.call(this),u(this,t,"m",i).call(this),h(this,n,this.createFlowRunner({dataId:"update-pic",flowId:this.avatar.flowId,onSuccess:()=>this.actions.getMe()}),"f"),u(this,o,"f").call(this,KC(this.state)),u(this,r,"f").call(this,JC(this.state)),this.subscribe(u(this,o,"f").bind(this),KC),this.subscribe(u(this,r,"f").bind(this),JC)}))}},n=new WeakMap,o=new WeakMap,r=new WeakMap,t=new WeakSet,i=function(){this.avatar=new wa((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-avatar")}),{logger:this.logger}),this.avatar.onClick((()=>{var e;null===(e=u(this,n,"f"))||void 0===e||e.open()}))},s})),FS=Ti((e=>{var t,n,i,o,r,s,a;return a=class extends(Ei(kc,xS,Cs,MS,US)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),i.set(this,void 0),r.set(this,Ai((e=>{var t,o;this.emailUserAttr.value=e,null===(t=u(this,n,"f"))||void 0===t||t.refresh(),null===(o=u(this,i,"f"))||void 0===o||o.refresh()}))),s.set(this,Ai((e=>{this.emailUserAttr.badgeLabel=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var a;yield null===(a=e.onWidgetRootReady)||void 0===a?void 0:a.call(this),u(this,t,"m",o).call(this),h(this,n,this.createFlowRunner({dataId:"edit-email",flowId:this.emailUserAttr.editFlowId,onSuccess:()=>this.actions.getMe()}),"f"),h(this,i,this.createFlowRunner({dataId:"delete-email",flowId:this.emailUserAttr.deleteFlowId,onSuccess:()=>this.actions.getMe()}),"f"),u(this,r,"f").call(this,HC(this.state)),u(this,s,"f").call(this,YC(this.state)),this.subscribe(u(this,r,"f").bind(this),HC),this.subscribe(u(this,s,"f").bind(this),YC)}))}},n=new WeakMap,i=new WeakMap,r=new WeakMap,s=new WeakMap,t=new WeakSet,o=function(){this.emailUserAttr=new rd((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="email"]')}),{logger:this.logger}),this.emailUserAttr.onEditClick((()=>{var e;null===(e=u(this,n,"f"))||void 0===e||e.open()})),this.emailUserAttr.onDeleteClick((()=>{var e;null===(e=u(this,i,"f"))||void 0===e||e.open()}))},a})),_S=Ti((e=>{var t,n,i;return i=class extends(Ei(xS,Cs,MS,ud)(e)){constructor(){super(...arguments),t.add(this)}handleLogout(){return c(this,void 0,void 0,(function*(){yield this.actions.logout(),this.dispatchEvent(new CustomEvent("logout"))}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",n).call(this)}))}},t=new WeakSet,n=function(){this.logout=new ka((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-button[data-id="logout"]')}),{logger:this.logger}),this.logout.onClick((()=>this.handleLogout()))},i})),qS=Ti((e=>{var t,n,i,o,r,s;return s=class extends(Ei(kc,xS,Cs,MS,US)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),i.set(this,void 0),r.set(this,Ai((e=>{var t,o;this.nameUserAttr.value=e,null===(t=u(this,n,"f"))||void 0===t||t.refresh(),null===(o=u(this,i,"f"))||void 0===o||o.refresh()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var s;yield null===(s=e.onWidgetRootReady)||void 0===s?void 0:s.call(this),u(this,t,"m",o).call(this),h(this,n,this.createFlowRunner({dataId:"edit-name",flowId:this.nameUserAttr.editFlowId,onSuccess:()=>this.actions.getMe()}),"f"),h(this,i,this.createFlowRunner({dataId:"delete-name",flowId:this.nameUserAttr.deleteFlowId,onSuccess:()=>this.actions.getMe()}),"f"),u(this,r,"f").call(this,JC(this.state)),this.subscribe(u(this,r,"f").bind(this),JC)}))}},n=new WeakMap,i=new WeakMap,r=new WeakMap,t=new WeakSet,o=function(){this.nameUserAttr=new rd((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="name"]')}),{logger:this.logger}),this.nameUserAttr.onEditClick((()=>{var e;null===(e=u(this,n,"f"))||void 0===e||e.open()})),this.nameUserAttr.onDeleteClick((()=>{var e;null===(e=u(this,i,"f"))||void 0===e||e.open()}))},s})),BS=Ti((e=>{var t,n,i,o,r,s;return s=class extends(Ei(kc,xS,Cs,MS,Sc,US)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),i.set(this,void 0),r.set(this,Ai((e=>{this.passkeyUserAuthMethod.fulfilled=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var s;yield null===(s=e.onWidgetRootReady)||void 0===s?void 0:s.call(this),u(this,t,"m",o).call(this),h(this,n,this.createFlowRunner({dataId:"add-passkey",flowId:this.passkeyUserAuthMethod.flowId,onSuccess:()=>this.actions.getMe()}),"f"),h(this,i,this.createFlowRunner({dataId:"remove-passkey",flowId:this.passkeyUserAuthMethod.fulfilledFlowId,onSuccess:()=>this.actions.getMe()}),"f"),u(this,r,"f").call(this,rS(this.state)),this.subscribe(u(this,r,"f").bind(this),rS)}))}},n=new WeakMap,i=new WeakMap,r=new WeakMap,t=new WeakSet,o=function(){this.passkeyUserAuthMethod=new sd((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="passkey"]')}),{logger:this.logger}),this.passkeyUserAuthMethod.onUnfulfilledButtonClick((()=>{var e;null===(e=u(this,n,"f"))||void 0===e||e.open()})),this.passkeyUserAuthMethod.onFulfilledButtonClick((()=>{var e;null===(e=u(this,i,"f"))||void 0===e||e.open()}))},s})),VS=Ti((e=>{var t,n;return n=class extends(Ei(kc,xS,Cs,MS,US)(e)){constructor(){super(...arguments),t.set(this,void 0)}initPasswordAuthMethod(){this.passwordUserAuthMethod=new sd((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="password"]')}),{logger:this.logger}),this.passwordUserAuthMethod.onUnfulfilledButtonClick((()=>{var e;null===(e=u(this,t,"f"))||void 0===e||e.open()}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),this.initPasswordAuthMethod(),h(this,t,this.createFlowRunner({dataId:"password",flowId:this.passwordUserAuthMethod.flowId}),"f")}))}},t=new WeakMap,n})),KS=Ti((e=>{var t,n,i,o,r,s,a;return a=class extends(Ei(kc,xS,Cs,MS,US)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),i.set(this,void 0),r.set(this,Ai((e=>{var t,o;this.phoneUserAttr.value=e,null===(t=u(this,n,"f"))||void 0===t||t.refresh(),null===(o=u(this,i,"f"))||void 0===o||o.refresh()}))),s.set(this,Ai((e=>{this.phoneUserAttr.badgeLabel=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var a;yield null===(a=e.onWidgetRootReady)||void 0===a?void 0:a.call(this),u(this,t,"m",o).call(this),h(this,n,this.createFlowRunner({dataId:"edit-phone",flowId:this.phoneUserAttr.editFlowId,onSuccess:()=>this.actions.getMe()}),"f"),h(this,i,this.createFlowRunner({dataId:"delete-phone",flowId:this.phoneUserAttr.deleteFlowId,onSuccess:()=>this.actions.getMe()}),"f"),u(this,r,"f").call(this,GC(this.state)),u(this,s,"f").call(this,XC(this.state)),this.subscribe(u(this,r,"f").bind(this),GC),this.subscribe(u(this,s,"f").bind(this),XC)}))}},n=new WeakMap,i=new WeakMap,r=new WeakMap,s=new WeakMap,t=new WeakSet,o=function(){this.phoneUserAttr=new rd((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="phone"]')}),{logger:this.logger}),this.phoneUserAttr.onEditClick((()=>{var e;null===(e=u(this,n,"f"))||void 0===e||e.open()})),this.phoneUserAttr.onDeleteClick((()=>{var e;null===(e=u(this,i,"f"))||void 0===e||e.open()}))},a})),HS=Ti((e=>{var t,n,i,o,r,s;return s=class extends(Ei(kc,xS,Cs,MS,US)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),i.set(this,void 0),r.set(this,Ai((e=>{this.recoveryEmailUserAttr.value=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var s;yield null===(s=e.onWidgetRootReady)||void 0===s?void 0:s.call(this),u(this,t,"m",o).call(this),h(this,n,this.createFlowRunner({dataId:"edit-recovery-email",flowId:this.recoveryEmailUserAttr.editFlowId,onSuccess:()=>this.actions.getMe()}),"f"),h(this,i,this.createFlowRunner({dataId:"delete-recovery-email",flowId:this.recoveryEmailUserAttr.deleteFlowId,onSuccess:()=>this.actions.getMe()}),"f"),u(this,r,"f").call(this,iS(this.state)),this.subscribe(u(this,r,"f").bind(this),iS)}))}},n=new WeakMap,i=new WeakMap,r=new WeakMap,t=new WeakSet,o=function(){this.recoveryEmailUserAttr=new rd((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="recoveryEmail"]')}),{logger:this.logger}),this.recoveryEmailUserAttr.onEditClick((()=>{var e;null===(e=u(this,n,"f"))||void 0===e||e.open()})),this.recoveryEmailUserAttr.onDeleteClick((()=>{var e;null===(e=u(this,i,"f"))||void 0===e||e.open()}))},s})),zS=Ti((e=>{var t,n,i,o,r,s;return s=class extends(Ei(kc,xS,Cs,MS,US)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),i.set(this,void 0),r.set(this,Ai((e=>{this.recoveryPhoneUserAttr.value=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var s;yield null===(s=e.onWidgetRootReady)||void 0===s?void 0:s.call(this),u(this,t,"m",o).call(this),h(this,n,this.createFlowRunner({dataId:"edit-recovery-phone",flowId:this.recoveryPhoneUserAttr.editFlowId,onSuccess:()=>this.actions.getMe()}),"f"),h(this,i,this.createFlowRunner({dataId:"delete-recovery-phone",flowId:this.recoveryPhoneUserAttr.deleteFlowId,onSuccess:()=>this.actions.getMe()}),"f"),u(this,r,"f").call(this,oS(this.state)),this.subscribe(u(this,r,"f").bind(this),oS)}))}},n=new WeakMap,i=new WeakMap,r=new WeakMap,t=new WeakSet,o=function(){this.recoveryPhoneUserAttr=new rd((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="recoveryPhone"]')}),{logger:this.logger}),this.recoveryPhoneUserAttr.onEditClick((()=>{var e;null===(e=u(this,n,"f"))||void 0===e||e.open()})),this.recoveryPhoneUserAttr.onDeleteClick((()=>{var e;null===(e=u(this,i,"f"))||void 0===e||e.open()}))},s})),JS=Ti((e=>{var t,n,i,o,r,s;return s=class extends(Ei(kc,xS,Cs,MS,US)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),i.set(this,void 0),r.set(this,Ai((e=>{this.totpUserAuthMethod.fulfilled=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var s;yield null===(s=e.onWidgetRootReady)||void 0===s?void 0:s.call(this),u(this,t,"m",o).call(this),h(this,n,this.createFlowRunner({dataId:"totp",flowId:this.totpUserAuthMethod.flowId,onSuccess:()=>this.actions.getMe()}),"f"),h(this,i,this.createFlowRunner({dataId:"remove-totp",flowId:this.totpUserAuthMethod.fulfilledFlowId,onSuccess:()=>this.actions.getMe()}),"f"),u(this,r,"f").call(this,sS(this.state)),this.subscribe(u(this,r,"f").bind(this),sS)}))}},n=new WeakMap,i=new WeakMap,r=new WeakMap,t=new WeakSet,o=function(){this.totpUserAuthMethod=new sd((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="totp"]')}),{logger:this.logger}),this.totpUserAuthMethod.onUnfulfilledButtonClick((()=>{var e;null===(e=u(this,n,"f"))||void 0===e||e.open()})),this.totpUserAuthMethod.onFulfilledButtonClick((()=>{var e;null===(e=u(this,i,"f"))||void 0===e||e.open()}))},s})),GS=Ti((e=>{var t,n,i,o,r,s,a,d,l,h;return h=class extends(Ei(kc,xS,Cs,MS,US)(e)){constructor(){super(...arguments),t.add(this),n.set(this,{}),i.set(this,{}),o.set(this,{}),l.set(this,Ai((e=>{Object.keys(u(this,n,"f")).forEach((t=>{u(this,n,"f")[t].value=(e[t]||"").toString()})),u(this,t,"m",d).call(this)})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),u(this,t,"m",a).call(this),u(this,l,"f").call(this,lS(this.state)),this.subscribe(u(this,l,"f").bind(this),lS)}))}},n=new WeakMap,i=new WeakMap,o=new WeakMap,l=new WeakMap,t=new WeakSet,r=function(e,t,n){const o=e.getAttribute("edit-flow-id");o&&(u(this,i,"f")[o]=this.createFlowRunner({dataId:`edit-${t}`,flowId:o,onSuccess:()=>this.actions.getMe()}),n.onEditClick((()=>{var e,t;null===(t=null===(e=u(this,i,"f"))||void 0===e?void 0:e[o])||void 0===t||t.open()})))},s=function(e,t,n){const i=e.getAttribute("delete-flow-id");i&&(u(this,o,"f")[i]=this.createFlowRunner({dataId:`delete-${t}`,flowId:i,onSuccess:()=>this.actions.getMe()}),n.onDeleteClick((()=>{var e,t;null===(t=null===(e=u(this,o,"f"))||void 0===e?void 0:e[i])||void 0===t||t.open()})))},a=function(){var e;const i=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelectorAll('descope-user-attribute[data-id^="builtin."]');Array.from(i||[]).forEach((e=>{const i=e.getAttribute("data-id").replace("builtin.",""),o=new rd(e,{logger:this.logger});u(this,n,"f")[i]=o,u(this,t,"m",r).call(this,e,i,o),u(this,t,"m",s).call(this,e,i,o)}))},d=function(){Object.values(u(this,i,"f")).forEach((e=>null==e?void 0:e.refresh())),Object.values(u(this,o,"f")).forEach((e=>null==e?void 0:e.refresh()))},h}));var ZS;!function(e){e.TEXT="text",e.NUMBER="number",e.BOOLEAN="boolean",e.SINGLE_SELECT="singleSelect",e.ARRAY="array",e.DATE="date"}(ZS||(ZS={}));const YS=Ti((e=>{var t,n,i,o,r,s,a;return n=class extends(Ei(kc,xS,Cs,MS,US)(e)){constructor(){super(...arguments),t.add(this),i.set(this,{}),o.set(this,{}),r.set(this,Ai((e=>{var i;const o=null===(i=this.shadowRoot)||void 0===i?void 0:i.querySelectorAll('descope-user-attribute[data-id^="customAttributes."]');Array.from(o).forEach((i=>{const o=i.getAttribute("data-id").replace("customAttributes.",""),r=i.getAttribute("data-type")||ZS.TEXT,d=e[o],l=new rd(i,{logger:this.logger});l.value=n.getFormattedValue(r,d),u(this,t,"m",s).call(this,i,o,l),u(this,t,"m",a).call(this,i,o,l)}))})))}static getFormattedValue(e,t){return e===ZS.DATE&&t?new Date(t).toLocaleString():e===ZS.BOOLEAN&&void 0!==t?t?"True":"False":(t||"").toString()}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.onWidgetRootReady)||void 0===t?void 0:t.call(this),u(this,r,"f").call(this,dS(this.state)),this.subscribe(u(this,r,"f").bind(this),dS)}))}},i=new WeakMap,o=new WeakMap,r=new WeakMap,t=new WeakSet,s=function(e,t,n){const o=e.getAttribute("edit-flow-id");o&&(u(this,i,"f")[o]=this.createFlowRunner({dataId:`edit-${t}`,flowId:o,onSuccess:()=>this.actions.getMe()}),n.onEditClick((()=>{var e,t;null===(t=null===(e=u(this,i,"f"))||void 0===e?void 0:e[o])||void 0===t||t.open()})))},a=function(e,t,n){const i=e.getAttribute("delete-flow-id");i&&(u(this,o,"f")[i]=this.createFlowRunner({dataId:`delete-${t}`,flowId:i,onSuccess:()=>this.actions.getMe()}),n.onDeleteClick((()=>{var e,t;null===(t=null===(e=u(this,o,"f"))||void 0===e?void 0:e[i])||void 0===t||t.open()})))},n})),XS=Ti((e=>{var t,n,i,o,r;return r=class extends(Ei(kc,sa,xS,Cs,MS,US)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),this.updateDeviceList=Ai((e=>{this.deviceList.data=e}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var r;yield null===(r=e.onWidgetRootReady)||void 0===r?void 0:r.call(this),this.deviceList=new ad((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-trusted-devices")}),{logger:this.logger}),this.deviceList.isExists&&(yield u(this,t,"m",o).call(this),u(this,t,"m",i).call(this,cS(this.state)),h(this,n,this.createFlowRunner({dataId:"untrust-device",flowId:this.deviceList.flowId,presetContent:!1,onSuccess:()=>this.actions.listDevices({userId:VC(this.state)})}),"f"),this.subscribe(this.updateDeviceList.bind(this),cS))}))}},n=new WeakMap,t=new WeakSet,i=function(e){this.deviceList.onRemoveDeviceClick((({id:e})=>{var t;null===(t=u(this,n,"f"))||void 0===t||t.open({form:{deviceId:e}})})),this.deviceList.data=e},o=function(){return c(this,void 0,void 0,(function*(){yield this.actions.listDevices({userId:VC(this.state)})}))},r})),QS=Ti((e=>{var t,n,i,o,r,s,a;return a=class extends(Ei(kc,xS,Cs,MS,Sc,US)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),i.set(this,void 0),r.set(this,Ai((e=>{this.actions.listPasskeys({userId:e})}))),this.updatePasskeyList=Ai((e=>{this.userPasskeys.data=e}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var a;yield null===(a=e.onWidgetRootReady)||void 0===a?void 0:a.call(this),this.userPasskeys=new ld((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-user-passkeys")}),{logger:this.logger}),this.userPasskeys.isExists&&(u(this,t,"m",s).call(this,uS(this.state)),h(this,n,this.createFlowRunner({dataId:"add-user-passkey",flowId:this.userPasskeys.addPasskeyFlowId,onSuccess:()=>u(this,t,"m",o).call(this)}),"f"),h(this,i,this.createFlowRunner({dataId:"remove-user-passkey",flowId:this.userPasskeys.removePasskeyFlowId,presetContent:!1,onSuccess:()=>u(this,t,"m",o).call(this)}),"f"),this.subscribe(u(this,r,"f").bind(this),VC),this.subscribe(this.updatePasskeyList.bind(this),uS))}))}},n=new WeakMap,i=new WeakMap,r=new WeakMap,t=new WeakSet,o=function(){this.actions.getMe(),this.actions.listPasskeys({userId:VC(this.state)})},s=function(e){this.updatePasskeyList(e),this.userPasskeys.onAddPasskeyClick((()=>{var e;null===(e=u(this,n,"f"))||void 0===e||e.open()})),this.userPasskeys.onRemovePasskeyClick((({id:e})=>{var t;null===(t=u(this,i,"f"))||void 0===t||t.open({form:{externalId:VC(this.state),credentialId:e}})}))},a})),eI={success:(new DOMParser).parseFromString('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Checkmark">\n<path id="Shape" d="M10.0485 15.6396C9.5799 15.171 8.8201 15.171 8.35147 15.6396C7.88284 16.1082 7.88284 16.868 8.35147 17.3367L12.7072 21.6924C13.1759 22.1611 13.9357 22.1611 14.4043 21.6924L24.7152 11.3815C25.1838 10.9129 25.1838 10.1531 24.7152 9.68448C24.2466 9.21585 23.4868 9.21585 23.0181 9.68448L13.5558 19.1469L10.0485 15.6396Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,error:(new DOMParser).parseFromString('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Icon">\n<path id="Vector" d="M15.9998 26.6558C10.1118 26.6558 5.34375 21.8878 5.34375 15.9998C5.34375 10.1118 10.1118 5.34375 15.9998 5.34375C21.8878 5.34375 26.6558 10.1118 26.6558 15.9998C26.6558 21.8878 21.8878 26.6558 15.9998 26.6558ZM15.9998 24.4798C20.6718 24.4798 24.4798 20.7038 24.4798 15.9998C24.4798 11.3278 20.7038 7.51975 15.9998 7.51975C11.3278 7.51975 7.51975 11.2958 7.51975 15.9998C7.51975 20.6718 11.2958 24.4798 15.9998 24.4798ZM15.3278 9.34375H16.6718C17.0558 9.34375 17.3438 9.63175 17.3118 9.98375L16.9598 16.9278C16.9598 17.1838 16.7678 17.3438 16.5438 17.3438H15.4558C15.2318 17.3438 15.0398 17.1518 15.0398 16.9278L14.6878 9.98375C14.6878 9.63175 14.9758 9.34375 15.3278 9.34375ZM15.4558 19.4558H16.5438C16.9278 19.4558 17.2158 19.7438 17.1838 20.1278V21.1838C17.1838 21.5678 16.8958 21.8558 16.5438 21.8558H15.4558C15.0718 21.8558 14.7838 21.5678 14.7838 21.1838V20.1278C14.7838 19.7438 15.0718 19.4558 15.4558 19.4558Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild},tI=Ti((e=>{var t,n,i,o,r;return r=class extends(Ei(Cs,xS,pd,Os)(e)){constructor(){super(...arguments),t.add(this),o.set(this,Ai((e=>{e.length&&(e.forEach((({type:e,msg:o})=>{const r=u(this,t,"m",i).call(this,e);r.setContent(u(this,t,"m",n).call(this,{type:e,msg:o})),r.show()})),setTimeout((()=>this.actions.clearNotifications())))})))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this),this.subscribe(u(this,o,"f").bind(this),hS)}))}},o=new WeakMap,t=new WeakSet,n=function({type:e,msg:t}){const n=eI[e],i=Object.assign((new DOMParser).parseFromString('<svg width="2em" height="2em" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Icon">\n<path id="Shape" d="M10.6712 12L7.27521 8.60406C6.90826 8.23711 6.90826 7.64216 7.27521 7.27521C7.64216 6.90826 8.23711 6.90826 8.60406 7.27521L12 10.6712L15.3959 7.27521C15.7629 6.90826 16.3578 6.90826 16.7248 7.27521C17.0917 7.64216 17.0917 8.23711 16.7248 8.60406L13.3288 12L16.7248 15.3959C17.0917 15.7629 17.0917 16.3578 16.7248 16.7248C16.3578 17.0917 15.7629 17.0917 15.3959 16.7248L12 13.3288L8.60406 16.7248C8.23711 17.0917 7.64216 17.0917 7.27521 16.7248C6.90826 16.3578 6.90826 15.7629 7.27521 15.3959L10.6712 12Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,{slot:"close"});return`${(null==n?void 0:n.outerHTML)||""}${t}${i.outerHTML}`},i=function(e){return this.createNotification({mode:e,duration:"error"===e?0:3e3,position:"bottom-start",size:"sm"})},r})),nI=Ti((e=>{var t,n,i,o,r,s,a,d,l,f,p;return p=class extends(Ei(xS,Cs,MS)(e)){constructor(){super(...arguments),t.add(this),n.set(this,null),o.set(this,(e=>c(this,void 0,void 0,(function*(){const t=e.target.value;yield this.actions.selectTenant(t)})))),r.set(this,(e=>{const i=pS(e);this.tenantSelector.value!==i&&u(this,t,"m",l).call(this,i);const{loading:o,error:r}=e.selectTenant,a=null!==e.tenant.previousTenantId,d=i!==u(this,n,"f");!i||o||r||a||!d||(h(this,n,i,"f"),u(this,t,"m",s).call(this))}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),this.actions.setCurrentTenantId((()=>{const e=In();return qC(e)})()),u(this,t,"m",i).call(this),u(this,t,"m",f).call(this),u(this,t,"m",d).call(this,fS(this.state)),this.subscribe(u(this,r,"f").bind(this))}))}},n=new WeakMap,o=new WeakMap,r=new WeakMap,t=new WeakSet,i=function(){this.tenantSelector=new dd((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-combo-box[name="tenantSelector"]')}),{logger:this.logger}),this.tenantSelector.onInput(u(this,o,"f"))},s=function(){const e=pS(this.state);this.dispatchEvent(new CustomEvent("tenant-changed",{bubbles:!0,composed:!0,detail:{tenantId:e}})),this.tenantSelector.shouldReload&&u(this,t,"m",a).call(this)},a=function(){setTimeout((()=>window.location.reload()),this.tenantSelector.refreshTimeout)},d=function(e){return c(this,void 0,void 0,(function*(){const t=e.map((e=>({label:e.tenantName||e.tenantId,value:e.tenantId})));yield this.tenantSelector.setData(t)}))},l=function(e){e&&(this.tenantSelector.value=e)},f=function(){this.tenantSelector.setAllowCustomValue(!0),setTimeout((()=>{u(this,t,"m",l).call(this,pS(this.state)),this.tenantSelector.setAllowCustomValue(!1)}))},p})),iI=Ti((e=>{var t,n,i,o,r,s;return s=class extends(Ei(kc,xS,Cs,MS,US)(e)){constructor(){super(...arguments),t.add(this),n.set(this,[]),i.set(this,void 0)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o,s;yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),u(this,t,"m",r).call(this),h(this,i,this.createFlowRunner({dataId:"generic-flow-modal",flowId:null===(s=u(this,n,"f")[0])||void 0===s?void 0:s.flowId,presetContent:!1,deferOpenUntilFirstPage:!0,onSuccess:()=>this.actions.getMe()}),"f"),u(this,n,"f").forEach((e=>e.enable()))}))}},n=new WeakMap,i=new WeakMap,t=new WeakSet,o=function(e){const t=new Sa(e,{logger:this.logger});t.onClick((()=>{var e;null===(e=u(this,i,"f"))||void 0===e||e.open({flowId:t.flowId,client:{userId:VC(this.state)}})})),u(this,n,"f").push(t)},r=function(){var e;const n=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelectorAll("[data-generic-flow-button-id]");Array.from(n).forEach((e=>{u(this,t,"m",o).call(this,e)}))},s})),oI=Ti((e=>class extends(Ei(fa,sa,AS,YS,FS,DS,qS,KS,HS,zS,BS,VS,JS,GS,_S,jS,XS,QS,tI,nI,iI,Oc)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),rI=Ei((e=>class extends(oI(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this);const n=customElements.get("descope-wc")||(yield Promise.resolve().then((function(){return Mh})).then((e=>e.default))),i=this;n.sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"user-profile-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.21.5"},get sessionTokenViaCookie(){return i.sessionTokenViaCookie},get refreshTokenViaCookie(){return i.refreshTokenViaCookie}}}))}}))(HTMLElement);customElements.define("descope-user-profile-widget",rI);var sI=Object.freeze({__proto__:null,default:rI});const aI=(e,t,n,i={})=>{var o,r,s,a;return[Math.min(Math.max(t,("all"===i.left?e.offsetWidth:null!==(o=i.left)&&void 0!==o?o:0)-e.offsetWidth),window.innerWidth-("all"===i.right?e.offsetWidth:null!==(r=i.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===i.top?e.offsetHeight:null!==(s=i.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===i.bottom?e.offsetHeight:null!==(a=i.bottom)&&void 0!==a?a:0))]};var dI,lI,cI,uI,hI,fI,pI,vI,gI,mI;const yI=document.createElement("template");yI.innerHTML='\n<div class="debugger">\n <div class="header">\n <span>Debugger messages</span>\n </div>\n <div class="content">\n <div class="empty-state">\n No errors detected 👀\n </div>\n </div>\n</div>\n';const bI=Ei(Gs)(HTMLElement);class wI extends bI{constructor(){var e;super(),dI.add(this),lI.set(this,new _i({messages:[]})),cI.set(this,void 0),uI.set(this,void 0),hI.set(this,void 0),fI.set(this,{resize:u(this,dI,"m",mI).bind(this)}),this.attachShadow({mode:"open"}),null===(e=this.shadowRoot)||void 0===e||e.appendChild(yI.content.cloneNode(!0)),this.injectStyle('\n.debugger {\n all: initial;\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n'),h(this,cI,this.shadowRoot.querySelector(".debugger"),"f"),u(this,cI,"f").style.top="32px",u(this,cI,"f").style.left=window.innerWidth-300-32+"px",h(this,uI,u(this,cI,"f").querySelector(".content"),"f"),h(this,hI,u(this,cI,"f").querySelector(".header"),"f")}updateData(e){u(this,lI,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((e,t,n)=>{let i=0,o=0,r=0,s=0;function a(t){t.preventDefault(),i=r-t.clientX,o=s-t.clientY,r=t.clientX,s=t.clientY;const[a,d]=aI(e,e.offsetLeft-i,e.offsetTop-o,n);e.style.top=`${d}px`,e.style.left=`${a}px`}function d(){document.onmouseup=null,document.onmousemove=null}function l(e){e.preventDefault(),r=e.clientX,s=e.clientY,document.onmouseup=d,document.onmousemove=a}t?t.onmousedown=l:e.onmousedown=l})(u(this,cI,"f"),u(this,hI,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",u(this,fI,"f").resize),(e=u(this,cI,"f")).onmousemove=t=>{var n;const i=t.target;(i.w&&i.w!==i.offsetWidth||i.h&&i.h!==i.offsetHeight)&&(null===(n=e.onresize)||void 0===n||n.call(e,t)),i.w=i.offsetWidth,i.h=i.offsetHeight},u(this,cI,"f").onresize=u(this,dI,"m",gI).bind(this),u(this,lI,"f").subscribe(u(this,dI,"m",pI).bind(this))}disconnectedCallback(){u(this,lI,"f").unsubscribeAll(),window.removeEventListener("resize",u(this,fI,"f").resize)}}lI=new WeakMap,cI=new WeakMap,uI=new WeakMap,hI=new WeakMap,fI=new WeakMap,dI=new WeakSet,pI=function(e){u(this,dI,"m",vI).call(this,e),u(this,dI,"m",gI).call(this)},vI=function(e){u(this,uI,"f").innerHTML=e.messages.map((e=>`\n <div class="msg">\n <svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M5.99984 13.167L8.99984 10.167L11.9998 13.167L13.1665 12.0003L10.1665 9.00033L13.1665 6.00033L11.9998 4.83366L8.99984 7.83366L5.99984 4.83366L4.83317 6.00033L7.83317 9.00033L4.83317 12.0003L5.99984 13.167ZM8.99984 17.3337C7.84706 17.3337 6.76373 17.1148 5.74984 16.677C4.73595 16.2398 3.854 15.6462 3.104 14.8962C2.354 14.1462 1.76039 13.2642 1.32317 12.2503C0.885393 11.2364 0.666504 10.1531 0.666504 9.00033C0.666504 7.84755 0.885393 6.76421 1.32317 5.75033C1.76039 4.73644 2.354 3.85449 3.104 3.10449C3.854 2.35449 4.73595 1.7606 5.74984 1.32283C6.76373 0.885603 7.84706 0.666992 8.99984 0.666992C10.1526 0.666992 11.2359 0.885603 12.2498 1.32283C13.2637 1.7606 14.1457 2.35449 14.8957 3.10449C15.6457 3.85449 16.2393 4.73644 16.6765 5.75033C17.1143 6.76421 17.3332 7.84755 17.3332 9.00033C17.3332 10.1531 17.1143 11.2364 16.6765 12.2503C16.2393 13.2642 15.6457 14.1462 14.8957 14.8962C14.1457 15.6462 13.2637 16.2398 12.2498 16.677C11.2359 17.1148 10.1526 17.3337 8.99984 17.3337ZM8.99984 15.667C10.8609 15.667 12.4373 15.0212 13.729 13.7295C15.0207 12.4378 15.6665 10.8614 15.6665 9.00033C15.6665 7.13921 15.0207 5.56283 13.729 4.27116C12.4373 2.97949 10.8609 2.33366 8.99984 2.33366C7.13873 2.33366 5.56234 2.97949 4.27067 4.27116C2.979 5.56283 2.33317 7.13921 2.33317 9.00033C2.33317 10.8614 2.979 12.4378 4.27067 13.7295C5.56234 15.0212 7.13873 15.667 8.99984 15.667Z" fill="#ED404A"/>\n</svg>\n\n <div class="msg_content">\n <div class="msg_title">\n ${Vi(e.title)}\n </div>\n <div class="msg_desc">\n ${Vi(e.description)}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},gI=function(){u(this,uI,"f").querySelectorAll(".msg").forEach((e=>{const t=e,n=t.querySelector(".msg_desc"),i=n.scrollWidth>n.clientWidth,o=n.clientHeight>20;i||o?(t.classList.add("collapsible"),t.onclick=e=>{e.target.classList.contains("msg_desc")||t.classList.toggle("collapsed")}):(t.classList.remove("collapsible"),t.onclick=null)}))},mI=function(){const[e,t]=aI(u(this,cI,"f"),Number.parseInt(u(this,cI,"f").style.left,10),Number.parseInt(u(this,cI,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});u(this,cI,"f").style.top=`${t}px`,u(this,cI,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",wI);var $I=Object.freeze({__proto__:null});const kI=(e,t,n,i={})=>{var o,r,s,a;return[Math.min(Math.max(t,("all"===i.left?e.offsetWidth:null!==(o=i.left)&&void 0!==o?o:0)-e.offsetWidth),window.innerWidth-("all"===i.right?e.offsetWidth:null!==(r=i.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===i.top?e.offsetHeight:null!==(s=i.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===i.bottom?e.offsetHeight:null!==(a=i.bottom)&&void 0!==a?a:0))]},CI=(e,t,n)=>{let i=0,o=0,r=0,s=0;function a(t){t.preventDefault(),i=r-t.clientX,o=s-t.clientY,r=t.clientX,s=t.clientY;const[a,d]=kI(e,e.offsetLeft-i,e.offsetTop-o,n);e.style.top=`${d}px`,e.style.left=`${a}px`}function d(){document.onmouseup=null,document.onmousemove=null}function l(e){e.preventDefault(),r=e.clientX,s=e.clientY,document.onmouseup=d,document.onmousemove=a}t?t.onmousedown=l:e.onmousedown=l};var SI,II,RI,EI,xI,OI,AI,NI,jI,MI,PI;const TI=document.createElement("template");TI.innerHTML='\n<div class="debugger">\n <div class="header">\n <span>Debugger messages</span>\n </div>\n <div class="content">\n <div class="empty-state">\n No errors detected 👀\n </div>\n </div>\n</div>\n';const WI=Ei(Gs)(HTMLElement);class LI extends WI{constructor(){super(),SI.add(this),II.set(this,new ts({messages:[]})),RI.set(this,void 0),EI.set(this,void 0),xI.set(this,void 0),OI.set(this,{resize:u(this,SI,"m",PI).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(TI.content.cloneNode(!0)),h(this,RI,this.shadowRoot.querySelector(".debugger"),"f"),h(this,EI,u(this,RI,"f").querySelector(".content"),"f"),h(this,xI,u(this,RI,"f").querySelector(".header"),"f"),u(this,SI,"m",AI).call(this)}updateData(e){u(this,II,"f").update((t=>({messages:t.messages.concat(e)})))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;null===(t=e.init)||void 0===t||t.call(this),CI(u(this,RI,"f"),u(this,xI,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",u(this,OI,"f").resize),(e=>{e.onmousemove=t=>{(t.target.w&&t.target.w!==t.target.offsetWidth||t.target.h&&t.target.h!==t.target.offsetHeight)&&e.onresize(t),t.target.w=t.target.offsetWidth,t.target.h=t.target.offsetHeight}})(u(this,RI,"f")),u(this,RI,"f").onresize=u(this,SI,"m",MI).bind(this),u(this,II,"f").subscribe(u(this,SI,"m",NI).bind(this))}))}disconnectedCallback(){u(this,II,"f").unsubscribeAll(),window.removeEventListener("resize",u(this,OI,"f").resize)}}II=new WeakMap,RI=new WeakMap,EI=new WeakMap,xI=new WeakMap,OI=new WeakMap,SI=new WeakSet,AI=function(){this.injectStyle('\n .debugger {\n all: initial;\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n'),u(this,RI,"f").style.top="32px",u(this,RI,"f").style.left=window.innerWidth-300-32+"px"},NI=function(e){u(this,SI,"m",jI).call(this,e),u(this,SI,"m",MI).call(this)},jI=function(e){u(this,EI,"f").innerHTML=e.messages.map((e=>`\n <div class="msg">\n <svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M5.99984 13.167L8.99984 10.167L11.9998 13.167L13.1665 12.0003L10.1665 9.00033L13.1665 6.00033L11.9998 4.83366L8.99984 7.83366L5.99984 4.83366L4.83317 6.00033L7.83317 9.00033L4.83317 12.0003L5.99984 13.167ZM8.99984 17.3337C7.84706 17.3337 6.76373 17.1148 5.74984 16.677C4.73595 16.2398 3.854 15.6462 3.104 14.8962C2.354 14.1462 1.76039 13.2642 1.32317 12.2503C0.885393 11.2364 0.666504 10.1531 0.666504 9.00033C0.666504 7.84755 0.885393 6.76421 1.32317 5.75033C1.76039 4.73644 2.354 3.85449 3.104 3.10449C3.854 2.35449 4.73595 1.7606 5.74984 1.32283C6.76373 0.885603 7.84706 0.666992 8.99984 0.666992C10.1526 0.666992 11.2359 0.885603 12.2498 1.32283C13.2637 1.7606 14.1457 2.35449 14.8957 3.10449C15.6457 3.85449 16.2393 4.73644 16.6765 5.75033C17.1143 6.76421 17.3332 7.84755 17.3332 9.00033C17.3332 10.1531 17.1143 11.2364 16.6765 12.2503C16.2393 13.2642 15.6457 14.1462 14.8957 14.8962C14.1457 15.6462 13.2637 16.2398 12.2498 16.677C11.2359 17.1148 10.1526 17.3337 8.99984 17.3337ZM8.99984 15.667C10.8609 15.667 12.4373 15.0212 13.729 13.7295C15.0207 12.4378 15.6665 10.8614 15.6665 9.00033C15.6665 7.13921 15.0207 5.56283 13.729 4.27116C12.4373 2.97949 10.8609 2.33366 8.99984 2.33366C7.13873 2.33366 5.56234 2.97949 4.27067 4.27116C2.979 5.56283 2.33317 7.13921 2.33317 9.00033C2.33317 10.8614 2.979 12.4378 4.27067 13.7295C5.56234 15.0212 7.13873 15.667 8.99984 15.667Z" fill="#ED404A"/>\n</svg>\n\n <div class="msg_content">\n <div class="msg_title">\n ${Vi(e.title)}\n </div>\n <div class="msg_desc">\n ${Vi(e.description)}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},MI=function(){u(this,EI,"f").querySelectorAll(".msg").forEach((e=>{const t=e.querySelector(".msg_desc"),n=t.scrollWidth>t.clientWidth,i=t.clientHeight>20;n||i?(e.classList.add("collapsible"),e.onclick=t=>{t.target.classList.contains("msg_desc")||e.classList.toggle("collapsed")}):(e.classList.remove("collapsible"),e.onclick=null)}))},PI=function(){const[e,t]=kI(u(this,RI,"f"),Number.parseInt(u(this,RI,"f").style.left,10),Number.parseInt(u(this,RI,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});u(this,RI,"f").style.top=`${t}px`,u(this,RI,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",LI);var UI=Object.freeze({__proto__:null,default:LI});e.AccessKeyManagement=eo,e.ApplicationsPortal=no,e.AuditManagement=oo,e.AuthProvider=({projectId:e,baseUrl:o="",baseStaticUrl:a="",baseCdnUrl:d="",sessionTokenViaCookie:l=!1,refreshTokenViaCookie:c=!1,hooks:u,persistTokens:h=!0,autoRefresh:f=!0,oidcConfig:p,storeLastAuthenticatedUser:v=!0,keepLastAuthenticatedUserAfterLogout:g=!1,refreshCookieName:m="",getExternalToken:y,customStorage:b,children:w})=>{const[$,k]=t.useState(),[C,S]=t.useState(),[I,R]=t.useState(),[E,x]=t.useState(!1),[O,A]=t.useState(!1),[N,j]=t.useState(!1),[M,P]=t.useState(!!p),[T,W]=t.useState(!1),[L,U]=t.useState(!1),D=t.useRef(!1),F=(({projectId:e,baseUrl:n,persistTokens:i,autoRefresh:o,sessionTokenViaCookie:r,refreshTokenViaCookie:a,refreshCookieName:d,oidcConfig:l,storeLastAuthenticatedUser:c,keepLastAuthenticatedUserAfterLogout:u,getExternalToken:h,hooks:f,customStorage:p})=>t.useMemo((()=>{if(e)return wi({projectId:e,baseUrl:n,sessionTokenViaCookie:r,refreshTokenViaCookie:a,baseHeaders:s,persistTokens:i,autoRefresh:o,refreshCookieName:d,oidcConfig:l,storeLastAuthenticatedUser:c,keepLastAuthenticatedUserAfterLogout:u,hooks:f,getExternalToken:h,customStorage:p})}),[e,n,JSON.stringify(r),JSON.stringify(a),h,p]))({projectId:e,baseUrl:o,persistTokens:h,autoRefresh:f,sessionTokenViaCookie:l,refreshTokenViaCookie:c,hooks:u,oidcConfig:p,storeLastAuthenticatedUser:v,keepLastAuthenticatedUserAfterLogout:g,refreshCookieName:m,getExternalToken:y,customStorage:b});t.useEffect((()=>{if(F){const e=F.onSessionTokenChange(S),t=F.onUserChange(k),n=F.onIsAuthenticatedChange(x),i=F.onClaimsChange(R);return()=>{e(),t(),n(),i()}}}),[F]);const _=t.useRef(!1),q=t.useRef(!1);t.useEffect((()=>{F&&p&&!D.current&&(D.current=!0,F.oidc.finishLoginIfNeed().finally((()=>{P(!1),_.current=!0,W(!0)})))}),[]);const B=t.useCallback((()=>{if(r())return;if(_.current)return;_.current=!0,j(!0);const e=()=>{j(!1),W(!0)};i(null==F?void 0:F.refresh)(void 0,!0).then(e,e)}),[F]),V=t.useCallback((()=>{if(q.current)return;q.current=!0,A(!0);const e=()=>{A(!1),U(!0)};i(F.me)().then(e,e)}),[F]),K=t.useMemo((()=>({fetchUser:V,user:$,isUserLoading:O,isUserFetchStarted:q.current,isUserFetchCompleted:L,fetchSession:B,session:C,isAuthenticated:E,isSessionLoading:N,isOidcLoading:M,isSessionFetchStarted:_.current,isSessionFetchCompleted:T,projectId:e,baseUrl:o,baseStaticUrl:a,baseCdnUrl:d,storeLastAuthenticatedUser:v,keepLastAuthenticatedUserAfterLogout:g,refreshCookieName:m,sessionTokenViaCookie:l,refreshTokenViaCookie:c,customStorage:b,setUser:k,setSession:S,setIsAuthenticated:x,claims:I,sdk:F})),[V,$,O,q.current,L,B,C,E,N,M,_.current,T,e,o,a,d,g,m,JSON.stringify(l),JSON.stringify(c),b,k,S,x,I,F]);return t.createElement(n.Provider,{value:K},w)},e.Descope=Gi,e.OutboundApplications=so,e.RoleManagement=lo,e.SignInFlow=e=>t.createElement(Gi,Object.assign({},e,{flowId:"sign-in"})),e.SignUpFlow=e=>t.createElement(Gi,Object.assign({},e,{flowId:"sign-up"})),e.SignUpOrInFlow=e=>t.createElement(Gi,Object.assign({},e,{flowId:"sign-up-or-in"})),e.TenantProfile=uo,e.UserManagement=fo,e.UserProfile=vo,e.baseHeaders=s,e.getCurrentTenant=Ri,e.getJwtPermissions=Si,e.getJwtRoles=Ii,e.getRefreshToken=Ci,e.getSessionToken=ki,e.isRefreshTokenExpired=(e=Ci())=>null==bi?void 0:bi.isJwtExpired(e),e.isSessionTokenExpired=(e=ki())=>null==bi?void 0:bi.isJwtExpired(e),e.refresh=(e=Ci())=>null==bi?void 0:bi.refresh(e),e.useDescope=()=>{const{sdk:e}=Zi();return t.useMemo((()=>e||new Proxy($i(),Xi)),[e])},e.useSession=()=>{const{session:e,claims:n,isSessionLoading:i,isOidcLoading:o,fetchSession:s,isSessionFetchStarted:a,isSessionFetchCompleted:d,isAuthenticated:l}=Zi(),c=t.useRef(i||o);t.useMemo((()=>{c.current=i||o}),[i,o,d]);const u=!l&&!i&&!r();return t.useMemo((()=>{u&&!a&&(c.current=!0)}),[a]),t.useEffect((()=>{u&&s()}),[s]),{isSessionLoading:c.current,sessionToken:e,claims:n,isAuthenticated:l}},e.useUser=()=>{const{user:e,fetchUser:n,isUserLoading:i,isAuthenticated:o,isUserFetchStarted:r,isUserFetchCompleted:s}=Zi(),[a,d]=t.useState(!1),l=t.useRef(i),c=t.useMemo((()=>!e&&!i&&o&&!a),[n,o,a]);return t.useMemo((()=>{l.current=i}),[i,s]),t.useMemo((()=>{c&&!r&&(l.current=!0)}),[c,r]),t.useEffect((()=>{c&&(d(!0),n())}),[c]),{isUserLoading:l.current,user:e}}}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Descope={},e.React)}(this,(function(e,t){"use strict";const n=t.createContext(void 0),i=e=>(...t)=>{if(!e)throw Error("You can only use this function after sdk initialization. Make sure to supply 'projectId' to <AuthProvider /> component");return e(...t)},o=e=>(...t)=>{let n;try{n=e(...t)}catch(e){console.error(e)}return n},r=()=>"undefined"!=typeof window&&!!window.descopeBridge,s={"x-descope-sdk-name":"react","x-descope-sdk-version":"3.6.0"},a="undefined"!=typeof window;var d=function(){return d=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},d.apply(this,arguments)};function l(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(i=Object.getOwnPropertySymbols(e);o<i.length;o++)t.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(e,i[o])&&(n[i[o]]=e[i[o]])}return n}function c(e,t,n,i){return new(n||(n=Promise))((function(o,r){function s(e){try{d(i.next(e))}catch(e){r(e)}}function a(e){try{d(i.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}d((i=i.apply(e,t||[])).next())}))}function u(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)}function h(e,t,n,i,o){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?o.call(e,n):o?o.value=n:t.set(e,n),n}"function"==typeof SuppressedError&&SuppressedError;class f extends Error{}function p(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return function(e){return decodeURIComponent(atob(e).replace(/(.)/g,((e,t)=>{let n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(t)}catch(e){return atob(t)}}function v(e,t){if("string"!=typeof e)throw new f("Invalid token specified: must be a string");t||(t={});const n=!0===t.header?0:1,i=e.split(".")[n];if("string"!=typeof i)throw new f(`Invalid token specified: missing part #${n+1}`);let o;try{o=p(i)}catch(e){throw new f(`Invalid token specified: invalid base64 for part #${n+1} (${e.message})`)}try{return JSON.parse(o)}catch(e){throw new f(`Invalid token specified: invalid json for part #${n+1} (${e.message})`)}}f.prototype.name="InvalidTokenError";var g={accessKey:{exchange:"/v1/auth/accesskey/exchange"},otp:{verify:"/v1/auth/otp/verify",signIn:"/v1/auth/otp/signin",signUp:"/v1/auth/otp/signup",update:{email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},signUpOrIn:"/v1/auth/otp/signup-in"},magicLink:{verify:"/v1/auth/magiclink/verify",signIn:"/v1/auth/magiclink/signin",signUp:"/v1/auth/magiclink/signup",update:{email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},signUpOrIn:"/v1/auth/magiclink/signup-in"},enchantedLink:{verify:"/v1/auth/enchantedlink/verify",signIn:"/v1/auth/enchantedlink/signin",signUp:"/v1/auth/enchantedlink/signup",session:"/v1/auth/enchantedlink/pending-session",update:{email:"/v1/auth/enchantedlink/update/email",phone:"/v1/auth/enchantedlink/update/phone"},signUpOrIn:"/v1/auth/enchantedlink/signup-in"},oauth:{start:"/v1/auth/oauth/authorize",exchange:"/v1/auth/oauth/exchange",startNative:"v1/auth/oauth/native/start",finishNative:"v1/auth/oauth/native/finish",oneTap:{getOneTapClientId:"/v1/auth/onetap/clientid/{provider}",exchangeOneTapIDToken:"/v1/auth/onetap/idtoken/exchange",verifyOneTapIDToken:"/v1/auth/onetap/idtoken/verify"}},outbound:{connect:"/v1/outbound/oauth/connect"},sso:{start:"/v1/auth/saml/authorize",exchange:"/v1/auth/saml/exchange"},totp:{verify:"/v1/auth/totp/verify",signUp:"/v1/auth/totp/signup",update:"/v1/auth/totp/update"},notp:{signIn:"/v1/auth/notp/whatsapp/signin",signUp:"/v1/auth/notp/whatsapp/signup",signUpOrIn:"/v1/auth/notp/whatsapp/signup-in",session:"/v1/auth/notp/pending-session"},webauthn:{signUp:{start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},signIn:{start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},signUpOrIn:{start:"/v1/auth/webauthn/signup-in/start"},update:{start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"}},password:{signUp:"/v1/auth/password/signup",signIn:"/v1/auth/password/signin",sendReset:"/v1/auth/password/reset",update:"/v1/auth/password/update",replace:"/v1/auth/password/replace",policy:"/v1/auth/password/policy"},emailVerification:{start:"/v1/auth/emailverification/start"},refresh:"/v1/auth/refresh",tryRefresh:"/v1/auth/try-refresh",selectTenant:"/v1/auth/tenant/select",logout:"/v1/auth/logout",logoutAll:"/v1/auth/logoutall",me:"/v1/auth/me",myTenants:"/v1/auth/me/tenants",history:"/v1/auth/me/history",flow:{start:"/v1/flow/start",next:"/v1/flow/next",event:"/v1/flow/event"}};const m="<region>",y=`https://api.${m}descope.com`,b=6e5,w=()=>{const e={};return{headers(t){const n="function"==typeof t.entries?Object.fromEntries(t.entries()):t;return e.Headers=JSON.stringify(n),this},body(t){return e.Body=t,this},url(t){return e.Url=t.toString(),this},method(t){return e.Method=t,this},title(t){return e.Title=t,this},status(t){return e.Status=t,this},retries(t){return e.Retries=t,this},build:()=>Object.keys(e).flatMap((t=>e[t]?[`${"Title"!==t?`${t}: `:""}${e[t]}`]:[])).join("\n")}},$=[503,520,521,522,524,530],k=[100,5e3,5e3],C=e=>new Promise((t=>setTimeout(t,e))),S=e=>async function(...t){let n=await e(...t);const i=!!(null==(o=t[1])?void 0:o.disableRetry);var o;let r=0;for(;!i&&$.includes(n.status)&&r<k.length;)await C(k[r]),n=await e(...t),r++;r>0&&(n.retries=r);const s=await n.text();return n.text=()=>Promise.resolve(s),n.json=()=>Promise.resolve(JSON.parse(s)),n.clone=()=>n,n};let I;const R=()=>{if(I)return I;const e=new Date,t=`${e.getUTCFullYear().toString()}-${(e.getUTCMonth()+1).toString().padStart(2,"0")}-${e.getUTCDate().toString().padStart(2,"0")}-${e.getUTCHours().toString().padStart(2,"0")}:${e.getUTCMinutes().toString().padStart(2,"0")}:${e.getUTCSeconds().toString().padStart(2,"0")}:${e.getUTCMilliseconds().toString()}`,n=Math.floor(1e3+9e3*Math.random());return I=`${t}-${n}`,I};var E;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT",e.patch="PATCH"}(E||(E={}));const x=({path:e,baseUrl:t,queryParams:n,projectId:i})=>{const o=i.slice(1,-27);t=t.replace(m,o?o+".":"");let r=e?`${t.replace(/\/$/,"")}/${null==e?void 0:e.replace(/^\//,"")}`:t;if(n){const e=Object.keys(n);e.forEach(((t,i)=>{r=`${r}${0===i?"?":""}${t}=${encodeURIComponent(n[t])}${i===e.length-1?"":"&"}`}))}return r},O=(...e)=>new Headers(e.reduce(((e,t)=>((e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t).forEach((([t,n])=>{e[t]="function"==typeof n?n():n})),e)),{})),A={"Content-Type":"application/json"},N=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},j=(e,t)=>{const n={"x-descope-sdk-session-id":R(),"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.79.0","x-descope-project-id":e};return t&&(n["x-descope-refresh-cookie-name"]=t),n},M=e=>{try{e=JSON.parse(e)}catch(e){return!1}return"object"==typeof e&&null!==e};var P=e=>{var t;return(({baseUrl:e,projectId:t,baseConfig:n,refreshCookieName:i,logger:o,hooks:r,cookiePolicy:s,fetch:a})=>{const d=e||y,l=((e,t)=>{const n=t||fetch;return n||null==e||e.warn("Fetch is not defined, you will not be able to send http requests, if you are running in a test, make sure fetch is defined globally"),e?async function(...t){if(!n)throw Error("Cannot send http request, fetch is not defined, if you are running in a test, make sure fetch is defined globally");e.log((e=>w().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const i=await S(n)(...t);return e[i.ok?"log":"error"](await(async e=>{const t=await e.text();return w().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).retries(e.retries).build()})(i)),i}:S(n)})(o,a),c=async e=>{var o;const a=(null==r?void 0:r.beforeRequest)?r.beforeRequest(e):e,{path:c,body:u,headers:h,queryParams:f,method:p,token:v,keepalive:g,disableRetry:m}=a,y=(e=>void 0===e?void 0:JSON.stringify(e))(u),b=Object.assign(Object.assign({headers:O(N(t,v),j(t,i),(null==n?void 0:n.baseHeaders)||{},M(y)?A:{},h),method:p,body:y},g?{keepalive:!0}:{}),m?{disableRetry:!0}:{});null!==s&&(b.credentials=s||"include");const w=await l(x({path:c,baseUrl:d,queryParams:f,projectId:t}),b);if((null==r?void 0:r.afterRequest)&&await r.afterRequest(e,null==w?void 0:w.clone()),null==r?void 0:r.transformResponse){const e=await w.json(),t=($=(null===(o=w.headers)||void 0===o?void 0:o.get("set-cookie"))||"",Object.fromEntries(function(e){if(!e)return[];const t=[];let n=0;function i(){for(;n<e.length&&/\s/.test(e.charAt(n));)n+=1;return n<e.length}function o(){const t=e.charAt(n);return"="!==t&&";"!==t&&","!==t}for(;n<e.length;){const r=n;let s,a,d=!1;for(;i();)if(","===e.charAt(n)){for(s=n,n+=1,i(),a=n;n<e.length&&o();)n+=1;if(n<e.length&&"="===e.charAt(n)){d=!0,n=a,t.push(e.substring(r,s));break}n=s+1}else n+=1;(!d||n>=e.length)&&t.push(e.substring(r,e.length))}return t}($).map((e=>{const t=e.split(";")[0],n=t.indexOf("=");return n<1?null:[t.substring(0,n).trim(),t.substring(n+1).trim()]})).filter(Boolean))),n=Object.assign(Object.create(null),{json:()=>Promise.resolve(e),cookies:t}),i=new Proxy(w,{get:(e,t)=>{if(t in n)return n[t];const i=e[t];return"function"==typeof i?i.bind(e):i},set:(e,t,i)=>(n[t]=i,!0),has:(e,t)=>t in n||t in e});return n.clone=()=>i,r.transformResponse(i)}var $;return w};return{get:(e,{headers:t,queryParams:n,token:i,keepalive:o,disableRetry:r}={})=>c({path:e,headers:t,queryParams:n,body:void 0,method:E.get,token:i,keepalive:o,disableRetry:r}),post:(e,t,{headers:n,queryParams:i,token:o,keepalive:r,disableRetry:s}={})=>c({path:e,headers:n,queryParams:i,body:t,method:E.post,token:o,keepalive:r,disableRetry:s}),patch:(e,t,{headers:n,queryParams:i,token:o,keepalive:r,disableRetry:s}={})=>c({path:e,headers:n,queryParams:i,body:t,method:E.patch,token:o,keepalive:r,disableRetry:s}),put:(e,t,{headers:n,queryParams:i,token:o,keepalive:r,disableRetry:s}={})=>c({path:e,headers:n,queryParams:i,body:t,method:E.put,token:o,keepalive:r,disableRetry:s}),delete:(e,{headers:t,queryParams:n,token:i,keepalive:o,disableRetry:r}={})=>c({path:e,headers:t,queryParams:n,body:void 0,method:E.delete,token:i,keepalive:o,disableRetry:r}),hooks:r,buildUrl:(e,n)=>x({projectId:t,baseUrl:d,path:e,queryParams:n})}})(Object.assign(Object.assign({},e),{hooks:{beforeRequest:t=>{var n;const i=[].concat((null===(n=e.hooks)||void 0===n?void 0:n.beforeRequest)||[]);return null==i?void 0:i.reduce(((e,t)=>t(e)),t)},afterRequest:async(t,n)=>{var i;const o=[].concat((null===(i=e.hooks)||void 0===i?void 0:i.afterRequest)||[]);0!=o.length&&(await Promise.allSettled(null==o?void 0:o.map((e=>e(t,null==n?void 0:n.clone()))))).forEach((t=>{var n;return"rejected"===t.status&&(null===(n=e.logger)||void 0===n?void 0:n.error(t.reason))}))},transformResponse:null===(t=e.hooks)||void 0===t?void 0:t.transformResponse}}))},T=429;function W(e,t,n){var i;let o=L(e);if(t){if(!(null==o?void 0:o.tenants)&&(null==o?void 0:o.dct)===t)return(null==o?void 0:o[n])||[];o=null===(i=null==o?void 0:o.tenants)||void 0===i?void 0:i[t]}const r=null==o?void 0:o[n];return Array.isArray(r)?r:[]}function L(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return v(e)}function U(e){const{exp:t}=L(e);return(new Date).getTime()/1e3>t}function D(e){let t=L(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function F(e,t){return W(e,t,"permissions")}function _(e,t){return W(e,t,"roles")}const q=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function B(e,t){var n,i;const o=await e,r={code:o.status,ok:o.ok,response:o},s=await o.clone().json();if(o.ok)r.data=s;else{r.error=s,o.status===T&&Object.assign(r.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0});const e=null===(i=o.headers)||void 0===i?void 0:i.get("cf-ray");e&&r.error&&Object.assign(r.error,{traceId:e})}return r}function V(e){var t;return(null===(t=L(e))||void 0===t?void 0:t.dct)||""}const K=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),H=(e,t)=>(n=t)=>t=>{const i=e.filter((e=>e(t)));return!(i.length<e.length)&&(n?n.replace("{val}",t):i.join(" OR "))},z=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),J=e=>t=>e.test(t),G=J(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),Z=J(/^\+[1-9]{1}[0-9]{3,14}$/),Y=K(G,'"{val}" is not a valid email'),X=K(Z,'"{val}" is not a valid phone number'),Q=K((e=>e.length>=1),"Minimum length is 1");const ee=K((e=>"string"==typeof e),"Input is not a string"),te=K((e=>Array.isArray(e)),"Input is not an array"),ne=K((e=>"boolean"==typeof e),"Input is not a boolean"),ie=K((e=>void 0===e),"Input is defined"),oe=H([ee(),ie()],"Input is not a string or undefined"),re=H([te(),ne()],"Input is not an array or boolean"),se=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>z(...e).validate(n[t]))),t(...n)),ae=e=>[ee(`"${e}" must be a string`)],de=e=>[oe(`"${e}" must be string or undefined`)],le=e=>[ee(`"${e}" must be a string`),Q(`"${e}" must not be empty`)],ce=e=>[ee(`"${e}" must be a string`),Y()],ue=e=>[ee(`"${e}" must be a string`),X()],he=se(le("accessKey")),fe=e=>({exchange:he(((t,n)=>B(e.post(g.accessKey.exchange,{loginOptions:n},{token:t}))))}),pe=(e,t,n)=>(t.forEach((t=>{const i=t.split(".");let o=i.shift(),r=e;for(;i.length>0;){if(r=r[o],!o||!r)throw Error(`Invalid path "${t}", "${o}" is missing or has no value`);o=i.shift()}if("function"!=typeof r[o])throw Error(`"${t}" is not a function`);const s=r[o];r[o]=n(s)})),e),ve=({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||b,b)});var ge,me;!function(e){e.sms="sms",e.voice="voice",e.whatsapp="whatsapp",e.im="im"}(ge||(ge={})),function(e){e.email="email"}(me||(me={}));const ye=Object.assign(Object.assign({},ge),me);var be;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(be||(be={}));const we=le("loginId"),$e=se(le("token")),ke=se(we),Ce=se(le("pendingRef")),Se=se(we,ue("phone")),Ie=se(we,ce("email")),Re=e=>{const t=t=>(n,i,o={},r)=>{var{providerId:s}=o,a=l(o,["providerId"]);return B(e.post(q(g.enchantedLink.signIn,t),{loginId:n,URI:i,loginOptions:a,providerId:s},{token:r}))},n=t=>(n,i,o={})=>{var{providerId:r}=o,s=l(o,["providerId"]);return B(e.post(q(g.enchantedLink.signUpOrIn,t),{loginId:n,URI:i,loginOptions:s,providerId:r}))},i=t=>(n,i,o,r={})=>{var{providerId:s}=r,a=l(r,["providerId"]);return B(e.post(q(g.enchantedLink.signUp,t),{loginId:n,URI:i,user:o,loginOptions:a,providerId:s}))};return{verify:$e((t=>B(e.post(g.enchantedLink.verify,{token:t})))),signIn:ke(t(ye.email)),signInWithPhone:ke(t(ge.sms)),signUpOrIn:ke(n(ye.email)),signUpOrInWithPhone:ke(n(ge.sms)),signUp:ke(i(ye.email)),signUpWithPhone:ke(i(ge.sms)),waitForSession:Ce(((t,n)=>new Promise((i=>{const{pollingIntervalMs:o,timeoutMs:r}=ve(n);let s;const a=setInterval((async()=>{const n=await e.post(g.enchantedLink.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),i(B(Promise.resolve(n))))}),o);s=setTimeout((()=>{i({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:Ie(((t,n,i,o,r)=>B(e.post(g.enchantedLink.update.email,Object.assign({loginId:t,email:n,URI:i},r),{token:o})))),phone:{sms:Se(((t,n,i,o,r)=>B(e.post(q(g.enchantedLink.update.phone,ge.sms),Object.assign({loginId:t,phone:n,URI:i},r),{token:o}))))}}}},Ee=se(le("flowId")),xe=se(le("executionId"),le("stepId"),le("interactionId")),Oe=se(le("executionId")),Ae=e=>({start:Ee(((t,n,i,o,r,s,a,d=!1)=>B(e.post(g.flow.start,{flowId:t,options:n,conditionInteractionId:i,interactionId:o,componentsVersion:r,flowVersions:s,input:a,isCustomScreen:d})))),next:xe(((t,n,i,o,r,s,a=!1,d)=>B(e.post(g.flow.next,{executionId:t,stepId:n,interactionId:i,version:o,componentsVersion:r,input:s,isCustomScreen:a,options:d})))),event:Oe(((t,n,i)=>B(e.post(g.flow.event,{executionId:t,events:n},{keepalive:i,disableRetry:!0}))))}),Ne=le("loginId"),je=se(le("token")),Me=se(Ne);se(le("pendingRef"));const Pe=se(Ne,ue("phone")),Te=se(Ne,ce("email")),We=Object.keys(ye).filter((e=>e!==ge.voice&&e!==ge.im)),Le=e=>({verify:je((t=>B(e.post(g.magicLink.verify,{token:t})))),signIn:We.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Me(((t,i,o={},r)=>{var{providerId:s}=o,a=l(o,["providerId"]);return B(e.post(q(g.magicLink.signIn,n),{loginId:t,URI:i,loginOptions:a,providerId:s},{token:r}))}))})),{}),signUp:We.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Me(((t,i,o,r={})=>{var{providerId:s}=r,a=l(r,["providerId"]);return B(e.post(q(g.magicLink.signUp,n),{loginId:t,URI:i,user:o,loginOptions:a,providerId:s}))}))})),{}),signUpOrIn:We.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Me(((t,i,o={})=>{var{providerId:r}=o,s=l(o,["providerId"]);return B(e.post(q(g.magicLink.signUpOrIn,n),{loginId:t,URI:i,loginOptions:s,providerId:r}))}))})),{}),update:{email:Te(((t,n,i,o,r)=>B(e.post(g.magicLink.update.email,Object.assign({loginId:t,email:n,URI:i},r),{token:o})))),phone:Object.keys(ge).filter((e=>e!==ge.voice)).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Pe(((t,i,o,r,s)=>B(e.post(q(g.magicLink.update.phone,n),Object.assign({loginId:t,phone:i,URI:o},s),{token:r}))))})),{})}});var Ue;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple",e.discord="discord",e.linkedin="linkedin",e.slack="slack"}(Ue||(Ue={}));const De=se(le("code")),Fe=e=>({start:Object.assign(((t,n,i,o,r)=>B(e.post(g.oauth.start,i||{},{queryParams:Object.assign(Object.assign({provider:t},n&&{redirectURL:n}),r&&{loginHint:r}),token:o}))),Object.keys(Ue).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,i,o,r)=>B(e.post(g.oauth.start,i||{},{queryParams:Object.assign(Object.assign({provider:n},t&&{redirectURL:t}),r&&{loginHint:r}),token:o}))})),{})),exchange:De((t=>B(e.post(g.oauth.exchange,{code:t})))),startNative:(t,n,i)=>B(e.post(g.oauth.startNative,{provider:t,loginOptions:n,implicit:i})),finishNative:(t,n,i,o,r)=>B(e.post(g.oauth.finishNative,{provider:t,stateId:n,user:i,code:o,idToken:r})),getOneTapClientId:t=>B(e.get(g.oauth.oneTap.getOneTapClientId.replace("{provider}",t))),verifyOneTapIDToken:(t,n,i,o)=>B(e.post(g.oauth.oneTap.verifyOneTapIDToken,{provider:t,idToken:n,nonce:i,loginOptions:o})),exchangeOneTapIDToken:(t,n,i,o)=>B(e.post(g.oauth.oneTap.exchangeOneTapIDToken,{provider:t,idToken:n,nonce:i,loginOptions:o}))}),_e=le("appId"),qe=se(_e),Be=e=>({connect:qe(((t,n,i)=>{const o=null==n?void 0:n.tenantId,r=null==n?void 0:n.tenantLevel;return null==n||delete n.tenantId,null==n||delete n.tenantLevel,B(e.post(g.outbound.connect,{appId:t,tenantId:o,tenantLevel:r,options:n},{token:i}))}))}),Ve=le("loginId"),Ke=se(Ve,le("code")),He=se(Ve),ze=se(Ve,ue("phone")),Je=se(Ve,ce("email")),Ge=e=>({verify:Object.keys(ye).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ke(((t,i)=>B(e.post(q(g.otp.verify,n),{code:i,loginId:t}))))})),{}),signIn:Object.keys(ye).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:He(((t,i={},o)=>{var{providerId:r}=i,s=l(i,["providerId"]);return B(e.post(q(g.otp.signIn,n),{loginId:t,loginOptions:s,providerId:r},{token:o}))}))})),{}),signUp:Object.keys(ye).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:He(((t,i,o={})=>{var{providerId:r}=o,s=l(o,["providerId"]);return B(e.post(q(g.otp.signUp,n),{loginId:t,user:i,loginOptions:s,providerId:r}))}))})),{}),signUpOrIn:Object.keys(ye).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:He(((t,i={})=>{var{providerId:o}=i,r=l(i,["providerId"]);return B(e.post(q(g.otp.signUpOrIn,n),{loginId:t,loginOptions:r,providerId:o}))}))})),{}),update:{email:Je(((t,n,i,o)=>B(e.post(g.otp.update.email,Object.assign({loginId:t,email:n},o),{token:i})))),phone:Object.keys(ge).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ze(((t,i,o,r)=>B(e.post(q(g.otp.update.phone,n),Object.assign({loginId:t,phone:i},r),{token:o}))))})),{})}}),Ze=se(le("tenant")),Ye=se(le("code")),Xe=e=>({start:Ze(((t,n,i,o,r,s,a,d)=>B(e.post(g.sso.start,i||{},Object.assign({queryParams:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({tenant:t},n&&{redirectURL:n}),r&&{ssoId:r}),s&&{forceAuthn:"true"}),a&&{loginHint:a}),d&&{initiatedEmail:t})},o&&{token:o}))))),exchange:Ye((t=>B(e.post(g.sso.exchange,{code:t}))))}),Qe=le("loginId"),et=se(Qe,le("code")),tt=se(Qe),nt=se(Qe),it=e=>({signUp:tt(((t,n)=>B(e.post(g.totp.signUp,{loginId:t,user:n})))),verify:et(((t,n,i,o)=>B(e.post(g.totp.verify,{loginId:t,code:n,loginOptions:i},{token:o})))),update:nt(((t,n)=>B(e.post(g.totp.update,{loginId:t},{token:n}))))}),ot=e=>({start:()=>B(e.post(g.emailVerification.start,{}))}),rt=le("loginId"),st=le("newPassword"),at=se(rt,le("password")),dt=se(rt),lt=se(rt,st),ct=se(rt,le("oldPassword"),st),ut=e=>({signUp:at(((t,n,i,o={})=>{var{providerId:r}=o,s=l(o,["providerId"]);return B(e.post(g.password.signUp,{loginId:t,password:n,user:i,loginOptions:s,providerId:r}))})),signIn:at(((t,n,i={})=>{var{providerId:o}=i,r=l(i,["providerId"]);return B(e.post(g.password.signIn,{loginId:t,password:n,loginOptions:r,providerId:o}))})),sendReset:dt(((t,n,i)=>B(e.post(g.password.sendReset,{loginId:t,redirectUrl:n,templateOptions:i})))),update:lt(((t,n,i)=>B(e.post(g.password.update,{loginId:t,newPassword:n},{token:i})))),replace:ct(((t,n,i)=>B(e.post(g.password.replace,{loginId:t,oldPassword:n,newPassword:i})))),policy:()=>B(e.get(g.password.policy))}),ht=ae("loginId"),ft=le("loginId"),pt=ae("origin"),vt=se(ft,pt,le("name")),gt=se(ft,pt),mt=se(ht,pt),yt=se(ft,pt,de("token")),bt=se(le("transactionId"),le("response")),wt=e=>({signUp:{start:vt(((t,n,i,o,r)=>B(e.post(g.webauthn.signUp.start,{user:{loginId:t,name:i},origin:n,loginOptions:r,passkeyOptions:o})))),finish:bt(((t,n)=>B(e.post(g.webauthn.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:mt(((t,n,i,o,r)=>B(e.post(g.webauthn.signIn.start,{loginId:t,origin:n,loginOptions:i,passkeyOptions:r},{token:o})))),finish:bt(((t,n)=>B(e.post(g.webauthn.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:gt(((t,n,i,o)=>B(e.post(g.webauthn.signUpOrIn.start,{loginId:t,origin:n,loginOptions:o,passkeyOptions:i}))))},update:{start:yt(((t,n,i,o,r)=>B(e.post(g.webauthn.update.start,{loginId:t,origin:n,passkeyOptions:o,mfa:r},{token:i})))),finish:bt(((t,n)=>B(e.post(g.webauthn.update.finish,{transactionId:t,response:n}))))}}),$t=ae("loginId"),kt=se($t),Ct=se(le("pendingRef")),St=e=>({signUpOrIn:kt(((t,n={})=>{var{providerId:i}=n,o=l(n,["providerId"]);return B(e.post(g.notp.signUpOrIn,{loginId:t,loginOptions:o,providerId:i}))})),signUp:kt(((t,n,i={})=>{var{providerId:o}=i,r=l(i,["providerId"]);return B(e.post(g.notp.signUp,{loginId:t,user:n,providerId:o,loginOptions:r}))})),signIn:kt(((t,n={},i)=>{var{providerId:o}=n,r=l(n,["providerId"]);return B(e.post(g.notp.signIn,{loginId:t,loginOptions:r,providerId:o},{token:i}))})),waitForSession:Ct(((t,n)=>new Promise((i=>{const{pollingIntervalMs:o,timeoutMs:r}=ve(n);let s;const a=setInterval((async()=>{const n=await e.post(g.notp.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),i(B(Promise.resolve(n))))}),o);s=setTimeout((()=>{i({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)}))))}),It=se(le("token")),Rt=se(de("token")),Et=e=>{const t={};return(null==e?void 0:e.ssoLogout)&&(t.ssoLogout=!0),(null==e?void 0:e.redirectUrl)&&(t.redirectUrl=e.redirectUrl),t};var xt,Ot=se([(xt=le("projectId"),K(((e,t)=>n=>z(...t).validate(((e,t)=>{const n=(Array.isArray(t)?t.join("."):String(t)).replace(/\[\\?("|')?(\w|d)+\\?("|')?\]/g,((e,t,n)=>"."+n)).split("."),i=n.length;let o=0,r=e===Object(e)?e:void 0;for(;null!=r&&o<i;)r=r[n[o++]];return o&&o===i&&void 0!==r?r:void 0})(n,e)))("projectId",xt))())])((e=>{const{projectId:t,logger:n,baseUrl:i,cookiePolicy:o,baseHeaders:r={},refreshCookieName:s,fetch:a}=e;return d=P({baseUrl:i,projectId:t,logger:n,hooks:{get beforeRequest(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.beforeRequest},get afterRequest(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.afterRequest},get transformResponse(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.transformResponse}},cookiePolicy:o,baseConfig:{baseHeaders:r},refreshCookieName:s,fetch:a}),{accessKey:fe(d),otp:Ge(d),magicLink:Le(d),enchantedLink:Re(d),oauth:Fe(d),outbound:Be(d),sso:Xe(d),saml:Xe(d),totp:it(d),notp:St(d),webauthn:wt(d),password:ut(d),flow:Ae(d),emailVerification:ot(d),refresh:Rt(((e,t,n,i)=>{const o={};n&&(o.externalToken=n);const r=i?g.tryRefresh:g.refresh;return B(d.post(r,o,{token:e,queryParams:t}))})),selectTenant:se([ee("tenantId")],[oe('"token" must be string or undefined')])(((e,t)=>B(d.post(g.selectTenant,{tenant:e},{token:t})))),logout:Rt(((e,t)=>B(d.post(g.logout,Et(t),{token:e})))),logoutAll:Rt(((e,t)=>B(d.post(g.logoutAll,Et(t),{token:e})))),me:Rt((e=>B(d.get(g.me,{token:e})))),myTenants:se([re('"tenants" must a string array or a boolean')],[oe('"token" must be string or undefined')])(((e,t)=>{const n={};return"boolean"==typeof e?n.dct=e:n.ids=e,B(d.post(g.myTenants,n,{token:t}))})),history:Rt((e=>B(d.get(g.history,{token:e})))),isJwtExpired:It(U),getTenants:It(D),getJwtPermissions:It(F),getJwtRoles:It(_),getCurrentTenant:It(V),httpClient:d};var d})),At=Object.assign(Ot,{DeliveryMethods:ye});
2
+ /*! js-cookie v3.0.8 | MIT */function Nt(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)"__proto__"!==i&&(e[i]=n[i])}return e}var jt=function e(t,n){function i(e,i,o){if("undefined"!=typeof document){"number"==typeof(o=Nt({},n,o)).expires&&(o.expires=new Date(Date.now()+864e5*o.expires)),o.expires&&(o.expires=o.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var r="";for(var s in o)o[s]&&(r+="; "+s,!0!==o[s]&&(r+="="+o[s].split(";")[0]));return document.cookie=e+"="+t.write(i,e)+r}}return Object.create({set:i,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],i={},o=0;o<n.length;o++){var r=n[o].split("="),s=r.slice(1).join("=");try{var a=decodeURIComponent(r[0]);if(a in i||(i[a]=t.read(s,a)),e===a)break}catch(e){}}return e?i[e]:i}},remove:function(e,t){i(e,"",Nt({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,Nt({},this.attributes,t))},withConverter:function(t){return e(Nt({},this.converter,t),this.attributes)}},{attributes:{value:Object.freeze(n)},converter:{value:Object.freeze(t)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"});var Mt={default:"endpoint"},Pt="Blocked by CSP",Tt="The endpoint parameter is not a valid URL",Wt="Failed to load the JS script of the agent",Lt="9319";function Ut(e,t){var n,i,o,r,s,a=[],d=(n=function(e){var t=function(e,t,n){if(n||2===arguments.length)for(var i,o=0,r=t.length;o<r;o++)!i&&o in t||(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))}([],e,!0);return{current:function(){return t[0]},postpone:function(){var e=t.shift();void 0!==e&&t.push(e)},exclude:function(){t.shift()}}}(e),r=0,i=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,r++))},o=new Set,[n.current(),function(e,t){var r,s=t instanceof Error?t.message:"";if(s===Pt||s===Tt)n.exclude(),r=0;else if(s===Lt)n.exclude();else if(s===Wt){var a=Date.now()-e.getTime()<50,d=n.current();d&&a&&!o.has(d)&&(o.add(d),r=0),n.postpone()}else n.postpone();var l=n.current();return void 0===l?void 0:[l,null!=r?r:e.getTime()+i()-Date.now()]}]),l=d[0],c=d[1];if(void 0===l)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var u=function(e){var n=new Date,i=function(t){return a.push({url:e,startedAt:n,finishedAt:new Date,error:t})},o=t(e);return o.then((function(){return i()}),i),o.catch((function(e){if(null!=s||(s=e),a.length>=5)throw s;var t=c(n,e);if(!t)throw s;var i,o=t[0],r=t[1];return(i=r,new Promise((function(e){return setTimeout(e,i)}))).then((function(){return u(o)}))}))};return u(l).then((function(e){return[e,a]}))}var Dt="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",Ft=Dt;function _t(e){var t;e.scriptUrlPattern;var n=e.token,i=e.apiKey,o=void 0===i?n:i,r=l(e,["scriptUrlPattern","token","apiKey"]),s=null!==(t=function(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)?e[t]:void 0}(e,"scriptUrlPattern"))&&void 0!==t?t:Dt,a=function(){var e=[],t=function(){e.push({time:new Date,state:document.visibilityState})},n=function(e,t,n,i){return e.addEventListener(t,n,i),function(){return e.removeEventListener(t,n,i)}}(document,"visibilitychange",t);return t(),[e,n]}(),c=a[0],u=a[1];return Promise.resolve().then((function(){if(!o||"string"!=typeof o)throw new Error("API key required");var e=function(e,t){return(Array.isArray(e)?e:[e]).map((function(e){return function(e,t){var n=encodeURIComponent;return e.replace(/<[^<>]+>/g,(function(e){return"<version>"===e?"3":"<apiKey>"===e?n(t):"<loaderVersion>"===e?n("3.11.6"):e}))}(String(e),t)}))}(s,o);return Ut(e,qt)})).catch((function(e){throw u(),function(e){return e instanceof Error&&e.message===Lt?new Error(Wt):e}(e)})).then((function(e){var t=e[0],n=e[1];return u(),t.load(d(d({},r),{ldi:{attempts:n,visibilityStates:c}}))}))}function qt(e){return function(e,t,n){var i,o=document,r="securitypolicyviolation",s=function(t){var n=new URL(e,location.href),o=t.blockedURI;o!==n.href&&o!==n.protocol.slice(0,-1)&&o!==n.origin||(i=t,a())};o.addEventListener(r,s);var a=function(){return o.removeEventListener(r,s)};return Promise.resolve().then(t).then((function(e){return a(),e}),(function(e){return new Promise((function(e){var t=new MessageChannel;t.port1.onmessage=function(){return e()},t.port2.postMessage(null)})).then((function(){if(a(),i)return n(i);throw e}))}))}(e,(function(){return function(e){return new Promise((function(t,n){if(function(e){if(URL.prototype)try{return new URL(e,location.href),!1}catch(e){if(e instanceof Error&&"TypeError"===e.name)return!0;throw e}}(e))throw new Error(Tt);var i=document.createElement("script"),o=function(){var e;return null===(e=i.parentNode)||void 0===e?void 0:e.removeChild(i)},r=document.head||document.getElementsByTagName("head")[0];i.onload=function(){o(),t()},i.onerror=function(){o(),n(new Error(Wt))},i.async=!0,i.src=e,r.appendChild(i)}))}(e)}),(function(){throw new Error(Pt)})).then(Bt)}function Bt(){var e=window,t="__fpjs_p_l_b",n=e[t];if(function(e,t){var n,i=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,e,t);(null==i?void 0:i.configurable)?delete e[t]:i&&!i.writable||(e[t]=void 0)}(e,t),"function"!=typeof(null==n?void 0:n.load))throw new Error(Lt);return n}const Vt="3.2.0",Kt="undefined"!=typeof window,Ht=Math.pow(2,31)-1,zt=2e4,Jt=`https://descopecdn.com/npm/oidc-client-ts@${Vt}/dist/browser/oidc-client-ts.min.js`,Gt=`https://cdn.jsdelivr.net/npm/oidc-client-ts@${Vt}/dist/browser/oidc-client-ts.min.js`,Zt=["/v1/auth/refresh","/v1/auth/try-refresh","/v1/auth/me","/v1/auth/me/tenants","/v1/auth/me/history"];let Yt;const Xt=e=>{try{return v(e).exp}catch(e){return null}},Qt=e=>{const{refresh_expire_in:t,refresh_token:n}=e;return t?Math.floor(Date.now()/1e3)+t:Xt(n)},en=e=>{const{expires_in:t,expires_at:n,access_token:i}=e;return n||(t?Math.floor(Date.now()/1e3)+t:i?Xt(i):void 0)},tn=e=>{const{access_token:t,id_token:n,refresh_token:i,refresh_expire_in:o}=e,r=l(e,["access_token","id_token","refresh_token","refresh_expire_in"]);return Object.assign({sessionJwt:e.sessionJwt||t,idToken:n,refreshJwt:e.refreshJwt||i,sessionExpiration:e.sessionExpiration||en(e),cookieExpiration:e.cookieExpiration||Qt(e)},r)},nn=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,i)=>{var o;return n[i]=[].concat((null===(o=e.hooks)||void 0===o?void 0:o[i])||[]).concat((null==t?void 0:t[i])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},on=async e=>{if(!(null==e?void 0:e.ok))return{};const t=await(null==e?void 0:e.clone().json()),n=(null==t?void 0:t.authInfo)||t||{};return tn(n)},rn=()=>Kt&&!!window.descopeBridge,sn=(e,t)=>{if(!((null==t?void 0:t.status)>=400&&(null==t?void 0:t.status)<500))return!1;const n=(null==e?void 0:e.path)||"";return Zt.includes(n)},an=void 0!==Yt||Kt&&void 0!==window.localStorage,dn=(e,t)=>{var n,i;return null===(i=null===(n=Yt||Kt&&window.localStorage)||void 0===n?void 0:n.setItem)||void 0===i?void 0:i.call(n,e,t)},ln=e=>{var t,n;return null===(n=null===(t=Yt||Kt&&window.localStorage)||void 0===t?void 0:t.getItem)||void 0===n?void 0:n.call(t,e)},cn=e=>{var t,n;return null===(n=null===(t=Yt||Kt&&window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===n?void 0:n.call(t,e)},un=e=>{var t,n,i,o,r;return null!==(r=null!==(n=null===(t=null==Yt?void 0:Yt.key)||void 0===t?void 0:t.call(Yt,e))&&void 0!==n?n:Kt&&(null===(o=null===(i=window.localStorage)||void 0===i?void 0:i.key)||void 0===o?void 0:o.call(i,e)))&&void 0!==r?r:null},hn=e=>{var t,n;return Kt&&(null===(n=null===(t=window.localStorage)||void 0===t?void 0:t.getItem)||void 0===n?void 0:n.call(t,e))||null},fn=e=>{var t,n;try{Kt&&(null===(n=null===(t=window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===n||n.call(t,e))}catch(e){}},pn=(...e)=>{console.debug(...e)},vn=(...e)=>{console.warn(...e)},gn=e=>e?e.getTime()-(new Date).getTime():0,mn="DS",yn="DSR",bn="DSI",wn="DSRCN";function $n(e,t,n){if(t){const{cookieDomain:i,cookiePath:o,cookieSameSite:r,cookieExpiration:s,cookieSecure:a}=n,d=new Date(1e3*s),l=kn(i);jt.set(e,t,{path:o,domain:l?i:void 0,expires:d,sameSite:r,secure:a})}}function kn(e){const t=window.location.hostname.split("."),n=null==e?void 0:e.split(".");return t.slice(-(null==n?void 0:n.length)).join(".")===e}const Cn=e=>(null==e?void 0:e.cookieName)||mn,Sn=e=>(null==e?void 0:e.cookieName)||yn;function In(e="",t){return jt.get(Sn(t))||ln(`${e}${yn}`)||""}function Rn(e="",t){return jt.get(Cn(t))||ln(`${e}${mn}`)||""}function En(e=""){return ln(`${e}${bn}`)||""}function xn(e="",t,n,i){cn(`${e}${yn}`),cn(`${e}${mn}`),cn(`${e}${bn}`),cn(`${e}${wn}`);const o=Cn(t);jt.remove(o,null==i?void 0:i.session);const r=Sn(n);jt.remove(r,null==i?void 0:i.refresh)}const On=(e,t,n)=>i=>{const o=Object.assign(i,{token:i.token||In(e,t)});if(!n){const t=function(e=""){return ln(`${e}${wn}`)}(e);t&&(o.headers=Object.assign(Object.assign({},o.headers||{}),{"x-descope-refresh-cookie-name":t}))}const r=function(e=""){return ln(`${e}DTD`)||""}(e);r&&(o.headers=Object.assign(Object.assign({},o.headers||{}),{"x-descope-trusted-device-token":r}));const s=function(e=""){return ln(`${e}DKD`)||""}(e);return s&&(o.headers=Object.assign(Object.assign({},o.headers||{}),{"x-descope-known-device-token":s})),o},An=Kt&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",Nn="vsid",jn="vrid",Mn="fp",Pn=(e=!1)=>{const t=ln(Mn);if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},Tn=async(e,t=An)=>{try{if(Pn())return;const n=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),i=new URL(t);i.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const o=new URL(t);o.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const r=o.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",s=_t({apiKey:e,endpoint:[i.toString(),Mt],scriptUrlPattern:[r,Ft]}),a=await s,{requestId:d}=await a.get({linkedId:n}),l=((e,t)=>({[Nn]:e,[jn]:t}))(n,d);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};dn(Mn,JSON.stringify(t))})(l)}catch(e){console.warn("Could not load fingerprint",e)}},Wn=e=>{const t=Pn(!0);return t&&e.body&&(e.body.fpData=t),e},Ln="descopeFlowNonce",Un="X-Descope-Flow-Nonce",Dn="/v1/flow/start",Fn="/v1/flow/next",_n=(e,t=Ln)=>`${t}${e}`,qn=(e,t=Ln)=>{try{const n=_n(e,t),i=ln(n);if(!i)return null;const o=JSON.parse(i);return o.expiry<Date.now()?(Bn(e,t),null):{value:o.value,seq:o.seq}}catch(e){return console.error("Error getting flow nonce:",e),null}},Bn=(e,t=Ln)=>{try{const n=_n(e,t);cn(n)}catch(e){console.error("Error removing flow nonce:",e)}},Vn=e=>{var t;return(null===(t=/.*\|#\|(.*)/.exec(e))||void 0===t?void 0:t[1])||null},Kn=e=>{var t;return e.path===Fn&&(null===(t=e.body)||void 0===t?void 0:t.executionId)?Vn(e.body.executionId):null},Hn="dls_last_user_login_id",zn="dls_last_user_display_name",Jn=e=>dn(Hn,e),Gn=()=>ln(Hn),Zn=()=>ln(zn),Yn=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,i={}]=t,o=Gn(),r=Zn();return o&&(null!==(n=i.lastAuth)&&void 0!==n||(i.lastAuth={}),i.lastAuth.loginId=o,i.lastAuth.name=r),await e(...t)},Xn="DSLI",Qn=e=>async(...t)=>{const n=await e(...t);return fn(Xn),n};function ei(){const e=[];return{pub:t=>{e.forEach((e=>e(t)))},sub:t=>{const n=e.push(t)-1;return()=>e.splice(n,1)}}}async function ti(e,t){const n=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=di(n.publicKey.challenge),n.publicKey.user.id=di(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=di(e.id)})),n}(e);t&&(n.signal=t.signal);try{return i=await navigator.credentials.create(n),JSON.stringify({id:i.id,rawId:li(i.rawId),type:i.type,authenticatorAttachment:null!==(o=i.authenticatorAttachment)&&void 0!==o?o:void 0,response:{attestationObject:li(i.response.attestationObject),clientDataJSON:li(i.response.clientDataJSON)}})}catch(e){throw await oi(e,n,!0)}var i,o}async function ni(e,t){const n=si(e);t&&(n.signal=t.signal);try{return ai(await navigator.credentials.get(n))}catch(e){throw await oi(e,n,!1)}}async function ii(e,t){const n=si(e);n.signal=t.signal,n.mediation="conditional";try{return ai(await navigator.credentials.get(n))}catch(e){throw await oi(e,n,!1)}}async function oi(e,t,n){if(e&&"object"==typeof e)try{e.reason=await async function(e,t,n){var i,o;const r=null==e?void 0:e.name;if("AbortError"===r&&(null==t?void 0:t.signal)instanceof AbortSignal)return"aborted";if("InvalidStateError"===r&&n)return"authenticator_already_registered";if("NotSupportedError"===r)return"no_supported_algorithm";if("ConstraintError"===r)return"authenticator_constraints_unsupported";if("SecurityError"===r){const e=window.location.hostname;return"localhost"===e||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)?"invalid_rpid":"invalid_domain"}if(!await ri())return"webauthn_unsupported";const s="platform"===(null===(o=null===(i=null==t?void 0:t.publicKey)||void 0===i?void 0:i.authenticatorSelection)||void 0===o?void 0:o.authenticatorAttachment);return n&&s&&!await ri(!0)?"platform_authenticator_unsupported":"NotAllowedError"===r?"not_allowed":"unknown"}(e,t,n)}catch(e){}return e}async function ri(e=!1){var t,n;if(!Kt)return Promise.resolve(!1);if(rn()){const e=null===(n=null===(t=window.descopeBridge)||void 0===t?void 0:t.hostInfo)||void 0===n?void 0:n.webauthn;if("boolean"==typeof e)return e}const i=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return i&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():i}function si(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=di(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=di(e.id)})),n}function ai(e){var t;return JSON.stringify({id:e.id,rawId:li(e.rawId),type:e.type,authenticatorAttachment:null!==(t=e.authenticatorAttachment)&&void 0!==t?t:void 0,response:{authenticatorData:li(e.response.authenticatorData),clientDataJSON:li(e.response.clientDataJSON),signature:li(e.response.signature),userHandle:e.response.userHandle?li(e.response.userHandle):void 0}})}function di(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function li(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var ci,ui=(ci=e=>({async signUp(t,n,i){const o=await e.webauthn.signUp.start(t,window.location.origin,n,i);if(!o.ok)return o;const r=await ti(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,r)},async signIn(t,n){const i=await e.webauthn.signIn.start(t,window.location.origin,void 0,void 0,n);if(!i.ok)return i;const o=await ni(i.data.options);return await e.webauthn.signIn.finish(i.data.transactionId,o)},async signUpOrIn(t,n){var i;const o=await e.webauthn.signUpOrIn.start(t,window.location.origin,n);if(!o.ok)return o;if(null===(i=o.data)||void 0===i?void 0:i.create){const t=await ti(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,t)}{const t=await ni(o.data.options);return await e.webauthn.signIn.finish(o.data.transactionId,t)}},async update(t,n,i){const o=await e.webauthn.update.start(t,window.location.origin,n,i);if(!o.ok)return o;const r=await ti(o.data.options);return await e.webauthn.update.finish(o.data.transactionId,r)},helpers:{create:ti,get:ni,isSupported:ri,conditional:ii}}),(...e)=>{const t=ci(...e);return Object.assign(t.signUp,e[0].webauthn.signUp),Object.assign(t.signIn,e[0].webauthn.signIn),Object.assign(t.signUpOrIn,e[0].webauthn.signUpOrIn),Object.assign(t.update,e[0].webauthn.update),t});const hi="/fedcm/config";async function fi(e,t){var n;try{await pi(e,t)}catch(e){null===(n=null==t?void 0:t.onFailed)||void 0===n||n.call(t,e)}}async function pi(e,t){var n,i;const o=await async function(e,t="google",n,i,o){const r=(()=>{if(window.crypto&&window.crypto.getRandomValues){const e=new Uint8Array(16);return window.crypto.getRandomValues(e),Array.from(e,(e=>e.toString(16).padStart(2,"0"))).join("")}return Math.random().toString(36).substring(2)})(),s=await async function(){return new Promise(((e,t)=>{if(window.google)return void e(window.google.accounts.id);let n=document.getElementById("google-gsi-client-script");n||(n=document.createElement("script"),document.head.appendChild(n),n.async=!0,n.defer=!0,n.id="google-gsi-client-script",n.src="https://accounts.google.com/gsi/client"),n.onload=function(){window.google?e(window.google.accounts.id):t("Failed to load Google GSI client script - not loaded properly")},n.onerror=function(){t("Failed to load Google GSI client script - failed to load")}}))}(),a=await e.oauth.getOneTapClientId(t);if(!a.ok)throw new Error("Failed to get OneTap client ID for provider "+t);const d=a.data.clientId;return new Promise((e=>{var a,l;const c=n=>{e({provider:t,nonce:r,credential:null==n?void 0:n.credential})};s.initialize(Object.assign(Object.assign({},n),{itp_support:null===(a=null==n?void 0:n.itp_support)||void 0===a||a,use_fedcm_for_prompt:null===(l=null==n?void 0:n.use_fedcm_for_prompt)||void 0===l||l,client_id:d,callback:c,nonce:r})),s.prompt((e=>{var t,n;if(o&&(null==e?void 0:e.isDismissedMoment())){const n=null===(t=e.getDismissedReason)||void 0===t?void 0:t.call(e);return null==o||o(n),void c()}if(i&&(null==e?void 0:e.isSkippedMoment())){const t=null===(n=e.getSkippedReason)||void 0===n?void 0:n.call(e);return null==i||i(t),void c()}}))}))}(e,t.provider,t.oneTapConfig,t.onSkipped,t.onDismissed);if(!o.credential)return null;if(null==t?void 0:t.onCodeReceived){const i=await e.oauth.verifyOneTapIDToken(o.provider,o.credential,o.nonce,null==t?void 0:t.loginOptions);if(!i.ok||!i.data)throw new Error("Failed to verify OneTap client ID for provider "+o.provider);null===(n=null==t?void 0:t.onCodeReceived)||void 0===n||n.call(t,i.data.code)}else{const n=await e.oauth.exchangeOneTapIDToken(o.provider,o.credential,o.nonce,null==t?void 0:t.loginOptions);if(!n.ok||!n.data)throw new Error("Failed to exchange OneTap client ID for provider "+o.provider);null===(i=null==t?void 0:t.onAuthenticated)||void 0===i||i.call(t,n.data)}}var vi=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await ri(),i=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return t[1]=i,e.flow.start(...t)}});let gi;const mi=(e,t)=>new Promise(((n,i)=>{if(!e.length)return i(new Error("No URLs provided to loadScriptWithFallback"));const o=t();if(o)return n(o);const r=e.shift(),s=document.createElement("script");s.src=r,s.id=(e=>{let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t).toString(16)})(r),s.onload=()=>{const e=t();if(e)return n(e);throw new Error("Could not get entry after loading script from URL")},s.addEventListener("error",(()=>{mi(e,t),s.setAttribute("data-error","true")})),document.body.appendChild(s)})),yi=(e,t,n)=>{const i=async()=>{let i,o;return i&&o||({client:i,stateUserKey:o}=await(async(e,t,n)=>{gi||(gi=(async()=>{try{return require("oidc-client-ts")}catch(e){return mi([Jt,Gt],(()=>window.oidc))}})());const{OidcClient:i,WebStorageStateStore:o}=await gi;if(!i)throw new Error("oidc-client-ts is not installed. Please install it by running `npm install oidc-client-ts`");const r=(null==n?void 0:n.redirectUri)||window.location.href;let s,a,d,l;if(null==n?void 0:n.issuer){if(!n.clientId)throw new Error("clientId is required when providing a custom issuer/authority");s=n.issuer,a=n.clientId,d=`${a}_user`,l="openid"}else(null==n?void 0:n.applicationId)?(s=e.httpClient.buildUrl(t),s=`${s}/${n.applicationId}`,a=t,d=`${a}_user`,l="openid email roles descope.custom_claims offline_access"):(s=e.httpClient.buildUrl(t),a=t,d=`${a}_user`,l="openid email roles descope.custom_claims offline_access");const c={authority:s,client_id:a,redirect_uri:r,response_type:"code",scope:(null==n?void 0:n.scope)||l,stateStore:new o({store:window.localStorage,prefix:a}),loadUserInfo:!0,fetchRequestCredentials:"same-origin"};return(null==n?void 0:n.redirectUri)&&(c.redirect_uri=n.redirectUri),{client:new i(c),stateUserKey:d}})(e,t,n)),{client:i,stateUserKey:o}},o=async(t="")=>{var n;const{client:o,stateUserKey:r}=await i(),s=await o.processSigninResponse(t||window.location.href);var a;return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(s)))),dn(r,JSON.stringify({id_token:(a=s).id_token,session_state:a.session_state,profile:a.profile})),(()=>{const e=new URL(window.location.href);e.searchParams.delete("code"),e.searchParams.delete("state"),window.history.replaceState({},document.title,e.toString())})(),s};return{loginWithRedirect:async(t={},n=!1)=>{var o;const{client:r}=await i(),s=await r.createSigninRequest(t),{url:a}=s;return n||(await(null===(o=e.httpClient.hooks)||void 0===o?void 0:o.afterRequest({},new Response(JSON.stringify(s)))),window.location.href=a),{ok:!0,data:s}},finishLogin:o,finishLoginIfNeed:async(e="")=>{if(window.location.search.includes("code")&&window.location.search.includes("state"))return await o(e)},refreshToken:async t=>{var n;const{client:o,stateUserKey:r}=await i(),s=(e=>{const t=ln(e);return t?JSON.parse(t):null})(r);if(!s)throw new Error("User not found in storage to refresh token");let a=t;if(!a){const t={};e.httpClient.hooks.beforeRequest(t),a=t.token}const d=await o.useRefreshToken({state:{refresh_token:a,session_state:s.session_state,profile:s.profile}});return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(d)))),d},logout:async(e,t=!1)=>{const{client:n,stateUserKey:o}=await i();e||(e={}),e.id_token_hint=e.id_token_hint||En(),e.post_logout_redirect_uri=e.post_logout_redirect_uri||window.location.href;const r=await n.createSignoutRequest(e),{url:s}=r;return cn(o),t||window.location.replace(s),r}}},bi=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>t=>{var n;return n=t.customStorage,Yt=n,e(t)}),(e=>t=>{var{fpKey:n,fpLoad:i}=t,o=l(t,["fpKey","fpLoad"]);return Kt?(n&&i&&Tn(n).catch((()=>null)),e(nn(o,{beforeRequest:Wn}))):e(o)}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.55.0"},t.baseHeaders)}))),(e=>t=>{const n=ei(),i=ei(),o=ei(),r=ei(),s=e(nn(t,{afterRequest:async(e,t)=>{if(sn(e,t))pn("Session invalidated, notifying subscribers with empty values"),i.pub(null),o.pub(null),n.pub(null),r.pub(null);else{const e=await(async e=>{const t=await on(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)})(t);e&&o.pub(e);const{sessionJwt:s,sessionExpiration:a,claims:d}=await on(t);s&&i.pub(s),d&&r.pub(d),(a||s)&&n.pub(a||42)}}})),a=pe(s,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const s=await e(...t);return i.pub(null),o.pub(null),n.pub(null),r.pub(null),s}));return Object.assign(a,{onSessionTokenChange:i.sub,onUserChange:o.sub,onClaimsChange:r.sub,onIsAuthenticatedChange:e=>n.sub((t=>{e(!!t)}))})}),(e=>t=>{var n;const{enableFlowNonce:i=!0,nonceStoragePrefix:o=Ln}=t,r=l(t,["enableFlowNonce","nonceStoragePrefix"]);if(!i)return e(r);((e=Ln)=>{try{if(!an)return;for(let o=0;o<(void 0,n=void 0,void 0,null!==(i=null!==(t=null==Yt?void 0:Yt.length)&&void 0!==t?t:Kt&&(null===(n=window.localStorage)||void 0===n?void 0:n.length))&&void 0!==i?i:0);o++){const t=un(o);if(t&&t.startsWith(e)){const n=ln(t);if(n)try{JSON.parse(n).expiry<Date.now()&&cn(t)}catch(e){cn(t)}}}}catch(e){console.error("Error cleaning up expired nonces:",e)}var t,n,i})(o);const s=e(nn(r,{afterRequest:async(e,t)=>{var n;if(e.path!==Dn&&e.path!==Fn)return;const{nonce:i,seq:r,executionId:s}=await(async(e,t)=>{try{const n=t.headers.get(Un),i=null===n?void 0:(e=>{const t=e.indexOf(".");if(t<=0)return;const n=e.slice(0,t);if(!/^\d+$/.test(n))return;const i=Number(n);return Number.isSafeInteger(i)?i:void 0})(n);let o=await t.clone().json().then((e=>(null==e?void 0:e.executionId)||null)).catch((()=>null));return o||(o=Kn(e)),{nonce:n,seq:i,executionId:Vn(o)}}catch(e){return{nonce:null,seq:void 0,executionId:null}}})(e,t);if(!i||!s)return;const a=e.path===Dn,d=null===(n=qn(s,o))||void 0===n?void 0:n.seq;!a&&void 0!==r&&void 0!==d&&r<=d||((e,t,n,i=Ln,o)=>{try{const r=_n(e,i),s=n?172800:10800,a={value:t,expiry:Date.now()+1e3*s,isStart:n,seq:o};dn(r,JSON.stringify(a))}catch(e){console.error("Error setting flow nonce:",e)}})(s,i,a,o,null!=r?r:a?void 0:d)},beforeRequest:e=>{if(e.path===Fn){const t=Kn(e);if(t){const n=((e,t=Ln)=>{var n,i;return null!==(i=null===(n=qn(e,t))||void 0===n?void 0:n.value)&&void 0!==i?i:null})(t,o);n&&(e.headers=e.headers||{},e.headers[Un]=n)}}return e}}));if(null===(n=s.flow)||void 0===n?void 0:n.next){let e=Promise.resolve();const t=s.flow.next.bind(s.flow);s.flow.next=async(...n)=>{const i=e;let o;e=new Promise((e=>{o=e})),await i;try{return await t(...n)}finally{o()}}}return s}),(e=>t=>{const n=e(nn(t,{afterRequest:async(e,t)=>{if(sn(e,t))return void fn(Xn);const n=await on(t);(null==n?void 0:n.sessionExpiration)&&((e,t)=>{var n,i;try{Kt&&(null===(i=null===(n=window.localStorage)||void 0===n?void 0:n.setItem)||void 0===i||i.call(n,e,t))}catch(e){}})(Xn,String(n.sessionExpiration))}}));return pe(n,["logout","logoutAll","oidc.logout"],Qn)}),(e=>t=>{var{autoRefresh:n}=t,i=l(t,["autoRefresh"]);const o=!!n,r="object"==typeof n&&(null==n?void 0:n.customActivityTracking);if(!o||rn())return Object.assign(e(i),{markUserActive:()=>{vn("markUserActive() called but has no effect")}});const{clearAllTimers:s,setTimer:a}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let d,c,u=null,h=!1,f=!1;r&&(pn("Activity-based refresh enabled"),u=(()=>{let e=!0;return{hadActivity:()=>e,reset:()=>{e=!1},markActive:()=>{e=!0}}})()),Kt&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&d&&new Date>d&&(pn("Expiration time passed, refreshing session"),g())}));const p=e(nn(i,{afterRequest:async(e,t)=>{const{sessionJwt:n,refreshJwt:i,sessionExpiration:o,nextRefreshSeconds:r}=await on(t);if(sn(e,t))pn("Session invalidated, canceling all timers"),s(),d=void 0;else if(n||o){if(d=((e,t)=>{if(t)return new Date(1e3*t);pn("Could not extract expiration time from session token, trying to decode the token");try{const t=v(e);if(t.exp)return new Date(1e3*t.exp)}catch(e){return null}})(n,o),!d)return void pn("Could not extract expiration time from session token");c=i,h=r>0;let e=((e,t)=>{let n;return t>0?(n=1e3*t,pn(`Using provided nextRefreshSeconds: ${t}s`)):n=gn(e)-zt,n>Ht&&(pn(`Timeout is too large (${n}ms), setting it to ${Ht}ms`),n=Ht),n})(d,r);s(),e<=zt&&(e=Math.max(gn(d),zt));const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});pn(`Setting refresh timer for ${t}. (${e}ms)`),u&&(u.reset(),f=!1),a((()=>{if(Kt&&"hidden"===document.visibilityState)pn("Skipping refresh due to timer - document is hidden");else{if(u&&h&&!u.hadActivity())return pn("Skipping refresh due to timer - user is idle"),void(f=!0);pn("Refreshing session due to timer"),g()}}),e)}}})),g=()=>p.refresh(In()||c).catch((e=>{vn("Automatic session refresh failed",e)}));return Object.assign(pe(p,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const n=await e(...t);return pn("Clearing all timers"),s(),n})),{markUserActive:u?()=>{pn("markUserActive() called"),h||pn("markUserActive() called but server does not have inactivity timeout configured (no nextRefreshSeconds)"),u.markActive(),f&&(pn("User became active after skipped refresh, triggering refresh"),f=!1,s(),g())}:()=>{vn("markUserActive() called but customActivityTracking is not enabled — this call has no effect")}})}),(e=>t=>{var{storeLastAuthenticatedUser:n=!0,keepLastAuthenticatedUserAfterLogout:i=!1}=t,o=l(t,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!n)return Object.assign(e(o),{getLastUserLoginId:Gn,getLastUserDisplayName:Zn});const r=e(nn(o,{afterRequest:async(e,t)=>{var n;const{userInfo:i,lastAuth:o}=await(async e=>{if(!(null==e?void 0:e.ok))return{userInfo:void 0,lastAuth:void 0};const t=await(null==e?void 0:e.clone().json()),n=tn((null==t?void 0:t.authInfo)||t||{});return{userInfo:(null==n?void 0:n.user)||((null==n?void 0:n.hasOwnProperty("userId"))?n:void 0),lastAuth:t.lastAuth}})(t),r=null===(n=null==i?void 0:i.loginIds)||void 0===n?void 0:n[0],s=null==i?void 0:i.name;r?(Jn(r),(e=>{dn(zn,e)})(s)):(null==o?void 0:o.loginId)&&Jn(o.loginId)}}));let s=pe(r,["flow.start"],Yn);return s=pe(s,["logout","logoutAll"],(e=>t=>async(...n)=>{const i=await t(...n);return e||(cn(Hn),cn(zn)),i})(i)),Object.assign(s,{getLastUserLoginId:Gn,getLastUserDisplayName:Zn})}),(e=>t=>{var{persistTokens:n,sessionTokenViaCookie:i,refreshTokenViaCookie:o,storagePrefix:r,refreshCookieName:s}=t,a=l(t,["persistTokens","sessionTokenViaCookie","refreshTokenViaCookie","storagePrefix","refreshCookieName"]);if(!n||!Kt)return e(Object.assign({refreshCookieName:s},a));let d;const c=e(nn(Object.assign({refreshCookieName:s},a),{beforeRequest:On(r,o,s),afterRequest:async(e,t)=>{if(sn(e,t))pn("Session invalidated, clearing persisted tokens"),xn(r,i,o,d);else{const e=await on(t);e.cookieName?dn(`${r||""}${wn}`,e.cookieName):e.refreshJwt&&cn(`${r||""}${wn}`);const n=((e={},t=!1,n="",i=!1)=>{var o,r,s,a;const{sessionJwt:d,refreshJwt:l,trustedDeviceJwt:c,knownDeviceJwt:u}=e;let h;if(l)if(i){cn(`${n}${yn}`);const t=i.sameSite||"Strict",s=null===(o=i.secure)||void 0===o||o,a=null!==(r=i.domain)&&void 0!==r?r:e.cookieDomain,d=Sn(i);s&&"https:"!==window.location.protocol&&vn("Refresh token cookie is configured with secure=true but the page is not using HTTPS. The cookie will not be set. To fix this, pass refreshTokenViaCookie: { secure: process.env['NODE_ENV'] !== 'development' }");const c=Object.assign(Object.assign({},e),{cookieSameSite:t,cookieSecure:s,cookieDomain:a});$n(d,l,c);const u=kn(a);h=Object.assign(Object.assign({},h),{refresh:{path:c.cookiePath,domain:u?a:void 0}})}else{const e=Sn(i);jt.remove(e),dn(`${n}${yn}`,l)}if(d)if(t){const n=t.sameSite||"Strict",i=null===(s=t.secure)||void 0===s||s,o=null!==(a=t.domain)&&void 0!==a?a:e.cookieDomain,r=Cn(t);i&&"https:"!==window.location.protocol&&vn("Session token cookie is configured with secure=true but the page is not using HTTPS. The cookie will not be set. To fix this, pass sessionTokenViaCookie: { secure: process.env['NODE_ENV'] !== 'development' }");const l=Object.assign(Object.assign({},e),{cookieSameSite:n,cookieSecure:i,cookieDomain:o});$n(r,d,l);const c=kn(o);h=Object.assign(Object.assign({},h),{session:{path:l.cookiePath,domain:c?o:void 0}})}else dn(`${n}${mn}`,d);return e.idToken&&dn(`${n}${bn}`,e.idToken),c&&dn(`${n}DTD`,c),u&&dn(`${n}DKD`,u),h})(e,i,r,o);n&&(d=n)}}})),u=pe(c,["logout","logoutAll","oidc.logout"],((e,t,n,i)=>o=>async(...r)=>{const s=await o(...r);return xn(e,t,n,null==i?void 0:i()),s})(r,i,o,(()=>d)));return Object.assign(u,{getRefreshToken:()=>In(r,o),getSessionToken:()=>Rn(r,i),getIdToken:()=>En(r)})}))((e=>{const t=At(e),n=yi(t,e.projectId,e.oidcConfig);return Object.assign(Object.assign({},t),{refresh:async(i,o)=>{var r;if(rn())return pn(`Refresh called in native flow: ${(new Error).stack}`),Promise.resolve({ok:!1,error:{errorCode:"J171000",errorDescription:"Refresh is not supported in native flows via the web SDK"}});if(e.oidcConfig)try{return await n.refreshToken(i),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161001",errorDescription:e.toString()}})}if(o&&Kt&&void 0!==window.localStorage&&!hn(Xn)&&!ln(Hn)&&!hn("DSLI_DISABLED"))return Promise.resolve({ok:!0});const s=Rn(),a=In();let d="";if(e.getExternalToken)try{d=await(null===(r=e.getExternalToken)||void 0===r?void 0:r.call(e))}catch(e){pn("Error getting external token while refreshing",e)}return t.refresh(i,{dcs:s?"t":"f",dcr:a?"t":"f"},d,o)},logout:async(i,o)=>{if(e.oidcConfig)try{return await n.logout({id_token_hint:i}),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161000",errorDescription:e.toString()}})}return t.logout(i,o)},flow:vi(t),webauthn:ui(t),fedcm:(i=t,o=e.projectId,{onetap:{requestExchangeCode(e){fi(i,e)},requestAuthentication(e){fi(i,e)}},async oneTap(e,t,n,o,r){await pi(i,{provider:e,oneTapConfig:t,loginOptions:n,onSkipped:o,onDismissed:r})},async launch(e){var t;const n={identity:{context:e||"signin",providers:[{configURL:i.httpClient.buildUrl(o+hi),clientId:o}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(n));return i.refresh(r.token)},isSupported:()=>Kt&&"IdentityCredential"in window,async isLoggedIn(e){var t;const n=i.httpClient.buildUrl(o+hi);try{const i={identity:{context:e||"signin",providers:[{configURL:n,clientId:o}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(i));return!!r&&!!r.token}catch(e){return!1}}}),oidc:n});var i,o}));let wi;const $i=e=>{const t=bi(Object.assign({persistTokens:a,autoRefresh:a},e));return wi=t,t},ki=()=>$i({projectId:"temp pid",persistTokens:!1,autoRefresh:!1,storeLastAuthenticatedUser:!1});wi=ki();const Ci=()=>a?null==wi?void 0:wi.getSessionToken():(console.warn("Get session token is not supported in SSR"),""),Si=()=>a?null==wi?void 0:wi.getRefreshToken():(console.warn("Get refresh token is not supported in SSR"),""),Ii=o(((e=Ci(),t)=>null==wi?void 0:wi.getJwtPermissions(e,t))),Ri=o(((e=Ci(),t)=>null==wi?void 0:wi.getJwtRoles(e,t))),Ei=o(((e=Ci())=>null==wi?void 0:wi.getCurrentTenant(e)));function xi(...e){return t=>e.reduce(((e,t)=>t(e)),t)}const Oi=e=>{const t=document.createElement("template");return t.innerHTML=e,t},Ai=(e,t)=>e.length===t.length&&e.every(((e,n)=>e===t[n])),Ni=e=>{let t,n;return(...i)=>(t&&Ai(t,i)||(t=i,n=e(...i)),n)},ji=e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_.]+/g,"-").toLowerCase(),Mi=e=>(t,...n)=>t.reduce(((t,i,o)=>{var r;return`${t}${i}${(null===(r=null==n?void 0:n[o])||void 0===r?void 0:r[e>1?1:0])||""}`}),""),Pi=(e,t=500)=>{let n;return function(...i){clearTimeout(n),n=setTimeout((()=>e.apply(this,i)),t)}},Ti=(e={})=>{const t=Oi("<descope-wc></descope-wc>");return Object.entries(e).forEach((([e,n])=>{t.content.querySelector("descope-wc").setAttribute(ji(e),(e=>"string"==typeof e?e:"boolean"==typeof e?String(e):(e=>null!==e&&"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype)(e)?JSON.stringify(e):"")(n))})),t},Wi=e=>{const t=Symbol((e=>{const t=e.toString();let n=0;for(let e=0;e<t.length;e++)n=(n<<5)-n+t.charCodeAt(e),n&=n;return n.toString(16)})(e));return n=>{if(n[t])return n;const i=e(n);return i[t]=!0,i}};var Li,Ui,Di,Fi;function _i(e,t){const n=Object.getOwnPropertyNames(e),i=Object.getOwnPropertyNames(t);if(n.length!==i.length)return!1;for(let i=0;i<n.length;i+=1){const o=n[i],r=e[o],s=t[o];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!_i(r,s))return!1}else if(r!==s)return!1}return!0}let qi=class{constructor(e={},{forceUpdate:t=!1}={}){Li.set(this,void 0),Ui.set(this,{}),Di.set(this,0),Fi.set(this,!0),this.update=e=>{const t="function"==typeof e?e(u(this,Li,"f")):e,n=Object.assign(Object.assign({},u(this,Li,"f")),t);if(u(this,Fi,"f")||!_i(u(this,Li,"f"),n)){const e=u(this,Li,"f");h(this,Li,n,"f"),Object.freeze(u(this,Li,"f")),setTimeout((()=>{Object.values(u(this,Ui,"f")).forEach((t=>t(n,e,((e,t)=>n=>e[n]!==t[n])(n,e))))}),0)}},h(this,Li,e,"f"),h(this,Fi,t,"f")}get current(){return Object.assign({},u(this,Li,"f"))}subscribe(e){return h(this,Di,u(this,Di,"f")+1,"f"),u(this,Ui,"f")[u(this,Di,"f")]=e,u(this,Di,"f").toString()}unsubscribe(e){const t=!!u(this,Ui,"f")[e];return t&&delete u(this,Ui,"f")[e],t}unsubscribeAll(){return h(this,Ui,{},"f"),!0}};Li=new WeakMap,Ui=new WeakMap,Di=new WeakMap,Fi=new WeakMap;const Bi=["=","+","-","@","\t","\r"],Vi=e=>{const t=(e=>e.length>0&&Bi.includes(e[0])?`'${e}`:e)(Array.isArray(e)?e.join("; "):String(null!=e?e:""));return t.includes(",")||t.includes('"')||t.includes("\n")||t.includes("\r")?`"${t.replace(/"/g,'""')}"`:t},Ki=e=>String(null!=e?e:"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;");function Hi(e){if(e)return{locale:e.toLowerCase(),fallback:e.toLowerCase()};const t=navigator.language;return t?t.includes("-")?{locale:t.toLowerCase(),fallback:t.split("-")[0].toLowerCase()}:{locale:t.toLowerCase(),fallback:t.toLowerCase()}:{locale:"",fallback:""}}const zi=e=>"string"==typeof e||null==e?e:JSON.stringify(e),Ji=e=>t.forwardRef(((n,i)=>{const{prop:o,attr:r,rest:s}=t.useMemo((()=>Object.entries(n).reduce(((e,[t,n])=>{const{trimmedKey:i,category:o}=(e=>{const[,t,n]=/(.*)\.(prop|attr)$/.exec(e)||[,e,"rest"];return{trimmedKey:t,category:n}})(t);return"prop"===o?e.prop.push([i,n]):"attr"===o?e.attr.push([ji(i),zi(n)]):Object.assign(e.rest,{[ji(i)]:n}),e}),{attr:[],prop:[],rest:{}})),[n]),a=t.useRef(null),d=t.useCallback((e=>{a.current=e,e&&(o.forEach((([e,t])=>{a.current[e]=t})),r.forEach((([t,n])=>{null==n?e.removeAttribute(t):e.setAttribute(t,n)})))}),[o,r,a]);return t.useImperativeHandle(i,(()=>a.current)),t.createElement(e,Object.assign({ref:d},s))})),Gi=t.lazy((async()=>{var e;return((null===(e=globalThis.customElements)||void 0===e?void 0:e.get("descope-wc"))||await Promise.resolve().then((function(){return Ph})).then((e=>e.default))).sdkConfigOverrides={baseHeaders:s,persistTokens:!1,hooks:{get beforeRequest(){return wi.httpClient.hooks.beforeRequest},set beforeRequest(e){}}},{default:Ji(t.forwardRef(((e,n)=>{var{"external-request-id":i}=e,o=l(e,["external-request-id"]);return t.useMemo((()=>{var e,t;e="x-external-rid",(t=i)?s[e]=t:delete s[e]}),[i]),t.createElement("descope-wc",Object.assign({ref:n},o))})))}})),Zi=t.forwardRef((({flowId:e,onSuccess:i,onError:o,onReady:r,logger:s,tenant:a,theme:d,nonce:l,locale:c,debug:u,client:h,form:f,telemetryKey:p,redirectUrl:v,autoFocus:g,validateOnBlur:m,restartOnError:y,sendSessionToken:b,errorTransformer:w,styleId:$,onScreenUpdate:k,dismissScreenErrorOnInput:C,outboundAppId:S,outboundAppScopes:I,popupOrigin:R,children:E,externalRequestId:x,themeOverride:O},A)=>{const[N,j]=t.useState(null);t.useImperativeHandle(A,(()=>N));const{projectId:M,baseUrl:P,baseStaticUrl:T,baseCdnUrl:W,storeLastAuthenticatedUser:L,keepLastAuthenticatedUserAfterLogout:U,refreshCookieName:D,customStorage:F,sdk:_}=t.useContext(n),q=t.useCallback((async e=>{await _.httpClient.hooks.afterRequest({},new Response(JSON.stringify(e.detail))),i&&i(e)}),[i]);return t.useEffect((()=>{const e=N;return null==e||e.addEventListener("success",q),o&&(null==e||e.addEventListener("error",o)),r&&(null==e||e.addEventListener("ready",r)),()=>{o&&(null==e||e.removeEventListener("error",o)),r&&(null==e||e.removeEventListener("ready",r)),null==e||e.removeEventListener("success",q)}}),[N,o,q]),t.useEffect((()=>{const e=N;return null==e||e.addEventListener("success",q),()=>{null==e||e.removeEventListener("success",q)}}),[N,q]),t.useEffect((()=>{const e=N;return o&&(null==e||e.addEventListener("error",o)),()=>{o&&(null==e||e.removeEventListener("error",o))}}),[N,o]),t.useEffect((()=>{const e=N;return r&&(null==e||e.addEventListener("ready",r)),()=>{r&&(null==e||e.removeEventListener("error",r))}}),[N,r]),t.createElement("form",null,t.createElement(t.Suspense,{fallback:null},t.createElement(Gi,{projectId:M,flowId:e,baseUrl:P,baseStaticUrl:T,baseCdnUrl:W,ref:j,telemetryKey:p,redirectUrl:v,autoFocus:g,styleId:$,validateOnBlur:m,restartOnError:y,keepLastAuthenticatedUserAfterLogout:U,tenant:a,externalRequestId:x,customStorage:F,themeOverride:O,"theme.attr":d,"nonce.attr":l,"locale.attr":c,"form.attr":f,"client.attr":h,"debug.attr":u,"outbound-app-id.attr":S,"outbound-app-scopes.attr":I,"popup-origin.attr":R,"store-last-authenticated-user.attr":L,"send-session-token.attr":b,"refreshCookieName.attr":D,"dismiss-screen-error-on-input.attr":C,"errorTransformer.prop":w,"logger.prop":s,"onScreenUpdate.prop":k,"customStorage.prop":F},E)))}));var Yi=()=>{const e=t.useContext(n);if(!e)throw Error("You can only use this hook in the context of <AuthProvider />");return e};const Xi=e=>`You can only use this ${e} after sdk initialization. Make sure to supply 'projectId' to <AuthProvider /> component`,Qi={get(e,t){if("object"==typeof e[t]&&null!==e[t])return new Proxy(e[t],Qi);if("function"==typeof e[t])return()=>{throw Error(Xi("function"))};throw Error(Xi("attribute"))}},eo=t.lazy((async()=>(await Promise.resolve().then((function(){return Zf})),{default:Ji(t.forwardRef(((e,n)=>t.createElement("descope-access-key-management-widget",Object.assign({ref:n},e)))))}))),to=t.forwardRef((({logger:e,tenant:i,theme:o,locale:r,debug:s,widgetId:a,styleId:d,onReady:l},c)=>{const[u,h]=t.useState(null);t.useImperativeHandle(c,(()=>u));const{projectId:f,baseUrl:p,baseStaticUrl:v,baseCdnUrl:g,refreshCookieName:m}=t.useContext(n);return t.useEffect((()=>{const e=u;return l&&(null==e||e.addEventListener("ready",l)),()=>{l&&(null==e||e.removeEventListener("ready",l))}}),[u,l]),t.createElement(t.Suspense,{fallback:null},t.createElement(eo,{ref:h,projectId:f,widgetId:a,tenant:i,baseUrl:p,baseStaticUrl:v,baseCdnUrl:g,"theme.attr":o,"locale.attr":r,"debug.attr":s,"styleId.attr":d,"refreshCookieName.attr":m,"logger.prop":e}))})),no=t.lazy((async()=>(await Promise.resolve().then((function(){return mp})),{default:Ji(t.forwardRef(((e,n)=>t.createElement("descope-applications-portal-widget",Object.assign({ref:n},e)))))}))),io=t.forwardRef((({logger:e,theme:i,locale:o,debug:r,widgetId:s,styleId:a,onReady:d},l)=>{const[c,u]=t.useState(null);t.useImperativeHandle(l,(()=>c));const{projectId:h,baseUrl:f,baseStaticUrl:p,baseCdnUrl:v,refreshCookieName:g}=t.useContext(n);return t.useEffect((()=>{const e=c;return d&&(null==e||e.addEventListener("ready",d)),()=>{d&&(null==e||e.removeEventListener("ready",d))}}),[c,d]),t.createElement(t.Suspense,{fallback:null},t.createElement(no,{ref:u,projectId:h,widgetId:s,baseUrl:f,baseStaticUrl:p,baseCdnUrl:v,"theme.attr":i,"locale.attr":o,"debug.attr":r,"styleId.attr":a,"refreshCookieName.attr":g,"logger.prop":e}))})),oo=t.lazy((async()=>(await Promise.resolve().then((function(){return Up})),{default:Ji(t.forwardRef(((e,n)=>t.createElement("descope-audit-management-widget",Object.assign({ref:n},e)))))}))),ro=t.forwardRef((({logger:e,tenant:i,theme:o,locale:r,debug:s,widgetId:a,styleId:d,onReady:l},c)=>{const[u,h]=t.useState(null);t.useImperativeHandle(c,(()=>u));const{projectId:f,baseUrl:p,baseStaticUrl:v,baseCdnUrl:g,refreshCookieName:m}=t.useContext(n);return t.useEffect((()=>{const e=u;return l&&(null==e||e.addEventListener("ready",l)),()=>{l&&(null==e||e.removeEventListener("ready",l))}}),[u,l]),t.createElement(t.Suspense,{fallback:null},t.createElement(oo,{ref:h,projectId:f,widgetId:a,tenant:i,baseUrl:p,baseStaticUrl:v,baseCdnUrl:g,"theme.attr":o,"locale.attr":r,"debug.attr":s,"styleId.attr":d,"refreshCookieName.attr":m,"logger.prop":e}))})),so=t.lazy((async()=>(await Promise.resolve().then((function(){return pv})),{default:Ji(t.forwardRef(((e,n)=>t.createElement("descope-outbound-applications-widget",Object.assign({ref:n},e)))))}))),ao=t.forwardRef((({logger:e,tenant:i,theme:o,locale:r,debug:s,widgetId:a,styleId:d,onReady:l,client:c,form:u},h)=>{const[f,p]=t.useState(null);t.useImperativeHandle(h,(()=>f));const{projectId:v,baseUrl:g,baseStaticUrl:m,baseCdnUrl:y,refreshCookieName:b}=t.useContext(n);return t.useEffect((()=>{const e=f;return l&&(null==e||e.addEventListener("ready",l)),()=>{l&&(null==e||e.removeEventListener("ready",l))}}),[f,l]),t.createElement(t.Suspense,{fallback:null},t.createElement(so,{ref:p,projectId:v,widgetId:a,baseUrl:g,baseStaticUrl:m,baseCdnUrl:y,"tenant.attr":i,"theme.attr":o,"locale.attr":r,"debug.attr":s,"styleId.attr":d,"refreshCookieName.attr":b,"client.attr":c,"form.attr":u,"logger.prop":e}))})),lo=t.lazy((async()=>(await Promise.resolve().then((function(){return vg})),{default:Ji(t.forwardRef(((e,n)=>t.createElement("descope-role-management-widget",Object.assign({ref:n},e)))))}))),co=t.forwardRef((({logger:e,tenant:i,theme:o,locale:r,debug:s,widgetId:a,styleId:d,onReady:l},c)=>{const[u,h]=t.useState(null);t.useImperativeHandle(c,(()=>u));const{projectId:f,baseUrl:p,baseStaticUrl:v,baseCdnUrl:g,refreshCookieName:m}=t.useContext(n);return t.useEffect((()=>{const e=u;return l&&(null==e||e.addEventListener("ready",l)),()=>{l&&(null==e||e.removeEventListener("ready",l))}}),[u,l]),t.createElement(t.Suspense,{fallback:null},t.createElement(lo,{ref:h,projectId:f,widgetId:a,tenant:i,baseUrl:p,baseStaticUrl:v,baseCdnUrl:g,"theme.attr":o,"locale.attr":r,"debug.attr":s,"styleId.attr":d,"refreshCookieName.attr":m,"logger.prop":e}))})),uo=t.lazy((async()=>(await Promise.resolve().then((function(){return dm})),{default:Ji(t.forwardRef(((e,n)=>t.createElement("descope-tenant-profile-widget",Object.assign({ref:n},e)))))}))),ho=t.forwardRef((({logger:e,theme:i,locale:o,debug:r,widgetId:s,styleId:a,tenant:d,onReady:l,client:c,form:u},h)=>{const[f,p]=t.useState(null);t.useImperativeHandle(h,(()=>f));const{projectId:v,baseUrl:g,baseStaticUrl:m,baseCdnUrl:y,refreshCookieName:b}=t.useContext(n);return t.useEffect((()=>{const e=f;return l&&(null==e||e.addEventListener("ready",l)),()=>{l&&(null==e||e.removeEventListener("ready",l))}}),[f,l]),t.createElement(t.Suspense,{fallback:null},t.createElement(uo,{projectId:v,widgetId:s,baseUrl:g,baseStaticUrl:m,baseCdnUrl:y,styleId:a,tenant:d,ref:p,"theme.attr":i,"locale.attr":o,"debug.attr":r,"styleId.attr":a,"tenant.attr":d,"refreshCookieName.attr":b,"client.attr":c,"form.attr":u,"logger.prop":e}))})),fo=t.lazy((async()=>(await Promise.resolve().then((function(){return xC})),{default:Ji(t.forwardRef(((e,n)=>t.createElement("descope-user-management-widget",Object.assign({ref:n},e)))))}))),po=t.forwardRef((({logger:e,tenant:i,theme:o,locale:r,debug:s,widgetId:a,styleId:d,onReady:l,client:c,form:u},h)=>{const[f,p]=t.useState(null);t.useImperativeHandle(h,(()=>f));const{projectId:v,baseUrl:g,baseStaticUrl:m,baseCdnUrl:y,refreshCookieName:b}=t.useContext(n);return t.useEffect((()=>{const e=f;return l&&(null==e||e.addEventListener("ready",l)),()=>{l&&(null==e||e.removeEventListener("ready",l))}}),[f,l]),t.createElement(t.Suspense,{fallback:null},t.createElement(fo,{projectId:v,widgetId:a,tenant:i,baseUrl:g,baseStaticUrl:m,baseCdnUrl:y,ref:p,"theme.attr":o,"locale.attr":r,"debug.attr":s,"styleId.attr":d,"refreshCookieName.attr":b,"client.attr":c,"form.attr":u,"logger.prop":e}))})),vo=t.lazy((async()=>(await Promise.resolve().then((function(){return aI})),{default:Ji(t.forwardRef(((e,n)=>t.createElement("descope-user-profile-widget",Object.assign({ref:n},e)))))}))),go=t.forwardRef((({logger:e,theme:i,locale:o,debug:r,widgetId:s,onLogout:a,onFlowPopupUnauthenticated:d,styleId:l,onReady:c,client:u,form:h},f)=>{const[p,v]=t.useState(null);t.useImperativeHandle(f,(()=>p));const{projectId:g,baseUrl:m,baseStaticUrl:y,baseCdnUrl:b,refreshCookieName:w,sessionTokenViaCookie:$,refreshTokenViaCookie:k,setSession:C,setUser:S,setIsAuthenticated:I}=t.useContext(n),R=t.useCallback((e=>{a&&a(e),I(!1),C(""),S(null)}),[a,C,I,S]);return t.useEffect((()=>{if(p)return p.addEventListener("logout",R),()=>p.removeEventListener("logout",R)}),[p,R]),t.useEffect((()=>{const e=p;if(e&&d)return e.addEventListener("flow-popup-unauthenticated",d),()=>e.removeEventListener("flow-popup-unauthenticated",d)}),[p,d]),t.useEffect((()=>{const e=p;return c&&(null==e||e.addEventListener("ready",c)),()=>{c&&(null==e||e.removeEventListener("ready",c))}}),[p,c]),t.createElement(t.Suspense,{fallback:null},t.createElement(vo,{projectId:g,widgetId:s,baseUrl:m,baseStaticUrl:y,baseCdnUrl:b,styleId:l,ref:v,"theme.attr":i,"locale.attr":o,"debug.attr":r,"styleId.attr":l,"refreshCookieName.attr":w,"sessionTokenViaCookie.attr":$,"refreshTokenViaCookie.attr":k,"client.attr":u,"form.attr":h,"logger.prop":e}))})),mo="undefined"!=typeof localStorage,yo="J151000",bo="E103205",wo="E108201",$o=mo&&localStorage.getItem("base.content.url")||"",ko="base.ui.components.url";mo&&localStorage.getItem(ko),mo&&localStorage.getItem(ko);const Co="descope-login-flow",So="code",Io="redirect_mode",Ro="err",Eo="data-exclude-field",xo="data-exclude-next",Oo="dls_last_auth",Ao="dls_last_submitted_login_id",No="dls_sso_run_",jo="state_id",Mo="saml_idp_state_id",Po="wsfed_idp_state_id",To="saml_idp_username",Wo="descope_idp_initiated",Lo="sso_app_id",Uo="custom_app_id",Do="third_party_app_id",Fo="third_party_app_state_id",_o="oidc_login_hint",qo="oidc_prompt",Bo="oidc_resource",Vo="oidc_error_redirect_uri",Ko="application_scopes",Ho="data-type",zo="redirect",Jo="poll",Go="webauthnCreate",Zo="webauthnGet",Yo="nativeBridge",Xo="loadForm",Qo="submit",er="polling",tr=["descope-multi-select-combo-box","descope-text-area"],nr="dls_last_auth_in_flight",ir=["cssVars","componentsConfig","inputs","errorText","errorType","clientScripts","data","totp","notp","sentTo","sso","selfProvisionDomains"],or=["hide","disable","read-only"],rr="hidden";function sr(e,t){const n=e.closest(`.${rr}`);return!!n&&n!==t}const ar=/(["\\])/g;function dr(e){return"undefined"!=typeof CSS&&"function"==typeof CSS.escape?CSS.escape(e):e.replace(ar,"\\$1")}function lr(e,t){return Array.from(e.querySelectorAll(`[id="${dr(t)}"]`))}function cr(e,t,n){return Object.keys(t).forEach((i=>{const o=t[i];n[i]!==o&&lr(e,i).forEach((e=>function(e,t){switch(t){case"hide":e.classList.remove(rr);break;case"disable":e.removeAttribute("disabled");break;case"read-only":e.removeAttribute("readonly")}}(e,o)))})),Object.keys(n).forEach((i=>{const o=n[i],r=t[i];o!==r&&lr(e,i).forEach((e=>function(e,t){switch(t){case"hide":e.classList.add(rr);break;case"disable":e.setAttribute("disabled","true");break;case"read-only":e.setAttribute("readonly","true")}}(e,o)))})),Object.assign({},n)}var ur;!function(e){e.backward="backward",e.forward="forward"}(ur||(ur={}));const hr=new Set,fr=(e,t)=>({origin:window.location.origin,pathname:window.location.pathname,hash:window.location.hash,projectId:e,flowId:t}),pr=(e,t)=>`dls_sso_query_params_${e}_${t}`,vr=e=>Object.values(null!=e?e:{}).some(Boolean),gr=Object.keys({oidcIdpStateId:!0,samlIdpStateId:!0,wsfedIdpStateId:!0,samlIdpUsername:!0,descopeIdpInitiated:!0,ssoAppId:!0,customAppId:!0,oidcLoginHint:!0,oidcPrompt:!0,oidcErrorRedirectUri:!0,oidcResource:!0,thirdPartyAppId:!0,thirdPartyAppStateId:!0,applicationScopes:!0}),mr=e=>gr.reduce(((t,n)=>(null==e?void 0:e[n])?Object.assign(t,{[n]:e[n]}):t),{}),yr=e=>{var t,n;const i=(null===(t=null==e?void 0:e.params)||void 0===t?void 0:t.oidcIdpStateId)&&(null===(n=null==e?void 0:e.params)||void 0===n?void 0:n.oidcErrorRedirectUri)?864e5:6e5;return Date.now()-e.ts<i},br=()=>{var e,t,n;try{const[i]=null!==(n=null===(t=null===(e=window.performance)||void 0===e?void 0:e.getEntriesByType)||void 0===t?void 0:t.call(e,"navigation"))&&void 0!==n?n:[],o=i;if("reload"!==(null==o?void 0:o.type)||!o.name)return!1;const r=new URL(o.name,window.location.href);return r.origin===window.location.origin&&r.pathname===window.location.pathname&&r.hash===window.location.hash}catch(e){return!1}},wr=(e,t)=>(null==e?void 0:e.origin)===t.origin&&(null==e?void 0:e.pathname)===t.pathname&&(null==e?void 0:e.hash)===t.hash&&(null==e?void 0:e.projectId)===t.projectId&&(null==e?void 0:e.flowId)===t.flowId,$r=(e,t,n,i=Date.now())=>{var o;if(vr(e))try{const r={params:e,scope:fr(t,n),ts:i};null===(o=window.sessionStorage)||void 0===o||o.setItem(pr(t,n),JSON.stringify(r))}catch(e){}},kr=(e,t)=>{var n;try{const i=null===(n=window.sessionStorage)||void 0===n?void 0:n.getItem(pr(e,t));if(!i)return;const o=JSON.parse(i);return wr(null==o?void 0:o.scope,fr(e,t))?o.ts:void 0}catch(e){return}},Cr=e=>`${No}${e}`,Sr=()=>{var e;return null!==(e=window.localStorage)&&void 0!==e?e:null},Ir=()=>{try{const e=Sr();if(!e)return;const t=[];for(let n=0;n<e.length;n+=1){const i=e.key(n);(null==i?void 0:i.startsWith(No))&&t.push(i)}t.forEach((t=>{let n=!0;try{n=!yr(JSON.parse(e.getItem(t)))}catch(t){}n&&e.removeItem(t)}))}catch(e){}},Rr=(e,t)=>{var n,i;try{const o=null===(n=window.sessionStorage)||void 0===n?void 0:n.getItem(pr(e,t));if(!o)return;const r=JSON.parse(o);wr(null==r?void 0:r.scope,fr(e,t))&&(null===(i=window.sessionStorage)||void 0===i||i.removeItem(pr(e,t)))}catch(e){}},Er=(e,t)=>Rr(e,t),xr=["descope-enriched-text"];function Or(e){return new URLSearchParams(window.location.search).get(e)}function Ar(e){if(window.history.replaceState&&Or(e)){const t=new URL(window.location.href),n=new URLSearchParams(t.search);n.delete(e),t.search=n.toString(),window.history.replaceState({},"",t.toString())}}const Nr=e=>{var t;return(null===(t=/.*\|#\|(.*)/.exec(e))||void 0===t?void 0:t[1])||""};function jr(e,t){if(!t)return;const n=+e,i=+t;return Number.isNaN(n)||Number.isNaN(i)?void 0:n>i?ur.forward:n<i?ur.backward:void 0}const Mr=e=>{let[t="",n=""]=(Or(Co)||"").split("_");const i=(e=>{var t;return(null===(t=/(.*)\|#\|.*/.exec(e))||void 0===t?void 0:t[1])||""})(t);return(!e||i&&i!==e)&&(t="",n=""),{executionId:t,stepId:n,executionFlowId:i}};function Pr(){Ar(Co)}function Tr(e){try{const{origin:t}=new URL(e);return"null"===t?void 0:t}catch(e){return}}const Wr=e=>e.replace(/-./g,(e=>e[1].toUpperCase())),Lr=(e,t,n)=>{const{executionId:i,stepId:o,executionFlowId:r}=Mr(e);if(r&&e!==r)return n.debug("Flow id does not match the execution flow id, skipping url params handling"),{ssoQueryParams:{}};(i||o)&&Pr();const s=Or("t")||void 0;s&&Ar("t");const a=Or(So)||void 0;a&&Ar(So);const d="popup"===Or(Io);d&&Ar(Io);const l=Or(Ro)||void 0;l&&Ar(Ro);const{redirectAuthCodeChallenge:c,redirectAuthCallbackUrl:u,redirectAuthBackupCallbackUri:h,redirectAuthInitiator:f}={redirectAuthCodeChallenge:Or("ra-challenge"),redirectAuthCallbackUrl:Or("ra-callback"),redirectAuthBackupCallbackUri:Or("ra-backup-callback"),redirectAuthInitiator:Or("ra-initiator")},p=Or(jo);p&&Ar(jo);const v=Or(Mo);v&&Ar(Mo);const g=Or(Po);g&&Ar(Po);const m=Or(To);v&&Ar(To);const y=Or(Wo);y&&Ar(Wo);const b=Or(Lo);b&&Ar(Lo);const w=Or(Uo);w&&Ar(Uo);const $=Or(Do);$&&Ar(Do);const k=Or(Fo);k&&Ar(Fo);const C=Or(Ko);C&&Ar(Ko);const S=Or(_o);S&&Ar(_o);const I=Or(qo);I&&Ar(qo);const R=Or(Vo);R&&Ar(Vo);const E=Or(Bo);E&&Ar(Bo);const x={oidcIdpStateId:p,samlIdpStateId:v,wsfedIdpStateId:g,samlIdpUsername:m,descopeIdpInitiated:"true"===y,ssoAppId:b,customAppId:w,oidcLoginHint:S,oidcPrompt:I,oidcErrorRedirectUri:R,oidcResource:E,thirdPartyAppId:$,thirdPartyAppStateId:k,applicationScopes:C},O=((e,t)=>{const n=[(i=fr(e,t)).origin,i.pathname,i.hash,i.projectId,i.flowId].join("|");var i;return!hr.has(n)&&(hr.add(n),!0)})(t,e);let A=x,N=null;if(Ir(),vr(x))$r(x,t,e);else if(i)N=((e,t,n)=>{var i;if(!e)return null;try{const o=null===(i=Sr())||void 0===i?void 0:i.getItem(Cr(e));if(!o)return null;const r=JSON.parse(o),s=mr(null==r?void 0:r.params);return(null==r?void 0:r.projectId)===t&&vr(s)&&yr(r)?($r(s,t,n,r.ts),s):null}catch(e){return null}})(Nr(i),t,e);else if(!r){const i=O?((e,t)=>{var n;if(!br())return null;try{const i=null===(n=window.sessionStorage)||void 0===n?void 0:n.getItem(pr(e,t));if(!i)return null;const o=JSON.parse(i);return wr(null==o?void 0:o.scope,fr(e,t))&&yr(o)?o.params:null}catch(e){return null}})(t,e):null;i?(n.debug("Restored SSO query params after a page reload"),A=i):((e,t)=>{br()||Rr(e,t)})(t,e)}return{executionId:i,stepId:o,token:s,code:a,isPopup:d,exchangeError:l,redirectAuthCodeChallenge:c,redirectAuthCallbackUrl:u,redirectAuthBackupCallbackUri:h,redirectAuthInitiator:f,ssoQueryParams:A,adoptedSsoQueryParams:N}},Ur=e=>{let t,n;return Object.assign(((...i)=>{return t&&(r=i,(o=t).length===r.length&&o.every(((e,t)=>e===r[t])))||(t=i,n=e(...i)),n;var o,r}),{reset:()=>{t=void 0,n=void 0}})},Dr=(e,t,n)=>{if(!0===t||"skipFirstScreen"===t&&!n){const t=Array.from(e.querySelectorAll('*[name]:not([auto-focus="false"]):not([aria-hidden="true"])')).find((t=>!sr(t,e)));setTimeout((()=>{null==t||t.focus()}))}};function Fr(e,t,n){return new Promise(((i,o)=>{let r=!1;const s=setTimeout((()=>{r=!0,void 0!==n?i(n):o(new Error(`Promise timed out after ${e} ms`))}),e);t.then((e=>{r||(clearTimeout(s),i(e))})).catch((e=>{r||(clearTimeout(s),o(e))}))}))}const _r=(e,{oidcIdpStateId:t,samlIdpStateId:n,wsfedIdpStateId:i,samlIdpUsername:o,ssoAppId:r,customAppId:s,oidcLoginHint:a,oidcPrompt:d,oidcErrorRedirectUri:l,oidcResource:c,thirdPartyAppId:u,thirdPartyAppStateId:h,applicationScopes:f})=>!(!e||t||n||i||o||r||s||a||d||l||c||u||h||f),qr=(e,t,n)=>{const i=document.createElement("input");return i.type="hidden",i.name=e,i.value=t,n&&i.setAttribute("role",n),i},Br=e=>null==e?void 0:e.submit(),Vr=(e,t)=>{const n=t.find((t=>e[t]));return n?e[n]:null},Kr=(e,t=100)=>{let n;return function(...i){n||e.apply(this,i),clearTimeout(n),n=setTimeout((()=>{n=null}),t)}},Hr={minLength:"data-password-policy-value-minlength",strength:"data-password-policy-value-passwordstrength",disallowedChars:"data-password-policy-value-disallowedchars",email:"data-password-policy-value-email",reuse:"data-password-policy-value-reuse",activePolicies:"active-policies",availablePolicies:"available-policies"},zr=(e,t)=>{var n;const i=null==e?void 0:e.componentsDynamicAttrs;if(!i)return;const o=Object.entries(i).find((([e])=>(e=>{var t;return null===(t=e.match(/\[data-name=["']([^"']+)["']\]/))||void 0===t?void 0:t[1]})(e)===t));return null===(n=null==o?void 0:o[1])||void 0===n?void 0:n.attributes},Jr=[{key:"totp",from:e=>e.totp},{key:"notp",from:e=>e.notp},{key:"sentTo",from:e=>e.sentTo},{key:"sso",from:e=>e.sso},{key:"selfProvisionDomains",from:e=>e.selfProvisionDomains},{key:"inboundAppApproveScopes",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.thirdPartyAppApproveScopes)||void 0===n?void 0:n.data}},{key:"securityQuestionsSetup",from:e=>{var t;return null===(t=e.componentsConfig)||void 0===t?void 0:t.sqSetup}},{key:"securityQuestionsVerify",from:e=>{var t;return null===(t=e.componentsConfig)||void 0===t?void 0:t.sqVerify}},{key:"userTenants",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.userSelectedTenant)||void 0===n?void 0:n.data}},{key:"userRoles",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.userRoles)||void 0===n?void 0:n.data}},{key:"ssoApplications",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.ssoApplications)||void 0===n?void 0:n.data}},{key:"ssoConfigurations",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.ssoConfigurations)||void 0===n?void 0:n.data}},{key:"samlAttributeMappings",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.samlMappings)||void 0===n?void 0:n.options}},{key:"oidcAttributeMappings",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.oidcMappings)||void 0===n?void 0:n.options}},{key:"samlGroupMappings",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.samlGroupMappings)||void 0===n?void 0:n.options}},{key:"passwordPolicy",from:e=>{var t;return(e=>{if(!e)return;const t=Object.fromEntries(Object.entries(Hr).map((([t,n])=>[t,e[n]])).filter((([,e])=>void 0!==e)));return Object.keys(t).length?t:void 0})(null===(t=e.componentsConfig)||void 0===t?void 0:t.newPassword)}},{key:"recoveryCodes",from:e=>(e=>{const t=zr(e,"recoveryCodes");if(t)return Array.isArray(t.data)?t.data.map((e=>e.value)):[]})(e.componentsConfig)},{key:"outboundApp",from:e=>(e=>{const t=zr(e,"outboundApp");if(t)return{label:t.label,iconSrc:t["icon-src"],appId:t["data-descope-outbound-oauth-app-id"]}})(e.componentsConfig)}],Gr=e=>{const t=Object.assign({},e);return e.inboundAppApproveScopes&&(t.thirdPartyAppApproveScopes=e.inboundAppApproveScopes),t};function Zr(e,t){return`sdkScriptsResults.${t?`${e}_${t}`:e}`}var Yr,Xr,Qr,es;function ts(e,t){const n=Object.getOwnPropertyNames(e),i=Object.getOwnPropertyNames(t);if(n.length!==i.length)return!1;for(let i=0;i<n.length;i+=1){const o=n[i],r=e[o],s=t[o];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!ts(r,s))return!1}else if(r!==s)return!1}return!0}let ns=class{constructor(e={},{forceUpdate:t=!1}={}){Yr.set(this,void 0),Xr.set(this,{}),Qr.set(this,0),es.set(this,!0),this.update=e=>{const t="function"==typeof e?e(u(this,Yr,"f")):e,n=Object.assign(Object.assign({},u(this,Yr,"f")),t),i=u(this,Yr,"f");h(this,Yr,n,"f"),Object.freeze(u(this,Yr,"f")),setTimeout((()=>{Object.values(u(this,Xr,"f")).forEach((({cb:e,selector:t,forceUpdate:o})=>{const r=t(i),s=t(n);(u(this,es,"f")||o||(function(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}(s)?!ts(r,s):r!==s))&&e(s,r,((e,t)=>n=>e[n]!==t[n])(s,r))}))}),0)},h(this,Yr,e,"f"),h(this,es,t,"f")}get current(){return Object.assign({},u(this,Yr,"f"))}set forceUpdate(e){h(this,es,e,"f")}subscribe(e,t=e=>e,{forceUpdate:n=!1}={}){return h(this,Qr,u(this,Qr,"f")+1,"f"),u(this,Xr,"f")[u(this,Qr,"f")]={cb:e,selector:t,forceUpdate:n},u(this,Qr,"f").toString()}unsubscribe(e){const t=!!u(this,Xr,"f")[e];return t&&delete u(this,Xr,"f")[e],t}unsubscribeAll(){return h(this,Xr,{},"f"),!0}};Yr=new WeakMap,Xr=new WeakMap,Qr=new WeakMap,es=new WeakMap;const is=/[\\*#/()[\]_<>`]/g,os=["disabled"],rs=(e,t)=>{Object.entries(t||{}).forEach((([t,n])=>{Array.from(e.querySelectorAll(`*[name="${t}"]:not([${Eo}])`)).forEach((e=>{e.value=n}))}))},ss=(e,t)=>t.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),e),as=(e,t,n)=>e.replace(/{{(.+?)}}/g,((e,i)=>n?(e=>"string"!=typeof e?e:e.replace(is,"\\$&"))(String(ss(t,i))):ss(t,i))),ds=(e,t,n)=>{e.querySelectorAll(`[${Ho}="${t}"]`).forEach((e=>{e.setAttribute("href",n)}))},ls=(e,t,n)=>{var i,o;const r=null===(i=customElements.get(t))||void 0===i?void 0:i.cssVarList.url;n&&r&&(null===(o=null==e?void 0:e.style)||void 0===o||o.setProperty(r,`url(data:image/jpg;base64,${n})`))},cs=(e,t,n,i)=>{var o,r;ds(e,"totp-link",null===(o=null==t?void 0:t.totp)||void 0===o?void 0:o.provisionUrl),ds(e,"notp-link",null===(r=null==t?void 0:t.notp)||void 0===r?void 0:r.redirectUrl),((e,t)=>{e.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((e=>{const n=(e=>xr.includes(e))(e.localName);e.textContent=as(e.textContent,t,n);const i=e.getAttribute("href");i&&e.setAttribute("href",as(i,t))}))})(e,t),((e,t,n)=>{if(!t)return;const{componentsDynamicAttrs:i}=t,o=l(t,["componentsDynamicAttrs"]),r=Object.keys(o).reduce(((e,t)=>(e[`[name=${t}]`]=o[t],e)),{});i&&Object.keys(i).forEach((e=>{const t=i[e];if(t){const{attributes:n}=t;n&&Object.keys(n).length&&(r[e]=n)}})),Object.keys(r).forEach((t=>{e.querySelectorAll(t).forEach((e=>{const i=r[t];Object.keys(i).forEach((t=>{let o=i[t];if("string"!=typeof o)try{o=JSON.stringify(o)}catch(e){n.error(`Could not stringify value "${o}" for "${t}"`,e.message),o=""}e.setAttribute(t,o)}))}))}))})(e,null==t?void 0:t.componentsConfig,i),((e,t)=>{e.querySelectorAll("[data-has-dynamic-attr-values]").forEach((e=>{Array.from(e.attributes).forEach((e=>{e.value=as(e.value,t)}))}))})(e,t),((e,t)=>{Object.entries(t).forEach((([t,n])=>{e.querySelectorAll(`[name="${t}"]`).forEach((e=>{Object.entries(n).forEach((([t,n])=>{os.includes(t)&&e.setAttribute(t,n)}))}))}))})(e,n)},us=Ur((()=>c(void 0,void 0,void 0,(function*(){var e,t;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return!1;try{const n=Promise.all([null===(e=window.PublicKeyCredential)||void 0===e?void 0:e.isConditionalMediationAvailable(),null===(t=window.PublicKeyCredential)||void 0===t?void 0:t.isUserVerifyingPlatformAuthenticatorAvailable()]).then((e=>e.every((e=>!!e)))),i=(()=>{var e;const t=null===(e=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===e?void 0:e.brands,n=null==t?void 0:t.find((({brand:e,version:t})=>"Chromium"===e&&parseFloat(t)));return n?n.version:0})()>=108;return yield Fr(100,n,i)}catch(e){return console.error("Conditional login check failed",e),!1}}))));let hs;const fs=(e,t)=>{hs?hs.setItem(e,t):void 0!==(null===window||void 0===window?void 0:window.localStorage)&&window.localStorage.setItem(e,t)},ps=e=>hs?hs.getItem(e):void 0!==(null===window||void 0===window?void 0:window.localStorage)?window.localStorage.getItem(e):null,vs="dls_ab_testing_id",gs={"lastAuth.loginId":{"not-empty":e=>{var t;return!!e.loginId||!!(null===(t=e.lastAuth)||void 0===t?void 0:t.loginId)},empty:e=>{var t;return!e.loginId&&!(null===(t=e.lastAuth)||void 0===t?void 0:t.loginId)}},idpInitiated:{"is-true":e=>!!e.code,"is-false":e=>!e.code},externalToken:{"is-true":e=>!!e.token,"is-false":e=>!e.token},abTestingKey:{"greater-than":(e,t)=>(e.abTestingKey||0)>t,"less-than":(e,t)=>(e.abTestingKey||0)<t,"greater-than-or-equal":(e,t)=>(e.abTestingKey||0)>=t,"less-than-or-equal":(e,t)=>(e.abTestingKey||0)<=t,"in-range":(e,t)=>{const[n,i]=t?t.split(",").map(Number):[void 0,void 0];return(e.abTestingKey||0)>=(null!=n?n:0)&&(e.abTestingKey||0)<=(null!=i?i:0)},"not-in-range":(e,t)=>{const[n,i]=t?t.split(",").map(Number):[void 0,void 0];return!(void 0!==n&&void 0!==i&&!Number.isNaN(n)&&!Number.isNaN(i))||(e.abTestingKey||0)<n||(e.abTestingKey||0)>i},"devised-by":(e,t)=>{const n=Number(t);return!Number.isNaN(n)&&(e.abTestingKey||0)%n==0}}};function ms(e,t){const n={};try{Object.assign(n,JSON.parse(ps(Oo)))}catch(e){null==t||t.warn("[Descope] Failed to read last auth from storage",String(e))}return n.loginId||e?n:{}}function ys(e,t){(null==e?void 0:e.authMethod)&&(t&&!e.loginId||fs(Oo,JSON.stringify(e)))}function bs(){try{return JSON.parse(ps(nr)||"{}")}catch(e){return{}}}function ws(e){try{(e=>{hs?hs.removeItem(e):void 0!==(null===window||void 0===window?void 0:window.localStorage)&&window.localStorage.removeItem(e)})(nr)}catch(t){null==e||e.warn("[Descope] Failed to clear in-flight last auth storage",String(t))}}const $s=["error","warn","info","debug"],ks={error:console.error.bind(console,"[Descope]"),warn:console.warn.bind(console,"[Descope]"),info:console.info.bind(console,"[Descope]"),debug:console.debug.bind(console,"[Descope]")},Cs=Wi((e=>{var t,n,i,o;return o=class extends e{constructor(){super(...arguments),t.add(this),n.set(this,u(this,t,"m",i).call(this,ks))}set logger(e){h(this,n,u(this,t,"m",i).call(this,e||ks),"f")}get logger(){return u(this,n,"f")}onLogEvent(e,t){}},n=new WeakMap,t=new WeakSet,i=function(e){return $s.reduce(((t,n)=>(t[n]=(...t)=>{var i;this.onLogEvent(n,t),null===(i=e[n])||void 0===i||i.call(e,...t)},t)),{})},o})),Ss="undefined"!=typeof localStorage,Is="https://static.descope.com/pages",Rs="https://static2.descope.com/pages",Es=Ss&&localStorage.getItem("base.content.url")||"",xs=(e,t)=>!t&&`${e} cannot be empty, please make sure to set this attribute`,Os=Wi((e=>{var t,n;return n=class extends e{constructor(){super(...arguments),t.set(this,!0)}connectedCallback(){var e,n;null===(e=super.connectedCallback)||void 0===e||e.call(this),(null===(n=this.shadowRoot)||void 0===n?void 0:n.isConnected)&&u(this,t,"f")&&(h(this,t,!1,"f"),this.init())}async init(){}},t=new WeakMap,n})),As=Wi((e=>{var t,n;const i=xi(Cs,Os)(e);return n=class extends i{constructor(){super(...arguments),t.set(this,{})}async init(){var e,n,i;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),n=this,i=e=>{var n;null===(n=u(this,t,"f")[e])||void 0===n||n.forEach((t=>{t(e,this.getAttribute(e))}))},Array.from(n.attributes).forEach((e=>i(e.name))),new MutationObserver((e=>{e.forEach((e=>{"attributes"===e.type&&e.oldValue!==n.getAttribute(e.attributeName)&&i(e.attributeName)}))})).observe(n,{attributes:!0,attributeOldValue:!0})}observeAttribute(e,n){u(this,t,"f")[e]||(u(this,t,"f")[e]=[]);const i=u(this,t,"f")[e].push(n);return()=>u(this,t,"f")[e].splice(i,1)}observeAttributes(e,t){const n=e.reduce(((e,n)=>(e.push(this.observeAttribute(n,t)),e)),[]);return()=>n.forEach((e=>e()))}},t=new WeakMap,n})),Ns=e=>t=>{var n,i,o;const r=xi(Cs,Os,As)(t),s=Object.keys(e);return o=class extends r{constructor(...e){super(...e),n.add(this),this.observeAttributes(s,u(this,n,"m",i).bind(this))}async init(){var e;s.forEach((e=>u(this,n,"m",i).call(this,e,this.getAttribute(e)))),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},n=new WeakSet,i=function(t,n){const i=e[t],o="function"==typeof i?i(t,n):i;o&&this.logger.error(o)},o};Ns.missingAttrValidator=xs;const js=Wi((e=>{const t=xi(Ns({"project-id":xs}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),Ms=Wi((e=>class extends e{get baseUrl(){return this.getAttribute("base-url")||""}})),Ps="Trying the next fallback URL...",Ts=async(e,t,{logger:n}={})=>{try{return await fetch(e,t)}catch(i){return null==n||n.debug(`Network error fetching URL ${e} [${i.message}], retrying...`),fetch(e,t)}};const Ws=Wi((e=>{var t,n,i,o,r,s,a;const d=xi(Cs,js,Ms)(e);return a=class extends d{constructor(){super(...arguments),t.add(this),n.set(this,void 0),i.set(this,void 0),o.set(this,new Set)}async fetchStaticResource(e,n){const s=u(this,t,"m",r).call(this,e),a=Array.isArray(s)?e=>{const{baseUrl:t}=s[e];h(this,i,t,"f");for(let t=0;t<e;t++){const e=s[t].baseUrl;u(this,o,"f").add(e)}}:null;try{const e=await(async(e,t,{logger:n,onSuccess:i}={})=>{const o=Array.isArray(e)?e:[e];for(let e=0;e<o.length;e++){const r=o[e],s=e===o.length-1;try{const o=await Ts(r.toString(),t,{logger:n});if(o.ok)return null==i||i(e),null==n||n.debug(`Successfully fetched URL ${r}`),o;const a=`Error fetching URL ${r} [${o.status}]`;if(s)throw new Error(a);null==n||n.debug(`${a}. ${Ps}`)}catch(e){const t=`Error fetching URL ${r} [${e.message}]`;if(s)throw new Error(t);null==n||n.debug(`${t}. ${Ps}`)}}})(s,{cache:"default"},{logger:this.logger,onSuccess:a});return{body:await e[n](),headers:Object.fromEntries(e.headers.entries())}}catch(e){this.logger.error(e.message)}}get baseStaticUrl(){return this.getAttribute("base-static-url")||""}},n=new WeakMap,i=new WeakMap,o=new WeakMap,t=new WeakSet,r=function(e){const r=Es||this.baseStaticUrl;if(r)return u(this,t,"m",s).call(this,e,r);u(this,n,"f")!==this.baseUrl&&(h(this,n,this.baseUrl,"f"),h(this,i,void 0,"f"),u(this,o,"f").clear());const a=[];if(u(this,i,"f"))a.push(u(this,t,"m",s).call(this,e,u(this,i,"f"))),u(this,i,"f")===Is&&a.push(u(this,t,"m",s).call(this,e,Rs));else{const n=this.baseUrl+"/pages";this.baseUrl&&!u(this,o,"f").has(n)&&a.push(u(this,t,"m",s).call(this,e,n)),u(this,o,"f").has(Is)||a.push(u(this,t,"m",s).call(this,e,Is)),a.push(u(this,t,"m",s).call(this,e,Rs))}return 1===a.length?a[0]:a},s=function(e,t){return function({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:i=Is}){const o=new URL(i);return o.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(o.pathname,e,n,t),o.baseUrl=i,o}({projectId:this.projectId,filename:e,baseUrl:t})},a})),Ls=Wi((e=>{var t,n;const i=xi(Ns({"project-id":xs}))(e);return n=class extends i{constructor(){super(...arguments),t.set(this,new Map)}onReset(e,n){if(u(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} already exists`);return u(this,t,"f").set(e,n),()=>{u(this,t,"f").delete(e)}}async reset(...e){0===e.length?await Promise.all(Array.from(u(this,t,"f").values()).map((e=>e()))):await Promise.all(e.map((e=>{var n;if(!u(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} does not exist`);return null===(n=u(this,t,"f").get(e))||void 0===n?void 0:n()})))}},t=new WeakMap,n})),Us=Wi((e=>{var t,n,i,o,r;const s=xi(Ws,Ls,Os)(e);return r=class extends s{constructor(){super(...arguments),t.add(this),i.set(this,void 0),o.set(this,(async()=>{try{const{body:e,headers:t}=await this.fetchStaticResource("config.json","json");return{projectConfig:e,executionContext:{geo:t["x-geo"]}}}catch(e){this.logger.error("Cannot fetch config file","make sure that your projectId & flowId are correct")}}))}async init(){await super.init(),this.onReset("config",u(this,t,"m",n).bind(this))}get config(){return u(this,i,"f")||h(this,i,u(this,o,"f").call(this),"f"),u(this,i,"f")}},i=new WeakMap,o=new WeakMap,t=new WeakSet,n=function(){h(this,i,void 0,"f")},r})),Ds=["https://descopecdn.com","https://static.descope.com","https://cdn.jsdelivr.net"],Fs=e=>{let t=0;const n=e.toString();for(let e=0;e<n.length;e++){t=(t<<5)-t+n.charCodeAt(e),t|=0}return`${Math.abs(t).toString()}`},_s=(e,t,n)=>new Promise(((i,o)=>{const r=((e,t)=>{const n=document.createElement("script");return n.id=e,t&&(n.integrity=t,n.crossOrigin="anonymous"),window.DESCOPE_NONCE&&n.setAttribute("nonce",window.DESCOPE_NONCE),n})(e,n);r.onerror=e=>{r.setAttribute("status","error"),o(e)},r.onload=()=>{r.setAttribute("status","loaded"),i(r)},r.src=t.toString(),document.body.appendChild(r)})),qs=(e,t)=>{if(t){const n=e.integrity;if(n!==t)return Promise.reject(new Error(`Integrity mismatch: expected ${t}, found ${n}`))}return"loaded"===e.getAttribute("status")?Promise.resolve(e):(e=>"error"===e.getAttribute("status"))(e)?Promise.reject():new Promise(((t,n)=>{e.addEventListener("load",(()=>{t(e)})),e.addEventListener("error",(e=>{n(e)}))}))},Bs=Wi((e=>{const t=xi(Cs)(e);return class extends t{get baseCdnUrl(){return this.getAttribute("base-cdn-url")||""}injectNpmLib(e,t,n="",i=[],o){return this.logger.debug(`Injecting npm lib: "${e}" with version: "${t}"${o?" with SRI integrity check":""}`),(async(e,t)=>{for(const i of e){const{id:e,url:o,integrity:r}=i,s=(n=e,document.querySelector(`script#${n}`));if(s)try{return await qs(s,r),i}catch(e){t(i,!0)}else try{return await _s(e,o,r),i}catch(e){t(i,!1)}}var n;throw new Error("All scripts failed to load")})(((e,t,n,i="",o)=>e.reduce(((e,r)=>{const s=r;if(!s)return e;let a;try{a=new URL(s)}catch(e){throw new Error(`Invalid URL: ${s}`)}"/"!==a.pathname||(a.pathname=`/npm/${t}@${n}/${i}`);const d={url:a,id:`npmlib-${t.replaceAll("@","").replaceAll("/","_")}-${Fs(a)}`};return o&&(d.integrity=o),[...e,d]}),[]))([...i,this.baseCdnUrl,...Ds],e,t,n,o),((e,t)=>{t?this.logger.error(`Existing script cannot be loaded: "${e.url}"`):this.logger.error(`Cannot load script from URL, Make sure this URL is valid and return the correct script: "${e.url}"`)}))}}})),Vs="base.ui.components.url",Ks=Ss&&localStorage.getItem(Vs),Hs=Wi((e=>{var t,n,i,o,r,s,a;const d=xi(Cs,Us,Bs)(e);return a=class extends d{constructor(){super(...arguments),t.add(this),o.set(this,void 0)}get descopeUi(){return u(this,o,"f")||h(this,o,u(this,t,"m",s).call(this),"f"),u(this,o,"f")}async loadDescopeUiComponents(e){const n=Array.isArray(e)?e:(e=>[...Array.from(e.content.querySelectorAll("*")).reduce(((e,t)=>t.localName.startsWith("descope-")?e.add(t.localName):e),new Set)])(e);return Promise.all(n.map((e=>u(this,t,"m",r).call(this,e))))}},o=new WeakMap,t=new WeakSet,n=async function(){var e;const t=await this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersion;return n?this.logger.debug(`Got component version "${n}"`):this.logger.error("Could not get components version"),n},i=async function(){var e;const t=await this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersionSri;return n&&this.logger.debug("SRI hash available for components"),n},r=async function(e){if(!!customElements.get(e))return void this.logger.debug(`Loading component "${e}" is skipped as it is already defined`);const t=await this.descopeUi;if(t[e])try{return await t[e]()}catch(t){if("NotSupportedError"!==t.name)throw t;console.debug(`Encountered an error while attempting to define the "${e}" component, it is likely that this component is already defined`)}else this.logger.error(`Cannot load UI component "${e}"`,`Descope UI does not have a component named "${e}", available components are: "${Object.keys(t).join(", ")}"`)},s=async function(){if(globalThis.DescopeUI)return globalThis.DescopeUI;try{const e=await u(this,t,"m",n).call(this),o=Ks?void 0:await u(this,t,"m",i).call(this);return await this.injectNpmLib("@descope/web-components-ui",e,"dist/umd/index.js",[Ks],o),this.logger.debug("DescopeUI was loaded"),globalThis.DescopeUI}catch(e){throw this.logger.error(e),new Error("DescopeUI was not loaded")}},a})),zs=Wi((e=>{var t,n,i;const o=xi(Os,As)(e);return i=class extends o{constructor(){super(...arguments),t.add(this)}get nonce(){return this.getAttribute("nonce")||""}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),this.observeAttribute("nonce",u(this,t,"m",n).bind(this)),u(this,t,"m",n).call(this)}},t=new WeakSet,n=function(){this.nonce&&(window.DESCOPE_NONCE=this.nonce)},i}));class Js{constructor(e,t,{prepend:n=!1}={}){this.styleEle=document.createElement("style"),this.styleEle.setAttribute("nonce",t),this.ref=e,this.ref&&(n?this.ref.prepend(this.styleEle):this.ref.append(this.styleEle))}replaceSync(e){this.styleEle.textContent=e}get cssRules(){var e;return null===(e=this.styleEle.sheet)||void 0===e?void 0:e.cssRules}}const Gs=Wi((e=>{const t=xi(zs)(e);return class extends t{injectStyle(e,{prepend:t=!1}={}){let n;try{n=new CSSStyleSheet}catch(e){n=new Js(this.shadowRoot,this.nonce,{prepend:t})}if(e&&n.replaceSync(e),n instanceof CSSStyleSheet){const e=this.shadowRoot;if(e&&"adoptedStyleSheets"in e){const i=[...e.adoptedStyleSheets||[]];i[t?"unshift":"push"](n),e.adoptedStyleSheets=i}}return n}}})),Zs="content-root",Ys="root",Xs=Wi((e=>{const t=xi(Gs)(e);return class extends t{constructor(...e){var t,n;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n <div id="${Ys}">\n <div id="${Zs}"></div>\n </div>\n `,this.injectStyle(`\n #${Ys}, #${Zs} {\n height: 100%;\n }\n #${Ys} {\n position: relative;\n height: fit-content;\n }\n #${Ys}:has(> #${Zs} > #ROOT[st-host-height="100%"]) {\n height: 100%;\n }\n `),this.contentRootElement=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById(Zs),this.rootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(Ys)}}})),Qs="theme",ea=(e,t,n="")=>Object.entries(e).reduce(((e,[i,o])=>{if(!/^[a-zA-Z0-9-]+$/.test(i))return t("Ignoring invalid override-css token path segment"),e;const r=n?`${n}-${i}`:i;if("object"==typeof o&&null!==o)return e+ea(o,t,r);const s=(e=>"number"==typeof e?Number.isFinite(e)?String(e):null:"string"!=typeof e||/[;{}]/.test(e)?null:e.trim())(o);return null===s?(t("Ignoring invalid override-css token value"),e):`${e}--descope-${r}:${s};`}),""),ta=e=>{const t=document.createElement("link");t.href=e,t.rel="stylesheet",document.head.appendChild(t)};function na(e,t){const n=Object.assign({},e);for(const[e,i]of Object.entries(t||{}))if(null!=i)if("object"==typeof i){if(0===Object.keys(i).length)continue;n[e]=na(n[e]||{},i)}else n[e]="string"==typeof i?(n[e]||"")+i:i;return n}const ia=(e,t)=>null!==t&&!/^[a-zA-Z0-9_-]*$/.test(t)&&"tenant must contain only alphanumeric characters, hyphens, or underscores",oa=Wi((e=>{const t=xi(Ns({tenant:ia}))(e);return class extends t{get tenantId(){return this.getAttribute("tenant")||void 0}}})),ra=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',sa=Wi((e=>{var t,n,i,o,r,s,a,d,l,c,f,p,v,g,m,y,b,w,$,k,C,S,I;const R=xi(Ns({theme:ra}),oa,Ws,Os,Hs,Us,Xs,As,Gs)(e);return I=class extends R{constructor(){super(...arguments),t.add(this),n.set(this,void 0),i.set(this,void 0),o.set(this,void 0),s.set(this,void 0),a.set(this,void 0),k.set(this,(()=>{u(this,t,"m",C).call(this),u(this,S,"f").call(this,"os"===this.getAttribute("theme"))})),S.set(this,(e=>{var n,i,o;const r=e?"addEventListener":"removeEventListener";null===(o=null===(i=null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-color-scheme: dark)"))||void 0===i?void 0:i[r])||void 0===o||o.call(i,"change",(()=>u(this,t,"m",C).call(this)))}))}get theme(){var e,t;const n=this.getAttribute("theme");if("os"===n){return window.matchMedia&&(null===(t=null===(e=window.matchMedia)||void 0===e?void 0:e.call(window,"(prefers-color-scheme: dark)"))||void 0===t?void 0:t.matches)?"dark":"light"}return n||"light"}get styleId(){return this.getAttribute("style-id")||Qs}get themeOverride(){const e=this.getAttribute("theme-override");if(!e)return null;try{return JSON.parse(e)}catch(e){return this.logger.error("Failed to parse theme-override attribute. error: ",e),null}}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),u(this,k,"f").call(this),await Promise.all([u(this,t,"m",c).call(this),u(this,t,"m",v).call(this),u(this,t,"m",m).call(this)]),u(this,t,"m",g).call(this),this.observeAttributes(["theme"],u(this,k,"f")),this.observeAttributes(["theme-override"],(()=>u(this,t,"m",g).call(this))),this.observeAttributes(["tenant"],(()=>{h(this,a,null,"f"),u(this,t,"m",v).call(this),u(this,t,"m",m).call(this),u(this,t,"m",w).call(this)})),this.observeAttributes(["style-id"],(()=>{h(this,s,null,"f"),u(this,t,"m",b).call(this),u(this,t,"m",c).call(this),u(this,t,"m",m).call(this)}))}},n=new WeakMap,i=new WeakMap,o=new WeakMap,s=new WeakMap,a=new WeakMap,k=new WeakMap,S=new WeakMap,t=new WeakSet,r=function(){const e=this.themeOverride;return e?["light","dark"].map((t=>{var n,i,o,r,s,a;const d=null===(o=null===(i=null===(n=e[t])||void 0===n?void 0:n.globals)||void 0===i?void 0:i.colors)||void 0===o?void 0:o.primary,l=null===(a=null===(s=null===(r=e[t])||void 0===r?void 0:r.globals)||void 0===s?void 0:s.colors)||void 0===a?void 0:a.secondary;return d||l?`[data-theme="${t}"]{${ea({colors:{primary:d,secondary:l}},(e=>this.logger.error(e)))}}`:""})).join(""):""},d=async function(){try{const{body:e}=await this.fetchStaticResource(`${this.styleId}.json`,"json");if("development"===process.env.NODE_ENV&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(Vs)))try{this.logger.warn("You are in DEV mode, and UI components override URL was found\ntrying to merge project theme with the default theme of the UI components");const t=await(async()=>{const e=localStorage.getItem(Vs),t=null==e?void 0:e.replace(/[^\/]+$/,"DescopeDev.js");console.warn("Trying to load DescopeDev.js from",t);const n=document.createElement("script");if(n.src=t,document.body.appendChild(n),await new Promise(((e,t)=>{n.onload=e,n.onerror=t})),globalThis.DescopeDev){const{themeToStyle:e,defaultTheme:t,darkTheme:n}=globalThis.DescopeDev;return{light:e(t),dark:e(n)}}})();t&&(e.light.components=Object.assign(Object.assign({},e.light.components),t.light.components),e.dark.components=Object.assign(Object.assign({},e.dark.components),t.dark.components),this.logger.warn("Theme was merged successfully"),console.log("%cNOTICE! This is not the theme that will be used in production!\n\nMake sure to test it without the override UI components URL!","color: black; background-color:yellow; font-size: x-large"))}catch(e){this.logger.error("Failed to merge UI components theme\n",e)}return e}catch(e){this.logger.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}},l=function(){return u(this,s,"f")||(h(this,s,u(this,t,"m",d).call(this),"f"),u(this,s,"f").then((e=>this.logger.debug("Fetched theme",e)))),u(this,s,"f")},c=async function(){var e,i;const o=await u(this,t,"a",l);if(!o)return;const r=((null===(e=null==o?void 0:o.light)||void 0===e?void 0:e.globals)||"")+((null===(i=null==o?void 0:o.dark)||void 0===i?void 0:i.globals)||"");u(this,n,"f")?u(this,n,"f").replaceSync(r):h(this,n,this.injectStyle(r,{prepend:!0}),"f")},f=async function(){const e=this.tenantId;if(e)try{const{body:t}=await this.fetchStaticResource(`${e}/theme.json`,"json");return t}catch(e){this.logger.warn("No tenant style exists, using project default theme.")}},p=function(){return u(this,a,"f")||h(this,a,u(this,t,"m",f).call(this),"f"),u(this,a,"f")},v=async function(){var e,n,o,r;if(!this.tenantId)return void(null===(e=u(this,i,"f"))||void 0===e||e.replaceSync(""));const s=await u(this,t,"a",p);if(!s)return void(null===(n=u(this,i,"f"))||void 0===n||n.replaceSync(""));const a=((null===(o=s.light)||void 0===o?void 0:o.globals)||"")+((null===(r=s.dark)||void 0===r?void 0:r.globals)||"");u(this,i,"f")?u(this,i,"f").replaceSync(a):h(this,i,this.injectStyle(a),"f")},g=async function(){var e;if(!this.themeOverride)return void(null===(e=u(this,o,"f"))||void 0===e||e.replaceSync(""));const n=u(this,t,"m",r).call(this);u(this,o,"f")?u(this,o,"f").replaceSync(n):h(this,o,this.injectStyle(n),"f")},m=async function(){var e,n,i,o;const r=await u(this,t,"a",l);if(!r)return;const s=await this.descopeUi;if(!(null==s?void 0:s.componentsThemeManager))return;const a=await u(this,t,"a",p);s.componentsThemeManager.themes={light:na((null===(e=null==r?void 0:r.light)||void 0===e?void 0:e.components)||{},(null===(n=null==a?void 0:a.light)||void 0===n?void 0:n.components)||{}),dark:na((null===(i=null==r?void 0:r.dark)||void 0===i?void 0:i.components)||{},(null===(o=null==a?void 0:a.dark)||void 0===o?void 0:o.components)||{})}},y=async function(){var e,t;const{projectConfig:n}=await this.config||{},i=null===(e=null==n?void 0:n.styles)||void 0===e?void 0:e[this.styleId],o=null==n?void 0:n.cssTemplate,r=i||o;return null===(t=null==r?void 0:r[this.theme])||void 0===t?void 0:t.fonts},b=async function(){const e=await u(this,t,"m",y).call(this);e?Object.values(e).forEach((e=>{e.url&&(this.logger.debug(`Loading font from URL "${e.url}"`),ta(e.url))})):this.logger.debug("No fonts to load"),u(this,t,"m",w).call(this)},w=async function(){var e;if(!this.tenantId)return;const n=await u(this,t,"a",p),i=null===(e=null==n?void 0:n[this.theme])||void 0===e?void 0:e.fonts;Object.values(i||{}).forEach((e=>{(null==e?void 0:e.url)&&(this.logger.debug(`Loading tenant font from URL "${e.url}"`),ta(e.url))}))},$=async function(){this.rootElement.setAttribute("data-theme",this.theme);const e=await this.descopeUi;(null==e?void 0:e.componentsThemeManager)&&(e.componentsThemeManager.currentThemeName=this.theme)},C=function(){u(this,t,"m",b).call(this),u(this,t,"m",$).call(this)},I})),aa=Ss&&localStorage.getItem("base.debug.logs.url"),da=Wi((e=>{const t=xi(Ns({"flow-id":xs}))(e);return class extends t{get flowId(){return this.getAttribute("flow-id")}}}));function la(e){const t=Math.floor(e/1e3);if(t<60)return`${t} seconds`;const n=Math.floor(t/60);if(n<60)return`${n} minutes`;const i=Math.floor(n/60);return i<24?`${i} hours`:`${Math.floor(i/24)} days`}const ca=Wi((e=>{var t,n,i,o,r,s,a,d,l,c,f,p;const v=xi(Bs,Cs,Os,Us,js,da)(e);return p=class extends v{constructor(){super(...arguments),t.add(this),n.set(this,null),i.set(this,!1),o.set(this,null),f.set(this,null)}get telemetryManager(){return u(this,n,"f")}updateTelemetryContext(e){if(u(this,n,"f"))try{u(this,n,"f").updateContext(e)}catch(e){this.logger.error("Error updating telemetry context:",e)}}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this));const n=this.sdkVersion||"1.0.0";h(this,f,u(this,t,"m",l).call(this).then((e=>u(this,t,"m",r).call(this,e,{projectId:this.projectId,flowId:this.flowId,sdkVersion:n}))).catch((e=>{this.logger.error("Failed to start telemetry:",e)})),"f")}get telemetryReady(){var e;return null!==(e=u(this,f,"f"))&&void 0!==e?e:Promise.resolve()}disconnectedCallback(){var e;null===(e=super.disconnectedCallback)||void 0===e||e.call(this),u(this,t,"m",a).call(this)}},n=new WeakMap,i=new WeakMap,o=new WeakMap,f=new WeakMap,t=new WeakSet,r=async function(e,o){if(null==e?void 0:e.enabled)if(u(this,i,"f"))this.logger.debug("Telemetry already initialized");else if(e.expiration&&Date.now()>=e.expiration)this.logger.info(`Telemetry expiration time has passed (${new Date(e.expiration).toISOString()}), skipping initialization`);else try{this.logger.debug("Initializing telemetry...");const r=e.version||"latest";await this.injectNpmLib("@descope/debug-logs",r,"dist/index.js",[aa]);const a=window.DescopeDebugLogs;if(!a)throw new Error("DescopeDebugLogs not found after loading @descope/debug-logs. This likely means the UMD build failed to load from CDN.");if(h(this,n,new a({enabled:!0,rumConfig:e.rumConfig,capture:e.capture},{projectId:o.projectId,flowId:o.flowId,version:o.sdkVersion||"1.0.0"},this.logger),"f"),!u(this,n,"f").isReady())return this.logger.error("Telemetry manager failed to initialize (RUM client not ready)"),void h(this,n,null,"f");h(this,i,!0,"f"),this.logger.info("Telemetry initialized successfully"),e.expiration&&u(this,t,"m",s).call(this,e.expiration)}catch(e){this.logger.error("Failed to initialize telemetry:",e),h(this,i,!1,"f")}else this.logger.debug("Telemetry is disabled, skipping initialization")},s=function(e){const n=e-Date.now();if(n<=0)return this.logger.info("Telemetry expiration time reached, shutting down"),void u(this,t,"m",a).call(this);const i=864e5,r=Math.min(n,i);n>i&&this.logger.warn(`Telemetry expiration is beyond maximum timeout (${la(n)}). Setting to maximum.`),this.logger.info(`Telemetry will expire at ${new Date(e).toISOString()} (in ${la(r)})`),h(this,o,setTimeout((()=>{this.logger.info("Telemetry expiration time reached, shutting down"),u(this,t,"m",a).call(this)}),r),"f")},a=function(){if(u(this,o,"f")&&(clearTimeout(u(this,o,"f")),h(this,o,null,"f")),u(this,n,"f"))try{this.logger.debug("Shutting down telemetry..."),u(this,n,"f").shutdown(),h(this,n,null,"f"),h(this,i,!1,"f"),this.logger.info("Telemetry shutdown complete")}catch(e){this.logger.error("Error shutting down telemetry:",e)}},d=function(e){return Boolean((null==e?void 0:e.applicationId)&&(null==e?void 0:e.identityPoolId)&&(null==e?void 0:e.region))},l=async function(){var e;const n=await this.config,i=null===(e=null==n?void 0:n.projectConfig)||void 0===e?void 0:e.telemetry;let o;try{const e=Number(process.env.DESCOPE_TELEMETRY_SESSION_SAMPLE_RATE);o={enabled:"true"===(process.env.DESCOPE_TELEMETRY_ENABLED||"").toLowerCase(),rumConfig:Object.assign({applicationId:process.env.DESCOPE_TELEMETRY_APPLICATION_ID||"",identityPoolId:process.env.DESCOPE_TELEMETRY_IDENTITY_POOL_ID||"",region:process.env.DESCOPE_TELEMETRY_REGION||"",sessionSampleRate:Number.isFinite(e)&&e>0?e:1},process.env.DESCOPE_TELEMETRY_GUEST_ROLE_ARN&&{guestRoleArn:process.env.DESCOPE_TELEMETRY_GUEST_ROLE_ARN})}}catch(e){o={enabled:!1,rumConfig:{applicationId:"",identityPoolId:"",region:"",sessionSampleRate:1}}}const r=Object.assign(Object.assign(Object.assign({},o),i),{rumConfig:Object.assign(Object.assign({},o.rumConfig),null==i?void 0:i.rumConfig),capture:u(this,t,"m",c).call(this,null==i?void 0:i.capture)});return r.enabled&&!u(this,t,"m",d).call(this,r.rumConfig)&&(this.logger.warn("Telemetry enabled but rumConfig is incomplete (applicationId/identityPoolId/region required). Skipping initialization."),r.enabled=!1),i||(r.expiration=Date.now()+3e5,this.logger.debug("No backend telemetry config present; applying a 5-minute safety cap on the session.")),r},c=function(e){const t=null==e?void 0:e.dom;return!1===t?Object.assign(Object.assign({console:!0,network:!0,navigation:!0},e),{dom:!1}):Object.assign(Object.assign({console:!0,network:!0,navigation:!0},e),{dom:Object.assign(Object.assign({throttleMs:2e3},"object"==typeof t?t:{}),{rootElement:this.shadowRoot})})},p})),ua=(e,t="")=>Object.keys(e).reduce(((n,i)=>{var o;if(Array.isArray(e[i]))return Object.assign(Object.assign({},n),{[i]:{value:e[i].map((e=>"object"==typeof e&&null!==e?ua(e):e))}});if("object"==typeof e[i]&&null!==e[i]&&!(null===(o=e[i])||void 0===o?void 0:o.value))return Object.assign(Object.assign({},n),ua(e[i],`${t+i}.`));const r="object"==typeof e[i]?e[i]:{value:e[i]},s=Object.assign(Object.assign({},n),{[t+i]:r,[`form.${t}${i}`]:r});return"displayName"===i?Object.assign(Object.assign({},s),{[`${t}fullName`]:r,[`form.${t}fullName`]:r}):s}),[]),ha=Wi((e=>{var t,n,i,o;return o=class extends e{constructor(){super(...arguments),t.add(this)}connectedCallback(){var e;u(this,t,"m",n).call(this)&&u(this,t,"m",i).call(this),null===(e=super.connectedCallback)||void 0===e||e.call(this)}},t=new WeakSet,n=function(){return!this.shadowRoot.host.closest("form")&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)},i=function(){const e=this.shadowRoot.host,t=document.createElement("form");t.style.width="100%",t.style.height="100%",e.parentElement.appendChild(t),t.appendChild(e)},o})),fa=Wi((e=>{var t,n,i,o,r,s,a;return a=class extends(xi(Os,Cs)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),this.attributeChangedCallback=(e,n,i)=>{var o;null===(o=super.attributeChangedCallback)||void 0===o||o.call(this,e,n,i),"debug"===e&&u(this,t,"m",r).call(this)}}get debug(){return"true"===this.getAttribute("debug")}onLogEvent(e,n){var i;null===(i=super.onLogEvent)||void 0===i||i.call(this,e,n),"error"===e&&u(this,t,"m",s).call(this,n[0]||"Error",n[1])}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),u(this,t,"m",r).call(this)}},n=new WeakMap,t=new WeakSet,i=function(){var e;null===(e=u(this,n,"f"))||void 0===e||e.remove(),h(this,n,null,"f")},o=async function(){h(this,n,document.createElement("descope-debugger"),"f"),Object.assign(u(this,n,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),await Promise.resolve().then((function(){return kI})),document.body.appendChild(u(this,n,"f"))},r=function(){this.debug?u(this,t,"m",o).call(this):u(this,t,"m",i).call(this)},s=function(e,t){var i;e&&(null===(i=u(this,n,"f"))||void 0===i||i.updateData({title:e,description:t}))},a})),pa="descope-modal";var va,ga,ma;let ya=class{constructor(e,t){va.set(this,void 0),this.nodeName="",h(this,va,e,"f"),this.logger=t.logger}get asyncEle(){return(async e=>new Promise((t=>{const n=setInterval((()=>{const i="function"==typeof e?e():e;i&&(clearInterval(n),t(i))}),100);setTimeout((()=>{clearInterval(n),t(null)}),1e3)})))(u(this,va,"f"))}get ele(){var e,t;const n="function"==typeof u(this,va,"f")?u(this,va,"f").call(this):u(this,va,"f");return n?(null==n?void 0:n.localName)!==this.nodeName?(null===(t=this.logger)||void 0===t||t.debug(`node name do not match, expected "${this.nodeName}", received "${n.localName}" `,Error()),null):n:(null===(e=this.logger)||void 0===e||e.debug(`Driver element is not available for ${this.nodeName}`,new Error),null)}get isExists(){return!!this.ele}};va=new WeakMap;let ba=class extends ya{constructor(){super(...arguments),this.nodeName="descope-apps-list"}set data(e){this.ele&&(this.ele.data=e)}get data(){var e;return null===(e=this.ele)||void 0===e?void 0:e.data}get ele(){return super.ele}},wa=class extends ya{constructor(){super(...arguments),this.nodeName="descope-avatar"}set displayName(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("display-name",e)}set image(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("img",e)}get flowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("flow-id")}onClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("click",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("click",e)}}},$a=class extends ya{constructor(){super(...arguments),this.nodeName="descope-filter",ga.set(this,null)}get data(){var e;try{return JSON.parse((null===(e=this.ele)||void 0===e?void 0:e.getAttribute("data"))||"[]")}catch(e){return[]}}set data(e){var t,n;h(this,ga,JSON.stringify(e),"f"),u(this,ga,"f")!==(null===(t=this.ele)||void 0===t?void 0:t.getAttribute("data"))&&(null===(n=this.ele)||void 0===n||n.setAttribute("data",u(this,ga,"f")))}get value(){var e;try{return JSON.parse((null===(e=this.ele)||void 0===e?void 0:e.getAttribute("value"))||"[]")}catch(e){return[]}}set value(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("value",JSON.stringify(e))}onApply(e){var t;const n=t=>e(t.detail);return null===(t=this.ele)||void 0===t||t.addEventListener("filter-apply",n),()=>{var e;return null===(e=this.ele)||void 0===e?void 0:e.removeEventListener("filter-apply",n)}}onClear(e){var t;const n=t=>e(t.detail);return null===(t=this.ele)||void 0===t||t.addEventListener("filter-clear",n),()=>{var e;return null===(e=this.ele)||void 0===e?void 0:e.removeEventListener("filter-clear",n)}}onDataChange(e){const t=this.ele;if(!t)return()=>{};const n=new MutationObserver((()=>{var n;(null!==(n=t.getAttribute("data"))&&void 0!==n?n:"[]")!==u(this,ga,"f")&&e()}));return n.observe(t,{attributes:!0,attributeFilter:["data"]}),()=>n.disconnect()}};ga=new WeakMap;let ka=class extends ya{constructor(){super(...arguments),this.nodeName="descope-button"}onClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("click",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("click",e)}}disable(){var e;null===(e=this.ele)||void 0===e||e.setAttribute("disabled","true")}enable(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("disabled")}},Ca=class extends ya{constructor(){super(...arguments),this.nodeName="descope-wc"}set projectId(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("project-id",e)}set baseUrl(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("base-url",e)}set flowId(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("flow-id",e)}set theme(e){var t,n;e?null===(n=this.ele)||void 0===n||n.setAttribute("theme",e):null===(t=this.ele)||void 0===t||t.removeAttribute("theme")}start(){var e,t;null===(t=null===(e=this.ele)||void 0===e?void 0:e.start)||void 0===t||t.call(e)}onSuccess(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("success",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("success",e)}}onPageUpdated(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("page-updated",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("page-updated",e)}}},Sa=class extends ka{get flowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("flow-id"))||""}get enableMode(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("enable-mode")}};const Ia=/^descope-grid-([^-]+)-column$/,Ra={text:class extends ya{constructor(){super(...arguments),this.nodeName="descope-grid-text-column"}onSortDirectionChange(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("direction-changed",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("selected-items-changed",e)}}},custom:class extends ya{constructor(){super(...arguments),this.nodeName="descope-grid-custom-column"}onSortDirectionChange(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("direction-changed",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("selected-items-changed",e)}}}};let Ea=class extends ya{constructor(){super(...arguments),this.nodeName="descope-grid",ma.set(this,void 0)}onSelectedItemsChange(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("selected-items-changed",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("selected-items-changed",e)}}get ele(){return super.ele}get data(){var e;return null===(e=this.ele)||void 0===e?void 0:e.data}set data(e){this.ele&&(this.ele.data=e)}get columns(){return this.ele?Array.from(this.ele.children).reduce(((e,t)=>{var n;const i=null===(n=Ia.exec(t.localName))||void 0===n?void 0:n[1],o=Ra[i];return o?(e.push(new o(t,{logger:this.logger})),e):e}),[]):[]}filterColumns(e){var t,n;const i=null===(t=this.ele.columns)||void 0===t?void 0:t.filter(e);i&&this.ele.columns&&(Ai(i,this.ele.columns)||(this.ele.columns=i,null===(n=u(this,ma,"f"))||void 0===n||n.call(this,i)))}onColumnsChange(e){h(this,ma,e,"f")}set renderColumn(e){this.ele.renderColumn=e}};ma=new WeakMap;let xa=class extends ya{constructor(){super(...arguments),this.nodeName="descope-link"}get ele(){return super.ele}get href(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("href")}set href(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("href",null!=e?e:"")}};var Oa,Aa,Na,ja,Ma,Pa,Ta,Wa,La,Ua,Da,Fa,_a,qa,Ba,Va,Ka,Ha,za;let Ja=class extends ya{constructor(...e){super(...e),Oa.add(this),Aa.set(this,void 0),Na.set(this,void 0),this.nodeName="descope-modal",u(this,Oa,"m",ja).call(this)}get isOpen(){var e;return"true"===(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("opened"))}get isClosed(){return!this.isOpen}close(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("opened")}async open(){var e,t;await(null===(e=this.beforeOpen)||void 0===e?void 0:e.call(this)),u(this,Oa,"m",ja).call(this),null===(t=this.ele)||void 0===t||t.setAttribute("opened","true")}reset(){var e;this.ele&&(this.ele.innerHTML=""),u(this,Aa,"f")&&(null===(e=this.ele)||void 0===e||e.append(u(this,Aa,"f").content.cloneNode(!0)))}setContent(e){h(this,Aa,e,"f"),this.reset()}remove(){var e,t;null===(e=u(this,Na,"f"))||void 0===e||e.disconnect(),null===(t=this.ele)||void 0===t||t.remove()}};Aa=new WeakMap,Na=new WeakMap,Oa=new WeakSet,ja=function(){if(u(this,Na,"f"))return;const e=this.ele;e&&(h(this,Na,new MutationObserver((t=>{t.forEach(((n,i)=>{var o;const r="true"===n.oldValue,s=t[i+1]?t[i+1].oldValue:e.getAttribute("opened");r&&"true"!==s&&(null===(o=this.afterClose)||void 0===o||o.call(this))}))})),"f"),u(this,Na,"f").observe(e,{attributes:!0,attributeFilter:["opened"],attributeOldValue:!0}))};let Ga=null,Za=class{constructor(e={}){Ma.add(this),Pa.set(this,null),Ta.set(this,""),Wa.set(this,void 0),La.set(this,void 0),Ua.set(this,!1),Da.set(this,[]),Fa.set(this,[]),_a.set(this,[]),qa.set(this,[]),Ba.set(this,void 0),Va.set(this,!1),this.logger=e.logger}onDone(e){return u(this,Da,"f").push(e),()=>{h(this,Da,u(this,Da,"f").filter((t=>t!==e)),"f")}}onClosed(e){return u(this,Fa,"f").push(e),()=>{h(this,Fa,u(this,Fa,"f").filter((t=>t!==e)),"f")}}onParentFocus(e){return u(this,qa,"f").push(e),()=>{h(this,qa,u(this,qa,"f").filter((t=>t!==e)),"f")}}onUnauthenticated(e){return u(this,_a,"f").push(e),()=>{h(this,_a,u(this,_a,"f").filter((t=>t!==e)),"f")}}get isOpen(){return!!u(this,Pa,"f")&&!u(this,Pa,"f").closed}open(e){var t,n;Ga&&Ga!==this&&Ga.standDown(),u(this,Ma,"m",za).call(this),h(this,Ua,!1,"f"),h(this,Va,!1,"f");try{h(this,Ta,new URL(e).origin,"f")}catch(n){return null===(t=this.logger)||void 0===t||t.error("Invalid flow popup url",e),!1}const i=`descope-widget-flow|${window.location.origin}`;return h(this,Pa,((e,t,n,i)=>{const o=void 0!==window.screenLeft?window.screenLeft:window.screen.left,r=void 0!==window.screenTop?window.screenTop:window.screen.top,s=((window.innerWidth||document.documentElement.clientWidth||window.screen.width)-n)/2+o,a=((window.innerHeight||document.documentElement.clientHeight||window.screen.height)-i)/2+r,d=function(){const e=navigator.userAgent||"",t=/\b(iPhone)\b/.test(e),n=/Safari/.test(e)&&!/CriOS|FxiOS|OPiOS|EdgiOS|Chrome|Chromium/.test(e);return t&&n}()?"about:blank":"",l=window.open(d,t,`width=${n},height=${i},top=${a},left=${s},scrollbars=yes,resizable=yes`);return l?(l.location.href=e,l.focus(),l):null})(e,i,480,650),"f"),u(this,Pa,"f")?(h(this,La,(e=>{var t,n,i,o,r,s;u(this,Pa,"f")&&e.source&&e.source!==u(this,Pa,"f")||(e.origin===u(this,Ta,"f")?"widget-flow-hello"!==(null===(n=e.data)||void 0===n?void 0:n.action)?"widget-flow-unauthenticated"!==(null===(r=e.data)||void 0===r?void 0:r.action)?"widget-flow-done"===(null===(s=e.data)||void 0===s?void 0:s.action)&&u(this,Ma,"m",Ha).call(this,u(this,Da,"f")):u(this,Ma,"m",Ha).call(this,u(this,_a,"f")):null===(i=e.source)||void 0===i||i.postMessage({action:"widget-flow-hello-ack",nonce:null===(o=e.data)||void 0===o?void 0:o.nonce},e.origin):null===(t=this.logger)||void 0===t||t.debug(`Ignoring popup message from unexpected origin "${e.origin}"`))}),"f"),window.addEventListener("message",u(this,La,"f")),h(this,Wa,setInterval((()=>{var e;(null===(e=u(this,Pa,"f"))||void 0===e?void 0:e.closed)&&u(this,Ma,"m",Ha).call(this,u(this,Fa,"f"))}),1e3),"f"),h(this,Ba,(()=>{"hidden"!==document.visibilityState&&(u(this,Va,"f")||u(this,Ua,"f")||(h(this,Va,!0,"f"),u(this,qa,"f").forEach((e=>e()))))}),"f"),window.addEventListener("focus",u(this,Ba,"f")),document.addEventListener("visibilitychange",u(this,Ba,"f")),Ga=this,!0):(null===(n=this.logger)||void 0===n||n.warn("Flow popup was blocked by the browser"),!1)}close(){var e;try{null===(e=u(this,Pa,"f"))||void 0===e||e.close()}catch(e){}u(this,Ma,"m",Ha).call(this,u(this,Fa,"f"))}remove(){u(this,Ma,"m",Ka).call(this)}standDown(){h(this,Ua,!0,"f"),u(this,Ma,"m",za).call(this),h(this,Pa,null,"f")}};Pa=new WeakMap,Ta=new WeakMap,Wa=new WeakMap,La=new WeakMap,Ua=new WeakMap,Da=new WeakMap,Fa=new WeakMap,_a=new WeakMap,qa=new WeakMap,Ba=new WeakMap,Va=new WeakMap,Ma=new WeakSet,Ka=function(){u(this,Ma,"m",za).call(this),Ga===this&&(Ga=null)},Ha=function(e){u(this,Ua,"f")||(h(this,Ua,!0,"f"),u(this,Ma,"m",Ka).call(this),e.forEach((e=>e())))},za=function(){u(this,Wa,"f")&&(clearInterval(u(this,Wa,"f")),h(this,Wa,void 0,"f")),u(this,La,"f")&&(window.removeEventListener("message",u(this,La,"f")),h(this,La,void 0,"f")),u(this,Ba,"f")&&(window.removeEventListener("focus",u(this,Ba,"f")),document.removeEventListener("visibilitychange",u(this,Ba,"f")),h(this,Ba,void 0,"f"))};let Ya=class extends ya{constructor(){super(...arguments),this.nodeName="descope-multi-line-mappings"}setData(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("data",JSON.stringify(e))}get value(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.value)||[]}set value(e){this.ele&&(this.ele.value=e)}get mergedValue(){return Object.entries(this.value.filter((({tenantId:e})=>!!e)).reduce(((e,{tenantId:t,roleNames:n})=>(e[t]=[...new Set([...e[t]||[],...n])],e)),{})).map((([e,t])=>({tenantId:e,roleNames:t})))}};const Xa=({label:e,value:t,description:n})=>{const i=document.createElement("span");i.setAttribute("data-name",e),i.setAttribute("data-id",t),i.style.display="flex",i.style.flexDirection="column";const o=document.createElement("span");if(o.textContent=e,i.appendChild(o),n){const e=document.createElement("span");e.textContent=n,e.style.opacity="0.6",e.style.fontSize="0.85em",i.appendChild(e)}return i.outerHTML};let Qa=class extends ya{constructor(){super(...arguments),this.nodeName="descope-multi-select-combo-box"}async setData(e){const t=await this.asyncEle;t&&(e.some((e=>e.description))&&(t.renderItem=Xa),t.setAttribute("data",JSON.stringify([...e].sort(((e,t)=>e.label.localeCompare(t.label))))))}},ed=class extends ya{constructor(){super(...arguments),this.nodeName="descope-notification"}close(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("opened")}show(){var e;null===(e=this.ele)||void 0===e||e.setAttribute("opened","true")}setContent(e){this.ele.innerHTML="",this.ele.appendChild(e.content.cloneNode(!0))}remove(){var e;null===(e=this.ele)||void 0===e||e.remove()}},td=class extends ya{constructor(){super(...arguments),this.nodeName="descope-outbound-apps"}set data(e){this.ele&&(this.ele.data=e)}get data(){var e;return null===(e=this.ele)||void 0===e?void 0:e.data}get ele(){return super.ele}get connectFlowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("connect-flow-id"))||""}get disconnectFlowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("disconnect-flow-id"))||""}onConnectClick(e){var t;const n=t=>e(t.detail);return null===(t=this.ele)||void 0===t||t.addEventListener("connect-clicked",n),()=>{var e;return null===(e=this.ele)||void 0===e?void 0:e.removeEventListener("connect-clicked",n)}}onDisconnectClick(e){var t;const n=t=>e(t.detail);return null===(t=this.ele)||void 0===t||t.addEventListener("disconnect-clicked",n),()=>{var e;return null===(e=this.ele)||void 0===e?void 0:e.removeEventListener("disconnect-clicked",n)}}},nd=class extends ya{constructor(){super(...arguments),this.nodeName="descope-combo-box"}onInput(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("input",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("input",e)}}get value(){var e;return null===(e=this.ele)||void 0===e?void 0:e.value}set value(e){this.ele&&(this.ele.value=e)}async setData(e){var t;null===(t=await this.asyncEle)||void 0===t||t.setAttribute("data",JSON.stringify(e.sort()))}setAllowCustomValue(e){this.ele&&this.ele.toggleAttribute("allow-custom-value",e)}},id=class extends ya{constructor(){super(...arguments),this.nodeName="descope-text"}get ele(){return super.ele}get text(){var e;return null===(e=this.ele)||void 0===e?void 0:e.innerText}set text(e){this.ele&&(this.ele.innerText=e)}},od=class extends ya{constructor(){super(...arguments),this.nodeName="descope-text-field"}onInput(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("input",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("input",e)}}get value(){var e;return null===(e=this.ele)||void 0===e?void 0:e.value}set value(e){this.ele&&(this.ele.value=e)}disable(){var e;null===(e=this.ele)||void 0===e||e.setAttribute("disabled","true")}enable(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("disabled")}},rd=class extends ya{constructor(){super(...arguments),this.nodeName="descope-user-attribute"}set value(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("value",e)}set badgeLabel(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("badge-label",e)}get label(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("label"))||""}get editFlowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("edit-flow-id"))||""}get deleteFlowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("delete-flow-id"))||""}onEditClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("edit-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("edit-clicked",e)}}onDeleteClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("delete-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("delete-clicked",e)}}},sd=class extends ya{constructor(){super(...arguments),this.nodeName="descope-user-auth-method"}set fulfilled(e){var t,n;e?null===(t=this.ele)||void 0===t||t.setAttribute("fulfilled","true"):null===(n=this.ele)||void 0===n||n.removeAttribute("fulfilled")}onUnfulfilledButtonClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("button-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("button-clicked",e)}}onFulfilledButtonClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("fulfilled-button-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("fulfilled-button-clicked",e)}}get flowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("flow-id")}get fulfilledFlowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("fulfilled-flow-id")}},ad=class extends ya{constructor(){super(...arguments),this.nodeName="descope-trusted-devices"}set displayName(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("display-name",e)}get ele(){return super.ele}get data(){var e;return null===(e=this.ele)||void 0===e?void 0:e.data}set data(e){this.ele&&(this.ele.data=e)}get flowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("flow-id")}onRemoveDeviceClick(e){var t;const n=t=>e(t.detail);return null===(t=this.ele)||void 0===t||t.addEventListener("remove-device-clicked",n),()=>{var e;return null===(e=this.ele)||void 0===e?void 0:e.removeEventListener("remove-device-clicked",n)}}},dd=class extends nd{get action(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("data-action"))||""}get refreshTimeout(){var e;return Number(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("data-refresh-timeout"))||500}get shouldReload(){return"reload"===this.action}},ld=class extends ya{constructor(){super(...arguments),this.nodeName="descope-user-passkeys"}get ele(){return super.ele}get data(){var e;return null===(e=this.ele)||void 0===e?void 0:e.data}set data(e){this.ele&&(this.ele.data=e)}get addPasskeyFlowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("add-passkey-flow-id")}get removePasskeyFlowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("remove-passkey-flow-id")}onAddPasskeyClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("add-passkey-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("add-passkey-clicked",e)}}onRemovePasskeyClick(e){var t;const n=t=>e(t.detail);return null===(t=this.ele)||void 0===t||t.addEventListener("remove-passkey-clicked",n),()=>{var e;return null===(e=this.ele)||void 0===e?void 0:e.removeEventListener("remove-passkey-clicked",n)}}},cd=class extends ya{constructor(){super(...arguments),this.nodeName="descope-multi-sso"}set data(e){this.ele&&(this.ele.data=e)}get data(){var e;return null===(e=this.ele)||void 0===e?void 0:e.data}get ele(){return super.ele}get createFlowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("data-create-flow-id"))||""}get deleteFlowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("data-delete-flow-id"))||""}onCreateClicked(e){var t;const n=()=>e();return null===(t=this.ele)||void 0===t||t.addEventListener("create-clicked",n),()=>{var e;return null===(e=this.ele)||void 0===e?void 0:e.removeEventListener("create-clicked",n)}}onDeleteClicked(e){var t;const n=t=>e(t.detail);return null===(t=this.ele)||void 0===t||t.addEventListener("delete-clicked",n),()=>{var e;return null===(e=this.ele)||void 0===e?void 0:e.removeEventListener("delete-clicked",n)}}};const ud=Wi((e=>{var t,n;const i=xi(Os,Xs,Hs)(e);return n=class extends i{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends Ja{setContent(t){e(t),super.setContent(t)}}})())}get modalDriverClass(){return u(this,t,"f")}createModal(e,n=u(this,t,"f")){const i=((e={})=>{const t=document.createElement(pa);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(i),new n(i,{logger:this.logger})}async init(){var e;this.loadDescopeUiComponents([pa]),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},t=new WeakMap,n})),hd=Wi((e=>class extends(ud(e)){createFlowModal(e){const t=this.modalDriverClass;return this.createModal(e,class extends t{setContent(e){const t=e.content.querySelector("descope-wc");t&&!t.hasAttribute("lazy-start")&&t.setAttribute("lazy-start","true"),super.setContent(e)}async open(){var e,t,n;await super.open(),null===(n=null===(t=null===(e=this.ele)||void 0===e?void 0:e.querySelector("descope-wc"))||void 0===t?void 0:t.start)||void 0===n||n.call(t)}})}})),fd="descope-notification",pd=Wi((e=>{var t,n;const i=xi(Os,Xs,Hs)(e);return n=class extends i{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends ed{setContent(t){const n="string"==typeof t?Oi(t):t;e(n),super.setContent(n)}}})())}createNotification(e){const n=((e={})=>{const t=document.createElement(fd);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(u(this,t,"f"))(n,{logger:this.logger})}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),this.loadDescopeUiComponents([fd])}},t=new WeakMap,n}));function vd(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var gd=(()=>"function"==typeof Symbol&&Symbol.observable||"@@observable")(),md=()=>Math.random().toString(36).substring(7).split("").join("."),yd={INIT:`@@redux/INIT${md()}`,REPLACE:`@@redux/REPLACE${md()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${md()}`};function bd(e){if("object"!=typeof e||null===e)return!1;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||null===Object.getPrototypeOf(e)}function wd(e){if(void 0===e)return"undefined";if(null===e)return"null";const t=typeof e;switch(t){case"boolean":case"string":case"number":case"symbol":case"function":return t}if(Array.isArray(e))return"array";if(function(e){return e instanceof Date||"function"==typeof e.toDateString&&"function"==typeof e.getDate&&"function"==typeof e.setDate}(e))return"date";if(function(e){return e instanceof Error||"string"==typeof e.message&&e.constructor&&"number"==typeof e.constructor.stackTraceLimit}(e))return"error";const n=function(e){return"function"==typeof e.constructor?e.constructor.name:null}(e);switch(n){case"Symbol":case"Promise":case"WeakMap":case"WeakSet":case"Map":case"Set":return n}return Object.prototype.toString.call(e).slice(8,-1).toLowerCase().replace(/\s/g,"")}function $d(e){let t=typeof e;return"production"!==process.env.NODE_ENV&&(t=wd(e)),t}function kd(e,t,n){if("function"!=typeof e)throw new Error("production"===process.env.NODE_ENV?vd(2):`Expected the root reducer to be a function. Instead, received: '${$d(e)}'`);if("function"==typeof t&&"function"==typeof n||"function"==typeof n&&"function"==typeof arguments[3])throw new Error("production"===process.env.NODE_ENV?vd(0):"It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function. See https://redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.");if("function"==typeof t&&void 0===n&&(n=t,t=void 0),void 0!==n){if("function"!=typeof n)throw new Error("production"===process.env.NODE_ENV?vd(1):`Expected the enhancer to be a function. Instead, received: '${$d(n)}'`);return n(kd)(e,t)}let i=e,o=t,r=new Map,s=r,a=0,d=!1;function l(){s===r&&(s=new Map,r.forEach(((e,t)=>{s.set(t,e)})))}function c(){if(d)throw new Error("production"===process.env.NODE_ENV?vd(3):"You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return o}function u(e){if("function"!=typeof e)throw new Error("production"===process.env.NODE_ENV?vd(4):`Expected the listener to be a function. Instead, received: '${$d(e)}'`);if(d)throw new Error("production"===process.env.NODE_ENV?vd(5):"You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api/store#subscribelistener for more details.");let t=!0;l();const n=a++;return s.set(n,e),function(){if(t){if(d)throw new Error("production"===process.env.NODE_ENV?vd(6):"You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api/store#subscribelistener for more details.");t=!1,l(),s.delete(n),r=null}}}function h(e){if(!bd(e))throw new Error("production"===process.env.NODE_ENV?vd(7):`Actions must be plain objects. Instead, the actual type was: '${$d(e)}'. You may need to add middleware to your store setup to handle dispatching other values, such as 'redux-thunk' to handle dispatching functions. See https://redux.js.org/tutorials/fundamentals/part-4-store#middleware and https://redux.js.org/tutorials/fundamentals/part-6-async-logic#using-the-redux-thunk-middleware for examples.`);if(void 0===e.type)throw new Error("production"===process.env.NODE_ENV?vd(8):'Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');if("string"!=typeof e.type)throw new Error("production"===process.env.NODE_ENV?vd(17):`Action "type" property must be a string. Instead, the actual type was: '${$d(e.type)}'. Value was: '${e.type}' (stringified)`);if(d)throw new Error("production"===process.env.NODE_ENV?vd(9):"Reducers may not dispatch actions.");try{d=!0,o=i(o,e)}finally{d=!1}return(r=s).forEach((e=>{e()})),e}h({type:yd.INIT});return{dispatch:h,subscribe:u,getState:c,replaceReducer:function(e){if("function"!=typeof e)throw new Error("production"===process.env.NODE_ENV?vd(10):`Expected the nextReducer to be a function. Instead, received: '${$d(e)}`);i=e,h({type:yd.REPLACE})},[gd]:function(){const e=u;return{subscribe(t){if("object"!=typeof t||null===t)throw new Error("production"===process.env.NODE_ENV?vd(11):`Expected the observer to be an object. Instead, received: '${$d(t)}'`);function n(){const e=t;e.next&&e.next(c())}n();return{unsubscribe:e(n)}},[gd](){return this}}}}}function Cd(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(e){}}function Sd(e){const t=Object.keys(e),n={};for(let i=0;i<t.length;i++){const o=t[i];"production"!==process.env.NODE_ENV&&void 0===e[o]&&Cd(`No reducer provided for key "${o}"`),"function"==typeof e[o]&&(n[o]=e[o])}const i=Object.keys(n);let o,r;"production"!==process.env.NODE_ENV&&(o={});try{!function(e){Object.keys(e).forEach((t=>{const n=e[t];if(void 0===n(void 0,{type:yd.INIT}))throw new Error("production"===process.env.NODE_ENV?vd(12):`The slice reducer for key "${t}" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.`);if(void 0===n(void 0,{type:yd.PROBE_UNKNOWN_ACTION()}))throw new Error("production"===process.env.NODE_ENV?vd(13):`The slice reducer for key "${t}" returned undefined when probed with a random type. Don't try to handle '${yd.INIT}' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.`)}))}(n)}catch(e){r=e}return function(e={},t){if(r)throw r;if("production"!==process.env.NODE_ENV){const i=function(e,t,n,i){const o=Object.keys(t),r=n&&n.type===yd.INIT?"preloadedState argument passed to createStore":"previous state received by the reducer";if(0===o.length)return"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";if(!bd(e))return`The ${r} has unexpected type of "${$d(e)}". Expected argument to be an object with the following keys: "${o.join('", "')}"`;const s=Object.keys(e).filter((e=>!t.hasOwnProperty(e)&&!i[e]));return s.forEach((e=>{i[e]=!0})),n&&n.type===yd.REPLACE?void 0:s.length>0?`Unexpected ${s.length>1?"keys":"key"} "${s.join('", "')}" found in ${r}. Expected to find one of the known reducer keys instead: "${o.join('", "')}". Unexpected keys will be ignored.`:void 0}(e,n,t,o);i&&Cd(i)}let s=!1;const a={};for(let o=0;o<i.length;o++){const r=i[o],d=n[r],l=e[r],c=d(l,t);if(void 0===c){const e=t&&t.type;throw new Error("production"===process.env.NODE_ENV?vd(14):`When called with an action of type ${e?`"${String(e)}"`:"(unknown type)"}, the slice reducer for key "${r}" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.`)}a[r]=c,s=s||c!==l}return s=s||i.length!==Object.keys(e).length,s?a:e}}function Id(...e){return 0===e.length?e=>e:1===e.length?e[0]:e.reduce(((e,t)=>(...n)=>e(t(...n))))}function Rd(e){return bd(e)&&"type"in e&&"string"==typeof e.type}var Ed=Symbol.for("immer-nothing"),xd=Symbol.for("immer-draftable"),Od=Symbol.for("immer-state"),Ad="production"!==process.env.NODE_ENV?[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}]:[];function Nd(e,...t){if("production"!==process.env.NODE_ENV){const n=Ad[e],i="function"==typeof n?n.apply(null,t):n;throw new Error(`[Immer] ${i}`)}throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var jd=Object.getPrototypeOf;function Md(e){return!!e&&!!e[Od]}function Pd(e){return!!e&&(Wd(e)||Array.isArray(e)||!!e[xd]||!!e.constructor?.[xd]||_d(e)||qd(e))}var Td=Object.prototype.constructor.toString();function Wd(e){if(!e||"object"!=typeof e)return!1;const t=jd(e);if(null===t)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object||"function"==typeof n&&Function.toString.call(n)===Td}function Ld(e,t){0===Ud(e)?Object.entries(e).forEach((([n,i])=>{t(n,i,e)})):e.forEach(((n,i)=>t(i,n,e)))}function Ud(e){const t=e[Od];return t?t.type_:Array.isArray(e)?1:_d(e)?2:qd(e)?3:0}function Dd(e,t){return 2===Ud(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Fd(e,t,n){const i=Ud(e);2===i?e.set(t,n):3===i?e.add(n):e[t]=n}function _d(e){return e instanceof Map}function qd(e){return e instanceof Set}function Bd(e){return e.copy_||e.base_}function Vd(e,t){if(_d(e))return new Map(e);if(qd(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&Wd(e)){if(!jd(e)){const t=Object.create(null);return Object.assign(t,e)}return{...e}}const n=Object.getOwnPropertyDescriptors(e);delete n[Od];let i=Reflect.ownKeys(n);for(let t=0;t<i.length;t++){const o=i[t],r=n[o];!1===r.writable&&(r.writable=!0,r.configurable=!0),(r.get||r.set)&&(n[o]={configurable:!0,writable:!0,enumerable:r.enumerable,value:e[o]})}return Object.create(jd(e),n)}function Kd(e,t=!1){return zd(e)||Md(e)||!Pd(e)||(Ud(e)>1&&(e.set=e.add=e.clear=e.delete=Hd),Object.freeze(e),t&&Ld(e,((e,t)=>Kd(t,!0)))),e}function Hd(){Nd(2)}function zd(e){return Object.isFrozen(e)}var Jd,Gd={};function Zd(e){const t=Gd[e];return t||Nd(0,e),t}function Yd(){return Jd}function Xd(e,t){t&&(Zd("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Qd(e){el(e),e.drafts_.forEach(nl),e.drafts_=null}function el(e){e===Jd&&(Jd=e.parent_)}function tl(e){return Jd={drafts_:[],parent_:Jd,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function nl(e){const t=e[Od];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function il(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return void 0!==e&&e!==n?(n[Od].modified_&&(Qd(t),Nd(4)),Pd(e)&&(e=ol(t,e),t.parent_||sl(t,e)),t.patches_&&Zd("Patches").generateReplacementPatches_(n[Od].base_,e,t.patches_,t.inversePatches_)):e=ol(t,n,[]),Qd(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Ed?e:void 0}function ol(e,t,n){if(zd(t))return t;const i=t[Od];if(!i)return Ld(t,((o,r)=>rl(e,i,t,o,r,n))),t;if(i.scope_!==e)return t;if(!i.modified_)return sl(e,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;const t=i.copy_;let o=t,r=!1;3===i.type_&&(o=new Set(t),t.clear(),r=!0),Ld(o,((o,s)=>rl(e,i,t,o,s,n,r))),sl(e,t,!1),n&&e.patches_&&Zd("Patches").generatePatches_(i,n,e.patches_,e.inversePatches_)}return i.copy_}function rl(e,t,n,i,o,r,s){if("production"!==process.env.NODE_ENV&&o===n&&Nd(5),Md(o)){const s=ol(e,o,r&&t&&3!==t.type_&&!Dd(t.assigned_,i)?r.concat(i):void 0);if(Fd(n,i,s),!Md(s))return;e.canAutoFreeze_=!1}else s&&n.add(o);if(Pd(o)&&!zd(o)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;ol(e,o),t&&t.scope_.parent_||sl(e,o)}}function sl(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Kd(t,n)}var al={get(e,t){if(t===Od)return e;const n=Bd(e);if(!Dd(n,t))return function(e,t,n){const i=cl(t,n);return i?"value"in i?i.value:i.get?.call(e.draft_):void 0}(e,n,t);const i=n[t];return e.finalized_||!Pd(i)?i:i===ll(e.base_,t)?(hl(e),e.copy_[t]=fl(i,e)):i},has:(e,t)=>t in Bd(e),ownKeys:e=>Reflect.ownKeys(Bd(e)),set(e,t,n){const i=cl(Bd(e),t);if(i?.set)return i.set.call(e.draft_,n),!0;if(!e.modified_){const i=ll(Bd(e),t),o=i?.[Od];if(o&&o.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}(n,i)&&(void 0!==n||Dd(e.base_,t)))return!0;hl(e),ul(e)}return e.copy_[t]===n&&(void 0!==n||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty:(e,t)=>(void 0!==ll(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,hl(e),ul(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=Bd(e),i=Reflect.getOwnPropertyDescriptor(n,t);return i?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:i.enumerable,value:n[t]}:i},defineProperty(){Nd(11)},getPrototypeOf:e=>jd(e.base_),setPrototypeOf(){Nd(12)}},dl={};function ll(e,t){const n=e[Od];return(n?Bd(n):e)[t]}function cl(e,t){if(!(t in e))return;let n=jd(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=jd(n)}}function ul(e){e.modified_||(e.modified_=!0,e.parent_&&ul(e.parent_))}function hl(e){e.copy_||(e.copy_=Vd(e.base_,e.scope_.immer_.useStrictShallowCopy_))}Ld(al,((e,t)=>{dl[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),dl.deleteProperty=function(e,t){return"production"!==process.env.NODE_ENV&&isNaN(parseInt(t))&&Nd(13),dl.set.call(this,e,t,void 0)},dl.set=function(e,t,n){return"production"!==process.env.NODE_ENV&&"length"!==t&&isNaN(parseInt(t))&&Nd(14),al.set.call(this,e[0],t,n,e[0])};function fl(e,t){const n=_d(e)?Zd("MapSet").proxyMap_(e,t):qd(e)?Zd("MapSet").proxySet_(e,t):function(e,t){const n=Array.isArray(e),i={type_:n?1:0,scope_:t?t.scope_:Yd(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let o=i,r=al;n&&(o=[i],r=dl);const{revoke:s,proxy:a}=Proxy.revocable(o,r);return i.draft_=a,i.revoke_=s,a}(e,t);return(t?t.scope_:Yd()).drafts_.push(n),n}function pl(e){return Md(e)||Nd(10,e),vl(e)}function vl(e){if(!Pd(e)||zd(e))return e;const t=e[Od];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Vd(e,t.scope_.immer_.useStrictShallowCopy_)}else n=Vd(e,!0);return Ld(n,((e,t)=>{Fd(n,e,vl(t))})),t&&(t.finalized_=!1),n}var gl=new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(e,t,n)=>{if("function"==typeof e&&"function"!=typeof t){const n=t;t=e;const i=this;return function(e=n,...o){return i.produce(e,(e=>t.call(this,e,...o)))}}let i;if("function"!=typeof t&&Nd(6),void 0!==n&&"function"!=typeof n&&Nd(7),Pd(e)){const o=tl(this),r=fl(e,void 0);let s=!0;try{i=t(r),s=!1}finally{s?Qd(o):el(o)}return Xd(o,n),il(i,o)}if(!e||"object"!=typeof e){if(i=t(e),void 0===i&&(i=e),i===Ed&&(i=void 0),this.autoFreeze_&&Kd(i,!0),n){const t=[],o=[];Zd("Patches").generateReplacementPatches_(e,i,t,o),n(t,o)}return i}Nd(1,e)},this.produceWithPatches=(e,t)=>{if("function"==typeof e)return(t,...n)=>this.produceWithPatches(t,(t=>e(t,...n)));let n,i;const o=this.produce(e,t,((e,t)=>{n=e,i=t}));return[o,n,i]},"boolean"==typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){Pd(e)||Nd(8),Md(e)&&(e=pl(e));const t=tl(this),n=fl(e,void 0);return n[Od].isManual_=!0,el(t),n}finishDraft(e,t){const n=e&&e[Od];n&&n.isManual_||Nd(9);const{scope_:i}=n;return Xd(i,t),il(void 0,i)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const i=t[n];if(0===i.path.length&&"replace"===i.op){e=i.value;break}}n>-1&&(t=t.slice(n+1));const i=Zd("Patches").applyPatches_;return Md(e)?i(e,t):this.produce(e,(e=>i(e,t)))}},ml=gl.produce;gl.produceWithPatches.bind(gl),gl.setAutoFreeze.bind(gl),gl.setUseStrictShallowCopy.bind(gl),gl.applyPatches.bind(gl),gl.createDraft.bind(gl),gl.finishDraft.bind(gl);var yl=(e,t,n)=>{if(1===t.length&&t[0]===n){let t=!1;try{const n={};e(n)===n&&(t=!0)}catch{}if(t){let e;try{throw new Error}catch(t){({stack:e}=t)}console.warn("The result function returned its own inputs without modification. e.g\n`createSelector([state => state.todos], todos => todos)`\nThis could lead to inefficient memoization and unnecessary re-renders.\nEnsure transformation logic is in the result function, and extraction logic is in the input selectors.",{stack:e})}}},bl=(e,t,n)=>{const{memoize:i,memoizeOptions:o}=t,{inputSelectorResults:r,inputSelectorResultsCopy:s}=e,a=i((()=>({})),...o);if(!(a.apply(null,r)===a.apply(null,s))){let e;try{throw new Error}catch(t){({stack:e}=t)}console.warn("An input selector returned a different result when passed same arguments.\nThis means your output selector will likely run more frequently than intended.\nAvoid returning a new reference inside your input selector, e.g.\n`createSelector([state => state.todos.map(todo => todo.id)], todoIds => todoIds.length)`",{arguments:n,firstInputs:r,secondInputs:s,stack:e})}},wl={inputStabilityCheck:"once",identityFunctionCheck:"once"};var $l=e=>Array.isArray(e)?e:[e];function kl(e){const t=Array.isArray(e[0])?e[0]:e;return function(e,t="expected all items to be functions, instead received the following types: "){if(!e.every((e=>"function"==typeof e))){const n=e.map((e=>"function"==typeof e?`function ${e.name||"unnamed"}()`:typeof e)).join(", ");throw new TypeError(`${t}[${n}]`)}}(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function Cl(e,t){const n=[],{length:i}=e;for(let o=0;o<i;o++)n.push(e[o].apply(null,t));return n}var Sl="undefined"!=typeof WeakRef?WeakRef:class{constructor(e){this.value=e}deref(){return this.value}},Il=0,Rl=1;function El(){return{s:Il,v:void 0,o:null,p:null}}function xl(e,t={}){let n=El();const{resultEqualityCheck:i}=t;let o,r=0;function s(){let t=n;const{length:s}=arguments;for(let e=0,n=s;e<n;e++){const n=arguments[e];if("function"==typeof n||"object"==typeof n&&null!==n){let e=t.o;null===e&&(t.o=e=new WeakMap);const i=e.get(n);void 0===i?(t=El(),e.set(n,t)):t=i}else{let e=t.p;null===e&&(t.p=e=new Map);const i=e.get(n);void 0===i?(t=El(),e.set(n,t)):t=i}}const a=t;let d;if(t.s===Rl)d=t.v;else if(d=e.apply(null,arguments),r++,i){const e=o?.deref?.()??o;null!=e&&i(e,d)&&(d=e,0!==r&&r--);o="object"==typeof d&&null!==d||"function"==typeof d?new Sl(d):d}return a.s=Rl,a.v=d,d}return s.clearCache=()=>{n=El(),s.resetResultsCount()},s.resultsCount=()=>r,s.resetResultsCount=()=>{r=0},s}function Ol(e,...t){const n="function"==typeof e?{memoize:e,memoizeOptions:t}:e,i=(...e)=>{let t,i=0,o=0,r={},s=e.pop();"object"==typeof s&&(r=s,s=e.pop()),function(e,t="expected a function, instead received "+typeof e){if("function"!=typeof e)throw new TypeError(t)}(s,`createSelector expects an output function after the inputs, but received: [${typeof s}]`);const a={...n,...r},{memoize:d,memoizeOptions:l=[],argsMemoize:c=xl,argsMemoizeOptions:u=[],devModeChecks:h={}}=a,f=$l(l),p=$l(u),v=kl(e),g=d((function(){return i++,s.apply(null,arguments)}),...f);let m=!0;const y=c((function(){o++;const e=Cl(v,arguments);if(t=g.apply(null,e),"production"!==process.env.NODE_ENV){const{identityFunctionCheck:n,inputStabilityCheck:i}=((e,t)=>{const{identityFunctionCheck:n,inputStabilityCheck:i}={...wl,...t};return{identityFunctionCheck:{shouldRun:"always"===n||"once"===n&&e,run:yl},inputStabilityCheck:{shouldRun:"always"===i||"once"===i&&e,run:bl}}})(m,h);if(n.shouldRun&&n.run(s,e,t),i.shouldRun){const t=Cl(v,arguments);i.run({inputSelectorResults:e,inputSelectorResultsCopy:t},{memoize:d,memoizeOptions:f},arguments)}m&&(m=!1)}return t}),...p);return Object.assign(y,{resultFunc:s,memoizedResultFunc:g,dependencies:v,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>t,recomputations:()=>i,resetRecomputations:()=>{i=0},memoize:d,argsMemoize:c})};return Object.assign(i,{withTypes:()=>i}),i}var Al=Ol(xl),Nl=Object.assign(((e,t=Al)=>{!function(e,t="expected an object, instead received "+typeof e){if("object"!=typeof e)throw new TypeError(t)}(e,"createStructuredSelector expects first argument to be an object where each property is a selector, instead received a "+typeof e);const n=Object.keys(e),i=t(n.map((t=>e[t])),((...e)=>e.reduce(((e,t,i)=>(e[n[i]]=t,e)),{})));return i}),{withTypes:()=>Nl});function jl(e){return({dispatch:t,getState:n})=>i=>o=>"function"==typeof o?o(t,n,e):i(o)}var Ml=jl(),Pl=jl;((...e)=>{const t=Ol(...e)})(xl);var Tl="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?Id:Id.apply(null,arguments)},Wl=e=>e&&"function"==typeof e.match;function Ll(e,t){function n(...n){if(t){let i=t(...n);if(!i)throw new Error("production"===process.env.NODE_ENV?mc(0):"prepareAction did not return an object");return{type:e,payload:i.payload,..."meta"in i&&{meta:i.meta},..."error"in i&&{error:i.error}}}return{type:e,payload:n[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=t=>Rd(t)&&t.type===e,n}function Ul(e){return"function"==typeof e&&"type"in e&&Wl(e)}function Dl(e,t){let n=0;return{measureTime(e){const t=Date.now();try{return e()}finally{const e=Date.now();n+=e-t}},warnIfExceeded(){n>e&&console.warn(`${t} took ${n}ms, which is more than the warning threshold of ${e}ms. \nIf your state or actions are very large, you may want to disable the middleware as it might cause too much of a slowdown in development mode. See https://redux-toolkit.js.org/api/getDefaultMiddleware for instructions.\nIt is disabled in production builds, so you don't need to worry about that.`)}}}var Fl=class e extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,e.prototype)}static get[Symbol.species](){return e}concat(...e){return super.concat.apply(this,e)}prepend(...t){return 1===t.length&&Array.isArray(t[0])?new e(...t[0].concat(this)):new e(...t.concat(this))}};function _l(e){return Pd(e)?ml(e,(()=>{})):e}function ql(e,t,n){if(e.has(t)){let i=e.get(t);return n.update&&(i=n.update(i,t,e),e.set(t,i)),i}if(!n.insert)throw new Error("production"===process.env.NODE_ENV?mc(10):"No insert provided for key not already in map");const i=n.insert(t,e);return e.set(t,i),i}function Bl(e){return"object"!=typeof e||null==e||Object.isFrozen(e)}function Vl(e,t,n){const i=Kl(e,t,n);return{detectMutations:()=>Hl(e,t,i,n)}}function Kl(e,t=[],n,i="",o=new Set){const r={value:n};if(!e(n)&&!o.has(n)){o.add(n),r.children={};for(const o in n){const s=i?i+"."+o:o;t.length&&-1!==t.indexOf(s)||(r.children[o]=Kl(e,t,n[o],s))}}return r}function Hl(e,t=[],n,i,o=!1,r=""){const s=n?n.value:void 0,a=s===i;if(o&&!a&&!Number.isNaN(i))return{wasMutated:!0,path:r};if(e(s)||e(i))return{wasMutated:!1};const d={};for(let e in n.children)d[e]=!0;for(let e in i)d[e]=!0;const l=t.length>0;for(let o in d){const s=r?r+"."+o:o;if(l){if(t.some((e=>e instanceof RegExp?e.test(s):s===e)))continue}const d=Hl(e,t,n.children[o],i[o],a,s);if(d.wasMutated)return d}return{wasMutated:!1}}function zl(e){const t=typeof e;return null==e||"string"===t||"boolean"===t||"number"===t||Array.isArray(e)||bd(e)}function Jl(e,t="",n=zl,i,o=[],r){let s;if(!n(e))return{keyPath:t||"<root>",value:e};if("object"!=typeof e||null===e)return!1;if(r?.has(e))return!1;const a=null!=i?i(e):Object.entries(e),d=o.length>0;for(const[e,l]of a){const a=t?t+"."+e:e;if(d){if(o.some((e=>e instanceof RegExp?e.test(a):a===e)))continue}if(!n(l))return{keyPath:a,value:l};if("object"==typeof l&&(s=Jl(l,a,n,i,o,r),s))return s}return r&&Gl(e)&&r.add(e),!1}function Gl(e){if(!Object.isFrozen(e))return!1;for(const t of Object.values(e))if("object"==typeof t&&null!==t&&!Gl(t))return!1;return!0}function Zl(e){return"boolean"==typeof e}var Yl=()=>function(e){const{thunk:t=!0,immutableCheck:n=!0,serializableCheck:i=!0,actionCreatorCheck:o=!0}=e??{};let r=new Fl;if(t&&(Zl(t)?r.push(Ml):r.push(Pl(t.extraArgument))),"production"!==process.env.NODE_ENV){if(n){let e={};Zl(n)||(e=n),r.unshift(function(e={}){if("production"===process.env.NODE_ENV)return()=>e=>t=>e(t);{let t=function(e,t,i,o){return JSON.stringify(e,n(t,o),i)},n=function(e,t){let n=[],i=[];return t||(t=function(e,t){return n[0]===t?"[Circular ~]":"[Circular ~."+i.slice(0,n.indexOf(t)).join(".")+"]"}),function(o,r){if(n.length>0){var s=n.indexOf(this);~s?n.splice(s+1):n.push(this),~s?i.splice(s,1/0,o):i.push(o),~n.indexOf(r)&&(r=t.call(this,o,r))}else n.push(r);return null==e?r:e.call(this,o,r)}},{isImmutable:i=Bl,ignoredPaths:o,warnAfter:r=32}=e;const s=Vl.bind(null,i,o);return({getState:e})=>{let n,i=e(),o=s(i);return a=>d=>{const l=Dl(r,"ImmutableStateInvariantMiddleware");l.measureTime((()=>{if(i=e(),n=o.detectMutations(),o=s(i),n.wasMutated)throw new Error("production"===process.env.NODE_ENV?mc(19):`A state mutation was detected between dispatches, in the path '${n.path||""}'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)}));const c=a(d);return l.measureTime((()=>{if(i=e(),n=o.detectMutations(),o=s(i),n.wasMutated)throw new Error("production"===process.env.NODE_ENV?mc(20):`A state mutation was detected inside a dispatch, in the path: ${n.path||""}. Take a look at the reducer(s) handling the action ${t(d)}. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)})),l.warnIfExceeded(),c}}}}(e))}if(i){let e={};Zl(i)||(e=i),r.push(function(e={}){if("production"===process.env.NODE_ENV)return()=>e=>t=>e(t);{const{isSerializable:t=zl,getEntries:n,ignoredActions:i=[],ignoredActionPaths:o=["meta.arg","meta.baseQueryMeta"],ignoredPaths:r=[],warnAfter:s=32,ignoreState:a=!1,ignoreActions:d=!1,disableCache:l=!1}=e,c=!l&&WeakSet?new WeakSet:void 0;return e=>l=>u=>{if(!Rd(u))return l(u);const h=l(u),f=Dl(s,"SerializableStateInvariantMiddleware");return d||i.length&&-1!==i.indexOf(u.type)||f.measureTime((()=>{const e=Jl(u,"",t,n,o,c);if(e){const{keyPath:t,value:n}=e;console.error(`A non-serializable value was detected in an action, in the path: \`${t}\`. Value:`,n,"\nTake a look at the logic that dispatched this action: ",u,"\n(See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)","\n(To allow non-serializable values see: https://redux-toolkit.js.org/usage/usage-guide#working-with-non-serializable-data)")}})),a||(f.measureTime((()=>{const i=Jl(e.getState(),"",t,n,r,c);if(i){const{keyPath:e,value:t}=i;console.error(`A non-serializable value was detected in the state, in the path: \`${e}\`. Value:`,t,`\nTake a look at the reducer(s) handling this action type: ${u.type}.\n(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)`)}})),f.warnIfExceeded()),h}}}(e))}if(o){let e={};Zl(o)||(e=o),r.unshift(function(e={}){if("production"===process.env.NODE_ENV)return()=>e=>t=>e(t);const{isActionCreator:t=Ul}=e;return()=>e=>n=>(t(n)&&console.warn(function(e){const t=e?`${e}`.split("/"):[],n=t[t.length-1]||"actionCreator";return`Detected an action creator with type "${e||"unknown"}" being dispatched. \nMake sure you're calling the action creator before dispatching, i.e. \`dispatch(${n}())\` instead of \`dispatch(${n})\`. This is necessary even if the action has no payload.`}(n.type)),e(n))}(e))}}return r},Xl=e=>t=>{setTimeout(t,e)},Ql="undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame:Xl(10),ec=e=>function(t){const{autoBatch:n=!0}=t??{};let i=new Fl(e);return n&&i.push(((e={type:"raf"})=>t=>(...n)=>{const i=t(...n);let o=!0,r=!1,s=!1;const a=new Set,d="tick"===e.type?queueMicrotask:"raf"===e.type?Ql:"callback"===e.type?e.queueNotification:Xl(e.timeout),l=()=>{s=!1,r&&(r=!1,a.forEach((e=>e())))};return Object.assign({},i,{subscribe(e){const t=i.subscribe((()=>o&&e()));return a.add(e),()=>{t(),a.delete(e)}},dispatch(e){try{return o=!e?.meta?.RTK_autoBatch,r=!o,r&&(s||(s=!0,d(l))),i.dispatch(e)}finally{o=!0}}})})("object"==typeof n?n:void 0)),i},tc="production"===process.env.NODE_ENV;function nc(e){const t=Yl(),{reducer:n,middleware:i,devTools:o=!0,preloadedState:r,enhancers:s}=e||{};let a,d;if("function"==typeof n)a=n;else{if(!bd(n))throw new Error("production"===process.env.NODE_ENV?mc(1):"`reducer` is a required argument, and must be a function or an object of functions that can be passed to combineReducers");a=Sd(n)}if(!tc&&i&&"function"!=typeof i)throw new Error("production"===process.env.NODE_ENV?mc(2):"`middleware` field must be a callback");if("function"==typeof i){if(d=i(t),!tc&&!Array.isArray(d))throw new Error("production"===process.env.NODE_ENV?mc(3):"when using a middleware builder function, an array of middleware must be returned")}else d=t();if(!tc&&d.some((e=>"function"!=typeof e)))throw new Error("production"===process.env.NODE_ENV?mc(4):"each middleware provided to configureStore must be a function");let l=Id;o&&(l=Tl({trace:!tc,..."object"==typeof o&&o}));const c=function(...e){return t=>(n,i)=>{const o=t(n,i);let r=()=>{throw new Error("production"===process.env.NODE_ENV?vd(15):"Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")};const s={getState:o.getState,dispatch:(e,...t)=>r(e,...t)},a=e.map((e=>e(s)));return r=Id(...a)(o.dispatch),{...o,dispatch:r}}}(...d),u=ec(c);if(!tc&&s&&"function"!=typeof s)throw new Error("production"===process.env.NODE_ENV?mc(5):"`enhancers` field must be a callback");let h="function"==typeof s?s(u):u();if(!tc&&!Array.isArray(h))throw new Error("production"===process.env.NODE_ENV?mc(6):"`enhancers` callback must return an array");if(!tc&&h.some((e=>"function"!=typeof e)))throw new Error("production"===process.env.NODE_ENV?mc(7):"each enhancer provided to configureStore must be a function");tc||!d.length||h.includes(c)||console.error("middlewares were provided, but middleware enhancer was not included in final enhancers - make sure to call `getDefaultEnhancers`");return kd(a,r,l(...h))}function ic(e){const t={},n=[];let i;const o={addCase(e,r){if("production"!==process.env.NODE_ENV){if(n.length>0)throw new Error("production"===process.env.NODE_ENV?mc(26):"`builder.addCase` should only be called before calling `builder.addMatcher`");if(i)throw new Error("production"===process.env.NODE_ENV?mc(27):"`builder.addCase` should only be called before calling `builder.addDefaultCase`")}const s="string"==typeof e?e:e.type;if(!s)throw new Error("production"===process.env.NODE_ENV?mc(28):"`builder.addCase` cannot be called with an empty action type");if(s in t)throw new Error("production"===process.env.NODE_ENV?mc(29):`\`builder.addCase\` cannot be called with two reducers for the same action type '${s}'`);return t[s]=r,o},addMatcher(e,t){if("production"!==process.env.NODE_ENV&&i)throw new Error("production"===process.env.NODE_ENV?mc(30):"`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");return n.push({matcher:e,reducer:t}),o},addDefaultCase(e){if("production"!==process.env.NODE_ENV&&i)throw new Error("production"===process.env.NODE_ENV?mc(31):"`builder.addDefaultCase` can only be called once");return i=e,o}};return e(o),[t,n,i]}function oc(...e){return t=>e.some((e=>((e,t)=>Wl(e)?e.match(t):e(t))(e,t)))}var rc=["name","message","stack","code"],sc=class{constructor(e,t){this.payload=e,this.meta=t}_type},ac=class{constructor(e,t){this.payload=e,this.meta=t}_type},dc=e=>{if("object"==typeof e&&null!==e){const t={};for(const n of rc)"string"==typeof e[n]&&(t[n]=e[n]);return t}return{message:String(e)}},lc=(()=>{function e(e,t,n){const i=Ll(e+"/fulfilled",((e,t,n,i)=>({payload:e,meta:{...i||{},arg:n,requestId:t,requestStatus:"fulfilled"}}))),o=Ll(e+"/pending",((e,t,n)=>({payload:void 0,meta:{...n||{},arg:t,requestId:e,requestStatus:"pending"}}))),r=Ll(e+"/rejected",((e,t,i,o,r)=>({payload:o,error:(n&&n.serializeError||dc)(e||"Rejected"),meta:{...r||{},arg:i,requestId:t,rejectedWithValue:!!o,requestStatus:"rejected",aborted:"AbortError"===e?.name,condition:"ConditionError"===e?.name}})));return Object.assign((function(e){return(s,a,d)=>{const l=n?.idGenerator?n.idGenerator(e):((e=21)=>{let t="",n=e;for(;n--;)t+="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW"[64*Math.random()|0];return t})(),c=new AbortController;let u;function h(e){u=e,c.abort()}const f=async function(){let f;try{let r=n?.condition?.(e,{getState:a,extra:d});if(null!==(p=r)&&"object"==typeof p&&"function"==typeof p.then&&(r=await r),!1===r||c.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};const v=new Promise(((e,t)=>c.signal.addEventListener("abort",(()=>t({name:"AbortError",message:u||"Aborted"})))));s(o(l,e,n?.getPendingMeta?.({requestId:l,arg:e},{getState:a,extra:d}))),f=await Promise.race([v,Promise.resolve(t(e,{dispatch:s,getState:a,extra:d,requestId:l,signal:c.signal,abort:h,rejectWithValue:(e,t)=>new sc(e,t),fulfillWithValue:(e,t)=>new ac(e,t)})).then((t=>{if(t instanceof sc)throw t;return t instanceof ac?i(t.payload,l,e,t.meta):i(t,l,e)}))])}catch(t){f=t instanceof sc?r(null,l,e,t.payload,t.meta):r(t,l,e)}var p;return n&&!n.dispatchConditionRejection&&r.match(f)&&f.meta.condition||s(f),f}();return Object.assign(f,{abort:h,requestId:l,arg:e,unwrap:()=>f.then(cc)})}}),{pending:o,rejected:r,fulfilled:i,settled:oc(r,i),typePrefix:e})}return e.withTypes=()=>e,e})();function cc(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}var uc=Symbol.for("rtk-slice-createasyncthunk");function hc(e,t){return`${e}/${t}`}function fc(e,t,n,i){function o(o,...r){let s=n.call(e,o);if(void 0===s)if(i)s=e.getInitialState();else if("production"!==process.env.NODE_ENV)throw new Error("production"===process.env.NODE_ENV?mc(16):"selectState returned undefined for an uninjected slice reducer");return t(s,...r)}return o.unwrapped=t,o}var pc=function({creators:e}={}){const t=e?.asyncThunk?.[uc];return function(e){const{name:n,reducerPath:i=n}=e;if(!n)throw new Error("production"===process.env.NODE_ENV?mc(11):"`name` is a required option for createSlice");"undefined"!=typeof process&&"development"===process.env.NODE_ENV&&void 0===e.initialState&&console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");const o=("function"==typeof e.reducers?e.reducers(function(){function e(e,t){return{_reducerDefinitionType:"asyncThunk",payloadCreator:e,...t}}return e.withTypes=()=>e,{reducer:e=>Object.assign({[e.name]:(...t)=>e(...t)}[e.name],{_reducerDefinitionType:"reducer"}),preparedReducer:(e,t)=>({_reducerDefinitionType:"reducerWithPrepare",prepare:e,reducer:t}),asyncThunk:e}}()):e.reducers)||{},r=Object.keys(o),s={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},a={addCase(e,t){const n="string"==typeof e?e:e.type;if(!n)throw new Error("production"===process.env.NODE_ENV?mc(12):"`context.addCase` cannot be called with an empty action type");if(n in s.sliceCaseReducersByType)throw new Error("production"===process.env.NODE_ENV?mc(13):"`context.addCase` cannot be called with two reducers for the same action type: "+n);return s.sliceCaseReducersByType[n]=t,a},addMatcher:(e,t)=>(s.sliceMatchers.push({matcher:e,reducer:t}),a),exposeAction:(e,t)=>(s.actionCreators[e]=t,a),exposeCaseReducer:(e,t)=>(s.sliceCaseReducersByName[e]=t,a)};function d(){if("production"!==process.env.NODE_ENV&&"object"==typeof e.extraReducers)throw new Error("production"===process.env.NODE_ENV?mc(14):"The object notation for `createSlice.extraReducers` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createSlice");const[t={},n=[],i]="function"==typeof e.extraReducers?ic(e.extraReducers):[e.extraReducers],o={...t,...s.sliceCaseReducersByType};return function(e,t){if("production"!==process.env.NODE_ENV&&"object"==typeof t)throw new Error("production"===process.env.NODE_ENV?mc(8):"The object notation for `createReducer` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer");let n,[i,o,r]=ic(t);if(function(e){return"function"==typeof e}(e))n=()=>_l(e());else{const t=_l(e);n=()=>t}function s(e=n(),t){let s=[i[t.type],...o.filter((({matcher:e})=>e(t))).map((({reducer:e})=>e))];return 0===s.filter((e=>!!e)).length&&(s=[r]),s.reduce(((e,n)=>{if(n){if(Md(e)){const i=n(e,t);return void 0===i?e:i}if(Pd(e))return ml(e,(e=>n(e,t)));{const i=n(e,t);if(void 0===i){if(null===e)return e;throw new Error("production"===process.env.NODE_ENV?mc(9):"A case reducer on a non-draftable value must not return undefined")}return i}}return e}),e)}return s.getInitialState=n,s}(e.initialState,(e=>{for(let t in o)e.addCase(t,o[t]);for(let t of s.sliceMatchers)e.addMatcher(t.matcher,t.reducer);for(let t of n)e.addMatcher(t.matcher,t.reducer);i&&e.addDefaultCase(i)}))}r.forEach((i=>{const r=o[i],s={reducerName:i,type:hc(n,i),createNotation:"function"==typeof e.reducers};!function(e){return"asyncThunk"===e._reducerDefinitionType}(r)?function({type:e,reducerName:t,createNotation:n},i,o){let r,s;if("reducer"in i){if(n&&!function(e){return"reducerWithPrepare"===e._reducerDefinitionType}(i))throw new Error("production"===process.env.NODE_ENV?mc(17):"Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");r=i.reducer,s=i.prepare}else r=i;o.addCase(e,r).exposeCaseReducer(t,r).exposeAction(t,s?Ll(e,s):Ll(e))}(s,r,a):function({type:e,reducerName:t},n,i,o){if(!o)throw new Error("production"===process.env.NODE_ENV?mc(18):"Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`.");const{payloadCreator:r,fulfilled:s,pending:a,rejected:d,settled:l,options:c}=n,u=o(e,r,c);i.exposeAction(t,u),s&&i.addCase(u.fulfilled,s);a&&i.addCase(u.pending,a);d&&i.addCase(u.rejected,d);l&&i.addMatcher(u.settled,l);i.exposeCaseReducer(t,{fulfilled:s||vc,pending:a||vc,rejected:d||vc,settled:l||vc})}(s,r,a,t)}));const l=e=>e,c=new WeakMap;let u;const h={name:n,reducerPath:i,reducer:(e,t)=>(u||(u=d()),u(e,t)),actions:s.actionCreators,caseReducers:s.sliceCaseReducersByName,getInitialState:()=>(u||(u=d()),u.getInitialState()),getSelectors(t=l){const n=ql(c,this,{insert:()=>new WeakMap});return ql(n,t,{insert:()=>{const n={};for(const[i,o]of Object.entries(e.selectors??{}))n[i]=fc(this,o,t,this!==h);return n}})},selectSlice(e){let t=e[this.reducerPath];if(void 0===t)if(this!==h)t=this.getInitialState();else if("production"!==process.env.NODE_ENV)throw new Error("production"===process.env.NODE_ENV?mc(15):"selectSlice returned undefined for an uninjected slice reducer");return t},get selectors(){return this.getSelectors(this.selectSlice)},injectInto(e,{reducerPath:t,...n}={}){const i=t??this.reducerPath;return e.inject({reducerPath:i,reducer:this.reducer},n),{...this,reducerPath:i}}};return h}}();function vc(){}var gc="listenerMiddleware";function mc(e){return`Minified Redux Toolkit error #${e}; visit https://redux-toolkit.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}Ll(`${gc}/add`),Ll(`${gc}/removeAll`),Ll(`${gc}/remove`);const yc=e=>Wi((t=>{const n=pc(e),i=Object.assign(Object.assign({},n.actions),e.asyncActions);return class extends(xi(Cs)(t)){constructor(...e){super(...e);const t=nc({reducer:n.reducer,middleware:e=>e({thunk:{extraArgument:this},serializableCheck:!1}),devTools:!1}),o=e=>async(...n)=>{const i=await t.dispatch(e(...n));try{cc(i)}catch(e){this.logger.error(e.message,i.type,e.stack)}return i},r=Object.keys(i).reduce(((e,t)=>(e[t]=o(i[t]),e)),{});this.actions=r,this.subscribe=(e,n=e=>e)=>t.subscribe((()=>e(n(t.getState()))))}}})),bc=Wi((e=>class extends(Cs(e)){validateForm(e){return this.getFormInputs(e).every((e=>{var t,n;return null===(t=e.reportValidity)||void 0===t||t.call(e),null===(n=e.checkValidity)||void 0===n?void 0:n.call(e)}))}getFormInputs(e){return e?Array.from(e.querySelectorAll("[name]")):(this.logger.debug("cannot get form inputs, no root element was received"),[])}getFormData(e){return this.getFormInputs(e).reduce(((e,t)=>Object.assign(e,{[t.getAttribute("name")]:t.value})),{})}setFormData(e,t){this.getFormInputs(e).forEach((e=>{t.hasOwnProperty(e.getAttribute("name"))&&(e.value=t[e.getAttribute("name")])}))}resetFormData(e){this.getFormInputs(e).forEach((e=>{e.value="",e.checked=!1}))}getFormFieldNames(e){return this.getFormInputs(e).map((e=>e.name))}disableFormField(e,t){var n;null===(n=this.getFormInputs(e).find((e=>e.name===t)))||void 0===n||n.setAttribute("disabled","true")}removeFormField(e,t){var n;null===(n=this.getFormInputs(e).find((e=>e.name===t)))||void 0===n||n.remove()}})),wc=Wi((e=>{const t=xi(Ns({"widget-id":xs}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}}})),$c=Wi((e=>{const t=xi(Us,wc)(e);return class extends t{async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this))}async getWidgetConfig(){var e,t;const n=await this.config;return null===(t=null===(e=null==n?void 0:n.projectConfig)||void 0===e?void 0:e.widgets)||void 0===t?void 0:t[this.widgetId]}async getHostedPageBaseUrl(){var e;const t=await this.config;return null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.hostedPageBaseUrl}}})),kc=Wi((e=>class extends e{get locale(){return this.getAttribute("locale")||""}get localeCandidates(){const{locale:e,fallback:t}=Hi(this.locale);return[...new Set([e,t].filter(Boolean))]}firstAvailableLocale(e){var t;const n=(null!=e?e:[]).map((e=>e.toLowerCase()));return null!==(t=this.localeCandidates.find((e=>n.includes(e))))&&void 0!==t?t:""}})),Cc=e=>Wi((t=>{var n,i,o;const r=xi(Ws,wc,$c,kc)(t);return o=class extends r{constructor(){super(...arguments),n.add(this)}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this))}async fetchWidgetPage(t){const o=await u(this,n,"m",i).call(this,t);if(void 0!==o)return o;const r=await this.fetchStaticResource(`${e}/${this.widgetId}/${t}`,"text");return null==r?void 0:r.body}},n=new WeakSet,i=async function(t){var n;const i=await this.getWidgetConfig(),o=this.firstAvailableLocale(null!==(n=null==i?void 0:i.targetLocales)&&void 0!==n?n:[]);if(!o)return;const r=".html",s=t.endsWith(r)?t.slice(0,-5):t;try{const t=await this.fetchStaticResource(`${e}/${this.widgetId}/${s}-${o}${r}`,"text");return null==t?void 0:t.body}catch(e){return}},o})),Sc=Wi((e=>class extends e{get refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}})),Ic=Wi((e=>{var t,n,i;return i=class extends(sa(e)){constructor(){super(...arguments),t.add(this)}get clientInput(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(e){return{}}}get formInput(){return this.getAttribute("form")||void 0}createFlowTemplate(e){var{flowId:i,client:o,form:r}=e,s=l(e,["flowId","client","form"]);return Ti(Object.assign({projectId:this.getAttribute("project-id"),flowId:i,baseUrl:this.getAttribute("base-url")||"",baseStaticUrl:this.getAttribute("base-static-url")||"",baseCdnUrl:this.getAttribute("base-cdn-url")||"",refreshCookieName:this.getAttribute("refresh-cookie-name")||"",theme:this.theme,"style-id":this.styleId,locale:this.getAttribute("locale")||"",form:u(this,t,"m",n).call(this,r),client:Object.assign(Object.assign({},this.clientInput),o)},s))}},t=new WeakSet,n=function(e){const t=this.formInput;if(!e)return t;if(!t)return e;try{return Object.assign(Object.assign({},JSON.parse(t)),e)}catch(t){return e}},i})),Rc=/(["\\])/g;function Ec(e,t){return Array.from(e.querySelectorAll(`[data-id="${n=t,"undefined"!=typeof CSS&&"function"==typeof CSS.escape?CSS.escape(n):n.replace(Rc,"\\$1")}"]`));var n}function xc(e,t){e&&t&&Object.entries(t).forEach((([t,n])=>{Ec(e,t).forEach((e=>function(e,t){var n;switch(t){case"hide":e.setAttribute("hidden",""),null===(n=e.style)||void 0===n||n.setProperty("display","none","important");break;case"disable":e.setAttribute("disabled","true");break;case"read-only":e.setAttribute("readonly","true")}}(e,n)))}))}const Oc=Wi((e=>{var t,n,i,o,r,s;const a=xi(Cs,Xs)(e);return s=class extends a{constructor(){super(...arguments),t.add(this),n.set(this,void 0),i.set(this,{})}async init(){var e,i;if("true"===this.getAttribute("mock"))return h(this,n,Promise.resolve({}),"f"),void await(null===(e=super.init)||void 0===e?void 0:e.call(this));const s=u(this,t,"m",o).call(this);h(this,n,u(this,t,"m",r).call(this,s),"f"),await(null===(i=super.init)||void 0===i?void 0:i.call(this))}async onWidgetRootReady(){var e,t;await(null===(e=super.onWidgetRootReady)||void 0===e?void 0:e.call(this)),h(this,i,null!==(t=await u(this,n,"f"))&&void 0!==t?t:{},"f"),xc(this.contentRootElement,u(this,i,"f"))}async reevaluateComponentsState(){const e=u(this,t,"m",o).call(this);var n,s;n=this.contentRootElement,s=u(this,i,"f"),n&&s&&Object.entries(s).forEach((([e,t])=>{Ec(n,e).forEach((e=>function(e,t){var n;switch(t){case"hide":e.removeAttribute("hidden"),null===(n=e.style)||void 0===n||n.removeProperty("display");break;case"disable":e.removeAttribute("disabled");break;case"read-only":e.removeAttribute("readonly")}}(e,t)))})),h(this,i,await u(this,t,"m",r).call(this,e),"f"),xc(this.contentRootElement,u(this,i,"f"))}},n=new WeakMap,i=new WeakMap,t=new WeakSet,o=function(){var e;const t=null===(e=this.api)||void 0===e?void 0:e.httpClient;if(!t)throw new Error("componentsConditionsMixin: the widget sdk must expose `httpClient`. Compose apiMixin and return `webSdk.httpClient` from createSdk.");return t},r=async function(e){var t;try{const n=await e.get("/v1/mgmt/widget/components-state");if(!(null==n?void 0:n.ok))return{};const i=await n.json();return null!==(t=null==i?void 0:i.componentsState)&&void 0!==t?t:{}}catch(e){return this.logger.debug("components-conditions: failed to fetch, showing all components",null==e?void 0:e.message),{}}},s})),Ac=["input","change"];function Nc(e){if("number"==typeof e&&Number.isFinite(e))return{value:e,ok:!0};if("boolean"==typeof e)return{value:e?1:0,ok:!0};if("string"==typeof e){if(""===e.trim())return{value:0,ok:!1};const t=Number(e);if(Number.isFinite(t))return{value:t,ok:!0}}return{value:0,ok:!1}}function jc(e){return null==e?"":"string"==typeof e?e:"boolean"==typeof e?e?"true":"false":"number"==typeof e?Number.isFinite(e)?String(e):"":String(e)}function Mc(e){if("boolean"==typeof e)return{value:e,ok:!0};if("string"==typeof e){if("true"===e)return{value:!0,ok:!0};if("false"===e)return{value:!1,ok:!0}}return"number"==typeof e?{value:0!==e,ok:!0}:{value:!1,ok:!1}}function Pc(e){return Array.isArray(e)?e:"string"==typeof e?e.split(","):null}function Tc(e){return null==e||("string"==typeof e?""===e:Array.isArray(e)?0===e.length:"object"==typeof e&&0===Object.keys(e).length)}const Wc=new Map,Lc={equal:(e,t)=>e===t||jc(e)===jc(t),"not-equal":(e,t)=>e!==t&&jc(e)!==jc(t),contains:(e,t)=>Array.isArray(e)?e.includes(t):"string"==typeof e&&e.includes(jc(t)),"doesnt-contains":(e,t)=>Array.isArray(e)?!e.includes(t):"string"==typeof e&&!e.includes(jc(t)),"greater-than":(e,t)=>{const n=Nc(e),i=Nc(t);return n.ok&&i.ok&&n.value>i.value},"greater-than-or-equal":(e,t)=>{const n=Nc(e),i=Nc(t);return n.ok&&i.ok&&n.value>=i.value},"less-than":(e,t)=>{const n=Nc(e),i=Nc(t);return n.ok&&i.ok&&n.value<i.value},"less-than-or-equal":(e,t)=>{const n=Nc(e),i=Nc(t);return n.ok&&i.ok&&n.value<=i.value},empty:e=>Tc(e),"not-empty":e=>!Tc(e),"is-true":e=>{const t=Mc(e);return t.ok&&t.value},"is-false":e=>{const t=Mc(e);return t.ok&&!t.value},in:(e,t)=>{const n=Pc(t);return null!==n&&n.includes(e)},"not-in":(e,t)=>{const n=Pc(t);return null!==n&&!n.includes(e)},matches:(e,t)=>{if("string"!=typeof e)return!1;const n=function(e){var t;if(Wc.has(e))return null!==(t=Wc.get(e))&&void 0!==t?t:null;let n;try{n=new RegExp(e)}catch(e){n=null}return Wc.set(e,n),n}(jc(t));return null!==n&&n.test(e)}};function Uc(e,t){var n;if(e)return"form"===e.kind&&e.form?t[e.form]:"list"===e.kind?(null!==(n=e.items)&&void 0!==n?n:[]).map((e=>Uc(e,t))):e.value}function Dc(e,t){const n=Lc[e.operator];return!!n&&n(Uc(e.target,t),Uc(e.predicate,t))}function Fc(e,t){const n={};return(null!=e?e:[]).forEach((e=>{var i;(function(e,t){var n;return(null!==(n=e.rules)&&void 0!==n?n:[]).some((e=>function(e,t){var n;const i=null!==(n=e.atomicConditions)&&void 0!==n?n:[];return!!i.length&&(e.logicalOr?i.some((e=>Dc(e,t))):i.every((e=>Dc(e,t))))}(e,t)))})(e,t)&&(null!==(i=e.componentIds)&&void 0!==i?i:[]).forEach((t=>{n[t]=e.action}))})),n}const _c="component-conditions:";function qc(e){return e instanceof HTMLInputElement?"checkbox"===e.type?e.checked:e.value:"checked"in e?e.checked:"value"in e?e.value:void 0}function Bc(e,t){const n=Object.keys(e),i=Object.keys(t);return n.length===i.length&&n.every((n=>e[n]===t[n]))}function Vc(){return{conditions:[],touchedIds:new Set,snapshot:{},applied:{},serverBaseline:{},debounceTimer:null,paused:!1,unsubscribePauseListener:null,inputHandler:()=>{},root:null}}function Kc(e,t,n){const i={};return n.forEach((n=>{e[n]?i[n]=e[n]:t[n]&&(i[n]=t[n])})),i}const Hc=Wi((e=>{var t,n,i,o,r,s;const a=xi(Cs)(e);return s=class extends a{constructor(){super(...arguments),t.add(this),n.set(this,Vc())}applyComponentsState(e,t){t&&(Object.entries(t).forEach((([e,t])=>{or.includes(t)||this.logger.error(`Unknown component action "${t}" for component with id "${e}"`,`Valid actions are ${or.map((e=>`"${e}"`)).join(", ")}`)})),cr(e,{},t))}initRealtimeConditions(e,o){var s,a,d,l;u(this,t,"m",r).call(this);const c=null!==(s=null==o?void 0:o.realtimeComponentsConditions)&&void 0!==s?s:[];if(!c.length)return void this.logger.debug(`${_c} no real-time rules to apply on this screen`);this.logger.info(`${_c} found ${c.length} real-time rule(s) for this screen`);const f={};Object.entries(null!==(a=null==o?void 0:o.form)&&void 0!==a?a:{}).forEach((([e,t])=>{f[`form.${e}`]=t})),function(e){const t=new Set,n=e=>{var i;e&&("form"===e.kind&&e.form?t.add(e.form):"list"===e.kind&&(null!==(i=e.items)&&void 0!==i?i:[]).forEach(n))};return(null!=e?e:[]).forEach((e=>{var t;return(null!==(t=e.rules)&&void 0!==t?t:[]).forEach((e=>{var t;return(null!==(t=e.atomicConditions)&&void 0!==t?t:[]).forEach((e=>{n(e.target),n(e.predicate)}))}))})),t}(c).forEach((t=>{const n=function(e,t){const n=t.startsWith("form.")?t.slice(5):t;return e.querySelector(`[name="${dr(t)}"]`)||e.querySelector(`[name="${dr(n)}"]`)}(e,t);if(!n)return;const i=qc(n);void 0!==i&&(f[t]=i)}));const p=function(e){const t=new Set;return(null!=e?e:[]).forEach((e=>{var n;(null!==(n=e.componentIds)&&void 0!==n?n:[]).forEach((e=>t.add(e)))})),t}(c),v={},g={};Object.entries(null!==(d=null==o?void 0:o.componentsState)&&void 0!==d?d:{}).forEach((([e,t])=>{p.has(e)&&(g[e]=t)})),Object.entries(null!==(l=null==o?void 0:o.serverOnlyComponentsState)&&void 0!==l?l:{}).forEach((([e,t])=>{p.has(e)&&(v[e]=t)}));const m={conditions:c,touchedIds:p,snapshot:f,applied:g,serverBaseline:v,debounceTimer:null,paused:!1,unsubscribePauseListener:null,inputHandler:()=>{},root:e},y=Kc(Fc(c,f),v,p);Bc(g,y)||(m.applied=cr(e,g,y)),m.inputHandler=e=>u(this,t,"m",i).call(this,e),Ac.forEach((t=>{e.addEventListener(t,m.inputHandler,!0)})),this.logger.debug(`${_c} listening for "${Ac.join('" and "')}" events on form fields; ${Object.keys(g).length} component(s) start hidden / disabled / read-only by these rules`);const b=this.nextRequestStatus;if(null==b?void 0:b.subscribe){const e=({isLoading:e})=>{m.paused=e,e&&m.debounceTimer&&(clearTimeout(m.debounceTimer),m.debounceTimer=null)},t=b.subscribe(e);m.unsubscribePauseListener=()=>{var e;null!=t&&(null===(e=b.unsubscribe)||void 0===e||e.call(b,t))}}h(this,n,m,"f")}disconnectedCallback(){var e;null===(e=super.disconnectedCallback)||void 0===e||e.call(this),u(this,t,"m",r).call(this)}},n=new WeakMap,t=new WeakSet,i=function(e){var i,r;const s=u(this,n,"f");if(!s.root||s.paused)return;const a=e.target;if(!a)return;if(null===(i=a.hasAttribute)||void 0===i?void 0:i.call(a,Eo))return;const d=null===(r=a.getAttribute)||void 0===r?void 0:r.call(a,"name");if(!d)return;const l=function(e){return e.startsWith("form.")?e:`form.${e}`}(d);s.snapshot[l]=qc(a),s.debounceTimer&&clearTimeout(s.debounceTimer),s.debounceTimer=setTimeout((()=>{s.debounceTimer=null,u(this,t,"m",o).call(this)}),50)},o=function(){const e=u(this,n,"f");if(!e.root)return;let t;try{t=Kc(Fc(e.conditions,e.snapshot),e.serverBaseline,e.touchedIds)}catch(e){return void this.logger.error(`${_c} failed to evaluate real-time rules — keeping the previous state`,null==e?void 0:e.message)}const i=e.applied;Bc(i,t)||(this.logger.debug(`${_c} form changed — updating components: was ${JSON.stringify(i)}, now ${JSON.stringify(t)}`),e.applied=cr(e.root,i,t))},r=function(){const e=u(this,n,"f");e.debounceTimer&&clearTimeout(e.debounceTimer),e.unsubscribePauseListener&&e.unsubscribePauseListener(),e.root&&Ac.forEach((t=>{e.root.removeEventListener(t,e.inputHandler,!0)})),h(this,n,Vc(),"f")},s})),zc="project-id",Jc="flow-id",Gc=e=>{const t=(e=>{const t=e.getAttribute(zc),n=e.getAttribute(Jc);return t&&n?Array.from(e.ownerDocument.querySelectorAll("descope-wc")).filter((e=>e.getAttribute(zc)===t&&e.getAttribute(Jc)===n)):[]})(e);return t.length>1&&t[0]!==e},Zc=Wi((e=>{var t,n,i,o;const r=xi(Cs)(e);return o=class extends r{constructor(){super(...arguments),t.add(this),n.set(this,void 0)}connectedCallback(){var e;null===(e=super.connectedCallback)||void 0===e||e.call(this),u(this,t,"m",i).call(this)}attributeChangedCallback(e,n,o){var r;null===(r=super.attributeChangedCallback)||void 0===r||r.call(this,e,n,o),n===o||e!==zc&&e!==Jc||u(this,t,"m",i).call(this)}},n=new WeakMap,t=new WeakSet,i=function(){queueMicrotask((()=>{if(!this.isConnected)return;const e=this.getAttribute(zc),t=this.getAttribute(Jc),i=`${e}|${t}`;u(this,n,"f")!==i&&Gc(this)&&(h(this,n,i,"f"),this.logger.warn("Multiple Descope flow components detected on the same page",`The same flow ("${t}") and project ("${e}") are running more than once on this page. This is not supported and may cause the flow to behave unexpectedly.`))}))},o})),Yc=["externalId","email","phone"],Xc=["newPassword","password"],Qc="data-username-anchor",eu=e=>{var t;if(!e)return"";try{const n=null===(t=window.sessionStorage)||void 0===t?void 0:t.getItem(Ao);if(!n)return"";const i=JSON.parse(n);return i.executionId===e&&i.loginId||""}catch(e){return""}},tu=Wi((e=>{var t,n,i,o,r;const s=xi(Cs)(e);return r=class extends s{constructor(){super(...arguments),t.add(this),n.set(this,void 0)}updateScreenUser(e){var r,s,a;h(this,n,{email:null==e?void 0:e.email,loginIds:(null===(r=null==e?void 0:e.loginIds)||void 0===r?void 0:r.length)?e.loginIds:[eu(u(this,t,"a",o))||(null===(a=null===(s=u(this,t,"a",i).sdk)||void 0===s?void 0:s.getLastUserLoginId)||void 0===a?void 0:a.call(s))].filter(Boolean)},"f")}updateUsernameAnchor(){document.querySelectorAll(`[${Qc}="true"]`).forEach((e=>e.remove())),((e,t,n,i)=>{var o;const r=(null==n?void 0:n.email)||(null===(o=null==n?void 0:n.loginIds)||void 0===o?void 0:o[0]);(e=>e.querySelector("descope-new-password")||e.querySelector("descope-password"))(t)?r?(e=>{const t=['input[autocomplete="username"]',...Yc.map((e=>`[name="${e}"]`))].join(", ");return e.some((e=>e.querySelector(t)))})([e,t])?i.debug("Username anchor: screen already has an identifier field"):(i.debug("Username anchor: injecting hidden username input"),e.appendChild((e=>{const t=document.createElement("input");return t.setAttribute("autocomplete","username"),t.setAttribute("name","username"),t.setAttribute("type","email"),t.setAttribute("readonly","true"),t.setAttribute("tabindex","-1"),t.setAttribute("aria-hidden","true"),t.setAttribute(Eo,"true"),t.setAttribute(Qc,"true"),t.setAttribute("value",e),t.value=e,Object.assign(t.style,{position:"absolute",opacity:"0",pointerEvents:"none",height:"0",border:"0"}),t})(r))):i.debug("Username anchor: no user identifier available"):i.debug("Username anchor: no password component on screen")})(this,u(this,t,"a",i).contentRootElement,u(this,n,"f"),this.logger)}captureLastSubmittedLoginId(e={},n){const i=Vr(e,Yc);i&&((e,t)=>{var n;if(e&&t)try{null===(n=window.sessionStorage)||void 0===n||n.setItem(Ao,JSON.stringify({executionId:t,loginId:e}))}catch(e){}})(i,n||u(this,t,"a",o))}storeCredentials(e={}){var t,i,o,r,s,a;const d=Vr(e,Yc)||(null===(t=u(this,n,"f"))||void 0===t?void 0:t.email)||(null===(o=null===(i=u(this,n,"f"))||void 0===i?void 0:i.loginIds)||void 0===o?void 0:o[0]),l=Vr(e,Xc);if(d&&l)try{if(!globalThis.PasswordCredential)return;const e=new globalThis.PasswordCredential({id:d,password:l});null===(a=null===(s=null===(r=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===r?void 0:r.store)||void 0===s?void 0:s.call(r,e))||void 0===a||a.catch((e=>{this.logger.debug("Could not store credentials",null==e?void 0:e.message)}))}catch(e){this.logger.warn("Could not store credentials",e.message)}}},n=new WeakMap,t=new WeakSet,i=function(){return this},o=function(){var e,n;return(null===(n=null===(e=u(this,t,"a",i).flowState)||void 0===e?void 0:e.current)||void 0===n?void 0:n.executionId)||""},r})),nu="data-evp-token",iu='descope-email-field[email-verification="true"]',ou=e=>{e.querySelectorAll(`[${nu}]`).forEach((e=>e.remove()))},ru=Wi((e=>{var t,n,i,o,r,s,a;const d=xi(Cs)(e);return a=class extends d{constructor(){super(...arguments),t.add(this),n.set(this,void 0),i.set(this,!1),o.set(this,0),r.set(this,(e=>{(e=>e.composedPath().some((e=>e instanceof Element&&e.matches(iu))))(e)&&(h(this,i,"focusin"===e.type,"f"),"focusout"===e.type&&h(this,o,Date.now(),"f"))}))}clearEmailVerification(){h(this,n,void 0,"f"),h(this,i,!1,"f"),h(this,o,0,"f"),ou(this)}startEmailVerification(e){var i,o,a;const d=null===(i=u(this,t,"a",s).sdk)||void 0===i?void 0:i.emailVerification;if(!(d&&(()=>{var e,t;return!!(null===(t=null===(e=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===e?void 0:e.brands)||void 0===t?void 0:t.some((({brand:e})=>"Google Chrome"===e)))})()&&(l=e,l.querySelector(iu))&&this.closest("form")))return;var l;null===(o=this.shadowRoot)||void 0===o||o.addEventListener("focusin",u(this,r,"f")),null===(a=this.shadowRoot)||void 0===a||a.addEventListener("focusout",u(this,r,"f"));const c=d.start().then((e=>{var t,i;e.ok&&(null===(t=e.data)||void 0===t?void 0:t.nonce)?u(this,n,"f")===c&&((e,t)=>{const n=document.createElement("input");n.type="hidden",n.setAttribute("autocomplete","email-verification-token"),n.setAttribute(Eo,"true"),n.setAttribute(nu,"true"),n.nonce=t,n.setAttribute("nonce",t),e.appendChild(n)})(this,e.data.nonce):this.logger.warn("Email verification start failed",null===(i=e.error)||void 0===i?void 0:i.errorDescription)})).catch((e=>{this.logger.warn("Email verification start failed",null==e?void 0:e.message)}));h(this,n,c,"f")}emailVerificationToken(e){return c(this,void 0,void 0,(function*(){var t,n;if("true"===e.getAttribute("formnovalidate")||!this.querySelector(`[${nu}]`)||!(null===(n=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector(iu))||void 0===n?void 0:n.value))return"";u(this,i,"f")&&(()=>{var e;let t=document.activeElement;for(;null===(e=null==t?void 0:t.shadowRoot)||void 0===e?void 0:e.activeElement;)t=t.shadowRoot.activeElement;t instanceof HTMLElement&&t.blur()})();const r=u(this,o,"f")+900-Date.now();r>0&&(yield new Promise((e=>{setTimeout(e,r)})));const s=(e=>{const t=e.querySelector(`[${nu}]`),n=e.closest("form");if(!t||!n)return"";let i="";const o=e=>{e.target===n&&(e.preventDefault(),e.stopImmediatePropagation(),i=t.value,t.value="")};window.addEventListener("submit",o,!0);const{noValidate:r}=n;n.noValidate=!0;try{n.requestSubmit()}finally{n.noValidate=r,window.removeEventListener("submit",o,!0)}return i})(this);return s&&ou(this),s}))}},n=new WeakMap,i=new WeakMap,o=new WeakMap,r=new WeakMap,t=new WeakSet,s=function(){return this},a})),su=e=>`${e.screenId}|${e.field}|${e.rule}`,au=()=>{try{return crypto.randomUUID()}catch(e){return`${Date.now()}-${Math.round(1e9*Math.random())}`}},du=(e,t)=>e?e.badInput?"bad-input":e.valueMissing?"required":e.typeMismatch?"email"===t||"url"===t?t:"type-mismatch":e.patternMismatch?"pattern":e.tooShort?"too-short":e.tooLong?"too-long":e.rangeUnderflow||e.rangeOverflow||e.stepMismatch?"range":e.customError?"custom":"unknown":"unknown",lu=Wi((e=>{var t,n,i,o,r,s,a,d,l,c,f,p,v,g,m,y,b,w,$,k;const C=xi(Cs)(e);return k=class extends C{constructor(){super(...arguments),t.add(this),n.set(this,[]),i.set(this,void 0),o.set(this,void 0),r.set(this,new Set),s.set(this,!1),a.set(this,0),d.set(this,void 0),l.set(this,!1),c.set(this,(()=>u(this,t,"m",y).call(this,!1))),f.set(this,(()=>{"hidden"===document.visibilityState&&u(this,t,"m",y).call(this,!0)})),p.set(this,(()=>u(this,t,"m",y).call(this,!0)))}setValidationTrackingEnabled(e){u(this,l,"f")!==e&&(h(this,l,e,"f"),e||u(this,t,"m",m).call(this))}setValidationTrackingSender(e){h(this,d,e,"f")}setValidationTrackingExecution(e){u(this,l,"f")&&e&&u(this,n,"f").length&&(h(this,i,e,"f"),u(this,t,"m",y).call(this,!1))}trackValidationErrors(e,n){var i,o;try{u(this,t,"m",v).call(this,e,n)}catch(e){null===(o=null===(i=this.logger)||void 0===i?void 0:i.debug)||void 0===o||o.call(i,"Failed to track validation errors",String(e))}}teardownValidationTracking(){u(this,t,"m",y).call(this,!1),h(this,a,u(this,a,"f")+1,"f"),u(this,r,"f").forEach(clearTimeout),u(this,r,"f").clear(),u(this,s,"f")&&(h(this,s,!1,"f"),this.removeEventListener("screen-updated",u(this,c,"f")),this.removeEventListener("success",u(this,c,"f")),this.removeEventListener("error",u(this,c,"f")),document.removeEventListener("visibilitychange",u(this,f,"f")),window.removeEventListener("pagehide",u(this,p,"f")))}},n=new WeakMap,i=new WeakMap,o=new WeakMap,r=new WeakMap,s=new WeakMap,a=new WeakMap,d=new WeakMap,l=new WeakMap,c=new WeakMap,f=new WeakMap,p=new WeakMap,t=new WeakSet,v=function(e,o){if(!u(this,l,"f")||!(null==e?void 0:e.length))return;const r=o||{};u(this,t,"m",$).call(this),e.forEach((e=>{if(u(this,n,"f").length>=20)return;const o=((e,t)=>{var n;const i=null===(n=null==e?void 0:e.getAttribute)||void 0===n?void 0:n.call(e,"name");return i?{id:au(),field:i,rule:du(e.validity,e.type),message:e.validationMessage||"",screenId:t.screenId||"",screenName:t.screenName||"",ts:Date.now()}:null})(e,r);if(!o)return;const s=su(o);u(this,n,"f").some((e=>su(e)===s))||(u(this,n,"f").push(o),h(this,i,r.executionId||u(this,i,"f"),"f"),u(this,n,"f").length>=20&&u(this,t,"m",y).call(this,!1))})),u(this,n,"f").length>=20?u(this,t,"m",y).call(this,!1):u(this,t,"m",g).call(this)},g=function(){clearTimeout(u(this,o,"f")),h(this,o,setTimeout((()=>u(this,t,"m",y).call(this,!1)),2e3),"f")},m=function(){clearTimeout(u(this,o,"f")),h(this,a,u(this,a,"f")+1,"f"),u(this,r,"f").forEach(clearTimeout),u(this,r,"f").clear(),h(this,n,[],"f"),h(this,i,void 0,"f")},y=function(e){var r,s;if(clearTimeout(u(this,o,"f")),!u(this,n,"f").length)return void h(this,i,void 0,"f");if(!u(this,i,"f"))return;if(!u(this,d,"f"))return;const l=u(this,n,"f"),c=u(this,i,"f");h(this,n,[],"f"),h(this,i,void 0,"f");try{const n={executionId:c,events:l};e?u(this,d,"f").call(this,n,{keepalive:!0}).catch((()=>{})):u(this,t,"m",b).call(this,n,2,u(this,a,"f"))}catch(e){null===(s=null===(r=this.logger)||void 0===r?void 0:r.debug)||void 0===s||s.call(r,"Failed to send validation events",String(e))}},b=function(e,n,i){u(this,d,"f").call(this,e,{keepalive:!1}).then((o=>{!o.ok&&o.retryable&&n>0&&u(this,t,"m",w).call(this,e,n,i)})).catch((()=>{n>0&&u(this,t,"m",w).call(this,e,n,i)}))},w=function(e,n,i){if(i!==u(this,a,"f"))return;const o=setTimeout((()=>{u(this,r,"f").delete(o),i===u(this,a,"f")&&u(this,t,"m",b).call(this,e,n-1,i)}),800*(2-n+1));u(this,r,"f").add(o)},$=function(){u(this,s,"f")||(h(this,s,!0,"f"),this.addEventListener("screen-updated",u(this,c,"f")),this.addEventListener("success",u(this,c,"f")),this.addEventListener("error",u(this,c,"f")),document.addEventListener("visibilitychange",u(this,f,"f")),window.addEventListener("pagehide",u(this,p,"f")))},k}));var cu,uu,hu,fu,pu,vu,gu,mu,yu,bu,wu,$u,ku,Cu,Su,Iu,Ru,Eu,xu,Ou,Au,Nu,ju,Mu,Pu,Tu,Wu;const Lu=xi(sa,Ws,ha,Hc,Zc,tu,ru,Gs,ca,lu)(HTMLElement);let Uu=class extends Lu{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","locale","debug","storage-prefix","preview","redirect-url","auto-focus","store-last-authenticated-user","refresh-cookie-name","keep-last-authenticated-user-after-logout","validate-on-blur","send-session-token","style-id"]}get adoptedSsoQueryParams(){return u(this,pu,"f")}constructor(e){super(),cu.add(this),this.sdkVersion="4.8.0",hu.set(this,!1),fu.set(this,void 0),pu.set(this,null),this.flowStatus="initial",this.loggerWrapper={error:(e,t="")=>{this.logger.error(e,t,new Error),u(this,cu,"m",Wu).call(this,e,t)},warn:(e,t="")=>{this.logger.warn(e,t)},info:(e,t="",n={})=>{this.logger.info(e,t,n)},debug:(e,t="")=>{this.logger.debug(e,t)}},vu.set(this,new ns),gu.set(this,new ns),mu.set(this,{}),this.getComponentsContext=()=>u(this,mu,"f"),this.nextRequestStatus=new ns({isLoading:!1}),yu.set(this,void 0),bu.set(this,{popstate:u(this,cu,"m",Su).bind(this),componentsContext:u(this,cu,"m",Au).bind(this)}),wu.set(this,void 0),this.getConfig=()=>c(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),Nu.set(this,void 0),ju.set(this,void 0),h(this,wu,e,"f"),u(this,cu,"m",ku).call(this)}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(e){return{}}}get redirectUrl(){return this.getAttribute("redirect-url")||void 0}get debug(){return"true"===this.getAttribute("debug")}get locale(){return this.getAttribute("locale")||void 0}get autoFocus(){var e;const t=null!==(e=this.getAttribute("auto-focus"))&&void 0!==e?e:"true";return"skipFirstScreen"===t?t:"true"===t}get validateOnBlur(){return"true"===this.getAttribute("validate-on-blur")}get storeLastAuthenticatedUser(){var e;return"true"===(null!==(e=this.getAttribute("store-last-authenticated-user"))&&void 0!==e?e:"true")}get refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}get keepLastAuthenticatedUserAfterLogout(){return"true"===this.getAttribute("keep-last-authenticated-user-after-logout")}get storagePrefix(){return this.getAttribute("storage-prefix")||""}get sendSessionToken(){return"true"===this.getAttribute("send-session-token")}get preview(){return!!this.getAttribute("preview")}get formConfig(){return(e=>{try{return ua(JSON.parse(e))}catch(e){return{}}})(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return((e,t)=>Object.fromEntries(Object.entries(e).map((([e,n])=>[e,n[t]]))))(this.formConfig,"value")}get outboundAppId(){return this.getAttribute("outbound-app-id")}get outboundAppScopes(){try{return JSON.parse(this.getAttribute("outbound-app-scopes"))||null}catch(e){return null}}get popupOrigin(){return this.getAttribute("popup-origin")}get customStorage(){return u(this,fu,"f")}set customStorage(e){if(e&&"function"!=typeof e.getItem)throw new Error("Custom storage must have a getItem method");if(e&&"function"!=typeof e.setItem)throw new Error("Custom storage must have a setItem method");if(e&&"function"!=typeof e.removeItem)throw new Error("Custom storage must have a removeItem method");h(this,fu,e,"f"),(e=>{hs=e})(e)}get lazyStart(){return"true"===this.getAttribute("lazy-start")}start(){var e;null===(e=u(this,ju,"f"))||void 0===e||e.call(this),h(this,Nu,Promise.resolve(),"f")}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return c(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"executionContext"in e?e.executionContext:void 0}))}getProjectConfig(){return c(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"projectConfig"in e?e.projectConfig:void 0}))}getFlowConfig(){return c(this,void 0,void 0,(function*(){var e,t;const n=yield this.getProjectConfig(),i=(null===(e=null==n?void 0:n.flows)||void 0===e?void 0:e[this.flowId])||{};return null!==(t=i.version)&&void 0!==t||(i.version=0),i}))}getTargetLocales(){return c(this,void 0,void 0,(function*(){const e=yield this.getFlowConfig();return((null==e?void 0:e.targetLocales)||[]).map((e=>e.toLowerCase()))}))}handleKeyPress(){this.logger.debug("Enable key press handler"),this.rootElement.onkeydown=e=>{var t,n,i;const o=!!(null===(t=this.shadowRoot.activeElement)||void 0===t?void 0:t.getAttribute("href")),r=tr.includes(null!==(i=null===(n=this.shadowRoot.activeElement)||void 0===n?void 0:n.localName)&&void 0!==i?i:"");if("Enter"!==e.key||e.defaultPrevented||o||r)return;e.preventDefault();const s=this.rootElement.querySelectorAll("descope-button");if(1===s.length&&"false"!==s[0].getAttribute("auto-submit"))return void s[0].click();const a=Array.from(s).filter((e=>"true"===e.getAttribute("auto-submit")));if(1===a.length)return void a[0].click();const d=Array.from(s).filter((e=>"button"===e.getAttribute("data-type")));if(1===d.length)"false"!==d[0].getAttribute("auto-submit")&&d[0].click();else if(0===d.length){const e=Array.from(s).filter((e=>"sso"===e.getAttribute("data-type")));1===e.length&&"false"!==e[0].getAttribute("auto-submit")&&e[0].click()}}}disableKeyPressHandler(){this.logger.debug("Disable key press handler"),this.rootElement.onkeydown=null}getComponentsVersion(){return c(this,void 0,void 0,(function*(){var e;const t=yield this.getConfig();return("projectConfig"in t?null===(e=t.projectConfig)||void 0===e?void 0:e.componentsVersion:{})||(this.logger.error("Did not get components version, using latest version"),"latest")}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;if(this.flowStatus="loading",["ready","error","success"].forEach((e=>this.addEventListener(e,(()=>{this.flowStatus=e})))),yield null===(t=e.init)||void 0===t?void 0:t.call(this),u(this,gu,"f").subscribe(u(this,cu,"m",Tu).bind(this)),u(this,gu,"f").update({isDebug:this.debug}),u(this,cu,"m",Cu).call(this),yield u(this,cu,"m",xu).call(this))return void this.loggerWrapper.error("This SDK version does not support your flows version","Make sure to upgrade your flows to the latest version or use an older SDK version");const n=yield this.getConfig();if("isMissingConfig"in n&&n.isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");const{executionId:i,stepId:o,token:r,code:s,isPopup:a,exchangeError:d,redirectAuthCallbackUrl:l,redirectAuthBackupCallbackUri:c,redirectAuthCodeChallenge:f,redirectAuthInitiator:p,ssoQueryParams:v,adoptedSsoQueryParams:g}=Lr(this.flowId,this.projectId,this.loggerWrapper);h(this,pu,null!=g?g:null,"f"),window.addEventListener("popstate",u(this,bu,"f").popstate),window.addEventListener("components-context",u(this,bu,"f").componentsContext),u(this,vu,"f").subscribe(u(this,cu,"m",Eu).bind(this)),u(this,vu,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenantId,redirectUrl:this.redirectUrl,locale:this.locale,stepId:o,executionId:i,token:r,code:s,isPopup:a,exchangeError:d,redirectAuthCallbackUrl:l,redirectAuthBackupCallbackUri:c,redirectAuthCodeChallenge:f,redirectAuthInitiator:p},v)),h(this,hu,!0,"f")}))}disconnectedCallback(){var e;u(this,vu,"f").unsubscribeAll(),u(this,gu,"f").unsubscribeAll(),u(this,cu,"m",Pu).call(this),window.removeEventListener("popstate",u(this,bu,"f").popstate),window.removeEventListener("components-context",u(this,bu,"f").componentsContext),null===(e=super.disconnectedCallback)||void 0===e||e.call(this)}attributeChangedCallback(e,t,n){var i;if(null===(i=super.attributeChangedCallback)||void 0===i||i.call(this,e,t,n),this.shadowRoot.isConnected&&u(this,hu,"f")&&t!==n&&uu.observedAttributes.includes(e)){u(this,cu,"m",Cu).call(this);const i=null===t;u(this,vu,"f").update((({stepId:t,executionId:o})=>{let r=t,s=o;return i||(s=null,r=null,Pr()),{[Wr(e)]:n,stepId:r,executionId:s}})),u(this,gu,"f").update({isDebug:this.debug})}}};var Du,Fu,_u,qu,Bu,Vu,Ku,Hu,zu,Ju,Gu,Zu,Yu,Xu,Qu,eh,th,nh,ih,oh,rh,sh,ah,dh,lh,ch,uh,hh,fh,ph,vh,gh,mh,yh,bh,wh,$h,kh,Ch,Sh,Ih,Rh,Eh,xh,Oh,Ah,Nh;uu=Uu,hu=new WeakMap,fu=new WeakMap,pu=new WeakMap,vu=new WeakMap,gu=new WeakMap,mu=new WeakMap,yu=new WeakMap,bu=new WeakMap,wu=new WeakMap,Nu=new WeakMap,ju=new WeakMap,cu=new WeakSet,$u=function(){this.injectStyle("\n :host {\n\t\t\twidth: 100%;\n display: block;\n\t\t}\n\n\t\t#root {\n\t\t\theight: 100%;\n display: flex;\n flex-direction: column;\n\t\t}\n\n #content-root {\n all: initial;\n transition: opacity 200ms ease-in-out;\n }\n\n\t\t#root[data-theme] {\n\t\t\tbackground-color: transparent;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1!important;\n\t\t}\n\n .hidden {\n display: none;\n }\n ")},ku=function(){u(this,cu,"m",$u).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},Cu=function(){const e=["base-url","tenant","locale","debug","redirect-url","auto-focus","store-last-authenticated-user","refresh-cookie-name","keep-last-authenticated-user-after-logout","preview","storage-prefix","form","client","validate-on-blur","send-session-token","style-id","outbound-app-id","outbound-app-scopes","theme-override"];uu.observedAttributes.forEach((t=>{if(!e.includes(t)&&!this[Wr(t)])throw Error(`${t} cannot be empty`)}))},Su=function(){const{stepId:e,executionId:t}=Mr(this.flowId);t&&u(this,vu,"f").update({stepId:e,executionId:t})},Iu=function(e,t){bi&&"function"==typeof bi||this.logger.error("SDK was not loaded properly",bi,JSON.stringify(bi));const n=Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},uu.sdkConfigOverrides),{projectId:e,baseUrl:t});u(this,fu,"f")&&(n.customStorage=u(this,fu,"f")),this.sdk=bi(n);const i={start:1,next:7};["start","next"].forEach((e=>{const t=function(e,t,n){return(...i)=>c(this,void 0,void 0,(function*(){let o;const r=n+1;for(let s=0;s<r;s++)try{return yield e(...i)}catch(e){o=e,s<n&&(yield new Promise((e=>{setTimeout(e,t*Math.pow(2,s+1))})))}throw o}))}(this.sdk.flow[e],1e3,3);this.sdk.flow[e]=(...n)=>c(this,void 0,void 0,(function*(){const o=[...n],r=i[e],s=u(this,cu,"m",Ru).call(this,o[r]);void 0!==s&&(o[r]=s);try{return yield t(...o)}catch(t){return this.logger.error(`Error in sdk flow ${e} function`,t),{error:{errorCode:yo,errorDescription:t.toString()}}}}))}));const o=this.sdk.flow.start;this.sdk.flow.start=(...e)=>c(this,void 0,void 0,(function*(){return yield u(this,cu,"m",Mu).call(this),o.apply(this.sdk.flow,e)}))},Ru=function(e){if(!this.sendSessionToken)return e;const t=null==Rn?void 0:Rn(this.storagePrefix);return t?Object.assign(Object.assign({},null!=e?e:{}),{sessionJwt:t}):e},Eu=function(e,t,n){return c(this,void 0,void 0,(function*(){const{projectId:t,baseUrl:i}=e;if(n("projectId")||n("baseUrl")){if(!t)return;u(this,cu,"m",Iu).call(this,t,i)}u(this,wu,"f").call(this,e)}))},xu=function(){return c(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield u(this,cu,"m",Ou).call(this))}))},Ou=function(){return c(this,void 0,void 0,(function*(){const e=function({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:i}){const o=new URL($o||i||"https://static.descope.com/pages");return o.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(o.pathname,e,n,t),o.toString()}({projectId:this.projectId,filename:"config.json",assetsFolder:"v2-alpha",baseUrl:this.baseStaticUrl});try{return yield function(e,t){return c(this,void 0,void 0,(function*(){const n=yield fetch(e,{cache:"default"});if(!n.ok)throw Error(`Error fetching URL ${e} [${n.status}]`);return{body:yield n[t](),headers:Object.fromEntries(n.headers.entries())}}))}(e,"json"),!0}catch(e){return!1}}))},Au=function(e){h(this,mu,Object.assign(Object.assign({},u(this,mu,"f")),e.detail),"f")},Mu=function(){return this.lazyStart?(u(this,Nu,"f")||h(this,Nu,new Promise((e=>{h(this,ju,e,"f")})),"f"),u(this,Nu,"f")):Promise.resolve()},Pu=function(){var e;null===(e=u(this,yu,"f"))||void 0===e||e.remove(),h(this,yu,null,"f")},Tu=function(e){return c(this,arguments,void 0,(function*({isDebug:e}){e?(h(this,yu,document.createElement("descope-debugger"),"f"),Object.assign(u(this,yu,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return DI})),document.body.appendChild(u(this,yu,"f"))):u(this,cu,"m",Pu).call(this)}))},Wu=function(e,t){var n;e&&this.debug&&(null===(n=u(this,yu,"f"))||void 0===n||n.updateData({title:e,description:t}))},Uu.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"4.8.0"}};const jh="__descope_webauthn_timed_out__";let Mh=class e extends Uu{static set sdkConfigOverrides(e){Uu.sdkConfigOverrides=e}static get sdkConfigOverrides(){return Uu.sdkConfigOverrides}constructor(){const t=new ns({deferredRedirect:!1,deferredPolling:!1});super(t.update.bind(t)),Du.add(this),this.stepState=new ns({}),Fu.set(this,void 0),_u.set(this,null),qu.set(this,null),Bu.set(this,new Map),Vu.set(this,{visibilitychange:u(this,Du,"m",Ku).bind(this)}),this.bridgeVersion=e.bridgeVersion,Hu.set(this,void 0),this.nativeCallbacks={},eh.set(this,!1),this.handleRedirect=e=>{window.location.assign(e)},ih.set(this,(e=>{e&&this.clearEmailVerification();const t=()=>{this.contentRootElement.classList.toggle("hidden",e),this.slotElement.classList.toggle("hidden",!e),e&&(this.contentRootElement.innerHTML="")};e&&this.contentRootElement.hasChildNodes()?u(this,Du,"m",oh).call(this,t):t()})),rh.set(this,((e,t,n,i,o=!1)=>{const r=[bo,"E103202",wo];if(this.flowState.current.action===Jo){if(u(this,ah,"f").call(this)&&document.hidden)return this.logger.debug("polling - Deferring polling until in foreground"),void this.flowState.update({deferredPolling:!0});this.logger.debug("polling - Scheduling polling request");const s=Date.now(),a=o?500:2e3;h(this,Fu,setTimeout((()=>c(this,void 0,void 0,(function*(){var d,l;this.logger.debug("polling - Calling next");const c=this.sdk.flow.next(e,t,er,n,i,{}),h=document.hidden&&!o&&Date.now()-s>a+500;let f;h&&this.logger.debug("polling - The polling seems to be throttled");try{const e=h?1e3:6e3;f=yield Fr(e,c)}catch(d){return this.logger.warn(`polling - The ${h?"throttled fetch":"fetch"} call timed out or was aborted`),void u(this,rh,"f").call(this,e,t,n,i,h)}if((null===(d=null==f?void 0:f.error)||void 0===d?void 0:d.errorCode)===yo)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void u(this,rh,"f").call(this,e,t,n,i);this.logger.debug("polling - Got a response"),(null==f?void 0:f.error)&&this.logger.debug("polling - Response has an error",JSON.stringify(f.error,null,4)),(null===(l=null==f?void 0:f.error)||void 0===l?void 0:l.errorCode)&&r.includes(f.error.errorCode)?this.logger.debug("polling - Stopping polling due to error"):u(this,rh,"f").call(this,e,t,n,i),u(this,dh,"f").call(this,f)}))),a),"f")}})),sh.set(this,(()=>{clearTimeout(u(this,Fu,"f")),h(this,Fu,null,"f")})),ah.set(this,(()=>!!window.descopeBridge||/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))),dh.set(this,(e=>{var t,n,i,o,r,s,a,d,l,c,f,p,v;if(!(null==e?void 0:e.ok)){const a=null===(t=null==e?void 0:e.response)||void 0===t?void 0:t.url,d=`${null===(n=null==e?void 0:e.response)||void 0===n?void 0:n.status} - ${null===(i=null==e?void 0:e.response)||void 0===i?void 0:i.statusText}`;u(this,Du,"m",Ah).call(this,"error",(null==e?void 0:e.error)||{errorCode:"J151001",errorDescription:d,errorMessage:a}),this.loggerWrapper.error((null===(o=null==e?void 0:e.error)||void 0===o?void 0:o.errorDescription)||a,(null===(r=null==e?void 0:e.error)||void 0===r?void 0:r.errorMessage)||d);const l=null===(s=null==e?void 0:e.error)||void 0===s?void 0:s.errorCode;return void("E102004"!==l&&l!==bo&&l!==wo||!this.isRestartOnError||u(this,Du,"m",Qu).call(this))}null===(d=null===(a=e.data)||void 0===a?void 0:a.runnerLogs)||void 0===d||d.forEach((e=>{const{level:t,title:n,log:i}=e;t&&this.loggerWrapper[t]?this.loggerWrapper[t](n,i):this.loggerWrapper.info(n,i)}));const g=null===(f=null===(c=null===(l=e.data)||void 0===l?void 0:l.screen)||void 0===c?void 0:c.state)||void 0===f?void 0:f.errorText;(null===(p=e.data)||void 0===p?void 0:p.error)?this.loggerWrapper.error(`[${e.data.error.code}]: ${e.data.error.description}`,`${g?`${g} - `:""}${e.data.error.message}`):g&&this.loggerWrapper.error(g);const{status:m,authInfo:y,lastAuth:b,action:w,openInNewTabUrl:$}=e.data;if(w!==Jo&&u(this,sh,"f").call(this),"completed"===m){this.storeLastAuthenticatedUser&&ys(Object.assign(Object.assign({},b),{lastUsedPerScreen:bs()})),ws(this.loggerWrapper);const t=Object.assign({},y);return e.data.output&&Object.keys(e.data.output).length>0&&(t.flowOutput=e.data.output),this.setValidationTrackingExecution(e.data.executionId),Er(this.projectId,this.flowId),void u(this,Du,"m",Ah).call(this,"success",t)}this.storeLastAuthenticatedUser&&ys(b,!0),$&&window.open($,"_blank");const{executionId:k,stepId:C,stepName:S,screen:I,redirect:R,webauthn:E,error:x,samlIdpResponse:O,wsFedIdpResponse:A,nativeResponse:N}=e.data,j=Date.now();w!==Jo?(this.loggerWrapper.info(`Step "${S||`#${C}`}" is ${m}`,"",{screen:I,status:m,stepId:C,stepName:S,action:w,error:x}),(null===(v=I.state)||void 0===v?void 0:v.clientScripts)&&h(this,qu,this.loadSdkScripts(I.state.clientScripts),"f"),this.flowState.update({stepId:C,stepName:S,executionId:k,action:w,redirectTo:null==R?void 0:R.url,redirectIsPopup:null==R?void 0:R.isPopup,screenId:null==I?void 0:I.id,screenState:null==I?void 0:I.state,webauthnTransactionId:null==E?void 0:E.transactionId,webauthnOptions:null==E?void 0:E.options,samlIdpResponseUrl:null==O?void 0:O.url,samlIdpResponseSamlResponse:null==O?void 0:O.samlResponse,samlIdpResponseRelayState:null==O?void 0:O.relayState,wsFedIdpResponseUrl:null==A?void 0:A.url,wsFedIdpResponseWresult:null==A?void 0:A.wresult,wsFedIdpResponseWctx:null==A?void 0:A.wctx,nativeResponseType:null==N?void 0:N.type,nativePayload:null==N?void 0:N.payload,reqTimestamp:j})):this.flowState.update({action:w,reqTimestamp:j})})),lh.set(this,Ur((()=>c(this,void 0,void 0,(function*(){var e;try{const t=yield this.sdk.webauthn.signIn.start("",window.location.origin);return t.ok||this.loggerWrapper.warn("Webauthn start failed",null===(e=null==t?void 0:t.error)||void 0===e?void 0:e.errorMessage),t.data}catch(e){this.loggerWrapper.warn("Webauthn start failed",e.message)}}))))),fh.set(this,void 0),ph.set(this,void 0),wh.set(this,null),Sh.set(this,Kr(((e,t,n)=>c(this,void 0,void 0,(function*(){var i;if("true"!==e.getAttribute("loading")&&"true"!==e.getAttribute("disabled")){if("true"===e.getAttribute("formnovalidate")||u(this,Du,"m",yh).call(this)){const o=null==e?void 0:e.getAttribute("id");u(this,Du,"m",Eh).call(this,e,o,n);const r=u(this,Du,"m",$h).call(this,e);try{const n=yield u(this,Du,"m",bh).call(this),r=(e=>Array.from((null==e?void 0:e.attributes)||[]).reduce(((e,t)=>{var n;const i=null===(n=new RegExp("^data-descope-(\\S+)$").exec(t.name))||void 0===n?void 0:n[1];return i?Object.assign(e,{[i]:t.value}):e}),{}))(e);this.nextRequestStatus.update({isLoading:!0});const s=yield this.emailVerificationToken(e),a=Object.assign(Object.assign(Object.assign(Object.assign({},r),n),{origin:u(this,Du,"a",mh)}),s&&{evpToken:s}),d=yield t(o,a);this.nextRequestStatus.update({isLoading:!1}),this.captureLastSubmittedLoginId(n,null===(i=null==d?void 0:d.data)||void 0===i?void 0:i.executionId),this.storeCredentials(n)}catch(e){throw r(),e}}}else this.loggerWrapper.debug("Submit already in flight, ignoring")}))))),this.flowState=t,this.setValidationTrackingSender(((e,t)=>c(this,[e,t],void 0,(function*({executionId:e,events:t},{keepalive:n}){const i=yield this.sdk.flow.event(e,t,n);return{ok:i.ok,retryable:i.code>=500||429===i.code}}))))}nativeResume(e,t){var n,i,o,r,s,a;const d=JSON.parse(t);if("oauthWeb"===e||"sso"===e){let e,{exchangeCode:t}=d;if(!t){const o=new URL(d.url);t=null===(n=o.searchParams)||void 0===n?void 0:n.get(So),e=(null===(i=o.searchParams)||void 0===i?void 0:i.get(Ro))||void 0}null===(r=(o=this.nativeCallbacks).complete)||void 0===r||r.call(o,{exchangeCode:t,exchangeError:e,idpInitiated:!0})}else if("magicLink"===e){const e=new URL(d.url),t=e.searchParams.get("t"),n=e.searchParams.get(Co).split("_").pop();u(this,sh,"f").call(this),this.flowState.update({token:t,stepId:n,action:void 0})}else if("beforeScreen"===e){const{screenResolve:e}=this.nativeCallbacks;this.nativeCallbacks.screenResolve=null;const{override:t}=d;t||(this.nativeCallbacks.screenNext=null),null==e||e(t)}else if("resumeScreen"===e){const{interactionId:e,form:t}=d,{screenNext:n}=this.nativeCallbacks;this.nativeCallbacks.screenNext=null,null==n||n(e,t)}else null===(a=(s=this.nativeCallbacks).complete)||void 0===a||a.call(s,d)}loadSdkScriptsModules(){const e=this.shadowRoot.querySelectorAll("div[data-script-id]");return Array.from(e).map((e=>e.moduleRes)).filter((e=>!!e))}loadSdkScripts(e){const t=this.preview?null==e?void 0:e.filter((e=>"clientSignals"!==e.id)):e;if(!(null==t?void 0:t.length))return null;const n=(e,t)=>n=>{this.dispatchEvent(new CustomEvent("components-context",{detail:{[Zr(e.id,e.resultKey)]:n},bubbles:!0,composed:!0})),t(e.id)};this.loggerWrapper.debug(`Preparing to load scripts: ${t.map((e=>e.id)).join(", ")}`);const i=e=>c(this,void 0,void 0,(function*(){var t,o,r;const s=this.shadowRoot.querySelector(`[data-script-id="${e.id}"]`);if(s){this.loggerWrapper.debug("Script already loaded",e.id);const{moduleRes:n}=s;return null===(t=null==n?void 0:n.start)||void 0===t||t.call(n),n}if(!(null===(o=globalThis.descope)||void 0===o?void 0:o[e.id])){const t=u(this,Bu,"f").get(e.id);if(t)return yield t,i(e);const n=this.injectNpmLib("@descope/flow-scripts","1.0.22",`dist/${e.id}.js`);u(this,Bu,"f").set(e.id,n);try{yield n}finally{u(this,Bu,"f").delete(e.id)}}const a=null===(r=globalThis.descope)||void 0===r?void 0:r[e.id];return new Promise(((t,i)=>{try{const i=a(e.initArgs,{baseUrl:this.baseUrl,ref:this},n(e,t),this.loggerWrapper);if(i){const n=document.createElement("div");n.setAttribute("data-script-id",e.id),n.moduleRes=i,this.shadowRoot.appendChild(n);const o=this.nextRequestStatus.subscribe((()=>{var t;this.loggerWrapper.debug("Stopping script",e.id),(null===(t=i.stop)||void 0===t?void 0:t.call(i))&&(this.nextRequestStatus.unsubscribe(o),this.loggerWrapper.debug("Removing script",e.id),this.shadowRoot.removeChild(n))}));"function"==typeof i.present&&t(e.id)}}catch(t){i(t)}}))})),o=Promise.all((null!=t?t:[]).map((e=>i(e).catch((t=>(this.loggerWrapper.warn(`Sdk script ${e.id} failed to load, continuing without it`,null==t?void 0:t.message),null))))));let r;const s=new Promise((e=>{r=setTimeout((()=>{this.loggerWrapper.warn("SDK scripts loading timeout"),e(!0)}),5e3)}));return Promise.race([o,s]).finally((()=>clearTimeout(r))).catch((e=>(this.loggerWrapper.warn("Sdk scripts failed to load, continuing without them",null==e?void 0:e.message),null)))}get isDismissScreenErrorOnInput(){return"true"===this.getAttribute("dismiss-screen-error-on-input")}init(){var e,t;if(!window.descopeBridge)return this._init();this.lazyInit=this._init,h(this,Hu,null===(t=null===(e=null===window||void 0===window?void 0:window.descopeBridge)||void 0===e?void 0:e.registerFlow)||void 0===t?void 0:t.call(e,this),"f")}_init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t,n;this.shadowRoot.isConnected&&(null===(t=this.flowState)||void 0===t||t.subscribe(this.onFlowChange.bind(this)),u(this,Du,"m",Yu).call(this),window.addEventListener("visibilitychange",u(this,Vu,"f").visibilitychange)),yield null===(n=e.init)||void 0===n?void 0:n.call(this)}))}disconnectedCallback(){var e,t,n;super.disconnectedCallback(),this.teardownValidationTracking(),u(this,Hu,"f")&&(null===(t=null===(e=window.descopeBridge)||void 0===e?void 0:e.unregisterFlow)||void 0===t||t.call(e,u(this,Hu,"f")),h(this,Hu,void 0,"f")),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),u(this,sh,"f").call(this),null===(n=u(this,_u,"f"))||void 0===n||n.abort(),h(this,_u,null,"f"),this.clearEmailVerification(),window.removeEventListener("visibilitychange",u(this,Vu,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return c(this,void 0,void 0,(function*(){let n;const i=Hi(e),o=yield this.getTargetLocales();return o.includes(i.locale)?n=`${t}-${i.locale}.html`:o.includes(i.fallback)&&(n=`${t}-${i.fallback}.html`),n}))}getPageContent(e,t){return c(this,void 0,void 0,(function*(){if(t)try{const{body:e}=yield this.fetchStaticResource(t,"text");return e}catch(n){this.loggerWrapper.error(`Failed to fetch flow page from ${t}. Fallback to url ${e}`,n)}try{const{body:t}=yield this.fetchStaticResource(e,"text");return t}catch(e){this.loggerWrapper.error("Failed to fetch flow page",e.message)}return null}))}onFlowChange(e,t,n){return c(this,void 0,void 0,(function*(){var i,o;const{projectId:r,flowId:s,tenant:a,stepId:d,executionId:f,action:p,screenId:v,screenState:g,redirectTo:m,redirectIsPopup:y,redirectUrl:b,token:w,code:$,isPopup:k,exchangeError:C,webauthnTransactionId:S,webauthnOptions:I,redirectAuthCodeChallenge:R,redirectAuthCallbackUrl:E,redirectAuthBackupCallbackUri:x,redirectAuthInitiator:O,locale:A,samlIdpResponseUrl:N,samlIdpResponseSamlResponse:j,samlIdpResponseRelayState:M,wsFedIdpResponseUrl:P,wsFedIdpResponseWresult:T,wsFedIdpResponseWctx:W,nativeResponseType:L,nativePayload:U,reqTimestamp:D}=e,F=l(e,["projectId","flowId","tenant","stepId","executionId","action","screenId","screenState","redirectTo","redirectIsPopup","redirectUrl","token","code","isPopup","exchangeError","webauthnTransactionId","webauthnOptions","redirectAuthCodeChallenge","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthInitiator","locale","samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState","wsFedIdpResponseUrl","wsFedIdpResponseWresult","wsFedIdpResponseWctx","nativeResponseType","nativePayload","reqTimestamp"]);let _,q,B;n("executionId")&&f&&((e,t,n,i)=>{var o,r;const s=(e=>{const t=Object.assign({},e);return delete t.oidcLoginHint,delete t.samlIdpUsername,t})(t);if(e&&vr(s)){try{const t={params:s,ts:null!==(o=kr(n,i))&&void 0!==o?o:Date.now(),projectId:n};null===(r=Sr())||void 0===r||r.setItem(Cr(e),JSON.stringify(t))}catch(e){}Ir()}})(Nr(f),mr(F),r,s);const V=(()=>{const e=ps(vs);if(!e){const e=Math.floor(100*Math.random()+1);return fs(vs,e.toString()),e}return Number(e)})(),{outboundAppId:K,outboundAppScopes:H}=this,z=this.sdk.getLastUserLoginId();n("flowId")&&this.setValidationTrackingEnabled(!1);const J=yield this.getFlowConfig();u(this,Du,"m",vh).call(this,J,f,n);const G=yield this.getProjectConfig(),Z=Object.entries(G.flows||{}).reduce(((e,[t,n])=>(e[t]=n.version,e)),{}),Y=E&&R?{callbackUrl:E,codeChallenge:R,backupCallbackUri:x}:void 0,X=this.nativeOptions?{platform:this.nativeOptions.platform,bridgeVersion:this.nativeOptions.bridgeVersion,oauthProvider:this.nativeOptions.oauthProvider,oauthRedirect:this.nativeOptions.oauthRedirect,magicLinkRedirect:this.nativeOptions.magicLinkRedirect,ssoRedirect:this.nativeOptions.ssoRedirect,externalAuthRedirect:this.nativeOptions.externalAuthRedirect}:void 0;let Q={};if(!f){ws(this.loggerWrapper);const e=[...J.clientScripts||[],...J.sdkScripts||[]];if(J.conditions){let t=[];({startScreenId:_,conditionInteractionId:B,startScreenName:q,clientScripts:t,componentsConfig:Q}=((e,t)=>{const n=null==t?void 0:t.find((({key:t,operator:n,predicate:i})=>{var o;if("ELSE"===t)return!0;const r=null===(o=gs[t])||void 0===o?void 0:o[n];return!!(null==r?void 0:r(e,i))}));return n?{startScreenId:n.met.screenId,startScreenName:n.met.screenName,conditionInteractionId:n.met.interactionId,clientScripts:n.met.clientScripts,componentsConfig:n.met.componentsConfig}:{}})({loginId:z,code:$,token:w,abTestingKey:V,lastAuth:ms(z,this.loggerWrapper)},J.conditions)),e.push(...t||[])}else J.condition?({startScreenId:_,startScreenName:q,conditionInteractionId:B}=((e,t)=>{var n;const i=null===(n=gs[null==e?void 0:e.key])||void 0===n?void 0:n[e.operator];if(!i)return{};const o=i(t,e.predicate)?e.met:e.unmet;return{startScreenId:null==o?void 0:o.screenId,startScreenName:null==o?void 0:o.screenName,conditionInteractionId:null==o?void 0:o.interactionId}})(J.condition,{loginId:z,code:$,token:w,abTestingKey:V,lastAuth:ms(z,this.loggerWrapper)})):(q=J.startScreenName,_=J.startScreenId);if(h(this,fh,_,"f"),h(this,ph,q,"f"),h(this,qu,this.loadSdkScripts(e),"f"),J.fingerprintEnabled&&J.fingerprintKey?yield Tn(J.fingerprintKey,this.baseUrl):cn(Mn),!_r(_,F)){const e=yield this.sdk.flow.start(s,Object.assign(Object.assign(Object.assign(Object.assign({tenant:a,redirectAuth:Y},F),{client:this.client}),b&&{redirectUrl:b}),{lastAuth:ms(z,this.loggerWrapper),preview:this.preview,abTestingKey:V,locale:Hi(A).locale,nativeOptions:X,outboundAppId:K,outboundAppScopes:H}),B,"",G.componentsVersion,Z,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:u(this,Du,"a",mh)},this.formConfigValues),$?{exchangeCode:$,idpInitiated:!0}:{}),F.descopeIdpInitiated&&{idpInitiated:!0}),w?{token:w}:{}),F.oidcLoginHint?{externalId:F.oidcLoginHint}:{}));return u(this,dh,"f").call(this,e),void("completed"!==(null===(i=null==e?void 0:e.data)||void 0===i?void 0:i.status)&&this.flowState.update({code:void 0,token:void 0}))}}if(this.loggerWrapper.debug("Before popup postmessage send",JSON.stringify({isPopup:k,code:$,exchangeError:C,isCodeChanged:n("code"),isExchangeErrorChanged:n("exchangeError")})),k&&(n("code")&&$||n("exchangeError")&&C))return void u(this,Du,"m",Nh).call(this,f,$,C);if(f&&(n("token")&&w||n("code")&&$||n("exchangeError")&&C)){const e=yield this.sdk.flow.next(f,d,Qo,J.version,G.componentsVersion,{token:w,exchangeCode:$,exchangeError:C,origin:u(this,Du,"a",mh)});return u(this,dh,"f").call(this,e),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(p===Xo&&N&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>n(e)))){if(!j)return void this.loggerWrapper.error("Did not get saml idp params data to load");((e,t,n,i)=>{const o=document.createElement("form");o.method="POST",o.action=e,o.appendChild(qr("SAMLResponse",t,"saml-response")),o.appendChild(qr("RelayState",n,"saml-relay-state")),document.body.appendChild(o),i(o)})(N,j,M||"",Br)}if(p===Xo&&P&&["wsFedIdpResponseUrl","wsFedIdpResponseWresult","wsFedIdpResponseWctx"].some((e=>n(e)))){if(!T)return void this.loggerWrapper.error("Did not get wsfed idp params data to load");((e,t,n,i)=>{const o=document.createElement("form");o.method="POST",o.action=e,o.appendChild(qr("wa","wsignin1.0")),o.appendChild(qr("wresult",t)),o.appendChild(qr("wctx",n)),document.body.appendChild(o),i(o)})(P,T,W||"",Br)}if(p===zo&&(n("redirectTo")||n("deferredRedirect"))){if(!m)return void this.loggerWrapper.error("Did not get redirect url");if("no-op"===m)return;if("android"===O&&document.hidden)return void this.flowState.update({deferredRedirect:!0});if(this.loggerWrapper.debug(`Redirect is popup ${y}`),y){this.loggerWrapper.debug("Opening redirect in popup");const e=((e,t,n,i)=>{const o=void 0!==window.screenLeft?window.screenLeft:window.screen.left,r=void 0!==window.screenTop?window.screenTop:window.screen.top,s=((window.innerWidth||document.documentElement.clientWidth||window.screen.width)-n)/2+o,a=((window.innerHeight||document.documentElement.clientHeight||window.screen.height)-i)/2+r,d=function(){const e=navigator.userAgent||"",t=/\b(iPhone)\b/.test(e),n=/Safari/.test(e)&&!/CriOS|FxiOS|OPiOS|EdgiOS|Chrome|Chromium/.test(e);return t&&n}()?"about:blank":"",l=window.open(d,t,`width=${n},height=${i},top=${a},left=${s},scrollbars=yes,resizable=yes`);return l.location.href=e,l.focus(),l})(m,"?",598,700),t=this.shouldUsePopupPostMessage();t&&(e.name=`descope-wc|${window.location.origin}`),this.loggerWrapper.debug("Popup communication method: "+(t?"postMessage":"BroadcastChannel"));let n=!1;const i=e=>{this.loggerWrapper.debug("Received popup message",JSON.stringify(e.data));const i=t?this.popupOrigin:window.location.origin;if(e.origin!==i)return void this.loggerWrapper.debug(`Ignoring message from unexpected origin. received: "${e.origin}", expected: "${i}"`);const{action:o,data:r}=e.data||{};"code"===o&&(n=!0,this.flowState.update({code:r.code,exchangeError:r.exchangeError}))};let o;this.loggerWrapper.debug("Starting popup closed detection");const r=setInterval((()=>{e.closed&&(this.loggerWrapper.debug("Popup closed, dispatching popupclosed event"),clearInterval(r),u(this,Du,"m",Ah).call(this,"popupclosed",{abandoned:!n}),this.loggerWrapper.debug("Cleaning up popup listeners"),null==o||o())}),1e3);if(t)window.addEventListener("message",i),o=()=>{this.loggerWrapper.debug("Cleaning up popup postMessage listener"),window.removeEventListener("message",i)};else{this.loggerWrapper.debug("Creating broadcast channel");const e=new BroadcastChannel(f);e.onmessage=i,o=()=>{this.loggerWrapper.debug("Closing channel"),e.close()}}}else((e,t,n,i,o)=>{var r;if(null==n?void 0:n.oidcErrorRedirectUri){try{const t=new URL(e,window.location.href),i=new URL(n.oidcErrorRedirectUri);if(t.origin!==i.origin||t.pathname!==i.pathname)return}catch(e){return}Er(i,o);try{t&&(null===(r=Sr())||void 0===r||r.removeItem(Cr(t)))}catch(e){}}})(m,Nr(f),Object.assign(Object.assign({},this.adoptedSsoQueryParams),mr(F)),r,s),this.handleRedirect(m),this.flowState.update({redirectTo:"no-op"}),u(this,Du,"m",Ah).call(this,"popupclosed",{});return}if(p===Go||p===Zo){if(!S||!I)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");null===(o=u(this,_u,"f"))||void 0===o||o.abort(),h(this,_u,null,"f");const e=yield u(this,Du,"m",nh).call(this,p,I),t=yield this.sdk.flow.next(f,d,Qo,J.version,G.componentsVersion,Object.assign({transactionId:S},e));u(this,dh,"f").call(this,t)}if(p===Yo)return this.nativeCallbacks.complete=e=>c(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(f,d,Qo,J.version,G.componentsVersion,e);u(this,dh,"f").call(this,t)})),u(this,Du,"m",Gu).call(this,L,U),void setTimeout((()=>{this.dispatchEvent(new Event("popupclosed"))}),500);if((n("action")||n("deferredPolling"))&&u(this,rh,"f").call(this,f,d,J.version,G.componentsVersion),!v&&!_)return void this.loggerWrapper.warn("No screen was found to show");const ee=_||v,te=yield this.getHtmlFilenameWithLocale(A,ee),{oidcLoginHint:ne,oidcPrompt:ie,oidcErrorRedirectUri:oe,oidcResource:re,samlIdpUsername:se}=F,ae={direction:jr(d,t.stepId),screenState:Object.assign(Object.assign({},g),{form:Object.assign(Object.assign({},this.formConfigValues),null==g?void 0:g.form),lastAuth:{loginId:z,name:this.sdk.getLastUserDisplayName()||z},componentsConfig:Object.assign(Object.assign(Object.assign({},J.componentsConfig),Q),null==g?void 0:g.componentsConfig)}),htmlFilename:`${ee}.html`,htmlLocaleFilename:te,screenId:ee,stepName:e.stepName||q,samlIdpUsername:se,oidcLoginHint:ne,oidcPrompt:ie,oidcErrorRedirectUri:oe,oidcResource:re,action:p,locale:Hi(A).locale},de=ms(z,this.loggerWrapper);_r(_,F)?ae.next=(e,t)=>c(this,void 0,void 0,(function*(){const n=(null==J?void 0:J.clientScripts)||[];yield u(this,Du,"m",Ih).call(this,n);const i=yield this.sdk.flow.start(s,Object.assign(Object.assign(Object.assign(Object.assign({tenant:a,redirectAuth:Y},F),{lastAuth:de,preview:this.preview,abTestingKey:V,client:this.client}),b&&{redirectUrl:b}),{locale:Hi(A).locale,nativeOptions:X,outboundAppId:K,outboundAppScopes:H}),B,e,G.componentsVersion,Z,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:u(this,Du,"a",mh)},this.formConfigValues),this.getComponentsContext()),Gr(t)),$&&{exchangeCode:$,idpInitiated:!0}),F.descopeIdpInitiated&&{idpInitiated:!0}),w&&{token:w}),ae.next.isCustomScreen);return u(this,dh,"f").call(this,i),i})):(n("projectId")||n("baseUrl")||n("executionId")||n("stepId"))&&(ae.next=(e,t)=>c(this,void 0,void 0,(function*(){const n=(null==g?void 0:g.clientScripts)||[];yield u(this,Du,"m",Ih).call(this,n);const i=yield this.sdk.flow.next(f,d,e,J.version,G.componentsVersion,Object.assign(Object.assign({origin:u(this,Du,"a",mh)},this.getComponentsContext()),Gr(t)),ae.next.isCustomScreen);return u(this,dh,"f").call(this,i),i}))),this.loggerWrapper.debug("Got a screen with id",ae.screenId),yield u(this,Du,"m",th).call(this,ae),this.stepState.update(ae)}))}onStepChange(e,t){return c(this,void 0,void 0,(function*(){var n,i,o;const{htmlFilename:r,htmlLocaleFilename:s,direction:a,next:d,screenState:l,screenId:h}=e;this.loggerWrapper.debug("Rendering a flow screen"),this.clearEmailVerification(),this.updateScreenUser(null==l?void 0:l.user);const f=document.createElement("template");f.innerHTML=yield this.getPageContent(r,s);const p=f.content.cloneNode(!0),v=this.loadDescopeUiComponents(f);this.sdk.webauthn.helpers.isSupported()?yield u(this,Du,"m",uh).call(this,p,d):(e=>{e.querySelectorAll(`descope-button[${Ho}="biometrics"]`).forEach((e=>e.setAttribute("disabled","true")))})(p),!e.samlIdpUsername||(null===(n=l.form)||void 0===n?void 0:n.loginId)||(null===(i=l.form)||void 0===i?void 0:i.email)||(l.form||(l.form={}),l.form.loginId=e.samlIdpUsername,l.form.email=e.samlIdpUsername),cs(p,l,this.formConfig,this.loggerWrapper),this.applyComponentsState(p,null==l?void 0:l.componentsState),this.startEmailVerification(p);const{geo:g}=null!==(o=yield this.getExecutionContext())&&void 0!==o?o:{};((e,t)=>{Object.entries({"default-code":"autoDetect","default-country":"autoDetect"}).forEach((([n,i])=>{Array.from(e.querySelectorAll(`[${n}="${i}"]`)).forEach((e=>{e.setAttribute(n,t||i)}))}))})(p,g),((e,t)=>{let n=t;if(t)try{const[e]=Intl.getCanonicalLocales(t);e&&(n=e)}catch(e){}Object.entries({lang:"autoDetect"}).forEach((([t,i])=>{Array.from(e.querySelectorAll(`[${t}="${i}"]`)).forEach((e=>{e.setAttribute(t,n||i)}))}))})(p,e.locale);const m=()=>c(this,void 0,void 0,(function*(){var n,i;yield v;const o=this.contentRootElement;((e,t)=>{ls(e,"descope-totp-image",t)})(o,null===(n=null==l?void 0:l.totp)||void 0===n?void 0:n.image),((e,t)=>{ls(e,"descope-notp-image",t)})(o,null===(i=null==l?void 0:l.notp)||void 0===i?void 0:i.image),((e,t,n,i)=>{n&&Object.keys(n).forEach((o=>{if(!t.querySelector(o))return void i.debug(`Skipping css vars for component "${o}"`,`Got css vars for component ${o} but Could not find it on next page`);const r=customElements.get(o);r?Object.keys(n[o]).forEach((t=>{var s;const a=n[o],d=null===(s=null==r?void 0:r.cssVarList)||void 0===s?void 0:s[t];if(!d)return void i.info(`Could not find css variable name for ${t} in ${o}`,"Check if the css variable is defined in the component");const l=a[t];e.style.setProperty(d,l)})):i.debug(`Could not find component class for ${o}`,"Check if the component is registered")}))})(o,p,l.cssVars,this.loggerWrapper),o.replaceChildren(p);const r=!t.htmlFilename;setTimeout((()=>{u(this,Du,"m",kh).call(this),this.updateUsernameAnchor(),this.validateOnBlur&&((e,t)=>{e.querySelectorAll("*[name]").forEach((n=>{n.addEventListener("blur",(()=>{var i;if(sr(n,e))return;const o=()=>{var e;const i=n.focus;n.focus=()=>{};const o=null===(e=n.reportValidity)||void 0===e?void 0:e.call(n);t&&!1===o&&t(n),setTimeout((()=>{n.focus=i}))};if("true"===n.getAttribute("invalid")||(null===(i=n.value)||void 0===i?void 0:i.length))return void o();const r={timer:void 0},s=e=>{"true"===e.target.getAttribute("formnovalidate")&&(clearTimeout(r.timer),r.timer=void 0)};r.timer=setTimeout((()=>{e.removeEventListener("click",s),o(),r.timer=void 0}),150),e.addEventListener("click",s,{once:!0})}))}))})(o,(e=>this.trackValidationErrors([e],u(this,Du,"a",gh)))),((e,t)=>{rs(e,null==t?void 0:t.inputs),rs(e,null==t?void 0:t.form)})(o,l),this.initRealtimeConditions(o,l),u(this,Du,"m",hh).call(this,{isFirstScreen:r,isCustomScreen:!1,stepName:e.stepName}),Dr(o,this.autoFocus,r),u(this,Du,"m",xh).call(this,h)})),u(this,Du,"m",Oh).call(this,d,h),o.querySelector(`[${Ho}="polling"]`)&&d(er,{})}));a?u(this,Du,"m",oh).call(this,m):m()}))}getInputs(){return Array.from(this.shadowRoot.querySelectorAll(`*:not(slot)[name]:not([${Eo}])`))}shouldUsePopupPostMessage(){if(!this.popupOrigin)return!1;try{new URL(this.popupOrigin)}catch(e){return!1}return!0}};Fu=new WeakMap,_u=new WeakMap,qu=new WeakMap,Bu=new WeakMap,Vu=new WeakMap,Hu=new WeakMap,eh=new WeakMap,ih=new WeakMap,rh=new WeakMap,sh=new WeakMap,ah=new WeakMap,dh=new WeakMap,lh=new WeakMap,fh=new WeakMap,ph=new WeakMap,wh=new WeakMap,Sh=new WeakMap,Du=new WeakSet,Ku=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1,deferredPolling:!1})}),300)},zu=function(e,t,n){return c(this,void 0,void 0,(function*(){var i;return(null===(i=this.nativeOptions)||void 0===i?void 0:i.bridgeVersion)>=2&&new Promise((i=>{this.nativeCallbacks.screenNext=n,this.nativeCallbacks.screenResolve=i,u(this,Du,"m",Gu).call(this,"beforeScreen",{screen:e,context:t})}))}))},Ju=function(e){var t;(null===(t=this.nativeOptions)||void 0===t?void 0:t.bridgeVersion)>=2&&u(this,Du,"m",Gu).call(this,"afterScreen",{screen:e})},Gu=function(e,t){u(this,Du,"m",Ah).call(this,"bridge",{type:e,payload:t})},Zu=function({errorText:e,errorType:t}){const n=()=>{var n;let i=e;try{i=(null===(n=this.errorTransformer)||void 0===n?void 0:n.call(this,{text:e,type:t}))||e}catch(e){this.loggerWrapper.error("Error transforming error message",e.message)}((e,t,n="")=>{e.querySelectorAll(`[${Ho}="${t}"]`).forEach((e=>{e.textContent=n,e.classList[n?"remove":"add"]("hide")}))})(this.contentRootElement,"error-message",i)};this.addEventListener("screen-updated",n,{once:!0}),n()},Yu=function(){var e,t,n,i;null===(e=this.stepState)||void 0===e||e.subscribe(this.onStepChange.bind(this),(e=>{var t=e.screenState,n=void 0===t?{}:t,{errorText:i,errorType:o}=n,r=l(n,["errorText","errorType"]),s=l(e,["screenState"]);return Object.assign(Object.assign({},s),{screenState:r})})),null===(t=this.stepState)||void 0===t||t.subscribe(u(this,Du,"m",Zu).bind(this),(e=>{var t,n;return{errorText:null===(t=null==e?void 0:e.screenState)||void 0===t?void 0:t.errorText,errorType:null===(n=null==e?void 0:e.screenState)||void 0===n?void 0:n.errorType}}),{forceUpdate:!0}),null===(n=this.stepState)||void 0===n||n.subscribe(u(this,Du,"m",Xu).bind(this),(e=>{var t,n;return{errorText:null===(t=null==e?void 0:e.screenState)||void 0===t?void 0:t.errorText,errorType:null===(n=null==e?void 0:e.screenState)||void 0===n?void 0:n.errorType}}),{forceUpdate:!0}),null===(i=this.flowState)||void 0===i||i.subscribe((({screenId:e,executionId:t})=>{var n;try{this.updateTelemetryContext({screenId:e,executionId:t})}catch(e){null===(n=this.logger)||void 0===n||n.error("Error updating telemetry screenId:",e)}}),(e=>({screenId:e.screenId,executionId:e.executionId})))},Xu=function({errorText:e,errorType:t}){(t||e)&&(this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((e=>{e.shadowRoot.querySelectorAll("descope-text-field[data-id]").forEach((e=>{e.value=""}))})),Dr(this.contentRootElement,this.autoFocus,!1))},Qu=function(){return c(this,void 0,void 0,(function*(){this.loggerWrapper.debug("Trying to restart the flow");const e=yield this.getComponentsVersion();this.reset(),e===(yield this.getComponentsVersion())?(this.loggerWrapper.debug("Components version was not changed, restarting flow"),this.flowState.update(Object.assign({stepId:null,executionId:null},this.adoptedSsoQueryParams))):this.loggerWrapper.error("Components version mismatch, please reload the page")}))},th=function(e){return c(this,void 0,void 0,(function*(){var t;const n=Object.assign(Object.assign({},this.stepState.current),e),{next:i,stepName:o}=n,r=(e=>{const t=(n=e.screenState,i=(e,t)=>ir.includes(t)||t.startsWith("_"),Object.fromEntries(Object.entries(n).filter((([e,t])=>!i(0,e)))));var n,i;const{screenState:{errorText:o,errorType:r}}=e;(o||r)&&(t.error={text:o,type:r}),e.action&&(t.action=e.action);const s=(e=>{if(!e)return;const t={};return Jr.forEach((({key:n,from:i})=>{const o=i(e);void 0!==o&&(t[n]=o)})),Object.keys(t).length?t:void 0})(e.screenState);return s&&(t.data=s),t})(l(n,["next","stepName"]));let s=yield u(this,Du,"m",zu).call(this,o,r,i);s||(s=Boolean(yield null===(t=this.onScreenUpdate)||void 0===t?void 0:t.call(this,o,r,i,this)));const a=!this.stepState.current.htmlFilename;if(u(this,ih,"f").call(this,s),i&&(i.isCustomScreen=s),u(this,eh,"f")!==s){const[e,t]=["flow","custom"].sort((()=>s?-1:1));this.loggerWrapper.debug(`Switching from ${t} screen to ${e} screen`),h(this,eh,s,"f"),s?this.stepState.unsubscribeAll():u(this,Du,"m",Yu).call(this)}s?(this.loggerWrapper.debug("Showing a custom screen"),u(this,Du,"m",hh).call(this,{isFirstScreen:a,isCustomScreen:s,stepName:e.stepName}),this.disableKeyPressHandler()):this.handleKeyPress(),this.stepState.forceUpdate=s}))},nh=function(e,t){return c(this,void 0,void 0,(function*(){const n=new AbortController;try{const i=e===Go?this.sdk.webauthn.helpers.create(t,n):this.sdk.webauthn.helpers.get(t,n),o=yield Fr(9e4,i,jh);return o!==jh?{response:o}:(n.abort(),this.loggerWrapper.warn("WebAuthn operation timed out after 90000ms"),{failure:"AbortError",failureReason:"aborted",failureMessage:"Passkey operation timed out"})}catch(e){return"InvalidStateError"===e.name?this.loggerWrapper.warn("WebAuthn operation failed",e.message):"NotAllowedError"!==e.name&&this.loggerWrapper.error(e.message),{failure:e.name,failureReason:e.reason,failureMessage:e.message}}}))},oh=function(e){this.contentRootElement.addEventListener("transitionend",(()=>{this.loggerWrapper.debug("page switch transition end"),this.contentRootElement.classList.remove("fade-out"),e()}),{once:!0}),this.loggerWrapper.debug("page switch transition start"),this.contentRootElement.classList.add("fade-out")},ch=function(e){const t=e.getAttribute("name");if(!["email"].includes(t)){const n=`user-${t}`;e.setAttribute("name",n),e.addEventListener("input",(()=>{e.setAttribute("name",e.value?t:n)}))}},uh=function(e,t){return c(this,void 0,void 0,(function*(){var n;null===(n=u(this,_u,"f"))||void 0===n||n.abort();const i=e.querySelector('*[autocomplete="webauthn"]');if(i&&(yield us())){const{options:e,transactionId:n}=(yield u(this,lh,"f").call(this))||{};e&&n&&(u(this,Du,"m",ch).call(this,i),h(this,_u,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(e,u(this,_u,"f")).then((e=>c(this,void 0,void 0,(function*(){t(i.id,{transactionId:n,response:e})})))).catch((e=>{"AbortError"!==e.name&&this.loggerWrapper.error("Conditional login failed",e.message)})))}}))},hh=function({isFirstScreen:e,isCustomScreen:t,stepName:n}){e&&u(this,Du,"m",Ah).call(this,"ready",{}),t||u(this,Du,"m",Ju).call(this,n),u(this,Du,"m",Ah).call(this,"page-updated",{screenName:n}),u(this,Du,"m",Ah).call(this,"screen-updated",{screenName:n})},vh=function(e,t,n){this.setValidationTrackingEnabled(!!e.clientValidationTrackingEnabled),t&&n("executionId")&&this.setValidationTrackingExecution(t)},gh=function(){var e,t,n,i,o,r,s;const a=null===(e=this.flowState)||void 0===e?void 0:e.current;return(null==a?void 0:a.executionId)?{executionId:a.executionId,screenId:a.screenId,screenName:(null===(s=null===(r=this.stepState)||void 0===r?void 0:r.current)||void 0===s?void 0:s.stepName)||a.stepName}:{executionId:void 0,screenId:null!==(t=u(this,fh,"f"))&&void 0!==t?t:null==a?void 0:a.screenId,screenName:null!==(n=u(this,ph,"f"))&&void 0!==n?n:(null===(o=null===(i=this.stepState)||void 0===i?void 0:i.current)||void 0===o?void 0:o.stepName)||(null==a?void 0:a.stepName)}},mh=function(){var e;return(null===(e=this.nativeOptions)||void 0===e?void 0:e.origin)||window.location.origin},yh=function(){let e=!0;const t=[];return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((n=>{var i,o,r;"slot"===n.localName||sr(n,this.contentRootElement)||(null===(i=n.reportValidity)||void 0===i||i.call(n),n.validity&&!n.validity.valid&&t.push(n),e&&(e=null===(r=null===(o=n.checkValidity)||void 0===o?void 0:o.call(n))||void 0===r||r))})),t.length&&this.trackValidationErrors(t,u(this,Du,"a",gh)),e},bh=function(){return c(this,void 0,void 0,(function*(){const e=this.getInputs();return(yield Promise.all(e.map((e=>c(this,void 0,void 0,(function*(){return{name:e.getAttribute("name"),value:e.value}})))))).reduce(((e,t)=>Object.assign(Object.assign({},e),{[t.name]:t.value})),{})}))},$h=function(e){var t,n;const i=Array.from(this.contentRootElement.querySelectorAll(':not([disabled]), [disabled="false"]')).filter((t=>t!==e)),o=(null===(n=null===(t=this.flowState.current)||void 0===t?void 0:t.screenState)||void 0===n?void 0:n.clientScripts)||[];e.setAttribute("loading","true"),i.forEach((e=>e.setAttribute("disabled","true")));const r=()=>{e.removeAttribute("loading"),i.forEach((e=>{e.removeAttribute("disabled")}))},s=e=>c(this,void 0,void 0,(function*(){var t;if(this.loggerWrapper.debug("Restoring components state"),this.removeEventListener("popupclosed",s),!0===(null===(t=null==e?void 0:e.detail)||void 0===t?void 0:t.abandoned)&&o.length)return h(this,qu,(()=>c(this,void 0,void 0,(function*(){try{yield this.loadSdkScripts(o)}catch(e){this.loggerWrapper.warn("Failed to refresh client scripts on popup close",null==e?void 0:e.message)}})))(),"f"),void r();r();const n=yield this.getFlowConfig(),i=[...n.clientScripts||[],...n.sdkScripts||[]];this.loadSdkScripts(i)})),a=()=>{var e;window.removeEventListener("pageshow",u(this,wh,"f")),h(this,wh,(e=>{e.persisted&&(this.logger.debug("Page was loaded from cache, restoring components state"),s())}),"f"),window.addEventListener("pageshow",u(this,wh,"f"),{once:!0});const t=null===(e=this.stepState)||void 0===e?void 0:e.subscribe(((e,n)=>{e===n&&s(),this.removeEventListener("popupclosed",s),this.stepState.unsubscribe(t)}),(e=>e.screenId),{forceUpdate:!0})},d=this.nextRequestStatus.subscribe((({isLoading:e})=>{e?this.addEventListener("popupclosed",s,{once:!0}):(this.nextRequestStatus.unsubscribe(d),"success"===this.flowStatus?(this.removeEventListener("popupclosed",s),r()):a())}));return r},kh=function(){document.querySelectorAll('[data-hidden-input="true"]').forEach((e=>e.remove())),this.contentRootElement.querySelectorAll('[external-input="true"]').forEach((e=>u(this,Du,"m",Ch).call(this,e)))},Ch=function(e){e&&e.querySelectorAll("input").forEach((t=>{const n=t.getAttribute("slot"),i=`input-${e.id}-${n}`,o=document.createElement("slot");o.setAttribute("name",i),o.setAttribute("slot",n),e.appendChild(o),t.setAttribute("slot",i),this.appendChild(t)}))},Ih=function(e){return c(this,void 0,void 0,(function*(){if(u(this,qu,"f")){this.loggerWrapper.debug("Waiting for sdk scripts to load");const e=Date.now();yield u(this,qu,"f"),this.loggerWrapper.debug("Sdk scripts loaded for",(Date.now()-e).toString())}const t=this.loadSdkScriptsModules(),n=e.map((e=>e.id));for(const e of t)if(n.includes(e.id))try{"function"==typeof e.present&&((yield e.present())||this.loggerWrapper.debug(`Sdk script ${e.id} was cancelled`))}catch(t){this.loggerWrapper.error(`Failed to present ${e.id} script module`,t.message)}const i=[];for(const e of t)"function"==typeof e.refresh&&i.push(e.refresh());if(i.length>0)try{yield Fr(5e3,Promise.all(i),null)}catch(e){this.loggerWrapper.error("Failed to refresh script module",e.message)}}))},Rh=function(e,t){this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((n=>{n.addEventListener("input",(()=>{var i;(null===(i=n.checkValidity)||void 0===i?void 0:i.call(n))&&u(this,Sh,"f").call(this,n,e,t)}))}))},Eh=function(e,t,n){t&&n&&"true"===e.getAttribute("data-opt-in-last-used-auth")&&function(e,t,n){try{const n=bs();n[e]=t,fs(nr,JSON.stringify(n))}catch(e){null==n||n.warn("[Descope] Failed to update in-flight last auth storage",String(e))}}(n,t,this.loggerWrapper)},xh=function(e){var t;const n=null===(t=ms(this.sdk.getLastUserLoginId(),this.loggerWrapper).lastUsedPerScreen)||void 0===t?void 0:t[e];if(!n)return;const i=this.contentRootElement.querySelector('descope-attachment[data-type="last-auth-badge"]'),o=this.contentRootElement.querySelector(`#${CSS.escape(n)}`);i&&o&&(o.replaceWith(i),i.appendChild(o))},Oh=function(e,t){this.contentRootElement.querySelectorAll(`descope-button:not([${xo}]), [data-type="button"]:not([${xo}]`).forEach((n=>{n.onclick=()=>{u(this,Sh,"f").call(this,n,e,t)}})),u(this,Du,"m",Rh).call(this,e,t),this.isDismissScreenErrorOnInput&&this.contentRootElement.querySelectorAll(`*[name]:not([${Eo}])`).forEach((e=>{e.addEventListener("input",(()=>{this.stepState.update((e=>Object.assign(Object.assign({},e),{screenState:Object.assign(Object.assign({},e.screenState),{errorText:"",errorType:""})})))}))}))},Ah=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))},Nh=function(e,t,n){var i;const[o,r]=(null===(i=window.name)||void 0===i?void 0:i.split("|"))||[],s="descope-wc"===o&&!!r,a=s?function(e){const t=Tr(e);if(t)return t===window.location.origin||Tr(function(){const e=new URLSearchParams(window.location.search).getAll("popup_opener_origin");return 1===e.length?e[0]:void 0}())===t?t:void 0}(r):void 0;s&&!a&&this.loggerWrapper.warn("Popup opener origin is not approved for this project, add it to the approved domains to send the OAuth result to it",r);const d={data:{code:t,exchangeError:n},action:"code"};if(a){this.loggerWrapper.debug("Using postMessage fallback to notify opener in origin",a);try{window.opener.postMessage(d,a)}catch(e){this.loggerWrapper.error("Failed to send postMessage fallback (likely COOP isolation)",null==e?void 0:e.message)}}else{this.loggerWrapper.debug("Creating popup channel",e);const t=new BroadcastChannel(e);t.postMessage(d),t.close()}try{window.close()}catch(e){}},Mh.bridgeVersion=3,customElements.get("descope-wc")?console.log("descope-wc is already defined"):customElements.define("descope-wc",Mh);var Ph=Object.freeze({__proto__:null,default:Mh});const Th=e=>e.selectedAccessKeysIds,Wh=e=>e.notifications,Lh=Al((e=>e.accessKeysList.data),(e=>e.map((e=>Object.assign(Object.assign({},e),{expireTimeFormatted:(null==e?void 0:e.expireTime)?new Date(1e3*((null==e?void 0:e.expireTime)||0)).toLocaleString():"Never",createdTimeFormatted:new Date(1e3*((null==e?void 0:e.createdTime)||0)).toLocaleString(),status:(null==e?void 0:e.expireTime)&&new Date(1e3*((null==e?void 0:e.expireTime)||0))<new Date?"expired":null==e?void 0:e.status}))))),Uh=Al(Th,Lh,((e,t)=>t.filter((t=>e.includes(t.id))))),Dh=Al(Th,(e=>!!e.length)),Fh=Al(Uh,(e=>e.every((e=>e.editable)))),_h=Al(Fh,Dh,((e,t)=>e&&t)),qh=Al(Uh,(e=>e.some((e=>"expired"===e.status)))),Bh=Al(_h,qh,((e,t)=>e&&!t)),Vh=Al(Th,(e=>1===e.length)),Kh=Al(Uh,(e=>1===e.length?e[0].name:`${e.length} access keys`)),Hh=Al(Bh,Vh,Uh,((e,t,n)=>{var i;return e&&t&&"active"===(null===(i=n[0])||void 0===i?void 0:i.status)})),zh=e=>(...t)=>n=>{n.addCase(e.pending,((e,n)=>{t.forEach((({onPending:t})=>{null==t||t(e,n)}))})),n.addCase(e.fulfilled,((e,n)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,n)}))})),n.addCase(e.rejected,((e,n)=>{t.forEach((({onRejected:t})=>{null==t||t(e,n)}))}))},Jh=e=>({onFulfilled:t=>{e(t).loading=!1},onPending:t=>{e(t).loading=!0,e(t).error=null},onRejected:(t,n)=>{e(t).loading=!1,e(t).error=n.error}}),Gh=({getErrorMsg:e,getSuccessMsg:t})=>({onFulfilled:(e,n)=>{t&&e.notifications.push({type:"success",msg:t(n)})},onRejected:(t,n)=>{e&&t.notifications.push({type:"error",msg:e(n)})}}),Zh=lc("accessKeys/create",((e,{extra:{api:t}})=>t.accesskey.create(e))),Yh=zh(Zh)({onFulfilled:(e,t)=>{e.accessKeysList.data.unshift(t.payload.key)}},Jh((e=>e.createAccessKey)),Gh({getSuccessMsg:()=>"Access Key created successfully",getErrorMsg:e=>{var t;const n=null===(t=e.error)||void 0===t?void 0:t.message;return`\n <div>\n <div>Failed to create access key</div>\n ${Ki(n)}\n </div>`}})),Xh={action:Zh,reducer:Yh},Qh=lc("accessKeys/delete",((e,{extra:{api:t}})=>t.accesskey.deleteBatch(e))),ef=zh(Qh)({onFulfilled:(e,t)=>{e.accessKeysList.data=e.accessKeysList.data.filter((e=>!t.meta.arg.includes(e.id))),e.selectedAccessKeysIds=[]}},Jh((e=>e.deleteAccessKey)),Gh({getSuccessMsg:e=>Mi(e.meta.arg.length)`${["",e.meta.arg.length]} ${["A","a"]}ccess key${["","s"]} deleted successfully`,getErrorMsg:e=>Mi(e.meta.arg.length)`Failed to delete access key${["","s"]}`})),tf={action:Qh,reducer:ef},nf=lc("accessKeys/search",((e,{extra:{api:t},getState:n})=>{const i=n().searchParams;return t.accesskey.search(Object.assign(Object.assign({},i),e))})),of=zh(nf)({onPending:(e,t)=>{e.searchParams=Object.assign(Object.assign({},e.searchParams),t.meta.arg)},onFulfilled:(e,t)=>{e.accessKeysList.data=t.payload}},Jh((e=>e.accessKeysList))),rf={action:nf,reducer:of},sf=lc("accessKeys/activate",((e,{extra:{api:t}})=>t.accesskey.activate(e))),af=zh(sf)({onFulfilled:(e,t)=>{e.accessKeysList.data.forEach((e=>{t.meta.arg.includes(e.id)&&(e.status="active")}))}},Jh((e=>e.activateAccessKey)),Gh({getSuccessMsg:e=>Mi(e.meta.arg.length)`${["",e.meta.arg.length]} ${["A","a"]}ccess key${["","s"]} activated successfully`,getErrorMsg:e=>Mi(e.meta.arg.length)`Failed to activate access key${["","s"]}`})),df={action:sf,reducer:af},lf=lc("accessKeys/deactivate",((e,{extra:{api:t}})=>t.accesskey.deactivate(e))),cf=zh(lf)({onFulfilled:(e,t)=>{e.accessKeysList.data.forEach((e=>{t.meta.arg.includes(e.id)&&(e.status="inactive")}))}},Jh((e=>e.deactivateAccessKey)),Gh({getSuccessMsg:e=>Mi(e.meta.arg.length)`${["",e.meta.arg.length]} ${["A","a"]}ccess key${["","s"]} deactivated successfully`,getErrorMsg:e=>Mi(e.meta.arg.length)`Failed to deactivate access key${["","s"]}`})),uf={action:lf,reducer:cf},hf=lc("accessKeys/rotate",((e,{extra:{api:t}})=>t.accesskey.rotate(e))),ff=zh(hf)({onFulfilled:(e,t)=>{const n=e.accessKeysList.data.findIndex((e=>e.id===t.payload.key.id));n>=0&&(e.accessKeysList.data[n]=t.payload.key)}},Jh((e=>e.rotateAccessKey)),Gh({getSuccessMsg:()=>"Access key rotated successfully",getErrorMsg:e=>{var t;const n=null===(t=e.error)||void 0===t?void 0:t.message;return`\n <div>\n <div>Failed to rotate access key</div>\n ${Ki(n)}\n </div>`}})),pf={action:hf,reducer:ff},vf=lc("tenant/getTenantRoles",((e,{extra:{api:t}})=>t.tenant.getTenantRoles())),gf={action:vf,reducer:zh(vf)({onFulfilled:(e,t)=>{e.tenantRoles.data=t.payload.roles}},Jh((e=>e.tenantRoles)))},mf={accessKeysList:{data:[],loading:!1,error:null},createAccessKey:{loading:!1,error:null},activateAccessKey:{loading:!1,error:null},deactivateAccessKey:{loading:!1,error:null},deleteAccessKey:{loading:!1,error:null},rotateAccessKey:{loading:!1,error:null},tenantRoles:{loading:!1,error:null,data:[]},searchParams:{text:"",sort:[]},selectedAccessKeysIds:[],notifications:[]},yf="/v1/mgmt/accesskey/search",bf="/v1/mgmt/accesskey/delete/batch",wf="/v1/mgmt/accesskey/create",$f="/v1/mgmt/accesskey/deactivate/batch",kf="/v1/mgmt/accesskey/activate/batch",Cf="/v1/mgmt/accesskey/rotate",Sf="/v1/mgmt/role/all",If=e=>c(void 0,void 0,void 0,(function*(){const t=yield e.text(),n=JSON.parse(t);if(!e.ok){const t=`${n.errorDescription}${n.errorMessage?`: ${n.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(n),e.text=()=>Promise.resolve(t)})),Rf=({httpClient:e,tenant:t,mock:n})=>({search:(...i)=>c(void 0,[...i],void 0,(function*({page:i,limit:o=1e4,text:r,sort:s}={}){if(n)return((...e)=>c(void 0,[...e],void 0,(function*({text:e,sort:t}={}){return new Promise((n=>{const i=[],o=(new Date).getTime()/1e3+2592e3,r=new Date(o).toLocaleString();for(let e=1;e<10;e+=1)i.push({id:`access-key-id-${e}`,name:`Access Key ${e}`,createdBy:`User ${e}`,editable:!0,expireTime:o,expireTimeFormatted:r,createdTime:o,createdTimeFormatted:r,roleNames:[`Role ${e}`],permittedIps:["127.1.2.3"],status:"active",clientId:`Client ID ${e}`,boundUserId:`User ${e}`});t.forEach((e=>{i.sort(((t,n)=>{var i,o;return e.desc?null===(o=n[e.field])||void 0===o?void 0:o.localeCompare(t[e.field]):null===(i=t[e.field])||void 0===i?void 0:i.localeCompare(n[e.field])}))})),n(i.filter((t=>t.name.toLowerCase().includes(e.toLowerCase())||t.createdBy.toLowerCase().includes(e.toLowerCase()))))}))})))({page:i,limit:o,text:r,sort:s});const a=yield e.post(yf,{limit:o,page:i,text:r,sort:s},{queryParams:{tenant:t}});return yield If(a),(yield a.json()).keys})),deleteBatch:i=>c(void 0,void 0,void 0,(function*(){if(n)return c(void 0,void 0,void 0,(function*(){}));const o=yield e.post(bf,{ids:i},{queryParams:{tenant:t}});return yield If(o),o.json()})),create:i=>c(void 0,[i],void 0,(function*({name:i,expiration:o,roleNames:r,userId:s,permittedIps:a}){const d=new Date;d.setDate(d.getDate()+ +o);const l="0"===o[0]?0:Math.floor(d.getTime()/1e3);if(n)return((e,t)=>c(void 0,[e,t],void 0,(function*({name:e,roleNames:t,userId:n,permittedIps:i},o){const r=Math.random().toString(10).substring(15);return new Promise((s=>{s({cleartext:Math.random().toString(20).substring(2),key:{id:`access-key-id-${r}`,name:e||`Access Key ${r}`,createdBy:n||`User ${r}`,editable:!0,expireTime:o,createdTime:(new Date).getTime()/1e3,roleNames:t,permittedIps:i,status:"active",clientId:`Client ID ${r}`,boundUserId:n||`User ${r}`}})}))})))({name:i,expiration:o,roleNames:r,userId:s,permittedIps:a},l);const u=yield e.post(wf,{name:i,expireTime:l,roleNames:r,userId:s,permittedIps:a},{queryParams:{tenant:t}});return yield If(u),yield u.json()})),activate:i=>c(void 0,void 0,void 0,(function*(){if(n)return c(void 0,void 0,void 0,(function*(){}));const o=yield e.post(kf,{ids:i},{queryParams:{tenant:t}});return yield If(o),yield o.json()})),deactivate:i=>c(void 0,void 0,void 0,(function*(){if(n)return c(void 0,void 0,void 0,(function*(){}));const o=yield e.post($f,{ids:i},{queryParams:{tenant:t}});return yield If(o),yield o.json()})),rotate:i=>c(void 0,[i],void 0,(function*({id:i}){if(n)return(e=>c(void 0,[e],void 0,(function*({id:e}){return new Promise((t=>{t({cleartext:Math.random().toString(20).substring(2),key:{id:e,name:`Access Key ${e}`,createdBy:"User",editable:!0,expireTime:(new Date).getTime()/1e3+2592e3,createdTime:(new Date).getTime()/1e3,roleNames:[],permittedIps:[],status:"active",clientId:`Client ID ${e}`,boundUserId:"User"}})}))})))({id:i});const o=yield e.post(Cf,{id:i},{queryParams:{tenant:t}});return yield If(o),yield o.json()}))}),Ef=({httpClient:e,tenant:t,mock:n})=>({getTenantRoles:()=>c(void 0,void 0,void 0,(function*(){if(n)return(e=>new Promise((t=>{const n=[];for(let t=1;t<5;t+=1)n.push({name:`Role ${t}`,description:`Role description ${t}`,createdTime:new Date,permissionNames:[`Permission ${t}`],tenantId:e});t({roles:n})})))(t);const i=yield e.get(Sf,{queryParams:{tenant:t}});return yield If(i),i.json()}))}),xf=Wi((e=>{var t,n,i,o;const r=xi(js,As,Cs,Ms,Sc,Ns({tenant:Ns.missingAttrValidator}))(e);return o=class extends r{constructor(){super(...arguments),t.add(this),n.set(this,void 0)}get tenantId(){return this.getAttribute("tenant")}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get api(){return u(this,n,"f")||u(this,t,"m",i).call(this),u(this,n,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.init)||void 0===o?void 0:o.call(this),this.observeAttributes(["project-id","base-url","tenant"],(()=>{u(this,n,"f")&&u(this,t,"m",i).call(this)}))}))}},n=new WeakMap,t=new WeakSet,i=function(){this.logger.debug("creating an sdk instance"),h(this,n,((e,t,n,i)=>{const o=bi(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"access-key-management-widget","x-descope-widget-id":i,"x-descope-widget-version":"0.10.20"}}));return{accesskey:Rf({httpClient:o.httpClient,tenant:t,mock:n}),tenant:Ef({httpClient:o.httpClient,tenant:t,mock:n}),httpClient:o.httpClient}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},this.tenantId,"true"===this.mock,this.widgetId),"f")},o})),Of=Wi((e=>{const t=xi(yc({name:"widget",initialState:mf,reducers:{setSelectedAccessKeysIds:(e,{payload:t})=>{e.selectedAccessKeysIds=t},clearNotifications:e=>{e.notifications=[]}},extraReducers:e=>{Xh.reducer(e),tf.reducer(e),rf.reducer(e),df.reducer(e),uf.reducer(e),pf.reducer(e),gf.reducer(e)},asyncActions:{searchAccessKeys:rf.action,createAccessKey:Xh.action,activateAccessKeys:df.action,deactivateAccessKeys:uf.action,deleteAccessKeys:tf.action,rotateAccessKey:pf.action,getTenantRoles:gf.action}}),Os,Cs,xf)(e);return class extends t{constructor(...e){super(...e),this.state=mf,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),Af=Wi((e=>{var t,n,i;return i=class extends(xi(Cs,Os,Hs,Xs,Cc("access-key-management-widget"),Of)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){return c(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.init)||void 0===i?void 0:i.call(this),yield Promise.all([u(this,t,"m",n).call(this),this.actions.searchAccessKeys(),this.actions.getTenantRoles()]),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,n=function(){return c(this,void 0,void 0,(function*(){const e=Oi(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},i})),Nf=Wi((e=>{var t,n,i,o,r;return r=class extends(xi(Of,Cs,Af)(e)){constructor(){super(...arguments),t.add(this),i.set(this,Ni((e=>{this.accessKeysTable.data=e}))),o.set(this,Pi(((e,t)=>{const n=[],{value:i}=t;if(i){const t=e.path;n.push({field:t,desc:"desc"===i})}this.actions.searchAccessKeys({sort:n})})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var r;yield null===(r=e.onWidgetRootReady)||void 0===r?void 0:r.call(this),u(this,t,"m",n).call(this),this.accessKeysTable.columns.forEach((e=>{e.onSortDirectionChange((e=>{u(this,o,"f").call(this,e.target,e.detail)}))})),u(this,i,"f").call(this,Lh(this.state)),this.subscribe(u(this,i,"f").bind(this),Lh)}))}},i=new WeakMap,o=new WeakMap,t=new WeakSet,n=function(){var e;this.accessKeysTable=new Ea(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="access-keys-table"]'),{logger:this.logger}),this.accessKeysTable.onSelectedItemsChange((e=>{this.actions.setSelectedAccessKeysIds(e.detail.value.map((({id:e})=>e)))}))},r})),jf=Wi((e=>{var t,n,i;return i=class extends(xi(Of,ud,Cs,Af)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),yield u(this,t,"m",n).call(this)}))}},t=new WeakSet,n=function(){return c(this,void 0,void 0,(function*(){var e;this.activateAccessKeysModal=this.createModal(),this.activateAccessKeysModal.setContent(Oi(yield this.fetchWidgetPage("activate-access-keys-modal.html")));const t=new ka((()=>{var e;return null===(e=this.activateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger});t.onClick((()=>this.activateAccessKeysModal.close()));const n=new ka((()=>{var e;return null===(e=this.activateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});n.onClick((()=>{const e=Uh(this.state);this.actions.activateAccessKeys(null==e?void 0:e.map((e=>e.id))),this.activateAccessKeysModal.close()}));const i=new id(null===(e=this.activateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.activateAccessKeysModal.beforeOpen=()=>{const e=Kh(this.state);i.text=`Activate ${e}?`}}))},i})),Mf=Wi((e=>{var t,n,i,o;return o=class extends(xi(Cs,Af,Of,jf)(e)){constructor(){super(...arguments),t.add(this),i.set(this,Ni((e=>{e?this.activateButton.enable():this.activateButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),u(this,t,"m",n).call(this),this.subscribe(u(this,i,"f").bind(this),Bh)}))}},i=new WeakMap,t=new WeakSet,n=function(){var e;this.activateButton=new ka(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="activate-access-keys"]'),{logger:this.logger}),this.activateButton.disable(),this.activateButton.onClick((()=>{this.activateAccessKeysModal.open()}))},o})),Pf=Wi((e=>{var t,n,i;return i=class extends(xi(Of,ud,bc,Cs,Af)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",n).call(this)}))}},t=new WeakSet,n=function(){return c(this,void 0,void 0,(function*(){this.createdAccessKeyModal=this.createModal(),this.createdAccessKeyModal.setContent(Oi(yield this.fetchWidgetPage("created-access-key-modal.html"))),new ka((()=>{var e;return null===(e=this.createdAccessKeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-close"]')}),{logger:this.logger}).onClick((()=>{navigator.clipboard.writeText(this.getFormData(this.createdAccessKeyModal.ele)["generated-key"]),this.resetFormData(this.createdAccessKeyModal.ele),this.createdAccessKeyModal.close()}))}))},i})),Tf=Wi((e=>{var t,n,i,o,r;return r=class extends(xi(Of,ud,bc,Cs,Af,Pf)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),o.set(this,(()=>c(this,void 0,void 0,(function*(){var e,t;yield u(this,n,"f").setData(null===(t=this.state,e=t.tenantRoles.data||[])||void 0===e?void 0:e.map((({name:e})=>({value:e,label:e}))))}))))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),u(this,t,"m",i).call(this)}))}},n=new WeakMap,o=new WeakMap,t=new WeakSet,i=function e(){return c(this,void 0,void 0,(function*(){this.createAccessKeyModal=this.createModal(),this.createAccessKeyModal.setContent(Oi(yield this.fetchWidgetPage("create-access-key-modal.html"))),new ka((()=>{var e;return null===(e=this.createAccessKeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger}).onClick((()=>{this.createAccessKeyModal.close(),this.resetFormData(this.createAccessKeyModal.ele)})),new ka((()=>{var e;return null===(e=this.createAccessKeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger}).onClick((()=>c(this,void 0,void 0,(function*(){var e,t;if(this.validateForm(this.createAccessKeyModal.ele)){const n=yield this.actions.createAccessKey(Object.assign({},this.getFormData(this.createAccessKeyModal.ele)));this.createAccessKeyModal.close(),(null===(e=null==n?void 0:n.payload)||void 0===e?void 0:e.cleartext)&&(this.setFormData(this.createdAccessKeyModal.ele,{"generated-key":null===(t=null==n?void 0:n.payload)||void 0===t?void 0:t.cleartext}),this.createdAccessKeyModal.open())}})))),h(this,n,new Qa((()=>{var e;return null===(e=this.createAccessKeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="roles-multiselect"]')}),{logger:this.logger}),"f"),u(this,o,"f").call(this),this.createAccessKeyModal.afterClose=()=>{u(this,t,"m",e).call(this)}}))},r})),Wf=Wi((e=>{var t,n,i;return i=class extends(xi(Cs,Tf,Af)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",n).call(this)}))}},t=new WeakSet,n=function(){var e;this.createButton=new ka(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="create-access-key"]'),{logger:this.logger}),this.createButton.onClick((()=>this.createAccessKeyModal.open()))},i})),Lf=Wi((e=>{var t,n,i;return i=class extends(xi(Of,ud,Cs,Af)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),yield u(this,t,"m",n).call(this)}))}},t=new WeakSet,n=function(){return c(this,void 0,void 0,(function*(){var e;this.deactivateAccessKeysModal=this.createModal(),this.deactivateAccessKeysModal.setContent(Oi(yield this.fetchWidgetPage("deactivate-access-keys-modal.html")));const t=new ka((()=>{var e;return null===(e=this.deactivateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger});t.onClick((()=>this.deactivateAccessKeysModal.close()));const n=new ka((()=>{var e;return null===(e=this.deactivateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});n.onClick((()=>{const e=Uh(this.state);this.actions.deactivateAccessKeys(null==e?void 0:e.map((e=>e.id))),this.deactivateAccessKeysModal.close()}));const i=new id(null===(e=this.deactivateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.deactivateAccessKeysModal.beforeOpen=()=>{const e=Kh(this.state);i.text=`Deactivate ${e}?`}}))},i})),Uf=Wi((e=>{var t,n,i,o;return o=class extends(xi(Cs,Af,Of,Lf)(e)){constructor(){super(...arguments),t.add(this),i.set(this,Ni((e=>{e?this.deactivateButton.enable():this.deactivateButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),u(this,t,"m",n).call(this),this.subscribe(u(this,i,"f").bind(this),Bh)}))}},i=new WeakMap,t=new WeakSet,n=function(){var e;this.deactivateButton=new ka(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="deactivate-access-keys"]'),{logger:this.logger}),this.deactivateButton.disable(),this.deactivateButton.onClick((()=>{this.deactivateAccessKeysModal.open()}))},o})),Df=Wi((e=>{var t,n,i;return i=class extends(xi(Of,ud,Cs,Af)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),yield u(this,t,"m",n).call(this)}))}},t=new WeakSet,n=function(){return c(this,void 0,void 0,(function*(){var e;this.deleteAccessKeysModal=this.createModal(),this.deleteAccessKeysModal.setContent(Oi(yield this.fetchWidgetPage("delete-access-keys-modal.html")));const t=new ka((()=>{var e;return null===(e=this.deleteAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger});t.onClick((()=>this.deleteAccessKeysModal.close()));const n=new ka((()=>{var e;return null===(e=this.deleteAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});n.onClick((()=>{const e=Uh(this.state);this.actions.deleteAccessKeys(null==e?void 0:e.map((e=>e.id))),this.deleteAccessKeysModal.close()}));const i=new id(null===(e=this.deleteAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.deleteAccessKeysModal.beforeOpen=()=>{const e=Kh(this.state);i.text=`Delete ${e}?`}}))},i})),Ff=Wi((e=>{var t,n,i,o;return o=class extends(xi(Cs,Af,Of,Df)(e)){constructor(){super(...arguments),t.add(this),i.set(this,Ni((e=>{e?this.deleteButton.enable():this.deleteButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),u(this,t,"m",n).call(this),this.subscribe(u(this,i,"f").bind(this),_h)}))}},i=new WeakMap,t=new WeakSet,n=function(){var e;this.deleteButton=new ka(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="delete-access-keys"]'),{logger:this.logger}),this.deleteButton.disable(),this.deleteButton.onClick((()=>{this.deleteAccessKeysModal.open()}))},o})),_f=Wi((e=>{var t,n,i,o;return o=class extends(xi(Cs,Af,Of)(e)){constructor(){super(...arguments),t.add(this),n.set(this,Pi((()=>{this.actions.searchAccessKeys({text:this.searchInput.value})})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),u(this,t,"m",i).call(this)}))}},n=new WeakMap,t=new WeakSet,i=function(){var e;this.searchInput=new od(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="search-input"]'),{logger:this.logger}),this.searchInput.onInput(u(this,n,"f"))},o})),qf={success:(new DOMParser).parseFromString('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Checkmark">\n<path id="Shape" d="M10.0485 15.6396C9.5799 15.171 8.8201 15.171 8.35147 15.6396C7.88284 16.1082 7.88284 16.868 8.35147 17.3367L12.7072 21.6924C13.1759 22.1611 13.9357 22.1611 14.4043 21.6924L24.7152 11.3815C25.1838 10.9129 25.1838 10.1531 24.7152 9.68448C24.2466 9.21585 23.4868 9.21585 23.0181 9.68448L13.5558 19.1469L10.0485 15.6396Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,error:(new DOMParser).parseFromString('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Icon">\n<path id="Vector" d="M15.9998 26.6558C10.1118 26.6558 5.34375 21.8878 5.34375 15.9998C5.34375 10.1118 10.1118 5.34375 15.9998 5.34375C21.8878 5.34375 26.6558 10.1118 26.6558 15.9998C26.6558 21.8878 21.8878 26.6558 15.9998 26.6558ZM15.9998 24.4798C20.6718 24.4798 24.4798 20.7038 24.4798 15.9998C24.4798 11.3278 20.7038 7.51975 15.9998 7.51975C11.3278 7.51975 7.51975 11.2958 7.51975 15.9998C7.51975 20.6718 11.2958 24.4798 15.9998 24.4798ZM15.3278 9.34375H16.6718C17.0558 9.34375 17.3438 9.63175 17.3118 9.98375L16.9598 16.9278C16.9598 17.1838 16.7678 17.3438 16.5438 17.3438H15.4558C15.2318 17.3438 15.0398 17.1518 15.0398 16.9278L14.6878 9.98375C14.6878 9.63175 14.9758 9.34375 15.3278 9.34375ZM15.4558 19.4558H16.5438C16.9278 19.4558 17.2158 19.7438 17.1838 20.1278V21.1838C17.1838 21.5678 16.8958 21.8558 16.5438 21.8558H15.4558C15.0718 21.8558 14.7838 21.5678 14.7838 21.1838V20.1278C14.7838 19.7438 15.0718 19.4558 15.4558 19.4558Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild},Bf=Wi((e=>{var t,n,i,o,r;return r=class extends(xi(Cs,Of,pd,Os)(e)){constructor(){super(...arguments),t.add(this),o.set(this,Ni((e=>{e.length&&(e.forEach((({type:e,msg:o})=>{const r=u(this,t,"m",i).call(this,e);r.setContent(u(this,t,"m",n).call(this,{type:e,msg:o})),r.show()})),setTimeout((()=>this.actions.clearNotifications())))})))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this),this.subscribe(u(this,o,"f").bind(this),Wh)}))}},o=new WeakMap,t=new WeakSet,n=function({type:e,msg:t}){const n=qf[e],i=Object.assign((new DOMParser).parseFromString('<svg width="2em" height="2em" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Icon">\n<path id="Shape" d="M10.6712 12L7.27521 8.60406C6.90826 8.23711 6.90826 7.64216 7.27521 7.27521C7.64216 6.90826 8.23711 6.90826 8.60406 7.27521L12 10.6712L15.3959 7.27521C15.7629 6.90826 16.3578 6.90826 16.7248 7.27521C17.0917 7.64216 17.0917 8.23711 16.7248 8.60406L13.3288 12L16.7248 15.3959C17.0917 15.7629 17.0917 16.3578 16.7248 16.7248C16.3578 17.0917 15.7629 17.0917 15.3959 16.7248L12 13.3288L8.60406 16.7248C8.23711 17.0917 7.64216 17.0917 7.27521 16.7248C6.90826 16.3578 6.90826 15.7629 7.27521 15.3959L10.6712 12Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,{slot:"close"});return`${(null==n?void 0:n.outerHTML)||""}${t}${i.outerHTML}`},i=function(e){return this.createNotification({mode:e,duration:"error"===e?0:3e3,position:"bottom-start",size:"sm"})},r})),Vf=Wi((e=>{var t,n,i;return i=class extends(xi(Of,ud,bc,Cs,Af)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",n).call(this)}))}},t=new WeakSet,n=function(){return c(this,void 0,void 0,(function*(){this.rotatedAccessKeyModal=this.createModal(),this.rotatedAccessKeyModal.setContent(Oi(yield this.fetchWidgetPage("rotated-access-key-modal.html"))),new ka((()=>{var e;return null===(e=this.rotatedAccessKeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-close"]')}),{logger:this.logger}).onClick((()=>{navigator.clipboard.writeText(this.getFormData(this.rotatedAccessKeyModal.ele)["generated-key"]),this.resetFormData(this.rotatedAccessKeyModal.ele),this.rotatedAccessKeyModal.close()}))}))},i})),Kf=Wi((e=>{var t,n,i;return i=class extends(xi(Of,ud,bc,Cs,Af,Vf)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),yield u(this,t,"m",n).call(this)}))}},t=new WeakSet,n=function(){return c(this,void 0,void 0,(function*(){var e;this.rotateAccessKeyModal=this.createModal(),this.rotateAccessKeyModal.setContent(Oi(yield this.fetchWidgetPage("rotate-access-key-modal.html")));const t=new ka((()=>{var e;return null===(e=this.rotateAccessKeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger});t.onClick((()=>this.rotateAccessKeyModal.close()));const n=new ka((()=>{var e;return null===(e=this.rotateAccessKeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});n.onClick((()=>c(this,void 0,void 0,(function*(){var e,t;const n=null===(e=Uh(this.state))||void 0===e?void 0:e[0];if(!n)return void this.rotateAccessKeyModal.close();const i=yield this.actions.rotateAccessKey({id:n.id});this.rotateAccessKeyModal.close(),(null===(t=null==i?void 0:i.payload)||void 0===t?void 0:t.cleartext)&&(this.setFormData(this.rotatedAccessKeyModal.ele,{"generated-key":i.payload.cleartext}),this.rotatedAccessKeyModal.open())}))));const i=new id(null===(e=this.rotateAccessKeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.rotateAccessKeyModal.beforeOpen=()=>{const e=Kh(this.state);i.text=`Rotate ${e}?`}}))},i})),Hf=Wi((e=>{var t,n,i,o;return o=class extends(xi(Cs,Af,Of,Kf)(e)){constructor(){super(...arguments),t.add(this),i.set(this,Ni((e=>{e?this.rotateButton.enable():this.rotateButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),u(this,t,"m",n).call(this),this.subscribe(u(this,i,"f").bind(this),Hh)}))}},i=new WeakMap,t=new WeakSet,n=function(){var e;this.rotateButton=new ka(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="rotate-access-keys"]'),{logger:this.logger}),this.rotateButton.disable(),this.rotateButton.onClick((()=>{this.rotateAccessKeyModal.open()}))},o})),zf=Wi((e=>class extends(xi(fa,sa,Nf,Wf,Ff,_f,Mf,Uf,Hf,Bf,Oc)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),Jf=xi((e=>class extends(zf(e)){}))(HTMLElement);customElements.define("descope-access-key-management-widget",Jf);var Gf,Zf=Object.freeze({__proto__:null,default:Jf});!function(e){e.oidc="oidc",e.saml="saml",e.wsfed="wsfed",e.custom="custom"}(Gf||(Gf={}));const Yf=e=>e.ssoAppsList.data,Xf=Al(Yf,(e=>{var t;return null===(t=null==e?void 0:e.filter)||void 0===t?void 0:t.call(e,(e=>e.appType===Gf.saml))})),Qf=Al(Yf,(e=>{var t;return null===(t=null==e?void 0:e.filter)||void 0===t?void 0:t.call(e,(e=>{var t;return e.appType===Gf.oidc&&(null===(t=e.oidcSettings)||void 0===t?void 0:t.customIdpInitiatedLoginPageUrl)}))})),ep=Al(Yf,(e=>{var t;return null===(t=null==e?void 0:e.filter)||void 0===t?void 0:t.call(e,(e=>{var t;return e.appType===Gf.wsfed&&(null===(t=e.wsfedSettings)||void 0===t?void 0:t.idpInitiatedUrl)}))})),tp=Al(Yf,(e=>{var t;return null===(t=null==e?void 0:e.filter)||void 0===t?void 0:t.call(e,(e=>e.appType===Gf.custom))})),np=e=>{var t,n,i,o;switch(e.appType){case Gf.saml:return null===(t=e.samlSettings)||void 0===t?void 0:t.idpInitiatedUrl;case Gf.oidc:return null===(n=e.oidcSettings)||void 0===n?void 0:n.customIdpInitiatedLoginPageUrl;case Gf.wsfed:return null===(i=e.wsfedSettings)||void 0===i?void 0:i.idpInitiatedUrl;case Gf.custom:return null===(o=e.customSettings)||void 0===o?void 0:o.loginPageUrl;default:return}},ip=Al(Xf,Qf,ep,tp,((e,t,n,i)=>[...e,...t,...n,...i].map((e=>({name:e.name,icon:e.logo,url:np(e)}))))),op=lc("ssoApps/load",((e,{extra:{api:t}})=>t.ssoApps.load())),rp=(e=>(...t)=>n=>{n.addCase(e.pending,((e,n)=>{t.forEach((({onPending:t})=>{null==t||t(e,n)}))})),n.addCase(e.fulfilled,((e,n)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,n)}))})),n.addCase(e.rejected,((e,n)=>{t.forEach((({onRejected:t})=>{null==t||t(e,n)}))}))})(op)({onFulfilled:(e,t)=>{var n;e.ssoAppsList.data=null===(n=t.payload)||void 0===n?void 0:n.apps}},(sp=e=>e.ssoAppsList,{onFulfilled:e=>{sp(e).loading=!1},onPending:e=>{sp(e).loading=!0,sp(e).error=null},onRejected:(e,t)=>{sp(e).loading=!1,sp(e).error=t.error}}));var sp;const ap={action:op,reducer:rp},dp={ssoAppsList:{data:[],loading:!1,error:null}},lp="/v1/mgmt/sso/idp/apps/load",cp=({httpClient:e,mock:t})=>({load:()=>c(void 0,void 0,void 0,(function*(){if(t)return c(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({apps:[{id:"ssoapp1",name:"App 1",description:"This is the first SAML app",enabled:!0,appType:Gf.saml,logo:"logo1",samlSettings:{idpInitiatedUrl:""}},{id:"ssoapp2",name:"App 2",description:"This is the first OIDC app",enabled:!0,appType:Gf.oidc,logo:"logo2"},{id:"ssoapp3",name:"App 3",description:"This is the second SAML app",enabled:!0,appType:Gf.saml,logo:"logo3",samlSettings:{idpInitiatedUrl:""}},{id:"ssoapp4",name:"App 4",description:"This is a WS-Fed app",enabled:!0,appType:Gf.wsfed,logo:"logo4",wsfedSettings:{idpInitiatedUrl:"http://localhost/wsfed/idp-initiated",realm:"urn:mock:realm",replyUrl:"http://localhost/reply",loginPageUrl:"http://localhost/login"}}]})}))}));const n=yield e.get(lp);return yield(e=>c(void 0,void 0,void 0,(function*(){const t=yield e.text(),n=JSON.parse(t);if(!e.ok){const t=`${n.errorDescription}${n.errorMessage?`: ${n.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(n),e.text=()=>Promise.resolve(t)})))(n),n.json()}))}),up=Wi((e=>{var t,n,i,o;const r=xi(js,As,Cs,Sc,Ms)(e);return o=class extends r{constructor(){super(...arguments),t.add(this),n.set(this,void 0)}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get api(){return u(this,n,"f")||u(this,t,"m",i).call(this),u(this,n,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.init)||void 0===o?void 0:o.call(this),this.observeAttributes(["project-id","base-url"],(()=>{u(this,n,"f")&&u(this,t,"m",i).call(this)}))}))}},n=new WeakMap,t=new WeakSet,i=function(){this.logger.debug("creating an sdk instance"),h(this,n,((e,t,n)=>{const i=bi(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"applications-portal-widget","x-descope-widget-id":n,"x-descope-widget-version":"0.9.20"}}));return{ssoApps:cp({httpClient:i.httpClient,mock:t}),httpClient:i.httpClient}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},"true"===this.mock,this.widgetId),"f")},o})),hp=Wi((e=>{const t=xi(yc({name:"widget",initialState:dp,reducers:{},extraReducers:e=>{ap.reducer(e)},asyncActions:{loadSSOApps:ap.action}}),Os,Cs,up)(e);return class extends t{constructor(...e){super(...e),this.state=dp,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),fp=Wi((e=>{var t,n,i,o;return o=class extends(xi(Cs,Os,Hs,Xs,Cc("applications-portal-widget"),hp)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){return c(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.init)||void 0===o?void 0:o.call(this);const[r]=yield Promise.all([u(this,t,"m",n).call(this),this.actions.loadSSOApps()]);u(this,t,"m",i).call(this,r),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,n=function(){return c(this,void 0,void 0,(function*(){const e=Oi(yield this.fetchWidgetPage("root.html"));return yield this.loadDescopeUiComponents(e),e}))},i=function(e){this.contentRootElement.append(e.content.cloneNode(!0))},o})),pp=Wi((e=>{var t,n,i;return i=class extends(xi(hp,Cs,fp)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",n).call(this,ip(this.state))}))}},t=new WeakSet,n=function(e){this.appsList=new ba((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-apps-list")}),{logger:this.logger}),this.appsList.data=e},i})),vp=Wi((e=>class extends(xi(fa,sa,pp,Oc)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),gp=xi((e=>class extends(vp(e)){}))(HTMLElement);customElements.define("descope-applications-portal-widget",gp);var mp=Object.freeze({__proto__:null,default:gp});const yp=(e,t)=>t?{[e]:t}:{},bp=e=>{if(!e)return;const t=JSON.parse(e);return Array.isArray(t)&&0===t.length?void 0:t},wp=e=>e.selectedAuditId,$p=Al((e=>e.auditList.data),(e=>e.map((e=>{const t=e||{},{occurred:n,ID:i,type:o}=t,r=t.data,s=void 0===r?{saml_request:"",saml_response:"",saml_generated_user:"",saml_generated_roles:"",oidc_response:"",oidc_generated_user:"",scim_request:"",scim_result:"",Change:""}:r,{saml_request:a,saml_response:d,saml_generated_user:c,saml_generated_roles:u,oidc_response:h,oidc_generated_user:f,scim_request:p,scim_result:v,Change:g}=s,m=l(s,["saml_request","saml_response","saml_generated_user","saml_generated_roles","oidc_response","oidc_generated_user","scim_request","scim_result","Change"]),y=l(t,["occurred","ID","type","data"]);var b;return(e=>Object.fromEntries(Object.entries(e).filter((([e,t])=>!!t))))(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},y),{data:m}),yp("type",(b=o)&&b[0].toUpperCase()+b.slice(1))),yp("saml_request",a)),yp("saml_response",d)),yp("saml_generated_user",bp(c))),yp("saml_generated_roles",bp(u))),yp("oidc_response",bp(h))),yp("oidc_generated_user",bp(f))),yp("scim_request",p)),yp("scim_result",v)),yp("Change",g)),{occurredFormatted:n?new Date(Number(n)||0).toLocaleString():"N/A"}))}))));Al(wp,$p,((e,t)=>t.find((t=>e===t.id)))),Al(wp,(e=>!!e));const kp=lc("audit/search",((e,{extra:{api:t},getState:n})=>{const i=n().searchParams;return t.audit.search(Object.assign(Object.assign({},i),e))})),Cp=(e=>(...t)=>n=>{n.addCase(e.pending,((e,n)=>{t.forEach((({onPending:t})=>{null==t||t(e,n)}))})),n.addCase(e.fulfilled,((e,n)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,n)}))})),n.addCase(e.rejected,((e,n)=>{t.forEach((({onRejected:t})=>{null==t||t(e,n)}))}))})(kp)({onPending:(e,t)=>{e.searchParams=Object.assign(Object.assign({},e.searchParams),t.meta.arg)},onFulfilled:(e,t)=>{e.auditList.data=t.payload}},(Sp=e=>e.auditList,{onFulfilled:e=>{Sp(e).loading=!1},onPending:e=>{Sp(e).loading=!0,Sp(e).error=null},onRejected:(e,t)=>{Sp(e).loading=!1,Sp(e).error=t.error}}));var Sp;const Ip={action:kp,reducer:Cp},Rp={auditList:{data:[],loading:!1,error:null},searchParams:{text:"",sort:[]},selectedAuditId:""},Ep="/v1/mgmt/audit/search",xp=({httpClient:e,tenant:t,mock:n})=>({search:(...i)=>c(void 0,[...i],void 0,(function*({page:i,limit:o=1e4,text:r,sort:s,from:a}={}){if(n)return(e=>c(void 0,[e],void 0,(function*({text:e,sort:t}){return new Promise((n=>{const i=[],o=(new Date).getTime()/1e3+2592e3,r=new Date(o).toLocaleString();for(let e=1;e<9;e+=1)i.push({id:`Audit ${e}`,action:`Action ${e}`,actorId:`Actor ${e}`,type:"info",method:`Method ${e}`,userId:`User ${e}`,device:`Device ${e}`,geo:`Geo ${e}`,remoteAddress:`127.0.0.${e}`,externalIds:[`Login ID ${e}`],occurred:o,occurredFormatted:r});t.forEach((e=>{i.sort(((t,n)=>{var i,o;return e.desc?null===(o=n[e.field])||void 0===o?void 0:o.localeCompare(t[e.field]):null===(i=t[e.field])||void 0===i?void 0:i.localeCompare(n[e.field])}))})),n(i.filter((t=>t.id.toLowerCase().includes(e.toLowerCase())||t.action.toLowerCase().includes(e.toLowerCase())||t.type.toLowerCase().includes(e.toLowerCase())||t.device.toLowerCase().includes(e.toLowerCase())||t.method.toLowerCase().includes(e.toLowerCase())||t.geo.toLowerCase().includes(e.toLowerCase())||t.remoteAddress.toLowerCase().includes(e.toLowerCase())||t.externalIds.includes(e.toLowerCase())||t.userId.toLowerCase().includes(e.toLowerCase()))))}))})))({page:i,limit:o,text:r,sort:s});const d=yield e.post(Ep,{limit:o,page:i,text:r,sort:s,from:a},{queryParams:{tenant:t}});return yield(e=>c(void 0,void 0,void 0,(function*(){const t=yield e.text(),n=JSON.parse(t);if(!e.ok){const t=`${n.errorDescription}${n.errorMessage?`: ${n.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(n),e.text=()=>Promise.resolve(t)})))(d),(yield d.json()).audits}))}),Op=Wi((e=>{var t,n,i,o;const r=xi(js,As,Cs,Ms,Sc,Ns({tenant:Ns.missingAttrValidator}))(e);return o=class extends r{constructor(){super(...arguments),t.add(this),n.set(this,void 0)}get tenantId(){return this.getAttribute("tenant")}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get api(){return u(this,n,"f")||u(this,t,"m",i).call(this),u(this,n,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.init)||void 0===o?void 0:o.call(this),this.observeAttributes(["project-id","base-url","tenant"],(()=>{u(this,n,"f")&&u(this,t,"m",i).call(this)}))}))}},n=new WeakMap,t=new WeakSet,i=function(){this.logger.debug("creating an sdk instance"),h(this,n,((e,t,n,i)=>{const o=bi(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"audit-management-widget","x-descope-widget-id":i,"x-descope-widget-version":"0.9.20"}}));return{audit:xp({httpClient:o.httpClient,tenant:t,mock:n}),httpClient:o.httpClient}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},this.tenantId,"true"===this.mock,this.widgetId),"f")},o})),Ap=Wi((e=>{const t=xi(yc({name:"widget",initialState:Rp,reducers:{setSelectedAuditId:(e,{payload:t})=>{e.selectedAuditId=t}},extraReducers:e=>{Ip.reducer(e)},asyncActions:{searchAudit:Ip.action}}),Os,Cs,Op)(e);return class extends t{constructor(...e){super(...e),this.state=Rp,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),Np=Wi((e=>{var t,n,i;return i=class extends(xi(Cs,Os,Hs,Xs,Cc("audit-management-widget"),Ap)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){return c(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.init)||void 0===i?void 0:i.call(this),yield Promise.all([u(this,t,"m",n).call(this)]),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,n=function(){return c(this,void 0,void 0,(function*(){const e=Oi(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},i})),jp=Wi((e=>{var t,n,i,o,r;return r=class extends(xi(Cs,Np,Ap)(e)){constructor(){super(...arguments),t.add(this),n.set(this,Pi((()=>{const e=this.rangeInput.value,t=new Date;let n;switch(e){case"minuets15":n=t.setMinutes(t.getMinutes()-15);break;case"hour":n=t.setHours(t.getHours()-1);break;case"hour6":n=t.setHours(t.getHours()-6);break;case"day":default:n=t.setDate(t.getDate()-1);break;case"day3":n=t.setDate(t.getDate()-3);break;case"week":n=t.setDate(t.getDate()-7);break;case"week2":n=t.setDate(t.getDate()-14);break;case"month":n=t.setMonth(t.getMonth()-1)}this.actions.searchAudit({text:this.searchInput.value,from:Math.floor(new Date(n).getTime())})})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),u(this,t,"m",i).call(this),u(this,t,"m",o).call(this)}))}},n=new WeakMap,t=new WeakSet,i=function(){var e;this.searchInput=new od(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="search-input"]'),{logger:this.logger}),this.searchInput.onInput(u(this,n,"f")),u(this,n,"f").call(this)},o=function(){var e;this.rangeInput=new nd(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="range-input"]'),{logger:this.logger}),this.rangeInput.onInput(u(this,n,"f"))},r})),Mp=Wi((e=>{var t,n,i,o;return o=class extends(xi(Ap,Cs,Np)(e)){constructor(){super(...arguments),t.add(this),i.set(this,Ni((e=>{this.auditTable.data=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),u(this,t,"m",n).call(this),u(this,i,"f").call(this,$p(this.state)),this.subscribe(u(this,i,"f").bind(this),$p)}))}},i=new WeakMap,t=new WeakSet,n=function(){var e;this.auditTable=new Ea(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="audit-table"]'),{logger:this.logger}),this.auditTable.onSelectedItemsChange((e=>{this.actions.setSelectedAuditId(e.detail.value.map((({id:e})=>e)))}))},o})),Pp=[{header:"Occurred",path:"occurredFormatted"},{header:"User ID",path:"userId"},{header:"Actor",path:"actorId"},{header:"Login IDs",path:"externalIds"},{header:"Remote Address",path:"remoteAddress"},{header:"Type",path:"type"},{header:"Action",path:"action"},{header:"Device",path:"device"},{header:"Method",path:"method"},{header:"Geo",path:"geo"}],Tp=Wi((e=>{var t,n,i;return i=class extends(xi(Cs,Np,Ap)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",n).call(this)}))}},t=new WeakSet,n=function(){var e;this.exportButton=new ka(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="export-button"]'),{logger:this.logger}),this.exportButton.onClick((()=>{const e=$p(this.state);if(!e.length)return void this.logger.warn("No audit data to export");const t=((e,t)=>[t.map((e=>Vi(e.header))).join(","),...e.map((e=>t.map((t=>Vi(e[t.path]))).join(",")))].join("\n"))(e,Pp);((e,t)=>{const n=new Blob(["\ufeff"+e],{type:"text/csv;charset=utf-8;"}),i=URL.createObjectURL(n),o=document.createElement("a");o.href=i,o.setAttribute("download",t),document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(i)})(t,`audit_logs_${(new Date).toISOString().slice(0,10)}.csv`)}))},i})),Wp=Wi((e=>class extends(xi(fa,sa,Mp,jp,Tp,Oc)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),Lp=xi((e=>class extends(Wp(e)){}))(HTMLElement);customElements.define("descope-audit-management-widget",Lp);var Up=Object.freeze({__proto__:null,default:Lp});function Dp(e){return new URLSearchParams(window.location.search).get(e)}const Fp=e=>(...t)=>n=>{n.addCase(e.pending,((e,n)=>{t.forEach((({onPending:t})=>{null==t||t(e,n)}))})),n.addCase(e.fulfilled,((e,n)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,n)}))})),n.addCase(e.rejected,((e,n)=>{t.forEach((({onRejected:t})=>{null==t||t(e,n)}))}))},_p=e=>({onFulfilled:t=>{e(t).loading=!1},onPending:t=>{e(t).loading=!0,e(t).error=null},onRejected:(t,n)=>{e(t).loading=!1,e(t).error=n.error}}),qp=lc("outboundApps/load",((e,{extra:{api:t}})=>t.outboundApps.getAllOutboundApps())),Bp=Fp(qp)({onFulfilled:(e,t)=>{var n;e.outboundAppsList.data=null===(n=t.payload)||void 0===n?void 0:n.apps}},_p((e=>e.outboundAppsList))),Vp={action:qp,reducer:Bp},Kp=lc("outboundApps/getConnectedOutboundApps",((e,{extra:{api:t}})=>t.outboundApps.getConnectedOutboundApps(e))),Hp=Fp(Kp)({onFulfilled:(e,t)=>{var n;e.connectedOutboundAppsIds.data=null===(n=t.payload)||void 0===n?void 0:n.appIds}},_p((e=>e.connectedOutboundAppsIds))),zp={action:Kp,reducer:Hp},Jp={outboundAppsList:{data:[],loading:!1,error:null},connectedOutboundAppsIds:{data:[],loading:!1,error:null},allowedAppsIds:{data:void 0},me:{loading:!1,error:null,data:{}}},Gp="/v1/mgmt/outbound/apps",Zp="/v1/mgmt/outbound/apps-with-user-token",Yp="/v1/auth/me",Xp=e=>c(void 0,void 0,void 0,(function*(){const t=yield e.text(),n=JSON.parse(t);if(!e.ok){const t=`${n.errorDescription}${n.errorMessage?`: ${n.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(n),e.text=()=>Promise.resolve(t)})),Qp=({httpClient:e,mock:t})=>({getAllOutboundApps:()=>c(void 0,void 0,void 0,(function*(){if(t)return c(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({apps:[{id:"appId1",name:"Application 1",description:"Description"},{id:"appId2",name:"Application 2",description:"Description"},{id:"appId3",name:"Application 3",description:"Description"}]})}))}));const n=yield e.get(Gp);return yield Xp(n),n.json()})),getConnectedOutboundApps:n=>c(void 0,[n],void 0,(function*({userId:n,tenantId:i}){if(t)return c(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({apps:["outboundApp3"]})}))}));const o=yield e.get(Zp,{queryParams:i?{userId:n,tenantId:i}:{userId:n}});return yield Xp(o),o.json()}))}),ev=({httpClient:e,mock:t})=>({me:()=>c(void 0,void 0,void 0,(function*(){if(t)return c(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({userId:"user-1"})}))}));const n=yield e.get(Yp);return yield Xp(n),n.json()}))}),tv=Wi((e=>{var t,n,i,o;const r=xi(js,As,Cs,Sc,Ms)(e);return o=class extends r{constructor(){super(...arguments),t.add(this),n.set(this,void 0)}get tenantId(){return this.getAttribute("tenant")}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get styleId(){return this.getAttribute("style-id")||Qs}get api(){return u(this,n,"f")||u(this,t,"m",i).call(this),u(this,n,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.init)||void 0===o?void 0:o.call(this),this.observeAttributes(["project-id","base-url"],(()=>{u(this,n,"f")&&u(this,t,"m",i).call(this)}))}))}},n=new WeakMap,t=new WeakSet,i=function(){this.logger.debug("creating an sdk instance"),h(this,n,((e,t,n)=>{const i=bi(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"outbound-applications-widget","x-descope-widget-id":n,"x-descope-widget-version":"0.7.27"}}));return{outboundApps:Qp({httpClient:i.httpClient,mock:t}),user:Object.assign({},ev({httpClient:i.httpClient,mock:t})),httpClient:i.httpClient}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},"true"===this.mock,this.widgetId),"f")},o})),nv=lc("users/me",((e,{extra:{api:t}})=>t.user.me())),iv={action:nv,reducer:Fp(nv)({onFulfilled:(e,t)=>{e.me.data=t.payload}},_p((e=>e.me)))},ov=Wi((e=>{const t=xi(yc({name:"widget",initialState:Jp,reducers:{setAllowedAppsIds:(e,{payload:t})=>{e.allowedAppsIds.data=t}},extraReducers:e=>{iv.reducer(e),zp.reducer(e),Vp.reducer(e)},asyncActions:{getMe:iv.action,getOutboundApps:Vp.action,getConnectedOutboundApps:zp.action}}),Os,Cs,tv)(e);return class extends t{constructor(...e){super(...e),this.state=Jp,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),rv="widget-flow",sv=Wi((e=>{var t,n,i;return i=class extends(xi(kc,Os,hd,ov,Sc,Cs,sa,Ic)(e)){constructor(){super(...arguments),t.add(this)}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.init)||void 0===i?void 0:i.call(this);const o=Dp(rv);o&&(function(e){if(window.history.replaceState&&Dp(e)){const t=new URL(window.location.href),n=new URLSearchParams(t.search);n.delete(e),t.search=n.toString(),window.history.replaceState({},"",t.toString())}}(rv),u(this,t,"m",n).call(this,o))}))}},t=new WeakSet,n=function(e){const t=this.createFlowModal({"data-id":"redirect-flow"});t.setContent(this.createFlowTemplate({flowId:e})),new Ca((()=>{var e;return null===(e=t.ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}).onSuccess((()=>{t.close(),this.actions.getMe()})),t.afterClose=()=>{t.remove()},t.open()},i})),av=Al((e=>e.outboundAppsList.data),(e=>e.connectedOutboundAppsIds.data),(e=>e.allowedAppsIds.data),((e,t,n)=>e.filter((e=>void 0===n||n.includes(e.id))).map((e=>{const n=(null==t?void 0:t.includes(e.id))||!1;return Object.assign(Object.assign({},e),{appId:e.id,isConnected:n})})).sort(((e,t)=>e.name.localeCompare(t.name))))),dv=Al((e=>e.me.data),(e=>e.userId)),lv=Wi((e=>{var t,n,i,o,r;return r=class extends(xi(Cs,Os,Hs,Xs,Cc("outbound-applications-widget"),ov)(e)){constructor(){super(...arguments),t.add(this)}static get observedAttributes(){return["allowed-outbound-apps-ids"]}attributeChangedCallback(e,n,i){"allowed-outbound-apps-ids"===e&&n!==i&&this.actions.setAllowedAppsIds(u(this,t,"a",o))}onWidgetRootReady(){return c(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var r;yield null===(r=e.init)||void 0===r?void 0:r.call(this),yield this.actions.getMe(),yield this.actions.setAllowedAppsIds(u(this,t,"a",o)),yield Promise.all([this.actions.getOutboundApps(),this.actions.getConnectedOutboundApps({userId:dv(this.state),tenantId:this.tenantId})]);const s=yield u(this,t,"m",n).call(this);u(this,t,"m",i).call(this,s),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,n=function(){return c(this,void 0,void 0,(function*(){const e=Oi(yield this.fetchWidgetPage("root.html"));return yield this.loadDescopeUiComponents(e),e}))},i=function(e){this.contentRootElement.append(e.content.cloneNode(!0))},o=function(){var e;if(!this.hasAttribute("allowed-outbound-apps-ids"))return;const t=null===(e=this.getAttribute("allowed-outbound-apps-ids"))||void 0===e?void 0:e.trim();return t?t.split(",").map((e=>e.trim())).filter(Boolean):[]},r})),cv=Wi((e=>class extends(xi(sa,As)(e)){syncFlowTheme(e){e.theme=this.theme,this.observeAttributes(["theme"],(()=>{e.theme=this.theme}))}})),uv=Wi((e=>{var t,n,i,o,r,s,a,d,l,f,p,v,g,m,y,b,w;return w=class extends(xi(kc,cv,ov,Cs,lv,hd,Ic)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),i.set(this,void 0),o.set(this,void 0),r.set(this,void 0),s.set(this,void 0),a.set(this,null),d.set(this,null),b.set(this,Ni((e=>{u(this,n,"f").data=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),u(this,t,"m",y).call(this,av(this.state)),u(this,t,"m",l).call(this),u(this,t,"m",v).call(this),this.subscribe(u(this,b,"f").bind(this),av)}))}},n=new WeakMap,i=new WeakMap,o=new WeakMap,r=new WeakMap,s=new WeakMap,a=new WeakMap,d=new WeakMap,b=new WeakMap,t=new WeakSet,l=function(){u(this,n,"f").connectFlowId&&(h(this,i,this.createFlowModal({"data-id":"outbound-apps-connect"}),"f"),u(this,i,"f").afterClose=()=>{var e;if(u(this,a,"f")){const t=null===(e=u(this,i,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc");null==t||t.removeEventListener("page-updated",u(this,a,"f")),h(this,a,null,"f")}},h(this,r,new Ca((()=>{var e;return null===(e=u(this,i,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(u(this,r,"f")))},f=function(e,t,n){e.open(),t.removeEventListener("page-updated",n)},p=function(e,n){var i;const o=null===(i=e.ele)||void 0===i?void 0:i.querySelector("descope-wc"),r=()=>u(this,t,"m",f).call(this,e,o,r);n=r,null==o||o.addEventListener("page-updated",n)},v=function(){h(this,o,this.createFlowModal({"data-id":"outbound-apps-disconnect"}),"f"),h(this,s,new Ca((()=>{var e;return null===(e=u(this,o,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,o,"f").afterClose=()=>{var e;if(u(this,d,"f")){const t=null===(e=u(this,o,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc");null==t||t.removeEventListener("page-updated",u(this,d,"f")),h(this,d,null,"f")}},this.syncFlowTheme(u(this,s,"f"))},g=function(e){u(this,i,"f").setContent(this.createFlowTemplate({flowId:u(this,n,"f").connectFlowId,lazyStart:!1,outboundAppId:e})),u(this,t,"m",p).call(this,u(this,i,"f"),u(this,a,"f")),u(this,r,"f").onSuccess((()=>{u(this,i,"f").close(),this.actions.getConnectedOutboundApps({userId:dv(this.state),tenantId:this.tenantId})}))},m=function(e){u(this,o,"f").setContent(this.createFlowTemplate({flowId:u(this,n,"f").disconnectFlowId,lazyStart:!1,outboundAppId:e})),u(this,t,"m",p).call(this,u(this,o,"f"),u(this,d,"f")),u(this,s,"f").onSuccess((()=>{u(this,o,"f").close(),this.actions.getConnectedOutboundApps({userId:dv(this.state)})}))},y=function(e){h(this,n,new td((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-outbound-apps")}),{logger:this.logger}),"f"),u(this,n,"f").onConnectClick((({id:e})=>{u(this,t,"m",g).call(this,e)})),u(this,n,"f").onDisconnectClick((({id:e})=>{u(this,t,"m",m).call(this,e)})),u(this,n,"f").data=e},w})),hv=Wi((e=>class extends(xi(fa,sa,sv,uv,Oc)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),fv=xi((e=>class extends(hv(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this),(customElements.get("descope-wc")||(yield Promise.resolve().then((function(){return Ph})).then((e=>e.default)))).sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"outbound-applications-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.7.27"}}}))}}))(HTMLElement);customElements.define("descope-outbound-applications-widget",fv);var pv=Object.freeze({__proto__:null,default:fv});const vv=e=>e.selectedRolesIds,gv=e=>e.notifications,mv=e=>e.tenantPermissions.data||[],yv=Al((e=>e.rolesList.data),(e=>e.map((e=>{var t;return Object.assign(Object.assign({},e),{editable:0===(null===(t=null==e?void 0:e.tenantId)||void 0===t?void 0:t.length)?"no":"yes"})})))),bv=Al(vv,yv,((e,t)=>t.filter((t=>e.includes(t.name))))),wv=Al(vv,(e=>!!e.length)),$v=Al(vv,(e=>1===e.length)),kv=Al(bv,$v,((e,t)=>t&&"yes"===e[0].editable)),Cv=Al(bv,(e=>1===e.length?e[0].name:`${e.length} roles`)),Sv=e=>(...t)=>n=>{n.addCase(e.pending,((e,n)=>{t.forEach((({onPending:t})=>{null==t||t(e,n)}))})),n.addCase(e.fulfilled,((e,n)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,n)}))})),n.addCase(e.rejected,((e,n)=>{t.forEach((({onRejected:t})=>{null==t||t(e,n)}))}))},Iv=e=>({onFulfilled:t=>{e(t).loading=!1},onPending:t=>{e(t).loading=!0,e(t).error=null},onRejected:(t,n)=>{e(t).loading=!1,e(t).error=n.error}}),Rv=({getErrorMsg:e,getSuccessMsg:t})=>({onFulfilled:(e,n)=>{t&&e.notifications.push({type:"success",msg:t(n)})},onRejected:(t,n)=>{e&&t.notifications.push({type:"error",msg:e(n)})}}),Ev=lc("roles/create",((e,{extra:{api:t}})=>t.role.create(e))),xv=Sv(Ev)({onFulfilled:(e,t)=>{e.rolesList.data.unshift(t.payload)}},Iv((e=>e.createRole)),Rv({getSuccessMsg:()=>"Role created successfully",getErrorMsg:e=>{var t;const n=null===(t=e.error)||void 0===t?void 0:t.message;return`\n <div>\n <div>Failed to create role</div>\n ${Ki(n)}\n </div>`}})),Ov={action:Ev,reducer:xv},Av=lc("roles/delete",((e,{extra:{api:t}})=>t.role.deleteBatch(e))),Nv=Sv(Av)({onFulfilled:(e,t)=>{e.rolesList.data=e.rolesList.data.filter((e=>{var n;return 0===(null===(n=null==e?void 0:e.tenantId)||void 0===n?void 0:n.length)||!t.meta.arg.includes(e.name)})),e.selectedRolesIds=[]}},Iv((e=>e.deleteRole)),Rv({getSuccessMsg:e=>Mi(e.meta.arg.length)`${["",e.meta.arg.length]} ${["R","r"]}ole${["","s"]} deleted successfully`,getErrorMsg:e=>Mi(e.meta.arg.length)`Failed to delete role${["","s"]}`})),jv={action:Av,reducer:Nv},Mv=lc("roles/duplicate",((e,{extra:{api:t}})=>t.role.create(e))),Pv=Sv(Mv)({onFulfilled:(e,t)=>{e.rolesList.data.unshift(t.payload)}},Iv((e=>e.duplicateRole)),Rv({getSuccessMsg:()=>"Role duplicated successfully",getErrorMsg:e=>{var t;const n=null===(t=e.error)||void 0===t?void 0:t.message;return`\n <div>\n <div>Failed to duplicate role</div>\n ${Ki(n)}\n </div>`}})),Tv={action:Mv,reducer:Pv},Wv=lc("roles/search",((e,{extra:{api:t},getState:n})=>{const i=n().searchParams;return t.role.search(Object.assign(Object.assign({},i),e))})),Lv=Sv(Wv)({onPending:(e,t)=>{e.searchParams=Object.assign(Object.assign({},e.searchParams),t.meta.arg)},onFulfilled:(e,t)=>{e.rolesList.data=t.payload}},Iv((e=>e.rolesList))),Uv={action:Wv,reducer:Lv},Dv=lc("roles/update",((e,{extra:{api:t}})=>t.role.update(e))),Fv=Sv(Dv)({onFulfilled:(e,t)=>{const n=e.rolesList.data.findIndex((e=>e.name===t.payload.oldName));-1!==n&&(e.rolesList.data[n]=t.payload)}},Iv((e=>e.updateRole)),Rv({getSuccessMsg:()=>"Role updated successfully",getErrorMsg:e=>{var t;const n=null===(t=e.error)||void 0===t?void 0:t.message;return`\n <div>\n <div>Failed to update role</div>\n ${Ki(n)}\n </div>`}})),_v={action:Dv,reducer:Fv},qv=lc("tenant/getTenantPermissions",((e,{extra:{api:t}})=>t.tenant.getTenantPermissions())),Bv={action:qv,reducer:Sv(qv)({onFulfilled:(e,t)=>{e.tenantPermissions.data=t.payload.permissions}},Iv((e=>e.tenantPermissions)))},Vv={rolesList:{data:[],loading:!1,error:null},createRole:{loading:!1,error:null},duplicateRole:{loading:!1,error:null},updateRole:{loading:!1,error:null},deleteRole:{loading:!1,error:null},tenantPermissions:{loading:!1,error:null,data:[]},searchParams:{text:"",sort:[]},selectedRolesIds:[],notifications:[]},Kv="/v1/mgmt/role/search",Hv="/v1/mgmt/role/delete/batch",zv="/v1/mgmt/role/create",Jv="/v1/mgmt/role/update",Gv="/v1/mgmt/permission/all",Zv=e=>c(void 0,void 0,void 0,(function*(){const t=yield e.text(),n=JSON.parse(t);if(!e.ok){const t=`${n.errorDescription}${n.errorMessage?`: ${n.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(n),e.text=()=>Promise.resolve(t)})),Yv=({httpClient:e,tenant:t,mock:n})=>({search:(...i)=>c(void 0,[...i],void 0,(function*({page:i,limit:o=1e4,text:r,sort:s}={}){if(n)return((e,t)=>c(void 0,[e,t],void 0,(function*({text:e,sort:t},n){return new Promise((i=>{const o=[];for(let e=1;e<10;e+=1)o.push({name:`Role ${e}`,description:`Role description ${e}`,permissionNames:[`Permission ${e}`],createdTime:new Date,tenantId:n});t.forEach((e=>{o.sort(((t,n)=>{var i,o;return e.desc?null===(o=n[e.field])||void 0===o?void 0:o.localeCompare(t[e.field]):null===(i=t[e.field])||void 0===i?void 0:i.localeCompare(n[e.field])}))})),i(o.filter((t=>t.name.toLowerCase().includes(e.toLowerCase())||t.description.toLowerCase().includes(e.toLowerCase()))))}))})))({page:i,limit:o,text:r,sort:s},t);const a=yield e.post(Kv,{limit:o,page:i,text:r,sort:s},{queryParams:{tenant:t}});return yield Zv(a),(yield a.json()).roles})),deleteBatch:i=>c(void 0,void 0,void 0,(function*(){if(n)return c(void 0,void 0,void 0,(function*(){}));const o=yield e.post(Hv,{roleNames:i},{queryParams:{tenant:t}});return yield Zv(o),o.json()})),create:i=>c(void 0,[i],void 0,(function*({name:i,description:o,permissionNames:r}){if(n)return((e,t)=>c(void 0,[e,t],void 0,(function*({name:e,description:t,permissionNames:n},i){return new Promise((o=>{o({name:e,description:t,permissionNames:n,createdTime:new Date,tenantId:i})}))})))({name:i,description:o,permissionNames:r},t);const s=yield e.post(zv,{name:i,description:o,permissionNames:r,tenantId:t},{queryParams:{tenant:t}});return yield Zv(s),yield s.json()})),update:i=>c(void 0,[i],void 0,(function*({name:i,newName:o,description:r,permissionNames:s}){if(n)return((e,t)=>c(void 0,[e,t],void 0,(function*({name:e,newName:t,description:n,permissionNames:i},o){return new Promise((r=>{r({name:t,description:n,permissionNames:i,createdTime:new Date,oldName:e,tenantId:o})}))})))({name:i,newName:o,description:r,permissionNames:s},t);const a=yield e.post(Jv,{name:i,newName:o,description:r,permissionNames:s,tenantId:t},{queryParams:{tenant:t}});yield Zv(a);const d=yield a.json();return d.oldName=i,d}))}),Xv=({httpClient:e,tenant:t,mock:n})=>({getTenantPermissions:()=>c(void 0,void 0,void 0,(function*(){if(n)return new Promise((e=>{const t=[];for(let e=1;e<5;e+=1)t.push({name:`Permission ${e}`});e({permissions:t})}));const i=yield e.get(Gv,{queryParams:{tenant:t}});return yield Zv(i),i.json()}))}),Qv=Wi((e=>{var t,n,i,o;const r=xi(js,As,Cs,Ms,Sc,Ns({tenant:Ns.missingAttrValidator}))(e);return o=class extends r{constructor(){super(...arguments),t.add(this),n.set(this,void 0)}get tenantId(){return this.getAttribute("tenant")}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get api(){return u(this,n,"f")||u(this,t,"m",i).call(this),u(this,n,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.init)||void 0===o?void 0:o.call(this),this.observeAttributes(["project-id","base-url","tenant"],(()=>{u(this,n,"f")&&u(this,t,"m",i).call(this)}))}))}},n=new WeakMap,t=new WeakSet,i=function(){this.logger.debug("creating an sdk instance"),h(this,n,((e,t,n,i)=>{const o=bi(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"role-management-widget","x-descope-widget-id":i,"x-descope-widget-version":"0.10.20"}}));return{role:Yv({httpClient:o.httpClient,tenant:t,mock:n}),tenant:Xv({httpClient:o.httpClient,tenant:t,mock:n}),httpClient:o.httpClient}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},this.tenantId,"true"===this.mock,this.widgetId),"f")},o})),eg=Wi((e=>{const t=xi(yc({name:"widget",initialState:Vv,reducers:{setSelectedRolesIds:(e,{payload:t})=>{e.selectedRolesIds=t},clearNotifications:e=>{e.notifications=[]}},extraReducers:e=>{Ov.reducer(e),Tv.reducer(e),_v.reducer(e),jv.reducer(e),Uv.reducer(e),Bv.reducer(e)},asyncActions:{searchRoles:Uv.action,createRole:Ov.action,duplicateRole:Tv.action,updateRole:_v.action,deleteRoles:jv.action,getTenantPermissions:Bv.action}}),Os,Cs,Qv)(e);return class extends t{constructor(...e){super(...e),this.state=Vv,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),tg=Wi((e=>{var t,n,i;return i=class extends(xi(Cs,Os,Hs,Xs,Cc("role-management-widget"),eg)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){return c(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.init)||void 0===i?void 0:i.call(this),yield Promise.all([u(this,t,"m",n).call(this),this.actions.searchRoles(),this.actions.getTenantPermissions()]),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,n=function(){return c(this,void 0,void 0,(function*(){const e=Oi(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},i})),ng=Wi((e=>{var t,n,i,o,r,s,a;return a=class extends(xi(eg,ud,bc,Cs,tg)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),i.set(this,"create"),o.set(this,null),s.set(this,(()=>c(this,void 0,void 0,(function*(){var e;yield u(this,n,"f").setData(null===(e=mv(this.state))||void 0===e?void 0:e.map((({name:e})=>({value:e,label:e}))))}))))}openRoleModal(e="create",t){h(this,i,e,"f"),h(this,o,null!=t?t:null,"f"),this.roleFormModal.open()}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),u(this,t,"m",r).call(this)}))}},n=new WeakMap,i=new WeakMap,o=new WeakMap,s=new WeakMap,t=new WeakSet,r=function(){return c(this,void 0,void 0,(function*(){this.roleFormModal=this.createModal(),this.roleFormModal.setContent(Oi(yield this.fetchWidgetPage("create-role-modal.html"))),new ka((()=>{var e;return null===(e=this.roleFormModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger}).onClick((()=>{this.roleFormModal.close(),this.resetFormData(this.roleFormModal.ele)})),new ka((()=>{var e;return null===(e=this.roleFormModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger}).onClick((()=>c(this,void 0,void 0,(function*(){if(this.validateForm(this.roleFormModal.ele)){const e=this.getFormData(this.roleFormModal.ele);"duplicate"===u(this,i,"f")?this.actions.duplicateRole(Object.assign({},e)):this.actions.createRole(Object.assign({},e)),this.roleFormModal.close(),this.resetFormData(this.roleFormModal.ele)}})))),h(this,n,new Qa((()=>{var e;return null===(e=this.roleFormModal.ele)||void 0===e?void 0:e.querySelector('[data-id="permissions-multiselect"]')}),{logger:this.logger}),"f"),u(this,s,"f").call(this),this.roleFormModal.beforeOpen=()=>c(this,void 0,void 0,(function*(){yield u(this,s,"f").call(this),u(this,o,"f")&&(this.setFormData(this.roleFormModal.ele,u(this,o,"f")),h(this,o,null,"f"))}))}))},a})),ig=Wi((e=>{var t,n,i;return i=class extends(xi(Cs,ng,tg)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",n).call(this)}))}},t=new WeakSet,n=function(){var e;this.createButton=new ka(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="create-role"]'),{logger:this.logger}),this.createButton.onClick((()=>this.openRoleModal()))},i})),og=Wi((e=>{var t,n,i;return i=class extends(xi(eg,ud,Cs,tg)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),yield u(this,t,"m",n).call(this)}))}},t=new WeakSet,n=function(){return c(this,void 0,void 0,(function*(){var e;this.deleteRolesModal=this.createModal(),this.deleteRolesModal.setContent(Oi(yield this.fetchWidgetPage("delete-roles-modal.html")));const t=new ka((()=>{var e;return null===(e=this.deleteRolesModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger});t.onClick((()=>this.deleteRolesModal.close()));const n=new ka((()=>{var e;return null===(e=this.deleteRolesModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});n.onClick((()=>{const e=bv(this.state);this.actions.deleteRoles(null==e?void 0:e.map((e=>e.name))),this.deleteRolesModal.close()}));const i=new id(null===(e=this.deleteRolesModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.deleteRolesModal.beforeOpen=()=>{const e=Cv(this.state);i.text=`Delete ${e}?`}}))},i})),rg=Wi((e=>{var t,n,i,o;return o=class extends(xi(Cs,tg,eg,og)(e)){constructor(){super(...arguments),t.add(this),i.set(this,Ni((e=>{e?this.deleteButton.enable():this.deleteButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),u(this,t,"m",n).call(this),this.subscribe(u(this,i,"f").bind(this),wv)}))}},i=new WeakMap,t=new WeakSet,n=function(){var e;this.deleteButton=new ka(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="delete-roles"]'),{logger:this.logger}),this.deleteButton.disable(),this.deleteButton.onClick((()=>{this.deleteRolesModal.open()}))},o})),sg=Wi((e=>{var t,n,i,o;return o=class extends(xi(Cs,tg,eg,ng)(e)){constructor(){super(...arguments),t.add(this),i.set(this,Ni((e=>{e?this.duplicateButton.enable():this.duplicateButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),u(this,t,"m",n).call(this),this.subscribe(u(this,i,"f").bind(this),$v)}))}},i=new WeakMap,t=new WeakSet,n=function(){var e;this.duplicateButton=new ka(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="duplicate-role"]'),{logger:this.logger}),this.duplicateButton.disable(),this.duplicateButton.onClick((()=>{var e,t,n;const i=null===(e=bv(this.state))||void 0===e?void 0:e[0];i&&this.openRoleModal("duplicate",{name:`${i.name} Copy`,description:null!==(t=i.description)&&void 0!==t?t:"",permissionNames:null!==(n=i.permissionNames)&&void 0!==n?n:[]})}))},o})),ag=Wi((e=>{var t,n,i,o,r,s,a,d;return d=class extends(xi(eg,ud,Cs,bc,tg)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),r.set(this,(()=>c(this,void 0,void 0,(function*(){var e;yield u(this,n,"f").setData(null===(e=mv(this.state))||void 0===e?void 0:e.map((({name:e})=>({value:e,label:e}))))})))),s.set(this,(()=>{var e;const t=null===(e=bv(this.state))||void 0===e?void 0:e[0],n={name:null==t?void 0:t.name,description:null==t?void 0:t.description,permissionNames:null==t?void 0:t.permissionNames};this.setFormData(this.editRoleModal.ele,n)}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),yield u(this,t,"m",a).call(this)}))}},n=new WeakMap,r=new WeakMap,s=new WeakMap,t=new WeakSet,i=function(){new ka((()=>{var e;return null===(e=this.editRoleModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger}).onClick((()=>this.editRoleModal.close()))},o=function(){new ka((()=>{var e;return null===(e=this.editRoleModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger}).onClick((()=>{var e;if(this.validateForm(this.editRoleModal.ele)){const t=this.getFormData(this.editRoleModal.ele),{name:n}=t,i=l(t,["name"]),o=null===(e=bv(this.state))||void 0===e?void 0:e[0];this.actions.updateRole(Object.assign({newName:n,name:o.name},i)),this.editRoleModal.close(),this.resetFormData(this.editRoleModal.ele)}}))},a=function(){return c(this,void 0,void 0,(function*(){this.editRoleModal=this.createModal(),this.editRoleModal.setContent(Oi(yield this.fetchWidgetPage("edit-role-modal.html"))),u(this,t,"m",i).call(this),u(this,t,"m",o).call(this),h(this,n,new Qa((()=>{var e;return null===(e=this.editRoleModal.ele)||void 0===e?void 0:e.querySelector('[data-id="permissions-multiselect"]')}),{logger:this.logger}),"f"),this.editRoleModal.beforeOpen=()=>c(this,void 0,void 0,(function*(){yield u(this,r,"f").call(this),u(this,s,"f").call(this)}))}))},d})),dg=Wi((e=>{var t,n,i,o;return o=class extends(xi(Cs,tg,eg,ag,bc)(e)){constructor(){super(...arguments),t.add(this),i.set(this,Ni((e=>{e?this.editButton.enable():this.editButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),u(this,t,"m",n).call(this),this.subscribe(u(this,i,"f").bind(this),kv)}))}},i=new WeakMap,t=new WeakSet,n=function(){var e;this.editButton=new ka(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="edit-role"]'),{logger:this.logger}),this.editButton.disable(),this.editButton.onClick((()=>{this.editRoleModal.open()}))},o})),lg=Wi((e=>{var t,n,i,o;return o=class extends(xi(Cs,tg,eg)(e)){constructor(){super(...arguments),t.add(this),n.set(this,Pi((()=>{this.actions.searchRoles({text:this.searchInput.value})})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),u(this,t,"m",i).call(this)}))}},n=new WeakMap,t=new WeakSet,i=function(){var e;this.searchInput=new od(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="search-input"]'),{logger:this.logger}),this.searchInput.onInput(u(this,n,"f"))},o})),cg={success:(new DOMParser).parseFromString('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Checkmark">\n<path id="Shape" d="M10.0485 15.6396C9.5799 15.171 8.8201 15.171 8.35147 15.6396C7.88284 16.1082 7.88284 16.868 8.35147 17.3367L12.7072 21.6924C13.1759 22.1611 13.9357 22.1611 14.4043 21.6924L24.7152 11.3815C25.1838 10.9129 25.1838 10.1531 24.7152 9.68448C24.2466 9.21585 23.4868 9.21585 23.0181 9.68448L13.5558 19.1469L10.0485 15.6396Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,error:(new DOMParser).parseFromString('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Icon">\n<path id="Vector" d="M15.9998 26.6558C10.1118 26.6558 5.34375 21.8878 5.34375 15.9998C5.34375 10.1118 10.1118 5.34375 15.9998 5.34375C21.8878 5.34375 26.6558 10.1118 26.6558 15.9998C26.6558 21.8878 21.8878 26.6558 15.9998 26.6558ZM15.9998 24.4798C20.6718 24.4798 24.4798 20.7038 24.4798 15.9998C24.4798 11.3278 20.7038 7.51975 15.9998 7.51975C11.3278 7.51975 7.51975 11.2958 7.51975 15.9998C7.51975 20.6718 11.2958 24.4798 15.9998 24.4798ZM15.3278 9.34375H16.6718C17.0558 9.34375 17.3438 9.63175 17.3118 9.98375L16.9598 16.9278C16.9598 17.1838 16.7678 17.3438 16.5438 17.3438H15.4558C15.2318 17.3438 15.0398 17.1518 15.0398 16.9278L14.6878 9.98375C14.6878 9.63175 14.9758 9.34375 15.3278 9.34375ZM15.4558 19.4558H16.5438C16.9278 19.4558 17.2158 19.7438 17.1838 20.1278V21.1838C17.1838 21.5678 16.8958 21.8558 16.5438 21.8558H15.4558C15.0718 21.8558 14.7838 21.5678 14.7838 21.1838V20.1278C14.7838 19.7438 15.0718 19.4558 15.4558 19.4558Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild},ug=Wi((e=>{var t,n,i,o,r;return r=class extends(xi(Cs,eg,pd,Os)(e)){constructor(){super(...arguments),t.add(this),o.set(this,Ni((e=>{e.length&&(e.forEach((({type:e,msg:o})=>{const r=u(this,t,"m",i).call(this,e);r.setContent(u(this,t,"m",n).call(this,{type:e,msg:o})),r.show()})),setTimeout((()=>this.actions.clearNotifications())))})))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this),this.subscribe(u(this,o,"f").bind(this),gv)}))}},o=new WeakMap,t=new WeakSet,n=function({type:e,msg:t}){const n=cg[e],i=Object.assign((new DOMParser).parseFromString('<svg width="2em" height="2em" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Icon">\n<path id="Shape" d="M10.6712 12L7.27521 8.60406C6.90826 8.23711 6.90826 7.64216 7.27521 7.27521C7.64216 6.90826 8.23711 6.90826 8.60406 7.27521L12 10.6712L15.3959 7.27521C15.7629 6.90826 16.3578 6.90826 16.7248 7.27521C17.0917 7.64216 17.0917 8.23711 16.7248 8.60406L13.3288 12L16.7248 15.3959C17.0917 15.7629 17.0917 16.3578 16.7248 16.7248C16.3578 17.0917 15.7629 17.0917 15.3959 16.7248L12 13.3288L8.60406 16.7248C8.23711 17.0917 7.64216 17.0917 7.27521 16.7248C6.90826 16.3578 6.90826 15.7629 7.27521 15.3959L10.6712 12Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,{slot:"close"});return`${(null==n?void 0:n.outerHTML)||""}${t}${i.outerHTML}`},i=function(e){return this.createNotification({mode:e,duration:"error"===e?0:3e3,position:"bottom-start",size:"sm"})},r})),hg=Wi((e=>{var t,n,i,o,r;return r=class extends(xi(eg,Cs,tg)(e)){constructor(){super(...arguments),t.add(this),i.set(this,Ni((e=>{this.rolesTable.data=e}))),o.set(this,Pi(((e,t)=>{const n=[],{value:i}=t;if(i){const t=e.path;n.push({field:t,desc:"desc"===i})}this.actions.searchRoles({sort:n})})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var r;yield null===(r=e.onWidgetRootReady)||void 0===r?void 0:r.call(this),u(this,t,"m",n).call(this),this.rolesTable.columns.forEach((e=>{e.onSortDirectionChange((e=>{u(this,o,"f").call(this,e.target,e.detail)}))})),u(this,i,"f").call(this,yv(this.state)),this.subscribe(u(this,i,"f").bind(this),yv)}))}},i=new WeakMap,o=new WeakMap,t=new WeakSet,n=function(){var e;this.rolesTable=new Ea(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="roles-table"]'),{logger:this.logger}),this.rolesTable.onSelectedItemsChange((e=>{this.actions.setSelectedRolesIds(e.detail.value.map((({name:e})=>e)))}))},r})),fg=Wi((e=>class extends(xi(fa,sa,hg,ig,rg,sg,dg,lg,ug,Oc)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),pg=xi((e=>class extends(fg(e)){}))(HTMLElement);customElements.define("descope-role-management-widget",pg);var vg=Object.freeze({__proto__:null,default:pg});const gg=e=>e.tenant.data,mg=e=>e.tenantAdminLinkSSO.data.defaultLink,yg={},bg=Al(gg,(e=>e.customAttributes||{})),wg=Al(gg,(e=>e.name||"")),$g=Al(gg,(e=>e.selfProvisioningDomains||[])),kg=Al(gg,(e=>e.enforceSSOExclusions||[])),Cg=Al(gg,(e=>e.enforceSSO||!1)),Sg=Al(gg,mg,(e=>e.tenantAdminLinkSSO.data.ssoIdToLink),(e=>e.tenantAdminLinkSSO.data.ssoIdToAuthenticationOnly||yg),((e,t,n,i)=>[...e?[{id:"",name:"Default SSO Configuration",authType:e.authType,isDefault:!0,link:t,authOnly:i.default_ssoid||!1}]:[],...((null==e?void 0:e.additionalSSOConfigs)||[]).map((({ssoId:e,name:t,authType:o})=>({id:e,name:t,authType:o,link:n[e]||"",authOnly:i[e]||!1})))])),Ig=Al(gg,(e=>((null==e?void 0:e.additionalSSOConfigs)||[]).map((({ssoId:e})=>e))));function Rg(e){return new URLSearchParams(window.location.search).get(e)}const Eg=e=>(...t)=>n=>{n.addCase(e.pending,((e,n)=>{t.forEach((({onPending:t})=>{null==t||t(e,n)}))})),n.addCase(e.fulfilled,((e,n)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,n)}))})),n.addCase(e.rejected,((e,n)=>{t.forEach((({onRejected:t})=>{null==t||t(e,n)}))}))},xg=e=>({onFulfilled:t=>{e(t).loading=!1},onPending:t=>{e(t).loading=!0,e(t).error=null},onRejected:(t,n)=>{e(t).loading=!1,e(t).error=n.error}}),Og=lc("users/me",((e,{extra:{api:t}})=>t.user.me())),Ag=Eg(Og)({onFulfilled:(e,t)=>{e.me.data=t.payload}},xg((e=>e.me))),Ng={action:Og,reducer:Ag},jg=lc("tenant/details",((e,{extra:{api:t}})=>t.tenant.details())),Mg=Eg(jg)({onFulfilled:(e,t)=>{e.tenant.data=t.payload}},xg((e=>e.tenant))),Pg={action:jg,reducer:Mg},Tg=lc("tenant/adminLinkSso",(({ssoIds:e},{extra:{api:t}})=>t.tenant.adminLinkSso({ssoIds:e}))),Wg={action:Tg,reducer:Eg(Tg)({onFulfilled:(e,t)=>{var n;e.tenantAdminLinkSSO.data=null!==(n=t.payload)&&void 0!==n?n:{defaultLink:"",ssoIdToLink:{}}}},xg((e=>e.tenantAdminLinkSSO)))},Lg={me:{loading:!1,error:null,data:{}},tenant:{loading:!1,error:null,data:{}},tenantAdminLinkSSO:{loading:!1,error:null,data:{defaultLink:"",ssoIdToLink:{}}}},Ug="/v1/auth/me",Dg="/v1/mgmt/tenant",Fg="/v1/mgmt/tenant/adminlinks/sso/authenticated/batch",_g=e=>c(void 0,void 0,void 0,(function*(){const t=yield e.text(),n=JSON.parse(t);if(!e.ok){const t=`${n.errorDescription}${n.errorMessage?`: ${n.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(n),e.text=()=>Promise.resolve(t)})),qg=({httpClient:e,tenantId:t,mock:n})=>{const i=encodeURIComponent(t||""),o=`?tenant=${i}&id=${i}`;return{details:()=>c(void 0,void 0,void 0,(function*(){if(n)return c(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({tenantId:"tenant-1",roleNames:["admin"],id:"tenant-1",name:"Test Tenant",selfProvisioningDomains:["example1.com","example2.com"],customAttributes:{},authType:"password",domains:[],createdTime:Date.now(),disabled:!1,enforceSSO:!0})}))}));if(!t)throw new Error("tenantId is not defined");const i=`${Dg}${o}`,r=yield e.get(i);return yield _g(r),yield r.json()})),adminLinkSso:o=>c(void 0,[o],void 0,(function*({ssoIds:o}){if(n)return c(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({defaultLink:"_blank",ssoIdToLink:{"okta-prod":"_blank?ssoId=okta-prod","entra-eu":"_blank?ssoId=entra-eu"}})}))}));if(!t)throw new Error("tenantId is not defined");const r=yield e.post(`${Fg}?tenant=${i}`,{tenantId:i,ssoIds:o},{headers:{"Content-Type":"application/json"}});return yield _g(r),yield r.json()}))}},Bg=({httpClient:e,mock:t})=>({me:()=>c(void 0,void 0,void 0,(function*(){if(t)return c(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({loginIds:["user@company.com"],externalIds:["user@company.com"],userId:"user-1",name:"Test User",email:"user@company.com",roleNames:["Role"],phone:"+1-202-555-010",verifiedEmail:!0,verifiedPhone:!0,userTenants:[],status:"enabled",editable:!0,createdTime:(new Date).getTime(),customAttributes:{},familyName:"",givenName:"",middleName:"",picture:void 0,password:!0,SAML:!1,test:!1,TOTP:!1,webauthn:!0})}))}));const n=yield e.get(Ug);return yield _g(n),n.json()}))}),Vg=Wi((e=>{var t,n,i,o;const r=xi(js,As,Cs,Ms,Sc)(e);return o=class extends r{constructor(){super(...arguments),t.add(this),n.set(this,void 0)}get widgetId(){return this.getAttribute("widget-id")}get tenantId(){return this.getAttribute("tenant")}get mock(){return this.getAttribute("mock")}get styleId(){return this.getAttribute("style-id")||Qs}get api(){return u(this,n,"f")||u(this,t,"m",i).call(this),u(this,n,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.init)||void 0===o?void 0:o.call(this),this.observeAttributes(["project-id","base-url","tenant","mock"],(()=>{u(this,n,"f")&&u(this,t,"m",i).call(this)}))}))}},n=new WeakMap,t=new WeakSet,i=function(){this.logger.debug("creating an sdk instance"),h(this,n,((e,t,n,i)=>{const o=bi(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"tenant-profile-widget","x-descope-widget-id":i,"x-descope-widget-version":"0.11.21"}}));return{user:Bg({httpClient:o.httpClient,mock:n}),tenant:qg({httpClient:o.httpClient,tenantId:t,mock:n}),httpClient:o.httpClient}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},this.tenantId,"true"===this.mock,this.widgetId),"f")},o})),Kg=Wi((e=>{const t=xi(yc({name:"widget",initialState:Lg,reducers:{},extraReducers:e=>{Ng.reducer(e),Pg.reducer(e),Wg.reducer(e)},asyncActions:{getMe:Ng.action,getTenant:Pg.action,getTenantAdminLinkSSO:Wg.action}}),Os,Cs,Vg)(e);return class extends t{constructor(...e){super(...e),this.state=Lg,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),Hg="widget-flow",zg=Wi((e=>{var t,n,i;return i=class extends(xi(kc,Os,hd,Kg,Sc,Cs,sa,Ic)(e)){constructor(){super(...arguments),t.add(this)}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.init)||void 0===i?void 0:i.call(this);const o=Rg(Hg);o&&(function(e){if(window.history.replaceState&&Rg(e)){const t=new URL(window.location.href),n=new URLSearchParams(t.search);n.delete(e),t.search=n.toString(),window.history.replaceState({},"",t.toString())}}(Hg),u(this,t,"m",n).call(this,o))}))}},t=new WeakSet,n=function(e){const t=this.createFlowModal({"data-id":"redirect-flow"});t.setContent(this.createFlowTemplate({flowId:e,tenant:this.tenantId})),new Ca((()=>{var e;return null===(e=t.ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}).onSuccess((()=>c(this,void 0,void 0,(function*(){t.close(),this.actions.getMe(),yield this.actions.getTenant();const e=Ig(this.state);yield this.actions.getTenantAdminLinkSSO({ssoIds:e})})))),t.afterClose=()=>{t.remove()},t.open()},i})),Jg=Wi((e=>class extends(xi(sa,As)(e)){syncFlowTheme(e){e.theme=this.theme,this.observeAttributes(["theme"],(()=>{e.theme=this.theme}))}})),Gg=Wi((e=>{var t,n,i;return i=class extends(xi(Cs,Os,Hs,Xs,Cc("tenant-profile-widget"),Kg)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){return c(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.init)||void 0===i?void 0:i.call(this);try{yield Promise.all([this.actions.getMe(),this.actions.getTenant()]);const e=Ig(this.state);yield this.actions.getTenantAdminLinkSSO({ssoIds:e})}catch(i){}const o=this.state.me.error||(()=>this.state.tenant.error)()||(()=>this.state.tenantAdminLinkSSO.error)();if(o){this.contentRootElement.innerHTML="";const e="object"==typeof o&&null!==o&&"message"in o?o.message:String(o)||"An error occurred";this.contentRootElement.append(function({mainMessage:e="An error occurred"}){const t=document.createElement("div");t.setAttribute("data-id","widget-error"),t.style.display="flex",t.style.flexDirection="column",t.style.alignItems="center",t.style.justifyContent="center",t.style.padding="72px 36px",t.style.background="#fff",t.style.borderRadius="12px",t.style.boxShadow="0 2px 8px rgba(0,0,0,0.03)",t.style.margin="32px auto",t.style.maxWidth="400px";const n=document.createElement("div");n.innerHTML='\n <svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">\n <circle cx="20" cy="20" r="18" stroke="#FF3B3B" stroke-width="3" fill="#fff"/>\n <text x="20" y="27" text-anchor="middle" font-size="24" font-family="Arial, sans-serif" fill="#FF3B3B">!</text>\n </svg>\n ',n.style.marginBottom="12px",t.appendChild(n);const i=document.createElement("div");return i.textContent=e,i.style.fontWeight="bold",i.style.fontSize="20px",i.style.color="#222",i.style.textAlign="center",i.style.marginTop="8px",t.appendChild(i),t}({mainMessage:e}))}else yield u(this,t,"m",n).call(this),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,n=function(){return c(this,void 0,void 0,(function*(){const e=Oi(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},i})),Zg=Wi((e=>{var t,n,i,o,r,s,a,d,l,f,p,v;return v=class extends(xi(Jg,Kg,hd,Cs,Gg,Ic)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),i.set(this,void 0),o.set(this,void 0),r.set(this,void 0),s.set(this,void 0)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),h(this,n,new cd((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-multi-sso")}),{logger:this.logger}),"f"),u(this,n,"f").isExists&&(u(this,t,"m",p).call(this),u(this,n,"f").data=Sg(this.state),this.subscribe((e=>{u(this,n,"f").data=e}),Sg))}))}},n=new WeakMap,i=new WeakMap,o=new WeakMap,r=new WeakMap,s=new WeakMap,t=new WeakSet,a=function(){h(this,i,this.createFlowModal({"data-id":"multi-sso-create-modal"}),"f"),h(this,o,new Ca((()=>{var e;return null===(e=u(this,i,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(u(this,o,"f"))},d=function(){h(this,r,this.createFlowModal({"data-id":"multi-sso-delete-modal"}),"f"),h(this,s,new Ca((()=>{var e;return null===(e=u(this,r,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(u(this,s,"f"))},l=function(e){u(this,i,"f").setContent(this.createFlowTemplate({flowId:e,tenant:this.tenantId})),u(this,i,"f").open(),u(this,o,"f").onSuccess((()=>c(this,void 0,void 0,(function*(){u(this,i,"f").close(),yield this.actions.getTenant();const e=Ig(this.state);yield this.actions.getTenantAdminLinkSSO({ssoIds:e})}))))},f=function(e,t){u(this,r,"f").setContent(this.createFlowTemplate({flowId:e,tenant:this.tenantId,form:{deleteSSOConfigurationId:t}})),u(this,r,"f").open(),u(this,s,"f").onSuccess((()=>{u(this,r,"f").close(),this.actions.getTenant()}))},p=function(){const{createFlowId:e,deleteFlowId:i}=u(this,n,"f");i&&(u(this,t,"m",d).call(this),u(this,n,"f").onDeleteClicked((({id:e})=>u(this,t,"m",f).call(this,i,e)))),e&&(u(this,t,"m",a).call(this),u(this,n,"f").onCreateClicked((()=>u(this,t,"m",l).call(this,e))))},v})),Yg=Wi((e=>{var t,n,i,o;return o=class extends(xi(Jg,Kg,Cs,Gg,Sc,ud)(e)){constructor(){super(...arguments),t.add(this),i.set(this,Ni((e=>{this.tenantAdminLinkSSODriver.href=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),u(this,t,"m",n).call(this),u(this,i,"f").call(this,mg(this.state)),this.subscribe(u(this,i,"f").bind(this),mg)}))}},i=new WeakMap,t=new WeakSet,n=function(){this.tenantAdminLinkSSODriver=new xa((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-link[data-id="tenant-admin-link-sso"]')}),{logger:this.logger})},o}));var Xg;!function(e){e.TEXT="text",e.NUMBER="number",e.BOOLEAN="boolean",e.SINGLE_SELECT="singleSelect",e.ARRAY="array",e.DATE="date"}(Xg||(Xg={}));const Qg=Wi((e=>{var t,n,i,o,r,s,a,d,l,h,f;return f=class extends(xi(kc,Jg,Kg,Cs,Gg,Sc,hd,Ic)(e)){constructor(){super(...arguments),t.add(this),n.set(this,{}),i.set(this,{}),o.set(this,{}),r.set(this,{}),d.set(this,Ni((e=>{var n;const i=null===(n=this.shadowRoot)||void 0===n?void 0:n.querySelectorAll('descope-user-attribute[data-id^="customAttributes."]');Array.from(i).forEach((n=>{const i=n.getAttribute("data-id").replace("customAttributes.",""),o=n.getAttribute("data-type")||Xg.TEXT,r=e[i],s=new rd(n,{logger:this.logger});s.value=((e,t)=>e===Xg.DATE&&t?new Date(t).toLocaleString():e===Xg.BOOLEAN&&void 0!==t?t?"True":"False":(t||"").toString())(o,r),u(this,t,"m",l).call(this,n,i,s,o,i),u(this,t,"m",h).call(this,n,i,s)}))})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.onWidgetRootReady)||void 0===t?void 0:t.call(this),u(this,d,"f").call(this,bg(this.state)),this.subscribe(u(this,d,"f").bind(this),bg)}))}},n=new WeakMap,i=new WeakMap,o=new WeakMap,r=new WeakMap,d=new WeakMap,t=new WeakSet,s=function(e,t,o){var r,s;const a=bg(this.state)[o],d=t===Xg.ARRAY?(a||[]).join(","):a;null===(r=u(this,n,"f")[e])||void 0===r||r.setContent(this.createFlowTemplate({flowId:e,tenant:this.tenantId,form:{customAttributes:{[o]:d}}})),null===(s=u(this,i,"f")[e])||void 0===s||s.onSuccess((()=>{var t;null===(t=u(this,n,"f")[e])||void 0===t||t.close(),this.actions.getTenant()}))},a=function(e){var t,n;null===(t=u(this,o,"f")[e])||void 0===t||t.setContent(this.createFlowTemplate({flowId:e,tenant:this.tenantId})),null===(n=u(this,r,"f")[e])||void 0===n||n.onSuccess((()=>{var t;null===(t=u(this,o,"f")[e])||void 0===t||t.close(),this.actions.getTenant()}))},l=function(e,o,r,a,d){const l=e.getAttribute("edit-flow-id");l&&(u(this,n,"f")[l]||(u(this,n,"f")[l]=this.createFlowModal({"data-id":`edit-${o}`}),u(this,i,"f")[l]=new Ca((()=>{var e,t;return null===(t=null===(e=u(this,n,"f")[l])||void 0===e?void 0:e.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),u(this,n,"f")[l].beforeOpen=u(this,t,"m",s).bind(this,l,a,d),r.onEditClick((()=>{var e,t;null===(t=null===(e=u(this,n,"f"))||void 0===e?void 0:e[l])||void 0===t||t.open()})),this.syncFlowTheme(u(this,i,"f")[l])))},h=function(e,n,i){const s=e.getAttribute("delete-flow-id");s&&(u(this,o,"f")[s]||(u(this,o,"f")[s]=this.createFlowModal({"data-id":`delete-${n}`}),u(this,r,"f")[s]=new Ca((()=>{var e,t;return null===(t=null===(e=u(this,o,"f")[s])||void 0===e?void 0:e.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),u(this,o,"f")[s].beforeOpen=u(this,t,"m",a).bind(this,s),i.onDeleteClick((()=>{var e,t;null===(t=null===(e=u(this,o,"f"))||void 0===e?void 0:e[s])||void 0===t||t.open()})),this.syncFlowTheme(u(this,r,"f")[s])))},f})),em=Wi((e=>{var t,n,i,o,r,s,a,d,l,f,p,v;return v=class extends(xi(kc,Jg,Kg,Cs,Gg,Sc,hd,Ic)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),i.set(this,void 0),o.set(this,void 0),r.set(this,void 0),p.set(this,Ni((e=>{this.tenantEmailDomainsDriver.value=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),u(this,t,"m",f).call(this),u(this,t,"m",s).call(this),u(this,t,"m",d).call(this),u(this,p,"f").call(this,$g(this.state)),this.subscribe(u(this,p,"f").bind(this),$g)}))}},n=new WeakMap,i=new WeakMap,o=new WeakMap,r=new WeakMap,p=new WeakMap,t=new WeakSet,s=function(){this.tenantEmailDomainsDriver.editFlowId&&(h(this,n,this.createFlowModal({"data-id":"edit-tenant-email-domains"}),"f"),h(this,i,new Ca((()=>{var e;return null===(e=u(this,n,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,n,"f").beforeOpen=u(this,t,"m",a).bind(this),u(this,t,"m",a).call(this),this.syncFlowTheme(u(this,i,"f")))},a=function(){u(this,n,"f").setContent(this.createFlowTemplate({flowId:this.tenantEmailDomainsDriver.editFlowId,tenant:this.tenantId,form:{tenantEmailDomains:$g(this.state)}})),u(this,i,"f").onSuccess((()=>{u(this,n,"f").close(),this.actions.getTenant()}))},d=function(){this.tenantEmailDomainsDriver.deleteFlowId&&(h(this,o,this.createFlowModal({"data-id":"delete-tenant-email-domains"}),"f"),h(this,r,new Ca((()=>{var e;return null===(e=u(this,o,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,o,"f").beforeOpen=u(this,t,"m",l).bind(this),u(this,t,"m",l).call(this),this.syncFlowTheme(u(this,r,"f")))},l=function(){u(this,o,"f").setContent(this.createFlowTemplate({flowId:this.tenantEmailDomainsDriver.deleteFlowId,tenant:this.tenantId})),u(this,r,"f").onSuccess((()=>{u(this,o,"f").close(),this.actions.getTenant()}))},f=function(){this.tenantEmailDomainsDriver=new rd((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="tenant-email-domains-edit"]')}),{logger:this.logger}),this.tenantEmailDomainsDriver.onEditClick((()=>{var e;null===(e=u(this,n,"f"))||void 0===e||e.open()})),this.tenantEmailDomainsDriver.onDeleteClick((()=>{var e;null===(e=u(this,o,"f"))||void 0===e||e.open()}))},v})),tm=Wi((e=>{var t,n,i,o,r,s,a,d,l,f,p,v;return v=class extends(xi(kc,Jg,Kg,Cs,Gg,Sc,hd,Ic)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),i.set(this,void 0),o.set(this,void 0),r.set(this,void 0),p.set(this,Ni((e=>{this.tenantSSOExclusionsDriver.value=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),u(this,t,"m",f).call(this),u(this,t,"m",s).call(this),u(this,t,"m",d).call(this),u(this,p,"f").call(this,kg(this.state)),this.subscribe(u(this,p,"f").bind(this),kg)}))}},n=new WeakMap,i=new WeakMap,o=new WeakMap,r=new WeakMap,p=new WeakMap,t=new WeakSet,s=function(){this.tenantSSOExclusionsDriver.editFlowId&&(h(this,n,this.createFlowModal({"data-id":"edit-tenant-sso-exclusions"}),"f"),h(this,i,new Ca((()=>{var e;return null===(e=u(this,n,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,n,"f").beforeOpen=u(this,t,"m",a).bind(this),u(this,t,"m",a).call(this),this.syncFlowTheme(u(this,i,"f")))},a=function(){u(this,n,"f").setContent(this.createFlowTemplate({flowId:this.tenantSSOExclusionsDriver.editFlowId,tenant:this.tenantId,form:{enforceSSOExclusions:kg(this.state)}})),u(this,i,"f").onSuccess((()=>{u(this,n,"f").close(),this.actions.getTenant()}))},d=function(){this.tenantSSOExclusionsDriver.deleteFlowId&&(h(this,o,this.createFlowModal({"data-id":"delete-tenant-sso-exclusions"}),"f"),h(this,r,new Ca((()=>{var e;return null===(e=u(this,o,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,o,"f").beforeOpen=u(this,t,"m",l).bind(this),u(this,t,"m",l).call(this),this.syncFlowTheme(u(this,r,"f")))},l=function(){u(this,o,"f").setContent(this.createFlowTemplate({flowId:this.tenantSSOExclusionsDriver.deleteFlowId,tenant:this.tenantId})),u(this,r,"f").onSuccess((()=>{u(this,o,"f").close(),this.actions.getTenant()}))},f=function(){this.tenantSSOExclusionsDriver=new rd((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="tenant-force-sso-exclusions-edit"]')}),{logger:this.logger}),this.tenantSSOExclusionsDriver.onEditClick((()=>{var e;null===(e=u(this,n,"f"))||void 0===e||e.open()})),this.tenantSSOExclusionsDriver.onDeleteClick((()=>{var e;null===(e=u(this,o,"f"))||void 0===e||e.open()}))},v})),nm=Wi((e=>{var t,n,i,o,r,s,a,d,l,f,p,v;return v=class extends(xi(kc,Jg,Kg,Cs,Gg,Sc,hd,Ic)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),i.set(this,void 0),o.set(this,void 0),r.set(this,void 0),p.set(this,Ni((e=>{this.tenantEnforceSSODriver.value=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),u(this,t,"m",f).call(this),u(this,t,"m",s).call(this),u(this,t,"m",d).call(this),u(this,p,"f").call(this,Cg(this.state)),this.subscribe(u(this,p,"f").bind(this),Cg)}))}},n=new WeakMap,i=new WeakMap,o=new WeakMap,r=new WeakMap,p=new WeakMap,t=new WeakSet,s=function(){this.tenantEnforceSSODriver.editFlowId&&(h(this,n,this.createFlowModal({"data-id":"edit-tenant-enforce-sso"}),"f"),h(this,i,new Ca((()=>{var e;return null===(e=u(this,n,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,n,"f").beforeOpen=u(this,t,"m",a).bind(this),u(this,t,"m",a).call(this),this.syncFlowTheme(u(this,i,"f")))},a=function(){u(this,n,"f").setContent(this.createFlowTemplate({flowId:this.tenantEnforceSSODriver.editFlowId,tenant:this.tenantId,form:{enforceSSO:Cg(this.state)}})),u(this,i,"f").onSuccess((()=>{u(this,n,"f").close(),this.actions.getTenant()}))},d=function(){this.tenantEnforceSSODriver.deleteFlowId&&(h(this,o,this.createFlowModal({"data-id":"delete-tenant-enforce-sso"}),"f"),h(this,r,new Ca((()=>{var e;return null===(e=u(this,o,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,o,"f").beforeOpen=u(this,t,"m",l).bind(this),u(this,t,"m",l).call(this),this.syncFlowTheme(u(this,r,"f")))},l=function(){u(this,o,"f").setContent(this.createFlowTemplate({flowId:this.tenantEnforceSSODriver.deleteFlowId,tenant:this.tenantId})),u(this,r,"f").onSuccess((()=>{u(this,o,"f").close(),this.actions.getTenant()}))},f=function(){this.tenantEnforceSSODriver=new rd((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="tenant-enforce-sso-edit"]')}),{logger:this.logger}),this.tenantEnforceSSODriver.onEditClick((()=>{var e;null===(e=u(this,n,"f"))||void 0===e||e.open()})),this.tenantEnforceSSODriver.onDeleteClick((()=>{var e;null===(e=u(this,o,"f"))||void 0===e||e.open()}))},v})),im=Wi((e=>{var t,n,i,o,r,s,a,d;return d=class extends(xi(kc,Jg,Kg,Cs,Gg,Sc,hd,Ic)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),i.set(this,void 0),a.set(this,Ni((e=>{this.tenantNameDriver.value=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),u(this,t,"m",s).call(this),u(this,t,"m",o).call(this),u(this,a,"f").call(this,wg(this.state)),this.subscribe(u(this,a,"f").bind(this),wg)}))}},n=new WeakMap,i=new WeakMap,a=new WeakMap,t=new WeakSet,o=function(){this.tenantNameDriver.editFlowId&&(h(this,n,this.createFlowModal({"data-id":"tenant-profile-set-name"}),"f"),h(this,i,new Ca((()=>{var e;return null===(e=u(this,n,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,n,"f").beforeOpen=u(this,t,"m",r).bind(this),u(this,t,"m",r).call(this),this.syncFlowTheme(u(this,i,"f")))},r=function(){u(this,n,"f").setContent(this.createFlowTemplate({flowId:this.tenantNameDriver.editFlowId,tenant:this.tenantId,form:{tenantName:wg(this.state)}})),u(this,i,"f").onSuccess((()=>{u(this,n,"f").close(),this.actions.getTenant()}))},s=function(){this.tenantNameDriver=new rd((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="tenant-name-edit"]')}),{logger:this.logger}),this.tenantNameDriver.onEditClick((()=>{var e;null===(e=u(this,n,"f"))||void 0===e||e.open()}))},d})),om=Wi((e=>{var t,n,i,o,r,s,a;return a=class extends(xi(kc,Jg,Kg,Cs,Gg,Sc,hd,Ic)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),i.set(this,void 0)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),u(this,t,"m",s).call(this),u(this,t,"m",o).call(this)}))}},n=new WeakMap,i=new WeakMap,t=new WeakSet,o=function(){this.TenantPasswordPolicyUserAuthMethodDriver.flowId&&(h(this,n,this.createFlowModal({"data-id":"password-policy"}),"f"),h(this,i,new Ca((()=>{var e;return null===(e=u(this,n,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,n,"f").afterClose=u(this,t,"m",r).bind(this),u(this,t,"m",r).call(this),this.syncFlowTheme(u(this,i,"f")))},r=function(){u(this,n,"f").setContent(this.createFlowTemplate({flowId:this.TenantPasswordPolicyUserAuthMethodDriver.flowId,tenant:this.tenantId})),u(this,i,"f").onSuccess((()=>{u(this,n,"f").close(),this.actions.getTenant()}))},s=function(){this.TenantPasswordPolicyUserAuthMethodDriver=new sd((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="password-policy"]')}),{logger:this.logger}),this.TenantPasswordPolicyUserAuthMethodDriver.onUnfulfilledButtonClick((()=>{var e;null===(e=u(this,n,"f"))||void 0===e||e.open()}))},a})),rm=Wi((e=>{var t,n,i,o,r,s,a;return a=class extends(xi(kc,Jg,Kg,Cs,Gg,Sc,hd,Ic)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),i.set(this,void 0)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),u(this,t,"m",s).call(this),u(this,t,"m",o).call(this)}))}},n=new WeakMap,i=new WeakMap,t=new WeakSet,o=function(){this.TenantSessionSettingsUserAuthMethodDriver.flowId&&(h(this,n,this.createFlowModal({"data-id":"session-settings"}),"f"),h(this,i,new Ca((()=>{var e;return null===(e=u(this,n,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,n,"f").afterClose=u(this,t,"m",r).bind(this),u(this,t,"m",r).call(this),this.syncFlowTheme(u(this,i,"f")))},r=function(){u(this,n,"f").setContent(this.createFlowTemplate({flowId:this.TenantSessionSettingsUserAuthMethodDriver.flowId,tenant:this.tenantId})),u(this,i,"f").onSuccess((()=>{u(this,n,"f").close(),this.actions.getTenant()}))},s=function(){this.TenantSessionSettingsUserAuthMethodDriver=new sd((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="session-settings"]')}),{logger:this.logger}),this.TenantSessionSettingsUserAuthMethodDriver.onUnfulfilledButtonClick((()=>{var e;null===(e=u(this,n,"f"))||void 0===e||e.open()}))},a})),sm=Wi((e=>class extends(xi(fa,sa,zg,Gg,im,em,tm,nm,Qg,Yg,om,rm,Zg,Oc)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),am=xi((e=>class extends(sm(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this),(customElements.get("descope-wc")||(yield Promise.resolve().then((function(){return Ph})).then((e=>e.default)))).sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"tenant-profile-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.11.21"}}}))}}))(HTMLElement);customElements.define("descope-tenant-profile-widget",am);var dm=Object.freeze({__proto__:null,default:am}),lm={version:4,country_calling_codes:{1:["US","AG","AI","AS","BB","BM","BS","CA","DM","DO","GD","GU","JM","KN","KY","LC","MP","MS","PR","SX","TC","TT","VC","VG","VI"],7:["RU","KZ"],20:["EG"],27:["ZA"],30:["GR"],31:["NL"],32:["BE"],33:["FR"],34:["ES"],36:["HU"],39:["IT","VA"],40:["RO"],41:["CH"],43:["AT"],44:["GB","GG","IM","JE"],45:["DK"],46:["SE"],47:["NO","SJ"],48:["PL"],49:["DE"],51:["PE"],52:["MX"],53:["CU"],54:["AR"],55:["BR"],56:["CL"],57:["CO"],58:["VE"],60:["MY"],61:["AU","CC","CX"],62:["ID"],63:["PH"],64:["NZ"],65:["SG"],66:["TH"],81:["JP"],82:["KR"],84:["VN"],86:["CN"],90:["TR"],91:["IN"],92:["PK"],93:["AF"],94:["LK"],95:["MM"],98:["IR"],211:["SS"],212:["MA","EH"],213:["DZ"],216:["TN"],218:["LY"],220:["GM"],221:["SN"],222:["MR"],223:["ML"],224:["GN"],225:["CI"],226:["BF"],227:["NE"],228:["TG"],229:["BJ"],230:["MU"],231:["LR"],232:["SL"],233:["GH"],234:["NG"],235:["TD"],236:["CF"],237:["CM"],238:["CV"],239:["ST"],240:["GQ"],241:["GA"],242:["CG"],243:["CD"],244:["AO"],245:["GW"],246:["IO"],247:["AC"],248:["SC"],249:["SD"],250:["RW"],251:["ET"],252:["SO"],253:["DJ"],254:["KE"],255:["TZ"],256:["UG"],257:["BI"],258:["MZ"],260:["ZM"],261:["MG"],262:["RE","YT"],263:["ZW"],264:["NA"],265:["MW"],266:["LS"],267:["BW"],268:["SZ"],269:["KM"],290:["SH","TA"],291:["ER"],297:["AW"],298:["FO"],299:["GL"],350:["GI"],351:["PT"],352:["LU"],353:["IE"],354:["IS"],355:["AL"],356:["MT"],357:["CY"],358:["FI","AX"],359:["BG"],370:["LT"],371:["LV"],372:["EE"],373:["MD"],374:["AM"],375:["BY"],376:["AD"],377:["MC"],378:["SM"],380:["UA"],381:["RS"],382:["ME"],383:["XK"],385:["HR"],386:["SI"],387:["BA"],389:["MK"],420:["CZ"],421:["SK"],423:["LI"],500:["FK"],501:["BZ"],502:["GT"],503:["SV"],504:["HN"],505:["NI"],506:["CR"],507:["PA"],508:["PM"],509:["HT"],590:["GP","BL","MF"],591:["BO"],592:["GY"],593:["EC"],594:["GF"],595:["PY"],596:["MQ"],597:["SR"],598:["UY"],599:["CW","BQ"],670:["TL"],672:["NF"],673:["BN"],674:["NR"],675:["PG"],676:["TO"],677:["SB"],678:["VU"],679:["FJ"],680:["PW"],681:["WF"],682:["CK"],683:["NU"],685:["WS"],686:["KI"],687:["NC"],688:["TV"],689:["PF"],690:["TK"],691:["FM"],692:["MH"],850:["KP"],852:["HK"],853:["MO"],855:["KH"],856:["LA"],880:["BD"],886:["TW"],960:["MV"],961:["LB"],962:["JO"],963:["SY"],964:["IQ"],965:["KW"],966:["SA"],967:["YE"],968:["OM"],970:["PS"],971:["AE"],972:["IL"],973:["BH"],974:["QA"],975:["BT"],976:["MN"],977:["NP"],992:["TJ"],993:["TM"],994:["AZ"],995:["GE"],996:["KG"],998:["UZ"]},countries:{AC:["247","00","(?:[01589]\\d|[46])\\d{4}",[5,6]],AD:["376","00","(?:1|6\\d)\\d{7}|[135-9]\\d{5}",[6,8,9],[["(\\d{3})(\\d{3})","$1 $2",["[135-9]"]],["(\\d{4})(\\d{4})","$1 $2",["1"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["6"]]]],AE:["971","00","(?:[4-7]\\d|9[0-689])\\d{7}|800\\d{2,9}|[2-4679]\\d{7}",[5,6,7,8,9,10,11,12],[["(\\d{3})(\\d{2,9})","$1 $2",["60|8"]],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[236]|[479][2-8]"],"0$1"],["(\\d{3})(\\d)(\\d{5})","$1 $2 $3",["[479]"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["5"],"0$1"]],"0"],AF:["93","00","[2-7]\\d{8}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[2-7]"],"0$1"]],"0"],AG:["1","011","(?:268|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([457]\\d{6})$|1","268$1",0,"268"],AI:["1","011","(?:264|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2457]\\d{6})$|1","264$1",0,"264"],AL:["355","00","(?:700\\d\\d|900)\\d{3}|8\\d{5,7}|(?:[2-5]|6\\d)\\d{7}",[6,7,8,9],[["(\\d{3})(\\d{3,4})","$1 $2",["80|9"],"0$1"],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["4[2-6]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[2358][2-5]|4"],"0$1"],["(\\d{3})(\\d{5})","$1 $2",["[23578]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["6"],"0$1"]],"0"],AM:["374","00","(?:[1-489]\\d|55|60|77)\\d{6}",[8],[["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["[89]0"],"0 $1"],["(\\d{3})(\\d{5})","$1 $2",["2|3[12]"],"(0$1)"],["(\\d{2})(\\d{6})","$1 $2",["1|47"],"(0$1)"],["(\\d{2})(\\d{6})","$1 $2",["[3-9]"],"0$1"]],"0"],AO:["244","00","[29]\\d{8}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[29]"]]]],AR:["54","00","(?:11|[89]\\d\\d)\\d{8}|[2368]\\d{9}",[10,11],[["(\\d{4})(\\d{2})(\\d{4})","$1 $2-$3",["2(?:2[024-9]|3[0-59]|47|6[245]|9[02-8])|3(?:3[28]|4[03-9]|5[2-46-8]|7[1-578]|8[2-9])","2(?:[23]02|6(?:[25]|4[6-8])|9(?:[02356]|4[02568]|72|8[23]))|3(?:3[28]|4(?:[04679]|3[5-8]|5[4-68]|8[2379])|5(?:[2467]|3[237]|8[2-5])|7[1-578]|8(?:[2469]|3[2578]|5[4-8]|7[36-8]|8[5-8]))|2(?:2[24-9]|3[1-59]|47)","2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3[78]|5(?:4[46]|8)|8[2379])|5(?:[2467]|3[237]|8[23])|7[1-578]|8(?:[2469]|3[278]|5[56][46]|86[3-6]))|2(?:2[24-9]|3[1-59]|47)|38(?:[58][78]|7[378])|3(?:4[35][56]|58[45]|8(?:[38]5|54|76))[4-6]","2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3(?:5(?:4[0-25689]|[56])|[78])|58|8[2379])|5(?:[2467]|3[237]|8(?:[23]|4(?:[45]|60)|5(?:4[0-39]|5|64)))|7[1-578]|8(?:[2469]|3[278]|54(?:4|5[13-7]|6[89])|86[3-6]))|2(?:2[24-9]|3[1-59]|47)|38(?:[58][78]|7[378])|3(?:454|85[56])[46]|3(?:4(?:36|5[56])|8(?:[38]5|76))[4-6]"],"0$1",1],["(\\d{2})(\\d{4})(\\d{4})","$1 $2-$3",["1"],"0$1",1],["(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["[68]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2-$3",["[23]"],"0$1",1],["(\\d)(\\d{4})(\\d{2})(\\d{4})","$2 15-$3-$4",["9(?:2[2-469]|3[3-578])","9(?:2(?:2[024-9]|3[0-59]|47|6[245]|9[02-8])|3(?:3[28]|4[03-9]|5[2-46-8]|7[1-578]|8[2-9]))","9(?:2(?:[23]02|6(?:[25]|4[6-8])|9(?:[02356]|4[02568]|72|8[23]))|3(?:3[28]|4(?:[04679]|3[5-8]|5[4-68]|8[2379])|5(?:[2467]|3[237]|8[2-5])|7[1-578]|8(?:[2469]|3[2578]|5[4-8]|7[36-8]|8[5-8])))|92(?:2[24-9]|3[1-59]|47)","9(?:2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3[78]|5(?:4[46]|8)|8[2379])|5(?:[2467]|3[237]|8[23])|7[1-578]|8(?:[2469]|3[278]|5(?:[56][46]|[78])|7[378]|8(?:6[3-6]|[78]))))|92(?:2[24-9]|3[1-59]|47)|93(?:4[35][56]|58[45]|8(?:[38]5|54|76))[4-6]","9(?:2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3(?:5(?:4[0-25689]|[56])|[78])|5(?:4[46]|8)|8[2379])|5(?:[2467]|3[237]|8(?:[23]|4(?:[45]|60)|5(?:4[0-39]|5|64)))|7[1-578]|8(?:[2469]|3[278]|5(?:4(?:4|5[13-7]|6[89])|[56][46]|[78])|7[378]|8(?:6[3-6]|[78]))))|92(?:2[24-9]|3[1-59]|47)|93(?:4(?:36|5[56])|8(?:[38]5|76))[4-6]"],"0$1",0,"$1 $2 $3-$4"],["(\\d)(\\d{2})(\\d{4})(\\d{4})","$2 15-$3-$4",["91"],"0$1",0,"$1 $2 $3-$4"],["(\\d{3})(\\d{3})(\\d{5})","$1-$2-$3",["8"],"0$1"],["(\\d)(\\d{3})(\\d{3})(\\d{4})","$2 15-$3-$4",["9"],"0$1",0,"$1 $2 $3-$4"]],"0",0,"0?(?:(11|2(?:2(?:02?|[13]|2[13-79]|4[1-6]|5[2457]|6[124-8]|7[1-4]|8[13-6]|9[1267])|3(?:02?|1[467]|2[03-6]|3[13-8]|[49][2-6]|5[2-8]|[67])|4(?:7[3-578]|9)|6(?:[0136]|2[24-6]|4[6-8]?|5[15-8])|80|9(?:0[1-3]|[19]|2\\d|3[1-6]|4[02568]?|5[2-4]|6[2-46]|72?|8[23]?))|3(?:3(?:2[79]|6|8[2578])|4(?:0[0-24-9]|[12]|3[5-8]?|4[24-7]|5[4-68]?|6[02-9]|7[126]|8[2379]?|9[1-36-8])|5(?:1|2[1245]|3[237]?|4[1-46-9]|6[2-4]|7[1-6]|8[2-5]?)|6[24]|7(?:[069]|1[1568]|2[15]|3[145]|4[13]|5[14-8]|7[2-57]|8[126])|8(?:[01]|2[15-7]|3[2578]?|4[13-6]|5[4-8]?|6[1-357-9]|7[36-8]?|8[5-8]?|9[124])))15)?","9$1"],AS:["1","011","(?:[58]\\d\\d|684|900)\\d{7}",[10],0,"1",0,"([267]\\d{6})$|1","684$1",0,"684"],AT:["43","00","1\\d{3,12}|2\\d{6,12}|43(?:(?:0\\d|5[02-9])\\d{3,9}|2\\d{4,5}|[3467]\\d{4}|8\\d{4,6}|9\\d{4,7})|5\\d{4,12}|8\\d{7,12}|9\\d{8,12}|(?:[367]\\d|4[0-24-9])\\d{4,11}",[4,5,6,7,8,9,10,11,12,13],[["(\\d)(\\d{3,12})","$1 $2",["1(?:11|[2-9])"],"0$1"],["(\\d{3})(\\d{2})","$1 $2",["517"],"0$1"],["(\\d{2})(\\d{3,5})","$1 $2",["5[079]"],"0$1"],["(\\d{3})(\\d{3,10})","$1 $2",["(?:31|4)6|51|6(?:5[0-3579]|[6-9])|7(?:20|32|8)|[89]"],"0$1"],["(\\d{4})(\\d{3,9})","$1 $2",["[2-467]|5[2-6]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["5"],"0$1"],["(\\d{2})(\\d{4})(\\d{4,7})","$1 $2 $3",["5"],"0$1"]],"0"],AU:["61","001[14-689]|14(?:1[14]|34|4[17]|[56]6|7[47]|88)0011","1(?:[0-79]\\d{7}(?:\\d(?:\\d{2})?)?|8[0-24-9]\\d{7})|[2-478]\\d{8}|1\\d{4,7}",[5,6,7,8,9,10,12],[["(\\d{2})(\\d{3,4})","$1 $2",["16"],"0$1"],["(\\d{2})(\\d{3})(\\d{2,4})","$1 $2 $3",["16"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["14|4"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["[2378]"],"(0$1)"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1(?:30|[89])"]]],"0",0,"(183[12])|0",0,0,0,[["(?:(?:(?:2(?:[0-26-9]\\d|3[0-8]|4[02-9]|5[0135-9])|7(?:[013-57-9]\\d|2[0-8]))\\d|3(?:(?:[0-3589]\\d|6[1-9]|7[0-35-9])\\d|4(?:[0-578]\\d|90)))\\d\\d|8(?:51(?:0(?:0[03-9]|[12479]\\d|3[2-9]|5[0-8]|6[1-9]|8[0-7])|1(?:[0235689]\\d|1[0-69]|4[0-589]|7[0-47-9])|2(?:0[0-79]|[18][13579]|2[14-9]|3[0-46-9]|[4-6]\\d|7[89]|9[0-4])|3\\d\\d)|(?:6[0-8]|[78]\\d)\\d{3}|9(?:[02-9]\\d{3}|1(?:(?:[0-58]\\d|6[0135-9])\\d|7(?:0[0-24-9]|[1-9]\\d)|9(?:[0-46-9]\\d|5[0-79])))))\\d{3}",[9]],["4(?:79[01]|83[0-389]|94[0-4])\\d{5}|4(?:[0-36]\\d|4[047-9]|5[0-25-9]|7[02-8]|8[0-24-9]|9[0-37-9])\\d{6}",[9]],["180(?:0\\d{3}|2)\\d{3}",[7,10]],["190[0-26]\\d{6}",[10]],0,0,0,["163\\d{2,6}",[5,6,7,8,9]],["14(?:5(?:1[0458]|[23][458])|71\\d)\\d{4}",[9]],["13(?:00\\d{6}(?:\\d{2})?|45[0-4]\\d{3})|13\\d{4}",[6,8,10,12]]],"0011"],AW:["297","00","(?:[25-79]\\d\\d|800)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[25-9]"]]]],AX:["358","00|99(?:[01469]|5(?:[14]1|3[23]|5[59]|77|88|9[09]))","2\\d{4,9}|35\\d{4,5}|(?:60\\d\\d|800)\\d{4,6}|7\\d{5,11}|(?:[14]\\d|3[0-46-9]|50)\\d{4,8}",[5,6,7,8,9,10,11,12],0,"0",0,0,0,0,"18",0,"00"],AZ:["994","00","365\\d{6}|(?:[124579]\\d|60|88)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["90"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["1[28]|2|365|46","1[28]|2|365[45]|46","1[28]|2|365(?:4|5[02])|46"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[13-9]"],"0$1"]],"0"],BA:["387","00","6\\d{8}|(?:[35689]\\d|49|70)\\d{6}",[8,9],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["6[1-3]|[7-9]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2-$3",["[3-5]|6[56]"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3 $4",["6"],"0$1"]],"0"],BB:["1","011","(?:246|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","246$1",0,"246"],BD:["880","00","[1-469]\\d{9}|8[0-79]\\d{7,8}|[2-79]\\d{8}|[2-9]\\d{7}|[3-9]\\d{6}|[57-9]\\d{5}",[6,7,8,9,10],[["(\\d{2})(\\d{4,6})","$1-$2",["31[5-8]|[459]1"],"0$1"],["(\\d{3})(\\d{3,7})","$1-$2",["3(?:[67]|8[013-9])|4(?:6[168]|7|[89][18])|5(?:6[128]|9)|6(?:[15]|28|4[14])|7[2-589]|8(?:0[014-9]|[12])|9[358]|(?:3[2-5]|4[235]|5[2-578]|6[0389]|76|8[3-7]|9[24])1|(?:44|66)[01346-9]"],"0$1"],["(\\d{4})(\\d{3,6})","$1-$2",["[13-9]|2[23]"],"0$1"],["(\\d)(\\d{7,8})","$1-$2",["2"],"0$1"]],"0"],BE:["32","00","4\\d{8}|[1-9]\\d{7}",[8,9],[["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["(?:80|9)0"],"0$1"],["(\\d)(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[239]|4[23]"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[15-8]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["4"],"0$1"]],"0"],BF:["226","00","[025-7]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[025-7]"]]]],BG:["359","00","00800\\d{7}|[2-7]\\d{6,7}|[89]\\d{6,8}|2\\d{5}",[6,7,8,9,12],[["(\\d)(\\d)(\\d{2})(\\d{2})","$1 $2 $3 $4",["2"],"0$1"],["(\\d{3})(\\d{4})","$1 $2",["43[1-6]|70[1-9]"],"0$1"],["(\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{2,3})","$1 $2 $3",["[356]|4[124-7]|7[1-9]|8[1-6]|9[1-7]"],"0$1"],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["(?:70|8)0"],"0$1"],["(\\d{3})(\\d{3})(\\d{2})","$1 $2 $3",["43[1-7]|7"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[48]|9[08]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["9"],"0$1"]],"0"],BH:["973","00","[136-9]\\d{7}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[13679]|8[02-4679]"]]]],BI:["257","00","(?:[267]\\d|31)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2367]"]]]],BJ:["229","00","(?:01\\d|[24-689])\\d{7}",[8,10],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[24-689]"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["0"]]]],BL:["590","00","(?:590\\d|7090)\\d{5}|(?:69|80|9\\d)\\d{7}",[9],0,"0",0,0,0,0,0,[["590(?:2[7-9]|3[3-7]|5[12]|87)\\d{4}"],["(?:69(?:0\\d\\d|1(?:2[2-9]|3[0-5])|4(?:0[89]|1[2-6]|9\\d)|6(?:1[016-9]|5[0-4]|[67]\\d))|7090[0-4])\\d{4}"],["80[0-5]\\d{6}"],0,0,0,0,0,["9(?:(?:39[5-7]|76[018])\\d|475[0-5])\\d{4}"]]],BM:["1","011","(?:441|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","441$1",0,"441"],BN:["673","00","[2-578]\\d{6}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[2-578]"]]]],BO:["591","00(?:1\\d)?","8001\\d{5}|(?:[2-467]\\d|50)\\d{6}",[8,9],[["(\\d)(\\d{7})","$1 $2",["[235]|4[46]"]],["(\\d{8})","$1",["[67]"]],["(\\d{3})(\\d{2})(\\d{4})","$1 $2 $3",["8"]]],"0",0,"0(1\\d)?"],BQ:["599","00","(?:[34]1|7\\d)\\d{5}",[7],0,0,0,0,0,0,"[347]"],BR:["55","00(?:1[245]|2[1-35]|31|4[13]|[56]5|99)","(?:[1-46-9]\\d\\d|5(?:[0-46-9]\\d|5[0-46-9]))\\d{8}|[1-9]\\d{9}|[3589]\\d{8}|[34]\\d{7}",[8,9,10,11],[["(\\d{4})(\\d{4})","$1-$2",["300|4(?:0[02]|37)","4(?:02|37)0|[34]00"]],["(\\d{3})(\\d{2,3})(\\d{4})","$1 $2 $3",["(?:[358]|90)0"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1 $2-$3",["(?:[14689][1-9]|2[12478]|3[1-578]|5[13-5]|7[13-579])[2-57]"],"($1)"],["(\\d{2})(\\d{5})(\\d{4})","$1 $2-$3",["[16][1-9]|[2-57-9]"],"($1)"]],"0",0,"(?:0|90)(?:(1[245]|2[1-35]|31|4[13]|[56]5|99)(\\d{10,11}))?","$2"],BS:["1","011","(?:242|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([3-8]\\d{6})$|1","242$1",0,"242"],BT:["975","00","[17]\\d{7}|[2-8]\\d{6}",[7,8],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[2-68]|7[246]"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["1[67]|7"]]]],BW:["267","00","(?:0800|(?:[37]|800)\\d)\\d{6}|(?:[2-6]\\d|90)\\d{5}",[7,8,10],[["(\\d{2})(\\d{5})","$1 $2",["90"]],["(\\d{3})(\\d{4})","$1 $2",["[24-6]|3[15-9]"]],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[37]"]],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["0"]],["(\\d{3})(\\d{4})(\\d{3})","$1 $2 $3",["8"]]]],BY:["375","810","(?:[12]\\d|33|44|902)\\d{7}|8(?:0[0-79]\\d{5,7}|[1-7]\\d{9})|8(?:1[0-489]|[5-79]\\d)\\d{7}|8[1-79]\\d{6,7}|8[0-79]\\d{5}|8\\d{5}",[6,7,8,9,10,11],[["(\\d{3})(\\d{3})","$1 $2",["800"],"8 $1"],["(\\d{3})(\\d{2})(\\d{2,4})","$1 $2 $3",["800"],"8 $1"],["(\\d{4})(\\d{2})(\\d{3})","$1 $2-$3",["1(?:5[169]|6[3-5]|7[179])|2(?:1[35]|2[34]|3[3-5])","1(?:5[169]|6(?:3[1-3]|4|5[125])|7(?:1[3-9]|7[0-24-6]|9[2-7]))|2(?:1[35]|2[34]|3[3-5])"],"8 0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2-$3-$4",["1(?:[56]|7[467])|2[1-3]"],"8 0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2-$3-$4",["[1-4]"],"8 0$1"],["(\\d{3})(\\d{3,4})(\\d{4})","$1 $2 $3",["[89]"],"8 $1"]],"8",0,"0|80?",0,0,0,0,"8~10"],BZ:["501","00","(?:0800\\d|[2-8])\\d{6}",[7,11],[["(\\d{3})(\\d{4})","$1-$2",["[2-8]"]],["(\\d)(\\d{3})(\\d{4})(\\d{3})","$1-$2-$3-$4",["0"]]]],CA:["1","011","[2-9]\\d{9}|3\\d{6}",[7,10],0,"1",0,0,0,0,0,[["(?:2(?:04|[23]6|[48]9|50|63)|3(?:06|43|54|6[578]|82)|4(?:03|1[68]|[26]8|3[178]|50|74)|5(?:06|1[49]|48|79|8[147])|6(?:04|[18]3|39|47|72)|7(?:0[59]|42|53|78|8[02])|8(?:[06]7|19|25|7[39])|9(?:0[25]|42))[2-9]\\d{6}",[10]],["",[10]],["8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",[10]],["900[2-9]\\d{6}",[10]],["52(?:3(?:[2-46-9][02-9]\\d|5(?:[02-46-9]\\d|5[0-46-9]))|4(?:[2-478][02-9]\\d|5(?:[034]\\d|2[024-9]|5[0-46-9])|6(?:0[1-9]|[2-9]\\d)|9(?:[05-9]\\d|2[0-5]|49)))\\d{4}|52[34][2-9]1[02-9]\\d{4}|(?:5(?:2[125-9]|33|44|66|77|88)|6(?:22|33))[2-9]\\d{6}",[10]],0,["310\\d{4}",[7]],0,["600[2-9]\\d{6}",[10]]]],CC:["61","001[14-689]|14(?:1[14]|34|4[17]|[56]6|7[47]|88)0011","1(?:[0-79]\\d{8}(?:\\d{2})?|8[0-24-9]\\d{7})|[148]\\d{8}|1\\d{5,7}",[6,7,8,9,10,12],0,"0",0,"([59]\\d{7})$|0","8$1",0,0,[["8(?:51(?:0(?:02|31|60|89)|1(?:18|76)|223)|91(?:0(?:1[0-2]|29)|1(?:[28]2|50|79)|2(?:10|64)|3(?:[06]8|22)|4[29]8|62\\d|70[23]|959))\\d{3}",[9]],["4(?:79[01]|83[0-389]|94[0-4])\\d{5}|4(?:[0-36]\\d|4[047-9]|5[0-25-9]|7[02-8]|8[0-24-9]|9[0-37-9])\\d{6}",[9]],["180(?:0\\d{3}|2)\\d{3}",[7,10]],["190[0-26]\\d{6}",[10]],0,0,0,0,["14(?:5(?:1[0458]|[23][458])|71\\d)\\d{4}",[9]],["13(?:00\\d{6}(?:\\d{2})?|45[0-4]\\d{3})|13\\d{4}",[6,8,10,12]]],"0011"],CD:["243","00","(?:(?:[189]|5\\d)\\d|2)\\d{7}|[1-68]\\d{6}",[7,8,9,10],[["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["88"],"0$1"],["(\\d{2})(\\d{5})","$1 $2",["[1-6]"],"0$1"],["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["1"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[89]"],"0$1"],["(\\d{2})(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3 $4",["5"],"0$1"]],"0"],CF:["236","00","(?:[27]\\d{3}|8776)\\d{4}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[278]"]]]],CG:["242","00","222\\d{6}|(?:0\\d|80)\\d{7}",[9],[["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["8"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[02]"]]]],CH:["41","00","8\\d{11}|[2-9]\\d{8}",[9,12],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8[047]|90"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-79]|81"],"0$1"],["(\\d{3})(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["8"],"0$1"]],"0"],CI:["225","00","[02]\\d{9}",[10],[["(\\d{2})(\\d{2})(\\d)(\\d{5})","$1 $2 $3 $4",["2"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3 $4",["0"]]]],CK:["682","00","[2-578]\\d{4}",[5],[["(\\d{2})(\\d{3})","$1 $2",["[2-578]"]]]],CL:["56","(?:0|1(?:1[0-69]|2[02-5]|5[13-58]|69|7[0167]|8[018]))0","12300\\d{6}|6\\d{9,10}|[2-9]\\d{8}",[9,10,11],[["(\\d{5})(\\d{4})","$1 $2",["219","2196"],"($1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["44"]],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["2[1-36]"],"($1)"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["9[2-9]"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["3[2-5]|[47]|5[1-3578]|6[13-57]|8(?:0[1-9]|[1-9])"],"($1)"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["60|8"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["1"]],["(\\d{3})(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3 $4",["60"]]]],CM:["237","00","[26]\\d{8}|88\\d{6,7}",[8,9],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["88"]],["(\\d)(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["[26]|88"]]]],CN:["86","00|1(?:[12]\\d|79)\\d\\d00","(?:(?:1[03-689]|2\\d)\\d\\d|6)\\d{8}|1\\d{10}|[126]\\d{6}(?:\\d(?:\\d{2})?)?|86\\d{5,6}|(?:[3-579]\\d|8[0-57-9])\\d{5,9}",[7,8,9,10,11,12],[["(\\d{2})(\\d{5,6})","$1 $2",["(?:10|2[0-57-9])[19]|3(?:[157]|35|49|9[1-68])|4(?:1[124-9]|2[179]|6[47-9]|7|8[23])|5(?:[1357]|2[37]|4[36]|6[1-46]|80)|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:07|1[236-8]|2[5-7]|[37]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3|4[13]|5[1-5]|7[0-79]|9[0-35-9])|(?:4[35]|59|85)[1-9]","(?:10|2[0-57-9])(?:1[02]|9[56])|8078|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))1","10(?:1(?:0|23)|9[56])|2[0-57-9](?:1(?:00|23)|9[56])|80781|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))12","10(?:1(?:0|23)|9[56])|2[0-57-9](?:1(?:00|23)|9[56])|807812|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))123","10(?:1(?:0|23)|9[56])|2[0-57-9](?:1(?:00|23)|9[56])|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:078|1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))123"],"0$1"],["(\\d{3})(\\d{5,6})","$1 $2",["3(?:[157]|35|49|9[1-68])|4(?:[17]|2[179]|6[47-9]|8[23])|5(?:[1357]|2[37]|4[36]|6[1-46]|80)|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]|4[13]|5[1-5])|(?:4[35]|59|85)[1-9]","(?:3(?:[157]\\d|35|49|9[1-68])|4(?:[17]\\d|2[179]|[35][1-9]|6[47-9]|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]\\d|4[13]|5[1-5]))[19]","85[23](?:10|95)|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:[17]\\d|2[179]|[35][1-9]|6[47-9]|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[14-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]\\d|4[13]|5[1-5]))(?:10|9[56])","85[23](?:100|95)|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:[17]\\d|2[179]|[35][1-9]|6[47-9]|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[14-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]\\d|4[13]|5[1-5]))(?:100|9[56])"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["(?:4|80)0"]],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["10|2(?:[02-57-9]|1[1-9])","10|2(?:[02-57-9]|1[1-9])","10[0-79]|2(?:[02-57-9]|1[1-79])|(?:10|21)8(?:0[1-9]|[1-9])"],"0$1",1],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["3(?:[3-59]|7[02-68])|4(?:[26-8]|3[3-9]|5[2-9])|5(?:3[03-9]|[468]|7[028]|9[2-46-9])|6|7(?:[0-247]|3[04-9]|5[0-4689]|6[2368])|8(?:[1-358]|9[1-7])|9(?:[013479]|5[1-5])|(?:[34]1|55|79|87)[02-9]"],"0$1",1],["(\\d{3})(\\d{7,8})","$1 $2",["9"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["80"],"0$1",1],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["[3-578]"],"0$1",1],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["1[3-9]"]],["(\\d{2})(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3 $4",["[12]"],"0$1",1]],"0",0,"(1(?:[12]\\d|79)\\d\\d)|0",0,0,0,0,"00"],CO:["57","00(?:4(?:[14]4|56)|[579])","(?:46|60\\d\\d)\\d{6}|(?:1\\d|[39])\\d{9}",[8,10,11],[["(\\d{4})(\\d{4})","$1 $2",["46"]],["(\\d{3})(\\d{7})","$1 $2",["6|90"],"($1)"],["(\\d{3})(\\d{7})","$1 $2",["3[0-357]|91"]],["(\\d)(\\d{3})(\\d{7})","$1-$2-$3",["1"],"0$1",0,"$1 $2 $3"]],"0",0,"0([3579]|4(?:[14]4|56))?"],CR:["506","00","(?:8\\d|90)\\d{8}|(?:[24-8]\\d{3}|3005)\\d{4}",[8,10],[["(\\d{4})(\\d{4})","$1 $2",["[2-7]|8[3-9]"]],["(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["[89]"]]],0,0,"(19(?:0[0-2468]|1[09]|20|66|77|99))"],CU:["53","119","(?:[2-7]|8\\d\\d)\\d{7}|[2-47]\\d{6}|[34]\\d{5}",[6,7,8,10],[["(\\d{2})(\\d{4,6})","$1 $2",["2[1-4]|[34]"],"(0$1)"],["(\\d)(\\d{6,7})","$1 $2",["7"],"(0$1)"],["(\\d)(\\d{7})","$1 $2",["[56]"],"0$1"],["(\\d{3})(\\d{7})","$1 $2",["8"],"0$1"]],"0"],CV:["238","0","(?:[2-59]\\d\\d|800)\\d{4}",[7],[["(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",["[2-589]"]]]],CW:["599","00","(?:[34]1|60|(?:7|9\\d)\\d)\\d{5}",[7,8],[["(\\d{3})(\\d{4})","$1 $2",["[3467]"]],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["9[4-8]"]]],0,0,0,0,0,"[69]"],CX:["61","001[14-689]|14(?:1[14]|34|4[17]|[56]6|7[47]|88)0011","1(?:[0-79]\\d{8}(?:\\d{2})?|8[0-24-9]\\d{7})|[148]\\d{8}|1\\d{5,7}",[6,7,8,9,10,12],0,"0",0,"([59]\\d{7})$|0","8$1",0,0,[["8(?:51(?:0(?:01|30|59|88)|1(?:17|46|75)|2(?:22|35))|91(?:00[6-9]|1(?:[28]1|49|78)|2(?:09|63)|3(?:12|26|75)|4(?:56|97)|64\\d|7(?:0[01]|1[0-2])|958))\\d{3}",[9]],["4(?:79[01]|83[0-389]|94[0-4])\\d{5}|4(?:[0-36]\\d|4[047-9]|5[0-25-9]|7[02-8]|8[0-24-9]|9[0-37-9])\\d{6}",[9]],["180(?:0\\d{3}|2)\\d{3}",[7,10]],["190[0-26]\\d{6}",[10]],0,0,0,0,["14(?:5(?:1[0458]|[23][458])|71\\d)\\d{4}",[9]],["13(?:00\\d{6}(?:\\d{2})?|45[0-4]\\d{3})|13\\d{4}",[6,8,10,12]]],"0011"],CY:["357","00","(?:[279]\\d|[58]0)\\d{6}",[8],[["(\\d{2})(\\d{6})","$1 $2",["[257-9]"]]]],CZ:["420","00","(?:[2-578]\\d|60)\\d{7}|9\\d{8,11}",[9,10,11,12],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[2-8]|9[015-7]"]],["(\\d{2})(\\d{3})(\\d{3})(\\d{2})","$1 $2 $3 $4",["96"]],["(\\d{2})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["9"]],["(\\d{3})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["9"]]]],DE:["49","00","[2579]\\d{5,14}|49(?:[34]0|69|8\\d)\\d\\d?|49(?:37|49|60|7[089]|9\\d)\\d{1,3}|49(?:2[024-9]|3[2-689]|7[1-7])\\d{1,8}|(?:1|[368]\\d|4[0-8])\\d{3,13}|49(?:[015]\\d|2[13]|31|[46][1-8])\\d{1,9}",[4,5,6,7,8,9,10,11,12,13,14,15],[["(\\d{2})(\\d{3,13})","$1 $2",["3[02]|40|[68]9"],"0$1"],["(\\d{3})(\\d{3,12})","$1 $2",["2(?:0[1-389]|1[124]|2[18]|3[14])|3(?:[35-9][15]|4[015])|906|(?:2[4-9]|4[2-9]|[579][1-9]|[68][1-8])1","2(?:0[1-389]|12[0-8])|3(?:[35-9][15]|4[015])|906|2(?:[13][14]|2[18])|(?:2[4-9]|4[2-9]|[579][1-9]|[68][1-8])1"],"0$1"],["(\\d{4})(\\d{2,11})","$1 $2",["[24-6]|3(?:[3569][02-46-9]|4[2-4679]|7[2-467]|8[2-46-8])|70[2-8]|8(?:0[2-9]|[1-8])|90[7-9]|[79][1-9]","[24-6]|3(?:3(?:0[1-467]|2[127-9]|3[124578]|7[1257-9]|8[1256]|9[145])|4(?:2[135]|4[13578]|9[1346])|5(?:0[14]|2[1-3589]|6[1-4]|7[13468]|8[13568])|6(?:2[1-489]|3[124-6]|6[13]|7[12579]|8[1-356]|9[135])|7(?:2[1-7]|4[145]|6[1-5]|7[1-4])|8(?:21|3[1468]|6|7[1467]|8[136])|9(?:0[12479]|2[1358]|4[134679]|6[1-9]|7[136]|8[147]|9[1468]))|70[2-8]|8(?:0[2-9]|[1-8])|90[7-9]|[79][1-9]|3[68]4[1347]|3(?:47|60)[1356]|3(?:3[46]|46|5[49])[1246]|3[4579]3[1357]"],"0$1"],["(\\d{3})(\\d{4})","$1 $2",["138"],"0$1"],["(\\d{5})(\\d{2,10})","$1 $2",["3"],"0$1"],["(\\d{3})(\\d{5,11})","$1 $2",["181"],"0$1"],["(\\d{3})(\\d)(\\d{4,10})","$1 $2 $3",["1(?:3|80)|9"],"0$1"],["(\\d{3})(\\d{7,8})","$1 $2",["1[67]"],"0$1"],["(\\d{3})(\\d{7,12})","$1 $2",["8"],"0$1"],["(\\d{5})(\\d{6})","$1 $2",["185","1850","18500"],"0$1"],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["7"],"0$1"],["(\\d{4})(\\d{7})","$1 $2",["18[68]"],"0$1"],["(\\d{4})(\\d{7})","$1 $2",["15[1279]"],"0$1"],["(\\d{5})(\\d{6})","$1 $2",["15[03568]","15(?:[0568]|31)"],"0$1"],["(\\d{3})(\\d{8})","$1 $2",["18"],"0$1"],["(\\d{3})(\\d{2})(\\d{7,8})","$1 $2 $3",["1(?:6[023]|7)"],"0$1"],["(\\d{4})(\\d{2})(\\d{7})","$1 $2 $3",["15[279]"],"0$1"],["(\\d{3})(\\d{2})(\\d{8})","$1 $2 $3",["15"],"0$1"]],"0"],DJ:["253","00","(?:2\\d|77)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[27]"]]]],DK:["45","00","[2-9]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-9]"]]]],DM:["1","011","(?:[58]\\d\\d|767|900)\\d{7}",[10],0,"1",0,"([2-7]\\d{6})$|1","767$1",0,"767"],DO:["1","011","(?:[58]\\d\\d|900)\\d{7}",[10],0,"1",0,0,0,0,"8001|8[024]9"],DZ:["213","00","(?:[1-4]|[5-79]\\d|80)\\d{7}",[8,9],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[1-4]"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["9"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-8]"],"0$1"]],"0"],EC:["593","00","1\\d{9,10}|(?:[2-7]|9\\d)\\d{7}",[8,9,10,11],[["(\\d)(\\d{3})(\\d{4})","$1 $2-$3",["[2-7]"],"(0$1)",0,"$1-$2-$3"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["9"],"0$1"],["(\\d{4})(\\d{3})(\\d{3,4})","$1 $2 $3",["1"]]],"0"],EE:["372","00","8\\d{9}|[4578]\\d{7}|(?:[3-8]\\d|90)\\d{5}",[7,8,10],[["(\\d{3})(\\d{4})","$1 $2",["[369]|4[3-8]|5(?:[0-2]|5[0-478]|6[45])|7[1-9]|88","[369]|4[3-8]|5(?:[02]|1(?:[0-8]|95)|5[0-478]|6(?:4[0-4]|5[1-589]))|7[1-9]|88"]],["(\\d{4})(\\d{3,4})","$1 $2",["[45]|8(?:00|[1-49])","[45]|8(?:00[1-9]|[1-49])"]],["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["7"]],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["8"]]]],EG:["20","00","[189]\\d{8,9}|[24-6]\\d{8}|[135]\\d{7}",[8,9,10],[["(\\d)(\\d{7,8})","$1 $2",["[23]"],"0$1"],["(\\d{2})(\\d{6,7})","$1 $2",["1[35]|[4-6]|8[2468]|9[235-7]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[89]"],"0$1"],["(\\d{2})(\\d{8})","$1 $2",["1"],"0$1"]],"0"],EH:["212","00","[5-8]\\d{8}",[9],0,"0",0,0,0,0,"528[89]"],ER:["291","00","[178]\\d{6}",[7],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[178]"],"0$1"]],"0"],ES:["34","00","[5-9]\\d{8}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[89]00"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-9]"]]]],ET:["251","00","(?:11|[2-579]\\d)\\d{7}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[1-579]"],"0$1"]],"0"],FI:["358","00|99(?:[01469]|5(?:[14]1|3[23]|5[59]|77|88|9[09]))","[1-35689]\\d{4}|7\\d{10,11}|(?:[124-7]\\d|3[0-46-9])\\d{8}|[1-9]\\d{5,8}",[5,6,7,8,9,10,11,12],[["(\\d{5})","$1",["20[2-59]"],"0$1"],["(\\d{3})(\\d{3,7})","$1 $2",["(?:[1-3]0|[68])0|70[07-9]"],"0$1"],["(\\d{2})(\\d{4,8})","$1 $2",["[14]|2[09]|50|7[135]"],"0$1"],["(\\d{2})(\\d{6,10})","$1 $2",["7"],"0$1"],["(\\d)(\\d{4,9})","$1 $2",["(?:19|[2568])[1-8]|3(?:0[1-9]|[1-9])|9"],"0$1"]],"0",0,0,0,0,"1[03-79]|[2-9]",0,"00"],FJ:["679","0(?:0|52)","45\\d{5}|(?:0800\\d|[235-9])\\d{6}",[7,11],[["(\\d{3})(\\d{4})","$1 $2",["[235-9]|45"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["0"]]],0,0,0,0,0,0,0,"00"],FK:["500","00","[2-7]\\d{4}",[5]],FM:["691","00","(?:[39]\\d\\d|820)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[389]"]]]],FO:["298","00","[2-9]\\d{5}",[6],[["(\\d{6})","$1",["[2-9]"]]],0,0,"(10(?:01|[12]0|88))"],FR:["33","00","[1-9]\\d{8}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0 $1"],["(\\d)(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["[1-79]"],"0$1"]],"0"],GA:["241","00","(?:[067]\\d|11)\\d{6}|[2-7]\\d{6}",[7,8],[["(\\d)(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-7]"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["0"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["11|[67]"],"0$1"]],0,0,"0(11\\d{6}|60\\d{6}|61\\d{6}|6[256]\\d{6}|7[467]\\d{6})","$1"],GB:["44","00","[1-357-9]\\d{9}|[18]\\d{8}|8\\d{6}",[7,9,10],[["(\\d{3})(\\d{4})","$1 $2",["800","8001","80011","800111","8001111"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",["845","8454","84546","845464"],"0$1"],["(\\d{3})(\\d{6})","$1 $2",["800"],"0$1"],["(\\d{5})(\\d{4,5})","$1 $2",["1(?:38|5[23]|69|76|94)","1(?:(?:38|69)7|5(?:24|39)|768|946)","1(?:3873|5(?:242|39[4-6])|(?:697|768)[347]|9467)"],"0$1"],["(\\d{4})(\\d{5,6})","$1 $2",["1(?:[2-69][02-9]|[78])"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["[25]|7(?:0|6[02-9])","[25]|7(?:0|6(?:[03-9]|2[356]))"],"0$1"],["(\\d{4})(\\d{6})","$1 $2",["7"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[1389]"],"0$1"]],"0",0,0,0,0,0,[["(?:1(?:1(?:3(?:[0-58]\\d\\d|73[0-35])|4(?:(?:[0-5]\\d|70)\\d|69[7-9])|(?:(?:5[0-26-9]|[78][0-49])\\d|6(?:[0-4]\\d|50))\\d)|(?:2(?:(?:0[024-9]|2[3-9]|3[3-79]|4[1-689]|[58][02-9]|6[0-47-9]|7[013-9]|9\\d)\\d|1(?:[0-7]\\d|8[0-3]))|(?:3(?:0\\d|1[0-8]|[25][02-9]|3[02-579]|[468][0-46-9]|7[1-35-79]|9[2-578])|4(?:0[03-9]|[137]\\d|[28][02-57-9]|4[02-69]|5[0-8]|[69][0-79])|5(?:0[1-35-9]|[16]\\d|2[024-9]|3[015689]|4[02-9]|5[03-9]|7[0-35-9]|8[0-468]|9[0-57-9])|6(?:0[034689]|1\\d|2[0-35689]|[38][013-9]|4[1-467]|5[0-69]|6[13-9]|7[0-8]|9[0-24578])|7(?:0[0246-9]|2\\d|3[0236-8]|4[03-9]|5[0-46-9]|6[013-9]|7[0-35-9]|8[024-9]|9[02-9])|8(?:0[35-9]|2[1-57-9]|3[02-578]|4[0-578]|5[124-9]|6[2-69]|7\\d|8[02-9]|9[02569])|9(?:0[02-589]|[18]\\d|2[02-689]|3[1-57-9]|4[2-9]|5[0-579]|6[2-47-9]|7[0-24578]|9[2-57]))\\d)\\d)|2(?:0[013478]|3[0189]|4[017]|8[0-46-9]|9[0-2])\\d{3})\\d{4}|1(?:2(?:0(?:46[1-4]|87[2-9])|545[1-79]|76(?:2\\d|3[1-8]|6[1-6])|9(?:7(?:2[0-4]|3[2-5])|8(?:2[2-8]|7[0-47-9]|8[3-5])))|3(?:6(?:38[2-5]|47[23])|8(?:47[04-9]|64[0157-9]))|4(?:044[1-7]|20(?:2[23]|8\\d)|6(?:0(?:30|5[2-57]|6[1-8]|7[2-8])|140)|8(?:052|87[1-3]))|5(?:2(?:4(?:3[2-79]|6\\d)|76\\d)|6(?:26[06-9]|686))|6(?:06(?:4\\d|7[4-79])|295[5-7]|35[34]\\d|47(?:24|61)|59(?:5[08]|6[67]|74)|9(?:55[0-4]|77[23]))|7(?:26(?:6[13-9]|7[0-7])|(?:442|688)\\d|50(?:2[0-3]|[3-68]2|76))|8(?:27[56]\\d|37(?:5[2-5]|8[239])|843[2-58])|9(?:0(?:0(?:6[1-8]|85)|52\\d)|3583|4(?:66[1-8]|9(?:2[01]|81))|63(?:23|3[1-4])|9561))\\d{3}",[9,10]],["7(?:457[0-57-9]|700[01]|911[028])\\d{5}|7(?:[1-3]\\d\\d|4(?:[0-46-9]\\d|5[0-689])|5(?:0[0-8]|[13-9]\\d|2[0-35-9])|7(?:0[1-9]|[1-7]\\d|8[02-9]|9[0-689])|8(?:[014-9]\\d|[23][0-8])|9(?:[024-9]\\d|1[02-9]|3[0-689]))\\d{6}",[10]],["80[08]\\d{7}|800\\d{6}|8001111"],["(?:8(?:4[2-5]|7[0-3])|9(?:[01]\\d|8[2-49]))\\d{7}|845464\\d",[7,10]],["70\\d{8}",[10]],0,["(?:3[0347]|55)\\d{8}",[10]],["76(?:464|652)\\d{5}|76(?:0[0-28]|2[356]|34|4[01347]|5[49]|6[0-369]|77|8[14]|9[139])\\d{6}",[10]],["56\\d{8}",[10]]],0," x"],GD:["1","011","(?:473|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","473$1",0,"473"],GE:["995","00","(?:[3-57]\\d\\d|800)\\d{6}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["70"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["32"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[57]"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[348]"],"0$1"]],"0"],GF:["594","00","(?:[56]94\\d|7093)\\d{5}|(?:80|9\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-7]|9[47]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[89]"],"0$1"]],"0"],GG:["44","00","(?:1481|[357-9]\\d{3})\\d{6}|8\\d{6}(?:\\d{2})?",[7,9,10],0,"0",0,"([25-9]\\d{5})$|0","1481$1",0,0,[["1481[25-9]\\d{5}",[10]],["7(?:(?:781|839)\\d|911[17])\\d{5}",[10]],["80[08]\\d{7}|800\\d{6}|8001111"],["(?:8(?:4[2-5]|7[0-3])|9(?:[01]\\d|8[0-3]))\\d{7}|845464\\d",[7,10]],["70\\d{8}",[10]],0,["(?:3[0347]|55)\\d{8}",[10]],["76(?:464|652)\\d{5}|76(?:0[0-28]|2[356]|34|4[01347]|5[49]|6[0-369]|77|8[14]|9[139])\\d{6}",[10]],["56\\d{8}",[10]]]],GH:["233","00","(?:[235]\\d{3}|800)\\d{5}",[8,9],[["(\\d{3})(\\d{5})","$1 $2",["8"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[235]"],"0$1"]],"0"],GI:["350","00","(?:[25]\\d|60)\\d{6}",[8],[["(\\d{3})(\\d{5})","$1 $2",["2"]]]],GL:["299","00","(?:19|[2-689]\\d|70)\\d{4}",[6],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["19|[2-9]"]]]],GM:["220","00","[2-9]\\d{6}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[2-9]"]]]],GN:["224","00","722\\d{6}|(?:3|6\\d)\\d{7}",[8,9],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["3"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[67]"]]]],GP:["590","00","(?:590\\d|7090)\\d{5}|(?:69|80|9\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-79]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0$1"]],"0",0,0,0,0,0,[["590(?:0[1-68]|[14][0-24-9]|2[0-68]|3[1-9]|5[3-579]|[68][0-689]|7[08]|9\\d)\\d{4}"],["(?:69(?:0\\d\\d|1(?:2[2-9]|3[0-5])|4(?:0[89]|1[2-6]|9\\d)|6(?:1[016-9]|5[0-4]|[67]\\d))|7090[0-4])\\d{4}"],["80[0-5]\\d{6}"],0,0,0,0,0,["9(?:(?:39[5-7]|76[018])\\d|475[0-5])\\d{4}"]]],GQ:["240","00","222\\d{6}|(?:3\\d|55|[89]0)\\d{7}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[235]"]],["(\\d{3})(\\d{6})","$1 $2",["[89]"]]]],GR:["30","00","5005000\\d{3}|8\\d{9,11}|(?:[269]\\d|70)\\d{8}",[10,11,12],[["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["21|7"]],["(\\d{4})(\\d{6})","$1 $2",["2(?:2|3[2-57-9]|4[2-469]|5[2-59]|6[2-9]|7[2-69]|8[2-49])|5"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[2689]"]],["(\\d{3})(\\d{3,4})(\\d{5})","$1 $2 $3",["8"]]]],GT:["502","00","80\\d{6}|(?:1\\d{3}|[2-7])\\d{7}",[8,11],[["(\\d{4})(\\d{4})","$1 $2",["[2-8]"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["1"]]]],GU:["1","011","(?:[58]\\d\\d|671|900)\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","671$1",0,"671"],GW:["245","00","[49]\\d{8}|4\\d{6}",[7,9],[["(\\d{3})(\\d{4})","$1 $2",["40"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[49]"]]]],GY:["592","001","(?:[2-8]\\d{3}|9008)\\d{3}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[2-9]"]]]],HK:["852","00(?:30|5[09]|[126-9]?)","8[0-46-9]\\d{6,7}|9\\d{4,7}|(?:[2-7]|9\\d{3})\\d{7}",[5,6,7,8,9,11],[["(\\d{3})(\\d{2,5})","$1 $2",["900","9003"]],["(\\d{4})(\\d{4})","$1 $2",["[2-7]|8[1-4]|9(?:0[1-9]|[1-8])"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8"]],["(\\d{3})(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3 $4",["9"]]],0,0,0,0,0,0,0,"00"],HN:["504","00","8\\d{10}|[237-9]\\d{7}",[8,11],[["(\\d{4})(\\d{4})","$1-$2",["[237-9]"]]]],HR:["385","00","(?:[24-69]\\d|3[0-79])\\d{7}|80\\d{5,7}|[1-79]\\d{7}|6\\d{5,6}",[6,7,8,9],[["(\\d{2})(\\d{2})(\\d{2,3})","$1 $2 $3",["6[01]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2,3})","$1 $2 $3",["8"],"0$1"],["(\\d)(\\d{4})(\\d{3})","$1 $2 $3",["1"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["6|7[245]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["9"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2-57]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8"],"0$1"]],"0"],HT:["509","00","(?:[2-489]\\d|55)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["[2-589]"]]]],HU:["36","00","[235-7]\\d{8}|[1-9]\\d{7}",[8,9],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["1"],"(06 $1)"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[27][2-9]|3[2-7]|4[24-9]|5[2-79]|6|8[2-57-9]|9[2-69]"],"(06 $1)"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2-9]"],"06 $1"]],"06"],ID:["62","00[89]","00[1-9]\\d{9,14}|(?:[1-36]|8\\d{5})\\d{6}|00\\d{9}|[1-9]\\d{8,10}|[2-9]\\d{7}",[7,8,9,10,11,12,13,14,15,16,17],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["15"]],["(\\d{2})(\\d{5,9})","$1 $2",["2[124]|[36]1"],"(0$1)"],["(\\d{3})(\\d{5,7})","$1 $2",["800"],"0$1"],["(\\d{3})(\\d{5,8})","$1 $2",["[2-79]"],"(0$1)"],["(\\d{3})(\\d{3,4})(\\d{3})","$1-$2-$3",["8[1-35-9]"],"0$1"],["(\\d{3})(\\d{6,8})","$1 $2",["1"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["804"],"0$1"],["(\\d{3})(\\d)(\\d{3})(\\d{3})","$1 $2 $3 $4",["80"],"0$1"],["(\\d{3})(\\d{4})(\\d{4,5})","$1-$2-$3",["8"],"0$1"]],"0"],IE:["353","00","(?:1\\d|[2569])\\d{6,8}|4\\d{6,9}|7\\d{8}|8\\d{8,9}",[7,8,9,10],[["(\\d{2})(\\d{5})","$1 $2",["2[24-9]|47|58|6[237-9]|9[35-9]"],"(0$1)"],["(\\d{3})(\\d{5})","$1 $2",["[45]0"],"(0$1)"],["(\\d)(\\d{3,4})(\\d{4})","$1 $2 $3",["1"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2569]|4[1-69]|7[14]"],"(0$1)"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["70"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["81"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[78]"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1"]],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["4"],"(0$1)"],["(\\d{2})(\\d)(\\d{3})(\\d{4})","$1 $2 $3 $4",["8"],"0$1"]],"0"],IL:["972","0(?:0|1[2-9])","1\\d{6}(?:\\d{3,5})?|[57]\\d{8}|[1-489]\\d{7}",[7,8,9,10,11,12],[["(\\d{4})(\\d{3})","$1-$2",["125"]],["(\\d{4})(\\d{2})(\\d{2})","$1-$2-$3",["121"]],["(\\d)(\\d{3})(\\d{4})","$1-$2-$3",["[2-489]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["[57]"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1-$2-$3",["12"]],["(\\d{4})(\\d{6})","$1-$2",["159"]],["(\\d)(\\d{3})(\\d{3})(\\d{3})","$1-$2-$3-$4",["1[7-9]"]],["(\\d{3})(\\d{1,2})(\\d{3})(\\d{4})","$1-$2 $3-$4",["15"]]],"0"],IM:["44","00","1624\\d{6}|(?:[3578]\\d|90)\\d{8}",[10],0,"0",0,"([25-8]\\d{5})$|0","1624$1",0,"74576|(?:16|7[56])24"],IN:["91","00","(?:000800|[2-9]\\d\\d)\\d{7}|1\\d{7,12}",[8,9,10,11,12,13],[["(\\d{8})","$1",["5(?:0|2[23]|3[03]|[67]1|88)","5(?:0|2(?:21|3)|3(?:0|3[23])|616|717|888)","5(?:0|2(?:21|3)|3(?:0|3[23])|616|717|8888)"],0,1],["(\\d{4})(\\d{4,5})","$1 $2",["180","1800"],0,1],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["140"],0,1],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["11|2[02]|33|4[04]|79[1-7]|80[2-46]","11|2[02]|33|4[04]|79(?:[1-6]|7[19])|80(?:[2-4]|6[0-589])","11|2[02]|33|4[04]|79(?:[124-6]|3(?:[02-9]|1[0-24-9])|7(?:1|9[1-6]))|80(?:[2-4]|6[0-589])"],"0$1",1],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["1(?:2[0-249]|3[0-25]|4[145]|[68]|7[1257])|2(?:1[257]|3[013]|4[01]|5[0137]|6[0158]|78|8[1568])|3(?:26|4[1-3]|5[34]|6[01489]|7[02-46]|8[159])|4(?:1[36]|2[1-47]|5[12]|6[0-26-9]|7[0-24-9]|8[013-57]|9[014-7])|5(?:1[025]|22|[36][25]|4[28]|5[12]|[78]1)|6(?:12|[2-4]1|5[17]|6[13]|80)|7(?:12|3[134]|4[47]|61|88)|8(?:16|2[014]|3[126]|6[136]|7[078]|8[34]|91)|(?:43|59|75)[15]|(?:1[59]|29|67|72)[14]","1(?:2[0-24]|3[0-25]|4[145]|[59][14]|6[1-9]|7[1257]|8[1-57-9])|2(?:1[257]|3[013]|4[01]|5[0137]|6[058]|78|8[1568]|9[14])|3(?:26|4[1-3]|5[34]|6[01489]|7[02-46]|8[159])|4(?:1[36]|2[1-47]|3[15]|5[12]|6[0-26-9]|7[0-24-9]|8[013-57]|9[014-7])|5(?:1[025]|22|[36][25]|4[28]|[578]1|9[15])|674|7(?:(?:2[14]|3[34]|5[15])[2-6]|61[346]|88[0-8])|8(?:70[2-6]|84[235-7]|91[3-7])|(?:1(?:29|60|8[06])|261|552|6(?:12|[2-47]1|5[17]|6[13]|80)|7(?:12|31|4[47])|8(?:16|2[014]|3[126]|6[136]|7[78]|83))[2-7]","1(?:2[0-24]|3[0-25]|4[145]|[59][14]|6[1-9]|7[1257]|8[1-57-9])|2(?:1[257]|3[013]|4[01]|5[0137]|6[058]|78|8[1568]|9[14])|3(?:26|4[1-3]|5[34]|6[01489]|7[02-46]|8[159])|4(?:1[36]|2[1-47]|3[15]|5[12]|6[0-26-9]|7[0-24-9]|8[013-57]|9[014-7])|5(?:1[025]|22|[36][25]|4[28]|[578]1|9[15])|6(?:12(?:[2-6]|7[0-8])|74[2-7])|7(?:(?:2[14]|5[15])[2-6]|3171|61[346]|88(?:[2-7]|82))|8(?:70[2-6]|84(?:[2356]|7[19])|91(?:[3-6]|7[19]))|73[134][2-6]|(?:74[47]|8(?:16|2[014]|3[126]|6[136]|7[78]|83))(?:[2-6]|7[19])|(?:1(?:29|60|8[06])|261|552|6(?:[2-4]1|5[17]|6[13]|7(?:1|4[0189])|80)|7(?:12|88[01]))[2-7]"],"0$1",1],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1(?:[2-479]|5[0235-9])|[2-5]|6(?:1[1358]|2[2457-9]|3[2-5]|4[235-7]|5[2-689]|6[24578]|7[235689]|8[1-6])|7(?:1[013-9]|28|3[129]|4[1-35689]|5[29]|6[02-5]|70)|807","1(?:[2-479]|5[0235-9])|[2-5]|6(?:1[1358]|2(?:[2457]|84|95)|3(?:[2-4]|55)|4[235-7]|5[2-689]|6[24578]|7[235689]|8[1-6])|7(?:1(?:[013-8]|9[6-9])|28[6-8]|3(?:17|2[0-49]|9[2-57])|4(?:1[2-4]|[29][0-7]|3[0-8]|[56]|8[0-24-7])|5(?:2[1-3]|9[0-6])|6(?:0[5689]|2[5-9]|3[02-8]|4|5[0-367])|70[13-7])|807[19]","1(?:[2-479]|5(?:[0236-9]|5[013-9]))|[2-5]|6(?:2(?:84|95)|355|83)|73179|807(?:1|9[1-3])|(?:1552|6(?:1[1358]|2[2457]|3[2-4]|4[235-7]|5[2-689]|6[24578]|7[235689]|8[124-6])\\d|7(?:1(?:[013-8]\\d|9[6-9])|28[6-8]|3(?:2[0-49]|9[2-57])|4(?:1[2-4]|[29][0-7]|3[0-8]|[56]\\d|8[0-24-7])|5(?:2[1-3]|9[0-6])|6(?:0[5689]|2[5-9]|3[02-8]|4\\d|5[0-367])|70[13-7]))[2-7]"],"0$1",1],["(\\d{5})(\\d{5})","$1 $2",["[6-9]"],"0$1",1],["(\\d{4})(\\d{2,4})(\\d{4})","$1 $2 $3",["1(?:6|8[06])","1(?:6|8[06]0)"],0,1],["(\\d{4})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["18"],0,1]],"0"],IO:["246","00","3\\d{6}",[7],[["(\\d{3})(\\d{4})","$1 $2",["3"]]]],IQ:["964","00","(?:1|7\\d\\d)\\d{7}|[2-6]\\d{7,8}",[8,9,10],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["1"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2-6]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["7"],"0$1"]],"0"],IR:["98","00","[1-9]\\d{9}|(?:[1-8]\\d\\d|9)\\d{3,4}",[4,5,6,7,10],[["(\\d{4,5})","$1",["96"],"0$1"],["(\\d{2})(\\d{4,5})","$1 $2",["(?:1[137]|2[13-68]|3[1458]|4[145]|5[1468]|6[16]|7[1467]|8[13467])[12689]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["9"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["[1-8]"],"0$1"]],"0"],IS:["354","00|1(?:0(?:01|[12]0)|100)","(?:38\\d|[4-9])\\d{6}",[7,9],[["(\\d{3})(\\d{4})","$1 $2",["[4-9]"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["3"]]],0,0,0,0,0,0,0,"00"],IT:["39","00","0\\d{5,10}|1\\d{8,10}|3(?:[0-8]\\d{7,10}|9\\d{7,8})|(?:43|55|70)\\d{8}|8\\d{5}(?:\\d{2,4})?",[6,7,8,9,10,11,12],[["(\\d{2})(\\d{4,6})","$1 $2",["0[26]"]],["(\\d{3})(\\d{3,6})","$1 $2",["0[13-57-9][0159]|8(?:03|4[17]|9[2-5])","0[13-57-9][0159]|8(?:03|4[17]|9(?:2|3[04]|[45][0-4]))"]],["(\\d{4})(\\d{2,6})","$1 $2",["0(?:[13-579][2-46-8]|8[236-8])"]],["(\\d{4})(\\d{4})","$1 $2",["894"]],["(\\d{2})(\\d{3,4})(\\d{4})","$1 $2 $3",["0[26]|5"]],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["1(?:44|[679])|[378]|43"]],["(\\d{3})(\\d{3,4})(\\d{4})","$1 $2 $3",["0[13-57-9][0159]|14"]],["(\\d{2})(\\d{4})(\\d{5})","$1 $2 $3",["0[26]"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["0"]],["(\\d{3})(\\d{4})(\\d{4,5})","$1 $2 $3",["3"]]],0,0,0,0,0,0,[["0669[0-79]\\d{1,6}|0(?:1(?:[0159]\\d|[27][1-5]|31|4[1-4]|6[1356]|8[2-57])|2\\d\\d|3(?:[0159]\\d|2[1-4]|3[12]|[48][1-6]|6[2-59]|7[1-7])|4(?:[0159]\\d|[23][1-9]|4[245]|6[1-5]|7[1-4]|81)|5(?:[0159]\\d|2[1-5]|3[2-6]|4[1-79]|6[4-6]|7[1-578]|8[3-8])|6(?:[0-57-9]\\d|6[0-8])|7(?:[0159]\\d|2[12]|3[1-7]|4[2-46]|6[13569]|7[13-6]|8[1-59])|8(?:[0159]\\d|2[3-578]|3[1-356]|[6-8][1-5])|9(?:[0159]\\d|[238][1-5]|4[12]|6[1-8]|7[1-6]))\\d{2,7}",[6,7,8,9,10,11]],["3[2-9]\\d{7,8}|(?:31|43)\\d{8}",[9,10]],["80(?:0\\d{3}|3)\\d{3}",[6,9]],["(?:0878\\d{3}|89(?:2\\d|3[04]|4(?:[0-4]|[5-9]\\d\\d)|5[0-4]))\\d\\d|(?:1(?:44|6[346])|89(?:38|5[5-9]|9))\\d{6}",[6,8,9,10]],["1(?:78\\d|99)\\d{6}",[9,10]],["3[2-8]\\d{9,10}",[11,12]],0,0,["55\\d{8}",[10]],["84(?:[08]\\d{3}|[17])\\d{3}",[6,9]]]],JE:["44","00","1534\\d{6}|(?:[3578]\\d|90)\\d{8}",[10],0,"0",0,"([0-24-8]\\d{5})$|0","1534$1",0,0,[["1534[0-24-8]\\d{5}"],["7(?:(?:(?:50|82)9|937)\\d|7(?:00[378]|97\\d))\\d{5}"],["80(?:07(?:35|81)|8901)\\d{4}"],["(?:8(?:4(?:4(?:4(?:05|42|69)|703)|5(?:041|800))|7(?:0002|1206))|90(?:066[59]|1810|71(?:07|55)))\\d{4}"],["701511\\d{4}"],0,["(?:3(?:0(?:07(?:35|81)|8901)|3\\d{4}|4(?:4(?:4(?:05|42|69)|703)|5(?:041|800))|7(?:0002|1206))|55\\d{4})\\d{4}"],["76(?:464|652)\\d{5}|76(?:0[0-28]|2[356]|34|4[01347]|5[49]|6[0-369]|77|8[14]|9[139])\\d{6}"],["56\\d{8}"]]],JM:["1","011","(?:[58]\\d\\d|658|900)\\d{7}",[10],0,"1",0,0,0,0,"658|876"],JO:["962","00","(?:(?:[2689]|7\\d)\\d|32|53)\\d{6}",[8,9],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[2356]|87"],"(0$1)"],["(\\d{3})(\\d{5,6})","$1 $2",["[89]"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["70"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["7"],"0$1"]],"0"],JP:["81","010","00[1-9]\\d{6,14}|[25-9]\\d{9}|(?:00|[1-9]\\d\\d)\\d{6}",[8,9,10,11,12,13,14,15,16,17],[["(\\d{3})(\\d{3})(\\d{3})","$1-$2-$3",["(?:12|57|99)0"],"0$1"],["(\\d{4})(\\d)(\\d{4})","$1-$2-$3",["1(?:26|3[79]|4[56]|5[4-68]|6[3-5])|499|5(?:76|97)|746|8(?:3[89]|47|51)|9(?:80|9[16])","1(?:267|3(?:7[247]|9[278])|466|5(?:47|58|64)|6(?:3[245]|48|5[4-68]))|499[2468]|5(?:76|97)9|7468|8(?:3(?:8[7-9]|96)|477|51[2-9])|9(?:802|9(?:1[23]|69))|1(?:45|58)[67]","1(?:267|3(?:7[247]|9[278])|466|5(?:47|58|64)|6(?:3[245]|48|5[4-68]))|499[2468]|5(?:769|979[2-69])|7468|8(?:3(?:8[7-9]|96[2457-9])|477|51[2-9])|9(?:802|9(?:1[23]|69))|1(?:45|58)[67]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["60"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1-$2-$3",["3|4(?:2[09]|7[01])|6[1-9]","3|4(?:2(?:0|9[02-69])|7(?:0[019]|1))|6[1-9]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["1(?:1|5[45]|77|88|9[69])|2(?:2[1-37]|3[0-269]|4[59]|5|6[24]|7[1-358]|8[1369]|9[0-38])|4(?:[28][1-9]|3[0-57]|[45]|6[248]|7[2-579]|9[29])|5(?:2|3[0459]|4[0-369]|5[29]|8[02389]|9[0-389])|7(?:2[02-46-9]|34|[58]|6[0249]|7[57]|9[2-6])|8(?:2[124589]|3[26-9]|49|51|6|7[0-468]|8[68]|9[019])|9(?:[23][1-9]|4[15]|5[138]|6[1-3]|7[156]|8[189]|9[1-489])","1(?:1|5(?:4[018]|5[017])|77|88|9[69])|2(?:2(?:[127]|3[014-9])|3[0-269]|4[59]|5(?:[1-3]|5[0-69]|9[19])|62|7(?:[1-35]|8[0189])|8(?:[16]|3[0134]|9[0-5])|9(?:[028]|17))|4(?:2(?:[13-79]|8[014-6])|3[0-57]|[45]|6[248]|7[2-47]|8[1-9]|9[29])|5(?:2|3(?:[045]|9[0-8])|4[0-369]|5[29]|8[02389]|9[0-3])|7(?:2[02-46-9]|34|[58]|6[0249]|7[57]|9(?:[23]|4[0-59]|5[01569]|6[0167]))|8(?:2(?:[1258]|4[0-39]|9[0-2469])|3(?:[29]|60)|49|51|6(?:[0-24]|36|5[0-3589]|7[23]|9[01459])|7[0-468]|8[68])|9(?:[23][1-9]|4[15]|5[138]|6[1-3]|7[156]|8[189]|9(?:[1289]|3[34]|4[0178]))|(?:264|837)[016-9]|2(?:57|93)[015-9]|(?:25[0468]|422|838)[01]|(?:47[59]|59[89]|8(?:6[68]|9))[019]","1(?:1|5(?:4[018]|5[017])|77|88|9[69])|2(?:2[127]|3[0-269]|4[59]|5(?:[1-3]|5[0-69]|9(?:17|99))|6(?:2|4[016-9])|7(?:[1-35]|8[0189])|8(?:[16]|3[0134]|9[0-5])|9(?:[028]|17))|4(?:2(?:[13-79]|8[014-6])|3[0-57]|[45]|6[248]|7[2-47]|9[29])|5(?:2|3(?:[045]|9(?:[0-58]|6[4-9]|7[0-35689]))|4[0-369]|5[29]|8[02389]|9[0-3])|7(?:2[02-46-9]|34|[58]|6[0249]|7[57]|9(?:[23]|4[0-59]|5[01569]|6[0167]))|8(?:2(?:[1258]|4[0-39]|9[0169])|3(?:[29]|60|7(?:[017-9]|6[6-8]))|49|51|6(?:[0-24]|36[2-57-9]|5(?:[0-389]|5[23])|6(?:[01]|9[178])|7(?:2[2-468]|3[78])|9[0145])|7[0-468]|8[68])|9(?:4[15]|5[138]|7[156]|8[189]|9(?:[1289]|3(?:31|4[357])|4[0178]))|(?:8294|96)[1-3]|2(?:57|93)[015-9]|(?:223|8699)[014-9]|(?:25[0468]|422|838)[01]|(?:48|8292|9[23])[1-9]|(?:47[59]|59[89]|8(?:68|9))[019]"],"0$1"],["(\\d{3})(\\d{2})(\\d{4})","$1-$2-$3",["[14]|[289][2-9]|5[3-9]|7[2-4679]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["800"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1-$2-$3",["[25-9]"],"0$1"]],"0",0,"(000[259]\\d{6})$|(?:(?:003768)0?)|0","$1"],KE:["254","000","(?:[17]\\d\\d|900)\\d{6}|(?:2|80)0\\d{6,7}|[4-6]\\d{6,8}",[7,8,9,10],[["(\\d{2})(\\d{5,7})","$1 $2",["[24-6]"],"0$1"],["(\\d{3})(\\d{6})","$1 $2",["[17]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["[89]"],"0$1"]],"0"],KG:["996","00","8\\d{9}|[235-9]\\d{8}",[9,10],[["(\\d{4})(\\d{5})","$1 $2",["3(?:1[346]|[24-79])"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[235-79]|88"],"0$1"],["(\\d{3})(\\d{3})(\\d)(\\d{2,3})","$1 $2 $3 $4",["8"],"0$1"]],"0"],KH:["855","00[14-9]","1\\d{9}|[1-9]\\d{7,8}",[8,9,10],[["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[1-9]"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1"]]],"0"],KI:["686","00","(?:[37]\\d|6[0-79])\\d{6}|(?:[2-48]\\d|50)\\d{3}",[5,8],0,"0"],KM:["269","00","[3478]\\d{6}",[7],[["(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",["[3478]"]]]],KN:["1","011","(?:[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-7]\\d{6})$|1","869$1",0,"869"],KP:["850","00|99","85\\d{6}|(?:19\\d|[2-7])\\d{7}",[8,10],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["8"],"0$1"],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[2-7]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["1"],"0$1"]],"0"],KR:["82","00(?:[125689]|3(?:[46]5|91)|7(?:00|27|3|55|6[126]))","00[1-9]\\d{8,11}|(?:[12]|5\\d{3})\\d{7}|[13-6]\\d{9}|(?:[1-6]\\d|80)\\d{7}|[3-6]\\d{4,5}|(?:00|7)0\\d{8}",[5,6,8,9,10,11,12,13,14],[["(\\d{2})(\\d{3,4})","$1-$2",["(?:3[1-3]|[46][1-4]|5[1-5])1"],"0$1"],["(\\d{4})(\\d{4})","$1-$2",["1"]],["(\\d)(\\d{3,4})(\\d{4})","$1-$2-$3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["[36]0|8"],"0$1"],["(\\d{2})(\\d{3,4})(\\d{4})","$1-$2-$3",["[1346]|5[1-5]"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1-$2-$3",["[57]"],"0$1"],["(\\d{2})(\\d{5})(\\d{4})","$1-$2-$3",["5"],"0$1"]],"0",0,"0(8(?:[1-46-8]|5\\d\\d))?"],KW:["965","00","18\\d{5}|(?:[2569]\\d|41)\\d{6}",[7,8],[["(\\d{4})(\\d{3,4})","$1 $2",["[169]|2(?:[235]|4[1-35-9])|52"]],["(\\d{3})(\\d{5})","$1 $2",["[245]"]]]],KY:["1","011","(?:345|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","345$1",0,"345"],KZ:["7","810","(?:33622|8\\d{8})\\d{5}|[78]\\d{9}",[10,14],0,"8",0,0,0,0,"33|7",0,"8~10"],LA:["856","00","[23]\\d{9}|3\\d{8}|(?:[235-8]\\d|41)\\d{6}",[8,9,10],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["2[13]|3[14]|[4-8]"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3 $4",["30[0135-9]"],"0$1"],["(\\d{2})(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3 $4",["[23]"],"0$1"]],"0"],LB:["961","00","[27-9]\\d{7}|[13-9]\\d{6}",[7,8],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[13-69]|7(?:[2-57]|62|8[0-7]|9[04-9])|8[02-9]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[27-9]"]]],"0"],LC:["1","011","(?:[58]\\d\\d|758|900)\\d{7}",[10],0,"1",0,"([2-8]\\d{6})$|1","758$1",0,"758"],LI:["423","00","[68]\\d{8}|(?:[2378]\\d|90)\\d{5}",[7,9],[["(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",["[2379]|8(?:0[09]|7)","[2379]|8(?:0(?:02|9)|7)"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["69"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["6"]]],"0",0,"(1001)|0"],LK:["94","00","[1-9]\\d{8}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["7"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[1-689]"],"0$1"]],"0"],LR:["231","00","(?:[245]\\d|33|77|88)\\d{7}|(?:2\\d|[4-6])\\d{6}",[7,8,9],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["4[67]|[56]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[2-578]"],"0$1"]],"0"],LS:["266","00","(?:[256]\\d\\d|800)\\d{5}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[2568]"]]]],LT:["370","00","(?:[3469]\\d|52|[78]0)\\d{6}",[8],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["52[0-7]"],"(0-$1)",1],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["[7-9]"],"0 $1",1],["(\\d{2})(\\d{6})","$1 $2",["37|4(?:[15]|6[1-8])"],"(0-$1)",1],["(\\d{3})(\\d{5})","$1 $2",["[3-6]"],"(0-$1)",1]],"0",0,"[08]"],LU:["352","00","35[013-9]\\d{4,8}|6\\d{8}|35\\d{2,4}|(?:[2457-9]\\d|3[0-46-9])\\d{2,9}",[4,5,6,7,8,9,10,11],[["(\\d{2})(\\d{3})","$1 $2",["2(?:0[2-689]|[2-9])|[3-57]|8(?:0[2-9]|[13-9])|9(?:0[89]|[2-579])"]],["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["2(?:0[2-689]|[2-9])|[3-57]|8(?:0[2-9]|[13-9])|9(?:0[89]|[2-579])"]],["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["20[2-689]"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{1,2})","$1 $2 $3 $4",["2(?:[0367]|4[3-8])"]],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["80[01]|90[015]"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3 $4",["20"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["6"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{1,2})","$1 $2 $3 $4 $5",["2(?:[0367]|4[3-8])"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{1,5})","$1 $2 $3 $4",["[3-57]|8[13-9]|9(?:0[89]|[2-579])|(?:2|80)[2-9]"]]],0,0,"(15(?:0[06]|1[12]|[35]5|4[04]|6[26]|77|88|99)\\d)"],LV:["371","00","(?:[268]\\d|90)\\d{6}",[8],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[269]|8[01]"]]]],LY:["218","00","[2-9]\\d{8}",[9],[["(\\d{2})(\\d{7})","$1-$2",["[2-9]"],"0$1"]],"0"],MA:["212","00","[5-8]\\d{8}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["5[45]"],"0$1"],["(\\d{4})(\\d{5})","$1-$2",["5(?:2[2-46-9]|3[3-9]|9)|8(?:0[89]|92)"],"0$1"],["(\\d{2})(\\d{7})","$1-$2",["8"],"0$1"],["(\\d{3})(\\d{6})","$1-$2",["[5-7]"],"0$1"]],"0",0,0,0,0,0,[["5(?:2(?:[0-25-79]\\d|3[1-578]|4[02-46-8]|8[0235-7])|3(?:[0-47]\\d|5[02-9]|6[02-8]|8[014-9]|9[3-9])|(?:4[067]|5[03])\\d)\\d{5}"],["(?:6(?:[0-79]\\d|8[0-247-9])|7(?:[0167]\\d|2[0-4]|5[01]|8[0-3]))\\d{6}"],["80[0-7]\\d{6}"],["89\\d{7}"],0,0,0,0,["(?:592(?:4[0-2]|93)|80[89]\\d\\d)\\d{4}"]]],MC:["377","00","(?:[3489]|6\\d)\\d{7}",[8,9],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["4"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[389]"]],["(\\d)(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["6"],"0$1"]],"0"],MD:["373","00","(?:[235-7]\\d|[89]0)\\d{6}",[8],[["(\\d{3})(\\d{5})","$1 $2",["[89]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["22|3"],"0$1"],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["[25-7]"],"0$1"]],"0"],ME:["382","00","(?:20|[3-79]\\d)\\d{6}|80\\d{6,7}",[8,9],[["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2-9]"],"0$1"]],"0"],MF:["590","00","(?:590\\d|7090)\\d{5}|(?:69|80|9\\d)\\d{7}",[9],0,"0",0,0,0,0,0,[["590(?:0[079]|[14]3|[27][79]|3[03-7]|5[0-268]|87)\\d{4}"],["(?:69(?:0\\d\\d|1(?:2[2-9]|3[0-5])|4(?:0[89]|1[2-6]|9\\d)|6(?:1[016-9]|5[0-4]|[67]\\d))|7090[0-4])\\d{4}"],["80[0-5]\\d{6}"],0,0,0,0,0,["9(?:(?:39[5-7]|76[018])\\d|475[0-5])\\d{4}"]]],MG:["261","00","[23]\\d{8}",[9],[["(\\d{2})(\\d{2})(\\d{3})(\\d{2})","$1 $2 $3 $4",["[23]"],"0$1"]],"0",0,"([24-9]\\d{6})$|0","20$1"],MH:["692","011","329\\d{4}|(?:[256]\\d|45)\\d{5}",[7],[["(\\d{3})(\\d{4})","$1-$2",["[2-6]"]]],"1"],MK:["389","00","[2-578]\\d{7}",[8],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["2|34[47]|4(?:[37]7|5[47]|64)"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[347]"],"0$1"],["(\\d{3})(\\d)(\\d{2})(\\d{2})","$1 $2 $3 $4",["[58]"],"0$1"]],"0"],ML:["223","00","[24-9]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[24-9]"]]]],MM:["95","00","1\\d{5,7}|95\\d{6}|(?:[4-7]|9[0-46-9])\\d{6,8}|(?:2|8\\d)\\d{5,8}",[6,7,8,9,10],[["(\\d)(\\d{2})(\\d{3})","$1 $2 $3",["16|2"],"0$1"],["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["4(?:[2-46]|5[3-5])|5|6(?:[1-689]|7[235-7])|7(?:[0-4]|5[2-7])|8[1-5]|(?:60|86)[23]"],"0$1"],["(\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["[12]|452|678|86","[12]|452|6788|86"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[4-7]|8[1-35]"],"0$1"],["(\\d)(\\d{3})(\\d{4,6})","$1 $2 $3",["9(?:2[0-4]|[35-9]|4[137-9])"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["2"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"],"0$1"],["(\\d)(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["92"],"0$1"],["(\\d)(\\d{5})(\\d{4})","$1 $2 $3",["9"],"0$1"]],"0"],MN:["976","001","[12]\\d{7,9}|[5-9]\\d{7}",[8,9,10],[["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["[12]1"],"0$1"],["(\\d{4})(\\d{4})","$1 $2",["[5-9]"]],["(\\d{3})(\\d{5,6})","$1 $2",["[12]2[1-3]"],"0$1"],["(\\d{4})(\\d{5,6})","$1 $2",["[12](?:27|3[2-8]|4[2-68]|5[1-4689])","[12](?:27|3[2-8]|4[2-68]|5[1-4689])[0-3]"],"0$1"],["(\\d{5})(\\d{4,5})","$1 $2",["[12]"],"0$1"]],"0"],MO:["853","00","0800\\d{3}|(?:28|[68]\\d)\\d{6}",[7,8],[["(\\d{4})(\\d{3})","$1 $2",["0"]],["(\\d{4})(\\d{4})","$1 $2",["[268]"]]]],MP:["1","011","[58]\\d{9}|(?:67|90)0\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","670$1",0,"670"],MQ:["596","00","(?:596\\d|7091)\\d{5}|(?:69|[89]\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-79]|8(?:0[6-9]|[36])"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0$1"]],"0"],MR:["222","00","(?:[2-4]\\d\\d|800)\\d{5}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-48]"]]]],MS:["1","011","(?:[58]\\d\\d|664|900)\\d{7}",[10],0,"1",0,"([34]\\d{6})$|1","664$1",0,"664"],MT:["356","00","3550\\d{4}|(?:[2579]\\d\\d|800)\\d{5}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[2357-9]"]]]],MU:["230","0(?:0|[24-7]0|3[03])","(?:[57]|8\\d\\d)\\d{7}|[2-468]\\d{6}",[7,8,10],[["(\\d{3})(\\d{4})","$1 $2",["[2-46]|8[013]"]],["(\\d{4})(\\d{4})","$1 $2",["[57]"]],["(\\d{5})(\\d{5})","$1 $2",["8"]]],0,0,0,0,0,0,0,"020"],MV:["960","0(?:0|19)","(?:800|9[0-57-9]\\d)\\d{7}|[34679]\\d{6}",[7,10],[["(\\d{3})(\\d{4})","$1-$2",["[34679]"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[89]"]]],0,0,0,0,0,0,0,"00"],MW:["265","00","(?:[1289]\\d|31|77)\\d{7}|1\\d{6}",[7,9],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["1[2-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["2"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[137-9]"],"0$1"]],"0"],MX:["52","0[09]","[2-9]\\d{9}",[10],[["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["33|5[56]|81"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[2-9]"]]],0,0,0,0,0,0,0,"00"],MY:["60","00","1\\d{8,9}|(?:3\\d|[4-9])\\d{7}",[8,9,10],[["(\\d)(\\d{3})(\\d{4})","$1-$2 $3",["[4-79]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1-$2 $3",["1(?:[02469]|[378][1-9]|53)|8","1(?:[02469]|[37][1-9]|53|8(?:[1-46-9]|5[7-9]))|8"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1-$2 $3",["3"],"0$1"],["(\\d)(\\d{3})(\\d{2})(\\d{4})","$1-$2-$3-$4",["1(?:[367]|80)"]],["(\\d{3})(\\d{3})(\\d{4})","$1-$2 $3",["15"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1-$2 $3",["1"],"0$1"]],"0"],MZ:["258","00","(?:2|8\\d)\\d{7}",[8,9],[["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["2|8[2-79]"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8"]]]],NA:["264","00","[68]\\d{7,8}",[8,9],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["88"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["6"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["87"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["8"],"0$1"]],"0"],NC:["687","00","(?:050|[2-57-9]\\d\\d)\\d{3}",[6],[["(\\d{2})(\\d{2})(\\d{2})","$1.$2.$3",["[02-57-9]"]]]],NE:["227","00","[027-9]\\d{7}",[8],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["08"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[089]|2[013]|7[0467]"]]]],NF:["672","00","[13]\\d{5}",[6],[["(\\d{2})(\\d{4})","$1 $2",["1[0-3]"]],["(\\d)(\\d{5})","$1 $2",["[13]"]]],0,0,"([0-258]\\d{4})$","3$1"],NG:["234","009","38\\d{6}|[78]\\d{9,13}|(?:20|9\\d)\\d{8}",[8,10,11,12,13,14],[["(\\d{2})(\\d{3})(\\d{2,3})","$1 $2 $3",["3"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["[7-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["20[129]"],"0$1"],["(\\d{4})(\\d{2})(\\d{4})","$1 $2 $3",["2"],"0$1"],["(\\d{3})(\\d{4})(\\d{4,5})","$1 $2 $3",["[78]"],"0$1"],["(\\d{3})(\\d{5})(\\d{5,6})","$1 $2 $3",["[78]"],"0$1"]],"0"],NI:["505","00","(?:1800|[25-8]\\d{3})\\d{4}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[125-8]"]]]],NL:["31","00","(?:[124-7]\\d\\d|3(?:[02-9]\\d|1[0-8]))\\d{6}|8\\d{6,9}|9\\d{6,10}|1\\d{4,5}",[5,6,7,8,9,10,11],[["(\\d{3})(\\d{4,7})","$1 $2",["[89]0"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["66"],"0$1"],["(\\d)(\\d{8})","$1 $2",["6"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["1[16-8]|2[259]|3[124]|4[17-9]|5[124679]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[1-578]|91"],"0$1"],["(\\d{3})(\\d{3})(\\d{5})","$1 $2 $3",["9"],"0$1"]],"0"],NO:["47","00","(?:0|[2-9]\\d{3})\\d{4}",[5,8],[["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["8"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-79]"]]],0,0,0,0,0,"[02-689]|7[0-8]"],NP:["977","00","(?:1\\d|9)\\d{9}|[1-9]\\d{7}",[8,10,11],[["(\\d)(\\d{7})","$1-$2",["1[2-6]"],"0$1"],["(\\d{2})(\\d{6})","$1-$2",["1[01]|[2-8]|9(?:[1-59]|[67][2-6])"],"0$1"],["(\\d{3})(\\d{7})","$1-$2",["9"]]],"0"],NR:["674","00","(?:444|(?:55|8\\d)\\d|666)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[4-68]"]]]],NU:["683","00","(?:[4-7]|888\\d)\\d{3}",[4,7],[["(\\d{3})(\\d{4})","$1 $2",["8"]]]],NZ:["64","0(?:0|161)","[1289]\\d{9}|50\\d{5}(?:\\d{2,3})?|[27-9]\\d{7,8}|(?:[34]\\d|6[0-35-9])\\d{6}|8\\d{4,6}",[5,6,7,8,9,10],[["(\\d{2})(\\d{3,8})","$1 $2",["8[1-79]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2,3})","$1 $2 $3",["50[036-8]|8|90","50(?:[0367]|88)|8|90"],"0$1"],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["24|[346]|7[2-57-9]|9[2-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["2(?:10|74)|[589]"],"0$1"],["(\\d{2})(\\d{3,4})(\\d{4})","$1 $2 $3",["1|2[028]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,5})","$1 $2 $3",["2(?:[169]|7[0-35-9])|7"],"0$1"]],"0",0,0,0,0,0,0,"00"],OM:["968","00","(?:1505|[279]\\d{3}|500)\\d{4}|800\\d{5,6}",[7,8,9],[["(\\d{3})(\\d{4,6})","$1 $2",["[58]"]],["(\\d{2})(\\d{6})","$1 $2",["2"]],["(\\d{4})(\\d{4})","$1 $2",["[179]"]]]],PA:["507","00","(?:00800|8\\d{3})\\d{6}|[68]\\d{7}|[1-57-9]\\d{6}",[7,8,10,11],[["(\\d{3})(\\d{4})","$1-$2",["[1-57-9]"]],["(\\d{4})(\\d{4})","$1-$2",["[68]"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"]]]],PE:["51","00|19(?:1[124]|77|90)00","(?:[14-8]|9\\d)\\d{7}",[8,9],[["(\\d{3})(\\d{5})","$1 $2",["80"],"(0$1)"],["(\\d)(\\d{7})","$1 $2",["1"],"(0$1)"],["(\\d{2})(\\d{6})","$1 $2",["[4-8]"],"(0$1)"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["9"]]],"0",0,0,0,0,0,0,"00"," Anexo "],PF:["689","00","4\\d{5}(?:\\d{2})?|8\\d{7,8}",[6,8,9],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["44"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["4|8[7-9]"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"]]]],PG:["675","00|140[1-3]","(?:180|[78]\\d{3})\\d{4}|(?:[2-589]\\d|64)\\d{5}",[7,8],[["(\\d{3})(\\d{4})","$1 $2",["18|[2-69]|85"]],["(\\d{4})(\\d{4})","$1 $2",["[78]"]]],0,0,0,0,0,0,0,"00"],PH:["63","00","(?:[2-7]|9\\d)\\d{8}|2\\d{5}|(?:1800|8)\\d{7,9}",[6,8,9,10,11,12,13],[["(\\d)(\\d{5})","$1 $2",["2"],"(0$1)"],["(\\d{4})(\\d{4,6})","$1 $2",["3(?:23|39|46)|4(?:2[3-6]|[35]9|4[26]|76)|544|88[245]|(?:52|64|86)2","3(?:230|397|461)|4(?:2(?:35|[46]4|51)|396|4(?:22|63)|59[347]|76[15])|5(?:221|446)|642[23]|8(?:622|8(?:[24]2|5[13]))"],"(0$1)"],["(\\d{5})(\\d{4})","$1 $2",["346|4(?:27|9[35])|883","3469|4(?:279|9(?:30|56))|8834"],"(0$1)"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["2"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[3-7]|8[2-8]"],"(0$1)"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[89]"],"0$1"],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["1"]],["(\\d{4})(\\d{1,2})(\\d{3})(\\d{4})","$1 $2 $3 $4",["1"]]],"0"],PK:["92","00","122\\d{6}|[24-8]\\d{10,11}|9(?:[013-9]\\d{8,10}|2(?:[01]\\d\\d|2(?:[06-8]\\d|1[01]))\\d{7})|(?:[2-8]\\d{3}|92(?:[0-7]\\d|8[1-9]))\\d{6}|[24-9]\\d{8}|[89]\\d{7}",[8,9,10,11,12],[["(\\d{3})(\\d{3})(\\d{2,7})","$1 $2 $3",["[89]0"],"0$1"],["(\\d{4})(\\d{5})","$1 $2",["1"]],["(\\d{3})(\\d{6,7})","$1 $2",["2(?:3[2358]|4[2-4]|9[2-8])|45[3479]|54[2-467]|60[468]|72[236]|8(?:2[2-689]|3[23578]|4[3478]|5[2356])|9(?:2[2-8]|3[27-9]|4[2-6]|6[3569]|9[25-8])","9(?:2[3-8]|98)|(?:2(?:3[2358]|4[2-4]|9[2-8])|45[3479]|54[2-467]|60[468]|72[236]|8(?:2[2-689]|3[23578]|4[3478]|5[2356])|9(?:22|3[27-9]|4[2-6]|6[3569]|9[25-7]))[2-9]"],"(0$1)"],["(\\d{2})(\\d{7,8})","$1 $2",["(?:2[125]|4[0-246-9]|5[1-35-7]|6[1-8]|7[14]|8[16]|91)[2-9]"],"(0$1)"],["(\\d{5})(\\d{5})","$1 $2",["58"],"(0$1)"],["(\\d{3})(\\d{7})","$1 $2",["3"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["2[125]|4[0-246-9]|5[1-35-7]|6[1-8]|7[14]|8[16]|91"],"(0$1)"],["(\\d{3})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["[24-9]"],"(0$1)"]],"0"],PL:["48","00","(?:6|8\\d\\d)\\d{7}|[1-9]\\d{6}(?:\\d{2})?|[26]\\d{5}",[6,7,8,9,10],[["(\\d{5})","$1",["19"]],["(\\d{3})(\\d{3})","$1 $2",["11|20|64"]],["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["(?:1[2-8]|2[2-69]|3[2-4]|4[1-468]|5[24-689]|6[1-3578]|7[14-7]|8[1-79]|9[145])1","(?:1[2-8]|2[2-69]|3[2-4]|4[1-468]|5[24-689]|6[1-3578]|7[14-7]|8[1-79]|9[145])19"]],["(\\d{3})(\\d{2})(\\d{2,3})","$1 $2 $3",["64"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["21|39|45|5[0137]|6[0469]|7[02389]|8(?:0[14]|8)"]],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["1[2-8]|[2-7]|8[1-79]|9[145]"]],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["8"]]]],PM:["508","00","[45]\\d{5}|(?:708|8\\d\\d)\\d{6}",[6,9],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["[45]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["7"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0$1"]],"0"],PR:["1","011","(?:[589]\\d\\d|787)\\d{7}",[10],0,"1",0,0,0,0,"787|939"],PS:["970","00","[2489]2\\d{6}|(?:1\\d|5)\\d{8}",[8,9,10],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[2489]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["5"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1"]]],"0"],PT:["351","00","1693\\d{5}|(?:[26-9]\\d|30)\\d{7}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["2[12]"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["16|[236-9]"]]]],PW:["680","01[12]","(?:[24-8]\\d\\d|345|900)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[2-9]"]]]],PY:["595","00","59\\d{4,6}|9\\d{5,10}|(?:[2-46-8]\\d|5[0-8])\\d{4,7}",[6,7,8,9,10,11],[["(\\d{3})(\\d{3,6})","$1 $2",["[2-9]0"],"0$1"],["(\\d{2})(\\d{5})","$1 $2",["[26]1|3[289]|4[1246-8]|7[1-3]|8[1-36]"],"(0$1)"],["(\\d{3})(\\d{4,5})","$1 $2",["2[279]|3[13-5]|4[359]|5|6(?:[34]|7[1-46-8])|7[46-8]|85"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["2[14-68]|3[26-9]|4[1246-8]|6(?:1|75)|7[1-35]|8[1-36]"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["87"]],["(\\d{3})(\\d{6})","$1 $2",["9(?:[5-79]|8[1-7])"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[2-8]"],"0$1"],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["9"]]],"0"],QA:["974","00","800\\d{4}|(?:2|800)\\d{6}|(?:0080|[3-7])\\d{7}",[7,8,9,11],[["(\\d{3})(\\d{4})","$1 $2",["2[16]|8"]],["(\\d{4})(\\d{4})","$1 $2",["[3-7]"]]]],RE:["262","00","709\\d{6}|(?:26|[689]\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[26-9]"],"0$1"]],"0",0,0,0,0,0,[["26(?:2\\d\\d|3(?:0\\d|1[0-6]))\\d{4}"],["(?:69(?:2\\d\\d|3(?:[06][0-6]|1[013]|2[0-2]|3[0-39]|4\\d|5[0-5]|7[0-37]|8[0-8]|9[0-479]))|7092[0-3])\\d{4}"],["80\\d{7}"],["89[1-37-9]\\d{6}"],0,0,0,0,["9(?:399[0-3]|479[0-5]|76(?:2[278]|3[0-37]))\\d{4}"],["8(?:1[019]|2[0156]|84|90)\\d{6}"]]],RO:["40","00","(?:[236-8]\\d|90)\\d{7}|[23]\\d{5}",[6,9],[["(\\d{3})(\\d{3})","$1 $2",["2[3-6]","2[3-6]\\d9"],"0$1"],["(\\d{2})(\\d{4})","$1 $2",["219|31"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[23]1"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[236-9]"],"0$1"]],"0",0,0,0,0,0,0,0," int "],RS:["381","00","38[02-9]\\d{6,9}|6\\d{7,9}|90\\d{4,8}|38\\d{5,6}|(?:7\\d\\d|800)\\d{3,9}|(?:[12]\\d|3[0-79])\\d{5,10}",[6,7,8,9,10,11,12],[["(\\d{3})(\\d{3,9})","$1 $2",["(?:2[389]|39)0|[7-9]"],"0$1"],["(\\d{2})(\\d{5,10})","$1 $2",["[1-36]"],"0$1"]],"0"],RU:["7","810","8\\d{13}|[347-9]\\d{9}",[10,14],[["(\\d{4})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["7(?:1[0-8]|2[1-9])","7(?:1(?:[0-356]2|4[29]|7|8[27])|2(?:1[23]|[2-9]2))","7(?:1(?:[0-356]2|4[29]|7|8[27])|2(?:13[03-69]|62[013-9]))|72[1-57-9]2"],"8 ($1)",1],["(\\d{5})(\\d)(\\d{2})(\\d{2})","$1 $2 $3 $4",["7(?:1[0-68]|2[1-9])","7(?:1(?:[06][3-6]|[18]|2[35]|[3-5][3-5])|2(?:[13][3-5]|[24-689]|7[457]))","7(?:1(?:0(?:[356]|4[023])|[18]|2(?:3[013-9]|5)|3[45]|43[013-79]|5(?:3[1-8]|4[1-7]|5)|6(?:3[0-35-9]|[4-6]))|2(?:1(?:3[178]|[45])|[24-689]|3[35]|7[457]))|7(?:14|23)4[0-8]|71(?:33|45)[1-79]"],"8 ($1)",1],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["7"],"8 ($1)",1],["(\\d{3})(\\d{3})(\\d{2})(\\d{2})","$1 $2-$3-$4",["[349]|8(?:[02-7]|1[1-8])"],"8 ($1)",1],["(\\d{4})(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3 $4",["8"],"8 ($1)"]],"8",0,0,0,0,"3[04-689]|[489]",0,"8~10"],RW:["250","00","(?:06|[27]\\d\\d|[89]00)\\d{6}",[8,9],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["0"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["2"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[7-9]"],"0$1"]],"0"],SA:["966","00","92\\d{7}|(?:[15]|8\\d)\\d{8}",[9,10],[["(\\d{4})(\\d{5})","$1 $2",["9"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["1"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["5"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["81"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"]]],"0"],SB:["677","0[01]","[6-9]\\d{6}|[1-6]\\d{4}",[5,7],[["(\\d{2})(\\d{5})","$1 $2",["6[89]|7|8[4-9]|9(?:[1-8]|9[0-8])"]]]],SC:["248","010|0[0-2]","(?:[2489]\\d|64)\\d{5}",[7],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[246]|9[57]"]]],0,0,0,0,0,0,0,"00"],SD:["249","00","[19]\\d{8}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[19]"],"0$1"]],"0"],SE:["46","00","(?:[26]\\d\\d|9)\\d{9}|[1-9]\\d{8}|[1-689]\\d{7}|[1-4689]\\d{6}|2\\d{5}",[6,7,8,9,10,12],[["(\\d{2})(\\d{2,3})(\\d{2})","$1-$2 $3",["20"],"0$1",0,"$1 $2 $3"],["(\\d{3})(\\d{4})","$1-$2",["9(?:00|39|44|9)"],"0$1",0,"$1 $2"],["(\\d{2})(\\d{3})(\\d{2})","$1-$2 $3",["[12][136]|3[356]|4[0246]|6[03]|90[1-9]"],"0$1",0,"$1 $2 $3"],["(\\d)(\\d{2,3})(\\d{2})(\\d{2})","$1-$2 $3 $4",["8"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2,3})(\\d{2})","$1-$2 $3",["1[2457]|2(?:[247-9]|5[0138])|3[0247-9]|4[1357-9]|5[0-35-9]|6(?:[125689]|4[02-57]|7[0-2])|9(?:[125-8]|3[02-5]|4[0-3])"],"0$1",0,"$1 $2 $3"],["(\\d{3})(\\d{2,3})(\\d{3})","$1-$2 $3",["9(?:00|39|44)"],"0$1",0,"$1 $2 $3"],["(\\d{2})(\\d{2,3})(\\d{2})(\\d{2})","$1-$2 $3 $4",["1[13689]|2[0136]|3[1356]|4[0246]|54|6[03]|90[1-9]"],"0$1",0,"$1 $2 $3 $4"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1-$2 $3 $4",["10|7"],"0$1",0,"$1 $2 $3 $4"],["(\\d)(\\d{3})(\\d{3})(\\d{2})","$1-$2 $3 $4",["8"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1-$2 $3 $4",["[13-5]|2(?:[247-9]|5[0138])|6(?:[124-689]|7[0-2])|9(?:[125-8]|3[02-5]|4[0-3])"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2})(\\d{2})(\\d{3})","$1-$2 $3 $4",["9"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1-$2 $3 $4 $5",["[26]"],"0$1",0,"$1 $2 $3 $4 $5"]],"0"],SG:["65","0[0-3]\\d","(?:(?:1\\d|8)\\d\\d|7000)\\d{7}|[3689]\\d{7}",[8,10,11],[["(\\d{4})(\\d{4})","$1 $2",["[369]|8(?:0[1-9]|[1-9])"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"]],["(\\d{4})(\\d{4})(\\d{3})","$1 $2 $3",["7"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["1"]]]],SH:["290","00","(?:[256]\\d|8)\\d{3}",[4,5],0,0,0,0,0,0,"[256]"],SI:["386","00|10(?:22|66|88|99)","[1-7]\\d{7}|8\\d{4,7}|90\\d{4,6}",[5,6,7,8],[["(\\d{2})(\\d{3,6})","$1 $2",["8[09]|9"],"0$1"],["(\\d{3})(\\d{5})","$1 $2",["59|8"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[37][01]|4[0139]|51|6"],"0$1"],["(\\d)(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[1-57]"],"(0$1)"]],"0",0,0,0,0,0,0,"00"],SJ:["47","00","0\\d{4}|(?:[489]\\d|79)\\d{6}",[5,8],0,0,0,0,0,0,"79"],SK:["421","00","[2-689]\\d{8}|[2-59]\\d{6}|[2-5]\\d{5}",[6,7,9],[["(\\d)(\\d{2})(\\d{3,4})","$1 $2 $3",["21"],"0$1"],["(\\d{2})(\\d{2})(\\d{2,3})","$1 $2 $3",["[3-5][1-8]1","[3-5][1-8]1[67]"],"0$1"],["(\\d)(\\d{3})(\\d{3})(\\d{2})","$1/$2 $3 $4",["2"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[689]"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1/$2 $3 $4",["[3-5]"],"0$1"]],"0"],SL:["232","00","(?:[237-9]\\d|66)\\d{6}",[8],[["(\\d{2})(\\d{6})","$1 $2",["[236-9]"],"(0$1)"]],"0"],SM:["378","00","(?:0549|[5-7]\\d)\\d{6}",[8,10],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-7]"]],["(\\d{4})(\\d{6})","$1 $2",["0"]]],0,0,"([89]\\d{5})$","0549$1"],SN:["221","00","(?:[378]\\d|93)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"]],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[379]"]]]],SO:["252","00","[346-9]\\d{8}|[12679]\\d{7}|[1-5]\\d{6}|[1348]\\d{5}",[6,7,8,9],[["(\\d{2})(\\d{4})","$1 $2",["8[125]"]],["(\\d{6})","$1",["[134]"]],["(\\d)(\\d{6})","$1 $2",["[15]|2[0-79]|3[0-46-8]|4[0-7]"]],["(\\d)(\\d{7})","$1 $2",["(?:2|90)4|[67]"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[348]|64|79|90"]],["(\\d{2})(\\d{5,7})","$1 $2",["1|28|6[0-35-9]|77|9[2-9]"]]],"0"],SR:["597","00","(?:[2-5]|68|[78]\\d)\\d{5}",[6,7],[["(\\d{2})(\\d{2})(\\d{2})","$1-$2-$3",["56"]],["(\\d{3})(\\d{3})","$1-$2",["[2-5]"]],["(\\d{3})(\\d{4})","$1-$2",["[6-8]"]]]],SS:["211","00","[19]\\d{8}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[19]"],"0$1"]],"0"],ST:["239","00","(?:22|9\\d)\\d{5}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[29]"]]]],SV:["503","00","[267]\\d{7}|(?:80\\d|900)\\d{4}(?:\\d{4})?",[7,8,11],[["(\\d{3})(\\d{4})","$1 $2",["[89]"]],["(\\d{4})(\\d{4})","$1 $2",["[267]"]],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["[89]"]]]],SX:["1","011","7215\\d{6}|(?:[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"(5\\d{6})$|1","721$1",0,"721"],SY:["963","00","[1-359]\\d{8}|[1-5]\\d{7}",[8,9],[["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[1-4]|5[1-3]"],"0$1",1],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[59]"],"0$1",1]],"0"],SZ:["268","00","0800\\d{4}|(?:[237]\\d|900)\\d{6}",[8,9],[["(\\d{4})(\\d{4})","$1 $2",["[0237]"]],["(\\d{5})(\\d{4})","$1 $2",["9"]]]],TA:["290","00","8\\d{3}",[4],0,0,0,0,0,0,"8"],TC:["1","011","(?:[58]\\d\\d|649|900)\\d{7}",[10],0,"1",0,"([2-479]\\d{6})$|1","649$1",0,"649"],TD:["235","00|16","(?:22|[689]\\d|77)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[26-9]"]]],0,0,0,0,0,0,0,"00"],TG:["228","00","[279]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[279]"]]]],TH:["66","00[1-9]","(?:001800|[2-57]|[689]\\d)\\d{7}|1\\d{7,9}",[8,9,10,13],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[13-9]"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1"]]],"0"],TJ:["992","810","[0-57-9]\\d{8}",[9],[["(\\d{6})(\\d)(\\d{2})","$1 $2 $3",["331","3317"]],["(\\d{3})(\\d{2})(\\d{4})","$1 $2 $3",["44[02-479]|[34]7"]],["(\\d{4})(\\d)(\\d{4})","$1 $2 $3",["3(?:[1245]|3[12])"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[0-57-9]"]]],0,0,0,0,0,0,0,"8~10"],TK:["690","00","[2-47]\\d{3,6}",[4,5,6,7]],TL:["670","00","7\\d{7}|(?:[2-47]\\d|[89]0)\\d{5}",[7,8],[["(\\d{3})(\\d{4})","$1 $2",["[2-489]|70"]],["(\\d{4})(\\d{4})","$1 $2",["7"]]]],TM:["993","810","(?:[1-6]\\d|71)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2-$3-$4",["12"],"(8 $1)"],["(\\d{3})(\\d)(\\d{2})(\\d{2})","$1 $2-$3-$4",["[1-5]"],"(8 $1)"],["(\\d{2})(\\d{6})","$1 $2",["[67]"],"8 $1"]],"8",0,0,0,0,0,0,"8~10"],TN:["216","00","[2-57-9]\\d{7}",[8],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[2-57-9]"]]]],TO:["676","00","(?:0800|(?:[5-8]\\d\\d|999)\\d)\\d{3}|[2-8]\\d{4}",[5,7],[["(\\d{2})(\\d{3})","$1-$2",["[2-4]|50|6[09]|7[0-24-69]|8[05]"]],["(\\d{4})(\\d{3})","$1 $2",["0"]],["(\\d{3})(\\d{4})","$1 $2",["[5-9]"]]]],TR:["90","00","4\\d{6}|8\\d{11,12}|(?:[2-58]\\d\\d|900)\\d{7}",[7,10,12,13],[["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["512|8[01589]|90"],"0$1",1],["(\\d{3})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["5(?:[0-59]|61)","5(?:[0-59]|61[06])","5(?:[0-59]|61[06]1)"],"0$1",1],["(\\d{3})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[24][1-8]|3[1-9]"],"(0$1)",1],["(\\d{3})(\\d{3})(\\d{6,7})","$1 $2 $3",["80"],"0$1",1]],"0"],TT:["1","011","(?:[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-46-8]\\d{6})$|1","868$1",0,"868"],TV:["688","00","(?:2|7\\d\\d|90)\\d{4}",[5,6,7],[["(\\d{2})(\\d{3})","$1 $2",["2"]],["(\\d{2})(\\d{4})","$1 $2",["90"]],["(\\d{2})(\\d{5})","$1 $2",["7"]]]],TW:["886","0(?:0[25-79]|19)","[2-689]\\d{8}|7\\d{9,10}|[2-8]\\d{7}|2\\d{6}",[7,8,9,10,11],[["(\\d{2})(\\d)(\\d{4})","$1 $2 $3",["202"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[258]0"],"0$1"],["(\\d)(\\d{3,4})(\\d{4})","$1 $2 $3",["[23568]|4(?:0[02-48]|[1-47-9])|7[1-9]","[23568]|4(?:0[2-48]|[1-47-9])|(?:400|7)[1-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[49]"],"0$1"],["(\\d{2})(\\d{4})(\\d{4,5})","$1 $2 $3",["7"],"0$1"]],"0",0,0,0,0,0,0,0,"#"],TZ:["255","00[056]","(?:[25-8]\\d|41|90)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{4})","$1 $2 $3",["[89]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[24]"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["5"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[67]"],"0$1"]],"0"],UA:["380","00","[89]\\d{9}|[3-9]\\d{8}",[9,10],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["6[12][29]|(?:3[1-8]|4[136-8]|5[12457]|6[49])2|(?:56|65)[24]","6[12][29]|(?:35|4[1378]|5[12457]|6[49])2|(?:56|65)[24]|(?:3[1-46-8]|46)2[013-9]"],"0$1"],["(\\d{4})(\\d{5})","$1 $2",["3[1-8]|4(?:[1367]|[45][6-9]|8[4-6])|5(?:[1-5]|6[0135689]|7[4-6])|6(?:[12][3-7]|[459])","3[1-8]|4(?:[1367]|[45][6-9]|8[4-6])|5(?:[1-5]|6(?:[015689]|3[02389])|7[4-6])|6(?:[12][3-7]|[459])"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[3-7]|89|9[1-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["[89]"],"0$1"]],"0",0,0,0,0,0,0,"0~0"],UG:["256","00[057]","800\\d{6}|(?:[29]0|[347]\\d)\\d{7}",[9],[["(\\d{4})(\\d{5})","$1 $2",["202","2024"],"0$1"],["(\\d{3})(\\d{6})","$1 $2",["[27-9]|4(?:6[45]|[7-9])"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["[34]"],"0$1"]],"0"],US:["1","011","[2-9]\\d{9}|3\\d{6}",[10],[["(\\d{3})(\\d{4})","$1-$2",["310"],0,1],["(\\d{3})(\\d{3})(\\d{4})","($1) $2-$3",["[2-9]"],0,1,"$1-$2-$3"]],"1",0,0,0,0,0,[["(?:3052(?:0[0-8]|[1-9]\\d)|5056(?:[0-35-9]\\d|4[468]))\\d{4}|(?:305[3-9]|472[24]|505[2-57-9]|983[2-47-9])\\d{6}|(?:2(?:0[1-35-9]|1[02-9]|2[03-57-9]|3[1459]|4[08]|5[1-46]|6[0279]|7[0269]|8[13])|3(?:0[1-47-9]|1[02-9]|2[0135-79]|3[0-24679]|4[167]|5[0-2]|6[01349]|8[056])|4(?:0[124-9]|1[02-579]|2[3-5]|3[0245]|4[023578]|58|6[349]|7[0589]|8[04])|5(?:0[1-47-9]|1[0235-8]|20|3[0149]|4[01]|5[179]|6[1-47]|7[0-5]|8[0256])|6(?:0[1-35-9]|1[024-9]|2[03689]|3[016]|4[0156]|5[01679]|6[0-279]|78|8[0-29])|7(?:0[1-46-8]|1[2-9]|2[04-8]|3[0-247]|4[037]|5[47]|6[02359]|7[0-59]|8[156])|8(?:0[1-68]|1[02-8]|2[068]|3[0-2589]|4[03578]|5[046-9]|6[02-5]|7[028])|9(?:0[1346-9]|1[02-9]|2[0589]|3[0146-8]|4[01357-9]|5[12469]|7[0-389]|8[04-69]))[2-9]\\d{6}"],[""],["8(?:00|33|44|55|66|77|88)[2-9]\\d{6}"],["900[2-9]\\d{6}"],["52(?:3(?:[2-46-9][02-9]\\d|5(?:[02-46-9]\\d|5[0-46-9]))|4(?:[2-478][02-9]\\d|5(?:[034]\\d|2[024-9]|5[0-46-9])|6(?:0[1-9]|[2-9]\\d)|9(?:[05-9]\\d|2[0-5]|49)))\\d{4}|52[34][2-9]1[02-9]\\d{4}|5(?:00|2[125-9]|33|44|66|77|88)[2-9]\\d{6}"],0,0,0,["305209\\d{4}"]]],UY:["598","0(?:0|1[3-9]\\d)","0004\\d{2,9}|[1249]\\d{7}|(?:[49]\\d|80)\\d{5}",[6,7,8,9,10,11,12,13],[["(\\d{3})(\\d{3,4})","$1 $2",["0"]],["(\\d{3})(\\d{4})","$1 $2",["[49]0|8"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["9"],"0$1"],["(\\d{4})(\\d{4})","$1 $2",["[124]"]],["(\\d{3})(\\d{3})(\\d{2,4})","$1 $2 $3",["0"]],["(\\d{3})(\\d{3})(\\d{3})(\\d{2,4})","$1 $2 $3 $4",["0"]]],"0",0,0,0,0,0,0,"00"," int. "],UZ:["998","00","(?:20|33|[5-9]\\d)\\d{7}",[9],[["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[235-9]"]]]],VA:["39","00","0\\d{5,10}|3[0-8]\\d{7,10}|55\\d{8}|8\\d{5}(?:\\d{2,4})?|(?:1\\d|39)\\d{7,8}",[6,7,8,9,10,11,12],0,0,0,0,0,0,"06698"],VC:["1","011","(?:[58]\\d\\d|784|900)\\d{7}",[10],0,"1",0,"([2-7]\\d{6})$|1","784$1",0,"784"],VE:["58","00","[68]00\\d{7}|(?:[24]\\d|[59]0)\\d{8}",[10],[["(\\d{3})(\\d{7})","$1-$2",["[24-689]"],"0$1"]],"0"],VG:["1","011","(?:284|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-578]\\d{6})$|1","284$1",0,"284"],VI:["1","011","[58]\\d{9}|(?:34|90)0\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","340$1",0,"340"],VN:["84","00","[12]\\d{9}|[135-9]\\d{8}|[16]\\d{7}|[16-8]\\d{6}",[7,8,9,10],[["(\\d{2})(\\d{5})","$1 $2",["80"],"0$1",1],["(\\d{4})(\\d{4,6})","$1 $2",["1"],0,1],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["6"],"0$1",1],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[357-9]"],"0$1",1],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["2[48]"],"0$1",1],["(\\d{3})(\\d{4})(\\d{3})","$1 $2 $3",["2"],"0$1",1]],"0"],VU:["678","00","[57-9]\\d{6}|(?:[238]\\d|48)\\d{3}",[5,7],[["(\\d{3})(\\d{4})","$1 $2",["[57-9]"]]]],WF:["681","00","(?:40|72|8\\d{4})\\d{4}|[89]\\d{5}",[6,9],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["[47-9]"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"]]]],WS:["685","0","(?:[2-6]|8\\d{5})\\d{4}|[78]\\d{6}|[68]\\d{5}",[5,6,7,10],[["(\\d{5})","$1",["[2-5]|6[1-9]"]],["(\\d{3})(\\d{3,7})","$1 $2",["[68]"]],["(\\d{2})(\\d{5})","$1 $2",["7"]]]],XK:["383","00","2\\d{7,8}|3\\d{7,11}|(?:4\\d\\d|[89]00)\\d{5}",[8,9,10,11,12],[["(\\d{3})(\\d{5})","$1 $2",["[89]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[2-4]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["2|39"],"0$1"],["(\\d{2})(\\d{7,10})","$1 $2",["3"],"0$1"]],"0"],YE:["967","00","(?:1|7\\d)\\d{7}|[1-7]\\d{6}",[7,8,9],[["(\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["[1-6]|7(?:[24-6]|8[0-7])"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["7"],"0$1"]],"0"],YT:["262","00","7093\\d{5}|(?:80|9\\d)\\d{7}|(?:26|63)9\\d{6}",[9],0,"0",0,0,0,0,0,[["269(?:0[0-467]|15|5[0-4]|6\\d|[78]0)\\d{4}"],["(?:639(?:0[0-79]|1[019]|[267]\\d|3[09]|40|5[05-9]|9[04-79])|7093[5-7])\\d{4}"],["80\\d{7}"],0,0,0,0,0,["9(?:(?:39|47)8[01]|769\\d)\\d{4}"]]],ZA:["27","00","[1-79]\\d{8}|8\\d{4,9}",[5,6,7,8,9,10],[["(\\d{2})(\\d{3,4})","$1 $2",["8[1-4]"],"0$1"],["(\\d{2})(\\d{3})(\\d{2,3})","$1 $2 $3",["8[1-4]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["860"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[1-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"],"0$1"]],"0"],ZM:["260","00","800\\d{6}|(?:21|63|[79]\\d)\\d{7}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[28]"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["[79]"],"0$1"]],"0"],ZW:["263","00","2(?:[0-57-9]\\d{6,8}|6[0-24-9]\\d{6,7})|[38]\\d{9}|[35-8]\\d{8}|[3-6]\\d{7}|[1-689]\\d{6}|[1-3569]\\d{5}|[1356]\\d{4}",[5,6,7,8,9,10],[["(\\d{3})(\\d{3,5})","$1 $2",["2(?:0[45]|2[278]|[49]8)|3(?:[09]8|17)|6(?:[29]8|37|75)|[23][78]|(?:33|5[15]|6[68])[78]"],"0$1"],["(\\d)(\\d{3})(\\d{2,4})","$1 $2 $3",["[49]"],"0$1"],["(\\d{3})(\\d{4})","$1 $2",["80"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["24|8[13-59]|(?:2[05-79]|39|5[45]|6[15-8])2","2(?:02[014]|4|[56]20|[79]2)|392|5(?:42|525)|6(?:[16-8]21|52[013])|8[13-59]"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["7"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["2(?:1[39]|2[0157]|[378]|[56][14])|3(?:12|29)","2(?:1[39]|2[0157]|[378]|[56][14])|3(?:123|29)"],"0$1"],["(\\d{4})(\\d{6})","$1 $2",["8"],"0$1"],["(\\d{2})(\\d{3,5})","$1 $2",["1|2(?:0[0-36-9]|12|29|[56])|3(?:1[0-689]|[24-6])|5(?:[0236-9]|1[2-4])|6(?:[013-59]|7[0-46-9])|(?:33|55|6[68])[0-69]|(?:29|3[09]|62)[0-79]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["29[013-9]|39|54"],"0$1"],["(\\d{4})(\\d{3,5})","$1 $2",["(?:25|54)8","258|5483"],"0$1"]],"0"]},nonGeographic:{800:["800",0,"(?:00|[1-9]\\d)\\d{6}",[8],[["(\\d{4})(\\d{4})","$1 $2",["\\d"]]],0,0,0,0,0,0,[0,0,["(?:00|[1-9]\\d)\\d{6}"]]],808:["808",0,"[1-9]\\d{7}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[1-9]"]]],0,0,0,0,0,0,[0,0,0,0,0,0,0,0,0,["[1-9]\\d{7}"]]],870:["870",0,"7\\d{11}|[235-7]\\d{8}",[9,12],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[235-7]"]]],0,0,0,0,0,0,[0,["(?:[356]|774[45])\\d{8}|7[6-8]\\d{7}"],0,0,0,0,0,0,["2\\d{8}",[9]]]],878:["878",0,"10\\d{10}",[12],[["(\\d{2})(\\d{5})(\\d{5})","$1 $2 $3",["1"]]],0,0,0,0,0,0,[0,0,0,0,0,0,0,0,["10\\d{10}"]]],881:["881",0,"6\\d{9}|[0-36-9]\\d{8}",[9,10],[["(\\d)(\\d{3})(\\d{5})","$1 $2 $3",["[0-37-9]"]],["(\\d)(\\d{3})(\\d{5,6})","$1 $2 $3",["6"]]],0,0,0,0,0,0,[0,["6\\d{9}|[0-36-9]\\d{8}"]]],882:["882",0,"[13]\\d{6}(?:\\d{2,5})?|[19]\\d{7}|(?:[25]\\d\\d|4)\\d{7}(?:\\d{2})?",[7,8,9,10,11,12],[["(\\d{2})(\\d{5})","$1 $2",["16|342"]],["(\\d{2})(\\d{6})","$1 $2",["49"]],["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["1[36]|9"]],["(\\d{2})(\\d{4})(\\d{3})","$1 $2 $3",["3[23]"]],["(\\d{2})(\\d{3,4})(\\d{4})","$1 $2 $3",["16"]],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["10|23|3(?:[15]|4[57])|4|51"]],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["34"]],["(\\d{2})(\\d{4,5})(\\d{5})","$1 $2 $3",["[1-35]"]]],0,0,0,0,0,0,[0,["342\\d{4}|(?:337|49)\\d{6}|(?:3(?:2|47|7\\d{3})|50\\d{3})\\d{7}",[7,8,9,10,12]],0,0,0,["348[57]\\d{7}",[11]],0,0,["1(?:3(?:0[0347]|[13][0139]|2[035]|4[013568]|6[0459]|7[06]|8[15-8]|9[0689])\\d{4}|6\\d{5,10})|(?:345\\d|9[89])\\d{6}|(?:10|2(?:3|85\\d)|3(?:[15]|[69]\\d\\d)|4[15-8]|51)\\d{8}"]]],883:["883",0,"(?:[1-4]\\d|51)\\d{6,10}",[8,9,10,11,12],[["(\\d{3})(\\d{3})(\\d{2,8})","$1 $2 $3",["[14]|2[24-689]|3[02-689]|51[24-9]"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["510"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["21"]],["(\\d{4})(\\d{4})(\\d{4})","$1 $2 $3",["51[13]"]],["(\\d{3})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["[235]"]]],0,0,0,0,0,0,[0,0,0,0,0,0,0,0,["(?:2(?:00\\d\\d|10)|(?:370[1-9]|51\\d0)\\d)\\d{7}|51(?:00\\d{5}|[24-9]0\\d{4,7})|(?:1[0-79]|2[24-689]|3[02-689]|4[0-4])0\\d{5,9}"]]],888:["888",0,"\\d{11}",[11],[["(\\d{3})(\\d{3})(\\d{5})","$1 $2 $3"]],0,0,0,0,0,0,[0,0,0,0,0,0,["\\d{11}"]]],979:["979",0,"[1359]\\d{8}",[9],[["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["[1359]"]]],0,0,0,0,0,0,[0,0,0,["[1359]\\d{8}"]]]}};function cm(e){return cm="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},cm(e)}function um(e){var t=vm();return function(){var n,i=mm(e);if(t){var o=mm(this).constructor;n=Reflect.construct(i,arguments,o)}else n=i.apply(this,arguments);return function(e,t){if(t&&("object"===cm(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return hm(e)}(this,n)}}function hm(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function fm(e){var t="function"==typeof Map?new Map:void 0;return fm=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,i)}function i(){return pm(e,arguments,mm(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),gm(i,e)},fm(e)}function pm(e,t,n){return pm=vm()?Reflect.construct:function(e,t,n){var i=[null];i.push.apply(i,t);var o=new(Function.bind.apply(e,i));return n&&gm(o,n.prototype),o},pm.apply(null,arguments)}function vm(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function gm(e,t){return gm=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},gm(e,t)}function mm(e){return mm=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},mm(e)}var ym=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&gm(e,t)}(i,e);var t,n=um(i);function i(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,i),t=n.call(this,e),Object.setPrototypeOf(hm(t),i.prototype),t.name=t.constructor.name,t}return t=i,Object.defineProperty(t,"prototype",{writable:!1}),t}(fm(Error)),bm=2,wm=17,$m=3,km="0-90-9٠-٩۰-۹",Cm="".concat("-‐-―−ー-").concat("//").concat("..").concat("  ­​⁠ ").concat("()()[]\\[\\]").concat("~⁓∼~"),Sm="++";function Im(e,t){e=e.split("-"),t=t.split("-");for(var n=e[0].split("."),i=t[0].split("."),o=0;o<3;o++){var r=Number(n[o]),s=Number(i[o]);if(r>s)return 1;if(s>r)return-1;if(!isNaN(r)&&isNaN(s))return 1;if(isNaN(r)&&!isNaN(s))return-1}return e[1]&&t[1]?e[1]>t[1]?1:e[1]<t[1]?-1:0:!e[1]&&t[1]?1:e[1]&&!t[1]?-1:0}var Rm={}.constructor;function Em(e){return null!=e&&e.constructor===Rm}function xm(e){return xm="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},xm(e)}function Om(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Am(e,t,n){return t&&function(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var Nm=" ext. ",jm=/^\d+$/,Mm=function(){function e(t){Om(this,e),function(e){if(!e)throw new Error("[libphonenumber-js] `metadata` argument not passed. Check your arguments.");if(!Em(e)||!Em(e.countries))throw new Error("[libphonenumber-js] `metadata` argument was passed but it's not a valid metadata. Must be an object having `.countries` child object property. Got ".concat(Em(e)?"an object of shape: { "+Object.keys(e).join(", ")+" }":"a "+Dm(e)+": "+e,"."))}(t),this.metadata=t,qm.call(this,t)}return Am(e,[{key:"getCountries",value:function(){return Object.keys(this.metadata.countries).filter((function(e){return"001"!==e}))}},{key:"getCountryMetadata",value:function(e){return this.metadata.countries[e]}},{key:"nonGeographic",value:function(){if(!(this.v1||this.v2||this.v3))return this.metadata.nonGeographic||this.metadata.nonGeographical}},{key:"hasCountry",value:function(e){return void 0!==this.getCountryMetadata(e)}},{key:"hasCallingCode",value:function(e){if(this.getCountryCodesForCallingCode(e))return!0;if(this.nonGeographic()){if(this.nonGeographic()[e])return!0}else{var t=this.countryCallingCodes()[e];if(t&&1===t.length&&"001"===t[0])return!0}}},{key:"isNonGeographicCallingCode",value:function(e){return this.nonGeographic()?!!this.nonGeographic()[e]:!this.getCountryCodesForCallingCode(e)}},{key:"country",value:function(e){return this.selectNumberingPlan(e)}},{key:"selectNumberingPlan",value:function(e,t){if(e&&jm.test(e)&&(t=e,e=null),e&&"001"!==e){if(!this.hasCountry(e))throw new Error("Unknown country: ".concat(e));this.numberingPlan=new Pm(this.getCountryMetadata(e),this)}else if(t){if(!this.hasCallingCode(t))throw new Error("Unknown calling code: ".concat(t));this.numberingPlan=new Pm(this.getNumberingPlanMetadata(t),this)}else this.numberingPlan=void 0;return this}},{key:"getCountryCodesForCallingCode",value:function(e){var t=this.countryCallingCodes()[e];if(t){if(1===t.length&&3===t[0].length)return;return t}}},{key:"getCountryCodeForCallingCode",value:function(e){var t=this.getCountryCodesForCallingCode(e);if(t)return t[0]}},{key:"getNumberingPlanMetadata",value:function(e){var t=this.getCountryCodeForCallingCode(e);if(t)return this.getCountryMetadata(t);if(this.nonGeographic()){var n=this.nonGeographic()[e];if(n)return n}else{var i=this.countryCallingCodes()[e];if(i&&1===i.length&&"001"===i[0])return this.metadata.countries["001"]}}},{key:"countryCallingCode",value:function(){return this.numberingPlan.callingCode()}},{key:"IDDPrefix",value:function(){return this.numberingPlan.IDDPrefix()}},{key:"defaultIDDPrefix",value:function(){return this.numberingPlan.defaultIDDPrefix()}},{key:"nationalNumberPattern",value:function(){return this.numberingPlan.nationalNumberPattern()}},{key:"possibleLengths",value:function(){return this.numberingPlan.possibleLengths()}},{key:"formats",value:function(){return this.numberingPlan.formats()}},{key:"nationalPrefixForParsing",value:function(){return this.numberingPlan.nationalPrefixForParsing()}},{key:"nationalPrefixTransformRule",value:function(){return this.numberingPlan.nationalPrefixTransformRule()}},{key:"leadingDigits",value:function(){return this.numberingPlan.leadingDigits()}},{key:"hasTypes",value:function(){return this.numberingPlan.hasTypes()}},{key:"type",value:function(e){return this.numberingPlan.type(e)}},{key:"ext",value:function(){return this.numberingPlan.ext()}},{key:"countryCallingCodes",value:function(){return this.v1?this.metadata.country_phone_code_to_countries:this.metadata.country_calling_codes}},{key:"chooseCountryByCountryCallingCode",value:function(e){return this.selectNumberingPlan(e)}},{key:"hasSelectedNumberingPlan",value:function(){return void 0!==this.numberingPlan}}]),e}(),Pm=function(){function e(t,n){Om(this,e),this.globalMetadataObject=n,this.metadata=t,qm.call(this,n.metadata)}return Am(e,[{key:"callingCode",value:function(){return this.metadata[0]}},{key:"getDefaultCountryMetadataForRegion",value:function(){return this.globalMetadataObject.getNumberingPlanMetadata(this.callingCode())}},{key:"IDDPrefix",value:function(){if(!this.v1&&!this.v2)return this.metadata[1]}},{key:"defaultIDDPrefix",value:function(){if(!this.v1&&!this.v2)return this.metadata[12]}},{key:"nationalNumberPattern",value:function(){return this.v1||this.v2?this.metadata[1]:this.metadata[2]}},{key:"possibleLengths",value:function(){if(!this.v1)return this.metadata[this.v2?2:3]}},{key:"_getFormats",value:function(e){return e[this.v1?2:this.v2?3:4]}},{key:"formats",value:function(){var e=this,t=this._getFormats(this.metadata)||this._getFormats(this.getDefaultCountryMetadataForRegion())||[];return t.map((function(t){return new Tm(t,e)}))}},{key:"nationalPrefix",value:function(){return this.metadata[this.v1?3:this.v2?4:5]}},{key:"_getNationalPrefixFormattingRule",value:function(e){return e[this.v1?4:this.v2?5:6]}},{key:"nationalPrefixFormattingRule",value:function(){return this._getNationalPrefixFormattingRule(this.metadata)||this._getNationalPrefixFormattingRule(this.getDefaultCountryMetadataForRegion())}},{key:"_nationalPrefixForParsing",value:function(){return this.metadata[this.v1?5:this.v2?6:7]}},{key:"nationalPrefixForParsing",value:function(){return this._nationalPrefixForParsing()||this.nationalPrefix()}},{key:"nationalPrefixTransformRule",value:function(){return this.metadata[this.v1?6:this.v2?7:8]}},{key:"_getNationalPrefixIsOptionalWhenFormatting",value:function(){return!!this.metadata[this.v1?7:this.v2?8:9]}},{key:"nationalPrefixIsOptionalWhenFormattingInNationalFormat",value:function(){return this._getNationalPrefixIsOptionalWhenFormatting(this.metadata)||this._getNationalPrefixIsOptionalWhenFormatting(this.getDefaultCountryMetadataForRegion())}},{key:"leadingDigits",value:function(){return this.metadata[this.v1?8:this.v2?9:10]}},{key:"types",value:function(){return this.metadata[this.v1?9:this.v2?10:11]}},{key:"hasTypes",value:function(){return(!this.types()||0!==this.types().length)&&!!this.types()}},{key:"type",value:function(e){if(this.hasTypes()&&Um(this.types(),e))return new Lm(Um(this.types(),e),this)}},{key:"ext",value:function(){return this.v1||this.v2?Nm:this.metadata[13]||Nm}}]),e}(),Tm=function(){function e(t,n){Om(this,e),this._format=t,this.metadata=n}return Am(e,[{key:"pattern",value:function(){return this._format[0]}},{key:"format",value:function(){return this._format[1]}},{key:"leadingDigitsPatterns",value:function(){return this._format[2]||[]}},{key:"nationalPrefixFormattingRule",value:function(){return this._format[3]||this.metadata.nationalPrefixFormattingRule()}},{key:"nationalPrefixIsOptionalWhenFormattingInNationalFormat",value:function(){return!!this._format[4]||this.metadata.nationalPrefixIsOptionalWhenFormattingInNationalFormat()}},{key:"nationalPrefixIsMandatoryWhenFormattingInNationalFormat",value:function(){return this.usesNationalPrefix()&&!this.nationalPrefixIsOptionalWhenFormattingInNationalFormat()}},{key:"usesNationalPrefix",value:function(){return!(!this.nationalPrefixFormattingRule()||Wm.test(this.nationalPrefixFormattingRule()))}},{key:"internationalFormat",value:function(){return this._format[5]||this.format()}}]),e}(),Wm=/^\(?\$1\)?$/,Lm=function(){function e(t,n){Om(this,e),this.type=t,this.metadata=n}return Am(e,[{key:"pattern",value:function(){return this.metadata.v1?this.type:this.type[0]}},{key:"possibleLengths",value:function(){if(!this.metadata.v1)return this.type[1]||this.metadata.possibleLengths()}}]),e}();function Um(e,t){switch(t){case"FIXED_LINE":return e[0];case"MOBILE":return e[1];case"TOLL_FREE":return e[2];case"PREMIUM_RATE":return e[3];case"PERSONAL_NUMBER":return e[4];case"VOICEMAIL":return e[5];case"UAN":return e[6];case"PAGER":return e[7];case"VOIP":return e[8];case"SHARED_COST":return e[9]}}var Dm=function(e){return xm(e)};function Fm(e,t){if((t=new Mm(t)).hasCountry(e))return t.country(e).countryCallingCode();throw new Error("Unknown country: ".concat(e))}function _m(e,t){return t.countries.hasOwnProperty(e)}function qm(e){var t=e.version;"number"==typeof t?(this.v1=1===t,this.v2=2===t,this.v3=3===t,this.v4=4===t):t?-1===Im(t,"1.2.0")?this.v2=!0:-1===Im(t,"1.7.35")?this.v3=!0:this.v4=!0:this.v1=!0}var Bm=function(e){return"([".concat(km,"]{1,").concat(e,"})")};function Vm(e){var t="[  \\t,]*",n="[:\\..]?[  \\t,-]*",i="#?",o="[  \\t]*";return";ext="+Bm("20")+"|"+(t+"(?:e?xt(?:ensi(?:ó?|ó))?n?|e?xtn?|доб|anexo)"+n+Bm("20")+i)+"|"+(t+"(?:[xx##~~]|int|int)"+n+Bm("9")+i)+"|"+("[- ]+"+Bm("6")+"#")+"|"+(o+"(?:,{2}|;)"+n+Bm("15")+i)+"|"+(o+"(?:,)+"+n+Bm("9")+i)}var Km="["+km+"]{"+bm+"}",Hm="[++]{0,1}(?:["+Cm+"]*["+km+"]){3,}["+Cm+km+"]*",zm=new RegExp("^[++]{0,1}(?:["+Cm+"]*["+km+"]){1,2}$","i"),Jm=Hm+"(?:"+Vm()+")?",Gm=new RegExp("^"+Km+"$|^"+Jm+"$","i");var Zm=new RegExp("(?:"+Vm()+")$","i");function Ym(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Xm(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Xm(e,t)}(e))||t){n&&(e=n);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Xm(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}var Qm={0:"0",1:"1",2:"2",3:"3",4:"4",5:"5",6:"6",7:"7",8:"8",9:"9","0":"0","1":"1","2":"2","3":"3","4":"4","5":"5","6":"6","7":"7","8":"8","9":"9","٠":"0","١":"1","٢":"2","٣":"3","٤":"4","٥":"5","٦":"6","٧":"7","٨":"8","٩":"9","۰":"0","۱":"1","۲":"2","۳":"3","۴":"4","۵":"5","۶":"6","۷":"7","۸":"8","۹":"9"};function ey(e){return Qm[e]}function ty(e){for(var t,n="",i=Ym(e.split(""));!(t=i()).done;){var o=ey(t.value);o&&(n+=o)}return n}function ny(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return iy(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return iy(e,t)}(e))||t){n&&(e=n);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function iy(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function oy(e){for(var t,n="",i=ny(e.split(""));!(t=i()).done;){n+=ry(t.value,n)||""}return n}function ry(e,t,n){if("+"===e){if(t)return;return"+"}return ey(e)}function sy(e,t){return function(e,t,n){var i=n.type(t),o=i&&i.possibleLengths()||n.possibleLengths();if(!o)return"IS_POSSIBLE";var r=e.length,s=o[0];if(s===r)return"IS_POSSIBLE";if(s>r)return"TOO_SHORT";if(o[o.length-1]<r)return"TOO_LONG";return o.indexOf(r,1)>=0?"IS_POSSIBLE":"INVALID_LENGTH"}(e,void 0,t)}function ay(e,t){return"IS_POSSIBLE"===sy(e,t)}function dy(e,t){return e=e||"",new RegExp("^(?:"+t+")$").test(e)}function ly(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return cy(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return cy(e,t)}(e))||t){n&&(e=n);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function cy(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}var uy=["MOBILE","PREMIUM_RATE","TOLL_FREE","SHARED_COST","VOIP","PERSONAL_NUMBER","PAGER","UAN","VOICEMAIL"];function hy(e,t,n){if(t=t||{},e.country||e.countryCallingCode){(n=new Mm(n)).selectNumberingPlan(e.country,e.countryCallingCode);var i=t.v2?e.nationalNumber:e.phone;if(dy(i,n.nationalNumberPattern())){if(fy(i,"FIXED_LINE",n))return n.type("MOBILE")&&""===n.type("MOBILE").pattern()?"FIXED_LINE_OR_MOBILE":n.type("MOBILE")?fy(i,"MOBILE",n)?"FIXED_LINE_OR_MOBILE":"FIXED_LINE":"FIXED_LINE_OR_MOBILE";for(var o,r=ly(uy);!(o=r()).done;){var s=o.value;if(fy(i,s,n))return s}}}}function fy(e,t,n){return!(!(t=n.type(t))||!t.pattern())&&(!(t.possibleLengths()&&t.possibleLengths().indexOf(e.length)<0)&&dy(e,t.pattern()))}function py(e,t,n){var i=new Mm(n).getCountryCodesForCallingCode(e);return i?i.filter((function(e){return function(e,t,n){var i=new Mm(n);if(i.selectNumberingPlan(t),i.numberingPlan.possibleLengths().indexOf(e.length)>=0)return!0;return!1}(t,e,n)})):[]}function vy(e){return e.replace(new RegExp("[".concat(Cm,"]+"),"g")," ").trim()}var gy=/(\$\d)/;function my(e,t,n){var i=n.useInternationalFormat,o=n.withNationalPrefix;n.carrierCode,n.metadata;var r=e.replace(new RegExp(t.pattern()),i?t.internationalFormat():o&&t.nationalPrefixFormattingRule()?t.format().replace(gy,t.nationalPrefixFormattingRule()):t.format());return i?vy(r):r}var yy=/^[\d]+(?:[~\u2053\u223C\uFF5E][\d]+)?$/;function by(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return wy(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return wy(e,t)}(e))||t){n&&(e=n);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function wy(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function $y(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function ky(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?$y(Object(n),!0).forEach((function(t){Cy(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):$y(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Cy(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Sy={formatExtension:function(e,t,n){return"".concat(e).concat(n.ext()).concat(t)}};function Iy(e,t,n,i){if(n=n?ky(ky({},Sy),n):Sy,i=new Mm(i),e.country&&"001"!==e.country){if(!i.hasCountry(e.country))throw new Error("Unknown country: ".concat(e.country));i.country(e.country)}else{if(!e.countryCallingCode)return e.phone||"";i.selectNumberingPlan(e.countryCallingCode)}var o,r=i.countryCallingCode(),s=n.v2?e.nationalNumber:e.phone;switch(t){case"NATIONAL":return s?xy(o=Ry(s,e.carrierCode,"NATIONAL",i,n),e.ext,i,n.formatExtension):"";case"INTERNATIONAL":return s?(o=Ry(s,null,"INTERNATIONAL",i,n),xy(o="+".concat(r," ").concat(o),e.ext,i,n.formatExtension)):"+".concat(r);case"E.164":return"+".concat(r).concat(s);case"RFC3966":return function(e){var t=e.number,n=e.ext;if(!t)return"";if("+"!==t[0])throw new Error('"formatRFC3966()" expects "number" to be in E.164 format.');return"tel:".concat(t).concat(n?";ext="+n:"")}({number:"+".concat(r).concat(s),ext:e.ext});case"IDD":if(!n.fromCountry)return;var a=function(e,t,n,i,o){var r=Fm(i,o.metadata);if(r===n){var s=Ry(e,t,"NATIONAL",o);return"1"===n?n+" "+s:s}var a=function(e,t,n){var i=new Mm(n);return i.selectNumberingPlan(e,t),i.defaultIDDPrefix()?i.defaultIDDPrefix():yy.test(i.IDDPrefix())?i.IDDPrefix():void 0}(i,void 0,o.metadata);if(a)return"".concat(a," ").concat(n," ").concat(Ry(e,null,"INTERNATIONAL",o))}(s,e.carrierCode,r,n.fromCountry,i);return xy(a,e.ext,i,n.formatExtension);default:throw new Error('Unknown "format" argument passed to "formatNumber()": "'.concat(t,'"'))}}function Ry(e,t,n,i,o){var r=Ey(i.formats(),e);return r?my(e,r,{useInternationalFormat:"INTERNATIONAL"===n,withNationalPrefix:!r.nationalPrefixIsOptionalWhenFormattingInNationalFormat()||!o||!1!==o.nationalPrefix,carrierCode:t,metadata:i}):e}function Ey(e,t){for(var n,i=by(e);!(n=i()).done;){var o=n.value;if(o.leadingDigitsPatterns().length>0){var r=o.leadingDigitsPatterns()[o.leadingDigitsPatterns().length-1];if(0!==t.search(r))continue}if(dy(t,o.pattern()))return o}}function xy(e,t,n,i){return t?i(e,t,n):e}function Oy(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function Ay(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Oy(Object(n),!0).forEach((function(t){Ny(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Oy(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Ny(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function jy(e,t,n){return t&&function(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var My=function(){function e(t,n,i){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),!t)throw new TypeError("`country` or `countryCallingCode` not passed");if(!n)throw new TypeError("`nationalNumber` not passed");if(!i)throw new TypeError("`metadata` not passed");var o=function(e,t){var n,i,o=new Mm(t);Py(e)?(n=e,o.selectNumberingPlan(n),i=o.countryCallingCode()):i=e;return{country:n,countryCallingCode:i}}(t,i),r=o.country,s=o.countryCallingCode;this.country=r,this.countryCallingCode=s,this.nationalNumber=n,this.number="+"+this.countryCallingCode+this.nationalNumber,this.getMetadata=function(){return i}}return jy(e,[{key:"setExt",value:function(e){this.ext=e}},{key:"getPossibleCountries",value:function(){return this.country?[this.country]:py(this.countryCallingCode,this.nationalNumber,this.getMetadata())}},{key:"isPossible",value:function(){return function(e,t,n){if(void 0===t&&(t={}),n=new Mm(n),t.v2){if(!e.countryCallingCode)throw new Error("Invalid phone number object passed");n.selectNumberingPlan(e.countryCallingCode)}else{if(!e.phone)return!1;if(e.country){if(!n.hasCountry(e.country))throw new Error("Unknown country: ".concat(e.country));n.country(e.country)}else{if(!e.countryCallingCode)throw new Error("Invalid phone number object passed");n.selectNumberingPlan(e.countryCallingCode)}}if(n.possibleLengths())return ay(e.phone||e.nationalNumber,n);if(e.countryCallingCode&&n.isNonGeographicCallingCode(e.countryCallingCode))return!0;throw new Error('Missing "possibleLengths" in metadata. Perhaps the metadata has been generated before v1.0.18.')}(this,{v2:!0},this.getMetadata())}},{key:"isValid",value:function(){return function(e,t,n){return t=t||{},(n=new Mm(n)).selectNumberingPlan(e.country,e.countryCallingCode),n.hasTypes()?void 0!==hy(e,t,n.metadata):dy(t.v2?e.nationalNumber:e.phone,n.nationalNumberPattern())}(this,{v2:!0},this.getMetadata())}},{key:"isNonGeographic",value:function(){return new Mm(this.getMetadata()).isNonGeographicCallingCode(this.countryCallingCode)}},{key:"isEqual",value:function(e){return this.number===e.number&&this.ext===e.ext}},{key:"getType",value:function(){return hy(this,{v2:!0},this.getMetadata())}},{key:"format",value:function(e,t){return Iy(this,e,t?Ay(Ay({},t),{},{v2:!0}):{v2:!0},this.getMetadata())}},{key:"formatNational",value:function(e){return this.format("NATIONAL",e)}},{key:"formatInternational",value:function(e){return this.format("INTERNATIONAL",e)}},{key:"getURI",value:function(e){return this.format("RFC3966",e)}}]),e}(),Py=function(e){return/^[A-Z]{2}$/.test(e)};var Ty=new RegExp("(["+km+"])");function Wy(e,t,n,i){if(t){var o=new Mm(i);o.selectNumberingPlan(t,n);var r=new RegExp(o.IDDPrefix());if(0===e.search(r)){var s=(e=e.slice(e.match(r)[0].length)).match(Ty);if(!(s&&null!=s[1]&&s[1].length>0&&"0"===s[1]))return e}}}function Ly(e,t){if(e&&t.numberingPlan.nationalPrefixForParsing()){var n=new RegExp("^(?:"+t.numberingPlan.nationalPrefixForParsing()+")"),i=n.exec(e);if(i){var o,r,s,a=i.length-1,d=a>0&&i[a];if(t.nationalPrefixTransformRule()&&d)o=e.replace(n,t.nationalPrefixTransformRule()),a>1&&(r=i[1]);else{var l=i[0];o=e.slice(l.length),d&&(r=i[1])}if(d){var c=e.indexOf(i[1]);e.slice(0,c)===t.numberingPlan.nationalPrefix()&&(s=t.numberingPlan.nationalPrefix())}else s=i[0];return{nationalNumber:o,nationalPrefix:s,carrierCode:r}}}return{nationalNumber:e}}function Uy(e,t){var n=Ly(e,t),i=n.carrierCode,o=n.nationalNumber;if(o!==e){if(!function(e,t,n){if(dy(e,n.nationalNumberPattern())&&!dy(t,n.nationalNumberPattern()))return!1;return!0}(e,o,t))return{nationalNumber:e};if(t.possibleLengths()&&!function(e,t){switch(sy(e,t)){case"TOO_SHORT":case"INVALID_LENGTH":return!1;default:return!0}}(o,t))return{nationalNumber:e}}return{nationalNumber:o,carrierCode:i}}function Dy(e,t,n,i){var o=t?Fm(t,i):n;if(0===e.indexOf(o)){(i=new Mm(i)).selectNumberingPlan(t,n);var r=e.slice(o.length),s=Uy(r,i).nationalNumber,a=Uy(e,i).nationalNumber;if(!dy(a,i.nationalNumberPattern())&&dy(s,i.nationalNumberPattern())||"TOO_LONG"===sy(a,i))return{countryCallingCode:o,number:r}}return{number:e}}function Fy(e,t,n,i){if(!e)return{};var o;if("+"!==e[0]){var r=Wy(e,t,n,i);if(!r||r===e){if(t||n){var s=Dy(e,t,n,i),a=s.countryCallingCode,d=s.number;if(a)return{countryCallingCodeSource:"FROM_NUMBER_WITHOUT_PLUS_SIGN",countryCallingCode:a,number:d}}return{number:e}}o=!0,e="+"+r}if("0"===e[1])return{};i=new Mm(i);for(var l=2;l-1<=$m&&l<=e.length;){var c=e.slice(1,l);if(i.hasCallingCode(c))return i.selectNumberingPlan(c),{countryCallingCodeSource:o?"FROM_NUMBER_WITH_IDD":"FROM_NUMBER_WITH_PLUS_SIGN",countryCallingCode:c,number:e.slice(l)};l++}return{}}function _y(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return qy(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return qy(e,t)}(e))||t){n&&(e=n);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function qy(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function By(e,t){var n=t.countries;t.defaultCountry;var i=t.metadata;i=new Mm(i);for(var o,r=_y(n);!(o=r()).done;){var s=o.value;if(i.country(s),i.leadingDigits()){if(e&&0===e.search(i.leadingDigits()))return s}else if(hy({phone:e,country:s},void 0,i.metadata))return s}}function Vy(e,t){var n=t.nationalNumber,i=t.defaultCountry,o=t.metadata,r=o.getCountryCodesForCallingCode(e);if(r)return 1===r.length?r[0]:By(n,{countries:r,defaultCountry:i,metadata:o.metadata})}var Ky="+",Hy="(["+km+"]|[\\-\\.\\(\\)]?)",zy=new RegExp("^\\"+Ky+Hy+"*["+km+"]"+Hy+"*$","g"),Jy=new RegExp("^("+("["+km+"]+((\\-)*["+km+"])*")+"\\.)*"+("[a-zA-Z]+((\\-)*["+km+"])*")+"\\.?$","g"),Gy="tel:",Zy=";phone-context=",Yy=";isub=";function Xy(e,t){var n,i=t.extractFormattedPhoneNumber,o=function(e){var t=e.indexOf(Zy);if(t<0)return null;var n=t+Zy.length;if(n>=e.length)return"";var i=e.indexOf(";",n);return i>=0?e.substring(n,i):e.substring(n)}(e);if(!function(e){return null===e||0!==e.length&&(zy.test(e)||Jy.test(e))}(o))throw new ym("NOT_A_NUMBER");if(null===o)n=i(e)||"";else{n="",o.charAt(0)===Ky&&(n+=o);var r,s=e.indexOf(Gy);r=s>=0?s+Gy.length:0;var a=e.indexOf(Zy);n+=e.substring(r,a)}var d=n.indexOf(Yy);if(d>0&&(n=n.substring(0,d)),""!==n)return n}var Qy=250,eb=new RegExp("[++"+km+"]"),tb=new RegExp("[^"+km+"#]+$");function nb(e,t,n){if(t=t||{},n=new Mm(n),t.defaultCountry&&!n.hasCountry(t.defaultCountry)){if(t.v2)throw new ym("INVALID_COUNTRY");throw new Error("Unknown country: ".concat(t.defaultCountry))}var i=function(e,t,n){var i=Xy(e,{extractFormattedPhoneNumber:function(e){return function(e,t,n){if(!e)return;if(e.length>Qy){if(n)throw new ym("TOO_LONG");return}if(!1===t)return e;var i=e.search(eb);if(i<0)return;return e.slice(i).replace(tb,"")}(e,n,t)}});if(!i)return{};if(!function(e){return e.length>=bm&&Gm.test(e)}(i))return function(e){return zm.test(e)}(i)?{error:"TOO_SHORT"}:{};var o=function(e){var t=e.search(Zm);if(t<0)return{};for(var n=e.slice(0,t),i=e.match(Zm),o=1;o<i.length;){if(i[o])return{number:n,ext:i[o]};o++}}(i);if(o.ext)return o;return{number:i}}(e,t.v2,t.extract),o=i.number,r=i.ext,s=i.error;if(!o){if(t.v2){if("TOO_SHORT"===s)throw new ym("TOO_SHORT");throw new ym("NOT_A_NUMBER")}return{}}var a=function(e,t,n,i){var o,r=Fy(oy(e),t,n,i.metadata),s=r.countryCallingCodeSource,a=r.countryCallingCode,d=r.number;if(a)i.selectNumberingPlan(a);else{if(!d||!t&&!n)return{};i.selectNumberingPlan(t,n),t&&(o=t),a=n||Fm(t,i.metadata)}if(!d)return{countryCallingCodeSource:s,countryCallingCode:a};var l=Uy(oy(d),i),c=l.nationalNumber,u=l.carrierCode,h=Vy(a,{nationalNumber:c,defaultCountry:t,metadata:i});h&&(o=h,"001"===h||i.country(o));return{country:o,countryCallingCode:a,countryCallingCodeSource:s,nationalNumber:c,carrierCode:u}}(o,t.defaultCountry,t.defaultCallingCode,n),d=a.country,l=a.nationalNumber,c=a.countryCallingCode,u=a.countryCallingCodeSource,h=a.carrierCode;if(!n.hasSelectedNumberingPlan()){if(t.v2)throw new ym("INVALID_COUNTRY");return{}}if(!l||l.length<bm){if(t.v2)throw new ym("TOO_SHORT");return{}}if(l.length>wm){if(t.v2)throw new ym("TOO_LONG");return{}}if(t.v2){var f=new My(c,l,n.metadata);return d&&(f.country=d),h&&(f.carrierCode=h),r&&(f.ext=r),f.__countryCallingCodeSource=u,f}var p=!!(t.extended?n.hasSelectedNumberingPlan():d)&&dy(l,n.nationalNumberPattern());return t.extended?{country:d,countryCallingCode:c,carrierCode:h,valid:p,possible:!!p||!(!0!==t.extended||!n.possibleLengths()||!ay(l,n)),phone:l,ext:r}:p?function(e,t,n){var i={country:e,phone:t};n&&(i.ext=n);return i}(d,l,r):{}}function ib(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function ob(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ib(Object(n),!0).forEach((function(t){rb(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ib(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function rb(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function sb(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function ab(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function db(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==n)return;var i,o,r=[],s=!0,a=!1;try{for(n=n.call(e);!(s=(i=n.next()).done)&&(r.push(i.value),!t||r.length!==t);s=!0);}catch(e){a=!0,o=e}finally{try{s||null==n.return||n.return()}finally{if(a)throw o}}return r}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return lb(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return lb(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function lb(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function cb(e){var t,n,i,o=db(Array.prototype.slice.call(e),4),r=o[0],s=o[1],a=o[2],d=o[3];if("string"!=typeof r)throw new TypeError("A text for parsing must be a string.");if(t=r,s&&"string"!=typeof s){if(!Em(s))throw new Error("Invalid second argument: ".concat(s));a?(n=s,i=a):i=s}else d?(n=a,i=d):(n=void 0,i=a),s&&(n=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?sb(Object(n),!0).forEach((function(t){ab(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):sb(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({defaultCountry:s},n));return{text:t,options:n,metadata:i}}function ub(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function hb(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ub(Object(n),!0).forEach((function(t){fb(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ub(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function fb(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function pb(e,t,n){t&&t.defaultCountry&&!_m(t.defaultCountry,n)&&(t=hb(hb({},t),{},{defaultCountry:void 0}));try{return function(e,t,n){return nb(e,ob(ob({},t),{},{v2:!0}),n)}(e,t,n)}catch(e){if(!(e instanceof ym))throw e}}function vb(){var e=cb(arguments);return pb(e.text,e.options,e.metadata)}function gb(e,t,n){return t&&function(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function mb(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var yb=gb((function e(t,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;mb(this,e),this.key=t,this.value=n,this.next=i,this.prev=o})),bb=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10;mb(this,e),this.size=0,this.limit=t,this.head=null,this.tail=null,this.cache={}}return gb(e,[{key:"put",value:function(e,t){if(this.ensureLimit(),this.head){var n=new yb(e,t,this.head);this.head.prev=n,this.head=n}else this.head=this.tail=new yb(e,t);this.cache[e]=this.head,this.size++}},{key:"get",value:function(e){if(this.cache[e]){var t=this.cache[e].value;return this.remove(e),this.put(e,t),t}console.log("Item not available in cache for key ".concat(e))}},{key:"ensureLimit",value:function(){this.size===this.limit&&this.remove(this.tail.key)}},{key:"remove",value:function(e){var t=this.cache[e];null!==t.prev?t.prev.next=t.next:this.head=t.next,null!==t.next?t.next.prev=t.prev:this.tail=t.prev,delete this.cache[e],this.size--}},{key:"clear",value:function(){this.head=null,this.tail=null,this.size=0,this.cache={}}}]),e}();function wb(e,t,n){return t&&function(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var $b=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.cache=new bb(t)}return wb(e,[{key:"getPatternForRegExp",value:function(e){var t=this.cache.get(e);return t||(t=new RegExp("^"+e),this.cache.put(e,t)),t}}]),e}();function kb(e,t){if(e<0||t<=0||t<e)throw new TypeError;return"{".concat(e,",").concat(t,"}")}function Cb(e,t){var n=t.search(e);return n>=0?t.slice(0,n):t}var Sb="   ᠎ - \u2028\u2029   ",Ib="[".concat(Sb,"]"),Rb="[^".concat(Sb,"]"),Eb="[".concat("0-9٠-٩۰-۹߀-߉०-९০-৯੦-੯૦-૯୦-୯௦-௯౦-౯೦-೯൦-൯๐-๙໐-໙༠-༩၀-၉႐-႙០-៩᠐-᠙᥆-᥏᧐-᧙᪀-᪉᪐-᪙᭐-᭙᮰-᮹᱀-᱉᱐-᱙꘠-꘩꣐-꣙꤀-꤉꧐-꧙꩐-꩙꯰-꯹0-9","]"),xb="A-Za-zªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԧԱ-Ֆՙա-ևא-תװ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࢠࢢ-ࢬऄ-हऽॐक़-ॡॱ-ॷॹ-ॿঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-ళవ-హఽౘౙౠౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-ഐഒ-ഺഽൎൠൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡷᢀ-ᢨᢪᢰ-ᣵᤀ-ᤜᥐ-ᥭᥰ-ᥴᦀ-ᦫᧁ-ᧇᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᳩ-ᳬᳮ-ᳱᳵᳶᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎↃↄⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⸯ々〆〱-〵〻〼ぁ-ゖゝ-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿌ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚗꚠ-ꛥꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐ-ꞓꞠ-Ɦꟸ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꪀ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꯀ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",Ob="[".concat(xb,"]"),Ab=new RegExp(Ob),Nb="[".concat("$¢-¥֏؋৲৳৻૱௹฿៛₠-₹꠸﷼﹩$¢£¥₩","]"),jb=new RegExp(Nb),Mb="[".concat("̀-ͯ҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-ٰٟۖ-ۜ۟-۪ۤۧۨ-ܑۭܰ-݊ަ-ް߫-߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛ࣤ-ࣾऀ-ंऺ़ु-ै्॑-ॗॢॣঁ়ু-ৄ্ৢৣਁਂ਼ੁੂੇੈੋ-੍ੑੰੱੵઁં઼ુ-ૅેૈ્ૢૣଁ଼ିୁ-ୄ୍ୖୢୣஂீ்ా-ీె-ైొ-్ౕౖౢౣ಼ಿೆೌ್ೢೣു-ൄ്ൢൣ්ි-ුූัิ-ฺ็-๎ັິ-ູົຼ່-ໍཱ༹༘༙༵༷-ཾྀ-྄྆྇ྍ-ྗྙ-ྼ࿆ိ-ူဲ-့္်ွှၘၙၞ-ၠၱ-ၴႂႅႆႍႝ፝-፟ᜒ-᜔ᜲ-᜴ᝒᝓᝲᝳ឴឵ិ-ួំ៉-៓៝᠋-᠍ᢩᤠ-ᤢᤧᤨᤲ᤹-᤻ᨘᨗᩖᩘ-ᩞ᩠ᩢᩥ-ᩬᩳ-᩿᩼ᬀ-ᬃ᬴ᬶ-ᬺᬼᭂ᭫-᭳ᮀᮁᮢ-ᮥᮨᮩ᯦᮫ᯨᯩᯭᯯ-ᯱᰬ-ᰳᰶ᰷᳐-᳔᳒-᳢᳠-᳨᳭᳴᷀-ᷦ᷼-᷿⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〭꙯ꙴ-꙽ꚟ꛰꛱ꠂ꠆ꠋꠥꠦ꣄꣠-꣱ꤦ-꤭ꥇ-ꥑꦀ-ꦂ꦳ꦶ-ꦹꦼꨩ-ꨮꨱꨲꨵꨶꩃꩌꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫬꫭ꫶ꯥꯨ꯭ﬞ︀-️︠-︦","]"),Pb=new RegExp(Mb),Tb=new RegExp("[\0-€-ÿĀ-ſḀ-ỿƀ-ɏ̀-ͯ]");function Wb(e){return!(!Ab.test(e)&&!Pb.test(e))&&Tb.test(e)}function Lb(e){return"%"===e||jb.test(e)}function Ub(e,t,n){var i=!0,o=vb(e,n);if(o||(i=!1,o=vb(e,{defaultCallingCode:t.countryCallingCode},n)),!o)return"INVALID_NUMBER";if(t.ext){if(o.ext!==t.ext)return"NO_MATCH"}else if(o.ext)return"NO_MATCH";return i&&t.countryCallingCode!==o.countryCallingCode?"NO_MATCH":t.number===o.number?i?"EXACT_MATCH":"NSN_MATCH":0===t.nationalNumber.indexOf(o.nationalNumber)||0===o.nationalNumber.indexOf(t.nationalNumber)?"SHORT_NSN_MATCH":"NO_MATCH"}var Db={POSSIBLE:function(e,t){return t.candidate,t.metadata,!0},VALID:function(e,t){var n=t.candidate;t.defaultCountry;var i=t.metadata;return!(!e.isValid()||!Fb(e,n,i))},STRICT_GROUPING:function(e,t){var n=t.candidate,i=t.defaultCountry,o=t.metadata;return t.regExpCache,!(!e.isValid()||!Fb(e,n,o)||qb(e,n)||!_b(e,{defaultCountry:i,metadata:o}))&&Bb()},EXACT_GROUPING:function(e,t){var n=t.candidate,i=t.defaultCountry,o=t.metadata;return t.regExpCache,!(!e.isValid()||!Fb(e,n,o)||qb(e,n)||!_b(e,{defaultCountry:i,metadata:o}))&&Bb()}};function Fb(e,t,n){for(var i=0;i<t.length-1;i++){var o=t.charAt(i);if("x"===o||"X"===o){var r=t.charAt(i+1);if("x"===r||"X"===r){if(i++,"NSN_MATCH"!==Ub(t.substring(i),e,n))return!1}else{var s=ty(t.substring(i));if(s){if(e.ext!==s)return!1}else if(e.ext)return!1}}}return!0}function _b(e,t){var n=t.defaultCountry,i=t.metadata;if("FROM_DEFAULT_COUNTRY"!==e.__countryCallingCodeSource)return!0;var o=new Mm(i);o.selectNumberingPlan(e.countryCallingCode),e.country||Vy(e.countryCallingCode,{nationalNumber:e.nationalNumber,defaultCountry:n,metadata:o});var r=e.nationalNumber,s=Ey(o.numberingPlan.formats(),r);return!s.nationalPrefixFormattingRule()||(!!o.numberingPlan.nationalPrefixIsOptionalWhenFormattingInNationalFormat()||(!s.usesNationalPrefix()||Boolean(e.nationalPrefix)))}function qb(e,t){var n=t.indexOf("/");if(n<0)return!1;var i=t.indexOf("/",n+1);return!(i<0)&&(!("FROM_NUMBER_WITH_PLUS_SIGN"===e.__countryCallingCodeSource||"FROM_NUMBER_WITHOUT_PLUS_SIGN"===e.__countryCallingCodeSource)||ty(t.substring(0,n))!==e.countryCallingCode||t.slice(i+1).indexOf("/")>=0)}function Bb(e,t,n,i,o){throw new Error("This part of code hasn't been ported")}var Vb=/[\\/] *x/;function Kb(e){return Cb(Vb,e)}var Hb=/(?:(?:[0-3]?\d\/[01]?\d)|(?:[01]?\d\/[0-3]?\d))\/(?:[12]\d)?\d{2}/,zb=/[12]\d{3}[-/]?[01]\d[-/]?[0-3]\d +[0-2]\d$/,Jb=/^:[0-5]\d/;function Gb(e,t,n){if(Hb.test(e))return!1;if(zb.test(e)){var i=n.slice(t+e.length);if(Jb.test(i))return!1}return!0}var Zb="(\\[([",Yb=")\\])]",Xb="[^".concat(Zb).concat(Yb,"]"),Qb="[".concat(Zb).concat(Sm,"]"),ew=new RegExp("^"+Qb),tw=kb(0,3),nw=new RegExp("^(?:[(\\[([])?(?:"+Xb+"+["+Yb+"])?"+Xb+"+(?:["+Zb+"]"+Xb+"+["+Yb+"])"+tw+Xb+"*$"),iw=/\d{1,5}-+\d{1,5}\s{0,4}\(\d{1,4}/;function ow(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return rw(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return rw(e,t)}(e))||t){n&&(e=n);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function rw(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function sw(e,t,n){return t&&function(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var aw=Vm(),dw=["\\/+(.*)/","(\\([^(]*)","(?:".concat(Ib,"-|-").concat(Ib,")").concat(Ib,"*(.+)"),"[‒-―-]".concat(Ib,"*(.+)"),"\\.+".concat(Ib,"*([^.]+)"),"".concat(Ib,"+(").concat(Rb,"+)")],lw=kb(0,2),cw=kb(0,4),uw=wm+$m,hw=kb(0,uw),fw="[".concat(Cm,"]")+cw,pw=Eb+kb(1,uw),vw="(?:"+Qb+fw+")"+lw+pw+"(?:"+fw+pw+")"+hw+"(?:"+aw+")?",gw=new RegExp("[^".concat("0-9²³¹¼-¾٠-٩۰-۹߀-߉०-९০-৯৴-৹੦-੯૦-૯୦-୯୲-୷௦-௲౦-౯౸-౾೦-೯൦-൵๐-๙໐-໙༠-༳၀-၉႐-႙፩-፼ᛮ-ᛰ០-៩៰-៹᠐-᠙᥆-᥏᧐-᧚᪀-᪉᪐-᪙᭐-᭙᮰-᮹᱀-᱉᱐-᱙⁰⁴-⁹₀-₉⅐-ↂↅ-↉①-⒛⓪-⓿❶-➓⳽〇〡-〩〸-〺㆒-㆕㈠-㈩㉈-㉏㉑-㉟㊀-㊉㊱-㊿꘠-꘩ꛦ-ꛯ꠰-꠵꣐-꣙꤀-꤉꧐-꧙꩐-꩙꯰-꯹0-9").concat(xb,"#]+$")),mw=Number.MAX_SAFE_INTEGER||Math.pow(2,53)-1,yw=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2?arguments[2]:void 0;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),!(n={v2:n.v2,defaultCallingCode:n.defaultCallingCode,defaultCountry:n.defaultCountry&&_m(n.defaultCountry,i)?n.defaultCountry:void 0,leniency:n.leniency||(n.extended?"POSSIBLE":"VALID"),maxTries:n.maxTries||mw}).leniency)throw new TypeError("`leniency` is required");if("POSSIBLE"!==n.leniency&&"VALID"!==n.leniency)throw new TypeError('Invalid `leniency`: "'.concat(n.leniency,'". Supported values: "POSSIBLE", "VALID".'));if(n.maxTries<0)throw new TypeError("`maxTries` must be `>= 0`");if(this.text=t,this.options=n,this.metadata=i,this.leniency=Db[n.leniency],!this.leniency)throw new TypeError('Unknown leniency: "'.concat(n.leniency,'"'));this.maxTries=n.maxTries,this.PATTERN=new RegExp(vw,"ig"),this.state="NOT_READY",this.searchIndex=0,this.regExpCache=new $b(32)}return sw(e,[{key:"find",value:function(){for(var e;this.maxTries>0&&null!==(e=this.PATTERN.exec(this.text));){var t=e[0],n=e.index;if(Gb(t=Kb(t),n,this.text)){var i=this.parseAndVerify(t,n,this.text)||this.extractInnerMatch(t,n,this.text);if(i){if(this.options.v2)return{startsAt:i.startsAt,endsAt:i.endsAt,number:i.phoneNumber};var o=i.phoneNumber,r={startsAt:i.startsAt,endsAt:i.endsAt,phone:o.nationalNumber};return o.country?r.country=o.country:r.countryCallingCode=o.countryCallingCode,o.ext&&(r.ext=o.ext),r}}this.maxTries--}}},{key:"extractInnerMatch",value:function(e,t,n){for(var i,o=ow(dw);!(i=o()).done;)for(var r=i.value,s=!0,a=void 0,d=new RegExp(r,"g");this.maxTries>0&&null!==(a=d.exec(e));){if(s){var l=Cb(gw,e.slice(0,a.index)),c=this.parseAndVerify(l,t,n);if(c)return c;this.maxTries--,s=!1}var u=Cb(gw,a[1]),h=e.indexOf(u,a.index),f=this.parseAndVerify(u,t+h,n);if(f)return f;this.maxTries--}}},{key:"parseAndVerify",value:function(e,t,n){if(function(e,t,n,i){if(nw.test(e)&&!iw.test(e)){if("POSSIBLE"!==i){if(t>0&&!ew.test(e)){var o=n[t-1];if(Lb(o)||Wb(o))return!1}var r=t+e.length;if(r<n.length){var s=n[r];if(Lb(s)||Wb(s))return!1}}return!0}}(e,t,n,this.options.leniency)){var i=vb(e,{extended:!0,defaultCountry:this.options.defaultCountry,defaultCallingCode:this.options.defaultCallingCode},this.metadata);if(i&&i.isPossible())return this.leniency(i,{candidate:e,defaultCountry:this.options.defaultCountry,metadata:this.metadata,regExpCache:this.regExpCache})?{startsAt:t,endsAt:t+e.length,phoneNumber:i}:void 0}}},{key:"hasNext",value:function(){return"NOT_READY"===this.state&&(this.lastMatch=this.find(),this.lastMatch?this.state="READY":this.state="DONE"),"READY"===this.state}},{key:"next",value:function(){if(!this.hasNext())throw new Error("No next element");var e=this.lastMatch;return this.lastMatch=null,this.state="NOT_READY",e}}]),e}();function bw(e,t,n){return t&&function(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var ww=function(){function e(t){var n=t.onCountryChange,i=t.onCallingCodeChange;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.onCountryChange=n,this.onCallingCodeChange=i}return bw(e,[{key:"reset",value:function(e){var t=e.country,n=e.callingCode;this.international=!1,this.missingPlus=!1,this.IDDPrefix=void 0,this.callingCode=void 0,this.digits="",this.resetNationalSignificantNumber(),this.initCountryAndCallingCode(t,n)}},{key:"resetNationalSignificantNumber",value:function(){this.nationalSignificantNumber=this.getNationalDigits(),this.nationalSignificantNumberMatchesInput=!0,this.nationalPrefix=void 0,this.carrierCode=void 0,this.complexPrefixBeforeNationalSignificantNumber=void 0}},{key:"update",value:function(e){for(var t=0,n=Object.keys(e);t<n.length;t++){var i=n[t];this[i]=e[i]}}},{key:"initCountryAndCallingCode",value:function(e,t){this.setCountry(e),this.setCallingCode(t)}},{key:"setCountry",value:function(e){this.country=e,this.onCountryChange(e)}},{key:"setCallingCode",value:function(e){this.callingCode=e,this.onCallingCodeChange(e,this.country)}},{key:"startInternationalNumber",value:function(e,t){this.international=!0,this.initCountryAndCallingCode(e,t)}},{key:"appendDigits",value:function(e){this.digits+=e}},{key:"appendNationalSignificantNumberDigits",value:function(e){this.nationalSignificantNumber+=e}},{key:"getNationalDigits",value:function(){return this.international?this.digits.slice((this.IDDPrefix?this.IDDPrefix.length:0)+(this.callingCode?this.callingCode.length:0)):this.digits}},{key:"getDigitsWithoutInternationalPrefix",value:function(){return this.international&&this.IDDPrefix?this.digits.slice(this.IDDPrefix.length):this.digits}}]),e}();function $w(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return kw(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return kw(e,t)}(e))||t){n&&(e=n);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function kw(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}var Cw="x",Sw=new RegExp(Cw);function Iw(e,t){if(t<1)return"";for(var n="";t>1;)1&t&&(n+=e),t>>=1,e+=e;return n+e}function Rw(e,t){return")"===e[t]&&t++,function(e){var t=[],n=0;for(;n<e.length;)"("===e[n]?t.push(n):")"===e[n]&&t.pop(),n++;var i=0,o="";t.push(e.length);for(var r=0,s=t;r<s.length;r++){var a=s[r];o+=e.slice(i,a),i=a+1}return o}(e.slice(0,t))}function Ew(e,t,n){var i=n.metadata,o=n.shouldTryNationalPrefixFormattingRule,r=n.getSeparatorAfterNationalPrefix;if(new RegExp("^(?:".concat(t.pattern(),")$")).test(e.nationalSignificantNumber))return function(e,t,n){var i=n.metadata,o=n.shouldTryNationalPrefixFormattingRule,r=n.getSeparatorAfterNationalPrefix;if(e.nationalSignificantNumber,e.international,e.nationalPrefix,e.carrierCode,o(t)){var s=xw(e,t,{useNationalPrefixFormattingRule:!0,getSeparatorAfterNationalPrefix:r,metadata:i});if(s)return s}return xw(e,t,{useNationalPrefixFormattingRule:!1,getSeparatorAfterNationalPrefix:r,metadata:i})}(e,t,{metadata:i,shouldTryNationalPrefixFormattingRule:o,getSeparatorAfterNationalPrefix:r})}function xw(e,t,n){var i=n.metadata,o=n.useNationalPrefixFormattingRule,r=n.getSeparatorAfterNationalPrefix,s=my(e.nationalSignificantNumber,t,{carrierCode:e.carrierCode,useInternationalFormat:e.international,withNationalPrefix:o,metadata:i});if(o||(e.nationalPrefix?s=e.nationalPrefix+r(t)+s:e.complexPrefixBeforeNationalSignificantNumber&&(s=e.complexPrefixBeforeNationalSignificantNumber+" "+s)),function(e,t){return ty(e)===t.getNationalDigits()}(s,e))return s}function Ow(e,t,n){return t&&function(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var Aw=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return Ow(e,[{key:"parse",value:function(e){if(this.context=[{or:!0,instructions:[]}],this.parsePattern(e),1!==this.context.length)throw new Error("Non-finalized contexts left when pattern parse ended");var t=this.context[0],n=t.branches,i=t.instructions;if(n)return{op:"|",args:n.concat([Pw(i)])};if(0===i.length)throw new Error("Pattern is required");return 1===i.length?i[0]:i}},{key:"startContext",value:function(e){this.context.push(e)}},{key:"endContext",value:function(){this.context.pop()}},{key:"getContext",value:function(){return this.context[this.context.length-1]}},{key:"parsePattern",value:function(e){if(!e)throw new Error("Pattern is required");var t=e.match(Mw);if(t){var n=t[1],i=e.slice(0,t.index),o=e.slice(t.index+n.length);switch(n){case"(?:":i&&this.parsePattern(i),this.startContext({or:!0,instructions:[],branches:[]});break;case")":if(!this.getContext().or)throw new Error('")" operator must be preceded by "(?:" operator');if(i&&this.parsePattern(i),0===this.getContext().instructions.length)throw new Error('No instructions found after "|" operator in an "or" group');var r=this.getContext().branches;r.push(Pw(this.getContext().instructions)),this.endContext(),this.getContext().instructions.push({op:"|",args:r});break;case"|":if(!this.getContext().or)throw new Error('"|" operator can only be used inside "or" groups');if(i&&this.parsePattern(i),!this.getContext().branches){if(1!==this.context.length)throw new Error('"branches" not found in an "or" group context');this.getContext().branches=[]}this.getContext().branches.push(Pw(this.getContext().instructions)),this.getContext().instructions=[];break;case"[":i&&this.parsePattern(i),this.startContext({oneOfSet:!0});break;case"]":if(!this.getContext().oneOfSet)throw new Error('"]" operator must be preceded by "[" operator');this.endContext(),this.getContext().instructions.push({op:"[]",args:Nw(i)});break;default:throw new Error("Unknown operator: ".concat(n))}o&&this.parsePattern(o)}else{if(jw.test(e))throw new Error("Illegal characters found in a pattern: ".concat(e));this.getContext().instructions=this.getContext().instructions.concat(e.split(""))}}}]),e}();function Nw(e){for(var t=[],n=0;n<e.length;){if("-"===e[n]){if(0===n||n===e.length-1)throw new Error("Couldn't parse a one-of set pattern: ".concat(e));for(var i=e[n-1].charCodeAt(0)+1,o=e[n+1].charCodeAt(0)-1,r=i;r<=o;)t.push(String.fromCharCode(r)),r++}else t.push(e[n]);n++}return t}var jw=/[\(\)\[\]\?\:\|]/,Mw=new RegExp("(\\||\\(\\?\\:|\\)|\\[|\\])");function Pw(e){return 1===e.length?e[0]:e}function Tw(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Ww(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Ww(e,t)}(e))||t){n&&(e=n);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Ww(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function Lw(e,t,n){return t&&function(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var Uw=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.matchTree=(new Aw).parse(t)}return Lw(e,[{key:"match",value:function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).allowOverflow;if(!e)throw new Error("String is required");var n=Dw(e.split(""),this.matchTree,!0);if(n&&n.match&&delete n.matchedChars,!n||!n.overflow||t)return n}}]),e}();function Dw(e,t,n){if("string"==typeof t){var i=e.join("");return 0===t.indexOf(i)?e.length===t.length?{match:!0,matchedChars:e}:{partialMatch:!0}:0===i.indexOf(t)?n&&e.length>t.length?{overflow:!0}:{match:!0,matchedChars:e.slice(0,t.length)}:void 0}if(Array.isArray(t)){for(var o=e.slice(),r=0;r<t.length;){var s=Dw(o,t[r],n&&r===t.length-1);if(!s)return;if(s.overflow)return s;if(!s.match){if(s.partialMatch)return{partialMatch:!0};throw new Error("Unsupported match result:\n".concat(JSON.stringify(s,null,2)))}if(0===(o=o.slice(s.matchedChars.length)).length)return r===t.length-1?{match:!0,matchedChars:e}:{partialMatch:!0};r++}return n?{overflow:!0}:{match:!0,matchedChars:e.slice(0,e.length-o.length)}}switch(t.op){case"|":for(var a,d,l=Tw(t.args);!(d=l()).done;){var c=Dw(e,d.value,n);if(c){if(c.overflow)return c;if(c.match)return{match:!0,matchedChars:c.matchedChars};if(!c.partialMatch)throw new Error("Unsupported match result:\n".concat(JSON.stringify(c,null,2)));a=!0}}return a?{partialMatch:!0}:void 0;case"[]":for(var u,h=Tw(t.args);!(u=h()).done;){var f=u.value;if(e[0]===f)return 1===e.length?{match:!0,matchedChars:e}:n?{overflow:!0}:{match:!0,matchedChars:[f]}}return;default:throw new Error("Unsupported instruction tree: ".concat(t))}}function Fw(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return _w(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _w(e,t)}(e))||t){n&&(e=n);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _w(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function qw(e,t,n){return t&&function(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var Bw=Iw("9",15),Vw=/[- ]/,Kw=new RegExp("["+Cm+"]*\\$1["+Cm+"]*(\\$\\d["+Cm+"]*)*$"),Hw=function(){function e(t){t.state;var n=t.metadata;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.metadata=n,this.resetFormat()}return qw(e,[{key:"resetFormat",value:function(){this.chosenFormat=void 0,this.template=void 0,this.nationalNumberTemplate=void 0,this.populatedNationalNumberTemplate=void 0,this.populatedNationalNumberTemplatePosition=-1}},{key:"reset",value:function(e,t){this.resetFormat(),e?(this.isNANP="1"===e.callingCode(),this.matchingFormats=e.formats(),t.nationalSignificantNumber&&this.narrowDownMatchingFormats(t)):(this.isNANP=void 0,this.matchingFormats=[])}},{key:"format",value:function(e,t){var n=this;if(function(e,t){return"IS_POSSIBLE"===sy(e,t)}(t.nationalSignificantNumber,this.metadata))for(var i,o=Fw(this.matchingFormats);!(i=o()).done;){var r=i.value,s=Ew(t,r,{metadata:this.metadata,shouldTryNationalPrefixFormattingRule:function(e){return n.shouldTryNationalPrefixFormattingRule(e,{international:t.international,nationalPrefix:t.nationalPrefix})},getSeparatorAfterNationalPrefix:function(e){return n.getSeparatorAfterNationalPrefix(e)}});if(s)return this.resetFormat(),this.chosenFormat=r,this.setNationalNumberTemplate(s.replace(/\d/g,Cw),t),this.populatedNationalNumberTemplate=s,this.populatedNationalNumberTemplatePosition=this.template.lastIndexOf(Cw),s}return this.formatNationalNumberWithNextDigits(e,t)}},{key:"formatNationalNumberWithNextDigits",value:function(e,t){var n=this.chosenFormat,i=this.chooseFormat(t);if(i)return i===n?this.formatNextNationalNumberDigits(e):this.formatNextNationalNumberDigits(t.getNationalDigits())}},{key:"narrowDownMatchingFormats",value:function(e){var t=this,n=e.nationalSignificantNumber,i=e.nationalPrefix,o=e.international,r=n,s=r.length-3;s<0&&(s=0),this.matchingFormats=this.matchingFormats.filter((function(e){return t.formatSuits(e,o,i)&&t.formatMatches(e,r,s)})),this.chosenFormat&&-1===this.matchingFormats.indexOf(this.chosenFormat)&&this.resetFormat()}},{key:"formatSuits",value:function(e,t,n){return!(n&&!e.usesNationalPrefix()&&!e.nationalPrefixIsOptionalWhenFormattingInNationalFormat())&&!(!t&&!n&&e.nationalPrefixIsMandatoryWhenFormattingInNationalFormat())}},{key:"formatMatches",value:function(e,t,n){var i=e.leadingDigitsPatterns().length;if(0===i)return!0;n=Math.min(n,i-1);var o=e.leadingDigitsPatterns()[n];if(t.length<3)try{return void 0!==new Uw(o).match(t,{allowOverflow:!0})}catch(e){return console.error(e),!0}return new RegExp("^(".concat(o,")")).test(t)}},{key:"getFormatFormat",value:function(e,t){return t?e.internationalFormat():e.format()}},{key:"chooseFormat",value:function(e){for(var t,n=this,i=function(){var i=t.value;return n.chosenFormat===i?"break":Kw.test(n.getFormatFormat(i,e.international))?n.createTemplateForFormat(i,e)?(n.chosenFormat=i,"break"):(n.matchingFormats=n.matchingFormats.filter((function(e){return e!==i})),"continue"):"continue"},o=Fw(this.matchingFormats.slice());!(t=o()).done;){var r=i();if("break"===r)break}return this.chosenFormat||this.resetFormat(),this.chosenFormat}},{key:"createTemplateForFormat",value:function(e,t){if(!(e.pattern().indexOf("|")>=0)){var n=this.getTemplateForFormat(e,t);return n?(this.setNationalNumberTemplate(n,t),!0):void 0}}},{key:"getSeparatorAfterNationalPrefix",value:function(e){return this.isNANP||e&&e.nationalPrefixFormattingRule()&&Vw.test(e.nationalPrefixFormattingRule())?" ":""}},{key:"getInternationalPrefixBeforeCountryCallingCode",value:function(e,t){var n=e.IDDPrefix,i=e.missingPlus;return n?t&&!1===t.spacing?n:n+" ":i?"":"+"}},{key:"getTemplate",value:function(e){if(this.template){for(var t=-1,n=0,i=e.international?this.getInternationalPrefixBeforeCountryCallingCode(e,{spacing:!1}):"";n<i.length+e.getDigitsWithoutInternationalPrefix().length;)t=this.template.indexOf(Cw,t+1),n++;return Rw(this.template,t+1)}}},{key:"setNationalNumberTemplate",value:function(e,t){this.nationalNumberTemplate=e,this.populatedNationalNumberTemplate=e,this.populatedNationalNumberTemplatePosition=-1,t.international?this.template=this.getInternationalPrefixBeforeCountryCallingCode(t).replace(/[\d\+]/g,Cw)+Iw(Cw,t.callingCode.length)+" "+e:this.template=e}},{key:"getTemplateForFormat",value:function(e,t){var n=t.nationalSignificantNumber,i=t.international,o=t.nationalPrefix,r=t.complexPrefixBeforeNationalSignificantNumber,s=e.pattern();s=s.replace(/\[([^\[\]])*\]/g,"\\d").replace(/\d(?=[^,}][^,}])/g,"\\d");var a=Bw.match(s)[0];if(!(n.length>a.length)){var d=new RegExp("^"+s+"$"),l=n.replace(/\d/g,"9");d.test(l)&&(a=l);var c,u=this.getFormatFormat(e,i);if(this.shouldTryNationalPrefixFormattingRule(e,{international:i,nationalPrefix:o})){var h=u.replace(gy,e.nationalPrefixFormattingRule());if(ty(e.nationalPrefixFormattingRule())===(o||"")+ty("$1")&&(u=h,c=!0,o))for(var f=o.length;f>0;)u=u.replace(/\d/,Cw),f--}var p=a.replace(new RegExp(s),u).replace(new RegExp("9","g"),Cw);return c||(r?p=Iw(Cw,r.length)+" "+p:o&&(p=Iw(Cw,o.length)+this.getSeparatorAfterNationalPrefix(e)+p)),i&&(p=vy(p)),p}}},{key:"formatNextNationalNumberDigits",value:function(e){var t=function(e,t,n){for(var i,o=$w(n.split(""));!(i=o()).done;){var r=i.value;if(e.slice(t+1).search(Sw)<0)return;t=e.search(Sw),e=e.replace(Sw,r)}return[e,t]}(this.populatedNationalNumberTemplate,this.populatedNationalNumberTemplatePosition,e);if(t)return this.populatedNationalNumberTemplate=t[0],this.populatedNationalNumberTemplatePosition=t[1],Rw(this.populatedNationalNumberTemplate,this.populatedNationalNumberTemplatePosition+1);this.resetFormat()}},{key:"shouldTryNationalPrefixFormattingRule",value:function(e,t){var n=t.international,i=t.nationalPrefix;if(e.nationalPrefixFormattingRule()){var o=e.usesNationalPrefix();if(o&&i||!o&&!n)return!0}}}]),e}();function zw(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==n)return;var i,o,r=[],s=!0,a=!1;try{for(n=n.call(e);!(s=(i=n.next()).done)&&(r.push(i.value),!t||r.length!==t);s=!0);}catch(e){a=!0,o=e}finally{try{s||null==n.return||n.return()}finally{if(a)throw o}}return r}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return Jw(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Jw(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Jw(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function Gw(e,t,n){return t&&function(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var Zw=new RegExp("^"+("["+Cm+km+"]+")+"$","i"),Yw="(?:[++]["+Cm+km+"]*|["+Cm+km+"]+)",Xw=new RegExp("[^"+Cm+km+"]+.*$"),Qw=/[^\d\[\]]/,e$=function(){function e(t){var n=t.defaultCountry,i=t.defaultCallingCode,o=t.metadata,r=t.onNationalSignificantNumberChange;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.defaultCountry=n,this.defaultCallingCode=i,this.metadata=o,this.onNationalSignificantNumberChange=r}return Gw(e,[{key:"input",value:function(e,t){var n,i=function(e){var t=function(e){var t=function(e){var t,n=e.search(Yw);if(n<0)return;e=e.slice(n),"+"===e[0]&&(t=!0,e=e.slice(1));e=e.replace(Xw,""),t&&(e="+"+e);return e}(e)||"";if("+"===t[0])return[t.slice(1),!0];return[t]}(e),n=zw(t,2),i=n[0],o=n[1];Zw.test(i)||(i="");return[i,o]}(e),o=zw(i,2),r=o[0],s=o[1],a=ty(r);return s&&(t.digits||(t.startInternationalNumber(),a||(n=!0))),a&&this.inputDigits(a,t),{digits:a,justLeadingPlus:n}}},{key:"inputDigits",value:function(e,t){var n=t.digits,i=n.length<3&&n.length+e.length>=3;if(t.appendDigits(e),i&&this.extractIddPrefix(t),this.isWaitingForCountryCallingCode(t)){if(!this.extractCountryCallingCode(t))return}else t.appendNationalSignificantNumberDigits(e);t.international||this.hasExtractedNationalSignificantNumber||this.extractNationalSignificantNumber(t.getNationalDigits(),(function(e){return t.update(e)}))}},{key:"isWaitingForCountryCallingCode",value:function(e){var t=e.international,n=e.callingCode;return t&&!n}},{key:"extractCountryCallingCode",value:function(e){var t=Fy("+"+e.getDigitsWithoutInternationalPrefix(),this.defaultCountry,this.defaultCallingCode,this.metadata.metadata),n=t.countryCallingCode,i=t.number;if(n)return e.setCallingCode(n),e.update({nationalSignificantNumber:i}),!0}},{key:"reset",value:function(e){if(e){this.hasSelectedNumberingPlan=!0;var t=e._nationalPrefixForParsing();this.couldPossiblyExtractAnotherNationalSignificantNumber=t&&Qw.test(t)}else this.hasSelectedNumberingPlan=void 0,this.couldPossiblyExtractAnotherNationalSignificantNumber=void 0}},{key:"extractNationalSignificantNumber",value:function(e,t){if(this.hasSelectedNumberingPlan){var n=Ly(e,this.metadata),i=n.nationalPrefix,o=n.nationalNumber,r=n.carrierCode;if(o!==e)return this.onExtractedNationalNumber(i,r,o,e,t),!0}}},{key:"extractAnotherNationalSignificantNumber",value:function(e,t,n){if(!this.hasExtractedNationalSignificantNumber)return this.extractNationalSignificantNumber(e,n);if(this.couldPossiblyExtractAnotherNationalSignificantNumber){var i=Ly(e,this.metadata),o=i.nationalPrefix,r=i.nationalNumber,s=i.carrierCode;if(r!==t)return this.onExtractedNationalNumber(o,s,r,e,n),!0}}},{key:"onExtractedNationalNumber",value:function(e,t,n,i,o){var r,s,a=i.lastIndexOf(n);if(a>=0&&a===i.length-n.length){s=!0;var d=i.slice(0,a);d!==e&&(r=d)}o({nationalPrefix:e,carrierCode:t,nationalSignificantNumber:n,nationalSignificantNumberMatchesInput:s,complexPrefixBeforeNationalSignificantNumber:r}),this.hasExtractedNationalSignificantNumber=!0,this.onNationalSignificantNumberChange()}},{key:"reExtractNationalSignificantNumber",value:function(e){return!!this.extractAnotherNationalSignificantNumber(e.getNationalDigits(),e.nationalSignificantNumber,(function(t){return e.update(t)}))||(this.extractIddPrefix(e)||this.fixMissingPlus(e)?(this.extractCallingCodeAndNationalSignificantNumber(e),!0):void 0)}},{key:"extractIddPrefix",value:function(e){var t=e.international,n=e.IDDPrefix,i=e.digits;if(e.nationalSignificantNumber,!t&&!n){var o=Wy(i,this.defaultCountry,this.defaultCallingCode,this.metadata.metadata);return void 0!==o&&o!==i?(e.update({IDDPrefix:i.slice(0,i.length-o.length)}),this.startInternationalNumber(e,{country:void 0,callingCode:void 0}),!0):void 0}}},{key:"fixMissingPlus",value:function(e){if(!e.international){var t=Dy(e.digits,this.defaultCountry,this.defaultCallingCode,this.metadata.metadata),n=t.countryCallingCode;if(t.number,n)return e.update({missingPlus:!0}),this.startInternationalNumber(e,{country:e.country,callingCode:n}),!0}}},{key:"startInternationalNumber",value:function(e,t){var n=t.country,i=t.callingCode;e.startInternationalNumber(n,i),e.nationalSignificantNumber&&(e.resetNationalSignificantNumber(),this.onNationalSignificantNumberChange(),this.hasExtractedNationalSignificantNumber=void 0)}},{key:"extractCallingCodeAndNationalSignificantNumber",value:function(e){this.extractCountryCallingCode(e)&&this.extractNationalSignificantNumber(e.getNationalDigits(),(function(t){return e.update(t)}))}}]),e}();function t$(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==n)return;var i,o,r=[],s=!0,a=!1;try{for(n=n.call(e);!(s=(i=n.next()).done)&&(r.push(i.value),!t||r.length!==t);s=!0);}catch(e){a=!0,o=e}finally{try{s||null==n.return||n.return()}finally{if(a)throw o}}return r}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return n$(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return n$(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n$(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function i$(e,t,n){return t&&function(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var o$,r$=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.metadata=new Mm(n);var i=t$(this.getCountryAndCallingCode(t),2),o=i[0],r=i[1];this.defaultCountry=o,this.defaultCallingCode=r,this.reset()}return i$(e,[{key:"getCountryAndCallingCode",value:function(e){var t,n;return e&&(Em(e)?(t=e.defaultCountry,n=e.defaultCallingCode):t=e),t&&!this.metadata.hasCountry(t)&&(t=void 0),[t,n]}},{key:"input",value:function(e){var t=this.parser.input(e,this.state),n=t.digits;if(t.justLeadingPlus)this.formattedOutput="+";else if(n){var i;if(this.determineTheCountryIfNeeded(),this.state.nationalSignificantNumber&&this.formatter.narrowDownMatchingFormats(this.state),this.metadata.hasSelectedNumberingPlan()&&(i=this.formatter.format(n,this.state)),void 0===i&&this.parser.reExtractNationalSignificantNumber(this.state)){this.determineTheCountryIfNeeded();var o=this.state.getNationalDigits();o&&(i=this.formatter.format(o,this.state))}this.formattedOutput=i?this.getFullNumber(i):this.getNonFormattedNumber()}return this.formattedOutput}},{key:"reset",value:function(){var e=this;return this.state=new ww({onCountryChange:function(t){e.country=t},onCallingCodeChange:function(t,n){e.metadata.selectNumberingPlan(n,t),e.formatter.reset(e.metadata.numberingPlan,e.state),e.parser.reset(e.metadata.numberingPlan)}}),this.formatter=new Hw({state:this.state,metadata:this.metadata}),this.parser=new e$({defaultCountry:this.defaultCountry,defaultCallingCode:this.defaultCallingCode,metadata:this.metadata,state:this.state,onNationalSignificantNumberChange:function(){e.determineTheCountryIfNeeded(),e.formatter.reset(e.metadata.numberingPlan,e.state)}}),this.state.reset({country:this.defaultCountry,callingCode:this.defaultCallingCode}),this.formattedOutput="",this}},{key:"isInternational",value:function(){return this.state.international}},{key:"getCallingCode",value:function(){if(this.isInternational())return this.state.callingCode}},{key:"getCountryCallingCode",value:function(){return this.getCallingCode()}},{key:"getCountry",value:function(){if(this.state.digits)return this._getCountry()}},{key:"_getCountry",value:function(){return this.state.country}},{key:"determineTheCountryIfNeeded",value:function(){this.state.country&&!this.isCountryCallingCodeAmbiguous()||this.determineTheCountry()}},{key:"getFullNumber",value:function(e){var t=this;if(this.isInternational()){var n=function(e){return t.formatter.getInternationalPrefixBeforeCountryCallingCode(t.state,{spacing:!!e})+e},i=this.state.callingCode;return n(i?e?"".concat(i," ").concat(e):i:"".concat(this.state.getDigitsWithoutInternationalPrefix()))}return e}},{key:"getNonFormattedNationalNumberWithPrefix",value:function(){var e=this.state,t=e.nationalSignificantNumber,n=e.complexPrefixBeforeNationalSignificantNumber,i=e.nationalPrefix,o=t,r=n||i;return r&&(o=r+o),o}},{key:"getNonFormattedNumber",value:function(){var e=this.state.nationalSignificantNumberMatchesInput;return this.getFullNumber(e?this.getNonFormattedNationalNumberWithPrefix():this.state.getNationalDigits())}},{key:"getNonFormattedTemplate",value:function(){var e=this.getNonFormattedNumber();if(e)return e.replace(/[\+\d]/g,Cw)}},{key:"isCountryCallingCodeAmbiguous",value:function(){var e=this.state.callingCode,t=this.metadata.getCountryCodesForCallingCode(e);return t&&t.length>1}},{key:"determineTheCountry",value:function(){this.state.setCountry(Vy(this.isInternational()?this.state.callingCode:this.defaultCallingCode,{nationalNumber:this.state.nationalSignificantNumber,defaultCountry:this.defaultCountry,metadata:this.metadata}))}},{key:"getNumberValue",value:function(){var e=this.state,t=e.digits,n=e.callingCode,i=e.country,o=e.nationalSignificantNumber;if(t)return this.isInternational()?n?"+"+n+o:"+"+t:i||n?"+"+(i?this.metadata.countryCallingCode():n)+o:void 0}},{key:"getNumber",value:function(){var e=this.state,t=e.nationalSignificantNumber,n=e.carrierCode,i=e.callingCode,o=this._getCountry();if(t&&(o||i)){if(o&&o===this.defaultCountry){var r=new Mm(this.metadata.metadata);r.selectNumberingPlan(o);var s=r.numberingPlan.callingCode(),a=this.metadata.getCountryCodesForCallingCode(s);if(a.length>1){var d=By(t,{countries:a,defaultCountry:this.defaultCountry,metadata:this.metadata.metadata});d&&(o=d)}}var l=new My(o||i,t,this.metadata.metadata);return n&&(l.carrierCode=n),l}}},{key:"isPossible",value:function(){var e=this.getNumber();return!!e&&e.isPossible()}},{key:"isValid",value:function(){var e=this.getNumber();return!!e&&e.isValid()}},{key:"getNationalNumber",value:function(){return this.state.nationalSignificantNumber}},{key:"getChars",value:function(){return(this.state.international?"+":"")+this.state.digits}},{key:"getTemplate",value:function(){return this.formatter.getTemplate(this.state)||this.getNonFormattedTemplate()||""}}]),e}();function s$(){return function(e,t){var n=Array.prototype.slice.call(t);return n.push(lm),e.apply(this,n)}(vb,arguments)}function a$(e,t){return yw.call(this,e,t,lm)}function d$(e){return r$.call(this,e,lm)}function l$(){return Mm.call(this,lm)}a$.prototype=Object.create(yw.prototype,{}),a$.prototype.constructor=a$,d$.prototype=Object.create(r$.prototype,{}),d$.prototype.constructor=d$,l$.prototype=Object.create(Mm.prototype,{}),l$.prototype.constructor=l$,function(e){e[e.text=1]="text",e[e.numeric=2]="numeric",e[e.bool=3]="bool",e[e.singleSelect=4]="singleSelect",e[e.array=5]="array",e[e.date=6]="date"}(o$||(o$={}));const c$=(e,t)=>Object.entries(e).reduce(((e,[n,i])=>{const[o,...r]=n.split(".");return t!==o?Object.assign(e,{[n]:i}):(e[o]||(e[o]={}),e[o][r.join(".")]=i,e)}),{}),u$=(e,t)=>Object.fromEntries(Object.entries(e||{}).map((([e,n])=>[`${t}.${e}`,n]))),h$=(e,t)=>e===o$.date?(e=>new Date(Number(e)).toLocaleDateString("en-US"))(`${t}`):t;function f$(e){return new URLSearchParams(window.location.search).get(e)}const p$={enabled:"active",disabled:"disabled",invited:"invited"},v$={password:"Passwords",totp:"TOTP",recovery_codes:"Recovery Codes",security_questions:"Security Questions"},g$=e=>e.tenantRoles.data,m$=e=>e.selectedUsersLoginIds,y$=e=>e.notifications,b$=e=>e.customAttributes.data,w$=Al((e=>e.subTenantRoles.data),(e=>Object.fromEntries(e.map((({tenantId:e,tenantName:t,roleNames:n})=>[e,t?{label:t,options:n}:n]))))),$$=Al(w$,(e=>Object.keys(e).length>0)),k$=Al(b$,(e=>Object.fromEntries(e.map((e=>[e.name,e.type]))))),C$=Al((e=>e.usersList.data),k$,((e,t)=>e.map((e=>Object.assign(Object.assign({},e),{customAttributes:Object.fromEntries(Object.entries(e.customAttributes||{}).map((([e,n])=>[e,h$(t[e],n)])))}))))),S$=e=>{const t=[e.roleNames||[],...(e.userTenants||[]).map((e=>e.roleNames||[]))].filter((e=>e.length>0));if(0===t.length)return e.roleNames||[];const n=t.map((e=>[...e].sort().join("\0")));return n.every((e=>e===n[0]))?t[0]:"Multiple roles"},I$=e=>{if(!(null==e?void 0:e.lockReason))return"";const t=v$[e.lockReason]||e.lockReason,n=e.tempLockExpiration||0;return 1e3*n>Date.now()?`Temp. Locked - ${t}`:"disabled"===e.status&&0===n?`Locked - ${t}`:""},R$=Al(C$,(e=>e.map((e=>{var t;return Object.assign(Object.assign(Object.assign({},e),u$(null==e?void 0:e.customAttributes,"customAttributes")),{createdTimeFormatted:new Date(1e3*((null==e?void 0:e.createdTime)||0)).toLocaleString(),status:p$[e.status]||e.status,lockReasonFormatted:I$(e),roles:S$(e),tenants:null===(t=e.userTenants)||void 0===t?void 0:t.map((e=>e.tenantName||e.tenantId))})})))),E$=Al(m$,R$,((e,t)=>t.filter((t=>e.includes(t.loginIds))))),x$=Al(E$,(e=>e.map((e=>e.userId)))),O$=Al(E$,(e=>e.map((({userId:e,loginIds:t})=>({userId:e,loginIds:t}))))),A$=Al(E$,(e=>e.map((e=>({userId:e.userId,roles:e.roleNames}))))),N$=Al(E$,(e=>e.map((e=>e.status)))),j$=Al(E$,(e=>e.every((e=>e.editable)))),M$=Al(m$,(e=>!!e.length)),P$=Al(m$,(e=>1===e.length)),T$=Al(m$,(e=>{var t;return null===(t=null==e?void 0:e[0])||void 0===t?void 0:t[0]})),W$=Al(P$,N$,((e,t)=>e&&t.every((e=>e===p$.enabled)))),L$=Al(N$,(e=>e.every((e=>e===p$.disabled)))),U$=Al(E$,(e=>{var t;return 1===e.length?e[0].name||e[0].email||(null===(t=e[0].loginIds)||void 0===t?void 0:t[0]):`${e.length} users`})),D$=Al(P$,L$,j$,((e,t,n)=>e&&t&&n)),F$=Al(P$,W$,j$,((e,t,n)=>e&&t&&n)),_$=Al(P$,j$,((e,t)=>e&&t)),q$=Al(P$,j$,((e,t)=>e&&t)),B$=Al(P$,j$,((e,t)=>e&&t)),V$=M$,K$=e=>(...t)=>n=>{n.addCase(e.pending,((e,n)=>{t.forEach((({onPending:t})=>{null==t||t(e,n)}))})),n.addCase(e.fulfilled,((e,n)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,n)}))})),n.addCase(e.rejected,((e,n)=>{t.forEach((({onRejected:t})=>{null==t||t(e,n)}))}))},H$=e=>({onFulfilled:t=>{e(t).loading=!1},onPending:t=>{e(t).loading=!0,e(t).error=null},onRejected:(t,n)=>{e(t).loading=!1,e(t).error=n.error}}),z$=({getErrorMsg:e,getSuccessMsg:t})=>({onFulfilled:(e,n)=>{t&&e.notifications.push({type:"success",msg:t(n)})},onRejected:(t,n)=>{e&&t.notifications.push({type:"error",msg:e(n)})}}),J$=lc("users/create",((e,{extra:{api:t}})=>t.user.create(e))),G$=K$(J$)({onFulfilled:(e,t)=>{var n;const i=(null===(n=t.payload)||void 0===n?void 0:n.userId)?e.usersList.data.findIndex((e=>e.userId===t.payload.userId)):-1;-1!==i?e.usersList.data[i]=t.payload:e.usersList.data.unshift(t.payload)}},H$((e=>e.createUser)),z$({getSuccessMsg:()=>"User created successfully",getErrorMsg:e=>{var t;const n=null===(t=e.error)||void 0===t?void 0:t.message;return`\n <div>\n <div>Failed to create user</div>\n ${Ki(n)}\n </div>`}})),Z$={action:J$,reducer:G$},Y$=lc("users/delete",((e,{extra:{api:t}})=>t.user.deleteBatch(e))),X$=K$(Y$)({onFulfilled:(e,t)=>{e.usersList.data=e.usersList.data.filter((e=>!t.meta.arg.includes(e.userId))),e.selectedUsersLoginIds=[]}},H$((e=>e.deleteUser)),z$({getSuccessMsg:e=>Mi(e.meta.arg.length)`${["",e.meta.arg.length]} ${["U","u"]}ser${["","s"]} deleted successfully`,getErrorMsg:e=>Mi(e.meta.arg.length)`Failed to delete user${["","s"]}`})),Q$={action:Y$,reducer:X$},ek=lc("users/setTempPassword",((e,{extra:{api:t}})=>t.user.setTempPassword(e))),tk=K$(ek)(H$((e=>e.setTempUserPassword)),z$({getSuccessMsg:()=>"Successfully reset user password",getErrorMsg:e=>{var t;const n=null===(t=e.error)||void 0===t?void 0:t.message;return`\n <div>\n <div>Failed to reset user's password</div>\n ${Ki(n)}\n </div>`}})),nk={action:ek,reducer:tk},ik=lc("users/getCustomAttributes",((e,{extra:{api:t}})=>t.user.getCustomAttributes())),ok=K$(ik)({onFulfilled:(e,t)=>{e.customAttributes.data=t.payload}},H$((e=>e.customAttributes))),rk={action:ik,reducer:ok},sk=lc("users/search",((e,{extra:{api:t},getState:n})=>{const i=n().searchParams;return t.user.search(Object.assign(Object.assign({},i),e))})),ak=K$(sk)({onPending:(e,t)=>{e.searchParams=Object.assign(Object.assign({},e.searchParams),t.meta.arg)},onFulfilled:(e,t)=>{e.usersList.data=t.payload}},H$((e=>e.usersList))),dk={action:sk,reducer:ak},lk=lc("tenant/getTenantRoles",((e,{extra:{api:t}})=>t.tenant.getTenantRoles())),ck=K$(lk)({onFulfilled:(e,t)=>{e.tenantRoles.data=t.payload.roles}},H$((e=>e.tenantRoles))),uk={action:lk,reducer:ck},hk=lc("tenant/getSubTenantRoles",((e,{extra:{api:t}})=>t.tenant.getSubTenantRoles())),fk=K$(hk)({onFulfilled:(e,t)=>{e.subTenantRoles.data=t.payload.roles},onRejected:e=>{e.subTenantRoles.data=[]}},H$((e=>e.subTenantRoles))),pk={action:hk,reducer:fk},vk=lc("users/update",((e,{extra:{api:t}})=>t.user.update(e))),gk=K$(vk)({onFulfilled:(e,t)=>{const n=e.usersList.data.findIndex((e=>Ai(e.loginIds,t.payload.loginIds)));-1!==n&&(e.usersList.data[n]=t.payload)}},H$((e=>e.updateUser)),z$({getSuccessMsg:()=>"User updated successfully",getErrorMsg:e=>{var t;const n=null===(t=e.error)||void 0===t?void 0:t.message;return`\n <div>\n <div>Failed to update user</div>\n ${Ki(n)}\n </div>`}})),mk={action:vk,reducer:gk},yk=lc("users/enable",((e,{extra:{api:t}})=>t.user.enable(e))),bk=K$(yk)({onFulfilled:(e,t)=>{var n;const i=e.usersList.data.findIndex((e=>{var n;return Ai(e.loginIds,null===(n=t.payload.user)||void 0===n?void 0:n.loginIds)}));-1!==i&&(e.usersList.data[i].status=null===(n=t.payload.user)||void 0===n?void 0:n.status)}},H$((e=>e.enableUser)),z$({getSuccessMsg:()=>"User enabled successfully",getErrorMsg:e=>{var t;const n=null===(t=e.error)||void 0===t?void 0:t.message;return`\n <div>\n <div>Failed to enable user</div>\n ${Ki(n)}\n </div>`}})),wk={action:yk,reducer:bk},$k=lc("users/disable",((e,{extra:{api:t}})=>t.user.disable(e))),kk=K$($k)({onFulfilled:(e,t)=>{var n;const i=e.usersList.data.findIndex((e=>{var n;return Ai(e.loginIds,null===(n=t.payload.user)||void 0===n?void 0:n.loginIds)}));-1!==i&&(e.usersList.data[i].status=null===(n=t.payload.user)||void 0===n?void 0:n.status)}},H$((e=>e.disableUser)),z$({getSuccessMsg:()=>"User disabled successfully",getErrorMsg:e=>{var t;const n=null===(t=e.error)||void 0===t?void 0:t.message;return`\n <div>\n <div>Failed to disable user</div>\n ${Ki(n)}\n </div>`}})),Ck={action:$k,reducer:kk},Sk=lc("users/removePasskey",((e,{extra:{api:t}})=>t.user.removePasskey(e))),Ik={action:Sk,reducer:K$(Sk)(H$((e=>e.removePasskey)),z$({getSuccessMsg:()=>"Successfully removed user's passkey",getErrorMsg:e=>{var t;const n=null===(t=e.error)||void 0===t?void 0:t.message;return`\n <div>\n <div>Failed to remove user's passkey</div>\n ${Ki(n)}\n </div>`}}))},Rk={usersList:{data:[],loading:!1,error:null},createUser:{loading:!1,error:null},updateUser:{loading:!1,error:null},deleteUser:{loading:!1,error:null},enableUser:{loading:!1,error:null},disableUser:{loading:!1,error:null},removePasskey:{loading:!1,error:null},setTempUserPassword:{loading:!1,error:null},customAttributes:{loading:!1,error:null,data:[]},tenantRoles:{loading:!1,error:null,data:[]},subTenantRoles:{loading:!1,error:null,data:[]},searchParams:{text:"",sort:[]},selectedUsersLoginIds:[],notifications:[]},Ek="/v1/mgmt/user/search",xk="/v1/mgmt/user/delete/batch",Ok="/v1/mgmt/user/create",Ak="/v1/mgmt/user/patch",Nk="/v1/mgmt/user/update/status",jk="/v1/mgmt/user/password/set/temporary",Mk="/v1/mgmt/user/passkeys/delete",Pk="/v1/mgmt/user/customattributes",Tk="/v1/mgmt/role/all",Wk="/v1/mgmt/role/subtenant/all",Lk=e=>c(void 0,void 0,void 0,(function*(){const t=yield e.text(),n=JSON.parse(t);if(!e.ok){const t=`${n.errorDescription}${n.errorMessage?`: ${n.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(n),e.text=()=>Promise.resolve(t)})),Uk=({httpClient:e,tenant:t,mock:n})=>({search:(...i)=>c(void 0,[...i],void 0,(function*(i={}){const{limit:o=1e4}=i,r=l(i,["limit"]);if(n)return(e=>c(void 0,[e],void 0,(function*({text:e,sort:t}){return new Promise((n=>{const i=[],o=(new Date).getTime();for(let e=1;e<10;e+=1)i.push({loginIds:[`user${e}@company.com`],externalIds:[`user${e}@company.com`],userId:`user-${e}`,name:`User ${e}`,email:`user${e}@company.com`,roleNames:[`Role ${e}`],phone:`+1-202-555-010${e}`,recoveryEmail:`recovery${e}@company.com`,recoveryPhone:`+1-202-555-020${e}`,verifiedEmail:!0,verifiedPhone:!0,verifiedRecoveryEmail:!0,verifiedRecoveryPhone:!0,userTenants:[{tenantId:"sub-tenant-1",tenantName:"Hurray",roleNames:["Role 1","Role 2"]}],status:"enabled",editable:!0,createdTime:o,createdTimeFormatted:new Date(1e3*(o||0)).toLocaleString(),customAttributes:{},familyName:"",givenName:"",middleName:"",picture:"",password:!0,SAML:e%3==0,OIDC:e%3==1,SCIM:e%3==2,test:!1,TOTP:!1,webauthn:!1});t.forEach((e=>{i.sort(((t,n)=>((e,t,n)=>{if("boolean"==typeof e&&"boolean"==typeof t){const i=e?1:0,o=t?1:0;return n?i-o:o-i}const i=(null==e?void 0:e.toString())||"",o=(null==t?void 0:t.toString())||"";return n?o.localeCompare(i):i.localeCompare(o)})(t[e.field],n[e.field],e.desc)))})),n(i.filter((t=>t.name.toLowerCase().includes(e.toLowerCase())||t.phone.toLowerCase().includes(e.toLowerCase())||t.status.toLowerCase().includes(e.toLowerCase())||"active"===e.toLowerCase()||t.familyName.toLowerCase().includes(e.toLowerCase())||t.givenName.toLowerCase().includes(e.toLowerCase())||t.middleName.toLowerCase().includes(e.toLowerCase())||t.email.toLowerCase().includes(e.toLowerCase()))))}))})))(Object.assign(Object.assign({},r),{limit:o}));const s=yield e.post(Ek,Object.assign(Object.assign({},r),{limit:o,withTestUser:!1}),{queryParams:{tenant:t}});return yield Lk(s),(yield s.json()).users})),deleteBatch:i=>c(void 0,void 0,void 0,(function*(){if(n)return c(void 0,void 0,void 0,(function*(){}));const o=yield e.post(xk,{userIds:i},{queryParams:{tenant:t}});return yield Lk(o),o.json()})),create:i=>c(void 0,[i],void 0,(function*({loginId:i,email:o,phone:r,recoveryEmail:s,recoveryPhone:a,displayName:d,roles:l,customAttributes:u,picture:h,verifiedEmail:f,verifiedPhone:p,givenName:v,middleName:g,familyName:m,additionalLoginIds:y,sendSMS:b,sendMail:w,inviteUrl:$,invite:k,userTenants:C}){if(n)return(e=>c(void 0,[e],void 0,(function*({loginId:e,email:t,phone:n,displayName:i,roles:o,customAttributes:r,picture:s,verifiedEmail:a,verifiedPhone:d,givenName:l,middleName:c,familyName:u,userTenants:h}){return new Promise((f=>{const p=Math.random().toString(10).substring(15);f({loginIds:[e],externalIds:[e],userId:`user-${p}`,email:t,phone:n,name:i,roleNames:o,customAttributes:r,picture:s,recoveryEmail:"",recoveryPhone:"",verifiedEmail:a,verifiedPhone:d,verifiedRecoveryEmail:!1,verifiedRecoveryPhone:!1,givenName:l,middleName:c,familyName:u,createdTime:(new Date).getTime(),editable:!0,password:!0,SAML:!1,SCIM:!1,OIDC:!1,status:"enabled",test:!1,TOTP:!1,userTenants:h||[],webauthn:!1})}))})))({loginId:i,email:o,phone:r,recoveryEmail:s,recoveryPhone:a,displayName:d,roles:l,customAttributes:u,picture:h,verifiedEmail:f,verifiedPhone:p,givenName:v,middleName:g,familyName:m,additionalLoginIds:y,sendSMS:b,sendMail:w,inviteUrl:$,invite:k,userTenants:C});const S=yield e.post(Ok,{loginId:i,email:o,phone:r,recoveryEmail:s,recoveryPhone:a,displayName:d,givenName:v,middleName:g,familyName:m,roleNames:l,userTenants:C,customAttributes:u,picture:h,verifiedEmail:f,verifiedPhone:p,verifiedRecoveryEmail:!!s||void 0,verifiedRecoveryPhone:!!a||void 0,additionalLoginIds:y,sendSMS:b,sendMail:w,inviteUrl:$,invite:k},{queryParams:{tenant:t}});return yield Lk(S),(yield S.json()).user})),update:i=>c(void 0,[i],void 0,(function*({loginId:i,email:o,phone:r,recoveryEmail:s,recoveryPhone:a,displayName:d,roles:l,customAttributes:u,picture:h,verifiedEmail:f,verifiedPhone:p,givenName:v,middleName:g,familyName:m,additionalLoginIds:y,userTenants:b}){if(n)return(e=>c(void 0,[e],void 0,(function*({loginId:e,email:t,phone:n,displayName:i,roles:o,customAttributes:r,picture:s,verifiedEmail:a,verifiedPhone:d,givenName:l,middleName:c,familyName:u,userTenants:h}){return new Promise((f=>{f({loginIds:[e],externalIds:[e],userId:e,email:t,phone:n,name:i,roleNames:o,customAttributes:r||{},picture:s,recoveryEmail:"",recoveryPhone:"",verifiedEmail:a,verifiedPhone:d,verifiedRecoveryEmail:!1,verifiedRecoveryPhone:!1,givenName:l,middleName:c,familyName:u,createdTime:(new Date).getTime(),editable:!0,password:!0,SAML:!1,SCIM:!1,OIDC:!1,status:"enabled",test:!1,TOTP:!1,userTenants:h||[],webauthn:!1})}))})))({loginId:i,email:o,phone:r,recoveryEmail:s,recoveryPhone:a,displayName:d,roles:l,customAttributes:u,picture:h,verifiedEmail:f,verifiedPhone:p,givenName:v,middleName:g,familyName:m,additionalLoginIds:y,userTenants:b});const w=yield e.patch(Ak,{loginId:i,email:o,phone:r,recoveryEmail:s,recoveryPhone:a,displayName:d,givenName:v,middleName:g,familyName:m,roleNames:l,userTenants:b,customAttributes:u,picture:h,verifiedEmail:f,verifiedPhone:p,verifiedRecoveryEmail:!!s||void 0,verifiedRecoveryPhone:!!a||void 0,additionalLoginIds:y},{queryParams:{tenant:t}});return yield Lk(w),(yield w.json()).user})),enable:i=>c(void 0,void 0,void 0,(function*(){if(n)return(e=>c(void 0,void 0,void 0,(function*(){return new Promise((t=>{t({user:{loginIds:[e],status:"enabled"}})}))})))(i);const o=yield e.post(Nk,{loginId:i,status:"enabled"},{queryParams:{tenant:t}});return yield Lk(o),o.json()})),disable:i=>c(void 0,void 0,void 0,(function*(){if(n)return(e=>c(void 0,void 0,void 0,(function*(){return new Promise((t=>{t({user:{loginIds:[e],status:"disabled"}})}))})))(i);const o=yield e.post(Nk,{loginId:i,status:"disabled"},{queryParams:{tenant:t}});return yield Lk(o),o.json()})),removePasskey:i=>c(void 0,void 0,void 0,(function*(){if(n)return c(void 0,void 0,void 0,(function*(){}));const o=yield e.post(Mk,{loginId:i},{queryParams:{tenant:t}});return yield Lk(o),o.json()})),setTempPassword:i=>c(void 0,void 0,void 0,(function*(){if(n)return c(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({cleartext:Math.random().toString(20).substring(2)})}))}));const o=yield e.post(jk,{loginId:i},{queryParams:{tenant:t}});return yield Lk(o),o.json()})),getCustomAttributes:()=>c(void 0,void 0,void 0,(function*(){if(n)return c(void 0,void 0,void 0,(function*(){return new Promise((e=>{e([])}))}));const i=yield e.get(Pk,{queryParams:{tenant:t}});return yield Lk(i),(yield i.json()).data}))}),Dk=({httpClient:e,tenant:t,mock:n})=>({getTenantRoles:()=>c(void 0,void 0,void 0,(function*(){if(n)return(e=>new Promise((t=>{const n=[];for(let t=1;t<5;t+=1)n.push({name:`Role ${t}`,description:`Role description ${t}`,createdTime:new Date,permissionNames:[`Permission ${t}`],tenantId:e});t({roles:n})})))(t);const i=yield e.get(Tk,{queryParams:{tenant:t}});return yield Lk(i),i.json()})),getSubTenantRoles:()=>c(void 0,void 0,void 0,(function*(){if(n)return new Promise((e=>{e({roles:[{tenantId:"sub-tenant-1",tenantName:"Sub Tenant 1",roleNames:["Role 1","Role 2"]},{tenantId:"sub-tenant-2",tenantName:"Sub Tenant 2",roleNames:["Role 1","Role 3"]},{tenantId:"sub-tenant-3",tenantName:"Sub Tenant 3",roleNames:["Role 2"]}]})}));const i=yield e.get(Wk,{queryParams:{tenant:t}});return yield Lk(i),i.json()}))}),Fk=Wi((e=>{var t,n,i,o;const r=xi(js,wc,As,Cs,Ms,Sc,Ns({tenant:Ns.missingAttrValidator}))(e);return o=class extends r{constructor(){super(...arguments),t.add(this),n.set(this,void 0)}get tenantId(){return this.getAttribute("tenant")}get mock(){return this.getAttribute("mock")}get styleId(){return this.getAttribute("style-id")||Qs}get api(){return u(this,n,"f")||u(this,t,"m",i).call(this),u(this,n,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.init)||void 0===o?void 0:o.call(this),this.observeAttributes(["project-id","base-url","tenant"],(()=>{u(this,n,"f")&&u(this,t,"m",i).call(this)}))}))}},n=new WeakMap,t=new WeakSet,i=function(){this.logger.debug("creating an sdk instance"),h(this,n,((e,t,n,i)=>{const o=bi(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"user-management-widget","x-descope-widget-id":i,"x-descope-widget-version":"0.21.18"}}));return{user:Uk({httpClient:o.httpClient,tenant:t,mock:n}),tenant:Dk({httpClient:o.httpClient,tenant:t,mock:n}),httpClient:o.httpClient}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},this.tenantId,"true"===this.mock,this.widgetId),"f")},o})),_k=Wi((e=>{const t=xi(yc({name:"widget",initialState:Rk,reducers:{setSelectedUsersIds:(e,{payload:t})=>{e.selectedUsersLoginIds=t},clearNotifications:e=>{e.notifications=[]}},extraReducers:e=>{Z$.reducer(e),mk.reducer(e),wk.reducer(e),Ck.reducer(e),Q$.reducer(e),dk.reducer(e),nk.reducer(e),Ik.reducer(e),rk.reducer(e),uk.reducer(e),pk.reducer(e)},asyncActions:{searchUsers:dk.action,createUser:Z$.action,updateUser:mk.action,enableUser:wk.action,disableUser:Ck.action,deleteUsers:Q$.action,removePasskey:Ik.action,getCustomAttributes:rk.action,getTenantRoles:uk.action,getSubTenantRoles:pk.action,setTempUserPassword:nk.action}}),Os,Cs,Fk)(e);return class extends t{constructor(...e){super(...e),this.state=Rk,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),qk=Wi((e=>{var t,n,i;return i=class extends(xi(Cs,Os,Hs,Xs,Cc("user-management-widget"),_k,$c)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){return c(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.init)||void 0===i?void 0:i.call(this),this.injectStyle(".hidden { display: none; }");const o=this.getWidgetConfig().then((e=>(null==e?void 0:e.allowSubTenants)?this.actions.getSubTenantRoles():void 0));yield Promise.all([u(this,t,"m",n).call(this),this.actions.searchUsers(),this.actions.getTenantRoles(),this.actions.getCustomAttributes(),o]),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,n=function(){return c(this,void 0,void 0,(function*(){const e=Oi(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},i})),Bk=Wi((e=>{var t,n,i,o,r,s,a,d,l;return l=class extends(xi(_k,ud,bc,Cs,$c,qk)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),i.set(this,void 0),o.set(this,void 0),a.set(this,(()=>c(this,void 0,void 0,(function*(){yield u(this,n,"f").setData(g$(this.state).map((({name:e,description:t})=>({value:e,label:e,description:t}))))})))),d.set(this,(()=>{var e;const t=$$(this.state);null===(e=u(this,i,"f"))||void 0===e||e.classList.toggle("hidden",!t),t&&u(this,o,"f").setData(w$(this.state))}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),u(this,t,"m",r).call(this)}))}},n=new WeakMap,i=new WeakMap,o=new WeakMap,a=new WeakMap,d=new WeakMap,t=new WeakSet,r=function(){return c(this,void 0,void 0,(function*(){var e;this.createUserModal=this.createModal(),this.createUserModal.setContent(Oi(yield this.fetchWidgetPage("create-user-modal.html")));const r=new ka((()=>{var e;return null===(e=this.createUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger}),l=()=>{this.resetFormData(this.createUserModal.ele),u(this,o,"f").value=[]};r.onClick((()=>{this.createUserModal.close(),l()}));const f=new ka((()=>{var e;return null===(e=this.createUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});f.onClick((()=>c(this,void 0,void 0,(function*(){if(this.validateForm(this.createUserModal.ele)){const e=this.getFormData(this.createUserModal.ele),t=u(this,o,"f").mergedValue;this.actions.createUser(Object.assign(Object.assign({},c$(e,"customAttributes")),{userTenants:t,invite:!0,verifiedEmail:!0,verifiedPhone:!0})),this.createUserModal.close(),l()}})))),h(this,n,new Qa((()=>{var e;return null===(e=this.createUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="roles-multiselect"]')}),{logger:this.logger}),"f"),h(this,i,null===(e=this.createUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="sub-tenant-section"]'),"f"),h(this,o,new Ya((()=>{var e;return null===(e=this.createUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="sub-tenant-mappings"]')}),{logger:this.logger}),"f"),u(this,a,"f").call(this),this.createUserModal.beforeOpen=()=>c(this,void 0,void 0,(function*(){const e=this.getWidgetConfig().then((e=>(null==e?void 0:e.allowSubTenants)?this.actions.getSubTenantRoles():void 0));yield Promise.all([this.actions.getTenantRoles(),e]),yield u(this,a,"f").call(this),u(this,d,"f").call(this),u(this,t,"m",s).call(this)}))}))},s=function(){const e=b$(this.state);this.getFormFieldNames(this.createUserModal.ele).forEach((t=>{const[n,i]=t.split(".");if("customAttributes"!==n)return;const o=e.find((e=>e.name===i));o?o.editable||this.disableFormField(this.createUserModal.ele,t):this.removeFormField(this.createUserModal.ele,t)}))},l})),Vk=Wi((e=>{var t,n,i;return i=class extends(xi(Cs,Bk,qk)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",n).call(this)}))}},t=new WeakSet,n=function(){var e;this.createButton=new ka(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="create-user"]'),{logger:this.logger}),this.createButton.onClick((()=>this.createUserModal.open()))},i})),Kk=Wi((e=>{var t,n,i;return i=class extends(xi(_k,ud,Cs,qk)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),yield u(this,t,"m",n).call(this)}))}},t=new WeakSet,n=function(){return c(this,void 0,void 0,(function*(){var e;this.deleteUsersModal=this.createModal(),this.deleteUsersModal.setContent(Oi(yield this.fetchWidgetPage("delete-users-modal.html")));const t=new ka((()=>{var e;return null===(e=this.deleteUsersModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger});t.onClick((()=>this.deleteUsersModal.close()));const n=new ka((()=>{var e;return null===(e=this.deleteUsersModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});n.onClick((()=>{const e=x$(this.state);this.actions.deleteUsers(e),this.deleteUsersModal.close()}));const i=new id(null===(e=this.deleteUsersModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.deleteUsersModal.beforeOpen=()=>{const e=U$(this.state);i.text=`Delete ${e}?`}}))},i})),Hk=Wi((e=>{var t,n,i,o;return o=class extends(xi(Cs,qk,_k,Kk)(e)){constructor(){super(...arguments),t.add(this),i.set(this,Ni((e=>{e?this.deleteButton.enable():this.deleteButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;u(this,t,"m",n).call(this),yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),this.subscribe(u(this,i,"f").bind(this),V$)}))}},i=new WeakMap,t=new WeakSet,n=function(){var e;this.deleteButton=new ka(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="delete-users"]'),{logger:this.logger}),this.deleteButton.disable(),this.deleteButton.onClick((()=>{this.deleteUsersModal.open()}))},o})),zk=Wi((e=>{var t,n,i,o,r;return r=class extends(xi(_k,ud,Cs,bc,qk)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),yield u(this,t,"m",o).call(this)}))}},t=new WeakSet,n=function(){new ka((()=>{var e;return null===(e=this.disableUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger}).onClick((()=>this.disableUserModal.close()))},i=function(){new ka((()=>{var e;return null===(e=this.disableUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger}).onClick((()=>{const e=T$(this.state);this.actions.disableUser(e),this.disableUserModal.close()}))},o=function(){return c(this,void 0,void 0,(function*(){var e;this.disableUserModal=this.createModal(),this.disableUserModal.setContent(Oi(yield this.fetchWidgetPage("disable-user-modal.html"))),u(this,t,"m",n).call(this),u(this,t,"m",i).call(this);const o=new id(null===(e=this.disableUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.disableUserModal.beforeOpen=()=>c(this,void 0,void 0,(function*(){const e=U$(this.state);o.text=`Disable ${e}?`}))}))},r})),Jk=Wi((e=>{var t,n,i,o;return o=class extends(xi(Cs,qk,_k,zk,bc)(e)){constructor(){super(...arguments),t.add(this),i.set(this,Ni((e=>{e?this.disableButton.enable():this.disableButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;u(this,t,"m",n).call(this),yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),this.subscribe(u(this,i,"f").bind(this),F$)}))}},i=new WeakMap,t=new WeakSet,n=function(){var e;this.disableButton=new ka(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="disable-user"]'),{logger:this.logger}),this.disableButton.disable(),this.disableButton.onClick((()=>{this.disableUserModal.open()}))},o})),Gk=e=>{if(!e)return e;const t=s$(e.startsWith("+")?e:`+${e}`);if(!t)return e;const n=new RegExp(`(\\+?${null==t?void 0:t.countryCallingCode})(.*)`);return(null==t?void 0:t.number.replace(n,"$1-$2"))||e},Zk=Wi((e=>{var t,n,i,o,r,s,a,d,f,p,v,g,m;return m=class extends(xi(_k,ud,Cs,bc,$c,qk)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),i.set(this,void 0),o.set(this,void 0),r.set(this,void 0),d.set(this,(()=>c(this,void 0,void 0,(function*(){yield u(this,i,"f").setData(g$(this.state).map((({name:e,description:t})=>({value:e,label:e,description:t}))))})))),f.set(this,(()=>{var e;const t=$$(this.state);null===(e=u(this,o,"f"))||void 0===e||e.classList.toggle("hidden",!t),t&&u(this,r,"f").setData(w$(this.state))})),v.set(this,(()=>{var e,t;const n=null===(e=E$(this.state))||void 0===e?void 0:e[0],i=Object.assign({loginId:null===(t=null==n?void 0:n.loginIds)||void 0===t?void 0:t.join(", "),displayName:null==n?void 0:n.name,email:null==n?void 0:n.email,phone:Gk(null==n?void 0:n.phone),recoveryEmail:null==n?void 0:n.recoveryEmail,recoveryPhone:Gk(null==n?void 0:n.recoveryPhone),roles:null==n?void 0:n.roleNames,givenName:null==n?void 0:n.givenName,familyName:null==n?void 0:n.familyName,middleName:null==n?void 0:n.middleName},u$(n.customAttributes,"customAttributes"));this.setFormData(this.editUserModal.ele,i),u(this,r,"f").value=(null==n?void 0:n.userTenants)||[]}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),yield u(this,t,"m",g).call(this)}))}},n=new WeakMap,i=new WeakMap,o=new WeakMap,r=new WeakMap,d=new WeakMap,f=new WeakMap,v=new WeakMap,t=new WeakSet,s=function(){new ka((()=>{var e;return null===(e=this.editUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger}).onClick((()=>this.editUserModal.close()))},a=function(){new ka((()=>{var e;return null===(e=this.editUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger}).onClick((()=>{if(this.validateForm(this.editUserModal.ele)){const e=this.getFormData(this.editUserModal.ele),{loginId:t}=e,n=l(e,["loginId"]),i=u(this,o,"f")&&!u(this,o,"f").classList.contains("hidden")?u(this,r,"f").mergedValue:void 0;this.actions.updateUser(Object.assign(Object.assign({loginId:t.split(", ")[0]},c$(n,"customAttributes")),void 0!==i&&{userTenants:i})),this.editUserModal.close(),this.resetFormData(this.editUserModal.ele)}}))},p=function(){const e=b$(this.state);this.getFormFieldNames(this.editUserModal.ele).forEach((t=>{const[n,i]=t.split(".");if("customAttributes"!==n)return;const o=e.find((e=>e.name===i));o?o.editable||this.disableFormField(this.editUserModal.ele,t):this.removeFormField(this.editUserModal.ele,t)}))},g=function(){return c(this,void 0,void 0,(function*(){var e,l;this.editUserModal=this.createModal(),this.editUserModal.setContent(Oi(yield this.fetchWidgetPage("edit-user-modal.html"))),u(this,t,"m",s).call(this),u(this,t,"m",a).call(this),h(this,n,new od(null===(e=this.editUserModal.ele)||void 0===e?void 0:e.querySelector('[name="loginId"]'),{logger:this.logger}),"f"),h(this,i,new Qa((()=>{var e;return null===(e=this.editUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="roles-multiselect"]')}),{logger:this.logger}),"f"),h(this,o,null===(l=this.editUserModal.ele)||void 0===l?void 0:l.querySelector('[data-id="sub-tenant-section"]'),"f"),h(this,r,new Ya((()=>{var e;return null===(e=this.editUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="sub-tenant-mappings"]')}),{logger:this.logger}),"f"),this.editUserModal.beforeOpen=()=>c(this,void 0,void 0,(function*(){const e=this.getWidgetConfig().then((e=>(null==e?void 0:e.allowSubTenants)?this.actions.getSubTenantRoles():void 0));yield Promise.all([this.actions.getTenantRoles(),e]),yield u(this,d,"f").call(this),u(this,n,"f").disable(),u(this,f,"f").call(this),u(this,v,"f").call(this),u(this,t,"m",p).call(this)}))}))},m})),Yk=Wi((e=>{var t,n,i,o;return o=class extends(xi(Cs,qk,_k,Zk,bc)(e)){constructor(){super(...arguments),t.add(this),i.set(this,Ni((e=>{e?this.editButton.enable():this.editButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;u(this,t,"m",n).call(this),yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),this.subscribe(u(this,i,"f").bind(this),_$)}))}},i=new WeakMap,t=new WeakSet,n=function(){var e;this.editButton=new ka(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="edit-user"]'),{logger:this.logger}),this.editButton.disable(),this.editButton.onClick((()=>{this.editUserModal.open()}))},o})),Xk=Wi((e=>{var t,n,i,o,r;return r=class extends(xi(_k,ud,Cs,bc,qk)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),yield u(this,t,"m",o).call(this)}))}},t=new WeakSet,n=function(){new ka((()=>{var e;return null===(e=this.enableUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger}).onClick((()=>this.enableUserModal.close()))},i=function(){new ka((()=>{var e;return null===(e=this.enableUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger}).onClick((()=>{const e=T$(this.state);this.actions.enableUser(e),this.enableUserModal.close()}))},o=function(){return c(this,void 0,void 0,(function*(){var e;this.enableUserModal=this.createModal(),this.enableUserModal.setContent(Oi(yield this.fetchWidgetPage("enable-user-modal.html"))),u(this,t,"m",n).call(this),u(this,t,"m",i).call(this);const o=new id(null===(e=this.enableUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.enableUserModal.beforeOpen=()=>c(this,void 0,void 0,(function*(){const e=U$(this.state);o.text=`Activate ${e}?`}))}))},r})),Qk=Wi((e=>{var t,n,i,o;return o=class extends(xi(Cs,qk,_k,Xk,bc)(e)){constructor(){super(...arguments),t.add(this),i.set(this,Ni((e=>{e?this.enableButton.enable():this.enableButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;u(this,t,"m",n).call(this),yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),this.subscribe(u(this,i,"f").bind(this),D$)}))}},i=new WeakMap,t=new WeakSet,n=function(){var e;this.enableButton=new ka(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="enable-user"]'),{logger:this.logger}),this.enableButton.disable(),this.enableButton.onClick((()=>{this.enableUserModal.open()}))},o})),eC=Wi((e=>{var t,n,i,o;return o=class extends(xi(Cs,qk,_k)(e)){constructor(){super(...arguments),t.add(this),n.set(this,Pi((()=>{this.actions.searchUsers({text:this.searchInput.value})})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),u(this,t,"m",i).call(this)}))}},n=new WeakMap,t=new WeakSet,i=function(){var e;this.searchInput=new od(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="search-input"]'),{logger:this.logger}),this.searchInput.onInput(u(this,n,"f"))},o})),tC=new Set(["contains","not-contains","starts-with","ends-with","not-equal"]),nC=e=>{const t=Array.isArray(e)?e[0]:e;return null==t||""===t?null:String(t)},iC=e=>Array.isArray(e)?e:null==e||""===e?[]:[String(e)],oC=(e,t)=>({[e]:t}),rC=(e,t)=>({customAttributes:{[e]:t}}),sC=(e,t)=>((e,t)=>"equal"===t.operator&&null!=e.exactField)(e,t)?((e,t)=>{const n=iC(t.value);return n.length?oC(e,n):{}})(e.exactField,t):((e,t)=>tC.has(t.operator)&&null!=e.likeField)(e,t)?((e,t)=>{var n,i;const o=nC(t.value);return null===o?{}:((e,t,n)=>({searchFields:[Object.assign({field:e,valStr:t},n?{negative:!0}:{})]}))(e,`${null!==(n=t.prefix)&&void 0!==n?n:""}${o}${null!==(i=t.suffix)&&void 0!==i?i:""}`,t.operator.startsWith("not-"))})(e.likeField,t):null,aC=(e,t)=>{const{mapping:n}=e;if(!n)return null;switch(n.kind){case"array":return((e,t)=>{if("is-any-of"!==t.operator)return null;const n=iC(t.value);if(!n.length)return{};const i=e.valueMap?n.map((t=>{var n;return null!==(n=e.valueMap[t])&&void 0!==n?n:t})):n;return oC(e.field,i)})(n,t);case"boolean":return((e,t)=>{if("equal"!==t.operator)return null;const n=nC(t.value);return"true"===n?oC(e.field,!0):"false"===n?oC(e.field,!1):{}})(n,t);case"text":return sC(n,t);case"customAttribute":return((e,t,n)=>{if((e=>"is-empty"===e.operator)(t))return rC(e.name,null);if(!(e=>"equal"===e.operator||"is-any-of"===e.operator)(t))return{};const i=((e,t)=>{if(Array.isArray(e))return e.length?e:void 0;if(null!=e&&""!==e){if("boolean"===t)return"true"===e||"false"!==e&&void 0;if("number"===t){const t=Number(e);return Number.isFinite(t)?t:void 0}return e}})(t.value,n);return void 0===i?{}:rC(e.name,i)})(n,t,e.inputType);default:return null}},dC=(e,t=[])=>{const n={};(e=>{const t=new Set(["searchFields","customAttributes"]);return e.forEach((e=>{const n=null==e?void 0:e.mapping;n&&("array"===n.kind||"boolean"===n.kind?t.add(n.field):"text"===n.kind&&n.exactField&&t.add(n.exactField))})),t})(t).forEach((e=>{n[e]=void 0}));const i=new Map(t.filter((e=>Boolean(e))).map((e=>[e.id,e])));return e.reduce(((e,t)=>{const n=((e,t)=>{if(e.column&&e.operator)return t.get(e.column)})(t,i);if(!n)return e;const o=aC(n,t);return o?((e,t)=>{const{searchFields:n,customAttributes:i}=t,o=l(t,["searchFields","customAttributes"]),r=n?(a=n,[...null!=(s=e.searchFields)?s:[],...a]):e.searchFields;var s,a;const d=i?((e,t)=>Object.assign(Object.assign({},null!=e?e:{}),t))(e.customAttributes,i):e.customAttributes,c=Object.assign({},e);return Object.entries(o).forEach((([e,t])=>{var n,i;c[e]=(n=c[e],i=t,Array.isArray(n)&&Array.isArray(i)?[...n,...i.filter((e=>!n.includes(e)))]:i)})),Object.assign(Object.assign({},c),{searchFields:r,customAttributes:d})})(e,o):e}),n)},lC="customAttributes.",cC="roles",uC=e=>{if("string"==typeof e)return{value:e,label:e};const{value:t,label:n}=e;return{value:t,label:n||t}},hC=(e,t,n)=>{var i;const o=((e,t)=>{if(!(null==t?void 0:t.length))return e.filter((e=>(null==e?void 0:e.id)!==cC));const n=t.map((e=>({value:e.name,label:e.name})));return e.map((e=>(null==e?void 0:e.id)===cC?Object.assign(Object.assign({},e),{options:n}):e))})(null!==(i=null==e?void 0:e.slice())&&void 0!==i?i:[],t);return((e,t)=>e.filter((e=>{var n;if(!(null===(n=null==e?void 0:e.id)||void 0===n?void 0:n.startsWith(lC))||!(null==t?void 0:t.length))return!0;const i=e.id.slice(17);return t.some((e=>e.name===i))})).map((e=>{var n;return(null===(n=null==e?void 0:e.id)||void 0===n?void 0:n.startsWith(lC))?((e,t)=>{const n=e.id.slice(17),i=null==t?void 0:t.find((e=>e.name===n));if(!i)return e;const o=e.label||i.displayName||n,r=(e=>Array.isArray(e.options)&&e.options.length?e.options.map(uC):void 0)(i),s=Object.assign(Object.assign({},e),{label:o});return r&&(s.options=r),s})(e,t):e})))(o,n)},fC=Wi((e=>{var t,n,i,o,r,s,a,d;return d=class extends(xi(Cs,qk,_k)(e)){constructor(){super(...arguments),t.set(this,null),n.set(this,(()=>u(this,t,"f")?[...u(this,t,"f")]:this.filter.data)),i.set(this,(e=>{const t=Array.isArray(null==e?void 0:e.value)?e.value:[];this.actions.searchUsers(Object.assign(Object.assign({},dC(t,u(this,n,"f").call(this))),{page:0}))})),o.set(this,(()=>{this.actions.searchUsers(Object.assign(Object.assign({},dC([],u(this,n,"f").call(this))),{page:0}))})),r.set(this,Ni(((e,t,n)=>{this.filter.data=hC(e,t,n)}))),s.set(this,(()=>{var e;(null===(e=this.filter)||void 0===e?void 0:e.isExists)&&u(this,r,"f").call(this,u(this,t,"f"),g$(this.state),b$(this.state))})),a.set(this,(()=>{h(this,t,Object.freeze(this.filter.data.slice()),"f"),u(this,s,"f").call(this)}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var t,n;yield null===(t=e.onWidgetRootReady)||void 0===t?void 0:t.call(this);const r=null===(n=this.shadowRoot)||void 0===n?void 0:n.querySelector("descope-filter");this.filter=new $a(r,{logger:this.logger}),this.filter.isExists&&(this.filter.onDataChange(u(this,a,"f")),u(this,a,"f").call(this),this.subscribe(u(this,s,"f"),g$),this.subscribe(u(this,s,"f"),b$),this.filter.onApply(u(this,i,"f")),this.filter.onClear(u(this,o,"f")))}))}},t=new WeakMap,n=new WeakMap,i=new WeakMap,o=new WeakMap,r=new WeakMap,s=new WeakMap,a=new WeakMap,d})),pC={success:(new DOMParser).parseFromString('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Checkmark">\n<path id="Shape" d="M10.0485 15.6396C9.5799 15.171 8.8201 15.171 8.35147 15.6396C7.88284 16.1082 7.88284 16.868 8.35147 17.3367L12.7072 21.6924C13.1759 22.1611 13.9357 22.1611 14.4043 21.6924L24.7152 11.3815C25.1838 10.9129 25.1838 10.1531 24.7152 9.68448C24.2466 9.21585 23.4868 9.21585 23.0181 9.68448L13.5558 19.1469L10.0485 15.6396Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,error:(new DOMParser).parseFromString('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Icon">\n<path id="Vector" d="M15.9998 26.6558C10.1118 26.6558 5.34375 21.8878 5.34375 15.9998C5.34375 10.1118 10.1118 5.34375 15.9998 5.34375C21.8878 5.34375 26.6558 10.1118 26.6558 15.9998C26.6558 21.8878 21.8878 26.6558 15.9998 26.6558ZM15.9998 24.4798C20.6718 24.4798 24.4798 20.7038 24.4798 15.9998C24.4798 11.3278 20.7038 7.51975 15.9998 7.51975C11.3278 7.51975 7.51975 11.2958 7.51975 15.9998C7.51975 20.6718 11.2958 24.4798 15.9998 24.4798ZM15.3278 9.34375H16.6718C17.0558 9.34375 17.3438 9.63175 17.3118 9.98375L16.9598 16.9278C16.9598 17.1838 16.7678 17.3438 16.5438 17.3438H15.4558C15.2318 17.3438 15.0398 17.1518 15.0398 16.9278L14.6878 9.98375C14.6878 9.63175 14.9758 9.34375 15.3278 9.34375ZM15.4558 19.4558H16.5438C16.9278 19.4558 17.2158 19.7438 17.1838 20.1278V21.1838C17.1838 21.5678 16.8958 21.8558 16.5438 21.8558H15.4558C15.0718 21.8558 14.7838 21.5678 14.7838 21.1838V20.1278C14.7838 19.7438 15.0718 19.4558 15.4558 19.4558Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild},vC=Wi((e=>{var t,n,i,o,r;return r=class extends(xi(Cs,_k,pd,Os)(e)){constructor(){super(...arguments),t.add(this),o.set(this,Ni((e=>{e.length&&(e.forEach((({type:e,msg:o})=>{const r=u(this,t,"m",i).call(this,e);r.setContent(u(this,t,"m",n).call(this,{type:e,msg:o})),r.show()})),setTimeout((()=>this.actions.clearNotifications())))})))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this),this.subscribe(u(this,o,"f").bind(this),y$)}))}},o=new WeakMap,t=new WeakSet,n=function({type:e,msg:t}){const n=pC[e],i=Object.assign((new DOMParser).parseFromString('<svg width="2em" height="2em" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Icon">\n<path id="Shape" d="M10.6712 12L7.27521 8.60406C6.90826 8.23711 6.90826 7.64216 7.27521 7.27521C7.64216 6.90826 8.23711 6.90826 8.60406 7.27521L12 10.6712L15.3959 7.27521C15.7629 6.90826 16.3578 6.90826 16.7248 7.27521C17.0917 7.64216 17.0917 8.23711 16.7248 8.60406L13.3288 12L16.7248 15.3959C17.0917 15.7629 17.0917 16.3578 16.7248 16.7248C16.3578 17.0917 15.7629 17.0917 15.3959 16.7248L12 13.3288L8.60406 16.7248C8.23711 17.0917 7.64216 17.0917 7.27521 16.7248C6.90826 16.3578 6.90826 15.7629 7.27521 15.3959L10.6712 12Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,{slot:"close"});return`${(null==n?void 0:n.outerHTML)||""}${t}${i.outerHTML}`},i=function(e){return this.createNotification({mode:e,duration:"error"===e?0:3e3,position:"bottom-start",size:"sm"})},r})),gC=Wi((e=>{var t,n,i,o,r;return r=class extends(xi(_k,ud,Cs,bc,qk)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),yield u(this,t,"m",o).call(this)}))}},t=new WeakSet,n=function(){new ka((()=>{var e;return null===(e=this.removePasskeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger}).onClick((()=>this.removePasskeyModal.close()))},i=function(){new ka((()=>{var e;return null===(e=this.removePasskeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger}).onClick((()=>{const e=T$(this.state);this.actions.removePasskey(e),this.removePasskeyModal.close()}))},o=function(){return c(this,void 0,void 0,(function*(){var e;this.removePasskeyModal=this.createModal(),this.removePasskeyModal.setContent(Oi(yield this.fetchWidgetPage("remove-passkey-modal.html"))),u(this,t,"m",n).call(this),u(this,t,"m",i).call(this);const o=new id(null===(e=this.removePasskeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.removePasskeyModal.beforeOpen=()=>c(this,void 0,void 0,(function*(){const e=U$(this.state);o.text=`Remove passkey for ${e}?`}))}))},r})),mC=Wi((e=>{var t,n,i,o;return o=class extends(xi(Cs,qk,_k,gC,bc)(e)){constructor(){super(...arguments),t.add(this),i.set(this,Ni((e=>{e?this.removePasskeyButton.enable():this.removePasskeyButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;u(this,t,"m",n).call(this),yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),this.subscribe(u(this,i,"f").bind(this),q$)}))}},i=new WeakMap,t=new WeakSet,n=function(){var e;this.removePasskeyButton=new ka(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="remove-passkey"]'),{logger:this.logger}),this.removePasskeyButton.disable(),this.removePasskeyButton.onClick((()=>{this.removePasskeyModal.open()}))},o})),yC=Wi((e=>{var t,n,i,o,r,s,a,d;return d=class extends(xi(_k,Cs,qk)(e)){constructor(){super(...arguments),t.add(this),o.set(this,Ni((e=>{this.usersTable.data=e}))),r.set(this,Pi(((e,t)=>{const n=[],{value:i}=t;if(i){const t=e.path;n.push({field:t,desc:"desc"===i})}this.actions.searchUsers({sort:n})}))),s.set(this,Ni((e=>{this.usersTable.filterColumns((t=>{var n;const[i,o]=(null===(n=t.path)||void 0===n?void 0:n.split("."))||[];return"customAttributes"!==i||!!(null==e?void 0:e.find((e=>e.name===o)))}))})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),u(this,t,"m",i).call(this),u(this,o,"f").call(this,R$(this.state)),u(this,s,"f").call(this,b$(this.state)),this.subscribe(u(this,s,"f").bind(this),b$),this.subscribe(u(this,o,"f").bind(this),R$)}))}},o=new WeakMap,r=new WeakMap,s=new WeakMap,t=new WeakSet,n=function(){const e=e=>{var t;return null===(t=this.usersTable.ele)||void 0===t?void 0:t.querySelector(`[path="${e}"]`)},t=e=>{var t;const n=`descope-grid-${e}-column`;return null===(t=this.usersTable.ele)||void 0===t?void 0:t.querySelector(n)},n=this.usersTable.renderColumn;this.usersTable.renderColumn=({path:i,header:o,type:r,attrs:s})=>{const a=e(i)||t(r);if(!a)return n({path:i,header:o,type:r,attrs:s});const d=a.cloneNode(!0),l=Object.assign(Object.assign({},s),{header:o});return Object.entries(l).forEach((([e,t])=>{d.setAttribute(e,t)})),d.outerHTML}},i=function(){var e;this.usersTable=new Ea(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="users-table"]'),{logger:this.logger}),this.usersTable.onSelectedItemsChange((e=>{this.actions.setSelectedUsersIds(e.detail.value.map((({loginIds:e})=>e)))})),this.usersTable.onColumnsChange(u(this,t,"m",a).bind(this)),u(this,t,"m",n).call(this),u(this,t,"m",a).call(this)},a=function(){this.usersTable.columns.forEach((e=>{e.onSortDirectionChange((e=>{u(this,r,"f").call(this,e.target,e.detail)}))}))},d})),bC=Wi((e=>{var t,n,i;return i=class extends(xi(_k,ud,Cs,bc,qk)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),yield u(this,t,"m",n).call(this)}))}},t=new WeakSet,n=function(){return c(this,void 0,void 0,(function*(){this.generatedPasswordModal=this.createModal(),this.generatedPasswordModal.setContent(Oi(yield this.fetchWidgetPage("generated-password-modal.html"))),new ka((()=>{var e;return null===(e=this.generatedPasswordModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-close"]')}),{logger:this.logger}).onClick((()=>{navigator.clipboard.writeText(this.getFormData(this.generatedPasswordModal.ele)["generated-password"]),this.resetFormData(this.generatedPasswordModal.ele),this.generatedPasswordModal.close()}))}))},i})),wC=Wi((e=>{var t,n,i,o,r;return r=class extends(xi(_k,ud,Cs,bc,qk,bC)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),yield u(this,t,"m",o).call(this)}))}},t=new WeakSet,n=function(){new ka((()=>{var e;return null===(e=this.resetPasswordModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger}).onClick((()=>this.resetPasswordModal.close()))},i=function(){new ka((()=>{var e;return null===(e=this.resetPasswordModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger}).onClick((()=>c(this,void 0,void 0,(function*(){var e;const t=T$(this.state),n=yield this.actions.setTempUserPassword(t);this.resetPasswordModal.close(),this.setFormData(this.generatedPasswordModal.ele,{"generated-password":null===(e=null==n?void 0:n.payload)||void 0===e?void 0:e.cleartext}),this.generatedPasswordModal.open()}))))},o=function(){return c(this,void 0,void 0,(function*(){var e;this.resetPasswordModal=this.createModal(),this.resetPasswordModal.setContent(Oi(yield this.fetchWidgetPage("reset-password-modal.html"))),u(this,t,"m",n).call(this),u(this,t,"m",i).call(this);const o=new id(null===(e=this.resetPasswordModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.resetPasswordModal.beforeOpen=()=>c(this,void 0,void 0,(function*(){const e=U$(this.state);o.text=`This will generate a new temporary password for ${e}?`}))}))},r})),$C=Wi((e=>{var t,n,i,o;return o=class extends(xi(Cs,qk,_k,wC,bc)(e)){constructor(){super(...arguments),t.add(this),i.set(this,Ni((e=>{e?this.resetPasswordButton.enable():this.resetPasswordButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;u(this,t,"m",n).call(this),yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),this.subscribe(u(this,i,"f").bind(this),B$)}))}},i=new WeakMap,t=new WeakSet,n=function(){var e;this.resetPasswordButton=new ka(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="reset-password"]'),{logger:this.logger}),this.resetPasswordButton.disable(),this.resetPasswordButton.onClick((()=>{this.resetPasswordModal.open()}))},o})),kC=Wi((e=>class extends(xi(sa,As)(e)){syncFlowTheme(e){e.theme=this.theme,this.observeAttributes(["theme"],(()=>{e.theme=this.theme}))}})),CC=Wi((e=>{var t,n,i,o,r,s,a,d,l,f,p,v,g,m;return m=class extends(xi(kc,kC,_k,hd,Cs,bc,qk,Ic)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),i.set(this,void 0),o.set(this,[]),r.set(this,null),s.set(this,null),g.set(this,Ni((e=>{u(this,o,"f").forEach((t=>{"onlyOne"===t.enableMode&&1===e.length||"oneOrMore"===t.enableMode&&e.length>0||"always"===t.enableMode?t.enable():t.disable()}))})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),u(this,t,"m",l).call(this),u(this,t,"m",d).call(this),u(this,g,"f").call(this,m$(this.state))}))}},n=new WeakMap,i=new WeakMap,o=new WeakMap,r=new WeakMap,s=new WeakMap,g=new WeakMap,t=new WeakSet,a=function(e){const n=new Sa(e,{logger:this.logger});n.onClick((()=>{u(this,t,"m",v).call(this,n.flowId)})),this.subscribe(u(this,g,"f").bind(this),m$),u(this,o,"f").push(n)},d=function(){var e;const n=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelectorAll("[data-generic-flow-button-id]");Array.from(n).forEach((e=>{u(this,t,"m",a).call(this,e)}))},l=function(){h(this,n,this.createFlowModal({"data-id":"generic-flow-modal"}),"f"),u(this,n,"f").afterClose=()=>{var e;u(this,r,"f")&&(null===(e=u(this,s,"f"))||void 0===e||e.call(this),h(this,r,null,"f"))},h(this,i,new Ca((()=>{var e;return null===(e=u(this,n,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(u(this,i,"f"))},f=function(){var e;u(this,n,"f").open(),null===(e=u(this,s,"f"))||void 0===e||e.call(this)},p=function(e,n){n=()=>u(this,t,"m",f).call(this),h(this,s,u(this,i,"f").onPageUpdated(n),"f")},v=function(e){u(this,n,"f").setContent(this.createFlowTemplate({flowId:e,lazyStart:!1,client:{userIds:x$(this.state),loginIds:O$(this.state),usersAndRoles:A$(this.state)},tenant:this.tenantId})),u(this,t,"m",p).call(this,u(this,n,"f"),u(this,r,"f")),u(this,i,"f").onSuccess((()=>{u(this,n,"f").close(),this.actions.searchUsers()}))},m})),SC="widget-flow",IC=Wi((e=>{var t,n,i;return i=class extends(xi(kc,Os,hd,_k,Sc,Cs,sa,Ic)(e)){constructor(){super(...arguments),t.add(this)}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.init)||void 0===i?void 0:i.call(this);const o=f$(SC);o&&(function(e){if(window.history.replaceState&&f$(e)){const t=new URL(window.location.href),n=new URLSearchParams(t.search);n.delete(e),t.search=n.toString(),window.history.replaceState({},"",t.toString())}}(SC),u(this,t,"m",n).call(this,o))}))}},t=new WeakSet,n=function(e){const t=this.createFlowModal({"data-id":"redirect-flow"});t.setContent(this.createFlowTemplate({flowId:e})),new Ca((()=>{var e;return null===(e=t.ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}).onSuccess((()=>{t.close()})),t.afterClose=()=>{t.remove()},t.open()},i})),RC=Wi((e=>class extends(xi(fa,sa,IC,yC,Vk,Hk,Yk,Qk,Jk,$C,mC,eC,fC,vC,CC,Oc)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),EC=xi((e=>class extends(RC(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this),(customElements.get("descope-wc")||(yield Promise.resolve().then((function(){return Ph})).then((e=>e.default)))).sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"user-management-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.21.18"}}}))}}))(HTMLElement);customElements.define("descope-user-management-widget",EC);var xC=Object.freeze({__proto__:null,default:EC});function OC(e){return new URLSearchParams(window.location.search).get(e)}const AC=e=>(...t)=>n=>{n.addCase(e.pending,((e,n)=>{t.forEach((({onPending:t})=>{null==t||t(e,n)}))})),n.addCase(e.fulfilled,((e,n)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,n)}))})),n.addCase(e.rejected,((e,n)=>{t.forEach((({onRejected:t})=>{null==t||t(e,n)}))}))},NC=e=>({onFulfilled:t=>{e(t).loading=!1},onPending:t=>{e(t).loading=!0,e(t).error=null},onRejected:(t,n)=>{e(t).loading=!1,e(t).error=n.error}}),jC=lc("users/me",((e,{extra:{api:t}})=>t.user.me())),MC=AC(jC)({onFulfilled:(e,t)=>{e.me.data=t.payload}},NC((e=>e.me))),PC={action:jC,reducer:MC},TC=lc("users/devices",((e,{extra:{api:t}})=>t.device.devices(e))),WC=AC(TC)({onFulfilled:(e,t)=>{e.devices.data=t.payload.devices}},NC((e=>e.devices))),LC={action:TC,reducer:WC},UC=lc("users/passkeys",((e,{extra:{api:t}})=>t.passkey.listPasskeys(e))),DC=AC(UC)({onFulfilled:(e,t)=>{e.passkeys.data=t.payload.passkeys}},NC((e=>e.passkeys))),FC={action:UC,reducer:DC},_C=lc("users/logout",((e,{extra:{api:t}})=>t.user.logout())),qC={action:_C,reducer:AC(_C)({})},BC=e=>{if(!e)return null;const t=(e=>{try{const t=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),n=decodeURIComponent(atob(t).split("").map((e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2))).join(""));return JSON.parse(n)}catch(e){return null}})(e);return(null==t?void 0:t.dct)||null},VC=e=>e.me.data,KC=Al(VC,(e=>e.userId)),HC=Al(VC,(e=>e.picture)),zC=Al(VC,(e=>e.email)),JC=Al(VC,(e=>e.verifiedEmail)),GC=Al(VC,(e=>e.name)),ZC=Al(VC,(e=>e.phone)),YC=Al(VC,(e=>e.verifiedPhone)),XC=Al(zC,JC,((e,t)=>e&&""!==e.trim()&&!t?"Unverified":"")),QC=Al(ZC,YC,((e,t)=>e&&""!==e.trim()&&!t?"Unverified":"")),eS=Al(VC,(e=>e.recoveryEmail)),tS=Al(VC,(e=>e.verifiedRecoveryEmail)),nS=Al(VC,(e=>e.recoveryPhone)),iS=Al(VC,(e=>e.verifiedRecoveryPhone)),oS=Al(eS,tS,((e,t)=>t?e:"")),rS=Al(nS,iS,((e,t)=>t?e:"")),sS=Al(VC,(e=>e.webauthn));Al(VC,(e=>e.password));const aS=Al(VC,(e=>e.TOTP)),dS={},lS=Al(VC,(e=>{var t;return null!==(t=e.customAttributes)&&void 0!==t?t:dS})),cS=Al(VC,(e=>({givenName:e.givenName,middleName:e.middleName,familyName:e.familyName}))),uS=Al((e=>e.devices.data),(e=>e.map((({id:e,name:t,deviceType:n,lastLoginTime:i,isCurrentDevice:o})=>({id:e,name:t,deviceType:n,lastLoginDate:1e3*parseInt(i,10),isCurrent:o}))))),hS=Al((e=>e.passkeys.data),(e=>e.map((({id:e,displayName:t,kind:n,createdTime:i})=>({id:e,name:t,passkeyType:n,createdAt:1e3*i}))))),fS=e=>e.notifications,pS=Al(VC,(e=>e.userTenants||[])),vS=e=>e.tenant.currentTenantId,gS=lc("tenant/select",((e,t)=>c(void 0,[e,t],void 0,(function*(e,{extra:{api:t},getState:n}){if(e===vS(n()))return null;const i=yield t.user.setCurrentTenant(e),o=i.sessionJwt||i.sessionToken;try{return{tenantId:BC(o)}}catch(e){return console.error("Failed to switch tenant:",e),null}})))),mS={action:gS,reducer:AC(gS)({onPending:e=>{e.tenant.previousTenantId=e.tenant.currentTenantId},onFulfilled:(e,t)=>{var n;e.tenant.currentTenantId=null===(n=t.payload)||void 0===n?void 0:n.tenantId,e.tenant.previousTenantId=null},onRejected:e=>{e.tenant.currentTenantId=e.tenant.previousTenantId,e.tenant.previousTenantId=null}},NC((e=>e.selectTenant)),(({getErrorMsg:e,getSuccessMsg:t})=>({onFulfilled:(e,n)=>{if(t){const i=t(n);i&&e.notifications.push({type:"success",msg:i})}},onRejected:(t,n)=>{if(e){const i=e(n);i&&t.notifications.push({type:"error",msg:i})}}}))({getErrorMsg:e=>{var t;return Ki(null===(t=e.error)||void 0===t?void 0:t.message).trim()||"Error"}}))},yS={me:{loading:!1,error:null,data:{}},devices:{loading:!1,error:null,data:[]},passkeys:{loading:!1,error:null,data:[]},tenant:{currentTenantId:null,previousTenantId:null},selectTenant:{loading:!1,error:null},notifications:[]},bS="/v1/auth/me",wS="/v1/mgmt/user/trusteddevices/list",$S="/v1/mgmt/user/passkeys/list",kS="/v1/auth/tenant/select",CS=e=>c(void 0,void 0,void 0,(function*(){const t=yield e.text(),n=JSON.parse(t);if(!e.ok){const t=`${n.errorDescription}${n.errorMessage?`: ${n.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(n),e.text=()=>Promise.resolve(t)})),SS=[{tenantName:"Tenant 1",tenantId:"tn1",roleNames:["Role"]},{tenantName:"Tenant 2",tenantId:"tn2",roleNames:["Role"]}],IS=({httpClient:e,mock:t})=>({me:()=>c(void 0,void 0,void 0,(function*(){if(t)return c(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({loginIds:["user@company.com"],externalIds:["user@company.com"],userId:"user-1",name:"Test User",email:"user@company.com",roleNames:["Role"],phone:"+1-202-555-010",recoveryEmail:"recovery@company.com",recoveryPhone:"+1-202-555-020",verifiedEmail:!0,verifiedPhone:!0,verifiedRecoveryEmail:!0,verifiedRecoveryPhone:!0,userTenants:SS,status:"enabled",editable:!0,createdTime:(new Date).getTime(),customAttributes:{},familyName:"",givenName:"",middleName:"",picture:void 0,password:!0,SAML:!1,test:!1,TOTP:!1,webauthn:!0})}))}));const n=yield e.get(bS);return yield CS(n),n.json()})),setCurrentTenant:t=>c(void 0,void 0,void 0,(function*(){const n=yield e.post(kS,{tenant:t});return yield CS(n),n.json()}))}),RS=({httpClient:e,mock:t})=>({devices:n=>c(void 0,[n],void 0,(function*({userId:n}){if(t)return{devices:[{id:"device-id-1",name:"Device 1",deviceType:"desktop",lastLoginDate:17359776e5,isCurrent:!1},{id:"device-id-2",name:"Device 2",deviceType:"mobile",lastLoginDate:17387505e5,isCurrentDevice:!0},{id:"device-id-3",name:"Device 3",deviceType:"tablet",lastLoginDate:17412642e5,isCurrent:!1},{id:"device-id-4",name:"Device 4",deviceType:"unknown",lastLoginDate:17440371e5,isCurrent:!1},{id:"device-id-5",name:"Device 5",deviceType:"desktop",lastLoginDate:174672e7,isCurrent:!1}]};const i=yield e.post(wS,{identifiers:[n]});return yield CS(i),i.json()}))}),ES=({httpClient:e,mock:t})=>({listPasskeys:n=>c(void 0,[n],void 0,(function*({userId:n}){if(t)return{passkeys:[{id:"vendor-id-1",displayName:"Device 1",kind:"google",createdTime:1735977600,rpId:"example.com"},{id:"vendor-id-2",displayName:"Device 2",kind:"edge",createdTime:1738750500,rpId:"example.com"},{id:"vendor-id-3",displayName:"Device 3",kind:"apple",createdTime:1741264200,rpId:"example.com"}]};const i=yield e.post($S,{loginId:n});return yield CS(i),i.json()}))}),xS=Wi((e=>{var t,n,i,o,r;const s=xi(js,As,Cs,Ms,Sc)(e);return r=class extends s{constructor(){super(...arguments),t.add(this),n.set(this,void 0)}get sessionTokenViaCookie(){return u(this,t,"m",o).call(this,"session-token-via-cookie")}get refreshTokenViaCookie(){return u(this,t,"m",o).call(this,"refresh-token-via-cookie")}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get styleId(){return this.getAttribute("style-id")||Qs}get api(){return u(this,n,"f")||u(this,t,"m",i).call(this),u(this,n,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.init)||void 0===o?void 0:o.call(this),this.observeAttributes(["project-id","base-url","session-token-via-cookie","refresh-token-via-cookie"],(()=>{u(this,n,"f")&&u(this,t,"m",i).call(this)}))}))}},n=new WeakMap,t=new WeakSet,i=function(){this.logger.debug("creating an sdk instance"),h(this,n,((e,t,n)=>{const i=bi(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"user-profile-widget","x-descope-widget-id":n,"x-descope-widget-version":"0.21.7"}}));return{user:Object.assign(Object.assign({},IS({httpClient:i.httpClient,mock:t})),{logout:t?()=>c(void 0,void 0,void 0,(function*(){})):i.logout}),device:Object.assign({},RS({httpClient:i.httpClient,mock:t})),passkey:Object.assign({},ES({httpClient:i.httpClient,mock:t})),refresh:t?()=>c(void 0,void 0,void 0,(function*(){return{ok:!0}})):i.refresh,httpClient:i.httpClient}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName,sessionTokenViaCookie:this.sessionTokenViaCookie,refreshTokenViaCookie:this.refreshTokenViaCookie},"true"===this.mock,this.widgetId),"f")},o=function(e){var t;try{return null!==(t=JSON.parse(this.getAttribute(e)))&&void 0!==t?t:void 0}catch(t){return void this.logger.warn(`invalid JSON in "${e}" attribute, ignoring it`)}},r})),OS=Wi((e=>{const t=xi(yc({name:"widget",initialState:yS,reducers:{clearNotifications:e=>{e.notifications=[]},setCurrentTenantId:(e,{payload:t})=>{e.tenant.currentTenantId=t}},extraReducers:e=>{PC.reducer(e),LC.reducer(e),FC.reducer(e),qC.reducer(e),mS.reducer(e)},asyncActions:{getMe:PC.action,listDevices:LC.action,listPasskeys:FC.action,logout:qC.action,selectTenant:mS.action}}),Os,Cs,xS)(e);return class extends t{constructor(...e){super(...e),this.state=yS,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),AS="widget-flow",NS=Wi((e=>{var t,n,i;return i=class extends(xi(kc,Os,hd,OS,Sc,Cs,sa,Ic)(e)){constructor(){super(...arguments),t.add(this)}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.init)||void 0===i?void 0:i.call(this);const o=OC(AS);o&&(function(e){if(window.history.replaceState&&OC(e)){const t=new URL(window.location.href),n=new URLSearchParams(t.search);n.delete(e),t.search=n.toString(),window.history.replaceState({},"",t.toString())}}(AS),u(this,t,"m",n).call(this,o))}))}},t=new WeakSet,n=function(e){const t=this.createFlowModal({"data-id":"redirect-flow"});t.setContent(this.createFlowTemplate({flowId:e})),new Ca((()=>{var e;return null===(e=t.ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}).onSuccess((()=>{t.close(),this.actions.getMe()})),t.afterClose=()=>{t.remove()},t.open()},i})),jS=()=>{var e;return"function"==typeof(null===(e=window.descopeBridge)||void 0===e?void 0:e.registerWidget)},MS=Wi((e=>{const t=e;return class extends t{init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;jS()&&window.descopeBridge.registerWidget(this),yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}handleLogout(){const e=Object.create(null,{handleLogout:{get:()=>super.handleLogout}});return c(this,void 0,void 0,(function*(){var t;jS()?this.dispatchEvent(new CustomEvent("widget-logout")):yield null===(t=e.handleLogout)||void 0===t?void 0:t.call(this)}))}getWidgetConfig(){const e=Object.create(null,{getWidgetConfig:{get:()=>super.getWidgetConfig}});return c(this,void 0,void 0,(function*(){var t;const n=yield null===(t=e.getWidgetConfig)||void 0===t?void 0:t.call(this);return jS()&&"popup"===(null==n?void 0:n.flowTarget)?Object.assign(Object.assign({},n),{flowTarget:"modal"}):n}))}}})),PS=Wi((e=>{var t,n,i;return i=class extends(xi(Cs,Os,Hs,Xs,Cc("user-profile-widget"),OS)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){return c(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.init)||void 0===i?void 0:i.call(this);try{yield this.actions.getMe(),yield u(this,t,"m",n).call(this),yield this.onWidgetRootReady()}catch(i){const e=null==i?void 0:i.code,t=(null==i?void 0:i.message)||("string"==typeof i?i:"Widget failed to initialize");throw this.dispatchEvent(new CustomEvent("error",{detail:{code:e,description:"Widget failed to initialize",message:t}})),i}this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,n=function(){return c(this,void 0,void 0,(function*(){const e=Oi(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},i})),TS=Wi((e=>class extends(xi(sa,As)(e)){syncFlowTheme(e){e.theme=this.theme,this.observeAttributes(["theme"],(()=>{e.theme=this.theme}))}})),WS=Wi((e=>{var t,n,i,o,r;return r=class extends(xi(Cs,OS)(e)){constructor(){super(...arguments),t.add(this),i.set(this,null)}onFlowPopupClosed(){return c(this,void 0,void 0,(function*(){var e;return h(this,i,null!==(e=u(this,i,"f"))&&void 0!==e?e:u(this,t,"m",o).call(this).finally((()=>{h(this,i,null,"f")})),"f"),u(this,i,"f")}))}},i=new WeakMap,t=new WeakSet,n=function(){return c(this,void 0,void 0,(function*(){var e;try{const e=yield this.api.refresh();return(null==e?void 0:e.ok)?"ok":401===(null==e?void 0:e.code)?"unauthenticated":"failed"}catch(t){return null===(e=this.logger)||void 0===e||e.debug("Session refresh threw",t),"failed"}}))},o=function(){return c(this,void 0,void 0,(function*(){var e;let i=yield u(this,t,"m",n).call(this);if("failed"===i&&(i=yield u(this,t,"m",n).call(this)),"unauthenticated"!==i)return"failed"===i?(null===(e=this.logger)||void 0===e||e.error("Could not refresh the session after a popup flow; the widget may be showing stale data"),void this.dispatchEvent(new CustomEvent("error",{detail:{message:"session-refresh-failed"}}))):void this.actions.getMe();this.dispatchEvent(new CustomEvent("logout"))}))},r})),LS={"flow-id":"flow",theme:"theme","style-id":"style",locale:"locale",tenant:"tenant"},US=["client","form"],DS=Wi((e=>{var t,n,i,o,r,s,a,d;return d=class extends(xi(Cs,hd,Ic,TS,$c,WS,PS)(e)){constructor(){super(...arguments),t.add(this),n.set(this,"modal"),i.set(this,""),o.set(this,void 0)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n,i;h(this,o,null!==(n=u(this,o,"f"))&&void 0!==n?n:u(this,t,"m",r).call(this),"f"),yield u(this,o,"f"),yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this)}))}createFlowRunner({dataId:e,flowId:i,closeOnOutsideClick:o=!0,presetContent:r=!0,deferOpenUntilFirstPage:s=!1,onSuccess:d}){if(!i)return;if("popup"===u(this,n,"f")){const e=u(this,t,"m",a).call(this,i,d);if(e)return e}const l=this.createFlowModal(Object.assign({"data-id":e},o?{"close-on-outside-click":"true"}:{})),c=new Ca((()=>{var e;return null===(e=l.ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger});this.syncFlowTheme(c);let h=null;const f=()=>{null==h||h(),h=null},p=e=>{l.setContent(this.createFlowTemplate(Object.assign(Object.assign({flowId:i},s?{lazyStart:!1}:{}),e))),s&&(f(),h=c.onPageUpdated((()=>{l.open(),f()}))),c.onSuccess((()=>{l.close(),null==d||d()}))};return s?l.afterClose=f:r&&(l.afterClose=()=>p(),p()),{open:e=>{(e||!r||s)&&p(e),s||l.open()},close:()=>l.close(),remove:()=>l.remove(),refresh:()=>{r&&!s&&l.isClosed&&p()}}}},n=new WeakMap,i=new WeakMap,o=new WeakMap,t=new WeakSet,r=function(){return c(this,void 0,void 0,(function*(){const e=yield this.getWidgetConfig(),t=yield this.getHostedPageBaseUrl();h(this,n,((e,t,n)=>"popup"!==e?"modal":t?"popup":(null==n||n(),"modal"))(null==e?void 0:e.flowTarget,t,(()=>{var e;return null===(e=this.logger)||void 0===e?void 0:e.error("Flows are configured to open in a popup, but this project has no custom domain, so they will open in a modal instead")})),"f"),h(this,i,t||"","f")}))},s=function(e,t){const n=this.createFlowTemplate(Object.assign({flowId:e},t));return((e,t,n,i,o)=>{const r=(null==t?void 0:t.getAttribute("project-id"))||"",s=new URL(`${e.replace(/\/$/,"")}/${r}`);Object.entries(LS).forEach((([e,n])=>{const i=null==t?void 0:t.getAttribute(e);i&&s.searchParams.set(n,i)})),US.forEach((e=>{const i=null==t?void 0:t.getAttribute(e);if(i)try{Object.entries(JSON.parse(i)).forEach((([t,n])=>{null===n||"object"!=typeof n?s.searchParams.set(`${e}.${t}`,String(n)):null==o||o(e,t)}))}catch(t){null==n||n(e,i)}}));const a=s.toString();return a.length>2e3&&(null==i||i(a.length)),a})(u(this,i,"f"),n.content.querySelector("descope-wc"),((e,t)=>{var n;return null===(n=this.logger)||void 0===n?void 0:n.error(`Could not parse flow ${e} inputs`,t)}),(e=>{var t;return null===(t=this.logger)||void 0===t?void 0:t.error(`The flow popup url is ${e} characters, past the 2000 that is safe everywhere, so the popup may be refused before the flow starts. Pass identifiers in form and client inputs rather than data.`)}),((e,t)=>{var n;return null===(n=this.logger)||void 0===n?void 0:n.error(`The flow ${e} input "${t}" is an object, and a popup flow can only take text, so it was not sent. Pass an id instead.`)}))},a=function(e,n){if(!u(this,i,"f"))return;const o=new Za({logger:this.logger}),r=()=>{var e;return null===(e=this.onFlowPopupClosed)||void 0===e?void 0:e.call(this)};o.onUnauthenticated((()=>{var e;null===(e=this.logger)||void 0===e||e.info("The auth domain does not recognise this user; asking the app to sign in again"),this.dispatchEvent(new CustomEvent("flow-popup-unauthenticated"))}));const a=()=>{null==n||n(),r()};return o.onDone(a),o.onClosed(a),o.onParentFocus(a),{open:n=>{var i;o.open(u(this,t,"m",s).call(this,e,n))||(null===(i=this.logger)||void 0===i||i.error("The browser blocked the flow popup, so the flow did not start"),this.dispatchEvent(new CustomEvent("error",{detail:{message:"flow-popup-blocked"}})))},close:()=>o.close(),remove:()=>o.remove(),refresh:()=>{}}},d})),FS=Wi((e=>{var t,n,i,o,r,s;return s=class extends(xi(kc,sa,OS,Cs,PS,DS)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),o.set(this,Ni((e=>{this.avatar.image=e}))),r.set(this,Ni((e=>{this.avatar.displayName=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var s;yield null===(s=e.onWidgetRootReady)||void 0===s?void 0:s.call(this),u(this,t,"m",i).call(this),h(this,n,this.createFlowRunner({dataId:"update-pic",flowId:this.avatar.flowId,onSuccess:()=>this.actions.getMe()}),"f"),u(this,o,"f").call(this,HC(this.state)),u(this,r,"f").call(this,GC(this.state)),this.subscribe(u(this,o,"f").bind(this),HC),this.subscribe(u(this,r,"f").bind(this),GC)}))}},n=new WeakMap,o=new WeakMap,r=new WeakMap,t=new WeakSet,i=function(){this.avatar=new wa((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-avatar")}),{logger:this.logger}),this.avatar.onClick((()=>{var e;null===(e=u(this,n,"f"))||void 0===e||e.open()}))},s})),_S=Wi((e=>{var t,n,i,o,r,s,a;return a=class extends(xi(kc,OS,Cs,PS,DS)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),i.set(this,void 0),r.set(this,Ni((e=>{var t,o;this.emailUserAttr.value=e,null===(t=u(this,n,"f"))||void 0===t||t.refresh(),null===(o=u(this,i,"f"))||void 0===o||o.refresh()}))),s.set(this,Ni((e=>{this.emailUserAttr.badgeLabel=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var a;yield null===(a=e.onWidgetRootReady)||void 0===a?void 0:a.call(this),u(this,t,"m",o).call(this),h(this,n,this.createFlowRunner({dataId:"edit-email",flowId:this.emailUserAttr.editFlowId,onSuccess:()=>this.actions.getMe()}),"f"),h(this,i,this.createFlowRunner({dataId:"delete-email",flowId:this.emailUserAttr.deleteFlowId,onSuccess:()=>this.actions.getMe()}),"f"),u(this,r,"f").call(this,zC(this.state)),u(this,s,"f").call(this,XC(this.state)),this.subscribe(u(this,r,"f").bind(this),zC),this.subscribe(u(this,s,"f").bind(this),XC)}))}},n=new WeakMap,i=new WeakMap,r=new WeakMap,s=new WeakMap,t=new WeakSet,o=function(){this.emailUserAttr=new rd((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="email"]')}),{logger:this.logger}),this.emailUserAttr.onEditClick((()=>{var e;null===(e=u(this,n,"f"))||void 0===e||e.open()})),this.emailUserAttr.onDeleteClick((()=>{var e;null===(e=u(this,i,"f"))||void 0===e||e.open()}))},a})),qS=Wi((e=>{var t,n,i;return i=class extends(xi(OS,Cs,PS,ud)(e)){constructor(){super(...arguments),t.add(this)}handleLogout(){return c(this,void 0,void 0,(function*(){yield this.actions.logout(),this.dispatchEvent(new CustomEvent("logout"))}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",n).call(this)}))}},t=new WeakSet,n=function(){this.logout=new ka((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-button[data-id="logout"]')}),{logger:this.logger}),this.logout.onClick((()=>this.handleLogout()))},i})),BS=Wi((e=>{var t,n,i,o,r,s;return s=class extends(xi(kc,OS,Cs,PS,DS)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),i.set(this,void 0),r.set(this,Ni((e=>{var t,o;this.nameUserAttr.value=e,null===(t=u(this,n,"f"))||void 0===t||t.refresh(),null===(o=u(this,i,"f"))||void 0===o||o.refresh()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var s;yield null===(s=e.onWidgetRootReady)||void 0===s?void 0:s.call(this),u(this,t,"m",o).call(this),h(this,n,this.createFlowRunner({dataId:"edit-name",flowId:this.nameUserAttr.editFlowId,onSuccess:()=>this.actions.getMe()}),"f"),h(this,i,this.createFlowRunner({dataId:"delete-name",flowId:this.nameUserAttr.deleteFlowId,onSuccess:()=>this.actions.getMe()}),"f"),u(this,r,"f").call(this,GC(this.state)),this.subscribe(u(this,r,"f").bind(this),GC)}))}},n=new WeakMap,i=new WeakMap,r=new WeakMap,t=new WeakSet,o=function(){this.nameUserAttr=new rd((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="name"]')}),{logger:this.logger}),this.nameUserAttr.onEditClick((()=>{var e;null===(e=u(this,n,"f"))||void 0===e||e.open()})),this.nameUserAttr.onDeleteClick((()=>{var e;null===(e=u(this,i,"f"))||void 0===e||e.open()}))},s})),VS=Wi((e=>{var t,n,i,o,r,s;return s=class extends(xi(kc,OS,Cs,PS,Sc,DS)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),i.set(this,void 0),r.set(this,Ni((e=>{this.passkeyUserAuthMethod.fulfilled=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var s;yield null===(s=e.onWidgetRootReady)||void 0===s?void 0:s.call(this),u(this,t,"m",o).call(this),h(this,n,this.createFlowRunner({dataId:"add-passkey",flowId:this.passkeyUserAuthMethod.flowId,onSuccess:()=>this.actions.getMe()}),"f"),h(this,i,this.createFlowRunner({dataId:"remove-passkey",flowId:this.passkeyUserAuthMethod.fulfilledFlowId,onSuccess:()=>this.actions.getMe()}),"f"),u(this,r,"f").call(this,sS(this.state)),this.subscribe(u(this,r,"f").bind(this),sS)}))}},n=new WeakMap,i=new WeakMap,r=new WeakMap,t=new WeakSet,o=function(){this.passkeyUserAuthMethod=new sd((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="passkey"]')}),{logger:this.logger}),this.passkeyUserAuthMethod.onUnfulfilledButtonClick((()=>{var e;null===(e=u(this,n,"f"))||void 0===e||e.open()})),this.passkeyUserAuthMethod.onFulfilledButtonClick((()=>{var e;null===(e=u(this,i,"f"))||void 0===e||e.open()}))},s})),KS=Wi((e=>{var t,n;return n=class extends(xi(kc,OS,Cs,PS,DS)(e)){constructor(){super(...arguments),t.set(this,void 0)}initPasswordAuthMethod(){this.passwordUserAuthMethod=new sd((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="password"]')}),{logger:this.logger}),this.passwordUserAuthMethod.onUnfulfilledButtonClick((()=>{var e;null===(e=u(this,t,"f"))||void 0===e||e.open()}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),this.initPasswordAuthMethod(),h(this,t,this.createFlowRunner({dataId:"password",flowId:this.passwordUserAuthMethod.flowId}),"f")}))}},t=new WeakMap,n})),HS=Wi((e=>{var t,n,i,o,r,s,a;return a=class extends(xi(kc,OS,Cs,PS,DS)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),i.set(this,void 0),r.set(this,Ni((e=>{var t,o;this.phoneUserAttr.value=e,null===(t=u(this,n,"f"))||void 0===t||t.refresh(),null===(o=u(this,i,"f"))||void 0===o||o.refresh()}))),s.set(this,Ni((e=>{this.phoneUserAttr.badgeLabel=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var a;yield null===(a=e.onWidgetRootReady)||void 0===a?void 0:a.call(this),u(this,t,"m",o).call(this),h(this,n,this.createFlowRunner({dataId:"edit-phone",flowId:this.phoneUserAttr.editFlowId,onSuccess:()=>this.actions.getMe()}),"f"),h(this,i,this.createFlowRunner({dataId:"delete-phone",flowId:this.phoneUserAttr.deleteFlowId,onSuccess:()=>this.actions.getMe()}),"f"),u(this,r,"f").call(this,ZC(this.state)),u(this,s,"f").call(this,QC(this.state)),this.subscribe(u(this,r,"f").bind(this),ZC),this.subscribe(u(this,s,"f").bind(this),QC)}))}},n=new WeakMap,i=new WeakMap,r=new WeakMap,s=new WeakMap,t=new WeakSet,o=function(){this.phoneUserAttr=new rd((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="phone"]')}),{logger:this.logger}),this.phoneUserAttr.onEditClick((()=>{var e;null===(e=u(this,n,"f"))||void 0===e||e.open()})),this.phoneUserAttr.onDeleteClick((()=>{var e;null===(e=u(this,i,"f"))||void 0===e||e.open()}))},a})),zS=Wi((e=>{var t,n,i,o,r,s;return s=class extends(xi(kc,OS,Cs,PS,DS)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),i.set(this,void 0),r.set(this,Ni((e=>{this.recoveryEmailUserAttr.value=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var s;yield null===(s=e.onWidgetRootReady)||void 0===s?void 0:s.call(this),u(this,t,"m",o).call(this),h(this,n,this.createFlowRunner({dataId:"edit-recovery-email",flowId:this.recoveryEmailUserAttr.editFlowId,onSuccess:()=>this.actions.getMe()}),"f"),h(this,i,this.createFlowRunner({dataId:"delete-recovery-email",flowId:this.recoveryEmailUserAttr.deleteFlowId,onSuccess:()=>this.actions.getMe()}),"f"),u(this,r,"f").call(this,oS(this.state)),this.subscribe(u(this,r,"f").bind(this),oS)}))}},n=new WeakMap,i=new WeakMap,r=new WeakMap,t=new WeakSet,o=function(){this.recoveryEmailUserAttr=new rd((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="recoveryEmail"]')}),{logger:this.logger}),this.recoveryEmailUserAttr.onEditClick((()=>{var e;null===(e=u(this,n,"f"))||void 0===e||e.open()})),this.recoveryEmailUserAttr.onDeleteClick((()=>{var e;null===(e=u(this,i,"f"))||void 0===e||e.open()}))},s})),JS=Wi((e=>{var t,n,i,o,r,s;return s=class extends(xi(kc,OS,Cs,PS,DS)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),i.set(this,void 0),r.set(this,Ni((e=>{this.recoveryPhoneUserAttr.value=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var s;yield null===(s=e.onWidgetRootReady)||void 0===s?void 0:s.call(this),u(this,t,"m",o).call(this),h(this,n,this.createFlowRunner({dataId:"edit-recovery-phone",flowId:this.recoveryPhoneUserAttr.editFlowId,onSuccess:()=>this.actions.getMe()}),"f"),h(this,i,this.createFlowRunner({dataId:"delete-recovery-phone",flowId:this.recoveryPhoneUserAttr.deleteFlowId,onSuccess:()=>this.actions.getMe()}),"f"),u(this,r,"f").call(this,rS(this.state)),this.subscribe(u(this,r,"f").bind(this),rS)}))}},n=new WeakMap,i=new WeakMap,r=new WeakMap,t=new WeakSet,o=function(){this.recoveryPhoneUserAttr=new rd((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="recoveryPhone"]')}),{logger:this.logger}),this.recoveryPhoneUserAttr.onEditClick((()=>{var e;null===(e=u(this,n,"f"))||void 0===e||e.open()})),this.recoveryPhoneUserAttr.onDeleteClick((()=>{var e;null===(e=u(this,i,"f"))||void 0===e||e.open()}))},s})),GS=Wi((e=>{var t,n,i,o,r,s;return s=class extends(xi(kc,OS,Cs,PS,DS)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),i.set(this,void 0),r.set(this,Ni((e=>{this.totpUserAuthMethod.fulfilled=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var s;yield null===(s=e.onWidgetRootReady)||void 0===s?void 0:s.call(this),u(this,t,"m",o).call(this),h(this,n,this.createFlowRunner({dataId:"totp",flowId:this.totpUserAuthMethod.flowId,onSuccess:()=>this.actions.getMe()}),"f"),h(this,i,this.createFlowRunner({dataId:"remove-totp",flowId:this.totpUserAuthMethod.fulfilledFlowId,onSuccess:()=>this.actions.getMe()}),"f"),u(this,r,"f").call(this,aS(this.state)),this.subscribe(u(this,r,"f").bind(this),aS)}))}},n=new WeakMap,i=new WeakMap,r=new WeakMap,t=new WeakSet,o=function(){this.totpUserAuthMethod=new sd((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="totp"]')}),{logger:this.logger}),this.totpUserAuthMethod.onUnfulfilledButtonClick((()=>{var e;null===(e=u(this,n,"f"))||void 0===e||e.open()})),this.totpUserAuthMethod.onFulfilledButtonClick((()=>{var e;null===(e=u(this,i,"f"))||void 0===e||e.open()}))},s})),ZS=Wi((e=>{var t,n,i,o,r,s,a,d,l,h;return h=class extends(xi(kc,OS,Cs,PS,DS)(e)){constructor(){super(...arguments),t.add(this),n.set(this,{}),i.set(this,{}),o.set(this,{}),l.set(this,Ni((e=>{Object.keys(u(this,n,"f")).forEach((t=>{u(this,n,"f")[t].value=(e[t]||"").toString()})),u(this,t,"m",d).call(this)})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),u(this,t,"m",a).call(this),u(this,l,"f").call(this,cS(this.state)),this.subscribe(u(this,l,"f").bind(this),cS)}))}},n=new WeakMap,i=new WeakMap,o=new WeakMap,l=new WeakMap,t=new WeakSet,r=function(e,t,n){const o=e.getAttribute("edit-flow-id");o&&(u(this,i,"f")[o]=this.createFlowRunner({dataId:`edit-${t}`,flowId:o,onSuccess:()=>this.actions.getMe()}),n.onEditClick((()=>{var e,t;null===(t=null===(e=u(this,i,"f"))||void 0===e?void 0:e[o])||void 0===t||t.open()})))},s=function(e,t,n){const i=e.getAttribute("delete-flow-id");i&&(u(this,o,"f")[i]=this.createFlowRunner({dataId:`delete-${t}`,flowId:i,onSuccess:()=>this.actions.getMe()}),n.onDeleteClick((()=>{var e,t;null===(t=null===(e=u(this,o,"f"))||void 0===e?void 0:e[i])||void 0===t||t.open()})))},a=function(){var e;const i=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelectorAll('descope-user-attribute[data-id^="builtin."]');Array.from(i||[]).forEach((e=>{const i=e.getAttribute("data-id").replace("builtin.",""),o=new rd(e,{logger:this.logger});u(this,n,"f")[i]=o,u(this,t,"m",r).call(this,e,i,o),u(this,t,"m",s).call(this,e,i,o)}))},d=function(){Object.values(u(this,i,"f")).forEach((e=>null==e?void 0:e.refresh())),Object.values(u(this,o,"f")).forEach((e=>null==e?void 0:e.refresh()))},h}));var YS;!function(e){e.TEXT="text",e.NUMBER="number",e.BOOLEAN="boolean",e.SINGLE_SELECT="singleSelect",e.ARRAY="array",e.DATE="date"}(YS||(YS={}));const XS=Wi((e=>{var t,n,i,o,r,s,a;return n=class extends(xi(kc,OS,Cs,PS,DS)(e)){constructor(){super(...arguments),t.add(this),i.set(this,{}),o.set(this,{}),r.set(this,Ni((e=>{var i;const o=null===(i=this.shadowRoot)||void 0===i?void 0:i.querySelectorAll('descope-user-attribute[data-id^="customAttributes."]');Array.from(o).forEach((i=>{const o=i.getAttribute("data-id").replace("customAttributes.",""),r=i.getAttribute("data-type")||YS.TEXT,d=e[o],l=new rd(i,{logger:this.logger});l.value=n.getFormattedValue(r,d),u(this,t,"m",s).call(this,i,o,l),u(this,t,"m",a).call(this,i,o,l)}))})))}static getFormattedValue(e,t){return e===YS.DATE&&t?new Date(t).toLocaleString():e===YS.BOOLEAN&&void 0!==t?t?"True":"False":(t||"").toString()}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.onWidgetRootReady)||void 0===t?void 0:t.call(this),u(this,r,"f").call(this,lS(this.state)),this.subscribe(u(this,r,"f").bind(this),lS)}))}},i=new WeakMap,o=new WeakMap,r=new WeakMap,t=new WeakSet,s=function(e,t,n){const o=e.getAttribute("edit-flow-id");o&&(u(this,i,"f")[o]=this.createFlowRunner({dataId:`edit-${t}`,flowId:o,onSuccess:()=>this.actions.getMe()}),n.onEditClick((()=>{var e,t;null===(t=null===(e=u(this,i,"f"))||void 0===e?void 0:e[o])||void 0===t||t.open()})))},a=function(e,t,n){const i=e.getAttribute("delete-flow-id");i&&(u(this,o,"f")[i]=this.createFlowRunner({dataId:`delete-${t}`,flowId:i,onSuccess:()=>this.actions.getMe()}),n.onDeleteClick((()=>{var e,t;null===(t=null===(e=u(this,o,"f"))||void 0===e?void 0:e[i])||void 0===t||t.open()})))},n})),QS=Wi((e=>{var t,n,i,o,r;return r=class extends(xi(kc,sa,OS,Cs,PS,DS)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),this.updateDeviceList=Ni((e=>{this.deviceList.data=e}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var r;yield null===(r=e.onWidgetRootReady)||void 0===r?void 0:r.call(this),this.deviceList=new ad((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-trusted-devices")}),{logger:this.logger}),this.deviceList.isExists&&(yield u(this,t,"m",o).call(this),u(this,t,"m",i).call(this,uS(this.state)),h(this,n,this.createFlowRunner({dataId:"untrust-device",flowId:this.deviceList.flowId,presetContent:!1,onSuccess:()=>this.actions.listDevices({userId:KC(this.state)})}),"f"),this.subscribe(this.updateDeviceList.bind(this),uS))}))}},n=new WeakMap,t=new WeakSet,i=function(e){this.deviceList.onRemoveDeviceClick((({id:e})=>{var t;null===(t=u(this,n,"f"))||void 0===t||t.open({form:{deviceId:e}})})),this.deviceList.data=e},o=function(){return c(this,void 0,void 0,(function*(){yield this.actions.listDevices({userId:KC(this.state)})}))},r})),eI=Wi((e=>{var t,n,i,o,r,s,a;return a=class extends(xi(kc,OS,Cs,PS,Sc,DS)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),i.set(this,void 0),r.set(this,Ni((e=>{this.actions.listPasskeys({userId:e})}))),this.updatePasskeyList=Ni((e=>{this.userPasskeys.data=e}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var a;yield null===(a=e.onWidgetRootReady)||void 0===a?void 0:a.call(this),this.userPasskeys=new ld((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-user-passkeys")}),{logger:this.logger}),this.userPasskeys.isExists&&(u(this,t,"m",s).call(this,hS(this.state)),h(this,n,this.createFlowRunner({dataId:"add-user-passkey",flowId:this.userPasskeys.addPasskeyFlowId,onSuccess:()=>u(this,t,"m",o).call(this)}),"f"),h(this,i,this.createFlowRunner({dataId:"remove-user-passkey",flowId:this.userPasskeys.removePasskeyFlowId,presetContent:!1,onSuccess:()=>u(this,t,"m",o).call(this)}),"f"),this.subscribe(u(this,r,"f").bind(this),KC),this.subscribe(this.updatePasskeyList.bind(this),hS))}))}},n=new WeakMap,i=new WeakMap,r=new WeakMap,t=new WeakSet,o=function(){this.actions.getMe(),this.actions.listPasskeys({userId:KC(this.state)})},s=function(e){this.updatePasskeyList(e),this.userPasskeys.onAddPasskeyClick((()=>{var e;null===(e=u(this,n,"f"))||void 0===e||e.open()})),this.userPasskeys.onRemovePasskeyClick((({id:e})=>{var t;null===(t=u(this,i,"f"))||void 0===t||t.open({form:{externalId:KC(this.state),credentialId:e}})}))},a})),tI={success:(new DOMParser).parseFromString('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Checkmark">\n<path id="Shape" d="M10.0485 15.6396C9.5799 15.171 8.8201 15.171 8.35147 15.6396C7.88284 16.1082 7.88284 16.868 8.35147 17.3367L12.7072 21.6924C13.1759 22.1611 13.9357 22.1611 14.4043 21.6924L24.7152 11.3815C25.1838 10.9129 25.1838 10.1531 24.7152 9.68448C24.2466 9.21585 23.4868 9.21585 23.0181 9.68448L13.5558 19.1469L10.0485 15.6396Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,error:(new DOMParser).parseFromString('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Icon">\n<path id="Vector" d="M15.9998 26.6558C10.1118 26.6558 5.34375 21.8878 5.34375 15.9998C5.34375 10.1118 10.1118 5.34375 15.9998 5.34375C21.8878 5.34375 26.6558 10.1118 26.6558 15.9998C26.6558 21.8878 21.8878 26.6558 15.9998 26.6558ZM15.9998 24.4798C20.6718 24.4798 24.4798 20.7038 24.4798 15.9998C24.4798 11.3278 20.7038 7.51975 15.9998 7.51975C11.3278 7.51975 7.51975 11.2958 7.51975 15.9998C7.51975 20.6718 11.2958 24.4798 15.9998 24.4798ZM15.3278 9.34375H16.6718C17.0558 9.34375 17.3438 9.63175 17.3118 9.98375L16.9598 16.9278C16.9598 17.1838 16.7678 17.3438 16.5438 17.3438H15.4558C15.2318 17.3438 15.0398 17.1518 15.0398 16.9278L14.6878 9.98375C14.6878 9.63175 14.9758 9.34375 15.3278 9.34375ZM15.4558 19.4558H16.5438C16.9278 19.4558 17.2158 19.7438 17.1838 20.1278V21.1838C17.1838 21.5678 16.8958 21.8558 16.5438 21.8558H15.4558C15.0718 21.8558 14.7838 21.5678 14.7838 21.1838V20.1278C14.7838 19.7438 15.0718 19.4558 15.4558 19.4558Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild},nI=Wi((e=>{var t,n,i,o,r;return r=class extends(xi(Cs,OS,pd,Os)(e)){constructor(){super(...arguments),t.add(this),o.set(this,Ni((e=>{e.length&&(e.forEach((({type:e,msg:o})=>{const r=u(this,t,"m",i).call(this,e);r.setContent(u(this,t,"m",n).call(this,{type:e,msg:o})),r.show()})),setTimeout((()=>this.actions.clearNotifications())))})))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this),this.subscribe(u(this,o,"f").bind(this),fS)}))}},o=new WeakMap,t=new WeakSet,n=function({type:e,msg:t}){const n=tI[e],i=Object.assign((new DOMParser).parseFromString('<svg width="2em" height="2em" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Icon">\n<path id="Shape" d="M10.6712 12L7.27521 8.60406C6.90826 8.23711 6.90826 7.64216 7.27521 7.27521C7.64216 6.90826 8.23711 6.90826 8.60406 7.27521L12 10.6712L15.3959 7.27521C15.7629 6.90826 16.3578 6.90826 16.7248 7.27521C17.0917 7.64216 17.0917 8.23711 16.7248 8.60406L13.3288 12L16.7248 15.3959C17.0917 15.7629 17.0917 16.3578 16.7248 16.7248C16.3578 17.0917 15.7629 17.0917 15.3959 16.7248L12 13.3288L8.60406 16.7248C8.23711 17.0917 7.64216 17.0917 7.27521 16.7248C6.90826 16.3578 6.90826 15.7629 7.27521 15.3959L10.6712 12Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,{slot:"close"});return`${(null==n?void 0:n.outerHTML)||""}${t}${i.outerHTML}`},i=function(e){return this.createNotification({mode:e,duration:"error"===e?0:3e3,position:"bottom-start",size:"sm"})},r})),iI=Wi((e=>{var t,n,i,o,r,s,a,d,l,f,p;return p=class extends(xi(OS,Cs,PS)(e)){constructor(){super(...arguments),t.add(this),n.set(this,null),o.set(this,(e=>c(this,void 0,void 0,(function*(){const t=e.target.value;yield this.actions.selectTenant(t)})))),r.set(this,(e=>{const i=vS(e);this.tenantSelector.value!==i&&u(this,t,"m",l).call(this,i);const{loading:o,error:r}=e.selectTenant,a=null!==e.tenant.previousTenantId,d=i!==u(this,n,"f");!i||o||r||a||!d||(h(this,n,i,"f"),u(this,t,"m",s).call(this))}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),this.actions.setCurrentTenantId((()=>{const e=Rn();return BC(e)})()),u(this,t,"m",i).call(this),u(this,t,"m",f).call(this),u(this,t,"m",d).call(this,pS(this.state)),this.subscribe(u(this,r,"f").bind(this))}))}},n=new WeakMap,o=new WeakMap,r=new WeakMap,t=new WeakSet,i=function(){this.tenantSelector=new dd((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-combo-box[name="tenantSelector"]')}),{logger:this.logger}),this.tenantSelector.onInput(u(this,o,"f"))},s=function(){const e=vS(this.state);this.dispatchEvent(new CustomEvent("tenant-changed",{bubbles:!0,composed:!0,detail:{tenantId:e}})),this.tenantSelector.shouldReload&&u(this,t,"m",a).call(this)},a=function(){setTimeout((()=>window.location.reload()),this.tenantSelector.refreshTimeout)},d=function(e){return c(this,void 0,void 0,(function*(){const t=e.map((e=>({label:e.tenantName||e.tenantId,value:e.tenantId})));yield this.tenantSelector.setData(t)}))},l=function(e){e&&(this.tenantSelector.value=e)},f=function(){this.tenantSelector.setAllowCustomValue(!0),setTimeout((()=>{u(this,t,"m",l).call(this,vS(this.state)),this.tenantSelector.setAllowCustomValue(!1)}))},p})),oI=Wi((e=>{var t,n,i,o,r,s;return s=class extends(xi(kc,OS,Cs,PS,DS)(e)){constructor(){super(...arguments),t.add(this),n.set(this,[]),i.set(this,void 0)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o,s;yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),u(this,t,"m",r).call(this),h(this,i,this.createFlowRunner({dataId:"generic-flow-modal",flowId:null===(s=u(this,n,"f")[0])||void 0===s?void 0:s.flowId,presetContent:!1,deferOpenUntilFirstPage:!0,onSuccess:()=>this.actions.getMe()}),"f"),u(this,n,"f").forEach((e=>e.enable()))}))}},n=new WeakMap,i=new WeakMap,t=new WeakSet,o=function(e){const t=new Sa(e,{logger:this.logger});t.onClick((()=>{var e;null===(e=u(this,i,"f"))||void 0===e||e.open({flowId:t.flowId,client:{userId:KC(this.state)}})})),u(this,n,"f").push(t)},r=function(){var e;const n=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelectorAll("[data-generic-flow-button-id]");Array.from(n).forEach((e=>{u(this,t,"m",o).call(this,e)}))},s})),rI=Wi((e=>class extends(xi(fa,sa,NS,XS,_S,FS,BS,HS,zS,JS,VS,KS,GS,ZS,qS,MS,QS,eI,nI,iI,oI,Oc)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),sI=xi((e=>class extends(rI(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this);const n=customElements.get("descope-wc")||(yield Promise.resolve().then((function(){return Ph})).then((e=>e.default))),i=this;n.sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"user-profile-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.21.7"},get sessionTokenViaCookie(){return i.sessionTokenViaCookie},get refreshTokenViaCookie(){return i.refreshTokenViaCookie}}}))}}))(HTMLElement);customElements.define("descope-user-profile-widget",sI);var aI=Object.freeze({__proto__:null,default:sI});const dI=(e,t,n,i={})=>{var o,r,s,a;return[Math.min(Math.max(t,("all"===i.left?e.offsetWidth:null!==(o=i.left)&&void 0!==o?o:0)-e.offsetWidth),window.innerWidth-("all"===i.right?e.offsetWidth:null!==(r=i.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===i.top?e.offsetHeight:null!==(s=i.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===i.bottom?e.offsetHeight:null!==(a=i.bottom)&&void 0!==a?a:0))]};var lI,cI,uI,hI,fI,pI,vI,gI,mI,yI;const bI=document.createElement("template");bI.innerHTML='\n<div class="debugger">\n <div class="header">\n <span>Debugger messages</span>\n </div>\n <div class="content">\n <div class="empty-state">\n No errors detected 👀\n </div>\n </div>\n</div>\n';const wI=xi(Gs)(HTMLElement);class $I extends wI{constructor(){var e;super(),lI.add(this),cI.set(this,new qi({messages:[]})),uI.set(this,void 0),hI.set(this,void 0),fI.set(this,void 0),pI.set(this,{resize:u(this,lI,"m",yI).bind(this)}),this.attachShadow({mode:"open"}),null===(e=this.shadowRoot)||void 0===e||e.appendChild(bI.content.cloneNode(!0)),this.injectStyle('\n.debugger {\n all: initial;\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n'),h(this,uI,this.shadowRoot.querySelector(".debugger"),"f"),u(this,uI,"f").style.top="32px",u(this,uI,"f").style.left=window.innerWidth-300-32+"px",h(this,hI,u(this,uI,"f").querySelector(".content"),"f"),h(this,fI,u(this,uI,"f").querySelector(".header"),"f")}updateData(e){u(this,cI,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((e,t,n)=>{let i=0,o=0,r=0,s=0;function a(t){t.preventDefault(),i=r-t.clientX,o=s-t.clientY,r=t.clientX,s=t.clientY;const[a,d]=dI(e,e.offsetLeft-i,e.offsetTop-o,n);e.style.top=`${d}px`,e.style.left=`${a}px`}function d(){document.onmouseup=null,document.onmousemove=null}function l(e){e.preventDefault(),r=e.clientX,s=e.clientY,document.onmouseup=d,document.onmousemove=a}t?t.onmousedown=l:e.onmousedown=l})(u(this,uI,"f"),u(this,fI,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",u(this,pI,"f").resize),(e=u(this,uI,"f")).onmousemove=t=>{var n;const i=t.target;(i.w&&i.w!==i.offsetWidth||i.h&&i.h!==i.offsetHeight)&&(null===(n=e.onresize)||void 0===n||n.call(e,t)),i.w=i.offsetWidth,i.h=i.offsetHeight},u(this,uI,"f").onresize=u(this,lI,"m",mI).bind(this),u(this,cI,"f").subscribe(u(this,lI,"m",vI).bind(this))}disconnectedCallback(){u(this,cI,"f").unsubscribeAll(),window.removeEventListener("resize",u(this,pI,"f").resize)}}cI=new WeakMap,uI=new WeakMap,hI=new WeakMap,fI=new WeakMap,pI=new WeakMap,lI=new WeakSet,vI=function(e){u(this,lI,"m",gI).call(this,e),u(this,lI,"m",mI).call(this)},gI=function(e){u(this,hI,"f").innerHTML=e.messages.map((e=>`\n <div class="msg">\n <svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M5.99984 13.167L8.99984 10.167L11.9998 13.167L13.1665 12.0003L10.1665 9.00033L13.1665 6.00033L11.9998 4.83366L8.99984 7.83366L5.99984 4.83366L4.83317 6.00033L7.83317 9.00033L4.83317 12.0003L5.99984 13.167ZM8.99984 17.3337C7.84706 17.3337 6.76373 17.1148 5.74984 16.677C4.73595 16.2398 3.854 15.6462 3.104 14.8962C2.354 14.1462 1.76039 13.2642 1.32317 12.2503C0.885393 11.2364 0.666504 10.1531 0.666504 9.00033C0.666504 7.84755 0.885393 6.76421 1.32317 5.75033C1.76039 4.73644 2.354 3.85449 3.104 3.10449C3.854 2.35449 4.73595 1.7606 5.74984 1.32283C6.76373 0.885603 7.84706 0.666992 8.99984 0.666992C10.1526 0.666992 11.2359 0.885603 12.2498 1.32283C13.2637 1.7606 14.1457 2.35449 14.8957 3.10449C15.6457 3.85449 16.2393 4.73644 16.6765 5.75033C17.1143 6.76421 17.3332 7.84755 17.3332 9.00033C17.3332 10.1531 17.1143 11.2364 16.6765 12.2503C16.2393 13.2642 15.6457 14.1462 14.8957 14.8962C14.1457 15.6462 13.2637 16.2398 12.2498 16.677C11.2359 17.1148 10.1526 17.3337 8.99984 17.3337ZM8.99984 15.667C10.8609 15.667 12.4373 15.0212 13.729 13.7295C15.0207 12.4378 15.6665 10.8614 15.6665 9.00033C15.6665 7.13921 15.0207 5.56283 13.729 4.27116C12.4373 2.97949 10.8609 2.33366 8.99984 2.33366C7.13873 2.33366 5.56234 2.97949 4.27067 4.27116C2.979 5.56283 2.33317 7.13921 2.33317 9.00033C2.33317 10.8614 2.979 12.4378 4.27067 13.7295C5.56234 15.0212 7.13873 15.667 8.99984 15.667Z" fill="#ED404A"/>\n</svg>\n\n <div class="msg_content">\n <div class="msg_title">\n ${Ki(e.title)}\n </div>\n <div class="msg_desc">\n ${Ki(e.description)}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},mI=function(){u(this,hI,"f").querySelectorAll(".msg").forEach((e=>{const t=e,n=t.querySelector(".msg_desc"),i=n.scrollWidth>n.clientWidth,o=n.clientHeight>20;i||o?(t.classList.add("collapsible"),t.onclick=e=>{e.target.classList.contains("msg_desc")||t.classList.toggle("collapsed")}):(t.classList.remove("collapsible"),t.onclick=null)}))},yI=function(){const[e,t]=dI(u(this,uI,"f"),Number.parseInt(u(this,uI,"f").style.left,10),Number.parseInt(u(this,uI,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});u(this,uI,"f").style.top=`${t}px`,u(this,uI,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",$I);var kI=Object.freeze({__proto__:null});const CI=(e,t,n,i={})=>{var o,r,s,a;return[Math.min(Math.max(t,("all"===i.left?e.offsetWidth:null!==(o=i.left)&&void 0!==o?o:0)-e.offsetWidth),window.innerWidth-("all"===i.right?e.offsetWidth:null!==(r=i.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===i.top?e.offsetHeight:null!==(s=i.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===i.bottom?e.offsetHeight:null!==(a=i.bottom)&&void 0!==a?a:0))]},SI=(e,t,n)=>{let i=0,o=0,r=0,s=0;function a(t){t.preventDefault(),i=r-t.clientX,o=s-t.clientY,r=t.clientX,s=t.clientY;const[a,d]=CI(e,e.offsetLeft-i,e.offsetTop-o,n);e.style.top=`${d}px`,e.style.left=`${a}px`}function d(){document.onmouseup=null,document.onmousemove=null}function l(e){e.preventDefault(),r=e.clientX,s=e.clientY,document.onmouseup=d,document.onmousemove=a}t?t.onmousedown=l:e.onmousedown=l};var II,RI,EI,xI,OI,AI,NI,jI,MI,PI,TI;const WI=document.createElement("template");WI.innerHTML='\n<div class="debugger">\n <div class="header">\n <span>Debugger messages</span>\n </div>\n <div class="content">\n <div class="empty-state">\n No errors detected 👀\n </div>\n </div>\n</div>\n';const LI=xi(Gs)(HTMLElement);class UI extends LI{constructor(){super(),II.add(this),RI.set(this,new ns({messages:[]})),EI.set(this,void 0),xI.set(this,void 0),OI.set(this,void 0),AI.set(this,{resize:u(this,II,"m",TI).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(WI.content.cloneNode(!0)),h(this,EI,this.shadowRoot.querySelector(".debugger"),"f"),h(this,xI,u(this,EI,"f").querySelector(".content"),"f"),h(this,OI,u(this,EI,"f").querySelector(".header"),"f"),u(this,II,"m",NI).call(this)}updateData(e){u(this,RI,"f").update((t=>({messages:t.messages.concat(e)})))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;null===(t=e.init)||void 0===t||t.call(this),SI(u(this,EI,"f"),u(this,OI,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",u(this,AI,"f").resize),(e=>{e.onmousemove=t=>{(t.target.w&&t.target.w!==t.target.offsetWidth||t.target.h&&t.target.h!==t.target.offsetHeight)&&e.onresize(t),t.target.w=t.target.offsetWidth,t.target.h=t.target.offsetHeight}})(u(this,EI,"f")),u(this,EI,"f").onresize=u(this,II,"m",PI).bind(this),u(this,RI,"f").subscribe(u(this,II,"m",jI).bind(this))}))}disconnectedCallback(){u(this,RI,"f").unsubscribeAll(),window.removeEventListener("resize",u(this,AI,"f").resize)}}RI=new WeakMap,EI=new WeakMap,xI=new WeakMap,OI=new WeakMap,AI=new WeakMap,II=new WeakSet,NI=function(){this.injectStyle('\n .debugger {\n all: initial;\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n'),u(this,EI,"f").style.top="32px",u(this,EI,"f").style.left=window.innerWidth-300-32+"px"},jI=function(e){u(this,II,"m",MI).call(this,e),u(this,II,"m",PI).call(this)},MI=function(e){u(this,xI,"f").innerHTML=e.messages.map((e=>`\n <div class="msg">\n <svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M5.99984 13.167L8.99984 10.167L11.9998 13.167L13.1665 12.0003L10.1665 9.00033L13.1665 6.00033L11.9998 4.83366L8.99984 7.83366L5.99984 4.83366L4.83317 6.00033L7.83317 9.00033L4.83317 12.0003L5.99984 13.167ZM8.99984 17.3337C7.84706 17.3337 6.76373 17.1148 5.74984 16.677C4.73595 16.2398 3.854 15.6462 3.104 14.8962C2.354 14.1462 1.76039 13.2642 1.32317 12.2503C0.885393 11.2364 0.666504 10.1531 0.666504 9.00033C0.666504 7.84755 0.885393 6.76421 1.32317 5.75033C1.76039 4.73644 2.354 3.85449 3.104 3.10449C3.854 2.35449 4.73595 1.7606 5.74984 1.32283C6.76373 0.885603 7.84706 0.666992 8.99984 0.666992C10.1526 0.666992 11.2359 0.885603 12.2498 1.32283C13.2637 1.7606 14.1457 2.35449 14.8957 3.10449C15.6457 3.85449 16.2393 4.73644 16.6765 5.75033C17.1143 6.76421 17.3332 7.84755 17.3332 9.00033C17.3332 10.1531 17.1143 11.2364 16.6765 12.2503C16.2393 13.2642 15.6457 14.1462 14.8957 14.8962C14.1457 15.6462 13.2637 16.2398 12.2498 16.677C11.2359 17.1148 10.1526 17.3337 8.99984 17.3337ZM8.99984 15.667C10.8609 15.667 12.4373 15.0212 13.729 13.7295C15.0207 12.4378 15.6665 10.8614 15.6665 9.00033C15.6665 7.13921 15.0207 5.56283 13.729 4.27116C12.4373 2.97949 10.8609 2.33366 8.99984 2.33366C7.13873 2.33366 5.56234 2.97949 4.27067 4.27116C2.979 5.56283 2.33317 7.13921 2.33317 9.00033C2.33317 10.8614 2.979 12.4378 4.27067 13.7295C5.56234 15.0212 7.13873 15.667 8.99984 15.667Z" fill="#ED404A"/>\n</svg>\n\n <div class="msg_content">\n <div class="msg_title">\n ${Ki(e.title)}\n </div>\n <div class="msg_desc">\n ${Ki(e.description)}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},PI=function(){u(this,xI,"f").querySelectorAll(".msg").forEach((e=>{const t=e.querySelector(".msg_desc"),n=t.scrollWidth>t.clientWidth,i=t.clientHeight>20;n||i?(e.classList.add("collapsible"),e.onclick=t=>{t.target.classList.contains("msg_desc")||e.classList.toggle("collapsed")}):(e.classList.remove("collapsible"),e.onclick=null)}))},TI=function(){const[e,t]=CI(u(this,EI,"f"),Number.parseInt(u(this,EI,"f").style.left,10),Number.parseInt(u(this,EI,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});u(this,EI,"f").style.top=`${t}px`,u(this,EI,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",UI);var DI=Object.freeze({__proto__:null,default:UI});e.AccessKeyManagement=to,e.ApplicationsPortal=io,e.AuditManagement=ro,e.AuthProvider=({projectId:e,baseUrl:o="",baseStaticUrl:a="",baseCdnUrl:d="",sessionTokenViaCookie:l=!1,refreshTokenViaCookie:c=!1,hooks:u,persistTokens:h=!0,autoRefresh:f=!0,oidcConfig:p,storeLastAuthenticatedUser:v=!0,keepLastAuthenticatedUserAfterLogout:g=!1,refreshCookieName:m="",getExternalToken:y,customStorage:b,children:w})=>{const[$,k]=t.useState(),[C,S]=t.useState(),[I,R]=t.useState(),[E,x]=t.useState(!1),[O,A]=t.useState(!1),[N,j]=t.useState(!1),[M,P]=t.useState(!!p),[T,W]=t.useState(!1),[L,U]=t.useState(!1),D=t.useRef(!1),F=(({projectId:e,baseUrl:n,persistTokens:i,autoRefresh:o,sessionTokenViaCookie:r,refreshTokenViaCookie:a,refreshCookieName:d,oidcConfig:l,storeLastAuthenticatedUser:c,keepLastAuthenticatedUserAfterLogout:u,getExternalToken:h,hooks:f,customStorage:p})=>t.useMemo((()=>{if(e)return $i({projectId:e,baseUrl:n,sessionTokenViaCookie:r,refreshTokenViaCookie:a,baseHeaders:s,persistTokens:i,autoRefresh:o,refreshCookieName:d,oidcConfig:l,storeLastAuthenticatedUser:c,keepLastAuthenticatedUserAfterLogout:u,hooks:f,getExternalToken:h,customStorage:p})}),[e,n,JSON.stringify(r),JSON.stringify(a),h,p]))({projectId:e,baseUrl:o,persistTokens:h,autoRefresh:f,sessionTokenViaCookie:l,refreshTokenViaCookie:c,hooks:u,oidcConfig:p,storeLastAuthenticatedUser:v,keepLastAuthenticatedUserAfterLogout:g,refreshCookieName:m,getExternalToken:y,customStorage:b});t.useEffect((()=>{if(F){const e=F.onSessionTokenChange(S),t=F.onUserChange(k),n=F.onIsAuthenticatedChange(x),i=F.onClaimsChange(R);return()=>{e(),t(),n(),i()}}}),[F]);const _=t.useRef(!1),q=t.useRef(!1);t.useEffect((()=>{F&&p&&!D.current&&(D.current=!0,F.oidc.finishLoginIfNeed().finally((()=>{P(!1),_.current=!0,W(!0)})))}),[]);const B=t.useCallback((()=>{if(r())return;if(_.current)return;_.current=!0,j(!0);const e=()=>{j(!1),W(!0)};i(null==F?void 0:F.refresh)(void 0,!0).then(e,e)}),[F]),V=t.useCallback((()=>{if(q.current)return;q.current=!0,A(!0);const e=()=>{A(!1),U(!0)};i(F.me)().then(e,e)}),[F]),K=t.useMemo((()=>({fetchUser:V,user:$,isUserLoading:O,isUserFetchStarted:q.current,isUserFetchCompleted:L,fetchSession:B,session:C,isAuthenticated:E,isSessionLoading:N,isOidcLoading:M,isSessionFetchStarted:_.current,isSessionFetchCompleted:T,projectId:e,baseUrl:o,baseStaticUrl:a,baseCdnUrl:d,storeLastAuthenticatedUser:v,keepLastAuthenticatedUserAfterLogout:g,refreshCookieName:m,sessionTokenViaCookie:l,refreshTokenViaCookie:c,customStorage:b,setUser:k,setSession:S,setIsAuthenticated:x,claims:I,sdk:F})),[V,$,O,q.current,L,B,C,E,N,M,_.current,T,e,o,a,d,g,m,JSON.stringify(l),JSON.stringify(c),b,k,S,x,I,F]);return t.createElement(n.Provider,{value:K},w)},e.Descope=Zi,e.OutboundApplications=ao,e.RoleManagement=co,e.SignInFlow=e=>t.createElement(Zi,Object.assign({},e,{flowId:"sign-in"})),e.SignUpFlow=e=>t.createElement(Zi,Object.assign({},e,{flowId:"sign-up"})),e.SignUpOrInFlow=e=>t.createElement(Zi,Object.assign({},e,{flowId:"sign-up-or-in"})),e.TenantProfile=ho,e.UserManagement=po,e.UserProfile=go,e.baseHeaders=s,e.getCurrentTenant=Ei,e.getJwtPermissions=Ii,e.getJwtRoles=Ri,e.getRefreshToken=Si,e.getSessionToken=Ci,e.isRefreshTokenExpired=(e=Si())=>null==wi?void 0:wi.isJwtExpired(e),e.isSessionTokenExpired=(e=Ci())=>null==wi?void 0:wi.isJwtExpired(e),e.refresh=(e=Si())=>null==wi?void 0:wi.refresh(e),e.useDescope=()=>{const{sdk:e}=Yi();return t.useMemo((()=>e||new Proxy(ki(),Qi)),[e])},e.useSession=()=>{const{session:e,claims:n,isSessionLoading:i,isOidcLoading:o,fetchSession:s,isSessionFetchStarted:a,isSessionFetchCompleted:d,isAuthenticated:l}=Yi(),c=t.useRef(i||o);t.useMemo((()=>{c.current=i||o}),[i,o,d]);const u=!l&&!i&&!r();return t.useMemo((()=>{u&&!a&&(c.current=!0)}),[a]),t.useEffect((()=>{u&&s()}),[s]),{isSessionLoading:c.current,sessionToken:e,claims:n,isAuthenticated:l}},e.useUser=()=>{const{user:e,fetchUser:n,isUserLoading:i,isAuthenticated:o,isUserFetchStarted:r,isUserFetchCompleted:s}=Yi(),[a,d]=t.useState(!1),l=t.useRef(i),c=t.useMemo((()=>!e&&!i&&o&&!a),[n,o,a]);return t.useMemo((()=>{l.current=i}),[i,s]),t.useMemo((()=>{c&&!r&&(l.current=!0)}),[c,r]),t.useEffect((()=>{c&&(d(!0),n())}),[c]),{isUserLoading:l.current,user:e}}}));
3
3
  //# sourceMappingURL=index.umd.js.map