1/*! For license information please see utils.js.LICENSE.txt */ 2(()=>{"use strict";var e={n:t=>{var n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},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,{SHIPPING_OPTION_REGEX:()=>E,convertCartAddressToPayPal:()=>N,convertFormToData:()=>J,convertPayPalAddressToCart:()=>L,debounce:()=>W,extractFullName:()=>G,extractShippingMethod:()=>F,fieldsToJson:()=>x,formatPaymentMethod:()=>X,getErrorMessage:()=>q,getFieldValue:()=>I,getPage:()=>z,getPayPalQueryParams:()=>T,getRestPath:()=>B,getRestRoute:()=>U,getSetting:()=>k,isAddPaymentMethodPage:()=>$,isAdminUser:()=>Y,isCheckout:()=>Q,isPluginConnected:()=>K,isValid:()=>V,isValidAddress:()=>R,isValidFieldValue:()=>H,loadPayPalSdk:()=>A,setFieldValue:()=>M,setSetting:()=>C,submitErrorMessage:()=>D});const n=window.lodash,r=window.jQuery;var o=e.n(r);const i=window.wp.hooks;function a(e,t){void 0===t&&(t={});var n=document.createElement("script");return n.src=e,Object.keys(t).forEach((function(e){n.setAttribute(e,t[e]),"data-csp-nonce"===e&&n.setAttribute("nonce",t["data-csp-nonce"])})),n}function l(e,t){if(void 0===t&&(t=c()),s(e,t),"undefined"==typeof window)return t.resolve(null);var n=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"],n=e["data-merchant-id"],r="",o="";Array.isArray(t)?t.length>1?(r="*",o=t.toString()):r=t.toString():"string"==typeof t&&t.length>0?r=t:"string"==typeof n&&n.length>0&&(r="*",o=n),e["merchant-id"]=r,e["data-merchant-id"]=o}(e);var n,r,o=Object.keys(e).filter((function(t){return void 0!==e[t]&&null!==e[t]&&""!==e[t]})).reduce((function(t,n){var r=e[n].toString();return"data-"===n.substring(0,5)?t.dataAttributes[n]=r:t.queryParams[n]=r,t}),{queryParams:{},dataAttributes:{}}),i=o.queryParams,a=o.dataAttributes;return{url:"".concat(t,"?").concat((n=i,r="",Object.keys(n).forEach((function(e){0!==r.length&&(r+="&"),r+=e+"="+n[e]})),r)),dataAttributes:a}}(e),r=n.url,o=n.dataAttributes,i=o["data-namespace"]||"paypal",l=u(i);return function(e,t){var n=document.querySelector('script[src="'.concat(e,'"]'));if(null===n)return null;var r=a(e,t),o=n.cloneNode();if(delete o.dataset.uidAuto,Object.keys(o.dataset).length!==Object.keys(r.dataset).length)return null;var i=!0;return Object.keys(o.dataset).forEach((function(e){o.dataset[e]!==r.dataset[e]&&(i=!1)})),i?n:null}(r,o)&&l?t.resolve(l):function(e,t){void 0===t&&(t=c()),s(e,t);var n=e.url,r=e.attributes;if("string"!=typeof n||0===n.length)throw new Error("Invalid url.");if(void 0!==r&&"object"!=typeof r)throw new Error("Expected attributes to be an object.");return new t((function(e,t){if("undefined"==typeof window)return e();!function(e){var t=e.onSuccess,n=e.onError,r=a(e.url,e.attributes);r.onerror=n,r.onload=t,document.head.insertBefore(r,document.head.firstElementChild)}({url:n,attributes:r,onSuccess:function(){return e()},onError:function(){var e=new Error('The script "'.concat(n,'" failed to load.'));return window.fetch?fetch(n).then((function(n){return 200===n.status&&t(e),n.text()})).then((function(e){var n=function(e){var t=e.split("/* Original Error:")[1];return t?t.replace(/\n/g,"").replace("*/","").trim():e}(e);t(new Error(n))})).catch((function(e){t(e)})):t(e)}})}))}({url:r,attributes:o},t).then((function(){var e=u(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 u(e){return window[e]}function s(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.")}var d=["locale"];function f(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];
2if(!n){if(Array.isArray(e)||(n=p(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,l=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){l=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(l)throw i}}}}function v(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i=[],a=!0,l=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(e){l=!0,o=e}finally{try{a||null==n.return||n.return()}finally{if(l)throw o}}return i}}(e,t)||p(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function p(e,t){if(e){if("string"==typeof e)return y(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?y(e,t):void 0}}function y(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function g(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function m(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function h(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?m(Object(n),!0).forEach((function(t){b(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):m(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function b(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var w={},P=!1,O=new Map,j=null,E=/^([\w]+)\:(.+)$/,_={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"},S={city:"city",state:"state",postal_code:"postcode",country_code:"country"},A=function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return new Promise((function(r,o){!t||(0,n.isEmpty)(t)||(0,n.isEqual)(t,w)?window.paypal&&!P?r(window.paypal):(i.defaultHooks.addAction("paypalInstanceCreated","wcPPCP",(function(e){r(e)})),i.defaultHooks.addAction("paypalLoadError","wcPPCP",(function(){o()}))):(w=t,window.paypal&&i.defaultHooks.doAction("paypalInstanceCleanup",window.paypal),P=!0,l(h({},t)).then((function(e){r(e),i.defaultHooks.doAction("paypalInstanceCreated",e,w)})).catch((function(n){var a;console.log(n);var l,c=(null==n||null===(a=n.message)||void 0===a?void 0:a.toLowerCase())||null;if(c){if(c.includes("locale")){t.locale;var u=g(t,d);return e(u).then((function(e){r(e)}))}c.includes("client-id not recognized")||c.includes("invalid query value for client-id")?l={code:"invalid_client_id"}:c.includes("invalid query value for currency")}i.defaultHooks.doAction("paypalLoadError"),o(l)})).finally((function(){P=!1})))}))},k=function(e){return void 0!==window.wcPPCPSettings&&window.wcPPCPSettings[e]||{}},C=function(e,t){if(void 0!==window.wcPPCPSettings)return window.wcPPCPSettings[e]=t},T=function(){return k("queryParams")},I=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"billing";return"shipping"!=e.substring(0,"shipping".length)&&"billing"!=e.substring(0,"billing".length)&&(e="".concat(t,"_").concat(e)),o()('[name="'.concat(e,'"]')).length?o()('[name="'.concat(e,'"]')).val():O.get(e)},x=function(){var e={};return O.forEach((function(t,n){e[n]=t})),e},M=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"billing";n&&"shipping"!=e.substring(0,"shipping".length)&&"billing"!=e.substring(0,"billing".length)&&(e="".concat(n,"_").concat(e)),O.set(e,t),o()('[name="'.concat(e,'"]')).length&&o()('[name="'.concat(e,'"]')).val(t)},q=function(e){var t=k("errorMessages");return"string"==typeof e?e:null!=e&&e.code&&null!=t&&t[e.code]?t[e.code]:null!=e&&e.message?e.message:void 0},D=function(e,t){var n,r,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"checkout";if(null==e||null===(n=e.message)||void 0===n||null===(r=n.toLowerCase())||void 0===r||!r.match(/detected popup close|window is closed/)){var a=q(e),l="woocommerce-NoticeGroup",c=o()(t);"checkout"==i&&(l+=" woocommerce-NoticeGroup-checkout"),a=Array.isArray(e)?'<div class="'+l+'"><ul class="woocommerce-error"><li>'+e.join("</li><li>")+"</li></ul></div>":"string"==typeof e&&/<[^>]*>/.test(e)?'<div class="'+l+'">'+e+"</div>":'<div class="'+l+'"><ul class="woocommerce-error"><li>'+a+"</li></ul></div>",o()(".woocommerce-NoticeGroup-checkout, .woocommerce-error, .woocommerce-message").remove(),c.prepend(a),o().scroll_to_notices?o().scroll_to_notices(c):o()("html, body").animate({scrollTop:c.offset().top-100},1e3)}},R=function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i="undefined"==typeof wc_address_i18n_params?k("i18n"):wc_address_i18n_params;if((0,n.isEmpty)(e))return!1;if(j||(j=JSON.parse(i.locale.replace(/"/g,'"'))),!e.country||(0,n.isEmpty)(e))return!1;var a=null!==(t=j)&&void 0!==t&&t[e.country]?j[e.country]:j.default;a=o().extend(!0,{},j.default,a);var l=Object.entries(a).filter((function(e){var t=v(e,2),n=t[0];return t[1],!r.includes(n)}));for(var c in a=Object.fromEntries(l)){var u;if(null!==(u=a[c])&&void 0!==u&&u.required){var s=(null==e?void 0:e[c])||null;if(!s||null==s||!s.trim())return!1}}return!0},N=function(e){var t={};for(var n in e)if(null!=_&&_[n])if(_[n].includes("|")){var r=v(_[n].split("|"),2),o=r[0];r[1],t[o]=e[n]}else t[_[n]]=e[n];return t},L=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n={};n=t?S:Object.fromEntries(Object.entries(_).map((function(e){var t=v(e,2),n=t[0];return[t[1],n]})));var r={};for(var o in n)if(o.includes("|")){var i,a=o.split("|"),l=f(a);try{for(l.s();!(i=l.n()).done;){var c=i.value;if(e.hasOwnProperty(c)){r[n[o]]=e[c];break}r[n[o]]=""}}catch(e){l.e(e)}finally{l.f()}}else e.hasOwnProperty(o)?r[n[o]]=e[o]:r[n[o]]="";return r},H=function(e){var t;return!!(e=null===(t=e)||void 0===t?void 0:t.trim())},V=function(e){return H(I(e))},F=function(e){var t=e.match(E);return t?b({},t[1],t[2]):null},G=function(e){return[(e=e.trim()).split(" ").slice(0,-1).join(" "),e.split(" ").pop()]},U=function(e){var t,n,r;return(null===(t=k("generalData"))||void 0===t||null===(n=t.restRoutes)||void 0===n||null===(r=n[e])||void 0===r?void 0:r.url)||null},B=function(e){var t,n;return e=e.replace(/^\//,""),null===(t=k("generalData"))||void 0===t||null===(n=t.ajaxRestPath)||void 0===n?void 0:n.replace("%s",e)},z=function(){return k("generalData").page},J=function(e){return e.serializeArray().reduce((function(e,t){return h(h({},e),{},b({},t.name,t.value))}),{})},Q=function(){return"checkout"===z()},$=function(){return"add_payment_method"===z()},X=function(e,t){var n={};Object.keys(t).forEach((function(e){n["{".concat(e,"}")]=t[e]}));var r=e;
2return Object.keys(n).forEach((function(e){for(;r.includes(e);)r=r.replace(e,n[e])})),r},K=function(){var e,t;return(null===(e=k("generalData"))||void 0===e||null===(t=e.clientId)||void 0===t?void 0:t.length)>0},W=function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:250;return function(){for(var r=arguments.length,o=new Array(r),i=0;i<r;i++)o[i]=arguments[i];clearTimeout(t),t=setTimeout((function(){e.apply(void 0,o)}),n)}},Y=function(){var e;return!0===(null===(e=k("generalData"))||void 0===e?void 0:e.is_admin)};(this.wcPPCP=this.wcPPCP||{}).utils=t})(); 3//# sourceMappingURL=utils.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.