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