{"version":3,"sources":["webpack://Unipol/./node_modules/@deleteagency/dc/src/dc-dom.js","webpack://Unipol/./node_modules/@deleteagency/dc/src/dc-factory.js","webpack://Unipol/./node_modules/@deleteagency/device-observer/src/device-observer.js","webpack://Unipol/./node_modules/@deleteagency/device-observer/src/index.js","webpack://Unipol/./node_modules/nanoid/index.browser.js"],"names":["COMPONENT_STATE_INITIALIZING","COMPONENT_STATE_LAZY_WAITING","COMPONENT_STATE_CREATED","COMPONENT_STATE_ERROR","constructor","this","_registredComponents","_elementsComponents","WeakMap","_instances","register","componentClass","selector","push","_getComponentStateOnElement","element","existedComponents","get","_setComponentStateOnElement","state","componentsMap","Map","set","init","root","document","body","withLazy","forEach","_initComponent","elements","namespace","getNamespacedAnchorAttribute","querySelectorAll","matches","msMatchesSelector","Error","dcDom","getNamespace","length","_initComponentOnElement","e","console","error","_isComponentLazy","checkElement","hasAttribute","parentElement","setTimeout","instance","_createComponentOnElement","_onComponentCreated","_onComponentCreationError","getElement","name","message","destroy","filter","contains","_destroyComponent","component","getChildComponents","getChildComponent","debug","_inited","_devices","_ascendingDevicesArray","_deviceName","_deviceIndex","_deviceChangeCallbacks","_resizeCallbacks","_debounceTimeoutId","devices","options","_setDevicesData","_resizeDebounce","resizeDebounce","_mobileFirst","mobileFirst","_updateDeviceData","window","addEventListener","_onWindowResize","bind","Object","keys","map","deviceName","sort","a","b","clearTimeout","_handleWindowResize","oldDeviceType","_invokeResize","_invokeDeviceChange","_checkDeviceNameRegistered","indexOf","join","_checkDevices","Infinity","currentDevice","reverse","find","deviceData","_isGreaterOrEqual","_isLowerOrEqual","cb","newDeviceType","pixelsValue","matchMedia","_getDeviceNameIndex","findIndex","subscribeOnResize","storedCb","subscribeOnChange","is","operator","isMatch","isGt","isGe","isLt","isLe","isGeCustom","value","DeviceObserver","nanoid","size","id","bytes","crypto","getRandomValues","Uint8Array","byte","toString","toUpperCase"],"mappings":"kJA2JA,MC9IMA,EAA+B,eAI/BC,EAA+B,eAI/BC,E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,CAMb,IAAIM,EAAqB,GAAdJ,EAAMF,GAGfC,GAFEK,EAAO,GAEHA,EAAKC,SAAS,IACXD,EAAO,IAETA,EAAO,IAAIC,SAAS,IAAIC,cACtBF,EAAO,GACV,IAEA,IAGV,OAAOL","file":"3615.51c0ad5efa402b28ed72.js","sourcesContent":["import utils from './utils';\r\n\r\nconst DC_NAMESPACE = 'data-dc';\r\nconst DC_NAMESPACED_ATTRIBUTE_REFERENCE = 'ref';\r\nconst DC_NAMESPACED_ATTRIBUTE_ID = 'id';\r\nconst DC_NAMESPACED_ATTRIBUTE_LAZY = 'lazy';\r\n\r\nfunction matches(root, selector) {\r\n // add support of the matches in IE\r\n return root.matches ? root.matches(selector) : root.msMatchesSelector(selector);\r\n}\r\n\r\nfunction getNamespacedAnchorAttribute(namespace) {\r\n return `${DC_NAMESPACE}-${namespace}`;\r\n}\r\n\r\n/**\r\n * @param {HTMLElement} root!\r\n * @param {string} namespace\r\n * @param {?string|Function} selector\r\n * @return {Array}\r\n * @throws Error\r\n */\r\nfunction findElementsForInit(root, namespace, selector = null) {\r\n // by default we use namespace\r\n if (selector === null) {\r\n selector = `[${getNamespacedAnchorAttribute(namespace)}]`;\r\n }\r\n\r\n let elements = [];\r\n if (typeof selector === 'string') {\r\n elements = [...root.querySelectorAll(selector)];\r\n if (matches(root, selector)) {\r\n elements.push(root);\r\n }\r\n } else if (typeof selector === 'function') {\r\n elements = selector(root);\r\n } else {\r\n throw new Error(\"Unknown selector's type\");\r\n }\r\n\r\n return elements;\r\n}\r\n\r\n/**\r\n * @param {HTMLElement} element\r\n * @return {boolean}\r\n */\r\nfunction isElementWithinLazyParent(element) {\r\n let checkElement = element;\r\n const attribute = `${DC_NAMESPACE}-${DC_NAMESPACED_ATTRIBUTE_LAZY}`;\r\n while (checkElement) {\r\n if (checkElement.hasAttribute(attribute)) {\r\n return true;\r\n }\r\n checkElement = checkElement.parentElement;\r\n }\r\n\r\n return false;\r\n}\r\n\r\n/**\r\n *\r\n * @param {HTMLElement} element\r\n * @param {string} namespace\r\n * @return {?string}\r\n */\r\nfunction getElementId(element, namespace) {\r\n return getNamespacedAttributeValue(element, DC_NAMESPACED_ATTRIBUTE_ID, namespace);\r\n}\r\n\r\n/**\r\n *\r\n * @param {HTMLElement} element\r\n * @param {string} selector\r\n * @param {string }namespace\r\n * @param {string} id\r\n * @return {HTMLElement[]}\r\n */\r\nfunction scopedQuerySelectorAll(element, selector, namespace, id) {\r\n if (id) {\r\n selector += `[${getNamespacedAttributeName(DC_NAMESPACED_ATTRIBUTE_ID, namespace)}=\"${id}\"]`;\r\n }\r\n return [...element.querySelectorAll(selector)];\r\n}\r\n\r\n/**\r\n * @param {HTMLElement} element\r\n * @param {string} namespace\r\n * @return {Object}\r\n */\r\nfunction getElementOptions(element, namespace) {\r\n return getElementAttributeAsObject(element, getNamespacedAnchorAttribute(namespace));\r\n}\r\n\r\n/**\r\n * @param {HTMLElement} element\r\n * @param {string} attribute\r\n * @return {?Object}\r\n */\r\nfunction getElementAttributeAsObject(element, attribute) {\r\n let result = {};\r\n const attributeValue = element.getAttribute(attribute);\r\n if (attributeValue) {\r\n try {\r\n result = JSON.parse(attributeValue);\r\n } catch (error) {\r\n console.error(`Unable to parse «${attribute}» attribute on element:`, element);\r\n throw error;\r\n }\r\n }\r\n\r\n return result;\r\n}\r\n\r\n/**\r\n * @param {HTMLElement} element\r\n * @param {string} namespace\r\n * @param {string} id\r\n * @return {ReferencesCollection}\r\n */\r\nfunction getElementRefs(element, namespace, id) {\r\n const refAttribute = getNamespacedAttributeName(DC_NAMESPACED_ATTRIBUTE_REFERENCE, namespace);\r\n const selector = `[${refAttribute}]`;\r\n\r\n const refs = {};\r\n const elements = scopedQuerySelectorAll(element, selector, namespace, id);\r\n if (elements.length > 0) {\r\n elements.forEach(element => {\r\n const refValue = element.getAttribute(refAttribute);\r\n if (refValue !== null) {\r\n utils.addToAssociativeCollection(refs, utils.getCamelCaseString(refValue), element);\r\n }\r\n });\r\n }\r\n\r\n return refs;\r\n}\r\n\r\nfunction findChildrenWithAttribute(element, attribute, namespace, id) {\r\n return scopedQuerySelectorAll(element, `[${getNamespacedAttributeName(attribute, namespace)}]`, namespace, id);\r\n}\r\n\r\nfunction getParentId(childElement, namespace) {\r\n return getNamespacedAttributeValue(childElement, DC_NAMESPACED_ATTRIBUTE_ID, namespace);\r\n}\r\n\r\nfunction getNamespacedAttributeValue(element, attribute, namespace) {\r\n return element.getAttribute(getNamespacedAttributeName(attribute, namespace));\r\n}\r\n\r\nfunction getNamespacedAttributeName(name, namespace) {\r\n return `${DC_NAMESPACE}-${namespace}-${name}`;\r\n}\r\n\r\nexport default {\r\n findElementsForInit,\r\n getElementId,\r\n getElementOptions,\r\n getElementRefs,\r\n getParentId,\r\n getNamespacedAttributeValue,\r\n findChildrenWithAttribute,\r\n isElementWithinLazyParent\r\n};\r\n","import dcDom from './dc-dom';\r\n\r\n/**\r\n * @typedef {string} ComponentState\r\n * */\r\n\r\n/**\r\n * @type {ComponentState}\r\n */\r\nconst COMPONENT_STATE_NOT_INITED = 'not-inited';\r\n/**\r\n * @type {ComponentState}\r\n */\r\nconst COMPONENT_STATE_INITIALIZING = 'initializing';\r\n/**\r\n * @type {ComponentState}\r\n */\r\nconst COMPONENT_STATE_LAZY_WAITING = 'lazy-waiting';\r\n/**\r\n * @type {ComponentState}\r\n */\r\nconst COMPONENT_STATE_CREATED = 'created';\r\n/**\r\n * @type {ComponentState}\r\n */\r\nconst COMPONENT_STATE_ERROR = 'error';\r\n/**\r\n * @type {ComponentState}\r\n */\r\nconst COMPONENT_STATE_DESTROYED = 'destroyed';\r\n\r\nclass DcFactory {\r\n constructor() {\r\n /**\r\n *\r\n * @type {{componentClass: typeof Component, selector: string}[]}\r\n * @private\r\n */\r\n this._registredComponents = [];\r\n\r\n /**\r\n *\r\n * @type {WeakMap>}\r\n * @private\r\n */\r\n this._elementsComponents = new WeakMap();\r\n\r\n /**\r\n *\r\n * @type {Component[]}\r\n * @private\r\n */\r\n this._instances = [];\r\n }\r\n\r\n /**\r\n *\r\n * @param {typeof Component} componentClass\r\n * @param {Function|string} selector that indicates how we should search that component elements\r\n */\r\n register(componentClass, selector = null) {\r\n this._registredComponents.push({\r\n componentClass,\r\n selector\r\n });\r\n }\r\n\r\n /**\r\n *\r\n * @param {HTMLElement} element\r\n * @param {typeof Component} componentClass\r\n * @return ComponentState\r\n * @private\r\n */\r\n _getComponentStateOnElement(element, componentClass) {\r\n const existedComponents = this._elementsComponents.get(element);\r\n return (existedComponents && existedComponents.get(componentClass)) || COMPONENT_STATE_NOT_INITED;\r\n }\r\n\r\n /**\r\n *\r\n * @param {HTMLElement} element\r\n * @param {typeof Component} componentClass\r\n * @param {ComponentState} state\r\n * @private\r\n */\r\n _setComponentStateOnElement(element, componentClass, state) {\r\n let componentsMap = this._elementsComponents.get(element);\r\n\r\n if (!componentsMap) {\r\n componentsMap = new Map();\r\n this._elementsComponents.set(element, componentsMap);\r\n }\r\n componentsMap.set(componentClass, state);\r\n }\r\n\r\n /**\r\n * Starts the factory on a given root: finds and creates all registered components within the root\r\n * @param {HTMLElement} root\r\n * @param {boolean} withLazy - Whether or not initialize component which marked as lazy\r\n */\r\n init(root = document.body, withLazy = true) {\r\n this._registredComponents.forEach(({ componentClass, selector }) => {\r\n this._initComponent(root, componentClass, selector, withLazy);\r\n });\r\n\r\n if (process.env.NODE_ENV === 'development') {\r\n // todo\r\n // find components which are declared in html as data-dc-component-*\r\n // but have no associated and registered components, throw warning\r\n }\r\n }\r\n\r\n /**\r\n *\r\n * @param {HTMLElement} root\r\n * @param {typeof Component} componentClass\r\n * @param {Function|string} selector\r\n * @param {boolean} withLazy\r\n * @private\r\n */\r\n _initComponent(root, componentClass, selector, withLazy) {\r\n try {\r\n const elements = dcDom.findElementsForInit(root, componentClass.getNamespace(), selector);\r\n if (elements.length > 0) {\r\n elements.forEach((element) => {\r\n this._initComponentOnElement(element, componentClass, withLazy);\r\n });\r\n }\r\n } catch (e) {\r\n // ignore current config error and move to the next one\r\n console.error(e);\r\n }\r\n }\r\n\r\n _isComponentLazy(element) {\r\n return dcDom.isElementWithinLazyParent(element);\r\n }\r\n\r\n /**\r\n * Init component class on elements\r\n * @param {HTMLElement} element\r\n * @param {typeof Component} componentClass\r\n * @param {boolean} withLazy\r\n * @private\r\n */\r\n _initComponentOnElement(element, componentClass, withLazy) {\r\n const state = this._getComponentStateOnElement(element, componentClass);\r\n switch (state) {\r\n // ignore components which are already created or in the middle of that process\r\n case COMPONENT_STATE_CREATED:\r\n case COMPONENT_STATE_ERROR:\r\n case COMPONENT_STATE_INITIALIZING:\r\n return;\r\n case COMPONENT_STATE_LAZY_WAITING:\r\n if (!withLazy) {\r\n return;\r\n }\r\n }\r\n\r\n // if component is lazy but we should not instantiate it according withLazy = false\r\n // we need to mark this component and wait until withLazy = true\r\n if (!withLazy && this._isComponentLazy(element)) {\r\n this._setComponentStateOnElement(element, componentClass, COMPONENT_STATE_LAZY_WAITING);\r\n return;\r\n }\r\n\r\n // finally init component on element\r\n this._setComponentStateOnElement(element, componentClass, COMPONENT_STATE_INITIALIZING);\r\n // TODO consider more sophisticated optimization technique\r\n setTimeout(() => {\r\n try {\r\n const instance = this._createComponentOnElement(componentClass, element);\r\n this._onComponentCreated(instance, componentClass);\r\n } catch (error) {\r\n this._onComponentCreationError(error, element, componentClass);\r\n }\r\n }, 0);\r\n }\r\n\r\n /**\r\n * @param {Component} instance\r\n * @param {typeof Component} componentClass\r\n * @private\r\n */\r\n _onComponentCreated(instance, componentClass) {\r\n this._setComponentStateOnElement(instance.getElement(), componentClass, COMPONENT_STATE_CREATED);\r\n this._instances = [...this._instances, instance];\r\n instance.init();\r\n }\r\n\r\n\r\n /**\r\n * @param {Error} error\r\n * @param {HTMLElement} element\r\n * @param {typeof Component} componentClass\r\n * @private\r\n */\r\n _onComponentCreationError(error, element, componentClass) {\r\n this._setComponentStateOnElement(element, componentClass, COMPONENT_STATE_ERROR);\r\n console.error(`Component ${componentClass.name} hasn't been created due to error: ${error.message}`, element);\r\n console.error(error);\r\n }\r\n\r\n /**\r\n *\r\n * @param {typeof Component} componentClass\r\n * @param {HTMLElement} element\r\n * @return {Component}\r\n * @private\r\n */\r\n _createComponentOnElement(componentClass, element) {\r\n const componentStateOnElement = this._getComponentStateOnElement(element, componentClass);\r\n\r\n switch (componentStateOnElement) {\r\n case COMPONENT_STATE_CREATED:\r\n throw new Error('Component of this class has already been created on this element');\r\n default:\r\n return new componentClass(element);\r\n }\r\n }\r\n\r\n /**\r\n * Destroy all previously registered components within the passed element\r\n * @param {HTMLElement} root\r\n */\r\n destroy(root) {\r\n this._instances = this._instances.filter((instance) => {\r\n if (instance.element === root || root.contains(instance.element)) {\r\n this._destroyComponent(instance);\r\n return false;\r\n }\r\n\r\n return true;\r\n });\r\n }\r\n\r\n /**\r\n *\r\n * @param {Component} component\r\n * @private\r\n */\r\n _destroyComponent(component) {\r\n this._setComponentStateOnElement(component.getElement(), component.constructor, COMPONENT_STATE_DESTROYED);\r\n component.destroy();\r\n }\r\n\r\n /**\r\n * Returns all components of componentClass which are contained within the passed element\r\n * @param {HTMLElement} element\r\n * @param {typeof Component} componentClass\r\n * @return Component[]\r\n */\r\n getChildComponents(element, componentClass) {\r\n return this._instances.filter((instance) => element.contains(instance.getElement()) && instance instanceof componentClass);\r\n }\r\n\r\n /**\r\n * Returns first found component of componentClass which is contained within the passed element\r\n * @param {HTMLElement} element\r\n * @param {typeof Component} componentClass\r\n * @return Component\r\n */\r\n getChildComponent(element, componentClass) {\r\n return this.getChildComponents(element, componentClass)[0];\r\n }\r\n\r\n /**\r\n * Returns all existing components on the passed element. Just for debugging purpose!\r\n * @param {HTMLElement} element\r\n * @return Component[]\r\n */\r\n debug(element) {\r\n return this._instances.filter((instance) => instance.getElement() === element);\r\n }\r\n}\r\n\r\n\r\nconst dcFactory = new DcFactory();\r\nexport default dcFactory;\r\n","const DEFAULT_RESIZE_DEBOUNCE = 100;\r\n\r\nclass DeviceObserver {\r\n constructor() {\r\n this._inited = false;\r\n this._devices = {};\r\n this._ascendingDevicesArray = [];\r\n this._deviceName = null;\r\n this._deviceIndex = null;\r\n this._deviceChangeCallbacks = [];\r\n\r\n this._resizeCallbacks = [];\r\n this._debounceTimeoutId = null;\r\n }\r\n\r\n /**\r\n * @param {Object} devices - Collection of devices and its breakpoints from which they start\r\n * For example: {\r\n * 'mobile': 0,\r\n * 'tablet': 768,\r\n * 'desktop:' 1024,\r\n * }\r\n * @param {Object} options\r\n */\r\n init(devices, options = {}) {\r\n this._setDevicesData(devices);\r\n this._resizeDebounce = 'resizeDebounce' in options ? options.resizeDebounce : DEFAULT_RESIZE_DEBOUNCE;\r\n this._mobileFirst = 'mobileFirst' in options ? options.mobileFirst : true;\r\n this._updateDeviceData();\r\n\r\n if (!this._inited) {\r\n this._inited = true;\r\n window.addEventListener('resize', this._onWindowResize.bind(this));\r\n }\r\n }\r\n\r\n /**\r\n * Apply desired format and save to the private variable\r\n * @param devices\r\n * @private\r\n */\r\n _setDevicesData(devices) {\r\n // save original devices\r\n this._devices = devices;\r\n // prepare an array of devices\r\n // make sure devices are sorted by breakpoints values [['mobile', 0], ['tablet', 768], ['desktop', 1024]]\r\n this._ascendingDevicesArray = Object.keys(devices).map((deviceName) => [deviceName, devices[deviceName]]).sort((a, b) => a[1] - b[1]);\r\n\r\n if (this._ascendingDevicesArray.length === 0) {\r\n throw new Error('No devices specified');\r\n }\r\n }\r\n\r\n _onWindowResize() {\r\n if (this._debounceTimeoutId !== null) {\r\n clearTimeout(this._debounceTimeoutId);\r\n }\r\n\r\n this._debounceTimeoutId = setTimeout(this._handleWindowResize.bind(this), this._resizeDebounce);\r\n }\r\n\r\n _handleWindowResize() {\r\n const oldDeviceType = this._deviceName;\r\n this._updateDeviceData();\r\n this._invokeResize();\r\n if (oldDeviceType !== this._deviceName) {\r\n this._invokeDeviceChange(this._deviceName, oldDeviceType);\r\n }\r\n }\r\n\r\n _checkDeviceNameRegistered(deviceName) {\r\n if (Object.keys(this._devices).indexOf(deviceName) === -1) {\r\n throw new Error(`Passes device name ${deviceName} was not found among registered: ${Object.keys(this._devices).join(', ')}`)\r\n }\r\n }\r\n\r\n _checkDevices() {\r\n if (this._ascendingDevicesArray.length === 0) {\r\n throw new Error('No devices specified');\r\n }\r\n\r\n if (this._mobileFirst && this._ascendingDevicesArray[0][1] !== 0) {\r\n throw new Error('The smallest device must have breakpoint equal 0 in case mobile-first approach is used');\r\n }\r\n\r\n if (!this._mobileFirst && this._ascendingDevicesArray[this._ascendingDevicesArray.length - 1][1] !== Infinity) {\r\n throw new Error('The greatest device name must have breakpoint equal Infinity in case desktop-first approach is used');\r\n }\r\n }\r\n\r\n _updateDeviceData() {\r\n this._checkDevices();\r\n\r\n let currentDevice;\r\n if (this._mobileFirst) {\r\n // reverse array because of mobile-first\r\n // create the new array before reverse not to mutate original one\r\n currentDevice = [...this._ascendingDevicesArray].reverse().find(deviceData => this._isGreaterOrEqual(deviceData[1]));\r\n } else {\r\n currentDevice = this._ascendingDevicesArray.find(deviceData => this._isLowerOrEqual(deviceData[1]));\r\n }\r\n\r\n this._deviceIndex = this._ascendingDevicesArray.indexOf(currentDevice);\r\n this._deviceName = currentDevice[0];\r\n }\r\n\r\n _invokeResize() {\r\n this._resizeCallbacks.forEach(cb => cb());\r\n }\r\n\r\n _invokeDeviceChange(newDeviceType, oldDeviceType) {\r\n this._deviceChangeCallbacks.forEach(cb => cb(newDeviceType, oldDeviceType));\r\n }\r\n\r\n _isGreaterOrEqual(pixelsValue) {\r\n return matchMedia(`only screen and (min-width:${pixelsValue}px)`).matches;\r\n }\r\n\r\n _isLowerOrEqual(pixelsValue) {\r\n // convert Infinity to some really big number\r\n // to make sure matchMedia below returns true in that case\r\n if (pixelsValue === Infinity) {\r\n pixelsValue = 100000;\r\n }\r\n return matchMedia(`only screen and (max-width:${pixelsValue}px)`).matches;\r\n }\r\n\r\n _getDeviceNameIndex(deviceName) {\r\n return this._ascendingDevicesArray.findIndex(deviceData => deviceData[0] === deviceName);\r\n }\r\n\r\n subscribeOnResize(cb) {\r\n this._resizeCallbacks.push(cb);\r\n\r\n // return unsubscribe method\r\n return () => {\r\n this._resizeCallbacks = this._resizeCallbacks.filter(storedCb => storedCb !== cb);\r\n };\r\n }\r\n\r\n subscribeOnChange(cb) {\r\n this._deviceChangeCallbacks.push(cb);\r\n\r\n // return unsubscribe method\r\n return () => {\r\n this._deviceChangeCallbacks = this._deviceChangeCallbacks.filter(storedCb => storedCb !== cb);\r\n };\r\n }\r\n\r\n is(operator, deviceName) {\r\n switch (operator) {\r\n case '=':\r\n return this.isMatch(deviceName);\r\n case '>':\r\n return this.isGt(deviceName);\r\n case '>=':\r\n return this.isGe(deviceName);\r\n case '<':\r\n return this.isLt(deviceName);\r\n case '<=':\r\n return this.isLe(deviceName);\r\n default:\r\n throw new Error('Unexpected operator received. You can use only the following: =, >, >=, <, <=');\r\n }\r\n }\r\n\r\n isMatch(deviceName) {\r\n this._checkDeviceNameRegistered(deviceName);\r\n return this._deviceName === deviceName;\r\n }\r\n\r\n isGt(deviceName) {\r\n this._checkDeviceNameRegistered(deviceName);\r\n return this._deviceIndex > this._getDeviceNameIndex(deviceName);\r\n }\r\n\r\n isGe(deviceName) {\r\n this._checkDeviceNameRegistered(deviceName);\r\n return this._deviceIndex >= this._getDeviceNameIndex(deviceName);\r\n }\r\n\r\n isLt(deviceName) {\r\n this._checkDeviceNameRegistered(deviceName);\r\n return this._deviceIndex < this._getDeviceNameIndex(deviceName);\r\n }\r\n\r\n isLe(deviceName) {\r\n this._checkDeviceNameRegistered(deviceName);\r\n return this._deviceIndex <= this._getDeviceNameIndex(deviceName);\r\n }\r\n\r\n // todo consider removing\r\n /**\r\n * @param {number} value - width in pixels to compare with\r\n * @return {boolean}\r\n */\r\n isGeCustom(value) {\r\n return this._isGreaterOrEqual(value);\r\n }\r\n}\r\n\r\nexport default DeviceObserver;\r\n","import DeviceObserver from './device-observer';\r\n\r\nconst deviceObserver = new DeviceObserver();\r\nexport { deviceObserver, DeviceObserver };\r\n","// This file replaces `index.js` in bundlers like webpack or Rollup,\n// according to `browser` config in `package.json`.\n\nimport { urlAlphabet } from './url-alphabet/index.js'\n\nif (process.env.NODE_ENV !== 'production') {\n // All bundlers will remove this block in the production bundle.\n if (\n typeof navigator !== 'undefined' &&\n navigator.product === 'ReactNative' &&\n typeof crypto === 'undefined'\n ) {\n throw new Error(\n 'React Native does not have a built-in secure random generator. ' +\n 'If you don’t need unpredictable IDs use `nanoid/non-secure`. ' +\n 'For secure IDs, import `react-native-get-random-values` ' +\n 'before Nano ID. If you use Expo, install `expo-random` ' +\n 'and use `nanoid/async`.'\n )\n }\n if (typeof msCrypto !== 'undefined' && typeof crypto === 'undefined') {\n throw new Error(\n 'Import file with `if (!window.crypto) window.crypto = window.msCrypto`' +\n ' before importing Nano ID to fix IE 11 support'\n )\n }\n if (typeof crypto === 'undefined') {\n throw new Error(\n 'Your browser does not have secure random generator. ' +\n 'If you don’t need unpredictable IDs, you can use nanoid/non-secure.'\n )\n }\n}\n\nlet random = bytes => crypto.getRandomValues(new Uint8Array(bytes))\n\nlet customRandom = (alphabet, size, getRandom) => {\n // First, a bitmask is necessary to generate the ID. The bitmask makes bytes\n // values closer to the alphabet size. The bitmask calculates the closest\n // `2^31 - 1` number, which exceeds the alphabet size.\n // For example, the bitmask for the alphabet size 30 is 31 (00011111).\n // `Math.clz32` is not used, because it is not available in browsers.\n let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1\n // Though, the bitmask solution is not perfect since the bytes exceeding\n // the alphabet size are refused. Therefore, to reliably generate the ID,\n // the random bytes redundancy has to be satisfied.\n\n // Note: every hardware random generator call is performance expensive,\n // because the system call for entropy collection takes a lot of time.\n // So, to avoid additional system calls, extra bytes are requested in advance.\n\n // Next, a step determines how many random bytes to generate.\n // The number of random bytes gets decided upon the ID size, mask,\n // alphabet size, and magic number 1.6 (using 1.6 peaks at performance\n // according to benchmarks).\n\n // `-~f => Math.ceil(f)` if f is a float\n // `-~i => i + 1` if i is an integer\n let step = -~((1.6 * mask * size) / alphabet.length)\n\n return () => {\n let id = ''\n while (true) {\n let bytes = getRandom(step)\n // A compact alternative for `for (var i = 0; i < step; i++)`.\n let j = step\n while (j--) {\n // Adding `|| ''` refuses a random byte that exceeds the alphabet size.\n id += alphabet[bytes[j] & mask] || ''\n // `id.length + 1 === size` is a more compact option.\n if (id.length === +size) return id\n }\n }\n }\n}\n\nlet customAlphabet = (alphabet, size) => customRandom(alphabet, size, random)\n\nlet nanoid = (size = 21) => {\n let id = ''\n let bytes = crypto.getRandomValues(new Uint8Array(size))\n\n // A compact alternative for `for (var i = 0; i < step; i++)`.\n while (size--) {\n // It is incorrect to use bytes exceeding the alphabet size.\n // The following mask reduces the random byte in the 0-255 value\n // range to the 0-63 value range. Therefore, adding hacks, such\n // as empty string fallback or magic numbers, is unneccessary because\n // the bitmask trims bytes down to the alphabet size.\n let byte = bytes[size] & 63\n if (byte < 36) {\n // `0-9a-z`\n id += byte.toString(36)\n } else if (byte < 62) {\n // `A-Z`\n id += (byte - 26).toString(36).toUpperCase()\n } else if (byte < 63) {\n id += '_'\n } else {\n id += '-'\n }\n }\n return id\n}\n\nexport { nanoid, customAlphabet, customRandom, urlAlphabet, random }\n"],"sourceRoot":""}