@digital-realty/ui-user-management 16.0.4 → 16.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import{__decorate as r}from"tslib";import{css as $,LitElement as I,html as c,svg as je,nothing as y}from"lit";import{customElement as A,property as d,state as m,query as D,queryAsync as qi}from"lit/decorators.js";import{MobxLitElement as Ue}from"@adobe/lit-mobx";import{elementTheme as ge,baseTheme as $e}from"@digital-realty/theme";import Qt from"toastify-js";import{ApplicationInsights as Hi}from"@microsoft/applicationinsights-web";import"@digital-realty/ix-progress/ix-progress.js";import"@digital-realty/ix-icon-button/ix-icon-button.js";import{makeAutoObservable as zi,toJS as Ne,observable as Yt,makeObservable as Vi}from"mobx";import{gql as Fe,GraphQLClient as ji}from"graphql-request";import{User as Gi,UserManager as Ji}from"oidc-client-ts";import Xt from"i18next";import{initLitI18n as Ki}from"lit-i18n";import{Router as ye}from"@vaadin/router";import"@digital-realty/ix-button/ix-button.js";import"@digital-realty/ix-dialog/ix-dialog.js";import"@digital-realty/ix-textbox/ix-textbox.js";import"@digital-realty/ix-phone-input/ix-phone-input.js";import{parsePhoneNumberWithError as eo,AsYouType as Zi,isPossiblePhoneNumber as Wi}from"libphonenumber-js";import{classMap as Qi}from"lit/directives/class-map.js";import Yi from"validator";import{keyed as Xi}from"lit/directives/keyed.js";import{ref as en}from"lit/directives/ref.js";import"@digital-realty/ix-tree/ix-tree.js";import"@digital-realty/ix-file-uploader/ix-file-uploader.js";import"@digital-realty/ix-select/ix-select.js";import"@digital-realty/ix-select/ix-select-option.js";import"@digital-realty/ix-multi-select/ix-multi-select.js";import{IconTypeMap as tn,updateNodeCheckedStatus as be,flattenTree as on,findChildNodeById as Ge,collapseAllNodes as Je,calculateCheckedEndNodesCount as to,getCheckedAndIndeterminateNodesOnly as oo,buildTreeFromFlatArray as io,updateChildrenCount as no}from"@digital-realty/ix-generic-tree";import{repeat as mt}from"lit/directives/repeat.js";import"@digital-realty/ix-tabs/ix-tabs.js";import"@digital-realty/ix-tabs/ix-primary-tab.js";import"@digital-realty/ix-icon/ix-icon.js";import"@digital-realty/ix-card/ix-card.js";import ao from"lodash.debounce";import"@digital-realty/ix-generic-tree/ix-generic-tree.js";import"@digital-realty/ix-accordion/ix-accordion.js";import"@digital-realty/ix-divider/ix-divider.js";import"@digital-realty/ix-phone-number/ix-phone-number.js";import"@material/web/icon/icon.js";const nn="http://localhost".replace(/\/+$/,"");class Y{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:nn}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||ro}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const an=new Y;class j{constructor(t=an){this.configuration=t,this.fetchApi=async(o,i)=>{let n={url:o,init:i};for(const s of this.middleware)s.pre&&(n=await s.pre({fetch:this.fetchApi,...n})||n);let a;try{a=await(this.configuration.fetchApi||fetch)(n.url,n.init)}catch(s){for(const l of this.middleware)l.onError&&(a=await l.onError({fetch:this.fetchApi,url:n.url,init:n.init,error:s,response:a?a.clone():void 0})||a);if(a===void 0)throw s instanceof Error?new ln(s,"The request failed and the interceptors did not return an alternative response"):s}for(const s of this.middleware)s.post&&(a=await s.post({fetch:this.fetchApi,url:n.url,init:n.init,response:a.clone()})||a);return a},this.middleware=t.middleware}withMiddleware(...t){const o=this.clone();return o.middleware=o.middleware.concat(...t),o}withPreMiddleware(...t){const o=t.map(i=>({pre:i}));return this.withMiddleware(...o)}withPostMiddleware(...t){const o=t.map(i=>({post:i}));return this.withMiddleware(...o)}isJsonMime(t){return t?j.jsonRegex.test(t):!1}async request(t,o){const{url:i,init:n}=await this.createFetchParams(t,o),a=await this.fetchApi(i,n);if(a&&a.status>=200&&a.status<300)return a;throw new so(a,"Response returned an error code")}async createFetchParams(t,o){let i=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(i+="?"+this.configuration.queryParamsStringify(t.query));const n=Object.assign({},this.configuration.headers,t.headers);Object.keys(n).forEach(u=>n[u]===void 0?delete n[u]:{});const a=typeof o=="function"?o:async()=>o,s={method:t.method,headers:n,body:t.body,credentials:this.configuration.credentials},l={...s,...await a({init:s,context:t})};let p;rn(l.body)||l.body instanceof URLSearchParams||sn(l.body)?p=l.body:this.isJsonMime(n["Content-Type"])?p=JSON.stringify(l.body):p=l.body;const h={...l,body:p};return{url:i,init:h}}clone(){const t=this.constructor,o=new t(this.configuration);return o.middleware=this.middleware.slice(),o}}j.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function sn(e){return typeof Blob<"u"&&e instanceof Blob}function rn(e){return typeof FormData<"u"&&e instanceof FormData}class so extends Error{constructor(t,o){super(o),this.response=t,this.name="ResponseError"}}class ln extends Error{constructor(t,o){super(o),this.cause=t,this.name="FetchError"}}class E extends Error{constructor(t,o){super(o),this.field=t,this.name="RequiredError"}}function f(e,t){return e[t]!=null}function ro(e,t=""){return Object.keys(e).map(o=>lo(o,e[o],t)).filter(o=>o.length>0).join("&")}function lo(e,t,o=""){const i=o+(o.length?`[${e}]`:e);if(t instanceof Array){const n=t.map(a=>encodeURIComponent(String(a))).join(`&${encodeURIComponent(i)}=`);return`${encodeURIComponent(i)}=${n}`}if(t instanceof Set){const n=Array.from(t);return lo(e,n,o)}return t instanceof Date?`${encodeURIComponent(i)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?ro(t,i):`${encodeURIComponent(i)}=${encodeURIComponent(String(t))}`}function cn(e){for(const t of e)if(t.contentType==="multipart/form-data")return!0;return!1}class R{constructor(t,o=i=>i){this.raw=t,this.transformer=o}async value(){return this.transformer(await this.raw.json())}}class xe{constructor(t){this.raw=t}async value(){}}class co{constructor(t){this.raw=t}async value(){return await this.raw.blob()}}const S={AccountSwitched:"account-switched",AuthenticationComplete:"authentication",CancelCreateUser:"cancel-create-user",ChangeUserAccount:"change-user-account",CloseDrawer:"close-drawer",CheckToggle:"check-toggle",CloseDialog:"close-dialog",CreateNewContact:"create-new-contact",CreateRole:"create-role",CreateUser:"create-user",AddRole:"add-role",ChangeAccountAssociation:"change-account",UpdateChanges:"update-changes",ReloadAccount:"reload-account",CreateUserClicked:"create-user-clicked",DrawerClose:"drawer-close",DuplicateRole:"duplicate-role",ErrorRaised:"um:error-raised",EvacAssistanceRequired:"evac-assistance-required",GridViewUpdate:"grid-view-update",NextButtonToggle:"next-button-toggle",NextStep:"next-step",OpenDialog:"open-dialog",PreviousStep:"previous-step",RefreshTable:"refresh-table",ResetSuccess:"reset-success",RouteChanged:"vaadin-router-location-changed",SetStep:"set-step",ToggleDialog:"toggle-dialog",ToggleDraft:"toggle-draft",ToggleDrawer:"toggle-drawer",ToggleNavBar:"toggle-menu",UpdateAccounts:"update-accounts",UpdateContact:"update-contact",UpdateDFA:"update-dfa",UpdateForm:"update-form",UserFlagUpdate:"user-flag-update",EditProfile:"edit-profile",OpenModificationDetails:"open-modification-details"},te=new Map,dn=e=>{if(e){const t=te.get(e);t&&(t.forEach(o=>{o&&typeof o.hideToast=="function"&&o.hideToast()}),te.delete(e))}else te.forEach(t=>{t.forEach(o=>{o&&typeof o.hideToast=="function"&&o.hideToast()})}),te.clear()},uo=(e,t,o,i,n,a)=>{const s=document.createElement("div");s.style.position="relative",s.style.padding="0",s.style.width="100%";const l=document.createElement("span");l.textContent=e,l.style.display="block",l.style.paddingRight=n?"30px":"0",s.appendChild(l);const p=Qt({node:s,duration:n?-1:t,newWindow:!1,close:n!=null?n:!1,gravity:"bottom",position:o!=null?o:"right",stopOnFocus:!0,className:"success-toast",style:{background:"rgb(76, 175, 80)",minWidth:i!=null?i:"fit-content",padding:"16px 20px"}});p.showToast(),n&&setTimeout(()=>{const h=document.querySelector(".toastify.on .toast-close:not([data-positioned])");h&&(h.setAttribute("data-positioned","true"),h.style.position="absolute",h.style.top="8px",h.style.right="8px",h.style.margin="0",h.style.padding="0",h.style.float="none",h.style.width="20px",h.style.height="20px",h.style.lineHeight="20px",h.style.textAlign="center")},10),a&&(te.has(a)||te.set(a,[]),te.get(a).push(p))},ho=(e,t,o,i,n,a,s)=>{const l=document.createElement("div");l.style.position="relative",l.style.padding="0",l.style.width="100%";const p=document.createElement("span");if(p.style.display="block",p.style.paddingRight=i?"30px":"0",a&&s){const[u,...b]=e.split(a);p.textContent=u;const F=document.createElement("span");if(F.textContent=a,F.style.textDecoration="underline",F.style.cursor="pointer",F.style.fontWeight="bold",F.addEventListener("click",s),p.appendChild(F),b.length>0&&b[0]){const se=document.createTextNode(b[0]);p.appendChild(se)}}else p.textContent=e;l.appendChild(p);const h=Qt({node:l,duration:i?-1:t,newWindow:!1,close:i!=null?i:!1,gravity:"bottom",position:o!=null?o:"right",stopOnFocus:!0,style:{background:"rgb(219, 0, 40)",minWidth:"344px",maxWidth:"750px",padding:"16px 20px"}});h.showToast(),i&&setTimeout(()=>{const u=document.querySelector(".toastify.on .toast-close:not([data-positioned])");u&&(u.setAttribute("data-positioned","true"),u.style.position="absolute",u.style.top="8px",u.style.right="8px",u.style.margin="0",u.style.padding="0",u.style.float="none",u.style.width="20px",u.style.height="20px",u.style.lineHeight="20px",u.style.textAlign="center")},10),n&&(te.has(n)||te.set(n,[]),te.get(n).push(h))};function N(){var e;const t=(e=window.gpConfig)===null||e===void 0?void 0:e["ui-user-management"];if(!t)throw new Error("ui-user-management config not loaded. Ensure config.json is fetched before app bootstrap.");return t}class un{constructor(){this.fetchAppInsightsFromWindow=()=>window._appInsights,this.tryFetchShellAppInsights=()=>{const o=this.fetchAppInsightsFromWindow();if(!o){const i=this.buildStandaloneAppInsights();return i.trackException({severityLevel:4,exception:new Error("Application Insights instance could not be located on window. Falling back to standalone instance.")}),i}return o},this.buildStandaloneAppInsights=()=>{const o=new Hi({config:{connectionString:N().UserManagement.UI.AppInsights.ConnectionString,isCookieUseDisabled:!0}});return o.loadAppInsights(),this.fetchAppInsightsFromWindow()&&o.trackException({severityLevel:4,exception:new Error("Application Insights instance already exists on window, but we're registering it again in standalone. This will cause issues with telemetry.")}),o};const t=N();this.appInsights=t.UserManagement.UI.AppInsights.ShouldUseGlobal?this.tryFetchShellAppInsights():this.buildStandaloneAppInsights()}}const hn=new un;var pn=hn.appInsights;class Wt{constructor(){this.displayErrorBinding=this.displayError.bind(this),this.setupErrorHandler=()=>{document.addEventListener(S.ErrorRaised,this.displayErrorBinding)},this.destroyErrorHandler=()=>{document.removeEventListener(S.ErrorRaised,this.displayErrorBinding)},this.handleError=async(t,o)=>{let i=t;i.userMessage=o,t instanceof so&&await t.response.json().then(n=>{var a;i.message=n.detail,n.status===403&&(i.userMessage=(a=n.detail)!==null&&a!==void 0?a:"You don't have permission to perform this action.")}).catch(()=>{i.message="Failed to get the error details from response."}),t instanceof PromiseRejectionEvent&&(i=await t.reason),pn.trackException({exception:i}),this.displayError(i),console.error(i)},this.setupErrorHandler()}static getInstance(){return this.instance||(this.instance=new Wt),this.instance}displayError(t){let o="";typeof t=="string"?o=t:"userMessage"in t&&t.userMessage!==void 0?o=t.userMessage:"message"in t&&(typeof t.message=="object"?o=JSON.stringify(t.message):o=String(t.message)),ho(o,5e3,"center")}consoleError(t){console.error(t)}}const g=Wt.getInstance(),po=$`:host{--navbar-width:256px;--navbar-closed-width:80px;--logo-padding-left:0px;--navbar-icon-min-width:24px}.nav-bar{background:linear-gradient(#1456e0 20.5%,#0d2497 113.5%)}.nav-bar.wide{background:linear-gradient(90.27deg,#1456e0 0,#0d2497 99.23%)}.nav-bar.long{width:var(--navbar-width)}.nav-bar.long.closed{width:var(--navbar-closed-width)}.white-icon{--md-icon-button-icon-color:white;--md-sys-color-on-surface-variant:white}.animate-width{transition:width .3s ease,viewBox .3s ease,left .3s ease,opacity 3s ease}.expand-cta{--md-icon-button-icon-color:#94a3b8}.divider{border-color:#fff;opacity:.2;margin:0;flex-shrink:0;border-width:0 0 thin;border-style:solid}`;let mo=class extends I{render(){return c` <ix-icon-button @click="${()=>{localStorage.clear(),window.location.href="/"}}" icon="restart_alt"> </ix-icon-button> `}};mo=r([A("dev-clear-storage-button")],mo);const _=$` *, ::before, ::after {
1
+ import{__decorate as r}from"tslib";import{css as $,LitElement as I,html as c,svg as Ge,nothing as y}from"lit";import{customElement as A,property as d,state as m,query as D,queryAsync as Bi}from"lit/decorators.js";import{MobxLitElement as Ue}from"@adobe/lit-mobx";import{elementTheme as ge,baseTheme as $e}from"@digital-realty/theme";import Wt from"toastify-js";import{ApplicationInsights as Li}from"@microsoft/applicationinsights-web";import"@digital-realty/ix-progress/ix-progress.js";import"@digital-realty/ix-icon-button/ix-icon-button.js";import{makeAutoObservable as qi,toJS as Ne,observable as Qt,makeObservable as Hi}from"mobx";import{gql as Fe,GraphQLClient as zi}from"graphql-request";import{User as Vi,UserManager as ji}from"oidc-client-ts";import Yt from"i18next";import{initLitI18n as Gi}from"lit-i18n";import{Router as ye}from"@vaadin/router";import"@digital-realty/ix-button/ix-button.js";import"@digital-realty/ix-dialog/ix-dialog.js";import"@digital-realty/ix-textbox/ix-textbox.js";import"@digital-realty/ix-phone-input/ix-phone-input.js";import{parsePhoneNumberWithError as Xt,AsYouType as Ji,isPossiblePhoneNumber as Ki}from"libphonenumber-js";import{classMap as Zi}from"lit/directives/class-map.js";import Wi from"validator";import{keyed as Qi}from"lit/directives/keyed.js";import{ref as Yi}from"lit/directives/ref.js";import"@digital-realty/ix-tree/ix-tree.js";import"@digital-realty/ix-file-uploader/ix-file-uploader.js";import"@digital-realty/ix-select/ix-select.js";import"@digital-realty/ix-select/ix-select-option.js";import"@digital-realty/ix-multi-select/ix-multi-select.js";import{IconTypeMap as Xi,updateNodeCheckedStatus as be,flattenTree as en,findChildNodeById as Je,collapseAllNodes as Ke,calculateCheckedEndNodesCount as eo,getCheckedAndIndeterminateNodesOnly as to,buildTreeFromFlatArray as oo,updateChildrenCount as io}from"@digital-realty/ix-generic-tree";import{repeat as gt}from"lit/directives/repeat.js";import"@digital-realty/ix-tabs/ix-tabs.js";import"@digital-realty/ix-tabs/ix-primary-tab.js";import"@digital-realty/ix-icon/ix-icon.js";import"@digital-realty/ix-card/ix-card.js";import no from"lodash.debounce";import"@digital-realty/ix-generic-tree/ix-generic-tree.js";import"@digital-realty/ix-accordion/ix-accordion.js";import"@digital-realty/ix-divider/ix-divider.js";import"@digital-realty/ix-phone-number/ix-phone-number.js";import"@material/web/icon/icon.js";const tn="http://localhost".replace(/\/+$/,"");class Y{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:tn}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||so}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const on=new Y;class j{constructor(t=on){this.configuration=t,this.fetchApi=async(o,i)=>{let n={url:o,init:i};for(const s of this.middleware)s.pre&&(n=await s.pre({fetch:this.fetchApi,...n})||n);let a;try{a=await(this.configuration.fetchApi||fetch)(n.url,n.init)}catch(s){for(const l of this.middleware)l.onError&&(a=await l.onError({fetch:this.fetchApi,url:n.url,init:n.init,error:s,response:a?a.clone():void 0})||a);if(a===void 0)throw s instanceof Error?new sn(s,"The request failed and the interceptors did not return an alternative response"):s}for(const s of this.middleware)s.post&&(a=await s.post({fetch:this.fetchApi,url:n.url,init:n.init,response:a.clone()})||a);return a},this.middleware=t.middleware}withMiddleware(...t){const o=this.clone();return o.middleware=o.middleware.concat(...t),o}withPreMiddleware(...t){const o=t.map(i=>({pre:i}));return this.withMiddleware(...o)}withPostMiddleware(...t){const o=t.map(i=>({post:i}));return this.withMiddleware(...o)}isJsonMime(t){return t?j.jsonRegex.test(t):!1}async request(t,o){const{url:i,init:n}=await this.createFetchParams(t,o),a=await this.fetchApi(i,n);if(a&&a.status>=200&&a.status<300)return a;throw new ao(a,"Response returned an error code")}async createFetchParams(t,o){let i=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(i+="?"+this.configuration.queryParamsStringify(t.query));const n=Object.assign({},this.configuration.headers,t.headers);Object.keys(n).forEach(u=>n[u]===void 0?delete n[u]:{});const a=typeof o=="function"?o:async()=>o,s={method:t.method,headers:n,body:t.body,credentials:this.configuration.credentials},l={...s,...await a({init:s,context:t})};let p;an(l.body)||l.body instanceof URLSearchParams||nn(l.body)?p=l.body:this.isJsonMime(n["Content-Type"])?p=JSON.stringify(l.body):p=l.body;const h={...l,body:p};return{url:i,init:h}}clone(){const t=this.constructor,o=new t(this.configuration);return o.middleware=this.middleware.slice(),o}}j.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function nn(e){return typeof Blob<"u"&&e instanceof Blob}function an(e){return typeof FormData<"u"&&e instanceof FormData}class ao extends Error{constructor(t,o){super(o),this.response=t,this.name="ResponseError"}}class sn extends Error{constructor(t,o){super(o),this.cause=t,this.name="FetchError"}}class E extends Error{constructor(t,o){super(o),this.field=t,this.name="RequiredError"}}function f(e,t){return e[t]!=null}function so(e,t=""){return Object.keys(e).map(o=>ro(o,e[o],t)).filter(o=>o.length>0).join("&")}function ro(e,t,o=""){const i=o+(o.length?`[${e}]`:e);if(t instanceof Array){const n=t.map(a=>encodeURIComponent(String(a))).join(`&${encodeURIComponent(i)}=`);return`${encodeURIComponent(i)}=${n}`}if(t instanceof Set){const n=Array.from(t);return ro(e,n,o)}return t instanceof Date?`${encodeURIComponent(i)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?so(t,i):`${encodeURIComponent(i)}=${encodeURIComponent(String(t))}`}function rn(e){for(const t of e)if(t.contentType==="multipart/form-data")return!0;return!1}class R{constructor(t,o=i=>i){this.raw=t,this.transformer=o}async value(){return this.transformer(await this.raw.json())}}class xe{constructor(t){this.raw=t}async value(){}}class lo{constructor(t){this.raw=t}async value(){return await this.raw.blob()}}const S={AccountSwitched:"account-switched",AuthenticationComplete:"authentication",CancelCreateUser:"cancel-create-user",ChangeUserAccount:"change-user-account",CloseDrawer:"close-drawer",CheckToggle:"check-toggle",CloseDialog:"close-dialog",CreateNewContact:"create-new-contact",CreateRole:"create-role",CreateUser:"create-user",AddRole:"add-role",ChangeAccountAssociation:"change-account",UpdateChanges:"update-changes",ReloadAccount:"reload-account",CreateUserClicked:"create-user-clicked",DrawerClose:"drawer-close",DuplicateRole:"duplicate-role",ErrorRaised:"um:error-raised",EvacAssistanceRequired:"evac-assistance-required",GridViewUpdate:"grid-view-update",NextButtonToggle:"next-button-toggle",NextStep:"next-step",OpenDialog:"open-dialog",PreviousStep:"previous-step",RefreshTable:"refresh-table",ResetSuccess:"reset-success",RouteChanged:"vaadin-router-location-changed",SetStep:"set-step",ToggleDialog:"toggle-dialog",ToggleDraft:"toggle-draft",ToggleDrawer:"toggle-drawer",ToggleNavBar:"toggle-menu",UpdateAccounts:"update-accounts",UpdateContact:"update-contact",UpdateDFA:"update-dfa",UpdateForm:"update-form",UserFlagUpdate:"user-flag-update",EditProfile:"edit-profile",OpenModificationDetails:"open-modification-details"},te=new Map,ln=e=>{if(e){const t=te.get(e);t&&(t.forEach(o=>{o&&typeof o.hideToast=="function"&&o.hideToast()}),te.delete(e))}else te.forEach(t=>{t.forEach(o=>{o&&typeof o.hideToast=="function"&&o.hideToast()})}),te.clear()},co=(e,t,o,i,n,a)=>{const s=document.createElement("div");s.style.position="relative",s.style.padding="0",s.style.width="100%";const l=document.createElement("span");l.textContent=e,l.style.display="block",l.style.paddingRight=n?"30px":"0",s.appendChild(l);const p=Wt({node:s,duration:n?-1:t,newWindow:!1,close:n!=null?n:!1,gravity:"bottom",position:o!=null?o:"right",stopOnFocus:!0,className:"success-toast",style:{background:"rgb(76, 175, 80)",minWidth:i!=null?i:"fit-content",padding:"16px 20px"}});p.showToast(),n&&setTimeout(()=>{const h=document.querySelector(".toastify.on .toast-close:not([data-positioned])");h&&(h.setAttribute("data-positioned","true"),h.style.position="absolute",h.style.top="8px",h.style.right="8px",h.style.margin="0",h.style.padding="0",h.style.float="none",h.style.width="20px",h.style.height="20px",h.style.lineHeight="20px",h.style.textAlign="center")},10),a&&(te.has(a)||te.set(a,[]),te.get(a).push(p))},uo=(e,t,o,i,n,a,s)=>{const l=document.createElement("div");l.style.position="relative",l.style.padding="0",l.style.width="100%";const p=document.createElement("span");if(p.style.display="block",p.style.paddingRight=i?"30px":"0",a&&s){const[u,...b]=e.split(a);p.textContent=u;const F=document.createElement("span");if(F.textContent=a,F.style.textDecoration="underline",F.style.cursor="pointer",F.style.fontWeight="bold",F.addEventListener("click",s),p.appendChild(F),b.length>0&&b[0]){const se=document.createTextNode(b[0]);p.appendChild(se)}}else p.textContent=e;l.appendChild(p);const h=Wt({node:l,duration:i?-1:t,newWindow:!1,close:i!=null?i:!1,gravity:"bottom",position:o!=null?o:"right",stopOnFocus:!0,style:{background:"rgb(219, 0, 40)",minWidth:"344px",maxWidth:"750px",padding:"16px 20px"}});h.showToast(),i&&setTimeout(()=>{const u=document.querySelector(".toastify.on .toast-close:not([data-positioned])");u&&(u.setAttribute("data-positioned","true"),u.style.position="absolute",u.style.top="8px",u.style.right="8px",u.style.margin="0",u.style.padding="0",u.style.float="none",u.style.width="20px",u.style.height="20px",u.style.lineHeight="20px",u.style.textAlign="center")},10),n&&(te.has(n)||te.set(n,[]),te.get(n).push(h))};function N(){var e;const t=(e=window.gpConfig)===null||e===void 0?void 0:e["ui-user-management"];if(!t)throw new Error("ui-user-management config not loaded. Ensure config.json is fetched before app bootstrap.");return t}class cn{constructor(){this.fetchAppInsightsFromWindow=()=>window._appInsights,this.tryFetchShellAppInsights=()=>{const o=this.fetchAppInsightsFromWindow();if(!o){const i=this.buildStandaloneAppInsights();return i.trackException({severityLevel:4,exception:new Error("Application Insights instance could not be located on window. Falling back to standalone instance.")}),i}return o},this.buildStandaloneAppInsights=()=>{const o=new Li({config:{connectionString:N().UserManagement.UI.AppInsights.ConnectionString,isCookieUseDisabled:!0}});return o.loadAppInsights(),this.fetchAppInsightsFromWindow()&&o.trackException({severityLevel:4,exception:new Error("Application Insights instance already exists on window, but we're registering it again in standalone. This will cause issues with telemetry.")}),o};const t=N();this.appInsights=t.UserManagement.UI.AppInsights.ShouldUseGlobal?this.tryFetchShellAppInsights():this.buildStandaloneAppInsights()}}const dn=new cn;var un=dn.appInsights;class Zt{constructor(){this.displayErrorBinding=this.displayError.bind(this),this.setupErrorHandler=()=>{document.addEventListener(S.ErrorRaised,this.displayErrorBinding)},this.destroyErrorHandler=()=>{document.removeEventListener(S.ErrorRaised,this.displayErrorBinding)},this.handleError=async(t,o)=>{let i=t;i.userMessage=o,t instanceof ao&&await t.response.json().then(n=>{var a;i.message=n.detail,n.status===403&&(i.userMessage=(a=n.detail)!==null&&a!==void 0?a:"You don't have permission to perform this action.")}).catch(()=>{i.message="Failed to get the error details from response."}),t instanceof PromiseRejectionEvent&&(i=await t.reason),un.trackException({exception:i}),this.displayError(i),console.error(i)},this.setupErrorHandler()}static getInstance(){return this.instance||(this.instance=new Zt),this.instance}displayError(t){let o="";typeof t=="string"?o=t:"userMessage"in t&&t.userMessage!==void 0?o=t.userMessage:"message"in t&&(typeof t.message=="object"?o=JSON.stringify(t.message):o=String(t.message)),uo(o,5e3,"center")}consoleError(t){console.error(t)}}const g=Zt.getInstance(),ho=$`:host{--navbar-width:256px;--navbar-closed-width:80px;--logo-padding-left:0px;--navbar-icon-min-width:24px}.nav-bar{background:linear-gradient(#1456e0 20.5%,#0d2497 113.5%)}.nav-bar.wide{background:linear-gradient(90.27deg,#1456e0 0,#0d2497 99.23%)}.nav-bar.long{width:var(--navbar-width)}.nav-bar.long.closed{width:var(--navbar-closed-width)}.white-icon{--md-icon-button-icon-color:white;--md-sys-color-on-surface-variant:white}.animate-width{transition:width .3s ease,viewBox .3s ease,left .3s ease,opacity 3s ease}.expand-cta{--md-icon-button-icon-color:#94a3b8}.divider{border-color:#fff;opacity:.2;margin:0;flex-shrink:0;border-width:0 0 thin;border-style:solid}`;let po=class extends I{render(){return c` <ix-icon-button @click="${()=>{localStorage.clear(),window.location.href="/"}}" icon="restart_alt"> </ix-icon-button> `}};po=r([A("dev-clear-storage-button")],po);const _=$` *, ::before, ::after {
2
2
  --tw-border-spacing-x: 0;
3
3
  --tw-border-spacing-y: 0;
4
4
  --tw-translate-x: 0;
@@ -1731,17 +1731,17 @@ video {
1731
1731
 
1732
1732
  .\\[\\&\\:not\\(\\:last-of-type\\)\\]\\:pr-8:not(:last-of-type) {
1733
1733
  padding-right: 2rem;
1734
- } `,Ke={digitalRealtyLogo:je`
1734
+ } `,Ze={digitalRealtyLogo:Ge`
1735
1735
  <path d="M17.6281 26.4421V23.1369C20.6656 23.1369 23.1369 20.6657 23.1369 17.6281H26.4421C26.4421 22.4881 22.4881 26.4421 17.6281 26.4421ZM17.6281 0V3.30527C20.6656 3.30527 23.1369 5.77647 23.1369 8.81404H26.4421C26.4421 3.95398 22.4881 0 17.6281 0ZM8.81404 23.1369H3.30527V17.6281H0V26.4421H8.81404V23.1369ZM3.30527 3.30527H8.81404V0H0V8.81404H3.30527V3.30527Z"></path>
1736
- `,digitalRealtyLogoWithText:je`
1736
+ `,digitalRealtyLogoWithText:Ge`
1737
1737
  <path d="M174.823 18.1256V18.338H174.216V19.7581H173.986V18.338H173.379V18.1256H174.823ZM175.376 18.1256L176.025 19.4728L176.68 18.1256H177.002V19.7581H176.784V18.3865L176.116 19.7581H175.928L175.272 18.3865V19.7581H175.06V18.1256H175.376Z"></path>
1738
1738
  <path d="M166.533 6.68392L169.465 12.0444L172.547 6.68392H175.666L170.866 14.902V19.7581H168.064V14.902L163.264 6.68392H166.533ZM162.921 6.68392V9.0933H159.148V19.7581H156.347V9.0933H152.574V6.68392H162.921ZM149.268 6.68393H146.467V19.7581H154.836V17.3487H149.268V6.68393ZM137.482 6.68392H140.844L145.588 19.7581H142.581L141.573 16.9005H136.605L135.596 19.7581H132.701L137.482 6.68392ZM140.807 14.6406L139.07 9.67235L137.352 14.6406H140.807ZM131.744 6.68392V9.0933H125.767V12.0257H130.623V14.323H125.767V17.3488H131.949V19.7581H122.965V6.68392H131.744ZM119.015 7.21625C119.743 7.57117 120.307 8.07848 120.705 8.73847C121.104 9.39836 121.303 10.1642 121.303 11.0358C121.303 11.87 121.104 12.6078 120.705 13.249C120.307 13.8904 119.759 14.3791 119.062 14.7152L121.639 19.7581H118.539L116.353 15.369H113.981V19.7581H111.18V6.68392H116.503C117.449 6.68392 118.286 6.86143 119.015 7.21625ZM116.279 13.0343C116.939 13.0343 117.465 12.8537 117.857 12.4927C118.249 12.1315 118.445 11.6459 118.445 11.0358C118.445 10.4132 118.249 9.92141 117.857 9.56024C117.465 9.19916 116.939 9.01862 116.279 9.01862H113.981V13.0343H116.279ZM99.9176 17.3487V6.68398H97.1161V19.7581H105.485V17.3487H99.9176ZM88.1319 6.68397L91.4938 6.68398L96.2379 19.7581H93.2309L92.2222 16.9005H87.2541L86.2454 19.7581H83.3504L88.1319 6.68397ZM91.4564 14.6405L89.7195 9.67236L88.0012 14.6405H91.4564ZM84.9942 6.68397V9.09335H81.2213V19.7581H78.4198V9.09335H74.6469V6.68397H84.9942ZM73.5075 6.68397V19.7581H70.7059V6.68397H73.5075ZM59.5649 7.39371C60.5422 6.84584 61.691 6.5719 63.0109 6.5719C64.0443 6.5719 64.972 6.77111 65.7937 7.16957C66.6156 7.56799 67.2786 8.12833 67.7829 8.85053C68.2872 9.57269 68.5954 10.4008 68.7074 11.3346H65.9432C65.7688 10.6 65.4202 10.0179 64.8972 9.58829C64.3742 9.15869 63.7206 8.94393 62.9361 8.94393C62.2139 8.94393 61.5851 9.12448 61.0497 9.48556C60.5143 9.84664 60.1034 10.351 59.817 10.9984C59.5306 11.6459 59.3874 12.3868 59.3874 13.221C59.3874 14.5036 59.7018 15.5371 60.3306 16.3215C60.9594 17.106 61.8279 17.4982 62.9361 17.4982C63.7454 17.4982 64.4614 17.2772 65.084 16.8351C65.7066 16.3931 66.0801 15.7425 66.2047 14.8833V14.7152H62.9547V12.4926H68.8008V19.7581H66.8584L66.5595 18.1332C66.1736 18.6437 65.6568 19.0609 65.0093 19.3846C64.3618 19.7083 63.6085 19.8702 62.7494 19.8702C61.5166 19.8702 60.4302 19.5963 59.4901 19.0484C58.55 18.5005 57.8216 17.7223 57.3048 16.7137C56.7881 15.7051 56.5298 14.5409 56.5298 13.221C56.5298 11.8887 56.7913 10.7214 57.3142 9.71903C57.8372 8.71668 58.5874 7.94154 59.5649 7.39371ZM55.0729 6.68397V19.7581H52.2713V6.68397H55.0729ZM44.2028 6.68397C45.5101 6.68397 46.665 6.96099 47.6674 7.51512C48.6697 8.0692 49.4417 8.84121 49.9834 9.8311C50.5251 10.821 50.7958 11.951 50.7958 13.221C50.7958 14.4911 50.5251 15.6211 49.9834 16.611C49.4417 17.6009 48.6697 18.3729 47.6674 18.927C46.665 19.4811 45.5101 19.7581 44.2028 19.7581H39.6641V6.68397H44.2028ZM46.9577 16.2748C47.6113 15.509 47.9382 14.4911 47.9382 13.221C47.9382 11.951 47.6113 10.9331 46.9577 10.1673C46.304 9.4015 45.3856 9.01863 44.2028 9.01863H42.4657V17.4234H44.2028C45.3856 17.4234 46.304 17.0406 46.9577 16.2748Z"></path>
1739
1739
  <path d="M17.6281 26.4421V23.1369C20.6656 23.1369 23.1369 20.6657 23.1369 17.6281H26.4421C26.4421 22.4881 22.4881 26.4421 17.6281 26.4421ZM17.6281 0V3.30527C20.6656 3.30527 23.1369 5.77647 23.1369 8.81404H26.4421C26.4421 3.95398 22.4881 0 17.6281 0ZM8.81404 23.1369H3.30527V17.6281H0V26.4421H8.81404V23.1369ZM3.30527 3.30527H8.81404V0H0V8.81404H3.30527V3.30527Z"></path>
1740
- `,userManagementIcon:je`
1740
+ `,userManagementIcon:Ge`
1741
1741
  <path d="M3 3C1.897 3 1 3.897 1 5V21H11V19H3V5H13V12C13 10.37 13.792 8.93544 15 8.02344V5C15 3.897 14.103 3 13 3H3ZM5 7V9H7V7H5ZM9 7V9H11V7H9ZM18 9C16.318 9 15 10.317 15 12C15 13.683 16.318 15 18 15C19.682 15 21 13.683 21 12C21 10.317 19.682 9 18 9ZM5 11V13H7V11H5ZM9 11V13H11V11H9ZM18 11C18.58 11 19 11.421 19 12C19 12.579 18.58 13 18 13C17.42 13 17 12.579 17 12C17 11.421 17.42 11 18 11ZM5 15V17H7V15H5ZM9 15V17H11V15H9ZM18 16C15.149 16 13 17.4558 13 19.3848V21H23V19.3848C23 17.4558 20.851 16 18 16ZM18 18C19.47 18 20.4895 18.504 20.8535 19H15.1465C15.5095 18.504 16.53 18 18 18Z"></path>
1742
- `,roleManagementIcon:je`
1742
+ `,roleManagementIcon:Ge`
1743
1743
  <path d="M12 3C9.80271 3 8 4.80271 8 7C8 9.19729 9.80271 11 12 11C14.1973 11 16 9.19729 16 7C16 4.80271 14.1973 3 12 3ZM12 5C13.1164 5 14 5.88359 14 7C14 8.11641 13.1164 9 12 9C10.8836 9 10 8.11641 10 7C10 5.88359 10.8836 5 12 5ZM18 12C16.1872 12 14.5593 12.8158 13.457 14.0957C12.9584 14.0389 12.4662 14 12 14C10.255 14 8.18716 14.4098 6.44922 15.0957C5.58025 15.4387 4.7947 15.846 4.16602 16.3691C3.53734 16.8922 3 17.5994 3 18.5V21H12.8145C13.8556 22.789 15.7903 24 18 24C21.3019 24 24 21.3019 24 18C24 14.6981 21.3019 12 18 12ZM18 14C19.0039 14 19.9057 14.377 20.6055 14.9805L18 17.5859L16.707 16.293L15.293 17.707L18 20.4141L21.7559 16.6582C21.9049 17.0789 22 17.5261 22 18C22 20.221 20.221 22 18 22C15.779 22 14 20.221 14 18C14 15.779 15.779 14 18 14ZM12 16C12.1083 16 12.2316 16.0115 12.3457 16.0156C12.1256 16.6382 12 17.3041 12 18C12 18.3415 12.0364 18.6738 12.0918 19H5V18.5C5 18.4346 5.06759 18.2205 5.44531 17.9062C5.82304 17.592 6.44549 17.2456 7.18164 16.9551C8.65395 16.374 10.586 16 12 16Z"></path>
1744
- `};class mn{constructor(){this.error=void 0,this.loading=!0,this.permissions=[],this.email=void 0,this.accountNumber="",this.accounts=[],this.accountHierarchy=[],this.permissionAssignment=[],zi(this)}setPermissions(t){this.permissions=structuredClone(t)}setError(t){this.error=t}set setLoading(t){this.loading=t}get getLoading(){return this.loading}clearError(){this.error=void 0}getMyPermissions(){return Ne(this.permissionAssignment)}setMyPermissions(t){this.permissionAssignment=structuredClone(t)}getPermissions(){return Ne(this.permissions)}setEmail(t){this.email=t}getEmail(){return this.email}setAccountNumber(t){this.accountNumber=t}getAccountNumber(){return this.accountNumber}setAccounts(t){this.accounts=t}getAccounts(){return Ne(this.accounts)}setAccountHierarchy(t){this.accountHierarchy=t}getAccountHierarchy(){return Ne(this.accountHierarchy)}}const U=new mn,T={user:"User",externalUser:"External User",internalUser:"Internal User",customRoles:"Custom Roles",internalRoles:"Internal Roles",defaultRoles:"Default System Roles",assignInternalRole:"Assign Internal Role"},x={read:"read",update:"update",create:"create",approve:"approve"};function gn(e){return fn(e)}function fn(e,t){return e==null?e:{account_number:f(e,"account_number")?e.account_number:void 0,parent_account_number:f(e,"parent_account_number")?e.parent_account_number:void 0,name:f(e,"name")?e.name:void 0,friendly_name:f(e,"friendly_name")?e.friendly_name:void 0}}function go(e){return vn(e)}function vn(e,t){return e}function gt(e){return yn(e)}function yn(e,t){return e==null?e:{id:e.id,account_number:e.account_number,account_name:e.account_name,account_friendly_name:e.account_friendly_name,status:go(e.status),updated_at:e.updated_at,updated_by:e.updated_by,user_id:e.user_id}}function bn(e){if(e!==void 0)return e===null?null:{user_id:e.user_id,account_number:e.account_number,change_history_id:e.change_history_id}}function xn(e){if(e!==void 0)return e===null?null:{status:e.status,change_history_id:e.change_history_id}}function fo(e){return wn(e)}function wn(e,t){return e==null?e:{created_at:e.created_at,created_by:e.created_by,authority_document_id:e.authority_document_id,change_history_id:f(e,"change_history_id")?e.change_history_id:void 0,file_name:e.file_name}}function vo(e){return An(e)}function An(e,t){return e==null?e:{authority_document_id:e.authority_document_id,change_history_id:f(e,"change_history_id")?e.change_history_id:void 0,file_name:e.file_name}}function yo(e){return Cn(e)}function Cn(e,t){return e==null?e:{reason:e.reason,authoriser_user_id:f(e,"authoriser_user_id")?e.authoriser_user_id:void 0,account_number:e.account_number}}function _n(e){if(e!==void 0)return e===null?null:{reason:e.reason,authoriser_user_id:e.authoriser_user_id,account_number:e.account_number}}function bo(e){return Tn(e)}function Tn(e,t){return e==null?e:{id:f(e,"id")?e.id:void 0,first_name:f(e,"first_name")?e.first_name:void 0,last_name:f(e,"last_name")?e.last_name:void 0,email:f(e,"email")?e.email:void 0}}function xo(e){return In(e)}function In(e,t){return e==null?e:{change_history_id:e.change_history_id,authoriser_details:f(e,"authoriser_details")?e.authoriser_details.map(yo):void 0,created_by:bo(e.created_by),created_at:e.created_at,authority_documents:f(e,"authority_documents")?e.authority_documents.map(vo):void 0}}function En(e){return Rn(e)}function Rn(e,t){return e==null?e:{change_history_id:e.change_history_id,authoriser_details:f(e,"authoriser_details")?e.authoriser_details.map(yo):void 0,created_by:bo(e.created_by),created_at:e.created_at,authority_documents:f(e,"authority_documents")?e.authority_documents.map(vo):void 0}}function Sn(e){return kn(e)}function kn(e,t){return e==null?e:{continuation_token:f(e,"continuation_token")?e.continuation_token:void 0}}function Un(e){return $n(e)}function $n(e,t){return e==null?e:{content:e.content.map(En),pageable:Sn(e.pageable)}}function Nn(e){if(e!==void 0)return e===null?null:{authoriser_details:e.authoriser_details===void 0?void 0:e.authoriser_details.map(_n),authority_documents:e.authority_documents}}function Fn(e){if(e!==void 0)return e===null?null:{role_id:e.role_id,user_id:e.user_id,account_number:e.account_number,location_id:e.location_id}}function Dn(e){if(e!==void 0)return e===null?null:{RoleAssignmentInput:e.RoleAssignmentInput===void 0?void 0:e.RoleAssignmentInput.map(Fn),change_history_id:e.change_history_id}}function wo(e){return Pn(e)}function Pn(e,t){return e==null?e:{permission_id:e.permission_id,permission_name:e.permission_name,is_non_location:e.is_non_location,privilege:e.privilege}}function Mn(e){return On(e)}function On(e,t){return e==null?e:{id:e.id,name:e.name,account_number:f(e,"account_number")?e.account_number:void 0,role_type:e.role_type,permissions:e.permissions.map(wo),status:e.status,message:e.message}}function Bn(e){return Ln(e)}function Ln(e,t){return e}function ic(e){return e}function qn(e){if(e!==void 0)return e===null?null:{user_flag_type:e.user_flag_type,user_id:e.user_id,account_number:e.account_number,location_id:e.location_id}}function Hn(e){if(e!==void 0)return e===null?null:{UserFlagAssignmentInputs:e.UserFlagAssignmentInputs===void 0?void 0:e.UserFlagAssignmentInputs.map(qn),change_history_id:e.change_history_id}}function De(e){if(e!==void 0)return e===null?null:{permission_id:e.permission_id,privilege:e.privilege}}function zn(e){if(e!==void 0)return e===null?null:{name:e.name,role_type:e.role_type,permissions:e.permissions.map(De),account_number:e.account_number,account_numbers:e.account_numbers}}function Vn(e){if(e!==void 0)return e===null?null:{name:e.name,role_type:e.role_type,permissions:e.permissions.map(De)}}function jn(e){if(e!==void 0)return e===null?null:{email_address:e.email_address}}function Gn(e){if(e!==void 0)return e===null?null:{name:e.name,role_type:e.role_type,permissions:e.permissions.map(De)}}function Jn(e){if(e!==void 0)return e===null?null:{name:e.name,role_type:e.role_type,permissions:e.permissions.map(De)}}const Ao={AccountAdmininstrator:"ACCOUNT_ADMININSTRATOR",VisitorAccessApprover:"VISITOR_ACCESS_APPROVER",PermanentBadgeApprover:"PERMANENT_BADGE_APPROVER",OnBehalfUserCreator:"ON_BEHALF_USER_CREATOR",OnBehalfUserUpdater:"ON_BEHALF_USER_UPDATER"};function Kn(e){return Zn(e)}function Zn(e,t){return e==null?e:{id:f(e,"id")?e.id:void 0,first_name:f(e,"first_name")?e.first_name:void 0,last_name:f(e,"last_name")?e.last_name:void 0,email:f(e,"email")?e.email:void 0,account_permission_group:f(e,"account_permission_group")?e.account_permission_group:void 0,account_associations:f(e,"account_associations")?e.account_associations:void 0}}function Wn(e){return Qn(e)}function Qn(e,t){return e==null?e:{items:f(e,"items")?e.items.map(Kn):void 0}}function Yn(e){return Xn(e)}function Xn(e,t){return e==null?e:{id:e.id,name:e.name,is_non_location:e.is_non_location,category:f(e,"category")?e.category:void 0,privileges:e.privileges,internal_privileges:e.internal_privileges,is_internal:e.is_internal}}function ea(e){return ta(e)}function ta(e,t){return e==null?e:{account_number:e.account_number,permission_name:e.permission_name,privilege:e.privilege,privilege_is_internal:e.privilege_is_internal,is_non_location:f(e,"is_non_location")?e.is_non_location:void 0,provenance:f(e,"provenance")?e.provenance:void 0}}function Co(e){return oa(e)}function oa(e,t){return e==null?e:{id:e.id,name:e.name,account_number:f(e,"account_number")?e.account_number:void 0,role_type:e.role_type,permissions:e.permissions.map(wo)}}function ft(e){return ia(e)}function ia(e,t){return e==null?e:{role_id:e.role_id,user_id:e.user_id,account_number:e.account_number,location_id:f(e,"location_id")?e.location_id:void 0,id:e.id,is_active:e.is_active}}function na(e){if(e!==void 0){if(e===null)return null;switch(e.role_type){case"CUSTOM":return zn(e);case"DEFAULT":return Vn(e);case"GLOBALACCESS":return Gn(e);case"INTERNAL":return Jn(e);default:throw new Error(`No variant of RoleCreate exists with 'role_type=${e.role_type}'`)}}}function aa(e){if(e!==void 0)return e===null?null:{role_name:e.role_name,permissions:e.permissions.map(De)}}function sa(e){return ra(e)}function ra(e,t){return e==null?e:{id:e.id,account_number:e.account_number,account_name:e.account_name,account_friendly_name:e.account_friendly_name,status:go(e.status),updated_at:e.updated_at,updated_by:e.updated_by}}function vt(e){return la(e)}function la(e,t){return e==null?e:{first_name:e.first_name,last_name:e.last_name,email:e.email,phone:e.phone,evacuation_assistance_required:f(e,"evacuation_assistance_required")?e.evacuation_assistance_required:void 0,id:e.id,is_active:f(e,"is_active")?e.is_active:void 0,account_associations:e.account_associations.map(sa)}}function yt(e){return ca(e)}function ca(e,t){return e==null?e:{user_flag_type:Bn(e.user_flag_type),user_id:e.user_id,account_number:e.account_number,location_id:e.location_id,id:e.id,is_active:f(e,"is_active")?e.is_active:void 0}}function da(e){if(e!==void 0)return e===null?null:{first_name:e.first_name,last_name:e.last_name,email:e.email,phone:e.phone,evacuation_assistance_required:e.evacuation_assistance_required,account_numbers:e.account_numbers,change_history_id:e.change_history_id}}function ua(e){if(e!==void 0)return e===null?null:{first_name:e.first_name,last_name:e.last_name,email:e.email,phone:e.phone,evacuation_assistance_required:e.evacuation_assistance_required}}function ha(e){return pa(e)}function pa(e,t){return e==null?e:{number:f(e,"number")?e.number:void 0,total_pages:f(e,"total_pages")?e.total_pages:void 0,first:f(e,"first")?e.first:void 0,last:f(e,"last")?e.last:void 0,size:f(e,"size")?e.size:void 0,number_of_elements:f(e,"number_of_elements")?e.number_of_elements:void 0,total_elements:f(e,"total_elements")?e.total_elements:void 0}}function ma(e){return ga(e)}function ga(e,t){return e==null?e:{content:f(e,"content")?e.content.map(vt):void 0,pageable:f(e,"pageable")?ha(e.pageable):void 0}}function fa(e){return va(e)}function va(e,t){return e==null?e:{email_address:f(e,"email_address")?e.email_address:void 0,is_verified:f(e,"is_verified")?e.is_verified:void 0,reason:f(e,"reason")?e.reason:void 0}}class ya extends j{async createAccountAssociationRaw(t,o){if(t.accountAssociationInput===null||t.accountAssociationInput===void 0)throw new E("accountAssociationInput","Required parameter requestParameters.accountAssociationInput was null or undefined when calling createAccountAssociation.");const i={},n={};n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/account-associations",method:"POST",headers:n,query:i,body:bn(t.accountAssociationInput)},o);return new R(a,s=>gt(s))}async createAccountAssociation(t,o){return await(await this.createAccountAssociationRaw(t,o)).value()}async getAccountAssociationsRaw(t,o){const i={};t.accountNumber!==void 0&&(i.account_number=t.accountNumber),t.userId!==void 0&&(i.user_id=t.userId),t.status!==void 0&&(i.status=t.status);const n={};this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/account-associations",method:"GET",headers:n,query:i},o);return new R(a,s=>s.map(gt))}async getAccountAssociations(t={},o){return await(await this.getAccountAssociationsRaw(t,o)).value()}async getUserAccountAssociationRaw(t,o){if(t.id===null||t.id===void 0)throw new E("id","Required parameter requestParameters.id was null or undefined when calling getUserAccountAssociation.");const i={},n={};this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/account-associations/{id}".replace("{id}",encodeURIComponent(String(t.id))),method:"GET",headers:n,query:i},o);return new R(a,s=>gt(s))}async getUserAccountAssociation(t,o){return await(await this.getUserAccountAssociationRaw(t,o)).value()}async updateAccountAssociationStatusRaw(t,o){if(t.id===null||t.id===void 0)throw new E("id","Required parameter requestParameters.id was null or undefined when calling updateAccountAssociationStatus.");if(t.accountAssociationStatusUpdate===null||t.accountAssociationStatusUpdate===void 0)throw new E("accountAssociationStatusUpdate","Required parameter requestParameters.accountAssociationStatusUpdate was null or undefined when calling updateAccountAssociationStatus.");const i={},n={};n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/account-associations/{id}".replace("{id}",encodeURIComponent(String(t.id))),method:"PATCH",headers:n,query:i,body:xn(t.accountAssociationStatusUpdate)},o);return new xe(a)}async updateAccountAssociationStatus(t,o){await this.updateAccountAssociationStatusRaw(t,o)}}class ba extends j{async getAccountsRaw(t){const o={},i={};this.configuration&&this.configuration.accessToken&&(i.Authorization=await this.configuration.accessToken("oAuth2",[]));const n=await this.request({path:"/accounts",method:"GET",headers:i,query:o},t);return new R(n,a=>a.map(gn))}async getAccounts(t){return await(await this.getAccountsRaw(t)).value()}}class xa extends j{async downloadAuthorityDocumentsRaw(t,o){if(t.id===null||t.id===void 0)throw new E("id","Required parameter requestParameters.id was null or undefined when calling downloadAuthorityDocuments.");const i={},n={};this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/authority-documents/{id}/content".replace("{id}",encodeURIComponent(String(t.id))),method:"GET",headers:n,query:i},o);return new co(a)}async downloadAuthorityDocuments(t,o){return await(await this.downloadAuthorityDocumentsRaw(t,o)).value()}async getAuthorityDocumentRaw(t,o){if(t.id===null||t.id===void 0)throw new E("id","Required parameter requestParameters.id was null or undefined when calling getAuthorityDocument.");const i={},n={};this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/authority-documents/{id}".replace("{id}",encodeURIComponent(String(t.id))),method:"GET",headers:n,query:i},o);return new R(a,s=>fo(s))}async getAuthorityDocument(t,o){return await(await this.getAuthorityDocumentRaw(t,o)).value()}async postAuthorityDocumentsRaw(t,o){if(t.file===null||t.file===void 0)throw new E("file","Required parameter requestParameters.file was null or undefined when calling postAuthorityDocuments.");const i={},n={};this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=[{contentType:"multipart/form-data"}],s=cn(a);let l,p=!1;p=s,p?l=new FormData:l=new URLSearchParams,t.file!==void 0&&l.append("file",t.file),t.fileName!==void 0&&l.append("file_name",t.fileName);const h=await this.request({path:"/authority-documents",method:"POST",headers:n,query:i,body:l},o);return new R(h,u=>fo(u))}async postAuthorityDocuments(t,o){return await(await this.postAuthorityDocumentsRaw(t,o)).value()}}class wa extends j{async getChangeHistoryRaw(t,o){const i={};t.continuationToken!==void 0&&(i.continuation_token=t.continuationToken),t.sort!==void 0&&(i.sort=t.sort),t.limit!==void 0&&(i.limit=t.limit),t.userId!==void 0&&(i.user_id=t.userId),t.accountNumber!==void 0&&(i.account_number=t.accountNumber);const n={};this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/change-histories",method:"GET",headers:n,query:i},o);return new R(a,s=>Un(s))}async getChangeHistory(t={},o){return await(await this.getChangeHistoryRaw(t,o)).value()}async getChangeHistoryByIdRaw(t,o){if(t.id===null||t.id===void 0)throw new E("id","Required parameter requestParameters.id was null or undefined when calling getChangeHistoryById.");const i={},n={};this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/change-histories/{id}".replace("{id}",encodeURIComponent(String(t.id))),method:"GET",headers:n,query:i},o);return new R(a,s=>xo(s))}async getChangeHistoryById(t,o){return await(await this.getChangeHistoryByIdRaw(t,o)).value()}async postChangeHistoryRaw(t,o){if(t.changeHistoryRequest===null||t.changeHistoryRequest===void 0)throw new E("changeHistoryRequest","Required parameter requestParameters.changeHistoryRequest was null or undefined when calling postChangeHistory.");const i={},n={};n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/change-histories",method:"POST",headers:n,query:i,body:Nn(t.changeHistoryRequest)},o);return new R(a,s=>xo(s))}async postChangeHistory(t,o){return await(await this.postChangeHistoryRaw(t,o)).value()}}class Aa extends j{async getPermissionsRaw(t){const o={},i={};this.configuration&&this.configuration.accessToken&&(i.Authorization=await this.configuration.accessToken("oAuth2",[]));const n=await this.request({path:"/permissions",method:"GET",headers:i,query:o},t);return new R(n,a=>a.map(Yn))}async getPermissions(t){return await(await this.getPermissionsRaw(t)).value()}async getUserPermissionsRaw(t,o){const i={};t.excludeSiblings!==void 0&&(i.exclude_siblings=t.excludeSiblings),t.excludeParents!==void 0&&(i.exclude_parents=t.excludeParents);const n={};this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/my-permissions",method:"GET",headers:n,query:i},o);return new R(a,s=>s.map(ea))}async getUserPermissions(t={},o){return await(await this.getUserPermissionsRaw(t,o)).value()}}class Ca extends j{async createRoleAssignmentsRaw(t,o){if(t.createRoleAssignment===null||t.createRoleAssignment===void 0)throw new E("createRoleAssignment","Required parameter requestParameters.createRoleAssignment was null or undefined when calling createRoleAssignments.");const i={},n={};n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/role-assignments",method:"POST",headers:n,query:i,body:Dn(t.createRoleAssignment)},o);return new R(a,s=>s.map(ft))}async createRoleAssignments(t,o){return await(await this.createRoleAssignmentsRaw(t,o)).value()}async deleteRoleAssignmentRaw(t,o){if(t.id===null||t.id===void 0)throw new E("id","Required parameter requestParameters.id was null or undefined when calling deleteRoleAssignment.");const i={};t.changeHistoryId!==void 0&&(i.change_history_id=t.changeHistoryId);const n={};this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/role-assignments/{id}".replace("{id}",encodeURIComponent(String(t.id))),method:"DELETE",headers:n,query:i},o);return new xe(a)}async deleteRoleAssignment(t,o){await this.deleteRoleAssignmentRaw(t,o)}async getRoleAssignmentRaw(t,o){if(t.id===null||t.id===void 0)throw new E("id","Required parameter requestParameters.id was null or undefined when calling getRoleAssignment.");const i={},n={};this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/role-assignments/{id}".replace("{id}",encodeURIComponent(String(t.id))),method:"GET",headers:n,query:i},o);return new R(a,s=>ft(s))}async getRoleAssignment(t,o){return await(await this.getRoleAssignmentRaw(t,o)).value()}async getRoleAssignmentsRaw(t,o){const i={};t.roleId!==void 0&&(i.role_id=t.roleId),t.userId!==void 0&&(i.user_id=t.userId),t.accountNumber!==void 0&&(i.account_number=t.accountNumber),t.locationId!==void 0&&(i.location_id=t.locationId),t.roleType!==void 0&&(i.role_type=t.roleType);const n={};this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/role-assignments",method:"GET",headers:n,query:i},o);return new R(a,s=>s.map(ft))}async getRoleAssignments(t={},o){return await(await this.getRoleAssignmentsRaw(t,o)).value()}}class _a extends j{async createRoleRaw(t,o){if(t.roleCreate===null||t.roleCreate===void 0)throw new E("roleCreate","Required parameter requestParameters.roleCreate was null or undefined when calling createRole.");const i={},n={};n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/roles",method:"POST",headers:n,query:i,body:na(t.roleCreate)},o);return new R(a,s=>s.map(Mn))}async createRole(t,o){return await(await this.createRoleRaw(t,o)).value()}async deleteRoleRaw(t,o){if(t.id===null||t.id===void 0)throw new E("id","Required parameter requestParameters.id was null or undefined when calling deleteRole.");const i={},n={};this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/roles/{id}".replace("{id}",encodeURIComponent(String(t.id))),method:"DELETE",headers:n,query:i},o);return new xe(a)}async deleteRole(t,o){await this.deleteRoleRaw(t,o)}async getRoleRaw(t,o){if(t.id===null||t.id===void 0)throw new E("id","Required parameter requestParameters.id was null or undefined when calling getRole.");const i={},n={};this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/roles/{id}".replace("{id}",encodeURIComponent(String(t.id))),method:"GET",headers:n,query:i},o);return new R(a,s=>Co(s))}async getRole(t,o){return await(await this.getRoleRaw(t,o)).value()}async getRolesRaw(t,o){const i={};t.roleType!==void 0&&(i.role_type=t.roleType);const n={};this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/roles",method:"GET",headers:n,query:i},o);return new R(a,s=>s.map(Co))}async getRoles(t={},o){return await(await this.getRolesRaw(t,o)).value()}async updateRoleRaw(t,o){if(t.id===null||t.id===void 0)throw new E("id","Required parameter requestParameters.id was null or undefined when calling updateRole.");if(t.roleUpdate===null||t.roleUpdate===void 0)throw new E("roleUpdate","Required parameter requestParameters.roleUpdate was null or undefined when calling updateRole.");const i={},n={};n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/roles/{id}".replace("{id}",encodeURIComponent(String(t.id))),method:"PUT",headers:n,query:i,body:aa(t.roleUpdate)},o);return new xe(a)}async updateRole(t,o){await this.updateRoleRaw(t,o)}}class Ta extends j{async createUserFlagsRaw(t,o){if(t.createUserFlagAssignment===null||t.createUserFlagAssignment===void 0)throw new E("createUserFlagAssignment","Required parameter requestParameters.createUserFlagAssignment was null or undefined when calling createUserFlags.");const i={},n={};n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/user-flags",method:"POST",headers:n,query:i,body:Hn(t.createUserFlagAssignment)},o);return new R(a,s=>s.map(yt))}async createUserFlags(t,o){return await(await this.createUserFlagsRaw(t,o)).value()}async deleteUserFlagRaw(t,o){if(t.id===null||t.id===void 0)throw new E("id","Required parameter requestParameters.id was null or undefined when calling deleteUserFlag.");const i={};t.changeHistoryId!==void 0&&(i.change_history_id=t.changeHistoryId);const n={};this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/user-flags/{id}".replace("{id}",encodeURIComponent(String(t.id))),method:"DELETE",headers:n,query:i},o);return new xe(a)}async deleteUserFlag(t,o){await this.deleteUserFlagRaw(t,o)}async getUserFlagRaw(t,o){if(t.id===null||t.id===void 0)throw new E("id","Required parameter requestParameters.id was null or undefined when calling getUserFlag.");const i={},n={};this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/user-flags/{id}".replace("{id}",encodeURIComponent(String(t.id))),method:"GET",headers:n,query:i},o);return new R(a,s=>yt(s))}async getUserFlag(t,o){return await(await this.getUserFlagRaw(t,o)).value()}async getUserFlagsRaw(t,o){const i={};t.userFlagType!==void 0&&(i.user_flag_type=t.userFlagType),t.userId!==void 0&&(i.user_id=t.userId),t.accountNumber!==void 0&&(i.account_number=t.accountNumber),t.locationId!==void 0&&(i.location_id=t.locationId);const n={};this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/user-flags",method:"GET",headers:n,query:i},o);return new R(a,s=>s.map(yt))}async getUserFlags(t={},o){return await(await this.getUserFlagsRaw(t,o)).value()}}class Ia extends j{async createUserRaw(t,o){if(t.userInput===null||t.userInput===void 0)throw new E("userInput","Required parameter requestParameters.userInput was null or undefined when calling createUser.");const i={},n={};n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/users",method:"POST",headers:n,query:i,body:da(t.userInput)},o);return new R(a,s=>vt(s))}async createUser(t,o){return await(await this.createUserRaw(t,o)).value()}async getMyAccountsAdminsAndApproversRaw(t,o){const i={};t.isMyAccountRequest!==void 0&&(i.is_my_account_request=t.isMyAccountRequest);const n={};this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/users/admins-and-approvers",method:"GET",headers:n,query:i},o);return new R(a,s=>Wn(s))}async getMyAccountsAdminsAndApprovers(t={},o){return await(await this.getMyAccountsAdminsAndApproversRaw(t,o)).value()}async getUserRaw(t,o){if(t.id===null||t.id===void 0)throw new E("id","Required parameter requestParameters.id was null or undefined when calling getUser.");const i={},n={};this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/users/{id}".replace("{id}",encodeURIComponent(String(t.id))),method:"GET",headers:n,query:i},o);return new R(a,s=>vt(s))}async getUser(t,o){return await(await this.getUserRaw(t,o)).value()}async getUserReportRaw(t,o){const i={};t.accountNumber!==void 0&&(i.account_number=t.accountNumber),t.includeChildAccounts!==void 0&&(i.include_child_accounts=t.includeChildAccounts),t.firstName!==void 0&&(i.first_name=t.firstName),t.lastName!==void 0&&(i.last_name=t.lastName),t.email!==void 0&&(i.email=t.email);const n={};this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/users-report",method:"GET",headers:n,query:i},o);return new co(a)}async getUserReport(t={},o){return await(await this.getUserReportRaw(t,o)).value()}async getUsersRaw(t,o){const i={};t.accountNumber!==void 0&&(i.account_number=t.accountNumber),t.includeChildAccounts!==void 0&&(i.include_child_accounts=t.includeChildAccounts),t.page!==void 0&&(i.page=t.page),t.size!==void 0&&(i.size=t.size),t.firstName!==void 0&&(i.first_name=t.firstName),t.lastName!==void 0&&(i.last_name=t.lastName),t.email!==void 0&&(i.email=t.email),t.sort!==void 0&&(i.sort=t.sort),t.order!==void 0&&(i.order=t.order);const n={};this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/users",method:"GET",headers:n,query:i},o);return new R(a,s=>ma(s))}async getUsers(t={},o){return await(await this.getUsersRaw(t,o)).value()}async updateUserRaw(t,o){if(t.id===null||t.id===void 0)throw new E("id","Required parameter requestParameters.id was null or undefined when calling updateUser.");if(t.userProfile===null||t.userProfile===void 0)throw new E("userProfile","Required parameter requestParameters.userProfile was null or undefined when calling updateUser.");const i={},n={};n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/users/{id}".replace("{id}",encodeURIComponent(String(t.id))),method:"PUT",headers:n,query:i,body:ua(t.userProfile)},o);return new xe(a)}async updateUser(t,o){await this.updateUserRaw(t,o)}}class Ea extends j{async verifyEmailRaw(t,o){if(t.emailVerificationInput===null||t.emailVerificationInput===void 0)throw new E("emailVerificationInput","Required parameter requestParameters.emailVerificationInput was null or undefined when calling verifyEmail.");const i={},n={};n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/user-attr-verification/email",method:"POST",headers:n,query:i,body:jn(t.emailVerificationInput)},o);return new R(a,s=>fa(s))}async verifyEmail(t,o){return await(await this.verifyEmailRaw(t,o)).value()}}const Ra=Fe`
1744
+ `};class hn{constructor(){this.error=void 0,this.loading=!0,this.permissions=[],this.email=void 0,this.accountNumber="",this.accounts=[],this.accountHierarchy=[],this.permissionAssignment=[],qi(this)}setPermissions(t){this.permissions=structuredClone(t)}setError(t){this.error=t}set setLoading(t){this.loading=t}get getLoading(){return this.loading}clearError(){this.error=void 0}getMyPermissions(){return Ne(this.permissionAssignment)}setMyPermissions(t){this.permissionAssignment=structuredClone(t)}getPermissions(){return Ne(this.permissions)}setEmail(t){this.email=t}getEmail(){return this.email}setAccountNumber(t){this.accountNumber=t}getAccountNumber(){return this.accountNumber}setAccounts(t){this.accounts=t}getAccounts(){return Ne(this.accounts)}setAccountHierarchy(t){this.accountHierarchy=t}getAccountHierarchy(){return Ne(this.accountHierarchy)}}const U=new hn,T={user:"User",externalUser:"External User",internalUser:"Internal User",customRoles:"Custom Roles",internalRoles:"Internal Roles",defaultRoles:"Default System Roles",assignInternalRole:"Assign Internal Role"},x={read:"read",update:"update",create:"create",approve:"approve"};function pn(e){return mn(e)}function mn(e,t){return e==null?e:{account_number:f(e,"account_number")?e.account_number:void 0,parent_account_number:f(e,"parent_account_number")?e.parent_account_number:void 0,name:f(e,"name")?e.name:void 0,friendly_name:f(e,"friendly_name")?e.friendly_name:void 0}}function mo(e){return gn(e)}function gn(e,t){return e}function ft(e){return fn(e)}function fn(e,t){return e==null?e:{id:e.id,account_number:e.account_number,account_name:e.account_name,account_friendly_name:e.account_friendly_name,status:mo(e.status),updated_at:e.updated_at,updated_by:e.updated_by,user_id:e.user_id}}function vn(e){if(e!==void 0)return e===null?null:{user_id:e.user_id,account_number:e.account_number,change_history_id:e.change_history_id}}function yn(e){if(e!==void 0)return e===null?null:{status:e.status,change_history_id:e.change_history_id}}function go(e){return bn(e)}function bn(e,t){return e==null?e:{created_at:e.created_at,created_by:e.created_by,authority_document_id:e.authority_document_id,change_history_id:f(e,"change_history_id")?e.change_history_id:void 0,file_name:e.file_name}}function fo(e){return xn(e)}function xn(e,t){return e==null?e:{authority_document_id:e.authority_document_id,change_history_id:f(e,"change_history_id")?e.change_history_id:void 0,file_name:e.file_name}}function vo(e){return wn(e)}function wn(e,t){return e==null?e:{reason:e.reason,authoriser_user_id:f(e,"authoriser_user_id")?e.authoriser_user_id:void 0,account_number:e.account_number}}function An(e){if(e!==void 0)return e===null?null:{reason:e.reason,authoriser_user_id:e.authoriser_user_id,account_number:e.account_number}}function yo(e){return Cn(e)}function Cn(e,t){return e==null?e:{id:f(e,"id")?e.id:void 0,first_name:f(e,"first_name")?e.first_name:void 0,last_name:f(e,"last_name")?e.last_name:void 0,email:f(e,"email")?e.email:void 0}}function bo(e){return _n(e)}function _n(e,t){return e==null?e:{change_history_id:e.change_history_id,authoriser_details:f(e,"authoriser_details")?e.authoriser_details.map(vo):void 0,created_by:yo(e.created_by),created_at:e.created_at,authority_documents:f(e,"authority_documents")?e.authority_documents.map(fo):void 0}}function Tn(e){return In(e)}function In(e,t){return e==null?e:{change_history_id:e.change_history_id,authoriser_details:f(e,"authoriser_details")?e.authoriser_details.map(vo):void 0,created_by:yo(e.created_by),created_at:e.created_at,authority_documents:f(e,"authority_documents")?e.authority_documents.map(fo):void 0}}function En(e){return Rn(e)}function Rn(e,t){return e==null?e:{continuation_token:f(e,"continuation_token")?e.continuation_token:void 0}}function Sn(e){return kn(e)}function kn(e,t){return e==null?e:{content:e.content.map(Tn),pageable:En(e.pageable)}}function Un(e){if(e!==void 0)return e===null?null:{authoriser_details:e.authoriser_details===void 0?void 0:e.authoriser_details.map(An),authority_documents:e.authority_documents}}function $n(e){if(e!==void 0)return e===null?null:{role_id:e.role_id,user_id:e.user_id,account_number:e.account_number,location_id:e.location_id}}function Nn(e){if(e!==void 0)return e===null?null:{RoleAssignmentInput:e.RoleAssignmentInput===void 0?void 0:e.RoleAssignmentInput.map($n),change_history_id:e.change_history_id}}function xo(e){return Fn(e)}function Fn(e,t){return e==null?e:{permission_id:e.permission_id,permission_name:e.permission_name,is_non_location:e.is_non_location,privilege:e.privilege}}function Dn(e){return Pn(e)}function Pn(e,t){return e==null?e:{id:e.id,name:e.name,account_number:f(e,"account_number")?e.account_number:void 0,role_type:e.role_type,permissions:e.permissions.map(xo),status:e.status,message:e.message}}function Mn(e){return On(e)}function On(e,t){return e}function oc(e){return e}function Bn(e){if(e!==void 0)return e===null?null:{user_flag_type:e.user_flag_type,user_id:e.user_id,account_number:e.account_number,location_id:e.location_id}}function Ln(e){if(e!==void 0)return e===null?null:{UserFlagAssignmentInputs:e.UserFlagAssignmentInputs===void 0?void 0:e.UserFlagAssignmentInputs.map(Bn),change_history_id:e.change_history_id}}function De(e){if(e!==void 0)return e===null?null:{permission_id:e.permission_id,privilege:e.privilege}}function qn(e){if(e!==void 0)return e===null?null:{name:e.name,role_type:e.role_type,permissions:e.permissions.map(De),account_number:e.account_number,account_numbers:e.account_numbers}}function Hn(e){if(e!==void 0)return e===null?null:{name:e.name,role_type:e.role_type,permissions:e.permissions.map(De)}}function zn(e){if(e!==void 0)return e===null?null:{email_address:e.email_address}}function Vn(e){if(e!==void 0)return e===null?null:{name:e.name,role_type:e.role_type,permissions:e.permissions.map(De)}}function jn(e){if(e!==void 0)return e===null?null:{name:e.name,role_type:e.role_type,permissions:e.permissions.map(De)}}const wo={AccountAdmininstrator:"ACCOUNT_ADMININSTRATOR",VisitorAccessApprover:"VISITOR_ACCESS_APPROVER",PermanentBadgeApprover:"PERMANENT_BADGE_APPROVER",OnBehalfUserCreator:"ON_BEHALF_USER_CREATOR",OnBehalfUserUpdater:"ON_BEHALF_USER_UPDATER"};function Gn(e){return Jn(e)}function Jn(e,t){return e==null?e:{id:f(e,"id")?e.id:void 0,first_name:f(e,"first_name")?e.first_name:void 0,last_name:f(e,"last_name")?e.last_name:void 0,email:f(e,"email")?e.email:void 0,account_permission_group:f(e,"account_permission_group")?e.account_permission_group:void 0,account_associations:f(e,"account_associations")?e.account_associations:void 0}}function Kn(e){return Zn(e)}function Zn(e,t){return e==null?e:{items:f(e,"items")?e.items.map(Gn):void 0}}function Wn(e){return Qn(e)}function Qn(e,t){return e==null?e:{id:e.id,name:e.name,is_non_location:e.is_non_location,category:f(e,"category")?e.category:void 0,privileges:e.privileges,internal_privileges:e.internal_privileges,is_internal:e.is_internal}}function Yn(e){return Xn(e)}function Xn(e,t){return e==null?e:{account_number:e.account_number,permission_name:e.permission_name,privilege:e.privilege,privilege_is_internal:e.privilege_is_internal,is_non_location:f(e,"is_non_location")?e.is_non_location:void 0,provenance:f(e,"provenance")?e.provenance:void 0}}function Ao(e){return ea(e)}function ea(e,t){return e==null?e:{id:e.id,name:e.name,account_number:f(e,"account_number")?e.account_number:void 0,role_type:e.role_type,permissions:e.permissions.map(xo)}}function vt(e){return ta(e)}function ta(e,t){return e==null?e:{role_id:e.role_id,user_id:e.user_id,account_number:e.account_number,location_id:f(e,"location_id")?e.location_id:void 0,id:e.id,is_active:e.is_active}}function oa(e){if(e!==void 0){if(e===null)return null;switch(e.role_type){case"CUSTOM":return qn(e);case"DEFAULT":return Hn(e);case"GLOBALACCESS":return Vn(e);case"INTERNAL":return jn(e);default:throw new Error(`No variant of RoleCreate exists with 'role_type=${e.role_type}'`)}}}function ia(e){if(e!==void 0)return e===null?null:{role_name:e.role_name,permissions:e.permissions.map(De)}}function na(e){return aa(e)}function aa(e,t){return e==null?e:{id:e.id,account_number:e.account_number,account_name:e.account_name,account_friendly_name:e.account_friendly_name,status:mo(e.status),updated_at:e.updated_at,updated_by:e.updated_by}}function yt(e){return sa(e)}function sa(e,t){return e==null?e:{first_name:e.first_name,last_name:e.last_name,email:e.email,phone:e.phone,evacuation_assistance_required:f(e,"evacuation_assistance_required")?e.evacuation_assistance_required:void 0,id:e.id,is_active:f(e,"is_active")?e.is_active:void 0,account_associations:e.account_associations.map(na)}}function bt(e){return ra(e)}function ra(e,t){return e==null?e:{user_flag_type:Mn(e.user_flag_type),user_id:e.user_id,account_number:e.account_number,location_id:e.location_id,id:e.id,is_active:f(e,"is_active")?e.is_active:void 0}}function la(e){if(e!==void 0)return e===null?null:{first_name:e.first_name,last_name:e.last_name,email:e.email,phone:e.phone,evacuation_assistance_required:e.evacuation_assistance_required,account_numbers:e.account_numbers,change_history_id:e.change_history_id}}function ca(e){if(e!==void 0)return e===null?null:{first_name:e.first_name,last_name:e.last_name,email:e.email,phone:e.phone,evacuation_assistance_required:e.evacuation_assistance_required}}function da(e){return ua(e)}function ua(e,t){return e==null?e:{number:f(e,"number")?e.number:void 0,total_pages:f(e,"total_pages")?e.total_pages:void 0,first:f(e,"first")?e.first:void 0,last:f(e,"last")?e.last:void 0,size:f(e,"size")?e.size:void 0,number_of_elements:f(e,"number_of_elements")?e.number_of_elements:void 0,total_elements:f(e,"total_elements")?e.total_elements:void 0}}function ha(e){return pa(e)}function pa(e,t){return e==null?e:{content:f(e,"content")?e.content.map(yt):void 0,pageable:f(e,"pageable")?da(e.pageable):void 0}}function ma(e){return ga(e)}function ga(e,t){return e==null?e:{email_address:f(e,"email_address")?e.email_address:void 0,is_verified:f(e,"is_verified")?e.is_verified:void 0,reason:f(e,"reason")?e.reason:void 0}}class fa extends j{async createAccountAssociationRaw(t,o){if(t.accountAssociationInput===null||t.accountAssociationInput===void 0)throw new E("accountAssociationInput","Required parameter requestParameters.accountAssociationInput was null or undefined when calling createAccountAssociation.");const i={},n={};n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/account-associations",method:"POST",headers:n,query:i,body:vn(t.accountAssociationInput)},o);return new R(a,s=>ft(s))}async createAccountAssociation(t,o){return await(await this.createAccountAssociationRaw(t,o)).value()}async getAccountAssociationsRaw(t,o){const i={};t.accountNumber!==void 0&&(i.account_number=t.accountNumber),t.userId!==void 0&&(i.user_id=t.userId),t.status!==void 0&&(i.status=t.status);const n={};this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/account-associations",method:"GET",headers:n,query:i},o);return new R(a,s=>s.map(ft))}async getAccountAssociations(t={},o){return await(await this.getAccountAssociationsRaw(t,o)).value()}async getUserAccountAssociationRaw(t,o){if(t.id===null||t.id===void 0)throw new E("id","Required parameter requestParameters.id was null or undefined when calling getUserAccountAssociation.");const i={},n={};this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/account-associations/{id}".replace("{id}",encodeURIComponent(String(t.id))),method:"GET",headers:n,query:i},o);return new R(a,s=>ft(s))}async getUserAccountAssociation(t,o){return await(await this.getUserAccountAssociationRaw(t,o)).value()}async updateAccountAssociationStatusRaw(t,o){if(t.id===null||t.id===void 0)throw new E("id","Required parameter requestParameters.id was null or undefined when calling updateAccountAssociationStatus.");if(t.accountAssociationStatusUpdate===null||t.accountAssociationStatusUpdate===void 0)throw new E("accountAssociationStatusUpdate","Required parameter requestParameters.accountAssociationStatusUpdate was null or undefined when calling updateAccountAssociationStatus.");const i={},n={};n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/account-associations/{id}".replace("{id}",encodeURIComponent(String(t.id))),method:"PATCH",headers:n,query:i,body:yn(t.accountAssociationStatusUpdate)},o);return new xe(a)}async updateAccountAssociationStatus(t,o){await this.updateAccountAssociationStatusRaw(t,o)}}class va extends j{async getAccountsRaw(t){const o={},i={};this.configuration&&this.configuration.accessToken&&(i.Authorization=await this.configuration.accessToken("oAuth2",[]));const n=await this.request({path:"/accounts",method:"GET",headers:i,query:o},t);return new R(n,a=>a.map(pn))}async getAccounts(t){return await(await this.getAccountsRaw(t)).value()}}class ya extends j{async downloadAuthorityDocumentsRaw(t,o){if(t.id===null||t.id===void 0)throw new E("id","Required parameter requestParameters.id was null or undefined when calling downloadAuthorityDocuments.");const i={},n={};this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/authority-documents/{id}/content".replace("{id}",encodeURIComponent(String(t.id))),method:"GET",headers:n,query:i},o);return new lo(a)}async downloadAuthorityDocuments(t,o){return await(await this.downloadAuthorityDocumentsRaw(t,o)).value()}async getAuthorityDocumentRaw(t,o){if(t.id===null||t.id===void 0)throw new E("id","Required parameter requestParameters.id was null or undefined when calling getAuthorityDocument.");const i={},n={};this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/authority-documents/{id}".replace("{id}",encodeURIComponent(String(t.id))),method:"GET",headers:n,query:i},o);return new R(a,s=>go(s))}async getAuthorityDocument(t,o){return await(await this.getAuthorityDocumentRaw(t,o)).value()}async postAuthorityDocumentsRaw(t,o){if(t.file===null||t.file===void 0)throw new E("file","Required parameter requestParameters.file was null or undefined when calling postAuthorityDocuments.");const i={},n={};this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=[{contentType:"multipart/form-data"}],s=rn(a);let l,p=!1;p=s,p?l=new FormData:l=new URLSearchParams,t.file!==void 0&&l.append("file",t.file),t.fileName!==void 0&&l.append("file_name",t.fileName);const h=await this.request({path:"/authority-documents",method:"POST",headers:n,query:i,body:l},o);return new R(h,u=>go(u))}async postAuthorityDocuments(t,o){return await(await this.postAuthorityDocumentsRaw(t,o)).value()}}class ba extends j{async getChangeHistoryRaw(t,o){const i={};t.continuationToken!==void 0&&(i.continuation_token=t.continuationToken),t.sort!==void 0&&(i.sort=t.sort),t.limit!==void 0&&(i.limit=t.limit),t.userId!==void 0&&(i.user_id=t.userId),t.accountNumber!==void 0&&(i.account_number=t.accountNumber);const n={};this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/change-histories",method:"GET",headers:n,query:i},o);return new R(a,s=>Sn(s))}async getChangeHistory(t={},o){return await(await this.getChangeHistoryRaw(t,o)).value()}async getChangeHistoryByIdRaw(t,o){if(t.id===null||t.id===void 0)throw new E("id","Required parameter requestParameters.id was null or undefined when calling getChangeHistoryById.");const i={},n={};this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/change-histories/{id}".replace("{id}",encodeURIComponent(String(t.id))),method:"GET",headers:n,query:i},o);return new R(a,s=>bo(s))}async getChangeHistoryById(t,o){return await(await this.getChangeHistoryByIdRaw(t,o)).value()}async postChangeHistoryRaw(t,o){if(t.changeHistoryRequest===null||t.changeHistoryRequest===void 0)throw new E("changeHistoryRequest","Required parameter requestParameters.changeHistoryRequest was null or undefined when calling postChangeHistory.");const i={},n={};n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/change-histories",method:"POST",headers:n,query:i,body:Un(t.changeHistoryRequest)},o);return new R(a,s=>bo(s))}async postChangeHistory(t,o){return await(await this.postChangeHistoryRaw(t,o)).value()}}class xa extends j{async getPermissionsRaw(t){const o={},i={};this.configuration&&this.configuration.accessToken&&(i.Authorization=await this.configuration.accessToken("oAuth2",[]));const n=await this.request({path:"/permissions",method:"GET",headers:i,query:o},t);return new R(n,a=>a.map(Wn))}async getPermissions(t){return await(await this.getPermissionsRaw(t)).value()}async getUserPermissionsRaw(t,o){const i={};t.excludeSiblings!==void 0&&(i.exclude_siblings=t.excludeSiblings),t.excludeParents!==void 0&&(i.exclude_parents=t.excludeParents);const n={};this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/my-permissions",method:"GET",headers:n,query:i},o);return new R(a,s=>s.map(Yn))}async getUserPermissions(t={},o){return await(await this.getUserPermissionsRaw(t,o)).value()}}class wa extends j{async createRoleAssignmentsRaw(t,o){if(t.createRoleAssignment===null||t.createRoleAssignment===void 0)throw new E("createRoleAssignment","Required parameter requestParameters.createRoleAssignment was null or undefined when calling createRoleAssignments.");const i={},n={};n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/role-assignments",method:"POST",headers:n,query:i,body:Nn(t.createRoleAssignment)},o);return new R(a,s=>s.map(vt))}async createRoleAssignments(t,o){return await(await this.createRoleAssignmentsRaw(t,o)).value()}async deleteRoleAssignmentRaw(t,o){if(t.id===null||t.id===void 0)throw new E("id","Required parameter requestParameters.id was null or undefined when calling deleteRoleAssignment.");const i={};t.changeHistoryId!==void 0&&(i.change_history_id=t.changeHistoryId);const n={};this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/role-assignments/{id}".replace("{id}",encodeURIComponent(String(t.id))),method:"DELETE",headers:n,query:i},o);return new xe(a)}async deleteRoleAssignment(t,o){await this.deleteRoleAssignmentRaw(t,o)}async getRoleAssignmentRaw(t,o){if(t.id===null||t.id===void 0)throw new E("id","Required parameter requestParameters.id was null or undefined when calling getRoleAssignment.");const i={},n={};this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/role-assignments/{id}".replace("{id}",encodeURIComponent(String(t.id))),method:"GET",headers:n,query:i},o);return new R(a,s=>vt(s))}async getRoleAssignment(t,o){return await(await this.getRoleAssignmentRaw(t,o)).value()}async getRoleAssignmentsRaw(t,o){const i={};t.roleId!==void 0&&(i.role_id=t.roleId),t.userId!==void 0&&(i.user_id=t.userId),t.accountNumber!==void 0&&(i.account_number=t.accountNumber),t.locationId!==void 0&&(i.location_id=t.locationId),t.roleType!==void 0&&(i.role_type=t.roleType);const n={};this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/role-assignments",method:"GET",headers:n,query:i},o);return new R(a,s=>s.map(vt))}async getRoleAssignments(t={},o){return await(await this.getRoleAssignmentsRaw(t,o)).value()}}class Aa extends j{async createRoleRaw(t,o){if(t.roleCreate===null||t.roleCreate===void 0)throw new E("roleCreate","Required parameter requestParameters.roleCreate was null or undefined when calling createRole.");const i={},n={};n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/roles",method:"POST",headers:n,query:i,body:oa(t.roleCreate)},o);return new R(a,s=>s.map(Dn))}async createRole(t,o){return await(await this.createRoleRaw(t,o)).value()}async deleteRoleRaw(t,o){if(t.id===null||t.id===void 0)throw new E("id","Required parameter requestParameters.id was null or undefined when calling deleteRole.");const i={},n={};this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/roles/{id}".replace("{id}",encodeURIComponent(String(t.id))),method:"DELETE",headers:n,query:i},o);return new xe(a)}async deleteRole(t,o){await this.deleteRoleRaw(t,o)}async getRoleRaw(t,o){if(t.id===null||t.id===void 0)throw new E("id","Required parameter requestParameters.id was null or undefined when calling getRole.");const i={},n={};this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/roles/{id}".replace("{id}",encodeURIComponent(String(t.id))),method:"GET",headers:n,query:i},o);return new R(a,s=>Ao(s))}async getRole(t,o){return await(await this.getRoleRaw(t,o)).value()}async getRolesRaw(t,o){const i={};t.roleType!==void 0&&(i.role_type=t.roleType);const n={};this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/roles",method:"GET",headers:n,query:i},o);return new R(a,s=>s.map(Ao))}async getRoles(t={},o){return await(await this.getRolesRaw(t,o)).value()}async updateRoleRaw(t,o){if(t.id===null||t.id===void 0)throw new E("id","Required parameter requestParameters.id was null or undefined when calling updateRole.");if(t.roleUpdate===null||t.roleUpdate===void 0)throw new E("roleUpdate","Required parameter requestParameters.roleUpdate was null or undefined when calling updateRole.");const i={},n={};n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/roles/{id}".replace("{id}",encodeURIComponent(String(t.id))),method:"PUT",headers:n,query:i,body:ia(t.roleUpdate)},o);return new xe(a)}async updateRole(t,o){await this.updateRoleRaw(t,o)}}class Ca extends j{async createUserFlagsRaw(t,o){if(t.createUserFlagAssignment===null||t.createUserFlagAssignment===void 0)throw new E("createUserFlagAssignment","Required parameter requestParameters.createUserFlagAssignment was null or undefined when calling createUserFlags.");const i={},n={};n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/user-flags",method:"POST",headers:n,query:i,body:Ln(t.createUserFlagAssignment)},o);return new R(a,s=>s.map(bt))}async createUserFlags(t,o){return await(await this.createUserFlagsRaw(t,o)).value()}async deleteUserFlagRaw(t,o){if(t.id===null||t.id===void 0)throw new E("id","Required parameter requestParameters.id was null or undefined when calling deleteUserFlag.");const i={};t.changeHistoryId!==void 0&&(i.change_history_id=t.changeHistoryId);const n={};this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/user-flags/{id}".replace("{id}",encodeURIComponent(String(t.id))),method:"DELETE",headers:n,query:i},o);return new xe(a)}async deleteUserFlag(t,o){await this.deleteUserFlagRaw(t,o)}async getUserFlagRaw(t,o){if(t.id===null||t.id===void 0)throw new E("id","Required parameter requestParameters.id was null or undefined when calling getUserFlag.");const i={},n={};this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/user-flags/{id}".replace("{id}",encodeURIComponent(String(t.id))),method:"GET",headers:n,query:i},o);return new R(a,s=>bt(s))}async getUserFlag(t,o){return await(await this.getUserFlagRaw(t,o)).value()}async getUserFlagsRaw(t,o){const i={};t.userFlagType!==void 0&&(i.user_flag_type=t.userFlagType),t.userId!==void 0&&(i.user_id=t.userId),t.accountNumber!==void 0&&(i.account_number=t.accountNumber),t.locationId!==void 0&&(i.location_id=t.locationId);const n={};this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/user-flags",method:"GET",headers:n,query:i},o);return new R(a,s=>s.map(bt))}async getUserFlags(t={},o){return await(await this.getUserFlagsRaw(t,o)).value()}}class _a extends j{async createUserRaw(t,o){if(t.userInput===null||t.userInput===void 0)throw new E("userInput","Required parameter requestParameters.userInput was null or undefined when calling createUser.");const i={},n={};n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/users",method:"POST",headers:n,query:i,body:la(t.userInput)},o);return new R(a,s=>yt(s))}async createUser(t,o){return await(await this.createUserRaw(t,o)).value()}async getMyAccountsAdminsAndApproversRaw(t,o){const i={};t.isMyAccountRequest!==void 0&&(i.is_my_account_request=t.isMyAccountRequest);const n={};this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/users/admins-and-approvers",method:"GET",headers:n,query:i},o);return new R(a,s=>Kn(s))}async getMyAccountsAdminsAndApprovers(t={},o){return await(await this.getMyAccountsAdminsAndApproversRaw(t,o)).value()}async getUserRaw(t,o){if(t.id===null||t.id===void 0)throw new E("id","Required parameter requestParameters.id was null or undefined when calling getUser.");const i={},n={};this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/users/{id}".replace("{id}",encodeURIComponent(String(t.id))),method:"GET",headers:n,query:i},o);return new R(a,s=>yt(s))}async getUser(t,o){return await(await this.getUserRaw(t,o)).value()}async getUserReportRaw(t,o){const i={};t.accountNumber!==void 0&&(i.account_number=t.accountNumber),t.includeChildAccounts!==void 0&&(i.include_child_accounts=t.includeChildAccounts),t.firstName!==void 0&&(i.first_name=t.firstName),t.lastName!==void 0&&(i.last_name=t.lastName),t.email!==void 0&&(i.email=t.email);const n={};this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/users-report",method:"GET",headers:n,query:i},o);return new lo(a)}async getUserReport(t={},o){return await(await this.getUserReportRaw(t,o)).value()}async getUsersRaw(t,o){const i={};t.accountNumber!==void 0&&(i.account_number=t.accountNumber),t.includeChildAccounts!==void 0&&(i.include_child_accounts=t.includeChildAccounts),t.page!==void 0&&(i.page=t.page),t.size!==void 0&&(i.size=t.size),t.firstName!==void 0&&(i.first_name=t.firstName),t.lastName!==void 0&&(i.last_name=t.lastName),t.email!==void 0&&(i.email=t.email),t.sort!==void 0&&(i.sort=t.sort),t.order!==void 0&&(i.order=t.order);const n={};this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/users",method:"GET",headers:n,query:i},o);return new R(a,s=>ha(s))}async getUsers(t={},o){return await(await this.getUsersRaw(t,o)).value()}async updateUserRaw(t,o){if(t.id===null||t.id===void 0)throw new E("id","Required parameter requestParameters.id was null or undefined when calling updateUser.");if(t.userProfile===null||t.userProfile===void 0)throw new E("userProfile","Required parameter requestParameters.userProfile was null or undefined when calling updateUser.");const i={},n={};n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/users/{id}".replace("{id}",encodeURIComponent(String(t.id))),method:"PUT",headers:n,query:i,body:ca(t.userProfile)},o);return new xe(a)}async updateUser(t,o){await this.updateUserRaw(t,o)}}class Ta extends j{async verifyEmailRaw(t,o){if(t.emailVerificationInput===null||t.emailVerificationInput===void 0)throw new E("emailVerificationInput","Required parameter requestParameters.emailVerificationInput was null or undefined when calling verifyEmail.");const i={},n={};n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const a=await this.request({path:"/user-attr-verification/email",method:"POST",headers:n,query:i,body:zn(t.emailVerificationInput)},o);return new R(a,s=>ma(s))}async verifyEmail(t,o){return await(await this.verifyEmailRaw(t,o)).value()}}const Ia=Fe`
1745
1745
  fragment RoleFields on RoleInventory {
1746
1746
  id
1747
1747
  accountNumber
@@ -1815,7 +1815,7 @@ video {
1815
1815
  }
1816
1816
  }
1817
1817
  }
1818
- `,Sa=Fe`
1818
+ `,Ea=Fe`
1819
1819
  fragment FlagFields on FlagInventory {
1820
1820
  id
1821
1821
  accountNumber
@@ -1887,7 +1887,7 @@ video {
1887
1887
  }
1888
1888
  }
1889
1889
  }
1890
- `,ka=Fe`
1890
+ `,Ra=Fe`
1891
1891
  fragment AccountFields on AccountInventory {
1892
1892
  id
1893
1893
  accountNumber
@@ -1945,7 +1945,7 @@ video {
1945
1945
  }
1946
1946
  }
1947
1947
  }
1948
- `,Ua=Fe`
1948
+ `,Sa=Fe`
1949
1949
  fragment RoleFields on RoleInventory {
1950
1950
  id
1951
1951
  accountNumber
@@ -1987,7 +1987,7 @@ video {
1987
1987
  }
1988
1988
  }
1989
1989
  }
1990
- `,$a=Fe`
1990
+ `,ka=Fe`
1991
1991
  fragment FlagFields on FlagInventory {
1992
1992
  id
1993
1993
  accountNumber
@@ -2029,7 +2029,7 @@ video {
2029
2029
  }
2030
2030
  }
2031
2031
  }
2032
- `;class Na{constructor(t){this.config=t,this.gqlClient=new ji(this.config.url),this.config.accessToken&&this.gqlClient.setHeader("authorization",this.config.accessToken)}async GetRolesInventory(t){var o;return(o=this.gqlClient)===null||o===void 0?void 0:o.request(Ra,{...t})}async GetFlagsInventory(t){var o;return(o=this.gqlClient)===null||o===void 0?void 0:o.request(Sa,{...t})}async GetAccountInventory(t){var o;return(o=this.gqlClient)===null||o===void 0?void 0:o.request(ka,{...t})}async SaveAccountRoleAssignments(t){var o;return(o=this.gqlClient)===null||o===void 0?void 0:o.request(Ua,{...t})}async SaveAccountFlagAssignments(t){var o;return(o=this.gqlClient)===null||o===void 0?void 0:o.request($a,{...t})}}const Fa="http://localhost".replace(/\/+$/,"");class _o{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:Fa}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||To}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const Da=new _o;class pt{constructor(t=Da){this.configuration=t,this.fetchApi=async(o,i)=>{let n={url:o,init:i};for(const s of this.middleware)s.pre&&(n=await s.pre({fetch:this.fetchApi,...n})||n);let a;try{a=await(this.configuration.fetchApi||fetch)(n.url,n.init)}catch(s){for(const l of this.middleware)l.onError&&(a=await l.onError({fetch:this.fetchApi,url:n.url,init:n.init,error:s,response:a?a.clone():void 0})||a);if(a===void 0)throw s instanceof Error?new Ba(s,"The request failed and the interceptors did not return an alternative response"):s}for(const s of this.middleware)s.post&&(a=await s.post({fetch:this.fetchApi,url:n.url,init:n.init,response:a.clone()})||a);return a},this.middleware=t.middleware}withMiddleware(...t){const o=this.clone();return o.middleware=o.middleware.concat(...t),o}withPreMiddleware(...t){const o=t.map(i=>({pre:i}));return this.withMiddleware(...o)}withPostMiddleware(...t){const o=t.map(i=>({post:i}));return this.withMiddleware(...o)}isJsonMime(t){return t?pt.jsonRegex.test(t):!1}async request(t,o){const{url:i,init:n}=await this.createFetchParams(t,o),a=await this.fetchApi(i,n);if(a&&a.status>=200&&a.status<300)return a;throw new Oa(a,"Response returned an error code")}async createFetchParams(t,o){let i=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(i+="?"+this.configuration.queryParamsStringify(t.query));const n=Object.assign({},this.configuration.headers,t.headers);Object.keys(n).forEach(u=>n[u]===void 0?delete n[u]:{});const a=typeof o=="function"?o:async()=>o,s={method:t.method,headers:n,body:t.body,credentials:this.configuration.credentials},l={...s,...await a({init:s,context:t})};let p;Ma(l.body)||l.body instanceof URLSearchParams||Pa(l.body)?p=l.body:this.isJsonMime(n["Content-Type"])?p=JSON.stringify(l.body):p=l.body;const h={...l,body:p};return{url:i,init:h}}clone(){const t=this.constructor,o=new t(this.configuration);return o.middleware=this.middleware.slice(),o}}pt.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function Pa(e){return typeof Blob<"u"&&e instanceof Blob}function Ma(e){return typeof FormData<"u"&&e instanceof FormData}class Oa extends Error{constructor(t,o){super(o),this.response=t,this.name="ResponseError"}}class Ba extends Error{constructor(t,o){super(o),this.cause=t,this.name="FetchError"}}class La extends Error{constructor(t,o){super(o),this.field=t,this.name="RequiredError"}}function re(e,t){return e[t]!=null}function To(e,t=""){return Object.keys(e).map(o=>Io(o,e[o],t)).filter(o=>o.length>0).join("&")}function Io(e,t,o=""){const i=o+(o.length?`[${e}]`:e);if(t instanceof Array){const n=t.map(a=>encodeURIComponent(String(a))).join(`&${encodeURIComponent(i)}=`);return`${encodeURIComponent(i)}=${n}`}if(t instanceof Set){const n=Array.from(t);return Io(e,n,o)}return t instanceof Date?`${encodeURIComponent(i)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?To(t,i):`${encodeURIComponent(i)}=${encodeURIComponent(String(t))}`}class Eo{constructor(t,o=i=>i){this.raw=t,this.transformer=o}async value(){return this.transformer(await this.raw.json())}}function Ro(e){return qa(e)}function qa(e,t){return e==null?e:{firstName:re(e,"firstName")?e.firstName:void 0,lastName:re(e,"lastName")?e.lastName:void 0,contactPhoneNumber:re(e,"contactPhoneNumber")?e.contactPhoneNumber:void 0,preferredLanguage:re(e,"preferredLanguage")?e.preferredLanguage:void 0,preferredTimezone:re(e,"preferredTimezone")?e.preferredTimezone:void 0,timezoneOverridden:re(e,"timezoneOverridden")?e.timezoneOverridden:void 0,preferredDateFormat:re(e,"preferredDateFormat")?e.preferredDateFormat:void 0,preferredTimeFormat:re(e,"preferredTimeFormat")?e.preferredTimeFormat:void 0,email:re(e,"email")?e.email:void 0}}function Ha(e){if(e!==void 0)return e===null?null:{firstName:e.firstName,lastName:e.lastName,contactPhoneNumber:e.contactPhoneNumber,preferredLanguage:e.preferredLanguage,preferredTimezone:e.preferredTimezone,timezoneOverridden:e.timezoneOverridden,preferredDateFormat:e.preferredDateFormat,preferredTimeFormat:e.preferredTimeFormat}}class za extends pt{async getUserSettingsRaw(t){const o={},i={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,s=await a("bearerToken",[]);s&&(i.Authorization=`Bearer ${s}`)}const n=await this.request({path:"/user-profile",method:"GET",headers:i,query:o},t);return new Eo(n,a=>Ro(a))}async getUserSettings(t){return await(await this.getUserSettingsRaw(t)).value()}async userProfilePatchRaw(t,o){if(t.profileSettingEditInput===null||t.profileSettingEditInput===void 0)throw new La("profileSettingEditInput","Required parameter requestParameters.profileSettingEditInput was null or undefined when calling userProfilePatch.");const i={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const s=this.configuration.accessToken,l=await s("bearerToken",[]);l&&(n.Authorization=`Bearer ${l}`)}const a=await this.request({path:"/user-profile",method:"PATCH",headers:n,query:i,body:Ha(t.profileSettingEditInput)},o);return new Eo(a,s=>Ro(s))}async userProfilePatch(t,o){return await(await this.userProfilePatchRaw(t,o)).value()}}class Va{constructor(t){this.configuration=t}get InventoryApi(){return new Na({url:this.configuration.userManagementAggregationApiUrl,accessToken:this.getToken()})}get UsersApi(){return new Ia(new Y({basePath:this.configuration.userManagementApiUrl,accessToken:this.getToken()}))}get AccountAssociationApi(){return new ya(new Y({basePath:this.configuration.userManagementApiUrl,accessToken:this.getToken()}))}get AccountsApi(){return new ba(new Y({basePath:this.configuration.userManagementApiUrl,accessToken:this.getToken()}))}get RolesApi(){return new _a(new Y({basePath:this.configuration.userManagementApiUrl,accessToken:this.getToken()}))}get PermissionsApi(){return new Aa(new Y({basePath:this.configuration.userManagementApiUrl,accessToken:this.getToken()}))}get RoleAssignmentsApi(){return new Ca(new Y({basePath:this.configuration.userManagementApiUrl,accessToken:this.getToken()}))}get UserFlagsApi(){return new Ta(new Y({basePath:this.configuration.userManagementApiUrl,accessToken:this.getToken()}))}get VerificationApi(){return new Ea(new Y({basePath:this.configuration.userManagementApiUrl,accessToken:this.getToken()}))}get ChangeHistoriesApi(){return new wa(new Y({basePath:this.configuration.userManagementApiUrl,accessToken:this.getToken()}))}get AuthorityDocumentsApi(){return new xa(new Y({basePath:this.configuration.userManagementApiUrl,accessToken:this.getToken()}))}get UserProfileSettingsApi(){var t;const o=((t=this.getToken())!==null&&t!==void 0?t:"").replace(/^Bearer\s+/i,""),i={};return new za(new _o({basePath:this.configuration.LoginAuthority,accessToken:o,headers:i}))}getToken(){return this.configuration.getTokenFn?this.configuration.getTokenFn():void 0}}class ja extends Gi{constructor(t,o){super({...t}),this.hashed_identifier="",this.email="",this.account_number="",this.hashed_identifier=o}get getEmail(){var t;return(t=this.email)!==null&&t!==void 0?t:this.profile.email}get getAccount(){var t;return(t=this.account_number)!==null&&t!==void 0?t:this.profile.account_number}}class Ve{constructor({loginAuthority:t,clientId:o,scope:i,postLogoutRedirectUri:n,userStorageKey:a=N().UserManagement.UI.UserManagementUIStorageKey,xauthStorageKey:s=N().UserManagement.UI.UserManagementXAuthUIStorageKey,redirectUrlKey:l="redirect-url",authPaths:p={authenticate:"authenticate",authCallback:"auth-callback",logout:"logout"}}){this.configuration={loginAuthority:t,clientId:o,scope:i,postLogoutRedirectUri:n,userStorageKey:a,xauthStorageKey:s,redirectUrlKey:l,authPaths:p};const{location:h}=window,u=`${h.protocol}//${h.hostname}${h.port?`:${h.port}`:""}`,b={authority:this.configuration.loginAuthority,client_id:this.configuration.clientId,redirect_uri:`${u}/${this.configuration.authPaths.authCallback}`,response_type:"code",scope:this.configuration.scope,post_logout_redirect_uri:this.configuration.postLogoutRedirectUri,loadUserInfo:!0};this.userManager=new Ji(b)}isLoggedIn(){const t=this.getUser();if(t===null)return!1;if(!t.expires_at)return!0;const o=new Date,i=new Date(t.expires_at*1e3);return o<i}redirectToAuth(t=!1){const o=this.isAuthenticating();(t||!o)&&(o||localStorage.setItem(this.configuration.redirectUrlKey,window.location.href),window.location.href=`/${this.configuration.authPaths.authenticate}`)}isAuthenticating(){const t=window.location.pathname.split("/");return t[t.length-1]===this.configuration.authPaths.authenticate?(this.userManager.signinRedirect(),!0):!1}isHandlingAuthCallback(){const t=window.location.pathname.split("/");return t[t.length-1]===this.configuration.authPaths.authCallback?(this.userManager.signinRedirectCallback().then(Ve.ensureValidUser).then(Ve.addHashedIdToUserProfile).then(o=>this.saveUser(o)).then(()=>this.authSuccessRedirect()).catch(()=>this.redirectToAuth()),!0):!1}authSuccessRedirect(){let t="/";const o=localStorage.getItem(this.configuration.redirectUrlKey);o&&(localStorage.removeItem(this.configuration.redirectUrlKey),t=o),window.location.href=t}redirectToLogout(){this.isHandlingLogout()||(window.location.href=`/${this.configuration.authPaths.logout}`)}isHandlingLogout(){const t=window.location.pathname.split("/");return t[t.length-1]===this.configuration.authPaths.logout?(this.clearUser(),window.localStorage.clear(),this.userManager.signoutRedirect({id_token_hint:this.getIdToken()}),!0):!1}isProcessing(){return this.isAuthenticating()||this.isHandlingAuthCallback()||this.isHandlingLogout()}saveUser(t){localStorage.setItem(this.configuration.userStorageKey,JSON.stringify(t))}clearUser(){localStorage.removeItem(this.configuration.userStorageKey)}getXAuthUser(){const t=localStorage.getItem(this.configuration.xauthStorageKey);if(t){const o=JSON.parse(t);if(o!=null&&o.email&&o!=null&&o.account_number)return o}}getTokenUser(){const t=localStorage.getItem(this.configuration.userStorageKey);if(t)return JSON.parse(t)}getUser(){const t=this.getTokenUser();return t?(t.profile.email||(t.profile.email=this.getXAuthUser().email),t!=null?t:null):null}getUserDetails(){const t={accountNumber:"",email:""},o=this.getUser();return o&&(t.accountNumber=o.profile.account_number,t.email=o.profile.email),t}getUserProfileSub(){var t;const o=this.getUser();return(t=o==null?void 0:o.profile)===null||t===void 0?void 0:t.sub}getUserLocale(){var t;const o=this.getUser();return(t=o==null?void 0:o.profile)===null||t===void 0?void 0:t.locale}getIdToken(){var t;return(t=this.getUser())===null||t===void 0?void 0:t.id_token}getAccessToken(){var t;return`Bearer ${(t=this.getUser())===null||t===void 0?void 0:t.access_token}`}static async hashValue(t){const o=new TextEncoder().encode(t),i=await crypto.subtle.digest("SHA-256",o);return Array.from(new Uint8Array(i)).map(n=>n.toString(16).padStart(2,"0")).join("")}static async addHashedIdToUserProfile(t){const o=`${t.profile.sub}-${t.profile.customer_id}`,i=await Ve.hashValue(o);return new ja(t,i)}static ensureValidUser(t){if(!t.id_token)throw new Error("Missing property:id_token");return t}}const we=N(),Ae=new Ve({loginAuthority:we.LoginAuthority,clientId:we.LoginService.UserManagementUIClientId,scope:we.LoginService.UserManagementUIScopes}),v=new Va({userManagementApiUrl:we.UserManagement.UI.UserManagementApiUrl,userManagementAggregationApiUrl:we.UserManagement.UI.UserManagementAggregationApiUrl,LoginAuthority:we.LoginAuthority,getTokenFn:()=>Ae.getAccessToken()});var Ga="Alerts",Ja="Content",Ka="DCIM",Za="Invoices",Wa="Marketplace",Qa="Release",Ya="Security",Xa={"Account Information":"Account Information",Alerts:Ga,"Cloud Connect":"Cloud Connect",Content:Ja,"Cross Connect":"Cross Connect","Custom Role":"Custom Role","Custom Roles":"Custom Roles","Customer Equipment Connection (CEC)":"Customer Equipment Connection (CEC)","Customer Support":"Customer Care","Customer Support Team":"Customer Support Team",DCIM:Ka,"DCIM-enabled location data":"DCIM-enabled location data","Default System Roles":"Default System Roles","EMEA MarketPlace":"EMEA MarketPlace","External User":"External User","Internal Roles":"Internal Roles","Internal User":"Internal User","Internet Exchange":"Internet Exchange","Intra-Customer Connectivity (ICC)":"Intra-Customer Connectivity (ICC)",Invoices:Za,"IP Bandwidth":"IP Bandwidth",Marketplace:Wa,"OSP Access":"OSP Access","Permanent Badge":"Permanent Badge","Planned Site Maintenance":"Maintenance & Incident Notifications","PoP/POE Room Access":"PoP/POE Room Access",Release:Qa,"Remote Hands":"Remote Hands","Remote Hands Package":"Remote Hands Package",Security:Ya,"Service Exchange Cloud Router":"Service Exchange Cloud Router","Service Exchange Port":"Service Exchange Port","Shipping & Receiving":"Deliveries & Removals","Space & Power":"Space & Power","Trouble Ticket":"Trouble Ticket","Visitor Access":"Visitor Access"};Xt.use(Ki).init({resources:{en:{translation:{...Xa}}},interpolation:{escapeValue:!1},lng:"en",debug:!1});const So=e=>Xt.t(e),es=e=>{const t=[];return e.forEach(o=>{t.push({id:o.id,name:So(o.name),isNonLocation:o.is_non_location,category:o.category,privileges:o.privileges,internalPrivileges:o.internal_privileges,isInternal:o.is_internal})}),t},ts=e=>{const t=[];return e.forEach(o=>{t.push({accountNumber:o.account_number,permissionName:So(o.permission_name),privilege:o.privilege})}),t};class os{async get(){try{const t=await v.PermissionsApi.getPermissions();return es(t)}catch(t){return g.handleError(t,"Could not get permissions."),[]}}async getMyPermissions(t){try{const o=await v.PermissionsApi.getUserPermissions(t);return ts(o)}catch(o){return g.handleError(o,"Could not retrieve current user's permissions."),[]}}}const Ze=new os,is=e=>{const t=[];return e.forEach(o=>{t.push({accountNumber:o.account_number,name:o.name,parentAccountNumber:o.parent_account_number,displayName:o.friendly_name})}),t};class ns{async get(){try{const t=await v.AccountsApi.getAccounts();return is(t)}catch(t){return g.handleError(t,"Failed to get accounts."),[]}}}const ko=new ns;class as{async getUserProfile(){try{return await v.UserProfileSettingsApi.getUserSettings()}catch(t){g.handleError(t,"Failed to get user profile.");return}}async updateUserProfile(t){try{return await v.UserProfileSettingsApi.userProfilePatch(t)}catch(o){g.handleError(o,"Failed to update user profile.");return}}}const bt=new as;class ss{constructor(){this.myPermissions=[]}isProfileOfLoggedInUser(t){var o;return((o=U==null?void 0:U.getEmail())===null||o===void 0?void 0:o.toLowerCase())===(t==null?void 0:t.toLowerCase())}hasUserRead(t){return this.hasPermission(T.user,x.read,t)}hasUserUpdate(t){return this.hasPermission(T.user,x.update,t)}hasExternalUserRead(t){return N().UserManagement.InternalUserRetired?this.hasPermission(T.user,x.read,t):this.hasPermission(T.externalUser,x.read,t)}hasExternalUserUpdate(t){return N().UserManagement.InternalUserRetired?this.hasPermission(T.user,x.update,t):this.hasPermission(T.externalUser,x.update,t)}hasExternalUserCreate(t){return N().UserManagement.InternalUserRetired?this.hasPermission(T.user,x.create,t):this.hasPermission(T.externalUser,x.create,t)}hasInternalUserRead(t){return N().UserManagement.InternalUserRetired?this.hasPermission(T.user,x.read,t):this.hasPermission(T.internalUser,x.read,t)}hasInternalUserUpdate(t){return N().UserManagement.InternalUserRetired?this.hasPermission(T.user,x.update,t):this.hasPermission(T.internalUser,x.update,t)}hasCustomRolesApprove(t){return this.hasPermission(T.customRoles,x.approve,t)}hasCustomRolesCreate(t){return this.hasPermission(T.customRoles,x.create,t)}hasCustomRolesUpdate(t){return this.hasPermission(T.customRoles,x.update,t)}hasCustomRolesRead(t){return this.hasPermission(T.customRoles,x.read,t)}hasInternalRolesCreate(t){return this.hasPermission(T.internalRoles,x.create,t)}hasInternalRolesUpdate(t){return this.hasPermission(T.internalRoles,x.update,t)}hasInternalRolesRead(t){return this.hasPermission(T.internalRoles,x.read,t)}hasDefaultSystemRolesCreate(t){return this.hasPermission(T.defaultRoles,x.create,t)}hasDefaultSystemRolesUpdate(t){return this.hasPermission(T.defaultRoles,x.update,t)}hasDefaultSystemRolesRead(t){return this.hasPermission(T.defaultRoles,x.read,t)}hasRoleManagementAccess(t){return this.hasPermission(T.defaultRoles,x.read,t)||this.hasPermission(T.customRoles,x.read,t)||this.hasPermission(T.internalRoles,x.read,t)||this.hasPermission(T.externalUser,x.read,t)}hasUserManagementAccess(){return N().UserManagement.InternalUserRetired?this.hasUserRead():this.hasExternalUserRead()||this.hasInternalUserRead()}hasAssignInternalRoleCreate(t){return this.hasPermission(T.assignInternalRole,x.create,t)}hasDLRDomain(){var t;const o=(t=U.getEmail())===null||t===void 0?void 0:t.toLowerCase().trim(),i=N();let n=!1;return i.InternalUserDomainWhitelist.split(",").forEach(a=>{const s=a.toLowerCase().trim();s&&o!=null&&o.endsWith(s)&&(n=!0)}),n}async refreshPermissions(){this.myPermissions=await Ze.getMyPermissions({excludeParents:!1,excludeSiblings:!0})}async refreshAccounts(){const t=await ko.get();U.setAccounts(t)}async getUserProfileSettings(){return bt.getUserProfile()}hasPrivilegeLevel(t,o){const i=[x.approve,x.create,x.update,x.read],n=i.findIndex(s=>s===t.toLowerCase()),a=i.findIndex(s=>s===o.toLowerCase());return n>=a}hasPermission(t,o,i){let{myPermissions:n}=this,a=!1;return i&&(n=n.filter(s=>s.accountNumber===i)),n.length&&o&&(a=n.some(s=>s.permissionName===t&&this.hasPrivilegeLevel(o,s.privilege))),a}}const B=new ss,Uo="uppercase font-bold tracking-wider",$o={LocalStorage:{},SessionStorage:{HasOutstandingChanges:"hasOutstandingChanges"}};let xt=class extends I{constructor(){super(...arguments),this.routeName=null}return(){window.sessionStorage.getItem($o.SessionStorage.HasOutstandingChanges)!=="true"&&this.routeName&&Qe(this.routeName)}render(){return c` <ix-button appearance="text" has-icon @click="${this.return}" data-testid="um-back-button"> <md-icon slot="icon">arrow_back</md-icon> <span class="${Uo}">Back</span> </ix-button>`}};r([d()],xt.prototype,"routeName",void 0),xt=r([A("um-back-button")],xt);const Pe=(e,t,o)=>{e.dispatchEvent(new CustomEvent(t,{detail:o,bubbles:!0,composed:!0}))};let No=class extends I{dispatchCreateUserEvent(){Pe(this,S.CreateUserClicked)}render(){return c` <ix-button @click="${this.dispatchCreateUserEvent}" has-icon> <md-icon slot="icon">add</md-icon> <span class="${Uo}">Create User</span> </ix-button>`}};No=r([A("um-create-user-button")],No);const G={Home:"Home",UserManagement:"User Management",RoleManagement:"Role Management",UserManagementDetails:"User Management Details"},Fo=[{name:G.Home,path:"(/?)",component:"home-view",action:()=>{import("./ui-user-management2.js")}},{name:G.UserManagement,path:"/user-management",component:"user-management-view",headerRight:c``,action:async()=>{B.hasUserManagementAccess()?import("./ui-user-management3.js"):ye.go("/")}},{name:G.RoleManagement,path:"/role-management",component:"role-management-view",action:async()=>{B.hasRoleManagementAccess()?import("./ui-user-management4.js"):ye.go("/")}},{name:G.UserManagementDetails,path:"/user-management-details",component:"user-management-details-view",hideAccountSwitcher:!0,headerLeft:c`<um-back-button routeName="${G.UserManagement}"></um-back-button>`,action:async()=>{B.hasUserManagementAccess()?import("./ui-user-management6.js"):ye.go("/")}}];let oe=null;function Do(){const{pathname:e,search:t,hash:o}=window.location;ye.go({pathname:e,search:t,hash:o})}function rs(e,t,o){const i=o.map(n=>({...n,path:`${t}${n.path}`,redirect:n.redirect?`${t}${n.redirect}`:null}));i.push({path:"(.*)",component:"no-elem"}),oe=new ye(e),oe.setRoutes(i),window.addEventListener("shell-after-navigate",Do)}function ls(){return oe}function cs(){oe==null||oe.unsubscribe(),oe==null||oe.removeRoutes(),oe=null,window.removeEventListener("shell-after-navigate",Do)}function We(e,t){return oe&&oe.urlForName(e,t)}function Qe(e,t){const o=We(e);o&&ye.go({pathname:o,hash:t})}const ds=e=>{var t,o,i,n,a,s;const l=Fo.find(h=>h.name===e),p=(s=(a=(n=(i=(o=(t=window.document.querySelector("gp-bootstrap"))===null||t===void 0?void 0:t.shadowRoot)===null||o===void 0?void 0:o.querySelector("global-portal-app"))===null||i===void 0?void 0:i.shadowRoot)===null||n===void 0?void 0:n.querySelector("ui-user-management"))===null||a===void 0?void 0:a.getAttribute("baseurl"))!==null&&s!==void 0?s:"";return window.location.pathname===`${p}${l==null?void 0:l.path}`};let wt=class extends Ue{constructor(){super(...arguments),this.setNavigationItemsBinding=this.setNavigationItems.bind(this),this.navigationItems=[],this.compact=!1}static get styles(){return[po,_]}connectedCallback(){super.connectedCallback(),window.addEventListener(S.RouteChanged,this.setNavigationItemsBinding)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener(S.RouteChanged,this.setNavigationItemsBinding)}setNavigationItems(){this.requestUpdate(),!this.navigationItems.length&&(this.navigationItems=[{href:We(G.UserManagement),title:"User Management",icon:c`<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" fill="white"> ${Ke.userManagementIcon} </svg>`},{href:We(G.RoleManagement),title:"Role Management",icon:c`<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" fill="white"> ${Ke.roleManagementIcon} </svg>`}])}toggleCompact(){Pe(this,S.ToggleNavBar),setTimeout(()=>{window.dispatchEvent(new Event("resize"))},301)}renderNavigation(){return B.hasExternalUserRead()?c`${this.navigationItems.map(e=>c` <li class="relative m-1"> <div class="${e.href===window.location.pathname?"bg-white opacity-[.16] inset-0 rounded-md absolute":""}"></div> <a href="${e.href}" class="${e.href===window.location.pathname?"flex px-6 py-4 gap-4 rounded-md font-bold":"flex px-6 py-4 gap-4 rounded-md font-bold opacity-60"}"> <div class="w-6 shrink-0">${e.icon}</div> <div class="grow text-left"> <div class="${this.compact?"w-0":"w-full"} animate-width overflow-hidden"> ${e.title} </div> </div> </a> </li> `)}`:y}render(){return c` <ix-icon-button @click="${this.toggleCompact}" icon="chevron_right" class="drop-shadow-lg items-center expand-cta bg-white rounded-full text-slate-600 h-8 w-8 absolute z-20 lg:right-0 lg:top-[34px] hidden top-[27px] right-[-8px] sm:flex ${this.compact?"animate-spin-180-backwards":"animate-spin-180-forwards"}"> </ix-icon-button> <nav class="flex flex-col overflow-hidden min-h-full rounded-xl drop-shadow text-center nav-bar long text-white ${this.compact?"closed":""} whitespace-nowrap animate-width"> <div class="m-1 px-6 py-4 hidden sm:block"> <svg @click="${this.toggleCompact}" focusable="false" viewBox="0 0 178 27" fill="white" class="w-[200px]"> ${Ke.digitalRealtyLogoWithText} </svg> </div> <hr class="divider hidden sm:block"> <ul class="grow"> ${this.renderNavigation()} </ul> <dev-clear-storage-button class="white-icon self-start p-5"></dev-clear-storage-button> </nav> `}};r([d({type:Boolean})],wt.prototype,"compact",void 0),wt=r([A("navigation-bar")],wt);const us=$`ix-dialog{--md-dialog-container-color:#fff}ix-icon-button{--md-sys-color-on-surface-variant:var(--md-sys-color-primary)}ix-select{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd;--md-menu-container-color:#fff}ix-select.thick{--md-menu-container-shape:10px}ix-select.slim{--md-outlined-field-bottom-space:2px;--md-outlined-field-top-space:2px}ix-button{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd}ix-button .disabled{color:var(--md-sys-text-color-disabled)}.btn_primary{--md-filled-button-container-color:var(--md-sys-color-primary)}.btn_primary ix-icon{color:var(--md-sys-color-on-primary)}.btn_secondary{--md-filled-button-container-color:var(--md-sys-color-secondary)}.btn_secondary ix-icon{color:var(--md-sys-color-on-secondary)}.btn_tertiary{--md-filled-button-container-color:var(--md-sys-color-tertiary)}.btn_tertiary ix-icon{color:var(--md-sys-color-on-tertiary)}.btn_danger{--md-filled-button-container-color:var(--md-sys-color-error)}.btn_danger ix-icon{color:var(--md-sys-color-on-error)}.icon-btn_primary ix-icon{color:var(--md-sys-color-primary)}.icon-btn_secondary ix-icon{color:var(--md-sys-color-secondary)}.icon-btn_tertiary ix-icon{color:var(--md-sys-color-tertiary)}.icon-btn_danger ix-icon{color:var(--md-sys-color-error)}ix-icon.icon-lg{--ix-icon-font-size:32px}.dialog-form{min-width:500px;display:flex;flex-direction:column;justify-content:space-between;padding:8px 24px 20px}.dialog-form .textfield{width:100%}.dialog-form.sm{min-width:560px}.dialog-form__textbox{padding-top:1rem}.dialog-actions{display:flex;justify-content:flex-end;padding:8px 15px 8px 20px}@media only screen and (min-width:5px) and (max-width:600px){ix-dialog{--md-dialog-container-shape:6px}}@media only screen and (min-width:601px){ix-dialog{--md-dialog-container-shape:3px}}.header-container{display:flex;align-items:center;margin-bottom:16px}.header-container-back-btn{display:flex;flex-direction:row;justify-content:space-between;align-items:center}.back{padding-left:12px}.arrow-back-icon{font-size:22px;align-items:center;padding-right:1px}.header-rhs-actions{display:flex;flex-direction:row;justify-content:space-between;align-items:center}.profile{background-color:#092241;height:35px;margin-right:30px;margin-left:30px;border-radius:10px;color:#fff;padding-left:20px;padding-right:20px;display:flex;align-items:center}.logout{height:35px;border-radius:10px;border:none;background-color:#1456e0;color:#fff;cursor:pointer;display:flex;align-items:center;justify-content:center;padding-left:15px;padding-right:15px}.logout svg{width:1em;height:1em;font-size:20px;margin-right:5px}.add-icon{font-size:20px;align-items:center}`;let Ce=class extends Ue{constructor(){super(...arguments),this.updateLayoutBinding=this.updateLayout.bind(this),this.pageTitle="",this.showCreateUserButton=!1,this.showHeader=!0}connectedCallback(){super.connectedCallback(),window.addEventListener(S.RouteChanged,this.updateLayoutBinding)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener(S.RouteChanged,this.updateLayoutBinding)}updateLayout(e){switch(this.pageTitle=e.detail.location.route.name||"",this.pageTitle){case"User Management":this.showCreateUserButton=B.hasExternalUserCreate(),this.showHeader=!0;break;case"Role Management":this.showCreateUserButton=!1,this.showHeader=!0;break;case"User Management Details":this.showCreateUserButton=!1,this.showHeader=!1;break}}getRoute(){return this.pageTitle==="User Management Details"?G.UserManagement:G.Home}dispatchCreateUserEvent(){Pe(this,S.CreateUser)}renderAppHeader(){return c` <div class="flex gap-2 items-center mt-4 mb-8 justify-between"> <div> ${this.showHeader?c`<h1 class="dlr-text-page-title">${this.pageTitle}</h1>`:c` <um-back-button .routeName="${this.getRoute()}"></um-back-button> `} </div> <div class="items-center flex gap-2 flex-wrap justify-end"> ${this.showCreateUserButton?c` <ix-button @click="${this.dispatchCreateUserEvent}" has-icon data-testid="create-user-button"> Create User <md-icon slot="icon">add</md-icon> </ix-button> `:y} </div> </div> `}render(){return c`${this.renderAppHeader()}`}};Ce.styles=[_,us],r([d({type:String})],Ce.prototype,"pageTitle",void 0),r([m()],Ce.prototype,"showCreateUserButton",void 0),r([m()],Ce.prototype,"showHeader",void 0),Ce=r([A("app-header")],Ce);const Po=$`ix-dialog{--md-dialog-container-color:#fff}ix-icon-button{--md-sys-color-on-surface-variant:var(--md-sys-color-primary)}ix-select{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd;--md-menu-container-color:#fff}ix-select.thick{--md-menu-container-shape:10px}ix-select.slim{--md-outlined-field-bottom-space:2px;--md-outlined-field-top-space:2px}ix-button{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd}ix-button .disabled{color:var(--md-sys-text-color-disabled)}.btn_primary{--md-filled-button-container-color:var(--md-sys-color-primary)}.btn_primary ix-icon{color:var(--md-sys-color-on-primary)}.btn_secondary{--md-filled-button-container-color:var(--md-sys-color-secondary)}.btn_secondary ix-icon{color:var(--md-sys-color-on-secondary)}.btn_tertiary{--md-filled-button-container-color:var(--md-sys-color-tertiary)}.btn_tertiary ix-icon{color:var(--md-sys-color-on-tertiary)}.btn_danger{--md-filled-button-container-color:var(--md-sys-color-error)}.btn_danger ix-icon{color:var(--md-sys-color-on-error)}.icon-btn_primary ix-icon{color:var(--md-sys-color-primary)}.icon-btn_secondary ix-icon{color:var(--md-sys-color-secondary)}.icon-btn_tertiary ix-icon{color:var(--md-sys-color-tertiary)}.icon-btn_danger ix-icon{color:var(--md-sys-color-error)}ix-icon.icon-lg{--ix-icon-font-size:32px}.dialog-form{min-width:500px;display:flex;flex-direction:column;justify-content:space-between;padding:8px 24px 20px}.dialog-form .textfield{width:100%}.dialog-form.sm{min-width:560px}.dialog-form__textbox{padding-top:1rem}.dialog-actions{display:flex;justify-content:flex-end;padding:8px 15px 8px 20px}@media only screen and (min-width:5px) and (max-width:600px){ix-dialog{--md-dialog-container-shape:6px}}@media only screen and (min-width:601px){ix-dialog{--md-dialog-container-shape:3px}}:host{--md-outlined-text-field-label-text-color:black}.input-group{display:flex;flex-direction:row;gap:20px;margin-bottom:20px}.input-group ix-phone-input,.input-group ix-textbox{flex:1}.textfield{width:100%}ix-button{font-family:var(--root-secondary-font)}@media screen and (max-width:600px){.input-group{flex-direction:column}}`,J=e=>e?e.component.value:null,Ye=(e,t)=>{if(!e)return;const o=e.component;o.value=t},_e=e=>{if(!e)return null;const{input:t}=e;return t.value},At=(e,t)=>{if(!e)return;const{input:o}=e;o.value=t},hs=e=>e?e.component.checked:null,ps=(e,t)=>{if(!e)return;const o=e.component;o.checked=t};function Mo(e){const t=JSON.stringify(e);return JSON.parse(t)}const ms=(e,t,o)=>e.sort((i,n)=>(i[t]<n[t]?-1:1)*(o?1:-1));function gs(e){const t={};for(const[o,i]of Object.entries(e))for(const n of o.split(" "))t[n]=i;return Qi(t)}const fs=e=>{try{const t=e.startsWith("+")?eo(e):eo(`+${e}`),o=`+${t.countryCallingCode} ${new Zi(t.country||"US").input(t.nationalNumber)}`;return o.endsWith(")")||o.endsWith("(")?e:o}catch(t){return e}},vs=()=>window.matchMedia("(min-width: 1024px)").matches,Me={phone:"^[+]?[(]?[0-9]{3}[)]?[-s.]?[0-9]{3}[-s.]?[0-9]{4,6}$",name:N().UserManagement.UI.ValidationRegexPatterns.name,alphabetOnly:"^[A-Za-z]+$"},Oe=(e,t)=>{const o=e;return"component"in o&&o.component.reportValidity(),t?(o.error=!1,o.errorText="",!0):(o.error=!0,o.errorText="This field is mandatory",!1)},Oo=(e,t,o)=>{const i=e;return t!=null&&t.match(i.pattern)?(i.error=!1,i.errorText="",!0):(i.error=!0,i.errorText=o,!1)},Bo=(e,t,o)=>{if(!t)return!1;const i=e;return Yi.isEmail(t)?(i.error=!1,i.errorText="",!0):(i.error=!0,i.errorText=o,!1)},ys=e=>e.error,bs=(e,t)=>{const o=t;return J(e)===o},Ct=(e,t,o)=>{const i=J(e);return e.required&&!Oe(e,i)||e.pattern&&!Oo(e,i,o)||e.type==="email"&&!Bo(e,i,o)?!1:!(ys(e)||bs(e,t))},_t=(e,t)=>{const o=_e(e),i=e;return Wi(o)?(i.error=!1,!0):(i.error=!0,i.errorText=t,!1)},xs=(e,t)=>{t.length>0&&t.forEach(o=>{const i=e.find(n=>n.id===o.field);i&&(i.error=!0,i.errorText=o.error,i.focus())})},w={CancelCreateUser:"cancel-create-user",CloseDrawer:"close-drawer",CreateContact:"create-contact",CreateNewContact:"create-new-contact",EvacAssistanceRequired:"evac-assistance-required",NextButtonToggle:"next-button-toggle",NextStep:"next-step",ResetSuccess:"reset-success",SetStep:"set-step",ToggleDialog:"toggle-dialog",ToggleDraft:"toggle-draft",ToggleDrawer:"toggle-drawer",UpdateAccounts:"update-accounts",UpdateAttachments:"update-attachments",UpdateContact:"update-contact",UpdateDFA:"update-dfa",UpdateFlags:"update-flags",UpdateObofSelections:"update-obof-selections",ValidateStep:"validate-step"};let fe=class extends I{constructor(){super(...arguments),this.validatingForm=!1,this._newContact={firstName:"",lastName:"",email:"",phone:"",accounts:[],evacAssistance:!1},this._nextButtonEnabled=!1}firstUpdated(){this._newContact=this.newContact,this.validateStep(),this.dispatchValidateStepEvent()}get firstName(){return this.renderRoot.querySelector("#first-name")}get lastName(){return this.renderRoot.querySelector("#last-name")}get email(){return this.renderRoot.querySelector("#email")}get phone(){return this.renderRoot.querySelector("#phone-number")}validateStep(){this._nextButtonEnabled=!(this.isInvalid()||this.isEmpty())}validateInput(e,t){const o=J(e);if(this.updateContactDetails(),e.required&&!Oe(e,o)){this._nextButtonEnabled=!1;return}e.pattern&&!Oo(e,o,t)&&(this._nextButtonEnabled=!1),this.validateStep(),this.dispatchNextButtonToggleEvent()}async validateEmailInput(e,t){this._nextButtonEnabled=!1;const o=J(e);if(this.updateContactDetails(),e.required&&!Oe(e,o)){this._nextButtonEnabled=!1;return}if(!Bo(e,o,t)){this._nextButtonEnabled=!1;return}clearTimeout(this.debounceTimeout),this.debounceTimeout=window.setTimeout(async()=>{const i={emailVerificationInput:{email_address:o!=null?o:""}};try{(await v.VerificationApi.verifyEmail(i)).is_verified?(e.error=!1,e.errorText="",this._nextButtonEnabled=!(this.isInvalid()||this.isEmpty())):(e.error=!0,e.errorText=`${t}`,this._nextButtonEnabled=!1)}catch(n){e.error=!0,e.errorText="An error occurred during email verification. Please try again later.",this._nextButtonEnabled=!1}},500),this.validateStep(),this.dispatchNextButtonToggleEvent()}validatePhoneInput(e,t){const o=_e(e);if(At(e,o),this.updateContactDetails(),e.required&&!Oe(e,o)){this._nextButtonEnabled=!1;return}if(!_t(e,t)){this._nextButtonEnabled=!1;return}this.validateStep(),this.dispatchNextButtonToggleEvent()}updateContactDetails(){var e,t,o,i;this._newContact={firstName:(e=J(this.firstName))!==null&&e!==void 0?e:"",lastName:(t=J(this.lastName))!==null&&t!==void 0?t:"",email:(o=J(this.email))!==null&&o!==void 0?o:"",phone:(i=_e(this.phone))!==null&&i!==void 0?i:"",accounts:this._newContact.accounts,evacAssistance:this._newContact.evacAssistance},this.dispatchUpdateContactEvent()}clearTextFields(){this._newContact={firstName:"",lastName:"",email:"",phone:"",accounts:[],evacAssistance:!1},Ye(this.firstName,""),Ye(this.lastName,""),Ye(this.email,""),this.phone.reset(),At(this.phone,"")}resetErrorStates(){this.firstName.error=!1,this.lastName.error=!1,this.email.error=!1,this.phone.error=!1}isInvalid(){return this.firstName.error||this.lastName.error||this.email.error||this.phone.error}isEmpty(){return!this._newContact.firstName||!this._newContact.lastName||!this._newContact.email||!this._newContact.phone}dispatchNextStepEvent(){this.dispatchEvent(new CustomEvent(w.NextStep,{bubbles:!0,composed:!0}))}dispatchUpdateContactEvent(){const e=new CustomEvent(w.UpdateContact,{detail:{newContact:this._newContact},bubbles:!0,composed:!0});this.dispatchEvent(e)}dispatchNextButtonToggleEvent(){this.dispatchEvent(new CustomEvent(w.NextButtonToggle,{detail:this._nextButtonEnabled,bubbles:!0,composed:!0}))}dispatchValidateStepEvent(){this.dispatchEvent(new CustomEvent(w.ValidateStep,{detail:this._nextButtonEnabled,bubbles:!0,composed:!0}))}render(){return c` <div class="input-group"> <ix-textbox required id="first-name" label="First name" name="first-name" type="text" value="${this._newContact.firstName}" @input="${()=>this.validateInput(this.firstName,"Invalid first name")}" pattern="${Me.name}" maxLength="50" data-testid="step-one-first-name"></ix-textbox> <ix-textbox required id="last-name" label="Last name" name="last-name" type="text" value="${this._newContact.lastName}" @input="${()=>this.validateInput(this.lastName,"Invalid last name")}" pattern="${Me.name}" maxLength="50" data-testid="step-one-last-name"></ix-textbox> </div> <div class="input-group"> <ix-textbox required id="email" label="Email Address" name="email" type="email" value="${this._newContact.email}" @input="${()=>this.validateEmailInput(this.email,"Invalid email address")}" data-testid="step-one-email"></ix-textbox> <ix-phone-input required id="phone-number" label="Phone Number" name="phone" value="${this._newContact.phone}" @input="${()=>this.validatePhoneInput(this.phone,"Invalid phone number")}" @country-change="${()=>this.phone.value?this.validatePhoneInput(this.phone,"Invalid phone number"):null}" data-testid="step-one-phone-number"></ix-phone-input> </div> <div style="display:flex;justify-content:flex-end;padding-top:8px"> <ix-button type="submit" ?disabled="${!this._nextButtonEnabled||this.validatingForm}" has-icon trailing-icon @click="${this.dispatchNextStepEvent}" data-testid="step-one-next-button"> Next <md-icon slot="icon">east</md-icon> </ix-button> </div> `}};fe.styles=[Po,_],r([d({type:Object})],fe.prototype,"newContact",void 0),r([d({type:Boolean})],fe.prototype,"validatingForm",void 0),r([m()],fe.prototype,"_newContact",void 0),r([m()],fe.prototype,"_nextButtonEnabled",void 0),fe=r([A("create-user-step-one")],fe);function Tt(e){var t;for(const o of e)if(o.checked||!((t=o.children)===null||t===void 0)&&t.length&&Tt(o.children))return!0;return!1}function It(e){return e.some(t=>t.subaccounts.length)?"nested":"flat"}function Et(e,t){var o,i;if(t==="flat")return e.filter(a=>a.checked);const n=[];for(const a of e){a.checked&&n.push(a);const s=(o=a.children)===null||o===void 0?void 0:o.every(l=>l.checked);if(!((i=a.children)===null||i===void 0)&&i.length&&(a.indeterminate||!s)){const l=Et(a.children,t);n.push(...l)}}return n}function Rt(e){var t;const o=[];for(const i of e)i.checked?o.push(i):!((t=i.children)===null||t===void 0)&&t.length&&o.push(...Rt(i.children));return o}function Lo(e){const t=[];function o(i){i.checked&&t.push(i.id),i.children&&i.children.forEach(n=>{o(n)})}return e.forEach(i=>{o(i)}),t}function St(e){var t;return[e.id||e.label,...Lo((t=e.children)!==null&&t!==void 0?t:[])]}const qo=e=>{var t;return{authorityDocumentId:e.authority_document_id,changeHistoryId:e.change_history_id,fileName:e.file_name,createdAt:(t=e.created_at)===null||t===void 0?void 0:t.toString(),createdBy:e.created_by}},ws=e=>({file:e.file,fileName:e.fileName}),As=e=>({id:e.id});class Cs{async create(t){try{const o=ws(t),i=await v.AuthorityDocumentsApi.postAuthorityDocuments(o);return qo(i)}catch(o){return g.handleError(o,"Failed to upload authority document."),{}}}async getById(t){try{const o=As(t),i=await v.AuthorityDocumentsApi.getAuthorityDocument(o);return qo(i)}catch(o){return g.handleError(o,"Failed to get authority document."),{}}}async download(t){try{return await v.AuthorityDocumentsApi.downloadAuthorityDocuments({id:t})}catch(o){g.handleError(o,"Failed to download authority document.");return}}}const Ho=new Cs,zo=()=>N().UserManagement.UI.AuthorityDocuments.MaxFileSizeMB,Vo=()=>N().UserManagement.UI.AuthorityDocuments.AcceptedExtensions,_s=e=>{const t={file:e,fileName:e.name};return Ho.create(t)},jo=128;function Go(){const e=N().UserManagement.UI.AuthorityDocuments;return{minAttachments:1,maxFileSizeMB:e.MaxFileSizeMB,acceptedExtensions:e.AcceptedExtensions,fileNamePattern:new RegExp(e.FileNamePattern)}}function Jo(e,t){var o;const i=[],n=t.maxFileSizeMB*1024*1024;e.size>n&&i.push({code:"SIZE_EXCEEDED",message:`File exceeds the maximum size of ${t.maxFileSizeMB}MB.`,fileName:e.name});const a=((o=e.name.split(".").pop())===null||o===void 0?void 0:o.toLowerCase())||"";a&&!t.acceptedExtensions.includes(a)&&i.push({code:"INVALID_EXTENSION",message:`File extension for '${e.name}' is not allowed.`,fileName:e.name});const s=/^[A-Za-z0-9._() -]+$/;return t.fileNamePattern.test(e.name)||s.test(e.name)||i.push({code:"INVALID_FILENAME",message:"Filename must not contain special characters. Allowed: A-Z a-z 0-9 _ - .",fileName:e.name}),e.name.length>jo&&i.push({code:"FILENAME_TOO_LONG",message:`Filename must not exceed ${jo} characters.`,fileName:e.name}),i}function Ko(e,t){return Jo(e,t)}function Zo(e,t){const o={isValid:!0,errors:[],fileErrors:new Map};if(!e||e.length===0)return o.isValid=!1,o.errors.push({code:"MIN_ATTACHMENTS_REQUIRED",message:"At least one document is required."}),o;for(const i of e){const n=Jo(i,t);n.length>0&&(o.isValid=!1,o.fileErrors.set(i.name,n))}return o}class Ts{constructor(t){this._attachments=[],this._validationResult=null,this._documentsRequired=!1,this._onStateChanged=null,this._config=t||Go()}get attachments(){return this._attachments}get validationResult(){return this._validationResult}get isValid(){return this._validationResult?this._validationResult.isValid:!0}get documentsRequired(){return this._documentsRequired}get canProceed(){return this._documentsRequired?this.isValid&&this._attachments.length>0:this.isValid}addFiles(t){const o=new Map;for(const i of t){const n=Ko(i,this._config);if(n.length>0)o.set(i.name,n);else{const a=Object.assign(i,{id:this.generateFileId(i)});this._attachments.some(s=>s.name===a.name&&s.size===a.size)||this._attachments.push(a)}}this.validateCurrent();for(const[i,n]of o)this._validationResult.fileErrors.set(i,n);this.notifyStateChanged()}removeFile(t){const o=this._attachments.length;this._attachments=this._attachments.filter(i=>!(i.name===t||i.id===t||this.getFileKey(i)===t)),this._attachments.length!==o&&(this.validateCurrent(),this.notifyStateChanged())}clearAll(){this._attachments=[],this.validateCurrent(),this.notifyStateChanged()}validateCurrent(){if(this._attachments.length===0){this._validationResult={isValid:!0,errors:[],fileErrors:new Map};return}const t=this._attachments.map(o=>new File([o],o.name,{type:o.type}));this._validationResult=Zo(t,this._config)}getFileErrors(t){return this._validationResult?this._validationResult.fileErrors.get(t)||[]:[]}setDocumentsRequired(t){this._documentsRequired!==t&&(this._documentsRequired=t,this.notifyStateChanged())}onStateChanged(t){this._onStateChanged=t}generateFileId(t){return`${Date.now()}-${t.name}-${t.size}`}getFileKey(t){return t.id||t.name}notifyStateChanged(){this._onStateChanged&&this._onStateChanged()}}function Wo(e){return new Ts(e)}const Is=e=>({id:e.id,firstName:e.first_name,lastName:e.last_name,email:e.email,accountPermissionGroup:e.account_permission_group,accountAssociations:e.account_associations}),Es=e=>{var t;return{items:((t=e.items)!==null&&t!==void 0?t:[]).map(Is)}};class Rs{async get(t={}){try{const o=await v.UsersApi.getMyAccountsAdminsAndApprovers({isMyAccountRequest:t.isMyAccountRequest});return Es(o).items}catch(o){return g.handleError(o,"Failed to get account admins and approvers."),[]}}}const Ss=new Rs,ks=()=>Ss.get({isMyAccountRequest:!1}),Qo=async e=>(await ks()).filter(t=>{var o;return(o=t.accountAssociations)===null||o===void 0?void 0:o.includes(e)}),z={RequestedByCustomer:"REQUESTED_BY_CUSTOMER",NoUserAvailable:"NO_USER_AVAILABLE",NewCustomer:"NEW_CUSTOMER"};class Xe{constructor(t="",o="",i=o,n=""){this.value=t,this.displayText=o,this.name=i,this.email=n}isValid(){return this.value!==""}}const Us=e=>({id:e.id,name:e.account_name,status:e.status,accountNumber:e.account_number,displayName:e.account_friendly_name,statusUpdateAt:e.updated_at,statusUpdateBy:e.updated_by}),kt=e=>{var t;const o=[];return(t=e.account_associations)===null||t===void 0||t.forEach(i=>{o.push(Us(i))}),{id:e.id,firstName:e.first_name,lastName:e.last_name,email:e.email,phone:e.phone,evacAssistance:e.evacuation_assistance_required,accounts:o,status:"Active"}},$s=e=>{var t;const o=[];return(t=e.accounts)===null||t===void 0||t.forEach(i=>{o.includes(i.accountNumber)||o.push(i.accountNumber)}),{first_name:e.firstName,last_name:e.lastName,email:e.email,phone:e.phone,account_numbers:o,evacuation_assistance_required:e.evacAssistance}},Ns=e=>({id:e.id,first_name:e.firstName,last_name:e.lastName,email:e.email,phone:e.phone,evacuation_assistance_required:e.evacAssistance}),Fs=e=>({accountNumber:e.accountNumber,includeChildAccounts:!0,page:e.page,size:e.size,firstName:e.firstName,lastName:e.lastName,email:e.email,sort:e.sort,order:e.order}),Ds=e=>{var t,o;const i=[];return(t=e.content)===null||t===void 0||t.forEach(n=>{i.push(kt(n))}),{contacts:i,recordCount:(o=e.pageable)===null||o===void 0?void 0:o.total_elements}},Ps=e=>({id:e.id}),Ms=e=>({id:e.id,userProfile:Ns(e.contactInput)}),Os=e=>({userInput:{...$s(e.contactInput),change_history_id:e.changeHistoryId}});class Bs{async update(t){try{const o=Ms(t);return v.UsersApi.updateUser(o)}catch(o){return g.handleError("Failed to update user.")}}async create(t){try{const o=Os(t),i=await v.UsersApi.createUser(o);return kt(i)}catch(o){return g.handleError(o,`Failed to create user for ${t.contactInput.email}`),{}}}async search(t){try{const o=Fs(t),i=await v.UsersApi.getUsers(o);return Ds(i)}catch(o){return g.handleError(o,"Failed to get users."),{}}}async get(t){try{const o=Ps(t),i=await v.UsersApi.getUser(o);return kt(i)}catch(o){return t!=null&&t.failSilently?{}:(g.handleError(o,"Failed to get user."),{})}}async getUsersReport(t){try{const o={accountNumber:t.accountNumber,includeChildAccounts:t.includeChildAccounts,firstName:t.firstName,lastName:t.lastName,email:t.email};return await v.UsersApi.getUserReport(o)}catch(o){throw g.handleError(o,"Failed to download users report."),o}}}const et=new Bs,Yo=e=>{const t=[...e.entries()].map(([o,i])=>({accountNumber:o,value:i.value})).filter(o=>!!o.value);if(t.length)return t.map(o=>o.value===z.NoUserAvailable?{reason:z.NoUserAvailable,authoriserUserId:"",accountNumber:o.accountNumber}:o.value===z.NewCustomer?{reason:z.NewCustomer,authoriserUserId:"",accountNumber:o.accountNumber}:{reason:z.RequestedByCustomer,authoriserUserId:o.value,accountNumber:o.accountNumber})},Xo=async e=>{const t=(await Promise.all(e.map(o=>_s(o)))).map(o=>o.authorityDocumentId).filter(Boolean);if(t.length!==e.length)throw new Error("Failed to upload all authority documents.");return t},Ut={noUserAvailable:"No User with Proper Permissions Available",newCustomer:"New Customer"},ei=(e,t,o)=>e?"loading":t>0?"selectable":o?"no-user":"new-customer",ti=(e,t)=>{const o=new Map(e!=null?e:new Map);t.forEach(n=>{o.has(n)||o.set(n,new Xe)});const i=new Set(t);return[...o.keys()].forEach(n=>{i.has(n)||o.delete(n)}),o},oi=(e,t)=>e.every(o=>{var i,n;return(n=(i=t==null?void 0:t.get(o))===null||i===void 0?void 0:i.isValid())!==null&&n!==void 0?n:!1}),$t=(e,t,o,i=[])=>{if(!e||!t||!o||o.size===0)return!1;const n=new Set(i),a=[...o.entries()].filter(([s])=>!n.size||n.has(s)).map(([,s])=>s).filter(s=>!!(s!=null&&s.value));return a.length?a.some(s=>s.value!==z.NewCustomer):!1},ii="data-wrap-patch";function ni(e,t){if(e.querySelector(`style[${ii}]`))return;const o=document.createElement("style");o.setAttribute(ii,""),o.textContent=t,e.appendChild(o)}function Ls(e){const t=()=>{const i=e.shadowRoot;i&&ni(i,`
2032
+ `;class Ua{constructor(t){this.config=t,this.gqlClient=new zi(this.config.url),this.config.accessToken&&this.gqlClient.setHeader("authorization",this.config.accessToken)}async GetRolesInventory(t){var o;return(o=this.gqlClient)===null||o===void 0?void 0:o.request(Ia,{...t})}async GetFlagsInventory(t){var o;return(o=this.gqlClient)===null||o===void 0?void 0:o.request(Ea,{...t})}async GetAccountInventory(t){var o;return(o=this.gqlClient)===null||o===void 0?void 0:o.request(Ra,{...t})}async SaveAccountRoleAssignments(t){var o;return(o=this.gqlClient)===null||o===void 0?void 0:o.request(Sa,{...t})}async SaveAccountFlagAssignments(t){var o;return(o=this.gqlClient)===null||o===void 0?void 0:o.request(ka,{...t})}}const $a="http://localhost".replace(/\/+$/,"");class Co{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:$a}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||_o}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const Na=new Co;class mt{constructor(t=Na){this.configuration=t,this.fetchApi=async(o,i)=>{let n={url:o,init:i};for(const s of this.middleware)s.pre&&(n=await s.pre({fetch:this.fetchApi,...n})||n);let a;try{a=await(this.configuration.fetchApi||fetch)(n.url,n.init)}catch(s){for(const l of this.middleware)l.onError&&(a=await l.onError({fetch:this.fetchApi,url:n.url,init:n.init,error:s,response:a?a.clone():void 0})||a);if(a===void 0)throw s instanceof Error?new Ma(s,"The request failed and the interceptors did not return an alternative response"):s}for(const s of this.middleware)s.post&&(a=await s.post({fetch:this.fetchApi,url:n.url,init:n.init,response:a.clone()})||a);return a},this.middleware=t.middleware}withMiddleware(...t){const o=this.clone();return o.middleware=o.middleware.concat(...t),o}withPreMiddleware(...t){const o=t.map(i=>({pre:i}));return this.withMiddleware(...o)}withPostMiddleware(...t){const o=t.map(i=>({post:i}));return this.withMiddleware(...o)}isJsonMime(t){return t?mt.jsonRegex.test(t):!1}async request(t,o){const{url:i,init:n}=await this.createFetchParams(t,o),a=await this.fetchApi(i,n);if(a&&a.status>=200&&a.status<300)return a;throw new Pa(a,"Response returned an error code")}async createFetchParams(t,o){let i=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(i+="?"+this.configuration.queryParamsStringify(t.query));const n=Object.assign({},this.configuration.headers,t.headers);Object.keys(n).forEach(u=>n[u]===void 0?delete n[u]:{});const a=typeof o=="function"?o:async()=>o,s={method:t.method,headers:n,body:t.body,credentials:this.configuration.credentials},l={...s,...await a({init:s,context:t})};let p;Da(l.body)||l.body instanceof URLSearchParams||Fa(l.body)?p=l.body:this.isJsonMime(n["Content-Type"])?p=JSON.stringify(l.body):p=l.body;const h={...l,body:p};return{url:i,init:h}}clone(){const t=this.constructor,o=new t(this.configuration);return o.middleware=this.middleware.slice(),o}}mt.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function Fa(e){return typeof Blob<"u"&&e instanceof Blob}function Da(e){return typeof FormData<"u"&&e instanceof FormData}class Pa extends Error{constructor(t,o){super(o),this.response=t,this.name="ResponseError"}}class Ma extends Error{constructor(t,o){super(o),this.cause=t,this.name="FetchError"}}class Oa extends Error{constructor(t,o){super(o),this.field=t,this.name="RequiredError"}}function re(e,t){return e[t]!=null}function _o(e,t=""){return Object.keys(e).map(o=>To(o,e[o],t)).filter(o=>o.length>0).join("&")}function To(e,t,o=""){const i=o+(o.length?`[${e}]`:e);if(t instanceof Array){const n=t.map(a=>encodeURIComponent(String(a))).join(`&${encodeURIComponent(i)}=`);return`${encodeURIComponent(i)}=${n}`}if(t instanceof Set){const n=Array.from(t);return To(e,n,o)}return t instanceof Date?`${encodeURIComponent(i)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?_o(t,i):`${encodeURIComponent(i)}=${encodeURIComponent(String(t))}`}class Io{constructor(t,o=i=>i){this.raw=t,this.transformer=o}async value(){return this.transformer(await this.raw.json())}}function Eo(e){return Ba(e)}function Ba(e,t){return e==null?e:{firstName:re(e,"firstName")?e.firstName:void 0,lastName:re(e,"lastName")?e.lastName:void 0,contactPhoneNumber:re(e,"contactPhoneNumber")?e.contactPhoneNumber:void 0,preferredLanguage:re(e,"preferredLanguage")?e.preferredLanguage:void 0,preferredTimezone:re(e,"preferredTimezone")?e.preferredTimezone:void 0,timezoneOverridden:re(e,"timezoneOverridden")?e.timezoneOverridden:void 0,preferredDateFormat:re(e,"preferredDateFormat")?e.preferredDateFormat:void 0,preferredTimeFormat:re(e,"preferredTimeFormat")?e.preferredTimeFormat:void 0,email:re(e,"email")?e.email:void 0}}function La(e){if(e!==void 0)return e===null?null:{firstName:e.firstName,lastName:e.lastName,contactPhoneNumber:e.contactPhoneNumber,preferredLanguage:e.preferredLanguage,preferredTimezone:e.preferredTimezone,timezoneOverridden:e.timezoneOverridden,preferredDateFormat:e.preferredDateFormat,preferredTimeFormat:e.preferredTimeFormat}}class qa extends mt{async getUserSettingsRaw(t){const o={},i={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,s=await a("bearerToken",[]);s&&(i.Authorization=`Bearer ${s}`)}const n=await this.request({path:"/user-profile",method:"GET",headers:i,query:o},t);return new Io(n,a=>Eo(a))}async getUserSettings(t){return await(await this.getUserSettingsRaw(t)).value()}async userProfilePatchRaw(t,o){if(t.profileSettingEditInput===null||t.profileSettingEditInput===void 0)throw new Oa("profileSettingEditInput","Required parameter requestParameters.profileSettingEditInput was null or undefined when calling userProfilePatch.");const i={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const s=this.configuration.accessToken,l=await s("bearerToken",[]);l&&(n.Authorization=`Bearer ${l}`)}const a=await this.request({path:"/user-profile",method:"PATCH",headers:n,query:i,body:La(t.profileSettingEditInput)},o);return new Io(a,s=>Eo(s))}async userProfilePatch(t,o){return await(await this.userProfilePatchRaw(t,o)).value()}}class Ha{constructor(t){this.configuration=t}get InventoryApi(){return new Ua({url:this.configuration.userManagementAggregationApiUrl,accessToken:this.getToken()})}get UsersApi(){return new _a(new Y({basePath:this.configuration.userManagementApiUrl,accessToken:this.getToken()}))}get AccountAssociationApi(){return new fa(new Y({basePath:this.configuration.userManagementApiUrl,accessToken:this.getToken()}))}get AccountsApi(){return new va(new Y({basePath:this.configuration.userManagementApiUrl,accessToken:this.getToken()}))}get RolesApi(){return new Aa(new Y({basePath:this.configuration.userManagementApiUrl,accessToken:this.getToken()}))}get PermissionsApi(){return new xa(new Y({basePath:this.configuration.userManagementApiUrl,accessToken:this.getToken()}))}get RoleAssignmentsApi(){return new wa(new Y({basePath:this.configuration.userManagementApiUrl,accessToken:this.getToken()}))}get UserFlagsApi(){return new Ca(new Y({basePath:this.configuration.userManagementApiUrl,accessToken:this.getToken()}))}get VerificationApi(){return new Ta(new Y({basePath:this.configuration.userManagementApiUrl,accessToken:this.getToken()}))}get ChangeHistoriesApi(){return new ba(new Y({basePath:this.configuration.userManagementApiUrl,accessToken:this.getToken()}))}get AuthorityDocumentsApi(){return new ya(new Y({basePath:this.configuration.userManagementApiUrl,accessToken:this.getToken()}))}get UserProfileSettingsApi(){var t;const o=((t=this.getToken())!==null&&t!==void 0?t:"").replace(/^Bearer\s+/i,""),i={};return new qa(new Co({basePath:this.configuration.LoginAuthority,accessToken:o,headers:i}))}getToken(){return this.configuration.getTokenFn?this.configuration.getTokenFn():void 0}}class za extends Vi{constructor(t,o){super({...t}),this.hashed_identifier="",this.email="",this.account_number="",this.hashed_identifier=o}get getEmail(){var t;return(t=this.email)!==null&&t!==void 0?t:this.profile.email}get getAccount(){var t;return(t=this.account_number)!==null&&t!==void 0?t:this.profile.account_number}}class je{constructor({loginAuthority:t,clientId:o,scope:i,postLogoutRedirectUri:n,userStorageKey:a=N().UserManagement.UI.UserManagementUIStorageKey,xauthStorageKey:s=N().UserManagement.UI.UserManagementXAuthUIStorageKey,redirectUrlKey:l="redirect-url",authPaths:p={authenticate:"authenticate",authCallback:"auth-callback",logout:"logout"}}){this.configuration={loginAuthority:t,clientId:o,scope:i,postLogoutRedirectUri:n,userStorageKey:a,xauthStorageKey:s,redirectUrlKey:l,authPaths:p};const{location:h}=window,u=`${h.protocol}//${h.hostname}${h.port?`:${h.port}`:""}`,b={authority:this.configuration.loginAuthority,client_id:this.configuration.clientId,redirect_uri:`${u}/${this.configuration.authPaths.authCallback}`,response_type:"code",scope:this.configuration.scope,post_logout_redirect_uri:this.configuration.postLogoutRedirectUri,loadUserInfo:!0};this.userManager=new ji(b)}isLoggedIn(){const t=this.getUser();if(t===null)return!1;if(!t.expires_at)return!0;const o=new Date,i=new Date(t.expires_at*1e3);return o<i}redirectToAuth(t=!1){const o=this.isAuthenticating();(t||!o)&&(o||localStorage.setItem(this.configuration.redirectUrlKey,window.location.href),window.location.href=`/${this.configuration.authPaths.authenticate}`)}isAuthenticating(){const t=window.location.pathname.split("/");return t[t.length-1]===this.configuration.authPaths.authenticate?(this.userManager.signinRedirect(),!0):!1}isHandlingAuthCallback(){const t=window.location.pathname.split("/");return t[t.length-1]===this.configuration.authPaths.authCallback?(this.userManager.signinRedirectCallback().then(je.ensureValidUser).then(je.addHashedIdToUserProfile).then(o=>this.saveUser(o)).then(()=>this.authSuccessRedirect()).catch(()=>this.redirectToAuth()),!0):!1}authSuccessRedirect(){let t="/";const o=localStorage.getItem(this.configuration.redirectUrlKey);o&&(localStorage.removeItem(this.configuration.redirectUrlKey),t=o),window.location.href=t}redirectToLogout(){this.isHandlingLogout()||(window.location.href=`/${this.configuration.authPaths.logout}`)}isHandlingLogout(){const t=window.location.pathname.split("/");return t[t.length-1]===this.configuration.authPaths.logout?(this.clearUser(),window.localStorage.clear(),this.userManager.signoutRedirect({id_token_hint:this.getIdToken()}),!0):!1}isProcessing(){return this.isAuthenticating()||this.isHandlingAuthCallback()||this.isHandlingLogout()}saveUser(t){localStorage.setItem(this.configuration.userStorageKey,JSON.stringify(t))}clearUser(){localStorage.removeItem(this.configuration.userStorageKey)}getXAuthUser(){const t=localStorage.getItem(this.configuration.xauthStorageKey);if(t){const o=JSON.parse(t);if(o!=null&&o.email&&o!=null&&o.account_number)return o}}getTokenUser(){const t=localStorage.getItem(this.configuration.userStorageKey);if(t)return JSON.parse(t)}getUser(){const t=this.getTokenUser();return t?(t.profile.email||(t.profile.email=this.getXAuthUser().email),t!=null?t:null):null}getUserDetails(){const t={accountNumber:"",email:""},o=this.getUser();return o&&(t.accountNumber=o.profile.account_number,t.email=o.profile.email),t}getUserProfileSub(){var t;const o=this.getUser();return(t=o==null?void 0:o.profile)===null||t===void 0?void 0:t.sub}getUserLocale(){var t;const o=this.getUser();return(t=o==null?void 0:o.profile)===null||t===void 0?void 0:t.locale}getIdToken(){var t;return(t=this.getUser())===null||t===void 0?void 0:t.id_token}getAccessToken(){var t;return`Bearer ${(t=this.getUser())===null||t===void 0?void 0:t.access_token}`}static async hashValue(t){const o=new TextEncoder().encode(t),i=await crypto.subtle.digest("SHA-256",o);return Array.from(new Uint8Array(i)).map(n=>n.toString(16).padStart(2,"0")).join("")}static async addHashedIdToUserProfile(t){const o=`${t.profile.sub}-${t.profile.customer_id}`,i=await je.hashValue(o);return new za(t,i)}static ensureValidUser(t){if(!t.id_token)throw new Error("Missing property:id_token");return t}}const we=N(),Ae=new je({loginAuthority:we.LoginAuthority,clientId:we.LoginService.UserManagementUIClientId,scope:we.LoginService.UserManagementUIScopes}),v=new Ha({userManagementApiUrl:we.UserManagement.UI.UserManagementApiUrl,userManagementAggregationApiUrl:we.UserManagement.UI.UserManagementAggregationApiUrl,LoginAuthority:we.LoginAuthority,getTokenFn:()=>Ae.getAccessToken()});var Va="Alerts",ja="Content",Ga="DCIM",Ja="Invoices",Ka="Marketplace",Za="Release",Wa="Security",Qa={"Account Information":"Account Information",Alerts:Va,"Cloud Connect":"Cloud Connect",Content:ja,"Cross Connect":"Cross Connect","Custom Role":"Custom Role","Custom Roles":"Custom Roles","Customer Equipment Connection (CEC)":"Customer Equipment Connection (CEC)","Customer Support":"Customer Care","Customer Support Team":"Customer Support Team",DCIM:Ga,"DCIM-enabled location data":"DCIM-enabled location data","Default System Roles":"Default System Roles","EMEA MarketPlace":"EMEA MarketPlace","External User":"External User","Internal Roles":"Internal Roles","Internal User":"Internal User","Internet Exchange":"Internet Exchange","Intra-Customer Connectivity (ICC)":"Intra-Customer Connectivity (ICC)",Invoices:Ja,"IP Bandwidth":"IP Bandwidth",Marketplace:Ka,"OSP Access":"OSP Access","Permanent Badge":"Permanent Badge","Planned Site Maintenance":"Maintenance & Incident Notifications","PoP/POE Room Access":"PoP/POE Room Access",Release:Za,"Remote Hands":"Remote Hands","Remote Hands Package":"Remote Hands Package",Security:Wa,"Service Exchange Cloud Router":"Service Exchange Cloud Router","Service Exchange Port":"Service Exchange Port","Shipping & Receiving":"Deliveries & Removals","Space & Power":"Space & Power","Trouble Ticket":"Trouble Ticket","Visitor Access":"Visitor Access"};Yt.use(Gi).init({resources:{en:{translation:{...Qa}}},interpolation:{escapeValue:!1},lng:"en",debug:!1});const Ro=e=>Yt.t(e),Ya=e=>{const t=[];return e.forEach(o=>{t.push({id:o.id,name:Ro(o.name),isNonLocation:o.is_non_location,category:o.category,privileges:o.privileges,internalPrivileges:o.internal_privileges,isInternal:o.is_internal})}),t},Xa=e=>{const t=[];return e.forEach(o=>{t.push({accountNumber:o.account_number,permissionName:Ro(o.permission_name),privilege:o.privilege})}),t};class es{async get(){try{const t=await v.PermissionsApi.getPermissions();return Ya(t)}catch(t){return g.handleError(t,"Could not get permissions."),[]}}async getMyPermissions(t){try{const o=await v.PermissionsApi.getUserPermissions(t);return Xa(o)}catch(o){return g.handleError(o,"Could not retrieve current user's permissions."),[]}}}const We=new es,ts=e=>{const t=[];return e.forEach(o=>{t.push({accountNumber:o.account_number,name:o.name,parentAccountNumber:o.parent_account_number,displayName:o.friendly_name})}),t};class os{async get(){try{const t=await v.AccountsApi.getAccounts();return ts(t)}catch(t){return g.handleError(t,"Failed to get accounts."),[]}}}const So=new os;class is{async getUserProfile(){try{return await v.UserProfileSettingsApi.getUserSettings()}catch(t){g.handleError(t,"Failed to get user profile.");return}}async updateUserProfile(t){try{return await v.UserProfileSettingsApi.userProfilePatch(t)}catch(o){g.handleError(o,"Failed to update user profile.");return}}}const xt=new is;class ns{constructor(){this.myPermissions=[]}isProfileOfLoggedInUser(t){var o;return((o=U==null?void 0:U.getEmail())===null||o===void 0?void 0:o.toLowerCase())===(t==null?void 0:t.toLowerCase())}hasUserRead(t){return this.hasPermission(T.user,x.read,t)}hasUserUpdate(t){return this.hasPermission(T.user,x.update,t)}hasExternalUserRead(t){return N().UserManagement.InternalUserRetired?this.hasPermission(T.user,x.read,t):this.hasPermission(T.externalUser,x.read,t)}hasExternalUserUpdate(t){return N().UserManagement.InternalUserRetired?this.hasPermission(T.user,x.update,t):this.hasPermission(T.externalUser,x.update,t)}hasExternalUserCreate(t){return N().UserManagement.InternalUserRetired?this.hasPermission(T.user,x.create,t):this.hasPermission(T.externalUser,x.create,t)}hasInternalUserRead(t){return N().UserManagement.InternalUserRetired?this.hasPermission(T.user,x.read,t):this.hasPermission(T.internalUser,x.read,t)}hasInternalUserUpdate(t){return N().UserManagement.InternalUserRetired?this.hasPermission(T.user,x.update,t):this.hasPermission(T.internalUser,x.update,t)}hasCustomRolesApprove(t){return this.hasPermission(T.customRoles,x.approve,t)}hasCustomRolesCreate(t){return this.hasPermission(T.customRoles,x.create,t)}hasCustomRolesUpdate(t){return this.hasPermission(T.customRoles,x.update,t)}hasCustomRolesRead(t){return this.hasPermission(T.customRoles,x.read,t)}hasInternalRolesCreate(t){return this.hasPermission(T.internalRoles,x.create,t)}hasInternalRolesUpdate(t){return this.hasPermission(T.internalRoles,x.update,t)}hasInternalRolesRead(t){return this.hasPermission(T.internalRoles,x.read,t)}hasDefaultSystemRolesCreate(t){return this.hasPermission(T.defaultRoles,x.create,t)}hasDefaultSystemRolesUpdate(t){return this.hasPermission(T.defaultRoles,x.update,t)}hasDefaultSystemRolesRead(t){return this.hasPermission(T.defaultRoles,x.read,t)}hasRoleManagementAccess(t){return this.hasPermission(T.defaultRoles,x.read,t)||this.hasPermission(T.customRoles,x.read,t)||this.hasPermission(T.internalRoles,x.read,t)||this.hasPermission(T.externalUser,x.read,t)}hasUserManagementAccess(){return N().UserManagement.InternalUserRetired?this.hasUserRead():this.hasExternalUserRead()||this.hasInternalUserRead()}hasAssignInternalRoleCreate(t){return this.hasPermission(T.assignInternalRole,x.create,t)}hasDLRDomain(){var t;const o=(t=U.getEmail())===null||t===void 0?void 0:t.toLowerCase().trim(),i=N();let n=!1;return i.InternalUserDomainWhitelist.split(",").forEach(a=>{const s=a.toLowerCase().trim();s&&o!=null&&o.endsWith(s)&&(n=!0)}),n}async refreshPermissions(){this.myPermissions=await We.getMyPermissions({excludeParents:!1,excludeSiblings:!0})}async refreshAccounts(){const t=await So.get();U.setAccounts(t)}async getUserProfileSettings(){return xt.getUserProfile()}hasPrivilegeLevel(t,o){const i=[x.approve,x.create,x.update,x.read],n=i.findIndex(s=>s===t.toLowerCase()),a=i.findIndex(s=>s===o.toLowerCase());return n>=a}hasPermission(t,o,i){let{myPermissions:n}=this,a=!1;return i&&(n=n.filter(s=>s.accountNumber===i)),n.length&&o&&(a=n.some(s=>s.permissionName===t&&this.hasPrivilegeLevel(o,s.privilege))),a}}const B=new ns,ko="uppercase font-bold tracking-wider",Uo={LocalStorage:{},SessionStorage:{HasOutstandingChanges:"hasOutstandingChanges"}};let wt=class extends I{constructor(){super(...arguments),this.routeName=null}return(){window.sessionStorage.getItem(Uo.SessionStorage.HasOutstandingChanges)!=="true"&&this.routeName&&Ye(this.routeName)}render(){return c` <ix-button appearance="text" has-icon @click="${this.return}" data-testid="um-back-button"> <md-icon slot="icon">arrow_back</md-icon> <span class="${ko}">Back</span> </ix-button>`}};r([d()],wt.prototype,"routeName",void 0),wt=r([A("um-back-button")],wt);const Pe=(e,t,o)=>{e.dispatchEvent(new CustomEvent(t,{detail:o,bubbles:!0,composed:!0}))};let $o=class extends I{dispatchCreateUserEvent(){Pe(this,S.CreateUserClicked)}render(){return c` <ix-button @click="${this.dispatchCreateUserEvent}" has-icon> <md-icon slot="icon">add</md-icon> <span class="${ko}">Create User</span> </ix-button>`}};$o=r([A("um-create-user-button")],$o);const G={Home:"Home",UserManagement:"User Management",RoleManagement:"Role Management",UserManagementDetails:"User Management Details"},No=[{name:G.Home,path:"(/?)",component:"home-view",action:()=>{import("./ui-user-management2.js")}},{name:G.UserManagement,path:"/user-management",component:"user-management-view",headerRight:c``,action:async()=>{B.hasUserManagementAccess()?import("./ui-user-management3.js"):ye.go("/")}},{name:G.RoleManagement,path:"/role-management",component:"role-management-view",action:async()=>{B.hasRoleManagementAccess()?import("./ui-user-management4.js"):ye.go("/")}},{name:G.UserManagementDetails,path:"/user-management-details",component:"user-management-details-view",hideAccountSwitcher:!0,headerLeft:c`<um-back-button routeName="${G.UserManagement}"></um-back-button>`,action:async()=>{B.hasUserManagementAccess()?import("./ui-user-management6.js"):ye.go("/")}}];let oe=null;function Fo(){const{pathname:e,search:t,hash:o}=window.location;ye.go({pathname:e,search:t,hash:o})}function as(e,t,o){const i=o.map(n=>({...n,path:`${t}${n.path}`,redirect:n.redirect?`${t}${n.redirect}`:null}));i.push({path:"(.*)",component:"no-elem"}),oe=new ye(e),oe.setRoutes(i),window.addEventListener("shell-after-navigate",Fo)}function ss(){return oe}function rs(){oe==null||oe.unsubscribe(),oe==null||oe.removeRoutes(),oe=null,window.removeEventListener("shell-after-navigate",Fo)}function Qe(e,t){return oe&&oe.urlForName(e,t)}function Ye(e,t){const o=Qe(e);o&&ye.go({pathname:o,hash:t})}const ls=e=>{var t,o,i,n,a,s;const l=No.find(h=>h.name===e),p=(s=(a=(n=(i=(o=(t=window.document.querySelector("gp-bootstrap"))===null||t===void 0?void 0:t.shadowRoot)===null||o===void 0?void 0:o.querySelector("global-portal-app"))===null||i===void 0?void 0:i.shadowRoot)===null||n===void 0?void 0:n.querySelector("ui-user-management"))===null||a===void 0?void 0:a.getAttribute("baseurl"))!==null&&s!==void 0?s:"";return window.location.pathname===`${p}${l==null?void 0:l.path}`};let At=class extends Ue{constructor(){super(...arguments),this.setNavigationItemsBinding=this.setNavigationItems.bind(this),this.navigationItems=[],this.compact=!1}static get styles(){return[ho,_]}connectedCallback(){super.connectedCallback(),window.addEventListener(S.RouteChanged,this.setNavigationItemsBinding)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener(S.RouteChanged,this.setNavigationItemsBinding)}setNavigationItems(){this.requestUpdate(),!this.navigationItems.length&&(this.navigationItems=[{href:Qe(G.UserManagement),title:"User Management",icon:c`<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" fill="white"> ${Ze.userManagementIcon} </svg>`},{href:Qe(G.RoleManagement),title:"Role Management",icon:c`<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" fill="white"> ${Ze.roleManagementIcon} </svg>`}])}toggleCompact(){Pe(this,S.ToggleNavBar),setTimeout(()=>{window.dispatchEvent(new Event("resize"))},301)}renderNavigation(){return B.hasExternalUserRead()?c`${this.navigationItems.map(e=>c` <li class="relative m-1"> <div class="${e.href===window.location.pathname?"bg-white opacity-[.16] inset-0 rounded-md absolute":""}"></div> <a href="${e.href}" class="${e.href===window.location.pathname?"flex px-6 py-4 gap-4 rounded-md font-bold":"flex px-6 py-4 gap-4 rounded-md font-bold opacity-60"}"> <div class="w-6 shrink-0">${e.icon}</div> <div class="grow text-left"> <div class="${this.compact?"w-0":"w-full"} animate-width overflow-hidden"> ${e.title} </div> </div> </a> </li> `)}`:y}render(){return c` <ix-icon-button @click="${this.toggleCompact}" icon="chevron_right" class="drop-shadow-lg items-center expand-cta bg-white rounded-full text-slate-600 h-8 w-8 absolute z-20 lg:right-0 lg:top-[34px] hidden top-[27px] right-[-8px] sm:flex ${this.compact?"animate-spin-180-backwards":"animate-spin-180-forwards"}"> </ix-icon-button> <nav class="flex flex-col overflow-hidden min-h-full rounded-xl drop-shadow text-center nav-bar long text-white ${this.compact?"closed":""} whitespace-nowrap animate-width"> <div class="m-1 px-6 py-4 hidden sm:block"> <svg @click="${this.toggleCompact}" focusable="false" viewBox="0 0 178 27" fill="white" class="w-[200px]"> ${Ze.digitalRealtyLogoWithText} </svg> </div> <hr class="divider hidden sm:block"> <ul class="grow"> ${this.renderNavigation()} </ul> <dev-clear-storage-button class="white-icon self-start p-5"></dev-clear-storage-button> </nav> `}};r([d({type:Boolean})],At.prototype,"compact",void 0),At=r([A("navigation-bar")],At);const cs=$`ix-dialog{--md-dialog-container-color:#fff}ix-icon-button{--md-sys-color-on-surface-variant:var(--md-sys-color-primary)}ix-select{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd;--md-menu-container-color:#fff}ix-select.thick{--md-menu-container-shape:10px}ix-select.slim{--md-outlined-field-bottom-space:2px;--md-outlined-field-top-space:2px}ix-button{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd}ix-button .disabled{color:var(--md-sys-text-color-disabled)}.btn_primary{--md-filled-button-container-color:var(--md-sys-color-primary)}.btn_primary ix-icon{color:var(--md-sys-color-on-primary)}.btn_secondary{--md-filled-button-container-color:var(--md-sys-color-secondary)}.btn_secondary ix-icon{color:var(--md-sys-color-on-secondary)}.btn_tertiary{--md-filled-button-container-color:var(--md-sys-color-tertiary)}.btn_tertiary ix-icon{color:var(--md-sys-color-on-tertiary)}.btn_danger{--md-filled-button-container-color:var(--md-sys-color-error)}.btn_danger ix-icon{color:var(--md-sys-color-on-error)}.icon-btn_primary ix-icon{color:var(--md-sys-color-primary)}.icon-btn_secondary ix-icon{color:var(--md-sys-color-secondary)}.icon-btn_tertiary ix-icon{color:var(--md-sys-color-tertiary)}.icon-btn_danger ix-icon{color:var(--md-sys-color-error)}ix-icon.icon-lg{--ix-icon-font-size:32px}.dialog-form{min-width:500px;display:flex;flex-direction:column;justify-content:space-between;padding:8px 24px 20px}.dialog-form .textfield{width:100%}.dialog-form.sm{min-width:560px}.dialog-form__textbox{padding-top:1rem}.dialog-actions{display:flex;justify-content:flex-end;padding:8px 15px 8px 20px}@media only screen and (min-width:5px) and (max-width:600px){ix-dialog{--md-dialog-container-shape:6px}}@media only screen and (min-width:601px){ix-dialog{--md-dialog-container-shape:3px}}.header-container{display:flex;align-items:center;margin-bottom:16px}.header-container-back-btn{display:flex;flex-direction:row;justify-content:space-between;align-items:center}.back{padding-left:12px}.arrow-back-icon{font-size:22px;align-items:center;padding-right:1px}.header-rhs-actions{display:flex;flex-direction:row;justify-content:space-between;align-items:center}.profile{background-color:#092241;height:35px;margin-right:30px;margin-left:30px;border-radius:10px;color:#fff;padding-left:20px;padding-right:20px;display:flex;align-items:center}.logout{height:35px;border-radius:10px;border:none;background-color:#1456e0;color:#fff;cursor:pointer;display:flex;align-items:center;justify-content:center;padding-left:15px;padding-right:15px}.logout svg{width:1em;height:1em;font-size:20px;margin-right:5px}.add-icon{font-size:20px;align-items:center}`;let Ce=class extends Ue{constructor(){super(...arguments),this.updateLayoutBinding=this.updateLayout.bind(this),this.pageTitle="",this.showCreateUserButton=!1,this.showHeader=!0}connectedCallback(){super.connectedCallback(),window.addEventListener(S.RouteChanged,this.updateLayoutBinding)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener(S.RouteChanged,this.updateLayoutBinding)}updateLayout(e){switch(this.pageTitle=e.detail.location.route.name||"",this.pageTitle){case"User Management":this.showCreateUserButton=B.hasExternalUserCreate(),this.showHeader=!0;break;case"Role Management":this.showCreateUserButton=!1,this.showHeader=!0;break;case"User Management Details":this.showCreateUserButton=!1,this.showHeader=!1;break}}getRoute(){return this.pageTitle==="User Management Details"?G.UserManagement:G.Home}dispatchCreateUserEvent(){Pe(this,S.CreateUser)}renderAppHeader(){return c` <div class="flex gap-2 items-center mt-4 mb-8 justify-between"> <div> ${this.showHeader?c`<h1 class="dlr-text-page-title">${this.pageTitle}</h1>`:c` <um-back-button .routeName="${this.getRoute()}"></um-back-button> `} </div> <div class="items-center flex gap-2 flex-wrap justify-end"> ${this.showCreateUserButton?c` <ix-button @click="${this.dispatchCreateUserEvent}" has-icon data-testid="create-user-button"> Create User <md-icon slot="icon">add</md-icon> </ix-button> `:y} </div> </div> `}render(){return c`${this.renderAppHeader()}`}};Ce.styles=[_,cs],r([d({type:String})],Ce.prototype,"pageTitle",void 0),r([m()],Ce.prototype,"showCreateUserButton",void 0),r([m()],Ce.prototype,"showHeader",void 0),Ce=r([A("app-header")],Ce);const Do=$`ix-dialog{--md-dialog-container-color:#fff}ix-icon-button{--md-sys-color-on-surface-variant:var(--md-sys-color-primary)}ix-select{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd;--md-menu-container-color:#fff}ix-select.thick{--md-menu-container-shape:10px}ix-select.slim{--md-outlined-field-bottom-space:2px;--md-outlined-field-top-space:2px}ix-button{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd}ix-button .disabled{color:var(--md-sys-text-color-disabled)}.btn_primary{--md-filled-button-container-color:var(--md-sys-color-primary)}.btn_primary ix-icon{color:var(--md-sys-color-on-primary)}.btn_secondary{--md-filled-button-container-color:var(--md-sys-color-secondary)}.btn_secondary ix-icon{color:var(--md-sys-color-on-secondary)}.btn_tertiary{--md-filled-button-container-color:var(--md-sys-color-tertiary)}.btn_tertiary ix-icon{color:var(--md-sys-color-on-tertiary)}.btn_danger{--md-filled-button-container-color:var(--md-sys-color-error)}.btn_danger ix-icon{color:var(--md-sys-color-on-error)}.icon-btn_primary ix-icon{color:var(--md-sys-color-primary)}.icon-btn_secondary ix-icon{color:var(--md-sys-color-secondary)}.icon-btn_tertiary ix-icon{color:var(--md-sys-color-tertiary)}.icon-btn_danger ix-icon{color:var(--md-sys-color-error)}ix-icon.icon-lg{--ix-icon-font-size:32px}.dialog-form{min-width:500px;display:flex;flex-direction:column;justify-content:space-between;padding:8px 24px 20px}.dialog-form .textfield{width:100%}.dialog-form.sm{min-width:560px}.dialog-form__textbox{padding-top:1rem}.dialog-actions{display:flex;justify-content:flex-end;padding:8px 15px 8px 20px}@media only screen and (min-width:5px) and (max-width:600px){ix-dialog{--md-dialog-container-shape:6px}}@media only screen and (min-width:601px){ix-dialog{--md-dialog-container-shape:3px}}:host{--md-outlined-text-field-label-text-color:black}.input-group{display:flex;flex-direction:row;gap:20px;margin-bottom:20px}.input-group ix-phone-input,.input-group ix-textbox{flex:1}.textfield{width:100%}ix-button{font-family:var(--root-secondary-font)}@media screen and (max-width:600px){.input-group{flex-direction:column}}`,J=e=>e?e.component.value:null,Xe=(e,t)=>{if(!e)return;const o=e.component;o.value=t},_e=e=>{if(!e)return null;const{input:t}=e;return t.value},Ct=(e,t)=>{if(!e)return;const{input:o}=e;o.value=t},ds=e=>e?e.component.checked:null,us=(e,t)=>{if(!e)return;const o=e.component;o.checked=t};function Po(e){const t=JSON.stringify(e);return JSON.parse(t)}const hs=(e,t,o)=>e.sort((i,n)=>(i[t]<n[t]?-1:1)*(o?1:-1));function ps(e){const t={};for(const[o,i]of Object.entries(e))for(const n of o.split(" "))t[n]=i;return Zi(t)}const ms=e=>{try{const t=e.startsWith("+")?Xt(e):Xt(`+${e}`),o=`+${t.countryCallingCode} ${new Ji(t.country||"US").input(t.nationalNumber)}`;return o.endsWith(")")||o.endsWith("(")?e:o}catch(t){return e}},gs=()=>window.matchMedia("(min-width: 1024px)").matches,Me={phone:"^[+]?[(]?[0-9]{3}[)]?[-s.]?[0-9]{3}[-s.]?[0-9]{4,6}$",name:N().UserManagement.UI.ValidationRegexPatterns.name,alphabetOnly:"^[A-Za-z]+$"},Oe=(e,t)=>{const o=e;return"component"in o&&o.component.reportValidity(),t?(o.error=!1,o.errorText="",!0):(o.error=!0,o.errorText="This field is mandatory",!1)},Mo=(e,t,o)=>{const i=e;return t!=null&&t.match(i.pattern)?(i.error=!1,i.errorText="",!0):(i.error=!0,i.errorText=o,!1)},Oo=(e,t,o)=>{if(!t)return!1;const i=e;return Wi.isEmail(t)?(i.error=!1,i.errorText="",!0):(i.error=!0,i.errorText=o,!1)},fs=e=>e.error,vs=(e,t)=>{const o=t;return J(e)===o},_t=(e,t,o)=>{const i=J(e);return e.required&&!Oe(e,i)||e.pattern&&!Mo(e,i,o)||e.type==="email"&&!Oo(e,i,o)?!1:!(fs(e)||vs(e,t))},Tt=(e,t)=>{const o=_e(e),i=e;return Ki(o)?(i.error=!1,!0):(i.error=!0,i.errorText=t,!1)},ys=(e,t)=>{t.length>0&&t.forEach(o=>{const i=e.find(n=>n.id===o.field);i&&(i.error=!0,i.errorText=o.error,i.focus())})},w={CancelCreateUser:"cancel-create-user",CloseDrawer:"close-drawer",CreateContact:"create-contact",CreateNewContact:"create-new-contact",EvacAssistanceRequired:"evac-assistance-required",NextButtonToggle:"next-button-toggle",NextStep:"next-step",ResetSuccess:"reset-success",SetStep:"set-step",ToggleDialog:"toggle-dialog",ToggleDraft:"toggle-draft",ToggleDrawer:"toggle-drawer",UpdateAccounts:"update-accounts",UpdateAttachments:"update-attachments",UpdateContact:"update-contact",UpdateDFA:"update-dfa",UpdateFlags:"update-flags",UpdateObofSelections:"update-obof-selections",ValidateStep:"validate-step"};let fe=class extends I{constructor(){super(...arguments),this.validatingForm=!1,this._newContact={firstName:"",lastName:"",email:"",phone:"",accounts:[],evacAssistance:!1},this._nextButtonEnabled=!1}firstUpdated(){this._newContact=this.newContact,this.validateStep(),this.dispatchValidateStepEvent()}get firstName(){return this.renderRoot.querySelector("#first-name")}get lastName(){return this.renderRoot.querySelector("#last-name")}get email(){return this.renderRoot.querySelector("#email")}get phone(){return this.renderRoot.querySelector("#phone-number")}validateStep(){this._nextButtonEnabled=!(this.isInvalid()||this.isEmpty())}validateInput(e,t){const o=J(e);if(this.updateContactDetails(),e.required&&!Oe(e,o)){this._nextButtonEnabled=!1;return}e.pattern&&!Mo(e,o,t)&&(this._nextButtonEnabled=!1),this.validateStep(),this.dispatchNextButtonToggleEvent()}async validateEmailInput(e,t){this._nextButtonEnabled=!1;const o=J(e);if(this.updateContactDetails(),e.required&&!Oe(e,o)){this._nextButtonEnabled=!1;return}if(!Oo(e,o,t)){this._nextButtonEnabled=!1;return}clearTimeout(this.debounceTimeout),this.debounceTimeout=window.setTimeout(async()=>{const i={emailVerificationInput:{email_address:o!=null?o:""}};try{(await v.VerificationApi.verifyEmail(i)).is_verified?(e.error=!1,e.errorText="",this._nextButtonEnabled=!(this.isInvalid()||this.isEmpty())):(e.error=!0,e.errorText=`${t}`,this._nextButtonEnabled=!1)}catch(n){e.error=!0,e.errorText="An error occurred during email verification. Please try again later.",this._nextButtonEnabled=!1}},500),this.validateStep(),this.dispatchNextButtonToggleEvent()}validatePhoneInput(e,t){const o=_e(e);if(Ct(e,o),this.updateContactDetails(),e.required&&!Oe(e,o)){this._nextButtonEnabled=!1;return}if(!Tt(e,t)){this._nextButtonEnabled=!1;return}this.validateStep(),this.dispatchNextButtonToggleEvent()}updateContactDetails(){var e,t,o,i;this._newContact={firstName:(e=J(this.firstName))!==null&&e!==void 0?e:"",lastName:(t=J(this.lastName))!==null&&t!==void 0?t:"",email:(o=J(this.email))!==null&&o!==void 0?o:"",phone:(i=_e(this.phone))!==null&&i!==void 0?i:"",accounts:this._newContact.accounts,evacAssistance:this._newContact.evacAssistance},this.dispatchUpdateContactEvent()}clearTextFields(){this._newContact={firstName:"",lastName:"",email:"",phone:"",accounts:[],evacAssistance:!1},Xe(this.firstName,""),Xe(this.lastName,""),Xe(this.email,""),this.phone.reset(),Ct(this.phone,"")}resetErrorStates(){this.firstName.error=!1,this.lastName.error=!1,this.email.error=!1,this.phone.error=!1}isInvalid(){return this.firstName.error||this.lastName.error||this.email.error||this.phone.error}isEmpty(){return!this._newContact.firstName||!this._newContact.lastName||!this._newContact.email||!this._newContact.phone}dispatchNextStepEvent(){this.dispatchEvent(new CustomEvent(w.NextStep,{bubbles:!0,composed:!0}))}dispatchUpdateContactEvent(){const e=new CustomEvent(w.UpdateContact,{detail:{newContact:this._newContact},bubbles:!0,composed:!0});this.dispatchEvent(e)}dispatchNextButtonToggleEvent(){this.dispatchEvent(new CustomEvent(w.NextButtonToggle,{detail:this._nextButtonEnabled,bubbles:!0,composed:!0}))}dispatchValidateStepEvent(){this.dispatchEvent(new CustomEvent(w.ValidateStep,{detail:this._nextButtonEnabled,bubbles:!0,composed:!0}))}render(){return c` <div class="input-group"> <ix-textbox required id="first-name" label="First name" name="first-name" type="text" value="${this._newContact.firstName}" @input="${()=>this.validateInput(this.firstName,"Invalid first name")}" pattern="${Me.name}" maxLength="50" data-testid="step-one-first-name"></ix-textbox> <ix-textbox required id="last-name" label="Last name" name="last-name" type="text" value="${this._newContact.lastName}" @input="${()=>this.validateInput(this.lastName,"Invalid last name")}" pattern="${Me.name}" maxLength="50" data-testid="step-one-last-name"></ix-textbox> </div> <div class="input-group"> <ix-textbox required id="email" label="Email Address" name="email" type="email" value="${this._newContact.email}" @input="${()=>this.validateEmailInput(this.email,"Invalid email address")}" data-testid="step-one-email"></ix-textbox> <ix-phone-input required id="phone-number" label="Phone Number" name="phone" value="${this._newContact.phone}" @input="${()=>this.validatePhoneInput(this.phone,"Invalid phone number")}" @country-change="${()=>this.phone.value?this.validatePhoneInput(this.phone,"Invalid phone number"):null}" data-testid="step-one-phone-number"></ix-phone-input> </div> <div style="display:flex;justify-content:flex-end;padding-top:8px"> <ix-button type="submit" ?disabled="${!this._nextButtonEnabled||this.validatingForm}" has-icon trailing-icon @click="${this.dispatchNextStepEvent}" data-testid="step-one-next-button"> Next <md-icon slot="icon">east</md-icon> </ix-button> </div> `}};fe.styles=[Do,_],r([d({type:Object})],fe.prototype,"newContact",void 0),r([d({type:Boolean})],fe.prototype,"validatingForm",void 0),r([m()],fe.prototype,"_newContact",void 0),r([m()],fe.prototype,"_nextButtonEnabled",void 0),fe=r([A("create-user-step-one")],fe);function It(e){var t;for(const o of e)if(o.checked||!((t=o.children)===null||t===void 0)&&t.length&&It(o.children))return!0;return!1}function Et(e){return e.some(t=>t.subaccounts.length)?"nested":"flat"}function Be(e,t){var o,i;if(t==="flat")return e.filter(a=>a.checked);const n=[];for(const a of e){a.checked&&n.push(a);const s=(o=a.children)===null||o===void 0?void 0:o.every(l=>l.checked);if(!((i=a.children)===null||i===void 0)&&i.length&&(a.indeterminate||!s)){const l=Be(a.children,t);n.push(...l)}}return n}function bs(e){const t=[];function o(i){i.checked&&t.push(i.id),i.children&&i.children.forEach(n=>{o(n)})}return e.forEach(i=>{o(i)}),t}function Rt(e){return Be([e],"nested").map(t=>t.id||t.label)}const Bo=e=>{var t;return{authorityDocumentId:e.authority_document_id,changeHistoryId:e.change_history_id,fileName:e.file_name,createdAt:(t=e.created_at)===null||t===void 0?void 0:t.toString(),createdBy:e.created_by}},xs=e=>({file:e.file,fileName:e.fileName}),ws=e=>({id:e.id});class As{async create(t){try{const o=xs(t),i=await v.AuthorityDocumentsApi.postAuthorityDocuments(o);return Bo(i)}catch(o){return g.handleError(o,"Failed to upload authority document."),{}}}async getById(t){try{const o=ws(t),i=await v.AuthorityDocumentsApi.getAuthorityDocument(o);return Bo(i)}catch(o){return g.handleError(o,"Failed to get authority document."),{}}}async download(t){try{return await v.AuthorityDocumentsApi.downloadAuthorityDocuments({id:t})}catch(o){g.handleError(o,"Failed to download authority document.");return}}}const Lo=new As,qo=()=>N().UserManagement.UI.AuthorityDocuments.MaxFileSizeMB,Ho=()=>N().UserManagement.UI.AuthorityDocuments.AcceptedExtensions,Cs=e=>{const t={file:e,fileName:e.name};return Lo.create(t)},zo=128;function Vo(){const e=N().UserManagement.UI.AuthorityDocuments;return{minAttachments:1,maxFileSizeMB:e.MaxFileSizeMB,acceptedExtensions:e.AcceptedExtensions,fileNamePattern:new RegExp(e.FileNamePattern)}}function jo(e,t){var o;const i=[],n=t.maxFileSizeMB*1024*1024;e.size>n&&i.push({code:"SIZE_EXCEEDED",message:`File exceeds the maximum size of ${t.maxFileSizeMB}MB.`,fileName:e.name});const a=((o=e.name.split(".").pop())===null||o===void 0?void 0:o.toLowerCase())||"";a&&!t.acceptedExtensions.includes(a)&&i.push({code:"INVALID_EXTENSION",message:`File extension for '${e.name}' is not allowed.`,fileName:e.name});const s=/^[A-Za-z0-9._() -]+$/;return t.fileNamePattern.test(e.name)||s.test(e.name)||i.push({code:"INVALID_FILENAME",message:"Filename must not contain special characters. Allowed: A-Z a-z 0-9 _ - .",fileName:e.name}),e.name.length>zo&&i.push({code:"FILENAME_TOO_LONG",message:`Filename must not exceed ${zo} characters.`,fileName:e.name}),i}function Go(e,t){return jo(e,t)}function Jo(e,t){const o={isValid:!0,errors:[],fileErrors:new Map};if(!e||e.length===0)return o.isValid=!1,o.errors.push({code:"MIN_ATTACHMENTS_REQUIRED",message:"At least one document is required."}),o;for(const i of e){const n=jo(i,t);n.length>0&&(o.isValid=!1,o.fileErrors.set(i.name,n))}return o}class _s{constructor(t){this._attachments=[],this._validationResult=null,this._documentsRequired=!1,this._onStateChanged=null,this._config=t||Vo()}get attachments(){return this._attachments}get validationResult(){return this._validationResult}get isValid(){return this._validationResult?this._validationResult.isValid:!0}get documentsRequired(){return this._documentsRequired}get canProceed(){return this._documentsRequired?this.isValid&&this._attachments.length>0:this.isValid}addFiles(t){const o=new Map;for(const i of t){const n=Go(i,this._config);if(n.length>0)o.set(i.name,n);else{const a=Object.assign(i,{id:this.generateFileId(i)});this._attachments.some(s=>s.name===a.name&&s.size===a.size)||this._attachments.push(a)}}this.validateCurrent();for(const[i,n]of o)this._validationResult.fileErrors.set(i,n);this.notifyStateChanged()}removeFile(t){const o=this._attachments.length;this._attachments=this._attachments.filter(i=>!(i.name===t||i.id===t||this.getFileKey(i)===t)),this._attachments.length!==o&&(this.validateCurrent(),this.notifyStateChanged())}clearAll(){this._attachments=[],this.validateCurrent(),this.notifyStateChanged()}validateCurrent(){if(this._attachments.length===0){this._validationResult={isValid:!0,errors:[],fileErrors:new Map};return}const t=this._attachments.map(o=>new File([o],o.name,{type:o.type}));this._validationResult=Jo(t,this._config)}getFileErrors(t){return this._validationResult?this._validationResult.fileErrors.get(t)||[]:[]}setDocumentsRequired(t){this._documentsRequired!==t&&(this._documentsRequired=t,this.notifyStateChanged())}onStateChanged(t){this._onStateChanged=t}generateFileId(t){return`${Date.now()}-${t.name}-${t.size}`}getFileKey(t){return t.id||t.name}notifyStateChanged(){this._onStateChanged&&this._onStateChanged()}}function Ko(e){return new _s(e)}const Ts=e=>({id:e.id,firstName:e.first_name,lastName:e.last_name,email:e.email,accountPermissionGroup:e.account_permission_group,accountAssociations:e.account_associations}),Is=e=>{var t;return{items:((t=e.items)!==null&&t!==void 0?t:[]).map(Ts)}};class Es{async get(t={}){try{const o=await v.UsersApi.getMyAccountsAdminsAndApprovers({isMyAccountRequest:t.isMyAccountRequest});return Is(o).items}catch(o){return g.handleError(o,"Failed to get account admins and approvers."),[]}}}const Rs=new Es,Ss=()=>Rs.get({isMyAccountRequest:!1}),Zo=async e=>(await Ss()).filter(t=>{var o;return(o=t.accountAssociations)===null||o===void 0?void 0:o.includes(e)}),z={RequestedByCustomer:"REQUESTED_BY_CUSTOMER",NoUserAvailable:"NO_USER_AVAILABLE",NewCustomer:"NEW_CUSTOMER"};class et{constructor(t="",o="",i=o,n=""){this.value=t,this.displayText=o,this.name=i,this.email=n}isValid(){return this.value!==""}}const ks=e=>({id:e.id,name:e.account_name,status:e.status,accountNumber:e.account_number,displayName:e.account_friendly_name,statusUpdateAt:e.updated_at,statusUpdateBy:e.updated_by}),St=e=>{var t;const o=[];return(t=e.account_associations)===null||t===void 0||t.forEach(i=>{o.push(ks(i))}),{id:e.id,firstName:e.first_name,lastName:e.last_name,email:e.email,phone:e.phone,evacAssistance:e.evacuation_assistance_required,accounts:o,status:"Active"}},Us=e=>{var t;const o=[];return(t=e.accounts)===null||t===void 0||t.forEach(i=>{o.includes(i.accountNumber)||o.push(i.accountNumber)}),{first_name:e.firstName,last_name:e.lastName,email:e.email,phone:e.phone,account_numbers:o,evacuation_assistance_required:e.evacAssistance}},$s=e=>({id:e.id,first_name:e.firstName,last_name:e.lastName,email:e.email,phone:e.phone,evacuation_assistance_required:e.evacAssistance}),Ns=e=>({accountNumber:e.accountNumber,includeChildAccounts:!0,page:e.page,size:e.size,firstName:e.firstName,lastName:e.lastName,email:e.email,sort:e.sort,order:e.order}),Fs=e=>{var t,o;const i=[];return(t=e.content)===null||t===void 0||t.forEach(n=>{i.push(St(n))}),{contacts:i,recordCount:(o=e.pageable)===null||o===void 0?void 0:o.total_elements}},Ds=e=>({id:e.id}),Ps=e=>({id:e.id,userProfile:$s(e.contactInput)}),Ms=e=>({userInput:{...Us(e.contactInput),change_history_id:e.changeHistoryId}});class Os{async update(t){try{const o=Ps(t);return v.UsersApi.updateUser(o)}catch(o){return g.handleError("Failed to update user.")}}async create(t){try{const o=Ms(t),i=await v.UsersApi.createUser(o);return St(i)}catch(o){return g.handleError(o,`Failed to create user for ${t.contactInput.email}`),{}}}async search(t){try{const o=Ns(t),i=await v.UsersApi.getUsers(o);return Fs(i)}catch(o){return g.handleError(o,"Failed to get users."),{}}}async get(t){try{const o=Ds(t),i=await v.UsersApi.getUser(o);return St(i)}catch(o){return t!=null&&t.failSilently?{}:(g.handleError(o,"Failed to get user."),{})}}async getUsersReport(t){try{const o={accountNumber:t.accountNumber,includeChildAccounts:t.includeChildAccounts,firstName:t.firstName,lastName:t.lastName,email:t.email};return await v.UsersApi.getUserReport(o)}catch(o){throw g.handleError(o,"Failed to download users report."),o}}}const tt=new Os,Wo=e=>{const t=[...e.entries()].map(([o,i])=>({accountNumber:o,value:i.value})).filter(o=>!!o.value);if(t.length)return t.map(o=>o.value===z.NoUserAvailable?{reason:z.NoUserAvailable,authoriserUserId:"",accountNumber:o.accountNumber}:o.value===z.NewCustomer?{reason:z.NewCustomer,authoriserUserId:"",accountNumber:o.accountNumber}:{reason:z.RequestedByCustomer,authoriserUserId:o.value,accountNumber:o.accountNumber})},Qo=async e=>{const t=(await Promise.all(e.map(o=>Cs(o)))).map(o=>o.authorityDocumentId).filter(Boolean);if(t.length!==e.length)throw new Error("Failed to upload all authority documents.");return t},kt={noUserAvailable:"No User with Proper Permissions Available",newCustomer:"New Customer"},Yo=(e,t,o)=>e?"loading":t>0?"selectable":o?"no-user":"new-customer",Xo=(e,t)=>{const o=new Map(e!=null?e:new Map);t.forEach(n=>{o.has(n)||o.set(n,new et)});const i=new Set(t);return[...o.keys()].forEach(n=>{i.has(n)||o.delete(n)}),o},ei=(e,t)=>e.every(o=>{var i,n;return(n=(i=t==null?void 0:t.get(o))===null||i===void 0?void 0:i.isValid())!==null&&n!==void 0?n:!1}),Ut=(e,t,o,i=[])=>{if(!e||!t||!o||o.size===0)return!1;const n=new Set(i),a=[...o.entries()].filter(([s])=>!n.size||n.has(s)).map(([,s])=>s).filter(s=>!!(s!=null&&s.value));return a.length?a.some(s=>s.value!==z.NewCustomer):!1},ti="data-wrap-patch";function oi(e,t){if(e.querySelector(`style[${ti}]`))return;const o=document.createElement("style");o.setAttribute(ti,""),o.textContent=t,e.appendChild(o)}function Bs(e){const t=()=>{const i=e.shadowRoot;i&&oi(i,`
2033
2033
  .file-chip { height: auto; min-height: 40px; flex-wrap: wrap; }
2034
2034
  .file-chip__name {
2035
2035
  white-space: normal;
@@ -2038,7 +2038,7 @@ video {
2038
2038
  min-width: 0;
2039
2039
  flex: 1 1 auto;
2040
2040
  }
2041
- `)},{updateComplete:o}=e;o&&typeof o.then=="function"?o.then(t,()=>{}):t()}function qs(e){try{const t=e.shadowRoot;if(!t)return()=>{};const o=()=>{ni(t,"ix-file-chip { max-width: 100%; min-width: 0; }"),t.querySelectorAll("ix-file-chip").forEach(Ls)};o();const i=new MutationObserver(o);return i.observe(t,{childList:!0,subtree:!0}),()=>i.disconnect()}catch(t){return()=>{}}}let P=class extends I{constructor(){super(...arguments),this.obofEnabled=!1,this.accountStructure="flat",this._nextButtonEnabled=!1,this._obofCreatorsByAccount=new Map,this._accountHierarchyHasUsers=new Map,this._loadingObofForAccounts=new Set,this._documentsRequired=!1,this._uploadErrors=[],this._uploaderInstanceKey=0,this.attachments=[],this._attachmentManager=Wo(),this.handleUploaderRef=e=>{var t;(t=this._chipWrapCleanup)===null||t===void 0||t.call(this),this._chipWrapCleanup=e?qs(e):void 0}}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this._chipWrapCleanup)===null||e===void 0||e.call(this),this._chipWrapCleanup=void 0}async connectedCallback(){super.connectedCallback(),this._accountTree=this.accountTree,this.obofSelections||(this.obofSelections=new Map),this.updateDocumentsRequired(),this.attachments.length&&(this._attachmentManager.addFiles(this.attachments),this.syncUploadErrorsFromManager()),await this.syncObofState(),this.validateStep(),this.dispatchValidateStepEvent()}updateDocumentsRequired(){const e=this.getSelectedAccountIds(),t=$t(this.obofEnabled,e.length>0,this.obofSelections,e);this._documentsRequired&&!t&&this.clearAttachments(),this._documentsRequired=t,this._attachmentManager.setDocumentsRequired(this._documentsRequired)}clearAttachments(){this._attachmentManager.clearAll(),this.attachments=[],this._uploadErrors=[],this._uploaderInstanceKey+=1,this.dispatchAttachmentsUpdateEvent(this.attachments)}async updated(e){super.updated(e),e.has("accountTree")&&this.accountTree!==this._accountTree&&(this._accountTree=this.accountTree,await this.syncObofState(),this.updateDocumentsRequired(),this.validateStep(),this.dispatchValidateStepEvent(),this.dispatchNextButtonToggleEvent()),e.has("attachments")&&this.requestUpdate()}getSelectedAccountNodes(){return this._accountTree?Rt(this._accountTree.children||[]):[]}getAllCheckedAccountIds(e){const t=[];for(const o of e){if(o.checked){const i=o.id||o.label;i&&t.push(i)}o.children&&o.children.length>0&&t.push(...this.getAllCheckedAccountIds(o.children))}return t}async syncObofState(){if(!this.obofEnabled||!this._accountTree)return;const e=this.getSelectedAccountNodes();if(e.length===0)return;const t=e.map(o=>o.id||o.label);await this.loadObofCreatorsForAccounts(t)}getSelectedAccountIds(){return this.getSelectedAccountNodes().map(e=>e.id||e.label)}getAncestorAccountIds(e){const t=[e],o=(n,a)=>{if(!n.children)return null;for(const s of n.children){if((s.id||s.label)===a)return n;const l=o(s,a);if(l)return l}return null};if(!this._accountTree)return t;let i=e;for(;i;){const n=o(this._accountTree,i);if(!n||n.id==="root")break;const a=n.id||n.label;if(a&&a!=="root")t.push(a),i=a;else break}return t}async loadObofCreatorsForAccounts(e){if(!this.obofEnabled)return;const t=e.filter(h=>!this._obofCreatorsByAccount.has(h)&&!this._loadingObofForAccounts.has(h));if(t.length===0)return;const o=new Set(this._loadingObofForAccounts);t.forEach(h=>o.add(h)),this._loadingObofForAccounts=o;const i=this._accountTree?this.getAllCheckedAccountIds([this._accountTree]):[];let n=[];if(t.length>0&&i.length>0)try{const h=this.getAncestorAccountIds(t[0]),u=h[h.length-1],b=await et.search({accountNumber:u,page:0,size:1e3});b.contacts&&b.contacts.length>0&&(n=b.contacts.filter(F=>F.accounts.some(se=>i.includes(se.accountNumber))))}catch(h){}const a=await Promise.all(t.map(async h=>{try{const u=(await Qo(h)).filter(F=>F.accountPermissionGroup===Ao.OnBehalfUserCreator);let b=!1;return u.length===0&&(b=n.some(F=>F.accounts.some(se=>se.accountNumber===h))),{accountId:h,creators:u,hierarchyHasUsers:b}}catch(u){return{accountId:h,creators:[],hierarchyHasUsers:!1}}})),s=new Map(this._obofCreatorsByAccount),l=new Map(this._accountHierarchyHasUsers),p=new Set(this._loadingObofForAccounts);a.forEach(({accountId:h,creators:u,hierarchyHasUsers:b})=>{s.set(h,u),l.set(h,b),p.delete(h)}),this._obofCreatorsByAccount=s,this._accountHierarchyHasUsers=l,this._loadingObofForAccounts=p,this.requestUpdate(),await this.updateComplete,this.validateStep(),this.dispatchNextButtonToggleEvent()}onFileClicked(){}syncUploadErrorsFromManager(){const e=this._attachmentManager.validationResult;if(!(!e||e.fileErrors.size===0))for(const t of e.fileErrors.values())this._uploadErrors.push(...t.map(o=>o.message))}onFileRemoved(e){if(!(e!=null&&e.detail))return;const t=e.detail.allFiles||[];this._attachmentManager.clearAll(),this._attachmentManager.addFiles(t),this.attachments=[...this._attachmentManager.attachments],this._uploadErrors=[],this.syncUploadErrorsFromManager(),this.dispatchAttachmentsUpdateEvent(this.attachments),this.validateStep(),this.requestUpdate()}onUploaded(e){const{filesUploaded:t}=e.detail;this._uploadErrors=[];const o=t.map(i=>i.file);this._attachmentManager.addFiles(o),o.some(i=>this._attachmentManager.getFileErrors(i.name).length>0)&&(this._uploaderInstanceKey+=1),this.attachments=[...this._attachmentManager.attachments],this.syncUploadErrorsFromManager(),this.dispatchAttachmentsUpdateEvent(this.attachments),this.validateStep(),this.requestUpdate()}handleObofOptionClick(e,t,o,i=o,n=""){const a=new Xe(t,o,i,n),s=new Map(this.obofSelections);for(const l of St(e))s.set(l,a);this.obofSelections=s,this.dispatchObofSelectionsUpdateEvent(),this.updateDocumentsRequired(),this.requestUpdate(),this.validateStep(),this.dispatchNextButtonToggleEvent()}renderObofs(){if(!this.obofEnabled)return y;const e=this.getSelectedAccountNodes();return e.length===0?y:c` <div class="mt-4 overflow-y-auto" style="max-height:200px"> ${e.map(t=>this.renderObofUserSelect(t))} </div> `}renderObofUserSelect(e){var t;const o=e.id||e.label,i=this._loadingObofForAccounts.has(o),n=this._obofCreatorsByAccount.get(o)||[],a=this._accountHierarchyHasUsers.get(o)||!1,s=((t=this.obofSelections)===null||t===void 0?void 0:t.get(o))||new Xe,l=s.value,p=ei(i,n.length,a);let h;if(p==="loading")h=c` <ix-select-option value="loading" display-text="Loading users..." disabled="disabled" selected="selected"> Loading users... </ix-select-option> `;else if(p==="selectable")h=c` ${n.map(u=>{const b=u.id;if(!b)return y;const F=`${u.firstName} ${u.lastName}`,se=`${F} (${u.email})`;return c` <ix-select-option value="${b}" display-text="${se}" ?selected="${l===b}" @click="${()=>this.handleObofOptionClick(e,b,se,F,u.email)}"> ${se} </ix-select-option> `})} `;else if(p==="no-user"){const u=Ut.noUserAvailable;h=c` <ix-select-option value="${z.NoUserAvailable}" display-text="${u}" ?selected="${l===z.NoUserAvailable}" @click="${()=>this.handleObofOptionClick(e,z.NoUserAvailable,u)}"> ${u} </ix-select-option> `}else{const u=Ut.newCustomer;h=c` <ix-select-option value="${z.NewCustomer}" display-text="${u}" ?selected="${l===z.NewCustomer}" @click="${()=>this.handleObofOptionClick(e,z.NewCustomer,u)}"> ${u} </ix-select-option> `}return c` <div class="mb-3"> <label for="obof-${o}-menu" class="text-sm font-medium" style="display:block;margin-bottom:8px"> ${e.label} </label> <ix-select quick menu-below class="w-full" id="obof-${o}-menu" menu-positioning="fixed" label="${i?"Loading users...":"Created on Behalf of*"}" .displayText="${i?"Loading users...":s.displayText}" ?disabled="${i}"> ${h} </ix-select> </div> `}renderDocumentUpload(){const e=this.getSelectedAccountIds(),t=e.length>0;if(!$t(this.obofEnabled,t,this.obofSelections,e))return y;const o=zo(),i=Vo(),n=i.map(s=>s.toUpperCase()).join(", "),a=`Max file size is ${o} MB with accepted file formats of ${n}`;return c` <div class="mt-4"> <label class="text-sm font-medium" style="display:block;margin-bottom:8px"> Document(s) of Request${this._documentsRequired?"*":""} </label> ${Xi(this._uploaderInstanceKey,c` <ix-file-uploader ${en(this.handleUploaderRef)} .allowDeleteDefaultFiles="${!0}" .allowMultipleFiles="${!0}" .defaultFiles="${this.attachments}" .extensions="${i}" .maxFileSizeValue="${o}" .headerText="${"CLICK HERE TO BROWSE YOUR DEVICE OR DROP FILES TO UPLOAD"}" .bodyText="${a}" .hideBody="${!1}" @on-file-clicked="${this.onFileClicked}" @on-file-removed="${this.onFileRemoved}" @on-files-uploaded="${this.onUploaded}"></ix-file-uploader> `)} ${this.renderUploadErrors()} </div> `}renderUploadErrors(){return!this._uploadErrors||this._uploadErrors.length===0?y:c` <div role="alert" class="mt-3 p-3 rounded" style="background-color:#fee;border:1px solid #fcc;color:#c00;font-size:.875rem"> ${this._uploadErrors.map(e=>c`<p style="margin:.25rem 0">${e}</p>`)} </div> `}renderAccounts(){var e,t;if(!this._accountTree)return y;const o=(t=(e=this._accountTree)===null||e===void 0?void 0:e.children)===null||t===void 0?void 0:t.some(i=>{var n;return(n=i.children)===null||n===void 0?void 0:n.length});return c` <div class="overflow-auto" style="max-height:250px"> <ix-tree checkboxesEnabled .rootNode="${this._accountTree}" .rollup="${!1}" .disableEndNodePointer="${!0}" .selectNodeOnClick="${!0}" ?removeChevron="${!o}" @on-tree-node-checked="${()=>this.toggleAccountChecked()}" data-testid="step-two-account-tree"></ix-tree> </div> `}validateStep(){if(!this._accountTree||!this.ixTree)return;const e=Tt([this._accountTree]);if(this.obofEnabled&&e){const t=this.getSelectedAccountIds(),o=oi(t,this.obofSelections),i=this._attachmentManager.canProceed;this._nextButtonEnabled=e&&o&&i}else this._nextButtonEnabled=e;this.dispatchNextButtonToggleEvent()}async toggleAccountChecked(){if(!(!this._accountTree||!this.ixTree)){if(await this.ixTree.updateComplete,this._accountTree=this.ixTree.rootNode,this.obofEnabled){const e=this.getSelectedAccountNodes(),t=e.map(i=>i.id||i.label),o=e.flatMap(St);this.obofSelections=ti(this.obofSelections,o),this.dispatchObofSelectionsUpdateEvent(),await this.loadObofCreatorsForAccounts(t)}this.updateDocumentsRequired(),this.dispatchUpdateAccountsEvent(),this.validateStep(),this.dispatchNextButtonToggleEvent()}}dispatchUpdateAccountsEvent(){this.dispatchEvent(new CustomEvent(w.UpdateAccounts,{detail:{rootNode:this._accountTree},bubbles:!0,composed:!0}))}dispatchObofSelectionsUpdateEvent(){this.dispatchEvent(new CustomEvent(w.UpdateObofSelections,{detail:{obofSelections:this.obofSelections},bubbles:!0,composed:!0}))}dispatchAttachmentsUpdateEvent(e){this.dispatchEvent(new CustomEvent(w.UpdateAttachments,{detail:{attachments:e},bubbles:!0,composed:!0}))}dispatchNextStepEvent(){this.dispatchEvent(new CustomEvent(w.NextStep,{bubbles:!0,composed:!0}))}dispatchNextButtonToggleEvent(){this.dispatchEvent(new CustomEvent(w.NextButtonToggle,{detail:this._nextButtonEnabled,bubbles:!0,composed:!0}))}dispatchValidateStepEvent(){this.dispatchEvent(new CustomEvent(w.ValidateStep,{detail:this._nextButtonEnabled,bubbles:!0,composed:!0}))}render(){return c` <div class="flex flex-col" style="min-height:100%"> <div class="flex-1" style="padding-right:8px"> ${this.renderAccounts()} ${this.renderObofs()} ${this.renderDocumentUpload()} </div> <div class="flex justify-end" style="margin-top:24px"> <ix-button type="submit" ?disabled="${!this._nextButtonEnabled}" has-icon trailing-icon @click="${this.dispatchNextStepEvent}" data-testid="step-two-next-button"> NEXT <md-icon slot="icon">east</md-icon> </ix-button> </div> </div> `}};P.styles=[_,ge],r([d({type:Object})],P.prototype,"accountTree",void 0),r([d({type:Boolean})],P.prototype,"obofEnabled",void 0),r([d({type:String})],P.prototype,"accountStructure",void 0),r([m()],P.prototype,"_accountTree",void 0),r([m()],P.prototype,"_nextButtonEnabled",void 0),r([m()],P.prototype,"_obofCreatorsByAccount",void 0),r([m()],P.prototype,"_accountHierarchyHasUsers",void 0),r([m()],P.prototype,"_loadingObofForAccounts",void 0),r([m()],P.prototype,"_documentsRequired",void 0),r([m()],P.prototype,"_uploadErrors",void 0),r([m()],P.prototype,"_uploaderInstanceKey",void 0),r([d({type:Object})],P.prototype,"obofSelections",void 0),r([d({type:Array})],P.prototype,"attachments",void 0),r([D("ix-tree")],P.prototype,"ixTree",void 0),P=r([A("create-user-step-two")],P);const ai=$`ix-dialog{--md-dialog-container-color:#fff}ix-icon-button{--md-sys-color-on-surface-variant:var(--md-sys-color-primary)}ix-select{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd;--md-menu-container-color:#fff}ix-select.thick{--md-menu-container-shape:10px}ix-select.slim{--md-outlined-field-bottom-space:2px;--md-outlined-field-top-space:2px}ix-button{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd}ix-button .disabled{color:var(--md-sys-text-color-disabled)}.btn_primary{--md-filled-button-container-color:var(--md-sys-color-primary)}.btn_primary ix-icon{color:var(--md-sys-color-on-primary)}.btn_secondary{--md-filled-button-container-color:var(--md-sys-color-secondary)}.btn_secondary ix-icon{color:var(--md-sys-color-on-secondary)}.btn_tertiary{--md-filled-button-container-color:var(--md-sys-color-tertiary)}.btn_tertiary ix-icon{color:var(--md-sys-color-on-tertiary)}.btn_danger{--md-filled-button-container-color:var(--md-sys-color-error)}.btn_danger ix-icon{color:var(--md-sys-color-on-error)}.icon-btn_primary ix-icon{color:var(--md-sys-color-primary)}.icon-btn_secondary ix-icon{color:var(--md-sys-color-secondary)}.icon-btn_tertiary ix-icon{color:var(--md-sys-color-tertiary)}.icon-btn_danger ix-icon{color:var(--md-sys-color-error)}ix-icon.icon-lg{--ix-icon-font-size:32px}.dialog-form{min-width:500px;display:flex;flex-direction:column;justify-content:space-between;padding:8px 24px 20px}.dialog-form .textfield{width:100%}.dialog-form.sm{min-width:560px}.dialog-form__textbox{padding-top:1rem}.dialog-actions{display:flex;justify-content:flex-end;padding:8px 15px 8px 20px}@media only screen and (min-width:5px) and (max-width:600px){ix-dialog{--md-dialog-container-shape:6px}}@media only screen and (min-width:601px){ix-dialog{--md-dialog-container-shape:3px}}:host{--ix-chip-container-color:var(--md-sys-color-primary);--md-input-chip-outline-color:var(--md-sys-color-primary);--md-input-chip-label-text-color:white;--md-outlined-field-leading-content-color:black;--md-outlined-field-label-text-color:black}.accounts-roles-container{display:flex;flex-direction:column;margin-bottom:10px;padding-left:2px}.accounts-roles-container>*{padding-bottom:15px}.accounts-roles-container>:not(:first-child){padding-top:20px}.account-roles-name{padding-bottom:10px}.account-roles{display:flex;flex-direction:column;gap:8px;height:100%}ix-button{font-family:var(--root-secondary-font)}`;function he(e,t,o=void 0){const i=tn[e.type]||(e.type==="Port"?"":"chevron_right"),n={id:e.id,label:e.label,children:[],secondaryLabel:e.secondaryLabel,parentId:e.parentId,childrenCount:e.childrenCount,disabled:e.isAssignable===!1,checkedChildrenCount:e.checkedChildrenCount,indeterminate:e.status==="INDETERMINATE",customerKnownSpaceName:e.customerKnownSpaceName,checked:o!=null?o:e.status==="CHECKED",originalCheckedStatus:o!=null?o:e.status==="CHECKED",inherited:e.inherited,icon:i};return t.children.push(n),e.inventoryItems&&e.inventoryItems.forEach(a=>{he(a,n,o?n.checked:void 0)}),t}function Nt(e){var t;const o=i=>{i.checked=!1};return e.children&&!((t=e.children)===null||t===void 0)&&t.length&&e.children.forEach(i=>Nt(i)),o(e)}const le=[{key:"ACCOUNTING_CONTACT",text:"Accounting flag",desc:"Authorized to discuss billing issues with DLR Accounts Receivable Group."},{key:"OPERATIONS_CONTACT",text:"Operations flag",desc:"Receives Planned Maintenance, Corrective Maintenance and Project Work notifications. Point of contact for DLR operations team."},{key:"EMERGENCY_CONTACT",text:"Emergency flag",desc:"Receives Incident Notifications. Point of contact during unplanned, emergency maintenance."},{key:"INTERCONNECTION_NOTIFICATIONS",text:"Interconnection Notifications",desc:"Receives notifications about interconnectivity orders."}],Ft=e=>{var t;return(t=le.find(o=>o.text===e))===null||t===void 0?void 0:t.key},Hs=e=>{var t;return(t=le.find(o=>o.key===e))===null||t===void 0?void 0:t.text};let X=class extends I{constructor(){super(...arguments),this.checkedAccounts=[],this.roles=[],this.dataForAccounts=[],this.treeData=[],this._dataForAccounts=[],this._treeData=[],this._nextButtonEnabled=!1,this.multiSelectOpen=!1}connectedCallback(){super.connectedCallback(),this._dataForAccounts=this.dataForAccounts,this._treeData=this.treeData,this.validateStep(),this.dispatchValidateStepEvent()}getRoles(e){return this.roles.filter(t=>t.accountId===e)[0].roles}getRolesData(e){const t=this.roles.filter(i=>i.accountId===e)[0],o=[];return t.roles.forEach(i=>{var n;i.removed=!0;const a={id:"root",label:"",children:[],customerKnownSpaceName:""},s=(n=this._treeData.find(p=>p.accountNumber===e))===null||n===void 0?void 0:n.data;s&&s.length&&he(s[0],a);const l={accountId:e,role:i,locations:[],genericTreeView:a};o.push(l)}),o}getFlagsData(e){const t=[];return le.forEach(o=>{const i={accountId:e,flag:o,locations:[],genericFlagsData:[]};t.push(i)}),t}renderMultiSelectRoles(){this._dataForAccounts.length===0&&(this._dataForAccounts=this.checkedAccounts.map(t=>({accountId:t.id,accountName:t.label,rolesData:this.getRolesData(t.id),flagsData:this.getFlagsData(t.id),flagData:[],active:!1})));const e={};return this._dataForAccounts.forEach(t=>{e[t.accountId]=t.rolesData.filter(o=>o.role.removed===!0).map(o=>o.role.name)}),this._dataForAccounts.map(t=>{const o=[...new Set(this.getRoles(t.accountId).map(i=>i.name))].map(i=>({label:i,selected:!e[t.accountId].includes(i)}));return c` <div> <div class="account-roles-name">${t.accountName}</div> <ix-multi-select data-testid="multi-select-roles-${t.accountId}" required id="${`${t.accountId}-multi-select`}" style="max-width:99%" class="multi-select" .menuPositioning="${"popover"}" .items="${o}" .label="${"Roles"}" @toggle-multi-select-item="${i=>this.handleMultiSelect(t.accountId,i.detail.label,i.detail.selected)}" @remove-multi-select-item="${i=>this.handleMultiSelect(t.accountId,i.detail,!1)}" @clear-multi-select="${()=>this.handleMultiSelectClear(t.accountId)}" @select-menu="${i=>this.handleSelectMenu(i)}"></ix-multi-select> </div> `})}handleSelectMenu(e){e.detail.value==="open"?this.multiSelectOpen=!0:this.multiSelectOpen=!1}handleMultiSelect(e,t,o){var i,n,a;const[s]=this._dataForAccounts.filter(u=>u.accountId===e),l=this.getRoles(s.accountId).find(u=>u.name===t);if(!l)return;const p=s.rolesData.findIndex(u=>u.role.id===l.id);if(l.permissions.every(u=>u.isNonLocation)){const u=(i=s.rolesData[p])===null||i===void 0?void 0:i.genericTreeView;if(!((n=u==null?void 0:u.children)===null||n===void 0)&&n.length){const b=u.children[0];b.checked=!0,be(b,u),s.rolesData[p].locations.push(b)}}const h=s.rolesData.findIndex(u=>u.role.id===(l==null?void 0:l.id));if(s.rolesData[h].role.removed=!(o&&h>=0),!o){const u={id:"root",label:"",children:[],customerKnownSpaceName:""},b=(a=this._treeData.find(F=>F.accountNumber===e))===null||a===void 0?void 0:a.data;b&&b.length&&he(b[0],u),s.rolesData[h].locations=[],s.rolesData[h].genericTreeView=u}this.validateStep(),this.dispatchUpdateDFAEvent(),this.dispatchNextButtonToggleEvent()}validateStep(){const e=this._dataForAccounts.every(o=>o.rolesData.filter(i=>i.role.removed===!1).length),t=this._dataForAccounts.length===this.checkedAccounts.length;this._nextButtonEnabled=e&&t}handleMultiSelectClear(e){const t=this._dataForAccounts.filter(o=>o.accountId===e)[0];this._dataForAccounts.find(o=>o.accountId===e).rolesData=this.getRolesData(t.accountId),this._nextButtonEnabled=!1,this.dispatchUpdateDFAEvent(),this.dispatchNextButtonToggleEvent()}dispatchUpdateDFAEvent(){const e=new CustomEvent(w.UpdateDFA,{detail:{dataForAccounts:this._dataForAccounts},bubbles:!0,composed:!0});this.dispatchEvent(e)}dispatchNextStepEvent(){this.dispatchEvent(new CustomEvent(w.NextStep,{bubbles:!0,composed:!0}))}dispatchNextButtonToggleEvent(){this.dispatchEvent(new CustomEvent(w.NextButtonToggle,{detail:this._nextButtonEnabled,bubbles:!0,composed:!0}))}dispatchValidateStepEvent(){this.dispatchEvent(new CustomEvent(w.ValidateStep,{detail:this._nextButtonEnabled,bubbles:!0,composed:!0}))}render(){const e=this.multiSelectOpen?"overflow-hidden":"overflow-auto";return c` <div class="wizard-step-content flex flex-col overflow-hidden"> <div class="p-1 dlr-text-default ${e}">${this.renderMultiSelectRoles()}</div> <div class="flex justify-end" style="padding-top:8px"> <ix-button class="pt-2" type="submit" ?disabled="${!this._nextButtonEnabled}" has-icon trailing-icon @click="${this.dispatchNextStepEvent}" data-testid="step-three-next-button"> Next <md-icon slot="icon">east</md-icon> </ix-button> </div> </div> `}};X.styles=[ai,_,$e],r([d({type:Array})],X.prototype,"checkedAccounts",void 0),r([d({type:Array})],X.prototype,"roles",void 0),r([d({type:Array})],X.prototype,"dataForAccounts",void 0),r([d({type:Array})],X.prototype,"treeData",void 0),r([m()],X.prototype,"_dataForAccounts",void 0),r([m()],X.prototype,"_treeData",void 0),r([m()],X.prototype,"_nextButtonEnabled",void 0),r([m()],X.prototype,"multiSelectOpen",void 0),X=r([A("create-user-step-three")],X);const tt=$`ix-dialog{--md-dialog-container-color:#fff}ix-icon-button{--md-sys-color-on-surface-variant:var(--md-sys-color-primary)}ix-select{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd;--md-menu-container-color:#fff}ix-select.thick{--md-menu-container-shape:10px}ix-select.slim{--md-outlined-field-bottom-space:2px;--md-outlined-field-top-space:2px}ix-button{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd}ix-button .disabled{color:var(--md-sys-text-color-disabled)}.btn_primary{--md-filled-button-container-color:var(--md-sys-color-primary)}.btn_primary ix-icon{color:var(--md-sys-color-on-primary)}.btn_secondary{--md-filled-button-container-color:var(--md-sys-color-secondary)}.btn_secondary ix-icon{color:var(--md-sys-color-on-secondary)}.btn_tertiary{--md-filled-button-container-color:var(--md-sys-color-tertiary)}.btn_tertiary ix-icon{color:var(--md-sys-color-on-tertiary)}.btn_danger{--md-filled-button-container-color:var(--md-sys-color-error)}.btn_danger ix-icon{color:var(--md-sys-color-on-error)}.icon-btn_primary ix-icon{color:var(--md-sys-color-primary)}.icon-btn_secondary ix-icon{color:var(--md-sys-color-secondary)}.icon-btn_tertiary ix-icon{color:var(--md-sys-color-tertiary)}.icon-btn_danger ix-icon{color:var(--md-sys-color-error)}ix-icon.icon-lg{--ix-icon-font-size:32px}.dialog-form{min-width:500px;display:flex;flex-direction:column;justify-content:space-between;padding:8px 24px 20px}.dialog-form .textfield{width:100%}.dialog-form.sm{min-width:560px}.dialog-form__textbox{padding-top:1rem}.dialog-actions{display:flex;justify-content:flex-end;padding:8px 15px 8px 20px}@media only screen and (min-width:5px) and (max-width:600px){ix-dialog{--md-dialog-container-shape:6px}}@media only screen and (min-width:601px){ix-dialog{--md-dialog-container-shape:3px}}.permission-container{padding:1rem 1.5rem 0 1.5rem}ix-icon-button{--md-sys-color-on-surface-variant:black}.permission-dialog-container{padding:1rem 1rem 0 1rem;width:500px}.permission-container-row{display:block;padding:8px;margin-top:12px;margin-bottom:12px;box-shadow:#e1e4e8 0 0 0 1px inset;border-radius:8px}.permission-container-item{display:flex;flex-direction:row;width:100%}.permission-arrow{width:30px;cursor:pointer}.permission-name{line-height:24px;color:#092241}.permission-item{display:grid;grid-template-columns:1fr 20%;gap:16px;-webkit-box-align:center;align-items:center;-webkit-box-flex:1;flex-grow:1;padding-top:5px}.permission-item-privilege{margin:0;color:#333}.permission-container-row-create-user{display:flex;padding:12px;margin-top:10px;margin-bottom:10px;height:24px;width:475px;box-shadow:#e1e4e8 0 0 0 1px inset;border-radius:8px}.non-location{margin:10px 5px 5px 5px;background-color:#f5f7ff;padding:8px;border-radius:5px}.non-location-icon{padding-left:8px}.permissions-dialog-container{max-height:70vh;overflow-x:auto}`;class K{}K.ROW=e=>`permission-group-row-${e}`,K.CATEGORY=e=>`permission-group-category-${e}`,K.OVERALL_PERM=e=>`permission-group-overall-${e}`,K.BTN_EXPAND=e=>`permission-group-btn-expand-${e}`,K.PERM_NAME=e=>`permission-group-name-${e}`,K.PERM_PRIVILEGE=e=>`permission-group-privilege-${e}`;let Be=class extends I{constructor(){super(...arguments),this.permissionGroup=void 0,this.isOpen=!1}onClick(){this.isOpen=!this.isOpen,this.requestUpdate()}renderPermissionItemRow(e,t){return c` <div class="flex justify-between pl-11 items-center permission-item"> <p data-testid="${K.PERM_NAME(e)}">${e}</p> <p class="capitalize permission-item-privilege pr-4" data-testid="${K.PERM_PRIVILEGE(e)}"> <small>${t}</small> </p> </div> `}renderPermissionItems(e){return this.isOpen?c`<div class="permission-items-container"> ${e.filter(t=>!t.isNonLocation).map(t=>this.renderPermissionItemRow(t.name,t.privilege))} </div>`:y}render(){var e,t,o,i,n,a,s,l,p,h,u,b;return c`<div class="permission-container-row" data-testid="${K.ROW((t=(e=this.permissionGroup)===null||e===void 0?void 0:e.category)!==null&&t!==void 0?t:"")}"> <div class="flex items-center justify-between"> <div class="flex items-center"> <ix-icon-button icon="${this.isOpen?"arrow_drop_down":"arrow_right"}" @click="${this.onClick}" data-testid="${K.BTN_EXPAND((i=(o=this.permissionGroup)===null||o===void 0?void 0:o.category)!==null&&i!==void 0?i:"")}"> </ix-icon-button> <p class="m-0 permission-name permission-item-name pl-1" id="permission-item-name" data-testid="${K.CATEGORY((a=(n=this.permissionGroup)===null||n===void 0?void 0:n.category)!==null&&a!==void 0?a:"")}"> ${(s=this.permissionGroup)===null||s===void 0?void 0:s.category} </p> </div> <p class="m-0 pl-4 capitalize permission-overall-privilege mr-4" data-testid="${K.OVERALL_PERM((p=(l=this.permissionGroup)===null||l===void 0?void 0:l.category)!==null&&p!==void 0?p:"")}"> <small>${(h=this.permissionGroup)===null||h===void 0?void 0:h.overallPrivilege}</small> </p> </div> ${this.renderPermissionItems((b=(u=this.permissionGroup)===null||u===void 0?void 0:u.items)!==null&&b!==void 0?b:[])} </div>`}};Be.styles=[tt,_],r([d({type:Object,attribute:!1})],Be.prototype,"permissionGroup",void 0),r([m()],Be.prototype,"isOpen",void 0),Be=r([A("permission-group")],Be);class Te{}Te.ROW=e=>`non-location-permission-row-${e}`,Te.NAME=e=>`non-location-permission-item-${e}`,Te.PRIVILEGE=e=>`non-location-permission-privilege-${e}`;let ot=class extends I{constructor(){super(...arguments),this.permission=void 0}render(){var e,t,o,i,n,a,s,l;return c`<div class="permission-container-row" data-testid="${Te.ROW((t=(e=this.permission)===null||e===void 0?void 0:e.name)!==null&&t!==void 0?t:"")}"> <div class="flex items-center justify-between"> <div class="flex items-center"> <p class="m-0 permission-name permission-item-name pl-1" data-testid="${Te.NAME((i=(o=this.permission)===null||o===void 0?void 0:o.name)!==null&&i!==void 0?i:"")}"> ${(n=this.permission)===null||n===void 0?void 0:n.name} </p> </div> <p class="m-0 pl-4 capitalize permission-overall-privilege mr-4" data-testid="${Te.PRIVILEGE((s=(a=this.permission)===null||a===void 0?void 0:a.name)!==null&&s!==void 0?s:"")}"> <small>${(l=this.permission)===null||l===void 0?void 0:l.privilege}</small> </p> </div> <div class="permission-items-container"> <div class="flex pl-13 items-center permission-item non-location"> <span class="non-location-icon"><md-icon slot="icon">info</md-icon></span> <p class="text-left dlr-text-caption"> You don't need to select location or assets for this permission </p> </div> </div> </div>`}};ot.styles=[tt,_],r([d({type:Object,attribute:!1})],ot.prototype,"permission",void 0),ot=r([A("non-location-permission")],ot);let it=class extends I{constructor(){super(...arguments),this.permission=void 0}render(){var e,t;return c` <div class="permission-container-row"> <div class="flex items-center justify-between"> <div class="flex items-center"> <p class="m-0 permission-name pl-1">${(e=this.permission)===null||e===void 0?void 0:e.name}</p> </div> <p class="m-0 pl-4 capitalize permission-overall-privilege mr-4"> <small>${(t=this.permission)===null||t===void 0?void 0:t.privilege}</small> </p> </div> </div> `}};it.styles=[tt,_],r([d({type:Object,attribute:!1})],it.prototype,"permission",void 0),it=r([A("non-category-permission")],it);const zs={AMER:"North America"},Dt={Global:0,Continent:1,Country:2,City:3,Site:4,Floor:5,Room:6,Cage:7,Row:8,Cabinet:9},Pt=e=>{var t,o;const i=Dt[e.type];return i===Dt.Continent&&e.label?(t=zs[e.label])!==null&&t!==void 0?t:e.label:e.label&&i>Dt.Site&&/^[0-9]{1,3}$/.test(e.label)?`${e.type} ${e.label}`:(o=e.label)!==null&&o!==void 0?o:void 0},Vs=e=>({id:e.id,accountNumber:e.accountNumber,roleId:e.roleId,parentId:e.parentInventoryId,customerKnownSpaceName:e.customerKnownSpaceName,type:e.type,label:Pt(e),isAssignable:e.isAssignable,secondaryLabel:e.secondaryLabel,childrenCount:e.childrenCount,inventoryItems:nt(e.inventoryItems),selected:e.selected,searched:e.searched,status:e.permissionStatus,inherited:e.inherited}),nt=e=>{const t=[];return e==null||e.forEach(o=>{t.push(Vs(o))}),t},js=e=>{var t,o,i,n,a,s,l,p;return{contactId:e.id,accountId:e.accountNumber,roleId:e.roleId,isInternal:e.isInternal,startInventoryId:e.location,searchLocationText:(t=e.searchLocationText)!==null&&t!==void 0?t:"",level1:!0,level2:!0,level3:(o=e.allChildren)!==null&&o!==void 0?o:!1,level4:(i=e.allChildren)!==null&&i!==void 0?i:!1,level5:(n=e.allChildren)!==null&&n!==void 0?n:!1,level6:(a=e.allChildren)!==null&&a!==void 0?a:!1,level7:(s=e.allChildren)!==null&&s!==void 0?s:!1,level8:(l=e.allChildren)!==null&&l!==void 0?l:!1,level9:(p=e.allChildren)!==null&&p!==void 0?p:!1}},Gs=e=>({contactId:e.id,accountId:e.accountNumber,flag:e.flag,isInternal:e.isInternal,startInventoryId:e.location,level1:!0,level2:!0,level3:!0,level4:!0,level5:!0,level6:!0,level7:!0,level8:!0,level9:!0}),Js=e=>{var t,o,i,n,a,s,l;return{accountId:e.accountNumber,isInternal:e.isInternal,level1:!0,level2:!0,level3:(t=e.allChildren)!==null&&t!==void 0?t:!1,level4:(o=e.allChildren)!==null&&o!==void 0?o:!1,level5:(i=e.allChildren)!==null&&i!==void 0?i:!1,level6:(n=e.allChildren)!==null&&n!==void 0?n:!1,level7:(a=e.allChildren)!==null&&a!==void 0?a:!1,level8:(s=e.allChildren)!==null&&s!==void 0?s:!1,level9:(l=e.allChildren)!==null&&l!==void 0?l:!1}},Ks=e=>({id:e.id,accountNumber:e.accountNumber,flag:e.flag,parentId:e.parentInventoryId,customerKnownSpaceName:e.customerKnownSpaceName,type:e.type,isAssignable:e.isAssignable,label:Pt(e),secondaryLabel:e.secondaryLabel,childrenCount:e.childrenCount,checkedChildrenCount:e.checkedChildrenCount,inventoryItems:si(e.inventoryItems),selected:e.selected,searched:!1,status:e.permissionStatus,inherited:e.inherited}),si=e=>{const t=[];return e==null||e.forEach(o=>{t.push(Ks(o))}),t},ri=e=>{const t=[];return e==null||e.forEach(o=>{t.push(Zs(o))}),t},Zs=e=>({id:e.id,accountNumber:e.accountNumber,parentId:e.parentInventoryId,customerKnownSpaceName:e.customerKnownSpaceName,type:e.type,isAssignable:e.isAssignable,label:Pt(e),secondaryLabel:e.secondaryLabel,childrenCount:e.childrenCount,inventoryItems:ri(e.inventoryItems)}),li=e=>{const t=[];return e==null||e.forEach(o=>{t.push({id:o.id,customerKnownName:o.customerKnownName,permissionStatus:o.permissionStatus})}),t},Ws=e=>({roleId:e.roleId,roleLocations:li(e.locations)}),Qs=e=>{const t=[];return e==null||e.forEach(o=>{t.push(Ws(o))}),t},Ys=e=>({contactId:e.contactId,accountNumber:e.accountNumber,locations:Qs(e.roleLocations),isInternal:e.isInternal,changeHistoryId:e.changeHistoryId}),Xs=e=>({flag:Ft(e.flag),flagLocations:li(e.locations)}),er=e=>{const t=[];return e==null||e.forEach(o=>{t.push(Xs(o))}),t},tr=e=>({contactId:e.contactId,accountNumber:e.accountNumber,locations:er(e.flagLocations),isInternal:e.isInternal,changeHistoryId:e.changeHistoryId});class or{async getRoleInventory(t){try{const o=js(t),i=await v.InventoryApi.GetRolesInventory(o);return i!=null&&i.getRoleTree?nt([i.getRoleTree]):[]}catch(o){return g.handleError(o,"Failed to load the portal access tree."),[]}}async getFlagInventory(t){try{const o=Gs(t),i=await v.InventoryApi.GetFlagsInventory(o);return i!=null&&i.getFlagTree?si([i==null?void 0:i.getFlagTree]):[]}catch(o){return g.handleError(o,"Failed to load the portal access tree."),[]}}async getAccountInventory(t){try{const o=Js(t),i=await v.InventoryApi.GetAccountInventory(o);return i!=null&&i.getAccountTree?ri([i==null?void 0:i.getAccountTree]):[]}catch(o){return g.handleError(o,"Failed to get account inventory."),[]}}async saveAccountRoleInventory(t){try{const o=Ys(t),i=await v.InventoryApi.SaveAccountRoleAssignments(o);return nt(i==null?void 0:i.saveAccountRoleAssignments)}catch(o){return null}}async saveAccountFlagInventory(t){try{const o=tr(t),i=await v.InventoryApi.SaveAccountFlagAssignments(o);return nt(i==null?void 0:i.saveAccountUserFlagAssignments)}catch(o){return null}}}const Le=new or,ir=e=>({role_id:e.roleId,user_id:e.contactId,account_number:e.accountNumber,location_id:e.location}),ci=e=>({roleId:e.role_id,contactId:e.user_id,accountNumber:e.account_number,location:e.location_id,id:e.id,isActive:e.is_active}),nr=e=>{const t=[];return e.forEach(o=>t.push(ir(o))),t},di=e=>{const t=[];return e.forEach(o=>t.push(ci(o))),t},ar=e=>({userId:e.contactId,roleId:e.roleId,accountNumber:e.accountNumber,roleType:e.roleType}),sr=e=>({id:e.id}),rr=e=>({createRoleAssignment:{RoleAssignmentInput:nr(e.roleAssignmentInput),change_history_id:e.changeHistoryId}}),lr=e=>({id:e.id,changeHistoryId:e.changeHistoryId});class cr{async get(t){try{const o=ar(t),i=await v.RoleAssignmentsApi.getRoleAssignments(o);return di(i)}catch(o){return g.handleError(o,"Failed to get role assignments."),[]}}async getById(t){try{const o=sr(t),i=await v.RoleAssignmentsApi.getRoleAssignment(o);return ci(i)}catch(o){return g.handleError(o,"Failed to get role assignment"),{}}}async create(t){try{const o=rr(t),i=await v.RoleAssignmentsApi.createRoleAssignments(o);return di(i)}catch(o){return g.handleError(o,"Failed to create role assignment."),[]}}async delete(t){try{const o=lr(t);return v.RoleAssignmentsApi.deleteRoleAssignment(o)}catch(o){return g.handleError(o,"Failed to delete role assignment.")}}}const qe=new cr,dr=async e=>{for(const t of e)await Promise.all(t.map(o=>o))},Ie=async e=>{const t=[];for(const o of e){const i=await Promise.all(o.map(n=>n));t.push(i)}return t},ur=e=>({user_flag_type:e.userFlagType,user_id:e.contactId,account_number:e.accountNumber,location_id:e.location}),ui=e=>({userFlagType:e.user_flag_type,contactId:e.user_id,accountNumber:e.account_number,location:e.location_id,id:e.id}),hr=e=>{const t=[];return e.forEach(o=>t.push(ur(o))),t},hi=e=>{const t=[];return e.forEach(o=>t.push(ui(o))),t},pr=e=>({userId:e.contactId,accountNumber:e.accountNumber,userFlagType:e.userFlagType,locationId:e.location}),mr=e=>({id:e.id}),gr=e=>({createUserFlagAssignment:{UserFlagAssignmentInputs:hr(e.userFlagAssignmentInput),change_history_id:e.changeHistoryId}}),fr=e=>({id:e.id});class vr{async get(t){try{const o=pr(t),i=await v.UserFlagsApi.getUserFlags(o);return hi(i)}catch(o){return g.handleError(o,"Failed to get assigned user flags."),[]}}async getById(t){try{const o=mr(t),i=await v.UserFlagsApi.getUserFlag(o);return ui(i)}catch(o){return g.handleError(o,"Failed to get user flag assignment."),{}}}async create(t){try{const o=gr(t),i=await v.UserFlagsApi.createUserFlags(o);return hi(i)}catch(o){return g.handleError(o,"Failed to create user flag assignment."),[]}}async delete(t){try{const o=fr(t);return v.UserFlagsApi.deleteUserFlag(o)}catch(o){return g.handleError(o,"Failed to delete user flag assignment.")}}}const He=new vr;class yr{constructor(){this.deleteAssignmentsAndFlags=async(t,o)=>{const i=[],n=[],a=[];try{return t.forEach(s=>{i.push(qe.delete({id:s}))}),o.forEach(s=>{n.push(He.delete({id:s}))}),i.length>0&&a.push(i),n.length>0&&a.push(n),dr(a)}catch(s){return g.handleError(s,"Failed to delete batch of role assignments and flags.")}},this.createAssignmentsAndFlags=async(t,o)=>{const i=[];try{if(t.length>0){const n=[qe.create({roleAssignmentInput:t})];i.push(n)}if(o.length>0){const n=[He.create({userFlagAssignmentInput:o})];i.push(n)}return[...await Ie(i)]}catch(n){return g.handleError(n,"Failed to create batch of role assignments and flags."),[]}},this.upsertAssignmentAndFlags=async(t,o,i,n,a)=>{try{(t.length>0||o.length)&&await this.deleteAssignmentsAndFlags(t,o),(i.length>0||n.length)&&await this.createAssignmentsAndFlags(i.map(s=>({...s,isInternal:a})),n)}catch(s){g.handleError(s,"Failed to upsert role assignments and flags.")}},this.getAssignmentInventory=async(t,o,i,n)=>{const a=[],s=[];try{return i.forEach(l=>{s.push(Le.getRoleInventory({id:t,accountNumber:o,roleId:l,location:"",isInternal:n,allChildren:!0}))}),a.push(s),[...(await Ie(a))[0]].flat()}catch(l){return g.handleError(l,"Failed to get inventory assignments."),[]}},this.getFlagInventory=async(t,o,i)=>{const n=[],a=[];try{return le.forEach(s=>{a.push(Le.getFlagInventory({id:t,flag:s.key,accountNumber:o,location:"",allChildren:!1,isInternal:i}))}),n.push(a),[...(await Ie(n))[0]].flat()}catch(s){return g.handleError(s,"Failed to get inventory flags."),[]}}}}const pi=new yr;async function br(e,t,o,i,n,a,s){const l={id:t,roleId:e,accountNumber:o,location:i,searchLocationText:n,allChildren:a,isInternal:s};return await Le.getRoleInventory(l)}async function mi(e,t,o,i){const n=await pi.getAssignmentInventory(t,o,e,i),a={id:"root",label:"",children:[],customerKnownSpaceName:""},s=[];for(const l of n){const p=he(l,structuredClone(a));s.push({role:l.roleId,rootNode:p,isOpen:!1})}return s}async function xr(e,t,o){const i=await pi.getFlagInventory(e,t,o),n={id:"root",label:"",children:[],customerKnownSpaceName:""},a=[];for(const s of i){const l=he(s,structuredClone(n));a.push({label:Hs(s.flag),rootNode:l,isOpen:!1})}return a}const Mt=e=>{const t=[];return e?(e.forEach(o=>{const i=t.findIndex(s=>s.category===o.category),n={id:o.permissionId,name:o.permissionName,privilege:o.privilege,isNonLocation:o.isNonLocation};if(i===-1)return t.push({category:o.category||"Misc.",overallPrivilege:o.privilege,items:[n]});const a=s=>new Set(s.map(l=>l.privilege)).size===1?s[0].privilege:"MIXED";t[i].items.push(n),t[i].overallPrivilege=a(t[i].items)}),ms(t,"category",!0)):t},wr=async(e,t,o,i)=>{const n=await mi(e,t,o,i),a=await xr(t,o,i);return[n,a]},Z={Default:"DEFAULT",Internal:"INTERNAL",Custom:"CUSTOM",GlobalAccess:"GLOBALACCESS"};Object.values(Z);const gi=e=>({permissionId:e.permission_id,isNonLocation:e.is_non_location,privilege:e.privilege}),fi=e=>{const t=[];return e.permissions.forEach(o=>t.push(gi(o))),{name:e.name,accountNumber:e.account_number,roleType:e.role_type,permissions:t,removed:!1,id:e.id}},vi=e=>{const t=[];return e.forEach(o=>{t.push(fi(o))}),t},Ar=e=>{var t,o;const i=[];return e.permissions.forEach(n=>i.push(gi(n))),{name:e.name,accountNumber:e.account_number,roleType:e.role_type,permissions:i,removed:!1,id:e.id,status:(t=e.status)!==null&&t!==void 0?t:!0,message:(o=e.message)!==null&&o!==void 0?o:""}},Cr=e=>{const t=[];return e.forEach(o=>{t.push(Ar(o))}),t},_r=e=>({permission_id:e.permissionId,privilege:e.privilege}),yi=e=>{const t=[];return e.forEach(o=>{t.push(_r(o))}),t},Tr=e=>({role_name:e.name,permissions:yi(e.permissions)}),Ir=e=>{const t={name:e.name,role_type:e.roleType,permissions:yi(e.permissions)};switch(e.roleType){case Z.Internal:case Z.Default:case Z.GlobalAccess:return t;case Z.Custom:{if(e.accountNumbers&&e.accountNumbers.length>0)return{...t,account_numbers:e.accountNumbers};if(e.accountNumber)return{...t,account_number:e.accountNumber};throw new Error("Account number is required for custom roles. Please ensure an account is selected.")}default:throw new Error(`Unknown role type; ${e.roleType} provided`)}},Er=e=>({roleType:e.roleType}),Rr=e=>({id:e.id}),Sr=e=>({roleCreate:Ir(e.roleCreate)}),kr=e=>({id:e.id,roleUpdate:Tr(e.roleUpdate)}),Ur=e=>({id:e.id});class $r{async get(t){try{let o;if(!(t!=null&&t.roleType)){const a=await v.RolesApi.getRoles();return o=vi(a),o}const i=Er(t),n=await v.RolesApi.getRoles(i);return o=vi(n),o}catch(o){return g.handleError(o,"Failed to get roles."),[]}}async getById(t){try{const o=Rr(t),i=await v.RolesApi.getRole(o);return fi(i)}catch(o){return g.handleError(o,"Failed to get role."),{}}}async update(t){try{const o=kr(t);return v.RolesApi.updateRole(o)}catch(o){return g.handleError(o,"Failed to update role.")}}async create(t){try{const o=Sr(t),i=await v.RolesApi.createRole(o);return Cr(i)}catch(o){return g.handleError(o,`Failed to create the role '${t.roleCreate.name}'.`),[]}}async delete(t){try{const o=Ur(t);return v.RolesApi.deleteRole(o)}catch(o){return g.handleError(o,"Failed to delete role.")}}}const Ot=new $r,Bt=e=>({id:e.id,accountNumber:e.account_number,accountName:e.account_name,displayName:e.account_friendly_name,status:e.status,updatedAt:e.updated_at,updatedBy:e.updated_by,userId:e.user_id}),Nr=e=>{const t=[];return e.forEach(o=>{t.push(Bt(o))}),t},Fr=e=>({user_id:e.contactId,account_number:e.accountNumber,change_history_id:e.changeHistoryId}),Dr=e=>({accountNumber:e.accountNumber,userId:e.contactId,status:e.status}),Pr=e=>({accountAssociationInput:Fr(e.accountAssociationInput)}),Mr=e=>({id:e.id}),Or=e=>({id:e.id,accountAssociationStatusUpdate:{status:e.accountAssociationStatusUpdate.status,change_history_id:e.accountAssociationStatusUpdate.changeHistoryId}});class Br{async create(t){try{const o=Pr(t),i=await v.AccountAssociationApi.createAccountAssociation(o);return Bt(i)}catch(o){return g.handleError(o,"Failed to create account association."),null}}async get(t){try{const o=Dr(t),i=await v.AccountAssociationApi.getAccountAssociations(o);return Nr(i)}catch(o){return g.handleError(o,"Failed to get associated accounts."),[]}}async getById(t){try{const o=Mr(t),i=await v.AccountAssociationApi.getUserAccountAssociation(o);return Bt(i)}catch(o){return g.handleError(o,"Failed to get account association"),{}}}async update(t){try{const o=Or(t);await v.AccountAssociationApi.updateAccountAssociationStatus(o)}catch(o){g.handleError(o,"Failed to update account association status.")}}}const bi=new Br;class Lr{constructor(){this.getRoles=async t=>{try{let o=[];return t?o=await Ot.get({roleType:t}):o=await Ot.get({}),[...new Map(o.map(i=>[i.id,i])).values()]}catch(o){return g.handleError(o,"Failed to get all roles."),[]}},this.getRolesAndPermissions=async t=>{const o=await Promise.allSettled([Ze.get(),this.getRoles(t)]);o.forEach(s=>{if(s.status==="rejected")throw new Error});const i=[o[0].value,o[1].value],[n,a]=i;try{return a.forEach(s=>{s.permissions.forEach(l=>{const p=n.find(h=>h.id===l.permissionId);p&&(l.permissionName=p.name,l.category=p.category)})}),a}catch(s){return g.handleError(s,"Failed to get roles with permissions."),[]}},this.getUserData=async(t,o)=>{const i=[];try{const n=[qe.get({contactId:t}),He.get({contactId:t,accountNumber:o}),bi.get({contactId:t,accountNumber:o})];return i.push(n),[...(await Ie(i))[0]]}catch(n){return g.handleError(n,"Failed to get user data."),[]}},this.getState=async()=>{const t=[];try{const o=[Ze.getMyPermissions({excludeParents:!1,excludeSiblings:!0}),Ze.get(),this.getRolesAndPermissions(),ko.get()];return t.push(o),[...(await Ie(t))[0]]}catch(o){return g.handleError(o,"Failed to get user state."),[]}},this.getAccountData=async t=>{const o=[],i=[];try{for(const n of t)i.push(Le.getAccountInventory({accountNumber:n,allChildren:!0}));return o.push(i),[...(await Ie(o))[0]]}catch(n){return g.handleError(n,"Failed to get account data."),[]}}}}const at=new Lr;class Ee{constructor(t){this._state=t,this._hydrating=!1,Vi(this)}get(){return this.state}set(t){this._state=t}update(t){this._state={...this.get(),...t}}clear(){this.isObject(this._state)&&(this._state={}),this.isArray(this._state)&&(this._state=[])}isHydrating(){return this.hydrating}requestHydration(){this._hydrating=!0}completeHydration(){this._hydrating=!1}get state(){return Ne(this._state)}get hydrating(){return this._hydrating}isArray(t){return Array.isArray(t)}isObject(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}}r([Yt],Ee.prototype,"_state",void 0),r([Yt],Ee.prototype,"_hydrating",void 0);class qr extends Ee{async refresh(){this.requestHydration();const t=await at.getRolesAndPermissions();this.set(t),this.completeHydration()}}const ve=new qr([]);let Re=class extends I{constructor(){super(...arguments),this.inPermissionsDialog=!1,this.permissionData=[]}updated(e){e.has("activeRoleId")&&this.hydratePermissions()}hydratePermissions(){const e=ve.get().find(t=>t.id===this.activeRoleId);e!=null&&e.permissions&&(this.permissionData=Mt(e.permissions))}render(){const e=this.permissionData.filter(i=>i.category!=="Misc.").flatMap(i=>i.items).filter(i=>i.isNonLocation),t=structuredClone(this.permissionData).filter(i=>i.category!=="Misc.").filter(i=>i.items.some(n=>!n.isNonLocation)).map(i=>({...i,items:i.items.filter(n=>!n.isNonLocation)})),o=this.permissionData.filter(i=>!i.category||i.category==="Misc.").flatMap(i=>i.items);return c` <div data-testid="permissions-container" class="${this.inPermissionsDialog?"permissions-dialog-container":""}"> ${this.inPermissionsDialog?y:c`<h3 class="dlr-text-heading">Permissions</h3>`} ${mt(e,i=>i.id,i=>c` <non-location-permission .permission="${i}"></non-location-permission> `)} ${mt(t,i=>i.items,i=>c` <permission-group .permissionGroup="${i}"></permission-group> `)} ${mt(o,i=>i.id,i=>c` <non-category-permission .permission="${i}"></non-category-permission> `)} </div> `}};Re.styles=[tt,_],r([d()],Re.prototype,"activeRoleId",void 0),r([d({type:Boolean})],Re.prototype,"inPermissionsDialog",void 0),r([m()],Re.prototype,"permissionData",void 0),Re=r([A("user-details-permission")],Re);const st=$`@font-face{font-family:'Material Icons';font-style:normal;font-weight:400;src:url(https://fonts.gstatic.com/s/materialicons/v145/flUhRq6tzZclQEJ-Vdg-IuiaDsNZ.ttf) format('truetype')}.material-icons{font-family:'Material Icons';font-weight:400;font-style:normal;font-size:24px;line-height:1;letter-spacing:normal;text-transform:none;display:inline-block;white-space:nowrap;word-wrap:normal;direction:ltr}.flex{display:flex}.flex-1{flex:1}.border-top-solid-gray{border-top:solid 1px #ddd}.red{background-color:#db0028}.blue{background-color:#1456e0}.white{background-color:#fff;color:#1456e0;border:solid 1px #1456e0}.right{float:right}.margin-top-20{margin-top:20px}.padding-2{padding:2px}.padding-20{padding:20px}.padding-right-10{padding:10px}`,rt=$`ix-dialog{--md-dialog-container-color:#fff}ix-icon-button{--md-sys-color-on-surface-variant:var(--md-sys-color-primary)}ix-select{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd;--md-menu-container-color:#fff}ix-select.thick{--md-menu-container-shape:10px}ix-select.slim{--md-outlined-field-bottom-space:2px;--md-outlined-field-top-space:2px}ix-button{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd}ix-button .disabled{color:var(--md-sys-text-color-disabled)}.btn_primary{--md-filled-button-container-color:var(--md-sys-color-primary)}.btn_primary ix-icon{color:var(--md-sys-color-on-primary)}.btn_secondary{--md-filled-button-container-color:var(--md-sys-color-secondary)}.btn_secondary ix-icon{color:var(--md-sys-color-on-secondary)}.btn_tertiary{--md-filled-button-container-color:var(--md-sys-color-tertiary)}.btn_tertiary ix-icon{color:var(--md-sys-color-on-tertiary)}.btn_danger{--md-filled-button-container-color:var(--md-sys-color-error)}.btn_danger ix-icon{color:var(--md-sys-color-on-error)}.icon-btn_primary ix-icon{color:var(--md-sys-color-primary)}.icon-btn_secondary ix-icon{color:var(--md-sys-color-secondary)}.icon-btn_tertiary ix-icon{color:var(--md-sys-color-tertiary)}.icon-btn_danger ix-icon{color:var(--md-sys-color-error)}ix-icon.icon-lg{--ix-icon-font-size:32px}.dialog-form{min-width:500px;display:flex;flex-direction:column;justify-content:space-between;padding:8px 24px 20px}.dialog-form .textfield{width:100%}.dialog-form.sm{min-width:560px}.dialog-form__textbox{padding-top:1rem}.dialog-actions{display:flex;justify-content:flex-end;padding:8px 15px 8px 20px}@media only screen and (min-width:5px) and (max-width:600px){ix-dialog{--md-dialog-container-shape:6px}}@media only screen and (min-width:601px){ix-dialog{--md-dialog-container-shape:3px}}:host{--md-sys-color-on-surface-variant:rgba(9, 34, 65, 0.7);--md-primary-tab-hover-label-text-color:#1456e0}.remove{background-color:#fff;color:#db0028;border:1px solid #db0028}.remove-disabled{background-color:#fff;color:rgba(0,0,0,.26);border:1px solid rgba(0,0,0,.26)}.remove-role-container{padding:1rem 0 0 1rem}ix-textbox,md-textfield{--md-outlined-text-field-width:100%;--md-outlined-text-field-focus-width:100%;width:inherit}.option{display:block;width:100%}.option-disabled{display:block;width:100%;color:#ddd}.check_circle{color:#4caf50}.mail{color:#ff9800}.warning{color:#db0028}.delete_forever{color:#6d758c}.active-icon-section{display:flex;align-items:center;padding-right:16px}.panel-status{display:flex;-webkit-box-align:center;align-items:center;gap:4px;padding-right:8px}.panel-button-container{display:flex;flex-direction:row;column-gap:12px}.suspend-button{padding:8.5px 20px}.account-status-suspend{width:100px;padding-left:2px}.btn-disabled{color:rgba(0,0,0,.26);box-shadow:none;background-color:rgba(0,0,0,.12)}.confirmation-content{flex:1 1 auto;padding-right:24px;padding-bottom:20px;padding-left:24px;overflow:hidden;padding-top:8px!important}.role-add-icon{vertical-align:text-bottom;padding-right:5px}.role-add-text{vertical-align:text-top;text-transform:uppercase}.confirmation-content{max-width:550px}.add-roles-dialog-actions{display:flex;justify-content:flex-end;padding:24px 15px 8px 20px}.user-detail-navigation-contents{display:flex;align-items:center}.user-detail-navigation-contents>ix-button{margin-left:auto}.user-detail-navigation{border-top:1.5px solid #bec9c8;position:relative;top:-1px}.flag-text{text-align:right;margin-right:1.5rem}#flag-text-link{color:#1456e0}.mobile-options{display:none}.email{text-decoration:underline}ix-button{font-family:var(--root-secondary-font)}@media only screen and (max-width:600px){.user-details-controls>ix-button{display:none}div>.user-details-controls{padding-right:0}.mobile-options{display:flex;align-items:center;color:var(--md-sys-color-primary,#1456e0);font-size:24px}ix-menu-item{min-width:200px}h1{margin-bottom:.75rem}.tree-view{overflow-x:auto;overflow-y:hidden;max-width:100%}.flag-text{text-align:center;margin-right:0}.user-details-panel{margin:0 -.5rem;overflow:hidden}}@media only screen and (min-width:601px) and (max-width:1200px){.tree-view{overflow-x:auto;overflow-y:hidden;max-width:100%}}@media only screen and (max-width:1200px){.flex.user-status{flex-direction:column;align-items:flex-start}.user-status-header{width:100%;justify-content:space-between;padding-bottom:12px}}`;class lt{}lt.BTN_CANCEL=e=>`changes-dialog-${e}-btn-cancel`,lt.BTN_CONFIRM=e=>`changes-dialog-${e}-btn-confirm`;let ce=class extends I{constructor(){super(...arguments),this.handleEscapeKeyBinding=this.handleEscapeKey.bind(this),this.headerText="",this.bodyText="",this.cancelButtonText="Cancel",this.confirmationButtonText="Confirm",this.isOpen=!1,this.submitting=!1}connectedCallback(){super.connectedCallback(),this.addEventListener("keydown",this.handleEscapeKeyBinding)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("keydown",this.handleEscapeKeyBinding)}handleEscapeKey(e){return e.which===27&&this.handleCancelChanges(),null}handleConfirmChanges(){this.dispatchEvent(new CustomEvent("confirm"))}handleCancelChanges(){this.dispatchEvent(new CustomEvent("cancel"))}renderHeader(){return this.headerText.length?c`<div slot="headline"> <h1 class="dlr-text-heading">${this.headerText}</h1> </div>`:y}renderContent(){return this.bodyText?c`<div class="confirmation-content" slot="content" method="dialog"> <p>${this.bodyText}</p> </div>`:y}renderFooter(){return c` <div class="dialog-actions" slot="actions"> <ix-button form="confirm-updates" appearance="text" text="${this.cancelButtonText}" ?disabled="${this.submitting}" @click="${()=>this.handleCancelChanges()}" data-testid="${lt.BTN_CANCEL(this.id)}"> ${this.cancelButtonText} </ix-button> <ix-button id="add-account-button" form="confirm-updates" appearance="text" text="${this.confirmationButtonText}" ?submitting="${this.submitting}" @click="${()=>this.handleConfirmChanges()}" data-testid="${lt.BTN_CONFIRM(this.id)}"> ${this.confirmationButtonText} </ix-button> </div> `}render(){return c`<ix-dialog class="z-50 relative" id="add-role-to-account" ?open="${this.isOpen}" @closed="${()=>this.handleCancelChanges()}"> ${this.renderHeader()} ${this.renderContent()} ${this.renderFooter()} </ix-dialog>`}};ce.styles=[st,rt,_],r([d({type:String})],ce.prototype,"headerText",void 0),r([d({type:String})],ce.prototype,"bodyText",void 0),r([d({type:String})],ce.prototype,"cancelButtonText",void 0),r([d({type:String})],ce.prototype,"confirmationButtonText",void 0),r([d({type:Boolean,reflect:!0})],ce.prototype,"isOpen",void 0),r([d({type:Boolean})],ce.prototype,"submitting",void 0),ce=r([A("changes-confirmation")],ce);const Hr=$`
2041
+ `)},{updateComplete:o}=e;o&&typeof o.then=="function"?o.then(t,()=>{}):t()}function Ls(e){try{const t=e.shadowRoot;if(!t)return()=>{};const o=()=>{oi(t,"ix-file-chip { max-width: 100%; min-width: 0; }"),t.querySelectorAll("ix-file-chip").forEach(Bs)};o();const i=new MutationObserver(o);return i.observe(t,{childList:!0,subtree:!0}),()=>i.disconnect()}catch(t){return()=>{}}}let P=class extends I{constructor(){super(...arguments),this.obofEnabled=!1,this.accountStructure="flat",this._nextButtonEnabled=!1,this._obofCreatorsByAccount=new Map,this._accountHierarchyHasUsers=new Map,this._loadingObofForAccounts=new Set,this._documentsRequired=!1,this._uploadErrors=[],this._uploaderInstanceKey=0,this.attachments=[],this._attachmentManager=Ko(),this.handleUploaderRef=e=>{var t;(t=this._chipWrapCleanup)===null||t===void 0||t.call(this),this._chipWrapCleanup=e?Ls(e):void 0}}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this._chipWrapCleanup)===null||e===void 0||e.call(this),this._chipWrapCleanup=void 0}async connectedCallback(){super.connectedCallback(),this._accountTree=this.accountTree,this.obofSelections||(this.obofSelections=new Map),this.updateDocumentsRequired(),this.attachments.length&&(this._attachmentManager.addFiles(this.attachments),this.syncUploadErrorsFromManager()),await this.syncObofState(),this.validateStep(),this.dispatchValidateStepEvent()}updateDocumentsRequired(){const e=this.getSelectedAccountIds(),t=Ut(this.obofEnabled,e.length>0,this.obofSelections,e);this._documentsRequired&&!t&&this.clearAttachments(),this._documentsRequired=t,this._attachmentManager.setDocumentsRequired(this._documentsRequired)}clearAttachments(){this._attachmentManager.clearAll(),this.attachments=[],this._uploadErrors=[],this._uploaderInstanceKey+=1,this.dispatchAttachmentsUpdateEvent(this.attachments)}async updated(e){super.updated(e),e.has("accountTree")&&this.accountTree!==this._accountTree&&(this._accountTree=this.accountTree,await this.syncObofState(),this.updateDocumentsRequired(),this.validateStep(),this.dispatchValidateStepEvent(),this.dispatchNextButtonToggleEvent()),e.has("attachments")&&this.requestUpdate()}getSelectedAccountNodes(){return this._accountTree?Be(this._accountTree.children||[],this.accountStructure):[]}getAllCheckedAccountIds(e){const t=[];for(const o of e){if(o.checked){const i=o.id||o.label;i&&t.push(i)}o.children&&o.children.length>0&&t.push(...this.getAllCheckedAccountIds(o.children))}return t}async syncObofState(){if(!this.obofEnabled||!this._accountTree)return;const e=this.getSelectedAccountNodes();if(e.length===0)return;const t=e.map(o=>o.id||o.label);await this.loadObofCreatorsForAccounts(t)}getSelectedAccountIds(){return this.getSelectedAccountNodes().map(e=>e.id||e.label)}getAncestorAccountIds(e){const t=[e],o=(n,a)=>{if(!n.children)return null;for(const s of n.children){if((s.id||s.label)===a)return n;const l=o(s,a);if(l)return l}return null};if(!this._accountTree)return t;let i=e;for(;i;){const n=o(this._accountTree,i);if(!n||n.id==="root")break;const a=n.id||n.label;if(a&&a!=="root")t.push(a),i=a;else break}return t}async loadObofCreatorsForAccounts(e){if(!this.obofEnabled)return;const t=e.filter(h=>!this._obofCreatorsByAccount.has(h)&&!this._loadingObofForAccounts.has(h));if(t.length===0)return;const o=new Set(this._loadingObofForAccounts);t.forEach(h=>o.add(h)),this._loadingObofForAccounts=o;const i=this._accountTree?this.getAllCheckedAccountIds([this._accountTree]):[];let n=[];if(t.length>0&&i.length>0)try{const h=this.getAncestorAccountIds(t[0]),u=h[h.length-1],b=await tt.search({accountNumber:u,page:0,size:1e3});b.contacts&&b.contacts.length>0&&(n=b.contacts.filter(F=>F.accounts.some(se=>i.includes(se.accountNumber))))}catch(h){}const a=await Promise.all(t.map(async h=>{try{const u=(await Zo(h)).filter(F=>F.accountPermissionGroup===wo.OnBehalfUserCreator);let b=!1;return u.length===0&&(b=n.some(F=>F.accounts.some(se=>se.accountNumber===h))),{accountId:h,creators:u,hierarchyHasUsers:b}}catch(u){return{accountId:h,creators:[],hierarchyHasUsers:!1}}})),s=new Map(this._obofCreatorsByAccount),l=new Map(this._accountHierarchyHasUsers),p=new Set(this._loadingObofForAccounts);a.forEach(({accountId:h,creators:u,hierarchyHasUsers:b})=>{s.set(h,u),l.set(h,b),p.delete(h)}),this._obofCreatorsByAccount=s,this._accountHierarchyHasUsers=l,this._loadingObofForAccounts=p,this.requestUpdate(),await this.updateComplete,this.validateStep(),this.dispatchNextButtonToggleEvent()}onFileClicked(){}syncUploadErrorsFromManager(){const e=this._attachmentManager.validationResult;if(!(!e||e.fileErrors.size===0))for(const t of e.fileErrors.values())this._uploadErrors.push(...t.map(o=>o.message))}onFileRemoved(e){if(!(e!=null&&e.detail))return;const t=e.detail.allFiles||[];this._attachmentManager.clearAll(),this._attachmentManager.addFiles(t),this.attachments=[...this._attachmentManager.attachments],this._uploadErrors=[],this.syncUploadErrorsFromManager(),this.dispatchAttachmentsUpdateEvent(this.attachments),this.validateStep(),this.requestUpdate()}onUploaded(e){const{filesUploaded:t}=e.detail;this._uploadErrors=[];const o=t.map(i=>i.file);this._attachmentManager.addFiles(o),o.some(i=>this._attachmentManager.getFileErrors(i.name).length>0)&&(this._uploaderInstanceKey+=1),this.attachments=[...this._attachmentManager.attachments],this.syncUploadErrorsFromManager(),this.dispatchAttachmentsUpdateEvent(this.attachments),this.validateStep(),this.requestUpdate()}handleObofOptionClick(e,t,o,i=o,n=""){const a=new et(t,o,i,n),s=new Map(this.obofSelections);for(const l of Rt(e))s.set(l,a);this.obofSelections=s,this.dispatchObofSelectionsUpdateEvent(),this.updateDocumentsRequired(),this.requestUpdate(),this.validateStep(),this.dispatchNextButtonToggleEvent()}renderObofs(){if(!this.obofEnabled)return y;const e=this.getSelectedAccountNodes();return e.length===0?y:c` <div class="mt-4 overflow-y-auto" style="max-height:200px"> ${e.map(t=>this.renderObofUserSelect(t))} </div> `}renderObofUserSelect(e){var t;const o=e.id||e.label,i=this._loadingObofForAccounts.has(o),n=this._obofCreatorsByAccount.get(o)||[],a=this._accountHierarchyHasUsers.get(o)||!1,s=((t=this.obofSelections)===null||t===void 0?void 0:t.get(o))||new et,l=s.value,p=Yo(i,n.length,a);let h;if(p==="loading")h=c` <ix-select-option value="loading" display-text="Loading users..." disabled="disabled" selected="selected"> Loading users... </ix-select-option> `;else if(p==="selectable")h=c` ${n.map(u=>{const b=u.id;if(!b)return y;const F=`${u.firstName} ${u.lastName}`,se=`${F} (${u.email})`;return c` <ix-select-option value="${b}" display-text="${se}" ?selected="${l===b}" @click="${()=>this.handleObofOptionClick(e,b,se,F,u.email)}"> ${se} </ix-select-option> `})} `;else if(p==="no-user"){const u=kt.noUserAvailable;h=c` <ix-select-option value="${z.NoUserAvailable}" display-text="${u}" ?selected="${l===z.NoUserAvailable}" @click="${()=>this.handleObofOptionClick(e,z.NoUserAvailable,u)}"> ${u} </ix-select-option> `}else{const u=kt.newCustomer;h=c` <ix-select-option value="${z.NewCustomer}" display-text="${u}" ?selected="${l===z.NewCustomer}" @click="${()=>this.handleObofOptionClick(e,z.NewCustomer,u)}"> ${u} </ix-select-option> `}return c` <div class="mb-3"> <label for="obof-${o}-menu" class="text-sm font-medium" style="display:block;margin-bottom:8px"> ${e.label} </label> <ix-select quick menu-below class="w-full" id="obof-${o}-menu" menu-positioning="fixed" label="${i?"Loading users...":"Created on Behalf of*"}" .displayText="${i?"Loading users...":s.displayText}" ?disabled="${i}"> ${h} </ix-select> </div> `}renderDocumentUpload(){const e=this.getSelectedAccountIds(),t=e.length>0;if(!Ut(this.obofEnabled,t,this.obofSelections,e))return y;const o=qo(),i=Ho(),n=i.map(s=>s.toUpperCase()).join(", "),a=`Max file size is ${o} MB with accepted file formats of ${n}`;return c` <div class="mt-4"> <label class="text-sm font-medium" style="display:block;margin-bottom:8px"> Document(s) of Request${this._documentsRequired?"*":""} </label> ${Qi(this._uploaderInstanceKey,c` <ix-file-uploader ${Yi(this.handleUploaderRef)} .allowDeleteDefaultFiles="${!0}" .allowMultipleFiles="${!0}" .defaultFiles="${this.attachments}" .extensions="${i}" .maxFileSizeValue="${o}" .headerText="${"CLICK HERE TO BROWSE YOUR DEVICE OR DROP FILES TO UPLOAD"}" .bodyText="${a}" .hideBody="${!1}" @on-file-clicked="${this.onFileClicked}" @on-file-removed="${this.onFileRemoved}" @on-files-uploaded="${this.onUploaded}"></ix-file-uploader> `)} ${this.renderUploadErrors()} </div> `}renderUploadErrors(){return!this._uploadErrors||this._uploadErrors.length===0?y:c` <div role="alert" class="mt-3 p-3 rounded" style="background-color:#fee;border:1px solid #fcc;color:#c00;font-size:.875rem"> ${this._uploadErrors.map(e=>c`<p style="margin:.25rem 0">${e}</p>`)} </div> `}renderAccounts(){var e,t;if(!this._accountTree)return y;const o=(t=(e=this._accountTree)===null||e===void 0?void 0:e.children)===null||t===void 0?void 0:t.some(i=>{var n;return(n=i.children)===null||n===void 0?void 0:n.length});return c` <div class="overflow-auto" style="max-height:250px"> <ix-tree checkboxesEnabled .rootNode="${this._accountTree}" .rollup="${!1}" .disableEndNodePointer="${!0}" .selectNodeOnClick="${!0}" ?removeChevron="${!o}" @on-tree-node-checked="${()=>this.toggleAccountChecked()}" data-testid="step-two-account-tree"></ix-tree> </div> `}validateStep(){if(!this._accountTree||!this.ixTree)return;const e=It([this._accountTree]);if(this.obofEnabled&&e){const t=this.getSelectedAccountIds(),o=ei(t,this.obofSelections),i=this._attachmentManager.canProceed;this._nextButtonEnabled=e&&o&&i}else this._nextButtonEnabled=e;this.dispatchNextButtonToggleEvent()}async toggleAccountChecked(){if(!(!this._accountTree||!this.ixTree)){if(await this.ixTree.updateComplete,this._accountTree=this.ixTree.rootNode,this.obofEnabled){const e=this.getSelectedAccountNodes(),t=e.map(i=>i.id||i.label),o=e.flatMap(Rt);this.obofSelections=Xo(this.obofSelections,o),this.dispatchObofSelectionsUpdateEvent(),await this.loadObofCreatorsForAccounts(t)}this.updateDocumentsRequired(),this.dispatchUpdateAccountsEvent(),this.validateStep(),this.dispatchNextButtonToggleEvent()}}dispatchUpdateAccountsEvent(){this.dispatchEvent(new CustomEvent(w.UpdateAccounts,{detail:{rootNode:this._accountTree},bubbles:!0,composed:!0}))}dispatchObofSelectionsUpdateEvent(){this.dispatchEvent(new CustomEvent(w.UpdateObofSelections,{detail:{obofSelections:this.obofSelections},bubbles:!0,composed:!0}))}dispatchAttachmentsUpdateEvent(e){this.dispatchEvent(new CustomEvent(w.UpdateAttachments,{detail:{attachments:e},bubbles:!0,composed:!0}))}dispatchNextStepEvent(){this.dispatchEvent(new CustomEvent(w.NextStep,{bubbles:!0,composed:!0}))}dispatchNextButtonToggleEvent(){this.dispatchEvent(new CustomEvent(w.NextButtonToggle,{detail:this._nextButtonEnabled,bubbles:!0,composed:!0}))}dispatchValidateStepEvent(){this.dispatchEvent(new CustomEvent(w.ValidateStep,{detail:this._nextButtonEnabled,bubbles:!0,composed:!0}))}render(){return c` <div class="flex flex-col" style="min-height:100%"> <div class="flex-1" style="padding-right:8px"> ${this.renderAccounts()} ${this.renderObofs()} ${this.renderDocumentUpload()} </div> <div class="flex justify-end" style="margin-top:24px"> <ix-button type="submit" ?disabled="${!this._nextButtonEnabled}" has-icon trailing-icon @click="${this.dispatchNextStepEvent}" data-testid="step-two-next-button"> NEXT <md-icon slot="icon">east</md-icon> </ix-button> </div> </div> `}};P.styles=[_,ge],r([d({type:Object})],P.prototype,"accountTree",void 0),r([d({type:Boolean})],P.prototype,"obofEnabled",void 0),r([d({type:String})],P.prototype,"accountStructure",void 0),r([m()],P.prototype,"_accountTree",void 0),r([m()],P.prototype,"_nextButtonEnabled",void 0),r([m()],P.prototype,"_obofCreatorsByAccount",void 0),r([m()],P.prototype,"_accountHierarchyHasUsers",void 0),r([m()],P.prototype,"_loadingObofForAccounts",void 0),r([m()],P.prototype,"_documentsRequired",void 0),r([m()],P.prototype,"_uploadErrors",void 0),r([m()],P.prototype,"_uploaderInstanceKey",void 0),r([d({type:Object})],P.prototype,"obofSelections",void 0),r([d({type:Array})],P.prototype,"attachments",void 0),r([D("ix-tree")],P.prototype,"ixTree",void 0),P=r([A("create-user-step-two")],P);const ii=$`ix-dialog{--md-dialog-container-color:#fff}ix-icon-button{--md-sys-color-on-surface-variant:var(--md-sys-color-primary)}ix-select{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd;--md-menu-container-color:#fff}ix-select.thick{--md-menu-container-shape:10px}ix-select.slim{--md-outlined-field-bottom-space:2px;--md-outlined-field-top-space:2px}ix-button{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd}ix-button .disabled{color:var(--md-sys-text-color-disabled)}.btn_primary{--md-filled-button-container-color:var(--md-sys-color-primary)}.btn_primary ix-icon{color:var(--md-sys-color-on-primary)}.btn_secondary{--md-filled-button-container-color:var(--md-sys-color-secondary)}.btn_secondary ix-icon{color:var(--md-sys-color-on-secondary)}.btn_tertiary{--md-filled-button-container-color:var(--md-sys-color-tertiary)}.btn_tertiary ix-icon{color:var(--md-sys-color-on-tertiary)}.btn_danger{--md-filled-button-container-color:var(--md-sys-color-error)}.btn_danger ix-icon{color:var(--md-sys-color-on-error)}.icon-btn_primary ix-icon{color:var(--md-sys-color-primary)}.icon-btn_secondary ix-icon{color:var(--md-sys-color-secondary)}.icon-btn_tertiary ix-icon{color:var(--md-sys-color-tertiary)}.icon-btn_danger ix-icon{color:var(--md-sys-color-error)}ix-icon.icon-lg{--ix-icon-font-size:32px}.dialog-form{min-width:500px;display:flex;flex-direction:column;justify-content:space-between;padding:8px 24px 20px}.dialog-form .textfield{width:100%}.dialog-form.sm{min-width:560px}.dialog-form__textbox{padding-top:1rem}.dialog-actions{display:flex;justify-content:flex-end;padding:8px 15px 8px 20px}@media only screen and (min-width:5px) and (max-width:600px){ix-dialog{--md-dialog-container-shape:6px}}@media only screen and (min-width:601px){ix-dialog{--md-dialog-container-shape:3px}}:host{--ix-chip-container-color:var(--md-sys-color-primary);--md-input-chip-outline-color:var(--md-sys-color-primary);--md-input-chip-label-text-color:white;--md-outlined-field-leading-content-color:black;--md-outlined-field-label-text-color:black}.accounts-roles-container{display:flex;flex-direction:column;margin-bottom:10px;padding-left:2px}.accounts-roles-container>*{padding-bottom:15px}.accounts-roles-container>:not(:first-child){padding-top:20px}.account-roles-name{padding-bottom:10px}.account-roles{display:flex;flex-direction:column;gap:8px;height:100%}ix-button{font-family:var(--root-secondary-font)}`;function he(e,t,o=void 0){const i=Xi[e.type]||(e.type==="Port"?"":"chevron_right"),n={id:e.id,label:e.label,children:[],secondaryLabel:e.secondaryLabel,parentId:e.parentId,childrenCount:e.childrenCount,disabled:e.isAssignable===!1,checkedChildrenCount:e.checkedChildrenCount,indeterminate:e.status==="INDETERMINATE",customerKnownSpaceName:e.customerKnownSpaceName,checked:o!=null?o:e.status==="CHECKED",originalCheckedStatus:o!=null?o:e.status==="CHECKED",inherited:e.inherited,icon:i};return t.children.push(n),e.inventoryItems&&e.inventoryItems.forEach(a=>{he(a,n,o?n.checked:void 0)}),t}function $t(e){var t;const o=i=>{i.checked=!1};return e.children&&!((t=e.children)===null||t===void 0)&&t.length&&e.children.forEach(i=>$t(i)),o(e)}const le=[{key:"ACCOUNTING_CONTACT",text:"Accounting flag",desc:"Authorized to discuss billing issues with DLR Accounts Receivable Group."},{key:"OPERATIONS_CONTACT",text:"Operations flag",desc:"Receives Planned Maintenance, Corrective Maintenance and Project Work notifications. Point of contact for DLR operations team."},{key:"EMERGENCY_CONTACT",text:"Emergency flag",desc:"Receives Incident Notifications. Point of contact during unplanned, emergency maintenance."},{key:"INTERCONNECTION_NOTIFICATIONS",text:"Interconnection Notifications",desc:"Receives notifications about interconnectivity orders."}],Nt=e=>{var t;return(t=le.find(o=>o.text===e))===null||t===void 0?void 0:t.key},qs=e=>{var t;return(t=le.find(o=>o.key===e))===null||t===void 0?void 0:t.text};let X=class extends I{constructor(){super(...arguments),this.checkedAccounts=[],this.roles=[],this.dataForAccounts=[],this.treeData=[],this._dataForAccounts=[],this._treeData=[],this._nextButtonEnabled=!1,this.multiSelectOpen=!1}connectedCallback(){super.connectedCallback(),this._dataForAccounts=this.dataForAccounts,this._treeData=this.treeData,this.validateStep(),this.dispatchValidateStepEvent()}getRoles(e){return this.roles.filter(t=>t.accountId===e)[0].roles}getRolesData(e){const t=this.roles.filter(i=>i.accountId===e)[0],o=[];return t.roles.forEach(i=>{var n;i.removed=!0;const a={id:"root",label:"",children:[],customerKnownSpaceName:""},s=(n=this._treeData.find(p=>p.accountNumber===e))===null||n===void 0?void 0:n.data;s&&s.length&&he(s[0],a);const l={accountId:e,role:i,locations:[],genericTreeView:a};o.push(l)}),o}getFlagsData(e){const t=[];return le.forEach(o=>{const i={accountId:e,flag:o,locations:[],genericFlagsData:[]};t.push(i)}),t}renderMultiSelectRoles(){this._dataForAccounts.length===0&&(this._dataForAccounts=this.checkedAccounts.map(t=>({accountId:t.id,accountName:t.label,rolesData:this.getRolesData(t.id),flagsData:this.getFlagsData(t.id),flagData:[],active:!1})));const e={};return this._dataForAccounts.forEach(t=>{e[t.accountId]=t.rolesData.filter(o=>o.role.removed===!0).map(o=>o.role.name)}),this._dataForAccounts.map(t=>{const o=[...new Set(this.getRoles(t.accountId).map(i=>i.name))].map(i=>({label:i,selected:!e[t.accountId].includes(i)}));return c` <div> <div class="account-roles-name">${t.accountName}</div> <ix-multi-select data-testid="multi-select-roles-${t.accountId}" required id="${`${t.accountId}-multi-select`}" style="max-width:99%" class="multi-select" .menuPositioning="${"popover"}" .items="${o}" .label="${"Roles"}" @toggle-multi-select-item="${i=>this.handleMultiSelect(t.accountId,i.detail.label,i.detail.selected)}" @remove-multi-select-item="${i=>this.handleMultiSelect(t.accountId,i.detail,!1)}" @clear-multi-select="${()=>this.handleMultiSelectClear(t.accountId)}" @select-menu="${i=>this.handleSelectMenu(i)}"></ix-multi-select> </div> `})}handleSelectMenu(e){e.detail.value==="open"?this.multiSelectOpen=!0:this.multiSelectOpen=!1}handleMultiSelect(e,t,o){var i,n,a;const[s]=this._dataForAccounts.filter(u=>u.accountId===e),l=this.getRoles(s.accountId).find(u=>u.name===t);if(!l)return;const p=s.rolesData.findIndex(u=>u.role.id===l.id);if(l.permissions.every(u=>u.isNonLocation)){const u=(i=s.rolesData[p])===null||i===void 0?void 0:i.genericTreeView;if(!((n=u==null?void 0:u.children)===null||n===void 0)&&n.length){const b=u.children[0];b.checked=!0,be(b,u),s.rolesData[p].locations.push(b)}}const h=s.rolesData.findIndex(u=>u.role.id===(l==null?void 0:l.id));if(s.rolesData[h].role.removed=!(o&&h>=0),!o){const u={id:"root",label:"",children:[],customerKnownSpaceName:""},b=(a=this._treeData.find(F=>F.accountNumber===e))===null||a===void 0?void 0:a.data;b&&b.length&&he(b[0],u),s.rolesData[h].locations=[],s.rolesData[h].genericTreeView=u}this.validateStep(),this.dispatchUpdateDFAEvent(),this.dispatchNextButtonToggleEvent()}validateStep(){const e=this._dataForAccounts.every(o=>o.rolesData.filter(i=>i.role.removed===!1).length),t=this._dataForAccounts.length===this.checkedAccounts.length;this._nextButtonEnabled=e&&t}handleMultiSelectClear(e){const t=this._dataForAccounts.filter(o=>o.accountId===e)[0];this._dataForAccounts.find(o=>o.accountId===e).rolesData=this.getRolesData(t.accountId),this._nextButtonEnabled=!1,this.dispatchUpdateDFAEvent(),this.dispatchNextButtonToggleEvent()}dispatchUpdateDFAEvent(){const e=new CustomEvent(w.UpdateDFA,{detail:{dataForAccounts:this._dataForAccounts},bubbles:!0,composed:!0});this.dispatchEvent(e)}dispatchNextStepEvent(){this.dispatchEvent(new CustomEvent(w.NextStep,{bubbles:!0,composed:!0}))}dispatchNextButtonToggleEvent(){this.dispatchEvent(new CustomEvent(w.NextButtonToggle,{detail:this._nextButtonEnabled,bubbles:!0,composed:!0}))}dispatchValidateStepEvent(){this.dispatchEvent(new CustomEvent(w.ValidateStep,{detail:this._nextButtonEnabled,bubbles:!0,composed:!0}))}render(){const e=this.multiSelectOpen?"overflow-hidden":"overflow-auto";return c` <div class="wizard-step-content flex flex-col overflow-hidden"> <div class="p-1 dlr-text-default ${e}">${this.renderMultiSelectRoles()}</div> <div class="flex justify-end" style="padding-top:8px"> <ix-button class="pt-2" type="submit" ?disabled="${!this._nextButtonEnabled}" has-icon trailing-icon @click="${this.dispatchNextStepEvent}" data-testid="step-three-next-button"> Next <md-icon slot="icon">east</md-icon> </ix-button> </div> </div> `}};X.styles=[ii,_,$e],r([d({type:Array})],X.prototype,"checkedAccounts",void 0),r([d({type:Array})],X.prototype,"roles",void 0),r([d({type:Array})],X.prototype,"dataForAccounts",void 0),r([d({type:Array})],X.prototype,"treeData",void 0),r([m()],X.prototype,"_dataForAccounts",void 0),r([m()],X.prototype,"_treeData",void 0),r([m()],X.prototype,"_nextButtonEnabled",void 0),r([m()],X.prototype,"multiSelectOpen",void 0),X=r([A("create-user-step-three")],X);const ot=$`ix-dialog{--md-dialog-container-color:#fff}ix-icon-button{--md-sys-color-on-surface-variant:var(--md-sys-color-primary)}ix-select{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd;--md-menu-container-color:#fff}ix-select.thick{--md-menu-container-shape:10px}ix-select.slim{--md-outlined-field-bottom-space:2px;--md-outlined-field-top-space:2px}ix-button{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd}ix-button .disabled{color:var(--md-sys-text-color-disabled)}.btn_primary{--md-filled-button-container-color:var(--md-sys-color-primary)}.btn_primary ix-icon{color:var(--md-sys-color-on-primary)}.btn_secondary{--md-filled-button-container-color:var(--md-sys-color-secondary)}.btn_secondary ix-icon{color:var(--md-sys-color-on-secondary)}.btn_tertiary{--md-filled-button-container-color:var(--md-sys-color-tertiary)}.btn_tertiary ix-icon{color:var(--md-sys-color-on-tertiary)}.btn_danger{--md-filled-button-container-color:var(--md-sys-color-error)}.btn_danger ix-icon{color:var(--md-sys-color-on-error)}.icon-btn_primary ix-icon{color:var(--md-sys-color-primary)}.icon-btn_secondary ix-icon{color:var(--md-sys-color-secondary)}.icon-btn_tertiary ix-icon{color:var(--md-sys-color-tertiary)}.icon-btn_danger ix-icon{color:var(--md-sys-color-error)}ix-icon.icon-lg{--ix-icon-font-size:32px}.dialog-form{min-width:500px;display:flex;flex-direction:column;justify-content:space-between;padding:8px 24px 20px}.dialog-form .textfield{width:100%}.dialog-form.sm{min-width:560px}.dialog-form__textbox{padding-top:1rem}.dialog-actions{display:flex;justify-content:flex-end;padding:8px 15px 8px 20px}@media only screen and (min-width:5px) and (max-width:600px){ix-dialog{--md-dialog-container-shape:6px}}@media only screen and (min-width:601px){ix-dialog{--md-dialog-container-shape:3px}}.permission-container{padding:1rem 1.5rem 0 1.5rem}ix-icon-button{--md-sys-color-on-surface-variant:black}.permission-dialog-container{padding:1rem 1rem 0 1rem;width:500px}.permission-container-row{display:block;padding:8px;margin-top:12px;margin-bottom:12px;box-shadow:#e1e4e8 0 0 0 1px inset;border-radius:8px}.permission-container-item{display:flex;flex-direction:row;width:100%}.permission-arrow{width:30px;cursor:pointer}.permission-name{line-height:24px;color:#092241}.permission-item{display:grid;grid-template-columns:1fr 20%;gap:16px;-webkit-box-align:center;align-items:center;-webkit-box-flex:1;flex-grow:1;padding-top:5px}.permission-item-privilege{margin:0;color:#333}.permission-container-row-create-user{display:flex;padding:12px;margin-top:10px;margin-bottom:10px;height:24px;width:475px;box-shadow:#e1e4e8 0 0 0 1px inset;border-radius:8px}.non-location{margin:10px 5px 5px 5px;background-color:#f5f7ff;padding:8px;border-radius:5px}.non-location-icon{padding-left:8px}.permissions-dialog-container{max-height:70vh;overflow-x:auto}`;class K{}K.ROW=e=>`permission-group-row-${e}`,K.CATEGORY=e=>`permission-group-category-${e}`,K.OVERALL_PERM=e=>`permission-group-overall-${e}`,K.BTN_EXPAND=e=>`permission-group-btn-expand-${e}`,K.PERM_NAME=e=>`permission-group-name-${e}`,K.PERM_PRIVILEGE=e=>`permission-group-privilege-${e}`;let Le=class extends I{constructor(){super(...arguments),this.permissionGroup=void 0,this.isOpen=!1}onClick(){this.isOpen=!this.isOpen,this.requestUpdate()}renderPermissionItemRow(e,t){return c` <div class="flex justify-between pl-11 items-center permission-item"> <p data-testid="${K.PERM_NAME(e)}">${e}</p> <p class="capitalize permission-item-privilege pr-4" data-testid="${K.PERM_PRIVILEGE(e)}"> <small>${t}</small> </p> </div> `}renderPermissionItems(e){return this.isOpen?c`<div class="permission-items-container"> ${e.filter(t=>!t.isNonLocation).map(t=>this.renderPermissionItemRow(t.name,t.privilege))} </div>`:y}render(){var e,t,o,i,n,a,s,l,p,h,u,b;return c`<div class="permission-container-row" data-testid="${K.ROW((t=(e=this.permissionGroup)===null||e===void 0?void 0:e.category)!==null&&t!==void 0?t:"")}"> <div class="flex items-center justify-between"> <div class="flex items-center"> <ix-icon-button icon="${this.isOpen?"arrow_drop_down":"arrow_right"}" @click="${this.onClick}" data-testid="${K.BTN_EXPAND((i=(o=this.permissionGroup)===null||o===void 0?void 0:o.category)!==null&&i!==void 0?i:"")}"> </ix-icon-button> <p class="m-0 permission-name permission-item-name pl-1" id="permission-item-name" data-testid="${K.CATEGORY((a=(n=this.permissionGroup)===null||n===void 0?void 0:n.category)!==null&&a!==void 0?a:"")}"> ${(s=this.permissionGroup)===null||s===void 0?void 0:s.category} </p> </div> <p class="m-0 pl-4 capitalize permission-overall-privilege mr-4" data-testid="${K.OVERALL_PERM((p=(l=this.permissionGroup)===null||l===void 0?void 0:l.category)!==null&&p!==void 0?p:"")}"> <small>${(h=this.permissionGroup)===null||h===void 0?void 0:h.overallPrivilege}</small> </p> </div> ${this.renderPermissionItems((b=(u=this.permissionGroup)===null||u===void 0?void 0:u.items)!==null&&b!==void 0?b:[])} </div>`}};Le.styles=[ot,_],r([d({type:Object,attribute:!1})],Le.prototype,"permissionGroup",void 0),r([m()],Le.prototype,"isOpen",void 0),Le=r([A("permission-group")],Le);class Te{}Te.ROW=e=>`non-location-permission-row-${e}`,Te.NAME=e=>`non-location-permission-item-${e}`,Te.PRIVILEGE=e=>`non-location-permission-privilege-${e}`;let it=class extends I{constructor(){super(...arguments),this.permission=void 0}render(){var e,t,o,i,n,a,s,l;return c`<div class="permission-container-row" data-testid="${Te.ROW((t=(e=this.permission)===null||e===void 0?void 0:e.name)!==null&&t!==void 0?t:"")}"> <div class="flex items-center justify-between"> <div class="flex items-center"> <p class="m-0 permission-name permission-item-name pl-1" data-testid="${Te.NAME((i=(o=this.permission)===null||o===void 0?void 0:o.name)!==null&&i!==void 0?i:"")}"> ${(n=this.permission)===null||n===void 0?void 0:n.name} </p> </div> <p class="m-0 pl-4 capitalize permission-overall-privilege mr-4" data-testid="${Te.PRIVILEGE((s=(a=this.permission)===null||a===void 0?void 0:a.name)!==null&&s!==void 0?s:"")}"> <small>${(l=this.permission)===null||l===void 0?void 0:l.privilege}</small> </p> </div> <div class="permission-items-container"> <div class="flex pl-13 items-center permission-item non-location"> <span class="non-location-icon"><md-icon slot="icon">info</md-icon></span> <p class="text-left dlr-text-caption"> You don't need to select location or assets for this permission </p> </div> </div> </div>`}};it.styles=[ot,_],r([d({type:Object,attribute:!1})],it.prototype,"permission",void 0),it=r([A("non-location-permission")],it);let nt=class extends I{constructor(){super(...arguments),this.permission=void 0}render(){var e,t;return c` <div class="permission-container-row"> <div class="flex items-center justify-between"> <div class="flex items-center"> <p class="m-0 permission-name pl-1">${(e=this.permission)===null||e===void 0?void 0:e.name}</p> </div> <p class="m-0 pl-4 capitalize permission-overall-privilege mr-4"> <small>${(t=this.permission)===null||t===void 0?void 0:t.privilege}</small> </p> </div> </div> `}};nt.styles=[ot,_],r([d({type:Object,attribute:!1})],nt.prototype,"permission",void 0),nt=r([A("non-category-permission")],nt);const Hs={AMER:"North America"},Ft={Global:0,Continent:1,Country:2,City:3,Site:4,Floor:5,Room:6,Cage:7,Row:8,Cabinet:9},Dt=e=>{var t,o;const i=Ft[e.type];return i===Ft.Continent&&e.label?(t=Hs[e.label])!==null&&t!==void 0?t:e.label:e.label&&i>Ft.Site&&/^[0-9]{1,3}$/.test(e.label)?`${e.type} ${e.label}`:(o=e.label)!==null&&o!==void 0?o:void 0},zs=e=>({id:e.id,accountNumber:e.accountNumber,roleId:e.roleId,parentId:e.parentInventoryId,customerKnownSpaceName:e.customerKnownSpaceName,type:e.type,label:Dt(e),isAssignable:e.isAssignable,secondaryLabel:e.secondaryLabel,childrenCount:e.childrenCount,inventoryItems:at(e.inventoryItems),selected:e.selected,searched:e.searched,status:e.permissionStatus,inherited:e.inherited}),at=e=>{const t=[];return e==null||e.forEach(o=>{t.push(zs(o))}),t},Vs=e=>{var t,o,i,n,a,s,l,p;return{contactId:e.id,accountId:e.accountNumber,roleId:e.roleId,isInternal:e.isInternal,startInventoryId:e.location,searchLocationText:(t=e.searchLocationText)!==null&&t!==void 0?t:"",level1:!0,level2:!0,level3:(o=e.allChildren)!==null&&o!==void 0?o:!1,level4:(i=e.allChildren)!==null&&i!==void 0?i:!1,level5:(n=e.allChildren)!==null&&n!==void 0?n:!1,level6:(a=e.allChildren)!==null&&a!==void 0?a:!1,level7:(s=e.allChildren)!==null&&s!==void 0?s:!1,level8:(l=e.allChildren)!==null&&l!==void 0?l:!1,level9:(p=e.allChildren)!==null&&p!==void 0?p:!1}},js=e=>({contactId:e.id,accountId:e.accountNumber,flag:e.flag,isInternal:e.isInternal,startInventoryId:e.location,level1:!0,level2:!0,level3:!0,level4:!0,level5:!0,level6:!0,level7:!0,level8:!0,level9:!0}),Gs=e=>{var t,o,i,n,a,s,l;return{accountId:e.accountNumber,isInternal:e.isInternal,level1:!0,level2:!0,level3:(t=e.allChildren)!==null&&t!==void 0?t:!1,level4:(o=e.allChildren)!==null&&o!==void 0?o:!1,level5:(i=e.allChildren)!==null&&i!==void 0?i:!1,level6:(n=e.allChildren)!==null&&n!==void 0?n:!1,level7:(a=e.allChildren)!==null&&a!==void 0?a:!1,level8:(s=e.allChildren)!==null&&s!==void 0?s:!1,level9:(l=e.allChildren)!==null&&l!==void 0?l:!1}},Js=e=>({id:e.id,accountNumber:e.accountNumber,flag:e.flag,parentId:e.parentInventoryId,customerKnownSpaceName:e.customerKnownSpaceName,type:e.type,isAssignable:e.isAssignable,label:Dt(e),secondaryLabel:e.secondaryLabel,childrenCount:e.childrenCount,checkedChildrenCount:e.checkedChildrenCount,inventoryItems:ni(e.inventoryItems),selected:e.selected,searched:!1,status:e.permissionStatus,inherited:e.inherited}),ni=e=>{const t=[];return e==null||e.forEach(o=>{t.push(Js(o))}),t},ai=e=>{const t=[];return e==null||e.forEach(o=>{t.push(Ks(o))}),t},Ks=e=>({id:e.id,accountNumber:e.accountNumber,parentId:e.parentInventoryId,customerKnownSpaceName:e.customerKnownSpaceName,type:e.type,isAssignable:e.isAssignable,label:Dt(e),secondaryLabel:e.secondaryLabel,childrenCount:e.childrenCount,inventoryItems:ai(e.inventoryItems)}),si=e=>{const t=[];return e==null||e.forEach(o=>{t.push({id:o.id,customerKnownName:o.customerKnownName,permissionStatus:o.permissionStatus})}),t},Zs=e=>({roleId:e.roleId,roleLocations:si(e.locations)}),Ws=e=>{const t=[];return e==null||e.forEach(o=>{t.push(Zs(o))}),t},Qs=e=>({contactId:e.contactId,accountNumber:e.accountNumber,locations:Ws(e.roleLocations),isInternal:e.isInternal,changeHistoryId:e.changeHistoryId}),Ys=e=>({flag:Nt(e.flag),flagLocations:si(e.locations)}),Xs=e=>{const t=[];return e==null||e.forEach(o=>{t.push(Ys(o))}),t},er=e=>({contactId:e.contactId,accountNumber:e.accountNumber,locations:Xs(e.flagLocations),isInternal:e.isInternal,changeHistoryId:e.changeHistoryId});class tr{async getRoleInventory(t){try{const o=Vs(t),i=await v.InventoryApi.GetRolesInventory(o);return i!=null&&i.getRoleTree?at([i.getRoleTree]):[]}catch(o){return g.handleError(o,"Failed to load the portal access tree."),[]}}async getFlagInventory(t){try{const o=js(t),i=await v.InventoryApi.GetFlagsInventory(o);return i!=null&&i.getFlagTree?ni([i==null?void 0:i.getFlagTree]):[]}catch(o){return g.handleError(o,"Failed to load the portal access tree."),[]}}async getAccountInventory(t){try{const o=Gs(t),i=await v.InventoryApi.GetAccountInventory(o);return i!=null&&i.getAccountTree?ai([i==null?void 0:i.getAccountTree]):[]}catch(o){return g.handleError(o,"Failed to get account inventory."),[]}}async saveAccountRoleInventory(t){try{const o=Qs(t),i=await v.InventoryApi.SaveAccountRoleAssignments(o);return at(i==null?void 0:i.saveAccountRoleAssignments)}catch(o){return null}}async saveAccountFlagInventory(t){try{const o=er(t),i=await v.InventoryApi.SaveAccountFlagAssignments(o);return at(i==null?void 0:i.saveAccountUserFlagAssignments)}catch(o){return null}}}const qe=new tr,or=e=>({role_id:e.roleId,user_id:e.contactId,account_number:e.accountNumber,location_id:e.location}),ri=e=>({roleId:e.role_id,contactId:e.user_id,accountNumber:e.account_number,location:e.location_id,id:e.id,isActive:e.is_active}),ir=e=>{const t=[];return e.forEach(o=>t.push(or(o))),t},li=e=>{const t=[];return e.forEach(o=>t.push(ri(o))),t},nr=e=>({userId:e.contactId,roleId:e.roleId,accountNumber:e.accountNumber,roleType:e.roleType}),ar=e=>({id:e.id}),sr=e=>({createRoleAssignment:{RoleAssignmentInput:ir(e.roleAssignmentInput),change_history_id:e.changeHistoryId}}),rr=e=>({id:e.id,changeHistoryId:e.changeHistoryId});class lr{async get(t){try{const o=nr(t),i=await v.RoleAssignmentsApi.getRoleAssignments(o);return li(i)}catch(o){return g.handleError(o,"Failed to get role assignments."),[]}}async getById(t){try{const o=ar(t),i=await v.RoleAssignmentsApi.getRoleAssignment(o);return ri(i)}catch(o){return g.handleError(o,"Failed to get role assignment"),{}}}async create(t){try{const o=sr(t),i=await v.RoleAssignmentsApi.createRoleAssignments(o);return li(i)}catch(o){return g.handleError(o,"Failed to create role assignment."),[]}}async delete(t){try{const o=rr(t);return v.RoleAssignmentsApi.deleteRoleAssignment(o)}catch(o){return g.handleError(o,"Failed to delete role assignment.")}}}const He=new lr,cr=async e=>{for(const t of e)await Promise.all(t.map(o=>o))},Ie=async e=>{const t=[];for(const o of e){const i=await Promise.all(o.map(n=>n));t.push(i)}return t},dr=e=>({user_flag_type:e.userFlagType,user_id:e.contactId,account_number:e.accountNumber,location_id:e.location}),ci=e=>({userFlagType:e.user_flag_type,contactId:e.user_id,accountNumber:e.account_number,location:e.location_id,id:e.id}),ur=e=>{const t=[];return e.forEach(o=>t.push(dr(o))),t},di=e=>{const t=[];return e.forEach(o=>t.push(ci(o))),t},hr=e=>({userId:e.contactId,accountNumber:e.accountNumber,userFlagType:e.userFlagType,locationId:e.location}),pr=e=>({id:e.id}),mr=e=>({createUserFlagAssignment:{UserFlagAssignmentInputs:ur(e.userFlagAssignmentInput),change_history_id:e.changeHistoryId}}),gr=e=>({id:e.id});class fr{async get(t){try{const o=hr(t),i=await v.UserFlagsApi.getUserFlags(o);return di(i)}catch(o){return g.handleError(o,"Failed to get assigned user flags."),[]}}async getById(t){try{const o=pr(t),i=await v.UserFlagsApi.getUserFlag(o);return ci(i)}catch(o){return g.handleError(o,"Failed to get user flag assignment."),{}}}async create(t){try{const o=mr(t),i=await v.UserFlagsApi.createUserFlags(o);return di(i)}catch(o){return g.handleError(o,"Failed to create user flag assignment."),[]}}async delete(t){try{const o=gr(t);return v.UserFlagsApi.deleteUserFlag(o)}catch(o){return g.handleError(o,"Failed to delete user flag assignment.")}}}const ze=new fr;class vr{constructor(){this.deleteAssignmentsAndFlags=async(t,o)=>{const i=[],n=[],a=[];try{return t.forEach(s=>{i.push(He.delete({id:s}))}),o.forEach(s=>{n.push(ze.delete({id:s}))}),i.length>0&&a.push(i),n.length>0&&a.push(n),cr(a)}catch(s){return g.handleError(s,"Failed to delete batch of role assignments and flags.")}},this.createAssignmentsAndFlags=async(t,o)=>{const i=[];try{if(t.length>0){const n=[He.create({roleAssignmentInput:t})];i.push(n)}if(o.length>0){const n=[ze.create({userFlagAssignmentInput:o})];i.push(n)}return[...await Ie(i)]}catch(n){return g.handleError(n,"Failed to create batch of role assignments and flags."),[]}},this.upsertAssignmentAndFlags=async(t,o,i,n,a)=>{try{(t.length>0||o.length)&&await this.deleteAssignmentsAndFlags(t,o),(i.length>0||n.length)&&await this.createAssignmentsAndFlags(i.map(s=>({...s,isInternal:a})),n)}catch(s){g.handleError(s,"Failed to upsert role assignments and flags.")}},this.getAssignmentInventory=async(t,o,i,n)=>{const a=[],s=[];try{return i.forEach(l=>{s.push(qe.getRoleInventory({id:t,accountNumber:o,roleId:l,location:"",isInternal:n,allChildren:!0}))}),a.push(s),[...(await Ie(a))[0]].flat()}catch(l){return g.handleError(l,"Failed to get inventory assignments."),[]}},this.getFlagInventory=async(t,o,i)=>{const n=[],a=[];try{return le.forEach(s=>{a.push(qe.getFlagInventory({id:t,flag:s.key,accountNumber:o,location:"",allChildren:!1,isInternal:i}))}),n.push(a),[...(await Ie(n))[0]].flat()}catch(s){return g.handleError(s,"Failed to get inventory flags."),[]}}}}const ui=new vr;async function yr(e,t,o,i,n,a,s){const l={id:t,roleId:e,accountNumber:o,location:i,searchLocationText:n,allChildren:a,isInternal:s};return await qe.getRoleInventory(l)}async function hi(e,t,o,i){const n=await ui.getAssignmentInventory(t,o,e,i),a={id:"root",label:"",children:[],customerKnownSpaceName:""},s=[];for(const l of n){const p=he(l,structuredClone(a));s.push({role:l.roleId,rootNode:p,isOpen:!1})}return s}async function br(e,t,o){const i=await ui.getFlagInventory(e,t,o),n={id:"root",label:"",children:[],customerKnownSpaceName:""},a=[];for(const s of i){const l=he(s,structuredClone(n));a.push({label:qs(s.flag),rootNode:l,isOpen:!1})}return a}const Pt=e=>{const t=[];return e?(e.forEach(o=>{const i=t.findIndex(s=>s.category===o.category),n={id:o.permissionId,name:o.permissionName,privilege:o.privilege,isNonLocation:o.isNonLocation};if(i===-1)return t.push({category:o.category||"Misc.",overallPrivilege:o.privilege,items:[n]});const a=s=>new Set(s.map(l=>l.privilege)).size===1?s[0].privilege:"MIXED";t[i].items.push(n),t[i].overallPrivilege=a(t[i].items)}),hs(t,"category",!0)):t},xr=async(e,t,o,i)=>{const n=await hi(e,t,o,i),a=await br(t,o,i);return[n,a]},Z={Default:"DEFAULT",Internal:"INTERNAL",Custom:"CUSTOM",GlobalAccess:"GLOBALACCESS"};Object.values(Z);const pi=e=>({permissionId:e.permission_id,isNonLocation:e.is_non_location,privilege:e.privilege}),mi=e=>{const t=[];return e.permissions.forEach(o=>t.push(pi(o))),{name:e.name,accountNumber:e.account_number,roleType:e.role_type,permissions:t,removed:!1,id:e.id}},gi=e=>{const t=[];return e.forEach(o=>{t.push(mi(o))}),t},wr=e=>{var t,o;const i=[];return e.permissions.forEach(n=>i.push(pi(n))),{name:e.name,accountNumber:e.account_number,roleType:e.role_type,permissions:i,removed:!1,id:e.id,status:(t=e.status)!==null&&t!==void 0?t:!0,message:(o=e.message)!==null&&o!==void 0?o:""}},Ar=e=>{const t=[];return e.forEach(o=>{t.push(wr(o))}),t},Cr=e=>({permission_id:e.permissionId,privilege:e.privilege}),fi=e=>{const t=[];return e.forEach(o=>{t.push(Cr(o))}),t},_r=e=>({role_name:e.name,permissions:fi(e.permissions)}),Tr=e=>{const t={name:e.name,role_type:e.roleType,permissions:fi(e.permissions)};switch(e.roleType){case Z.Internal:case Z.Default:case Z.GlobalAccess:return t;case Z.Custom:{if(e.accountNumbers&&e.accountNumbers.length>0)return{...t,account_numbers:e.accountNumbers};if(e.accountNumber)return{...t,account_number:e.accountNumber};throw new Error("Account number is required for custom roles. Please ensure an account is selected.")}default:throw new Error(`Unknown role type; ${e.roleType} provided`)}},Ir=e=>({roleType:e.roleType}),Er=e=>({id:e.id}),Rr=e=>({roleCreate:Tr(e.roleCreate)}),Sr=e=>({id:e.id,roleUpdate:_r(e.roleUpdate)}),kr=e=>({id:e.id});class Ur{async get(t){try{let o;if(!(t!=null&&t.roleType)){const a=await v.RolesApi.getRoles();return o=gi(a),o}const i=Ir(t),n=await v.RolesApi.getRoles(i);return o=gi(n),o}catch(o){return g.handleError(o,"Failed to get roles."),[]}}async getById(t){try{const o=Er(t),i=await v.RolesApi.getRole(o);return mi(i)}catch(o){return g.handleError(o,"Failed to get role."),{}}}async update(t){try{const o=Sr(t);return v.RolesApi.updateRole(o)}catch(o){return g.handleError(o,"Failed to update role.")}}async create(t){try{const o=Rr(t),i=await v.RolesApi.createRole(o);return Ar(i)}catch(o){return g.handleError(o,`Failed to create the role '${t.roleCreate.name}'.`),[]}}async delete(t){try{const o=kr(t);return v.RolesApi.deleteRole(o)}catch(o){return g.handleError(o,"Failed to delete role.")}}}const Mt=new Ur,Ot=e=>({id:e.id,accountNumber:e.account_number,accountName:e.account_name,displayName:e.account_friendly_name,status:e.status,updatedAt:e.updated_at,updatedBy:e.updated_by,userId:e.user_id}),$r=e=>{const t=[];return e.forEach(o=>{t.push(Ot(o))}),t},Nr=e=>({user_id:e.contactId,account_number:e.accountNumber,change_history_id:e.changeHistoryId}),Fr=e=>({accountNumber:e.accountNumber,userId:e.contactId,status:e.status}),Dr=e=>({accountAssociationInput:Nr(e.accountAssociationInput)}),Pr=e=>({id:e.id}),Mr=e=>({id:e.id,accountAssociationStatusUpdate:{status:e.accountAssociationStatusUpdate.status,change_history_id:e.accountAssociationStatusUpdate.changeHistoryId}});class Or{async create(t){try{const o=Dr(t),i=await v.AccountAssociationApi.createAccountAssociation(o);return Ot(i)}catch(o){return g.handleError(o,"Failed to create account association."),null}}async get(t){try{const o=Fr(t),i=await v.AccountAssociationApi.getAccountAssociations(o);return $r(i)}catch(o){return g.handleError(o,"Failed to get associated accounts."),[]}}async getById(t){try{const o=Pr(t),i=await v.AccountAssociationApi.getUserAccountAssociation(o);return Ot(i)}catch(o){return g.handleError(o,"Failed to get account association"),{}}}async update(t){try{const o=Mr(t);await v.AccountAssociationApi.updateAccountAssociationStatus(o)}catch(o){g.handleError(o,"Failed to update account association status.")}}}const vi=new Or;class Br{constructor(){this.getRoles=async t=>{try{let o=[];return t?o=await Mt.get({roleType:t}):o=await Mt.get({}),[...new Map(o.map(i=>[i.id,i])).values()]}catch(o){return g.handleError(o,"Failed to get all roles."),[]}},this.getRolesAndPermissions=async t=>{const o=await Promise.allSettled([We.get(),this.getRoles(t)]);o.forEach(s=>{if(s.status==="rejected")throw new Error});const i=[o[0].value,o[1].value],[n,a]=i;try{return a.forEach(s=>{s.permissions.forEach(l=>{const p=n.find(h=>h.id===l.permissionId);p&&(l.permissionName=p.name,l.category=p.category)})}),a}catch(s){return g.handleError(s,"Failed to get roles with permissions."),[]}},this.getUserData=async(t,o)=>{const i=[];try{const n=[He.get({contactId:t}),ze.get({contactId:t,accountNumber:o}),vi.get({contactId:t,accountNumber:o})];return i.push(n),[...(await Ie(i))[0]]}catch(n){return g.handleError(n,"Failed to get user data."),[]}},this.getState=async()=>{const t=[];try{const o=[We.getMyPermissions({excludeParents:!1,excludeSiblings:!0}),We.get(),this.getRolesAndPermissions(),So.get()];return t.push(o),[...(await Ie(t))[0]]}catch(o){return g.handleError(o,"Failed to get user state."),[]}},this.getAccountData=async t=>{const o=[],i=[];try{for(const n of t)i.push(qe.getAccountInventory({accountNumber:n,allChildren:!0}));return o.push(i),[...(await Ie(o))[0]]}catch(n){return g.handleError(n,"Failed to get account data."),[]}}}}const st=new Br;class Ee{constructor(t){this._state=t,this._hydrating=!1,Hi(this)}get(){return this.state}set(t){this._state=t}update(t){this._state={...this.get(),...t}}clear(){this.isObject(this._state)&&(this._state={}),this.isArray(this._state)&&(this._state=[])}isHydrating(){return this.hydrating}requestHydration(){this._hydrating=!0}completeHydration(){this._hydrating=!1}get state(){return Ne(this._state)}get hydrating(){return this._hydrating}isArray(t){return Array.isArray(t)}isObject(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}}r([Qt],Ee.prototype,"_state",void 0),r([Qt],Ee.prototype,"_hydrating",void 0);class Lr extends Ee{async refresh(){this.requestHydration();const t=await st.getRolesAndPermissions();this.set(t),this.completeHydration()}}const ve=new Lr([]);let Re=class extends I{constructor(){super(...arguments),this.inPermissionsDialog=!1,this.permissionData=[]}updated(e){e.has("activeRoleId")&&this.hydratePermissions()}hydratePermissions(){const e=ve.get().find(t=>t.id===this.activeRoleId);e!=null&&e.permissions&&(this.permissionData=Pt(e.permissions))}render(){const e=this.permissionData.filter(i=>i.category!=="Misc.").flatMap(i=>i.items).filter(i=>i.isNonLocation),t=structuredClone(this.permissionData).filter(i=>i.category!=="Misc.").filter(i=>i.items.some(n=>!n.isNonLocation)).map(i=>({...i,items:i.items.filter(n=>!n.isNonLocation)})),o=this.permissionData.filter(i=>!i.category||i.category==="Misc.").flatMap(i=>i.items);return c` <div data-testid="permissions-container" class="${this.inPermissionsDialog?"permissions-dialog-container":""}"> ${this.inPermissionsDialog?y:c`<h3 class="dlr-text-heading">Permissions</h3>`} ${gt(e,i=>i.id,i=>c` <non-location-permission .permission="${i}"></non-location-permission> `)} ${gt(t,i=>i.items,i=>c` <permission-group .permissionGroup="${i}"></permission-group> `)} ${gt(o,i=>i.id,i=>c` <non-category-permission .permission="${i}"></non-category-permission> `)} </div> `}};Re.styles=[ot,_],r([d()],Re.prototype,"activeRoleId",void 0),r([d({type:Boolean})],Re.prototype,"inPermissionsDialog",void 0),r([m()],Re.prototype,"permissionData",void 0),Re=r([A("user-details-permission")],Re);const rt=$`@font-face{font-family:'Material Icons';font-style:normal;font-weight:400;src:url(https://fonts.gstatic.com/s/materialicons/v145/flUhRq6tzZclQEJ-Vdg-IuiaDsNZ.ttf) format('truetype')}.material-icons{font-family:'Material Icons';font-weight:400;font-style:normal;font-size:24px;line-height:1;letter-spacing:normal;text-transform:none;display:inline-block;white-space:nowrap;word-wrap:normal;direction:ltr}.flex{display:flex}.flex-1{flex:1}.border-top-solid-gray{border-top:solid 1px #ddd}.red{background-color:#db0028}.blue{background-color:#1456e0}.white{background-color:#fff;color:#1456e0;border:solid 1px #1456e0}.right{float:right}.margin-top-20{margin-top:20px}.padding-2{padding:2px}.padding-20{padding:20px}.padding-right-10{padding:10px}`,lt=$`ix-dialog{--md-dialog-container-color:#fff}ix-icon-button{--md-sys-color-on-surface-variant:var(--md-sys-color-primary)}ix-select{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd;--md-menu-container-color:#fff}ix-select.thick{--md-menu-container-shape:10px}ix-select.slim{--md-outlined-field-bottom-space:2px;--md-outlined-field-top-space:2px}ix-button{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd}ix-button .disabled{color:var(--md-sys-text-color-disabled)}.btn_primary{--md-filled-button-container-color:var(--md-sys-color-primary)}.btn_primary ix-icon{color:var(--md-sys-color-on-primary)}.btn_secondary{--md-filled-button-container-color:var(--md-sys-color-secondary)}.btn_secondary ix-icon{color:var(--md-sys-color-on-secondary)}.btn_tertiary{--md-filled-button-container-color:var(--md-sys-color-tertiary)}.btn_tertiary ix-icon{color:var(--md-sys-color-on-tertiary)}.btn_danger{--md-filled-button-container-color:var(--md-sys-color-error)}.btn_danger ix-icon{color:var(--md-sys-color-on-error)}.icon-btn_primary ix-icon{color:var(--md-sys-color-primary)}.icon-btn_secondary ix-icon{color:var(--md-sys-color-secondary)}.icon-btn_tertiary ix-icon{color:var(--md-sys-color-tertiary)}.icon-btn_danger ix-icon{color:var(--md-sys-color-error)}ix-icon.icon-lg{--ix-icon-font-size:32px}.dialog-form{min-width:500px;display:flex;flex-direction:column;justify-content:space-between;padding:8px 24px 20px}.dialog-form .textfield{width:100%}.dialog-form.sm{min-width:560px}.dialog-form__textbox{padding-top:1rem}.dialog-actions{display:flex;justify-content:flex-end;padding:8px 15px 8px 20px}@media only screen and (min-width:5px) and (max-width:600px){ix-dialog{--md-dialog-container-shape:6px}}@media only screen and (min-width:601px){ix-dialog{--md-dialog-container-shape:3px}}:host{--md-sys-color-on-surface-variant:rgba(9, 34, 65, 0.7);--md-primary-tab-hover-label-text-color:#1456e0}.remove{background-color:#fff;color:#db0028;border:1px solid #db0028}.remove-disabled{background-color:#fff;color:rgba(0,0,0,.26);border:1px solid rgba(0,0,0,.26)}.remove-role-container{padding:1rem 0 0 1rem}ix-textbox,md-textfield{--md-outlined-text-field-width:100%;--md-outlined-text-field-focus-width:100%;width:inherit}.option{display:block;width:100%}.option-disabled{display:block;width:100%;color:#ddd}.check_circle{color:#4caf50}.mail{color:#ff9800}.warning{color:#db0028}.delete_forever{color:#6d758c}.active-icon-section{display:flex;align-items:center;padding-right:16px}.panel-status{display:flex;-webkit-box-align:center;align-items:center;gap:4px;padding-right:8px}.panel-button-container{display:flex;flex-direction:row;column-gap:12px}.suspend-button{padding:8.5px 20px}.account-status-suspend{width:100px;padding-left:2px}.btn-disabled{color:rgba(0,0,0,.26);box-shadow:none;background-color:rgba(0,0,0,.12)}.confirmation-content{flex:1 1 auto;padding-right:24px;padding-bottom:20px;padding-left:24px;overflow:hidden;padding-top:8px!important}.role-add-icon{vertical-align:text-bottom;padding-right:5px}.role-add-text{vertical-align:text-top;text-transform:uppercase}.confirmation-content{max-width:550px}.add-roles-dialog-actions{display:flex;justify-content:flex-end;padding:24px 15px 8px 20px}.user-detail-navigation-contents{display:flex;align-items:center}.user-detail-navigation-contents>ix-button{margin-left:auto}.user-detail-navigation{border-top:1.5px solid #bec9c8;position:relative;top:-1px}.flag-text{text-align:right;margin-right:1.5rem}#flag-text-link{color:#1456e0}.mobile-options{display:none}.email{text-decoration:underline}ix-button{font-family:var(--root-secondary-font)}@media only screen and (max-width:600px){.user-details-controls>ix-button{display:none}div>.user-details-controls{padding-right:0}.mobile-options{display:flex;align-items:center;color:var(--md-sys-color-primary,#1456e0);font-size:24px}ix-menu-item{min-width:200px}h1{margin-bottom:.75rem}.tree-view{overflow-x:auto;overflow-y:hidden;max-width:100%}.flag-text{text-align:center;margin-right:0}.user-details-panel{margin:0 -.5rem;overflow:hidden}}@media only screen and (min-width:601px) and (max-width:1200px){.tree-view{overflow-x:auto;overflow-y:hidden;max-width:100%}}@media only screen and (max-width:1200px){.flex.user-status{flex-direction:column;align-items:flex-start}.user-status-header{width:100%;justify-content:space-between;padding-bottom:12px}}`;class ct{}ct.BTN_CANCEL=e=>`changes-dialog-${e}-btn-cancel`,ct.BTN_CONFIRM=e=>`changes-dialog-${e}-btn-confirm`;let ce=class extends I{constructor(){super(...arguments),this.handleEscapeKeyBinding=this.handleEscapeKey.bind(this),this.headerText="",this.bodyText="",this.cancelButtonText="Cancel",this.confirmationButtonText="Confirm",this.isOpen=!1,this.submitting=!1}connectedCallback(){super.connectedCallback(),this.addEventListener("keydown",this.handleEscapeKeyBinding)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("keydown",this.handleEscapeKeyBinding)}handleEscapeKey(e){return e.which===27&&this.handleCancelChanges(),null}handleConfirmChanges(){this.dispatchEvent(new CustomEvent("confirm"))}handleCancelChanges(){this.dispatchEvent(new CustomEvent("cancel"))}renderHeader(){return this.headerText.length?c`<div slot="headline"> <h1 class="dlr-text-heading">${this.headerText}</h1> </div>`:y}renderContent(){return this.bodyText?c`<div class="confirmation-content" slot="content" method="dialog"> <p>${this.bodyText}</p> </div>`:y}renderFooter(){return c` <div class="dialog-actions" slot="actions"> <ix-button form="confirm-updates" appearance="text" text="${this.cancelButtonText}" ?disabled="${this.submitting}" @click="${()=>this.handleCancelChanges()}" data-testid="${ct.BTN_CANCEL(this.id)}"> ${this.cancelButtonText} </ix-button> <ix-button id="add-account-button" form="confirm-updates" appearance="text" text="${this.confirmationButtonText}" ?submitting="${this.submitting}" @click="${()=>this.handleConfirmChanges()}" data-testid="${ct.BTN_CONFIRM(this.id)}"> ${this.confirmationButtonText} </ix-button> </div> `}render(){return c`<ix-dialog class="z-50 relative" id="add-role-to-account" ?open="${this.isOpen}" @closed="${()=>this.handleCancelChanges()}"> ${this.renderHeader()} ${this.renderContent()} ${this.renderFooter()} </ix-dialog>`}};ce.styles=[rt,lt,_],r([d({type:String})],ce.prototype,"headerText",void 0),r([d({type:String})],ce.prototype,"bodyText",void 0),r([d({type:String})],ce.prototype,"cancelButtonText",void 0),r([d({type:String})],ce.prototype,"confirmationButtonText",void 0),r([d({type:Boolean,reflect:!0})],ce.prototype,"isOpen",void 0),r([d({type:Boolean})],ce.prototype,"submitting",void 0),ce=r([A("changes-confirmation")],ce);const qr=$`
2042
2042
  .tab-container {
2043
2043
  container-type: inline-size;
2044
2044
  }
@@ -2054,4 +2054,4 @@ video {
2054
2054
  width: 100%;
2055
2055
  }
2056
2056
  }
2057
- `;class ct{}ct.BTN_ADD_ROLE="user-details-tab-roles-btn-add-role",ct.BTN_REMOVE_ROLE="user-details-tab-roles-btn-remove-role";const Lt={RoleSelect:"role-select",OpenRoleMenu:"open-role-menu",RemoveRoleMenu:"open-remove-role-menu"};let ie=class extends I{constructor(){super(...arguments),this.disableEscapeKeyBinding=this.disableEscapeKey.bind(this),this.assignedRoles=[],this.activeRoleId="",this.canAddRoles=!1,this.addRolesDisabled=!1,this.canRemoveRoles=!1,this.removeRolesDisabled=!1}connectedCallback(){super.connectedCallback(),this.tabs&&this.tabs.addEventListener("keydown",this.disableEscapeKeyBinding)}disconnectedCallback(){super.disconnectedCallback(),this.tabs&&this.tabs.removeEventListener("keydown",this.disableEscapeKeyBinding)}disableEscapeKey(e){return e.which===27?!1:null}handleRoleClick(e,t){this.dispatchEvent(new CustomEvent(Lt.RoleSelect,{detail:{roleId:t},bubbles:!0,composed:!0})),e.target.scrollIntoView({inline:"center",behavior:"smooth",block:"nearest"})}dispatchOpenRoleMenu(){this.dispatchEvent(new CustomEvent(Lt.OpenRoleMenu,{bubbles:!0,composed:!0}))}dispatchOpenRemoveRoleMeu(){this.dispatchEvent(new CustomEvent(Lt.RemoveRoleMenu,{bubbles:!0,composed:!0}))}setActiveRole(e){this.tabs&&(this.tabs.activeTabIndex=this.assignedRoles.findIndex(t=>t.id===e))}renderAddRoleButton(){return this.canAddRoles?c` <ix-button data-testid="${ct.BTN_ADD_ROLE}" appearance="text" @click="${()=>this.dispatchOpenRoleMenu()}" class="primary" aria-label="Add Role" ?disabled="${this.addRolesDisabled}" has-icon> <md-icon slot="icon">add</md-icon> Add Role </ix-button> `:y}renderRemoveRoleButton(){return this.canRemoveRoles?c` <ix-button data-testid="${ct.BTN_REMOVE_ROLE}" appearance="outlined" .disabled="${this.removeRolesDisabled}" @click="${()=>this.dispatchOpenRemoveRoleMeu()}" class="cancel"> <span>REMOVE ROLE</span> </ix-button> `:y}renderRole(e){return e?c`<ix-primary-tab data-testid="ix-tab-role-${e.id}" @click="${t=>this.handleRoleClick(t,e.id)}" ?activeDisabled="${e.id===this.activeRoleId}"><span id="${`role-tab-${e.id}`}" class="font-bold flex items-center uppercase">${e.name}</span> </ix-primary-tab>`:y}render(){return c` <div class="tab-container"> <div class="flex gap-4 max-w-full overflow-hidden tab-outer-wrapper"> <div class="flex-1 overflow-auto tab-inner-wrapper"> <ix-tabs data-testid="ix-tabs-roles" id="roles-tabs" .scrollButtons="${this.assignedRoles.length>1}" hideScrollBar left-align="true"> ${this.assignedRoles.map(e=>this.renderRole(e))} </ix-tabs> </div> <div class="flex items-center gap-4 shrink-0 tab-inner-wrapper"> ${this.renderAddRoleButton()} ${this.renderRemoveRoleButton()} </div> </div> </div> `}};ie.styles=[st,rt,_,ge,Hr],r([d({type:Array,attribute:!1})],ie.prototype,"assignedRoles",void 0),r([d({type:String,attribute:!1})],ie.prototype,"activeRoleId",void 0),r([d({type:Boolean})],ie.prototype,"canAddRoles",void 0),r([d({type:Boolean})],ie.prototype,"addRolesDisabled",void 0),r([d({type:Boolean})],ie.prototype,"canRemoveRoles",void 0),r([d({type:Boolean})],ie.prototype,"removeRolesDisabled",void 0),r([D("#roles-tabs")],ie.prototype,"tabs",void 0),ie=r([A("user-details-tab-roles")],ie);const xi=e=>U.getAccounts().find(t=>t.accountNumber===e),wi=(e,t)=>{const o=e.filter(i=>i.parentAccountNumber===t);return o.length?o.flatMap(i=>({id:i.accountNumber,name:i.name,displayName:i.displayName,subaccounts:wi(e,i.accountNumber)})):[]},dt=e=>{try{const t=e.map(i=>i.accountNumber),o=e.filter(i=>!t.includes(i.parentAccountNumber||""));if(!o)throw new Error("Failed to get nested account structure");return o.map(i=>({id:i.accountNumber,name:i.name,displayName:i.displayName,subaccounts:wi(e,i.accountNumber)}))}catch(t){return console.error("Could not get nested account structure",t),[]}},qt=()=>U.getAccounts().sort((e,t)=>e.name.localeCompare(t.name,void 0,{sensitivity:"base"})),Ai=e=>ve.get().find(t=>t.id===e)||null,zr=e=>{const t=[],o=[...new Set(e.map(i=>i.roleId))];for(const i of o){const n=Ai(i);n&&t.push(n)}return t},Ci=e=>{var t;return{label:(t=e.displayName)!==null&&t!==void 0?t:e.name,id:e.id,children:e.subaccounts.map(o=>Ci(o))}},_i=(e,t)=>{e.children&&e.children.length&&e.children.forEach(i=>_i(i,t));const o=t.filter(i=>e.id===i.accountNumber).map(i=>({label:i.name,id:i.id,children:void 0}));e.children&&(e.children=o.concat(e.children))},Vr=e=>{const t=[],o=qt().filter(s=>B.hasCustomRolesRead(s.accountNumber)||B.hasCustomRolesCreate(s.accountNumber)||B.hasCustomRolesUpdate(s.accountNumber)||B.hasCustomRolesApprove(s.accountNumber)),i=dt(o);i.forEach(s=>t.push(Ci(s)));const n=ve.get().filter(s=>s.roleType===Z.Custom);t.forEach(s=>{_i(s,n),s.expanded=e.includes(s.id)});const a=i.some(s=>!!s.subaccounts.length);return{tree:{label:"root",id:"root",children:t},isEndChild:!a&&o.length<=1}},Ht=(e,t,o=!1)=>{let i=t.filter(n=>n.accountNumber===e||n.roleType===Z.Default||n.roleType===Z.Internal||n.roleType===Z.GlobalAccess);return o||(i=i.filter(n=>n.roleType!==Z.Internal&&n.roleType!==Z.GlobalAccess)),i};class ee{}ee.HEADING="add-account-role-dialog-heading",ee.ROLE_SELECTOR="add-account-role-dialog-role-selector",ee.ROLE_OPTION=e=>`add-account-role-dialog-role-option-${e}`,ee.BTN_CANCEL="add-account-role-dialog-cancel-button",ee.BTN_ADD="add-account-role-dialog-add-role-button",ee.SUCCESS_MESSAGE="add-account-role-dialog-success-message";function pe(e){const t=e==null?void 0:e.toLowerCase().trim();return N().InternalUserDomainWhitelist.split(",").map(o=>o.toLowerCase().trim()).filter(Boolean).some(o=>t==null?void 0:t.includes(o))}function jr(e){return pe(e)&&N().EnableUMChangeHistory===!0}function zt(){return jr(U.getEmail())}let W=class extends I{constructor(){super(...arguments),this.roles=[],this.assignedRoles=[],this.isOpen=!1,this.loading=!1,this.roleId="",this.disabled=!0,this.handleEscapeKeyBinding=this.handleEscapeKey.bind(this),this.handleCancelChangesBinding=this.handleCancelChanges.bind(this)}get name(){var e,t;return`${(e=this.contact)===null||e===void 0?void 0:e.firstName} ${(t=this.contact)===null||t===void 0?void 0:t.lastName}`}get addableRoles(){var e,t,o;if(!(!((e=this.account)===null||e===void 0)&&e.accountNumber))return[];const i=pe((t=this.contact)===null||t===void 0?void 0:t.email)&&B.hasAssignInternalRoleCreate((o=this.account)===null||o===void 0?void 0:o.accountNumber);return Ht(this.account.accountNumber,this.roles,i)}connectedCallback(){super.connectedCallback(),this.addEventListener("keydown",this.handleEscapeKeyBinding),this.addEventListener("blur",this.handleCancelChangesBinding)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("keydown",this.handleEscapeKeyBinding),this.removeEventListener("blur",this.handleCancelChangesBinding)}handleEscapeKey(e){return e.which===27&&(this.isOpen=!1),null}async handleOpenDialog(){this.isOpen=!0;const e=await this.rolesMenu;e==null||e.reset(),this.disabled=!0}async handleConfirmChanges(){this.dispatchEvent(new CustomEvent(S.AddRole,{detail:{roleId:this.roleId}}))}async handleCancelChanges(){this.isOpen=!1}handleRoleSelect(e){e&&(this.disabled=!1)}renderRoleOptions(){return c` ${this.addableRoles.map((e,t)=>c` <ix-select-option class="option" value="${t}" ?disabled="${this.assignedRoles.some(o=>o.id===e.id)}" @click="${()=>{this.roleId=this.addableRoles[t].id}}" data-testid="${ee.ROLE_OPTION(e.name)}"> <div slot="headline">${e.name}</div> </ix-select-option>`)} `}renderHeader(){var e;return c` <div id="confirmation-header" slot="headline" style="max-width:560px" data-testid="${ee.HEADING}"> <h1 class="dlr-text-heading break-words"> Add Role to ${this.name} for ${(e=this.account)===null||e===void 0?void 0:e.name} </h1> </div>`}renderContent(){return c` <div slot="content" method="dialog"> <form slot="content" style="padding-top:0" id="add-role-to-roles" method="dialog"> <ix-select quick menu-below class="thick" id="roles-menu" menu-positioning="fixed" @input="${e=>this.handleRoleSelect(e.target.value)}" data-testid="${ee.ROLE_SELECTOR}"> ${this.renderRoleOptions()} </ix-select> </form> </div>`}renderFooter(){return c` <div class="add-roles-dialog-actions" slot="actions"> <ix-button form="confirm-updates" appearance="text" text="Cancel" ?disabled="${this.loading}" @click="${()=>this.handleCancelChanges()}" data-testid="${ee.BTN_CANCEL}"> Cancel </ix-button> <ix-button id="add-account-button" form="confirm-updates" appearance="text" text="Add Role" ?disabled="${this.disabled}" ?submitting="${this.loading}" @click="${this.handleConfirmChanges}" data-testid="${ee.BTN_ADD}">Add Role </ix-button> </div> `}render(){return c` <ix-dialog class="z-50 relative" id="add-role-to-account" ?open="${this.isOpen}"> ${this.renderHeader()} ${this.renderContent()} ${this.renderFooter()} </ix-dialog>`}};W.styles=[st,rt,_],r([d({type:Object})],W.prototype,"contact",void 0),r([d({type:Object})],W.prototype,"account",void 0),r([d({type:Array})],W.prototype,"roles",void 0),r([d({type:Array})],W.prototype,"assignedRoles",void 0),r([d({type:Boolean,reflect:!0})],W.prototype,"isOpen",void 0),r([m()],W.prototype,"loading",void 0),r([m()],W.prototype,"roleId",void 0),r([m()],W.prototype,"disabled",void 0),r([qi("#roles-menu")],W.prototype,"rolesMenu",void 0),W=r([A("add-account-role")],W);const Vt=$`ix-dialog{--md-dialog-container-color:#fff}ix-icon-button{--md-sys-color-on-surface-variant:var(--md-sys-color-primary)}ix-select{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd;--md-menu-container-color:#fff}ix-select.thick{--md-menu-container-shape:10px}ix-select.slim{--md-outlined-field-bottom-space:2px;--md-outlined-field-top-space:2px}ix-button{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd}ix-button .disabled{color:var(--md-sys-text-color-disabled)}.btn_primary{--md-filled-button-container-color:var(--md-sys-color-primary)}.btn_primary ix-icon{color:var(--md-sys-color-on-primary)}.btn_secondary{--md-filled-button-container-color:var(--md-sys-color-secondary)}.btn_secondary ix-icon{color:var(--md-sys-color-on-secondary)}.btn_tertiary{--md-filled-button-container-color:var(--md-sys-color-tertiary)}.btn_tertiary ix-icon{color:var(--md-sys-color-on-tertiary)}.btn_danger{--md-filled-button-container-color:var(--md-sys-color-error)}.btn_danger ix-icon{color:var(--md-sys-color-on-error)}.icon-btn_primary ix-icon{color:var(--md-sys-color-primary)}.icon-btn_secondary ix-icon{color:var(--md-sys-color-secondary)}.icon-btn_tertiary ix-icon{color:var(--md-sys-color-tertiary)}.icon-btn_danger ix-icon{color:var(--md-sys-color-error)}ix-icon.icon-lg{--ix-icon-font-size:32px}.dialog-form{min-width:500px;display:flex;flex-direction:column;justify-content:space-between;padding:8px 24px 20px}.dialog-form .textfield{width:100%}.dialog-form.sm{min-width:560px}.dialog-form__textbox{padding-top:1rem}.dialog-actions{display:flex;justify-content:flex-end;padding:8px 15px 8px 20px}@media only screen and (min-width:5px) and (max-width:600px){ix-dialog{--md-dialog-container-shape:6px}}@media only screen and (min-width:601px){ix-dialog{--md-dialog-container-shape:3px}}.cards-container{display:flex;flex-wrap:wrap}.cards-container>:first-child{padding:8px 8px 8px 0}.cards-container>:not(:first-child){padding:8px}.tree-role-locations-count{margin:0;color:rgba(9,34,65,.3);padding-right:20px;text-transform:uppercase;font-weight:700}.tree-role-locations-count-active{margin:0;padding-right:40px;text-transform:uppercase;font-weight:700;font-size:.875rem;font-family:var(--root-secondary-font)}.assign-portal-access-text{font-family:Open Sans;font-weight:400;font-size:12px;line-height:16px;letter-spacing:.4px;color:#092241B2;margin-top:.25rem;margin-bottom:1rem}ix-button{font-family:var(--root-secondary-font)}.remove{color:#db0028}.permissions-content{width:800px}.dismiss-btn{color:#1456e0}@media only screen and (max-width:600px){#next-button{display:inline-block}.next-control{text-align:center}.tree-view-container-footer{padding-bottom:1rem}.permissions-content{width:auto}.cards-container{display:flex;flex-wrap:nowrap;max-width:100%;overflow-x:auto}}@media only screen and (min-width:601px){.permissions-locations{display:flex;justify-content:space-between;align-items:center;width:100%}.controls{display:flex;justify-content:space-between;align-items:center}}@media only screen and (max-width:600px){.cards-container{flex-wrap:unset;overflow-x:auto}.tree-role-locations{margin-top:-3px!important}.tree-role-locations-count,.tree-role-locations-count-active{font-size:.875rem!important}}`,Gr={ToggleActiveCard:"toggle-active-card"};let Se=class extends I{constructor(){super(...arguments),this.dataForAccounts=[],this.isRoles=!1}dispatchToggleActiveCard(e){this.dispatchEvent(new CustomEvent(Gr.ToggleActiveCard,{detail:{accountId:e},bubbles:!0,composed:!0}))}renderCards(){return this.dataForAccounts.map(e=>{if(this.isRoles){const o=e.rolesData.filter(i=>i.role.removed===!1).map(i=>i.role.name);return c` <ix-card data-testid="ix-card-${e.accountId}" .itemId="${e.accountId}" .name="${e.accountName}" .names="${o}" .type="${"roles"}" ?isActive="${this.selectedAccountId===e.accountId}" @toggle-card="${i=>{this.dispatchToggleActiveCard(i.detail)}}"></ix-card> `}const t=le.map(o=>o.text);return c` <ix-card data-testid="ix-card-${e.accountId}" .itemId="${e.accountId}" .name="${e.accountName}" .names="${t}" .type="${"flags"}" .isActive="${this.selectedAccountId===e.accountId}" @toggle-card="${o=>{this.dispatchToggleActiveCard(o.detail)}}"></ix-card> `})}render(){return c`<div class="cards-container">${this.renderCards()}</div> `}};Se.styles=[Vt,_,$e,ge],r([d({type:Array})],Se.prototype,"dataForAccounts",void 0),r([d({type:String})],Se.prototype,"selectedAccountId",void 0),r([d({type:Boolean})],Se.prototype,"isRoles",void 0),Se=r([A("account-tabbing-card")],Se);class ut{constructor(){this.updates=[]}get nodeUpdates(){return this.updates}update(t){this.updates=[];let o=[];t&&(o=on(t));for(const i of o)i.originalCheckedStatus!==i.checked&&this.updates.push(i)}}class Ti{constructor(){this._nodeUpdates=[]}create(t){if(this._nodeUpdates.find(i=>i.key===t))return;const o=new ut;this._nodeUpdates.push({key:t,item:o})}update(t,o){const i=this._nodeUpdates.find(n=>n.key===t);i==null||i.item.update(o)}get nodeUpdates(){return this._nodeUpdates}get isDirty(){let t=0;return this._nodeUpdates.forEach(o=>{t+=o.item.nodeUpdates.length}),t>0}get nodeChanges(){const t=[];return this._nodeUpdates.forEach(o=>{o.item.nodeUpdates.length>0&&o.item.nodeUpdates.forEach(i=>{const n=t.find(a=>a.key===o.key);n?n.items.push(i):t.push({key:o.key,items:[i]})})}),t}reset(){this._nodeUpdates=[]}remove(t){this._nodeUpdates=this._nodeUpdates.filter(o=>o.key!==t)}}function jt(e,t){var o,i;const n=[],a=t.toLowerCase().trim();if(a.length<2||((!((o=e.label)===null||o===void 0)&&o.toLowerCase().includes(a)||!((i=e.secondaryLabel)===null||i===void 0)&&i.toLowerCase().includes(a))&&n.push(e),!e.children))return n;for(const s of e.children){const l=jt(s,t);n.push(...l)}return n}function Ii(e,t,o){if(e==="previous"){const i=o.indexOf(t)-1,n=i<0?o.length-1:i;return o[n]}if(e==="next"){const i=o.indexOf(t)+1,n=i>=o.length?0:i;return o[n]}}function Ei(e,t){const o=[];for(const i of t){o.push(i.id),i.selected=!0;let n=Ge(e,i.id);for(;n!=null&&n.parentId;)n=Ge(e,n.parentId),n&&(n.expanded=!0)}return o}function Gt(e){e.selected=!1,e.children&&e.children.forEach(t=>{Gt(t)})}class Jr{constructor(){this._dataCollection=new Map}capture(t){var o;let i;const n=this._dataCollection.get(t);return n&&(i=Mo(n.data),!((o=n.options)===null||o===void 0)&&o.consume&&this._dataCollection.delete(t)),i}emit(t,o){o.options={lock:!1,consume:!0,...o.options},this._store(t,o)}lock(t){const o=this._dataCollection.get(t);o&&(o.options.lock=!0)}remove(t){this._dataCollection.delete(t)}_store(t,o){var i;const n=this._dataCollection.get(t);return n&&!((i=n.options)===null||i===void 0)&&i.lock?!1:(this._dataCollection.set(t,Mo(o)),!0)}}const ht=new Jr;class Kr extends Ee{}const Jt=new Kr({});let M=class extends I{constructor(){super(...arguments),this.searching=!1,this.disableTree=!1,this.readonly=!1,this.activeRoleId="",this.searchResultCount=0,this.searchResultIndex=0,this.selectedIds=[],this.loadingNodes=!1,this.assignmentUpdateManagers=[],this.searchText="",this.onSearchTextChange=ao(async e=>{var t;this.searchText=e.detail.searchText;const o=(t=this.assignment)===null||t===void 0?void 0:t.rootNode;Gt(o);const i=jt(o,this.searchText);i.length&&Je(o),this.searchResultCount=i.length;const n=Ei(o,i);[this.selectedId]=n,this.selectedIds=[...n],this.searchResultIndex=n.indexOf(this.selectedId)+1,this.requestUpdate()},500)}updated(e){super.updated(e),e.has("activeRoleId")&&this.handleNonLocationTrees()}disconnectedCallback(){super.disconnectedCallback(),this.emitUpdates()}emitUpdates(){var e,t;const o=Jt.get(),i=(e=this.assignmentUpdateManagers.find(l=>l.accountId===o.accountNumber))===null||e===void 0?void 0:e.nodeManager,n=i==null?void 0:i.nodeUpdates.flatMap(l=>l.item.nodeUpdates);if(!(o!=null&&o.accountNumber)&&!i)return;const a={data:n||[],options:{consume:!1}},s=`${o.accountNumber}:${(t=this.contact)===null||t===void 0?void 0:t.id}`;ht.emit(s,a)}dispatchCheckToggleEvent(e){this.dispatchEvent(new CustomEvent(S.CheckToggle,{detail:{message:{updates:structuredClone(e)}}}))}handleNonLocationTrees(){const e=ve.get().find(n=>{var a;return n.id===((a=this.assignment)===null||a===void 0?void 0:a.role)});if(!e||!this.assignment)return;if(!e.permissions.every(n=>n.isNonLocation)){this.disableTree=!1;return}const t=this.assignment.rootNode.children[0];t.checked=!0,this.disableTree=!0,be(t,this.assignment.rootNode);const o=this.getOrCreateNodeManager();if(!o)return;const i=o.nodeUpdates.find(n=>{var a;return n.key===((a=this.assignment)===null||a===void 0?void 0:a.role)});i&&(i.item.update(this.assignment.rootNode),this.dispatchCheckToggleEvent(o.nodeChanges))}onTreeCheckToggle(e){var t;try{const o=this.getOrCreateNodeManager();if(!o)throw new Error("Node manager is missing.");const i=o.nodeUpdates.find(n=>{var a;return n.key===((a=this.assignment)===null||a===void 0?void 0:a.role)});i&&i.item.update(e.detail.message.rootNode),!((t=this.assignment)===null||t===void 0)&&t.rootNode&&(this.assignment.rootNode=structuredClone(e.detail.message.rootNode)),this.dispatchCheckToggleEvent(o.nodeChanges)}catch(o){g.handleError(o,"Failed to toggle tree check.")}}async onTreeExpandToggle(e){var t,o;try{const i=e.detail.message.update,n=e.detail.message.node;if(n.children&&n.children.length)return;if(!this.contact.id||!this.accountNumber)throw new Error("Contact ID or Account Number is missing.");n.loading=!0;const a=await br((t=this.assignment)===null||t===void 0?void 0:t.role,this.contact.id,this.accountNumber,n.id,void 0,!0,pe((o=this.contact)===null||o===void 0?void 0:o.email));n.loading=!1,a[0].inventoryItems&&a[0].inventoryItems.length&&(a[0].inventoryItems.forEach(s=>{he(s,n),n.originalCheckedStatus!==n.checked&&be(n,n)}),i())}catch(i){g.handleError(i,"Failed to expand tree node.")}}destroyRoleManager(){const e=this.assignmentUpdateManagers.find(t=>t.accountId===this.accountNumber);e&&(e.nodeManager.reset(),this.assignmentUpdateManagers=this.assignmentUpdateManagers.filter(t=>t.accountId!==this.accountNumber))}getOrCreateNodeManager(){var e;let t;try{if(!this.accountNumber)throw new Error("Account number is missing.");t=(e=this.assignmentUpdateManagers.find(o=>o.accountId===this.accountNumber))===null||e===void 0?void 0:e.nodeManager,t||(this.assignmentUpdateManagers.push({accountId:this.accountNumber,nodeManager:new Ti}),t=this.assignmentUpdateManagers.find(o=>o.accountId===this.accountNumber).nodeManager)}catch(o){g.handleError(o,"Failed to get or create node manager.")}return t}disableCheckboxes(){return this.readonly?!0:this.disableTree}onSearchNavigation(e){if(!this.selectedIds.length)return;const t=Ii(e.detail.direction,this.selectedId,this.selectedIds);this.selectedId=t!=null?t:this.selectedId,this.searchResultIndex=this.selectedIds.indexOf(this.selectedId)+1,this.requestUpdate()}render(){var e;const t=this.getOrCreateNodeManager();return t&&this.assignment&&t.create(this.assignment.role),c` <div class="flex items-center py-[0.75rem]"> <h1 class="dlr-text-heading">Portal Access</h1> <ix-progress .linear="${!1}" .indeterminate="${!0}" style="visibility:${this.searching?"visible":"hidden"}"></ix-progress> </div> <ix-generic-tree data-testid="location-treeview" .rootNode="${(e=this.assignment)===null||e===void 0?void 0:e.rootNode}" .searchText="${this.searchText}" .selectedId="${this.selectedId}" .showCheckboxes="${!0}" .disableCheckboxes="${this.disableCheckboxes()}" @search-text-change="${this.onSearchTextChange}" @search-navigation="${o=>this.onSearchNavigation(o)}" @check-toggle="${o=>this.onTreeCheckToggle(o)}" @expand-toggle="${o=>this.onTreeExpandToggle(o)}" searchEnabled .searchResultCount="${this.searchResultCount}" .searchResultIndex="${this.searchResultIndex}" searchPlaceholder="Search by Site or Asset Name.."></ix-generic-tree> `}};M.styles=[_,$`:host{--md-circular-progress-size:28px}`],r([d({type:Object,attribute:!1})],M.prototype,"assignment",void 0),r([d({type:Object})],M.prototype,"contact",void 0),r([d({type:String})],M.prototype,"accountNumber",void 0),r([d({type:String})],M.prototype,"selectedId",void 0),r([d({type:Boolean})],M.prototype,"searching",void 0),r([d({type:Boolean})],M.prototype,"disableTree",void 0),r([d({type:Boolean})],M.prototype,"readonly",void 0),r([d({type:String})],M.prototype,"activeRoleId",void 0),r([m()],M.prototype,"searchResultCount",void 0),r([m()],M.prototype,"searchResultIndex",void 0),r([m()],M.prototype,"selectedIds",void 0),r([m()],M.prototype,"loadingNodes",void 0),r([m()],M.prototype,"assignmentUpdateManagers",void 0),r([m()],M.prototype,"searchText",void 0),M=r([A("user-details-assignments")],M);let O=class extends I{constructor(){super(...arguments),this.dataForAccounts=[],this.permissions=[],this._dataForAccounts=[],this.showPermissionsDialog=!1,this.removeRoleDialogOpen=!1,this._nextButtonEnabled=!1}connectedCallback(){super.connectedCallback(),this._dataForAccounts=this.dataForAccounts,this._selectedAccountId=this.selectedAccountId,this._selectedRoleId=this.selectedRoleId,this.validateStep(),this.dispatchValidateStepEvent(),this.setInitialRole()}get noOfLocations(){var e;return to((e=this.selectedRoleData)===null||e===void 0?void 0:e.genericTreeView)}get canAddRolesDisabled(){return this.unAvailableRoles&&this.unAvailableRoles.length<=0}get availableRoles(){const e=this._dataForAccounts.find(o=>o.accountId===this._selectedAccountId),t=e==null?void 0:e.rolesData.filter(o=>o.role.removed===!1);return t==null?void 0:t.flatMap(o=>o.role)}get unAvailableRoles(){const e=this._dataForAccounts.find(o=>o.accountId===this._selectedAccountId),t=e==null?void 0:e.rolesData.filter(o=>o.role.removed===!0);return t==null?void 0:t.flatMap(o=>o.role)}get roles(){const e=this._dataForAccounts.find(t=>t.accountId===this._selectedAccountId);return e==null?void 0:e.rolesData.flatMap(t=>t.role)}get selectedAccount(){return this._dataForAccounts.find(e=>e.accountId===this._selectedAccountId)}get selectedRole(){return this.selectedAccount.rolesData.find(e=>e.role.id===this._selectedRoleId).role}get selectedRolePermissions(){var e,t;return(t=(e=this._dataForAccounts.find(o=>o.accountId===this._selectedAccountId))===null||e===void 0?void 0:e.rolesData.find(o=>o.role.id===this._selectedRoleId))===null||t===void 0?void 0:t.role.permissions}get selectedRoleData(){return this.selectedAccount.rolesData.find(e=>e.role.id===this._selectedRoleId)}toggleActiveCard(e){var t;this._selectedAccountId=e,this._selectedRoleId=(t=this._dataForAccounts.find(o=>o.accountId===e))===null||t===void 0?void 0:t.rolesData[0].role.id,this._dataForAccounts.forEach(o=>{o.accountId!==e?o.active=!1:o.active=!0}),this.roleTabComponent.setActiveRole(this._selectedRoleId),this.setInitialRole(),this.requestUpdate()}setInitialRole(){this.availableRoles&&this.availableRoles.length>0&&(this._selectedRoleId=this.availableRoles[0].id)}dispatchOpenAddAccountRole(){this.addRoleDialog.handleOpenDialog()}dispatchTabControl(e){this._selectedRoleId=this.roles[e].id,this.roleTabComponent.setActiveRole(this._selectedRoleId)}addRole(e){var t;const o=this.selectedAccount.rolesData.findIndex(i=>i.role.id===e);if(this.selectedAccount.rolesData[o].role.permissions.every(i=>i.isNonLocation)){const i=this.selectedAccount.rolesData[o].genericTreeView;if(!(!((t=i==null?void 0:i.children)===null||t===void 0)&&t.length))return;const n=i.children[0];n.checked=!0,be(n,i),this.selectedAccount.rolesData[o].locations.push(n)}else this.selectedAccount.rolesData[o].locations=[];this.selectedAccount.rolesData[o].role.removed=!1,this.requestUpdate(),this.dispatchTabControl(o),this.addRoleDialog.handleCancelChanges()}dispatchRemoveRoleEvent(){const e=this.roles.findIndex(o=>o.id===this._selectedRoleId);this.roles[e].removed=!0;const t=this.selectedAccount.rolesData.findIndex(o=>o.role.id===this._selectedRoleId);this.selectedAccount.rolesData[t].locations=[],this.selectedAccount.rolesData[t].role.removed=!0,this.selectedAccount.rolesData[t].genericTreeView&&Nt(this.selectedAccount.rolesData[t].genericTreeView),this.validateStep(),this.setInitialRole(),this.requestUpdate()}renderTree(){const e=this._dataForAccounts.find(n=>n.accountId===this._selectedAccountId),t=e==null?void 0:e.rolesData.find(n=>n.role.id===this._selectedRoleId);if(!t)return y;const o={role:t.role.id,rootNode:t.genericTreeView},i=n=>{this.requestUpdate();const{updates:a}=n.detail.message,s=a.find(l=>l.key===t.role.id);s!=null&&s.items?t.locations=s.items.filter(l=>l.checked):t.locations=[],this.validateStep(),this.dispatchUpdateDFAEvent(),this.dispatchNextButtonToggleEvent()};if(o&&o.rootNode){const n=t==null?void 0:t.role.permissions.every(a=>a.isNonLocation);return c`<user-details-assignments .assignment="${o}" .contact="${this.contact}" .accountNumber="${e==null?void 0:e.accountId}" @check-toggle="${i}" ?disableTree="${n}"></user-details-assignments>`}return y}validateStep(){let e=!0;for(const t of this._dataForAccounts)if(!t.rolesData.filter(o=>o.role.removed===!1).every(o=>o.locations.length)){e=!1;break}this._nextButtonEnabled=e}renderRoles(){var e,t;return c` <user-details-tab-roles id="role-data-element" .assignedRoles="${this.availableRoles}" .activeRoleId="${(e=this._selectedRoleId)!==null&&e!==void 0?e:""}" .canRemoveRoles="${!0}" .removeRolesDisabled="${((t=this.availableRoles)===null||t===void 0?void 0:t.length)<=1}" .canAddRoles="${!0}" .addRolesDisabled="${this.canAddRolesDisabled}" @role-select="${o=>this._selectedRoleId=o.detail.roleId}" @open-role-menu="${()=>this.dispatchOpenAddAccountRole()}" @open-remove-role-menu="${()=>this.removeRoleDialogOpen=!0}"></user-details-tab-roles> `}renderAddAccountRoleConfirmation(){var e;return c`<add-account-role id="add-role-dialog" .contact="${this.contact}" .account="${xi((e=this.selectedAccount)===null||e===void 0?void 0:e.accountId)||""}" .assignedRoles="${this.availableRoles}" .roles="${this.roles}" @add-role="${t=>this.addRole(t.detail.roleId)}"> </add-account-role>`}renderRemoveRoleConfirmation(){return c`<changes-confirmation id="remove-role-dialog" ?isOpen="${this.removeRoleDialogOpen}" .headerText="${"Are you sure you want to remove this role?"}" .bodyText="${"The user will no longer be able to perform the permissions of this role for this account."}" .confirmationButtonText="${"Remove Role"}" @confirm="${()=>{this.dispatchRemoveRoleEvent(),this.validateStep(),this.removeRoleDialogOpen=!1}}" @cancel="${()=>this.removeRoleDialogOpen=!1}"> </changes-confirmation>`}renderControls(){return c` <div class="controls"> <div class="flex justify-between py-2 items-center permissions-locations"> ${this.renderViewPermissionsButton()} <div class="flex items-center">${this.renderLocationsCount()}</div> </div> <div class="next-control"> <ix-button id="next-button" type="submit" has-icon trailing-icon ?disabled="${!this._nextButtonEnabled}" @click="${()=>{this.dispatchNextStepEvent()}}" data-testid="step-four-next-button"> Next <md-icon slot="icon">east</md-icon> </ix-button> </div> </div> `}renderPermissionsDialog(){var e,t;return c` <ix-dialog ?open="${this.showPermissionsDialog}" @close="${()=>this.showPermissionsDialog=!1}"> <div class="dlr-text-heading" slot="headline">${this.selectedRole.name}</div> <div class="permissions-content" slot="content"> <user-details-permission inPermissionsDialog .permissionData="${(t=Mt((e=this.selectedRolePermissions)!==null&&e!==void 0?e:[]))!==null&&t!==void 0?t:[]}"> </user-details-permission> </div> <div class="dialog-actions" slot="actions"> <ix-button appearance="text" @click="${this.togglePermissionsDialog}" slot="secondary"><span class="dismiss-btn">Dismiss</span></ix-button> </div> </ix-dialog> `}togglePermissionsDialog(){this.showPermissionsDialog=!this.showPermissionsDialog}renderViewPermissionsButton(){return c` <div class="tree-view-permissions"> <ix-button class="temp-button view-permissions" appearance="text" @click="${this.togglePermissionsDialog}"> View Permissions </ix-button> </div> `}renderLocationsCount(){const e=`dlr-text-default font-bold uppercase ${this.noOfLocations?"tree-role-locations-count-active":"tree-role-locations-count"}`;return c`<div class="tree-role-locations"> <span class="${e}"> ${this.noOfLocations?c`${this.noOfLocations} locations`:c`Select Locations`} </span> </div>`}dispatchNextStepEvent(){this.dispatchEvent(new CustomEvent(w.NextStep,{bubbles:!0,composed:!0}))}dispatchNextButtonToggleEvent(){this.dispatchEvent(new CustomEvent(w.NextButtonToggle,{detail:this._nextButtonEnabled,bubbles:!0,composed:!0}))}dispatchValidateStepEvent(){this.dispatchEvent(new CustomEvent(w.ValidateStep,{detail:this._nextButtonEnabled,bubbles:!0,composed:!0}))}dispatchUpdateDFAEvent(){const e=new CustomEvent(w.UpdateDFA,{detail:{dataForAccounts:this._dataForAccounts},bubbles:!0,composed:!0});this.dispatchEvent(e)}renderAccountTabbingCard(){return c` <account-tabbing-card data-testid="step-four-account-cards" isRoles .dataForAccounts="${this._dataForAccounts}" .selectedAccountId="${this._selectedAccountId}" @toggle-active-card="${e=>this.toggleActiveCard(e.detail.accountId)}"> </account-tabbing-card> `}render(){return c` <div class="wizard-step-content overflow-y-auto h-full max-h-screen md:p-1"> ${this.renderAccountTabbingCard()} <div class="tree-view-container-content">${this.renderRoles()}</div> <div class="controls-container">${this.renderControls()}</div> <div class="tree-view-container-footer">${this.renderTree()}</div> </div> ${this.renderAddAccountRoleConfirmation()} ${this.renderRemoveRoleConfirmation()} ${this.renderPermissionsDialog()} `}};O.styles=[Vt,_,ge],r([d({type:Array})],O.prototype,"dataForAccounts",void 0),r([d({type:Array})],O.prototype,"permissions",void 0),r([d({type:String})],O.prototype,"selectedAccountId",void 0),r([d({type:String})],O.prototype,"selectedRoleId",void 0),r([d({type:Object})],O.prototype,"contact",void 0),r([m()],O.prototype,"_dataForAccounts",void 0),r([m()],O.prototype,"_selectedAccountId",void 0),r([m()],O.prototype,"_selectedRoleId",void 0),r([m()],O.prototype,"showPermissionsDialog",void 0),r([m()],O.prototype,"removeRoleDialogOpen",void 0),r([m()],O.prototype,"_nextButtonEnabled",void 0),r([D("#add-role-dialog")],O.prototype,"addRoleDialog",void 0),r([D("#role-data-element")],O.prototype,"roleTabComponent",void 0),r([D("user-details-assignments")],O.prototype,"assignmentTreeComponent",void 0),O=r([A("create-user-step-four")],O);const Ri=$`ix-dialog{--md-dialog-container-color:#fff}ix-icon-button{--md-sys-color-on-surface-variant:var(--md-sys-color-primary)}ix-select{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd;--md-menu-container-color:#fff}ix-select.thick{--md-menu-container-shape:10px}ix-select.slim{--md-outlined-field-bottom-space:2px;--md-outlined-field-top-space:2px}ix-button{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd}ix-button .disabled{color:var(--md-sys-text-color-disabled)}.btn_primary{--md-filled-button-container-color:var(--md-sys-color-primary)}.btn_primary ix-icon{color:var(--md-sys-color-on-primary)}.btn_secondary{--md-filled-button-container-color:var(--md-sys-color-secondary)}.btn_secondary ix-icon{color:var(--md-sys-color-on-secondary)}.btn_tertiary{--md-filled-button-container-color:var(--md-sys-color-tertiary)}.btn_tertiary ix-icon{color:var(--md-sys-color-on-tertiary)}.btn_danger{--md-filled-button-container-color:var(--md-sys-color-error)}.btn_danger ix-icon{color:var(--md-sys-color-on-error)}.icon-btn_primary ix-icon{color:var(--md-sys-color-primary)}.icon-btn_secondary ix-icon{color:var(--md-sys-color-secondary)}.icon-btn_tertiary ix-icon{color:var(--md-sys-color-tertiary)}.icon-btn_danger ix-icon{color:var(--md-sys-color-error)}ix-icon.icon-lg{--ix-icon-font-size:32px}.dialog-form{min-width:500px;display:flex;flex-direction:column;justify-content:space-between;padding:8px 24px 20px}.dialog-form .textfield{width:100%}.dialog-form.sm{min-width:560px}.dialog-form__textbox{padding-top:1rem}.dialog-actions{display:flex;justify-content:flex-end;padding:8px 15px 8px 20px}@media only screen and (min-width:5px) and (max-width:600px){ix-dialog{--md-dialog-container-shape:6px}}@media only screen and (min-width:601px){ix-dialog{--md-dialog-container-shape:3px}}ix-icon-button{--md-sys-color-on-surface-variant:black}`;class de{}de.ACCORDION=e=>`user-flags-accordion-${e}`,de.COMPONENT=e=>`user-flags-${e}`,de.TREE=e=>`user-flags-tree-${e}`,de.ASSIGNMENT_COUNT=e=>`user-flags-assignment-count-${e}`,de.SEARCH_BOX=()=>"search-box";let L=class extends I{constructor(){super(...arguments),this.searchEnabled=!1,this.showCheckboxes=!1,this.disableCheckboxes=!1,this.filledIcons=!1,this.searching=!1,this.searchText="",this.selectedIds=[],this.searchResultCount=0,this.searchResultIndex=0,this.onSearchTextChange=ao(async e=>{Gt(this.flagTree.rootNode),this.searchText=e.detail.searchText;const t=jt(this.flagTree.rootNode,e.detail.searchText);t.length&&Je(this.flagTree.rootNode),this.searchResultCount=t.length;const o=Ei(this.flagTree.rootNode,t);[this.selectedId]=o,this.selectedIds=[...o],this.searchResultIndex=o.indexOf(this.selectedId)+1,this.requestUpdate()},500)}onTreeCheckToggle(e){var t;this.flagTree.updateService&&this.flagTree.updateService.update(e.detail.message.rootNode);const o=this.flagUpdateManager.nodeUpdates.find(i=>i.key===this.flagTree.label);o&&o.item.update(e.detail.message.rootNode),this.dispatchEvent(new CustomEvent(S.CheckToggle,{detail:{message:{...e.detail.message,flagLabel:this.flagTree.label,updates:this.flagUpdateManager.nodeChanges,rootNode:(t=this.flagTree.updateService)===null||t===void 0?void 0:t.nodeUpdates[0]}}})),this.flagTree.rootNode=structuredClone(e.detail.message.rootNode),this.requestUpdate("flagTree")}onSearchNavigation(e){if(!this.selectedIds.length)return;const t=Ii(e.detail.direction,this.selectedId,this.selectedIds);this.selectedId=t!=null?t:this.selectedId,this.searchResultIndex=this.selectedIds.indexOf(this.selectedId)+1,this.requestUpdate()}render(){var e;return c` <ix-generic-tree data-testid="${de.TREE(this.flagTree.label)}" ?showCheckboxes="${this.showCheckboxes}" ?filledIcons="${this.filledIcons}" ?disableCheckboxes="${this.disableCheckboxes}" .rootNode="${this.flagTree.rootNode}" .selectedId="${this.selectedId}" .searchText="${this.searchText}" @check-toggle="${t=>this.onTreeCheckToggle(t)}" @search-text-change="${t=>this.onSearchTextChange(t)}" @search-navigation="${t=>this.onSearchNavigation(t)}" ?searchEnabled="${this.searchEnabled&&(((e=this.flagTree.rootNode.children)===null||e===void 0?void 0:e.length)||0)>0}" .searchResultCount="${this.searchResultCount}" .searchResultIndex="${this.searchResultIndex}" searchPlaceholder="Search by Site or Asset Name.."></ix-generic-tree> `}};L.styles=[Ri,_],r([d({type:Object,attribute:!1})],L.prototype,"flagTree",void 0),r([d({type:Boolean})],L.prototype,"searchEnabled",void 0),r([d({type:Boolean})],L.prototype,"showCheckboxes",void 0),r([d({type:Boolean})],L.prototype,"disableCheckboxes",void 0),r([d({type:Boolean})],L.prototype,"filledIcons",void 0),r([d({type:Boolean})],L.prototype,"searching",void 0),r([d({type:String})],L.prototype,"selectedId",void 0),r([d({type:Object})],L.prototype,"flagUpdateManager",void 0),r([m()],L.prototype,"searchText",void 0),r([m()],L.prototype,"selectedIds",void 0),r([m()],L.prototype,"searchResultCount",void 0),r([m()],L.prototype,"searchResultIndex",void 0),L=r([A("user-flag")],L);let Q=class extends I{constructor(){super(...arguments),this.searchEnabled=!1,this.showCheckboxes=!1,this.disableCheckboxes=!1,this.filledIcons=!1,this.searching=!1,this.flags=[],this.flagUpdateManager=new Ti,this._defaultUpdates=[]}reset(){this._defaultUpdates=[],this.flagUpdateManager.reset()}onAccordionToggle(e){!e.detail.isOpen||!this.flags.length||(this.flags.forEach(t=>{t.label!==e.detail.accordionId?t.isOpen=!1:t.isOpen=!0}),this.requestUpdate())}connectedCallback(){var e;if(super.connectedCallback(),this._defaultUpdates=[],!this.contact)return;const t=Jt.get();if(!(!((e=this._defaultUpdates)===null||e===void 0)&&e.length)&&t!=null&&t.accountNumber){const o=`${t.accountNumber}:${this.contact.id}`,i=ht.capture(o);i&&ht.lock(o),this._defaultUpdates=i}}disconnectedCallback(){this.reset()}onTreeCheckToggle(e){this.dispatchEvent(new CustomEvent(S.CheckToggle,{detail:{message:{...e.detail.message,flagLabel:e.detail.message.flagLabel,updates:e.detail.message.updates,rootNode:e.detail.message.rootNode}}}))}getUserFlagAssignmentCount(e){var t;const o=(t=e.rootNode.children)===null||t===void 0?void 0:t.at(0);o&&(o.checkedChildrenCount=to(o),this.renderAssignmentCount(e))}renderAssignmentCount(e){var t;const o=(t=e.rootNode.children)===null||t===void 0?void 0:t.at(0);return o!=null&&o.checkedChildrenCount?c` <span style="color:#53657a;margin-left:8px" data-testid="${de.ASSIGNMENT_COUNT(e.label)}">${o.checkedChildrenCount}</span> `:y}renderUserFlag(e){var t,o;this.flagUpdateManager.create(e.label);const i=this.flagUpdateManager.nodeUpdates.find(n=>n.key===e.label);return!((t=this._defaultUpdates)===null||t===void 0)&&t.length&&!e.defaultsApplied&&(this._defaultUpdates.forEach(n=>{const a=Ge(e.rootNode,n.id);a&&(a.checked=!0,be(a,e.rootNode),i==null||i.item.update(e.rootNode))}),e.defaultsApplied=!0),this.getUserFlagAssignmentCount(e),c` <div class="mb-2"> <ix-accordion ?isOpen="${e.isOpen}" .accordionId="${e.label}" @toggle="${this.onAccordionToggle}" data-testid="${de.ACCORDION(e.label)}"> <p slot="title" class="m-0 pl-1"> ${e.label} ${this.renderAssignmentCount(e)} </p> <div style="padding-left:30px"> <div class="flex items-center"> <p class="dlr-text-small"> ${((o=le.find(n=>n.text===e.label))===null||o===void 0?void 0:o.desc)||""} </p> <ix-progress .linear="${!1}" .indeterminate="${!0}" style="visibility:${this.searching?"visible":"hidden"}"></ix-progress> </div> <user-flag data-testid="${de.COMPONENT(e.label)}" ?showCheckboxes="${this.showCheckboxes}" ?filledIcons="${this.filledIcons}" ?disableCheckboxes="${this.disableCheckboxes}" ?searchEnabled="${this.searchEnabled}" .flagTree="${e}" .flagUpdateManager="${this.flagUpdateManager}" @check-toggle="${n=>this.onTreeCheckToggle(n)}"></user-flag> </div> </ix-accordion> </div> `}render(){return c` ${this.flags.map(e=>this.renderUserFlag(e))}`}};Q.styles=[Ri,_],r([d({type:Boolean})],Q.prototype,"searchEnabled",void 0),r([d({type:Boolean})],Q.prototype,"showCheckboxes",void 0),r([d({type:Boolean})],Q.prototype,"disableCheckboxes",void 0),r([d({type:Boolean})],Q.prototype,"filledIcons",void 0),r([d({type:Boolean})],Q.prototype,"searching",void 0),r([d({type:Array,attribute:!1})],Q.prototype,"flags",void 0),r([d({type:Object})],Q.prototype,"contact",void 0),r([m()],Q.prototype,"flagUpdateManager",void 0),r([m()],Q.prototype,"_defaultUpdates",void 0),Q=r([A("user-flags")],Q);const Si=$`ix-dialog{--md-dialog-container-color:#fff}ix-icon-button{--md-sys-color-on-surface-variant:var(--md-sys-color-primary)}ix-select{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd;--md-menu-container-color:#fff}ix-select.thick{--md-menu-container-shape:10px}ix-select.slim{--md-outlined-field-bottom-space:2px;--md-outlined-field-top-space:2px}ix-button{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd}ix-button .disabled{color:var(--md-sys-text-color-disabled)}.btn_primary{--md-filled-button-container-color:var(--md-sys-color-primary)}.btn_primary ix-icon{color:var(--md-sys-color-on-primary)}.btn_secondary{--md-filled-button-container-color:var(--md-sys-color-secondary)}.btn_secondary ix-icon{color:var(--md-sys-color-on-secondary)}.btn_tertiary{--md-filled-button-container-color:var(--md-sys-color-tertiary)}.btn_tertiary ix-icon{color:var(--md-sys-color-on-tertiary)}.btn_danger{--md-filled-button-container-color:var(--md-sys-color-error)}.btn_danger ix-icon{color:var(--md-sys-color-on-error)}.icon-btn_primary ix-icon{color:var(--md-sys-color-primary)}.icon-btn_secondary ix-icon{color:var(--md-sys-color-secondary)}.icon-btn_tertiary ix-icon{color:var(--md-sys-color-tertiary)}.icon-btn_danger ix-icon{color:var(--md-sys-color-error)}ix-icon.icon-lg{--ix-icon-font-size:32px}.dialog-form{min-width:500px;display:flex;flex-direction:column;justify-content:space-between;padding:8px 24px 20px}.dialog-form .textfield{width:100%}.dialog-form.sm{min-width:560px}.dialog-form__textbox{padding-top:1rem}.dialog-actions{display:flex;justify-content:flex-end;padding:8px 15px 8px 20px}@media only screen and (min-width:5px) and (max-width:600px){ix-dialog{--md-dialog-container-shape:6px}}@media only screen and (min-width:601px){ix-dialog{--md-dialog-container-shape:3px}}.user-details-header-text{margin-bottom:10px}.user-details-row{display:grid;grid-template-columns:1fr 1fr}.row-label{color:rgba(9,34,65,.7);word-break:break-word;width:192px}.row-value{color:#092241;overflow-wrap:anywhere}.user-details-body{display:flex;gap:10px;flex-direction:column}.arrow-forward-icon{padding-left:6px}.access-summary-header,.user-details-header{display:flex;flex-direction:row;align-items:center;justify-content:space-between}ix-divider{margin-top:30px;margin-bottom:30px}.user-flag-information{margin-left:5px}.user-flag-learn-text{padding-bottom:20px}.user-flag-learn-text-link{color:#1456e0}.user-flag-evacuation{vertical-align:top;line-height:18px}.evacuation-label{padding-left:8px;vertical-align:top}.evacuation-text{text-align:justify;padding-left:5px;padding-top:10px;padding-bottom:30px;color:#092241;margin-right:40px}.flags-description ix-button{margin-top:.5rem;width:112px}ix-button{font-family:var(--root-secondary-font)}@media only screen and (max-width:600px){.flags-description{flex-direction:column-reverse;text-align:center}.flags-description p{text-align:left}.evacuation-text{margin-right:0}.flags-description ix-button{display:block}.subheading-container{flex-direction:column;align-items:start;gap:.75rem}.submit-btn{width:100%}.user-details-row{grid-template-columns:1fr}.step-five-next-container{display:flex;justify-content:center}}ix-phone-number{--ix-phone-number-font-size:16px;--ix-phone-number-text-color:#092241}`;let ne=class extends I{constructor(){super(...arguments),this.dataForAccounts=[],this.evacAssistanceRequired=!1,this._dataForAccounts=[]}get selectedAccount(){return this._dataForAccounts.find(e=>e.accountId===this._selectedAccountId)}connectedCallback(){super.connectedCallback(),this._dataForAccounts=this.dataForAccounts,this._selectedAccountId=this.selectedAccountId}setSelectedFlag(e){this._selectedFlagId=e}setInitialFlag(){this._selectedFlagId=le[0].key}toggleActiveCard(e){this._selectedAccountId=e;const t=this._dataForAccounts.find(o=>o.accountId===e);t&&t.genericFlagsData&&(this._selectedFlagId=Ft(t.genericFlagsData[0].label)),this.setSelectedFlag(this._selectedFlagId),this.setInitialFlag(),this.requestUpdate()}dispatchNextStepEvent(){this.dispatchEvent(new CustomEvent(w.NextStep,{bubbles:!0,composed:!0}))}renderAccountTabbingCard(){return c` <account-tabbing-card data-testid="step-five-account-cards" .dataForAccounts="${this._dataForAccounts}" .selectedAccountId="${this._selectedAccountId}" @toggle-active-card="${e=>this.toggleActiveCard(e.detail.accountId)}"> </account-tabbing-card> `}renderElevatedNextButton(){return c` <div class="flex justify-between flags-description"> <p style="max-width:550px" class="dlr-text-caption evacuation-text"> The locations chosen for this account's Portal access will automatically default selections for the user flags listed below. You have the flexibility to modify these selections by deselecting specific locations and choosing others as needed. </p> <div class="step-five-next-container"> <ix-button type="submit" has-icon trailing-icon @click="${this.dispatchNextStepEvent}" data-testid="step-five-next-button"> <span class="uppercase font-bold tracking-wider">Next</span> <md-icon slot="icon">east</md-icon> </ix-button> </div> </div> `}renderUserFlags(){var e,t;const o=i=>{var n;const a=(n=structuredClone(i.detail.message.updates))!==null&&n!==void 0?n:[];this.selectedAccount&&a.forEach(s=>{const l=this.selectedAccount.flagData.findIndex(p=>p.key===s.key);l>-1?this.selectedAccount.flagData[l]=structuredClone(s):this.selectedAccount.flagData.push(s)}),this.dispatchEvent(new CustomEvent(w.UpdateFlags,{bubbles:!0}))};return c` <user-flags class="grid grid-cols-1 gap-3" showCheckboxes filledIcons searchEnabled .flags="${(t=(e=this.selectedAccount)===null||e===void 0?void 0:e.genericFlagsData)!==null&&t!==void 0?t:[]}" @check-toggle="${o}" data-testid="step-five-user-flags"></user-flags> `}render(){return c` <div class="wizard-step-content"> ${this.renderAccountTabbingCard()} ${this.renderElevatedNextButton()} ${this.renderUserFlags()} </div> `}};ne.styles=[Si,_,ge],r([d({type:Object})],ne.prototype,"newContact",void 0),r([d({type:Array})],ne.prototype,"dataForAccounts",void 0),r([d({type:String})],ne.prototype,"selectedAccountId",void 0),r([d({type:Boolean,reflect:!0})],ne.prototype,"evacAssistanceRequired",void 0),r([m()],ne.prototype,"_dataForAccounts",void 0),r([m()],ne.prototype,"_selectedAccountId",void 0),r([m()],ne.prototype,"_selectedFlagId",void 0),ne=r([A("create-user-step-five")],ne);class k{}k.SUCCESS_CREATED="create-user-success",k.SUCCESS_ICON="create-user-success-icon",k.USER_DETAILS="create-user-success-details",k.SUCCESS_MESSAGE="create-user-success-message",k.VIEW_USER="view-user-button",k.BACK_TO_USERS="back-to-users-button",k.S6={DETAILS_HEADER:"s6-details-header",DETAILS_BODY:"s6-details-body",DETAILS_FIRST_NAME:"s6-details-first-name",DETAILS_LAST_NAME:"s6-details-last-name",DETAILS_EMAIL:"s6-details-email",DETAILS_PHONE:"s6-details-phone",PORTAL_TREE:"s6-portal-tree",FLAG_TREE:"s6-flag-tree",TAB_PORTAL:"s6-tab-portal",TAB_FLAGS:"s6-tab-flags"};let q=class extends I{constructor(){super(...arguments),this.newContact={},this.dataForAccounts=[],this.attachments=[],this.obofSelections=new Map,this.obofEnabled=!1,this.submitting=!1,this.hideContactDetails=!1,this._readonlyTreeViews=[],this._readonlyUserFlags=[],this._selectedTab="roles-and-portal-access",this._isFirstLoad=!0}connectedCallback(){super.connectedCallback(),this._readonlyTreeViews=this.generateReadOnlyTreeViews(),this._readonlyUserFlags=this.generateReadOnlyUserFlags()}isTabActive(e){return this._isFirstLoad?y:this._selectedTab===e}generateReadOnlyTreeViews(){const e=[];return this.dataForAccounts.forEach(t=>{let o=[];t.rolesData.forEach(i=>{if(!i.role.removed){const n=oo(i.genericTreeView),a=io(structuredClone(n));no(a),o.push({role:i.role.name,tree:a})}}),e.push({accountId:t.accountId,accountName:t.accountName,roleTrees:o}),o=[]}),e}generateReadOnlyUserFlags(){const e=[];return this.dataForAccounts.forEach(t=>{let o=[];t.genericFlagsData&&(t.genericFlagsData.forEach(i=>{const n=oo(i.rootNode),a=io(structuredClone(n));no(a),o.push({label:i.label,rootNode:a,isOpen:!1})}),e.push({accountName:t.accountName,flagTrees:o}),o=[])}),e}renderUserDetails(){return c` <div class="user-details"> <div class="user-details-header" data-testid="${k.S6.DETAILS_HEADER}"> <div class="user-details-header-text">User Details</div> <ix-icon-button class="icon-btn_primary" filledIcon icon="edit" ?disabled="${this.submitting}" @click="${()=>this.dispatchSetStepEvent(1)}"></ix-icon-button> </div> <div class="user-details-body" data-testid="${k.S6.DETAILS_BODY}"> <div class="user-details-row"> <div class="dlr-text-default row-label">First Name</div> <div class="dlr-text-default row-value" data-testid="${k.S6.DETAILS_FIRST_NAME}"> ${this.newContact.firstName} </div> </div> <div class="user-details-row"> <div class="dlr-text-default row-label">Last Name</div> <div class="dlr-text-default row-value" data-testid="${k.S6.DETAILS_LAST_NAME}"> ${this.newContact.lastName} </div> </div> <div class="user-details-row"> <div class="dlr-text-default row-label">Email Address</div> <div class="dlr-text-default row-value" data-testid="${k.S6.DETAILS_EMAIL}"> ${this.newContact.email} </div> </div> <div class="user-details-row"> <div class="dlr-text-default row-label">Phone</div> <ix-phone-number data-testid="${k.S6.DETAILS_PHONE}" .number="${this.newContact.phone}"></ix-phone-number> </div> </div> </div> `}renderTabs(){return c` <ix-tabs> <ix-primary-tab @click="${()=>{this._selectedTab="roles-and-portal-access",this._isFirstLoad=!1}}" ?active="${this.isTabActive("roles-and-portal-access")}" data-testid="${k.S6.TAB_PORTAL}"> <span style="${this._selectedTab==="roles-and-portal-access"?"":"color: #092241; opacity: 60%;"}" class="flex items-center uppercase font-bold tracking-wide"> Roles and Portal Access </span> </ix-primary-tab> <ix-primary-tab @click="${()=>{this._selectedTab="user-flags",this._isFirstLoad=!1}}" ?active="${this.isTabActive("user-flags")}" data-testid="${k.S6.TAB_FLAGS}"> <span style="${this._selectedTab==="user-flags"?"":"color: #092241; opacity: 60%;"}" class="flex items-center uppercase font-bold tracking-wide">User Flags</span></ix-primary-tab> </ix-tabs> `}renderObofSummaryRows(e){if(!this.obofEnabled)return y;const t=this.obofSelections.get(e);return c` <div class="user-details-row pt-1"> <div class="dlr-text-default row-label" style="white-space:nowrap"> Created on Behalf of Name </div> <div class="dlr-text-default row-value">${(t==null?void 0:t.name)||"-"}</div> </div> <div class="user-details-row"> <div class="dlr-text-default row-label" style="white-space:nowrap"> Created on Behalf of Email </div> <div class="dlr-text-default row-value">${(t==null?void 0:t.email)||"-"}</div> </div> `}renderAttachmentsSummaryRow(){return this.attachments.length?c` <div class="user-details-row pt-1"> <div class="dlr-text-default row-label">Attachments</div> <div class="row-value flex flex-wrap gap-2"> ${this.attachments.map(e=>c`<span class="px-2 py-1 bg-[#f0f5ff] text-[#092241]">${e.name}</span>`)} </div> </div> `:y}renderRolesAndPortalAccessSummary(){return this._selectedTab!=="roles-and-portal-access"?y:c` <div class="py-4"> ${this._readonlyTreeViews.map(e=>c` <div> <h4 class="pt-1 pb-3">${e.accountName}</h4> ${this.renderObofSummaryRows(e.accountId)} ${this.renderAttachmentsSummaryRow()} ${e.roleTrees.map(t=>c` <div class="pb-2"> <div class="pb-1">${t.role}</div> <ix-generic-tree filledIcons .rootNode="${t.tree}" data-testid="${k.S6.PORTAL_TREE}"></ix-generic-tree> </div> `)} </div>`)} </div> `}renderUserFlagsSummary(){return this._selectedTab!=="user-flags"?y:c`<div> ${this._readonlyUserFlags.map(e=>c` <div class="py-2"> <h4 class="font-bold pb-2">${e.accountName}</h4> <user-flags filledIcons disableCheckboxes .flags="${e.flagTrees}" data-testid="${k.S6.FLAG_TREE}"></user-flags> </div>`)} </div>`}renderLearnMoreText(){return this._selectedTab==="user-flags"?c` <div style="padding-top:15px"> Learn more about user flags <a class="user-flag-learn-text-link" href="#">here.</a> </div> `:c` <div style="padding-top:15px" class="text-black roles-and-portal-access-text"> Learn more about roles and portal access <a class="user-flag-learn-text-link" href="#">here.</a> </div> `}dispatchSetStepEvent(e){this.dispatchEvent(new CustomEvent(w.SetStep,{detail:{step:e},bubbles:!0,composed:!0}))}render(){return c` <div class="wizard-step-content overflow-y-auto overflow-x-hidden md:p-1"> ${this.hideContactDetails?y:c`${this.renderUserDetails()}<ix-divider></ix-divider>`} ${this.renderTabs()} ${this.renderLearnMoreText()} ${this.renderRolesAndPortalAccessSummary()} ${this.renderUserFlagsSummary()} </div> `}};q.styles=[Si,_,ge],r([d({type:Object})],q.prototype,"newContact",void 0),r([d({type:Array})],q.prototype,"dataForAccounts",void 0),r([d({type:Array})],q.prototype,"attachments",void 0),r([d({type:Object})],q.prototype,"obofSelections",void 0),r([d({type:Boolean})],q.prototype,"obofEnabled",void 0),r([d({type:Boolean})],q.prototype,"submitting",void 0),r([d({type:Boolean})],q.prototype,"hideContactDetails",void 0),r([m()],q.prototype,"_readonlyTreeViews",void 0),r([m()],q.prototype,"_readonlyUserFlags",void 0),r([m()],q.prototype,"_selectedTab",void 0),r([m()],q.prototype,"_isFirstLoad",void 0),q=r([A("create-user-step-six")],q);const Zr=$`ix-dialog{--md-dialog-container-color:#fff}ix-icon-button{--md-sys-color-on-surface-variant:var(--md-sys-color-primary)}ix-select{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd;--md-menu-container-color:#fff}ix-select.thick{--md-menu-container-shape:10px}ix-select.slim{--md-outlined-field-bottom-space:2px;--md-outlined-field-top-space:2px}ix-button{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd}ix-button .disabled{color:var(--md-sys-text-color-disabled)}.btn_primary{--md-filled-button-container-color:var(--md-sys-color-primary)}.btn_primary ix-icon{color:var(--md-sys-color-on-primary)}.btn_secondary{--md-filled-button-container-color:var(--md-sys-color-secondary)}.btn_secondary ix-icon{color:var(--md-sys-color-on-secondary)}.btn_tertiary{--md-filled-button-container-color:var(--md-sys-color-tertiary)}.btn_tertiary ix-icon{color:var(--md-sys-color-on-tertiary)}.btn_danger{--md-filled-button-container-color:var(--md-sys-color-error)}.btn_danger ix-icon{color:var(--md-sys-color-on-error)}.icon-btn_primary ix-icon{color:var(--md-sys-color-primary)}.icon-btn_secondary ix-icon{color:var(--md-sys-color-secondary)}.icon-btn_tertiary ix-icon{color:var(--md-sys-color-tertiary)}.icon-btn_danger ix-icon{color:var(--md-sys-color-error)}ix-icon.icon-lg{--ix-icon-font-size:32px}.dialog-form{min-width:500px;display:flex;flex-direction:column;justify-content:space-between;padding:8px 24px 20px}.dialog-form .textfield{width:100%}.dialog-form.sm{min-width:560px}.dialog-form__textbox{padding-top:1rem}.dialog-actions{display:flex;justify-content:flex-end;padding:8px 15px 8px 20px}@media only screen and (min-width:5px) and (max-width:600px){ix-dialog{--md-dialog-container-shape:6px}}@media only screen and (min-width:601px){ix-dialog{--md-dialog-container-shape:3px}}.drawer-container{z-index:100;display:flex;flex-direction:row;position:fixed;width:100%;height:100%;top:var(--intraportal-nav-height,0);right:0;background-color:rgba(0,0,0,.5);animation-duration:.25s;animation-name:fadeIn;animation-timing-function:ease-out}.drawer-container-hide{z-index:100;display:flex;flex-direction:row;flex:0 0 auto;position:fixed;width:100vw;height:100vh;top:0;right:0;background-color:rgba(0,0,0,.5);animation-duration:.25s;animation-name:fadeOut;animation-timing-function:ease-out}.drawer-filler{flex:1}aside{padding:32px 40px 40px;border-radius:1rem 0 0 1rem}.drawer-slide-in{width:100vw;max-width:816px;height:calc(100% - var(--intraportal-nav-height,0px));float:right;display:flex;flex-direction:column;background-color:#fff;box-sizing:border-box;animation-duration:.25s;animation-name:slideInFromRight}.drawer-slide-out{width:100vw;max-width:810px;height:100vh;float:right;background-color:#fff;box-sizing:border-box;animation-duration:.25s;animation-name:slideOutToRight}@media screen and (min-width:1024px){.drawer{width:45%}}.drawer-header{display:flex;justify-content:space-between;align-items:center}.drawer-body{flex-grow:1;overflow:hidden}.drawer-header__hide-btn{flex:1}.drawer-header__title{flex:1;text-align:center;flex-grow:1;flex-shrink:0}.drawer-header__close-btn{flex:1}.hide-text{cursor:pointer;user-select:none}.hide-icon{font-weight:700}@keyframes fadeIn{from{opacity:0}to{opacity:1}}@keyframes fadeOut{from{opacity:1}to{opacity:0}}@keyframes slideInFromRight{from{transform:translateX(100%)}to{transform:translateX(0)}}@keyframes slideOutToRight{from{transform:translateX(0)}to{transform:translateX(100%)}}@media screen and (max-width:600px){aside{border-radius:0;padding:1rem}}`,ke={ToggleDialog:"toggle-dialog",ToggleDraft:"toggle-draft",CloseSuccess:"close-success",BlurDrawer:"blur-drawer",DrawerOpened:"drawer-opened",DrawerClosed:"drawer-closed"};let me=class extends I{constructor(){super(...arguments),this.isVisible=!1,this.summaryScreen=!1,this.submitting=!1,this.showMinimiseButton=!1}static get styles(){return[Zr,_]}connectedCallback(){super.connectedCallback(),this.hasUpdated&&this.isVisible&&this.dispatchVisibilityEvent(!0)}disconnectedCallback(){super.disconnectedCallback(),this.isVisible&&this.dispatchVisibilityEvent(!1)}updated(e){super.updated(e),e.has("isVisible")&&(this.isVisible?this.dispatchVisibilityEvent(!0):e.get("isVisible")===!0&&this.dispatchVisibilityEvent(!1))}dispatchVisibilityEvent(e){const t=new CustomEvent(e?ke.DrawerOpened:ke.DrawerClosed,{bubbles:!0,composed:!0,detail:{drawer:this}});(this.isConnected?this:window).dispatchEvent(t)}dispatchDialogToggleEvent(){this.submitting||this.dispatchEvent(new CustomEvent(ke.ToggleDialog,{composed:!0,bubbles:!0}))}dispatchDraftToggleEvent(){var e,t;(e=this.drawer)===null||e===void 0||e.setAttribute("class","drawer-slide-out"),(t=this.drawerContainer)===null||t===void 0||t.setAttribute("class","drawer-container-hide"),setTimeout(()=>{this.dispatchEvent(new CustomEvent(ke.ToggleDraft,{bubbles:!0,composed:!0}))},250)}dispatchBlurEvent(){this.dispatchEvent(new CustomEvent(ke.BlurDrawer,{bubbles:!0,composed:!0}))}dispatchDrawerCloseEvent(){this.dispatchEvent(new CustomEvent(ke.CloseSuccess,{bubbles:!0,composed:!0}))}render(){const e=this.isVisible?"slide-in":"slide-out";return this.isVisible?(document.body.style.overflow="hidden",document.documentElement.style.overflow="hidden",c` <div class="drawer-container" data-testid="ui-um-drawer-container"> <div class="drawer-filler" @click="${this.dispatchBlurEvent}" @keypress="${this.dispatchBlurEvent}"></div> <aside class="drawer-${e}"> <div class="drawer-header"> <div class="drawer-header__hide-btn"> ${!this.summaryScreen&&this.showMinimiseButton?c` <ix-button class="flex w-24" appearance="text" has-icon @click="${this.dispatchDraftToggleEvent}" ?disabled="${this.submitting}" data-testid="hide-drawer-button"> <md-icon class="hide-icon" slot="icon">fullscreen_exit</md-icon> <p class="dlr-text-small hide-text font-bold uppercase">Hide</p> </ix-button> `:y} </div> <div> <slot name="centre-top"></slot> </div> <div class="drawer-header__close-btn"> <div class="float-right"> <ix-icon-button aria-label="Close" icon="close" @click="${this.summaryScreen?this.dispatchDrawerCloseEvent:this.dispatchDialogToggleEvent}" data-testid="close-drawer-icon"></ix-icon-button> </div> </div> </div> <div class="drawer-body"> <slot name="content"></slot> </div> </aside> </div> `):(document.body.style.overflow="auto",document.documentElement.style.overflow="initial",y)}};r([d({type:Boolean})],me.prototype,"isVisible",void 0),r([d({type:Boolean})],me.prototype,"summaryScreen",void 0),r([d({type:Boolean})],me.prototype,"submitting",void 0),r([d({type:Boolean})],me.prototype,"showMinimiseButton",void 0),r([D("aside")],me.prototype,"drawer",void 0),r([D(".drawer-container")],me.prototype,"drawerContainer",void 0),me=r([A("ui-um-drawer")],me);const Wr=$`ix-dialog{--md-dialog-container-color:#fff}ix-icon-button{--md-sys-color-on-surface-variant:var(--md-sys-color-primary)}ix-select{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd;--md-menu-container-color:#fff}ix-select.thick{--md-menu-container-shape:10px}ix-select.slim{--md-outlined-field-bottom-space:2px;--md-outlined-field-top-space:2px}ix-button{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd}ix-button .disabled{color:var(--md-sys-text-color-disabled)}.btn_primary{--md-filled-button-container-color:var(--md-sys-color-primary)}.btn_primary ix-icon{color:var(--md-sys-color-on-primary)}.btn_secondary{--md-filled-button-container-color:var(--md-sys-color-secondary)}.btn_secondary ix-icon{color:var(--md-sys-color-on-secondary)}.btn_tertiary{--md-filled-button-container-color:var(--md-sys-color-tertiary)}.btn_tertiary ix-icon{color:var(--md-sys-color-on-tertiary)}.btn_danger{--md-filled-button-container-color:var(--md-sys-color-error)}.btn_danger ix-icon{color:var(--md-sys-color-on-error)}.icon-btn_primary ix-icon{color:var(--md-sys-color-primary)}.icon-btn_secondary ix-icon{color:var(--md-sys-color-secondary)}.icon-btn_tertiary ix-icon{color:var(--md-sys-color-tertiary)}.icon-btn_danger ix-icon{color:var(--md-sys-color-error)}ix-icon.icon-lg{--ix-icon-font-size:32px}.dialog-form{min-width:500px;display:flex;flex-direction:column;justify-content:space-between;padding:8px 24px 20px}.dialog-form .textfield{width:100%}.dialog-form.sm{min-width:560px}.dialog-form__textbox{padding-top:1rem}.dialog-actions{display:flex;justify-content:flex-end;padding:8px 15px 8px 20px}@media only screen and (min-width:5px) and (max-width:600px){ix-dialog{--md-dialog-container-shape:6px}}@media only screen and (min-width:601px){ix-dialog{--md-dialog-container-shape:3px}}.wizard-body{overflow:hidden;height:100%}.wizard-footer{float:right}.form{height:100%}`,Kt={UpdateForm:"update-form",NextStepWizard:"next-step-wizard",PrevStep:"prev-step-wizard",ButtonToggle:"button-toggle"};let Zt=class extends I{constructor(){super(...arguments),this.updateFormBinding=this.updateForm.bind(this),this.handleSlotChangeBinding=this.handleSlotChange.bind(this),this.wizardForm=new FormData}static get styles(){return[Wr,_]}connectedCallback(){super.connectedCallback(),window.addEventListener(Kt.UpdateForm,this.updateFormBinding)}disconnectedCallback(){var e;super.disconnectedCallback(),window.removeEventListener(Kt.UpdateForm,this.updateFormBinding);const t=(e=this.shadowRoot)===null||e===void 0?void 0:e.querySelector("slot");t&&t.removeEventListener("slotchange",this.handleSlotChangeBinding)}firstUpdated(){var e;const t=(e=this.shadowRoot)===null||e===void 0?void 0:e.querySelector("slot");t&&t.addEventListener("slotchange",this.handleSlotChangeBinding)}updateForm(e){e.detail.forEach((t,o)=>this.wizardForm.set(o,t))}handleSlotChange(){var e;const t=(e=this.shadowRoot)===null||e===void 0?void 0:e.querySelector("slot");t&&t.assignedElements().forEach(o=>{o.wizardForm=this.wizardForm})}dispatchButtonToggleEvent(e){this.dispatchEvent(new CustomEvent(Kt.ButtonToggle,{detail:e,bubbles:!0,composed:!0}))}render(){return c` <div class="wizard-body"> <form class="form"> <slot name="wizard-content"></slot> </form> </div> `}};r([d({type:Object})],Zt.prototype,"wizardForm",void 0),Zt=r([A("ui-um-wizard")],Zt);const Qr=$`ix-dialog{--md-dialog-container-color:#fff}ix-icon-button{--md-sys-color-on-surface-variant:var(--md-sys-color-primary)}ix-select{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd;--md-menu-container-color:#fff}ix-select.thick{--md-menu-container-shape:10px}ix-select.slim{--md-outlined-field-bottom-space:2px;--md-outlined-field-top-space:2px}ix-button{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd}ix-button .disabled{color:var(--md-sys-text-color-disabled)}.btn_primary{--md-filled-button-container-color:var(--md-sys-color-primary)}.btn_primary ix-icon{color:var(--md-sys-color-on-primary)}.btn_secondary{--md-filled-button-container-color:var(--md-sys-color-secondary)}.btn_secondary ix-icon{color:var(--md-sys-color-on-secondary)}.btn_tertiary{--md-filled-button-container-color:var(--md-sys-color-tertiary)}.btn_tertiary ix-icon{color:var(--md-sys-color-on-tertiary)}.btn_danger{--md-filled-button-container-color:var(--md-sys-color-error)}.btn_danger ix-icon{color:var(--md-sys-color-on-error)}.icon-btn_primary ix-icon{color:var(--md-sys-color-primary)}.icon-btn_secondary ix-icon{color:var(--md-sys-color-secondary)}.icon-btn_tertiary ix-icon{color:var(--md-sys-color-tertiary)}.icon-btn_danger ix-icon{color:var(--md-sys-color-error)}ix-icon.icon-lg{--ix-icon-font-size:32px}.dialog-form{min-width:500px;display:flex;flex-direction:column;justify-content:space-between;padding:8px 24px 20px}.dialog-form .textfield{width:100%}.dialog-form.sm{min-width:560px}.dialog-form__textbox{padding-top:1rem}.dialog-actions{display:flex;justify-content:flex-end;padding:8px 15px 8px 20px}@media only screen and (min-width:5px) and (max-width:600px){ix-dialog{--md-dialog-container-shape:6px}}@media only screen and (min-width:601px){ix-dialog{--md-dialog-container-shape:3px}}:host{display:block;height:100%;min-height:0}.wizard-step-form{display:flex;flex-direction:column;height:100%;min-height:0}.wizard-step-form>*{min-height:0}.step{overflow:auto}.wizard-step__btn-group{padding:20px 0;float:right}.input-group{display:flex;flex-direction:row;gap:20px;margin-bottom:20px}.input-group ix-phone-input,.input-group ix-textbox{flex:1}.textfield{width:100%}.subheading-container{display:flex;flex-direction:row;justify-content:space-between;align-items:center;margin-bottom:36px;margin-top:24px}.submit-btn{width:167.44px}.submit-btn-content{display:flex;align-items:center;flex-direction:row;justify-content:space-between}@media screen and (max-width:600px){.input-group{display:block;flex-direction:row;gap:20px;margin-bottom:20px}.input-group ix-phone-input,.input-group ix-textbox{flex:1}}`;let ue=class extends I{constructor(){super(...arguments),this.handleSlotChangeBinding=this.handleSlotChange.bind(this),this.stepTitle="",this.stepSubTitle="",this.isRequired=!1,this.isLastStep=!1,this.submitting=!1}static get styles(){return[Qr,$e,_]}disconnectedCallback(){var e;super.disconnectedCallback();const t=(e=this.shadowRoot)===null||e===void 0?void 0:e.querySelector("slot");t&&t.removeEventListener("slotchange",this.handleSlotChangeBinding)}firstUpdated(){var e;const t=(e=this.shadowRoot)===null||e===void 0?void 0:e.querySelector("slot");t&&t.addEventListener("slotchange",this.handleSlotChangeBinding),this.firstFocusableElement.focus()}handleSlotChange(){var e,t;const o=(e=this.shadowRoot)===null||e===void 0?void 0:e.querySelector("slot");for(const i of o.assignedNodes())(t=this.form)===null||t===void 0||t.insertBefore(i,o)}dispatchSubmitEvent(e){e.preventDefault(),this.dispatchEvent(new CustomEvent(w.CreateContact,{bubbles:!0,composed:!0}))}render(){return c` <form class="wizard-step-form" @keydown="${e=>{e.key==="Escape"&&(e.stopPropagation(),e.preventDefault(),this.dispatchEvent(new CustomEvent("close-wizard",{detail:{originElement:this.firstFocusableElement},bubbles:!0,composed:!0})))}}"> <div class="wizard-step-heading pt-6"> <h2 class="dlr-text-page-title" data-testid="dlr-text-page-title" tabindex="-1"> ${this.stepTitle} </h2> <div class="subheading-container"> <h3 class="dlr-text-heading" data-testid="dlr-text-heading">${this.stepSubTitle}</h3> ${this.isRequired?c` <span class="dlr-text-small italic required-field">*denotes required field</span> `:y} ${this.isLastStep?c` <ix-button class="submit-btn" has-icon ?submitting="${this.submitting}" @click="${e=>this.dispatchSubmitEvent(e)}" data-testid="wizard-submit-button"> <div class="submit-btn-content"> Yes, Submit <md-icon class="arrow-forward-icon" slot="icon">arrow_forward</md-icon> </div> </ix-button> `:y} </div> </div> <slot></slot> </form> <div tabindex="-1" @focus="${()=>{this.firstFocusableElement.focus()}}"></div> `}};r([D('[tabindex="-1"]')],ue.prototype,"firstFocusableElement",void 0),r([d({type:String})],ue.prototype,"stepTitle",void 0),r([d({type:String})],ue.prototype,"stepSubTitle",void 0),r([d({type:Boolean})],ue.prototype,"isRequired",void 0),r([d({type:Boolean})],ue.prototype,"isLastStep",void 0),r([d({type:Boolean})],ue.prototype,"submitting",void 0),r([D("form")],ue.prototype,"form",void 0),ue=r([A("ui-um-wizard-step")],ue);const ki=$`ix-dialog{--md-dialog-container-color:#fff}ix-icon-button{--md-sys-color-on-surface-variant:var(--md-sys-color-primary)}ix-select{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd;--md-menu-container-color:#fff}ix-select.thick{--md-menu-container-shape:10px}ix-select.slim{--md-outlined-field-bottom-space:2px;--md-outlined-field-top-space:2px}ix-button{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd}ix-button .disabled{color:var(--md-sys-text-color-disabled)}.btn_primary{--md-filled-button-container-color:var(--md-sys-color-primary)}.btn_primary ix-icon{color:var(--md-sys-color-on-primary)}.btn_secondary{--md-filled-button-container-color:var(--md-sys-color-secondary)}.btn_secondary ix-icon{color:var(--md-sys-color-on-secondary)}.btn_tertiary{--md-filled-button-container-color:var(--md-sys-color-tertiary)}.btn_tertiary ix-icon{color:var(--md-sys-color-on-tertiary)}.btn_danger{--md-filled-button-container-color:var(--md-sys-color-error)}.btn_danger ix-icon{color:var(--md-sys-color-on-error)}.icon-btn_primary ix-icon{color:var(--md-sys-color-primary)}.icon-btn_secondary ix-icon{color:var(--md-sys-color-secondary)}.icon-btn_tertiary ix-icon{color:var(--md-sys-color-tertiary)}.icon-btn_danger ix-icon{color:var(--md-sys-color-error)}ix-icon.icon-lg{--ix-icon-font-size:32px}.dialog-form{min-width:500px;display:flex;flex-direction:column;justify-content:space-between;padding:8px 24px 20px}.dialog-form .textfield{width:100%}.dialog-form.sm{min-width:560px}.dialog-form__textbox{padding-top:1rem}.dialog-actions{display:flex;justify-content:flex-end;padding:8px 15px 8px 20px}@media only screen and (min-width:5px) and (max-width:600px){ix-dialog{--md-dialog-container-shape:6px}}@media only screen and (min-width:601px){ix-dialog{--md-dialog-container-shape:3px}}ix-dialog{position:absolute;z-index:101}.create-user-wizard{height:100%;display:flex;flex-direction:column}.dlr-text-small.step-progress{letter-spacing:1.25px}ix-button{font-family:var(--root-secondary-font)}@media only screen and (max-width:600px){.success-actions{flex-direction:column;width:100%}.success-actions ix-button{display:block;width:100%}}`;function Ui(e,t){const o={id:"root",label:"",children:[],customerKnownSpaceName:""},i=new ut,n=structuredClone(e.rolesData.filter(h=>h.locations.length>0).filter(h=>!h.role.removed).flatMap(h=>h.locations)),a=t.data;a&&a.length&&he(a[0],o),n.forEach(h=>{const u=Ge(o,h.id);u&&(u.checked=!0,be(u,o),i.update(o))});const s={label:"",isOpen:!1,rootNode:o},l=[],p=le.map(h=>{const u=structuredClone(s);return u.updateService=new ut,u.updateService.updates=structuredClone(i.nodeUpdates),u.label=h.text,l.push({key:h.text,items:structuredClone(i.nodeUpdates)}),u});e.genericFlagsData=[...p],e.flagData=l}const $i=(e,t)=>{var o;const i={expanded:!1,id:e.id,label:(o=e.displayName)!==null&&o!==void 0?o:e.name,parentId:t.id};return e.subaccounts&&(i.children=e.subaccounts.map(n=>$i(n,i))),i},Yr=e=>{const t={expanded:!1,id:"root",label:"",parentId:"",children:[],disabled:!1};return t.children=e.map(o=>$i(o,t)),t};function Ni(e,t){var o;const i={id:e.id,label:(o=e.displayName)!==null&&o!==void 0?o:e.name,parentId:t.id,expanded:!1,checked:!1,indeterminate:!1,children:[]};return e.subaccounts&&(i.children=e.subaccounts.map(n=>Ni(n,i))),i}function Fi(e){const t={id:"root",parentId:"",label:"",expanded:!1,checked:!1,children:[]};return e.forEach(o=>t.children.push(Ni(o,t))),t}const Xr=e=>{const t=dt(e);return Yr(t)};let C=class extends I{constructor(){super(...arguments),this.showDrawer=!1,this.success=!1,this.submitting=!1,this.newUserId="",this.permissions=[],this.roles=[],this.treeData=[],this.loading=!1,this.selectedAccountId="",this.selectedRoleId="",this.step=1,this.validatingStepOne=!1,this.newContact={firstName:"",lastName:"",email:"",phone:"",accounts:[],evacAssistance:!1},this.dataForAccounts=[],this.showManageUserDialog=!1,this.userId="",this.stepTitle="Add New User",this.isNextButtonEnabled=!1,this.canQuickNavigateSteps={1:!1,2:!1,3:!1,4:!1,5:!1,6:!1},this.maxQuickStep=1,this.obofSelections=new Map,this.attachments=[]}connectedCallback(){super.connectedCallback(),this.setupAccountSelector()}get stepOne(){var e,t;return(t=(e=this.renderRoot.querySelector("#step-1"))===null||e===void 0?void 0:e.shadowRoot)===null||t===void 0?void 0:t.querySelector("create-user-step-one")}setupAccountSelector(){const e=qt().filter(t=>B.hasExternalUserCreate(t.accountNumber));this.accounts=dt(e),this.accountTree=Fi(this.accounts),this.permissions=U.getPermissions()}resetStep(){this.handleDialogReset("close")}setStep(e){this.step=e,this.canQuickNavigateSteps={1:!0,2:!0,3:!0,4:!0,5:!0,6:!0}}resetSteps(e){Object.keys(this.canQuickNavigateSteps).forEach(t=>{e.includes(t)||(this.canQuickNavigateSteps={...this.canQuickNavigateSteps,[t]:!1})})}onNextButtonToggle(e){this.isNextButtonEnabled=e.detail,this.step===1?this.canQuickNavigateSteps={...this.canQuickNavigateSteps,1:!1}:this.step===2?this.resetSteps(["1"]):this.step===3?this.resetSteps(["1","2"]):this.step===4?this.resetSteps(["1","2","3"]):this.canQuickNavigateSteps={...this.canQuickNavigateSteps,[this.step]:!1},this.maxQuickStep=this.step}onPrevStep(){this.step!==1&&(this.step===2&&this.collapseAccountTree(),(this.step===5||this.step===6)&&this.collapseLocationTrees(),this.step===6&&(this.isNextButtonEnabled=!0),this.canQuickNavigateSteps[(this.step-1).toString()]=!0,this.maxQuickStep=Math.max(this.maxQuickStep,this.step),this.step-=1)}onQuickNextStep(){this.canQuickNavigateSteps[this.step]&&this.onNextStep()}async onNextStep(){var e;if(this.isNextButtonEnabled){if(this.loading=!0,this.step===1){if(this.collapseAccountTree(),!this.canQuickNavigateSteps[1]){this.validatingStepOne=!0;const t=await this.validateEmail();if(this.validatingStepOne=!1,!t){this.loading=!1;return}}}else if(this.step===2&&!this.canQuickNavigateSteps[2]){if(!this.accountTree)return;const t=((e=this.checkedAccounts)===null||e===void 0?void 0:e.map(a=>a.id))||[],o=await at.getAccountData(t),i=ve.get(),n=pe(this.newContact.email)&&B.hasAssignInternalRoleCreate(U.getAccountNumber());this.roles=[],this.treeData=[];for(let a=0;a<t.length;a+=1){const s=Ht(t[a],i,n),l=t[a];this.roles.push({accountId:l,roles:structuredClone(s)}),this.treeData.push({contactId:"",accountNumber:l,roleId:"",data:o[a]})}}else if(this.step===3)this.selectedAccountId=this.dataForAccounts[0].accountId,this.selectedRoleId=this.dataForAccounts[0].rolesData[0].role.id;else if(this.step===4){for(const t of this.dataForAccounts){const o=this.treeData.find(i=>i.accountNumber===t.accountId);o&&Ui(t,o)}this.collapseLocationTrees()}else this.step===5&&this.collapseLocationTrees();this.step!==4&&(this.isNextButtonEnabled=!1),this.step+1===this.maxQuickStep&&(this.canQuickNavigateSteps[this.step]=!1),this.loading=!1,this.step+=1}}collapseAccountTree(){this.accountTree&&(this.accountTree.expanded=!1,this.accountTree.children&&this.accountTree.children.forEach(e=>{e.expanded=!1,e.children&&e.children.forEach(t=>{t.expanded=!1})}))}collapseLocationTrees(){this.dataForAccounts.forEach(e=>{var t;e.rolesData.forEach(o=>{Je(o.genericTreeView)}),(t=e.genericFlagsData)===null||t===void 0||t.forEach(o=>{Je(o.rootNode)})})}async validateEmail(){const e=await et.search({email:this.newContact.email.split("@")[0]});return e.contacts.find(t=>t.email===this.newContact.email)?(this.userId=e.contacts[0].id,this.toggleManageUserDialog(),!1):!0}handleDialogReset(e){this.step=1,this.newContact={id:"",firstName:"",lastName:"",email:"",phone:"",accounts:[],evacAssistance:!1},this.setupAccountSelector(),this.stepOne&&(this.stepOne.clearTextFields(),this.stepOne.resetErrorStates(),this.stepOne._nextButtonEnabled=!1),this.dataForAccounts=[],this.obofSelections=new Map,this.attachments=[],this.selectedAccountId="",this.selectedRoleId="",this.canQuickNavigateSteps={1:!1,2:!1,3:!1,4:!1,5:!1,6:!1},this.maxQuickStep=1,this.isNextButtonEnabled=!1,this.dispatchResetSuccessEvent(),e==="toggle"?this.dispatchToggleDrawerEvent():this.dispatchDrawerCloseEvent()}updateAccounts(e){var t;this.accountTree=e.detail.rootNode,!((t=this.accountTree)===null||t===void 0)&&t.children&&(this.checkedAccounts=Et(this.accountTree.children,It(this.accounts||[])),this.dataForAccounts=[])}updateObofSelections(e){this.obofSelections=e.detail.obofSelections}get obofEnabled(){return zt()&&!pe(this.newContact.email)}onUpdateContact(e){const t=e.detail.newContact;this.newContact.email!==t.email&&this.newContact.email!==""&&(this.resetSteps(["1"]),this.dataForAccounts=[]),this.newContact=t}renderWizardStep(){switch(this.step){case 1:return c` <ui-um-wizard-step id="step-1" slot="wizard-content" isRequired .stepTitle="${this.stepTitle}" .stepSubTitle="${"User Information"}" data-testid="create-user-step-one"> <create-user-step-one .newContact="${this.newContact}" .validatingForm="${this.validatingStepOne}" @update-contact="${e=>this.onUpdateContact(e)}" @next-step="${this.onNextStep}" @validate-step="${e=>this.isNextButtonEnabled=e.detail}" @next-button-toggle="${e=>this.onNextButtonToggle(e)}"></create-user-step-one> </ui-um-wizard-step> `;case 2:return c` <ui-um-wizard-step slot="wizard-content" isRequired .stepTitle="${this.stepTitle}" .stepSubTitle="${"Accounts*"}" data-testid="create-user-step-two"> <create-user-step-two class="flex flex-col overflow-auto grow" .accountTree="${this.accountTree}" .accountStructure="${It(this.accounts||[])}" .obofEnabled="${this.obofEnabled}" .obofSelections="${this.obofSelections}" .attachments="${this.attachments}" @update-accounts="${e=>this.updateAccounts(e)}" @update-obof-selections="${e=>this.updateObofSelections(e)}" @update-attachments="${e=>{this.attachments=e.detail.attachments}}" @next-step="${this.onNextStep}" @validate-step="${e=>this.isNextButtonEnabled=e.detail}" @next-button-toggle="${e=>this.onNextButtonToggle(e)}"></create-user-step-two> </ui-um-wizard-step> `;case 3:return c` <ui-um-wizard-step slot="wizard-content" isRequired .stepTitle="${this.stepTitle}" .stepSubTitle="${"Roles"}" data-testid="create-user-step-three"> <create-user-step-three class="flex flex-col overflow-auto grow" .checkedAccounts="${this.checkedAccounts||[]}" .roles="${this.roles}" .dataForAccounts="${this.dataForAccounts}" .treeData="${this.treeData}" @update-dfa="${e=>{this.dataForAccounts=e.detail.dataForAccounts}}" @next-step="${this.onNextStep}" @validate-step="${e=>this.isNextButtonEnabled=e.detail}" @next-button-toggle="${e=>this.onNextButtonToggle(e)}"></create-user-step-three> </ui-um-wizard-step> `;case 4:return c` <ui-um-wizard-step slot="wizard-content" isRequired .stepTitle="${this.stepTitle}" .stepSubTitle="${"Portal Access"}" data-testid="create-user-step-four"> <create-user-step-four class="step" .dataForAccounts="${this.dataForAccounts}" .selectedAccountId="${this.selectedAccountId}" .selectedRoleId="${this.selectedRoleId}" .permissions="${this.permissions}" .contact="${this.newContact}" @update-dfa="${e=>this.dataForAccounts=e.detail.dataForAccounts}" @next-step="${this.onNextStep}" @validate-step="${e=>this.isNextButtonEnabled=e.detail}" @next-button-toggle="${e=>this.onNextButtonToggle(e)}"></create-user-step-four> </ui-um-wizard-step> `;case 5:return c` <ui-um-wizard-step slot="wizard-content" .stepTitle="${this.stepTitle}" .stepSubTitle="${"User Flags"}" data-testid="create-user-step-five"> <create-user-step-five class="step" .dataForAccounts="${this.dataForAccounts}" .selectedAccountId="${this.selectedAccountId}" .evacAssistanceRequired="${this.newContact.evacAssistance}" @evac-assistance-required="${e=>this.newContact.evacAssistance=e.detail}" @update-flags="${()=>this.canQuickNavigateSteps={...this.canQuickNavigateSteps,5:!1}}" @next-step="${this.onNextStep}"> </create-user-step-five> </ui-um-wizard-step> `;case 6:return c` <ui-um-wizard-step isLastStep slot="wizard-content" .stepTitle="${this.stepTitle}" .stepSubTitle="${"Are these details correct?"}" ?submitting="${this.submitting}" @create-contact="${this.dispatchCreateNewContactEvent}" data-testid="create-user-step-six"> <create-user-step-six class="step" .dataForAccounts="${this.dataForAccounts}" .newContact="${this.newContact}" .obofEnabled="${this.obofEnabled}" .obofSelections="${this.obofSelections}" .attachments="${this.attachments}" ?submitting="${this.submitting}" @set-step="${e=>this.setStep(e.detail.step)}"></create-user-step-six> </ui-um-wizard-step> `}return y}renderProgress(){return c`<ix-progress slot="wizard-content" indeterminate></ix-progress>`}renderSuccessMessage(){return c` <div data-testid="${k.SUCCESS_CREATED}" slot="content" class="flex flex-col justify-between items-center pt-40 h-96"> <ix-icon data-testid="${k.SUCCESS_ICON}" style="color:#4caf50;font-size:75px;font-weight:700">check_circle</ix-icon> <span data-testid="${k.USER_DETAILS}" class="text-2xl font-bold pb-5">${this.newContact.firstName} ${this.newContact.lastName} Created</span> <div data-testid="${k.SUCCESS_MESSAGE}" class="pb-5"> ${this.newContact.firstName} ${this.newContact.lastName} has been successfully created. </div> <div class="flex justify-between w-400 success-actions"> <ix-button data-testid="${k.VIEW_USER}" appearance="outlined" @click="${this.handleViewUserRedirect}" class="p-1"><span class="font-bold text-sm tracking-wider uppercase">View user</span></ix-button> <ix-button data-testid="${k.BACK_TO_USERS}" appearance="filled" class="p-1" @click="${()=>this.handleDialogReset("close")}"><span class="font-bold uppercase text-sm tracking-wider">Back to users</span></ix-button> </div> </div> `}handleViewUserRedirect(){this.handleDialogReset("close"),Qe(G.UserManagementDetails,`?id=${this.newUserId}`),this.newUserId=""}renderManageUserDialog(){return c` <ix-dialog ?open="${this.showManageUserDialog}"> <div class="dlr-text-heading" slot="headline"> This user already exists for your Master Account </div> <div class="dialog-actions" slot="actions"> <ix-button appearance="text" @click="${this.handleManageUserDialogClose}" slot="secondary"> Cancel </ix-button> <ix-button appearance="text" @click="${this.handleManageUserRedirect}" slot="primary"> Manage User </ix-button> </div> </ix-dialog> `}toggleManageUserDialog(){this.showManageUserDialog=!this.showManageUserDialog}handleManageUserDialogClose(){this.toggleManageUserDialog(),this.handleDialogReset("close")}handleManageUserRedirect(){this.toggleManageUserDialog(),this.handleDialogReset("close"),Qe(G.UserManagementDetails,`?id=${this.userId}`),this.userId=""}dispatchToggleDrawerEvent(){this.dispatchEvent(new CustomEvent(w.ToggleDrawer,{bubbles:!0,composed:!0}))}dispatchDrawerCloseEvent(){this.dispatchEvent(new CustomEvent(w.CloseDrawer,{bubbles:!0,composed:!0}))}dispatchResetSuccessEvent(){this.dispatchEvent(new CustomEvent(w.ResetSuccess,{bubbles:!0,composed:!0}))}dispatchCreateNewContactEvent(){this.dispatchEvent(new CustomEvent(w.CreateNewContact,{detail:{newContact:this.newContact,dataForAccounts:this.dataForAccounts,attachments:this.attachments,obofSelections:this.obofSelections},bubbles:!0,composed:!0}))}renderDrawerControls(){return c` <div slot="centre-top"> <div class="flex"> ${this.success?y:c` <ix-icon-button class="icon-btn_primary" ?disabled="${this.step===1||this.loading}" @click="${()=>this.onPrevStep()}" icon="chevron_left" data-testid="prev-step-icon"> </ix-icon-button> <span class="dlr-text-small uppercase font-bold pt-[10px] px-2 step-progress" data-testid="step-progress"> ${this.step} of 6 </span> <ix-icon-button style="${this.step===6?"visibility: hidden":""}" class="icon-btn_primary ${this.step===6||!this.isNextButtonEnabled||this.loading?"disabled":""}" ?disabled="${!this.canQuickNavigateSteps[this.step]||this.loading}" @click="${()=>this.onQuickNextStep()}" icon="chevron_right" data-testid="next-step-icon"> </ix-icon-button> `} </div> </div> `}render(){return c` <ui-um-drawer ?isVisible="${this.showDrawer}" ?summaryScreen="${this.success}" ?submitting="${this.submitting}" @close-success="${()=>this.handleDialogReset("close")}" data-testid="ui-um-drawer"> ${this.renderDrawerControls()} ${this.success?this.renderSuccessMessage():c` <ui-um-wizard class="create-user-wizard" slot="content" data-testid="create-user-wizard"> ${this.loading?this.renderProgress():this.renderWizardStep()} </ui-um-wizard> `} </ui-um-drawer> ${this.renderManageUserDialog()} `}};C.styles=[ki,_,$e],r([d({type:Boolean})],C.prototype,"showDrawer",void 0),r([d({type:Boolean})],C.prototype,"success",void 0),r([d({type:Boolean})],C.prototype,"submitting",void 0),r([d({type:String})],C.prototype,"newUserId",void 0),r([m()],C.prototype,"accounts",void 0),r([m()],C.prototype,"accountTree",void 0),r([m()],C.prototype,"permissions",void 0),r([m()],C.prototype,"roles",void 0),r([m()],C.prototype,"treeData",void 0),r([m()],C.prototype,"loading",void 0),r([m()],C.prototype,"selectedAccountId",void 0),r([m()],C.prototype,"selectedRoleId",void 0),r([m()],C.prototype,"step",void 0),r([m()],C.prototype,"validatingStepOne",void 0),r([m()],C.prototype,"newContact",void 0),r([m()],C.prototype,"dataForAccounts",void 0),r([m()],C.prototype,"showManageUserDialog",void 0),r([m()],C.prototype,"userId",void 0),r([m()],C.prototype,"stepTitle",void 0),r([m()],C.prototype,"isNextButtonEnabled",void 0),r([m()],C.prototype,"canQuickNavigateSteps",void 0),r([m()],C.prototype,"maxQuickStep",void 0),r([m()],C.prototype,"checkedAccounts",void 0),r([m()],C.prototype,"obofSelections",void 0),r([m()],C.prototype,"attachments",void 0),C=r([A("create-user")],C);const el=$`.draft-container{display:flex;flex-direction:row;justify-content:space-between;bottom:24px;position:fixed;right:24px;z-index:1200;gap:8px;background-color:#fff;border-radius:16px;box-shadow:rgba(0,0,0,.12) 0 12px 20px -12px,#e1e4e8 0 0 0 1px inset;align-items:center;padding:16px 24px;width:250px}`;let ze=class extends I{constructor(){super(...arguments),this.header="",this.subText="",this.isVisible=!1}static get styles(){return[el]}dispatchDraftToggleEvent(){this.dispatchEvent(new CustomEvent(S.ToggleDraft,{bubbles:!0,composed:!0}))}dispatchDialogToggleEvent(){this.dispatchEvent(new CustomEvent(S.ToggleDialog,{composed:!0}))}render(){return this.isVisible?(document.body.style.overflow="hidden",c` <div class="draft-container"> <div class="draft-text"> <p class="dlr-text-caption text-on-surface-variant">${this.header}</p> <p class="dlr-text-small font-bold">${this.subText}</p> </div> <div class="draft-buttons"> <ix-icon-button filledIcon @click="${this.dispatchDialogToggleEvent}"> <ix-icon filled slot="default" style="color:red">delete</ix-icon> </ix-icon-button> <ix-icon-button appearance="filled" @click="${this.dispatchDraftToggleEvent}"> <ix-icon slot="default">fullscreen</ix-icon> </ix-icon-button> </div> </div> `):(document.body.style.overflow="auto",y)}};r([d({type:String})],ze.prototype,"header",void 0),r([d({type:String})],ze.prototype,"subText",void 0),r([d({type:Boolean})],ze.prototype,"isVisible",void 0),ze=r([A("ix-draft")],ze);const Di=$`ix-dialog .dialog-content{max-width:560px}`,tl=e=>({id:e==null?void 0:e.id,firstName:e==null?void 0:e.first_name,lastName:e==null?void 0:e.last_name,email:e==null?void 0:e.email}),ol=e=>({authorityDocumentId:e.authority_document_id,changeHistoryId:e.change_history_id,fileName:e.file_name}),il=e=>e?{reason:e.reason,authoriserUserId:e.authoriser_user_id,accountNumber:e.account_number}:void 0,nl=e=>({reason:e.reason,authoriser_user_id:e.authoriserUserId,account_number:e.accountNumber}),Pi=e=>{var t,o,i;return{authoriserDetails:(t=e.authoriser_details)===null||t===void 0?void 0:t.map(il).filter(Boolean),changeHistoryId:e.change_history_id,createdBy:tl(e.created_by),createdAt:(o=e.created_at)===null||o===void 0?void 0:o.toString(),authorityDocuments:(i=e.authority_documents)===null||i===void 0?void 0:i.map(ol)}},al=e=>{var t,o,i;return{content:(o=(t=e.content)===null||t===void 0?void 0:t.map(Pi))!==null&&o!==void 0?o:[],continuationToken:(i=e.pageable)===null||i===void 0?void 0:i.continuation_token}},sl=e=>({continuationToken:e.continuationToken,sort:e.sort,limit:e.limit,userId:e.userId,accountNumber:e.accountNumber}),rl=e=>{var t;return{changeHistoryRequest:{authoriser_details:(t=e.changeHistoryInput.authoriserDetails)===null||t===void 0?void 0:t.map(nl),authority_documents:e.changeHistoryInput.authorityDocuments}}};class ll{async get(t={}){try{const o=sl(t),i=await v.ChangeHistoriesApi.getChangeHistory(o);return al(i)}catch(o){return o.response.status!==404&&g.handleError(o,"Failed to get change histories."),{content:[]}}}async create(t){try{const o=rl(t),i=await v.ChangeHistoriesApi.postChangeHistory(o);return Pi(i)}catch(o){return g.handleError(o,"Failed to create change history."),{}}}}const Mi=new ll,cl=(e,t={})=>{const o={...t,userId:e};return Mi.get(o)},Oi=e=>{const t={changeHistoryInput:e};return Mi.create(t)};let ae=class extends Ue{constructor(){super(...arguments),this.showDrawer=!1,this.showDraft=!1,this.showCancelDialog=!1,this.success=!1,this.newUserId="",this.submittingNewUser=!1,this.cancellingCreateUser=!1}static get styles(){return[Di,ge,_]}async createNewContact(e){this.submittingNewUser=!0;const t=e.detail.newContact,o=e.detail.dataForAccounts,i=e.detail.attachments||[],n=e.detail.obofSelections||new Map;o.forEach(({accountId:a})=>{t.accounts.some(({accountNumber:s})=>s===a)||t.accounts.push({accountNumber:a})});try{const a=zt()&&!pe(t.email);let s;if(a){const p=i.length?await Xo(i):[],h=Yo(n),u=await Oi({authoriserDetails:h,authorityDocuments:p.length?p:void 0});if(!(u!=null&&u.changeHistoryId))throw new Error("Failed to create change history.");s=u.changeHistoryId}this.newUserId=await this.createContact(t,s);const l=[this.createRoleAssignments(o,t.email,s),this.createUserFlags(o,s)];(await Promise.allSettled(l)).forEach(p=>{if(p.status==="rejected")throw new Error(p.reason)}),this.dispatchTableRefreshEvent(),this.success=!0}catch(a){this.success=!1}finally{this.submittingNewUser=!1}}async createContact(e,t){const o=await et.create({contactInput:e,changeHistoryId:t});if(!(o!=null&&o.id))throw new Error("Failed to create the new user.");return o.id}async createRoleAssignments(e,t,o){const i=[],n=pe(t);if(e.forEach(({rolesData:a})=>{a.filter(s=>s.role.removed===!1).forEach(s=>{s.locations.forEach(l=>{i.push({roleId:s.role.id,location:l.customerKnownSpaceName,accountNumber:s.accountId,contactId:this.newUserId,isInternal:n})})})}),i.length&&!(await qe.create({roleAssignmentInput:i,changeHistoryId:o})).length)throw new Error("Failed to assign role(s) to the new user.")}async createUserFlags(e,t){var o;const i=[];for(const n of e)n.flagData&&((o=n.genericFlagsData)===null||o===void 0||o.forEach(a=>{a.updateService&&a.updateService.updates.forEach(s=>{const l={accountNumber:n.accountId,contactId:this.newUserId,userFlagType:Ft(a.label),location:s.customerKnownSpaceName||""};i.push(l)})}));if(i.length&&!(await He.create({userFlagAssignmentInput:i,changeHistoryId:t})).length)throw new Error("We could not assign the selected flags to the new user.")}dispatchDraftToggleEvent(){this.dispatchEvent(new CustomEvent(w.ToggleDraft,{composed:!0})),this.dispatchDrawerToggleEvent()}dispatchDrawerToggleEvent(){this.dispatchEvent(new CustomEvent(w.ToggleDrawer,{composed:!0}))}dispatchTableRefreshEvent(){document.dispatchEvent(new CustomEvent(S.RefreshTable,{composed:!0}))}toggleDialog(){this.dispatchEvent(new CustomEvent(w.ToggleDialog,{composed:!0,bubbles:!0}))}toggleSuccess(){this.success=!this.success}resetSuccess(){this.success=!1}cancelCreateUser(){this.cancellingCreateUser=!0,setTimeout(()=>{var e;(e=this.createUser)===null||e===void 0||e.resetStep(),this.dispatchEvent(new CustomEvent(w.CancelCreateUser,{composed:!0})),this.cancellingCreateUser=!1},50)}renderCancelDialog(){return c` <ix-dialog ?open="${this.showCancelDialog}" @cancel="${this.toggleDialog}" data-testid="dialog-cancel-add-user"> <div class="dlr-text-heading md:w-[560px]" slot="headline"> Are you sure you want to cancel? </div> <div class="dialog-content" slot="content"> <p>All the details provided will be lost.</p> </div> <div class="dialog-actions" slot="actions"> <ix-button appearance="text" ?disabled="${this.cancellingCreateUser}" @click="${this.toggleDialog}" slot="secondary" data-testid="dismiss-close-create-user-button"> Dismiss </ix-button> <ix-button appearance="text" ?submitting="${this.cancellingCreateUser}" @click="${this.cancelCreateUser}" slot="primary" data-testid="cancel-create-user-button"> Cancel adding user </ix-button> </div> </ix-dialog> `}render(){return c` <create-user .newUserId="${this.newUserId}" ?showDrawer="${this.showDrawer}" ?submitting="${this.submittingNewUser}" ?success="${this.success}" @toggle-drawer="${this.dispatchDrawerToggleEvent}" @create-new-contact="${e=>this.createNewContact(e)}" @toggle-success="${this.toggleSuccess}" @reset-success="${this.resetSuccess}" data-testid="um-create-user"></create-user> <ix-draft header="Draft" subText="Add New User" ?isVisible="${this.showDraft}" @toggle-dialog="${this.toggleDialog}"></ix-draft> ${this.renderCancelDialog()} `}};r([d({type:Boolean})],ae.prototype,"showDrawer",void 0),r([d({type:Boolean})],ae.prototype,"showDraft",void 0),r([d({type:Boolean})],ae.prototype,"showCancelDialog",void 0),r([m()],ae.prototype,"success",void 0),r([m()],ae.prototype,"newUserId",void 0),r([m()],ae.prototype,"submittingNewUser",void 0),r([m()],ae.prototype,"cancellingCreateUser",void 0),r([D("create-user")],ae.prototype,"createUser",void 0),ae=r([A("create-user-container")],ae);const Bi=$`ix-dialog{--md-dialog-container-color:#fff}ix-icon-button{--md-sys-color-on-surface-variant:var(--md-sys-color-primary)}ix-select{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd;--md-menu-container-color:#fff}ix-select.thick{--md-menu-container-shape:10px}ix-select.slim{--md-outlined-field-bottom-space:2px;--md-outlined-field-top-space:2px}ix-button{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd}ix-button .disabled{color:var(--md-sys-text-color-disabled)}.btn_primary{--md-filled-button-container-color:var(--md-sys-color-primary)}.btn_primary ix-icon{color:var(--md-sys-color-on-primary)}.btn_secondary{--md-filled-button-container-color:var(--md-sys-color-secondary)}.btn_secondary ix-icon{color:var(--md-sys-color-on-secondary)}.btn_tertiary{--md-filled-button-container-color:var(--md-sys-color-tertiary)}.btn_tertiary ix-icon{color:var(--md-sys-color-on-tertiary)}.btn_danger{--md-filled-button-container-color:var(--md-sys-color-error)}.btn_danger ix-icon{color:var(--md-sys-color-on-error)}.icon-btn_primary ix-icon{color:var(--md-sys-color-primary)}.icon-btn_secondary ix-icon{color:var(--md-sys-color-secondary)}.icon-btn_tertiary ix-icon{color:var(--md-sys-color-tertiary)}.icon-btn_danger ix-icon{color:var(--md-sys-color-error)}ix-icon.icon-lg{--ix-icon-font-size:32px}.dialog-form{min-width:500px;display:flex;flex-direction:column;justify-content:space-between;padding:8px 24px 20px}.dialog-form .textfield{width:100%}.dialog-form.sm{min-width:560px}.dialog-form__textbox{padding-top:1rem}.dialog-actions{display:flex;justify-content:flex-end;padding:8px 15px 8px 20px}@media only screen and (min-width:5px) and (max-width:600px){ix-dialog{--md-dialog-container-shape:6px}}@media only screen and (min-width:601px){ix-dialog{--md-dialog-container-shape:3px}}.user-details-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:1.5rem}.edit-icon{font-size:22px;align-items:center;padding-right:1px}.email,.first-name,.last-name{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#edit-profile-id{display:flex;flex-direction:column}.single-row-textbox{width:100%}#edit-profile-id>*{margin:5px 0}ix-textbox,md-textfield{--md-outlined-text-field-width:100%;--md-outlined-text-field-focus-width:100%;width:inherit}.user-profile-name-input-group{display:flex;justify-content:space-between;gap:10px}.user-profile-input{padding-bottom:10px;width:100%}ix-phone-number{--ix-phone-number-font-size:16px;--ix-phone-number-text-color:#092241}`;class dl{constructor(t){(this._host=t).addController(this)}hostConnected(){}hostDisconnected(){}hostUpdate(){}getUserProfile(){return bt.getUserProfile()}updateUserProfile(t){return bt.updateUserProfile(t)}}var ul=[{key:"Etc/GMT+12",value:"(UTC-12:00) International Date Line West"},{key:"Etc/GMT+11",value:"(UTC-11:00) Coordinated Universal Time-11"},{key:"America/Adak",value:"(UTC-10:00) Aleutian Islands"},{key:"Pacific/Honolulu",value:"(UTC-10:00) Hawaii"},{key:"Pacific/Marquesas",value:"(UTC-09:30) Marquesas Islands"},{key:"America/Anchorage",value:"(UTC-09:00) Alaska"},{key:"Etc/GMT+9",value:"(UTC-09:00) Coordinated Universal Time-09"},{key:"America/Tijuana",value:"(UTC-08:00) Baja California"},{key:"Etc/GMT+8",value:"(UTC-08:00) Coordinated Universal Time-08"},{key:"America/Los_Angeles",value:"(UTC-08:00) Pacific Time (US, Canada)"},{key:"America/Phoenix",value:"(UTC-07:00) Arizona"},{key:"America/Chihuahua",value:"(UTC-07:00) Chihuahua, La Paz, Mazatlan"},{key:"America/Denver",value:"(UTC-07:00) Mountain Time (US, Canada)"},{key:"America/Whitehorse",value:"(UTC-07:00) Yukon"},{key:"America/Guatemala",value:"(UTC-06:00) Central America"},{key:"America/Chicago",value:"(UTC-06:00) Central Time (US, Canada)"},{key:"Pacific/Easter",value:"(UTC-06:00) Easter Island"},{key:"America/Mexico_City",value:"(UTC-06:00) Guadalajara, Mexico City, Monterrey"},{key:"America/Regina",value:"(UTC-06:00) Saskatchewan"},{key:"America/Bogota",value:"(UTC-05:00) Bogota, Lima, Quito, Rio Branco"},{key:"America/Cancun",value:"(UTC-05:00) Chetumal"},{key:"America/New_York",value:"(UTC-05:00) Eastern Time (US, Canada)"},{key:"America/Port-au-Prince",value:"(UTC-05:00) Haiti"},{key:"America/Havana",value:"(UTC-05:00) Havana"},{key:"America/Indiana/Indianapolis",value:"(UTC-05:00) Indiana (East)"},{key:"America/Grand_Turk",value:"(UTC-05:00) Turks and Caicos"},{key:"America/Asuncion",value:"(UTC-04:00) Asuncion"},{key:"America/Halifax",value:"(UTC-04:00) Atlantic Time (Canada)"},{key:"America/Caracas",value:"(UTC-04:00) Caracas"},{key:"America/Cuiaba",value:"(UTC-04:00) Cuiaba"},{key:"America/La_Paz",value:"(UTC-04:00) Georgetown, La Paz, Manaus, San Juan"},{key:"America/Santiago",value:"(UTC-04:00) Santiago"},{key:"America/St_Johns",value:"(UTC-03:30) Newfoundland"},{key:"America/Araguaina",value:"(UTC-03:00) Araguaina"},{key:"America/Sao_Paulo",value:"(UTC-03:00) Brasilia"},{key:"America/Cayenne",value:"(UTC-03:00) Cayenne, Fortaleza"},{key:"America/Argentina/Buenos_Aires",value:"(UTC-03:00) City of Buenos Aires"},{key:"America/Nuuk",value:"(UTC-03:00) Greenland"},{key:"America/Montevideo",value:"(UTC-03:00) Montevideo"},{key:"America/Punta_Arenas",value:"(UTC-03:00) Punta Arenas"},{key:"America/Miquelon",value:"(UTC-03:00) Saint Pierre and Miquelon"},{key:"America/Bahia",value:"(UTC-03:00) Salvador"},{key:"Etc/GMT+2",value:"(UTC-02:00) Coordinated Universal Time-02"},{key:"Atlantic/Azores",value:"(UTC-01:00) Azores"},{key:"Atlantic/Cape_Verde",value:"(UTC-01:00) Cabo Verde Is."},{key:"Etc/UTC",value:"(UTC) Coordinated Universal Time"},{key:"Europe/London",value:"(UTC+00:00) Dublin, Edinburgh, Lisbon, London"},{key:"Atlantic/Reykjavik",value:"(UTC+00:00) Monrovia, Reykjavik"},{key:"Africa/Sao_Tome",value:"(UTC+00:00) Sao Tome"},{key:"Africa/Casablanca",value:"(UTC+01:00) Casablanca"},{key:"Europe/Berlin",value:"(UTC+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna"},{key:"Europe/Budapest",value:"(UTC+01:00) Belgrade, Bratislava, Budapest, Ljubljana, Prague"},{key:"Europe/Paris",value:"(UTC+01:00) Brussels, Copenhagen, Madrid, Paris"},{key:"Europe/Warsaw",value:"(UTC+01:00) Sarajevo, Skopje, Warsaw, Zagreb"},{key:"Africa/Lagos",value:"(UTC+01:00) West Central Africa"},{key:"Asia/Amman",value:"(UTC+02:00) Amman"},{key:"Europe/Bucharest",value:"(UTC+02:00) Athens, Bucharest"},{key:"Asia/Beirut",value:"(UTC+02:00) Beirut"},{key:"Africa/Cairo",value:"(UTC+02:00) Cairo"},{key:"Europe/Chisinau",value:"(UTC+02:00) Chisinau"},{key:"Asia/Damascus",value:"(UTC+02:00) Damascus"},{key:"Asia/Hebron",value:"(UTC+02:00) Gaza, Hebron"},{key:"Africa/Johannesburg",value:"(UTC+02:00) Harare, Pretoria"},{key:"Europe/Kiev",value:"(UTC+02:00) Helsinki, Kyiv, Riga, Sofia, Tallinn, Vilnius"},{key:"Asia/Jerusalem",value:"(UTC+02:00) Jerusalem"},{key:"Africa/Juba",value:"(UTC+02:00) Juba"},{key:"Europe/Kaliningrad",value:"(UTC+02:00) Kaliningrad"},{key:"Africa/Khartoum",value:"(UTC+02:00) Khartoum"},{key:"Africa/Tripoli",value:"(UTC+02:00) Tripoli"},{key:"Africa/Windhoek",value:"(UTC+02:00) Windhoek"},{key:"Asia/Baghdad",value:"(UTC+03:00) Baghdad"},{key:"Europe/Istanbul",value:"(UTC+03:00) Istanbul"},{key:"Asia/Riyadh",value:"(UTC+03:00) Kuwait, Riyadh"},{key:"Europe/Minsk",value:"(UTC+03:00) Minsk"},{key:"Europe/Moscow",value:"(UTC+03:00) Moscow, St. Petersburg"},{key:"Africa/Nairobi",value:"(UTC+03:00) Nairobi"},{key:"Europe/Volgograd",value:"(UTC+04:00) Volgograd"},{key:"Asia/Tehran",value:"(UTC+03:30) Tehran"},{key:"Asia/Dubai",value:"(UTC+04:00) Abu Dhabi, Muscat"},{key:"Europe/Astrakhan",value:"(UTC+04:00) Astrakhan, Ulyanovsk"},{key:"Asia/Baku",value:"(UTC+04:00) Baku"},{key:"Europe/Samara",value:"(UTC+04:00) Izhevsk, Samara"},{key:"Indian/Mauritius",value:"(UTC+04:00) Port Louis"},{key:"Europe/Saratov",value:"(UTC+04:00) Saratov"},{key:"Asia/Tbilisi",value:"(UTC+04:00) Tbilisi"},{key:"Asia/Yerevan",value:"(UTC+04:00) Yerevan"},{key:"Asia/Kabul",value:"(UTC+04:30) Kabul"},{key:"Asia/Tashkent",value:"(UTC+05:00) Ashgabat, Tashkent"},{key:"Asia/Yekaterinburg",value:"(UTC+05:00) Ekaterinburg"},{key:"Asia/Karachi",value:"(UTC+05:00) Islamabad, Karachi"},{key:"Asia/Qyzylorda",value:"(UTC+05:00) Qyzylorda"},{key:"Asia/Kolkata",value:"(UTC+05:30) Chennai, Kolkata, Mumbai, New Delhi"},{key:"Asia/Colombo",value:"(UTC+05:30) Sri Jayawardenepura"},{key:"Asia/Kathmandu",value:"(UTC+05:45) Kathmandu"},{key:"Asia/Almaty",value:"(UTC+06:00) Astana"},{key:"Asia/Dhaka",value:"(UTC+06:00) Dhaka"},{key:"Asia/Omsk",value:"(UTC+06:00) Omsk"},{key:"Asia/Yangon",value:"(UTC+06:30) Yangon (Rangoon)"},{key:"Asia/Bangkok",value:"(UTC+07:00) Bangkok, Hanoi, Jakarta"},{key:"Asia/Barnaul",value:"(UTC+07:00) Barnaul, Gorno-Altaysk"},{key:"Asia/Hovd",value:"(UTC+07:00) Hovd"},{key:"Asia/Krasnoyarsk",value:"(UTC+07:00) Krasnoyarsk"},{key:"Asia/Novosibirsk",value:"(UTC+07:00) Novosibirsk"},{key:"Asia/Tomsk",value:"(UTC+07:00) Tomsk"},{key:"Asia/Shanghai",value:"(UTC+08:00) Beijing, Chongqing, Hong Kong, Urumqi"},{key:"Asia/Irkutsk",value:"(UTC+08:00) Irkutsk"},{key:"Asia/Singapore",value:"(UTC+08:00) Kuala Lumpur, Singapore"},{key:"Australia/Perth",value:"(UTC+08:00) Perth"},{key:"Asia/Taipei",value:"(UTC+08:00) Taipei"},{key:"Asia/Ulaanbaatar",value:"(UTC+08:00) Ulaanbaatar"},{key:"Australia/Eucla",value:"(UTC+08:45) Eucla"},{key:"Asia/Chita",value:"(UTC+09:00) Chita"},{key:"Asia/Tokyo",value:"(UTC+09:00) Osaka, Sapporo, Tokyo"},{key:"Asia/Pyongyang",value:"(UTC+09:00) Pyongyang"},{key:"Asia/Seoul",value:"(UTC+09:00) Seoul"},{key:"Asia/Yakutsk",value:"(UTC+09:00) Yakutsk"},{key:"Australia/Adelaide",value:"(UTC+09:30) Adelaide"},{key:"Australia/Darwin",value:"(UTC+09:30) Darwin"},{key:"Australia/Brisbane",value:"(UTC+10:00) Brisbane"},{key:"Australia/Sydney",value:"(UTC+10:00) Canberra, Melbourne, Sydney"},{key:"Pacific/Port_Moresby",value:"(UTC+10:00) Guam, Port Moresby"},{key:"Australia/Hobart",value:"(UTC+10:00) Hobart"},{key:"Asia/Vladivostok",value:"(UTC+10:00) Vladivostok"},{key:"Australia/Lord_Howe",value:"(UTC+10:30) Lord Howe Island"},{key:"Pacific/Bougainville",value:"(UTC+11:00) Bougainville Island"},{key:"Asia/Srednekolymsk",value:"(UTC+11:00) Chokurdakh"},{key:"Asia/Magadan",value:"(UTC+11:00) Magadan"},{key:"Pacific/Norfolk",value:"(UTC+11:00) Norfolk Island"},{key:"Asia/Sakhalin",value:"(UTC+11:00) Sakhalin"},{key:"Pacific/Guadalcanal",value:"(UTC+11:00) Solomon Is., New Caledonia"},{key:"Asia/Kamchatka",value:"(UTC+12:00) Anadyr, Petropavlovsk-Kamchatsky"},{key:"Pacific/Auckland",value:"(UTC+12:00) Auckland, Wellington"},{key:"Etc/GMT-12",value:"(UTC+12:00) Coordinated Universal Time+12"},{key:"Pacific/Fiji",value:"(UTC+12:00) Fiji"},{key:"Pacific/Chatham",value:"(UTC+12:45) Chatham Islands"},{key:"Etc/GMT-13",value:"(UTC+13:00) Coordinated Universal Time+13"},{key:"Pacific/Tongatapu",value:"(UTC+13:00) Nuku'alofa"},{key:"Pacific/Apia",value:"(UTC+13:00) Samoa"},{key:"Pacific/Kiritimati",value:"(UTC+14:00) Kiritimati Island"}];const hl=()=>ul.map(({key:e,value:t})=>({timeZone:e,displayName:t}));let H=class extends Ue{constructor(){super(...arguments),this.userProfileController=new dl(this),this.supportedDateFormat={"MM/dd/yyyy":"mm/dd/yyyy (e.g.: 04/24/2023)","dd/MM/yyyy":"dd/mm/yyyy (e.g.: 24/04/2023)","yyyy/MM/dd":"yyyy/mm/dd (e.g.: 2023/04/24)"},this.supportedTimeFormat={"h:mm a":"12-hour clock (e.g. 1:00 PM)","HH:mm":"24-hour clock (e.g. 13:00)"},this.isDialogVisible=!1,this.allowSave=!0,this.isLoading=!1,this.timezones=hl()}async firstUpdated(){await this.retrieveUserProfile(),this.shouldDisableSaveButton()}async retrieveUserProfile(){this.isLoading=!0,this.userProfile=await this.userProfileController.getUserProfile(),this.isLoading=!1}closeDialog(){this.isDialogVisible=!1,this.dispatchEvent(new CustomEvent("closeEditProfileDialog",{bubbles:!0,composed:!0}))}async saveUserProfileChanges(){var e,t,o,i;const n={profileSettingEditInput:{firstName:(e=J(this.firstName))!==null&&e!==void 0?e:this.firstName.value,lastName:(t=J(this.lastName))!==null&&t!==void 0?t:this.lastName.value,contactPhoneNumber:(o=_e(this.phoneNumber))!==null&&o!==void 0?o:this.phoneNumber.value,preferredTimezone:this.preferredTimezone.value,preferredDateFormat:this.preferredDateFormat.value,preferredTimeFormat:this.preferredTimeFormat.value}};((i=this.userProfile)===null||i===void 0?void 0:i.preferredTimezone)!==n.profileSettingEditInput.preferredTimezone&&(n.profileSettingEditInput.timezoneOverridden=!0),this.isLoading=!0,await this.userProfileController.updateUserProfile(n).then(()=>{uo("Your profile info has been successfully updated",3e3,"center")}),this.saveDateTimeFormatToLocalStorage(n),this.isLoading=!1,this.closeDialog()}validatePhoneInput(e,t){const o=_e(e);if(o==="000-000-0000"){e.error=!1,e.errorText="",this.shouldDisableSaveButton();return}if(this.userProfile.contactPhoneNumber=o!=null?o:"",e.required&&!Oe(e,o)){this.allowSave=!1;return}if(!_t(e,t)){this.allowSave=!1;return}e.error=!1,e.errorText="",this.shouldDisableSaveButton()}saveDateTimeFormatToLocalStorage(e){localStorage.setItem("date-format",JSON.stringify({preferredDateFormat:e.profileSettingEditInput.preferredDateFormat,preferredTimeFormat:e.profileSettingEditInput.preferredTimeFormat,preferredTimezone:e.profileSettingEditInput.preferredTimezone})),this.dispatchEvent(new CustomEvent("dateFormatChanged",{bubbles:!0,composed:!0}))}shouldDisableSaveButton(){this.allowSave=!(this.isInvalid()||this.isEmpty())}isInvalid(){return this.firstName.error||this.lastName.error||this.phoneNumber.error}isEmpty(){var e,t,o;return!(!((e=this.userProfile)===null||e===void 0)&&e.firstName)||!(!((t=this.userProfile)===null||t===void 0)&&t.lastName)||!(!((o=this.userProfile)===null||o===void 0)&&o.contactPhoneNumber)}render(){var e,t,o,i,n,a,s,l;return c`<ix-dialog class="dialog z-50 relative" ?open="${this.isDialogVisible}" @close="${()=>this.closeDialog()}"> ${this.isLoading?c`<ix-progress indeterminate slot="content"></ix-progress>`:""} <div class="dlr-text-heading flex p-6" slot="headline"> <span>Edit Profile</span> </div> <form class="dialog-form min-w-0 max-w-full max-[640px]:w-screen px-6 pb-5 pt-[0px]" slot="content" id="edit-profile-id" method="dialog"> <div class="user-profile-name-input-group grid grid-cols-1 sm:grid-cols-2 gap-3"> <div class="user-profile-input"> <ix-textbox required id="first-name" class="textbox" type="text" pattern="${Me.name}" label="First Name" placeholder="i.e. First Name" value="${(t=(e=this.userProfile)===null||e===void 0?void 0:e.firstName)!==null&&t!==void 0?t:""}" @input="${()=>{var p;this.allowSave=Ct(this.firstName,this.firstName.value,"Invalid first name"),this.userProfile.firstName=(p=J(this.firstName))!==null&&p!==void 0?p:"",this.shouldDisableSaveButton()}}"></ix-textbox> </div> <div class="user-profile-input"> <ix-textbox required id="last-name" class="textbox" type="text" pattern="${Me.name}" label="Last Name" placeholder="i.e. Last Name" value="${(i=(o=this.userProfile)===null||o===void 0?void 0:o.lastName)!==null&&i!==void 0?i:""}" @input="${()=>{var p;this.allowSave=Ct(this.lastName,this.lastName.value,"Invalid last name"),this.userProfile.lastName=(p=J(this.lastName))!==null&&p!==void 0?p:"",this.shouldDisableSaveButton()}}"></ix-textbox> </div> </div> <div class="user-profile-input mb-4"> <ix-phone-input required id="phone-number" class="single-row-textbox w-full" label="Phone Number" value="${(a=(n=this.userProfile)===null||n===void 0?void 0:n.contactPhoneNumber)!==null&&a!==void 0?a:""}" @input="${()=>{this.validatePhoneInput(this.phoneNumber,"Invalid phone number")}}"></ix-phone-input> </div> <div class="user-profile-input"> <ix-textbox id="email" class="single-row-textbox" type="email" label="Email Address" readOnly="true" disabled="true" value="${(l=(s=this.userProfile)===null||s===void 0?void 0:s.email)!==null&&l!==void 0?l:""}"></ix-textbox> </div> <div class="user-profile-input"> <ix-select appearance="outlined" id="preferredTimezone" label="Time Zone" menu-positioning="fixed"> ${this.timezones.map(p=>{var h;return c` <ix-select-option value="${p.timeZone}" ?selected="${p.timeZone===((h=this.userProfile)===null||h===void 0?void 0:h.preferredTimezone)}"> <div slot="headline">${p.displayName}</div> </ix-select-option> `})} </ix-select> </div> <div class="user-profile-input"> <ix-select menu-positioning="fixed" appearance="outlined" id="preferredDateFormat" label="Date format"> ${Object.entries(this.supportedDateFormat).map(([p,h])=>{var u;return c` <ix-select-option value="${p}" ?selected="${p===((u=this.userProfile)===null||u===void 0?void 0:u.preferredDateFormat)}"> <div slot="headline">${h}</div> </ix-select-option> `})} </ix-select> </div> <div class="user-profile-input"> <ix-select menu-positioning="fixed" appearance="outlined" id="preferredTimeFormat" label="Time Format"> ${Object.entries(this.supportedTimeFormat).map(([p,h])=>{var u;return c` <ix-select-option value="${p}" ?selected="${p===((u=this.userProfile)===null||u===void 0?void 0:u.preferredTimeFormat)}"> <div slot="headline">${h}</div> </ix-select-option> `})} </ix-select> </div> </form> <div class="dialog-actions p-2" slot="actions"> <ix-button form="edit-profile-id" appearance="text" text="Cancel" @click="${()=>this.closeDialog()}"> Cancel </ix-button> <ix-button id="save-user-button" appearance="text" text="Save Changes" ?disabled="${!this.allowSave||this.isLoading}" @click="${()=>{this.saveUserProfileChanges()}}"> Save Changes </ix-button> </div> </ix-dialog>`}};H.styles=[Bi,_],r([d({type:Boolean})],H.prototype,"isDialogVisible",void 0),r([m()],H.prototype,"allowSave",void 0),r([m()],H.prototype,"userProfile",void 0),r([m()],H.prototype,"isLoading",void 0),r([m()],H.prototype,"timezones",void 0),r([D("#first-name")],H.prototype,"firstName",void 0),r([D("#last-name")],H.prototype,"lastName",void 0),r([D("#phone-number")],H.prototype,"phoneNumber",void 0),r([D("#preferredTimezone")],H.prototype,"preferredTimezone",void 0),r([D("#preferredDateFormat")],H.prototype,"preferredDateFormat",void 0),r([D("#preferredTimeFormat")],H.prototype,"preferredTimeFormat",void 0),H=r([A("ui-um-user-profile")],H);class pl{async getAuthorisation(){const t=await at.getState(),[o,i,n,a]=t;return[o,i,n,a]}}const ml=new pl;class gl extends Ee{constructor(){super(...arguments),this.expandedNodes=[]}toggleNodeExpanded(t){this.expandedNodes.includes(t)?this.expandedNodes=this.expandedNodes.filter(o=>o!==t):this.expandedNodes.push(t)}async refresh(){this.requestHydration(),this.set(Vr(this.expandedNodes)),this.completeHydration()}}const Li=new gl({});let V=class extends Ue{constructor(){super(),this.errorService=g,this.routes=[],this.baseUrl="",this.isStandalone=!1,this.disableAuthentication=!1,this.compact=localStorage.getItem("compact")==="true",this.showDrawer=!1,this.showDraft=!1,this.showCancelDialog=!1,this.isEditUserProfileDialogOpen=!1,this.handleDrawerEventBinding=this.handleDrawerEvent.bind(this),this.handleCloseEditProfileDialogBinding=this.handleCloseEditProfileDialog.bind(this),this.handleAccountSwitchBinding=this.handleAccountSwitch.bind(this),this.handleEditProfileEventBinding=this.handleEditProfileEvent.bind(this),U.setLoading=!0}connectedCallback(){super.connectedCallback(),window.addEventListener(S.CreateUserClicked,this.handleDrawerEventBinding),document.addEventListener(S.AccountSwitched,this.handleAccountSwitchBinding),window.addEventListener(S.EditProfile,this.handleEditProfileEventBinding)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener(S.CreateUserClicked,this.handleDrawerEventBinding),document.removeEventListener(S.AccountSwitched,this.handleAccountSwitchBinding),window.removeEventListener(S.EditProfile,this.handleEditProfileEventBinding),cs(),g.destroyErrorHandler()}async handleAccountSwitch(e){const t=e.detail;U.setAccountNumber(t),await this.fetchData();const o=window.location.href.split("?")[0];window.history.replaceState({},document.title,o)}handleDrawerEvent(){this.toggleDrawer()}async firstUpdated(){await this.configureAuthentication(),await this.fetchData(),this.init(),U.setLoading=!1}updated(e){e.has("routes")&&this.routes.length&&ls().setRoutes(this.routes)}async fetchData(){const e=Ae.getUserDetails(),{email:t}=e;return ml.getAuthorisation().then(o=>{const[i,n,a,s]=o;return U.setMyPermissions(i),B.myPermissions=U.getMyPermissions(),U.setEmail(t),U.setPermissions(n),U.setAccounts(s),ve.set(a),Li.refresh(),o})}async configureAuthentication(){this.disableAuthentication||N().UserManagement.UI.DisableUserManagementUIAuth||!this.isStandalone?await this.configureAuthorisation():Ae.isProcessing()||(Ae.isLoggedIn()?await this.configureAuthorisation():Ae.redirectToAuth())}async configureAuthorisation(){const e=Ae.getUserDetails(),{accountNumber:t}=e;U.setAccountNumber(t)}init(){setTimeout(()=>{this.mainApp&&(rs(this.mainApp,this.baseUrl,Fo),Pe(window,S.AuthenticationComplete,{accountNumber:U.getAccountNumber()}))})}toggleDrawer(){this.showDraft&&(this.showDraft=!this.showDraft),this.showDrawer=!this.showDrawer}closeDrawer(){this.showDrawer=!1}toggleCompact(){this.compact=!this.compact,localStorage.setItem("compact",`${this.compact}`)}toggleDraft(){this.showDrawer=!this.showDrawer,this.showDraft=!this.showDraft}cancelCreateUser(){this.showDrawer=!1,this.showDraft=!1,this.showCancelDialog=!1}toggleCancelDialog(){this.showCancelDialog=!this.showCancelDialog}renderCreateUser(){return B.hasExternalUserCreate()?c` <create-user-container ?showDrawer="${this.showDrawer}" ?showDraft="${this.showDraft}" ?showCancelDialog="${this.showCancelDialog}" @blur-drawer="${this.toggleCancelDialog}" @toggle-drawer="${this.toggleDrawer}" @toggle-draft="${this.toggleDraft}" @toggle-dialog="${this.toggleCancelDialog}" @close-drawer="${this.closeDrawer}" @cancel-create-user="${this.cancelCreateUser}"></create-user-container> `:y}renderLoading(){return U.getLoading?c` <main> <error-dialog></error-dialog> <ix-progress id="application-loading-bar" aria-label="Application loading bar" indeterminate></ix-progress> </main> `:y}handleEditProfileEvent(){this.isEditUserProfileDialogOpen=!0}handleCloseEditProfileDialog(){this.isEditUserProfileDialogOpen=!1}renderEditProfileForm(){return c` <ui-um-user-profile ?isDialogVisible="${this.isEditUserProfileDialogOpen}" @closeEditProfileDialog="${this.handleCloseEditProfileDialogBinding}"></ui-um-user-profile>`}render(){return c` ${this.renderCreateUser()} <div class="flex flex-col"> <div class="animate-width absolute inset-0 bg-black opacity-50 z-20 ${this.compact?"hidden":"block"} lg:hidden" @click="${this.toggleCompact}" @keypress="${this.toggleCompact}"></div> ${this.isStandalone?c` <nav class="nav-bar wide p-4 m-2 rounded-xl flex items-center relative z-1 md:hidden"> <div class="flex-1"> <ix-icon-button @click="${this.toggleCompact}" icon="menu" class="white-icon"></ix-icon-button> </div> <div class="w-[178px]"> <svg focusable="false" viewBox="0 0 178 27" fill="white" class="w-full"> ${Ke.digitalRealtyLogoWithText} </svg> </div> <div class="flex-1"></div> </nav> `:y} <div class="w-full h-full flex relative ${this.showDrawer?"drawer-visible":""}"> ${this.isStandalone?c` <div class="${this.compact?"left-[-200px]":"left-0"} min-w-[96px] absolute z-1 md:relative lg:min-w-fit md:left-0 animate-width h-screen"> <navigation-bar @toggle-menu="${this.toggleCompact}" ?compact="${this.compact}" class="h-full p-2 block absolute drop-shadow-lg overflow-auto sm:overflow-visible lg:static lg:p-4"></navigation-bar> </div> `:y} <div class="grow w-full h-full"> <div class="flex flex-col grow h-full ${this.isStandalone?"p-2 lg:p-4":""}"> ${this.isStandalone?c`<app-header @create-user="${this.toggleDrawer}"></app-header>`:y} <main class="h-full">${this.renderLoading()}</main> </div> </div> </div> </div> ${this.renderEditProfileForm()}`}};V.styles=[po,$e,_],r([d({type:Array})],V.prototype,"routes",void 0),r([d({type:String})],V.prototype,"baseUrl",void 0),r([d({type:Boolean})],V.prototype,"isStandalone",void 0),r([d({type:Boolean,attribute:!0})],V.prototype,"disableAuthentication",void 0),r([d({type:Boolean,attribute:!1})],V.prototype,"compact",void 0),r([m()],V.prototype,"showDrawer",void 0),r([m()],V.prototype,"showDraft",void 0),r([m()],V.prototype,"showCancelDialog",void 0),r([m()],V.prototype,"isEditUserProfileDialogOpen",void 0),r([D("main")],V.prototype,"mainApp",void 0),V=r([A("ui-user-management")],V);export{ut as $,S as A,Ee as B,$o as C,N as D,st as E,Ho as F,bi as G,Le as H,He as I,Jt as J,ht as K,zr as L,Wo as M,Qo as N,Ao as O,ei as P,z as Q,G as R,Ut as S,_ as T,rt as U,zo as V,Vo as W,Xo as X,Xe as Y,Yo as Z,Oi as _,U as a,zt as a0,pe as a1,Ht as a2,cl as a3,wr as a4,Ai as a5,mi as a6,Bi as a7,At as a8,ps as a9,at as aA,Ui as aB,Et as aC,It as aD,Di as aE,Ct as aa,_t as ab,_e as ac,hs as ad,xs as ae,Me as af,fs as ag,Po as ah,Rt as ai,Zo as aj,Go as ak,$t as al,Tt as am,oi as an,St as ao,ti as ap,Ko as aq,w as ar,ai as as,he as at,le as au,Vt as av,Nt as aw,Mt as ax,k as ay,ki as az,ds as b,B as c,Z as d,ho as e,ve as f,We as g,Li as h,vs as i,dn as j,J as k,Lo as l,gs as m,Qe as n,qt as o,g as p,dt as q,Pe as r,Ye as s,Fi as t,et as u,Xr as v,Ot as w,uo as x,qe as y,xi as z};
2057
+ `;class dt{}dt.BTN_ADD_ROLE="user-details-tab-roles-btn-add-role",dt.BTN_REMOVE_ROLE="user-details-tab-roles-btn-remove-role";const Bt={RoleSelect:"role-select",OpenRoleMenu:"open-role-menu",RemoveRoleMenu:"open-remove-role-menu"};let ie=class extends I{constructor(){super(...arguments),this.disableEscapeKeyBinding=this.disableEscapeKey.bind(this),this.assignedRoles=[],this.activeRoleId="",this.canAddRoles=!1,this.addRolesDisabled=!1,this.canRemoveRoles=!1,this.removeRolesDisabled=!1}connectedCallback(){super.connectedCallback(),this.tabs&&this.tabs.addEventListener("keydown",this.disableEscapeKeyBinding)}disconnectedCallback(){super.disconnectedCallback(),this.tabs&&this.tabs.removeEventListener("keydown",this.disableEscapeKeyBinding)}disableEscapeKey(e){return e.which===27?!1:null}handleRoleClick(e,t){this.dispatchEvent(new CustomEvent(Bt.RoleSelect,{detail:{roleId:t},bubbles:!0,composed:!0})),e.target.scrollIntoView({inline:"center",behavior:"smooth",block:"nearest"})}dispatchOpenRoleMenu(){this.dispatchEvent(new CustomEvent(Bt.OpenRoleMenu,{bubbles:!0,composed:!0}))}dispatchOpenRemoveRoleMeu(){this.dispatchEvent(new CustomEvent(Bt.RemoveRoleMenu,{bubbles:!0,composed:!0}))}setActiveRole(e){this.tabs&&(this.tabs.activeTabIndex=this.assignedRoles.findIndex(t=>t.id===e))}renderAddRoleButton(){return this.canAddRoles?c` <ix-button data-testid="${dt.BTN_ADD_ROLE}" appearance="text" @click="${()=>this.dispatchOpenRoleMenu()}" class="primary" aria-label="Add Role" ?disabled="${this.addRolesDisabled}" has-icon> <md-icon slot="icon">add</md-icon> Add Role </ix-button> `:y}renderRemoveRoleButton(){return this.canRemoveRoles?c` <ix-button data-testid="${dt.BTN_REMOVE_ROLE}" appearance="outlined" .disabled="${this.removeRolesDisabled}" @click="${()=>this.dispatchOpenRemoveRoleMeu()}" class="cancel"> <span>REMOVE ROLE</span> </ix-button> `:y}renderRole(e){return e?c`<ix-primary-tab data-testid="ix-tab-role-${e.id}" @click="${t=>this.handleRoleClick(t,e.id)}" ?activeDisabled="${e.id===this.activeRoleId}"><span id="${`role-tab-${e.id}`}" class="font-bold flex items-center uppercase">${e.name}</span> </ix-primary-tab>`:y}render(){return c` <div class="tab-container"> <div class="flex gap-4 max-w-full overflow-hidden tab-outer-wrapper"> <div class="flex-1 overflow-auto tab-inner-wrapper"> <ix-tabs data-testid="ix-tabs-roles" id="roles-tabs" .scrollButtons="${this.assignedRoles.length>1}" hideScrollBar left-align="true"> ${this.assignedRoles.map(e=>this.renderRole(e))} </ix-tabs> </div> <div class="flex items-center gap-4 shrink-0 tab-inner-wrapper"> ${this.renderAddRoleButton()} ${this.renderRemoveRoleButton()} </div> </div> </div> `}};ie.styles=[rt,lt,_,ge,qr],r([d({type:Array,attribute:!1})],ie.prototype,"assignedRoles",void 0),r([d({type:String,attribute:!1})],ie.prototype,"activeRoleId",void 0),r([d({type:Boolean})],ie.prototype,"canAddRoles",void 0),r([d({type:Boolean})],ie.prototype,"addRolesDisabled",void 0),r([d({type:Boolean})],ie.prototype,"canRemoveRoles",void 0),r([d({type:Boolean})],ie.prototype,"removeRolesDisabled",void 0),r([D("#roles-tabs")],ie.prototype,"tabs",void 0),ie=r([A("user-details-tab-roles")],ie);const yi=e=>U.getAccounts().find(t=>t.accountNumber===e),bi=(e,t)=>{const o=e.filter(i=>i.parentAccountNumber===t);return o.length?o.flatMap(i=>({id:i.accountNumber,name:i.name,displayName:i.displayName,subaccounts:bi(e,i.accountNumber)})):[]},ut=e=>{try{const t=e.map(i=>i.accountNumber),o=e.filter(i=>!t.includes(i.parentAccountNumber||""));if(!o)throw new Error("Failed to get nested account structure");return o.map(i=>({id:i.accountNumber,name:i.name,displayName:i.displayName,subaccounts:bi(e,i.accountNumber)}))}catch(t){return console.error("Could not get nested account structure",t),[]}},Lt=()=>U.getAccounts().sort((e,t)=>e.name.localeCompare(t.name,void 0,{sensitivity:"base"})),xi=e=>ve.get().find(t=>t.id===e)||null,Hr=e=>{const t=[],o=[...new Set(e.map(i=>i.roleId))];for(const i of o){const n=xi(i);n&&t.push(n)}return t},wi=e=>{var t;return{label:(t=e.displayName)!==null&&t!==void 0?t:e.name,id:e.id,children:e.subaccounts.map(o=>wi(o))}},Ai=(e,t)=>{e.children&&e.children.length&&e.children.forEach(i=>Ai(i,t));const o=t.filter(i=>e.id===i.accountNumber).map(i=>({label:i.name,id:i.id,children:void 0}));e.children&&(e.children=o.concat(e.children))},zr=e=>{const t=[],o=Lt().filter(s=>B.hasCustomRolesRead(s.accountNumber)||B.hasCustomRolesCreate(s.accountNumber)||B.hasCustomRolesUpdate(s.accountNumber)||B.hasCustomRolesApprove(s.accountNumber)),i=ut(o);i.forEach(s=>t.push(wi(s)));const n=ve.get().filter(s=>s.roleType===Z.Custom);t.forEach(s=>{Ai(s,n),s.expanded=e.includes(s.id)});const a=i.some(s=>!!s.subaccounts.length);return{tree:{label:"root",id:"root",children:t},isEndChild:!a&&o.length<=1}},qt=(e,t,o=!1)=>{let i=t.filter(n=>n.accountNumber===e||n.roleType===Z.Default||n.roleType===Z.Internal||n.roleType===Z.GlobalAccess);return o||(i=i.filter(n=>n.roleType!==Z.Internal&&n.roleType!==Z.GlobalAccess)),i};class ee{}ee.HEADING="add-account-role-dialog-heading",ee.ROLE_SELECTOR="add-account-role-dialog-role-selector",ee.ROLE_OPTION=e=>`add-account-role-dialog-role-option-${e}`,ee.BTN_CANCEL="add-account-role-dialog-cancel-button",ee.BTN_ADD="add-account-role-dialog-add-role-button",ee.SUCCESS_MESSAGE="add-account-role-dialog-success-message";function pe(e){const t=e==null?void 0:e.toLowerCase().trim();return N().InternalUserDomainWhitelist.split(",").map(o=>o.toLowerCase().trim()).filter(Boolean).some(o=>t==null?void 0:t.includes(o))}function Vr(e){return pe(e)&&N().EnableUMChangeHistory===!0}function Ht(){return Vr(U.getEmail())}let W=class extends I{constructor(){super(...arguments),this.roles=[],this.assignedRoles=[],this.isOpen=!1,this.loading=!1,this.roleId="",this.disabled=!0,this.handleEscapeKeyBinding=this.handleEscapeKey.bind(this),this.handleCancelChangesBinding=this.handleCancelChanges.bind(this)}get name(){var e,t;return`${(e=this.contact)===null||e===void 0?void 0:e.firstName} ${(t=this.contact)===null||t===void 0?void 0:t.lastName}`}get addableRoles(){var e,t,o;if(!(!((e=this.account)===null||e===void 0)&&e.accountNumber))return[];const i=pe((t=this.contact)===null||t===void 0?void 0:t.email)&&B.hasAssignInternalRoleCreate((o=this.account)===null||o===void 0?void 0:o.accountNumber);return qt(this.account.accountNumber,this.roles,i)}connectedCallback(){super.connectedCallback(),this.addEventListener("keydown",this.handleEscapeKeyBinding),this.addEventListener("blur",this.handleCancelChangesBinding)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("keydown",this.handleEscapeKeyBinding),this.removeEventListener("blur",this.handleCancelChangesBinding)}handleEscapeKey(e){return e.which===27&&(this.isOpen=!1),null}async handleOpenDialog(){this.isOpen=!0;const e=await this.rolesMenu;e==null||e.reset(),this.disabled=!0}async handleConfirmChanges(){this.dispatchEvent(new CustomEvent(S.AddRole,{detail:{roleId:this.roleId}}))}async handleCancelChanges(){this.isOpen=!1}handleRoleSelect(e){e&&(this.disabled=!1)}renderRoleOptions(){return c` ${this.addableRoles.map((e,t)=>c` <ix-select-option class="option" value="${t}" ?disabled="${this.assignedRoles.some(o=>o.id===e.id)}" @click="${()=>{this.roleId=this.addableRoles[t].id}}" data-testid="${ee.ROLE_OPTION(e.name)}"> <div slot="headline">${e.name}</div> </ix-select-option>`)} `}renderHeader(){var e;return c` <div id="confirmation-header" slot="headline" style="max-width:560px" data-testid="${ee.HEADING}"> <h1 class="dlr-text-heading break-words"> Add Role to ${this.name} for ${(e=this.account)===null||e===void 0?void 0:e.name} </h1> </div>`}renderContent(){return c` <div slot="content" method="dialog"> <form slot="content" style="padding-top:0" id="add-role-to-roles" method="dialog"> <ix-select quick menu-below class="thick" id="roles-menu" menu-positioning="fixed" @input="${e=>this.handleRoleSelect(e.target.value)}" data-testid="${ee.ROLE_SELECTOR}"> ${this.renderRoleOptions()} </ix-select> </form> </div>`}renderFooter(){return c` <div class="add-roles-dialog-actions" slot="actions"> <ix-button form="confirm-updates" appearance="text" text="Cancel" ?disabled="${this.loading}" @click="${()=>this.handleCancelChanges()}" data-testid="${ee.BTN_CANCEL}"> Cancel </ix-button> <ix-button id="add-account-button" form="confirm-updates" appearance="text" text="Add Role" ?disabled="${this.disabled}" ?submitting="${this.loading}" @click="${this.handleConfirmChanges}" data-testid="${ee.BTN_ADD}">Add Role </ix-button> </div> `}render(){return c` <ix-dialog class="z-50 relative" id="add-role-to-account" ?open="${this.isOpen}"> ${this.renderHeader()} ${this.renderContent()} ${this.renderFooter()} </ix-dialog>`}};W.styles=[rt,lt,_],r([d({type:Object})],W.prototype,"contact",void 0),r([d({type:Object})],W.prototype,"account",void 0),r([d({type:Array})],W.prototype,"roles",void 0),r([d({type:Array})],W.prototype,"assignedRoles",void 0),r([d({type:Boolean,reflect:!0})],W.prototype,"isOpen",void 0),r([m()],W.prototype,"loading",void 0),r([m()],W.prototype,"roleId",void 0),r([m()],W.prototype,"disabled",void 0),r([Bi("#roles-menu")],W.prototype,"rolesMenu",void 0),W=r([A("add-account-role")],W);const zt=$`ix-dialog{--md-dialog-container-color:#fff}ix-icon-button{--md-sys-color-on-surface-variant:var(--md-sys-color-primary)}ix-select{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd;--md-menu-container-color:#fff}ix-select.thick{--md-menu-container-shape:10px}ix-select.slim{--md-outlined-field-bottom-space:2px;--md-outlined-field-top-space:2px}ix-button{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd}ix-button .disabled{color:var(--md-sys-text-color-disabled)}.btn_primary{--md-filled-button-container-color:var(--md-sys-color-primary)}.btn_primary ix-icon{color:var(--md-sys-color-on-primary)}.btn_secondary{--md-filled-button-container-color:var(--md-sys-color-secondary)}.btn_secondary ix-icon{color:var(--md-sys-color-on-secondary)}.btn_tertiary{--md-filled-button-container-color:var(--md-sys-color-tertiary)}.btn_tertiary ix-icon{color:var(--md-sys-color-on-tertiary)}.btn_danger{--md-filled-button-container-color:var(--md-sys-color-error)}.btn_danger ix-icon{color:var(--md-sys-color-on-error)}.icon-btn_primary ix-icon{color:var(--md-sys-color-primary)}.icon-btn_secondary ix-icon{color:var(--md-sys-color-secondary)}.icon-btn_tertiary ix-icon{color:var(--md-sys-color-tertiary)}.icon-btn_danger ix-icon{color:var(--md-sys-color-error)}ix-icon.icon-lg{--ix-icon-font-size:32px}.dialog-form{min-width:500px;display:flex;flex-direction:column;justify-content:space-between;padding:8px 24px 20px}.dialog-form .textfield{width:100%}.dialog-form.sm{min-width:560px}.dialog-form__textbox{padding-top:1rem}.dialog-actions{display:flex;justify-content:flex-end;padding:8px 15px 8px 20px}@media only screen and (min-width:5px) and (max-width:600px){ix-dialog{--md-dialog-container-shape:6px}}@media only screen and (min-width:601px){ix-dialog{--md-dialog-container-shape:3px}}.cards-container{display:flex;flex-wrap:wrap}.cards-container>:first-child{padding:8px 8px 8px 0}.cards-container>:not(:first-child){padding:8px}.tree-role-locations-count{margin:0;color:rgba(9,34,65,.3);padding-right:20px;text-transform:uppercase;font-weight:700}.tree-role-locations-count-active{margin:0;padding-right:40px;text-transform:uppercase;font-weight:700;font-size:.875rem;font-family:var(--root-secondary-font)}.assign-portal-access-text{font-family:Open Sans;font-weight:400;font-size:12px;line-height:16px;letter-spacing:.4px;color:#092241B2;margin-top:.25rem;margin-bottom:1rem}ix-button{font-family:var(--root-secondary-font)}.remove{color:#db0028}.permissions-content{width:800px}.dismiss-btn{color:#1456e0}@media only screen and (max-width:600px){#next-button{display:inline-block}.next-control{text-align:center}.tree-view-container-footer{padding-bottom:1rem}.permissions-content{width:auto}.cards-container{display:flex;flex-wrap:nowrap;max-width:100%;overflow-x:auto}}@media only screen and (min-width:601px){.permissions-locations{display:flex;justify-content:space-between;align-items:center;width:100%}.controls{display:flex;justify-content:space-between;align-items:center}}@media only screen and (max-width:600px){.cards-container{flex-wrap:unset;overflow-x:auto}.tree-role-locations{margin-top:-3px!important}.tree-role-locations-count,.tree-role-locations-count-active{font-size:.875rem!important}}`,jr={ToggleActiveCard:"toggle-active-card"};let Se=class extends I{constructor(){super(...arguments),this.dataForAccounts=[],this.isRoles=!1}dispatchToggleActiveCard(e){this.dispatchEvent(new CustomEvent(jr.ToggleActiveCard,{detail:{accountId:e},bubbles:!0,composed:!0}))}renderCards(){return this.dataForAccounts.map(e=>{if(this.isRoles){const o=e.rolesData.filter(i=>i.role.removed===!1).map(i=>i.role.name);return c` <ix-card data-testid="ix-card-${e.accountId}" .itemId="${e.accountId}" .name="${e.accountName}" .names="${o}" .type="${"roles"}" ?isActive="${this.selectedAccountId===e.accountId}" @toggle-card="${i=>{this.dispatchToggleActiveCard(i.detail)}}"></ix-card> `}const t=le.map(o=>o.text);return c` <ix-card data-testid="ix-card-${e.accountId}" .itemId="${e.accountId}" .name="${e.accountName}" .names="${t}" .type="${"flags"}" .isActive="${this.selectedAccountId===e.accountId}" @toggle-card="${o=>{this.dispatchToggleActiveCard(o.detail)}}"></ix-card> `})}render(){return c`<div class="cards-container">${this.renderCards()}</div> `}};Se.styles=[zt,_,$e,ge],r([d({type:Array})],Se.prototype,"dataForAccounts",void 0),r([d({type:String})],Se.prototype,"selectedAccountId",void 0),r([d({type:Boolean})],Se.prototype,"isRoles",void 0),Se=r([A("account-tabbing-card")],Se);class ht{constructor(){this.updates=[]}get nodeUpdates(){return this.updates}update(t){this.updates=[];let o=[];t&&(o=en(t));for(const i of o)i.originalCheckedStatus!==i.checked&&this.updates.push(i)}}class Ci{constructor(){this._nodeUpdates=[]}create(t){if(this._nodeUpdates.find(i=>i.key===t))return;const o=new ht;this._nodeUpdates.push({key:t,item:o})}update(t,o){const i=this._nodeUpdates.find(n=>n.key===t);i==null||i.item.update(o)}get nodeUpdates(){return this._nodeUpdates}get isDirty(){let t=0;return this._nodeUpdates.forEach(o=>{t+=o.item.nodeUpdates.length}),t>0}get nodeChanges(){const t=[];return this._nodeUpdates.forEach(o=>{o.item.nodeUpdates.length>0&&o.item.nodeUpdates.forEach(i=>{const n=t.find(a=>a.key===o.key);n?n.items.push(i):t.push({key:o.key,items:[i]})})}),t}reset(){this._nodeUpdates=[]}remove(t){this._nodeUpdates=this._nodeUpdates.filter(o=>o.key!==t)}}function Vt(e,t){var o,i;const n=[],a=t.toLowerCase().trim();if(a.length<2||((!((o=e.label)===null||o===void 0)&&o.toLowerCase().includes(a)||!((i=e.secondaryLabel)===null||i===void 0)&&i.toLowerCase().includes(a))&&n.push(e),!e.children))return n;for(const s of e.children){const l=Vt(s,t);n.push(...l)}return n}function _i(e,t,o){if(e==="previous"){const i=o.indexOf(t)-1,n=i<0?o.length-1:i;return o[n]}if(e==="next"){const i=o.indexOf(t)+1,n=i>=o.length?0:i;return o[n]}}function Ti(e,t){const o=[];for(const i of t){o.push(i.id),i.selected=!0;let n=Je(e,i.id);for(;n!=null&&n.parentId;)n=Je(e,n.parentId),n&&(n.expanded=!0)}return o}function jt(e){e.selected=!1,e.children&&e.children.forEach(t=>{jt(t)})}class Gr{constructor(){this._dataCollection=new Map}capture(t){var o;let i;const n=this._dataCollection.get(t);return n&&(i=Po(n.data),!((o=n.options)===null||o===void 0)&&o.consume&&this._dataCollection.delete(t)),i}emit(t,o){o.options={lock:!1,consume:!0,...o.options},this._store(t,o)}lock(t){const o=this._dataCollection.get(t);o&&(o.options.lock=!0)}remove(t){this._dataCollection.delete(t)}_store(t,o){var i;const n=this._dataCollection.get(t);return n&&!((i=n.options)===null||i===void 0)&&i.lock?!1:(this._dataCollection.set(t,Po(o)),!0)}}const pt=new Gr;class Jr extends Ee{}const Gt=new Jr({});let M=class extends I{constructor(){super(...arguments),this.searching=!1,this.disableTree=!1,this.readonly=!1,this.activeRoleId="",this.searchResultCount=0,this.searchResultIndex=0,this.selectedIds=[],this.loadingNodes=!1,this.assignmentUpdateManagers=[],this.searchText="",this.onSearchTextChange=no(async e=>{var t;this.searchText=e.detail.searchText;const o=(t=this.assignment)===null||t===void 0?void 0:t.rootNode;jt(o);const i=Vt(o,this.searchText);i.length&&Ke(o),this.searchResultCount=i.length;const n=Ti(o,i);[this.selectedId]=n,this.selectedIds=[...n],this.searchResultIndex=n.indexOf(this.selectedId)+1,this.requestUpdate()},500)}updated(e){super.updated(e),e.has("activeRoleId")&&this.handleNonLocationTrees()}disconnectedCallback(){super.disconnectedCallback(),this.emitUpdates()}emitUpdates(){var e,t;const o=Gt.get(),i=(e=this.assignmentUpdateManagers.find(l=>l.accountId===o.accountNumber))===null||e===void 0?void 0:e.nodeManager,n=i==null?void 0:i.nodeUpdates.flatMap(l=>l.item.nodeUpdates);if(!(o!=null&&o.accountNumber)&&!i)return;const a={data:n||[],options:{consume:!1}},s=`${o.accountNumber}:${(t=this.contact)===null||t===void 0?void 0:t.id}`;pt.emit(s,a)}dispatchCheckToggleEvent(e){this.dispatchEvent(new CustomEvent(S.CheckToggle,{detail:{message:{updates:structuredClone(e)}}}))}handleNonLocationTrees(){const e=ve.get().find(n=>{var a;return n.id===((a=this.assignment)===null||a===void 0?void 0:a.role)});if(!e||!this.assignment)return;if(!e.permissions.every(n=>n.isNonLocation)){this.disableTree=!1;return}const t=this.assignment.rootNode.children[0];t.checked=!0,this.disableTree=!0,be(t,this.assignment.rootNode);const o=this.getOrCreateNodeManager();if(!o)return;const i=o.nodeUpdates.find(n=>{var a;return n.key===((a=this.assignment)===null||a===void 0?void 0:a.role)});i&&(i.item.update(this.assignment.rootNode),this.dispatchCheckToggleEvent(o.nodeChanges))}onTreeCheckToggle(e){var t;try{const o=this.getOrCreateNodeManager();if(!o)throw new Error("Node manager is missing.");const i=o.nodeUpdates.find(n=>{var a;return n.key===((a=this.assignment)===null||a===void 0?void 0:a.role)});i&&i.item.update(e.detail.message.rootNode),!((t=this.assignment)===null||t===void 0)&&t.rootNode&&(this.assignment.rootNode=structuredClone(e.detail.message.rootNode)),this.dispatchCheckToggleEvent(o.nodeChanges)}catch(o){g.handleError(o,"Failed to toggle tree check.")}}async onTreeExpandToggle(e){var t,o;try{const i=e.detail.message.update,n=e.detail.message.node;if(n.children&&n.children.length)return;if(!this.contact.id||!this.accountNumber)throw new Error("Contact ID or Account Number is missing.");n.loading=!0;const a=await yr((t=this.assignment)===null||t===void 0?void 0:t.role,this.contact.id,this.accountNumber,n.id,void 0,!0,pe((o=this.contact)===null||o===void 0?void 0:o.email));n.loading=!1,a[0].inventoryItems&&a[0].inventoryItems.length&&(a[0].inventoryItems.forEach(s=>{he(s,n),n.originalCheckedStatus!==n.checked&&be(n,n)}),i())}catch(i){g.handleError(i,"Failed to expand tree node.")}}destroyRoleManager(){const e=this.assignmentUpdateManagers.find(t=>t.accountId===this.accountNumber);e&&(e.nodeManager.reset(),this.assignmentUpdateManagers=this.assignmentUpdateManagers.filter(t=>t.accountId!==this.accountNumber))}getOrCreateNodeManager(){var e;let t;try{if(!this.accountNumber)throw new Error("Account number is missing.");t=(e=this.assignmentUpdateManagers.find(o=>o.accountId===this.accountNumber))===null||e===void 0?void 0:e.nodeManager,t||(this.assignmentUpdateManagers.push({accountId:this.accountNumber,nodeManager:new Ci}),t=this.assignmentUpdateManagers.find(o=>o.accountId===this.accountNumber).nodeManager)}catch(o){g.handleError(o,"Failed to get or create node manager.")}return t}disableCheckboxes(){return this.readonly?!0:this.disableTree}onSearchNavigation(e){if(!this.selectedIds.length)return;const t=_i(e.detail.direction,this.selectedId,this.selectedIds);this.selectedId=t!=null?t:this.selectedId,this.searchResultIndex=this.selectedIds.indexOf(this.selectedId)+1,this.requestUpdate()}render(){var e;const t=this.getOrCreateNodeManager();return t&&this.assignment&&t.create(this.assignment.role),c` <div class="flex items-center py-[0.75rem]"> <h1 class="dlr-text-heading">Portal Access</h1> <ix-progress .linear="${!1}" .indeterminate="${!0}" style="visibility:${this.searching?"visible":"hidden"}"></ix-progress> </div> <ix-generic-tree data-testid="location-treeview" .rootNode="${(e=this.assignment)===null||e===void 0?void 0:e.rootNode}" .searchText="${this.searchText}" .selectedId="${this.selectedId}" .showCheckboxes="${!0}" .disableCheckboxes="${this.disableCheckboxes()}" @search-text-change="${this.onSearchTextChange}" @search-navigation="${o=>this.onSearchNavigation(o)}" @check-toggle="${o=>this.onTreeCheckToggle(o)}" @expand-toggle="${o=>this.onTreeExpandToggle(o)}" searchEnabled .searchResultCount="${this.searchResultCount}" .searchResultIndex="${this.searchResultIndex}" searchPlaceholder="Search by Site or Asset Name.."></ix-generic-tree> `}};M.styles=[_,$`:host{--md-circular-progress-size:28px}`],r([d({type:Object,attribute:!1})],M.prototype,"assignment",void 0),r([d({type:Object})],M.prototype,"contact",void 0),r([d({type:String})],M.prototype,"accountNumber",void 0),r([d({type:String})],M.prototype,"selectedId",void 0),r([d({type:Boolean})],M.prototype,"searching",void 0),r([d({type:Boolean})],M.prototype,"disableTree",void 0),r([d({type:Boolean})],M.prototype,"readonly",void 0),r([d({type:String})],M.prototype,"activeRoleId",void 0),r([m()],M.prototype,"searchResultCount",void 0),r([m()],M.prototype,"searchResultIndex",void 0),r([m()],M.prototype,"selectedIds",void 0),r([m()],M.prototype,"loadingNodes",void 0),r([m()],M.prototype,"assignmentUpdateManagers",void 0),r([m()],M.prototype,"searchText",void 0),M=r([A("user-details-assignments")],M);let O=class extends I{constructor(){super(...arguments),this.dataForAccounts=[],this.permissions=[],this._dataForAccounts=[],this.showPermissionsDialog=!1,this.removeRoleDialogOpen=!1,this._nextButtonEnabled=!1}connectedCallback(){super.connectedCallback(),this._dataForAccounts=this.dataForAccounts,this._selectedAccountId=this.selectedAccountId,this._selectedRoleId=this.selectedRoleId,this.validateStep(),this.dispatchValidateStepEvent(),this.setInitialRole()}get noOfLocations(){var e;return eo((e=this.selectedRoleData)===null||e===void 0?void 0:e.genericTreeView)}get canAddRolesDisabled(){return this.unAvailableRoles&&this.unAvailableRoles.length<=0}get availableRoles(){const e=this._dataForAccounts.find(o=>o.accountId===this._selectedAccountId),t=e==null?void 0:e.rolesData.filter(o=>o.role.removed===!1);return t==null?void 0:t.flatMap(o=>o.role)}get unAvailableRoles(){const e=this._dataForAccounts.find(o=>o.accountId===this._selectedAccountId),t=e==null?void 0:e.rolesData.filter(o=>o.role.removed===!0);return t==null?void 0:t.flatMap(o=>o.role)}get roles(){const e=this._dataForAccounts.find(t=>t.accountId===this._selectedAccountId);return e==null?void 0:e.rolesData.flatMap(t=>t.role)}get selectedAccount(){return this._dataForAccounts.find(e=>e.accountId===this._selectedAccountId)}get selectedRole(){return this.selectedAccount.rolesData.find(e=>e.role.id===this._selectedRoleId).role}get selectedRolePermissions(){var e,t;return(t=(e=this._dataForAccounts.find(o=>o.accountId===this._selectedAccountId))===null||e===void 0?void 0:e.rolesData.find(o=>o.role.id===this._selectedRoleId))===null||t===void 0?void 0:t.role.permissions}get selectedRoleData(){return this.selectedAccount.rolesData.find(e=>e.role.id===this._selectedRoleId)}toggleActiveCard(e){var t;this._selectedAccountId=e,this._selectedRoleId=(t=this._dataForAccounts.find(o=>o.accountId===e))===null||t===void 0?void 0:t.rolesData[0].role.id,this._dataForAccounts.forEach(o=>{o.accountId!==e?o.active=!1:o.active=!0}),this.roleTabComponent.setActiveRole(this._selectedRoleId),this.setInitialRole(),this.requestUpdate()}setInitialRole(){this.availableRoles&&this.availableRoles.length>0&&(this._selectedRoleId=this.availableRoles[0].id)}dispatchOpenAddAccountRole(){this.addRoleDialog.handleOpenDialog()}dispatchTabControl(e){this._selectedRoleId=this.roles[e].id,this.roleTabComponent.setActiveRole(this._selectedRoleId)}addRole(e){var t;const o=this.selectedAccount.rolesData.findIndex(i=>i.role.id===e);if(this.selectedAccount.rolesData[o].role.permissions.every(i=>i.isNonLocation)){const i=this.selectedAccount.rolesData[o].genericTreeView;if(!(!((t=i==null?void 0:i.children)===null||t===void 0)&&t.length))return;const n=i.children[0];n.checked=!0,be(n,i),this.selectedAccount.rolesData[o].locations.push(n)}else this.selectedAccount.rolesData[o].locations=[];this.selectedAccount.rolesData[o].role.removed=!1,this.requestUpdate(),this.dispatchTabControl(o),this.addRoleDialog.handleCancelChanges()}dispatchRemoveRoleEvent(){const e=this.roles.findIndex(o=>o.id===this._selectedRoleId);this.roles[e].removed=!0;const t=this.selectedAccount.rolesData.findIndex(o=>o.role.id===this._selectedRoleId);this.selectedAccount.rolesData[t].locations=[],this.selectedAccount.rolesData[t].role.removed=!0,this.selectedAccount.rolesData[t].genericTreeView&&$t(this.selectedAccount.rolesData[t].genericTreeView),this.validateStep(),this.setInitialRole(),this.requestUpdate()}renderTree(){const e=this._dataForAccounts.find(n=>n.accountId===this._selectedAccountId),t=e==null?void 0:e.rolesData.find(n=>n.role.id===this._selectedRoleId);if(!t)return y;const o={role:t.role.id,rootNode:t.genericTreeView},i=n=>{this.requestUpdate();const{updates:a}=n.detail.message,s=a.find(l=>l.key===t.role.id);s!=null&&s.items?t.locations=s.items.filter(l=>l.checked):t.locations=[],this.validateStep(),this.dispatchUpdateDFAEvent(),this.dispatchNextButtonToggleEvent()};if(o&&o.rootNode){const n=t==null?void 0:t.role.permissions.every(a=>a.isNonLocation);return c`<user-details-assignments .assignment="${o}" .contact="${this.contact}" .accountNumber="${e==null?void 0:e.accountId}" @check-toggle="${i}" ?disableTree="${n}"></user-details-assignments>`}return y}validateStep(){let e=!0;for(const t of this._dataForAccounts)if(!t.rolesData.filter(o=>o.role.removed===!1).every(o=>o.locations.length)){e=!1;break}this._nextButtonEnabled=e}renderRoles(){var e,t;return c` <user-details-tab-roles id="role-data-element" .assignedRoles="${this.availableRoles}" .activeRoleId="${(e=this._selectedRoleId)!==null&&e!==void 0?e:""}" .canRemoveRoles="${!0}" .removeRolesDisabled="${((t=this.availableRoles)===null||t===void 0?void 0:t.length)<=1}" .canAddRoles="${!0}" .addRolesDisabled="${this.canAddRolesDisabled}" @role-select="${o=>this._selectedRoleId=o.detail.roleId}" @open-role-menu="${()=>this.dispatchOpenAddAccountRole()}" @open-remove-role-menu="${()=>this.removeRoleDialogOpen=!0}"></user-details-tab-roles> `}renderAddAccountRoleConfirmation(){var e;return c`<add-account-role id="add-role-dialog" .contact="${this.contact}" .account="${yi((e=this.selectedAccount)===null||e===void 0?void 0:e.accountId)||""}" .assignedRoles="${this.availableRoles}" .roles="${this.roles}" @add-role="${t=>this.addRole(t.detail.roleId)}"> </add-account-role>`}renderRemoveRoleConfirmation(){return c`<changes-confirmation id="remove-role-dialog" ?isOpen="${this.removeRoleDialogOpen}" .headerText="${"Are you sure you want to remove this role?"}" .bodyText="${"The user will no longer be able to perform the permissions of this role for this account."}" .confirmationButtonText="${"Remove Role"}" @confirm="${()=>{this.dispatchRemoveRoleEvent(),this.validateStep(),this.removeRoleDialogOpen=!1}}" @cancel="${()=>this.removeRoleDialogOpen=!1}"> </changes-confirmation>`}renderControls(){return c` <div class="controls"> <div class="flex justify-between py-2 items-center permissions-locations"> ${this.renderViewPermissionsButton()} <div class="flex items-center">${this.renderLocationsCount()}</div> </div> <div class="next-control"> <ix-button id="next-button" type="submit" has-icon trailing-icon ?disabled="${!this._nextButtonEnabled}" @click="${()=>{this.dispatchNextStepEvent()}}" data-testid="step-four-next-button"> Next <md-icon slot="icon">east</md-icon> </ix-button> </div> </div> `}renderPermissionsDialog(){var e,t;return c` <ix-dialog ?open="${this.showPermissionsDialog}" @close="${()=>this.showPermissionsDialog=!1}"> <div class="dlr-text-heading" slot="headline">${this.selectedRole.name}</div> <div class="permissions-content" slot="content"> <user-details-permission inPermissionsDialog .permissionData="${(t=Pt((e=this.selectedRolePermissions)!==null&&e!==void 0?e:[]))!==null&&t!==void 0?t:[]}"> </user-details-permission> </div> <div class="dialog-actions" slot="actions"> <ix-button appearance="text" @click="${this.togglePermissionsDialog}" slot="secondary"><span class="dismiss-btn">Dismiss</span></ix-button> </div> </ix-dialog> `}togglePermissionsDialog(){this.showPermissionsDialog=!this.showPermissionsDialog}renderViewPermissionsButton(){return c` <div class="tree-view-permissions"> <ix-button class="temp-button view-permissions" appearance="text" @click="${this.togglePermissionsDialog}"> View Permissions </ix-button> </div> `}renderLocationsCount(){const e=`dlr-text-default font-bold uppercase ${this.noOfLocations?"tree-role-locations-count-active":"tree-role-locations-count"}`;return c`<div class="tree-role-locations"> <span class="${e}"> ${this.noOfLocations?c`${this.noOfLocations} locations`:c`Select Locations`} </span> </div>`}dispatchNextStepEvent(){this.dispatchEvent(new CustomEvent(w.NextStep,{bubbles:!0,composed:!0}))}dispatchNextButtonToggleEvent(){this.dispatchEvent(new CustomEvent(w.NextButtonToggle,{detail:this._nextButtonEnabled,bubbles:!0,composed:!0}))}dispatchValidateStepEvent(){this.dispatchEvent(new CustomEvent(w.ValidateStep,{detail:this._nextButtonEnabled,bubbles:!0,composed:!0}))}dispatchUpdateDFAEvent(){const e=new CustomEvent(w.UpdateDFA,{detail:{dataForAccounts:this._dataForAccounts},bubbles:!0,composed:!0});this.dispatchEvent(e)}renderAccountTabbingCard(){return c` <account-tabbing-card data-testid="step-four-account-cards" isRoles .dataForAccounts="${this._dataForAccounts}" .selectedAccountId="${this._selectedAccountId}" @toggle-active-card="${e=>this.toggleActiveCard(e.detail.accountId)}"> </account-tabbing-card> `}render(){return c` <div class="wizard-step-content overflow-y-auto h-full max-h-screen md:p-1"> ${this.renderAccountTabbingCard()} <div class="tree-view-container-content">${this.renderRoles()}</div> <div class="controls-container">${this.renderControls()}</div> <div class="tree-view-container-footer">${this.renderTree()}</div> </div> ${this.renderAddAccountRoleConfirmation()} ${this.renderRemoveRoleConfirmation()} ${this.renderPermissionsDialog()} `}};O.styles=[zt,_,ge],r([d({type:Array})],O.prototype,"dataForAccounts",void 0),r([d({type:Array})],O.prototype,"permissions",void 0),r([d({type:String})],O.prototype,"selectedAccountId",void 0),r([d({type:String})],O.prototype,"selectedRoleId",void 0),r([d({type:Object})],O.prototype,"contact",void 0),r([m()],O.prototype,"_dataForAccounts",void 0),r([m()],O.prototype,"_selectedAccountId",void 0),r([m()],O.prototype,"_selectedRoleId",void 0),r([m()],O.prototype,"showPermissionsDialog",void 0),r([m()],O.prototype,"removeRoleDialogOpen",void 0),r([m()],O.prototype,"_nextButtonEnabled",void 0),r([D("#add-role-dialog")],O.prototype,"addRoleDialog",void 0),r([D("#role-data-element")],O.prototype,"roleTabComponent",void 0),r([D("user-details-assignments")],O.prototype,"assignmentTreeComponent",void 0),O=r([A("create-user-step-four")],O);const Ii=$`ix-dialog{--md-dialog-container-color:#fff}ix-icon-button{--md-sys-color-on-surface-variant:var(--md-sys-color-primary)}ix-select{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd;--md-menu-container-color:#fff}ix-select.thick{--md-menu-container-shape:10px}ix-select.slim{--md-outlined-field-bottom-space:2px;--md-outlined-field-top-space:2px}ix-button{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd}ix-button .disabled{color:var(--md-sys-text-color-disabled)}.btn_primary{--md-filled-button-container-color:var(--md-sys-color-primary)}.btn_primary ix-icon{color:var(--md-sys-color-on-primary)}.btn_secondary{--md-filled-button-container-color:var(--md-sys-color-secondary)}.btn_secondary ix-icon{color:var(--md-sys-color-on-secondary)}.btn_tertiary{--md-filled-button-container-color:var(--md-sys-color-tertiary)}.btn_tertiary ix-icon{color:var(--md-sys-color-on-tertiary)}.btn_danger{--md-filled-button-container-color:var(--md-sys-color-error)}.btn_danger ix-icon{color:var(--md-sys-color-on-error)}.icon-btn_primary ix-icon{color:var(--md-sys-color-primary)}.icon-btn_secondary ix-icon{color:var(--md-sys-color-secondary)}.icon-btn_tertiary ix-icon{color:var(--md-sys-color-tertiary)}.icon-btn_danger ix-icon{color:var(--md-sys-color-error)}ix-icon.icon-lg{--ix-icon-font-size:32px}.dialog-form{min-width:500px;display:flex;flex-direction:column;justify-content:space-between;padding:8px 24px 20px}.dialog-form .textfield{width:100%}.dialog-form.sm{min-width:560px}.dialog-form__textbox{padding-top:1rem}.dialog-actions{display:flex;justify-content:flex-end;padding:8px 15px 8px 20px}@media only screen and (min-width:5px) and (max-width:600px){ix-dialog{--md-dialog-container-shape:6px}}@media only screen and (min-width:601px){ix-dialog{--md-dialog-container-shape:3px}}ix-icon-button{--md-sys-color-on-surface-variant:black}`;class de{}de.ACCORDION=e=>`user-flags-accordion-${e}`,de.COMPONENT=e=>`user-flags-${e}`,de.TREE=e=>`user-flags-tree-${e}`,de.ASSIGNMENT_COUNT=e=>`user-flags-assignment-count-${e}`,de.SEARCH_BOX=()=>"search-box";let L=class extends I{constructor(){super(...arguments),this.searchEnabled=!1,this.showCheckboxes=!1,this.disableCheckboxes=!1,this.filledIcons=!1,this.searching=!1,this.searchText="",this.selectedIds=[],this.searchResultCount=0,this.searchResultIndex=0,this.onSearchTextChange=no(async e=>{jt(this.flagTree.rootNode),this.searchText=e.detail.searchText;const t=Vt(this.flagTree.rootNode,e.detail.searchText);t.length&&Ke(this.flagTree.rootNode),this.searchResultCount=t.length;const o=Ti(this.flagTree.rootNode,t);[this.selectedId]=o,this.selectedIds=[...o],this.searchResultIndex=o.indexOf(this.selectedId)+1,this.requestUpdate()},500)}onTreeCheckToggle(e){var t;this.flagTree.updateService&&this.flagTree.updateService.update(e.detail.message.rootNode);const o=this.flagUpdateManager.nodeUpdates.find(i=>i.key===this.flagTree.label);o&&o.item.update(e.detail.message.rootNode),this.dispatchEvent(new CustomEvent(S.CheckToggle,{detail:{message:{...e.detail.message,flagLabel:this.flagTree.label,updates:this.flagUpdateManager.nodeChanges,rootNode:(t=this.flagTree.updateService)===null||t===void 0?void 0:t.nodeUpdates[0]}}})),this.flagTree.rootNode=structuredClone(e.detail.message.rootNode),this.requestUpdate("flagTree")}onSearchNavigation(e){if(!this.selectedIds.length)return;const t=_i(e.detail.direction,this.selectedId,this.selectedIds);this.selectedId=t!=null?t:this.selectedId,this.searchResultIndex=this.selectedIds.indexOf(this.selectedId)+1,this.requestUpdate()}render(){var e;return c` <ix-generic-tree data-testid="${de.TREE(this.flagTree.label)}" ?showCheckboxes="${this.showCheckboxes}" ?filledIcons="${this.filledIcons}" ?disableCheckboxes="${this.disableCheckboxes}" .rootNode="${this.flagTree.rootNode}" .selectedId="${this.selectedId}" .searchText="${this.searchText}" @check-toggle="${t=>this.onTreeCheckToggle(t)}" @search-text-change="${t=>this.onSearchTextChange(t)}" @search-navigation="${t=>this.onSearchNavigation(t)}" ?searchEnabled="${this.searchEnabled&&(((e=this.flagTree.rootNode.children)===null||e===void 0?void 0:e.length)||0)>0}" .searchResultCount="${this.searchResultCount}" .searchResultIndex="${this.searchResultIndex}" searchPlaceholder="Search by Site or Asset Name.."></ix-generic-tree> `}};L.styles=[Ii,_],r([d({type:Object,attribute:!1})],L.prototype,"flagTree",void 0),r([d({type:Boolean})],L.prototype,"searchEnabled",void 0),r([d({type:Boolean})],L.prototype,"showCheckboxes",void 0),r([d({type:Boolean})],L.prototype,"disableCheckboxes",void 0),r([d({type:Boolean})],L.prototype,"filledIcons",void 0),r([d({type:Boolean})],L.prototype,"searching",void 0),r([d({type:String})],L.prototype,"selectedId",void 0),r([d({type:Object})],L.prototype,"flagUpdateManager",void 0),r([m()],L.prototype,"searchText",void 0),r([m()],L.prototype,"selectedIds",void 0),r([m()],L.prototype,"searchResultCount",void 0),r([m()],L.prototype,"searchResultIndex",void 0),L=r([A("user-flag")],L);let Q=class extends I{constructor(){super(...arguments),this.searchEnabled=!1,this.showCheckboxes=!1,this.disableCheckboxes=!1,this.filledIcons=!1,this.searching=!1,this.flags=[],this.flagUpdateManager=new Ci,this._defaultUpdates=[]}reset(){this._defaultUpdates=[],this.flagUpdateManager.reset()}onAccordionToggle(e){!e.detail.isOpen||!this.flags.length||(this.flags.forEach(t=>{t.label!==e.detail.accordionId?t.isOpen=!1:t.isOpen=!0}),this.requestUpdate())}connectedCallback(){var e;if(super.connectedCallback(),this._defaultUpdates=[],!this.contact)return;const t=Gt.get();if(!(!((e=this._defaultUpdates)===null||e===void 0)&&e.length)&&t!=null&&t.accountNumber){const o=`${t.accountNumber}:${this.contact.id}`,i=pt.capture(o);i&&pt.lock(o),this._defaultUpdates=i}}disconnectedCallback(){this.reset()}onTreeCheckToggle(e){this.dispatchEvent(new CustomEvent(S.CheckToggle,{detail:{message:{...e.detail.message,flagLabel:e.detail.message.flagLabel,updates:e.detail.message.updates,rootNode:e.detail.message.rootNode}}}))}getUserFlagAssignmentCount(e){var t;const o=(t=e.rootNode.children)===null||t===void 0?void 0:t.at(0);o&&(o.checkedChildrenCount=eo(o),this.renderAssignmentCount(e))}renderAssignmentCount(e){var t;const o=(t=e.rootNode.children)===null||t===void 0?void 0:t.at(0);return o!=null&&o.checkedChildrenCount?c` <span style="color:#53657a;margin-left:8px" data-testid="${de.ASSIGNMENT_COUNT(e.label)}">${o.checkedChildrenCount}</span> `:y}renderUserFlag(e){var t,o;this.flagUpdateManager.create(e.label);const i=this.flagUpdateManager.nodeUpdates.find(n=>n.key===e.label);return!((t=this._defaultUpdates)===null||t===void 0)&&t.length&&!e.defaultsApplied&&(this._defaultUpdates.forEach(n=>{const a=Je(e.rootNode,n.id);a&&(a.checked=!0,be(a,e.rootNode),i==null||i.item.update(e.rootNode))}),e.defaultsApplied=!0),this.getUserFlagAssignmentCount(e),c` <div class="mb-2"> <ix-accordion ?isOpen="${e.isOpen}" .accordionId="${e.label}" @toggle="${this.onAccordionToggle}" data-testid="${de.ACCORDION(e.label)}"> <p slot="title" class="m-0 pl-1"> ${e.label} ${this.renderAssignmentCount(e)} </p> <div style="padding-left:30px"> <div class="flex items-center"> <p class="dlr-text-small"> ${((o=le.find(n=>n.text===e.label))===null||o===void 0?void 0:o.desc)||""} </p> <ix-progress .linear="${!1}" .indeterminate="${!0}" style="visibility:${this.searching?"visible":"hidden"}"></ix-progress> </div> <user-flag data-testid="${de.COMPONENT(e.label)}" ?showCheckboxes="${this.showCheckboxes}" ?filledIcons="${this.filledIcons}" ?disableCheckboxes="${this.disableCheckboxes}" ?searchEnabled="${this.searchEnabled}" .flagTree="${e}" .flagUpdateManager="${this.flagUpdateManager}" @check-toggle="${n=>this.onTreeCheckToggle(n)}"></user-flag> </div> </ix-accordion> </div> `}render(){return c` ${this.flags.map(e=>this.renderUserFlag(e))}`}};Q.styles=[Ii,_],r([d({type:Boolean})],Q.prototype,"searchEnabled",void 0),r([d({type:Boolean})],Q.prototype,"showCheckboxes",void 0),r([d({type:Boolean})],Q.prototype,"disableCheckboxes",void 0),r([d({type:Boolean})],Q.prototype,"filledIcons",void 0),r([d({type:Boolean})],Q.prototype,"searching",void 0),r([d({type:Array,attribute:!1})],Q.prototype,"flags",void 0),r([d({type:Object})],Q.prototype,"contact",void 0),r([m()],Q.prototype,"flagUpdateManager",void 0),r([m()],Q.prototype,"_defaultUpdates",void 0),Q=r([A("user-flags")],Q);const Ei=$`ix-dialog{--md-dialog-container-color:#fff}ix-icon-button{--md-sys-color-on-surface-variant:var(--md-sys-color-primary)}ix-select{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd;--md-menu-container-color:#fff}ix-select.thick{--md-menu-container-shape:10px}ix-select.slim{--md-outlined-field-bottom-space:2px;--md-outlined-field-top-space:2px}ix-button{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd}ix-button .disabled{color:var(--md-sys-text-color-disabled)}.btn_primary{--md-filled-button-container-color:var(--md-sys-color-primary)}.btn_primary ix-icon{color:var(--md-sys-color-on-primary)}.btn_secondary{--md-filled-button-container-color:var(--md-sys-color-secondary)}.btn_secondary ix-icon{color:var(--md-sys-color-on-secondary)}.btn_tertiary{--md-filled-button-container-color:var(--md-sys-color-tertiary)}.btn_tertiary ix-icon{color:var(--md-sys-color-on-tertiary)}.btn_danger{--md-filled-button-container-color:var(--md-sys-color-error)}.btn_danger ix-icon{color:var(--md-sys-color-on-error)}.icon-btn_primary ix-icon{color:var(--md-sys-color-primary)}.icon-btn_secondary ix-icon{color:var(--md-sys-color-secondary)}.icon-btn_tertiary ix-icon{color:var(--md-sys-color-tertiary)}.icon-btn_danger ix-icon{color:var(--md-sys-color-error)}ix-icon.icon-lg{--ix-icon-font-size:32px}.dialog-form{min-width:500px;display:flex;flex-direction:column;justify-content:space-between;padding:8px 24px 20px}.dialog-form .textfield{width:100%}.dialog-form.sm{min-width:560px}.dialog-form__textbox{padding-top:1rem}.dialog-actions{display:flex;justify-content:flex-end;padding:8px 15px 8px 20px}@media only screen and (min-width:5px) and (max-width:600px){ix-dialog{--md-dialog-container-shape:6px}}@media only screen and (min-width:601px){ix-dialog{--md-dialog-container-shape:3px}}.user-details-header-text{margin-bottom:10px}.user-details-row{display:grid;grid-template-columns:1fr 1fr}.row-label{color:rgba(9,34,65,.7);word-break:break-word;width:192px}.row-value{color:#092241;overflow-wrap:anywhere}.user-details-body{display:flex;gap:10px;flex-direction:column}.arrow-forward-icon{padding-left:6px}.access-summary-header,.user-details-header{display:flex;flex-direction:row;align-items:center;justify-content:space-between}ix-divider{margin-top:30px;margin-bottom:30px}.user-flag-information{margin-left:5px}.user-flag-learn-text{padding-bottom:20px}.user-flag-learn-text-link{color:#1456e0}.user-flag-evacuation{vertical-align:top;line-height:18px}.evacuation-label{padding-left:8px;vertical-align:top}.evacuation-text{text-align:justify;padding-left:5px;padding-top:10px;padding-bottom:30px;color:#092241;margin-right:40px}.flags-description ix-button{margin-top:.5rem;width:112px}ix-button{font-family:var(--root-secondary-font)}@media only screen and (max-width:600px){.flags-description{flex-direction:column-reverse;text-align:center}.flags-description p{text-align:left}.evacuation-text{margin-right:0}.flags-description ix-button{display:block}.subheading-container{flex-direction:column;align-items:start;gap:.75rem}.submit-btn{width:100%}.user-details-row{grid-template-columns:1fr}.step-five-next-container{display:flex;justify-content:center}}ix-phone-number{--ix-phone-number-font-size:16px;--ix-phone-number-text-color:#092241}`;let ne=class extends I{constructor(){super(...arguments),this.dataForAccounts=[],this.evacAssistanceRequired=!1,this._dataForAccounts=[]}get selectedAccount(){return this._dataForAccounts.find(e=>e.accountId===this._selectedAccountId)}connectedCallback(){super.connectedCallback(),this._dataForAccounts=this.dataForAccounts,this._selectedAccountId=this.selectedAccountId}setSelectedFlag(e){this._selectedFlagId=e}setInitialFlag(){this._selectedFlagId=le[0].key}toggleActiveCard(e){this._selectedAccountId=e;const t=this._dataForAccounts.find(o=>o.accountId===e);t&&t.genericFlagsData&&(this._selectedFlagId=Nt(t.genericFlagsData[0].label)),this.setSelectedFlag(this._selectedFlagId),this.setInitialFlag(),this.requestUpdate()}dispatchNextStepEvent(){this.dispatchEvent(new CustomEvent(w.NextStep,{bubbles:!0,composed:!0}))}renderAccountTabbingCard(){return c` <account-tabbing-card data-testid="step-five-account-cards" .dataForAccounts="${this._dataForAccounts}" .selectedAccountId="${this._selectedAccountId}" @toggle-active-card="${e=>this.toggleActiveCard(e.detail.accountId)}"> </account-tabbing-card> `}renderElevatedNextButton(){return c` <div class="flex justify-between flags-description"> <p style="max-width:550px" class="dlr-text-caption evacuation-text"> The locations chosen for this account's Portal access will automatically default selections for the user flags listed below. You have the flexibility to modify these selections by deselecting specific locations and choosing others as needed. </p> <div class="step-five-next-container"> <ix-button type="submit" has-icon trailing-icon @click="${this.dispatchNextStepEvent}" data-testid="step-five-next-button"> <span class="uppercase font-bold tracking-wider">Next</span> <md-icon slot="icon">east</md-icon> </ix-button> </div> </div> `}renderUserFlags(){var e,t;const o=i=>{var n;const a=(n=structuredClone(i.detail.message.updates))!==null&&n!==void 0?n:[];this.selectedAccount&&a.forEach(s=>{const l=this.selectedAccount.flagData.findIndex(p=>p.key===s.key);l>-1?this.selectedAccount.flagData[l]=structuredClone(s):this.selectedAccount.flagData.push(s)}),this.dispatchEvent(new CustomEvent(w.UpdateFlags,{bubbles:!0}))};return c` <user-flags class="grid grid-cols-1 gap-3" showCheckboxes filledIcons searchEnabled .flags="${(t=(e=this.selectedAccount)===null||e===void 0?void 0:e.genericFlagsData)!==null&&t!==void 0?t:[]}" @check-toggle="${o}" data-testid="step-five-user-flags"></user-flags> `}render(){return c` <div class="wizard-step-content"> ${this.renderAccountTabbingCard()} ${this.renderElevatedNextButton()} ${this.renderUserFlags()} </div> `}};ne.styles=[Ei,_,ge],r([d({type:Object})],ne.prototype,"newContact",void 0),r([d({type:Array})],ne.prototype,"dataForAccounts",void 0),r([d({type:String})],ne.prototype,"selectedAccountId",void 0),r([d({type:Boolean,reflect:!0})],ne.prototype,"evacAssistanceRequired",void 0),r([m()],ne.prototype,"_dataForAccounts",void 0),r([m()],ne.prototype,"_selectedAccountId",void 0),r([m()],ne.prototype,"_selectedFlagId",void 0),ne=r([A("create-user-step-five")],ne);class k{}k.SUCCESS_CREATED="create-user-success",k.SUCCESS_ICON="create-user-success-icon",k.USER_DETAILS="create-user-success-details",k.SUCCESS_MESSAGE="create-user-success-message",k.VIEW_USER="view-user-button",k.BACK_TO_USERS="back-to-users-button",k.S6={DETAILS_HEADER:"s6-details-header",DETAILS_BODY:"s6-details-body",DETAILS_FIRST_NAME:"s6-details-first-name",DETAILS_LAST_NAME:"s6-details-last-name",DETAILS_EMAIL:"s6-details-email",DETAILS_PHONE:"s6-details-phone",PORTAL_TREE:"s6-portal-tree",FLAG_TREE:"s6-flag-tree",TAB_PORTAL:"s6-tab-portal",TAB_FLAGS:"s6-tab-flags"};let q=class extends I{constructor(){super(...arguments),this.newContact={},this.dataForAccounts=[],this.attachments=[],this.obofSelections=new Map,this.obofEnabled=!1,this.submitting=!1,this.hideContactDetails=!1,this._readonlyTreeViews=[],this._readonlyUserFlags=[],this._selectedTab="roles-and-portal-access",this._isFirstLoad=!0}connectedCallback(){super.connectedCallback(),this._readonlyTreeViews=this.generateReadOnlyTreeViews(),this._readonlyUserFlags=this.generateReadOnlyUserFlags()}isTabActive(e){return this._isFirstLoad?y:this._selectedTab===e}generateReadOnlyTreeViews(){const e=[];return this.dataForAccounts.forEach(t=>{let o=[];t.rolesData.forEach(i=>{if(!i.role.removed){const n=to(i.genericTreeView),a=oo(structuredClone(n));io(a),o.push({role:i.role.name,tree:a})}}),e.push({accountId:t.accountId,accountName:t.accountName,roleTrees:o}),o=[]}),e}generateReadOnlyUserFlags(){const e=[];return this.dataForAccounts.forEach(t=>{let o=[];t.genericFlagsData&&(t.genericFlagsData.forEach(i=>{const n=to(i.rootNode),a=oo(structuredClone(n));io(a),o.push({label:i.label,rootNode:a,isOpen:!1})}),e.push({accountName:t.accountName,flagTrees:o}),o=[])}),e}renderUserDetails(){return c` <div class="user-details"> <div class="user-details-header" data-testid="${k.S6.DETAILS_HEADER}"> <div class="user-details-header-text">User Details</div> <ix-icon-button class="icon-btn_primary" filledIcon icon="edit" ?disabled="${this.submitting}" @click="${()=>this.dispatchSetStepEvent(1)}"></ix-icon-button> </div> <div class="user-details-body" data-testid="${k.S6.DETAILS_BODY}"> <div class="user-details-row"> <div class="dlr-text-default row-label">First Name</div> <div class="dlr-text-default row-value" data-testid="${k.S6.DETAILS_FIRST_NAME}"> ${this.newContact.firstName} </div> </div> <div class="user-details-row"> <div class="dlr-text-default row-label">Last Name</div> <div class="dlr-text-default row-value" data-testid="${k.S6.DETAILS_LAST_NAME}"> ${this.newContact.lastName} </div> </div> <div class="user-details-row"> <div class="dlr-text-default row-label">Email Address</div> <div class="dlr-text-default row-value" data-testid="${k.S6.DETAILS_EMAIL}"> ${this.newContact.email} </div> </div> <div class="user-details-row"> <div class="dlr-text-default row-label">Phone</div> <ix-phone-number data-testid="${k.S6.DETAILS_PHONE}" .number="${this.newContact.phone}"></ix-phone-number> </div> </div> </div> `}renderTabs(){return c` <ix-tabs> <ix-primary-tab @click="${()=>{this._selectedTab="roles-and-portal-access",this._isFirstLoad=!1}}" ?active="${this.isTabActive("roles-and-portal-access")}" data-testid="${k.S6.TAB_PORTAL}"> <span style="${this._selectedTab==="roles-and-portal-access"?"":"color: #092241; opacity: 60%;"}" class="flex items-center uppercase font-bold tracking-wide"> Roles and Portal Access </span> </ix-primary-tab> <ix-primary-tab @click="${()=>{this._selectedTab="user-flags",this._isFirstLoad=!1}}" ?active="${this.isTabActive("user-flags")}" data-testid="${k.S6.TAB_FLAGS}"> <span style="${this._selectedTab==="user-flags"?"":"color: #092241; opacity: 60%;"}" class="flex items-center uppercase font-bold tracking-wide">User Flags</span></ix-primary-tab> </ix-tabs> `}renderObofSummaryRows(e){if(!this.obofEnabled)return y;const t=this.obofSelections.get(e);return c` <div class="user-details-row pt-1"> <div class="dlr-text-default row-label" style="white-space:nowrap"> Created on Behalf of Name </div> <div class="dlr-text-default row-value">${(t==null?void 0:t.name)||"-"}</div> </div> <div class="user-details-row"> <div class="dlr-text-default row-label" style="white-space:nowrap"> Created on Behalf of Email </div> <div class="dlr-text-default row-value">${(t==null?void 0:t.email)||"-"}</div> </div> `}renderAttachmentsSummaryRow(){return this.attachments.length?c` <div class="user-details-row pt-1"> <div class="dlr-text-default row-label">Attachments</div> <div class="row-value flex flex-wrap gap-2"> ${this.attachments.map(e=>c`<span class="px-2 py-1 bg-[#f0f5ff] text-[#092241]">${e.name}</span>`)} </div> </div> `:y}renderRolesAndPortalAccessSummary(){return this._selectedTab!=="roles-and-portal-access"?y:c` <div class="py-4"> ${this._readonlyTreeViews.map(e=>c` <div> <h4 class="pt-1 pb-3">${e.accountName}</h4> ${this.renderObofSummaryRows(e.accountId)} ${this.renderAttachmentsSummaryRow()} ${e.roleTrees.map(t=>c` <div class="pb-2"> <div class="pb-1">${t.role}</div> <ix-generic-tree filledIcons .rootNode="${t.tree}" data-testid="${k.S6.PORTAL_TREE}"></ix-generic-tree> </div> `)} </div>`)} </div> `}renderUserFlagsSummary(){return this._selectedTab!=="user-flags"?y:c`<div> ${this._readonlyUserFlags.map(e=>c` <div class="py-2"> <h4 class="font-bold pb-2">${e.accountName}</h4> <user-flags filledIcons disableCheckboxes .flags="${e.flagTrees}" data-testid="${k.S6.FLAG_TREE}"></user-flags> </div>`)} </div>`}renderLearnMoreText(){return this._selectedTab==="user-flags"?c` <div style="padding-top:15px"> Learn more about user flags <a class="user-flag-learn-text-link" href="#">here.</a> </div> `:c` <div style="padding-top:15px" class="text-black roles-and-portal-access-text"> Learn more about roles and portal access <a class="user-flag-learn-text-link" href="#">here.</a> </div> `}dispatchSetStepEvent(e){this.dispatchEvent(new CustomEvent(w.SetStep,{detail:{step:e},bubbles:!0,composed:!0}))}render(){return c` <div class="wizard-step-content overflow-y-auto overflow-x-hidden md:p-1"> ${this.hideContactDetails?y:c`${this.renderUserDetails()}<ix-divider></ix-divider>`} ${this.renderTabs()} ${this.renderLearnMoreText()} ${this.renderRolesAndPortalAccessSummary()} ${this.renderUserFlagsSummary()} </div> `}};q.styles=[Ei,_,ge],r([d({type:Object})],q.prototype,"newContact",void 0),r([d({type:Array})],q.prototype,"dataForAccounts",void 0),r([d({type:Array})],q.prototype,"attachments",void 0),r([d({type:Object})],q.prototype,"obofSelections",void 0),r([d({type:Boolean})],q.prototype,"obofEnabled",void 0),r([d({type:Boolean})],q.prototype,"submitting",void 0),r([d({type:Boolean})],q.prototype,"hideContactDetails",void 0),r([m()],q.prototype,"_readonlyTreeViews",void 0),r([m()],q.prototype,"_readonlyUserFlags",void 0),r([m()],q.prototype,"_selectedTab",void 0),r([m()],q.prototype,"_isFirstLoad",void 0),q=r([A("create-user-step-six")],q);const Kr=$`ix-dialog{--md-dialog-container-color:#fff}ix-icon-button{--md-sys-color-on-surface-variant:var(--md-sys-color-primary)}ix-select{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd;--md-menu-container-color:#fff}ix-select.thick{--md-menu-container-shape:10px}ix-select.slim{--md-outlined-field-bottom-space:2px;--md-outlined-field-top-space:2px}ix-button{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd}ix-button .disabled{color:var(--md-sys-text-color-disabled)}.btn_primary{--md-filled-button-container-color:var(--md-sys-color-primary)}.btn_primary ix-icon{color:var(--md-sys-color-on-primary)}.btn_secondary{--md-filled-button-container-color:var(--md-sys-color-secondary)}.btn_secondary ix-icon{color:var(--md-sys-color-on-secondary)}.btn_tertiary{--md-filled-button-container-color:var(--md-sys-color-tertiary)}.btn_tertiary ix-icon{color:var(--md-sys-color-on-tertiary)}.btn_danger{--md-filled-button-container-color:var(--md-sys-color-error)}.btn_danger ix-icon{color:var(--md-sys-color-on-error)}.icon-btn_primary ix-icon{color:var(--md-sys-color-primary)}.icon-btn_secondary ix-icon{color:var(--md-sys-color-secondary)}.icon-btn_tertiary ix-icon{color:var(--md-sys-color-tertiary)}.icon-btn_danger ix-icon{color:var(--md-sys-color-error)}ix-icon.icon-lg{--ix-icon-font-size:32px}.dialog-form{min-width:500px;display:flex;flex-direction:column;justify-content:space-between;padding:8px 24px 20px}.dialog-form .textfield{width:100%}.dialog-form.sm{min-width:560px}.dialog-form__textbox{padding-top:1rem}.dialog-actions{display:flex;justify-content:flex-end;padding:8px 15px 8px 20px}@media only screen and (min-width:5px) and (max-width:600px){ix-dialog{--md-dialog-container-shape:6px}}@media only screen and (min-width:601px){ix-dialog{--md-dialog-container-shape:3px}}.drawer-container{z-index:100;display:flex;flex-direction:row;position:fixed;width:100%;height:100%;top:var(--intraportal-nav-height,0);right:0;background-color:rgba(0,0,0,.5);animation-duration:.25s;animation-name:fadeIn;animation-timing-function:ease-out}.drawer-container-hide{z-index:100;display:flex;flex-direction:row;flex:0 0 auto;position:fixed;width:100vw;height:100vh;top:0;right:0;background-color:rgba(0,0,0,.5);animation-duration:.25s;animation-name:fadeOut;animation-timing-function:ease-out}.drawer-filler{flex:1}aside{padding:32px 40px 40px;border-radius:1rem 0 0 1rem}.drawer-slide-in{width:100vw;max-width:816px;height:calc(100% - var(--intraportal-nav-height,0px));float:right;display:flex;flex-direction:column;background-color:#fff;box-sizing:border-box;animation-duration:.25s;animation-name:slideInFromRight}.drawer-slide-out{width:100vw;max-width:810px;height:100vh;float:right;background-color:#fff;box-sizing:border-box;animation-duration:.25s;animation-name:slideOutToRight}@media screen and (min-width:1024px){.drawer{width:45%}}.drawer-header{display:flex;justify-content:space-between;align-items:center}.drawer-body{flex-grow:1;overflow:hidden}.drawer-header__hide-btn{flex:1}.drawer-header__title{flex:1;text-align:center;flex-grow:1;flex-shrink:0}.drawer-header__close-btn{flex:1}.hide-text{cursor:pointer;user-select:none}.hide-icon{font-weight:700}@keyframes fadeIn{from{opacity:0}to{opacity:1}}@keyframes fadeOut{from{opacity:1}to{opacity:0}}@keyframes slideInFromRight{from{transform:translateX(100%)}to{transform:translateX(0)}}@keyframes slideOutToRight{from{transform:translateX(0)}to{transform:translateX(100%)}}@media screen and (max-width:600px){aside{border-radius:0;padding:1rem}}`,ke={ToggleDialog:"toggle-dialog",ToggleDraft:"toggle-draft",CloseSuccess:"close-success",BlurDrawer:"blur-drawer",DrawerOpened:"drawer-opened",DrawerClosed:"drawer-closed"};let me=class extends I{constructor(){super(...arguments),this.isVisible=!1,this.summaryScreen=!1,this.submitting=!1,this.showMinimiseButton=!1}static get styles(){return[Kr,_]}connectedCallback(){super.connectedCallback(),this.hasUpdated&&this.isVisible&&this.dispatchVisibilityEvent(!0)}disconnectedCallback(){super.disconnectedCallback(),this.isVisible&&this.dispatchVisibilityEvent(!1)}updated(e){super.updated(e),e.has("isVisible")&&(this.isVisible?this.dispatchVisibilityEvent(!0):e.get("isVisible")===!0&&this.dispatchVisibilityEvent(!1))}dispatchVisibilityEvent(e){const t=new CustomEvent(e?ke.DrawerOpened:ke.DrawerClosed,{bubbles:!0,composed:!0,detail:{drawer:this}});(this.isConnected?this:window).dispatchEvent(t)}dispatchDialogToggleEvent(){this.submitting||this.dispatchEvent(new CustomEvent(ke.ToggleDialog,{composed:!0,bubbles:!0}))}dispatchDraftToggleEvent(){var e,t;(e=this.drawer)===null||e===void 0||e.setAttribute("class","drawer-slide-out"),(t=this.drawerContainer)===null||t===void 0||t.setAttribute("class","drawer-container-hide"),setTimeout(()=>{this.dispatchEvent(new CustomEvent(ke.ToggleDraft,{bubbles:!0,composed:!0}))},250)}dispatchBlurEvent(){this.dispatchEvent(new CustomEvent(ke.BlurDrawer,{bubbles:!0,composed:!0}))}dispatchDrawerCloseEvent(){this.dispatchEvent(new CustomEvent(ke.CloseSuccess,{bubbles:!0,composed:!0}))}render(){const e=this.isVisible?"slide-in":"slide-out";return this.isVisible?(document.body.style.overflow="hidden",document.documentElement.style.overflow="hidden",c` <div class="drawer-container" data-testid="ui-um-drawer-container"> <div class="drawer-filler" @click="${this.dispatchBlurEvent}" @keypress="${this.dispatchBlurEvent}"></div> <aside class="drawer-${e}"> <div class="drawer-header"> <div class="drawer-header__hide-btn"> ${!this.summaryScreen&&this.showMinimiseButton?c` <ix-button class="flex w-24" appearance="text" has-icon @click="${this.dispatchDraftToggleEvent}" ?disabled="${this.submitting}" data-testid="hide-drawer-button"> <md-icon class="hide-icon" slot="icon">fullscreen_exit</md-icon> <p class="dlr-text-small hide-text font-bold uppercase">Hide</p> </ix-button> `:y} </div> <div> <slot name="centre-top"></slot> </div> <div class="drawer-header__close-btn"> <div class="float-right"> <ix-icon-button aria-label="Close" icon="close" @click="${this.summaryScreen?this.dispatchDrawerCloseEvent:this.dispatchDialogToggleEvent}" data-testid="close-drawer-icon"></ix-icon-button> </div> </div> </div> <div class="drawer-body"> <slot name="content"></slot> </div> </aside> </div> `):(document.body.style.overflow="auto",document.documentElement.style.overflow="initial",y)}};r([d({type:Boolean})],me.prototype,"isVisible",void 0),r([d({type:Boolean})],me.prototype,"summaryScreen",void 0),r([d({type:Boolean})],me.prototype,"submitting",void 0),r([d({type:Boolean})],me.prototype,"showMinimiseButton",void 0),r([D("aside")],me.prototype,"drawer",void 0),r([D(".drawer-container")],me.prototype,"drawerContainer",void 0),me=r([A("ui-um-drawer")],me);const Zr=$`ix-dialog{--md-dialog-container-color:#fff}ix-icon-button{--md-sys-color-on-surface-variant:var(--md-sys-color-primary)}ix-select{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd;--md-menu-container-color:#fff}ix-select.thick{--md-menu-container-shape:10px}ix-select.slim{--md-outlined-field-bottom-space:2px;--md-outlined-field-top-space:2px}ix-button{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd}ix-button .disabled{color:var(--md-sys-text-color-disabled)}.btn_primary{--md-filled-button-container-color:var(--md-sys-color-primary)}.btn_primary ix-icon{color:var(--md-sys-color-on-primary)}.btn_secondary{--md-filled-button-container-color:var(--md-sys-color-secondary)}.btn_secondary ix-icon{color:var(--md-sys-color-on-secondary)}.btn_tertiary{--md-filled-button-container-color:var(--md-sys-color-tertiary)}.btn_tertiary ix-icon{color:var(--md-sys-color-on-tertiary)}.btn_danger{--md-filled-button-container-color:var(--md-sys-color-error)}.btn_danger ix-icon{color:var(--md-sys-color-on-error)}.icon-btn_primary ix-icon{color:var(--md-sys-color-primary)}.icon-btn_secondary ix-icon{color:var(--md-sys-color-secondary)}.icon-btn_tertiary ix-icon{color:var(--md-sys-color-tertiary)}.icon-btn_danger ix-icon{color:var(--md-sys-color-error)}ix-icon.icon-lg{--ix-icon-font-size:32px}.dialog-form{min-width:500px;display:flex;flex-direction:column;justify-content:space-between;padding:8px 24px 20px}.dialog-form .textfield{width:100%}.dialog-form.sm{min-width:560px}.dialog-form__textbox{padding-top:1rem}.dialog-actions{display:flex;justify-content:flex-end;padding:8px 15px 8px 20px}@media only screen and (min-width:5px) and (max-width:600px){ix-dialog{--md-dialog-container-shape:6px}}@media only screen and (min-width:601px){ix-dialog{--md-dialog-container-shape:3px}}.wizard-body{overflow:hidden;height:100%}.wizard-footer{float:right}.form{height:100%}`,Jt={UpdateForm:"update-form",NextStepWizard:"next-step-wizard",PrevStep:"prev-step-wizard",ButtonToggle:"button-toggle"};let Kt=class extends I{constructor(){super(...arguments),this.updateFormBinding=this.updateForm.bind(this),this.handleSlotChangeBinding=this.handleSlotChange.bind(this),this.wizardForm=new FormData}static get styles(){return[Zr,_]}connectedCallback(){super.connectedCallback(),window.addEventListener(Jt.UpdateForm,this.updateFormBinding)}disconnectedCallback(){var e;super.disconnectedCallback(),window.removeEventListener(Jt.UpdateForm,this.updateFormBinding);const t=(e=this.shadowRoot)===null||e===void 0?void 0:e.querySelector("slot");t&&t.removeEventListener("slotchange",this.handleSlotChangeBinding)}firstUpdated(){var e;const t=(e=this.shadowRoot)===null||e===void 0?void 0:e.querySelector("slot");t&&t.addEventListener("slotchange",this.handleSlotChangeBinding)}updateForm(e){e.detail.forEach((t,o)=>this.wizardForm.set(o,t))}handleSlotChange(){var e;const t=(e=this.shadowRoot)===null||e===void 0?void 0:e.querySelector("slot");t&&t.assignedElements().forEach(o=>{o.wizardForm=this.wizardForm})}dispatchButtonToggleEvent(e){this.dispatchEvent(new CustomEvent(Jt.ButtonToggle,{detail:e,bubbles:!0,composed:!0}))}render(){return c` <div class="wizard-body"> <form class="form"> <slot name="wizard-content"></slot> </form> </div> `}};r([d({type:Object})],Kt.prototype,"wizardForm",void 0),Kt=r([A("ui-um-wizard")],Kt);const Wr=$`ix-dialog{--md-dialog-container-color:#fff}ix-icon-button{--md-sys-color-on-surface-variant:var(--md-sys-color-primary)}ix-select{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd;--md-menu-container-color:#fff}ix-select.thick{--md-menu-container-shape:10px}ix-select.slim{--md-outlined-field-bottom-space:2px;--md-outlined-field-top-space:2px}ix-button{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd}ix-button .disabled{color:var(--md-sys-text-color-disabled)}.btn_primary{--md-filled-button-container-color:var(--md-sys-color-primary)}.btn_primary ix-icon{color:var(--md-sys-color-on-primary)}.btn_secondary{--md-filled-button-container-color:var(--md-sys-color-secondary)}.btn_secondary ix-icon{color:var(--md-sys-color-on-secondary)}.btn_tertiary{--md-filled-button-container-color:var(--md-sys-color-tertiary)}.btn_tertiary ix-icon{color:var(--md-sys-color-on-tertiary)}.btn_danger{--md-filled-button-container-color:var(--md-sys-color-error)}.btn_danger ix-icon{color:var(--md-sys-color-on-error)}.icon-btn_primary ix-icon{color:var(--md-sys-color-primary)}.icon-btn_secondary ix-icon{color:var(--md-sys-color-secondary)}.icon-btn_tertiary ix-icon{color:var(--md-sys-color-tertiary)}.icon-btn_danger ix-icon{color:var(--md-sys-color-error)}ix-icon.icon-lg{--ix-icon-font-size:32px}.dialog-form{min-width:500px;display:flex;flex-direction:column;justify-content:space-between;padding:8px 24px 20px}.dialog-form .textfield{width:100%}.dialog-form.sm{min-width:560px}.dialog-form__textbox{padding-top:1rem}.dialog-actions{display:flex;justify-content:flex-end;padding:8px 15px 8px 20px}@media only screen and (min-width:5px) and (max-width:600px){ix-dialog{--md-dialog-container-shape:6px}}@media only screen and (min-width:601px){ix-dialog{--md-dialog-container-shape:3px}}:host{display:block;height:100%;min-height:0}.wizard-step-form{display:flex;flex-direction:column;height:100%;min-height:0}.wizard-step-form>*{min-height:0}.step{overflow:auto}.wizard-step__btn-group{padding:20px 0;float:right}.input-group{display:flex;flex-direction:row;gap:20px;margin-bottom:20px}.input-group ix-phone-input,.input-group ix-textbox{flex:1}.textfield{width:100%}.subheading-container{display:flex;flex-direction:row;justify-content:space-between;align-items:center;margin-bottom:36px;margin-top:24px}.submit-btn{width:167.44px}.submit-btn-content{display:flex;align-items:center;flex-direction:row;justify-content:space-between}@media screen and (max-width:600px){.input-group{display:block;flex-direction:row;gap:20px;margin-bottom:20px}.input-group ix-phone-input,.input-group ix-textbox{flex:1}}`;let ue=class extends I{constructor(){super(...arguments),this.handleSlotChangeBinding=this.handleSlotChange.bind(this),this.stepTitle="",this.stepSubTitle="",this.isRequired=!1,this.isLastStep=!1,this.submitting=!1}static get styles(){return[Wr,$e,_]}disconnectedCallback(){var e;super.disconnectedCallback();const t=(e=this.shadowRoot)===null||e===void 0?void 0:e.querySelector("slot");t&&t.removeEventListener("slotchange",this.handleSlotChangeBinding)}firstUpdated(){var e;const t=(e=this.shadowRoot)===null||e===void 0?void 0:e.querySelector("slot");t&&t.addEventListener("slotchange",this.handleSlotChangeBinding),this.firstFocusableElement.focus()}handleSlotChange(){var e,t;const o=(e=this.shadowRoot)===null||e===void 0?void 0:e.querySelector("slot");for(const i of o.assignedNodes())(t=this.form)===null||t===void 0||t.insertBefore(i,o)}dispatchSubmitEvent(e){e.preventDefault(),this.dispatchEvent(new CustomEvent(w.CreateContact,{bubbles:!0,composed:!0}))}render(){return c` <form class="wizard-step-form" @keydown="${e=>{e.key==="Escape"&&(e.stopPropagation(),e.preventDefault(),this.dispatchEvent(new CustomEvent("close-wizard",{detail:{originElement:this.firstFocusableElement},bubbles:!0,composed:!0})))}}"> <div class="wizard-step-heading pt-6"> <h2 class="dlr-text-page-title" data-testid="dlr-text-page-title" tabindex="-1"> ${this.stepTitle} </h2> <div class="subheading-container"> <h3 class="dlr-text-heading" data-testid="dlr-text-heading">${this.stepSubTitle}</h3> ${this.isRequired?c` <span class="dlr-text-small italic required-field">*denotes required field</span> `:y} ${this.isLastStep?c` <ix-button class="submit-btn" has-icon ?submitting="${this.submitting}" @click="${e=>this.dispatchSubmitEvent(e)}" data-testid="wizard-submit-button"> <div class="submit-btn-content"> Yes, Submit <md-icon class="arrow-forward-icon" slot="icon">arrow_forward</md-icon> </div> </ix-button> `:y} </div> </div> <slot></slot> </form> <div tabindex="-1" @focus="${()=>{this.firstFocusableElement.focus()}}"></div> `}};r([D('[tabindex="-1"]')],ue.prototype,"firstFocusableElement",void 0),r([d({type:String})],ue.prototype,"stepTitle",void 0),r([d({type:String})],ue.prototype,"stepSubTitle",void 0),r([d({type:Boolean})],ue.prototype,"isRequired",void 0),r([d({type:Boolean})],ue.prototype,"isLastStep",void 0),r([d({type:Boolean})],ue.prototype,"submitting",void 0),r([D("form")],ue.prototype,"form",void 0),ue=r([A("ui-um-wizard-step")],ue);const Ri=$`ix-dialog{--md-dialog-container-color:#fff}ix-icon-button{--md-sys-color-on-surface-variant:var(--md-sys-color-primary)}ix-select{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd;--md-menu-container-color:#fff}ix-select.thick{--md-menu-container-shape:10px}ix-select.slim{--md-outlined-field-bottom-space:2px;--md-outlined-field-top-space:2px}ix-button{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd}ix-button .disabled{color:var(--md-sys-text-color-disabled)}.btn_primary{--md-filled-button-container-color:var(--md-sys-color-primary)}.btn_primary ix-icon{color:var(--md-sys-color-on-primary)}.btn_secondary{--md-filled-button-container-color:var(--md-sys-color-secondary)}.btn_secondary ix-icon{color:var(--md-sys-color-on-secondary)}.btn_tertiary{--md-filled-button-container-color:var(--md-sys-color-tertiary)}.btn_tertiary ix-icon{color:var(--md-sys-color-on-tertiary)}.btn_danger{--md-filled-button-container-color:var(--md-sys-color-error)}.btn_danger ix-icon{color:var(--md-sys-color-on-error)}.icon-btn_primary ix-icon{color:var(--md-sys-color-primary)}.icon-btn_secondary ix-icon{color:var(--md-sys-color-secondary)}.icon-btn_tertiary ix-icon{color:var(--md-sys-color-tertiary)}.icon-btn_danger ix-icon{color:var(--md-sys-color-error)}ix-icon.icon-lg{--ix-icon-font-size:32px}.dialog-form{min-width:500px;display:flex;flex-direction:column;justify-content:space-between;padding:8px 24px 20px}.dialog-form .textfield{width:100%}.dialog-form.sm{min-width:560px}.dialog-form__textbox{padding-top:1rem}.dialog-actions{display:flex;justify-content:flex-end;padding:8px 15px 8px 20px}@media only screen and (min-width:5px) and (max-width:600px){ix-dialog{--md-dialog-container-shape:6px}}@media only screen and (min-width:601px){ix-dialog{--md-dialog-container-shape:3px}}ix-dialog{position:absolute;z-index:101}.create-user-wizard{height:100%;display:flex;flex-direction:column}.dlr-text-small.step-progress{letter-spacing:1.25px}ix-button{font-family:var(--root-secondary-font)}@media only screen and (max-width:600px){.success-actions{flex-direction:column;width:100%}.success-actions ix-button{display:block;width:100%}}`;function Si(e,t){const o={id:"root",label:"",children:[],customerKnownSpaceName:""},i=new ht,n=structuredClone(e.rolesData.filter(h=>h.locations.length>0).filter(h=>!h.role.removed).flatMap(h=>h.locations)),a=t.data;a&&a.length&&he(a[0],o),n.forEach(h=>{const u=Je(o,h.id);u&&(u.checked=!0,be(u,o),i.update(o))});const s={label:"",isOpen:!1,rootNode:o},l=[],p=le.map(h=>{const u=structuredClone(s);return u.updateService=new ht,u.updateService.updates=structuredClone(i.nodeUpdates),u.label=h.text,l.push({key:h.text,items:structuredClone(i.nodeUpdates)}),u});e.genericFlagsData=[...p],e.flagData=l}const ki=(e,t)=>{var o;const i={expanded:!1,id:e.id,label:(o=e.displayName)!==null&&o!==void 0?o:e.name,parentId:t.id};return e.subaccounts&&(i.children=e.subaccounts.map(n=>ki(n,i))),i},Qr=e=>{const t={expanded:!1,id:"root",label:"",parentId:"",children:[],disabled:!1};return t.children=e.map(o=>ki(o,t)),t};function Ui(e,t){var o;const i={id:e.id,label:(o=e.displayName)!==null&&o!==void 0?o:e.name,parentId:t.id,expanded:!1,checked:!1,indeterminate:!1,children:[]};return e.subaccounts&&(i.children=e.subaccounts.map(n=>Ui(n,i))),i}function $i(e){const t={id:"root",parentId:"",label:"",expanded:!1,checked:!1,children:[]};return e.forEach(o=>t.children.push(Ui(o,t))),t}const Yr=e=>{const t=ut(e);return Qr(t)};let C=class extends I{constructor(){super(...arguments),this.showDrawer=!1,this.success=!1,this.submitting=!1,this.newUserId="",this.permissions=[],this.roles=[],this.treeData=[],this.loading=!1,this.selectedAccountId="",this.selectedRoleId="",this.step=1,this.validatingStepOne=!1,this.newContact={firstName:"",lastName:"",email:"",phone:"",accounts:[],evacAssistance:!1},this.dataForAccounts=[],this.showManageUserDialog=!1,this.userId="",this.stepTitle="Add New User",this.isNextButtonEnabled=!1,this.canQuickNavigateSteps={1:!1,2:!1,3:!1,4:!1,5:!1,6:!1},this.maxQuickStep=1,this.obofSelections=new Map,this.attachments=[]}connectedCallback(){super.connectedCallback(),this.setupAccountSelector()}get stepOne(){var e,t;return(t=(e=this.renderRoot.querySelector("#step-1"))===null||e===void 0?void 0:e.shadowRoot)===null||t===void 0?void 0:t.querySelector("create-user-step-one")}setupAccountSelector(){const e=Lt().filter(t=>B.hasExternalUserCreate(t.accountNumber));this.accounts=ut(e),this.accountTree=$i(this.accounts),this.permissions=U.getPermissions()}resetStep(){this.handleDialogReset("close")}setStep(e){this.step=e,this.canQuickNavigateSteps={1:!0,2:!0,3:!0,4:!0,5:!0,6:!0}}resetSteps(e){Object.keys(this.canQuickNavigateSteps).forEach(t=>{e.includes(t)||(this.canQuickNavigateSteps={...this.canQuickNavigateSteps,[t]:!1})})}onNextButtonToggle(e){this.isNextButtonEnabled=e.detail,this.step===1?this.canQuickNavigateSteps={...this.canQuickNavigateSteps,1:!1}:this.step===2?this.resetSteps(["1"]):this.step===3?this.resetSteps(["1","2"]):this.step===4?this.resetSteps(["1","2","3"]):this.canQuickNavigateSteps={...this.canQuickNavigateSteps,[this.step]:!1},this.maxQuickStep=this.step}onPrevStep(){this.step!==1&&(this.step===2&&this.collapseAccountTree(),(this.step===5||this.step===6)&&this.collapseLocationTrees(),this.step===6&&(this.isNextButtonEnabled=!0),this.canQuickNavigateSteps[(this.step-1).toString()]=!0,this.maxQuickStep=Math.max(this.maxQuickStep,this.step),this.step-=1)}onQuickNextStep(){this.canQuickNavigateSteps[this.step]&&this.onNextStep()}async onNextStep(){var e;if(this.isNextButtonEnabled){if(this.loading=!0,this.step===1){if(this.collapseAccountTree(),!this.canQuickNavigateSteps[1]){this.validatingStepOne=!0;const t=await this.validateEmail();if(this.validatingStepOne=!1,!t){this.loading=!1;return}}}else if(this.step===2&&!this.canQuickNavigateSteps[2]){if(!this.accountTree)return;const t=((e=this.checkedAccounts)===null||e===void 0?void 0:e.map(a=>a.id))||[],o=await st.getAccountData(t),i=ve.get(),n=pe(this.newContact.email)&&B.hasAssignInternalRoleCreate(U.getAccountNumber());this.roles=[],this.treeData=[];for(let a=0;a<t.length;a+=1){const s=qt(t[a],i,n),l=t[a];this.roles.push({accountId:l,roles:structuredClone(s)}),this.treeData.push({contactId:"",accountNumber:l,roleId:"",data:o[a]})}}else if(this.step===3)this.selectedAccountId=this.dataForAccounts[0].accountId,this.selectedRoleId=this.dataForAccounts[0].rolesData[0].role.id;else if(this.step===4){for(const t of this.dataForAccounts){const o=this.treeData.find(i=>i.accountNumber===t.accountId);o&&Si(t,o)}this.collapseLocationTrees()}else this.step===5&&this.collapseLocationTrees();this.step!==4&&(this.isNextButtonEnabled=!1),this.step+1===this.maxQuickStep&&(this.canQuickNavigateSteps[this.step]=!1),this.loading=!1,this.step+=1}}collapseAccountTree(){this.accountTree&&(this.accountTree.expanded=!1,this.accountTree.children&&this.accountTree.children.forEach(e=>{e.expanded=!1,e.children&&e.children.forEach(t=>{t.expanded=!1})}))}collapseLocationTrees(){this.dataForAccounts.forEach(e=>{var t;e.rolesData.forEach(o=>{Ke(o.genericTreeView)}),(t=e.genericFlagsData)===null||t===void 0||t.forEach(o=>{Ke(o.rootNode)})})}async validateEmail(){const e=await tt.search({email:this.newContact.email.split("@")[0]});return e.contacts.find(t=>t.email===this.newContact.email)?(this.userId=e.contacts[0].id,this.toggleManageUserDialog(),!1):!0}handleDialogReset(e){this.step=1,this.newContact={id:"",firstName:"",lastName:"",email:"",phone:"",accounts:[],evacAssistance:!1},this.setupAccountSelector(),this.stepOne&&(this.stepOne.clearTextFields(),this.stepOne.resetErrorStates(),this.stepOne._nextButtonEnabled=!1),this.dataForAccounts=[],this.obofSelections=new Map,this.attachments=[],this.selectedAccountId="",this.selectedRoleId="",this.canQuickNavigateSteps={1:!1,2:!1,3:!1,4:!1,5:!1,6:!1},this.maxQuickStep=1,this.isNextButtonEnabled=!1,this.dispatchResetSuccessEvent(),e==="toggle"?this.dispatchToggleDrawerEvent():this.dispatchDrawerCloseEvent()}updateAccounts(e){var t;this.accountTree=e.detail.rootNode,!((t=this.accountTree)===null||t===void 0)&&t.children&&(this.checkedAccounts=Be(this.accountTree.children,Et(this.accounts||[])),this.dataForAccounts=[])}updateObofSelections(e){this.obofSelections=e.detail.obofSelections}get obofEnabled(){return Ht()&&!pe(this.newContact.email)}onUpdateContact(e){const t=e.detail.newContact;this.newContact.email!==t.email&&this.newContact.email!==""&&(this.resetSteps(["1"]),this.dataForAccounts=[]),this.newContact=t}renderWizardStep(){switch(this.step){case 1:return c` <ui-um-wizard-step id="step-1" slot="wizard-content" isRequired .stepTitle="${this.stepTitle}" .stepSubTitle="${"User Information"}" data-testid="create-user-step-one"> <create-user-step-one .newContact="${this.newContact}" .validatingForm="${this.validatingStepOne}" @update-contact="${e=>this.onUpdateContact(e)}" @next-step="${this.onNextStep}" @validate-step="${e=>this.isNextButtonEnabled=e.detail}" @next-button-toggle="${e=>this.onNextButtonToggle(e)}"></create-user-step-one> </ui-um-wizard-step> `;case 2:return c` <ui-um-wizard-step slot="wizard-content" isRequired .stepTitle="${this.stepTitle}" .stepSubTitle="${"Accounts*"}" data-testid="create-user-step-two"> <create-user-step-two class="flex flex-col overflow-auto grow" .accountTree="${this.accountTree}" .accountStructure="${Et(this.accounts||[])}" .obofEnabled="${this.obofEnabled}" .obofSelections="${this.obofSelections}" .attachments="${this.attachments}" @update-accounts="${e=>this.updateAccounts(e)}" @update-obof-selections="${e=>this.updateObofSelections(e)}" @update-attachments="${e=>{this.attachments=e.detail.attachments}}" @next-step="${this.onNextStep}" @validate-step="${e=>this.isNextButtonEnabled=e.detail}" @next-button-toggle="${e=>this.onNextButtonToggle(e)}"></create-user-step-two> </ui-um-wizard-step> `;case 3:return c` <ui-um-wizard-step slot="wizard-content" isRequired .stepTitle="${this.stepTitle}" .stepSubTitle="${"Roles"}" data-testid="create-user-step-three"> <create-user-step-three class="flex flex-col overflow-auto grow" .checkedAccounts="${this.checkedAccounts||[]}" .roles="${this.roles}" .dataForAccounts="${this.dataForAccounts}" .treeData="${this.treeData}" @update-dfa="${e=>{this.dataForAccounts=e.detail.dataForAccounts}}" @next-step="${this.onNextStep}" @validate-step="${e=>this.isNextButtonEnabled=e.detail}" @next-button-toggle="${e=>this.onNextButtonToggle(e)}"></create-user-step-three> </ui-um-wizard-step> `;case 4:return c` <ui-um-wizard-step slot="wizard-content" isRequired .stepTitle="${this.stepTitle}" .stepSubTitle="${"Portal Access"}" data-testid="create-user-step-four"> <create-user-step-four class="step" .dataForAccounts="${this.dataForAccounts}" .selectedAccountId="${this.selectedAccountId}" .selectedRoleId="${this.selectedRoleId}" .permissions="${this.permissions}" .contact="${this.newContact}" @update-dfa="${e=>this.dataForAccounts=e.detail.dataForAccounts}" @next-step="${this.onNextStep}" @validate-step="${e=>this.isNextButtonEnabled=e.detail}" @next-button-toggle="${e=>this.onNextButtonToggle(e)}"></create-user-step-four> </ui-um-wizard-step> `;case 5:return c` <ui-um-wizard-step slot="wizard-content" .stepTitle="${this.stepTitle}" .stepSubTitle="${"User Flags"}" data-testid="create-user-step-five"> <create-user-step-five class="step" .dataForAccounts="${this.dataForAccounts}" .selectedAccountId="${this.selectedAccountId}" .evacAssistanceRequired="${this.newContact.evacAssistance}" @evac-assistance-required="${e=>this.newContact.evacAssistance=e.detail}" @update-flags="${()=>this.canQuickNavigateSteps={...this.canQuickNavigateSteps,5:!1}}" @next-step="${this.onNextStep}"> </create-user-step-five> </ui-um-wizard-step> `;case 6:return c` <ui-um-wizard-step isLastStep slot="wizard-content" .stepTitle="${this.stepTitle}" .stepSubTitle="${"Are these details correct?"}" ?submitting="${this.submitting}" @create-contact="${this.dispatchCreateNewContactEvent}" data-testid="create-user-step-six"> <create-user-step-six class="step" .dataForAccounts="${this.dataForAccounts}" .newContact="${this.newContact}" .obofEnabled="${this.obofEnabled}" .obofSelections="${this.obofSelections}" .attachments="${this.attachments}" ?submitting="${this.submitting}" @set-step="${e=>this.setStep(e.detail.step)}"></create-user-step-six> </ui-um-wizard-step> `}return y}renderProgress(){return c`<ix-progress slot="wizard-content" indeterminate></ix-progress>`}renderSuccessMessage(){return c` <div data-testid="${k.SUCCESS_CREATED}" slot="content" class="flex flex-col justify-between items-center pt-40 h-96"> <ix-icon data-testid="${k.SUCCESS_ICON}" style="color:#4caf50;font-size:75px;font-weight:700">check_circle</ix-icon> <span data-testid="${k.USER_DETAILS}" class="text-2xl font-bold pb-5">${this.newContact.firstName} ${this.newContact.lastName} Created</span> <div data-testid="${k.SUCCESS_MESSAGE}" class="pb-5"> ${this.newContact.firstName} ${this.newContact.lastName} has been successfully created. </div> <div class="flex justify-between w-400 success-actions"> <ix-button data-testid="${k.VIEW_USER}" appearance="outlined" @click="${this.handleViewUserRedirect}" class="p-1"><span class="font-bold text-sm tracking-wider uppercase">View user</span></ix-button> <ix-button data-testid="${k.BACK_TO_USERS}" appearance="filled" class="p-1" @click="${()=>this.handleDialogReset("close")}"><span class="font-bold uppercase text-sm tracking-wider">Back to users</span></ix-button> </div> </div> `}handleViewUserRedirect(){this.handleDialogReset("close"),Ye(G.UserManagementDetails,`?id=${this.newUserId}`),this.newUserId=""}renderManageUserDialog(){return c` <ix-dialog ?open="${this.showManageUserDialog}"> <div class="dlr-text-heading" slot="headline"> This user already exists for your Master Account </div> <div class="dialog-actions" slot="actions"> <ix-button appearance="text" @click="${this.handleManageUserDialogClose}" slot="secondary"> Cancel </ix-button> <ix-button appearance="text" @click="${this.handleManageUserRedirect}" slot="primary"> Manage User </ix-button> </div> </ix-dialog> `}toggleManageUserDialog(){this.showManageUserDialog=!this.showManageUserDialog}handleManageUserDialogClose(){this.toggleManageUserDialog(),this.handleDialogReset("close")}handleManageUserRedirect(){this.toggleManageUserDialog(),this.handleDialogReset("close"),Ye(G.UserManagementDetails,`?id=${this.userId}`),this.userId=""}dispatchToggleDrawerEvent(){this.dispatchEvent(new CustomEvent(w.ToggleDrawer,{bubbles:!0,composed:!0}))}dispatchDrawerCloseEvent(){this.dispatchEvent(new CustomEvent(w.CloseDrawer,{bubbles:!0,composed:!0}))}dispatchResetSuccessEvent(){this.dispatchEvent(new CustomEvent(w.ResetSuccess,{bubbles:!0,composed:!0}))}dispatchCreateNewContactEvent(){this.dispatchEvent(new CustomEvent(w.CreateNewContact,{detail:{newContact:this.newContact,dataForAccounts:this.dataForAccounts,attachments:this.attachments,obofSelections:this.obofSelections},bubbles:!0,composed:!0}))}renderDrawerControls(){return c` <div slot="centre-top"> <div class="flex"> ${this.success?y:c` <ix-icon-button class="icon-btn_primary" ?disabled="${this.step===1||this.loading}" @click="${()=>this.onPrevStep()}" icon="chevron_left" data-testid="prev-step-icon"> </ix-icon-button> <span class="dlr-text-small uppercase font-bold pt-[10px] px-2 step-progress" data-testid="step-progress"> ${this.step} of 6 </span> <ix-icon-button style="${this.step===6?"visibility: hidden":""}" class="icon-btn_primary ${this.step===6||!this.isNextButtonEnabled||this.loading?"disabled":""}" ?disabled="${!this.canQuickNavigateSteps[this.step]||this.loading}" @click="${()=>this.onQuickNextStep()}" icon="chevron_right" data-testid="next-step-icon"> </ix-icon-button> `} </div> </div> `}render(){return c` <ui-um-drawer ?isVisible="${this.showDrawer}" ?summaryScreen="${this.success}" ?submitting="${this.submitting}" @close-success="${()=>this.handleDialogReset("close")}" data-testid="ui-um-drawer"> ${this.renderDrawerControls()} ${this.success?this.renderSuccessMessage():c` <ui-um-wizard class="create-user-wizard" slot="content" data-testid="create-user-wizard"> ${this.loading?this.renderProgress():this.renderWizardStep()} </ui-um-wizard> `} </ui-um-drawer> ${this.renderManageUserDialog()} `}};C.styles=[Ri,_,$e],r([d({type:Boolean})],C.prototype,"showDrawer",void 0),r([d({type:Boolean})],C.prototype,"success",void 0),r([d({type:Boolean})],C.prototype,"submitting",void 0),r([d({type:String})],C.prototype,"newUserId",void 0),r([m()],C.prototype,"accounts",void 0),r([m()],C.prototype,"accountTree",void 0),r([m()],C.prototype,"permissions",void 0),r([m()],C.prototype,"roles",void 0),r([m()],C.prototype,"treeData",void 0),r([m()],C.prototype,"loading",void 0),r([m()],C.prototype,"selectedAccountId",void 0),r([m()],C.prototype,"selectedRoleId",void 0),r([m()],C.prototype,"step",void 0),r([m()],C.prototype,"validatingStepOne",void 0),r([m()],C.prototype,"newContact",void 0),r([m()],C.prototype,"dataForAccounts",void 0),r([m()],C.prototype,"showManageUserDialog",void 0),r([m()],C.prototype,"userId",void 0),r([m()],C.prototype,"stepTitle",void 0),r([m()],C.prototype,"isNextButtonEnabled",void 0),r([m()],C.prototype,"canQuickNavigateSteps",void 0),r([m()],C.prototype,"maxQuickStep",void 0),r([m()],C.prototype,"checkedAccounts",void 0),r([m()],C.prototype,"obofSelections",void 0),r([m()],C.prototype,"attachments",void 0),C=r([A("create-user")],C);const Xr=$`.draft-container{display:flex;flex-direction:row;justify-content:space-between;bottom:24px;position:fixed;right:24px;z-index:1200;gap:8px;background-color:#fff;border-radius:16px;box-shadow:rgba(0,0,0,.12) 0 12px 20px -12px,#e1e4e8 0 0 0 1px inset;align-items:center;padding:16px 24px;width:250px}`;let Ve=class extends I{constructor(){super(...arguments),this.header="",this.subText="",this.isVisible=!1}static get styles(){return[Xr]}dispatchDraftToggleEvent(){this.dispatchEvent(new CustomEvent(S.ToggleDraft,{bubbles:!0,composed:!0}))}dispatchDialogToggleEvent(){this.dispatchEvent(new CustomEvent(S.ToggleDialog,{composed:!0}))}render(){return this.isVisible?(document.body.style.overflow="hidden",c` <div class="draft-container"> <div class="draft-text"> <p class="dlr-text-caption text-on-surface-variant">${this.header}</p> <p class="dlr-text-small font-bold">${this.subText}</p> </div> <div class="draft-buttons"> <ix-icon-button filledIcon @click="${this.dispatchDialogToggleEvent}"> <ix-icon filled slot="default" style="color:red">delete</ix-icon> </ix-icon-button> <ix-icon-button appearance="filled" @click="${this.dispatchDraftToggleEvent}"> <ix-icon slot="default">fullscreen</ix-icon> </ix-icon-button> </div> </div> `):(document.body.style.overflow="auto",y)}};r([d({type:String})],Ve.prototype,"header",void 0),r([d({type:String})],Ve.prototype,"subText",void 0),r([d({type:Boolean})],Ve.prototype,"isVisible",void 0),Ve=r([A("ix-draft")],Ve);const Ni=$`ix-dialog .dialog-content{max-width:560px}`,el=e=>({id:e==null?void 0:e.id,firstName:e==null?void 0:e.first_name,lastName:e==null?void 0:e.last_name,email:e==null?void 0:e.email}),tl=e=>({authorityDocumentId:e.authority_document_id,changeHistoryId:e.change_history_id,fileName:e.file_name}),ol=e=>e?{reason:e.reason,authoriserUserId:e.authoriser_user_id,accountNumber:e.account_number}:void 0,il=e=>({reason:e.reason,authoriser_user_id:e.authoriserUserId,account_number:e.accountNumber}),Fi=e=>{var t,o,i;return{authoriserDetails:(t=e.authoriser_details)===null||t===void 0?void 0:t.map(ol).filter(Boolean),changeHistoryId:e.change_history_id,createdBy:el(e.created_by),createdAt:(o=e.created_at)===null||o===void 0?void 0:o.toString(),authorityDocuments:(i=e.authority_documents)===null||i===void 0?void 0:i.map(tl)}},nl=e=>{var t,o,i;return{content:(o=(t=e.content)===null||t===void 0?void 0:t.map(Fi))!==null&&o!==void 0?o:[],continuationToken:(i=e.pageable)===null||i===void 0?void 0:i.continuation_token}},al=e=>({continuationToken:e.continuationToken,sort:e.sort,limit:e.limit,userId:e.userId,accountNumber:e.accountNumber}),sl=e=>{var t;return{changeHistoryRequest:{authoriser_details:(t=e.changeHistoryInput.authoriserDetails)===null||t===void 0?void 0:t.map(il),authority_documents:e.changeHistoryInput.authorityDocuments}}};class rl{async get(t={}){try{const o=al(t),i=await v.ChangeHistoriesApi.getChangeHistory(o);return nl(i)}catch(o){return o.response.status!==404&&g.handleError(o,"Failed to get change histories."),{content:[]}}}async create(t){try{const o=sl(t),i=await v.ChangeHistoriesApi.postChangeHistory(o);return Fi(i)}catch(o){return g.handleError(o,"Failed to create change history."),{}}}}const Di=new rl,ll=(e,t={})=>{const o={...t,userId:e};return Di.get(o)},Pi=e=>{const t={changeHistoryInput:e};return Di.create(t)};let ae=class extends Ue{constructor(){super(...arguments),this.showDrawer=!1,this.showDraft=!1,this.showCancelDialog=!1,this.success=!1,this.newUserId="",this.submittingNewUser=!1,this.cancellingCreateUser=!1}static get styles(){return[Ni,ge,_]}async createNewContact(e){this.submittingNewUser=!0;const t=e.detail.newContact,o=e.detail.dataForAccounts,i=e.detail.attachments||[],n=e.detail.obofSelections||new Map;t.accounts=o.map(({accountId:a})=>({accountNumber:a}));try{const a=Ht()&&!pe(t.email);let s;if(a){const p=i.length?await Qo(i):[],h=Wo(n),u=await Pi({authoriserDetails:h,authorityDocuments:p.length?p:void 0});if(!(u!=null&&u.changeHistoryId))throw new Error("Failed to create change history.");s=u.changeHistoryId}this.newUserId=await this.createContact(t,s);const l=[this.createRoleAssignments(o,t.email,s),this.createUserFlags(o,s)];(await Promise.allSettled(l)).forEach(p=>{if(p.status==="rejected")throw new Error(p.reason)}),this.dispatchTableRefreshEvent(),this.success=!0}catch(a){this.success=!1}finally{this.submittingNewUser=!1}}async createContact(e,t){const o=await tt.create({contactInput:e,changeHistoryId:t});if(!(o!=null&&o.id))throw new Error("Failed to create the new user.");return o.id}async createRoleAssignments(e,t,o){const i=[],n=pe(t);if(e.forEach(({rolesData:a})=>{a.filter(s=>s.role.removed===!1).forEach(s=>{s.locations.forEach(l=>{i.push({roleId:s.role.id,location:l.customerKnownSpaceName,accountNumber:s.accountId,contactId:this.newUserId,isInternal:n})})})}),i.length&&!(await He.create({roleAssignmentInput:i,changeHistoryId:o})).length)throw new Error("Failed to assign role(s) to the new user.")}async createUserFlags(e,t){var o;const i=[];for(const n of e)n.flagData&&((o=n.genericFlagsData)===null||o===void 0||o.forEach(a=>{a.updateService&&a.updateService.updates.forEach(s=>{const l={accountNumber:n.accountId,contactId:this.newUserId,userFlagType:Nt(a.label),location:s.customerKnownSpaceName||""};i.push(l)})}));if(i.length&&!(await ze.create({userFlagAssignmentInput:i,changeHistoryId:t})).length)throw new Error("We could not assign the selected flags to the new user.")}dispatchDraftToggleEvent(){this.dispatchEvent(new CustomEvent(w.ToggleDraft,{composed:!0})),this.dispatchDrawerToggleEvent()}dispatchDrawerToggleEvent(){this.dispatchEvent(new CustomEvent(w.ToggleDrawer,{composed:!0}))}dispatchTableRefreshEvent(){document.dispatchEvent(new CustomEvent(S.RefreshTable,{composed:!0}))}toggleDialog(){this.dispatchEvent(new CustomEvent(w.ToggleDialog,{composed:!0,bubbles:!0}))}toggleSuccess(){this.success=!this.success}resetSuccess(){this.success=!1}cancelCreateUser(){this.cancellingCreateUser=!0,setTimeout(()=>{var e;(e=this.createUser)===null||e===void 0||e.resetStep(),this.dispatchEvent(new CustomEvent(w.CancelCreateUser,{composed:!0})),this.cancellingCreateUser=!1},50)}renderCancelDialog(){return c` <ix-dialog ?open="${this.showCancelDialog}" @cancel="${this.toggleDialog}" data-testid="dialog-cancel-add-user"> <div class="dlr-text-heading md:w-[560px]" slot="headline"> Are you sure you want to cancel? </div> <div class="dialog-content" slot="content"> <p>All the details provided will be lost.</p> </div> <div class="dialog-actions" slot="actions"> <ix-button appearance="text" ?disabled="${this.cancellingCreateUser}" @click="${this.toggleDialog}" slot="secondary" data-testid="dismiss-close-create-user-button"> Dismiss </ix-button> <ix-button appearance="text" ?submitting="${this.cancellingCreateUser}" @click="${this.cancelCreateUser}" slot="primary" data-testid="cancel-create-user-button"> Cancel adding user </ix-button> </div> </ix-dialog> `}render(){return c` <create-user .newUserId="${this.newUserId}" ?showDrawer="${this.showDrawer}" ?submitting="${this.submittingNewUser}" ?success="${this.success}" @toggle-drawer="${this.dispatchDrawerToggleEvent}" @create-new-contact="${e=>this.createNewContact(e)}" @toggle-success="${this.toggleSuccess}" @reset-success="${this.resetSuccess}" data-testid="um-create-user"></create-user> <ix-draft header="Draft" subText="Add New User" ?isVisible="${this.showDraft}" @toggle-dialog="${this.toggleDialog}"></ix-draft> ${this.renderCancelDialog()} `}};r([d({type:Boolean})],ae.prototype,"showDrawer",void 0),r([d({type:Boolean})],ae.prototype,"showDraft",void 0),r([d({type:Boolean})],ae.prototype,"showCancelDialog",void 0),r([m()],ae.prototype,"success",void 0),r([m()],ae.prototype,"newUserId",void 0),r([m()],ae.prototype,"submittingNewUser",void 0),r([m()],ae.prototype,"cancellingCreateUser",void 0),r([D("create-user")],ae.prototype,"createUser",void 0),ae=r([A("create-user-container")],ae);const Mi=$`ix-dialog{--md-dialog-container-color:#fff}ix-icon-button{--md-sys-color-on-surface-variant:var(--md-sys-color-primary)}ix-select{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd;--md-menu-container-color:#fff}ix-select.thick{--md-menu-container-shape:10px}ix-select.slim{--md-outlined-field-bottom-space:2px;--md-outlined-field-top-space:2px}ix-button{--md-outlined-button-outline-color:var(--md-sys-color-primary);--md-outlined-select-text-field-outline-color:#ddd}ix-button .disabled{color:var(--md-sys-text-color-disabled)}.btn_primary{--md-filled-button-container-color:var(--md-sys-color-primary)}.btn_primary ix-icon{color:var(--md-sys-color-on-primary)}.btn_secondary{--md-filled-button-container-color:var(--md-sys-color-secondary)}.btn_secondary ix-icon{color:var(--md-sys-color-on-secondary)}.btn_tertiary{--md-filled-button-container-color:var(--md-sys-color-tertiary)}.btn_tertiary ix-icon{color:var(--md-sys-color-on-tertiary)}.btn_danger{--md-filled-button-container-color:var(--md-sys-color-error)}.btn_danger ix-icon{color:var(--md-sys-color-on-error)}.icon-btn_primary ix-icon{color:var(--md-sys-color-primary)}.icon-btn_secondary ix-icon{color:var(--md-sys-color-secondary)}.icon-btn_tertiary ix-icon{color:var(--md-sys-color-tertiary)}.icon-btn_danger ix-icon{color:var(--md-sys-color-error)}ix-icon.icon-lg{--ix-icon-font-size:32px}.dialog-form{min-width:500px;display:flex;flex-direction:column;justify-content:space-between;padding:8px 24px 20px}.dialog-form .textfield{width:100%}.dialog-form.sm{min-width:560px}.dialog-form__textbox{padding-top:1rem}.dialog-actions{display:flex;justify-content:flex-end;padding:8px 15px 8px 20px}@media only screen and (min-width:5px) and (max-width:600px){ix-dialog{--md-dialog-container-shape:6px}}@media only screen and (min-width:601px){ix-dialog{--md-dialog-container-shape:3px}}.user-details-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:1.5rem}.edit-icon{font-size:22px;align-items:center;padding-right:1px}.email,.first-name,.last-name{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#edit-profile-id{display:flex;flex-direction:column}.single-row-textbox{width:100%}#edit-profile-id>*{margin:5px 0}ix-textbox,md-textfield{--md-outlined-text-field-width:100%;--md-outlined-text-field-focus-width:100%;width:inherit}.user-profile-name-input-group{display:flex;justify-content:space-between;gap:10px}.user-profile-input{padding-bottom:10px;width:100%}ix-phone-number{--ix-phone-number-font-size:16px;--ix-phone-number-text-color:#092241}`;class cl{constructor(t){(this._host=t).addController(this)}hostConnected(){}hostDisconnected(){}hostUpdate(){}getUserProfile(){return xt.getUserProfile()}updateUserProfile(t){return xt.updateUserProfile(t)}}var dl=[{key:"Etc/GMT+12",value:"(UTC-12:00) International Date Line West"},{key:"Etc/GMT+11",value:"(UTC-11:00) Coordinated Universal Time-11"},{key:"America/Adak",value:"(UTC-10:00) Aleutian Islands"},{key:"Pacific/Honolulu",value:"(UTC-10:00) Hawaii"},{key:"Pacific/Marquesas",value:"(UTC-09:30) Marquesas Islands"},{key:"America/Anchorage",value:"(UTC-09:00) Alaska"},{key:"Etc/GMT+9",value:"(UTC-09:00) Coordinated Universal Time-09"},{key:"America/Tijuana",value:"(UTC-08:00) Baja California"},{key:"Etc/GMT+8",value:"(UTC-08:00) Coordinated Universal Time-08"},{key:"America/Los_Angeles",value:"(UTC-08:00) Pacific Time (US, Canada)"},{key:"America/Phoenix",value:"(UTC-07:00) Arizona"},{key:"America/Chihuahua",value:"(UTC-07:00) Chihuahua, La Paz, Mazatlan"},{key:"America/Denver",value:"(UTC-07:00) Mountain Time (US, Canada)"},{key:"America/Whitehorse",value:"(UTC-07:00) Yukon"},{key:"America/Guatemala",value:"(UTC-06:00) Central America"},{key:"America/Chicago",value:"(UTC-06:00) Central Time (US, Canada)"},{key:"Pacific/Easter",value:"(UTC-06:00) Easter Island"},{key:"America/Mexico_City",value:"(UTC-06:00) Guadalajara, Mexico City, Monterrey"},{key:"America/Regina",value:"(UTC-06:00) Saskatchewan"},{key:"America/Bogota",value:"(UTC-05:00) Bogota, Lima, Quito, Rio Branco"},{key:"America/Cancun",value:"(UTC-05:00) Chetumal"},{key:"America/New_York",value:"(UTC-05:00) Eastern Time (US, Canada)"},{key:"America/Port-au-Prince",value:"(UTC-05:00) Haiti"},{key:"America/Havana",value:"(UTC-05:00) Havana"},{key:"America/Indiana/Indianapolis",value:"(UTC-05:00) Indiana (East)"},{key:"America/Grand_Turk",value:"(UTC-05:00) Turks and Caicos"},{key:"America/Asuncion",value:"(UTC-04:00) Asuncion"},{key:"America/Halifax",value:"(UTC-04:00) Atlantic Time (Canada)"},{key:"America/Caracas",value:"(UTC-04:00) Caracas"},{key:"America/Cuiaba",value:"(UTC-04:00) Cuiaba"},{key:"America/La_Paz",value:"(UTC-04:00) Georgetown, La Paz, Manaus, San Juan"},{key:"America/Santiago",value:"(UTC-04:00) Santiago"},{key:"America/St_Johns",value:"(UTC-03:30) Newfoundland"},{key:"America/Araguaina",value:"(UTC-03:00) Araguaina"},{key:"America/Sao_Paulo",value:"(UTC-03:00) Brasilia"},{key:"America/Cayenne",value:"(UTC-03:00) Cayenne, Fortaleza"},{key:"America/Argentina/Buenos_Aires",value:"(UTC-03:00) City of Buenos Aires"},{key:"America/Nuuk",value:"(UTC-03:00) Greenland"},{key:"America/Montevideo",value:"(UTC-03:00) Montevideo"},{key:"America/Punta_Arenas",value:"(UTC-03:00) Punta Arenas"},{key:"America/Miquelon",value:"(UTC-03:00) Saint Pierre and Miquelon"},{key:"America/Bahia",value:"(UTC-03:00) Salvador"},{key:"Etc/GMT+2",value:"(UTC-02:00) Coordinated Universal Time-02"},{key:"Atlantic/Azores",value:"(UTC-01:00) Azores"},{key:"Atlantic/Cape_Verde",value:"(UTC-01:00) Cabo Verde Is."},{key:"Etc/UTC",value:"(UTC) Coordinated Universal Time"},{key:"Europe/London",value:"(UTC+00:00) Dublin, Edinburgh, Lisbon, London"},{key:"Atlantic/Reykjavik",value:"(UTC+00:00) Monrovia, Reykjavik"},{key:"Africa/Sao_Tome",value:"(UTC+00:00) Sao Tome"},{key:"Africa/Casablanca",value:"(UTC+01:00) Casablanca"},{key:"Europe/Berlin",value:"(UTC+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna"},{key:"Europe/Budapest",value:"(UTC+01:00) Belgrade, Bratislava, Budapest, Ljubljana, Prague"},{key:"Europe/Paris",value:"(UTC+01:00) Brussels, Copenhagen, Madrid, Paris"},{key:"Europe/Warsaw",value:"(UTC+01:00) Sarajevo, Skopje, Warsaw, Zagreb"},{key:"Africa/Lagos",value:"(UTC+01:00) West Central Africa"},{key:"Asia/Amman",value:"(UTC+02:00) Amman"},{key:"Europe/Bucharest",value:"(UTC+02:00) Athens, Bucharest"},{key:"Asia/Beirut",value:"(UTC+02:00) Beirut"},{key:"Africa/Cairo",value:"(UTC+02:00) Cairo"},{key:"Europe/Chisinau",value:"(UTC+02:00) Chisinau"},{key:"Asia/Damascus",value:"(UTC+02:00) Damascus"},{key:"Asia/Hebron",value:"(UTC+02:00) Gaza, Hebron"},{key:"Africa/Johannesburg",value:"(UTC+02:00) Harare, Pretoria"},{key:"Europe/Kiev",value:"(UTC+02:00) Helsinki, Kyiv, Riga, Sofia, Tallinn, Vilnius"},{key:"Asia/Jerusalem",value:"(UTC+02:00) Jerusalem"},{key:"Africa/Juba",value:"(UTC+02:00) Juba"},{key:"Europe/Kaliningrad",value:"(UTC+02:00) Kaliningrad"},{key:"Africa/Khartoum",value:"(UTC+02:00) Khartoum"},{key:"Africa/Tripoli",value:"(UTC+02:00) Tripoli"},{key:"Africa/Windhoek",value:"(UTC+02:00) Windhoek"},{key:"Asia/Baghdad",value:"(UTC+03:00) Baghdad"},{key:"Europe/Istanbul",value:"(UTC+03:00) Istanbul"},{key:"Asia/Riyadh",value:"(UTC+03:00) Kuwait, Riyadh"},{key:"Europe/Minsk",value:"(UTC+03:00) Minsk"},{key:"Europe/Moscow",value:"(UTC+03:00) Moscow, St. Petersburg"},{key:"Africa/Nairobi",value:"(UTC+03:00) Nairobi"},{key:"Europe/Volgograd",value:"(UTC+04:00) Volgograd"},{key:"Asia/Tehran",value:"(UTC+03:30) Tehran"},{key:"Asia/Dubai",value:"(UTC+04:00) Abu Dhabi, Muscat"},{key:"Europe/Astrakhan",value:"(UTC+04:00) Astrakhan, Ulyanovsk"},{key:"Asia/Baku",value:"(UTC+04:00) Baku"},{key:"Europe/Samara",value:"(UTC+04:00) Izhevsk, Samara"},{key:"Indian/Mauritius",value:"(UTC+04:00) Port Louis"},{key:"Europe/Saratov",value:"(UTC+04:00) Saratov"},{key:"Asia/Tbilisi",value:"(UTC+04:00) Tbilisi"},{key:"Asia/Yerevan",value:"(UTC+04:00) Yerevan"},{key:"Asia/Kabul",value:"(UTC+04:30) Kabul"},{key:"Asia/Tashkent",value:"(UTC+05:00) Ashgabat, Tashkent"},{key:"Asia/Yekaterinburg",value:"(UTC+05:00) Ekaterinburg"},{key:"Asia/Karachi",value:"(UTC+05:00) Islamabad, Karachi"},{key:"Asia/Qyzylorda",value:"(UTC+05:00) Qyzylorda"},{key:"Asia/Kolkata",value:"(UTC+05:30) Chennai, Kolkata, Mumbai, New Delhi"},{key:"Asia/Colombo",value:"(UTC+05:30) Sri Jayawardenepura"},{key:"Asia/Kathmandu",value:"(UTC+05:45) Kathmandu"},{key:"Asia/Almaty",value:"(UTC+06:00) Astana"},{key:"Asia/Dhaka",value:"(UTC+06:00) Dhaka"},{key:"Asia/Omsk",value:"(UTC+06:00) Omsk"},{key:"Asia/Yangon",value:"(UTC+06:30) Yangon (Rangoon)"},{key:"Asia/Bangkok",value:"(UTC+07:00) Bangkok, Hanoi, Jakarta"},{key:"Asia/Barnaul",value:"(UTC+07:00) Barnaul, Gorno-Altaysk"},{key:"Asia/Hovd",value:"(UTC+07:00) Hovd"},{key:"Asia/Krasnoyarsk",value:"(UTC+07:00) Krasnoyarsk"},{key:"Asia/Novosibirsk",value:"(UTC+07:00) Novosibirsk"},{key:"Asia/Tomsk",value:"(UTC+07:00) Tomsk"},{key:"Asia/Shanghai",value:"(UTC+08:00) Beijing, Chongqing, Hong Kong, Urumqi"},{key:"Asia/Irkutsk",value:"(UTC+08:00) Irkutsk"},{key:"Asia/Singapore",value:"(UTC+08:00) Kuala Lumpur, Singapore"},{key:"Australia/Perth",value:"(UTC+08:00) Perth"},{key:"Asia/Taipei",value:"(UTC+08:00) Taipei"},{key:"Asia/Ulaanbaatar",value:"(UTC+08:00) Ulaanbaatar"},{key:"Australia/Eucla",value:"(UTC+08:45) Eucla"},{key:"Asia/Chita",value:"(UTC+09:00) Chita"},{key:"Asia/Tokyo",value:"(UTC+09:00) Osaka, Sapporo, Tokyo"},{key:"Asia/Pyongyang",value:"(UTC+09:00) Pyongyang"},{key:"Asia/Seoul",value:"(UTC+09:00) Seoul"},{key:"Asia/Yakutsk",value:"(UTC+09:00) Yakutsk"},{key:"Australia/Adelaide",value:"(UTC+09:30) Adelaide"},{key:"Australia/Darwin",value:"(UTC+09:30) Darwin"},{key:"Australia/Brisbane",value:"(UTC+10:00) Brisbane"},{key:"Australia/Sydney",value:"(UTC+10:00) Canberra, Melbourne, Sydney"},{key:"Pacific/Port_Moresby",value:"(UTC+10:00) Guam, Port Moresby"},{key:"Australia/Hobart",value:"(UTC+10:00) Hobart"},{key:"Asia/Vladivostok",value:"(UTC+10:00) Vladivostok"},{key:"Australia/Lord_Howe",value:"(UTC+10:30) Lord Howe Island"},{key:"Pacific/Bougainville",value:"(UTC+11:00) Bougainville Island"},{key:"Asia/Srednekolymsk",value:"(UTC+11:00) Chokurdakh"},{key:"Asia/Magadan",value:"(UTC+11:00) Magadan"},{key:"Pacific/Norfolk",value:"(UTC+11:00) Norfolk Island"},{key:"Asia/Sakhalin",value:"(UTC+11:00) Sakhalin"},{key:"Pacific/Guadalcanal",value:"(UTC+11:00) Solomon Is., New Caledonia"},{key:"Asia/Kamchatka",value:"(UTC+12:00) Anadyr, Petropavlovsk-Kamchatsky"},{key:"Pacific/Auckland",value:"(UTC+12:00) Auckland, Wellington"},{key:"Etc/GMT-12",value:"(UTC+12:00) Coordinated Universal Time+12"},{key:"Pacific/Fiji",value:"(UTC+12:00) Fiji"},{key:"Pacific/Chatham",value:"(UTC+12:45) Chatham Islands"},{key:"Etc/GMT-13",value:"(UTC+13:00) Coordinated Universal Time+13"},{key:"Pacific/Tongatapu",value:"(UTC+13:00) Nuku'alofa"},{key:"Pacific/Apia",value:"(UTC+13:00) Samoa"},{key:"Pacific/Kiritimati",value:"(UTC+14:00) Kiritimati Island"}];const ul=()=>dl.map(({key:e,value:t})=>({timeZone:e,displayName:t}));let H=class extends Ue{constructor(){super(...arguments),this.userProfileController=new cl(this),this.supportedDateFormat={"MM/dd/yyyy":"mm/dd/yyyy (e.g.: 04/24/2023)","dd/MM/yyyy":"dd/mm/yyyy (e.g.: 24/04/2023)","yyyy/MM/dd":"yyyy/mm/dd (e.g.: 2023/04/24)"},this.supportedTimeFormat={"h:mm a":"12-hour clock (e.g. 1:00 PM)","HH:mm":"24-hour clock (e.g. 13:00)"},this.isDialogVisible=!1,this.allowSave=!0,this.isLoading=!1,this.timezones=ul()}async firstUpdated(){await this.retrieveUserProfile(),this.shouldDisableSaveButton()}async retrieveUserProfile(){this.isLoading=!0,this.userProfile=await this.userProfileController.getUserProfile(),this.isLoading=!1}closeDialog(){this.isDialogVisible=!1,this.dispatchEvent(new CustomEvent("closeEditProfileDialog",{bubbles:!0,composed:!0}))}async saveUserProfileChanges(){var e,t,o,i;const n={profileSettingEditInput:{firstName:(e=J(this.firstName))!==null&&e!==void 0?e:this.firstName.value,lastName:(t=J(this.lastName))!==null&&t!==void 0?t:this.lastName.value,contactPhoneNumber:(o=_e(this.phoneNumber))!==null&&o!==void 0?o:this.phoneNumber.value,preferredTimezone:this.preferredTimezone.value,preferredDateFormat:this.preferredDateFormat.value,preferredTimeFormat:this.preferredTimeFormat.value}};((i=this.userProfile)===null||i===void 0?void 0:i.preferredTimezone)!==n.profileSettingEditInput.preferredTimezone&&(n.profileSettingEditInput.timezoneOverridden=!0),this.isLoading=!0,await this.userProfileController.updateUserProfile(n).then(()=>{co("Your profile info has been successfully updated",3e3,"center")}),this.saveDateTimeFormatToLocalStorage(n),this.isLoading=!1,this.closeDialog()}validatePhoneInput(e,t){const o=_e(e);if(o==="000-000-0000"){e.error=!1,e.errorText="",this.shouldDisableSaveButton();return}if(this.userProfile.contactPhoneNumber=o!=null?o:"",e.required&&!Oe(e,o)){this.allowSave=!1;return}if(!Tt(e,t)){this.allowSave=!1;return}e.error=!1,e.errorText="",this.shouldDisableSaveButton()}saveDateTimeFormatToLocalStorage(e){localStorage.setItem("date-format",JSON.stringify({preferredDateFormat:e.profileSettingEditInput.preferredDateFormat,preferredTimeFormat:e.profileSettingEditInput.preferredTimeFormat,preferredTimezone:e.profileSettingEditInput.preferredTimezone})),this.dispatchEvent(new CustomEvent("dateFormatChanged",{bubbles:!0,composed:!0}))}shouldDisableSaveButton(){this.allowSave=!(this.isInvalid()||this.isEmpty())}isInvalid(){return this.firstName.error||this.lastName.error||this.phoneNumber.error}isEmpty(){var e,t,o;return!(!((e=this.userProfile)===null||e===void 0)&&e.firstName)||!(!((t=this.userProfile)===null||t===void 0)&&t.lastName)||!(!((o=this.userProfile)===null||o===void 0)&&o.contactPhoneNumber)}render(){var e,t,o,i,n,a,s,l;return c`<ix-dialog class="dialog z-50 relative" ?open="${this.isDialogVisible}" @close="${()=>this.closeDialog()}"> ${this.isLoading?c`<ix-progress indeterminate slot="content"></ix-progress>`:""} <div class="dlr-text-heading flex p-6" slot="headline"> <span>Edit Profile</span> </div> <form class="dialog-form min-w-0 max-w-full max-[640px]:w-screen px-6 pb-5 pt-[0px]" slot="content" id="edit-profile-id" method="dialog"> <div class="user-profile-name-input-group grid grid-cols-1 sm:grid-cols-2 gap-3"> <div class="user-profile-input"> <ix-textbox required id="first-name" class="textbox" type="text" pattern="${Me.name}" label="First Name" placeholder="i.e. First Name" value="${(t=(e=this.userProfile)===null||e===void 0?void 0:e.firstName)!==null&&t!==void 0?t:""}" @input="${()=>{var p;this.allowSave=_t(this.firstName,this.firstName.value,"Invalid first name"),this.userProfile.firstName=(p=J(this.firstName))!==null&&p!==void 0?p:"",this.shouldDisableSaveButton()}}"></ix-textbox> </div> <div class="user-profile-input"> <ix-textbox required id="last-name" class="textbox" type="text" pattern="${Me.name}" label="Last Name" placeholder="i.e. Last Name" value="${(i=(o=this.userProfile)===null||o===void 0?void 0:o.lastName)!==null&&i!==void 0?i:""}" @input="${()=>{var p;this.allowSave=_t(this.lastName,this.lastName.value,"Invalid last name"),this.userProfile.lastName=(p=J(this.lastName))!==null&&p!==void 0?p:"",this.shouldDisableSaveButton()}}"></ix-textbox> </div> </div> <div class="user-profile-input mb-4"> <ix-phone-input required id="phone-number" class="single-row-textbox w-full" label="Phone Number" value="${(a=(n=this.userProfile)===null||n===void 0?void 0:n.contactPhoneNumber)!==null&&a!==void 0?a:""}" @input="${()=>{this.validatePhoneInput(this.phoneNumber,"Invalid phone number")}}"></ix-phone-input> </div> <div class="user-profile-input"> <ix-textbox id="email" class="single-row-textbox" type="email" label="Email Address" readOnly="true" disabled="true" value="${(l=(s=this.userProfile)===null||s===void 0?void 0:s.email)!==null&&l!==void 0?l:""}"></ix-textbox> </div> <div class="user-profile-input"> <ix-select appearance="outlined" id="preferredTimezone" label="Time Zone" menu-positioning="fixed"> ${this.timezones.map(p=>{var h;return c` <ix-select-option value="${p.timeZone}" ?selected="${p.timeZone===((h=this.userProfile)===null||h===void 0?void 0:h.preferredTimezone)}"> <div slot="headline">${p.displayName}</div> </ix-select-option> `})} </ix-select> </div> <div class="user-profile-input"> <ix-select menu-positioning="fixed" appearance="outlined" id="preferredDateFormat" label="Date format"> ${Object.entries(this.supportedDateFormat).map(([p,h])=>{var u;return c` <ix-select-option value="${p}" ?selected="${p===((u=this.userProfile)===null||u===void 0?void 0:u.preferredDateFormat)}"> <div slot="headline">${h}</div> </ix-select-option> `})} </ix-select> </div> <div class="user-profile-input"> <ix-select menu-positioning="fixed" appearance="outlined" id="preferredTimeFormat" label="Time Format"> ${Object.entries(this.supportedTimeFormat).map(([p,h])=>{var u;return c` <ix-select-option value="${p}" ?selected="${p===((u=this.userProfile)===null||u===void 0?void 0:u.preferredTimeFormat)}"> <div slot="headline">${h}</div> </ix-select-option> `})} </ix-select> </div> </form> <div class="dialog-actions p-2" slot="actions"> <ix-button form="edit-profile-id" appearance="text" text="Cancel" @click="${()=>this.closeDialog()}"> Cancel </ix-button> <ix-button id="save-user-button" appearance="text" text="Save Changes" ?disabled="${!this.allowSave||this.isLoading}" @click="${()=>{this.saveUserProfileChanges()}}"> Save Changes </ix-button> </div> </ix-dialog>`}};H.styles=[Mi,_],r([d({type:Boolean})],H.prototype,"isDialogVisible",void 0),r([m()],H.prototype,"allowSave",void 0),r([m()],H.prototype,"userProfile",void 0),r([m()],H.prototype,"isLoading",void 0),r([m()],H.prototype,"timezones",void 0),r([D("#first-name")],H.prototype,"firstName",void 0),r([D("#last-name")],H.prototype,"lastName",void 0),r([D("#phone-number")],H.prototype,"phoneNumber",void 0),r([D("#preferredTimezone")],H.prototype,"preferredTimezone",void 0),r([D("#preferredDateFormat")],H.prototype,"preferredDateFormat",void 0),r([D("#preferredTimeFormat")],H.prototype,"preferredTimeFormat",void 0),H=r([A("ui-um-user-profile")],H);class hl{async getAuthorisation(){const t=await st.getState(),[o,i,n,a]=t;return[o,i,n,a]}}const pl=new hl;class ml extends Ee{constructor(){super(...arguments),this.expandedNodes=[]}toggleNodeExpanded(t){this.expandedNodes.includes(t)?this.expandedNodes=this.expandedNodes.filter(o=>o!==t):this.expandedNodes.push(t)}async refresh(){this.requestHydration(),this.set(zr(this.expandedNodes)),this.completeHydration()}}const Oi=new ml({});let V=class extends Ue{constructor(){super(),this.errorService=g,this.routes=[],this.baseUrl="",this.isStandalone=!1,this.disableAuthentication=!1,this.compact=localStorage.getItem("compact")==="true",this.showDrawer=!1,this.showDraft=!1,this.showCancelDialog=!1,this.isEditUserProfileDialogOpen=!1,this.handleDrawerEventBinding=this.handleDrawerEvent.bind(this),this.handleCloseEditProfileDialogBinding=this.handleCloseEditProfileDialog.bind(this),this.handleAccountSwitchBinding=this.handleAccountSwitch.bind(this),this.handleEditProfileEventBinding=this.handleEditProfileEvent.bind(this),U.setLoading=!0}connectedCallback(){super.connectedCallback(),window.addEventListener(S.CreateUserClicked,this.handleDrawerEventBinding),document.addEventListener(S.AccountSwitched,this.handleAccountSwitchBinding),window.addEventListener(S.EditProfile,this.handleEditProfileEventBinding)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener(S.CreateUserClicked,this.handleDrawerEventBinding),document.removeEventListener(S.AccountSwitched,this.handleAccountSwitchBinding),window.removeEventListener(S.EditProfile,this.handleEditProfileEventBinding),rs(),g.destroyErrorHandler()}async handleAccountSwitch(e){const t=e.detail;U.setAccountNumber(t),await this.fetchData();const o=window.location.href.split("?")[0];window.history.replaceState({},document.title,o)}handleDrawerEvent(){this.toggleDrawer()}async firstUpdated(){await this.configureAuthentication(),await this.fetchData(),this.init(),U.setLoading=!1}updated(e){e.has("routes")&&this.routes.length&&ss().setRoutes(this.routes)}async fetchData(){const e=Ae.getUserDetails(),{email:t}=e;return pl.getAuthorisation().then(o=>{const[i,n,a,s]=o;return U.setMyPermissions(i),B.myPermissions=U.getMyPermissions(),U.setEmail(t),U.setPermissions(n),U.setAccounts(s),ve.set(a),Oi.refresh(),o})}async configureAuthentication(){this.disableAuthentication||N().UserManagement.UI.DisableUserManagementUIAuth||!this.isStandalone?await this.configureAuthorisation():Ae.isProcessing()||(Ae.isLoggedIn()?await this.configureAuthorisation():Ae.redirectToAuth())}async configureAuthorisation(){const e=Ae.getUserDetails(),{accountNumber:t}=e;U.setAccountNumber(t)}init(){setTimeout(()=>{this.mainApp&&(as(this.mainApp,this.baseUrl,No),Pe(window,S.AuthenticationComplete,{accountNumber:U.getAccountNumber()}))})}toggleDrawer(){this.showDraft&&(this.showDraft=!this.showDraft),this.showDrawer=!this.showDrawer}closeDrawer(){this.showDrawer=!1}toggleCompact(){this.compact=!this.compact,localStorage.setItem("compact",`${this.compact}`)}toggleDraft(){this.showDrawer=!this.showDrawer,this.showDraft=!this.showDraft}cancelCreateUser(){this.showDrawer=!1,this.showDraft=!1,this.showCancelDialog=!1}toggleCancelDialog(){this.showCancelDialog=!this.showCancelDialog}renderCreateUser(){return B.hasExternalUserCreate()?c` <create-user-container ?showDrawer="${this.showDrawer}" ?showDraft="${this.showDraft}" ?showCancelDialog="${this.showCancelDialog}" @blur-drawer="${this.toggleCancelDialog}" @toggle-drawer="${this.toggleDrawer}" @toggle-draft="${this.toggleDraft}" @toggle-dialog="${this.toggleCancelDialog}" @close-drawer="${this.closeDrawer}" @cancel-create-user="${this.cancelCreateUser}"></create-user-container> `:y}renderLoading(){return U.getLoading?c` <main> <error-dialog></error-dialog> <ix-progress id="application-loading-bar" aria-label="Application loading bar" indeterminate></ix-progress> </main> `:y}handleEditProfileEvent(){this.isEditUserProfileDialogOpen=!0}handleCloseEditProfileDialog(){this.isEditUserProfileDialogOpen=!1}renderEditProfileForm(){return c` <ui-um-user-profile ?isDialogVisible="${this.isEditUserProfileDialogOpen}" @closeEditProfileDialog="${this.handleCloseEditProfileDialogBinding}"></ui-um-user-profile>`}render(){return c` ${this.renderCreateUser()} <div class="flex flex-col"> <div class="animate-width absolute inset-0 bg-black opacity-50 z-20 ${this.compact?"hidden":"block"} lg:hidden" @click="${this.toggleCompact}" @keypress="${this.toggleCompact}"></div> ${this.isStandalone?c` <nav class="nav-bar wide p-4 m-2 rounded-xl flex items-center relative z-1 md:hidden"> <div class="flex-1"> <ix-icon-button @click="${this.toggleCompact}" icon="menu" class="white-icon"></ix-icon-button> </div> <div class="w-[178px]"> <svg focusable="false" viewBox="0 0 178 27" fill="white" class="w-full"> ${Ze.digitalRealtyLogoWithText} </svg> </div> <div class="flex-1"></div> </nav> `:y} <div class="w-full h-full flex relative ${this.showDrawer?"drawer-visible":""}"> ${this.isStandalone?c` <div class="${this.compact?"left-[-200px]":"left-0"} min-w-[96px] absolute z-1 md:relative lg:min-w-fit md:left-0 animate-width h-screen"> <navigation-bar @toggle-menu="${this.toggleCompact}" ?compact="${this.compact}" class="h-full p-2 block absolute drop-shadow-lg overflow-auto sm:overflow-visible lg:static lg:p-4"></navigation-bar> </div> `:y} <div class="grow w-full h-full"> <div class="flex flex-col grow h-full ${this.isStandalone?"p-2 lg:p-4":""}"> ${this.isStandalone?c`<app-header @create-user="${this.toggleDrawer}"></app-header>`:y} <main class="h-full">${this.renderLoading()}</main> </div> </div> </div> </div> ${this.renderEditProfileForm()}`}};V.styles=[ho,$e,_],r([d({type:Array})],V.prototype,"routes",void 0),r([d({type:String})],V.prototype,"baseUrl",void 0),r([d({type:Boolean})],V.prototype,"isStandalone",void 0),r([d({type:Boolean,attribute:!0})],V.prototype,"disableAuthentication",void 0),r([d({type:Boolean,attribute:!1})],V.prototype,"compact",void 0),r([m()],V.prototype,"showDrawer",void 0),r([m()],V.prototype,"showDraft",void 0),r([m()],V.prototype,"showCancelDialog",void 0),r([m()],V.prototype,"isEditUserProfileDialogOpen",void 0),r([D("main")],V.prototype,"mainApp",void 0),V=r([A("ui-user-management")],V);export{ht as $,S as A,Ee as B,Uo as C,N as D,rt as E,Lo as F,vi as G,qe as H,ze as I,Gt as J,pt as K,Hr as L,Ko as M,Zo as N,wo as O,Yo as P,z as Q,G as R,kt as S,_ as T,lt as U,qo as V,Ho as W,Qo as X,et as Y,Wo as Z,Pi as _,U as a,Ht as a0,pe as a1,qt as a2,ll as a3,xr as a4,xi as a5,hi as a6,Mi as a7,Ct as a8,us as a9,st as aA,Si as aB,Et as aC,Ni as aD,_t as aa,Tt as ab,_e as ac,ds as ad,ys as ae,Me as af,ms as ag,Do as ah,Be as ai,Jo as aj,Vo as ak,Ut as al,It as am,ei as an,Rt as ao,Xo as ap,Go as aq,w as ar,ii as as,he as at,le as au,zt as av,$t as aw,Pt as ax,k as ay,Ri as az,ls as b,B as c,Z as d,uo as e,ve as f,Qe as g,Oi as h,gs as i,ln as j,J as k,bs as l,ps as m,Ye as n,Lt as o,g as p,ut as q,Pe as r,Xe as s,$i as t,tt as u,Yr as v,Mt as w,co as x,He as y,yi as z};