web-push-notifications 3.110.0 → 3.115.0

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 (37) hide show
  1. package/CHANGELOG.md +65 -0
  2. package/core/Pushwoosh.d.ts +3 -0
  3. package/core/Pushwoosh.types.d.ts +1 -0
  4. package/core/elementPickerRequest.d.ts +8 -0
  5. package/models/NotificationPayload.types.d.ts +1 -0
  6. package/models/__tests__/NotificationPayload.buttons.test.d.ts +1 -0
  7. package/modules/Api/Api.d.ts +1 -1
  8. package/modules/ApiClient/ApiClient.types.d.ts +2 -0
  9. package/npm.js +1 -1
  10. package/npm.js.map +1 -1
  11. package/package.json +1 -1
  12. package/service-worker.js +1 -1
  13. package/service-worker.js.map +1 -1
  14. package/widget-inbox.js +1 -1
  15. package/widget-inbox.js.map +1 -1
  16. package/widget-recommendations.js +1 -1
  17. package/widget-recommendations.js.map +1 -1
  18. package/widget-subscribe-popup.js +1 -1
  19. package/widget-subscribe-popup.js.map +1 -1
  20. package/widget-subscription-button.js +1 -1
  21. package/widget-subscription-button.js.map +1 -1
  22. package/widget-subscription-prompt.js +1 -1
  23. package/widget-subscription-prompt.js.map +1 -1
  24. package/widget-subscription.js +1 -1
  25. package/widget-subscription.js.map +1 -1
  26. package/widget-web-popups.js +1 -1
  27. package/widget-web-popups.js.map +1 -1
  28. package/widgets/ElementPicker/ElementPicker.d.ts +48 -0
  29. package/widgets/ElementPicker/__tests__/elementPicker.test.d.ts +1 -0
  30. package/widgets/ElementPicker/__tests__/selector.test.d.ts +1 -0
  31. package/widgets/ElementPicker/selector.d.ts +16 -0
  32. package/widgets/WebPopups/WebPopupsWidget.d.ts +10 -2
  33. package/widgets/WebPopups/__tests__/clickTrigger.test.d.ts +1 -0
  34. package/widgets/WebPopups/__tests__/exitIntentTrigger.test.d.ts +1 -0
  35. package/widgets/WebPopups/clickTrigger.d.ts +5 -0
  36. package/widgets/WebPopups/exitIntent.d.ts +6 -0
  37. package/widgets/WebPopups/types.d.ts +3 -3
