web-push-notifications 3.110.0 → 3.115.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/CHANGELOG.md +65 -0
  2. package/core/Pushwoosh.d.ts +3 -0
  3. package/core/Pushwoosh.types.d.ts +1 -0
  4. package/core/elementPickerRequest.d.ts +8 -0
  5. package/models/NotificationPayload.types.d.ts +1 -0
  6. package/models/__tests__/NotificationPayload.buttons.test.d.ts +1 -0
  7. package/modules/Api/Api.d.ts +1 -1
  8. package/modules/ApiClient/ApiClient.types.d.ts +2 -0
  9. package/npm.js +1 -1
  10. package/npm.js.map +1 -1
  11. package/package.json +1 -1
  12. package/service-worker.js +1 -1
  13. package/service-worker.js.map +1 -1
  14. package/widget-inbox.js +1 -1
  15. package/widget-inbox.js.map +1 -1
  16. package/widget-recommendations.js +1 -1
  17. package/widget-recommendations.js.map +1 -1
  18. package/widget-subscribe-popup.js +1 -1
  19. package/widget-subscribe-popup.js.map +1 -1
  20. package/widget-subscription-button.js +1 -1
  21. package/widget-subscription-button.js.map +1 -1
  22. package/widget-subscription-prompt.js +1 -1
  23. package/widget-subscription-prompt.js.map +1 -1
  24. package/widget-subscription.js +1 -1
  25. package/widget-subscription.js.map +1 -1
  26. package/widget-web-popups.js +1 -1
  27. package/widget-web-popups.js.map +1 -1
  28. package/widgets/ElementPicker/ElementPicker.d.ts +48 -0
  29. package/widgets/ElementPicker/__tests__/elementPicker.test.d.ts +1 -0
  30. package/widgets/ElementPicker/__tests__/selector.test.d.ts +1 -0
  31. package/widgets/ElementPicker/selector.d.ts +16 -0
  32. package/widgets/WebPopups/WebPopupsWidget.d.ts +10 -2
  33. package/widgets/WebPopups/__tests__/clickTrigger.test.d.ts +1 -0
  34. package/widgets/WebPopups/__tests__/exitIntentTrigger.test.d.ts +1 -0
  35. package/widgets/WebPopups/clickTrigger.d.ts +5 -0
  36. package/widgets/WebPopups/exitIntent.d.ts +6 -0
  37.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C","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/core/constants.ts","webpack://web-push-notifications/./src/widgets/SubscriptionButton/constants.ts","webpack://web-push-notifications/./src/widgets/SubscriptionButton/positioning.ts","webpack://web-push-notifications/./src/widgets/SubscriptionButton/index.ts","webpack://web-push-notifications/./src/widgets/SubscriptionButton/bell.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};","export const DEFAULT_SERVICE_WORKER_URL = '/pushwoosh-service-worker.js';\nexport const DEFAULT_API_URL = 'https://api.pushwoosh.com/json/1.3/';\n\nexport const PERIOD_SEND_APP_OPEN = 3600000;\nexport const PERIOD_GOAL_EVENT = 86400000;\n\nexport const DEFAULT_NOTIFICATION_TITLE = 'Pushwoosh notification';\nexport const DEFAULT_NOTIFICATION_IMAGE = 'https://cp.pushwoosh.com/img/logo-medium.png';\n\n// Keys\nexport const KEY_SHOW_SUBSCRIBE_WIDGET = 'WIDGET_SHOWED';\nexport const KEY_CLICK_SUBSCRIBE_WIDGET = 'WIDGET_CLICKED';\n\n// Local storage keys\nexport const KEY_DEVICE_REGISTRATION_STATUS: string = 'deviceRegistrationStatus';\nexport const KEY_REPORTED_PUSH_PERMISSION_STATUS: string = 'reportedPushPermissionStatus';\nexport const KEY_SAFARI_PREVIOUS_PERMISSION = 'safariPreviousPermission';\nexport const MANUAL_SET_LOGGER_LEVEL = 'PW_SET_LOGGER_LEVEL';\n\n// Device registration status\nexport const DEVICE_REGISTRATION_STATUS_REGISTERED: string = 'registered';\nexport const DEVICE_REGISTRATION_STATUS_UNREGISTERED: string = 'unregistered';\n\n// Permissions\nexport const PERMISSION_DENIED = 'denied';\nexport const PERMISSION_GRANTED = 'granted';\nexport const PERMISSION_PROMPT = 'default';\n\n// Events\nexport const LEGACY_EVENT_ON_LOAD = 'onLoad';\nexport const LEGACY_EVENT_ON_READY = 'onReady';\nexport const LEGACY_EVENT_ON_SUBSCRIBE = 'onSubscribe';\nexport const LEGACY_EVENT_ON_UNSUBSCRIBE = 'onUnsubscribe';\nexport const LEGACY_EVENT_ON_REGISTER = 'onRegister';\nexport const LEGACY_EVENT_ON_PERMISSION_PROMPT = 'onPermissionPrompt';\nexport const LEGACY_EVENT_ON_PERMISSION_DENIED = 'onPermissionDenied';\nexport const LEGACY_EVENT_ON_PERMISSION_GRANTED = 'onPermissionGranted';\nexport const LEGACY_EVENT_ON_SW_INIT_ERROR = 'onSWInitError';\nexport const LEGACY_EVENT_ON_PUSH_DELIVERY = 'onPushDelivery';\nexport const LEGACY_EVENT_ON_NOTIFICATION_CLICK = 'onNotificationClick';\nexport const LEGACY_EVENT_ON_NOTIFICATION_CLOSE = 'onNotificationClose';\nexport const LEGACY_EVENT_ON_CHANGE_COMMUNICATION_ENABLED = 'onChangeCommunicationEnabled';\nexport const LEGACY_EVENT_ON_PUT_NEW_MESSAGE_TO_INBOX_STORE = 'onPutNewMessageToInboxStore';\nexport const LEGACY_EVENT_ON_UPDATE_INBOX_MESSAGES = 'onUpdateInboxMessages';\nexport const LEGACY_EVENT_ON_SHOW_NOTIFICATION_PERMISSION_DIALOG = 'onShowNotificationPermissionDialog';\nexport const LEGACY_EVENT_ON_HIDE_NOTIFICATION_PERMISSION_DIALOG = 'onHideNotificationPermissionDialog';\n\nexport const LEGACY_EVENT_ON_SHOW_SUBSCRIPTION_WIDGET = 'onShowSubscriptionWidget';\nexport const LEGACY_EVENT_ON_HIDE_SUBSCRIPTION_WIDGET = 'onHideSubscriptionWidget';\n\n// Post Events\nexport const EVENT_SHOW_SUBSCRIBE_BUTTON = 'showSubscribeButton';\nexport const EVENT_CLICK_SUBSCRIBE_BUTTON = 'clickSubscribeButton';\nexport const EVENT_GDPR_CONSENT = 'GDPRConsent';\nexport const EVENT_GDPR_DELETE = 'GDPRDelete';\nexport const EVENT_PW_SITE_OPENED = 'PW_SiteOpened'; // for default events\n\n// Storage that keeps no hwid (in-app webview, private window, insecure context)\n// leaves the device unidentifiable, and the backend rejects such requests.\nexport const HWID_UNAVAILABLE_MESSAGE = 'Pushwoosh: the SDK storage does not keep the hwid in this browser '\n + '(in-app webview, private window or insecure context), so this device cannot be identified. '\n + 'Requests that need an hwid are not sent.';\n\nexport const IDENTITY_UNAVAILABLE_MESSAGE = 'Pushwoosh: neither a userId nor an hwid is available, '\n + 'so there is nothing to register the email, SMS or WhatsApp channel to. '\n + 'Pass a userId in the init params.';\n\n// A rejected application code is a configuration error, not a failure: no\n// request of the SDK can succeed after it, so init stops instead of retrying.\nexport const API_STATUS_CODE_INVALID_APPLICATION = 210;\nexport const FATAL_API_STATUS_CODES: number[] = [API_STATUS_CODE_INVALID_APPLICATION];\n\n// How long an inbox tap waits for a widget bundle before falling back to the message link.\nexport const WIDGET_LOAD_TIMEOUT_MS = 10000;\n\n// A browser subscription can hang; the permission-change report stops waiting for it after this.\nexport const SUBSCRIPTION_WAIT_TIMEOUT_MS: number = 10000;\n","// Bell\nimport { type TBellConfig } from './subscribe_widget.types';\n\nexport const BELL_POSITION_BOTTOM_RIGHT = 'bottomRight';\nexport const BELL_POSITION_BOTTOM_LEFT = 'bottomLeft';\nexport const BELL_POSITION_TOP_RIGHT = 'topRight';\nexport const BELL_POSITION_TOP_LEFT = 'topLeft';\n\n// Common\nexport const WIDGET_CONTAINER_ID = 'pushwooshBellWidget';\n\nexport const SUBSCRIBE_WIDGET_DEFAULT_CONFIG: TBellConfig = {\n position: BELL_POSITION_BOTTOM_LEFT,\n bgColor: '#12AE7E',\n bellColor: 'white',\n bellStrokeColor: '#08754f',\n bellButtonBorder: '1px solid #379676',\n shadow: '0px 0px 6px rgba(0, 0, 0, 0.75)',\n size: '48px',\n indent: '20px',\n zIndex: '999999',\n tooltipText: {\n successSubscribe: 'You are successfully subscribed!',\n needSubscribe: 'Get notifications about important news!',\n blockSubscribe: 'Click to see how to get notifications',\n alreadySubscribed: 'You are already subscribed',\n },\n};\n","import {\n BELL_POSITION_TOP_RIGHT,\n BELL_POSITION_TOP_LEFT,\n BELL_POSITION_BOTTOM_LEFT,\n BELL_POSITION_BOTTOM_RIGHT,\n} from './constants';\nimport { type TBellPosition, type TPositionStyles } from './subscribe_widget.types';\n\nexport default class Positioning {\n public static getBellPosition(position: TBellPosition, indent: string): TPositionStyles {\n let positionStyles: TPositionStyles;\n\n switch (position) {\n case BELL_POSITION_BOTTOM_RIGHT:\n positionStyles = {\n top: 'auto',\n left: 'auto',\n bottom: indent,\n right: indent,\n };\n break;\n case BELL_POSITION_BOTTOM_LEFT:\n positionStyles = {\n top: 'auto',\n left: indent,\n bottom: indent,\n right: 'auto',\n };\n break;\n case BELL_POSITION_TOP_LEFT:\n positionStyles = {\n top: indent,\n left: indent,\n bottom: 'auto',\n right: 'auto',\n };\n break;\n case BELL_POSITION_TOP_RIGHT:\n positionStyles = {\n top: indent,\n left: 'auto',\n bottom: 'auto',\n right: indent,\n };\n break;\n default:\n positionStyles = {\n top: 'auto',\n left: 'auto',\n bottom: indent,\n right: indent,\n };\n }\n\n return positionStyles;\n }\n\n public static getTooltipPosition(bellPosition: TBellPosition, bellSize: string): [{ left: string } | { right: string }, string] {\n let positionStyles;\n let tooltipModification;\n const increaseIndent = (parseInt(bellSize) + 12) + 'px';\n\n switch (bellPosition) {\n case BELL_POSITION_BOTTOM_RIGHT:\n positionStyles = { right: increaseIndent };\n tooltipModification = 'right';\n break;\n case BELL_POSITION_BOTTOM_LEFT:\n positionStyles = { left: increaseIndent };\n tooltipModification = 'left';\n break;\n case BELL_POSITION_TOP_LEFT:\n positionStyles = { left: increaseIndent };\n tooltipModification = 'left';\n break;\n case BELL_POSITION_TOP_RIGHT:\n positionStyles = { right: increaseIndent };\n tooltipModification = 'right';\n break;\n default:\n positionStyles = { right: increaseIndent };\n tooltipModification = 'right';\n }\n\n return [positionStyles, tooltipModification];\n }\n\n public static getPopoverPosition(bellPosition: TBellPosition, bellSize: string): [TPositionStyles, string] {\n let positionStyles;\n let popoverModification;\n const increaseIndent = (parseInt(bellSize) + 15) + 'px';\n\n switch (bellPosition) {\n case BELL_POSITION_BOTTOM_RIGHT:\n positionStyles = {\n bottom: increaseIndent,\n right: '0',\n left: 'auto',\n top: 'auto',\n };\n popoverModification = 'bottom';\n break;\n case BELL_POSITION_BOTTOM_LEFT:\n positionStyles = {\n bottom: increaseIndent,\n left: '0',\n right: 'auto',\n top: 'auto',\n };\n popoverModification = 'bottom';\n break;\n case BELL_POSITION_TOP_LEFT:\n positionStyles = {\n top: increaseIndent,\n left: '0',\n right: 'auto',\n bottom: 'auto',\n };\n popoverModification = 'top';\n break;\n case BELL_POSITION_TOP_RIGHT:\n positionStyles = {\n top: increaseIndent,\n right: '0',\n left: 'auto',\n bottom: 'auto',\n };\n popoverModification = 'top';\n break;\n default:\n positionStyles = {\n bottom: increaseIndent,\n right: '0',\n left: 'auto',\n top: 'auto',\n };\n popoverModification = 'bottom';\n }\n\n return [positionStyles, popoverModification];\n }\n\n public static getPopoverArrowPosition(bellPosition: TBellPosition, bellSize: string) {\n let arrowAdditionalStyles;\n\n switch (bellPosition) {\n case BELL_POSITION_BOTTOM_RIGHT:\n arrowAdditionalStyles = `\\n.pushwoosh-subscribe-widget__popover__bottom:after {left: auto; right: ${(parseInt(bellSize) / 2 - 4) + 'px'}`;\n break;\n case BELL_POSITION_BOTTOM_LEFT:\n arrowAdditionalStyles = `\\n.pushwoosh-subscribe-widget__popover__bottom:after {right: auto; left: ${(parseInt(bellSize) / 2 - 12) + 'px'}`;\n break;\n case BELL_POSITION_TOP_LEFT:\n arrowAdditionalStyles = `\\n.pushwoosh-subscribe-widget__popover__top:after {right: auto; left: ${(parseInt(bellSize) / 2 - 12) + 'px'}`;\n break;\n case BELL_POSITION_TOP_RIGHT:\n arrowAdditionalStyles = `\\n.pushwoosh-subscribe-widget__popover__top:after {left: auto; right: ${(parseInt(bellSize) / 2 - 4) + 'px'}`;\n break;\n default:\n arrowAdditionalStyles = `\\n.pushwoosh-subscribe-widget__popover__bottom:after {left: auto; right: ${(parseInt(bellSize) / 2 - 4) + 'px'}`;\n }\n\n return arrowAdditionalStyles;\n }\n}\n","import {\n PERMISSION_GRANTED,\n PERMISSION_DENIED,\n PERMISSION_PROMPT,\n} from '../../core/constants';\nimport mainCss from './assets/css/main.css';\nimport bellSVG from './bell';\nimport {\n SUBSCRIBE_WIDGET_DEFAULT_CONFIG,\n WIDGET_CONTAINER_ID,\n} from './constants';\nimport Positioning from './positioning';\nimport { type TBellConfig, type TCSSStylesObject, type TStyleKeys } from './subscribe_widget.types';\nimport { type Pushwoosh } from '../../core/Pushwoosh';\nimport {\n type TPlatformChrome,\n type TPlatformEdge,\n type TPlatformFirefox,\n type TPlatformSafari,\n} from '../../modules/PlatformChecker/PlatformChecker.types';\n\nexport class PWSubscriptionButtonWidget {\n widget: HTMLElement;\n tooltip: HTMLElement;\n popover: HTMLElement;\n style: HTMLElement;\n pw: Pushwoosh;\n config: TBellConfig;\n\n constructor(pw: Pushwoosh) {\n // Set Pushwoosh object\n this.pw = pw;\n if (!pw.platformChecker.isAvailableNotifications) {\n console.warn('Browser does not support push notifications');\n return;\n }\n\n // Bindings\n this.clickBell = this.clickBell.bind(this);\n this.onSubscribeEvent = this.onSubscribeEvent.bind(this);\n this.onUnsubscribeEvent = this.onUnsubscribeEvent.bind(this);\n this.onPermissionDeniedEvent = this.onPermissionDeniedEvent.bind(this);\n this.clickOutOfPopover = this.clickOutOfPopover.bind(this);\n\n // Config\n const tooltipText = Object.assign(SUBSCRIBE_WIDGET_DEFAULT_CONFIG.tooltipText, pw.initParams.subscribeWidget!.tooltipText);\n this.config = Object.assign({}, SUBSCRIBE_WIDGET_DEFAULT_CONFIG, pw.initParams.subscribeWidget);\n this.config.tooltipText = tooltipText;\n }\n\n public async run() {\n // Nothing to subscribe to when push is unavailable, and the constructor\n // leaves the config unset in that case — so keep this before any render.\n if (!this.pw.isPushAvailable()) {\n return;\n }\n\n const isSubscribed = await this.pw.isSubscribed();\n if (!isSubscribed) {\n await this.render();\n }\n }\n\n /**\n * Apply styles to element\n * @param styles\n * @param {HTMLElement} element\n */\n private addStylesToElement(styles: TCSSStylesObject, element: HTMLElement) {\n Object.keys(styles).forEach((st: TStyleKeys) => {\n element.style[st] = styles[st];\n });\n }\n\n /**\n * Create container element\n * @returns {HTMLElement}\n */\n private createContainer(): HTMLElement {\n const container = document.createElement('div');\n container.id = WIDGET_CONTAINER_ID;\n container.className = 'pushwoosh-subscribe-widget';\n const position = Positioning.getBellPosition(this.config.position, this.config.indent);\n const styles = Object.assign({\n zIndex: this.config.zIndex,\n }, position);\n this.addStylesToElement(styles, container);\n return container;\n }\n\n /**\n * Create styles element\n * @returns {HTMLElement}\n */\n private createStyle(): HTMLElement {\n const styleNode = document.createElement('style');\n styleNode.innerHTML = mainCss;\n return styleNode;\n }\n\n /**\n * Create cell button element\n * @returns {HTMLElement}\n */\n private createBell(): HTMLElement {\n const { config } = this;\n let bell;\n if (config.buttonImage) {\n bell = document.createElement('img') as HTMLImageElement;\n bell.src = config.buttonImage;\n } else {\n bell = document.createElement('div');\n this.addStylesToElement({\n backgroundColor: config.bgColor,\n boxShadow: config.shadow,\n lineHeight: config.size,\n border: config.bellButtonBorder,\n }, bell);\n\n bell.innerHTML = bellSVG(config.bellColor, config.bellStrokeColor);\n }\n this.addStylesToElement({\n width: config.size,\n height: config.size,\n }, bell);\n bell.className = 'pushwoosh-subscribe-widget__bell-button';\n return bell;\n }\n\n /**\n * Create tooltip element\n * @returns {Promise<HTMLElement>}\n */\n private async createTooltip(): Promise<HTMLElement> {\n const tooltip = document.createElement('div');\n const [position, modification] = Positioning.getTooltipPosition(this.config.position, this.config.size);\n tooltip.className = `pushwoosh-subscribe-widget__tooltip pushwoosh-subscribe-widget__tooltip__${modification}`;\n this.addStylesToElement(position, tooltip);\n\n tooltip.appendChild(await this.createTooltipContent());\n return tooltip;\n }\n\n /**\n * Create tooltip content element\n * @returns {Promise<HTMLElement>}\n */\n private async createTooltipContent(): Promise<HTMLElement> {\n const tooltipContent = document.createElement('div');\n tooltipContent.innerText = await this.tooltipTextFactory();\n tooltipContent.className = 'pushwoosh-subscribe-widget__tooltip-content';\n return tooltipContent;\n }\n\n /**\n * Tooltip text content depending of the permissions\n * @returns {Promise<string>}\n */\n private async tooltipTextFactory(): Promise<string> {\n const permission = this.pw.driver?.getPermission();\n const { tooltipText } = this.config;\n const isManuallyUnsubscribed = await this.pw.data.getStatusManualUnsubscribed();\n\n switch (permission) {\n case PERMISSION_GRANTED:\n return isManuallyUnsubscribed ? tooltipText.needSubscribe : tooltipText.alreadySubscribed;\n case PERMISSION_PROMPT:\n return tooltipText.needSubscribe;\n case PERMISSION_DENIED:\n return tooltipText.blockSubscribe;\n default:\n return tooltipText.needSubscribe;\n }\n }\n\n /**\n * Create permission denied popover element\n * @returns {HTMLElement}\n */\n private createPopover(): HTMLElement {\n const popoverContentWrapper = document.createElement('div');\n const popover = document.createElement('div');\n const [position, modification] = Positioning.getPopoverPosition(this.config.position, this.config.size);\n popover.className = `pushwoosh-subscribe-widget__popover pushwoosh-subscribe-widget__popover__${modification}`;\n popoverContentWrapper.className = 'pushwoosh-subscribe-widget__popover-content-wrapper';\n\n this.style.innerHTML += Positioning.getPopoverArrowPosition(this.config.position, this.config.size);\n\n const styles = Object.assign({\n maxWidth: `calc(100vw - ${this.config.indent} - ${this.config.indent})`,\n }, position);\n this.addStylesToElement(styles, popover);\n\n popoverContentWrapper.appendChild(this.createPopoverContent());\n popover.appendChild(popoverContentWrapper);\n return popover;\n }\n\n private getBrowserName() {\n const platformChecker = this.pw.platformChecker;\n let browser;\n if (platformChecker.isOpera) {\n browser = 'opera';\n } else if (<TPlatformChrome>platformChecker.platform === 11 && navigator.userAgent.match(/Android/i)) {\n browser = 'mobileChrome';\n } else if (<TPlatformFirefox>platformChecker.platform === 12) {\n browser = 'firefox';\n } else if (<TPlatformSafari>platformChecker.platform === 10) {\n browser = 'safari';\n } else if (<TPlatformEdge>platformChecker.platform === 150) {\n browser = 'edge';\n } else {\n browser = 'chrome';\n }\n return browser;\n }\n\n /**\n * Create permission denied popover content element\n * @returns {HTMLElement}\n */\n private createPopoverContent(): HTMLElement {\n const { config } = this;\n const popoverContent = document.createElement('div');\n popoverContent.className = 'pushwoosh-subscribe-widget__popover-content';\n\n const browser = this.getBrowserName();\n\n const userImageSrc = config.contentImages && config.contentImages[browser];\n if (userImageSrc) {\n const image = document.createElement('img') as HTMLImageElement;\n image.src = userImageSrc;\n popoverContent.appendChild(image);\n } else {\n const standardImagesMap: Record<string, string> = {\n opera: 'opera',\n mobileChrome: 'mobile_chrome',\n firefox: 'FF',\n safari: 'safari',\n };\n const standardImage = standardImagesMap[browser] || 'chrome';\n [{\n src: this.getImageSrc(standardImage),\n width: 500,\n height: 130,\n }, {\n src: this.getImageSrc(`${standardImage}_unlock`),\n width: 500,\n height: 230,\n }].forEach((imageAttrs) => {\n const image = document.createElement('img');\n Object.assign(image, imageAttrs);\n popoverContent.appendChild(image);\n });\n }\n\n return popoverContent;\n }\n\n /**\n * Return source of help images depending of the browser\n * @returns {string}\n */\n getImageSrc(img: string): string {\n return `https://cdn.pushwoosh.com/webpush/img/${img}.jpg`;\n }\n\n private async render() {\n this.widget = this.createContainer();\n this.style = this.createStyle();\n const bell = this.createBell();\n this.tooltip = await this.createTooltip();\n this.popover = await this.createPopover();\n\n this.widget.appendChild(this.style);\n this.widget.appendChild(bell);\n this.widget.appendChild(this.tooltip);\n this.widget.appendChild(this.popover);\n\n document.body.appendChild(this.widget);\n\n this.pw.push(['onSubscribe', this.onSubscribeEvent]);\n this.pw.push(['onUnsubscribe', this.onUnsubscribeEvent]);\n this.pw.push(['onPermissionDenied', this.onPermissionDeniedEvent]);\n\n this.addEventListeners();\n }\n\n addEventListeners() {\n this.widget.addEventListener('click', this.clickBell);\n window.addEventListener('click', this.clickOutOfPopover);\n }\n\n /**\n * Toggle visibility of popover\n */\n toggleHelpPopover() {\n this.popover.classList.toggle('pushwoosh-subscribe-widget__popover__visible');\n }\n\n /**\n * Click bell button event callback\n * @returns {Promise<void>}\n */\n private async clickBell() {\n const permission = this.pw.driver?.getPermission();\n\n switch (permission) {\n case PERMISSION_GRANTED:\n await this.pw.subscribe();\n\n break;\n case PERMISSION_PROMPT:\n await this.pw.subscribe();\n\n break;\n case PERMISSION_DENIED:\n this.toggleHelpPopover();\n\n break;\n default:\n console.warn('Unknown browser notification permission');\n }\n }\n\n /**\n * On subscribe event callback\n * @returns {Promise<void>}\n */\n private async onSubscribeEvent() {\n const tooltipContent = this.tooltip.querySelector('div');\n\n if (tooltipContent === null) {\n return;\n }\n\n tooltipContent.innerText = this.config.tooltipText.successSubscribe;\n this.tooltip.classList.add('pushwoosh-subscribe-widget__tooltip__visible');\n\n setTimeout(async () => {\n this.tooltip.classList.remove('pushwoosh-subscribe-widget__tooltip__visible');\n tooltipContent.innerText = await this.tooltipTextFactory();\n\n this.widget.classList.add('pushwoosh-subscribe-widget__subscribed');\n }, 2000);\n }\n\n /**\n * On permission denied event\n * @returns {Promise<void>}\n */\n private async onPermissionDeniedEvent(): Promise<void> {\n this.addEventListeners();\n\n const tooltipContent = this.tooltip.querySelector('div');\n if (tooltipContent === null) return;\n tooltipContent.innerText = await this.tooltipTextFactory();\n }\n\n /**\n * Out of popover click event\n * @param {MessageEvent} ev\n */\n clickOutOfPopover(ev: MessageEvent) {\n const closeRule = this.popover.classList.contains('pushwoosh-subscribe-widget__popover__visible')\n && !(ev.target as any).classList.contains('pushwoosh-subscribe-widget__popover')\n && (ev.target as any).closest('.pushwoosh-subscribe-widget__popover') === null\n && !(ev.target as any).classList.contains('pushwoosh-subscribe-widget__bell-button')\n && (ev.target as any).closest('.pushwoosh-subscribe-widget__bell-button') === null;\n\n if (closeRule) this.popover.classList.remove('pushwoosh-subscribe-widget__popover__visible');\n }\n\n private async onUnsubscribeEvent() {\n const tooltipContent = this.tooltip.querySelector('div');\n\n if (tooltipContent === null) {\n return;\n }\n\n tooltipContent.innerText = await this.tooltipTextFactory();\n }\n}\n","export default (fillColor: string, strokeColor: string) => {\n return '<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\\n'\n + '<svg\\n'\n + ' xmlns:dc=\"http://purl.org/dc/elements/1.1/\"\\n'\n + ' xmlns:cc=\"http://creativecommons.org/ns#\"\\n'\n + ' xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\\n'\n + ' xmlns:svg=\"http://www.w3.org/2000/svg\"\\n'\n + ' xmlns=\"http://www.w3.org/2000/svg\"\\n'\n + ' xmlns:sodipodi=\"http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd\"\\n'\n + ' xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\"\\n'\n + ' version=\"1.1\"\\n'\n + ' id=\"Capa_1\"\\n'\n + ' x=\"0px\"\\n'\n + ' y=\"0px\"\\n'\n + ' viewBox=\"0 0 346.013 346.013\"\\n'\n + ' style=\"enable-background:new 0 0 346.013 346.013;width: 80%; height: auto; vertical-align: middle;\"\\n'\n + ' xml:space=\"preserve\"\\n'\n + ' inkscape:version=\"0.91 r13725\"\\n'\n + ' sodipodi:docname=\"alarm_white.svg\"><metadata\\n'\n + ' id=\"metadata51\"><rdf:RDF><cc:Work\\n'\n + ' rdf:about=\"\"><dc:format>image/svg+xml</dc:format><dc:type\\n'\n + ' rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs\\n'\n + ' id=\"defs49\" /><sodipodi:namedview\\n'\n + ' borderopacity=\"1\"\\n'\n + ' objecttolerance=\"10\"\\n'\n + ' gridtolerance=\"10\"\\n'\n + ' guidetolerance=\"10\"\\n'\n + ' inkscape:pageopacity=\"0\"\\n'\n + ' inkscape:pageshadow=\"2\"\\n'\n + ' inkscape:window-width=\"1618\"\\n'\n + ' inkscape:window-height=\"828\"\\n'\n + ' id=\"namedview47\"\\n'\n + ' showgrid=\"false\"\\n'\n + ' inkscape:zoom=\"0.6820553\"\\n'\n + ' inkscape:cx=\"173.0065\"\\n'\n + ' inkscape:cy=\"173.0065\"\\n'\n + ' inkscape:window-x=\"0\"\\n'\n + ' inkscape:window-y=\"0\"\\n'\n + ' inkscape:window-maximized=\"0\"\\n'\n + ' inkscape:current-layer=\"g3\" /><g\\n'\n + ' id=\"g3\"><path\\n'\n + ' d=\"m 256.76227,220.19006 c -1.77513,-2.69766 -3.45154,-5.24564 -3.98966,-7.46382 -0.042,-0.17861 -0.0911,-0.36128 -0.16237,-0.61436 -2.28354,-7.67647 0.69147,-24.43921 2.46886,-34.45124 0.26788,-1.50394 0.52274,-2.94197 0.75286,-4.29035 0.0232,-0.13675 0.044,-0.27211 0.0724,-0.48006 1.95582,-15.28051 2.58811,-37.91956 -5.51044,-58.99147 -5.6032,-14.57978 -14.45978,-25.82612 -26.3559,-33.48393 1.26598,-9.812938 -4.85967,-19.343691 -14.66682,-22.0511 -9.80715,-2.70741 -19.95724,2.33226 -23.90298,11.405413 -14.1382,0.467533 -27.51111,5.577097 -39.80114,15.219267 -17.76129,13.9298 -28.83431,33.68757 -34.99389,47.80757 l -0.0479,0.11335 c -0.0512,0.12175 -0.0998,0.24114 -0.13249,0.32962 -0.49733,1.28292 -1.01552,2.64514 -1.55689,4.07255 -3.61311,9.51043 -9.66004,25.42824 -15.611995,30.89342 -0.106524,0.10027 -0.208228,0.20187 -0.362362,0.35435 -1.636243,1.66563 -4.382941,2.99463 -7.288979,4.40101 -7.145531,3.45301 -22.013613,10.64166 -17.206389,31.67844 0.929154,4.07105 4.008437,7.29057 8.033861,8.40185 l 167.570804,46.2604 c 4.02253,1.11048 8.31521,-0.0729 11.2052,-3.08958 14.91617,-15.58874 5.84693,-29.38668 1.48625,-36.02133 z\"\\n'\n + ' id=\"path5\"\\n'\n + ' inkscape:connector-curvature=\"0\"\\n'\n + ' vector-effect=\"non-scaling-stroke\"\\n'\n + ` style=\"fill:${fillColor}; stroke: ${strokeColor}; stroke-width: 1; \" /><path\\n`\n + ' vector-effect=\"non-scaling-stroke\"\\n'\n + ' d=\"m 174.26737,259.72378 -38.76399,-10.70137 c -1.59243,-0.43962 -3.28183,-0.15596 -4.63548,0.7754 -2.53909,1.7494 -2.84182,4.93159 -3.02304,6.83188 l -0.0151,0.15247 c -1.22819,12.67106 6.79854,24.33046 19.08688,27.72284 12.51583,3.45518 25.8324,-2.91586 30.9681,-14.80385 l 0.0935,-0.19205 c 0.52305,-1.06418 1.74613,-3.55554 0.50882,-6.31116 -0.44302,-0.98439 -1.5794,-2.74529 -4.21964,-3.47416 z\"\\n'\n + ' id=\"path7\"\\n'\n + ' inkscape:connector-curvature=\"0\"\\n'\n + ` style=\"fill:${fillColor}; stroke: ${strokeColor}; stroke-width: 1;\" /></g><g\\n`\n + ' id=\"g17\" /><g\\n'\n + ' id=\"g19\" /><g\\n'\n + ' id=\"g21\" /><g\\n'\n + ' id=\"g23\" /><g\\n'\n + ' id=\"g25\" /><g\\n'\n + ' id=\"g27\" /><g\\n'\n + ' id=\"g29\" /><g\\n'\n + ' id=\"g31\" /><g\\n'\n + ' id=\"g33\" /><g\\n'\n + ' id=\"g35\" /><g\\n'\n + ' id=\"g37\" /><g\\n'\n + ' id=\"g39\" /><g\\n'\n + ' id=\"g41\" /><g\\n'\n + ' id=\"g43\" /><g\\n'\n + ' id=\"g45\" /></svg>';\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","PERMISSION_GRANTED","PERMISSION_PROMPT","BELL_POSITION_BOTTOM_RIGHT","BELL_POSITION_BOTTOM_LEFT","BELL_POSITION_TOP_RIGHT","BELL_POSITION_TOP_LEFT","SUBSCRIBE_WIDGET_DEFAULT_CONFIG","position","bgColor","bellColor","bellStrokeColor","bellButtonBorder","shadow","size","indent","zIndex","tooltipText","successSubscribe","needSubscribe","blockSubscribe","alreadySubscribed","Positioning","getBellPosition","positionStyles","top","left","bottom","right","getTooltipPosition","bellPosition","bellSize","tooltipModification","increaseIndent","parseInt","getPopoverPosition","popoverModification","getPopoverArrowPosition","arrowAdditionalStyles","PWSubscriptionButtonWidget","constructor","pw","platformChecker","isAvailableNotifications","console","warn","clickBell","bind","onSubscribeEvent","onUnsubscribeEvent","onPermissionDeniedEvent","clickOutOfPopover","assign","initParams","subscribeWidget","config","run","isPushAvailable","isSubscribed","render","addStylesToElement","styles","element","keys","forEach","st","style","createContainer","container","document","createElement","id","className","createStyle","styleNode","innerHTML","createBell","bell","fillColor","strokeColor","buttonImage","src","backgroundColor","boxShadow","lineHeight","border","width","height","createTooltip","tooltip","modification","appendChild","createTooltipContent","tooltipContent","innerText","tooltipTextFactory","permission","driver","getPermission","isManuallyUnsubscribed","data","getStatusManualUnsubscribed","createPopover","popoverContentWrapper","popover","maxWidth","createPopoverContent","getBrowserName","browser","isOpera","platform","navigator","userAgent","match","popoverContent","userImageSrc","contentImages","image","standardImage","opera","mobileChrome","firefox","safari","getImageSrc","imageAttrs","img","widget","body","push","addEventListeners","addEventListener","window","toggleHelpPopover","classList","toggle","subscribe","querySelector","add","setTimeout","async","remove","ev","contains","target","closest"],"sourceRoot":""}
