!function(){"use strict";var e=window.wp.element,t=window.wp.components,n=n=>{let{name:a,val:l,setValue:r}=n;document.addEventListener("term-submited",(()=>{o("")}));const o=e=>{"string"!=typeof e?e.hasOwnProperty("hex")&&r(e.hex):r(e)};return(0,e.createElement)(e.Fragment,null,(0,e.createElement)(t.Dropdown,{className:"sp-swatches-color",position:"bottom right",renderContent:()=>(0,e.createElement)(t.ColorPicker,{color:l,onChangeComplete:o,disableAlpha:!0}),renderToggle:n=>{let{onToggle:r}=n;return(0,e.createElement)("div",{className:"product-variation-color-wrapper"},(0,e.createElement)(t.ColorIndicator,{onClick:r,colorValue:l}),(0,e.createElement)(t.TextControl,{name:a,onChange:o,onClick:r,value:l}))}}))},a=window.wp.i18n,l=window.wp.mediaUtils,r=n=>{let{name:r,val:o,setValue:m}=n;document.addEventListener("term-submited",(()=>{c("")}));const c=e=>{"string"!=typeof e?e.hasOwnProperty("url")&&m(e.url):m(e)};return(0,e.createElement)(e.Fragment,null,(0,e.createElement)(l.MediaUpload,{onSelect:c,allowedTypes:["image"],render:n=>{let{open:l}=n;return((n,l)=>n?(0,e.createElement)(e.Fragment,null,(0,e.createElement)("div",{className:"sp-vs-image-toggle image",style:{backgroundImage:`url(${n})`},onClick:l,onKeyDown:l,role:"button",tabIndex:0}),(0,e.createElement)("div",{className:"sp-vs-buttons-wrapper"},(0,e.createElement)(t.Button,{isSecondary:!0,onClick:l},(0,a.__)("Replace image","sparks-for-woocommerce")),(0,e.createElement)(t.Button,{isLink:!0,isDestructive:!0,onClick:()=>c("")},(0,a.__)("Remove image","sparks-for-woocommerce")))):(0,e.createElement)(t.Button,{onClick:l,className:"sp-vs-image-toggle placeholder"},(0,a.__)("Set variation image","sparks-for-woocommerce")))(o,l)}}),(0,e.createElement)(t.TextControl,{type:"hidden",name:r,value:o||""}))};const o=document.getElementById("sp-swatches-custom-fields");if(null!=o){const a=o.getAttribute("data-type"),l=o.getAttribute("data-name");let m=o.getAttribute("data-value");m=m||"",(0,e.render)((0,e.createElement)((a=>{let{name:l,type:o,value:m}=a;const[c,s]=(0,e.useState)(m);return"color"===o?(0,e.createElement)(n,{name:l,val:c,setValue:s}):"image"===o?(0,e.createElement)(r,{name:l,val:c,setValue:s}):"label"===o?(0,e.createElement)(e.Fragment,null,(0,e.createElement)(t.TextControl,{name:l,onChange:e=>{s(e)},value:c})):null}),{name:l,type:a,value:m}),o)}}();