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