{"version":3,"file":"autocomplete.mjs","sources":["../../../../../k8-fastbuild-ST-fdfa778d11ba/bin/src/angular/autocomplete/autocomplete.ts","../../../../../k8-fastbuild-ST-fdfa778d11ba/bin/src/angular/autocomplete/autocomplete.html","../../../../../k8-fastbuild-ST-fdfa778d11ba/bin/src/angular/autocomplete/autocomplete-origin.ts","../../../../../k8-fastbuild-ST-fdfa778d11ba/bin/src/angular/autocomplete/autocomplete-trigger.ts","../../../../../k8-fastbuild-ST-fdfa778d11ba/bin/src/angular/autocomplete/autocomplete.module.ts"],"sourcesContent":["import { ActiveDescendantKeyManager, _IdGenerator } from '@angular/cdk/a11y';\nimport { Platform } from '@angular/cdk/platform';\nimport {\n  AfterContentInit,\n  booleanAttribute,\n  ChangeDetectionStrategy,\n  ChangeDetectorRef,\n  Component,\n  ContentChildren,\n  ElementRef,\n  EventEmitter,\n  inject,\n  InjectionToken,\n  Input,\n  OnDestroy,\n  Output,\n  QueryList,\n  TemplateRef,\n  ViewChild,\n  ViewEncapsulation,\n} from '@angular/core';\nimport {\n  SbbOptgroup,\n  SbbOption,\n  SbbOptionHint,\n  SBB_OPTION_PARENT_COMPONENT,\n} from '@sbb-esta/angular/core';\nimport { BehaviorSubject, Subscription } from 'rxjs';\n\n/** Event object that is emitted when an autocomplete option is selected. */\nexport class SbbAutocompleteSelectedEvent {\n  constructor(\n    /** Reference to the autocomplete panel that emitted the event. */\n    public source: SbbAutocomplete,\n    /** Option that was selected. */\n    public option: SbbOption,\n  ) {}\n}\n\n/** Event object that is emitted when an autocomplete option is activated. */\nexport interface SbbAutocompleteActivatedEvent {\n  /** Reference to the autocomplete panel that emitted the event. */\n  source: SbbAutocomplete;\n  /** Option that was selected. */\n  option: SbbOption | null;\n}\n\n/** Default `sbb-autocomplete` options that can be overridden. */\nexport interface SbbAutocompleteDefaultOptions {\n  /** Whether the first option should be highlighted when an autocomplete panel is opened. */\n  autoActiveFirstOption?: boolean;\n\n  /** Whether the active option should be selected as the user is navigating. */\n  autoSelectActiveOption?: boolean;\n\n  /** Whether the user is required to make a selection when they're interacting with the autocomplete. */\n  requireSelection?: boolean;\n\n  /** Class or list of classes to be applied to the autocomplete's overlay panel. */\n  overlayPanelClass?: string | string[];\n}\n\n/** Injection token to be used to override the default options for `sbb-autocomplete`. */\nexport const SBB_AUTOCOMPLETE_DEFAULT_OPTIONS = new InjectionToken<SbbAutocompleteDefaultOptions>(\n  'sbb-autocomplete-default-options',\n  {\n    providedIn: 'root',\n    factory: () => ({\n      autoActiveFirstOption: false,\n      autoSelectActiveOption: false,\n      requireSelection: false,\n    }),\n  },\n);\n\n@Component({\n  selector: 'sbb-autocomplete',\n  exportAs: 'sbbAutocomplete',\n  templateUrl: 'autocomplete.html',\n  styleUrls: ['autocomplete.css'],\n  encapsulation: ViewEncapsulation.None,\n  changeDetection: ChangeDetectionStrategy.OnPush,\n  providers: [\n    {\n      provide: SBB_OPTION_PARENT_COMPONENT,\n      useExisting: SbbAutocomplete,\n    },\n  ],\n  host: {\n    class: 'sbb-autocomplete',\n  },\n})\nexport class SbbAutocomplete implements AfterContentInit, OnDestroy {\n  private _changeDetectorRef = inject(ChangeDetectorRef);\n  private _elementRef = inject<ElementRef<HTMLElement>>(ElementRef);\n  protected defaults: SbbAutocompleteDefaultOptions = inject<SbbAutocompleteDefaultOptions>(\n    SBB_AUTOCOMPLETE_DEFAULT_OPTIONS,\n  );\n\n  private _activeOptionChanges = Subscription.EMPTY;\n\n  /** Manages active item in option list based on key events. */\n  _keyManager: ActiveDescendantKeyManager<SbbOption>;\n\n  /** Whether the autocomplete panel should be visible, depending on option length. */\n  get showPanel(): boolean {\n    return this._showPanel.value;\n  }\n  _showPanel: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);\n\n  /** Whether the autocomplete panel is open. */\n  get isOpen(): boolean {\n    return this._isOpen && this.showPanel;\n  }\n  _isOpen: boolean = false;\n\n  // The @ViewChild query for TemplateRef here needs to be static because some code paths\n  // lead to the overlay being created before change detection has finished for this component.\n  // Notably, another component may trigger `focus` on the autocomplete-trigger.\n\n  /** @docs-private */\n  @ViewChild(TemplateRef, { static: true }) template: TemplateRef<any>;\n\n  /** Element for the panel containing the autocomplete options. */\n  @ViewChild('panel') panel: ElementRef;\n\n  /** All of the defined select options. */\n  @ContentChildren(SbbOption, { descendants: true }) options: QueryList<SbbOption>;\n\n  /** All of the defined groups of options. */\n  @ContentChildren(SbbOptgroup, { descendants: true }) optionGroups: QueryList<SbbOptgroup>;\n\n  /** All of the defined option hints. */\n  @ContentChildren(SbbOptionHint, { descendants: true })\n  hints: QueryList<SbbOptionHint>;\n\n  /** Aria label of the autocomplete. If not specified, the placeholder will be used as label. */\n  @Input('aria-label') ariaLabel: string;\n\n  /** Input that can be used to specify the `aria-labelledby` attribute. */\n  @Input('aria-labelledby') ariaLabelledby: string;\n\n  /** Function that maps an option's control value to its display value in the trigger. */\n  @Input() displayWith: ((value: any) => string) | null = null;\n\n  /**\n   * Function which normalizes input values to highlight them in options.\n   * E.g. If your function is <code>(value: string) => value.replace(new RegExp('[ö]', 'i'), 'o')</code>\n   * and you search for 'Faroer', an option like 'Faröer' will be highlighted.\n   * IMPORTANT: The provided function MAY NOT change the order of the characters or the length of the string.\n   * (e.g. changing `ä` to `ae` would break the highlighting function)\n   */\n  @Input() localeNormalizer: ((value: string) => string) | null = null;\n\n  /**\n   * Whether the first option should be highlighted when the autocomplete panel is opened.\n   * Can be configured globally through the `SBB_AUTOCOMPLETE_DEFAULT_OPTIONS` token.\n   */\n  @Input({ transform: booleanAttribute }) autoActiveFirstOption: boolean;\n\n  /** Whether the active option should be selected as the user is navigating. */\n  @Input({ transform: booleanAttribute }) autoSelectActiveOption: boolean;\n\n  /**\n   * Whether the user is required to make a selection when they're interacting with the\n   * autocomplete. If the user moves away from the autocomplete without selecting an option from\n   * the list, the value will be reset. If the user opens the panel and closes it without\n   * interacting or selecting a value, the initial value will be kept.\n   */\n  @Input({ transform: booleanAttribute }) requireSelection: boolean;\n\n  /**\n   * Specify the width of the autocomplete panel.  Can be any CSS sizing value, otherwise it will\n   * match the width of its host.\n   */\n  @Input() panelWidth: string | number;\n\n  /** Event that is emitted whenever an option from the list is selected. */\n  @Output()\n  readonly optionSelected: EventEmitter<SbbAutocompleteSelectedEvent> =\n    new EventEmitter<SbbAutocompleteSelectedEvent>();\n\n  /** Event that is emitted when the autocomplete panel is opened. */\n  @Output() readonly opened: EventEmitter<void> = new EventEmitter<void>();\n\n  /** Event that is emitted when the autocomplete panel is closed. */\n  @Output() readonly closed: EventEmitter<void> = new EventEmitter<void>();\n\n  /** Emits whenever an option is activated. */\n  @Output()\n  readonly optionActivated: EventEmitter<SbbAutocompleteActivatedEvent> =\n    new EventEmitter<SbbAutocompleteActivatedEvent>();\n\n  /**\n   * Takes classes set on the host sbb-autocomplete element and applies them to the panel\n   * inside the overlay container to allow for easy styling.\n   */\n  @Input('class')\n  set classList(value: string | string[]) {\n    this._classList = value;\n    this._elementRef.nativeElement.className = '';\n  }\n  _classList: string | string[];\n\n  /** If set to true, the panel is also displayed if there are no options but hints. */\n  @Input({ transform: booleanAttribute }) showHintIfNoOptions: boolean = false;\n\n  /** Unique ID to be used by autocomplete trigger's \"aria-controls\" property. */\n  id: string = inject(_IdGenerator).getId('sbb-autocomplete-');\n\n  /**\n   * Tells any descendant `sbb-optgroup` to use the inert a11y pattern.\n   * @docs-private\n   */\n  readonly inertGroups: boolean;\n\n  constructor(...args: unknown[]);\n  constructor() {\n    const platform = inject(Platform);\n\n    // TODO(crisbeto): the problem that the `inertGroups` option resolves is only present on\n    // Safari using VoiceOver. We should occasionally check back to see whether the bug\n    // wasn't resolved in VoiceOver, and if it has, we can remove this and the `inertGroups`\n    // option altogether.\n    this.inertGroups = platform?.SAFARI || false;\n    this.autoActiveFirstOption = !!this.defaults.autoActiveFirstOption;\n    this.autoSelectActiveOption = !!this.defaults.autoSelectActiveOption;\n    this.requireSelection = !!this.defaults.requireSelection;\n  }\n\n  ngAfterContentInit() {\n    this._keyManager = new ActiveDescendantKeyManager<SbbOption>(this.options).withWrap();\n    this._activeOptionChanges = this._keyManager.change.subscribe((index) => {\n      if (this.isOpen) {\n        this.optionActivated.emit({ source: this, option: this.options.toArray()[index] || null });\n      }\n    });\n\n    // Set the initial visibility state.\n    this._setVisibility();\n  }\n\n  ngOnDestroy() {\n    this._activeOptionChanges.unsubscribe();\n    this._keyManager?.destroy();\n  }\n\n  /**\n   * Sets the panel scrollTop. This allows us to manually scroll to display options\n   * above or below the fold, as they are not actually being focused when active.\n   */\n  _setScrollTop(scrollTop: number): void {\n    if (this.panel) {\n      this.panel.nativeElement.scrollTop = scrollTop;\n    }\n  }\n\n  /** Returns the panel's scrollTop. */\n  _getScrollTop(): number {\n    return this.panel ? this.panel.nativeElement.scrollTop : 0;\n  }\n\n  /**\n   * Panel should hide itself when the option list is empty.\n   * If there are only hints and showHintIfNoOptions is true,\n   * the panel should still be displayed.\n   */\n  _setVisibility() {\n    this._showPanel.next(\n      !!this.options.length || (!!this.hints.length && this.showHintIfNoOptions),\n    );\n    this._changeDetectorRef.markForCheck();\n  }\n\n  /** Emits the `select` event. */\n  _emitSelectEvent(option: SbbOption): void {\n    const event = new SbbAutocompleteSelectedEvent(this, option);\n    this.optionSelected.emit(event);\n  }\n\n  /** Gets the aria-labelledby for the autocomplete panel. */\n  _getPanelAriaLabelledby(labelId: string | null): string | null {\n    if (this.ariaLabel) {\n      return null;\n    }\n\n    const labelExpression = labelId ? labelId + ' ' : '';\n    return this.ariaLabelledby ? labelExpression + this.ariaLabelledby : labelId;\n  }\n}\n","<ng-template let-formFieldId=\"id\">\n  <div\n    class=\"sbb-panel sbb-panel-padded sbb-autocomplete-panel sbb-scrollbar\"\n    role=\"listbox\"\n    [id]=\"id\"\n    [attr.aria-label]=\"ariaLabel || null\"\n    [attr.aria-labelledby]=\"_getPanelAriaLabelledby(formFieldId)\"\n    [class]=\"_classList\"\n    [class.sbb-autocomplete-visible]=\"showPanel\"\n    [class.sbb-autocomplete-hidden]=\"!showPanel\"\n    #panel\n  >\n    <ng-content></ng-content>\n  </div>\n</ng-template>\n","import { Directive, ElementRef, inject } from '@angular/core';\n\n/**\n * Directive applied to an element to make it usable\n * as a connection point for an autocomplete panel.\n */\n@Directive({\n  selector: '[sbbAutocompleteOrigin]',\n  exportAs: 'sbbAutocompleteOrigin',\n})\nexport class SbbAutocompleteOrigin {\n  elementRef: ElementRef<HTMLElement> = inject<ElementRef<HTMLElement>>(ElementRef);\n\n  constructor(...args: unknown[]);\n  constructor() {}\n}\n","import { addAriaReferencedId, removeAriaReferencedId } from '@angular/cdk/a11y';\nimport { coerceStringArray } from '@angular/cdk/coercion';\nimport { DOWN_ARROW, ENTER, ESCAPE, hasModifierKey, TAB, UP_ARROW } from '@angular/cdk/keycodes';\nimport {\n  ConnectedPosition,\n  createRepositionScrollStrategy,\n  FlexibleConnectedPositionStrategy,\n  Overlay,\n  OverlayConfig,\n  OverlayRef,\n  PositionStrategy,\n  ScrollStrategy,\n} from '@angular/cdk/overlay';\nimport { _getEventTarget } from '@angular/cdk/platform';\nimport { TemplatePortal } from '@angular/cdk/portal';\nimport { ViewportRuler } from '@angular/cdk/scrolling';\nimport { DOCUMENT } from '@angular/common';\nimport {\n  afterNextRender,\n  AfterViewInit,\n  booleanAttribute,\n  ChangeDetectorRef,\n  Directive,\n  ElementRef,\n  forwardRef,\n  inject,\n  InjectionToken,\n  Injector,\n  Input,\n  NgZone,\n  OnChanges,\n  OnDestroy,\n  SimpleChanges,\n  ViewContainerRef,\n} from '@angular/core';\nimport { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';\nimport {\n  countGroupLabelsBeforeOption,\n  getOptionScrollPosition,\n  SbbOption,\n  SbbOptionSelectionChange,\n  TypeRef,\n} from '@sbb-esta/angular/core';\nimport type { SbbFormField } from '@sbb-esta/angular/form-field';\nimport { SBB_FORM_FIELD } from '@sbb-esta/angular/form-field';\nimport {\n  BehaviorSubject,\n  combineLatest,\n  defer,\n  fromEvent,\n  merge,\n  Observable,\n  of as observableOf,\n  Subject,\n  Subscription,\n} from 'rxjs';\nimport {\n  delay,\n  distinctUntilChanged,\n  filter,\n  map,\n  startWith,\n  switchMap,\n  take,\n  tap,\n} from 'rxjs/operators';\n\nimport {\n  SbbAutocomplete,\n  SbbAutocompleteDefaultOptions,\n  SBB_AUTOCOMPLETE_DEFAULT_OPTIONS,\n} from './autocomplete';\nimport { SbbAutocompleteOrigin } from './autocomplete-origin';\n\n/** Injection token that determines the scroll handling while the autocomplete panel is open. */\nexport const SBB_AUTOCOMPLETE_SCROLL_STRATEGY = new InjectionToken<() => ScrollStrategy>(\n  'sbb-autocomplete-scroll-strategy',\n  {\n    providedIn: 'root',\n    factory: () => {\n      const injector = inject(Injector);\n      return () => createRepositionScrollStrategy(injector);\n    },\n  },\n);\n\n/**\n * Creates an error to be thrown when attempting to use an autocomplete trigger without a panel.\n * @docs-private\n */\nexport function getSbbAutocompleteMissingPanelError(): Error {\n  return Error(\n    'Attempting to open an undefined instance of `sbb-autocomplete`. ' +\n      'Make sure that the id passed to the `sbbAutocomplete` is correct and that ' +\n      `you're attempting to open it after the ngAfterContentInit hook.`,\n  );\n}\n\n@Directive({\n  selector: `input[sbbAutocomplete]`,\n  exportAs: 'sbbAutocompleteTrigger',\n  providers: [\n    {\n      provide: NG_VALUE_ACCESSOR,\n      useExisting: forwardRef(() => SbbAutocompleteTrigger),\n      multi: true,\n    },\n  ],\n  host: {\n    class: 'sbb-autocomplete-trigger',\n    '[attr.autocomplete]': 'autocompleteAttribute',\n    '[attr.role]': 'autocompleteDisabled ? null : \"combobox\"',\n    '[attr.aria-autocomplete]': 'autocompleteDisabled ? null : \"list\"',\n    '[attr.aria-activedescendant]': '(panelOpen && activeOption) ? activeOption.id : null',\n    '[attr.aria-expanded]': 'autocompleteDisabled ? null : panelOpen.toString()',\n    '[attr.aria-controls]': '(autocompleteDisabled || !panelOpen) ? null : autocomplete?.id',\n    '[attr.aria-haspopup]': 'autocompleteDisabled ? null : \"listbox\"',\n    '[class.sbb-focused]': 'panelOpen',\n    // Note: we use `focusin`, as opposed to `focus`, in order to open the panel\n    // a little earlier. This avoids issues where IE delays the focusing of the input.\n    '(focusin)': '_handleFocus()',\n    '(blur)': '_onTouched()',\n    '(input)': '_handleInput($event)',\n    '(keydown)': '_handleKeydown($event)',\n    '(click)': '_handleClick()',\n  },\n})\nexport class SbbAutocompleteTrigger\n  implements ControlValueAccessor, AfterViewInit, OnChanges, OnDestroy\n{\n  private _element = inject<ElementRef<HTMLInputElement>>(ElementRef);\n  private _overlay = inject(Overlay);\n  private _viewContainerRef = inject(ViewContainerRef);\n  private _zone = inject(NgZone);\n  private _changeDetectorRef = inject(ChangeDetectorRef);\n  private _formField = inject<TypeRef<SbbFormField> | null>(SBB_FORM_FIELD, {\n    optional: true,\n    host: true,\n  });\n  private _document = inject(DOCUMENT, { optional: true })!;\n  private _viewportRuler = inject(ViewportRuler);\n  private _defaults = inject<SbbAutocompleteDefaultOptions | null>(\n    SBB_AUTOCOMPLETE_DEFAULT_OPTIONS,\n    { optional: true },\n  );\n\n  private _overlayRef: OverlayRef | null;\n  private _portal: TemplatePortal;\n  private _componentDestroyed = false;\n  private _scrollStrategy = inject(SBB_AUTOCOMPLETE_SCROLL_STRATEGY);\n  private _keydownSubscription: Subscription | null;\n  private _outsideClickSubscription: Subscription | null;\n\n  /** Old value of the native input. Used to work around issues with the `input` event on IE. */\n  private _previousValue: string | number | null;\n\n  /** Value of the input element when the panel was attached (even if there are no options). */\n  private _valueOnAttach: string | number | null;\n\n  /** Value on the previous keydown event. */\n  private _valueOnLastKeydown: string | null;\n\n  /** Strategy that is used to position the panel. */\n  private _positionStrategy: FlexibleConnectedPositionStrategy;\n\n  /** The subscription for closing actions (some are bound to document). */\n  private _closingActionsSubscription: Subscription;\n\n  /** Subscription to viewport size changes. */\n  private _viewportSubscription = Subscription.EMPTY;\n\n  /** Subscription to position changes */\n  private _positionSubscription = Subscription.EMPTY;\n\n  /** Subscription to highlight options */\n  private _highlightSubscription = Subscription.EMPTY;\n\n  /** Subscription to toggle classes on the connected element */\n  private _connectedElementClassSubscription = Subscription.EMPTY;\n\n  /** BehaviourSubject holding inputValue. Used for highlighting */\n  private _inputValue = new BehaviorSubject('');\n\n  /**\n   * Whether the autocomplete can open the next time it is focused. Used to prevent a focused,\n   * closed autocomplete from being reopened if the user switches to another browser tab and then\n   * comes back.\n   */\n  private _canOpenOnNextFocus = true;\n\n  /** Value inside the input before we auto-selected an option. */\n  private _valueBeforeAutoSelection: string | undefined;\n\n  /**\n   * Current option that we have auto-selected as the user is navigating,\n   * but which hasn't been propagated to the model value yet.\n   */\n  private _pendingAutoselectedOption: SbbOption | null;\n\n  /** Stream of keyboard events that can close the panel. */\n  private readonly _closeKeyEventStream = new Subject<void>();\n\n  /**\n   * Event handler for when the window is blurred. Needs to be an\n   * arrow function in order to preserve the context.\n   */\n  private _windowBlurHandler = () => {\n    // If the user blurred the window while the autocomplete is focused, it means that it'll be\n    // refocused when they come back. In this case we want to skip the first focus event, if the\n    // pane was closed, in order to avoid reopening it unintentionally.\n    this._canOpenOnNextFocus =\n      this._document.activeElement !== this._element.nativeElement || this.panelOpen;\n  };\n\n  /** `View -> model callback called when value changes` */\n  _onChange: (value: any) => void = () => {};\n\n  /** `View -> model callback called when autocomplete has been touched` */\n  _onTouched: () => void = () => {};\n\n  /** The autocomplete panel to be attached to this trigger. */\n  @Input('sbbAutocomplete')\n  get autocomplete(): SbbAutocomplete {\n    return this._autocomplete;\n  }\n  set autocomplete(autocomplete: SbbAutocomplete) {\n    this._autocomplete = autocomplete;\n\n    this._highlightSubscription.unsubscribe();\n    this._connectedElementClassSubscription.unsubscribe();\n    if (!autocomplete) {\n      return;\n    }\n\n    const renderCallback = new Observable((subscriber) => {\n      afterNextRender(() => subscriber.next(), { injector: this._injector });\n    });\n    const onReady = autocomplete.options ? observableOf(null) : renderCallback;\n\n    this._highlightSubscription = onReady\n      .pipe(\n        switchMap(() =>\n          combineLatest([\n            this._inputValue,\n            (autocomplete.options.changes as Observable<SbbOption[]>).pipe(\n              startWith(autocomplete.options.toArray()),\n            ),\n          ]),\n        ),\n        filter((value) => !!value[1] && !!value[1].length),\n      )\n      .subscribe(([inputValue, options]) => {\n        options.forEach((option) =>\n          option._highlight(inputValue, this.autocomplete.localeNormalizer),\n        );\n      });\n\n    this._connectedElementClassSubscription = this.autocomplete._showPanel\n      .pipe(\n        distinctUntilChanged(),\n        filter((s) => !s),\n      )\n      .subscribe(() => {\n        this._getConnectedElement().nativeElement.classList.remove('sbb-input-with-open-panel');\n        this._getConnectedElement().nativeElement.classList.remove(\n          'sbb-input-with-open-panel-above',\n        );\n      });\n  }\n  private _autocomplete: SbbAutocomplete;\n\n  /**\n   * Position of the autocomplete panel relative to the trigger element. A position of `auto`\n   * will render the panel underneath the trigger if there is enough space for it to fit in\n   * the viewport, otherwise the panel will be shown above it. If the position is set to\n   * `above` or `below`, the panel will always be shown above or below the trigger. no matter\n   * whether it fits completely in the viewport.\n   */\n  @Input('sbbAutocompletePosition') position: 'auto' | 'above' | 'below' = 'auto';\n\n  /**\n   * Reference relative to which to position the autocomplete panel.\n   * Defaults to the autocomplete trigger element.\n   */\n  @Input('sbbAutocompleteConnectedTo') connectedTo: SbbAutocompleteOrigin;\n\n  /**\n   * `autocomplete` attribute to be set on the input element.\n   * @docs-private\n   */\n  @Input('autocomplete') autocompleteAttribute: string = 'off';\n\n  /**\n   * Whether the autocomplete is disabled. When disabled, the element will\n   * act as a regular input and the user won't be able to open the panel.\n   */\n  @Input({ alias: 'sbbAutocompleteDisabled', transform: booleanAttribute })\n  autocompleteDisabled: boolean = false;\n\n  private _initialized = new Subject<void>();\n\n  private _injector = inject(Injector);\n\n  constructor(...args: unknown[]);\n  constructor() {}\n\n  /** Class to apply to the panel when it's above the input. */\n  private _aboveClass: string = 'sbb-autocomplete-panel-above';\n\n  ngAfterViewInit() {\n    this._initialized.next();\n    this._initialized.complete();\n\n    const window = this._getWindow();\n\n    if (typeof window !== 'undefined') {\n      this._zone.runOutsideAngular(() => window.addEventListener('blur', this._windowBlurHandler));\n    }\n  }\n\n  ngOnChanges(changes: SimpleChanges) {\n    if (changes['position'] && this._positionStrategy) {\n      this._setStrategyPositions(this._positionStrategy);\n\n      if (this.panelOpen) {\n        this._overlayRef!.updatePosition();\n      }\n    }\n  }\n\n  ngOnDestroy() {\n    const window = this._getWindow();\n\n    if (typeof window !== 'undefined') {\n      window.removeEventListener('blur', this._windowBlurHandler);\n    }\n\n    this._viewportSubscription.unsubscribe();\n    this._positionSubscription.unsubscribe();\n    this._highlightSubscription.unsubscribe();\n    this._connectedElementClassSubscription.unsubscribe();\n    this._componentDestroyed = true;\n    this._destroyPanel();\n    this._closeKeyEventStream.complete();\n    this._clearFromModal();\n  }\n\n  /** Whether or not the autocomplete panel is open. */\n  get panelOpen(): boolean {\n    return this._overlayAttached && this.autocomplete.showPanel;\n  }\n  private _overlayAttached: boolean = false;\n\n  /** Opens the autocomplete suggestion panel. */\n  openPanel(): void {\n    this._openPanelInternal();\n  }\n\n  /** Closes the autocomplete suggestion panel. */\n  closePanel(): void {\n    if (!this._overlayAttached) {\n      return;\n    }\n\n    if (this.panelOpen) {\n      // Only emit if the panel was visible.\n      // `afterNextRender` always runs outside of the Angular zone, so all the subscriptions from\n      // `_subscribeToClosingActions()` are also outside of the Angular zone.\n      // We should manually run in Angular zone to update UI after panel closing.\n      this._zone.run(() => {\n        this.autocomplete.closed.emit();\n      });\n    }\n\n    this.autocomplete._isOpen = this._overlayAttached = false;\n    this._pendingAutoselectedOption = null;\n\n    if (this._overlayRef && this._overlayRef.hasAttached()) {\n      this._overlayRef.detach();\n      this._closingActionsSubscription.unsubscribe();\n    }\n\n    this._updatePanelState();\n\n    this._getConnectedElement().nativeElement.classList.remove('sbb-input-with-open-panel');\n    this._getConnectedElement().nativeElement.classList.remove('sbb-input-with-open-panel-above');\n\n    // Note that in some cases this can end up being called after the component is destroyed.\n    // Add a check to ensure that we don't try to run change detection on a destroyed view.\n    if (!this._componentDestroyed) {\n      // We need to trigger change detection manually, because\n      // `fromEvent` doesn't seem to do it at the proper time.\n      // This ensures that the label is reset when the\n      // user clicks outside.\n      this._changeDetectorRef.detectChanges();\n    }\n  }\n\n  /**\n   * Updates the position of the autocomplete suggestion panel to ensure that it fits all options\n   * within the viewport.\n   */\n  updatePosition(): void {\n    if (this._overlayAttached) {\n      this._overlayRef!.updatePosition();\n    }\n  }\n\n  /**\n   * A stream of actions that should close the autocomplete panel, including\n   * when an option is selected, on blur, and when TAB is pressed.\n   */\n  get panelClosingActions(): Observable<SbbOptionSelectionChange | null> {\n    return merge(\n      this.optionSelections,\n      this.autocomplete._keyManager.tabOut.pipe(filter(() => this._overlayAttached)),\n      this._closeKeyEventStream,\n      this._getOutsideClickStream(),\n      this._overlayRef\n        ? this._overlayRef.detachments().pipe(filter(() => this._overlayAttached))\n        : observableOf(),\n    ).pipe(\n      // Normalize the output so we return a consistent type.\n      map((event) => (event instanceof SbbOptionSelectionChange ? event : null)),\n    );\n  }\n\n  /** Stream of changes to the selection state of the autocomplete options. */\n  readonly optionSelections: Observable<SbbOptionSelectionChange> = defer(() => {\n    const options = this.autocomplete ? this.autocomplete.options : null;\n\n    if (options) {\n      return options.changes.pipe(\n        startWith(options),\n        switchMap(() => merge(...options.map((option) => option.onSelectionChange))),\n      );\n    }\n    // If there are any subscribers before `ngAfterViewInit`, the `autocomplete` will be undefined.\n    // Return a stream that we'll replace with the real one once everything is in place.\n    return this._initialized.pipe(switchMap(() => this.optionSelections));\n  }) as Observable<SbbOptionSelectionChange>;\n\n  /** The currently active option, coerced to SbbOption type. */\n  get activeOption(): SbbOption | null {\n    if (this.autocomplete && this.autocomplete._keyManager) {\n      return this.autocomplete._keyManager.activeItem;\n    }\n\n    return null;\n  }\n\n  /** Stream of clicks outside of the autocomplete panel. */\n  private _getOutsideClickStream(): Observable<any> {\n    return merge(\n      fromEvent(this._document, 'click') as Observable<MouseEvent>,\n      fromEvent(this._document, 'auxclick') as Observable<MouseEvent>,\n      fromEvent(this._document, 'touchend') as Observable<TouchEvent>,\n    ).pipe(\n      filter((event) => {\n        // If we're in the Shadow DOM, the event target will be the shadow root, so we have to\n        // fall back to check the first element in the path of the click event.\n        const clickTarget = _getEventTarget<HTMLElement>(event)!;\n        const formField = this._formField ? this._formField._elementRef.nativeElement : null;\n        const customOrigin = this.connectedTo ? this.connectedTo.elementRef.nativeElement : null;\n\n        return (\n          this._overlayAttached &&\n          clickTarget !== this._element.nativeElement &&\n          // Normally focus moves inside `mousedown` so this condition will almost always be\n          // true. Its main purpose is to handle the case where the input is focused from an\n          // outside click which propagates up to the `body` listener within the same sequence\n          // and causes the panel to close immediately (see angular/components#3106).\n          this._document.activeElement !== this._element.nativeElement &&\n          (!formField || !formField.contains(clickTarget)) &&\n          (!customOrigin || !customOrigin.contains(clickTarget)) &&\n          !!this._overlayRef &&\n          !this._overlayRef.overlayElement.contains(clickTarget)\n        );\n      }),\n    );\n  }\n\n  // Implemented as part of ControlValueAccessor.\n  writeValue(value: any): void {\n    Promise.resolve(null).then(() => this._assignOptionValue(value));\n  }\n\n  // Implemented as part of ControlValueAccessor.\n  registerOnChange(fn: (value: any) => {}): void {\n    this._onChange = fn;\n  }\n\n  // Implemented as part of ControlValueAccessor.\n  registerOnTouched(fn: () => {}) {\n    this._onTouched = fn;\n  }\n\n  // Implemented as part of ControlValueAccessor.\n  setDisabledState(isDisabled: boolean) {\n    this._element.nativeElement.disabled = isDisabled;\n  }\n\n  _handleKeydown(event: KeyboardEvent): void {\n    const keyCode = event.keyCode;\n    const hasModifier = hasModifierKey(event);\n\n    // Prevent the default action on all escape key presses. This is here primarily to bring IE\n    // in line with other browsers. By default, pressing escape on IE will cause it to revert\n    // the input value to the one that it had on focus, however it won't dispatch any events\n    // which means that the model value will be out of sync with the view.\n    if (keyCode === ESCAPE && !hasModifier) {\n      event.preventDefault();\n    }\n\n    this._valueOnLastKeydown = this._element.nativeElement.value;\n\n    if (this.activeOption && keyCode === ENTER && this.panelOpen && !hasModifier) {\n      this.activeOption._selectViaInteraction();\n      this._resetActiveItem();\n      event.preventDefault();\n    } else if (this.autocomplete) {\n      const prevActiveItem = this.autocomplete._keyManager.activeItem;\n      const isArrowKey = keyCode === UP_ARROW || keyCode === DOWN_ARROW;\n\n      if (keyCode === TAB || (isArrowKey && !hasModifier && this.panelOpen)) {\n        this.autocomplete._keyManager.onKeydown(event);\n      } else if (isArrowKey && this._canOpen()) {\n        this._openPanelInternal(this._valueOnLastKeydown);\n      }\n\n      if (isArrowKey || this.autocomplete._keyManager.activeItem !== prevActiveItem) {\n        this._scrollToOption(this.autocomplete._keyManager.activeItemIndex || 0);\n\n        if (this.autocomplete.autoSelectActiveOption && this.activeOption) {\n          if (!this._pendingAutoselectedOption) {\n            this._valueBeforeAutoSelection = this._valueOnLastKeydown;\n          }\n\n          this._pendingAutoselectedOption = this.activeOption;\n          this._assignOptionValue(this.activeOption.value);\n        }\n      }\n    }\n  }\n\n  _handleInput(event: Event): void {\n    const target = event.target as HTMLInputElement;\n    let value: number | string | null = target.value;\n\n    // Based on `NumberValueAccessor` from forms.\n    if (target.type === 'number') {\n      value = value === '' ? null : parseFloat(value);\n    }\n\n    // If the input has a placeholder, IE will fire the `input` event on page load,\n    // focus and blur, in addition to when the user actually changed the value. To\n    // filter out all of the extra events, we save the value on focus and between\n    // `input` events, and we check whether it changed.\n    // See: https://connect.microsoft.com/IE/feedback/details/885747/\n    if (this._previousValue !== value) {\n      this._previousValue = value;\n      this._pendingAutoselectedOption = null;\n\n      // If selection is required we don't write to the CVA while the user is typing.\n      // At the end of the selection either the user will have picked something\n      // or we'll reset the value back to null.\n      if (!this.autocomplete || !this.autocomplete.requireSelection) {\n        this._onChange(value);\n      }\n      this._inputValue.next(target.value);\n\n      if (!value) {\n        this._clearPreviousSelectedOption(null, false);\n      } else if (this.panelOpen && !this.autocomplete.requireSelection) {\n        // Note that we don't reset this when `requireSelection` is enabled,\n        // because the option will be reset when the panel is closed.\n        const selectedOption = this.autocomplete.options?.find((option) => option.selected);\n\n        if (selectedOption) {\n          const display = this._getDisplayValue(selectedOption.value);\n\n          if (value !== display) {\n            selectedOption.deselect(false);\n          }\n        }\n      }\n\n      if (this._canOpen() && this._document.activeElement === event.target) {\n        // When the `input` event fires, the input's value will have already changed. This means\n        // that if we take the `this._element.nativeElement.value` directly, it'll be one keystroke\n        // behind. This can be a problem when the user selects a value, changes a character while\n        // the input still has focus and then clicks away (see #28432). To work around it, we\n        // capture the value in `keydown` so we can use it here.\n        const valueOnAttach = this._valueOnLastKeydown ?? this._element.nativeElement.value;\n        this._valueOnLastKeydown = null;\n        this._openPanelInternal(valueOnAttach);\n      }\n    }\n  }\n\n  /**\n   * Note: we use `focusin`, as opposed to `focus`, in order to open the panel\n   * a little earlier. This avoids issues where IE delays the focusing of the input.\n   */\n  _handleFocus(): void {\n    if (!this._canOpenOnNextFocus) {\n      this._canOpenOnNextFocus = true;\n    } else if (this._canOpen()) {\n      this._previousValue = this._element.nativeElement.value;\n      this._attachOverlay(this._previousValue);\n    }\n  }\n\n  _handleClick(): void {\n    if (this._canOpen() && !this.panelOpen) {\n      this._openPanelInternal();\n    }\n  }\n\n  /**\n   * Update width of the autocomplete panel.\n   */\n  _updateSize() {\n    this._overlayRef?.updateSize({ width: this._getPanelWidth() });\n  }\n\n  /**\n   * This method listens to a stream of panel closing actions and resets the\n   * stream every time the option list changes.\n   */\n  private _subscribeToClosingActions(): Subscription {\n    const initialRender = new Observable((subscriber) => {\n      afterNextRender(\n        () => {\n          if (!this._componentDestroyed) {\n            subscriber.next();\n          }\n        },\n        { injector: this._injector },\n      );\n    });\n    const optionChanges = this.autocomplete.options.changes.pipe(\n      tap(() => this._positionStrategy.reapplyLastPosition()),\n      // Defer emitting to the stream until the next tick, because changing\n      // bindings in here will cause \"changed after checked\" errors.\n      delay(0),\n    );\n\n    // When the options are initially rendered, and when the option list changes...\n    return (\n      merge(initialRender, optionChanges)\n        .pipe(\n          // create a new stream of panelClosingActions, replacing any previous streams\n          // that were created, and flatten it so our stream only emits closing events...\n          switchMap(() =>\n            this._zone.run(() => {\n              // `afterNextRender` always runs outside of the Angular zone, thus we have to re-enter\n              // the Angular zone. This will lead to change detection being called outside of the Angular\n              // zone and the `autocomplete.opened` will also emit outside of the Angular.\n              const wasOpen = this.panelOpen;\n              this._resetActiveItem();\n              this._updatePanelState();\n              this._changeDetectorRef.detectChanges();\n\n              if (this.panelOpen) {\n                // Fix to avoid scrolling to the top if a new element is added.\n                // This happens because our overlay has a dynamic height (different from @angular/material).\n                // When the _resetBoundingBoxStyles() function in the FlexibleConnectedPositionStrategy\n                // is called, the element is reset to full height and scaled back afterwards.\n                // During this the scroll position gets lost.\n                //\n                // An alternative to this hack would be to either use a maxHeight property for our\n                // overlay or to fix this in angular/components.\n                const scrollTop = this.autocomplete.panel.nativeElement.scrollTop;\n                this._overlayRef!.updatePosition();\n                this.autocomplete.panel.nativeElement.scrollTop = scrollTop;\n              }\n\n              if (wasOpen !== this.panelOpen) {\n                // If the `panelOpen` state changed, we need to make sure to emit the `opened` or\n                // `closed` event, because we may not have emitted it. This can happen\n                // - if the users opens the panel and there are no options, but the\n                //   options come in slightly later or as a result of the value changing,\n                // - if the panel is closed after the user entered a string that did not match any\n                //   of the available options,\n                // - if a valid string is entered after an invalid one.\n                if (this.panelOpen) {\n                  this._emitOpened();\n                } else {\n                  this.autocomplete.closed.emit();\n                }\n              }\n\n              return this.panelClosingActions;\n            }),\n          ),\n          // when the first closing event occurs...\n          take(1),\n        )\n        // set the value, close the panel, and complete.\n        .subscribe((event) => this._setValueAndClose(event))\n    );\n  }\n\n  /**\n   * Emits the opened event once it's known that the panel will be shown and stores\n   * the state of the trigger right before the opening sequence was finished.\n   */\n  private _emitOpened() {\n    this.autocomplete.opened.emit();\n  }\n\n  /** Destroys the autocomplete suggestion panel. */\n  private _destroyPanel(): void {\n    if (this._overlayRef) {\n      this.closePanel();\n      this._overlayRef.dispose();\n      this._overlayRef = null;\n    }\n  }\n\n  /** Given a value, returns the string that should be shown within the input. */\n  private _getDisplayValue<T>(value: T): T | string {\n    const autocomplete = this.autocomplete;\n    return autocomplete && autocomplete.displayWith ? autocomplete.displayWith(value) : value;\n  }\n\n  private _assignOptionValue(value: any): void {\n    const toDisplay = this._getDisplayValue(value);\n\n    if (value == null) {\n      this._clearPreviousSelectedOption(null, false);\n    }\n\n    // Simply falling back to an empty string if the display value is falsy does not work properly.\n    // The display value can also be the number zero and shouldn't fall back to an empty string.\n    this._updateNativeInputValue(toDisplay != null ? toDisplay : '');\n  }\n\n  private _updateNativeInputValue(value: string): void {\n    // We want to clear the previous selection if our new value is falsy. e.g: reactive form field\n    // being reset.\n    if (!value) {\n      this._clearPreviousSelectedOption(null, false);\n    }\n\n    // If it's used within a `SbbFormField`, we should set it through the property so it can go\n    // through change detection.\n    if (this._formField && this._formField._control) {\n      this._formField._control.value = value;\n    } else {\n      this._element.nativeElement.value = value;\n    }\n\n    this._previousValue = value;\n    this._inputValue.next(value);\n  }\n\n  /**\n   * This method closes the panel, and if a value is specified, also sets the associated\n   * control to that value. It will also mark the control as dirty if this interaction\n   * stemmed from the user.\n   */\n  private _setValueAndClose(event: SbbOptionSelectionChange | null): void {\n    const panel = this.autocomplete;\n    const toSelect = event ? event.source : this._pendingAutoselectedOption;\n\n    if (toSelect) {\n      this._clearPreviousSelectedOption(toSelect);\n      this._assignOptionValue(toSelect.value);\n      this._onChange(toSelect.value);\n      panel._emitSelectEvent(toSelect);\n      this._element.nativeElement.focus();\n    } else if (\n      panel.requireSelection &&\n      this._element.nativeElement.value !== this._valueOnAttach\n    ) {\n      this._clearPreviousSelectedOption(null);\n      this._assignOptionValue(null);\n      this._onChange(null);\n    }\n\n    this.closePanel();\n  }\n\n  /**\n   * Clear any previous selected option and emit a selection change event for this option.\n   */\n  private _clearPreviousSelectedOption(skip: SbbOption | null, emitEvent?: boolean) {\n    // Null checks are necessary here, because the autocomplete\n    // or its options may not have been assigned yet.\n    this.autocomplete?.options?.forEach((option) => {\n      if (option !== skip && option.selected) {\n        option.deselect(emitEvent);\n      }\n    });\n  }\n\n  private _openPanelInternal(valueOnAttach = this._element.nativeElement.value) {\n    this._attachOverlay(valueOnAttach);\n  }\n\n  private _attachOverlay(valueOnAttach: string): void {\n    if (!this.autocomplete && (typeof ngDevMode === 'undefined' || ngDevMode)) {\n      throw getSbbAutocompleteMissingPanelError();\n    }\n\n    let overlayRef = this._overlayRef;\n\n    if (!overlayRef) {\n      this._portal = new TemplatePortal(this.autocomplete.template, this._viewContainerRef, {\n        id: this._formField?.getLabelId(),\n      });\n      overlayRef = this._overlay.create(this._getOverlayConfig());\n      this._overlayRef = overlayRef;\n\n      if (this._positionStrategy) {\n        this._positionSubscription.unsubscribe();\n        this._positionSubscription = combineLatest([\n          this._positionStrategy.positionChanges,\n          this.autocomplete._showPanel,\n        ]).subscribe(([position, showPanel]) => {\n          if (this.autocomplete.panel && showPanel) {\n            this._getConnectedElement().nativeElement.classList.add('sbb-input-with-open-panel');\n\n            if (position.connectionPair.originY === 'top') {\n              this.autocomplete.panel.nativeElement.classList.add('sbb-panel-above');\n              this._getConnectedElement().nativeElement.classList.add(\n                'sbb-input-with-open-panel-above',\n              );\n            } else {\n              this.autocomplete.panel.nativeElement.classList.remove('sbb-panel-above');\n              this._getConnectedElement().nativeElement.classList.remove(\n                'sbb-input-with-open-panel-above',\n              );\n            }\n          }\n        });\n      }\n\n      this._viewportSubscription = this._viewportRuler.change().subscribe(() => {\n        if (this.panelOpen && overlayRef) {\n          overlayRef.updateSize({ width: this._getPanelWidth() });\n        }\n      });\n    } else {\n      // Update the trigger, panel width and direction, in case anything has changed.\n      this._positionStrategy.setOrigin(this._getConnectedElement());\n      overlayRef.updateSize({ width: this._getPanelWidth() });\n    }\n\n    if (overlayRef && !overlayRef.hasAttached()) {\n      overlayRef.attach(this._portal);\n      this._valueOnAttach = valueOnAttach;\n      this._valueOnLastKeydown = null;\n      this._closingActionsSubscription = this._subscribeToClosingActions();\n    }\n\n    const wasOpen = this.panelOpen;\n\n    this.autocomplete._isOpen = this._overlayAttached = true;\n    this._updatePanelState();\n    this._applyModalPanelOwnership();\n\n    // We need to do an extra `panelOpen` check in here, because the\n    // autocomplete won't be shown if there are no options.\n    if (this.panelOpen && wasOpen !== this.panelOpen) {\n      this._emitOpened();\n    }\n  }\n\n  /** Handles keyboard events coming from the overlay panel. */\n  private _handlePanelKeydown = (event: KeyboardEvent) => {\n    // Close when pressing ESCAPE or ALT + UP_ARROW, based on the a11y guidelines.\n    // See: https://www.w3.org/TR/wai-aria-practices-1.1/#textbox-keyboard-interaction\n    if (\n      (event.keyCode === ESCAPE && !hasModifierKey(event)) ||\n      (event.keyCode === UP_ARROW && hasModifierKey(event, 'altKey'))\n    ) {\n      // If the user had typed something in before we autoselected an option, and they decided\n      // to cancel the selection, restore the input value to the one they had typed in.\n      if (this._pendingAutoselectedOption) {\n        this._updateNativeInputValue(this._valueBeforeAutoSelection ?? '');\n        this._pendingAutoselectedOption = null;\n      }\n      this._closeKeyEventStream.next();\n      this._resetActiveItem();\n      // We need to stop propagation, otherwise the event will eventually\n      // reach the input itself and cause the overlay to be reopened.\n      event.stopPropagation();\n      event.preventDefault();\n    }\n  };\n\n  /** Updates the panel's visibility state and any trigger state tied to id. */\n  private _updatePanelState() {\n    this.autocomplete._setVisibility();\n\n    // Note that here we subscribe and unsubscribe based on the panel's visiblity state,\n    // because the act of subscribing will prevent events from reaching other overlays and\n    // we don't want to block the events if there are no options.\n    if (this.panelOpen) {\n      const overlayRef = this._overlayRef!;\n\n      if (!this._keydownSubscription) {\n        // Use the `keydownEvents` in order to take advantage of\n        // the overlay event targeting provided by the CDK overlay.\n        this._keydownSubscription = overlayRef.keydownEvents().subscribe(this._handlePanelKeydown);\n      }\n\n      if (!this._outsideClickSubscription) {\n        // Subscribe to the pointer events stream so that it doesn't get picked up by other overlays.\n        // TODO(crisbeto): we should switch `_getOutsideClickStream` eventually to use this stream,\n        // but the behvior isn't exactly the same and it ends up breaking some internal tests.\n        this._outsideClickSubscription = overlayRef.outsidePointerEvents().subscribe();\n      }\n    } else {\n      this._keydownSubscription?.unsubscribe();\n      this._outsideClickSubscription?.unsubscribe();\n      this._keydownSubscription = this._outsideClickSubscription = null;\n    }\n  }\n\n  private _getOverlayConfig(): OverlayConfig {\n    return new OverlayConfig({\n      positionStrategy: this._getOverlayPosition(),\n      scrollStrategy: this._scrollStrategy(),\n      width: this._getPanelWidth(),\n      panelClass: coerceStringArray(this._defaults?.overlayPanelClass).concat('sbb-overlay-panel'),\n      minHeight: 0, // Enables scrolling\n    });\n  }\n\n  private _getOverlayPosition(): PositionStrategy {\n    const strategy = this._overlay\n      .position()\n      .flexibleConnectedTo(this._getConnectedElement())\n      .withFlexibleDimensions(true)\n      .withPush(false);\n\n    this._setStrategyPositions(strategy);\n    this._positionStrategy = strategy;\n    return strategy;\n  }\n\n  /** Sets the positions on a position strategy based on the directive's input state. */\n  private _setStrategyPositions(positionStrategy: FlexibleConnectedPositionStrategy) {\n    // Note that we provide horizontal fallback positions, even though by default the dropdown\n    // width matches the input, because consumers can override the width. See #18854.\n    const belowPositions: ConnectedPosition[] = [\n      { originX: 'start', originY: 'bottom', overlayX: 'start', overlayY: 'top' },\n      { originX: 'end', originY: 'bottom', overlayX: 'end', overlayY: 'top' },\n    ];\n\n    // The overlay edge connected to the trigger should have squared corners, while\n    // the opposite end has rounded corners. We apply a CSS class to swap the\n    // border-radius based on the overlay position.\n    const panelClass = this._aboveClass;\n    const abovePositions: ConnectedPosition[] = [\n      { originX: 'start', originY: 'top', overlayX: 'start', overlayY: 'bottom', panelClass },\n      { originX: 'end', originY: 'top', overlayX: 'end', overlayY: 'bottom', panelClass },\n    ];\n\n    let positions: ConnectedPosition[];\n\n    if (this.position === 'above') {\n      positions = abovePositions;\n    } else if (this.position === 'below') {\n      positions = belowPositions;\n    } else {\n      positions = [...belowPositions, ...abovePositions];\n    }\n\n    positionStrategy.withPositions(positions);\n  }\n\n  private _getConnectedElement(): ElementRef<HTMLElement> {\n    if (this.connectedTo) {\n      return this.connectedTo.elementRef;\n    }\n\n    return this._formField ? this._formField.getConnectedOverlayOrigin() : this._element;\n  }\n\n  private _getPanelWidth(): number | string {\n    return this.autocomplete.panelWidth || this._getHostWidth();\n  }\n\n  /** Returns the width of the input element, so the panel width can match it. */\n  private _getHostWidth(): number {\n    return this._getConnectedElement().nativeElement.getBoundingClientRect().width;\n  }\n\n  /**\n   * Resets the active item to -1 so arrow events will activate the\n   * correct options, or to 0 if the consumer opted into it.\n   */\n  private _resetActiveItem(): void {\n    const autocomplete = this.autocomplete;\n\n    if (autocomplete.autoActiveFirstOption) {\n      // Note that we go through `setFirstItemActive`, rather than `setActiveItem(0)`, because\n      // the former will find the next enabled option, if the first one is disabled.\n      autocomplete._keyManager.setFirstItemActive();\n    } else {\n      autocomplete._keyManager.setActiveItem(-1);\n    }\n  }\n\n  /** Determines whether the panel can be opened. */\n  private _canOpen(): boolean {\n    const element = this._element.nativeElement;\n    return !element.readOnly && !element.disabled && !this.autocompleteDisabled;\n  }\n\n  /** Use defaultView of injected document if available or fallback to global window reference */\n  private _getWindow(): Window {\n    return this._document?.defaultView || window;\n  }\n\n  /** Scrolls to a particular option in the list. */\n  private _scrollToOption(index: number): void {\n    // Given that we are not actually focusing active options, we must manually adjust scroll\n    // to reveal options below the fold. First, we find the offset of the option from the top\n    // of the panel. If that offset is below the fold, the new scrollTop will be the offset -\n    // the panel height + the option height, so the active option will be just visible at the\n    // bottom of the panel. If that offset is above the top of the visible panel, the new scrollTop\n    // will become the offset. If that offset is visible within the panel already, the scrollTop is\n    // not adjusted.\n    const autocomplete = this.autocomplete;\n    const labelCount = countGroupLabelsBeforeOption(\n      index,\n      autocomplete.options,\n      autocomplete.optionGroups,\n    );\n\n    if (index === 0 && labelCount === 1) {\n      // If we've got one group label before the option and we're at the top option,\n      // scroll the list to the top. This is better UX than scrolling the list to the\n      // top of the option, because it allows the user to read the top group's label.\n      autocomplete._setScrollTop(0);\n    } else if (autocomplete.panel) {\n      const option = autocomplete.options.toArray()[index];\n\n      if (option) {\n        const element = option._getHostElement();\n        const newScrollPosition = getOptionScrollPosition(\n          element.offsetTop,\n          element.offsetHeight,\n          autocomplete._getScrollTop(),\n          autocomplete.panel.nativeElement.offsetHeight,\n        );\n\n        autocomplete._setScrollTop(newScrollPosition);\n      }\n    }\n  }\n\n  /**\n   * Track which modal we have modified the `aria-owns` attribute of. When the combobox trigger is\n   * inside an aria-modal, we apply aria-owns to the parent modal with the `id` of the options\n   * panel. Track the modal we have changed so we can undo the changes on destroy.\n   */\n  private _trackedModal: Element | null = null;\n\n  /**\n   * If the autocomplete trigger is inside of an `aria-modal` element, connect\n   * that modal to the options panel with `aria-owns`.\n   *\n   * For some browser + screen reader combinations, when navigation is inside\n   * of an `aria-modal` element, the screen reader treats everything outside\n   * of that modal as hidden or invisible.\n   *\n   * This causes a problem when the combobox trigger is _inside_ of a modal, because the\n   * options panel is rendered _outside_ of that modal, preventing screen reader navigation\n   * from reaching the panel.\n   *\n   * We can work around this issue by applying `aria-owns` to the modal with the `id` of\n   * the options panel. This effectively communicates to assistive technology that the\n   * options panel is part of the same interaction as the modal.\n   *\n   * At time of this writing, this issue is present in VoiceOver.\n   * See https://github.com/angular/components/issues/20694\n   */\n  private _applyModalPanelOwnership() {\n    // TODO(http://github.com/angular/components/issues/26853): consider de-duplicating this with\n    // the `LiveAnnouncer` and any other usages.\n    //\n    // Note that the selector here is limited to CDK overlays at the moment in order to reduce the\n    // section of the DOM we need to look through. This should cover all the cases we support, but\n    // the selector can be expanded if it turns out to be too narrow.\n    const modal = this._element.nativeElement.closest(\n      'body > .cdk-overlay-container [aria-modal=\"true\"]',\n    );\n\n    if (!modal) {\n      // Most commonly, the autocomplete trigger is not inside a modal.\n      return;\n    }\n\n    const panelId = this.autocomplete.id;\n\n    if (this._trackedModal) {\n      removeAriaReferencedId(this._trackedModal, 'aria-owns', panelId);\n    }\n\n    addAriaReferencedId(modal, 'aria-owns', panelId);\n    this._trackedModal = modal;\n  }\n\n  /** Clears the references to the listbox overlay element from the modal it was added to. */\n  private _clearFromModal() {\n    if (this._trackedModal) {\n      const panelId = this.autocomplete.id;\n\n      removeAriaReferencedId(this._trackedModal, 'aria-owns', panelId);\n      this._trackedModal = null;\n    }\n  }\n}\n","import { A11yModule } from '@angular/cdk/a11y';\nimport { OverlayModule } from '@angular/cdk/overlay';\nimport { NgModule } from '@angular/core';\nimport { SbbCommonModule, SbbOptionModule } from '@sbb-esta/angular/core';\n\nimport { SbbAutocomplete } from './autocomplete';\nimport { SbbAutocompleteOrigin } from './autocomplete-origin';\nimport { SbbAutocompleteTrigger } from './autocomplete-trigger';\n\n@NgModule({\n  imports: [\n    A11yModule,\n    OverlayModule,\n    SbbCommonModule,\n    SbbOptionModule,\n    SbbAutocomplete,\n    SbbAutocompleteOrigin,\n    SbbAutocompleteTrigger,\n  ],\n  exports: [\n    SbbOptionModule,\n    OverlayModule,\n    SbbAutocomplete,\n    SbbAutocompleteOrigin,\n    SbbAutocompleteTrigger,\n  ],\n})\nexport class SbbAutocompleteModule {}\n"],"names":["SbbAutocompleteSelectedEvent","source","option","constructor","SBB_AUTOCOMPLETE_DEFAULT_OPTIONS","InjectionToken","providedIn","factory","autoActiveFirstOption","autoSelectActiveOption","requireSelection","SbbAutocomplete","_changeDetectorRef","inject","ChangeDetectorRef","_elementRef","ElementRef","defaults","_activeOptionChanges","Subscription","EMPTY","_keyManager","showPanel","_showPanel","value","BehaviorSubject","isOpen","_isOpen","template","panel","options","optionGroups","hints","ariaLabel","ariaLabelledby","displayWith","localeNormalizer","panelWidth","optionSelected","EventEmitter","opened","closed","optionActivated","classList","_classList","nativeElement","className","showHintIfNoOptions","id","_IdGenerator","getId","inertGroups","platform","Platform","SAFARI","ngAfterContentInit","ActiveDescendantKeyManager","withWrap","change","subscribe","index","emit","toArray","_setVisibility","ngOnDestroy","unsubscribe","destroy","_setScrollTop","scrollTop","_getScrollTop","next","length","markForCheck","_emitSelectEvent","event","_getPanelAriaLabelledby","labelId","labelExpression","deps","target","i0","ɵɵFactoryTarget","Component","isStandalone","selector","inputs","booleanAttribute","outputs","host","classAttribute","providers","provide","SBB_OPTION_PARENT_COMPONENT","useExisting","queries","propertyName","predicate","SbbOption","SbbOptgroup","descendants","SbbOptionHint","viewQueries","first","TemplateRef","styles","changeDetection","ChangeDetectionStrategy","OnPush","encapsulation","ViewEncapsulation","None","decorators","exportAs","class","ViewChild","args","static","ContentChildren","Input","transform","Output","SbbAutocompleteOrigin","elementRef","Directive","ngImport","SBB_AUTOCOMPLETE_SCROLL_STRATEGY","injector","Injector","createRepositionScrollStrategy","getSbbAutocompleteMissingPanelError","Error","SbbAutocompleteTrigger","_element","_overlay","Overlay","_viewContainerRef","ViewContainerRef","_zone","NgZone","_formField","SBB_FORM_FIELD","optional","_document","DOCUMENT","_viewportRuler","ViewportRuler","_defaults","_overlayRef","_portal","_componentDestroyed","_scrollStrategy","_keydownSubscription","_outsideClickSubscription","_previousValue","_valueOnAttach","_valueOnLastKeydown","_positionStrategy","_closingActionsSubscription","_viewportSubscription","_positionSubscription","_highlightSubscription","_connectedElementClassSubscription","_inputValue","_canOpenOnNextFocus","_valueBeforeAutoSelection","_pendingAutoselectedOption","_closeKeyEventStream","Subject","_windowBlurHandler","activeElement","panelOpen","_onChange","_onTouched","autocomplete","_autocomplete","renderCallback","Observable","subscriber","afterNextRender","_injector","onReady","observableOf","pipe","switchMap","combineLatest","changes","startWith","filter","inputValue","forEach","_highlight","distinctUntilChanged","s","_getConnectedElement","remove","position","connectedTo","autocompleteAttribute","autocompleteDisabled","_initialized","_aboveClass","ngAfterViewInit","complete","window","_getWindow","runOutsideAngular","addEventListener","ngOnChanges","_setStrategyPositions","updatePosition","removeEventListener","_destroyPanel","_clearFromModal","_overlayAttached","openPanel","_openPanelInternal","closePanel","run","hasAttached","detach","_updatePanelState","detectChanges","panelClosingActions","merge","optionSelections","tabOut","_getOutsideClickStream","detachments","map","SbbOptionSelectionChange","defer","onSelectionChange","activeOption","activeItem","fromEvent","clickTarget","_getEventTarget","formField","customOrigin","contains","overlayElement","writeValue","Promise","resolve","then","_assignOptionValue","registerOnChange","fn","registerOnTouched","setDisabledState","isDisabled","disabled","_handleKeydown","keyCode","hasModifier","hasModifierKey","ESCAPE","preventDefault","ENTER","_selectViaInteraction","_resetActiveItem","prevActiveItem","isArrowKey","UP_ARROW","DOWN_ARROW","TAB","onKeydown","_canOpen","_scrollToOption","activeItemIndex","_handleInput","type","parseFloat","_clearPreviousSelectedOption","selectedOption","find","selected","display","_getDisplayValue","deselect","valueOnAttach","_handleFocus","_attachOverlay","_handleClick","_updateSize","updateSize","width","_getPanelWidth","_subscribeToClosingActions","initialRender","optionChanges","tap","reapplyLastPosition","delay","wasOpen","_emitOpened","take","_setValueAndClose","dispose","toDisplay","_updateNativeInputValue","_control","toSelect","focus","skip","emitEvent","ngDevMode","overlayRef","TemplatePortal","getLabelId","create","_getOverlayConfig","positionChanges","add","connectionPair","originY","setOrigin","attach","_applyModalPanelOwnership","_handlePanelKeydown","stopPropagation","keydownEvents","outsidePointerEvents","OverlayConfig","positionStrategy","_getOverlayPosition","scrollStrategy","panelClass","coerceStringArray","overlayPanelClass","concat","minHeight","strategy","flexibleConnectedTo","withFlexibleDimensions","withPush","belowPositions","originX","overlayX","overlayY","abovePositions","positions","withPositions","getConnectedOverlayOrigin","_getHostWidth","getBoundingClientRect","setFirstItemActive","setActiveItem","element","readOnly","defaultView","labelCount","countGroupLabelsBeforeOption","_getHostElement","newScrollPosition","getOptionScrollPosition","offsetTop","offsetHeight","_trackedModal","modal","closest","panelId","removeAriaReferencedId","addAriaReferencedId","listeners","properties","NG_VALUE_ACCESSOR","forwardRef","multi","usesOnChanges","alias","SbbAutocompleteModule","NgModule","ɵmod","ɵɵngDeclareNgModule","minVersion","version","A11yModule","OverlayModule","SbbCommonModule","SbbOptionModule","ɵinj","ɵɵngDeclareInjector","imports","exports"],"mappings":";;;;;;;;;;;;;;;;MA8BaA,4BAA4B,CAA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