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B,OAAO;QAGT,IAAI,aAAa,IAAI,CAAC,UAAU;QAChC,IAAI,MAAM,WAAW,IAAI,CAAC,WAAW;QAErC,IAAI,YAAY,WAAW,OAAO,CAAC;QACnC,MAAM,UAAU,SAAS;QAEzB,MAAO,OAAO,KAAM;YAClB,IAAI,OAAO,WAAW,OAAO,CAAC;YAC9B,IAAI,KAAK,SAAS,EAAE;gBAClB,IAAI,YAAY,KAAK,SAAS,CAAC,KAAK,CAAC,GAAG,OAAO,MAAM;gBACrD,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAW,YAAY,GAC/C,OAAO,CAAA,GAAA,+DAAW,EAAE,CAAA,GAAA,gEAAY,EAAE,MAAM,IAAI,CAAC,UAAU,IAAI;YAE/D;YAEA,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC;QACpC;QAEA,OAAO;IACT;AACF","sources":["packages/@adobe/react-spectrum/src/card/BaseLayout.tsx"],"sourcesContent":["// @ts-nocheck\n/*\n * Copyright 2021 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Direction, Key, KeyboardDelegate, Node} from '@react-types/shared';\nimport {getChildNodes, getFirstItem} from 'react-stately/private/collections/getChildNodes';\nimport {GridCollection} from 'react-stately/private/grid/GridCollection';\nimport {InvalidationContext, Layout, LayoutInfo, Rect, Size} from 'react-stately/useVirtualizerState';\nimport {Scale} from '../provider/types';\n\nexport interface BaseLayoutOptions {\n  collator?: Intl.Collator,\n  // TODO: is this valid or is scale a spectrum specific thing that should be left out of the layouts?\n  scale?: Scale,\n  /**\n   * The margin around the grid view between the edges and the items.\n   * @default 24\n   */\n  margin?: number\n}\n\ninterface CardViewLayoutOptions {\n  isLoading: boolean,\n  direction: Direction\n}\n\nexport class BaseLayout<T> extends Layout<Node<T>, CardViewLayoutOptions> implements KeyboardDelegate {\n  protected contentSize: Size;\n  protected layoutInfos: Map<Key, LayoutInfo>;\n  protected collator: Intl.Collator;\n  protected lastCollection: GridCollection<T>;\n  collection:  GridCollection<T>;\n  isLoading: boolean;\n  disabledKeys: Set<Key> = new Set();\n  direction: Direction;\n  scale: Scale;\n  margin: number;\n\n  constructor(options: BaseLayoutOptions = {}) {\n    super();\n    this.layoutInfos = new Map();\n    this.collator = options.collator;\n    this.lastCollection = null;\n    this.scale = options.scale || 'medium';\n    this.margin = options.margin || 24;\n  }\n\n  update(invalidationContext: InvalidationContext<CardViewLayoutOptions>): void {\n    this.collection = this.virtualizer.collection as GridCollection<T>;\n    this.isLoading = invalidationContext.layoutOptions?.isLoading || false;\n    this.direction = invalidationContext.layoutOptions?.direction || 'ltr';\n    this.buildCollection(invalidationContext);\n\n    // Remove layout info that doesn't exist in new collection\n    if (this.lastCollection) {\n      for (let key of this.lastCollection.getKeys()) {\n        if (!this.collection.getItem(key)) {\n          this.layoutInfos.delete(key);\n        }\n      }\n\n      if (!this.isLoading) {\n        this.layoutInfos.delete('loader');\n      }\n\n      if (this.collection.size > 0) {\n        this.layoutInfos.delete('placeholder');\n      }\n    }\n\n    this.lastCollection = this.collection;\n  }\n\n  // eslint-disable-next-line @typescript-eslint/no-unused-vars\n  buildCollection(invalidationContext?: InvalidationContext): void {}\n\n  getContentSize(): number {\n    return this.contentSize;\n  }\n\n  getLayoutInfo(key: Key): LayoutInfo {\n    return this.layoutInfos.get(key)!;\n  }\n\n  getVisibleLayoutInfos(rect: Rect, excludePersistedKeys = false): LayoutInfo[] {\n    let res: LayoutInfo[] = [];\n\n    for (let layoutInfo of this.layoutInfos.values()) {\n      if (this.isVisible(layoutInfo, rect, excludePersistedKeys)) {\n        res.push(layoutInfo);\n      }\n    }\n\n    return res;\n  }\n\n  isVisible(layoutInfo: LayoutInfo, rect: Rect, excludePersistedKeys: boolean): boolean {\n    if (layoutInfo.rect.intersects(rect)) {\n      return true;\n    }\n\n    if (!excludePersistedKeys) {\n      return this.virtualizer.isPersistedKey(layoutInfo.key);\n    }\n\n    return false;\n  }\n\n  _findClosestLayoutInfo(target: Rect, rect: Rect): LayoutInfo | null {\n    let layoutInfos = this.getVisibleLayoutInfos(rect, true);\n    let best = null;\n    let bestDistance = Infinity;\n\n    // Calculates distance as the distance between the center of 2 rects.\n    for (let cur of layoutInfos) {\n      if (cur.type === 'item') {\n        let curRect = cur.rect;\n        let targetMidX = (target.x + target.maxX) / 2;\n        let targetMidY = (target.y + target.maxY) / 2;\n        let curMidX = (curRect.x + curRect.maxX) / 2;\n        let curMidY = (curRect.y + curRect.maxY) / 2;\n        let dist = Math.pow(targetMidX - curMidX, 2) + Math.pow(targetMidY - curMidY, 2);\n        if (dist < bestDistance) {\n          best = cur;\n          bestDistance = dist;\n        }\n      }\n    }\n\n    return best;\n  }\n\n  _findClosest(target: Rect, rect: Rect): LayoutInfo | null {\n    let best = this._findClosestLayoutInfo(target, rect);\n    return best || null;\n  }\n\n  getKeyBelow(key: Key): Node<T> | undefined {\n    // Expected key is the currently focused cell so we need the parent row key\n    let parentRowKey = this.collection.getItem(key).parentKey;\n    let layoutInfo = this.getLayoutInfo(parentRowKey);\n    let rect = new Rect(layoutInfo.rect.x, layoutInfo.rect.maxY + 1, layoutInfo.rect.width, this.virtualizer.visibleRect.height);\n    let closestRow = this.collection.getItem(this._findClosest(layoutInfo.rect, rect)?.key);\n    return getFirstItem(getChildNodes(closestRow, this.collection))?.key;\n  }\n\n  getKeyAbove(key: Key): Node<T> | undefined {\n    // Expected key is the currently focused cell so we need the parent row key\n    let parentRowKey = this.collection.getItem(key).parentKey;\n    let layoutInfo = this.getLayoutInfo(parentRowKey);\n    let rect = new Rect(layoutInfo.rect.x, 0, layoutInfo.rect.width, layoutInfo.rect.y - 1);\n    let closestRow = this.collection.getItem(this._findClosest(layoutInfo.rect, rect)?.key);\n    return getFirstItem(getChildNodes(closestRow, this.collection))?.key;\n  }\n\n  getKeyRightOf(key: Key): Node<T> | undefined {\n    // Expected key is the currently focused cell so we need the parent row key\n    let parentRowKey = this.collection.getItem(key).parentKey;\n    key = this.direction === 'rtl' ?  this.collection.getKeyBefore(parentRowKey) : this.collection.getKeyAfter(parentRowKey);\n\n    while (key != null) {\n      let item = this.collection.getItem(key);\n      // Don't check if item is disabled because we want to be able to focus disabled items in a grid (double check this)\n      if (item.type === 'item') {\n        return getFirstItem(getChildNodes(item, this.collection))?.key;\n      }\n      key = this.direction === 'rtl' ?  this.collection.getKeyBefore(key) : this.collection.getKeyAfter(key);\n    }\n  }\n\n  getKeyLeftOf(key: Key): Node<T> | undefined {\n    // Expected key is the currently focused cell so we need the parent row key\n    let parentRowKey = this.collection.getItem(key).parentKey;\n    key = this.direction === 'rtl' ?  this.collection.getKeyAfter(parentRowKey) : this.collection.getKeyBefore(parentRowKey);\n    while (key != null) {\n      let item = this.collection.getItem(key);\n      // Don't check if item is disabled because we want to be able to focus disabled items in a grid (double check this)\n      if (item.type === 'item') {\n        return getFirstItem(getChildNodes(item, this.collection))?.key;\n      }\n\n      key = this.direction === 'rtl' ?  this.collection.getKeyAfter(key) : this.collection.getKeyBefore(key);\n    }\n  }\n\n  getFirstKey(): Node<T> | undefined {\n    let firstRow = this.collection.getItem(this.collection.getFirstKey());\n    return getFirstItem(getChildNodes(firstRow, this.collection))?.key;\n  }\n\n  getLastKey(): Node<T> | undefined {\n    let lastRow = this.collection.getItem(this.collection.getLastKey());\n    return getFirstItem(getChildNodes(lastRow, this.collection))?.key;\n  }\n\n  // TODO: pretty unwieldy because it needs to bounce back and forth between the parent key and the child key\n  // Perhaps have layoutInfo store childKey as well so we don't need to do this? Or maybe make the layoutInfos be the cells instead of the rows?\n  getKeyPageAbove(key: Key): Node<T> | undefined {\n    // Expected key is the currently focused cell so we need the parent row key\n    let parentRowKey = this.collection.getItem(key).parentKey;\n    let layoutInfo = this.getLayoutInfo(parentRowKey);\n\n    if (layoutInfo) {\n      let pageY = Math.max(0, layoutInfo.rect.y + layoutInfo.rect.height - this.virtualizer.visibleRect.height);\n      // If the node is so large that it spans multiple page heights, return the key of the item immediately above\n      // Otherwise keep going up until we exceed a single page height worth of nodes\n      let keyAbove = this.collection.getItem(this.getKeyAbove(key))?.parentKey;\n      layoutInfo = this.getLayoutInfo(keyAbove);\n\n      if (layoutInfo && layoutInfo.rect.y > pageY) {\n        while (layoutInfo && layoutInfo.rect.y > pageY) {\n          let childKey = getFirstItem(getChildNodes(this.collection.getItem(layoutInfo.key), this.collection))?.key;\n          let keyAbove = this.collection.getItem(this.getKeyAbove(childKey))?.parentKey;\n          layoutInfo = this.getLayoutInfo(keyAbove);\n        }\n      }\n\n      if (layoutInfo) {\n        let childKey = getFirstItem(getChildNodes(this.collection.getItem(layoutInfo.key), this.collection))?.key;\n        return childKey;\n      }\n    }\n\n    return this.getFirstKey();\n  }\n\n  // TODO: pretty unwieldy because it needs to bounce back and forth between the parent key and the child key\n  // Perhaps have layoutInfo store childKey as well so we don't need to do this?\n  getKeyPageBelow(key: Key): Node<T> | undefined {\n    // Expected key is the currently focused cell so we need the parent row key\n    let parentRowKey = this.collection.getItem(key).parentKey;\n    let layoutInfo = this.getLayoutInfo(parentRowKey);\n    if (layoutInfo) {\n      let pageY = Math.min(this.virtualizer.contentSize.height, layoutInfo.rect.y - layoutInfo.rect.height + this.virtualizer.visibleRect.height);\n      // If the node is so large that it spans multiple page heights, return the key of the item immediately below\n      // Otherwise keep going up until we exceed a single page height worth of nodes\n      let keyBelow =  this.collection.getItem(this.getKeyBelow(key))?.parentKey;\n      layoutInfo = this.getLayoutInfo(keyBelow);\n      if (layoutInfo && layoutInfo.rect.y < pageY) {\n        while (layoutInfo && layoutInfo.rect.y < pageY) {\n          let childKey = getFirstItem(getChildNodes(this.collection.getItem(layoutInfo.key), this.collection))?.key;\n          let keyBelow = this.collection.getItem(this.getKeyBelow(childKey))?.parentKey;\n          layoutInfo = this.getLayoutInfo(keyBelow);\n        }\n      }\n\n      if (layoutInfo) {\n        let childKey = getFirstItem(getChildNodes(this.collection.getItem(layoutInfo.key), this.collection))?.key;\n        return childKey;\n      }\n    }\n\n    return this.getLastKey();\n  }\n\n  getKeyForSearch(search: string, fromKey?: Key): Node<T> | undefined | null {\n    if (!this.collator) {\n      return null;\n    }\n\n    let collection = this.collection;\n    let key = fromKey ?? this.getFirstKey();\n\n    let startItem = collection.getItem(key);\n    key = startItem.parentKey;\n\n    while (key != null) {\n      let item = collection.getItem(key);\n      if (item.textValue) {\n        let substring = item.textValue.slice(0, search.length);\n        if (this.collator.compare(substring, search) === 0) {\n          return getFirstItem(getChildNodes(item, this.collection))?.key;\n        }\n      }\n\n      key = this.collection.getKeyAfter(key);\n    }\n\n    return null;\n  }\n}\n"],"names":[],"version":3,"file":"BaseLayout.cjs.map"}