@@ -1,2 +1,2 @@
1
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(this,()=>(()=>{"use strict";const e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}};let t={};e.r(t),e.d(t,{RecommendationsWidget:()=>v});const r="keyValue",n="messages",o="inboxMessages";function a(e,t){return function(r){r.objectStoreNames.contains(e)||t(r)}}const i=[a(r,function(e){e.createObjectStore(r,{keyPath:"key"})}),a("log",function(e){const t=e.createObjectStore("log",{keyPath:"id",autoIncrement:!0});t.createIndex("environment","environment",{unique:!1}),t.createIndex("date","date",{unique:!1}),t.createIndex("type","type",{unique:!1})}),a(n,function(e){e.createObjectStore(n,{keyPath:"id",autoIncrement:!0}).createIndex("date","date",{unique:!1})}),a(o,function(e){const t="status",r=e.createObjectStore(o,{keyPath:"inbox_id",autoIncrement:!1});r.createIndex(t,t,{unique:!1,multiEntry:!0}),r.createIndex("rt","rt",{unique:!1,multiEntry:!0})})];class s{get all(){return i}}class c{constructor(e,t=new s){this.db=e,this.migrationsBuilder=t}applyMigrations(){this.applyMigrationsPack(this.migrationsBuilder.all)}applyMigrationsPack(e){e.forEach(e=>{e(this.db)})}}function l(e,t){console.info("onversionchange",t),e.close()}let d;function u(e){return(d||(d=new Promise((e,t)=>{const r=indexedDB.open("PUSHWOOSH_SDK_STORE",7);r.onsuccess=r=>{const n=r.target.result;n.onversionchange=l.bind(null,n,t),e(n)},r.onerror=()=>t(r.error),r.onupgradeneeded=e=>{const r=e.target.result;r.onversionchange=l.bind(null,r,t),new c(r).applyMigrations()}})),d).then(t=>new Promise((r,n)=>e(t,r,n)))}class p{_add(e){return u((t,r,n)=>{const o=t.transaction([this.name],"readwrite").objectStore(this.name).add(e);o.onsuccess=()=>{r(e)},o.onerror=()=>{n(o.error)}}).then(e=>this.getAll().then(t=>{if(Array.isArray(t)){const r=t.map(e=>e.id).sort((e,t)=>e==t?0:e<t?1:-1);if(r.length>this.maxItems)return Promise.all(r.slice(this.maxItems).map(e=>this.delete(e))).then(()=>e)}return e}))}delete(e){return u((t,r,n)=>{const o=t.transaction([this.name],"readwrite").objectStore(this.name).delete(e);o.onsuccess=()=>{r(o.result)},o.onerror=()=>{n(o.error)}})}getAll(){return u((e,t,r)=>{const n=[],o=e.transaction(this.name).objectStore(this.name).openCursor();o.onsuccess=e=>{const r=e.target.result;r?(r.value&&n.push(r.value),r.continue()):t(n)},o.onerror=()=>{r(o.error)}})}}h=r;var h;const m=new class extends p{constructor(){super(...arguments),this.name="log",this.maxItems=100,this.environment="undefined"!=typeof self&&self.registration?"worker":"browser"}add(e,t,r){const n={type:e,environment:this.environment,message:`${t}`,date:new Date};return t instanceof Error&&(n.stack=t.stack),r&&(n.additional=r),this._add(n)}},f=(new class extends p{constructor(){super(...arguments),this.name=n,this.maxItems=25}add(e){return this._add({...e,date:new Date})}},{error:1,info:2,debug:3});let g=3;const b={setLevel(e){f[e]||(e="error"),g=f[e]},write(e,t,r){return"error"===e?this.error(t):this.info(t),m.add(e,t,r)}};Object.keys(f).forEach(e=>{const t=f[e];b[e]=(...r)=>{t<=g&&(console.groupCollapsed(e),console.info("",...r),console.trace("trace"),console.groupEnd())}});const w="[data-pw-recommendations]",y=["data-pw-recommendations","data-pw-strategy","data-pw-fallback","data-pw-limit","data-pw-product-id","data-pw-exclude","data-pw-block","data-pw-title","data-pw-fallback-title"];function x(e){try{const t=new URL(e,location.href);return"http:"===t.protocol||"https:"===t.protocol?t.href:null}catch{return null}}class v{constructor(e,t=document){this.generations=new WeakMap,this.recommendations=e,this.root=t}run(){this.root.querySelectorAll(w).forEach(e=>{this.render(e)}),this.observer=new MutationObserver(e=>this.onMutations(e)),this.observer.observe(this.root.documentElement,{childList:!0,subtree:!0,attributes:!0,attributeFilter:y})}stop(){this.observer?.disconnect()}async render(e){const t=(this.generations.get(e)??0)+1;this.generations.set(e,t);const r=e.shadowRoot??e.attachShadow({mode:"open"});this.setState(e,"loading"),e.dataset.pwMinHeight&&(e.style.minHeight=/^\d+$/.test(e.dataset.pwMinHeight)?`${e.dataset.pwMinHeight}px`:e.dataset.pwMinHeight);const n=function(e){const{dataset:t}=e,r=Number(t.pwLimit);return{strategy:t.pwStrategy||"bestsellers_30d",fallback:t.pwFallback||void 0,limit:Number.isFinite(r)&&r>0?r:void 0,productId:t.pwProductId||void 0,exclude:t.pwExclude?t.pwExclude.split(",").map(e=>e.trim()).filter(Boolean):void 0,block:t.pwBlock||void 0}}(e);let o;try{o=await this.recommendations.fetch(n)}catch(n){if(this.generations.get(e)!==t)return;return b.error(n,"Pushwoosh: recommendations block failed to load"),r.replaceChildren(),void this.setState(e,"error")}if(this.generations.get(e)===t){if(!o.items?.length)return r.replaceChildren(),void this.setState(e,"empty");r.replaceChildren(...this.build(e,n,o)),this.setState(e,"ready")}}build(e,t,r){const n=this.root,o=n.createElement("style");o.textContent="\n:host { display: block; font-family: var(--pw-reco-font, inherit); }\n.title { margin: 0 0 12px; font-size: 1.25em; font-weight: 600; }\n.grid {\n display: grid;\n gap: 16px;\n grid-template-columns: repeat(var(--pw-reco-columns, auto-fill), minmax(140px, 1fr));\n}\n@media (max-width: 600px) {\n .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }\n}\n.card { display: flex; flex-direction: column; gap: 6px; color: inherit; text-decoration: none; }\n.image {\n width: 100%;\n aspect-ratio: 1;\n object-fit: cover;\n border-radius: var(--pw-reco-radius, 8px);\n background: rgba(0, 0, 0, 0.04);\n}\n.name { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }\n.price { color: var(--pw-reco-accent, currentColor); font-weight: 600; }\n.old { margin-left: 6px; font-weight: 400; text-decoration: line-through; opacity: 0.6; }\n";const a=[o],i=r.strategy!==t.strategy&&e.dataset.pwFallbackTitle?e.dataset.pwFallbackTitle:e.dataset.pwTitle;if(i){const e=n.createElement("div");e.className="title",e.setAttribute("part","title"),e.textContent=i,a.push(e)}const s=n.createElement("div");return s.className="grid",s.setAttribute("part","grid"),r.items.forEach((e,n)=>s.appendChild(this.card(e,n+1,t.block,r.strategy))),a.push(s),a}card(e,t,r,n){const o=this.root,a=o.createElement("a");a.className="card",a.setAttribute("part","card");const i=x(e.url);if(i&&(a.href=i),a.addEventListener("click",()=>{this.recommendations.trackClick({block:r,strategy:n,productId:e.id,position:t}).catch(e=>b.error(e,"Pushwoosh: failed to report a recommendation click"))}),e.image_url&&x(e.image_url)){const t=o.createElement("img");t.className="image",t.loading="lazy",t.alt=e.title,t.src=e.image_url,a.appendChild(t)}const s=o.createElement("span");if(s.className="name",s.textContent=e.title,a.appendChild(s),e.price_formatted){const t=o.createElement("span");if(t.className="price",t.textContent=e.price_formatted,e.old_price_formatted){const r=o.createElement("span");r.className="old",r.textContent=e.old_price_formatted,t.appendChild(r)}a.appendChild(t)}return a}setState(e,t){e.setAttribute("data-pw-state",t)}onMutations(e){const t=new Set;e.forEach(e=>{"attributes"!==e.type?e.addedNodes.forEach(e=>{e instanceof HTMLElement&&(e.matches(w)&&t.add(e),e.querySelectorAll(w).forEach(e=>t.add(e)))}):e.target.matches?.(w)&&t.add(e.target)}),t.forEach(e=>{this.render(e)})}}return t})());
1
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(this,()=>(()=>{"use strict";const e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{Object.defineProperties(e,{[Symbol.toStringTag]:{value:"Module"},__esModule:{value:!0}})}};let t={};e.r(t),e.d(t,{RecommendationsWidget:()=>v});const r="keyValue",n="messages",o="inboxMessages";function a(e,t){return function(r){r.objectStoreNames.contains(e)||t(r)}}const i=[a(r,function(e){e.createObjectStore(r,{keyPath:"key"})}),a("log",function(e){const t=e.createObjectStore("log",{keyPath:"id",autoIncrement:!0});t.createIndex("environment","environment",{unique:!1}),t.createIndex("date","date",{unique:!1}),t.createIndex("type","type",{unique:!1})}),a(n,function(e){e.createObjectStore(n,{keyPath:"id",autoIncrement:!0}).createIndex("date","date",{unique:!1})}),a(o,function(e){const t="status",r=e.createObjectStore(o,{keyPath:"inbox_id",autoIncrement:!1});r.createIndex(t,t,{unique:!1,multiEntry:!0}),r.createIndex("rt","rt",{unique:!1,multiEntry:!0})})];class s{get all(){return i}}class c{constructor(e,t=new s){this.db=e,this.migrationsBuilder=t}applyMigrations(){this.applyMigrationsPack(this.migrationsBuilder.all)}applyMigrationsPack(e){e.forEach(e=>{e(this.db)})}}function l(e,t){console.info("onversionchange",t),e.close()}let d;function u(e){return(d||(d=new Promise((e,t)=>{const r=indexedDB.open("PUSHWOOSH_SDK_STORE",7);r.onsuccess=r=>{const n=r.target.result;n.onversionchange=l.bind(null,n,t),e(n)},r.onerror=()=>t(r.error),r.onupgradeneeded=e=>{const r=e.target.result;r.onversionchange=l.bind(null,r,t),new c(r).applyMigrations()}})),d).then(t=>new Promise((r,n)=>e(t,r,n)))}class p{_add(e){return u((t,r,n)=>{const o=t.transaction([this.name],"readwrite").objectStore(this.name).add(e);o.onsuccess=()=>{r(e)},o.onerror=()=>{n(o.error)}}).then(e=>this.getAll().then(t=>{if(Array.isArray(t)){const r=t.map(e=>e.id).sort((e,t)=>e==t?0:e<t?1:-1);if(r.length>this.maxItems)return Promise.all(r.slice(this.maxItems).map(e=>this.delete(e))).then(()=>e)}return e}))}delete(e){return u((t,r,n)=>{const o=t.transaction([this.name],"readwrite").objectStore(this.name).delete(e);o.onsuccess=()=>{r(o.result)},o.onerror=()=>{n(o.error)}})}getAll(){return u((e,t,r)=>{const n=[],o=e.transaction(this.name).objectStore(this.name).openCursor();o.onsuccess=e=>{const r=e.target.result;r?(r.value&&n.push(r.value),r.continue()):t(n)},o.onerror=()=>{r(o.error)}})}}h=r;var h;const m=new class extends p{constructor(){super(...arguments),this.name="log",this.maxItems=100,this.environment="undefined"!=typeof self&&self.registration?"worker":"browser"}add(e,t,r){const n={type:e,environment:this.environment,message:`${t}`,date:new Date};return t instanceof Error&&(n.stack=t.stack),r&&(n.additional=r),this._add(n)}},f=(new class extends p{constructor(){super(...arguments),this.name=n,this.maxItems=25}add(e){return this._add({...e,date:new Date})}},{error:1,info:2,debug:3});let g=3;const b={setLevel(e){f[e]||(e="error"),g=f[e]},write(e,t,r){return"error"===e?this.error(t):this.info(t),m.add(e,t,r)}};Object.keys(f).forEach(e=>{const t=f[e];b[e]=(...r)=>{t<=g&&(console.groupCollapsed(e),console.info("",...r),console.trace("trace"),console.groupEnd())}});const w="[data-pw-recommendations]",y=["data-pw-recommendations","data-pw-strategy","data-pw-fallback","data-pw-limit","data-pw-product-id","data-pw-exclude","data-pw-block","data-pw-title","data-pw-fallback-title"];function x(e){try{const t=new URL(e,location.href);return"http:"===t.protocol||"https:"===t.protocol?t.href:null}catch{return null}}class v{constructor(e,t=document){this.generations=new WeakMap,this.recommendations=e,this.root=t}run(){this.root.querySelectorAll(w).forEach(e=>{this.render(e)}),this.observer=new MutationObserver(e=>this.onMutations(e)),this.observer.observe(this.root.documentElement,{childList:!0,subtree:!0,attributes:!0,attributeFilter:y})}stop(){this.observer?.disconnect()}async render(e){const t=(this.generations.get(e)??0)+1;this.generations.set(e,t);const r=e.shadowRoot??e.attachShadow({mode:"open"});this.setState(e,"loading"),e.dataset.pwMinHeight&&(e.style.minHeight=/^\d+$/.test(e.dataset.pwMinHeight)?`${e.dataset.pwMinHeight}px`:e.dataset.pwMinHeight);const n=function(e){const{dataset:t}=e,r=Number(t.pwLimit);return{strategy:t.pwStrategy||"bestsellers_30d",fallback:t.pwFallback||void 0,limit:Number.isFinite(r)&&r>0?r:void 0,productId:t.pwProductId||void 0,exclude:t.pwExclude?t.pwExclude.split(",").map(e=>e.trim()).filter(Boolean):void 0,block:t.pwBlock||void 0}}(e);let o;try{o=await this.recommendations.fetch(n)}catch(n){if(this.generations.get(e)!==t)return;return b.error(n,"Pushwoosh: recommendations block failed to load"),r.replaceChildren(),void this.setState(e,"error")}if(this.generations.get(e)===t){if(!o.items?.length)return r.replaceChildren(),void this.setState(e,"empty");r.replaceChildren(...this.build(e,n,o)),this.setState(e,"ready")}}build(e,t,r){const n=this.root,o=n.createElement("style");o.textContent="\n:host { display: block; font-family: var(--pw-reco-font, inherit); }\n.title { margin: 0 0 12px; font-size: 1.25em; font-weight: 600; }\n.grid {\n display: grid;\n gap: 16px;\n grid-template-columns: repeat(var(--pw-reco-columns, auto-fill), minmax(140px, 1fr));\n}\n@media (max-width: 600px) {\n .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }\n}\n.card { display: flex; flex-direction: column; gap: 6px; color: inherit; text-decoration: none; }\n.image {\n width: 100%;\n aspect-ratio: 1;\n object-fit: cover;\n border-radius: var(--pw-reco-radius, 8px);\n background: rgba(0, 0, 0, 0.04);\n}\n.name { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }\n.price { color: var(--pw-reco-accent, currentColor); font-weight: 600; }\n.old { margin-left: 6px; font-weight: 400; text-decoration: line-through; opacity: 0.6; }\n";const a=[o],i=r.strategy!==t.strategy&&e.dataset.pwFallbackTitle?e.dataset.pwFallbackTitle:e.dataset.pwTitle;if(i){const e=n.createElement("div");e.className="title",e.setAttribute("part","title"),e.textContent=i,a.push(e)}const s=n.createElement("div");return s.className="grid",s.setAttribute("part","grid"),r.items.forEach((e,n)=>s.appendChild(this.card(e,n+1,t.block,r.strategy))),a.push(s),a}card(e,t,r,n){const o=this.root,a=o.createElement("a");a.className="card",a.setAttribute("part","card");const i=x(e.url);if(i&&(a.href=i),a.addEventListener("click",()=>{this.recommendations.trackClick({block:r,strategy:n,productId:e.id,position:t}).catch(e=>b.error(e,"Pushwoosh: failed to report a recommendation click"))}),e.image_url&&x(e.image_url)){const t=o.createElement("img");t.className="image",t.loading="lazy",t.alt=e.title,t.src=e.image_url,a.appendChild(t)}const s=o.createElement("span");if(s.className="name",s.textContent=e.title,a.appendChild(s),e.price_formatted){const t=o.createElement("span");if(t.className="price",t.textContent=e.price_formatted,e.old_price_formatted){const r=o.createElement("span");r.className="old",r.textContent=e.old_price_formatted,t.appendChild(r)}a.appendChild(t)}return a}setState(e,t){e.setAttribute("data-pw-state",t)}onMutations(e){const t=new Set;e.forEach(e=>{"attributes"!==e.type?e.addedNodes.forEach(e=>{e instanceof HTMLElement&&(e.matches(w)&&t.add(e),e.querySelectorAll(w).forEach(e=>t.add(e)))}):e.target.matches?.(w)&&t.add(e.target)}),t.forEach(e=>{this.render(e)})}}return t})());
2
2
  //# sourceMappingURL=widget-recommendations.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"widget-recommendations.js","mappings":"CAAA,SAAAA,EAAAC,GACA,oBAAAC,SAAA,iBAAAC,OACAA,OAAAD,QAAAD,SACA,sBAAAG,QAAAA,OAAAC,IACAD,OAAA,GAAAH,OACA,CACA,IAAAK,EAAAL,IACA,QAAAM,KAAAD,GAAA,iBAAAJ,QAAAA,QAAAF,GAAAO,GAAAD,EAAAC,EACA,CACC,CATD,CASCC,KAAA,uBCRD,MAAAC,EAAA,CCAAA,EAAA,CAAAP,EAAAQ,KACA,QAAAC,KAAAD,EACAD,EAAAG,EAAAF,EAAAC,KAAAF,EAAAG,EAAAV,EAAAS,IACAE,OAAAC,eAAAZ,EAAAS,EAAA,CAAyCI,YAAA,EAAAC,IAAAN,EAAAC,MCJzCF,EAAA,CAAAQ,EAAAC,IAAAL,OAAAM,UAAAC,eAAAC,KAAAJ,EA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EG,MAAOxI,GAAUyC,EAAOzC,MAAMA,EAAO,yDAGtCiI,EAAKQ,WAAanF,EAAS2E,EAAKQ,WAAY,CAC9C,MAAMC,EAAQpB,EAAIC,cAAc,OAChCmB,EAAMZ,UAAY,QAClBY,EAAMC,QAAU,OAChBD,EAAME,IAAMX,EAAKP,MACjBgB,EAAMG,IAAMZ,EAAKQ,UACjBL,EAAKD,YAAYO,EACnB,CAEA,MAAMvL,EAAOmK,EAAIC,cAAc,QAK/B,GAJApK,EAAK2K,UAAY,OACjB3K,EAAKqK,YAAcS,EAAKP,MACxBU,EAAKD,YAAYhL,GAEb8K,EAAKa,gBAAiB,CACxB,MAAMC,EAAQzB,EAAIC,cAAc,QAGhC,GAFAwB,EAAMjB,UAAY,QAClBiB,EAAMvB,YAAcS,EAAKa,gBACrBb,EAAKe,oBAAqB,CAC5B,MAAMC,EAAM3B,EAAIC,cAAc,QAC9B0B,EAAInB,UAAY,MAChBmB,EAAIzB,YAAcS,EAAKe,oBACvBD,EAAMZ,YAAYc,EACpB,CACAb,EAAKD,YAAYY,EACnB,CAEA,OAAOX,CACT,CAEQ,QAAA5C,CAASpB,EAAiB8E,GAChC9E,EAAG2D,aAAa,gBAAiBmB,EACnC,CAEQ,WAAAzE,CAAYD,GAClB,MAAM2E,EAAQ,IAAIC,IAClB5E,EAAU7F,QAAS0K,IACK,eAAlBA,EAAStH,KAKbsH,EAASC,WAAW3K,QAAS4K,IACrBA,aAAgBC,cAClBD,EAAKE,QAAQrG,IAAqB+F,EAAM5I,IAAIgJ,GAChDA,EAAKpF,iBAA8Bf,GAAoBzE,QAASyF,GAAO+E,EAAM5I,IAAI6D,OAP5EiF,EAASzJ,OAAuB6J,UAAUrG,IAAqB+F,EAAM5I,IAAI8I,EAASzJ,UAU3FuJ,EAAMxK,QAASyF,IAAYtI,KAAKuI,OAAOD,IACzC","sources":["webpack://web-push-notifications/webpack/universalModuleDefinition","webpack://web-push-notifications/webpack/bootstrap","webpack://web-push-notifications/webpack/runtime/define property getters","webpack://web-push-notifications/webpack/runtime/hasOwnProperty shorthand","webpack://web-push-notifications/webpack/runtime/make namespace object","webpack://web-push-notifications/./src/widgets/Recommendations/styles.ts","webpack://web-push-notifications/./src/modules/storage/migrations/constants.ts","webpack://web-push-notifications/./src/modules/storage/migrations/helpers.ts","webpack://web-push-notifications/./src/modules/storage/migrations/initial.ts","webpack://web-push-notifications/./src/modules/storage/migrations/Migrations.ts","webpack://web-push-notifications/./src/modules/storage/migrations/MigrationExecutor.ts","webpack://web-push-notifications/./src/core/storage.ts","webpack://web-push-notifications/./src/core/logger.ts","webpack://web-push-notifications/./src/widgets/Recommendations/RecommendationsWidget.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse {\n\t\tvar a = factory();\n\t\tfor(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];\n\t}\n})(this, () => {\nreturn ","// The require scope\nconst __webpack_require__ = {};\n\n","// define getter/value functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop));","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","// Custom properties cross the shadow boundary, so the site themes the block from its own CSS.\nexport const RECOMMENDATIONS_STYLES = `\n:host { display: block; font-family: var(--pw-reco-font, inherit); }\n.title { margin: 0 0 12px; font-size: 1.25em; font-weight: 600; }\n.grid {\n display: grid;\n gap: 16px;\n grid-template-columns: repeat(var(--pw-reco-columns, auto-fill), minmax(140px, 1fr));\n}\n@media (max-width: 600px) {\n .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }\n}\n.card { display: flex; flex-direction: column; gap: 6px; color: inherit; text-decoration: none; }\n.image {\n width: 100%;\n aspect-ratio: 1;\n object-fit: cover;\n border-radius: var(--pw-reco-radius, 8px);\n background: rgba(0, 0, 0, 0.04);\n}\n.name { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }\n.price { color: var(--pw-reco-accent, currentColor); font-weight: 600; }\n.old { margin-left: 6px; font-weight: 400; text-decoration: line-through; opacity: 0.6; }\n`;\n","import { type TInboxMessagesStoreName, type TKeyValueStoreName, type TMainLogStoreName, type TMessageLogStoreName } from '../Storage.types';\n\nexport const STORE_NAME_KEY_VALUE: TKeyValueStoreName = 'keyValue';\nexport const STORE_NAME_MESSAGE_LOG: TMessageLogStoreName = 'messages';\nexport const STORE_NAME_MAIN_LOG: TMainLogStoreName = 'log';\nexport const STORE_NAME_INBOX_MESSAGES: TInboxMessagesStoreName = 'inboxMessages';\n\nexport const KEY_PATH_BASE_INCREMENT = 'id';\n","import { type TMigrationType, type TSdkStoreName } from '../Storage.types';\n\n/**\n * Check existed store, before create\n * @param name\n * @param storeCreator\n */\nexport function storeCreatorDecorator(name: TSdkStoreName, storeCreator: TMigrationType): TMigrationType {\n return function (database: IDBDatabase) {\n if (database.objectStoreNames.contains(name)) {\n return;\n }\n\n storeCreator(database);\n };\n}\n","import {\n STORE_NAME_INBOX_MESSAGES,\n STORE_NAME_KEY_VALUE,\n STORE_NAME_MAIN_LOG,\n STORE_NAME_MESSAGE_LOG,\n KEY_PATH_BASE_INCREMENT,\n} from './constants';\nimport { storeCreatorDecorator } from './helpers';\nimport {\n type TInboxMessagesIDBKeyPath,\n type TInboxMessagesIDBRemovalTimeIndex,\n type TInboxMessagesIDBStatusIndex,\n} from '../../../models/InboxMessages.types';\n\n/**\n * Create keyValue store migration\n * @param database\n */\nfunction createKeyValueStore(database: IDBDatabase) {\n database.createObjectStore(STORE_NAME_KEY_VALUE, { keyPath: 'key' });\n}\n\n/**\n * Create log store migration\n * @param database\n */\nfunction createLogStore(database: IDBDatabase) {\n const logStore = database.createObjectStore(\n STORE_NAME_MAIN_LOG,\n { keyPath: KEY_PATH_BASE_INCREMENT, autoIncrement: true },\n );\n logStore.createIndex('environment', 'environment', { unique: false });\n logStore.createIndex('date', 'date', { unique: false });\n logStore.createIndex('type', 'type', { unique: false });\n}\n\n/**\n * Create message log store migration\n * @param database\n */\nfunction createMessageLogStore(database: IDBDatabase) {\n const messagesStore = database.createObjectStore(\n STORE_NAME_MESSAGE_LOG,\n { keyPath: KEY_PATH_BASE_INCREMENT, autoIncrement: true },\n );\n messagesStore.createIndex('date', 'date', { unique: false });\n}\n\n/**\n * Create inbox messages store migration\n * @param database\n */\nfunction createInboxMessagesStore(database: IDBDatabase) {\n const keyPath: TInboxMessagesIDBKeyPath = 'inbox_id';\n const statusIndex: TInboxMessagesIDBStatusIndex = 'status';\n const removalTimeIndex: TInboxMessagesIDBRemovalTimeIndex = 'rt';\n\n const store = database.createObjectStore(STORE_NAME_INBOX_MESSAGES,\n { keyPath, autoIncrement: false },\n );\n store.createIndex(statusIndex, statusIndex, { unique: false, multiEntry: true });\n store.createIndex(removalTimeIndex, removalTimeIndex, { unique: false, multiEntry: true });\n}\n\nexport default [\n storeCreatorDecorator(STORE_NAME_KEY_VALUE, createKeyValueStore),\n storeCreatorDecorator(STORE_NAME_MAIN_LOG, createLogStore),\n storeCreatorDecorator(STORE_NAME_MESSAGE_LOG, createMessageLogStore),\n storeCreatorDecorator(STORE_NAME_INBOX_MESSAGES, createInboxMessagesStore),\n];\n","import { default as migrationsInitial } from './initial';\nimport { type TMigrationType } from '../Storage.types';\n\nexport default class Migrations {\n get all(): Array<TMigrationType> {\n return migrationsInitial;\n }\n}\n","import Migrations from './Migrations';\nimport { type TMigrationType } from '../Storage.types';\n\nexport default class MigrationExecutor {\n db: IDBDatabase;\n migrationsBuilder: Migrations;\n\n constructor(\n db: IDBDatabase,\n migrationsBuilder: Migrations = new Migrations(),\n ) {\n this.db = db;\n this.migrationsBuilder = migrationsBuilder;\n }\n\n applyMigrations() {\n this.applyMigrationsPack(this.migrationsBuilder.all);\n }\n\n applyMigrationsPack(migrationsPack: Array<TMigrationType>) {\n migrationsPack.forEach((migration) => {\n migration(this.db);\n });\n }\n}\n","import {\n STORE_NAME_KEY_VALUE,\n STORE_NAME_MAIN_LOG,\n STORE_NAME_MESSAGE_LOG,\n} from '../modules/storage/migrations/constants';\nimport MigrationExecutor from '../modules/storage/migrations/MigrationExecutor';\nimport { type IIDBOpenEventTargetWithResult } from '../modules/storage/Storage.types';\nimport version from '../modules/storage/version';\n\ndeclare const self: ServiceWorkerGlobalScope;\n\nfunction onversionchange(database: IDBDatabase, event: Event) {\n console.info('onversionchange', event);\n database.close();\n}\n\nlet databasePromise: Promise<IDBDatabase>;\nexport function getInstance(): Promise<IDBDatabase> {\n if (!databasePromise) {\n databasePromise = new Promise<IDBDatabase>((resolve, reject) => {\n const request: IDBOpenDBRequest = indexedDB.open('PUSHWOOSH_SDK_STORE', version);\n request.onsuccess = (event) => {\n const database: IDBDatabase = (event.target as IIDBOpenEventTargetWithResult).result;\n database.onversionchange = onversionchange.bind(null, database, reject);\n resolve(database);\n };\n\n request.onerror = () => reject(request.error);\n\n request.onupgradeneeded = (event) => {\n const database: IDBDatabase = (event.target as IIDBOpenEventTargetWithResult).result;\n database.onversionchange = onversionchange.bind(null, database, reject);\n\n const migrationExecutor = new MigrationExecutor(database);\n migrationExecutor.applyMigrations();\n };\n });\n }\n return databasePromise;\n}\n\nfunction getInstanceWithPromise(executor: any): any {\n return getInstance().then((database) => (\n new Promise((resolve, reject) => executor(database, resolve, reject))\n ));\n}\n\nfunction createKeyValue(name: string) {\n return {\n get<K extends string, D>(key: K, defaultValue?: D) {\n return getInstanceWithPromise((database: IDBDatabase, resolve: any, reject: any) => {\n const request = database.transaction(name).objectStore(name).get(key);\n\n /** @TODO\n * we cant invoke \"resolve\" or \"reject\" in onsuccess or onerror because\n * it leads to bugs in Safari when we try to get permissions for notifications\n *\n * Checking status of request in setTimeout fixes this bug\n */\n let isComplete = false;\n let isError = false;\n let timeout: any;\n\n const check = () => {\n clearTimeout(timeout);\n if (isComplete) {\n resolve(request.result?.value || defaultValue);\n } else if (isError) {\n reject(request.error);\n } else {\n timeout = setTimeout(check, 0);\n }\n };\n\n request.onsuccess = () => isComplete = true;\n request.onerror = () => isError = true;\n check();\n });\n },\n\n getAll() {\n return getInstanceWithPromise((database: IDBDatabase, resolve: any, reject: any) => {\n const result: { [key: string]: any } = {};\n const cursor = database.transaction(name).objectStore(name).openCursor();\n let isComplete = false;\n let isError = false;\n let timeout: any;\n\n /** @TODO\n * we cant invoke \"resolve\" or \"reject\" in onsuccess or onerror because\n * it leads to bugs in Safari when we try to get permissions for notifications\n *\n * Checking status of request in setTimeout fixes this bug\n */\n const check = () => {\n clearTimeout(timeout);\n if (isComplete) {\n resolve(result);\n } else if (isError) {\n reject(cursor.error);\n } else {\n timeout = setTimeout(check, 0);\n }\n };\n\n cursor.onsuccess = (event) => {\n const cursorResult = (event.target as any).result;\n if (cursorResult) {\n result[cursorResult.key] = cursorResult.value.value;\n cursorResult.continue();\n } else {\n isComplete = true;\n }\n };\n cursor.onerror = () => isError = true;\n check();\n });\n },\n\n async extend(key: string, value: any) {\n const oldValues = await this.get(key);\n const { ...newValues } = value;\n await this.set(key, { ...oldValues, ...newValues });\n },\n\n set<K, D>(key: K, value: D) {\n return getInstanceWithPromise((database: IDBDatabase, resolve: any, reject: any) => {\n const request = database.transaction([name], 'readwrite').objectStore(name).put({ key, value });\n let isComplete = false;\n let isError = false;\n let timeout: any;\n\n /** @TODO\n * we cant invoke \"resolve\" or \"reject\" in onsuccess or onerror because\n * it leads to bugs in Safari when we try to get permissions for notifications\n *\n * Checking status of request in setTimeout fixes this bug\n */\n const check = () => {\n clearTimeout(timeout);\n if (isComplete) {\n resolve(key);\n } else if (isError) {\n reject(request.error);\n } else {\n timeout = setTimeout(check, 0);\n }\n };\n\n request.onsuccess = () => isComplete = true;\n request.onerror = () => isError = true;\n check();\n });\n },\n };\n}\n\nexport abstract class LogBase {\n protected abstract name: string;\n protected abstract maxItems: number;\n _add(obj: any) {\n return getInstanceWithPromise((database: IDBDatabase, resolve: any, reject: any) => {\n const request = database.transaction([this.name], 'readwrite').objectStore(this.name).add(obj);\n request.onsuccess = () => {\n resolve(obj);\n };\n request.onerror = () => {\n reject(request.error);\n };\n }).then((obj: any) => {\n return this.getAll().then((items: { id: number }[]) => {\n if (Array.isArray(items)) {\n const ids = items.map((i) => i.id).sort((a, b) => {\n if (a == b) return 0;\n return a < b ? 1 : -1;\n });\n if (ids.length > this.maxItems) {\n return Promise.all(ids.slice(this.maxItems).map((id) => this.delete(id))).then(() => obj);\n }\n }\n return obj;\n });\n });\n }\n\n delete(key: any) {\n return getInstanceWithPromise((database: IDBDatabase, resolve: any, reject: any) => {\n const request = database.transaction([this.name], 'readwrite').objectStore(this.name).delete(key);\n request.onsuccess = () => {\n resolve(request.result);\n };\n request.onerror = () => {\n reject(request.error);\n };\n });\n }\n\n getAll() {\n return getInstanceWithPromise((database: IDBDatabase, resolve: any, reject: any) => {\n const result: any[] = [];\n const cursor = database.transaction(this.name).objectStore(this.name).openCursor();\n cursor.onsuccess = (ev) => {\n const cursorResult = (ev.target as any).result;\n if (cursorResult) {\n if (cursorResult.value) {\n result.push(cursorResult.value);\n }\n cursorResult.continue();\n } else {\n resolve(result);\n }\n };\n cursor.onerror = () => {\n reject(cursor.error);\n };\n });\n }\n}\n\nexport class LogLog extends LogBase {\n protected name = STORE_NAME_MAIN_LOG;\n protected maxItems = 100;\n protected environment = (typeof self !== 'undefined' && self.registration) ? 'worker' : 'browser';\n add(type: string, message: any, additional?: any) {\n const obj: any = {\n type,\n environment: this.environment,\n message: `${message}`,\n date: new Date(),\n };\n if (message instanceof Error) {\n obj.stack = message.stack;\n }\n if (additional) {\n obj.additional = additional;\n }\n return this._add(obj);\n }\n}\n\nexport class LogMessage extends LogBase {\n protected name = STORE_NAME_MESSAGE_LOG;\n protected maxItems = 25;\n add(log: any) {\n return this._add({\n ...log,\n date: new Date(),\n });\n }\n}\n\nexport const keyValue = createKeyValue(STORE_NAME_KEY_VALUE);\nexport const log = new LogLog();\nexport const message = new LogMessage();\n","import { log as logStorage } from './storage';\n\nconst levels: { [key: string]: number } = {\n error: 1,\n info: 2,\n debug: 3,\n};\n\nlet limitLevel = 3;\n\ntype TWriteType = 'error' | 'apirequest' | 'info';\n\ninterface ILogger {\n setLevel(level: string): void;\n error(...args: any[]): void;\n info(...args: any[]): void;\n debug(...args: any[]): void;\n write(type: TWriteType, message: any, additional?: any): Promise<void>;\n isManualLevel(): boolean;\n [key: string]: any;\n}\n\nconst Logger: ILogger = {\n setLevel(level) {\n if (!levels[level]) {\n level = 'error';\n }\n limitLevel = levels[level];\n },\n write(type: TWriteType, message: any, additional?: any) {\n if (type === 'error') {\n this.error(message);\n } else {\n this.info(message);\n }\n return logStorage.add(type, message, additional);\n },\n} as ILogger;\n\nObject.keys(levels).forEach((levelName: string) => {\n const levelNumber = levels[levelName];\n Logger[levelName] = (...args: any[]) => {\n if (levelNumber <= limitLevel) {\n console.groupCollapsed(levelName);\n console.info('', ...args);\n console.trace('trace');\n console.groupEnd();\n }\n };\n});\n\nexport function logAndThrowError(error: string) {\n const logText = new Error(error);\n Logger.write('error', logText, 'logAndThrowError');\n throw logText;\n}\n\nexport function logAndRejectError(error: string, reject: (e: any) => void) {\n const logText = new Error(error);\n Logger.write('error', logText, 'logAndRejectError');\n reject(logText);\n}\n\nexport { Logger };\n","import { RECOMMENDATIONS_STYLES } from './styles';\nimport { Logger } from '../../core/logger';\nimport { type Recommendations } from '../../modules/Recommendations/Recommendations';\nimport {\n type IRecommendationsRequest, type IRecommendationsResponse, type IRecommendedProduct, type TRecommendationStrategy,\n} from '../../modules/Recommendations/Recommendations.types';\n\nexport const CONTAINER_SELECTOR = '[data-pw-recommendations]';\n\n// a change to any of these re-renders the block\nconst WATCHED_ATTRIBUTES = [\n 'data-pw-recommendations', 'data-pw-strategy', 'data-pw-fallback', 'data-pw-limit', 'data-pw-product-id',\n 'data-pw-exclude', 'data-pw-block', 'data-pw-title', 'data-pw-fallback-title',\n];\n\nexport type TRecommendationsState = 'loading' | 'ready' | 'empty' | 'error';\n\n/** The block's request, read from its data attributes. */\nexport function readRequest(el: HTMLElement): IRecommendationsRequest {\n const { dataset } = el;\n const limit = Number(dataset.pwLimit);\n\n return {\n strategy: (dataset.pwStrategy || 'bestsellers_30d') as TRecommendationStrategy,\n fallback: dataset.pwFallback as IRecommendationsRequest['fallback'] || undefined,\n limit: Number.isFinite(limit) && limit > 0 ? limit : undefined,\n productId: dataset.pwProductId || undefined,\n exclude: dataset.pwExclude ? dataset.pwExclude.split(',').map((id) => id.trim()).filter(Boolean) : undefined,\n block: dataset.pwBlock || undefined,\n };\n}\n\n// the feed is the merchant's catalog: a javascript: link from it must not reach the page\nfunction safeHref(url: string): string | null {\n try {\n const parsed = new URL(url, location.href);\n\n return parsed.protocol === 'http:' || parsed.protocol === 'https:' ? parsed.href : null;\n } catch {\n return null;\n }\n}\n\nexport class RecommendationsWidget {\n private readonly recommendations: Recommendations;\n private readonly root: Document;\n // a re-render supersedes the request in flight: its late answer must not overwrite the new one\n private readonly generations = new WeakMap<HTMLElement, number>();\n private observer?: MutationObserver;\n\n constructor(recommendations: Recommendations, root: Document = document) {\n this.recommendations = recommendations;\n this.root = root;\n }\n\n public run(): void {\n this.root.querySelectorAll<HTMLElement>(CONTAINER_SELECTOR).forEach((el) => void this.render(el));\n\n // SPA pages add blocks and swap the product on screen without a reload\n this.observer = new MutationObserver((mutations) => this.onMutations(mutations));\n this.observer.observe(this.root.documentElement, {\n childList: true, subtree: true, attributes: true, attributeFilter: WATCHED_ATTRIBUTES,\n });\n }\n\n public stop(): void {\n this.observer?.disconnect();\n }\n\n public async render(el: HTMLElement): Promise<void> {\n const generation = (this.generations.get(el) ?? 0) + 1;\n this.generations.set(el, generation);\n\n const shadow = el.shadowRoot ?? el.attachShadow({ mode: 'open' });\n this.setState(el, 'loading');\n if (el.dataset.pwMinHeight) {\n el.style.minHeight = /^\\d+$/.test(el.dataset.pwMinHeight) ? `${el.dataset.pwMinHeight}px` : el.dataset.pwMinHeight;\n }\n\n const request = readRequest(el);\n let response: IRecommendationsResponse;\n try {\n response = await this.recommendations.fetch(request);\n } catch (error) {\n if (this.generations.get(el) !== generation) return;\n Logger.error(error, 'Pushwoosh: recommendations block failed to load');\n shadow.replaceChildren();\n this.setState(el, 'error');\n\n return;\n }\n if (this.generations.get(el) !== generation) return;\n\n if (!response.items?.length) {\n // the site hides its own frame around an empty block by this state\n shadow.replaceChildren();\n this.setState(el, 'empty');\n\n return;\n }\n\n shadow.replaceChildren(...this.build(el, request, response));\n this.setState(el, 'ready');\n }\n\n private build(el: HTMLElement, request: IRecommendationsRequest, response: IRecommendationsResponse): Node[] {\n const doc = this.root;\n const style = doc.createElement('style');\n style.textContent = RECOMMENDATIONS_STYLES;\n const nodes: Node[] = [style];\n\n const fellBack = response.strategy !== request.strategy;\n const title = fellBack && el.dataset.pwFallbackTitle ? el.dataset.pwFallbackTitle : el.dataset.pwTitle;\n if (title) {\n const heading = doc.createElement('div');\n heading.className = 'title';\n heading.setAttribute('part', 'title');\n heading.textContent = title;\n nodes.push(heading);\n }\n\n const grid = doc.createElement('div');\n grid.className = 'grid';\n grid.setAttribute('part', 'grid');\n response.items.forEach((item, index) => grid.appendChild(this.card(item, index + 1, request.block, response.strategy)));\n nodes.push(grid);\n\n return nodes;\n }\n\n private card(item: IRecommendedProduct, position: number, block: string | undefined, strategy: string): HTMLElement {\n const doc = this.root;\n const card = doc.createElement('a');\n card.className = 'card';\n card.setAttribute('part', 'card');\n const href = safeHref(item.url);\n if (href) card.href = href;\n card.addEventListener('click', () => {\n void this.recommendations.trackClick({ block, strategy, productId: item.id, position })\n .catch((error) => Logger.error(error, 'Pushwoosh: failed to report a recommendation click'));\n });\n\n if (item.image_url && safeHref(item.image_url)) {\n const image = doc.createElement('img');\n image.className = 'image';\n image.loading = 'lazy';\n image.alt = item.title;\n image.src = item.image_url;\n card.appendChild(image);\n }\n\n const name = doc.createElement('span');\n name.className = 'name';\n name.textContent = item.title;\n card.appendChild(name);\n\n if (item.price_formatted) {\n const price = doc.createElement('span');\n price.className = 'price';\n price.textContent = item.price_formatted;\n if (item.old_price_formatted) {\n const old = doc.createElement('span');\n old.className = 'old';\n old.textContent = item.old_price_formatted;\n price.appendChild(old);\n }\n card.appendChild(price);\n }\n\n return card;\n }\n\n private setState(el: HTMLElement, state: TRecommendationsState): void {\n el.setAttribute('data-pw-state', state);\n }\n\n private onMutations(mutations: MutationRecord[]): void {\n const dirty = new Set<HTMLElement>();\n mutations.forEach((mutation) => {\n if (mutation.type === 'attributes') {\n if ((mutation.target as HTMLElement).matches?.(CONTAINER_SELECTOR)) dirty.add(mutation.target as HTMLElement);\n\n return;\n }\n mutation.addedNodes.forEach((node) => {\n if (!(node instanceof HTMLElement)) return;\n if (node.matches(CONTAINER_SELECTOR)) dirty.add(node);\n node.querySelectorAll<HTMLElement>(CONTAINER_SELECTOR).forEach((el) => dirty.add(el));\n });\n });\n dirty.forEach((el) => void this.render(el));\n }\n}\n"],"names":["root","factory","exports","module","define","amd","a","i","this","__webpack_require__","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","STORE_NAME_KEY_VALUE","STORE_NAME_MESSAGE_LOG","STORE_NAME_INBOX_MESSAGES","storeCreatorDecorator","name","storeCreator","database","objectStoreNames","contains","initial","createObjectStore","keyPath","logStore","autoIncrement","createIndex","unique","statusIndex","store","multiEntry","Migrations","all","MigrationExecutor","constructor","db","migrationsBuilder","applyMigrations","applyMigrationsPack","migrationsPack","forEach","migration","onversionchange","event","console","info","close","databasePromise","getInstanceWithPromise","executor","Promise","resolve","reject","request","indexedDB","open","onsuccess","target","result","bind","onerror","error","onupgradeneeded","then","LogBase","_add","transaction","objectStore","add","getAll","items","Array","isArray","ids","map","id","sort","b","length","maxItems","slice","delete","cursor","openCursor","ev","cursorResult","push","continue","log","environment","self","registration","type","message","additional","date","Date","Error","stack","levels","debug","limitLevel","Logger","setLevel","level","write","keys","levelName","levelNumber","args","groupCollapsed","trace","groupEnd","CONTAINER_SELECTOR","WATCHED_ATTRIBUTES","safeHref","url","parsed","URL","location","href","protocol","RecommendationsWidget","recommendations","document","generations","WeakMap","run","querySelectorAll","el","render","observer","MutationObserver","mutations","onMutations","observe","documentElement","childList","subtree","attributes","attributeFilter","stop","disconnect","generation","set","shadow","shadowRoot","attachShadow","mode","setState","dataset","pwMinHeight","style","minHeight","test","limit","Number","pwLimit","strategy","pwStrategy","fallback","pwFallback","undefined","isFinite","productId","pwProductId","exclude","pwExclude","split","trim","filter","Boolean","block","pwBlock","readRequest","response","fetch","replaceChildren","build","doc","createElement","textContent","nodes","title","pwFallbackTitle","pwTitle","heading","className","setAttribute","grid","item","index","appendChild","card","position","addEventListener","trackClick","catch","image_url","image","loading","alt","src","price_formatted","price","old_price_formatted","old","state","dirty","Set","mutation","addedNodes","node","HTMLElement","matches"],"sourceRoot":""}
