PageSourceSearch

https://japanesegardens.jp/wp-content/plugins/woocommerce/assets/c…/cart.js?ver=6ef41e00d2939992b95c

js japanesegardens.jp collected 2026-10-02 12:22:13 UTC 9,151 bytes, 1 lines download raw bytes

1import*as e from"@woocommerce/stores/store-notices";import*as t from"@wordpress/interactivity";import*as r from"@woocommerce/stores/woocommerce/products";var o={4317:e=>{e.exports=import("@wordpress/a11y")},1167:t=>{t.exports=e}},n={};function s(e){var t=n[e];if(void 0!==t)return t.exports;var r=n[e]={exports:{}};return o[e](r,r.exports,s),r.exports}s.d=(e,t)=>{for(var r in t)s.o(t,r)&&!s.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);const a=(c={getConfig:()=>t.getConfig,store:()=>t.store},d={},s.d(d,c),d),i=({preserveCartData:e=!1})=>{((e,{bubbles:t=!1,cancelable:r=!1,element:o,detail:n={}})=>{if(!CustomEvent)return;o||(o=document.body);const s=new CustomEvent(e,{bubbles:t,cancelable:r,detail:n});o.dispatchEvent(s)})("wc-blocks_added_to_cart",{bubbles:!0,cancelable:!0,detail:{preserveCartData:e}})};var c,d;s.d({},{});const l=e=>e.replace(/^attribute_(pa_)?/,"").replace(/-/g," ").toLowerCase(),u=(e,t)=>l(e)===l(t),{state:m}=(0,a.store)("woocommerce/products",{},{lock:"I acknowledge that using a private store means my plugin will inevitably break on the next store release."});function y(e){return"name"in e}const p=e=>({notice:e.message,type:"error",dismissible:!0}),f=e=>({notice:e,type:"notice",dismissible:!0}),h=(e,t)=>{const r=e.items,o=t.items,n=r.filter(e=>y(e)&&!o.some(t=>e.key===t.key)),s=o.filter(e=>{if(!y(e))return!1;const t=r.find(t=>t.key===e.key);return t&&e.quantity!==t.quantity});return[...n.map(e=>f('"%s" was removed from your cart.'.replace("%s",e.name))),...s.map(e=>f('The quantity of "%1$s" was changed to %2$d.'.replace("%1$s",e.name).replace("%2$d",e.quantity.toString())))]};let g=!1,w=3e3,v=null;const b=new Promise(e=>{v=e});function k({quantityChanges:e}){window.dispatchEvent(new CustomEvent("wc-blocks_store_sync_required",{detail:{type:"from_iAPI",quantityChanges:e}}))}let C=null;async function q(e,t){return await b,C||(C=function(e){const{endpoint:t,getHeaders:r,takeSnapshot:o,rollback:n,commit:s,fetchHandler:a=fetch}=e;let i=null;const c=new Map;let d=[],l=null,u=null;const m=new Map;let y=!1,p=!1,f=[],h=0;function g(){l=null,d.length>0?v():function(){null!==u?s(u):null!==i&&n(i),c.forEach(e=>{const t=m.get(e.id);e.request.onSettled?.({success:!t,...null!==u&&{data:u},...t&&{error:t}})}),p=!1;const e=f;f=[],e.forEach(e=>e()),c.forEach(e=>{const t=m.get(e.id);t?e.reject(t):e.resolve({success:!0,...null!==u&&{data:u}})}),i=null,u=null,m.clear(),c.clear()}()}function w(e,t){for(const r of e)m.set(r,t);g()}async function v(){if(y=!1,0===d.length||null!==l)return;l=[...d],d=[];const e=l,o=r();try{const r=e.map(e=>{const t=c.get(e);return t?{path:t.request.path,method:t.request.method,headers:{...o,"Content-Type":"application/json"},body:t.request.body}:null}).filter(Boolean),n=await a(t,{method:"POST",headers:{"Content-Type":"application/json",...o},body:JSON.stringify({requests:r})});n.ok?function(e,t){t.forEach((t,r)=>{const o=e[r];if(o)if(t.status>=200&&t.status<300)u=t.body;else{const e=t.body;m.set(o,Object.assign(new Error(e?.message||"Request failed"),{code:e?.code||"unknown_error"}))}}),g()}(e,(await n.json()).responses||[]):w(e,new Error(`Request failed: ${n.status}`))}catch(t){w(e,t instanceof Error?t:new Error(String(t)))}}return{submit:function(e){return new Promise((t,r)=>{const n=String(h++);p||(i=o(),p=!0);const s=e.body?JSON.parse(JSON.stringify(e.body)):void 0;e.applyOptimistic&&e.applyOptimistic(),c.set(n,{id:n,request:{...e,body:s},resolve:t,reject:r}),d.push(n),y||null!==l||(y=!0,queueMicrotask(()=>v()))})},getStatus:function(){return{isProcessing:p,pendingCount:d.length}},waitForIdle:function(){return p?new Promise(e=>{f.push(e)}):Promise.resolve()}}}({endpoint:`${e.restUrl}wc/store/v1/batch`,getHeaders:()=>({Nonce:e.nonce}),takeSnapshot:()=>JSON.parse(JSON.stringify(e.cart)),rollback:t=>{e.cart=t},commit:t=>{e.cart=t},fetchHandler:async(...t)=>{const r=await fetch(...t);return e.nonce=r.headers.get("Nonce")||e.nonce,r}})),C.submit(t)}const N="I acknowledge that using a private store means my plugin will inevitably break on the next store release.",{state:S}=(0,a.store)("woocommerce",{},{lock:N}),{actions:I}=(0,a.store)("woocommerce",{state:{findItemInCart:({id:e,key:t,variation:r})=>S.cart.items.find(o=>t?t===o.key:"variation"===o.type?!(e!==o.id||!o.variation||!r||o.variation.length!==r.length)&&((e,t)=>{if(!Array.isArray(e.variation)||!Array.isArray(t))return!1;if(e.variation.length!==t.length)return!1;const r=m.productVariations[e.id]?.parent,o=m.products[r]?.attributes??[];return e.variation.every(({attribute:e,value:r})=>t.some(t=>{const n=o.find(t=>u(e,t.name))?.terms,s=n?.find(e=>e.name===r)?.slug||r;return u(t.attribute,e)&&t.value.toLowerCase()===s?.toLowerCase()}))})(o,r):e===o.id)},actions:{*removeCartItem(e){const t={cartItemsPendingDelete:[e]};let r=null;try{const o=(yield q(S,{path:"/wc/store/v1/cart/remove-item",method:"POST",body:{key:e},applyOptimistic:()=>{S.cart.items=S.cart.items.filter(t=>t.key!==e),r=JSON.parse(JSON.stringify(S.cart))},onSettled:({success:e})=>{e&&k({quantityChanges:t})}})).data;if(o&&r){const e=h(r,o),t=o.errors.map(p);yield I.updateNotices([...e,...t],!0)}}catch(e){I.showNoticeError(e)}},*addCartItem({id:e,key:t,quantity:r,quantityToAdd:o,variation:n},{showCartUpdatesNotices:c=!0}
1={}){if(void 0!==r&&void 0!==o)throw new Error("addCartItem: pass either quantity or quantityToAdd, not both.");const d=Promise.resolve().then(s.bind(s,4317)),l=S.findItemInCart({id:e,key:t,variation:n});let u;u="number"==typeof o?(l?.quantity??0)+o:"number"==typeof r?r:1;const m=!!l?.key,f=m?"update-item":"add-item",g=m?{cartItemsPendingQuantity:l?.key?[l.key]:[]}:{productsPendingAdd:[e]};let w;if(m&&l)w={...l,quantity:u};else{const t=l?u-l.quantity:u;w={id:e,quantity:t,...n&&{variation:n}}}let v=null;try{const e=(yield q(S,{path:`/wc/store/v1/cart/${f}`,method:"POST",body:w,applyOptimistic:()=>{l?y(l)&&l.sold_individually||(l.quantity=u):S.cart.items.push(w),v=JSON.parse(JSON.stringify(S.cart))},onSettled:({success:e})=>{e&&(i({preserveCartData:!0}),k({quantityChanges:g}))}})).data;if(c&&e&&v){const t=h(v,e),r=e.errors.map(p);yield I.updateNotices([...t,...r],!0)}const{messages:t}=(0,a.getConfig)("woocommerce");if(t?.addedToCartText){const{speak:e}=yield d;e(t.addedToCartText,"polite")}}catch(e){I.showNoticeError(e)}},*batchAddCartItems(e,{showCartUpdatesNotices:t=!0}={}){const r=Promise.resolve().then(s.bind(s,4317)),o={};try{const n=e.map((t,r)=>{const n=S.findItemInCart({id:t.id,key:t.key,variation:t.variation});let s;s="number"==typeof t.quantityToAdd?(n?.quantity??0)+t.quantityToAdd:t.quantity??1;const a=!!n?.key,c=a?"update-item":"add-item";let d;if(a&&n)d={key:n.key,id:n.id,quantity:s},o.cartItemsPendingQuantity=[...o.cartItemsPendingQuantity??[],n.key];else{const e=n?s-n.quantity:s;d={id:t.id,quantity:e,...t.variation&&{variation:t.variation}},o.productsPendingAdd=[...o.productsPendingAdd??[],t.id]}const l=r===e.length-1;return q(S,{path:`/wc/store/v1/cart/${c}`,method:"POST",body:d,applyOptimistic:()=>{n?n.quantity=s:S.cart.items.push(d)},...l&&{onSettled:({data:e})=>{e&&(i({preserveCartData:!0}),k({quantityChanges:o}))}}})}),s=JSON.parse(JSON.stringify(S.cart)),c=yield Promise.allSettled(n),d=[...c].reverse().find(e=>"fulfilled"===e.status&&e.value.success);if(d){const e=d.value.data;if(t){const t=h(s,e),r=e.errors.map(p);yield I.updateNotices([...t,...r],!0)}const{messages:o}=(0,a.getConfig)("woocommerce");if(o?.addedToCartText){const{speak:e}=yield r;e(o.addedToCartText,"polite")}}const l=c.filter(e=>"rejected"===e.status).map(e=>p(e.reason));l.length>0&&(yield I.updateNotices(l))}catch(e){I.showNoticeError(e)}},*refreshCartItems(){if(!C?.getStatus().isProcessing&&!g){g=!0;try{const t=yield fetch(`${S.restUrl}wc/store/v1/cart`,{method:"GET",cache:"no-store",headers:{"Content-Type":"application/json"}});S.nonce=t.headers.get("Nonce")||S.nonce,v&&(v(),v=null);const r=yield t.json();if(function(e){return!e.ok}(t))throw e=r,Object.assign(new Error(e.message||"Unknown error."),{code:e.code||"unknown_error"});if(C?.getStatus().isProcessing)return;S.cart=r,w=3e3}catch(e){setTimeout(I.refreshCartItems,w),w*=2}finally{g=!1}var e}},*waitForIdle(){C&&(yield C.waitForIdle())},*showNoticeError(e){yield Promise.resolve().then(s.bind(s,1167));const{actions:t}=(0,a.store)("woocommerce/store-notices",{},{lock:"I acknowledge that using a private store means my plugin will inevitably break on the next store release."}),{code:r,message:o}=e,n=S.errorMessages?.[r]||o;t.addNotice({notice:n,type:"error",dismissible:!0}),console.error(e)},*updateNotices(e=[],t=!1){yield Promise.resolve().then(s.bind(s,1167));const{state:r,actions:o}=(0,a.store)("woocommerce/store-notices",{},{lock:"I acknowledge that using a private store means my plugin will inevitably break on the next store release."}),n=e.map(e=>o.addNotice(e)),{notices:i}=r;t&&i.map(({id:e})=>e).filter(e=>!n.includes(e)).forEach(e=>o.removeNotice(e))}}},{lock:N});I.refreshCartItems(),window.addEventListener("wc-blocks_store_sync_required",async e=>{"from_@wordpress/data"===e.detail.type&&I.refreshCartItems()});

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.