import { i as Subscribable, r as ServerReadable } from "../../index-B0IeflOl.mjs";
//#region src/web/media-query/index.d.ts
interface MediaQuery extends Subscribable<boolean>, ServerReadable<boolean> {}
type MinMaxPrefix = 'min-' | 'max-' | '';
type CSSUnitSuffix = 'px' | 'em' | 'rem' | 'vw' | 'vh' | 'dvw' | 'dvh' | 'svw' | 'svh' | 'lvw' | 'lvh' | 'cqw' | 'cqh' | 'vmin' | 'vmax' | 'cm' | 'mm' | 'in' | 'pt' | 'pc';
type CSSUnit = `${number}${CSSUnitSuffix}`;
type CSSResolution = `${number}${'dpi' | 'dpcm' | 'dppx' | 'x'}`;
type Ratio = `${number}${'' | ' '}/${'' | ' '}${number}`;
type Digit = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9';
type ParseNum<S extends string, Acc extends string = ''> = S extends `${infer D extends Digit | '.'}${infer Rest}` ? ParseNum<Rest, `${Acc}${D}`> : Acc extends `${infer N extends number}` ? N : false;
type MQEnum<F extends string, V extends string> = `(${F}: ${V})`;
type MQRange<F extends string, V extends string = CSSUnit> = `(${MinMaxPrefix}${F}: ${V})`;
type MQOptNum<F extends string> = `(${MinMaxPrefix}${F}${'' | `: ${number}`})`;
type RangeFeature = 'width' | 'height' | 'inline-size' | 'block-size' | 'aspect-ratio' | 'resolution' | 'color' | 'color-index' | 'monochrome';
type RangeValue<F extends string> = F extends 'aspect-ratio' ? Ratio : F extends 'resolution' ? CSSResolution : F extends 'color' | 'color-index' | 'monochrome' ? `${number}` : CSSUnit;
type RangeOp = '<' | '<=' | '>' | '>=' | '=';
type RangeLt = '<' | '<=';
/** Level 4 range syntax, e.g. `(width >= 768px)`. */
type MQRangeSyntax = { [F in RangeFeature]: `(${F} ${RangeOp} ${RangeValue<F>})` | `(${RangeValue<F>} ${RangeOp} ${F})` | `(${RangeValue<F>} ${RangeLt} ${F} ${RangeLt} ${RangeValue<F>})`; }[RangeFeature];
type MediaQueryType = `${'only ' | 'not ' | ''}${'screen' | 'print' | 'all'}` | MQEnum<'any-hover' | 'hover', 'hover' | 'none'> | MQEnum<'any-pointer' | 'pointer', 'none' | 'coarse' | 'fine'> | MQRange<'width' | 'height' | 'device-width' | 'device-height' | 'inline-size' | 'block-size'> | MQRange<'aspect-ratio' | 'device-aspect-ratio', Ratio> | MQOptNum<'color' | 'color-index' | 'monochrome'> | MQEnum<'color-gamut', 'srgb' | 'p3' | 'rec2020'> | MQEnum<'dynamic-range' | 'video-dynamic-range', 'standard' | 'high'> | MQEnum<'device-posture', 'continuous' | 'folded'> | MQEnum<'display-mode', 'browser' | 'fullscreen' | 'minimal-ui' | 'picture-in-picture' | 'standalone' | 'window-controls-overlay'> | MQEnum<'orientation', 'portrait' | 'landscape'> | MQEnum<'scan', 'interlace' | 'progressive'> | MQEnum<'grid', '0' | '1'> | MQEnum<'update', 'none' | 'slow' | 'fast'> | MQEnum<'overflow-block', 'none' | 'scroll' | 'optional-paged' | 'paged'> | MQEnum<'overflow-inline', 'none' | 'scroll'> | MQEnum<'environment-blending', 'opaque' | 'additive' | 'subtractive'> | MQRange<'resolution', 'infinite' | CSSResolution> | MQEnum<'prefers-color-scheme', 'light' | 'dark'> | MQEnum<'prefers-contrast', 'no-preference' | 'more' | 'less' | 'forced'> | MQEnum<'prefers-reduced-motion' | 'prefers-reduced-transparency' | 'prefers-reduced-data', 'no-preference' | 'reduce'> | MQEnum<'forced-colors', 'none' | 'active'> | MQEnum<'inverted-colors', 'none' | 'inverted'> | MQEnum<'prefers-online', 'online' | 'offline'> | MQEnum<'scripting', 'none' | 'initial-only' | 'enabled'> | MQRangeSyntax;
type Suggestion = MediaQueryType | `${MediaQueryType} and ` | `${MediaQueryType}, `;
type IsValid<T extends string> = string extends T ? true : T extends `${infer L}, ${infer R}` ? IsValid<L> extends true ? IsValid<R> : false : T extends `${infer L} and ${infer R}` ? IsValid<L> extends true ? IsValid<R> : false : T extends `not ${infer Rest}` ? IsValid<Rest> : T extends MediaQueryType ? true : false;
type ValuesOf<F extends string, MQ = MediaQueryType> = MQ extends `(${F}: ${infer V})` ? V : never;
type SuggestFeature<F extends string, V extends string> = ParseNum<V> extends (infer N extends number) ? `(${F}: ${N}${CSSUnitSuffix})` : [ValuesOf<F>] extends [never] ? MediaQueryType : `(${F}: ${ValuesOf<F>})`;
type Suggest<T extends string> = string extends T ? Suggestion : T extends `${infer L}, ${infer R}` ? IsValid<L> extends true ? `${L}, ${Suggest<R>}` : Suggestion : T extends `${infer L} and ${infer R}` ? IsValid<L> extends true ? `${L} and ${Suggest<R>}` : Suggestion : T extends `not ${infer Rest}` ? `not ${Suggest<Rest>}` : T extends `(${infer F}: ${infer Rest}` ? SuggestFeature<F, Rest extends `${infer V})` ? V : Rest> : MediaQueryType;
interface MediaQueryOptions<T extends string> {
  /**
   * Media query, e.g. `(min-width: 768px)`. Literals are type-checked; widen
   * to `string` to skip.
   */
  query: IsValid<T> extends true ? T : Suggest<T>;
  /**
   * SSR `get()` value.
   * @default false
   */
  defaultMatches?: boolean;
}
/**
 * Reactive media query. On the server, `get()` and the SSR snapshot are
 * `defaultMatches` (`false`).
 *
 * @example Vanilla
 * ```ts twoslash title="media-query.ts"
 * import { createMediaQuery } from 'seitu/web'
 * import { useSubscription } from 'seitu/react'
 *
 * const isDesktop = createMediaQuery({ query: '(min-width: 768px)' })
 *
 * isDesktop.subscribe(matches => {
 *   console.log(matches)
 * })
 *
 * const state = isDesktop.get()
 * console.log(state)
 * ```
 *
 * @example React
 * ```tsx twoslash title="page.tsx"
 * import { createMediaQuery } from 'seitu/web'
 * import { useSubscription } from 'seitu/react'
 *
 * const isDesktop = createMediaQuery({ query: '(min-width: 768px)' })
 *
 * function Layout() {
 *   const matches = useSubscription(isDesktop)
 *   return matches ? 'i am desktop' : 'i am mobile'
 * }
 * ```
 *
 * @example Errors
 * ```tsx twoslash
 * import { createMediaQuery } from 'seitu/web'
 * import { useSubscription } from 'seitu/react'
 *
 * // @errors: 2362 2322 1109
 * createMediaQuery({ query: '(min-width: ' })
 *
 * // @errors: 2362 2322 2820
 * createMediaQuery({ query: '(min-width: 768' })
 * ```
 */
declare function createMediaQuery<T extends string>(options: MediaQueryOptions<T>): MediaQuery;
//#endregion
export { MediaQuery, MediaQueryOptions, MediaQueryType, createMediaQuery };