{"version":3,"names":["createContext","useContext","NavigationMenuRootContext","useNavigationMenuRootContext","optional","value","Error","NavigationMenuTreeContext","useNavigationMenuTreeContext","v","undefined"],"sources":["navigation-menu-root-context.ts"],"sourcesContent":["/**\n * Solid 2 port of Base UI React's `NavigationMenuRootContext`\n * (`packages/react/src/navigation-menu/root/NavigationMenuRootContext.ts`).\n *\n * Thread the navigation-menu root's reactive state + mutable slots to every\n * descendant part. Every reactive field is exposed as an accessor (no bare\n * values) so consumers don't need to unwrap signals.\n *\n * `createContext<T | null>(null)` + `== null` sentinel — the\n * nested `<NavigationMenu.Root>` branch checks the parent context before\n * wrapping in a second `FloatingTree`, so the context must tolerate being\n * read from above a provider.\n */\nimport {\n\ttype Accessor,\n\tcreateContext,\n\ttype Setter,\n\tuseContext,\n} from \"solid-js\";\nimport type {\n\tBaseUIChangeEventDetails,\n\tREASONS,\n} from \"../../internals/change-event-details\";\nimport type { FloatingRootStore } from \"../../internals/floating-ui/components/floating-root-store\";\nimport type { MutableRef } from \"../../internals/floating-ui/types\";\nimport type { TransitionStatus } from \"../../internals/use-transition-status/use-transition-status\";\n\n/**\n * Shared slot between triggers for canceling a stale popup auto-size reset.\n * Mutable — React uses a `useRef`; Solid uses a plain object carried on\n * context. The `owner` key is the item value that scheduled the reset, so a\n * newly-active trigger can detect whether it \"owns\" the abort controller\n * before clobbering it.\n */\nexport interface NavigationMenuPopupAutoSizeResetState {\n\tabortController: AbortController | null;\n\towner: unknown;\n}\n\n/**\n * Direction of activation — set when a new trigger takes over from the\n * previously active one. Used by the content panel to choose an enter\n * direction for its animation.\n */\nexport type NavigationMenuActivationDirection =\n\t| \"left\"\n\t| \"right\"\n\t| \"up\"\n\t| \"down\"\n\t| null;\n\n/**\n * Change-event reason union for `NavigationMenu.Root`. Ported 1:1 from\n * React's `NavigationMenuRootChangeEventReason`.\n */\nexport type NavigationMenuRootChangeEventReason =\n\t| typeof REASONS.triggerPress\n\t| typeof REASONS.triggerHover\n\t| typeof REASONS.outsidePress\n\t| typeof REASONS.listNavigation\n\t| typeof REASONS.focusOut\n\t| typeof REASONS.escapeKey\n\t| typeof REASONS.linkPress\n\t| typeof REASONS.none;\n\nexport type NavigationMenuRootChangeEventDetails =\n\tBaseUIChangeEventDetails<NavigationMenuRootChangeEventReason>;\n\nexport interface NavigationMenuRootContextValue<Value = unknown> {\n\t/** Reactive open state (true once `value` is non-nullish). */\n\topen: Accessor<boolean>;\n\t/** Currently active item value (or `null`). */\n\tvalue: Accessor<Value | null>;\n\t/** Change the active item value. Accepts cancel-able event details. */\n\tsetValue: (\n\t\tnext: Value | null,\n\t\tdetails: NavigationMenuRootChangeEventDetails,\n\t) => void;\n\t/** Enter/exit transition phase, or undefined when settled. */\n\ttransitionStatus: Accessor<TransitionStatus>;\n\t/** Whether the popup DOM subtree is currently mounted. */\n\tmounted: Accessor<boolean>;\n\n\tpopupElement: Accessor<HTMLElement | null>;\n\tsetPopupElement: Setter<HTMLElement | null>;\n\tpositionerElement: Accessor<HTMLElement | null>;\n\tsetPositionerElement: Setter<HTMLElement | null>;\n\tviewportElement: Accessor<HTMLElement | null>;\n\tsetViewportElement: Setter<HTMLElement | null>;\n\tviewportTargetElement: Accessor<HTMLElement | null>;\n\tsetViewportTargetElement: Setter<HTMLElement | null>;\n\n\tactivationDirection: Accessor<NavigationMenuActivationDirection>;\n\tsetActivationDirection: Setter<NavigationMenuActivationDirection>;\n\n\tfloatingRootContext: Accessor<FloatingRootStore | undefined>;\n\tsetFloatingRootContext: Setter<FloatingRootStore | undefined>;\n\n\tcurrentContentRef: MutableRef<HTMLDivElement | null>;\n\tnested: boolean;\n\trootRef: MutableRef<HTMLElement | null>;\n\n\tbeforeInsideRef: MutableRef<HTMLSpanElement | null>;\n\tafterInsideRef: MutableRef<HTMLSpanElement | null>;\n\tbeforeOutsideRef: MutableRef<HTMLSpanElement | null>;\n\tafterOutsideRef: MutableRef<HTMLSpanElement | null>;\n\n\tprevTriggerElementRef: MutableRef<Element | null | undefined>;\n\tpopupAutoSizeResetRef: MutableRef<NavigationMenuPopupAutoSizeResetState>;\n\n\tdelay: Accessor<number>;\n\tcloseDelay: Accessor<number>;\n\torientation: Accessor<\"horizontal\" | \"vertical\">;\n\n\tviewportInert: Accessor<boolean>;\n\tsetViewportInert: Setter<boolean>;\n}\n\nexport const NavigationMenuRootContext =\n\tcreateContext<NavigationMenuRootContextValue | null>(null);\n\nexport function useNavigationMenuRootContext(): NavigationMenuRootContextValue;\nexport function useNavigationMenuRootContext(\n\toptional: true,\n): NavigationMenuRootContextValue | null;\nexport function useNavigationMenuRootContext(\n\toptional?: boolean,\n): NavigationMenuRootContextValue | null {\n\tconst value = useContext(NavigationMenuRootContext);\n\tif (value == null && !optional) {\n\t\tthrow new Error(\n\t\t\t\"Base UI: NavigationMenuRootContext is missing. Navigation Menu parts must be placed within <NavigationMenu.Root>.\",\n\t\t);\n\t}\n\treturn value;\n}\n\n/**\n * Tree-scope context — carries the `FloatingTree` node id the current root\n * registered itself under. Nested menus read it so `isOutsideMenuEvent` can\n * consult child-node floatings.\n *\n * `null` sentinel because top-level roots may be mounted without a parent\n * `FloatingTree` (first-mount path wraps itself).\n */\nexport const NavigationMenuTreeContext = createContext<string | null>(null);\n\nexport function useNavigationMenuTreeContext(): string | undefined {\n\tconst v = useContext(NavigationMenuTreeContext);\n\treturn v ?? undefined;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAECA,aAAa,EAEbC,UAAU,QACJ,UAAU;;AASjB;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;;AAQA;AACA;AACA;AACA;;AAgEA,OAAO,MAAMC,yBAAyB,GACrCF,aAAa,CAAwC,IAAI,CAAC;AAM3D,OAAO,SAASG,4BAA4BA,CAC3CC,QAAkB,EACsB;EACxC,MAAMC,KAAK,GAAGJ,UAAU,CAACC,yBAAyB,CAAC;EACnD,IAAIG,KAAK,IAAI,IAAI,IAAI,CAACD,QAAQ,EAAE;IAC/B,MAAM,IAAIE,KAAK,CACd,mHACD,CAAC;EACF;EACA,OAAOD,KAAK;AACb;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAME,yBAAyB,GAAGP,aAAa,CAAgB,IAAI,CAAC;AAE3E,OAAO,SAASQ,4BAA4BA,CAAA,EAAuB;EAClE,MAAMC,CAAC,GAAGR,UAAU,CAACM,yBAAyB,CAAC;EAC/C,OAAOE,CAAC,IAAIC,SAAS;AACtB","ignoreList":[]}