{"version":3,"file":"types.mjs","sources":["../../../../src/lib/layouts/context-aware/types.ts"],"sourcesContent":["/**\n * @fileoverview Comprehensive type definitions for Context & DOM Aware Layout System\n *\n * This module defines all TypeScript types, interfaces, and type utilities used\n * throughout the context-aware layout system. The types are designed to be:\n * - Strictly typed with no implicit `any`\n * - Composable through discriminated unions\n * - Self-documenting with comprehensive JSDoc\n * - Performance-oriented with readonly modifiers where appropriate\n *\n * @module layouts/context-aware/types\n * @author Agent 4 - PhD Context Systems Expert\n * @version 1.0.0\n */\n\nimport type React from 'react';\nimport type { CSSProperties, RefObject, ReactNode } from 'react';\n\n// ============================================================================\n// Layout Type Definitions\n// ============================================================================\n\n/**\n * Represents the CSS display layout type of an element.\n * Used for layout ancestry tracking and constraint inheritance.\n *\n * @remarks\n * The layout type determines how child elements are positioned and\n * how constraints are inherited through the DOM tree.\n */\nexport type LayoutType =\n  | 'grid'\n  | 'flex'\n  | 'block'\n  | 'inline'\n  | 'inline-block'\n  | 'inline-flex'\n  | 'inline-grid'\n  | 'table'\n  | 'table-row'\n  | 'table-cell'\n  | 'contents'\n  | 'none';\n\n/**\n * Represents CSS position property values.\n */\nexport type PositionType = 'static' | 'relative' | 'absolute' | 'fixed' | 'sticky';\n\n/**\n * Represents CSS overflow property values.\n */\nexport type OverflowType = 'visible' | 'hidden' | 'scroll' | 'auto' | 'clip';\n\n/**\n * Flex direction for flex containers.\n */\nexport type FlexDirection = 'row' | 'row-reverse' | 'column' | 'column-reverse';\n\n/**\n * Grid auto flow direction for grid containers.\n */\nexport type GridAutoFlow = 'row' | 'column' | 'dense' | 'row dense' | 'column dense';\n\n// ============================================================================\n// Dimension and Constraint Types\n// ============================================================================\n\n/**\n * Represents a dimension value that can be a number (pixels) or CSS string.\n */\nexport type DimensionValue = number | string | 'auto' | 'inherit' | 'initial';\n\n/**\n * Immutable dimension bounds for layout constraints.\n */\nexport interface DimensionBounds {\n  readonly min: number;\n  readonly max: number;\n  readonly current: number;\n}\n\n/**\n * Comprehensive layout constraints for an element.\n *\n * @remarks\n * These constraints are inherited and transformed through the layout\n * ancestry chain, allowing child elements to understand their available space.\n */\nexport interface LayoutConstraints {\n  /** Width constraints in pixels */\n  readonly width: DimensionBounds;\n  /** Height constraints in pixels */\n  readonly height: DimensionBounds;\n  /** Whether the element can grow in the main axis */\n  readonly canGrow: boolean;\n  /** Whether the element can shrink in the main axis */\n  readonly canShrink: boolean;\n  /** Aspect ratio constraint (width / height), null if unconstrained */\n  readonly aspectRatio: number | null;\n  /** Whether the element is absolutely positioned (breaks flow) */\n  readonly isAbsolutelyPositioned: boolean;\n  /** Whether the element creates a new stacking context */\n  readonly createsStackingContext: boolean;\n}\n\n/**\n * Represents the computed bounding box of an element.\n * Extends DOMRect with additional computed properties.\n */\nexport interface ComputedBounds {\n  readonly x: number;\n  readonly y: number;\n  readonly width: number;\n  readonly height: number;\n  readonly top: number;\n  readonly right: number;\n  readonly bottom: number;\n  readonly left: number;\n  /** Content box dimensions (excluding padding and border) */\n  readonly contentBox: {\n    readonly width: number;\n    readonly height: number;\n  };\n  /** Padding box dimensions (including padding, excluding border) */\n  readonly paddingBox: {\n    readonly width: number;\n    readonly height: number;\n  };\n  /** Border box dimensions (including padding and border) */\n  readonly borderBox: {\n    readonly width: number;\n    readonly height: number;\n  };\n}\n\n// ============================================================================\n// Layout Ancestor Types\n// ============================================================================\n\n/**\n * Represents a single ancestor in the layout chain.\n *\n * @remarks\n * Layout ancestors provide context about the parent elements' layout\n * types, dimensions, and constraints. This enables child components\n * to make intelligent layout decisions.\n */\nexport interface LayoutAncestor {\n  /** Unique identifier for the ancestor element */\n  readonly id: string;\n  /** Reference to the actual DOM element */\n  readonly element: Element;\n  /** The CSS display layout type */\n  readonly layoutType: LayoutType;\n  /** The CSS position type */\n  readonly positionType: PositionType;\n  /** Computed bounding box */\n  readonly bounds: ComputedBounds;\n  /** Layout constraints for children */\n  readonly constraints: LayoutConstraints;\n  /** Depth in the layout ancestry (0 = closest parent) */\n  readonly depth: number;\n  /** Whether this ancestor is a scroll container */\n  readonly isScrollContainer: boolean;\n  /** Whether this ancestor creates a containing block for absolute positioning */\n  readonly isContainingBlock: boolean;\n  /** Flex-specific properties (only present for flex containers) */\n  readonly flexProperties?: FlexContainerProperties;\n  /** Grid-specific properties (only present for grid containers) */\n  readonly gridProperties?: GridContainerProperties;\n}\n\n/**\n * Properties specific to flex containers.\n */\nexport interface FlexContainerProperties {\n  readonly direction: FlexDirection;\n  readonly wrap: 'nowrap' | 'wrap' | 'wrap-reverse';\n  readonly justifyContent: string;\n  readonly alignItems: string;\n  readonly alignContent: string;\n  readonly gap: number;\n  readonly rowGap: number;\n  readonly columnGap: number;\n}\n\n/**\n * Properties specific to grid containers.\n */\nexport interface GridContainerProperties {\n  readonly templateColumns: string;\n  readonly templateRows: string;\n  readonly autoFlow: GridAutoFlow;\n  readonly gap: number;\n  readonly rowGap: number;\n  readonly columnGap: number;\n  readonly templateAreas: string | null;\n}\n\n// ============================================================================\n// Viewport Types\n// ============================================================================\n\n/**\n * Visibility states for elements relative to the viewport.\n */\nexport type VisibilityState =\n  | 'visible' // Fully visible in viewport\n  | 'partial' // Partially visible\n  | 'hidden' // Not visible (above/below viewport)\n  | 'obscured' // In viewport but covered by another element\n  | 'unknown'; // State cannot be determined (SSR)\n\n/**\n * Scroll direction for tracking scroll behavior.\n */\nexport type ScrollDirection = 'up' | 'down' | 'left' | 'right' | 'none';\n\n/**\n * Comprehensive viewport information.\n *\n * @remarks\n * Provides a complete picture of the viewport state including\n * dimensions, scroll position, and device characteristics.\n */\nexport interface ViewportInfo {\n  /** Viewport width in pixels */\n  readonly width: number;\n  /** Viewport height in pixels */\n  readonly height: number;\n  /** Current horizontal scroll position */\n  readonly scrollX: number;\n  /** Current vertical scroll position */\n  readonly scrollY: number;\n  /** Maximum horizontal scroll distance */\n  readonly scrollWidth: number;\n  /** Maximum vertical scroll distance */\n  readonly scrollHeight: number;\n  /** Device pixel ratio for high-DPI displays */\n  readonly devicePixelRatio: number;\n  /** Whether the device supports touch input */\n  readonly isTouch: boolean;\n  /** Current orientation ('portrait' | 'landscape') */\n  readonly orientation: 'portrait' | 'landscape';\n  /** Safe area insets for notched displays */\n  readonly safeAreaInsets: {\n    readonly top: number;\n    readonly right: number;\n    readonly bottom: number;\n    readonly left: number;\n  };\n}\n\n/**\n * Position of an element relative to the viewport.\n */\nexport interface ViewportPosition {\n  /** Element's bounds relative to viewport */\n  readonly bounds: ComputedBounds;\n  /** Visibility state in viewport */\n  readonly visibility: VisibilityState;\n  /** Intersection ratio with viewport (0-1) */\n  readonly intersectionRatio: number;\n  /** Distance from viewport edges */\n  readonly distanceFromViewport: {\n    readonly top: number;\n    readonly right: number;\n    readonly bottom: number;\n    readonly left: number;\n  };\n  /** Whether element is above, below, or within viewport */\n  readonly relativePosition: 'above' | 'within' | 'below' | 'left' | 'right';\n  /** Timestamp of last position update */\n  readonly lastUpdated: number;\n}\n\n// ============================================================================\n// Scroll Container Types\n// ============================================================================\n\n/**\n * Scroll container detection and state information.\n */\nexport interface ScrollContainer {\n  /** Reference to the scroll container element */\n  readonly element: Element;\n  /** Unique identifier */\n  readonly id: string;\n  /** Current scroll position */\n  readonly scrollPosition: {\n    readonly x: number;\n    readonly y: number;\n  };\n  /** Total scrollable dimensions */\n  readonly scrollDimensions: {\n    readonly width: number;\n    readonly height: number;\n  };\n  /** Visible dimensions (container size) */\n  readonly visibleDimensions: {\n    readonly width: number;\n    readonly height: number;\n  };\n  /** Overflow configuration */\n  readonly overflow: {\n    readonly x: OverflowType;\n    readonly y: OverflowType;\n  };\n  /** Whether currently scrolling */\n  readonly isScrolling: boolean;\n  /** Current scroll direction */\n  readonly scrollDirection: ScrollDirection;\n  /** Scroll velocity for momentum detection */\n  readonly scrollVelocity: {\n    readonly x: number;\n    readonly y: number;\n  };\n  /** Scroll progress (0-1) for each axis */\n  readonly scrollProgress: {\n    readonly x: number;\n    readonly y: number;\n  };\n  /** Whether scroll has reached edges */\n  readonly atEdge: {\n    readonly top: boolean;\n    readonly right: boolean;\n    readonly bottom: boolean;\n    readonly left: boolean;\n  };\n}\n\n/**\n * Sticky element coordination state.\n */\nexport interface StickyState {\n  /** Whether the element is currently stuck */\n  readonly isStuck: boolean;\n  /** Which edge the element is stuck to */\n  readonly stuckTo: 'top' | 'bottom' | 'left' | 'right' | null;\n  /** Original position before sticking */\n  readonly originalPosition: {\n    readonly top: number;\n    readonly left: number;\n  };\n  /** Current offset from stuck edge */\n  readonly offset: number;\n  /** Other sticky elements in the same container */\n  readonly siblingStickies: ReadonlyArray<{\n    readonly id: string;\n    readonly isStuck: boolean;\n    readonly offset: number;\n  }>;\n}\n\n// ============================================================================\n// Portal Context Types\n// ============================================================================\n\n/**\n * Portal context for maintaining state across portal boundaries.\n */\nexport interface PortalContext {\n  /** The portal root element */\n  readonly portalRoot: Element;\n  /** Original context before portal */\n  readonly sourceContext: DOMContextSnapshot;\n  /** Z-index layer for this portal */\n  readonly layer: number;\n  /** Whether to bridge events back to source */\n  readonly bridgeEvents: boolean;\n  /** Portal nesting depth */\n  readonly nestingDepth: number;\n  /** Parent portal context (if nested) */\n  readonly parentPortal: PortalContext | null;\n  /** Unique identifier for this portal instance */\n  readonly portalId: string;\n}\n\n/**\n * Snapshot of DOM context for portal bridging.\n */\nexport interface DOMContextSnapshot {\n  /** Layout ancestry at snapshot time */\n  readonly ancestors: ReadonlyArray<LayoutAncestor>;\n  /** Viewport info at snapshot time */\n  readonly viewport: ViewportInfo;\n  /** Scroll container at snapshot time */\n  readonly scrollContainer: ScrollContainer | null;\n  /** Z-index context at snapshot time */\n  readonly zIndex: ZIndexContext;\n  /** Timestamp of snapshot */\n  readonly timestamp: number;\n}\n\n// ============================================================================\n// Z-Index Management Types\n// ============================================================================\n\n/**\n * Z-index layer presets for consistent stacking.\n */\nexport type ZIndexLayer =\n  | 'base' // 0 - Normal content\n  | 'dropdown' // 1000 - Dropdowns, selects\n  | 'sticky' // 1100 - Sticky elements\n  | 'fixed' // 1200 - Fixed elements\n  | 'modalBackdrop' // 1300 - Modal backdrops\n  | 'modal' // 1400 - Modal dialogs\n  | 'popover' // 1500 - Popovers, tooltips\n  | 'toast' // 1600 - Toast notifications\n  | 'tooltip' // 1700 - Tooltips (highest priority)\n  | 'max'; // 9999 - Maximum (use sparingly)\n\n/**\n * Z-index values for each layer.\n */\nexport const Z_INDEX_LAYERS: Record<ZIndexLayer, number> = {\n  base: 0,\n  dropdown: 1000,\n  sticky: 1100,\n  fixed: 1200,\n  modalBackdrop: 1300,\n  modal: 1400,\n  popover: 1500,\n  toast: 1600,\n  tooltip: 1700,\n  max: 9999,\n} as const;\n\n/**\n * Z-index context for stacking management.\n */\nexport interface ZIndexContext {\n  /** Current z-index value */\n  readonly zIndex: number;\n  /** Layer this element belongs to */\n  readonly layer: ZIndexLayer;\n  /** Stacking context root element */\n  readonly stackingContextRoot: Element | null;\n  /** Whether this element creates a new stacking context */\n  readonly createsStackingContext: boolean;\n  /** Relative order within the same layer */\n  readonly orderInLayer: number;\n  /** Total elements in this layer */\n  readonly layerCount: number;\n}\n\n// ============================================================================\n// Complete DOM Context Type\n// ============================================================================\n\n/**\n * Complete DOM context combining all context aspects.\n *\n * @remarks\n * This is the main type that components receive from the context provider.\n * It provides comprehensive information about the element's DOM environment.\n *\n * @example\n * ```tsx\n * const context = useDOMContext();\n * if (context.ancestors[0]?.layoutType === 'flex') {\n *   // Parent is a flex container, adjust behavior\n * }\n * ```\n */\nexport interface DOMContext {\n  /** Complete layout ancestry chain */\n  readonly ancestors: ReadonlyArray<LayoutAncestor>;\n  /** Current viewport information */\n  readonly viewport: ViewportInfo;\n  /** Nearest scroll container (null if none) */\n  readonly scrollContainer: ScrollContainer | null;\n  /** Portal context (null if not in portal) */\n  readonly portal: PortalContext | null;\n  /** Z-index stacking context */\n  readonly zIndex: ZIndexContext;\n  /** Whether context is fully initialized */\n  readonly isInitialized: boolean;\n  /** Whether running in SSR mode */\n  readonly isSSR: boolean;\n  /** Unique context instance ID */\n  readonly contextId: string;\n  /** Timestamp of last context update */\n  readonly lastUpdated: number;\n}\n\n// ============================================================================\n// Component Props Types\n// ============================================================================\n\n/**\n * Base props for context-aware components.\n */\nexport interface ContextAwareComponentProps {\n  /** React children */\n  children?: ReactNode;\n  /** Optional CSS class name */\n  className?: string;\n  /** Optional inline styles */\n  style?: CSSProperties;\n  /** Optional test ID for testing */\n  'data-testid'?: string;\n}\n\n/**\n * Props for DOMContextProvider component.\n */\nexport interface DOMContextProviderProps extends ContextAwareComponentProps {\n  /** Initial viewport info for SSR */\n  initialViewport?: Partial<ViewportInfo>;\n  /** Debounce time for context updates (ms) */\n  updateDebounceMs?: number;\n  /** Whether to track scroll containers */\n  trackScrollContainers?: boolean;\n  /** Whether to track z-index contexts */\n  trackZIndex?: boolean;\n  /** Callback when context updates */\n  onContextUpdate?: (context: DOMContext) => void;\n}\n\n/**\n * Props for ContextAwareBox component.\n */\nexport interface ContextAwareBoxProps extends ContextAwareComponentProps {\n  /** HTML element to render */\n  as?: keyof React.JSX.IntrinsicElements;\n  /** Ref to the underlying element */\n  ref?: RefObject<HTMLElement>;\n  /** Whether to provide context to children */\n  provideContext?: boolean;\n  /** Callback with DOM context */\n  onContextReady?: (context: DOMContext) => void;\n  /** Layout hint for children */\n  layoutHint?: LayoutType;\n}\n\n/**\n * Props for PortalBridge component.\n */\nexport interface PortalBridgeProps extends ContextAwareComponentProps {\n  /** Target element or selector for portal */\n  target?: Element | string;\n  /** Z-index layer for portal */\n  layer?: ZIndexLayer;\n  /** Whether to bridge events to source context */\n  bridgeEvents?: boolean;\n  /** Whether to preserve scroll position on mount */\n  preserveScrollPosition?: boolean;\n  /** Callback when portal is mounted */\n  onPortalMount?: (portal: PortalContext) => void;\n  /** Callback when portal is unmounted */\n  onPortalUnmount?: () => void;\n  /**\n   * Whether to render children inline as fallback when portal cannot be created.\n   * This prevents blank pages when React environment issues occur.\n   * @default true\n   */\n  fallbackToInline?: boolean;\n  /**\n   * Custom fallback content to render when portal fails.\n   * If not provided and fallbackToInline is true, children will render inline.\n   */\n  fallback?: React.ReactNode;\n  /**\n   * Callback when portal initialization fails.\n   */\n  onPortalError?: (error: Error) => void;\n}\n\n/**\n * Props for ScrollAwareContainer component.\n */\nexport interface ScrollAwareContainerProps extends ContextAwareComponentProps {\n  /** Whether to virtualize content */\n  virtualize?: boolean;\n  /** Item height for virtualization */\n  itemHeight?: number;\n  /** Overscan count for virtualization */\n  overscan?: number;\n  /** Callback on scroll */\n  onScroll?: (scrollState: ScrollContainer) => void;\n  /** Callback when scroll reaches edge */\n  onScrollEdge?: (edge: 'top' | 'right' | 'bottom' | 'left') => void;\n  /** Whether to hide scrollbar */\n  hideScrollbar?: boolean;\n  /** Scroll behavior ('auto' | 'smooth') */\n  scrollBehavior?: 'auto' | 'smooth';\n}\n\n/**\n * Props for ViewportAnchor component.\n */\nexport interface ViewportAnchorProps extends ContextAwareComponentProps {\n  /** Anchor point on element */\n  anchor?: 'top' | 'center' | 'bottom' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';\n  /** Sticky behavior configuration */\n  sticky?: {\n    /** Whether sticky is enabled */\n    enabled: boolean;\n    /** Offset from edge when stuck */\n    offset?: number;\n    /** Which edge to stick to */\n    edge?: 'top' | 'bottom';\n    /** Z-index when stuck */\n    zIndex?: number;\n  };\n  /** Callback when visibility changes */\n  onVisibilityChange?: (visibility: VisibilityState) => void;\n  /** Callback when position changes */\n  onPositionChange?: (position: ViewportPosition) => void;\n  /** Intersection threshold for visibility callbacks */\n  intersectionThreshold?: number | number[];\n}\n\n// ============================================================================\n// Hook Return Types\n// ============================================================================\n\n/**\n * Return type for useDOMContext hook.\n */\nexport interface UseDOMContextReturn {\n  /** Current DOM context */\n  context: DOMContext;\n  /** Whether context is loading */\n  isLoading: boolean;\n  /** Ref to attach to observed element */\n  ref: RefObject<HTMLElement | null>;\n  /** Force context update */\n  refresh: () => void;\n}\n\n/**\n * Return type for useLayoutAncestry hook.\n */\nexport interface UseLayoutAncestryReturn {\n  /** Full ancestry chain */\n  ancestors: ReadonlyArray<LayoutAncestor>;\n  /** Closest ancestor of a specific type */\n  findAncestor: (type: LayoutType) => LayoutAncestor | undefined;\n  /** Check if in a specific layout type */\n  isInLayout: (type: LayoutType) => boolean;\n  /** Get constraints from nearest constraining ancestor */\n  constraints: LayoutConstraints | null;\n  /** Depth in layout tree */\n  depth: number;\n}\n\n/**\n * Return type for useViewportPosition hook.\n */\nexport interface UseViewportPositionReturn {\n  /** Current viewport position */\n  position: ViewportPosition | null;\n  /** Whether element is visible */\n  isVisible: boolean;\n  /** Whether element is fully visible */\n  isFullyVisible: boolean;\n  /** Current visibility state */\n  visibility: VisibilityState;\n  /** Ref to attach to observed element */\n  ref: RefObject<HTMLElement | null>;\n  /** Scroll element into view */\n  scrollIntoView: (options?: ScrollIntoViewOptions) => void;\n}\n\n/**\n * Return type for useScrollContext hook.\n */\nexport interface UseScrollContextReturn {\n  /** Current scroll container state */\n  scrollContainer: ScrollContainer | null;\n  /** Whether in a scroll container */\n  isInScrollContainer: boolean;\n  /** Scroll to specific position */\n  scrollTo: (options: { x?: number; y?: number; behavior?: 'auto' | 'smooth' }) => void;\n  /** Scroll by offset */\n  scrollBy: (options: { x?: number; y?: number; behavior?: 'auto' | 'smooth' }) => void;\n  /** Current scroll direction */\n  scrollDirection: ScrollDirection;\n  /** Current scroll progress (0-1) */\n  scrollProgress: { x: number; y: number };\n}\n\n/**\n * Return type for usePortalContext hook.\n */\nexport interface UsePortalContextReturn {\n  /** Current portal context */\n  portal: PortalContext | null;\n  /** Whether inside a portal */\n  isInPortal: boolean;\n  /** Source context (from before portal) */\n  sourceContext: DOMContextSnapshot | null;\n  /** Current z-index layer */\n  layer: ZIndexLayer;\n  /** Get z-index for a layer */\n  getLayerZIndex: (layer: ZIndexLayer) => number;\n}\n\n// ============================================================================\n// Event Types\n// ============================================================================\n\n/**\n * DOM context change event detail.\n */\nexport interface DOMContextChangeEvent {\n  /** Previous context state */\n  previousContext: DOMContext;\n  /** New context state */\n  newContext: DOMContext;\n  /** What triggered the change */\n  trigger: 'resize' | 'scroll' | 'mutation' | 'manual' | 'initial';\n  /** Timestamp of change */\n  timestamp: number;\n}\n\n/**\n * Scroll event detail for scroll containers.\n */\nexport interface ScrollEventDetail {\n  /** Scroll container state */\n  container: ScrollContainer;\n  /** Delta from previous position */\n  delta: { x: number; y: number };\n  /** Whether scroll is from user interaction */\n  isUserScroll: boolean;\n  /** Whether scroll is from programmatic action */\n  isProgrammaticScroll: boolean;\n}\n\n// ============================================================================\n// Configuration Types\n// ============================================================================\n\n/**\n * Configuration for context tracking behavior.\n */\nexport interface ContextTrackingConfig {\n  /** Throttle interval for resize/scroll events (ms) */\n  throttleMs: number;\n  /** Debounce interval for batch updates (ms) */\n  debounceMs: number;\n  /** Whether to use RAF for updates */\n  useRAF: boolean;\n  /** Whether to track mutations */\n  trackMutations: boolean;\n  /** Mutation observer config */\n  mutationConfig: MutationObserverInit;\n  /** Intersection observer thresholds */\n  intersectionThresholds: number[];\n  /** Whether to enable debug mode */\n  debug: boolean;\n}\n\n/**\n * Default context tracking configuration.\n */\nexport const DEFAULT_TRACKING_CONFIG: ContextTrackingConfig = {\n  throttleMs: 16, // ~60fps\n  debounceMs: 100,\n  useRAF: true,\n  trackMutations: true,\n  mutationConfig: {\n    childList: true,\n    subtree: true,\n    attributes: true,\n    attributeFilter: ['style', 'class'],\n  },\n  intersectionThresholds: [0, 0.25, 0.5, 0.75, 1],\n  debug: false,\n} as const;\n\n// ============================================================================\n// Utility Types\n// ============================================================================\n\n/**\n * Extracts the element type from a ref.\n */\nexport type RefElement<T> = T extends RefObject<infer E> ? E : never;\n\n/**\n * Makes selected properties required.\n */\nexport type RequireKeys<T, K extends keyof T> = T & Required<Pick<T, K>>;\n\n/**\n * Creates a partial type with some required keys.\n */\nexport type PartialExcept<T, K extends keyof T> = Partial<Omit<T, K>> & Pick<T, K>;\n\n/**\n * Deep readonly type.\n */\nexport type DeepReadonly<T> = {\n  readonly [P in keyof T]: T[P] extends object ? DeepReadonly<T[P]> : T[P];\n};\n\n/**\n * Type guard for checking if value is defined.\n */\nexport function isDefined<T>(value: T | null | undefined): value is T {\n  return value !== null && value !== undefined;\n}\n\n/**\n * Type guard for layout type.\n */\nexport function isLayoutType(value: string): value is LayoutType {\n  return [\n    'grid',\n    'flex',\n    'block',\n    'inline',\n    'inline-block',\n    'inline-flex',\n    'inline-grid',\n    'table',\n    'table-row',\n    'table-cell',\n    'contents',\n    'none',\n  ].includes(value);\n}\n\n/**\n * Type guard for position type.\n */\nexport function isPositionType(value: string): value is PositionType {\n  return ['static', 'relative', 'absolute', 'fixed', 'sticky'].includes(value);\n}\n\n/**\n * Type guard for scroll container.\n */\nexport function isScrollContainer(element: Element): boolean {\n  const style = getComputedStyle(element);\n  const { overflowX } = style;\n  const { overflowY } = style;\n  return (\n    overflowX === 'auto' || overflowX === 'scroll' || overflowY === 'auto' || overflowY === 'scroll'\n  );\n}\n"],"names":["Z_INDEX_LAYERS","DEFAULT_TRACKING_CONFIG","isDefined","value","isLayoutType","isPositionType","isScrollContainer","element","style","overflowX","overflowY"],"mappings":"AAiaO,MAAMA,IAA8C;AAAA,EACzD,MAAM;AAAA,EACN,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,eAAe;AAAA,EACf,OAAO;AAAA,EACP,SAAS;AAAA,EACT,OAAO;AAAA,EACP,SAAS;AAAA,EACT,KAAK;AACP,GA6UaC,IAAiD;AAAA,EAC5D,YAAY;AAAA;AAAA,EACZ,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,IACd,WAAW;AAAA,IACX,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,iBAAiB,CAAC,SAAS,OAAO;AAAA,EAAA;AAAA,EAEpC,wBAAwB,CAAC,GAAG,MAAM,KAAK,MAAM,CAAC;AAAA,EAC9C,OAAO;AACT;AA+BO,SAASC,EAAaC,GAAyC;AACpE,SAAOA,KAAU;AACnB;AAKO,SAASC,EAAaD,GAAoC;AAC/D,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,EACA,SAASA,CAAK;AAClB;AAKO,SAASE,EAAeF,GAAsC;AACnE,SAAO,CAAC,UAAU,YAAY,YAAY,SAAS,QAAQ,EAAE,SAASA,CAAK;AAC7E;AAKO,SAASG,EAAkBC,GAA2B;AAC3D,QAAMC,IAAQ,iBAAiBD,CAAO,GAChC,EAAE,WAAAE,MAAcD,GAChB,EAAE,WAAAE,MAAcF;AACtB,SACEC,MAAc,UAAUA,MAAc,YAAYC,MAAc,UAAUA,MAAc;AAE5F;"}