"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),c=require("@aplus-frontend/antdv"),l=require("lodash-unified");require("../../hooks/index.js");const b=require("../hooks/use-options.js"),B=require("../../hooks/useControllableValue.js"),q=e.defineComponent({name:"ApFieldSegmented",__name:"index",props:{mode:{default:"edit"},class:{},style:{},emptyText:{default:"--"},customReadMode:{},prefixCls:{},options:{},block:{type:Boolean,default:void 0},disabled:{type:Boolean,default:void 0},size:{},value:{},motionName:{},onChange:{},"onUpdate:value":{},vertical:{type:Boolean},shape:{},name:{},defaultValue:{},request:{}},emits:["update:value"],setup(r,{emit:p}){const t=r,m=e.computed(()=>l.omit(t,["onUpdate:value","value","defaultValue","options"])),{options:s,updateOptions:f}=b.default(t),v=p,{value:i,updateValue:g}=B.useControllableValue(t,v),u=e.ref(!1),y=e.useSlots();e.onMounted(()=>{l.isFunction(t.request)&&(u.value=!0,t.request().then(n=>f(n)).finally(()=>{u.value=!1}))});const k=e.computed(()=>{const n=e.unref(i);if(l.isUndefined(n))return e.createVNode(e.Fragment,null,[t.emptyText]);const o=e.unref(s)?.find(d=>d===n||d?.value===n);if(l.isString(o)||l.isNumber(o))return e.createVNode(e.Fragment,null,[o]);const a=o?.label||y.label;return l.isFunction(a)?e.createVNode(e.Fragment,null,[a?.({...o})]):e.createVNode(e.Fragment,null,[a||t.emptyText])});return(n,o)=>u.value?(e.openBlock(),e.createBlock(e.unref(c.Spin),{key:0,size:"small"})):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[r.mode==="read"?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(k.value),{key:0})):(e.openBlock(),e.createBlock(e.unref(c.Segmented),e.mergeProps({key:1},m.value,{value:e.unref(i),options:e.unref(s),"onUpdate:value":e.unref(g)}),{label:e.withCtx(a=>[e.renderSlot(n.$slots,"label",e.normalizeProps(e.guardReactiveProps(a)))]),_:3},16,["value","options","onUpdate:value"]))],64))}});exports.default=q;
