(()=>{"use strict";var e,o,t,r={9342:(e,o,t)=>{const r=window.wp.blocks;var i=t(4530),s=t(6012);const n=JSON.parse('{"name":"woocommerce/add-to-cart-with-options-variation-selector-attribute","title":"Variation Selector: Template (Beta)","description":"A template for attribute name and options that will be applied to all variable products with attributes.","category":"woocommerce-product-elements","keywords":["WooCommerce"],"usesContext":["postId"],"ancestor":["woocommerce/add-to-cart-with-options-variation-selector"],"textdomain":"woocommerce","apiVersion":3,"$schema":"https://schemas.wp.org/trunk/block.json","supports":{"inserter":false,"interactivity":true}}');var a=t(6087);const c=window.wp.blockEditor,l=window.wp.data,d=window.wc.wcBlocksSharedContext;var m=t(7723);const u=[{id:1,taxonomy:"pa_color",name:(0,m.__)("Color","woocommerce"),has_variations:!0,terms:[{id:1,slug:"blue",name:(0,m.__)("Blue","woocommerce")},{id:2,slug:"red",name:(0,m.__)("Red","woocommerce")},{id:3,slug:"green",name:(0,m.__)("Green","woocommerce")}]},{id:2,taxonomy:"pa_size",name:(0,m.__)("Size","woocommerce"),has_variations:!0,terms:[{id:1,slug:"sm",name:(0,m.__)("Small","woocommerce")},{id:2,slug:"md",name:(0,m.__)("Medium","woocommerce")},{id:3,slug:"lg",name:(0,m.__)("Large","woocommerce")}]}];var p=t(790);function w({blocks:e,isSelected:o,onSelect:t}){const r=(0,c.__experimentalUseBlockPreview)({blocks:e}),i=(0,c.useInnerBlocksProps)({role:"listitem"},{templateLock:"insert"});return(0,p.jsxs)(p.Fragment,{children:[o?(0,p.jsx)("div",{...i}):(0,p.jsx)(p.Fragment,{}),(0,p.jsx)("div",{role:"listitem",style:{display:o?"none":void 0},children:(0,p.jsx)("div",{...r,role:"button",tabIndex:0,onClick:t,onKeyDown:t})})]})}(0,r.registerBlockType)(n,{edit:function(e){const{clientId:o}=e,{className:t}=e.attributes,r=(0,c.useBlockProps)({className:t}),{product:i}=(0,d.useProductDataContext)(),s="variable"===i.type?i.attributes:u,{blocks:n}=(0,l.useSelect)((e=>{const{getBlocks:t}=e(c.store);return{blocks:t(o)}}),[o]),[m,b]=(0,a.useState)();return(0,p.jsx)("div",{...r,role:"list",children:s.map((e=>(0,p.jsx)(d.CustomDataProvider,{id:"attribute",data:e,children:(0,p.jsx)(w,{blocks:n,isSelected:(m||s[0]?.id)===e.id,onSelect:()=>b(e.id)})},e.id)))})},attributes:n.attributes,icon:{src:(0,p.jsx)(i.A,{icon:s.A,className:"wc-block-editor-components-block-icon"})},save:function(){const e=c.useBlockProps.save(),o=c.useInnerBlocksProps.save({...e,role:"listitem"});return(0,p.jsx)("div",{...o})}})},1609:e=>{e.exports=window.React},790:e=>{e.exports=window.ReactJSXRuntime},6087:e=>{e.exports=window.wp.element},7723:e=>{e.exports=window.wp.i18n},5573:e=>{e.exports=window.wp.primitives}},i={};function s(e){var o=i[e];if(void 0!==o)return o.exports;var t=i[e]={exports:{}};return r[e].call(t.exports,t,t.exports,s),t.exports}s.m=r,e=[],s.O=(o,t,r,i)=>{if(!t){var n=1/0;for(d=0;d<e.length;d++){for(var[t,r,i]=e[d],a=!0,c=0;c<t.length;c++)(!1&i||n>=i)&&Object.keys(s.O).every((e=>s.O[e](t[c])))?t.splice(c--,1):(a=!1,i<n&&(n=i));if(a){e.splice(d--,1);var l=r();void 0!==l&&(o=l)}}return o}i=i||0;for(var d=e.length;d>0&&e[d-1][2]>i;d--)e[d]=e[d-1];e[d]=[t,r,i]},s.n=e=>{var o=e&&e.__esModule?()=>e.default:()=>e;return s.d(o,{a:o}),o},t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,s.t=function(e,r){if(1&r&&(e=this(e)),8&r)return e;if("object"==typeof e&&e){if(4&r&&e.__esModule)return e;if(16&r&&"function"==typeof e.then)return e}var i=Object.create(null);s.r(i);var n={};o=o||[null,t({}),t([]),t(t)];for(var a=2&r&&e;"object"==typeof a&&!~o.indexOf(a);a=t(a))Object.getOwnPropertyNames(a).forEach((o=>n[o]=()=>e[o]));return n.default=()=>e,s.d(i,n),i},s.d=(e,o)=>{for(var t in o)s.o(o,t)&&!s.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:o[t]})},s.o=(e,o)=>Object.prototype.hasOwnProperty.call(e,o),s.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.j=9860,(()=>{var e={9860:0};s.O.j=o=>0===e[o];var o=(o,t)=>{var r,i,[n,a,c]=t,l=0;if(n.some((o=>0!==e[o]))){for(r in a)s.o(a,r)&&(s.m[r]=a[r]);if(c)var d=c(s)}for(o&&o(t);l<n.length;l++)i=n[l],s.o(e,i)&&e[i]&&e[i][0](),e[i]=0;return s.O(d)},t=globalThis.webpackChunkwebpackWcBlocksMainJsonp=globalThis.webpackChunkwebpackWcBlocksMainJsonp||[];t.forEach(o.bind(null,0)),t.push=o.bind(null,t.push.bind(t))})();var n=s.O(void 0,[94],(()=>s(9342)));n=s.O(n),((this.wc=this.wc||{}).blocks=this.wc.blocks||{})["add-to-cart-with-options-variation-selector-attribute"]=n})();