mirror of
https://gh.wpcy.net/https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2026-04-25 01:02:18 +08:00
1 line
No EOL
5.2 KiB
JavaScript
1 line
No EOL
5.2 KiB
JavaScript
(()=>{"use strict";function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(t,e){for(var i=0;i<e.length;i++){var o=e[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,n(o.key),o)}}function n(e){var n=function(e){if("object"!=t(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,"string");if("object"!=t(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==t(n)?n:n+""}function i(t,e,n){o(t,e),e.set(t,n)}function o(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}function s(t,e){return t.get(a(t,e))}function r(t,e,n){return t.set(a(t,e),n),n}function a(t,e,n){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:n;throw new TypeError("Private element is not present on this object")}var u=new WeakMap,l=new WeakMap,c=new WeakMap,h=new WeakMap,f=new WeakSet,y=function(){return t=function t(e,n){var a,y,p;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),o(this,p=f),p.add(this),i(this,u,null),i(this,l,{}),i(this,c,null),i(this,h,""),r(u,this,e),r(l,this,n),r(h,this,s(u,this).dataset.ppcpMsgId),null===(a=s(l,this))||void 0===a||!a.endpoint||null===(y=s(l,this))||void 0===y||!y.nonce)throw console.error("Ajax config (Mute):",s(l,this)),new Error("Invalid ajax configuration for DismissibleMessage. Nonce/Endpoint missing");if(!s(h,this))throw console.error("Notice Element:",s(u,this)),new Error("Invalid notice element passed to DismissibleMessage. No MsgId defined");this.onDismissClickProxy=this.onDismissClickProxy.bind(this),this.enableCloseButtons=this.enableCloseButtons.bind(this),this.disableCloseButtons=this.disableCloseButtons.bind(this),this.dismiss=this.dismiss.bind(this),this.addEventListeners()},(n=[{key:"id",get:function(){return s(h,this)}},{key:"closeButton",get:function(){return s(c,this)||r(c,this,s(u,this).querySelector("button.notice-dismiss")),s(c,this)}},{key:"addEventListeners",value:function(){s(u,this).addEventListener("click",this.onDismissClickProxy,!0)}},{key:"removeEventListeners",value:function(){s(u,this).removeEventListener("click",this.onDismissClickProxy,!0)}},{key:"onDismissClickProxy",value:function(t){var e;if(null!==(e=t.target)&&void 0!==e&&e.matches("button.notice-dismiss"))return this.disableCloseButtons(),this.muteMessage(),t.preventDefault(),t.stopPropagation(),!1}},{key:"disableCloseButtons",value:function(){this.closeButton.setAttribute("disabled","disabled"),this.closeButton.style.pointerEvents="none",this.closeButton.style.opacity=0}},{key:"enableCloseButtons",value:function(){this.closeButton.removeAttribute("disabled","disabled"),this.closeButton.style.pointerEvents="",this.closeButton.style.opacity=""}},{key:"showSpinner",value:function(){var t=document.createElement("span");t.classList.add("spinner","is-active","doing-ajax"),s(u,this).appendChild(t)}},{key:"muteMessage",value:function(){a(f,this,p).call(this).then(this.dismiss)}},{key:"dismiss",value:function(){this.removeEventListeners(),this.enableCloseButtons(),this.closeButton.dispatchEvent(new Event("click"))}}])&&e(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,n}();function p(){this.showSpinner();var t={id:this.id,nonce:s(l,this).nonce};return fetch(s(l,this).endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}).then(function(t){return t.json()})}function d(t){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},d(t)}function m(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,v(i.key),i)}}function v(t){var e=function(t){if("object"!=d(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=d(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==d(e)?e:e+""}function b(t,e,n){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:n;throw new TypeError("Private element is not present on this object")}var w=new WeakMap;new(function(){return t=function t(e){var n,i;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,n){(function(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")})(t,e),e.set(t,n)}(this,w,{}),i=e,(n=w).set(b(n,this),i),this.setupDismissibleMessages()},(e=[{key:"setupDismissibleMessages",value:function(){var t,e,n=null===(t=(e=w).get(b(e,this)))||void 0===t||null===(t=t.ajax)||void 0===t?void 0:t.mute_message;document.querySelectorAll(".notice[data-ppcp-msg-id]").forEach(function(t){new y(t,n)})}}])&&m(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}())(window.wc_admin_notices)})(); |