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