import{a as z}from"./index-_-ijfL1Q.js";import{p as q,q as w,k as p,t as $,c as f,o as u,F as I,G as P,h as T,v as D,u as n,w as d,x as c,y as N,z as U,D as E}from"./index-DRopsKkO.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=q({inheritAttrs:!1,__name:"UToggle",props:w({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:{}},{...E(b,S),options:()=>[],modelValue:()=>[]}),emits:["update:modelValue"],setup(m,{emit:v}){const o=m,i=v,s=p({get:()=>o.modelValue,set:e=>i("update:modelValue",e)});function g(e){return Array.isArray(s.value)?s.value.includes(e.value):s.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(s.value)?[...s.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}=$(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,D({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:r=>y(t)}),{left:d(({iconName:r})=>[c(e.$slots,"left",{option:t,iconName:r,index:a})]),default:d(({label:r,iconName:V})=>[c(e.$slots,"option",{option:t,label:r,iconName:V,index:a})]),right:d(({iconName:r})=>[c(e.$slots,"right",{option:t,iconName:r,index:a})]),_:2},1040,["label","size","round","block","square","icon","left-icon","right-icon","disabled","data-test","onClick"]))),128))],16))}});export{F as _};
