(()=>{"use strict";const i=window.wp.blocks,e=window.wp.blockEditor,s=window.wp.data,t=window.wp.components;window.React;const c=window.ReactJSXRuntime,n=JSON.parse('{"UU":"vinoshipper-injector/add-to-cart"}');(0,i.registerBlockType)(n.UU,{edit:function({attributes:i,setAttributes:n}){var l;const{productId:d,accountId:o,includeQty:N,productUnits:r}=i;let j=null!==(l=wp.data.select("core").getSite().vs_injector_account_id)&&void 0!==l?l:null;o&&(j=o);const{producer:a,products:I,productsOptions:u}=(0,s.useSelect)((i=>({...i("vsInjectorProductItemStore").getAll()})));function L(){if(d){return I.find((i=>i.id===d))||{id:d,displayName:null}}return{id:null,displayName:null}}function w(){return a||{id:null,name:"N/A",img:null}}return(0,c.jsxs)("div",{...(0,e.useBlockProps)(),children:[(0,c.jsxs)(e.InspectorControls,{children:[(0,c.jsx)(t.PanelBody,{title:"Settings",children:(0,c.jsx)("fieldset",{children:(0,c.jsx)(t.SelectControl,{label:"Product",options:function(){if(u.length>0)return u;const i=[{label:"No Account ID Found",value:"0",disabled:!0}];return d&&i.push({label:`Product ID #${d}`,value:d,disabled:!1}),i}(),value:d,onChange:i=>{n(i?{productId:parseInt(i)}:{productId:null})},help:(0,c.jsxs)("div",{children:["Products associated to:",(0,c.jsx)("br",{}),w().name," (#",w().id,")"]}),__nextHasNoMarginBottom:!0})})}),(0,c.jsx)(t.PanelBody,{title:"Display",children:(0,c.jsxs)("fieldset",{children:[(0,c.jsx)(t.ToggleControl,{label:"Include Quantity Selector",help:N?"Display the quantity selector.":"Do not display the quantity selector.",checked:N,onChange:i=>{n({includeQty:i})},__nextHasNoMarginBottom:!0}),(0,c.jsx)(t.TextControl,{label:"Product Units",help:'Replace the display of "Qty" in the quantity selector.',checked:r,disabled:!N,onChange:i=>{n({productUnits:i})},__nextHasNoMarginBottom:!0})]})})]}),(0,c.jsx)("div",{className:"vs-injector-block-editor-content",children:(0,c.jsxs)("div",{className:"vs-injector-block-add-to-cart",children:[(0,c.jsxs)("div",{className:"vs-injector-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vcj0iI2ZmZiIvPjwvbGluZWFyR3JhZGllbnQ+PC9kZWZzPjxjaXJjbGUgY2xhc3M9ImNscy0xIiBjeD0iNTEyIiBjeT0iNTEyIiByPSI1MTIiLz48cGF0aCBjbGFzcz0iY2xzLTIiIGQ9Ik01MTIuNTgsNjUxLjQyLDQwNS43NSwyNDZBNDAsNDAsMCwwLDAsMzY3LDIxNi4xNkgzMjMuNzRhNDAuMDUsNDAuMDUsMCwwLDAtMzguNjcsNTAuNUw0MjQuMjEsNzgxLjI1YTY3LjIyLDY3LjIyLDAsMCwwLDY0Ljg4LDQ5LjY3aDQ3YTY3LjE1LDY3LjE1LDAsMCwwLDUzLjUtMjYuNjFDNTUzLjQzLDgwMyw1MzQuMzcsNzM0LjkxLDUxMi41OCw2NTEuNDJaIi8+PHBhdGggY2xhc3M9ImNscy0zIiBkPSJNNzAxLjQ0LDIxNi4xNkg2NTguMTVBNDAuMDUsNDAuMDUsMCwwLDAsNjE5LjQyLDI0Nkw1MTIuNTgsNjUxLjQyYzIxLjc5LDgzLjQ5LDQwLjg1LDE1MS41Nyw3NywxNTIuODlBNjguMzIsNjguMzIsMCwwLDAsNjAxLDc4MS4yNUw3NDAuMSwyNjYuNjZBNDAuMDUsNDAuMDUsMCwwLDAsNzAxLjQ0LDIxNi4xNloiLz48L3N2Zz4K",className:"vs-icon",alt:"Vinoshipper"}),(0,c.jsx)("h2",{children:"Add To Cart"})]}),j&&(0,c.jsxs)("div",{children:[(0,c.jsxs)("h3",{children:[L().displayName&&(0,c.jsx)("span",{dangerouslySetInnerHTML:{__html:L().displayName}}),!L().displayName&&L().id&&(0,c.jsxs)("span",{children:["Product: #",L()?.id]}),!d&&(0,c.jsx)("strong",{children:"Warning: No Product Set!"})]}),(0,c.jsxs)("ul",{children:[!N&&(0,c.jsx)("li",{children:"Will not display the quantity selector."}),r&&(0,c.jsxs)("li",{children:["Units: ",r]})]})]}),!j&&(0,c.jsxs)("div",{className:"vs-injector-block-error",children:[(0,c.jsx)("h3",{children:"Vinoshipper Account ID: Missing"}),(0,c.jsx)("p",{children:"Please set your Vinoshipper Account ID in the Vinoshipper settings before using any Vinoshipper blocks."})]})]})})]})}})})();