@digital-realty/app-shell 13.0.13 → 13.0.14-IXUAT-11078.545130

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bootstrap.js CHANGED
@@ -1 +1 @@
1
- import{__decorate as I}from"tslib";import{LitElement as P,html as c}from"lit";import{property as b}from"lit/decorators.js";import{ApplicationInsights as ee,DistributedTracingModes as te}from"@microsoft/applicationinsights-web";import{authedUser as R}from"@digital-realty/ix-account-switcher";import{UserManager as se}from"oidc-client-ts";import"@digital-realty/ix-app-logic/views/splash-screen.js";import{makeObservable as ne,action as oe,observable as ae,toJS as re}from"mobx";function i(){var e;const t=(e=window.gpConfig)==null?void 0:e["app-shell"];if(!t)throw new Error("App-shell config not loaded. Ensure config.json is fetched before app bootstrap.");return t}const{PortalInterxion:ie,PortalGlobalPortal:le,PortalServiceFabric:ce,PortalMarketplacePortal:pe}=i(),ue={strict:"strictly_necessary",performance:"performance",targeting:"targeting"},de={accept:"accept_all",reject:"reject_all",custom:"customize",no:"no_sell",bypass:"gpc_bypass"},T="globalportalappshell",u="user-authentication",E="redirect-url",me="ui-cookie-policy",ge="date-format",y="Global Portal",v="Service Fabric",N="Marketplace Portal",O="EMEA Customer Portal",k="x-auth",[d,he,_e,Ee]=["CREATE","UPDATE","READ","APPROVE"],[L,f,fe,Ce,x,Se,Et,we,U,ft,Ae,Ie,M,D,V,Ct,Pe,St,be,G,j,$,Re,H,Te,ye,B,ve]=["Cloud Connect","Cross Connect","Custom Roles","Customer Care","Customer Equipment Connection (CEC)","Customer Support","DCIM-enabled location data","Default System Roles","External User","Facility Access","Internal Roles","Internal User","Internet Exchange","Intra-Customer Connectivity (ICC)","IP Bandwidth","OSP Access","Permanent Badge","PoP/POE Room Access","Remote Hands","Remote Hands Package","Service Exchange Cloud Router","Service Exchange Port","Shipping & Receiving","Space & Power","Trouble Ticket","Visitor Access","User","ESG Reporting"],Ne=[be,Se,Te,Re,ye,Pe,Ce],Oe=[f,L,x,M,D,V,G,j,$,H],F=[f,L,x,M,D,V,G,j,$,H],ke={LocationChanged:"location-changed",VaadinRouterLocationChanged:"vaadin-router-location-changed",CreateUserClicked:"create-user-clicked"},z={SessionStorage:{HasOutstandingChanges:"hasOutstandingChanges",ShowLastLoginPopup:"showLastLoginPopup"}},[Le,xe,Ue]=["Security","DCIM","Planned Site Maintenance"],Me=[Le,xe,Ue],De=[{label:y,href:le,selected:!0},{label:N,href:pe},{label:O,href:ie},{label:v,href:ce,target:"_blank"}],K={appInsights:"_appInsights"},Ve=()=>{const{ApplicationInsightsInstrumentationKey:e,ApplicationInsightsCorrelationHeaderExcludedDomains:t}=i(),s=new ee({config:{instrumentationKey:e,enableCorsCorrelation:!0,enableRequestHeaderTracking:!0,enableResponseHeaderTracking:!0,enableAutoRouteTracking:!0,autoTrackPageVisitTime:!0,enableAjaxErrorStatusText:!0,enableAjaxPerfTracking:!0,enableUnhandledPromiseRejectionTracking:!0,isCookieUseDisabled:!0,distributedTracingMode:te.AI_AND_W3C,correlationHeaderExcludedDomains:t.split(",").map(n=>n.trim())}});return s.loadAppInsights(),s.trackPageView(),s.addTelemetryInitializer(n=>{n.tags["ai.cloud.role"]=T}),s},m=(e,t,s)=>(...n)=>{const[o,...a]=n;typeof o=="string"&&o.startsWith("[mobx]")&&t===4?s.trackException({exception:{message:a[0].message,stack:a[0].stack,name:o},severityLevel:4}):s.trackTrace({severityLevel:t,message:o},a),e.apply(console,[o,...a])},Ge=e=>{console.log=m(console.log,2,e),console.info=m(console.info,2,e),console.warn=m(console.warn,3,e),console.error=m(console.error,4,e),window.console=console},je=()=>{const{ApplicationInsightsInstrumentationKey:e}=i();if(!e)return;const t=Ve();window[K.appInsights]=t,window.dispatchEvent(new Event("appInsightsInitialized")),Ge(t)},J=async e=>{const t=new TextEncoder().encode(e),s=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(s)).map(n=>n.toString(16).padStart(2,"0")).join("")};function $e(){const{location:e}=window,t=`${e.protocol}//${e.hostname}${e.port?`:${e.port}`:""}`,{LoginAuthority:s,GlobalPortalClientId:n,GlobalPortalUIScopes:o,GlobalPlanBShellPostLogoutRedirectUrl:a}=i();return{authority:s,client_id:n,redirect_uri:`${t}/auth-callback`,response_type:"code",scope:o,post_logout_redirect_uri:a,monitorSession:!1}}const C=new se($e()),He=e=>{const t=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),s=decodeURIComponent(window.atob(t).split("").map(n=>`%${`00${n.charCodeAt(0).toString(16)}`.slice(-2)}`).join(""));return JSON.parse(s)},Be=()=>{localStorage.removeItem(u)},l=()=>{const e=localStorage.getItem(u);return e?JSON.parse(e):null},W=()=>{var e;const t=localStorage.getItem(k);return t?(e=JSON.parse(t))==null?void 0:e.email:null},Fe=async()=>{const e=l();if(!e)return null;const t=(e.profile.given_name||"")+(e.profile.family_name||"")+e.profile.sub;return await J(t)},Y=()=>{const e=l();return e?e.id_token:null},q=(e,t)=>{const s={...t,...e},n=He(e.access_token);return s.profile.sub=n.sub,s.profile.account_number=n.account_number,s.expires_at=n.exp,s.is_federated=n.is_federated,n.previous_login_date&&(s.profile.previous_login_date=n.previous_login_date),R.setAccount({accountNumber:n.account_number,email:n.email,name:n.name,givenName:n.given_name,familyName:n.family_name,authTime:n.exp,accessToken:e.access_token,idToken:e.id_token}),localStorage.setItem(u,JSON.stringify(s)),s},ze=e=>{q(e,null)},X=()=>{const e=l();return e?e.access_token:null},Ke=()=>{const e=l();return e&&e.is_federated!==null&&e.is_federated!==void 0?String(e.is_federated).toLowerCase()==="true":!1},Je=()=>{const e=l();return e!=null&&e.expires_at?e.expires_at>Date.now()/1e3:!1},We=()=>{var e;const t=l();return((e=t==null?void 0:t.profile)==null?void 0:e.previous_login_date)||null},Ye=["authenticate","auth-callback","logout"],qe=e=>e.expires_at&&new Date(e.expires_at*1e3),Xe=e=>e.expires_at&&new Date(e.expires_at*1e3+i().TokenValidForOfflineUsePostExpiryInHours*60*60*1e3),Q=()=>{if(!i().IsLoginEnabled)return!1;const e=l();if(!Y())return!0;if(!e.expires_at)return!1;const t=new Date;return navigator.onLine?t>qe(e):t>Xe(e)},Qe=()=>{const e=window.location.pathname.split("/");return Ye.includes(e[e.length-1])},Ze=()=>{const e=window.location.pathname.split("/");return e[e.length-1]==="authenticate"?(i().IsLoginEnabled?C.signinRedirect():window.location.href="/",!0):!1},et=()=>{let e="/";const t=localStorage.getItem(E);t&&(localStorage.removeItem(E),e=t),sessionStorage.setItem(z.SessionStorage.ShowLastLoginPopup,"true"),window.location.href=e},tt=e=>{if(!e.id_token)throw new Error("Missing property:id_token");return e},S=e=>{const t=Qe();(!t||e)&&(t||localStorage.setItem(E,window.location.href),window.location.href="/authenticate")},st=async e=>{const t=`${e.profile.sub}-${e.profile.customer_id}`,s=await J(t);return{...e,profile:{...e.profile,hashed_identifier:s}}},nt=()=>{const e=window.location.pathname.split("/");return e[e.length-1]==="auth-callback"?(C.signinRedirectCallback().then(tt).then(st).then(ze).then(et).catch(S),!0):!1};class ot extends P{render(){return c` <ix-splash-screen></ix-splash-screen> `}}window.customElements.define("splash-screen",ot);class at{constructor(){this.permissions=[],this.loading=!1,this.getPermissions=async()=>{var t;const s=(t=R)==null?void 0:t.access_token;if(!s)return[];const{ApiBaseUrl:n}=i(),o=await fetch(`${n}/usermanagement/my-permissions?exclude_parents=false&exclude_siblings=true`,{headers:{Authorization:`Bearer ${s}`}});return o.ok?o.json():[]},ne(this,{permissions:ae,setPermissions:oe})}setPermissions(t){this.permissions=t.reduce((s,n)=>(s[n.permission_name]=n.privilege,s),{})}tryLoadPermissions(){try{this.loading||(this.loading=!0,this.getPermissions().then(t=>{this.setPermissions(t),this.loading=!1}).catch(()=>{this.loading=!1}))}catch(t){this.loading=!1}}clearPermissions(){this.setPermissions([])}hasExternalUserCreate(){return this.hasPermission(U,d)||this.hasPermission(B,d)}hasConnectivityCreate(){return this.hasPermission(f,d)}hasPrivilegeLevel(t,s){const n=[Ee,d,he,_e],o=n.findIndex(r=>r===t),a=n.findIndex(r=>r===s);return o>=a}hasPermission(t,s){let n=!1;const o=re(this.permissions),a=Object.keys(o).find(r=>r===t);return a&&(n=this.hasPrivilegeLevel(s,o[a])),n}}const w=new at,Z=()=>{const e=new Headers;return e.append("Authorization",`Bearer ${X()}`),e},rt=async()=>{const{ApiBaseUrl:e}=i(),t=`${e}/inventory/locations?embed=permissions&page_size=1000`;let s=[],n=1;for(;;){const a=await fetch(`${t}&cursor=${n}`,{headers:Z()});if(!a.ok)return Promise.reject();const r=await a.json();if(s.push(...r.items),r.self===r.last)break;n++}s=s.filter(a=>a.permissions.some(r=>F.includes(r.name)));const o=new Map;for(const a of s)o.has(a.account_number)?o.get(a.account_number).push(a.site_id):o.set(a.account_number,[a.site_id]);return o},it=async e=>{const{ApiBaseUrl:t}=i(),s=new URLSearchParams;s.append("process","Cross_connect");const n=[...e.keys()],o=[...new Set([...e.values()].flat())];s.append("account_number",n.join(",")),s.append("site",o.join(","));const a=await fetch(`${t}/site-navigations/site-configurations?${s}`,{headers:Z()});return a.ok?await a.json():Promise.reject()},lt=async()=>{try{const e=await rt();return e.size===0?!1:(await it(e)).some(t=>{var s;return t.portal==="GlobalPortal"&&!!((s=e.get(t.account_number))!=null&&s.includes(t.site))})}catch(e){return console.error("Failed to determine portal-managed inventory:",e),!1}};class A extends P{constructor(){super(),this._currentView="splash",this.appLoaded=!1,this._onPopState=()=>{i().IsLoginEnabled&&Q()&&S()};try{je()}catch(s){console.error("Telemetry initialization failed:",s)}const t=window.location.pathname;if(t==="/session-expired"){this._currentView="session-expired",this._loadView("session-expired");return}if(t==="/logout"){this._currentView="logout",this._loadView("logout");return}if(Ze()||nt()){this._currentView="splash";return}if(Q()){this._currentView="splash",S();return}this._currentView="app",this._loadApp()}async _loadView(t){t==="session-expired"?await import("@digital-realty/ix-app-logic/views/session-expiry.js"):t==="logout"&&await import("./logout-DHu3NPe-.js")}connectedCallback(){super.connectedCallback(),window.addEventListener("popstate",this._onPopState)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("popstate",this._onPopState)}_getAccountNumber(){var t,s,n;return(n=new URLSearchParams(window.location.search).get("selected_account_number"))!=null?n:(s=(t=l())==null?void 0:t.profile)==null?void 0:s.account_number}_isESGAccessOnly(t,s){const n=t.filter(o=>o.account_number===s);return n.length===1&&n[0].permission_name==="ESG Reporting"}async _applyGomFF(t){var s,n,o;const a=W(),r=structuredClone(window.gpConfig);if(!a||!r)return t;const g=((s=i().SuperusersWhitelist)!=null?s:"").split(",").map(_=>_.trim().toLowerCase()).includes(a.toLowerCase()),h=!!((n=t["ui-gom"])!=null&&n.enabled)&&!!((o=r["ui-launchpad"])!=null&&o.IsInventoryManagementEnabled),p=await lt()&&(g||h);return r["app-shell"].IsInventoryManagementEnabled=p,r["ui-launchpad"].IsInventoryManagementEnabled=p,window.gpConfig=Object.freeze(r),t["ui-gom"]?{...t,"ui-gom":{...t["ui-gom"],enabled:p}}:t}_applyMfeOverrides(t,s){const n={};for(const o of Object.keys(t))n[o]={...t[o],enabled:s.includes(o)};return n}async _loadApp(){var t;const{authedUser:s}=await import("@digital-realty/ix-account-switcher");await s.hydrateStore();const[n,o]=await Promise.allSettled([fetch("./registered-apps.json").then(_=>_.json()),w.getPermissions()]);if(n.status==="rejected"){console.error("Failed to load registered apps:",n.reason);return}if(o.status==="rejected"){console.error("Failed to load permissions:",o.reason);return}const{registeredApps:a}=n.value,r=o.value,g=(t=this._getAccountNumber())!=null?t:"",h=this._isESGAccessOnly(r,g)?this._applyMfeOverrides(a,["ui-esg"]):a,p=await this._applyGomFF(h);window.registeredApps=Object.freeze(p),w.setPermissions(r),await import("./app-BFjhvWIr.js"),this.appLoaded=!0}render(){switch(this._currentView){case"session-expired":return c`<ix-session-expiry></ix-session-expiry>`;case"logout":return c`<ixp-logout></ixp-logout>`;case"app":return this.appLoaded?c`<global-portal-app appTitle="DLR" showDrawer></global-portal-app>`:c`<splash-screen></splash-screen>`;default:return c`<splash-screen></splash-screen>`}}}I([b({type:String})],A.prototype,"_currentView",void 0),I([b({type:Boolean})],A.prototype,"appLoaded",void 0),window.customElements.define("gp-bootstrap",A);export{ke as A,k as B,fe as C,ge as D,ve as E,me as F,y as G,Oe as I,N as M,F as O,Me as R,Ne as S,B as U,Y as a,Fe as b,Be as c,W as d,X as e,l as f,i as g,q as h,We as i,Ke as j,z as k,Ie as l,U as m,we as n,Ae as o,w as p,O as q,De as r,v as s,K as t,C as u,T as v,ue as w,Je as x,de as y,u as z};
1
+ import{__decorate as A}from"tslib";import{LitElement as I,html as c}from"lit";import{property as P}from"lit/decorators.js";import{ApplicationInsights as ee,DistributedTracingModes as te}from"@microsoft/applicationinsights-web";import{authedUser as b}from"@digital-realty/ix-account-switcher";import{UserManager as se}from"oidc-client-ts";import"@digital-realty/ix-app-logic/views/splash-screen.js";import{makeObservable as ne,action as oe,observable as re,toJS as ae}from"mobx";function i(){var e;const t=(e=window.gpConfig)==null?void 0:e["app-shell"];if(!t)throw new Error("App-shell config not loaded. Ensure config.json is fetched before app bootstrap.");return t}const{PortalInterxion:ie,PortalGlobalPortal:le,PortalServiceFabric:ce,PortalMarketplacePortal:pe}=i(),ue={strict:"strictly_necessary",performance:"performance",targeting:"targeting"},de={accept:"accept_all",reject:"reject_all",custom:"customize",no:"no_sell",bypass:"gpc_bypass"},R="globalportalappshell",u="user-authentication",_="redirect-url",me="ui-cookie-policy",ge="date-format",T="Global Portal",y="Service Fabric",v="Marketplace Portal",N="EMEA Customer Portal",O="x-auth",[d,he,_e,Ee]=["CREATE","UPDATE","READ","APPROVE"],[k,E,fe,Se,U,Ce,ft,we,L,St,Ae,Ie,x,M,D,Ct,Pe,wt,be,V,G,j,Re,$,Te,ye,H,ve]=["Cloud Connect","Cross Connect","Custom Roles","Customer Care","Customer Equipment Connection (CEC)","Customer Support","DCIM-enabled location data","Default System Roles","External User","Facility Access","Internal Roles","Internal User","Internet Exchange","Intra-Customer Connectivity (ICC)","IP Bandwidth","OSP Access","Permanent Badge","PoP/POE Room Access","Remote Hands","Remote Hands Package","Service Exchange Cloud Router","Service Exchange Port","Shipping & Receiving","Space & Power","Trouble Ticket","Visitor Access","User","ESG Reporting"],Ne=[be,Ce,Te,Re,ye,Pe,Se],Oe=[E,k,U,x,M,D,V,G,j,$],B=[E,k,U,x,M,D,V,G,j,$],ke={LocationChanged:"location-changed",VaadinRouterLocationChanged:"vaadin-router-location-changed",CreateUserClicked:"create-user-clicked"},F={SessionStorage:{HasOutstandingChanges:"hasOutstandingChanges",ShowLastLoginPopup:"showLastLoginPopup"}},[Ue,Le,xe]=["Security","DCIM","Planned Site Maintenance"],Me=[Ue,Le,xe],De=[{label:T,href:le,selected:!0},{label:v,href:pe},{label:N,href:ie},{label:y,href:ce,target:"_blank"}],z={appInsights:"_appInsights"},Ve=()=>{const{ApplicationInsightsInstrumentationKey:e,ApplicationInsightsCorrelationHeaderExcludedDomains:t}=i(),s=new ee({config:{instrumentationKey:e,enableCorsCorrelation:!0,enableRequestHeaderTracking:!0,enableResponseHeaderTracking:!0,enableAutoRouteTracking:!0,autoTrackPageVisitTime:!0,enableAjaxErrorStatusText:!0,enableAjaxPerfTracking:!0,enableUnhandledPromiseRejectionTracking:!0,isCookieUseDisabled:!0,distributedTracingMode:te.AI_AND_W3C,correlationHeaderExcludedDomains:t.split(",").map(n=>n.trim())}});return s.loadAppInsights(),s.trackPageView(),s.addTelemetryInitializer(n=>{n.tags["ai.cloud.role"]=R}),s},m=(e,t,s)=>(...n)=>{const[o,...r]=n;typeof o=="string"&&o.startsWith("[mobx]")&&t===4?s.trackException({exception:{message:r[0].message,stack:r[0].stack,name:o},severityLevel:4}):s.trackTrace({severityLevel:t,message:o},r),e.apply(console,[o,...r])},Ge=e=>{console.log=m(console.log,2,e),console.info=m(console.info,2,e),console.warn=m(console.warn,3,e),console.error=m(console.error,4,e),window.console=console},je=()=>{const{ApplicationInsightsInstrumentationKey:e}=i();if(!e)return;const t=Ve();window[z.appInsights]=t,window.dispatchEvent(new Event("appInsightsInitialized")),Ge(t)},K=async e=>{const t=new TextEncoder().encode(e),s=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(s)).map(n=>n.toString(16).padStart(2,"0")).join("")};function $e(){const{location:e}=window,t=`${e.protocol}//${e.hostname}${e.port?`:${e.port}`:""}`,{LoginAuthority:s,GlobalPortalClientId:n,GlobalPortalUIScopes:o,GlobalPlanBShellPostLogoutRedirectUrl:r}=i();return{authority:s,client_id:n,redirect_uri:`${t}/auth-callback`,response_type:"code",scope:o,post_logout_redirect_uri:r,monitorSession:!1}}const f=new se($e()),He=e=>{const t=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),s=decodeURIComponent(window.atob(t).split("").map(n=>`%${`00${n.charCodeAt(0).toString(16)}`.slice(-2)}`).join(""));return JSON.parse(s)},Be=()=>{localStorage.removeItem(u)},l=()=>{const e=localStorage.getItem(u);return e?JSON.parse(e):null},J=()=>{var e;const t=localStorage.getItem(O);return t?(e=JSON.parse(t))==null?void 0:e.email:null},Fe=async()=>{const e=l();if(!e)return null;const t=(e.profile.given_name||"")+(e.profile.family_name||"")+e.profile.sub;return await K(t)},Y=()=>{const e=l();return e?e.id_token:null},q=(e,t)=>{const s={...t,...e},n=He(e.access_token);return s.profile.sub=n.sub,s.profile.account_number=n.account_number,s.expires_at=n.exp,s.is_federated=n.is_federated,n.previous_login_date&&(s.profile.previous_login_date=n.previous_login_date),b.setAccount({accountNumber:n.account_number,email:n.email,name:n.name,givenName:n.given_name,familyName:n.family_name,authTime:n.exp,accessToken:e.access_token,idToken:e.id_token}),localStorage.setItem(u,JSON.stringify(s)),s},ze=e=>{q(e,null)},W=()=>{const e=l();return e?e.access_token:null},Ke=()=>{const e=l();return e&&e.is_federated!==null&&e.is_federated!==void 0?String(e.is_federated).toLowerCase()==="true":!1},Je=()=>{const e=l();return e!=null&&e.expires_at?e.expires_at>Date.now()/1e3:!1},Ye=()=>{var e;const t=l();return((e=t==null?void 0:t.profile)==null?void 0:e.previous_login_date)||null},qe=["authenticate","auth-callback","logout"],We=e=>e.expires_at&&new Date(e.expires_at*1e3),Xe=e=>e.expires_at&&new Date(e.expires_at*1e3+i().TokenValidForOfflineUsePostExpiryInHours*60*60*1e3),X=()=>{if(!i().IsLoginEnabled)return!1;const e=l();if(!Y())return!0;if(!e.expires_at)return!1;const t=new Date;return navigator.onLine?t>We(e):t>Xe(e)},Qe=()=>{const e=window.location.pathname.split("/");return qe.includes(e[e.length-1])},Ze=()=>{const e=window.location.pathname.split("/");return e[e.length-1]==="authenticate"?(i().IsLoginEnabled?f.signinRedirect():window.location.href="/",!0):!1},et=()=>{let e="/";const t=localStorage.getItem(_);t&&(localStorage.removeItem(_),e=t),sessionStorage.setItem(F.SessionStorage.ShowLastLoginPopup,"true"),window.location.href=e},tt=e=>{if(!e.id_token)throw new Error("Missing property:id_token");return e},S=e=>{const t=Qe();(!t||e)&&(t||localStorage.setItem(_,window.location.href),window.location.href="/authenticate")},st=async e=>{const t=`${e.profile.sub}-${e.profile.customer_id}`,s=await K(t);return{...e,profile:{...e.profile,hashed_identifier:s}}},nt=()=>{const e=window.location.pathname.split("/");return e[e.length-1]==="auth-callback"?(f.signinRedirectCallback().then(tt).then(st).then(ze).then(et).catch(S),!0):!1};class ot extends I{render(){return c` <ix-splash-screen></ix-splash-screen> `}}window.customElements.define("splash-screen",ot);class rt{constructor(){this.permissions=[],this.loading=!1,this.getPermissions=async()=>{var t;const s=(t=b)==null?void 0:t.access_token;if(!s)return[];const{ApiBaseUrl:n}=i(),o=await fetch(`${n}/usermanagement/my-permissions?exclude_parents=false&exclude_siblings=true`,{headers:{Authorization:`Bearer ${s}`}});return o.ok?o.json():[]},ne(this,{permissions:re,setPermissions:oe})}setPermissions(t){this.permissions=t.reduce((s,n)=>(s[n.permission_name]=n.privilege,s),{})}tryLoadPermissions(){try{this.loading||(this.loading=!0,this.getPermissions().then(t=>{this.setPermissions(t),this.loading=!1}).catch(()=>{this.loading=!1}))}catch(t){this.loading=!1}}clearPermissions(){this.setPermissions([])}hasExternalUserCreate(){return this.hasPermission(L,d)||this.hasPermission(H,d)}hasConnectivityCreate(){return this.hasPermission(E,d)}hasPrivilegeLevel(t,s){const n=[Ee,d,he,_e],o=n.findIndex(a=>a===t),r=n.findIndex(a=>a===s);return o>=r}hasPermission(t,s){let n=!1;const o=ae(this.permissions),r=Object.keys(o).find(a=>a===t);return r&&(n=this.hasPrivilegeLevel(s,o[r])),n}}const C=new rt,Q=()=>{const e=new Headers;return e.append("Authorization",`Bearer ${W()}`),e},at=async()=>{const{ApiBaseUrl:e}=i(),t=`${e}/inventory/locations?embed=permissions&page_size=1000`;let s=[],n=1;for(;;){const r=await fetch(`${t}&cursor=${n}`,{headers:Q()});if(!r.ok)return Promise.reject();const a=await r.json();if(s.push(...a.items),a.self===a.last)break;n++}s=s.filter(r=>r.permissions.some(a=>B.includes(a.name)));const o=new Map;for(const r of s)o.has(r.account_number)?o.get(r.account_number).push(r.site_id):o.set(r.account_number,[r.site_id]);return o},it=async e=>{const{ApiBaseUrl:t}=i(),s=new URLSearchParams;s.append("process","Cross_connect");const n=[...e.keys()],o=[...new Set([...e.values()].flat())];s.append("account_number",n.join(",")),s.append("site",o.join(","));const r=await fetch(`${t}/site-navigations/site-configurations?${s}`,{headers:Q()});return r.ok?await r.json():Promise.reject()},lt=async()=>{try{const e=await at();return e.size===0?!1:(await it(e)).some(t=>{var s;return t.portal==="GlobalPortal"&&!!((s=e.get(t.account_number))!=null&&s.includes(t.site))})}catch(e){return console.error("Failed to determine portal-managed inventory:",e),!1}},ct="SUPERUSER";class w extends I{constructor(){super(),this._currentView="splash",this.appLoaded=!1,this._onPopState=()=>{i().IsLoginEnabled&&X()&&S()};try{je()}catch(s){console.error("Telemetry initialization failed:",s)}const t=window.location.pathname;if(t==="/session-expired"){this._currentView="session-expired",this._loadView("session-expired");return}if(t==="/logout"){this._currentView="logout",this._loadView("logout");return}if(Ze()||nt()){this._currentView="splash";return}if(X()){this._currentView="splash",S();return}this._currentView="app",this._loadApp()}async _loadView(t){t==="session-expired"?await import("@digital-realty/ix-app-logic/views/session-expiry.js"):t==="logout"&&await import("./logout-DHu3NPe-.js")}connectedCallback(){super.connectedCallback(),window.addEventListener("popstate",this._onPopState)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("popstate",this._onPopState)}_getAccountNumber(){var t,s,n;return(n=new URLSearchParams(window.location.search).get("selected_account_number"))!=null?n:(s=(t=l())==null?void 0:t.profile)==null?void 0:s.account_number}_isESGAccessOnly(t,s){const n=t.filter(o=>o.account_number===s);return n.length===1&&n[0].permission_name==="ESG Reporting"}_isSuperUser(t){return t.some(s=>{var n;return(n=s.provenance)==null?void 0:n.includes(ct)})}async _applyGomFF(t,s){var n,o;const r=J(),a=structuredClone(window.gpConfig);if(!r||!a)return t;const g=this._isSuperUser(s),h=!!((n=t["ui-gom"])!=null&&n.enabled)&&!!((o=a["ui-launchpad"])!=null&&o.IsInventoryManagementEnabled),p=await lt()&&(g||h);return a["app-shell"].IsInventoryManagementEnabled=p,a["ui-launchpad"].IsInventoryManagementEnabled=p,window.gpConfig=Object.freeze(a),t["ui-gom"]?{...t,"ui-gom":{...t["ui-gom"],enabled:p}}:t}_applyMfeOverrides(t,s){const n={};for(const o of Object.keys(t))n[o]={...t[o],enabled:s.includes(o)};return n}async _loadApp(){var t;const{authedUser:s}=await import("@digital-realty/ix-account-switcher");await s.hydrateStore();const[n,o]=await Promise.allSettled([fetch("./registered-apps.json").then(Z=>Z.json()),C.getPermissions()]);if(n.status==="rejected"){console.error("Failed to load registered apps:",n.reason);return}if(o.status==="rejected"){console.error("Failed to load permissions:",o.reason);return}const{registeredApps:r}=n.value,a=o.value,g=(t=this._getAccountNumber())!=null?t:"",h=this._isESGAccessOnly(a,g)?this._applyMfeOverrides(r,["ui-esg"]):r,p=await this._applyGomFF(h,a);window.registeredApps=Object.freeze(p),C.setPermissions(a),await import("./app-BFjhvWIr.js"),this.appLoaded=!0}render(){switch(this._currentView){case"session-expired":return c`<ix-session-expiry></ix-session-expiry>`;case"logout":return c`<ixp-logout></ixp-logout>`;case"app":return this.appLoaded?c`<global-portal-app appTitle="DLR" showDrawer></global-portal-app>`:c`<splash-screen></splash-screen>`;default:return c`<splash-screen></splash-screen>`}}}A([P({type:String})],w.prototype,"_currentView",void 0),A([P({type:Boolean})],w.prototype,"appLoaded",void 0),window.customElements.define("gp-bootstrap",w);export{ke as A,O as B,fe as C,ge as D,ve as E,me as F,T as G,Oe as I,v as M,B as O,Me as R,Ne as S,H as U,Y as a,Fe as b,Be as c,J as d,W as e,l as f,i as g,q as h,Ye as i,Ke as j,F as k,Ie as l,L as m,we as n,Ae as o,C as p,N as q,De as r,y as s,z as t,f as u,R as v,ue as w,Je as x,de as y,u as z};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digital-realty/app-shell",
3
- "version": "13.0.13",
3
+ "version": "13.0.14-IXUAT-11078.545130",
4
4
  "license": "UNLICENSED",
5
5
  "contributors": [
6
6
  "DLR"