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