@spectrum-web-components/iconset 0.50.0-beta.7 → 0.50.0-beta.9

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spectrum-web-components/iconset",
3
- "version": "0.50.0-beta.7",
3
+ "version": "0.50.0-beta.9",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -60,7 +60,7 @@
60
60
  "lit-html"
61
61
  ],
62
62
  "dependencies": {
63
- "@spectrum-web-components/base": "^0.50.0-beta.7"
63
+ "@spectrum-web-components/base": "^0.50.0-beta.9"
64
64
  },
65
65
  "types": "./src/index.d.ts",
66
66
  "customElements": "custom-elements.json",
@@ -68,7 +68,8 @@
68
68
  "sideEffects": [
69
69
  "./src/index.js",
70
70
  "./stories/icons-demo.js",
71
+ "./stories/iconsList.json",
71
72
  "./**/*.dev.js"
72
73
  ],
73
- "gitHead": "8b6f00cd8d316f90897282a1842d05d5867891c2"
74
+ "gitHead": "c984cc2babbfecd14c86403ab920fbf6b0beb52c"
74
75
  }
@@ -16,7 +16,8 @@ import {
16
16
  } from "@spectrum-web-components/base";
17
17
  import {
18
18
  customElement,
19
- property
19
+ property,
20
+ state
20
21
  } from "@spectrum-web-components/base/src/decorators.js";
21
22
  import { ifDefined } from "@spectrum-web-components/base/src/directives.js";
22
23
  import "@spectrum-web-components/search/sp-search.js";
@@ -24,6 +25,11 @@ import "@spectrum-web-components/field-label/sp-field-label.js";
24
25
  import bodyStyles from "@spectrum-web-components/styles/body.js";
25
26
  import "@spectrum-web-components/icon/sp-icon.js";
26
27
  import "@spectrum-web-components/help-text/sp-help-text.js";
