{"version":3,"file":"styloviz-core-layout.mjs","names":[],"sources":["../../../../projects/core/layout/element-size.ts","../../../../projects/core/layout/floating-layer.ts"],"sourcesContent":["import {\n  DestroyRef,\n  computed,\n  effect,\n  inject,\n  signal,\n  type Signal,\n} from '@angular/core';\n\n/**\n * ============================================================================\n *  One measurement primitive — `X-12`, and the Layout backlog's `X-4`/`N-8`\n * ============================================================================\n *\n * Every geometry consumer needs the same thing: *how big is this, and tell me\n * when it changes.* Anchor re-measures sections (`NV-02-M4`), Breadcrumb decides\n * how many crumbs fit (`NV-03-M4`), Tabs and Mega Menu decide whether to collapse\n * (`X-11`).\n *\n * ★ This is also the Layout & Utilities `X-4`/`N-8` measurement primitive. It is\n * consumed by Affix, Splitter, Scroll Area, Watermark, Number Ticker, Expand,\n * Toolbar and the navigation families, in place of the hand-rolled\n * `ResizeObserver`s each used to carry with its own answer to throttling,\n * teardown and what \"size\" means. `N-8` asks for a choice of box, hence the\n * `box` option below.\n *\n * ── ★ The border box, not the content box ──────────────────────────────────\n * The obvious source is `entry.contentRect`, and for an overflow decision it is\n * **wrong**: `contentRect` excludes padding and border, so a strip measured that\n * way under-reports by exactly its own padding. A tab list with `px-4` decides\n * six tabs fit in the space five occupy, renders them, and overflows — and the\n * error scales with the design, so it looks like a spacing bug rather than a\n * measurement one. `borderBoxSize` is what actually occupies space.\n *\n * ── ★ The first value does not wait for the observer ───────────────────────\n * `ResizeObserver` delivers its first entry asynchronously, so a component that\n * waited for it would render one frame with a size of zero — which for an\n * overflow decision means *\"nothing fits\"*, so the first paint of every\n * responsive strip would be its fully-collapsed form, expanding a frame later.\n *\n * So the element is measured directly, with `getBoundingClientRect`, **in the\n * same pass that starts observing it**. That pass is an `effect`, so it runs on\n * the first change detection rather than at construction — which is still before\n * the first paint, and is the point that matters.\n *\n * ── Throttled, because the observer is not ─────────────────────────────────\n * A drag or an animated panel produces many callbacks per frame. Emissions are\n * coalesced to one per animation frame, which is the finest granularity a layout\n * decision can actually use.\n *\n * ⚠️ **Do not resize the observed element from a reader of this signal.** That is\n * the classic `ResizeObserver loop completed with undelivered notifications`, and\n * no amount of throttling fixes it — a feedback loop measured once per frame is\n * still a feedback loop. Measure a container and size something *else*.\n */\n\n/** A size in CSS pixels — the border box unless `box: 'content-box'` was asked for. */\nexport interface SvSize {\n  readonly width: number;\n  readonly height: number;\n}\n\n/** Zero, and what every server render reports. */\nexport const SV_SIZE_ZERO: SvSize = { width: 0, height: 0 };\n\n/** Options for {@link svElementSize}. */\nexport interface SvElementSizeOptions {\n  /**\n   * Coalesce emissions to one per this many milliseconds instead of one per\n   * animation frame.\n   *\n   * A frame is the right default — it is the finest granularity a layout\n   * decision can use — but a consumer doing real work per measurement (a\n   * reflow, a re-render of many nodes) may want less.\n   */\n  readonly throttleMs?: number;\n\n  /**\n   * Construct the observer. The test adapter `X-12` asks for, and the SSR escape\n   * hatch: return `null` and nothing is observed.\n   *\n   * @default the platform `ResizeObserver`, or `null` where there is none\n   */\n  readonly observe?: (callback: ResizeObserverCallback) => ResizeObserver | null;\n\n  /**\n   * Which box to report (`N-8`).\n   *\n   * - `'border-box'` — content + padding + border: what the element OCCUPIES,\n   *   and the right answer for every overflow decision (see above).\n   * - `'content-box'` — the area children lay out in: the right answer when\n   *   sizing something that goes INSIDE the element (a canvas, a tile grid).\n   *\n   * @default 'border-box'\n   */\n  readonly box?: 'border-box' | 'content-box';\n}\n\n/** Parse a computed length, treating anything unreadable as zero. */\nfunction px(value: string | undefined): number {\n  const n = parseFloat(value ?? '');\n  return Number.isFinite(n) ? n : 0;\n}\n\n/**\n * Measure `el` now, directly, without waiting for an observer callback.\n *\n * ⚠️ Guarded, because the measuring `effect` also runs during prerender, where\n * the server DOM may hand back an element whose `getBoundingClientRect` is\n * missing or not a function. That element is reported at zero — the same\n * answer as \"no observer\" — rather than throwing out of change detection.\n */\nfunction measure(el: Element, box: 'border-box' | 'content-box'): SvSize {\n  if (typeof el.getBoundingClientRect !== 'function') return SV_SIZE_ZERO;\n  const rect = el.getBoundingClientRect();\n  const width = rect?.width ?? 0;\n  const height = rect?.height ?? 0;\n  if (box === 'border-box') return { width, height };\n\n  // content-box = border-box − padding − border, per axis.\n  const view = el.ownerDocument?.defaultView;\n  if (!view || typeof view.getComputedStyle !== 'function') return { width, height };\n  const cs = view.getComputedStyle(el);\n  const insetX =\n    px(cs.paddingLeft) + px(cs.paddingRight) + px(cs.borderLeftWidth) + px(cs.borderRightWidth);\n  const insetY =\n    px(cs.paddingTop) + px(cs.paddingBottom) + px(cs.borderTopWidth) + px(cs.borderBottomWidth);\n  return { width: Math.max(0, width - insetX), height: Math.max(0, height - insetY) };\n}\n\n/** The content-box size out of an entry. `contentRect` IS the content box. */\nfunction contentSizeOf(entry: ResizeObserverEntry): SvSize {\n  const box = entry.contentBoxSize?.[0];\n  if (box) return { width: box.inlineSize, height: box.blockSize };\n  return { width: entry.contentRect.width, height: entry.contentRect.height };\n}\n\n/** The border-box size out of an entry, falling back for older engines. */\nfunction sizeOf(entry: ResizeObserverEntry): SvSize {\n  const box = entry.borderBoxSize?.[0];\n  if (box) return { width: box.inlineSize, height: box.blockSize };\n  // ⚠️ `contentRect` is the fallback and NOT the preference — it excludes\n  //    padding and border, so an overflow decision made on it under-measures by\n  //    exactly the element's own padding. Only reached on an engine with no\n  //    `borderBoxSize`, where it is the best available answer.\n  return { width: entry.contentRect.width, height: entry.contentRect.height };\n}\n\nfunction defaultObserve(callback: ResizeObserverCallback): ResizeObserver | null {\n  if (typeof ResizeObserver === 'undefined') return null;\n  return new ResizeObserver(callback);\n}\n\n/**\n * The border-box size of an element (or its content box, with `box`), as a\n * signal that updates when it changes.\n *\n * Call it in a field initializer, inside an injection context; the observer is\n * disconnected with the component.\n *\n * ```ts\n * private readonly strip = viewChild<ElementRef<HTMLElement>>('strip');\n * protected readonly stripSize = svElementSize(() => this.strip()?.nativeElement ?? null);\n * protected readonly crowded = computed(() => this.stripSize().width < 480);\n * ```\n *\n * ★ **Returns `{ 0, 0 }` on the server**, and a component must render sensibly\n * at that size. Zero means \"nothing fits\", so a responsive strip should treat it\n * as *\"decide later\"* rather than as *\"collapse everything\"* — otherwise every\n * prerendered page ships its fully-collapsed form and expands on hydration.\n */\nexport function svElementSize(\n  // ⚠️ Not `Signal<Element | null> | (() => Element | null)`. A `Signal` IS\n  //    callable, so that union is entirely functions: TypeScript narrows the\n  //    non-function branch to `never` and `target()` stops type-checking. One\n  //    call signature covers both, because a signal satisfies it.\n  target: () => Element | null | undefined,\n  options: SvElementSizeOptions = {},\n): Signal<SvSize> {\n  const { throttleMs, observe = defaultObserve, box = 'border-box' } = options;\n  const read = box === 'content-box' ? contentSizeOf : sizeOf;\n\n  const size = signal<SvSize>(SV_SIZE_ZERO);\n\n  let observer: ResizeObserver | null = null;\n  let observed: Element | null = null;\n  let scheduled = false;\n  let timer: ReturnType<typeof setTimeout> | null = null;\n  let frame: number | null = null;\n\n  const publish = (next: SvSize): void => {\n    // `computed`-like: identical values do not wake anybody. A strip that is\n    // re-measured on every scroll of an unrelated container should cost nothing.\n    const current = size();\n    if (current.width === next.width && current.height === next.height) return;\n    size.set(next);\n  };\n\n  const flush = (entries: readonly ResizeObserverEntry[]): void => {\n    const last = entries[entries.length - 1];\n    if (last) publish(read(last));\n  };\n\n  /**\n   * The most recent entries seen during the current window.\n   *\n   * ★★ Held outside the callback on purpose. The obvious shape — capture\n   * `entries` in the closure the first time and flush that — **publishes the\n   * FIRST size of the burst and discards the rest**, so a drag that ends at 400px\n   * settles the signal on whatever it measured at the start. That is worse than\n   * not coalescing at all: it is not a delayed answer, it is a wrong one that\n   * never corrects. Found by the throttling test, which is why it asserts the\n   * final width rather than \"eventually something\".\n   */\n  let latest: readonly ResizeObserverEntry[] = [];\n\n  const onResize: ResizeObserverCallback = (entries) => {\n    latest = entries;\n    if (scheduled) return;\n    scheduled = true;\n\n    const run = (): void => {\n      scheduled = false;\n      frame = null;\n      timer = null;\n      flush(latest);\n    };\n\n    if (throttleMs !== undefined) timer = setTimeout(run, throttleMs);\n    else if (typeof requestAnimationFrame === 'function') frame = requestAnimationFrame(run);\n    else timer = setTimeout(run);\n  };\n\n  const stop = (): void => {\n    observer?.disconnect();\n    observer = null;\n    observed = null;\n    if (frame !== null && typeof cancelAnimationFrame === 'function') cancelAnimationFrame(frame);\n    if (timer !== null) clearTimeout(timer);\n    frame = null;\n    timer = null;\n    scheduled = false;\n  };\n\n  effect(() => {\n    const el = target();\n\n    if (!el) {\n      stop();\n      size.set(SV_SIZE_ZERO);\n      return;\n    }\n    if (el === observed) return;\n\n    stop();\n    observed = el;\n\n    // ★ Measured directly, before the observer has said anything — otherwise the\n    //   first frame reports zero, which an overflow decision reads as \"nothing\n    //   fits\".\n    publish(measure(el, box));\n\n    observer = observe(onResize);\n    observer?.observe(el, { box });\n  });\n\n  inject(DestroyRef).onDestroy(stop);\n\n  return computed(() => size());\n}\n","import {\n  DestroyRef,\n  Injectable,\n  computed,\n  effect,\n  inject,\n  signal,\n  untracked,\n  type Signal,\n} from '@angular/core';\nimport { svElementSize, type SvElementSizeOptions } from './element-size';\n\n/**\n * ============================================================================\n *  One owner for the screen's corners — `X-5` / `N-7`\n * ============================================================================\n *\n * Scroll to Top, Speed Dial and affixed blocks each solved *viewport* collision\n * on their own and none of them solved *each other*. A FAB and a scroll-to-top\n * button both default to `bottom-6 right-6`; on the same page they render on top\n * of one another, and the host's chat launcher or cookie banner joins them. No\n * single component can fix that, because \"who else is in this corner\" is a fact\n * about the page, not about the component.\n *\n * So the page gets one registry. Anything that occupies a corner or an edge —\n * a kit control, or **the host's own** chat widget, cookie banner or bottom nav —\n * registers a region (anchor + size), and each registrant reads back how far it\n * must sit from the edge so that it clears everything ranked before it.\n *\n * ★★★ STACKING RULE, IN ONE SENTENCE. Within one side of the screen, a region is\n *     pushed away from the edge by every region ranked before it that it can\n *     collide with: full-width EDGE regions (`'bottom'`, `'top'`) push every\n *     corner on their side, and CORNER regions push only their own corner.\n *     Rank is `order` (lower sits nearer the edge), then registration order.\n *\n * ★★ WHY FULL-WIDTH EDGES OUTRANK CORNERS. A cookie banner or a mobile bottom\n *    nav spans the whole edge, so there is no corner beside it for a FAB to use —\n *    the FAB has to sit on top of it. The reverse is never true.\n *\n * ★ A zero-height region takes no space and adds no gap. That is also what makes\n *   the manager an SSR no-op: every measurement on the server is zero (see\n *   `svElementSize`), so every offset there is zero and the server-rendered\n *   markup matches a page with no manager at all.\n *\n * ⚠️ Safe-area insets are NOT folded into the numeric offset. `env()` has no\n *   value in script — only in CSS — so the offset is px and the inset is added\n *   in the style string by `svFloatingInset()`. The two cannot drift.\n */\n\n/** A corner a floating control sits in, or a full-width edge a host bar spans. */\nexport type SvFloatingAnchor =\n  | 'bottom-right'\n  | 'bottom-left'\n  | 'bottom-center'\n  | 'top-right'\n  | 'top-left'\n  | 'top-center'\n  | 'bottom'\n  | 'top';\n\n/**\n * Where a region ranks within its side. Lower sits nearer the edge.\n *\n * ★ The kit's own defaults are spaced so a host can slot between them: a host\n *   chat launcher at `15` sits above a Speed Dial and below Scroll to Top.\n */\nexport const SV_FLOATING_ORDER = {\n  /** Full-width host bars — bottom navigation, cookie banner. */\n  edge: 0,\n  /** A Speed Dial / FAB: the primary action keeps the corner. */\n  fab: 10,\n  /** Scroll to Top: a utility, so it yields the corner to the FAB. */\n  scrollToTop: 20,\n  /** An affixed block. */\n  affix: 30,\n} as const;\n\n/**\n * z-index bands for floating page chrome.\n *\n * ★ All deliberately BELOW `SvOverlayStackService`'s interactive base (1000): a\n *   menu, drawer or dialog must always paint over a FAB, and a FAB's own menu is\n *   one of those surfaces. Raising any of these past 999 would bury overlays\n *   under page chrome.\n */\nexport const SV_FLOATING_Z = {\n  /**\n   * ★ 30, matching the `z-30` a pinned `<sv-affix>` has always painted with.\n   *   Lowering the shipped class to match a new constant could drop a pinned\n   *   header under host content a host had already layered at 21–29, so the\n   *   constant follows the component rather than the other way round.\n   */\n  affix: 30,\n  control: 50,\n  banner: 60,\n} as const;\n\n/** The CSS for each safe-area inset, with a zero fallback. */\nexport const SV_SAFE_AREA = {\n  top: 'env(safe-area-inset-top, 0px)',\n  right: 'env(safe-area-inset-right, 0px)',\n  bottom: 'env(safe-area-inset-bottom, 0px)',\n  left: 'env(safe-area-inset-left, 0px)',\n} as const;\n\n/** One side of the viewport. */\nexport type SvSafeAreaSide = keyof typeof SV_SAFE_AREA;\n\n/** What a registrant tells the manager about itself. */\nexport interface SvFloatingRegion {\n  /** Where it sits. */\n  readonly anchor: SvFloatingAnchor;\n  /** Its occupied width in CSS px. Informational; stacking uses height. @default 0 */\n  readonly width?: number;\n  /** Its occupied height in CSS px. `0` takes no space. @default 0 */\n  readonly height?: number;\n  /** Rank within its side; lower sits nearer the edge. @default SV_FLOATING_ORDER.edge for an edge, 0 for a corner */\n  readonly order?: number;\n  /** A name for diagnostics — `data-sv-floating` and `regions()`. */\n  readonly label?: string;\n}\n\n/** A registered region, as `regions()` reports it. */\nexport interface SvFloatingRegionState extends Required<Omit<SvFloatingRegion, 'label'>> {\n  readonly id: number;\n  readonly label: string;\n}\n\n/** The registration. Update it when the region resizes; release it when it leaves. */\nexport interface SvFloatingRegionHandle {\n  readonly id: number;\n  /** How far (px) this region must sit from its edge to clear everything ranked before it. */\n  readonly offset: Signal<number>;\n  /** Change the anchor, size or order. */\n  update(patch: Partial<SvFloatingRegion>): void;\n  /** Remove the region. Idempotent. */\n  release(): void;\n}\n\n/** The side a region stacks along. */\nfunction sideOf(anchor: SvFloatingAnchor): 'top' | 'bottom' {\n  return anchor.startsWith('top') ? 'top' : 'bottom';\n}\n\nfunction isEdge(anchor: SvFloatingAnchor): boolean {\n  return anchor === 'top' || anchor === 'bottom';\n}\n\n/**\n * The floating-layer registry. Root-scoped: one page, one set of corners.\n *\n * ```ts\n * // A host's own chat launcher, so kit controls in that corner clear it:\n * const chat = inject(SvFloatingLayerService).register({\n *   anchor: 'bottom-right', height: 64, order: 15, label: 'chat',\n * });\n * // …later: chat.update({ height: 480 }); chat.release();\n * ```\n */\n@Injectable({ providedIn: 'root' })\nexport class SvFloatingLayerService {\n  /** Gap (px) kept between two stacked regions. */\n  readonly gap = 12;\n\n  private readonly _regions = signal<readonly SvFloatingRegionState[]>([]);\n  private _nextId = 0;\n\n  /** Every registered region, in registration order. Diagnostics and tests. */\n  readonly regions: Signal<readonly SvFloatingRegionState[]> = this._regions.asReadonly();\n\n  /** Register an occupied region. Release the handle when it leaves the page. */\n  register(region: SvFloatingRegion): SvFloatingRegionHandle {\n    const id = this._nextId++;\n    this._regions.update((list) => [...list, this._normalise(id, region)]);\n\n    let released = false;\n    return {\n      id,\n      offset: computed(() => this._offsetOf(id)),\n      update: (patch) => {\n        if (released) return;\n        this._regions.update((list) =>\n          list.map((r) => (r.id === id ? this._normalise(id, { ...r, ...patch }) : r)),\n        );\n      },\n      release: () => {\n        if (released) return;\n        released = true;\n        this._regions.update((list) => list.filter((r) => r.id !== id));\n      },\n    };\n  }\n\n  /**\n   * The offset an UNREGISTERED element at `anchor` would need to clear every\n   * region there — for a host that wants to read the layout without joining it.\n   */\n  offsetAt(anchor: SvFloatingAnchor): number {\n    return this._sum(this._regions(), anchor, () => true);\n  }\n\n  /**\n   * The offset a region at `anchor` with rank `order` WOULD get if it\n   * registered now (ties rank it last) — for a block that only registers once\n   * it is on screen but must decide where to go before that, e.g. an affix\n   * about to pin. Reading it first avoids a one-frame jump on registration.\n   */\n  offsetFor(anchor: SvFloatingAnchor, order: number): number {\n    const self = isEdge(anchor);\n    return this._sum(this._regions(), anchor, (other) =>\n      (isEdge(other.anchor) && !self) || other.order <= order,\n    );\n  }\n\n  /** Test seam: forget every region. */\n  reset(): void {\n    this._regions.set([]);\n  }\n\n  private _normalise(id: number, region: SvFloatingRegion): SvFloatingRegionState {\n    const finite = (n: number | undefined): number =>\n      typeof n === 'number' && Number.isFinite(n) && n > 0 ? n : 0;\n    return {\n      id,\n      anchor: region.anchor,\n      width: finite(region.width),\n      height: finite(region.height),\n      order:\n        typeof region.order === 'number' && Number.isFinite(region.order)\n          ? region.order\n          : isEdge(region.anchor) ? SV_FLOATING_ORDER.edge : 0,\n      label: region.label ?? '',\n    };\n  }\n\n  private _offsetOf(id: number): number {\n    const list = this._regions();\n    const self = list.find((r) => r.id === id);\n    if (!self) return 0;\n    const selfIndex = list.indexOf(self);\n    return this._sum(list, self.anchor, (other) => {\n      if (other.id === id) return false;\n      // Edge regions push corners regardless of rank (see the class JSDoc).\n      if (isEdge(other.anchor) && !isEdge(self.anchor)) return true;\n      if (other.order !== self.order) return other.order < self.order;\n      return list.indexOf(other) < selfIndex;\n    });\n  }\n\n  /** Total height (+ gap) of the regions at `anchor`'s side it collides with and `before` admits. */\n  private _sum(\n    list: readonly SvFloatingRegionState[],\n    anchor: SvFloatingAnchor,\n    before: (other: SvFloatingRegionState) => boolean,\n  ): number {\n    const side = sideOf(anchor);\n    let total = 0;\n    for (const other of list) {\n      if (other.height === 0 || sideOf(other.anchor) !== side) continue;\n      // A corner only collides with its own corner and with the full-width edge.\n      const collides = isEdge(anchor) ? isEdge(other.anchor) : isEdge(other.anchor) || other.anchor === anchor;\n      if (collides && before(other)) total += other.height + this.gap;\n    }\n    return total;\n  }\n}\n\n/**\n * The CSS length for an inset from `side`: a base, the manager's offset, and the\n * device safe-area inset, in one `calc()`.\n *\n * ```html\n * <div class=\"fixed right-6\" [style.bottom]=\"inset()\"></div>\n * ```\n *\n * ★ `env()` resolves to 0 unless the page sets `viewport-fit=cover`, so on every\n *   ordinary page this equals `base + offset` exactly.\n */\nexport function svFloatingInset(side: SvSafeAreaSide, basePx: number, offsetPx = 0): string {\n  const px = (Number.isFinite(basePx) ? basePx : 0) + (Number.isFinite(offsetPx) ? offsetPx : 0);\n  return `calc(${px}px + ${SV_SAFE_AREA[side]})`;\n}\n\n/** Options for {@link svFloatingRegion}. */\nexport interface SvFloatingRegionOptions {\n  /** The corner or edge; `null` does not register (contained / demo / off). */\n  readonly anchor: () => SvFloatingAnchor | null;\n  /** The element whose border box is the occupied region. */\n  readonly element: () => Element | null | undefined;\n  /** Rank within the side — a number, or a getter (e.g. an input). @default 0 */\n  readonly order?: number | (() => number);\n  /** Diagnostics label. */\n  readonly label?: string;\n  /** Passed to `svElementSize` — the measurement test adapter. */\n  readonly observe?: SvElementSizeOptions['observe'];\n}\n\n/** What {@link svFloatingRegion} gives back. */\nexport interface SvFloatingRegionRef {\n  /** Distance (px) from the edge that clears everything ranked before this. `0` when unregistered. */\n  readonly offset: Signal<number>;\n  /** Whether the region is currently registered. */\n  readonly registered: Signal<boolean>;\n}\n\n/**\n * Register an element as an occupied floating region for as long as the\n * calling component lives. Call it in a field initializer (injection context).\n *\n * Measures with `svElementSize` (border box, rAF-throttled, zero on the server),\n * keeps the registration's size current, re-registers when the anchor changes,\n * and releases on destroy.\n */\nexport function svFloatingRegion(options: SvFloatingRegionOptions): SvFloatingRegionRef {\n  const layer = inject(SvFloatingLayerService);\n  const size = svElementSize(options.element, { observe: options.observe });\n\n  let handle: SvFloatingRegionHandle | null = null;\n  let anchorOf: SvFloatingAnchor | null = null;\n  const current = signal<SvFloatingRegionHandle | null>(null);\n\n  const release = (): void => {\n    handle?.release();\n    handle = null;\n    anchorOf = null;\n    current.set(null);\n  };\n\n  effect(() => {\n    const anchor = options.anchor();\n    const { width, height } = size();\n    const order = typeof options.order === 'function' ? options.order() : options.order;\n    // ★ Untracked: registering writes the registry, and the registry is what\n    //   every offset reads. Tracking it here would re-run this effect on every\n    //   OTHER region's resize.\n    untracked(() => {\n      if (!anchor) {\n        release();\n        return;\n      }\n      if (handle && anchorOf === anchor) {\n        handle.update({ width, height, order });\n        return;\n      }\n      release();\n      handle = layer.register({ anchor, width, height, order, label: options.label });\n      anchorOf = anchor;\n      current.set(handle);\n    });\n  });\n\n  inject(DestroyRef).onDestroy(release);\n\n  return {\n    offset: computed(() => current()?.offset() ?? 0),\n    registered: computed(() => current() !== null),\n  };\n}\n"],"mappings":";;AA+DA,MAAa,eAAuB;CAAE,OAAO;CAAG,QAAQ;AAAC;AAoCzD,SAAS,GAAG,OAAyB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