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;WACA;WACA,MAAM,qBAAqB;WAC3B;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAEA;WACA;WACA;;;;;UEjDA;UACA;UACA;UACA;UACA","sources":["webpack://woo-wallet/./src/partial-payment/index.js","webpack://woo-wallet/./src/partial-payment/style.scss","webpack://woo-wallet/external window \"React\"","webpack://woo-wallet/external window [\"wc\",\"blocksCheckout\"]","webpack://woo-wallet/external window [\"wc\",\"blocksComponents\"]","webpack://woo-wallet/external window [\"wc\",\"wcSettings\"]","webpack://woo-wallet/external window [\"wp\",\"element\"]","webpack://woo-wallet/external window [\"wp\",\"htmlEntities\"]","webpack://woo-wallet/external window [\"wp\",\"i18n\"]","webpack://woo-wallet/external window [\"wp\",\"plugins\"]","webpack://woo-wallet/webpack/bootstrap","webpack://woo-wallet/webpack/runtime/chunk loaded","webpack://woo-wallet/webpack/runtime/compat get default export","webpack://woo-wallet/webpack/runtime/define property getters","webpack://woo-wallet/webpack/runtime/hasOwnProperty shorthand","webpack://woo-wallet/webpack/runtime/make namespace object","webpack://woo-wallet/webpack/runtime/jsonp chunk loading","webpack://woo-wallet/webpack/before-startup","webpack://woo-wallet/webpack/startup","webpack://woo-wallet/webpack/after-startup"],"sourcesContent":["/**\n * External dependencies\n */\nimport { registerPlugin } from '@wordpress/plugins';\nimport { ExperimentalOrderMeta, ExperimentalDiscountsMeta } from '@woocommerce/blocks-checkout';\nimport { getSetting } from '@woocommerce/settings';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useState } from '@wordpress/element';\nimport {\n\tPanel,\n\tValidatedTextInput,\n\tValidationInputError,\n\tButton\n} from '@woocommerce/blocks-components';\n\n/**\n * Internal dependencies\n */\nimport './style.scss';\n\nconst { extensionCartUpdate } = window.wc.blocksCheckout;\nconst settings = getSetting('partial-payment_data');\n\nconst render = () => {\n\tconst [partialPaymentAmount, setPartialPaymentAmount] = settings.partial_payment_amount ? useState(settings.partial_payment_amount) : useState('');\n\tconst [showSpinner, setShowSpinner] = useState(false);\n\tconst textInputId = `wc-block-components-partial-payment_input`;\n\tconst buttonClickHandler = (e) => {\n\t\te.preventDefault();\n\t\tsetShowSpinner(true);\n\t\textensionCartUpdate({\n\t\t\tnamespace: 'apply-partial-payment',\n\t\t\tdata: {\n\t\t\t\t'amount': partialPaymentAmount,\n\t\t\t},\n\t\t}).then( () => {\n\t\t\tsetShowSpinner(false);\n\t\t});\n\t};\n\n\tconst formatedBalance = () => {\n\t\tconst { balance, currency_symbol, decimal_separator, thousand_separator, decimals } = settings;\n\t\t// Ensure that 'amount' is a valid number\n\t\tlet numericAmount = parseFloat(balance);\n\t\tif (isNaN(numericAmount)) {\n\t\t\treturn amount; // Return the original value if it's not a valid number\n\t\t}\n\t\t// Format the amount to the required number of decimal places\n\t\tlet fixedAmount = numericAmount.toFixed(decimals);\n\t\t// Split the integer and decimal parts\n\t\tlet parts = fixedAmount.split('.');\n\t\t// Add thousand separator to the integer part only\n\t\tparts[0] = parts[0].replace(/\\B(?=(\\d{3})+(?!\\d))/g, thousand_separator);\n\t\t// Rejoin integer and decimal parts with the correct decimal separator\n\t\tlet formattedAmount = parts.join(decimal_separator);\n\t\treturn decodeEntities(`${currency_symbol}${formattedAmount}`);\n\t}\n\n\treturn (\n\t\t\n\t\t\t{settings.active ? (\n\t\t\t\t\n\t\t\t\t\t\t\t{ /* translators: 1: Wallet amount */ sprintf(__('You have %s in your wallet to spend!', 'woo-wallet'), formatedBalance())}\n\t\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t{__(\"Enter the amount you'd like to redeem\", \"woo-wallet\")}\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\n\t\t\t\t\t\t\t {\n\t\t\t\t\t\t\t\t\tsetPartialPaymentAmount(newPartialPaymentAmount);\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\tfocusOnMount={false}\n\t\t\t\t\t\t\t\tvalidateOnMount={false}\n\t\t\t\t\t\t\t\tshowError={false}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t{__(\n\t\t\t\t\t\t\t\t\t'Apply',\n\t\t\t\t\t\t\t\t\t'woo-wallet'\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\n\t\t\t) : (<>)}\n\t\t
\n\t);\n};\n\nregisterPlugin('partial-payment-block', {\n\trender,\n\tscope: 'woocommerce-checkout',\n});","// extracted by mini-css-extract-plugin\nexport {};","module.exports = window[\"React\"];","module.exports = window[\"wc\"][\"blocksCheckout\"];","module.exports = window[\"wc\"][\"blocksComponents\"];","module.exports = window[\"wc\"][\"wcSettings\"];","module.exports = window[\"wp\"][\"element\"];","module.exports = window[\"wp\"][\"htmlEntities\"];","module.exports = window[\"wp\"][\"i18n\"];","module.exports = window[\"wp\"][\"plugins\"];","// 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// expose the modules object (__webpack_modules__)\n__webpack_require__.m = __webpack_modules__;\n\n","var deferred = [];\n__webpack_require__.O = (result, chunkIds, fn, priority) => {\n\tif(chunkIds) {\n\t\tpriority = priority || 0;\n\t\tfor(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1];\n\t\tdeferred[i] = [chunkIds, fn, priority];\n\t\treturn;\n\t}\n\tvar notFulfilled = Infinity;\n\tfor (var i = 0; i < deferred.length; i++) {\n\t\tvar [chunkIds, fn, priority] = deferred[i];\n\t\tvar fulfilled = true;\n\t\tfor (var j = 0; j < chunkIds.length; j++) {\n\t\t\tif ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every((key) => (__webpack_require__.O[key](chunkIds[j])))) {\n\t\t\t\tchunkIds.splice(j--, 1);\n\t\t\t} else {\n\t\t\t\tfulfilled = false;\n\t\t\t\tif(priority < notFulfilled) notFulfilled = priority;\n\t\t\t}\n\t\t}\n\t\tif(fulfilled) {\n\t\t\tdeferred.splice(i--, 1)\n\t\t\tvar r = fn();\n\t\t\tif (r !== undefined) result = r;\n\t\t}\n\t}\n\treturn result;\n};","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter 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\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","// no baseURI\n\n// object to store loaded and loading chunks\n// undefined = chunk not loaded, null = chunk preloaded/prefetched\n// [resolve, reject, Promise] = chunk loading, 0 = chunk loaded\nvar installedChunks = {\n\t\"partial-payment/index\": 0,\n\t\"partial-payment/style-index\": 0\n};\n\n// no chunk on demand loading\n\n// no prefetching\n\n// no preloaded\n\n// no HMR\n\n// no HMR manifest\n\n__webpack_require__.O.j = (chunkId) => (installedChunks[chunkId] === 0);\n\n// install a JSONP callback for chunk loading\nvar webpackJsonpCallback = (parentChunkLoadingFunction, data) => {\n\tvar [chunkIds, moreModules, runtime] = data;\n\t// add \"moreModules\" to the modules object,\n\t// then flag all \"chunkIds\" as loaded and fire callback\n\tvar moduleId, chunkId, i = 0;\n\tif(chunkIds.some((id) => (installedChunks[id] !== 0))) {\n\t\tfor(moduleId in moreModules) {\n\t\t\tif(__webpack_require__.o(moreModules, moduleId)) {\n\t\t\t\t__webpack_require__.m[moduleId] = moreModules[moduleId];\n\t\t\t}\n\t\t}\n\t\tif(runtime) var result = runtime(__webpack_require__);\n\t}\n\tif(parentChunkLoadingFunction) parentChunkLoadingFunction(data);\n\tfor(;i < chunkIds.length; i++) {\n\t\tchunkId = chunkIds[i];\n\t\tif(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {\n\t\t\tinstalledChunks[chunkId][0]();\n\t\t}\n\t\tinstalledChunks[chunkId] = 0;\n\t}\n\treturn __webpack_require__.O(result);\n}\n\nvar chunkLoadingGlobal = globalThis[\"webpackChunkwoo_wallet\"] = globalThis[\"webpackChunkwoo_wallet\"] || [];\nchunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));\nchunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));","","// startup\n// Load entry module and return exports\n// This entry module depends on other loaded chunks and execution need to be delayed\nvar __webpack_exports__ = __webpack_require__.O(undefined, [\"partial-payment/style-index\"], () => (__webpack_require__(\"./src/partial-payment/index.js\")))\n__webpack_exports__ = __webpack_require__.O(__webpack_exports__);\n",""],"names":["registerPlugin","ExperimentalOrderMeta","ExperimentalDiscountsMeta","getSetting","__","sprintf","decodeEntities","useState","Panel","ValidatedTextInput","ValidationInputError","Button","extensionCartUpdate","window","wc","blocksCheckout","settings","render","partialPaymentAmount","setPartialPaymentAmount","partial_payment_amount","showSpinner","setShowSpinner","textInputId","buttonClickHandler","e","preventDefault","namespace","data","then","formatedBalance","balance","currency_symbol","decimal_separator","thousand_separator","decimals","numericAmount","parseFloat","isNaN","amount","fixedAmount","toFixed","parts","split","replace","formattedAmount","join","createElement","active","className","initialOpen","hasBorder","title","class","id","errorId","label","value","onChange","newPartialPaymentAmount","focusOnMount","validateOnMount","showError","disabled","type","onClick","Fragment","scope"],"sourceRoot":""}