{"version":3,"file":"forty-cdk-virtualization.mjs","sources":["../../../projects/forty-cdk/virtualization/src/virtualizer.ts","../../../projects/forty-cdk/virtualization/src/infinite-scroll.ts","../../../projects/forty-cdk/virtualization/src/virtual-viewport-context.ts","../../../projects/forty-cdk/virtualization/src/virtual-viewport.ts","../../../projects/forty-cdk/virtualization/src/virtual-for.ts","../../../projects/forty-cdk/virtualization/src/public-api.ts","../../../projects/forty-cdk/virtualization/src/forty-cdk-virtualization.ts"],"sourcesContent":["import { isPlatformBrowser } from '@angular/common';\nimport {\n  DestroyRef,\n  type Signal,\n  computed,\n  effect,\n  inject,\n  PLATFORM_ID,\n  signal,\n} from '@angular/core';\nimport {\n  Virtualizer,\n  elementScroll,\n  observeElementOffset,\n  observeElementRect,\n} from '@tanstack/virtual-core';\nimport type {\n  VirtualItem as CoreVirtualItem,\n  VirtualizerOptions as CoreVirtualizerOptions,\n} from '@tanstack/virtual-core';\n\nimport { afterNextRenderCancellable } from 'forty-cdk/core';\n\n/** Default number of items rendered beyond the visible window on each side. */\nconst DEFAULT_OVERSCAN = 5;\n\n/**\n * Configuration for {@link injectVirtualizer}. The consumer owns the data and\n * the DOM; the virtualizer only computes which slice of the data is visible.\n */\nexport interface VirtualizerOptions {\n  /** Reactive total number of items in the list. */\n  readonly count: Signal<number>;\n  /**\n   * Estimated size, in CSS pixels, of the item at `index` along the scroll\n   * axis (height when vertical, width when horizontal). Used until an item is\n   * measured. Should be a stable function reference.\n   */\n  readonly estimateSize: (index: number) => number;\n  /** Reactive reference to the scroll container element (e.g. a `viewChild`). */\n  readonly scrollElement: Signal<HTMLElement | null>;\n  /** Scroll axis. Defaults to `'vertical'`. */\n  readonly orientation?: 'vertical' | 'horizontal';\n  /**\n   * Number of items to render beyond the visible window on each side, to\n   * reduce blank flashes while scrolling. Defaults to `5`.\n   */\n  readonly overscan?: number;\n  /** Stable key for the item at `index`. Defaults to the index itself. */\n  readonly getItemKey?: (index: number) => string | number;\n  /**\n   * Offset, in CSS pixels, added before the first item along the scroll axis.\n   * Every item's computed offset and every `scrollToIndex` / `scrollToOffset`\n   * alignment shifts by this amount, so a sticky header rendered inside the\n   * scroller no longer overlaps the row a cross-window keyboard move lands on.\n   * Defaults to `0`. Should be a stable value.\n   */\n  readonly scrollMargin?: number;\n}\n\n/** A single item in the currently rendered window. */\nexport interface VirtualItem {\n  /** Index of the item in the full list. */\n  readonly index: number;\n  /** Stable key (from `getItemKey`, or the index). */\n  readonly key: string | number;\n  /** Offset of the item from the start of the scroll container, in pixels. */\n  readonly start: number;\n  /** Size of the item along the scroll axis, in pixels. */\n  readonly size: number;\n}\n\n/** Reactive handle returned by {@link injectVirtualizer}. */\nexport interface ForVirtualizer {\n  /** The items in the currently visible window plus overscan. */\n  readonly virtualItems: Signal<readonly VirtualItem[]>;\n  /** Total scroll size of all items, in pixels (drives the spacer element). */\n  readonly totalSize: Signal<number>;\n  /**\n   * The inclusive-exclusive `[firstIndex, lastIndex + 1)` index window currently\n   * rendered (visible window plus overscan), or `[0, 0]` when nothing is rendered.\n   * Plugs straight into a list primitive's `[visibleRange]`-style input (e.g.\n   * `[forCombobox][visibleRange]`) so windowing composes without the consumer\n   * re-deriving the range from {@link ForVirtualizer.virtualItems}.\n   */\n  readonly range: Signal<readonly [number, number]>;\n  /** Scroll the container so the item at `index` is in view. */\n  scrollToIndex(index: number, options?: { align?: 'start' | 'center' | 'end' | 'auto' }): void;\n  /** Scroll the container to an absolute pixel offset. */\n  scrollToOffset(offset: number): void;\n  /**\n   * Record the measured size of a rendered item element (dynamic sizes).\n   * Passing `null` sweeps detached (evicted) elements from the measurement\n   * cache and stops observing them, so recycled rows scrolled out of the window\n   * are not retained/observed until the directive is destroyed.\n   */\n  measureElement(element: HTMLElement | null): void;\n  /**\n   * The item at `index` as computed from the core's measurement cache — its\n   * `start` reflects measured sizes and `scrollMargin`, not pure estimate math.\n   * Returns `null` before the core has mounted or when `index` is out of range.\n   * Used to position a retained (pinned) row on its real offset rather than\n   * recomputing it from `estimateSize`.\n   */\n  measurementFor(index: number): VirtualItem | null;\n}\n\n/**\n * Sum of the estimated size of every item: `count` × the estimate when it's\n * uniform, else the per-index estimator summed. Used as the SSR / pre-mount\n * total before the core has measured any item, and shared with the ergonomic\n * viewport layer so the estimate-total math lives in one place.\n */\nexport function estimateTotal(count: number, estimateSize: (index: number) => number): number {\n  let total = 0;\n  for (let index = 0; index < count; index++) {\n    total += estimateSize(index);\n  }\n  return total;\n}\n\nfunction toVirtualItem(item: CoreVirtualItem): VirtualItem {\n  return {\n    index: item.index,\n    key: item.key as string | number,\n    start: item.start,\n    size: item.size,\n  };\n}\n\nfunction virtualItemsEqual(a: readonly VirtualItem[], b: readonly VirtualItem[]): boolean {\n  if (a === b) return true;\n  if (a.length !== b.length) return false;\n  for (let i = 0; i < a.length; i++) {\n    const x = a[i]!;\n    const y = b[i]!;\n    if (x.index !== y.index || x.key !== y.key || x.start !== y.start || x.size !== y.size) {\n      return false;\n    }\n  }\n  return true;\n}\n\n/**\n * Headless windowing core: given a reactive item count, a size estimator and a\n * scroll container, returns the slice of items currently visible (plus\n * overscan), the total scroll size, and imperative scroll/measure helpers. The\n * consumer renders the items with their own `@for` and applies the position\n * transform — this primitive owns no DOM.\n *\n * Backed by `@tanstack/virtual-core`. SSR-safe: off-browser it returns an empty\n * window and the estimate-based total without touching `document`/`window`; the\n * first real window is produced after the first browser render.\n *\n * Must be called from an injection context (a component/directive constructor\n * or field initializer).\n *\n * @param options Reactive count, size estimator, scroll element and tuning.\n * @returns A {@link ForVirtualizer} handle of signals + imperative methods.\n */\nexport function injectVirtualizer(options: VirtualizerOptions): ForVirtualizer {\n  if (!isPlatformBrowser(inject(PLATFORM_ID))) {\n    return {\n      virtualItems: signal<readonly VirtualItem[]>([]).asReadonly(),\n      totalSize: computed(() => estimateTotal(options.count(), options.estimateSize)),\n      range: computed<readonly [number, number]>(() => [0, 0]),\n      scrollToIndex: () => undefined,\n      scrollToOffset: () => undefined,\n      measureElement: () => undefined,\n      measurementFor: () => null,\n    };\n  }\n\n  const horizontal = (options.orientation ?? 'vertical') === 'horizontal';\n  const overscan = options.overscan ?? DEFAULT_OVERSCAN;\n  const scrollMargin = options.scrollMargin ?? 0;\n  const notify = signal(0, { equal: () => false });\n  const mounted = signal(false);\n\n  const buildCoreOptions = (\n    count: number,\n    scrollElement: HTMLElement | null,\n  ): CoreVirtualizerOptions<HTMLElement, HTMLElement> => ({\n    count,\n    getScrollElement: () => scrollElement,\n    estimateSize: options.estimateSize,\n    getItemKey: options.getItemKey,\n    overscan,\n    horizontal,\n    scrollMargin,\n    scrollToFn: elementScroll,\n    observeElementRect,\n    observeElementOffset,\n    onChange: () => notify.set(0),\n  });\n\n  const virtualizer = new Virtualizer<HTMLElement, HTMLElement>(\n    buildCoreOptions(options.count(), options.scrollElement()),\n  );\n\n  // @sanctioned-effect(external-source): `notify` is a change-notification\n  // bridge from the imperative `@tanstack/virtual-core` core into the signal\n  // graph. When `count` / `scrollElement` change the core is reconfigured\n  // imperatively (`setOptions` + `_willUpdate`), so `notify.set(0)` forces the\n  // `virtualItems` / `totalSize` computeds to re-read it. The effect never reads\n  // `notify`, so there is no self-cycle.\n  effect(() => {\n    virtualizer.setOptions(buildCoreOptions(options.count(), options.scrollElement()));\n    virtualizer._willUpdate();\n    notify.set(0);\n  });\n\n  let cleanup: (() => void) | undefined;\n  afterNextRenderCancellable(() => {\n    cleanup = virtualizer._didMount();\n    mounted.set(true);\n  });\n  inject(DestroyRef).onDestroy(() => cleanup?.());\n\n  const virtualItems = computed<readonly VirtualItem[]>(\n    () => {\n      notify();\n      if (!mounted()) return [];\n      return virtualizer.getVirtualItems().map(toVirtualItem);\n    },\n    { equal: virtualItemsEqual },\n  );\n\n  const totalSize = computed<number>(() => {\n    notify();\n    if (!mounted()) return estimateTotal(options.count(), options.estimateSize);\n    return virtualizer.getTotalSize();\n  });\n\n  const range = computed<readonly [number, number]>(() => {\n    const items = virtualItems();\n    if (items.length === 0) return [0, 0];\n    return [items[0]!.index, items[items.length - 1]!.index + 1];\n  });\n\n  return {\n    virtualItems,\n    totalSize,\n    range,\n    scrollToIndex: (index, scrollOptions) => virtualizer.scrollToIndex(index, scrollOptions),\n    scrollToOffset: (offset) => virtualizer.scrollToOffset(offset),\n    measureElement: (element) => virtualizer.measureElement(element),\n    measurementFor: (index) => {\n      if (!mounted() || index < 0 || index >= options.count()) {\n        return null;\n      }\n      const measurement = virtualizer.measurementsCache[index];\n      return measurement === undefined ? null : toVirtualItem(measurement);\n    },\n  };\n}\n","import { type Signal, computed, effect, linkedSignal, signal, untracked } from '@angular/core';\n\nconst DEFAULT_THRESHOLD = 5;\n\n/**\n * Configuration for {@link injectInfiniteScroll}. The consumer owns the data and\n * the fetch; this core only decides *when* to ask for more.\n */\nexport interface InfiniteScrollOptions {\n  /**\n   * The rendered window, `[firstIndex, lastIndex + 1)` — e.g.\n   * `injectVirtualizer(...).range`. An empty `[0, 0]` window never fires.\n   */\n  readonly range: Signal<readonly [number, number]>;\n  /** Reactive total number of currently-loaded items. */\n  readonly count: Signal<number>;\n  /**\n   * Fire when the window's last index comes within this many items of `count`.\n   * Defaults to `5` (mirrors the windowing core's default overscan).\n   */\n  readonly threshold?: number;\n  /** When this resolves to `true` the detector never fires. */\n  readonly disabled?: Signal<boolean>;\n  /**\n   * Called once per threshold crossing. If it returns a promise, the next fire\n   * is suppressed until that promise settles (`pending` reflects the in-flight\n   * state); the detector re-arms when `count` grows.\n   */\n  readonly onLoadMore: () => void | Promise<unknown>;\n}\n\n/** Reactive handle returned by {@link injectInfiniteScroll}. */\nexport interface ForInfiniteScroll {\n  /** True while an `onLoadMore` promise is in flight. */\n  readonly pending: Signal<boolean>;\n}\n\n/**\n * Headless infinite-scroll detector: composes on top of any windowed list's\n * `range` + `count` signals and fires `onLoadMore` once per threshold crossing,\n * suppressing re-fire while a returned promise is pending and re-arming when\n * `count` grows (a page was appended). It owns no DOM, adds no scroll listener —\n * the trigger rides the existing reactive recompute — and is SSR-safe by\n * construction: off-browser the window is `[0, 0]`, so it never fires.\n *\n * Must be called from an injection context (a component/directive constructor\n * or field initializer).\n *\n * @param options Reactive `range` + `count`, an optional `threshold`/`disabled`,\n *   and the `onLoadMore` callback.\n * @returns A {@link ForInfiniteScroll} handle exposing the `pending` signal.\n */\nexport function injectInfiniteScroll(options: InfiniteScrollOptions): ForInfiniteScroll {\n  const threshold = options.threshold ?? DEFAULT_THRESHOLD;\n  const pending = signal(false);\n\n  const nearEnd = computed(() => {\n    if (options.disabled?.()) return false;\n    const [start, end] = options.range();\n    if (end <= start) return false;\n    const total = options.count();\n    return total > 0 && end >= total - threshold;\n  });\n\n  const armed = linkedSignal<number, boolean>({\n    source: () => options.count(),\n    computation: () => true,\n  });\n\n  // @sanctioned-effect(untracked-read): both `armed` and `pending` are read\n  // through `untracked`, so the effect tracks only `count` / `nearEnd` and never\n  // cycles on the latches it writes; the `pending` writes bridge a caller-owned\n  // promise, which is outside the reactive graph entirely.\n  effect(() => {\n    options.count();\n    if (!nearEnd() || !untracked(armed)) return;\n    if (untracked(pending)) return;\n    armed.set(false);\n    const result = options.onLoadMore();\n    if (result instanceof Promise) {\n      pending.set(true);\n      void result.finally(() => pending.set(false));\n    }\n  });\n\n  return { pending: pending.asReadonly() };\n}\n","import { InjectionToken, inject, type Signal } from '@angular/core';\n\nimport { orphanContextError } from 'forty-cdk/core';\n\nimport { type VirtualItem } from './virtualizer';\n\n/**\n * Coordination surface a {@link ForVirtualViewport} exposes to the\n * `*forVirtualFor` structural directive nested inside it.\n */\nexport interface ForVirtualViewportContext {\n  /** The items in the currently visible window plus overscan. */\n  readonly virtualItems: Signal<readonly VirtualItem[]>;\n  /** The total number of items in the full (non-windowed) list. */\n  readonly count: Signal<number>;\n  /** Scroll axis, resolved once when the viewport initializes. */\n  readonly orientation: Signal<'vertical' | 'horizontal'>;\n}\n\n/** DI token carrying the {@link ForVirtualViewportContext}. */\nexport const FOR_VIRTUAL_VIEWPORT_CONTEXT = new InjectionToken<ForVirtualViewportContext>(\n  'FOR_VIRTUAL_VIEWPORT_CONTEXT',\n);\n\n/**\n * Resolve the enclosing viewport context, throwing a primitive-prefixed error\n * when the piece is used outside a `[forVirtualViewport]`. Internal — never\n * re-exported from the primitive barrel.\n */\nexport function injectVirtualViewportContext(consumer: string): ForVirtualViewportContext {\n  const context = inject(FOR_VIRTUAL_VIEWPORT_CONTEXT, { optional: true });\n  if (!context) {\n    throw orphanContextError({\n      code: 'FORCDK-VIRTUALIZATION-001',\n      piece: consumer,\n      root: '[forVirtualViewport]',\n      token: 'FOR_VIRTUAL_VIEWPORT_CONTEXT',\n    });\n  }\n  return context;\n}\n","import {\n  ChangeDetectionStrategy,\n  Component,\n  ElementRef,\n  Injector,\n  type OnInit,\n  type Signal,\n  afterEveryRender,\n  computed,\n  inject,\n  input,\n  output,\n  runInInjectionContext,\n  signal,\n} from '@angular/core';\n\nimport {\n  FOR_VIRTUAL_VIEWPORT_CONTEXT,\n  type ForVirtualViewportContext,\n} from './virtual-viewport-context';\nimport { injectInfiniteScroll } from './infinite-scroll';\nimport {\n  type ForVirtualizer,\n  type VirtualItem,\n  estimateTotal,\n  injectVirtualizer,\n} from './virtualizer';\n\n/** Default estimated item size, in CSS pixels, when none is provided. */\nconst DEFAULT_ESTIMATE_SIZE = 50;\n\n/** Default number of items rendered beyond the visible window on each side. */\nconst DEFAULT_OVERSCAN = 5;\n\n/**\n * Scroll viewport for the ergonomic virtualization layer. Decorate a fixed-size\n * scroll container with `[forVirtualViewport]`, give it `[virtualCount]` and an\n * `[estimateSize]`, and nest a single `*forVirtualFor` inside it — the viewport\n * owns the scroll container, the total-size sizer, and the windowing core, so\n * the consumer writes no manual spacer or position transform.\n *\n * Built on the headless {@link injectVirtualizer} core; for full manual control\n * (custom DOM, dynamic measurement, window/document scroller) use that directly.\n *\n * The viewport forces `overflow: auto` on its host and renders a relatively\n * positioned sizer whose main-axis size tracks `totalSize()`; `*forVirtualFor`\n * projects its rows into that sizer and positions each one absolutely.\n *\n * `orientation` and `overscan` are read once when the viewport initializes;\n * change them before first render, not at runtime.\n */\n@Component({\n  selector: 'for-virtual-viewport, [forVirtualViewport]',\n  exportAs: 'forVirtualViewport',\n  changeDetection: ChangeDetectionStrategy.OnPush,\n  providers: [{ provide: FOR_VIRTUAL_VIEWPORT_CONTEXT, useExisting: ForVirtualViewport }],\n  host: {\n    '[style.overflow]': '\"auto\"',\n  },\n  template: `\n    <div style=\"position: relative\" [style.width]=\"sizerWidth()\" [style.height]=\"sizerHeight()\">\n      <ng-content />\n    </div>\n  `,\n})\nexport class ForVirtualViewport implements ForVirtualViewportContext, OnInit {\n  readonly #host = inject<ElementRef<HTMLElement>>(ElementRef);\n  readonly #injector = inject(Injector);\n  readonly #scrollElement = signal<HTMLElement | null>(this.#host.nativeElement);\n  readonly #virtualizer = signal<ForVirtualizer | null>(null);\n\n  /** Total number of items in the full list. */\n  readonly virtualCount = input.required<number>();\n\n  /** Estimated item size in px along the scroll axis: a number or a per-index estimator. */\n  readonly estimateSize = input<number | ((index: number) => number)>(DEFAULT_ESTIMATE_SIZE);\n\n  /** Scroll axis. Resolved once on init; runtime changes are not tracked by the core. */\n  readonly orientation = input<'vertical' | 'horizontal'>('vertical');\n\n  /** Items rendered beyond the visible window on each side. Resolved once on init. */\n  readonly overscan = input<number>(DEFAULT_OVERSCAN);\n\n  /** Stable key for the item at `index`. Defaults to the index. */\n  readonly getItemKey = input<((index: number) => string | number) | undefined>(undefined);\n\n  /**\n   * Emits when the rendered window comes within ~`overscan` items of the end of\n   * the list, signalling the consumer to load the next page. Built on\n   * {@link injectInfiniteScroll}; fires once per threshold crossing and re-arms\n   * when the bound count grows. The consumer owns the fetch (e.g. via `resource()`).\n   */\n  readonly endReached = output<void>();\n\n  /**\n   * The total number of items in the full (non-windowed) list — the\n   * {@link ForVirtualViewportContext.count} the nested `*forVirtualFor` reads.\n   * Aliases the `virtualCount` input signal directly (no wrapper node).\n   */\n  readonly count = this.virtualCount;\n\n  readonly #estimator = computed<(index: number) => number>(() => {\n    const estimate = this.estimateSize();\n    return typeof estimate === 'function' ? estimate : () => estimate;\n  });\n\n  readonly #estimateTotal = computed(() => estimateTotal(this.count(), this.#estimator()));\n\n  readonly #reorderingIndex = signal<number | null>(null);\n\n  /**\n   * The items in the currently visible window plus overscan, augmented to always\n   * include the row pinned via {@link setReorderingIndex} even when it is scrolled\n   * out of view, so a drag-reorder's lifted row is never recycled out from under\n   * the gesture. Pinning never widens {@link range} (sourced from the underlying\n   * virtualizer), so it leaves infinite-scroll untouched.\n   */\n  readonly virtualItems: Signal<readonly VirtualItem[]> = computed(() => {\n    const items = this.#virtualizer()?.virtualItems() ?? [];\n    const retain = this.#reorderingIndex();\n    if (retain === null || retain < 0 || retain >= this.count()) {\n      return items;\n    }\n    if (items.some((item) => item.index === retain)) {\n      return items;\n    }\n    return [...items, this.#retainedItem(retain)].sort((a, b) => a.index - b.index);\n  });\n\n  /** Total scroll size of all items, in pixels (drives the sizer). */\n  readonly totalSize = computed(() => this.#virtualizer()?.totalSize() ?? this.#estimateTotal());\n\n  readonly #range = computed<readonly [number, number]>(\n    () => this.#virtualizer()?.range() ?? [0, 0],\n  );\n\n  protected readonly sizerWidth = computed(() =>\n    this.orientation() === 'horizontal' ? `${this.totalSize()}px` : '100%',\n  );\n\n  protected readonly sizerHeight = computed(() =>\n    this.orientation() === 'horizontal' ? '100%' : `${this.totalSize()}px`,\n  );\n\n  constructor() {\n    afterEveryRender(() => this.#virtualizer()?.measureElement(null));\n  }\n\n  ngOnInit(): void {\n    runInInjectionContext(this.#injector, () => {\n      this.#virtualizer.set(\n        injectVirtualizer({\n          count: this.count,\n          estimateSize: (index) => this.#estimator()(index),\n          scrollElement: this.#scrollElement,\n          orientation: this.orientation(),\n          overscan: this.overscan(),\n          getItemKey: this.getItemKey(),\n        }),\n      );\n      injectInfiniteScroll({\n        range: this.#range,\n        count: this.count,\n        onLoadMore: () => this.endReached.emit(),\n      });\n    });\n  }\n\n  /**\n   * Pin the row at the absolute `index` into the rendered window so it stays\n   * mounted even when the window scrolls past it — used by `[forVirtualReorder]`\n   * to keep a drag-reorder's lifted row alive across auto-scroll and dataset-wide\n   * keyboard stepping. Pass `null` to release. No-op when the index is out of\n   * range; rarely needed directly.\n   */\n  setReorderingIndex(index: number | null): void {\n    this.#reorderingIndex.set(index);\n  }\n\n  /** Scroll the container so the item at `index` is in view. No-op until initialized. */\n  scrollToIndex(index: number, options?: { align?: 'start' | 'center' | 'end' | 'auto' }): void {\n    this.#virtualizer()?.scrollToIndex(index, options);\n  }\n\n  /** Scroll the container to an absolute pixel offset. No-op until initialized. */\n  scrollToOffset(offset: number): void {\n    this.#virtualizer()?.scrollToOffset(offset);\n  }\n\n  /**\n   * Record the measured size of a rendered item element. Passing `null` sweeps\n   * detached (recycled) rows from the measurement cache and stops observing\n   * them — the viewport already performs this sweep after every render, so a\n   * monotonically scrolling list never retains one detached element per row\n   * scrolled past. No-op until initialized.\n   */\n  measureElement(element: HTMLElement | null): void {\n    this.#virtualizer()?.measureElement(element);\n  }\n\n  #retainedItem(index: number): VirtualItem {\n    const measured = this.#virtualizer()?.measurementFor(index) ?? null;\n    if (measured !== null) {\n      return measured;\n    }\n    const estimator = this.#estimator();\n    let start = 0;\n    for (let i = 0; i < index; i++) {\n      start += estimator(i);\n    }\n    const key = this.getItemKey()?.(index) ?? index;\n    return { index, key, start, size: estimator(index) };\n  }\n}\n","import {\n  Directive,\n  type EmbeddedViewRef,\n  TemplateRef,\n  ViewContainerRef,\n  effect,\n  inject,\n  input,\n} from '@angular/core';\n\nimport { injectVirtualViewportContext } from './virtual-viewport-context';\nimport { type VirtualItem } from './virtualizer';\n\n/** Template context exposed to each row rendered by `*forVirtualFor`. */\nexport interface ForVirtualForContext<T> {\n  /** The row data at this index (`let row`). */\n  $implicit: T;\n  /** The virtual item metadata: index, key, start offset, size (`let item = virtualItem`). */\n  virtualItem: VirtualItem;\n  /** The item's index in the full list (`let i = index`). */\n  index: number;\n  /** The total number of items in the full list (`let n = count`). */\n  count: number;\n}\n\n/**\n * Structural directive that renders only the visible window of a list inside a\n * `[forVirtualViewport]`. Pass the full data array; the directive iterates the\n * viewport's `virtualItems()`, exposes each row plus its `virtualItem` to the\n * template, positions it absolutely (so the consumer writes no transform), and\n * binds `aria-setsize` (true total) / `aria-posinset` (`index + 1`) so screen\n * readers announce the real list size.\n *\n * ```html\n * <div forVirtualViewport [virtualCount]=\"rows().length\" [estimateSize]=\"44\">\n *   <div *forVirtualFor=\"let row of rows(); let item = virtualItem\">{{ row.label }}</div>\n * </div>\n * ```\n *\n * A row that stays in the window across a re-render **keeps its DOM node in place**: views\n * that left the window are removed before the surviving ones are re-indexed, so a view whose\n * position in the window changed never has to be detached and re-inserted to get there. That\n * is what makes focus survive a window jump — `ViewContainerRef.move` removes the node from\n * the document before re-inserting it, which blurs whatever inside it was focused, and the\n * row pinned by `[forVirtualReorder]` is focused for the whole gesture.\n */\n@Directive({\n  selector: '[forVirtualFor][forVirtualForOf]',\n})\nexport class ForVirtualFor<T> {\n  readonly #template = inject<TemplateRef<ForVirtualForContext<T>>>(TemplateRef);\n  readonly #viewContainer = inject(ViewContainerRef);\n  readonly #viewport = injectVirtualViewportContext('ForVirtualFor');\n  readonly #views = new Map<string | number, EmbeddedViewRef<ForVirtualForContext<T>>>();\n\n  /** The full list of items to virtualize. */\n  readonly forVirtualForOf = input.required<readonly T[]>({ alias: 'forVirtualForOf' });\n\n  constructor() {\n    effect(() => this.#render());\n  }\n\n  /** Narrows the template context type for `let row of …` strict template checking. */\n  static ngTemplateContextGuard<T>(\n    _directive: ForVirtualFor<T>,\n    _context: unknown,\n  ): _context is ForVirtualForContext<T> {\n    return true;\n  }\n\n  #render(): void {\n    const items = this.#viewport.virtualItems();\n    const data = this.forVirtualForOf();\n    const count = this.#viewport.count();\n    const horizontal = this.#viewport.orientation() === 'horizontal';\n\n    const seen = new Set(items.map((item) => item.key));\n    for (const [key, view] of this.#views) {\n      if (seen.has(key)) {\n        continue;\n      }\n      const index = this.#viewContainer.indexOf(view);\n      if (index >= 0) {\n        this.#viewContainer.remove(index);\n      }\n      this.#views.delete(key);\n    }\n\n    items.forEach((item, position) => {\n      const value = data[item.index]!;\n      let view = this.#views.get(item.key);\n      if (!view) {\n        view = this.#viewContainer.createEmbeddedView(\n          this.#template,\n          { $implicit: value, virtualItem: item, index: item.index, count },\n          position,\n        );\n        this.#views.set(item.key, view);\n      } else {\n        if (this.#viewContainer.indexOf(view) !== position) {\n          this.#viewContainer.move(view, position);\n        }\n        view.context.$implicit = value;\n        view.context.virtualItem = item;\n        view.context.index = item.index;\n        view.context.count = count;\n        view.markForCheck();\n      }\n      this.#applyLayout(view, item, count, horizontal);\n    });\n  }\n\n  #applyLayout(\n    view: EmbeddedViewRef<ForVirtualForContext<T>>,\n    item: VirtualItem,\n    count: number,\n    horizontal: boolean,\n  ): void {\n    const node = view.rootNodes[0] as unknown;\n    if (!(node instanceof HTMLElement)) {\n      return;\n    }\n    node.style.position = 'absolute';\n    node.style.top = '0';\n    node.style.left = '0';\n    if (horizontal) {\n      node.style.height = '100%';\n      node.style.transform = `translateX(${item.start}px)`;\n    } else {\n      node.style.width = '100%';\n      node.style.transform = `translateY(${item.start}px)`;\n    }\n    node.setAttribute('data-index', String(item.index));\n    node.setAttribute('aria-setsize', String(count));\n    node.setAttribute('aria-posinset', String(item.index + 1));\n  }\n}\n","/*\n * Public API surface of forty-cdk/virtualization.\n *\n * Virtualization (the windowing core, the Shape A viewport directives and\n * infinite-scroll) ships from this secondary entry point so that\n * `@tanstack/virtual-core` is isolated to its own bundle chunk: only consumers\n * importing from `forty-cdk/virtualization` pull it in, even when another lazy\n * route in the same app virtualizes.\n *\n * Nothing here imports another primitive, so the isolation is structural rather\n * than a tree-shaking claim. The two adapters that do compose a second primitive\n * ship from their own entry points: `forty-cdk/table-virtualization`\n * (`[forTableVirtualized]`) and `forty-cdk/virtual-reorder`\n * (`[forVirtualReorder]`).\n */\n\nexport {\n  injectVirtualizer,\n  type ForVirtualizer,\n  type VirtualItem,\n  type VirtualizerOptions,\n} from './virtualizer';\nexport {\n  injectInfiniteScroll,\n  type ForInfiniteScroll,\n  type InfiniteScrollOptions,\n} from './infinite-scroll';\nexport {\n  FOR_VIRTUAL_VIEWPORT_CONTEXT,\n  type ForVirtualViewportContext,\n} from './virtual-viewport-context';\nexport { ForVirtualViewport } from './virtual-viewport';\nexport { ForVirtualFor, type ForVirtualForContext } from './virtual-for';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["DEFAULT_OVERSCAN"],"mappings":";;;;;;AAuBA;AACA,MAAMA,kBAAgB,GAAG,CAAC;AAmF1B;;;;;AAKG;AACG,SAAU,aAAa,CAAC,KAAa,EAAE,YAAuC,EAAA;IAClF,IAAI,KAAK,GAAG,CAAC;AACb,IAAA,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,EAAE,KAAK,EAAE,EAAE;AAC1C,QAAA,KAAK,IAAI,YAAY,CAAC,KAAK,CAAC;IAC9B;AACA,IAAA,OAAO,KAAK;AACd;AAEA,SAAS,aAAa,CAAC,IAAqB,EAAA;IAC1C,OAAO;QACL,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,GAAG,EAAE,IAAI,CAAC,GAAsB;QAChC,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,IAAI,EAAE,IAAI,CAAC,IAAI;KAChB;AACH;AAEA,SAAS,iBAAiB,CAAC,CAAyB,EAAE,CAAyB,EAAA;IAC7E,IAAI,CAAC,KAAK,CAAC;AAAE,QAAA,OAAO,IAAI;AACxB,IAAA,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM;AAAE,QAAA,OAAO,KAAK;AACvC,IAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AACjC,QAAA,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAE;AACf,QAAA,MAA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