web-push-notifications 3.75.0 → 3.77.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/helpers/__tests__/cssColor.test.d.ts +1 -0
- package/helpers/__tests__/cssVariableUsage.d.ts +5 -0
- package/helpers/__tests__/cssVariables.test.d.ts +1 -0
- package/helpers/__tests__/styleConfigContract.d.ts +2 -0
- package/helpers/cssColor.d.ts +4 -0
- package/helpers/cssVariables.d.ts +8 -0
- package/npm.js +1 -1
- package/package.json +1 -1
- package/service-worker.js +1 -1
- package/widget-inbox.js +1 -1
- package/widget-inbox.js.map +1 -1
- package/widget-subscribe-popup.js +1 -1
- package/widget-subscribe-popup.js.map +1 -1
- package/widgets/Inbox/InboxWidget.d.ts +1 -2
- package/widgets/Inbox/constants.d.ts +2 -1
- package/widgets/Inbox/helpers.d.ts +0 -1
- package/widgets/Inbox/inbox_widget.types.d.ts +2 -5
- package/widgets/SubscribePopup/SubscribePopup.d.ts +4 -4
- package/widgets/SubscribePopup/__tests__/SubscribePopup.test.d.ts +1 -0
- package/widgets/SubscribePopup/__tests__/constants.test.d.ts +1 -0
- package/widgets/SubscribePopup/constants.d.ts +1 -1
- package/widgets/SubscribePopup/types/subscribe-popup.d.ts +3 -10
- package/widgets/SubscribePopup/helpers.d.ts +0 -1
package/widget-inbox.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"widget-inbox.js","mappings":"CAAA,SAAAA,EAAAC,GACA,oBAAAC,SAAA,iBAAAC,OACAA,OAAAD,QAAAD,SACA,sBAAAG,QAAAA,OAAAC,IACAD,OAAA,GAAAH,OACA,CACA,IAAAK,EAAAL,IACA,QAAAM,KAAAD,GAAA,iBAAAJ,QAAAA,QAAAF,GAAAO,GAAAD,EAAAC,EACA,CACC,CATD,CASCC,KAAA,uBCRD,MAAAC,EAAA,CCAAA,EAAA,CAAAP,EAAAQ,KACA,QAAAC,KA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K4I,SAIP,MAAMiI,EAAcF,EAAYG,aAAa,4BAE7C,IAAKD,EACH,OAKF,GAFsCL,EAAME,OAAQE,QAAQ,yBAI1D,YADA5Q,KAAKsQ,eAAe,CAACO,IAKvB,MAAME,EAA2BP,EAAME,OAAQE,QAAQ,iBAEvD,GAAIG,EAEF,YADA/Q,KAAKgR,UAAUH,EAAaI,SAASF,EAAWD,aAAa,kBAAoB,IAAK,KAMxF,MAAMI,EAA6BV,EAAME,OAAQE,QAAQ,mBACnDO,EAAYD,GAAgBA,EAAaJ,aAAa,sBD3kBzD,IAAmBnL,EC6kBlBwL,ID7kBkBxL,EC6kBKwL,KD5kBZ3J,EAAcpD,KAAKqD,EAAU9B,IC6kB1C2D,SAAS8H,SAASC,KAAOF,EAI3BnR,KAAKoQ,qBAAqBS,EAC5B,CAGQ,SAAAG,CAAUlF,EAAclF,GAC9B5G,KAAK6J,aAAaiC,GAAQlF,EAE1B,MAAM+E,EAAiB3L,KAAK4J,iBAAiBkC,GACvCtH,EAAUxE,KAAK8J,SAAS4F,KAAM4B,GAAuCA,EAAKxF,OAASA,GAErFH,GAAkBnH,IACpBmH,EAAef,UAAY/E,EAAgBrB,EAASoC,GAExD,CAEQ,qBAAA+B,GACF3I,KAAKyD,SAAWzD,KAAKgJ,SACvBhJ,KAAK4I,SAGP5I,KAAKwM,gBACP","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/helpers/escape.ts","webpack://web-push-notifications/./src/widgets/Inbox/widgetTemplates.ts","webpack://web-push-notifications/./src/models/InboxCell.ts","webpack://web-push-notifications/./src/helpers/url.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\nconst __webpack_require__ = {};\n\n","// define getter/value functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop));","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { type IConfigStyles, type IInboxWidgetConfig } from './inbox_widget.types';\n\n/** Shortest gap between two server refreshes triggered by opening the widget. */\nexport const SYNC_INTERVAL = 30 * 1000;\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 { name: 'unreadDotColor', type: 'color' },\n { name: 'avatarBgColor', type: 'color' },\n { name: 'avatarTextColor', type: 'color' },\n { name: 'avatarSize', type: 'size' },\n { name: 'mediaRadius', type: 'size' },\n { name: 'slideCaptionColor', type: 'color' },\n { name: 'slideScrimColor', type: 'color' },\n { name: 'pagerDotActiveColor', type: 'color' },\n { name: 'pagerDotColor', 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 legacyClassicCell: false,\n\n // Defaults mirror the control panel preview (dumb-components `InboxPreview`),\n // so a cell looks here the way the campaign editor promised it would.\n unreadDotColor: '#00a2ff', // Color.BRIGHT\n avatarBgColor: '#c4c8cc', // Color.PHANTOM\n avatarTextColor: '#4b5057', // Color.MAIN\n avatarSize: 52,\n mediaRadius: 8, // ShapeRadius.SECTION\n slideCaptionColor: '#ffffff', // Color.CLEAR\n slideScrimColor: 'rgba(0,0,0,.45)',\n pagerDotActiveColor: '#00a2ff', // Color.BRIGHT\n pagerDotColor: '#ebf0f5', // Color.DIVIDER\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\n// `sendDate` is a real UTC instant now, so the shift that used to undo an\n// equal one in `publicMessageBuilder` is gone.\nexport function getMessageTime(date: string): string {\n const localDate = new Date(date);\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\n// Newest first. The timezone shift the two dates used to go through cancelled\n// out for a comparison anyway, and is gone with the one in `getMessageTime`.\nexport function compareBySendDate(dateOne: string, dateTwo: string): number {\n return new Date(dateTwo).getTime() - new Date(dateOne).getTime();\n}\n","/** Used to map characters to HTML entities. */\nconst htmlEscapes: { [key: string]: string } = {\n '&': '&',\n '<': '<',\n '>': '>',\n '\"': '"',\n '\\'': ''',\n};\n\n/** Used to match HTML characters and HTML entities. */\nconst reUnescapedHtml = /[&<>\"']/g;\nconst reHasUnescapedHtml = RegExp(reUnescapedHtml.source);\n\n/** Converts `&`, `<`, `>`, `\"` and `'` to HTML entities. The inverse of `unescape`. */\nexport function escape(string: string): string {\n return (string && reHasUnescapedHtml.test(string))\n ? string.replace(reUnescapedHtml, (chr) => htmlEscapes[chr])\n : string;\n}\n","import { getMessageTime } from './helpers';\nimport { escape } from '../../helpers/escape';\nimport { getIconInitial } from '../../models/InboxCell';\nimport { type IInboxMessageSlide } from '../../models/InboxCell.types';\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\n// Campaign content, unlike the config-driven templates above: every value is\n// escaped because it reaches the page from the control panel.\n\n/** Small round avatar, or the colored initial drawn when the campaign sent no icon. */\nconst avatarTemplate = ({ iconUrl, title, message }: IInboxMessagePublic): string => (\n iconUrl\n ? `<img src=\"${escape(iconUrl)}\" alt=\"${escape(title || message)}\" class=\"pw-inbox_message-image\">`\n : `<span class=\"pw-inbox_icon-initial\">${escape(getIconInitial(title, message))}</span>`\n);\n\n/** Title, body and date. Shared by every layout that draws text at all. */\nconst textsTemplate = ({ title, message, sendDate, isRead }: IInboxMessagePublic): string => `\n<div class=\"pw-inbox_content\">\n <div class=\"pw-inbox_item-title\">\n ${escape(title)}${isRead ? '' : '<span class=\"pw-inbox_unread-dot\"></span>'}\n </div>\n <div class=\"pw-inbox_item-body\">\n ${escape(message)}\n </div>\n <div class=\"pw-inbox_item-time\">\n ${escape(getMessageTime(sendDate))}\n </div>\n</div>`;\n\nconst heroTemplate = (url: string, alt: string): string => `\n<div class=\"pw-inbox_media\">\n <img src=\"${escape(url)}\" alt=\"${escape(alt)}\" class=\"pw-inbox_hero\">\n</div>`;\n\nconst carouselTemplate = (slides: Array<IInboxMessageSlide>, activeIndex: number, alt: string): string => {\n const slide = slides[activeIndex];\n const caption = slide.caption\n ? `<span class=\"pw-inbox_slide-caption\">${escape(slide.caption)}</span>`\n : '';\n\n // One slide is in the DOM at a time: the widget replaces its own innerHTML on\n // every refresh, so there is no state to keep in the markup either way.\n const dots = slides.length > 1\n ? `<div class=\"pw-inbox_pager\">${slides\n .map((_slide, index) => `<button type=\"button\" class=\"pw-inbox_dot${index === activeIndex ? ' pw-active' : ''}\" data-pw-slide=\"${index}\"></button>`)\n .join('')}</div>`\n : '';\n\n return `\n<div class=\"pw-inbox_media\">\n <div class=\"pw-inbox_slide\" data-pw-slide-link=\"${escape(slide.link)}\">\n <img src=\"${escape(slide.imageUrl)}\" alt=\"${escape(slide.caption || alt)}\" class=\"pw-inbox_hero\">\n ${caption}\n </div>\n ${dots}\n</div>`;\n};\n\nexport const messageTemplate = (message: IInboxMessagePublic, activeSlide: number = 0): string => {\n const { layout, heroUrl, carousel, title, message: body } = message;\n const alt = title || body;\n\n let inner: string;\n\n switch (layout) {\n case 'banner':\n // Banner is the hero alone: the control panel sends it with no title or\n // body on purpose, and drawing an empty text block looks like a bug.\n inner = heroTemplate(heroUrl, alt);\n break;\n case 'captioned':\n inner = `${heroTemplate(heroUrl, alt)}${textsTemplate(message)}`;\n break;\n case 'carousel':\n inner = `${carouselTemplate(carousel, Math.min(activeSlide, carousel.length - 1), alt)}${textsTemplate(message)}`;\n break;\n default:\n inner = `<div class=\"pw-inbox_icon\">${avatarTemplate(message)}</div>${textsTemplate(message)}`;\n }\n\n return `\n<div class=\"pw-inbox_item-inner pw-inbox_item--${escape(layout)}\">\n ${inner}\n</div>\n<span class=\"pw-inbox_item-remove\"></span>`;\n};\n","import {\n type IInboxMessageSlide,\n type IInboxSlideRaw,\n type IInboxUserData,\n type TInboxLayout,\n} from './InboxCell.types';\nimport { type IInboxMessageActionParams } from './InboxMessages.types';\nimport { isSafeAbsoluteUrl } from '../helpers/url';\n\n// Cap of the sending pipeline (`maxInboxCarouselSlides`) and of the editor.\n// The rpc-v2 proto comment promising ten is wrong.\nexport const MAX_CAROUSEL_SLIDES = 5;\n\n/** Layouts we can draw; anything else falls back to the heuristic. */\nexport const KNOWN_LAYOUTS: ReadonlyArray<TInboxLayout> = ['classic', 'captioned', 'banner', 'carousel'];\n\n// An object from `getInboxMessages`, a JSON string on the push path; both\n// forms are accepted, as in the iOS SDK.\nexport function parseUserData(actionParams: IInboxMessageActionParams): IInboxUserData {\n const userData = actionParams?.u;\n\n if (!userData) {\n return {};\n }\n\n if (typeof userData === 'string') {\n try {\n return JSON.parse(userData) || {};\n } catch {\n return {};\n }\n }\n\n return typeof userData === 'object' ? <IInboxUserData>userData : {};\n}\n\n/** Slides we can draw: the ones with an image, at most {@link MAX_CAROUSEL_SLIDES}. */\nexport function getValidSlides(userData: IInboxUserData): Array<IInboxMessageSlide> {\n const slides: Array<IInboxSlideRaw> = Array.isArray(userData.carousel) ? userData.carousel : [];\n\n return slides\n .filter((slide) => !!slide && !!slide.image)\n .slice(0, MAX_CAROUSEL_SLIDES)\n .map((slide) => ({\n imageUrl: <string>slide.image,\n caption: slide.title || '',\n // Needs a scheme, as in the iOS SDK, and a scheme that is not script:\n // the widget assigns this straight to `location.href` on a tap.\n link: slide.url && isSafeAbsoluteUrl(slide.url) ? slide.url : '',\n }));\n}\n\n// Hero of the banner and captioned layouts. `b` is the campaign's `bannerUrl`\n// and the only hero source for web; the avatar stands in when none was sent.\nexport function getHeroUrl(\n actionParams: IInboxMessageActionParams,\n userData: IInboxUserData,\n messageImage: string,\n): string {\n return actionParams?.b || messageImage || userData.image || '';\n}\n\n/** Small round avatar of a cell: the message image, or the one inside `u`. */\nexport function getIconUrl(userData: IInboxUserData, messageImage: string): string {\n return messageImage || userData.image || '';\n}\n\n// Ported from `resolveInboxLayout` in dumb-components, so a cell draws here as\n// the control panel preview promised. Unrenderable layouts degrade to classic.\nexport function resolveInboxLayout(options: {\n displayType?: string;\n hasTitle: boolean;\n hasBody: boolean;\n /** Hero available to draw, avatar fallback included. Decides degradation. */\n heroUrl: string;\n /** The campaign's own banner, `action_params.b`. Only this may trigger the heuristic. */\n bannerUrl: string;\n slidesCount: number;\n}): TInboxLayout {\n const { hasTitle, hasBody, heroUrl, bannerUrl, slidesCount } = options;\n\n let requested = <TInboxLayout>options.displayType;\n\n if (KNOWN_LAYOUTS.indexOf(requested) === -1) {\n // Narrower than dumb-components on purpose: an icon must not count as a\n // hero here, or every legacy message would flip to captioned.\n if (bannerUrl && !hasTitle) {\n requested = 'banner';\n } else if (bannerUrl && hasTitle && hasBody) {\n requested = 'captioned';\n } else {\n requested = 'classic';\n }\n }\n\n switch (requested) {\n case 'banner':\n return heroUrl ? 'banner' : 'classic';\n case 'captioned':\n return heroUrl && hasTitle && hasBody ? 'captioned' : 'classic';\n case 'carousel':\n return hasTitle && hasBody && slidesCount > 0 ? 'carousel' : 'classic';\n default:\n return 'classic';\n }\n}\n\n/** The colored initial a classic cell shows when the campaign sent no icon. */\nexport function getIconInitial(title: string, body: string): string {\n return (title || body || '?').trim().charAt(0).toUpperCase() || '?';\n}\n\n// The pipeline merges `customData` flat into `u`, so the contract keys are the\n// only ones to strip.\nexport function getCustomData(userData: IInboxUserData): Record<string, unknown> {\n const contractKeys = ['displayType', 'carousel', 'image'];\n\n return Object.keys(userData)\n .filter((key) => contractKeys.indexOf(key) === -1)\n .reduce<Record<string, unknown>>((acc, key) => {\n acc[key] = userData[key];\n\n return acc;\n }, {});\n}\n","// Schemes that run script in the page's own origin; everything else either\n// navigates away or is handed to the OS.\nconst UNSAFE_SCHEME = /^(?:javascript|vbscript|data|blob|file):/i;\nconst HAS_SCHEME = /^[a-z][a-z\\d+\\-.]*:/i;\n\n// Browsers ignore whitespace and control characters while resolving a scheme,\n// so a tab inside \"java<tab>script:\" navigates just as `javascript:` does.\nfunction normalize(url: string): string {\n return url\n .split('')\n .filter((char) => char.charCodeAt(0) > 0x20 && char.charCodeAt(0) !== 0x7F)\n .join('');\n}\n\n/** True when the url is safe to assign to `location.href`. Relative urls qualify. */\nexport function isSafeUrl(url: string): boolean {\n return !!url && !UNSAFE_SCHEME.test(normalize(url));\n}\n\n/** True when the url carries a scheme and that scheme is safe to navigate to. */\nexport function isSafeAbsoluteUrl(url: string): boolean {\n const normalized = normalize(url);\n\n return HAS_SCHEME.test(normalized) && !UNSAFE_SCHEME.test(normalized);\n}\n","import {\n CONFIG_STYLES,\n DEFAULT_CONFIG,\n SYNC_INTERVAL,\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 { isSafeUrl } from '../../helpers/url';\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 /** Visible slide per carousel message, kept across the widget's re-renders. */\n activeSlides: { [code: string]: number };\n readItems: Array<string>;\n isOpened: boolean;\n config: IInboxWidgetConfig;\n defaultMargin: number;\n isFixed: boolean;\n private lastSyncAt: number = 0;\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 // Init has just pulled the inbox itself, so the first bell open must not\n // fetch the whole thing again seconds later.\n this.lastSyncAt = Date.now();\n\n this.defaultMargin = 12;\n this.messagesElements = {};\n this.activeSlides = {};\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 this.widget.classList.toggle('pw-inbox-widget--legacy-cell', this.config.legacyClassicCell);\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\n // innerHTML was just replaced, so every element collected last render is\n // detached: keeping them leaks and feeds stale offsets to the viewport check.\n this.messagesElements = {};\n\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, this.activeSlides[message.code] || 0);\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 this.syncMessages();\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 window.removeEventListener('scroll', 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 // Taken and cleared in one step: the codes are reported once, and a long\n // session does not keep growing the array across every open/close cycle.\n const codes = this.readItems;\n this.readItems = [];\n\n this.pw.pwinbox.readMessagesWithCodes(codes).then(this.updateInbox);\n }\n\n // Opening the bell is the only refresh besides init: a standalone App Inbox\n // message rides a channel with no sender, so no push announces one.\n private syncMessages() {\n // getInboxMessages returns the whole inbox, with no paging on the server\n // side, so toggling the bell must not turn into a request per click.\n if (Date.now() - this.lastSyncAt < SYNC_INTERVAL) {\n return;\n }\n\n this.lastSyncAt = Date.now();\n\n this.pw.pwinbox.syncMessages().catch((error: unknown) => {\n // Not the SDK Logger: it drags `core/storage` in and costs this bundle\n // ~20 KiB. SubscriptionButton logs the same way for the same reason.\n console.error('Pushwoosh: cannot refresh the inbox on open', error);\n });\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 // Was `slice(indexOf(code), 1)`, which returns an empty array for any index\n // past 1 and so discarded every pending read code, not just this one.\n this.readItems = this.readItems.filter((code: string) => messages.indexOf(code) === -1);\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 // A pager dot only switches the slide: it must not open the message.\n const dotElement = (<HTMLElement>event.target).closest('.pw-inbox_dot');\n\n if (dotElement) {\n this.showSlide(messageCode, parseInt(dotElement.getAttribute('data-pw-slide') || '0', 10));\n return;\n }\n\n // A slide link goes there instead of the whole message's action, as in the\n // iOS SDK. Re-checked here because the value round-trips through the DOM.\n const slideElement = (<HTMLElement>event.target).closest('.pw-inbox_slide');\n const slideLink = slideElement && slideElement.getAttribute('data-pw-slide-link');\n\n if (slideLink && isSafeUrl(slideLink)) {\n document.location.href = slideLink;\n return;\n }\n\n this.performMessageAction(messageCode);\n }\n\n /** Switch the visible slide of one carousel message and redraw just that cell. */\n private showSlide(code: string, index: number) {\n this.activeSlides[code] = index;\n\n const messageElement = this.messagesElements[code];\n const message = this.messages.find((item: IInboxMessagePublic): boolean => item.code === code);\n\n if (messageElement && message) {\n messageElement.innerHTML = messageTemplate(message, index);\n }\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","legacyClassicCell","unreadDotColor","avatarBgColor","avatarTextColor","avatarSize","mediaRadius","slideCaptionColor","slideScrimColor","pagerDotActiveColor","pagerDotColor","COLOR_TEST_REGEXP","isElementFixed","element","isFixed","window","getComputedStyle","parentElement","htmlEscapes","reUnescapedHtml","reHasUnescapedHtml","RegExp","source","escape_escape","string","test","replace","chr","textsTemplate","message","sendDate","isRead","date","localDate","Date","gap","getTime","Math","floor","getDate","getMonth","getFullYear","getHours","getMinutes","toString","slice","getMessageTime","heroTemplate","url","alt","messageTemplate","activeSlide","layout","heroUrl","carousel","body","inner","slides","activeIndex","slide","caption","dots","length","map","_slide","index","join","link","imageUrl","carouselTemplate","min","iconUrl","trim","charAt","toUpperCase","getIconInitial","avatarTemplate","UNSAFE_SCHEME","normalize","split","filter","char","charCodeAt","PWInboxWidget","constructor","pw","lastSyncAt","inboxWidgetConfig","initParams","inboxWidget","config","updateInbox","bind","markVisibleItemsAsRead","onWidgetClickHandler","onTriggerClickHandler","onWindowScrollHandler","toggle","run","initTrigger","addListeners","isOpened","openWidget","closeWidget","pwinbox","Error","trigger","document","getElementById","classList","add","now","defaultMargin","messagesElements","activeSlides","messages","readItems","updateCounter","renderWidget","widget","createElement","id","className","widgetParent","querySelector","appendChild","getStyle","renderWidgetInner","styleNode","innerHTML","configureStyle","styles","resultStyles","forEach","style","template","result","getStyleFormatter","parseFloat","color","remove","renderMessages","widgetTemplateEmpty","list","messageElement","isActionPerformed","setAttribute","code","count","updateInboxMessages","sort","sendDateOne","sendDateTwo","compareBySendDate","dateOne","syncMessages","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","keys","push","scrollTop","offsetTop","find","indexOf","codes","readMessagesWithCodes","then","catch","error","console","loadMessages","unreadMessagesCount","performMessageAction","performActionForMessageWithCode","removeMessages","deleteMessagesWithCodes","event","stopPropagation","target","itemElement","closest","messageCode","getAttribute","dotElement","showSlide","parseInt","slideElement","slideLink","location","href","item"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"widget-inbox.js","mappings":"CAAA,SAAAA,EAAAC,GACA,oBAAAC,SAAA,iBAAAC,OACAA,OAAAD,QAAAD,SACA,sBAAAG,QAAAA,OAAAC,IACAD,OAAA,GAAAH,OACA,CACA,IAAAK,EAAAL,IACA,QAAAM,KAAAD,GAAA,iBAAAJ,QAAAA,QAAAF,GAAAO,GAAAD,EAAAC,EACA,CACC,CATD,CASCC,KAAA,uBCRD,MAAAC,EAAA,CCAAA,EAAA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,GAAkB5H,IACpB4H,EAAeL,UAAYlG,EAAgBrB,EAASoC,GAExD,CAEQ,qBAAAoD,GACFrK,KAAK8D,SAAW9D,KAAK0K,SACvB1K,KAAKsK,SAGPtK,KAAKsN,gBACP","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/helpers/escape.ts","webpack://web-push-notifications/./src/widgets/Inbox/widgetTemplates.ts","webpack://web-push-notifications/./src/models/InboxCell.ts","webpack://web-push-notifications/./src/helpers/cssColor.ts","webpack://web-push-notifications/./src/helpers/cssVariables.ts","webpack://web-push-notifications/./src/helpers/url.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\nconst __webpack_require__ = {};\n\n","// define getter/value functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop));","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { type IConfigStyles, type IInboxWidgetConfig, type TStylesNames } from './inbox_widget.types';\n\n/** Shortest gap between two server refreshes triggered by opening the widget. */\nexport const SYNC_INTERVAL = 30 * 1000;\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 STYLE_PREFIX = 'pw-inbox';\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 { name: 'unreadDotColor', type: 'color' },\n { name: 'avatarBgColor', type: 'color' },\n { name: 'avatarTextColor', type: 'color' },\n { name: 'avatarSize', type: 'size' },\n { name: 'mediaRadius', type: 'size' },\n { name: 'slideCaptionColor', type: 'color' },\n { name: 'slideScrimColor', type: 'color' },\n { name: 'pagerDotActiveColor', type: 'color' },\n { name: 'pagerDotColor', type: 'color' },\n];\n\n// The trigger is the customer's own element, outside the widget root, so the\n// badge rules need their variables set on it too.\nconst TRIGGER_STYLE_NAMES: Array<TStylesNames> = ['badgeBgColor', 'badgeTextColor'];\n\nexport const TRIGGER_CONFIG_STYLES: Array<IConfigStyles> = CONFIG_STYLES\n .filter((style) => TRIGGER_STYLE_NAMES.indexOf(style.name) !== -1);\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 legacyClassicCell: false,\n\n // Defaults mirror the control panel preview (dumb-components `InboxPreview`),\n // so a cell looks here the way the campaign editor promised it would.\n unreadDotColor: '#00a2ff', // Color.BRIGHT\n avatarBgColor: '#c4c8cc', // Color.PHANTOM\n avatarTextColor: '#4b5057', // Color.MAIN\n avatarSize: 52,\n mediaRadius: 8, // ShapeRadius.SECTION\n slideCaptionColor: '#ffffff', // Color.CLEAR\n slideScrimColor: 'rgba(0,0,0,.45)',\n pagerDotActiveColor: '#00a2ff', // Color.BRIGHT\n pagerDotColor: '#ebf0f5', // Color.DIVIDER\n};\n","import {\n MILLISECONDS_IN_HOUR,\n MILLISECONDS_IN_DAY,\n MONTHS,\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\n// `sendDate` is a real UTC instant now, so the shift that used to undo an\n// equal one in `publicMessageBuilder` is gone.\nexport function getMessageTime(date: string): string {\n const localDate = new Date(date);\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\n// Newest first. The timezone shift the two dates used to go through cancelled\n// out for a comparison anyway, and is gone with the one in `getMessageTime`.\nexport function compareBySendDate(dateOne: string, dateTwo: string): number {\n return new Date(dateTwo).getTime() - new Date(dateOne).getTime();\n}\n","/** Used to map characters to HTML entities. */\nconst htmlEscapes: { [key: string]: string } = {\n '&': '&',\n '<': '<',\n '>': '>',\n '\"': '"',\n '\\'': ''',\n};\n\n/** Used to match HTML characters and HTML entities. */\nconst reUnescapedHtml = /[&<>\"']/g;\nconst reHasUnescapedHtml = RegExp(reUnescapedHtml.source);\n\n/** Converts `&`, `<`, `>`, `\"` and `'` to HTML entities. The inverse of `unescape`. */\nexport function escape(string: string): string {\n return (string && reHasUnescapedHtml.test(string))\n ? string.replace(reUnescapedHtml, (chr) => htmlEscapes[chr])\n : string;\n}\n","import { getMessageTime } from './helpers';\nimport { escape } from '../../helpers/escape';\nimport { getIconInitial } from '../../models/InboxCell';\nimport { type IInboxMessageSlide } from '../../models/InboxCell.types';\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\n// Campaign content, unlike the config-driven templates above: every value is\n// escaped because it reaches the page from the control panel.\n\n/** Small round avatar, or the colored initial drawn when the campaign sent no icon. */\nconst avatarTemplate = ({ iconUrl, title, message }: IInboxMessagePublic): string => (\n iconUrl\n ? `<img src=\"${escape(iconUrl)}\" alt=\"${escape(title || message)}\" class=\"pw-inbox_message-image\">`\n : `<span class=\"pw-inbox_icon-initial\">${escape(getIconInitial(title, message))}</span>`\n);\n\n/** Title, body and date. Shared by every layout that draws text at all. */\nconst textsTemplate = ({ title, message, sendDate, isRead }: IInboxMessagePublic): string => `\n<div class=\"pw-inbox_content\">\n <div class=\"pw-inbox_item-title\">\n ${escape(title)}${isRead ? '' : '<span class=\"pw-inbox_unread-dot\"></span>'}\n </div>\n <div class=\"pw-inbox_item-body\">\n ${escape(message)}\n </div>\n <div class=\"pw-inbox_item-time\">\n ${escape(getMessageTime(sendDate))}\n </div>\n</div>`;\n\nconst heroTemplate = (url: string, alt: string): string => `\n<div class=\"pw-inbox_media\">\n <img src=\"${escape(url)}\" alt=\"${escape(alt)}\" class=\"pw-inbox_hero\">\n</div>`;\n\nconst carouselTemplate = (slides: Array<IInboxMessageSlide>, activeIndex: number, alt: string): string => {\n const slide = slides[activeIndex];\n const caption = slide.caption\n ? `<span class=\"pw-inbox_slide-caption\">${escape(slide.caption)}</span>`\n : '';\n\n // One slide is in the DOM at a time: the widget replaces its own innerHTML on\n // every refresh, so there is no state to keep in the markup either way.\n const dots = slides.length > 1\n ? `<div class=\"pw-inbox_pager\">${slides\n .map((_slide, index) => `<button type=\"button\" class=\"pw-inbox_dot${index === activeIndex ? ' pw-active' : ''}\" data-pw-slide=\"${index}\"></button>`)\n .join('')}</div>`\n : '';\n\n return `\n<div class=\"pw-inbox_media\">\n <div class=\"pw-inbox_slide\" data-pw-slide-link=\"${escape(slide.link)}\">\n <img src=\"${escape(slide.imageUrl)}\" alt=\"${escape(slide.caption || alt)}\" class=\"pw-inbox_hero\">\n ${caption}\n </div>\n ${dots}\n</div>`;\n};\n\nexport const messageTemplate = (message: IInboxMessagePublic, activeSlide: number = 0): string => {\n const { layout, heroUrl, carousel, title, message: body } = message;\n const alt = title || body;\n\n let inner: string;\n\n switch (layout) {\n case 'banner':\n // Banner is the hero alone: the control panel sends it with no title or\n // body on purpose, and drawing an empty text block looks like a bug.\n inner = heroTemplate(heroUrl, alt);\n break;\n case 'captioned':\n inner = `${heroTemplate(heroUrl, alt)}${textsTemplate(message)}`;\n break;\n case 'carousel':\n inner = `${carouselTemplate(carousel, Math.min(activeSlide, carousel.length - 1), alt)}${textsTemplate(message)}`;\n break;\n default:\n inner = `<div class=\"pw-inbox_icon\">${avatarTemplate(message)}</div>${textsTemplate(message)}`;\n }\n\n return `\n<div class=\"pw-inbox_item-inner pw-inbox_item--${escape(layout)}\">\n ${inner}\n</div>\n<span class=\"pw-inbox_item-remove\"></span>`;\n};\n","import {\n type IInboxMessageSlide,\n type IInboxSlideRaw,\n type IInboxUserData,\n type TInboxLayout,\n} from './InboxCell.types';\nimport { type IInboxMessageActionParams } from './InboxMessages.types';\nimport { isSafeAbsoluteUrl } from '../helpers/url';\n\n// Cap of the sending pipeline (`maxInboxCarouselSlides`) and of the editor.\n// The rpc-v2 proto comment promising ten is wrong.\nexport const MAX_CAROUSEL_SLIDES = 5;\n\n/** Layouts we can draw; anything else falls back to the heuristic. */\nexport const KNOWN_LAYOUTS: ReadonlyArray<TInboxLayout> = ['classic', 'captioned', 'banner', 'carousel'];\n\n// An object from `getInboxMessages`, a JSON string on the push path; both\n// forms are accepted, as in the iOS SDK.\nexport function parseUserData(actionParams: IInboxMessageActionParams): IInboxUserData {\n const userData = actionParams?.u;\n\n if (!userData) {\n return {};\n }\n\n if (typeof userData === 'string') {\n try {\n return JSON.parse(userData) || {};\n } catch {\n return {};\n }\n }\n\n return typeof userData === 'object' ? <IInboxUserData>userData : {};\n}\n\n/** Slides we can draw: the ones with an image, at most {@link MAX_CAROUSEL_SLIDES}. */\nexport function getValidSlides(userData: IInboxUserData): Array<IInboxMessageSlide> {\n const slides: Array<IInboxSlideRaw> = Array.isArray(userData.carousel) ? userData.carousel : [];\n\n return slides\n .filter((slide) => !!slide && !!slide.image)\n .slice(0, MAX_CAROUSEL_SLIDES)\n .map((slide) => ({\n imageUrl: <string>slide.image,\n caption: slide.title || '',\n // Needs a scheme, as in the iOS SDK, and a scheme that is not script:\n // the widget assigns this straight to `location.href` on a tap.\n link: slide.url && isSafeAbsoluteUrl(slide.url) ? slide.url : '',\n }));\n}\n\n// Hero of the banner and captioned layouts. `b` is the campaign's `bannerUrl`\n// and the only hero source for web; the avatar stands in when none was sent.\nexport function getHeroUrl(\n actionParams: IInboxMessageActionParams,\n userData: IInboxUserData,\n messageImage: string,\n): string {\n return actionParams?.b || messageImage || userData.image || '';\n}\n\n/** Small round avatar of a cell: the message image, or the one inside `u`. */\nexport function getIconUrl(userData: IInboxUserData, messageImage: string): string {\n return messageImage || userData.image || '';\n}\n\n// Ported from `resolveInboxLayout` in dumb-components, so a cell draws here as\n// the control panel preview promised. Unrenderable layouts degrade to classic.\nexport function resolveInboxLayout(options: {\n displayType?: string;\n hasTitle: boolean;\n hasBody: boolean;\n /** Hero available to draw, avatar fallback included. Decides degradation. */\n heroUrl: string;\n /** The campaign's own banner, `action_params.b`. Only this may trigger the heuristic. */\n bannerUrl: string;\n slidesCount: number;\n}): TInboxLayout {\n const { hasTitle, hasBody, heroUrl, bannerUrl, slidesCount } = options;\n\n let requested = <TInboxLayout>options.displayType;\n\n if (KNOWN_LAYOUTS.indexOf(requested) === -1) {\n // Narrower than dumb-components on purpose: an icon must not count as a\n // hero here, or every legacy message would flip to captioned.\n if (bannerUrl && !hasTitle) {\n requested = 'banner';\n } else if (bannerUrl && hasTitle && hasBody) {\n requested = 'captioned';\n } else {\n requested = 'classic';\n }\n }\n\n switch (requested) {\n case 'banner':\n return heroUrl ? 'banner' : 'classic';\n case 'captioned':\n return heroUrl && hasTitle && hasBody ? 'captioned' : 'classic';\n case 'carousel':\n return hasTitle && hasBody && slidesCount > 0 ? 'carousel' : 'classic';\n default:\n return 'classic';\n }\n}\n\n/** The colored initial a classic cell shows when the campaign sent no icon. */\nexport function getIconInitial(title: string, body: string): string {\n return (title || body || '?').trim().charAt(0).toUpperCase() || '?';\n}\n\n// The pipeline merges `customData` flat into `u`, so the contract keys are the\n// only ones to strip.\nexport function getCustomData(userData: IInboxUserData): Record<string, unknown> {\n const contractKeys = ['displayType', 'carousel', 'image'];\n\n return Object.keys(userData)\n .filter((key) => contractKeys.indexOf(key) === -1)\n .reduce<Record<string, unknown>>((acc, key) => {\n acc[key] = userData[key];\n\n return acc;\n }, {});\n}\n","/** Drawn when the configured colour is one the browser would refuse. */\nexport const FALLBACK_COLOR = '#333';\n\n// A colour value never needs these, and they are exactly what would end the\n// declaration or the rule it is interpolated into.\nconst RULE_BREAKERS = /[;{}]/;\n\n// One element, reused: the widgets validate every colour of their config on\n// each render.\nlet probe: HTMLElement | null = null;\n\n/** Keeps a colour the browser accepts, and replaces anything else with {@link FALLBACK_COLOR}. */\nexport function getValidColor(color: string): string {\n if (RULE_BREAKERS.test(color)) {\n return FALLBACK_COLOR;\n }\n\n if (!probe) {\n probe = document.createElement('div');\n }\n\n probe.style.color = '';\n probe.style.color = color;\n\n return probe.style.color ? color : FALLBACK_COLOR;\n}\n","import { getValidColor } from './cssColor';\n\nexport type TStyleVariableType = 'number' | 'color' | 'string' | 'size';\n\nexport interface IStyleVariable<TName extends string = string> {\n name: TName;\n type: TStyleVariableType;\n}\n\nexport function getCssVariableName(prefix: string, name: string): string {\n return `--${prefix}-${name}`;\n}\n\n// `null` means \"leave it unset\": a custom property holding garbage makes every\n// rule that reads it invalid, while an absent one falls back to the stylesheet.\nexport function formatStyleVariable(type: TStyleVariableType, value: string | number | undefined): string | null {\n switch (type) {\n case 'size': {\n const size = Number(value ?? 0);\n return Number.isFinite(size) ? `${size}px` : null;\n }\n case 'number': {\n const parsed = parseFloat(String(value));\n return Number.isFinite(parsed) ? String(parsed) : null;\n }\n case 'color': {\n const color = String(value);\n return getValidColor(color) === color ? color : null;\n }\n default: {\n const text = String(value).trim();\n return text || null;\n }\n }\n}\n\nexport function applyStyleVariables<TName extends string>(\n element: HTMLElement,\n prefix: string,\n variables: Array<IStyleVariable<TName>>,\n values: Record<TName, string | number>,\n): void {\n variables.forEach(({ name, type }) => {\n const formatted = formatStyleVariable(type, values[name]);\n\n if (formatted !== null) {\n element.style.setProperty(getCssVariableName(prefix, name), formatted);\n }\n });\n}\n","// Schemes that run script in the page's own origin; everything else either\n// navigates away or is handed to the OS.\nconst UNSAFE_SCHEME = /^(?:javascript|vbscript|data|blob|file):/i;\nconst HAS_SCHEME = /^[a-z][a-z\\d+\\-.]*:/i;\n\n// Browsers ignore whitespace and control characters while resolving a scheme,\n// so a tab inside \"java<tab>script:\" navigates just as `javascript:` does.\nfunction normalize(url: string): string {\n return url\n .split('')\n .filter((char) => char.charCodeAt(0) > 0x20 && char.charCodeAt(0) !== 0x7F)\n .join('');\n}\n\n/** True when the url is safe to assign to `location.href`. Relative urls qualify. */\nexport function isSafeUrl(url: string): boolean {\n return !!url && !UNSAFE_SCHEME.test(normalize(url));\n}\n\n/** True when the url carries a scheme and that scheme is safe to navigate to. */\nexport function isSafeAbsoluteUrl(url: string): boolean {\n const normalized = normalize(url);\n\n return HAS_SCHEME.test(normalized) && !UNSAFE_SCHEME.test(normalized);\n}\n","import {\n CONFIG_STYLES,\n DEFAULT_CONFIG,\n STYLE_PREFIX,\n SYNC_INTERVAL,\n TRIGGER_CONFIG_STYLES,\n} from './constants';\nimport inboxWidgetStyleCss from './css/inboxWidgetStyle.css';\nimport {\n isElementFixed,\n compareBySendDate,\n} from './helpers';\nimport { 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 { applyStyleVariables } from '../../helpers/cssVariables';\nimport { isSafeUrl } from '../../helpers/url';\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 /** Visible slide per carousel message, kept across the widget's re-renders. */\n activeSlides: { [code: string]: number };\n readItems: Array<string>;\n isOpened: boolean;\n config: IInboxWidgetConfig;\n defaultMargin: number;\n isFixed: boolean;\n private lastSyncAt: number = 0;\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 // Init has just pulled the inbox itself, so the first bell open must not\n // fetch the whole thing again seconds later.\n this.lastSyncAt = Date.now();\n\n this.defaultMargin = 12;\n this.messagesElements = {};\n this.activeSlides = {};\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 this.widget.classList.toggle('pw-inbox-widget--legacy-cell', this.config.legacyClassicCell);\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.applyStyleVariables();\n this.renderWidgetInner();\n }\n\n private getStyle(): HTMLStyleElement {\n const styleNode = document.createElement('style');\n styleNode.innerHTML = inboxWidgetStyleCss.toString();\n return styleNode;\n }\n\n private applyStyleVariables() {\n applyStyleVariables(this.widget, STYLE_PREFIX, CONFIG_STYLES, this.config);\n applyStyleVariables(this.trigger, STYLE_PREFIX, TRIGGER_CONFIG_STYLES, this.config);\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\n // innerHTML was just replaced, so every element collected last render is\n // detached: keeping them leaks and feeds stale offsets to the viewport check.\n this.messagesElements = {};\n\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, this.activeSlides[message.code] || 0);\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 this.syncMessages();\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 window.removeEventListener('scroll', 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 // Taken and cleared in one step: the codes are reported once, and a long\n // session does not keep growing the array across every open/close cycle.\n const codes = this.readItems;\n this.readItems = [];\n\n this.pw.pwinbox.readMessagesWithCodes(codes).then(this.updateInbox);\n }\n\n // Opening the bell is the only refresh besides init: a standalone App Inbox\n // message rides a channel with no sender, so no push announces one.\n private syncMessages() {\n // getInboxMessages returns the whole inbox, with no paging on the server\n // side, so toggling the bell must not turn into a request per click.\n if (Date.now() - this.lastSyncAt < SYNC_INTERVAL) {\n return;\n }\n\n this.lastSyncAt = Date.now();\n\n this.pw.pwinbox.syncMessages().catch((error: unknown) => {\n // Not the SDK Logger: it drags `core/storage` in and costs this bundle\n // ~20 KiB. SubscriptionButton logs the same way for the same reason.\n console.error('Pushwoosh: cannot refresh the inbox on open', error);\n });\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 // Was `slice(indexOf(code), 1)`, which returns an empty array for any index\n // past 1 and so discarded every pending read code, not just this one.\n this.readItems = this.readItems.filter((code: string) => messages.indexOf(code) === -1);\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 // A pager dot only switches the slide: it must not open the message.\n const dotElement = (<HTMLElement>event.target).closest('.pw-inbox_dot');\n\n if (dotElement) {\n this.showSlide(messageCode, parseInt(dotElement.getAttribute('data-pw-slide') || '0', 10));\n return;\n }\n\n // A slide link goes there instead of the whole message's action, as in the\n // iOS SDK. Re-checked here because the value round-trips through the DOM.\n const slideElement = (<HTMLElement>event.target).closest('.pw-inbox_slide');\n const slideLink = slideElement && slideElement.getAttribute('data-pw-slide-link');\n\n if (slideLink && isSafeUrl(slideLink)) {\n document.location.href = slideLink;\n return;\n }\n\n this.performMessageAction(messageCode);\n }\n\n /** Switch the visible slide of one carousel message and redraw just that cell. */\n private showSlide(code: string, index: number) {\n this.activeSlides[code] = index;\n\n const messageElement = this.messagesElements[code];\n const message = this.messages.find((item: IInboxMessagePublic): boolean => item.code === code);\n\n if (messageElement && message) {\n messageElement.innerHTML = messageTemplate(message, index);\n }\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","STYLE_PREFIX","CONFIG_STYLES","name","type","TRIGGER_STYLE_NAMES","TRIGGER_CONFIG_STYLES","filter","style","indexOf","DEFAULT_CONFIG","enable","triggerId","position","appendTo","title","bgColor","textColor","fontFamily","borderRadius","borderColor","badgeBgColor","badgeTextColor","widgetWidth","zIndex","messageTitleColor","timeTextColor","emptyInboxTitle","emptyInboxTitleColor","emptyInboxText","emptyInboxTextColor","emptyInboxIconUrl","arrowBorderColor","legacyClassicCell","unreadDotColor","avatarBgColor","avatarTextColor","avatarSize","mediaRadius","slideCaptionColor","slideScrimColor","pagerDotActiveColor","pagerDotColor","isElementFixed","element","isFixed","window","getComputedStyle","parentElement","htmlEscapes","reUnescapedHtml","reHasUnescapedHtml","RegExp","source","escape_escape","string","test","replace","chr","textsTemplate","message","sendDate","isRead","date","localDate","Date","gap","getTime","Math","floor","getDate","getMonth","getFullYear","getHours","getMinutes","toString","slice","getMessageTime","heroTemplate","url","alt","messageTemplate","activeSlide","layout","heroUrl","carousel","body","inner","slides","activeIndex","slide","caption","dots","length","map","_slide","index","join","link","imageUrl","carouselTemplate","min","iconUrl","trim","charAt","toUpperCase","getIconInitial","avatarTemplate","FALLBACK_COLOR","RULE_BREAKERS","probe","formatStyleVariable","size","Number","isFinite","parsed","parseFloat","String","color","document","createElement","getValidColor","applyStyleVariables","prefix","variables","values","forEach","formatted","setProperty","getCssVariableName","UNSAFE_SCHEME","normalize","split","char","charCodeAt","PWInboxWidget","constructor","pw","lastSyncAt","inboxWidgetConfig","initParams","inboxWidget","config","updateInbox","bind","markVisibleItemsAsRead","onWidgetClickHandler","onTriggerClickHandler","onWindowScrollHandler","toggle","run","initTrigger","addListeners","isOpened","openWidget","closeWidget","pwinbox","Error","trigger","getElementById","classList","add","now","defaultMargin","messagesElements","activeSlides","messages","readItems","updateCounter","renderWidget","widget","id","className","widgetParent","querySelector","appendChild","getStyle","renderWidgetInner","styleNode","innerHTML","remove","renderMessages","widgetTemplateEmpty","list","messageElement","isActionPerformed","setAttribute","code","count","updateInboxMessages","sort","sendDateOne","sendDateTwo","compareBySendDate","dateOne","syncMessages","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","keys","push","scrollTop","offsetTop","find","codes","readMessagesWithCodes","then","catch","error","console","loadMessages","unreadMessagesCount","performMessageAction","performActionForMessageWithCode","removeMessages","deleteMessagesWithCodes","event","stopPropagation","target","itemElement","closest","messageCode","getAttribute","dotElement","showSlide","parseInt","slideElement","slideLink","location","href","item"],"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";const 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=>{Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}};let 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 t=this.pw.isPushAvailable()?this.pw.driver:null;if(!t)return;const{manualToggle:n}=this.config,[e,o]=await Promise.all([this.pw.isSubscribed(),this.pw.data.getStatusManualUnsubscribed()]);if(e||!n&&o)return;const p=t.getPermission();if("granted"===p||"denied"===p)return;if(this.renderPopup(),this.appendStyles(),this.pw.moduleRegistry.subscribePopup=this,this.pw.dispatchEvent("subscribe-popup-ready",{}),n)return;const i=localStorage.getItem("LAST_OPEN_SUBSCRIPTION_POPUP"),s=i?parseInt(i):0,r=(new Date).getTime();s+1e3*this.config.retryOffset<r&&setTimeout(()=>{this.toggle(!0)},1e3*this.config.delay)}toggle(t){const n=void 0===t?!this.isShown:!!t;n!==this.isShown&&(n?this.show():this.hide())}async show(){if(await this.pw.isSubscribed())return;this.isShown=!0,this.popup.classList.add("pw-show"),document.body.classList.add("pw-popup-opened");const t=new CustomEvent("showPopup",{bubbles:!1,cancelable:!1,detail:{popup:this.popup}});this.popup.dispatchEvent(t);if(Math.max(document.documentElement.clientWidth,window.innerWidth||0)<541)return;const{theme:n,viewport: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 p=n();for(var e in p)("object"==typeof exports?exports:t)[e]=p[e]}}(this,()=>(()=>{"use strict";const t={d:(n,p)=>{for(var e in p)t.o(p,e)&&!t.o(n,e)&&Object.defineProperty(n,e,{enumerable:!0,get:p[e]})},o:(t,n)=>Object.prototype.hasOwnProperty.call(t,n),r:t=>{Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}};let n={};t.r(n),t.d(n,{PWSubscribePopupWidget:()=>a});const p={enable:!0,text:"Don’t miss out on our news and updates! Enable push notifications",askLaterButtonText:"Not now",confirmSubscriptionButtonText:"Subscribe",delay:5,retryOffset:604800,overlay:!1,position:"top",mobileViewMargin:"0",bgColor:"#fff",borderColor:"transparent",boxShadow:"0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23)",textColor:"#000",textSize:"inherit",textWeight:"normal",fontFamily:"inherit",subscribeBtnBgColor:"#4285f4",subscribeBtnTextColor:"#fff",subscribeBtnTextWeight:"normal",subscribeBtnBorderColor:"transparent",subscribeBtnBorderRadius:"2px",askLaterBtnBgColor:"transparent",askLaterBtnTextColor:"#000",askLaterBtnTextWeight:"normal",askLaterBtnBorderColor:"transparent",askLaterBtnBorderRadius:"2px",theme:"material",viewport:"html"},e=[{name:"mobileViewMargin",type:"string"},{name:"bgColor",type:"color"},{name:"borderColor",type:"color"},{name:"boxShadow",type:"string"},{name:"textColor",type:"color"},{name:"textSize",type:"string"},{name:"textWeight",type:"string"},{name:"fontFamily",type:"string"},{name:"subscribeBtnBgColor",type:"color"},{name:"subscribeBtnTextColor",type:"color"},{name:"subscribeBtnTextWeight",type:"string"},{name:"subscribeBtnBorderColor",type:"color"},{name:"subscribeBtnBorderRadius",type:"string"},{name:"askLaterBtnBgColor",type:"color"},{name:"askLaterBtnTextColor",type:"color"},{name:"askLaterBtnTextWeight",type:"string"},{name:"askLaterBtnBorderColor",type:"color"},{name:"askLaterBtnBorderRadius",type:"string"}],o="#333",i=/[;{}]/;let s=null;function r(t,n){switch(t){case"size":{const t=Number(n??0);return Number.isFinite(t)?`${t}px`:null}case"number":{const t=parseFloat(String(n));return Number.isFinite(t)?String(t):null}case"color":{const t=String(n);return function(t){return i.test(t)?o:(s||(s=document.createElement("div")),s.style.color="",s.style.color=t,s.style.color?t:o)}(t)===t?t:null}default:return String(n).trim()||null}}class a{constructor(t){this.pw=t;const{mobileViewMargin:n=""}=t.initParams.subscribePopup||{};this.config={...p,...t.initParams.subscribePopup},this.hasMobileViewMargin=Boolean(n),this.onAskLaterClick=this.onAskLaterClick.bind(this),this.onSubscribeClick=this.onSubscribeClick.bind(this)}async run(){const t=this.pw.isPushAvailable()?this.pw.driver:null;if(!t)return;const{manualToggle:n}=this.config,[p,e]=await Promise.all([this.pw.isSubscribed(),this.pw.data.getStatusManualUnsubscribed()]);if(p||!n&&e)return;const o=t.getPermission();if("granted"===o||"denied"===o)return;if(this.renderPopup(),this.appendStyles(),this.pw.moduleRegistry.subscribePopup=this,this.pw.dispatchEvent("subscribe-popup-ready",{}),n)return;const i=localStorage.getItem("LAST_OPEN_SUBSCRIPTION_POPUP"),s=i?parseInt(i):0,r=(new Date).getTime();s+1e3*this.config.retryOffset<r&&setTimeout(()=>{this.toggle(!0)},1e3*this.config.delay)}toggle(t){const n=void 0===t?!this.isShown:!!t;n!==this.isShown&&(n?this.show():this.hide())}async show(){if(await this.pw.isSubscribed())return;this.isShown=!0,this.popup.classList.add("pw-show"),document.body.classList.add("pw-popup-opened");const t=new CustomEvent("showPopup",{bubbles:!1,cancelable:!1,detail:{popup:this.popup}});this.popup.dispatchEvent(t);if(Math.max(document.documentElement.clientWidth,window.innerWidth||0)<541)return;const{theme:n,viewport:p,position:e}=this.config;if("topbar"===n&&"top"===e){const t=document.querySelector(p)||document.createElement("div"),n=window.getComputedStyle(t).marginTop||"0";t.style.transition="margin-top .3s ease-out",t.style.marginTop=`${parseInt(n)+this.popup.getBoundingClientRect().height}px`}this.pw.dispatchEvent("subscribe-popup-show",{})}hide(){this.isShown=!1,this.popup.classList.remove("pw-show"),document.body.classList.remove("pw-popup-opened");const t=new CustomEvent("hidePopup",{bubbles:!1,cancelable:!1,detail:{popup:this.popup}});this.popup.dispatchEvent(t);const n=(new Date).getTime().toString();localStorage.setItem("LAST_OPEN_SUBSCRIPTION_POPUP",n);if(Math.max(document.documentElement.clientWidth,window.innerWidth||0)<541)return;const{theme:p,viewport:e,position:o}=this.config;if("topbar"===p&&"top"===o){const t=document.querySelector(e)||document.createElement("div"),n=window.getComputedStyle(t).marginTop||"0";t.style.marginTop=parseInt(n)-this.popup.getBoundingClientRect().height+"px"}this.pw.dispatchEvent("subscribe-popup-hide",{})}renderPopup(){this.popup=document.createElement("div"),this.popup.id="pwSubscribePopup";const{text:t,askLaterButtonText:n,confirmSubscriptionButtonText:p,iconUrl:e,iconAlt:o,position:i,overlay:s,theme:r}=this.config;this.popup.className=`pw-subscribe-popup pw-position-${i} pw-subscribe-popup-${r}`,this.popup.classList.toggle("pw-subscribe-popup__overlay",s),this.popup.classList.toggle("pw-mobile-view-margin",this.hasMobileViewMargin),this.popup.innerHTML=(({iconUrl:t,iconAlt:n,text:p,askLaterButtonText:e,confirmSubscriptionButtonText:o})=>`<div class="pw-subscription-popup-inner">\n <div class="pw-subscription-popup-content">\n ${t?`<div class="pw-subscription-popup-icon"><img src="${t}" alt="${n||"Subscribe"}"></div>`:""}\n <div class="pw-subscription-popup-text">\n ${p}\n </div>\n </div>\n <div class="pw-subscription-popup-controls">\n <button name="pwAskLater" class="pw-subscribe-popup-button">${e}</button>\n <button name="pwSubscribe" class="pw-subscribe-popup-button pw-subscribe-popup-button-active">${o}</button>\n </div>\n </div>`)({text:t,askLaterButtonText:n,confirmSubscriptionButtonText:p,iconUrl:e,iconAlt:o}),this.applyStyleVariables(),document.body.appendChild(this.popup),this.addListeners()}appendStyles(){const t=document.createElement("style");t.innerHTML=".pw-subscribe-popup {\n position: fixed;\n left: 50%;\n transform: translateX(-50%);\n justify-content: center;\n z-index: 1000000;\n display: flex;\n transition: all .4s ease-out;\n}\n\n.pw-subscribe-popup.pw-position-top {\n top: calc(-100% - 24px);\n}\n.pw-subscribe-popup.pw-position-top.pw-show {\n top: 0;\n}\n\n.pw-subscribe-popup.pw-position-bottom {\n bottom: calc(-100% - 24px);\n}\n.pw-subscribe-popup.pw-position-bottom.pw-show {\n bottom: 0;\n}\n\n.pw-subscribe-popup.pw-position-center {\n display: flex;\n\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n height: 100vh;\n justify-content: center;\n align-items: center;\n\n transform: none;\n}\n\n.pw-subscribe-popup__overlay {\n background: rgba(0,0,0,.4);\n z-index: 1000000;\n}\n\n.pw-subscribe-popup.pw-position-center:not(.pw-subscribe-popup__overlay) {\n pointer-events: none;\n}\n\n.pw-subscribe-popup.pw-position-center:not(.pw-show) {\n display: none;\n}\n\n\n.pw-subscribe-popup__overlay.pw-position-top {\n align-items: flex-start;\n}\n\n.pw-subscribe-popup__overlay.pw-position-bottom {\n align-items: flex-end;\n}\n\n.pw-subscribe-popup__overlay.pw-position-center {\n align-items: center;\n}\n\n.pw-subscription-popup-inner {\n max-width: 400px;\n font-size: var(--pw-popup-textSize, inherit);\n color: var(--pw-popup-textColor, #000);\n font-weight: var(--pw-popup-textWeight, normal);\n font-family: var(--pw-popup-fontFamily, inherit);\n border-style: solid;\n border-width: 1px;\n border-color: var(--pw-popup-borderColor, transparent);\n background: var(--pw-popup-bgColor, #fff);\n box-shadow: var(--pw-popup-boxShadow, 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23));\n pointer-events: auto;\n}\n\n.pw-subscription-popup-content {\n padding: 16px 16px 4px;\n display: flex;\n justify-content: stretch;\n}\n\n.pw-subscription-popup-icon {\n flex: 0 0 50px;\n margin-right: 12px;\n padding-top: 4px;\n}\n\n.pw-subscription-popup-icon img {\n max-width: 60px;\n max-height: 60px;\n}\n\n.pw-subscription-popup-text {\n flex: 1 1 300px;\n}\n\n.pw-subscription-popup-controls {\n display: flex;\n flex-wrap: nowrap;\n justify-content: center;\n padding: 8px 16px 16px;\n}\n\nbutton.pw-subscribe-popup-button {\n border: solid 1px var(--pw-popup-askLaterBtnBorderColor, transparent);\n border-radius: var(--pw-popup-askLaterBtnBorderRadius, 2px);\n display: inline-block;\n height: 36px;\n line-height: 36px;\n padding: 0 16px;\n text-transform: uppercase;\n font-weight: var(--pw-popup-askLaterBtnTextWeight, normal);\n vertical-align: middle;\n -webkit-tap-highlight-color: transparent;\n font-size: 14px;\n outline: 0;\n text-decoration: none;\n color: var(--pw-popup-askLaterBtnTextColor, #000);\n text-align: center;\n letter-spacing: .5px;\n cursor: pointer;\n background: var(--pw-popup-askLaterBtnBgColor, transparent);\n margin: 4px 8px;\n}\nbutton.pw-subscribe-popup-button:hover {\n background: rgba(0,0,0,.04);\n}\nbutton.pw-subscribe-popup-button:active {\n background: rgba(0,0,0,.12);\n}\n\nbutton.pw-subscribe-popup-button.pw-subscribe-popup-button-active {\n color: var(--pw-popup-subscribeBtnTextColor, #fff);\n background: var(--pw-popup-subscribeBtnBgColor, #4285f4);\n border-radius: var(--pw-popup-subscribeBtnBorderRadius, 2px);\n border: solid 1px var(--pw-popup-subscribeBtnBorderColor, transparent);\n box-shadow: 0 2px 2px 0 rgba(0,0,0,0.14),\n 0 3px 1px -2px rgba(0,0,0,0.12),\n 0 1px 5px 0 rgba(0,0,0,0.2);\n font-weight: var(--pw-popup-subscribeBtnTextWeight, normal);\n}\nbutton.pw-subscribe-popup-button.pw-subscribe-popup-button-active:hover {\n box-shadow: 0 3px 3px 0 rgba(0,0,0,0.14),\n 0 1px 7px 0 rgba(0,0,0,0.12),\n 0 3px 1px -1px rgba(0,0,0,0.2);\n}\nbutton.pw-subscribe-popup-button.pw-subscribe-popup-button-active:active {\n box-shadow: 0 2px 2px 0 rgba(0,0,0,0.14),\n 0 3px 1px -2px rgba(0,0,0,0.12),\n 0 1px 5px 0 rgba(0,0,0,0.2);\n}\n\n@media screen and (min-width: 541px) {\n\n .pw-subscribe-popup-topbar {\n width: 100%;\n }\n\n .pw-subscribe-popup-topbar .pw-subscription-popup-inner {\n max-width: 100%;\n width: 100%;\n display: flex;\n flex-direction: row;\n padding: 2px 40px;\n justify-content: center;\n align-items: center;\n flex-wrap: nowrap;\n }\n\n .pw-subscribe-popup-topbar .pw-subscription-popup-content {\n padding: 0;\n justify-content: flex-start;\n align-items: center;\n }\n\n .pw-subscribe-popup-topbar .pw-subscription-popup-icon img {\n max-width: 28px;\n max-height: 28px;\n }\n\n .pw-subscribe-popup-topbar button.pw-subscribe-popup-button {\n height: 32px;\n line-height: 32px;\n }\n\n .pw-subscribe-popup-topbar .pw-subscription-popup-controls {\n padding: 0 0 0 16px;\n align-items: center;\n }\n}\n@media screen and (max-width: 540px) {\n .pw-subscribe-popup,\n .pw-subscribe-popup.pw-position-top,\n .pw-subscribe-popup.pw-position-center,\n .pw-subscribe-popup.pw-position-bottom {\n top: auto;\n bottom: -110%;\n left: 0;\n right: 0;\n transform: none;\n display: flex;\n transition: bottom .4s ease-out;\n align-items: flex-end;\n }\n\n .pw-subscribe-popup.pw-mobile-view-margin {\n top: auto !important;\n transition: none;\n }\n\n .pw-subscribe-popup.pw-subscribe-popup__overlay {\n align-items: flex-end;\n }\n\n .pw-subscribe-popup.pw-show {\n bottom: var(--pw-popup-mobileViewMargin, 0);\n }\n\n .pw-subscribe-popup__overlay .pw-subscription-popup-inner {\n align-items: flex-end;\n justify-content: stretch;\n }\n\n .pw-subscription-popup-inner {\n max-width: 100%;\n width: 100%;\n }\n}\n".toString(),document.body.appendChild(t)}applyStyleVariables(){var t,n,p,o;t=this.popup,n="pw-popup",p=e,o=this.config,p.forEach(({name:p,type:e})=>{const i=r(e,o[p]);null!==i&&t.style.setProperty(function(t,n){return`--${t}-${n}`}(n,p),i)})}addListeners(){const t=this.popup.querySelector('button[name="pwAskLater"]')||document.createElement("button"),n=this.popup.querySelector('button[name="pwSubscribe"]')||document.createElement("button");t.addEventListener("click",this.onAskLaterClick),n.addEventListener("click",this.onSubscribeClick)}onAskLaterClick(){this.toggle(!1),this.pw.dispatchEvent("subscribe-popup-decline",{})}onSubscribeClick(){this.toggle(!1),this.pw.dispatchEvent("subscribe-popup-accept",{}),this.pw.subscribe()}}return n})());
|
|
2
2
|
//# sourceMappingURL=widget-subscribe-popup.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"widget-subscribe-popup.js","mappings":"CAAA,SAAAA,EAAAC,GACA,oBAAAC,SAAA,iBAAAC,OACAA,OAAAD,QAAAD,SACA,sBAAAG,QAAAA,OAAAC,IACAD,OAAA,GAAAH,OACA,CACA,IAAAK,EAAAL,IACA,QAAAM,KAAAD,GAAA,iBAAAJ,QAAAA,QAAAF,GAAAO,GAAAD,EAAAC,EACA,CACC,CATD,CASCC,KAAA,uBCRD,MAAAC,EAAA,CCAAA,EAAA,CAAAP,EAAAQ,KACA,QAAAC,KAAAD,EACAD,EAAAG,EAAAF,EAAAC,KAAAF,EAAAG,EAAAV,EAAAS,IACAE,OAAAC,eAAAZ,EAAAS,EAAA,CAAyCI,YAAA,EAAAC,IAAAN,EAAAC,MCJzCF,EAAA,CAAAQ,EAAAC,IAAAL,OAAAM,UAAAC,eAAAC,KAAAJ,EAAAC,GCCAT,EAAAP,IACAW,OAAAC,eAAAZ,EAAAoB,OAAAC,YAAA,CAAsDC,MAAA,WACtDX,OAAAC,eAAAZ,EAAA,cAAgDsB,OAAA,4DCDzC,MAAMC,EAAwC,CACnDC,QAAQ,EACRC,KAAM,oEACNC,mBAAoB,UACpBC,8BAA+B,YAC/BC,MAA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AIC,OAAO,WAAWxB,EAAMjE,UAAW,MAClD0F,EAAS1I,KAAKiI,kBAAkBhB,GAEtCqB,EAAeA,EAAaK,QAAQH,EAAUE,KAGzCJ,CACT,CAEA,YAAAP,GACE,MAAMa,EAAiB5I,KAAK2F,MAAMiB,cAAc,8BAC3Cd,SAASe,cAAc,UACtBgC,EAAkB7I,KAAK2F,MAAMiB,cAAc,+BAC5Cd,SAASe,cAAc,UAE5B+B,EAAeE,iBAAiB,QAAS9I,KAAK0D,iBAC9CmF,EAAgBC,iBAAiB,QAAS9I,KAAK4D,iBACjD,CAEA,eAAAF,GACE1D,KAAKsF,QAAO,GACZtF,KAAKoD,GAAGwB,cAAc,0BAA2B,GACnD,CAEA,gBAAAhB,GACE5D,KAAKsF,QAAO,GACZtF,KAAKoD,GAAGwB,cAAc,yBAA0B,IAChD5E,KAAKoD,GAAG2F,WACV","sources":["webpack://web-push-notifications/webpack/universalModuleDefinition","webpack://web-push-notifications/webpack/bootstrap","webpack://web-push-notifications/webpack/runtime/define property getters","webpack://web-push-notifications/webpack/runtime/hasOwnProperty shorthand","webpack://web-push-notifications/webpack/runtime/make namespace object","webpack://web-push-notifications/./src/widgets/SubscribePopup/constants.ts","webpack://web-push-notifications/./src/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\nconst __webpack_require__ = {};\n\n","// define getter/value functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop));","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { type ISubscribePopupConfig, type ISubscribePopupConfigStyles } from './types/subscribe-popup';\n\nexport const DEFAULT_CONFIG: ISubscribePopupConfig = {\n enable: true,\n text: 'Don’t miss out on our news and updates! Enable push notifications',\n askLaterButtonText: 'Not now',\n confirmSubscriptionButtonText: 'Subscribe',\n delay: 5,\n retryOffset: 60 * 60 * 24 * 7,\n overlay: false,\n position: 'top',\n mobileViewMargin: '0',\n\n bgColor: '#fff',\n borderColor: 'transparent',\n boxShadow: '0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23)',\n\n textColor: '#000',\n textSize: 'inherit',\n textWeight: 'normal',\n fontFamily: 'inherit',\n\n subscribeBtnBgColor: '#4285f4',\n subscribeBtnTextColor: '#fff',\n subscribeBtnTextWeight: 'normal',\n subscribeBtnBorderColor: 'transparent',\n subscribeBtnBorderRadius: '2px',\n\n askLaterBtnBgColor: 'transparent',\n askLaterBtnTextColor: '#000',\n askLaterBtnTextWeight: 'normal',\n askLaterBtnBorderColor: 'transparent',\n askLaterBtnBorderRadius: '2px',\n\n theme: 'material',\n viewport: 'html',\n};\n\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 // Nothing to ask for when push is unavailable; also narrows `driver`.\n const driver = this.pw.isPushAvailable() ? this.pw.driver : null;\n\n if (!driver) {\n return;\n }\n\n const { manualToggle } = this.config;\n const [isSubscribed, isManualUnsubscribed] = await Promise.all([\n this.pw.isSubscribed(),\n this.pw.data.getStatusManualUnsubscribed(),\n ]);\n if (isSubscribed || (!manualToggle && isManualUnsubscribed)) {\n return;\n }\n\n const permission = driver.getPermission();\n if (permission === PERMISSION_GRANTED || permission === PERMISSION_DENIED) {\n return;\n }\n\n this.renderPopup();\n this.appendStyles();\n\n this.pw.moduleRegistry.subscribePopup = this;\n this.pw.dispatchEvent('subscribe-popup-ready', {});\n\n if (manualToggle) {\n return;\n }\n\n const lastPopupOpen = localStorage.getItem('LAST_OPEN_SUBSCRIPTION_POPUP');\n const lastPopupOpenTime = lastPopupOpen ? parseInt(lastPopupOpen) : 0;\n const now = new Date().getTime();\n\n if (lastPopupOpenTime + (this.config.retryOffset * 1000) < now) {\n setTimeout(() => {\n this.toggle(true);\n }, this.config.delay * 1000);\n }\n }\n\n toggle(isShown?: boolean) {\n const isPopupShown = typeof isShown === 'undefined' ? !this.isShown : !!isShown;\n if (isPopupShown !== this.isShown) {\n if (isPopupShown) {\n this.show();\n } else {\n this.hide();\n }\n }\n }\n\n async show() {\n if (await this.pw.isSubscribed()) {\n return;\n }\n this.isShown = true;\n this.popup.classList.add('pw-show');\n document.body.classList.add('pw-popup-opened');\n\n const event = new CustomEvent('showPopup', {\n bubbles: false,\n cancelable: false,\n detail: {\n popup: this.popup,\n },\n });\n this.popup.dispatchEvent(event);\n\n const screenWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);\n if (screenWidth < 541) {\n // mobile screen doesn't support themes\n return;\n }\n const {\n theme,\n viewport,\n position,\n } = this.config;\n if (theme === 'topbar' && position === 'top') {\n const viewportElement: HTMLElement = document.querySelector(viewport) || document.createElement('div');\n const currentMarginTop = window.getComputedStyle(viewportElement).marginTop || '0';\n viewportElement.style.transition = 'margin-top .3s ease-out';\n viewportElement.style.marginTop = `${parseInt(currentMarginTop) + this.popup.getBoundingClientRect().height}px`;\n }\n\n this.pw.dispatchEvent('subscribe-popup-show', {});\n }\n\n hide() {\n this.isShown = false;\n this.popup.classList.remove('pw-show');\n document.body.classList.remove('pw-popup-opened');\n\n const event = new CustomEvent('hidePopup', {\n bubbles: false,\n cancelable: false,\n detail: {\n popup: this.popup,\n },\n });\n this.popup.dispatchEvent(event);\n\n const now = new Date().getTime().toString();\n\n localStorage.setItem('LAST_OPEN_SUBSCRIPTION_POPUP', now);\n\n const screenWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);\n if (screenWidth < 541) {\n // mobile screen doesn't support themes\n return;\n }\n const {\n theme,\n viewport,\n position,\n } = this.config;\n if (theme === 'topbar' && position === 'top') {\n const viewportElement: HTMLElement = document.querySelector(viewport) || document.createElement('div');\n const currentMarginTop = window.getComputedStyle(viewportElement).marginTop || '0';\n viewportElement.style.marginTop = `${parseInt(currentMarginTop) - this.popup.getBoundingClientRect().height}px`;\n }\n\n this.pw.dispatchEvent('subscribe-popup-hide', {});\n }\n\n renderPopup() {\n this.popup = document.createElement('div');\n this.popup.id = 'pwSubscribePopup';\n const {\n text,\n askLaterButtonText,\n confirmSubscriptionButtonText,\n iconUrl,\n iconAlt,\n position,\n overlay,\n theme,\n } = this.config;\n this.popup.className = `pw-subscribe-popup pw-position-${position} pw-subscribe-popup-${theme}`;\n this.popup.classList.toggle('pw-subscribe-popup__overlay', overlay);\n this.popup.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","driver","isPushAvailable","manualToggle","isSubscribed","isManualUnsubscribed","Promise","all","data","getStatusManualUnsubscribed","permission","getPermission","renderPopup","appendStyles","moduleRegistry","dispatchEvent","lastPopupOpen","localStorage","getItem","lastPopupOpenTime","parseInt","now","Date","getTime","setTimeout","toggle","isShown","isPopupShown","show","hide","popup","classList","add","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,SAAAA,EAAAC,GACA,oBAAAC,SAAA,iBAAAC,OACAA,OAAAD,QAAAD,SACA,sBAAAG,QAAA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2G,MAAMgB,cAAc,+BAC5C9D,SAASC,cAAc,UAE5BwF,EAAeE,iBAAiB,QAASxJ,KAAK0E,iBAC9C6E,EAAgBC,iBAAiB,QAASxJ,KAAK4E,iBACjD,CAEA,eAAAF,GACE1E,KAAKsG,QAAO,GACZtG,KAAKoE,GAAGwB,cAAc,0BAA2B,GACnD,CAEA,gBAAAhB,GACE5E,KAAKsG,QAAO,GACZtG,KAAKoE,GAAGwB,cAAc,yBAA0B,IAChD5F,KAAKoE,GAAGqF,WACV","sources":["webpack://web-push-notifications/webpack/universalModuleDefinition","webpack://web-push-notifications/webpack/bootstrap","webpack://web-push-notifications/webpack/runtime/define property getters","webpack://web-push-notifications/webpack/runtime/hasOwnProperty shorthand","webpack://web-push-notifications/webpack/runtime/make namespace object","webpack://web-push-notifications/./src/widgets/SubscribePopup/constants.ts","webpack://web-push-notifications/./src/helpers/cssColor.ts","webpack://web-push-notifications/./src/helpers/cssVariables.ts","webpack://web-push-notifications/./src/widgets/SubscribePopup/SubscribePopup.ts","webpack://web-push-notifications/./src/widgets/SubscribePopup/popupTemplates.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse {\n\t\tvar a = factory();\n\t\tfor(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];\n\t}\n})(this, () => {\nreturn ","// The require scope\nconst __webpack_require__ = {};\n\n","// define getter/value functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop));","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { type ISubscribePopupConfig, type ISubscribePopupConfigStyles } from './types/subscribe-popup';\n\nexport const DEFAULT_CONFIG: ISubscribePopupConfig = {\n enable: true,\n text: 'Don’t miss out on our news and updates! Enable push notifications',\n askLaterButtonText: 'Not now',\n confirmSubscriptionButtonText: 'Subscribe',\n delay: 5,\n retryOffset: 60 * 60 * 24 * 7,\n overlay: false,\n position: 'top',\n mobileViewMargin: '0',\n\n bgColor: '#fff',\n borderColor: 'transparent',\n boxShadow: '0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23)',\n\n textColor: '#000',\n textSize: 'inherit',\n textWeight: 'normal',\n fontFamily: 'inherit',\n\n subscribeBtnBgColor: '#4285f4',\n subscribeBtnTextColor: '#fff',\n subscribeBtnTextWeight: 'normal',\n subscribeBtnBorderColor: 'transparent',\n subscribeBtnBorderRadius: '2px',\n\n askLaterBtnBgColor: 'transparent',\n askLaterBtnTextColor: '#000',\n askLaterBtnTextWeight: 'normal',\n askLaterBtnBorderColor: 'transparent',\n askLaterBtnBorderRadius: '2px',\n\n theme: 'material',\n viewport: 'html',\n};\n\n// Permissions\nexport const PERMISSION_DENIED = 'denied';\nexport const PERMISSION_GRANTED = 'granted';\n\nexport const STYLE_PREFIX = 'pw-popup';\n\nexport const CONFIG_STYLES: Array<ISubscribePopupConfigStyles> = [\n { name: 'mobileViewMargin', type: 'string' },\n { name: 'bgColor', type: 'color' },\n { name: 'borderColor', type: 'color' },\n { name: 'boxShadow', type: 'string' },\n { name: 'textColor', type: 'color' },\n { name: 'textSize', type: 'string' },\n { name: 'textWeight', type: 'string' },\n { name: 'fontFamily', type: 'string' },\n { name: 'subscribeBtnBgColor', type: 'color' },\n { name: 'subscribeBtnTextColor', type: 'color' },\n { name: 'subscribeBtnTextWeight', type: 'string' },\n { name: 'subscribeBtnBorderColor', type: 'color' },\n { name: 'subscribeBtnBorderRadius', type: 'string' },\n { name: 'askLaterBtnBgColor', type: 'color' },\n { name: 'askLaterBtnTextColor', type: 'color' },\n { name: 'askLaterBtnTextWeight', type: 'string' },\n { name: 'askLaterBtnBorderColor', type: 'color' },\n { name: 'askLaterBtnBorderRadius', type: 'string' },\n];\n","/** Drawn when the configured colour is one the browser would refuse. */\nexport const FALLBACK_COLOR = '#333';\n\n// A colour value never needs these, and they are exactly what would end the\n// declaration or the rule it is interpolated into.\nconst RULE_BREAKERS = /[;{}]/;\n\n// One element, reused: the widgets validate every colour of their config on\n// each render.\nlet probe: HTMLElement | null = null;\n\n/** Keeps a colour the browser accepts, and replaces anything else with {@link FALLBACK_COLOR}. */\nexport function getValidColor(color: string): string {\n if (RULE_BREAKERS.test(color)) {\n return FALLBACK_COLOR;\n }\n\n if (!probe) {\n probe = document.createElement('div');\n }\n\n probe.style.color = '';\n probe.style.color = color;\n\n return probe.style.color ? color : FALLBACK_COLOR;\n}\n","import { getValidColor } from './cssColor';\n\nexport type TStyleVariableType = 'number' | 'color' | 'string' | 'size';\n\nexport interface IStyleVariable<TName extends string = string> {\n name: TName;\n type: TStyleVariableType;\n}\n\nexport function getCssVariableName(prefix: string, name: string): string {\n return `--${prefix}-${name}`;\n}\n\n// `null` means \"leave it unset\": a custom property holding garbage makes every\n// rule that reads it invalid, while an absent one falls back to the stylesheet.\nexport function formatStyleVariable(type: TStyleVariableType, value: string | number | undefined): string | null {\n switch (type) {\n case 'size': {\n const size = Number(value ?? 0);\n return Number.isFinite(size) ? `${size}px` : null;\n }\n case 'number': {\n const parsed = parseFloat(String(value));\n return Number.isFinite(parsed) ? String(parsed) : null;\n }\n case 'color': {\n const color = String(value);\n return getValidColor(color) === color ? color : null;\n }\n default: {\n const text = String(value).trim();\n return text || null;\n }\n }\n}\n\nexport function applyStyleVariables<TName extends string>(\n element: HTMLElement,\n prefix: string,\n variables: Array<IStyleVariable<TName>>,\n values: Record<TName, string | number>,\n): void {\n variables.forEach(({ name, type }) => {\n const formatted = formatStyleVariable(type, values[name]);\n\n if (formatted !== null) {\n element.style.setProperty(getCssVariableName(prefix, name), formatted);\n }\n });\n}\n","import {\n DEFAULT_CONFIG,\n CONFIG_STYLES,\n STYLE_PREFIX,\n\n PERMISSION_DENIED,\n PERMISSION_GRANTED,\n} from './constants';\nimport { innerTemplate } from './popupTemplates';\nimport popupCss from './styles/popup.css';\nimport { type ISubscribePopupConfig } from './types/subscribe-popup';\nimport { type Pushwoosh } from '../../core/Pushwoosh';\nimport { applyStyleVariables } from '../../helpers/cssVariables';\n\nexport class PWSubscribePopupWidget {\n pw: Pushwoosh;\n config: ISubscribePopupConfig;\n popup: HTMLElement;\n isShown: boolean;\n private hasMobileViewMargin: boolean;\n\n constructor(pw: Pushwoosh) {\n this.pw = pw;\n\n const { mobileViewMargin = '' } = pw.initParams.subscribePopup || ({} as ISubscribePopupConfig);\n\n this.config = {\n ...DEFAULT_CONFIG,\n ...pw.initParams.subscribePopup,\n };\n\n this.hasMobileViewMargin = Boolean(mobileViewMargin);\n\n this.onAskLaterClick = this.onAskLaterClick.bind(this);\n this.onSubscribeClick = this.onSubscribeClick.bind(this);\n }\n\n async run() {\n // Nothing to ask for when push is unavailable; also narrows `driver`.\n const driver = this.pw.isPushAvailable() ? this.pw.driver : null;\n\n if (!driver) {\n return;\n }\n\n const { manualToggle } = this.config;\n const [isSubscribed, isManualUnsubscribed] = await Promise.all([\n this.pw.isSubscribed(),\n this.pw.data.getStatusManualUnsubscribed(),\n ]);\n if (isSubscribed || (!manualToggle && isManualUnsubscribed)) {\n return;\n }\n\n const permission = driver.getPermission();\n if (permission === PERMISSION_GRANTED || permission === PERMISSION_DENIED) {\n return;\n }\n\n this.renderPopup();\n this.appendStyles();\n\n this.pw.moduleRegistry.subscribePopup = this;\n this.pw.dispatchEvent('subscribe-popup-ready', {});\n\n if (manualToggle) {\n return;\n }\n\n const lastPopupOpen = localStorage.getItem('LAST_OPEN_SUBSCRIPTION_POPUP');\n const lastPopupOpenTime = lastPopupOpen ? parseInt(lastPopupOpen) : 0;\n const now = new Date().getTime();\n\n if (lastPopupOpenTime + (this.config.retryOffset * 1000) < now) {\n setTimeout(() => {\n this.toggle(true);\n }, this.config.delay * 1000);\n }\n }\n\n toggle(isShown?: boolean) {\n const isPopupShown = typeof isShown === 'undefined' ? !this.isShown : !!isShown;\n if (isPopupShown !== this.isShown) {\n if (isPopupShown) {\n this.show();\n } else {\n this.hide();\n }\n }\n }\n\n async show() {\n if (await this.pw.isSubscribed()) {\n return;\n }\n this.isShown = true;\n this.popup.classList.add('pw-show');\n document.body.classList.add('pw-popup-opened');\n\n const event = new CustomEvent('showPopup', {\n bubbles: false,\n cancelable: false,\n detail: {\n popup: this.popup,\n },\n });\n this.popup.dispatchEvent(event);\n\n const screenWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);\n if (screenWidth < 541) {\n // mobile screen doesn't support themes\n return;\n }\n const {\n theme,\n viewport,\n position,\n } = this.config;\n if (theme === 'topbar' && position === 'top') {\n const viewportElement: HTMLElement = document.querySelector(viewport) || document.createElement('div');\n const currentMarginTop = window.getComputedStyle(viewportElement).marginTop || '0';\n viewportElement.style.transition = 'margin-top .3s ease-out';\n viewportElement.style.marginTop = `${parseInt(currentMarginTop) + this.popup.getBoundingClientRect().height}px`;\n }\n\n this.pw.dispatchEvent('subscribe-popup-show', {});\n }\n\n hide() {\n this.isShown = false;\n this.popup.classList.remove('pw-show');\n document.body.classList.remove('pw-popup-opened');\n\n const event = new CustomEvent('hidePopup', {\n bubbles: false,\n cancelable: false,\n detail: {\n popup: this.popup,\n },\n });\n this.popup.dispatchEvent(event);\n\n const now = new Date().getTime().toString();\n\n localStorage.setItem('LAST_OPEN_SUBSCRIPTION_POPUP', now);\n\n const screenWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);\n if (screenWidth < 541) {\n // mobile screen doesn't support themes\n return;\n }\n const {\n theme,\n viewport,\n position,\n } = this.config;\n if (theme === 'topbar' && position === 'top') {\n const viewportElement: HTMLElement = document.querySelector(viewport) || document.createElement('div');\n const currentMarginTop = window.getComputedStyle(viewportElement).marginTop || '0';\n viewportElement.style.marginTop = `${parseInt(currentMarginTop) - this.popup.getBoundingClientRect().height}px`;\n }\n\n this.pw.dispatchEvent('subscribe-popup-hide', {});\n }\n\n renderPopup() {\n this.popup = document.createElement('div');\n this.popup.id = 'pwSubscribePopup';\n const {\n text,\n askLaterButtonText,\n confirmSubscriptionButtonText,\n iconUrl,\n iconAlt,\n position,\n overlay,\n theme,\n } = this.config;\n this.popup.className = `pw-subscribe-popup pw-position-${position} pw-subscribe-popup-${theme}`;\n this.popup.classList.toggle('pw-subscribe-popup__overlay', overlay);\n this.popup.classList.toggle('pw-mobile-view-margin', this.hasMobileViewMargin);\n this.popup.innerHTML = innerTemplate({\n text,\n askLaterButtonText,\n confirmSubscriptionButtonText,\n iconUrl,\n iconAlt,\n });\n this.applyStyleVariables();\n document.body.appendChild(this.popup);\n this.addListeners();\n }\n\n appendStyles() {\n const style = document.createElement('style');\n style.innerHTML = popupCss.toString();\n document.body.appendChild(style);\n }\n\n applyStyleVariables() {\n applyStyleVariables(this.popup, STYLE_PREFIX, CONFIG_STYLES, this.config);\n }\n\n addListeners() {\n const askLaterButton = this.popup.querySelector('button[name=\"pwAskLater\"]')\n || document.createElement('button');\n const subscribeButton = this.popup.querySelector('button[name=\"pwSubscribe\"]')\n || document.createElement('button');\n\n askLaterButton.addEventListener('click', this.onAskLaterClick);\n subscribeButton.addEventListener('click', this.onSubscribeClick);\n }\n\n onAskLaterClick() {\n this.toggle(false);\n this.pw.dispatchEvent('subscribe-popup-decline', {});\n }\n\n onSubscribeClick() {\n this.toggle(false);\n this.pw.dispatchEvent('subscribe-popup-accept', {});\n this.pw.subscribe();\n }\n}\n","interface IInnerTemplate {\n iconUrl?: string;\n iconAlt?: string;\n text: string;\n askLaterButtonText: string;\n confirmSubscriptionButtonText: string;\n}\n\nexport const innerTemplate = ({ iconUrl, iconAlt, text, askLaterButtonText, confirmSubscriptionButtonText }: IInnerTemplate): string => {\n return `<div class=\"pw-subscription-popup-inner\">\n <div class=\"pw-subscription-popup-content\">\n ${iconUrl\n ? `<div class=\"pw-subscription-popup-icon\"><img src=\"${iconUrl}\" alt=\"${iconAlt || 'Subscribe'}\"></div>`\n : ''}\n <div class=\"pw-subscription-popup-text\">\n ${text}\n </div>\n </div>\n <div class=\"pw-subscription-popup-controls\">\n <button name=\"pwAskLater\" class=\"pw-subscribe-popup-button\">${askLaterButtonText}</button>\n <button name=\"pwSubscribe\" class=\"pw-subscribe-popup-button pw-subscribe-popup-button-active\">${confirmSubscriptionButtonText}</button>\n </div>\n </div>`;\n};\n"],"names":["root","factory","exports","module","define","amd","a","i","this","__webpack_require__","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","DEFAULT_CONFIG","enable","text","askLaterButtonText","confirmSubscriptionButtonText","delay","retryOffset","overlay","position","mobileViewMargin","bgColor","borderColor","boxShadow","textColor","textSize","textWeight","fontFamily","subscribeBtnBgColor","subscribeBtnTextColor","subscribeBtnTextWeight","subscribeBtnBorderColor","subscribeBtnBorderRadius","askLaterBtnBgColor","askLaterBtnTextColor","askLaterBtnTextWeight","askLaterBtnBorderColor","askLaterBtnBorderRadius","theme","viewport","CONFIG_STYLES","name","type","FALLBACK_COLOR","RULE_BREAKERS","probe","formatStyleVariable","size","Number","isFinite","parsed","parseFloat","String","color","test","document","createElement","style","getValidColor","trim","PWSubscribePopupWidget","constructor","pw","initParams","subscribePopup","config","hasMobileViewMargin","Boolean","onAskLaterClick","bind","onSubscribeClick","run","driver","isPushAvailable","manualToggle","isSubscribed","isManualUnsubscribed","Promise","all","data","getStatusManualUnsubscribed","permission","getPermission","renderPopup","appendStyles","moduleRegistry","dispatchEvent","lastPopupOpen","localStorage","getItem","lastPopupOpenTime","parseInt","now","Date","getTime","setTimeout","toggle","isShown","isPopupShown","show","hide","popup","classList","add","body","event","CustomEvent","bubbles","cancelable","detail","Math","max","documentElement","clientWidth","window","innerWidth","viewportElement","querySelector","currentMarginTop","getComputedStyle","marginTop","transition","getBoundingClientRect","height","remove","toString","setItem","id","iconUrl","iconAlt","className","innerHTML","innerTemplate","applyStyleVariables","appendChild","addListeners","element","prefix","variables","values","forEach","formatted","setProperty","getCssVariableName","askLaterButton","subscribeButton","addEventListener","subscribe"],"sourceRoot":""}
|
|
@@ -26,8 +26,7 @@ export declare class PWInboxWidget {
|
|
|
26
26
|
private initTrigger;
|
|
27
27
|
private renderWidget;
|
|
28
28
|
private getStyle;
|
|
29
|
-
private
|
|
30
|
-
private getStyleFormatter;
|
|
29
|
+
private applyStyleVariables;
|
|
31
30
|
private renderWidgetInner;
|
|
32
31
|
private renderMessages;
|
|
33
32
|
private updateCounter;
|
|
@@ -4,6 +4,7 @@ export declare const SYNC_INTERVAL: number;
|
|
|
4
4
|
export declare const MILLISECONDS_IN_DAY: number;
|
|
5
5
|
export declare const MILLISECONDS_IN_HOUR: number;
|
|
6
6
|
export declare const MONTHS: string[];
|
|
7
|
+
export declare const STYLE_PREFIX = "pw-inbox";
|
|
7
8
|
export declare const CONFIG_STYLES: Array<IConfigStyles>;
|
|
9
|
+
export declare const TRIGGER_CONFIG_STYLES: Array<IConfigStyles>;
|
|
8
10
|
export declare const DEFAULT_CONFIG: IInboxWidgetConfig;
|
|
9
|
-
export declare const COLOR_TEST_REGEXP: RegExp;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export declare function isElementFixed(element: HTMLElement): boolean;
|
|
2
2
|
export declare function getMessageTime(date: string): string;
|
|
3
|
-
export declare function getValidColor(color: string): string;
|
|
4
3
|
export declare function compareBySendDate(dateOne: string, dateTwo: string): number;
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
+
import { type IStyleVariable } from '../../helpers/cssVariables';
|
|
1
2
|
export interface TMessagesElementsType {
|
|
2
3
|
[code: string]: HTMLElement;
|
|
3
4
|
}
|
|
4
|
-
export
|
|
5
|
-
name: TStylesNames;
|
|
6
|
-
type: TStylesTypes;
|
|
7
|
-
}
|
|
5
|
+
export type IConfigStyles = IStyleVariable<TStylesNames>;
|
|
8
6
|
export type TStylesNames = 'bgColor' | 'textColor' | 'fontFamily' | 'borderRadius' | 'borderColor' | 'badgeBgColor' | 'badgeTextColor' | 'widgetWidth' | 'zIndex' | 'messageTitleColor' | 'timeTextColor' | 'emptyInboxTitleColor' | 'emptyInboxTextColor' | 'arrowBorderColor' | 'unreadDotColor' | 'avatarBgColor' | 'avatarTextColor' | 'avatarSize' | 'mediaRadius' | 'slideCaptionColor' | 'slideScrimColor' | 'pagerDotActiveColor' | 'pagerDotColor';
|
|
9
|
-
export type TStylesTypes = 'number' | 'color' | 'string' | 'size';
|
|
10
7
|
export type TWidgetPosition = 'left' | 'right' | 'top' | 'bottom';
|
|
11
8
|
export interface IInboxWidgetConfig {
|
|
12
9
|
enable: boolean;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type ISubscribePopupConfig } from './types/subscribe-popup';
|
|
2
2
|
import { type Pushwoosh } from '../../core/Pushwoosh';
|
|
3
3
|
export declare class PWSubscribePopupWidget {
|
|
4
4
|
pw: Pushwoosh;
|
|
5
|
-
config:
|
|
5
|
+
config: ISubscribePopupConfig;
|
|
6
6
|
popup: HTMLElement;
|
|
7
7
|
isShown: boolean;
|
|
8
|
+
private hasMobileViewMargin;
|
|
8
9
|
constructor(pw: Pushwoosh);
|
|
9
10
|
run(): Promise<void>;
|
|
10
11
|
toggle(isShown?: boolean): void;
|
|
@@ -12,8 +13,7 @@ export declare class PWSubscribePopupWidget {
|
|
|
12
13
|
hide(): void;
|
|
13
14
|
renderPopup(): void;
|
|
14
15
|
appendStyles(): void;
|
|
15
|
-
|
|
16
|
-
configureStyle(styles: string): string;
|
|
16
|
+
applyStyleVariables(): void;
|
|
17
17
|
addListeners(): void;
|
|
18
18
|
onAskLaterClick(): void;
|
|
19
19
|
onSubscribeClick(): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ISubscribePopupConfig, type ISubscribePopupConfigStyles } from './types/subscribe-popup';
|
|
2
2
|
export declare const DEFAULT_CONFIG: ISubscribePopupConfig;
|
|
3
|
-
export declare const COLOR_TEST_REGEXP: RegExp;
|
|
4
3
|
export declare const PERMISSION_DENIED = "denied";
|
|
5
4
|
export declare const PERMISSION_GRANTED = "granted";
|
|
5
|
+
export declare const STYLE_PREFIX = "pw-popup";
|
|
6
6
|
export declare const CONFIG_STYLES: Array<ISubscribePopupConfigStyles>;
|