import{a as z}from"./index-DruWBKkm.js";import{l as w,p as $,g as p,s as q,c as f,o as u,F as I,E as P,h as T,t as E,u as n,w as d,v as c,x as N,y as U,C as D}from"./index-CdEV5Lsj.js";const b={options:{base:"flex",variants:{size:{"2xs":"gap-1.5",xs:"gap-1.5",sm:"gap-2",md:"gap-2",lg:"gap-2.5",xl:"gap-2.5"},split:{true:"flex-wrap",false:"flex-nowrap gap-1 p-1 w-fit border rounded-dynamic border-gray-300"},disabled:{true:"pointer-events-none bg-gray-100"},block:{true:"w-full flex-nowrap"},round:{true:"rounded-full"}}},toggleButton:{base:"{UButton} font-normal focus-visible:ring-offset-0",defaults:{variant:"thirdary"}},toggleButtonInactive:{base:"{>toggleButton}",variants:{split:{false:"border-0",true:`
          border border-gray-300 hover:border-gray-400
          hover:bg-transparent dark:hover:bg-transparent
          active:bg-transparent dark:active:bg-transparent
        `}}},toggleButtonActive:{base:"{>toggleButton}",variants:{split:{false:"border-0",true:`
          border border-brand-600
        `}},defaults:{color:"brand",filled:!0}},defaults:{size:"md",split:!1,block:!1,round:!1,square:!1,disabled:!1,multiple:!1}},S="UToggle",F=w({inheritAttrs:!1,__name:"UToggle",props:$({modelValue:{type:[String,Number,Boolean,Array]},options:{},size:{},name:{},multiple:{type:Boolean},split:{type:Boolean},disabled:{type:Boolean},block:{type:Boolean},round:{type:Boolean},square:{type:Boolean},id:{},config:{},dataTest:{}},{...D(b,S),options:()=>[],modelValue:()=>[]}),emits:["update:modelValue"],setup(m,{emit:v}){const o=m,i=v,r=p({get:()=>o.modelValue,set:e=>i("update:modelValue",e)});function g(e){return Array.isArray(r.value)?r.value.includes(e.value):r.value===e.value}function y(e){const l={...e};if(delete l.onClick,typeof e.onClick=="function"&&e.onClick(l),o.multiple||o.options.length===1){const t=Array.isArray(r.value)?[...r.value]:[],a=t.indexOf(l.value);~a?t.splice(a,1):t.push(l.value),i("update:modelValue",t)}else i("update:modelValue",l.value)}const k=p(()=>({split:o.split,selected:g})),{getDataTest:B,optionsAttrs:h,toggleButtonInactiveAttrs:A,toggleButtonActiveAttrs:C}=q(b,k);return(e,l)=>(u(),f("div",N(U(n(h))),[(u(!0),f(I,null,P(e.options,(t,a)=>(u(),T(z,E({key:t.value,label:t.label,tabindex:"0",color:"gray",size:e.size,round:e.round,block:e.block,square:e.square,icon:t.icon,"left-icon":t.leftIcon,"right-icon":t.rightIcon,disabled:t.disabled||e.disabled,ref_for:!0},g(t)?n(C):n(A),{"data-test":n(B)(`option-${a}`),onClick:s=>y(t)}),{left:d(({iconName:s})=>[c(e.$slots,"left",{option:t,iconName:s,index:a})]),default:d(({label:s,iconName:V})=>[c(e.$slots,"option",{option:t,label:s,iconName:V,index:a})]),right:d(({iconName:s})=>[c(e.$slots,"right",{option:t,iconName:s,index:a})]),_:2},1040,["label","size","round","block","square","icon","left-icon","right-icon","disabled","data-test","onClick"]))),128))],16))}});export{F as _};
