import*as o from"react";import{useControllableProp as n}from"./use-controllable.js";import{useId as e}from"./use-id.js";import{callAllHandlers as r}from"../../../utils/dist/esm/function.js";function t(){return(t=Object.assign||function(o){for(var n=1;n<arguments.length;n++){var e=arguments[n];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(o[r]=e[r])}return o}).apply(this,arguments)}function i(i){void 0===i&&(i={});var{onClose:s,onOpen:l,isOpen:u,id:a}=i,[c,p]=o.useState(i.defaultIsOpen||!1),[d,f]=n(u,c),m=e(a,"disclosure"),C=o.useCallback((()=>{d||p(!1),null==s||s()}),[d,s]),O=o.useCallback((()=>{d||p(!0),null==l||l()}),[d,l]),v=o.useCallback((()=>{(f?C:O)()}),[f,O,C]);return{isOpen:!!f,onOpen:O,onClose:C,onToggle:v,isControlled:d,getButtonProps:function(o){return void 0===o&&(o={}),t({},o,{"aria-expanded":"true","aria-controls":m,onClick:r(o.onClick,v)})},getDisclosureProps:function(o){return void 0===o&&(o={}),t({},o,{hidden:!f,id:m})}}}export{i as useDisclosure};
//# sourceMappingURL=use-disclosure.js.map
