import{g as y,w as m}from"./vendor-vue-runtime-dom-B2rky8vu.js";import{u as F}from"./admin-BM775jCq.js";import"./settings.consts-C6F6lZ8o.js";import{B as x}from"./ThemeToggle-a3yohy6x.js";import"./vendor-vueform-slider-CCH9_7pb.js";import{u as E}from"./OrderForm--Em8u8hn.js";import{d as I,e as S,f as p,i as d,j as _,m as A,F as L,r as M,x as l}from"./vendor-vue-runtime-core-DwK6Ry68.js";import{r as f,u as i}from"./vendor-vue-reactivity-CheHbvBM.js";import{a as z}from"./vendor-vue-shared-DrzsEcag.js";import{_ as N}from"./vendor-vue3-html2pdf-KR020wX8.js";const V={class:"ccb-of-options"},$=["onDragover"],j=["aria-label","onDragstart"],G={class:"ccb-of-options__input-wrap"},H=["placeholder","value","onInput"],R=["aria-label","onClick"],Y=I({__name:"OrderFormOptionsEditor",setup(q){const{optionsList:v,updateOption:b,removeOption:O,addOption:h,reorderOptions:D}=E(),T=F(),g=S(()=>T.getTranslations),s=f(!1),n=f(null),e=f(null),w=(a,t)=>{s.value=!0,n.value=a,e.value=a,t.dataTransfer&&(t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("text/plain",String(a)))},B=(a,t)=>{if(n.value===null)return;const u=t.currentTarget;if(!u)return;const o=u.getBoundingClientRect(),r=t.clientY>o.top+o.height/2;let c=a+(r?1:0);c=Math.max(0,Math.min(c,v.value.length)),e.value=c},C=()=>{s.value=!1,e.value=null,n.value=null},k=()=>{if(n.value!==null&&e.value!==null){const a=n.value;let t=e.value;t>a&&(t-=1),t!==a&&D(a,t)}s.value=!1,e.value=null,n.value=null};return(a,t)=>(d(),p("div",V,[_(y,{name:"of-option-row",tag:"div",class:"ccb-of-options__list"},{default:A(()=>[(d(!0),p(L,null,M(i(v),(u,o)=>(d(),p("div",{key:`option_${o}`,class:z(["ccb-of-options__row",{"is-dragging":s.value&&o===n.value,"is-drop-before":s.value&&e.value===o,"is-drop-after":s.value&&e.value===o+1}]),onDragover:m(r=>B(o,r),["prevent"]),onDrop:m(k,["prevent"])},[l("button",{class:"ccb-of-options__drag",type:"button",tabindex:"-1",draggable:"true","aria-label":g.value.dragOption,onDragstart:r=>w(o,r),onDragend:C},t[0]||(t[0]=[l("i",{class:"ccb-icon-drag-dots"},null,-1)]),40,j),l("div",G,[l("input",{class:"ccb-of-options__input",type:"text",placeholder:"Option "+(o+1),value:u.optionText,onInput:r=>i(b)(o,r.target.value)},null,40,H)]),l("button",{class:"ccb-of-options__remove",type:"button","aria-label":g.value.removeOption,onClick:r=>i(O)(o)},t[1]||(t[1]=[l("i",{class:"ccb-icon-close-x"},null,-1)]),8,R)],42,$))),128))]),_:1}),_(i(x),{label:"Add Option",type:"green-ghost",size:"xs",iconLeft:"ccb-icon-ic_plus_big",onClick:i(h),style:{width:"124px"}},null,8,["onClick"])]))}}),at=N(Y,[["__scopeId","data-v-b807a47a"]]);export{at as O};
//# sourceMappingURL=OrderFormOptionsEditor-DqGOht0q.js.map