1
+ {"version":3,"file":"widget-recommendations.js","mappings":"CAAA,SAAAA,EAAAC,GACA,oBAAAC,SAAA,iBAAAC,OACAA,OAAAD,QAAAD,SACA,sBAAAG,QAAAA,OAAAC,IACAD,OAAA,GAAAH,OACA,CACA,IAAAK,EAAAL,IACA,QAAAM,KAAAD,GAAA,iBAAAJ,QAAAA,QAAAF,GAAAO,GAAAD,EAAAC,EACA,CACC,CATD,CASCC,KAAA,uBCRD,MAAAC,EAAA,CCAAA,EAAA,CAAAP,EAAAQ,KACA,QAAAC,KAAAD,EACAD,EAAAG,EAAAF,EAAAC,KAAAF,EAAAG,EAAAV,EAAAS,IACAE,OAAAC,eAAAZ,EAAAS,EAAA,CAAyCI,YAAA,EAAAC,IAAAN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web-push-notifications/webpack/universalModuleDefinition","webpack://web-push-notifications/webpack/bootstrap","webpack://web-push-notifications/webpack/runtime/define property getters","webpack://web-push-notifications/webpack/runtime/hasOwnProperty shorthand","webpack://web-push-notifications/webpack/runtime/make namespace object","webpack://web-push-notifications/./src/widgets/Recommendations/styles.ts","webpack://web-push-notifications/./src/modules/storage/migrations/constants.ts","webpack://web-push-notifications/./src/modules/storage/migrations/helpers.ts","webpack://web-push-notifications/./src/modules/storage/migrations/initial.ts","webpack://web-push-notifications/./src/modules/storage/migrations/Migrations.ts","webpack://web-push-notifications/./src/modules/storage/migrations/MigrationExecutor.ts","webpack://web-push-notifications/./src/core/storage.ts","webpack://web-push-notifications/./src/core/logger.ts","webpack://web-push-notifications/./src/widgets/Recommendations/RecommendationsWidget.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse {\n\t\tvar a = factory();\n\t\tfor(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];\n\t}\n})(this, () => {\nreturn ","// The require scope\nconst __webpack_require__ = {};\n\n","// define getter/value functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop));","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tObject.defineProperties(exports, { [Symbol.toStringTag]: { value: 'Module' }, __esModule: { value: true } });\n};","// Custom properties cross the shadow boundary, so the site themes the block from its own CSS.\nexport const RECOMMENDATIONS_STYLES = `\n:host { display: block; font-family: var(--pw-reco-font, inherit); }\n.title { margin: 0 0 12px; font-size: 1.25em; font-weight: 600; }\n.grid {\n display: grid;\n gap: 16px;\n grid-template-columns: repeat(var(--pw-reco-columns, auto-fill), minmax(140px, 1fr));\n}\n@media (max-width: 600px) {\n .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }\n}\n.card { display: flex; flex-direction: column; gap: 6px; color: inherit; text-decoration: none; }\n.image {\n width: 100%;\n aspect-ratio: 1;\n object-fit: cover;\n border-radius: var(--pw-reco-radius, 8px);\n background: rgba(0, 0, 0, 0.04);\n}\n.name { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }\n.price { color: var(--pw-reco-accent, currentColor); font-weight: 600; }\n.old { margin-left: 6px; font-weight: 400; text-decoration: line-through; opacity: 0.6; }\n`;\n","import { type TInboxMessagesStoreName, type TKeyValueStoreName, type TMainLogStoreName, type TMessageLogStoreName } from '../Storage.types';\n\nexport const STORE_NAME_KEY_VALUE: TKeyValueStoreName = 'keyValue';\nexport const STORE_NAME_MESSAGE_LOG: TMessageLogStoreName = 'messages';\nexport const STORE_NAME_MAIN_LOG: TMainLogStoreName = 'log';\nexport const STORE_NAME_INBOX_MESSAGES: TInboxMessagesStoreName = 'inboxMessages';\n\nexport const KEY_PATH_BASE_INCREMENT = 'id';\n","import { type TMigrationType, type TSdkStoreName } from '../Storage.types';\n\n/**\n * Check existed store, before create\n * @param name\n * @param storeCreator\n */\nexport function storeCreatorDecorator(name: TSdkStoreName, storeCreator: TMigrationType): TMigrationType {\n return function (database: IDBDatabase) {\n if (database.objectStoreNames.contains(name)) {\n return;\n }\n\n storeCreator(database);\n };\n}\n","import {\n STORE_NAME_INBOX_MESSAGES,\n STORE_NAME_KEY_VALUE,\n STORE_NAME_MAIN_LOG,\n STORE_NAME_MESSAGE_LOG,\n KEY_PATH_BASE_INCREMENT,\n} from './constants';\nimport { storeCreatorDecorator } from './helpers';\nimport {\n type TInboxMessagesIDBKeyPath,\n type TInboxMessagesIDBRemovalTimeIndex,\n type TInboxMessagesIDBStatusIndex,\n} from '../../../models/InboxMessages.types';\n\n/**\n * Create keyValue store migration\n * @param database\n */\nfunction createKeyValueStore(database: IDBDatabase) {\n database.createObjectStore(STORE_NAME_KEY_VALUE, { keyPath: 'key' });\n}\n\n/**\n * Create log store migration\n * @param database\n */\nfunction createLogStore(database: IDBDatabase) {\n const logStore = database.createObjectStore(\n STORE_NAME_MAIN_LOG,\n { keyPath: KEY_PATH_BASE_INCREMENT, autoIncrement: true },\n );\n logStore.createIndex('environment', 'environment', { unique: false });\n logStore.createIndex('date', 'date', { unique: false });\n logStore.createIndex('type', 'type', { unique: false });\n}\n\n/**\n * Create message log store migration\n * @param database\n */\nfunction createMessageLogStore(database: IDBDatabase) {\n const messagesStore = database.createObjectStore(\n STORE_NAME_MESSAGE_LOG,\n { keyPath: KEY_PATH_BASE_INCREMENT, autoIncrement: true },\n );\n messagesStore.createIndex('date', 'date', { unique: false });\n}\n\n/**\n * Create inbox messages store migration\n * @param database\n */\nfunction createInboxMessagesStore(database: IDBDatabase) {\n const keyPath: TInboxMessagesIDBKeyPath = 'inbox_id';\n const statusIndex: TInboxMessagesIDBStatusIndex = 'status';\n const removalTimeIndex: TInboxMessagesIDBRemovalTimeIndex = 'rt';\n\n const store = database.createObjectStore(STORE_NAME_INBOX_MESSAGES,\n { keyPath, autoIncrement: false },\n );\n store.createIndex(statusIndex, statusIndex, { unique: false, multiEntry: true });\n store.createIndex(removalTimeIndex, removalTimeIndex, { unique: false, multiEntry: true });\n}\n\nexport default [\n storeCreatorDecorator(STORE_NAME_KEY_VALUE, createKeyValueStore),\n storeCreatorDecorator(STORE_NAME_MAIN_LOG, createLogStore),\n storeCreatorDecorator(STORE_NAME_MESSAGE_LOG, createMessageLogStore),\n storeCreatorDecorator(STORE_NAME_INBOX_MESSAGES, createInboxMessagesStore),\n];\n","import { default as migrationsInitial } from './initial';\nimport { type TMigrationType } from '../Storage.types';\n\nexport default class Migrations {\n get all(): Array<TMigrationType> {\n return migrationsInitial;\n }\n}\n","import Migrations from './Migrations';\nimport { type TMigrationType } from '../Storage.types';\n\nexport default class MigrationExecutor {\n db: IDBDatabase;\n migrationsBuilder: Migrations;\n\n constructor(\n db: IDBDatabase,\n migrationsBuilder: Migrations = new Migrations(),\n ) {\n this.db = db;\n this.migrationsBuilder = migrationsBuilder;\n }\n\n applyMigrations() {\n this.applyMigrationsPack(this.migrationsBuilder.all);\n }\n\n applyMigrationsPack(migrationsPack: Array<TMigrationType>) {\n migrationsPack.forEach((migration) => {\n migration(this.db);\n });\n }\n}\n","import {\n STORE_NAME_KEY_VALUE,\n STORE_NAME_MAIN_LOG,\n STORE_NAME_MESSAGE_LOG,\n} from '../modules/storage/migrations/constants';\nimport MigrationExecutor from '../modules/storage/migrations/MigrationExecutor';\nimport { type IIDBOpenEventTargetWithResult } from '../modules/storage/Storage.types';\nimport version from '../modules/storage/version';\n\ndeclare const self: ServiceWorkerGlobalScope;\n\nfunction onversionchange(database: IDBDatabase, event: Event) {\n console.info('onversionchange', event);\n database.close();\n}\n\nlet databasePromise: Promise<IDBDatabase>;\nexport function getInstance(): Promise<IDBDatabase> {\n if (!databasePromise) {\n databasePromise = new Promise<IDBDatabase>((resolve, reject) => {\n const request: IDBOpenDBRequest = indexedDB.open('PUSHWOOSH_SDK_STORE', version);\n request.onsuccess = (event) => {\n const database: IDBDatabase = (event.target as IIDBOpenEventTargetWithResult).result;\n database.onversionchange = onversionchange.bind(null, database, reject);\n resolve(database);\n };\n\n request.onerror = () => reject(request.error);\n\n request.onupgradeneeded = (event) => {\n const database: IDBDatabase = (event.target as IIDBOpenEventTargetWithResult).result;\n database.onversionchange = onversionchange.bind(null, database, reject);\n\n const migrationExecutor = new MigrationExecutor(database);\n migrationExecutor.applyMigrations();\n };\n });\n }\n return databasePromise;\n}\n\nfunction getInstanceWithPromise(executor: any): any {\n return getInstance().then((database) => (\n new Promise((resolve, reject) => executor(database, resolve, reject))\n ));\n}\n\nfunction createKeyValue(name: string) {\n return {\n get<K extends string, D>(key: K, defaultValue?: D) {\n return getInstanceWithPromise((database: IDBDatabase, resolve: any, reject: any) => {\n const request = database.transaction(name).objectStore(name).get(key);\n\n /** @TODO\n * we cant invoke \"resolve\" or \"reject\" in onsuccess or onerror because\n * it leads to bugs in Safari when we try to get permissions for notifications\n *\n * Checking status of request in setTimeout fixes this bug\n */\n let isComplete = false;\n let isError = false;\n let timeout: any;\n\n const check = () => {\n clearTimeout(timeout);\n if (isComplete) {\n resolve(request.result?.value || defaultValue);\n } else if (isError) {\n reject(request.error);\n } else {\n timeout = setTimeout(check, 0);\n }\n };\n\n request.onsuccess = () => isComplete = true;\n request.onerror = () => isError = true;\n check();\n });\n },\n\n getAll() {\n return getInstanceWithPromise((database: IDBDatabase, resolve: any, reject: any) => {\n const result: { [key: string]: any } = {};\n const cursor = database.transaction(name).objectStore(name).openCursor();\n let isComplete = false;\n let isError = false;\n let timeout: any;\n\n /** @TODO\n * we cant invoke \"resolve\" or \"reject\" in onsuccess or onerror because\n * it leads to bugs in Safari when we try to get permissions for notifications\n *\n * Checking status of request in setTimeout fixes this bug\n */\n const check = () => {\n clearTimeout(timeout);\n if (isComplete) {\n resolve(result);\n } else if (isError) {\n reject(cursor.error);\n } else {\n timeout = setTimeout(check, 0);\n }\n };\n\n cursor.onsuccess = (event) => {\n const cursorResult = (event.target as any).result;\n if (cursorResult) {\n result[cursorResult.key] = cursorResult.value.value;\n cursorResult.continue();\n } else {\n isComplete = true;\n }\n };\n cursor.onerror = () => isError = true;\n check();\n });\n },\n\n async extend(key: string, value: any) {\n const oldValues = await this.get(key);\n const { ...newValues } = value;\n await this.set(key, { ...oldValues, ...newValues });\n },\n\n set<K, D>(key: K, value: D) {\n return getInstanceWithPromise((database: IDBDatabase, resolve: any, reject: any) => {\n const request = database.transaction([name], 'readwrite').objectStore(name).put({ key, value });\n let isComplete = false;\n let isError = false;\n let timeout: any;\n\n /** @TODO\n * we cant invoke \"resolve\" or \"reject\" in onsuccess or onerror because\n * it leads to bugs in Safari when we try to get permissions for notifications\n *\n * Checking status of request in setTimeout fixes this bug\n */\n const check = () => {\n clearTimeout(timeout);\n if (isComplete) {\n resolve(key);\n } else if (isError) {\n reject(request.error);\n } else {\n timeout = setTimeout(check, 0);\n }\n };\n\n request.onsuccess = () => isComplete = true;\n request.onerror = () => isError = true;\n check();\n });\n },\n };\n}\n\nexport abstract class LogBase {\n protected abstract name: string;\n protected abstract maxItems: number;\n _add(obj: any) {\n return getInstanceWithPromise((database: IDBDatabase, resolve: any, reject: any) => {\n const request = database.transaction([this.name], 'readwrite').objectStore(this.name).add(obj);\n request.onsuccess = () => {\n resolve(obj);\n };\n request.onerror = () => {\n reject(request.error);\n };\n }).then((obj: any) => {\n return this.getAll().then((items: { id: number }[]) => {\n if (Array.isArray(items)) {\n const ids = items.map((i) => i.id).sort((a, b) => {\n if (a == b) return 0;\n return a < b ? 1 : -1;\n });\n if (ids.length > this.maxItems) {\n return Promise.all(ids.slice(this.maxItems).map((id) => this.delete(id))).then(() => obj);\n }\n }\n return obj;\n });\n });\n }\n\n delete(key: any) {\n return getInstanceWithPromise((database: IDBDatabase, resolve: any, reject: any) => {\n const request = database.transaction([this.name], 'readwrite').objectStore(this.name).delete(key);\n request.onsuccess = () => {\n resolve(request.result);\n };\n request.onerror = () => {\n reject(request.error);\n };\n });\n }\n\n getAll() {\n return getInstanceWithPromise((database: IDBDatabase, resolve: any, reject: any) => {\n const result: any[] = [];\n const cursor = database.transaction(this.name).objectStore(this.name).openCursor();\n cursor.onsuccess = (ev) => {\n const cursorResult = (ev.target as any).result;\n if (cursorResult) {\n if (cursorResult.value) {\n result.push(cursorResult.value);\n }\n cursorResult.continue();\n } else {\n resolve(result);\n }\n };\n cursor.onerror = () => {\n reject(cursor.error);\n };\n });\n }\n}\n\nexport class LogLog extends LogBase {\n protected name = STORE_NAME_MAIN_LOG;\n protected maxItems = 100;\n protected environment = (typeof self !== 'undefined' && self.registration) ? 'worker' : 'browser';\n add(type: string, message: any, additional?: any) {\n const obj: any = {\n type,\n environment: this.environment,\n message: `${message}`,\n date: new Date(),\n };\n if (message instanceof Error) {\n obj.stack = message.stack;\n }\n if (additional) {\n obj.additional = additional;\n }\n return this._add(obj);\n }\n}\n\nexport class LogMessage extends LogBase {\n protected name = STORE_NAME_MESSAGE_LOG;\n protected maxItems = 25;\n add(log: any) {\n return this._add({\n ...log,\n date: new Date(),\n });\n }\n}\n\nexport const keyValue = createKeyValue(STORE_NAME_KEY_VALUE);\nexport const log = new LogLog();\nexport const message = new LogMessage();\n","import { log as logStorage } from './storage';\n\nconst levels: { [key: string]: number } = {\n error: 1,\n info: 2,\n debug: 3,\n};\n\nlet limitLevel = 3;\n\ntype TWriteType = 'error' | 'apirequest' | 'info';\n\ninterface ILogger {\n setLevel(level: string): void;\n error(...args: any[]): void;\n info(...args: any[]): void;\n debug(...args: any[]): void;\n write(type: TWriteType, message: any, additional?: any): Promise<void>;\n isManualLevel(): boolean;\n [key: string]: any;\n}\n\nconst Logger: ILogger = {\n setLevel(level) {\n if (!levels[level]) {\n level = 'error';\n }\n limitLevel = levels[level];\n },\n write(type: TWriteType, message: any, additional?: any) {\n if (type === 'error') {\n this.error(message);\n } else {\n this.info(message);\n }\n return logStorage.add(type, message, additional);\n },\n} as ILogger;\n\nObject.keys(levels).forEach((levelName: string) => {\n const levelNumber = levels[levelName];\n Logger[levelName] = (...args: any[]) => {\n if (levelNumber <= limitLevel) {\n console.groupCollapsed(levelName);\n console.info('', ...args);\n console.trace('trace');\n console.groupEnd();\n }\n };\n});\n\nexport function logAndThrowError(error: string) {\n const logText = new Error(error);\n Logger.write('error', logText, 'logAndThrowError');\n throw logText;\n}\n\nexport function logAndRejectError(error: string, reject: (e: any) => void) {\n const logText = new Error(error);\n Logger.write('error', logText, 'logAndRejectError');\n reject(logText);\n}\n\nexport { Logger };\n","import { RECOMMENDATIONS_STYLES } from './styles';\nimport { Logger } from '../../core/logger';\nimport { type Recommendations } from '../../modules/Recommendations/Recommendations';\nimport {\n type IRecommendationsRequest, type IRecommendationsResponse, type IRecommendedProduct, type TRecommendationStrategy,\n} from '../../modules/Recommendations/Recommendations.types';\n\nexport const CONTAINER_SELECTOR = '[data-pw-recommendations]';\n\n// a change to any of these re-renders the block\nconst WATCHED_ATTRIBUTES = [\n 'data-pw-recommendations', 'data-pw-strategy', 'data-pw-fallback', 'data-pw-limit', 'data-pw-product-id',\n 'data-pw-exclude', 'data-pw-block', 'data-pw-title', 'data-pw-fallback-title',\n];\n\nexport type TRecommendationsState = 'loading' | 'ready' | 'empty' | 'error';\n\n/** The block's request, read from its data attributes. */\nexport function readRequest(el: HTMLElement): IRecommendationsRequest {\n const { dataset } = el;\n const limit = Number(dataset.pwLimit);\n\n return {\n strategy: (dataset.pwStrategy || 'bestsellers_30d') as TRecommendationStrategy,\n fallback: dataset.pwFallback as IRecommendationsRequest['fallback'] || undefined,\n limit: Number.isFinite(limit) && limit > 0 ? limit : undefined,\n productId: dataset.pwProductId || undefined,\n exclude: dataset.pwExclude ? dataset.pwExclude.split(',').map((id) => id.trim()).filter(Boolean) : undefined,\n block: dataset.pwBlock || undefined,\n };\n}\n\n// the feed is the merchant's catalog: a javascript: link from it must not reach the page\nfunction safeHref(url: string): string | null {\n try {\n const parsed = new URL(url, location.href);\n\n return parsed.protocol === 'http:' || parsed.protocol === 'https:' ? parsed.href : null;\n } catch {\n return null;\n }\n}\n\nexport class RecommendationsWidget {\n private readonly recommendations: Recommendations;\n private readonly root: Document;\n // a re-render supersedes the request in flight: its late answer must not overwrite the new one\n private readonly generations = new WeakMap<HTMLElement, number>();\n private observer?: MutationObserver;\n\n constructor(recommendations: Recommendations, root: Document = document) {\n this.recommendations = recommendations;\n this.root = root;\n }\n\n public run(): void {\n this.root.querySelectorAll<HTMLElement>(CONTAINER_SELECTOR).forEach((el) => void this.render(el));\n\n // SPA pages add blocks and swap the product on screen without a reload\n this.observer = new MutationObserver((mutations) => this.onMutations(mutations));\n this.observer.observe(this.root.documentElement, {\n childList: true, subtree: true, attributes: true, attributeFilter: WATCHED_ATTRIBUTES,\n });\n }\n\n public stop(): void {\n this.observer?.disconnect();\n }\n\n public async render(el: HTMLElement): Promise<void> {\n const generation = (this.generations.get(el) ?? 0) + 1;\n this.generations.set(el, generation);\n\n const shadow = el.shadowRoot ?? el.attachShadow({ mode: 'open' });\n this.setState(el, 'loading');\n if (el.dataset.pwMinHeight) {\n el.style.minHeight = /^\\d+$/.test(el.dataset.pwMinHeight) ? `${el.dataset.pwMinHeight}px` : el.dataset.pwMinHeight;\n }\n\n const request = readRequest(el);\n let response: IRecommendationsResponse;\n try {\n response = await this.recommendations.fetch(request);\n } catch (error) {\n if (this.generations.get(el) !== generation) return;\n Logger.error(error, 'Pushwoosh: recommendations block failed to load');\n shadow.replaceChildren();\n this.setState(el, 'error');\n\n return;\n }\n if (this.generations.get(el) !== generation) return;\n\n if (!response.items?.length) {\n // the site hides its own frame around an empty block by this state\n shadow.replaceChildren();\n this.setState(el, 'empty');\n\n return;\n }\n\n shadow.replaceChildren(...this.build(el, request, response));\n this.setState(el, 'ready');\n }\n\n private build(el: HTMLElement, request: IRecommendationsRequest, response: IRecommendationsResponse): Node[] {\n const doc = this.root;\n const style = doc.createElement('style');\n style.textContent = RECOMMENDATIONS_STYLES;\n const nodes: Node[] = [style];\n\n const fellBack = response.strategy !== request.strategy;\n const title = fellBack && el.dataset.pwFallbackTitle ? el.dataset.pwFallbackTitle : el.dataset.pwTitle;\n if (title) {\n const heading = doc.createElement('div');\n heading.className = 'title';\n heading.setAttribute('part', 'title');\n heading.textContent = title;\n nodes.push(heading);\n }\n\n const grid = doc.createElement('div');\n grid.className = 'grid';\n grid.setAttribute('part', 'grid');\n response.items.forEach((item, index) => grid.appendChild(this.card(item, index + 1, request.block, response.strategy)));\n nodes.push(grid);\n\n return nodes;\n }\n\n private card(item: IRecommendedProduct, position: number, block: string | undefined, strategy: string): HTMLElement {\n const doc = this.root;\n const card = doc.createElement('a');\n card.className = 'card';\n card.setAttribute('part', 'card');\n const href = safeHref(item.url);\n if (href) card.href = href;\n card.addEventListener('click', () => {\n void this.recommendations.trackClick({ block, strategy, productId: item.id, position })\n .catch((error) => Logger.error(error, 'Pushwoosh: failed to report a recommendation click'));\n });\n\n if (item.image_url && safeHref(item.image_url)) {\n const image = doc.createElement('img');\n image.className = 'image';\n image.loading = 'lazy';\n image.alt = item.title;\n image.src = item.image_url;\n card.appendChild(image);\n }\n\n const name = doc.createElement('span');\n name.className = 'name';\n name.textContent = item.title;\n card.appendChild(name);\n\n if (item.price_formatted) {\n const price = doc.createElement('span');\n price.className = 'price';\n price.textContent = item.price_formatted;\n if (item.old_price_formatted) {\n const old = doc.createElement('span');\n old.className = 'old';\n old.textContent = item.old_price_formatted;\n price.appendChild(old);\n }\n card.appendChild(price);\n }\n\n return card;\n }\n\n private setState(el: HTMLElement, state: TRecommendationsState): void {\n el.setAttribute('data-pw-state', state);\n }\n\n private onMutations(mutations: MutationRecord[]): void {\n const dirty = new Set<HTMLElement>();\n mutations.forEach((mutation) => {\n if (mutation.type === 'attributes') {\n if ((mutation.target as HTMLElement).matches?.(CONTAINER_SELECTOR)) dirty.add(mutation.target as HTMLElement);\n\n return;\n }\n mutation.addedNodes.forEach((node) => {\n if (!(node instanceof HTMLElement)) return;\n if (node.matches(CONTAINER_SELECTOR)) dirty.add(node);\n node.querySelectorAll<HTMLElement>(CONTAINER_SELECTOR).forEach((el) => dirty.add(el));\n });\n });\n dirty.forEach((el) => void this.render(el));\n }\n}\n"],"names":["root","factory","exports","module","define","amd","a","i","this","__webpack_require__","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","defineProperties","Symbol","toStringTag","value","__esModule","STORE_NAME_KEY_VALUE","STORE_NAME_MESSAGE_LOG","STORE_NAME_INBOX_MESSAGES","storeCreatorDecorator","name","storeCreator","database","objectStoreNames","contains","initial","createObjectStore","keyPath","logStore","autoIncrement","createIndex","unique","statusIndex","store","multiEntry","Migrations","all","MigrationExecutor","constructor","db","migrationsBuilder","applyMigrations","applyMigrationsPack","migrationsPack","forEach","migration","onversionchange","event","console","info","close","databasePromise","getInstanceWithPromise","executor","Promise","resolve","reject","request","indexedDB","open","onsuccess","target","result","bind","onerror","error","onupgradeneeded","then","LogBase","_add","transaction","objectStore","add","getAll","items","Array","isArray","ids","map","id","sort","b","length","maxItems","slice","delete","cursor","openCursor","ev","cursorResult","push","continue","log","environment","self","registration","type","message","additional","date","Date","Error","stack","levels","debug","limitLevel","Logger","setLevel","level","write","keys","levelName","levelNumber","args","groupCollapsed","trace","groupEnd","CONTAINER_SELECTOR","WATCHED_ATTRIBUTES","safeHref","url","parsed","URL","location","href","protocol","RecommendationsWidget","recommendations","document","generations","WeakMap","run","querySelectorAll","el","render","observer","MutationObserver","mutations","onMutations","observe","documentElement","childList","subtree","attributes","attributeFilter","stop","disconnect","generation","set","shadow","shadowRoot","attachShadow","mode","setState","dataset","pwMinHeight","style","minHeight","test","limit","Number","pwLimit","strategy","pwStrategy","fallback","pwFallback","undefined","isFinite","productId","pwProductId","exclude","pwExclude","split","trim","filter","Boolean","block","pwBlock","readRequest","response","fetch","replaceChildren","build","doc","createElement","textContent","nodes","title","pwFallbackTitle","pwTitle","heading","className","setAttribute","grid","item","index","appendChild","card","position","addEventListener","trackClick","catch","image_url","image","loading","alt","src","price_formatted","price","old_price_formatted","old","state","dirty","Set","mutation","addedNodes","node","HTMLElement","matches"],"sourceRoot":""}
@@ -1,2 +1,2 @@
1
- !function(t,n){if("object"==typeof exports&&"object"==typeof module)module.exports=n();else if("function"==typeof define&&define.amd)define([],n);else{var p=n();for(var e in p)("object"==typeof exports?exports:t)[e]=p[e]}}(this,()=>(()=>{"use strict";const t={d:(n,p)=>{for(var e in p)t.o(p,e)&&!t.o(n,e)&&Object.defineProperty(n,e,{enumerable:!0,get:p[e]})},o:(t,n)=>Object.prototype.hasOwnProperty.call(t,n),r:t=>{Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}};let n={};t.r(n),t.d(n,{PWSubscribePopupWidget:()=>a});const p={enable:!0,text:"Don’t miss out on our news and updates! Enable push notifications",askLaterButtonText:"Not now",confirmSubscriptionButtonText:"Subscribe",delay:5,retryOffset:604800,overlay:!1,position:"top",mobileViewMargin:"0",bgColor:"#fff",borderColor:"transparent",boxShadow:"0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23)",textColor:"#000",textSize:"inherit",textWeight:"normal",fontFamily:"inherit",subscribeBtnBgColor:"#4285f4",subscribeBtnTextColor:"#fff",subscribeBtnTextWeight:"normal",subscribeBtnBorderColor:"transparent",subscribeBtnBorderRadius:"2px",askLaterBtnBgColor:"transparent",askLaterBtnTextColor:"#000",askLaterBtnTextWeight:"normal",askLaterBtnBorderColor:"transparent",askLaterBtnBorderRadius:"2px",theme:"material",viewport:"html"},e=[{name:"mobileViewMargin",type:"string"},{name:"bgColor",type:"color"},{name:"borderColor",type:"color"},{name:"boxShadow",type:"string"},{name:"textColor",type:"color"},{name:"textSize",type:"string"},{name:"textWeight",type:"string"},{name:"fontFamily",type:"string"},{name:"subscribeBtnBgColor",type:"color"},{name:"subscribeBtnTextColor",type:"color"},{name:"subscribeBtnTextWeight",type:"string"},{name:"subscribeBtnBorderColor",type:"color"},{name:"subscribeBtnBorderRadius",type:"string"},{name:"askLaterBtnBgColor",type:"color"},{name:"askLaterBtnTextColor",type:"color"},{name:"askLaterBtnTextWeight",type:"string"},{name:"askLaterBtnBorderColor",type:"color"},{name:"askLaterBtnBorderRadius",type:"string"}],o="#333",i=/[;{}]/;let s=null;function r(t,n){switch(t){case"size":{const t=Number(n??0);return Number.isFinite(t)?`${t}px`:null}case"number":{const t=parseFloat(String(n));return Number.isFinite(t)?String(t):null}case"color":{const t=String(n);return function(t){return i.test(t)?o:(s||(s=document.createElement("div")),s.style.color="",s.style.color=t,s.style.color?t:o)}(t)===t?t:null}default:return String(n).trim()||null}}class a{constructor(t){this.pw=t;const{mobileViewMargin:n=""}=t.initParams.subscribePopup||{};this.config={...p,...t.initParams.subscribePopup},this.hasMobileViewMargin=Boolean(n),this.onAskLaterClick=this.onAskLaterClick.bind(this),this.onSubscribeClick=this.onSubscribeClick.bind(this)}async run(){const t=this.pw.isPushAvailable()?this.pw.driver:null;if(!t)return;const{manualToggle:n}=this.config,[p,e]=await Promise.all([this.pw.isSubscribed(),this.pw.data.getStatusManualUnsubscribed()]);if(p||!n&&e)return;const o=t.getPermission();if("granted"===o||"denied"===o)return;if(this.renderPopup(),this.appendStyles(),this.pw.moduleRegistry.subscribePopup=this,this.pw.dispatchEvent("subscribe-popup-ready",{}),n)return;const i=localStorage.getItem("LAST_OPEN_SUBSCRIPTION_POPUP"),s=i?parseInt(i):0,r=(new Date).getTime();s+1e3*this.config.retryOffset<r&&setTimeout(()=>{this.toggle(!0)},1e3*this.config.delay)}toggle(t){const n=void 0===t?!this.isShown:!!t;n!==this.isShown&&(n?this.show():this.hide())}async show(){if(await this.pw.isSubscribed())return;this.isShown=!0,this.popup.classList.add("pw-show"),document.body.classList.add("pw-popup-opened");const t=new CustomEvent("showPopup",{bubbles:!1,cancelable:!1,detail:{popup:this.popup}});this.popup.dispatchEvent(t);if(Math.max(document.documentElement.clientWidth,window.innerWidth||0)<541)return;const{theme:n,viewport:p,position:e}=this.config;if("topbar"===n&&"top"===e){const t=document.querySelector(p)||document.createElement("div"),n=window.getComputedStyle(t).marginTop||"0";t.style.transition="margin-top .3s ease-out",t.style.marginTop=`${parseInt(n)+this.popup.getBoundingClientRect().height}px`}this.pw.dispatchEvent("subscribe-popup-show",{})}hide(){this.isShown=!1,this.popup.classList.remove("pw-show"),document.body.classList.remove("pw-popup-opened");const t=new CustomEvent("hidePopup",{bubbles:!1,cancelable:!1,detail:{popup:this.popup}});this.popup.dispatchEvent(t);const n=(new Date).getTime().toString();localStorage.setItem("LAST_OPEN_SUBSCRIPTION_POPUP",n);if(Math.max(document.documentElement.clientWidth,window.innerWidth||0)<541)return;const{theme:p,viewport:e,position:o}=this.config;if("topbar"===p&&"top"===o){const t=document.querySelector(e)||document.createElement("div"),n=window.getComputedStyle(t).marginTop||"0";t.style.marginTop=parseInt(n)-this.popup.getBoundingClientRect().height+"px"}this.pw.dispatchEvent("subscribe-popup-hide",{})}renderPopup(){this.popup=document.createElement("div"),this.popup.id="pwSubscribePopup";const{text:t,askLaterButtonText:n,confirmSubscriptionButtonText:p,iconUrl:e,iconAlt:o,position:i,overlay:s,theme:r}=this.config;this.popup.className=`pw-subscribe-popup pw-position-${i} pw-subscribe-popup-${r}`,this.popup.classList.toggle("pw-subscribe-popup__overlay",s),this.popup.classList.toggle("pw-mobile-view-margin",this.hasMobileViewMargin),this.popup.innerHTML=(({iconUrl:t,iconAlt:n,text:p,askLaterButtonText:e,confirmSubscriptionButtonText:o})=>`<div class="pw-subscription-popup-inner">\n <div class="pw-subscription-popup-content">\n ${t?`<div class="pw-subscription-popup-icon"><img src="${t}" alt="${n||"Subscribe"}"></div>`:""}\n <div class="pw-subscription-popup-text">\n ${p}\n </div>\n </div>\n <div class="pw-subscription-popup-controls">\n <button name="pwAskLater" class="pw-subscribe-popup-button">${e}</button>\n <button name="pwSubscribe" class="pw-subscribe-popup-button pw-subscribe-popup-button-active">${o}</button>\n </div>\n </div>`)({text:t,askLaterButtonText:n,confirmSubscriptionButtonText:p,iconUrl:e,iconAlt:o}),this.applyStyleVariables(),document.body.appendChild(this.popup),this.addListeners()}appendStyles(){const t=document.createElement("style");t.innerHTML=".pw-subscribe-popup {\n position: fixed;\n left: 50%;\n transform: translateX(-50%);\n justify-content: center;\n z-index: 1000000;\n display: flex;\n transition: all .4s ease-out;\n}\n\n.pw-subscribe-popup.pw-position-top {\n top: calc(-100% - 24px);\n}\n.pw-subscribe-popup.pw-position-top.pw-show {\n top: 0;\n}\n\n.pw-subscribe-popup.pw-position-bottom {\n bottom: calc(-100% - 24px);\n}\n.pw-subscribe-popup.pw-position-bottom.pw-show {\n bottom: 0;\n}\n\n.pw-subscribe-popup.pw-position-center {\n display: flex;\n\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n height: 100vh;\n justify-content: center;\n align-items: center;\n\n transform: none;\n}\n\n.pw-subscribe-popup__overlay {\n background: rgba(0,0,0,.4);\n z-index: 1000000;\n}\n\n.pw-subscribe-popup.pw-position-center:not(.pw-subscribe-popup__overlay) {\n pointer-events: none;\n}\n\n.pw-subscribe-popup.pw-position-center:not(.pw-show) {\n display: none;\n}\n\n\n.pw-subscribe-popup__overlay.pw-position-top {\n align-items: flex-start;\n}\n\n.pw-subscribe-popup__overlay.pw-position-bottom {\n align-items: flex-end;\n}\n\n.pw-subscribe-popup__overlay.pw-position-center {\n align-items: center;\n}\n\n.pw-subscription-popup-inner {\n max-width: 400px;\n font-size: var(--pw-popup-textSize, inherit);\n color: var(--pw-popup-textColor, #000);\n font-weight: var(--pw-popup-textWeight, normal);\n font-family: var(--pw-popup-fontFamily, inherit);\n border-style: solid;\n border-width: 1px;\n border-color: var(--pw-popup-borderColor, transparent);\n background: var(--pw-popup-bgColor, #fff);\n box-shadow: var(--pw-popup-boxShadow, 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23));\n pointer-events: auto;\n}\n\n.pw-subscription-popup-content {\n padding: 16px 16px 4px;\n display: flex;\n justify-content: stretch;\n}\n\n.pw-subscription-popup-icon {\n flex: 0 0 50px;\n margin-right: 12px;\n padding-top: 4px;\n}\n\n.pw-subscription-popup-icon img {\n max-width: 60px;\n max-height: 60px;\n}\n\n.pw-subscription-popup-text {\n flex: 1 1 300px;\n}\n\n.pw-subscription-popup-controls {\n display: flex;\n flex-wrap: nowrap;\n justify-content: center;\n padding: 8px 16px 16px;\n}\n\nbutton.pw-subscribe-popup-button {\n border: solid 1px var(--pw-popup-askLaterBtnBorderColor, transparent);\n border-radius: var(--pw-popup-askLaterBtnBorderRadius, 2px);\n display: inline-block;\n height: 36px;\n line-height: 36px;\n padding: 0 16px;\n text-transform: uppercase;\n font-weight: var(--pw-popup-askLaterBtnTextWeight, normal);\n vertical-align: middle;\n -webkit-tap-highlight-color: transparent;\n font-size: 14px;\n outline: 0;\n text-decoration: none;\n color: var(--pw-popup-askLaterBtnTextColor, #000);\n text-align: center;\n letter-spacing: .5px;\n cursor: pointer;\n background: var(--pw-popup-askLaterBtnBgColor, transparent);\n margin: 4px 8px;\n}\nbutton.pw-subscribe-popup-button:hover {\n background: rgba(0,0,0,.04);\n}\nbutton.pw-subscribe-popup-button:active {\n background: rgba(0,0,0,.12);\n}\n\nbutton.pw-subscribe-popup-button.pw-subscribe-popup-button-active {\n color: var(--pw-popup-subscribeBtnTextColor, #fff);\n background: var(--pw-popup-subscribeBtnBgColor, #4285f4);\n border-radius: var(--pw-popup-subscribeBtnBorderRadius, 2px);\n border: solid 1px var(--pw-popup-subscribeBtnBorderColor, transparent);\n box-shadow: 0 2px 2px 0 rgba(0,0,0,0.14),\n 0 3px 1px -2px rgba(0,0,0,0.12),\n 0 1px 5px 0 rgba(0,0,0,0.2);\n font-weight: var(--pw-popup-subscribeBtnTextWeight, normal);\n}\nbutton.pw-subscribe-popup-button.pw-subscribe-popup-button-active:hover {\n box-shadow: 0 3px 3px 0 rgba(0,0,0,0.14),\n 0 1px 7px 0 rgba(0,0,0,0.12),\n 0 3px 1px -1px rgba(0,0,0,0.2);\n}\nbutton.pw-subscribe-popup-button.pw-subscribe-popup-button-active:active {\n box-shadow: 0 2px 2px 0 rgba(0,0,0,0.14),\n 0 3px 1px -2px rgba(0,0,0,0.12),\n 0 1px 5px 0 rgba(0,0,0,0.2);\n}\n\n@media screen and (min-width: 541px) {\n\n .pw-subscribe-popup-topbar {\n width: 100%;\n }\n\n .pw-subscribe-popup-topbar .pw-subscription-popup-inner {\n max-width: 100%;\n width: 100%;\n display: flex;\n flex-direction: row;\n padding: 2px 40px;\n justify-content: center;\n align-items: center;\n flex-wrap: nowrap;\n }\n\n .pw-subscribe-popup-topbar .pw-subscription-popup-content {\n padding: 0;\n justify-content: flex-start;\n align-items: center;\n }\n\n .pw-subscribe-popup-topbar .pw-subscription-popup-icon img {\n max-width: 28px;\n max-height: 28px;\n }\n\n .pw-subscribe-popup-topbar button.pw-subscribe-popup-button {\n height: 32px;\n line-height: 32px;\n }\n\n .pw-subscribe-popup-topbar .pw-subscription-popup-controls {\n padding: 0 0 0 16px;\n align-items: center;\n }\n}\n@media screen and (max-width: 540px) {\n .pw-subscribe-popup,\n .pw-subscribe-popup.pw-position-top,\n .pw-subscribe-popup.pw-position-center,\n .pw-subscribe-popup.pw-position-bottom {\n top: auto;\n bottom: -110%;\n left: 0;\n right: 0;\n transform: none;\n display: flex;\n transition: bottom .4s ease-out;\n align-items: flex-end;\n }\n\n .pw-subscribe-popup.pw-mobile-view-margin {\n top: auto !important;\n transition: none;\n }\n\n .pw-subscribe-popup.pw-subscribe-popup__overlay {\n align-items: flex-end;\n }\n\n .pw-subscribe-popup.pw-show {\n bottom: var(--pw-popup-mobileViewMargin, 0);\n }\n\n .pw-subscribe-popup__overlay .pw-subscription-popup-inner {\n align-items: flex-end;\n justify-content: stretch;\n }\n\n .pw-subscription-popup-inner {\n max-width: 100%;\n width: 100%;\n }\n}\n".toString(),document.body.appendChild(t)}applyStyleVariables(){var t,n,p,o;t=this.popup,n="pw-popup",p=e,o=this.config,p.forEach(({name:p,type:e})=>{const i=r(e,o[p]);null!==i&&t.style.setProperty(function(t,n){return`--${t}-${n}`}(n,p),i)})}addListeners(){const t=this.popup.querySelector('button[name="pwAskLater"]')||document.createElement("button"),n=this.popup.querySelector('button[name="pwSubscribe"]')||document.createElement("button");t.addEventListener("click",this.onAskLaterClick),n.addEventListener("click",this.onSubscribeClick)}onAskLaterClick(){this.toggle(!1),this.pw.dispatchEvent("subscribe-popup-decline",{})}onSubscribeClick(){this.toggle(!1),this.pw.dispatchEvent("subscribe-popup-accept",{}),this.pw.subscribe()}}return n})());
1
+ !function(t,n){if("object"==typeof exports&&"object"==typeof module)module.exports=n();else if("function"==typeof define&&define.amd)define([],n);else{var p=n();for(var e in p)("object"==typeof exports?exports:t)[e]=p[e]}}(this,()=>(()=>{"use strict";const t={d:(n,p)=>{for(var e in p)t.o(p,e)&&!t.o(n,e)&&Object.defineProperty(n,e,{enumerable:!0,get:p[e]})},o:(t,n)=>Object.prototype.hasOwnProperty.call(t,n),r:t=>{Object.defineProperties(t,{[Symbol.toStringTag]:{value:"Module"},__esModule:{value:!0}})}};let n={};t.r(n),t.d(n,{PWSubscribePopupWidget:()=>a});const p={enable:!0,text:"Don’t miss out on our news and updates! Enable push notifications",askLaterButtonText:"Not now",confirmSubscriptionButtonText:"Subscribe",delay:5,retryOffset:604800,overlay:!1,position:"top",mobileViewMargin:"0",bgColor:"#fff",borderColor:"transparent",boxShadow:"0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23)",textColor:"#000",textSize:"inherit",textWeight:"normal",fontFamily:"inherit",subscribeBtnBgColor:"#4285f4",subscribeBtnTextColor:"#fff",subscribeBtnTextWeight:"normal",subscribeBtnBorderColor:"transparent",subscribeBtnBorderRadius:"2px",askLaterBtnBgColor:"transparent",askLaterBtnTextColor:"#000",askLaterBtnTextWeight:"normal",askLaterBtnBorderColor:"transparent",askLaterBtnBorderRadius:"2px",theme:"material",viewport:"html"},e=[{name:"mobileViewMargin",type:"string"},{name:"bgColor",type:"color"},{name:"borderColor",type:"color"},{name:"boxShadow",type:"string"},{name:"textColor",type:"color"},{name:"textSize",type:"string"},{name:"textWeight",type:"string"},{name:"fontFamily",type:"string"},{name:"subscribeBtnBgColor",type:"color"},{name:"subscribeBtnTextColor",type:"color"},{name:"subscribeBtnTextWeight",type:"string"},{name:"subscribeBtnBorderColor",type:"color"},{name:"subscribeBtnBorderRadius",type:"string"},{name:"askLaterBtnBgColor",type:"color"},{name:"askLaterBtnTextColor",type:"color"},{name:"askLaterBtnTextWeight",type:"string"},{name:"askLaterBtnBorderColor",type:"color"},{name:"askLaterBtnBorderRadius",type:"string"}],o="#333",i=/[;{}]/;let s=null;function r(t,n){switch(t){case"size":{const t=Number(n??0);return Number.isFinite(t)?`${t}px`:null}case"number":{const t=parseFloat(String(n));return Number.isFinite(t)?String(t):null}case"color":{const t=String(n);return function(t){return i.test(t)?o:(s||(s=document.createElement("div")),s.style.color="",s.style.color=t,s.style.color?t:o)}(t)===t?t:null}default:return String(n).trim()||null}}class a{constructor(t){this.pw=t;const{mobileViewMargin:n=""}=t.initParams.subscribePopup||{};this.config={...p,...t.initParams.subscribePopup},this.hasMobileViewMargin=Boolean(n),this.onAskLaterClick=this.onAskLaterClick.bind(this),this.onSubscribeClick=this.onSubscribeClick.bind(this)}async run(){const t=this.pw.isPushAvailable()?this.pw.driver:null;if(!t)return;const{manualToggle:n}=this.config,[p,e]=await Promise.all([this.pw.isSubscribed(),this.pw.data.getStatusManualUnsubscribed()]);if(p||!n&&e)return;const o=t.getPermission();if("granted"===o||"denied"===o)return;if(this.renderPopup(),this.appendStyles(),this.pw.moduleRegistry.subscribePopup=this,this.pw.dispatchEvent("subscribe-popup-ready",{}),n)return;const i=localStorage.getItem("LAST_OPEN_SUBSCRIPTION_POPUP"),s=i?parseInt(i):0,r=(new Date).getTime();s+1e3*this.config.retryOffset<r&&setTimeout(()=>{this.toggle(!0)},1e3*this.config.delay)}toggle(t){const n=void 0===t?!this.isShown:!!t;n!==this.isShown&&(n?this.show():this.hide())}async show(){if(await this.pw.isSubscribed())return;this.isShown=!0,this.popup.classList.add("pw-show"),document.body.classList.add("pw-popup-opened");const t=new CustomEvent("showPopup",{bubbles:!1,cancelable:!1,detail:{popup:this.popup}});this.popup.dispatchEvent(t);if(Math.max(document.documentElement.clientWidth,window.innerWidth||0)<541)return;const{theme:n,viewport:p,position:e}=this.config;if("topbar"===n&&"top"===e){const t=document.querySelector(p)||document.createElement("div"),n=window.getComputedStyle(t).marginTop||"0";t.style.transition="margin-top .3s ease-out",t.style.marginTop=`${parseInt(n)+this.popup.getBoundingClientRect().height}px`}this.pw.dispatchEvent("subscribe-popup-show",{})}hide(){this.isShown=!1,this.popup.classList.remove("pw-show"),document.body.classList.remove("pw-popup-opened");const t=new CustomEvent("hidePopup",{bubbles:!1,cancelable:!1,detail:{popup:this.popup}});this.popup.dispatchEvent(t);const n=(new Date).getTime().toString();localStorage.setItem("LAST_OPEN_SUBSCRIPTION_POPUP",n);if(Math.max(document.documentElement.clientWidth,window.innerWidth||0)<541)return;const{theme:p,viewport:e,position:o}=this.config;if("topbar"===p&&"top"===o){const t=document.querySelector(e)||document.createElement("div"),n=window.getComputedStyle(t).marginTop||"0";t.style.marginTop=parseInt(n)-this.popup.getBoundingClientRect().height+"px"}this.pw.dispatchEvent("subscribe-popup-hide",{})}renderPopup(){this.popup=document.createElement("div"),this.popup.id="pwSubscribePopup";const{text:t,askLaterButtonText:n,confirmSubscriptionButtonText:p,iconUrl:e,iconAlt:o,position:i,overlay:s,theme:r}=this.config;this.popup.className=`pw-subscribe-popup pw-position-${i} pw-subscribe-popup-${r}`,this.popup.classList.toggle("pw-subscribe-popup__overlay",s),this.popup.classList.toggle("pw-mobile-view-margin",this.hasMobileViewMargin),this.popup.innerHTML=(({iconUrl:t,iconAlt:n,text:p,askLaterButtonText:e,confirmSubscriptionButtonText:o})=>`<div class="pw-subscription-popup-inner">\n <div class="pw-subscription-popup-content">\n ${t?`<div class="pw-subscription-popup-icon"><img src="${t}" alt="${n||"Subscribe"}"></div>`:""}\n <div class="pw-subscription-popup-text">\n ${p}\n </div>\n </div>\n <div class="pw-subscription-popup-controls">\n <button name="pwAskLater" class="pw-subscribe-popup-button">${e}</button>\n <button name="pwSubscribe" class="pw-subscribe-popup-button pw-subscribe-popup-button-active">${o}</button>\n </div>\n </div>`)({text:t,askLaterButtonText:n,confirmSubscriptionButtonText:p,iconUrl:e,iconAlt:o}),this.applyStyleVariables(),document.body.appendChild(this.popup),this.addListeners()}appendStyles(){const t=document.createElement("style");t.innerHTML=".pw-subscribe-popup {\n position: fixed;\n left: 50%;\n transform: translateX(-50%);\n justify-content: center;\n z-index: 1000000;\n display: flex;\n transition: all .4s ease-out;\n}\n\n.pw-subscribe-popup.pw-position-top {\n top: calc(-100% - 24px);\n}\n.pw-subscribe-popup.pw-position-top.pw-show {\n top: 0;\n}\n\n.pw-subscribe-popup.pw-position-bottom {\n bottom: calc(-100% - 24px);\n}\n.pw-subscribe-popup.pw-position-bottom.pw-show {\n bottom: 0;\n}\n\n.pw-subscribe-popup.pw-position-center {\n display: flex;\n\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n height: 100vh;\n justify-content: center;\n align-items: center;\n\n transform: none;\n}\n\n.pw-subscribe-popup__overlay {\n background: rgba(0,0,0,.4);\n z-index: 1000000;\n}\n\n.pw-subscribe-popup.pw-position-center:not(.pw-subscribe-popup__overlay) {\n pointer-events: none;\n}\n\n.pw-subscribe-popup.pw-position-center:not(.pw-show) {\n display: none;\n}\n\n\n.pw-subscribe-popup__overlay.pw-position-top {\n align-items: flex-start;\n}\n\n.pw-subscribe-popup__overlay.pw-position-bottom {\n align-items: flex-end;\n}\n\n.pw-subscribe-popup__overlay.pw-position-center {\n align-items: center;\n}\n\n.pw-subscription-popup-inner {\n max-width: 400px;\n font-size: var(--pw-popup-textSize, inherit);\n color: var(--pw-popup-textColor, #000);\n font-weight: var(--pw-popup-textWeight, normal);\n font-family: var(--pw-popup-fontFamily, inherit);\n border-style: solid;\n border-width: 1px;\n border-color: var(--pw-popup-borderColor, transparent);\n background: var(--pw-popup-bgColor, #fff);\n box-shadow: var(--pw-popup-boxShadow, 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23));\n pointer-events: auto;\n}\n\n.pw-subscription-popup-content {\n padding: 16px 16px 4px;\n display: flex;\n justify-content: stretch;\n}\n\n.pw-subscription-popup-icon {\n flex: 0 0 50px;\n margin-right: 12px;\n padding-top: 4px;\n}\n\n.pw-subscription-popup-icon img {\n max-width: 60px;\n max-height: 60px;\n}\n\n.pw-subscription-popup-text {\n flex: 1 1 300px;\n}\n\n.pw-subscription-popup-controls {\n display: flex;\n flex-wrap: nowrap;\n justify-content: center;\n padding: 8px 16px 16px;\n}\n\nbutton.pw-subscribe-popup-button {\n border: solid 1px var(--pw-popup-askLaterBtnBorderColor, transparent);\n border-radius: var(--pw-popup-askLaterBtnBorderRadius, 2px);\n display: inline-block;\n height: 36px;\n line-height: 36px;\n padding: 0 16px;\n text-transform: uppercase;\n font-weight: var(--pw-popup-askLaterBtnTextWeight, normal);\n vertical-align: middle;\n -webkit-tap-highlight-color: transparent;\n font-size: 14px;\n outline: 0;\n text-decoration: none;\n color: var(--pw-popup-askLaterBtnTextColor, #000);\n text-align: center;\n letter-spacing: .5px;\n cursor: pointer;\n background: var(--pw-popup-askLaterBtnBgColor, transparent);\n margin: 4px 8px;\n}\nbutton.pw-subscribe-popup-button:hover {\n background: rgba(0,0,0,.04);\n}\nbutton.pw-subscribe-popup-button:active {\n background: rgba(0,0,0,.12);\n}\n\nbutton.pw-subscribe-popup-button.pw-subscribe-popup-button-active {\n color: var(--pw-popup-subscribeBtnTextColor, #fff);\n background: var(--pw-popup-subscribeBtnBgColor, #4285f4);\n border-radius: var(--pw-popup-subscribeBtnBorderRadius, 2px);\n border: solid 1px var(--pw-popup-subscribeBtnBorderColor, transparent);\n box-shadow: 0 2px 2px 0 rgba(0,0,0,0.14),\n 0 3px 1px -2px rgba(0,0,0,0.12),\n 0 1px 5px 0 rgba(0,0,0,0.2);\n font-weight: var(--pw-popup-subscribeBtnTextWeight, normal);\n}\nbutton.pw-subscribe-popup-button.pw-subscribe-popup-button-active:hover {\n box-shadow: 0 3px 3px 0 rgba(0,0,0,0.14),\n 0 1px 7px 0 rgba(0,0,0,0.12),\n 0 3px 1px -1px rgba(0,0,0,0.2);\n}\nbutton.pw-subscribe-popup-button.pw-subscribe-popup-button-active:active {\n box-shadow: 0 2px 2px 0 rgba(0,0,0,0.14),\n 0 3px 1px -2px rgba(0,0,0,0.12),\n 0 1px 5px 0 rgba(0,0,0,0.2);\n}\n\n@media screen and (min-width: 541px) {\n\n .pw-subscribe-popup-topbar {\n width: 100%;\n }\n\n .pw-subscribe-popup-topbar .pw-subscription-popup-inner {\n max-width: 100%;\n width: 100%;\n display: flex;\n flex-direction: row;\n padding: 2px 40px;\n justify-content: center;\n align-items: center;\n flex-wrap: nowrap;\n }\n\n .pw-subscribe-popup-topbar .pw-subscription-popup-content {\n padding: 0;\n justify-content: flex-start;\n align-items: center;\n }\n\n .pw-subscribe-popup-topbar .pw-subscription-popup-icon img {\n max-width: 28px;\n max-height: 28px;\n }\n\n .pw-subscribe-popup-topbar button.pw-subscribe-popup-button {\n height: 32px;\n line-height: 32px;\n }\n\n .pw-subscribe-popup-topbar .pw-subscription-popup-controls {\n padding: 0 0 0 16px;\n align-items: center;\n }\n}\n@media screen and (max-width: 540px) {\n .pw-subscribe-popup,\n .pw-subscribe-popup.pw-position-top,\n .pw-subscribe-popup.pw-position-center,\n .pw-subscribe-popup.pw-position-bottom {\n top: auto;\n bottom: -110%;\n left: 0;\n right: 0;\n transform: none;\n display: flex;\n transition: bottom .4s ease-out;\n align-items: flex-end;\n }\n\n .pw-subscribe-popup.pw-mobile-view-margin {\n top: auto !important;\n transition: none;\n }\n\n .pw-subscribe-popup.pw-subscribe-popup__overlay {\n align-items: flex-end;\n }\n\n .pw-subscribe-popup.pw-show {\n bottom: var(--pw-popup-mobileViewMargin, 0);\n }\n\n .pw-subscribe-popup__overlay .pw-subscription-popup-inner {\n align-items: flex-end;\n justify-content: stretch;\n }\n\n .pw-subscription-popup-inner {\n max-width: 100%;\n width: 100%;\n }\n}\n".toString(),document.body.appendChild(t)}applyStyleVariables(){var t,n,p,o;t=this.popup,n="pw-popup",p=e,o=this.config,p.forEach(({name:p,type:e})=>{const i=r(e,o[p]);null!==i&&t.style.setProperty(function(t,n){return`--${t}-${n}`}(n,p),i)})}addListeners(){const t=this.popup.querySelector('button[name="pwAskLater"]')||document.createElement("button"),n=this.popup.querySelector('button[name="pwSubscribe"]')||document.createElement("button");t.addEventListener("click",this.onAskLaterClick),n.addEventListener("click",this.onSubscribeClick)}onAskLaterClick(){this.toggle(!1),this.pw.dispatchEvent("subscribe-popup-decline",{})}onSubscribeClick(){this.toggle(!1),this.pw.dispatchEvent("subscribe-popup-accept",{}),this.pw.subscribe()}}return n})());
2
2
  //# sourceMappingURL=widget-subscribe-popup.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"widget-subscribe-popup.js","mappings":"CAAA,SAAAA,EAAAC,GACA,oBAAAC,SAAA,iBAAAC,OACAA,OAAAD,QAAAD,SACA,sBAAAG,QAAAA,OAAAC,IACAD,OAAA,GAAAH,OACA,CACA,IAAAK,EAAAL,IACA,QAAAM,KAAAD,GAAA,iBAAAJ,QAAAA,QAAAF,GAAAO,GAAAD,EAAAC,EACA,CACC,CATD,CASCC,KAAA,uBCRD,MAAAC,EAAA,CCAAA,EAAA,CAAAP,EAAAQ,KACA,QAAAC,KAAAD,EACAD,EAAAG,EAAAF,EAAAC,KAAAF,EAAAG,EAAAV,EAAAS,IACAE,OAAAC,eAAAZ,EAAAS,EAAA,CAAyCI,YAAA,EAAAC,IAAAN,EAAAC,MCJzCF,EAAA,CAAAQ,EAAAC,IAAAL,OAAAM,UAAAC,eAAAC,KAAAJ,EAAAC,GCCAT,EAAAP,IACAW,OAAAC,eAAAZ,EAAAoB,OAAAC,YAAA,CAAsDC,MAAA,WACtDX,OAAAC,eAAAZ,EAAA,cAAgDsB,OAAA,4DCDzC,MAAMC,EAAwC,CACnDC,QAAQ,EACRC,KAAM,oEACNC,mBAAoB,UACpBC,8BAA+B,YAC/BC,MAAO,EACPC,YAAa,OACbC,SAAS,EACTC,SAAU,MACVC,iBAAkB,IAElBC,QAAS,OACTC,YAAa,cACbC,UAAW,yDAEXC,UAAW,OACXC,SAAU,UACVC,WAAY,SACZC,WAAY,UAEZC,oBAAqB,UACrBC,sBAAuB,OACvBC,uBAAwB,SACxBC,wBAAyB,cACzBC,yBAA0B,MAE1BC,mBAAoB,cACpBC,qBAAsB,OACtBC,sBAAuB,SACvBC,uBAAwB,cACxBC,wBAAyB,M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AMC,WACzB,MAAMmG,EAAY/F,EAAoBJ,EAAMiG,EAAOlG,IAEjC,OAAdoG,GACFL,EAAQ/E,MAAMqF,YArCb,SAA4BL,EAAgBhG,GACjD,MAAO,KAAKgG,KAAUhG,GACxB,CAmCgCsG,CAAmBN,EAAQhG,GAAOoG,IC2JhE,CAEA,YAAAN,GACE,MAAMS,EAAiBtJ,KAAK2G,MAAMgB,cAAc,8BAC3C9D,SAASC,cAAc,UACtByF,EAAkBvJ,KAAK2G,MAAMgB,cAAc,+BAC5C9D,SAASC,cAAc,UAE5BwF,EAAeE,iBAAiB,QAASxJ,KAAK0E,iBAC9C6E,EAAgBC,iBAAiB,QAASxJ,KAAK4E,iBACjD,CAEA,eAAAF,GACE1E,KAAKsG,QAAO,GACZtG,KAAKoE,GAAGwB,cAAc,0BAA2B,GACnD,CAEA,gBAAAhB,GACE5E,KAAKsG,QAAO,GACZtG,KAAKoE,GAAGwB,cAAc,yBAA0B,IAChD5F,KAAKoE,GAAGqF,WACV","sources":["webpack://web-push-notifications/webpack/universalModuleDefinition","webpack://web-push-notifications/webpack/bootstrap","webpack://web-push-notifications/webpack/runtime/define property getters","webpack://web-push-notifications/webpack/runtime/hasOwnProperty shorthand","webpack://web-push-notifications/webpack/runtime/make namespace object","webpack://web-push-notifications/./src/widgets/SubscribePopup/constants.ts","webpack://web-push-notifications/./src/helpers/cssColor.ts","webpack://web-push-notifications/./src/helpers/cssVariables.ts","webpack://web-push-notifications/./src/widgets/SubscribePopup/SubscribePopup.ts","webpack://web-push-notifications/./src/widgets/SubscribePopup/popupTemplates.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse {\n\t\tvar a = factory();\n\t\tfor(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];\n\t}\n})(this, () => {\nreturn ","// The require scope\nconst __webpack_require__ = {};\n\n","// define getter/value functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop));","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { type ISubscribePopupConfig, type ISubscribePopupConfigStyles } from './types/subscribe-popup';\n\nexport const DEFAULT_CONFIG: ISubscribePopupConfig = {\n enable: true,\n text: 'Don’t miss out on our news and updates! Enable push notifications',\n askLaterButtonText: 'Not now',\n confirmSubscriptionButtonText: 'Subscribe',\n delay: 5,\n retryOffset: 60 * 60 * 24 * 7,\n overlay: false,\n position: 'top',\n mobileViewMargin: '0',\n\n bgColor: '#fff',\n borderColor: 'transparent',\n boxShadow: '0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23)',\n\n textColor: '#000',\n textSize: 'inherit',\n textWeight: 'normal',\n fontFamily: 'inherit',\n\n subscribeBtnBgColor: '#4285f4',\n subscribeBtnTextColor: '#fff',\n subscribeBtnTextWeight: 'normal',\n subscribeBtnBorderColor: 'transparent',\n subscribeBtnBorderRadius: '2px',\n\n askLaterBtnBgColor: 'transparent',\n askLaterBtnTextColor: '#000',\n askLaterBtnTextWeight: 'normal',\n askLaterBtnBorderColor: 'transparent',\n askLaterBtnBorderRadius: '2px',\n\n theme: 'material',\n viewport: 'html',\n};\n\n// Permissions\nexport const PERMISSION_DENIED = 'denied';\nexport const PERMISSION_GRANTED = 'granted';\n\nexport const STYLE_PREFIX = 'pw-popup';\n\nexport const CONFIG_STYLES: Array<ISubscribePopupConfigStyles> = [\n { name: 'mobileViewMargin', type: 'string' },\n { name: 'bgColor', type: 'color' },\n { name: 'borderColor', type: 'color' },\n { name: 'boxShadow', type: 'string' },\n { name: 'textColor', type: 'color' },\n { name: 'textSize', type: 'string' },\n { name: 'textWeight', type: 'string' },\n { name: 'fontFamily', type: 'string' },\n { name: 'subscribeBtnBgColor', type: 'color' },\n { name: 'subscribeBtnTextColor', type: 'color' },\n { name: 'subscribeBtnTextWeight', type: 'string' },\n { name: 'subscribeBtnBorderColor', type: 'color' },\n { name: 'subscribeBtnBorderRadius', type: 'string' },\n { name: 'askLaterBtnBgColor', type: 'color' },\n { name: 'askLaterBtnTextColor', type: 'color' },\n { name: 'askLaterBtnTextWeight', type: 'string' },\n { name: 'askLaterBtnBorderColor', type: 'color' },\n { name: 'askLaterBtnBorderRadius', type: 'string' },\n];\n","/** Drawn when the configured colour is one the browser would refuse. */\nexport const FALLBACK_COLOR = '#333';\n\n// A colour value never needs these, and they are exactly what would end the\n// declaration or the rule it is interpolated into.\nconst RULE_BREAKERS = /[;{}]/;\n\n// One element, reused: the widgets validate every colour of their config on\n// each render.\nlet probe: HTMLElement | null = null;\n\n/** Keeps a colour the browser accepts, and replaces anything else with {@link FALLBACK_COLOR}. */\nexport function getValidColor(color: string): string {\n if (RULE_BREAKERS.test(color)) {\n return FALLBACK_COLOR;\n }\n\n if (!probe) {\n probe = document.createElement('div');\n }\n\n probe.style.color = '';\n probe.style.color = color;\n\n return probe.style.color ? color : FALLBACK_COLOR;\n}\n","import { getValidColor } from './cssColor';\n\nexport type TStyleVariableType = 'number' | 'color' | 'string' | 'size';\n\nexport interface IStyleVariable<TName extends string = string> {\n name: TName;\n type: TStyleVariableType;\n}\n\nexport function getCssVariableName(prefix: string, name: string): string {\n return `--${prefix}-${name}`;\n}\n\n// `null` means \"leave it unset\": a custom property holding garbage makes every\n// rule that reads it invalid, while an absent one falls back to the stylesheet.\nexport function formatStyleVariable(type: TStyleVariableType, value: string | number | undefined): string | null {\n switch (type) {\n case 'size': {\n const size = Number(value ?? 0);\n return Number.isFinite(size) ? `${size}px` : null;\n }\n case 'number': {\n const parsed = parseFloat(String(value));\n return Number.isFinite(parsed) ? String(parsed) : null;\n }\n case 'color': {\n const color = String(value);\n return getValidColor(color) === color ? color : null;\n }\n default: {\n const text = String(value).trim();\n return text || null;\n }\n }\n}\n\nexport function applyStyleVariables<TName extends string>(\n element: HTMLElement,\n prefix: string,\n variables: Array<IStyleVariable<TName>>,\n values: Record<TName, string | number>,\n): void {\n variables.forEach(({ name, type }) => {\n const formatted = formatStyleVariable(type, values[name]);\n\n if (formatted !== null) {\n element.style.setProperty(getCssVariableName(prefix, name), formatted);\n }\n });\n}\n","import {\n DEFAULT_CONFIG,\n CONFIG_STYLES,\n STYLE_PREFIX,\n\n PERMISSION_DENIED,\n PERMISSION_GRANTED,\n} from './constants';\nimport { innerTemplate } from './popupTemplates';\nimport popupCss from './styles/popup.css';\nimport { type ISubscribePopupConfig } from './types/subscribe-popup';\nimport { type Pushwoosh } from '../../core/Pushwoosh';\nimport { applyStyleVariables } from '../../helpers/cssVariables';\n\nexport class PWSubscribePopupWidget {\n pw: Pushwoosh;\n config: ISubscribePopupConfig;\n popup: HTMLElement;\n isShown: boolean;\n private hasMobileViewMargin: boolean;\n\n constructor(pw: Pushwoosh) {\n this.pw = pw;\n\n const { mobileViewMargin = '' } = pw.initParams.subscribePopup || ({} as ISubscribePopupConfig);\n\n this.config = {\n ...DEFAULT_CONFIG,\n ...pw.initParams.subscribePopup,\n };\n\n this.hasMobileViewMargin = Boolean(mobileViewMargin);\n\n this.onAskLaterClick = this.onAskLaterClick.bind(this);\n this.onSubscribeClick = this.onSubscribeClick.bind(this);\n }\n\n async run() {\n // Nothing to ask for when push is unavailable; also narrows `driver`.\n const driver = this.pw.isPushAvailable() ? this.pw.driver : null;\n\n if (!driver) {\n return;\n }\n\n const { manualToggle } = this.config;\n const [isSubscribed, isManualUnsubscribed] = await Promise.all([\n this.pw.isSubscribed(),\n this.pw.data.getStatusManualUnsubscribed(),\n ]);\n if (isSubscribed || (!manualToggle && isManualUnsubscribed)) {\n return;\n }\n\n const permission = driver.getPermission();\n if (permission === PERMISSION_GRANTED || permission === PERMISSION_DENIED) {\n return;\n }\n\n this.renderPopup();\n this.appendStyles();\n\n this.pw.moduleRegistry.subscribePopup = this;\n this.pw.dispatchEvent('subscribe-popup-ready', {});\n\n if (manualToggle) {\n return;\n }\n\n const lastPopupOpen = localStorage.getItem('LAST_OPEN_SUBSCRIPTION_POPUP');\n const lastPopupOpenTime = lastPopupOpen ? parseInt(lastPopupOpen) : 0;\n const now = new Date().getTime();\n\n if (lastPopupOpenTime + (this.config.retryOffset * 1000) < now) {\n setTimeout(() => {\n this.toggle(true);\n }, this.config.delay * 1000);\n }\n }\n\n toggle(isShown?: boolean) {\n const isPopupShown = typeof isShown === 'undefined' ? !this.isShown : !!isShown;\n if (isPopupShown !== this.isShown) {\n if (isPopupShown) {\n this.show();\n } else {\n this.hide();\n }\n }\n }\n\n async show() {\n if (await this.pw.isSubscribed()) {\n return;\n }\n this.isShown = true;\n this.popup.classList.add('pw-show');\n document.body.classList.add('pw-popup-opened');\n\n const event = new CustomEvent('showPopup', {\n bubbles: false,\n cancelable: false,\n detail: {\n popup: this.popup,\n },\n });\n this.popup.dispatchEvent(event);\n\n const screenWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);\n if (screenWidth < 541) {\n // mobile screen doesn't support themes\n return;\n }\n const {\n theme,\n viewport,\n position,\n } = this.config;\n if (theme === 'topbar' && position === 'top') {\n const viewportElement: HTMLElement = document.querySelector(viewport) || document.createElement('div');\n const currentMarginTop = window.getComputedStyle(viewportElement).marginTop || '0';\n viewportElement.style.transition = 'margin-top .3s ease-out';\n viewportElement.style.marginTop = `${parseInt(currentMarginTop) + this.popup.getBoundingClientRect().height}px`;\n }\n\n this.pw.dispatchEvent('subscribe-popup-show', {});\n }\n\n hide() {\n this.isShown = false;\n this.popup.classList.remove('pw-show');\n document.body.classList.remove('pw-popup-opened');\n\n const event = new CustomEvent('hidePopup', {\n bubbles: false,\n cancelable: false,\n detail: {\n popup: this.popup,\n },\n });\n this.popup.dispatchEvent(event);\n\n const now = new Date().getTime().toString();\n\n localStorage.setItem('LAST_OPEN_SUBSCRIPTION_POPUP', now);\n\n const screenWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);\n if (screenWidth < 541) {\n // mobile screen doesn't support themes\n return;\n }\n const {\n theme,\n viewport,\n position,\n } = this.config;\n if (theme === 'topbar' && position === 'top') {\n const viewportElement: HTMLElement = document.querySelector(viewport) || document.createElement('div');\n const currentMarginTop = window.getComputedStyle(viewportElement).marginTop || '0';\n viewportElement.style.marginTop = `${parseInt(currentMarginTop) - this.popup.getBoundingClientRect().height}px`;\n }\n\n this.pw.dispatchEvent('subscribe-popup-hide', {});\n }\n\n renderPopup() {\n this.popup = document.createElement('div');\n this.popup.id = 'pwSubscribePopup';\n const {\n text,\n askLaterButtonText,\n confirmSubscriptionButtonText,\n iconUrl,\n iconAlt,\n position,\n overlay,\n theme,\n } = this.config;\n this.popup.className = `pw-subscribe-popup pw-position-${position} pw-subscribe-popup-${theme}`;\n this.popup.classList.toggle('pw-subscribe-popup__overlay', overlay);\n this.popup.classList.toggle('pw-mobile-view-margin', this.hasMobileViewMargin);\n this.popup.innerHTML = innerTemplate({\n text,\n askLaterButtonText,\n confirmSubscriptionButtonText,\n iconUrl,\n iconAlt,\n });\n this.applyStyleVariables();\n document.body.appendChild(this.popup);\n this.addListeners();\n }\n\n appendStyles() {\n const style = document.createElement('style');\n style.innerHTML = popupCss.toString();\n document.body.appendChild(style);\n }\n\n applyStyleVariables() {\n applyStyleVariables(this.popup, STYLE_PREFIX, CONFIG_STYLES, this.config);\n }\n\n addListeners() {\n const askLaterButton = this.popup.querySelector('button[name=\"pwAskLater\"]')\n || document.createElement('button');\n const subscribeButton = this.popup.querySelector('button[name=\"pwSubscribe\"]')\n || document.createElement('button');\n\n askLaterButton.addEventListener('click', this.onAskLaterClick);\n subscribeButton.addEventListener('click', this.onSubscribeClick);\n }\n\n onAskLaterClick() {\n this.toggle(false);\n this.pw.dispatchEvent('subscribe-popup-decline', {});\n }\n\n onSubscribeClick() {\n this.toggle(false);\n this.pw.dispatchEvent('subscribe-popup-accept', {});\n this.pw.subscribe();\n }\n}\n","interface IInnerTemplate {\n iconUrl?: string;\n iconAlt?: string;\n text: string;\n askLaterButtonText: string;\n confirmSubscriptionButtonText: string;\n}\n\nexport const innerTemplate = ({ iconUrl, iconAlt, text, askLaterButtonText, confirmSubscriptionButtonText }: IInnerTemplate): string => {\n return `<div class=\"pw-subscription-popup-inner\">\n <div class=\"pw-subscription-popup-content\">\n ${iconUrl\n ? `<div class=\"pw-subscription-popup-icon\"><img src=\"${iconUrl}\" alt=\"${iconAlt || 'Subscribe'}\"></div>`\n : ''}\n <div class=\"pw-subscription-popup-text\">\n ${text}\n </div>\n </div>\n <div class=\"pw-subscription-popup-controls\">\n <button name=\"pwAskLater\" class=\"pw-subscribe-popup-button\">${askLaterButtonText}</button>\n <button name=\"pwSubscribe\" class=\"pw-subscribe-popup-button pw-subscribe-popup-button-active\">${confirmSubscriptionButtonText}</button>\n </div>\n </div>`;\n};\n"],"names":["root","factory","exports","module","define","amd","a","i","this","__webpack_require__","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","DEFAULT_CONFIG","enable","text","askLaterButtonText","confirmSubscriptionButtonText","delay","retryOffset","overlay","position","mobileViewMargin","bgColor","borderColor","boxShadow","textColor","textSize","textWeight","fontFamily","subscribeBtnBgColor","subscribeBtnTextColor","subscribeBtnTextWeight","subscribeBtnBorderColor","subscribeBtnBorderRadius","askLaterBtnBgColor","askLaterBtnTextColor","askLaterBtnTextWeight","askLaterBtnBorderColor","askLaterBtnBorderRadius","theme","viewport","CONFIG_STYLES","name","type","FALLBACK_COLOR","RULE_BREAKERS","probe","formatStyleVariable","size","Number","isFinite","parsed","parseFloat","String","color","test","document","createElement","style","getValidColor","trim","PWSubscribePopupWidget","constructor","pw","initParams","subscribePopup","config","hasMobileViewMargin","Boolean","onAskLaterClick","bind","onSubscribeClick","run","driver","isPushAvailable","manualToggle","isSubscribed","isManualUnsubscribed","Promise","all","data","getStatusManualUnsubscribed","permission","getPermission","renderPopup","appendStyles","moduleRegistry","dispatchEvent","lastPopupOpen","localStorage","getItem","lastPopupOpenTime","parseInt","now","Date","getTime","setTimeout","toggle","isShown","isPopupShown","show","hide","popup","classList","add","body","event","CustomEvent","bubbles","cancelable","detail","Math","max","documentElement","clientWidth","window","innerWidth","viewportElement","querySelector","currentMarginTop","getComputedStyle","marginTop","transition","getBoundingClientRect","height","remove","toString","setItem","id","iconUrl","iconAlt","className","innerHTML","innerTemplate","applyStyleVariables","appendChild","addListeners","element","prefix","variables","values","forEach","formatted","setProperty","getCssVariableName","askLaterButton","subscribeButton","addEventListener","subscribe"],"sourceRoot":""}
