@memberjunction/ng-ui-components 6.2.0-edge.2 → 6.2.0-edge.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.
Files changed (36) hide show
  1. package/README.md +1 -1
  2. package/dist/lib/accordion/accordion.component.d.ts +14 -4
  3. package/dist/lib/accordion/accordion.component.d.ts.map +1 -1
  4. package/dist/lib/accordion/accordion.component.js +96 -46
  5. package/dist/lib/accordion/accordion.component.js.map +1 -1
  6. package/dist/lib/accordion/accordion.scss +54 -5
  7. package/dist/lib/button/button.directive.d.ts +27 -15
  8. package/dist/lib/button/button.directive.d.ts.map +1 -1
  9. package/dist/lib/button/button.directive.js +34 -19
  10. package/dist/lib/button/button.directive.js.map +1 -1
  11. package/dist/lib/button/button.scss +35 -0
  12. package/dist/lib/dropdown/dropdown.component.d.ts +22 -0
  13. package/dist/lib/dropdown/dropdown.component.d.ts.map +1 -1
  14. package/dist/lib/dropdown/dropdown.component.js +43 -6
  15. package/dist/lib/dropdown/dropdown.component.js.map +1 -1
  16. package/dist/lib/icon-picker/font-awesome-icons.d.ts +130 -0
  17. package/dist/lib/icon-picker/font-awesome-icons.d.ts.map +1 -0
  18. package/dist/lib/icon-picker/font-awesome-icons.js +256 -0
  19. package/dist/lib/icon-picker/font-awesome-icons.js.map +1 -0
  20. package/dist/lib/icon-picker/icon-catalogue.service.d.ts +71 -0
  21. package/dist/lib/icon-picker/icon-catalogue.service.d.ts.map +1 -0
  22. package/dist/lib/icon-picker/icon-catalogue.service.js +153 -0
  23. package/dist/lib/icon-picker/icon-catalogue.service.js.map +1 -0
  24. package/dist/lib/icon-picker/icon-picker.component.d.ts +117 -0
  25. package/dist/lib/icon-picker/icon-picker.component.d.ts.map +1 -0
  26. package/dist/lib/icon-picker/icon-picker.component.js +362 -0
  27. package/dist/lib/icon-picker/icon-picker.component.js.map +1 -0
  28. package/dist/lib/menu/menu.component.d.ts +64 -0
  29. package/dist/lib/menu/menu.component.d.ts.map +1 -0
  30. package/dist/lib/menu/menu.component.js +149 -0
  31. package/dist/lib/menu/menu.component.js.map +1 -0
  32. package/dist/public-api.d.ts +4 -0
  33. package/dist/public-api.d.ts.map +1 -1
  34. package/dist/public-api.js +4 -0
  35. package/dist/public-api.js.map +1 -1
  36. package/package.json +2 -2
