@descope/user-profile-widget
Advanced tools
Comparing version
/** | ||
* @descope/user-profile-widget v0.4.0 | ||
* @descope/user-profile-widget v0.4.1 | ||
*/ | ||
"use strict";var e=require("tslib"),t=require("@descope/sdk-helpers"),i=require("@descope/sdk-mixins"),s=require("@descope/sdk-component-drivers"),a=require("@reduxjs/toolkit");require("@descope/core-js-sdk");var r=require("@descope/web-js-sdk"),l=require("reselect");require("@descope/web-component");const o=(e={})=>{const i=t.createTemplate("<descope-wc></descope-wc>");return Object.entries(e).forEach((([e,s])=>{i.content.querySelector("descope-wc").setAttribute(t.kebabCase(e),s)})),i};function d(e){return new URLSearchParams(window.location.search).get(e)}const n=e=>(...t)=>i=>{i.addCase(e.pending,((e,i)=>{t.forEach((({onPending:t})=>{null==t||t(e,i)}))})),i.addCase(e.fulfilled,((e,i)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,i)}))})),i.addCase(e.rejected,((e,i)=>{t.forEach((({onRejected:t})=>{null==t||t(e,i)}))}))},c=a.createAsyncThunk("users/me",((e,{extra:{api:t}})=>t.user.me())),h=n(c)({onFulfilled:(e,t)=>{e.me.data=t.payload}},(v=e=>e.me,{onFulfilled:e=>{v(e).loading=!1},onPending:e=>{v(e).loading=!0,v(e).error=null},onRejected:(e,t)=>{v(e).loading=!1,v(e).error=t.error}}));var v;const u={action:c,reducer:h},_=a.createAsyncThunk("users/logout",((e,{extra:{api:t}})=>t.user.logout())),f={action:_,reducer:n(_)({})},g={me:{loading:!1,error:null,data:{}}},p={me:"/v1/auth/me"},w=()=>e.__awaiter(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})}))})),m=({httpClient:t,mock:i})=>({me:()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(i)return w();const s=yield t.get(p.me);return yield(t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=yield t.text(),i=JSON.parse(e);if(!t.ok){const e=`${i.errorDescription}${i.errorMessage?`: ${i.errorMessage}`:""}`;throw Error(e||`${t.status} ${t.statusText}`)}t.json=()=>Promise.resolve(i),t.text=()=>Promise.resolve(e)})))(s),s.json()}))}),F=t.createSingletonMixin((s=>{var a,l,o,d;const n=t.compose(i.projectIdMixin,i.observeAttributesMixin,i.loggerMixin,i.baseUrlMixin,i.cookieConfigMixin)(s);return d=class extends n{constructor(){super(...arguments),a.add(this),l.set(this,void 0)}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get api(){return e.__classPrivateFieldGet(this,l,"f")||e.__classPrivateFieldGet(this,a,"m",o).call(this),e.__classPrivateFieldGet(this,l,"f")}init(){const t=Object.create(null,{init:{get:()=>super.init}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.init)||void 0===i?void 0:i.call(this),this.observeAttributes(["project-id","base-url"],(()=>{e.__classPrivateFieldGet(this,l,"f")&&e.__classPrivateFieldGet(this,a,"m",o).call(this)}))}))}},l=new WeakMap,a=new WeakSet,o=function(){this.logger.debug("creating an sdk instance"),e.__classPrivateFieldSet(this,l,((t,i,s)=>{const a=r(Object.assign(Object.assign({},t),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"user-profile-widget","x-descope-widget-id":s,"x-descope-widget-version":"0.4.0"}}));return{user:Object.assign(Object.assign({},m({httpClient:a.httpClient,mock:i})),{logout:i?()=>e.__awaiter(void 0,void 0,void 0,(function*(){})):a.logout})}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},"true"===this.mock,this.widgetId),"f")},d})),b=t.createSingletonMixin((e=>{const s=t.compose(i.createStateManagementMixin({name:"widget",initialState:g,reducers:{},extraReducers:e=>{u.reducer(e),f.reducer(e)},asyncActions:{getMe:u.action,logout:f.action}}),i.initLifecycleMixin,i.loggerMixin,F)(e);return class extends s{constructor(...e){super(...e),this.state=g,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),P="widget-flow",M=t.createSingletonMixin((a=>{var r,l,n;return n=class extends(t.compose(i.initLifecycleMixin,i.modalMixin,b,i.cookieConfigMixin,i.loggerMixin)(a)){constructor(){super(...arguments),r.add(this)}init(){const t=Object.create(null,{init:{get:()=>super.init}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.init)||void 0===i?void 0:i.call(this);const s=d(P);s&&(!function(e){if(window.history.replaceState&&d(e)){const t=new URL(window.location.href),i=new URLSearchParams(t.search);i.delete(e),t.search=i.toString(),window.history.replaceState({},"",t.toString())}}(P),e.__classPrivateFieldGet(this,r,"m",l).call(this,s))}))}},r=new WeakSet,l=function(e){const t=this.createModal({"data-id":"redirect-flow"});t.setContent(o({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName}));new s.FlowDriver((()=>{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()},n})),G=e=>e.me.data,S=l.createSelector(G,(e=>e.picture)),U=l.createSelector(G,(e=>e.email)),y=l.createSelector(G,(e=>e.verifiedEmail)),k=l.createSelector(G,(e=>e.name)),C=l.createSelector(G,(e=>e.phone)),x=l.createSelector(G,(e=>e.verifiedPhone)),R=l.createSelector(G,(e=>e.webauthn));l.createSelector(G,(e=>e.password));const W=l.createSelector(G,(e=>e.TOTP)),A=l.createSelector(G,(e=>e.customAttributes)),I=t.createSingletonMixin((s=>{const a=t.compose(i.staticResourcesMixin,i.createValidateAttributesMixin({"widget-id":i.createValidateAttributesMixin.missingAttrValidator}))(s);return class extends a{get widgetId(){return this.getAttribute("widget-id")}fetchWidgetPage(t){return e.__awaiter(this,void 0,void 0,(function*(){return(yield this.fetchStaticResource(`user-profile-widget/${this.widgetId}/${t}`,"text")).body}))}}})),j=t.createSingletonMixin((s=>{var a,r,l;return l=class extends(t.compose(i.loggerMixin,i.initLifecycleMixin,i.descopeUiMixin,i.initElementMixin,I,b)(s)){constructor(){super(...arguments),a.add(this)}onWidgetRootReady(){return e.__awaiter(this,void 0,void 0,(function*(){}))}init(){const t=Object.create(null,{init:{get:()=>super.init}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.init)||void 0===i?void 0:i.call(this),yield Promise.all([this.actions.getMe(),e.__classPrivateFieldGet(this,a,"m",r).call(this)]),this.onWidgetRootReady()}))}},a=new WeakSet,r=function(){return e.__awaiter(this,void 0,void 0,(function*(){const e=t.createTemplate(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},l})),N=t.createSingletonMixin((e=>class extends(t.compose(i.themeMixin,i.observeAttributesMixin)(e)){syncFlowTheme(e){e.theme=this.theme,this.observeAttributes(["theme"],(()=>{e.theme=this.theme}))}})),T=t.createSingletonMixin((a=>{var r,l,d,n,c,h,v,u,_;return _=class extends(t.compose(N,i.themeMixin,b,i.loggerMixin,i.cookieConfigMixin,j,i.modalMixin)(a)){constructor(){super(...arguments),r.add(this),l.set(this,void 0),d.set(this,void 0),v.set(this,t.withMemCache((e=>{this.avatar.image=e}))),u.set(this,t.withMemCache((e=>{this.avatar.displayName=e})))}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldGet(this,r,"m",h).call(this),e.__classPrivateFieldGet(this,r,"m",n).call(this),e.__classPrivateFieldGet(this,v,"f").call(this,S(this.state)),e.__classPrivateFieldGet(this,u,"f").call(this,k(this.state)),this.subscribe(e.__classPrivateFieldGet(this,v,"f").bind(this),S),this.subscribe(e.__classPrivateFieldGet(this,u,"f").bind(this),k)}))}},l=new WeakMap,d=new WeakMap,v=new WeakMap,u=new WeakMap,r=new WeakSet,n=function(){this.avatar.flowId&&(e.__classPrivateFieldSet(this,l,this.createModal({"data-id":"update-pic"}),"f"),e.__classPrivateFieldSet(this,d,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,l,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,l,"f").afterClose=e.__classPrivateFieldGet(this,r,"m",c).bind(this),e.__classPrivateFieldGet(this,r,"m",c).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,d,"f")))},c=function(){e.__classPrivateFieldGet(this,l,"f").setContent(o({projectId:this.projectId,flowId:this.avatar.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),e.__classPrivateFieldGet(this,d,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,l,"f").close(),this.actions.getMe()}))},h=function(){this.avatar=new s.AvatarDriver((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-avatar")}),{logger:this.logger}),this.avatar.onClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,l,"f"))||void 0===t||t.open()}))},_})),q=t.createSingletonMixin((a=>{var r,l,d,n,c,h,v,u,_,f,g,p,w;return w=class extends(t.compose(N,b,i.loggerMixin,j,i.cookieConfigMixin,i.modalMixin)(a)){constructor(){super(...arguments),r.add(this),l.set(this,void 0),d.set(this,void 0),n.set(this,void 0),c.set(this,void 0),g.set(this,t.withMemCache((e=>{this.emailUserAttr.value=e}))),p.set(this,t.withMemCache((e=>{this.emailUserAttr.badgeLabel=e?"":"Unverified"})))}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldGet(this,r,"m",f).call(this),e.__classPrivateFieldGet(this,r,"m",h).call(this),e.__classPrivateFieldGet(this,r,"m",u).call(this),e.__classPrivateFieldGet(this,g,"f").call(this,U(this.state)),e.__classPrivateFieldGet(this,p,"f").call(this,y(this.state)),this.subscribe(e.__classPrivateFieldGet(this,g,"f").bind(this),U),this.subscribe(e.__classPrivateFieldGet(this,p,"f").bind(this),y)}))}},l=new WeakMap,d=new WeakMap,n=new WeakMap,c=new WeakMap,g=new WeakMap,p=new WeakMap,r=new WeakSet,h=function(){this.emailUserAttr.editFlowId&&(e.__classPrivateFieldSet(this,l,this.createModal({"data-id":"edit-email"}),"f"),e.__classPrivateFieldSet(this,d,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,l,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,l,"f").afterClose=e.__classPrivateFieldGet(this,r,"m",v).bind(this),e.__classPrivateFieldGet(this,r,"m",v).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,d,"f")))},v=function(){e.__classPrivateFieldGet(this,l,"f").setContent(o({projectId:this.projectId,flowId:this.emailUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),e.__classPrivateFieldGet(this,d,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,l,"f").close(),this.actions.getMe()}))},u=function(){this.emailUserAttr.deleteFlowId&&(e.__classPrivateFieldSet(this,n,this.createModal({"data-id":"delete-email"}),"f"),e.__classPrivateFieldSet(this,c,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,n,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,n,"f").afterClose=e.__classPrivateFieldGet(this,r,"m",_).bind(this),e.__classPrivateFieldGet(this,r,"m",_).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,c,"f")))},_=function(){e.__classPrivateFieldGet(this,n,"f").setContent(o({projectId:this.projectId,flowId:this.emailUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),e.__classPrivateFieldGet(this,c,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,n,"f").close(),this.actions.getMe()}))},f=function(){this.emailUserAttr=new s.UserAttributeDriver((()=>{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 t;null===(t=e.__classPrivateFieldGet(this,l,"f"))||void 0===t||t.open()})),this.emailUserAttr.onDeleteClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,n,"f"))||void 0===t||t.open()}))},w})),D=t.createSingletonMixin((a=>{var r,l,o;return o=class extends(t.compose(b,i.loggerMixin,j,i.modalMixin)(a)){constructor(){super(...arguments),r.add(this)}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldGet(this,r,"m",l).call(this)}))}},r=new WeakSet,l=function(){this.logout=new s.ButtonDriver((()=>{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((()=>e.__awaiter(this,void 0,void 0,(function*(){yield this.actions.logout(),this.dispatchEvent(new CustomEvent("logout"))}))))},o})),E=t.createSingletonMixin((a=>{var r,l,d,n,c,h,v,u,_,f,g,p;return p=class extends(t.compose(N,b,i.loggerMixin,j,i.cookieConfigMixin,i.modalMixin)(a)){constructor(){super(...arguments),r.add(this),l.set(this,void 0),d.set(this,void 0),n.set(this,void 0),c.set(this,void 0),g.set(this,t.withMemCache((e=>{this.nameUserAttr.value=e})))}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldGet(this,r,"m",f).call(this),e.__classPrivateFieldGet(this,r,"m",h).call(this),e.__classPrivateFieldGet(this,r,"m",u).call(this),e.__classPrivateFieldGet(this,g,"f").call(this,k(this.state)),this.subscribe(e.__classPrivateFieldGet(this,g,"f").bind(this),k)}))}},l=new WeakMap,d=new WeakMap,n=new WeakMap,c=new WeakMap,g=new WeakMap,r=new WeakSet,h=function(){this.nameUserAttr.editFlowId&&(e.__classPrivateFieldSet(this,l,this.createModal({"data-id":"edit-name"}),"f"),e.__classPrivateFieldSet(this,d,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,l,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,l,"f").afterClose=e.__classPrivateFieldGet(this,r,"m",v).bind(this),e.__classPrivateFieldGet(this,r,"m",v).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,d,"f")))},v=function(){e.__classPrivateFieldGet(this,l,"f").setContent(o({projectId:this.projectId,flowId:this.nameUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),e.__classPrivateFieldGet(this,d,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,l,"f").close(),this.actions.getMe()}))},u=function(){this.nameUserAttr.deleteFlowId&&(e.__classPrivateFieldSet(this,n,this.createModal({"data-id":"delete-name"}),"f"),e.__classPrivateFieldSet(this,c,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,n,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,n,"f").afterClose=e.__classPrivateFieldGet(this,r,"m",_).bind(this),e.__classPrivateFieldGet(this,r,"m",_).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,c,"f")))},_=function(){e.__classPrivateFieldGet(this,n,"f").setContent(o({projectId:this.projectId,flowId:this.nameUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),e.__classPrivateFieldGet(this,c,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,n,"f").close(),this.actions.getMe()}))},f=function(){this.nameUserAttr=new s.UserAttributeDriver((()=>{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 t;null===(t=e.__classPrivateFieldGet(this,l,"f"))||void 0===t||t.open()})),this.nameUserAttr.onDeleteClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,n,"f"))||void 0===t||t.open()}))},p})),O=t.createSingletonMixin((a=>{var r,l,d,n,c,h,v,u;return u=class extends(t.compose(N,b,i.loggerMixin,j,i.cookieConfigMixin,i.modalMixin)(a)){constructor(){super(...arguments),r.add(this),l.set(this,void 0),d.set(this,void 0),v.set(this,t.withMemCache((e=>{this.passkeyUserAuthMethod.fulfilled=e})))}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldGet(this,r,"m",h).call(this),e.__classPrivateFieldGet(this,r,"m",n).call(this),e.__classPrivateFieldGet(this,v,"f").call(this,R(this.state)),this.subscribe(e.__classPrivateFieldGet(this,v,"f").bind(this),R)}))}},l=new WeakMap,d=new WeakMap,v=new WeakMap,r=new WeakSet,n=function(){this.passkeyUserAuthMethod.flowId&&(e.__classPrivateFieldSet(this,l,this.createModal({"data-id":"passkey"}),"f"),e.__classPrivateFieldSet(this,d,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,l,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,l,"f").afterClose=e.__classPrivateFieldGet(this,r,"m",c).bind(this),e.__classPrivateFieldGet(this,r,"m",c).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,d,"f")))},c=function(){e.__classPrivateFieldGet(this,l,"f").setContent(o({projectId:this.projectId,flowId:this.passkeyUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),e.__classPrivateFieldGet(this,d,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,l,"f").close(),this.actions.getMe()}))},h=function(){this.passkeyUserAuthMethod=new s.UserAuthMethodDriver((()=>{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.onButtonClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,l,"f"))||void 0===t||t.open()}))},u})),L=t.createSingletonMixin((a=>{var r,l,d,n,c,h;return h=class extends(t.compose(N,b,i.loggerMixin,j,i.cookieConfigMixin,i.modalMixin)(a)){constructor(){super(...arguments),r.add(this),l.set(this,void 0),d.set(this,void 0)}initPasswordAuthMethod(){this.passwordUserAuthMethod=new s.UserAuthMethodDriver((()=>{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.onButtonClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,l,"f"))||void 0===t||t.open()}))}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),this.initPasswordAuthMethod(),e.__classPrivateFieldGet(this,r,"m",n).call(this)}))}},l=new WeakMap,d=new WeakMap,r=new WeakSet,n=function(){this.passwordUserAuthMethod.flowId&&(e.__classPrivateFieldSet(this,l,this.createModal({"data-id":"password"}),"f"),e.__classPrivateFieldSet(this,d,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,l,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,l,"f").afterClose=e.__classPrivateFieldGet(this,r,"m",c).bind(this),e.__classPrivateFieldGet(this,r,"m",c).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,d,"f")))},c=function(){e.__classPrivateFieldGet(this,l,"f").setContent(o({projectId:this.projectId,flowId:this.passwordUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),e.__classPrivateFieldGet(this,d,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,l,"f").close()}))},h})),$=t.createSingletonMixin((a=>{var r,l,d,n,c,h,v,u,_,f,g,p,w;return w=class extends(t.compose(N,b,i.loggerMixin,j,i.cookieConfigMixin,i.modalMixin)(a)){constructor(){super(...arguments),r.add(this),l.set(this,void 0),d.set(this,void 0),n.set(this,void 0),c.set(this,void 0),g.set(this,t.withMemCache((e=>{this.phoneUserAttr.value=e}))),p.set(this,t.withMemCache((e=>{this.phoneUserAttr.badgeLabel=e?"":"Unverified"})))}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldGet(this,r,"m",f).call(this),e.__classPrivateFieldGet(this,r,"m",h).call(this),e.__classPrivateFieldGet(this,r,"m",u).call(this),e.__classPrivateFieldGet(this,g,"f").call(this,C(this.state)),e.__classPrivateFieldGet(this,p,"f").call(this,x(this.state)),this.subscribe(e.__classPrivateFieldGet(this,g,"f").bind(this),C),this.subscribe(e.__classPrivateFieldGet(this,p,"f").bind(this),x)}))}},l=new WeakMap,d=new WeakMap,n=new WeakMap,c=new WeakMap,g=new WeakMap,p=new WeakMap,r=new WeakSet,h=function(){this.phoneUserAttr.editFlowId&&(e.__classPrivateFieldSet(this,l,this.createModal({"data-id":"edit-phone"}),"f"),e.__classPrivateFieldSet(this,d,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,l,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,l,"f").afterClose=e.__classPrivateFieldGet(this,r,"m",v).bind(this),e.__classPrivateFieldGet(this,r,"m",v).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,d,"f")))},v=function(){e.__classPrivateFieldGet(this,l,"f").setContent(o({projectId:this.projectId,flowId:this.phoneUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),e.__classPrivateFieldGet(this,d,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,l,"f").close(),this.actions.getMe()}))},u=function(){this.phoneUserAttr.deleteFlowId&&(e.__classPrivateFieldSet(this,n,this.createModal({"data-id":"delete-phone"}),"f"),e.__classPrivateFieldSet(this,c,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,n,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,n,"f").afterClose=e.__classPrivateFieldGet(this,r,"m",_).bind(this),e.__classPrivateFieldGet(this,r,"m",_).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,c,"f")))},_=function(){e.__classPrivateFieldGet(this,n,"f").setContent(o({projectId:this.projectId,flowId:this.phoneUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),e.__classPrivateFieldGet(this,c,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,n,"f").close(),this.actions.getMe()}))},f=function(){this.phoneUserAttr=new s.UserAttributeDriver((()=>{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 t;null===(t=e.__classPrivateFieldGet(this,l,"f"))||void 0===t||t.open()})),this.phoneUserAttr.onDeleteClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,n,"f"))||void 0===t||t.open()}))},w}));var B;!function(e){e.TEXT="text",e.NUMBER="number",e.BOOLEAN="boolean",e.SINGLE_SELECT="singleSelect",e.ARRAY="array",e.DATE="date"}(B||(B={}));const V=t.createSingletonMixin((a=>{var r,l,d,n,c,h,v,u,_,f,g;return l=class extends(t.compose(N,b,i.loggerMixin,j,i.cookieConfigMixin,i.modalMixin)(a)){constructor(){super(...arguments),r.add(this),d.set(this,{}),n.set(this,{}),c.set(this,{}),h.set(this,{}),_.set(this,t.withMemCache((t=>{var i;const a=null===(i=this.shadowRoot)||void 0===i?void 0:i.querySelectorAll('descope-user-attribute[data-id^="customAttributes."]');Array.from(a).forEach((i=>{const a=i.getAttribute("data-id").replace("customAttributes.",""),o=i.getAttribute("data-type")||B.TEXT,d=t[a],n=new s.UserAttributeDriver(i,{logger:this.logger});n.value=l.getFormattedValue(o,d),e.__classPrivateFieldGet(this,r,"m",f).call(this,i,a,n),e.__classPrivateFieldGet(this,r,"m",g).call(this,i,a,n)}))})))}static getFormattedValue(e,t){return e===B.DATE&&t?new Date(t).toLocaleString():e===B.BOOLEAN&&void 0!==t?t?"True":"False":(t||"").toString()}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldGet(this,_,"f").call(this,A(this.state)),this.subscribe(e.__classPrivateFieldGet(this,_,"f").bind(this),A)}))}},d=new WeakMap,n=new WeakMap,c=new WeakMap,h=new WeakMap,_=new WeakMap,r=new WeakSet,v=function(t){var i,s;null===(i=e.__classPrivateFieldGet(this,d,"f")[t])||void 0===i||i.setContent(o({projectId:this.projectId,flowId:t,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),null===(s=e.__classPrivateFieldGet(this,n,"f")[t])||void 0===s||s.onSuccess((()=>{var i;null===(i=e.__classPrivateFieldGet(this,d,"f")[t])||void 0===i||i.close(),this.actions.getMe()}))},u=function(t){var i,s;null===(i=e.__classPrivateFieldGet(this,c,"f")[t])||void 0===i||i.setContent(o({projectId:this.projectId,flowId:t,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),null===(s=e.__classPrivateFieldGet(this,h,"f")[t])||void 0===s||s.onSuccess((()=>{var i;null===(i=e.__classPrivateFieldGet(this,c,"f")[t])||void 0===i||i.close(),this.actions.getMe()}))},f=function(t,i,a){const l=t.getAttribute("edit-flow-id");l&&(e.__classPrivateFieldGet(this,d,"f")[l]=this.createModal({"data-id":`edit-${i}`}),e.__classPrivateFieldGet(this,n,"f")[l]=new s.FlowDriver((()=>{var t,i;return null===(i=null===(t=e.__classPrivateFieldGet(this,d,"f")[l])||void 0===t?void 0:t.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),e.__classPrivateFieldGet(this,d,"f")[l].afterClose=e.__classPrivateFieldGet(this,r,"m",v).bind(this,l),a.onEditClick((()=>{var t,i;null===(i=null===(t=e.__classPrivateFieldGet(this,d,"f"))||void 0===t?void 0:t[l])||void 0===i||i.open()})),e.__classPrivateFieldGet(this,r,"m",v).call(this,l),this.syncFlowTheme(e.__classPrivateFieldGet(this,n,"f")[l]))},g=function(t,i,a){const l=t.getAttribute("delete-flow-id");l&&(e.__classPrivateFieldGet(this,c,"f")[l]=this.createModal({"data-id":`delete-${i}`}),e.__classPrivateFieldGet(this,h,"f")[l]=new s.FlowDriver((()=>{var t,i;return null===(i=null===(t=e.__classPrivateFieldGet(this,c,"f")[l])||void 0===t?void 0:t.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),e.__classPrivateFieldGet(this,c,"f")[l].afterClose=e.__classPrivateFieldGet(this,r,"m",u).bind(this,l),a.onDeleteClick((()=>{var t,i;null===(i=null===(t=e.__classPrivateFieldGet(this,c,"f"))||void 0===t?void 0:t[l])||void 0===i||i.open()})),e.__classPrivateFieldGet(this,r,"m",u).call(this,l),this.syncFlowTheme(e.__classPrivateFieldGet(this,h,"f")[l]))},l})),H=t.createSingletonMixin((a=>{var r,l,d,n,c,h,v,u;return u=class extends(t.compose(N,b,i.loggerMixin,j,i.cookieConfigMixin,i.modalMixin)(a)){constructor(){super(...arguments),r.add(this),l.set(this,void 0),d.set(this,void 0),v.set(this,t.withMemCache((e=>{this.totpUserAuthMethod.fulfilled=e})))}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldGet(this,r,"m",h).call(this),e.__classPrivateFieldGet(this,r,"m",n).call(this),e.__classPrivateFieldGet(this,v,"f").call(this,W(this.state)),this.subscribe(e.__classPrivateFieldGet(this,v,"f").bind(this),W)}))}},l=new WeakMap,d=new WeakMap,v=new WeakMap,r=new WeakSet,n=function(){this.totpUserAuthMethod.flowId&&(e.__classPrivateFieldSet(this,l,this.createModal({"data-id":"totp"}),"f"),e.__classPrivateFieldSet(this,d,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,l,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,l,"f").afterClose=e.__classPrivateFieldGet(this,r,"m",c).bind(this),e.__classPrivateFieldGet(this,r,"m",c).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,d,"f")))},c=function(){e.__classPrivateFieldGet(this,l,"f").setContent(o({projectId:this.projectId,flowId:this.totpUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),e.__classPrivateFieldGet(this,d,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,l,"f").close(),this.actions.getMe()}))},h=function(){this.totpUserAuthMethod=new s.UserAuthMethodDriver((()=>{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.onButtonClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,l,"f"))||void 0===t||t.open()}))},u})),X=t.createSingletonMixin((s=>class extends(t.compose(i.debuggerMixin,i.themeMixin,M,V,q,T,E,$,O,L,L,H,D)(s)){init(){const t=Object.create(null,{init:{get:()=>super.init}});return e.__awaiter(this,void 0,void 0,(function*(){var e;yield null===(e=t.init)||void 0===e?void 0:e.call(this)}))}})),J=t.compose((t=>class extends(X(t)){init(){const t=Object.create(null,{init:{get:()=>super.init}});return e.__awaiter(this,void 0,void 0,(function*(){var e;yield null===(e=t.init)||void 0===e?void 0:e.call(this);(customElements.get("descope-wc")||(yield import("@descope/web-component").then((e=>e.default)))).sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"user-profile-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.4.0"}}}))}}))(HTMLElement);customElements.define("descope-user-profile-widget",J),module.exports=J; | ||
"use strict";var e=require("tslib"),t=require("@descope/sdk-helpers"),i=require("@descope/sdk-mixins"),s=require("@descope/sdk-component-drivers"),a=require("@reduxjs/toolkit");require("@descope/core-js-sdk");var r=require("@descope/web-js-sdk"),l=require("reselect");require("@descope/web-component");const o=(e={})=>{const i=t.createTemplate("<descope-wc></descope-wc>");return Object.entries(e).forEach((([e,s])=>{i.content.querySelector("descope-wc").setAttribute(t.kebabCase(e),s)})),i};function d(e){return new URLSearchParams(window.location.search).get(e)}const n=e=>(...t)=>i=>{i.addCase(e.pending,((e,i)=>{t.forEach((({onPending:t})=>{null==t||t(e,i)}))})),i.addCase(e.fulfilled,((e,i)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,i)}))})),i.addCase(e.rejected,((e,i)=>{t.forEach((({onRejected:t})=>{null==t||t(e,i)}))}))},c=a.createAsyncThunk("users/me",((e,{extra:{api:t}})=>t.user.me())),h=n(c)({onFulfilled:(e,t)=>{e.me.data=t.payload}},(v=e=>e.me,{onFulfilled:e=>{v(e).loading=!1},onPending:e=>{v(e).loading=!0,v(e).error=null},onRejected:(e,t)=>{v(e).loading=!1,v(e).error=t.error}}));var v;const u={action:c,reducer:h},_=a.createAsyncThunk("users/logout",((e,{extra:{api:t}})=>t.user.logout())),f={action:_,reducer:n(_)({})},g={me:{loading:!1,error:null,data:{}}},p={me:"/v1/auth/me"},w=()=>e.__awaiter(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})}))})),m=({httpClient:t,mock:i})=>({me:()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(i)return w();const s=yield t.get(p.me);return yield(t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=yield t.text(),i=JSON.parse(e);if(!t.ok){const e=`${i.errorDescription}${i.errorMessage?`: ${i.errorMessage}`:""}`;throw Error(e||`${t.status} ${t.statusText}`)}t.json=()=>Promise.resolve(i),t.text=()=>Promise.resolve(e)})))(s),s.json()}))}),F=t.createSingletonMixin((s=>{var a,l,o,d;const n=t.compose(i.projectIdMixin,i.observeAttributesMixin,i.loggerMixin,i.baseUrlMixin,i.cookieConfigMixin)(s);return d=class extends n{constructor(){super(...arguments),a.add(this),l.set(this,void 0)}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get api(){return e.__classPrivateFieldGet(this,l,"f")||e.__classPrivateFieldGet(this,a,"m",o).call(this),e.__classPrivateFieldGet(this,l,"f")}init(){const t=Object.create(null,{init:{get:()=>super.init}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.init)||void 0===i?void 0:i.call(this),this.observeAttributes(["project-id","base-url"],(()=>{e.__classPrivateFieldGet(this,l,"f")&&e.__classPrivateFieldGet(this,a,"m",o).call(this)}))}))}},l=new WeakMap,a=new WeakSet,o=function(){this.logger.debug("creating an sdk instance"),e.__classPrivateFieldSet(this,l,((t,i,s)=>{const a=r(Object.assign(Object.assign({},t),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"user-profile-widget","x-descope-widget-id":s,"x-descope-widget-version":"0.4.1"}}));return{user:Object.assign(Object.assign({},m({httpClient:a.httpClient,mock:i})),{logout:i?()=>e.__awaiter(void 0,void 0,void 0,(function*(){})):a.logout})}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},"true"===this.mock,this.widgetId),"f")},d})),b=t.createSingletonMixin((e=>{const s=t.compose(i.createStateManagementMixin({name:"widget",initialState:g,reducers:{},extraReducers:e=>{u.reducer(e),f.reducer(e)},asyncActions:{getMe:u.action,logout:f.action}}),i.initLifecycleMixin,i.loggerMixin,F)(e);return class extends s{constructor(...e){super(...e),this.state=g,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),P="widget-flow",M=t.createSingletonMixin((a=>{var r,l,n;return n=class extends(t.compose(i.initLifecycleMixin,i.modalMixin,b,i.cookieConfigMixin,i.loggerMixin)(a)){constructor(){super(...arguments),r.add(this)}init(){const t=Object.create(null,{init:{get:()=>super.init}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.init)||void 0===i?void 0:i.call(this);const s=d(P);s&&(!function(e){if(window.history.replaceState&&d(e)){const t=new URL(window.location.href),i=new URLSearchParams(t.search);i.delete(e),t.search=i.toString(),window.history.replaceState({},"",t.toString())}}(P),e.__classPrivateFieldGet(this,r,"m",l).call(this,s))}))}},r=new WeakSet,l=function(e){const t=this.createModal({"data-id":"redirect-flow"});t.setContent(o({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName}));new s.FlowDriver((()=>{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()},n})),G=e=>e.me.data,S=l.createSelector(G,(e=>e.picture)),U=l.createSelector(G,(e=>e.email)),y=l.createSelector(G,(e=>e.verifiedEmail)),k=l.createSelector(G,(e=>e.name)),C=l.createSelector(G,(e=>e.phone)),x=l.createSelector(G,(e=>e.verifiedPhone)),R=l.createSelector(G,(e=>e.webauthn));l.createSelector(G,(e=>e.password));const W=l.createSelector(G,(e=>e.TOTP)),A=l.createSelector(G,(e=>e.customAttributes)),I=t.createSingletonMixin((s=>{const a=t.compose(i.staticResourcesMixin,i.createValidateAttributesMixin({"widget-id":i.createValidateAttributesMixin.missingAttrValidator}))(s);return class extends a{get widgetId(){return this.getAttribute("widget-id")}fetchWidgetPage(t){return e.__awaiter(this,void 0,void 0,(function*(){return(yield this.fetchStaticResource(`user-profile-widget/${this.widgetId}/${t}`,"text")).body}))}}})),j=t.createSingletonMixin((s=>{var a,r,l;return l=class extends(t.compose(i.loggerMixin,i.initLifecycleMixin,i.descopeUiMixin,i.initElementMixin,I,b)(s)){constructor(){super(...arguments),a.add(this)}onWidgetRootReady(){return e.__awaiter(this,void 0,void 0,(function*(){}))}init(){const t=Object.create(null,{init:{get:()=>super.init}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.init)||void 0===i?void 0:i.call(this),yield Promise.all([this.actions.getMe(),e.__classPrivateFieldGet(this,a,"m",r).call(this)]),this.onWidgetRootReady()}))}},a=new WeakSet,r=function(){return e.__awaiter(this,void 0,void 0,(function*(){const e=t.createTemplate(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},l})),N=t.createSingletonMixin((e=>class extends(t.compose(i.themeMixin,i.observeAttributesMixin)(e)){syncFlowTheme(e){e.theme=this.theme,this.observeAttributes(["theme"],(()=>{e.theme=this.theme}))}})),T=t.createSingletonMixin((a=>{var r,l,d,n,c,h,v,u,_;return _=class extends(t.compose(N,i.themeMixin,b,i.loggerMixin,i.cookieConfigMixin,j,i.modalMixin)(a)){constructor(){super(...arguments),r.add(this),l.set(this,void 0),d.set(this,void 0),v.set(this,t.withMemCache((e=>{this.avatar.image=e}))),u.set(this,t.withMemCache((e=>{this.avatar.displayName=e})))}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldGet(this,r,"m",h).call(this),e.__classPrivateFieldGet(this,r,"m",n).call(this),e.__classPrivateFieldGet(this,v,"f").call(this,S(this.state)),e.__classPrivateFieldGet(this,u,"f").call(this,k(this.state)),this.subscribe(e.__classPrivateFieldGet(this,v,"f").bind(this),S),this.subscribe(e.__classPrivateFieldGet(this,u,"f").bind(this),k)}))}},l=new WeakMap,d=new WeakMap,v=new WeakMap,u=new WeakMap,r=new WeakSet,n=function(){this.avatar.flowId&&(e.__classPrivateFieldSet(this,l,this.createModal({"data-id":"update-pic"}),"f"),e.__classPrivateFieldSet(this,d,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,l,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,l,"f").afterClose=e.__classPrivateFieldGet(this,r,"m",c).bind(this),e.__classPrivateFieldGet(this,r,"m",c).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,d,"f")))},c=function(){e.__classPrivateFieldGet(this,l,"f").setContent(o({projectId:this.projectId,flowId:this.avatar.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),e.__classPrivateFieldGet(this,d,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,l,"f").close(),this.actions.getMe()}))},h=function(){this.avatar=new s.AvatarDriver((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-avatar")}),{logger:this.logger}),this.avatar.onClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,l,"f"))||void 0===t||t.open()}))},_})),q=t.createSingletonMixin((a=>{var r,l,d,n,c,h,v,u,_,f,g,p,w;return w=class extends(t.compose(N,b,i.loggerMixin,j,i.cookieConfigMixin,i.modalMixin)(a)){constructor(){super(...arguments),r.add(this),l.set(this,void 0),d.set(this,void 0),n.set(this,void 0),c.set(this,void 0),g.set(this,t.withMemCache((e=>{this.emailUserAttr.value=e}))),p.set(this,t.withMemCache((e=>{this.emailUserAttr.badgeLabel=e?"":"Unverified"})))}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldGet(this,r,"m",f).call(this),e.__classPrivateFieldGet(this,r,"m",h).call(this),e.__classPrivateFieldGet(this,r,"m",u).call(this),e.__classPrivateFieldGet(this,g,"f").call(this,U(this.state)),e.__classPrivateFieldGet(this,p,"f").call(this,y(this.state)),this.subscribe(e.__classPrivateFieldGet(this,g,"f").bind(this),U),this.subscribe(e.__classPrivateFieldGet(this,p,"f").bind(this),y)}))}},l=new WeakMap,d=new WeakMap,n=new WeakMap,c=new WeakMap,g=new WeakMap,p=new WeakMap,r=new WeakSet,h=function(){this.emailUserAttr.editFlowId&&(e.__classPrivateFieldSet(this,l,this.createModal({"data-id":"edit-email"}),"f"),e.__classPrivateFieldSet(this,d,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,l,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,l,"f").afterClose=e.__classPrivateFieldGet(this,r,"m",v).bind(this),e.__classPrivateFieldGet(this,r,"m",v).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,d,"f")))},v=function(){e.__classPrivateFieldGet(this,l,"f").setContent(o({projectId:this.projectId,flowId:this.emailUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),e.__classPrivateFieldGet(this,d,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,l,"f").close(),this.actions.getMe()}))},u=function(){this.emailUserAttr.deleteFlowId&&(e.__classPrivateFieldSet(this,n,this.createModal({"data-id":"delete-email"}),"f"),e.__classPrivateFieldSet(this,c,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,n,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,n,"f").afterClose=e.__classPrivateFieldGet(this,r,"m",_).bind(this),e.__classPrivateFieldGet(this,r,"m",_).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,c,"f")))},_=function(){e.__classPrivateFieldGet(this,n,"f").setContent(o({projectId:this.projectId,flowId:this.emailUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),e.__classPrivateFieldGet(this,c,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,n,"f").close(),this.actions.getMe()}))},f=function(){this.emailUserAttr=new s.UserAttributeDriver((()=>{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 t;null===(t=e.__classPrivateFieldGet(this,l,"f"))||void 0===t||t.open()})),this.emailUserAttr.onDeleteClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,n,"f"))||void 0===t||t.open()}))},w})),D=t.createSingletonMixin((a=>{var r,l,o;return o=class extends(t.compose(b,i.loggerMixin,j,i.modalMixin)(a)){constructor(){super(...arguments),r.add(this)}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldGet(this,r,"m",l).call(this)}))}},r=new WeakSet,l=function(){this.logout=new s.ButtonDriver((()=>{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((()=>e.__awaiter(this,void 0,void 0,(function*(){yield this.actions.logout(),this.dispatchEvent(new CustomEvent("logout"))}))))},o})),E=t.createSingletonMixin((a=>{var r,l,d,n,c,h,v,u,_,f,g,p;return p=class extends(t.compose(N,b,i.loggerMixin,j,i.cookieConfigMixin,i.modalMixin)(a)){constructor(){super(...arguments),r.add(this),l.set(this,void 0),d.set(this,void 0),n.set(this,void 0),c.set(this,void 0),g.set(this,t.withMemCache((e=>{this.nameUserAttr.value=e})))}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldGet(this,r,"m",f).call(this),e.__classPrivateFieldGet(this,r,"m",h).call(this),e.__classPrivateFieldGet(this,r,"m",u).call(this),e.__classPrivateFieldGet(this,g,"f").call(this,k(this.state)),this.subscribe(e.__classPrivateFieldGet(this,g,"f").bind(this),k)}))}},l=new WeakMap,d=new WeakMap,n=new WeakMap,c=new WeakMap,g=new WeakMap,r=new WeakSet,h=function(){this.nameUserAttr.editFlowId&&(e.__classPrivateFieldSet(this,l,this.createModal({"data-id":"edit-name"}),"f"),e.__classPrivateFieldSet(this,d,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,l,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,l,"f").afterClose=e.__classPrivateFieldGet(this,r,"m",v).bind(this),e.__classPrivateFieldGet(this,r,"m",v).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,d,"f")))},v=function(){e.__classPrivateFieldGet(this,l,"f").setContent(o({projectId:this.projectId,flowId:this.nameUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),e.__classPrivateFieldGet(this,d,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,l,"f").close(),this.actions.getMe()}))},u=function(){this.nameUserAttr.deleteFlowId&&(e.__classPrivateFieldSet(this,n,this.createModal({"data-id":"delete-name"}),"f"),e.__classPrivateFieldSet(this,c,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,n,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,n,"f").afterClose=e.__classPrivateFieldGet(this,r,"m",_).bind(this),e.__classPrivateFieldGet(this,r,"m",_).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,c,"f")))},_=function(){e.__classPrivateFieldGet(this,n,"f").setContent(o({projectId:this.projectId,flowId:this.nameUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),e.__classPrivateFieldGet(this,c,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,n,"f").close(),this.actions.getMe()}))},f=function(){this.nameUserAttr=new s.UserAttributeDriver((()=>{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 t;null===(t=e.__classPrivateFieldGet(this,l,"f"))||void 0===t||t.open()})),this.nameUserAttr.onDeleteClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,n,"f"))||void 0===t||t.open()}))},p})),O=t.createSingletonMixin((a=>{var r,l,d,n,c,h,v,u;return u=class extends(t.compose(N,b,i.loggerMixin,j,i.cookieConfigMixin,i.modalMixin)(a)){constructor(){super(...arguments),r.add(this),l.set(this,void 0),d.set(this,void 0),v.set(this,t.withMemCache((e=>{this.passkeyUserAuthMethod.fulfilled=e})))}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldGet(this,r,"m",h).call(this),e.__classPrivateFieldGet(this,r,"m",n).call(this),e.__classPrivateFieldGet(this,v,"f").call(this,R(this.state)),this.subscribe(e.__classPrivateFieldGet(this,v,"f").bind(this),R)}))}},l=new WeakMap,d=new WeakMap,v=new WeakMap,r=new WeakSet,n=function(){this.passkeyUserAuthMethod.flowId&&(e.__classPrivateFieldSet(this,l,this.createModal({"data-id":"passkey"}),"f"),e.__classPrivateFieldSet(this,d,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,l,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,l,"f").afterClose=e.__classPrivateFieldGet(this,r,"m",c).bind(this),e.__classPrivateFieldGet(this,r,"m",c).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,d,"f")))},c=function(){e.__classPrivateFieldGet(this,l,"f").setContent(o({projectId:this.projectId,flowId:this.passkeyUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),e.__classPrivateFieldGet(this,d,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,l,"f").close(),this.actions.getMe()}))},h=function(){this.passkeyUserAuthMethod=new s.UserAuthMethodDriver((()=>{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.onButtonClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,l,"f"))||void 0===t||t.open()}))},u})),L=t.createSingletonMixin((a=>{var r,l,d,n,c,h;return h=class extends(t.compose(N,b,i.loggerMixin,j,i.cookieConfigMixin,i.modalMixin)(a)){constructor(){super(...arguments),r.add(this),l.set(this,void 0),d.set(this,void 0)}initPasswordAuthMethod(){this.passwordUserAuthMethod=new s.UserAuthMethodDriver((()=>{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.onButtonClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,l,"f"))||void 0===t||t.open()}))}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),this.initPasswordAuthMethod(),e.__classPrivateFieldGet(this,r,"m",n).call(this)}))}},l=new WeakMap,d=new WeakMap,r=new WeakSet,n=function(){this.passwordUserAuthMethod.flowId&&(e.__classPrivateFieldSet(this,l,this.createModal({"data-id":"password"}),"f"),e.__classPrivateFieldSet(this,d,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,l,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,l,"f").afterClose=e.__classPrivateFieldGet(this,r,"m",c).bind(this),e.__classPrivateFieldGet(this,r,"m",c).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,d,"f")))},c=function(){e.__classPrivateFieldGet(this,l,"f").setContent(o({projectId:this.projectId,flowId:this.passwordUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),e.__classPrivateFieldGet(this,d,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,l,"f").close()}))},h})),$=t.createSingletonMixin((a=>{var r,l,d,n,c,h,v,u,_,f,g,p,w;return w=class extends(t.compose(N,b,i.loggerMixin,j,i.cookieConfigMixin,i.modalMixin)(a)){constructor(){super(...arguments),r.add(this),l.set(this,void 0),d.set(this,void 0),n.set(this,void 0),c.set(this,void 0),g.set(this,t.withMemCache((e=>{this.phoneUserAttr.value=e}))),p.set(this,t.withMemCache((e=>{this.phoneUserAttr.badgeLabel=e?"":"Unverified"})))}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldGet(this,r,"m",f).call(this),e.__classPrivateFieldGet(this,r,"m",h).call(this),e.__classPrivateFieldGet(this,r,"m",u).call(this),e.__classPrivateFieldGet(this,g,"f").call(this,C(this.state)),e.__classPrivateFieldGet(this,p,"f").call(this,x(this.state)),this.subscribe(e.__classPrivateFieldGet(this,g,"f").bind(this),C),this.subscribe(e.__classPrivateFieldGet(this,p,"f").bind(this),x)}))}},l=new WeakMap,d=new WeakMap,n=new WeakMap,c=new WeakMap,g=new WeakMap,p=new WeakMap,r=new WeakSet,h=function(){this.phoneUserAttr.editFlowId&&(e.__classPrivateFieldSet(this,l,this.createModal({"data-id":"edit-phone"}),"f"),e.__classPrivateFieldSet(this,d,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,l,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,l,"f").afterClose=e.__classPrivateFieldGet(this,r,"m",v).bind(this),e.__classPrivateFieldGet(this,r,"m",v).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,d,"f")))},v=function(){e.__classPrivateFieldGet(this,l,"f").setContent(o({projectId:this.projectId,flowId:this.phoneUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),e.__classPrivateFieldGet(this,d,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,l,"f").close(),this.actions.getMe()}))},u=function(){this.phoneUserAttr.deleteFlowId&&(e.__classPrivateFieldSet(this,n,this.createModal({"data-id":"delete-phone"}),"f"),e.__classPrivateFieldSet(this,c,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,n,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,n,"f").afterClose=e.__classPrivateFieldGet(this,r,"m",_).bind(this),e.__classPrivateFieldGet(this,r,"m",_).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,c,"f")))},_=function(){e.__classPrivateFieldGet(this,n,"f").setContent(o({projectId:this.projectId,flowId:this.phoneUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),e.__classPrivateFieldGet(this,c,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,n,"f").close(),this.actions.getMe()}))},f=function(){this.phoneUserAttr=new s.UserAttributeDriver((()=>{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 t;null===(t=e.__classPrivateFieldGet(this,l,"f"))||void 0===t||t.open()})),this.phoneUserAttr.onDeleteClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,n,"f"))||void 0===t||t.open()}))},w}));var B;!function(e){e.TEXT="text",e.NUMBER="number",e.BOOLEAN="boolean",e.SINGLE_SELECT="singleSelect",e.ARRAY="array",e.DATE="date"}(B||(B={}));const V=t.createSingletonMixin((a=>{var r,l,d,n,c,h,v,u,_,f,g;return l=class extends(t.compose(N,b,i.loggerMixin,j,i.cookieConfigMixin,i.modalMixin)(a)){constructor(){super(...arguments),r.add(this),d.set(this,{}),n.set(this,{}),c.set(this,{}),h.set(this,{}),_.set(this,t.withMemCache((t=>{var i;const a=null===(i=this.shadowRoot)||void 0===i?void 0:i.querySelectorAll('descope-user-attribute[data-id^="customAttributes."]');Array.from(a).forEach((i=>{const a=i.getAttribute("data-id").replace("customAttributes.",""),o=i.getAttribute("data-type")||B.TEXT,d=t[a],n=new s.UserAttributeDriver(i,{logger:this.logger});n.value=l.getFormattedValue(o,d),e.__classPrivateFieldGet(this,r,"m",f).call(this,i,a,n),e.__classPrivateFieldGet(this,r,"m",g).call(this,i,a,n)}))})))}static getFormattedValue(e,t){return e===B.DATE&&t?new Date(t).toLocaleString():e===B.BOOLEAN&&void 0!==t?t?"True":"False":(t||"").toString()}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldGet(this,_,"f").call(this,A(this.state)),this.subscribe(e.__classPrivateFieldGet(this,_,"f").bind(this),A)}))}},d=new WeakMap,n=new WeakMap,c=new WeakMap,h=new WeakMap,_=new WeakMap,r=new WeakSet,v=function(t){var i,s;null===(i=e.__classPrivateFieldGet(this,d,"f")[t])||void 0===i||i.setContent(o({projectId:this.projectId,flowId:t,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),null===(s=e.__classPrivateFieldGet(this,n,"f")[t])||void 0===s||s.onSuccess((()=>{var i;null===(i=e.__classPrivateFieldGet(this,d,"f")[t])||void 0===i||i.close(),this.actions.getMe()}))},u=function(t){var i,s;null===(i=e.__classPrivateFieldGet(this,c,"f")[t])||void 0===i||i.setContent(o({projectId:this.projectId,flowId:t,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),null===(s=e.__classPrivateFieldGet(this,h,"f")[t])||void 0===s||s.onSuccess((()=>{var i;null===(i=e.__classPrivateFieldGet(this,c,"f")[t])||void 0===i||i.close(),this.actions.getMe()}))},f=function(t,i,a){const l=t.getAttribute("edit-flow-id");l&&(e.__classPrivateFieldGet(this,d,"f")[l]=this.createModal({"data-id":`edit-${i}`}),e.__classPrivateFieldGet(this,n,"f")[l]=new s.FlowDriver((()=>{var t,i;return null===(i=null===(t=e.__classPrivateFieldGet(this,d,"f")[l])||void 0===t?void 0:t.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),e.__classPrivateFieldGet(this,d,"f")[l].afterClose=e.__classPrivateFieldGet(this,r,"m",v).bind(this,l),a.onEditClick((()=>{var t,i;null===(i=null===(t=e.__classPrivateFieldGet(this,d,"f"))||void 0===t?void 0:t[l])||void 0===i||i.open()})),e.__classPrivateFieldGet(this,r,"m",v).call(this,l),this.syncFlowTheme(e.__classPrivateFieldGet(this,n,"f")[l]))},g=function(t,i,a){const l=t.getAttribute("delete-flow-id");l&&(e.__classPrivateFieldGet(this,c,"f")[l]=this.createModal({"data-id":`delete-${i}`}),e.__classPrivateFieldGet(this,h,"f")[l]=new s.FlowDriver((()=>{var t,i;return null===(i=null===(t=e.__classPrivateFieldGet(this,c,"f")[l])||void 0===t?void 0:t.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),e.__classPrivateFieldGet(this,c,"f")[l].afterClose=e.__classPrivateFieldGet(this,r,"m",u).bind(this,l),a.onDeleteClick((()=>{var t,i;null===(i=null===(t=e.__classPrivateFieldGet(this,c,"f"))||void 0===t?void 0:t[l])||void 0===i||i.open()})),e.__classPrivateFieldGet(this,r,"m",u).call(this,l),this.syncFlowTheme(e.__classPrivateFieldGet(this,h,"f")[l]))},l})),H=t.createSingletonMixin((a=>{var r,l,d,n,c,h,v,u;return u=class extends(t.compose(N,b,i.loggerMixin,j,i.cookieConfigMixin,i.modalMixin)(a)){constructor(){super(...arguments),r.add(this),l.set(this,void 0),d.set(this,void 0),v.set(this,t.withMemCache((e=>{this.totpUserAuthMethod.fulfilled=e})))}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldGet(this,r,"m",h).call(this),e.__classPrivateFieldGet(this,r,"m",n).call(this),e.__classPrivateFieldGet(this,v,"f").call(this,W(this.state)),this.subscribe(e.__classPrivateFieldGet(this,v,"f").bind(this),W)}))}},l=new WeakMap,d=new WeakMap,v=new WeakMap,r=new WeakSet,n=function(){this.totpUserAuthMethod.flowId&&(e.__classPrivateFieldSet(this,l,this.createModal({"data-id":"totp"}),"f"),e.__classPrivateFieldSet(this,d,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,l,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,l,"f").afterClose=e.__classPrivateFieldGet(this,r,"m",c).bind(this),e.__classPrivateFieldGet(this,r,"m",c).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,d,"f")))},c=function(){e.__classPrivateFieldGet(this,l,"f").setContent(o({projectId:this.projectId,flowId:this.totpUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),e.__classPrivateFieldGet(this,d,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,l,"f").close(),this.actions.getMe()}))},h=function(){this.totpUserAuthMethod=new s.UserAuthMethodDriver((()=>{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.onButtonClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,l,"f"))||void 0===t||t.open()}))},u})),X=t.createSingletonMixin((s=>class extends(t.compose(i.debuggerMixin,i.themeMixin,M,V,q,T,E,$,O,L,L,H,D)(s)){init(){const t=Object.create(null,{init:{get:()=>super.init}});return e.__awaiter(this,void 0,void 0,(function*(){var e;yield null===(e=t.init)||void 0===e?void 0:e.call(this)}))}})),J=t.compose((t=>class extends(X(t)){init(){const t=Object.create(null,{init:{get:()=>super.init}});return e.__awaiter(this,void 0,void 0,(function*(){var e;yield null===(e=t.init)||void 0===e?void 0:e.call(this);(customElements.get("descope-wc")||(yield import("@descope/web-component").then((e=>e.default)))).sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"user-profile-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.4.1"}}}))}}))(HTMLElement);customElements.define("descope-user-profile-widget",J),module.exports=J; | ||
//# sourceMappingURL=index.js.map |
/** | ||
* @descope/user-profile-widget v0.4.0 | ||
* @descope/user-profile-widget v0.4.1 | ||
*/ | ||
import{__awaiter as t,__classPrivateFieldGet as e,__classPrivateFieldSet as i}from"tslib";import{createTemplate as s,kebabCase as o,createSingletonMixin as r,compose as a,withMemCache as n}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 v,modalMixin as g,staticResourcesMixin as p,createValidateAttributesMixin as m,descopeUiMixin as w,initElementMixin as b,themeMixin as U,debuggerMixin as y}from"@descope/sdk-mixins";import{FlowDriver as k,AvatarDriver as C,UserAttributeDriver as R,ButtonDriver as S,UserAuthMethodDriver as W}from"@descope/sdk-component-drivers";import{createAsyncThunk as M}from"@reduxjs/toolkit";import"@descope/core-js-sdk";import I from"@descope/web-js-sdk";import{createSelector as A}from"reselect";import"@descope/web-component";const j=(t={})=>{const e=s("<descope-wc></descope-wc>");return Object.entries(t).forEach((([t,i])=>{e.content.querySelector("descope-wc").setAttribute(o(t),i)})),e};function N(t){return new URLSearchParams(window.location.search).get(t)}const x=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=M("users/me",((t,{extra:{api:e}})=>e.user.me())),F=x(T)({onFulfilled:(t,e)=>{t.me.data=e.payload}},(E=t=>t.me,{onFulfilled:t=>{E(t).loading=!1},onPending:t=>{E(t).loading=!0,E(t).error=null},onRejected:(t,e)=>{E(t).loading=!1,E(t).error=e.error}}));var E;const O={action:T,reducer:F},q=M("users/logout",((t,{extra:{api:e}})=>e.user.logout())),P={action:q,reducer:x(q)({})},L={me:{loading:!1,error:null,data:{}}},D={me:"/v1/auth/me"},$=()=>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})}))})),B=({httpClient:e,mock:i})=>({me:()=>t(void 0,void 0,void 0,(function*(){if(i)return $();const s=yield e.get(D.me);return yield(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)})))(s),s.json()}))}),H=r((s=>{var o,r,n,f;const v=a(d,l,h,c,u)(s);return f=class extends v{constructor(){super(...arguments),o.add(this),r.set(this,void 0)}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get api(){return e(this,r,"f")||e(this,o,"m",n).call(this),e(this,r,"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"],(()=>{e(this,r,"f")&&e(this,o,"m",n).call(this)}))}))}},r=new WeakMap,o=new WeakSet,n=function(){this.logger.debug("creating an sdk instance"),i(this,r,((e,i,s)=>{const o=I(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"user-profile-widget","x-descope-widget-id":s,"x-descope-widget-version":"0.4.0"}}));return{user:Object.assign(Object.assign({},B({httpClient:o.httpClient,mock:i})),{logout:i?()=>t(void 0,void 0,void 0,(function*(){})):o.logout})}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},"true"===this.mock,this.widgetId),"f")},f})),V=r((t=>{const e=a(f({name:"widget",initialState:L,reducers:{},extraReducers:t=>{O.reducer(t),P.reducer(t)},asyncActions:{getMe:O.action,logout:P.action}}),v,h,H)(t);return class extends e{constructor(...t){super(...t),this.state=L,this.subscribe((t=>{this.logger.debug("State update:",t),this.state=t}))}}})),X="widget-flow",G=r((i=>{var s,o,r;return r=class extends(a(v,g,V,u,h)(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 r=N(X);r&&(!function(t){if(window.history.replaceState&&N(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())}}(X),e(this,s,"m",o).call(this,r))}))}},s=new WeakSet,o=function(t){const e=this.createModal({"data-id":"redirect-flow"});e.setContent(j({projectId:this.projectId,flowId:t,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName}));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()})),e.afterClose=()=>{e.remove()},e.open()},r})),J=t=>t.me.data,Y=A(J,(t=>t.picture)),_=A(J,(t=>t.email)),z=A(J,(t=>t.verifiedEmail)),K=A(J,(t=>t.name)),Q=A(J,(t=>t.phone)),Z=A(J,(t=>t.verifiedPhone)),tt=A(J,(t=>t.webauthn));A(J,(t=>t.password));const et=A(J,(t=>t.TOTP)),it=A(J,(t=>t.customAttributes)),st=r((e=>{const i=a(p,m({"widget-id":m.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(`user-profile-widget/${this.widgetId}/${e}`,"text")).body}))}}})),ot=r((i=>{var o,r,n;return n=class extends(a(h,v,w,b,st,V)(i)){constructor(){super(...arguments),o.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),yield Promise.all([this.actions.getMe(),e(this,o,"m",r).call(this)]),this.onWidgetRootReady()}))}},o=new WeakSet,r=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))}))},n})),rt=r((t=>class extends(a(U,l)(t)){syncFlowTheme(t){t.theme=this.theme,this.observeAttributes(["theme"],(()=>{t.theme=this.theme}))}})),at=r((s=>{var o,r,d,l,c,f,v,p,m;return m=class extends(a(rt,U,V,h,u,ot,g)(s)){constructor(){super(...arguments),o.add(this),r.set(this,void 0),d.set(this,void 0),v.set(this,n((t=>{this.avatar.image=t}))),p.set(this,n((t=>{this.avatar.displayName=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,o,"m",f).call(this),e(this,o,"m",l).call(this),e(this,v,"f").call(this,Y(this.state)),e(this,p,"f").call(this,K(this.state)),this.subscribe(e(this,v,"f").bind(this),Y),this.subscribe(e(this,p,"f").bind(this),K)}))}},r=new WeakMap,d=new WeakMap,v=new WeakMap,p=new WeakMap,o=new WeakSet,l=function(){this.avatar.flowId&&(i(this,r,this.createModal({"data-id":"update-pic"}),"f"),i(this,d,new k((()=>{var t;return null===(t=e(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,r,"f").afterClose=e(this,o,"m",c).bind(this),e(this,o,"m",c).call(this),this.syncFlowTheme(e(this,d,"f")))},c=function(){e(this,r,"f").setContent(j({projectId:this.projectId,flowId:this.avatar.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),e(this,d,"f").onSuccess((()=>{e(this,r,"f").close(),this.actions.getMe()}))},f=function(){this.avatar=new C((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector("descope-avatar")}),{logger:this.logger}),this.avatar.onClick((()=>{var t;null===(t=e(this,r,"f"))||void 0===t||t.open()}))},m})),nt=r((s=>{var o,r,d,l,c,f,v,p,m,w,b,U,y;return y=class extends(a(rt,V,h,ot,u,g)(s)){constructor(){super(...arguments),o.add(this),r.set(this,void 0),d.set(this,void 0),l.set(this,void 0),c.set(this,void 0),b.set(this,n((t=>{this.emailUserAttr.value=t}))),U.set(this,n((t=>{this.emailUserAttr.badgeLabel=t?"":"Unverified"})))}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,o,"m",w).call(this),e(this,o,"m",f).call(this),e(this,o,"m",p).call(this),e(this,b,"f").call(this,_(this.state)),e(this,U,"f").call(this,z(this.state)),this.subscribe(e(this,b,"f").bind(this),_),this.subscribe(e(this,U,"f").bind(this),z)}))}},r=new WeakMap,d=new WeakMap,l=new WeakMap,c=new WeakMap,b=new WeakMap,U=new WeakMap,o=new WeakSet,f=function(){this.emailUserAttr.editFlowId&&(i(this,r,this.createModal({"data-id":"edit-email"}),"f"),i(this,d,new k((()=>{var t;return null===(t=e(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,r,"f").afterClose=e(this,o,"m",v).bind(this),e(this,o,"m",v).call(this),this.syncFlowTheme(e(this,d,"f")))},v=function(){e(this,r,"f").setContent(j({projectId:this.projectId,flowId:this.emailUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),e(this,d,"f").onSuccess((()=>{e(this,r,"f").close(),this.actions.getMe()}))},p=function(){this.emailUserAttr.deleteFlowId&&(i(this,l,this.createModal({"data-id":"delete-email"}),"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,o,"m",m).bind(this),e(this,o,"m",m).call(this),this.syncFlowTheme(e(this,c,"f")))},m=function(){e(this,l,"f").setContent(j({projectId:this.projectId,flowId:this.emailUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),e(this,c,"f").onSuccess((()=>{e(this,l,"f").close(),this.actions.getMe()}))},w=function(){this.emailUserAttr=new R((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-attribute[data-id="email"]')}),{logger:this.logger}),this.emailUserAttr.onEditClick((()=>{var t;null===(t=e(this,r,"f"))||void 0===t||t.open()})),this.emailUserAttr.onDeleteClick((()=>{var t;null===(t=e(this,l,"f"))||void 0===t||t.open()}))},y})),dt=r((i=>{var s,o,r;return r=class extends(a(V,h,ot,g)(i)){constructor(){super(...arguments),s.add(this)}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",o).call(this)}))}},s=new WeakSet,o=function(){this.logout=new S((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-button[data-id="logout"]')}),{logger:this.logger}),this.logout.onClick((()=>t(this,void 0,void 0,(function*(){yield this.actions.logout(),this.dispatchEvent(new CustomEvent("logout"))}))))},r})),lt=r((s=>{var o,r,d,l,c,f,v,p,m,w,b,U;return U=class extends(a(rt,V,h,ot,u,g)(s)){constructor(){super(...arguments),o.add(this),r.set(this,void 0),d.set(this,void 0),l.set(this,void 0),c.set(this,void 0),b.set(this,n((t=>{this.nameUserAttr.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,o,"m",w).call(this),e(this,o,"m",f).call(this),e(this,o,"m",p).call(this),e(this,b,"f").call(this,K(this.state)),this.subscribe(e(this,b,"f").bind(this),K)}))}},r=new WeakMap,d=new WeakMap,l=new WeakMap,c=new WeakMap,b=new WeakMap,o=new WeakSet,f=function(){this.nameUserAttr.editFlowId&&(i(this,r,this.createModal({"data-id":"edit-name"}),"f"),i(this,d,new k((()=>{var t;return null===(t=e(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,r,"f").afterClose=e(this,o,"m",v).bind(this),e(this,o,"m",v).call(this),this.syncFlowTheme(e(this,d,"f")))},v=function(){e(this,r,"f").setContent(j({projectId:this.projectId,flowId:this.nameUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),e(this,d,"f").onSuccess((()=>{e(this,r,"f").close(),this.actions.getMe()}))},p=function(){this.nameUserAttr.deleteFlowId&&(i(this,l,this.createModal({"data-id":"delete-name"}),"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,o,"m",m).bind(this),e(this,o,"m",m).call(this),this.syncFlowTheme(e(this,c,"f")))},m=function(){e(this,l,"f").setContent(j({projectId:this.projectId,flowId:this.nameUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),e(this,c,"f").onSuccess((()=>{e(this,l,"f").close(),this.actions.getMe()}))},w=function(){this.nameUserAttr=new R((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-attribute[data-id="name"]')}),{logger:this.logger}),this.nameUserAttr.onEditClick((()=>{var t;null===(t=e(this,r,"f"))||void 0===t||t.open()})),this.nameUserAttr.onDeleteClick((()=>{var t;null===(t=e(this,l,"f"))||void 0===t||t.open()}))},U})),ht=r((s=>{var o,r,d,l,c,f,v,p;return p=class extends(a(rt,V,h,ot,u,g)(s)){constructor(){super(...arguments),o.add(this),r.set(this,void 0),d.set(this,void 0),v.set(this,n((t=>{this.passkeyUserAuthMethod.fulfilled=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,o,"m",f).call(this),e(this,o,"m",l).call(this),e(this,v,"f").call(this,tt(this.state)),this.subscribe(e(this,v,"f").bind(this),tt)}))}},r=new WeakMap,d=new WeakMap,v=new WeakMap,o=new WeakSet,l=function(){this.passkeyUserAuthMethod.flowId&&(i(this,r,this.createModal({"data-id":"passkey"}),"f"),i(this,d,new k((()=>{var t;return null===(t=e(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,r,"f").afterClose=e(this,o,"m",c).bind(this),e(this,o,"m",c).call(this),this.syncFlowTheme(e(this,d,"f")))},c=function(){e(this,r,"f").setContent(j({projectId:this.projectId,flowId:this.passkeyUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),e(this,d,"f").onSuccess((()=>{e(this,r,"f").close(),this.actions.getMe()}))},f=function(){this.passkeyUserAuthMethod=new W((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-auth-method[data-id="passkey"]')}),{logger:this.logger}),this.passkeyUserAuthMethod.onButtonClick((()=>{var t;null===(t=e(this,r,"f"))||void 0===t||t.open()}))},p})),ct=r((s=>{var o,r,n,d,l,c;return c=class extends(a(rt,V,h,ot,u,g)(s)){constructor(){super(...arguments),o.add(this),r.set(this,void 0),n.set(this,void 0)}initPasswordAuthMethod(){this.passwordUserAuthMethod=new W((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-auth-method[data-id="password"]')}),{logger:this.logger}),this.passwordUserAuthMethod.onButtonClick((()=>{var t;null===(t=e(this,r,"f"))||void 0===t||t.open()}))}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),this.initPasswordAuthMethod(),e(this,o,"m",d).call(this)}))}},r=new WeakMap,n=new WeakMap,o=new WeakSet,d=function(){this.passwordUserAuthMethod.flowId&&(i(this,r,this.createModal({"data-id":"password"}),"f"),i(this,n,new k((()=>{var t;return null===(t=e(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,r,"f").afterClose=e(this,o,"m",l).bind(this),e(this,o,"m",l).call(this),this.syncFlowTheme(e(this,n,"f")))},l=function(){e(this,r,"f").setContent(j({projectId:this.projectId,flowId:this.passwordUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),e(this,n,"f").onSuccess((()=>{e(this,r,"f").close()}))},c})),ut=r((s=>{var o,r,d,l,c,f,v,p,m,w,b,U,y;return y=class extends(a(rt,V,h,ot,u,g)(s)){constructor(){super(...arguments),o.add(this),r.set(this,void 0),d.set(this,void 0),l.set(this,void 0),c.set(this,void 0),b.set(this,n((t=>{this.phoneUserAttr.value=t}))),U.set(this,n((t=>{this.phoneUserAttr.badgeLabel=t?"":"Unverified"})))}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,o,"m",w).call(this),e(this,o,"m",f).call(this),e(this,o,"m",p).call(this),e(this,b,"f").call(this,Q(this.state)),e(this,U,"f").call(this,Z(this.state)),this.subscribe(e(this,b,"f").bind(this),Q),this.subscribe(e(this,U,"f").bind(this),Z)}))}},r=new WeakMap,d=new WeakMap,l=new WeakMap,c=new WeakMap,b=new WeakMap,U=new WeakMap,o=new WeakSet,f=function(){this.phoneUserAttr.editFlowId&&(i(this,r,this.createModal({"data-id":"edit-phone"}),"f"),i(this,d,new k((()=>{var t;return null===(t=e(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,r,"f").afterClose=e(this,o,"m",v).bind(this),e(this,o,"m",v).call(this),this.syncFlowTheme(e(this,d,"f")))},v=function(){e(this,r,"f").setContent(j({projectId:this.projectId,flowId:this.phoneUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),e(this,d,"f").onSuccess((()=>{e(this,r,"f").close(),this.actions.getMe()}))},p=function(){this.phoneUserAttr.deleteFlowId&&(i(this,l,this.createModal({"data-id":"delete-phone"}),"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,o,"m",m).bind(this),e(this,o,"m",m).call(this),this.syncFlowTheme(e(this,c,"f")))},m=function(){e(this,l,"f").setContent(j({projectId:this.projectId,flowId:this.phoneUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),e(this,c,"f").onSuccess((()=>{e(this,l,"f").close(),this.actions.getMe()}))},w=function(){this.phoneUserAttr=new R((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-attribute[data-id="phone"]')}),{logger:this.logger}),this.phoneUserAttr.onEditClick((()=>{var t;null===(t=e(this,r,"f"))||void 0===t||t.open()})),this.phoneUserAttr.onDeleteClick((()=>{var t;null===(t=e(this,l,"f"))||void 0===t||t.open()}))},y}));var ft;!function(t){t.TEXT="text",t.NUMBER="number",t.BOOLEAN="boolean",t.SINGLE_SELECT="singleSelect",t.ARRAY="array",t.DATE="date"}(ft||(ft={}));const vt=r((i=>{var s,o,r,d,l,c,f,v,p,m,w;return o=class extends(a(rt,V,h,ot,u,g)(i)){constructor(){super(...arguments),s.add(this),r.set(this,{}),d.set(this,{}),l.set(this,{}),c.set(this,{}),p.set(this,n((t=>{var i;const r=null===(i=this.shadowRoot)||void 0===i?void 0:i.querySelectorAll('descope-user-attribute[data-id^="customAttributes."]');Array.from(r).forEach((i=>{const r=i.getAttribute("data-id").replace("customAttributes.",""),a=i.getAttribute("data-type")||ft.TEXT,n=t[r],d=new R(i,{logger:this.logger});d.value=o.getFormattedValue(a,n),e(this,s,"m",m).call(this,i,r,d),e(this,s,"m",w).call(this,i,r,d)}))})))}static getFormattedValue(t,e){return t===ft.DATE&&e?new Date(e).toLocaleString():t===ft.BOOLEAN&&void 0!==e?e?"True":"False":(e||"").toString()}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,p,"f").call(this,it(this.state)),this.subscribe(e(this,p,"f").bind(this),it)}))}},r=new WeakMap,d=new WeakMap,l=new WeakMap,c=new WeakMap,p=new WeakMap,s=new WeakSet,f=function(t){var i,s;null===(i=e(this,r,"f")[t])||void 0===i||i.setContent(j({projectId:this.projectId,flowId:t,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),null===(s=e(this,d,"f")[t])||void 0===s||s.onSuccess((()=>{var i;null===(i=e(this,r,"f")[t])||void 0===i||i.close(),this.actions.getMe()}))},v=function(t){var i,s;null===(i=e(this,l,"f")[t])||void 0===i||i.setContent(j({projectId:this.projectId,flowId:t,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),null===(s=e(this,c,"f")[t])||void 0===s||s.onSuccess((()=>{var i;null===(i=e(this,l,"f")[t])||void 0===i||i.close(),this.actions.getMe()}))},m=function(t,i,o){const a=t.getAttribute("edit-flow-id");a&&(e(this,r,"f")[a]=this.createModal({"data-id":`edit-${i}`}),e(this,d,"f")[a]=new k((()=>{var t,i;return null===(i=null===(t=e(this,r,"f")[a])||void 0===t?void 0:t.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),e(this,r,"f")[a].afterClose=e(this,s,"m",f).bind(this,a),o.onEditClick((()=>{var t,i;null===(i=null===(t=e(this,r,"f"))||void 0===t?void 0:t[a])||void 0===i||i.open()})),e(this,s,"m",f).call(this,a),this.syncFlowTheme(e(this,d,"f")[a]))},w=function(t,i,o){const r=t.getAttribute("delete-flow-id");r&&(e(this,l,"f")[r]=this.createModal({"data-id":`delete-${i}`}),e(this,c,"f")[r]=new k((()=>{var t,i;return null===(i=null===(t=e(this,l,"f")[r])||void 0===t?void 0:t.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),e(this,l,"f")[r].afterClose=e(this,s,"m",v).bind(this,r),o.onDeleteClick((()=>{var t,i;null===(i=null===(t=e(this,l,"f"))||void 0===t?void 0:t[r])||void 0===i||i.open()})),e(this,s,"m",v).call(this,r),this.syncFlowTheme(e(this,c,"f")[r]))},o})),gt=r((s=>{var o,r,d,l,c,f,v,p;return p=class extends(a(rt,V,h,ot,u,g)(s)){constructor(){super(...arguments),o.add(this),r.set(this,void 0),d.set(this,void 0),v.set(this,n((t=>{this.totpUserAuthMethod.fulfilled=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,o,"m",f).call(this),e(this,o,"m",l).call(this),e(this,v,"f").call(this,et(this.state)),this.subscribe(e(this,v,"f").bind(this),et)}))}},r=new WeakMap,d=new WeakMap,v=new WeakMap,o=new WeakSet,l=function(){this.totpUserAuthMethod.flowId&&(i(this,r,this.createModal({"data-id":"totp"}),"f"),i(this,d,new k((()=>{var t;return null===(t=e(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,r,"f").afterClose=e(this,o,"m",c).bind(this),e(this,o,"m",c).call(this),this.syncFlowTheme(e(this,d,"f")))},c=function(){e(this,r,"f").setContent(j({projectId:this.projectId,flowId:this.totpUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),e(this,d,"f").onSuccess((()=>{e(this,r,"f").close(),this.actions.getMe()}))},f=function(){this.totpUserAuthMethod=new W((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-auth-method[data-id="totp"]')}),{logger:this.logger}),this.totpUserAuthMethod.onButtonClick((()=>{var t;null===(t=e(this,r,"f"))||void 0===t||t.open()}))},p})),pt=r((e=>class extends(a(y,U,G,vt,nt,at,lt,ut,ht,ct,ct,gt,dt)(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)}))}})),mt=a((e=>class extends(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);(customElements.get("descope-wc")||(yield import("@descope/web-component").then((t=>t.default)))).sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"user-profile-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.4.0"}}}))}}))(HTMLElement);customElements.define("descope-user-profile-widget",mt);export{mt as default}; | ||
import{__awaiter as t,__classPrivateFieldGet as e,__classPrivateFieldSet as i}from"tslib";import{createTemplate as s,kebabCase as o,createSingletonMixin as r,compose as a,withMemCache as n}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 v,modalMixin as g,staticResourcesMixin as p,createValidateAttributesMixin as m,descopeUiMixin as w,initElementMixin as b,themeMixin as U,debuggerMixin as y}from"@descope/sdk-mixins";import{FlowDriver as k,AvatarDriver as C,UserAttributeDriver as R,ButtonDriver as S,UserAuthMethodDriver as W}from"@descope/sdk-component-drivers";import{createAsyncThunk as M}from"@reduxjs/toolkit";import"@descope/core-js-sdk";import I from"@descope/web-js-sdk";import{createSelector as A}from"reselect";import"@descope/web-component";const j=(t={})=>{const e=s("<descope-wc></descope-wc>");return Object.entries(t).forEach((([t,i])=>{e.content.querySelector("descope-wc").setAttribute(o(t),i)})),e};function N(t){return new URLSearchParams(window.location.search).get(t)}const x=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=M("users/me",((t,{extra:{api:e}})=>e.user.me())),F=x(T)({onFulfilled:(t,e)=>{t.me.data=e.payload}},(E=t=>t.me,{onFulfilled:t=>{E(t).loading=!1},onPending:t=>{E(t).loading=!0,E(t).error=null},onRejected:(t,e)=>{E(t).loading=!1,E(t).error=e.error}}));var E;const O={action:T,reducer:F},q=M("users/logout",((t,{extra:{api:e}})=>e.user.logout())),P={action:q,reducer:x(q)({})},L={me:{loading:!1,error:null,data:{}}},D={me:"/v1/auth/me"},$=()=>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})}))})),B=({httpClient:e,mock:i})=>({me:()=>t(void 0,void 0,void 0,(function*(){if(i)return $();const s=yield e.get(D.me);return yield(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)})))(s),s.json()}))}),H=r((s=>{var o,r,n,f;const v=a(d,l,h,c,u)(s);return f=class extends v{constructor(){super(...arguments),o.add(this),r.set(this,void 0)}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get api(){return e(this,r,"f")||e(this,o,"m",n).call(this),e(this,r,"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"],(()=>{e(this,r,"f")&&e(this,o,"m",n).call(this)}))}))}},r=new WeakMap,o=new WeakSet,n=function(){this.logger.debug("creating an sdk instance"),i(this,r,((e,i,s)=>{const o=I(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"user-profile-widget","x-descope-widget-id":s,"x-descope-widget-version":"0.4.1"}}));return{user:Object.assign(Object.assign({},B({httpClient:o.httpClient,mock:i})),{logout:i?()=>t(void 0,void 0,void 0,(function*(){})):o.logout})}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},"true"===this.mock,this.widgetId),"f")},f})),V=r((t=>{const e=a(f({name:"widget",initialState:L,reducers:{},extraReducers:t=>{O.reducer(t),P.reducer(t)},asyncActions:{getMe:O.action,logout:P.action}}),v,h,H)(t);return class extends e{constructor(...t){super(...t),this.state=L,this.subscribe((t=>{this.logger.debug("State update:",t),this.state=t}))}}})),X="widget-flow",G=r((i=>{var s,o,r;return r=class extends(a(v,g,V,u,h)(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 r=N(X);r&&(!function(t){if(window.history.replaceState&&N(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())}}(X),e(this,s,"m",o).call(this,r))}))}},s=new WeakSet,o=function(t){const e=this.createModal({"data-id":"redirect-flow"});e.setContent(j({projectId:this.projectId,flowId:t,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName}));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()})),e.afterClose=()=>{e.remove()},e.open()},r})),J=t=>t.me.data,Y=A(J,(t=>t.picture)),_=A(J,(t=>t.email)),z=A(J,(t=>t.verifiedEmail)),K=A(J,(t=>t.name)),Q=A(J,(t=>t.phone)),Z=A(J,(t=>t.verifiedPhone)),tt=A(J,(t=>t.webauthn));A(J,(t=>t.password));const et=A(J,(t=>t.TOTP)),it=A(J,(t=>t.customAttributes)),st=r((e=>{const i=a(p,m({"widget-id":m.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(`user-profile-widget/${this.widgetId}/${e}`,"text")).body}))}}})),ot=r((i=>{var o,r,n;return n=class extends(a(h,v,w,b,st,V)(i)){constructor(){super(...arguments),o.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),yield Promise.all([this.actions.getMe(),e(this,o,"m",r).call(this)]),this.onWidgetRootReady()}))}},o=new WeakSet,r=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))}))},n})),rt=r((t=>class extends(a(U,l)(t)){syncFlowTheme(t){t.theme=this.theme,this.observeAttributes(["theme"],(()=>{t.theme=this.theme}))}})),at=r((s=>{var o,r,d,l,c,f,v,p,m;return m=class extends(a(rt,U,V,h,u,ot,g)(s)){constructor(){super(...arguments),o.add(this),r.set(this,void 0),d.set(this,void 0),v.set(this,n((t=>{this.avatar.image=t}))),p.set(this,n((t=>{this.avatar.displayName=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,o,"m",f).call(this),e(this,o,"m",l).call(this),e(this,v,"f").call(this,Y(this.state)),e(this,p,"f").call(this,K(this.state)),this.subscribe(e(this,v,"f").bind(this),Y),this.subscribe(e(this,p,"f").bind(this),K)}))}},r=new WeakMap,d=new WeakMap,v=new WeakMap,p=new WeakMap,o=new WeakSet,l=function(){this.avatar.flowId&&(i(this,r,this.createModal({"data-id":"update-pic"}),"f"),i(this,d,new k((()=>{var t;return null===(t=e(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,r,"f").afterClose=e(this,o,"m",c).bind(this),e(this,o,"m",c).call(this),this.syncFlowTheme(e(this,d,"f")))},c=function(){e(this,r,"f").setContent(j({projectId:this.projectId,flowId:this.avatar.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),e(this,d,"f").onSuccess((()=>{e(this,r,"f").close(),this.actions.getMe()}))},f=function(){this.avatar=new C((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector("descope-avatar")}),{logger:this.logger}),this.avatar.onClick((()=>{var t;null===(t=e(this,r,"f"))||void 0===t||t.open()}))},m})),nt=r((s=>{var o,r,d,l,c,f,v,p,m,w,b,U,y;return y=class extends(a(rt,V,h,ot,u,g)(s)){constructor(){super(...arguments),o.add(this),r.set(this,void 0),d.set(this,void 0),l.set(this,void 0),c.set(this,void 0),b.set(this,n((t=>{this.emailUserAttr.value=t}))),U.set(this,n((t=>{this.emailUserAttr.badgeLabel=t?"":"Unverified"})))}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,o,"m",w).call(this),e(this,o,"m",f).call(this),e(this,o,"m",p).call(this),e(this,b,"f").call(this,_(this.state)),e(this,U,"f").call(this,z(this.state)),this.subscribe(e(this,b,"f").bind(this),_),this.subscribe(e(this,U,"f").bind(this),z)}))}},r=new WeakMap,d=new WeakMap,l=new WeakMap,c=new WeakMap,b=new WeakMap,U=new WeakMap,o=new WeakSet,f=function(){this.emailUserAttr.editFlowId&&(i(this,r,this.createModal({"data-id":"edit-email"}),"f"),i(this,d,new k((()=>{var t;return null===(t=e(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,r,"f").afterClose=e(this,o,"m",v).bind(this),e(this,o,"m",v).call(this),this.syncFlowTheme(e(this,d,"f")))},v=function(){e(this,r,"f").setContent(j({projectId:this.projectId,flowId:this.emailUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),e(this,d,"f").onSuccess((()=>{e(this,r,"f").close(),this.actions.getMe()}))},p=function(){this.emailUserAttr.deleteFlowId&&(i(this,l,this.createModal({"data-id":"delete-email"}),"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,o,"m",m).bind(this),e(this,o,"m",m).call(this),this.syncFlowTheme(e(this,c,"f")))},m=function(){e(this,l,"f").setContent(j({projectId:this.projectId,flowId:this.emailUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),e(this,c,"f").onSuccess((()=>{e(this,l,"f").close(),this.actions.getMe()}))},w=function(){this.emailUserAttr=new R((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-attribute[data-id="email"]')}),{logger:this.logger}),this.emailUserAttr.onEditClick((()=>{var t;null===(t=e(this,r,"f"))||void 0===t||t.open()})),this.emailUserAttr.onDeleteClick((()=>{var t;null===(t=e(this,l,"f"))||void 0===t||t.open()}))},y})),dt=r((i=>{var s,o,r;return r=class extends(a(V,h,ot,g)(i)){constructor(){super(...arguments),s.add(this)}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",o).call(this)}))}},s=new WeakSet,o=function(){this.logout=new S((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-button[data-id="logout"]')}),{logger:this.logger}),this.logout.onClick((()=>t(this,void 0,void 0,(function*(){yield this.actions.logout(),this.dispatchEvent(new CustomEvent("logout"))}))))},r})),lt=r((s=>{var o,r,d,l,c,f,v,p,m,w,b,U;return U=class extends(a(rt,V,h,ot,u,g)(s)){constructor(){super(...arguments),o.add(this),r.set(this,void 0),d.set(this,void 0),l.set(this,void 0),c.set(this,void 0),b.set(this,n((t=>{this.nameUserAttr.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,o,"m",w).call(this),e(this,o,"m",f).call(this),e(this,o,"m",p).call(this),e(this,b,"f").call(this,K(this.state)),this.subscribe(e(this,b,"f").bind(this),K)}))}},r=new WeakMap,d=new WeakMap,l=new WeakMap,c=new WeakMap,b=new WeakMap,o=new WeakSet,f=function(){this.nameUserAttr.editFlowId&&(i(this,r,this.createModal({"data-id":"edit-name"}),"f"),i(this,d,new k((()=>{var t;return null===(t=e(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,r,"f").afterClose=e(this,o,"m",v).bind(this),e(this,o,"m",v).call(this),this.syncFlowTheme(e(this,d,"f")))},v=function(){e(this,r,"f").setContent(j({projectId:this.projectId,flowId:this.nameUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),e(this,d,"f").onSuccess((()=>{e(this,r,"f").close(),this.actions.getMe()}))},p=function(){this.nameUserAttr.deleteFlowId&&(i(this,l,this.createModal({"data-id":"delete-name"}),"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,o,"m",m).bind(this),e(this,o,"m",m).call(this),this.syncFlowTheme(e(this,c,"f")))},m=function(){e(this,l,"f").setContent(j({projectId:this.projectId,flowId:this.nameUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),e(this,c,"f").onSuccess((()=>{e(this,l,"f").close(),this.actions.getMe()}))},w=function(){this.nameUserAttr=new R((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-attribute[data-id="name"]')}),{logger:this.logger}),this.nameUserAttr.onEditClick((()=>{var t;null===(t=e(this,r,"f"))||void 0===t||t.open()})),this.nameUserAttr.onDeleteClick((()=>{var t;null===(t=e(this,l,"f"))||void 0===t||t.open()}))},U})),ht=r((s=>{var o,r,d,l,c,f,v,p;return p=class extends(a(rt,V,h,ot,u,g)(s)){constructor(){super(...arguments),o.add(this),r.set(this,void 0),d.set(this,void 0),v.set(this,n((t=>{this.passkeyUserAuthMethod.fulfilled=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,o,"m",f).call(this),e(this,o,"m",l).call(this),e(this,v,"f").call(this,tt(this.state)),this.subscribe(e(this,v,"f").bind(this),tt)}))}},r=new WeakMap,d=new WeakMap,v=new WeakMap,o=new WeakSet,l=function(){this.passkeyUserAuthMethod.flowId&&(i(this,r,this.createModal({"data-id":"passkey"}),"f"),i(this,d,new k((()=>{var t;return null===(t=e(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,r,"f").afterClose=e(this,o,"m",c).bind(this),e(this,o,"m",c).call(this),this.syncFlowTheme(e(this,d,"f")))},c=function(){e(this,r,"f").setContent(j({projectId:this.projectId,flowId:this.passkeyUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),e(this,d,"f").onSuccess((()=>{e(this,r,"f").close(),this.actions.getMe()}))},f=function(){this.passkeyUserAuthMethod=new W((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-auth-method[data-id="passkey"]')}),{logger:this.logger}),this.passkeyUserAuthMethod.onButtonClick((()=>{var t;null===(t=e(this,r,"f"))||void 0===t||t.open()}))},p})),ct=r((s=>{var o,r,n,d,l,c;return c=class extends(a(rt,V,h,ot,u,g)(s)){constructor(){super(...arguments),o.add(this),r.set(this,void 0),n.set(this,void 0)}initPasswordAuthMethod(){this.passwordUserAuthMethod=new W((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-auth-method[data-id="password"]')}),{logger:this.logger}),this.passwordUserAuthMethod.onButtonClick((()=>{var t;null===(t=e(this,r,"f"))||void 0===t||t.open()}))}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),this.initPasswordAuthMethod(),e(this,o,"m",d).call(this)}))}},r=new WeakMap,n=new WeakMap,o=new WeakSet,d=function(){this.passwordUserAuthMethod.flowId&&(i(this,r,this.createModal({"data-id":"password"}),"f"),i(this,n,new k((()=>{var t;return null===(t=e(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,r,"f").afterClose=e(this,o,"m",l).bind(this),e(this,o,"m",l).call(this),this.syncFlowTheme(e(this,n,"f")))},l=function(){e(this,r,"f").setContent(j({projectId:this.projectId,flowId:this.passwordUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),e(this,n,"f").onSuccess((()=>{e(this,r,"f").close()}))},c})),ut=r((s=>{var o,r,d,l,c,f,v,p,m,w,b,U,y;return y=class extends(a(rt,V,h,ot,u,g)(s)){constructor(){super(...arguments),o.add(this),r.set(this,void 0),d.set(this,void 0),l.set(this,void 0),c.set(this,void 0),b.set(this,n((t=>{this.phoneUserAttr.value=t}))),U.set(this,n((t=>{this.phoneUserAttr.badgeLabel=t?"":"Unverified"})))}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,o,"m",w).call(this),e(this,o,"m",f).call(this),e(this,o,"m",p).call(this),e(this,b,"f").call(this,Q(this.state)),e(this,U,"f").call(this,Z(this.state)),this.subscribe(e(this,b,"f").bind(this),Q),this.subscribe(e(this,U,"f").bind(this),Z)}))}},r=new WeakMap,d=new WeakMap,l=new WeakMap,c=new WeakMap,b=new WeakMap,U=new WeakMap,o=new WeakSet,f=function(){this.phoneUserAttr.editFlowId&&(i(this,r,this.createModal({"data-id":"edit-phone"}),"f"),i(this,d,new k((()=>{var t;return null===(t=e(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,r,"f").afterClose=e(this,o,"m",v).bind(this),e(this,o,"m",v).call(this),this.syncFlowTheme(e(this,d,"f")))},v=function(){e(this,r,"f").setContent(j({projectId:this.projectId,flowId:this.phoneUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),e(this,d,"f").onSuccess((()=>{e(this,r,"f").close(),this.actions.getMe()}))},p=function(){this.phoneUserAttr.deleteFlowId&&(i(this,l,this.createModal({"data-id":"delete-phone"}),"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,o,"m",m).bind(this),e(this,o,"m",m).call(this),this.syncFlowTheme(e(this,c,"f")))},m=function(){e(this,l,"f").setContent(j({projectId:this.projectId,flowId:this.phoneUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),e(this,c,"f").onSuccess((()=>{e(this,l,"f").close(),this.actions.getMe()}))},w=function(){this.phoneUserAttr=new R((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-attribute[data-id="phone"]')}),{logger:this.logger}),this.phoneUserAttr.onEditClick((()=>{var t;null===(t=e(this,r,"f"))||void 0===t||t.open()})),this.phoneUserAttr.onDeleteClick((()=>{var t;null===(t=e(this,l,"f"))||void 0===t||t.open()}))},y}));var ft;!function(t){t.TEXT="text",t.NUMBER="number",t.BOOLEAN="boolean",t.SINGLE_SELECT="singleSelect",t.ARRAY="array",t.DATE="date"}(ft||(ft={}));const vt=r((i=>{var s,o,r,d,l,c,f,v,p,m,w;return o=class extends(a(rt,V,h,ot,u,g)(i)){constructor(){super(...arguments),s.add(this),r.set(this,{}),d.set(this,{}),l.set(this,{}),c.set(this,{}),p.set(this,n((t=>{var i;const r=null===(i=this.shadowRoot)||void 0===i?void 0:i.querySelectorAll('descope-user-attribute[data-id^="customAttributes."]');Array.from(r).forEach((i=>{const r=i.getAttribute("data-id").replace("customAttributes.",""),a=i.getAttribute("data-type")||ft.TEXT,n=t[r],d=new R(i,{logger:this.logger});d.value=o.getFormattedValue(a,n),e(this,s,"m",m).call(this,i,r,d),e(this,s,"m",w).call(this,i,r,d)}))})))}static getFormattedValue(t,e){return t===ft.DATE&&e?new Date(e).toLocaleString():t===ft.BOOLEAN&&void 0!==e?e?"True":"False":(e||"").toString()}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,p,"f").call(this,it(this.state)),this.subscribe(e(this,p,"f").bind(this),it)}))}},r=new WeakMap,d=new WeakMap,l=new WeakMap,c=new WeakMap,p=new WeakMap,s=new WeakSet,f=function(t){var i,s;null===(i=e(this,r,"f")[t])||void 0===i||i.setContent(j({projectId:this.projectId,flowId:t,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),null===(s=e(this,d,"f")[t])||void 0===s||s.onSuccess((()=>{var i;null===(i=e(this,r,"f")[t])||void 0===i||i.close(),this.actions.getMe()}))},v=function(t){var i,s;null===(i=e(this,l,"f")[t])||void 0===i||i.setContent(j({projectId:this.projectId,flowId:t,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),null===(s=e(this,c,"f")[t])||void 0===s||s.onSuccess((()=>{var i;null===(i=e(this,l,"f")[t])||void 0===i||i.close(),this.actions.getMe()}))},m=function(t,i,o){const a=t.getAttribute("edit-flow-id");a&&(e(this,r,"f")[a]=this.createModal({"data-id":`edit-${i}`}),e(this,d,"f")[a]=new k((()=>{var t,i;return null===(i=null===(t=e(this,r,"f")[a])||void 0===t?void 0:t.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),e(this,r,"f")[a].afterClose=e(this,s,"m",f).bind(this,a),o.onEditClick((()=>{var t,i;null===(i=null===(t=e(this,r,"f"))||void 0===t?void 0:t[a])||void 0===i||i.open()})),e(this,s,"m",f).call(this,a),this.syncFlowTheme(e(this,d,"f")[a]))},w=function(t,i,o){const r=t.getAttribute("delete-flow-id");r&&(e(this,l,"f")[r]=this.createModal({"data-id":`delete-${i}`}),e(this,c,"f")[r]=new k((()=>{var t,i;return null===(i=null===(t=e(this,l,"f")[r])||void 0===t?void 0:t.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),e(this,l,"f")[r].afterClose=e(this,s,"m",v).bind(this,r),o.onDeleteClick((()=>{var t,i;null===(i=null===(t=e(this,l,"f"))||void 0===t?void 0:t[r])||void 0===i||i.open()})),e(this,s,"m",v).call(this,r),this.syncFlowTheme(e(this,c,"f")[r]))},o})),gt=r((s=>{var o,r,d,l,c,f,v,p;return p=class extends(a(rt,V,h,ot,u,g)(s)){constructor(){super(...arguments),o.add(this),r.set(this,void 0),d.set(this,void 0),v.set(this,n((t=>{this.totpUserAuthMethod.fulfilled=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,o,"m",f).call(this),e(this,o,"m",l).call(this),e(this,v,"f").call(this,et(this.state)),this.subscribe(e(this,v,"f").bind(this),et)}))}},r=new WeakMap,d=new WeakMap,v=new WeakMap,o=new WeakSet,l=function(){this.totpUserAuthMethod.flowId&&(i(this,r,this.createModal({"data-id":"totp"}),"f"),i(this,d,new k((()=>{var t;return null===(t=e(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,r,"f").afterClose=e(this,o,"m",c).bind(this),e(this,o,"m",c).call(this),this.syncFlowTheme(e(this,d,"f")))},c=function(){e(this,r,"f").setContent(j({projectId:this.projectId,flowId:this.totpUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName})),e(this,d,"f").onSuccess((()=>{e(this,r,"f").close(),this.actions.getMe()}))},f=function(){this.totpUserAuthMethod=new W((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-auth-method[data-id="totp"]')}),{logger:this.logger}),this.totpUserAuthMethod.onButtonClick((()=>{var t;null===(t=e(this,r,"f"))||void 0===t||t.open()}))},p})),pt=r((e=>class extends(a(y,U,G,vt,nt,at,lt,ut,ht,ct,ct,gt,dt)(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)}))}})),mt=a((e=>class extends(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);(customElements.get("descope-wc")||(yield import("@descope/web-component").then((t=>t.default)))).sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"user-profile-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.4.1"}}}))}}))(HTMLElement);customElements.define("descope-user-profile-widget",mt);export{mt as default}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@descope/user-profile-widget", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"author": "Descope Team <info@descope.com>", | ||
@@ -79,7 +79,7 @@ "homepage": "https://github.com/descope/descope-js", | ||
"immer": "^10.0.3", | ||
"@descope/web-component": "3.39.0", | ||
"@descope/web-js-sdk": "1.27.0", | ||
"@descope/web-component": "3.39.1", | ||
"@descope/sdk-helpers": "0.3.0", | ||
"@descope/sdk-component-drivers": "0.2.52", | ||
"@descope/sdk-mixins": "0.11.2", | ||
"@descope/web-js-sdk": "1.26.2" | ||
"@descope/sdk-component-drivers": "0.2.52" | ||
}, | ||
@@ -86,0 +86,0 @@ "optionalDependencies": { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
2395722
0.52%+ Added
+ Added
- Removed
- Removed
Updated