import{h as t}from"./codemirror-core-DIzFijqu.js";import{c as te,t as le}from"./index-CjmGjyN8.js";import{C as ne,D as oe,bv as V,bw as ce,n as de,q as ie,H as ue,x as n,i as $,p as re,r as d}from"./react-dom-C0IJc3nR.js";import{m as be}from"./chunk-WQVQ7P2I-De41EkH8.js";function fe(l={}){let{isReadOnly:i}=l,[u,r]=ne(l.isSelected,l.defaultSelected||!1,l.onChange);function v(C){i||r(C)}function h(){i||r(!u)}return{isSelected:u,setSelected:v,toggle:h}}function pe(l={}){var i,u;const r=te(),[v,h]=oe(l,V.variantKeys),{ref:C,as:H,name:P,value:N="",isReadOnly:y=!1,autoFocus:x=!1,startContent:M,endContent:_,defaultSelected:I,isSelected:R,children:b,thumbIcon:j,className:q,classNames:a,onChange:B,onValueChange:D,...f}=v,K=H||"label",k=t.useRef(null),m=t.useRef(null),w=(u=(i=l.disableAnimation)!=null?i:r==null?void 0:r.disableAnimation)!=null?u:!1,g=t.useId(),p=t.useMemo(()=>{const e=f["aria-label"]||typeof b=="string"?b:void 0;return{name:P,value:N,children:b,autoFocus:x,defaultSelected:I,isSelected:R,isDisabled:!!l.isDisabled,isReadOnly:y,"aria-label":e,"aria-labelledby":f["aria-labelledby"]||g,onChange:D}},[N,P,g,b,x,y,R,I,l.isDisabled,f["aria-label"],f["aria-labelledby"],D]),O=fe(p);le(()=>{if(!m.current)return;const e=!!m.current.checked;O.setSelected(e)},[m.current]);const{inputProps:o,isPressed:W,isReadOnly:F}=ce(p,O,m),{focusProps:z,isFocused:A,isFocusVisible:E}=de({autoFocus:o.autoFocus}),{hoverProps:G,isHovered:L}=ie({isDisabled:o.disabled}),T=p.isDisabled||F?!1:W,c=o.checked,S=o.disabled,s=t.useMemo(()=>V({...h,disableAnimation:w}),[ue(h),w]),J=n(a==null?void 0:a.base,q),Q=e=>({...$(G,f,e),ref:k,className:s.base({class:n(J,e==null?void 0:e.className)}),"data-disabled":d(S),"data-selected":d(c),"data-readonly":d(F),"data-focus":d(A),"data-focus-visible":d(E),"data-hover":d(L),"data-pressed":d(T)}),U=t.useCallback((e={})=>({...e,"aria-hidden":!0,className:n(s.wrapper({class:n(a==null?void 0:a.wrapper,e==null?void 0:e.className)}))}),[s,a==null?void 0:a.wrapper]),X=(e={})=>({...$(o,z,e),ref:be(m,C),id:o.id,className:s.hiddenInput({class:a==null?void 0:a.hiddenInput}),onChange:re(B,o.onChange)}),Y=t.useCallback((e={})=>({...e,className:s.thumb({class:n(a==null?void 0:a.thumb,e==null?void 0:e.className)})}),[s,a==null?void 0:a.thumb]),Z=t.useCallback((e={})=>({...e,id:g,className:s.label({class:n(a==null?void 0:a.label,e==null?void 0:e.className)})}),[s,a==null?void 0:a.label,S,c]),ee=t.useCallback((e={includeStateProps:!1})=>$({width:"1em",height:"1em",className:s.thumbIcon({class:n(a==null?void 0:a.thumbIcon)})},e.includeStateProps?{isSelected:c}:{}),[s,a==null?void 0:a.thumbIcon,c]),ae=t.useCallback((e={})=>({width:"1em",height:"1em",...e,className:s.startContent({class:n(a==null?void 0:a.startContent,e==null?void 0:e.className)})}),[s,a==null?void 0:a.startContent,c]),se=t.useCallback((e={})=>({width:"1em",height:"1em",...e,className:s.endContent({class:n(a==null?void 0:a.endContent,e==null?void 0:e.className)})}),[s,a==null?void 0:a.endContent,c]);return{Component:K,slots:s,classNames:a,domRef:k,children:b,thumbIcon:j,startContent:M,endContent:_,isHovered:L,isSelected:c,isPressed:T,isFocused:A,isFocusVisible:E,isDisabled:S,getBaseProps:Q,getWrapperProps:U,getInputProps:X,getLabelProps:Z,getThumbProps:Y,getThumbIconProps:ee,getStartContentProps:ae,getEndContentProps:se}}export{pe as u};
