@filip.mazev/blocks 1.4.3 → 1.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/_index.scss +1 -1
- package/core/styles/_field-state.scss +16 -4
- package/core/styles/_index.scss +0 -1
- package/core/styles/_mixins.scss +2 -2
- package/core/styles/_motion.scss +1 -1
- package/core/styles/_palettes.scss +127 -132
- package/core/styles/_slider.scss +158 -40
- package/core/styles/_theme-engine.scss +43 -63
- package/core/styles/_utilities.scss +3 -4
- package/core/styles/_validation.scss +6 -1
- package/core/styles/_variables.scss +24 -14
- package/core/styles/themes/_cyberpunk-theme.scss +1 -1
- package/core/styles/themes/_green-theme.scss +1 -1
- package/core/styles/themes/_high-contrast-theme.scss +152 -133
- package/core/styles/themes/_orange-theme.scss +1 -1
- package/core/styles/themes/_purple-theme.scss +1 -1
- package/core/styles/themes/_red-theme.scss +1 -1
- package/core/styles/themes/_white-theme.scss +26 -20
- package/effects/README.md +5 -9
- package/effects/effects.css +200 -121
- package/effects/runtime/README.md +19 -11
- package/fesm2022/filip.mazev-blocks-core.mjs +27 -22
- package/fesm2022/filip.mazev-blocks-core.mjs.map +1 -1
- package/fesm2022/filip.mazev-blocks-effects-runtime.mjs +887 -67
- package/fesm2022/filip.mazev-blocks-effects-runtime.mjs.map +1 -1
- package/fesm2022/filip.mazev-blocks-effects.mjs +8 -48
- package/fesm2022/filip.mazev-blocks-effects.mjs.map +1 -1
- package/fesm2022/filip.mazev-blocks-forms.mjs +65 -61
- package/fesm2022/filip.mazev-blocks-forms.mjs.map +1 -1
- package/fesm2022/filip.mazev-blocks-modal.mjs +29 -32
- package/fesm2022/filip.mazev-blocks-modal.mjs.map +1 -1
- package/fesm2022/filip.mazev-blocks-navigation.mjs +35 -1
- package/fesm2022/filip.mazev-blocks-navigation.mjs.map +1 -1
- package/fesm2022/filip.mazev-blocks-primitives.mjs +106 -32
- package/fesm2022/filip.mazev-blocks-primitives.mjs.map +1 -1
- package/fesm2022/filip.mazev-blocks-toastr.mjs +5 -7
- package/fesm2022/filip.mazev-blocks-toastr.mjs.map +1 -1
- package/fesm2022/filip.mazev-blocks.mjs +1 -1
- package/fesm2022/filip.mazev-blocks.mjs.map +1 -1
- package/navigation/README.md +44 -0
- package/package.json +1 -1
- package/schematics/ng-add/index.js +4 -1
- package/types/filip.mazev-blocks-core.d.ts +3 -4
- package/types/filip.mazev-blocks-effects-runtime.d.ts +10 -8
- package/types/filip.mazev-blocks-effects.d.ts +5 -17
- package/types/filip.mazev-blocks-forms.d.ts +13 -11
- package/types/filip.mazev-blocks-modal.d.ts +1 -0
- package/types/filip.mazev-blocks-navigation.d.ts +21 -5
- package/types/filip.mazev-blocks-primitives.d.ts +10 -0
- package/types/filip.mazev-blocks-toastr.d.ts +4 -4
- package/types/filip.mazev-blocks.d.ts +1 -1
|
@@ -9,20 +9,12 @@ var BxSurfaceDirective = class BxSurfaceDirective {
|
|
|
9
9
|
a11y = inject(BxA11yService);
|
|
10
10
|
zone = inject(NgZone);
|
|
11
11
|
isBrowser = isPlatformBrowser(inject(PLATFORM_ID));
|
|
12
|
-
bxSurface = input(void 0, {
|
|
13
|
-
...ngDevMode ? { debugName: "bxSurface" } : /* istanbul ignore next */ {},
|
|
14
|
-
transform: (value) => value || void 0
|
|
15
|
-
});
|
|
16
12
|
bxSurfaceInteractive = input(void 0, {
|
|
17
13
|
...ngDevMode ? { debugName: "bxSurfaceInteractive" } : /* istanbul ignore next */ {},
|
|
18
14
|
transform: optionalBoolean
|
|
19
15
|
});
|
|
20
|
-
|
|
21
|
-
...ngDevMode ? { debugName: "
|
|
22
|
-
transform: optionalNumber
|
|
23
|
-
});
|
|
24
|
-
bxSurfaceTint = input(void 0, {
|
|
25
|
-
...ngDevMode ? { debugName: "bxSurfaceTint" } : /* istanbul ignore next */ {},
|
|
16
|
+
bxSurfaceGlassiness = input(void 0, {
|
|
17
|
+
...ngDevMode ? { debugName: "bxSurfaceGlassiness" } : /* istanbul ignore next */ {},
|
|
26
18
|
transform: optionalNumber
|
|
27
19
|
});
|
|
28
20
|
bxSurfaceEmission = input(...ngDevMode ? [void 0, { debugName: "bxSurfaceEmission" }] : /* istanbul ignore next */ []);
|
|
@@ -50,12 +42,10 @@ var BxSurfaceDirective = class BxSurfaceDirective {
|
|
|
50
42
|
}
|
|
51
43
|
options() {
|
|
52
44
|
return {
|
|
53
|
-
|
|
45
|
+
glassiness: this.bxSurfaceGlassiness(),
|
|
54
46
|
interactive: this.bxSurfaceInteractive(),
|
|
55
47
|
reducedMotion: this.a11y.isReducedMotion(),
|
|
56
48
|
reducedTransparency: this.bxReducedTransparency(),
|
|
57
|
-
blur: this.bxSurfaceBlur(),
|
|
58
|
-
tint: this.bxSurfaceTint(),
|
|
59
49
|
emission: this.bxSurfaceEmission(),
|
|
60
50
|
focusEmission: this.bxSurfaceFocusEmission()
|
|
61
51
|
};
|
|
@@ -75,13 +65,6 @@ var BxSurfaceDirective = class BxSurfaceDirective {
|
|
|
75
65
|
isStandalone: true,
|
|
76
66
|
selector: "[bxSurface]",
|
|
77
67
|
inputs: {
|
|
78
|
-
bxSurface: {
|
|
79
|
-
classPropertyName: "bxSurface",
|
|
80
|
-
publicName: "bxSurface",
|
|
81
|
-
isSignal: true,
|
|
82
|
-
isRequired: false,
|
|
83
|
-
transformFunction: null
|
|
84
|
-
},
|
|
85
68
|
bxSurfaceInteractive: {
|
|
86
69
|
classPropertyName: "bxSurfaceInteractive",
|
|
87
70
|
publicName: "bxSurfaceInteractive",
|
|
@@ -89,16 +72,9 @@ var BxSurfaceDirective = class BxSurfaceDirective {
|
|
|
89
72
|
isRequired: false,
|
|
90
73
|
transformFunction: null
|
|
91
74
|
},
|
|
92
|
-
|
|
93
|
-
classPropertyName: "
|
|
94
|
-
publicName: "
|
|
95
|
-
isSignal: true,
|
|
96
|
-
isRequired: false,
|
|
97
|
-
transformFunction: null
|
|
98
|
-
},
|
|
99
|
-
bxSurfaceTint: {
|
|
100
|
-
classPropertyName: "bxSurfaceTint",
|
|
101
|
-
publicName: "bxSurfaceTint",
|
|
75
|
+
bxSurfaceGlassiness: {
|
|
76
|
+
classPropertyName: "bxSurfaceGlassiness",
|
|
77
|
+
publicName: "bxSurfaceGlassiness",
|
|
102
78
|
isSignal: true,
|
|
103
79
|
isRequired: false,
|
|
104
80
|
transformFunction: null
|
|
@@ -144,14 +120,6 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
144
120
|
}],
|
|
145
121
|
ctorParameters: () => [],
|
|
146
122
|
propDecorators: {
|
|
147
|
-
bxSurface: [{
|
|
148
|
-
type: i0.Input,
|
|
149
|
-
args: [{
|
|
150
|
-
isSignal: true,
|
|
151
|
-
alias: "bxSurface",
|
|
152
|
-
required: false
|
|
153
|
-
}]
|
|
154
|
-
}],
|
|
155
123
|
bxSurfaceInteractive: [{
|
|
156
124
|
type: i0.Input,
|
|
157
125
|
args: [{
|
|
@@ -160,19 +128,11 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
160
128
|
required: false
|
|
161
129
|
}]
|
|
162
130
|
}],
|
|
163
|
-
|
|
164
|
-
type: i0.Input,
|
|
165
|
-
args: [{
|
|
166
|
-
isSignal: true,
|
|
167
|
-
alias: "bxSurfaceBlur",
|
|
168
|
-
required: false
|
|
169
|
-
}]
|
|
170
|
-
}],
|
|
171
|
-
bxSurfaceTint: [{
|
|
131
|
+
bxSurfaceGlassiness: [{
|
|
172
132
|
type: i0.Input,
|
|
173
133
|
args: [{
|
|
174
134
|
isSignal: true,
|
|
175
|
-
alias: "
|
|
135
|
+
alias: "bxSurfaceGlassiness",
|
|
176
136
|
required: false
|
|
177
137
|
}]
|
|
178
138
|
}],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filip.mazev-blocks-effects.mjs","names":[],"sources":["../../../projects/blocks/effects/directives/surface.directive.ts","../../../projects/blocks/effects/component-surface.ts","../../../projects/blocks/effects/lighting.service.ts"],"sourcesContent":["import { isPlatformBrowser } from '@angular/common';\nimport { AfterViewInit, booleanAttribute, DestroyRef, Directive, effect, ElementRef, inject, input, NgZone, numberAttribute, PLATFORM_ID } from '@angular/core';\nimport { BxA11yService, ThemingService } from '@filip.mazev/blocks/core';\nimport { GlassMaterial, mountSurface, SurfaceOptions } from '@filip.mazev/blocks/effects/runtime';\n\n/** Adds a decorative material without replacing native controls or their content. */\n@Directive({\n selector: '[bxSurface]',\n standalone: true,\n exportAs: 'bxSurface'\n})\nexport class BxSurfaceDirective implements AfterViewInit {\n private readonly element = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly theme = inject(ThemingService);\n private readonly a11y = inject(BxA11yService);\n private readonly zone = inject(NgZone);\n private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n public readonly bxSurface = input<GlassMaterial | undefined, GlassMaterial | '' | undefined>(undefined, { transform: (value) => value || undefined });\n public readonly bxSurfaceInteractive = input<boolean | undefined, unknown>(undefined, { transform: optionalBoolean });\n public readonly bxSurfaceBlur = input<number | undefined, unknown>(undefined, { transform: optionalNumber });\n public readonly bxSurfaceTint = input<number | undefined, unknown>(undefined, { transform: optionalNumber });\n public readonly bxSurfaceEmission = input<string | undefined>();\n public readonly bxSurfaceFocusEmission = input<string | undefined>();\n public readonly bxReducedTransparency = input<boolean | undefined, unknown>(undefined, {\n transform: optionalBoolean\n });\n\n private surface?: ReturnType<typeof mountSurface>;\n\n constructor() {\n effect(() => {\n const options = this.options();\n this.zone.runOutsideAngular(() => this.surface?.update(options));\n });\n\n inject(DestroyRef).onDestroy(() => {\n this.surface?.destroy();\n this.surface = undefined;\n });\n }\n\n public ngAfterViewInit(): void {\n if (this.isBrowser) {\n const options = this.options();\n this.surface = this.zone.runOutsideAngular(() => mountSurface(this.element.nativeElement, options));\n }\n }\n\n private options(): SurfaceOptions {\n return {\n material: this.bxSurface(),\n interactive: this.bxSurfaceInteractive(),\n reducedMotion: this.a11y.isReducedMotion(),\n reducedTransparency: this.bxReducedTransparency(),\n blur: this.bxSurfaceBlur(),\n tint: this.bxSurfaceTint(),\n emission: this.bxSurfaceEmission(),\n focusEmission: this.bxSurfaceFocusEmission()\n };\n }\n}\n\nfunction optionalNumber(value: unknown): number | undefined {\n return value === undefined || value === null ? undefined : numberAttribute(value);\n}\n\nfunction optionalBoolean(value: unknown): boolean | undefined {\n return value === undefined || value === null ? undefined : booleanAttribute(value);\n}\n","import { isPlatformBrowser } from '@angular/common';\nimport { afterNextRender, DestroyRef, effect, ElementRef, inject, NgZone, PLATFORM_ID } from '@angular/core';\nimport { BxA11yService, ThemingService } from '@filip.mazev/blocks/core';\nimport { mountSurface, SurfaceOptions } from '@filip.mazev/blocks/effects/runtime';\n\n/** Internal component integration. An explicit bxSurface directive takes precedence. */\nexport function injectComponentSurface(options: () => SurfaceOptions = () => ({})): void {\n const element = inject<ElementRef<HTMLElement>>(ElementRef);\n const zone = inject(NgZone);\n const a11y = inject(BxA11yService);\n inject(ThemingService);\n let surface: ReturnType<typeof mountSurface> | undefined;\n const browser = isPlatformBrowser(inject(PLATFORM_ID));\n effect(() => {\n const current = { ...options(), reducedMotion: a11y.isReducedMotion() };\n zone.runOutsideAngular(() => surface?.update(current));\n });\n afterNextRender(() => {\n if (browser && !element.nativeElement.hasAttribute('data-bx-surface')) {\n surface = zone.runOutsideAngular(() =>\n mountSurface(element.nativeElement, {\n ...options(),\n reducedMotion: a11y.isReducedMotion()\n })\n );\n }\n });\n inject(DestroyRef).onDestroy(() => surface?.destroy());\n}\n","import { Injectable, NgZone, inject } from '@angular/core';\nimport { GlassLight, GlassScene, mountGlassScene } from '@filip.mazev/blocks/effects/runtime';\n\nexport interface BxGlassLight {\n update(light: GlassLight): void;\n destroy(): void;\n}\n\n/** Combine local semantic emitters without replacing another field's or toast's light. */\n@Injectable({ providedIn: 'root' })\nexport class BxGlassLightingService {\n private readonly zone = inject(NgZone);\n private readonly groups = new Map<HTMLElement, { scene: GlassScene; lights: Map<symbol, GlassLight> }>();\n\n register(root: HTMLElement, light: GlassLight): BxGlassLight {\n let group = this.groups.get(root);\n if (!group) {\n group = { scene: this.zone.runOutsideAngular(() => mountGlassScene(root)), lights: new Map() };\n this.groups.set(root, group);\n }\n const current = group;\n const id = Symbol();\n let disposed = false;\n const sync = () => this.zone.runOutsideAngular(() => current.scene.update({ lights: [...current.lights.values()] }));\n current.lights.set(id, light);\n sync();\n return {\n update: (next) => {\n if (!disposed) {\n current.lights.set(id, next);\n sync();\n }\n },\n destroy: () => {\n if (disposed) return;\n disposed = true;\n current.lights.delete(id);\n if (current.lights.size) sync();\n else {\n this.zone.runOutsideAngular(() => current.scene.destroy());\n this.groups.delete(root);\n }\n }\n };\n }\n}\n"],"mappings":";;;;;AAWA,IAAa,qBAAb,MAAa,mBAAkB;CACZ,UAAU,OAAgC,UAAU;CACpD,QAAQ,OAAO,cAAc;CAC7B,OAAO,OAAO,aAAa;CAC3B,OAAO,OAAO,MAAM;CACpB,YAAY,kBAAkB,OAAO,WAAW,CAAC;CAClD,YAAY,MAAiE,QAAS;EAAA,GAAA,YAAA,EAAA,WAAA,YAAA,+BAAA,CAAA;EAAI,YAAY,UAAU,SAAS;CAAS,CAAA;CAClI,uBAAuB,MAAoC,QAAS;EAAA,GAAA,YAAA,EAAA,WAAA,uBAAA,+BAAA,CAAA;EAAI,WAAW;CAAe,CAAA;CAClG,gBAAgB,MAAmC,QAAS;EAAA,GAAA,YAAA,EAAA,WAAA,gBAAA,+BAAA,CAAA;EAAI,WAAW;CAAc,CAAA;CACzF,gBAAgB,MAAmC,QAAS;EAAA,GAAA,YAAA,EAAA,WAAA,gBAAA,+BAAA,CAAA;EAAI,WAAW;CAAc,CAAA;CACzF,oBAAoB,MAA2B,GAAA,YAAA,CAAA,QAAA,EAAA,WAAA,oBAAA,CAAA,+BAAA,CAAA,CAAA;CAC/C,yBAAyB,MAA2B,GAAA,YAAA,CAAA,QAAA,EAAA,WAAA,yBAAA,CAAA,+BAAA,CAAA,CAAA;CACpD,wBAAwB,MAAoC,QAAS;EA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nB,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAsB,YAAA,CAAA;EADlC,MAAA;EAAW,MAAA,CAAA,EAAE,YAAY,OAAM,CAAE"}
|
|
1
|
+
{"version":3,"file":"filip.mazev-blocks-effects.mjs","names":[],"sources":["../../../projects/blocks/effects/directives/surface.directive.ts","../../../projects/blocks/effects/component-surface.ts","../../../projects/blocks/effects/lighting.service.ts"],"sourcesContent":["import { isPlatformBrowser } from '@angular/common';\nimport { AfterViewInit, booleanAttribute, DestroyRef, Directive, effect, ElementRef, inject, input, NgZone, numberAttribute, PLATFORM_ID } from '@angular/core';\nimport { BxA11yService, ThemingService } from '@filip.mazev/blocks/core';\nimport { mountSurface, SurfaceOptions } from '@filip.mazev/blocks/effects/runtime';\n\n/** Adds a decorative material without replacing native controls or their content. */\n@Directive({\n selector: '[bxSurface]',\n standalone: true,\n exportAs: 'bxSurface'\n})\nexport class BxSurfaceDirective implements AfterViewInit {\n private readonly element = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly theme = inject(ThemingService);\n private readonly a11y = inject(BxA11yService);\n private readonly zone = inject(NgZone);\n private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n public readonly bxSurfaceInteractive = input<boolean | undefined, unknown>(undefined, { transform: optionalBoolean });\n public readonly bxSurfaceGlassiness = input<number | undefined, unknown>(undefined, { transform: optionalNumber });\n public readonly bxSurfaceEmission = input<string | undefined>();\n public readonly bxSurfaceFocusEmission = input<string | undefined>();\n public readonly bxReducedTransparency = input<boolean | undefined, unknown>(undefined, {\n transform: optionalBoolean\n });\n\n private surface?: ReturnType<typeof mountSurface>;\n\n constructor() {\n effect(() => {\n const options = this.options();\n this.zone.runOutsideAngular(() => this.surface?.update(options));\n });\n\n inject(DestroyRef).onDestroy(() => {\n this.surface?.destroy();\n this.surface = undefined;\n });\n }\n\n public ngAfterViewInit(): void {\n if (this.isBrowser) {\n const options = this.options();\n this.surface = this.zone.runOutsideAngular(() => mountSurface(this.element.nativeElement, options));\n }\n }\n\n private options(): SurfaceOptions {\n return {\n glassiness: this.bxSurfaceGlassiness(),\n interactive: this.bxSurfaceInteractive(),\n reducedMotion: this.a11y.isReducedMotion(),\n reducedTransparency: this.bxReducedTransparency(),\n emission: this.bxSurfaceEmission(),\n focusEmission: this.bxSurfaceFocusEmission()\n };\n }\n}\n\nfunction optionalNumber(value: unknown): number | undefined {\n return value === undefined || value === null ? undefined : numberAttribute(value);\n}\n\nfunction optionalBoolean(value: unknown): boolean | undefined {\n return value === undefined || value === null ? undefined : booleanAttribute(value);\n}\n","import { isPlatformBrowser } from '@angular/common';\nimport { afterNextRender, DestroyRef, effect, ElementRef, inject, NgZone, PLATFORM_ID } from '@angular/core';\nimport { BxA11yService, ThemingService } from '@filip.mazev/blocks/core';\nimport { mountSurface, SurfaceOptions } from '@filip.mazev/blocks/effects/runtime';\n\n/** Internal component integration. An explicit bxSurface directive takes precedence. */\nexport function injectComponentSurface(options: () => SurfaceOptions = () => ({})): void {\n const element = inject<ElementRef<HTMLElement>>(ElementRef);\n const zone = inject(NgZone);\n const a11y = inject(BxA11yService);\n inject(ThemingService);\n let surface: ReturnType<typeof mountSurface> | undefined;\n const browser = isPlatformBrowser(inject(PLATFORM_ID));\n effect(() => {\n const current = { ...options(), reducedMotion: a11y.isReducedMotion() };\n zone.runOutsideAngular(() => surface?.update(current));\n });\n afterNextRender(() => {\n if (browser && !element.nativeElement.hasAttribute('data-bx-surface')) {\n surface = zone.runOutsideAngular(() =>\n mountSurface(element.nativeElement, {\n ...options(),\n reducedMotion: a11y.isReducedMotion()\n })\n );\n }\n });\n inject(DestroyRef).onDestroy(() => surface?.destroy());\n}\n","import { Injectable, NgZone, inject } from '@angular/core';\nimport { GlassLight, GlassScene, mountGlassScene } from '@filip.mazev/blocks/effects/runtime';\n\nexport interface BxGlassLight {\n update(light: GlassLight): void;\n destroy(): void;\n}\n\n/** Combine local semantic emitters without replacing another field's or toast's light. */\n@Injectable({ providedIn: 'root' })\nexport class BxGlassLightingService {\n private readonly zone = inject(NgZone);\n private readonly groups = new Map<HTMLElement, { scene: GlassScene; lights: Map<symbol, GlassLight> }>();\n\n public register(root: HTMLElement, light: GlassLight): BxGlassLight {\n let group = this.groups.get(root);\n if (!group) {\n group = { scene: this.zone.runOutsideAngular(() => mountGlassScene(root)), lights: new Map() };\n this.groups.set(root, group);\n }\n const current = group;\n const id = Symbol();\n let disposed = false;\n const sync = () => this.zone.runOutsideAngular(() => current.scene.update({ lights: [...current.lights.values()] }));\n current.lights.set(id, light);\n sync();\n return {\n update: (next) => {\n if (!disposed) {\n current.lights.set(id, next);\n sync();\n }\n },\n destroy: () => {\n if (disposed) return;\n disposed = true;\n current.lights.delete(id);\n if (current.lights.size) sync();\n else {\n this.zone.runOutsideAngular(() => current.scene.destroy());\n this.groups.delete(root);\n }\n }\n };\n }\n}\n"],"mappings":";;;;;AAWA,IAAa,qBAAb,MAAa,mBAAkB;CACZ,UAAU,OAAgC,UAAU;CACpD,QAAQ,OAAO,cAAc;CAC7B,OAAO,OAAO,aAAa;CAC3B,OAAO,OAAO,MAAM;CACpB,YAAY,kBAAkB,OAAO,WAAW,CAAC;CAClD,uBAAuB,MAAoC,QAAS;EAAA,GAAA,YAAA,EAAA,WAAA,uBAAA,+BAAA,CAAA;EAAI,WAAW;CAAe,CAAA;CAClG,sBAAsB,MAAmC,QAAS;EAAA,GAAA,YAAA,EAAA,WAAA,sBAAA,+BAAA,CAAA;EAAI,WAAW;CAAc,CAAA;CAC/F,oBAAoB,MAA2B,GAAA,YAAA,CAAA,QAAA,EAAA,WAAA,oBAAA,CAAA,+BAAA,CAAA,CAAA;CAC/C,yBAAyB,MAA2B,GAAA,YAAA,CAAA,QAAA,EAAA,WAAA,yBAAA,CAAA,+BAAA,CAAA,CAAA;CACpD,wBAAwB,MAAoC,QAAS;EAAA,GAAA,YAAA,EAAA,WAAA,wBAAA,+BAAA,CAAA;EACnF,WAAW;CAAe,CAAA;CA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