\r\n )\r\n};\r\n\r\nexport default Page;","export const COOKIES = 'cookies';\r\nexport const SESSION_STORAGE = 'session-storage';\r\nexport const LOCAL_STORAGE = 'local-storage';\r\n\r\n/**\r\n * check if storage type is enabled\r\n * storageType - 'local-storage', 'session-storage', or 'cookies'\r\n */\r\nexport const isStorageEnabled = (storageType: string) => {\r\n\r\n if(storageType === COOKIES) return true;\r\n\r\n if(storageType === LOCAL_STORAGE){\r\n\r\n const temp = 'test';\r\n\r\n try {\r\n window.localStorage.setItem(temp, temp);\r\n window.localStorage.removeItem(temp);\r\n return true;\r\n }\r\n catch(e) {\r\n return false;\r\n }\r\n }\r\n\r\n if(storageType === SESSION_STORAGE){\r\n\r\n const temp = 'test';\r\n\r\n try {\r\n window.sessionStorage.setItem(temp, temp);\r\n window.sessionStorage.removeItem(temp);\r\n return true;\r\n }\r\n catch(e) {\r\n return false;\r\n }\r\n }\r\n\r\n return false;\r\n};\r\n\r\n/**\r\n * set cookie\r\n * expiration - cookie expiration in minutes (-1 = cookie expires when browser is closed)\r\n * samesite - strict or lax\r\n */\r\nexport const setCookie = (\r\n name: string,\r\n value: any,\r\n expiration: number = -1,\r\n secure: boolean = false,\r\n samesite: string|undefined = undefined,\r\n preventStringify: boolean = false,\r\n domain?: string, // .waves.com\r\n) => {\r\n\r\n const escapedValue = encodeURIComponent(preventStringify ? value : JSON.stringify(value));\r\n const exp = Number(expiration) || -1;\r\n let cookieString = '';\r\n\r\n const domainValue = domain ? `domain=${ domain };` : '';\r\n\r\n if(exp === -1) {\r\n\r\n // cookie expires when browser is closed\r\n // If neither expires nor max-age specified the cookie will expire at the end of session.\r\n cookieString = `${ name }=${ escapedValue };path=/;${ domainValue }`;\r\n }\r\n else{\r\n const date = new Date();\r\n date.setMinutes(date.getMinutes() + expiration);\r\n\r\n // option to set expiration in days:\r\n //864e5 = 86400000 = 1000*60*60*24 represents the number of milliseconds in a 24 hour day.\r\n //date.setTime(date.getTime() + (days * 864e5));\r\n\r\n const expires = date.toUTCString();\r\n cookieString = `${ name }=${ escapedValue };path=/;${ domainValue }expires=${ expires }`;\r\n }\r\n\r\n if(samesite){\r\n // The strict value will prevent the cookie from being sent by the browser to the target site in all cross-site browsing context, even when following a regular link.\r\n // The lax value will only send cookies for TOP LEVEL navigation GET requests. This is sufficient for user tracking, but it will prevent many CSRF attacks.\r\n cookieString += `;samesite=${samesite}`;\r\n }\r\n\r\n if(secure){\r\n // Cookie to only be transmitted over secure protocol as https. Before Chrome 52, this flag could appear with cookies from http domains.\r\n cookieString += ';secure';\r\n }\r\n\r\n document.cookie = cookieString;\r\n};\r\n\r\n/**\r\n * Get cookie by name\r\n */\r\nexport const getCookie = (name: string) => {\r\n\r\n const cookies = document.cookie.split(';');\r\n\r\n for (let i=0; i {\r\n const escapedValue = encodeURIComponent(JSON.stringify(value));\r\n window.localStorage.setItem(storageName, escapedValue);\r\n};\r\n\r\n/**\r\n * get a value to the local storage\r\n */\r\nexport const getLocalStorageItem = (storageName: string) => {\r\n const value = window.localStorage.getItem(storageName) as string;\r\n return decodeURIComponent(value);\r\n};\r\n\r\n/**\r\n * save a value to the session storage\r\n */\r\nexport const setSessionStorageItem = (storageName: string, value: any) => {\r\n const escapedValue = encodeURIComponent(JSON.stringify(value));\r\n window.sessionStorage.setItem(storageName, escapedValue);\r\n};\r\n\r\n/**\r\n * get a value to the session storage\r\n */\r\nexport const getSessionStorageItem = (storageName: string) => {\r\n const value = window.sessionStorage.getItem(storageName) as string;\r\n return decodeURIComponent(value);\r\n};\r\n\r\n/**\r\n * save to web storage or cookies\r\n * storageType - 'local-storage', 'session-storage', or 'cookies'\r\n * cookiesExpiration - cookies expiration in minutes (-1 = cookies expire when browser is closed)\r\n */\r\nexport const saveToStorage = (storageType: string, storageName: any, value: any, cookiesExpiration: number = -1) => {\r\n\r\n // if this storage type is not supported -> do nothing\r\n if(!isStorageEnabled(storageType)) return;\r\n\r\n if(storageType === COOKIES) {\r\n setCookie(storageName, value, cookiesExpiration);\r\n }\r\n\r\n if(storageType === LOCAL_STORAGE) {\r\n setLocalStorageItem(storageName, value);\r\n }\r\n\r\n if(storageType === SESSION_STORAGE) {\r\n setSessionStorageItem(storageName, value);\r\n }\r\n};\r\n\r\n/**\r\n * get value from storage\r\n * storageType - 'local-storage', 'session-storage', or 'cookies'\r\n */\r\nexport const getFromStorage = (storageType: string, storageName: string) : string|null => {\r\n\r\n // if this storage type is not supported -> do nothing\r\n if(!isStorageEnabled(storageType)) return null;\r\n\r\n if(storageType === COOKIES) {\r\n return getCookie(storageName);\r\n }\r\n\r\n if(storageType === LOCAL_STORAGE) {\r\n return getLocalStorageItem(storageName);\r\n }\r\n\r\n if(storageType === SESSION_STORAGE) {\r\n return getSessionStorageItem(storageName);\r\n }\r\n\r\n return null;\r\n};\r\n\r\n/**\r\n * if storage already exists, append to it, otherwise create a new one\r\n * storageType - 'local-storage', 'session-storage', or 'cookies'\r\n * storageName - it is used like key name in web storage, or like cookie name\r\n * this is a property name that is used to store the value inside the general widgets object\r\n * value - the value that should be stored\r\n * cookiesExpiration - cookies expiration in minutes (-1 = cookies expire when browser is closed)\r\n */\r\nexport const appendToStorage = (storageType: string, storageName: string, key: string, value: any, cookiesExpiration: number = -1) => {\r\n\r\n let data = getFromStorage(storageType, storageName) as any;\r\n\r\n try{\r\n data = JSON.parse(data);\r\n }\r\n catch(err){}\r\n\r\n if(!data) {\r\n\r\n // create new entry\r\n data = {\r\n [key]: value\r\n };\r\n }\r\n else{\r\n // append the entry\r\n data[key] = value;\r\n }\r\n\r\n // overwrite the storage\r\n saveToStorage(storageType, storageName, data, cookiesExpiration = -1);\r\n};","import ReactDOM from 'react-dom';\r\nimport React from 'react';\r\nimport Page from './ui/page';\r\n\r\n/**\r\n * entry point\r\n * https://dev.waves.com/r/yl6wb1tw\r\n * https://wavesaudio.atlassian.net/browse/DSWEB-3172\r\n */\r\nconst init = () => {\r\n const $root = document.getElementById('refer-redirect-app');\r\n if (!$root) return;\r\n\r\n ReactDOM.render(\r\n \r\n \r\n ,\r\n $root\r\n );\r\n};\r\n\r\ndocument.addEventListener('DOMContentLoaded', () => {\r\n init();\r\n});\r\n\r\nexport {}"],"names":["__webpack_require__","module","getter","__esModule","d","a","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","ReactDOM","React","props","role","className","classes","xmlns","width","height","viewBox","style","fill","color","Channel","getRedirectData","async","shortURL","channelID","url","data","qs","params","push","window","encodeURIComponent","join","encodeData","headers","Headers","append","response","fetch","method","credentials","status","location","href","ifShouldDenyOnReadOnly","Error","json","statusCode","useEffect","DEFAULT_REDIRECT","parsed","pathname","indexOf","part","replace","endsWith","substring","length","suffix","channelName","purl","facebook","twitter","email","parseReferUrl","isValid","relatedData","clickGUID","redirectURL","name","value","expiration","secure","samesite","undefined","domain","escapedValue","JSON","stringify","exp","Number","cookieString","domainValue","date","Date","setMinutes","getMinutes","expires","toUTCString","document","cookie","setCookie","cookieExpiration","addEventListener","$root","getElementById","init"],"sourceRoot":""}