import{D as v,_ as w,r as n,o as i,d as m,e as q,a as l,t as h,g as f,c as p,b as E,i as V,F as y}from"./app-PFKfXWEI.js";import{a as C}from"./_baseIsEqual-DTBiz6Tr.js";import{M as S}from"./Modal-c7b3PsDt.js";import{T as B}from"./TextInput-CNd7BHfN.js";import{A as I}from"./AutoComplete-D56ZVB9O.js";import{L as D}from"./LoadingButton-DuL9lXrz.js";var d,_;function F(){if(_)return d;_=1;var e=C();function t(o,u){return e(o,u)}return d=t,d}var L=F();const O=v(L),M={emits:["close","selected"],components:{AutoComplete:I,LoadingButton:D,Modal:S,TextInput:B},props:{variants:{required:!0},nf:String,show:{default:!1},maxWidth:{default:"2xl"},closeable:{default:!0}},data(){return{sku:null,error:null}},watch:{sku:{immediate:!0,handler(e){e&&e.length==36&&(this.error=null,this.$emit("selected",e))}}},mounted(){this.error=null,document.getElementById("variation-sku").focus()},methods:{checkSelected(){this.variants.find(e=>!e.selected)||this.add()},add(){if(this.variants.find(e=>!e.selected))this.error=this.$t("Please select all the variants");else{let e={};this.variants.map(t=>t.selected?e[t.name]=t.selected:""),this.error=null,this.$emit("selected",e)}},close(){this.$emit("close")}}},N={class:"relative px-6 py-4"},U={class:"text-lg font-bold"},j={class:"mt-4"},A={class:"py-2 mx-auto max-w-7xl"},T={key:0,class:"text-red-600 px-4 py-3 mb-6 rounded-md bg-red-100"},W={class:"flex items-start gap-6"};function P(e,t,o,u,r,c){const x=n("icons"),g=n("text-input"),b=n("auto-complete"),k=n("modal");return i(),m(k,{show:o.show,"max-width":o.maxWidth,closeable:o.closeable,onClose:c.close},{default:q(()=>[l("div",N,[l("h3",U,h(e.$t("Select Variants")),1),l("button",{onClick:t[0]||(t[0]=s=>c.close()),class:"fixed top-2 right-2 flex items-center justify-center h-8 w-8 rounded-full text-gray-600 hover:text-gray-800 hover:bg-gray-300 focus:outline-none"},[f(x,{name:"cross",class:"h-5 w-5"})]),l("div",j,[l("section",A,[r.error||o.nf?(i(),p("div",T,h(r.error||o.nf),1)):E("",!0),f(g,{class:"w-full block mb-6",id:"variation-sku",modelValue:r.sku,"onUpdate:modelValue":t[1]||(t[1]=s=>r.sku=s),placeholder:e.$t("Scan barcode")},null,8,["modelValue","placeholder"]),l("div",W,[(i(!0),p(y,null,V(o.variants,s=>(i(),m(b,{key:s.sku,class:"w-1/2",id:s.sku,label:e.$t(s.name),modelValue:s.selected,"onUpdate:modelValue":[a=>s.selected=a,c.checkSelected],position:"bottom-12 sm:top-12",suggestions:s.option.filter(a=>a).map(a=>e.$t(a))},null,8,["id","label","modelValue","onUpdate:modelValue","suggestions"]))),128))])])])])]),_:1},8,["show","max-width","closeable","onClose"])}const Q=w(M,[["render",P]]);export{Q as S,O as _};
