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AAC,GAAG,CAAC,YAAY,GAAG,EAAE;YACtC,IAAI,YAAY,IAAI,CAAC,IAAI;QAC3B;QAEA,IAAI,CAAC,WAAW,CAAC,MAAM,GAAG,IAAI,IAAI,CAAC,QAAQ;QAC3C,OAAO;IACT;IAEU,aAAa,IAAa,EAAE,CAAS,EAAE,CAAS,EAAc;QACtE,+CAA+C;QAC/C,IAAI,aAAa;YACf,MAAM;YACN,KAAK,KAAK,GAAG,GAAG;YAChB,WAAW,KAAK,GAAG;YACnB,OAAO;YACP,OAAO,KAAK,KAAK;YACjB,OAAO,KAAK,KAAK;YACjB,eAAe;YACf,YAAY,EAAE;YACd,UAAU,KAAK,QAAQ;YACvB,WAAW,KAAK,SAAS;QAC3B;QAEA,oEAAoE;QACpE,IAAI,SAAS,IAAI,CAAC,kBAAkB,CAAC,YAAY,GAAG;QACpD,OAAO,IAAI,GAAG;QACd,OAAO,UAAU,CAAC,SAAS,GAAG,KAAK,GAAG;QACtC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,WAAW,GAAG,EAAE;QACrC,KAAK,OAAO,UAAU,CAAC,IAAI,CAAC,MAAM;QAElC,IAAI,UAAU,KAAK,CAAC,aAAa,MAAM,GAAG;QAC1C,QAAQ,QAAQ,CAAE,OAAO,CAAC;QAC1B,OAAO;IACT;AACF","sources":["packages/@adobe/react-spectrum/src/listbox/ListBoxLayout.ts"],"sourcesContent":["import {\n  InvalidationContext,\n  LayoutInfo,\n  LayoutNode,\n  ListLayout,\n  ListLayoutOptions,\n  Rect\n} from 'react-stately/useVirtualizerState';\nimport {Node} from '@react-types/shared';\n\ninterface ListBoxLayoutProps extends ListLayoutOptions {\n  isLoading?: boolean;\n}\n\ninterface ListBoxLayoutOptions extends ListLayoutOptions {\n  placeholderHeight: number;\n  paddingY: number;\n}\n\nexport class ListBoxLayout<T> extends ListLayout<T, ListBoxLayoutProps> {\n  private isLoading: boolean = false;\n  private placeholderHeight: number;\n  private paddingY: number;\n\n  constructor(opts: ListBoxLayoutOptions) {\n    super(opts);\n    this.placeholderHeight = opts.placeholderHeight;\n    this.paddingY = opts.paddingY;\n  }\n\n  update(invalidationContext: InvalidationContext<ListBoxLayoutProps>): void {\n    this.isLoading = invalidationContext.layoutOptions?.isLoading || false;\n    super.update(invalidationContext);\n  }\n\n  protected buildCollection(): LayoutNode[] {\n    let nodes = super.buildCollection(this.paddingY);\n    let y = this.contentSize.height;\n\n    if (this.isLoading) {\n      let rect = new Rect(0, y, this.virtualizer!.visibleRect.width, 40);\n      let loader = new LayoutInfo('loader', 'loader', rect);\n      let node = {\n        layoutInfo: loader,\n        validRect: loader.rect\n      };\n      nodes.push(node);\n      this.layoutNodes.set(loader.key, node);\n      y = loader.rect.maxY;\n    }\n\n    if (nodes.length === 0) {\n      let rect = new Rect(\n        0,\n        y,\n        this.virtualizer!.visibleRect.width,\n        this.placeholderHeight ?? this.virtualizer!.visibleRect.height\n      );\n      let placeholder = new LayoutInfo('placeholder', 'placeholder', rect);\n      let node = {\n        layoutInfo: placeholder,\n        validRect: placeholder.rect\n      };\n      nodes.push(node);\n      this.layoutNodes.set(placeholder.key, node);\n      y = placeholder.rect.maxY;\n    }\n\n    this.contentSize.height = y + this.paddingY;\n    return nodes;\n  }\n\n  protected buildSection(node: Node<T>, x: number, y: number): LayoutNode {\n    // Synthesize a collection node for the header.\n    let headerNode = {\n      type: 'header',\n      key: node.key + ':header',\n      parentKey: node.key,\n      value: null,\n      level: node.level,\n      index: node.index,\n      hasChildNodes: false,\n      childNodes: [],\n      rendered: node.rendered,\n      textValue: node.textValue\n    };\n\n    // Build layout node for it and adjust y offset of section children.\n    let header = this.buildSectionHeader(headerNode, x, y);\n    header.node = headerNode;\n    header.layoutInfo.parentKey = node.key;\n    this.layoutNodes.set(headerNode.key, header);\n    y += header.layoutInfo.rect.height;\n\n    let section = super.buildSection(node, x, y);\n    section.children!.unshift(header);\n    return section;\n  }\n}\n"],"names":[],"version":3,"file":"ListBoxLayout.cjs.map"}