import { type StorageImplementation, type StorageOptions } from "./types.js";
/**
 * The `useStorage` hook can be used to read and write from `localStorage`
 * (default) or `sessionStorage`. The default behavior will automatically sync
 * the value across tabs using the `StorageEvent`.
 *
 * @example Simple Example
 * ```tsx
 * import { TextField } from "@react-md/core/form/TextField";
 * import { useStorage } from "@react-md/core/storage/useStorage";
 * import { type ReactElement } from "react";
 *
 * function Example(): ReactElement {
 *   const { value, setValue } = useStorage({
 *     key: "savedSearch",
 *     defaultValue: "",
 *   });
 *
 *   return (
 *     <TextField
 *       label="Search"
 *       placeholder="Search..."
 *       type="search"
 *       value={value}
 *       onChange={(event) => {
 *         setValue(event.currentTarget.value)
 *       }}
 *     />
 *   );
 * }
 * ```
 *
 * @example Type-safe Objects
 * ```tsx
 * import { useStorage } from "@react-md/core/storage/useStorage";
 * import { type ReactElement } from "react";
 *
 * interface ExpectedSchema {
 *   label: string;
 *   value: string;
 *   // others
 * }
 *
 * function Example(): ReactElement {
 *   const { value, setValue } = useStorage<ExpectedSchema | null>({
 *     key: "someKey",
 *     defaultValue: null,
 *
 *     // this is optional: you can create a custom deserializer to validate
 *     // the stored value to prevent people manually updating local storage in
 *     // the dev tools
 *     deserializer(item) {
 *       const parsed = JSON.parse(item):
 *       const { label, value } = parsed;
 *       if (typeof label !== 'string' || typeof value !== 'string') {
 *         return null;
 *       }
 *
 *       return { label, value };
 *     }
 *   });
 *
 *   // do something
 *   // value will be `ExpectedSchema | null`
 * }
 * ```
 *
 * @example Manual Persistence
 * ```tsx
 * import { Button } from "@react-md/core/button/Button";
 * import { Checkbox } from "@react-md/core/form/Checkbox";
 * import { Form } from "@react-md/core/form/Form";
 * import { useStorage } from "@react-md/core/storage/useStorage";
 * import { type ReactElement } from "react";
 *
 * function Example(): ReactElement {
 *   const { value, setValue, remove, persist } = useStorage({
 *     key: "someKey",
 *     manual: true,
 *     defaultValue: false,
 *   });
 *
 *   return (
 *     <Form
 *       onSubmit={() => {
 *         // current value will be saved into local storage
 *         persist();
 *       }}
 *       onReset={() => {
 *         // "someKey" will be removed from local storage
 *         remove();
 *       }}
 *     >
 *       <Checkbox
 *         label="Allow cookies"
 *         checked={value}
 *         onChange={(event) =>
 *           setValue(event.currentTarget.checked);
 *         }
 *       />
 *       <Button type="reset">Decline</Button>
 *       <Button type="submit">Save</Button>
 *     </Form>
 *   );
 * }
 * ```
 *
 * @see {@link https://react-md.dev/hooks/use-storage | useStorage Demos}
 * @see https://developer.mozilla.org/en-US/docs/Web/API/StorageEvent
 * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage
 * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage
 * @since 6.0.0
 */
export declare function useStorage<T>(options: StorageOptions<T>): StorageImplementation<T>;
