• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2024-2025 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15/* THIS IS AUTOGENERATED FILE, PLEASE DON`T CHANGE IT MANUALLY */
16class ArkResourcesHelper {
17    static $r(name, id) {
18        let splitted = name.split('.', 2);
19        let strType = splitted[1];
20        let type = undefined;
21        switch (strType) {
22            case 'float':
23                type = ArkResourcesHelper.FLOAT;
24                break;
25            case 'color':
26            default:
27                type = ArkResourcesHelper.COLOR;
28                break;
29        }
30        return { 'id': id !== null && id !== void 0 ? id : -1, 'type': type, 'params': [name], 'bundleName': '', 'moduleName': '' };
31    }
32}
33ArkResourcesHelper.COLOR = 10001;
34ArkResourcesHelper.FLOAT = 10002;
35class ArkThemeNativeHelper {
36    static sendThemeToNative(theme, elmtId) {
37        WithTheme.sendThemeToNative(ArkThemeNativeHelper.convertThemeToColorArray(theme), elmtId);
38    }
39    static createInternal(themeScopeId, themeId, theme, colorMode, onThemeScopeDestroy) {
40        if (colorMode && colorMode !== ThemeColorMode.SYSTEM) {
41            ArkThemeScopeManager.getInstance().onEnterLocalColorMode(colorMode);
42        }
43        getUINativeModule().theme.createAndBindTheme(themeScopeId, themeId, ArkThemeNativeHelper.convertColorsToArray(theme === null || theme === void 0 ? void 0 : theme.colors), colorMode, onThemeScopeDestroy);
44        if (colorMode && colorMode !== ThemeColorMode.SYSTEM) {
45            ArkThemeScopeManager.getInstance().onExitLocalColorMode();
46        }
47    }
48    static setDefaultTheme(theme) {
49        const colorArray = ArkThemeNativeHelper.convertColorsToArray(theme === null || theme === void 0 ? void 0 : theme.colors);
50        ArkThemeScopeManager.getInstance().onEnterLocalColorMode(ThemeColorMode.LIGHT);
51        getUINativeModule().theme.setDefaultTheme(colorArray, false);
52        ArkThemeScopeManager.getInstance().onEnterLocalColorMode(ThemeColorMode.DARK);
53        getUINativeModule().theme.setDefaultTheme(colorArray, true);
54        ArkThemeScopeManager.getInstance().onExitLocalColorMode();
55    }
56    static convertThemeToColorArray(theme) {
57        return [
58            theme.colors.brand,
59            theme.colors.warning,
60            theme.colors.alert,
61            theme.colors.confirm,
62            theme.colors.fontPrimary,
63            theme.colors.fontSecondary,
64            theme.colors.fontTertiary,
65            theme.colors.fontFourth,
66            theme.colors.fontEmphasize,
67            theme.colors.fontOnPrimary,
68            theme.colors.fontOnSecondary,
69            theme.colors.fontOnTertiary,
70            theme.colors.fontOnFourth,
71            theme.colors.iconPrimary,
72            theme.colors.iconSecondary,
73            theme.colors.iconTertiary,
74            theme.colors.iconFourth,
75            theme.colors.iconEmphasize,
76            theme.colors.iconSubEmphasize,
77            theme.colors.iconOnPrimary,
78            theme.colors.iconOnSecondary,
79            theme.colors.iconOnTertiary,
80            theme.colors.iconOnFourth,
81            theme.colors.backgroundPrimary,
82            theme.colors.backgroundSecondary,
83            theme.colors.backgroundTertiary,
84            theme.colors.backgroundFourth,
85            theme.colors.backgroundEmphasize,
86            theme.colors.compForegroundPrimary,
87            theme.colors.compBackgroundPrimary,
88            theme.colors.compBackgroundPrimaryTran,
89            theme.colors.compBackgroundPrimaryContrary,
90            theme.colors.compBackgroundGray,
91            theme.colors.compBackgroundSecondary,
92            theme.colors.compBackgroundTertiary,
93            theme.colors.compBackgroundEmphasize,
94            theme.colors.compBackgroundNeutral,
95            theme.colors.compEmphasizeSecondary,
96            theme.colors.compEmphasizeTertiary,
97            theme.colors.compDivider,
98            theme.colors.compCommonContrary,
99            theme.colors.compBackgroundFocus,
100            theme.colors.compFocusedPrimary,
101            theme.colors.compFocusedSecondary,
102            theme.colors.compFocusedTertiary,
103            theme.colors.interactiveHover,
104            theme.colors.interactivePressed,
105            theme.colors.interactiveFocus,
106            theme.colors.interactiveActive,
107            theme.colors.interactiveSelect,
108            theme.colors.interactiveClick,
109        ];
110    }
111    static convertColorsToArray(colors) {
112        const basisColors = ArkThemeScopeManager.getSystemColors();
113        if (!colors) {
114            return new Array(Object.keys(basisColors).length).fill(undefined);
115        }
116        const colorArray = [];
117        for (let attr in basisColors) {
118            colorArray.push(colors[attr]);
119        }
120        return colorArray;
121    }
122}
123globalThis.LazyForEach.getItemGeneratorForThemeSupport = function (paramItemGenerator) {
124    const themeScope = ArkThemeScopeManager.getInstance().lastLocalThemeScope();
125    if (themeScope === undefined) {
126        return paramItemGenerator;
127    }
128    const itemGeneratorWrapper = (...params) => {
129        const result = ArkThemeScopeManager.getInstance().onDeepRenderScopeEnter(themeScope);
130        paramItemGenerator(...params);
131        if (result === true) {
132            ArkThemeScopeManager.getInstance().onDeepRenderScopeExit();
133        }
134    };
135    return itemGeneratorWrapper;
136};
137if (globalThis.WithTheme !== undefined) {
138    globalThis.ListItem.getDeepRenderFuncForThemeSupport = function (deepRenderFunction) {
139        const themeScope = ArkThemeScopeManager.getInstance().lastLocalThemeScope();
140        if (themeScope === undefined) {
141            return deepRenderFunction;
142        }
143        const deepRenderFunctionWrapper = (elmtId, isInitialRender) => {
144            const result = ArkThemeScopeManager.getInstance().onDeepRenderScopeEnter(themeScope);
145            deepRenderFunction(elmtId, isInitialRender);
146            if (result === true) {
147                ArkThemeScopeManager.getInstance().onDeepRenderScopeExit();
148            }
149        };
150        return deepRenderFunctionWrapper;
151    };
152}
153class ArkThemeCache {
154    constructor() {
155        this.cache = [];
156    }
157    static getInstance() {
158        if (!ArkThemeCache.instance) {
159            ArkThemeCache.instance = new ArkThemeCache();
160        }
161        return ArkThemeCache.instance;
162    }
163    add(theme) {
164        if (this.contains(theme)) {
165            return;
166        }
167        this.cache.push(theme);
168    }
169    remove(theme) {
170        const index = this.cache.indexOf(theme);
171        if (index == -1) {
172            return;
173        }
174        this.cache.splice(index, 1);
175        getUINativeModule().theme.removeFromCache(theme.id);
176    }
177    get(baselineThemeId, customTheme, colorMode) {
178        return this.cache.find((item) => {
179            return item.getParentThemeId() === baselineThemeId &&
180                item.getColorMode() === colorMode &&
181                this.isEqualsCustomThemes(item.getCustomTheme(), customTheme);
182        });
183    }
184    contains(theme) {
185        return this.containsByAttributes(theme.getParentThemeId(), theme.getCustomTheme(), theme.getColorMode());
186    }
187    containsByAttributes(baselineThemeId, customTheme, colorMode) {
188        return this.get(baselineThemeId, customTheme, colorMode) !== undefined;
189    }
190    isEqualsCustomThemes(theme1, theme2) {
191        if (theme1 === theme2) {
192            return true;
193        }
194        if (!theme1 || !theme2) {
195            return false;
196        }
197        if (theme1.colors === theme2.colors) {
198            return true;
199        }
200        if (!theme1.colors || !theme2.colors) {
201            return false;
202        }
203        let keys1 = Object.keys(theme1.colors);
204        let keys2 = Object.keys(theme2.colors);
205        if (keys1.length !== keys2.length) {
206            return false;
207        }
208        for (let key of keys1) {
209            if (!keys2.includes(key)) {
210                return false;
211            }
212            let value1 = theme1.colors[key];
213            let value2 = theme2.colors[key];
214            if (value1 !== value2) {
215                return false;
216            }
217        }
218        return true;
219    }
220}
221let themeCounter = 0;
222class ArkThemeBase {
223    constructor(parentId, customTheme, colorMode, colors, shapes, typography) {
224        this.scopesCounter = 0;
225        this.bindedThemeScopesIds = [];
226        this.isJustCreated = true;
227        this.parentThemeId = -1;
228        this.id = themeCounter++;
229        this.parentThemeId = parentId;
230        this.customTheme = ArkThemeBase.copyCustomTheme(customTheme);
231        this.colorMode = colorMode;
232        this.colors = colors;
233        this.shapes = shapes;
234        this.typography = typography;
235    }
236    bindToScope(themeScopeId) {
237        if (this.bindedThemeScopesIds.includes(themeScopeId)) {
238            return;
239        }
240        this.scopesCounter++;
241        this.bindedThemeScopesIds.push(themeScopeId);
242        if (this.isJustCreated) {
243            ArkThemeCache.getInstance().add(this);
244            this.isJustCreated = false;
245        }
246    }
247    unbindFromScope(themeScopeId) {
248        const index = this.bindedThemeScopesIds.indexOf(themeScopeId);
249        if (index == -1) {
250            return;
251        }
252        this.scopesCounter--;
253        this.bindedThemeScopesIds.splice(index, 1);
254        if (this.canBeDestroyed()) {
255            ArkThemeCache.getInstance().remove(this);
256        }
257    }
258    canBeDestroyed() {
259        return !this.isJustCreated && this.scopesCounter === 0;
260    }
261    getParentThemeId() {
262        return this.parentThemeId;
263    }
264    getCustomTheme() {
265        return this.customTheme;
266    }
267    getColorMode() {
268        return this.colorMode;
269    }
270    static copyCustomTheme(customTheme) {
271        if (!customTheme) {
272            return undefined;
273        }
274        const copyTheme = {};
275        if (customTheme.colors) {
276            copyTheme.colors = {};
277            Object.assign(copyTheme.colors, customTheme.colors);
278        }
279        if (customTheme.shapes) {
280            copyTheme.shapes = {};
281            Object.assign(copyTheme.shapes, customTheme.shapes);
282        }
283        if (customTheme.typography) {
284            copyTheme.typography = {};
285            Object.assign(copyTheme.typography, customTheme.typography);
286        }
287        return copyTheme;
288    }
289}
290class ArkSystemColors {
291    constructor() {
292        this.brand = ArkResourcesHelper.$r('sys.color.brand', 125830976);
293        this.warning = ArkResourcesHelper.$r('sys.color.warning', 125830979);
294        this.alert = ArkResourcesHelper.$r('sys.color.alert', 125830980);
295        this.confirm = ArkResourcesHelper.$r('sys.color.confirm', 125830981);
296        this.fontPrimary = ArkResourcesHelper.$r('sys.color.font_primary', 125830982);
297        this.fontSecondary = ArkResourcesHelper.$r('sys.color.font_secondary', 125830983);
298        this.fontTertiary = ArkResourcesHelper.$r('sys.color.font_tertiary', 125830984);
299        this.fontFourth = ArkResourcesHelper.$r('sys.color.font_fourth', 125830985);
300        this.fontEmphasize = ArkResourcesHelper.$r('sys.color.font_emphasize', 125830986);
301        this.fontOnPrimary = ArkResourcesHelper.$r('sys.color.font_on_primary', 125830987);
302        this.fontOnSecondary = ArkResourcesHelper.$r('sys.color.font_on_secondary', 125830988);
303        this.fontOnTertiary = ArkResourcesHelper.$r('sys.color.font_on_tertiary', 125830989);
304        this.fontOnFourth = ArkResourcesHelper.$r('sys.color.font_on_fourth', 125830990);
305        this.iconPrimary = ArkResourcesHelper.$r('sys.color.icon_primary', 125830991);
306        this.iconSecondary = ArkResourcesHelper.$r('sys.color.icon_secondary', 125830992);
307        this.iconTertiary = ArkResourcesHelper.$r('sys.color.icon_tertiary', 125830993);
308        this.iconFourth = ArkResourcesHelper.$r('sys.color.icon_fourth', 125830994);
309        this.iconEmphasize = ArkResourcesHelper.$r('sys.color.icon_emphasize', 125830995);
310        this.iconSubEmphasize = ArkResourcesHelper.$r('sys.color.icon_sub_emphasize', 125830996);
311        this.iconOnPrimary = ArkResourcesHelper.$r('sys.color.icon_on_primary', 125831057);
312        this.iconOnSecondary = ArkResourcesHelper.$r('sys.color.icon_on_secondary', 125831058);
313        this.iconOnTertiary = ArkResourcesHelper.$r('sys.color.icon_on_tertiary', 125831059);
314        this.iconOnFourth = ArkResourcesHelper.$r('sys.color.icon_on_fourth', 125831060);
315        this.backgroundPrimary = ArkResourcesHelper.$r('sys.color.background_primary', 125831061);
316        this.backgroundSecondary = ArkResourcesHelper.$r('sys.color.background_secondary', 125831062);
317        this.backgroundTertiary = ArkResourcesHelper.$r('sys.color.background_tertiary', 125831063);
318        this.backgroundFourth = ArkResourcesHelper.$r('sys.color.background_fourth', 125831064);
319        this.backgroundEmphasize = ArkResourcesHelper.$r('sys.color.background_emphasize', 125831065);
320        this.compForegroundPrimary = ArkResourcesHelper.$r('sys.color.comp_foreground_primary', 125831003);
321        this.compBackgroundPrimary = ArkResourcesHelper.$r('sys.color.comp_background_primary', 125831004);
322        this.compBackgroundPrimaryTran = ArkResourcesHelper.$r('sys.color.comp_background_primary_tran');
323        this.compBackgroundPrimaryContrary = ArkResourcesHelper.$r('sys.color.comp_background_primary_contrary', 125831005);
324        this.compBackgroundGray = ArkResourcesHelper.$r('sys.color.comp_background_gray', 125831006);
325        this.compBackgroundSecondary = ArkResourcesHelper.$r('sys.color.comp_background_secondary', 125831007);
326        this.compBackgroundTertiary = ArkResourcesHelper.$r('sys.color.comp_background_tertiary', 125831008);
327        this.compBackgroundEmphasize = ArkResourcesHelper.$r('sys.color.comp_background_emphasize', 125831009);
328        this.compBackgroundNeutral = ArkResourcesHelper.$r('sys.color.neutral', 125831066);
329        this.compEmphasizeSecondary = ArkResourcesHelper.$r('sys.color.comp_emphasize_secondary', 125831011);
330        this.compEmphasizeTertiary = ArkResourcesHelper.$r('sys.color.comp_emphasize_tertiary', 125831012);
331        this.compDivider = ArkResourcesHelper.$r('sys.color.comp_divider', 125831013);
332        this.compCommonContrary = ArkResourcesHelper.$r('sys.color.comp_common_contrary', 125831014);
333        this.compBackgroundFocus = ArkResourcesHelper.$r('sys.color.comp_background_focus', 125831015);
334        this.compFocusedPrimary = ArkResourcesHelper.$r('sys.color.comp_focused_primary', 125831016);
335        this.compFocusedSecondary = ArkResourcesHelper.$r('sys.color.comp_focused_secondary', 125831017);
336        this.compFocusedTertiary = ArkResourcesHelper.$r('sys.color.comp_focused_tertiary', 125831018);
337        this.interactiveHover = ArkResourcesHelper.$r('sys.color.interactive_hover', 125831019);
338        this.interactivePressed = ArkResourcesHelper.$r('sys.color.interactive_pressed', 125831020);
339        this.interactiveFocus = ArkResourcesHelper.$r('sys.color.interactive_focus', 125831021);
340        this.interactiveActive = ArkResourcesHelper.$r('sys.color.interactive_active', 125831022);
341        this.interactiveSelect = ArkResourcesHelper.$r('sys.color.interactive_select', 125831023);
342        this.interactiveClick = ArkResourcesHelper.$r('sys.color.interactive_click', 125831024);
343    }
344}
345class ArkSystemCornerRadius {
346    constructor() {
347        this.none = ArkResourcesHelper.$r('sys.float.corner_radius_none');
348        this.level1 = ArkResourcesHelper.$r('sys.float.corner_radius_level1');
349        this.level2 = ArkResourcesHelper.$r('sys.float.corner_radius_level2');
350        this.level3 = ArkResourcesHelper.$r('sys.float.corner_radius_level3');
351        this.level4 = ArkResourcesHelper.$r('sys.float.corner_radius_level4');
352        this.level5 = ArkResourcesHelper.$r('sys.float.corner_radius_level5');
353        this.level6 = ArkResourcesHelper.$r('sys.float.corner_radius_level6');
354        this.level7 = ArkResourcesHelper.$r('sys.float.corner_radius_level7');
355        this.level8 = ArkResourcesHelper.$r('sys.float.corner_radius_level8');
356        this.level9 = ArkResourcesHelper.$r('sys.float.corner_radius_level9');
357        this.level10 = ArkResourcesHelper.$r('sys.float.corner_radius_level10');
358        this.level11 = ArkResourcesHelper.$r('sys.float.corner_radius_level11');
359        this.level12 = ArkResourcesHelper.$r('sys.float.corner_radius_level12');
360        this.level16 = ArkResourcesHelper.$r('sys.float.corner_radius_level16');
361    }
362}
363class ArkSystemPaddings {
364    constructor() {
365        this.level0 = ArkResourcesHelper.$r('sys.float.padding_level0');
366        this.level1 = ArkResourcesHelper.$r('sys.float.padding_level1');
367        this.level2 = ArkResourcesHelper.$r('sys.float.padding_level2');
368        this.level3 = ArkResourcesHelper.$r('sys.float.padding_level3');
369        this.level4 = ArkResourcesHelper.$r('sys.float.padding_level4');
370        this.level5 = ArkResourcesHelper.$r('sys.float.padding_level5');
371        this.level6 = ArkResourcesHelper.$r('sys.float.padding_level6');
372        this.level7 = ArkResourcesHelper.$r('sys.float.padding_level7');
373        this.level8 = ArkResourcesHelper.$r('sys.float.padding_level8');
374        this.level9 = ArkResourcesHelper.$r('sys.float.padding_level9');
375        this.level10 = ArkResourcesHelper.$r('sys.float.padding_level10');
376        this.level11 = ArkResourcesHelper.$r('sys.float.padding_level11');
377        this.level12 = ArkResourcesHelper.$r('sys.float.padding_level12');
378        this.level16 = ArkResourcesHelper.$r('sys.float.padding_level16');
379        this.level24 = ArkResourcesHelper.$r('sys.float.padding_level24');
380        this.level32 = ArkResourcesHelper.$r('sys.float.padding_level32');
381        this.level36 = ArkResourcesHelper.$r('sys.float.padding_level36');
382    }
383}
384class ArkSystemOutlines {
385    constructor() {
386        this.none = ArkResourcesHelper.$r('sys.float.outline_none');
387        this.xs = ArkResourcesHelper.$r('sys.float.outline_extra_small');
388        this.s = ArkResourcesHelper.$r('sys.float.outline_small');
389        this.m = ArkResourcesHelper.$r('sys.float.outline_medium');
390        this.l = ArkResourcesHelper.$r('sys.float.outline_larger');
391        this.xl = ArkResourcesHelper.$r('sys.float.outline_extra_larger');
392    }
393}
394class ArkSystemBorders {
395    constructor() {
396        this.none = ArkResourcesHelper.$r('sys.float.border_none');
397        this.xs = ArkResourcesHelper.$r('sys.float.border_extra_small');
398        this.s = ArkResourcesHelper.$r('sys.float.border_small');
399        this.m = ArkResourcesHelper.$r('sys.float.border_medium');
400        this.l = ArkResourcesHelper.$r('sys.float.border_larger');
401        this.xl = ArkResourcesHelper.$r('sys.float.border_extra_larger');
402    }
403}
404class ArkSystemShapes {
405    constructor() {
406        this.cornerRadius = new ArkSystemCornerRadius();
407        this.paddings = new ArkSystemPaddings();
408        this.borders = new ArkSystemBorders();
409        this.outlines = new ArkSystemOutlines();
410    }
411}
412class ArkTypographyWeights {
413}
414ArkTypographyWeights.thin = 100;
415ArkTypographyWeights.ultralight = 200;
416ArkTypographyWeights.light = 300;
417ArkTypographyWeights.regular = 400;
418ArkTypographyWeights.medium = 500;
419ArkTypographyWeights.semibold = 600;
420ArkTypographyWeights.bold = 700;
421ArkTypographyWeights.heavy = 800;
422ArkTypographyWeights.black = 900;
423class ArkSystemTypography {
424    constructor() {
425        this.displayLarge = {
426            weight: ArkTypographyWeights.light,
427            size: ArkResourcesHelper.$r('sys.float.Display_L')
428        };
429        this.displayMiddle = {
430            weight: ArkTypographyWeights.light,
431            size: ArkResourcesHelper.$r('sys.float.Display_M')
432        };
433        this.displaySmall = {
434            weight: ArkTypographyWeights.light,
435            size: ArkResourcesHelper.$r('sys.float.Display_S')
436        };
437        this.titleLarge = {
438            weight: ArkTypographyWeights.bold,
439            size: ArkResourcesHelper.$r('sys.float.Title_L')
440        };
441        this.titleMiddle = {
442            weight: ArkTypographyWeights.bold,
443            size: ArkResourcesHelper.$r('sys.float.Title_M')
444        };
445        this.titleSmall = {
446            weight: ArkTypographyWeights.bold,
447            size: ArkResourcesHelper.$r('sys.float.Title_S')
448        };
449        this.subtitleLarge = {
450            weight: ArkTypographyWeights.medium,
451            size: ArkResourcesHelper.$r('sys.float.Subtitle_L')
452        };
453        this.subtitleMiddle = {
454            weight: ArkTypographyWeights.medium,
455            size: ArkResourcesHelper.$r('sys.float.Subtitle_M')
456        };
457        this.subtitleSmall = {
458            weight: ArkTypographyWeights.medium,
459            size: ArkResourcesHelper.$r('sys.float.Subtitle_S')
460        };
461        this.bodyLarge = {
462            weight: ArkTypographyWeights.medium,
463            size: ArkResourcesHelper.$r('sys.float.Body_L')
464        };
465        this.bodyMiddle = {
466            weight: ArkTypographyWeights.regular,
467            size: ArkResourcesHelper.$r('sys.float.Body_M')
468        };
469        this.bodySmall = {
470            weight: ArkTypographyWeights.regular,
471            size: ArkResourcesHelper.$r('sys.float.Body_S')
472        };
473        this.captionLarge = {
474            weight: ArkTypographyWeights.medium,
475            size: ArkResourcesHelper.$r('sys.float.Caption_L')
476        };
477        this.captionMiddle = {
478            weight: ArkTypographyWeights.medium,
479            size: ArkResourcesHelper.$r('sys.float.Caption_M')
480        };
481        this.captionSmall = {
482            weight: ArkTypographyWeights.medium,
483            size: ArkResourcesHelper.$r('sys.float.Caption_S')
484        };
485    }
486}
487class ArkSystemTheme extends ArkThemeBase {
488    constructor() {
489        super(-1, undefined, ThemeColorMode.SYSTEM, new ArkSystemColors(), new ArkSystemShapes(), new ArkSystemTypography());
490    }
491}
492if (globalThis.WithTheme !== undefined) {
493    globalThis.WithTheme.create = function (themeOptions) {
494        var _a;
495        const elmtId = ViewStackProcessor.GetElmtIdToAccountFor();
496        const colorMode = (_a = themeOptions === null || themeOptions === void 0 ? void 0 : themeOptions.colorMode) !== null && _a !== void 0 ? _a : ThemeColorMode.SYSTEM;
497        const cloneTheme = ArkThemeScopeManager.cloneCustomThemeWithExpand(themeOptions === null || themeOptions === void 0 ? void 0 : themeOptions.theme);
498        const theme = ArkThemeScopeManager.getInstance().makeTheme(cloneTheme, colorMode);
499        theme.bindToScope(elmtId);
500        const onThemeScopeDestroy = () => {
501            ArkThemeScopeManager.getInstance().onScopeDestroy(elmtId);
502        };
503        ArkThemeNativeHelper.sendThemeToNative(theme, elmtId);
504        ArkThemeNativeHelper.createInternal(elmtId, theme.id, cloneTheme, colorMode, onThemeScopeDestroy);
505        ArkThemeScopeManager.getInstance().onScopeEnter(elmtId, themeOptions !== null && themeOptions !== void 0 ? themeOptions : {}, theme);
506    };
507    globalThis.WithTheme.pop = function () {
508        ArkThemeScopeManager.getInstance().onScopeExit();
509        getUINativeModule().theme.pop();
510    };
511}
512class ArkColorsImpl {
513    constructor(colors, baselineColors) {
514        Object.assign(this, baselineColors, colors);
515    }
516    static expandByBrandColor(colors) {
517        var _a, _b, _c, _d, _e, _f, _g, _h, _j;
518        if (colors.brand) {
519            const brandColors = ArkColorsImpl.makeBrandColors(colors.brand);
520            colors.fontEmphasize = (_a = colors.fontEmphasize) !== null && _a !== void 0 ? _a : brandColors.primary;
521            colors.iconEmphasize = (_b = colors.iconEmphasize) !== null && _b !== void 0 ? _b : brandColors.primary;
522            colors.iconSubEmphasize = (_c = colors.iconSubEmphasize) !== null && _c !== void 0 ? _c : brandColors.tertiary;
523            colors.backgroundEmphasize = (_d = colors.backgroundEmphasize) !== null && _d !== void 0 ? _d : brandColors.primary;
524            colors.compBackgroundEmphasize = (_e = colors.compBackgroundEmphasize) !== null && _e !== void 0 ? _e : brandColors.primary;
525            colors.compEmphasizeSecondary = (_f = colors.compEmphasizeSecondary) !== null && _f !== void 0 ? _f : brandColors.fourth;
526            colors.compEmphasizeTertiary = (_g = colors.compEmphasizeTertiary) !== null && _g !== void 0 ? _g : brandColors.fifth;
527            colors.interactiveFocus = (_h = colors.interactiveFocus) !== null && _h !== void 0 ? _h : brandColors.primary;
528            colors.interactiveActive = (_j = colors.interactiveActive) !== null && _j !== void 0 ? _j : brandColors.primary;
529        }
530    }
531    static makeBrandColors(brandColor) {
532        const result = {
533            primary: undefined,
534            secondary: undefined,
535            tertiary: undefined,
536            fourth: undefined,
537            fifth: undefined,
538            sixth: undefined
539        };
540        if (brandColor) {
541            if (brandColor instanceof Object) {
542                result.primary = brandColor;
543                result.secondary = ArkColorsImpl.makeResourceWithOpacity(brandColor, 0.6);
544                result.tertiary = ArkColorsImpl.makeResourceWithOpacity(brandColor, 0.4);
545                result.fourth = ArkColorsImpl.makeResourceWithOpacity(brandColor, 0.2);
546                result.fifth = ArkColorsImpl.makeResourceWithOpacity(brandColor, 0.1);
547                result.sixth = ArkColorsImpl.makeResourceWithOpacity(brandColor, 0.05);
548            }
549            else {
550                const argbColor = getUINativeModule().resource.getColorValue(brandColor);
551                result.primary = argbColor;
552                result.secondary = ArkColorsImpl.blendOpacity(argbColor, 0.6);
553                result.tertiary = ArkColorsImpl.blendOpacity(argbColor, 0.4);
554                result.fourth = ArkColorsImpl.blendOpacity(argbColor, 0.2);
555                result.fifth = ArkColorsImpl.blendOpacity(argbColor, 0.1);
556                result.sixth = ArkColorsImpl.blendOpacity(argbColor, 0.05);
557            }
558        }
559        return result;
560    }
561    static makeResourceWithOpacity(resourceColor, opacityRatio) {
562        return {
563            'id': resourceColor.id,
564            'type': resourceColor.type,
565            'params': [...resourceColor.params],
566            'bundleName': resourceColor.bundleName,
567            'moduleName': resourceColor.moduleName,
568            'opacityRatio': opacityRatio
569        };
570    }
571    static blendOpacity(argbColor, opacityRatio) {
572        if (opacityRatio < 0 || opacityRatio > 1.0) {
573            return argbColor;
574        }
575        const alpha = (argbColor >> 24) & 0xFF;
576        const outAlpha = (alpha * opacityRatio) & 0xFF;
577        return ((argbColor & 0x00FFFFFF) | (outAlpha & 0xFF) << 24) >>> 0;
578    }
579}
580class ArkCornerRadiusImpl {
581    constructor(corners, baselineCorners) {
582        Object.assign(this, baselineCorners, corners);
583    }
584}
585class ArkPaddingsImpl {
586    constructor(paddings, baselinePaddings) {
587        Object.assign(this, baselinePaddings, paddings);
588    }
589}
590class ArkOutlinesImpl {
591    constructor(outlines = {}, baselineOutlines) {
592        Object.assign(this, baselineOutlines, outlines);
593    }
594}
595class ArkBordersImpl {
596    constructor(borders = {}, baselineBorders) {
597        Object.assign(this, baselineBorders, borders);
598    }
599}
600class ArkShapesImpl {
601    constructor(shapes, baselineShapes) {
602        this.cornerRadius = new ArkCornerRadiusImpl(shapes === null || shapes === void 0 ? void 0 : shapes.cornerRadius, baselineShapes.cornerRadius);
603        this.paddings = new ArkPaddingsImpl(shapes === null || shapes === void 0 ? void 0 : shapes.paddings, baselineShapes.paddings);
604        this.borders = new ArkBordersImpl(shapes === null || shapes === void 0 ? void 0 : shapes.borders, baselineShapes.borders);
605        this.outlines = new ArkOutlinesImpl(shapes === null || shapes === void 0 ? void 0 : shapes.outlines, baselineShapes.outlines);
606    }
607}
608class ArkTypographyImpl {
609    constructor(typography, baselineTypography) {
610        var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35;
611        this.displayLarge = {
612            weight: (_b = (_a = typography === null || typography === void 0 ? void 0 : typography.displayLarge) === null || _a === void 0 ? void 0 : _a.weight) !== null && _b !== void 0 ? _b : ArkTypographyWeights.light,
613            size: (_d = (_c = typography === null || typography === void 0 ? void 0 : typography.displayLarge) === null || _c === void 0 ? void 0 : _c.size) !== null && _d !== void 0 ? _d : baselineTypography.displayLarge.size
614        };
615        this.displayMiddle = {
616            weight: (_f = (_e = typography === null || typography === void 0 ? void 0 : typography.displayMiddle) === null || _e === void 0 ? void 0 : _e.weight) !== null && _f !== void 0 ? _f : ArkTypographyWeights.light,
617            size: (_h = (_g = typography === null || typography === void 0 ? void 0 : typography.displayMiddle) === null || _g === void 0 ? void 0 : _g.size) !== null && _h !== void 0 ? _h : baselineTypography.displayMiddle.size
618        };
619        this.displaySmall = {
620            weight: (_k = (_j = typography === null || typography === void 0 ? void 0 : typography.displaySmall) === null || _j === void 0 ? void 0 : _j.weight) !== null && _k !== void 0 ? _k : ArkTypographyWeights.light,
621            size: (_m = (_l = typography === null || typography === void 0 ? void 0 : typography.displaySmall) === null || _l === void 0 ? void 0 : _l.size) !== null && _m !== void 0 ? _m : baselineTypography.displaySmall.size
622        };
623        this.titleLarge = {
624            weight: (_p = (_o = typography === null || typography === void 0 ? void 0 : typography.titleLarge) === null || _o === void 0 ? void 0 : _o.weight) !== null && _p !== void 0 ? _p : ArkTypographyWeights.bold,
625            size: (_r = (_q = typography === null || typography === void 0 ? void 0 : typography.titleLarge) === null || _q === void 0 ? void 0 : _q.size) !== null && _r !== void 0 ? _r : baselineTypography.titleLarge.size
626        };
627        this.titleMiddle = {
628            weight: (_t = (_s = typography === null || typography === void 0 ? void 0 : typography.titleMiddle) === null || _s === void 0 ? void 0 : _s.weight) !== null && _t !== void 0 ? _t : ArkTypographyWeights.bold,
629            size: (_v = (_u = typography === null || typography === void 0 ? void 0 : typography.titleMiddle) === null || _u === void 0 ? void 0 : _u.size) !== null && _v !== void 0 ? _v : baselineTypography.titleMiddle.size
630        };
631        this.titleSmall = {
632            weight: (_x = (_w = typography === null || typography === void 0 ? void 0 : typography.titleSmall) === null || _w === void 0 ? void 0 : _w.weight) !== null && _x !== void 0 ? _x : ArkTypographyWeights.bold,
633            size: (_z = (_y = typography === null || typography === void 0 ? void 0 : typography.titleSmall) === null || _y === void 0 ? void 0 : _y.size) !== null && _z !== void 0 ? _z : baselineTypography.titleSmall.size
634        };
635        this.subtitleLarge = {
636            weight: (_1 = (_0 = typography === null || typography === void 0 ? void 0 : typography.subtitleLarge) === null || _0 === void 0 ? void 0 : _0.weight) !== null && _1 !== void 0 ? _1 : ArkTypographyWeights.medium,
637            size: (_3 = (_2 = typography === null || typography === void 0 ? void 0 : typography.subtitleLarge) === null || _2 === void 0 ? void 0 : _2.size) !== null && _3 !== void 0 ? _3 : baselineTypography.subtitleLarge.size
638        };
639        this.subtitleMiddle = {
640            weight: (_5 = (_4 = typography === null || typography === void 0 ? void 0 : typography.subtitleMiddle) === null || _4 === void 0 ? void 0 : _4.weight) !== null && _5 !== void 0 ? _5 : ArkTypographyWeights.medium,
641            size: (_7 = (_6 = typography === null || typography === void 0 ? void 0 : typography.subtitleMiddle) === null || _6 === void 0 ? void 0 : _6.size) !== null && _7 !== void 0 ? _7 : baselineTypography.subtitleMiddle.size
642        };
643        this.subtitleSmall = {
644            weight: (_9 = (_8 = typography === null || typography === void 0 ? void 0 : typography.subtitleSmall) === null || _8 === void 0 ? void 0 : _8.weight) !== null && _9 !== void 0 ? _9 : ArkTypographyWeights.medium,
645            size: (_11 = (_10 = typography === null || typography === void 0 ? void 0 : typography.subtitleSmall) === null || _10 === void 0 ? void 0 : _10.size) !== null && _11 !== void 0 ? _11 : baselineTypography.subtitleSmall.size
646        };
647        this.bodyLarge = {
648            weight: (_13 = (_12 = typography === null || typography === void 0 ? void 0 : typography.bodyLarge) === null || _12 === void 0 ? void 0 : _12.weight) !== null && _13 !== void 0 ? _13 : ArkTypographyWeights.medium,
649            size: (_15 = (_14 = typography === null || typography === void 0 ? void 0 : typography.bodyLarge) === null || _14 === void 0 ? void 0 : _14.size) !== null && _15 !== void 0 ? _15 : baselineTypography.bodyLarge.size
650        };
651        this.bodyMiddle = {
652            weight: (_17 = (_16 = typography === null || typography === void 0 ? void 0 : typography.bodyMiddle) === null || _16 === void 0 ? void 0 : _16.weight) !== null && _17 !== void 0 ? _17 : ArkTypographyWeights.regular,
653            size: (_19 = (_18 = typography === null || typography === void 0 ? void 0 : typography.bodyMiddle) === null || _18 === void 0 ? void 0 : _18.size) !== null && _19 !== void 0 ? _19 : baselineTypography.bodyMiddle.size
654        };
655        this.bodySmall = {
656            weight: (_21 = (_20 = typography === null || typography === void 0 ? void 0 : typography.bodySmall) === null || _20 === void 0 ? void 0 : _20.weight) !== null && _21 !== void 0 ? _21 : ArkTypographyWeights.regular,
657            size: (_23 = (_22 = typography === null || typography === void 0 ? void 0 : typography.bodySmall) === null || _22 === void 0 ? void 0 : _22.size) !== null && _23 !== void 0 ? _23 : baselineTypography.bodySmall.size
658        };
659        this.captionLarge = {
660            weight: (_25 = (_24 = typography === null || typography === void 0 ? void 0 : typography.captionLarge) === null || _24 === void 0 ? void 0 : _24.weight) !== null && _25 !== void 0 ? _25 : ArkTypographyWeights.medium,
661            size: (_27 = (_26 = typography === null || typography === void 0 ? void 0 : typography.captionLarge) === null || _26 === void 0 ? void 0 : _26.size) !== null && _27 !== void 0 ? _27 : baselineTypography.captionLarge.size
662        };
663        this.captionMiddle = {
664            weight: (_29 = (_28 = typography === null || typography === void 0 ? void 0 : typography.captionMiddle) === null || _28 === void 0 ? void 0 : _28.weight) !== null && _29 !== void 0 ? _29 : ArkTypographyWeights.medium,
665            size: (_31 = (_30 = typography === null || typography === void 0 ? void 0 : typography.captionMiddle) === null || _30 === void 0 ? void 0 : _30.size) !== null && _31 !== void 0 ? _31 : baselineTypography.captionMiddle.size
666        };
667        this.captionSmall = {
668            weight: (_33 = (_32 = typography === null || typography === void 0 ? void 0 : typography.captionSmall) === null || _32 === void 0 ? void 0 : _32.weight) !== null && _33 !== void 0 ? _33 : ArkTypographyWeights.medium,
669            size: (_35 = (_34 = typography === null || typography === void 0 ? void 0 : typography.captionSmall) === null || _34 === void 0 ? void 0 : _34.size) !== null && _35 !== void 0 ? _35 : baselineTypography.captionSmall.size
670        };
671    }
672}
673class ArkThemeImpl extends ArkThemeBase {
674    constructor(customTheme, colorMode, baselineTheme) {
675        if (!customTheme) {
676            super(baselineTheme.id, undefined, colorMode, new ArkColorsImpl(undefined, baselineTheme.colors), new ArkShapesImpl(undefined, baselineTheme.shapes), new ArkTypographyImpl(undefined, baselineTheme.typography));
677            return;
678        }
679        super(baselineTheme.id, customTheme, colorMode, new ArkColorsImpl(customTheme.colors, baselineTheme.colors), new ArkShapesImpl(customTheme.shapes, baselineTheme.shapes), new ArkTypographyImpl(customTheme.typography, baselineTheme.typography));
680    }
681}
682class ArkThemeScopeItem {
683    constructor() {
684        this.isInWhiteList = undefined;
685        this.listener = undefined;
686    }
687}
688class ArkThemeScopeArray extends Array {
689    binarySearch(elmtId) {
690        let start = 0;
691        let end = this.length - 1;
692        while (start <= end) {
693            let mid = (start + end) >> 1;
694            if (this[mid].elmtId === elmtId) {
695                return mid;
696            }
697            if (elmtId < this[mid].elmtId) {
698                end = mid - 1;
699            }
700            else {
701                start = mid + 1;
702            }
703        }
704        return -1;
705    }
706}
707class ArkThemeScope {
708    constructor(ownerComponentId, withThemeId, withThemeOptions, theme) {
709        this.ownerComponentId = ownerComponentId;
710        this.withThemeId = withThemeId;
711        this.withThemeOptions = withThemeOptions;
712        this.theme = theme;
713        this.prevColorMode = this.colorMode();
714    }
715    getOwnerComponentId() {
716        return this.ownerComponentId;
717    }
718    getWithThemeId() {
719        return this.withThemeId;
720    }
721    addComponentToScope(elmtId, owner, componentName) {
722        if (this.isComponentInScope(elmtId)) {
723            return;
724        }
725        if (!this.components) {
726            this.components = new ArkThemeScopeArray();
727        }
728        this.components.push({ elmtId: elmtId, ownerId: owner.id__(), owner: owner, name: componentName });
729    }
730    addCustomListenerInScope(listener) {
731        const len = this.components ? this.components.length : -1;
732        if (len <= 0) {
733            return;
734        }
735        const listenerId = listener.id__();
736        let themeScopeItem = this.components[len - 1];
737        if (themeScopeItem.elmtId === listenerId) {
738            themeScopeItem.listener = listener;
739            return;
740        }
741        themeScopeItem = this.components.find((item) => item.elmtId === listenerId);
742        if (themeScopeItem) {
743            themeScopeItem.listener = listener;
744        }
745    }
746    removeComponentFromScope(elmtId) {
747        if (this.components) {
748            const index = this.components.binarySearch(elmtId);
749            if (index > -1) {
750                this.components.splice(index, 1);
751            }
752        }
753    }
754    isComponentInScope(elmtId) {
755        return this.components && (this.components.binarySearch(elmtId) > -1);
756    }
757    componentsInScope() {
758        return this.components;
759    }
760    colorMode() {
761        var _a;
762        return (_a = this.withThemeOptions.colorMode) !== null && _a !== void 0 ? _a : ThemeColorMode.SYSTEM;
763    }
764    customTheme() {
765        var _a;
766        return (_a = this.withThemeOptions.theme) !== null && _a !== void 0 ? _a : {};
767    }
768    getTheme() {
769        return this.theme;
770    }
771    options() {
772        return this.withThemeOptions;
773    }
774    updateWithThemeOptions(options, theme) {
775        var _a;
776        this.prevColorMode = this.colorMode();
777        this.withThemeOptions = options;
778        if (this.theme !== theme) {
779            (_a = this.theme) === null || _a === void 0 ? void 0 : _a.unbindFromScope(this.getWithThemeId());
780            this.theme = theme;
781        }
782    }
783    isColorModeChanged() {
784        return this.prevColorMode !== this.colorMode();
785    }
786}
787class ArkThemeScopeManager {
788    constructor() {
789        this.localThemeScopes = [];
790        this.themeScopes = undefined;
791        this.ifElseLastScope = undefined;
792        this.ifElseScopes = [];
793        this.lastThemeScopeId = 0;
794        this.listeners = [];
795        this.defaultTheme = undefined;
796    }
797    onComponentCreateEnter(componentName, elmtId, isFirstRender, ownerComponent) {
798        this.handledIsFirstRender = isFirstRender;
799        this.handledOwnerComponentId = ownerComponent.id__();
800        this.handledComponentElmtId = elmtId;
801        if (!this.themeScopes || componentName === 'WithTheme') {
802            return;
803        }
804        if (this.themeScopes.length === 0) {
805            this.handleThemeScopeChange(undefined);
806            return;
807        }
808        let scope = undefined;
809        if (isFirstRender) {
810            const currentLocalScope = this.localThemeScopes[this.localThemeScopes.length - 1];
811            const currentIfElseScope = this.ifElseScopes[this.ifElseScopes.length - 1];
812            if (currentLocalScope) {
813                scope = currentLocalScope;
814                scope.addComponentToScope(elmtId, ownerComponent, componentName);
815            }
816            else if (currentIfElseScope) {
817                scope = currentIfElseScope;
818                scope.addComponentToScope(elmtId, ownerComponent, componentName);
819            }
820            else {
821                const parentScope = ownerComponent.themeScope_;
822                if (parentScope) {
823                    scope = parentScope;
824                    scope.addComponentToScope(elmtId, ownerComponent, componentName);
825                }
826            }
827        }
828        if (scope === undefined) {
829            scope = this.scopeForElmtId(elmtId);
830        }
831        this.handledColorMode = scope === null || scope === void 0 ? void 0 : scope.colorMode();
832        if (this.handledColorMode === ThemeColorMode.LIGHT || this.handledColorMode === ThemeColorMode.DARK) {
833            this.onEnterLocalColorMode(this.handledColorMode);
834        }
835        if (componentName === 'If') {
836            this.ifElseLastScope = scope;
837        }
838        this.handledThemeScope = scope;
839        this.handleThemeScopeChange(this.handledThemeScope);
840    }
841    onComponentCreateExit(elmtId) {
842        if (this.handledColorMode === ThemeColorMode.LIGHT || this.handledColorMode === ThemeColorMode.DARK) {
843            this.onExitLocalColorMode();
844        }
845        this.handledThemeScope = undefined;
846        this.handledComponentElmtId = undefined;
847    }
848    onScopeEnter(withThemeId, withThemeOptions, theme) {
849        this.lastThemeScopeId = withThemeId;
850        if (this.handledIsFirstRender === true) {
851            let themeScope = new ArkThemeScope(this.handledOwnerComponentId, withThemeId, withThemeOptions, theme);
852            this.localThemeScopes.push(themeScope);
853            if (!this.themeScopes) {
854                this.themeScopes = new Array();
855            }
856            this.themeScopes.push(themeScope);
857        }
858        else {
859            const scope = this.themeScopes.find(item => item.getWithThemeId() === withThemeId);
860            scope === null || scope === void 0 ? void 0 : scope.updateWithThemeOptions(withThemeOptions, theme);
861            this.forceRerenderScope(scope);
862        }
863    }
864    onScopeExit() {
865        if (this.handledIsFirstRender === true) {
866            this.localThemeScopes.pop();
867        }
868    }
869    onScopeDestroy(themeScopeId) {
870        var _a;
871        this.themeScopes = (_a = this.themeScopes) === null || _a === void 0 ? void 0 : _a.filter((scope) => {
872            if (scope.getWithThemeId() === themeScopeId) {
873                this.onScopeDestroyInternal(scope);
874                return false;
875            }
876            return true;
877        });
878    }
879    onScopeDestroyInternal(scope) {
880        const theme = scope.getTheme();
881        if (theme) {
882            theme.unbindFromScope(scope.getWithThemeId());
883        }
884        const index = this.localThemeScopes.indexOf(scope);
885        if (index !== -1) {
886            this.localThemeScopes.splice(index, 1);
887        }
888        WithTheme.removeThemeInNative(scope.getWithThemeId());
889    }
890    onViewPUCreate(ownerComponent) {
891        var _a;
892        if (ownerComponent.parent_ === undefined) {
893            this.subscribeListener(ownerComponent);
894        }
895        ownerComponent.themeScope_ = this.scopeForElmtId(ownerComponent.id__());
896        (_a = ownerComponent.themeScope_) === null || _a === void 0 ? void 0 : _a.addCustomListenerInScope(ownerComponent);
897    }
898    onViewPUDelete(ownerComponent) {
899        var _a;
900        this.unsubscribeListener(ownerComponent);
901        const ownerComponentId = ownerComponent.id__();
902        this.themeScopes = (_a = this.themeScopes) === null || _a === void 0 ? void 0 : _a.filter((scope) => {
903            if (scope.getOwnerComponentId() === ownerComponentId) {
904                this.onScopeDestroyInternal(scope);
905                return false;
906            }
907            return true;
908        });
909    }
910    onIfElseBranchUpdateEnter() {
911        this.ifElseScopes.push(this.ifElseLastScope);
912    }
913    onIfElseBranchUpdateExit(removedElmtIds) {
914        const scope = this.ifElseScopes.pop();
915        if (removedElmtIds && scope) {
916            removedElmtIds.forEach(elmtId => scope.removeComponentFromScope(elmtId));
917        }
918    }
919    onDeepRenderScopeEnter(themeScope) {
920        if (themeScope) {
921            this.localThemeScopes.push(themeScope);
922            return true;
923        }
924        return false;
925    }
926    onDeepRenderScopeExit() {
927        this.localThemeScopes.pop();
928    }
929    subscribeListener(listener) {
930        if (this.listeners.includes(listener)) {
931            return;
932        }
933        this.listeners.push(listener);
934    }
935    unsubscribeListener(listener) {
936        const index = this.listeners.indexOf(listener, 0);
937        if (index > -1) {
938            this.listeners.splice(index, 1);
939        }
940        const scope = listener.themeScope_;
941        if (scope) {
942            scope.removeComponentFromScope(listener.id__());
943            listener.themeScope_ = undefined;
944        }
945    }
946    getFinalTheme(ownerComponent) {
947        var _a, _b, _c;
948        return (_c = (_b = (_a = ownerComponent.themeScope_) === null || _a === void 0 ? void 0 : _a.getTheme()) !== null && _b !== void 0 ? _b : this.defaultTheme) !== null && _c !== void 0 ? _c : ArkThemeScopeManager.SystemTheme;
949    }
950    scopeForElmtId(elmtId) {
951        var _a;
952        if (this.handledThemeScope && this.handledComponentElmtId === elmtId) {
953            return this.handledThemeScope;
954        }
955        if (this.handledIsFirstRender) {
956            if (this.localThemeScopes.length > 0) {
957                return this.localThemeScopes[this.localThemeScopes.length - 1];
958            }
959        }
960        return (_a = this.themeScopes) === null || _a === void 0 ? void 0 : _a.find(item => item.isComponentInScope(elmtId));
961    }
962    lastLocalThemeScope() {
963        if (this.localThemeScopes.length > 0) {
964            return this.localThemeScopes[this.localThemeScopes.length - 1];
965        }
966        return undefined;
967    }
968    onEnterLocalColorMode(colorMode) {
969        getUINativeModule().resource.updateColorMode(colorMode);
970    }
971    onExitLocalColorMode() {
972        getUINativeModule().resource.restore();
973    }
974    forceRerenderScope(scope) {
975        var _a, _b, _c;
976        if (scope === undefined) {
977            return;
978        }
979        const theme = (_b = (_a = scope === null || scope === void 0 ? void 0 : scope.getTheme()) !== null && _a !== void 0 ? _a : this.defaultTheme) !== null && _b !== void 0 ? _b : ArkThemeScopeManager.SystemTheme;
980        (_c = scope.componentsInScope()) === null || _c === void 0 ? void 0 : _c.forEach((item) => this.notifyScopeThemeChanged(item, theme, scope.isColorModeChanged()));
981    }
982    notifyScopeThemeChanged(item, themeWillApply, isColorModeChanged) {
983        if (item.owner) {
984            const listener = item.owner;
985            if (isColorModeChanged) {
986                listener.forceRerenderNode(item.elmtId);
987            }
988            else {
989                let isInWhiteList = item.isInWhiteList;
990                if (isInWhiteList === undefined) {
991                    isInWhiteList = ArkThemeWhiteList.isInWhiteList(item.name);
992                    item.isInWhiteList = isInWhiteList;
993                }
994                if (isInWhiteList === true) {
995                    listener.forceRerenderNode(item.elmtId);
996                }
997            }
998        }
999        if (item.listener) {
1000            const listener = item.listener;
1001            listener.onWillApplyTheme(themeWillApply);
1002        }
1003    }
1004    makeTheme(customTheme, colorMode) {
1005        var _a;
1006        const baselineTheme = (_a = this.defaultTheme) !== null && _a !== void 0 ? _a : ArkThemeScopeManager.SystemTheme;
1007        const theme = ArkThemeCache.getInstance().get(baselineTheme.id, customTheme, colorMode);
1008        return theme ? theme : new ArkThemeImpl(customTheme, colorMode, baselineTheme);
1009    }
1010    static cloneCustomThemeWithExpand(customTheme) {
1011        const theme = ArkThemeBase.copyCustomTheme(customTheme);
1012        if (theme === null || theme === void 0 ? void 0 : theme.colors) {
1013            ArkColorsImpl.expandByBrandColor(theme.colors);
1014        }
1015        return theme;
1016    }
1017    setDefaultTheme(customTheme) {
1018        var _a;
1019        (_a = this.defaultTheme) === null || _a === void 0 ? void 0 : _a.unbindFromScope(0);
1020        this.defaultTheme = ArkThemeScopeManager.SystemTheme;
1021        const cloneTheme = ArkThemeScopeManager.cloneCustomThemeWithExpand(customTheme);
1022        this.defaultTheme = this.makeTheme(customTheme, ThemeColorMode.SYSTEM);
1023        this.defaultTheme.bindToScope(0);
1024        ArkThemeNativeHelper.sendThemeToNative(this.defaultTheme, 0);
1025        ArkThemeNativeHelper.setDefaultTheme(cloneTheme);
1026        this.notifyGlobalThemeChanged();
1027    }
1028    static getSystemColors() {
1029        return ArkThemeScopeManager.SystemTheme.colors;
1030    }
1031    notifyGlobalThemeChanged() {
1032        this.listeners.forEach(listener => {
1033            if (listener.parent_ === undefined) {
1034                listener.onGlobalThemeChanged();
1035            }
1036        });
1037    }
1038    handleThemeScopeChange(scope) {
1039        var _a;
1040        const currentThemeScopeId = (_a = scope === null || scope === void 0 ? void 0 : scope.getWithThemeId()) !== null && _a !== void 0 ? _a : 0;
1041        if (currentThemeScopeId !== this.lastThemeScopeId) {
1042            this.lastThemeScopeId = currentThemeScopeId;
1043            WithTheme.setThemeScopeId(currentThemeScopeId);
1044        }
1045    }
1046    static getInstance() {
1047        if (!ArkThemeScopeManager.instance) {
1048            ArkThemeScopeManager.instance = new ArkThemeScopeManager();
1049            ViewBuildNodeBase.setArkThemeScopeManager(ArkThemeScopeManager.instance);
1050        }
1051        return ArkThemeScopeManager.instance;
1052    }
1053}
1054ArkThemeScopeManager.SystemTheme = new ArkSystemTheme();
1055ArkThemeScopeManager.instance = undefined;
1056globalThis.themeScopeMgr = ArkThemeScopeManager.getInstance();
1057class ArkThemeWhiteList {
1058    static isInWhiteList(componentName) {
1059        let start = 0;
1060        let end = ArkThemeWhiteList.whiteList.length - 1;
1061        while (start <= end) {
1062            let mid = (start + end) >> 1;
1063            if (ArkThemeWhiteList.whiteList[mid].localeCompare(componentName) === 0) {
1064                return true;
1065            }
1066            if (ArkThemeWhiteList.whiteList[mid].localeCompare(componentName) === 1) {
1067                end = mid - 1;
1068            }
1069            else {
1070                start = mid + 1;
1071            }
1072        }
1073        return false;
1074    }
1075}
1076ArkThemeWhiteList.whiteList = [
1077    'AlphabetIndexer',
1078    'Badge',
1079    'Button',
1080    'DataPanel',
1081    'Menu',
1082    'MenuItem',
1083    'PatternLock',
1084    'QRCode',
1085    'Radio',
1086    'Scroll',
1087    'Slider',
1088    'Swiper',
1089    'Text',
1090];
1091