"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("vue"),h=require("../../_util/classNames.js"),S=require("../../_util/props-util/initDefaultProps.js"),s=require("../../_util/type.js"),$=require("../../config-provider/hooks/useConfigInject.js"),C=require("../style/index.js"),T=require("./MotionThumb.js");function q(e){return e.map(a=>typeof a=="object"&&a!==null?a:{label:a?.toString(),title:a?.toString(),value:a})}const y=()=>({prefixCls:String,options:s.arrayType(),block:s.booleanType(),disabled:s.booleanType(),size:s.stringType(),value:{...s.someType([String,Number]),required:!0},motionName:String,onChange:s.functionType(),"onUpdate:value":s.functionType()}),N=(e,{slots:a,emit:b})=>{const{value:o,disabled:u,payload:f,title:i,prefixCls:r,label:d=a.label,checked:m,className:c}=e,v=g=>{u||b("change",g,o)};return n.createVNode("label",{class:h.default({[`${r}-item-disabled`]:u},c)},[n.createVNode("input",{class:`${r}-item-input`,type:"radio",disabled:u,checked:m,onChange:v},null),n.createVNode("div",{class:`${r}-item-label`,title:typeof i=="string"?i:""},[typeof d=="function"?d({value:o,disabled:u,payload:f,title:i}):d??o])])};N.inheritAttrs=!1;const x=n.defineComponent({name:"ASegmented",inheritAttrs:!1,props:S.default(y(),{options:[],motionName:"thumb-motion"}),slots:Object,setup(e,{emit:a,slots:b,attrs:o}){const{prefixCls:u,direction:f,size:i}=$.default("segmented",e),[r,d]=C.default(u),m=n.shallowRef(),c=n.shallowRef(!1),v=n.computed(()=>q(e.options)),g=(t,l)=>{e.disabled||(a("update:value",l),a("change",l))};return()=>{const t=u.value;return r(n.createVNode("div",{...o,class:h.default(t,{[d.value]:!0,[`${t}-block`]:e.block,[`${t}-disabled`]:e.disabled,[`${t}-lg`]:i.value=="large",[`${t}-sm`]:i.value=="small",[`${t}-rtl`]:f.value==="rtl"},o.class),ref:m},[n.createVNode("div",{class:`${t}-group`},[n.createVNode(T.default,{containerRef:m,prefixCls:t,value:e.value,motionName:`${t}-${e.motionName}`,direction:f.value,getValueIndex:l=>v.value.findIndex(p=>p.value===l),onMotionStart:()=>{c.value=!0},onMotionEnd:()=>{c.value=!1}},null),v.value.map(l=>n.createVNode(N,{key:l.value,prefixCls:t,checked:l.value===e.value,onChange:g,...l,className:h.default(l.className,`${t}-item`,{[`${t}-item-selected`]:l.value===e.value&&!c.value}),disabled:!!e.disabled||!!l.disabled},b))])]))}}});exports.default=x;exports.segmentedProps=y;
