@descope/tenant-profile-widget 0.2.23 → 0.3.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/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  /**
3
- * @descope/tenant-profile-widget v0.2.23
3
+ * @descope/tenant-profile-widget v0.3.0
4
4
  */
5
- import{__awaiter as t,__classPrivateFieldGet as e,__classPrivateFieldSet as i}from"tslib";import{createTemplate as s,kebabCase as n,createSingletonMixin as o,compose as r,withMemCache as a}from"@descope/sdk-helpers";import{projectIdMixin as d,observeAttributesMixin as l,loggerMixin as h,baseUrlMixin as c,cookieConfigMixin as u,createStateManagementMixin as f,initLifecycleMixin as m,modalMixin as v,themeMixin as g,staticResourcesMixin as p,createValidateAttributesMixin as w,descopeUiMixin as b,initElementMixin as S,debuggerMixin as y}from"@descope/sdk-mixins";import{FlowDriver as k,LinkDriver as C,UserAttributeDriver as R}from"@descope/sdk-component-drivers";import{createAsyncThunk as I}from"@reduxjs/toolkit";import"@descope/core-js-sdk";import x from"@descope/web-js-sdk";import{createSelector as U}from"reselect";import"@descope/web-component";const W=(t={})=>{const e=s("<descope-wc></descope-wc>");return Object.entries(t).forEach((([t,i])=>{e.content.querySelector("descope-wc").setAttribute(n(t),i)})),e};function E(t){return new URLSearchParams(window.location.search).get(t)}const O=t=>(...e)=>i=>{i.addCase(t.pending,((t,i)=>{e.forEach((({onPending:e})=>{null==e||e(t,i)}))})),i.addCase(t.fulfilled,((t,i)=>{e.forEach((({onFulfilled:e})=>{null==e||e(t,i)}))})),i.addCase(t.rejected,((t,i)=>{e.forEach((({onRejected:e})=>{null==e||e(t,i)}))}))},D=t=>({onFulfilled:e=>{t(e).loading=!1},onPending:e=>{t(e).loading=!0,t(e).error=null},onRejected:(e,i)=>{t(e).loading=!1,t(e).error=i.error}}),j=I("users/me",((t,{extra:{api:e}})=>e.user.me())),T=O(j)({onFulfilled:(t,e)=>{t.me.data=e.payload}},D((t=>t.me))),M={action:j,reducer:T},A=I("tenant/details",((t,{extra:{api:e}})=>e.tenant.details())),N=O(A)({onFulfilled:(t,e)=>{t.tenant.data=e.payload}},D((t=>t.tenant))),F={action:A,reducer:N},L=I("tenant/adminLinkSso",((t,{extra:{api:e}})=>e.tenant.adminLinkSso())),q={action:L,reducer:O(L)({onFulfilled:(t,e)=>{var i;t.tenantAdminLinkSSO.data=(null===(i=e.payload)||void 0===i?void 0:i.adminSSOConfigurationLink)||""}},D((t=>t.tenantAdminLinkSSO)))},P={me:{loading:!1,error:null,data:{}},tenant:{loading:!1,error:null,data:{}},tenantAdminLinkSSO:{loading:!1,error:null,data:""}},$={me:"/v1/auth/me"},B={details:"/v1/mgmt/tenant",adminLinkSso:"/v1/mgmt/tenant/adminlinks/sso/authenticated"},J=e=>t(void 0,void 0,void 0,(function*(){const t=yield e.text(),i=JSON.parse(t);if(!e.ok){const t=`${i.errorDescription}${i.errorMessage?`: ${i.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(i),e.text=()=>Promise.resolve(t)})),H=()=>t(void 0,void 0,void 0,(function*(){return new Promise((t=>{t({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})}))})),z=()=>t(void 0,void 0,void 0,(function*(){return new Promise((t=>{t({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})}))})),X=()=>t(void 0,void 0,void 0,(function*(){return new Promise((t=>{t({adminSSOConfigurationLink:"_blank"})}))})),Y=({httpClient:e,tenantId:i,mock:s})=>{const n=encodeURIComponent(i||""),o=`?tenant=${n}&id=${n}`;return{details:()=>t(void 0,void 0,void 0,(function*(){if(s)return z();if(!i)throw new Error("tenantId is not defined");const t=`${B.details}${o}`,n=yield e.get(t);yield J(n);return yield n.json()})),adminLinkSso:()=>t(void 0,void 0,void 0,(function*(){if(s)return X();if(!i)throw new Error("tenantId is not defined");const t=yield e.post(`${B.adminLinkSso}?tenant=${n}`,{tenantId:n},{headers:{"Content-Type":"application/json"}});yield J(t);return yield t.json()}))}},_=({httpClient:e,mock:i})=>({me:()=>t(void 0,void 0,void 0,(function*(){if(i)return H();const t=yield e.get($.me);return yield J(t),t.json()}))}),G=o((s=>{var n,o,a,f;const m=r(d,l,h,c,u)(s);return f=class extends m{constructor(){super(...arguments),n.add(this),o.set(this,void 0)}get widgetId(){return this.getAttribute("widget-id")}get tenantId(){return this.getAttribute("tenant")}get mock(){return this.getAttribute("mock")}get api(){return e(this,o,"f")||e(this,n,"m",a).call(this),e(this,o,"f")}init(){const i=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.init)||void 0===t?void 0:t.call(this),this.observeAttributes(["project-id","base-url","tenant","mock"],(()=>{e(this,o,"f")&&e(this,n,"m",a).call(this)}))}))}},o=new WeakMap,n=new WeakSet,a=function(){this.logger.debug("creating an sdk instance"),i(this,o,((t,e,i,s)=>{const n=x(Object.assign(Object.assign({},t),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"tenant-profile-widget","x-descope-widget-id":s,"x-descope-widget-version":"0.2.23"}}));return{user:_({httpClient:n.httpClient,mock:i}),tenant:Y({httpClient:n.httpClient,tenantId:e,mock:i})}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},this.tenantId,"true"===this.mock,this.widgetId),"f")},f})),V=o((t=>{const e=r(f({name:"widget",initialState:P,reducers:{},extraReducers:t=>{M.reducer(t),F.reducer(t),q.reducer(t)},asyncActions:{getMe:M.action,getTenant:F.action,getTenantAdminLinkSSO:q.action}}),m,h,G)(t);return class extends e{constructor(...t){super(...t),this.state=P,this.subscribe((t=>{this.logger.debug("State update:",t),this.state=t}))}}})),K="widget-flow",Q=o((i=>{var s,n,o;return o=class extends(r(m,v,V,u,h,g)(i)){constructor(){super(...arguments),s.add(this)}init(){const i=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.init)||void 0===t?void 0:t.call(this);const o=E(K);o&&(!function(t){if(window.history.replaceState&&E(t)){const e=new URL(window.location.href),i=new URLSearchParams(e.search);i.delete(t),e.search=i.toString(),window.history.replaceState({},"",e.toString())}}(K),e(this,s,"m",n).call(this,o))}))}},s=new WeakSet,n=function(t){const e=this.createModal({"data-id":"redirect-flow"});e.setContent(W({projectId:this.projectId,flowId:t,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme}));new k((()=>{var t;return null===(t=e.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}).onSuccess((()=>{e.close(),this.actions.getMe(),this.actions.getTenant(),this.actions.getTenantAdminLinkSSO()})),e.afterClose=()=>{e.remove()},e.open()},o})),Z=t=>t.tenant.data,tt=t=>t.tenantAdminLinkSSO.data,et=U(Z,(t=>t.customAttributes||{})),it=U(Z,(t=>t.name||"")),st=U(Z,(t=>t.selfProvisioningDomains||[])),nt=U(Z,(t=>t.enforceSSOExclusions||[])),ot=U(Z,(t=>t.enforceSSO||!1)),rt=o((t=>class extends(r(g,l)(t)){syncFlowTheme(t){t.theme=this.theme,this.observeAttributes(["theme"],(()=>{t.theme=this.theme}))}})),at=o((e=>{const i=r(p,w({"widget-id":w.missingAttrValidator}))(e);return class extends i{get widgetId(){return this.getAttribute("widget-id")}fetchWidgetPage(e){return t(this,void 0,void 0,(function*(){return(yield this.fetchStaticResource(`tenant-profile-widget/${this.widgetId}/${e}`,"text")).body}))}}}));const dt=o((i=>{var n,o,a;return a=class extends(r(h,m,b,S,at,V)(i)){constructor(){super(...arguments),n.add(this)}onWidgetRootReady(){return t(this,void 0,void 0,(function*(){}))}init(){const i=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.init)||void 0===t?void 0:t.call(this);try{yield Promise.all([this.actions.getMe(),this.actions.getTenant(),this.actions.getTenantAdminLinkSSO()])}catch(t){}const s=this.state.me.error||(t=>t.tenant.error)(this.state)||(t=>t.tenantAdminLinkSSO.error)(this.state);if(s){this.contentRootElement.innerHTML="";const t="object"==typeof s&&null!==s&&"message"in s?s.message:String(s)||"An error occurred";this.contentRootElement.append(function({mainMessage:t="An error occurred"}){const e=document.createElement("div");e.setAttribute("data-id","widget-error"),e.style.display="flex",e.style.flexDirection="column",e.style.alignItems="center",e.style.justifyContent="center",e.style.padding="72px 36px",e.style.background="#fff",e.style.borderRadius="12px",e.style.boxShadow="0 2px 8px rgba(0,0,0,0.03)",e.style.margin="32px auto",e.style.maxWidth="400px";const i=document.createElement("div");i.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 ',i.style.marginBottom="12px",e.appendChild(i);const s=document.createElement("div");return s.textContent=t,s.style.fontWeight="bold",s.style.fontSize="20px",s.style.color="#222",s.style.textAlign="center",s.style.marginTop="8px",e.appendChild(s),e}({mainMessage:t}))}else yield e(this,n,"m",o).call(this),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},n=new WeakSet,o=function(){return t(this,void 0,void 0,(function*(){const t=s(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(t),this.contentRootElement.append(t.content.cloneNode(!0))}))},a})),lt=o((i=>{var s,n,o,d;return d=class extends(r(rt,V,h,dt,u,v)(i)){constructor(){super(...arguments),s.add(this),o.set(this,a((t=>{this.tenantAdminLinkSSODriver.href=t})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,s,"m",n).call(this),e(this,o,"f").call(this,tt(this.state)),this.subscribe(e(this,o,"f").bind(this),tt)}))}},o=new WeakMap,s=new WeakSet,n=function(){this.tenantAdminLinkSSODriver=new C((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-link[data-id="tenant-admin-link-sso"]')}),{logger:this.logger})},d}));var ht;!function(t){t.TEXT="text",t.NUMBER="number",t.BOOLEAN="boolean",t.SINGLE_SELECT="singleSelect",t.ARRAY="array",t.DATE="date"}(ht||(ht={}));const ct=o((i=>{var s,n,o,d,l,c,f,m,g,p,w;return w=class extends(r(rt,V,h,dt,u,v)(i)){constructor(){super(...arguments),s.add(this),n.set(this,{}),o.set(this,{}),d.set(this,{}),l.set(this,{}),m.set(this,a((t=>{var i;const n=null===(i=this.shadowRoot)||void 0===i?void 0:i.querySelectorAll('descope-user-attribute[data-id^="customAttributes."]');Array.from(n).forEach((i=>{const n=i.getAttribute("data-id").replace("customAttributes.",""),o=i.getAttribute("data-type")||ht.TEXT,r=t[n],a=new R(i,{logger:this.logger});a.value=((t,e)=>t===ht.DATE&&e?new Date(e).toLocaleString():t===ht.BOOLEAN&&void 0!==e?e?"True":"False":(e||"").toString())(o,r),e(this,s,"m",g).call(this,i,n,a,o,n,r),e(this,s,"m",p).call(this,i,n,a)}))})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,m,"f").call(this,et(this.state)),this.subscribe(e(this,m,"f").bind(this),et)}))}},n=new WeakMap,o=new WeakMap,d=new WeakMap,l=new WeakMap,m=new WeakMap,s=new WeakSet,c=function(t,i,s,r){var a,d;const l=i===ht.ARRAY?(r||[]).join(","):r;null===(a=e(this,n,"f")[t])||void 0===a||a.setContent(W({projectId:this.projectId,flowId:t,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,form:JSON.stringify({customAttributes:{[s]:l}})})),null===(d=e(this,o,"f")[t])||void 0===d||d.onSuccess((()=>{var i;null===(i=e(this,n,"f")[t])||void 0===i||i.close(),this.actions.getTenant()}))},f=function(t){var i,s;null===(i=e(this,d,"f")[t])||void 0===i||i.setContent(W({projectId:this.projectId,flowId:t,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme})),null===(s=e(this,l,"f")[t])||void 0===s||s.onSuccess((()=>{var i;null===(i=e(this,d,"f")[t])||void 0===i||i.close(),this.actions.getTenant()}))},g=function(t,i,r,a,d,l){const h=t.getAttribute("edit-flow-id");h&&(e(this,n,"f")[h]=this.createModal({"data-id":`edit-${i}`}),e(this,o,"f")[h]=new k((()=>{var t,i;return null===(i=null===(t=e(this,n,"f")[h])||void 0===t?void 0:t.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),e(this,n,"f")[h].afterClose=e(this,s,"m",c).bind(this,h),r.onEditClick((()=>{var t,i;null===(i=null===(t=e(this,n,"f"))||void 0===t?void 0:t[h])||void 0===i||i.open()})),e(this,s,"m",c).call(this,h,a,d,l),this.syncFlowTheme(e(this,o,"f")[h]))},p=function(t,i,n){const o=t.getAttribute("delete-flow-id");o&&(e(this,d,"f")[o]=this.createModal({"data-id":`delete-${i}`}),e(this,l,"f")[o]=new k((()=>{var t,i;return null===(i=null===(t=e(this,d,"f")[o])||void 0===t?void 0:t.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),e(this,d,"f")[o].afterClose=e(this,s,"m",f).bind(this,o),n.onDeleteClick((()=>{var t,i;null===(i=null===(t=e(this,d,"f"))||void 0===t?void 0:t[o])||void 0===i||i.open()})),e(this,s,"m",f).call(this,o),this.syncFlowTheme(e(this,l,"f")[o]))},w})),ut=o((s=>{var n,o,d,l,c,f,m,g,p,w,b,S;return S=class extends(r(rt,V,h,dt,u,v)(s)){constructor(){super(...arguments),n.add(this),o.set(this,void 0),d.set(this,void 0),l.set(this,void 0),c.set(this,void 0),b.set(this,a((t=>{this.tenantEmailDomainsDriver.value=t})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,n,"m",w).call(this),e(this,n,"m",f).call(this),e(this,n,"m",g).call(this),e(this,b,"f").call(this,st(this.state)),this.subscribe(e(this,b,"f").bind(this),st)}))}},o=new WeakMap,d=new WeakMap,l=new WeakMap,c=new WeakMap,b=new WeakMap,n=new WeakSet,f=function(){this.tenantEmailDomainsDriver.editFlowId&&(i(this,o,this.createModal({"data-id":"edit-tenant-email-domains"}),"f"),i(this,d,new k((()=>{var t;return null===(t=e(this,o,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,o,"f").afterClose=e(this,n,"m",m).bind(this),e(this,n,"m",m).call(this),this.syncFlowTheme(e(this,d,"f")))},m=function(){e(this,o,"f").setContent(W({projectId:this.projectId,flowId:this.tenantEmailDomainsDriver.editFlowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,form:JSON.stringify({tenantEmailDomains:st(this.state)})})),e(this,d,"f").onSuccess((()=>{e(this,o,"f").close(),this.actions.getTenant()}))},g=function(){this.tenantEmailDomainsDriver.deleteFlowId&&(i(this,l,this.createModal({"data-id":"delete-tenant-email-domains"}),"f"),i(this,c,new k((()=>{var t;return null===(t=e(this,l,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,l,"f").afterClose=e(this,n,"m",p).bind(this),e(this,n,"m",p).call(this),this.syncFlowTheme(e(this,c,"f")))},p=function(){e(this,l,"f").setContent(W({projectId:this.projectId,flowId:this.tenantEmailDomainsDriver.deleteFlowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme})),e(this,c,"f").onSuccess((()=>{e(this,l,"f").close(),this.actions.getTenant()}))},w=function(){this.tenantEmailDomainsDriver=new R((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-attribute[data-id="tenant-email-domains-edit"]')}),{logger:this.logger}),this.tenantEmailDomainsDriver.onEditClick((()=>{var t;null===(t=e(this,o,"f"))||void 0===t||t.open()})),this.tenantEmailDomainsDriver.onDeleteClick((()=>{var t;null===(t=e(this,l,"f"))||void 0===t||t.open()}))},S})),ft=o((s=>{var n,o,d,l,c,f,m,g,p,w,b,S;return S=class extends(r(rt,V,h,dt,u,v)(s)){constructor(){super(...arguments),n.add(this),o.set(this,void 0),d.set(this,void 0),l.set(this,void 0),c.set(this,void 0),b.set(this,a((t=>{this.tenantSSOExclusionsDriver.value=t})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,n,"m",w).call(this),e(this,n,"m",f).call(this),e(this,n,"m",g).call(this),e(this,b,"f").call(this,nt(this.state)),this.subscribe(e(this,b,"f").bind(this),nt)}))}},o=new WeakMap,d=new WeakMap,l=new WeakMap,c=new WeakMap,b=new WeakMap,n=new WeakSet,f=function(){this.tenantSSOExclusionsDriver.editFlowId&&(i(this,o,this.createModal({"data-id":"edit-tenant-sso-exclusions"}),"f"),i(this,d,new k((()=>{var t;return null===(t=e(this,o,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,o,"f").afterClose=e(this,n,"m",m).bind(this),e(this,n,"m",m).call(this),this.syncFlowTheme(e(this,d,"f")))},m=function(){e(this,o,"f").setContent(W({projectId:this.projectId,flowId:this.tenantSSOExclusionsDriver.editFlowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,form:JSON.stringify({enforceSSOExclusions:nt(this.state)})})),e(this,d,"f").onSuccess((()=>{e(this,o,"f").close(),this.actions.getTenant()}))},g=function(){this.tenantSSOExclusionsDriver.deleteFlowId&&(i(this,l,this.createModal({"data-id":"delete-tenant-sso-exclusions"}),"f"),i(this,c,new k((()=>{var t;return null===(t=e(this,l,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,l,"f").afterClose=e(this,n,"m",p).bind(this),e(this,n,"m",p).call(this),this.syncFlowTheme(e(this,c,"f")))},p=function(){e(this,l,"f").setContent(W({projectId:this.projectId,flowId:this.tenantSSOExclusionsDriver.deleteFlowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme})),e(this,c,"f").onSuccess((()=>{e(this,l,"f").close(),this.actions.getTenant()}))},w=function(){this.tenantSSOExclusionsDriver=new R((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-attribute[data-id="tenant-force-sso-exclusions-edit"]')}),{logger:this.logger}),this.tenantSSOExclusionsDriver.onEditClick((()=>{var t;null===(t=e(this,o,"f"))||void 0===t||t.open()})),this.tenantSSOExclusionsDriver.onDeleteClick((()=>{var t;null===(t=e(this,l,"f"))||void 0===t||t.open()}))},S})),mt=o((s=>{var n,o,d,l,c,f,m,g,p,w,b,S;return S=class extends(r(rt,V,h,dt,u,v)(s)){constructor(){super(...arguments),n.add(this),o.set(this,void 0),d.set(this,void 0),l.set(this,void 0),c.set(this,void 0),b.set(this,a((t=>{this.tenantEnforceSSODriver.value=t})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,n,"m",w).call(this),e(this,n,"m",f).call(this),e(this,n,"m",g).call(this),e(this,b,"f").call(this,ot(this.state)),this.subscribe(e(this,b,"f").bind(this),ot)}))}},o=new WeakMap,d=new WeakMap,l=new WeakMap,c=new WeakMap,b=new WeakMap,n=new WeakSet,f=function(){this.tenantEnforceSSODriver.editFlowId&&(i(this,o,this.createModal({"data-id":"edit-tenant-enforce-sso"}),"f"),i(this,d,new k((()=>{var t;return null===(t=e(this,o,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,o,"f").afterClose=e(this,n,"m",m).bind(this),e(this,n,"m",m).call(this),this.syncFlowTheme(e(this,d,"f")))},m=function(){e(this,o,"f").setContent(W({projectId:this.projectId,flowId:this.tenantEnforceSSODriver.editFlowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,form:JSON.stringify({enforceSSO:ot(this.state)})})),e(this,d,"f").onSuccess((()=>{e(this,o,"f").close(),this.actions.getTenant()}))},g=function(){this.tenantEnforceSSODriver.deleteFlowId&&(i(this,l,this.createModal({"data-id":"delete-tenant-enforce-sso"}),"f"),i(this,c,new k((()=>{var t;return null===(t=e(this,l,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,l,"f").afterClose=e(this,n,"m",p).bind(this),e(this,n,"m",p).call(this),this.syncFlowTheme(e(this,c,"f")))},p=function(){e(this,l,"f").setContent(W({projectId:this.projectId,flowId:this.tenantEnforceSSODriver.deleteFlowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme})),e(this,c,"f").onSuccess((()=>{e(this,l,"f").close(),this.actions.getTenant()}))},w=function(){this.tenantEnforceSSODriver=new R((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-attribute[data-id="tenant-enforce-sso-edit"]')}),{logger:this.logger}),this.tenantEnforceSSODriver.onEditClick((()=>{var t;null===(t=e(this,o,"f"))||void 0===t||t.open()})),this.tenantEnforceSSODriver.onDeleteClick((()=>{var t;null===(t=e(this,l,"f"))||void 0===t||t.open()}))},S})),vt=o((s=>{var n,o,d,l,c,f,m,g;return g=class extends(r(rt,V,h,dt,u,v)(s)){constructor(){super(...arguments),n.add(this),o.set(this,void 0),d.set(this,void 0),m.set(this,a((t=>{this.tenantNameDriver.value=t})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,n,"m",f).call(this),e(this,n,"m",l).call(this),e(this,m,"f").call(this,it(this.state)),this.subscribe(e(this,m,"f").bind(this),it)}))}},o=new WeakMap,d=new WeakMap,m=new WeakMap,n=new WeakSet,l=function(){this.tenantNameDriver.editFlowId&&(i(this,o,this.createModal({"data-id":"tenant-profile-set-name"}),"f"),i(this,d,new k((()=>{var t;return null===(t=e(this,o,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,o,"f").afterClose=e(this,n,"m",c).bind(this),e(this,n,"m",c).call(this),this.syncFlowTheme(e(this,d,"f")))},c=function(){e(this,o,"f").setContent(W({projectId:this.projectId,flowId:this.tenantNameDriver.editFlowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,form:JSON.stringify({tenantName:it(this.state)})})),e(this,d,"f").onSuccess((()=>{e(this,o,"f").close(),this.actions.getTenant()}))},f=function(){this.tenantNameDriver=new R((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-attribute[data-id="tenant-name-edit"]')}),{logger:this.logger}),this.tenantNameDriver.onEditClick((()=>{var t;null===(t=e(this,o,"f"))||void 0===t||t.open()}))},g})),gt=o((e=>class extends(r(y,g,Q,dt,vt,ut,ft,mt,ct,lt)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),pt=r((e=>class extends(gt(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return t(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 import("@descope/web-component").then((t=>t.default)))).sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"tenant-profile-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.2.23"}}}))}}))(HTMLElement);customElements.define("descope-tenant-profile-widget",pt);export{pt as default};
5
+ import{__awaiter as t,__classPrivateFieldGet as e,__classPrivateFieldSet as i}from"tslib";import{createTemplate as s,kebabCase as n,createSingletonMixin as o,compose as r,withMemCache as a}from"@descope/sdk-helpers";import{projectIdMixin as d,observeAttributesMixin as l,loggerMixin as h,baseUrlMixin as c,cookieConfigMixin as u,createStateManagementMixin as f,initLifecycleMixin as m,modalMixin as v,themeMixin as g,staticResourcesMixin as p,createValidateAttributesMixin as w,descopeUiMixin as b,initElementMixin as S,debuggerMixin as y}from"@descope/sdk-mixins";import{FlowDriver as k,LinkDriver as C,UserAttributeDriver as R,UserAuthMethodDriver as I}from"@descope/sdk-component-drivers";import{createAsyncThunk as U}from"@reduxjs/toolkit";import"@descope/core-js-sdk";import x from"@descope/web-js-sdk";import{createSelector as W}from"reselect";import"@descope/web-component";const E=(t={})=>{const e=s("<descope-wc></descope-wc>");return Object.entries(t).forEach((([t,i])=>{e.content.querySelector("descope-wc").setAttribute(n(t),i)})),e};function O(t){return new URLSearchParams(window.location.search).get(t)}const D=t=>(...e)=>i=>{i.addCase(t.pending,((t,i)=>{e.forEach((({onPending:e})=>{null==e||e(t,i)}))})),i.addCase(t.fulfilled,((t,i)=>{e.forEach((({onFulfilled:e})=>{null==e||e(t,i)}))})),i.addCase(t.rejected,((t,i)=>{e.forEach((({onRejected:e})=>{null==e||e(t,i)}))}))},T=t=>({onFulfilled:e=>{t(e).loading=!1},onPending:e=>{t(e).loading=!0,t(e).error=null},onRejected:(e,i)=>{t(e).loading=!1,t(e).error=i.error}}),j=U("users/me",((t,{extra:{api:e}})=>e.user.me())),M=D(j)({onFulfilled:(t,e)=>{t.me.data=e.payload}},T((t=>t.me))),A={action:j,reducer:M},N=U("tenant/details",((t,{extra:{api:e}})=>e.tenant.details())),F=D(N)({onFulfilled:(t,e)=>{t.tenant.data=e.payload}},T((t=>t.tenant))),L={action:N,reducer:F},P=U("tenant/adminLinkSso",((t,{extra:{api:e}})=>e.tenant.adminLinkSso())),q={action:P,reducer:D(P)({onFulfilled:(t,e)=>{var i;t.tenantAdminLinkSSO.data=(null===(i=e.payload)||void 0===i?void 0:i.adminSSOConfigurationLink)||""}},T((t=>t.tenantAdminLinkSSO)))},$={me:{loading:!1,error:null,data:{}},tenant:{loading:!1,error:null,data:{}},tenantAdminLinkSSO:{loading:!1,error:null,data:""}},B={me:"/v1/auth/me"},J={details:"/v1/mgmt/tenant",adminLinkSso:"/v1/mgmt/tenant/adminlinks/sso/authenticated"},H=e=>t(void 0,void 0,void 0,(function*(){const t=yield e.text(),i=JSON.parse(t);if(!e.ok){const t=`${i.errorDescription}${i.errorMessage?`: ${i.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(i),e.text=()=>Promise.resolve(t)})),z=()=>t(void 0,void 0,void 0,(function*(){return new Promise((t=>{t({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})}))})),X=()=>t(void 0,void 0,void 0,(function*(){return new Promise((t=>{t({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})}))})),Y=()=>t(void 0,void 0,void 0,(function*(){return new Promise((t=>{t({adminSSOConfigurationLink:"_blank"})}))})),_=({httpClient:e,tenantId:i,mock:s})=>{const n=encodeURIComponent(i||""),o=`?tenant=${n}&id=${n}`;return{details:()=>t(void 0,void 0,void 0,(function*(){if(s)return X();if(!i)throw new Error("tenantId is not defined");const t=`${J.details}${o}`,n=yield e.get(t);yield H(n);return yield n.json()})),adminLinkSso:()=>t(void 0,void 0,void 0,(function*(){if(s)return Y();if(!i)throw new Error("tenantId is not defined");const t=yield e.post(`${J.adminLinkSso}?tenant=${n}`,{tenantId:n},{headers:{"Content-Type":"application/json"}});yield H(t);return yield t.json()}))}},G=({httpClient:e,mock:i})=>({me:()=>t(void 0,void 0,void 0,(function*(){if(i)return z();const t=yield e.get(B.me);return yield H(t),t.json()}))}),V=o((s=>{var n,o,a,f;const m=r(d,l,h,c,u)(s);return f=class extends m{constructor(){super(...arguments),n.add(this),o.set(this,void 0)}get widgetId(){return this.getAttribute("widget-id")}get tenantId(){return this.getAttribute("tenant")}get mock(){return this.getAttribute("mock")}get api(){return e(this,o,"f")||e(this,n,"m",a).call(this),e(this,o,"f")}init(){const i=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.init)||void 0===t?void 0:t.call(this),this.observeAttributes(["project-id","base-url","tenant","mock"],(()=>{e(this,o,"f")&&e(this,n,"m",a).call(this)}))}))}},o=new WeakMap,n=new WeakSet,a=function(){this.logger.debug("creating an sdk instance"),i(this,o,((t,e,i,s)=>{const n=x(Object.assign(Object.assign({},t),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"tenant-profile-widget","x-descope-widget-id":s,"x-descope-widget-version":"0.3.0"}}));return{user:G({httpClient:n.httpClient,mock:i}),tenant:_({httpClient:n.httpClient,tenantId:e,mock:i})}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},this.tenantId,"true"===this.mock,this.widgetId),"f")},f})),K=o((t=>{const e=r(f({name:"widget",initialState:$,reducers:{},extraReducers:t=>{A.reducer(t),L.reducer(t),q.reducer(t)},asyncActions:{getMe:A.action,getTenant:L.action,getTenantAdminLinkSSO:q.action}}),m,h,V)(t);return class extends e{constructor(...t){super(...t),this.state=$,this.subscribe((t=>{this.logger.debug("State update:",t),this.state=t}))}}})),Q="widget-flow",Z=o((i=>{var s,n,o;return o=class extends(r(m,v,K,u,h,g)(i)){constructor(){super(...arguments),s.add(this)}init(){const i=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.init)||void 0===t?void 0:t.call(this);const o=O(Q);o&&(!function(t){if(window.history.replaceState&&O(t)){const e=new URL(window.location.href),i=new URLSearchParams(e.search);i.delete(t),e.search=i.toString(),window.history.replaceState({},"",e.toString())}}(Q),e(this,s,"m",n).call(this,o))}))}},s=new WeakSet,n=function(t){const e=this.createModal({"data-id":"redirect-flow"});e.setContent(E({projectId:this.projectId,flowId:t,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme}));new k((()=>{var t;return null===(t=e.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}).onSuccess((()=>{e.close(),this.actions.getMe(),this.actions.getTenant(),this.actions.getTenantAdminLinkSSO()})),e.afterClose=()=>{e.remove()},e.open()},o})),tt=t=>t.tenant.data,et=t=>t.tenantAdminLinkSSO.data,it=W(tt,(t=>t.customAttributes||{})),st=W(tt,(t=>t.name||"")),nt=W(tt,(t=>t.selfProvisioningDomains||[])),ot=W(tt,(t=>t.enforceSSOExclusions||[])),rt=W(tt,(t=>t.enforceSSO||!1)),at=o((t=>class extends(r(g,l)(t)){syncFlowTheme(t){t.theme=this.theme,this.observeAttributes(["theme"],(()=>{t.theme=this.theme}))}})),dt=o((e=>{const i=r(p,w({"widget-id":w.missingAttrValidator}))(e);return class extends i{get widgetId(){return this.getAttribute("widget-id")}fetchWidgetPage(e){return t(this,void 0,void 0,(function*(){return(yield this.fetchStaticResource(`tenant-profile-widget/${this.widgetId}/${e}`,"text")).body}))}}}));const lt=o((i=>{var n,o,a;return a=class extends(r(h,m,b,S,dt,K)(i)){constructor(){super(...arguments),n.add(this)}onWidgetRootReady(){return t(this,void 0,void 0,(function*(){}))}init(){const i=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.init)||void 0===t?void 0:t.call(this);try{yield Promise.all([this.actions.getMe(),this.actions.getTenant(),this.actions.getTenantAdminLinkSSO()])}catch(t){}const s=this.state.me.error||(t=>t.tenant.error)(this.state)||(t=>t.tenantAdminLinkSSO.error)(this.state);if(s){this.contentRootElement.innerHTML="";const t="object"==typeof s&&null!==s&&"message"in s?s.message:String(s)||"An error occurred";this.contentRootElement.append(function({mainMessage:t="An error occurred"}){const e=document.createElement("div");e.setAttribute("data-id","widget-error"),e.style.display="flex",e.style.flexDirection="column",e.style.alignItems="center",e.style.justifyContent="center",e.style.padding="72px 36px",e.style.background="#fff",e.style.borderRadius="12px",e.style.boxShadow="0 2px 8px rgba(0,0,0,0.03)",e.style.margin="32px auto",e.style.maxWidth="400px";const i=document.createElement("div");i.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 ',i.style.marginBottom="12px",e.appendChild(i);const s=document.createElement("div");return s.textContent=t,s.style.fontWeight="bold",s.style.fontSize="20px",s.style.color="#222",s.style.textAlign="center",s.style.marginTop="8px",e.appendChild(s),e}({mainMessage:t}))}else yield e(this,n,"m",o).call(this),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},n=new WeakSet,o=function(){return t(this,void 0,void 0,(function*(){const t=s(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(t),this.contentRootElement.append(t.content.cloneNode(!0))}))},a})),ht=o((i=>{var s,n,o,d;return d=class extends(r(at,K,h,lt,u,v)(i)){constructor(){super(...arguments),s.add(this),o.set(this,a((t=>{this.tenantAdminLinkSSODriver.href=t})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,s,"m",n).call(this),e(this,o,"f").call(this,et(this.state)),this.subscribe(e(this,o,"f").bind(this),et)}))}},o=new WeakMap,s=new WeakSet,n=function(){this.tenantAdminLinkSSODriver=new C((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-link[data-id="tenant-admin-link-sso"]')}),{logger:this.logger})},d}));var ct;!function(t){t.TEXT="text",t.NUMBER="number",t.BOOLEAN="boolean",t.SINGLE_SELECT="singleSelect",t.ARRAY="array",t.DATE="date"}(ct||(ct={}));const ut=o((i=>{var s,n,o,d,l,c,f,m,g,p,w;return w=class extends(r(at,K,h,lt,u,v)(i)){constructor(){super(...arguments),s.add(this),n.set(this,{}),o.set(this,{}),d.set(this,{}),l.set(this,{}),m.set(this,a((t=>{var i;const n=null===(i=this.shadowRoot)||void 0===i?void 0:i.querySelectorAll('descope-user-attribute[data-id^="customAttributes."]');Array.from(n).forEach((i=>{const n=i.getAttribute("data-id").replace("customAttributes.",""),o=i.getAttribute("data-type")||ct.TEXT,r=t[n],a=new R(i,{logger:this.logger});a.value=((t,e)=>t===ct.DATE&&e?new Date(e).toLocaleString():t===ct.BOOLEAN&&void 0!==e?e?"True":"False":(e||"").toString())(o,r),e(this,s,"m",g).call(this,i,n,a,o,n,r),e(this,s,"m",p).call(this,i,n,a)}))})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,m,"f").call(this,it(this.state)),this.subscribe(e(this,m,"f").bind(this),it)}))}},n=new WeakMap,o=new WeakMap,d=new WeakMap,l=new WeakMap,m=new WeakMap,s=new WeakSet,c=function(t,i,s,r){var a,d;const l=i===ct.ARRAY?(r||[]).join(","):r;null===(a=e(this,n,"f")[t])||void 0===a||a.setContent(E({projectId:this.projectId,flowId:t,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,form:JSON.stringify({customAttributes:{[s]:l}})})),null===(d=e(this,o,"f")[t])||void 0===d||d.onSuccess((()=>{var i;null===(i=e(this,n,"f")[t])||void 0===i||i.close(),this.actions.getTenant()}))},f=function(t){var i,s;null===(i=e(this,d,"f")[t])||void 0===i||i.setContent(E({projectId:this.projectId,flowId:t,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme})),null===(s=e(this,l,"f")[t])||void 0===s||s.onSuccess((()=>{var i;null===(i=e(this,d,"f")[t])||void 0===i||i.close(),this.actions.getTenant()}))},g=function(t,i,r,a,d,l){const h=t.getAttribute("edit-flow-id");h&&(e(this,n,"f")[h]=this.createModal({"data-id":`edit-${i}`}),e(this,o,"f")[h]=new k((()=>{var t,i;return null===(i=null===(t=e(this,n,"f")[h])||void 0===t?void 0:t.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),e(this,n,"f")[h].afterClose=e(this,s,"m",c).bind(this,h),r.onEditClick((()=>{var t,i;null===(i=null===(t=e(this,n,"f"))||void 0===t?void 0:t[h])||void 0===i||i.open()})),e(this,s,"m",c).call(this,h,a,d,l),this.syncFlowTheme(e(this,o,"f")[h]))},p=function(t,i,n){const o=t.getAttribute("delete-flow-id");o&&(e(this,d,"f")[o]=this.createModal({"data-id":`delete-${i}`}),e(this,l,"f")[o]=new k((()=>{var t,i;return null===(i=null===(t=e(this,d,"f")[o])||void 0===t?void 0:t.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),e(this,d,"f")[o].afterClose=e(this,s,"m",f).bind(this,o),n.onDeleteClick((()=>{var t,i;null===(i=null===(t=e(this,d,"f"))||void 0===t?void 0:t[o])||void 0===i||i.open()})),e(this,s,"m",f).call(this,o),this.syncFlowTheme(e(this,l,"f")[o]))},w})),ft=o((s=>{var n,o,d,l,c,f,m,g,p,w,b,S;return S=class extends(r(at,K,h,lt,u,v)(s)){constructor(){super(...arguments),n.add(this),o.set(this,void 0),d.set(this,void 0),l.set(this,void 0),c.set(this,void 0),b.set(this,a((t=>{this.tenantEmailDomainsDriver.value=t})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,n,"m",w).call(this),e(this,n,"m",f).call(this),e(this,n,"m",g).call(this),e(this,b,"f").call(this,nt(this.state)),this.subscribe(e(this,b,"f").bind(this),nt)}))}},o=new WeakMap,d=new WeakMap,l=new WeakMap,c=new WeakMap,b=new WeakMap,n=new WeakSet,f=function(){this.tenantEmailDomainsDriver.editFlowId&&(i(this,o,this.createModal({"data-id":"edit-tenant-email-domains"}),"f"),i(this,d,new k((()=>{var t;return null===(t=e(this,o,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,o,"f").afterClose=e(this,n,"m",m).bind(this),e(this,n,"m",m).call(this),this.syncFlowTheme(e(this,d,"f")))},m=function(){e(this,o,"f").setContent(E({projectId:this.projectId,flowId:this.tenantEmailDomainsDriver.editFlowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,form:JSON.stringify({tenantEmailDomains:nt(this.state)})})),e(this,d,"f").onSuccess((()=>{e(this,o,"f").close(),this.actions.getTenant()}))},g=function(){this.tenantEmailDomainsDriver.deleteFlowId&&(i(this,l,this.createModal({"data-id":"delete-tenant-email-domains"}),"f"),i(this,c,new k((()=>{var t;return null===(t=e(this,l,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,l,"f").afterClose=e(this,n,"m",p).bind(this),e(this,n,"m",p).call(this),this.syncFlowTheme(e(this,c,"f")))},p=function(){e(this,l,"f").setContent(E({projectId:this.projectId,flowId:this.tenantEmailDomainsDriver.deleteFlowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme})),e(this,c,"f").onSuccess((()=>{e(this,l,"f").close(),this.actions.getTenant()}))},w=function(){this.tenantEmailDomainsDriver=new R((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-attribute[data-id="tenant-email-domains-edit"]')}),{logger:this.logger}),this.tenantEmailDomainsDriver.onEditClick((()=>{var t;null===(t=e(this,o,"f"))||void 0===t||t.open()})),this.tenantEmailDomainsDriver.onDeleteClick((()=>{var t;null===(t=e(this,l,"f"))||void 0===t||t.open()}))},S})),mt=o((s=>{var n,o,d,l,c,f,m,g,p,w,b,S;return S=class extends(r(at,K,h,lt,u,v)(s)){constructor(){super(...arguments),n.add(this),o.set(this,void 0),d.set(this,void 0),l.set(this,void 0),c.set(this,void 0),b.set(this,a((t=>{this.tenantSSOExclusionsDriver.value=t})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,n,"m",w).call(this),e(this,n,"m",f).call(this),e(this,n,"m",g).call(this),e(this,b,"f").call(this,ot(this.state)),this.subscribe(e(this,b,"f").bind(this),ot)}))}},o=new WeakMap,d=new WeakMap,l=new WeakMap,c=new WeakMap,b=new WeakMap,n=new WeakSet,f=function(){this.tenantSSOExclusionsDriver.editFlowId&&(i(this,o,this.createModal({"data-id":"edit-tenant-sso-exclusions"}),"f"),i(this,d,new k((()=>{var t;return null===(t=e(this,o,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,o,"f").afterClose=e(this,n,"m",m).bind(this),e(this,n,"m",m).call(this),this.syncFlowTheme(e(this,d,"f")))},m=function(){e(this,o,"f").setContent(E({projectId:this.projectId,flowId:this.tenantSSOExclusionsDriver.editFlowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,form:JSON.stringify({enforceSSOExclusions:ot(this.state)})})),e(this,d,"f").onSuccess((()=>{e(this,o,"f").close(),this.actions.getTenant()}))},g=function(){this.tenantSSOExclusionsDriver.deleteFlowId&&(i(this,l,this.createModal({"data-id":"delete-tenant-sso-exclusions"}),"f"),i(this,c,new k((()=>{var t;return null===(t=e(this,l,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,l,"f").afterClose=e(this,n,"m",p).bind(this),e(this,n,"m",p).call(this),this.syncFlowTheme(e(this,c,"f")))},p=function(){e(this,l,"f").setContent(E({projectId:this.projectId,flowId:this.tenantSSOExclusionsDriver.deleteFlowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme})),e(this,c,"f").onSuccess((()=>{e(this,l,"f").close(),this.actions.getTenant()}))},w=function(){this.tenantSSOExclusionsDriver=new R((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-attribute[data-id="tenant-force-sso-exclusions-edit"]')}),{logger:this.logger}),this.tenantSSOExclusionsDriver.onEditClick((()=>{var t;null===(t=e(this,o,"f"))||void 0===t||t.open()})),this.tenantSSOExclusionsDriver.onDeleteClick((()=>{var t;null===(t=e(this,l,"f"))||void 0===t||t.open()}))},S})),vt=o((s=>{var n,o,d,l,c,f,m,g,p,w,b,S;return S=class extends(r(at,K,h,lt,u,v)(s)){constructor(){super(...arguments),n.add(this),o.set(this,void 0),d.set(this,void 0),l.set(this,void 0),c.set(this,void 0),b.set(this,a((t=>{this.tenantEnforceSSODriver.value=t})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,n,"m",w).call(this),e(this,n,"m",f).call(this),e(this,n,"m",g).call(this),e(this,b,"f").call(this,rt(this.state)),this.subscribe(e(this,b,"f").bind(this),rt)}))}},o=new WeakMap,d=new WeakMap,l=new WeakMap,c=new WeakMap,b=new WeakMap,n=new WeakSet,f=function(){this.tenantEnforceSSODriver.editFlowId&&(i(this,o,this.createModal({"data-id":"edit-tenant-enforce-sso"}),"f"),i(this,d,new k((()=>{var t;return null===(t=e(this,o,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,o,"f").afterClose=e(this,n,"m",m).bind(this),e(this,n,"m",m).call(this),this.syncFlowTheme(e(this,d,"f")))},m=function(){e(this,o,"f").setContent(E({projectId:this.projectId,flowId:this.tenantEnforceSSODriver.editFlowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,form:JSON.stringify({enforceSSO:rt(this.state)})})),e(this,d,"f").onSuccess((()=>{e(this,o,"f").close(),this.actions.getTenant()}))},g=function(){this.tenantEnforceSSODriver.deleteFlowId&&(i(this,l,this.createModal({"data-id":"delete-tenant-enforce-sso"}),"f"),i(this,c,new k((()=>{var t;return null===(t=e(this,l,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,l,"f").afterClose=e(this,n,"m",p).bind(this),e(this,n,"m",p).call(this),this.syncFlowTheme(e(this,c,"f")))},p=function(){e(this,l,"f").setContent(E({projectId:this.projectId,flowId:this.tenantEnforceSSODriver.deleteFlowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme})),e(this,c,"f").onSuccess((()=>{e(this,l,"f").close(),this.actions.getTenant()}))},w=function(){this.tenantEnforceSSODriver=new R((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-attribute[data-id="tenant-enforce-sso-edit"]')}),{logger:this.logger}),this.tenantEnforceSSODriver.onEditClick((()=>{var t;null===(t=e(this,o,"f"))||void 0===t||t.open()})),this.tenantEnforceSSODriver.onDeleteClick((()=>{var t;null===(t=e(this,l,"f"))||void 0===t||t.open()}))},S})),gt=o((s=>{var n,o,d,l,c,f,m,g;return g=class extends(r(at,K,h,lt,u,v)(s)){constructor(){super(...arguments),n.add(this),o.set(this,void 0),d.set(this,void 0),m.set(this,a((t=>{this.tenantNameDriver.value=t})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,n,"m",f).call(this),e(this,n,"m",l).call(this),e(this,m,"f").call(this,st(this.state)),this.subscribe(e(this,m,"f").bind(this),st)}))}},o=new WeakMap,d=new WeakMap,m=new WeakMap,n=new WeakSet,l=function(){this.tenantNameDriver.editFlowId&&(i(this,o,this.createModal({"data-id":"tenant-profile-set-name"}),"f"),i(this,d,new k((()=>{var t;return null===(t=e(this,o,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,o,"f").afterClose=e(this,n,"m",c).bind(this),e(this,n,"m",c).call(this),this.syncFlowTheme(e(this,d,"f")))},c=function(){e(this,o,"f").setContent(E({projectId:this.projectId,flowId:this.tenantNameDriver.editFlowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,form:JSON.stringify({tenantName:st(this.state)})})),e(this,d,"f").onSuccess((()=>{e(this,o,"f").close(),this.actions.getTenant()}))},f=function(){this.tenantNameDriver=new R((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-attribute[data-id="tenant-name-edit"]')}),{logger:this.logger}),this.tenantNameDriver.onEditClick((()=>{var t;null===(t=e(this,o,"f"))||void 0===t||t.open()}))},g})),pt=o((s=>{var n,o,a,d,l,c,f;return f=class extends(r(at,K,h,lt,u,v)(s)){constructor(){super(...arguments),n.add(this),o.set(this,void 0),a.set(this,void 0)}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,n,"m",c).call(this),e(this,n,"m",d).call(this)}))}},o=new WeakMap,a=new WeakMap,n=new WeakSet,d=function(){this.TenantPasswordPolicyUserAuthMethodDriver.flowId&&(i(this,o,this.createModal({"data-id":"password-policy"}),"f"),i(this,a,new k((()=>{var t;return null===(t=e(this,o,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,o,"f").afterClose=e(this,n,"m",l).bind(this),e(this,n,"m",l).call(this),this.syncFlowTheme(e(this,a,"f")))},l=function(){e(this,o,"f").setContent(E({projectId:this.projectId,flowId:this.TenantPasswordPolicyUserAuthMethodDriver.flowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme})),e(this,a,"f").onSuccess((()=>{e(this,o,"f").close(),this.actions.getTenant()}))},c=function(){this.TenantPasswordPolicyUserAuthMethodDriver=new I((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-auth-method[data-id="password-policy"]')}),{logger:this.logger}),this.TenantPasswordPolicyUserAuthMethodDriver.onUnfulfilledButtonClick((()=>{var t;null===(t=e(this,o,"f"))||void 0===t||t.open()}))},f})),wt=o((e=>class extends(r(y,g,Z,lt,gt,ft,mt,vt,ut,ht,pt)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),bt=r((e=>class extends(wt(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return t(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 import("@descope/web-component").then((t=>t.default)))).sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"tenant-profile-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.3.0"}}}))}}))(HTMLElement);customElements.define("descope-tenant-profile-widget",bt);export{bt as default};
6
6
  //# sourceMappingURL=index.js.map