@telia-ace/widget-utilities 1.3.25-rc.3 → 1.3.25

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.
Files changed (3) hide show
  1. package/index.js +1 -1
  2. package/index.mjs +31 -19
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function L(e){const t=[];return e.forEach(o=>{t.indexOf(o)===-1&&t.push(o)}),t}function w(e="",t=""){const o=e.split(" ").concat(t.split(" "));return L(o).join(" ").trim()}function W(e,t){if(e){if(typeof t=="string")return t;if(Array.isArray(t)){let o="";return t.forEach(r=>o=w(o,r)),o}}}function z(...e){let t="";return e.length&&e.forEach(o=>{typeof o=="string"?t=w(t,o):Array.isArray(o)?t=w(t,W(...o)):typeof o<"u"&&o!==null&&process.env.NODE_ENV!=="production"&&h.warn("appendClassNames: arguments either haveto be a string or [boolean, ...string[]]. Passed args:",...e)}),t}const I=(e,t)=>{let o,r=[];return i=>(clearTimeout(o),new Promise((n,a)=>{r.push([i,n,a]),o=setTimeout(()=>{let f=t();r.forEach(([c,g,m])=>{f=c(f)}),r=[],n(f)},e)}))};function T(e){const t={};if(typeof e=="number"||typeof e=="string")return e;for(const o in e)if(e.hasOwnProperty(o)){const r=e[o],i=o.substring(0,1).toLowerCase()+o.substring(1);if(Object.prototype.toString.call(r)==="[object Array]"){t[i]=[];for(let n=0,a=r.length;n<a;n++)t[i].push(T(r[n]))}else r!==null&&typeof r=="object"?t[i]=T(r):t[i]=r}return t}function O(e={}){const{phrase:t="",category:o,guideCategory:r,contactCategory:i,take:n,connectionKey:a,accordion:f,id:c,uriName:g,sorting:m,tag:u,tagId:l,tagTitle:p,...D}=e,s={};return Object.keys(D).forEach(k=>{typeof e[k]=="string"&&(s[k]=e[k])}),typeof t=="string"&&t.length&&(s.phrase=t),t===null&&(s.phrase=t),typeof r=="string"&&r!=="0"&&(s.guideCategory=r),typeof r=="number"&&r!==0&&(s.guideCategory=r),typeof r=="object"&&r!==null&&(typeof r.id=="string"&&r.id!=="0"&&(s.guideCategory=r.id),typeof r.id=="number"&&r.id!==0&&(s.guideCategory=r.id)),typeof i=="string"&&i!=="0"&&(s.contactCategory=i),typeof i=="number"&&i!==0&&(s.contactCategory=i),typeof i=="object"&&i!==null&&(typeof i.id=="string"&&i.id!=="0"&&(s.contactCategory=i.id),typeof i.id=="number"&&i.id!==0&&(s.contactCategory=i.id)),typeof o=="string"&&o!=="0"&&(s.category=o),typeof o=="number"&&o!==0&&(s.category=o),typeof o=="object"&&o!==null&&(typeof o.id=="string"&&o.id!=="0"&&(s.category=o.id),typeof o.id=="number"&&o.id!==0&&(s.category=o.id)),c&&(s.id=c),g&&(+s.category||+s.guideCategory||+s.guide||+s.contactCategory||+s.contactMethod)&&(s.uriName=g),a&&(s.connectionKey=a),n&&(s.take=n),m&&(s.sorting=m),typeof f=="string"&&f.length>0&&(s.accordion=f),typeof u=="string"&&u!=="0"&&(s.tag=u),typeof u=="number"&&u!==0&&(s.tag=u),Array.isArray(u)&&u.length&&(s.tag=u),(typeof l=="string"||typeof l=="number")&&(s.tagId=l),typeof p=="string"&&(s.tagTitle=p),typeof s.tag=="string"&&(s.tag=s.tag.split(",")),s}function*x(e){if(e)for(let t=0;t<e.length;t++){const o=e[t];yield o,o.items&&(yield*x(o.items))}}const N=(e,t)=>{const o=x(t);let r=o.next(),i=null;for(;!r.done;)r.value.id===e&&(i=r.value),r=o.next();return i},$=e=>{if(!e)return"";const t=[{from:/[äæǽ]+/gi,to:"ae"},{from:/[öœ]+/gi,to:"oe"},{from:/[ü]+/gi,to:"ue"},{from:/[Ä]+/gi,to:"Ae"},{from:/[Ü]+/gi,to:"Ue"},{from:/[Ö]+/gi,to:"Oe"},{from:/[ÀÁÂÃÄÅǺĀĂĄǍΑΆẢẠẦẪẨẬẰẮẴẲẶА]+/gi,to:"A"},{from:/[àáâãåǻāăąǎªαάảạầấẫẩậằắẵẳặа]+/gi,to:"a"},{from:/[Б]+/gi,to:"B"},{from:/[б]+/gi,to:"b"},{from:/[ÇĆĈĊČ]+/gi,to:"C"},{from:/[çćĉċč]+/gi,to:"c"},{from:/[Д]+/gi,to:"D"},{from:/[д]+/gi,to:"d"},{from:/[ÐĎĐΔ]+/gi,to:"Dj"},{from:/[ðďđδ]+/gi,to:"dj"},{from:/[ÈÉÊËĒĔĖĘĚΕΈẼẺẸỀẾỄỂỆЕЭ]+/gi,to:"E"},{from:/[èéêëēĕėęěέεẽẻẹềếễểệеэ]+/gi,to:"e"},{from:/[Ф]+/gi,to:"F"},{from:/[ф]+/gi,to:"f"},{from:/[ĜĞĠĢΓГҐ]+/gi,to:"G"},{from:/[ĝğġģγгґ]+/gi,to:"g"},{from:/[ĤĦ]+/gi,to:"H"},{from:/[ĥħ]+/gi,to:"h"},{from:/[ÌÍÎÏĨĪĬǏĮİΗΉΊΙΪỈỊИЫ]+/gi,to:"I"},{from:/[ìíîïĩīĭǐįıηήίιϊỉịиыї]+/gi,to:"i"},{from:/[Ĵ]+/gi,to:"J"},{from:/[ĵ]+/gi,to:"j"},{from:/[ĶΚК]+/gi,to:"K"},{from:/[ķκк]+/gi,to:"k"},{from:/[ĹĻĽĿŁΛЛ]+/gi,to:"L"},{from:/[ĺļľŀłλл]+/gi,to:"l"},{from:/[М]+/gi,to:"M"},{from:/[м]+/gi,to:"m"},{from:/[ÑŃŅŇΝН]+/gi,to:"N"},{from:/[ñńņňʼnνн]+/gi,to:"n"},{from:/[ÒÓÔÕŌŎǑŐƠØǾΟΌΩΏỎỌỒỐỖỔỘỜỚỠỞỢО]+/gi,to:"O"},{from:/[òóôõōŏǒőơøǿºοόωώỏọồốỗổộờớỡởợо]+/gi,to:"o"},{from:/[П]+/gi,to:"P"},{from:/[п]+/gi,to:"p"},{from:/[ŔŖŘΡР]+/gi,to:"R"},{from:/[ŕŗřρр]+/gi,to:"r"},{from:/[ŚŜŞȘŠΣС]+/gi,to:"S"},{from:/[śŝşșšſσςс]+/gi,to:"s"},{from:/[ȚŢŤŦτТ]+/gi,to:"T"},{from:/[țţťŧт]+/gi,to:"t"},{from:/[ÙÚÛŨŪŬŮŰŲƯǓǕǗǙǛŨỦỤỪỨỮỬỰУ]+/gi,to:"U"},{from:/[ùúûũūŭůűųưǔǖǘǚǜυύϋủụừứữửựу]+/gi,to:"u"},{from:/[ÝŸŶΥΎΫỲỸỶỴЙ]+/gi,to:"Y"},{from:/[ýÿŷỳỹỷỵй]+/gi,to:"y"},{from:/[В]+/gi,to:"V"},{from:/[в]+/gi,to:"v"},{from:/[Ŵ]+/gi,to:"W"},{from:/[ŵ]+/gi,to:"w"},{from:/[ŹŻŽΖЗ]+/gi,to:"Z"},{from:/[źżžζз]+/gi,to:"z"},{from:/[ÆǼ]+/gi,to:"AE"},{from:/[ß]+/gi,to:"ss"},{from:/[IJ]+/gi,to:"IJ"},{from:/[ij]+/gi,to:"ij"},{from:/[Œ]+/gi,to:"OE"},{from:/[ƒ]+/gi,to:"f"},{from:/[ξ]+/gi,to:"ks"},{from:/[π]+/gi,to:"p"},{from:/[β]+/gi,to:"v"},{from:/[μ]+/gi,to:"m"},{from:/[ψ]+/gi,to:"ps"},{from:/[Ё]+/gi,to:"Yo"},{from:/[ё]+/gi,to:"yo"},{from:/[Є]+/gi,to:"Ye"},{from:/[є]+/gi,to:"ye"},{from:/[Ї]+/gi,to:"Yi"},{from:/[Ж]+/gi,to:"Zh"},{from:/[ж]+/gi,to:"zh"},{from:/[Х]+/gi,to:"Kh"},{from:/[х]+/gi,to:"kh"},{from:/[Ц]+/gi,to:"Ts"},{from:/[ц]+/gi,to:"ts"},{from:/[Ч]+/gi,to:"Ch"},{from:/[ч]+/gi,to:"ch"},{from:/[Ш]+/gi,to:"Sh"},{from:/[ш]+/gi,to:"sh"},{from:/[Щ]+/gi,to:"Shch"},{from:/[щ]+/gi,to:"shch"},{from:/[ЪъЬь]+/gi,to:""},{from:/[Ю]+/gi,to:"Yu"},{from:/[ю]+/gi,to:"yu"},{from:/[Я]+/gi,to:"Ya"},{from:/[я]+/gi,to:"ya"}],o=/[^a-zA-Z0-9]+/g,r=/[-]$/;let i=e;for(const n in t)t.hasOwnProperty(n)&&t[n].from.test(e)&&(i=i.replace(t[n].from,t[n].to));return i=i.replace(o,"-"),i=i.replace(r,""),i=i.toLowerCase(),i||"humany"};function E(e,t={},o){return e.forEach(r=>{o&&(t[+r.id]=o),r.items&&E(r.items,t,r.id)}),t}function S(e,t,o=[e],r=E(t)){const i=a=>{const f=r[+a];f&&(o.unshift(f),i(f))},n=r[+e];return n&&(o.unshift(n),i(n)),o}const q=(e,t)=>typeof e>"u"||typeof t>"u"?new Map:new Map(e.map(o=>{const r=N(o,t);return[o,r]})),B=(e,t,o,r="guide-categories")=>o.getAsync("dataClient").then(i=>i.fetch(r,{expandCategories:"descendants"}).then(({categories:n})=>{const a=f=>{const c=S(f,n),g=q(c,n),m=[];return c.forEach(u=>{const l=g.get(u);l&&m.push({routeName:e,title:l.title,symbol:l.symbol,id:l.id,routeParams:O(r==="contact-method-categories"?{contactCategory:l.id,uriName:$(l.title)}:{guideCategory:l.id,uriName:$(l.title)})})}),m};return Array.isArray(t)?t.reduce((f,c)=>{const g=a(c);return g.length>0&&f.push(g),f},[]):a(t)})),M=e=>{let t;e.split(",")[0].indexOf("base64")!==-1?t=atob(e.split(",")[1]):t=decodeURI(e.split(",")[1]);const o=e.split(",")[0].split(":")[1].split(";")[0],r=[];for(let i=0;i<t.length;i++)r[i]=t.charCodeAt(i);return new Blob([new Uint8Array(r)],{type:o})};function U(...e){return process.env.NODE_ENV!=="production"&&console&&console.warn(...e)}const A=(e,t,...o)=>typeof t=="string"?e(`[humany] ${t}`,...o):e(t,...o),y=class{constructor(){this.keys=[],this.log=(e,...t)=>this.lookup(e,()=>y.log(...t)),this.warn=(e,...t)=>this.lookup(e,()=>y.warn(...t)),this.error=(e,...t)=>this.lookup(e,()=>y.error(...t)),this.info=(e,...t)=>this.lookup(e,()=>y.info(...t))}lookup(e,t){this.keys.indexOf(e)===-1&&(this.keys.push(e),t())}};let h=y;h.log=(...e)=>A(console.log,...e);h.warn=(...e)=>A(console.warn,...e);h.error=(...e)=>A(console.error,...e);h.info=(...e)=>A(console.info,...e);const C=e=>{let t={},o,r;if(typeof e!="object"||e===null)return e;t=Array.isArray(e)?[]:{};for(r in e)o=e[r],t[r]=typeof o=="object"&&o!==null?C(o):o;return t},V=e=>{if(!e)return null;const t=localStorage.getItem(`humany_${P(e.tenant+e.name)}`);if(t){const{activeStickyWidget:o}=JSON.parse(t);if(o&&o.value&&e.widgets.get(o.value)){const i=document.createElement("a");i.setAttribute("href",`//${e.bindings[0]}/${o.value}`),document.body.appendChild(i)}}},F=(e,t=!1)=>{const o=new Date(e);let r=`${o.getMonth()+1}`,i=`${o.getDate()}`;const n=o.getFullYear();if(r.length<2&&(r=`0${r}`),i.length<2&&(i=`0${i}`),t){let a=`${o.getHours()}`,f=`${o.getMinutes()}`;return a.length<2&&(a=`0${a}`),f.length<2&&(f=`0${f}`),`${[n,r,i].join("-")} ${[a,f].join(":")}`}return[n,r,i].join("-")};function Y(e){const t=document.cookie;if(t.length>0){let o=t.indexOf(`${e}=`);if(o!==-1){o=o+e.length+1;let r=t.indexOf(";",o);return r===-1&&(r=t.length),unescape(t.substring(o,r))}}return null}function P(e){let t=0;if(e.length===0)return t.toString();for(let o=0;o<e.length;o++){const r=e.charCodeAt(o);t=(t<<5)-t+r,t=t&t}return t.toString()}const K=(e,t)=>{if(!e||!t)return!0;let o=t.parentNode,r=!1;for(;o!==null;)o===e&&(r=!0),o=o.parentNode;return r};function _(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/\s+/g,"-").toLowerCase()}class Z{constructor(t,o){this.lockWarningTime=t,this.lockErrorTime=o,this.tasks=[],this.current=Promise.resolve(),this.next=this.next.bind(this)}add(t,o,r,i){this.tasks.push({task:t,resolve:o,reject:r,done:i}),this.next()}next(){this.current=this.current.then(()=>{const t=this.tasks.shift();if(t){let o;const r=setTimeout(()=>{process.env.NODE_ENV!=="production"&&h.warn(`A lock has exceeded ${this.lockWarningTime} ms. Waiting additional ${this.lockErrorTime} ms before rejecting the task.`,t),o=setTimeout(()=>{t.reject("lock timeout exceeded")},this.lockErrorTime)},this.lockWarningTime),i=Promise.resolve(t.task()).then(n=>(clearTimeout(r),clearTimeout(o),n));return Promise.resolve(i).then(this.next).then(()=>i.then(n=>{t.done(),t.resolve(n)})).catch(n=>(t.done(),t.reject(n),this.next()))}return Promise.resolve()})}}const b=new WeakMap;function J(e,t=5e3,o=1e3){return b.has(e)||b.set(e,new Z(t,o)),r=>new Promise((i,n)=>{const a=b.get(e);a.add(r,i,n,()=>{a.tasks.length||b.delete(e)})})}const v=e=>!!e&&typeof e=="object"&&!Array.isArray(e),Q=(e,...t)=>{const o=C(e),r=C(t);return j(o,...r)},j=(e,...t)=>{if(!t.length)return e;const o=t.shift();if(v(e)&&v(o))for(const r in o)v(o[r])?(e[r]||Object.assign(e,{[r]:{}}),j(e[r],o[r])):Object.assign(e,{[r]:o[r]});return j(e,...t)},H=(e,t)=>{const o=()=>t.querySelectorAll("[data-loading=true]").length>0,i=(()=>{let a=!1;return()=>{if(a)return;e.get("$widget").events.dispatch("widget:data-loaded",{element:t}),a=!0}})();if(!o())return i();new MutationObserver((a,f)=>{a.find(g=>g.type==="attributes"&&g.attributeName==="data-loading")&&!o()&&(f.disconnect(),i())}).observe(t,{attributes:!0,childList:!0,subtree:!0})},R=(e,t)=>{e.get("$widget").container.getAsync("components").then(r=>{r.events.subscribeOnce("components:component-model-initialized",()=>{let i=r.nodes.visible.reduce((f,c)=>(!c.name||!c.type||c.type==="view"||c.type==="root"||c.attributes.layout.size==="none"||t.querySelector(`[data-name="${c.name}"]`)||f.push(c.name),f),[]),n=!1;new MutationObserver((f,c)=>{f.forEach(g=>{if(g.addedNodes){const m=Array.from(g.addedNodes).reduce((u,l)=>{const p=l.getAttribute&&l.getAttribute("data-name");return p&&i.indexOf(p)>-1&&u.push(p),u},[]);i=i.filter(u=>m.indexOf(u)===-1),!n&&i.length===0&&(n=!0,H(e,t),c.disconnect())}})}).observe(t,{attributes:!1,characterData:!1,childList:!0,subtree:!0,attributeOldValue:!1,characterDataOldValue:!1})})})},G=(e={})=>(Object.keys(e).forEach(t=>{(e[t]===null||typeof e[t]>"u")&&delete e[t]}),e);function X(e,t,o){let r="";if(o){const i=new Date;i.setTime(i.getTime()+o*24*60*60*1e3),r=`; expires=${i.toUTCString()}`}document.cookie=`${e}=${t}${r}; path=/`}const tt=(e,t)=>{let o=!0;return Object.keys(e).length!==Object.keys(t).length||Object.keys(e).some(i=>!Object.keys(t).some(a=>i===a))?!1:(Object.keys(e).forEach(i=>{if(o){const n=typeof e[i]>"u"?"":e[i],a=typeof t[i]>"u"?"":t[i];o=n.toString()===a.toString()}}),o)},d=()=>Math.floor((1+Math.random())*65536).toString(16).substring(1);function et(){return d()+d()+"-"+d()+"-"+d()+"-"+d()+"-"+d()+d()+d()}class ot{constructor(t){this.queue=[],this.queueAttemptCalls=0,this.callCount=5,this.add=o=>{this.queue.push(o),this.queueAttempt=setInterval(this.processQueue,1e3)},this.processQueue=()=>{if(this.queue.length>0){const o=[];this.queue.forEach((r,i)=>{const n=r();typeof n=="function"&&(n(),o.push(i))}),this.queue=this.queue.filter((r,i)=>!(o.indexOf(i)>-1)),this.queueAttempt&&clearInterval(this.queueAttempt)}this.queueAttemptCalls>this.callCount&&(clearInterval(this.queueAttempt),this.queueAttemptCalls=0),this.queueAttemptCalls=this.queueAttemptCalls+1},t&&t.callCount&&(this.callCount=t.callCount)}}exports.Logger=h;exports.WaitFor=ot;exports.appendClassNames=z;exports.buildCategoryTrail=B;exports.camilize=T;exports.categoryTrail=S;exports.createBatch=I;exports.createParams=O;exports.dataURItoBlob=M;exports.debugLog=U;exports.deepClone=C;exports.findAndActivateStoredWidgets=V;exports.findCategoryById=N;exports.formatDate=F;exports.formatUrl=$;exports.getCategoryTrailAsObjects=q;exports.getCookie=Y;exports.hash=P;exports.htmlParentContains=K;exports.kebabCase=_;exports.lock=J;exports.mergeDeep=Q;exports.notifyDataLoaded=R;exports.removeNullAndUndefinedValues=G;exports.setCookie=X;exports.shallowCompare=tt;exports.uuid=et;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function L(e){const t=[];return e.forEach(o=>{t.indexOf(o)===-1&&t.push(o)}),t}function w(e="",t=""){const o=e.split(" ").concat(t.split(" "));return L(o).join(" ").trim()}function W(e,t){if(e){if(typeof t=="string")return t;if(Array.isArray(t)){let o="";return t.forEach(r=>o=w(o,r)),o}}}function z(...e){let t="";return e.length&&e.forEach(o=>{typeof o=="string"?t=w(t,o):Array.isArray(o)?t=w(t,W(...o)):typeof o<"u"&&o!==null&&process.env.NODE_ENV!=="production"&&h.warn("appendClassNames: arguments either haveto be a string or [boolean, ...string[]]. Passed args:",...e)}),t}const I=(e,t)=>{let o,r=[];return i=>(clearTimeout(o),new Promise((n,a)=>{r.push([i,n,a]),o=setTimeout(()=>{let f=t();r.forEach(([c,g,m])=>{f=c(f)}),r=[],n(f)},e)}))};function T(e){const t={};if(typeof e=="number"||typeof e=="string")return e;for(const o in e)if(e.hasOwnProperty(o)){const r=e[o],i=o.substring(0,1).toLowerCase()+o.substring(1);if(Object.prototype.toString.call(r)==="[object Array]"){t[i]=[];for(let n=0,a=r.length;n<a;n++)t[i].push(T(r[n]))}else r!==null&&typeof r=="object"?t[i]=T(r):t[i]=r}return t}function O(e={}){const{phrase:t="",category:o,guideCategory:r,contactCategory:i,take:n,connectionKey:a,accordion:f,id:c,uriName:g,sorting:m,tag:u,tagId:l,tagTitle:p,...D}=e,s={};return Object.keys(D).forEach(v=>{typeof e[v]=="string"&&(s[v]=e[v])}),typeof t=="string"&&t.length&&(s.phrase=t),t===null&&(s.phrase=t),typeof r=="string"&&r!=="0"&&(s.guideCategory=r),typeof r=="number"&&r!==0&&(s.guideCategory=r),typeof r=="object"&&r!==null&&(typeof r.id=="string"&&r.id!=="0"&&(s.guideCategory=r.id),typeof r.id=="number"&&r.id!==0&&(s.guideCategory=r.id)),typeof i=="string"&&i!=="0"&&(s.contactCategory=i),typeof i=="number"&&i!==0&&(s.contactCategory=i),typeof i=="object"&&i!==null&&(typeof i.id=="string"&&i.id!=="0"&&(s.contactCategory=i.id),typeof i.id=="number"&&i.id!==0&&(s.contactCategory=i.id)),typeof o=="string"&&o!=="0"&&(s.category=o),typeof o=="number"&&o!==0&&(s.category=o),typeof o=="object"&&o!==null&&(typeof o.id=="string"&&o.id!=="0"&&(s.category=o.id),typeof o.id=="number"&&o.id!==0&&(s.category=o.id)),c&&(s.id=c),g&&(+s.category||+s.guideCategory||+s.guide||+s.contactCategory||+s.contactMethod)&&(s.uriName=g),a&&(s.connectionKey=a),n&&(s.take=n),m&&(s.sorting=m),typeof f=="string"&&f.length>0&&(s.accordion=f),typeof u=="string"&&u!=="0"&&(s.tag=u),typeof u=="number"&&u!==0&&(s.tag=u),Array.isArray(u)&&u.length&&(s.tag=u),(typeof l=="string"||typeof l=="number")&&(s.tagId=l),typeof p=="string"&&(s.tagTitle=p),typeof s.tag=="string"&&(s.tag=s.tag.split(",")),s}function*x(e){if(e)for(let t=0;t<e.length;t++){const o=e[t];yield o,o.items&&(yield*x(o.items))}}const N=(e,t)=>{const o=x(t);let r=o.next(),i=null;for(;!r.done;)r.value.id===e&&(i=r.value),r=o.next();return i},$=e=>{if(!e)return"";const t=[{from:/[äæǽ]+/gi,to:"ae"},{from:/[öœ]+/gi,to:"oe"},{from:/[ü]+/gi,to:"ue"},{from:/[Ä]+/gi,to:"Ae"},{from:/[Ü]+/gi,to:"Ue"},{from:/[Ö]+/gi,to:"Oe"},{from:/[ÀÁÂÃÄÅǺĀĂĄǍΑΆẢẠẦẪẨẬẰẮẴẲẶА]+/gi,to:"A"},{from:/[àáâãåǻāăąǎªαάảạầấẫẩậằắẵẳặа]+/gi,to:"a"},{from:/[Б]+/gi,to:"B"},{from:/[б]+/gi,to:"b"},{from:/[ÇĆĈĊČ]+/gi,to:"C"},{from:/[çćĉċč]+/gi,to:"c"},{from:/[Д]+/gi,to:"D"},{from:/[д]+/gi,to:"d"},{from:/[ÐĎĐΔ]+/gi,to:"Dj"},{from:/[ðďđδ]+/gi,to:"dj"},{from:/[ÈÉÊËĒĔĖĘĚΕΈẼẺẸỀẾỄỂỆЕЭ]+/gi,to:"E"},{from:/[èéêëēĕėęěέεẽẻẹềếễểệеэ]+/gi,to:"e"},{from:/[Ф]+/gi,to:"F"},{from:/[ф]+/gi,to:"f"},{from:/[ĜĞĠĢΓГҐ]+/gi,to:"G"},{from:/[ĝğġģγгґ]+/gi,to:"g"},{from:/[ĤĦ]+/gi,to:"H"},{from:/[ĥħ]+/gi,to:"h"},{from:/[ÌÍÎÏĨĪĬǏĮİΗΉΊΙΪỈỊИЫ]+/gi,to:"I"},{from:/[ìíîïĩīĭǐįıηήίιϊỉịиыї]+/gi,to:"i"},{from:/[Ĵ]+/gi,to:"J"},{from:/[ĵ]+/gi,to:"j"},{from:/[ĶΚК]+/gi,to:"K"},{from:/[ķκк]+/gi,to:"k"},{from:/[ĹĻĽĿŁΛЛ]+/gi,to:"L"},{from:/[ĺļľŀłλл]+/gi,to:"l"},{from:/[М]+/gi,to:"M"},{from:/[м]+/gi,to:"m"},{from:/[ÑŃŅŇΝН]+/gi,to:"N"},{from:/[ñńņňʼnνн]+/gi,to:"n"},{from:/[ÒÓÔÕŌŎǑŐƠØǾΟΌΩΏỎỌỒỐỖỔỘỜỚỠỞỢО]+/gi,to:"O"},{from:/[òóôõōŏǒőơøǿºοόωώỏọồốỗổộờớỡởợо]+/gi,to:"o"},{from:/[П]+/gi,to:"P"},{from:/[п]+/gi,to:"p"},{from:/[ŔŖŘΡР]+/gi,to:"R"},{from:/[ŕŗřρр]+/gi,to:"r"},{from:/[ŚŜŞȘŠΣС]+/gi,to:"S"},{from:/[śŝşșšſσςс]+/gi,to:"s"},{from:/[ȚŢŤŦτТ]+/gi,to:"T"},{from:/[țţťŧт]+/gi,to:"t"},{from:/[ÙÚÛŨŪŬŮŰŲƯǓǕǗǙǛŨỦỤỪỨỮỬỰУ]+/gi,to:"U"},{from:/[ùúûũūŭůűųưǔǖǘǚǜυύϋủụừứữửựу]+/gi,to:"u"},{from:/[ÝŸŶΥΎΫỲỸỶỴЙ]+/gi,to:"Y"},{from:/[ýÿŷỳỹỷỵй]+/gi,to:"y"},{from:/[В]+/gi,to:"V"},{from:/[в]+/gi,to:"v"},{from:/[Ŵ]+/gi,to:"W"},{from:/[ŵ]+/gi,to:"w"},{from:/[ŹŻŽΖЗ]+/gi,to:"Z"},{from:/[źżžζз]+/gi,to:"z"},{from:/[ÆǼ]+/gi,to:"AE"},{from:/[ß]+/gi,to:"ss"},{from:/[IJ]+/gi,to:"IJ"},{from:/[ij]+/gi,to:"ij"},{from:/[Œ]+/gi,to:"OE"},{from:/[ƒ]+/gi,to:"f"},{from:/[ξ]+/gi,to:"ks"},{from:/[π]+/gi,to:"p"},{from:/[β]+/gi,to:"v"},{from:/[μ]+/gi,to:"m"},{from:/[ψ]+/gi,to:"ps"},{from:/[Ё]+/gi,to:"Yo"},{from:/[ё]+/gi,to:"yo"},{from:/[Є]+/gi,to:"Ye"},{from:/[є]+/gi,to:"ye"},{from:/[Ї]+/gi,to:"Yi"},{from:/[Ж]+/gi,to:"Zh"},{from:/[ж]+/gi,to:"zh"},{from:/[Х]+/gi,to:"Kh"},{from:/[х]+/gi,to:"kh"},{from:/[Ц]+/gi,to:"Ts"},{from:/[ц]+/gi,to:"ts"},{from:/[Ч]+/gi,to:"Ch"},{from:/[ч]+/gi,to:"ch"},{from:/[Ш]+/gi,to:"Sh"},{from:/[ш]+/gi,to:"sh"},{from:/[Щ]+/gi,to:"Shch"},{from:/[щ]+/gi,to:"shch"},{from:/[ЪъЬь]+/gi,to:""},{from:/[Ю]+/gi,to:"Yu"},{from:/[ю]+/gi,to:"yu"},{from:/[Я]+/gi,to:"Ya"},{from:/[я]+/gi,to:"ya"}],o=/[^a-zA-Z0-9]+/g,r=/[-]$/;let i=e;for(const n in t)t.hasOwnProperty(n)&&t[n].from.test(e)&&(i=i.replace(t[n].from,t[n].to));return i=i.replace(o,"-"),i=i.replace(r,""),i=i.toLowerCase(),i||"humany"};function E(e,t={},o){return e.forEach(r=>{o&&(t[+r.id]=o),r.items&&E(r.items,t,r.id)}),t}function S(e,t,o=[e],r=E(t)){const i=a=>{const f=r[+a];f&&(o.unshift(f),i(f))},n=r[+e];return n&&(o.unshift(n),i(n)),o}const q=(e,t)=>typeof e>"u"||typeof t>"u"?new Map:new Map(e.map(o=>{const r=N(o,t);return[o,r]})),B=(e,t,o,r="guide-categories")=>o.getAsync("dataClient").then(i=>i.fetch(r,{expandCategories:"descendants"}).then(({categories:n})=>{const a=f=>{const c=S(f,n),g=q(c,n),m=[];return c.forEach(u=>{const l=g.get(u);l&&m.push({routeName:e,title:l.title,symbol:l.symbol,id:l.id,routeParams:O(r==="contact-method-categories"?{contactCategory:l.id,uriName:$(l.title)}:{guideCategory:l.id,uriName:$(l.title)})})}),m};return Array.isArray(t)?t.reduce((f,c)=>{const g=a(c);return g.length>0&&f.push(g),f},[]):a(t)})),M=e=>{let t;e.split(",")[0].indexOf("base64")!==-1?t=atob(e.split(",")[1]):t=decodeURI(e.split(",")[1]);const o=e.split(",")[0].split(":")[1].split(";")[0],r=[];for(let i=0;i<t.length;i++)r[i]=t.charCodeAt(i);return new Blob([new Uint8Array(r)],{type:o})};function U(...e){return process.env.NODE_ENV!=="production"&&console&&console.warn(...e)}const A=(e,t,...o)=>typeof t=="string"?e(`[humany] ${t}`,...o):e(t,...o),y=class{constructor(){this.keys=[],this.log=(e,...t)=>this.lookup(e,()=>y.log(...t)),this.warn=(e,...t)=>this.lookup(e,()=>y.warn(...t)),this.error=(e,...t)=>this.lookup(e,()=>y.error(...t)),this.info=(e,...t)=>this.lookup(e,()=>y.info(...t))}lookup(e,t){this.keys.indexOf(e)===-1&&(this.keys.push(e),t())}};let h=y;h.log=(...e)=>A(console.log,...e);h.warn=(...e)=>A(console.warn,...e);h.error=(...e)=>A(console.error,...e);h.info=(...e)=>A(console.info,...e);const C=e=>{let t={},o,r;if(typeof e!="object"||e===null)return e;t=Array.isArray(e)?[]:{};for(r in e)o=e[r],t[r]=typeof o=="object"&&o!==null?C(o):o;return t},V=e=>{var o;if(!e)return null;const t=localStorage.getItem(`humany_${P(e.tenant+e.name)}`);if(t){const{activeStickyWidget:r}=JSON.parse(t);if(r&&r.value){const i=e.widgets.get(r.value);if(i)if(r.value.endsWith("_contact-method")){const n=e.widgets.get(r.value.slice(0,-7));(o=n==null?void 0:n.events)==null||o.subscribe("widget:attached",()=>{i.activate(),i.invoke("attach"),i.invoke("open")})}else{const n=document.createElement("a");n.setAttribute("href",`//${e.bindings[0]}/${r.value}`),document.body.appendChild(n)}}}},F=(e,t=!1)=>{const o=new Date(e);let r=`${o.getMonth()+1}`,i=`${o.getDate()}`;const n=o.getFullYear();if(r.length<2&&(r=`0${r}`),i.length<2&&(i=`0${i}`),t){let a=`${o.getHours()}`,f=`${o.getMinutes()}`;return a.length<2&&(a=`0${a}`),f.length<2&&(f=`0${f}`),`${[n,r,i].join("-")} ${[a,f].join(":")}`}return[n,r,i].join("-")};function Y(e){const t=document.cookie;if(t.length>0){let o=t.indexOf(`${e}=`);if(o!==-1){o=o+e.length+1;let r=t.indexOf(";",o);return r===-1&&(r=t.length),unescape(t.substring(o,r))}}return null}function P(e){let t=0;if(e.length===0)return t.toString();for(let o=0;o<e.length;o++){const r=e.charCodeAt(o);t=(t<<5)-t+r,t=t&t}return t.toString()}const _=(e,t)=>{if(!e||!t)return!0;let o=t.parentNode,r=!1;for(;o!==null;)o===e&&(r=!0),o=o.parentNode;return r};function K(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/\s+/g,"-").toLowerCase()}class Z{constructor(t,o){this.lockWarningTime=t,this.lockErrorTime=o,this.tasks=[],this.current=Promise.resolve(),this.next=this.next.bind(this)}add(t,o,r,i){this.tasks.push({task:t,resolve:o,reject:r,done:i}),this.next()}next(){this.current=this.current.then(()=>{const t=this.tasks.shift();if(t){let o;const r=setTimeout(()=>{process.env.NODE_ENV!=="production"&&h.warn(`A lock has exceeded ${this.lockWarningTime} ms. Waiting additional ${this.lockErrorTime} ms before rejecting the task.`,t),o=setTimeout(()=>{t.reject("lock timeout exceeded")},this.lockErrorTime)},this.lockWarningTime),i=Promise.resolve(t.task()).then(n=>(clearTimeout(r),clearTimeout(o),n));return Promise.resolve(i).then(this.next).then(()=>i.then(n=>{t.done(),t.resolve(n)})).catch(n=>(t.done(),t.reject(n),this.next()))}return Promise.resolve()})}}const b=new WeakMap;function J(e,t=5e3,o=1e3){return b.has(e)||b.set(e,new Z(t,o)),r=>new Promise((i,n)=>{const a=b.get(e);a.add(r,i,n,()=>{a.tasks.length||b.delete(e)})})}const k=e=>!!e&&typeof e=="object"&&!Array.isArray(e),Q=(e,...t)=>{const o=C(e),r=C(t);return j(o,...r)},j=(e,...t)=>{if(!t.length)return e;const o=t.shift();if(k(e)&&k(o))for(const r in o)k(o[r])?(e[r]||Object.assign(e,{[r]:{}}),j(e[r],o[r])):Object.assign(e,{[r]:o[r]});return j(e,...t)},H=(e,t)=>{const o=()=>t.querySelectorAll("[data-loading=true]").length>0,i=(()=>{let a=!1;return()=>{if(a)return;e.get("$widget").events.dispatch("widget:data-loaded",{element:t}),a=!0}})();if(!o())return i();new MutationObserver((a,f)=>{a.find(g=>g.type==="attributes"&&g.attributeName==="data-loading")&&!o()&&(f.disconnect(),i())}).observe(t,{attributes:!0,childList:!0,subtree:!0})},R=(e,t)=>{e.get("$widget").container.getAsync("components").then(r=>{r.events.subscribeOnce("components:component-model-initialized",()=>{let i=r.nodes.visible.reduce((f,c)=>(!c.name||!c.type||c.type==="view"||c.type==="root"||c.attributes.layout.size==="none"||t.querySelector(`[data-name="${c.name}"]`)||f.push(c.name),f),[]),n=!1;new MutationObserver((f,c)=>{f.forEach(g=>{if(g.addedNodes){const m=Array.from(g.addedNodes).reduce((u,l)=>{const p=l.getAttribute&&l.getAttribute("data-name");return p&&i.indexOf(p)>-1&&u.push(p),u},[]);i=i.filter(u=>m.indexOf(u)===-1),!n&&i.length===0&&(n=!0,H(e,t),c.disconnect())}})}).observe(t,{attributes:!1,characterData:!1,childList:!0,subtree:!0,attributeOldValue:!1,characterDataOldValue:!1})})})},G=(e={})=>(Object.keys(e).forEach(t=>{(e[t]===null||typeof e[t]>"u")&&delete e[t]}),e);function X(e,t,o){let r="";if(o){const i=new Date;i.setTime(i.getTime()+o*24*60*60*1e3),r=`; expires=${i.toUTCString()}`}document.cookie=`${e}=${t}${r}; path=/`}const tt=(e,t)=>{let o=!0;return Object.keys(e).length!==Object.keys(t).length||Object.keys(e).some(i=>!Object.keys(t).some(a=>i===a))?!1:(Object.keys(e).forEach(i=>{if(o){const n=typeof e[i]>"u"?"":e[i],a=typeof t[i]>"u"?"":t[i];o=n.toString()===a.toString()}}),o)},d=()=>Math.floor((1+Math.random())*65536).toString(16).substring(1);function et(){return d()+d()+"-"+d()+"-"+d()+"-"+d()+"-"+d()+d()+d()}class ot{constructor(t){this.queue=[],this.queueAttemptCalls=0,this.callCount=5,this.add=o=>{this.queue.push(o),this.queueAttempt=setInterval(this.processQueue,1e3)},this.processQueue=()=>{if(this.queue.length>0){const o=[];this.queue.forEach((r,i)=>{const n=r();typeof n=="function"&&(n(),o.push(i))}),this.queue=this.queue.filter((r,i)=>!(o.indexOf(i)>-1)),this.queueAttempt&&clearInterval(this.queueAttempt)}this.queueAttemptCalls>this.callCount&&(clearInterval(this.queueAttempt),this.queueAttemptCalls=0),this.queueAttemptCalls=this.queueAttemptCalls+1},t&&t.callCount&&(this.callCount=t.callCount)}}exports.Logger=h;exports.WaitFor=ot;exports.appendClassNames=z;exports.buildCategoryTrail=B;exports.camilize=T;exports.categoryTrail=S;exports.createBatch=I;exports.createParams=O;exports.dataURItoBlob=M;exports.debugLog=U;exports.deepClone=C;exports.findAndActivateStoredWidgets=V;exports.findCategoryById=N;exports.formatDate=F;exports.formatUrl=$;exports.getCategoryTrailAsObjects=q;exports.getCookie=Y;exports.hash=P;exports.htmlParentContains=_;exports.kebabCase=K;exports.lock=J;exports.mergeDeep=Q;exports.notifyDataLoaded=R;exports.removeNullAndUndefinedValues=G;exports.setCookie=X;exports.shallowCompare=tt;exports.uuid=et;
package/index.mjs CHANGED
@@ -4,7 +4,7 @@ function q(e) {
4
4
  t.indexOf(o) === -1 && t.push(o);
5
5
  }), t;