1
+ {"version":3,"file":"widget-subscription-button.js","mappings":"CAAA,SAAAA,EAAAC,GACA,oBAAAC,SAAA,iBAAAC,OACAA,OAAAD,QAAAD,SACA,sBAAAG,QAAAA,OAAAC,IACAD,OAAA,GAAAH,OACA,CACA,IAAAK,EAAAL,IACA,QAAAM,KAAAD,GAAA,iBAAAJ,QAAAA,QAAAF,GAAAO,GAAAD,EAAAC,EACA,CACC,CATD,CASCC,KAAA,uBCRD,MAAAC,EAAA,CCAAA,EAAA,CAAAP,EAAAQ,KACA,QAAAC,KAAAD,EACAD,EAAAG,EAAAF,EAAAC,KAAAF,EAAAG,EAAAV,EAAAS,IACAE,OAAAC,eAAAZ,EAAAS,EAAA,CAAyCI,YAAA,EAAAC,IAAAN,EAAAC,MCJzCF,EAAA,CAAAQ,EAAAC,IAAAL,OAAAM,UAAAC,eAAAC,KAAAJ,EAAAC,GCCAT,EAAAP,IACAW,OAAAS,iBAAApB,EAAA,CAAoC,CAAAqB,OAAAC,aAAA,CAAwBC,MAAA,UAAiBC,WAAA,CAAgBD,OAAA,iECFtF,MAyBME,EAAqB,UACrBC,EAAoB,UCvBpBC,EAA6B,cAC7BC,EAA4B,aAC5BC,EAA0B,WAC1BC,EAAyB,UAKzBC,EAA+C,CAC1DC,SAAUJ,EACVK,QAAS,UACTC,UAAW,QACXC,gBAAiB,UACjBC,iBAAkB,oBAClBC,OAAQ,kCACRC,KAAM,OACNC,OAAQ,OACRC,OAAQ,SACRC,YAAa,CACXC,iBAAkB,mCAClBC,cAAe,0CACfC,eAAgB,wCAChBC,kBAAmB,+BCjBR,MAAMC,EACZ,sBAAOC,CAAgBf,EAAyBO,GACrD,IAAIS,EAEJ,OAAQhB,GACN,KAAKL,EACHqB,EAAiB,CACfC,IAAK,OACLC,KAAM,OAC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,MAAM4C,EAAiB/G,KAAK2G,QAAQ+C,cAAc,OAE3B,OAAnB3C,IAIJA,EAAeC,gBAAkBhH,KAAKiH,qBACxC","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/core/constants.ts","webpack://web-push-notifications/./src/widgets/SubscriptionButton/constants.ts","webpack://web-push-notifications/./src/widgets/SubscriptionButton/positioning.ts","webpack://web-push-notifications/./src/widgets/SubscriptionButton/index.ts","webpack://web-push-notifications/./src/widgets/SubscriptionButton/bell.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse {\n\t\tvar a = factory();\n\t\tfor(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];\n\t}\n})(this, () => {\nreturn ","// The require scope\nconst __webpack_require__ = {};\n\n","// define getter/value functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop));","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tObject.defineProperties(exports, { [Symbol.toStringTag]: { value: 'Module' }, __esModule: { value: true } });\n};","export const DEFAULT_SERVICE_WORKER_URL = '/pushwoosh-service-worker.js';\nexport const DEFAULT_API_URL = 'https://api.pushwoosh.com/json/1.3/';\n\nexport const PERIOD_SEND_APP_OPEN = 3600000;\nexport const PERIOD_GOAL_EVENT = 86400000;\n\nexport const DEFAULT_NOTIFICATION_TITLE = 'Pushwoosh notification';\nexport const DEFAULT_NOTIFICATION_IMAGE = 'https://cp.pushwoosh.com/img/logo-medium.png';\n\n// Keys\nexport const KEY_SHOW_SUBSCRIBE_WIDGET = 'WIDGET_SHOWED';\nexport const KEY_CLICK_SUBSCRIBE_WIDGET = 'WIDGET_CLICKED';\n\n// Local storage keys\nexport const KEY_DEVICE_REGISTRATION_STATUS: string = 'deviceRegistrationStatus';\nexport const KEY_REPORTED_PUSH_PERMISSION_STATUS: string = 'reportedPushPermissionStatus';\nexport const KEY_SAFARI_PREVIOUS_PERMISSION = 'safariPreviousPermission';\nexport const MANUAL_SET_LOGGER_LEVEL = 'PW_SET_LOGGER_LEVEL';\n\n// Device registration status\nexport const DEVICE_REGISTRATION_STATUS_REGISTERED: string = 'registered';\nexport const DEVICE_REGISTRATION_STATUS_UNREGISTERED: string = 'unregistered';\n\n// Permissions\nexport const PERMISSION_DENIED = 'denied';\nexport const PERMISSION_GRANTED = 'granted';\nexport const PERMISSION_PROMPT = 'default';\n\n// Events\nexport const LEGACY_EVENT_ON_LOAD = 'onLoad';\nexport const LEGACY_EVENT_ON_READY = 'onReady';\nexport const LEGACY_EVENT_ON_SUBSCRIBE = 'onSubscribe';\nexport const LEGACY_EVENT_ON_UNSUBSCRIBE = 'onUnsubscribe';\nexport const LEGACY_EVENT_ON_REGISTER = 'onRegister';\nexport const LEGACY_EVENT_ON_PERMISSION_PROMPT = 'onPermissionPrompt';\nexport const LEGACY_EVENT_ON_PERMISSION_DENIED = 'onPermissionDenied';\nexport const LEGACY_EVENT_ON_PERMISSION_GRANTED = 'onPermissionGranted';\nexport const LEGACY_EVENT_ON_SW_INIT_ERROR = 'onSWInitError';\nexport const LEGACY_EVENT_ON_PUSH_DELIVERY = 'onPushDelivery';\nexport const LEGACY_EVENT_ON_NOTIFICATION_CLICK = 'onNotificationClick';\nexport const LEGACY_EVENT_ON_NOTIFICATION_CLOSE = 'onNotificationClose';\nexport const LEGACY_EVENT_ON_CHANGE_COMMUNICATION_ENABLED = 'onChangeCommunicationEnabled';\nexport const LEGACY_EVENT_ON_PUT_NEW_MESSAGE_TO_INBOX_STORE = 'onPutNewMessageToInboxStore';\nexport const LEGACY_EVENT_ON_UPDATE_INBOX_MESSAGES = 'onUpdateInboxMessages';\nexport const LEGACY_EVENT_ON_SHOW_NOTIFICATION_PERMISSION_DIALOG = 'onShowNotificationPermissionDialog';\nexport const LEGACY_EVENT_ON_HIDE_NOTIFICATION_PERMISSION_DIALOG = 'onHideNotificationPermissionDialog';\n\nexport const LEGACY_EVENT_ON_SHOW_SUBSCRIPTION_WIDGET = 'onShowSubscriptionWidget';\nexport const LEGACY_EVENT_ON_HIDE_SUBSCRIPTION_WIDGET = 'onHideSubscriptionWidget';\n\n// Post Events\nexport const EVENT_SHOW_SUBSCRIBE_BUTTON = 'showSubscribeButton';\nexport const EVENT_CLICK_SUBSCRIBE_BUTTON = 'clickSubscribeButton';\nexport const EVENT_GDPR_CONSENT = 'GDPRConsent';\nexport const EVENT_GDPR_DELETE = 'GDPRDelete';\nexport const EVENT_PW_SITE_OPENED = 'PW_SiteOpened'; // for default events\n\n// Storage that keeps no hwid (in-app webview, private window, insecure context)\n// leaves the device unidentifiable, and the backend rejects such requests.\nexport const HWID_UNAVAILABLE_MESSAGE = 'Pushwoosh: the SDK storage does not keep the hwid in this browser '\n + '(in-app webview, private window or insecure context), so this device cannot be identified. '\n + 'Requests that need an hwid are not sent.';\n\nexport const IDENTITY_UNAVAILABLE_MESSAGE = 'Pushwoosh: neither a userId nor an hwid is available, '\n + 'so there is nothing to register the email, SMS or WhatsApp channel to. '\n + 'Pass a userId in the init params.';\n\n// A rejected application code is a configuration error, not a failure: no\n// request of the SDK can succeed after it, so init stops instead of retrying.\nexport const API_STATUS_CODE_INVALID_APPLICATION = 210;\nexport const FATAL_API_STATUS_CODES: number[] = [API_STATUS_CODE_INVALID_APPLICATION];\n\n// How long an inbox tap waits for a widget bundle before falling back to the message link.\nexport const WIDGET_LOAD_TIMEOUT_MS = 10000;\n\n// A browser subscription can hang; the permission-change report stops waiting for it after this.\nexport const SUBSCRIPTION_WAIT_TIMEOUT_MS: number = 10000;\n","// Bell\nimport { type TBellConfig } from './subscribe_widget.types';\n\nexport const BELL_POSITION_BOTTOM_RIGHT = 'bottomRight';\nexport const BELL_POSITION_BOTTOM_LEFT = 'bottomLeft';\nexport const BELL_POSITION_TOP_RIGHT = 'topRight';\nexport const BELL_POSITION_TOP_LEFT = 'topLeft';\n\n// Common\nexport const WIDGET_CONTAINER_ID = 'pushwooshBellWidget';\n\nexport const SUBSCRIBE_WIDGET_DEFAULT_CONFIG: TBellConfig = {\n position: BELL_POSITION_BOTTOM_LEFT,\n bgColor: '#12AE7E',\n bellColor: 'white',\n bellStrokeColor: '#08754f',\n bellButtonBorder: '1px solid #379676',\n shadow: '0px 0px 6px rgba(0, 0, 0, 0.75)',\n size: '48px',\n indent: '20px',\n zIndex: '999999',\n tooltipText: {\n successSubscribe: 'You are successfully subscribed!',\n needSubscribe: 'Get notifications about important news!',\n blockSubscribe: 'Click to see how to get notifications',\n alreadySubscribed: 'You are already subscribed',\n },\n};\n","import {\n BELL_POSITION_TOP_RIGHT,\n BELL_POSITION_TOP_LEFT,\n BELL_POSITION_BOTTOM_LEFT,\n BELL_POSITION_BOTTOM_RIGHT,\n} from './constants';\nimport { type TBellPosition, type TPositionStyles } from './subscribe_widget.types';\n\nexport default class Positioning {\n public static getBellPosition(position: TBellPosition, indent: string): TPositionStyles {\n let positionStyles: TPositionStyles;\n\n switch (position) {\n case BELL_POSITION_BOTTOM_RIGHT:\n positionStyles = {\n top: 'auto',\n left: 'auto',\n bottom: indent,\n right: indent,\n };\n break;\n case BELL_POSITION_BOTTOM_LEFT:\n positionStyles = {\n top: 'auto',\n left: indent,\n bottom: indent,\n right: 'auto',\n };\n break;\n case BELL_POSITION_TOP_LEFT:\n positionStyles = {\n top: indent,\n left: indent,\n bottom: 'auto',\n right: 'auto',\n };\n break;\n case BELL_POSITION_TOP_RIGHT:\n positionStyles = {\n top: indent,\n left: 'auto',\n bottom: 'auto',\n right: indent,\n };\n break;\n default:\n positionStyles = {\n top: 'auto',\n left: 'auto',\n bottom: indent,\n right: indent,\n };\n }\n\n return positionStyles;\n }\n\n public static getTooltipPosition(bellPosition: TBellPosition, bellSize: string): [{ left: string } | { right: string }, string] {\n let positionStyles;\n let tooltipModification;\n const increaseIndent = (parseInt(bellSize) + 12) + 'px';\n\n switch (bellPosition) {\n case BELL_POSITION_BOTTOM_RIGHT:\n positionStyles = { right: increaseIndent };\n tooltipModification = 'right';\n break;\n case BELL_POSITION_BOTTOM_LEFT:\n positionStyles = { left: increaseIndent };\n tooltipModification = 'left';\n break;\n case BELL_POSITION_TOP_LEFT:\n positionStyles = { left: increaseIndent };\n tooltipModification = 'left';\n break;\n case BELL_POSITION_TOP_RIGHT:\n positionStyles = { right: increaseIndent };\n tooltipModification = 'right';\n break;\n default:\n positionStyles = { right: increaseIndent };\n tooltipModification = 'right';\n }\n\n return [positionStyles, tooltipModification];\n }\n\n public static getPopoverPosition(bellPosition: TBellPosition, bellSize: string): [TPositionStyles, string] {\n let positionStyles;\n let popoverModification;\n const increaseIndent = (parseInt(bellSize) + 15) + 'px';\n\n switch (bellPosition) {\n case BELL_POSITION_BOTTOM_RIGHT:\n positionStyles = {\n bottom: increaseIndent,\n right: '0',\n left: 'auto',\n top: 'auto',\n };\n popoverModification = 'bottom';\n break;\n case BELL_POSITION_BOTTOM_LEFT:\n positionStyles = {\n bottom: increaseIndent,\n left: '0',\n right: 'auto',\n top: 'auto',\n };\n popoverModification = 'bottom';\n break;\n case BELL_POSITION_TOP_LEFT:\n positionStyles = {\n top: increaseIndent,\n left: '0',\n right: 'auto',\n bottom: 'auto',\n };\n popoverModification = 'top';\n break;\n case BELL_POSITION_TOP_RIGHT:\n positionStyles = {\n top: increaseIndent,\n right: '0',\n left: 'auto',\n bottom: 'auto',\n };\n popoverModification = 'top';\n break;\n default:\n positionStyles = {\n bottom: increaseIndent,\n right: '0',\n left: 'auto',\n top: 'auto',\n };\n popoverModification = 'bottom';\n }\n\n return [positionStyles, popoverModification];\n }\n\n public static getPopoverArrowPosition(bellPosition: TBellPosition, bellSize: string) {\n let arrowAdditionalStyles;\n\n switch (bellPosition) {\n case BELL_POSITION_BOTTOM_RIGHT:\n arrowAdditionalStyles = `\\n.pushwoosh-subscribe-widget__popover__bottom:after {left: auto; right: ${(parseInt(bellSize) / 2 - 4) + 'px'}`;\n break;\n case BELL_POSITION_BOTTOM_LEFT:\n arrowAdditionalStyles = `\\n.pushwoosh-subscribe-widget__popover__bottom:after {right: auto; left: ${(parseInt(bellSize) / 2 - 12) + 'px'}`;\n break;\n case BELL_POSITION_TOP_LEFT:\n arrowAdditionalStyles = `\\n.pushwoosh-subscribe-widget__popover__top:after {right: auto; left: ${(parseInt(bellSize) / 2 - 12) + 'px'}`;\n break;\n case BELL_POSITION_TOP_RIGHT:\n arrowAdditionalStyles = `\\n.pushwoosh-subscribe-widget__popover__top:after {left: auto; right: ${(parseInt(bellSize) / 2 - 4) + 'px'}`;\n break;\n default:\n arrowAdditionalStyles = `\\n.pushwoosh-subscribe-widget__popover__bottom:after {left: auto; right: ${(parseInt(bellSize) / 2 - 4) + 'px'}`;\n }\n\n return arrowAdditionalStyles;\n }\n}\n","import {\n PERMISSION_GRANTED,\n PERMISSION_DENIED,\n PERMISSION_PROMPT,\n} from '../../core/constants';\nimport mainCss from './assets/css/main.css';\nimport bellSVG from './bell';\nimport {\n SUBSCRIBE_WIDGET_DEFAULT_CONFIG,\n WIDGET_CONTAINER_ID,\n} from './constants';\nimport Positioning from './positioning';\nimport { type TBellConfig, type TCSSStylesObject, type TStyleKeys } from './subscribe_widget.types';\nimport { type Pushwoosh } from '../../core/Pushwoosh';\nimport {\n type TPlatformChrome,\n type TPlatformEdge,\n type TPlatformFirefox,\n type TPlatformSafari,\n} from '../../modules/PlatformChecker/PlatformChecker.types';\n\nexport class PWSubscriptionButtonWidget {\n widget: HTMLElement;\n tooltip: HTMLElement;\n popover: HTMLElement;\n style: HTMLElement;\n pw: Pushwoosh;\n config: TBellConfig;\n\n constructor(pw: Pushwoosh) {\n // Set Pushwoosh object\n this.pw = pw;\n if (!pw.platformChecker.isAvailableNotifications) {\n console.warn('Browser does not support push notifications');\n return;\n }\n\n // Bindings\n this.clickBell = this.clickBell.bind(this);\n this.onSubscribeEvent = this.onSubscribeEvent.bind(this);\n this.onUnsubscribeEvent = this.onUnsubscribeEvent.bind(this);\n this.onPermissionDeniedEvent = this.onPermissionDeniedEvent.bind(this);\n this.clickOutOfPopover = this.clickOutOfPopover.bind(this);\n\n // Config\n const tooltipText = Object.assign(SUBSCRIBE_WIDGET_DEFAULT_CONFIG.tooltipText, pw.initParams.subscribeWidget!.tooltipText);\n this.config = Object.assign({}, SUBSCRIBE_WIDGET_DEFAULT_CONFIG, pw.initParams.subscribeWidget);\n this.config.tooltipText = tooltipText;\n }\n\n public async run() {\n // Nothing to subscribe to when push is unavailable, and the constructor\n // leaves the config unset in that case — so keep this before any render.\n if (!this.pw.isPushAvailable()) {\n return;\n }\n\n const isSubscribed = await this.pw.isSubscribed();\n if (!isSubscribed) {\n await this.render();\n }\n }\n\n /**\n * Apply styles to element\n * @param styles\n * @param {HTMLElement} element\n */\n private addStylesToElement(styles: TCSSStylesObject, element: HTMLElement) {\n Object.keys(styles).forEach((st: TStyleKeys) => {\n element.style[st] = styles[st];\n });\n }\n\n /**\n * Create container element\n * @returns {HTMLElement}\n */\n private createContainer(): HTMLElement {\n const container = document.createElement('div');\n container.id = WIDGET_CONTAINER_ID;\n container.className = 'pushwoosh-subscribe-widget';\n const position = Positioning.getBellPosition(this.config.position, this.config.indent);\n const styles = Object.assign({\n zIndex: this.config.zIndex,\n }, position);\n this.addStylesToElement(styles, container);\n return container;\n }\n\n /**\n * Create styles element\n * @returns {HTMLElement}\n */\n private createStyle(): HTMLElement {\n const styleNode = document.createElement('style');\n styleNode.innerHTML = mainCss;\n return styleNode;\n }\n\n /**\n * Create cell button element\n * @returns {HTMLElement}\n */\n private createBell(): HTMLElement {\n const { config } = this;\n let bell;\n if (config.buttonImage) {\n bell = document.createElement('img') as HTMLImageElement;\n bell.src = config.buttonImage;\n } else {\n bell = document.createElement('div');\n this.addStylesToElement({\n backgroundColor: config.bgColor,\n boxShadow: config.shadow,\n lineHeight: config.size,\n border: config.bellButtonBorder,\n }, bell);\n\n bell.innerHTML = bellSVG(config.bellColor, config.bellStrokeColor);\n }\n this.addStylesToElement({\n width: config.size,\n height: config.size,\n }, bell);\n bell.className = 'pushwoosh-subscribe-widget__bell-button';\n return bell;\n }\n\n /**\n * Create tooltip element\n * @returns {Promise<HTMLElement>}\n */\n private async createTooltip(): Promise<HTMLElement> {\n const tooltip = document.createElement('div');\n const [position, modification] = Positioning.getTooltipPosition(this.config.position, this.config.size);\n tooltip.className = `pushwoosh-subscribe-widget__tooltip pushwoosh-subscribe-widget__tooltip__${modification}`;\n this.addStylesToElement(position, tooltip);\n\n tooltip.appendChild(await this.createTooltipContent());\n return tooltip;\n }\n\n /**\n * Create tooltip content element\n * @returns {Promise<HTMLElement>}\n */\n private async createTooltipContent(): Promise<HTMLElement> {\n const tooltipContent = document.createElement('div');\n tooltipContent.innerText = await this.tooltipTextFactory();\n tooltipContent.className = 'pushwoosh-subscribe-widget__tooltip-content';\n return tooltipContent;\n }\n\n /**\n * Tooltip text content depending of the permissions\n * @returns {Promise<string>}\n */\n private async tooltipTextFactory(): Promise<string> {\n const permission = this.pw.driver?.getPermission();\n const { tooltipText } = this.config;\n const isManuallyUnsubscribed = await this.pw.data.getStatusManualUnsubscribed();\n\n switch (permission) {\n case PERMISSION_GRANTED:\n return isManuallyUnsubscribed ? tooltipText.needSubscribe : tooltipText.alreadySubscribed;\n case PERMISSION_PROMPT:\n return tooltipText.needSubscribe;\n case PERMISSION_DENIED:\n return tooltipText.blockSubscribe;\n default:\n return tooltipText.needSubscribe;\n }\n }\n\n /**\n * Create permission denied popover element\n * @returns {HTMLElement}\n */\n private createPopover(): HTMLElement {\n const popoverContentWrapper = document.createElement('div');\n const popover = document.createElement('div');\n const [position, modification] = Positioning.getPopoverPosition(this.config.position, this.config.size);\n popover.className = `pushwoosh-subscribe-widget__popover pushwoosh-subscribe-widget__popover__${modification}`;\n popoverContentWrapper.className = 'pushwoosh-subscribe-widget__popover-content-wrapper';\n\n this.style.innerHTML += Positioning.getPopoverArrowPosition(this.config.position, this.config.size);\n\n const styles = Object.assign({\n maxWidth: `calc(100vw - ${this.config.indent} - ${this.config.indent})`,\n }, position);\n this.addStylesToElement(styles, popover);\n\n popoverContentWrapper.appendChild(this.createPopoverContent());\n popover.appendChild(popoverContentWrapper);\n return popover;\n }\n\n private getBrowserName() {\n const platformChecker = this.pw.platformChecker;\n let browser;\n if (platformChecker.isOpera) {\n browser = 'opera';\n } else if (<TPlatformChrome>platformChecker.platform === 11 && navigator.userAgent.match(/Android/i)) {\n browser = 'mobileChrome';\n } else if (<TPlatformFirefox>platformChecker.platform === 12) {\n browser = 'firefox';\n } else if (<TPlatformSafari>platformChecker.platform === 10) {\n browser = 'safari';\n } else if (<TPlatformEdge>platformChecker.platform === 150) {\n browser = 'edge';\n } else {\n browser = 'chrome';\n }\n return browser;\n }\n\n /**\n * Create permission denied popover content element\n * @returns {HTMLElement}\n */\n private createPopoverContent(): HTMLElement {\n const { config } = this;\n const popoverContent = document.createElement('div');\n popoverContent.className = 'pushwoosh-subscribe-widget__popover-content';\n\n const browser = this.getBrowserName();\n\n const userImageSrc = config.contentImages && config.contentImages[browser];\n if (userImageSrc) {\n const image = document.createElement('img') as HTMLImageElement;\n image.src = userImageSrc;\n popoverContent.appendChild(image);\n } else {\n const standardImagesMap: Record<string, string> = {\n opera: 'opera',\n mobileChrome: 'mobile_chrome',\n firefox: 'FF',\n safari: 'safari',\n };\n const standardImage = standardImagesMap[browser] || 'chrome';\n [{\n src: this.getImageSrc(standardImage),\n width: 500,\n height: 130,\n }, {\n src: this.getImageSrc(`${standardImage}_unlock`),\n width: 500,\n height: 230,\n }].forEach((imageAttrs) => {\n const image = document.createElement('img');\n Object.assign(image, imageAttrs);\n popoverContent.appendChild(image);\n });\n }\n\n return popoverContent;\n }\n\n /**\n * Return source of help images depending of the browser\n * @returns {string}\n */\n getImageSrc(img: string): string {\n return `https://cdn.pushwoosh.com/webpush/img/${img}.jpg`;\n }\n\n private async render() {\n this.widget = this.createContainer();\n this.style = this.createStyle();\n const bell = this.createBell();\n this.tooltip = await this.createTooltip();\n this.popover = await this.createPopover();\n\n this.widget.appendChild(this.style);\n this.widget.appendChild(bell);\n this.widget.appendChild(this.tooltip);\n this.widget.appendChild(this.popover);\n\n document.body.appendChild(this.widget);\n\n this.pw.push(['onSubscribe', this.onSubscribeEvent]);\n this.pw.push(['onUnsubscribe', this.onUnsubscribeEvent]);\n this.pw.push(['onPermissionDenied', this.onPermissionDeniedEvent]);\n\n this.addEventListeners();\n }\n\n addEventListeners() {\n this.widget.addEventListener('click', this.clickBell);\n window.addEventListener('click', this.clickOutOfPopover);\n }\n\n /**\n * Toggle visibility of popover\n */\n toggleHelpPopover() {\n this.popover.classList.toggle('pushwoosh-subscribe-widget__popover__visible');\n }\n\n /**\n * Click bell button event callback\n * @returns {Promise<void>}\n */\n private async clickBell() {\n const permission = this.pw.driver?.getPermission();\n\n switch (permission) {\n case PERMISSION_GRANTED:\n await this.pw.subscribe();\n\n break;\n case PERMISSION_PROMPT:\n await this.pw.subscribe();\n\n break;\n case PERMISSION_DENIED:\n this.toggleHelpPopover();\n\n break;\n default:\n console.warn('Unknown browser notification permission');\n }\n }\n\n /**\n * On subscribe event callback\n * @returns {Promise<void>}\n */\n private async onSubscribeEvent() {\n const tooltipContent = this.tooltip.querySelector('div');\n\n if (tooltipContent === null) {\n return;\n }\n\n tooltipContent.innerText = this.config.tooltipText.successSubscribe;\n this.tooltip.classList.add('pushwoosh-subscribe-widget__tooltip__visible');\n\n setTimeout(async () => {\n this.tooltip.classList.remove('pushwoosh-subscribe-widget__tooltip__visible');\n tooltipContent.innerText = await this.tooltipTextFactory();\n\n this.widget.classList.add('pushwoosh-subscribe-widget__subscribed');\n }, 2000);\n }\n\n /**\n * On permission denied event\n * @returns {Promise<void>}\n */\n private async onPermissionDeniedEvent(): Promise<void> {\n this.addEventListeners();\n\n const tooltipContent = this.tooltip.querySelector('div');\n if (tooltipContent === null) return;\n tooltipContent.innerText = await this.tooltipTextFactory();\n }\n\n /**\n * Out of popover click event\n * @param {MessageEvent} ev\n */\n clickOutOfPopover(ev: MessageEvent) {\n const closeRule = this.popover.classList.contains('pushwoosh-subscribe-widget__popover__visible')\n && !(ev.target as any).classList.contains('pushwoosh-subscribe-widget__popover')\n && (ev.target as any).closest('.pushwoosh-subscribe-widget__popover') === null\n && !(ev.target as any).classList.contains('pushwoosh-subscribe-widget__bell-button')\n && (ev.target as any).closest('.pushwoosh-subscribe-widget__bell-button') === null;\n\n if (closeRule) this.popover.classList.remove('pushwoosh-subscribe-widget__popover__visible');\n }\n\n private async onUnsubscribeEvent() {\n const tooltipContent = this.tooltip.querySelector('div');\n\n if (tooltipContent === null) {\n return;\n }\n\n tooltipContent.innerText = await this.tooltipTextFactory();\n }\n}\n","export default (fillColor: string, strokeColor: string) => {\n return '<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\\n'\n + '<svg\\n'\n + ' xmlns:dc=\"http://purl.org/dc/elements/1.1/\"\\n'\n + ' xmlns:cc=\"http://creativecommons.org/ns#\"\\n'\n + ' xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\\n'\n + ' xmlns:svg=\"http://www.w3.org/2000/svg\"\\n'\n + ' xmlns=\"http://www.w3.org/2000/svg\"\\n'\n + ' xmlns:sodipodi=\"http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd\"\\n'\n + ' xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\"\\n'\n + ' version=\"1.1\"\\n'\n + ' id=\"Capa_1\"\\n'\n + ' x=\"0px\"\\n'\n + ' y=\"0px\"\\n'\n + ' viewBox=\"0 0 346.013 346.013\"\\n'\n + ' style=\"enable-background:new 0 0 346.013 346.013;width: 80%; height: auto; vertical-align: middle;\"\\n'\n + ' xml:space=\"preserve\"\\n'\n + ' inkscape:version=\"0.91 r13725\"\\n'\n + ' sodipodi:docname=\"alarm_white.svg\"><metadata\\n'\n + ' id=\"metadata51\"><rdf:RDF><cc:Work\\n'\n + ' rdf:about=\"\"><dc:format>image/svg+xml</dc:format><dc:type\\n'\n + ' rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs\\n'\n + ' id=\"defs49\" /><sodipodi:namedview\\n'\n + ' borderopacity=\"1\"\\n'\n + ' objecttolerance=\"10\"\\n'\n + ' gridtolerance=\"10\"\\n'\n + ' guidetolerance=\"10\"\\n'\n + ' inkscape:pageopacity=\"0\"\\n'\n + ' inkscape:pageshadow=\"2\"\\n'\n + ' inkscape:window-width=\"1618\"\\n'\n + ' inkscape:window-height=\"828\"\\n'\n + ' id=\"namedview47\"\\n'\n + ' showgrid=\"false\"\\n'\n + ' inkscape:zoom=\"0.6820553\"\\n'\n + ' inkscape:cx=\"173.0065\"\\n'\n + ' inkscape:cy=\"173.0065\"\\n'\n + ' inkscape:window-x=\"0\"\\n'\n + ' inkscape:window-y=\"0\"\\n'\n + ' inkscape:window-maximized=\"0\"\\n'\n + ' inkscape:current-layer=\"g3\" /><g\\n'\n + ' id=\"g3\"><path\\n'\n + ' d=\"m 256.76227,220.19006 c -1.77513,-2.69766 -3.45154,-5.24564 -3.98966,-7.46382 -0.042,-0.17861 -0.0911,-0.36128 -0.16237,-0.61436 -2.28354,-7.67647 0.69147,-24.43921 2.46886,-34.45124 0.26788,-1.50394 0.52274,-2.94197 0.75286,-4.29035 0.0232,-0.13675 0.044,-0.27211 0.0724,-0.48006 1.95582,-15.28051 2.58811,-37.91956 -5.51044,-58.99147 -5.6032,-14.57978 -14.45978,-25.82612 -26.3559,-33.48393 1.26598,-9.812938 -4.85967,-19.343691 -14.66682,-22.0511 -9.80715,-2.70741 -19.95724,2.33226 -23.90298,11.405413 -14.1382,0.467533 -27.51111,5.577097 -39.80114,15.219267 -17.76129,13.9298 -28.83431,33.68757 -34.99389,47.80757 l -0.0479,0.11335 c -0.0512,0.12175 -0.0998,0.24114 -0.13249,0.32962 -0.49733,1.28292 -1.01552,2.64514 -1.55689,4.07255 -3.61311,9.51043 -9.66004,25.42824 -15.611995,30.89342 -0.106524,0.10027 -0.208228,0.20187 -0.362362,0.35435 -1.636243,1.66563 -4.382941,2.99463 -7.288979,4.40101 -7.145531,3.45301 -22.013613,10.64166 -17.206389,31.67844 0.929154,4.07105 4.008437,7.29057 8.033861,8.40185 l 167.570804,46.2604 c 4.02253,1.11048 8.31521,-0.0729 11.2052,-3.08958 14.91617,-15.58874 5.84693,-29.38668 1.48625,-36.02133 z\"\\n'\n + ' id=\"path5\"\\n'\n + ' inkscape:connector-curvature=\"0\"\\n'\n + ' vector-effect=\"non-scaling-stroke\"\\n'\n + ` style=\"fill:${fillColor}; stroke: ${strokeColor}; stroke-width: 1; \" /><path\\n`\n + ' vector-effect=\"non-scaling-stroke\"\\n'\n + ' d=\"m 174.26737,259.72378 -38.76399,-10.70137 c -1.59243,-0.43962 -3.28183,-0.15596 -4.63548,0.7754 -2.53909,1.7494 -2.84182,4.93159 -3.02304,6.83188 l -0.0151,0.15247 c -1.22819,12.67106 6.79854,24.33046 19.08688,27.72284 12.51583,3.45518 25.8324,-2.91586 30.9681,-14.80385 l 0.0935,-0.19205 c 0.52305,-1.06418 1.74613,-3.55554 0.50882,-6.31116 -0.44302,-0.98439 -1.5794,-2.74529 -4.21964,-3.47416 z\"\\n'\n + ' id=\"path7\"\\n'\n + ' inkscape:connector-curvature=\"0\"\\n'\n + ` style=\"fill:${fillColor}; stroke: ${strokeColor}; stroke-width: 1;\" /></g><g\\n`\n + ' id=\"g17\" /><g\\n'\n + ' id=\"g19\" /><g\\n'\n + ' id=\"g21\" /><g\\n'\n + ' id=\"g23\" /><g\\n'\n + ' id=\"g25\" /><g\\n'\n + ' id=\"g27\" /><g\\n'\n + ' id=\"g29\" /><g\\n'\n + ' id=\"g31\" /><g\\n'\n + ' id=\"g33\" /><g\\n'\n + ' id=\"g35\" /><g\\n'\n + ' id=\"g37\" /><g\\n'\n + ' id=\"g39\" /><g\\n'\n + ' id=\"g41\" /><g\\n'\n + ' id=\"g43\" /><g\\n'\n + ' id=\"g45\" /></svg>';\n};\n"],"names":["root","factory","exports","module","define","amd","a","i","this","__webpack_require__","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","defineProperties","Symbol","toStringTag","value","__esModule","PERMISSION_GRANTED","PERMISSION_PROMPT","BELL_POSITION_BOTTOM_RIGHT","BELL_POSITION_BOTTOM_LEFT","BELL_POSITION_TOP_RIGHT","BELL_POSITION_TOP_LEFT","SUBSCRIBE_WIDGET_DEFAULT_CONFIG","position","bgColor","bellColor","bellStrokeColor","bellButtonBorder","shadow","size","indent","zIndex","tooltipText","successSubscribe","needSubscribe","blockSubscribe","alreadySubscribed","Positioning","getBellPosition","positionStyles","top","left","bottom","right","getTooltipPosition","bellPosition","bellSize","tooltipModification","increaseIndent","parseInt","getPopoverPosition","popoverModification","getPopoverArrowPosition","arrowAdditionalStyles","PWSubscriptionButtonWidget","constructor","pw","platformChecker","isAvailableNotifications","console","warn","clickBell","bind","onSubscribeEvent","onUnsubscribeEvent","onPermissionDeniedEvent","clickOutOfPopover","assign","initParams","subscribeWidget","config","run","isPushAvailable","isSubscribed","render","addStylesToElement","styles","element","keys","forEach","st","style","createContainer","container","document","createElement","id","className","createStyle","styleNode","innerHTML","createBell","bell","fillColor","strokeColor","buttonImage","src","backgroundColor","boxShadow","lineHeight","border","width","height","createTooltip","tooltip","modification","appendChild","createTooltipContent","tooltipContent","innerText","tooltipTextFactory","permission","driver","getPermission","isManuallyUnsubscribed","data","getStatusManualUnsubscribed","createPopover","popoverContentWrapper","popover","maxWidth","createPopoverContent","getBrowserName","browser","isOpera","platform","navigator","userAgent","match","popoverContent","userImageSrc","contentImages","image","standardImage","opera","mobileChrome","firefox","safari","getImageSrc","imageAttrs","img","widget","body","push","addEventListeners","addEventListener","window","toggleHelpPopover","classList","toggle","subscribe","querySelector","add","setTimeout","async","remove","ev","contains","target","closest"],"sourceRoot":""}
@@ -1,2 +1,2 @@
1
- !function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n=e();for(var o in n)("object"==typeof exports?exports:t)[o]=n[o]}}(this,()=>(()=>{"use strict";const t={d:(e,n)=>{for(var o in n)t.o(n,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:n[o]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}};let e={};t.r(e),t.d(e,{PWSubscriptionPromptWidget:()=>c});const n="not-set",o={headerText:"Subscribe to our news",headerTextColor:"#000000",subheaderText:"Don't miss out on the latest news and updates!",subheaderTextColor:"#000000",buttonAcceptText:"Agree",buttonAcceptTextColor:"#1A72E8",buttonAcceptRound:"4px",buttonAcceptBackgroundColor:"#FFFFFF",buttonAcceptBorderColor:"#E3E4E8",buttonCancelText:"Deny",buttonCancelTextColor:"#1A72E8",buttonCancelRound:"4px",buttonCancelBackgroundColor:"#FFFFFF",buttonCancelBorderColor:"#E3E4E8",cappingCount:3,cappingDelay:144e5,backgroundColor:"#FFFFFF"},i=t=>{const e=t?.subscription_prompt_widget&&t.subscription_prompt_widget.params,n={cappingCount:o.cappingCount,cappingDelay:o.cappingDelay,...e};return e?n:o},r=async(t,e,o=i(t))=>{if(void 0!==t?.web_sdk)return"the application is managed in the Control Panel, where the subscription widget replaces this prompt";const r=t?.subscription_prompt?.use_case;return"not-used"===r?"the application uses its own subscription prompt":r!==n||e.initParams.autoSubscribe?await(async(t,e)=>{const n=(new Date).getTime(),o=await e.data.getPromptDisplayCount(),i=await e.data.getPromptLastSeenTime(),r=t.cappingCount>o,s=n-i>t.cappingDelay;return r&&s})(o,e)?null:"the subscription prompt capping is exhausted":"the subscription prompt use case is not set and autoSubscribe is off"},s="pushwoosh-subscription-widget";class c{constructor(t){this.pw=t}async run(){const{pw:t}=this;if(!t.isPushAvailable())return;const e=await t.data.getFeatures(),o=i(e);if(await r(e,t,o))return;const s=e?.subscription_prompt?.use_case;("default"===s||s===n)&&(this.init(o),this.show(),t.moduleRegistry.subscriptionPrompt=this,await(async t=>{const e=await t.data.getPromptDisplayCount(),n=(new Date).getTime();await t.data.setPromptDisplayCount(e+1),await t.data.setPromptLastSeenTime(n)})(t))}init(t){if(!this.getRootElement()){const e=(t=>`\n <div id="${s}-root" class="${s}">\n <div class="${s}__body">\n <div class="${s}__header">\n ${t.headerText}\n </div>\n <div class="${s}__description">\n ${t.subheaderText}\n </div>\n <div class="${s}__controls">\n <button type="button" id="${s}-decline" class="${s}__control ${s}__control_decline">\n ${t.buttonCancelText}\n </button>\n <button type="button" id="${s}-accept" class="${s}__control ${s}__control_accept">\n ${t.buttonAcceptText}\n </button>\n </div>\n </div>\n </div>\n `)(t),n=(t=>{const e=document.createElement("style");return e.innerHTML=`\n .${s} * {\n box-sizing: border-box!important;\n }\n \n .${s} {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n margin: 0 auto;\n width: 320px;\n display: none;\n z-index: 2147483648;\n opacity: 0.99;\n }\n \n .${s}_show {\n display: block;\n }\n \n .${s}__body {\n width: 320px;\n background-color: ${t.backgroundColor?t.backgroundColor:"#FFFFFF"};\n box-shadow: 0 9px 15px rgba(0, 0, 0, 0.1), 0 0 6px rgba(0, 0, 0, 0.06);\n border-radius: 4px;\n padding: 20px 20px 12px;\n }\n \n .${s}__header {\n color: ${t.headerTextColor};\n font-size: 18px;\n font-weight: bold; \n }\n \n .${s}__description {\n color: ${t.subheaderTextColor};\n font-size: 14px;\n line-height: 1.5;\n margin-top: 14px;\n }\n \n .${s}__description:empty {\n display: none;\n }\n \n .${s}__controls {\n display: flex;\n flex-wrap: nowrap;\n justify-content: flex-end;\n margin: 20px 0 0;\n }\n \n .${s}__control {\n -webkit-appearance: none;\n border: 1px solid transparent;\n font-size: 12px;\n font-weight: bold;\n padding: 0 20px;\n height: 32px;\n cursor: pointer;\n }\n \n .${s}__control_decline {\n color: ${t.buttonCancelTextColor};\n background-color: ${t.buttonCancelBackgroundColor};\n border-radius: ${t.buttonCancelRound};\n border-color: ${t.buttonCancelBorderColor};\n }\n \n .${s}__control_accept {\n color: ${t.buttonAcceptTextColor};\n background-color: ${t.buttonAcceptBackgroundColor};\n border-radius: ${t.buttonAcceptRound};\n border-color: ${t.buttonAcceptBorderColor};\n margin: 0 0 0 12px;\n }\n `,e})(t);document.body.insertAdjacentHTML("beforeend",e),document.head.appendChild(n)}this.addEventListeners()}show(){const t=this.getRootElementWithCheckExist();this.pw.dispatchEvent("show-subscription-widget",{}),t.classList.add(`${s}_show`)}hide(){const t=this.getRootElementWithCheckExist();t.classList.contains(`${s}_show`)&&(this.pw.dispatchEvent("hide-subscription-widget",{}),t.classList.remove(`${s}_show`))}getRootElement(){return document.getElementById(`${s}-root`)}getRootElementWithCheckExist(){const t=this.getRootElement();if(!t)throw new Error(`Can't find element by id "${s}-root", please use method init first.`);return t}getDeclineButtonWithCheckExist(){const t=document.getElementById(`${s}-decline`);if(!t)throw new Error(`Can't find element by id "${s}-decline", please use method init first.`);return t}getAcceptButtonWithCheckExist(){const t=document.getElementById(`${s}-accept`);if(!t)throw new Error(`Can't find element by id "${s}-accept", please use method init first.`);return t}addEventListeners(){const t=this.getRootElementWithCheckExist(),e=this.getDeclineButtonWithCheckExist(),n=this.getAcceptButtonWithCheckExist();document.addEventListener("click",e=>{t.contains(e.target)||this.hide()}),e.addEventListener("click",()=>{this.hide()}),n.addEventListener("click",()=>{this.hide(),this.pw.subscribe()})}}return e})());
1
+ !function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n=e();for(var o in n)("object"==typeof exports?exports:t)[o]=n[o]}}(this,()=>(()=>{"use strict";const t={d:(e,n)=>{for(var o in n)t.o(n,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:n[o]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{Object.defineProperties(t,{[Symbol.toStringTag]:{value:"Module"},__esModule:{value:!0}})}};let e={};t.r(e),t.d(e,{PWSubscriptionPromptWidget:()=>c});const n="not-set",o={headerText:"Subscribe to our news",headerTextColor:"#000000",subheaderText:"Don't miss out on the latest news and updates!",subheaderTextColor:"#000000",buttonAcceptText:"Agree",buttonAcceptTextColor:"#1A72E8",buttonAcceptRound:"4px",buttonAcceptBackgroundColor:"#FFFFFF",buttonAcceptBorderColor:"#E3E4E8",buttonCancelText:"Deny",buttonCancelTextColor:"#1A72E8",buttonCancelRound:"4px",buttonCancelBackgroundColor:"#FFFFFF",buttonCancelBorderColor:"#E3E4E8",cappingCount:3,cappingDelay:144e5,backgroundColor:"#FFFFFF"},i=t=>{const e=t?.subscription_prompt_widget&&t.subscription_prompt_widget.params,n={cappingCount:o.cappingCount,cappingDelay:o.cappingDelay,...e};return e?n:o},r=async(t,e,o=i(t))=>{if(void 0!==t?.web_sdk)return"the application is managed in the Control Panel, where the subscription widget replaces this prompt";const r=t?.subscription_prompt?.use_case;return"not-used"===r?"the application uses its own subscription prompt":r!==n||e.initParams.autoSubscribe?await(async(t,e)=>{const n=(new Date).getTime(),o=await e.data.getPromptDisplayCount(),i=await e.data.getPromptLastSeenTime(),r=t.cappingCount>o,s=n-i>t.cappingDelay;return r&&s})(o,e)?null:"the subscription prompt capping is exhausted":"the subscription prompt use case is not set and autoSubscribe is off"},s="pushwoosh-subscription-widget";class c{constructor(t){this.pw=t}async run(){const{pw:t}=this;if(!t.isPushAvailable())return;const e=await t.data.getFeatures(),o=i(e);if(await r(e,t,o))return;const s=e?.subscription_prompt?.use_case;("default"===s||s===n)&&(this.init(o),this.show(),t.moduleRegistry.subscriptionPrompt=this,await(async t=>{const e=await t.data.getPromptDisplayCount(),n=(new Date).getTime();await t.data.setPromptDisplayCount(e+1),await t.data.setPromptLastSeenTime(n)})(t))}init(t){if(!this.getRootElement()){const e=(t=>`\n <div id="${s}-root" class="${s}">\n <div class="${s}__body">\n <div class="${s}__header">\n ${t.headerText}\n </div>\n <div class="${s}__description">\n ${t.subheaderText}\n </div>\n <div class="${s}__controls">\n <button type="button" id="${s}-decline" class="${s}__control ${s}__control_decline">\n ${t.buttonCancelText}\n </button>\n <button type="button" id="${s}-accept" class="${s}__control ${s}__control_accept">\n ${t.buttonAcceptText}\n </button>\n </div>\n </div>\n </div>\n `)(t),n=(t=>{const e=document.createElement("style");return e.innerHTML=`\n .${s} * {\n box-sizing: border-box!important;\n }\n \n .${s} {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n margin: 0 auto;\n width: 320px;\n display: none;\n z-index: 2147483648;\n opacity: 0.99;\n }\n \n .${s}_show {\n display: block;\n }\n \n .${s}__body {\n width: 320px;\n background-color: ${t.backgroundColor?t.backgroundColor:"#FFFFFF"};\n box-shadow: 0 9px 15px rgba(0, 0, 0, 0.1), 0 0 6px rgba(0, 0, 0, 0.06);\n border-radius: 4px;\n padding: 20px 20px 12px;\n }\n \n .${s}__header {\n color: ${t.headerTextColor};\n font-size: 18px;\n font-weight: bold; \n }\n \n .${s}__description {\n color: ${t.subheaderTextColor};\n font-size: 14px;\n line-height: 1.5;\n margin-top: 14px;\n }\n \n .${s}__description:empty {\n display: none;\n }\n \n .${s}__controls {\n display: flex;\n flex-wrap: nowrap;\n justify-content: flex-end;\n margin: 20px 0 0;\n }\n \n .${s}__control {\n -webkit-appearance: none;\n border: 1px solid transparent;\n font-size: 12px;\n font-weight: bold;\n padding: 0 20px;\n height: 32px;\n cursor: pointer;\n }\n \n .${s}__control_decline {\n color: ${t.buttonCancelTextColor};\n background-color: ${t.buttonCancelBackgroundColor};\n border-radius: ${t.buttonCancelRound};\n border-color: ${t.buttonCancelBorderColor};\n }\n \n .${s}__control_accept {\n color: ${t.buttonAcceptTextColor};\n background-color: ${t.buttonAcceptBackgroundColor};\n border-radius: ${t.buttonAcceptRound};\n border-color: ${t.buttonAcceptBorderColor};\n margin: 0 0 0 12px;\n }\n `,e})(t);document.body.insertAdjacentHTML("beforeend",e),document.head.appendChild(n)}this.addEventListeners()}show(){const t=this.getRootElementWithCheckExist();this.pw.dispatchEvent("show-subscription-widget",{}),t.classList.add(`${s}_show`)}hide(){const t=this.getRootElementWithCheckExist();t.classList.contains(`${s}_show`)&&(this.pw.dispatchEvent("hide-subscription-widget",{}),t.classList.remove(`${s}_show`))}getRootElement(){return document.getElementById(`${s}-root`)}getRootElementWithCheckExist(){const t=this.getRootElement();if(!t)throw new Error(`Can't find element by id "${s}-root", please use method init first.`);return t}getDeclineButtonWithCheckExist(){const t=document.getElementById(`${s}-decline`);if(!t)throw new Error(`Can't find element by id "${s}-decline", please use method init first.`);return t}getAcceptButtonWithCheckExist(){const t=document.getElementById(`${s}-accept`);if(!t)throw new Error(`Can't find element by id "${s}-accept", please use method init first.`);return t}addEventListeners(){const t=this.getRootElementWithCheckExist(),e=this.getDeclineButtonWithCheckExist(),n=this.getAcceptButtonWithCheckExist();document.addEventListener("click",e=>{t.contains(e.target)||this.hide()}),e.addEventListener("click",()=>{this.hide()}),n.addEventListener("click",()=>{this.hide(),this.pw.subscribe()})}}return e})());
2
2
  //# sourceMappingURL=widget-subscription-prompt.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"widget-subscription-prompt.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,GAA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4F,SAGPS,EAAcC,iBAAiB,QAAS,KACtCtG,KAAK4F,OACL5F,KAAK2C,GAAG8D,aAEZ","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/SubscriptionPrompt/constants.ts","webpack://web-push-notifications/./src/widgets/SubscriptionPrompt/helpers.ts","webpack://web-push-notifications/./src/widgets/SubscriptionPrompt/SubscriptionPromptWidget.constants.ts","webpack://web-push-notifications/./src/widgets/SubscriptionPrompt/SubscriptionPromptWidget.ts","webpack://web-push-notifications/./src/widgets/SubscriptionPrompt/SubscriptionPromptWidget.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};","export const SUBSCRIPTION_WIDGET_USE_CASE_NOT_SET = 'not-set';\nexport const SUBSCRIPTION_WIDGET_USE_CASE_DEFAULT = 'default';\nexport const SUBSCRIPTION_WIDGET_USE_CASE_NOT_USED = 'not-used';\n\nexport const SUBSCRIPTION_PROMPT_WIDGET_DEFAULT_CONFIG = {\n headerText: 'Subscribe to our news',\n headerTextColor: '#000000',\n subheaderText: 'Don\\'t miss out on the latest news and updates!',\n subheaderTextColor: '#000000',\n buttonAcceptText: 'Agree',\n buttonAcceptTextColor: '#1A72E8',\n buttonAcceptRound: '4px',\n buttonAcceptBackgroundColor: '#FFFFFF',\n buttonAcceptBorderColor: '#E3E4E8',\n buttonCancelText: 'Deny',\n buttonCancelTextColor: '#1A72E8',\n buttonCancelRound: '4px',\n buttonCancelBackgroundColor: '#FFFFFF',\n buttonCancelBorderColor: '#E3E4E8',\n cappingCount: 3,\n cappingDelay: 1000 * 60 * 60 * 4, // time in ms\n backgroundColor: '#FFFFFF',\n};\n","import {\n SUBSCRIPTION_PROMPT_WIDGET_DEFAULT_CONFIG,\n SUBSCRIPTION_WIDGET_USE_CASE_NOT_SET,\n SUBSCRIPTION_WIDGET_USE_CASE_NOT_USED,\n} from './constants';\nimport type { ISubscriptionPromptWidgetParams } from './SubscriptionPromptWidget.types';\nimport type { Pushwoosh } from '../../core/Pushwoosh';\n\nexport const getWidgetConfig = (features: any): ISubscriptionPromptWidgetParams => {\n // get config by features from get config method\n const currentConfig = features?.['subscription_prompt_widget'] && features['subscription_prompt_widget'].params;\n\n // merge current config with capping defaults\n const configWithDefaultCapping: ISubscriptionPromptWidgetParams = {\n cappingCount: SUBSCRIPTION_PROMPT_WIDGET_DEFAULT_CONFIG.cappingCount,\n cappingDelay: SUBSCRIPTION_PROMPT_WIDGET_DEFAULT_CONFIG.cappingDelay,\n ...currentConfig,\n };\n\n // if current config is not exist show with default values\n return currentConfig\n ? configWithDefaultCapping\n : SUBSCRIPTION_PROMPT_WIDGET_DEFAULT_CONFIG;\n};\n\nexport const checkCanShowByCapping = async (widgetConfig: ISubscriptionPromptWidgetParams, pw: Pushwoosh): Promise<boolean> => {\n const currentTime = new Date().getTime();\n const displayCount = await pw.data.getPromptDisplayCount();\n const lastSeenTime = await pw.data.getPromptLastSeenTime();\n\n // can show by max display count\n const canShowByCapping = widgetConfig.cappingCount > displayCount;\n\n // can show last seen time\n const canShowByLastTime = currentTime - lastSeenTime > widgetConfig.cappingDelay;\n\n return canShowByCapping && canShowByLastTime;\n};\n\n// Shared by the widget and by the entry point that decides whether to fetch\n// the widget bundle at all, so both answer the same question in one place.\nexport const getSubscriptionPromptSkipReason = async (\n features: any,\n pw: Pushwoosh,\n widgetConfig: ISubscriptionPromptWidgetParams = getWidgetConfig(features),\n): Promise<string | null> => {\n // The server sends `web_sdk` only to panel-managed applications, which configure the unified widget instead.\n if (features?.['web_sdk'] !== undefined) {\n return 'the application is managed in the Control Panel, where the subscription widget replaces this prompt';\n }\n\n const useCase = features?.['subscription_prompt']?.['use_case'];\n\n if (useCase === SUBSCRIPTION_WIDGET_USE_CASE_NOT_USED) {\n return 'the application uses its own subscription prompt';\n }\n\n if (useCase === SUBSCRIPTION_WIDGET_USE_CASE_NOT_SET && !pw.initParams.autoSubscribe) {\n return 'the subscription prompt use case is not set and autoSubscribe is off';\n }\n\n if (!await checkCanShowByCapping(widgetConfig, pw)) {\n return 'the subscription prompt capping is exhausted';\n }\n\n // Absent features (older backend, failed loadConfig) keep the previous\n // behaviour: the bundle is fetched and the widget decides for itself.\n return null;\n};\n\nexport const updateCappingParams = async (pw: Pushwoosh): Promise<void> => {\n const displayCount = await pw.data.getPromptDisplayCount();\n const currentTime = new Date().getTime();\n\n await pw.data.setPromptDisplayCount(displayCount + 1);\n await pw.data.setPromptLastSeenTime(currentTime);\n};\n","export const SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE = 'pushwoosh-subscription-widget';\n","import { SUBSCRIPTION_WIDGET_USE_CASE_DEFAULT, SUBSCRIPTION_WIDGET_USE_CASE_NOT_SET } from './constants';\nimport { getSubscriptionPromptSkipReason, getWidgetConfig, updateCappingParams } from './helpers';\nimport { SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE } from './SubscriptionPromptWidget.constants';\nimport { getHTML, getStyles } from './SubscriptionPromptWidget.helpers';\nimport { type ISubscriptionPromptWidgetParams } from './SubscriptionPromptWidget.types';\nimport { type Pushwoosh } from '../../core/Pushwoosh';\n\nexport class PWSubscriptionPromptWidget {\n private readonly pw: Pushwoosh;\n\n constructor(pw: Pushwoosh) {\n this.pw = pw;\n };\n\n public async run(): Promise<void> {\n const { pw } = this;\n\n // Nothing to ask for when push is unavailable (the npm export can be\n // constructed directly, without the entry point's own check).\n if (!pw.isPushAvailable()) {\n return;\n }\n\n const features = await pw.data.getFeatures();\n const widgetConfig = getWidgetConfig(features);\n\n // Same check the entry point runs before fetching this bundle; kept here\n // too, the bundle can also be loaded directly (npm export, own loader).\n if (await getSubscriptionPromptSkipReason(features, pw, widgetConfig)) {\n return;\n }\n\n const currentPromptUseCase = features?.['subscription_prompt']?.['use_case'];\n\n // show subscription prompt widget\n const isDefaultUseCase = currentPromptUseCase === SUBSCRIPTION_WIDGET_USE_CASE_DEFAULT;\n // `autoSubscribe: false` on this use case is already a skip reason above.\n const isNotSetUseCase = currentPromptUseCase === SUBSCRIPTION_WIDGET_USE_CASE_NOT_SET;\n\n // show subscription prompt widget\n if (isDefaultUseCase || isNotSetUseCase) {\n this.init(widgetConfig);\n this.show();\n pw.moduleRegistry.subscriptionPrompt = this;\n await updateCappingParams(pw);\n }\n }\n\n public init(params: ISubscriptionPromptWidgetParams): void {\n const rootElement = this.getRootElement();\n\n // if root element not exist\n // create widget\n if (!rootElement) {\n const html = getHTML(params);\n const styles = getStyles(params);\n\n // append popup to body\n document.body.insertAdjacentHTML('beforeend', html);\n\n // append styles to head\n document.head.appendChild(styles);\n }\n\n this.addEventListeners();\n }\n\n public show(): void {\n const rootElement = this.getRootElementWithCheckExist();\n this.pw.dispatchEvent('show-subscription-widget', {});\n\n rootElement.classList.add(`${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}_show`);\n }\n\n public hide(): void {\n const rootElement = this.getRootElementWithCheckExist();\n\n if (rootElement.classList.contains(`${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}_show`)) {\n this.pw.dispatchEvent('hide-subscription-widget', {});\n rootElement.classList.remove(`${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}_show`);\n }\n }\n\n private getRootElement(): HTMLElement | null {\n return document.getElementById(`${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}-root`);\n }\n\n private getRootElementWithCheckExist(): HTMLElement {\n const element = this.getRootElement();\n\n if (!element) {\n throw new Error(`Can't find element by id \"${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}-root\", please use method init first.`);\n }\n\n return element;\n }\n\n private getDeclineButtonWithCheckExist(): HTMLButtonElement {\n const element = document.getElementById(`${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}-decline`) as HTMLButtonElement;\n\n if (!element) {\n throw new Error(`Can't find element by id \"${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}-decline\", please use method init first.`);\n }\n\n return element;\n }\n\n private getAcceptButtonWithCheckExist(): HTMLButtonElement {\n const element = document.getElementById(`${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}-accept`) as HTMLButtonElement;\n\n if (!element) {\n throw new Error(`Can't find element by id \"${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}-accept\", please use method init first.`);\n }\n\n return element;\n }\n\n private addEventListeners(): void {\n const rootElement = this.getRootElementWithCheckExist();\n const declineElement = this.getDeclineButtonWithCheckExist();\n const acceptElement = this.getAcceptButtonWithCheckExist();\n\n document.addEventListener('click', (event) => {\n if (!rootElement.contains((event.target as HTMLElement))) {\n this.hide();\n }\n });\n\n declineElement.addEventListener('click', () => {\n this.hide();\n });\n\n acceptElement.addEventListener('click', () => {\n this.hide();\n this.pw.subscribe();\n });\n }\n}\n","import { SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE } from './SubscriptionPromptWidget.constants';\nimport { type ISubscriptionPromptWidgetParams } from './SubscriptionPromptWidget.types';\n\nexport const getHTML = (params: ISubscriptionPromptWidgetParams): string => {\n return `\n <div id=\"${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}-root\" class=\"${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}\">\n <div class=\"${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}__body\">\n <div class=\"${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}__header\">\n ${params.headerText}\n </div>\n <div class=\"${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}__description\">\n ${params.subheaderText}\n </div>\n <div class=\"${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}__controls\">\n <button type=\"button\" id=\"${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}-decline\" class=\"${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}__control ${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}__control_decline\">\n ${params.buttonCancelText}\n </button>\n <button type=\"button\" id=\"${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}-accept\" class=\"${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}__control ${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}__control_accept\">\n ${params.buttonAcceptText}\n </button>\n </div>\n </div>\n </div>\n `;\n};\n\nexport const getStyles = (params: ISubscriptionPromptWidgetParams) => {\n const styles = document.createElement('style');\n\n styles.innerHTML = `\n .${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE} * {\n box-sizing: border-box!important;\n }\n \n .${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE} {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n margin: 0 auto;\n width: 320px;\n display: none;\n z-index: 2147483648;\n opacity: 0.99;\n }\n \n .${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}_show {\n display: block;\n }\n \n .${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}__body {\n width: 320px;\n background-color: ${params.backgroundColor ? params.backgroundColor : '#FFFFFF'};\n box-shadow: 0 9px 15px rgba(0, 0, 0, 0.1), 0 0 6px rgba(0, 0, 0, 0.06);\n border-radius: 4px;\n padding: 20px 20px 12px;\n }\n \n .${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}__header {\n color: ${params.headerTextColor};\n font-size: 18px;\n font-weight: bold; \n }\n \n .${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}__description {\n color: ${params.subheaderTextColor};\n font-size: 14px;\n line-height: 1.5;\n margin-top: 14px;\n }\n \n .${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}__description:empty {\n display: none;\n }\n \n .${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}__controls {\n display: flex;\n flex-wrap: nowrap;\n justify-content: flex-end;\n margin: 20px 0 0;\n }\n \n .${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}__control {\n -webkit-appearance: none;\n border: 1px solid transparent;\n font-size: 12px;\n font-weight: bold;\n padding: 0 20px;\n height: 32px;\n cursor: pointer;\n }\n \n .${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}__control_decline {\n color: ${params.buttonCancelTextColor};\n background-color: ${params.buttonCancelBackgroundColor};\n border-radius: ${params.buttonCancelRound};\n border-color: ${params.buttonCancelBorderColor};\n }\n \n .${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}__control_accept {\n color: ${params.buttonAcceptTextColor};\n background-color: ${params.buttonAcceptBackgroundColor};\n border-radius: ${params.buttonAcceptRound};\n border-color: ${params.buttonAcceptBorderColor};\n margin: 0 0 0 12px;\n }\n `;\n\n return styles;\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","SUBSCRIPTION_WIDGET_USE_CASE_NOT_SET","SUBSCRIPTION_PROMPT_WIDGET_DEFAULT_CONFIG","headerText","headerTextColor","subheaderText","subheaderTextColor","buttonAcceptText","buttonAcceptTextColor","buttonAcceptRound","buttonAcceptBackgroundColor","buttonAcceptBorderColor","buttonCancelText","buttonCancelTextColor","buttonCancelRound","buttonCancelBackgroundColor","buttonCancelBorderColor","cappingCount","cappingDelay","backgroundColor","getWidgetConfig","features","currentConfig","params","configWithDefaultCapping","getSubscriptionPromptSkipReason","async","pw","widgetConfig","undefined","useCase","initParams","autoSubscribe","currentTime","Date","getTime","displayCount","data","getPromptDisplayCount","lastSeenTime","getPromptLastSeenTime","canShowByCapping","canShowByLastTime","checkCanShowByCapping","SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE","PWSubscriptionPromptWidget","constructor","run","isPushAvailable","getFeatures","currentPromptUseCase","init","show","moduleRegistry","subscriptionPrompt","setPromptDisplayCount","setPromptLastSeenTime","updateCappingParams","getRootElement","html","getHTML","styles","document","createElement","innerHTML","getStyles","body","insertAdjacentHTML","head","appendChild","addEventListeners","rootElement","getRootElementWithCheckExist","dispatchEvent","classList","add","hide","contains","remove","getElementById","element","Error","getDeclineButtonWithCheckExist","getAcceptButtonWithCheckExist","declineElement","acceptElement","addEventListener","event","target","subscribe"],"sourceRoot":""}
1
+ {"version":3,"file":"widget-subscription-prompt.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,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F,+BACzB1F,KAAK6C,GAAG8C,cAAc,2BAA4B,IAElDF,EAAYG,UAAUC,IAAI,GAAG/B,SAC/B,CAEO,IAAAgC,GACL,MAAML,EAAczF,KAAK0F,+BAErBD,EAAYG,UAAUG,SAAS,GAAGjC,YACpC9D,KAAK6C,GAAG8C,cAAc,2BAA4B,IAClDF,EAAYG,UAAUI,OAAO,GAAGlC,UAEpC,CAEQ,cAAAc,GACN,OAAOI,SAASiB,eAAe,GAAGnC,SACpC,CAEQ,4BAAA4B,GACN,MAAMQ,EAAUlG,KAAK4E,iBAErB,IAAKsB,EACH,MAAM,IAAIC,MAAM,6BAA6BrC,0CAG/C,OAAOoC,CACT,CAEQ,8BAAAE,GACN,MAAMF,EAAUlB,SAASiB,eAAe,GAAGnC,aAE3C,IAAKoC,EACH,MAAM,IAAIC,MAAM,6BAA6BrC,6CAG/C,OAAOoC,CACT,CAEQ,6BAAAG,GACN,MAAMH,EAAUlB,SAASiB,eAAe,GAAGnC,YAE3C,IAAKoC,EACH,MAAM,IAAIC,MAAM,6BAA6BrC,4CAG/C,OAAOoC,CACT,CAEQ,iBAAAV,GACN,MAAMC,EAAczF,KAAK0F,+BACnBY,EAAiBtG,KAAKoG,iCACtBG,EAAgBvG,KAAKqG,gCAE3BrB,SAASwB,iBAAiB,QAAUC,IAC7BhB,EAAYM,SAAUU,EAAMC,SAC/B1G,KAAK8F,SAITQ,EAAeE,iBAAiB,QAAS,KACvCxG,KAAK8F,SAGPS,EAAcC,iBAAiB,QAAS,KACtCxG,KAAK8F,OACL9F,KAAK6C,GAAG8D,aAEZ","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/SubscriptionPrompt/constants.ts","webpack://web-push-notifications/./src/widgets/SubscriptionPrompt/helpers.ts","webpack://web-push-notifications/./src/widgets/SubscriptionPrompt/SubscriptionPromptWidget.constants.ts","webpack://web-push-notifications/./src/widgets/SubscriptionPrompt/SubscriptionPromptWidget.ts","webpack://web-push-notifications/./src/widgets/SubscriptionPrompt/SubscriptionPromptWidget.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.defineProperties(exports, { [Symbol.toStringTag]: { value: 'Module' }, __esModule: { value: true } });\n};","export const SUBSCRIPTION_WIDGET_USE_CASE_NOT_SET = 'not-set';\nexport const SUBSCRIPTION_WIDGET_USE_CASE_DEFAULT = 'default';\nexport const SUBSCRIPTION_WIDGET_USE_CASE_NOT_USED = 'not-used';\n\nexport const SUBSCRIPTION_PROMPT_WIDGET_DEFAULT_CONFIG = {\n headerText: 'Subscribe to our news',\n headerTextColor: '#000000',\n subheaderText: 'Don\\'t miss out on the latest news and updates!',\n subheaderTextColor: '#000000',\n buttonAcceptText: 'Agree',\n buttonAcceptTextColor: '#1A72E8',\n buttonAcceptRound: '4px',\n buttonAcceptBackgroundColor: '#FFFFFF',\n buttonAcceptBorderColor: '#E3E4E8',\n buttonCancelText: 'Deny',\n buttonCancelTextColor: '#1A72E8',\n buttonCancelRound: '4px',\n buttonCancelBackgroundColor: '#FFFFFF',\n buttonCancelBorderColor: '#E3E4E8',\n cappingCount: 3,\n cappingDelay: 1000 * 60 * 60 * 4, // time in ms\n backgroundColor: '#FFFFFF',\n};\n","import {\n SUBSCRIPTION_PROMPT_WIDGET_DEFAULT_CONFIG,\n SUBSCRIPTION_WIDGET_USE_CASE_NOT_SET,\n SUBSCRIPTION_WIDGET_USE_CASE_NOT_USED,\n} from './constants';\nimport type { ISubscriptionPromptWidgetParams } from './SubscriptionPromptWidget.types';\nimport type { Pushwoosh } from '../../core/Pushwoosh';\n\nexport const getWidgetConfig = (features: any): ISubscriptionPromptWidgetParams => {\n // get config by features from get config method\n const currentConfig = features?.['subscription_prompt_widget'] && features['subscription_prompt_widget'].params;\n\n // merge current config with capping defaults\n const configWithDefaultCapping: ISubscriptionPromptWidgetParams = {\n cappingCount: SUBSCRIPTION_PROMPT_WIDGET_DEFAULT_CONFIG.cappingCount,\n cappingDelay: SUBSCRIPTION_PROMPT_WIDGET_DEFAULT_CONFIG.cappingDelay,\n ...currentConfig,\n };\n\n // if current config is not exist show with default values\n return currentConfig\n ? configWithDefaultCapping\n : SUBSCRIPTION_PROMPT_WIDGET_DEFAULT_CONFIG;\n};\n\nexport const checkCanShowByCapping = async (widgetConfig: ISubscriptionPromptWidgetParams, pw: Pushwoosh): Promise<boolean> => {\n const currentTime = new Date().getTime();\n const displayCount = await pw.data.getPromptDisplayCount();\n const lastSeenTime = await pw.data.getPromptLastSeenTime();\n\n // can show by max display count\n const canShowByCapping = widgetConfig.cappingCount > displayCount;\n\n // can show last seen time\n const canShowByLastTime = currentTime - lastSeenTime > widgetConfig.cappingDelay;\n\n return canShowByCapping && canShowByLastTime;\n};\n\n// Shared by the widget and by the entry point that decides whether to fetch\n// the widget bundle at all, so both answer the same question in one place.\nexport const getSubscriptionPromptSkipReason = async (\n features: any,\n pw: Pushwoosh,\n widgetConfig: ISubscriptionPromptWidgetParams = getWidgetConfig(features),\n): Promise<string | null> => {\n // The server sends `web_sdk` only to panel-managed applications, which configure the unified widget instead.\n if (features?.['web_sdk'] !== undefined) {\n return 'the application is managed in the Control Panel, where the subscription widget replaces this prompt';\n }\n\n const useCase = features?.['subscription_prompt']?.['use_case'];\n\n if (useCase === SUBSCRIPTION_WIDGET_USE_CASE_NOT_USED) {\n return 'the application uses its own subscription prompt';\n }\n\n if (useCase === SUBSCRIPTION_WIDGET_USE_CASE_NOT_SET && !pw.initParams.autoSubscribe) {\n return 'the subscription prompt use case is not set and autoSubscribe is off';\n }\n\n if (!await checkCanShowByCapping(widgetConfig, pw)) {\n return 'the subscription prompt capping is exhausted';\n }\n\n // Absent features (older backend, failed loadConfig) keep the previous\n // behaviour: the bundle is fetched and the widget decides for itself.\n return null;\n};\n\nexport const updateCappingParams = async (pw: Pushwoosh): Promise<void> => {\n const displayCount = await pw.data.getPromptDisplayCount();\n const currentTime = new Date().getTime();\n\n await pw.data.setPromptDisplayCount(displayCount + 1);\n await pw.data.setPromptLastSeenTime(currentTime);\n};\n","export const SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE = 'pushwoosh-subscription-widget';\n","import { SUBSCRIPTION_WIDGET_USE_CASE_DEFAULT, SUBSCRIPTION_WIDGET_USE_CASE_NOT_SET } from './constants';\nimport { getSubscriptionPromptSkipReason, getWidgetConfig, updateCappingParams } from './helpers';\nimport { SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE } from './SubscriptionPromptWidget.constants';\nimport { getHTML, getStyles } from './SubscriptionPromptWidget.helpers';\nimport { type ISubscriptionPromptWidgetParams } from './SubscriptionPromptWidget.types';\nimport { type Pushwoosh } from '../../core/Pushwoosh';\n\nexport class PWSubscriptionPromptWidget {\n private readonly pw: Pushwoosh;\n\n constructor(pw: Pushwoosh) {\n this.pw = pw;\n };\n\n public async run(): Promise<void> {\n const { pw } = this;\n\n // Nothing to ask for when push is unavailable (the npm export can be\n // constructed directly, without the entry point's own check).\n if (!pw.isPushAvailable()) {\n return;\n }\n\n const features = await pw.data.getFeatures();\n const widgetConfig = getWidgetConfig(features);\n\n // Same check the entry point runs before fetching this bundle; kept here\n // too, the bundle can also be loaded directly (npm export, own loader).\n if (await getSubscriptionPromptSkipReason(features, pw, widgetConfig)) {\n return;\n }\n\n const currentPromptUseCase = features?.['subscription_prompt']?.['use_case'];\n\n // show subscription prompt widget\n const isDefaultUseCase = currentPromptUseCase === SUBSCRIPTION_WIDGET_USE_CASE_DEFAULT;\n // `autoSubscribe: false` on this use case is already a skip reason above.\n const isNotSetUseCase = currentPromptUseCase === SUBSCRIPTION_WIDGET_USE_CASE_NOT_SET;\n\n // show subscription prompt widget\n if (isDefaultUseCase || isNotSetUseCase) {\n this.init(widgetConfig);\n this.show();\n pw.moduleRegistry.subscriptionPrompt = this;\n await updateCappingParams(pw);\n }\n }\n\n public init(params: ISubscriptionPromptWidgetParams): void {\n const rootElement = this.getRootElement();\n\n // if root element not exist\n // create widget\n if (!rootElement) {\n const html = getHTML(params);\n const styles = getStyles(params);\n\n // append popup to body\n document.body.insertAdjacentHTML('beforeend', html);\n\n // append styles to head\n document.head.appendChild(styles);\n }\n\n this.addEventListeners();\n }\n\n public show(): void {\n const rootElement = this.getRootElementWithCheckExist();\n this.pw.dispatchEvent('show-subscription-widget', {});\n\n rootElement.classList.add(`${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}_show`);\n }\n\n public hide(): void {\n const rootElement = this.getRootElementWithCheckExist();\n\n if (rootElement.classList.contains(`${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}_show`)) {\n this.pw.dispatchEvent('hide-subscription-widget', {});\n rootElement.classList.remove(`${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}_show`);\n }\n }\n\n private getRootElement(): HTMLElement | null {\n return document.getElementById(`${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}-root`);\n }\n\n private getRootElementWithCheckExist(): HTMLElement {\n const element = this.getRootElement();\n\n if (!element) {\n throw new Error(`Can't find element by id \"${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}-root\", please use method init first.`);\n }\n\n return element;\n }\n\n private getDeclineButtonWithCheckExist(): HTMLButtonElement {\n const element = document.getElementById(`${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}-decline`) as HTMLButtonElement;\n\n if (!element) {\n throw new Error(`Can't find element by id \"${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}-decline\", please use method init first.`);\n }\n\n return element;\n }\n\n private getAcceptButtonWithCheckExist(): HTMLButtonElement {\n const element = document.getElementById(`${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}-accept`) as HTMLButtonElement;\n\n if (!element) {\n throw new Error(`Can't find element by id \"${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}-accept\", please use method init first.`);\n }\n\n return element;\n }\n\n private addEventListeners(): void {\n const rootElement = this.getRootElementWithCheckExist();\n const declineElement = this.getDeclineButtonWithCheckExist();\n const acceptElement = this.getAcceptButtonWithCheckExist();\n\n document.addEventListener('click', (event) => {\n if (!rootElement.contains((event.target as HTMLElement))) {\n this.hide();\n }\n });\n\n declineElement.addEventListener('click', () => {\n this.hide();\n });\n\n acceptElement.addEventListener('click', () => {\n this.hide();\n this.pw.subscribe();\n });\n }\n}\n","import { SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE } from './SubscriptionPromptWidget.constants';\nimport { type ISubscriptionPromptWidgetParams } from './SubscriptionPromptWidget.types';\n\nexport const getHTML = (params: ISubscriptionPromptWidgetParams): string => {\n return `\n <div id=\"${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}-root\" class=\"${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}\">\n <div class=\"${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}__body\">\n <div class=\"${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}__header\">\n ${params.headerText}\n </div>\n <div class=\"${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}__description\">\n ${params.subheaderText}\n </div>\n <div class=\"${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}__controls\">\n <button type=\"button\" id=\"${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}-decline\" class=\"${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}__control ${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}__control_decline\">\n ${params.buttonCancelText}\n </button>\n <button type=\"button\" id=\"${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}-accept\" class=\"${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}__control ${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}__control_accept\">\n ${params.buttonAcceptText}\n </button>\n </div>\n </div>\n </div>\n `;\n};\n\nexport const getStyles = (params: ISubscriptionPromptWidgetParams) => {\n const styles = document.createElement('style');\n\n styles.innerHTML = `\n .${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE} * {\n box-sizing: border-box!important;\n }\n \n .${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE} {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n margin: 0 auto;\n width: 320px;\n display: none;\n z-index: 2147483648;\n opacity: 0.99;\n }\n \n .${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}_show {\n display: block;\n }\n \n .${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}__body {\n width: 320px;\n background-color: ${params.backgroundColor ? params.backgroundColor : '#FFFFFF'};\n box-shadow: 0 9px 15px rgba(0, 0, 0, 0.1), 0 0 6px rgba(0, 0, 0, 0.06);\n border-radius: 4px;\n padding: 20px 20px 12px;\n }\n \n .${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}__header {\n color: ${params.headerTextColor};\n font-size: 18px;\n font-weight: bold; \n }\n \n .${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}__description {\n color: ${params.subheaderTextColor};\n font-size: 14px;\n line-height: 1.5;\n margin-top: 14px;\n }\n \n .${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}__description:empty {\n display: none;\n }\n \n .${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}__controls {\n display: flex;\n flex-wrap: nowrap;\n justify-content: flex-end;\n margin: 20px 0 0;\n }\n \n .${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}__control {\n -webkit-appearance: none;\n border: 1px solid transparent;\n font-size: 12px;\n font-weight: bold;\n padding: 0 20px;\n height: 32px;\n cursor: pointer;\n }\n \n .${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}__control_decline {\n color: ${params.buttonCancelTextColor};\n background-color: ${params.buttonCancelBackgroundColor};\n border-radius: ${params.buttonCancelRound};\n border-color: ${params.buttonCancelBorderColor};\n }\n \n .${SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE}__control_accept {\n color: ${params.buttonAcceptTextColor};\n background-color: ${params.buttonAcceptBackgroundColor};\n border-radius: ${params.buttonAcceptRound};\n border-color: ${params.buttonAcceptBorderColor};\n margin: 0 0 0 12px;\n }\n `;\n\n return styles;\n};\n"],"names":["root","factory","exports","module","define","amd","a","i","this","__webpack_require__","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","defineProperties","Symbol","toStringTag","value","__esModule","SUBSCRIPTION_WIDGET_USE_CASE_NOT_SET","SUBSCRIPTION_PROMPT_WIDGET_DEFAULT_CONFIG","headerText","headerTextColor","subheaderText","subheaderTextColor","buttonAcceptText","buttonAcceptTextColor","buttonAcceptRound","buttonAcceptBackgroundColor","buttonAcceptBorderColor","buttonCancelText","buttonCancelTextColor","buttonCancelRound","buttonCancelBackgroundColor","buttonCancelBorderColor","cappingCount","cappingDelay","backgroundColor","getWidgetConfig","features","currentConfig","params","configWithDefaultCapping","getSubscriptionPromptSkipReason","async","pw","widgetConfig","undefined","useCase","initParams","autoSubscribe","currentTime","Date","getTime","displayCount","data","getPromptDisplayCount","lastSeenTime","getPromptLastSeenTime","canShowByCapping","canShowByLastTime","checkCanShowByCapping","SUBSCRIPTION_PROMPT_WIDGET_NAMESPACE","PWSubscriptionPromptWidget","constructor","run","isPushAvailable","getFeatures","currentPromptUseCase","init","show","moduleRegistry","subscriptionPrompt","setPromptDisplayCount","setPromptLastSeenTime","updateCappingParams","getRootElement","html","getHTML","styles","document","createElement","innerHTML","getStyles","body","insertAdjacentHTML","head","appendChild","addEventListeners","rootElement","getRootElementWithCheckExist","dispatchEvent","classList","add","hide","contains","remove","getElementById","element","Error","getDeclineButtonWithCheckExist","getAcceptButtonWithCheckExist","declineElement","acceptElement","addEventListener","event","target","subscribe"],"sourceRoot":""}
@@ -1,2 +1,2 @@
1
- !function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("preact"),require("preact/compat"),require("preact/jsx-runtime"));else if("function"==typeof define&&define.amd)define(["preact","preact/compat","preact/jsx-runtime"],e);else{var n="object"==typeof exports?e(require("preact"),require("preact/compat"),require("preact/jsx-runtime")):e(t.preact,t.preactCompat,t.jsxRuntime);for(var o in n)("object"==typeof exports?exports:t)[o]=n[o]}}(this,(t,e,n)=>(()=>{"use strict";var o={524(e){e.exports=t},873(t){t.exports=e},247(t){t.exports=n}};const i={};function r(t){const e=i[t];if(void 0!==e)return e.exports;const n=i[t]={exports:{}};return o[t](n,n.exports,r),n.exports}r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};let s={};r.r(s),r.d(s,{PWSubscriptionWidget:()=>St});const a=/^(https?:|mailto:|tel:)/i,c="#101828",l="#667085",d="#FFFFFF",u={background:"#FFFFFF",accent:"#2970FF",text:c,textSecondary:l,textInverse:"#FFFFFF"};function h(t,e){return{display:"block",boxSizing:"border-box",width:"100%",padding:"10px 25px",borderRadius:6,fontSize:14,fontWeight:600,fontFamily:"inherit",lineHeight:1.5,textAlign:"center",textDecoration:"none",cursor:"pointer",..."secondary"===t?{backgroundColor:e.surface,color:e.accent,border:`1px solid ${e.accent}`}:{backgroundColor:e.accent,color:e.onAccent,border:"none"}}}const p={card:["top","bottom","top-left","top-right","bottom-left","bottom-right"],bar:["top","bottom"],modal:["center"]},f=Object.keys(p),b=["bottom-right","bottom-left","top-right","top-left"],m=["auto","launcher","manual"],g={delay:[0,3600],cappingCount:[0,100],cappingInterval:[0,8760],borderRadius:[0,32],offset:[0,100],launcherSize:[16,200],zIndex:[0,2147483647]},y={enable:!1,prompt:{enabled:!1,layout:"card",position:"top",borderRadius:12,overlay:!1},launcher:{enabled:!1,position:"bottom-right",offset:20,width:48,height:48},display:{trigger:"auto",delay:5,cappingCount:3,cappingInterval:4},texts:{title:"Stay in the loop",message:"Allow notifications to get our news and special offers first.",acceptText:"Allow",declineText:"Not now",closeText:"Got it",blockedTitle:"Notifications are blocked",blockedMessage:"To get our notifications, allow them for this site in your browser settings.",launcherLabel:"Subscribe to notifications",launcherBlockedLabel:"Notifications are blocked"},colors:u,fontFamily:'Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',zIndex:2147483e3},x=/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;function w(t){const e=x.exec(t.trim())?.[1];if(!e)return null;const n=3===e.length?e.split("").map(t=>t+t).join(""):e;return[0,2,4].map(t=>parseInt(n.slice(t,t+2),16))}function v([t,e,n]){return`#${[t,e,n].map(t=>Math.max(0,Math.min(255,Math.round(t))).toString(16).padStart(2,"0")).join("")}`}function k(t,e,n){let o=n;return o<0&&(o+=1),o>1&&(o-=1),o<1/6?t+6*(e-t)*o:o<.5?e:o<2/3?t+(e-t)*(2/3-o)*6:t}function M(t){return t>.5?.07+.86*(1-t):t}function S(t){return t<.5?.93-t*((.93-.5)/.5):t}function j(t,e){const n=w(t);if(!n)return t;const[o,i,r]=function([t,e,n]){const[o,i,r]=[t/255,e/255,n/255],s=Math.max(o,i,r),a=Math.min(o,i,r),c=(s+a)/2;if(s===a)return[0,0,c];const l=s-a;let d;return d=s===o?(i-r)/l+(i<r?6:0):s===i?(r-o)/l+2:(o-i)/l+4,[d/6,c>.5?l/(2-s-a):l/(s+a),c]}(n);return v(function([t,e,n]){if(0===e){const t=255*n;return[t,t,t]}const o=n<.5?n*(1+e):n+e-n*e,i=2*n-o;return[255*k(i,o,t+1/3),255*k(i,o,t),255*k(i,o,t-1/3)]}([o,i,"fold"===e?M(r):S(r)]))}function I(t,e,n){const o=w(t),i=w(e);return o&&i?v(o.map((t,e)=>t+(i[e]-t)*n)):t}function C(t){const e=w(t);if(!e)return!1;const[n,o,i]=e;return(.299*n+.587*o+.114*i)/255>.6}function F(t){return{background:j(t.background,"fold"),accent:t.accent,text:j(t.text,"lift"),textSecondary:j(t.textSecondary,"lift"),textInverse:t.textInverse}}function z(t,e){return"light"===e?{surface:u.background,surfaceText:c,border:"#D0D5DD",onAccent:d,error:"#D92D20",chromeIcon:l}:{surface:I(t.background,t.text,.08),surfaceText:t.text,border:I(t.background,t.text,.24),onAccent:C(t.accent)?c:d,error:"#FDA29B",chromeIcon:t.textSecondary}}function A(t){return!0===t.dark?.enabled}function P(t,e="light"){return"dark"===e&&A(t)?"dark":"light"}function E(t,e="light"){const n=P(t,e),o="dark"===n?(i=t.colors,r=t.dark,{...F(i),...r?.colors??{}}):t.colors;var i,r;return{...o,scheme:n,...z(o,n)}}function T(t){const e=(t||"").trim();if(e)return e.startsWith("#")||e.startsWith("/")||e.startsWith("?")||a.test(e)?e:void 0}new Set(["STRONG","B","EM","I","U","BR","A"]);function D(t){return"string"==typeof t&&t?t:void 0}function H(t){const e="object"==typeof t.colors&&null!==t.colors?t.colors:{};return{background:D(e.background)??D(t.background)??u.background,accent:D(e.accent)??D(t.accent)??u.accent,text:D(e.text)??u.text,textSecondary:D(e.textSecondary)??u.textSecondary,textInverse:D(e.textInverse)??u.textInverse}}function L(t,e){const n=t.dark;if("object"!=typeof n||null===n)return;const o=n,i="object"==typeof o.colors&&null!==o.colors?o.colors:{},r=F(e),s=function(t){if("object"!=typeof t||null===t)return;const e=t,n=D(e.color);if(!n)return;return{color:n,opacity:"number"==typeof e.opacity&&Number.isFinite(e.opacity)?Math.max(0,Math.min(1,e.opacity)):1}}(o.overlay);return{enabled:!0===o.enabled,colors:{background:D(i.background)??r.background,accent:D(i.accent)??r.accent,text:D(i.text)??r.text,textSecondary:D(i.textSecondary)??r.textSecondary,textInverse:D(i.textInverse)??r.textInverse},...s?{overlay:s}:{},...D(o.boxShadow)?{boxShadow:o.boxShadow}:{}}}function O(t){return"object"!=typeof t||null===t||Array.isArray(t)?{}:t}function R(t,e,n){return e.includes(t)?t:n}function W(t,[e,n],o){return"number"==typeof t&&Number.isFinite(t)?Math.max(e,Math.min(n,Math.round(t))):o}function q(t,e){if("string"!=typeof t)return e;const n=t.trim();return n?n.slice(0,300):e}function B(t){const e=T("string"==typeof t?t:void 0);return e&&/^(https?:\/\/|\/)/i.test(e)?e:void 0}function U(t,e){const n="string"==typeof e?e.trim().slice(0,64):"";return n?{[t]:n}:{}}function V(t){const e=y.texts,n=Object.keys(e);return Object.fromEntries(n.map(n=>[n,q(t[n],e[n])]))}function _(t){return"default"===t||"denied"===t}function N(t){return"denied"===t?"blocked":"ask"}function $(t,e){return t.launcher.enabled&&_(e)}var G=r(247),K=r(524),X=r(873);const J="(prefers-color-scheme: dark)";function Q(){return"undefined"!=typeof window&&"function"==typeof window.matchMedia&&window.matchMedia(J).matches}const Y={bell:"M6 10a6 6 0 0 1 12 0c0 4 1.5 5.5 2 6H4c.5-.5 2-2 2-6M10 20a2 2 0 0 0 4 0",gift:"M3 11h18v9a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1zM2.5 7h19v4h-19zM12 7v14M12 7c-1 0-3-.2-3.5-1a2 2 0 0 1 3.5-1 2 2 0 0 1 3.5 1c-.5.8-2.5 1-3.5 1z",cart:"M2 4h2.2l2.4 11.2A2 2 0 0 0 8.6 17H19M6 7h15l-2.2 7.5H8M10.5 20a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0M19.5 20a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0",chart:"M3 21h18M7 21V11M12 21V6M17 21v-8",lock:"M5 11h14v10H5zM8 11V8a4 4 0 0 1 8 0v3",calendar:"M4 6h16v15H4zM4 10h16M9 3v4M15 3v4",check:"M4 13l5 5L20 6",star:"M12 3l2.9 5.9 6.5.9-4.7 4.6 1.1 6.5-5.8-3.1-5.8 3.1 1.1-6.5L2.6 9.8l6.5-.9z",clock:"M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0M12 7v5l4 2",tag:"M20.6 13.4l-7.2 7.2a2 2 0 0 1-2.8 0l-7-7A2 2 0 0 1 3 12.2V5a2 2 0 0 1 2-2h7.2a2 2 0 0 1 1.4.6l7 7a2 2 0 0 1 0 2.8zM9 8a1 1 0 1 1-2 0 1 1 0 0 1 2 0",mail:"M3 6h18v12H3zM3 7l9 6 9-6",phone:"M7 2h10a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1M10 19h4",download:"M12 3v12M7 11l5 5 5-5M4 20h16",play:"M8 5l12 7-12 7z",shield:"M12 3l8 3v6c0 5-3.4 8.6-8 10-4.6-1.4-8-5-8-10V6z",sparkle:"M12 3l1.8 5.2L19 10l-5.2 1.8L12 17l-1.8-5.2L5 10l5.2-1.8zM18 15l.9 2.1 2.1.9-2.1.9-.9 2.1-.9-2.1L15 18l2.1-.9z",percent:"M19 5L5 19M8.5 8.5a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0M20.5 15.5a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0",truck:"M2 7h12v10H2zM14 10h4l3 3v4h-7M8.5 19a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0M20 19a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0",ticket:"M4 7h16v4a2 2 0 0 0 0 4v3H4v-3a2 2 0 0 0 0-4zM14 7v12",user:"M20 21a8 8 0 0 0-16 0M16 7a4 4 0 1 1-8 0 4 4 0 0 1 8 0"},Z=(Object.keys(Y),"0 12px 32px rgba(16, 24, 40, 0.18)");function tt(t,e){const[n,o]=t.split("-");return{[n]:e,[o]:e}}function et(t,e){return e?(t?"pw-subw-drop":"pw-subw-rise")+" 0.3s ease-out backwards":void 0}function nt(t,e,n){const{layout:o,position:i}=t.prompt,r={position:e,zIndex:t.zIndex,boxSizing:"border-box",pointerEvents:"auto"};if("bar"===o)return{...r,left:0,right:0,[i]:0,animation:et("top"===i,n)};if("modal"===o)return{...r,top:"50%",left:"50%",width:"min(420px, calc(100% - 32px))",transform:"translate(-50%, -50%)",animation:n?"pw-subw-fade 0.25s ease-out backwards":void 0};const s="min(360px, calc(100% - 32px))",a=et(i.startsWith("top"),n);return"top"===i||"bottom"===i?{...r,[i]:16,left:"50%",width:s,transform:"translateX(-50%)",animation:a}:{...r,...tt(i,16),width:s,animation:a}}function ot({label:t,primary:e,colors:n,disabled:o,onClick:i}){return(0,G.jsx)("button",{type:"button",disabled:o,onClick:i,style:{...h(e?"primary":"secondary",n),display:"inline-block",width:"auto",padding:"8px 18px",whiteSpace:"nowrap",opacity:o?.6:1,cursor:o?"default":"pointer"},children:t})}function it({config:t,variant:e,colors:n,busy:o,onAccept:i,onDecline:r}){const{prompt:s,texts:a}=t,c="bar"===s.layout,l="blocked"===e;return(0,G.jsxs)("div",{role:"dialog","aria-label":l?a.blockedTitle:a.title,style:{display:"flex",flexDirection:c?"row":"column",alignItems:c?"center":"stretch",flexWrap:c?"wrap":"nowrap",gap:16,padding:c?"12px 20px":20,boxSizing:"border-box",width:"100%",borderRadius:c?0:s.borderRadius,boxShadow:Z,backgroundColor:n.background,color:n.text,fontFamily:t.fontFamily,colorScheme:n.scheme},children:[(0,G.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:12,flex:c?"1 1 240px":void 0},children:[s.iconUrl&&(0,G.jsx)("img",{src:s.iconUrl,alt:"",width:48,height:48,style:{flex:"none",borderRadius:8,objectFit:"cover"}}),(0,G.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4,minWidth:0},children:[(0,G.jsx)("div",{style:{fontSize:16,fontWeight:600,lineHeight:1.4},children:l?a.blockedTitle:a.title}),(0,G.jsx)("div",{style:{fontSize:14,lineHeight:1.5,color:n.textSecondary},children:l?a.blockedMessage:a.message})]})]}),(0,G.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,flex:"none"},children:l?(0,G.jsx)(ot,{label:a.closeText,primary:!0,colors:n,onClick:r}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(ot,{label:a.declineText,primary:!1,colors:n,onClick:r}),(0,G.jsx)(ot,{label:a.acceptText,primary:!0,colors:n,disabled:o,onClick:i})]})})]})}function rt({config:t,blocked:e,colors:n,onClick:o}){const{width:i,height:r,imageUrl:s}=t.launcher,a=e?t.texts.launcherBlockedLabel:t.texts.launcherLabel,c=Math.round(Math.min(i,r)/2),l={display:"flex",alignItems:"center",justifyContent:"center",width:i,height:r,padding:0,border:"none",cursor:"pointer",opacity:e?.7:1};return s?(0,G.jsx)("button",{type:"button","aria-label":a,title:a,onClick:o,style:{...l,background:"none"},children:(0,G.jsx)("img",{src:s,alt:"",width:i,height:r,style:{display:"block",objectFit:"contain"}})}):(0,G.jsx)("button",{type:"button","aria-label":a,title:a,onClick:o,style:{...l,borderRadius:"50%",backgroundColor:t.launcher.background??n.accent,color:t.launcher.iconColor??n.onAccent,boxShadow:Z},children:(0,G.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,G.jsx)("path",{d:Y.bell}),e&&(0,G.jsx)("path",{d:"M4 4l16 16"})]})})}function st({config:t,permission:e,open:n,mode:o="live",colorScheme:i="auto",busy:r,onAccept:s,onDecline:a,onLauncherClick:c}){const l=E(t,function(t,e){const[n,o]=(0,X.useState)(()=>"auto"===t&&e&&Q()),i=[t,e],[r,s]=(0,X.useState)(null);return(null===r||i.some((t,e)=>t!==r[e]))&&(s(i),"auto"===t&&e&&o(Q())),(0,X.useEffect)(()=>{if("auto"!==t||!e||"undefined"==typeof window||"function"!=typeof window.matchMedia)return;const n=window.matchMedia(J),i=t=>o(t.matches);return n.addEventListener("change",i),()=>n.removeEventListener("change",i)},[t,e]),"auto"!==t?t:n?"dark":"light"}(i,A(t))),d="live"===o,u=d?"fixed":"absolute",h=n&&t.prompt.enabled,p=$(t,e);return h||p?(0,G.jsxs)(G.Fragment,{children:[d&&(0,G.jsx)("style",{children:"\n@keyframes pw-subw-fade { from { opacity: 0; } }\n@keyframes pw-subw-drop { from { opacity: 0; translate: 0 -16px; } }\n@keyframes pw-subw-rise { from { opacity: 0; translate: 0 16px; } }\n"}),h&&t.prompt.overlay&&(0,G.jsx)("div",{style:{position:u,inset:0,zIndex:t.zIndex,backgroundColor:"rgba(16, 24, 40, 0.5)",animation:d?"pw-subw-fade 0.2s ease-out backwards":void 0,pointerEvents:"auto"},onClick:a}),h&&(0,G.jsx)("div",{style:nt(t,u,d),children:(0,G.jsx)(it,{config:t,variant:N(e),colors:l,busy:r,onAccept:s,onDecline:a})}),p&&(0,G.jsx)("div",{style:{position:u,zIndex:t.zIndex,pointerEvents:"auto",...tt(t.launcher.position,t.launcher.offset)},children:(0,G.jsx)(rt,{config:t,blocked:"denied"===e,colors:l,onClick:c})})]}):null}const at="keyValue",ct="messages",lt="inboxMessages";function dt(t,e){return function(n){n.objectStoreNames.contains(t)||e(n)}}const ut=[dt(at,function(t){t.createObjectStore(at,{keyPath:"key"})}),dt("log",function(t){const e=t.createObjectStore("log",{keyPath:"id",autoIncrement:!0});e.createIndex("environment","environment",{unique:!1}),e.createIndex("date","date",{unique:!1}),e.createIndex("type","type",{unique:!1})}),dt(ct,function(t){t.createObjectStore(ct,{keyPath:"id",autoIncrement:!0}).createIndex("date","date",{unique:!1})}),dt(lt,function(t){const e="status",n=t.createObjectStore(lt,{keyPath:"inbox_id",autoIncrement:!1});n.createIndex(e,e,{unique:!1,multiEntry:!0}),n.createIndex("rt","rt",{unique:!1,multiEntry:!0})})];class ht{get all(){return ut}}class pt{constructor(t,e=new ht){this.db=t,this.migrationsBuilder=e}applyMigrations(){this.applyMigrationsPack(this.migrationsBuilder.all)}applyMigrationsPack(t){t.forEach(t=>{t(this.db)})}}function ft(t,e){console.info("onversionchange",e),t.close()}let bt;function mt(t){return(bt||(bt=new Promise((t,e)=>{const n=indexedDB.open("PUSHWOOSH_SDK_STORE",7);n.onsuccess=n=>{const o=n.target.result;o.onversionchange=ft.bind(null,o,e),t(o)},n.onerror=()=>e(n.error),n.onupgradeneeded=t=>{const n=t.target.result;n.onversionchange=ft.bind(null,n,e),new pt(n).applyMigrations()}})),bt).then(e=>new Promise((n,o)=>t(e,n,o)))}class gt{_add(t){return mt((e,n,o)=>{const i=e.transaction([this.name],"readwrite").objectStore(this.name).add(t);i.onsuccess=()=>{n(t)},i.onerror=()=>{o(i.error)}}).then(t=>this.getAll().then(e=>{if(Array.isArray(e)){const n=e.map(t=>t.id).sort((t,e)=>t==e?0:t<e?1:-1);if(n.length>this.maxItems)return Promise.all(n.slice(this.maxItems).map(t=>this.delete(t))).then(()=>t)}return t}))}delete(t){return mt((e,n,o)=>{const i=e.transaction([this.name],"readwrite").objectStore(this.name).delete(t);i.onsuccess=()=>{n(i.result)},i.onerror=()=>{o(i.error)}})}getAll(){return mt((t,e,n)=>{const o=[],i=t.transaction(this.name).objectStore(this.name).openCursor();i.onsuccess=t=>{const n=t.target.result;n?(n.value&&o.push(n.value),n.continue()):e(o)},i.onerror=()=>{n(i.error)}})}}yt=at;var yt;const xt=new class extends gt{constructor(){super(...arguments),this.name="log",this.maxItems=100,this.environment="undefined"!=typeof self&&self.registration?"worker":"browser"}add(t,e,n){const o={type:t,environment:this.environment,message:`${e}`,date:new Date};return e instanceof Error&&(o.stack=e.stack),n&&(o.additional=n),this._add(o)}},wt=(new class extends gt{constructor(){super(...arguments),this.name=ct,this.maxItems=25}add(t){return this._add({...t,date:new Date})}},{error:1,info:2,debug:3});let vt=3;const kt={setLevel(t){wt[t]||(t="error"),vt=wt[t]},write(t,e,n){return"error"===t?this.error(e):this.info(e),xt.add(t,e,n)}};Object.keys(wt).forEach(t=>{const e=wt[t];kt[t]=(...n)=>{e<=vt&&(console.groupCollapsed(t),console.info("",...n),console.trace("trace"),console.groupEnd())}});const Mt="Pushwoosh subscription widget:";class St{constructor(t){this.permission="unsupported",this.open=!1,this.busy=!1,this.container=null,this.autoShowTimer=null,this.pw=t,this.config=function(t){const e=y,n=O(t),o=O(n.prompt),i=O(n.launcher),r=O(n.display),s=g,a=R(o.layout,f,e.prompt.layout),c=p[a],l=R(r.trigger,m,e.display.trigger),d=B(o.iconUrl),u=B(i.imageUrl),h=H({colors:n.colors}),x=L({dark:n.dark},h),w=!0===o.enabled,v=!0===i.enabled;return{enable:w||v,prompt:{enabled:w,layout:a,position:R(o.position,c,c[0]),...d?{iconUrl:d}:{},borderRadius:W(o.borderRadius,s.borderRadius,e.prompt.borderRadius),overlay:"modal"===a||!0===o.overlay},launcher:{enabled:v,position:R(i.position,b,e.launcher.position),offset:W(i.offset,s.offset,e.launcher.offset),width:W(i.width,s.launcherSize,e.launcher.width),height:W(i.height,s.launcherSize,e.launcher.height),...u?{imageUrl:u}:{},...U("background",i.background),...U("iconColor",i.iconColor)},display:{trigger:l,delay:W(r.delay,s.delay,e.display.delay),cappingCount:W(r.cappingCount,s.cappingCount,e.display.cappingCount),cappingInterval:W(r.cappingInterval,s.cappingInterval,e.display.cappingInterval)},texts:V(O(n.texts)),colors:h,...x?{dark:x}:{},fontFamily:q(n.fontFamily,e.fontFamily),zIndex:W(n.zIndex,s.zIndex,e.zIndex)}}(t.initParams.subscriptionWidget),this.accept=this.accept.bind(this),this.decline=this.decline.bind(this),this.toggle=this.toggle.bind(this),this.launcherClick=this.launcherClick.bind(this),t.moduleRegistry.subscriptionWidget=this}async run(){const{pw:t,config:e}=this;e.enable&&t.isPushAvailable()&&(this.permission=await this.readPermission(),this.mount(),this.listenSubscriptionChanges(),await this.scheduleAutoShow())}show(){this.container&&this.config.prompt.enabled&&_(this.permission)&&!this.open&&(this.open=!0,this.render(),this.pw.dispatchEvent("show-subscription-widget",{}))}hide(){this.open&&(this.open=!1,this.busy=!1,this.render(),this.pw.dispatchEvent("hide-subscription-widget",{}))}toggle(t){t??!this.open?this.show():this.hide()}isVisible(){return this.open}async readPermission(){const t=this.pw.driver?.getPermission();return"denied"===t?"denied":await this.pw.isSubscribed()?"granted":"default"}mount(){const t=document.createElement("div");t.id="pushwoosh-subscription-widget",t.style.position="fixed",t.style.inset="0",t.style.zIndex=String(this.config.zIndex),t.style.pointerEvents="none",document.body.appendChild(t),this.container=document.createElement("div"),t.attachShadow({mode:"open"}).appendChild(this.container),this.render()}render(){var t;if(this.container)return this.open||$(this.config,this.permission)?void((t,e)=>{(0,K.render)((0,G.jsx)(st,{...e,mode:"live"}),t)})(this.container,{config:this.config,permission:this.permission,open:this.open,busy:this.busy,onAccept:this.accept,onDecline:this.decline,onLauncherClick:this.launcherClick}):(t=this.container,void(0,K.render)(null,t))}async scheduleAutoShow(){const t=await this.pw.data.getSubscriptionWidgetHistory();(function(t,e,n,o){const{trigger:i,cappingCount:r,cappingInterval:s}=t.display;return!(!t.prompt.enabled||"auto"!==i||"default"!==e||r>0&&n.shownCount>=r||!(null===n.lastShownAt||o-n.lastShownAt>=36e5*s))})(this.config,this.permission,t,Date.now())&&(this.autoShowTimer=setTimeout(async()=>{this.autoShowTimer=null,this.open||"default"!==this.permission||(this.show(),await this.pw.data.setSubscriptionWidgetHistory(function(t,e){return{shownCount:t.shownCount+1,lastShownAt:e}}(t,Date.now())))},1e3*this.config.display.delay))}launcherClick(){const t=(e=this.config,n=this.permission,e.prompt.enabled?"prompt":"default"===n?"subscribe":"none");var e,n;"prompt"===t?this.toggle():"subscribe"===t&&this.subscribeFromLauncher()}async subscribeFromLauncher(){try{await this.pw.subscribe()}catch(t){kt.error(t,`${Mt} failed to subscribe`)}this.permission=await this.readPermission(),this.render()}async accept(){this.busy=!0,this.render();try{await this.pw.subscribe()}catch(t){kt.error(t,`${Mt} failed to subscribe`)}if(this.permission=await this.readPermission(),"denied"===this.permission)return this.busy=!1,void this.render();this.hide()}decline(){this.hide()}listenSubscriptionChanges(){const t=async()=>{this.permission=await this.readPermission(),"granted"===this.permission&&(this.cancelAutoShow(),this.hide()),this.render()};this.pw.addSdkEventHandler("subscribe",t),this.pw.addSdkEventHandler("unsubscribe",t),this.pw.addSdkEventHandler("permission-denied",t)}cancelAutoShow(){null!==this.autoShowTimer&&(clearTimeout(this.autoShowTimer),this.autoShowTimer=null)}}return s})());
1
+ !function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("preact"),require("preact/compat"),require("preact/jsx-runtime"));else if("function"==typeof define&&define.amd)define(["preact","preact/compat","preact/jsx-runtime"],e);else{var n="object"==typeof exports?e(require("preact"),require("preact/compat"),require("preact/jsx-runtime")):e(t.preact,t.preactCompat,t.jsxRuntime);for(var o in n)("object"==typeof exports?exports:t)[o]=n[o]}}(this,(t,e,n)=>(()=>{"use strict";var o={524(e){e.exports=t},873(t){t.exports=e},247(t){t.exports=n}};const i={};function r(t){const e=i[t];if(void 0!==e)return e.exports;const n=i[t]={exports:{}};return o[t](n,n.exports,r),n.exports}r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{Object.defineProperties(t,{[Symbol.toStringTag]:{value:"Module"},__esModule:{value:!0}})};let s={};r.r(s),r.d(s,{PWSubscriptionWidget:()=>St});const a=/^(https?:|mailto:|tel:)/i,c="#101828",l="#667085",d="#FFFFFF",u={background:"#FFFFFF",accent:"#2970FF",text:c,textSecondary:l,textInverse:"#FFFFFF"};function h(t,e){return{display:"block",boxSizing:"border-box",width:"100%",padding:"10px 25px",borderRadius:6,fontSize:14,fontWeight:600,fontFamily:"inherit",lineHeight:1.5,textAlign:"center",textDecoration:"none",cursor:"pointer",..."secondary"===t?{backgroundColor:e.surface,color:e.accent,border:`1px solid ${e.accent}`}:{backgroundColor:e.accent,color:e.onAccent,border:"none"}}}const p={card:["top","bottom","top-left","top-right","bottom-left","bottom-right"],bar:["top","bottom"],modal:["center"]},f=Object.keys(p),b=["bottom-right","bottom-left","top-right","top-left"],m=["auto","launcher","manual"],g={delay:[0,3600],cappingCount:[0,100],cappingInterval:[0,8760],borderRadius:[0,32],offset:[0,100],launcherSize:[16,200],zIndex:[0,2147483647]},y={enable:!1,prompt:{enabled:!1,layout:"card",position:"top",borderRadius:12,overlay:!1},launcher:{enabled:!1,position:"bottom-right",offset:20,width:48,height:48},display:{trigger:"auto",delay:5,cappingCount:3,cappingInterval:4},texts:{title:"Stay in the loop",message:"Allow notifications to get our news and special offers first.",acceptText:"Allow",declineText:"Not now",closeText:"Got it",blockedTitle:"Notifications are blocked",blockedMessage:"To get our notifications, allow them for this site in your browser settings.",launcherLabel:"Subscribe to notifications",launcherBlockedLabel:"Notifications are blocked"},colors:u,fontFamily:'Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',zIndex:2147483e3},x=/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;function w(t){const e=x.exec(t.trim())?.[1];if(!e)return null;const n=3===e.length?e.split("").map(t=>t+t).join(""):e;return[0,2,4].map(t=>parseInt(n.slice(t,t+2),16))}function v([t,e,n]){return`#${[t,e,n].map(t=>Math.max(0,Math.min(255,Math.round(t))).toString(16).padStart(2,"0")).join("")}`}function k(t,e,n){let o=n;return o<0&&(o+=1),o>1&&(o-=1),o<1/6?t+6*(e-t)*o:o<.5?e:o<2/3?t+(e-t)*(2/3-o)*6:t}function M(t){return t>.5?.07+.86*(1-t):t}function S(t){return t<.5?.93-t*((.93-.5)/.5):t}function j(t,e){const n=w(t);if(!n)return t;const[o,i,r]=function([t,e,n]){const[o,i,r]=[t/255,e/255,n/255],s=Math.max(o,i,r),a=Math.min(o,i,r),c=(s+a)/2;if(s===a)return[0,0,c];const l=s-a;let d;return d=s===o?(i-r)/l+(i<r?6:0):s===i?(r-o)/l+2:(o-i)/l+4,[d/6,c>.5?l/(2-s-a):l/(s+a),c]}(n);return v(function([t,e,n]){if(0===e){const t=255*n;return[t,t,t]}const o=n<.5?n*(1+e):n+e-n*e,i=2*n-o;return[255*k(i,o,t+1/3),255*k(i,o,t),255*k(i,o,t-1/3)]}([o,i,"fold"===e?M(r):S(r)]))}function I(t,e,n){const o=w(t),i=w(e);return o&&i?v(o.map((t,e)=>t+(i[e]-t)*n)):t}function C(t){const e=w(t);if(!e)return!1;const[n,o,i]=e;return(.299*n+.587*o+.114*i)/255>.6}function F(t){return{background:j(t.background,"fold"),accent:t.accent,text:j(t.text,"lift"),textSecondary:j(t.textSecondary,"lift"),textInverse:t.textInverse}}function z(t,e){return"light"===e?{surface:u.background,surfaceText:c,border:"#D0D5DD",onAccent:d,error:"#D92D20",chromeIcon:l}:{surface:I(t.background,t.text,.08),surfaceText:t.text,border:I(t.background,t.text,.24),onAccent:C(t.accent)?c:d,error:"#FDA29B",chromeIcon:t.textSecondary}}function A(t){return!0===t.dark?.enabled}function E(t,e="light"){return"dark"===e&&A(t)?"dark":"light"}function P(t,e="light"){const n=E(t,e),o="dark"===n?(i=t.colors,r=t.dark,{...F(i),...r?.colors??{}}):t.colors;var i,r;return{...o,scheme:n,...z(o,n)}}function T(t){const e=(t||"").trim();if(e)return e.startsWith("#")||e.startsWith("/")||e.startsWith("?")||a.test(e)?e:void 0}new Set(["STRONG","B","EM","I","U","BR","A"]);function D(t){return"string"==typeof t&&t?t:void 0}function H(t){const e="object"==typeof t.colors&&null!==t.colors?t.colors:{};return{background:D(e.background)??D(t.background)??u.background,accent:D(e.accent)??D(t.accent)??u.accent,text:D(e.text)??u.text,textSecondary:D(e.textSecondary)??u.textSecondary,textInverse:D(e.textInverse)??u.textInverse}}function L(t,e){const n=t.dark;if("object"!=typeof n||null===n)return;const o=n,i="object"==typeof o.colors&&null!==o.colors?o.colors:{},r=F(e),s=function(t){if("object"!=typeof t||null===t)return;const e=t,n=D(e.color);if(!n)return;return{color:n,opacity:"number"==typeof e.opacity&&Number.isFinite(e.opacity)?Math.max(0,Math.min(1,e.opacity)):1}}(o.overlay);return{enabled:!0===o.enabled,colors:{background:D(i.background)??r.background,accent:D(i.accent)??r.accent,text:D(i.text)??r.text,textSecondary:D(i.textSecondary)??r.textSecondary,textInverse:D(i.textInverse)??r.textInverse},...s?{overlay:s}:{},...D(o.boxShadow)?{boxShadow:o.boxShadow}:{}}}function O(t){return"object"!=typeof t||null===t||Array.isArray(t)?{}:t}function R(t,e,n){return e.includes(t)?t:n}function W(t,[e,n],o){return"number"==typeof t&&Number.isFinite(t)?Math.max(e,Math.min(n,Math.round(t))):o}function q(t,e){if("string"!=typeof t)return e;const n=t.trim();return n?n.slice(0,300):e}function B(t){const e=T("string"==typeof t?t:void 0);return e&&/^(https?:\/\/|\/)/i.test(e)?e:void 0}function U(t,e){const n="string"==typeof e?e.trim().slice(0,64):"";return n?{[t]:n}:{}}function V(t){const e=y.texts,n=Object.keys(e);return Object.fromEntries(n.map(n=>[n,q(t[n],e[n])]))}function _(t){return"default"===t||"denied"===t}function N(t){return"denied"===t?"blocked":"ask"}function $(t,e){return t.launcher.enabled&&_(e)}var G=r(247),K=r(524),X=r(873);const J="(prefers-color-scheme: dark)";function Q(){return"undefined"!=typeof window&&"function"==typeof window.matchMedia&&window.matchMedia(J).matches}const Y={bell:"M6 10a6 6 0 0 1 12 0c0 4 1.5 5.5 2 6H4c.5-.5 2-2 2-6M10 20a2 2 0 0 0 4 0",gift:"M3 11h18v9a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1zM2.5 7h19v4h-19zM12 7v14M12 7c-1 0-3-.2-3.5-1a2 2 0 0 1 3.5-1 2 2 0 0 1 3.5 1c-.5.8-2.5 1-3.5 1z",cart:"M2 4h2.2l2.4 11.2A2 2 0 0 0 8.6 17H19M6 7h15l-2.2 7.5H8M10.5 20a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0M19.5 20a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0",chart:"M3 21h18M7 21V11M12 21V6M17 21v-8",lock:"M5 11h14v10H5zM8 11V8a4 4 0 0 1 8 0v3",calendar:"M4 6h16v15H4zM4 10h16M9 3v4M15 3v4",check:"M4 13l5 5L20 6",star:"M12 3l2.9 5.9 6.5.9-4.7 4.6 1.1 6.5-5.8-3.1-5.8 3.1 1.1-6.5L2.6 9.8l6.5-.9z",clock:"M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0M12 7v5l4 2",tag:"M20.6 13.4l-7.2 7.2a2 2 0 0 1-2.8 0l-7-7A2 2 0 0 1 3 12.2V5a2 2 0 0 1 2-2h7.2a2 2 0 0 1 1.4.6l7 7a2 2 0 0 1 0 2.8zM9 8a1 1 0 1 1-2 0 1 1 0 0 1 2 0",mail:"M3 6h18v12H3zM3 7l9 6 9-6",phone:"M7 2h10a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1M10 19h4",download:"M12 3v12M7 11l5 5 5-5M4 20h16",play:"M8 5l12 7-12 7z",shield:"M12 3l8 3v6c0 5-3.4 8.6-8 10-4.6-1.4-8-5-8-10V6z",sparkle:"M12 3l1.8 5.2L19 10l-5.2 1.8L12 17l-1.8-5.2L5 10l5.2-1.8zM18 15l.9 2.1 2.1.9-2.1.9-.9 2.1-.9-2.1L15 18l2.1-.9z",percent:"M19 5L5 19M8.5 8.5a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0M20.5 15.5a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0",truck:"M2 7h12v10H2zM14 10h4l3 3v4h-7M8.5 19a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0M20 19a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0",ticket:"M4 7h16v4a2 2 0 0 0 0 4v3H4v-3a2 2 0 0 0 0-4zM14 7v12",user:"M20 21a8 8 0 0 0-16 0M16 7a4 4 0 1 1-8 0 4 4 0 0 1 8 0"},Z=(Object.keys(Y),"0 12px 32px rgba(16, 24, 40, 0.18)");function tt(t,e){const[n,o]=t.split("-");return{[n]:e,[o]:e}}function et(t,e){return e?(t?"pw-subw-drop":"pw-subw-rise")+" 0.3s ease-out backwards":void 0}function nt(t,e,n){const{layout:o,position:i}=t.prompt,r={position:e,zIndex:t.zIndex,boxSizing:"border-box",pointerEvents:"auto"};if("bar"===o)return{...r,left:0,right:0,[i]:0,animation:et("top"===i,n)};if("modal"===o)return{...r,top:"50%",left:"50%",width:"min(420px, calc(100% - 32px))",transform:"translate(-50%, -50%)",animation:n?"pw-subw-fade 0.25s ease-out backwards":void 0};const s="min(360px, calc(100% - 32px))",a=et(i.startsWith("top"),n);return"top"===i||"bottom"===i?{...r,[i]:16,left:"50%",width:s,transform:"translateX(-50%)",animation:a}:{...r,...tt(i,16),width:s,animation:a}}function ot({label:t,primary:e,colors:n,disabled:o,onClick:i}){return(0,G.jsx)("button",{type:"button",disabled:o,onClick:i,style:{...h(e?"primary":"secondary",n),display:"inline-block",width:"auto",padding:"8px 18px",whiteSpace:"nowrap",opacity:o?.6:1,cursor:o?"default":"pointer"},children:t})}function it({config:t,variant:e,colors:n,busy:o,onAccept:i,onDecline:r}){const{prompt:s,texts:a}=t,c="bar"===s.layout,l="blocked"===e;return(0,G.jsxs)("div",{role:"dialog","aria-label":l?a.blockedTitle:a.title,style:{display:"flex",flexDirection:c?"row":"column",alignItems:c?"center":"stretch",flexWrap:c?"wrap":"nowrap",gap:16,padding:c?"12px 20px":20,boxSizing:"border-box",width:"100%",borderRadius:c?0:s.borderRadius,boxShadow:Z,backgroundColor:n.background,color:n.text,fontFamily:t.fontFamily,colorScheme:n.scheme},children:[(0,G.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:12,flex:c?"1 1 240px":void 0},children:[s.iconUrl&&(0,G.jsx)("img",{src:s.iconUrl,alt:"",width:48,height:48,style:{flex:"none",borderRadius:8,objectFit:"cover"}}),(0,G.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4,minWidth:0},children:[(0,G.jsx)("div",{style:{fontSize:16,fontWeight:600,lineHeight:1.4},children:l?a.blockedTitle:a.title}),(0,G.jsx)("div",{style:{fontSize:14,lineHeight:1.5,color:n.textSecondary},children:l?a.blockedMessage:a.message})]})]}),(0,G.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,flex:"none"},children:l?(0,G.jsx)(ot,{label:a.closeText,primary:!0,colors:n,onClick:r}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(ot,{label:a.declineText,primary:!1,colors:n,onClick:r}),(0,G.jsx)(ot,{label:a.acceptText,primary:!0,colors:n,disabled:o,onClick:i})]})})]})}function rt({config:t,blocked:e,colors:n,onClick:o}){const{width:i,height:r,imageUrl:s}=t.launcher,a=e?t.texts.launcherBlockedLabel:t.texts.launcherLabel,c=Math.round(Math.min(i,r)/2),l={display:"flex",alignItems:"center",justifyContent:"center",width:i,height:r,padding:0,border:"none",cursor:"pointer",opacity:e?.7:1};return s?(0,G.jsx)("button",{type:"button","aria-label":a,title:a,onClick:o,style:{...l,background:"none"},children:(0,G.jsx)("img",{src:s,alt:"",width:i,height:r,style:{display:"block",objectFit:"contain"}})}):(0,G.jsx)("button",{type:"button","aria-label":a,title:a,onClick:o,style:{...l,borderRadius:"50%",backgroundColor:t.launcher.background??n.accent,color:t.launcher.iconColor??n.onAccent,boxShadow:Z},children:(0,G.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,G.jsx)("path",{d:Y.bell}),e&&(0,G.jsx)("path",{d:"M4 4l16 16"})]})})}function st({config:t,permission:e,open:n,mode:o="live",colorScheme:i="auto",busy:r,onAccept:s,onDecline:a,onLauncherClick:c}){const l=P(t,function(t,e){const[n,o]=(0,X.useState)(()=>"auto"===t&&e&&Q()),i=[t,e],[r,s]=(0,X.useState)(null);return(null===r||i.some((t,e)=>t!==r[e]))&&(s(i),"auto"===t&&e&&o(Q())),(0,X.useEffect)(()=>{if("auto"!==t||!e||"undefined"==typeof window||"function"!=typeof window.matchMedia)return;const n=window.matchMedia(J),i=t=>o(t.matches);return n.addEventListener("change",i),()=>n.removeEventListener("change",i)},[t,e]),"auto"!==t?t:n?"dark":"light"}(i,A(t))),d="live"===o,u=d?"fixed":"absolute",h=n&&t.prompt.enabled,p=$(t,e);return h||p?(0,G.jsxs)(G.Fragment,{children:[d&&(0,G.jsx)("style",{children:"\n@keyframes pw-subw-fade { from { opacity: 0; } }\n@keyframes pw-subw-drop { from { opacity: 0; translate: 0 -16px; } }\n@keyframes pw-subw-rise { from { opacity: 0; translate: 0 16px; } }\n"}),h&&t.prompt.overlay&&(0,G.jsx)("div",{style:{position:u,inset:0,zIndex:t.zIndex,backgroundColor:"rgba(16, 24, 40, 0.5)",animation:d?"pw-subw-fade 0.2s ease-out backwards":void 0,pointerEvents:"auto"},onClick:a}),h&&(0,G.jsx)("div",{style:nt(t,u,d),children:(0,G.jsx)(it,{config:t,variant:N(e),colors:l,busy:r,onAccept:s,onDecline:a})}),p&&(0,G.jsx)("div",{style:{position:u,zIndex:t.zIndex,pointerEvents:"auto",...tt(t.launcher.position,t.launcher.offset)},children:(0,G.jsx)(rt,{config:t,blocked:"denied"===e,colors:l,onClick:c})})]}):null}const at="keyValue",ct="messages",lt="inboxMessages";function dt(t,e){return function(n){n.objectStoreNames.contains(t)||e(n)}}const ut=[dt(at,function(t){t.createObjectStore(at,{keyPath:"key"})}),dt("log",function(t){const e=t.createObjectStore("log",{keyPath:"id",autoIncrement:!0});e.createIndex("environment","environment",{unique:!1}),e.createIndex("date","date",{unique:!1}),e.createIndex("type","type",{unique:!1})}),dt(ct,function(t){t.createObjectStore(ct,{keyPath:"id",autoIncrement:!0}).createIndex("date","date",{unique:!1})}),dt(lt,function(t){const e="status",n=t.createObjectStore(lt,{keyPath:"inbox_id",autoIncrement:!1});n.createIndex(e,e,{unique:!1,multiEntry:!0}),n.createIndex("rt","rt",{unique:!1,multiEntry:!0})})];class ht{get all(){return ut}}class pt{constructor(t,e=new ht){this.db=t,this.migrationsBuilder=e}applyMigrations(){this.applyMigrationsPack(this.migrationsBuilder.all)}applyMigrationsPack(t){t.forEach(t=>{t(this.db)})}}function ft(t,e){console.info("onversionchange",e),t.close()}let bt;function mt(t){return(bt||(bt=new Promise((t,e)=>{const n=indexedDB.open("PUSHWOOSH_SDK_STORE",7);n.onsuccess=n=>{const o=n.target.result;o.onversionchange=ft.bind(null,o,e),t(o)},n.onerror=()=>e(n.error),n.onupgradeneeded=t=>{const n=t.target.result;n.onversionchange=ft.bind(null,n,e),new pt(n).applyMigrations()}})),bt).then(e=>new Promise((n,o)=>t(e,n,o)))}class gt{_add(t){return mt((e,n,o)=>{const i=e.transaction([this.name],"readwrite").objectStore(this.name).add(t);i.onsuccess=()=>{n(t)},i.onerror=()=>{o(i.error)}}).then(t=>this.getAll().then(e=>{if(Array.isArray(e)){const n=e.map(t=>t.id).sort((t,e)=>t==e?0:t<e?1:-1);if(n.length>this.maxItems)return Promise.all(n.slice(this.maxItems).map(t=>this.delete(t))).then(()=>t)}return t}))}delete(t){return mt((e,n,o)=>{const i=e.transaction([this.name],"readwrite").objectStore(this.name).delete(t);i.onsuccess=()=>{n(i.result)},i.onerror=()=>{o(i.error)}})}getAll(){return mt((t,e,n)=>{const o=[],i=t.transaction(this.name).objectStore(this.name).openCursor();i.onsuccess=t=>{const n=t.target.result;n?(n.value&&o.push(n.value),n.continue()):e(o)},i.onerror=()=>{n(i.error)}})}}yt=at;var yt;const xt=new class extends gt{constructor(){super(...arguments),this.name="log",this.maxItems=100,this.environment="undefined"!=typeof self&&self.registration?"worker":"browser"}add(t,e,n){const o={type:t,environment:this.environment,message:`${e}`,date:new Date};return e instanceof Error&&(o.stack=e.stack),n&&(o.additional=n),this._add(o)}},wt=(new class extends gt{constructor(){super(...arguments),this.name=ct,this.maxItems=25}add(t){return this._add({...t,date:new Date})}},{error:1,info:2,debug:3});let vt=3;const kt={setLevel(t){wt[t]||(t="error"),vt=wt[t]},write(t,e,n){return"error"===t?this.error(e):this.info(e),xt.add(t,e,n)}};Object.keys(wt).forEach(t=>{const e=wt[t];kt[t]=(...n)=>{e<=vt&&(console.groupCollapsed(t),console.info("",...n),console.trace("trace"),console.groupEnd())}});const Mt="Pushwoosh subscription widget:";class St{constructor(t){this.permission="unsupported",this.open=!1,this.busy=!1,this.container=null,this.autoShowTimer=null,this.pw=t,this.config=function(t){const e=y,n=O(t),o=O(n.prompt),i=O(n.launcher),r=O(n.display),s=g,a=R(o.layout,f,e.prompt.layout),c=p[a],l=R(r.trigger,m,e.display.trigger),d=B(o.iconUrl),u=B(i.imageUrl),h=H({colors:n.colors}),x=L({dark:n.dark},h),w=!0===o.enabled,v=!0===i.enabled;return{enable:w||v,prompt:{enabled:w,layout:a,position:R(o.position,c,c[0]),...d?{iconUrl:d}:{},borderRadius:W(o.borderRadius,s.borderRadius,e.prompt.borderRadius),overlay:"modal"===a||!0===o.overlay},launcher:{enabled:v,position:R(i.position,b,e.launcher.position),offset:W(i.offset,s.offset,e.launcher.offset),width:W(i.width,s.launcherSize,e.launcher.width),height:W(i.height,s.launcherSize,e.launcher.height),...u?{imageUrl:u}:{},...U("background",i.background),...U("iconColor",i.iconColor)},display:{trigger:l,delay:W(r.delay,s.delay,e.display.delay),cappingCount:W(r.cappingCount,s.cappingCount,e.display.cappingCount),cappingInterval:W(r.cappingInterval,s.cappingInterval,e.display.cappingInterval)},texts:V(O(n.texts)),colors:h,...x?{dark:x}:{},fontFamily:q(n.fontFamily,e.fontFamily),zIndex:W(n.zIndex,s.zIndex,e.zIndex)}}(t.initParams.subscriptionWidget),this.accept=this.accept.bind(this),this.decline=this.decline.bind(this),this.toggle=this.toggle.bind(this),this.launcherClick=this.launcherClick.bind(this),t.moduleRegistry.subscriptionWidget=this}async run(){const{pw:t,config:e}=this;e.enable&&t.isPushAvailable()&&(this.permission=await this.readPermission(),this.mount(),this.listenSubscriptionChanges(),await this.scheduleAutoShow())}show(){this.container&&this.config.prompt.enabled&&_(this.permission)&&!this.open&&(this.open=!0,this.render(),this.pw.dispatchEvent("show-subscription-widget",{}))}hide(){this.open&&(this.open=!1,this.busy=!1,this.render(),this.pw.dispatchEvent("hide-subscription-widget",{}))}toggle(t){t??!this.open?this.show():this.hide()}isVisible(){return this.open}async readPermission(){const t=this.pw.driver?.getPermission();return"denied"===t?"denied":await this.pw.isSubscribed()?"granted":"default"}mount(){const t=document.createElement("div");t.id="pushwoosh-subscription-widget",t.style.position="fixed",t.style.inset="0",t.style.zIndex=String(this.config.zIndex),t.style.pointerEvents="none",document.body.appendChild(t),this.container=document.createElement("div"),t.attachShadow({mode:"open"}).appendChild(this.container),this.render()}render(){var t;if(this.container)return this.open||$(this.config,this.permission)?void((t,e)=>{(0,K.render)((0,G.jsx)(st,{...e,mode:"live"}),t)})(this.container,{config:this.config,permission:this.permission,open:this.open,busy:this.busy,onAccept:this.accept,onDecline:this.decline,onLauncherClick:this.launcherClick}):(t=this.container,void(0,K.render)(null,t))}async scheduleAutoShow(){const t=await this.pw.data.getSubscriptionWidgetHistory();(function(t,e,n,o){const{trigger:i,cappingCount:r,cappingInterval:s}=t.display;return!(!t.prompt.enabled||"auto"!==i||"default"!==e||r>0&&n.shownCount>=r||!(null===n.lastShownAt||o-n.lastShownAt>=36e5*s))})(this.config,this.permission,t,Date.now())&&(this.autoShowTimer=setTimeout(async()=>{this.autoShowTimer=null,this.open||"default"!==this.permission||(this.show(),await this.pw.data.setSubscriptionWidgetHistory(function(t,e){return{shownCount:t.shownCount+1,lastShownAt:e}}(t,Date.now())))},1e3*this.config.display.delay))}launcherClick(){const t=(e=this.config,n=this.permission,e.prompt.enabled?"prompt":"default"===n?"subscribe":"none");var e,n;"prompt"===t?this.toggle():"subscribe"===t&&this.subscribeFromLauncher()}async subscribeFromLauncher(){try{await this.pw.subscribe()}catch(t){kt.error(t,`${Mt} failed to subscribe`)}this.permission=await this.readPermission(),this.render()}async accept(){this.busy=!0,this.render();try{await this.pw.subscribe()}catch(t){kt.error(t,`${Mt} failed to subscribe`)}if(this.permission=await this.readPermission(),"denied"===this.permission)return this.busy=!1,void this.render();this.hide()}decline(){this.hide()}listenSubscriptionChanges(){const t=async()=>{this.permission=await this.readPermission(),"granted"===this.permission&&(this.cancelAutoShow(),this.hide()),this.render()};this.pw.addSdkEventHandler("subscribe",t),this.pw.addSdkEventHandler("unsubscribe",t),this.pw.addSdkEventHandler("permission-denied",t)}cancelAutoShow(){null!==this.autoShowTimer&&(clearTimeout(this.autoShowTimer),this.autoShowTimer=null)}}return s})());
2
2
  //# sourceMappingURL=widget-subscription.js.map