whoami7 - Manager
:
/
home
/
dataiclx
/
vielorbe.com
/
wp-content
/
plugins
/
surecart
/
dist
/
components
/
components
/
Upload File:
files >> //home/dataiclx/vielorbe.com/wp-content/plugins/surecart/dist/components/components/functions.js
function findScript(t,e){var r=document.querySelector('script[src="'.concat(t,'"]'));if(null===r)return null;var n=createScriptElement(t,e),a=r.cloneNode();if(delete a.dataset.uidAuto,Object.keys(a.dataset).length!==Object.keys(n.dataset).length)return null;var o=!0;return Object.keys(a.dataset).forEach((function(t){a.dataset[t]!==n.dataset[t]&&(o=!1)})),o?r:null}function insertScriptElement(t){var e=t.url,r=t.attributes,n=t.onSuccess,a=t.onError,o=createScriptElement(e,r);o.onerror=a,o.onload=n,document.head.insertBefore(o,document.head.firstElementChild)}function processOptions(t){var e="https://www.paypal.com/sdk/js";t.sdkBaseURL&&(e=t.sdkBaseURL,delete t.sdkBaseURL),processMerchantID(t);var r=Object.keys(t).filter((function(e){return void 0!==t[e]&&null!==t[e]&&""!==t[e]})).reduce((function(e,r){var n=t[r].toString();return"data-"===r.substring(0,5)?e.dataAttributes[r]=n:e.queryParams[r]=n,e}),{queryParams:{},dataAttributes:{}}),n=r.queryParams,a=r.dataAttributes;return{url:"".concat(e,"?").concat(objectToQueryString(n)),dataAttributes:a}}function objectToQueryString(t){var e="";return Object.keys(t).forEach((function(r){0!==e.length&&(e+="&"),e+=r+"="+t[r]})),e}function parseErrorMessage(t){var e=t.split("/* Original Error:")[1];return e?e.replace(/\n/g,"").replace("*/","").trim():t}function createScriptElement(t,e){void 0===e&&(e={});var r=document.createElement("script");return r.src=t,Object.keys(e).forEach((function(t){r.setAttribute(t,e[t]),"data-csp-nonce"===t&&r.setAttribute("nonce",e["data-csp-nonce"])})),r}function processMerchantID(t){var e=t["merchant-id"],r=t["data-merchant-id"],n="",a="";return Array.isArray(e)?e.length>1?(n="*",a=e.toString()):n=e.toString():"string"==typeof e&&e.length>0?n=e:"string"==typeof r&&r.length>0&&(n="*",a=r),t["merchant-id"]=n,t["data-merchant-id"]=a,t}function loadScript(t,e){if(void 0===e&&(e=getDefaultPromiseImplementation()),validateArguments(t,e),"undefined"==typeof document)return e.resolve(null);var r=processOptions(t),n=r.url,a=r.dataAttributes,o=a["data-namespace"]||"paypal",i=getPayPalWindowNamespace(o);return findScript(n,a)&&i?e.resolve(i):loadCustomScript({url:n,attributes:a},e).then((function(){var t=getPayPalWindowNamespace(o);if(t)return t;throw new Error("The window.".concat(o," global variable is not available."))}))}function loadCustomScript(t,e){void 0===e&&(e=getDefaultPromiseImplementation()),validateArguments(t,e);var r=t.url,n=t.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 e((function(t,e){if("undefined"==typeof document)return t();insertScriptElement({url:r,attributes:n,onSuccess:function(){return t()},onError:function(){var t=new Error('The script "'.concat(r,'" failed to load.'));return window.fetch?fetch(r).then((function(r){return 200===r.status&&e(t),r.text()})).then((function(t){var r=parseErrorMessage(t);e(new Error(r))})).catch((function(t){e(t)})):e(t)}})}))}function getDefaultPromiseImplementation(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}function getPayPalWindowNamespace(t){return window[t]}function validateArguments(t,e){if("object"!=typeof t||null===t)throw new Error("Expected an options object.");if(void 0!==e&&"function"!=typeof e)throw new Error("Expected PromisePonyfill to be a function.")}const getScriptLoadParams=({clientId:t,reusable:e,merchantId:r,currency:n="usd",merchantInitiated:a})=>({"client-id":t.replace(/ /g,""),...!e||a?{"merchant-id":r.replace(/ /g,"")}:{},commit:!1,intent:e?"tokenize":"capture",vault:!0,currency:n?n.toUpperCase():"USD"});export{getScriptLoadParams as g,loadScript as l};
Copyright ©2021 || Defacer Indonesia