@@ -0,0 +1,153 @@
1
+ import { Injectable } from '@angular/core';
2
+ import { FALLBACK_ICONS, ProbeIconStyleFonts, ResolveIconStyles, ScanLoadedIconRules, } from './font-awesome-icons';
3
+ import * as i0 from "@angular/core";
4
+ /**
5
+ * The Font Awesome icons this page can draw, worked out once and shared.
6
+ *
7
+ * Answering it means walking every CSS rule in the document and then measuring a couple of
8
+ * thousand glyphs, so it is done on first ask and kept. A picker that recomputed per open
9
+ * would stall each time it was used.
10
+ */
11
+ export class IconCatalogueService {
12
+ catalogue = null;
13
+ loading = null;
14
+ fallback = false;
15
+ /**
16
+ * Every icon on offer, with the style that draws it.
17
+ *
18
+ * Each style has to be FETCHED before it can be measured. A browser loads a web font
19
+ * only when something on the page uses it, so an app drawing solid icons has the solid
20
+ * font and neither of the others — and measuring then reports every brands and regular
21
+ * icon as missing, which is most of the catalogue.
22
+ *
23
+ * Falls back to a short built-in list when the stylesheets cannot be read — a
24
+ * cross-origin sheet without CORS headers throws on `cssRules` — or when reading them
25
+ * fails in any other way, so the picker always has something to show.
26
+ */
27
+ async Load(doc = document) {
28
+ if (this.catalogue)
29
+ return this.catalogue;
30
+ if (!this.loading) {
31
+ this.loading = this.build(doc).catch(() => {
32
+ this.loading = null;
33
+ return this.useFallback();
34
+ });
35
+ }
36
+ return this.loading;
37
+ }
38
+ /**
39
+ * What is known right now, without waiting.
40
+ *
41
+ * Empty until {@link Load} has finished, which is the honest answer: a caller that
42
+ * rendered this before the fonts arrived would draw the short fallback list and then
43
+ * replace it, which reads as the picker changing its mind.
44
+ */
45
+ Icons() {
46
+ return this.catalogue ?? [];
47
+ }
48
+ /** True when the built-in list is standing in because the page could not be read. */
49
+ IsFallback() {
50
+ return this.fallback;
51
+ }
52
+ /** Forgets the catalogue, for a page that loads a different icon set later. */
53
+ Forget() {
54
+ this.catalogue = null;
55
+ this.loading = null;
56
+ this.fallback = false;
57
+ }
58
+ async build(doc) {
59
+ const rules = ScanLoadedIconRules(doc);
60
+ const fonts = rules.length > 0 ? ProbeIconStyleFonts(doc) : [];
61
+ const ready = await this.fetchFonts(doc, fonts);
62
+ const measure = ready.length > 0 ? this.glyphTest(doc) : null;
63
+ const resolved = measure ? ResolveIconStyles(rules, fonts, measure) : [];
64
+ if (resolved.length === 0)
65
+ return this.useFallback();
66
+ this.fallback = false;
67
+ this.catalogue = resolved;
68
+ return this.catalogue;
69
+ }
70
+ /** Keeps the short built-in list as the catalogue. */
71
+ useFallback() {
72
+ this.fallback = true;
73
+ this.catalogue = [...FALLBACK_ICONS];
74
+ return this.catalogue;
75
+ }
76
+ /**
77
+ * Fetch each style's font file, returning the ones that arrived.
78
+ *
79
+ * `document.fonts.load` resolves once the face is usable by canvas. A style that fails
80
+ * to load is dropped rather than measured, because measuring it would report every one
81
+ * of its icons as missing and quietly halve the catalogue.
82
+ */
83
+ async fetchFonts(doc, fonts) {
84
+ const faces = doc.fonts;
85
+ if (!faces?.load)
86
+ return [...fonts];
87
+ const results = await Promise.all(fonts.map(async (font) => {
88
+ try {
89
+ const loaded = await faces.load(`${font.FontWeight} 16px ${font.FontFamily}`);
90
+ return loaded.length > 0 ? font : null;
91
+ }
92
+ catch {
93
+ // A face the browser refuses to load cannot be measured either.
94
+ return null;
95
+ }
96
+ }));
97
+ return results.filter((font) => font !== null);
98
+ }
99
+ /**
100
+ * A test for whether a font really has a glyph, by measuring it.
101
+ *
102
+ * The family is named ALONE, with no fallback behind it, and the glyph's width is
103
+ * compared against a codepoint no icon font defines. A glyph the font lacks is drawn
104
+ * by the browser's last-resort font, exactly as the control is, so the two measure the
105
+ * same — while a glyph it has measures at the icon's own advance width.
106
+ *
107
+ * Comparing against the same family instead of against a second font stack is what
108
+ * makes this sound. Font Awesome Free ships two faces under ONE family name, solid at
109
+ * weight 900 and regular at 400, so a glyph missing from the requested weight is drawn
110
+ * from the other one before any fallback is reached — and a comparison that assumed
111
+ * the fallback had been reached read that as a hit.
112
+ *
113
+ * Returns null where there is no canvas to measure with, in which case the caller
114
+ * falls back rather than offering every icon in every style.
115
+ */
116
+ glyphTest(doc) {
117
+ const context = doc.createElement('canvas').getContext('2d');
118
+ if (!context)
119
+ return null;
120
+ const widths = new Map();
121
+ const measure = (glyph, font) => {
122
+ const key = font + '|' + glyph;
123
+ let width = widths.get(key);
124
+ if (width === undefined) {
125
+ context.font = font;
126
+ width = context.measureText(glyph).width;
127
+ widths.set(key, width);
128
+ }
129
+ return width;
130
+ };
131
+ return (glyph, font) => {
132
+ if (!glyph)
133
+ return false;
134
+ const face = font.FontWeight + ' 48px ' + font.FontFamily;
135
+ const width = measure(glyph, face);
136
+ return width > 0 && width !== measure(ABSENT_GLYPH, face);
137
+ };
138
+ }
139
+ static ɵfac = function IconCatalogueService_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || IconCatalogueService)(); };
140
+ static ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: IconCatalogueService, factory: IconCatalogueService.ɵfac, providedIn: 'root' });
141
+ }
142
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(IconCatalogueService, [{
143
+ type: Injectable,
144
+ args: [{ providedIn: 'root' }]
145
+ }], null, null); })();
146
+ /**
147
+ * A codepoint no icon font defines, for measuring what "missing" looks like.
148
+ *
149
+ * Plane 16's private-use area, which Font Awesome does not reach into — its own icons sit
150
+ * in the basic-plane private-use area — so every font draws this as its last-resort box.
151
+ */
152
+ const ABSENT_GLYPH = String.fromCodePoint(0x10FFFD);
153
+ //# sourceMappingURL=icon-catalogue.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"icon-catalogue.service.js","sourceRoot":"","sources":["../../../src/lib/icon-picker/icon-catalogue.service.ts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AC,UAAU,CAAC;YAC1D,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;YACnC,OAAO,KAAK,GAAG,CAAC,IAAI,KAAK,KAAK,OAAO,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;QAC9D,CAAC,CAAC;IACN,CAAC;8GAjIQ,oBAAoB;gEAApB,oBAAoB,WAApB,oBAAoB,mBADP,MAAM;;iFACnB,oBAAoB;cADhC,UAAU;eAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;AAqIlC;;;;;GAKG;AACH,MAAM,YAAY,GAAG,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC","sourcesContent":["import { Injectable } from '@angular/core';\nimport {\n FALLBACK_ICONS,\n ProbeIconStyleFonts,\n ResolveIconStyles,\n ScanLoadedIconRules,\n type FontAwesomeIcon,\n type IconStyleFont,\n} from './font-awesome-icons';\n\n/**\n * The Font Awesome icons this page can draw, worked out once and shared.\n *\n * Answering it means walking every CSS rule in the document and then measuring a couple of\n * thousand glyphs, so it is done on first ask and kept. A picker that recomputed per open\n * would stall each time it was used.\n */\n@Injectable({ providedIn: 'root' })\nexport class IconCatalogueService {\n private catalogue: FontAwesomeIcon[] | null = null;\n private loading: Promise<readonly FontAwesomeIcon[]> | null = null;\n private fallback = false;\n\n /**\n * Every icon on offer, with the style that draws it.\n *\n * Each style has to be FETCHED before it can be measured. A browser loads a web font\n * only when something on the page uses it, so an app drawing solid icons has the solid\n * font and neither of the others — and measuring then reports every brands and regular\n * icon as missing, which is most of the catalogue.\n *\n * Falls back to a short built-in list when the stylesheets cannot be read — a\n * cross-origin sheet without CORS headers throws on `cssRules` — or when reading them\n * fails in any other way, so the picker always has something to show.\n */\n public async Load(doc: Document = document): Promise<readonly FontAwesomeIcon[]> {\n if (this.catalogue) return this.catalogue;\n if (!this.loading) {\n this.loading = this.build(doc).catch(() => {\n this.loading = null;\n return this.useFallback();\n });\n }\n return this.loading;\n }\n\n /**\n * What is known right now, without waiting.\n *\n * Empty until {@link Load} has finished, which is the honest answer: a caller that\n * rendered this before the fonts arrived would draw the short fallback list and then\n * replace it, which reads as the picker changing its mind.\n */\n public Icons(): readonly FontAwesomeIcon[] {\n return this.catalogue ?? [];\n }\n\n /** True when the built-in list is standing in because the page could not be read. */\n public IsFallback(): boolean {\n return this.fallback;\n }\n\n /** Forgets the catalogue, for a page that loads a different icon set later. */\n public Forget(): void {\n this.catalogue = null;\n this.loading = null;\n this.fallback = false;\n }\n\n private async build(doc: Document): Promise<readonly FontAwesomeIcon[]> {\n const rules = ScanLoadedIconRules(doc);\n const fonts = rules.length > 0 ? ProbeIconStyleFonts(doc) : [];\n const ready = await this.fetchFonts(doc, fonts);\n const measure = ready.length > 0 ? this.glyphTest(doc) : null;\n const resolved = measure ? ResolveIconStyles(rules, fonts, measure) : [];\n if (resolved.length === 0) return this.useFallback();\n this.fallback = false;\n this.catalogue = resolved;\n return this.catalogue;\n }\n\n /** Keeps the short built-in list as the catalogue. */\n private useFallback(): readonly FontAwesomeIcon[] {\n this.fallback = true;\n this.catalogue = [...FALLBACK_ICONS];\n return this.catalogue;\n }\n\n /**\n * Fetch each style's font file, returning the ones that arrived.\n *\n * `document.fonts.load` resolves once the face is usable by canvas. A style that fails\n * to load is dropped rather than measured, because measuring it would report every one\n * of its icons as missing and quietly halve the catalogue.\n */\n private async fetchFonts(doc: Document, fonts: readonly IconStyleFont[]): Promise<IconStyleFont[]> {\n const faces = doc.fonts;\n if (!faces?.load) return [...fonts];\n const results = await Promise.all(fonts.map(async (font) => {\n try {\n const loaded = await faces.load(`${font.FontWeight} 16px ${font.FontFamily}`);\n return loaded.length > 0 ? font : null;\n } catch {\n // A face the browser refuses to load cannot be measured either.\n return null;\n }\n }));\n return results.filter((font): font is IconStyleFont => font !== null);\n }\n\n /**\n * A test for whether a font really has a glyph, by measuring it.\n *\n * The family is named ALONE, with no fallback behind it, and the glyph's width is\n * compared against a codepoint no icon font defines. A glyph the font lacks is drawn\n * by the browser's last-resort font, exactly as the control is, so the two measure the\n * same — while a glyph it has measures at the icon's own advance width.\n *\n * Comparing against the same family instead of against a second font stack is what\n * makes this sound. Font Awesome Free ships two faces under ONE family name, solid at\n * weight 900 and regular at 400, so a glyph missing from the requested weight is drawn\n * from the other one before any fallback is reached — and a comparison that assumed\n * the fallback had been reached read that as a hit.\n *\n * Returns null where there is no canvas to measure with, in which case the caller\n * falls back rather than offering every icon in every style.\n */\n private glyphTest(doc: Document): ((glyph: string, font: IconStyleFont) => boolean) | null {\n const context = doc.createElement('canvas').getContext('2d');\n if (!context) return null;\n const widths = new Map<string, number>();\n const measure = (glyph: string, font: string): number => {\n const key = font + '|' + glyph;\n let width = widths.get(key);\n if (width === undefined) {\n context.font = font;\n width = context.measureText(glyph).width;\n widths.set(key, width);\n }\n return width;\n };\n return (glyph: string, font: IconStyleFont): boolean => {\n if (!glyph) return false;\n const face = font.FontWeight + ' 48px ' + font.FontFamily;\n const width = measure(glyph, face);\n return width > 0 && width !== measure(ABSENT_GLYPH, face);\n };\n }\n}\n\n/**\n * A codepoint no icon font defines, for measuring what \"missing\" looks like.\n *\n * Plane 16's private-use area, which Font Awesome does not reach into — its own icons sit\n * in the basic-plane private-use area — so every font draws this as its last-resort box.\n */\nconst ABSENT_GLYPH = String.fromCodePoint(0x10FFFD);\n"]}
@@ -0,0 +1,117 @@
1
+ import { EventEmitter } from '@angular/core';
2
+ import { ControlValueAccessor } from '@angular/forms';
3
+ import { ConnectedPosition } from '@angular/cdk/overlay';
4
+ import { type FontAwesomeIcon } from './font-awesome-icons';
5
+ import * as i0 from "@angular/core";
6
+ /**
7
+ * mj-icon-picker — choose a Font Awesome icon by looking at it.
8
+ *
9
+ * Typing a class name is not something to ask of a user: the name has to be remembered
10
+ * exactly, and Font Awesome needs a style class beside it — `fa-chart-column` on its own
11
+ * renders nothing at all, which looks like a bug rather than a missing word. This searches
12
+ * the icons the page has actually loaded and writes a complete class string.
13
+ *
14
+ * The text box stays, because a user who knows the name is faster typing it, and because a
15
+ * value from elsewhere must remain editable. What it emits is normalized either way.
16
+ *
17
+ * The grid opens in an overlay rather than inside the field. Anchored in the field it sat
18
+ * in whatever scrolling box the host had, widened that box and left the surrounding panel
19
+ * scrolling sideways — a picker must not resize the form it is part of.
20
+ *
21
+ * @example
22
+ * ```html
23
+ * <mj-icon-picker [(ngModel)]="Icon" Placeholder="Search icons"></mj-icon-picker>
24
+ * ```
25
+ */
26
+ export declare class MjIconPickerComponent implements ControlValueAccessor {
27
+ /** The icon class string, e.g. `fa-solid fa-chart-column`. */
28
+ set Value(value: string);
29
+ get Value(): string;
30
+ ValueChange: EventEmitter<string>;
31
+ Placeholder: string;
32
+ /** Accessible name for the text box, when no visible label sits beside it. */
33
+ AriaLabel: string;
34
+ /** Disables both the box and the browse button. */
35
+ Disabled: boolean;
36
+ /** The style given to a name typed by hand, when it names none itself. */
37
+ Style: string;
38
+ private _value;
39
+ private readonly host;
40
+ private readonly cdr;
41
+ private readonly catalogue;
42
+ private searchBox?;
43
+ private browseButton?;
44
+ /** What is in the text box, which may not yet be a complete class string. */
45
+ Text: string;
46
+ /** Whether the icon grid is open. */
47
+ IsOpen: boolean;
48
+ /** Width the overlay opens at, so the grid is usable beside a narrow field. */
49
+ static readonly GRID_WIDTH = 320;
50
+ readonly GridWidth = 320;
51
+ /** Below the field, or above it when there is no room. */
52
+ readonly Positions: ConnectedPosition[];
53
+ /** What the user typed into the grid's own search box. */
54
+ get Search(): string;
55
+ /**
56
+ * Setting it marks the view, because this component is OnPush and the search may be
57
+ * set by a host as well as by the box — a value that does not repaint the grid is
58
+ * worse than no search at all.
59
+ */
60
+ set Search(value: string);
61
+ private search;
62
+ /** The icon drawn in the preview, or '' when nothing is set. */
63
+ get Preview(): string;
64
+ /** The current icon's bare name, for the grid's selected state. */
65
+ get SelectedName(): string;
66
+ /** The icons to show, narrowed by the grid's search box: at most {@link ICON_RESULT_LIMIT}. */
67
+ get Results(): FontAwesomeIcon[];
68
+ /** How many icons match the search, including the ones past the grid's limit. */
69
+ get MatchCount(): number;
70
+ /** True when more icons match than the grid draws, so the user is told to narrow the search. */
71
+ get IsCapped(): boolean;
72
+ /** "Showing N of M icons…" while the grid is cut short; empty otherwise. */
73
+ get CapNote(): string;
74
+ private matchMemo;
75
+ /** Every icon matching the search, worked out once per catalogue and search. */
76
+ private matches;
77
+ /** Whether a grid cell is the current icon, under its own name or one of its aliases. */
78
+ IsSelected(icon: FontAwesomeIcon): boolean;
79
+ /** Every icon on offer, each with the style that actually draws it. */
80
+ get Icons(): readonly FontAwesomeIcon[];
81
+ /** True when the page could not be read and the short list is standing in. */
82
+ get IsFallbackCatalogue(): boolean;
83
+ /** True while the icon fonts are being fetched so their glyphs can be measured. */
84
+ IsLoading: boolean;
85
+ private get ownerDocument();
86
+ /** The complete class string for one grid cell. */
87
+ ClassFor(icon: FontAwesomeIcon): string;
88
+ Toggle(): void;
89
+ /**
90
+ * Read the catalogue, showing a wait while the icon fonts arrive.
91
+ *
92
+ * They have to be fetched before their glyphs can be measured, and a browser fetches
93
+ * a web font only when the page uses it — so on an app that draws solid icons the
94
+ * other styles are not there yet. Rendering the grid before they land would show it
95
+ * missing every brands and regular icon, then fill them in, which reads as a bug.
96
+ */
97
+ private loadCatalogue;
98
+ /** Closes the grid and puts focus back on the browse button. */
99
+ Close(): void;
100
+ /** Typed text is normalized on the way out, so a bare name still renders. */
101
+ OnTextChanged(raw: string): void;
102
+ /** Writes the icon in the style that draws it, not in whatever the field defaulted to. */
103
+ Choose(icon: FontAwesomeIcon): void;
104
+ /** Clears the icon. A panel with none is a normal thing to want. */
105
+ Clear(): void;
106
+ private commit;
107
+ private onChange;
108
+ private onTouched;
109
+ writeValue(value: string | null): void;
110
+ registerOnChange(fn: (value: string) => void): void;
111
+ registerOnTouched(fn: () => void): void;
112
+ setDisabledState(disabled: boolean): void;
113
+ OnBlur(): void;
114
+ static ɵfac: i0.ɵɵFactoryDeclaration<MjIconPickerComponent, never>;
115
+ static ɵcmp: i0.ɵɵComponentDeclaration<MjIconPickerComponent, "mj-icon-picker", never, { "Value": { "alias": "Value"; "required": false; }; "Placeholder": { "alias": "Placeholder"; "required": false; }; "AriaLabel": { "alias": "AriaLabel"; "required": false; }; "Disabled": { "alias": "Disabled"; "required": false; }; "Style": { "alias": "Style"; "required": false; }; }, { "ValueChange": "ValueChange"; }, never, never, true, never>;
116
+ }
117
+ //# sourceMappingURL=icon-picker.component.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"icon-picker.component.d.ts","sourceRoot":"","sources":["../../../src/lib/icon-picker/icon-picker.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAKH,YAAY,EAMf,MAAM,eAAe,CAAC;AACvB,OAAO,EAAqB,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACzE,OAAO,EAAiB,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAMH,KAAK,eAAe,EACvB,MAAM,sBAAsB,CAAC;;AAG9B;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBASa,qBAAsB,YAAW,oBAAoB;IAC9D,8DAA8D;IAC9D,IACI,KAAK,CAAC,KAAK,EAAE,MAAM,EAGtB;IACD,IAAI,KAAK,IAAI,MAAM,CAAwB;IAEjC,WAAW,uBAA8B;IAE1C,WAAW,SAAmC;IAEvD,8EAA8E;IACrE,SAAS,SAAU;IAE5B,mDAAmD;IAC1C,QAAQ,UAAS;IAE1B,0EAA0E;IACjE,KAAK,SAAsB;IAEpC,OAAO,CAAC,MAAM,CAAM;IACpB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAmC;IACxD,OAAO,CAAC,QAAQ,CAAC,GAAG,CAA6B;IACjD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAgC;IAErC,OAAO,CAAC,SAAS,CAAC,CAA+B;IACjD,OAAO,CAAC,YAAY,CAAC,CAAgC;IAE1E,6EAA6E;IACtE,IAAI,SAAM;IAEjB,qCAAqC;IAC9B,MAAM,UAAS;IAEtB,+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