{"version":3,"file":"_tree-key-manager-chunk.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/src/cdk/a11y/key-manager/tree-key-manager.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {InjectionToken, QueryList} from '@angular/core';\nimport {coerceObservable} from '../../coercion/private';\nimport {Observable, Subject, Subscription, isObservable, of as observableOf} from 'rxjs';\nimport {take} from 'rxjs/operators';\nimport {\n  TreeKeyManagerFactory,\n  TreeKeyManagerItem,\n  TreeKeyManagerOptions,\n  TreeKeyManagerStrategy,\n} from './tree-key-manager-strategy';\nimport {Typeahead} from './typeahead';\n\n/**\n * This class manages keyboard events for trees. If you pass it a QueryList or other list of tree\n * items, it will set the active item, focus, handle expansion and typeahead correctly when\n * keyboard events occur.\n */\nexport class TreeKeyManager<T extends TreeKeyManagerItem> implements TreeKeyManagerStrategy<T> {\n  /** The index of the currently active (focused) item. */\n  private _activeItemIndex = -1;\n  /** The currently active (focused) item. */\n  private _activeItem: T | null = null;\n  /** Whether or not we activate the item when it's focused. */\n  private _shouldActivationFollowFocus = false;\n  /**\n   * The orientation that the tree is laid out in. In `rtl` mode, the behavior of Left and\n   * Right arrow are switched.\n   */\n  private _horizontalOrientation: 'ltr' | 'rtl' = 'ltr';\n\n  /**\n   * Predicate function that can be used to check whether an item should be skipped\n   * by the key manager.\n   *\n   * The default value for this doesn't skip any elements in order to keep tree items focusable\n   * when disabled. This aligns with ARIA guidelines:\n   * https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#focusabilityofdisabledcontrols.\n   */\n  private _skipPredicateFn = (_item: T) => false;\n\n  /** Function to determine equivalent items. */\n  private _trackByFn: (item: T) => unknown = (item: T) => item;\n\n  /** Synchronous cache of the items to manage. */\n  private _items: T[] = [];\n\n  private _typeahead?: Typeahead<T>;\n  private _typeaheadSubscription = Subscription.EMPTY;\n\n  private _hasInitialFocused = false;\n\n  private _initializeFocus(): void {\n    if (this._hasInitialFocused || this._items.length === 0) {\n      return;\n    }\n\n    let activeIndex = 0;\n    for (let i = 0; i < this._items.length; i++) {\n      if (!this._skipPredicateFn(this._items[i]) && !this._isItemDisabled(this._items[i])) {\n        activeIndex = i;\n        break;\n      }\n    }\n\n    const activeItem = this._items[activeIndex];\n\n    // Use `makeFocusable` here, because we want the item to just be focusable, not actually\n    // capture the focus since the user isn't interacting with it. See #29628.\n    if (activeItem.makeFocusable) {\n      this._activeItem?.unfocus();\n      this._activeItemIndex = activeIndex;\n      this._activeItem = activeItem;\n      this._typeahead?.setCurrentSelectedItemIndex(activeIndex);\n      activeItem.makeFocusable();\n    } else {\n      // Backwards compatibility for items that don't implement `makeFocusable`.\n      this.focusItem(activeIndex);\n    }\n\n    this._hasInitialFocused = true;\n  }\n\n  /**\n   *\n   * @param items List of TreeKeyManager options. Can be synchronous or asynchronous.\n   * @param config Optional configuration options. By default, use 'ltr' horizontal orientation. By\n   * default, do not skip any nodes. By default, key manager only calls `focus` method when items\n   * are focused and does not call `activate`. If `typeaheadDefaultInterval` is `true`, use a\n   * default interval of 200ms.\n   */\n  constructor(items: Observable<T[]> | QueryList<T> | T[], config: TreeKeyManagerOptions<T>) {\n    // We allow for the items to be an array or Observable because, in some cases, the consumer may\n    // not have access to a QueryList of the items they want to manage (e.g. when the\n    // items aren't being collected via `ViewChildren` or `ContentChildren`).\n    if (items instanceof QueryList) {\n      this._items = items.toArray();\n      items.changes.subscribe((newItems: QueryList<T>) => this._itemsChanged(newItems.toArray()));\n    } else if (isObservable(items)) {\n      items.subscribe(newItems => this._itemsChanged(newItems));\n    } else {\n      this._items = items;\n      this._initializeFocus();\n    }\n\n    if (typeof config.shouldActivationFollowFocus === 'boolean') {\n      this._shouldActivationFollowFocus = config.shouldActivationFollowFocus;\n    }\n    if (config.horizontalOrientation) {\n      this._horizontalOrientation = config.horizontalOrientation;\n    }\n    if (config.skipPredicate) {\n      this._skipPredicateFn = config.skipPredicate;\n    }\n    if (config.trackBy) {\n      this._trackByFn = config.trackBy;\n    }\n    if (typeof config.typeAheadDebounceInterval !== 'undefined') {\n      this._setTypeAhead(config.typeAheadDebounceInterval);\n    }\n  }\n\n  /** Stream that emits any time the focused item changes. */\n  readonly change = new Subject<T | null>();\n\n  /** Cleans up the key manager. */\n  destroy() {\n    this._typeaheadSubscription.unsubscribe();\n    this._typeahead?.destroy();\n    this.change.complete();\n  }\n\n  /**\n   * Handles a keyboard event on the tree.\n   * @param event Keyboard event that represents the user interaction with the tree.\n   */\n  onKeydown(event: KeyboardEvent) {\n    const key = event.key;\n\n    switch (key) {\n      case 'Tab':\n        // Return early here, in order to allow Tab to actually tab out of the tree\n        return;\n\n      case 'ArrowDown':\n        this._focusNextItem();\n        break;\n\n      case 'ArrowUp':\n        this._focusPreviousItem();\n        break;\n\n      case 'ArrowRight':\n        this._horizontalOrientation === 'rtl'\n          ? this._collapseCurrentItem()\n          : this._expandCurrentItem();\n        break;\n\n      case 'ArrowLeft':\n        this._horizontalOrientation === 'rtl'\n          ? this._expandCurrentItem()\n          : this._collapseCurrentItem();\n        break;\n\n      case 'Home':\n        this._focusFirstItem();\n        break;\n\n      case 'End':\n        this._focusLastItem();\n        break;\n\n      case 'Enter':\n      case ' ':\n        this._activateCurrentItem();\n        break;\n\n      default:\n        if (event.key === '*') {\n          this._expandAllItemsAtCurrentItemLevel();\n          break;\n        }\n\n        this._typeahead?.handleKey(event);\n        // Return here, in order to avoid preventing the default action of non-navigational\n        // keys or resetting the buffer of pressed letters.\n        return;\n    }\n\n    // Reset the typeahead since the user has used a navigational key.\n    this._typeahead?.reset();\n    event.preventDefault();\n  }\n\n  /** Index of the currently active item. */\n  getActiveItemIndex(): number | null {\n    return this._activeItemIndex;\n  }\n\n  /** The currently active item. */\n  getActiveItem(): T | null {\n    return this._activeItem;\n  }\n\n  /** Called when the list of items has changed. */\n  private _itemsChanged(newItems: T[]) {\n    if (this._hasInitialFocused && this._activeItem && !newItems.includes(this._activeItem)) {\n      this._activeItem = null;\n      this._hasInitialFocused = false;\n    }\n\n    this._items = newItems;\n    this._typeahead?.setItems(this._items);\n    this._updateActiveItemIndex(this._items);\n    this._initializeFocus();\n  }\n\n  /** Focus the first available item. */\n  private _focusFirstItem(): void {\n    this.focusItem(this._findNextAvailableItemIndex(-1));\n  }\n\n  /** Focus the last available item. */\n  private _focusLastItem(): void {\n    this.focusItem(this._findPreviousAvailableItemIndex(this._items.length));\n  }\n\n  /** Focus the next available item. */\n  private _focusNextItem(): void {\n    this.focusItem(this._findNextAvailableItemIndex(this._activeItemIndex));\n  }\n\n  /** Focus the previous available item. */\n  private _focusPreviousItem(): void {\n    this.focusItem(this._findPreviousAvailableItemIndex(this._activeItemIndex));\n  }\n\n  /**\n   * Focus the provided item by index.\n   * @param index The index of the item to focus.\n   * @param options Additional focusing options.\n   */\n  focusItem(index: number, options?: {emitChangeEvent?: boolean}): void;\n  focusItem(item: T, options?: {emitChangeEvent?: boolean}): void;\n  focusItem(itemOrIndex: number | T, options?: {emitChangeEvent?: boolean}): void;\n  focusItem(itemOrIndex: number | T, options: {emitChangeEvent?: boolean} = {}) {\n    // Set default options\n    options.emitChangeEvent ??= true;\n\n    let index =\n      typeof itemOrIndex === 'number'\n        ? itemOrIndex\n        : this._items.findIndex(item => this._trackByFn(item) === this._trackByFn(itemOrIndex));\n    if (index < 0 || index >= this._items.length) {\n      return;\n    }\n    const activeItem = this._items[index];\n\n    // If we're just setting the same item, don't re-call activate or focus\n    if (\n      this._activeItem !== null &&\n      this._trackByFn(activeItem) === this._trackByFn(this._activeItem)\n    ) {\n      return;\n    }\n\n    const previousActiveItem = this._activeItem;\n    this._activeItem = activeItem ?? null;\n    this._activeItemIndex = index;\n    this._typeahead?.setCurrentSelectedItemIndex(index);\n\n    this._activeItem?.focus();\n    previousActiveItem?.unfocus();\n\n    if (options.emitChangeEvent) {\n      this.change.next(this._activeItem);\n    }\n\n    if (this._shouldActivationFollowFocus) {\n      this._activateCurrentItem();\n    }\n  }\n\n  private _updateActiveItemIndex(newItems: T[]) {\n    const activeItem = this._activeItem;\n    if (!activeItem) {\n      return;\n    }\n\n    const newIndex = newItems.findIndex(\n      item => this._trackByFn(item) === this._trackByFn(activeItem),\n    );\n\n    if (newIndex > -1 && newIndex !== this._activeItemIndex) {\n      this._activeItemIndex = newIndex;\n      this._typeahead?.setCurrentSelectedItemIndex(newIndex);\n    }\n  }\n\n  private _setTypeAhead(debounceInterval: number | boolean) {\n    this._typeahead = new Typeahead(this._items, {\n      debounceInterval: typeof debounceInterval === 'number' ? debounceInterval : undefined,\n      skipPredicate: item => this._skipPredicateFn(item),\n    });\n\n    this._typeaheadSubscription = this._typeahead.selectedItem.subscribe(item => {\n      this.focusItem(item);\n    });\n  }\n\n  private _findNextAvailableItemIndex(startingIndex: number) {\n    for (let i = startingIndex + 1; i < this._items.length; i++) {\n      if (!this._skipPredicateFn(this._items[i])) {\n        return i;\n      }\n    }\n    return startingIndex;\n  }\n\n  private _findPreviousAvailableItemIndex(startingIndex: number) {\n    for (let i = startingIndex - 1; i >= 0; i--) {\n      if (!this._skipPredicateFn(this._items[i])) {\n        return i;\n      }\n    }\n    return startingIndex;\n  }\n\n  /**\n   * If the item is already expanded, we collapse the item. Otherwise, we will focus the parent.\n   */\n  private _collapseCurrentItem() {\n    if (!this._activeItem) {\n      return;\n    }\n\n    if (this._isCurrentItemExpanded()) {\n      this._activeItem.collapse();\n    } else {\n      const parent = this._activeItem.getParent();\n      if (!parent || this._skipPredicateFn(parent as T)) {\n        return;\n      }\n      this.focusItem(parent as T);\n    }\n  }\n\n  /**\n   * If the item is already collapsed, we expand the item. Otherwise, we will focus the first child.\n   */\n  private _expandCurrentItem() {\n    if (!this._activeItem) {\n      return;\n    }\n\n    if (!this._isCurrentItemExpanded()) {\n      this._activeItem.expand();\n    } else {\n      coerceObservable(this._activeItem.getChildren())\n        .pipe(take(1))\n        .subscribe(children => {\n          const firstChild = children.find(child => !this._skipPredicateFn(child as T));\n          if (!firstChild) {\n            return;\n          }\n          this.focusItem(firstChild as T);\n        });\n    }\n  }\n\n  private _isCurrentItemExpanded() {\n    if (!this._activeItem) {\n      return false;\n    }\n    return typeof this._activeItem.isExpanded === 'boolean'\n      ? this._activeItem.isExpanded\n      : this._activeItem.isExpanded();\n  }\n\n  private _isItemDisabled(item: TreeKeyManagerItem) {\n    return typeof item.isDisabled === 'boolean' ? item.isDisabled : item.isDisabled?.();\n  }\n\n  /** For all items that are the same level as the current item, we expand those items. */\n  private _expandAllItemsAtCurrentItemLevel() {\n    if (!this._activeItem) {\n      return;\n    }\n\n    const parent = this._activeItem.getParent();\n    let itemsToExpand;\n    if (!parent) {\n      itemsToExpand = observableOf(this._items.filter(item => item.getParent() === null));\n    } else {\n      itemsToExpand = coerceObservable(parent.getChildren());\n    }\n\n    itemsToExpand.pipe(take(1)).subscribe(items => {\n      for (const item of items) {\n        item.expand();\n      }\n    });\n  }\n\n  private _activateCurrentItem() {\n    this._activeItem?.activate();\n  }\n}\n\n/** Injection token that determines the key manager to use. */\nexport const TREE_KEY_MANAGER = new InjectionToken<TreeKeyManagerFactory<any>>('tree-key-manager', {\n  providedIn: 'root',\n  factory: () => (items, options) => new TreeKeyManager(items, options),\n});\n"],"names":["TreeKeyManager","_activeItemIndex","_activeItem","_shouldActivationFollowFocus","_horizontalOrientation","_skipPredicateFn","_item","_trackByFn","item","_items","_typeahead","_typeaheadSubscription","Subscription","EMPTY","_hasInitialFocused","_initializeFocus","length","activeIndex","i","_isItemDisabled","activeItem","makeFocusable","unfocus","setCurrentSelectedItemIndex","focusItem","constructor","items","config","QueryList","toArray","changes","subscribe","newItems","_itemsChanged","isObservable","shouldActivationFollowFocus","horizontalOrientation","skipPredicate","trackBy","typeAheadDebounceInterval","_setTypeAhead","change","Subject","destroy","unsubscribe","complete","onKeydown","event","key","_focusNextItem","_focusPreviousItem","_collapseCurrentItem","_expandCurrentItem","_focusFirstItem","_focusLastItem","_activateCurrentItem","_expandAllItemsAtCurrentItemLevel","handleKey","reset","preventDefault","getActiveItemIndex","getActiveItem","includes","setItems","_updateActiveItemIndex","_findNextAvailableItemIndex","_findPreviousAvailableItemIndex","itemOrIndex","options","emitChangeEvent","index","findIndex","previousActiveItem","focus","next","newIndex","debounceInterval","Typeahead","undefined","selectedItem","startingIndex","_isCurrentItemExpanded","collapse","parent","getParent","expand","coerceObservable","getChildren","pipe","take","children","firstChild","find","child","isExpanded","isDisabled","itemsToExpand","observableOf","filter","activate","TREE_KEY_MANAGER","InjectionToken","providedIn","factory"],"mappings":";;;;;;MAyBaA,cAAc,CAAA;EAEjBC,gBAAgB,GAAG,EAAE;AAErBC,EAAAA,WAAW,GAAa,IAAI;AAE5BC,EAAAA,4BAA4B,GAAG,KAAK;AAKpCC,EAAAA,sBAAsB,GAAkB,KAAK;EAU7CC,gBAAgB,GAAIC,KAAQ,IAAK,KAAK;EAGtCC,UAAU,GAA0BC,IAAO,IAAKA,IAAI;AAGpDC,EAAAA,MAAM,GAAQ,EAAE;EAEhBC,UAAU;EACVC,sBAAsB,GAAGC,YAAY,CAACC,KAAK;AAE3CC,EAAAA,kBAAkB,GAAG,KAAK;AAE1BC,EAAAA,gBAAgBA,GAAA;IACtB,IAAI,IAAI,CAACD,kBAAkB,IAAI,IAAI,CAACL,MAAM,CAACO,MAAM,KAAK,CAAC,EAAE;AACvD,MAAA;AACF,IAAA;IAEA,IAAIC,WAAW,GAAG,CAAC;AACnB,IAAA,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAG,IAAI,CAACT,MAAM,CAACO,MAAM,EAAEE,CAAC,EAAE,EAAE;MAC3C,IAAI,CAAC,IAAI,CAACb,gBAAgB,CAAC,IAAI,CAACI,MAAM,CAACS,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAACC,eAAe,CAAC,IAAI,CAACV,MAAM,CAACS,CAAC,CAAC,CAAC,EAAE;AACnFD,QAAAA,WAAW,GAAGC,CAAC;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