6
6
  }
7
- function v(e = "", t = "") {
7
+ function k(e = "", t = "") {
8
8
  const o = e.split(" ").concat(t.split(" "));
9
9
  return q(o).join(" ").trim();
10
10
  }
@@ -14,14 +14,14 @@ function S(e, t) {
14
14
  return t;
15
15
  if (Array.isArray(t)) {
16
16
  let o = "";
17
- return t.forEach((r) => o = v(o, r)), o;
17
+ return t.forEach((r) => o = k(o, r)), o;
18
18
  }
19
19
  }
20
20
  }
21
21
  function M(...e) {
22
22
  let t = "";
23
23
  return e.length && e.forEach((o) => {
24
- typeof o == "string" ? t = v(t, o) : Array.isArray(o) ? t = v(t, S(...o)) : typeof o < "u" && o !== null && process.env.NODE_ENV !== "production" && p.warn(
24
+ typeof o == "string" ? t = k(t, o) : Array.isArray(o) ? t = k(t, S(...o)) : typeof o < "u" && o !== null && process.env.NODE_ENV !== "production" && p.warn(
25
25
  "appendClassNames: arguments either haveto be a string or [boolean, ...string[]]. Passed args:",
26
26
  ...e
27
27
  );
@@ -228,7 +228,7 @@ const L = (e, t) => typeof e > "u" || typeof t > "u" ? /* @__PURE__ */ new Map()
228
228
  const g = c(a);
229
229
  return g.length > 0 && f.push(g), f;
230
230
  }, []) : c(t);
231
- })), F = (e) => {
231
+ })), _ = (e) => {
232
232
  let t;
233
233
  e.split(",")[0].indexOf("base64") !== -1 ? t = atob(e.split(",")[1]) : t = decodeURI(e.split(",")[1]);
234
234
  const o = e.split(",")[0].split(":")[1].split(";")[0], r = [];
@@ -236,7 +236,7 @@ const L = (e, t) => typeof e > "u" || typeof t > "u" ? /* @__PURE__ */ new Map()
236
236
  r[i] = t.charCodeAt(i);
237
237
  return new Blob([new Uint8Array(r)], { type: o });
238
238
  };
