import{m as h}from"./slider-B0ER1pJ5.js";import{u as B}from"./useFieldsExtraOptions-BAS3Fj_1.js";import{a as D,k as S,C as L,b as r,O as w,o as E,Q as O,m,g as d,p as o,n as q,D as x,u as i,I as b,q as N,F as z,H as U,P as H}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 I={class:"slider-min-max"},Q={class:"label"},R={class:"label"},T={class:"custom-marks"},A=["onClick"],ee=D({__name:"MultiPoint",props:{field:{},modelValue:{}},emits:["update:modelValue"],setup(F,{emit:P}){const c=F,v=P,y=S(c.modelValue),{field:l}=L(c),{formatMinMax:C}=B(l),k=r({get:()=>c.modelValue,set:a=>v("update:modelValue",a)}),s=r(()=>Number(l.value.min)),u=r(()=>Number(l.value.max)),_=r(()=>l.value.jump?1:Number(l.value.step||1)),M=r(()=>l.value.jump),p=r(()=>{var t;return(((t=l.value.scalePoints)==null?void 0:t.trim())||"").split(",").map(e=>Number(e.trim())).filter(e=>!isNaN(e)&&e>=s.value&&e<=u.value)}),V=a=>{M.value&&p.value.includes(a)&&(n.value=a.toString(),v("update:modelValue",a))},j=a=>({left:`${(a-s.value)/(u.value-s.value)*100}%`});w(()=>c.modelValue,a=>{y.value=a,n.value=a.toString()});const $=a=>{const t=a.toFixed(2);return parseFloat(t).toString()};let f,n=S("0");return E(()=>{l.value.defaultValue&&(n.value=l.value.defaultValue.toString());const a=document.querySelector(`[data-id="${l.value.alias}"] .slider-tooltip`);a&&(f=new MutationObserver(t=>{for(const e of t)e.type==="childList"&&setTimeout(()=>{n.value=a.textContent??""},130)}),f.observe(a,{childList:!0,subtree:!0,characterData:!0}))}),O(()=>{f&&f.disconnect()}),w(y,a=>{if(M.value){const t=p.value.reduce((e,g)=>Math.abs(g-a)<Math.abs(e-a)?g:e,p.value[0]);v("update:modelValue",t)}else v("update:modelValue",a)}),(a,t)=>(d(),m("div",{class:b(["slider-wrapper ccb-multi-point-range-field",{jump:i(l).jump}])},[o("div",I,[o("div",{class:"slider-min-max-item first",onClick:t[0]||(t[0]=e=>V(s.value))},[t[3]||(t[3]=o("span",{class:"tick"},null,-1)),o("span",Q,x(i(C)(s.value)),1)]),o("div",{class:b(["slider-min-max-item",{done:k.value>=u.value}]),onClick:t[1]||(t[1]=e=>V(u.value))},[t[4]||(t[4]=o("span",{class:"tick"},null,-1)),o("span",R,x(i(C)(u.value)),1)],2)]),q(i(h),{modelValue:k.value,"onUpdate:modelValue":t[2]||(t[2]=e=>k.value=e),min:s.value,max:u.value,step:_.value,disabled:i(l).disabled,"show-tooltip":"focus",class:"custom-slider",format:$},null,8,["modelValue","min","max","step","disabled"]),o("div",T,[i(l).scalePoints?(d(!0),m(z,{key:0},U(p.value,e=>(d(),m("div",{key:e,class:"mark",style:H(j(e))},[e!==s.value&&e!==u.value?(d(),m("div",{key:0,class:b(["tick",{"tick-passed":e<=Number(i(n))}])},null,2)):N("",!0),e!==s.value&&e!==u.value?(d(),m("div",{key:1,class:b(["label",{"label-passed":e<=Number(i(n))}]),onClick:g=>V(e)},x(e),11,A)):N("",!0)],4))),128)):N("",!0)])],2))}});export{ee as default};
//# sourceMappingURL=MultiPoint-DUVCTDW5.js.map
