UNPKG

@postnord/web-components

Version:
5 lines 2.89 kB
/*! * Built with Stencil * By PostNord. */ import{transformTag as n}from"@stencil/core/internal/client";const t=[];for(let n=0;n<256;++n)t.push((n+256).toString(16).slice(1));let o;const r=new Uint8Array(16);var e={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};const s="SE",u="DK",c="FI",i="NO",a="sv",d="en",p="da",f="fi",m="no",w=[s,"DK","FI","NO"],l=[a,d,p,f,m],y={SE:[a,d],DK:[p,d],FI:[f,a,d],NO:[m,d]},h={KB:1024,MB:1048576,GB:1073741824,TB:1099511627776},b=function(n){const t=n.trim();if(!t)return 0;const o=t.search(/[a-zA-Z]/),r=-1===o?t:t.slice(0,o).trim(),e=-1===o?"":t.slice(o).trim();if(!r||e&&!/^[a-zA-Z]{2}$/.test(e))return 0;const s=Number(r);if(!Number.isFinite(s))return 0;const u=e.toUpperCase(),c=h[u];return c?s*c:s};function g(){return window.innerWidth/16<55}function v(){const{matches:n}=window.matchMedia("(prefers-reduced-motion: reduce)");return n}const N=()=>{return e.randomUUID?e.randomUUID():function(n){const e=(n=n||{}).random??n.rng?.()??function(){if(!o){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");o=crypto.getRandomValues.bind(crypto)}return o(r)}();if(e.length<16)throw new Error("Random bytes length must be >= 16");return e[6]=15&e[6]|64,e[8]=63&e[8]|128,function(n,o=0){return(t[n[o+0]]+t[n[o+1]]+t[n[o+2]]+t[n[o+3]]+"-"+t[n[o+4]]+t[n[o+5]]+"-"+t[n[o+6]]+t[n[o+7]]+"-"+t[n[o+8]]+t[n[o+9]]+"-"+t[n[o+10]]+t[n[o+11]]+t[n[o+12]]+t[n[o+13]]+t[n[o+14]]+t[n[o+15]]).toLowerCase()}(e)}(n);var n};function x(){return document?.querySelector("pn-topbar")?.offsetHeight||0}function D(){return g()&&document?.querySelector("pn-side-menu")?.offsetHeight||0}function B(){return g()?0:document?.querySelector("pn-side-menu")?.offsetWidth||0}function E(){const n=x()+D();return n>window.scrollY?n-window.scrollY:0}async function F(n){const t=()=>window.pnTopbar;function o(o){const r=o||t();return n.market=r.market,n.language=r.language,r.hasLoaded&&(t().onChangeMarket=t=>n.market=t,t().onChangeLanguage=t=>n.language=t),r}return await new Promise((r=>document.querySelector("pn-topbar")?t()?.hasLoaded?r(o()):void window.addEventListener("topbarLoaded",(()=>r(o()))):r(o({hasLoaded:!1,market:n.market||s,language:n.language||d}))))}const I=(t,o,r)=>{if(v())return;const{left:e,top:s,width:u,height:c}=o.getBoundingClientRect(),{clientX:i=0,clientY:a=0}=t||{},d=u>c?u:c,p=document.createElement(n("div"));p.classList.add("pn-ripple"),p.style.height=2*d+"px",p.style.width=2*d+"px",p.style.left=i>0?i-e+"px":"50%",p.style.top=a>0?a-s+"px":"50%",r?o.querySelector(r).appendChild(p):o.appendChild(p),setTimeout((()=>p.remove()),400)};export{u as D,c as F,i as N,s as S,y as a,x as b,D as c,p as d,d as e,f,b as g,B as h,g as i,E as j,F as k,l,w as m,m as n,I as o,v as r,a as s,N as u}