website-utilities 1.0.410 → 1.0.412
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/index.d.ts +1 -1
- package/index.js +1 -1
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -150,7 +150,7 @@ export declare class WebsiteUtilities<TElement = HTMLElement, ExternalProperties
|
|
|
150
150
|
context?: string;
|
|
151
151
|
value?: number;
|
|
152
152
|
}): Promise<void>;
|
|
153
|
-
|
|
153
|
+
initializePriorityNavigation(): void;
|
|
154
154
|
/**
|
|
155
155
|
* This method triggers if the viewport moves to the top.
|
|
156
156
|
*/
|
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";if("undefined"!=typeof module&&null!==module&&"undefined"!==eval("typeof require")&&null!==eval("require")&&"main"in eval("require")&&"undefined"!==eval("typeof require.main")&&null!==eval("require.main")){var ORIGINAL_MAIN_MODULE=module;module!==eval("require.main")&&"paths"in module&&"paths"in eval("require.main")&&"undefined"!=typeof __dirname&&null!==__dirname&&(module.paths=eval("require.main.paths").concat(module.paths.filter((function(path){return eval("require.main.paths").includes(path)}))))}if(null==window)var window="undefined"==typeof global||null===global?{}:global;!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@babel/runtime/helpers/applyDecoratedDescriptor"),require("@babel/runtime/helpers/initializerDefineProperty"),require("@babel/runtime/helpers/initializerWarningHelper"),require("clientnode"),require("clientnode/property-types"),require("web-component-wrapper/Web"),require("web-component-wrapper/decorator"));else if("function"==typeof define&&define.amd)define(["@babel/runtime/helpers/applyDecoratedDescriptor","@babel/runtime/helpers/initializerDefineProperty","@babel/runtime/helpers/initializerWarningHelper","clientnode","clientnode/property-types","web-component-wrapper/Web","web-component-wrapper/decorator"],t);else{var o="object"==typeof exports?t(require("@babel/runtime/helpers/applyDecoratedDescriptor"),require("@babel/runtime/helpers/initializerDefineProperty"),require("@babel/runtime/helpers/initializerWarningHelper"),require("clientnode"),require("clientnode/property-types"),require("web-component-wrapper/Web"),require("web-component-wrapper/decorator")):t(e["@babel/runtime/helpers/applyDecoratedDescriptor"],e["@babel/runtime/helpers/initializerDefineProperty"],e["@babel/runtime/helpers/initializerWarningHelper"],e.clientnode,e["clientnode/property-types"],e["web-component-wrapper/Web"],e["web-component-wrapper/decorator"]);for(var i in o)("object"==typeof exports?exports:e)[i]=o[i]}}(this,((e,t,o,i,n,r,s)=>(()=>{var l=[,,,e=>{e.exports=t},t=>{t.exports=e},e=>{e.exports=o},e=>{e.exports=i},e=>{e.exports=n},e=>{e.exports=s},e=>{e.exports=r}],a={};function c(e){var t=a[e];if(void 0!==t)return t.exports;var o=a[e]={exports:{}};return l[e](o,o.exports,c),o.exports}c.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return c.d(t,{a:t}),t},c.d=(e,t)=>{for(var o in t)c.o(t,o)&&!c.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},c.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),c.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var u={};return(()=>{c.r(u),c.d(u,{WebsiteUtilities:()=>R,api:()=>H,default:()=>Q,log:()=>$});var e,t,o,i,n,r,s,l,a,p,d,h,m,w,f,b,v,g,y,T,S,N,L,D,C,_,O,A,x,k,q,M,E,I,P=c(3),z=c.n(P),U=c(4),B=c.n(U),j=(c(5),c(6)),V=c(7),W=c(8),F=c(9);const $=new j.Logger({name:"website-utilities"});let R=(e=(0,W.property)({type:V.object}),t=(0,W.property)({type:V.func}),o=(0,W.property)({type:V.func}),i=(0,W.property)({type:V.func}),n=(0,W.property)({type:V.func}),r=(0,W.property)({type:V.func}),s=(0,W.property)({type:V.func}),l=(0,W.property)({type:V.func}),a=(0,W.property)({type:V.func}),p=(0,W.property)({type:V.func}),d=(0,W.property)({type:V.func}),h=(0,W.property)({type:V.func}),m=(0,W.property)({type:V.func}),w=(0,W.property)({type:V.func}),f=(0,W.property)({type:V.func}),b=(0,W.property)({type:V.func}),I=class e extends F.Web{constructor(){super(),this.self=e,z()(this,"options",g,this),z()(this,"onChangeMediaQueryMode",y,this),z()(this,"onChangeToExtraSmallMode",T,this),z()(this,"onChangeToLargeMode",S,this),z()(this,"onChangeToMediumMode",N,this),z()(this,"onChangeToSmallMode",L,this),z()(this,"onStartUpAnimationComplete",D,this),z()(this,"onSwitchSection",C,this),z()(this,"onViewportMovesAwayFromTop",_,this),z()(this,"onViewportMovesToTop",O,this),z()(this,"onSwitchToManualScrollingIndicator",A,this),z()(this,"onLoaded",x,this),z()(this,"onButtonClick",k,this),z()(this,"onSectionSwitch",q,this),z()(this,"onLinkClick",M,this),z()(this,"onTrack",E,this),this.currentSectionName="",this.startUpAnimationIsComplete=!1,this.continueAutoScrolling=!1,this.viewportIsOnTop=void 0,this.windowLoadingCoverDomNode=null,this.topDomNode=null,this.routerOutletDomNode=null,this.sectionDomNodes={},this.scrollToTopButtonDomNodes=null,this.defineGetterAndSetterInterface()}async onUpdateAttribute(e,t){await super.onUpdateAttribute(e,t),"options"===e&&this._extendOptions()}async render(e="unknown",t=!0){if(await super.render(e,!1),0===Object.keys(this.options).length&&this._extendOptions(),this.disableScrolling(),!this.self.windowLoaded){const e=()=>{this.self.windowLoaded||(this.self.windowLoaded=!0,this._removeLoadingCover().then((()=>{this.enableScrolling(),this._performStartUpEffects(),this.onLoaded()})))};(0,j.onDocumentReady)((()=>{(0,j.timeout)(e,this.options.windowLoadedTimeoutAfterDocLoadedInMSec)})),j.globalContext.window&&this.addSecureEventListener(j.globalContext.window,"load",e)}await this.waitForNestedComponentRendering(),this.grabDomNodes(),this._bindScrollEvents(),this._bindClickTracking(),await this._initializeRouting(),this.priorityNavigation(),await this.resolveRenderingPromiseIfSet(e,t)}grabDomNodes(){var e,t,o;this.topDomNode=this.hostDomNode.querySelector(this.options.selectors.top),this.scrollToTopButtonDomNodes=this.hostDomNode.querySelectorAll(this.options.selectors.scrollToTopButtons),this.routerOutletDomNode=this.hostDomNode.querySelector(this.options.selectors.routerOutlet);for(const e of null!==(i=this.routerOutletDomNode?.children)&&void 0!==i?i:[]){var i;const t=e.getAttribute("data-website-utilities-section");""===t?this.sectionDomNodes.default=e:t&&this.options.sectionNames.managed.includes(t)&&(this.sectionDomNodes[t]=e)}this.windowLoadingCoverDomNode=null!==(e=null!==(t=null!==(o=this.hostDomNode.querySelector(this.options.selectors.windowLoadingCover))&&void 0!==o?o:this.hostDomNode.parentElement?.querySelector(this.options.selectors.windowLoadingCover))&&void 0!==t?t:j.globalContext.document?.body.querySelector(this.options.selectors.windowLoadingCover))&&void 0!==e?e:null}interruptableScrollToTop(){const e=window.pageYOffset,t=performance.now();this.continueAutoScrolling=!0;const o=i=>{if(!this.continueAutoScrolling)return;const n=i-t,r=Math.min(n/500,1),s=r*(2-r);window.scrollTo(0,e*(1-s)),r<1?requestAnimationFrame(o):this.continueAutoScrolling=!1};requestAnimationFrame(o)}scrollToTop(){j.globalContext.document&&window.scrollTo({top:0,behavior:"smooth"})}disableScrolling(){this.hostDomNode.parentElement&&(this.hostDomNode.parentElement.classList.add("wu-disable-scrolling"),this.addSecureEventListener(this.hostDomNode.parentElement,"touchmove",j.preventDefault))}enableScrolling(){this.hostDomNode.parentElement&&(this.hostDomNode.parentElement.classList.remove("wu-disable-scrolling"),this.hostDomNode.parentElement.classList.remove("touchmove"),this.hostDomNode.parentElement.removeEventListener("touchmove",j.preventDefault))}async track(e){if(j.globalContext.window?.location&&this.options.tracking){const t={context:`${j.globalContext.window.location.pathname}#`+this.currentSectionName,...e};("number"!=typeof t.value||isNaN(t.value))&&(t.value=1),$.debug('Run tracking code: "event" with arguments:'),$.debug(t);try{await this.onTrack(t)}catch(e){$.warn(`Problem in tracking "${(0,j.represent)(t)}":`,(0,j.represent)(e))}}}priorityNavigation(){const e=this.hostDomNode.querySelectorAll(this.options.selectors.priorityNavigation),t=()=>{for(const t of e){const e=t.querySelectorAll("ul > li"),o=Array.from(e).filter((e=>!e.classList.contains(this.options.selectors.priorityNavigationOverflow.substring(1)))),i=t.querySelector("ul > li").offsetTop,n=[];let r=!0,s=0;for(const e of o){e.offsetTop!==i&&(n.push(e),r&&(n.push(o[s-1]),r=!1)),s+=1}if(n.length){const e=n.map((e=>e.cloneNode(!0)));for(const e of n)e.classList.add("wu-priority-navigation__list__item--hide");const o=t.querySelector(this.options.selectors.priorityNavigationOverflowList);if(o)for(const t of e)o.append(t);const i=t.querySelector(this.options.selectors.priorityNavigationOverflow);i&&i.classList.add("wu-priority-navigation__overflow--inline-block"),t.style.overflow="visible"}}};for(const e of this.hostDomNode.querySelectorAll(this.options.selectors.priorityNavigationOverflowTitle))e.addEventListener("click",(()=>{for(const e of this.hostDomNode.querySelectorAll(this.options.selectors.priorityNavigationOverflowList))e.classList.toggle("wu-priority-navigation__overflow__list--show")}));for(const o of e){const e=(0,j.trailingThrottle)((()=>{for(const e of o.querySelectorAll(this.options.selectors.priorityNavigationOverflowList))for(;e.firstChild;)e.removeChild(e.firstChild);for(const e of o.querySelectorAll(this.options.selectors.priorityNavigationOverflow))e.classList.remove("wu-priority-navigation__overflow--show-inline-block");for(const e of o.querySelectorAll("ul > li"))e.classList.contains(this.options.selectors.priorityNavigationOverflow.substring(1))||e.classList.remove("wu-priority-navigation__list__item--hide");t(),o.classList.remove("wu-priority-navigation--resizing")}),20);new ResizeObserver((()=>{o.classList.add("wu-priority-navigation--resizing"),e()})).observe(o)}t()}_onViewportMovesToTop(){this._finishScrollToTopButtonTransition();for(const t of null!==(e=this.scrollToTopButtonDomNodes)&&void 0!==e?e:[]){var e;const o=()=>{t.removeEventListener("transitionend",i),t.removeEventListener("transitioncancel",o)},i=()=>{this.viewportIsOnTop&&t.classList.add("wu-top-settled"),o()};t.addEventListener("transitionend",i,{once:!0}),t.addEventListener("transitioncancel",o,{once:!0}),t.classList.add("wu-scroll-up")}}async _onViewportMovesAwayFromTop(){this._finishScrollToTopButtonTransition("wu-top-settled"),await(0,j.timeout)(),this._finishScrollToTopButtonTransition();for(const t of null!==(e=this.scrollToTopButtonDomNodes)&&void 0!==e?e:[]){var e;t.classList.add("wu-scroll-down")}}async switchSection(e,t){if(j.globalContext.window&&"location"in j.globalContext.window&&(""===e||this.options.sectionNames.managed.includes(e)||this.options.sectionNames.unmanaged.includes(e))){var o,i;const n=Object.prototype.hasOwnProperty.call(this.sectionDomNodes,this.currentSectionName)?this.sectionDomNodes[this.currentSectionName]:null!==(o=this.sectionDomNodes.default)&&void 0!==o?o:null,r=Object.prototype.hasOwnProperty.call(this.sectionDomNodes,e)?this.sectionDomNodes[e]:null!==(i=this.sectionDomNodes.default)&&void 0!==i?i:null;await this.self.switchSectionLock.acquire(),$.debug(`Run section switch from "${this.currentSectionName}" to`,`"${e}".`),this.currentSectionName===e?(n&&(n.classList.remove("wu-section-active"),n.classList.add("wu-section-inactive")),r&&(r.classList.remove("wu-section-inactive"),r.classList.add("wu-section-active"))):this.options.sectionNames.unmanaged.includes(e)&&this.options.sectionNames.unmanaged.includes(this.currentSectionName)||(this.interruptableScrollToTop(),n&&(await(0,j.fadeOut)(n),n.classList.remove("wu-section-active"),n.classList.add("wu-section-inactive")),r&&(r.classList.remove("wu-section-inactive"),r.classList.add("wu-section-active"),await(0,j.fadeIn)(r)));const s=this.currentSectionName;this.currentSectionName=e;try{await this.onSectionSwitch(this.currentSectionName,s,t)}catch(e){$.warn("Problem due to call section switch callback on section",`"${this.currentSectionName}": ${(0,j.represent)(e)}`)}await this.self.switchSectionLock.release()}}_extendOptions(){this.setPropertyValue("options",(0,j.extend)(!0,{},this.self._defaultOptions,this.options))}_initializeRouting(){this._bindNavigationEvents();const e=j.globalContext.location?.hash&&j.globalContext.location.hash.substring(1);e&&(this.options.sectionNames.managed.includes(e)||this.options.sectionNames.unmanaged.includes(e))&&(this.currentSectionName=e);for(const e of Object.values(this.sectionDomNodes))e.classList.add("wu-section-inactive");return this.switchSection(null!=e?e:this.currentSectionName)}_finishScrollToTopButtonTransition(e=["wu-scroll-down","wu-scroll-up"]){for(const o of null!==(t=this.scrollToTopButtonDomNodes)&&void 0!==t?t:[]){var t;o.classList.remove(...[].concat(e))}}_bindScrollEvents(){if(j.globalContext.document){for(const e of[j.globalContext.document.body,j.globalContext.document.querySelector("html"),j.globalContext.window])for(const t of this.options.knownScrollEventNames)e&&this.addSecureEventListener(e,t,(e=>{this.onSwitchToManualScrollingIndicator(e)&&(this.continueAutoScrolling=!1)}));if(j.globalContext.window&&this.addSecureEventListener(j.globalContext.window,"scroll",(e=>{j.globalContext.window?.scrollY?this.viewportIsOnTop&&(this.viewportIsOnTop=!1,this._onViewportMovesAwayFromTop().then(this.onViewportMovesAwayFromTop.bind(this,e))):this.viewportIsOnTop||(this.viewportIsOnTop=!0,this._onViewportMovesToTop(),this.onViewportMovesToTop(e))})),j.globalContext.window?.scrollY)this.viewportIsOnTop=!1,this._onViewportMovesAwayFromTop().then((()=>{this.onViewportMovesAwayFromTop()}));else{this.viewportIsOnTop=!0;for(const t of null!==(e=this.scrollToTopButtonDomNodes)&&void 0!==e?e:[]){var e;t.classList.add("wu-top-settled")}this._onViewportMovesToTop(),this.onViewportMovesToTop()}}}async _removeLoadingCover(){await(0,j.timeout)(this.options.additionalPageLoadingTimeInMilliseconds);for(const e of this.hostDomNode.querySelectorAll(`[class^="${this.options.selectors.startUpAnimationClassPrefix}"], [class*=" ${this.options.selectors.startUpAnimationClassPrefix}"]`))e.style.opacity="0";this.windowLoadingCoverDomNode&&await(0,j.fadeOut)(this.windowLoadingCoverDomNode)}async _performStartUpEffects(){const e=[];let t=1;for(;;){const o=this.hostDomNode.querySelectorAll("."+this.options.selectors.startUpAnimationClassPrefix+String(t));if(0===o.length){await Promise.all(e),this.startUpAnimationIsComplete=!0,this.onStartUpAnimationComplete();break}await(0,j.timeout)(this.options.startUpAnimationElementDelayInMilliseconds);for(const t of o)e.push((0,j.fadeIn)(t));t+=1}}_bindNavigationEvents(){j.globalContext.window&&this.addSecureEventListener(j.globalContext.window,"hashchange",(e=>{if(this.startUpAnimationIsComplete){const t=location.hash.substring(1);this.switchSection(t,e)}})),this._bindScrollToTopButton()}_bindScrollToTopButton(){for(const e of this.scrollToTopButtonDomNodes||[])this.addSecureEventListener(e,"click",(e=>{e.preventDefault(),this.interruptableScrollToTop()}))}_bindClickTracking(){if(this.options.tracking){for(const e of this.hostDomNode.querySelectorAll("a"))this.addSecureEventListener(e,"click",this.onButtonClick.bind(this));for(const e of this.hostDomNode.querySelectorAll("button"))this.addSecureEventListener(e,"click",this.onButtonClick.bind(this))}}},I._name="WebsiteUtilities",I._defaultOptions={additionalPageLoadingTimeInMilliseconds:0,startUpAnimationElementDelayInMilliseconds:100,windowLoadedTimeoutAfterDocLoadedInMSec:2e3,domain:"auto",knownScrollEventNames:["DOMMouseScroll","keyup","mousedown","mousewheel","scroll","touchmove","wheel"],mediaQueryClassNameIndicator:[["extraSmall","xs"],["small","sm"],["medium","md"],["large","lg"]],sectionNames:{managed:["home"],unmanaged:[]},selectors:{windowLoadingCover:".wu-window-loading-cover",startUpAnimationClassPrefix:"wu-start-up-animation-number-",top:".wu-header",routerOutlet:".wu-router-outlet",scrollToTopButtons:".wu-scroll-to-top",priorityNavigation:".wu-priority-navigation",priorityNavigationOverflow:".wu-priority-navigation__overflow",priorityNavigationOverflowTitle:".wu-priority-navigation__overflow__title",priorityNavigationOverflowList:".wu-priority-navigation__overflow__list"},tracking:!1},I.windowLoaded=!1,I.switchSectionLock=new j.Lock,v=I,g=B()(v.prototype,"options",[e],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return{}}}),y=B()(v.prototype,"onChangeMediaQueryMode",[t],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return j.NOOP}}),T=B()(v.prototype,"onChangeToExtraSmallMode",[o],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return j.NOOP}}),S=B()(v.prototype,"onChangeToLargeMode",[i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return j.NOOP}}),N=B()(v.prototype,"onChangeToMediumMode",[n],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return j.NOOP}}),L=B()(v.prototype,"onChangeToSmallMode",[r],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return j.NOOP}}),D=B()(v.prototype,"onStartUpAnimationComplete",[s],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return j.NOOP}}),C=B()(v.prototype,"onSwitchSection",[l],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return j.NOOP}}),_=B()(v.prototype,"onViewportMovesAwayFromTop",[a],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return j.NOOP}}),O=B()(v.prototype,"onViewportMovesToTop",[p],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return j.NOOP}}),A=B()(v.prototype,"onSwitchToManualScrollingIndicator",[d],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return()=>!0}}),x=B()(v.prototype,"onLoaded",[h],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return j.NOOP}}),k=B()(v.prototype,"onButtonClick",[m],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return function(e){const t=e.target,o=(0,j.getText)(t).join(" ");this.onTrack({event:"buttonClick",eventType:"click",label:o,reference:t.getAttribute("action")||t.getAttribute("target")||t.getAttribute("type")||o,subject:"button",value:parseInt(t.getAttribute("website-analytics-value")||"1"),userInteraction:!0})}}}),q=B()(v.prototype,"onSectionSwitch",[w],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return async function(e,t,o){j.globalContext.window?.location&&await this.onTrack({event:"sectionSwitch",eventType:"sectionSwitch",label:e,reference:`${j.globalContext.window.location.pathname}#${e}`,subject:"url",userInteraction:!1})}}}),M=B()(v.prototype,"onLinkClick",[f],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return function(e){const t=e.target,o=(0,j.getText)(t).join(" ");this.onTrack({event:"linkClick",eventType:"click",label:o,reference:t.getAttribute("href")||t.getAttribute("action")||t.getAttribute("target")||t.getAttribute("type")||o,subject:"link",value:parseInt(t.getAttribute("website-analytics-value")||"1"),userInteraction:!0})}}}),E=B()(v.prototype,"onTrack",[b],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return function(e){return this.options.tracking&&j.globalContext.dataLayer?.push(e),Promise.resolve()}}}),v);const H={component:R,register:(e=(0,j.camelCaseToDelimited)(R._name))=>{customElements.define(e,R)}},Q=R;j.globalContext.AUTO_DEFINE_WEBSITE_UTILITIES&&H.register()})(),u})()));
|
|
1
|
+
"use strict";if("undefined"!=typeof module&&null!==module&&"undefined"!==eval("typeof require")&&null!==eval("require")&&"main"in eval("require")&&"undefined"!==eval("typeof require.main")&&null!==eval("require.main")){var ORIGINAL_MAIN_MODULE=module;module!==eval("require.main")&&"paths"in module&&"paths"in eval("require.main")&&"undefined"!=typeof __dirname&&null!==__dirname&&(module.paths=eval("require.main.paths").concat(module.paths.filter((function(path){return eval("require.main.paths").includes(path)}))))}if(null==window)var window="undefined"==typeof global||null===global?{}:global;!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@babel/runtime/helpers/applyDecoratedDescriptor"),require("@babel/runtime/helpers/initializerDefineProperty"),require("@babel/runtime/helpers/initializerWarningHelper"),require("clientnode"),require("clientnode/property-types"),require("web-component-wrapper/Web"),require("web-component-wrapper/decorator"));else if("function"==typeof define&&define.amd)define(["@babel/runtime/helpers/applyDecoratedDescriptor","@babel/runtime/helpers/initializerDefineProperty","@babel/runtime/helpers/initializerWarningHelper","clientnode","clientnode/property-types","web-component-wrapper/Web","web-component-wrapper/decorator"],t);else{var o="object"==typeof exports?t(require("@babel/runtime/helpers/applyDecoratedDescriptor"),require("@babel/runtime/helpers/initializerDefineProperty"),require("@babel/runtime/helpers/initializerWarningHelper"),require("clientnode"),require("clientnode/property-types"),require("web-component-wrapper/Web"),require("web-component-wrapper/decorator")):t(e["@babel/runtime/helpers/applyDecoratedDescriptor"],e["@babel/runtime/helpers/initializerDefineProperty"],e["@babel/runtime/helpers/initializerWarningHelper"],e.clientnode,e["clientnode/property-types"],e["web-component-wrapper/Web"],e["web-component-wrapper/decorator"]);for(var i in o)("object"==typeof exports?exports:e)[i]=o[i]}}(this,((e,t,o,i,n,r,s)=>(()=>{var l=[,,,e=>{e.exports=t},t=>{t.exports=e},e=>{e.exports=o},e=>{e.exports=i},e=>{e.exports=n},e=>{e.exports=s},e=>{e.exports=r}],a={};function c(e){var t=a[e];if(void 0!==t)return t.exports;var o=a[e]={exports:{}};return l[e](o,o.exports,c),o.exports}c.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return c.d(t,{a:t}),t},c.d=(e,t)=>{for(var o in t)c.o(t,o)&&!c.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},c.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),c.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var u={};return(()=>{c.r(u),c.d(u,{WebsiteUtilities:()=>R,api:()=>H,default:()=>Q,log:()=>$});var e,t,o,i,n,r,s,l,a,p,d,h,m,w,f,b,v,g,y,T,S,N,L,D,C,_,O,A,x,k,q,M,E,I,P=c(3),z=c.n(P),U=c(4),B=c.n(U),j=(c(5),c(6)),V=c(7),W=c(8),F=c(9);const $=new j.Logger({name:"website-utilities"});let R=(e=(0,W.property)({type:V.object}),t=(0,W.property)({type:V.func}),o=(0,W.property)({type:V.func}),i=(0,W.property)({type:V.func}),n=(0,W.property)({type:V.func}),r=(0,W.property)({type:V.func}),s=(0,W.property)({type:V.func}),l=(0,W.property)({type:V.func}),a=(0,W.property)({type:V.func}),p=(0,W.property)({type:V.func}),d=(0,W.property)({type:V.func}),h=(0,W.property)({type:V.func}),m=(0,W.property)({type:V.func}),w=(0,W.property)({type:V.func}),f=(0,W.property)({type:V.func}),b=(0,W.property)({type:V.func}),I=class e extends F.Web{constructor(){super(),this.self=e,z()(this,"options",g,this),z()(this,"onChangeMediaQueryMode",y,this),z()(this,"onChangeToExtraSmallMode",T,this),z()(this,"onChangeToLargeMode",S,this),z()(this,"onChangeToMediumMode",N,this),z()(this,"onChangeToSmallMode",L,this),z()(this,"onStartUpAnimationComplete",D,this),z()(this,"onSwitchSection",C,this),z()(this,"onViewportMovesAwayFromTop",_,this),z()(this,"onViewportMovesToTop",O,this),z()(this,"onSwitchToManualScrollingIndicator",A,this),z()(this,"onLoaded",x,this),z()(this,"onButtonClick",k,this),z()(this,"onSectionSwitch",q,this),z()(this,"onLinkClick",M,this),z()(this,"onTrack",E,this),this.currentSectionName="",this.startUpAnimationIsComplete=!1,this.continueAutoScrolling=!1,this.viewportIsOnTop=void 0,this.windowLoadingCoverDomNode=null,this.topDomNode=null,this.routerOutletDomNode=null,this.sectionDomNodes={},this.scrollToTopButtonDomNodes=null,this.defineGetterAndSetterInterface()}async onUpdateAttribute(e,t){await super.onUpdateAttribute(e,t),"options"===e&&this._extendOptions()}async render(e="unknown",t=!0){if(await super.render(e,!1),0===Object.keys(this.options).length&&this._extendOptions(),this.disableScrolling(),!this.self.windowLoaded){const e=()=>{this.self.windowLoaded||(this.self.windowLoaded=!0,this._removeLoadingCover().then((()=>{this.enableScrolling(),this._performStartUpEffects(),this.onLoaded()})))};(0,j.onDocumentReady)((()=>{(0,j.timeout)(e,this.options.windowLoadedTimeoutAfterDocLoadedInMSec)})),j.globalContext.window&&this.addSecureEventListener(j.globalContext.window,"load",e)}await this.waitForNestedComponentRendering(),this.grabDomNodes(),this._bindScrollEvents(),this._bindClickTracking(),await this._initializeRouting(),this.initializePriorityNavigation(),await this.resolveRenderingPromiseIfSet(e,t)}grabDomNodes(){var e,t,o;this.topDomNode=this.hostDomNode.querySelector(this.options.selectors.top),this.scrollToTopButtonDomNodes=this.hostDomNode.querySelectorAll(this.options.selectors.scrollToTopButtons),this.routerOutletDomNode=this.hostDomNode.querySelector(this.options.selectors.routerOutlet);for(const e of null!==(i=this.routerOutletDomNode?.children)&&void 0!==i?i:[]){var i;const t=e.getAttribute("data-website-utilities-section");""===t?this.sectionDomNodes.default=e:t&&this.options.sectionNames.managed.includes(t)&&(this.sectionDomNodes[t]=e)}this.windowLoadingCoverDomNode=null!==(e=null!==(t=null!==(o=this.hostDomNode.querySelector(this.options.selectors.windowLoadingCover))&&void 0!==o?o:this.hostDomNode.parentElement?.querySelector(this.options.selectors.windowLoadingCover))&&void 0!==t?t:j.globalContext.document?.body.querySelector(this.options.selectors.windowLoadingCover))&&void 0!==e?e:null}interruptableScrollToTop(){const e=window.pageYOffset,t=performance.now();this.continueAutoScrolling=!0;const o=i=>{if(!this.continueAutoScrolling)return;const n=i-t,r=Math.min(n/500,1),s=r*(2-r);window.scrollTo(0,e*(1-s)),r<1?requestAnimationFrame(o):this.continueAutoScrolling=!1};requestAnimationFrame(o)}scrollToTop(){j.globalContext.document&&window.scrollTo({top:0,behavior:"smooth"})}disableScrolling(){this.hostDomNode.parentElement&&(this.hostDomNode.parentElement.classList.add("wu-disable-scrolling"),this.addSecureEventListener(this.hostDomNode.parentElement,"touchmove",j.preventDefault))}enableScrolling(){this.hostDomNode.parentElement&&(this.hostDomNode.parentElement.classList.remove("wu-disable-scrolling"),this.hostDomNode.parentElement.classList.remove("touchmove"),this.hostDomNode.parentElement.removeEventListener("touchmove",j.preventDefault))}async track(e){if(j.globalContext.window?.location&&this.options.tracking){const t={context:`${j.globalContext.window.location.pathname}#`+this.currentSectionName,...e};("number"!=typeof t.value||isNaN(t.value))&&(t.value=1),$.debug('Run tracking code: "event" with arguments:'),$.debug(t);try{await this.onTrack(t)}catch(e){$.warn(`Problem in tracking "${(0,j.represent)(t)}":`,(0,j.represent)(e))}}}initializePriorityNavigation(){const e=this.hostDomNode.querySelectorAll(this.options.selectors.priorityNavigation);if(0===e.length)return;const t=()=>{for(const t of e){const e=t.querySelectorAll("ul > li"),o=Array.from(e).filter((e=>!e.classList.contains(this.options.selectors.priorityNavigationOverflow.substring(1)))),i=t.querySelector("ul > li").offsetTop,n=[];let r=!0,s=0;for(const e of o){e.offsetTop!==i&&(n.push(e),r&&(n.push(o[s-1]),r=!1)),s+=1}if(n.length){const e=n.map((e=>e.cloneNode(!0)));for(const e of n)e.classList.add("wu-priority-navigation__list__item--hide");const o=t.querySelector(this.options.selectors.priorityNavigationOverflowList);if(o)for(const t of e)o.append(t);const i=t.querySelector(this.options.selectors.priorityNavigationOverflow);i&&i.classList.add("wu-priority-navigation__overflow--inline-block"),t.style.overflow="visible"}}};for(const e of this.hostDomNode.querySelectorAll(this.options.selectors.priorityNavigationOverflowTitle))e.addEventListener("click",(()=>{for(const e of this.hostDomNode.querySelectorAll(this.options.selectors.priorityNavigationOverflowList))e.classList.toggle("wu-priority-navigation__overflow__list--show")}));for(const o of e){const e=(0,j.trailingThrottle)((()=>{for(const e of o.querySelectorAll(this.options.selectors.priorityNavigationOverflowList))for(;e.firstChild;)e.removeChild(e.firstChild);for(const e of o.querySelectorAll(this.options.selectors.priorityNavigationOverflow))e.classList.remove("wu-priority-navigation__overflow--show-inline-block");for(const e of o.querySelectorAll("ul > li"))e.classList.contains(this.options.selectors.priorityNavigationOverflow.substring(1))||e.classList.remove("wu-priority-navigation__list__item--hide");t(),o.classList.remove("wu-priority-navigation--resizing")}),20);new ResizeObserver((()=>{o.classList.add("wu-priority-navigation--resizing"),e()})).observe(o)}t()}_onViewportMovesToTop(){this._finishScrollToTopButtonTransition();for(const t of null!==(e=this.scrollToTopButtonDomNodes)&&void 0!==e?e:[]){var e;const o=()=>{t.removeEventListener("transitionend",i),t.removeEventListener("transitioncancel",o)},i=()=>{this.viewportIsOnTop&&t.classList.add("wu-top-settled"),o()};t.addEventListener("transitionend",i,{once:!0}),t.addEventListener("transitioncancel",o,{once:!0}),t.classList.add("wu-scroll-up")}}async _onViewportMovesAwayFromTop(){this._finishScrollToTopButtonTransition("wu-top-settled"),await(0,j.timeout)(),this._finishScrollToTopButtonTransition();for(const t of null!==(e=this.scrollToTopButtonDomNodes)&&void 0!==e?e:[]){var e;t.classList.add("wu-scroll-down")}}async switchSection(e,t){if(j.globalContext.window&&"location"in j.globalContext.window&&(""===e||this.options.sectionNames.managed.includes(e)||this.options.sectionNames.unmanaged.includes(e))){var o,i;const n=Object.prototype.hasOwnProperty.call(this.sectionDomNodes,this.currentSectionName)?this.sectionDomNodes[this.currentSectionName]:null!==(o=this.sectionDomNodes.default)&&void 0!==o?o:null,r=Object.prototype.hasOwnProperty.call(this.sectionDomNodes,e)?this.sectionDomNodes[e]:null!==(i=this.sectionDomNodes.default)&&void 0!==i?i:null;await this.self.switchSectionLock.acquire(),$.debug(`Run section switch from "${this.currentSectionName}" to`,`"${e}".`),this.currentSectionName===e?(n&&(n.classList.remove("wu-section-active"),n.classList.add("wu-section-inactive")),r&&(r.classList.remove("wu-section-inactive"),r.classList.add("wu-section-active"))):this.options.sectionNames.unmanaged.includes(e)&&this.options.sectionNames.unmanaged.includes(this.currentSectionName)||(this.interruptableScrollToTop(),n&&(await(0,j.fadeOut)(n),n.classList.remove("wu-section-active"),n.classList.add("wu-section-inactive")),r&&(r.classList.remove("wu-section-inactive"),r.classList.add("wu-section-active"),await(0,j.fadeIn)(r)));const s=this.currentSectionName;this.currentSectionName=e;try{await this.onSectionSwitch(this.currentSectionName,s,t)}catch(e){$.warn("Problem due to call section switch callback on section",`"${this.currentSectionName}": ${(0,j.represent)(e)}`)}await this.self.switchSectionLock.release()}}_extendOptions(){this.setPropertyValue("options",(0,j.extend)(!0,{},this.self._defaultOptions,this.options))}_initializeRouting(){this._bindNavigationEvents();const e=j.globalContext.location?.hash&&j.globalContext.location.hash.substring(1);e&&(this.options.sectionNames.managed.includes(e)||this.options.sectionNames.unmanaged.includes(e))&&(this.currentSectionName=e);for(const e of Object.values(this.sectionDomNodes))e.classList.add("wu-section-inactive");return this.switchSection(null!=e?e:this.currentSectionName)}_finishScrollToTopButtonTransition(e=["wu-scroll-down","wu-scroll-up"]){for(const o of null!==(t=this.scrollToTopButtonDomNodes)&&void 0!==t?t:[]){var t;o.classList.remove(...[].concat(e))}}_bindScrollEvents(){if(j.globalContext.document){for(const e of[j.globalContext.document.body,j.globalContext.document.querySelector("html"),j.globalContext.window])for(const t of this.options.knownScrollEventNames)e&&this.addSecureEventListener(e,t,(e=>{this.onSwitchToManualScrollingIndicator(e)&&(this.continueAutoScrolling=!1)}));if(j.globalContext.window&&this.addSecureEventListener(j.globalContext.window,"scroll",(e=>{j.globalContext.window?.scrollY?this.viewportIsOnTop&&(this.viewportIsOnTop=!1,this._onViewportMovesAwayFromTop().then(this.onViewportMovesAwayFromTop.bind(this,e))):this.viewportIsOnTop||(this.viewportIsOnTop=!0,this._onViewportMovesToTop(),this.onViewportMovesToTop(e))})),j.globalContext.window?.scrollY)this.viewportIsOnTop=!1,this._onViewportMovesAwayFromTop().then((()=>{this.onViewportMovesAwayFromTop()}));else{this.viewportIsOnTop=!0;for(const t of null!==(e=this.scrollToTopButtonDomNodes)&&void 0!==e?e:[]){var e;t.classList.add("wu-top-settled")}this._onViewportMovesToTop(),this.onViewportMovesToTop()}}}async _removeLoadingCover(){await(0,j.timeout)(this.options.additionalPageLoadingTimeInMilliseconds);for(const e of this.hostDomNode.querySelectorAll(`[class^="${this.options.selectors.startUpAnimationClassPrefix}"], [class*=" ${this.options.selectors.startUpAnimationClassPrefix}"]`))e.style.opacity="0";this.windowLoadingCoverDomNode&&await(0,j.fadeOut)(this.windowLoadingCoverDomNode)}async _performStartUpEffects(){const e=[];let t=1;for(;;){const o=this.hostDomNode.querySelectorAll("."+this.options.selectors.startUpAnimationClassPrefix+String(t));if(0===o.length){await Promise.all(e),this.startUpAnimationIsComplete=!0,this.onStartUpAnimationComplete();break}await(0,j.timeout)(this.options.startUpAnimationElementDelayInMilliseconds);for(const t of o)e.push((0,j.fadeIn)(t));t+=1}}_bindNavigationEvents(){j.globalContext.window&&this.addSecureEventListener(j.globalContext.window,"hashchange",(e=>{if(this.startUpAnimationIsComplete){const t=location.hash.substring(1);this.switchSection(t,e)}})),this._bindScrollToTopButton()}_bindScrollToTopButton(){for(const e of this.scrollToTopButtonDomNodes||[])this.addSecureEventListener(e,"click",(e=>{e.preventDefault(),this.interruptableScrollToTop()}))}_bindClickTracking(){if(this.options.tracking){for(const e of this.hostDomNode.querySelectorAll("a"))this.addSecureEventListener(e,"click",this.onButtonClick.bind(this));for(const e of this.hostDomNode.querySelectorAll("button"))this.addSecureEventListener(e,"click",this.onButtonClick.bind(this))}}},I._name="WebsiteUtilities",I._defaultOptions={additionalPageLoadingTimeInMilliseconds:0,startUpAnimationElementDelayInMilliseconds:100,windowLoadedTimeoutAfterDocLoadedInMSec:2e3,domain:"auto",knownScrollEventNames:["DOMMouseScroll","keyup","mousedown","mousewheel","scroll","touchmove","wheel"],mediaQueryClassNameIndicator:[["extraSmall","xs"],["small","sm"],["medium","md"],["large","lg"]],sectionNames:{managed:["home"],unmanaged:[]},selectors:{windowLoadingCover:".wu-window-loading-cover",startUpAnimationClassPrefix:"wu-start-up-animation-number-",top:".wu-header",routerOutlet:".wu-router-outlet",scrollToTopButtons:".wu-scroll-to-top",priorityNavigation:".wu-priority-navigation",priorityNavigationOverflow:".wu-priority-navigation__overflow",priorityNavigationOverflowTitle:".wu-priority-navigation__overflow__title",priorityNavigationOverflowList:".wu-priority-navigation__overflow__list"},tracking:!1},I.windowLoaded=!1,I.switchSectionLock=new j.Lock,v=I,g=B()(v.prototype,"options",[e],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return{}}}),y=B()(v.prototype,"onChangeMediaQueryMode",[t],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return j.NOOP}}),T=B()(v.prototype,"onChangeToExtraSmallMode",[o],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return j.NOOP}}),S=B()(v.prototype,"onChangeToLargeMode",[i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return j.NOOP}}),N=B()(v.prototype,"onChangeToMediumMode",[n],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return j.NOOP}}),L=B()(v.prototype,"onChangeToSmallMode",[r],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return j.NOOP}}),D=B()(v.prototype,"onStartUpAnimationComplete",[s],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return j.NOOP}}),C=B()(v.prototype,"onSwitchSection",[l],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return j.NOOP}}),_=B()(v.prototype,"onViewportMovesAwayFromTop",[a],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return j.NOOP}}),O=B()(v.prototype,"onViewportMovesToTop",[p],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return j.NOOP}}),A=B()(v.prototype,"onSwitchToManualScrollingIndicator",[d],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return()=>!0}}),x=B()(v.prototype,"onLoaded",[h],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return j.NOOP}}),k=B()(v.prototype,"onButtonClick",[m],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return function(e){const t=e.target,o=(0,j.getText)(t).join(" ");this.onTrack({event:"buttonClick",eventType:"click",label:o,reference:t.getAttribute("action")||t.getAttribute("target")||t.getAttribute("type")||o,subject:"button",value:parseInt(t.getAttribute("website-analytics-value")||"1"),userInteraction:!0})}}}),q=B()(v.prototype,"onSectionSwitch",[w],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return async function(e,t,o){j.globalContext.window?.location&&await this.onTrack({event:"sectionSwitch",eventType:"sectionSwitch",label:e,reference:`${j.globalContext.window.location.pathname}#${e}`,subject:"url",userInteraction:!1})}}}),M=B()(v.prototype,"onLinkClick",[f],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return function(e){const t=e.target,o=(0,j.getText)(t).join(" ");this.onTrack({event:"linkClick",eventType:"click",label:o,reference:t.getAttribute("href")||t.getAttribute("action")||t.getAttribute("target")||t.getAttribute("type")||o,subject:"link",value:parseInt(t.getAttribute("website-analytics-value")||"1"),userInteraction:!0})}}}),E=B()(v.prototype,"onTrack",[b],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return function(e){return this.options.tracking&&j.globalContext.dataLayer?.push(e),Promise.resolve()}}}),v);const H={component:R,register:(e=(0,j.camelCaseToDelimited)(R._name))=>{customElements.define(e,R)}},Q=R;j.globalContext.AUTO_DEFINE_WEBSITE_UTILITIES&&H.register()})(),u})()));
|