239
- function K(...e) {
239
+ function F(...e) {
240
240
  return process.env.NODE_ENV !== "production" && console && console.warn(...e);
241
241
  }
242
242
  const C = (e, t, ...o) => typeof t == "string" ? e(`[humany] ${t}`, ...o) : e(t, ...o), y = class {
@@ -260,20 +260,32 @@ const w = (e) => {
260
260
  for (r in e)
261
261
  o = e[r], t[r] = typeof o == "object" && o !== null ? w(o) : o;
262
262
  return t;
263
- }, _ = (e) => {
263
+ }, K = (e) => {
264
+ var o;
264
265
  if (!e)
265
266
  return null;
266
267
  const t = localStorage.getItem(
267
268
  `humany_${z(e.tenant + e.name)}`
268
269
  );
269
270
  if (t) {
270
- const { activeStickyWidget: o } = JSON.parse(t);
271
- if (o && o.value && e.widgets.get(o.value)) {
272
- const i = document.createElement("a");
273
- i.setAttribute(
274
- "href",
275
- `//${e.bindings[0]}/${o.value}`
276
- ), document.body.appendChild(i);
271
+ const { activeStickyWidget: r } = JSON.parse(t);
272
+ if (r && r.value) {
273
+ const i = e.widgets.get(r.value);
274
+ if (i)
275
+ if (r.value.endsWith("_contact-method")) {
276
+ const n = e.widgets.get(
277
+ r.value.slice(0, -7)
278
+ );
279
+ (o = n == null ? void 0 : n.events) == null || o.subscribe("widget:attached", () => {
280
+ i.activate(), i.invoke("attach"), i.invoke("open");
281
+ });
282
+ } else {
283
+ const n = document.createElement("a");
284
+ n.setAttribute(
285
+ "href",
286
+ `//${e.bindings[0]}/${r.value}`
287
+ ), document.body.appendChild(n);
288
+ }
277
289
  }
278
290
  }
279
291
  }, B = (e, t = !1) => {
@@ -358,16 +370,16 @@ function Q(e, t = 5e3, o = 1e3) {
358
370
  });
359
371
  });
360
372
  }
