{"version":3,"file":"index.cjs","sources":["../../src/vue/hooks/use-ui.ts","../../src/vue/hooks/use-ui-container.ts","../../src/vue/registries/anchor-registry.ts","../../src/vue/registries/component-registry.ts","../../src/vue/registries/renderers-registry.ts","../../src/vue/auto-menu-renderer.vue","../../src/vue/root.vue","../../src/vue/provider.vue","../../src/vue/hooks/use-item-renderer.ts","../../src/vue/hooks/use-register-anchor.ts","../../src/vue/hooks/use-schema-renderer.ts","../../src/vue/hooks/use-selection-menu.ts"],"sourcesContent":["import { ref, watch, computed, readonly, toValue, type MaybeRefOrGetter } from 'vue';\nimport { useCapability, usePlugin } from '@embedpdf/core/vue';\nimport { UIPlugin, UIDocumentState, UISchema } from '@embedpdf/plugin-ui';\n\nexport const useUIPlugin = () => usePlugin<UIPlugin>(UIPlugin.id);\nexport const useUICapability = () => useCapability<UIPlugin>(UIPlugin.id);\n\n/**\n * Hook for UI state for a specific document\n * @param documentId Document ID (can be ref, computed, getter, or plain value)\n */\nexport const useUIState = (documentId: MaybeRefOrGetter<string>) => {\n  const { provides } = useUICapability();\n  const state = ref<UIDocumentState | null>(null);\n\n  watch(\n    [provides, () => toValue(documentId)],\n    ([providesValue, docId], _, onCleanup) => {\n      if (!providesValue) {\n        state.value = null;\n        return;\n      }\n\n      const scope = providesValue.forDocument(docId);\n\n      // Set initial state\n      state.value = scope.getState();\n\n      // Subscribe to all changes\n      const unsubToolbar = scope.onToolbarChanged(() => {\n        state.value = scope.getState();\n      });\n      const unsubSidebar = scope.onSidebarChanged(() => {\n        state.value = scope.getState();\n      });\n      const unsubModal = scope.onModalChanged(() => {\n        state.value = scope.getState();\n      });\n      const unsubMenu = scope.onMenuChanged(() => {\n        state.value = scope.getState();\n      });\n      const unsubOverlay = scope.onOverlayChanged(() => {\n        state.value = scope.getState();\n      });\n\n      onCleanup(() => {\n        unsubToolbar();\n        unsubSidebar();\n        unsubModal();\n        unsubMenu();\n        unsubOverlay();\n      });\n    },\n    { immediate: true },\n  );\n\n  // Return a computed ref for the scoped capability\n  const scopedProvides = computed(() => {\n    const docId = toValue(documentId);\n    return provides.value?.forDocument(docId) ?? null;\n  });\n\n  return {\n    provides: scopedProvides,\n    state: readonly(state),\n  };\n};\n\n/**\n * Hook to get UI schema\n */\nexport const useUISchema = () => {\n  const { provides } = useUICapability();\n  const schema = computed<UISchema | null>(() => provides.value?.getSchema() ?? null);\n\n  return readonly(schema);\n};\n","import { inject, type Ref, type InjectionKey } from 'vue';\n\nexport interface UIContainerContextValue {\n  /** Reference to the UIRoot container element */\n  containerRef: Ref<HTMLDivElement | null>;\n  /** Get the container element (may be null if not mounted) */\n  getContainer: () => HTMLDivElement | null;\n}\n\nexport const UI_CONTAINER_KEY: InjectionKey<UIContainerContextValue> = Symbol('ui-container');\n\n/**\n * Hook to access the UI container element.\n *\n * This provides access to the UIRoot container for:\n * - Container query based responsiveness\n * - Portaling elements to the root\n * - Measuring container dimensions\n *\n * @example\n * ```vue\n * <script setup>\n * import { useUIContainer } from '@embedpdf/plugin-ui/vue';\n * import { onMounted, onUnmounted } from 'vue';\n *\n * const { containerRef, getContainer } = useUIContainer();\n *\n * onMounted(() => {\n *   const container = getContainer();\n *   if (!container) return;\n *\n *   const observer = new ResizeObserver(() => {\n *     console.log('Container width:', container.clientWidth);\n *   });\n *   observer.observe(container);\n *\n *   onUnmounted(() => observer.disconnect());\n * });\n * </script>\n * ```\n */\nexport function useUIContainer(): UIContainerContextValue {\n  const context = inject(UI_CONTAINER_KEY);\n  if (!context) {\n    throw new Error('useUIContainer must be used within a UIProvider');\n  }\n  return context;\n}\n","import { ref, inject, provide, type InjectionKey, type Ref } from 'vue';\n\n/**\n * Anchor Registry\n *\n * Tracks DOM elements for menu positioning.\n * Each anchor is scoped by documentId and itemId.\n */\nexport interface AnchorRegistry {\n  register(documentId: string, itemId: string, element: HTMLElement): void;\n  unregister(documentId: string, itemId: string): void;\n  getAnchor(documentId: string, itemId: string): HTMLElement | null;\n}\n\nconst AnchorRegistryKey: InjectionKey<AnchorRegistry> = Symbol('AnchorRegistry');\n\nexport function createAnchorRegistry(): AnchorRegistry {\n  const anchors: Ref<Map<string, HTMLElement>> = ref(new Map());\n\n  return {\n    register(documentId: string, itemId: string, element: HTMLElement) {\n      const key = `${documentId}:${itemId}`;\n      anchors.value.set(key, element);\n    },\n\n    unregister(documentId: string, itemId: string) {\n      const key = `${documentId}:${itemId}`;\n      anchors.value.delete(key);\n    },\n\n    getAnchor(documentId: string, itemId: string) {\n      const key = `${documentId}:${itemId}`;\n      return anchors.value.get(key) || null;\n    },\n  };\n}\n\nexport function provideAnchorRegistry() {\n  const registry = createAnchorRegistry();\n  provide(AnchorRegistryKey, registry);\n  return registry;\n}\n\nexport function useAnchorRegistry(): AnchorRegistry {\n  const registry = inject(AnchorRegistryKey);\n  if (!registry) {\n    throw new Error('useAnchorRegistry must be used within UIProvider');\n  }\n  return registry;\n}\n","import { ref, inject, provide, type Component, type InjectionKey, type Ref } from 'vue';\nimport type { BaseComponentProps } from '../types';\n\n/**\n * Component Registry\n *\n * Stores custom components that can be referenced in the UI schema.\n */\nexport interface ComponentRegistry {\n  register(id: string, component: Component<BaseComponentProps>): void;\n  unregister(id: string): void;\n  get(id: string): Component<BaseComponentProps> | undefined;\n  has(id: string): boolean;\n  getRegisteredIds(): string[];\n}\n\nconst ComponentRegistryKey: InjectionKey<ComponentRegistry> = Symbol('ComponentRegistry');\n\nexport function createComponentRegistry(\n  initialComponents: Record<string, Component<BaseComponentProps>> = {},\n): ComponentRegistry {\n  const components: Ref<Map<string, Component<BaseComponentProps>>> = ref(\n    new Map(Object.entries(initialComponents)),\n  );\n\n  return {\n    register(id: string, component: Component<BaseComponentProps>) {\n      components.value.set(id, component);\n    },\n\n    unregister(id: string) {\n      components.value.delete(id);\n    },\n\n    get(id: string) {\n      return components.value.get(id);\n    },\n\n    has(id: string) {\n      return components.value.has(id);\n    },\n\n    getRegisteredIds() {\n      return Array.from(components.value.keys());\n    },\n  };\n}\n\nexport function provideComponentRegistry(\n  initialComponents: Record<string, Component<BaseComponentProps>> = {},\n) {\n  const registry = createComponentRegistry(initialComponents);\n  provide(ComponentRegistryKey, registry);\n  return registry;\n}\n\nexport function useComponentRegistry(): ComponentRegistry {\n  const registry = inject(ComponentRegistryKey);\n  if (!registry) {\n    throw new Error('useComponentRegistry must be used within UIProvider');\n  }\n  return registry;\n}\n","import { inject, provide, type InjectionKey } from 'vue';\nimport type { UIRenderers } from '../types';\n\n/**\n * Renderers Registry\n *\n * Provides access to user-supplied renderers (toolbar, panel, menu).\n */\nconst RenderersKey: InjectionKey<UIRenderers> = Symbol('Renderers');\n\nexport function provideRenderers(renderers: UIRenderers) {\n  provide(RenderersKey, renderers);\n}\n\nexport function useRenderers(): UIRenderers {\n  const renderers = inject(RenderersKey);\n  if (!renderers) {\n    throw new Error('useRenderers must be used within UIProvider');\n  }\n  return renderers;\n}\n","<template>\n  <component\n    v-if=\"activeMenu && menuSchema && MenuRenderer\"\n    :is=\"MenuRenderer\"\n    :schema=\"menuSchema\"\n    :documentId=\"documentId\"\n    :anchorEl=\"activeMenu.anchorEl\"\n    :onClose=\"handleClose\"\n    :container=\"container\"\n  />\n</template>\n\n<script setup lang=\"ts\">\nimport { ref, computed, watch } from 'vue';\nimport { useUIState, useUICapability } from './hooks/use-ui';\nimport { useAnchorRegistry } from './registries/anchor-registry';\nimport { useRenderers } from './registries/renderers-registry';\n\n/**\n * Automatically renders menus when opened\n *\n * This component:\n * 1. Listens to UI plugin state for open menus\n * 2. Looks up anchor elements from the anchor registry\n * 3. Renders menus using the user-provided menu renderer\n */\n\ninterface Props {\n  documentId: string; // Which document's menus to render\n  container?: HTMLElement | null;\n}\n\nconst props = defineProps<Props>();\n\nconst { state: uiState } = useUIState(() => props.documentId);\nconst { provides } = useUICapability();\nconst anchorRegistry = useAnchorRegistry();\nconst renderers = useRenderers();\n\nconst activeMenu = ref<{\n  menuId: string;\n  anchorEl: HTMLElement | null;\n} | null>(null);\n\nconst openMenus = computed(() => uiState.value?.openMenus || {});\nconst schema = computed(() => provides.value?.getSchema());\n\n// Update active menu when state changes\nwatch(\n  openMenus,\n  (menus) => {\n    const openMenuIds = Object.keys(menus);\n\n    if (openMenuIds.length > 0) {\n      // Show the first open menu (in practice, should only be one)\n      const menuId = openMenuIds[0];\n      if (!menuId) {\n        activeMenu.value = null;\n        return;\n      }\n\n      const menuState = menus[menuId];\n      if (menuState && menuState.triggeredByItemId) {\n        // Look up anchor with documentId scope\n        const anchor = anchorRegistry.getAnchor(props.documentId, menuState.triggeredByItemId);\n        activeMenu.value = { menuId, anchorEl: anchor };\n      } else {\n        activeMenu.value = null;\n      }\n    } else {\n      activeMenu.value = null;\n    }\n  },\n  { immediate: true },\n);\n\nconst menuSchema = computed(() => {\n  if (!activeMenu.value || !schema.value) return null;\n\n  const menuSchemaValue = schema.value.menus[activeMenu.value.menuId];\n  if (!menuSchemaValue) {\n    console.warn(`Menu \"${activeMenu.value.menuId}\" not found in schema`);\n    return null;\n  }\n\n  return menuSchemaValue;\n});\n\nconst handleClose = () => {\n  if (activeMenu.value) {\n    provides.value?.forDocument(props.documentId).closeMenu(activeMenu.value.menuId);\n  }\n};\n\n// Use the user-provided menu renderer\nconst MenuRenderer = computed(() => renderers.menu);\n</script>\n","<template>\n  <div\n    ref=\"rootRef\"\n    v-bind=\"{ ...attrs, ...(rootAttrs as any) }\"\n    :style=\"{ containerType: 'inline-size' }\"\n  >\n    <slot />\n  </div>\n</template>\n\n<script setup lang=\"ts\">\nimport { ref, computed, onMounted, onUnmounted, watch, useAttrs, provide } from 'vue';\nimport { UI_ATTRIBUTES, UI_SELECTORS } from '@embedpdf/plugin-ui';\nimport { useUIPlugin, useUICapability } from './hooks/use-ui';\nimport { UI_CONTAINER_KEY, type UIContainerContextValue } from './hooks/use-ui-container';\n\n// Disable automatic attribute inheritance since we handle it manually\ndefineOptions({\n  inheritAttrs: false,\n});\n\nconst attrs = useAttrs();\n\nconst { plugin } = useUIPlugin();\nconst { provides } = useUICapability();\n\nconst disabledCategories = ref<string[]>([]);\nconst hiddenItems = ref<string[]>([]);\nconst rootRef = ref<HTMLDivElement | null>(null);\n\n// Provide container context for child components\nconst containerContext: UIContainerContextValue = {\n  containerRef: rootRef,\n  getContainer: () => rootRef.value,\n};\nprovide(UI_CONTAINER_KEY, containerContext);\n\nlet styleEl: HTMLStyleElement | null = null;\nlet styleTarget: HTMLElement | ShadowRoot | null = null;\n\n/**\n * Find the style injection target for an element.\n * Returns the shadow root if inside one, otherwise document.head.\n */\nfunction getStyleTarget(element: HTMLElement): HTMLElement | ShadowRoot {\n  const root = element.getRootNode();\n  if (root instanceof ShadowRoot) {\n    return root;\n  }\n  return document.head;\n}\n\n/**\n * Inject or update stylesheet\n */\nfunction injectStyles() {\n  if (!rootRef.value || !plugin.value) {\n    return;\n  }\n\n  styleTarget = getStyleTarget(rootRef.value);\n\n  // Check if styles already exist in this target\n  const existingStyle = styleTarget.querySelector(UI_SELECTORS.STYLES) as HTMLStyleElement | null;\n\n  if (existingStyle) {\n    styleEl = existingStyle;\n    // Update content in case locale changed\n    existingStyle.textContent = plugin.value.getStylesheet();\n    return;\n  }\n\n  // Create and inject stylesheet\n  const stylesheet = plugin.value.getStylesheet();\n  const newStyleEl = document.createElement('style');\n  newStyleEl.setAttribute(UI_ATTRIBUTES.STYLES, '');\n  newStyleEl.textContent = stylesheet;\n\n  if (styleTarget instanceof ShadowRoot) {\n    styleTarget.insertBefore(newStyleEl, styleTarget.firstChild);\n  } else {\n    styleTarget.appendChild(newStyleEl);\n  }\n\n  styleEl = newStyleEl;\n}\n\n/**\n * Cleanup styles\n */\nfunction cleanupStyles() {\n  if (styleEl?.parentNode) {\n    styleEl.remove();\n  }\n  styleEl = null;\n  styleTarget = null;\n}\n\n// Build root element attributes\nconst rootAttrs = computed(() => {\n  const result: Record<string, string> = {\n    [UI_ATTRIBUTES.ROOT]: '',\n  };\n\n  if (disabledCategories.value.length > 0) {\n    result[UI_ATTRIBUTES.DISABLED_CATEGORIES] = disabledCategories.value.join(' ');\n  }\n\n  if (hiddenItems.value.length > 0) {\n    result[UI_ATTRIBUTES.HIDDEN_ITEMS] = hiddenItems.value.join(' ');\n  }\n\n  return result;\n});\n\n// Stylesheet invalidation cleanup\nlet stylesheetCleanup: (() => void) | null = null;\n\n// Category change cleanup\nlet categoryCleanup: (() => void) | null = null;\n\nonMounted(() => {\n  // Inject styles on mount\n  injectStyles();\n\n  // Subscribe to stylesheet invalidation\n  if (plugin.value) {\n    stylesheetCleanup = plugin.value.onStylesheetInvalidated(() => {\n      if (styleEl && plugin.value) {\n        styleEl.textContent = plugin.value.getStylesheet();\n      }\n    });\n  }\n\n  // Subscribe to category changes\n  if (provides.value) {\n    disabledCategories.value = provides.value.getDisabledCategories();\n    hiddenItems.value = provides.value.getHiddenItems();\n\n    categoryCleanup = provides.value.onCategoryChanged((event) => {\n      disabledCategories.value = event.disabledCategories;\n      hiddenItems.value = event.hiddenItems;\n    });\n  }\n});\n\nonUnmounted(() => {\n  cleanupStyles();\n  stylesheetCleanup?.();\n  categoryCleanup?.();\n});\n\n// Re-inject styles if plugin changes\nwatch(plugin, () => {\n  if (rootRef.value && plugin.value) {\n    injectStyles();\n  }\n});\n</script>\n","<template>\n  <UIRoot v-bind=\"attrs\">\n    <slot />\n    <!-- Automatically render menus for this document -->\n    <AutoMenuRenderer :documentId=\"documentId\" :container=\"menuContainer\" />\n  </UIRoot>\n</template>\n\n<script setup lang=\"ts\">\nimport type { Component } from 'vue';\nimport { useAttrs } from 'vue';\nimport { provideAnchorRegistry } from './registries/anchor-registry';\nimport { provideComponentRegistry } from './registries/component-registry';\nimport { provideRenderers } from './registries/renderers-registry';\nimport type { BaseComponentProps, UIRenderers } from './types';\nimport AutoMenuRenderer from './auto-menu-renderer.vue';\nimport UIRoot from './root.vue';\n\n// Disable automatic attribute inheritance since we pass them to UIRoot\ndefineOptions({\n  inheritAttrs: false,\n});\n\nconst attrs = useAttrs();\n\n/**\n * UIProvider Props\n */\ninterface Props {\n  /**\n   * Document ID for this UI context\n   * Required for menu rendering\n   */\n  documentId: string;\n\n  /**\n   * Custom component registry\n   * Maps component IDs to components\n   */\n  components?: Record<string, Component<BaseComponentProps>>;\n\n  /**\n   * REQUIRED: User-provided renderers\n   * These define how toolbars, panels, and menus are displayed\n   */\n  renderers: UIRenderers;\n\n  /**\n   * Optional: Container for menu portal\n   * Defaults to document.body\n   */\n  menuContainer?: HTMLElement | null;\n}\n\nconst props = withDefaults(defineProps<Props>(), {\n  components: () => ({}),\n  menuContainer: null,\n});\n\n/**\n * UIProvider - Single provider for all UI plugin functionality\n *\n * Manages:\n * - Anchor registry for menu positioning\n * - Component registry for custom components\n * - Renderers for toolbars, panels, and menus\n * - Automatic menu rendering\n *\n * @example\n * ```vue\n * <EmbedPDF :engine=\"engine\" :plugins=\"plugins\">\n *   <template v-slot=\"{ pluginsReady, activeDocumentId }\">\n *     <UIProvider\n *       v-if=\"pluginsReady && activeDocumentId\"\n *       :documentId=\"activeDocumentId\"\n *       :components=\"{\n *         'thumbnail-panel': ThumbnailPanel,\n *         'bookmark-panel': BookmarkPanel,\n *       }\"\n *       :renderers=\"{\n *         toolbar: ToolbarRenderer,\n *         panel: PanelRenderer,\n *         menu: MenuRenderer,\n *       }\"\n *       class=\"relative flex h-full w-full\"\n *     >\n *       <ViewerLayout />\n *     </UIProvider>\n *   </template>\n * </EmbedPDF>\n * ```\n */\n\n// Provide all registries\nprovideAnchorRegistry();\nprovideComponentRegistry(props.components);\nprovideRenderers(props.renderers);\n</script>\n","import { h } from 'vue';\nimport { useComponentRegistry } from '../registries/component-registry';\n\n/**\n * Helper utilities for building renderers\n */\nexport function useItemRenderer() {\n  const componentRegistry = useComponentRegistry();\n\n  return {\n    /**\n     * Render a custom component by ID\n     *\n     * @param componentId - Component ID from schema\n     * @param documentId - Document ID\n     * @param props - Additional props to pass to component\n     * @returns Rendered component or null if not found\n     */\n    renderCustomComponent: (componentId: string, documentId: string, props?: any) => {\n      const Component = componentRegistry.get(componentId);\n\n      if (!Component) {\n        console.error(`Component \"${componentId}\" not found in registry`);\n        return null;\n      }\n\n      return h(Component, { documentId, ...(props || {}) });\n    },\n  };\n}\n","import { onBeforeUnmount, ref, watch, toValue, type MaybeRefOrGetter } from 'vue';\nimport { useAnchorRegistry } from '../registries/anchor-registry';\n\n/**\n * Register a DOM element as an anchor for menus\n *\n * @param documentId - Document ID (can be ref, computed, getter, or plain value)\n * @param itemId - Item ID (can be ref, computed, getter, or plain value)\n * @returns Ref callback to attach to the element (use with :ref=\"anchorRef\")\n *\n * @example\n * ```vue\n * <script setup lang=\"ts\">\n * const anchorRef = useRegisterAnchor(() => props.documentId, () => props.itemId);\n * </script>\n *\n * <template>\n *   <button :ref=\"anchorRef\">Zoom</button>\n * </template>\n * ```\n */\nexport function useRegisterAnchor(\n  documentId: MaybeRefOrGetter<string>,\n  itemId: MaybeRefOrGetter<string>,\n) {\n  const registry = useAnchorRegistry();\n  const elementRef = ref<HTMLElement | null>(null);\n\n  // Re-register when documentId or itemId change\n  watch(\n    [() => toValue(documentId), () => toValue(itemId)],\n    ([newDocId, newItemId], [oldDocId, oldItemId]) => {\n      // Unregister under old key if values changed\n      if (oldDocId && oldItemId && (oldDocId !== newDocId || oldItemId !== newItemId)) {\n        registry.unregister(oldDocId, oldItemId);\n      }\n\n      // Register under new key if element exists\n      if (elementRef.value && newDocId && newItemId) {\n        registry.register(newDocId, newItemId, elementRef.value);\n      }\n    },\n  );\n\n  // Function to set ref\n  const setRef = (el: any) => {\n    // Handle Vue 3 ref binding (component refs have $el)\n    const element = el?.$el || el;\n\n    const docId = toValue(documentId);\n    const item = toValue(itemId);\n\n    // Unregister previous element if exists\n    if (elementRef.value && elementRef.value !== element) {\n      registry.unregister(docId, item);\n    }\n\n    elementRef.value = element;\n\n    // Register new element\n    if (element) {\n      registry.register(docId, item, element);\n    }\n  };\n\n  // Cleanup on unmount\n  onBeforeUnmount(() => {\n    if (elementRef.value) {\n      registry.unregister(toValue(documentId), toValue(itemId));\n    }\n  });\n\n  return setRef;\n}\n","import { h, toValue, type VNode, type MaybeRefOrGetter } from 'vue';\nimport { useUICapability, useUIState } from './use-ui';\nimport { useRenderers } from '../registries/renderers-registry';\n\n/**\n * High-level composable for rendering UI from schema\n *\n * Provides simple functions to render toolbars, sidebars, and modals.\n * Always passes isOpen state to renderers so they can control animations.\n *\n * Automatically subscribes to UI state changes for the given document.\n * @param documentId Document ID (can be ref, computed, getter, or plain value)\n */\nexport function useSchemaRenderer(documentId: MaybeRefOrGetter<string>) {\n  const renderers = useRenderers();\n  const { provides } = useUICapability();\n  const { state: uiState } = useUIState(documentId);\n\n  return {\n    /**\n     * Render a toolbar by placement and slot\n     *\n     * Always renders with isOpen state when toolbar exists in slot.\n     *\n     * @param placement - 'top' | 'bottom' | 'left' | 'right'\n     * @param slot - Slot name (e.g. 'main', 'secondary')\n     *\n     * @example\n     * ```vue\n     * <component :is=\"renderToolbar('top', 'main')\" />\n     * <component :is=\"renderToolbar('top', 'secondary')\" />\n     * ```\n     */\n    renderToolbar: (placement: 'top' | 'bottom' | 'left' | 'right', slot: string): VNode | null => {\n      const schema = provides.value?.getSchema();\n\n      if (!schema || !provides.value || !uiState.value) return null;\n\n      const slotKey = `${placement}-${slot}`;\n      const toolbarSlot = uiState.value.activeToolbars[slotKey];\n\n      // If no toolbar in this slot, nothing to render\n      if (!toolbarSlot) return null;\n\n      const toolbarSchema = schema.toolbars[toolbarSlot.toolbarId];\n      if (!toolbarSchema) {\n        console.warn(`Toolbar \"${toolbarSlot.toolbarId}\" not found in schema`);\n        return null;\n      }\n\n      // Check if toolbar is closable\n      const isClosable = !toolbarSchema.permanent;\n\n      const handleClose = isClosable\n        ? () => {\n            provides.value?.forDocument(toValue(documentId)).closeToolbarSlot(placement, slot);\n          }\n        : undefined;\n\n      const ToolbarRenderer = renderers.toolbar;\n\n      // ALWAYS render, pass isOpen state\n      return h(ToolbarRenderer, {\n        key: toolbarSlot.toolbarId,\n        schema: toolbarSchema,\n        documentId: toValue(documentId),\n        isOpen: toolbarSlot.isOpen,\n        onClose: handleClose,\n      });\n    },\n\n    /**\n     * Render a sidebar by placement and slot\n     *\n     * ALWAYS renders (when sidebar exists in slot) with isOpen state.\n     * Your renderer controls whether to display or animate.\n     *\n     * @param placement - 'left' | 'right' | 'top' | 'bottom'\n     * @param slot - Slot name (e.g. 'main', 'secondary', 'inspector')\n     *\n     * @example\n     * ```vue\n     * <component :is=\"renderSidebar('left', 'main')\" />\n     * <component :is=\"renderSidebar('right', 'main')\" />\n     * ```\n     */\n    renderSidebar: (placement: 'left' | 'right' | 'top' | 'bottom', slot: string): VNode | null => {\n      const schema = provides.value?.getSchema();\n\n      if (!schema || !provides.value || !uiState.value) return null;\n\n      const slotKey = `${placement}-${slot}`;\n      const sidebarSlot = uiState.value.activeSidebars[slotKey];\n\n      // If no sidebar in this slot, nothing to render\n      if (!sidebarSlot) return null;\n\n      const sidebarSchema = schema.sidebars?.[sidebarSlot.sidebarId];\n      if (!sidebarSchema) {\n        console.warn(`Sidebar \"${sidebarSlot.sidebarId}\" not found in schema`);\n        return null;\n      }\n\n      const handleClose = () => {\n        provides.value?.forDocument(toValue(documentId)).closeSidebarSlot(placement, slot);\n      };\n\n      const SidebarRenderer = renderers.sidebar;\n\n      // ALWAYS render, pass isOpen state\n      return h(SidebarRenderer, {\n        key: sidebarSlot.sidebarId,\n        schema: sidebarSchema,\n        documentId: toValue(documentId),\n        isOpen: sidebarSlot.isOpen,\n        onClose: handleClose,\n        sidebarProps: sidebarSlot.props,\n      });\n    },\n\n    /**\n     * Render the active modal (if any)\n     *\n     * Only one modal can be active at a time.\n     * Modals are defined in schema.modals.\n     *\n     * Supports animation lifecycle:\n     * - isOpen: true = visible\n     * - isOpen: false = animate out (modal still rendered)\n     * - onExited called after animation → modal removed\n     *\n     * @example\n     * ```vue\n     * <component :is=\"renderModal()\" />\n     * ```\n     */\n    renderModal: (): VNode | null => {\n      const schema = provides.value?.getSchema();\n\n      if (!schema || !provides.value || !uiState.value?.activeModal) return null;\n\n      const { modalId, isOpen } = uiState.value.activeModal;\n\n      const modalSchema = schema.modals?.[modalId];\n      if (!modalSchema) {\n        console.warn(`Modal \"${modalId}\" not found in schema`);\n        return null;\n      }\n\n      const handleClose = () => {\n        provides.value?.forDocument(toValue(documentId)).closeModal();\n      };\n\n      const handleExited = () => {\n        provides.value?.forDocument(toValue(documentId)).clearModal();\n      };\n\n      const ModalRenderer = renderers.modal;\n      if (!ModalRenderer) {\n        console.warn('No modal renderer registered');\n        return null;\n      }\n\n      return h(ModalRenderer, {\n        key: modalId,\n        schema: modalSchema,\n        documentId: toValue(documentId),\n        isOpen,\n        onClose: handleClose,\n        onExited: handleExited,\n        modalProps: uiState.value.activeModal.props,\n      });\n    },\n\n    /**\n     * Helper: Get all active toolbars for this document\n     * Useful for batch rendering or debugging\n     */\n    getActiveToolbars: () => {\n      if (!uiState.value) return [];\n      return Object.entries(uiState.value.activeToolbars).map(([slotKey, toolbarSlot]) => {\n        const [placement, slot] = slotKey.split('-');\n        return {\n          placement,\n          slot,\n          toolbarId: toolbarSlot.toolbarId,\n          isOpen: toolbarSlot.isOpen,\n        };\n      });\n    },\n\n    /**\n     * Helper: Get all active sidebars for this document\n     * Useful for batch rendering or debugging\n     */\n    getActiveSidebars: () => {\n      if (!uiState.value) return [];\n      return Object.entries(uiState.value.activeSidebars).map(([slotKey, sidebarSlot]) => {\n        const [placement, slot] = slotKey.split('-');\n        return {\n          placement,\n          slot,\n          sidebarId: sidebarSlot.sidebarId,\n          isOpen: sidebarSlot.isOpen,\n        };\n      });\n    },\n\n    /**\n     * Render all enabled overlays\n     *\n     * Overlays are floating components positioned over the document content.\n     * Unlike modals, multiple overlays can be visible and they don't block interaction.\n     * Overlay visibility is controlled by the enabledOverlays state.\n     *\n     * @example\n     * ```vue\n     * <div class=\"relative\">\n     *   <slot />\n     *   <component :is=\"renderOverlays()\" />\n     * </div>\n     * ```\n     */\n    renderOverlays: (): VNode[] | null => {\n      const schema = provides.value?.getSchema();\n\n      if (!schema?.overlays || !provides.value || !uiState.value) return null;\n\n      const OverlayRenderer = renderers.overlay;\n      if (!OverlayRenderer) {\n        return null;\n      }\n\n      const overlays = Object.values(schema.overlays);\n      if (overlays.length === 0) return null;\n\n      // Filter overlays by enabled state (default to true if not explicitly set)\n      const enabledOverlays = overlays.filter(\n        (overlay) => uiState.value!.enabledOverlays[overlay.id] !== false,\n      );\n\n      return enabledOverlays.map((overlaySchema) =>\n        h(OverlayRenderer, {\n          key: overlaySchema.id,\n          schema: overlaySchema,\n          documentId: toValue(documentId),\n        }),\n      );\n    },\n  };\n}\n","import { computed, h, toValue, type VNode, type MaybeRefOrGetter } from 'vue';\nimport type { SelectionMenuPropsBase, SelectionMenuRenderFn } from '@embedpdf/utils/vue';\nimport { useUICapability } from './use-ui';\nimport { useRenderers } from '../registries/renderers-registry';\n\n/**\n * Creates a render function for a selection menu from the schema\n *\n * @param menuId - The selection menu ID from schema\n * @param documentId - Document ID (can be ref, computed, getter, or plain value)\n * @returns A computed ref containing the render function or undefined\n *\n * @example\n * ```vue\n * <script setup lang=\"ts\">\n * const annotationMenu = useSelectionMenu('annotation', () => props.documentId);\n * </script>\n *\n * <template>\n *   <AnnotationLayer\n *     :documentId=\"documentId\"\n *     :selectionMenu=\"annotationMenu\"\n *   />\n * </template>\n * ```\n */\nexport function useSelectionMenu<TContext extends { type: string } = { type: string }>(\n  menuId: MaybeRefOrGetter<string>,\n  documentId: MaybeRefOrGetter<string>,\n) {\n  const { provides } = useUICapability();\n  const renderers = useRenderers();\n\n  const schema = computed(() => provides.value?.getSchema());\n  const menuSchema = computed(() => schema.value?.selectionMenus?.[toValue(menuId)]);\n\n  // Return a computed that produces the render function (or undefined)\n  const renderFn = computed<SelectionMenuRenderFn<TContext> | undefined>(() => {\n    // If no schema for this menu, return undefined\n    if (!menuSchema.value) {\n      return undefined;\n    }\n\n    // Capture current values for the closure\n    const currentMenuSchema = menuSchema.value;\n    const currentDocumentId = toValue(documentId);\n    const SelectionMenuRenderer = renderers.selectionMenu;\n\n    // Return the render function\n    return (props: SelectionMenuPropsBase<TContext>): VNode | null => {\n      if (!props.selected) {\n        return null;\n      }\n\n      return h(SelectionMenuRenderer, {\n        schema: currentMenuSchema,\n        documentId: currentDocumentId,\n        props,\n      });\n    };\n  });\n\n  return renderFn;\n}\n"],"names":["useUIPlugin","usePlugin","UIPlugin","id","useUICapability","useCapability","useUIState","documentId","provides","state","ref","watch","toValue","providesValue","docId","_","onCleanup","value","scope","forDocument","getState","unsubToolbar","onToolbarChanged","unsubSidebar","onSidebarChanged","unsubModal","onModalChanged","unsubMenu","onMenuChanged","unsubOverlay","onOverlayChanged","immediate","computed","_a","readonly","UI_CONTAINER_KEY","Symbol","AnchorRegistryKey","createAnchorRegistry","anchors","Map","register","itemId","element","key","set","unregister","delete","getAnchor","get","provideAnchorRegistry","registry","provide","useAnchorRegistry","inject","Error","ComponentRegistryKey","createComponentRegistry","initialComponents","components","Object","entries","component","has","getRegisteredIds","Array","from","keys","provideComponentRegistry","useComponentRegistry","RenderersKey","provideRenderers","renderers","useRenderers","props","__props","uiState","anchorRegistry","activeMenu","openMenus","schema","getSchema","menus","openMenuIds","length","menuId","menuState","triggeredByItemId","anchor","anchorEl","menuSchema","menuSchemaValue","console","warn","handleClose","closeMenu","MenuRenderer","menu","_openBlock","_createBlock","_resolveDynamicComponent","onClose","container","attrs","useAttrs","plugin","disabledCategories","hiddenItems","rootRef","containerContext","containerRef","getContainer","styleEl","styleTarget","injectStyles","root","getRootNode","ShadowRoot","document","head","getStyleTarget","existingStyle","querySelector","UI_SELECTORS","STYLES","textContent","getStylesheet","stylesheet","newStyleEl","createElement","setAttribute","UI_ATTRIBUTES","insertBefore","firstChild","appendChild","rootAttrs","result","ROOT","DISABLED_CATEGORIES","join","HIDDEN_ITEMS","stylesheetCleanup","categoryCleanup","onMounted","onStylesheetInvalidated","getDisabledCategories","getHiddenItems","onCategoryChanged","event","onUnmounted","parentNode","remove","_createElementBlock","_mergeProps","_unref","style","containerType","_renderSlot","_ctx","$slots","UIRoot","_createVNode","AutoMenuRenderer","menuContainer","componentRegistry","renderCustomComponent","componentId","Component","h","error","elementRef","newDocId","newItemId","oldDocId","oldItemId","onBeforeUnmount","el","$el","item","renderToolbar","placement","slot","slotKey","toolbarSlot","activeToolbars","toolbarSchema","toolbars","toolbarId","permanent","closeToolbarSlot","ToolbarRenderer","toolbar","isOpen","renderSidebar","sidebarSlot","activeSidebars","sidebarSchema","_b","sidebars","sidebarId","SidebarRenderer","sidebar","closeSidebarSlot","sidebarProps","renderModal","activeModal","modalId","modalSchema","_c","modals","ModalRenderer","modal","closeModal","onExited","clearModal","modalProps","getActiveToolbars","map","split","getActiveSidebars","renderOverlays","overlays","OverlayRenderer","overlay","values","filter","enabledOverlays","overlaySchema","selectionMenus","currentMenuSchema","currentDocumentId","SelectionMenuRenderer","selectionMenu","selected","context"],"mappings":"wKAIaA,EAAc,IAAMC,YAAoBC,EAAAA,SAASC,IACjDC,EAAkB,IAAMC,gBAAwBH,EAAAA,SAASC,IAMzDG,EAAcC,IACzB,MAAMC,SAAEA,GAAaJ,IACfK,EAAQC,EAAAA,IAA4B,MAE1CC,EAAAA,MACE,CAACH,EAAU,IAAMI,UAAQL,IACzB,EAAEM,EAAeC,GAAQC,EAAGC,KAC1B,IAAKH,EAEH,YADAJ,EAAMQ,MAAQ,MAIhB,MAAMC,EAAQL,EAAcM,YAAYL,GAGxCL,EAAMQ,MAAQC,EAAME,WAGpB,MAAMC,EAAeH,EAAMI,iBAAiB,KAC1Cb,EAAMQ,MAAQC,EAAME,aAEhBG,EAAeL,EAAMM,iBAAiB,KAC1Cf,EAAMQ,MAAQC,EAAME,aAEhBK,EAAaP,EAAMQ,eAAe,KACtCjB,EAAMQ,MAAQC,EAAME,aAEhBO,EAAYT,EAAMU,cAAc,KACpCnB,EAAMQ,MAAQC,EAAME,aAEhBS,EAAeX,EAAMY,iBAAiB,KAC1CrB,EAAMQ,MAAQC,EAAME,aAGtBJ,EAAU,K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