import{m as O}from"./vendor-vueform-slider-CCH9_7pb.js";import{u as P}from"./useFieldsExtraOptions-BNwbfzEK.js";import{d as J,e as p,w as N,f as v,i as V,x as u,j as $,t as _,F as B,r as z}from"./vendor-vue-runtime-core-DwK6Ry68.js";import{t as A,r as E,u as l}from"./vendor-vue-reactivity-CheHbvBM.js";import{t as x,b as D,a as L}from"./vendor-vue-shared-DrzsEcag.js";import"./settingsStore-8bwiLMEn.js";import"./vendor-pinia-BSPefQhS.js";import"./convert-case-to-camel-case.utils-CK5dBN7n.js";const R={class:"slider-min-max"},U={class:"label"},q={class:"label"},G={class:"custom-marks"},H=["onClick"],ee=J({__name:"Flat",props:{field:{},modelValue:{}},emits:["update:modelValue"],setup(h,{emit:C}){const n=h,{field:t}=A(n),{formatMinMax:y}=P(t),M=p(()=>t.value.jump?1:Number(t.value.step||1)),o=p(()=>Number(t.value.min)),r=p(()=>Number(t.value.max)),f=E(n.modelValue),b=p(()=>t.value.jump),m=C,S=e=>{m("update:modelValue",Array.isArray(e)?e:[e])},F=e=>{const s=e.toFixed(2);return parseFloat(s).toString()},i=p(()=>{var s;return(((s=t.value.scalePoints)==null?void 0:s.trim())||"").split(",").map(a=>Number(a.trim())).filter(a=>!isNaN(a)&&a>=o.value&&a<=r.value)}),j=e=>({left:`${(e-o.value)/(r.value-o.value)*100}%`}),g=e=>{t.value.disabled||b.value&&m("update:modelValue",[f.value[0],e])},w=e=>{b.value&&i.value.includes(e)&&m("update:modelValue",[e,f.value[1]])};return N(()=>n.modelValue,e=>{f.value=e}),N(f,e=>{if(b.value){const s=i.value.reduce((d,c)=>Math.abs(c-e[0])<Math.abs(d-e[0])?c:d,i.value[0]),a=i.value.reduce((d,c)=>Math.abs(c-e[1])<Math.abs(d-e[1])?c:d,i.value[0]),k=[s,a];JSON.stringify(k)!==JSON.stringify(n.modelValue)&&m("update:modelValue",k)}else JSON.stringify(e)!==JSON.stringify(n.modelValue)&&m("update:modelValue",e)}),(e,s)=>(V(),v("div",{class:L(["slider-wrapper ccb-flat-multi-range-field",{jump:l(t).jump}])},[u("div",R,[u("div",{class:"slider-min-max-item first",onClick:s[0]||(s[0]=a=>w(o.value))},[u("span",U,x(l(y)(o.value)),1)]),u("div",{class:"slider-min-max-item",onClick:s[1]||(s[1]=a=>g(r.value))},[u("span",q,x(l(y)(r.value)),1)])]),$(l(O),{style:{margin:"10px 0"},format:F,min:l(t).min,max:l(t).max,step:M.value,disabled:l(t).disabled,modelValue:e.modelValue,"onUpdate:modelValue":S,"show-tooltip":"focus"},null,8,["min","max","step","disabled","modelValue"]),u("div",G,[l(t).scalePoints?(V(!0),v(B,{key:0},z(i.value,a=>(V(),v("div",{key:a,class:"mark",style:D(j(a))},[a!==o.value&&a!==r.value?(V(),v("div",{key:0,class:"label",onClick:k=>g(a)},x(a),9,H)):_("",!0)],4))),128)):_("",!0)])],2))}});export{ee as default};
//# sourceMappingURL=Flat-CKJSgjKS.js.map