361
- const k = (e) => !!e && typeof e == "object" && !Array.isArray(e), H = (e, ...t) => {
373
+ const v = (e) => !!e && typeof e == "object" && !Array.isArray(e), H = (e, ...t) => {
362
374
  const o = w(e), r = w(t);
363
375
  return O(o, ...r);
364
376
  }, O = (e, ...t) => {
365
377
  if (!t.length)
366
378
  return e;
367
379
  const o = t.shift();
368
- if (k(e) && k(o))
380
+ if (v(e) && v(o))
369
381
  for (const r in o)
370
- k(o[r]) ? (e[r] || Object.assign(e, { [r]: {} }), O(e[r], o[r])) : Object.assign(e, { [r]: o[r] });
382
+ v(o[r]) ? (e[r] || Object.assign(e, { [r]: {} }), O(e[r], o[r])) : Object.assign(e, { [r]: o[r] });
371
383
  return O(e, ...t);
372
384
  }, I = (e, t) => {
373
385
  const o = () => t.querySelectorAll("[data-loading=true]").length > 0, i = (() => {
@@ -471,10 +483,10 @@ export {
471
483
  D as categoryTrail,
472
484
  V as createBatch,
473
485
  x as createParams,
474
- F as dataURItoBlob,
475
- K as debugLog,
486
+ _ as dataURItoBlob,
487
+ F as debugLog,
476
488
  w as deepClone,
477
- _ as findAndActivateStoredWidgets,
489
+ K as findAndActivateStoredWidgets,
478
490
  P as findCategoryById,
479
491
  B as formatDate,
480
492
  T as formatUrl,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telia-ace/widget-utilities",
3
- "version": "1.3.25-rc.3",
3
+ "version": "1.3.25",
4
4
  "dependencies": {
5
5
  "@webprovisions/platform": "^1.1.4"
6
6
  },