1
+ {"version":3,"file":"widget-subscribe-popup.js","mappings":"CAAA,SAAAA,EAAAC,GACA,oBAAAC,SAAA,iBAAAC,OACAA,OAAAD,QAAAD,SACA,sBAAAG,QAAAA,OAAAC,IACAD,OAAA,GAAAH,OACA,CACA,IAAAK,EAAAL,IACA,QAAAM,KAAAD,GAAA,iBAAAJ,QAAAA,QAAAF,GAAAO,GAAAD,EAAAC,EACA,CACC,CATD,CASCC,KAAA,uBCRD,MAAAC,EAAA,CCAAA,EAAA,CAAAP,EAAAQ,KACA,QAAAC,KAAAD,EACAD,EAAAG,EAAAF,EAAAC,KAAAF,EAAAG,EAAAV,EAAAS,IACAE,OAAAC,eAAAZ,EAAAS,EAAA,CAAyCI,YAAA,EAAAC,IAAAN,EAAAC,MCJzCF,EAAA,CAAAQ,EAAAC,IAAAL,OAAAM,UAAAC,eAAAC,KAAAJ,EAAAC,GCCAT,EAAAP,IACAW,OAAAS,iBAAApB,EAAA,CAAoC,CAAAqB,OAAAC,aAAA,CAAwBC,MAAA,UAAiBC,WAAA,CAAgBD,OAAA,6DCAtF,MAAME,EAAwC,CACnDC,QAAQ,EACRC,KA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ASiD,KAAK8B,YAAY9I,KAAK6G,OAC/B7G,KAAK+I,cACP,CAEA,YAAAnD,GACE,MAAM3B,EAAQF,SAASC,cAAc,SACrCC,EAAM0E,okLAAqBN,WAC3BtE,SAASiD,KAAK8B,YAAY7E,EAC5B,CAEA,mBAAA4E,GDnKK,IACLG,EACAC,EACAC,EACAC,EAHAH,ECmKsBhJ,KAAK6G,MDlK3BoC,EFI0B,WEH1BC,ECiKgDlG,EDhKhDmG,ECgK+DnJ,KAAKyE,OD9JpEyE,EAAUE,QAAQ,EAAGnG,OAAMC,WACzB,MAAMmG,EAAY/F,EAAoBJ,EAAMiG,EAAOlG,IAEjC,OAAdoG,GACFL,EAAQ/E,MAAMqF,YArCb,SAA4BL,EAAgBhG,GACjD,MAAO,KAAKgG,KAAUhG,GACxB,CAmCgCsG,CAAmBN,EAAQhG,GAAOoG,IC2JhE,CAEA,YAAAN,GACE,MAAMS,EAAiBxJ,KAAK6G,MAAMgB,cAAc,8BAC3C9D,SAASC,cAAc,UACtByF,EAAkBzJ,KAAK6G,MAAMgB,cAAc,+BAC5C9D,SAASC,cAAc,UAE5BwF,EAAeE,iBAAiB,QAAS1J,KAAK4E,iBAC9C6E,EAAgBC,iBAAiB,QAAS1J,KAAK8E,iBACjD,CAEA,eAAAF,GACE5E,KAAKwG,QAAO,GACZxG,KAAKsE,GAAGwB,cAAc,0BAA2B,GACnD,CAEA,gBAAAhB,GACE9E,KAAKwG,QAAO,GACZxG,KAAKsE,GAAGwB,cAAc,yBAA0B,IAChD9F,KAAKsE,GAAGqF,WACV","sources":["webpack://web-push-notifications/webpack/universalModuleDefinition","webpack://web-push-notifications/webpack/bootstrap","webpack://web-push-notifications/webpack/runtime/define property getters","webpack://web-push-notifications/webpack/runtime/hasOwnProperty shorthand","webpack://web-push-notifications/webpack/runtime/make namespace object","webpack://web-push-notifications/./src/widgets/SubscribePopup/constants.ts","webpack://web-push-notifications/./src/helpers/cssColor.ts","webpack://web-push-notifications/./src/helpers/cssVariables.ts","webpack://web-push-notifications/./src/widgets/SubscribePopup/SubscribePopup.ts","webpack://web-push-notifications/./src/widgets/SubscribePopup/popupTemplates.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse {\n\t\tvar a = factory();\n\t\tfor(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];\n\t}\n})(this, () => {\nreturn ","// The require scope\nconst __webpack_require__ = {};\n\n","// define getter/value functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop));","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tObject.defineProperties(exports, { [Symbol.toStringTag]: { value: 'Module' }, __esModule: { value: true } });\n};","import { type ISubscribePopupConfig, type ISubscribePopupConfigStyles } from './types/subscribe-popup';\n\nexport const DEFAULT_CONFIG: ISubscribePopupConfig = {\n enable: true,\n text: 'Don’t miss out on our news and updates! Enable push notifications',\n askLaterButtonText: 'Not now',\n confirmSubscriptionButtonText: 'Subscribe',\n delay: 5,\n retryOffset: 60 * 60 * 24 * 7,\n overlay: false,\n position: 'top',\n mobileViewMargin: '0',\n\n bgColor: '#fff',\n borderColor: 'transparent',\n boxShadow: '0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23)',\n\n textColor: '#000',\n textSize: 'inherit',\n textWeight: 'normal',\n fontFamily: 'inherit',\n\n subscribeBtnBgColor: '#4285f4',\n subscribeBtnTextColor: '#fff',\n subscribeBtnTextWeight: 'normal',\n subscribeBtnBorderColor: 'transparent',\n subscribeBtnBorderRadius: '2px',\n\n askLaterBtnBgColor: 'transparent',\n askLaterBtnTextColor: '#000',\n askLaterBtnTextWeight: 'normal',\n askLaterBtnBorderColor: 'transparent',\n askLaterBtnBorderRadius: '2px',\n\n theme: 'material',\n viewport: 'html',\n};\n\n// Permissions\nexport const PERMISSION_DENIED = 'denied';\nexport const PERMISSION_GRANTED = 'granted';\n\nexport const STYLE_PREFIX = 'pw-popup';\n\nexport const CONFIG_STYLES: Array<ISubscribePopupConfigStyles> = [\n { name: 'mobileViewMargin', type: 'string' },\n { name: 'bgColor', type: 'color' },\n { name: 'borderColor', type: 'color' },\n { name: 'boxShadow', type: 'string' },\n { name: 'textColor', type: 'color' },\n { name: 'textSize', type: 'string' },\n { name: 'textWeight', type: 'string' },\n { name: 'fontFamily', type: 'string' },\n { name: 'subscribeBtnBgColor', type: 'color' },\n { name: 'subscribeBtnTextColor', type: 'color' },\n { name: 'subscribeBtnTextWeight', type: 'string' },\n { name: 'subscribeBtnBorderColor', type: 'color' },\n { name: 'subscribeBtnBorderRadius', type: 'string' },\n { name: 'askLaterBtnBgColor', type: 'color' },\n { name: 'askLaterBtnTextColor', type: 'color' },\n { name: 'askLaterBtnTextWeight', type: 'string' },\n { name: 'askLaterBtnBorderColor', type: 'color' },\n { name: 'askLaterBtnBorderRadius', type: 'string' },\n];\n","/** Drawn when the configured colour is one the browser would refuse. */\nexport const FALLBACK_COLOR = '#333';\n\n// A colour value never needs these, and they are exactly what would end the\n// declaration or the rule it is interpolated into.\nconst RULE_BREAKERS = /[;{}]/;\n\n// One element, reused: the widgets validate every colour of their config on\n// each render.\nlet probe: HTMLElement | null = null;\n\n/** Keeps a colour the browser accepts, and replaces anything else with {@link FALLBACK_COLOR}. */\nexport function getValidColor(color: string): string {\n if (RULE_BREAKERS.test(color)) {\n return FALLBACK_COLOR;\n }\n\n if (!probe) {\n probe = document.createElement('div');\n }\n\n probe.style.color = '';\n probe.style.color = color;\n\n return probe.style.color ? color : FALLBACK_COLOR;\n}\n","import { getValidColor } from './cssColor';\n\nexport type TStyleVariableType = 'number' | 'color' | 'string' | 'size';\n\nexport interface IStyleVariable<TName extends string = string> {\n name: TName;\n type: TStyleVariableType;\n}\n\nexport function getCssVariableName(prefix: string, name: string): string {\n return `--${prefix}-${name}`;\n}\n\n// `null` means \"leave it unset\": a custom property holding garbage makes every\n// rule that reads it invalid, while an absent one falls back to the stylesheet.\nexport function formatStyleVariable(type: TStyleVariableType, value: string | number | undefined): string | null {\n switch (type) {\n case 'size': {\n const size = Number(value ?? 0);\n return Number.isFinite(size) ? `${size}px` : null;\n }\n case 'number': {\n const parsed = parseFloat(String(value));\n return Number.isFinite(parsed) ? String(parsed) : null;\n }\n case 'color': {\n const color = String(value);\n return getValidColor(color) === color ? color : null;\n }\n default: {\n const text = String(value).trim();\n return text || null;\n }\n }\n}\n\nexport function applyStyleVariables<TName extends string>(\n element: HTMLElement,\n prefix: string,\n variables: Array<IStyleVariable<TName>>,\n values: Record<TName, string | number>,\n): void {\n variables.forEach(({ name, type }) => {\n const formatted = formatStyleVariable(type, values[name]);\n\n if (formatted !== null) {\n element.style.setProperty(getCssVariableName(prefix, name), formatted);\n }\n });\n}\n","import {\n DEFAULT_CONFIG,\n CONFIG_STYLES,\n STYLE_PREFIX,\n\n PERMISSION_DENIED,\n PERMISSION_GRANTED,\n} from './constants';\nimport { innerTemplate } from './popupTemplates';\nimport popupCss from './styles/popup.css';\nimport { type ISubscribePopupConfig } from './types/subscribe-popup';\nimport { type Pushwoosh } from '../../core/Pushwoosh';\nimport { applyStyleVariables } from '../../helpers/cssVariables';\n\nexport class PWSubscribePopupWidget {\n pw: Pushwoosh;\n config: ISubscribePopupConfig;\n popup: HTMLElement;\n isShown: boolean;\n private hasMobileViewMargin: boolean;\n\n constructor(pw: Pushwoosh) {\n this.pw = pw;\n\n const { mobileViewMargin = '' } = pw.initParams.subscribePopup || ({} as ISubscribePopupConfig);\n\n this.config = {\n ...DEFAULT_CONFIG,\n ...pw.initParams.subscribePopup,\n };\n\n this.hasMobileViewMargin = Boolean(mobileViewMargin);\n\n this.onAskLaterClick = this.onAskLaterClick.bind(this);\n this.onSubscribeClick = this.onSubscribeClick.bind(this);\n }\n\n async run() {\n // Nothing to ask for when push is unavailable; also narrows `driver`.\n const driver = this.pw.isPushAvailable() ? this.pw.driver : null;\n\n if (!driver) {\n return;\n }\n\n const { manualToggle } = this.config;\n const [isSubscribed, isManualUnsubscribed] = await Promise.all([\n this.pw.isSubscribed(),\n this.pw.data.getStatusManualUnsubscribed(),\n ]);\n if (isSubscribed || (!manualToggle && isManualUnsubscribed)) {\n return;\n }\n\n const permission = driver.getPermission();\n if (permission === PERMISSION_GRANTED || permission === PERMISSION_DENIED) {\n return;\n }\n\n this.renderPopup();\n this.appendStyles();\n\n this.pw.moduleRegistry.subscribePopup = this;\n this.pw.dispatchEvent('subscribe-popup-ready', {});\n\n if (manualToggle) {\n return;\n }\n\n const lastPopupOpen = localStorage.getItem('LAST_OPEN_SUBSCRIPTION_POPUP');\n const lastPopupOpenTime = lastPopupOpen ? parseInt(lastPopupOpen) : 0;\n const now = new Date().getTime();\n\n if (lastPopupOpenTime + (this.config.retryOffset * 1000) < now) {\n setTimeout(() => {\n this.toggle(true);\n }, this.config.delay * 1000);\n }\n }\n\n toggle(isShown?: boolean) {\n const isPopupShown = typeof isShown === 'undefined' ? !this.isShown : !!isShown;\n if (isPopupShown !== this.isShown) {\n if (isPopupShown) {\n this.show();\n } else {\n this.hide();\n }\n }\n }\n\n async show() {\n if (await this.pw.isSubscribed()) {\n return;\n }\n this.isShown = true;\n this.popup.classList.add('pw-show');\n document.body.classList.add('pw-popup-opened');\n\n const event = new CustomEvent('showPopup', {\n bubbles: false,\n cancelable: false,\n detail: {\n popup: this.popup,\n },\n });\n this.popup.dispatchEvent(event);\n\n const screenWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);\n if (screenWidth < 541) {\n // mobile screen doesn't support themes\n return;\n }\n const {\n theme,\n viewport,\n position,\n } = this.config;\n if (theme === 'topbar' && position === 'top') {\n const viewportElement: HTMLElement = document.querySelector(viewport) || document.createElement('div');\n const currentMarginTop = window.getComputedStyle(viewportElement).marginTop || '0';\n viewportElement.style.transition = 'margin-top .3s ease-out';\n viewportElement.style.marginTop = `${parseInt(currentMarginTop) + this.popup.getBoundingClientRect().height}px`;\n }\n\n this.pw.dispatchEvent('subscribe-popup-show', {});\n }\n\n hide() {\n this.isShown = false;\n this.popup.classList.remove('pw-show');\n document.body.classList.remove('pw-popup-opened');\n\n const event = new CustomEvent('hidePopup', {\n bubbles: false,\n cancelable: false,\n detail: {\n popup: this.popup,\n },\n });\n this.popup.dispatchEvent(event);\n\n const now = new Date().getTime().toString();\n\n localStorage.setItem('LAST_OPEN_SUBSCRIPTION_POPUP', now);\n\n const screenWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);\n if (screenWidth < 541) {\n // mobile screen doesn't support themes\n return;\n }\n const {\n theme,\n viewport,\n position,\n } = this.config;\n if (theme === 'topbar' && position === 'top') {\n const viewportElement: HTMLElement = document.querySelector(viewport) || document.createElement('div');\n const currentMarginTop = window.getComputedStyle(viewportElement).marginTop || '0';\n viewportElement.style.marginTop = `${parseInt(currentMarginTop) - this.popup.getBoundingClientRect().height}px`;\n }\n\n this.pw.dispatchEvent('subscribe-popup-hide', {});\n }\n\n renderPopup() {\n this.popup = document.createElement('div');\n this.popup.id = 'pwSubscribePopup';\n const {\n text,\n askLaterButtonText,\n confirmSubscriptionButtonText,\n iconUrl,\n iconAlt,\n position,\n overlay,\n theme,\n } = this.config;\n this.popup.className = `pw-subscribe-popup pw-position-${position} pw-subscribe-popup-${theme}`;\n this.popup.classList.toggle('pw-subscribe-popup__overlay', overlay);\n this.popup.classList.toggle('pw-mobile-view-margin', this.hasMobileViewMargin);\n this.popup.innerHTML = innerTemplate({\n text,\n askLaterButtonText,\n confirmSubscriptionButtonText,\n iconUrl,\n iconAlt,\n });\n this.applyStyleVariables();\n document.body.appendChild(this.popup);\n this.addListeners();\n }\n\n appendStyles() {\n const style = document.createElement('style');\n style.innerHTML = popupCss.toString();\n document.body.appendChild(style);\n }\n\n applyStyleVariables() {\n applyStyleVariables(this.popup, STYLE_PREFIX, CONFIG_STYLES, this.config);\n }\n\n addListeners() {\n const askLaterButton = this.popup.querySelector('button[name=\"pwAskLater\"]')\n || document.createElement('button');\n const subscribeButton = this.popup.querySelector('button[name=\"pwSubscribe\"]')\n || document.createElement('button');\n\n askLaterButton.addEventListener('click', this.onAskLaterClick);\n subscribeButton.addEventListener('click', this.onSubscribeClick);\n }\n\n onAskLaterClick() {\n this.toggle(false);\n this.pw.dispatchEvent('subscribe-popup-decline', {});\n }\n\n onSubscribeClick() {\n this.toggle(false);\n this.pw.dispatchEvent('subscribe-popup-accept', {});\n this.pw.subscribe();\n }\n}\n","interface IInnerTemplate {\n iconUrl?: string;\n iconAlt?: string;\n text: string;\n askLaterButtonText: string;\n confirmSubscriptionButtonText: string;\n}\n\nexport const innerTemplate = ({ iconUrl, iconAlt, text, askLaterButtonText, confirmSubscriptionButtonText }: IInnerTemplate): string => {\n return `<div class=\"pw-subscription-popup-inner\">\n <div class=\"pw-subscription-popup-content\">\n ${iconUrl\n ? `<div class=\"pw-subscription-popup-icon\"><img src=\"${iconUrl}\" alt=\"${iconAlt || 'Subscribe'}\"></div>`\n : ''}\n <div class=\"pw-subscription-popup-text\">\n ${text}\n </div>\n </div>\n <div class=\"pw-subscription-popup-controls\">\n <button name=\"pwAskLater\" class=\"pw-subscribe-popup-button\">${askLaterButtonText}</button>\n <button name=\"pwSubscribe\" class=\"pw-subscribe-popup-button pw-subscribe-popup-button-active\">${confirmSubscriptionButtonText}</button>\n </div>\n </div>`;\n};\n"],"names":["root","factory","exports","module","define","amd","a","i","this","__webpack_require__","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","defineProperties","Symbol","toStringTag","value","__esModule","DEFAULT_CONFIG","enable","text","askLaterButtonText","confirmSubscriptionButtonText","delay","retryOffset","overlay","position","mobileViewMargin","bgColor","borderColor","boxShadow","textColor","textSize","textWeight","fontFamily","subscribeBtnBgColor","subscribeBtnTextColor","subscribeBtnTextWeight","subscribeBtnBorderColor","subscribeBtnBorderRadius","askLaterBtnBgColor","askLaterBtnTextColor","askLaterBtnTextWeight","askLaterBtnBorderColor","askLaterBtnBorderRadius","theme","viewport","CONFIG_STYLES","name","type","FALLBACK_COLOR","RULE_BREAKERS","probe","formatStyleVariable","size","Number","isFinite","parsed","parseFloat","String","color","test","document","createElement","style","getValidColor","trim","PWSubscribePopupWidget","constructor","pw","initParams","subscribePopup","config","hasMobileViewMargin","Boolean","onAskLaterClick","bind","onSubscribeClick","run","driver","isPushAvailable","manualToggle","isSubscribed","isManualUnsubscribed","Promise","all","data","getStatusManualUnsubscribed","permission","getPermission","renderPopup","appendStyles","moduleRegistry","dispatchEvent","lastPopupOpen","localStorage","getItem","lastPopupOpenTime","parseInt","now","Date","getTime","setTimeout","toggle","isShown","isPopupShown","show","hide","popup","classList","add","body","event","CustomEvent","bubbles","cancelable","detail","Math","max","documentElement","clientWidth","window","innerWidth","viewportElement","querySelector","currentMarginTop","getComputedStyle","marginTop","transition","getBoundingClientRect","height","remove","toString","setItem","id","iconUrl","iconAlt","className","innerHTML","innerTemplate","applyStyleVariables","appendChild","addListeners","element","prefix","variables","values","forEach","formatted","setProperty","getCssVariableName","askLaterButton","subscribeButton","addEventListener","subscribe"],"sourceRoot":""}
@@ -1,2 +1,2 @@
1
- !function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var o=e();for(var i in o)("object"==typeof exports?exports:t)[i]=o[i]}}(this,()=>(()=>{"use strict";const t={d:(e,o)=>{for(var i in o)t.o(o,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:o[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}};let e={};t.r(e),t.d(e,{PWSubscriptionButtonWidget:()=>d});const o="granted",i="default",s="bottomRight",n="bottomLeft",r="topRight",a="topLeft",p={position:n,bgColor:"#12AE7E",bellColor:"white",bellStrokeColor:"#08754f",bellButtonBorder:"1px solid #379676",shadow:"0px 0px 6px rgba(0, 0, 0, 0.75)",size:"48px",indent:"20px",zIndex:"999999",tooltipText:{successSubscribe:"You are successfully subscribed!",needSubscribe:"Get notifications about important news!",blockSubscribe:"Click to see how to get notifications",alreadySubscribed:"You are already subscribed"}};class c{static getBellPosition(t,e){let o;switch(t){case s:o={top:"auto",left:"auto",bottom:e,right:e};break;case n:o={top:"auto",left:e,bottom:e,right:"auto"};break;case a:o={top:e,left:e,bottom:"auto",right:"auto"};break;case r:o={top:e,left:"auto",bottom:"auto",right:e};break;default:o={top:"auto",left:"auto",bottom:e,right:e}}return o}static getTooltipPosition(t,e){let o,i;const r=parseInt(e)+12+"px";switch(t){case s:o={right:r},i="right";break;case n:case a:o={left:r},i="left";break;default:o={right:r},i="right"}return[o,i]}static getPopoverPosition(t,e){let o,i;const p=parseInt(e)+15+"px";switch(t){case s:o={bottom:p,right:"0",left:"auto",top:"auto"},i="bottom";break;case n:o={bottom:p,left:"0",right:"auto",top:"auto"},i="bottom";break;case a:o={top:p,left:"0",right:"auto",bottom:"auto"},i="top";break;case r:o={top:p,right:"0",left:"auto",bottom:"auto"},i="top";break;default:o={bottom:p,right:"0",left:"auto",top:"auto"},i="bottom"}return[o,i]}static getPopoverArrowPosition(t,e){let o;switch(t){case s:o="\n.pushwoosh-subscribe-widget__popover__bottom:after {left: auto; right: "+(parseInt(e)/2-4+"px");break;case n:o="\n.pushwoosh-subscribe-widget__popover__bottom:after {right: auto; left: "+(parseInt(e)/2-12+"px");break;case a:o="\n.pushwoosh-subscribe-widget__popover__top:after {right: auto; left: "+(parseInt(e)/2-12+"px");break;case r:o="\n.pushwoosh-subscribe-widget__popover__top:after {left: auto; right: "+(parseInt(e)/2-4+"px");break;default:o="\n.pushwoosh-subscribe-widget__popover__bottom:after {left: auto; right: "+(parseInt(e)/2-4+"px")}return o}}class d{constructor(t){if(this.pw=t,!t.platformChecker.isAvailableNotifications)return void console.warn("Browser does not support push notifications");this.clickBell=this.clickBell.bind(this),this.onSubscribeEvent=this.onSubscribeEvent.bind(this),this.onUnsubscribeEvent=this.onUnsubscribeEvent.bind(this),this.onPermissionDeniedEvent=this.onPermissionDeniedEvent.bind(this),this.clickOutOfPopover=this.clickOutOfPopover.bind(this);const e=Object.assign(p.tooltipText,t.initParams.subscribeWidget.tooltipText);this.config=Object.assign({},p,t.initParams.subscribeWidget),this.config.tooltipText=e}async run(){if(!this.pw.isPushAvailable())return;await this.pw.isSubscribed()||await this.render()}addStylesToElement(t,e){Object.keys(t).forEach(o=>{e.style[o]=t[o]})}createContainer(){const t=document.createElement("div");t.id="pushwooshBellWidget",t.className="pushwoosh-subscribe-widget";const e=c.getBellPosition(this.config.position,this.config.indent),o=Object.assign({zIndex:this.config.zIndex},e);return this.addStylesToElement(o,t),t}createStyle(){const t=document.createElement("style");return t.innerHTML='/* Widget */\n.pushwoosh-subscribe-widget {\n position: fixed;\n display: block;\n transform: translate3d(0, 0, 0);\n}\n\n.pushwoosh-subscribe-widget__subscribed {\n display: none;\n}\n\n.pushwoosh-subscribe-widget .pushwoosh-subscribe-widget__bell-button {\n border-radius: 50%;\n cursor: pointer;\n font-size: 0;\n text-align: center;\n transform: scale(0.9) translate3d(0, 0, 0);\n transition: transform .3s ease-in-out;\n position: relative;\n}\n\n.pushwoosh-subscribe-widget .pushwoosh-subscribe-widget__bell-button:hover {\n transform: scale(1);\n}\n\n/* Tooltip */\n.pushwoosh-subscribe-widget__tooltip {\n position: absolute;\n height: 48px;\n max-width: 300px;\n min-width: 200px;\n padding: 5px 7px;\n background-color: #3b444b;\n color: #ffffff;\n text-align: center;\n vertical-align: middle;\n box-sizing: border-box;\n line-height: 38px;\n font-size: 0;\n font-weight: normal;\n visibility: hidden;\n opacity: 0;\n transition: visibility 0s ease-in .3s,\n opacity .3s ease-in;\n top: 50%;\n transform: translate(0, -50%);\n box-shadow: 1px 1px 5px 0 rgba(0,0,0,0.5);\n}\n\n.pushwoosh-subscribe-widget__tooltip__right:after,\n.pushwoosh-subscribe-widget__tooltip__left:after {\n content: "";\n top: 50%;\n height: 0;\n width: 0;\n position: absolute;\n pointer-events: none;\n border-top: 5px solid transparent;\n border-bottom: 5px solid transparent;\n background: #3b444b;\n}\n\n.pushwoosh-subscribe-widget__tooltip__right:after {\n left: calc(100% - 7px);\n border-top: 5px solid #3b444b;\n border-left: 5px solid #3b444b;\n border-right: 5px solid transparent;\n box-sizing: border-box;\n transform-origin: 0 0;\n transform: rotate(-45deg);\n box-shadow: 2px 2px 2px 0 rgba(0, 0, 0, 0.25);\n}\n\n.pushwoosh-subscribe-widget__tooltip__left:after {\n left: -7px;\n border-top: 5px solid #3b444b;\n border-right: 5px solid #3b444b;\n border-left: 5px solid transparent;\n box-sizing: border-box;\n transform-origin: 0 0;\n transform: rotate(-45deg);\n box-shadow: -2px -2px 2px 0 rgba(0, 0, 0, 0.25);\n}\n\n.pushwoosh-subscribe-widget__bell-button:hover + .pushwoosh-subscribe-widget__tooltip,\n.pushwoosh-subscribe-widget__tooltip.pushwoosh-subscribe-widget__tooltip__visible {\n display: block;\n visibility: visible;\n opacity: 1;\n transition-delay: 0s;\n}\n\n.pushwoosh-subscribe-widget .pushwoosh-subscribe-widget__tooltip-content {\n display: inline-block;\n vertical-align: middle;\n font-size: 14px;\n line-height: 1.4;\n white-space: nowrap;\n overflow: hidden;\n padding-right: 5px;\n text-overflow: ellipsis;\n max-width: 100%;\n}\n\n/* Popover */\n\n.pushwoosh-subscribe-widget .pushwoosh-subscribe-widget__popover {\n position: absolute;\n right: auto;\n box-shadow: 1px 1px 5px 0 rgba(0, 0, 0, 0.5);\n box-sizing: border-box;\n background: #9ca8b1;\n visibility: hidden;\n opacity: 0;\n transition: visibility 0s ease-in .5s,\n opacity .5s ease-in;\n}\n\n.pushwoosh-subscribe-widget .pushwoosh-subscribe-widget__popover__visible {\n display: block;\n visibility: visible;\n opacity: 1;\n transition-delay: 0s;\n}\n\n.pushwoosh-subscribe-widget__popover__bottom:after,\n.pushwoosh-subscribe-widget__popover__top:after {\n content: "";\n height: 0;\n width: 0;\n position: absolute;\n pointer-events: none;\n border-right: 8px solid transparent;\n border-left: 8px solid #9ca8b1;\n background: #9ca8b1;\n transform-origin: 0 0;\n transform: rotate(-45deg);\n}\n\n.pushwoosh-subscribe-widget__popover__bottom:after {\n border-bottom: 8px solid #9ca8b1;\n border-top: 8px solid transparent;\n box-sizing: border-box;\n box-shadow: -2px 2px 1px 0 rgba(0, 0, 0, 0.25);\n bottom: -16px;\n}\n\n.pushwoosh-subscribe-widget__popover__top:after {\n top: 0;\n border-top: 8px solid #9ca8b1;\n border-bottom: 8px solid transparent;\n box-sizing: border-box;\n box-shadow: 1px -1px 1px 0 rgba(0, 0, 0, 0.25);\n}\n\n.pushwoosh-subscribe-widget__popover-content-wrapper {\n overflow: auto;\n max-width: 100%;\n}\n\n\n.pushwoosh-subscribe-widget .pushwoosh-subscribe-widget__popover-content {\n display: flex;\n flex-direction: column;\n padding: 14px;\n box-sizing: border-box;\n float: left;\n min-width: 100%;\n align-items: center;\n}\n\n.pushwoosh-subscribe-widget .pushwoosh-subscribe-widget__popover img {\n display: block;\n}\n\n.pushwoosh-subscribe-widget .pushwoosh-subscribe-widget__popover img:first-child {\n margin-bottom: 14px;\n}\n\n@media (max-width: 767px) and (orientation: portrait) {\n .pushwoosh-subscribe-widget .pushwoosh-subscribe-widget__popover-content {\n flex-direction: column;\n }\n .pushwoosh-subscribe-widget .pushwoosh-subscribe-widget__popover img {\n max-width: 280px;\n height: auto;\n }\n .pushwoosh-subscribe-widget .pushwoosh-subscribe-widget__popover img:first-child {\n margin-right: 0;\n margin-bottom: 14px;\n }\n}\n@media (max-width: 767px) and (orientation: landscape) {\n .pushwoosh-subscribe-widget .pushwoosh-subscribe-widget__popover-content {\n flex-direction: row;\n }\n .pushwoosh-subscribe-widget .pushwoosh-subscribe-widget__popover img {\n max-width: 280px;\n height: auto;\n }\n .pushwoosh-subscribe-widget .pushwoosh-subscribe-widget__popover img:first-child {\n margin-right: 14px;\n margin-bottom: 0;\n }\n}\n',t}createBell(){const{config:t}=this;let e;var o,i;return t.buttonImage?(e=document.createElement("img"),e.src=t.buttonImage):(e=document.createElement("div"),this.addStylesToElement({backgroundColor:t.bgColor,boxShadow:t.shadow,lineHeight:t.size,border:t.bellButtonBorder},e),e.innerHTML=(o=t.bellColor,i=t.bellStrokeColor,`<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n<svg\n xmlns:dc="http://purl.org/dc/elements/1.1/"\n xmlns:cc="http://creativecommons.org/ns#"\n xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"\n xmlns:svg="http://www.w3.org/2000/svg"\n xmlns="http://www.w3.org/2000/svg"\n xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"\n xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"\n version="1.1"\n id="Capa_1"\n x="0px"\n y="0px"\n viewBox="0 0 346.013 346.013"\n style="enable-background:new 0 0 346.013 346.013;width: 80%; height: auto; vertical-align: middle;"\n xml:space="preserve"\n inkscape:version="0.91 r13725"\n sodipodi:docname="alarm_white.svg"><metadata\n id="metadata51"><rdf:RDF><cc:Work\n rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type\n rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs\n id="defs49" /><sodipodi:namedview\n borderopacity="1"\n objecttolerance="10"\n gridtolerance="10"\n guidetolerance="10"\n inkscape:pageopacity="0"\n inkscape:pageshadow="2"\n inkscape:window-width="1618"\n inkscape:window-height="828"\n id="namedview47"\n showgrid="false"\n inkscape:zoom="0.6820553"\n inkscape:cx="173.0065"\n inkscape:cy="173.0065"\n inkscape:window-x="0"\n inkscape:window-y="0"\n inkscape:window-maximized="0"\n inkscape:current-layer="g3" /><g\n id="g3"><path\n d="m 256.76227,220.19006 c -1.77513,-2.69766 -3.45154,-5.24564 -3.98966,-7.46382 -0.042,-0.17861 -0.0911,-0.36128 -0.16237,-0.61436 -2.28354,-7.67647 0.69147,-24.43921 2.46886,-34.45124 0.26788,-1.50394 0.52274,-2.94197 0.75286,-4.29035 0.0232,-0.13675 0.044,-0.27211 0.0724,-0.48006 1.95582,-15.28051 2.58811,-37.91956 -5.51044,-58.99147 -5.6032,-14.57978 -14.45978,-25.82612 -26.3559,-33.48393 1.26598,-9.812938 -4.85967,-19.343691 -14.66682,-22.0511 -9.80715,-2.70741 -19.95724,2.33226 -23.90298,11.405413 -14.1382,0.467533 -27.51111,5.577097 -39.80114,15.219267 -17.76129,13.9298 -28.83431,33.68757 -34.99389,47.80757 l -0.0479,0.11335 c -0.0512,0.12175 -0.0998,0.24114 -0.13249,0.32962 -0.49733,1.28292 -1.01552,2.64514 -1.55689,4.07255 -3.61311,9.51043 -9.66004,25.42824 -15.611995,30.89342 -0.106524,0.10027 -0.208228,0.20187 -0.362362,0.35435 -1.636243,1.66563 -4.382941,2.99463 -7.288979,4.40101 -7.145531,3.45301 -22.013613,10.64166 -17.206389,31.67844 0.929154,4.07105 4.008437,7.29057 8.033861,8.40185 l 167.570804,46.2604 c 4.02253,1.11048 8.31521,-0.0729 11.2052,-3.08958 14.91617,-15.58874 5.84693,-29.38668 1.48625,-36.02133 z"\n id="path5"\n inkscape:connector-curvature="0"\n vector-effect="non-scaling-stroke"\n style="fill:${o}; stroke: ${i}; stroke-width: 1; " /><path\n vector-effect="non-scaling-stroke"\n d="m 174.26737,259.72378 -38.76399,-10.70137 c -1.59243,-0.43962 -3.28183,-0.15596 -4.63548,0.7754 -2.53909,1.7494 -2.84182,4.93159 -3.02304,6.83188 l -0.0151,0.15247 c -1.22819,12.67106 6.79854,24.33046 19.08688,27.72284 12.51583,3.45518 25.8324,-2.91586 30.9681,-14.80385 l 0.0935,-0.19205 c 0.52305,-1.06418 1.74613,-3.55554 0.50882,-6.31116 -0.44302,-0.98439 -1.5794,-2.74529 -4.21964,-3.47416 z"\n id="path7"\n inkscape:connector-curvature="0"\n style="fill:${o}; stroke: ${i}; stroke-width: 1;" /></g><g\n id="g17" /><g\n id="g19" /><g\n id="g21" /><g\n id="g23" /><g\n id="g25" /><g\n id="g27" /><g\n id="g29" /><g\n id="g31" /><g\n id="g33" /><g\n id="g35" /><g\n id="g37" /><g\n id="g39" /><g\n id="g41" /><g\n id="g43" /><g\n id="g45" /></svg>`)),this.addStylesToElement({width:t.size,height:t.size},e),e.className="pushwoosh-subscribe-widget__bell-button",e}async createTooltip(){const t=document.createElement("div"),[e,o]=c.getTooltipPosition(this.config.position,this.config.size);return t.className=`pushwoosh-subscribe-widget__tooltip pushwoosh-subscribe-widget__tooltip__${o}`,this.addStylesToElement(e,t),t.appendChild(await this.createTooltipContent()),t}async createTooltipContent(){const t=document.createElement("div");return t.innerText=await this.tooltipTextFactory(),t.className="pushwoosh-subscribe-widget__tooltip-content",t}async tooltipTextFactory(){const t=this.pw.driver?.getPermission(),{tooltipText:e}=this.config,s=await this.pw.data.getStatusManualUnsubscribed();switch(t){case o:return s?e.needSubscribe:e.alreadySubscribed;case i:return e.needSubscribe;case"denied":return e.blockSubscribe;default:return e.needSubscribe}}createPopover(){const t=document.createElement("div"),e=document.createElement("div"),[o,i]=c.getPopoverPosition(this.config.position,this.config.size);e.className=`pushwoosh-subscribe-widget__popover pushwoosh-subscribe-widget__popover__${i}`,t.className="pushwoosh-subscribe-widget__popover-content-wrapper",this.style.innerHTML+=c.getPopoverArrowPosition(this.config.position,this.config.size);const s=Object.assign({maxWidth:`calc(100vw - ${this.config.indent} - ${this.config.indent})`},o);return this.addStylesToElement(s,e),t.appendChild(this.createPopoverContent()),e.appendChild(t),e}getBrowserName(){const t=this.pw.platformChecker;let e;return e=t.isOpera?"opera":11===t.platform&&navigator.userAgent.match(/Android/i)?"mobileChrome":12===t.platform?"firefox":10===t.platform?"safari":150===t.platform?"edge":"chrome",e}createPopoverContent(){const{config:t}=this,e=document.createElement("div");e.className="pushwoosh-subscribe-widget__popover-content";const o=this.getBrowserName(),i=t.contentImages&&t.contentImages[o];if(i){const t=document.createElement("img");t.src=i,e.appendChild(t)}else{const t={opera:"opera",mobileChrome:"mobile_chrome",firefox:"FF",safari:"safari"}[o]||"chrome";[{src:this.getImageSrc(t),width:500,height:130},{src:this.getImageSrc(`${t}_unlock`),width:500,height:230}].forEach(t=>{const o=document.createElement("img");Object.assign(o,t),e.appendChild(o)})}return e}getImageSrc(t){return`https://cdn.pushwoosh.com/webpush/img/${t}.jpg`}async render(){this.widget=this.createContainer(),this.style=this.createStyle();const t=this.createBell();this.tooltip=await this.createTooltip(),this.popover=await this.createPopover(),this.widget.appendChild(this.style),this.widget.appendChild(t),this.widget.appendChild(this.tooltip),this.widget.appendChild(this.popover),document.body.appendChild(this.widget),this.pw.push(["onSubscribe",this.onSubscribeEvent]),this.pw.push(["onUnsubscribe",this.onUnsubscribeEvent]),this.pw.push(["onPermissionDenied",this.onPermissionDeniedEvent]),this.addEventListeners()}addEventListeners(){this.widget.addEventListener("click",this.clickBell),window.addEventListener("click",this.clickOutOfPopover)}toggleHelpPopover(){this.popover.classList.toggle("pushwoosh-subscribe-widget__popover__visible")}async clickBell(){const t=this.pw.driver?.getPermission();switch(t){case o:case i:await this.pw.subscribe();break;case"denied":this.toggleHelpPopover();break;default:console.warn("Unknown browser notification permission")}}async onSubscribeEvent(){const t=this.tooltip.querySelector("div");null!==t&&(t.innerText=this.config.tooltipText.successSubscribe,this.tooltip.classList.add("pushwoosh-subscribe-widget__tooltip__visible"),setTimeout(async()=>{this.tooltip.classList.remove("pushwoosh-subscribe-widget__tooltip__visible"),t.innerText=await this.tooltipTextFactory(),this.widget.classList.add("pushwoosh-subscribe-widget__subscribed")},2e3))}async onPermissionDeniedEvent(){this.addEventListeners();const t=this.tooltip.querySelector("div");null!==t&&(t.innerText=await this.tooltipTextFactory())}clickOutOfPopover(t){this.popover.classList.contains("pushwoosh-subscribe-widget__popover__visible")&&!t.target.classList.contains("pushwoosh-subscribe-widget__popover")&&null===t.target.closest(".pushwoosh-subscribe-widget__popover")&&!t.target.classList.contains("pushwoosh-subscribe-widget__bell-button")&&null===t.target.closest(".pushwoosh-subscribe-widget__bell-button")&&this.popover.classList.remove("pushwoosh-subscribe-widget__popover__visible")}async onUnsubscribeEvent(){const t=this.tooltip.querySelector("div");null!==t&&(t.innerText=await this.tooltipTextFactory())}}return e})());
1
+ !function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var o=e();for(var i in o)("object"==typeof exports?exports:t)[i]=o[i]}}(this,()=>(()=>{"use strict";const t={d:(e,o)=>{for(var i in o)t.o(o,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:o[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{Object.defineProperties(t,{[Symbol.toStringTag]:{value:"Module"},__esModule:{value:!0}})}};let e={};t.r(e),t.d(e,{PWSubscriptionButtonWidget:()=>d});const o="granted",i="default",s="bottomRight",n="bottomLeft",r="topRight",a="topLeft",p={position:n,bgColor:"#12AE7E",bellColor:"white",bellStrokeColor:"#08754f",bellButtonBorder:"1px solid #379676",shadow:"0px 0px 6px rgba(0, 0, 0, 0.75)",size:"48px",indent:"20px",zIndex:"999999",tooltipText:{successSubscribe:"You are successfully subscribed!",needSubscribe:"Get notifications about important news!",blockSubscribe:"Click to see how to get notifications",alreadySubscribed:"You are already subscribed"}};class c{static getBellPosition(t,e){let o;switch(t){case s:o={top:"auto",left:"auto",bottom:e,right:e};break;case n:o={top:"auto",left:e,bottom:e,right:"auto"};break;case a:o={top:e,left:e,bottom:"auto",right:"auto"};break;case r:o={top:e,left:"auto",bottom:"auto",right:e};break;default:o={top:"auto",left:"auto",bottom:e,right:e}}return o}static getTooltipPosition(t,e){let o,i;const r=parseInt(e)+12+"px";switch(t){case s:o={right:r},i="right";break;case n:case a:o={left:r},i="left";break;default:o={right:r},i="right"}return[o,i]}static getPopoverPosition(t,e){let o,i;const p=parseInt(e)+15+"px";switch(t){case s:o={bottom:p,right:"0",left:"auto",top:"auto"},i="bottom";break;case n:o={bottom:p,left:"0",right:"auto",top:"auto"},i="bottom";break;case a:o={top:p,left:"0",right:"auto",bottom:"auto"},i="top";break;case r:o={top:p,right:"0",left:"auto",bottom:"auto"},i="top";break;default:o={bottom:p,right:"0",left:"auto",top:"auto"},i="bottom"}return[o,i]}static getPopoverArrowPosition(t,e){let o;switch(t){case s:o="\n.pushwoosh-subscribe-widget__popover__bottom:after {left: auto; right: "+(parseInt(e)/2-4+"px");break;case n:o="\n.pushwoosh-subscribe-widget__popover__bottom:after {right: auto; left: "+(parseInt(e)/2-12+"px");break;case a:o="\n.pushwoosh-subscribe-widget__popover__top:after {right: auto; left: "+(parseInt(e)/2-12+"px");break;case r:o="\n.pushwoosh-subscribe-widget__popover__top:after {left: auto; right: "+(parseInt(e)/2-4+"px");break;default:o="\n.pushwoosh-subscribe-widget__popover__bottom:after {left: auto; right: "+(parseInt(e)/2-4+"px")}return o}}class d{constructor(t){if(this.pw=t,!t.platformChecker.isAvailableNotifications)return void console.warn("Browser does not support push notifications");this.clickBell=this.clickBell.bind(this),this.onSubscribeEvent=this.onSubscribeEvent.bind(this),this.onUnsubscribeEvent=this.onUnsubscribeEvent.bind(this),this.onPermissionDeniedEvent=this.onPermissionDeniedEvent.bind(this),this.clickOutOfPopover=this.clickOutOfPopover.bind(this);const e=Object.assign(p.tooltipText,t.initParams.subscribeWidget.tooltipText);this.config=Object.assign({},p,t.initParams.subscribeWidget),this.config.tooltipText=e}async run(){if(!this.pw.isPushAvailable())return;await this.pw.isSubscribed()||await this.render()}addStylesToElement(t,e){Object.keys(t).forEach(o=>{e.style[o]=t[o]})}createContainer(){const t=document.createElement("div");t.id="pushwooshBellWidget",t.className="pushwoosh-subscribe-widget";const e=c.getBellPosition(this.config.position,this.config.indent),o=Object.assign({zIndex:this.config.zIndex},e);return this.addStylesToElement(o,t),t}createStyle(){const t=document.createElement("style");return t.innerHTML='/* Widget */\n.pushwoosh-subscribe-widget {\n position: fixed;\n display: block;\n transform: translate3d(0, 0, 0);\n}\n\n.pushwoosh-subscribe-widget__subscribed {\n display: none;\n}\n\n.pushwoosh-subscribe-widget .pushwoosh-subscribe-widget__bell-button {\n border-radius: 50%;\n cursor: pointer;\n font-size: 0;\n text-align: center;\n transform: scale(0.9) translate3d(0, 0, 0);\n transition: transform .3s ease-in-out;\n position: relative;\n}\n\n.pushwoosh-subscribe-widget .pushwoosh-subscribe-widget__bell-button:hover {\n transform: scale(1);\n}\n\n/* Tooltip */\n.pushwoosh-subscribe-widget__tooltip {\n position: absolute;\n height: 48px;\n max-width: 300px;\n min-width: 200px;\n padding: 5px 7px;\n background-color: #3b444b;\n color: #ffffff;\n text-align: center;\n vertical-align: middle;\n box-sizing: border-box;\n line-height: 38px;\n font-size: 0;\n font-weight: normal;\n visibility: hidden;\n opacity: 0;\n transition: visibility 0s ease-in .3s,\n opacity .3s ease-in;\n top: 50%;\n transform: translate(0, -50%);\n box-shadow: 1px 1px 5px 0 rgba(0,0,0,0.5);\n}\n\n.pushwoosh-subscribe-widget__tooltip__right:after,\n.pushwoosh-subscribe-widget__tooltip__left:after {\n content: "";\n top: 50%;\n height: 0;\n width: 0;\n position: absolute;\n pointer-events: none;\n border-top: 5px solid transparent;\n border-bottom: 5px solid transparent;\n background: #3b444b;\n}\n\n.pushwoosh-subscribe-widget__tooltip__right:after {\n left: calc(100% - 7px);\n border-top: 5px solid #3b444b;\n border-left: 5px solid #3b444b;\n border-right: 5px solid transparent;\n box-sizing: border-box;\n transform-origin: 0 0;\n transform: rotate(-45deg);\n box-shadow: 2px 2px 2px 0 rgba(0, 0, 0, 0.25);\n}\n\n.pushwoosh-subscribe-widget__tooltip__left:after {\n left: -7px;\n border-top: 5px solid #3b444b;\n border-right: 5px solid #3b444b;\n border-left: 5px solid transparent;\n box-sizing: border-box;\n transform-origin: 0 0;\n transform: rotate(-45deg);\n box-shadow: -2px -2px 2px 0 rgba(0, 0, 0, 0.25);\n}\n\n.pushwoosh-subscribe-widget__bell-button:hover + .pushwoosh-subscribe-widget__tooltip,\n.pushwoosh-subscribe-widget__tooltip.pushwoosh-subscribe-widget__tooltip__visible {\n display: block;\n visibility: visible;\n opacity: 1;\n transition-delay: 0s;\n}\n\n.pushwoosh-subscribe-widget .pushwoosh-subscribe-widget__tooltip-content {\n display: inline-block;\n vertical-align: middle;\n font-size: 14px;\n line-height: 1.4;\n white-space: nowrap;\n overflow: hidden;\n padding-right: 5px;\n text-overflow: ellipsis;\n max-width: 100%;\n}\n\n/* Popover */\n\n.pushwoosh-subscribe-widget .pushwoosh-subscribe-widget__popover {\n position: absolute;\n right: auto;\n box-shadow: 1px 1px 5px 0 rgba(0, 0, 0, 0.5);\n box-sizing: border-box;\n background: #9ca8b1;\n visibility: hidden;\n opacity: 0;\n transition: visibility 0s ease-in .5s,\n opacity .5s ease-in;\n}\n\n.pushwoosh-subscribe-widget .pushwoosh-subscribe-widget__popover__visible {\n display: block;\n visibility: visible;\n opacity: 1;\n transition-delay: 0s;\n}\n\n.pushwoosh-subscribe-widget__popover__bottom:after,\n.pushwoosh-subscribe-widget__popover__top:after {\n content: "";\n height: 0;\n width: 0;\n position: absolute;\n pointer-events: none;\n border-right: 8px solid transparent;\n border-left: 8px solid #9ca8b1;\n background: #9ca8b1;\n transform-origin: 0 0;\n transform: rotate(-45deg);\n}\n\n.pushwoosh-subscribe-widget__popover__bottom:after {\n border-bottom: 8px solid #9ca8b1;\n border-top: 8px solid transparent;\n box-sizing: border-box;\n box-shadow: -2px 2px 1px 0 rgba(0, 0, 0, 0.25);\n bottom: -16px;\n}\n\n.pushwoosh-subscribe-widget__popover__top:after {\n top: 0;\n border-top: 8px solid #9ca8b1;\n border-bottom: 8px solid transparent;\n box-sizing: border-box;\n box-shadow: 1px -1px 1px 0 rgba(0, 0, 0, 0.25);\n}\n\n.pushwoosh-subscribe-widget__popover-content-wrapper {\n overflow: auto;\n max-width: 100%;\n}\n\n\n.pushwoosh-subscribe-widget .pushwoosh-subscribe-widget__popover-content {\n display: flex;\n flex-direction: column;\n padding: 14px;\n box-sizing: border-box;\n float: left;\n min-width: 100%;\n align-items: center;\n}\n\n.pushwoosh-subscribe-widget .pushwoosh-subscribe-widget__popover img {\n display: block;\n}\n\n.pushwoosh-subscribe-widget .pushwoosh-subscribe-widget__popover img:first-child {\n margin-bottom: 14px;\n}\n\n@media (max-width: 767px) and (orientation: portrait) {\n .pushwoosh-subscribe-widget .pushwoosh-subscribe-widget__popover-content {\n flex-direction: column;\n }\n .pushwoosh-subscribe-widget .pushwoosh-subscribe-widget__popover img {\n max-width: 280px;\n height: auto;\n }\n .pushwoosh-subscribe-widget .pushwoosh-subscribe-widget__popover img:first-child {\n margin-right: 0;\n margin-bottom: 14px;\n }\n}\n@media (max-width: 767px) and (orientation: landscape) {\n .pushwoosh-subscribe-widget .pushwoosh-subscribe-widget__popover-content {\n flex-direction: row;\n }\n .pushwoosh-subscribe-widget .pushwoosh-subscribe-widget__popover img {\n max-width: 280px;\n height: auto;\n }\n .pushwoosh-subscribe-widget .pushwoosh-subscribe-widget__popover img:first-child {\n margin-right: 14px;\n margin-bottom: 0;\n }\n}\n',t}createBell(){const{config:t}=this;let e;var o,i;return t.buttonImage?(e=document.createElement("img"),e.src=t.buttonImage):(e=document.createElement("div"),this.addStylesToElement({backgroundColor:t.bgColor,boxShadow:t.shadow,lineHeight:t.size,border:t.bellButtonBorder},e),e.innerHTML=(o=t.bellColor,i=t.bellStrokeColor,`<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n<svg\n xmlns:dc="http://purl.org/dc/elements/1.1/"\n xmlns:cc="http://creativecommons.org/ns#"\n xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"\n xmlns:svg="http://www.w3.org/2000/svg"\n xmlns="http://www.w3.org/2000/svg"\n xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"\n xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"\n version="1.1"\n id="Capa_1"\n x="0px"\n y="0px"\n viewBox="0 0 346.013 346.013"\n style="enable-background:new 0 0 346.013 346.013;width: 80%; height: auto; vertical-align: middle;"\n xml:space="preserve"\n inkscape:version="0.91 r13725"\n sodipodi:docname="alarm_white.svg"><metadata\n id="metadata51"><rdf:RDF><cc:Work\n rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type\n rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs\n id="defs49" /><sodipodi:namedview\n borderopacity="1"\n objecttolerance="10"\n gridtolerance="10"\n guidetolerance="10"\n inkscape:pageopacity="0"\n inkscape:pageshadow="2"\n inkscape:window-width="1618"\n inkscape:window-height="828"\n id="namedview47"\n showgrid="false"\n inkscape:zoom="0.6820553"\n inkscape:cx="173.0065"\n inkscape:cy="173.0065"\n inkscape:window-x="0"\n inkscape:window-y="0"\n inkscape:window-maximized="0"\n inkscape:current-layer="g3" /><g\n id="g3"><path\n d="m 256.76227,220.19006 c -1.77513,-2.69766 -3.45154,-5.24564 -3.98966,-7.46382 -0.042,-0.17861 -0.0911,-0.36128 -0.16237,-0.61436 -2.28354,-7.67647 0.69147,-24.43921 2.46886,-34.45124 0.26788,-1.50394 0.52274,-2.94197 0.75286,-4.29035 0.0232,-0.13675 0.044,-0.27211 0.0724,-0.48006 1.95582,-15.28051 2.58811,-37.91956 -5.51044,-58.99147 -5.6032,-14.57978 -14.45978,-25.82612 -26.3559,-33.48393 1.26598,-9.812938 -4.85967,-19.343691 -14.66682,-22.0511 -9.80715,-2.70741 -19.95724,2.33226 -23.90298,11.405413 -14.1382,0.467533 -27.51111,5.577097 -39.80114,15.219267 -17.76129,13.9298 -28.83431,33.68757 -34.99389,47.80757 l -0.0479,0.11335 c -0.0512,0.12175 -0.0998,0.24114 -0.13249,0.32962 -0.49733,1.28292 -1.01552,2.64514 -1.55689,4.07255 -3.61311,9.51043 -9.66004,25.42824 -15.611995,30.89342 -0.106524,0.10027 -0.208228,0.20187 -0.362362,0.35435 -1.636243,1.66563 -4.382941,2.99463 -7.288979,4.40101 -7.145531,3.45301 -22.013613,10.64166 -17.206389,31.67844 0.929154,4.07105 4.008437,7.29057 8.033861,8.40185 l 167.570804,46.2604 c 4.02253,1.11048 8.31521,-0.0729 11.2052,-3.08958 14.91617,-15.58874 5.84693,-29.38668 1.48625,-36.02133 z"\n id="path5"\n inkscape:connector-curvature="0"\n vector-effect="non-scaling-stroke"\n style="fill:${o}; stroke: ${i}; stroke-width: 1; " /><path\n vector-effect="non-scaling-stroke"\n d="m 174.26737,259.72378 -38.76399,-10.70137 c -1.59243,-0.43962 -3.28183,-0.15596 -4.63548,0.7754 -2.53909,1.7494 -2.84182,4.93159 -3.02304,6.83188 l -0.0151,0.15247 c -1.22819,12.67106 6.79854,24.33046 19.08688,27.72284 12.51583,3.45518 25.8324,-2.91586 30.9681,-14.80385 l 0.0935,-0.19205 c 0.52305,-1.06418 1.74613,-3.55554 0.50882,-6.31116 -0.44302,-0.98439 -1.5794,-2.74529 -4.21964,-3.47416 z"\n id="path7"\n inkscape:connector-curvature="0"\n style="fill:${o}; stroke: ${i}; stroke-width: 1;" /></g><g\n id="g17" /><g\n id="g19" /><g\n id="g21" /><g\n id="g23" /><g\n id="g25" /><g\n id="g27" /><g\n id="g29" /><g\n id="g31" /><g\n id="g33" /><g\n id="g35" /><g\n id="g37" /><g\n id="g39" /><g\n id="g41" /><g\n id="g43" /><g\n id="g45" /></svg>`)),this.addStylesToElement({width:t.size,height:t.size},e),e.className="pushwoosh-subscribe-widget__bell-button",e}async createTooltip(){const t=document.createElement("div"),[e,o]=c.getTooltipPosition(this.config.position,this.config.size);return t.className=`pushwoosh-subscribe-widget__tooltip pushwoosh-subscribe-widget__tooltip__${o}`,this.addStylesToElement(e,t),t.appendChild(await this.createTooltipContent()),t}async createTooltipContent(){const t=document.createElement("div");return t.innerText=await this.tooltipTextFactory(),t.className="pushwoosh-subscribe-widget__tooltip-content",t}async tooltipTextFactory(){const t=this.pw.driver?.getPermission(),{tooltipText:e}=this.config,s=await this.pw.data.getStatusManualUnsubscribed();switch(t){case o:return s?e.needSubscribe:e.alreadySubscribed;case i:return e.needSubscribe;case"denied":return e.blockSubscribe;default:return e.needSubscribe}}createPopover(){const t=document.createElement("div"),e=document.createElement("div"),[o,i]=c.getPopoverPosition(this.config.position,this.config.size);e.className=`pushwoosh-subscribe-widget__popover pushwoosh-subscribe-widget__popover__${i}`,t.className="pushwoosh-subscribe-widget__popover-content-wrapper",this.style.innerHTML+=c.getPopoverArrowPosition(this.config.position,this.config.size);const s=Object.assign({maxWidth:`calc(100vw - ${this.config.indent} - ${this.config.indent})`},o);return this.addStylesToElement(s,e),t.appendChild(this.createPopoverContent()),e.appendChild(t),e}getBrowserName(){const t=this.pw.platformChecker;let e;return e=t.isOpera?"opera":11===t.platform&&navigator.userAgent.match(/Android/i)?"mobileChrome":12===t.platform?"firefox":10===t.platform?"safari":150===t.platform?"edge":"chrome",e}createPopoverContent(){const{config:t}=this,e=document.createElement("div");e.className="pushwoosh-subscribe-widget__popover-content";const o=this.getBrowserName(),i=t.contentImages&&t.contentImages[o];if(i){const t=document.createElement("img");t.src=i,e.appendChild(t)}else{const t={opera:"opera",mobileChrome:"mobile_chrome",firefox:"FF",safari:"safari"}[o]||"chrome";[{src:this.getImageSrc(t),width:500,height:130},{src:this.getImageSrc(`${t}_unlock`),width:500,height:230}].forEach(t=>{const o=document.createElement("img");Object.assign(o,t),e.appendChild(o)})}return e}getImageSrc(t){return`https://cdn.pushwoosh.com/webpush/img/${t}.jpg`}async render(){this.widget=this.createContainer(),this.style=this.createStyle();const t=this.createBell();this.tooltip=await this.createTooltip(),this.popover=await this.createPopover(),this.widget.appendChild(this.style),this.widget.appendChild(t),this.widget.appendChild(this.tooltip),this.widget.appendChild(this.popover),document.body.appendChild(this.widget),this.pw.push(["onSubscribe",this.onSubscribeEvent]),this.pw.push(["onUnsubscribe",this.onUnsubscribeEvent]),this.pw.push(["onPermissionDenied",this.onPermissionDeniedEvent]),this.addEventListeners()}addEventListeners(){this.widget.addEventListener("click",this.clickBell),window.addEventListener("click",this.clickOutOfPopover)}toggleHelpPopover(){this.popover.classList.toggle("pushwoosh-subscribe-widget__popover__visible")}async clickBell(){const t=this.pw.driver?.getPermission();switch(t){case o:case i:await this.pw.subscribe();break;case"denied":this.toggleHelpPopover();break;default:console.warn("Unknown browser notification permission")}}async onSubscribeEvent(){const t=this.tooltip.querySelector("div");null!==t&&(t.innerText=this.config.tooltipText.successSubscribe,this.tooltip.classList.add("pushwoosh-subscribe-widget__tooltip__visible"),setTimeout(async()=>{this.tooltip.classList.remove("pushwoosh-subscribe-widget__tooltip__visible"),t.innerText=await this.tooltipTextFactory(),this.widget.classList.add("pushwoosh-subscribe-widget__subscribed")},2e3))}async onPermissionDeniedEvent(){this.addEventListeners();const t=this.tooltip.querySelector("div");null!==t&&(t.innerText=await this.tooltipTextFactory())}clickOutOfPopover(t){this.popover.classList.contains("pushwoosh-subscribe-widget__popover__visible")&&!t.target.classList.contains("pushwoosh-subscribe-widget__popover")&&null===t.target.closest(".pushwoosh-subscribe-widget__popover")&&!t.target.classList.contains("pushwoosh-subscribe-widget__bell-button")&&null===t.target.closest(".pushwoosh-subscribe-widget__bell-button")&&this.popover.classList.remove("pushwoosh-subscribe-widget__popover__visible")}async onUnsubscribeEvent(){const t=this.tooltip.querySelector("div");null!==t&&(t.innerText=await this.tooltipTextFactory())}}return e})());
2
2
  //# sourceMappingURL=widget-subscription-button.js.map