/*! For license information please see utils.js.LICENSE.txt */ (()=>{"use strict";var e={n:t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{ConfigurationError:()=>K,SHIPPING_OPTION_REGEX:()=>y,convertCartAddressToPayPal:()=>C,convertFormToJson:()=>B,convertPayPalAddressToCart:()=>S,debounce:()=>z,extractFullName:()=>R,extractShippingMethod:()=>M,fieldsToJson:()=>_,formatPaymentMethod:()=>U,getErrorMessage:()=>j,getFieldValue:()=>E,getPage:()=>I,getPayPalQueryParams:()=>b,getRestPath:()=>x,getRestRoute:()=>$,getSetting:()=>P,isAddPaymentMethod:()=>V,isAdminUser:()=>Q,isCart:()=>F,isCheckout:()=>N,isFieldRequired:()=>X,isMiniCartEnabled:()=>G,isOrderPay:()=>L,isPluginConnected:()=>J,isProduct:()=>D,isProduction:()=>W,isShop:()=>H,isValid:()=>q,isValidAddress:()=>A,isValidFieldValue:()=>T,loadPayPalSdk:()=>h,setFieldValue:()=>k,setSetting:()=>v,submitErrorMessage:()=>O});const r=window.lodash,n=window.jQuery;var o=e.n(n);const i=window.wp.hooks;function a(e,t){void 0===t&&(t={});var r=document.createElement("script");return r.src=e,Object.keys(t).forEach(function(e){r.setAttribute(e,t[e]),"data-csp-nonce"===e&&r.setAttribute("nonce",t["data-csp-nonce"])}),r}function s(e,t){if(void 0===t&&(t=c()),u(e,t),"undefined"==typeof document)return t.resolve(null);var r=function(e){var t="https://www.paypal.com/sdk/js";e.sdkBaseURL&&(t=e.sdkBaseURL,delete e.sdkBaseURL),function(e){var t=e["merchant-id"],r=e["data-merchant-id"],n="",o="";Array.isArray(t)?t.length>1?(n="*",o=t.toString()):n=t.toString():"string"==typeof t&&t.length>0?n=t:"string"==typeof r&&r.length>0&&(n="*",o=r),e["merchant-id"]=n,e["data-merchant-id"]=o}(e);var r,n,o=Object.keys(e).filter(function(t){return void 0!==e[t]&&null!==e[t]&&""!==e[t]}).reduce(function(t,r){var n=e[r].toString();return"data-"===r.substring(0,5)?t.dataAttributes[r]=n:t.queryParams[r]=n,t},{queryParams:{},dataAttributes:{}}),i=o.queryParams,a=o.dataAttributes;return{url:"".concat(t,"?").concat((r=i,n="",Object.keys(r).forEach(function(e){0!==n.length&&(n+="&"),n+=e+"="+r[e]}),n)),dataAttributes:a}}(e),n=r.url,o=r.dataAttributes,i=o["data-namespace"]||"paypal",s=l(i);return function(e,t){var r=document.querySelector('script[src="'.concat(e,'"]'));if(null===r)return null;var n=a(e,t),o=r.cloneNode();if(delete o.dataset.uidAuto,Object.keys(o.dataset).length!==Object.keys(n.dataset).length)return null;var i=!0;return Object.keys(o.dataset).forEach(function(e){o.dataset[e]!==n.dataset[e]&&(i=!1)}),i?r:null}(n,o)&&s?t.resolve(s):function(e,t){void 0===t&&(t=c()),u(e,t);var r=e.url,n=e.attributes;if("string"!=typeof r||0===r.length)throw new Error("Invalid url.");if(void 0!==n&&"object"!=typeof n)throw new Error("Expected attributes to be an object.");return new t(function(e,t){if("undefined"==typeof document)return e();!function(e){var t=e.onSuccess,r=e.onError,n=a(e.url,e.attributes);n.onerror=r,n.onload=t,document.head.insertBefore(n,document.head.firstElementChild)}({url:r,attributes:n,onSuccess:function(){return e()},onError:function(){var e=new Error('The script "'.concat(r,'" failed to load.'));return window.fetch?fetch(r).then(function(r){return 200===r.status&&t(e),r.text()}).then(function(e){var r=function(e){var t=e.split("/* Original Error:")[1];return t?t.replace(/\n/g,"").replace("*/","").trim():e}(e);t(new Error(r))}).catch(function(e){t(e)}):t(e)}})})}({url:n,attributes:o},t).then(function(){var e=l(i);if(e)return e;throw new Error("The window.".concat(i," global variable is not available."))})}function c(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}function l(e){return window[e]}function u(e,t){if("object"!=typeof e||null===e)throw new Error("Expected an options object.");if(void 0!==t&&"function"!=typeof t)throw new Error("Expected PromisePonyfill to be a function.")}let d={},f=!1;const p=new Map;let m=null;const y=/^([\w]+)\:(.+)$/,g={address_1:"address_line_1|line1",address_2:"address_line_2|line2",state:"admin_area_1|state",city:"admin_area_2|city",postcode:"postal_code",country:"country_code"},w={city:"city",state:"state",postal_code:"postcode",country_code:"country"},h=(e=null)=>new Promise((t,n)=>{!e||(0,r.isEmpty)(e)||(0,r.isEqual)(e,d)?window.paypal&&!f?t(window.paypal):(i.defaultHooks.addAction("paypalInstanceCreated","wcPPCP",e=>{t(e)}),i.defaultHooks.addAction("paypalLoadError","wcPPCP",()=>{n()})):(d=e,window.paypal&&i.defaultHooks.doAction("paypalInstanceCleanup",window.paypal),f=!0,s({...e}).then(e=>{t(e),i.defaultHooks.doAction("paypalInstanceCreated",e,d)}).catch(r=>{console.log(r);const o=r?.message?.toLowerCase()||null;let a;if(o){if(o.includes("locale")){const{locale:r,...n}=e;return h(n).then(e=>{t(e)})}o.includes("client-id not recognized")||o.includes("invalid query value for client-id")?a={code:"invalid_client_id"}:o.includes("invalid query value for currency")}i.defaultHooks.doAction("paypalLoadError"),n(a)}).finally(()=>{f=!1}))}),P=e=>void 0!==window.wcPPCPSettings&&e in window.wcPPCPSettings?window.wcPPCPSettings[e]:{},v=(e,t)=>{if(void 0!==window.wcPPCPSettings)return window.wcPPCPSettings[e]=t},b=()=>P("queryParams"),E=(e,t="billing",r=!1)=>("shipping"!=e.substring(0,8)&&"billing"!=e.substring(0,7)&&t&&(e=`${t}_${e}`),r?p.get(e):o()(`[name="${e}"]`).length?o()(`[name="${e}"]`).val():p.get(e)),_=()=>{const e={};return p.forEach((t,r)=>{e[r]=t}),e},k=(e,t,r="billing")=>{r&&"shipping"!=e.substring(0,8)&&"billing"!=e.substring(0,7)&&(e=`${r}_${e}`),p.set(e,t),o()(`[name="${e}"]`).length&&o()(`[name="${e}"]`).val(t)},j=e=>{const t=P("errorMessages");return"string"==typeof e?e:e?.code&&t?.[e.code]?t[e.code]:e?.message?e.message:void 0},O=(e,t,r="checkout")=>{if(e?.message?.toLowerCase()?.match(/detected popup close|window is closed/))return;let n=j(e),i="woocommerce-NoticeGroup";const a=o()(t);"checkout"===r&&(i+=" woocommerce-NoticeGroup-checkout"),n=Array.isArray(e)?'