UNPKG

@tanstack/solid-router

Version:

Modern and scalable routing for Solid applications

1 lines 30.8 kB
{"version":3,"file":"link.cjs","names":["Solid","mergeRefs","deepEqual","functionalUpdate","getUrlScheme","hasKeys","isDangerousProtocol","preloadWarning","removeTrailingSlash","isServer","Dynamic","useRouter","useIntersectionObserver","useHydrated","AnyRouter","Constrain","LinkOptions","RegisteredRouter","RoutePaths","ValidateLinkOptions","ValidateLinkOptionsArray","timeoutMap","WeakMap","ReturnType","setTimeout","cancelPreload","eventTarget","clearTimeout","get","delete","useLinkProps","TRouter","TFrom","options","UseLinkPropsOptions","TTo","TMaskFrom","TMaskTo","ComponentProps","router","local","rest","splitProps","mergeProps","activeProps","STATIC_ACTIVE_PROPS_GET","inactiveProps","STATIC_INACTIVE_PROPS_GET","_","propsSafeToSpread","currentLocation","createMemo","stores","location","undefined","equals","prev","next","href","_fromLocation","nextOptions","untrack","buildLocation","hrefOption","disabled","maskedLocation","publicHref","external","history","createHref","protocolAllowlist","process","env","NODE_ENV","console","warn","externalLink","to","scheme","has","_href","shouldHydrateHash","ssr","hasHydrated","isActive","activeOptions","current","nextLocation","currentPath","pathname","basepath","nextPath","exact","startsWith","length","includeSearch","searchTest","search","partial","ignoreUndefined","explicitUndefined","includeHash","currentHash","hash","simpleStyling","class","style","ResolvedLinkStateProps","Omit","JSX","CSSProperties","resolveLinkStateProps","base","active","STATIC_DEFAULT_ACTIVE_ATTRIBUTES","stateProps","EMPTY_OBJECT","className","filter","Boolean","join","STATIC_ACTIVE_ATTRIBUTES","props","onClick","onBlur","onFocus","onMouseEnter","onMouseLeave","onMouseOut","onMouseOver","onTouchStart","ref","target","STATIC_DISABLED_PROPS","key","STATIC_EVENT_PROPS","hasRenderFetched","preload","reloadDocument","defaultPreload","preloadDelay","defaultPreloadDelay","doPreload","preloadRoute","Parameters","catch","err","setRef","createSignal","Element","enqueuePreload","e","MouseEvent","FocusEvent","IntersectionObserverEntry","isIntersecting","set","createEffect","handleClick","elementTarget","currentTarget","HTMLAnchorElement","SVGAElement","getAttribute","effectiveTarget","metaKey","altKey","ctrlKey","shiftKey","defaultPrevented","button","preventDefault","navigate","replace","resetScroll","hashScrollIntoView","startTransition","viewTransition","ignoreBlocker","handleTouchStart","handleLeave","createComposedHandler","resolvedProps","const","STATIC_ACTIVE_PROPS","role","callHandler","Event","event","TEvent","T","handler","EventHandlerUnion","getHandler","fallback","ActiveLinkOptions","ActiveLinkOptionProps","TComp","ActiveLinkProps","Partial","LinkComponentSolidProps","LinkProps","LinkPropsChildren","children","state","ValidComponent","CreateLinkProps","LinkComponentProps","LinkComponent","TDefaultFrom","LinkComponentRoute","defaultFrom","createLink","Comp","_$createComponent","Link","_$mergeProps","_asChild","linkProps","ch","svgLinkProps","_el$","_tmpl$","_el$2","firstChild","_$spread","_$insert","_el$3","_tmpl$2","component","LinkOptionsFnOptions","TOptions","ReadonlyArray","LinkOptionsFn","linkOptions"],"sources":["../../src/link.tsx"],"sourcesContent":["import * as Solid from 'solid-js'\n\nimport { mergeRefs } from '@solid-primitives/refs'\n\nimport {\n deepEqual,\n functionalUpdate,\n getUrlScheme,\n hasKeys,\n isDangerousProtocol,\n preloadWarning,\n removeTrailingSlash,\n} from '@tanstack/router-core'\n\nimport { isServer } from '@tanstack/router-core/isServer'\nimport { Dynamic } from 'solid-js/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'\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): Solid.ComponentProps<'a'> {\n const router = useRouter()\n const [local, rest] = Solid.splitProps(\n Solid.mergeProps(\n {\n activeProps: STATIC_ACTIVE_PROPS_GET,\n inactiveProps: STATIC_INACTIVE_PROPS_GET,\n },\n options,\n ),\n [\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 ],\n )\n\n // const {\n // // custom props\n // activeProps = () => ({ class: 'active' }),\n // inactiveProps = () => ({}),\n // activeOptions,\n // to,\n // preload: userPreload,\n // preloadDelay: userPreloadDelay,\n // hashScrollIntoView,\n // replace,\n // startTransition,\n // resetScroll,\n // viewTransition,\n // // element props\n // children,\n // target,\n // disabled,\n // style,\n // class,\n // onClick,\n // onFocus,\n // onMouseEnter,\n // onMouseLeave,\n // onTouchStart,\n // ignoreBlocker,\n // ...rest\n // } = options\n\n const [_, propsSafeToSpread] = Solid.splitProps(rest, [\n 'params',\n 'search',\n 'hash',\n 'state',\n 'mask',\n 'reloadDocument',\n 'unsafeRelative',\n 'from',\n 'href',\n ])\n\n const currentLocation = Solid.createMemo(\n () => router.stores.location.get(),\n undefined,\n { equals: (prev, next) => prev.href === next.href },\n )\n\n const next = Solid.createMemo(() => {\n // Rebuild when inherited search/hash or the current route context changes.\n const _fromLocation = currentLocation()\n const nextOptions = { _fromLocation, ...options } as any\n // untrack because router-core will also access stores, which are signals in solid\n return Solid.untrack(() => router.buildLocation(nextOptions))\n })\n\n const hrefOption = Solid.createMemo(() => {\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 const href = external\n ? publicHref\n : router.history.createHref(publicHref) || '/'\n if (\n (external || href !== publicHref) &&\n isDangerousProtocol(href, router.protocolAllowlist)\n ) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`Blocked Link with dangerous protocol: ${href}`)\n }\n return undefined\n }\n\n return href\n })\n\n const externalLink = Solid.createMemo(() => {\n const to = options.to\n const scheme = typeof to === 'string' && getUrlScheme(to)\n if (scheme) {\n if (!router.protocolAllowlist.has(scheme)) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`Blocked Link with dangerous protocol: ${to}`)\n }\n return null\n }\n return to\n }\n\n const _href = hrefOption()\n if (!_href && !options.disabled) {\n return null\n }\n return _href && getUrlScheme(_href) ? _href : undefined\n })\n\n const shouldHydrateHash = !isServer && !!router.options.ssr\n const hasHydrated = (isServer ?? router.isServer) ? undefined : useHydrated()\n\n const isActive = Solid.createMemo(() => {\n if (externalLink() !== undefined) {\n return false\n }\n const activeOptions = local.activeOptions\n const current = currentLocation()\n const nextLocation = next()\n\n const currentPath = removeTrailingSlash(current.pathname, router.basepath)\n const nextPath = removeTrailingSlash(nextLocation.pathname, router.basepath)\n\n // Both modes compare normalized paths; fuzzy matches need a segment boundary.\n if (\n activeOptions?.exact\n ? currentPath !== nextPath\n : !(\n currentPath.startsWith(nextPath) &&\n (currentPath.length === nextPath.length ||\n currentPath[nextPath.length] === '/')\n )\n ) {\n return false\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\n const simpleStyling = Solid.createMemo(\n () =>\n local.activeProps === STATIC_ACTIVE_PROPS_GET &&\n local.inactiveProps === STATIC_INACTIVE_PROPS_GET &&\n local.class === undefined &&\n local.style === undefined,\n )\n\n type ResolvedLinkStateProps = Omit<Solid.ComponentProps<'a'>, 'style'> & {\n style?: Solid.JSX.CSSProperties\n }\n\n const resolveLinkStateProps = (\n base: Solid.ComponentProps<'a'> & { disabled?: boolean },\n ) => {\n const active = isActive()\n\n if (simpleStyling()) {\n return {\n ...base,\n ...(active && STATIC_DEFAULT_ACTIVE_ATTRIBUTES),\n }\n }\n\n // Active and inactive props are mutually exclusive.\n const stateProps: ResolvedLinkStateProps = active\n ? (functionalUpdate(local.activeProps as any, {}) ?? EMPTY_OBJECT)\n : functionalUpdate(local.inactiveProps, {})\n const style = {\n ...local.style,\n ...stateProps.style,\n }\n const className = [local.class, stateProps.class].filter(Boolean).join(' ')\n\n return {\n ...stateProps,\n ...base,\n ...(hasKeys(style) ? { style } : undefined),\n ...(className ? { class: className } : undefined),\n ...(active && STATIC_ACTIVE_ATTRIBUTES),\n } as ResolvedLinkStateProps\n }\n\n // Keep the guard inline so browser builds can drop the server return.\n if (isServer ?? router.isServer) {\n const external = externalLink()\n const disabled = local.disabled || external === null\n const props = resolveLinkStateProps({\n onClick: local.onClick,\n onBlur: local.onBlur,\n onFocus: local.onFocus,\n onMouseEnter: local.onMouseEnter,\n onMouseLeave: local.onMouseLeave,\n onMouseOut: local.onMouseOut,\n onMouseOver: local.onMouseOver,\n onTouchStart: local.onTouchStart,\n href: external === null ? undefined : external || hrefOption(),\n ref: options.ref,\n disabled,\n target: local.target,\n ...(disabled && STATIC_DISABLED_PROPS),\n })\n // Avoid creating merged-prop getters for absent server event handlers.\n for (const key of STATIC_EVENT_PROPS) {\n if (props[key] === undefined) {\n delete props[key]\n }\n }\n return Solid.mergeProps(propsSafeToSpread, props) as any\n }\n\n let hasRenderFetched = false\n\n const preload = Solid.createMemo(() => {\n if (\n options.reloadDocument ||\n externalLink() !== undefined ||\n local.disabled\n ) {\n return false\n }\n return local.preload ?? router.options.defaultPreload\n })\n const preloadDelay = () =>\n local.preloadDelay ?? router.options.defaultPreloadDelay ?? 0\n\n const doPreload = () =>\n router\n .preloadRoute(options as Parameters<typeof router.preloadRoute>[0])\n .catch((err: any) => {\n console.warn(err)\n console.warn(preloadWarning)\n })\n\n const [ref, setRef] = Solid.createSignal<Element | null>(null)\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(() => {\n if (hasRenderFetched) {\n return\n }\n if (preload() === 'render') {\n doPreload()\n hasRenderFetched = true\n }\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 externalLink() === undefined &&\n !(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) &&\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 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 const resolvedProps = Solid.createMemo(() => {\n const external = externalLink()\n const disabled = local.disabled || external === null\n\n const base = {\n href: external === null ? undefined : external || hrefOption(),\n ref: mergeRefs(setRef, options.ref),\n onClick,\n onBlur,\n onFocus,\n onMouseEnter,\n onMouseOver,\n onMouseLeave,\n onMouseOut,\n onTouchStart,\n disabled,\n target: local.target,\n ...(disabled && STATIC_DISABLED_PROPS),\n }\n\n return resolveLinkStateProps(base)\n })\n\n return Solid.mergeProps(propsSafeToSpread, resolvedProps) as any\n}\n\nconst STATIC_EVENT_PROPS = [\n 'onClick',\n 'onBlur',\n 'onFocus',\n 'onMouseEnter',\n 'onMouseLeave',\n 'onMouseOut',\n 'onMouseOver',\n 'onTouchStart',\n] as const\nconst STATIC_ACTIVE_PROPS = { class: 'active' }\nconst STATIC_ACTIVE_PROPS_GET = () => STATIC_ACTIVE_PROPS\nconst EMPTY_OBJECT = {}\nconst STATIC_INACTIVE_PROPS_GET = () => EMPTY_OBJECT\nconst STATIC_DEFAULT_ACTIVE_ATTRIBUTES = {\n class: 'active',\n 'data-status': 'active',\n 'aria-current': 'page',\n}\nconst STATIC_DISABLED_PROPS = {\n role: 'link' as const,\n 'aria-disabled': true,\n}\nconst STATIC_ACTIVE_ATTRIBUTES = {\n 'data-status': 'active',\n 'aria-current': 'page',\n}\n\n/** Call a JSX.EventHandlerUnion with the event. */\nfunction callHandler<T, TEvent extends Event>(\n event: TEvent & { currentTarget: T; target: Element },\n handler: Solid.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: () => Solid.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<Solid.ComponentProps<'a'>, 'style'> & { style?: Solid.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?:\n | Solid.JSX.Element\n | ((state: { isActive: boolean }) => Solid.JSX.Element)\n}\n\ntype LinkComponentSolidProps<TComp> = TComp extends Solid.ValidComponent\n ? Omit<Solid.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) => Solid.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 ): Solid.JSX.Element\n}\n\nexport function createLink<const TComp>(\n Comp: Constrain<TComp, any, (props: CreateLinkProps) => Solid.JSX.Element>,\n): LinkComponent<TComp> {\n return (props) => <Link {...props} _asChild={Comp} />\n}\n\nexport const Link: LinkComponent<'a'> = (props) => {\n const [local, rest] = Solid.splitProps(\n props as typeof props & { _asChild: any },\n ['_asChild', 'children'],\n )\n\n const [_, linkProps] = Solid.splitProps(\n useLinkProps(rest as unknown as any),\n ['type'],\n )\n\n const children = Solid.createMemo(() => {\n const ch = local.children\n if (typeof ch === 'function') {\n return ch({\n get isActive() {\n return (linkProps as any)['data-status'] === 'active'\n },\n })\n }\n\n return ch satisfies Solid.JSX.Element\n })\n\n if (local._asChild === 'svg') {\n const [_, svgLinkProps] = Solid.splitProps(linkProps, ['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 Solid.ValidComponent} {...linkProps}>\n {children()}\n </Dynamic>\n )\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":";;;;;;;;;;;;AAiCA,IAAMqB,6BAAa,IAAIC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