/home/altere25/labratnyc.com/wp-content/plugins/woocommerce-payments/dist
Edit: /home/altere25/labratnyc.com/wp-content/plugins/woocommerce-payments/dist/multi-currency.js (57394B)
(()=>{var e={2291(e,t,n){"use strict";t.A=function(e){var t=e.size,n=void 0===t?24:t,r=e.onClick,c=(e.icon,e.className),i=function(e,t){if(null==e)return{};var n,r,s=function(e,t){if(null==e)return{};var n,r,s={},o=Object.keys(e);for(r=0;r
{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;globalThis.importScripts&&(e=globalThis.location+"");var t=globalThis.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName("script");if(r.length)for(var s=r.length-1;s>-1&&(!e||!/^http(s?):/.test(e));)e=r[s--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),n.p=e})(),n.p=window.wcpayAssets.url,(()=>{"use strict";var e={};n.r(e),n.d(e,{getAccountBusinessSupportEmail:()=>se,getAccountBusinessSupportPhone:()=>oe,getAccountCommunicationsEmail:()=>Ge,getAccountDomesticCurrency:()=>ae,getAccountStatementDescriptor:()=>te,getAccountStatementDescriptorKana:()=>re,getAccountStatementDescriptorKanji:()=>ne,getAdvancedFraudProtectionSettings:()=>Re,getAvailablePaymentMethodIds:()=>Q,getCompletedWaitingPeriod:()=>de,getCurrentProtectionLevel:()=>Ae,getDepositDelayDays:()=>ue,getDepositRestrictions:()=>_e,getDepositScheduleInterval:()=>ce,getDepositScheduleMonthlyAnchor:()=>le,getDepositScheduleWeeklyAnchor:()=>ie,getDepositStatus:()=>me,getDuplicatedPaymentMethodIds:()=>Y,getEnabledPaymentMethodIds:()=>K,getExpressCheckoutCartMethods:()=>We,getExpressCheckoutCheckoutMethods:()=>qe,getExpressCheckoutProductMethods:()=>Ve,getIsCardPresentEligible:()=>Te,getIsDebugLogEnabled:()=>fe,getIsDevModeEnabled:()=>ge,getIsExpressCheckoutInPaymentMethodsEnabled:()=>Se,getIsManualCaptureEnabled:()=>pe,getIsMultiCurrencyEnabled:()=>we,getIsPaymentRequestEnabled:()=>be,getIsSavedCardsEnabled:()=>je,getIsStripeBillingEnabled:()=>Ue,getIsStripeBillingMigrationInProgress:()=>Fe,getIsSubscriptionsPluginActive:()=>Pe,getIsTestModeEnabled:()=>ye,getIsTestModeOnboarding:()=>he,getIsWCPayEnabled:()=>J,getIsWCPaySubscriptionsEligible:()=>Ie,getIsWCPaySubscriptionsEnabled:()=>ke,getIsWooPayEnabled:()=>Oe,getIsWooPayGlobalThemeSupportEnabled:()=>Me,getPaymentMethodStatuses:()=>X,getPaymentRequestButtonBorderRadius:()=>Ce,getPaymentRequestButtonSize:()=>ve,getPaymentRequestButtonTheme:()=>xe,getPaymentRequestButtonType:()=>Ee,getSavingError:()=>Ne,getSettings:()=>H,getShowWooPayIncompatibilityNotice:()=>Be,getStripeBillingMigratedCount:()=>ze,getStripeBillingSubscriptionCount:()=>$e,getWooPayCustomMessage:()=>De,getWooPayStoreLogo:()=>Le,isDirty:()=>ee,isSavingSettings:()=>Z});var t={};n.r(t),n.d(t,{saveOption:()=>Ft,saveSettings:()=>Nt,submitStripeBillingSubscriptionMigration:()=>Ut,updateAccountBusinessSupportEmail:()=>Et,updateAccountBusinessSupportPhone:()=>vt,updateAccountCommunicationsEmail:()=>Lt,updateAccountStatementDescriptor:()=>St,updateAccountStatementDescriptorKana:()=>wt,updateAccountStatementDescriptorKanji:()=>ft,updateAdvancedFraudProtectionSettings:()=>Mt,updateDepositScheduleInterval:()=>xt,updateDepositScheduleMonthlyAnchor:()=>jt,updateDepositScheduleWeeklyAnchor:()=>Ct,updateEnabledPaymentMethodIds:()=>ut,updateExpressCheckoutCartMethods:()=>Rt,updateExpressCheckoutCheckoutMethods:()=>Bt,updateExpressCheckoutProductMethods:()=>At,updateIsCardPresentEligible:()=>tt,updateIsDebugLogEnabled:()=>ht,updateIsExpressCheckoutInPaymentMethodsEnabled:()=>lt,updateIsManualCaptureEnabled:()=>pt,updateIsMultiCurrencyEnabled:()=>gt,updateIsPaymentRequestEnabled:()=>it,updateIsSavedCardsEnabled:()=>et,updateIsSavingSettings:()=>dt,updateIsStripeBillingEnabled:()=>Dt,updateIsTestModeEnabled:()=>yt,updateIsWCPayEnabled:()=>ct,updateIsWCPaySubscriptionsEnabled:()=>bt,updateIsWooPayEnabled:()=>Tt,updateIsWooPayGlobalThemeSupportEnabled:()=>kt,updatePaymentRequestButtonBorderRadius:()=>ot,updatePaymentRequestButtonSize:()=>rt,updatePaymentRequestButtonTheme:()=>st,updatePaymentRequestButtonType:()=>nt,updateProtectionLevel:()=>Ot,updateSelectedPaymentMethod:()=>mt,updateSettings:()=>at,updateUnselectedPaymentMethod:()=>_t,updateWooPayCustomMessage:()=>It,updateWooPayStoreLogo:()=>Pt});var r={};n.r(r),n.d(r,{getSettings:()=>$t});var s={};n.r(s),n.d(s,{getAvailableCurrencies:()=>Qt,getCurrencies:()=>Kt,getCurrencySettings:()=>en,getDefaultCurrency:()=>Zt,getEnabledCurrencies:()=>Xt,getStoreSettings:()=>tn,isSavingStoreSettings:()=>rn,isStoreSettingsDirty:()=>nn});var o={};n.r(o),n.d(o,{saveOption:()=>hn,saveStoreSettings:()=>yn,submitCurrencySettings:()=>pn,submitEnabledCurrenciesUpdate:()=>_n,updateAvailableCurrencies:()=>on,updateCurrencies:()=>sn,updateCurrencySettings:()=>ln,updateDefaultCurrency:()=>cn,updateEnabledCurrencies:()=>an,updateIsSavingStoreSettings:()=>mn,updateStoreSettingValues:()=>dn,updateStoreSettings:()=>un});var a={};n.r(a),n.d(a,{getCurrencies:()=>gn,getCurrencySettings:()=>bn,getStoreSettings:()=>Sn});var c=n(1609);const i=window.ReactDOM,l=window.wc.navigation,u=((0,c.createContext)({isActive:!1,setActive:()=>null,isCompleted:!1,setCompleted:()=>null,taskId:""}),window.ReactJSXRuntime);(0,c.createContext)({activeTask:"",setActiveTask:()=>null,completedTasks:{},setCompletedTasks:()=>null});const d=window.wp.components;function m(e){var t,n,r="";if("string"==typeof e||"number"==typeof e)r+=e;else if("object"==typeof e)if(Array.isArray(e)){var s=e.length;for(t=0;t(0,u.jsxs)(d.Modal,{className:_("wcpay-confirmation-modal",n),...r,children:[e,(0,u.jsx)(p.HorizontalRule,{className:"wcpay-confirmation-modal__separator"}),(0,u.jsx)("div",{className:"wcpay-confirmation-modal__footer",children:t})]}),h="https://cdn.sift.com/s.js",g=({beacon_key:e,session_id:t,user_id:n})=>{const r=window._sift=window._sift||[];if(r.push(["_setAccount",e]),r.push(["_setUserId",n]),r.push(["_setSessionId",t]),r.push(["_trackPageview"]),!document.querySelector(`[src="${h}"]`)){const e=document.createElement("script");e.src=h,e.async=!0,document.body.appendChild(e)}};(Object.getOwnPropertyDescriptor(g,"name")||{}).writable||Object.defineProperty(g,"name",{value:"default",configurable:!0});const b="https://js.stripe.com/v3",S=()=>{if(!document.querySelector(`[src^="${b}"]`)){const e=document.createElement("script");e.src=b,e.async=!0,document.body.appendChild(e)}};(Object.getOwnPropertyDescriptor(S,"name")||{}).writable||Object.defineProperty(S,"name",{value:"default",configurable:!0});const f={sift:g,stripe:S},w=e=>{for(const t in e){const n=f[t];n&&e[t]&&n(e[t])}};(Object.getOwnPropertyDescriptor(w,"name")||{}).writable||Object.defineProperty(w,"name",{value:"default",configurable:!0});const E=window.wp.i18n;var v=n(2291),x=n(8295),C=n(6947);const j=function(e){const{icon:t,actions:n,children:r,buttonVariant:s,...o}=e;o.className=_("wcpay-inline-notice",`wcpay-inline-${o.status}-notice`,o.className);let a=t;if(!0===a)switch(o.status){case"success":a=(0,u.jsx)(v.A,{});break;case"error":case"warning":a=(0,u.jsx)(x.A,{});break;default:a=(0,u.jsx)(C.A,{})}const c="wcpay-inline-notice__action",i=n?.map((e,t)=>"url"in e?(0,u.jsx)("a",{className:c,href:e.url,children:e.label},t):(0,u.jsx)(d.Button,{className:c,onClick:e.onClick,isBusy:e.isBusy??!1,disabled:e.disabled??!1,variant:s,children:e.label},t));return(0,u.jsx)(d.Notice,{...o,children:(0,u.jsxs)(d.Flex,{align:"center",justify:"flex-start",children:[a&&(0,u.jsx)(d.FlexItem,{className:`wcpay-inline-notice__icon wcpay-inline-${o.status}-notice__icon`,children:(0,u.jsx)(d.Icon,{icon:a,size:24})}),(0,u.jsxs)(d.FlexItem,{className:`wcpay-inline-notice__content wcpay-inline-${o.status}-notice__content`,children:[r,i&&(0,u.jsx)(d.Flex,{className:"wcpay-inline-notice__content__actions",align:"baseline",justify:"flex-start",gap:4,children:i})]})]})})};c.Component;const N=({isLoading:e,display:t,placeholder:n,value:r,children:s,...o})=>e?(0,u.jsx)("span",{className:t?`is-loadable-placeholder is-${t}`:"is-loadable-placeholder","aria-busy":"true",...o,children:void 0===n?s||r:n}):(0,u.jsx)(u.Fragment,{children:s||r}),T=({numLines:e,...t})=>{const n=(0,u.jsx)("p",{style:{lineHeight:e},children:"Block placeholder"});return(0,u.jsx)(N,{...t,placeholder:n,display:"block","aria-hidden":!0})},k=({Icon:e,label:t})=>e?(0,u.jsxs)("span",{className:_("woocommerce-payments__payment-method-icon"),children:[(0,u.jsx)(e,{}),t&&(0,u.jsx)("span",{className:"woocommerce-payments__payment-method-icon__label",children:t})]}):null,I=({children:e})=>(0,u.jsx)("div",{className:"wcpay-settings-layout",children:e}),P=()=>null,O=({description:e=P,children:t,className:n,id:r})=>(0,u.jsxs)("div",{className:_("settings-section",n),id:r,children:[(0,u.jsx)("div",{className:"settings-section__details",children:(0,u.jsx)(e,{})}),(0,u.jsx)("div",{className:"settings-section__controls",children:t})]}),M=window.wp.domReady;var D=n.n(M);const L=(e,t={})=>{if(window.wcpaySettings){Object.assign(t,{is_test_mode:wcpaySettings.testMode,jetpack_connected:wcpaySettings.isJetpackConnected,wcpay_version:wcpaySettings.version,woo_country_code:wcpaySettings.connect.country,hosting_provider:wcpaySettings.trackingInfo?.hosting_provider});for(const e in t)void 0===t[e]&&delete t[e]}D()(()=>{(wc?.tracks?.recordEvent??wcTracks.recordEvent)(e,t)})};(0,c.createContext)(window.wcpaySettings);const A=window.wc.currency;var R=n.n(A);const B=window.lodash;(0,E.__)("Australian dollar","woocommerce-payments"),(0,E.__)("Canadian dollar","woocommerce-payments"),(0,E.__)("Swiss franc","woocommerce-payments"),(0,E.__)("Danish krone","woocommerce-payments"),(0,E.__)("Euro","woocommerce-payments"),(0,E.__)("Pound sterling","woocommerce-payments"),(0,E.__)("Norwegian krone","woocommerce-payments"),(0,E.__)("New Zealand dollar","woocommerce-payments"),(0,E.__)("Swedish krona","woocommerce-payments"),(0,E.__)("United States (US) dollar","woocommerce-payments");const U=e=>wcpaySettings.zeroDecimalCurrencies.includes(e.toLowerCase());function F(e,t,n){try{return e.toLocaleString(void 0,{style:"currency",currency:t,currencyDisplay:"narrowSymbol",dummy:n})}catch(r){return(0,E.sprintf)(n?"%s %i":"%s %.2f",t.toUpperCase(),e)}}function $(e){return(new DOMParser).parseFromString(e,"text/html").documentElement.textContent}const z={SET_SETTINGS:"SET_SETTINGS",SET_SETTINGS_VALUES:"SET_SETTINGS_VALUES",SET_IS_SAVING_SETTINGS:"SET_IS_SAVING_SETTINGS",SET_SELECTED_PAYMENT_METHOD:"SET_SELECTED_PAYMENT_METHOD",SET_UNSELECTED_PAYMENT_METHOD:"SET_UNSELECTED_PAYMENT_METHOD"},G={isDirty:!1,isSaving:!1,savingError:null,data:{}},V={},W=[],q=e=>e&&e.settings||V,H=e=>q(e).data||V,Y=e=>H(e).duplicated_payment_method_ids||V,J=e=>H(e).is_wcpay_enabled||!1,K=e=>H(e).enabled_payment_method_ids||W,Q=e=>H(e).available_payment_method_ids||W,X=e=>H(e).payment_method_statuses||V,Z=e=>q(e).isSaving||!1,ee=e=>q(e).isDirty||!1,te=e=>H(e).account_statement_descriptor||"",ne=e=>H(e).account_statement_descriptor_kanji||"",re=e=>H(e).account_statement_descriptor_kana||"",se=e=>H(e).account_business_support_email||"",oe=e=>H(e).account_business_support_phone||"",ae=e=>H(e).account_domestic_currency||"",ce=e=>H(e).deposit_schedule_interval||"",ie=e=>H(e).deposit_schedule_weekly_anchor||"",le=e=>H(e).deposit_schedule_monthly_anchor||"",ue=e=>H(e).deposit_delay_days||"7",de=e=>H(e).deposit_completed_waiting_period||!1,me=e=>H(e).deposit_status||"",_e=e=>H(e).deposit_restrictions||"",pe=e=>H(e).is_manual_capture_enabled||!1,ye=e=>H(e).is_test_mode_enabled||!1,he=e=>H(e).is_test_mode_onboarding||!1,ge=e=>H(e).is_dev_mode_enabled||!1,be=e=>H(e).is_payment_request_enabled||!1,Se=e=>H(e).is_express_checkout_in_payment_methods_enabled||!1,fe=e=>H(e).is_debug_log_enabled||!1,we=e=>H(e).is_multi_currency_enabled||!1,Ee=e=>H(e).payment_request_button_type||"",ve=e=>H(e).payment_request_button_size||"",xe=e=>H(e).payment_request_button_theme||"",Ce=e=>{const t=H(e)?.payment_request_button_border_radius;return 0===t||"0"===t||t?t:"undefined"==typeof wcpaySettings?4:parseInt(window?.wcpaySettings?.defaultExpressCheckoutBorderRadius||4,10)},je=e=>H(e).is_saved_cards_enabled||!1,Ne=e=>q(e).savingError,Te=e=>H(e).is_card_present_eligible||!1,ke=e=>H(e).is_wcpay_subscriptions_enabled||!1,Ie=e=>H(e).is_wcpay_subscriptions_eligible||!1,Pe=e=>H(e).is_subscriptions_plugin_active||!1,Oe=e=>H(e).is_woopay_enabled||!1,Me=e=>H(e).is_woopay_global_theme_support_enabled||!1,De=e=>H(e).woopay_custom_message||"",Le=e=>H(e).woopay_store_logo||"",Ae=e=>H(e).current_protection_level||"basic",Re=e=>H(e).advanced_fraud_protection_settings||W,Be=e=>H(e).show_woopay_incompatibility_notice||!1,Ue=e=>H(e).is_stripe_billing_enabled||!1,Fe=e=>H(e).is_migrating_stripe_billing||!1,$e=e=>H(e).stripe_billing_subscription_count||0,ze=e=>H(e).stripe_billing_migrated_count||0,Ge=e=>H(e).account_communications_email||"",Ve=e=>H(e).express_checkout_product_methods||W,We=e=>H(e).express_checkout_cart_methods||W,qe=e=>H(e).express_checkout_checkout_methods||W,He=window.wp.data,Ye=window.wp.dataControls,Je=window.wp.apiFetch;var Ke=n.n(Je);const Qe="/wc/v3/payments",Xe="wc/payments/settings";function Ze(e){return{type:z.SET_SETTINGS_VALUES,payload:e}}function et(e){return Ze({is_saved_cards_enabled:e})}function tt(e){return Ze({is_card_present_eligible:e})}function nt(e){return Ze({payment_request_button_type:e})}function rt(e){return Ze({payment_request_button_size:e})}function st(e){return Ze({payment_request_button_theme:e})}function ot(e){return Ze({payment_request_button_border_radius:e})}function at(e){return{type:z.SET_SETTINGS,data:e}}function ct(e){return Ze({is_wcpay_enabled:e})}function it(e){return Ze({is_payment_request_enabled:e})}function lt(e){return Ze({is_express_checkout_in_payment_methods_enabled:e})}function ut(e){return Ze({enabled_payment_method_ids:[...e]})}function dt(e,t){return{type:z.SET_IS_SAVING_SETTINGS,isSaving:e,error:t}}function mt(e){return{type:z.SET_SELECTED_PAYMENT_METHOD,id:e}}function _t(e){return{type:z.SET_UNSELECTED_PAYMENT_METHOD,id:e}}function pt(e){return Ze({is_manual_capture_enabled:e})}function yt(e){return Ze({is_test_mode_enabled:e})}function ht(e){return Ze({is_debug_log_enabled:e})}function gt(e){return Ze({is_multi_currency_enabled:e})}function bt(e){return Ze({is_wcpay_subscriptions_enabled:e})}function St(e){return Ze({account_statement_descriptor:e})}function ft(e){return Ze({account_statement_descriptor_kanji:e})}function wt(e){return Ze({account_statement_descriptor_kana:e})}function Et(e){return Ze({account_business_support_email:e})}function vt(e){return Ze({account_business_support_phone:e})}function xt(e){return Ze({deposit_schedule_interval:e})}function Ct(e){return Ze({deposit_schedule_weekly_anchor:e})}function jt(e){return Ze({deposit_schedule_monthly_anchor:""===e?null:parseInt(e,10)})}function*Nt(){let e=null;try{const e=(0,He.select)(Xe).getSettings();yield dt(!0,null);const t=yield(0,Ye.apiFetch)({path:`${Qe}/settings`,method:"post",data:e});yield at({...e,payment_method_statuses:t.data.payment_method_statuses}),yield(0,He.dispatch)("core/notices").createSuccessNotice((0,E.__)("Settings saved.","woocommerce-payments"))}catch(t){e=t,yield(0,He.dispatch)("core/notices").createErrorNotice((0,E.__)("Error saving settings.","woocommerce-payments")),e.server_error&&!e.data?.details&&(yield(0,He.dispatch)("core/notices").createErrorNotice(e.server_error))}finally{yield dt(!1,e)}return null===e}function Tt(e){return Ze({is_woopay_enabled:e})}function kt(e){return Ze({is_woopay_global_theme_support_enabled:e})}function It(e){return Ze({woopay_custom_message:e})}function Pt(e){return Ze({woopay_store_logo:e})}function Ot(e){return Ze({current_protection_level:e})}function Mt(e){return Ze({advanced_fraud_protection_settings:e})}function Dt(e){return Ze({is_stripe_billing_enabled:e})}function Lt(e){return Ze({account_communications_email:e})}function At(e){return Ze({express_checkout_product_methods:[...e]})}function Rt(e){return Ze({express_checkout_cart_methods:[...e]})}function Bt(e){return Ze({express_checkout_checkout_methods:[...e]})}function*Ut(){try{yield(0,He.dispatch)(Xe).startResolution("scheduleStripeBillingMigration"),yield(0,Ye.apiFetch)({path:`${Qe}/settings/schedule-stripe-billing-migration`,method:"post"})}catch(e){yield(0,He.dispatch)("core/notices").createErrorNotice((0,E.__)("Error starting the Stripe Billing migration.","woocommerce-payments"))}yield(0,He.dispatch)(Xe).finishResolution("scheduleStripeBillingMigration")}function Ft(e,t){return Ke()({path:`${Qe}/settings/${e}`,method:"post",data:{value:t}}).catch(()=>{(0,He.dispatch)("core/notices").createErrorNotice((0,E.__)("Error saving option","woocommerce-payments"))})}function*$t(){const e=`${Qe}/settings`;try{const t=yield(0,Ye.apiFetch)({path:e});yield at(t)}catch(e){yield(0,He.dispatch)("core/notices").createErrorNotice((0,E.__)("Error retrieving settings.","woocommerce-payments"))}}const zt=Xe,Gt=(0,He.createReduxStore)(zt,{reducer:(0,He.combineReducers)({settings:(e=G,{type:t,...n})=>{switch(t){case z.SET_SETTINGS:return{...e,data:n.data,isDirty:!1};case z.SET_SETTINGS_VALUES:return{...e,savingError:null,isDirty:!0,data:{...e.data,...n.payload}};case z.SET_IS_SAVING_SETTINGS:return{...e,isDirty:!(!n.isSaving&&!n.error)&&e.isDirty,isSaving:n.isSaving,savingError:n.error};case z.SET_SELECTED_PAYMENT_METHOD:return{...e,isDirty:!0,data:{...e.data,enabled_payment_method_ids:e.data.enabled_payment_method_ids.concat(n.id)}};case z.SET_UNSELECTED_PAYMENT_METHOD:return{...e,isDirty:!0,data:{...e.data,enabled_payment_method_ids:e.data.enabled_payment_method_ids.filter(e=>e!==n.id)}}}return e}}),actions:t,selectors:e,resolvers:r,controls:Ye.controls});(0,He.register)(Gt);const Vt=e=>()=>{const{updateExpressCheckoutProductMethods:t,updateExpressCheckoutCartMethods:n,updateExpressCheckoutCheckoutMethods:r}=(0,He.useDispatch)(zt),s=(0,He.useSelect)(e=>e(zt).getExpressCheckoutProductMethods()),o=(0,He.useSelect)(e=>e(zt).getExpressCheckoutCartMethods()),a=(0,He.useSelect)(e=>e(zt).getExpressCheckoutCheckoutMethods()),c={product:s,cart:o,checkout:a},i={product:t,cart:n,checkout:r};return[[s.includes(e)&&"product",o.includes(e)&&"cart",a.includes(e)&&"checkout"].filter(Boolean),(t,n)=>{i[t](n?[...c[t],e]:c[t].filter(t=>t!==e))}]},Wt=(Vt("payment_request"),Vt("woopay"),Vt("amazon_pay"),"/wc/v3/payments"),qt="wc/payments/multi-currency",Ht={SET_CURRENCIES:"SET_CURRENCIES",SET_AVAILABLE_CURRENCIES:"SET_AVAILABLE_CURRENCIES",SET_ENABLED_CURRENCIES:"SET_ENABLED_CURRENCIES",SET_DEFAULT_CURRENCY:"SET_DEFAULT_CURRENCY",SET_CURRENCY_SETTINGS:"SET_CURRENCY_SETTINGS",SET_STORE_SETTINGS:"SET_STORE_SETTINGS",SET_STORE_SETTINGS_VALUES:"SET_STORE_SETTINGS_VALUES",SET_IS_SAVING_STORE_SETTINGS:"SET_IS_SAVING_STORE_SETTINGS"},Yt={},Jt=e=>e&&e||{},Kt=e=>Jt(e).currencies||{},Qt=e=>Kt(e).available||{},Xt=e=>Kt(e).enabled||{},Zt=e=>Kt(e).default||{},en=e=>Jt(e).currency_settings||{},tn=e=>Jt(e).settings?.data||{},nn=e=>Jt(e).settings?.isDirty??!1,rn=e=>Jt(e).settings?.isSaving??!1;function sn(e){return{type:Ht.SET_CURRENCIES,data:e}}function on(e){return{type:Ht.SET_AVAILABLE_CURRENCIES,data:e}}function an(e){return{type:Ht.SET_ENABLED_CURRENCIES,data:e}}function cn(e){return{type:Ht.SET_DEFAULT_CURRENCY,data:e}}function ln(e,t){return{type:Ht.SET_CURRENCY_SETTINGS,data:{code:e,data:t}}}function un(e){return{type:Ht.SET_STORE_SETTINGS,data:e}}function dn(e){return{type:Ht.SET_STORE_SETTINGS_VALUES,data:e}}function mn(e,t){return{type:Ht.SET_IS_SAVING_STORE_SETTINGS,data:{isSaving:e,error:t}}}function*_n(e){const t=Object.keys((0,He.select)(qt).getEnabledCurrencies()),n=e.filter(e=>!t.includes(e)),r=t.filter(t=>!e.includes(t));try{const t=yield(0,Ye.apiFetch)({path:`${Wt}/multi-currency/update-enabled-currencies`,method:"POST",data:{enabled:e}});yield sn(t),yield(0,He.dispatch)("core/notices").createSuccessNotice((0,E.__)("Enabled currencies updated.","woocommerce-payments")),L("wcpay_multi_currency_enabled_currencies_updated",{added_currencies:n,removed_currencies:r})}catch(e){yield(0,He.dispatch)("core/notices").createErrorNotice((0,E.__)("Error updating enabled currencies.","woocommerce-payments"))}}function*pn(e,t){try{const n=yield(0,Ye.apiFetch)({path:`${Wt}/multi-currency/currencies/${e}`,method:"POST",data:t});yield ln(e,n),yield(0,He.dispatch)("core/notices").createSuccessNotice((0,E.__)("Currency settings updated.","woocommerce-payments"))}catch(e){yield(0,He.dispatch)("core/notices").createErrorNotice((0,E.__)("Error updating currency settings.","woocommerce-payments"))}}function*yn(e=!1){let t=null;try{const t=(0,He.select)(qt).getStoreSettings();yield mn(!0,null);const n=yield(0,Ye.apiFetch)({path:`${Wt}/multi-currency/update-settings`,method:"POST",data:{wcpay_multi_currency_enable_auto_currency:t.enable_auto_currency?"yes":"no",wcpay_multi_currency_enable_storefront_switcher:t.enable_storefront_switcher?"yes":"no",wcpay_multi_currency_rendering_mode:t.rendering_mode||"speed",wcpay_multi_currency_cache_recommendation_dismissed:t.cache_recommendation_dismissed?"yes":"no"}});yield un(n),e||(yield(0,He.dispatch)("core/notices").createSuccessNotice((0,E.__)("Store settings saved.","woocommerce-payments")))}catch(e){t=e,yield(0,He.dispatch)("core/notices").createErrorNotice((0,E.__)("Error saving store settings.","woocommerce-payments"))}finally{yield mn(!1,t)}}function hn(e,t){Ke()({path:`${Wt}/settings/${e}`,method:"post",data:{value:t}}).catch(()=>{(0,He.dispatch)("core/notices").createErrorNotice((0,E.__)("Error saving option","woocommerce-payments"))})}function*gn(){const e=`${Wt}/multi-currency/currencies`;try{const t=yield(0,Ye.apiFetch)({path:e});yield sn(t)}catch(e){yield(0,He.dispatch)("core/notices").createErrorNotice((0,E.__)("Error retrieving currencies.","woocommerce-payments"))}}function*bn(e){const t=`${Wt}/multi-currency/currencies/${e}`;try{const n=yield(0,Ye.apiFetch)({path:t});yield ln(e,n)}catch(e){yield(0,He.dispatch)("core/notices").createErrorNotice((0,E.__)("Error retrieving single currency settings.","woocommerce-payments"))}}function*Sn(){const e=`${Wt}/multi-currency/get-settings`;try{const t=yield(0,Ye.apiFetch)({path:e});yield un(t)}catch(e){yield(0,He.dispatch)("core/notices").createErrorNotice((0,E.__)("Error retrieving store settings.","woocommerce-payments"))}}const fn=()=>(0,He.useSelect)(e=>{const{getCurrencies:t,isResolving:n}=e(qt);return{currencies:t(),isLoading:n("getCurrencies",[])}},[]),wn=()=>{const e=(0,He.useSelect)(e=>{const{getEnabledCurrencies:t}=e(qt);return t()}),{submitEnabledCurrenciesUpdate:t}=(0,He.useDispatch)(qt);return{enabledCurrencies:e,submitEnabledCurrenciesUpdate:t}},En=()=>{const{storeSettings:e,isLoading:t,isDirty:n,isSaving:r}=(0,He.useSelect)(e=>{const{getStoreSettings:t,isStoreSettingsDirty:n,isSavingStoreSettings:r,isResolving:s}=e(qt);return{storeSettings:t(),isLoading:s("getStoreSettings",[]),isDirty:n(),isSaving:r()}}),{updateStoreSettingValues:s,saveStoreSettings:o}=(0,He.useDispatch)(qt);return{storeSettings:e,isLoading:t,isDirty:n,isSaving:r,updateStoreSettingValues:s,saveStoreSettings:o}},vn=()=>(0,He.useSelect)(e=>{const{getDefaultCurrency:t}=e(qt);return t()});(0,He.registerStore)(qt,{reducer:(e=Yt,{type:t,data:n=[]})=>{switch(t){case Ht.SET_CURRENCIES:return{...e,currencies:n,available:n.available,enabled:n.enabled,default:n.default};case Ht.SET_AVAILABLE_CURRENCIES:return{...e,currencies:{...e,available:n.available},available:n.available};case Ht.SET_ENABLED_CURRENCIES:return{...e,currencies:{...e,enabled:n.enabled},enabled:n.enabled};case Ht.SET_DEFAULT_CURRENCY:return{...e,currencies:{...e,default:n.default},default:n.default};case Ht.SET_CURRENCY_SETTINGS:return{...e,currency_settings:{...e.currency_settings,[n.code]:n.data}};case Ht.SET_STORE_SETTINGS:return{...e,settings:{...e.settings,isDirty:!1,data:{enable_auto_currency:n.wcpay_multi_currency_enable_auto_currency,enable_storefront_switcher:n.wcpay_multi_currency_enable_storefront_switcher,rendering_mode:n.wcpay_multi_currency_rendering_mode,is_cache_optimized_feature_enabled:n.is_cache_optimized_feature_enabled,should_recommend_cache_mode:n.should_recommend_cache_mode,cache_recommendation_dismissed:n.cache_recommendation_dismissed,site_theme:n.site_theme,date_format:n.date_format,time_format:n.time_format,store_url:n.store_url}}};case Ht.SET_STORE_SETTINGS_VALUES:return{...e,settings:{...e.settings,savingError:null,isDirty:!0,data:{...e.settings?.data||{},...n}}};case Ht.SET_IS_SAVING_STORE_SETTINGS:return{...e,settings:{...e.settings,isDirty:!(!n.isSaving&&!n.error)&&(e.settings?.isDirty??!1),isSaving:n.isSaving,savingError:n.error}}}return e},actions:{...o},controls:Ye.controls,selectors:{...s},resolvers:{...a}});const xn=({isPreviewModalOpen:e,setPreviewModalOpen:t,isStorefrontSwitcherEnabledValue:n,isAutomaticSwitchEnabledValue:r})=>{const{storeSettings:s}=En();return e&&(0,u.jsx)(d.Modal,{title:(0,E.__)("Preview","woocommerce-payments"),isDismissible:!0,className:"multi-currency-store-settings-preview-modal",shouldCloseOnClickOutside:!1,onRequestClose:()=>{t(!1)},children:(0,u.jsx)("iframe",{title:(0,E.__)("Preview","woocommerce-payments"),className:"multi-currency-store-settings-preview-iframe",src:"/"+s.store_url+"?is_mc_onboarding_simulation=1&enable_storefront_switcher="+n+"&enable_auto_currency="+r})})},Cn=window.wp.element,jn=({children:e})=>(0,u.jsx)("ul",{children:e});function Nn(e){return e.startsWith("{{/")?{type:"componentClose",value:e.replace(/\W/g,"")}:e.endsWith("/}}")?{type:"componentSelfClosing",value:e.replace(/\W/g,"")}:e.startsWith("{{")?{type:"componentOpen",value:e.replace(/\W/g,"")}:{type:"string",value:e}}function Tn(e,t){let n,r,s=[];for(let o=0;o{const c=(0,Cn.useCallback)(t=>{e(s,t)},[s,e]);return(0,u.jsx)("li",{className:"enabled-currency-checkbox","data-testid":a,children:(0,u.jsx)(d.CheckboxControl,{code:s,checked:t,onChange:c,label:kn({mixedString:"{{flag /}} {{name /}} {{code /}}",components:{flag:(0,u.jsx)("span",{className:"enabled-currency-checkbox__flag",children:""!==n?n:(0,u.jsx)("div",{className:"enabled-currency-checkbox__flag-text",children:(0,u.jsx)("span",{children:s})})}),name:(0,u.jsx)("span",{children:o}),code:(0,u.jsxs)("span",{className:"enabled-currency-checkbox__code",children:["(",r,r!==s&&" "+s,")"]})}}),__nextHasNoMarginBottom:!0})})};(0,E.__)("any","woocommerce-payments"),(0,E.__)("one","woocommerce-payments"),(0,E.__)("two","woocommerce-payments"),(0,E.__)("three","woocommerce-payments"),(0,E.__)("four","woocommerce-payments"),(0,E.__)("five","woocommerce-payments"),(0,E.__)("six","woocommerce-payments"),(0,E.__)("seven","woocommerce-payments"),(0,E.__)("eight","woocommerce-payments"),(0,E.__)("nine","woocommerce-payments");const Pn=({className:e,children:t})=>(0,u.jsx)("ul",{className:e,children:t});var On=n(8971);const Mn=({symbol:e})=>(0,u.jsx)("div",{className:"currency-delete-illustration__wrapper",children:(0,u.jsxs)("div",{className:"currency-delete-illustration__illustrations",children:[e,(0,u.jsx)(On.A,{className:"currency-delete-illustration__currency-cross-icon"})]})}),Dn=n.p+"../assets/images/payment-methods/jcb.svg?ver=cbb1bd44391fc950405c",Ln=n.p+"../assets/images/cards/visa.svg?ver=4092a4a60d0cc118521a",An=n.p+"../assets/images/cards/mastercard.svg?ver=6129dd1939ec8fae99f6",Rn=n.p+"../assets/images/cards/amex.svg?ver=acda1145a36f911ce8bb",Bn=n.p+"../assets/images/payment-methods/woo.svg?ver=f8038db537160f3d85b8",Un=n.p+"../assets/images/payment-methods/woo-short.svg?ver=9536f8da3fd7b2f65555",Fn=n.p+"../assets/images/cards/diners.svg?ver=54cab5feb20ce75b53a4",$n=n.p+"../assets/images/cards/discover.svg?ver=01d6dfbfbc64f24bee7c",zn=n.p+"../assets/images/cards/cb.svg?ver=7b1291fee8396b46e81f",Gn=n.p+"../assets/images/cards/unionpay.svg?ver=d45c6881498629ee226c",Vn=(e,t,n=!0)=>({className:r,...s})=>(0,u.jsx)("img",{className:_("payment-method__icon",n?"":"no-border",r),src:e,alt:t,...s}),Wn=(Vn(Rn,(0,E.__)("American Express","woocommerce-payments")),Vn(zn,(0,E.__)("Cartes Bancaires","woocommerce-payments")),Vn(Fn,(0,E.__)("Diners Club","woocommerce-payments")),Vn($n,(0,E.__)("Discover","woocommerce-payments")),Vn(Dn,(0,E.__)("JCB","woocommerce-payments")));if(Vn(An,(0,E.__)("Mastercard","woocommerce-payments")),Vn(Gn,(0,E.__)("UnionPay","woocommerce-payments")),Vn(Ln,(0,E.__)("Visa","woocommerce-payments")),Vn(Bn,(0,E.__)("WooPay","woocommerce-payments"),!1),Vn(Un,(0,E.__)("WooPay","woocommerce-payments"),!1),"undefined"==typeof wooPaymentsPaymentMethodDefinitions)throw new Error("wooPaymentsPaymentMethodDefinitions is undefined");const qn=Object.keys(wooPaymentsPaymentMethodDefinitions).reduce((e,t)=>(e[t]={...wooPaymentsPaymentMethodDefinitions[t],icon:({className:e})=>(0,u.jsx)("img",{src:wooPaymentsPaymentMethodDefinitions[t].settings_icon_url,alt:wooPaymentsPaymentMethodDefinitions[t].label,className:_("payment-method__icon",e)})},e),{jcb:{id:"jcb",label:(0,E.__)("JCB","woocommerce-payments"),description:(0,E.__)("Let your customers pay with JCB, the only international payment brand based in Japan.","woocommerce-payments"),icon:Wn,currencies:["JPY"],stripe_key:"jcb_payments",allows_manual_capture:!1,allows_pay_later:!1,accepts_only_domestic_payment:!1,settings_icon_url:""}}),Hn=({code:e,label:t,symbol:n,onClick:r,className:s})=>{const[o,a]=(0,Cn.useState)(!1),c=window.multiCurrencyPaymentMethodsMap,i=c&&c[e]&&Object.keys(c[e]).length>0,l=i?Object.keys(c[e]):[],m=(0,Cn.useCallback)(()=>{i?a(!0):r(e)},[a,i,r,e]),_=(0,Cn.useCallback)(()=>{a(!1),r(e)},[r,a,e]),p=(0,Cn.useCallback)(()=>{a(!1)},[a]);return(0,u.jsxs)(u.Fragment,{children:[o&&(0,u.jsxs)(y,{title:(0,E.sprintf)((0,E.__)("Remove %1$s","woocommerce-payments"),t),onRequestClose:p,className:"enabled-currency-delete-modal",actions:(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(d.Button,{onClick:_,isPrimary:!0,isDestructive:!0,children:(0,E.__)("Remove","woocommerce-payments")}),(0,u.jsx)(d.Button,{onClick:p,isSecondary:!0,children:(0,E.__)("Cancel","woocommerce-payments")})]}),children:[(0,u.jsx)(Mn,{symbol:n}),(0,u.jsx)("p",{children:kn({mixedString:(0,E.sprintf)((0,E.__)("Are you sure you want to remove {{strong}}%s (%s){{/strong}}? Your customers will no longer be able to pay in this currency and use payment methods listed below.","woocommerce-payments"),t,e===n?e:[e,n].join(" ")),components:{strong:(0,u.jsx)("strong",{})}})}),(0,u.jsx)("ul",{children:l.map(e=>(0,u.jsx)("li",{children:(0,u.jsx)(k,{Icon:qn[e].icon,label:qn[e].label})},e))}),(0,u.jsx)("p",{children:(0,E.sprintf)((0,E.__)("You can add %s (%s) again at any time in Multi-Currency settings.","woocommerce-payments"),t,e===n?e:[e,n].join(" "))})]}),(0,u.jsx)(d.Button,{isLink:!0,"aria-label":(0,E.sprintf)((0,E.__)("Remove %1$s as an enabled currency","woocommerce-payments"),t),className:s,onClick:m,__next40pxDefaultSize:!0,children:(0,u.jsx)(d.Icon,{icon:"trash"})})]})},Yn=(0,c.createContext)(),Jn=({currency:{code:e,flag:t,id:n,is_default:r,name:s,symbol:o,rate:a},onDeleteClick:i})=>{const{code:l,is_zero_decimal:m}=vn(),{setCurrencyCodeToShowSettingsFor:p}=(0,c.useContext)(Yn);return(0,u.jsxs)("li",{className:_("enabled-currency",n),children:[(0,u.jsxs)("div",{className:"enabled-currency__container",children:[(0,u.jsx)("div",{className:"enabled-currency__flag",children:""!==t?t:(0,u.jsx)("div",{className:"enabled-currency__flag-text",children:(0,u.jsx)("span",{children:e})})}),(0,u.jsx)("div",{className:"enabled-currency__label",children:s}),(0,u.jsxs)("div",{className:"enabled-currency__code",children:["(",o+(o===e?"":` ${e}`),")"]})]}),(0,u.jsx)("div",{className:"enabled-currency__rate",children:(()=>{const t=m?Number.parseFloat(1e3*a).toFixed(2):Number.parseFloat(a).toFixed(2);return r?(0,E.__)("Default currency","woocommerce-payments"):m?`1,000 ${l} → ${t} ${e}`:`1 ${l} → ${t} ${e}`})()}),(0,u.jsxs)("div",{className:"enabled-currency__actions",children:[!r&&(0,u.jsx)(d.Button,{isLink:!0,onClick:()=>{p(e)},"aria-label":(0,E.sprintf)((0,E.__)("Edit %1$s","woocommerce-payments"),s),className:"enabled-currency__action edit",__next40pxDefaultSize:!0,children:(0,E.__)("manage","woocommerce-payments")}),i&&(0,u.jsx)(Hn,{className:"enabled-currency__action delete",onClick:i,label:s,code:e,symbol:o})]})]})},Kn=({isLoading:e})=>(0,u.jsxs)("li",{className:_("enabled-currency-placeholder","enabled-currency"),children:[(0,u.jsxs)("div",{className:"enabled-currency__container",children:[(0,u.jsx)("div",{className:"enabled-currency__flag",children:(0,u.jsx)(T,{isLoading:e,numLines:1,children:(0,u.jsx)("div",{className:"enabled-currency__flag-text"})})}),(0,u.jsx)("div",{className:"enabled-currency__label",children:(0,u.jsx)(T,{isLoading:e,numLines:1})}),(0,u.jsx)("div",{className:"enabled-currency__code",children:(0,u.jsx)(T,{isLoading:e,numLines:1})})]}),(0,u.jsx)("div",{className:"enabled-currency__rate",children:(0,u.jsx)(T,{isLoading:e,numLines:1})}),(0,u.jsx)("div",{className:"enabled-currency__actions",children:(0,u.jsx)(T,{isLoading:e,numLines:1})})]}),Qn=({className:e})=>{const t=(0,He.useSelect)(e=>{const{getAvailableCurrencies:t}=e(qt);return t()}),n=Object.keys(t),r=(0,Cn.useRef)(null),{enabledCurrencies:s,submitEnabledCurrenciesUpdate:o}=wn(),a=Object.keys(s),c=vn().code;n.splice(n.indexOf(c),1);const[i,l]=(0,Cn.useState)(""),[m,_]=(0,Cn.useState)({}),p=i?n.filter(e=>{const{symbol:n,name:r}=t[e];return`${n} ${e} ${r}`.toLocaleLowerCase().indexOf(i.toLocaleLowerCase())>-1}):n,h=(0,Cn.useCallback)(()=>{_(n.reduce((e,t)=>(e[t]=a.includes(t),e),{}))},[a,n]);(0,Cn.useEffect)(()=>{h()},[JSON.stringify(n),JSON.stringify(a)]);const g=(e,t)=>{_(n=>({...n,[e]:t}))},[b,S]=(0,Cn.useState)(!1),[f,w]=(0,Cn.useState)(!1),v=(0,Cn.useCallback)(()=>{S(!0)},[S]),x=(0,Cn.useCallback)(()=>{S(!1),w(!1),l(""),h()},[S,h]);return(0,Cn.useEffect)(()=>{b&&r&&!1===f&&w(r.current.offsetWidth)},[JSON.stringify(p),b]),(0,u.jsxs)(u.Fragment,{children:[b&&(0,u.jsxs)(y,{focusOnMount:"firstContentElement",title:(0,E.__)("Add enabled currencies","woocommerce-payments"),onRequestClose:x,className:"add-enabled-currencies-modal",actions:(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(d.Button,{isSecondary:!0,onClick:x,__next40pxDefaultSize:!0,children:(0,E.__)("Cancel","woocommerce-payments")}),(0,u.jsx)(d.Button,{isPrimary:!0,onClick:()=>{S(!1),w(!1),l("");const e=Object.entries(m).filter(([,e])=>e).map(([e])=>e);e.push(c),e.sort(),o(e)},__next40pxDefaultSize:!0,children:(0,E.__)("Update selected","woocommerce-payments")})]}),children:[(0,u.jsx)("div",{className:"add-enabled-currencies-modal__search",children:(0,u.jsx)(d.SearchControl,{__nextHasNoMarginBottom:!0,value:i,onChange:l,placeholder:(0,E.__)("Search currencies","woocommerce-payments")})}),(0,u.jsx)("h3",{children:i?(0,E.sprintf)((0,E.__)("Search results (%1$d currencies)","woocommerce-payments"),p.length):(0,E.__)("All currencies","woocommerce-payments")}),(0,u.jsx)("div",{className:"add-enabled-currencies-modal__content",ref:r,style:{width:f||"auto"},children:(0,u.jsx)(jn,{children:p.map(e=>(0,u.jsx)(In,{checked:m[e],onChange:g,currency:t[e]},t[e].id))})})]}),(0,u.jsx)(d.Button,{variant:"secondary",className:e,onClick:v,"data-testid":"enabled-currencies-add-button",__next40pxDefaultSize:!0,children:(0,E.__)("Add/remove currencies","woocommerce-payments")})]})},Xn=()=>(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("h2",{children:(0,E.__)("Enabled currencies","woocommerce-payments")}),(0,u.jsx)("p",{children:(0,Cn.createInterpolateElement)((0,E.__)("Accept payments in multiple currencies. Prices are converted based on exchange rates and rounding rules. Learn more","woocommerce-payments"),{learnMoreLink:(0,u.jsx)(d.ExternalLink,{href:"https://woocommerce.com/document/woopayments/currencies/multi-currency-setup/#enabled-currencies"})})})]}),Zn=()=>{const{isLoading:e}=fn(),{enabledCurrencies:t,submitEnabledCurrenciesUpdate:n}=wn(),r="wcpay-multi-currency",s=e=>{const r=Object.keys(t);r.splice(r.indexOf(e),1),n(r)},o=t?Object.keys(t):[];return(0,u.jsx)(O,{description:Xn,className:"multi-currency-settings-enabled-currencies-section",children:(0,u.jsxs)(d.Card,{className:`${r}__enabled-currencies`,children:[(0,u.jsxs)(d.CardBody,{className:`${r}__enabled-currencies-header`,children:[(0,u.jsx)("div",{children:(0,E.__)("Name","woocommerce-payments")}),(0,u.jsx)("div",{children:(0,E.__)("Exchange rate","woocommerce-payments")}),(0,u.jsx)("div",{})]}),(0,u.jsx)(d.CardDivider,{}),(0,u.jsx)(d.CardBody,{className:`${r}__enabled-currencies-list-body`,children:(0,u.jsxs)(Pn,{className:"enabled-currencies-list",children:[!e&&t&&o.map(e=>(0,u.jsx)(Jn,{currency:t[e],onDeleteClick:t[e].is_default?void 0:s},t[e].id)),e&&[1,2,3,4,5].map(e=>(0,u.jsx)(Kn,{isLoading:1},"loadable-placeholder-"+e))]})}),(0,u.jsx)(d.CardDivider,{}),(0,u.jsx)(d.CardBody,{className:`${r}__available-currencies-container`,children:t&&(0,u.jsx)(Qn,{className:`${r}__available-currencies-modal`})})]})})},er=({isBusy:e,className:t,children:n})=>(0,u.jsxs)("div",{className:_("wcpay-form-busy-state",t,{"is-busy":e}),"aria-busy":e,children:[(0,u.jsx)("div",{className:"wcpay-form-busy-state__status screen-reader-text",role:"status","aria-live":"polite",children:e?(0,E.__)("Saving…","woocommerce-payments"):""}),n]}),tr=()=>(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("h2",{children:(0,E.__)("Store settings","woocommerce-payments")}),(0,u.jsx)("p",{children:(0,Cn.createInterpolateElement)((0,E.__)("Store settings allow your customers to choose which currency they would like to use when shopping at your store. Learn more","woocommerce-payments"),{learnMoreLink:(0,u.jsx)(d.ExternalLink,{href:"https://woocommerce.com/document/woopayments/currencies/multi-currency-setup/#store-settings"})})})]}),nr=()=>{const{storeSettings:e,isLoading:t,isDirty:n,isSaving:r,updateStoreSettingValues:s,saveStoreSettings:o}=En();(0,c.useEffect)(()=>{n||(window.onbeforeunload=null)},[n]);const[a,i]=(0,c.useState)(!1);return(0,u.jsxs)(er,{isBusy:r,children:[(0,u.jsx)(O,{description:tr,className:"multi-currency-settings-store-settings-section",children:(0,u.jsx)(T,{isLoading:t,numLines:10,children:(0,u.jsxs)(d.Card,{className:"multi-currency-settings__wrapper",children:[(0,u.jsxs)(d.CardBody,{className:"wcpay-card-body",children:[(0,u.jsx)(d.CheckboxControl,{checked:!!e.enable_auto_currency,onChange:e=>s({enable_auto_currency:e}),"data-testid":"enable_auto_currency",label:(0,E.__)("Automatically switch customers to their local currency if it has been enabled","woocommerce-payments"),help:(0,Cn.createInterpolateElement)((0,E.__)("Customers will be notified via store alert banner. Preview","woocommerce-payments"),{previewLink:(0,u.jsx)(d.Button,{isLink:!0,onClick:()=>{i(!0)},__next40pxDefaultSize:!0})}),__nextHasNoMarginBottom:!0}),e.should_recommend_cache_mode?(0,u.jsx)(j,{status:"info",icon:!0,isDismissible:!0,onRemove:()=>{s({cache_recommendation_dismissed:!0}),o()},actions:[{label:(0,E.__)("Use caching mode","woocommerce-payments"),onClick:()=>{s({rendering_mode:"cache"}),o()},isBusy:r,disabled:r}],children:(0,E.__)("We detected that your store uses page caching. Switching Multi-Currency to the caching-optimized rendering mode lets your host cache pages effectively.","woocommerce-payments")}):null,e.is_cache_optimized_feature_enabled?(0,u.jsx)(d.RadioControl,{label:(0,E.__)("Price rendering mode","woocommerce-payments"),help:(0,E.__)('Choose how multi-currency prices are rendered. "Optimized for caching" outputs identical HTML for all visitors and converts prices client-side, allowing hosting providers to cache pages effectively.',"woocommerce-payments"),selected:e.rendering_mode||"speed",options:[{label:(0,E.__)("Optimized for speed (default)","woocommerce-payments"),value:"speed"},{label:(0,E.__)("Optimized for caching","woocommerce-payments"),value:"cache"}],onChange:e=>s({rendering_mode:e})}):null,"Storefront"===e.site_theme?(0,u.jsx)(d.CheckboxControl,{checked:!!e.enable_storefront_switcher,onChange:e=>s({enable_storefront_switcher:e}),"data-testid":"enable_storefront_switcher",label:(0,E.__)("Add a currency switcher to the Storefront theme on breadcrumb section.","woocommerce-payments"),help:(0,Cn.createInterpolateElement)((0,E.sprintf)((0,E.__)("A currency switcher is also available in your widgets. Configure now","woocommerce-payments"),"widgets.php"),{linkToWidgets:(0,u.jsx)("a",{href:"widgets.php"})}),__nextHasNoMarginBottom:!0}):null]}),(0,u.jsx)(xn,{isPreviewModalOpen:a,setPreviewModalOpen:i,isStorefrontSwitcherEnabledValue:!1,isAutomaticSwitchEnabledValue:!0})]})})}),(0,u.jsx)(O,{className:"multi-currency-settings-save-settings-section",children:(0,u.jsx)(d.Button,{isPrimary:!0,isBusy:r,disabled:r||!n,onClick:o,__next40pxDefaultSize:!0,children:(0,E.__)("Save changes","woocommerce-payments")})})]})},rr=()=>(0,u.jsx)("div",{className:"multi-currency-settings",children:(0,u.jsxs)(I,{children:[(0,u.jsx)(Zn,{}),(0,u.jsx)(nr,{})]})}),sr=window.wp.date,or=window.moment;var ar=n.n(or);const cr=window.wc.components,ir=({storeCurrency:e,targetCurrency:t,currencyRate:n=null,roundingValue:r,charmValue:s})=>{const[o,a]=(0,c.useState)(20),i=(0,c.useMemo)(()=>{const e=parseFloat(o.toString().replace(/,/g,"."))*parseFloat(n||t.rate),a=(parseFloat(r)?Math.ceil(e/parseFloat(r))*parseFloat(r):e)+parseFloat(s);return isNaN(a)?(0,E.__)("Please enter a valid number","woocommerce-payments"):((e,t="USD",n=null,r=!1)=>{const s=U(t);s||(e/=100);const o=e<0,a=o?-1*e:e,c=o?"-":"",i=r?(e=>{const t=e.toUpperCase(),{currencyData:n,connect:{country:r="US"}}=wcpaySettings;if(n[r]?.code===t)return R()(n[r]);const s=(0,B.find)(n,{code:t});if(s){const{defaultLocale:e={}}=s;return e.hasOwnProperty("decimalSeparator")&&e.hasOwnProperty("thousandSeparator")&&e.hasOwnProperty("symbolPosition")&&(s.decimalSeparator=e.decimalSeparator,s.thousandSeparator=e.thousandSeparator,s.symbolPosition=e.symbolPosition),R()(s)}return null})(t):((e,t=null)=>{const{currencyData:n,connect:{country:r="US"}}=wcpaySettings,s=(0,B.find)(n,{code:e.toUpperCase()});if(s){if(null!==t&&t.toUpperCase()!==e.toUpperCase()||n[r]){const e=t?(0,B.find)(n,{code:t.toUpperCase()}):n[r];e&&(s.decimalSeparator=e.decimalSeparator,s.thousandSeparator=e.thousandSeparator,s.symbolPosition=e.symbolPosition)}return R()(s)}return null})(t,n);if(null===i)return c+F(a,t,s);try{return c+("function"==typeof i.formatAmount?$(i.formatAmount(a)):$(i.formatCurrency(a)))}catch(e){return c+$(F(a,t,s))}})(U(t.code)?a:100*a,t.code,null,!0)},[o,s,n,r,t]);return(0,u.jsx)(d.Card,{className:"single-currency-settings-preview-wrapper",children:(0,u.jsxs)(d.CardBody,{className:"wcpay-card-body",children:[(0,u.jsx)("div",{children:"left"===e.symbol_position?(0,u.jsx)(cr.TextControlWithAffixes,{label:e.name,prefix:e.symbol,"data-testid":"store_currency_value",value:o.toString(),onChange:a}):(0,u.jsx)(cr.TextControlWithAffixes,{label:e.name,suffix:e.symbol,"data-testid":"store_currency_value",value:o.toString(),onChange:a})}),(0,u.jsx)("div",{children:(0,u.jsx)(cr.TextControlWithAffixes,{"data-testid":"calculated_value",label:t&&t.name,value:i,onChange:()=>null,disabled:!0})})]})})},lr={0:(0,E.__)("None","woocommerce-payments"),.25:"0.25","0.50":"0.50","1.00":"1.00 (recommended)","5.00":"5.00","10.00":"10.00"},ur={1:"1",10:"10",25:"25",50:"50",100:"100 (recommended)",500:"500",1e3:"1000"},dr={"0.00":(0,E.__)("None","woocommerce-payments"),"-0.01":"-0.01","-0.05":"-0.05"},mr={"0.00":(0,E.__)("None","woocommerce-payments"),"-1":"-1","-5":"-5","-10":"-10","-20":"-20","-25":"-25","-50":"-50","-100":"-100"},_r=()=>(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("h2",{children:(0,E.__)("Currency settings","woocommerce-payments")}),(0,u.jsx)("p",{children:(0,E.__)("Choose between automatic or manual exchange rates and modify formatting rules to refine the display of your prices.","woocommerce-payments")})]}),pr=()=>{const{currencyCodeToShowSettingsFor:e,setCurrencyCodeToShowSettingsFor:t}=(0,c.useContext)(Yn),[n,r]=(0,c.useState)(!1),{currencies:s}=fn(),{enabledCurrencies:o}=wn(),{storeSettings:a}=En(),{currencySettings:i,isLoading:m,submitCurrencySettings:_}=(e=>{const{currencySettings:t,isLoading:n}=(0,He.useSelect)(t=>{const{getCurrencySettings:n,isResolving:r}=t(qt);return{currencySettings:n(e),isLoading:r("getCurrencySettings",[e])}}),{submitCurrencySettings:r}=(0,He.dispatch)(qt);return{currencySettings:t,isLoading:n,submitCurrencySettings:r}})(e),p=s.default?s.default:{},y=s.available?.[e]??{},h=!!s.available&&!s.available[e],g=y.is_zero_decimal?ur:lr,b=y.is_zero_decimal?mr:dr,S="automatic",f=y?.is_zero_decimal?"100":"1.00",w="0.00",[v,x]=(0,c.useState)(S),[C,j]=(0,c.useState)(0),[N,k]=(0,c.useState)(f),[P,M]=(0,c.useState)(w),[D,L]=(0,c.useState)(!1);(0,c.useEffect)(()=>{i[e]&&(x(i[e].exchange_rate_type||S),j(i[e].manual_rate||0),k(i[e].price_rounding??f),M(i[e].price_charm||w))},[i,e,f]),(0,c.useEffect)(()=>{h&&t(null)},[h,t]);const A=(e=>{const t=(0,Cn.useRef)();return(0,Cn.useEffect)(()=>{t.current=e}),(0,Cn.useCallback)(()=>{const e=t.current();if(!e)return;const n=e=>{e.preventDefault(),e.returnValue=""};window.addEventListener("beforeunload",n);const r=(0,l.getHistory)().block(t=>(window.confirm(e)&&(r(),t.retry()),!0));return()=>{window.removeEventListener("beforeunload",n),r()}},[])})(()=>n?(0,E.__)("There are unsaved changes on this page. Are you sure you want to leave and discard the unsaved changes?","woocommerce-payments"):void 0);if((0,c.useEffect)(A,[A,n]),h)return null;const R=a.date_format??"M j, Y",B=a.time_format??"g:iA",U=y?(0,sr.dateI18n)(`${R} ${B}`,ar().unix(y.last_updated).toISOString()):"";return(0,u.jsx)("div",{className:"single-currency-settings",children:(0,u.jsxs)(I,{children:[(0,u.jsxs)("h2",{className:"single-currency-settings-breadcrumb",children:[(0,u.jsx)(d.Button,{isLink:!0,onClick:()=>t(null),__next40pxDefaultSize:!0,children:(0,E.__)("Enabled currencies","woocommerce-payments")})," ","> ",y.name," (",y.code,")"," ",y.flag]}),(0,u.jsxs)(er,{isBusy:D,children:[(0,u.jsx)(O,{description:_r,children:(0,u.jsx)(T,{isLoading:m,numLines:33,children:(0,u.jsx)(d.Card,{className:"single-currency-settings-currency-settings",children:(0,u.jsxs)(d.CardBody,{className:"wcpay-card-body",children:[(0,u.jsx)("h4",{children:(0,E.__)("Exchange rate","woocommerce-payments")}),(0,u.jsx)("fieldset",{children:(0,u.jsxs)("ul",{children:[(0,u.jsx)("li",{children:(0,u.jsx)(d.RadioControl,{onChange:e=>{x(e),r(!0),"manual"===e&&j(C||y.rate)},options:[{description:y.last_updated?(0,E.sprintf)((0,E.__)("Current rate: 1 %s = %s %s (Last updated: %s)","woocommerce-payments"),p.code,y.rate,y.code,U):(0,E.__)("Error - Unable to fetch automatic rate for this currency","woocommerce-payments"),label:(0,E.__)("Fetch rates automatically","woocommerce-payments"),value:"automatic"},{description:(0,E.__)("Enter your fixed rate of exchange","woocommerce-payments"),label:(0,E.__)("Manual","woocommerce-payments"),value:"manual"}],selected:v})}),"manual"===v&&(0,u.jsx)("li",{children:(0,u.jsx)(d.TextControl,{"data-testid":"manual_rate_input",label:(0,E.__)("Manual Rate","woocommerce-payments"),help:(0,E.__)("Enter the manual rate you would like to use. Must be a positive number.","woocommerce-payments"),value:C||y.rate,onChange:e=>{j(e.replace(/,/g,".")),r(!0)},__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0})})]})}),(0,u.jsx)("h4",{children:(0,E.__)("Formatting rules","woocommerce-payments")}),(0,u.jsx)("fieldset",{children:(0,u.jsxs)("ul",{children:[(0,u.jsx)("li",{children:(0,u.jsx)(d.SelectControl,{"data-testid":"price_rounding",label:(0,E.__)("Price rounding","woocommerce-payments"),help:kn({mixedString:(0,E.sprintf)((0,E.__)("Make your %s prices consistent by rounding them up after they're converted. {{learnMoreLink}}Learn more{{/learnMoreLink}}","woocommerce-payments"),y.code),components:{learnMoreLink:(0,u.jsx)(d.ExternalLink,{href:"https://woocommerce.com/document/woopayments/currencies/multi-currency-setup/#price-rounding"})}}),value:parseFloat(N),onChange:e=>{k(e),r(!0)},options:Object.keys(g).map(e=>({value:parseFloat(e),label:g[e]})),__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0})}),(0,u.jsx)("li",{children:(0,u.jsx)(d.SelectControl,{"data-testid":"price_charm",label:(0,E.__)("Charm pricing","woocommerce-payments"),help:kn({mixedString:(0,E.sprintf)((0,E.__)("Reduce the converted price for a specific amount. {{learnMoreLink}}Learn more{{/learnMoreLink}}","woocommerce-payments"),y.code),components:{learnMoreLink:(0,u.jsx)(d.ExternalLink,{href:"https://woocommerce.com/document/woopayments/currencies/multi-currency-setup/#charm-pricing"})}}),value:parseFloat(P),onChange:e=>{M(e),r(!0)},options:Object.keys(b).map(e=>({value:parseFloat(e),label:b[e]})),__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0})})]})})]})})})}),(0,u.jsx)(O,{description:()=>(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("h2",{children:(0,E.__)("Preview","woocommerce-payments")}),(0,u.jsx)("p",{children:m?"":(0,E.sprintf)((0,E.__)("Enter a price in your default currency (%s) to see it converted to %s using the exchange rate and formatting rules above.","woocommerce-payments"),p.name,y.name)})]}),children:(0,u.jsx)(T,{isLoading:m,numLines:8,children:(0,u.jsx)(ir,{className:"single-currency-settings-currency-preview",storeCurrency:p,targetCurrency:y,currencyRate:"manual"===v?C:null,roundingValue:N,charmValue:P})})}),(0,u.jsx)(O,{className:"single-currency-settings-save-settings-section",children:(0,u.jsx)(d.Button,{isPrimary:!0,isBusy:D,disabled:D||!n,onClick:async()=>{L(!0),await _(y.code,{exchange_rate_type:v,manual_rate:C,price_rounding:N,price_charm:P}),isNaN(C)||(o[y.code].rate=Number(C)),L(!1),r(!1)},__next40pxDefaultSize:!0,children:(0,E.__)("Save changes","woocommerce-payments")})})]})]})})},yr=()=>{const[e,t]=(0,c.useState)(()=>(0,l.getQuery)().currency||null);return(0,c.useEffect)(()=>(0,l.getHistory)().listen(()=>{t((0,l.getQuery)().currency||null)}),[]),(0,u.jsx)(Yn.Provider,{value:{currencyCodeToShowSettingsFor:e,setCurrencyCodeToShowSettingsFor:e=>{(0,l.updateQueryString)({currency:e||void 0})}},children:e?(0,u.jsx)(pr,{}):(0,u.jsx)(rr,{})})},hr=document.querySelector("#wcpay_multi_currency_settings_container");hr&&(0,i.createRoot)(hr).render((0,u.jsx)(yr,{}))})()})();