{"version":3,"file":"scrolling.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/src/cdk-experimental/scrolling/auto-size-virtual-scroll.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/src/cdk-experimental/scrolling/scrolling-module.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 {coerceNumberProperty, NumberInput} from '@angular/cdk/coercion';\nimport {ListRange} from '@angular/cdk/collections';\nimport {\n  CdkVirtualScrollViewport,\n  VIRTUAL_SCROLL_STRATEGY,\n  VirtualScrollStrategy,\n} from '@angular/cdk/scrolling';\nimport {Directive, forwardRef, Input, OnChanges} from '@angular/core';\nimport {Observable} from 'rxjs';\n\n/**\n * A class that tracks the size of items that have been seen and uses it to estimate the average\n * item size.\n */\nexport class ItemSizeAverager {\n  /** The total amount of weight behind the current average. */\n  private _totalWeight = 0;\n\n  /** The current average item size. */\n  private _averageItemSize: number;\n\n  /** The default size to use for items when no data is available. */\n  private _defaultItemSize: number;\n\n  /** @param defaultItemSize The default size to use for items when no data is available. */\n  constructor(defaultItemSize = 50) {\n    this._defaultItemSize = defaultItemSize;\n    this._averageItemSize = defaultItemSize;\n  }\n\n  /** Returns the average item size. */\n  getAverageItemSize(): number {\n    return this._averageItemSize;\n  }\n\n  /**\n   * Adds a measurement sample for the estimator to consider.\n   * @param range The measured range.\n   * @param size The measured size of the given range in pixels.\n   */\n  addSample(range: ListRange, size: number) {\n    const newTotalWeight = this._totalWeight + range.end - range.start;\n    if (newTotalWeight) {\n      const newAverageItemSize =\n        (size + this._averageItemSize * this._totalWeight) / newTotalWeight;\n      if (newAverageItemSize) {\n        this._averageItemSize = newAverageItemSize;\n        this._totalWeight = newTotalWeight;\n      }\n    }\n  }\n\n  /** Resets the averager. */\n  reset() {\n    this._averageItemSize = this._defaultItemSize;\n    this._totalWeight = 0;\n  }\n}\n\n/** Virtual scrolling strategy for lists with items of unknown or dynamic size. */\nexport class AutoSizeVirtualScrollStrategy implements VirtualScrollStrategy {\n  /** @docs-private Implemented as part of VirtualScrollStrategy. */\n  scrolledIndexChange = new Observable<number>(() => {\n    // TODO(mmalerba): Implement.\n    if (typeof ngDevMode === 'undefined' || ngDevMode) {\n      throw Error(\n        'cdk-virtual-scroll: scrolledIndexChange is currently not supported for the' +\n          ' autosize scroll strategy',\n      );\n    }\n  });\n\n  /** The attached viewport. */\n  private _viewport: CdkVirtualScrollViewport | null = null;\n\n  /** The minimum amount of buffer rendered beyond the viewport (in pixels). */\n  private _minBufferPx: number;\n\n  /** The number of buffer items to render beyond the edge of the viewport (in pixels). */\n  private _maxBufferPx: number;\n\n  /** The estimator used to estimate the size of unseen items. */\n  private _averager: ItemSizeAverager;\n\n  /** The last measured scroll offset of the viewport. */\n  private _lastScrollOffset!: number;\n\n  /** The last measured size of the rendered content in the viewport. */\n  private _lastRenderedContentSize!: number;\n\n  /** The last measured size of the rendered content in the viewport. */\n  private _lastRenderedContentOffset!: number;\n\n  /**\n   * The number of consecutive cycles where removing extra items has failed. Failure here means that\n   * we estimated how many items we could safely remove, but our estimate turned out to be too much\n   * and it wasn't safe to remove that many elements.\n   */\n  private _removalFailures = 0;\n\n  /**\n   * @param minBufferPx The minimum amount of buffer rendered beyond the viewport (in pixels).\n   *     If the amount of buffer dips below this number, more items will be rendered.\n   * @param maxBufferPx The number of pixels worth of buffer to shoot for when rendering new items.\n   *     If the actual amount turns out to be less it will not necessarily trigger an additional\n   *     rendering cycle (as long as the amount of buffer is still greater than `minBufferPx`).\n   * @param averager The averager used to estimate the size of unseen items.\n   */\n  constructor(minBufferPx: number, maxBufferPx: number, averager = new ItemSizeAverager()) {\n    this._minBufferPx = minBufferPx;\n    this._maxBufferPx = maxBufferPx;\n    this._averager = averager;\n  }\n\n  /**\n   * Attaches this scroll strategy to a viewport.\n   * @param viewport The viewport to attach this strategy to.\n   */\n  attach(viewport: CdkVirtualScrollViewport) {\n    this._averager.reset();\n    this._viewport = viewport;\n    this._renderContentForCurrentOffset();\n  }\n\n  /** Detaches this scroll strategy from the currently attached viewport. */\n  detach() {\n    this._viewport = null;\n  }\n\n  /** @docs-private Implemented as part of VirtualScrollStrategy. */\n  onContentScrolled() {\n    if (this._viewport) {\n      this._updateRenderedContentAfterScroll();\n    }\n  }\n\n  /** @docs-private Implemented as part of VirtualScrollStrategy. */\n  onDataLengthChanged() {\n    if (this._viewport) {\n      this._renderContentForCurrentOffset();\n      this._checkRenderedContentSize();\n    }\n  }\n\n  /** @docs-private Implemented as part of VirtualScrollStrategy. */\n  onContentRendered() {\n    if (this._viewport) {\n      this._checkRenderedContentSize();\n    }\n  }\n\n  /** @docs-private Implemented as part of VirtualScrollStrategy. */\n  onRenderedOffsetChanged() {\n    if (this._viewport) {\n      this._checkRenderedContentOffset();\n    }\n  }\n\n  /** Scroll to the offset for the given index. */\n  scrollToIndex(): void {\n    if (typeof ngDevMode === 'undefined' || ngDevMode) {\n      // TODO(mmalerba): Implement.\n      throw Error(\n        'cdk-virtual-scroll: scrollToIndex is currently not supported for the autosize' +\n          ' scroll strategy',\n      );\n    }\n  }\n\n  /**\n   * Update the buffer parameters.\n   * @param minBufferPx The minimum amount of buffer rendered beyond the viewport (in pixels).\n   * @param maxBufferPx The number of buffer items to render beyond the edge of the viewport (in\n   *     pixels).\n   */\n  updateBufferSize(minBufferPx: number, maxBufferPx: number) {\n    if (maxBufferPx < minBufferPx) {\n      throw Error('CDK virtual scroll: maxBufferPx must be greater than or equal to minBufferPx');\n    }\n    this._minBufferPx = minBufferPx;\n    this._maxBufferPx = maxBufferPx;\n  }\n\n  /** Update the rendered content after the user scrolls. */\n  private _updateRenderedContentAfterScroll() {\n    const viewport = this._viewport!;\n\n    // The current scroll offset.\n    const scrollOffset = viewport.measureScrollOffset();\n    // The delta between the current scroll offset and the previously recorded scroll offset.\n    let scrollDelta = scrollOffset - this._lastScrollOffset;\n    // The magnitude of the scroll delta.\n    let scrollMagnitude = Math.abs(scrollDelta);\n\n    // The currently rendered range.\n    const renderedRange = viewport.getRenderedRange();\n\n    // If we're scrolling toward the top, we need to account for the fact that the predicted amount\n    // of content and the actual amount of scrollable space may differ. We address this by slowly\n    // correcting the difference on each scroll event.\n    let offsetCorrection = 0;\n    if (scrollDelta < 0) {\n      // The content offset we would expect based on the average item size.\n      const predictedOffset = renderedRange.start * this._averager.getAverageItemSize();\n      // The difference between the predicted size of the un-rendered content at the beginning and\n      // the actual available space to scroll over. We need to reduce this to zero by the time the\n      // user scrolls to the top.\n      // - 0 indicates that the predicted size and available space are the same.\n      // - A negative number that the predicted size is smaller than the available space.\n      // - A positive number indicates the predicted size is larger than the available space\n      const offsetDifference = predictedOffset - this._lastRenderedContentOffset;\n      // The amount of difference to correct during this scroll event. We calculate this as a\n      // percentage of the total difference based on the percentage of the distance toward the top\n      // that the user scrolled.\n      offsetCorrection = Math.round(\n        offsetDifference *\n          Math.max(0, Math.min(1, scrollMagnitude / (scrollOffset + scrollMagnitude))),\n      );\n\n      // Based on the offset correction above, we pretend that the scroll delta was bigger or\n      // smaller than it actually was, this way we can start to eliminate the difference.\n      scrollDelta = scrollDelta - offsetCorrection;\n      scrollMagnitude = Math.abs(scrollDelta);\n    }\n\n    // The current amount of buffer past the start of the viewport.\n    const startBuffer = this._lastScrollOffset - this._lastRenderedContentOffset;\n    // The current amount of buffer past the end of the viewport.\n    const endBuffer =\n      this._lastRenderedContentOffset +\n      this._lastRenderedContentSize -\n      (this._lastScrollOffset + viewport.getViewportSize());\n    // The amount of unfilled space that should be filled on the side the user is scrolling toward\n    // in order to safely absorb the scroll delta.\n    const underscan =\n      scrollMagnitude + this._minBufferPx - (scrollDelta < 0 ? startBuffer : endBuffer);\n\n    // Check if there's unfilled space that we need to render new elements to fill.\n    if (underscan > 0) {\n      // Check if the scroll magnitude was larger than the viewport size. In this case the user\n      // won't notice a discontinuity if we just jump to the new estimated position in the list.\n      // However, if the scroll magnitude is smaller than the viewport the user might notice some\n      // jitteriness if we just jump to the estimated position. Instead we make sure to scroll by\n      // the same number of pixels as the scroll magnitude.\n      if (scrollMagnitude >= viewport.getViewportSize()) {\n        this._renderContentForCurrentOffset();\n      } else {\n        // The number of new items to render on the side the user is scrolling towards. Rather than\n        // just filling the underscan space, we actually fill enough to have a buffer size of\n        // `maxBufferPx`. This gives us a little wiggle room in case our item size estimate is off.\n        const addItems = Math.max(\n          0,\n          Math.ceil(\n            (underscan - this._minBufferPx + this._maxBufferPx) /\n              this._averager.getAverageItemSize(),\n          ),\n        );\n        // The amount of filled space beyond what is necessary on the side the user is scrolling\n        // away from.\n        const overscan =\n          (scrollDelta < 0 ? endBuffer : startBuffer) - this._minBufferPx + scrollMagnitude;\n        // The number of currently rendered items to remove on the side the user is scrolling away\n        // from. If removal has failed in recent cycles we are less aggressive in how much we try to\n        // remove.\n        const unboundedRemoveItems = Math.floor(\n          overscan / this._averager.getAverageItemSize() / (this._removalFailures + 1),\n        );\n        const removeItems = Math.min(\n          renderedRange.end - renderedRange.start,\n          Math.max(0, unboundedRemoveItems),\n        );\n\n        // The new range we will tell the viewport to render. We first expand it to include the new\n        // items we want rendered, we then contract the opposite side to remove items we no longer\n        // want rendered.\n        const range = this._expandRange(\n          renderedRange,\n          scrollDelta < 0 ? addItems : 0,\n          scrollDelta > 0 ? addItems : 0,\n        );\n        if (scrollDelta < 0) {\n          range.end = Math.max(range.start + 1, range.end - removeItems);\n        } else {\n          range.start = Math.min(range.end - 1, range.start + removeItems);\n        }\n\n        // The new offset we want to set on the rendered content. To determine this we measure the\n        // number of pixels we removed and then adjust the offset to the start of the rendered\n        // content or to the end of the rendered content accordingly (whichever one doesn't require\n        // that the newly added items to be rendered to calculate.)\n        let contentOffset: number;\n        let contentOffsetTo: 'to-start' | 'to-end';\n        if (scrollDelta < 0) {\n          let removedSize = viewport.measureRangeSize({\n            start: range.end,\n            end: renderedRange.end,\n          });\n          // Check that we're not removing too much.\n          if (removedSize <= overscan) {\n            contentOffset =\n              this._lastRenderedContentOffset + this._lastRenderedContentSize - removedSize;\n            this._removalFailures = 0;\n          } else {\n            // If the removal is more than the overscan can absorb just undo it and record the fact\n            // that the removal failed so we can be less aggressive next time.\n            range.end = renderedRange.end;\n            contentOffset = this._lastRenderedContentOffset + this._lastRenderedContentSize;\n            this._removalFailures++;\n          }\n          contentOffsetTo = 'to-end';\n        } else {\n          const removedSize = viewport.measureRangeSize({\n            start: renderedRange.start,\n            end: range.start,\n          });\n          // Check that we're not removing too much.\n          if (removedSize <= overscan) {\n            contentOffset = this._lastRenderedContentOffset + removedSize;\n            this._removalFailures = 0;\n          } else {\n            // If the removal is more than the overscan can absorb just undo it and record the fact\n            // that the removal failed so we can be less aggressive next time.\n            range.start = renderedRange.start;\n            contentOffset = this._lastRenderedContentOffset;\n            this._removalFailures++;\n          }\n          contentOffsetTo = 'to-start';\n        }\n\n        // Set the range and offset we calculated above.\n        viewport.setRenderedRange(range);\n        viewport.setRenderedContentOffset(contentOffset + offsetCorrection, contentOffsetTo);\n      }\n    } else if (offsetCorrection) {\n      // Even if the rendered range didn't change, we may still need to adjust the content offset to\n      // simulate scrolling slightly slower or faster than the user actually scrolled.\n      viewport.setRenderedContentOffset(this._lastRenderedContentOffset + offsetCorrection);\n    }\n\n    // Save the scroll offset to be compared to the new value on the next scroll event.\n    this._lastScrollOffset = scrollOffset;\n  }\n\n  /**\n   * Checks the size of the currently rendered content and uses it to update the estimated item size\n   * and estimated total content size.\n   */\n  private _checkRenderedContentSize() {\n    const viewport = this._viewport!;\n    this._lastRenderedContentSize = viewport.measureRenderedContentSize();\n    this._averager.addSample(viewport.getRenderedRange(), this._lastRenderedContentSize);\n    this._updateTotalContentSize(this._lastRenderedContentSize);\n  }\n\n  /** Checks the currently rendered content offset and saves the value for later use. */\n  private _checkRenderedContentOffset() {\n    const viewport = this._viewport!;\n    this._lastRenderedContentOffset = viewport.getOffsetToRenderedContentStart()!;\n  }\n\n  /**\n   * Recalculates the rendered content based on our estimate of what should be shown at the current\n   * scroll offset.\n   */\n  private _renderContentForCurrentOffset() {\n    const viewport = this._viewport!;\n    const scrollOffset = viewport.measureScrollOffset();\n    this._lastScrollOffset = scrollOffset;\n    this._removalFailures = 0;\n\n    const itemSize = this._averager.getAverageItemSize();\n    const firstVisibleIndex = Math.min(\n      viewport.getDataLength() - 1,\n      Math.floor(scrollOffset / itemSize),\n    );\n    const bufferSize = Math.ceil(this._maxBufferPx / itemSize);\n    const range = this._expandRange(\n      this._getVisibleRangeForIndex(firstVisibleIndex),\n      bufferSize,\n      bufferSize,\n    );\n\n    viewport.setRenderedRange(range);\n    viewport.setRenderedContentOffset(itemSize * range.start);\n  }\n\n  // TODO: maybe move to base class, can probably share with fixed size strategy.\n  /**\n   * Gets the visible range of data for the given start index. If the start index is too close to\n   * the end of the list it may be backed up to ensure the estimated size of the range is enough to\n   * fill the viewport.\n   * Note: must not be called if `this._viewport` is null\n   * @param startIndex The index to start the range at\n   * @return a range estimated to be large enough to fill the viewport when rendered.\n   */\n  private _getVisibleRangeForIndex(startIndex: number): ListRange {\n    const viewport = this._viewport!;\n    const range: ListRange = {\n      start: startIndex,\n      end: startIndex + Math.ceil(viewport.getViewportSize() / this._averager.getAverageItemSize()),\n    };\n    const extra = range.end - viewport.getDataLength();\n    if (extra > 0) {\n      range.start = Math.max(0, range.start - extra);\n    }\n    return range;\n  }\n\n  // TODO: maybe move to base class, can probably share with fixed size strategy.\n  /**\n   * Expand the given range by the given amount in either direction.\n   * Note: must not be called if `this._viewport` is null\n   * @param range The range to expand\n   * @param expandStart The number of items to expand the start of the range by.\n   * @param expandEnd The number of items to expand the end of the range by.\n   * @return The expanded range.\n   */\n  private _expandRange(range: ListRange, expandStart: number, expandEnd: number): ListRange {\n    const viewport = this._viewport!;\n    const start = Math.max(0, range.start - expandStart);\n    const end = Math.min(viewport.getDataLength(), range.end + expandEnd);\n    return {start, end};\n  }\n\n  /** Update the viewport's total content size. */\n  private _updateTotalContentSize(renderedContentSize: number) {\n    const viewport = this._viewport!;\n    const renderedRange = viewport.getRenderedRange();\n    const totalSize =\n      renderedContentSize +\n      (viewport.getDataLength() - (renderedRange.end - renderedRange.start)) *\n        this._averager.getAverageItemSize();\n    viewport.setTotalContentSize(totalSize);\n  }\n}\n\n/**\n * Provider factory for `AutoSizeVirtualScrollStrategy` that simply extracts the already created\n * `AutoSizeVirtualScrollStrategy` from the given directive.\n * @param autoSizeDir The instance of `CdkAutoSizeVirtualScroll` to extract the\n *     `AutoSizeVirtualScrollStrategy` from.\n */\nexport function _autoSizeVirtualScrollStrategyFactory(autoSizeDir: CdkAutoSizeVirtualScroll) {\n  return autoSizeDir._scrollStrategy;\n}\n\n/** A virtual scroll strategy that supports unknown or dynamic size items. */\n@Directive({\n  selector: 'cdk-virtual-scroll-viewport[autosize]',\n  providers: [\n    {\n      provide: VIRTUAL_SCROLL_STRATEGY,\n      useFactory: _autoSizeVirtualScrollStrategyFactory,\n      deps: [forwardRef(() => CdkAutoSizeVirtualScroll)],\n    },\n  ],\n})\nexport class CdkAutoSizeVirtualScroll implements OnChanges {\n  /**\n   * The minimum amount of buffer rendered beyond the viewport (in pixels).\n   * If the amount of buffer dips below this number, more items will be rendered. Defaults to 100px.\n   */\n  @Input()\n  get minBufferPx(): number {\n    return this._minBufferPx;\n  }\n  set minBufferPx(value: NumberInput) {\n    this._minBufferPx = coerceNumberProperty(value);\n  }\n  _minBufferPx = 100;\n\n  /**\n   * The number of pixels worth of buffer to shoot for when rendering new items.\n   * If the actual amount turns out to be less it will not necessarily trigger an additional\n   * rendering cycle (as long as the amount of buffer is still greater than `minBufferPx`).\n   * Defaults to 200px.\n   */\n  @Input()\n  get maxBufferPx(): number {\n    return this._maxBufferPx;\n  }\n  set maxBufferPx(value: NumberInput) {\n    this._maxBufferPx = coerceNumberProperty(value);\n  }\n  _maxBufferPx = 200;\n\n  /** The scroll strategy used by this directive. */\n  _scrollStrategy = new AutoSizeVirtualScrollStrategy(this.minBufferPx, this.maxBufferPx);\n\n  ngOnChanges() {\n    this._scrollStrategy.updateBufferSize(this.minBufferPx, this.maxBufferPx);\n  }\n}\n","/**\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 {NgModule} from '@angular/core';\nimport {CdkAutoSizeVirtualScroll} from './auto-size-virtual-scroll';\n\n@NgModule({\n  imports: [CdkAutoSizeVirtualScroll],\n  exports: [CdkAutoSizeVirtualScroll],\n})\nexport class ScrollingModule {}\n"],"names":["ItemSizeAverager","_totalWeight","_averageItemSize","_defaultItemSize","constructor","defaultItemSize","getAverageItemSize","addSample","range","size","newTotalWeight","end","start","newAverageItemSize","reset","AutoSizeVirtualScrollStrategy","scrolledIndexChange","Observable","ngDevMode","Error","_viewport","_minBufferPx","_maxBufferPx","_averager","_lastScrollOffset","_lastRenderedContentSize","_lastRenderedContentOffset","_removalFailures","minBufferPx","maxBufferPx","averager","attach","viewport","_renderContentForCurrentOffset","detach","onContentScrolled","_updateRenderedContentAfterScroll","onDataLengthChanged","_checkRenderedContentSize","onContentRendered","onRenderedOffsetChanged","_checkRenderedContentOffset","scrollToIndex","updateBufferSize","scrollOffset","measureScrollOffset","scrollDelta","scrollMagnitude","Math","abs","renderedRange","getRenderedRange","offsetCorrection","predictedOffset","offsetDifference","round","max","min","startBuffer","endBuffer","getViewportSize","underscan","addItems","ceil","overscan","unboundedRemoveItems","floor","removeItems","_expandRange","contentOffset","contentOffsetTo","removedSize","measureRangeSize","setRenderedRange","setRenderedContentOffset","measureRenderedContentSize","_updateTotalContentSize","getOffsetToRenderedContentStart","itemSize","firstVisibleIndex","getDataLength","bufferSize","_getVisibleRangeForIndex","startIndex","extra","expandStart","expandEnd","renderedContentSize","totalSize","setTotalContentSize","_autoSizeVirtualScrollStrategyFactory","autoSizeDir","_scrollStrategy","CdkAutoSizeVirtualScroll","value","coerceNumberProperty","ngOnChanges","deps","target","i0","ɵɵFactoryTarget","Directive","ɵdir","ɵɵngDeclareDirective","minVersion","version","type","isStandalone","selector","inputs","providers","provide","VIRTUAL_SCROLL_STRATEGY","useFactory","forwardRef","usesOnChanges","ngImport","decorators","args","Input","ScrollingModule","NgModule","imports","exports"],"mappings":";;;;;;MAsBaA,gBAAgB,CAAA;AAEnBC,EAAAA,YAAY,GAAG,CAAC;EAGhBC,gBAAgB;EAGhBC,gBAAgB;AAGxBC,EAAAA,WAAAA,CAAYC,eAAe,GAAG,EAAE,EAAA;IAC9B,IAAI,CAACF,gBAAgB,GAAGE,eAAe;IACvC,IAAI,CAACH,gBAAgB,GAAGG,eAAe;AACzC,EAAA;AAGAC,EAAAA,kBAAkBA,GAAA;IAChB,OAAO,IAAI,CAACJ,gBAAgB;AAC9B,EAAA;AAOAK,EAAAA,SAASA,CAACC,KAAgB,EAAEC,IAAY,EAAA;AACtC,IAAA,MAAMC,cAAc,GAAG,IAAI,CAACT,YAAY,GAAGO,KAAK,CAACG,GAAG,GAAGH,KAAK,CAACI,KAAK;AAClE,IAAA,IAAIF,cAAc,EAAE;AAClB,MAAA,MAAMG,kBAAkB,GACtB,CAACJ,IAAI,GAAG,IAAI,CAACP,gBAAgB,GAAG,IAAI,CAACD,YAAY,IAAIS,cAAc;AACrE,MAAA,IAAIG,kBAAkB,EAAE;QACtB,IAAI,CAACX,gBAAgB,GAAGW,kBAAkB;QAC1C,IAAI,CAACZ,YAAY,GAAGS,cAAc;AACpC,MAAA;AACF,IAAA;AACF,EAAA;AAGAI,EAAAA,KAAKA,GAAA;AACH,IAAA,IAAI,CAACZ,gBAAgB,GAAG,IAAI,CAACC,gBAAgB;IAC7C,IAAI,CAACF,YAAY,GAAG,CAAC;AACvB,EAAA;AACD;MAGYc,6BAA6B,CAAA;AAExCC,EAAAA,mBAAmB,GAAG,IAAIC,UAAU,CAAS,MAAK;AAEhD,IAAA,IAAI,OAAOC,SAAS,KAAK,WAAW,IAAIA,SAAS,EAAE;AACjD,MAAA,MAAMC,KAAK,CACT,4E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