PK
Current Path : /home/wallqcyy/www/wp-content/plugins/woocommerce/assets/client/blocks/ |
Current File : //home/wallqcyy/www/wp-content/plugins/woocommerce/assets/client/blocks/wc-blocks-middleware.js |
(()=>{"use strict";var e={n:t=>{var o=t&&t.__esModule?()=>t.default:()=>t;return e.d(o,{a:o}),o},d:(t,o)=>{for(var r in o)e.o(o,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:o[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.wp.apiFetch;var o=e.n(t);let r="",a=0;try{const e=window.localStorage.getItem("storeApiNonce"),t=e?JSON.parse(e):{};r=t?.nonce||"",a=t?.timestamp||0}catch{}const s=e=>{const t=e.url||e.path;return!(!t||!e.method||"GET"===e.method)&&null!==/wc\/store\/v1\//.exec(t)},n=(e,t)=>{e!==r&&(a&&t<a||(r=e,a=t||Date.now()/1e3,window.localStorage.setItem("storeApiNonce",JSON.stringify({nonce:r,timestamp:a}))))},c=e=>{const t=e.headers||{};return e.headers={...t,Nonce:r},e};o().use(((e,t)=>(s(e)&&(e=c(e),Array.isArray(e?.data?.requests)&&(e.data.requests=e.data.requests.map(c))),t(e,t)))),o().setNonce=e=>{const t="function"==typeof e?.get?e.get("Nonce"):e.Nonce,o="function"==typeof e?.get?e.get("Nonce-Timestamp"):e["Nonce-Timestamp"];t&&n(t,o)},n(wcBlocksMiddlewareConfig.storeApiNonce,wcBlocksMiddlewareConfig.storeApiNonceTimestamp);const i=window.wp.url;o().use(((e,t)=>("string"==typeof e.url&&s(e)&&(e.url=(0,i.addQueryArgs)(e.url,{_locale:"site"})),"string"==typeof e.path&&s(e)&&(e.path=(0,i.addQueryArgs)(e.path,{_locale:"site"})),t(e))));let l=window.localStorage.getItem("storeApiCartHash");o().setCartHash=e=>{const t="function"==typeof e?.get?e.get("Cart-Hash"):e["Cart-Hash"];t&&(e=>{e!==l&&(l=e,window.localStorage.setItem("storeApiCartHash",l))})(t)},(this.wc=this.wc||{}).wcBlocksMiddleware={}})();