import{o as e,r as t}from"./jsx-runtime-BbTa8W_M-1776590214964.js";import{t as n}from"./dist-DOof8Mki-1776590214964.js";typeof window<`u`&&window.document&&window.document.createElement;function r(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}var i=e(t(),1),a=i.useInsertionEffect||n;function o({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){let[a,o,l]=s({defaultProp:t,onChange:n}),u=e!==void 0,d=u?e:a;{let t=i.useRef(e!==void 0);i.useEffect(()=>{let e=t.current;e!==u&&console.warn(`${r} is changing from ${e?`controlled`:`uncontrolled`} to ${u?`controlled`:`uncontrolled`}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),t.current=u},[u,r])}return[d,i.useCallback(t=>{if(u){let n=c(t)?t(e):t;n!==e&&l.current?.(n)}else o(t)},[u,e,o,l])]}function s({defaultProp:e,onChange:t}){let[n,r]=i.useState(e),o=i.useRef(n),s=i.useRef(t);return a(()=>{s.current=t},[t]),i.useEffect(()=>{o.current!==n&&(s.current?.(n),o.current=n)},[n,o]),[n,r,s]}function c(e){return typeof e==`function`}export{r as n,o as t};