import{j as g,a as M}from"./jsx-runtime-5BUNAZ9W.js";import{c as I}from"./cn-466VSCev.js";import{_ as u}from"./extends-dGVwEr9R.js";import{R as o,r as v}from"./index-4g5l5LRQ.js";import{$ as S}from"./index-tktZLsKA.js";import{$ as T}from"./index-VfKohXEB.js";import{$ as E,a as j,b as k}from"./index-nsyKp4dq.js";import{$ as D,t as O}from"./toggle-BfvV1tgM.js";import{$ as P}from"./index-nyvS1vus.js";import{$ as L}from"./index-8KrFLZLq.js";import"./_commonjsHelpers-4gQjN7DL.js";import"./index-zaNpaTzt.js";import"./index-dNGI4_9C.js";import"./index-pbeB-vsG.js";import"./index-h5B_Sw1x.js";import"./index-gUvWXRra.js";import"./index-gxNcLOY3.js";import"./index-TrPPXL0M.js";import"./index-polp_dyw.js";const b="ToggleGroup",[V,$e]=S(b,[E]),N=E(),U=o.forwardRef((e,a)=>{const{type:l,...t}=e;if(l==="single"){const r=t;return o.createElement(H,u({},r,{ref:a}))}if(l==="multiple"){const r=t;return o.createElement(J,u({},r,{ref:a}))}throw new Error(`Missing prop \`type\` expected on \`${b}\``)}),[R,A]=V(b),H=o.forwardRef((e,a)=>{const{value:l,defaultValue:t,onValueChange:r=()=>{},...n}=e,[c,s]=P({prop:l,defaultProp:t,onChange:r});return o.createElement(R,{scope:e.__scopeToggleGroup,type:"single",value:c?[c]:[],onItemActivate:s,onItemDeactivate:o.useCallback(()=>s(""),[s])},o.createElement(w,u({},n,{ref:a})))}),J=o.forwardRef((e,a)=>{const{value:l,defaultValue:t,onValueChange:r=()=>{},...n}=e,[c=[],s]=P({prop:l,defaultProp:t,onChange:r}),p=o.useCallback(i=>s((d=[])=>[...d,i]),[s]),G=o.useCallback(i=>s((d=[])=>d.filter(B=>B!==i)),[s]);return o.createElement(R,{scope:e.__scopeToggleGroup,type:"multiple",value:c,onItemActivate:p,onItemDeactivate:G},o.createElement(w,u({},n,{ref:a})))}),[K,Q]=V(b),w=o.forwardRef((e,a)=>{const{__scopeToggleGroup:l,disabled:t=!1,rovingFocus:r=!0,orientation:n,dir:c,loop:s=!0,...p}=e,G=N(l),i=L(c),d={role:"group",dir:i,...p};return o.createElement(K,{scope:l,rovingFocus:r,disabled:t},r?o.createElement(j,u({asChild:!0},G,{orientation:n,dir:i,loop:s}),o.createElement(T.div,u({},d,{ref:a}))):o.createElement(T.div,u({},d,{ref:a})))}),_="ToggleGroupItem",W=o.forwardRef((e,a)=>{const l=A(_,e.__scopeToggleGroup),t=Q(_,e.__scopeToggleGroup),r=N(e.__scopeToggleGroup),n=l.value.includes(e.value),c=t.disabled||e.disabled,s={...e,pressed:n,disabled:c},p=o.useRef(null);return t.rovingFocus?o.createElement(k,u({asChild:!0},r,{focusable:!c,active:n,ref:p}),o.createElement(x,u({},s,{ref:a}))):o.createElement(x,u({},s,{ref:a}))}),x=o.forwardRef((e,a)=>{const{__scopeToggleGroup:l,value:t,...r}=e,n=A(_,l),c={role:"radio","aria-checked":e.pressed,"aria-pressed":void 0},s=n.type==="single"?c:void 0;return o.createElement(D,u({},s,r,{ref:a,onPressedChange:p=>{p?n.onItemActivate(t):n.onItemDeactivate(t)}}))}),z=U,F=W,q=v.createContext({size:"default",variant:"default"}),m=v.forwardRef(({className:e,variant:a,size:l,children:t,...r},n)=>g(z,{ref:n,className:I("flex items-center justify-center gap-1",e),...r,children:g(q.Provider,{value:{variant:a,size:l},children:t})}));m.displayName=z.displayName;const f=v.forwardRef(({className:e,children:a,variant:l,size:t,...r},n)=>{const c=v.useContext(q);return g(F,{ref:n,className:I(O({variant:c.variant||l,size:c.size||t}),e),...r,children:a})});f.displayName=F.displayName;try{m.displayName="ToggleGroup",m.__docgenInfo={description:"",displayName:"ToggleGroup",props:{asChild:{defaultValue:null,description:"",name:"asChild",required:!1,type:{name:"boolean"}},variant:{defaultValue:null,description:"",name:"variant",required:!1,type:{name:"enum",value:[{value:'"default"'},{value:'"outline"'}]}},size:{defaultValue:null,description:"",name:"size",required:!1,type:{name:"enum",value:[{value:'"default"'},{value:'"sm"'},{value:'"lg"'}]}}}}}catch{}try{f.displayName="ToggleGroupItem",f.__docgenInfo={description:"",displayName:"ToggleGroupItem",props:{asChild:{defaultValue:null,description:"",name:"asChild",required:!1,type:{name:"boolean"}},variant:{defaultValue:null,description:"",name:"variant",required:!1,type:{name:"enum",value:[{value:'"default"'},{value:'"outline"'}]}},size:{defaultValue:null,description:"",name:"size",required:!1,type:{name:"enum",value:[{value:'"default"'},{value:'"sm"'},{value:'"lg"'}]}}}}}catch{}const ve={title:"ui/ToggleGroup",component:m,tags:["autodocs"],argTypes:{}},$={render:e=>M(m,{type:"single",children:[g(f,{value:"a",children:"A"}),g(f,{value:"b",children:"B"}),g(f,{value:"c",children:"C"})]}),args:{}};var y,C,h;$.parameters={...$.parameters,docs:{...(y=$.parameters)==null?void 0:y.docs,source:{originalSource:`{
  render: args => <ToggleGroup type="single">
      <ToggleGroupItem value="a">A</ToggleGroupItem>
      <ToggleGroupItem value="b">B</ToggleGroupItem>
      <ToggleGroupItem value="c">C</ToggleGroupItem>
    </ToggleGroup>,
  args: {}
}`,...(h=(C=$.parameters)==null?void 0:C.docs)==null?void 0:h.source}}};const be=["Base"];export{$ as Base,be as __namedExportsOrder,ve as default};
