'use strict'; var chunkB35DANTX_cjs = require('./chunk-B35DANTX.cjs'); var react = require('react'); function useWindowManager(options) { const [wm] = react.useState(() => chunkB35DANTX_cjs.createWindowManager(options)); react.useEffect(() => () => wm.destroy(), [wm]); return wm; } function useWmState(wm) { return react.useSyncExternalStore(wm.subscribe, wm.getState, wm.getState); } function useWmWindow(wm, id) { const getSnapshot = react.useCallback(() => wm.get(id), [wm, id]); return react.useSyncExternalStore(wm.subscribe, getSnapshot, getSnapshot); } function useDesktop(wm, options) { const optionsRef = react.useRef(options); const binder = react.useMemo(() => chunkB35DANTX_cjs.createDesktopBinder(wm, optionsRef.current), [wm]); const cleanupRef = react.useRef(null); const ref = react.useCallback( (node) => { if (node) { cleanupRef.current = binder.bindDesktop(node); } else { cleanupRef.current?.(); cleanupRef.current = null; } }, [binder] ); return { ref, binder, controller: binder.controller }; } function useWmWindowRef(binder, id, options) { const optionsRef = react.useRef(options); const cleanupRef = react.useRef(null); return react.useCallback( (node) => { if (node) { cleanupRef.current = binder.bindWindow(id, node, optionsRef.current); } else { cleanupRef.current?.(); cleanupRef.current = null; } }, [binder, id] ); } exports.useDesktop = useDesktop; exports.useWindowManager = useWindowManager; exports.useWmState = useWmState; exports.useWmWindow = useWmWindow; exports.useWmWindowRef = useWmWindowRef; //# sourceMappingURL=react.cjs.map //# sourceMappingURL=react.cjs.map