28
+ import iconsList from "./iconsList.json";
29
+ import {
30
+ SystemResolutionController,
31
+ systemResolverUpdatedSymbol
32
+ } from "@spectrum-web-components/reactive-controllers/src/SystemContextResolution.js";
27
33
  export let DelayedReady = class extends SpectrumElement {
28
34
  render() {
29
35
  return html`
@@ -61,17 +67,45 @@ export let IconsDemo = class extends SpectrumElement {
61
67
  this.size = "m";
62
68
  this.search = "";
63
69
  this.icons = [];
70
+ this.unsubscribeSystemContext = null;
71
+ this.spectrumVersion = 1;
64
72
  this.iconset = [];
73
+ this.systemResolver = new SystemResolutionController(this);
65
74
  this.iconset = [];
66
75
  this.handleIconSetAdded = this.handleIconSetAdded.bind(this);
67
76
  }
68
- connectedCallback() {
77
+ async connectedCallback() {
69
78
  super.connectedCallback();
79
+ this.requestSystemContext();
70
80
  window.addEventListener("sp-iconset-added", this.handleIconSetAdded);
71
81
  }
72
82
  disconnectedCallback() {
73
83
  window.removeEventListener("sp-iconset-added", this.handleIconSetAdded);
74
84
  super.disconnectedCallback();
85
+ if (this.unsubscribeSystemContext) {
86
+ this.unsubscribeSystemContext();
87
+ this.unsubscribeSystemContext = null;
88
+ }
89
+ }
90
+ requestSystemContext() {
91
+ this.dispatchEvent(
92
+ new CustomEvent("sp-system-context", {
93
+ detail: {
94
+ callback: (system, unsubscribe) => {
95
+ this.spectrumVersion = system === "spectrum-two" ? 2 : 1;
96
+ this.unsubscribeSystemContext = unsubscribe;
97
+ }
98
+ },
99
+ bubbles: true,
100
+ composed: true
101
+ })
102
+ );
103
+ }
104
+ update(changes) {
105
+ if (changes.has(systemResolverUpdatedSymbol)) {
106
+ this.spectrumVersion = this.systemResolver.system === "spectrum-two" ? 2 : 1;
107
+ }
108
+ super.update(changes);
75
109
  }
76
110
  handleIconSetAdded(event) {
77
111
  const { iconset } = event.detail;
@@ -156,9 +190,14 @@ export let IconsDemo = class extends SpectrumElement {
156
190
  this.updateSearch(event);
157
191
  }
158
192
  renderSearch() {
159
- const matchingIcons = this.search ? this.icons.filter(
160
- (icon) => icon.name.toLowerCase().search(this.search) !== -1
193
+ let matchingIcons = this.search ? this.icons.filter(
194
+ (icon) => icon.name.toLowerCase().includes(this.search.toLowerCase())
161
195
  ) : this.icons;
196
+ const iconVersion = this.spectrumVersion === 2 ? "s2" : "s1";
197
+ matchingIcons = matchingIcons.filter((icon) => {
198
+ const iconName = icon.name.replace(/\s/g, "").toLowerCase();
199
+ return iconsList[iconVersion].includes(iconName);
200
+ });
162
201
  return html`
163
202
  <div class="search" part="search">
164
203
  <sp-field-label for="search">Spectrum icons:</sp-field-label>
@@ -228,6 +267,9 @@ __decorateClass([
228
267
  __decorateClass([
229
268
  property({ attribute: false })
230
269
  ], IconsDemo.prototype, "icons", 2);
270
+ __decorateClass([
271
+ state()
272
+ ], IconsDemo.prototype, "spectrumVersion", 2);
231
273
  IconsDemo = __decorateClass([
232
274
  customElement("icons-demo")
233
275
  ], IconsDemo);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["icons-demo.ts"],
4
- "sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { IconsetAddedDetail } from '@spectrum-web-components/iconset';\nimport {\n css,\n CSSResultGroup,\n html,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport {\n customElement,\n property,\n} from '@spectrum-web-components/base/src/decorators.js';\nimport { ifDefined } from '@spectrum-web-components/base/src/directives.js';\nimport { Search } from '@spectrum-web-components/search';\nimport '@spectrum-web-components/search/sp-search.js';\nimport '@spectrum-web-components/field-label/sp-field-label.js';\nimport bodyStyles from '@spectrum-web-components/styles/body.js';\nimport '@spectrum-web-components/icon/sp-icon.js';\nimport '@spectrum-web-components/help-text/sp-help-text.js';\n\n@customElement('delayed-ready')\nexport class DelayedReady extends SpectrumElement {\n _delayedReady!: Promise<void>;\n _resolveDelayedReady!: () => void;\n\n protected override render(): TemplateResult {\n return html`\n <slot @slotchange=${this.handleSlotchange}></slot>\n `;\n }\n\n protected override firstUpdated(): void {\n this._delayedReady = new Promise(\n (res) => (this._resolveDelayedReady = res)\n );\n }\n\n protected override async getUpdateComplete(): Promise<boolean> {\n const complete = (await super.getUpdateComplete()) as boolean;\n await this._delayedReady;\n return complete;\n }\n\n public handleSlotchange({\n target,\n }: Event & { target: HTMLSlotElement }): void {\n if (target.assignedElements({ flatten: true }).length) {\n requestAnimationFrame(() => {\n this._resolveDelayedReady();\n });\n }\n }\n}\n\n@customElement('icons-demo')\nexport class IconsDemo extends SpectrumElement {\n @property()\n public name = 'ui';\n\n @property()\n public package = '';\n\n @property()\n public size = 'm';\n\n @property()\n public search = '';\n\n @property({ attribute: false })\n public icons: {\n name: string;\n story(size: string): TemplateResult;\n tag: string;\n }[] = [];\n\n private iconset: string[] = [];\n public constructor() {\n super();\n this.iconset = [];\n this.handleIconSetAdded = this.handleIconSetAdded.bind(this);\n }\n public override connectedCallback(): void {\n super.connectedCallback();\n window.addEventListener('sp-iconset-added', this.handleIconSetAdded);\n }\n public override disconnectedCallback(): void {\n window.removeEventListener('sp-iconset-added', this.handleIconSetAdded);\n super.disconnectedCallback();\n }\n public handleIconSetAdded(event: CustomEvent<IconsetAddedDetail>): void {\n const { iconset } = event.detail;\n this.iconset = iconset.getIconList();\n this.requestUpdate();\n }\n public static override get styles(): CSSResultGroup {\n return [\n ...bodyStyles,\n css`\n :host {\n display: grid;\n grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));\n gap: 20px;\n align-items: flex-start;\n }\n .icon {\n display: flex;\n flex-direction: column;\n align-items: center;\n text-align: center;\n border-radius: var(\n --spectrum-alias-focus-ring-gap,\n var(--spectrum-global-dimension-static-size-25)\n );\n }\n :host([package]) .icon {\n cursor: pointer;\n }\n sp-icon {\n margin-bottom: 10px;\n }\n .search {\n grid-column-start: 1;\n grid-column-end: -1;\n }\n .icon[tabindex]:focus {\n outline: none;\n }\n .icon[tabindex]:focus-visible {\n outline: var(--spectrum-alias-focus-ring-size) solid\n var(--spectrum-alias-focus-ring-color);\n outline-offset: calc(\n var(\n --spectrum-alias-focus-ring-gap,\n var(--spectrum-global-dimension-static-size-25)\n ) * 2\n );\n }\n `,\n ];\n }\n private handleKeydown(event: KeyboardEvent, tag: string): void {\n const { code } = event;\n if (code !== 'Enter' && code !== 'NumpadEnter' && code !== 'Space') {\n return;\n }\n event.preventDefault();\n this.shouldCopy(tag);\n }\n\n private shouldCopy(tag: string): void {\n if (!this.package) return;\n const conditionedTag = tag.slice(1, tag.length - 1);\n const importURL = `import '@spectrum-web-components/${this.package}/icons/${conditionedTag}.js';`;\n this.dispatchEvent(\n new CustomEvent('copy-text', {\n bubbles: true,\n composed: true,\n detail: {\n message: 'Import statement copied to clipboard!',\n text: importURL,\n },\n })\n );\n }\n private updateSearch(event: Event & { target: Search }): void {\n event.stopPropagation();\n this.search = event.target.value;\n }\n private submit(event: Event & { target: Search }): void {\n event.stopPropagation();\n this.updateSearch(event);\n }\n private renderSearch(): TemplateResult {\n const matchingIcons = this.search\n ? this.icons.filter(\n (icon) => icon.name.toLowerCase().search(this.search) !== -1\n )\n : this.icons;\n return html`\n <div class=\"search\" part=\"search\">\n <sp-field-label for=\"search\">Spectrum icons:</sp-field-label>\n <sp-search\n id=\"search\"\n @keydown=${this.updateSearch}\n @input=${this.updateSearch}\n @submit=${this.submit}\n .value=${this.search}\n label=\"Search for icons\"\n autocomplete=\"off\"\n >\n <sp-help-text slot=\"help-text\">\n Showing ${matchingIcons.length} of ${this.icons.length}\n available icons.\n </sp-help-text>\n </sp-search>\n </div>\n ${matchingIcons.map((icon) => {\n return html`\n <bdo\n class=\"icon\"\n part=\"icon\"\n dir=\"ltr\"\n class=\"icon\"\n @click=${() => this.shouldCopy(icon.tag)}\n @keydown=${(event: KeyboardEvent) =>\n this.handleKeydown(event, icon.tag)}\n tabindex=${ifDefined(this.package ? '0' : undefined)}\n >\n ${icon.story(this.size)} ${icon.tag}\n </bdo>\n `;\n })}\n `;\n }\n protected override render(): TemplateResult {\n return html`\n ${this.icons.length\n ? this.renderSearch()\n : html`\n <slot></slot>\n `}\n ${this.iconset.map(\n (icon) => html`\n <bdo class=\"icon\" dir=\"ltr\">\n <sp-icon\n size=\"xl\"\n name=${`${this.name}:${icon}`}\n ></sp-icon>\n ${icon}\n </bdo>\n `\n )}\n `;\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;AAYA;AAAA,EACI;AAAA,EAEA;AAAA,EACA;AAAA,OAEG;AACP;AAAA,EACI;AAAA,EACA;AAAA,OACG;AACP,SAAS,iBAAiB;AAE1B,OAAO;AACP,OAAO;AACP,OAAO,gBAAgB;AACvB,OAAO;AACP,OAAO;AAGA,WAAM,eAAN,cAA2B,gBAAgB;AAAA,EAI3B,SAAyB;AACxC,WAAO;AAAA,gCACiB,KAAK,gBAAgB;AAAA;AAAA,EAEjD;AAAA,EAEmB,eAAqB;AACpC,SAAK,gBAAgB,IAAI;AAAA,MACrB,CAAC,QAAS,KAAK,uBAAuB;AAAA,IAC1C;AAAA,EACJ;AAAA,EAEA,MAAyB,oBAAsC;AAC3D,UAAM,WAAY,MAAM,MAAM,kBAAkB;AAChD,UAAM,KAAK;AACX,WAAO;AAAA,EACX;AAAA,EAEO,iBAAiB;AAAA,IACpB;AAAA,EACJ,GAA8C;AAC1C,QAAI,OAAO,iBAAiB,EAAE,SAAS,KAAK,CAAC,EAAE,QAAQ;AACnD,4BAAsB,MAAM;AACxB,aAAK,qBAAqB;AAAA,MAC9B,CAAC;AAAA,IACL;AAAA,EACJ;AACJ;AA/Ba,eAAN;AAAA,EADN,cAAc,eAAe;AAAA,GACjB;AAkCN,WAAM,YAAN,cAAwB,gBAAgB;AAAA,EAqBpC,cAAc;AACjB,UAAM;AApBV,SAAO,OAAO;AAGd,SAAO,UAAU;AAGjB,SAAO,OAAO;AAGd,SAAO,SAAS;AAGhB,SAAO,QAID,CAAC;AAEP,SAAQ,UAAoB,CAAC;AAGzB,SAAK,UAAU,CAAC;AAChB,SAAK,qBAAqB,K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AS;AAAA,GADD,UAEF;AAGA;AAAA,EADN,SAAS;AAAA,GAJD,UAKF;AAGA;AAAA,EADN,SAAS;AAAA,GAPD,UAQF;AAGA;AAAA,EADN,SAAS;AAAA,GAVD,UAWF;AAGA;AAAA,EADN,SAAS,EAAE,WAAW,MAAM,CAAC;AAAA,GAbrB,UAcF;AAdE,YAAN;AAAA,EADN,cAAc,YAAY;AAAA,GACd;",
4
+ "sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { IconsetAddedDetail } from '@spectrum-web-components/iconset';\nimport {\n css,\n CSSResultGroup,\n html,\n PropertyValues,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport {\n customElement,\n property,\n state,\n} from '@spectrum-web-components/base/src/decorators.js';\nimport { ifDefined } from '@spectrum-web-components/base/src/directives.js';\nimport { Search } from '@spectrum-web-components/search';\nimport '@spectrum-web-components/search/sp-search.js';\nimport '@spectrum-web-components/field-label/sp-field-label.js';\nimport bodyStyles from '@spectrum-web-components/styles/body.js';\nimport '@spectrum-web-components/icon/sp-icon.js';\nimport '@spectrum-web-components/help-text/sp-help-text.js';\n\nimport iconsList from './iconsList.json' assert { type: 'json' };\n\nimport {\n SystemResolutionController,\n systemResolverUpdatedSymbol,\n} from '@spectrum-web-components/reactive-controllers/src/SystemContextResolution.js';\n\nimport type { SystemVariant } from '@spectrum-web-components/theme';\n\n@customElement('delayed-ready')\nexport class DelayedReady extends SpectrumElement {\n _delayedReady!: Promise<void>;\n _resolveDelayedReady!: () => void;\n\n protected override render(): TemplateResult {\n return html`\n <slot @slotchange=${this.handleSlotchange}></slot>\n `;\n }\n\n protected override firstUpdated(): void {\n this._delayedReady = new Promise(\n (res) => (this._resolveDelayedReady = res)\n );\n }\n\n protected override async getUpdateComplete(): Promise<boolean> {\n const complete = (await super.getUpdateComplete()) as boolean;\n await this._delayedReady;\n return complete;\n }\n\n public handleSlotchange({\n target,\n }: Event & { target: HTMLSlotElement }): void {\n if (target.assignedElements({ flatten: true }).length) {\n requestAnimationFrame(() => {\n this._resolveDelayedReady();\n });\n }\n }\n}\n\n@customElement('icons-demo')\nexport class IconsDemo extends SpectrumElement {\n @property()\n public name = 'ui';\n\n @property()\n public package = '';\n\n @property()\n public size = 'm';\n\n @property()\n public search = '';\n\n @property({ attribute: false })\n public icons: {\n name: string;\n story(size: string): TemplateResult;\n tag: string;\n }[] = [];\n\n private unsubscribeSystemContext: (() => void) | null = null;\n\n @state()\n public spectrumVersion = 1;\n\n private iconset: string[] = [];\n public constructor() {\n super();\n this.iconset = [];\n this.handleIconSetAdded = this.handleIconSetAdded.bind(this);\n }\n\n public override async connectedCallback(): Promise<void> {\n super.connectedCallback();\n this.requestSystemContext();\n window.addEventListener('sp-iconset-added', this.handleIconSetAdded);\n }\n public override disconnectedCallback(): void {\n window.removeEventListener('sp-iconset-added', this.handleIconSetAdded);\n super.disconnectedCallback();\n if (this.unsubscribeSystemContext) {\n this.unsubscribeSystemContext();\n this.unsubscribeSystemContext = null;\n }\n }\n\n private requestSystemContext(): void {\n this.dispatchEvent(\n new CustomEvent('sp-system-context', {\n detail: {\n callback: (\n system: SystemVariant,\n unsubscribe: () => void\n ) => {\n this.spectrumVersion =\n system === 'spectrum-two' ? 2 : 1;\n this.unsubscribeSystemContext = unsubscribe;\n },\n },\n bubbles: true,\n composed: true,\n })\n );\n }\n private systemResolver = new SystemResolutionController(this);\n\n protected override update(changes: PropertyValues): void {\n if (changes.has(systemResolverUpdatedSymbol)) {\n this.spectrumVersion =\n this.systemResolver.system === 'spectrum-two' ? 2 : 1;\n }\n\n super.update(changes);\n }\n\n public handleIconSetAdded(event: CustomEvent<IconsetAddedDetail>): void {\n const { iconset } = event.detail;\n this.iconset = iconset.getIconList();\n this.requestUpdate();\n }\n public static override get styles(): CSSResultGroup {\n return [\n ...bodyStyles,\n css`\n :host {\n display: grid;\n grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));\n gap: 20px;\n align-items: flex-start;\n }\n .icon {\n display: flex;\n flex-direction: column;\n align-items: center;\n text-align: center;\n border-radius: var(\n --spectrum-alias-focus-ring-gap,\n var(--spectrum-global-dimension-static-size-25)\n );\n }\n :host([package]) .icon {\n cursor: pointer;\n }\n sp-icon {\n margin-bottom: 10px;\n }\n .search {\n grid-column-start: 1;\n grid-column-end: -1;\n }\n .icon[tabindex]:focus {\n outline: none;\n }\n .icon[tabindex]:focus-visible {\n outline: var(--spectrum-alias-focus-ring-size) solid\n var(--spectrum-alias-focus-ring-color);\n outline-offset: calc(\n var(\n --spectrum-alias-focus-ring-gap,\n var(--spectrum-global-dimension-static-size-25)\n ) * 2\n );\n }\n `,\n ];\n }\n private handleKeydown(event: KeyboardEvent, tag: string): void {\n const { code } = event;\n if (code !== 'Enter' && code !== 'NumpadEnter' && code !== 'Space') {\n return;\n }\n event.preventDefault();\n this.shouldCopy(tag);\n }\n\n private shouldCopy(tag: string): void {\n if (!this.package) return;\n const conditionedTag = tag.slice(1, tag.length - 1);\n const importURL = `import '@spectrum-web-components/${this.package}/icons/${conditionedTag}.js';`;\n this.dispatchEvent(\n new CustomEvent('copy-text', {\n bubbles: true,\n composed: true,\n detail: {\n message: 'Import statement copied to clipboard!',\n text: importURL,\n },\n })\n );\n }\n private updateSearch(event: Event & { target: Search }): void {\n event.stopPropagation();\n this.search = event.target.value;\n }\n private submit(event: Event & { target: Search }): void {\n event.stopPropagation();\n this.updateSearch(event);\n }\n private renderSearch(): TemplateResult {\n let matchingIcons = this.search\n ? this.icons.filter((icon) =>\n icon.name.toLowerCase().includes(this.search.toLowerCase())\n )\n : this.icons;\n\n const iconVersion = this.spectrumVersion === 2 ? 's2' : 's1';\n // Filter out icons that are not in the current version\n matchingIcons = matchingIcons.filter((icon) => {\n const iconName = icon.name.replace(/\\s/g, '').toLowerCase();\n return iconsList[iconVersion].includes(iconName);\n });\n\n return html`\n <div class=\"search\" part=\"search\">\n <sp-field-label for=\"search\">Spectrum icons:</sp-field-label>\n <sp-search\n id=\"search\"\n @keydown=${this.updateSearch}\n @input=${this.updateSearch}\n @submit=${this.submit}\n .value=${this.search}\n label=\"Search for icons\"\n autocomplete=\"off\"\n >\n <sp-help-text slot=\"help-text\">\n Showing ${matchingIcons.length} of ${this.icons.length}\n available icons.\n </sp-help-text>\n </sp-search>\n </div>\n ${matchingIcons.map((icon) => {\n return html`\n <bdo\n class=\"icon\"\n part=\"icon\"\n dir=\"ltr\"\n class=\"icon\"\n @click=${() => this.shouldCopy(icon.tag)}\n @keydown=${(event: KeyboardEvent) =>\n this.handleKeydown(event, icon.tag)}\n tabindex=${ifDefined(this.package ? '0' : undefined)}\n >\n ${icon.story(this.size)} ${icon.tag}\n </bdo>\n `;\n })}\n `;\n }\n protected override render(): TemplateResult {\n return html`\n ${this.icons.length\n ? this.renderSearch()\n : html`\n <slot></slot>\n `}\n ${this.iconset.map(\n (icon) => html`\n <bdo class=\"icon\" dir=\"ltr\">\n <sp-icon\n size=\"xl\"\n name=${`${this.name}:${icon}`}\n ></sp-icon>\n ${icon}\n </bdo>\n `\n )}\n `;\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;AAYA;AAAA,EACI;AAAA,EAEA;AAAA,EAEA;AAAA,OAEG;AACP;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,OACG;AACP,SAAS,iBAAiB;AAE1B,OAAO;AACP,OAAO;AACP,OAAO,gBAAgB;AACvB,OAAO;AACP,OAAO;AAEP,OAAO,eAAe;AAEtB;AAAA,EACI;AAAA,EACA;AAAA,OACG;AAKA,WAAM,eAAN,cAA2B,gBAAgB;AAAA,EAI3B,SAAyB;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