@seahax/elemental
Advanced tools
+5
-3
@@ -9,3 +9,5 @@ type Alpha = 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z'; | ||
| type Attrs<TElement> = TElement extends string | CustomElementConstructor | Element ? Readonly<Record<`${Alpha}${string}`, AttrValue>> : {}; | ||
| export type ChildValue = Node | string | number | bigint | false | null | undefined; | ||
| export type HtmlSingleChild = Node | string | number | bigint | false | null | undefined; | ||
| export type HtmlChild = HtmlSingleChild | readonly HtmlSingleChild[]; | ||
| export type HtmlChildren = readonly HtmlChild[]; | ||
| export type HtmlConfig<TElement> = Attrs<TElement> & Props<ElementType<TElement>>; | ||
@@ -16,4 +18,4 @@ export type ElementType<TElement> = TElement extends string ? TElement extends keyof TagMap ? TagMap[TElement] : HTMLElement : TElement extends CustomElementConstructor ? InstanceType<TElement> : TElement extends Element | Document | ShadowRoot ? TElement : never; | ||
| */ | ||
| export declare function html<TElement extends keyof TagMap | (string & {}) | CustomElementConstructor | Element | Document | ShadowRoot>(el: TElement, config?: HtmlConfig<TElement>, children?: readonly ChildValue[]): ElementType<NoInfer<TElement>>; | ||
| export declare function html<TElement extends keyof TagMap | (string & {}) | CustomElementConstructor | Element | Document | ShadowRoot>(el: TElement, children?: readonly ChildValue[]): ElementType<TElement>; | ||
| export declare function html<TElement extends keyof TagMap | (string & {}) | CustomElementConstructor | Element | Document | ShadowRoot>(el: TElement, config?: HtmlConfig<TElement>, children?: HtmlChildren): ElementType<NoInfer<TElement>>; | ||
| export declare function html<TElement extends keyof TagMap | (string & {}) | CustomElementConstructor | Element | Document | ShadowRoot>(el: TElement, children?: HtmlChildren): ElementType<TElement>; | ||
| export {}; |
+1
-1
@@ -26,3 +26,3 @@ //#region src/html.ts | ||
| if (n) { | ||
| let t = n.filter((e) => e != null && e !== !1).map((e) => typeof e == "object" ? e : document.createTextNode(String(e))); | ||
| let t = n.flat(1).filter((e) => e != null && e !== !1).map((e) => typeof e == "object" ? e : document.createTextNode(String(e))); | ||
| e.replaceChildren(...t); | ||
@@ -29,0 +29,0 @@ } |
+1
-1
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"html.js","names":[],"sources":["../src/html.ts"],"sourcesContent":["// prettier-ignore\ntype Alpha = 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z';\ntype AttrValue = string | number | bigint | boolean | null | undefined;\ntype TagMap = HTMLElementTagNameMap & HTMLElementDeprecatedTagNameMap;\n\ntype IfEquals<T, U, Y = unknown, N = never> =\n (<G>() => G extends T ? 1 : 2) extends <G>() => G extends U ? 1 : 2 ? Y : N;\n\ntype Props<TElement> = {\n readonly [P in keyof TElement & string as TElement[P] extends ((...args: any[]) => any) | null | undefined\n ? never\n : IfEquals<Record<P, TElement[P]>, Pick<TElement, P>, `:${P}`, never>]?: TElement[P];\n};\n\ntype Attrs<TElement> = TElement extends string | CustomElementConstructor | Element\n ? Readonly<Record<`${Alpha}${string}`, AttrValue>>\n : {};\n\nexport type ChildValue = Node | string | number | bigint | false | null | undefined;\n\nexport type HtmlConfig<TElement> = Attrs<TElement> & Props<ElementType<TElement>>;\n\nexport type ElementType<TElement> = TElement extends string\n ? TElement extends keyof TagMap\n ? TagMap[TElement]\n : HTMLElement\n : TElement extends CustomElementConstructor\n ? InstanceType<TElement>\n : TElement extends Element | Document | ShadowRoot\n ? TElement\n : never;\n\n/**\n * Create or update an HTML element.\n */\nexport function html<\n TElement extends keyof TagMap | (string & {}) | CustomElementConstructor | Element | Document | ShadowRoot,\n>(el: TElement, config?: HtmlConfig<TElement>, children?: readonly ChildValue[]): ElementType<NoInfer<TElement>>;\nexport function html<\n TElement extends keyof TagMap | (string & {}) | CustomElementConstructor | Element | Document | ShadowRoot,\n>(el: TElement, children?: readonly ChildValue[]): ElementType<TElement>;\n\nexport function html(\n el: string | CustomElementConstructor | Element | Document | ShadowRoot,\n configOrChildren: readonly ChildValue[] | Readonly<Record<string, any>> = {},\n children?: readonly ChildValue[],\n): Node {\n if (typeof el === 'function') {\n let name = customElements.getName(el);\n\n if (name == null) {\n name = `ce-${crypto.randomUUID()}`;\n customElements.define(name, el);\n }\n\n el = name;\n }\n\n if (typeof el === 'string') el = document.createElement(el);\n\n let config: Readonly<Record<string, any>>;\n [config, children] = Array.isArray(configOrChildren)\n ? [{}, configOrChildren as readonly ChildValue[]]\n : [configOrChildren as Readonly<Record<string, any>>, children];\n\n if ('setAttribute' in el) {\n for (const [name, rawValue] of Object.entries(config)) {\n if (rawValue === undefined || name.startsWith(':')) continue;\n\n if (rawValue === null || rawValue === false) {\n if (el.hasAttribute(name)) el.removeAttribute(name);\n } else {\n const value = rawValue == true ? '' : String(rawValue);\n if (el.getAttribute(name) !== value) {\n try {\n el.setAttribute(name, value);\n } catch (error) {\n console.warn(error);\n }\n }\n }\n }\n }\n\n for (const [rawName, value] of Object.entries(config)) {\n if (value === undefined || !rawName.startsWith(':')) continue;\n const name = rawName.slice(1);\n if (Reflect.get(el, name) !== value) Reflect.set(el, name, value);\n }\n\n if (children) {\n const childNodes = children\n .filter((child) => child != null && child !== false)\n .map((child) => (typeof child !== 'object' ? document.createTextNode(String(child)) : child));\n\n el.replaceChildren(...childNodes);\n }\n\n return el;\n}\n"],"mappings":";AA0CA,SAAgB,EACd,GACA,IAA0E,EAAE,EAC5E,GACM;AACN,KAAI,OAAO,KAAO,YAAY;EAC5B,IAAI,IAAO,eAAe,QAAQ,EAAG;AAOrC,EALI,MACF,IAAO,MAAM,OAAO,YAAY,IAChC,eAAe,OAAO,GAAM,EAAG,GAGjC,IAAK;;AAGP,CAAI,OAAO,KAAO,aAAU,IAAK,SAAS,cAAc,EAAG;CAE3D,IAAI;AAKJ,KAJA,CAAC,GAAQ,KAAY,MAAM,QAAQ,EAAiB,GAChD,CAAC,EAAE,EAAE,EAA0C,GAC/C,CAAC,GAAmD,EAAS,EAE7D,kBAAkB,GACpB;OAAK,IAAM,CAAC,GAAM,MAAa,OAAO,QAAQ,EAAO,CAC/C,aAAa,KAAA,KAAa,EAAK,WAAW,IAAI,EAElD,KAAI,MAAa,QAAQ,MAAa,IAChC,EAAG,aAAa,EAAK,IAAE,EAAG,gBAAgB,EAAK;OAC9C;GACL,IAAM,IAAQ,KAAY,IAAO,KAAK,OAAO,EAAS;AACtD,OAAI,EAAG,aAAa,EAAK,KAAK,EAC5B,KAAI;AACF,MAAG,aAAa,GAAM,EAAM;YACrB,GAAO;AACd,YAAQ,KAAK,EAAM;;;;AAO7B,MAAK,IAAM,CAAC,GAAS,MAAU,OAAO,QAAQ,EAAO,EAAE;AACrD,MAAI,MAAU,KAAA,KAAa,CAAC,EAAQ,WAAW,IAAI,CAAE;EACrD,IAAM,IAAO,EAAQ,MAAM,EAAE;AAC7B,EAAI,QAAQ,IAAI,GAAI,EAAK,KAAK,KAAO,QAAQ,IAAI,GAAI,GAAM,EAAM;;AAGnE,KAAI,GAAU;EACZ,IAAM,IAAa,EAChB,QAAQ,MAAU,KAAS,QAAQ,MAAU,GAAM,CACnD,KAAK,MAAW,OAAO,KAAU,WAAoD,IAAzC,SAAS,eAAe,OAAO,EAAM,CAAC,CAAU;AAE/F,IAAG,gBAAgB,GAAG,EAAW;;AAGnC,QAAO"} | ||
| {"version":3,"file":"html.js","names":[],"sources":["../src/html.ts"],"sourcesContent":["// prettier-ignore\ntype Alpha = 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z';\ntype AttrValue = string | number | bigint | boolean | null | undefined;\ntype TagMap = HTMLElementTagNameMap & HTMLElementDeprecatedTagNameMap;\n\ntype IfEquals<T, U, Y = unknown, N = never> =\n (<G>() => G extends T ? 1 : 2) extends <G>() => G extends U ? 1 : 2 ? Y : N;\n\ntype Props<TElement> = {\n readonly [P in keyof TElement & string as TElement[P] extends ((...args: any[]) => any) | null | undefined\n ? never\n : IfEquals<Record<P, TElement[P]>, Pick<TElement, P>, `:${P}`, never>]?: TElement[P];\n};\n\ntype Attrs<TElement> = TElement extends string | CustomElementConstructor | Element\n ? Readonly<Record<`${Alpha}${string}`, AttrValue>>\n : {};\n\nexport type HtmlSingleChild = Node | string | number | bigint | false | null | undefined;\nexport type HtmlChild = HtmlSingleChild | readonly HtmlSingleChild[];\nexport type HtmlChildren = readonly HtmlChild[];\nexport type HtmlConfig<TElement> = Attrs<TElement> & Props<ElementType<TElement>>;\n\nexport type ElementType<TElement> = TElement extends string\n ? TElement extends keyof TagMap\n ? TagMap[TElement]\n : HTMLElement\n : TElement extends CustomElementConstructor\n ? InstanceType<TElement>\n : TElement extends Element | Document | ShadowRoot\n ? TElement\n : never;\n\n/**\n * Create or update an HTML element.\n */\nexport function html<\n TElement extends keyof TagMap | (string & {}) | CustomElementConstructor | Element | Document | ShadowRoot,\n>(el: TElement, config?: HtmlConfig<TElement>, children?: HtmlChildren): ElementType<NoInfer<TElement>>;\nexport function html<\n TElement extends keyof TagMap | (string & {}) | CustomElementConstructor | Element | Document | ShadowRoot,\n>(el: TElement, children?: HtmlChildren): ElementType<TElement>;\n\nexport function html(\n el: string | CustomElementConstructor | Element | Document | ShadowRoot,\n configOrChildren: HtmlChildren | Readonly<Record<string, any>> = {},\n children?: HtmlChildren,\n): Node {\n if (typeof el === 'function') {\n let name = customElements.getName(el);\n\n if (name == null) {\n name = `ce-${crypto.randomUUID()}`;\n customElements.define(name, el);\n }\n\n el = name;\n }\n\n if (typeof el === 'string') el = document.createElement(el);\n\n let config: Readonly<Record<string, any>>;\n [config, children] = Array.isArray(configOrChildren)\n ? [{}, configOrChildren as HtmlChildren]\n : [configOrChildren as Readonly<Record<string, any>>, children];\n\n if ('setAttribute' in el) {\n for (const [name, rawValue] of Object.entries(config)) {\n if (rawValue === undefined || name.startsWith(':')) continue;\n\n if (rawValue === null || rawValue === false) {\n if (el.hasAttribute(name)) el.removeAttribute(name);\n } else {\n const value = rawValue == true ? '' : String(rawValue);\n if (el.getAttribute(name) !== value) {\n try {\n el.setAttribute(name, value);\n } catch (error) {\n console.warn(error);\n }\n }\n }\n }\n }\n\n for (const [rawName, value] of Object.entries(config)) {\n if (value === undefined || !rawName.startsWith(':')) continue;\n const name = rawName.slice(1);\n if (Reflect.get(el, name) !== value) Reflect.set(el, name, value);\n }\n\n if (children) {\n const childNodes = children\n .flat(1)\n .filter((child) => child != null && child !== false)\n .map((child) => (typeof child !== 'object' ? document.createTextNode(String(child)) : child));\n\n el.replaceChildren(...childNodes);\n }\n\n return el;\n}\n"],"mappings":";AA2CA,SAAgB,EACd,GACA,IAAiE,EAAE,EACnE,GACM;AACN,KAAI,OAAO,KAAO,YAAY;EAC5B,IAAI,IAAO,eAAe,QAAQ,EAAG;AAOrC,EALI,MACF,IAAO,MAAM,OAAO,YAAY,IAChC,eAAe,OAAO,GAAM,EAAG,GAGjC,IAAK;;AAGP,CAAI,OAAO,KAAO,aAAU,IAAK,SAAS,cAAc,EAAG;CAE3D,IAAI;AAKJ,KAJA,CAAC,GAAQ,KAAY,MAAM,QAAQ,EAAiB,GAChD,CAAC,EAAE,EAAE,EAAiC,GACtC,CAAC,GAAmD,EAAS,EAE7D,kBAAkB,GACpB;OAAK,IAAM,CAAC,GAAM,MAAa,OAAO,QAAQ,EAAO,CAC/C,aAAa,KAAA,KAAa,EAAK,WAAW,IAAI,EAElD,KAAI,MAAa,QAAQ,MAAa,IAChC,EAAG,aAAa,EAAK,IAAE,EAAG,gBAAgB,EAAK;OAC9C;GACL,IAAM,IAAQ,KAAY,IAAO,KAAK,OAAO,EAAS;AACtD,OAAI,EAAG,aAAa,EAAK,KAAK,EAC5B,KAAI;AACF,MAAG,aAAa,GAAM,EAAM;YACrB,GAAO;AACd,YAAQ,KAAK,EAAM;;;;AAO7B,MAAK,IAAM,CAAC,GAAS,MAAU,OAAO,QAAQ,EAAO,EAAE;AACrD,MAAI,MAAU,KAAA,KAAa,CAAC,EAAQ,WAAW,IAAI,CAAE;EACrD,IAAM,IAAO,EAAQ,MAAM,EAAE;AAC7B,EAAI,QAAQ,IAAI,GAAI,EAAK,KAAK,KAAO,QAAQ,IAAI,GAAI,GAAM,EAAM;;AAGnE,KAAI,GAAU;EACZ,IAAM,IAAa,EAChB,KAAK,EAAE,CACP,QAAQ,MAAU,KAAS,QAAQ,MAAU,GAAM,CACnD,KAAK,MAAW,OAAO,KAAU,WAAoD,IAAzC,SAAS,eAAe,OAAO,EAAM,CAAC,CAAU;AAE/F,IAAG,gBAAgB,GAAG,EAAW;;AAGnC,QAAO"} |
| import { type ComponentConstructor } from '../defineComponent.ts'; | ||
| import { type ChildValue, type HtmlConfig } from '../html.ts'; | ||
| import { type HtmlChildren, type HtmlConfig } from '../html.ts'; | ||
| import type { RouterOptions } from './defineRouter.ts'; | ||
@@ -12,3 +12,3 @@ interface Route { | ||
| readonly config: HtmlConfig<HTMLElement>; | ||
| readonly children: readonly ChildValue[]; | ||
| readonly children: HtmlChildren; | ||
| readonly pattern: string; | ||
@@ -15,0 +15,0 @@ } |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"defineRouterComponent.js","names":[],"sources":["../../src/router/defineRouterComponent.ts"],"sourcesContent":["import { type ComponentConstructor, defineComponent } from '../defineComponent.ts';\nimport { useEffect } from '../hooks/useEffect.ts';\nimport { useLocationHref } from '../hooks/useLocationHref.ts';\nimport { useRef } from '../hooks/useRef.ts';\nimport { type ChildValue, html, type HtmlConfig } from '../html.ts';\nimport { compareRouteMatches } from './compareRouteMatches.ts';\nimport type { RouterOptions } from './defineRouter.ts';\nimport { parsePath } from './parsePath.ts';\n\ninterface Route {\n readonly component: CustomElementConstructor;\n readonly config: (pathParams: Record<string, string>, searchParams?: URLSearchParams) => HtmlConfig<HTMLElement>;\n readonly matcher: (segments: readonly string[]) => Record<string, string> | null;\n}\n\nexport interface RouteMatch {\n readonly component: CustomElementConstructor;\n readonly config: HtmlConfig<HTMLElement>;\n readonly children: readonly ChildValue[];\n readonly pattern: string;\n}\n\nexport function defineRouterComponent(\n routeEntries: ReadonlyMap<`/${string}`, Route>,\n { fallback, invalid, ...options }: RouterOptions = {},\n): ComponentConstructor<{}> {\n return defineComponent(\n (shadow) => {\n const href = useLocationHref();\n const routeMatch = useRef<RouteMatch | null>(null, { compare: compareRouteMatches });\n\n let prev:\n | { readonly component: CustomElementConstructor; readonly pattern: string; readonly element: HTMLElement }\n | undefined;\n\n useEffect([href], (href) => {\n const url = new URL(href);\n const segments = parsePath(url.pathname);\n\n for (const [pattern, { component, config, matcher }] of routeEntries.entries()) {\n const pathParams = matcher(segments);\n\n if (pathParams) {\n const searchParams = config.length >= 2 ? new URLSearchParams(url.search) : undefined;\n try {\n const resolvedConfig = config(pathParams, searchParams);\n routeMatch.value = { pattern, component, config: resolvedConfig, children: [] };\n return;\n } catch (error) {\n if (invalid) {\n routeMatch.value = {\n component: invalid,\n pattern: 'invalid',\n config: {\n 'data-error-name': error instanceof Error ? error.name : null,\n 'data-error-code': typeof (error as any)?.code === 'string' ? (error as any).code : null,\n },\n children: [error instanceof Error ? error.message : String(error)],\n };\n\n return;\n }\n\n console.warn(error);\n }\n }\n }\n\n routeMatch.value = fallback ? { component: fallback, pattern: 'fallback', config: {}, children: [] } : null;\n });\n\n useEffect([routeMatch], (routeMatch) => {\n if (!routeMatch) {\n html(shadow, []);\n return;\n }\n\n if (prev?.component === routeMatch.component && prev.pattern === routeMatch.pattern) {\n html(prev.element, routeMatch.config, routeMatch.children);\n return;\n }\n\n const element = html(routeMatch.component, routeMatch.config, routeMatch.children);\n html(shadow, [element]);\n prev = { component: routeMatch.component, pattern: routeMatch.pattern, element };\n });\n },\n { ...options, styles: [':host{display:contents;}'] },\n );\n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U,EAAK,EAAW,WAAW,EAAW,QAAQ,EAAW,SAAS;AAElF,GADA,EAAK,GAAQ,CAAC,EAAQ,CAAC,EACvB,IAAO;IAAE,WAAW,EAAW;IAAW,SAAS,EAAW;IAAS;IAAS;IAChF;IAEJ;EAAE,GAAG;EAAS,QAAQ,CAAC,2BAA2B;EAAE,CACrD"} | ||
| {"version":3,"file":"defineRouterComponent.js","names":[],"sources":["../../src/router/defineRouterComponent.ts"],"sourcesContent":["import { type ComponentConstructor, defineComponent } from '../defineComponent.ts';\nimport { useEffect } from '../hooks/useEffect.ts';\nimport { useLocationHref } from '../hooks/useLocationHref.ts';\nimport { useRef } from '../hooks/useRef.ts';\nimport { html, type HtmlChildren, type HtmlConfig } from '../html.ts';\nimport { compareRouteMatches } from './compareRouteMatches.ts';\nimport type { RouterOptions } from './defineRouter.ts';\nimport { parsePath } from './parsePath.ts';\n\ninterface Route {\n readonly component: CustomElementConstructor;\n readonly config: (pathParams: Record<string, string>, searchParams?: URLSearchParams) => HtmlConfig<HTMLElement>;\n readonly matcher: (segments: readonly string[]) => Record<string, string> | null;\n}\n\nexport interface RouteMatch {\n readonly component: CustomElementConstructor;\n readonly config: HtmlConfig<HTMLElement>;\n readonly children: HtmlChildren;\n readonly pattern: string;\n}\n\nexport function defineRouterComponent(\n routeEntries: ReadonlyMap<`/${string}`, Route>,\n { fallback, invalid, ...options }: RouterOptions = {},\n): ComponentConstructor<{}> {\n return defineComponent(\n (shadow) => {\n const href = useLocationHref();\n const routeMatch = useRef<RouteMatch | null>(null, { compare: compareRouteMatches });\n\n let prev:\n | { readonly component: CustomElementConstructor; readonly pattern: string; readonly element: HTMLElement }\n | undefined;\n\n useEffect([href], (href) => {\n const url = new URL(href);\n const segments = parsePath(url.pathname);\n\n for (const [pattern, { component, config, matcher }] of routeEntries.entries()) {\n const pathParams = matcher(segments);\n\n if (pathParams) {\n const searchParams = config.length >= 2 ? new URLSearchParams(url.search) : undefined;\n try {\n const resolvedConfig = config(pathParams, searchParams);\n routeMatch.value = { pattern, component, config: resolvedConfig, children: [] };\n return;\n } catch (error) {\n if (invalid) {\n routeMatch.value = {\n component: invalid,\n pattern: 'invalid',\n config: {\n 'data-error-name': error instanceof Error ? error.name : null,\n 'data-error-code': typeof (error as any)?.code === 'string' ? (error as any).code : null,\n },\n children: [error instanceof Error ? error.message : String(error)],\n };\n\n return;\n }\n\n console.warn(error);\n }\n }\n }\n\n routeMatch.value = fallback ? { component: fallback, pattern: 'fallback', config: {}, children: [] } : null;\n });\n\n useEffect([routeMatch], (routeMatch) => {\n if (!routeMatch) {\n html(shadow, []);\n return;\n }\n\n if (prev?.component === routeMatch.component && prev.pattern === routeMatch.pattern) {\n html(prev.element, routeMatch.config, routeMatch.children);\n return;\n }\n\n const element = html(routeMatch.component, routeMatch.config, routeMatch.children);\n html(shadow, [element]);\n prev = { component: routeMatch.component, pattern: routeMatch.pattern, element };\n });\n },\n { ...options, styles: [':host{display:contents;}'] },\n );\n}\n"],"mappings":";;;;;;;;AAsBA,SAAgB,EACd,GACA,EAAE,aAAU,YAAS,GAAG,MAA2B,EAAE,EAC3B;AAC1B,QAAO,GACJ,MAAW;EACV,IAAM,IAAO,GAAiB,EACxB,IAAa,EAA0B,MAAM,EAAE,SAAS,GAAqB,CAAC,EAEhF;AAwCJ,EApCA,EAAU,CAAC,EAAK,GAAG,MAAS;GAC1B,IAAM,IAAM,IAAI,IAAI,EAAK,EACnB,IAAW,EAAU,EAAI,SAAS;AAExC,QAAK,IAAM,CAAC,GAAS,EAAE,cAAW,WAAQ,iBAAc,EAAa,SAAS,EAAE;IAC9E,IAAM,IAAa,EAAQ,EAAS;AAEpC,QAAI,GAAY;KACd,IAAM,IAAe,EAAO,UAAU,IAAI,IAAI,gBAAgB,EAAI,OAAO,GAAG,KAAA;AAC5E,SAAI;AAEF,QAAW,QAAQ;OAAE;OAAS;OAAW,QADlB,EAAO,GAAY,EACO;OAAgB,UAAU,EAAE;OAAE;AAC/E;cACO,GAAO;AACd,UAA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