@luigi-project/client 2.26.1-dev.202601280040 → 2.26.1-dev.202601281005

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/luigi-client.js CHANGED
@@ -1,2 +1 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.LuigiClient=t():e.LuigiClient=t()}(self,(()=>(()=>{"use strict";var e={224:e=>{e.exports={rE:"2.26.0"}}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var r={};function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,a(r.key),r)}}function a(e){var t=function(e){if("object"!=o(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=o(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==o(t)?t:t+""}n.d(r,{default:()=>se});var u=function(){return e=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.promises={}},(t=[{key:"setPromise",value:function(e,t){this.promises[e]=t}},{key:"getPromise",value:function(e){return this.promises[e]}}])&&i(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();function s(e){return s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s(e)}function c(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,l(r.key),r)}}function l(e){var t=function(e){if("object"!=s(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=s(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==s(t)?t:t+""}var f=new(function(){return e=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.listeners=[],this.origin="";var t=function(e){if(e.data.msg)if("custom"===e.data.msg){var t=this.convertCustomMessageInternalToUser(e.data);this.listeners.filter((function(e){return e.name===t.id})).map((function(e){return e.eventFn(t,e.listenerId)}))}else this.listeners.filter((function(t){return t.name===e.data.msg})).map((function(t){return t.eventFn(e,t.listenerId)}))}.bind(this);window.addEventListener("message",t)},t=[{key:"convertCustomMessageInternalToUser",value:function(e){return e.data}},{key:"convertCustomMessageUserToInternal",value:function(e){return{msg:"custom",data:e}}},{key:"convertStorageMessageToInternal",value:function(e){return{msg:"storage",data:e}}},{key:"addEventListener",value:function(e,t){var n=this.getRandomId();return this.listeners.push({name:e,eventFn:t,listenerId:n}),n}},{key:"removeEventListener",value:function(e){return!!Boolean(this.listeners.find((function(t){return t.listenerId===e})))&&(this.listeners=this.listeners.filter((function(t){return t.listenerId!==e})),!0)}},{key:"getRandomId",value:function(){return window.crypto.getRandomValues(new Uint32Array(1))[0]}},{key:"isFunction",value:function(e){return"function"==typeof e}},{key:"isObject",value:function(e){return"[object Object]"===Object.prototype.toString.call(e)}},{key:"getLuigiCoreDomain",value:function(){return this.origin}},{key:"setLuigiCoreDomain",value:function(e){e&&"null"!==e&&(this.origin=e)}},{key:"setTargetOrigin",value:function(e){this.setLuigiCoreDomain(e)}},{key:"sendPostMessageToLuigiCore",value:function(e){if(this.origin)try{window.parent.postMessage(e,this.origin)}catch(t){console.warn("Unable to post message "+e+" to Luigi Core from origin "+this.origin+": "+t)}else console.warn('There is no target origin set. You can specify the target origin by calling LuigiClient.setTargetOrigin("targetorigin") in your micro frontend.')}},{key:"hasIntent",value:function(e){return!!e&&e.toLowerCase().includes("#?intent=")}},{key:"deSanitizeParamsMap",value:function(e){var t=this;return Object.entries(e).reduce((function(e,n){return e[t.deSanitizeParam(n[0])]=t.deSanitizeParam(n[1]),e}),{})}},{key:"deSanitizeParam",value:function(){return String(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").replaceAll("&lt;","<").replaceAll("&gt;",">").replaceAll("&quot;",'"').replaceAll("&#39;","'").replaceAll("&sol;","/")}}],t&&c(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}());function v(e){return v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},v(e)}function d(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,y(r.key),r)}}function y(e){var t=function(e){if("object"!=v(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=v(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==v(t)?t:t+""}function p(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(p=function(){return!!e})()}function g(e){return g=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},g(e)}function m(e,t){return m=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},m(e,t)}var h=new(function(e){function t(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(e=function(e,t,n){return t=g(t),function(e,t){if(t&&("object"==v(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,p()?Reflect.construct(t,n||[],g(e).constructor):t.apply(e,n))}(this,t)).luigiInitialized=!1,e.defaultContextKeys=["context","internal","nodeParams","pathParams","searchParams"],e.setCurrentContext(e.defaultContextKeys.reduce((function(e,t){return e[t]={},e}),{})),e._onContextUpdatedFns={},e._onInactiveFns={},e._onInitFns={},e.authData={},e._isDeferInitDefined()||e.luigiClientInit(),e}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&m(e,t)}(t,e),r=t,o=[{key:"_isDeferInitDefined",value:function(){return window.document.head.hasAttribute("defer-luigi-init")}},{key:"_isTpcCheckDisabled",value:function(){var e,t,n;return window.document.head.hasAttribute("disable-tpc-check")||(null===(e=this.currentContext)||void 0===e||null===(t=e.internal)||void 0===t||null===(n=t.thirdPartyCookieCheck)||void 0===n?void 0:n.disabled)}},{key:"isLuigiClientInitialized",value:function(){return this.luigiInitialized}},{key:"luigiClientInit",value:function(){var e=this;if(this.luigiInitialized)console.warn("Luigi Client has been already initialized");else{var t=function(t){for(var n=0;n<e.defaultContextKeys.length;n++){var r=e.defaultContextKeys[n];try{"string"==typeof t[r]&&(t[r]=JSON.parse(t[r]))}catch(e){console.info("unable to parse luigi context data for",r,t[r],e)}}e.setCurrentContext(t)},r=function(t){t&&(e.authData=t)};f.addEventListener("luigi.init",(function(n){t(n.data),r(n.data.authData),f.setLuigiCoreDomain(n.origin),e.luigiInitialized=!0,e._notifyInit(n.origin),e._tpcCheck(),f.sendPostMessageToLuigiCore({msg:"luigi.init.ok"})})),f.addEventListener("luigi-client.inactive-microfrontend",(function(t){e._notifyInactive(t.origin)})),f.addEventListener("luigi.auth.tokenIssued",(function(e){r(e.data.authData)})),f.addEventListener("luigi.navigate",(function(n){if(t(n.data),!e.currentContext.internal.isNavigateBack&&!e.currentContext.withoutSync){var r=window.location.hash;history.replaceState({luigiInduced:!0},"",n.data.viewUrl),window.dispatchEvent(new PopStateEvent("popstate",{state:"luiginavigation"})),window.location.hash!==r&&window.dispatchEvent(new HashChangeEvent("hashchange"))}e.currentContext.withoutSync&&Object.assign(e.currentContext.context,{viewUrl:n.data.viewUrl?n.data.viewUrl:void 0,pathParams:n.data.pathParams?n.data.pathParams:void 0}),e._notifyUpdate(),f.sendPostMessageToLuigiCore({msg:"luigi.navigate.ok"})})),window.parent.postMessage({msg:"luigi.get-context",clientVersion:n(224).rE},"*")}}},{key:"_tpcCheck",value:function(){if(!this._isTpcCheckDisabled()){var e,t="enabled",n=document.cookie;n&&(e=n.split(";").map((function(e){return e.trim()})).find((function(e){return"luigiCookie=true"===e}))),"luigiCookie=true"===e&&(document.cookie="luigiCookie=; Max-Age=-99999999; SameSite=None; Secure"),document.cookie="luigiCookie=true; SameSite=None; Secure",(n=document.cookie)&&(e=n.split(";").map((function(e){return e.trim()})).find((function(e){return"luigiCookie=true"===e}))),"luigiCookie=true"===e?(document.cookie="luigiCookie=; Max-Age=-99999999; SameSite=None; Secure",window.parent.postMessage({msg:"luigi.third-party-cookie",tpc:t},"*")):(t="disabled",window.parent.postMessage({msg:"luigi.third-party-cookie",tpc:t},"*"),console.warn("Third party cookies are not supported!"))}}},{key:"_callAllFns",value:function(e,t,n){for(var r in e)e.hasOwnProperty(r)&&f.isFunction(e[r])&&e[r](t,n)}},{key:"_notifyInit",value:function(e){this._callAllFns(this._onInitFns,this.currentContext.context,e)}},{key:"_notifyUpdate",value:function(){this._callAllFns(this._onContextUpdatedFns,this.currentContext.context)}},{key:"_notifyInactive",value:function(){this._callAllFns(this._onInactiveFns)}},{key:"setCurrentContext",value:function(e){this.currentContext=e}},{key:"addInitListener",value:function(e,t){var n=f.getRandomId();return this._onInitFns[n]=e,t&&document.head.setAttribute("disable-tpc-check",""),this.luigiInitialized&&f.isFunction(e)&&e(this.currentContext.context,f.getLuigiCoreDomain()),n}},{key:"removeInitListener",value:function(e){return!!this._onInitFns[e]&&(this._onInitFns[e]=void 0,!0)}},{key:"addContextUpdateListener",value:function(e){var t=f.getRandomId();return this._onContextUpdatedFns[t]=e,this.luigiInitialized&&f.isFunction(e)&&e(this.currentContext.context),t}},{key:"removeContextUpdateListener",value:function(e){return!!this._onContextUpdatedFns[e]&&(this._onContextUpdatedFns[e]=void 0,!0)}},{key:"addInactiveListener",value:function(e){var t=f.getRandomId();return this._onInactiveFns[t]=e,t}},{key:"removeInactiveListener",value:function(e){return!!this._onInactiveFns[e]&&(this._onInactiveFns[e]=void 0,!0)}},{key:"addCustomMessageListener",value:function(e,t){return f.addEventListener(e,(function(e,n){return t(e,n)}))}},{key:"removeCustomMessageListener",value:function(e){return f.removeEventListener(e)}},{key:"getToken",value:function(){return this.authData.accessToken}},{key:"getContext",value:function(){return this.getEventData()}},{key:"getEventData",value:function(){return this.currentContext.context}},{key:"getActiveFeatureToggles",value:function(){var e;return null!==(e=this.currentContext.internal.activeFeatureToggleList)&&void 0!==e?e:[]}},{key:"addNodeParams",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];e&&f.sendPostMessageToLuigiCore({msg:"luigi.addNodeParams",data:e,keepBrowserHistory:t})}},{key:"getNodeParams",value:function(){return arguments.length>0&&void 0!==arguments[0]&&arguments[0]?f.deSanitizeParamsMap(this.currentContext.nodeParams):this.currentContext.nodeParams}},{key:"getPathParams",value:function(){return this.currentContext.pathParams}},{key:"getCoreSearchParams",value:function(){return this.currentContext.searchParams||{}}},{key:"addCoreSearchParams",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];e&&f.sendPostMessageToLuigiCore({msg:"luigi.addSearchParams",data:e,keepBrowserHistory:t})}},{key:"getClientPermissions",value:function(){return this.currentContext.internal.clientPermissions||{}}},{key:"setTargetOrigin",value:function(e){f.setTargetOrigin(e)}},{key:"sendCustomMessage",value:function(e){var t=f.convertCustomMessageUserToInternal(e);f.sendPostMessageToLuigiCore(t)}},{key:"getUserSettings",value:function(){return this.currentContext.internal.userSettings}},{key:"getAnchor",value:function(){return this.currentContext.internal.anchor||""}},{key:"setAnchor",value:function(e){f.sendPostMessageToLuigiCore({msg:"luigi.setAnchor",anchor:e})}},{key:"setViewGroupData",value:function(e){f.sendPostMessageToLuigiCore({msg:"luigi.setVGData",data:e})}}],o&&d(r.prototype,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,o}(u));function b(e){return b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},b(e)}function w(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,k(r.key),r)}}function k(e){var t=function(e){if("object"!=b(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=b(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==b(t)?t:t+""}function P(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(P=function(){return!!e})()}function C(e){return C=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},C(e)}function S(e,t){return S=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},S(e,t)}var O=function(e){function t(e){var n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(n=function(e,t,n){return t=C(t),function(e,t){if(t&&("object"==b(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,P()?Reflect.construct(t,n||[],C(e).constructor):t.apply(e,n))}(this,t)).validSplitViewEvents=["expand","collapse","resize","close"],n.splitView={exists:!0,size:40,collapsed:!1},Object.assign(n.splitView,e),n.splitView.listeners=[f.addEventListener("luigi.navigation.splitview.internal",(function(e){Object.assign(n.splitView,e.data.data)}))],n.on("resize",(function(e){n.splitView.size=e})),n.on("close",(function(){n.splitView.listeners.forEach((function(e){return f.removeEventListener(e)}))})),n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&S(e,t)}(t,e),n=t,r=[{key:"sendSplitViewEvent",value:function(e,t){f.sendPostMessageToLuigiCore({msg:"luigi.navigation.splitview.".concat(e),data:t})}},{key:"collapse",value:function(){this.sendSplitViewEvent("collapse")}},{key:"expand",value:function(){this.sendSplitViewEvent("expand")}},{key:"close",value:function(){this.sendSplitViewEvent("close")}},{key:"setSize",value:function(e){this.sendSplitViewEvent("resize",e)}},{key:"on",value:function(e,t){if(!this.validSplitViewEvents.includes(e))return console.warn(e+" is not a valid split view event"),!1;var n=f.addEventListener("luigi.navigation.splitview.".concat(e,".ok"),(function(e){var n="number"==typeof e.data.data?e.data.data:void 0;t(n)}));return this.splitView.listeners.push(n),n}},{key:"removeEventListener",value:function(e){return f.removeEventListener(e)}},{key:"exists",value:function(){return this.splitView.exists}},{key:"getSize",value:function(){return this.splitView.size}},{key:"isCollapsed",value:function(){return this.splitView.collapsed}},{key:"isExpanded",value:function(){return!this.splitView.collapsed}}],r&&w(n.prototype,r),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r}(u);function x(e){return x="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},x(e)}function j(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function E(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?j(Object(n),!0).forEach((function(t){L(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):j(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function L(e,t,n){return(t=A(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function I(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i,a,u=[],s=!0,c=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;s=!1}else for(;!(s=(r=i.call(n)).done)&&(u.push(r.value),u.length!==t);s=!0);}catch(e){c=!0,o=e}finally{try{if(!s&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return u}}(e,t)||T(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function T(e,t){if(e){if("string"==typeof e)return M(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?M(e,t):void 0}}function M(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function _(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,A(r.key),r)}}function A(e){var t=function(e){if("object"!=x(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=x(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==x(t)?t:t+""}function F(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(F=function(){return!!e})()}function D(e){return D=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},D(e)}function R(e,t){return R=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},R(e,t)}var V=function(e){function t(e){var n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),n=function(e,t,n){return t=D(t),function(e,t){if(t&&("object"==x(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,F()?Reflect.construct(t,n||[],D(e).constructor):t.apply(e,n))}(this,t),Object.assign(n,e),n.options={preserveView:!1,nodeParams:{},errorSkipNavigation:!1,fromContext:null,fromClosestContext:!1,fromVirtualTreeRoot:!1,fromParent:!1,relative:!1,link:"",newTab:!1,preserveQueryParams:!1,anchor:"",preventContextUpdate:!1,preventHistoryEntry:!1},n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&R(e,t)}(t,e),n=t,r=[{key:"navigate",value:function(e,t,n,r,o,i){if(this.options.errorSkipNavigation)this.options.errorSkipNavigation=!1;else{r&&o&&i&&console.warn("modalSettings, splitViewSettings and drawerSettings cannot be used together. Only modal setting will be taken into account."),this.options.preserveView=n;var a="/"!==e[0];if("/"===e&&(r||o||i))console.warn("Navigation with an absolute path prevented.");else{var u={msg:"luigi.navigation.open",sessionId:t,params:Object.assign(this.options,{link:e,relative:a,intent:f.hasIntent(e),modal:r,splitView:o,drawer:i})};f.sendPostMessageToLuigiCore(u)}}}},{key:"updateModalPathInternalNavigation",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(e){var r={msg:"luigi.navigation.updateModalDataPath",params:Object.assign(this.options,{link:e,modal:t,history:n})};f.sendPostMessageToLuigiCore(r)}else console.warn("Updating path of the modal upon internal navigation prevented. No path specified.")}},{key:"navigateToIntent",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r="#?intent=";if(r+=e,n&&null!==(t=Object.keys(n))&&void 0!==t&&t.length){var o=Object.entries(n);if(o.length>0){r+="?";var i,a=function(e){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=T(e))){t&&(e=t);var n=0,r=function(){};return{s:r,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,a=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return i=e.done,e},e:function(e){a=!0,o=e},f:function(){try{i||null==t.return||t.return()}finally{if(a)throw o}}}}(o);try{for(a.s();!(i=a.n()).done;){var u=I(i.value,2);r+=u[0]+"="+u[1]+"&"}}catch(e){a.e(e)}finally{a.f()}r=r.slice(0,-1)}}this.navigate(r)}},{key:"openAsModal",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};f.addEventListener("luigi.navigation.modal.close",(function(e,n){var r,o=t.getPromise("modal");o&&(o.resolveFn(E(E({},e.data),{},{goBackValue:null===(r=e.data)||void 0===r?void 0:r.data})),t.setPromise("modal",void 0)),f.removeEventListener(n)}));var r={};return r.promise=new Promise((function(e,t){r.resolveFn=e,r.rejectFn=t})),this.setPromise("modal",r),this.navigate(e,0,!0,n),r.promise}},{key:"updateModalSettings",value:function(){var e={msg:"luigi.navigation.updateModalSettings",updatedModalSettings:arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},addHistoryEntry:arguments.length>1&&void 0!==arguments[1]&&arguments[1]};f.sendPostMessageToLuigiCore(e)}},{key:"openAsSplitView",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.navigate(e,0,!0,void 0,t),new O(t)}},{key:"openAsDrawer",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.navigate(e,0,!0,void 0,void 0,t)}},{key:"fromContext",value:function(e){return this.currentContext.context.parentNavigationContexts&&-1!==this.currentContext.context.parentNavigationContexts.indexOf(e)?this.options.fromContext=e:(this.options.errorSkipNavigation=!0,console.error("Navigation not possible, navigationContext "+e+" not found.")),this}},{key:"fromClosestContext",value:function(){var e;return(null===(e=this.currentContext)||void 0===e?void 0:e.context.parentNavigationContexts.length)>0?(this.options.fromContext=null,this.options.fromClosestContext=!0):console.error("Navigation not possible, no parent navigationContext found."),this}},{key:"fromVirtualTreeRoot",value:function(){return this.options.fromContext=null,this.options.fromClosestContext=!1,this.options.fromVirtualTreeRoot=!0,this}},{key:"fromParent",value:function(){return this.options.fromParent=!0,this}},{key:"withParams",value:function(e){return e&&Object.assign(this.options.nodeParams,e),this}},{key:"withOptions",value:function(e){return f.isObject(e)?(void 0!==e.preventHistoryEntry&&(this.options.preventHistoryEntry=e.preventHistoryEntry),void 0!==e.preventContextUpdate&&(this.options.preventContextUpdate=e.preventContextUpdate),this):this}},{key:"pathExists",value:function(e){var t=f.getRandomId(),n=this.getPromise("pathExistsPromises")||{};n[t]={resolveFn:function(){},then:function(e){this.resolveFn=e}},this.setPromise("pathExistsPromises",n),f.addEventListener("luigi.navigation.pathExists.answer",function(e,n){var r=e.data.data,o=this.getPromise("pathExistsPromises")||{};r.correlationId===t&&(o[r.correlationId]&&(o[r.correlationId].resolveFn(r.pathExists),delete o[r.correlationId],this.setPromise("pathExistsPromises",o)),f.removeEventListener(n))}.bind(this));var r={msg:"luigi.navigation.pathExists",data:Object.assign(this.options,{id:t,link:e,intent:f.hasIntent(e),relative:"/"!==e[0]})};return f.sendPostMessageToLuigiCore(r),n[t]}},{key:"hasBack",value:function(){return!!this.currentContext.internal.modal||0!==this.currentContext.internal.viewStackSize}},{key:"goBack",value:function(e){f.sendPostMessageToLuigiCore({msg:"luigi.navigation.back",goBackContext:e&&JSON.stringify(e)})}},{key:"withoutSync",value:function(){return this.options.withoutSync=!0,this}},{key:"newTab",value:function(){return this.options.newTab=!0,this}},{key:"preserveQueryParams",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.options.preserveQueryParams=e,this}},{key:"getCurrentRoute",value:function(){var e=this,t=f.getRandomId(),n=this.getPromise("getCurrentRoute")||{};return n[t]={resolveFn:function(){},then:function(e){this.resolveFn=e}},this.setPromise("getCurrentRoute",n),f.addEventListener("luigi.navigation.currentRoute.answer",(function(n,r){var o=n.data.data,i=e.getPromise("getCurrentRoute")||{};o.correlationId===t&&(i[o.correlationId]&&(i[o.correlationId].resolveFn(o.route),delete i[o.correlationId],e.setPromise("getCurrentRoute",i)),f.removeEventListener(r)),f.removeEventListener(r)})),f.sendPostMessageToLuigiCore({msg:"luigi.navigation.currentRoute",data:Object.assign(this.options,{id:t})}),n[t]}}],r&&_(n.prototype,r),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r}(u);function U(e){return U="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},U(e)}function N(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,z(r.key),r)}}function z(e){var t=function(e){if("object"!=U(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=U(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==U(t)?t:t+""}function B(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(B=function(){return!!e})()}function H(e){return H=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},H(e)}function K(e,t){return K=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},K(e,t)}var G=new(function(e){function t(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),e=function(e,t,n){return t=H(t),function(e,t){if(t&&("object"==U(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,B()?Reflect.construct(t,n||[],H(e).constructor):t.apply(e,n))}(this,t),f.addEventListener("luigi.current-locale-changed",(function(e){var t;e.data.currentLocale&&null!==(t=h.currentContext)&&void 0!==t&&t.internal&&(h.currentContext.internal.currentLocale=e.data.currentLocale,h._notifyUpdate())})),e}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&K(e,t)}(t,e),n=t,r=[{key:"showLoadingIndicator",value:function(){f.sendPostMessageToLuigiCore({msg:"luigi.show-loading-indicator"})}},{key:"hideLoadingIndicator",value:function(){f.sendPostMessageToLuigiCore({msg:"luigi.hide-loading-indicator"})}},{key:"closeCurrentModal",value:function(){f.sendPostMessageToLuigiCore({msg:"luigi.close-modal"})}},{key:"addBackdrop",value:function(){f.sendPostMessageToLuigiCore({msg:"luigi.add-backdrop"})}},{key:"removeBackdrop",value:function(){f.sendPostMessageToLuigiCore({msg:"luigi.remove-backdrop"})}},{key:"setDirtyStatus",value:function(e){f.sendPostMessageToLuigiCore({msg:"luigi.set-page-dirty",dirty:e})}},{key:"showConfirmationModal",value:function(e){var t=this;f.addEventListener("luigi.ux.confirmationModal.hide",(function(e,n){t.hideConfirmationModal(e.data.data),f.removeEventListener(n)})),f.sendPostMessageToLuigiCore({msg:"luigi.ux.confirmationModal.show",data:{settings:e}});var n={};return n.promise=new Promise((function(e,t){n.resolveFn=e,n.rejectFn=t})),this.setPromise("confirmationModal",n),n.promise}},{key:"hideConfirmationModal",value:function(e){var t=this.getPromise("confirmationModal");t&&(e.confirmed?t.resolveFn():t.rejectFn(),this.setPromise("confirmationModal",void 0))}},{key:"showAlert",value:function(e){var t=this;e.id=f.getRandomId(),f.addEventListener("luigi.ux.alert.hide",(function(n,r){n.data.id===e.id&&(t.hideAlert(n.data),f.removeEventListener(r))})),(null==e?void 0:e.closeAfter)<100&&(console.warn("Message with id='".concat(e.id,"' has too small 'closeAfter' value. It needs to be at least 100ms.")),e.closeAfter=void 0),f.sendPostMessageToLuigiCore({msg:"luigi.ux.alert.show",data:{settings:e}});var n=this.getPromise("alerts")||{};return n[e.id]={},n[e.id].promise=new Promise((function(t){n[e.id].resolveFn=t})),this.setPromise("alerts",n),n[e.id].promise}},{key:"hideAlert",value:function(e){var t=e.id,n=e.dismissKey,r=this.getPromise("alerts");t&&r[t]&&(r[t].resolveFn(n||t),delete r[t],this.setPromise("alerts",r))}},{key:"getCurrentLocale",value:function(){var e,t;return null===(e=h.currentContext)||void 0===e||null===(t=e.internal)||void 0===t?void 0:t.currentLocale}},{key:"setCurrentLocale",value:function(e){e&&f.sendPostMessageToLuigiCore({msg:"luigi.ux.set-current-locale",data:{currentLocale:e}})}},{key:"isSplitView",value:function(){var e,t;return null===(e=h.currentContext)||void 0===e||null===(t=e.internal)||void 0===t?void 0:t.splitView}},{key:"isModal",value:function(){var e,t;return null===(e=h.currentContext)||void 0===e||null===(t=e.internal)||void 0===t?void 0:t.modal}},{key:"isDrawer",value:function(){var e,t;return null===(e=h.currentContext)||void 0===e||null===(t=e.internal)||void 0===t?void 0:t.drawer}},{key:"getCurrentTheme",value:function(){var e,t;return null===(e=h.currentContext)||void 0===e||null===(t=e.internal)||void 0===t?void 0:t.currentTheme}},{key:"getCSSVariables",value:function(){var e,t;return(null===(e=h.currentContext)||void 0===e||null===(t=e.internal)||void 0===t?void 0:t.cssVariables)||{}}},{key:"applyCSS",value:function(){var e,t;document.querySelectorAll("head style[luigi-injected]").forEach((function(e){e.remove()}));var n=null===(e=h.currentContext)||void 0===e||null===(t=e.internal)||void 0===t?void 0:t.cssVariables;if(n){var r=":root {\n";Object.keys(n).forEach((function(e){var t=n[e];r+=(e.startsWith("--")?"":"--")+e+":"+t+";\n"})),r+="}";var o=document.createElement("style");o.setAttribute("luigi-injected",!0),o.innerHTML=r,document.head.appendChild(o)}}}],r&&N(n.prototype,r),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r}(u));function Q(e){return Q="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Q(e)}function q(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function J(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,Y(r.key),r)}}function W(e,t,n){return t&&J(e.prototype,t),n&&J(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function Y(e){var t=function(e){if("object"!=Q(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=Q(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Q(t)?t:t+""}function $(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return($=function(){return!!e})()}function X(e){return X=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},X(e)}function Z(e,t){return Z=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Z(e,t)}var ee=new Map,te=function(e){function t(){var e,n,r,o;return q(this,t),(n=this,r=t,r=X(r),e=function(e,t){if(t&&("object"==Q(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(n,$()?Reflect.construct(r,o||[],X(n).constructor):r.apply(n,o))).storageEventProcessor=new ne,f.addEventListener("storage",(function(t,n){return e.storageEventProcessor.processEvent(t,n)})),e}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Z(e,t)}(t,e),W(t,[{key:"setItem",value:function(e,t){var n=this;return new Promise((function(r,o){n.storageEventProcessor.execute(r,o,"setItem",{key:e,value:t})}))}},{key:"getItem",value:function(e){var t=this;return new Promise((function(n,r){t.storageEventProcessor.execute(n,r,"getItem",{key:e})}))}},{key:"removeItem",value:function(e){var t=this;return new Promise((function(n,r){t.storageEventProcessor.execute(n,r,"removeItem",{key:e})}))}},{key:"clear",value:function(){var e=this;return new Promise((function(t,n){e.storageEventProcessor.execute(t,n,"clear",{})}))}},{key:"has",value:function(e){var t=this;return new Promise((function(n,r){t.storageEventProcessor.execute(n,r,"has",{key:e})}))}},{key:"getAllKeys",value:function(){var e=this;return new Promise((function(t,n){e.storageEventProcessor.execute(t,n,"getAllKeys",{})}))}}])}(u),ne=function(){return W((function e(){q(this,e)}),[{key:"processEvent",value:function(e,t){try{var n=e.data.data;if(!ee.has(n.id))return void console.log("Impossible to find Promise method for message "+n.id);var r=ee.get(n.id);"ERROR"===n.status?r.reject(n.result):r.resolve(n.result),ee.delete(n.id)}catch(e){console.error(e)}}},{key:"waitForSyncResult",value:function(e){for(var t=(new Date).getTime();!syncOperation.has(e);)if((new Date).getTime()-t>1e4)throw"Storage operation is taking more than 1 second...Some problem with Luigi Core communication";var n=syncOperation.get(e);return ee.delete(e),n}},{key:"execute",value:function(e,t,n,r){var o=f.getRandomId();this.createPendingOperation(o,e,t),this.sendMessage(o,n,r)}},{key:"createPendingOperation",value:function(e,t,n){ee.set(e,{resolve:t,reject:n})}},{key:"sendMessage",value:function(e,t,n){f.sendPostMessageToLuigiCore({msg:"storage",data:{id:e,operation:t,params:n}})}}])}(),re=new te;function oe(e){return oe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},oe(e)}function ie(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,ae(r.key),r)}}function ae(e){var t=function(e){if("object"!=oe(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=oe(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==oe(t)?t:t+""}var ue=function(){return e=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),window!==window.top&&("true"!==window.document.head.getAttribute("disable-luigi-history-handling")&&(history.pushState=history.replaceState.bind(history)),"true"!==window.document.head.getAttribute("disable-luigi-runtime-error-handling")&&window.addEventListener("error",(function(e){var t={msg:"luigi-runtime-error-handling",errorObj:{filename:e.filename,message:e.message,lineno:e.lineno,colno:e.colno,error:e.error}};f.sendPostMessageToLuigiCore(t)})))},(t=[{key:"addInitListener",value:function(e,t){return h.addInitListener(e,t)}},{key:"removeInitListener",value:function(e){return h.removeInitListener(e)}},{key:"addContextUpdateListener",value:function(e){return h.addContextUpdateListener(e)}},{key:"removeContextUpdateListener",value:function(e){return h.removeContextUpdateListener(e)}},{key:"getToken",value:function(){return h.getToken()}},{key:"getEventData",value:function(){return h.getEventData()}},{key:"getContext",value:function(){return h.getContext()}},{key:"addNodeParams",value:function(e,t){return h.addNodeParams(e,t)}},{key:"getNodeParams",value:function(e){return h.getNodeParams(e)}},{key:"getActiveFeatureToggles",value:function(){return h.getActiveFeatureToggles()}},{key:"getPathParams",value:function(){return h.getPathParams()}},{key:"getCoreSearchParams",value:function(){return h.getCoreSearchParams()}},{key:"addCoreSearchParams",value:function(e,t){return h.addCoreSearchParams(e,t)}},{key:"getClientPermissions",value:function(){return h.getClientPermissions()}},{key:"sendCustomMessage",value:function(e){return h.sendCustomMessage(e)}},{key:"addCustomMessageListener",value:function(e,t){return h.addCustomMessageListener(e,t)}},{key:"removeCustomMessageListener",value:function(e){return h.removeCustomMessageListener(e)}},{key:"addInactiveListener",value:function(e,t){return h.addInactiveListener(e,t)}},{key:"removeInactiveListener",value:function(e){return h.removeInactiveListener(e)}},{key:"setTargetOrigin",value:function(e){return h.setTargetOrigin(e)}},{key:"getUserSettings",value:function(){return h.getUserSettings()}},{key:"isLuigiClientInitialized",value:function(){return h.isLuigiClientInitialized()}},{key:"luigiClientInit",value:function(){return h.luigiClientInit()}},{key:"getAnchor",value:function(){return h.getAnchor()}},{key:"setAnchor",value:function(e){return h.setAnchor(e)}},{key:"setViewGroupData",value:function(e){return h.setViewGroupData(e)}},{key:"linkManager",value:function(){return new V({currentContext:h.currentContext})}},{key:"uxManager",value:function(){return G}},{key:"lifecycleManager",value:function(){return h}},{key:"storageManager",value:function(){return re}}])&&ie(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();const se=ue=new ue;return r.default})()));
2
- //# sourceMappingURL=luigi-client.js.map
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).LuigiClient=t()}(this,(function(){"use strict";function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function t(e,t,n){return t=o(t),function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,s()?Reflect.construct(t,[],o(e).constructor):t.apply(e,n))}function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t,n){return t&&function(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,v(i.key),i)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function r(e,t,n){return(t=v(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e){return o=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},o(e)}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&c(e,t)}function s(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(s=function(){return!!e})()}function u(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function l(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?u(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):u(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function c(e,t){return c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},c(e,t)}function d(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var i,r,o,a,s=[],u=!0,l=!1;try{if(o=(n=n.call(e)).next,0===t);else for(;!(u=(i=o.call(n)).done)&&(s.push(i.value),s.length!==t);u=!0);}catch(e){l=!0,r=e}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(l)throw r}}return s}}(e,t)||g(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t);if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:t+""}function g(t,n){if(t){if("string"==typeof t)return e(t,n);var i={}.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?e(t,n):void 0}}var f=function(){return i((function e(){n(this,e),this.promises={}}),[{key:"setPromise",value:function(e,t){this.promises[e]=t}},{key:"getPromise",value:function(e){return this.promises[e]}}])}(),h=function(){return i((function e(){n(this,e),this.listeners=[],this.origin="";var t=function(e){if(e.data.msg)if("custom"===e.data.msg){var t=this.convertCustomMessageInternalToUser(e.data);this.listeners.filter((function(e){return e.name===t.id})).map((function(e){return e.eventFn(t,e.listenerId)}))}else this.listeners.filter((function(t){return t.name===e.data.msg})).map((function(t){return t.eventFn(e,t.listenerId)}))}.bind(this);window.addEventListener("message",t)}),[{key:"convertCustomMessageInternalToUser",value:function(e){return e.data}},{key:"convertCustomMessageUserToInternal",value:function(e){return{msg:"custom",data:e}}},{key:"convertStorageMessageToInternal",value:function(e){return{msg:"storage",data:e}}},{key:"addEventListener",value:function(e,t){var n=this.getRandomId();return this.listeners.push({name:e,eventFn:t,listenerId:n}),n}},{key:"removeEventListener",value:function(e){return!!Boolean(this.listeners.find((function(t){return t.listenerId===e})))&&(this.listeners=this.listeners.filter((function(t){return t.listenerId!==e})),!0)}},{key:"getRandomId",value:function(){return window.crypto.getRandomValues(new Uint32Array(1))[0]}},{key:"isFunction",value:function(e){return"function"==typeof e}},{key:"isObject",value:function(e){return"[object Object]"===Object.prototype.toString.call(e)}},{key:"getLuigiCoreDomain",value:function(){return this.origin}},{key:"setLuigiCoreDomain",value:function(e){e&&"null"!==e&&(this.origin=e)}},{key:"setTargetOrigin",value:function(e){this.setLuigiCoreDomain(e)}},{key:"sendPostMessageToLuigiCore",value:function(e){if(this.origin)try{window.parent.postMessage(e,this.origin)}catch(t){console.warn("Unable to post message "+e+" to Luigi Core from origin "+this.origin+": "+t)}else console.warn('There is no target origin set. You can specify the target origin by calling LuigiClient.setTargetOrigin("targetorigin") in your micro frontend.')}},{key:"hasIntent",value:function(e){return!!e&&e.toLowerCase().includes("#?intent=")}},{key:"deSanitizeParamsMap",value:function(e){var t=this;return Object.entries(e).reduce((function(e,n){return e[t.deSanitizeParam(n[0])]=t.deSanitizeParam(n[1]),e}),{})}},{key:"deSanitizeParam",value:function(){return String(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").replaceAll("&lt;","<").replaceAll("&gt;",">").replaceAll("&quot;",'"').replaceAll("&#39;","'").replaceAll("&sol;","/")}}])}(),m=new h,p=function(e){function r(){var e;return n(this,r),(e=t(this,r)).luigiInitialized=!1,e.defaultContextKeys=["context","internal","nodeParams","pathParams","searchParams"],e.setCurrentContext(e.defaultContextKeys.reduce((function(e,t){return e[t]={},e}),{})),e._onContextUpdatedFns={},e._onInactiveFns={},e._onInitFns={},e.authData={},e._isDeferInitDefined()||e.luigiClientInit(),e}return a(r,e),i(r,[{key:"_isDeferInitDefined",value:function(){return window.document.head.hasAttribute("defer-luigi-init")}},{key:"_isTpcCheckDisabled",value:function(){var e,t,n;return window.document.head.hasAttribute("disable-tpc-check")||(null===(e=this.currentContext)||void 0===e||null===(t=e.internal)||void 0===t||null===(n=t.thirdPartyCookieCheck)||void 0===n?void 0:n.disabled)}},{key:"isLuigiClientInitialized",value:function(){return this.luigiInitialized}},{key:"luigiClientInit",value:function(){var e=this;if(this.luigiInitialized)console.warn("Luigi Client has been already initialized");else{var t=function(t){for(var n=0;n<e.defaultContextKeys.length;n++){var i=e.defaultContextKeys[n];try{"string"==typeof t[i]&&(t[i]=JSON.parse(t[i]))}catch(e){console.info("unable to parse luigi context data for",i,t[i],e)}}e.setCurrentContext(t)},n=function(t){t&&(e.authData=t)};m.addEventListener("luigi.init",(function(i){t(i.data),n(i.data.authData),m.setLuigiCoreDomain(i.origin),e.luigiInitialized=!0,e._notifyInit(i.origin),e._tpcCheck(),m.sendPostMessageToLuigiCore({msg:"luigi.init.ok"})})),m.addEventListener("luigi-client.inactive-microfrontend",(function(t){e._notifyInactive(t.origin)})),m.addEventListener("luigi.auth.tokenIssued",(function(e){n(e.data.authData)})),m.addEventListener("luigi.navigate",(function(n){if(t(n.data),!e.currentContext.internal.isNavigateBack&&!e.currentContext.withoutSync){var i=window.location.hash;history.replaceState({luigiInduced:!0},"",n.data.viewUrl),window.dispatchEvent(new PopStateEvent("popstate",{state:"luiginavigation"})),window.location.hash!==i&&window.dispatchEvent(new HashChangeEvent("hashchange"))}e.currentContext.withoutSync&&Object.assign(e.currentContext.context,{viewUrl:n.data.viewUrl?n.data.viewUrl:void 0,pathParams:n.data.pathParams?n.data.pathParams:void 0}),e._notifyUpdate(),m.sendPostMessageToLuigiCore({msg:"luigi.navigate.ok"})})),window.parent.postMessage({msg:"luigi.get-context",clientVersion:"2.26.0"},"*")}}},{key:"_tpcCheck",value:function(){if(!this._isTpcCheckDisabled()){var e,t="enabled",n=document.cookie;n&&(e=n.split(";").map((function(e){return e.trim()})).find((function(e){return"luigiCookie=true"===e}))),"luigiCookie=true"===e&&(document.cookie="luigiCookie=; Max-Age=-99999999; SameSite=None; Secure"),document.cookie="luigiCookie=true; SameSite=None; Secure",(n=document.cookie)&&(e=n.split(";").map((function(e){return e.trim()})).find((function(e){return"luigiCookie=true"===e}))),"luigiCookie=true"===e?(document.cookie="luigiCookie=; Max-Age=-99999999; SameSite=None; Secure",window.parent.postMessage({msg:"luigi.third-party-cookie",tpc:t},"*")):(t="disabled",window.parent.postMessage({msg:"luigi.third-party-cookie",tpc:t},"*"),console.warn("Third party cookies are not supported!"))}}},{key:"_callAllFns",value:function(e,t,n){for(var i in e)e.hasOwnProperty(i)&&m.isFunction(e[i])&&e[i](t,n)}},{key:"_notifyInit",value:function(e){this._callAllFns(this._onInitFns,this.currentContext.context,e)}},{key:"_notifyUpdate",value:function(){this._callAllFns(this._onContextUpdatedFns,this.currentContext.context)}},{key:"_notifyInactive",value:function(){this._callAllFns(this._onInactiveFns)}},{key:"setCurrentContext",value:function(e){this.currentContext=e}},{key:"addInitListener",value:function(e,t){var n=m.getRandomId();return this._onInitFns[n]=e,t&&document.head.setAttribute("disable-tpc-check",""),this.luigiInitialized&&m.isFunction(e)&&e(this.currentContext.context,m.getLuigiCoreDomain()),n}},{key:"removeInitListener",value:function(e){return!!this._onInitFns[e]&&(this._onInitFns[e]=void 0,!0)}},{key:"addContextUpdateListener",value:function(e){var t=m.getRandomId();return this._onContextUpdatedFns[t]=e,this.luigiInitialized&&m.isFunction(e)&&e(this.currentContext.context),t}},{key:"removeContextUpdateListener",value:function(e){return!!this._onContextUpdatedFns[e]&&(this._onContextUpdatedFns[e]=void 0,!0)}},{key:"addInactiveListener",value:function(e){var t=m.getRandomId();return this._onInactiveFns[t]=e,t}},{key:"removeInactiveListener",value:function(e){return!!this._onInactiveFns[e]&&(this._onInactiveFns[e]=void 0,!0)}},{key:"addCustomMessageListener",value:function(e,t){return m.addEventListener(e,(function(e,n){return t(e,n)}))}},{key:"removeCustomMessageListener",value:function(e){return m.removeEventListener(e)}},{key:"getToken",value:function(){return this.authData.accessToken}},{key:"getContext",value:function(){return this.getEventData()}},{key:"getEventData",value:function(){return this.currentContext.context}},{key:"getActiveFeatureToggles",value:function(){var e;return null!==(e=this.currentContext.internal.activeFeatureToggleList)&&void 0!==e?e:[]}},{key:"addNodeParams",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];e&&m.sendPostMessageToLuigiCore({msg:"luigi.addNodeParams",data:e,keepBrowserHistory:t})}},{key:"getNodeParams",value:function(){return arguments.length>0&&void 0!==arguments[0]&&arguments[0]?m.deSanitizeParamsMap(this.currentContext.nodeParams):this.currentContext.nodeParams}},{key:"getPathParams",value:function(){return this.currentContext.pathParams}},{key:"getCoreSearchParams",value:function(){return this.currentContext.searchParams||{}}},{key:"addCoreSearchParams",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];e&&m.sendPostMessageToLuigiCore({msg:"luigi.addSearchParams",data:e,keepBrowserHistory:t})}},{key:"getClientPermissions",value:function(){return this.currentContext.internal.clientPermissions||{}}},{key:"setTargetOrigin",value:function(e){m.setTargetOrigin(e)}},{key:"sendCustomMessage",value:function(e){var t=m.convertCustomMessageUserToInternal(e);m.sendPostMessageToLuigiCore(t)}},{key:"getUserSettings",value:function(){return this.currentContext.internal.userSettings}},{key:"getAnchor",value:function(){return this.currentContext.internal.anchor||""}},{key:"setAnchor",value:function(e){m.sendPostMessageToLuigiCore({msg:"luigi.setAnchor",anchor:e})}},{key:"setViewGroupData",value:function(e){m.sendPostMessageToLuigiCore({msg:"luigi.setVGData",data:e})}}])}(f),y=new p,k=function(e){function r(e){var i;n(this,r),(i=t(this,r)).validSplitViewEvents=["expand","collapse","resize","close"],i.splitView={exists:!0,size:40,collapsed:!1},Object.assign(i.splitView,e);return i.splitView.listeners=[m.addEventListener("luigi.navigation.splitview.internal",(function(e){Object.assign(i.splitView,e.data.data)}))],i.on("resize",(function(e){i.splitView.size=e})),i.on("close",(function(){i.splitView.listeners.forEach((function(e){return m.removeEventListener(e)}))})),i}return a(r,e),i(r,[{key:"sendSplitViewEvent",value:function(e,t){m.sendPostMessageToLuigiCore({msg:"luigi.navigation.splitview.".concat(e),data:t})}},{key:"collapse",value:function(){this.sendSplitViewEvent("collapse")}},{key:"expand",value:function(){this.sendSplitViewEvent("expand")}},{key:"close",value:function(){this.sendSplitViewEvent("close")}},{key:"setSize",value:function(e){this.sendSplitViewEvent("resize",e)}},{key:"on",value:function(e,t){if(!this.validSplitViewEvents.includes(e))return console.warn(e+" is not a valid split view event"),!1;var n=m.addEventListener("luigi.navigation.splitview.".concat(e,".ok"),(function(e){var n="number"==typeof e.data.data?e.data.data:void 0;t(n)}));return this.splitView.listeners.push(n),n}},{key:"removeEventListener",value:function(e){return m.removeEventListener(e)}},{key:"exists",value:function(){return this.splitView.exists}},{key:"getSize",value:function(){return this.splitView.size}},{key:"isCollapsed",value:function(){return this.splitView.collapsed}},{key:"isExpanded",value:function(){return!this.splitView.collapsed}}])}(f),C=function(e){function r(e){var i;return n(this,r),i=t(this,r),Object.assign(i,e),i.options={preserveView:!1,nodeParams:{},errorSkipNavigation:!1,fromContext:null,fromClosestContext:!1,fromVirtualTreeRoot:!1,fromParent:!1,relative:!1,link:"",newTab:!1,preserveQueryParams:!1,anchor:"",preventContextUpdate:!1,preventHistoryEntry:!1},i}return a(r,e),i(r,[{key:"navigate",value:function(e,t,n,i,r,o){if(this.options.errorSkipNavigation)this.options.errorSkipNavigation=!1;else{i&&r&&o&&console.warn("modalSettings, splitViewSettings and drawerSettings cannot be used together. Only modal setting will be taken into account."),this.options.preserveView=n;var a="/"!==e[0];if("/"===e&&(i||r||o))console.warn("Navigation with an absolute path prevented.");else{var s={msg:"luigi.navigation.open",sessionId:t,params:Object.assign(this.options,{link:e,relative:a,intent:m.hasIntent(e),modal:i,splitView:r,drawer:o})};m.sendPostMessageToLuigiCore(s)}}}},{key:"updateModalPathInternalNavigation",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(e){var i={msg:"luigi.navigation.updateModalDataPath",params:Object.assign(this.options,{link:e,modal:t,history:n})};m.sendPostMessageToLuigiCore(i)}else console.warn("Updating path of the modal upon internal navigation prevented. No path specified.")}},{key:"navigateToIntent",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i="#?intent=";if(i+=e,n&&null!==(t=Object.keys(n))&&void 0!==t&&t.length){var r=Object.entries(n);if(r.length>0){i+="?";var o,a=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=g(e))||t){n&&(e=n);var i=0,r=function(){};return{s:r,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}(r);try{for(a.s();!(o=a.n()).done;){var s=d(o.value,2);i+=s[0]+"="+s[1]+"&"}}catch(e){a.e(e)}finally{a.f()}i=i.slice(0,-1)}}this.navigate(i)}},{key:"openAsModal",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};m.addEventListener("luigi.navigation.modal.close",(function(e,n){var i,r=t.getPromise("modal");r&&(r.resolveFn(l(l({},e.data),{},{goBackValue:null===(i=e.data)||void 0===i?void 0:i.data})),t.setPromise("modal",void 0));m.removeEventListener(n)}));var i={};return i.promise=new Promise((function(e,t){i.resolveFn=e,i.rejectFn=t})),this.setPromise("modal",i),this.navigate(e,0,!0,n),i.promise}},{key:"updateModalSettings",value:function(){var e={msg:"luigi.navigation.updateModalSettings",updatedModalSettings:arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},addHistoryEntry:arguments.length>1&&void 0!==arguments[1]&&arguments[1]};m.sendPostMessageToLuigiCore(e)}},{key:"openAsSplitView",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.navigate(e,0,!0,void 0,t),new k(t)}},{key:"openAsDrawer",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.navigate(e,0,!0,void 0,void 0,t)}},{key:"fromContext",value:function(e){return this.currentContext.context.parentNavigationContexts&&-1!==this.currentContext.context.parentNavigationContexts.indexOf(e)?this.options.fromContext=e:(this.options.errorSkipNavigation=!0,console.error("Navigation not possible, navigationContext "+e+" not found.")),this}},{key:"fromClosestContext",value:function(){var e;return(null===(e=this.currentContext)||void 0===e?void 0:e.context.parentNavigationContexts.length)>0?(this.options.fromContext=null,this.options.fromClosestContext=!0):console.error("Navigation not possible, no parent navigationContext found."),this}},{key:"fromVirtualTreeRoot",value:function(){return this.options.fromContext=null,this.options.fromClosestContext=!1,this.options.fromVirtualTreeRoot=!0,this}},{key:"fromParent",value:function(){return this.options.fromParent=!0,this}},{key:"withParams",value:function(e){return e&&Object.assign(this.options.nodeParams,e),this}},{key:"withOptions",value:function(e){return m.isObject(e)?(void 0!==e.preventHistoryEntry&&(this.options.preventHistoryEntry=e.preventHistoryEntry),void 0!==e.preventContextUpdate&&(this.options.preventContextUpdate=e.preventContextUpdate),this):this}},{key:"pathExists",value:function(e){var t=m.getRandomId(),n=this.getPromise("pathExistsPromises")||{};n[t]={resolveFn:function(){},then:function(e){this.resolveFn=e}},this.setPromise("pathExistsPromises",n),m.addEventListener("luigi.navigation.pathExists.answer",function(e,n){var i=e.data.data,r=this.getPromise("pathExistsPromises")||{};i.correlationId===t&&(r[i.correlationId]&&(r[i.correlationId].resolveFn(i.pathExists),delete r[i.correlationId],this.setPromise("pathExistsPromises",r)),m.removeEventListener(n))}.bind(this));var i={msg:"luigi.navigation.pathExists",data:Object.assign(this.options,{id:t,link:e,intent:m.hasIntent(e),relative:"/"!==e[0]})};return m.sendPostMessageToLuigiCore(i),n[t]}},{key:"hasBack",value:function(){return!!this.currentContext.internal.modal||0!==this.currentContext.internal.viewStackSize}},{key:"goBack",value:function(e){m.sendPostMessageToLuigiCore({msg:"luigi.navigation.back",goBackContext:e&&JSON.stringify(e)})}},{key:"withoutSync",value:function(){return this.options.withoutSync=!0,this}},{key:"newTab",value:function(){return this.options.newTab=!0,this}},{key:"preserveQueryParams",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.options.preserveQueryParams=e,this}},{key:"getCurrentRoute",value:function(){var e=this,t=m.getRandomId(),n=this.getPromise("getCurrentRoute")||{};return n[t]={resolveFn:function(){},then:function(e){this.resolveFn=e}},this.setPromise("getCurrentRoute",n),m.addEventListener("luigi.navigation.currentRoute.answer",(function(n,i){var r=n.data.data,o=e.getPromise("getCurrentRoute")||{};r.correlationId===t&&(o[r.correlationId]&&(o[r.correlationId].resolveFn(r.route),delete o[r.correlationId],e.setPromise("getCurrentRoute",o)),m.removeEventListener(i)),m.removeEventListener(i)})),m.sendPostMessageToLuigiCore({msg:"luigi.navigation.currentRoute",data:Object.assign(this.options,{id:t})}),n[t]}}])}(f),w=new(function(e){function r(){var e;return n(this,r),e=t(this,r),m.addEventListener("luigi.current-locale-changed",(function(e){var t;e.data.currentLocale&&null!==(t=y.currentContext)&&void 0!==t&&t.internal&&(y.currentContext.internal.currentLocale=e.data.currentLocale,y._notifyUpdate())})),e}return a(r,e),i(r,[{key:"showLoadingIndicator",value:function(){m.sendPostMessageToLuigiCore({msg:"luigi.show-loading-indicator"})}},{key:"hideLoadingIndicator",value:function(){m.sendPostMessageToLuigiCore({msg:"luigi.hide-loading-indicator"})}},{key:"closeCurrentModal",value:function(){m.sendPostMessageToLuigiCore({msg:"luigi.close-modal"})}},{key:"addBackdrop",value:function(){m.sendPostMessageToLuigiCore({msg:"luigi.add-backdrop"})}},{key:"removeBackdrop",value:function(){m.sendPostMessageToLuigiCore({msg:"luigi.remove-backdrop"})}},{key:"setDirtyStatus",value:function(e){m.sendPostMessageToLuigiCore({msg:"luigi.set-page-dirty",dirty:e})}},{key:"showConfirmationModal",value:function(e){var t=this;m.addEventListener("luigi.ux.confirmationModal.hide",(function(e,n){t.hideConfirmationModal(e.data.data),m.removeEventListener(n)})),m.sendPostMessageToLuigiCore({msg:"luigi.ux.confirmationModal.show",data:{settings:e}});var n={};return n.promise=new Promise((function(e,t){n.resolveFn=e,n.rejectFn=t})),this.setPromise("confirmationModal",n),n.promise}},{key:"hideConfirmationModal",value:function(e){var t=this.getPromise("confirmationModal");t&&(e.confirmed?t.resolveFn():t.rejectFn(),this.setPromise("confirmationModal",void 0))}},{key:"showAlert",value:function(e){var t=this;e.id=m.getRandomId(),m.addEventListener("luigi.ux.alert.hide",(function(n,i){n.data.id===e.id&&(t.hideAlert(n.data),m.removeEventListener(i))})),(null==e?void 0:e.closeAfter)<100&&(console.warn("Message with id='".concat(e.id,"' has too small 'closeAfter' value. It needs to be at least 100ms.")),e.closeAfter=void 0),m.sendPostMessageToLuigiCore({msg:"luigi.ux.alert.show",data:{settings:e}});var n=this.getPromise("alerts")||{};return n[e.id]={},n[e.id].promise=new Promise((function(t){n[e.id].resolveFn=t})),this.setPromise("alerts",n),n[e.id].promise}},{key:"hideAlert",value:function(e){var t=e.id,n=e.dismissKey,i=this.getPromise("alerts");t&&i[t]&&(i[t].resolveFn(n||t),delete i[t],this.setPromise("alerts",i))}},{key:"getCurrentLocale",value:function(){var e,t;return null===(e=y.currentContext)||void 0===e||null===(t=e.internal)||void 0===t?void 0:t.currentLocale}},{key:"setCurrentLocale",value:function(e){e&&m.sendPostMessageToLuigiCore({msg:"luigi.ux.set-current-locale",data:{currentLocale:e}})}},{key:"isSplitView",value:function(){var e,t;return null===(e=y.currentContext)||void 0===e||null===(t=e.internal)||void 0===t?void 0:t.splitView}},{key:"isModal",value:function(){var e,t;return null===(e=y.currentContext)||void 0===e||null===(t=e.internal)||void 0===t?void 0:t.modal}},{key:"isDrawer",value:function(){var e,t;return null===(e=y.currentContext)||void 0===e||null===(t=e.internal)||void 0===t?void 0:t.drawer}},{key:"getCurrentTheme",value:function(){var e,t;return null===(e=y.currentContext)||void 0===e||null===(t=e.internal)||void 0===t?void 0:t.currentTheme}},{key:"getCSSVariables",value:function(){var e,t;return(null===(e=y.currentContext)||void 0===e||null===(t=e.internal)||void 0===t?void 0:t.cssVariables)||{}}},{key:"applyCSS",value:function(){var e,t;document.querySelectorAll("head style[luigi-injected]").forEach((function(e){e.remove()}));var n=null===(e=y.currentContext)||void 0===e||null===(t=e.internal)||void 0===t?void 0:t.cssVariables;if(n){var i=":root {\n";Object.keys(n).forEach((function(e){var t=n[e];i+=(e.startsWith("--")?"":"--")+e+":"+t+";\n"})),i+="}";var r=document.createElement("style");r.setAttribute("luigi-injected",!0),r.innerHTML=i,document.head.appendChild(r)}}}])}(f)),P=new Map,b=function(e){function r(){var e;return n(this,r),(e=t(this,r)).storageEventProcessor=new x,m.addEventListener("storage",(function(t,n){return e.storageEventProcessor.processEvent(t,n)})),e}return a(r,e),i(r,[{key:"setItem",value:function(e,t){var n=this;return new Promise((function(i,r){n.storageEventProcessor.execute(i,r,"setItem",{key:e,value:t})}))}},{key:"getItem",value:function(e){var t=this;return new Promise((function(n,i){t.storageEventProcessor.execute(n,i,"getItem",{key:e})}))}},{key:"removeItem",value:function(e){var t=this;return new Promise((function(n,i){t.storageEventProcessor.execute(n,i,"removeItem",{key:e})}))}},{key:"clear",value:function(){var e=this;return new Promise((function(t,n){e.storageEventProcessor.execute(t,n,"clear",{})}))}},{key:"has",value:function(e){var t=this;return new Promise((function(n,i){t.storageEventProcessor.execute(n,i,"has",{key:e})}))}},{key:"getAllKeys",value:function(){var e=this;return new Promise((function(t,n){e.storageEventProcessor.execute(t,n,"getAllKeys",{})}))}}])}(f),x=function(){return i((function e(){n(this,e)}),[{key:"processEvent",value:function(e,t){try{var n=e.data.data;if(!P.has(n.id))return void console.log("Impossible to find Promise method for message "+n.id);var i=P.get(n.id);"ERROR"===n.status?i.reject(n.result):i.resolve(n.result),P.delete(n.id)}catch(e){console.error(e)}}},{key:"waitForSyncResult",value:function(e){for(var t=(new Date).getTime();!syncOperation.has(e);){if((new Date).getTime()-t>1e4)throw"Storage operation is taking more than 1 second...Some problem with Luigi Core communication"}var n=syncOperation.get(e);return P.delete(e),n}},{key:"execute",value:function(e,t,n,i){var r=m.getRandomId();this.createPendingOperation(r,e,t),this.sendMessage(r,n,i)}},{key:"createPendingOperation",value:function(e,t,n){P.set(e,{resolve:t,reject:n})}},{key:"sendMessage",value:function(e,t,n){m.sendPostMessageToLuigiCore({msg:"storage",data:{id:e,operation:t,params:n}})}}])}(),L=new b,I=function(){return i((function e(){n(this,e),window!==window.top&&("true"!==window.document.head.getAttribute("disable-luigi-history-handling")&&(history.pushState=history.replaceState.bind(history)),"true"!==window.document.head.getAttribute("disable-luigi-runtime-error-handling")&&window.addEventListener("error",(function(e){var t={msg:"luigi-runtime-error-handling",errorObj:{filename:e.filename,message:e.message,lineno:e.lineno,colno:e.colno,error:e.error}};m.sendPostMessageToLuigiCore(t)})))}),[{key:"addInitListener",value:function(e,t){return y.addInitListener(e,t)}},{key:"removeInitListener",value:function(e){return y.removeInitListener(e)}},{key:"addContextUpdateListener",value:function(e){return y.addContextUpdateListener(e)}},{key:"removeContextUpdateListener",value:function(e){return y.removeContextUpdateListener(e)}},{key:"getToken",value:function(){return y.getToken()}},{key:"getEventData",value:function(){return y.getEventData()}},{key:"getContext",value:function(){return y.getContext()}},{key:"addNodeParams",value:function(e,t){return y.addNodeParams(e,t)}},{key:"getNodeParams",value:function(e){return y.getNodeParams(e)}},{key:"getActiveFeatureToggles",value:function(){return y.getActiveFeatureToggles()}},{key:"getPathParams",value:function(){return y.getPathParams()}},{key:"getCoreSearchParams",value:function(){return y.getCoreSearchParams()}},{key:"addCoreSearchParams",value:function(e,t){return y.addCoreSearchParams(e,t)}},{key:"getClientPermissions",value:function(){return y.getClientPermissions()}},{key:"sendCustomMessage",value:function(e){return y.sendCustomMessage(e)}},{key:"addCustomMessageListener",value:function(e,t){return y.addCustomMessageListener(e,t)}},{key:"removeCustomMessageListener",value:function(e){return y.removeCustomMessageListener(e)}},{key:"addInactiveListener",value:function(e,t){return y.addInactiveListener(e,t)}},{key:"removeInactiveListener",value:function(e){return y.removeInactiveListener(e)}},{key:"setTargetOrigin",value:function(e){return y.setTargetOrigin(e)}},{key:"getUserSettings",value:function(){return y.getUserSettings()}},{key:"isLuigiClientInitialized",value:function(){return y.isLuigiClientInitialized()}},{key:"luigiClientInit",value:function(){return y.luigiClientInit()}},{key:"getAnchor",value:function(){return y.getAnchor()}},{key:"setAnchor",value:function(e){return y.setAnchor(e)}},{key:"setViewGroupData",value:function(e){return y.setViewGroupData(e)}},{key:"linkManager",value:function(){return new C({currentContext:y.currentContext})}},{key:"uxManager",value:function(){return w}},{key:"lifecycleManager",value:function(){return y}},{key:"storageManager",value:function(){return L}}])}();return I=new I}));
package/luigi-element.js CHANGED
@@ -1 +1,158 @@
1
- export class LuigiElement extends HTMLElement{constructor(t){super();const e=!!t&&t.openShadow;this._shadowRoot=this.attachShadow({mode:e?"open":"closed",delegatesFocus:!1}),this.__initialized=!1,this.deferLuigiClientWCInit=!!t&&t.deferLuigiClientWCInit}__postProcess(t,e,i){this.LuigiClient=e,this.context=t;const o=document.createElement("template");o.innerHTML=this.render(t);const s=()=>{if(!this.__initialized){this._shadowRoot.appendChild(o.content.cloneNode(!0)),Reflect.ownKeys(Reflect.getPrototypeOf(this)).forEach((t=>{t.startsWith("$_")&&(this._shadowRoot[t]=this[t].bind(this))}));const e=this._shadowRoot.querySelectorAll("[id]");e&&e.forEach((t=>{this["$"+t.getAttribute("id")]=t})),this.afterInit(t),this.__initialized=!0}};if(this.luigiConfig&&this.luigiConfig.styleSources&&this.luigiConfig.styleSources.length>0){let t=this.luigiConfig.styleSources.length;const e=this.luigiConfig.loadStylesSync,o=()=>{t--,t<1&&s()};this.luigiConfig.styleSources.forEach(((t,s)=>{const n=document.createElement("link");n.setAttribute("rel","stylesheet"),n.setAttribute("href",i+t),e&&(n.addEventListener("load",o),n.addEventListener("error",o)),this._shadowRoot.appendChild(n)})),e||s()}else s()}afterInit(t){}render(t){return""}update(){}onContextUpdate(t){}querySelector(t){return this._shadowRoot.querySelector(t)}set context(t){this.__lui_ctx=t,this.__initialized&&(this.onContextUpdate(t),this.attributeChangedCallback())}get context(){return this.__lui_ctx}attributeChangedCallback(t,e,i){this.update()}}export function html(t,...e){let i="";return t.forEach(((t,o)=>{i+=t,o<e.length&&void 0!==e[o]&&null!==e[o]&&(i+=e[o])})),i.replace(/\$\_/gi,"this.getRootNode().$_")}
1
+ /**
2
+ * @module luigi-element
3
+ */
4
+
5
+ /**
6
+ * Base class for Luigi web component micro frontends.
7
+ * @augments HTMLElement
8
+ * @class
9
+ */
10
+ export class LuigiElement extends HTMLElement {
11
+ constructor(options) {
12
+ super();
13
+ const openShadow = options ? options.openShadow : false;
14
+ this._shadowRoot = this.attachShadow({
15
+ mode: openShadow ? 'open' : 'closed',
16
+ delegatesFocus: false
17
+ });
18
+ this.__initialized = false;
19
+ this.deferLuigiClientWCInit = options ? options.deferLuigiClientWCInit : false;
20
+ }
21
+
22
+ /**
23
+ * Invoked by luigi core if present, internal, don't override.
24
+ * @private
25
+ */
26
+ __postProcess(ctx, luigiClient, module_location_path) {
27
+ this.LuigiClient = luigiClient;
28
+ this.context = ctx;
29
+ const template = document.createElement('template');
30
+ template.innerHTML = this.render(ctx);
31
+ const attCnt = () => {
32
+ if (!this.__initialized) {
33
+ this._shadowRoot.appendChild(template.content.cloneNode(true));
34
+ Reflect.ownKeys(Reflect.getPrototypeOf(this)).forEach((el) => {
35
+ if (el.startsWith('$_')) {
36
+ this._shadowRoot[el] = this[el].bind(this);
37
+ }
38
+ });
39
+ const elementsWithIds = this._shadowRoot.querySelectorAll('[id]');
40
+ if (elementsWithIds) {
41
+ elementsWithIds.forEach((el) => {
42
+ this['$' + el.getAttribute('id')] = el;
43
+ });
44
+ }
45
+ this.afterInit(ctx);
46
+ this.__initialized = true;
47
+ }
48
+ };
49
+ if (this.luigiConfig && this.luigiConfig.styleSources && this.luigiConfig.styleSources.length > 0) {
50
+ let nr_styles = this.luigiConfig.styleSources.length;
51
+ const loadStylesSync = this.luigiConfig.loadStylesSync;
52
+ const afterLoadOrError = () => {
53
+ nr_styles--;
54
+ if (nr_styles < 1) {
55
+ attCnt();
56
+ }
57
+ };
58
+
59
+ this.luigiConfig.styleSources.forEach((element, index) => {
60
+ const link = document.createElement('link');
61
+ link.setAttribute('rel', 'stylesheet');
62
+ link.setAttribute('href', module_location_path + element);
63
+ if (loadStylesSync) {
64
+ link.addEventListener('load', afterLoadOrError);
65
+ link.addEventListener('error', afterLoadOrError);
66
+ }
67
+ this._shadowRoot.appendChild(link);
68
+ });
69
+ if (!loadStylesSync) {
70
+ attCnt();
71
+ }
72
+ } else {
73
+ attCnt();
74
+ }
75
+ }
76
+
77
+ /**
78
+ * Override to execute logic after initialization of the web component, i.e.
79
+ * after internal rendering and all context data set.
80
+ * @param {any} ctx - the context object passed by luigi core
81
+ */
82
+ afterInit(ctx) {
83
+ return;
84
+ }
85
+
86
+ /**
87
+ * Override to return the html template string defining the web component view.
88
+ * @param {any} ctx - the context object passed by luigi core
89
+ */
90
+ render(ctx) {
91
+ return '';
92
+ }
93
+
94
+ /**
95
+ * Override to execute logic after an attribute of this web component has changed.
96
+ */
97
+ update() {
98
+ return;
99
+ }
100
+
101
+ /**
102
+ * Override to execute logic when a new context object is set.
103
+ * @param {any} ctx - the new context object passed by luigi core
104
+ */
105
+ onContextUpdate(ctx) {
106
+ return;
107
+ }
108
+
109
+ /**
110
+ * Query selector operating on shadow root.
111
+ * @see ParentNode.querySelector
112
+ */
113
+ querySelector(selector) {
114
+ return this._shadowRoot.querySelector(selector);
115
+ }
116
+
117
+ /**
118
+ * Handles changes on the context property.
119
+ * @private
120
+ */
121
+ set context(ctx) {
122
+ this.__lui_ctx = ctx;
123
+ if (this.__initialized) {
124
+ this.onContextUpdate(ctx);
125
+ this.attributeChangedCallback();
126
+ }
127
+ }
128
+
129
+ get context() {
130
+ return this.__lui_ctx;
131
+ }
132
+
133
+ /**
134
+ * Handles changes on attributes.
135
+ * @private
136
+ */
137
+ attributeChangedCallback(name, oldVal, newVal) {
138
+ this.update();
139
+ }
140
+ }
141
+
142
+ /**
143
+ * Html string processing according to luigi functionality.
144
+ * Also useful in combination with LitElement VS Code plugins.
145
+ * @param {string} literal - the literal to process
146
+ * @param {unknown[]} keys - the array of keys to process
147
+ * @returns {string} the processed literal
148
+ */
149
+ export function html(literal, ...keys) {
150
+ let html = '';
151
+ literal.forEach((el, index) => {
152
+ html += el;
153
+ if (index < keys.length && keys[index] !== undefined && keys[index] !== null) {
154
+ html += keys[index];
155
+ }
156
+ });
157
+ return html.replace(/\$\_/gi, 'this.getRootNode().$_');
158
+ }
package/package.json CHANGED
@@ -17,5 +17,5 @@
17
17
  "micro-frontends",
18
18
  "microfrontends"
19
19
  ],
20
- "version": "2.26.1-dev.202601280040"
20
+ "version": "2.26.1-dev.202601281005"
21
21
  }