web-push-notifications 3.45.2 → 3.46.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/widget-inbox.js CHANGED
@@ -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 n=e();for(var i in n)("object"==typeof exports?exports:t)[i]=n[i]}}(this,(()=>(()=>{"use strict";var t={d:(e,n)=>{for(var i in n)t.o(n,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:n[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{PWInboxWidget:()=>a});const n=["Jan","Feb","Mar","Apr","May","June","July","Aug","Sept","Oct","Nov","Dec"],i=[{name:"widgetWidth",type:"size"},{name:"borderRadius",type:"size"},{name:"zIndex",type:"number"},{name:"fontFamily",type:"string"},{name:"bgColor",type:"color"},{name:"textColor",type:"color"},{name:"arrowBorderColor",type:"color"},{name:"borderColor",type:"color"},{name:"badgeBgColor",type:"color"},{name:"badgeTextColor",type:"color"},{name:"timeTextColor",type:"color"},{name:"messageTitleColor",type:"color"},{name:"emptyInboxTitleColor",type:"color"},{name:"emptyInboxTextColor",type:"color"}],o={enable:!1,triggerId:"pwInbox",position:"bottom",appendTo:"body",title:"Inbox",bgColor:"#ffffff",textColor:"#333333",fontFamily:"inherit",borderRadius:4,borderColor:"transparent",badgeBgColor:"#ff4c00",badgeTextColor:"#ffffff",widgetWidth:350,zIndex:100,messageTitleColor:"#7a7a7a",timeTextColor:"#c4c4c4",emptyInboxTitle:"You're all caught up",emptyInboxTitleColor:"#333333",emptyInboxText:"There are no new messages. Stay tuned!",emptyInboxTextColor:"#7a7a7a",emptyInboxIconUrl:"https://pushon.pushwoosh.com/static/icon-empty-inbox.png",arrowBorderColor:"rgba(0,0,0,.1)"},s=/^(#([\da-f]{3}){1,2}$|(rgb|hsl)a\((\d{1,3}%?,\s?){3}(1|0?\.\d+)\)$|(rgb|hsl)\(\d{1,3}%?(,\s?\d{1,3}%?){2}\)$)/;function r(t){let e="fixed"===window.getComputedStyle(t).position;return!e&&t.parentElement&&(e=r(t.parentElement)),e}const d=({imageUrl:t,title:e,message:i,sendDate:o})=>`\n<div class="pw-inbox_item-inner">\n <div class="pw-inbox_icon">\n <img src="${t}" alt="${e||i}" class="pw-inbox_message-image">\n </div>\n <div class="pw-inbox_content">\n ${e?`<div class="pw-inbox_item-title">\n ${e}\n </div>`:null}\n <div class="pw-inbox_item-body">\n ${i}\n </div>\n <div class="pw-inbox_item-time">\n ${function(t){const e=new Date(t),i=e.getHours()+e.getTimezoneOffset()/60;e.setHours(i);const o=(new Date).getTime()-e.getTime();if(o<=6e4)return"Just now";if(o<36e5&&o>0)return`${Math.floor(o/6e4)} minutes ago`;if(o<864e5&&o>0)return`${Math.floor(o/36e5)} hours ago`;return`${e.getDate()} ${n[e.getMonth()]} ${e.getFullYear()}, ${e.getHours()}:${`0${e.getMinutes().toString()}`.slice(-2)}`}(o)}\n </div>\n </div>\n</div>\n<span class="pw-inbox_item-remove"></span>`;class a{constructor(t){this.pw=t;const e=this.pw.initParams.inboxWidget;this.config={...o,arrowBorderColor:e.borderColor&&"transparent"!==e.borderColor?e.borderColor:"rgba(0,0,0,.1)",...this.pw.initParams.inboxWidget},this.updateInbox=this.updateInbox.bind(this),this.markVisibleItemsAsRead=this.markVisibleItemsAsRead.bind(this),this.onWidgetClickHandler=this.onWidgetClickHandler.bind(this),this.onTriggerClickHandler=this.onTriggerClickHandler.bind(this),this.onWindowScrollHandler=this.onWindowScrollHandler.bind(this),this.toggle=this.toggle.bind(this)}async run(){this.initTrigger(),this.updateInbox(),this.addListeners()}toggle(t){(void 0===t?!this.isOpened:t)?this.openWidget():this.closeWidget()}initTrigger(){if(!this.pw.pwinbox)throw new Error("Web inbox is not allowed.");const t=document.getElementById(this.config.triggerId);if(!t)throw new Error("Inbox trigger element doesn't exist. You must set triggerId in inboxWidget config. See the documentation.");this.trigger=t,this.trigger.classList.add("pw-inbox-trigger"),this.defaultMargin=12,this.messagesElements={},this.messages=[],this.readItems=[],this.updateCounter(0),this.isOpened=!1,this.renderWidget(),this.isFixed=r(this.trigger)}renderWidget(){this.widget=document.createElement("div"),this.widget.id="pwInboxWidget",this.widget.className="pw-inbox-widget",this.widget.classList.toggle("pw-open",this.isOpened),this.widgetParent=document.querySelector(this.config.appendTo)||document.body,this.widgetParent.appendChild(this.widget),this.widgetParent.appendChild(this.getStyle()),this.renderWidgetInner()}getStyle(){const t=document.createElement("style");return t.innerHTML=this.configureStyle(".pw-inbox-trigger {\n position: relative;\n cursor: pointer;\n}\n\n.pw-inbox-trigger:after {\n content: attr(data-pw-count);\n display: block;\n position: absolute;\n right: 0;\n top: 0;\n background: var(--badgeBgColor);\n border-radius: 8px;\n color: var(--badgeTextColor);\n font-size: 10px;\n font-weight: normal;\n line-height: 16px;\n width: 16px;\n padding: 0 2px;\n box-sizing: border-box;\n text-align: center;\n}\n\n.pw-inbox-trigger.pw-empty:after {\n display: none;\n}\n\n.pw-inbox-widget * {\n position: static;\n box-sizing: border-box;\n font-size: 1em;\n outline: none;\n font-family: var(--fontFamily);\n}\n.pw-inbox-widget {\n font-size: 14px;\n position: absolute;\n top: 0;\n left: -1000px;\n background: var(--bgColor);\n border: solid 1px var(--borderColor);\n border-radius: var(--borderRadius);\n width: var(--widgetWidth);\n box-shadow: 0 1px 4px 0 rgba(0,0,0,.25);\n z-index: var(--zIndex);\n opacity: 0;\n transition: opacity .6s ease;\n transition-delay: 100ms;\n}\n.pw-inbox-widget.pw-open {\n opacity: 1;\n transition-delay: 0ms;\n}\n.pw-inbox-widget.pw-inbox-widget--inset {\n top: auto;\n left: auto;\n display: none;\n}\n.pw-inbox-widget.pw-inbox-widget--inset.pw-open {\n display: block;\n}\n.pw-inbox-widget.pw-inbox-widget--inset.pw-bottom {\n top: 100%;\n left: 50%;\n transform: translateX(-50%);\n}\n.pw-inbox-widget.pw-inbox-widget--inset.pw-top {\n bottom: 100%;\n left: 50%;\n transform: translateX(-50%);\n}\n.pw-inbox-widget.pw-inbox-widget--inset.pw-right {\n left: 100%;\n top: 50%;\n transform: translateY(-50%);\n}\n.pw-inbox-widget.pw-inbox-widget--inset.pw-left {\n right: 100%;\n top: 50%;\n transform: translateY(-50%);\n}\n.pw-inbox-widget.pw-inbox-widget--empty {\n max-height: none;\n}\n.pw-inbox-widget .pw-inbox__arrow {\n display: block;\n width: 0;\n height: 0;\n border-width: 10px;\n border-style: solid;\n border-color: transparent;\n position: absolute;\n}\n.pw-inbox-widget .pw-inbox__arrow:before {\n content: \"\";\n display: block;\n width: 0;\n height: 0;\n border-width: 10px;\n border-style: solid;\n border-color: transparent;\n position: absolute;\n}\n.pw-inbox-widget.pw-top {\n margin-top: -12px;\n}\n.pw-inbox-widget.pw-top .pw-inbox__arrow {\n border-top-color: var(--arrowBorderColor);\n bottom: -21px;\n left: 50%;\n transform: translateX(-50%);\n}\n.pw-inbox-widget.pw-top .pw-inbox__arrow:before {\n border-top-color: var(--bgColor);\n top: -11px;\n left: -10px;\n}\n.pw-inbox-widget.pw-bottom {\n margin-top: 12px;\n}\n.pw-inbox-widget.pw-bottom .pw-inbox__arrow {\n border-bottom-color: var(--arrowBorderColor);\n top: -21px;\n left: 50%;\n transform: translateX(-50%);\n}\n.pw-inbox-widget.pw-bottom .pw-inbox__arrow:before {\n border-bottom-color: var(--bgColor);\n bottom: -11px;\n left: -10px;\n}\n.pw-inbox-widget.pw-left {\n margin-left: -12px;\n}\n.pw-inbox-widget.pw-left .pw-inbox__arrow {\n border-left-color: var(--arrowBorderColor);\n right: -21px;\n top: 50%;\n transform: translateY(-50%);\n}\n.pw-inbox-widget.pw-left .pw-inbox__arrow:before {\n border-left-color: var(--bgColor);\n left: -11px;\n top: -10px;\n}\n.pw-inbox-widget.pw-right {\n margin-left: 12px;\n}\n.pw-inbox-widget.pw-right .pw-inbox__arrow {\n border-right-color: var(--arrowBorderColor);\n left: -21px;\n top: 50%;\n transform: translateY(-50%);\n}\n.pw-inbox-widget.pw-right .pw-inbox__arrow:before {\n border-right-color: var(--bgColor);\n right: -11px;\n top: -10px;\n}\n.pw-inbox_inner {\n overflow: hidden;\n display: flex;\n flex-direction: column;\n height: 100%;\n}\n.pw-inbox_title {\n color: var(--textColor);\n margin: 0;\n padding: 28px 32px 12px;\n font-size: 24px;\n font-weight: 500;\n line-height: 1.1;\n text-align: left;\n flex: 0 0 66px;\n}\n.pw-inbox_list {\n overflow-x: hidden;\n overflow-y: auto;\n min-width: 200px;\n max-height: 300px;\n padding: 0;\n margin: 0;\n list-style: none;\n position: relative;\n flex: 1 1 auto;\n}\n\n.pw-inbox_item {\n position: relative;\n padding: 8px 32px;\n margin: 0;\n text-align: left;\n}\n.pw-inbox_item-inner {\n display: flex;\n cursor: pointer;\n}\n.pw-inbox_icon {\n flex: 0 0 40px;\n}\n.pw-inbox_message-image {\n width: 28px;\n}\n.pw-inbox_content {\n flex: 0 1 100%;\n}\n.pw-inbox_item-title {\n color: var(--messageTitleColor);\n font-size: 14px;\n line-height: 20px;\n margin-bottom: 4px;\n}\n.pw-inbox_item-body {\n color: var(--textColor);\n font-size: 14px;\n line-height: 20px;\n margin-bottom: 4px;\n}\n.pw-inbox_item-time {\n color: var(--timeTextColor);\n font-size: 12px;\n line-height: 17px;\n}\n.pw-inbox_item-remove {\n position: absolute;\n z-index: 2;\n top: 8px;\n right: 8px;\n display: none;\n width: 10px;\n height: 10px;\n background: transparent url('https://cdn.pushwoosh.com/webpush/img/iconClose.svg') 50% no-repeat;\n cursor: pointer;\n}\n.pw-inbox_item:hover .pw-inbox_item-remove {\n display: block;\n}\n\n.pw-inbox_item.pw-new .pw-inbox_item-title {\n color: var(--textColor);\n font-weight: 700;\n}\n\n.pw-inbox_item.pw-new .pw-inbox_item-body {\n font-weight: 700;\n}\n\n.pw-inbox_list--empty {\n padding: 50px 16px;\n text-align: center;\n max-height: 100%;\n overflow: auto;\n}\n\n.pw-inbox_list--empty .pw-inbox_list-icon {\n text-align: center;\n margin-bottom: 30px;\n}\n.pw-inbox_list--empty .pw-inbox_list-icon img {\n max-width: 100%;\n}\n\n.pw-inbox_list--empty .pw-inbox_list-title {\n font-size: 28px;\n line-height: 36px;\n color: var(--emptyInboxTitleColor);\n margin-bottom: 20px;\n}\n\n.pw-inbox_list--empty .ipw-inbox_list-body {\n font-size: 14px;\n line-height: 18px;\n color: var(--emptyInboxTextColor);\n}\n"),t}configureStyle(t){let e=t.toString();return i.forEach((t=>{const n=new RegExp(`var\\(--${t.name}\\)`,"ig"),i=this.getStyleFormatter(t);e=e.replace(n,i)})),e}getStyleFormatter(t){switch(t.type){case"size":return`${this.config[t.name]||0}px`;case"number":return parseFloat(this.config[t.name].toString()).toString();case"string":return this.config[t.name].toString();case"color":return"transparent"===(e=this.config[t.name].toString())||s.test(e)?e:"#333";default:return"none"}var e}renderWidgetInner(){if(this.messages.length>0)this.widget.classList.remove("pw-inbox-widget--empty"),this.widget.innerHTML=`\n<div class="pw-inbox__arrow"></div>\n<div class="pw-inbox_inner">\n <div class="pw-inbox_title">\n ${this.config.title}\n </div>\n <ul class="pw-inbox_list">\n\n </ul>\n</div>`,this.renderMessages();else{this.widget.classList.add("pw-inbox-widget--empty");const{emptyInboxTitle:t,emptyInboxText:e,emptyInboxIconUrl:n}=this.config;this.widget.innerHTML=((t,e,n)=>`\n<div class="pw-inbox__arrow"></div>\n<div class="pw-inbox_list--empty">\n <div class="pw-inbox_list-icon">\n <img src="${t}" alt="${e}">\n </div>\n <div class="pw-inbox_list-title">\n ${e}\n </div>\n <div class="ipw-inbox_list-body">\n ${n}\n </div>\n</div>`)(n,t,e)}}renderMessages(){this.list=this.widget.querySelector(".pw-inbox_list")||document.createElement("ul"),this.messages.forEach((t=>{const e=document.createElement("li");e.className="pw-inbox_item",e.classList.toggle("pw-new",!t.isRead),e.classList.toggle("pw-unread",!t.isActionPerformed),e.setAttribute("data-pw-inbox-message-id",t.code),e.innerHTML=d(t),this.list.appendChild(e),this.messagesElements[t.code]=e}))}updateCounter(t){this.count=t,this.trigger.setAttribute("data-pw-count",`${this.count}`),this.trigger.classList.toggle("pw-empty",0===this.count)}updateInboxMessages(t){this.messages=t.sort((({sendDate:t},{sendDate:e})=>function(t,e){const n=new Date(t),i=n.getHours()+n.getTimezoneOffset()/60,o=new Date(e),s=o.getHours()+o.getTimezoneOffset()/60;return n.setHours(i),o.setHours(s),o.getTime()-n.getTime()}(t,e))),this.renderWidgetInner()}openWidget(){this.isOpened=!0,this.widget.classList.add("pw-open"),document.addEventListener("click",this.onWidgetClickHandler),window.addEventListener("scroll",this.onWindowScrollHandler),window.addEventListener("resize",this.onWindowScrollHandler),this.markVisibleItemsAsRead(),this.messages.length>0&&this.list.addEventListener("scroll",this.markVisibleItemsAsRead),this.positionWidget()}closeWidget(){this.isOpened=!1,document.removeEventListener("click",this.onWidgetClickHandler),document.removeEventListener("click",this.onWindowScrollHandler),window.removeEventListener("resize",this.onWindowScrollHandler),this.updateReadStatus(),this.messages.length>0&&this.list.removeEventListener("scroll",this.markVisibleItemsAsRead),this.widget.classList.remove("pw-open","pw-top","pw-bottom","pw-right","pw-left"),this.widget.removeAttribute("style")}positionWidget(){this.isOpened&&(this.widgetParent===document.body?this.defaultPlaceWidget():this.customPlaceWidget())}customPlaceWidget(){const{position:t}=this.config;this.widgetParent.style.position="relative",this.widget.classList.add("pw-inbox-widget--inset"),this.widget.classList.add(`pw-${t}`)}defaultPlaceWidget(){const t=this.pw.initParams.inboxWidget.position?this.config.position:this.getDefaultPosition(),e=this.widget.getBoundingClientRect();if(!document.documentElement)return;const n=Math.max(document.documentElement.clientWidth,window.innerWidth||0),i=Math.max(document.documentElement.clientHeight,window.innerHeight||0);switch(e.width+2*this.defaultMargin>n&&(this.widget.style.width=n-2*this.defaultMargin+"px"),e.height+24>i&&(this.widget.style.height=i-2*this.defaultMargin+"px"),t){case"top":this.alignWidgetTop();break;case"right":this.alignWidgetRight();break;case"left":this.alignWidgetLeft();break;case"bottom":this.alignWidgetBottom()}}alignWidgetTop(){const t=this.trigger.getBoundingClientRect(),e=this.widget.getBoundingClientRect();if(!document.documentElement)return;const n=Math.max(document.documentElement.clientWidth,window.innerWidth||0),i=this.widget.querySelector(".pw-inbox__arrow")||document.createElement("div");this.widget.classList.add("pw-top");let o=pageXOffset+t.left+Math.floor(t.width/2)-Math.floor(e.width/2);const s=o<pageXOffset,r=o+e.width>pageXOffset+n;s&&(o=pageXOffset+this.defaultMargin),r&&(o=pageXOffset+n-e.width-this.defaultMargin);const d=pageYOffset+t.top-e.height;this.alignWidgetElement(o,d),i.style.left=t.left+Math.floor(t.width/2)-o+"px";const a=this.widget.getBoundingClientRect().top;if(a<0){const t=this.widget.getBoundingClientRect().height+a-this.defaultMargin,e=this.widget.getBoundingClientRect().top-a+this.defaultMargin;this.widget.style.height=`${t}px`,this.widget.style.top=`${e}px`}}alignWidgetRight(){const t=this.trigger.getBoundingClientRect(),e=this.widget.getBoundingClientRect();if(!document.documentElement)return;const n=Math.max(document.documentElement.clientWidth,window.innerWidth||0),i=Math.max(document.documentElement.clientHeight,window.innerHeight||0),o=this.widget.querySelector(".pw-inbox__arrow")||document.createElement("div");this.widget.classList.add("pw-right");let s=pageYOffset+t.top+Math.floor(t.height/2)-Math.floor(e.height/2);const r=s<pageYOffset,d=pageYOffset+i<s+e.height;r&&(s=pageYOffset+this.defaultMargin),d&&(s=pageYOffset+i-e.height-this.defaultMargin);const a=pageXOffset+t.left+t.width;this.alignWidgetElement(a,s),o.style.top=t.top+Math.floor(t.height/2)-s+"px";const l=n-this.widget.getBoundingClientRect().right;if(l<this.defaultMargin){const t=this.widget.getBoundingClientRect().width+l-this.defaultMargin;this.widget.style.width=`${t}px`}}alignWidgetLeft(){const t=this.trigger.getBoundingClientRect(),e=this.widget.getBoundingClientRect();if(!document.documentElement)return;const n=Math.max(document.documentElement.clientHeight,window.innerHeight||0),i=this.widget.querySelector(".pw-inbox__arrow")||document.createElement("div");this.widget.classList.add("pw-left");let o=pageYOffset+t.top+Math.floor(t.height/2)-Math.floor(e.height/2);const s=o<pageYOffset,r=pageYOffset+n<o+e.height;s&&(o=pageYOffset+this.defaultMargin),r&&(o=pageYOffset+n-e.height-this.defaultMargin);const d=pageXOffset+t.left-e.width;this.alignWidgetElement(d,o),i.style.top=t.top+Math.floor(t.height/2)-o+"px";const a=this.widget.getBoundingClientRect().left;if(a<0){const t=this.widget.getBoundingClientRect().width+a-this.defaultMargin,e=this.widget.getBoundingClientRect().left-a;this.widget.style.width=`${t}px`,this.widget.style.left=`${e}px`}}alignWidgetBottom(){const t=this.trigger.getBoundingClientRect(),e=this.widget.getBoundingClientRect();if(!document.documentElement)return;const n=Math.max(document.documentElement.clientWidth,window.innerWidth||0),i=Math.max(document.documentElement.clientHeight,window.innerHeight||0),o=this.widget.querySelector(".pw-inbox__arrow")||document.createElement("div");this.widget.classList.add("pw-bottom");let s=pageXOffset+t.left+Math.floor(t.width/2)-Math.floor(e.width/2);const r=s<pageXOffset,d=s+e.width>pageXOffset+n;r&&(s=pageXOffset+this.defaultMargin),d&&(s=pageXOffset+n-e.width-12);const a=pageYOffset+t.top+t.height;this.alignWidgetElement(s,a),o.style.left=t.left+Math.floor(t.width/2)-s+"px";const l=i-this.widget.getBoundingClientRect().bottom;if(l<this.defaultMargin){const t=this.widget.getBoundingClientRect().height+l-this.defaultMargin;this.widget.style.height=`${t}px`}}alignWidgetElement(t,e){this.widget.style.left=`${t}px`,this.widget.style.top=`${e}px`}getDefaultPosition(){const{left:t,top:e,width:n,height:i}=this.trigger.getBoundingClientRect();if(!document.documentElement)return"";const o={right:t,bottom:e,left:Math.max(document.documentElement.clientWidth,window.innerWidth||0)-(t+n),top:Math.max(document.documentElement.clientHeight,window.innerHeight||0)-(e+i)},s=Math.min(t,e,o.left,o.top);let r="bottom";return Object.keys(o).forEach((t=>{o[t]===s&&(r=t)})),r}addListeners(){this.trigger.addEventListener("click",this.onTriggerClickHandler),this.pw.push(["onPutNewMessageToInboxStore",()=>{this.updateInbox()}]),this.pw.push(["onUpdateInboxMessages",()=>{this.updateInbox()}])}markVisibleItemsAsRead(){if(0===this.messages.length)return;const t=this.list.clientHeight+this.list.scrollTop-50;Object.keys(this.messagesElements).forEach((e=>{if(!this.messagesElements[e]||this.messagesElements[e].offsetTop>t)return;const n=this.messages.find((t=>t.code===e));!n||n.isRead||this.readItems.indexOf(e)+1||this.readItems.push(e)}))}updateReadStatus(){this.pw.pwinbox.readMessagesWithCodes(this.readItems).then(this.updateInbox)}updateInbox(){this.pw.pwinbox.loadMessages().then((t=>{this.updateInboxMessages(t)})),this.pw.pwinbox.unreadMessagesCount().then((t=>{this.updateCounter(t)}))}performMessageAction(t){this.pw.pwinbox.performActionForMessageWithCode(t).then((()=>{this.updateInbox()}))}removeMessages(t){t.forEach((t=>{this.readItems=this.readItems.slice(this.readItems.indexOf(t),1)})),this.pw.pwinbox.deleteMessagesWithCodes(t).then((()=>{this.updateInbox()}))}onTriggerClickHandler(t){t.stopPropagation(),t.target&&this.toggle()}onWidgetClickHandler(t){if(!t.target)return;const e=t.target.closest(".pw-inbox_item");if(!e)return void this.toggle();const n=e.getAttribute("data-pw-inbox-message-id");if(!n)return;t.target.closest(".pw-inbox_item-remove")?this.removeMessages([n]):this.performMessageAction(n)}onWindowScrollHandler(){this.isFixed&&this.isOpened?this.toggle():this.positionWidget()}}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 n=e();for(var i in n)("object"==typeof exports?exports:t)[i]=n[i]}}(this,()=>(()=>{"use strict";var t={d:(e,n)=>{for(var i in n)t.o(n,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:n[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{PWInboxWidget:()=>a});const n=["Jan","Feb","Mar","Apr","May","June","July","Aug","Sept","Oct","Nov","Dec"],i=[{name:"widgetWidth",type:"size"},{name:"borderRadius",type:"size"},{name:"zIndex",type:"number"},{name:"fontFamily",type:"string"},{name:"bgColor",type:"color"},{name:"textColor",type:"color"},{name:"arrowBorderColor",type:"color"},{name:"borderColor",type:"color"},{name:"badgeBgColor",type:"color"},{name:"badgeTextColor",type:"color"},{name:"timeTextColor",type:"color"},{name:"messageTitleColor",type:"color"},{name:"emptyInboxTitleColor",type:"color"},{name:"emptyInboxTextColor",type:"color"}],o={enable:!1,triggerId:"pwInbox",position:"bottom",appendTo:"body",title:"Inbox",bgColor:"#ffffff",textColor:"#333333",fontFamily:"inherit",borderRadius:4,borderColor:"transparent",badgeBgColor:"#ff4c00",badgeTextColor:"#ffffff",widgetWidth:350,zIndex:100,messageTitleColor:"#7a7a7a",timeTextColor:"#c4c4c4",emptyInboxTitle:"You're all caught up",emptyInboxTitleColor:"#333333",emptyInboxText:"There are no new messages. Stay tuned!",emptyInboxTextColor:"#7a7a7a",emptyInboxIconUrl:"https://pushon.pushwoosh.com/static/icon-empty-inbox.png",arrowBorderColor:"rgba(0,0,0,.1)"},s=/^(#([\da-f]{3}){1,2}$|(rgb|hsl)a\((\d{1,3}%?,\s?){3}(1|0?\.\d+)\)$|(rgb|hsl)\(\d{1,3}%?(,\s?\d{1,3}%?){2}\)$)/;function r(t){let e="fixed"===window.getComputedStyle(t).position;return!e&&t.parentElement&&(e=r(t.parentElement)),e}const d=({imageUrl:t,title:e,message:i,sendDate:o})=>`\n<div class="pw-inbox_item-inner">\n <div class="pw-inbox_icon">\n <img src="${t}" alt="${e||i}" class="pw-inbox_message-image">\n </div>\n <div class="pw-inbox_content">\n ${e?`<div class="pw-inbox_item-title">\n ${e}\n </div>`:null}\n <div class="pw-inbox_item-body">\n ${i}\n </div>\n <div class="pw-inbox_item-time">\n ${function(t){const e=new Date(t),i=e.getHours()+e.getTimezoneOffset()/60;e.setHours(i);const o=(new Date).getTime()-e.getTime();if(o<=6e4)return"Just now";if(o<36e5&&o>0)return`${Math.floor(o/6e4)} minutes ago`;if(o<864e5&&o>0)return`${Math.floor(o/36e5)} hours ago`;return`${e.getDate()} ${n[e.getMonth()]} ${e.getFullYear()}, ${e.getHours()}:${`0${e.getMinutes().toString()}`.slice(-2)}`}(o)}\n </div>\n </div>\n</div>\n<span class="pw-inbox_item-remove"></span>`;class a{constructor(t){this.pw=t;const e=this.pw.initParams.inboxWidget;this.config={...o,arrowBorderColor:e.borderColor&&"transparent"!==e.borderColor?e.borderColor:"rgba(0,0,0,.1)",...this.pw.initParams.inboxWidget},this.updateInbox=this.updateInbox.bind(this),this.markVisibleItemsAsRead=this.markVisibleItemsAsRead.bind(this),this.onWidgetClickHandler=this.onWidgetClickHandler.bind(this),this.onTriggerClickHandler=this.onTriggerClickHandler.bind(this),this.onWindowScrollHandler=this.onWindowScrollHandler.bind(this),this.toggle=this.toggle.bind(this)}async run(){this.initTrigger(),this.updateInbox(),this.addListeners()}toggle(t){(void 0===t?!this.isOpened:t)?this.openWidget():this.closeWidget()}initTrigger(){if(!this.pw.pwinbox)throw new Error("Web inbox is not allowed.");const t=document.getElementById(this.config.triggerId);if(!t)throw new Error("Inbox trigger element doesn't exist. You must set triggerId in inboxWidget config. See the documentation.");this.trigger=t,this.trigger.classList.add("pw-inbox-trigger"),this.defaultMargin=12,this.messagesElements={},this.messages=[],this.readItems=[],this.updateCounter(0),this.isOpened=!1,this.renderWidget(),this.isFixed=r(this.trigger)}renderWidget(){this.widget=document.createElement("div"),this.widget.id="pwInboxWidget",this.widget.className="pw-inbox-widget",this.widget.classList.toggle("pw-open",this.isOpened),this.widgetParent=document.querySelector(this.config.appendTo)||document.body,this.widgetParent.appendChild(this.widget),this.widgetParent.appendChild(this.getStyle()),this.renderWidgetInner()}getStyle(){const t=document.createElement("style");return t.innerHTML=this.configureStyle(".pw-inbox-trigger {\n position: relative;\n cursor: pointer;\n}\n\n.pw-inbox-trigger:after {\n content: attr(data-pw-count);\n display: block;\n position: absolute;\n right: 0;\n top: 0;\n background: var(--badgeBgColor);\n border-radius: 8px;\n color: var(--badgeTextColor);\n font-size: 10px;\n font-weight: normal;\n line-height: 16px;\n width: 16px;\n padding: 0 2px;\n box-sizing: border-box;\n text-align: center;\n}\n\n.pw-inbox-trigger.pw-empty:after {\n display: none;\n}\n\n.pw-inbox-widget * {\n position: static;\n box-sizing: border-box;\n font-size: 1em;\n outline: none;\n font-family: var(--fontFamily);\n}\n.pw-inbox-widget {\n font-size: 14px;\n position: absolute;\n top: 0;\n left: -1000px;\n background: var(--bgColor);\n border: solid 1px var(--borderColor);\n border-radius: var(--borderRadius);\n width: var(--widgetWidth);\n box-shadow: 0 1px 4px 0 rgba(0,0,0,.25);\n z-index: var(--zIndex);\n opacity: 0;\n transition: opacity .6s ease;\n transition-delay: 100ms;\n}\n.pw-inbox-widget.pw-open {\n opacity: 1;\n transition-delay: 0ms;\n}\n.pw-inbox-widget.pw-inbox-widget--inset {\n top: auto;\n left: auto;\n display: none;\n}\n.pw-inbox-widget.pw-inbox-widget--inset.pw-open {\n display: block;\n}\n.pw-inbox-widget.pw-inbox-widget--inset.pw-bottom {\n top: 100%;\n left: 50%;\n transform: translateX(-50%);\n}\n.pw-inbox-widget.pw-inbox-widget--inset.pw-top {\n bottom: 100%;\n left: 50%;\n transform: translateX(-50%);\n}\n.pw-inbox-widget.pw-inbox-widget--inset.pw-right {\n left: 100%;\n top: 50%;\n transform: translateY(-50%);\n}\n.pw-inbox-widget.pw-inbox-widget--inset.pw-left {\n right: 100%;\n top: 50%;\n transform: translateY(-50%);\n}\n.pw-inbox-widget.pw-inbox-widget--empty {\n max-height: none;\n}\n.pw-inbox-widget .pw-inbox__arrow {\n display: block;\n width: 0;\n height: 0;\n border-width: 10px;\n border-style: solid;\n border-color: transparent;\n position: absolute;\n}\n.pw-inbox-widget .pw-inbox__arrow:before {\n content: \"\";\n display: block;\n width: 0;\n height: 0;\n border-width: 10px;\n border-style: solid;\n border-color: transparent;\n position: absolute;\n}\n.pw-inbox-widget.pw-top {\n margin-top: -12px;\n}\n.pw-inbox-widget.pw-top .pw-inbox__arrow {\n border-top-color: var(--arrowBorderColor);\n bottom: -21px;\n left: 50%;\n transform: translateX(-50%);\n}\n.pw-inbox-widget.pw-top .pw-inbox__arrow:before {\n border-top-color: var(--bgColor);\n top: -11px;\n left: -10px;\n}\n.pw-inbox-widget.pw-bottom {\n margin-top: 12px;\n}\n.pw-inbox-widget.pw-bottom .pw-inbox__arrow {\n border-bottom-color: var(--arrowBorderColor);\n top: -21px;\n left: 50%;\n transform: translateX(-50%);\n}\n.pw-inbox-widget.pw-bottom .pw-inbox__arrow:before {\n border-bottom-color: var(--bgColor);\n bottom: -11px;\n left: -10px;\n}\n.pw-inbox-widget.pw-left {\n margin-left: -12px;\n}\n.pw-inbox-widget.pw-left .pw-inbox__arrow {\n border-left-color: var(--arrowBorderColor);\n right: -21px;\n top: 50%;\n transform: translateY(-50%);\n}\n.pw-inbox-widget.pw-left .pw-inbox__arrow:before {\n border-left-color: var(--bgColor);\n left: -11px;\n top: -10px;\n}\n.pw-inbox-widget.pw-right {\n margin-left: 12px;\n}\n.pw-inbox-widget.pw-right .pw-inbox__arrow {\n border-right-color: var(--arrowBorderColor);\n left: -21px;\n top: 50%;\n transform: translateY(-50%);\n}\n.pw-inbox-widget.pw-right .pw-inbox__arrow:before {\n border-right-color: var(--bgColor);\n right: -11px;\n top: -10px;\n}\n.pw-inbox_inner {\n overflow: hidden;\n display: flex;\n flex-direction: column;\n height: 100%;\n}\n.pw-inbox_title {\n color: var(--textColor);\n margin: 0;\n padding: 28px 32px 12px;\n font-size: 24px;\n font-weight: 500;\n line-height: 1.1;\n text-align: left;\n flex: 0 0 66px;\n}\n.pw-inbox_list {\n overflow-x: hidden;\n overflow-y: auto;\n min-width: 200px;\n max-height: 300px;\n padding: 0;\n margin: 0;\n list-style: none;\n position: relative;\n flex: 1 1 auto;\n}\n\n.pw-inbox_item {\n position: relative;\n padding: 8px 32px;\n margin: 0;\n text-align: left;\n}\n.pw-inbox_item-inner {\n display: flex;\n cursor: pointer;\n}\n.pw-inbox_icon {\n flex: 0 0 40px;\n}\n.pw-inbox_message-image {\n width: 28px;\n}\n.pw-inbox_content {\n flex: 0 1 100%;\n}\n.pw-inbox_item-title {\n color: var(--messageTitleColor);\n font-size: 14px;\n line-height: 20px;\n margin-bottom: 4px;\n}\n.pw-inbox_item-body {\n color: var(--textColor);\n font-size: 14px;\n line-height: 20px;\n margin-bottom: 4px;\n}\n.pw-inbox_item-time {\n color: var(--timeTextColor);\n font-size: 12px;\n line-height: 17px;\n}\n.pw-inbox_item-remove {\n position: absolute;\n z-index: 2;\n top: 8px;\n right: 8px;\n display: none;\n width: 10px;\n height: 10px;\n background: transparent url('https://cdn.pushwoosh.com/webpush/img/iconClose.svg') 50% no-repeat;\n cursor: pointer;\n}\n.pw-inbox_item:hover .pw-inbox_item-remove {\n display: block;\n}\n\n.pw-inbox_item.pw-new .pw-inbox_item-title {\n color: var(--textColor);\n font-weight: 700;\n}\n\n.pw-inbox_item.pw-new .pw-inbox_item-body {\n font-weight: 700;\n}\n\n.pw-inbox_list--empty {\n padding: 50px 16px;\n text-align: center;\n max-height: 100%;\n overflow: auto;\n}\n\n.pw-inbox_list--empty .pw-inbox_list-icon {\n text-align: center;\n margin-bottom: 30px;\n}\n.pw-inbox_list--empty .pw-inbox_list-icon img {\n max-width: 100%;\n}\n\n.pw-inbox_list--empty .pw-inbox_list-title {\n font-size: 28px;\n line-height: 36px;\n color: var(--emptyInboxTitleColor);\n margin-bottom: 20px;\n}\n\n.pw-inbox_list--empty .ipw-inbox_list-body {\n font-size: 14px;\n line-height: 18px;\n color: var(--emptyInboxTextColor);\n}\n"),t}configureStyle(t){let e=t.toString();return i.forEach(t=>{const n=new RegExp(`var\\(--${t.name}\\)`,"ig"),i=this.getStyleFormatter(t);e=e.replace(n,i)}),e}getStyleFormatter(t){switch(t.type){case"size":return`${this.config[t.name]||0}px`;case"number":return parseFloat(this.config[t.name].toString()).toString();case"string":return this.config[t.name].toString();case"color":return"transparent"===(e=this.config[t.name].toString())||s.test(e)?e:"#333";default:return"none"}var e}renderWidgetInner(){if(this.messages.length>0)this.widget.classList.remove("pw-inbox-widget--empty"),this.widget.innerHTML=`\n<div class="pw-inbox__arrow"></div>\n<div class="pw-inbox_inner">\n <div class="pw-inbox_title">\n ${this.config.title}\n </div>\n <ul class="pw-inbox_list">\n\n </ul>\n</div>`,this.renderMessages();else{this.widget.classList.add("pw-inbox-widget--empty");const{emptyInboxTitle:t,emptyInboxText:e,emptyInboxIconUrl:n}=this.config;this.widget.innerHTML=((t,e,n)=>`\n<div class="pw-inbox__arrow"></div>\n<div class="pw-inbox_list--empty">\n <div class="pw-inbox_list-icon">\n <img src="${t}" alt="${e}">\n </div>\n <div class="pw-inbox_list-title">\n ${e}\n </div>\n <div class="ipw-inbox_list-body">\n ${n}\n </div>\n</div>`)(n,t,e)}}renderMessages(){this.list=this.widget.querySelector(".pw-inbox_list")||document.createElement("ul"),this.messages.forEach(t=>{const e=document.createElement("li");e.className="pw-inbox_item",e.classList.toggle("pw-new",!t.isRead),e.classList.toggle("pw-unread",!t.isActionPerformed),e.setAttribute("data-pw-inbox-message-id",t.code),e.innerHTML=d(t),this.list.appendChild(e),this.messagesElements[t.code]=e})}updateCounter(t){this.count=t,this.trigger.setAttribute("data-pw-count",`${this.count}`),this.trigger.classList.toggle("pw-empty",0===this.count)}updateInboxMessages(t){this.messages=t.sort(({sendDate:t},{sendDate:e})=>function(t,e){const n=new Date(t),i=n.getHours()+n.getTimezoneOffset()/60,o=new Date(e),s=o.getHours()+o.getTimezoneOffset()/60;return n.setHours(i),o.setHours(s),o.getTime()-n.getTime()}(t,e)),this.renderWidgetInner()}openWidget(){this.isOpened=!0,this.widget.classList.add("pw-open"),document.addEventListener("click",this.onWidgetClickHandler),window.addEventListener("scroll",this.onWindowScrollHandler),window.addEventListener("resize",this.onWindowScrollHandler),this.markVisibleItemsAsRead(),this.messages.length>0&&this.list.addEventListener("scroll",this.markVisibleItemsAsRead),this.positionWidget()}closeWidget(){this.isOpened=!1,document.removeEventListener("click",this.onWidgetClickHandler),document.removeEventListener("click",this.onWindowScrollHandler),window.removeEventListener("resize",this.onWindowScrollHandler),this.updateReadStatus(),this.messages.length>0&&this.list.removeEventListener("scroll",this.markVisibleItemsAsRead),this.widget.classList.remove("pw-open","pw-top","pw-bottom","pw-right","pw-left"),this.widget.removeAttribute("style")}positionWidget(){this.isOpened&&(this.widgetParent===document.body?this.defaultPlaceWidget():this.customPlaceWidget())}customPlaceWidget(){const{position:t}=this.config;this.widgetParent.style.position="relative",this.widget.classList.add("pw-inbox-widget--inset"),this.widget.classList.add(`pw-${t}`)}defaultPlaceWidget(){const t=this.pw.initParams.inboxWidget.position?this.config.position:this.getDefaultPosition(),e=this.widget.getBoundingClientRect();if(!document.documentElement)return;const n=Math.max(document.documentElement.clientWidth,window.innerWidth||0),i=Math.max(document.documentElement.clientHeight,window.innerHeight||0);switch(e.width+2*this.defaultMargin>n&&(this.widget.style.width=n-2*this.defaultMargin+"px"),e.height+24>i&&(this.widget.style.height=i-2*this.defaultMargin+"px"),t){case"top":this.alignWidgetTop();break;case"right":this.alignWidgetRight();break;case"left":this.alignWidgetLeft();break;case"bottom":this.alignWidgetBottom()}}alignWidgetTop(){const t=this.trigger.getBoundingClientRect(),e=this.widget.getBoundingClientRect();if(!document.documentElement)return;const n=Math.max(document.documentElement.clientWidth,window.innerWidth||0),i=this.widget.querySelector(".pw-inbox__arrow")||document.createElement("div");this.widget.classList.add("pw-top");let o=pageXOffset+t.left+Math.floor(t.width/2)-Math.floor(e.width/2);const s=o<pageXOffset,r=o+e.width>pageXOffset+n;s&&(o=pageXOffset+this.defaultMargin),r&&(o=pageXOffset+n-e.width-this.defaultMargin);const d=pageYOffset+t.top-e.height;this.alignWidgetElement(o,d),i.style.left=t.left+Math.floor(t.width/2)-o+"px";const a=this.widget.getBoundingClientRect().top;if(a<0){const t=this.widget.getBoundingClientRect().height+a-this.defaultMargin,e=this.widget.getBoundingClientRect().top-a+this.defaultMargin;this.widget.style.height=`${t}px`,this.widget.style.top=`${e}px`}}alignWidgetRight(){const t=this.trigger.getBoundingClientRect(),e=this.widget.getBoundingClientRect();if(!document.documentElement)return;const n=Math.max(document.documentElement.clientWidth,window.innerWidth||0),i=Math.max(document.documentElement.clientHeight,window.innerHeight||0),o=this.widget.querySelector(".pw-inbox__arrow")||document.createElement("div");this.widget.classList.add("pw-right");let s=pageYOffset+t.top+Math.floor(t.height/2)-Math.floor(e.height/2);const r=s<pageYOffset,d=pageYOffset+i<s+e.height;r&&(s=pageYOffset+this.defaultMargin),d&&(s=pageYOffset+i-e.height-this.defaultMargin);const a=pageXOffset+t.left+t.width;this.alignWidgetElement(a,s),o.style.top=t.top+Math.floor(t.height/2)-s+"px";const l=n-this.widget.getBoundingClientRect().right;if(l<this.defaultMargin){const t=this.widget.getBoundingClientRect().width+l-this.defaultMargin;this.widget.style.width=`${t}px`}}alignWidgetLeft(){const t=this.trigger.getBoundingClientRect(),e=this.widget.getBoundingClientRect();if(!document.documentElement)return;const n=Math.max(document.documentElement.clientHeight,window.innerHeight||0),i=this.widget.querySelector(".pw-inbox__arrow")||document.createElement("div");this.widget.classList.add("pw-left");let o=pageYOffset+t.top+Math.floor(t.height/2)-Math.floor(e.height/2);const s=o<pageYOffset,r=pageYOffset+n<o+e.height;s&&(o=pageYOffset+this.defaultMargin),r&&(o=pageYOffset+n-e.height-this.defaultMargin);const d=pageXOffset+t.left-e.width;this.alignWidgetElement(d,o),i.style.top=t.top+Math.floor(t.height/2)-o+"px";const a=this.widget.getBoundingClientRect().left;if(a<0){const t=this.widget.getBoundingClientRect().width+a-this.defaultMargin,e=this.widget.getBoundingClientRect().left-a;this.widget.style.width=`${t}px`,this.widget.style.left=`${e}px`}}alignWidgetBottom(){const t=this.trigger.getBoundingClientRect(),e=this.widget.getBoundingClientRect();if(!document.documentElement)return;const n=Math.max(document.documentElement.clientWidth,window.innerWidth||0),i=Math.max(document.documentElement.clientHeight,window.innerHeight||0),o=this.widget.querySelector(".pw-inbox__arrow")||document.createElement("div");this.widget.classList.add("pw-bottom");let s=pageXOffset+t.left+Math.floor(t.width/2)-Math.floor(e.width/2);const r=s<pageXOffset,d=s+e.width>pageXOffset+n;r&&(s=pageXOffset+this.defaultMargin),d&&(s=pageXOffset+n-e.width-12);const a=pageYOffset+t.top+t.height;this.alignWidgetElement(s,a),o.style.left=t.left+Math.floor(t.width/2)-s+"px";const l=i-this.widget.getBoundingClientRect().bottom;if(l<this.defaultMargin){const t=this.widget.getBoundingClientRect().height+l-this.defaultMargin;this.widget.style.height=`${t}px`}}alignWidgetElement(t,e){this.widget.style.left=`${t}px`,this.widget.style.top=`${e}px`}getDefaultPosition(){const{left:t,top:e,width:n,height:i}=this.trigger.getBoundingClientRect();if(!document.documentElement)return"";const o={right:t,bottom:e,left:Math.max(document.documentElement.clientWidth,window.innerWidth||0)-(t+n),top:Math.max(document.documentElement.clientHeight,window.innerHeight||0)-(e+i)},s=Math.min(t,e,o.left,o.top);let r="bottom";return Object.keys(o).forEach(t=>{o[t]===s&&(r=t)}),r}addListeners(){this.trigger.addEventListener("click",this.onTriggerClickHandler),this.pw.push(["onPutNewMessageToInboxStore",()=>{this.updateInbox()}]),this.pw.push(["onUpdateInboxMessages",()=>{this.updateInbox()}])}markVisibleItemsAsRead(){if(0===this.messages.length)return;const t=this.list.clientHeight+this.list.scrollTop-50;Object.keys(this.messagesElements).forEach(e=>{if(!this.messagesElements[e]||this.messagesElements[e].offsetTop>t)return;const n=this.messages.find(t=>t.code===e);!n||n.isRead||this.readItems.indexOf(e)+1||this.readItems.push(e)})}updateReadStatus(){this.pw.pwinbox.readMessagesWithCodes(this.readItems).then(this.updateInbox)}updateInbox(){this.pw.pwinbox.loadMessages().then(t=>{this.updateInboxMessages(t)}),this.pw.pwinbox.unreadMessagesCount().then(t=>{this.updateCounter(t)})}performMessageAction(t){this.pw.pwinbox.performActionForMessageWithCode(t).then(()=>{this.updateInbox()})}removeMessages(t){t.forEach(t=>{this.readItems=this.readItems.slice(this.readItems.indexOf(t),1)}),this.pw.pwinbox.deleteMessagesWithCodes(t).then(()=>{this.updateInbox()})}onTriggerClickHandler(t){t.stopPropagation(),t.target&&this.toggle()}onWidgetClickHandler(t){if(!t.target)return;const e=t.target.closest(".pw-inbox_item");if(!e)return void this.toggle();const n=e.getAttribute("data-pw-inbox-message-id");if(!n)return;t.target.closest(".pw-inbox_item-remove")?this.removeMessages([n]):this.performMessageAction(n)}onWindowScrollHandler(){this.isFixed&&this.isOpened?this.toggle():this.positionWidget()}}return e})());
2
2
  //# sourceMappingURL=widget-inbox.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"widget-inbox.js","mappings":"CAAA,SAA2CA,EAAMC,GAChD,GAAsB,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,SACb,GAAqB,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,OACP,CACJ,IAAIK,EAAIL,IACR,IAAI,IAAIM,KAAKD,GAAuB,iBAAZJ,QAAuBA,QAAUF,GAAMO,GAAKD,EAAEC,EACvE,CACA,CATD,CASGC,MAAM,I,mBCRT,IAAIC,EAAsB,CCA1BA,EAAwB,CAACP,EAASQ,KACjC,IAAI,IAAIC,KAAOD,EACXD,EAAoBG,EAAEF,EAAYC,KAASF,EAAoBG,EAAEV,EAASS,IAC5EE,OAAOC,eAAeZ,EAASS,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,MCJ3EF,EAAwB,CAACQ,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFT,EAAyBP,IACH,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ExD,IAAKD,EAEH,YADA1N,KAAKsF,SAIP,MAAMsI,EAAcF,EAAYG,aAAa,4BAE7C,IAAKD,EACH,OAGoCL,EAAME,OAAQE,QAAQ,yBAG1D3N,KAAKqN,eAAe,CAACO,IAIvB5N,KAAKmN,qBAAqBS,EAC5B,CAEQ,qBAAAvI,GACFrF,KAAK+C,SAAW/C,KAAK0F,SACvB1F,KAAKsF,SAGPtF,KAAK0J,gBACP,E","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/Inbox/constants.ts","webpack://web-push-notifications/./src/widgets/Inbox/helpers.ts","webpack://web-push-notifications/./src/widgets/Inbox/widgetTemplates.ts","webpack://web-push-notifications/./src/widgets/Inbox/InboxWidget.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\nvar __webpack_require__ = {};\n\n","// define getter 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\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { type IConfigStyles, type IInboxWidgetConfig } from './inbox_widget.types';\n\nexport const MILLISECONDS_IN_DAY = 60 * 60 * 24 * 1000;\nexport const MILLISECONDS_IN_HOUR = 60 * 60 * 1000;\nexport const MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'June', 'July', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec'];\n\nexport const CONFIG_STYLES: Array<IConfigStyles> = [\n { name: 'widgetWidth', type: 'size' },\n { name: 'borderRadius', type: 'size' },\n { name: 'zIndex', type: 'number' },\n { name: 'fontFamily', type: 'string' },\n { name: 'bgColor', type: 'color' },\n { name: 'textColor', type: 'color' },\n { name: 'arrowBorderColor', type: 'color' },\n { name: 'borderColor', type: 'color' },\n { name: 'badgeBgColor', type: 'color' },\n { name: 'badgeTextColor', type: 'color' },\n { name: 'timeTextColor', type: 'color' },\n { name: 'messageTitleColor', type: 'color' },\n { name: 'emptyInboxTitleColor', type: 'color' },\n { name: 'emptyInboxTextColor', type: 'color' },\n];\n\nexport const DEFAULT_CONFIG: IInboxWidgetConfig = {\n enable: false,\n triggerId: 'pwInbox',\n position: 'bottom',\n appendTo: 'body',\n title: 'Inbox',\n bgColor: '#ffffff',\n textColor: '#333333',\n fontFamily: 'inherit',\n borderRadius: 4,\n borderColor: 'transparent',\n badgeBgColor: '#ff4c00',\n badgeTextColor: '#ffffff',\n widgetWidth: 350,\n zIndex: 100,\n messageTitleColor: '#7a7a7a',\n timeTextColor: '#c4c4c4',\n emptyInboxTitle: 'You\\'re all caught up',\n emptyInboxTitleColor: '#333333',\n emptyInboxText: 'There are no new messages. Stay tuned!',\n emptyInboxTextColor: '#7a7a7a',\n emptyInboxIconUrl: 'https://pushon.pushwoosh.com/static/icon-empty-inbox.png',\n arrowBorderColor: 'rgba(0,0,0,.1)',\n};\n\nexport const COLOR_TEST_REGEXP = /^(#([\\da-f]{3}){1,2}$|(rgb|hsl)a\\((\\d{1,3}%?,\\s?){3}(1|0?\\.\\d+)\\)$|(rgb|hsl)\\(\\d{1,3}%?(,\\s?\\d{1,3}%?){2}\\)$)/;\n","import {\n MILLISECONDS_IN_HOUR,\n MILLISECONDS_IN_DAY,\n MONTHS,\n COLOR_TEST_REGEXP,\n} from './constants';\n\nexport function isElementFixed(element: HTMLElement): boolean {\n let isFixed = window.getComputedStyle(element).position === 'fixed';\n if (!isFixed && element.parentElement) {\n isFixed = isElementFixed(element.parentElement);\n }\n return isFixed;\n}\n\nexport function getMessageTime(date: string): string {\n const localDate = new Date(date);\n const localTime = localDate.getHours() + (localDate.getTimezoneOffset() / 60);\n localDate.setHours(localTime);\n const now = new Date();\n\n const gap = (now.getTime() - localDate.getTime());\n\n if (gap <= 60 * 1000) {\n return `Just now`;\n } else if (gap < MILLISECONDS_IN_HOUR && gap > 0) {\n const minutesAgo = Math.floor(gap / (60 * 1000));\n return `${minutesAgo} minutes ago`;\n } else if (gap < MILLISECONDS_IN_DAY && gap > 0) {\n const hoursAgo = Math.floor(gap / (60 * 60 * 1000));\n return `${hoursAgo} hours ago`;\n }\n\n const day = localDate.getDate();\n const month = MONTHS[localDate.getMonth()];\n const year = localDate.getFullYear();\n const hours = localDate.getHours();\n const minutes = `0${localDate.getMinutes().toString()}`.slice(-2); // padStart(2, 0)\n\n return `${day} ${month} ${year}, ${hours}:${minutes}`;\n}\n\nexport function getValidColor(color: string): string {\n if (color === 'transparent') {\n return color;\n }\n\n return COLOR_TEST_REGEXP.test(color)\n ? color\n : '#333';\n}\n\nexport function compareBySendDate(dateOne: string, dateTwo: string): number {\n const localDateOne = new Date(dateOne);\n const localTimeOne = localDateOne.getHours() + (localDateOne.getTimezoneOffset() / 60);\n const localDateTwo = new Date(dateTwo);\n const localTimeTwo = localDateTwo.getHours() + (localDateTwo.getTimezoneOffset() / 60);\n\n localDateOne.setHours(localTimeOne);\n localDateTwo.setHours(localTimeTwo);\n\n return localDateTwo.getTime() - localDateOne.getTime();\n}\n","import { getMessageTime } from './helpers';\nimport { type IInboxMessagePublic } from '../../models/InboxMessages.types';\n\nexport const widgetTemplate = (title: string): string => `\n<div class=\"pw-inbox__arrow\"></div>\n<div class=\"pw-inbox_inner\">\n <div class=\"pw-inbox_title\">\n ${title}\n </div>\n <ul class=\"pw-inbox_list\">\n\n </ul>\n</div>`;\n\nexport const widgetTemplateEmpty = (\n emptyInboxIconUrl: string,\n emptyInboxTitle: string,\n emptyInboxText: string,\n) => `\n<div class=\"pw-inbox__arrow\"></div>\n<div class=\"pw-inbox_list--empty\">\n <div class=\"pw-inbox_list-icon\">\n <img src=\"${emptyInboxIconUrl}\" alt=\"${emptyInboxTitle}\">\n </div>\n <div class=\"pw-inbox_list-title\">\n ${emptyInboxTitle}\n </div>\n <div class=\"ipw-inbox_list-body\">\n ${emptyInboxText}\n </div>\n</div>`;\n\nexport const messageTemplate = ({\n imageUrl,\n title,\n message,\n sendDate,\n}: IInboxMessagePublic) => `\n<div class=\"pw-inbox_item-inner\">\n <div class=\"pw-inbox_icon\">\n <img src=\"${imageUrl}\" alt=\"${title || message}\" class=\"pw-inbox_message-image\">\n </div>\n <div class=\"pw-inbox_content\">\n ${title ? `<div class=\"pw-inbox_item-title\">\n ${title}\n </div>` : null}\n <div class=\"pw-inbox_item-body\">\n ${message}\n </div>\n <div class=\"pw-inbox_item-time\">\n ${getMessageTime(sendDate)}\n </div>\n </div>\n</div>\n<span class=\"pw-inbox_item-remove\"></span>`;\n","import {\n CONFIG_STYLES,\n DEFAULT_CONFIG,\n} from './constants';\nimport inboxWidgetStyleCss from './css/inboxWidgetStyle.css';\nimport {\n getValidColor,\n isElementFixed,\n compareBySendDate,\n} from './helpers';\nimport { type IConfigStyles, type IInboxWidgetConfig, type TMessagesElementsType } from './inbox_widget.types';\nimport {\n messageTemplate,\n widgetTemplate,\n widgetTemplateEmpty,\n} from './widgetTemplates';\nimport { type Pushwoosh } from '../../core/Pushwoosh';\nimport { type IInboxMessagePublic } from '../../models/InboxMessages.types';\n\nexport class PWInboxWidget {\n pw: Pushwoosh;\n widget: HTMLElement;\n trigger: HTMLElement;\n list: HTMLElement;\n widgetParent: HTMLElement;\n count: number;\n messages: Array<IInboxMessagePublic>;\n messagesElements: TMessagesElementsType;\n readItems: Array<string>;\n isOpened: boolean;\n config: IInboxWidgetConfig;\n defaultMargin: number;\n isFixed: boolean;\n\n constructor(pw: Pushwoosh) {\n // Set Pushwoosh object\n this.pw = pw;\n\n const inboxWidgetConfig = this.pw.initParams.inboxWidget!;\n\n this.config = {\n ...DEFAULT_CONFIG,\n arrowBorderColor: inboxWidgetConfig.borderColor && inboxWidgetConfig.borderColor !== 'transparent'\n ? inboxWidgetConfig.borderColor\n : 'rgba(0,0,0,.1)',\n ...this.pw.initParams.inboxWidget,\n };\n\n this.updateInbox = this.updateInbox.bind(this);\n this.markVisibleItemsAsRead = this.markVisibleItemsAsRead.bind(this);\n this.onWidgetClickHandler = this.onWidgetClickHandler.bind(this);\n this.onTriggerClickHandler = this.onTriggerClickHandler.bind(this);\n this.onWindowScrollHandler = this.onWindowScrollHandler.bind(this);\n this.toggle = this.toggle.bind(this);\n }\n\n public async run() {\n this.initTrigger();\n this.updateInbox();\n this.addListeners();\n }\n\n public toggle(isOpened?: boolean) {\n const openWidget = typeof isOpened === 'undefined'\n ? !this.isOpened\n : isOpened;\n\n if (openWidget) {\n this.openWidget();\n } else {\n this.closeWidget();\n }\n }\n\n // set inbox widget to trigger element on page\n private initTrigger() {\n if (!this.pw.pwinbox) {\n throw new Error('Web inbox is not allowed.');\n }\n\n const trigger = document.getElementById(this.config.triggerId);\n\n if (!trigger) {\n throw new Error('Inbox trigger element doesn\\'t exist. You must set triggerId in inboxWidget config. See the documentation.');\n }\n\n this.trigger = trigger;\n this.trigger.classList.add('pw-inbox-trigger');\n\n this.defaultMargin = 12;\n this.messagesElements = {};\n this.messages = [];\n this.readItems = [];\n this.updateCounter(0);\n this.isOpened = false;\n\n this.renderWidget();\n\n this.isFixed = isElementFixed(this.trigger);\n }\n\n private renderWidget() {\n this.widget = document.createElement('div');\n this.widget.id = 'pwInboxWidget';\n this.widget.className = 'pw-inbox-widget';\n this.widget.classList.toggle('pw-open', this.isOpened);\n\n this.widgetParent = document.querySelector(this.config.appendTo) || document.body;\n\n this.widgetParent.appendChild(this.widget);\n this.widgetParent.appendChild(this.getStyle());\n this.renderWidgetInner();\n }\n\n private getStyle(): HTMLStyleElement {\n const styleNode = document.createElement('style');\n styleNode.innerHTML = this.configureStyle(inboxWidgetStyleCss);\n return styleNode;\n }\n\n private configureStyle(styles: string): string {\n let resultStyles = styles.toString();\n CONFIG_STYLES.forEach((style: IConfigStyles) => {\n const template = new RegExp(`var\\\\(--${style.name}\\\\)`, 'ig');\n const result = this.getStyleFormatter(style);\n\n resultStyles = resultStyles.replace(template, result);\n });\n return resultStyles;\n }\n\n private getStyleFormatter(style: IConfigStyles): string {\n switch (style.type) {\n case 'size':\n return `${this.config[style.name] || 0}px`;\n case 'number':\n return parseFloat(this.config[style.name].toString()).toString();\n case 'string':\n return this.config[style.name].toString();\n case 'color':\n return getValidColor(this.config[style.name].toString());\n default:\n return 'none';\n }\n }\n\n private renderWidgetInner() {\n if (this.messages.length > 0) {\n this.widget.classList.remove('pw-inbox-widget--empty');\n this.widget.innerHTML = widgetTemplate(this.config.title);\n this.renderMessages();\n } else {\n this.widget.classList.add('pw-inbox-widget--empty');\n const {\n emptyInboxTitle,\n emptyInboxText,\n emptyInboxIconUrl,\n } = this.config;\n this.widget.innerHTML = widgetTemplateEmpty(emptyInboxIconUrl, emptyInboxTitle, emptyInboxText);\n }\n }\n\n private renderMessages() {\n this.list = this.widget.querySelector('.pw-inbox_list') || document.createElement('ul');\n this.messages.forEach((message: IInboxMessagePublic) => {\n const messageElement = document.createElement('li');\n messageElement.className = 'pw-inbox_item';\n messageElement.classList.toggle('pw-new', !message.isRead);\n messageElement.classList.toggle('pw-unread', !message.isActionPerformed);\n messageElement.setAttribute('data-pw-inbox-message-id', message.code);\n messageElement.innerHTML = messageTemplate(message);\n\n this.list.appendChild(messageElement);\n this.messagesElements[message.code] = messageElement;\n });\n }\n\n private updateCounter(count: number) {\n this.count = count;\n this.trigger.setAttribute('data-pw-count', `${this.count}`);\n this.trigger.classList.toggle('pw-empty', this.count === 0);\n }\n\n private updateInboxMessages(messages: Array<IInboxMessagePublic>) {\n this.messages = messages.sort(({ sendDate: sendDateOne }, { sendDate: sendDateTwo }) => compareBySendDate(sendDateOne, sendDateTwo));\n this.renderWidgetInner();\n }\n\n openWidget() {\n this.isOpened = true;\n this.widget.classList.add('pw-open');\n document.addEventListener('click', this.onWidgetClickHandler);\n window.addEventListener('scroll', this.onWindowScrollHandler);\n window.addEventListener('resize', this.onWindowScrollHandler);\n this.markVisibleItemsAsRead();\n if (this.messages.length > 0) {\n this.list.addEventListener('scroll', this.markVisibleItemsAsRead);\n }\n this.positionWidget();\n }\n\n closeWidget() {\n this.isOpened = false;\n document.removeEventListener('click', this.onWidgetClickHandler);\n document.removeEventListener('click', this.onWindowScrollHandler);\n window.removeEventListener('resize', this.onWindowScrollHandler);\n this.updateReadStatus();\n if (this.messages.length > 0) {\n this.list.removeEventListener('scroll', this.markVisibleItemsAsRead);\n }\n this.widget.classList.remove('pw-open', 'pw-top', 'pw-bottom', 'pw-right', 'pw-left');\n this.widget.removeAttribute('style');\n }\n\n private positionWidget() {\n if (!this.isOpened) {\n return;\n }\n if (this.widgetParent === document.body) {\n this.defaultPlaceWidget();\n } else {\n this.customPlaceWidget();\n }\n }\n\n private customPlaceWidget() {\n const { position } = this.config;\n this.widgetParent.style.position = 'relative';\n this.widget.classList.add('pw-inbox-widget--inset');\n this.widget.classList.add(`pw-${position}`);\n }\n\n private defaultPlaceWidget() {\n const position = this.pw.initParams.inboxWidget!.position ? this.config.position : this.getDefaultPosition();\n\n const widgetRect = this.widget.getBoundingClientRect();\n if (!document.documentElement) {\n return;\n }\n const windowWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);\n const windowHeight = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);\n\n if (widgetRect.width + (this.defaultMargin * 2) > windowWidth) {\n this.widget.style.width = `${windowWidth - (this.defaultMargin * 2)}px`;\n }\n if (widgetRect.height + 24 > windowHeight) {\n this.widget.style.height = `${windowHeight - (this.defaultMargin * 2)}px`;\n }\n\n switch (position) {\n case 'top': {\n this.alignWidgetTop();\n break;\n }\n case 'right': {\n this.alignWidgetRight();\n break;\n }\n case 'left': {\n this.alignWidgetLeft();\n break;\n }\n case 'bottom': {\n this.alignWidgetBottom();\n break;\n }\n }\n }\n\n private alignWidgetTop() {\n const triggerRect = this.trigger.getBoundingClientRect();\n const widgetRect = this.widget.getBoundingClientRect();\n if (!document.documentElement) {\n return;\n }\n const windowWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);\n const arrow: HTMLElement = this.widget.querySelector('.pw-inbox__arrow') || document.createElement('div');\n\n this.widget.classList.add('pw-top');\n\n let left = pageXOffset + triggerRect.left + Math.floor(triggerRect.width / 2) - Math.floor(widgetRect.width / 2);\n\n const isUnderLeft = left < pageXOffset;\n const isUnderRight = left + widgetRect.width > pageXOffset + windowWidth;\n\n if (isUnderLeft) {\n left = pageXOffset + this.defaultMargin;\n }\n if (isUnderRight) {\n left = pageXOffset + windowWidth - widgetRect.width - this.defaultMargin;\n }\n\n const top = pageYOffset + triggerRect.top - widgetRect.height;\n\n this.alignWidgetElement(left, top);\n arrow.style.left = `${triggerRect.left + Math.floor(triggerRect.width / 2) - left}px`;\n\n const topMargin = this.widget.getBoundingClientRect().top;\n const isUnderTop = topMargin < 0;\n if (isUnderTop) {\n const newHeight = this.widget.getBoundingClientRect().height + topMargin - this.defaultMargin;\n const newTop = this.widget.getBoundingClientRect().top - topMargin + this.defaultMargin;\n this.widget.style.height = `${newHeight}px`;\n this.widget.style.top = `${newTop}px`;\n }\n }\n\n private alignWidgetRight() {\n const triggerRect = this.trigger.getBoundingClientRect();\n const widgetRect = this.widget.getBoundingClientRect();\n if (!document.documentElement) {\n return;\n }\n const windowWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);\n const windowHeight = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);\n const arrow: HTMLElement = this.widget.querySelector('.pw-inbox__arrow') || document.createElement('div');\n\n this.widget.classList.add('pw-right');\n\n let top = pageYOffset + triggerRect.top + Math.floor(triggerRect.height / 2) - Math.floor(widgetRect.height / 2);\n\n const isUnderTop = top < pageYOffset;\n const isUnderBottom = pageYOffset + windowHeight < top + widgetRect.height;\n\n if (isUnderTop) {\n top = pageYOffset + this.defaultMargin;\n }\n\n if (isUnderBottom) {\n top = pageYOffset + windowHeight - widgetRect.height - this.defaultMargin;\n }\n\n const left = pageXOffset + triggerRect.left + triggerRect.width;\n\n this.alignWidgetElement(left, top);\n arrow.style.top = `${triggerRect.top + Math.floor(triggerRect.height / 2) - top}px`;\n\n const rightMargin = windowWidth - this.widget.getBoundingClientRect().right;\n const isUnderRight = rightMargin < this.defaultMargin;\n if (isUnderRight) {\n const newWidth = this.widget.getBoundingClientRect().width + rightMargin - this.defaultMargin;\n this.widget.style.width = `${newWidth}px`;\n }\n }\n\n private alignWidgetLeft() {\n const triggerRect = this.trigger.getBoundingClientRect();\n const widgetRect = this.widget.getBoundingClientRect();\n if (!document.documentElement) {\n return;\n }\n const windowHeight = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);\n const arrow: HTMLElement = this.widget.querySelector('.pw-inbox__arrow') || document.createElement('div');\n\n this.widget.classList.add('pw-left');\n\n let top = pageYOffset + triggerRect.top + Math.floor(triggerRect.height / 2) - Math.floor(widgetRect.height / 2);\n\n const isUnderTop = top < pageYOffset;\n const isUnderBottom = pageYOffset + windowHeight < top + widgetRect.height;\n\n if (isUnderTop) {\n top = pageYOffset + this.defaultMargin;\n }\n\n if (isUnderBottom) {\n top = pageYOffset + windowHeight - widgetRect.height - this.defaultMargin;\n }\n\n const left = pageXOffset + triggerRect.left - widgetRect.width;\n\n this.alignWidgetElement(left, top);\n arrow.style.top = `${triggerRect.top + Math.floor(triggerRect.height / 2) - top}px`;\n\n const leftMargin = this.widget.getBoundingClientRect().left;\n const isUnderLeft = leftMargin < 0;\n if (isUnderLeft) {\n const newWidth = this.widget.getBoundingClientRect().width + leftMargin - this.defaultMargin;\n const newLeft = this.widget.getBoundingClientRect().left - leftMargin;\n this.widget.style.width = `${newWidth}px`;\n this.widget.style.left = `${newLeft}px`;\n }\n }\n\n private alignWidgetBottom() {\n const triggerRect = this.trigger.getBoundingClientRect();\n const widgetRect = this.widget.getBoundingClientRect();\n if (!document.documentElement) {\n return;\n }\n const windowWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);\n const windowHeight = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);\n const arrow: HTMLElement = this.widget.querySelector('.pw-inbox__arrow') || document.createElement('div');\n\n this.widget.classList.add('pw-bottom');\n\n let left = pageXOffset + triggerRect.left + Math.floor(triggerRect.width / 2) - Math.floor(widgetRect.width / 2);\n\n const isUnderLeft = left < pageXOffset;\n const isUnderRight = left + widgetRect.width > pageXOffset + windowWidth;\n\n if (isUnderLeft) {\n left = pageXOffset + this.defaultMargin;\n }\n if (isUnderRight) {\n left = pageXOffset + windowWidth - widgetRect.width - 12;\n }\n\n const top = pageYOffset + triggerRect.top + triggerRect.height;\n\n this.alignWidgetElement(left, top);\n arrow.style.left = `${triggerRect.left + Math.floor(triggerRect.width / 2) - left}px`;\n\n const bottomRange = windowHeight - this.widget.getBoundingClientRect().bottom;\n const isUnderBottom = bottomRange < this.defaultMargin;\n if (isUnderBottom) {\n const newHeight = this.widget.getBoundingClientRect().height + bottomRange - this.defaultMargin;\n this.widget.style.height = `${newHeight}px`;\n }\n }\n\n private alignWidgetElement(left: number, top: number) {\n this.widget.style.left = `${left}px`;\n this.widget.style.top = `${top}px`;\n }\n\n private getDefaultPosition(): string {\n const { left, top, width, height } = this.trigger.getBoundingClientRect();\n if (!document.documentElement) {\n return '';\n }\n const windowWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);\n const windowHeight = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);\n\n const antiMargins: { [key: string]: number } = {\n right: left,\n bottom: top,\n left: windowWidth - (left + width),\n top: windowHeight - (top + height),\n };\n\n const leastMargin = Math.min(left, top, antiMargins.left, antiMargins.top);\n\n let position = 'bottom';\n\n Object.keys(antiMargins).forEach((key) => {\n if (antiMargins[key] === leastMargin) {\n position = key;\n }\n });\n\n return position;\n }\n\n private addListeners() {\n this.trigger.addEventListener('click', this.onTriggerClickHandler);\n\n this.pw.push(['onPutNewMessageToInboxStore', () => {\n this.updateInbox();\n }]);\n this.pw.push(['onUpdateInboxMessages', () => {\n this.updateInbox();\n }]);\n }\n\n private markVisibleItemsAsRead() {\n if (this.messages.length === 0) {\n return;\n }\n const scrollTop = (this.list.clientHeight + this.list.scrollTop) - 50;\n Object.keys(this.messagesElements).forEach((code: string) => {\n // check message exists and user saw the message in viewport\n if (!this.messagesElements[code] || this.messagesElements[code].offsetTop > scrollTop) {\n return;\n }\n\n const message = this.messages.find((message: IInboxMessagePublic): boolean => message.code === code);\n\n // mark messages as read\n if (!!message && !message.isRead && !(this.readItems.indexOf(code) + 1)) {\n this.readItems.push(code);\n }\n });\n }\n\n private updateReadStatus() {\n this.pw.pwinbox.readMessagesWithCodes(this.readItems).then(this.updateInbox);\n }\n\n private updateInbox() {\n this.pw.pwinbox.loadMessages().then((messages: Array<IInboxMessagePublic>) => {\n this.updateInboxMessages(messages);\n });\n this.pw.pwinbox.unreadMessagesCount().then((count: number) => {\n this.updateCounter(count);\n });\n }\n\n private performMessageAction(code: string) {\n this.pw.pwinbox.performActionForMessageWithCode(code)\n .then(() => {\n this.updateInbox();\n });\n }\n\n private removeMessages(messages: Array<string>) {\n messages.forEach((code: string) => {\n this.readItems = this.readItems.slice(this.readItems.indexOf(code), 1);\n });\n this.pw.pwinbox.deleteMessagesWithCodes(messages)\n .then(() => {\n this.updateInbox();\n });\n }\n\n // handlers\n\n private onTriggerClickHandler(event: MouseEvent) {\n event.stopPropagation();\n if (!event.target) {\n return;\n }\n\n this.toggle();\n }\n\n private onWidgetClickHandler(event: MouseEvent) {\n if (!event.target) {\n return;\n }\n\n const itemElement = (<HTMLElement>event.target).closest('.pw-inbox_item');\n\n if (!itemElement) {\n this.toggle();\n return;\n }\n\n const messageCode = itemElement.getAttribute('data-pw-inbox-message-id');\n\n if (!messageCode) {\n return;\n }\n\n const removeIconClick = (<HTMLElement>event.target).closest('.pw-inbox_item-remove');\n\n if (removeIconClick) {\n this.removeMessages([messageCode]);\n return;\n }\n\n this.performMessageAction(messageCode);\n }\n\n private onWindowScrollHandler() {\n if (this.isFixed && this.isOpened) {\n this.toggle();\n return;\n }\n this.positionWidget();\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","MONTHS","CONFIG_STYLES","name","type","DEFAULT_CONFIG","enable","triggerId","position","appendTo","title","bgColor","textColor","fontFamily","borderRadius","borderColor","badgeBgColor","badgeTextColor","widgetWidth","zIndex","messageTitleColor","timeTextColor","emptyInboxTitle","emptyInboxTitleColor","emptyInboxText","emptyInboxTextColor","emptyInboxIconUrl","arrowBorderColor","COLOR_TEST_REGEXP","isElementFixed","element","isFixed","window","getComputedStyle","parentElement","messageTemplate","imageUrl","message","sendDate","date","localDate","Date","localTime","getHours","getTimezoneOffset","setHours","gap","getTime","Math","floor","getDate","getMonth","getFullYear","getMinutes","toString","slice","getMessageTime","PWInboxWidget","constructor","pw","inboxWidgetConfig","initParams","inboxWidget","config","updateInbox","bind","markVisibleItemsAsRead","onWidgetClickHandler","onTriggerClickHandler","onWindowScrollHandler","toggle","run","initTrigger","addListeners","isOpened","openWidget","closeWidget","pwinbox","Error","trigger","document","getElementById","classList","add","defaultMargin","messagesElements","messages","readItems","updateCounter","renderWidget","widget","createElement","id","className","widgetParent","querySelector","body","appendChild","getStyle","renderWidgetInner","styleNode","innerHTML","configureStyle","styles","resultStyles","forEach","style","template","RegExp","result","getStyleFormatter","replace","parseFloat","color","test","length","remove","renderMessages","widgetTemplateEmpty","list","messageElement","isRead","isActionPerformed","setAttribute","code","count","updateInboxMessages","sort","sendDateOne","sendDateTwo","dateOne","dateTwo","localDateOne","localTimeOne","localDateTwo","localTimeTwo","compareBySendDate","addEventListener","positionWidget","removeEventListener","updateReadStatus","removeAttribute","defaultPlaceWidget","customPlaceWidget","getDefaultPosition","widgetRect","getBoundingClientRect","documentElement","windowWidth","max","clientWidth","innerWidth","windowHeight","clientHeight","innerHeight","width","height","alignWidgetTop","alignWidgetRight","alignWidgetLeft","alignWidgetBottom","triggerRect","arrow","left","pageXOffset","isUnderLeft","isUnderRight","top","pageYOffset","alignWidgetElement","topMargin","newHeight","newTop","isUnderTop","isUnderBottom","rightMargin","right","newWidth","leftMargin","newLeft","bottomRange","bottom","antiMargins","leastMargin","min","keys","push","scrollTop","offsetTop","find","indexOf","readMessagesWithCodes","then","loadMessages","unreadMessagesCount","performMessageAction","performActionForMessageWithCode","removeMessages","deleteMessagesWithCodes","event","stopPropagation","target","itemElement","closest","messageCode","getAttribute"],"sourceRoot":""}
1
+ {"version":3,"file":"widget-inbox.js","mappings":"CAAA,SAA2CA,EAAMC,GAChD,GAAsB,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,SACb,GAAqB,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,OACP,CACJ,IAAIK,EAAIL,IACR,IAAI,IAAIM,KAAKD,GAAuB,iBAAZJ,QAAuBA,QAAUF,GAAMO,GAAKD,EAAEC,EACvE,CACA,CATD,CASGC,KAAM,I,mBCRT,IAAIC,EAAsB,CCA1BA,EAAwB,CAACP,EAASQ,KACjC,IAAI,IAAIC,KAAOD,EACXD,EAAoBG,EAAEF,EAAYC,KAASF,EAAoBG,EAAEV,EAASS,IAC5EE,OAAOC,eAAeZ,EAASS,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,MCJ3EF,EAA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CAAqBoI,GAC3B,IAAKA,EAAME,OACT,OAGF,MAAMC,EAA4BH,EAAME,OAAQE,QAAQ,kBAExD,IAAKD,EAEH,YADA1N,KAAKsF,SAIP,MAAMsI,EAAcF,EAAYG,aAAa,4BAE7C,IAAKD,EACH,OAGoCL,EAAME,OAAQE,QAAQ,yBAG1D3N,KAAKqN,eAAe,CAACO,IAIvB5N,KAAKmN,qBAAqBS,EAC5B,CAEQ,qBAAAvI,GACFrF,KAAK+C,SAAW/C,KAAK0F,SACvB1F,KAAKsF,SAGPtF,KAAK0J,gBACP,E","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/Inbox/constants.ts","webpack://web-push-notifications/./src/widgets/Inbox/helpers.ts","webpack://web-push-notifications/./src/widgets/Inbox/widgetTemplates.ts","webpack://web-push-notifications/./src/widgets/Inbox/InboxWidget.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\nvar __webpack_require__ = {};\n\n","// define getter 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\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { type IConfigStyles, type IInboxWidgetConfig } from './inbox_widget.types';\n\nexport const MILLISECONDS_IN_DAY = 60 * 60 * 24 * 1000;\nexport const MILLISECONDS_IN_HOUR = 60 * 60 * 1000;\nexport const MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'June', 'July', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec'];\n\nexport const CONFIG_STYLES: Array<IConfigStyles> = [\n { name: 'widgetWidth', type: 'size' },\n { name: 'borderRadius', type: 'size' },\n { name: 'zIndex', type: 'number' },\n { name: 'fontFamily', type: 'string' },\n { name: 'bgColor', type: 'color' },\n { name: 'textColor', type: 'color' },\n { name: 'arrowBorderColor', type: 'color' },\n { name: 'borderColor', type: 'color' },\n { name: 'badgeBgColor', type: 'color' },\n { name: 'badgeTextColor', type: 'color' },\n { name: 'timeTextColor', type: 'color' },\n { name: 'messageTitleColor', type: 'color' },\n { name: 'emptyInboxTitleColor', type: 'color' },\n { name: 'emptyInboxTextColor', type: 'color' },\n];\n\nexport const DEFAULT_CONFIG: IInboxWidgetConfig = {\n enable: false,\n triggerId: 'pwInbox',\n position: 'bottom',\n appendTo: 'body',\n title: 'Inbox',\n bgColor: '#ffffff',\n textColor: '#333333',\n fontFamily: 'inherit',\n borderRadius: 4,\n borderColor: 'transparent',\n badgeBgColor: '#ff4c00',\n badgeTextColor: '#ffffff',\n widgetWidth: 350,\n zIndex: 100,\n messageTitleColor: '#7a7a7a',\n timeTextColor: '#c4c4c4',\n emptyInboxTitle: 'You\\'re all caught up',\n emptyInboxTitleColor: '#333333',\n emptyInboxText: 'There are no new messages. Stay tuned!',\n emptyInboxTextColor: '#7a7a7a',\n emptyInboxIconUrl: 'https://pushon.pushwoosh.com/static/icon-empty-inbox.png',\n arrowBorderColor: 'rgba(0,0,0,.1)',\n};\n\nexport const COLOR_TEST_REGEXP = /^(#([\\da-f]{3}){1,2}$|(rgb|hsl)a\\((\\d{1,3}%?,\\s?){3}(1|0?\\.\\d+)\\)$|(rgb|hsl)\\(\\d{1,3}%?(,\\s?\\d{1,3}%?){2}\\)$)/;\n","import {\n MILLISECONDS_IN_HOUR,\n MILLISECONDS_IN_DAY,\n MONTHS,\n COLOR_TEST_REGEXP,\n} from './constants';\n\nexport function isElementFixed(element: HTMLElement): boolean {\n let isFixed = window.getComputedStyle(element).position === 'fixed';\n if (!isFixed && element.parentElement) {\n isFixed = isElementFixed(element.parentElement);\n }\n return isFixed;\n}\n\nexport function getMessageTime(date: string): string {\n const localDate = new Date(date);\n const localTime = localDate.getHours() + (localDate.getTimezoneOffset() / 60);\n localDate.setHours(localTime);\n const now = new Date();\n\n const gap = (now.getTime() - localDate.getTime());\n\n if (gap <= 60 * 1000) {\n return `Just now`;\n } else if (gap < MILLISECONDS_IN_HOUR && gap > 0) {\n const minutesAgo = Math.floor(gap / (60 * 1000));\n return `${minutesAgo} minutes ago`;\n } else if (gap < MILLISECONDS_IN_DAY && gap > 0) {\n const hoursAgo = Math.floor(gap / (60 * 60 * 1000));\n return `${hoursAgo} hours ago`;\n }\n\n const day = localDate.getDate();\n const month = MONTHS[localDate.getMonth()];\n const year = localDate.getFullYear();\n const hours = localDate.getHours();\n const minutes = `0${localDate.getMinutes().toString()}`.slice(-2); // padStart(2, 0)\n\n return `${day} ${month} ${year}, ${hours}:${minutes}`;\n}\n\nexport function getValidColor(color: string): string {\n if (color === 'transparent') {\n return color;\n }\n\n return COLOR_TEST_REGEXP.test(color)\n ? color\n : '#333';\n}\n\nexport function compareBySendDate(dateOne: string, dateTwo: string): number {\n const localDateOne = new Date(dateOne);\n const localTimeOne = localDateOne.getHours() + (localDateOne.getTimezoneOffset() / 60);\n const localDateTwo = new Date(dateTwo);\n const localTimeTwo = localDateTwo.getHours() + (localDateTwo.getTimezoneOffset() / 60);\n\n localDateOne.setHours(localTimeOne);\n localDateTwo.setHours(localTimeTwo);\n\n return localDateTwo.getTime() - localDateOne.getTime();\n}\n","import { getMessageTime } from './helpers';\nimport { type IInboxMessagePublic } from '../../models/InboxMessages.types';\n\nexport const widgetTemplate = (title: string): string => `\n<div class=\"pw-inbox__arrow\"></div>\n<div class=\"pw-inbox_inner\">\n <div class=\"pw-inbox_title\">\n ${title}\n </div>\n <ul class=\"pw-inbox_list\">\n\n </ul>\n</div>`;\n\nexport const widgetTemplateEmpty = (\n emptyInboxIconUrl: string,\n emptyInboxTitle: string,\n emptyInboxText: string,\n) => `\n<div class=\"pw-inbox__arrow\"></div>\n<div class=\"pw-inbox_list--empty\">\n <div class=\"pw-inbox_list-icon\">\n <img src=\"${emptyInboxIconUrl}\" alt=\"${emptyInboxTitle}\">\n </div>\n <div class=\"pw-inbox_list-title\">\n ${emptyInboxTitle}\n </div>\n <div class=\"ipw-inbox_list-body\">\n ${emptyInboxText}\n </div>\n</div>`;\n\nexport const messageTemplate = ({\n imageUrl,\n title,\n message,\n sendDate,\n}: IInboxMessagePublic) => `\n<div class=\"pw-inbox_item-inner\">\n <div class=\"pw-inbox_icon\">\n <img src=\"${imageUrl}\" alt=\"${title || message}\" class=\"pw-inbox_message-image\">\n </div>\n <div class=\"pw-inbox_content\">\n ${title ? `<div class=\"pw-inbox_item-title\">\n ${title}\n </div>` : null}\n <div class=\"pw-inbox_item-body\">\n ${message}\n </div>\n <div class=\"pw-inbox_item-time\">\n ${getMessageTime(sendDate)}\n </div>\n </div>\n</div>\n<span class=\"pw-inbox_item-remove\"></span>`;\n","import {\n CONFIG_STYLES,\n DEFAULT_CONFIG,\n} from './constants';\nimport inboxWidgetStyleCss from './css/inboxWidgetStyle.css';\nimport {\n getValidColor,\n isElementFixed,\n compareBySendDate,\n} from './helpers';\nimport { type IConfigStyles, type IInboxWidgetConfig, type TMessagesElementsType } from './inbox_widget.types';\nimport {\n messageTemplate,\n widgetTemplate,\n widgetTemplateEmpty,\n} from './widgetTemplates';\nimport { type Pushwoosh } from '../../core/Pushwoosh';\nimport { type IInboxMessagePublic } from '../../models/InboxMessages.types';\n\nexport class PWInboxWidget {\n pw: Pushwoosh;\n widget: HTMLElement;\n trigger: HTMLElement;\n list: HTMLElement;\n widgetParent: HTMLElement;\n count: number;\n messages: Array<IInboxMessagePublic>;\n messagesElements: TMessagesElementsType;\n readItems: Array<string>;\n isOpened: boolean;\n config: IInboxWidgetConfig;\n defaultMargin: number;\n isFixed: boolean;\n\n constructor(pw: Pushwoosh) {\n // Set Pushwoosh object\n this.pw = pw;\n\n const inboxWidgetConfig = this.pw.initParams.inboxWidget!;\n\n this.config = {\n ...DEFAULT_CONFIG,\n arrowBorderColor: inboxWidgetConfig.borderColor && inboxWidgetConfig.borderColor !== 'transparent'\n ? inboxWidgetConfig.borderColor\n : 'rgba(0,0,0,.1)',\n ...this.pw.initParams.inboxWidget,\n };\n\n this.updateInbox = this.updateInbox.bind(this);\n this.markVisibleItemsAsRead = this.markVisibleItemsAsRead.bind(this);\n this.onWidgetClickHandler = this.onWidgetClickHandler.bind(this);\n this.onTriggerClickHandler = this.onTriggerClickHandler.bind(this);\n this.onWindowScrollHandler = this.onWindowScrollHandler.bind(this);\n this.toggle = this.toggle.bind(this);\n }\n\n public async run() {\n this.initTrigger();\n this.updateInbox();\n this.addListeners();\n }\n\n public toggle(isOpened?: boolean) {\n const openWidget = typeof isOpened === 'undefined'\n ? !this.isOpened\n : isOpened;\n\n if (openWidget) {\n this.openWidget();\n } else {\n this.closeWidget();\n }\n }\n\n // set inbox widget to trigger element on page\n private initTrigger() {\n if (!this.pw.pwinbox) {\n throw new Error('Web inbox is not allowed.');\n }\n\n const trigger = document.getElementById(this.config.triggerId);\n\n if (!trigger) {\n throw new Error('Inbox trigger element doesn\\'t exist. You must set triggerId in inboxWidget config. See the documentation.');\n }\n\n this.trigger = trigger;\n this.trigger.classList.add('pw-inbox-trigger');\n\n this.defaultMargin = 12;\n this.messagesElements = {};\n this.messages = [];\n this.readItems = [];\n this.updateCounter(0);\n this.isOpened = false;\n\n this.renderWidget();\n\n this.isFixed = isElementFixed(this.trigger);\n }\n\n private renderWidget() {\n this.widget = document.createElement('div');\n this.widget.id = 'pwInboxWidget';\n this.widget.className = 'pw-inbox-widget';\n this.widget.classList.toggle('pw-open', this.isOpened);\n\n this.widgetParent = document.querySelector(this.config.appendTo) || document.body;\n\n this.widgetParent.appendChild(this.widget);\n this.widgetParent.appendChild(this.getStyle());\n this.renderWidgetInner();\n }\n\n private getStyle(): HTMLStyleElement {\n const styleNode = document.createElement('style');\n styleNode.innerHTML = this.configureStyle(inboxWidgetStyleCss);\n return styleNode;\n }\n\n private configureStyle(styles: string): string {\n let resultStyles = styles.toString();\n CONFIG_STYLES.forEach((style: IConfigStyles) => {\n const template = new RegExp(`var\\\\(--${style.name}\\\\)`, 'ig');\n const result = this.getStyleFormatter(style);\n\n resultStyles = resultStyles.replace(template, result);\n });\n return resultStyles;\n }\n\n private getStyleFormatter(style: IConfigStyles): string {\n switch (style.type) {\n case 'size':\n return `${this.config[style.name] || 0}px`;\n case 'number':\n return parseFloat(this.config[style.name].toString()).toString();\n case 'string':\n return this.config[style.name].toString();\n case 'color':\n return getValidColor(this.config[style.name].toString());\n default:\n return 'none';\n }\n }\n\n private renderWidgetInner() {\n if (this.messages.length > 0) {\n this.widget.classList.remove('pw-inbox-widget--empty');\n this.widget.innerHTML = widgetTemplate(this.config.title);\n this.renderMessages();\n } else {\n this.widget.classList.add('pw-inbox-widget--empty');\n const {\n emptyInboxTitle,\n emptyInboxText,\n emptyInboxIconUrl,\n } = this.config;\n this.widget.innerHTML = widgetTemplateEmpty(emptyInboxIconUrl, emptyInboxTitle, emptyInboxText);\n }\n }\n\n private renderMessages() {\n this.list = this.widget.querySelector('.pw-inbox_list') || document.createElement('ul');\n this.messages.forEach((message: IInboxMessagePublic) => {\n const messageElement = document.createElement('li');\n messageElement.className = 'pw-inbox_item';\n messageElement.classList.toggle('pw-new', !message.isRead);\n messageElement.classList.toggle('pw-unread', !message.isActionPerformed);\n messageElement.setAttribute('data-pw-inbox-message-id', message.code);\n messageElement.innerHTML = messageTemplate(message);\n\n this.list.appendChild(messageElement);\n this.messagesElements[message.code] = messageElement;\n });\n }\n\n private updateCounter(count: number) {\n this.count = count;\n this.trigger.setAttribute('data-pw-count', `${this.count}`);\n this.trigger.classList.toggle('pw-empty', this.count === 0);\n }\n\n private updateInboxMessages(messages: Array<IInboxMessagePublic>) {\n this.messages = messages.sort(({ sendDate: sendDateOne }, { sendDate: sendDateTwo }) => compareBySendDate(sendDateOne, sendDateTwo));\n this.renderWidgetInner();\n }\n\n openWidget() {\n this.isOpened = true;\n this.widget.classList.add('pw-open');\n document.addEventListener('click', this.onWidgetClickHandler);\n window.addEventListener('scroll', this.onWindowScrollHandler);\n window.addEventListener('resize', this.onWindowScrollHandler);\n this.markVisibleItemsAsRead();\n if (this.messages.length > 0) {\n this.list.addEventListener('scroll', this.markVisibleItemsAsRead);\n }\n this.positionWidget();\n }\n\n closeWidget() {\n this.isOpened = false;\n document.removeEventListener('click', this.onWidgetClickHandler);\n document.removeEventListener('click', this.onWindowScrollHandler);\n window.removeEventListener('resize', this.onWindowScrollHandler);\n this.updateReadStatus();\n if (this.messages.length > 0) {\n this.list.removeEventListener('scroll', this.markVisibleItemsAsRead);\n }\n this.widget.classList.remove('pw-open', 'pw-top', 'pw-bottom', 'pw-right', 'pw-left');\n this.widget.removeAttribute('style');\n }\n\n private positionWidget() {\n if (!this.isOpened) {\n return;\n }\n if (this.widgetParent === document.body) {\n this.defaultPlaceWidget();\n } else {\n this.customPlaceWidget();\n }\n }\n\n private customPlaceWidget() {\n const { position } = this.config;\n this.widgetParent.style.position = 'relative';\n this.widget.classList.add('pw-inbox-widget--inset');\n this.widget.classList.add(`pw-${position}`);\n }\n\n private defaultPlaceWidget() {\n const position = this.pw.initParams.inboxWidget!.position ? this.config.position : this.getDefaultPosition();\n\n const widgetRect = this.widget.getBoundingClientRect();\n if (!document.documentElement) {\n return;\n }\n const windowWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);\n const windowHeight = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);\n\n if (widgetRect.width + (this.defaultMargin * 2) > windowWidth) {\n this.widget.style.width = `${windowWidth - (this.defaultMargin * 2)}px`;\n }\n if (widgetRect.height + 24 > windowHeight) {\n this.widget.style.height = `${windowHeight - (this.defaultMargin * 2)}px`;\n }\n\n switch (position) {\n case 'top': {\n this.alignWidgetTop();\n break;\n }\n case 'right': {\n this.alignWidgetRight();\n break;\n }\n case 'left': {\n this.alignWidgetLeft();\n break;\n }\n case 'bottom': {\n this.alignWidgetBottom();\n break;\n }\n }\n }\n\n private alignWidgetTop() {\n const triggerRect = this.trigger.getBoundingClientRect();\n const widgetRect = this.widget.getBoundingClientRect();\n if (!document.documentElement) {\n return;\n }\n const windowWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);\n const arrow: HTMLElement = this.widget.querySelector('.pw-inbox__arrow') || document.createElement('div');\n\n this.widget.classList.add('pw-top');\n\n let left = pageXOffset + triggerRect.left + Math.floor(triggerRect.width / 2) - Math.floor(widgetRect.width / 2);\n\n const isUnderLeft = left < pageXOffset;\n const isUnderRight = left + widgetRect.width > pageXOffset + windowWidth;\n\n if (isUnderLeft) {\n left = pageXOffset + this.defaultMargin;\n }\n if (isUnderRight) {\n left = pageXOffset + windowWidth - widgetRect.width - this.defaultMargin;\n }\n\n const top = pageYOffset + triggerRect.top - widgetRect.height;\n\n this.alignWidgetElement(left, top);\n arrow.style.left = `${triggerRect.left + Math.floor(triggerRect.width / 2) - left}px`;\n\n const topMargin = this.widget.getBoundingClientRect().top;\n const isUnderTop = topMargin < 0;\n if (isUnderTop) {\n const newHeight = this.widget.getBoundingClientRect().height + topMargin - this.defaultMargin;\n const newTop = this.widget.getBoundingClientRect().top - topMargin + this.defaultMargin;\n this.widget.style.height = `${newHeight}px`;\n this.widget.style.top = `${newTop}px`;\n }\n }\n\n private alignWidgetRight() {\n const triggerRect = this.trigger.getBoundingClientRect();\n const widgetRect = this.widget.getBoundingClientRect();\n if (!document.documentElement) {\n return;\n }\n const windowWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);\n const windowHeight = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);\n const arrow: HTMLElement = this.widget.querySelector('.pw-inbox__arrow') || document.createElement('div');\n\n this.widget.classList.add('pw-right');\n\n let top = pageYOffset + triggerRect.top + Math.floor(triggerRect.height / 2) - Math.floor(widgetRect.height / 2);\n\n const isUnderTop = top < pageYOffset;\n const isUnderBottom = pageYOffset + windowHeight < top + widgetRect.height;\n\n if (isUnderTop) {\n top = pageYOffset + this.defaultMargin;\n }\n\n if (isUnderBottom) {\n top = pageYOffset + windowHeight - widgetRect.height - this.defaultMargin;\n }\n\n const left = pageXOffset + triggerRect.left + triggerRect.width;\n\n this.alignWidgetElement(left, top);\n arrow.style.top = `${triggerRect.top + Math.floor(triggerRect.height / 2) - top}px`;\n\n const rightMargin = windowWidth - this.widget.getBoundingClientRect().right;\n const isUnderRight = rightMargin < this.defaultMargin;\n if (isUnderRight) {\n const newWidth = this.widget.getBoundingClientRect().width + rightMargin - this.defaultMargin;\n this.widget.style.width = `${newWidth}px`;\n }\n }\n\n private alignWidgetLeft() {\n const triggerRect = this.trigger.getBoundingClientRect();\n const widgetRect = this.widget.getBoundingClientRect();\n if (!document.documentElement) {\n return;\n }\n const windowHeight = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);\n const arrow: HTMLElement = this.widget.querySelector('.pw-inbox__arrow') || document.createElement('div');\n\n this.widget.classList.add('pw-left');\n\n let top = pageYOffset + triggerRect.top + Math.floor(triggerRect.height / 2) - Math.floor(widgetRect.height / 2);\n\n const isUnderTop = top < pageYOffset;\n const isUnderBottom = pageYOffset + windowHeight < top + widgetRect.height;\n\n if (isUnderTop) {\n top = pageYOffset + this.defaultMargin;\n }\n\n if (isUnderBottom) {\n top = pageYOffset + windowHeight - widgetRect.height - this.defaultMargin;\n }\n\n const left = pageXOffset + triggerRect.left - widgetRect.width;\n\n this.alignWidgetElement(left, top);\n arrow.style.top = `${triggerRect.top + Math.floor(triggerRect.height / 2) - top}px`;\n\n const leftMargin = this.widget.getBoundingClientRect().left;\n const isUnderLeft = leftMargin < 0;\n if (isUnderLeft) {\n const newWidth = this.widget.getBoundingClientRect().width + leftMargin - this.defaultMargin;\n const newLeft = this.widget.getBoundingClientRect().left - leftMargin;\n this.widget.style.width = `${newWidth}px`;\n this.widget.style.left = `${newLeft}px`;\n }\n }\n\n private alignWidgetBottom() {\n const triggerRect = this.trigger.getBoundingClientRect();\n const widgetRect = this.widget.getBoundingClientRect();\n if (!document.documentElement) {\n return;\n }\n const windowWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);\n const windowHeight = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);\n const arrow: HTMLElement = this.widget.querySelector('.pw-inbox__arrow') || document.createElement('div');\n\n this.widget.classList.add('pw-bottom');\n\n let left = pageXOffset + triggerRect.left + Math.floor(triggerRect.width / 2) - Math.floor(widgetRect.width / 2);\n\n const isUnderLeft = left < pageXOffset;\n const isUnderRight = left + widgetRect.width > pageXOffset + windowWidth;\n\n if (isUnderLeft) {\n left = pageXOffset + this.defaultMargin;\n }\n if (isUnderRight) {\n left = pageXOffset + windowWidth - widgetRect.width - 12;\n }\n\n const top = pageYOffset + triggerRect.top + triggerRect.height;\n\n this.alignWidgetElement(left, top);\n arrow.style.left = `${triggerRect.left + Math.floor(triggerRect.width / 2) - left}px`;\n\n const bottomRange = windowHeight - this.widget.getBoundingClientRect().bottom;\n const isUnderBottom = bottomRange < this.defaultMargin;\n if (isUnderBottom) {\n const newHeight = this.widget.getBoundingClientRect().height + bottomRange - this.defaultMargin;\n this.widget.style.height = `${newHeight}px`;\n }\n }\n\n private alignWidgetElement(left: number, top: number) {\n this.widget.style.left = `${left}px`;\n this.widget.style.top = `${top}px`;\n }\n\n private getDefaultPosition(): string {\n const { left, top, width, height } = this.trigger.getBoundingClientRect();\n if (!document.documentElement) {\n return '';\n }\n const windowWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);\n const windowHeight = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);\n\n const antiMargins: { [key: string]: number } = {\n right: left,\n bottom: top,\n left: windowWidth - (left + width),\n top: windowHeight - (top + height),\n };\n\n const leastMargin = Math.min(left, top, antiMargins.left, antiMargins.top);\n\n let position = 'bottom';\n\n Object.keys(antiMargins).forEach((key) => {\n if (antiMargins[key] === leastMargin) {\n position = key;\n }\n });\n\n return position;\n }\n\n private addListeners() {\n this.trigger.addEventListener('click', this.onTriggerClickHandler);\n\n this.pw.push(['onPutNewMessageToInboxStore', () => {\n this.updateInbox();\n }]);\n this.pw.push(['onUpdateInboxMessages', () => {\n this.updateInbox();\n }]);\n }\n\n private markVisibleItemsAsRead() {\n if (this.messages.length === 0) {\n return;\n }\n const scrollTop = (this.list.clientHeight + this.list.scrollTop) - 50;\n Object.keys(this.messagesElements).forEach((code: string) => {\n // check message exists and user saw the message in viewport\n if (!this.messagesElements[code] || this.messagesElements[code].offsetTop > scrollTop) {\n return;\n }\n\n const message = this.messages.find((message: IInboxMessagePublic): boolean => message.code === code);\n\n // mark messages as read\n if (!!message && !message.isRead && !(this.readItems.indexOf(code) + 1)) {\n this.readItems.push(code);\n }\n });\n }\n\n private updateReadStatus() {\n this.pw.pwinbox.readMessagesWithCodes(this.readItems).then(this.updateInbox);\n }\n\n private updateInbox() {\n this.pw.pwinbox.loadMessages().then((messages: Array<IInboxMessagePublic>) => {\n this.updateInboxMessages(messages);\n });\n this.pw.pwinbox.unreadMessagesCount().then((count: number) => {\n this.updateCounter(count);\n });\n }\n\n private performMessageAction(code: string) {\n this.pw.pwinbox.performActionForMessageWithCode(code)\n .then(() => {\n this.updateInbox();\n });\n }\n\n private removeMessages(messages: Array<string>) {\n messages.forEach((code: string) => {\n this.readItems = this.readItems.slice(this.readItems.indexOf(code), 1);\n });\n this.pw.pwinbox.deleteMessagesWithCodes(messages)\n .then(() => {\n this.updateInbox();\n });\n }\n\n // handlers\n\n private onTriggerClickHandler(event: MouseEvent) {\n event.stopPropagation();\n if (!event.target) {\n return;\n }\n\n this.toggle();\n }\n\n private onWidgetClickHandler(event: MouseEvent) {\n if (!event.target) {\n return;\n }\n\n const itemElement = (<HTMLElement>event.target).closest('.pw-inbox_item');\n\n if (!itemElement) {\n this.toggle();\n return;\n }\n\n const messageCode = itemElement.getAttribute('data-pw-inbox-message-id');\n\n if (!messageCode) {\n return;\n }\n\n const removeIconClick = (<HTMLElement>event.target).closest('.pw-inbox_item-remove');\n\n if (removeIconClick) {\n this.removeMessages([messageCode]);\n return;\n }\n\n this.performMessageAction(messageCode);\n }\n\n private onWindowScrollHandler() {\n if (this.isFixed && this.isOpened) {\n this.toggle();\n return;\n }\n this.positionWidget();\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","MONTHS","CONFIG_STYLES","name","type","DEFAULT_CONFIG","enable","triggerId","position","appendTo","title","bgColor","textColor","fontFamily","borderRadius","borderColor","badgeBgColor","badgeTextColor","widgetWidth","zIndex","messageTitleColor","timeTextColor","emptyInboxTitle","emptyInboxTitleColor","emptyInboxText","emptyInboxTextColor","emptyInboxIconUrl","arrowBorderColor","COLOR_TEST_REGEXP","isElementFixed","element","isFixed","window","getComputedStyle","parentElement","messageTemplate","imageUrl","message","sendDate","date","localDate","Date","localTime","getHours","getTimezoneOffset","setHours","gap","getTime","Math","floor","getDate","getMonth","getFullYear","getMinutes","toString","slice","getMessageTime","PWInboxWidget","constructor","pw","inboxWidgetConfig","initParams","inboxWidget","config","updateInbox","bind","markVisibleItemsAsRead","onWidgetClickHandler","onTriggerClickHandler","onWindowScrollHandler","toggle","run","initTrigger","addListeners","isOpened","openWidget","closeWidget","pwinbox","Error","trigger","document","getElementById","classList","add","defaultMargin","messagesElements","messages","readItems","updateCounter","renderWidget","widget","createElement","id","className","widgetParent","querySelector","body","appendChild","getStyle","renderWidgetInner","styleNode","innerHTML","configureStyle","styles","resultStyles","forEach","style","template","RegExp","result","getStyleFormatter","replace","parseFloat","color","test","length","remove","renderMessages","widgetTemplateEmpty","list","messageElement","isRead","isActionPerformed","setAttribute","code","count","updateInboxMessages","sort","sendDateOne","sendDateTwo","dateOne","dateTwo","localDateOne","localTimeOne","localDateTwo","localTimeTwo","compareBySendDate","addEventListener","positionWidget","removeEventListener","updateReadStatus","removeAttribute","defaultPlaceWidget","customPlaceWidget","getDefaultPosition","widgetRect","getBoundingClientRect","documentElement","windowWidth","max","clientWidth","innerWidth","windowHeight","clientHeight","innerHeight","width","height","alignWidgetTop","alignWidgetRight","alignWidgetLeft","alignWidgetBottom","triggerRect","arrow","left","pageXOffset","isUnderLeft","isUnderRight","top","pageYOffset","alignWidgetElement","topMargin","newHeight","newTop","isUnderTop","isUnderBottom","rightMargin","right","newWidth","leftMargin","newLeft","bottomRange","bottom","antiMargins","leastMargin","min","keys","push","scrollTop","offsetTop","find","indexOf","readMessagesWithCodes","then","loadMessages","unreadMessagesCount","performMessageAction","performActionForMessageWithCode","removeMessages","deleteMessagesWithCodes","event","stopPropagation","target","itemElement","closest","messageCode","getAttribute"],"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 e=n();for(var o in e)("object"==typeof exports?exports:t)[o]=e[o]}}(this,(()=>(()=>{"use strict";var t={d:(n,e)=>{for(var o in e)t.o(e,o)&&!t.o(n,o)&&Object.defineProperty(n,o,{enumerable:!0,get:e[o]})},o:(t,n)=>Object.prototype.hasOwnProperty.call(t,n),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},n={};t.r(n),t.d(n,{PWSubscribePopupWidget:()=>i});const e={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"},o=/^(#([\da-f]{3}){1,2}$|(rgb|hsl)a\((\d{1,3}%?,\s?){3}(1|0?\.\d+)\)$|(rgb|hsl)\(\d{1,3}%?(,\s?\d{1,3}%?){2}\)$)/i,p=[{name:"mobileViewMargin",type:"string"},{name:"mobileViewPosition",type:"string"},{name:"mobileViewTransition",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"}];class i{constructor(t){this.pw=t;const{mobileViewMargin:n=""}=t.initParams.subscribePopup||{};this.config={...e,...t.initParams.subscribePopup,mobileViewTransition:n?"none":"bottom .4s ease-out",mobileViewPosition:n?"auto!important":"auto"},this.onAskLaterClick=this.onAskLaterClick.bind(this),this.onSubscribeClick=this.onSubscribeClick.bind(this)}async run(){const{manualToggle:t}=this.config,[n,e]=await Promise.all([this.pw.isSubscribed(),this.pw.data.getStatusManualUnsubscribed()]);if(n||!t&&e)return;const o=this.pw.driver.getPermission();if("granted"===o||"denied"===o)return;if(this.renderPopup(),this.appendStyles(),this.pw.moduleRegistry.subscribePopup=this,this.pw.dispatchEvent("subscribe-popup-ready",{}),t)return;const p=localStorage.getItem("LAST_OPEN_SUBSCRIPTION_POPUP"),i=p?parseInt(p):0,s=(new Date).getTime();i+1e3*this.config.retryOffset<s&&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:e,position:o}=this.config;if("topbar"===n&&"top"===o){const t=document.querySelector(e)||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:e,viewport:o,position:p}=this.config;if("topbar"===e&&"top"===p){const t=document.querySelector(o)||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:e,iconUrl:o,iconAlt:p,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.innerHTML=(({iconUrl:t,iconAlt:n,text:e,askLaterButtonText:o,confirmSubscriptionButtonText:p})=>`<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 ${e}\n </div>\n </div>\n <div class="pw-subscription-popup-controls">\n <button name="pwAskLater" class="pw-subscribe-popup-button">${o}</button>\n <button name="pwSubscribe" class="pw-subscribe-popup-button pw-subscribe-popup-button-active">${p}</button>\n </div>\n </div>`)({text:t,askLaterButtonText:n,confirmSubscriptionButtonText:e,iconUrl:o,iconAlt:p}),document.body.appendChild(this.popup),this.addListeners()}appendStyles(){const t=document.createElement("style");t.innerHTML=this.configureStyle(".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(--textSize);\n color: var(--textColor);\n font-weight: var(--textWeight);\n font-family: var(--fontFamily);\n border-style: solid;\n border-width: 1px;\n border-color: var(--borderColor);\n background: var(--bgColor);\n box-shadow: var(--boxShadow);\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(--askLaterBtnBorderColor);\n border-radius: var(--askLaterBtnBorderRadius);\n display: inline-block;\n height: 36px;\n line-height: 36px;\n padding: 0 16px;\n text-transform: uppercase;\n font-weight: var(--askLaterBtnTextWeight);\n vertical-align: middle;\n -webkit-tap-highlight-color: transparent;\n font-size: 14px;\n outline: 0;\n text-decoration: none;\n color: var(--askLaterBtnTextColor);\n text-align: center;\n letter-spacing: .5px;\n cursor: pointer;\n background: var(--askLaterBtnBgColor);\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(--subscribeBtnTextColor);\n background: var(--subscribeBtnBgColor);\n border-radius: var(--subscribeBtnBorderRadius);\n border: solid 1px var(--subscribeBtnBorderColor);\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(--subscribeBtnTextWeight);\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: var(--mobileViewPosition);\n bottom: -110%;\n left: 0;\n right: 0;\n transform: none;\n display: flex;\n transition: var(--mobileViewTransition);\n align-items: flex-end;\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(--mobileViewMargin);\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"),document.body.appendChild(t)}getStyleFormatter(t){switch(t.type){case"size":return`${this.config[t.name]||0}px`;case"number":return parseFloat(this.config[t.name].toString()).toString();case"string":return this.config[t.name].toString();case"color":return"transparent"===(n=this.config[t.name].toString())||o.test(n)?n:"#333";default:return"none"}var n}configureStyle(t){let n=t.toString();return p.forEach((t=>{const e=new RegExp(`var\\(--${t.name}\\)`,"ig"),o=this.getStyleFormatter(t);n=n.replace(e,o)})),n}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 e=n();for(var o in e)("object"==typeof exports?exports:t)[o]=e[o]}}(this,()=>(()=>{"use strict";var t={d:(n,e)=>{for(var o in e)t.o(e,o)&&!t.o(n,o)&&Object.defineProperty(n,o,{enumerable:!0,get:e[o]})},o:(t,n)=>Object.prototype.hasOwnProperty.call(t,n),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},n={};t.r(n),t.d(n,{PWSubscribePopupWidget:()=>i});const e={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"},o=/^(#([\da-f]{3}){1,2}$|(rgb|hsl)a\((\d{1,3}%?,\s?){3}(1|0?\.\d+)\)$|(rgb|hsl)\(\d{1,3}%?(,\s?\d{1,3}%?){2}\)$)/i,p=[{name:"mobileViewMargin",type:"string"},{name:"mobileViewPosition",type:"string"},{name:"mobileViewTransition",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"}];class i{constructor(t){this.pw=t;const{mobileViewMargin:n=""}=t.initParams.subscribePopup||{};this.config={...e,...t.initParams.subscribePopup,mobileViewTransition:n?"none":"bottom .4s ease-out",mobileViewPosition:n?"auto!important":"auto"},this.onAskLaterClick=this.onAskLaterClick.bind(this),this.onSubscribeClick=this.onSubscribeClick.bind(this)}async run(){const{manualToggle:t}=this.config,[n,e]=await Promise.all([this.pw.isSubscribed(),this.pw.data.getStatusManualUnsubscribed()]);if(n||!t&&e)return;const o=this.pw.driver.getPermission();if("granted"===o||"denied"===o)return;if(this.renderPopup(),this.appendStyles(),this.pw.moduleRegistry.subscribePopup=this,this.pw.dispatchEvent("subscribe-popup-ready",{}),t)return;const p=localStorage.getItem("LAST_OPEN_SUBSCRIPTION_POPUP"),i=p?parseInt(p):0,s=(new Date).getTime();i+1e3*this.config.retryOffset<s&&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:e,position:o}=this.config;if("topbar"===n&&"top"===o){const t=document.querySelector(e)||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:e,viewport:o,position:p}=this.config;if("topbar"===e&&"top"===p){const t=document.querySelector(o)||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:e,iconUrl:o,iconAlt:p,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.innerHTML=(({iconUrl:t,iconAlt:n,text:e,askLaterButtonText:o,confirmSubscriptionButtonText:p})=>`<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 ${e}\n </div>\n </div>\n <div class="pw-subscription-popup-controls">\n <button name="pwAskLater" class="pw-subscribe-popup-button">${o}</button>\n <button name="pwSubscribe" class="pw-subscribe-popup-button pw-subscribe-popup-button-active">${p}</button>\n </div>\n </div>`)({text:t,askLaterButtonText:n,confirmSubscriptionButtonText:e,iconUrl:o,iconAlt:p}),document.body.appendChild(this.popup),this.addListeners()}appendStyles(){const t=document.createElement("style");t.innerHTML=this.configureStyle(".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(--textSize);\n color: var(--textColor);\n font-weight: var(--textWeight);\n font-family: var(--fontFamily);\n border-style: solid;\n border-width: 1px;\n border-color: var(--borderColor);\n background: var(--bgColor);\n box-shadow: var(--boxShadow);\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(--askLaterBtnBorderColor);\n border-radius: var(--askLaterBtnBorderRadius);\n display: inline-block;\n height: 36px;\n line-height: 36px;\n padding: 0 16px;\n text-transform: uppercase;\n font-weight: var(--askLaterBtnTextWeight);\n vertical-align: middle;\n -webkit-tap-highlight-color: transparent;\n font-size: 14px;\n outline: 0;\n text-decoration: none;\n color: var(--askLaterBtnTextColor);\n text-align: center;\n letter-spacing: .5px;\n cursor: pointer;\n background: var(--askLaterBtnBgColor);\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(--subscribeBtnTextColor);\n background: var(--subscribeBtnBgColor);\n border-radius: var(--subscribeBtnBorderRadius);\n border: solid 1px var(--subscribeBtnBorderColor);\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(--subscribeBtnTextWeight);\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: var(--mobileViewPosition);\n bottom: -110%;\n left: 0;\n right: 0;\n transform: none;\n display: flex;\n transition: var(--mobileViewTransition);\n align-items: flex-end;\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(--mobileViewMargin);\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"),document.body.appendChild(t)}getStyleFormatter(t){switch(t.type){case"size":return`${this.config[t.name]||0}px`;case"number":return parseFloat(this.config[t.name].toString()).toString();case"string":return this.config[t.name].toString();case"color":return"transparent"===(n=this.config[t.name].toString())||o.test(n)?n:"#333";default:return"none"}var n}configureStyle(t){let n=t.toString();return p.forEach(t=>{const e=new RegExp(`var\\(--${t.name}\\)`,"ig"),o=this.getStyleFormatter(t);n=n.replace(e,o)}),n}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,SAA2CA,EAAMC,GAChD,GAAsB,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,SACb,GAAqB,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,OACP,CACJ,IAAIK,EAAIL,IACR,IAAI,IAAIM,KAAKD,GAAuB,iBAAZJ,QAAuBA,QAAUF,GAAMO,GAAKD,EAAEC,EACvE,CACA,CATD,CASGC,MAAM,I,mBCRT,IAAIC,EAAsB,CCA1BA,EAAwB,CAACP,EAASQ,KACjC,IAAI,IAAIC,KAAOD,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IAAK,SACH,OAAOiF,WAAWjI,KAAKuD,OAAOyD,EAAMhE,MAAMqE,YAAYA,WACxD,IAAK,SACH,OAAOrH,KAAKuD,OAAOyD,EAAMhE,MAAMqE,WACjC,IAAK,QACH,MEtMQ,iBADca,EFuMDlI,KAAKuD,OAAOyD,EAAMhE,MAAMqE,aElM5CvE,EAAkBqF,KAAKD,GAHrBA,EAKL,OFiMA,QACE,MAAO,OEzMR,IAAuBA,CF2M5B,CAEA,cAAAH,CAAeK,GACb,IAAIC,EAAeD,EAAOf,WAS1B,OAPAtE,EAAcuF,SAAStB,IACrB,MAAMuB,EAAW,IAAIC,OAAO,WAAWxB,EAAMhE,UAAW,MAClDyF,EAASzI,KAAKgI,kBAAkBhB,GAEtCqB,EAAeA,EAAaK,QAAQH,EAAUE,MAGzCJ,CACT,CAEA,YAAAP,GACE,MAAMa,EAAiB3I,KAAK0F,MAAMiB,cAAc,8BAC3Cd,SAASe,cAAc,UACtBgC,EAAkB5I,KAAK0F,MAAMiB,cAAc,+BAC5Cd,SAASe,cAAc,UAE5B+B,EAAeE,iBAAiB,QAAS7I,KAAK0D,iBAC9CkF,EAAgBC,iBAAiB,QAAS7I,KAAK4D,iBACjD,CAEA,eAAAF,GACE1D,KAAKqF,QAAO,GACZrF,KAAKoD,GAAGuB,cAAc,0BAA2B,CAAC,EACpD,CAEA,gBAAAf,GACE5D,KAAKqF,QAAO,GACZrF,KAAKoD,GAAGuB,cAAc,yBAA0B,CAAC,GACjD3E,KAAKoD,GAAG0F,WACV,E","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/widgets/SubscribePopup/SubscribePopup.ts","webpack://web-push-notifications/./src/widgets/SubscribePopup/popupTemplates.ts","webpack://web-push-notifications/./src/widgets/SubscribePopup/helpers.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\nvar __webpack_require__ = {};\n\n","// define getter 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\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\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\nexport const COLOR_TEST_REGEXP = /^(#([\\da-f]{3}){1,2}$|(rgb|hsl)a\\((\\d{1,3}%?,\\s?){3}(1|0?\\.\\d+)\\)$|(rgb|hsl)\\(\\d{1,3}%?(,\\s?\\d{1,3}%?){2}\\)$)/i;\n\n// Permissions\nexport const PERMISSION_DENIED = 'denied';\nexport const PERMISSION_GRANTED = 'granted';\n\nexport const CONFIG_STYLES: Array<ISubscribePopupConfigStyles> = [\n { name: 'mobileViewMargin', type: 'string' },\n { name: 'mobileViewPosition', type: 'string' },\n { name: 'mobileViewTransition', 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","import {\n DEFAULT_CONFIG,\n CONFIG_STYLES,\n\n PERMISSION_DENIED,\n PERMISSION_GRANTED,\n} from './constants';\nimport { getValidColor } from './helpers';\nimport { innerTemplate } from './popupTemplates';\nimport popupCss from './styles/popup.css';\nimport {\n type ISubscribePopupConfig,\n type ISubscribePopupConfigStyles,\n type ISubscribePopupVariables,\n} from './types/subscribe-popup';\nimport { type Pushwoosh } from '../../core/Pushwoosh';\n\nexport class PWSubscribePopupWidget {\n pw: Pushwoosh;\n config: ISubscribePopupVariables;\n popup: HTMLElement;\n isShown: 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 mobileViewTransition: mobileViewMargin ? 'none' : 'bottom .4s ease-out',\n mobileViewPosition: mobileViewMargin ? 'auto!important' : 'auto',\n };\n\n this.onAskLaterClick = this.onAskLaterClick.bind(this);\n this.onSubscribeClick = this.onSubscribeClick.bind(this);\n }\n\n async run() {\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 = this.pw.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.innerHTML = innerTemplate({\n text,\n askLaterButtonText,\n confirmSubscriptionButtonText,\n iconUrl,\n iconAlt,\n });\n document.body.appendChild(this.popup);\n this.addListeners();\n }\n\n appendStyles() {\n const style = document.createElement('style');\n style.innerHTML = this.configureStyle(popupCss);\n document.body.appendChild(style);\n }\n\n private getStyleFormatter(style: ISubscribePopupConfigStyles): string {\n switch (style.type) {\n case 'size':\n return `${this.config[style.name] || 0}px`;\n case 'number':\n return parseFloat(this.config[style.name].toString()).toString();\n case 'string':\n return this.config[style.name].toString();\n case 'color':\n return getValidColor(this.config[style.name].toString());\n default:\n return 'none';\n }\n }\n\n configureStyle(styles: string): string {\n let resultStyles = styles.toString();\n\n CONFIG_STYLES.forEach((style: ISubscribePopupConfigStyles) => {\n const template = new RegExp(`var\\\\(--${style.name}\\\\)`, 'ig');\n const result = this.getStyleFormatter(style);\n\n resultStyles = resultStyles.replace(template, result);\n });\n\n return resultStyles;\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","import { COLOR_TEST_REGEXP } from './constants';\n\nexport function getValidColor(color: string): string {\n if (color === 'transparent') {\n return color;\n }\n\n return COLOR_TEST_REGEXP.test(color)\n ? color\n : '#333';\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","COLOR_TEST_REGEXP","CONFIG_STYLES","name","type","PWSubscribePopupWidget","constructor","pw","initParams","subscribePopup","config","mobileViewTransition","mobileViewPosition","onAskLaterClick","bind","onSubscribeClick","run","manualToggle","isSubscribed","isManualUnsubscribed","Promise","all","data","getStatusManualUnsubscribed","permission","driver","getPermission","renderPopup","appendStyles","moduleRegistry","dispatchEvent","lastPopupOpen","localStorage","getItem","lastPopupOpenTime","parseInt","now","Date","getTime","setTimeout","toggle","isShown","isPopupShown","show","hide","popup","classList","add","document","body","event","CustomEvent","bubbles","cancelable","detail","Math","max","documentElement","clientWidth","window","innerWidth","viewportElement","querySelector","createElement","currentMarginTop","getComputedStyle","marginTop","style","transition","getBoundingClientRect","height","remove","toString","setItem","id","iconUrl","iconAlt","className","innerHTML","innerTemplate","appendChild","addListeners","configureStyle","getStyleFormatter","parseFloat","color","test","styles","resultStyles","forEach","template","RegExp","result","replace","askLaterButton","subscribeButton","addEventListener","subscribe"],"sourceRoot":""}
1
+ {"version":3,"file":"widget-subscribe-popup.js","mappings":"CAAA,SAA2CA,EAAMC,GAChD,GAAsB,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,SACb,GAAqB,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,OACP,CACJ,IAAIK,EAAIL,IACR,IAAI,IAAIM,KAAKD,GAAuB,iBAAZJ,QAAuBA,QAAUF,GAAMO,GAAKD,EAAEC,EACvE,CACA,CATD,CASGC,KAAM,I,mBCRT,IAAIC,EAAsB,CCA1BA,EAAwB,CAACP,EAASQ,KACjC,IAAI,IAAIC,KAAOD,EACXD,EAAoBG,EAAEF,EAAYC,KAASF,EAAoBG,EAAEV,EAASS,IAC5EE,OAAOC,eAAeZ,EAASS,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,MCJ3EF,EAAwB,CAACQ,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFT,EAAyBP,IACH,oBAAXoB,QAA0BA,OAAOC,aAC1CV,OAAOC,eAAeZ,EAASoB,OAAOC,YAAa,CAAEC,MAAO,WAE7DX,OAAOC,eAAeZ,EAAS,aAAc,CAAEsB,OAAO,M,kDCHhD,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,OACvB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+BAC5Cd,SAASe,cAAc,UAE5B+B,EAAeE,iBAAiB,QAAS7I,KAAK0D,iBAC9CkF,EAAgBC,iBAAiB,QAAS7I,KAAK4D,iBACjD,CAEA,eAAAF,GACE1D,KAAKqF,QAAO,GACZrF,KAAKoD,GAAGuB,cAAc,0BAA2B,CAAC,EACpD,CAEA,gBAAAf,GACE5D,KAAKqF,QAAO,GACZrF,KAAKoD,GAAGuB,cAAc,yBAA0B,CAAC,GACjD3E,KAAKoD,GAAG0F,WACV,E","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/widgets/SubscribePopup/SubscribePopup.ts","webpack://web-push-notifications/./src/widgets/SubscribePopup/popupTemplates.ts","webpack://web-push-notifications/./src/widgets/SubscribePopup/helpers.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\nvar __webpack_require__ = {};\n\n","// define getter 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\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\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\nexport const COLOR_TEST_REGEXP = /^(#([\\da-f]{3}){1,2}$|(rgb|hsl)a\\((\\d{1,3}%?,\\s?){3}(1|0?\\.\\d+)\\)$|(rgb|hsl)\\(\\d{1,3}%?(,\\s?\\d{1,3}%?){2}\\)$)/i;\n\n// Permissions\nexport const PERMISSION_DENIED = 'denied';\nexport const PERMISSION_GRANTED = 'granted';\n\nexport const CONFIG_STYLES: Array<ISubscribePopupConfigStyles> = [\n { name: 'mobileViewMargin', type: 'string' },\n { name: 'mobileViewPosition', type: 'string' },\n { name: 'mobileViewTransition', 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","import {\n DEFAULT_CONFIG,\n CONFIG_STYLES,\n\n PERMISSION_DENIED,\n PERMISSION_GRANTED,\n} from './constants';\nimport { getValidColor } from './helpers';\nimport { innerTemplate } from './popupTemplates';\nimport popupCss from './styles/popup.css';\nimport {\n type ISubscribePopupConfig,\n type ISubscribePopupConfigStyles,\n type ISubscribePopupVariables,\n} from './types/subscribe-popup';\nimport { type Pushwoosh } from '../../core/Pushwoosh';\n\nexport class PWSubscribePopupWidget {\n pw: Pushwoosh;\n config: ISubscribePopupVariables;\n popup: HTMLElement;\n isShown: 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 mobileViewTransition: mobileViewMargin ? 'none' : 'bottom .4s ease-out',\n mobileViewPosition: mobileViewMargin ? 'auto!important' : 'auto',\n };\n\n this.onAskLaterClick = this.onAskLaterClick.bind(this);\n this.onSubscribeClick = this.onSubscribeClick.bind(this);\n }\n\n async run() {\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 = this.pw.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.innerHTML = innerTemplate({\n text,\n askLaterButtonText,\n confirmSubscriptionButtonText,\n iconUrl,\n iconAlt,\n });\n document.body.appendChild(this.popup);\n this.addListeners();\n }\n\n appendStyles() {\n const style = document.createElement('style');\n style.innerHTML = this.configureStyle(popupCss);\n document.body.appendChild(style);\n }\n\n private getStyleFormatter(style: ISubscribePopupConfigStyles): string {\n switch (style.type) {\n case 'size':\n return `${this.config[style.name] || 0}px`;\n case 'number':\n return parseFloat(this.config[style.name].toString()).toString();\n case 'string':\n return this.config[style.name].toString();\n case 'color':\n return getValidColor(this.config[style.name].toString());\n default:\n return 'none';\n }\n }\n\n configureStyle(styles: string): string {\n let resultStyles = styles.toString();\n\n CONFIG_STYLES.forEach((style: ISubscribePopupConfigStyles) => {\n const template = new RegExp(`var\\\\(--${style.name}\\\\)`, 'ig');\n const result = this.getStyleFormatter(style);\n\n resultStyles = resultStyles.replace(template, result);\n });\n\n return resultStyles;\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","import { COLOR_TEST_REGEXP } from './constants';\n\nexport function getValidColor(color: string): string {\n if (color === 'transparent') {\n return color;\n }\n\n return COLOR_TEST_REGEXP.test(color)\n ? color\n : '#333';\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","COLOR_TEST_REGEXP","CONFIG_STYLES","name","type","PWSubscribePopupWidget","constructor","pw","initParams","subscribePopup","config","mobileViewTransition","mobileViewPosition","onAskLaterClick","bind","onSubscribeClick","run","manualToggle","isSubscribed","isManualUnsubscribed","Promise","all","data","getStatusManualUnsubscribed","permission","driver","getPermission","renderPopup","appendStyles","moduleRegistry","dispatchEvent","lastPopupOpen","localStorage","getItem","lastPopupOpenTime","parseInt","now","Date","getTime","setTimeout","toggle","isShown","isPopupShown","show","hide","popup","classList","add","document","body","event","CustomEvent","bubbles","cancelable","detail","Math","max","documentElement","clientWidth","window","innerWidth","viewportElement","querySelector","createElement","currentMarginTop","getComputedStyle","marginTop","style","transition","getBoundingClientRect","height","remove","toString","setItem","id","iconUrl","iconAlt","className","innerHTML","innerTemplate","appendChild","addListeners","configureStyle","getStyleFormatter","parseFloat","color","test","styles","resultStyles","forEach","template","RegExp","result","replace","askLaterButton","subscribeButton","addEventListener","subscribe"],"sourceRoot":""}