@tanstack/solid-router
Version:
Modern and scalable routing for Solid applications
1 lines • 31.1 kB
Source Map (JSON)
{"version":3,"file":"link.cjs","names":["<Link {...props} _asChild={Comp} />","_asChild={Comp}","<svg>\n <a {...svgLinkProps}>{children()}</a>\n </svg>","<a {...linkProps}>{children()}</a>","<Dynamic component={local._asChild as ValidComponent} {...linkProps}>\n {children()}\n </Dynamic>"],"sources":["../../src/link.tsx"],"sourcesContent":["import * as Solid from 'solid-js'\n\nimport {\n deepEqual,\n exactPathTest,\n functionalUpdate,\n hasKeys,\n isDangerousProtocol,\n preloadWarning,\n removeTrailingSlash,\n} from '@tanstack/router-core'\n\nimport { isServer } from '@tanstack/router-core/isServer'\nimport { Dynamic } from '@solidjs/web'\nimport { useRouter } from './useRouter'\n\nimport { useIntersectionObserver } from './utils'\n\nimport { useHydrated } from './ClientOnly'\nimport type {\n AnyRouter,\n Constrain,\n LinkOptions,\n RegisteredRouter,\n RoutePaths,\n} from '@tanstack/router-core'\nimport type {\n ValidateLinkOptions,\n ValidateLinkOptionsArray,\n} from './typePrimitives'\nimport type { ComponentProps, JSX, ValidComponent } from '@solidjs/web'\n\nfunction mergeRefs<T>(...refs: Array<unknown>): (el: T) => void {\n const setRef = (ref: unknown, el: T) => {\n if (typeof ref === 'function') {\n ref(el)\n } else if (Array.isArray(ref)) {\n for (const nestedRef of ref) {\n setRef(nestedRef, el)\n }\n }\n }\n\n return (el: T) => {\n for (const ref of refs) {\n setRef(ref, el)\n }\n }\n}\n\nfunction splitProps<T extends Record<string, any>, TKey extends keyof T>(\n props: T,\n keys: ReadonlyArray<TKey>,\n): [Pick<T, TKey>, Omit<T, TKey>] {\n const _local = {} as Pick<T, TKey>\n const _rest = {} as Omit<T, TKey>\n\n // A safe way to polyfill splitProps if native getter copy is too complex\n // is just to return [props, Solid.omit(props, keys)] but it modifies typing.\n // Actually, Solid.omit exists!\n // Note: Solid.omit uses rest params (...keys), so we must spread the array.\n return [props as any, Solid.omit(props, ...(keys as any)) as any]\n}\nconst timeoutMap = new WeakMap<object, ReturnType<typeof setTimeout>>()\nconst cancelPreload = (eventTarget: object) => {\n clearTimeout(timeoutMap.get(eventTarget))\n timeoutMap.delete(eventTarget)\n}\n\nexport function useLinkProps<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends RoutePaths<TRouter['routeTree']> | string = string,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom,\n TMaskTo extends string = '',\n>(\n options: UseLinkPropsOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n): ComponentProps<'a'> {\n const router = useRouter()\n const shouldHydrateHash = !isServer && !!router.options.ssr\n const hasHydrated = useHydrated()\n\n let hasRenderFetched = false\n\n // Defaults are resolved through accessors at the use sites instead of\n // merging them into the props. Every merge/omit proxy layered here gets\n // re-enumerated by spread() on each navigation, and V8 dispatches proxy\n // traps in native runtime code — keeping this path proxy-free is what\n // keeps Link updates cheap.\n const local = options\n const activeProps = () => local.activeProps ?? STATIC_ACTIVE_PROPS_GET\n const inactiveProps = () => local.inactiveProps ?? STATIC_INACTIVE_PROPS_GET\n\n const propsSafeToSpread = Solid.omit(\n options as Record<string, any>,\n 'activeProps',\n 'inactiveProps',\n 'activeOptions',\n 'to',\n 'preload',\n 'preloadDelay',\n 'preloadIntentProximity',\n 'hashScrollIntoView',\n 'replace',\n 'startTransition',\n 'resetScroll',\n 'viewTransition',\n 'target',\n 'disabled',\n 'style',\n 'class',\n 'onClick',\n 'onBlur',\n 'onFocus',\n 'onMouseEnter',\n 'onMouseLeave',\n 'onMouseOver',\n 'onMouseOut',\n 'onTouchStart',\n 'ignoreBlocker',\n 'params',\n 'search',\n 'hash',\n 'state',\n 'mask',\n 'reloadDocument',\n 'unsafeRelative',\n 'from',\n )\n\n const currentLocation = Solid.createMemo(() => router.stores.location.get(), {\n equals: (prev, next) => prev.href === next.href,\n })\n\n const _options = () => options\n\n const next = Solid.createMemo(\n () => {\n // Rebuild when inherited search/hash or the current route context changes.\n const _fromLocation = currentLocation()\n const options = { _fromLocation, ..._options() } as any\n // untrack because router-core will also access stores, which are signals in solid\n return Solid.untrack(() => router.buildLocation(options))\n },\n {\n lazy: true,\n // Navigations usually leave most links' built locations unchanged;\n // comparing hrefs lets downstream memos (href, isActive) skip work.\n equals: (prev, next) =>\n prev.href === next.href &&\n prev.external === next.external &&\n prev.maskedLocation?.href === next.maskedLocation?.href,\n },\n )\n\n const hrefOption = Solid.createMemo(\n () => {\n if (_options().disabled) return undefined\n // Use publicHref - it contains the correct href for display\n // When a rewrite changes the origin, publicHref is the full URL\n // Otherwise it's the origin-stripped path\n // This avoids constructing URL objects in the hot path\n const location = next().maskedLocation ?? next()\n const publicHref = location.publicHref\n const external = location.external\n\n if (external) {\n return { href: publicHref, external: true }\n }\n\n return {\n href: router.history.createHref(publicHref) || '/',\n external: false,\n }\n },\n { lazy: true },\n )\n\n const externalLink = Solid.createMemo(\n () => {\n const _href = hrefOption()\n if (_href?.external) {\n // Block dangerous protocols for external links\n if (isDangerousProtocol(_href.href, router.protocolAllowlist)) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`Blocked Link with dangerous protocol: ${_href.href}`)\n }\n return undefined\n }\n return _href.href\n }\n const to = _options().to\n const safeInternal = isSafeInternal(to)\n if (safeInternal) return undefined\n if (typeof to !== 'string' || to.indexOf(':') === -1) return undefined\n try {\n new URL(to as any)\n // Block dangerous protocols like javascript:, blob:, data:\n if (isDangerousProtocol(to, router.protocolAllowlist)) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`Blocked Link with dangerous protocol: ${to}`)\n }\n return undefined\n }\n return to\n } catch {}\n return undefined\n },\n { lazy: true },\n )\n\n const preload = Solid.createMemo(\n () => {\n if (_options().reloadDocument || externalLink() || local.disabled) {\n return false\n }\n return local.preload ?? router.options.defaultPreload\n },\n { lazy: true },\n )\n const preloadDelay = () =>\n local.preloadDelay ?? router.options.defaultPreloadDelay ?? 0\n\n const isActive = Solid.createMemo(\n () => {\n if (externalLink()) return false\n const activeOptions = local.activeOptions\n const current = currentLocation()\n const nextLocation = next()\n\n if (activeOptions?.exact) {\n const testExact = exactPathTest(\n current.pathname,\n nextLocation.pathname,\n router.basepath,\n )\n if (!testExact) {\n return false\n }\n } else {\n const currentPath = removeTrailingSlash(\n current.pathname,\n router.basepath,\n )\n const nextPath = removeTrailingSlash(\n nextLocation.pathname,\n router.basepath,\n )\n\n const pathIsFuzzyEqual =\n currentPath.startsWith(nextPath) &&\n (currentPath.length === nextPath.length ||\n currentPath[nextPath.length] === '/')\n if (!pathIsFuzzyEqual) {\n return false\n }\n }\n\n if (activeOptions?.includeSearch ?? true) {\n const searchTest = deepEqual(current.search, nextLocation.search, {\n partial: !activeOptions?.exact,\n ignoreUndefined: !activeOptions?.explicitUndefined,\n })\n if (!searchTest) {\n return false\n }\n }\n\n if (activeOptions?.includeHash) {\n const currentHash =\n shouldHydrateHash && !hasHydrated() ? '' : current.hash\n return currentHash === nextLocation.hash\n }\n return true\n },\n { lazy: true },\n )\n\n const doPreload = () =>\n router\n .preloadRoute({ ...options, _builtLocation: next() } as any)\n .catch((err: any) => {\n console.warn(err)\n console.warn(preloadWarning)\n })\n\n const [ref, setRefSignal] = Solid.createSignal<Element | null>(null)\n\n const setRef = (el: Element | null) => {\n Solid.runWithOwner(null, () => {\n setRefSignal(el)\n })\n }\n\n const enqueuePreload = (\n e?: MouseEvent | FocusEvent | IntersectionObserverEntry,\n ) => {\n if (!e) {\n cancelPreload(ref)\n return\n }\n\n if (\n !(\n (e as IntersectionObserverEntry).isIntersecting ??\n preload() === 'intent'\n )\n ) {\n if ((e as IntersectionObserverEntry).isIntersecting === false) {\n cancelPreload(ref)\n }\n return\n }\n\n if (!preloadDelay()) {\n doPreload()\n return\n }\n\n if (!timeoutMap.has(ref)) {\n timeoutMap.set(\n ref,\n setTimeout(() => {\n timeoutMap.delete(ref)\n doPreload()\n }, preloadDelay()),\n )\n }\n }\n\n useIntersectionObserver(ref, enqueuePreload, () => preload() !== 'viewport')\n\n Solid.createEffect(preload, (preloadValue) => {\n if (hasRenderFetched) {\n return\n }\n if (preloadValue === 'render') {\n Solid.untrack(() => doPreload())\n hasRenderFetched = true\n }\n })\n\n if (Solid.untrack(externalLink)) {\n const externalHref = Solid.untrack(externalLink)\n return Solid.merge(\n propsSafeToSpread,\n {\n ref: mergeRefs(setRef, options.ref),\n href: externalHref,\n },\n splitProps(local, [\n 'target',\n 'disabled',\n 'style',\n 'class',\n 'onClick',\n 'onBlur',\n 'onFocus',\n 'onMouseEnter',\n 'onMouseLeave',\n 'onMouseOut',\n 'onMouseOver',\n 'onTouchStart',\n ])[0],\n ) as any\n }\n\n // The click handler\n const handleClick = (e: MouseEvent) => {\n // Check actual element's target attribute as fallback\n const elementTarget = (\n e.currentTarget as HTMLAnchorElement | SVGAElement\n ).getAttribute('target')\n const effectiveTarget =\n local.target !== undefined ? local.target : elementTarget\n\n if (\n !local.disabled &&\n !isCtrlEvent(e) &&\n !e.defaultPrevented &&\n (!effectiveTarget || effectiveTarget === '_self') &&\n e.button === 0\n ) {\n e.preventDefault()\n\n // All is well? Navigate!\n // N.B. we don't call `router.commitLocation(next) here because we want to run `validateSearch` before committing\n router.navigate({\n ...options,\n replace: local.replace,\n resetScroll: local.resetScroll,\n hashScrollIntoView: local.hashScrollIntoView,\n startTransition: local.startTransition,\n viewTransition: local.viewTransition,\n ignoreBlocker: local.ignoreBlocker,\n })\n }\n }\n\n const handleTouchStart = () => {\n if (preload() !== 'intent') return\n doPreload()\n }\n\n const handleLeave = () => {\n if (preload() === 'intent') {\n cancelPreload(ref)\n }\n }\n\n const simpleStyling = Solid.createMemo(\n () =>\n activeProps() === STATIC_ACTIVE_PROPS_GET &&\n inactiveProps() === STATIC_INACTIVE_PROPS_GET &&\n local.class === undefined &&\n local.style === undefined,\n { lazy: true },\n )\n\n const onClick = createComposedHandler(() => local.onClick, handleClick)\n const onBlur = createComposedHandler(() => local.onBlur, handleLeave)\n const onFocus = createComposedHandler(() => local.onFocus, enqueuePreload)\n const onMouseEnter = createComposedHandler(\n () => local.onMouseEnter,\n enqueuePreload,\n )\n const onMouseOver = createComposedHandler(\n () => local.onMouseOver,\n enqueuePreload,\n )\n const onMouseLeave = createComposedHandler(\n () => local.onMouseLeave,\n handleLeave,\n )\n const onMouseOut = createComposedHandler(() => local.onMouseOut, handleLeave)\n const onTouchStart = createComposedHandler(\n () => local.onTouchStart,\n handleTouchStart,\n )\n\n type ResolvedLinkStateProps = Omit<ComponentProps<'a'>, 'style'> & {\n style?: JSX.CSSProperties\n }\n\n const resolvedStateProps = Solid.createMemo(\n (): ResolvedLinkStateProps =>\n (isActive()\n ? functionalUpdate(activeProps() as any, {})\n : functionalUpdate(inactiveProps(), {})) ?? EMPTY_OBJECT,\n { lazy: true },\n )\n\n const resolvedClass = Solid.createMemo(\n () => {\n if (simpleStyling()) return isActive() ? 'active' : undefined\n return (\n [local.class, resolvedStateProps().class].filter(Boolean).join(' ') ||\n undefined\n )\n },\n { lazy: true },\n )\n\n const resolvedStyle = Solid.createMemo(\n () => {\n if (simpleStyling()) return local.style\n const style = { ...local.style, ...resolvedStateProps().style }\n return hasKeys(style) ? style : undefined\n },\n { lazy: true },\n )\n\n // The returned object must be a plain object with a stable key set so the\n // consuming spread() never enumerates through proxy traps. Reactivity lives\n // in the property getters; values that no longer apply resolve to undefined,\n // which spread()/assign() treats as attribute removal. Keys returned by\n // activeProps/inactiveProps are discovered once at setup.\n const extraStateKeys = new Set<string>()\n Solid.untrack(() => {\n for (const stateProps of [\n functionalUpdate(activeProps() as any, {}),\n functionalUpdate(inactiveProps(), {}),\n ]) {\n if (stateProps) {\n for (const key of Object.keys(stateProps)) {\n if (key !== 'class' && key !== 'style') extraStateKeys.add(key)\n }\n }\n }\n })\n\n const composedRef = mergeRefs(setRef, (el: Element) => {\n const r = _options().ref as any\n if (typeof r === 'function') r(el)\n })\n\n const linkProps: Record<string, any> = {}\n for (const key of Object.keys(propsSafeToSpread)) {\n Object.defineProperty(\n linkProps,\n key,\n Object.getOwnPropertyDescriptor(propsSafeToSpread, key)!,\n )\n }\n for (const key of extraStateKeys) {\n Object.defineProperty(linkProps, key, {\n get: () => (resolvedStateProps() as Record<string, any>)[key],\n enumerable: true,\n configurable: true,\n })\n }\n\n const defineGetters = (getters: Record<string, () => any>) => {\n for (const key of Object.keys(getters)) {\n Object.defineProperty(linkProps, key, {\n get: getters[key],\n enumerable: true,\n configurable: true,\n })\n }\n }\n\n linkProps.ref = composedRef\n linkProps.onClick = onClick\n linkProps.onBlur = onBlur\n linkProps.onFocus = onFocus\n linkProps.onMouseEnter = onMouseEnter\n linkProps.onMouseOver = onMouseOver\n linkProps.onMouseLeave = onMouseLeave\n linkProps.onMouseOut = onMouseOut\n linkProps.onTouchStart = onTouchStart\n\n defineGetters({\n href: () => hrefOption()?.href,\n disabled: () => !!local.disabled,\n target: () => local.target,\n role: () => (local.disabled ? 'link' : undefined),\n 'aria-disabled': () => (local.disabled ? 'true' : undefined),\n 'data-status': () => (isActive() ? 'active' : undefined),\n 'aria-current': () => (isActive() ? 'page' : undefined),\n class: resolvedClass,\n style: resolvedStyle,\n })\n\n return linkProps as any\n}\n\nconst STATIC_ACTIVE_PROPS = { class: 'active' }\nconst STATIC_ACTIVE_PROPS_GET = () => STATIC_ACTIVE_PROPS\nconst EMPTY_OBJECT = {}\nconst STATIC_INACTIVE_PROPS_GET = () => EMPTY_OBJECT\n\n/** Call a JSX.EventHandlerUnion with the event. */\nfunction callHandler<T, TEvent extends Event>(\n event: TEvent & { currentTarget: T; target: Element },\n handler: JSX.EventHandlerUnion<T, TEvent>,\n) {\n if (typeof handler === 'function') {\n handler(event)\n } else {\n handler[0](handler[1], event)\n }\n return event.defaultPrevented\n}\n\nfunction createComposedHandler<T, TEvent extends Event>(\n getHandler: () => JSX.EventHandlerUnion<T, TEvent> | undefined,\n fallback: (event: TEvent) => void,\n) {\n return (event: TEvent & { currentTarget: T; target: Element }) => {\n const handler = getHandler()\n if (!handler || !callHandler(event, handler)) fallback(event)\n }\n}\n\nexport type UseLinkPropsOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends RoutePaths<TRouter['routeTree']> | string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom,\n TMaskTo extends string = '.',\n> = ActiveLinkOptions<'a', TRouter, TFrom, TTo, TMaskFrom, TMaskTo> &\n Omit<ComponentProps<'a'>, 'style'> & { style?: JSX.CSSProperties }\n\nexport type ActiveLinkOptions<\n TComp = 'a',\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '.',\n> = LinkOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> &\n ActiveLinkOptionProps<TComp>\n\ntype ActiveLinkProps<TComp> = Partial<\n LinkComponentSolidProps<TComp> & {\n [key: `data-${string}`]: unknown\n }\n>\n\nexport interface ActiveLinkOptionProps<TComp = 'a'> {\n /**\n * A function that returns additional props for the `active` state of this link.\n * These props override other props passed to the link (`style`'s are merged, `class`'s are concatenated)\n */\n activeProps?: ActiveLinkProps<TComp> | (() => ActiveLinkProps<TComp>)\n /**\n * A function that returns additional props for the `inactive` state of this link.\n * These props override other props passed to the link (`style`'s are merged, `class`'s are concatenated)\n */\n inactiveProps?: ActiveLinkProps<TComp> | (() => ActiveLinkProps<TComp>)\n}\n\nexport type LinkProps<\n TComp = 'a',\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '.',\n> = ActiveLinkOptions<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo> &\n LinkPropsChildren\n\nexport interface LinkPropsChildren {\n // If a function is passed as a child, it will be given the `isActive` boolean to aid in further styling on the element it returns\n children?: JSX.Element | ((state: { isActive: boolean }) => JSX.Element)\n}\n\ntype LinkComponentSolidProps<TComp> = TComp extends ValidComponent\n ? Omit<ComponentProps<TComp>, keyof CreateLinkProps>\n : never\n\nexport type LinkComponentProps<\n TComp = 'a',\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '.',\n> = LinkComponentSolidProps<TComp> &\n LinkProps<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo>\n\nexport type CreateLinkProps = LinkProps<\n any,\n any,\n string,\n string,\n string,\n string\n>\n\nexport type LinkComponent<\n in out TComp,\n in out TDefaultFrom extends string = string,\n> = <\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends string = TDefaultFrom,\n const TTo extends string | undefined = undefined,\n const TMaskFrom extends string = TFrom,\n const TMaskTo extends string = '',\n>(\n props: LinkComponentProps<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n) => JSX.Element\n\nexport interface LinkComponentRoute<\n in out TDefaultFrom extends string = string,\n> {\n defaultFrom: TDefaultFrom;\n <\n TRouter extends AnyRouter = RegisteredRouter,\n const TTo extends string | undefined = undefined,\n const TMaskTo extends string = '',\n >(\n props: LinkComponentProps<\n 'a',\n TRouter,\n this['defaultFrom'],\n TTo,\n this['defaultFrom'],\n TMaskTo\n >,\n ): JSX.Element\n}\n\nexport function createLink<const TComp>(\n Comp: Constrain<TComp, any, (props: CreateLinkProps) => JSX.Element>,\n): LinkComponent<TComp> {\n return (props) => <Link {...props} _asChild={Comp} />\n}\n\nexport const Link: LinkComponent<'a'> = (props) => {\n const [local, rest] = splitProps(props as typeof props & { _asChild: any }, [\n '_asChild',\n 'children',\n ])\n const [_, linkProps] = splitProps(useLinkProps(rest as unknown as any), [\n 'type',\n ])\n\n // Resolve children once using Solid.children to avoid\n // re-accessing the children getter (which in Solid 2.0 would\n // re-invoke createComponent each time for JSX children).\n const resolvedChildren = Solid.children(() => local.children as JSX.Element)\n const children = () => {\n const ch = resolvedChildren()\n if (typeof ch === 'function') {\n return (ch as Function)({\n get isActive() {\n return (linkProps as any)['data-status'] === 'active'\n },\n })\n }\n\n return ch\n }\n\n if (local._asChild === 'svg') {\n const [_, svgLinkProps] = splitProps(linkProps as any, ['class'])\n return (\n <svg>\n <a {...svgLinkProps}>{children()}</a>\n </svg>\n )\n }\n\n if (!local._asChild) {\n return <a {...linkProps}>{children()}</a>\n }\n\n return (\n <Dynamic component={local._asChild as ValidComponent} {...linkProps}>\n {children()}\n </Dynamic>\n )\n}\n\nfunction isCtrlEvent(e: MouseEvent) {\n return !!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey)\n}\n\nfunction isSafeInternal(to: unknown) {\n if (typeof to !== 'string') return false\n const zero = to.charCodeAt(0)\n if (zero === 47) return to.charCodeAt(1) !== 47 // '/' but not '//'\n return zero === 46 // '.', '..', './', '../'\n}\n\nexport type LinkOptionsFnOptions<\n TOptions,\n TComp,\n TRouter extends AnyRouter = RegisteredRouter,\n> =\n TOptions extends ReadonlyArray<any>\n ? ValidateLinkOptionsArray<TRouter, TOptions, string, TComp>\n : ValidateLinkOptions<TRouter, TOptions, string, TComp>\n\nexport type LinkOptionsFn<TComp> = <\n const TOptions,\n TRouter extends AnyRouter = RegisteredRouter,\n>(\n options: LinkOptionsFnOptions<TOptions, TComp, TRouter>,\n) => TOptions\n\nexport const linkOptions: LinkOptionsFn<'a'> = (options) => {\n return options as any\n}\n"],"mappings":";;;;;;;;;;;;AAgCA,SAAS,UAAa,GAAG,MAAuC;CAC9D,MAAM,UAAU,KAAc,OAAU;EACtC,IAAI,OAAO,QAAQ,YACjB,IAAI,EAAE;OACD,IAAI,MAAM,QAAQ,GAAG,GAC1B,KAAK,MAAM,aAAa,KACtB,OAAO,WAAW,EAAE;CAG1B;CAEA,QAAQ,OAAU;EAChB,KAAK,MAAM,OAAO,MAChB,OAAO,KAAK,EAAE;CAElB;AACF;AAEA,SAAS,WACP,OACA,MACgC;CAQhC,OAAO,CAAC,OAAc,SAAM,KAAK,OAAO,GAAI,IAAY,CAAQ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