import{m as $}from"./slider-B0ER1pJ5.js";import{u as B}from"./useFieldsExtraOptions-BAS3Fj_1.js";import{a as D,k as y,C as L,b as n,o as E,Q as O,O as S,m as p,g as f,p as r,n as q,D as x,u as s,I as b,q as h,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"},A={class:"custom-marks"},G=["onClick"],ee=D({__name:"Small",props:{field:{},modelValue:{}},emits:["update:modelValue"],setup(M,{emit:w}){const m=M,d=w,N=y(m.modelValue),{field:l}=L(m),{formatMinMax:C}=B(l),V=n({get:()=>m.modelValue,set:a=>d("update:modelValue",a)}),o=n(()=>Number(l.value.min)),u=n(()=>Number(l.value.max)),F=n(()=>l.value.jump?1:Number(l.value.step||1)),_=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)}),j=a=>({left:`${(a-o.value)/(u.value-o.value)*100}%`}),P=a=>{const t=a.toFixed(2);return parseFloat(t).toString()},k=a=>{_.value&&c.value.includes(a)&&(i.value=a.toString(),d("update:modelValue",a))};let v,i=y("0");return E(()=>{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}))}),O(()=>{v&&v.disconnect()}),S(()=>m.modelValue,a=>{i.value=a.toString(),N.value=a}),S(N,a=>{if(_.value){const t=c.value.reduce((e,g)=>Math.abs(g-a)<Math.abs(e-a)?g: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",I,[r("div",{class:"slider-min-max-item first",onClick:t[0]||(t[0]=e=>k(o.value))},[r("span",Q,x(s(C)(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",R,x(s(C)(u.value)),1)],2)]),q(s($),{modelValue:V.value,"onUpdate:modelValue":t[2]||(t[2]=e=>V.value=e),min:o.value,max:u.value,step:F.value,disabled:s(l).disabled,"show-tooltip":"focus",class:"custom-slider",marks:!0,format:P},null,8,["modelValue","min","max","step","disabled"]),r("div",A,[s(l).scalePoints?(f(!0),p(z,{key:0},U(c.value,e=>(f(),p("div",{key:e,class:"mark",style:H(j(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:g=>k(e)},x(e),11,G)):h("",!0)],4))),128)):h("",!0)])],2))}});export{ee as default};
//# sourceMappingURL=Small-CfQJu5QV.js.map
