{"version":3,"sources":["webpack://woocommerce-multicurrency/./src/WOOMC/Frontend/src/frontend.js","webpack://woocommerce-multicurrency/./src/WOOMC/Frontend/src/Cache.js","webpack://woocommerce-multicurrency/./src/WOOMC/Frontend/src/Console.js","webpack://woocommerce-multicurrency/./src/WOOMC/Frontend/src/Cookie.js","webpack://woocommerce-multicurrency/./src/WOOMC/Frontend/src/CurrencyCookie.js","webpack://woocommerce-multicurrency/./src/WOOMC/Frontend/src/Page.js","webpack://woocommerce-multicurrency/./src/WOOMC/Frontend/src/Prerequisites.js","webpack://woocommerce-multicurrency/./src/WOOMC/Frontend/src/Reloaded.js","webpack://woocommerce-multicurrency/webpack/bootstrap"],"names":["MODULE","Prerequisites","CurrencyCookie","Cache","Console","require","module","exports","bust","navigator","cookieEnabled","window","location","search","indexOf","debug","Reloaded","isSet","unset","history","replaceState","href","notAsCached","Page","reload","error","formatMessage","msg","formatData","level","theTrace","Error","stack","split","shift","Date","toLocaleString","printMessage","woomc","console_log","console","info","log","warn","get","name","theCookie","document","cookie","find","row","startsWith","Cookie","cookieSettings","set","currency","expires","activeCookie","jQuery","currentURL","appendTo","body","submit","met","RELOADED_NAME","some","item","trim","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","$","settings","woocommerce_default_customer_address","referrer","trigger"],"mappings":"gBAWMA,EAEAC,EACAC,EACAC,EACAC,E,uBCZN,IAAMA,EAAUC,EAAQ,KAmDxBC,EAAOC,QAAU,CAChBC,KAzCY,WAEZ,GAAKC,UAAUC,cAQf,GAAIC,OAAOC,SAASC,OAAOC,QAAQ,aAAe,EACjDV,EAAQW,MACP,oEAFF,CAWA,IAAMC,EAAWX,EAAQ,KACzB,GAAIW,EAASC,QAOZ,OANAD,EAASE,aAGLP,OAAOQ,QAAQC,cAClBT,OAAOQ,QAAQC,aAAa,KAAM,KAAMT,OAAOC,SAASS,OAM1D,GADuBhB,EAAQ,KACZiB,cAAe,CACjC,IAAMC,EAAOlB,EAAQ,KACr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QAGrB,IAAID,EAAS8D,EAAyBE,GAAY,CAGjD/D,QAAS,CAAC,GAOX,OAHAkE,EAAoBH,GAAUhE,EAAQA,EAAOC,QAAS8D,GAG/C/D,EAAOC,OACf,CRXMP,EAAS,OAETC,EAAgBI,EAAQ,KACxBH,EAAiBG,EAAQ,KACzBF,EAAQE,EAAQ,KAChBD,EAAUC,EAAQ,KAExBqD,QAAO,SAAUgB,GAEXzE,EAAc8D,QAsBnB3D,EAAQW,MAAM,IAAD,OAAKf,EAAM,yBAAiBsC,MAAMqC,SAASC,uCACxDxE,EAAQW,MAAM,IAAD,OAAKf,EAAM,+BAAuBsC,MAAMiB,SAAQ,uBAAerD,EAAe0C,QAO3FzC,EAAMK,QAS4C,IAAjDG,OAAOC,SAASC,OAAOC,QAAQ,eACiC,IAA7DiC,SAAS8B,SAAS/D,QAAQ,YAAD,OAAawB,MAAMiB,aAE/CmB,EAAE3B,SAASc,MAAMiB,QAAQ,uBACzB1E,EAAQW,MAAM,0DAGfX,EAAQW,MAAM,IAAD,OAAKf,EAAM,eACzB,G","file":"frontend.js","sourcesContent":["/**\n * JS to handle the currency selector.\n *\n * @package WooCommerce-MultiCurrency\n *\n * @since 1.17.0\n *\n * Copyright (c) 2019, TIV.NET INC. All Rights Reserved.\n */\n/*global woomc*/\n\nconst MODULE = \"ROOT\";\n\nconst Prerequisites = require(\"./Prerequisites\");\nconst CurrencyCookie = require(\"./CurrencyCookie\");\nconst Cache = require(\"./Cache\");\nconst Console = require(\"./Console\");\n\njQuery(function ($) {\n\n\tif (!Prerequisites.met()) {\n\t\treturn;\n\t}\n\n\t/**\n\t * @namespace woomc\n\t * @property {string} currentURL\n\t * @property {string} currency\n\t * @property {Object} cookieSettings\n\t * @property {string} cookieSettings.name\n\t * @property {number} cookieSettings.expires\n\t * @property {string} console_log\n\t * @property {string} settings\n\t * @property {string} settings.woocommerce_default_customer_address\n\t */\n\n\t/**\n\t * @namespace woomc_currency_selector\n\t * @property {string} currencySelectorDOM\n\t * @property {string} url.currencySelectorCSS\n\t */\n\n\tConsole.debug(`[${MODULE}] Geolocation=${woomc.settings.woocommerce_default_customer_address}`);\n\tConsole.debug(`[${MODULE}] Currency: on page=${woomc.currency}, in cookie=${CurrencyCookie.get()}`);\n\n\t/**\n\t * Check if we need to reload the outdated cached page.\n\t *\n\t * @since 1.20.1\n\t */\n\tCache.bust();\n\n\t/**\n\t * Refresh fragments when URL contains \"currency=...\" and it's not repeated (referer).\n\t * Otherwise, the mini-cart keeps the old currency.\n\t *\n\t * @since 2.8.2\n\t */\n\tif (\n\t\twindow.location.search.indexOf(\"currency=\") !== -1\n\t\t&& document.referrer.indexOf(`currency=${woomc.currency}`) === -1\n\t) {\n\t\t$(document.body).trigger(\"wc_fragment_refresh\");\n\t\tConsole.debug('Currency switch in URL detected. Refreshed fragments.');\n\t}\n\n\tConsole.debug(`[${MODULE}] The End.`);\n});\n","/*\n * Copyright (c) 2020, TIV.NET INC. All Rights Reserved.\n */\n\nconst Console = require('./Console');\n\n/**\n * If the body class' currency does not match the currency cookie,\n * we assume that the page is cached. We'll try to reload it.\n *\n * @since 1.20.1\n * @since 1.20.2 Check for a special cookie because not all themes have the body class filter.\n * @since 2.0.0 Do not use body class for checking. Use the woomc.currency var set by backend.\n * @since 2.6.3 Ignore browsers with cookies disabled.\n */\nconst bust = () => {\n\t// Browser with cookies disabled. Cannot help.\n\tif (!navigator.cookieEnabled) {\n\t\tConsole.error(\n\t\t\t'Cookies disabled in the browser. Cache buster will not work.',\n\t\t);\n\t\treturn;\n\t}\n\n\t// Currency is set via URL. No additional processing is needed.\n\tif (window.location.search.indexOf('currency=') > 0) {\n\t\tConsole.debug(\n\t\t\t'Currency is set via URL. No additional processing is needed.',\n\t\t);\n\t\treturn;\n\t}\n\n\t/**\n\t * The `reloaded` cookie tells that the page was just reloaded.\n\t * To avoid endless loop, we check for it and do not reload.\n\t */\n\tconst Reloaded = require('./Reloaded');\n\tif (Reloaded.isSet()) {\n\t\tReloaded.unset();\n\t\t// Also, we try a trick to make the browser forget that we reloaded using a POST.\n\t\t// Otherwise, if people try F5, the browser prompts for form re-submission.\n\t\tif (window.history.replaceState) {\n\t\t\twindow.history.replaceState(null, null, window.location.href);\n\t\t}\n\t\treturn;\n\t}\n\n\tconst CurrencyCookie = require('./CurrencyCookie');\n\tif (CurrencyCookie.notAsCached()) {\n\t\tconst Page = require('./Page');\n\t\tConsole.debug('Reloading page...');\n\t\tPage.reload();\n\t}\n};\n\nmodule.exports = {\n\tbust,\n};\n","/**\n * Browser console API.\n * @since 2.6.3\n * Copyright (c) 2020, TIV.NET INC. All Rights Reserved.\n */\n\n/**\n * @namespace woomc\n * @property {string} currentURL\n * @property {string} currency\n * @property {Object} cookieSettings\n * @property {string} cookieSettings.name\n * @property {number} cookieSettings.expires\n * @property {string} console_log\n * @property {string} settings\n * @property {string} settings.woocommerce_default_customer_address\n */\n\n/**\n * @namespace woomc_currency_selector\n * @property {string} currencySelectorDOM\n * @property {string} url.currencySelectorCSS\n */\n\nconst LABEL = \"WooCommerce-Multicurrency-Frontend\";\n\n/**\n * To activate console messages, need to set a cookie.\n * @returns {boolean}\n */\nconst isActive = () => \"object\" === typeof woomc && \"Y\" === woomc.console_log;\n\n/**\n * Format the message.\n * @param {string} msg Raw message.\n * @returns {string}\n */\nconst formatMessage = (msg) => `[${LABEL}] ${msg}`;\n\n/**\n * Format the data object attached to the message.\n * @param {string} level Severity.\n * @param {string} msg Raw message.\n * @returns {{msg: string, trace: string[], level: string, url: string, timestamp: string}}\n */\nconst formatData = (level, msg) => {\n\tlet theTrace = new Error().stack.split(\"\\n\");\n\ttheTrace.shift();\n\n\treturn {\n\t\t\"level\": level,\n\t\t// \"msg\": msg,\n\t\t\"timestamp\": new Date().toLocaleString(),\n\t\t\"url\": window.location.href,\n\t\t\"trace\": theTrace\n\t}\n};\n\n/**\n * Print the console message.\n * @param {string} msg Raw message.\n * @param {string} level Severity.\n */\nconst printMessage = (msg, level) => {\n\tif (!isActive()) {\n\t\treturn;\n\t}\n\n\tswitch (level) {\n\t\tcase \"DEBUG\":\n\t\t\tconsole.debug(formatMessage(msg), formatData(level, msg));\n\t\t\tbreak;\n\t\tcase \"ERROR\":\n\t\t\tconsole.error(formatMessage(msg), formatData(level, msg));\n\t\t\tbreak;\n\t\tcase \"INFO\":\n\t\t\tconsole.info(formatMessage(msg), formatData(level, msg));\n\t\t\tbreak;\n\t\tcase \"LOG\":\n\t\t\tconsole.log(formatMessage(msg), formatData(level, msg));\n\t\t\tbreak;\n\t\tcase \"WARN\":\n\t\t\tconsole.warn(formatMessage(msg), formatData(level, msg));\n\t\t\tbreak;\n\t\tdefault:\n\t\t// Do nothing.\n\t}\n};\n\n/**\n * Display console message.\n * @param msg The message text.\n */\nconst debug = (msg) => printMessage(msg, \"DEBUG\");\nconst error = (msg) => printMessage(msg, \"ERROR\");\nconst info = (msg) => printMessage(msg, \"INFO\");\nconst log = (msg) => printMessage(msg, \"LOG\");\nconst warn = (msg) => printMessage(msg, \"WARN\");\n\nmodule.exports = {\n\tdebug,\n\terror,\n\tinfo,\n\tlog,\n\twarn\n};\n","/**\n * Cookie handling.\n * @since 2.6.3\n * Copyright (c) 2020, TIV.NET INC. All Rights Reserved.\n */\n\n/**\n * Get a cookie value.\n * @param {string} name Name of the cookie.\n * @returns {string} The value or empty string if not found.\n */\nconst get = (name) => {\n\tconst theCookie = document.cookie\n\t\t.split('; ')\n\t\t.find(row => row.startsWith(`${name}=`));\n\n\treturn theCookie ? theCookie.split('=')[1] : \"\";\n};\n\nmodule.exports = {\n\tget\n};\n","/*\n * Copyright (c) 2020, TIV.NET INC. All Rights Reserved.\n */\n\n/**\n * @namespace woomc\n * @property {Object} cookieSettings\n * @property {string} cookieSettings.name\n */\n\nconst MODULE = \"CurrencyCookie\";\n\nconst Console = require(\"./Console\");\nconst Cookie = require(\"./Cookie\");\n\n/**\n * Save currency in cookie.\n *\n * @param {string} currency The currency code.\n */\nconst set = (currency) => {\n\tdocument.cookie = `${woomc.cookieSettings.name}=${currency};path=/;max-age=${woomc.cookieSettings.expires};samesite=strict`;\n};\n\nconst get = () => Cookie.get(woomc.cookieSettings.name);\n\nconst notAsCached = () => {\n\n\tconst activeCookie = get();\n\n\tConsole.debug(`[${MODULE}] Cookies: active=${activeCookie}; woomc.currency=${woomc.currency}`);\n\n\tif (activeCookie !== woomc.currency) {\n\t\tConsole.debug(\"activeCookie !== woomc.currency\");\n\t\treturn true;\n\t}\n\n\treturn false;\n}\n\n\nmodule.exports = {\n\tget,\n\tset,\n\tnotAsCached\n};\n","/*\n * Copyright (c) 2020, TIV.NET INC. All Rights Reserved.\n */\n\n/**\n * @namespace woomc\n * @property {string} currentURL\n */\n\n/**\n * Force reloading page from the server.\n *\n * @since 1.20.1\n * @since 1.20.2 Set also a special cookie because not all themes have the body class filter.\n */\n\nconst reload = () => {\n\n\trequire(\"./Reloaded\").set();\n\n\tjQuery(\"
\",\n\t\t{\n\t\t\t\"method\": \"post\",\n\t\t\t\"action\": woomc.currentURL\n\t\t}\n\t)\n\t\t.appendTo(document.body)\n\t\t.submit()\n\t;\n};\n\nmodule.exports = {\n\treload\n};\n","/*\n * Copyright (c) 2020, TIV.NET INC. All Rights Reserved.\n */\n\n/**\n * @namespace woomc\n */\n\nconst Console = require(\"./Console\");\n\n/**\n * Check if prerequisites met.\n * @returns {boolean}\n */\nconst met = () => {\n\n\tif (\"undefined\" === typeof woomc) {\n\t\tConsole.error(\"Internal Error: Undefined 'woomc'.\");\n\t\t// disableCurrencySelectors();\n\t\treturn false;\n\t}\n\n\t// Browser with cookies disabled.\n\tif (!navigator.cookieEnabled) {\n\t\tConsole.error(\"Cookies disabled in the browser. Currency selector will not work.\");\n\t\t// disableCurrencySelectors();\n\t\treturn false;\n\t}\n\n\tConsole.debug(\"Frontend prerequisites met.\");\n\treturn true;\n\n};\n\n// const disableCurrencySelectors = () => {\n// \tdocument\n// \t\t.querySelectorAll(\".woocommerce-currency-selector\")\n// \t\t.forEach(selector => {\n// \t\t\tselector.disabled = true;\n// \t\t\tselector.style.opacity = \".2\";\n// \t\t})\n// \t;\n// }\n\nmodule.exports = {\n\tmet\n};\n","/*\n * Copyright (c) 2020, TIV.NET INC. All Rights Reserved.\n */\n\nconst RELOADED_NAME = \"woocommerce-multicurrency-reloaded\";\n\nconst set = () => {\n\tdocument.cookie = `${RELOADED_NAME}=1;samesite=strict`;\n};\n\nconst unset = () => {\n\tdocument.cookie = `${RELOADED_NAME}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;samesite=strict`;\n};\n\nconst isSet = () => {\n\treturn document.cookie.split(\";\").some((item) => item.trim().startsWith(`${RELOADED_NAME}=`))\n};\n\nmodule.exports = {\n\tset,\n\tunset,\n\tisSet\n};\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n"],"sourceRoot":""}