• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023-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 */
15if (!('finalizeConstruction' in ViewPU.prototype)) {
16    Reflect.set(ViewPU.prototype, 'finalizeConstruction', () => {
17    });
18}
19const display = requireNapi('display');
20const hilog = requireNapi('hilog');
21const measure = requireNapi('measure');
22const resourceManager = requireNapi('resourceManager');
23const LengthMetrics = requireNapi('arkui.node').LengthMetrics;
24const LengthUnit = requireNapi('arkui.node').LengthUnit;
25const accessibility = requireNapi('accessibility');
26const KeyCode = requireNapi('multimodalInput.keyCode').KeyCode;
27const i18n = requireNapi('i18n')
28
29class CustomThemeImpl {
30    constructor(colors) {
31        this.colors = colors;
32    }
33}
34
35const TITLE_MAX_LINES = 2;
36const HORIZON_BUTTON_MAX_COUNT = 2;
37const VERTICAL_BUTTON_MAX_COUNT = 4;
38const BUTTON_LAYOUT_WEIGHT = 1;
39const CONTENT_MAX_LINES = 2;
40const LOADING_PROGRESS_WIDTH = 40;
41const LOADING_PROGRESS_HEIGHT = 40;
42const LOADING_MAX_LINES = 10;
43const LOADING_MAX_LINES_BIG_FONT = 4;
44const LOADING_TEXT_LAYOUT_WEIGHT = 1;
45const LOADING_TEXT_MARGIN_LEFT = 12;
46const LOADING_MIN_HEIGHT = 48;
47const LIST_MIN_HEIGHT = 48;
48const CHECKBOX_CONTAINER_LENGTH = 20;
49const TEXT_MIN_HEIGHT = 48;
50const MIN_CONTENT_HEIGHT = 100;
51const MAX_CONTENT_HEIGHT = 30000;
52const KEYCODE_UP = 2012;
53const KEYCODE_DOWN = 2013;
54const IGNORE_KEY_EVENT_TYPE = 1;
55const FIRST_ITEM_INDEX = 0;
56const VERSION_TWELVE = 50000012;
57const MAX_FONT_SCALE = 2;
58const FADEOUT_GRADIENT_WIDTH = 32;
59const FADEOUT_ENABLE = 'true';
60// 'sys.float.alert_container_max_width'
61const MAX_DIALOG_WIDTH = getNumberByResourceId(125831042, 400);
62// 'sys.float.padding_level8'
63const BUTTON_HORIZONTAL_PADDING = getNumberByResourceId(125830927, 16);
64// 'sys.float.Body_L'
65const BODY_L = getNumberByResourceId(125830970, 16);
66// 'sys.float.Body_M'
67const BODY_M = getNumberByResourceId(125830971, 14);
68// 'sys.float.Body_S'
69const BODY_S = getNumberByResourceId(125830972, 12);
70// 'sys.float.Title_S'
71const TITLE_S = getNumberByResourceId(125830966, 20);
72// 'sys.float.padding_level8'
73const PADDING_LEVEL_8 = getNumberByResourceId(125830927, 16);
74const BUTTON_HORIZONTAL_MARGIN = lazyInit(() => {
75    return getLengthMetricsByResource({
76        'id': -1,
77        'type': 10002,
78        params: ['sys.float.alert_right_padding_horizontal'],
79        'bundleName': '__harDefaultBundleName__',
80        'moduleName': '__harDefaultModuleName__'
81    }, 16);
82});
83const BUTTON_HORIZONTAL_SPACE = lazyInit(() => {
84    return getLengthMetricsByResource({
85        'id': -1,
86        'type': 10002,
87        params: ['sys.float.alert_button_horizontal_space'],
88        'bundleName': '__harDefaultBundleName__',
89        'moduleName': '__harDefaultModuleName__'
90    }, 8);
91});
92const BUTTON_MIN_FONT_SIZE = lazyInit(() => {
93    return getLengthMetricsByResource({
94        'id': -1,
95        'type': 10002,
96        params: ['sys.float.dialog_button_font_min_size'],
97        'bundleName': '__harDefaultBundleName__',
98        'moduleName': '__harDefaultModuleName__'
99    }, 9);
100});
101const BUTTON_MAX_FONT_SIZE = lazyInit(() => {
102    return getLengthMetricsByResource({
103        'id': -1,
104        'type': 10002,
105        params: ['sys.float.dialog_button_font_max_size'],
106        'bundleName': '__harDefaultBundleName__',
107        'moduleName': '__harDefaultModuleName__'
108    }, 16);
109});
110const DEFAULT_IMAGE_SIZE = lazyInit(() => {
111    return getLengthMetricsByResource({
112        'id': -1,
113        'type': 10002,
114        params: ['sys.float.dialog_tip_image_size'],
115        'bundleName': '__harDefaultBundleName__',
116        'moduleName': '__harDefaultModuleName__'
117    }, 64);
118});
119const DEFAULT_IMAGE_RADIUS = lazyInit(() => {
120    return getLengthMetricsByResource({
121        'id': -1,
122        'type': 10002,
123        params: ['sys.float.dialog_tip_image_radius'],
124        'bundleName': '__harDefaultBundleName__',
125        'moduleName': '__harDefaultModuleName__'
126    }, 12);
127});
128const TIP_TEXT_TOP_PADDING = lazyInit(() => {
129    return getLengthMetricsByResource({
130        'id': -1,
131        'type': 10002,
132        params: ['sys.float.dialog_tip_text_top_padding'],
133        'bundleName': '__harDefaultBundleName__',
134        'moduleName': '__harDefaultModuleName__'
135    }, 16);
136});
137const TIP_CHECKBOX_TOP_PADDING = lazyInit(() => {
138    return getLengthMetricsByResource({
139        'id': -1,
140        'type': 10002,
141        params: ['sys.float.dialog_checkbox_top_padding'],
142        'bundleName': '__harDefaultBundleName__',
143        'moduleName': '__harDefaultModuleName__'
144    }, 8);
145});
146const TIP_CHECKBOX_BOTTOM_PADDING = lazyInit(() => {
147    return getLengthMetricsByResource({
148        'id': -1,
149        'type': 10002,
150        params: ['sys.float.dialog_checkbox_bottom_padding'],
151        'bundleName': '__harDefaultBundleName__',
152        'moduleName': '__harDefaultModuleName__'
153    }, 8, true);
154});
155const TIP_CHECKBOX_END_MARGIN = lazyInit(() => {
156    return getLengthMetricsByResource({
157        'id': -1,
158        'type': 10002,
159        params: ['sys.float.dialog_checkbox_end_margin'],
160        'bundleName': '__harDefaultBundleName__',
161        'moduleName': '__harDefaultModuleName__'
162    }, 8);
163});
164const SUBTITLE_SIZE = lazyInit(() => {
165    return getLengthMetricsByResource({
166        'id': -1,
167        'type': 10002,
168        params: ['sys.float.dialog_subtitle_font_size'],
169        'bundleName': '__harDefaultBundleName__',
170        'moduleName': '__harDefaultModuleName__'
171    }, 14);
172});
173const CHECKBOX_CONTAINER_HEIGHT = lazyInit(() => {
174    return getLengthMetricsByResource({
175        'id': -1,
176        'type': 10002,
177        params: ['sys.float.dialog_checkbox_min_height'],
178        'bundleName': '__harDefaultBundleName__',
179        'moduleName': '__harDefaultModuleName__'
180    }, 48, true);
181});
182const CONTENT_END_MARGIN = lazyInit(() => {
183    return getLengthMetricsByResource({
184        'id': -1,
185        'type': 10002,
186        params: ['sys.float.dialog_content_right_margin'],
187        'bundleName': '__harDefaultBundleName__',
188        'moduleName': '__harDefaultModuleName__'
189    }, 16);
190});
191const SCROLL_END_MARGIN = lazyInit(() => {
192    return getLengthMetricsByResource({
193        'id': -1,
194        'type': 10002,
195        params: ['sys.float.dialog_scroll_right_margin'],
196        'bundleName': '__harDefaultBundleName__',
197        'moduleName': '__harDefaultModuleName__'
198    }, 16);
199});
200const DIALOG_DIVIDER_SHOW = lazyInit(() => {
201    return getLengthMetricsByResource({
202        'id': -1,
203        'type': 10002,
204        params: ['sys.float.dialog_divider_show'],
205        'bundleName': '__harDefaultBundleName__',
206        'moduleName': '__harDefaultModuleName__'
207    }, 1, true);
208});
209const ALERT_BUTTON_STYLE = lazyInit(() => {
210    return getLengthMetricsByResource({
211        'id': -1,
212        'type': 10002,
213        params: ['sys.float.alert_button_style'],
214        'bundleName': '__harDefaultBundleName__',
215        'moduleName': '__harDefaultModuleName__'
216    }, 2, true);
217});
218const ALERT_TITLE_ALIGNMENT = lazyInit(() => {
219    return getLengthMetricsByResource({
220        'id': -1,
221        'type': 10002,
222        params: ['sys.float.alert_title_alignment'],
223        'bundleName': '__harDefaultBundleName__',
224        'moduleName': '__harDefaultModuleName__'
225    }, 1);
226});
227const ERROR_BUTTON_STYLE = lazyInit(() => {
228    return getLengthMetricsByResource({
229        'id': -1,
230        'type': 10002,
231        params: ['sys.float.dialog_error_button_style'],
232        'bundleName': '__harDefaultBundleName__',
233        'moduleName': '__harDefaultModuleName__'
234    }, 2, true);
235});
236// 'sys.string.ohos_id_text_fadeout_enable_default'
237const IS_FADEOUT_ENABLE = lazyInit(() => {
238    return getString(125831120) === FADEOUT_ENABLE;
239});
240// 'sys.string.dialog_title_font_weight'
241const TITLE_FONT_WEIGHT = lazyInit(() => {
242    let fontWeight = FontWeight[getString(125834679) || 'Bold'];
243    return fontWeight;
244});
245// 'sys.string.dialog_content_font_weight'
246const CONTENT_FONT_WEIGHT = lazyInit(() => {
247    let fontWeight = FontWeight[getString(125834682) || 'Medium'];
248    return fontWeight;
249});
250// 'sys.string.dialog_content_font_size'
251const CONTENT_FONT_SIZE = lazyInit(() => {
252    return getLengthMetricsByResource({
253        'id': -1,
254        'type': 10002,
255        params: ['sys.float.dialog_content_font_size'],
256        'bundleName': '__harDefaultBundleName__',
257        'moduleName': '__harDefaultModuleName__'
258    }, BODY_L);
259});
260const SCROLL_BAR_OFFSET = 20;
261const SELECT_DIALOG_SCROLL_BAR_OFFSET = 4;
262
263export class TipsDialog extends ViewPU {
264    constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) {
265        super(parent, __localStorage, elmtId, extraInfo);
266        if (typeof paramsLambda === 'function') {
267            this.paramsGenerator_ = paramsLambda;
268        }
269        this.controller = undefined;
270        this.imageRes = null;
271        this.__imageSize =
272            new ObservedPropertyObjectPU({ width: DEFAULT_IMAGE_SIZE(), height: DEFAULT_IMAGE_SIZE() }, this,
273                'imageSize');
274        this.title = null;
275        this.content = null;
276        this.checkAction = undefined;
277        this.onCheckedChange = undefined;
278        this.checkTips = null;
279        this.__isChecked = new ObservedPropertySimplePU(false, this, 'isChecked');
280        this.primaryButton = null;
281        this.secondaryButton = null;
282        this.buttons = undefined;
283        this.__textAlignment = new ObservedPropertySimplePU(TextAlign.Center, this, 'textAlignment');
284        this.marginOffset = 0;
285        this.contentScroller = new Scroller();
286        this.__fontColorWithTheme = new ObservedPropertyObjectPU({
287            'id': -1,
288            'type': 10001,
289            params: ['sys.color.font_primary'],
290            'bundleName': '__harDefaultBundleName__',
291            'moduleName': '__harDefaultModuleName__'
292        }, this, 'fontColorWithTheme');
293        this.theme = new CustomThemeImpl({});
294        this.themeColorMode = ThemeColorMode.SYSTEM;
295        this.__fontSizeScale = new ObservedPropertySimplePU(1, this, 'fontSizeScale');
296        this.__minContentHeight = new ObservedPropertySimplePU(160, this, 'minContentHeight');
297        this.imageIndex = 0;
298        this.textIndex = 1;
299        this.checkBoxIndex = 2;
300        this.appMaxFontScale = 3.2;
301        this.setInitiallyProvidedValue(params);
302        this.finalizeConstruction();
303    }
304
305    setInitiallyProvidedValue(params) {
306        if (params.controller !== undefined) {
307            this.controller = params.controller;
308        }
309        if (params.imageRes !== undefined) {
310            this.imageRes = params.imageRes;
311        }
312        if (params.imageSize !== undefined) {
313            this.imageSize = params.imageSize;
314        }
315        if (params.title !== undefined) {
316            this.title = params.title;
317        }
318        if (params.content !== undefined) {
319            this.content = params.content;
320        }
321        if (params.checkAction !== undefined) {
322            this.checkAction = params.checkAction;
323        }
324        if (params.onCheckedChange !== undefined) {
325            this.onCheckedChange = params.onCheckedChange;
326        }
327        if (params.checkTips !== undefined) {
328            this.checkTips = params.checkTips;
329        }
330        if (params.isChecked !== undefined) {
331            this.isChecked = params.isChecked;
332        }
333        if (params.primaryButton !== undefined) {
334            this.primaryButton = params.primaryButton;
335        }
336        if (params.secondaryButton !== undefined) {
337            this.secondaryButton = params.secondaryButton;
338        }
339        if (params.buttons !== undefined) {
340            this.buttons = params.buttons;
341        }
342        if (params.textAlignment !== undefined) {
343            this.textAlignment = params.textAlignment;
344        }
345        if (params.marginOffset !== undefined) {
346            this.marginOffset = params.marginOffset;
347        }
348        if (params.contentScroller !== undefined) {
349            this.contentScroller = params.contentScroller;
350        }
351        if (params.fontColorWithTheme !== undefined) {
352            this.fontColorWithTheme = params.fontColorWithTheme;
353        }
354        if (params.theme !== undefined) {
355            this.theme = params.theme;
356        }
357        if (params.themeColorMode !== undefined) {
358            this.themeColorMode = params.themeColorMode;
359        }
360        if (params.fontSizeScale !== undefined) {
361            this.fontSizeScale = params.fontSizeScale;
362        }
363        if (params.minContentHeight !== undefined) {
364            this.minContentHeight = params.minContentHeight;
365        }
366        if (params.imageIndex !== undefined) {
367            this.imageIndex = params.imageIndex;
368        }
369        if (params.textIndex !== undefined) {
370            this.textIndex = params.textIndex;
371        }
372        if (params.checkBoxIndex !== undefined) {
373            this.checkBoxIndex = params.checkBoxIndex;
374        }
375        if (params.appMaxFontScale !== undefined) {
376            this.appMaxFontScale = params.appMaxFontScale;
377        }
378    }
379
380    updateStateVars(params) {
381    }
382
383    purgeVariableDependenciesOnElmtId(rmElmtId) {
384        this.__imageSize.purgeDependencyOnElmtId(rmElmtId);
385        this.__isChecked.purgeDependencyOnElmtId(rmElmtId);
386        this.__textAlignment.purgeDependencyOnElmtId(rmElmtId);
387        this.__fontColorWithTheme.purgeDependencyOnElmtId(rmElmtId);
388        this.__fontSizeScale.purgeDependencyOnElmtId(rmElmtId);
389        this.__minContentHeight.purgeDependencyOnElmtId(rmElmtId);
390    }
391
392    aboutToBeDeleted() {
393        this.__imageSize.aboutToBeDeleted();
394        this.__isChecked.aboutToBeDeleted();
395        this.__textAlignment.aboutToBeDeleted();
396        this.__fontColorWithTheme.aboutToBeDeleted();
397        this.__fontSizeScale.aboutToBeDeleted();
398        this.__minContentHeight.aboutToBeDeleted();
399        SubscriberManager.Get().delete(this.id__());
400        this.aboutToBeDeletedInternal();
401    }
402
403    setController(ctr) {
404        this.controller = ctr;
405    }
406
407    get imageSize() {
408        return this.__imageSize.get();
409    }
410
411    set imageSize(newValue) {
412        this.__imageSize.set(newValue);
413    }
414
415    get isChecked() {
416        return this.__isChecked.get();
417    }
418
419    set isChecked(newValue) {
420        this.__isChecked.set(newValue);
421    }
422
423    get textAlignment() {
424        return this.__textAlignment.get();
425    }
426
427    set textAlignment(newValue) {
428        this.__textAlignment.set(newValue);
429    }
430
431    get fontColorWithTheme() {
432        return this.__fontColorWithTheme.get();
433    }
434
435    set fontColorWithTheme(newValue) {
436        this.__fontColorWithTheme.set(newValue);
437    }
438
439    get fontSizeScale() {
440        return this.__fontSizeScale.get();
441    }
442
443    set fontSizeScale(newValue) {
444        this.__fontSizeScale.set(newValue);
445    }
446
447    get minContentHeight() {
448        return this.__minContentHeight.get();
449    }
450
451    set minContentHeight(newValue) {
452        this.__minContentHeight.set(newValue);
453    }
454
455    initialRender() {
456        this.observeComponentCreation2((elmtId, isInitialRender) => {
457            __Common__.create();
458            __Common__.constraintSize({ maxHeight: '100%' });
459        }, __Common__);
460        {
461            this.observeComponentCreation2((elmtId, isInitialRender) => {
462                if (isInitialRender) {
463                    let componentCall = new CustomDialogContentComponent(this, {
464                        controller: this.controller,
465                        contentBuilder: () => {
466                            this.contentBuilder();
467                        },
468                        buttons: this.buttons,
469                        theme: this.theme,
470                        themeColorMode: this.themeColorMode,
471                        fontSizeScale: this.__fontSizeScale,
472                        minContentHeight: this.__minContentHeight,
473                    }, undefined, elmtId, () => {
474                    }, { page: 'library/src/main/ets/components/dialog.ets', line: 182, col: 5 });
475                    ViewPU.create(componentCall);
476                    let paramsLambda = () => {
477                        return {
478                            controller: this.controller,
479                            contentBuilder: () => {
480                                this.contentBuilder();
481                            },
482                            buttons: this.buttons,
483                            theme: this.theme,
484                            themeColorMode: this.themeColorMode,
485                            fontSizeScale: this.fontSizeScale,
486                            minContentHeight: this.minContentHeight
487                        };
488                    };
489                    componentCall.paramsGenerator_ = paramsLambda;
490                } else {
491                    this.updateStateVarsOfChildByElmtId(elmtId, {});
492                }
493            }, { name: 'CustomDialogContentComponent' });
494        }
495        __Common__.pop();
496    }
497
498    contentBuilder(parent = null) {
499        {
500            this.observeComponentCreation2((elmtId, isInitialRender) => {
501                if (isInitialRender) {
502                    let componentCall = new TipsDialogContentLayout(this, {
503                        title: this.title,
504                        content: this.content,
505                        checkTips: this.checkTips,
506                        minContentHeight: this.__minContentHeight,
507                        dialogBuilder: () => {
508                            this.observeComponentCreation2((elmtId, isInitialRender) => {
509                                ForEach.create();
510                                const forEachItemGenFunction = _item => {
511                                    const index = _item;
512                                    this.observeComponentCreation2((elmtId, isInitialRender) => {
513                                        If.create();
514                                        if (index === this.imageIndex) {
515                                            this.ifElseBranchUpdateFunction(0, () => {
516                                                this.imagePart.bind(this)();
517                                            });
518                                        } else if (index === this.textIndex) {
519                                            this.ifElseBranchUpdateFunction(1, () => {
520                                                this.observeComponentCreation2((elmtId, isInitialRender) => {
521                                                    Column.create();
522                                                    Column.padding({ top: TIP_TEXT_TOP_PADDING() });
523                                                }, Column);
524                                                this.observeComponentCreation2((elmtId, isInitialRender) => {
525                                                    WithTheme.create({
526                                                        theme: this.theme,
527                                                        colorMode: this.themeColorMode
528                                                    });
529                                                }, WithTheme);
530                                                this.textPart.bind(this)();
531                                                WithTheme.pop();
532                                                Column.pop();
533                                            });
534                                        } else {
535                                            this.ifElseBranchUpdateFunction(2, () => {
536                                                this.observeComponentCreation2((elmtId, isInitialRender) => {
537                                                    WithTheme.create({
538                                                        theme: this.theme,
539                                                        colorMode: this.themeColorMode
540                                                    });
541                                                }, WithTheme);
542                                                this.checkBoxPart.bind(this)();
543                                                WithTheme.pop();
544                                            });
545                                        }
546                                    }, If);
547                                    If.pop();
548                                };
549                                this.forEachUpdateFunction(elmtId,
550                                    [this.imageIndex, this.textIndex, this.checkBoxIndex], forEachItemGenFunction);
551                            }, ForEach);
552                            ForEach.pop();
553                        }
554                    }, undefined, elmtId, () => {
555                    }, { page: 'library/src/main/ets/components/dialog.ets', line: 197, col: 5 });
556                    ViewPU.create(componentCall);
557                    let paramsLambda = () => {
558                        return {
559                            title: this.title,
560                            content: this.content,
561                            checkTips: this.checkTips,
562                            minContentHeight: this.minContentHeight,
563                            dialogBuilder: () => {
564                                this.observeComponentCreation2((elmtId, isInitialRender) => {
565                                    ForEach.create();
566                                    const forEachItemGenFunction = _item => {
567                                        const index = _item;
568                                        this.observeComponentCreation2((elmtId, isInitialRender) => {
569                                            If.create();
570                                            if (index === this.imageIndex) {
571                                                this.ifElseBranchUpdateFunction(0, () => {
572                                                    this.imagePart.bind(this)();
573                                                });
574                                            } else if (index === this.textIndex) {
575                                                this.ifElseBranchUpdateFunction(1, () => {
576                                                    this.observeComponentCreation2((elmtId, isInitialRender) => {
577                                                        Column.create();
578                                                        Column.padding({ top: TIP_TEXT_TOP_PADDING() });
579                                                    }, Column);
580                                                    this.observeComponentCreation2((elmtId, isInitialRender) => {
581                                                        WithTheme.create({
582                                                            theme: this.theme,
583                                                            colorMode: this.themeColorMode
584                                                        });
585                                                    }, WithTheme);
586                                                    this.textPart.bind(this)();
587                                                    WithTheme.pop();
588                                                    Column.pop();
589                                                });
590                                            } else {
591                                                this.ifElseBranchUpdateFunction(2, () => {
592                                                    this.observeComponentCreation2((elmtId, isInitialRender) => {
593                                                        WithTheme.create({
594                                                            theme: this.theme,
595                                                            colorMode: this.themeColorMode
596                                                        });
597                                                    }, WithTheme);
598                                                    this.checkBoxPart.bind(this)();
599                                                    WithTheme.pop();
600                                                });
601                                            }
602                                        }, If);
603                                        If.pop();
604                                    };
605                                    this.forEachUpdateFunction(elmtId,
606                                        [this.imageIndex, this.textIndex, this.checkBoxIndex], forEachItemGenFunction);
607                                }, ForEach);
608                                ForEach.pop();
609                            }
610                        };
611                    };
612                    componentCall.paramsGenerator_ = paramsLambda;
613                } else {
614                    this.updateStateVarsOfChildByElmtId(elmtId, {});
615                }
616            }, { name: 'TipsDialogContentLayout' });
617        }
618    }
619
620    checkBoxPart(parent = null) {
621        this.observeComponentCreation2((elmtId, isInitialRender) => {
622            Row.create();
623            Row.accessibilityGroup(true);
624            Row.accessibilityText(getCheckTipsAccessibilityText(this.checkTips, this.isChecked));
625            Row.accessibilityDescription(this.isChecked ? {
626                'id': -1,
627                'type': 10003,
628                params: ['sys.string.advanced_dialog_accessibility_cancel_checked_desc'],
629                'bundleName': '__harDefaultBundleName__',
630                'moduleName': '__harDefaultModuleName__'
631            } : {
632                'id': -1,
633                'type': 10003,
634                params: ['sys.string.slider_accessibility_unselectedDesc'],
635                'bundleName': '__harDefaultBundleName__',
636                'moduleName': '__harDefaultModuleName__'
637            });
638            Row.onClick(() => {
639                this.isChecked = !this.isChecked;
640                if (this.checkAction) {
641                    this.checkAction(this.isChecked);
642                }
643                try {
644                    let eventInfo = ({
645                        type: 'announceForAccessibility',
646                        bundleName: getContext()?.abilityInfo?.bundleName,
647                        triggerAction: 'common',
648                        textAnnouncedForAccessibility: this.isChecked ?
649                        getContext().resourceManager.getStringSync(125833934) :
650                        getContext().resourceManager.getStringSync(125833935)
651                    });
652                    accessibility.sendAccessibilityEvent(eventInfo).then(() => {
653                        console.info(`Accessibility send event`);
654                    });
655                } catch (exception) {
656                    let code = exception.code;
657                    let message = exception.message;
658                    hilog.error(0x3900, 'Ace', `Faild to send event, cause, code: ${code}, message: ${message}`);
659                }
660            });
661            Row.padding({ top: TIP_CHECKBOX_TOP_PADDING(), bottom: TIP_CHECKBOX_BOTTOM_PADDING() });
662            Row.constraintSize({ minHeight: CHECKBOX_CONTAINER_HEIGHT() });
663            Row.width('100%');
664        }, Row);
665        this.observeComponentCreation2((elmtId, isInitialRender) => {
666            If.create();
667            if (this.checkTips !== null) {
668                this.ifElseBranchUpdateFunction(0, () => {
669                    this.observeComponentCreation2((elmtId, isInitialRender) => {
670                        Checkbox.create({ name: '', group: 'checkboxGroup' });
671                        Checkbox.select(this.isChecked);
672                        Checkbox.onChange((checked) => {
673                            this.isChecked = checked;
674                            if (this.checkAction) {
675                                this.checkAction(checked);
676                            }
677                            if (this.onCheckedChange) {
678                                this.onCheckedChange(checked);
679                            }
680                        });
681                        Checkbox.margin({
682                            start: LengthMetrics.vp(0),
683                            end: LengthMetrics.vp(TIP_CHECKBOX_END_MARGIN())
684                        });
685                    }, Checkbox);
686                    Checkbox.pop();
687                    this.observeComponentCreation2((elmtId, isInitialRender) => {
688                        Text.create(this.checkTips);
689                        Text.fontSize(`${CONTENT_FONT_SIZE()}fp`);
690                        Text.fontWeight(FontWeight.Regular);
691                        Text.fontColor(ObservedObject.GetRawObject(this.fontColorWithTheme));
692                        Text.maxLines(CONTENT_MAX_LINES);
693                        Text.layoutWeight(1);
694                        Text.focusable(false);
695                        Text.textOverflow({ overflow: TextOverflow.Ellipsis });
696                    }, Text);
697                    Text.pop();
698                });
699            } else {
700                this.ifElseBranchUpdateFunction(1, () => {
701                });
702            }
703        }, If);
704        If.pop();
705        Row.pop();
706    }
707
708    imagePart(parent = null) {
709        this.observeComponentCreation2((elmtId, isInitialRender) => {
710            Column.create();
711            Column.width('100%');
712        }, Column);
713        this.observeComponentCreation2((elmtId, isInitialRender) => {
714            Image.create(this.imageRes);
715            Image.objectFit(ImageFit.Contain);
716            Image.borderRadius(DEFAULT_IMAGE_RADIUS());
717            Image.constraintSize({
718                maxWidth: this.imageSize?.width ?? DEFAULT_IMAGE_SIZE(),
719                maxHeight: this.imageSize?.height ?? DEFAULT_IMAGE_SIZE()
720            });
721        }, Image);
722        Column.pop();
723    }
724
725    textPart(parent = null) {
726        this.observeComponentCreation2((elmtId, isInitialRender) => {
727            Scroll.create(this.contentScroller);
728            Scroll.fadingEdge(IS_FADEOUT_ENABLE(), { fadingEdgeLength: LengthMetrics.vp(FADEOUT_GRADIENT_WIDTH) });
729            Scroll.nestedScroll({
730                scrollForward: NestedScrollMode.PARALLEL,
731                scrollBackward: NestedScrollMode.PARALLEL
732            });
733            Scroll.margin({ end: LengthMetrics.vp(0 - SCROLL_BAR_OFFSET) });
734        }, Scroll);
735        this.observeComponentCreation2((elmtId, isInitialRender) => {
736            Column.create();
737            Column.margin({ end: LengthMetrics.vp(SCROLL_BAR_OFFSET) });
738            Column.width(`calc(100% - ${SCROLL_BAR_OFFSET}vp)`);
739        }, Column);
740        this.observeComponentCreation2((elmtId, isInitialRender) => {
741            If.create();
742            if (this.title !== null) {
743                this.ifElseBranchUpdateFunction(0, () => {
744                    this.observeComponentCreation2((elmtId, isInitialRender) => {
745                        Row.create();
746                        Row.padding({
747                            bottom: {
748                                'id': -1,
749                                'type': 10002,
750                                params: ['sys.float.padding_level8'],
751                                'bundleName': '__harDefaultBundleName__',
752                                'moduleName': '__harDefaultModuleName__'
753                            }
754                        });
755                    }, Row);
756                    this.observeComponentCreation2((elmtId, isInitialRender) => {
757                        Text.create(this.title);
758                        Text.fontSize(`${TITLE_S}fp`);
759                        Text.maxFontScale(Math.min(this.appMaxFontScale, MAX_FONT_SCALE));
760                        Text.fontWeight(TITLE_FONT_WEIGHT());
761                        Text.fontColor(ObservedObject.GetRawObject(this.fontColorWithTheme));
762                        Text.textAlign(TextAlign.Center);
763                        Text.maxLines(CONTENT_MAX_LINES);
764                        Text.textOverflow({ overflow: TextOverflow.Ellipsis });
765                        Text.width('100%');
766                    }, Text);
767                    Text.pop();
768                    Row.pop();
769                });
770            } else {
771                this.ifElseBranchUpdateFunction(1, () => {
772                });
773            }
774        }, If);
775        If.pop();
776        this.observeComponentCreation2((elmtId, isInitialRender) => {
777            If.create();
778            if (this.content !== null) {
779                this.ifElseBranchUpdateFunction(0, () => {
780                    this.observeComponentCreation2((elmtId, isInitialRender) => {
781                        Row.create();
782                    }, Row);
783                    this.observeComponentCreation2((elmtId, isInitialRender) => {
784                        Text.create(this.content);
785                        Text.focusable(true);
786                        Text.defaultFocus(!(this.primaryButton || this.secondaryButton));
787                        Text.focusBox({
788                            strokeWidth: LengthMetrics.px(0)
789                        });
790                        Text.fontSize(this.getContentFontSize());
791                        Text.fontWeight(CONTENT_FONT_WEIGHT());
792                        Text.fontColor(ObservedObject.GetRawObject(this.fontColorWithTheme));
793                        Text.textAlign(this.textAlignment);
794                        Text.width('100%');
795                        Text.onKeyEvent((event) => {
796                            if (event) {
797                                resolveKeyEvent(event, this.contentScroller);
798                            }
799                        });
800                    }, Text);
801                    Text.pop();
802                    Row.pop();
803                });
804            } else {
805                this.ifElseBranchUpdateFunction(1, () => {
806                });
807            }
808        }, If);
809        If.pop();
810        Column.pop();
811        Scroll.pop();
812    }
813
814    aboutToAppear() {
815        this.fontColorWithTheme = this.theme?.colors?.fontPrimary ?
816        this.theme.colors.fontPrimary : {
817                'id': -1,
818                'type': 10001,
819                params: ['sys.color.font_primary'],
820                'bundleName': '__harDefaultBundleName__',
821                'moduleName': '__harDefaultModuleName__'
822            };
823        let uiContext = this.getUIContext();
824        this.appMaxFontScale = uiContext.getMaxFontScale();
825        this.initButtons();
826        this.initMargin();
827    }
828
829    getContentFontSize() {
830        return CONTENT_FONT_SIZE() + 'fp';
831    }
832
833    initButtons() {
834        if (!this.primaryButton && !this.secondaryButton) {
835            return;
836        }
837        this.buttons = [];
838        if (this.primaryButton) {
839            this.buttons.push(this.primaryButton);
840        }
841        if (this.secondaryButton) {
842            this.buttons.push(this.secondaryButton);
843        }
844    }
845
846    initMargin() {
847        this.marginOffset = 0 - SCROLL_END_MARGIN();
848    }
849
850    rerender() {
851        this.updateDirtyElements();
852    }
853}
854
855class TipsDialogContentLayout extends ViewPU {
856    constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) {
857        super(parent, __localStorage, elmtId, extraInfo);
858        if (typeof paramsLambda === 'function') {
859            this.paramsGenerator_ = paramsLambda;
860        }
861        this.title = null;
862        this.content = null;
863        this.checkTips = null;
864        this.__minContentHeight = new SynchedPropertySimpleTwoWayPU(params.minContentHeight, this, 'minContentHeight');
865        this.dialogBuilder = this.doNothingBuilder;
866        this.imageIndex = 0;
867        this.textIndex = 1;
868        this.checkBoxIndex = 2;
869        this.childrenSize = 3;
870        this.setInitiallyProvidedValue(params);
871        this.finalizeConstruction();
872    }
873
874    setInitiallyProvidedValue(params) {
875        if (params.title !== undefined) {
876            this.title = params.title;
877        }
878        if (params.content !== undefined) {
879            this.content = params.content;
880        }
881        if (params.checkTips !== undefined) {
882            this.checkTips = params.checkTips;
883        }
884        if (params.dialogBuilder !== undefined) {
885            this.dialogBuilder = params.dialogBuilder;
886        }
887        if (params.imageIndex !== undefined) {
888            this.imageIndex = params.imageIndex;
889        }
890        if (params.textIndex !== undefined) {
891            this.textIndex = params.textIndex;
892        }
893        if (params.checkBoxIndex !== undefined) {
894            this.checkBoxIndex = params.checkBoxIndex;
895        }
896        if (params.childrenSize !== undefined) {
897            this.childrenSize = params.childrenSize;
898        }
899    }
900
901    updateStateVars(params) {
902    }
903
904    purgeVariableDependenciesOnElmtId(rmElmtId) {
905        this.__minContentHeight.purgeDependencyOnElmtId(rmElmtId);
906    }
907
908    aboutToBeDeleted() {
909        this.__minContentHeight.aboutToBeDeleted();
910        SubscriberManager.Get().delete(this.id__());
911        this.aboutToBeDeletedInternal();
912    }
913
914    doNothingBuilder(parent = null) {
915    }
916
917    get minContentHeight() {
918        return this.__minContentHeight.get();
919    }
920
921    set minContentHeight(newValue) {
922        this.__minContentHeight.set(newValue);
923    }
924
925    onPlaceChildren(selfLayoutInfo, children, constraint) {
926        let currentX = 0;
927        let currentY = 0;
928        for (let index = 0; index < children.length; index++) {
929            let child = children[index];
930            child.layout({ x: currentX, y: currentY });
931            currentY += child.measureResult.height;
932        }
933    }
934
935    onMeasureSize(selfLayoutInfo, children, constraint) {
936        let sizeResult = { width: Number(constraint.maxWidth), height: 0 };
937        if (children.length < this.childrenSize) {
938            return sizeResult;
939        }
940        let height = 0;
941        let checkBoxHeight = 0;
942        if (this.checkTips !== null) {
943            let checkboxChild = children[this.checkBoxIndex];
944            let checkboxConstraint = {
945                maxWidth: constraint.maxWidth,
946                minHeight: CHECKBOX_CONTAINER_HEIGHT(),
947                maxHeight: constraint.maxHeight
948            };
949            let checkBoxMeasureResult = checkboxChild.measure(checkboxConstraint);
950            checkBoxHeight = checkBoxMeasureResult.height;
951            height += checkBoxHeight;
952        }
953        let imageChild = children[this.imageIndex];
954        let textMinHeight = 0;
955        if (this.title !== null || this.content !== null) {
956            textMinHeight = TEXT_MIN_HEIGHT + PADDING_LEVEL_8;
957        }
958        let imageMaxHeight = Number(constraint.maxHeight) - checkBoxHeight - textMinHeight;
959        let imageConstraint = {
960            maxWidth: constraint.maxWidth,
961            maxHeight: imageMaxHeight
962        };
963        let imageMeasureResult = imageChild.measure(imageConstraint);
964        height += imageMeasureResult.height;
965        if (this.title !== null || this.content !== null) {
966            let textChild = children[this.textIndex];
967            let contentMaxHeight = Number(constraint.maxHeight) - imageMeasureResult.height - checkBoxHeight;
968            let contentConstraint = {
969                maxWidth: constraint.maxWidth,
970                maxHeight: Math.max(contentMaxHeight, TEXT_MIN_HEIGHT)
971            };
972            let contentMeasureResult = textChild.measure(contentConstraint);
973            height += contentMeasureResult.height;
974        }
975        sizeResult.height = height;
976        this.minContentHeight =
977            Math.max(checkBoxHeight + imageMeasureResult.height + textMinHeight, MIN_CONTENT_HEIGHT);
978        return sizeResult;
979    }
980
981    initialRender() {
982        this.dialogBuilder.bind(this)();
983    }
984
985    rerender() {
986        this.updateDirtyElements();
987    }
988}
989
990export class SelectDialog extends ViewPU {
991    constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) {
992        super(parent, __localStorage, elmtId, extraInfo);
993        if (typeof paramsLambda === 'function') {
994            this.paramsGenerator_ = paramsLambda;
995        }
996        this.controller = undefined;
997        this.title = '';
998        this.content = '';
999        this.confirm = null;
1000        this.radioContent = [];
1001        this.buttons = [];
1002        this.contentPadding = undefined;
1003        this.isFocus = false;
1004        this.currentFocusIndex = -1;
1005        this.radioHeight = 0;
1006        this.itemHeight = 0;
1007        this.__selectedIndex = new ObservedPropertySimplePU(-1, this, 'selectedIndex');
1008        this.contentBuilder = this.buildContent;
1009        this.__fontColorWithTheme = new ObservedPropertyObjectPU({
1010            'id': -1,
1011            'type': 10001,
1012            params: ['sys.color.font_primary'],
1013            'bundleName': '__harDefaultBundleName__',
1014            'moduleName': '__harDefaultModuleName__'
1015        }, this, 'fontColorWithTheme');
1016        this.__dividerColorWithTheme = new ObservedPropertyObjectPU({
1017            'id': -1,
1018            'type': 10001,
1019            params: ['sys.color.comp_divider'],
1020            'bundleName': '__harDefaultBundleName__',
1021            'moduleName': '__harDefaultModuleName__'
1022        }, this, 'dividerColorWithTheme');
1023        this.theme = new CustomThemeImpl({});
1024        this.themeColorMode = ThemeColorMode.SYSTEM;
1025        this.contentScroller = new Scroller();
1026        this.__fontSizeScale = new ObservedPropertySimplePU(1, this, 'fontSizeScale');
1027        this.__minContentHeight = new ObservedPropertySimplePU(MIN_CONTENT_HEIGHT, this, 'minContentHeight');
1028        this.setInitiallyProvidedValue(params);
1029        this.finalizeConstruction();
1030    }
1031
1032    setInitiallyProvidedValue(params) {
1033        if (params.controller !== undefined) {
1034            this.controller = params.controller;
1035        }
1036        if (params.title !== undefined) {
1037            this.title = params.title;
1038        }
1039        if (params.content !== undefined) {
1040            this.content = params.content;
1041        }
1042        if (params.confirm !== undefined) {
1043            this.confirm = params.confirm;
1044        }
1045        if (params.radioContent !== undefined) {
1046            this.radioContent = params.radioContent;
1047        }
1048        if (params.buttons !== undefined) {
1049            this.buttons = params.buttons;
1050        }
1051        if (params.contentPadding !== undefined) {
1052            this.contentPadding = params.contentPadding;
1053        }
1054        if (params.isFocus !== undefined) {
1055            this.isFocus = params.isFocus;
1056        }
1057        if (params.currentFocusIndex !== undefined) {
1058            this.currentFocusIndex = params.currentFocusIndex;
1059        }
1060        if (params.radioHeight !== undefined) {
1061            this.radioHeight = params.radioHeight;
1062        }
1063        if (params.itemHeight !== undefined) {
1064            this.itemHeight = params.itemHeight;
1065        }
1066        if (params.selectedIndex !== undefined) {
1067            this.selectedIndex = params.selectedIndex;
1068        }
1069        if (params.contentBuilder !== undefined) {
1070            this.contentBuilder = params.contentBuilder;
1071        }
1072        if (params.fontColorWithTheme !== undefined) {
1073            this.fontColorWithTheme = params.fontColorWithTheme;
1074        }
1075        if (params.dividerColorWithTheme !== undefined) {
1076            this.dividerColorWithTheme = params.dividerColorWithTheme;
1077        }
1078        if (params.theme !== undefined) {
1079            this.theme = params.theme;
1080        }
1081        if (params.themeColorMode !== undefined) {
1082            this.themeColorMode = params.themeColorMode;
1083        }
1084        if (params.contentScroller !== undefined) {
1085            this.contentScroller = params.contentScroller;
1086        }
1087        if (params.fontSizeScale !== undefined) {
1088            this.fontSizeScale = params.fontSizeScale;
1089        }
1090        if (params.minContentHeight !== undefined) {
1091            this.minContentHeight = params.minContentHeight;
1092        }
1093    }
1094
1095    updateStateVars(params) {
1096    }
1097
1098    purgeVariableDependenciesOnElmtId(rmElmtId) {
1099        this.__selectedIndex.purgeDependencyOnElmtId(rmElmtId);
1100        this.__fontColorWithTheme.purgeDependencyOnElmtId(rmElmtId);
1101        this.__dividerColorWithTheme.purgeDependencyOnElmtId(rmElmtId);
1102        this.__fontSizeScale.purgeDependencyOnElmtId(rmElmtId);
1103        this.__minContentHeight.purgeDependencyOnElmtId(rmElmtId);
1104    }
1105
1106    aboutToBeDeleted() {
1107        this.__selectedIndex.aboutToBeDeleted();
1108        this.__fontColorWithTheme.aboutToBeDeleted();
1109        this.__dividerColorWithTheme.aboutToBeDeleted();
1110        this.__fontSizeScale.aboutToBeDeleted();
1111        this.__minContentHeight.aboutToBeDeleted();
1112        SubscriberManager.Get().delete(this.id__());
1113        this.aboutToBeDeletedInternal();
1114    }
1115
1116    setController(ctr) {
1117        this.controller = ctr;
1118    }
1119
1120    get selectedIndex() {
1121        return this.__selectedIndex.get();
1122    }
1123
1124    set selectedIndex(newValue) {
1125        this.__selectedIndex.set(newValue);
1126    }
1127
1128    get fontColorWithTheme() {
1129        return this.__fontColorWithTheme.get();
1130    }
1131
1132    set fontColorWithTheme(newValue) {
1133        this.__fontColorWithTheme.set(newValue);
1134    }
1135
1136    get dividerColorWithTheme() {
1137        return this.__dividerColorWithTheme.get();
1138    }
1139
1140    set dividerColorWithTheme(newValue) {
1141        this.__dividerColorWithTheme.set(newValue);
1142    }
1143
1144    get fontSizeScale() {
1145        return this.__fontSizeScale.get();
1146    }
1147
1148    set fontSizeScale(newValue) {
1149        this.__fontSizeScale.set(newValue);
1150    }
1151
1152    get minContentHeight() {
1153        return this.__minContentHeight.get();
1154    }
1155
1156    set minContentHeight(newValue) {
1157        this.__minContentHeight.set(newValue);
1158    }
1159
1160    buildContent(parent = null) {
1161        this.observeComponentCreation2((elmtId, isInitialRender) => {
1162            Scroll.create(this.contentScroller);
1163            Scroll.scrollBar(BarState.Auto);
1164            Scroll.nestedScroll({
1165                scrollForward: NestedScrollMode.PARALLEL,
1166                scrollBackward: NestedScrollMode.PARALLEL
1167            });
1168            Scroll.onDidScroll((xOffset, yOffset) => {
1169                let scrollHeight = (this.itemHeight - this.radioHeight) / 2;
1170                if (this.isFocus) {
1171                    if (this.currentFocusIndex === this.radioContent.length - 1) {
1172                        this.contentScroller.scrollEdge(Edge.Bottom);
1173                        this.currentFocusIndex = -1;
1174                    } else if (this.currentFocusIndex === FIRST_ITEM_INDEX) {
1175                        this.contentScroller.scrollEdge(Edge.Top);
1176                        this.currentFocusIndex = -1;
1177                    } else {
1178                        if (yOffset > 0) {
1179                            this.contentScroller.scrollBy(0, scrollHeight);
1180                        } else if (yOffset < 0) {
1181                            this.contentScroller.scrollBy(0, 0 - scrollHeight);
1182                        }
1183                    }
1184                    this.isFocus = false;
1185                }
1186            });
1187            Scroll.margin({ end: LengthMetrics.vp(SELECT_DIALOG_SCROLL_BAR_OFFSET) });
1188        }, Scroll);
1189        this.observeComponentCreation2((elmtId, isInitialRender) => {
1190            Column.create();
1191        }, Column);
1192        this.observeComponentCreation2((elmtId, isInitialRender) => {
1193            If.create();
1194            if (this.content) {
1195                this.ifElseBranchUpdateFunction(0, () => {
1196                    this.observeComponentCreation2((elmtId, isInitialRender) => {
1197                        Row.create();
1198                        Row.padding({
1199                            left: {
1200                                'id': -1,
1201                                'type': 10002,
1202                                params: ['sys.float.padding_level12'],
1203                                'bundleName': '__harDefaultBundleName__',
1204                                'moduleName': '__harDefaultModuleName__'
1205                            },
1206                            right: {
1207                                'id': -1,
1208                                'type': 10002,
1209                                params: ['sys.float.padding_level12'],
1210                                'bundleName': '__harDefaultBundleName__',
1211                                'moduleName': '__harDefaultModuleName__'
1212                            },
1213                            bottom: {
1214                                'id': -1,
1215                                'type': 10002,
1216                                params: ['sys.float.padding_level4'],
1217                                'bundleName': '__harDefaultBundleName__',
1218                                'moduleName': '__harDefaultModuleName__'
1219                            }
1220                        });
1221                        Row.width('100%');
1222                    }, Row);
1223                    this.observeComponentCreation2((elmtId, isInitialRender) => {
1224                        Text.create(this.content);
1225                        Text.fontSize(`${BODY_M}fp`);
1226                        Text.fontWeight(FontWeight.Regular);
1227                        Text.fontColor(ObservedObject.GetRawObject(this.fontColorWithTheme));
1228                        Text.textOverflow({ overflow: TextOverflow.Ellipsis });
1229                    }, Text);
1230                    Text.pop();
1231                    Row.pop();
1232                });
1233            } else {
1234                this.ifElseBranchUpdateFunction(1, () => {
1235                });
1236            }
1237        }, If);
1238        If.pop();
1239        this.observeComponentCreation2((elmtId, isInitialRender) => {
1240            List.create();
1241            List.width('100%');
1242            List.clip(false);
1243            List.onFocus(() => {
1244                if (!this.contentScroller.isAtEnd()) {
1245                    this.contentScroller.scrollEdge(Edge.Top);
1246                    focusControl.requestFocus(String(FIRST_ITEM_INDEX));
1247                }
1248            });
1249            List.defaultFocus(this.buttons?.length === 0 ? true : false);
1250        }, List);
1251        this.observeComponentCreation2((elmtId, isInitialRender) => {
1252            ForEach.create();
1253            const forEachItemGenFunction = (_item, index) => {
1254                const item = _item;
1255                {
1256                    const itemCreation = (elmtId, isInitialRender) => {
1257                        ViewStackProcessor.StartGetAccessRecordingFor(elmtId);
1258                        itemCreation2(elmtId, isInitialRender);
1259                        if (!isInitialRender) {
1260                            ListItem.pop();
1261                        }
1262                        ViewStackProcessor.StopGetAccessRecording();
1263                    };
1264                    const itemCreation2 = (elmtId, isInitialRender) => {
1265                        ListItem.create(deepRenderFunction, true);
1266                        ListItem.padding({
1267                            left: {
1268                                'id': -1,
1269                                'type': 10002,
1270                                params: ['sys.float.padding_level6'],
1271                                'bundleName': '__harDefaultBundleName__',
1272                                'moduleName': '__harDefaultModuleName__'
1273                            },
1274                            right: {
1275                                'id': -1,
1276                                'type': 10002,
1277                                params: ['sys.float.padding_level6'],
1278                                'bundleName': '__harDefaultBundleName__',
1279                                'moduleName': '__harDefaultModuleName__'
1280                            }
1281                        });
1282                        ListItem.onSizeChange((oldValue, newValue) => {
1283                            this.itemHeight = Number(newValue.height);
1284                        });
1285                    };
1286                    const deepRenderFunction = (elmtId, isInitialRender) => {
1287                        itemCreation(elmtId, isInitialRender);
1288                        this.observeComponentCreation2((elmtId, isInitialRender) => {
1289                            Column.create();
1290                            Column.borderRadius({
1291                                'id': -1,
1292                                'type': 10002,
1293                                params: ['sys.float.corner_radius_level8'],
1294                                'bundleName': '__harDefaultBundleName__',
1295                                'moduleName': '__harDefaultModuleName__'
1296                            });
1297                            Column.focusBox({
1298                                margin: { value: -2, unit: LengthUnit.VP }
1299                            });
1300                            Column.accessibilityText(getAccessibilityText(item.title, this.selectedIndex === index));
1301                            Column.onClick(() => {
1302                                this.selectedIndex = index;
1303                                item.action && item.action();
1304                                closeDialog(this.controller, 'onClick');
1305                            });
1306                        }, Column);
1307                        this.observeComponentCreation2((elmtId, isInitialRender) => {
1308                            Button.createWithChild();
1309                            Button.type(ButtonType.Normal);
1310                            Button.borderRadius({
1311                                'id': -1,
1312                                'type': 10002,
1313                                params: ['sys.float.corner_radius_level8'],
1314                                'bundleName': '__harDefaultBundleName__',
1315                                'moduleName': '__harDefaultModuleName__'
1316                            });
1317                            Button.buttonStyle(ButtonStyleMode.TEXTUAL);
1318                            Button.padding({
1319                                left: {
1320                                    'id': -1,
1321                                    'type': 10002,
1322                                    params: ['sys.float.padding_level6'],
1323                                    'bundleName': '__harDefaultBundleName__',
1324                                    'moduleName': '__harDefaultModuleName__'
1325                                },
1326                                right: {
1327                                    'id': -1,
1328                                    'type': 10002,
1329                                    params: ['sys.float.padding_level6'],
1330                                    'bundleName': '__harDefaultBundleName__',
1331                                    'moduleName': '__harDefaultModuleName__'
1332                                }
1333                            });
1334                        }, Button);
1335                        this.observeComponentCreation2((elmtId, isInitialRender) => {
1336                            Row.create();
1337                            Row.constraintSize({ minHeight: LIST_MIN_HEIGHT });
1338                            Row.clip(false);
1339                            Row.padding({
1340                                top: {
1341                                    'id': -1,
1342                                    'type': 10002,
1343                                    params: ['sys.float.padding_level4'],
1344                                    'bundleName': '__harDefaultBundleName__',
1345                                    'moduleName': '__harDefaultModuleName__'
1346                                },
1347                                bottom: {
1348                                    'id': -1,
1349                                    'type': 10002,
1350                                    params: ['sys.float.padding_level4'],
1351                                    'bundleName': '__harDefaultBundleName__',
1352                                    'moduleName': '__harDefaultModuleName__'
1353                                }
1354                            });
1355                        }, Row);
1356                        this.observeComponentCreation2((elmtId, isInitialRender) => {
1357                            Text.create(item.title);
1358                            Text.fontSize(`${BODY_L}fp`);
1359                            Text.fontWeight(FontWeight.Medium);
1360                            Text.fontColor(ObservedObject.GetRawObject(this.fontColorWithTheme));
1361                            Text.layoutWeight(1);
1362                            Text.direction(i18n.isRTL(i18n.System.getSystemLanguage()) ? Direction.Rtl : Direction.Ltr);
1363                        }, Text);
1364                        Text.pop();
1365                        this.observeComponentCreation2((elmtId, isInitialRender) => {
1366                            Radio.create({ value: 'item.title', group: 'radioGroup' });
1367                            Radio.size({ width: CHECKBOX_CONTAINER_LENGTH, height: CHECKBOX_CONTAINER_LENGTH });
1368                            Radio.checked(this.selectedIndex === index);
1369                            Radio.hitTestBehavior(HitTestMode.None);
1370                            Radio.id(String(index));
1371                            Radio.focusable(false);
1372                            Radio.accessibilityLevel('no');
1373                            Radio.onFocus(() => {
1374                                this.isFocus = true;
1375                                this.currentFocusIndex = index;
1376                                if (index === FIRST_ITEM_INDEX) {
1377                                    this.contentScroller.scrollEdge(Edge.Top);
1378                                } else if (index === this.radioContent.length - 1) {
1379                                    this.contentScroller.scrollEdge(Edge.Bottom);
1380                                }
1381                            });
1382                            Radio.onSizeChange((oldValue, newValue) => {
1383                                this.radioHeight = Number(newValue.height);
1384                            });
1385                        }, Radio);
1386                        Row.pop();
1387                        Button.pop();
1388                        this.observeComponentCreation2((elmtId, isInitialRender) => {
1389                            If.create();
1390                            if (index < this.radioContent.length - 1) {
1391                                this.ifElseBranchUpdateFunction(0, () => {
1392                                    this.observeComponentCreation2((elmtId, isInitialRender) => {
1393                                        Divider.create();
1394                                        Divider.color(ObservedObject.GetRawObject(this.dividerColorWithTheme));
1395                                        Divider.padding({
1396                                            left: {
1397                                                'id': -1,
1398                                                'type': 10002,
1399                                                params: ['sys.float.padding_level6'],
1400                                                'bundleName': '__harDefaultBundleName__',
1401                                                'moduleName': '__harDefaultModuleName__'
1402                                            },
1403                                            right: {
1404                                                'id': -1,
1405                                                'type': 10002,
1406                                                params: ['sys.float.padding_level6'],
1407                                                'bundleName': '__harDefaultBundleName__',
1408                                                'moduleName': '__harDefaultModuleName__'
1409                                            }
1410                                        });
1411                                    }, Divider);
1412                                });
1413                            } else {
1414                                this.ifElseBranchUpdateFunction(1, () => {
1415                                });
1416                            }
1417                        }, If);
1418                        If.pop();
1419                        Column.pop();
1420                        ListItem.pop();
1421                    };
1422                    this.observeComponentCreation2(itemCreation2, ListItem);
1423                    ListItem.pop();
1424                }
1425            };
1426            this.forEachUpdateFunction(elmtId, this.radioContent, forEachItemGenFunction, undefined, true, false);
1427        }, ForEach);
1428        ForEach.pop();
1429        List.pop();
1430        Column.pop();
1431        Scroll.pop();
1432    }
1433
1434    initialRender() {
1435        this.observeComponentCreation2((elmtId, isInitialRender) => {
1436            __Common__.create();
1437            __Common__.constraintSize({ maxHeight: '100%' });
1438        }, __Common__);
1439        {
1440            this.observeComponentCreation2((elmtId, isInitialRender) => {
1441                if (isInitialRender) {
1442                    let componentCall = new CustomDialogContentComponent(this, {
1443                        controller: this.controller,
1444                        primaryTitle: this.title,
1445                        contentBuilder: () => {
1446                            this.contentBuilder();
1447                        },
1448                        buttons: this.buttons,
1449                        contentAreaPadding: this.contentPadding,
1450                        theme: this.theme,
1451                        themeColorMode: this.themeColorMode,
1452                        fontSizeScale: this.__fontSizeScale,
1453                        minContentHeight: this.__minContentHeight,
1454                    }, undefined, elmtId, () => {
1455                    }, { page: 'library/src/main/ets/components/dialog.ets', line: 600, col: 5 });
1456                    ViewPU.create(componentCall);
1457                    let paramsLambda = () => {
1458                        return {
1459                            controller: this.controller,
1460                            primaryTitle: this.title,
1461                            contentBuilder: () => {
1462                                this.contentBuilder();
1463                            },
1464                            buttons: this.buttons,
1465                            contentAreaPadding: this.contentPadding,
1466                            theme: this.theme,
1467                            themeColorMode: this.themeColorMode,
1468                            fontSizeScale: this.fontSizeScale,
1469                            minContentHeight: this.minContentHeight
1470                        };
1471                    };
1472                    componentCall.paramsGenerator_ = paramsLambda;
1473                } else {
1474                    this.updateStateVarsOfChildByElmtId(elmtId, {});
1475                }
1476            }, { name: 'CustomDialogContentComponent' });
1477        }
1478        __Common__.pop();
1479    }
1480
1481    aboutToAppear() {
1482        this.fontColorWithTheme = this.theme?.colors?.fontPrimary ?
1483        this.theme.colors.fontPrimary : {
1484                'id': -1,
1485                'type': 10001,
1486                params: ['sys.color.font_primary'],
1487                'bundleName': '__harDefaultBundleName__',
1488                'moduleName': '__harDefaultModuleName__'
1489            };
1490        this.dividerColorWithTheme = this.theme?.colors?.compDivider ?
1491        this.theme.colors.compDivider : {
1492                'id': -1,
1493                'type': 10001,
1494                params: ['sys.color.comp_divider'],
1495                'bundleName': '__harDefaultBundleName__',
1496                'moduleName': '__harDefaultModuleName__'
1497            };
1498        this.initContentPadding();
1499        this.initButtons();
1500    }
1501
1502    initContentPadding() {
1503        this.contentPadding = {
1504            left: {
1505                'id': -1,
1506                'type': 10002,
1507                params: ['sys.float.padding_level0'],
1508                'bundleName': '__harDefaultBundleName__',
1509                'moduleName': '__harDefaultModuleName__'
1510            },
1511            right: {
1512                'id': -1,
1513                'type': 10002,
1514                params: ['sys.float.padding_level0'],
1515                'bundleName': '__harDefaultBundleName__',
1516                'moduleName': '__harDefaultModuleName__'
1517            }
1518        };
1519        if (!this.title && !this.confirm) {
1520            this.contentPadding = {
1521                top: {
1522                    'id': -1,
1523                    'type': 10002,
1524                    params: ['sys.float.padding_level12'],
1525                    'bundleName': '__harDefaultBundleName__',
1526                    'moduleName': '__harDefaultModuleName__'
1527                },
1528                bottom: {
1529                    'id': -1,
1530                    'type': 10002,
1531                    params: ['sys.float.padding_level12'],
1532                    'bundleName': '__harDefaultBundleName__',
1533                    'moduleName': '__harDefaultModuleName__'
1534                }
1535            };
1536            return;
1537        }
1538        if (!this.title) {
1539            this.contentPadding = {
1540                top: {
1541                    'id': -1,
1542                    'type': 10002,
1543                    params: ['sys.float.padding_level12'],
1544                    'bundleName': '__harDefaultBundleName__',
1545                    'moduleName': '__harDefaultModuleName__'
1546                }
1547            };
1548        } else if (!this.confirm) {
1549            this.contentPadding = {
1550                bottom: {
1551                    'id': -1,
1552                    'type': 10002,
1553                    params: ['sys.float.padding_level12'],
1554                    'bundleName': '__harDefaultBundleName__',
1555                    'moduleName': '__harDefaultModuleName__'
1556                }
1557            };
1558        }
1559    }
1560
1561    initButtons() {
1562        this.buttons = [];
1563        if (this.confirm) {
1564            this.buttons.push(this.confirm);
1565        }
1566    }
1567
1568    rerender() {
1569        this.updateDirtyElements();
1570    }
1571}
1572
1573class ConfirmDialogContentLayout extends ViewPU {
1574    constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) {
1575        super(parent, __localStorage, elmtId, extraInfo);
1576        if (typeof paramsLambda === 'function') {
1577            this.paramsGenerator_ = paramsLambda;
1578        }
1579        this.textIndex = 0;
1580        this.checkboxIndex = 1;
1581        this.__minContentHeight = new SynchedPropertySimpleTwoWayPU(params.minContentHeight, this, 'minContentHeight');
1582        this.updateTextAlign = (maxWidth) => {
1583        };
1584        this.dialogBuilder = this.doNothingBuilder;
1585        this.setInitiallyProvidedValue(params);
1586        this.finalizeConstruction();
1587    }
1588
1589    setInitiallyProvidedValue(params) {
1590        if (params.textIndex !== undefined) {
1591            this.textIndex = params.textIndex;
1592        }
1593        if (params.checkboxIndex !== undefined) {
1594            this.checkboxIndex = params.checkboxIndex;
1595        }
1596        if (params.updateTextAlign !== undefined) {
1597            this.updateTextAlign = params.updateTextAlign;
1598        }
1599        if (params.dialogBuilder !== undefined) {
1600            this.dialogBuilder = params.dialogBuilder;
1601        }
1602    }
1603
1604    updateStateVars(params) {
1605    }
1606
1607    purgeVariableDependenciesOnElmtId(rmElmtId) {
1608        this.__minContentHeight.purgeDependencyOnElmtId(rmElmtId);
1609    }
1610
1611    aboutToBeDeleted() {
1612        this.__minContentHeight.aboutToBeDeleted();
1613        SubscriberManager.Get().delete(this.id__());
1614        this.aboutToBeDeletedInternal();
1615    }
1616
1617    get minContentHeight() {
1618        return this.__minContentHeight.get();
1619    }
1620
1621    set minContentHeight(newValue) {
1622        this.__minContentHeight.set(newValue);
1623    }
1624
1625    doNothingBuilder(parent = null) {
1626    }
1627
1628    onPlaceChildren(selfLayoutInfo, children, constraint) {
1629        let currentX = 0;
1630        let currentY = 0;
1631        for (let index = 0; index < children.length; index++) {
1632            let child = children[index];
1633            child.layout({ x: currentX, y: currentY });
1634            currentY += child.measureResult.height;
1635        }
1636    }
1637
1638    onMeasureSize(selfLayoutInfo, children, constraint) {
1639        let sizeResult = { width: Number(constraint.maxWidth), height: 0 };
1640        let childrenSize = 2;
1641        if (children.length < childrenSize) {
1642            return sizeResult;
1643        }
1644        this.updateTextAlign(sizeResult.width);
1645        let height = 0;
1646        let checkboxChild = children[this.checkboxIndex];
1647        let checkboxConstraint = {
1648            maxWidth: constraint.maxWidth,
1649            minHeight: CHECKBOX_CONTAINER_HEIGHT(),
1650            maxHeight: constraint.maxHeight
1651        };
1652        let checkBoxMeasureResult = checkboxChild.measure(checkboxConstraint);
1653        height += checkBoxMeasureResult.height;
1654        let textChild = children[this.textIndex];
1655        let textConstraint = {
1656            maxWidth: constraint.maxWidth,
1657            maxHeight: Number(constraint.maxHeight) - height
1658        };
1659        let textMeasureResult = textChild.measure(textConstraint);
1660        height += textMeasureResult.height;
1661        sizeResult.height = height;
1662        this.minContentHeight = Math.max(checkBoxMeasureResult.height + TEXT_MIN_HEIGHT, MIN_CONTENT_HEIGHT);
1663        return sizeResult;
1664    }
1665
1666    initialRender() {
1667        this.dialogBuilder.bind(this)();
1668    }
1669
1670    rerender() {
1671        this.updateDirtyElements();
1672    }
1673}
1674
1675export class ConfirmDialog extends ViewPU {
1676    constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) {
1677        super(parent, __localStorage, elmtId, extraInfo);
1678        if (typeof paramsLambda === 'function') {
1679            this.paramsGenerator_ = paramsLambda;
1680        }
1681        this.controller = undefined;
1682        this.title = '';
1683        this.content = '';
1684        this.checkTips = '';
1685        this.__isChecked = new ObservedPropertySimplePU(false, this, 'isChecked');
1686        this.primaryButton = null;
1687        this.secondaryButton = null;
1688        this.__fontColorWithTheme = new ObservedPropertyObjectPU({
1689            'id': -1,
1690            'type': 10001,
1691            params: ['sys.color.font_primary'],
1692            'bundleName': '__harDefaultBundleName__',
1693            'moduleName': '__harDefaultModuleName__'
1694        }, this, 'fontColorWithTheme');
1695        this.theme = new CustomThemeImpl({});
1696        this.themeColorMode = ThemeColorMode.SYSTEM;
1697        this.onCheckedChange = undefined;
1698        this.contentScroller = new Scroller();
1699        this.buttons = undefined;
1700        this.__textAlign = new ObservedPropertySimplePU(TextAlign.Start, this, 'textAlign');
1701        this.marginOffset = 0;
1702        this.__fontSizeScale = new ObservedPropertySimplePU(1, this, 'fontSizeScale');
1703        this.__minContentHeight = new ObservedPropertySimplePU(MIN_CONTENT_HEIGHT, this, 'minContentHeight');
1704        this.textIndex = 0;
1705        this.checkboxIndex = 1;
1706        this.updateTextAlign = (maxWidth) => {
1707            if (this.content) {
1708                this.textAlign = getTextAlign(maxWidth, this.content, `${CONTENT_FONT_SIZE() * this.fontSizeScale}vp`);
1709            }
1710        };
1711        this.setInitiallyProvidedValue(params);
1712        this.finalizeConstruction();
1713    }
1714
1715    setInitiallyProvidedValue(params) {
1716        if (params.controller !== undefined) {
1717            this.controller = params.controller;
1718        }
1719        if (params.title !== undefined) {
1720            this.title = params.title;
1721        }
1722        if (params.content !== undefined) {
1723            this.content = params.content;
1724        }
1725        if (params.checkTips !== undefined) {
1726            this.checkTips = params.checkTips;
1727        }
1728        if (params.isChecked !== undefined) {
1729            this.isChecked = params.isChecked;
1730        }
1731        if (params.primaryButton !== undefined) {
1732            this.primaryButton = params.primaryButton;
1733        }
1734        if (params.secondaryButton !== undefined) {
1735            this.secondaryButton = params.secondaryButton;
1736        }
1737        if (params.fontColorWithTheme !== undefined) {
1738            this.fontColorWithTheme = params.fontColorWithTheme;
1739        }
1740        if (params.theme !== undefined) {
1741            this.theme = params.theme;
1742        }
1743        if (params.themeColorMode !== undefined) {
1744            this.themeColorMode = params.themeColorMode;
1745        }
1746        if (params.onCheckedChange !== undefined) {
1747            this.onCheckedChange = params.onCheckedChange;
1748        }
1749        if (params.contentScroller !== undefined) {
1750            this.contentScroller = params.contentScroller;
1751        }
1752        if (params.buttons !== undefined) {
1753            this.buttons = params.buttons;
1754        }
1755        if (params.textAlign !== undefined) {
1756            this.textAlign = params.textAlign;
1757        }
1758        if (params.marginOffset !== undefined) {
1759            this.marginOffset = params.marginOffset;
1760        }
1761        if (params.fontSizeScale !== undefined) {
1762            this.fontSizeScale = params.fontSizeScale;
1763        }
1764        if (params.minContentHeight !== undefined) {
1765            this.minContentHeight = params.minContentHeight;
1766        }
1767        if (params.textIndex !== undefined) {
1768            this.textIndex = params.textIndex;
1769        }
1770        if (params.checkboxIndex !== undefined) {
1771            this.checkboxIndex = params.checkboxIndex;
1772        }
1773        if (params.updateTextAlign !== undefined) {
1774            this.updateTextAlign = params.updateTextAlign;
1775        }
1776    }
1777
1778    updateStateVars(params) {
1779    }
1780
1781    purgeVariableDependenciesOnElmtId(rmElmtId) {
1782        this.__isChecked.purgeDependencyOnElmtId(rmElmtId);
1783        this.__fontColorWithTheme.purgeDependencyOnElmtId(rmElmtId);
1784        this.__textAlign.purgeDependencyOnElmtId(rmElmtId);
1785        this.__fontSizeScale.purgeDependencyOnElmtId(rmElmtId);
1786        this.__minContentHeight.purgeDependencyOnElmtId(rmElmtId);
1787    }
1788
1789    aboutToBeDeleted() {
1790        this.__isChecked.aboutToBeDeleted();
1791        this.__fontColorWithTheme.aboutToBeDeleted();
1792        this.__textAlign.aboutToBeDeleted();
1793        this.__fontSizeScale.aboutToBeDeleted();
1794        this.__minContentHeight.aboutToBeDeleted();
1795        SubscriberManager.Get().delete(this.id__());
1796        this.aboutToBeDeletedInternal();
1797    }
1798
1799    setController(ctr) {
1800        this.controller = ctr;
1801    }
1802
1803    get isChecked() {
1804        return this.__isChecked.get();
1805    }
1806
1807    set isChecked(newValue) {
1808        this.__isChecked.set(newValue);
1809    }
1810
1811    get fontColorWithTheme() {
1812        return this.__fontColorWithTheme.get();
1813    }
1814
1815    set fontColorWithTheme(newValue) {
1816        this.__fontColorWithTheme.set(newValue);
1817    }
1818
1819    get textAlign() {
1820        return this.__textAlign.get();
1821    }
1822
1823    set textAlign(newValue) {
1824        this.__textAlign.set(newValue);
1825    }
1826
1827    get fontSizeScale() {
1828        return this.__fontSizeScale.get();
1829    }
1830
1831    set fontSizeScale(newValue) {
1832        this.__fontSizeScale.set(newValue);
1833    }
1834
1835    get minContentHeight() {
1836        return this.__minContentHeight.get();
1837    }
1838
1839    set minContentHeight(newValue) {
1840        this.__minContentHeight.set(newValue);
1841    }
1842
1843    textBuilder(parent = null) {
1844        this.observeComponentCreation2((elmtId, isInitialRender) => {
1845            Column.create();
1846        }, Column);
1847        this.observeComponentCreation2((elmtId, isInitialRender) => {
1848            Scroll.create(this.contentScroller);
1849            Scroll.fadingEdge(IS_FADEOUT_ENABLE(), { fadingEdgeLength: LengthMetrics.vp(FADEOUT_GRADIENT_WIDTH) });
1850            Scroll.nestedScroll({
1851                scrollForward: NestedScrollMode.PARALLEL,
1852                scrollBackward: NestedScrollMode.PARALLEL
1853            });
1854            Scroll.margin({ end: LengthMetrics.vp(0 - SCROLL_BAR_OFFSET) });
1855        }, Scroll);
1856        this.observeComponentCreation2((elmtId, isInitialRender) => {
1857            Column.create();
1858            Column.margin({ end: LengthMetrics.vp(SCROLL_BAR_OFFSET) });
1859            Column.width(`calc(100% - ${SCROLL_BAR_OFFSET}vp)`);
1860        }, Column);
1861        this.observeComponentCreation2((elmtId, isInitialRender) => {
1862            Text.create(this.content);
1863            Text.focusable(true);
1864            Text.defaultFocus(!(this.primaryButton?.value || this.secondaryButton?.value));
1865            Text.focusBox({
1866                strokeWidth: LengthMetrics.px(0)
1867            });
1868            Text.fontSize(`${CONTENT_FONT_SIZE()}fp`);
1869            Text.fontWeight(CONTENT_FONT_WEIGHT());
1870            Text.fontColor(ObservedObject.GetRawObject(this.fontColorWithTheme));
1871            Text.textAlign(this.textAlign);
1872            Text.onKeyEvent((event) => {
1873                if (event) {
1874                    resolveKeyEvent(event, this.contentScroller);
1875                }
1876            });
1877            Text.width('100%');
1878        }, Text);
1879        Text.pop();
1880        Column.pop();
1881        Scroll.pop();
1882        Column.pop();
1883    }
1884
1885    checkBoxBuilder(parent = null) {
1886        this.observeComponentCreation2((elmtId, isInitialRender) => {
1887            Row.create();
1888            Row.accessibilityGroup(true);
1889            Row.accessibilityText(getCheckTipsAccessibilityText(this.checkTips, this.isChecked));
1890            Row.accessibilityDescription(this.isChecked ? {
1891                'id': -1,
1892                'type': 10003,
1893                params: ['sys.string.advanced_dialog_accessibility_cancel_checked_desc'],
1894                'bundleName': '__harDefaultBundleName__',
1895                'moduleName': '__harDefaultModuleName__'
1896            } : {
1897                'id': -1,
1898                'type': 10003,
1899                params: ['sys.string.slider_accessibility_unselectedDesc'],
1900                'bundleName': '__harDefaultBundleName__',
1901                'moduleName': '__harDefaultModuleName__'
1902            });
1903            Row.onClick(() => {
1904                this.isChecked = !this.isChecked;
1905                try {
1906                    let eventInfo = ({
1907                        type: 'announceForAccessibility',
1908                        bundleName: getContext()?.abilityInfo?.bundleName,
1909                        triggerAction: 'common',
1910                        textAnnouncedForAccessibility: this.isChecked ?
1911                        getContext().resourceManager.getStringSync(125833934) :
1912                        getContext().resourceManager.getStringSync(125833935)
1913                    });
1914                    accessibility.sendAccessibilityEvent(eventInfo).then(() => {
1915                        console.info(`Accessibility send event`);
1916                    });
1917                } catch (exception) {
1918                    let code = exception.code;
1919                    let message = exception.message;
1920                    hilog.error(0x3900, 'Ace', `Faild to send event, cause, code: ${code}, message: ${message}`);
1921                }
1922            });
1923            Row.width('100%');
1924            Row.padding({ top: TIP_CHECKBOX_TOP_PADDING(), bottom: TIP_CHECKBOX_BOTTOM_PADDING() });
1925        }, Row);
1926        this.observeComponentCreation2((elmtId, isInitialRender) => {
1927            Checkbox.create({ name: '', group: 'checkboxGroup' });
1928            Checkbox.select(this.isChecked);
1929            Checkbox.onChange((checked) => {
1930                this.isChecked = checked;
1931                if (this.onCheckedChange) {
1932                    this.onCheckedChange(this.isChecked);
1933                }
1934            });
1935            Checkbox.hitTestBehavior(HitTestMode.Block);
1936            Checkbox.margin({ start: LengthMetrics.vp(0), end: LengthMetrics.vp(TIP_CHECKBOX_END_MARGIN()) });
1937        }, Checkbox);
1938        Checkbox.pop();
1939        this.observeComponentCreation2((elmtId, isInitialRender) => {
1940            Text.create(this.checkTips);
1941            Text.fontSize(`${SUBTITLE_SIZE()}fp`);
1942            Text.fontWeight(CONTENT_FONT_WEIGHT());
1943            Text.fontColor(ObservedObject.GetRawObject(this.fontColorWithTheme));
1944            Text.maxLines(CONTENT_MAX_LINES);
1945            Text.focusable(false);
1946            Text.layoutWeight(1);
1947            Text.textOverflow({ overflow: TextOverflow.Ellipsis });
1948        }, Text);
1949        Text.pop();
1950        Row.pop();
1951    }
1952
1953    buildContent(parent = null) {
1954        {
1955            this.observeComponentCreation2((elmtId, isInitialRender) => {
1956                if (isInitialRender) {
1957                    let componentCall = new ConfirmDialogContentLayout(this, {
1958                        minContentHeight: this.__minContentHeight, updateTextAlign: this.updateTextAlign,
1959                        dialogBuilder: () => {
1960                            this.observeComponentCreation2((elmtId, isInitialRender) => {
1961                                ForEach.create();
1962                                const forEachItemGenFunction = _item => {
1963                                    const index = _item;
1964                                    this.observeComponentCreation2((elmtId, isInitialRender) => {
1965                                        If.create();
1966                                        if (index === this.textIndex) {
1967                                            this.ifElseBranchUpdateFunction(0, () => {
1968                                                this.observeComponentCreation2((elmtId, isInitialRender) => {
1969                                                    WithTheme.create({
1970                                                        theme: this.theme,
1971                                                        colorMode: this.themeColorMode
1972                                                    });
1973                                                }, WithTheme);
1974                                                this.textBuilder.bind(this)();
1975                                                WithTheme.pop();
1976                                            });
1977                                        } else if (index === this.checkboxIndex) {
1978                                            this.ifElseBranchUpdateFunction(1, () => {
1979                                                this.observeComponentCreation2((elmtId, isInitialRender) => {
1980                                                    WithTheme.create({
1981                                                        theme: this.theme,
1982                                                        colorMode: this.themeColorMode
1983                                                    });
1984                                                }, WithTheme);
1985                                                this.checkBoxBuilder.bind(this)();
1986                                                WithTheme.pop();
1987                                            });
1988                                        } else {
1989                                            this.ifElseBranchUpdateFunction(2, () => {
1990                                            });
1991                                        }
1992                                    }, If);
1993                                    If.pop();
1994                                };
1995                                this.forEachUpdateFunction(elmtId, [this.textIndex, this.checkboxIndex],
1996                                    forEachItemGenFunction);
1997                            }, ForEach);
1998                            ForEach.pop();
1999                        }
2000                    }, undefined, elmtId, () => {
2001                    }, { page: 'library/src/main/ets/components/dialog.ets', line: 826, col: 5 });
2002                    ViewPU.create(componentCall);
2003                    let paramsLambda = () => {
2004                        return {
2005                            minContentHeight: this.minContentHeight,
2006                            updateTextAlign: this.updateTextAlign,
2007                            dialogBuilder: () => {
2008                                this.observeComponentCreation2((elmtId, isInitialRender) => {
2009                                    ForEach.create();
2010                                    const forEachItemGenFunction = _item => {
2011                                        const index = _item;
2012                                        this.observeComponentCreation2((elmtId, isInitialRender) => {
2013                                            If.create();
2014                                            if (index === this.textIndex) {
2015                                                this.ifElseBranchUpdateFunction(0, () => {
2016                                                    this.observeComponentCreation2((elmtId, isInitialRender) => {
2017                                                        WithTheme.create({
2018                                                            theme: this.theme,
2019                                                            colorMode: this.themeColorMode
2020                                                        });
2021                                                    }, WithTheme);
2022                                                    this.textBuilder.bind(this)();
2023                                                    WithTheme.pop();
2024                                                });
2025                                            } else if (index === this.checkboxIndex) {
2026                                                this.ifElseBranchUpdateFunction(1, () => {
2027                                                    this.observeComponentCreation2((elmtId, isInitialRender) => {
2028                                                        WithTheme.create({
2029                                                            theme: this.theme,
2030                                                            colorMode: this.themeColorMode
2031                                                        });
2032                                                    }, WithTheme);
2033                                                    this.checkBoxBuilder.bind(this)();
2034                                                    WithTheme.pop();
2035                                                });
2036                                            } else {
2037                                                this.ifElseBranchUpdateFunction(2, () => {
2038                                                });
2039                                            }
2040                                        }, If);
2041                                        If.pop();
2042                                    };
2043                                    this.forEachUpdateFunction(elmtId, [this.textIndex, this.checkboxIndex],
2044                                        forEachItemGenFunction);
2045                                }, ForEach);
2046                                ForEach.pop();
2047                            }
2048                        };
2049                    };
2050                    componentCall.paramsGenerator_ = paramsLambda;
2051                } else {
2052                    this.updateStateVarsOfChildByElmtId(elmtId, {});
2053                }
2054            }, { name: 'ConfirmDialogContentLayout' });
2055        }
2056    }
2057
2058    initialRender() {
2059        this.observeComponentCreation2((elmtId, isInitialRender) => {
2060            __Common__.create();
2061            __Common__.constraintSize({ maxHeight: '100%' });
2062        }, __Common__);
2063        {
2064            this.observeComponentCreation2((elmtId, isInitialRender) => {
2065                if (isInitialRender) {
2066                    let componentCall = new CustomDialogContentComponent(this, {
2067                        primaryTitle: this.title,
2068                        controller: this.controller,
2069                        contentBuilder: () => {
2070                            this.buildContent();
2071                        },
2072                        minContentHeight: this.__minContentHeight,
2073                        buttons: this.buttons,
2074                        theme: this.theme,
2075                        themeColorMode: this.themeColorMode,
2076                        fontSizeScale: this.__fontSizeScale,
2077                    }, undefined, elmtId, () => {
2078                    }, { page: 'library/src/main/ets/components/dialog.ets', line: 842, col: 5 });
2079                    ViewPU.create(componentCall);
2080                    let paramsLambda = () => {
2081                        return {
2082                            primaryTitle: this.title,
2083                            controller: this.controller,
2084                            contentBuilder: () => {
2085                                this.buildContent();
2086                            },
2087                            minContentHeight: this.minContentHeight,
2088                            buttons: this.buttons,
2089                            theme: this.theme,
2090                            themeColorMode: this.themeColorMode,
2091                            fontSizeScale: this.fontSizeScale
2092                        };
2093                    };
2094                    componentCall.paramsGenerator_ = paramsLambda;
2095                } else {
2096                    this.updateStateVarsOfChildByElmtId(elmtId, {});
2097                }
2098            }, { name: 'CustomDialogContentComponent' });
2099        }
2100        __Common__.pop();
2101    }
2102
2103    aboutToAppear() {
2104        this.fontColorWithTheme = this.theme?.colors?.fontPrimary ?
2105        this.theme.colors.fontPrimary : {
2106                'id': -1,
2107                'type': 10001,
2108                params: ['sys.color.font_primary'],
2109                'bundleName': '__harDefaultBundleName__',
2110                'moduleName': '__harDefaultModuleName__'
2111            };
2112        this.initButtons();
2113        this.initMargin();
2114    }
2115
2116    initMargin() {
2117        this.marginOffset = 0 - SCROLL_END_MARGIN();
2118    }
2119
2120    initButtons() {
2121        if (!this.primaryButton && !this.secondaryButton) {
2122            return;
2123        }
2124        this.buttons = [];
2125        if (this.primaryButton) {
2126            this.buttons.push(this.primaryButton);
2127        }
2128        if (this.secondaryButton) {
2129            this.buttons.push(this.secondaryButton);
2130        }
2131    }
2132
2133    rerender() {
2134        this.updateDirtyElements();
2135    }
2136}
2137
2138export class AlertDialog extends ViewPU {
2139    constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) {
2140        super(parent, __localStorage, elmtId, extraInfo);
2141        if (typeof paramsLambda === 'function') {
2142            this.paramsGenerator_ = paramsLambda;
2143        }
2144        this.controller = undefined;
2145        this.primaryTitle = undefined;
2146        this.secondaryTitle = undefined;
2147        this.content = '';
2148        this.primaryButton = null;
2149        this.secondaryButton = null;
2150        this.buttons = undefined;
2151        this.__textAlign = new ObservedPropertySimplePU(TextAlign.Center, this, 'textAlign');
2152        this.contentScroller = new Scroller();
2153        this.__fontColorWithTheme = new ObservedPropertyObjectPU({
2154            'id': -1,
2155            'type': 10001,
2156            params: ['sys.color.font_primary'],
2157            'bundleName': '__harDefaultBundleName__',
2158            'moduleName': '__harDefaultModuleName__'
2159        }, this, 'fontColorWithTheme');
2160        this.theme = new CustomThemeImpl({});
2161        this.themeColorMode = ThemeColorMode.SYSTEM;
2162        this.__fontSizeScale = new ObservedPropertySimplePU(1, this, 'fontSizeScale');
2163        this.__minContentHeight = new ObservedPropertySimplePU(MIN_CONTENT_HEIGHT, this, 'minContentHeight');
2164        this.setInitiallyProvidedValue(params);
2165        this.finalizeConstruction();
2166    }
2167
2168    setInitiallyProvidedValue(params) {
2169        if (params.controller !== undefined) {
2170            this.controller = params.controller;
2171        }
2172        if (params.primaryTitle !== undefined) {
2173            this.primaryTitle = params.primaryTitle;
2174        }
2175        if (params.secondaryTitle !== undefined) {
2176            this.secondaryTitle = params.secondaryTitle;
2177        }
2178        if (params.content !== undefined) {
2179            this.content = params.content;
2180        }
2181        if (params.primaryButton !== undefined) {
2182            this.primaryButton = params.primaryButton;
2183        }
2184        if (params.secondaryButton !== undefined) {
2185            this.secondaryButton = params.secondaryButton;
2186        }
2187        if (params.buttons !== undefined) {
2188            this.buttons = params.buttons;
2189        }
2190        if (params.textAlign !== undefined) {
2191            this.textAlign = params.textAlign;
2192        }
2193        if (params.contentScroller !== undefined) {
2194            this.contentScroller = params.contentScroller;
2195        }
2196        if (params.fontColorWithTheme !== undefined) {
2197            this.fontColorWithTheme = params.fontColorWithTheme;
2198        }
2199        if (params.theme !== undefined) {
2200            this.theme = params.theme;
2201        }
2202        if (params.themeColorMode !== undefined) {
2203            this.themeColorMode = params.themeColorMode;
2204        }
2205        if (params.fontSizeScale !== undefined) {
2206            this.fontSizeScale = params.fontSizeScale;
2207        }
2208        if (params.minContentHeight !== undefined) {
2209            this.minContentHeight = params.minContentHeight;
2210        }
2211    }
2212
2213    updateStateVars(params) {
2214    }
2215
2216    purgeVariableDependenciesOnElmtId(rmElmtId) {
2217        this.__textAlign.purgeDependencyOnElmtId(rmElmtId);
2218        this.__fontColorWithTheme.purgeDependencyOnElmtId(rmElmtId);
2219        this.__fontSizeScale.purgeDependencyOnElmtId(rmElmtId);
2220        this.__minContentHeight.purgeDependencyOnElmtId(rmElmtId);
2221    }
2222
2223    aboutToBeDeleted() {
2224        this.__textAlign.aboutToBeDeleted();
2225        this.__fontColorWithTheme.aboutToBeDeleted();
2226        this.__fontSizeScale.aboutToBeDeleted();
2227        this.__minContentHeight.aboutToBeDeleted();
2228        SubscriberManager.Get().delete(this.id__());
2229        this.aboutToBeDeletedInternal();
2230    }
2231
2232    setController(ctr) {
2233        this.controller = ctr;
2234    }
2235
2236    get textAlign() {
2237        return this.__textAlign.get();
2238    }
2239
2240    set textAlign(newValue) {
2241        this.__textAlign.set(newValue);
2242    }
2243
2244    get fontColorWithTheme() {
2245        return this.__fontColorWithTheme.get();
2246    }
2247
2248    set fontColorWithTheme(newValue) {
2249        this.__fontColorWithTheme.set(newValue);
2250    }
2251
2252    get fontSizeScale() {
2253        return this.__fontSizeScale.get();
2254    }
2255
2256    set fontSizeScale(newValue) {
2257        this.__fontSizeScale.set(newValue);
2258    }
2259
2260    get minContentHeight() {
2261        return this.__minContentHeight.get();
2262    }
2263
2264    set minContentHeight(newValue) {
2265        this.__minContentHeight.set(newValue);
2266    }
2267
2268    initialRender() {
2269        this.observeComponentCreation2((elmtId, isInitialRender) => {
2270            __Common__.create();
2271            __Common__.constraintSize({ maxHeight: '100%' });
2272        }, __Common__);
2273        {
2274            this.observeComponentCreation2((elmtId, isInitialRender) => {
2275                if (isInitialRender) {
2276                    let componentCall = new CustomDialogContentComponent(this, {
2277                        primaryTitle: this.primaryTitle,
2278                        secondaryTitle: this.secondaryTitle,
2279                        controller: this.controller,
2280                        contentBuilder: () => {
2281                            this.AlertDialogContentBuilder();
2282                        },
2283                        buttons: this.buttons,
2284                        theme: this.theme,
2285                        themeColorMode: this.themeColorMode,
2286                        fontSizeScale: this.__fontSizeScale,
2287                        minContentHeight: this.__minContentHeight,
2288                    }, undefined, elmtId, () => {
2289                    }, { page: 'library/src/main/ets/components/dialog.ets', line: 900, col: 5 });
2290                    ViewPU.create(componentCall);
2291                    let paramsLambda = () => {
2292                        return {
2293                            primaryTitle: this.primaryTitle,
2294                            secondaryTitle: this.secondaryTitle,
2295                            controller: this.controller,
2296                            contentBuilder: () => {
2297                                this.AlertDialogContentBuilder();
2298                            },
2299                            buttons: this.buttons,
2300                            theme: this.theme,
2301                            themeColorMode: this.themeColorMode,
2302                            fontSizeScale: this.fontSizeScale,
2303                            minContentHeight: this.minContentHeight
2304                        };
2305                    };
2306                    componentCall.paramsGenerator_ = paramsLambda;
2307                } else {
2308                    this.updateStateVarsOfChildByElmtId(elmtId, {});
2309                }
2310            }, { name: 'CustomDialogContentComponent' });
2311        }
2312        __Common__.pop();
2313    }
2314
2315    AlertDialogContentBuilder(parent = null) {
2316        this.observeComponentCreation2((elmtId, isInitialRender) => {
2317            Column.create();
2318            Column.margin({ end: LengthMetrics.vp(0 - SCROLL_BAR_OFFSET) });
2319        }, Column);
2320        this.observeComponentCreation2((elmtId, isInitialRender) => {
2321            Scroll.create(this.contentScroller);
2322            Scroll.fadingEdge(IS_FADEOUT_ENABLE(), { fadingEdgeLength: LengthMetrics.vp(FADEOUT_GRADIENT_WIDTH) });
2323            Scroll.nestedScroll({
2324                scrollForward: NestedScrollMode.PARALLEL,
2325                scrollBackward: NestedScrollMode.PARALLEL
2326            });
2327            Scroll.width('100%');
2328        }, Scroll);
2329        this.observeComponentCreation2((elmtId, isInitialRender) => {
2330            Text.create(this.content);
2331            Text.focusable(true);
2332            Text.defaultFocus(!(this.primaryButton || this.secondaryButton));
2333            Text.focusBox({
2334                strokeWidth: LengthMetrics.px(0)
2335            });
2336            Text.fontSize(`${CONTENT_FONT_SIZE()}fp`);
2337            Text.fontWeight(this.getFontWeight());
2338            Text.fontColor(ObservedObject.GetRawObject(this.fontColorWithTheme));
2339            Text.margin({ end: LengthMetrics.vp(SCROLL_BAR_OFFSET) });
2340            Text.width(`calc(100% - ${SCROLL_BAR_OFFSET}vp)`);
2341            Text.textAlign(this.textAlign);
2342            Text.onKeyEvent((event) => {
2343                if (event) {
2344                    resolveKeyEvent(event, this.contentScroller);
2345                }
2346            });
2347        }, Text);
2348        Text.pop();
2349        Scroll.pop();
2350        Column.pop();
2351    }
2352
2353    aboutToAppear() {
2354        this.fontColorWithTheme = this.theme?.colors?.fontPrimary ?
2355        this.theme.colors.fontPrimary : {
2356                'id': -1,
2357                'type': 10001,
2358                params: ['sys.color.font_primary'],
2359                'bundleName': '__harDefaultBundleName__',
2360                'moduleName': '__harDefaultModuleName__'
2361            };
2362        this.initButtons();
2363    }
2364
2365    initButtons() {
2366        if (!this.primaryButton && !this.secondaryButton) {
2367            return;
2368        }
2369        this.buttons = [];
2370        if (this.primaryButton) {
2371            this.buttons.push(this.primaryButton);
2372        }
2373        if (this.secondaryButton) {
2374            this.buttons.push(this.secondaryButton);
2375        }
2376    }
2377
2378    getFontWeight() {
2379        if (this.primaryTitle || this.secondaryTitle) {
2380            return FontWeight.Regular;
2381        }
2382        return CONTENT_FONT_WEIGHT();
2383    }
2384
2385    rerender() {
2386        this.updateDirtyElements();
2387    }
2388}
2389
2390export class CustomContentDialog extends ViewPU {
2391    constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) {
2392        super(parent, __localStorage, elmtId, extraInfo);
2393        if (typeof paramsLambda === 'function') {
2394            this.paramsGenerator_ = paramsLambda;
2395        }
2396        this.controller = undefined;
2397        this.primaryTitle = undefined;
2398        this.secondaryTitle = undefined;
2399        this.contentBuilder = undefined;
2400        this.contentAreaPadding = undefined;
2401        this.localizedContentAreaPadding = undefined;
2402        this.buttons = undefined;
2403        this.theme = new CustomThemeImpl({});
2404        this.themeColorMode = ThemeColorMode.SYSTEM;
2405        this.__fontSizeScale = new ObservedPropertySimplePU(1, this, 'fontSizeScale');
2406        this.__minContentHeight = new ObservedPropertySimplePU(MIN_CONTENT_HEIGHT, this, 'minContentHeight');
2407        this.setInitiallyProvidedValue(params);
2408        this.finalizeConstruction();
2409    }
2410
2411    setInitiallyProvidedValue(params) {
2412        if (params.controller !== undefined) {
2413            this.controller = params.controller;
2414        }
2415        if (params.primaryTitle !== undefined) {
2416            this.primaryTitle = params.primaryTitle;
2417        }
2418        if (params.secondaryTitle !== undefined) {
2419            this.secondaryTitle = params.secondaryTitle;
2420        }
2421        if (params.contentBuilder !== undefined) {
2422            this.contentBuilder = params.contentBuilder;
2423        }
2424        if (params.contentAreaPadding !== undefined) {
2425            this.contentAreaPadding = params.contentAreaPadding;
2426        }
2427        if (params.localizedContentAreaPadding !== undefined) {
2428            this.localizedContentAreaPadding = params.localizedContentAreaPadding;
2429        }
2430        if (params.buttons !== undefined) {
2431            this.buttons = params.buttons;
2432        }
2433        if (params.theme !== undefined) {
2434            this.theme = params.theme;
2435        }
2436        if (params.themeColorMode !== undefined) {
2437            this.themeColorMode = params.themeColorMode;
2438        }
2439        if (params.fontSizeScale !== undefined) {
2440            this.fontSizeScale = params.fontSizeScale;
2441        }
2442        if (params.minContentHeight !== undefined) {
2443            this.minContentHeight = params.minContentHeight;
2444        }
2445    }
2446
2447    updateStateVars(params) {
2448    }
2449
2450    purgeVariableDependenciesOnElmtId(rmElmtId) {
2451        this.__fontSizeScale.purgeDependencyOnElmtId(rmElmtId);
2452        this.__minContentHeight.purgeDependencyOnElmtId(rmElmtId);
2453    }
2454
2455    aboutToBeDeleted() {
2456        this.__fontSizeScale.aboutToBeDeleted();
2457        this.__minContentHeight.aboutToBeDeleted();
2458        SubscriberManager.Get().delete(this.id__());
2459        this.aboutToBeDeletedInternal();
2460    }
2461
2462    setController(ctr) {
2463        this.controller = ctr;
2464    }
2465
2466    get fontSizeScale() {
2467        return this.__fontSizeScale.get();
2468    }
2469
2470    set fontSizeScale(newValue) {
2471        this.__fontSizeScale.set(newValue);
2472    }
2473
2474    get minContentHeight() {
2475        return this.__minContentHeight.get();
2476    }
2477
2478    set minContentHeight(newValue) {
2479        this.__minContentHeight.set(newValue);
2480    }
2481
2482    initialRender() {
2483        this.observeComponentCreation2((elmtId, isInitialRender) => {
2484            __Common__.create();
2485            __Common__.constraintSize({ maxHeight: '100%' });
2486        }, __Common__);
2487        {
2488            this.observeComponentCreation2((elmtId, isInitialRender) => {
2489                if (isInitialRender) {
2490                    let componentCall = new CustomDialogContentComponent(this, {
2491                        controller: this.controller,
2492                        primaryTitle: this.primaryTitle,
2493                        secondaryTitle: this.secondaryTitle,
2494                        contentBuilder: () => {
2495                            this.contentBuilder();
2496                        },
2497                        contentAreaPadding: this.contentAreaPadding,
2498                        localizedContentAreaPadding: this.localizedContentAreaPadding,
2499                        buttons: this.buttons,
2500                        theme: this.theme,
2501                        themeColorMode: this.themeColorMode,
2502                        fontSizeScale: this.__fontSizeScale,
2503                        minContentHeight: this.__minContentHeight,
2504                        customStyle: false
2505                    }, undefined, elmtId, () => {
2506                    }, { page: 'library/src/main/ets/components/dialog.ets', line: 993, col: 5 });
2507                    ViewPU.create(componentCall);
2508                    let paramsLambda = () => {
2509                        return {
2510                            controller: this.controller,
2511                            primaryTitle: this.primaryTitle,
2512                            secondaryTitle: this.secondaryTitle,
2513                            contentBuilder: () => {
2514                                this.contentBuilder();
2515                            },
2516                            contentAreaPadding: this.contentAreaPadding,
2517                            localizedContentAreaPadding: this.localizedContentAreaPadding,
2518                            buttons: this.buttons,
2519                            theme: this.theme,
2520                            themeColorMode: this.themeColorMode,
2521                            fontSizeScale: this.fontSizeScale,
2522                            minContentHeight: this.minContentHeight,
2523                            customStyle: false
2524                        };
2525                    };
2526                    componentCall.paramsGenerator_ = paramsLambda;
2527                } else {
2528                    this.updateStateVarsOfChildByElmtId(elmtId, {});
2529                }
2530            }, { name: 'CustomDialogContentComponent' });
2531        }
2532        __Common__.pop();
2533    }
2534
2535    rerender() {
2536        this.updateDirtyElements();
2537    }
2538}
2539
2540class CustomDialogControllerExtend extends CustomDialogController {
2541    constructor(value) {
2542        super(value);
2543        this.arg_ = value;
2544    }
2545}
2546
2547class CustomDialogLayout extends ViewPU {
2548    constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) {
2549        super(parent, __localStorage, elmtId, extraInfo);
2550        if (typeof paramsLambda === 'function') {
2551            this.paramsGenerator_ = paramsLambda;
2552        }
2553        this.__titleHeight = new SynchedPropertySimpleTwoWayPU(params.titleHeight, this, 'titleHeight');
2554        this.__buttonHeight = new SynchedPropertySimpleTwoWayPU(params.buttonHeight, this, 'buttonHeight');
2555        this.__titleMinHeight = new SynchedPropertyObjectTwoWayPU(params.titleMinHeight, this, 'titleMinHeight');
2556        this.dialogBuilder = this.doNothingBuilder;
2557        this.titleIndex = 0;
2558        this.contentIndex = 1;
2559        this.buttonIndex = 2;
2560        this.setInitiallyProvidedValue(params);
2561        this.finalizeConstruction();
2562    }
2563
2564    setInitiallyProvidedValue(params) {
2565        if (params.dialogBuilder !== undefined) {
2566            this.dialogBuilder = params.dialogBuilder;
2567        }
2568        if (params.titleIndex !== undefined) {
2569            this.titleIndex = params.titleIndex;
2570        }
2571        if (params.contentIndex !== undefined) {
2572            this.contentIndex = params.contentIndex;
2573        }
2574        if (params.buttonIndex !== undefined) {
2575            this.buttonIndex = params.buttonIndex;
2576        }
2577    }
2578
2579    updateStateVars(params) {
2580    }
2581
2582    purgeVariableDependenciesOnElmtId(rmElmtId) {
2583        this.__titleHeight.purgeDependencyOnElmtId(rmElmtId);
2584        this.__buttonHeight.purgeDependencyOnElmtId(rmElmtId);
2585        this.__titleMinHeight.purgeDependencyOnElmtId(rmElmtId);
2586    }
2587
2588    aboutToBeDeleted() {
2589        this.__titleHeight.aboutToBeDeleted();
2590        this.__buttonHeight.aboutToBeDeleted();
2591        this.__titleMinHeight.aboutToBeDeleted();
2592        SubscriberManager.Get().delete(this.id__());
2593        this.aboutToBeDeletedInternal();
2594    }
2595
2596    doNothingBuilder(parent = null) {
2597    }
2598
2599    get titleHeight() {
2600        return this.__titleHeight.get();
2601    }
2602
2603    set titleHeight(newValue) {
2604        this.__titleHeight.set(newValue);
2605    }
2606
2607    get buttonHeight() {
2608        return this.__buttonHeight.get();
2609    }
2610
2611    set buttonHeight(newValue) {
2612        this.__buttonHeight.set(newValue);
2613    }
2614
2615    get titleMinHeight() {
2616        return this.__titleMinHeight.get();
2617    }
2618
2619    set titleMinHeight(newValue) {
2620        this.__titleMinHeight.set(newValue);
2621    }
2622
2623    onPlaceChildren(selfLayoutInfo, children, constraint) {
2624        let currentX = 0;
2625        let currentY = 0;
2626        for (let index = 0; index < children.length; index++) {
2627            let child = children[index];
2628            child.layout({ x: currentX, y: currentY });
2629            currentY += child.measureResult.height;
2630        }
2631    }
2632
2633    onMeasureSize(selfLayoutInfo, children, constraint) {
2634        let sizeResult = { width: Number(constraint.maxWidth), height: 0 };
2635        let childrenSize = 3;
2636        if (children.length < childrenSize) {
2637            return sizeResult;
2638        }
2639        let height = 0;
2640        let titleChild = children[this.titleIndex];
2641        let titleConstraint = {
2642            maxWidth: constraint.maxWidth,
2643            minHeight: this.titleMinHeight,
2644            maxHeight: constraint.maxHeight
2645        };
2646        let titleMeasureResult = titleChild.measure(titleConstraint);
2647        this.titleHeight = titleMeasureResult.height;
2648        height += this.titleHeight;
2649        let buttonChild = children[this.buttonIndex];
2650        let buttonMeasureResult = buttonChild.measure(constraint);
2651        this.buttonHeight = buttonMeasureResult.height;
2652        height += this.buttonHeight;
2653        let contentChild = children[this.contentIndex];
2654        let contentConstraint = {
2655            maxWidth: constraint.maxWidth,
2656            maxHeight: Number(constraint.maxHeight) - height
2657        };
2658        let contentMeasureResult = contentChild.measure(contentConstraint);
2659        height += contentMeasureResult.height;
2660        sizeResult.height = height;
2661        return sizeResult;
2662    }
2663
2664    initialRender() {
2665        this.dialogBuilder.bind(this)();
2666    }
2667
2668    rerender() {
2669        this.updateDirtyElements();
2670    }
2671}
2672
2673class CustomDialogContentComponent extends ViewPU {
2674    constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) {
2675        super(parent, __localStorage, elmtId, extraInfo);
2676        if (typeof paramsLambda === 'function') {
2677            this.paramsGenerator_ = paramsLambda;
2678        }
2679        this.controller = undefined;
2680        this.primaryTitle = undefined;
2681        this.secondaryTitle = undefined;
2682        this.localizedContentAreaPadding = undefined;
2683        this.contentBuilder = this.defaultContentBuilder;
2684        this.buttons = undefined;
2685        this.contentAreaPadding = undefined;
2686        this.keyIndex = 0;
2687        this.theme = new CustomThemeImpl({});
2688        this.themeColorMode = ThemeColorMode.SYSTEM;
2689        this.__minContentHeight = new SynchedPropertySimpleTwoWayPU(params.minContentHeight, this, 'minContentHeight');
2690        this.__titleHeight = new ObservedPropertySimplePU(0, this, 'titleHeight');
2691        this.__buttonHeight = new ObservedPropertySimplePU(0, this, 'buttonHeight');
2692        this.__contentMaxHeight = new ObservedPropertyObjectPU('100%', this, 'contentMaxHeight');
2693        this.__fontSizeScale = new SynchedPropertySimpleTwoWayPU(params.fontSizeScale, this, 'fontSizeScale');
2694        this.__customStyle = new ObservedPropertySimplePU(undefined, this, 'customStyle');
2695        this.__buttonMaxFontSize = new ObservedPropertyObjectPU(`${BODY_L}fp`, this, 'buttonMaxFontSize');
2696        this.__buttonMinFontSize = new ObservedPropertyObjectPU(9, this, 'buttonMinFontSize');
2697        this.__primaryTitleFontSize = new ObservedPropertyObjectPU(`${TITLE_S}fp`, this, 'primaryTitleFontSize');
2698        this.__secondaryTitleFontSize = new ObservedPropertyObjectPU(`${SUBTITLE_SIZE()}fp`, this, 'secondaryTitleFontSize');
2699        this.__primaryTitleFontColorWithTheme = new ObservedPropertyObjectPU({
2700            'id': -1,
2701            'type': 10001,
2702            params: ['sys.color.font_primary'],
2703            'bundleName': '__harDefaultBundleName__',
2704            'moduleName': '__harDefaultModuleName__'
2705        }, this, 'primaryTitleFontColorWithTheme');
2706        this.__secondaryTitleFontColorWithTheme = new ObservedPropertyObjectPU({
2707            'id': -1,
2708            'type': 10001,
2709            params: ['sys.color.font_secondary'],
2710            'bundleName': '__harDefaultBundleName__',
2711            'moduleName': '__harDefaultModuleName__'
2712        }, this, 'secondaryTitleFontColorWithTheme');
2713        this.__titleTextAlign = new ObservedPropertySimplePU(TextAlign.Center, this, 'titleTextAlign');
2714        this.__isButtonVertical = new ObservedPropertySimplePU(false, this, 'isButtonVertical');
2715        this.__titleMinHeight = new ObservedPropertyObjectPU(0, this, 'titleMinHeight');
2716        this.isFollowingSystemFontScale = false;
2717        this.appMaxFontScale = 3.2;
2718        this.titleIndex = 0;
2719        this.contentIndex = 1;
2720        this.buttonIndex = 2;
2721        this.isHasDefaultFocus = false;
2722        this.isAllFocusFalse = false;
2723        this.scroller = new Scroller();
2724        this.setInitiallyProvidedValue(params);
2725        this.finalizeConstruction();
2726    }
2727
2728    setInitiallyProvidedValue(params) {
2729        if (params.controller !== undefined) {
2730            this.controller = params.controller;
2731        }
2732        if (params.primaryTitle !== undefined) {
2733            this.primaryTitle = params.primaryTitle;
2734        }
2735        if (params.secondaryTitle !== undefined) {
2736            this.secondaryTitle = params.secondaryTitle;
2737        }
2738        if (params.localizedContentAreaPadding !== undefined) {
2739            this.localizedContentAreaPadding = params.localizedContentAreaPadding;
2740        }
2741        if (params.contentBuilder !== undefined) {
2742            this.contentBuilder = params.contentBuilder;
2743        }
2744        if (params.buttons !== undefined) {
2745            this.buttons = params.buttons;
2746        }
2747        if (params.contentAreaPadding !== undefined) {
2748            this.contentAreaPadding = params.contentAreaPadding;
2749        }
2750        if (params.keyIndex !== undefined) {
2751            this.keyIndex = params.keyIndex;
2752        }
2753        if (params.theme !== undefined) {
2754            this.theme = params.theme;
2755        }
2756        if (params.themeColorMode !== undefined) {
2757            this.themeColorMode = params.themeColorMode;
2758        }
2759        if (params.titleHeight !== undefined) {
2760            this.titleHeight = params.titleHeight;
2761        }
2762        if (params.buttonHeight !== undefined) {
2763            this.buttonHeight = params.buttonHeight;
2764        }
2765        if (params.contentMaxHeight !== undefined) {
2766            this.contentMaxHeight = params.contentMaxHeight;
2767        }
2768        if (params.customStyle !== undefined) {
2769            this.customStyle = params.customStyle;
2770        }
2771        if (params.buttonMaxFontSize !== undefined) {
2772            this.buttonMaxFontSize = params.buttonMaxFontSize;
2773        }
2774        if (params.buttonMinFontSize !== undefined) {
2775            this.buttonMinFontSize = params.buttonMinFontSize;
2776        }
2777        if (params.primaryTitleFontSize !== undefined) {
2778            this.primaryTitleFontSize = params.primaryTitleFontSize;
2779        }
2780        if (params.secondaryTitleFontSize !== undefined) {
2781            this.secondaryTitleFontSize = params.secondaryTitleFontSize;
2782        }
2783        if (params.primaryTitleFontColorWithTheme !== undefined) {
2784            this.primaryTitleFontColorWithTheme = params.primaryTitleFontColorWithTheme;
2785        }
2786        if (params.secondaryTitleFontColorWithTheme !== undefined) {
2787            this.secondaryTitleFontColorWithTheme = params.secondaryTitleFontColorWithTheme;
2788        }
2789        if (params.titleTextAlign !== undefined) {
2790            this.titleTextAlign = params.titleTextAlign;
2791        }
2792        if (params.isButtonVertical !== undefined) {
2793            this.isButtonVertical = params.isButtonVertical;
2794        }
2795        if (params.titleMinHeight !== undefined) {
2796            this.titleMinHeight = params.titleMinHeight;
2797        }
2798        if (params.isFollowingSystemFontScale !== undefined) {
2799            this.isFollowingSystemFontScale = params.isFollowingSystemFontScale;
2800        }
2801        if (params.appMaxFontScale !== undefined) {
2802            this.appMaxFontScale = params.appMaxFontScale;
2803        }
2804        if (params.titleIndex !== undefined) {
2805            this.titleIndex = params.titleIndex;
2806        }
2807        if (params.contentIndex !== undefined) {
2808            this.contentIndex = params.contentIndex;
2809        }
2810        if (params.buttonIndex !== undefined) {
2811            this.buttonIndex = params.buttonIndex;
2812        }
2813        if (params.isHasDefaultFocus !== undefined) {
2814            this.isHasDefaultFocus = params.isHasDefaultFocus;
2815        }
2816        if (params.isAllFocusFalse !== undefined) {
2817            this.isAllFocusFalse = params.isAllFocusFalse;
2818        }
2819        if (params.scroller !== undefined) {
2820            this.scroller = params.scroller;
2821        }
2822    }
2823
2824    updateStateVars(params) {
2825    }
2826
2827    purgeVariableDependenciesOnElmtId(rmElmtId) {
2828        this.__minContentHeight.purgeDependencyOnElmtId(rmElmtId);
2829        this.__titleHeight.purgeDependencyOnElmtId(rmElmtId);
2830        this.__buttonHeight.purgeDependencyOnElmtId(rmElmtId);
2831        this.__contentMaxHeight.purgeDependencyOnElmtId(rmElmtId);
2832        this.__fontSizeScale.purgeDependencyOnElmtId(rmElmtId);
2833        this.__customStyle.purgeDependencyOnElmtId(rmElmtId);
2834        this.__buttonMaxFontSize.purgeDependencyOnElmtId(rmElmtId);
2835        this.__buttonMinFontSize.purgeDependencyOnElmtId(rmElmtId);
2836        this.__primaryTitleFontSize.purgeDependencyOnElmtId(rmElmtId);
2837        this.__secondaryTitleFontSize.purgeDependencyOnElmtId(rmElmtId);
2838        this.__primaryTitleFontColorWithTheme.purgeDependencyOnElmtId(rmElmtId);
2839        this.__secondaryTitleFontColorWithTheme.purgeDependencyOnElmtId(rmElmtId);
2840        this.__titleTextAlign.purgeDependencyOnElmtId(rmElmtId);
2841        this.__isButtonVertical.purgeDependencyOnElmtId(rmElmtId);
2842        this.__titleMinHeight.purgeDependencyOnElmtId(rmElmtId);
2843    }
2844
2845    aboutToBeDeleted() {
2846        this.__minContentHeight.aboutToBeDeleted();
2847        this.__titleHeight.aboutToBeDeleted();
2848        this.__buttonHeight.aboutToBeDeleted();
2849        this.__contentMaxHeight.aboutToBeDeleted();
2850        this.__fontSizeScale.aboutToBeDeleted();
2851        this.__customStyle.aboutToBeDeleted();
2852        this.__buttonMaxFontSize.aboutToBeDeleted();
2853        this.__buttonMinFontSize.aboutToBeDeleted();
2854        this.__primaryTitleFontSize.aboutToBeDeleted();
2855        this.__secondaryTitleFontSize.aboutToBeDeleted();
2856        this.__primaryTitleFontColorWithTheme.aboutToBeDeleted();
2857        this.__secondaryTitleFontColorWithTheme.aboutToBeDeleted();
2858        this.__titleTextAlign.aboutToBeDeleted();
2859        this.__isButtonVertical.aboutToBeDeleted();
2860        this.__titleMinHeight.aboutToBeDeleted();
2861        SubscriberManager.Get().delete(this.id__());
2862        this.aboutToBeDeletedInternal();
2863    }
2864
2865    get minContentHeight() {
2866        return this.__minContentHeight.get();
2867    }
2868
2869    set minContentHeight(newValue) {
2870        this.__minContentHeight.set(newValue);
2871    }
2872
2873    defaultContentBuilder(parent = null) {
2874    }
2875
2876    get titleHeight() {
2877        return this.__titleHeight.get();
2878    }
2879
2880    set titleHeight(newValue) {
2881        this.__titleHeight.set(newValue);
2882    }
2883
2884    get buttonHeight() {
2885        return this.__buttonHeight.get();
2886    }
2887
2888    set buttonHeight(newValue) {
2889        this.__buttonHeight.set(newValue);
2890    }
2891
2892    get contentMaxHeight() {
2893        return this.__contentMaxHeight.get();
2894    }
2895
2896    set contentMaxHeight(newValue) {
2897        this.__contentMaxHeight.set(newValue);
2898    }
2899
2900    get fontSizeScale() {
2901        return this.__fontSizeScale.get();
2902    }
2903
2904    set fontSizeScale(newValue) {
2905        this.__fontSizeScale.set(newValue);
2906    }
2907
2908    get customStyle() {
2909        return this.__customStyle.get();
2910    }
2911
2912    set customStyle(newValue) {
2913        this.__customStyle.set(newValue);
2914    }
2915
2916    get buttonMaxFontSize() {
2917        return this.__buttonMaxFontSize.get();
2918    }
2919
2920    set buttonMaxFontSize(newValue) {
2921        this.__buttonMaxFontSize.set(newValue);
2922    }
2923
2924    get buttonMinFontSize() {
2925        return this.__buttonMinFontSize.get();
2926    }
2927
2928    set buttonMinFontSize(newValue) {
2929        this.__buttonMinFontSize.set(newValue);
2930    }
2931
2932    get primaryTitleFontSize() {
2933        return this.__primaryTitleFontSize.get();
2934    }
2935
2936    set primaryTitleFontSize(newValue) {
2937        this.__primaryTitleFontSize.set(newValue);
2938    }
2939
2940    get secondaryTitleFontSize() {
2941        return this.__secondaryTitleFontSize.get();
2942    }
2943
2944    set secondaryTitleFontSize(newValue) {
2945        this.__secondaryTitleFontSize.set(newValue);
2946    }
2947
2948    get primaryTitleFontColorWithTheme() {
2949        return this.__primaryTitleFontColorWithTheme.get();
2950    }
2951
2952    set primaryTitleFontColorWithTheme(newValue) {
2953        this.__primaryTitleFontColorWithTheme.set(newValue);
2954    }
2955
2956    get secondaryTitleFontColorWithTheme() {
2957        return this.__secondaryTitleFontColorWithTheme.get();
2958    }
2959
2960    set secondaryTitleFontColorWithTheme(newValue) {
2961        this.__secondaryTitleFontColorWithTheme.set(newValue);
2962    }
2963
2964    get titleTextAlign() {
2965        return this.__titleTextAlign.get();
2966    }
2967
2968    set titleTextAlign(newValue) {
2969        this.__titleTextAlign.set(newValue);
2970    }
2971
2972    get isButtonVertical() {
2973        return this.__isButtonVertical.get();
2974    }
2975
2976    set isButtonVertical(newValue) {
2977        this.__isButtonVertical.set(newValue);
2978    }
2979
2980    get titleMinHeight() {
2981        return this.__titleMinHeight.get();
2982    }
2983
2984    set titleMinHeight(newValue) {
2985        this.__titleMinHeight.set(newValue);
2986    }
2987
2988    initialRender() {
2989        this.observeComponentCreation2((elmtId, isInitialRender) => {
2990            WithTheme.create({ theme: this.theme, colorMode: this.themeColorMode });
2991        }, WithTheme);
2992        this.observeComponentCreation2((elmtId, isInitialRender) => {
2993            RelativeContainer.create();
2994            RelativeContainer.height('auto');
2995        } , RelativeContainer);
2996        this.observeComponentCreation2((elmtId, isInitialRender) => {
2997            Scroll.create(this.scroller);
2998            Scroll.edgeEffect(EdgeEffect.None, { alwaysEnabled: false });
2999            Scroll.backgroundColor(this.themeColorMode === ThemeColorMode.SYSTEM || undefined ?
3000            Color.Transparent : {
3001                    'id': -1,
3002                    'type': 10001,
3003                    params: ['sys.color.comp_background_primary'],
3004                    'bundleName': '__harDefaultBundleName__',
3005                    'moduleName': '__harDefaultModuleName__'
3006                });
3007            Scroll.scrollBar(BarState.Off);
3008            Scroll.id('CustomDialogContentComponent');
3009        }, Scroll);
3010        this.observeComponentCreation2((elmtId, isInitialRender) => {
3011            Column.create();
3012            Column.constraintSize({ maxHeight: this.contentMaxHeight });
3013            Column.backgroundBlurStyle(this.customStyle ?
3014            BlurStyle.Thick : BlurStyle.NONE, undefined, { disableSystemAdaptation: true });
3015            Column.borderRadius(this.customStyle ? {
3016                'id': -1,
3017                'type': 10002,
3018                params: ['sys.float.ohos_id_corner_radius_dialog'],
3019                'bundleName': '__harDefaultBundleName__',
3020                'moduleName': '__harDefaultModuleName__'
3021            } : 0);
3022            Column.margin(this.customStyle ? {
3023                start: LengthMetrics.resource({
3024                    'id': -1,
3025                    'type': 10002,
3026                    params: ['sys.float.ohos_id_dialog_margin_start'],
3027                    'bundleName': '__harDefaultBundleName__',
3028                    'moduleName': '__harDefaultModuleName__'
3029                }),
3030                end: LengthMetrics.resource({
3031                    'id': -1,
3032                    'type': 10002,
3033                    params: ['sys.float.ohos_id_dialog_margin_end'],
3034                    'bundleName': '__harDefaultBundleName__',
3035                    'moduleName': '__harDefaultModuleName__'
3036                }),
3037                bottom: LengthMetrics.resource({
3038                    'id': -1,
3039                    'type': 10002,
3040                    params: ['sys.float.ohos_id_dialog_margin_bottom'],
3041                    'bundleName': '__harDefaultBundleName__',
3042                    'moduleName': '__harDefaultModuleName__'
3043                }),
3044            } : { left: 0, right: 0, bottom: 0 });
3045            Column.backgroundColor(this.customStyle ? {
3046                'id': -1,
3047                'type': 10001,
3048                params: ['sys.color.ohos_id_color_dialog_bg'],
3049                'bundleName': '__harDefaultBundleName__',
3050                'moduleName': '__harDefaultModuleName__'
3051            } : Color.Transparent);
3052        }, Column);
3053        {
3054            this.observeComponentCreation2((elmtId, isInitialRender) => {
3055                if (isInitialRender) {
3056                    let componentCall = new CustomDialogLayout(this, {
3057                        buttonHeight: this.__buttonHeight,
3058                        titleHeight: this.__titleHeight,
3059                        titleMinHeight: this.__titleMinHeight,
3060                        dialogBuilder: () => {
3061                            this.observeComponentCreation2((elmtId, isInitialRender) => {
3062                                ForEach.create();
3063                                const forEachItemGenFunction = _item => {
3064                                    const index = _item;
3065                                    this.observeComponentCreation2((elmtId, isInitialRender) => {
3066                                        If.create();
3067                                        if (index === this.titleIndex) {
3068                                            this.ifElseBranchUpdateFunction(0, () => {
3069                                                this.observeComponentCreation2((elmtId, isInitialRender) => {
3070                                                    WithTheme.create({
3071                                                        theme: this.theme,
3072                                                        colorMode: this.themeColorMode
3073                                                    });
3074                                                }, WithTheme);
3075                                                this.titleBuilder.bind(this)();
3076                                                WithTheme.pop();
3077                                            });
3078                                        } else if (index === this.contentIndex) {
3079                                            this.ifElseBranchUpdateFunction(1, () => {
3080                                                this.observeComponentCreation2((elmtId, isInitialRender) => {
3081                                                    Column.create();
3082                                                    Column.padding(this.getContentPadding());
3083                                                }, Column);
3084                                                this.observeComponentCreation2((elmtId, isInitialRender) => {
3085                                                    WithTheme.create({
3086                                                        theme: this.theme,
3087                                                        colorMode: this.themeColorMode
3088                                                    });
3089                                                }, WithTheme);
3090                                                this.contentBuilder.bind(this)();
3091                                                WithTheme.pop();
3092                                                Column.pop();
3093                                            });
3094                                        } else {
3095                                            this.ifElseBranchUpdateFunction(2, () => {
3096                                                this.buildButton.bind(this)();
3097                                            });
3098                                        }
3099                                    }, If);
3100                                    If.pop();
3101                                };
3102                                this.forEachUpdateFunction(elmtId,
3103                                    [this.titleIndex, this.contentIndex, this.buttonIndex], forEachItemGenFunction);
3104                            }, ForEach);
3105                            ForEach.pop();
3106                        }
3107                    }, undefined, elmtId, () => {
3108                    }, { page: 'library/src/main/ets/components/dialog.ets', line: 1133, col: 11 });
3109                    ViewPU.create(componentCall);
3110                    let paramsLambda = () => {
3111                        return {
3112                            buttonHeight: this.buttonHeight,
3113                            titleHeight: this.titleHeight,
3114                            titleMinHeight: this.titleMinHeight,
3115                            dialogBuilder: () => {
3116                                this.observeComponentCreation2((elmtId, isInitialRender) => {
3117                                    ForEach.create();
3118                                    const forEachItemGenFunction = _item => {
3119                                        const index = _item;
3120                                        this.observeComponentCreation2((elmtId, isInitialRender) => {
3121                                            If.create();
3122                                            if (index === this.titleIndex) {
3123                                                this.ifElseBranchUpdateFunction(0, () => {
3124                                                    this.observeComponentCreation2((elmtId, isInitialRender) => {
3125                                                        WithTheme.create({
3126                                                            theme: this.theme,
3127                                                            colorMode: this.themeColorMode
3128                                                        });
3129                                                    }, WithTheme);
3130                                                    this.titleBuilder.bind(this)();
3131                                                    WithTheme.pop();
3132                                                });
3133                                            } else if (index === this.contentIndex) {
3134                                                this.ifElseBranchUpdateFunction(1, () => {
3135                                                    this.observeComponentCreation2((elmtId, isInitialRender) => {
3136                                                        Column.create();
3137                                                        Column.padding(this.getContentPadding());
3138                                                    }, Column);
3139                                                    this.observeComponentCreation2((elmtId, isInitialRender) => {
3140                                                        WithTheme.create({
3141                                                            theme: this.theme,
3142                                                            colorMode: this.themeColorMode
3143                                                        });
3144                                                    }, WithTheme);
3145                                                    this.contentBuilder.bind(this)();
3146                                                    WithTheme.pop();
3147                                                    Column.pop();
3148                                                });
3149                                            } else {
3150                                                this.ifElseBranchUpdateFunction(2, () => {
3151                                                    this.buildButton.bind(this)();
3152                                                });
3153                                            }
3154                                        }, If);
3155                                        If.pop();
3156                                    };
3157                                    this.forEachUpdateFunction(elmtId,
3158                                        [this.titleIndex, this.contentIndex, this.buttonIndex], forEachItemGenFunction);
3159                                }, ForEach);
3160                                ForEach.pop();
3161                            }
3162                        };
3163                    };
3164                    componentCall.paramsGenerator_ = paramsLambda;
3165                } else {
3166                    this.updateStateVarsOfChildByElmtId(elmtId, {});
3167                }
3168            }, { name: 'CustomDialogLayout' });
3169        }
3170        Column.pop();
3171        Scroll.pop();
3172        this.observeComponentCreation2((elmtId, isInitialRender) => {
3173            ScrollBar.create({ scroller: this.scroller });
3174            ScrollBar.alignRules({
3175                top: { anchor: 'CustomDialogContentComponent', align: VerticalAlign.Top },
3176                bottom: { anchor: 'CustomDialogContentComponent', align: VerticalAlign.Bottom },
3177                end: { anchor: 'CustomDialogContentComponent', align: HorizontalAlign.End }
3178            });
3179            ScrollBar.margin({
3180                top: {
3181                'id': -1,
3182                'type': 10002,
3183                params: ['sys.float.alert_container_shape'],
3184                'bundleName': '__harDefaultBundleName__',
3185                'moduleName': '__harDefaultModuleName__'
3186                },
3187                bottom: {
3188                    'id': -1,
3189                    'type': 10002,
3190                    params: ['sys.float.alert_container_shape'],
3191                    'bundleName': '__harDefaultBundleName__',
3192                    'moduleName': '__harDefaultModuleName__'
3193                }
3194            });
3195            ScrollBar.enableNestedScroll(true);
3196            ScrollBar.hitTestBehavior(HitTestMode.Transparent);
3197            ScrollBar.onGestureRecognizerJudgeBegin((event, current, others) => {
3198                if (current) {
3199                    if (current.getType() == GestureControl.GestureType.LONG_PRESS_GESTURE) {
3200                        return GestureJudgeResult.REJECT;
3201                    }
3202                }
3203                return GestureJudgeResult.CONTINUE;
3204            });
3205        }, ScrollBar);
3206        ScrollBar.pop();
3207        RelativeContainer.pop();
3208        WithTheme.pop();
3209    }
3210
3211    onMeasureSize(selfLayoutInfo, children, constraint) {
3212        let sizeResult = { width: selfLayoutInfo.width, height: selfLayoutInfo.height };
3213        let maxWidth = Number(constraint.maxWidth);
3214        let maxHeight = Number(constraint.maxHeight);
3215        this.fontSizeScale = this.updateFontScale();
3216        this.updateFontSize();
3217        this.isButtonVertical = this.isVerticalAlignButton(maxWidth - BUTTON_HORIZONTAL_MARGIN() * 2);
3218        this.titleMinHeight = this.getTitleAreaMinHeight();
3219        let height = 0;
3220        children.forEach((child) => {
3221            this.contentMaxHeight = '100%';
3222            let measureResult = child.measure(constraint);
3223            if (maxHeight - this.buttonHeight - this.titleHeight < this.minContentHeight) {
3224                this.contentMaxHeight = MAX_CONTENT_HEIGHT;
3225                measureResult = child.measure(constraint);
3226            }
3227            height += measureResult.height;
3228        });
3229        sizeResult.height = height;
3230        sizeResult.width = maxWidth;
3231        return sizeResult;
3232    }
3233
3234    aboutToAppear() {
3235        try {
3236            let uiContext = this.getUIContext();
3237            this.isFollowingSystemFontScale = uiContext?.isFollowingSystemFontScale();
3238            this.appMaxFontScale = uiContext?.getMaxFontScale();
3239        } catch (err) {
3240            let code = err?.code;
3241            let message = err?.message;
3242            hilog.error(0x3900, 'Ace', `Faild to dialog getUIContext, code: ${code}, message: ${message}`);
3243        }
3244        this.fontSizeScale = this.updateFontScale();
3245        if (this.controller && this.customStyle === undefined) {
3246            let customController = this.controller;
3247            if (customController.arg_ && customController.arg_.customStyle &&
3248                customController.arg_.customStyle === true) {
3249                this.customStyle = true;
3250            }
3251        }
3252        if (this.customStyle === undefined) {
3253            this.customStyle = false;
3254        }
3255        this.primaryTitleFontColorWithTheme = this.theme?.colors?.fontPrimary ?
3256        this.theme.colors.fontPrimary : {
3257                'id': -1,
3258                'type': 10001,
3259                params: ['sys.color.font_primary'],
3260                'bundleName': '__harDefaultBundleName__',
3261                'moduleName': '__harDefaultModuleName__'
3262            };
3263        this.secondaryTitleFontColorWithTheme = this.theme?.colors?.fontSecondary ?
3264        this.theme.colors.fontSecondary : {
3265                'id': -1,
3266                'type': 10001,
3267                params: ['sys.color.font_secondary'],
3268                'bundleName': '__harDefaultBundleName__',
3269                'moduleName': '__harDefaultModuleName__'
3270            };
3271        this.initTitleTextAlign();
3272        this.setDefaultFocusState(this.buttons);
3273    }
3274
3275    updateFontSize() {
3276        if (this.fontSizeScale > MAX_FONT_SCALE) {
3277            this.buttonMaxFontSize = BUTTON_MAX_FONT_SIZE() * MAX_FONT_SCALE + 'vp';
3278            this.buttonMinFontSize = BUTTON_MIN_FONT_SIZE() * MAX_FONT_SCALE + 'vp';
3279        } else {
3280            this.buttonMaxFontSize = BUTTON_MAX_FONT_SIZE() + 'fp';
3281            this.buttonMinFontSize = BUTTON_MIN_FONT_SIZE() + 'fp';
3282        }
3283    }
3284
3285    updateFontScale() {
3286        try {
3287            let uiContext = this.getUIContext();
3288            let systemFontScale = uiContext.getHostContext()?.config?.fontSizeScale ?? 1;
3289            if (!this.isFollowingSystemFontScale) {
3290                return 1;
3291            }
3292            return Math.min(systemFontScale, this.appMaxFontScale);
3293        } catch (exception) {
3294            let code = exception.code;
3295            let message = exception.message;
3296            hilog.error(0x3900, 'Ace', `Faild to init fontsizescale info,cause, code: ${code}, message: ${message}`);
3297            return 1;
3298        }
3299    }
3300
3301    /**
3302     * get dialog content padding
3303     *
3304     * @returns content padding
3305     */
3306    getContentPadding() {
3307        if (this.localizedContentAreaPadding) {
3308            return this.localizedContentAreaPadding;
3309        }
3310        if (this.contentAreaPadding) {
3311            return this.contentAreaPadding;
3312        }
3313        if ((this.primaryTitle || this.secondaryTitle) && this.buttons && this.buttons.length > 0) {
3314            return {
3315                top: 0,
3316                right: {
3317                    'id': -1,
3318                    'type': 10002,
3319                    params: ['sys.float.alert_content_default_padding'],
3320                    'bundleName': '__harDefaultBundleName__',
3321                    'moduleName': '__harDefaultModuleName__'
3322                },
3323                bottom: 0,
3324                left: {
3325                    'id': -1,
3326                    'type': 10002,
3327                    params: ['sys.float.alert_content_default_padding'],
3328                    'bundleName': '__harDefaultBundleName__',
3329                    'moduleName': '__harDefaultModuleName__'
3330                },
3331            };
3332        } else if (this.primaryTitle || this.secondaryTitle) {
3333            return {
3334                top: 0,
3335                right: {
3336                    'id': -1,
3337                    'type': 10002,
3338                    params: ['sys.float.alert_content_default_padding'],
3339                    'bundleName': '__harDefaultBundleName__',
3340                    'moduleName': '__harDefaultModuleName__'
3341                },
3342                bottom: {
3343                    'id': -1,
3344                    'type': 10002,
3345                    params: ['sys.float.alert_content_default_padding'],
3346                    'bundleName': '__harDefaultBundleName__',
3347                    'moduleName': '__harDefaultModuleName__'
3348                },
3349                left: {
3350                    'id': -1,
3351                    'type': 10002,
3352                    params: ['sys.float.alert_content_default_padding'],
3353                    'bundleName': '__harDefaultBundleName__',
3354                    'moduleName': '__harDefaultModuleName__'
3355                },
3356            };
3357        } else if (this.buttons && this.buttons.length > 0) {
3358            return {
3359                top: {
3360                    'id': -1,
3361                    'type': 10002,
3362                    params: ['sys.float.alert_content_default_padding'],
3363                    'bundleName': '__harDefaultBundleName__',
3364                    'moduleName': '__harDefaultModuleName__'
3365                },
3366                right: {
3367                    'id': -1,
3368                    'type': 10002,
3369                    params: ['sys.float.alert_content_default_padding'],
3370                    'bundleName': '__harDefaultBundleName__',
3371                    'moduleName': '__harDefaultModuleName__'
3372                },
3373                bottom: 0,
3374                left: {
3375                    'id': -1,
3376                    'type': 10002,
3377                    params: ['sys.float.alert_content_default_padding'],
3378                    'bundleName': '__harDefaultBundleName__',
3379                    'moduleName': '__harDefaultModuleName__'
3380                },
3381            };
3382        } else {
3383            return {
3384                top: {
3385                    'id': -1,
3386                    'type': 10002,
3387                    params: ['sys.float.alert_content_default_padding'],
3388                    'bundleName': '__harDefaultBundleName__',
3389                    'moduleName': '__harDefaultModuleName__'
3390                },
3391                right: {
3392                    'id': -1,
3393                    'type': 10002,
3394                    params: ['sys.float.alert_content_default_padding'],
3395                    'bundleName': '__harDefaultBundleName__',
3396                    'moduleName': '__harDefaultModuleName__'
3397                },
3398                bottom: {
3399                    'id': -1,
3400                    'type': 10002,
3401                    params: ['sys.float.alert_content_default_padding'],
3402                    'bundleName': '__harDefaultBundleName__',
3403                    'moduleName': '__harDefaultModuleName__'
3404                },
3405                left: {
3406                    'id': -1,
3407                    'type': 10002,
3408                    params: ['sys.float.alert_content_default_padding'],
3409                    'bundleName': '__harDefaultBundleName__',
3410                    'moduleName': '__harDefaultModuleName__'
3411                },
3412            };
3413        }
3414    }
3415
3416    titleBuilder(parent = null) {
3417        this.observeComponentCreation2((elmtId, isInitialRender) => {
3418            Column.create();
3419            Column.justifyContent(FlexAlign.Center);
3420            Column.width('100%');
3421            Column.padding(this.getTitleAreaPadding());
3422        }, Column);
3423        this.observeComponentCreation2((elmtId, isInitialRender) => {
3424            Row.create();
3425            Row.width('100%');
3426        }, Row);
3427        this.observeComponentCreation2((elmtId, isInitialRender) => {
3428            Text.create(this.primaryTitle);
3429            Text.fontWeight(TITLE_FONT_WEIGHT());
3430            Text.fontColor(ObservedObject.GetRawObject(this.primaryTitleFontColorWithTheme));
3431            Text.textAlign(this.titleTextAlign);
3432            Text.fontSize(ObservedObject.GetRawObject(this.primaryTitleFontSize));
3433            Text.maxFontScale(Math.min(this.appMaxFontScale, MAX_FONT_SCALE));
3434            Text.maxLines(TITLE_MAX_LINES);
3435            Text.heightAdaptivePolicy(TextHeightAdaptivePolicy.MAX_LINES_FIRST);
3436            Text.textOverflow({ overflow: TextOverflow.Ellipsis });
3437            Text.width('100%');
3438        }, Text);
3439        Text.pop();
3440        Row.pop();
3441        this.observeComponentCreation2((elmtId, isInitialRender) => {
3442            If.create();
3443            if (this.primaryTitle && this.secondaryTitle) {
3444                this.ifElseBranchUpdateFunction(0, () => {
3445                    this.observeComponentCreation2((elmtId, isInitialRender) => {
3446                        Row.create();
3447                        Row.height({
3448                            'id': -1,
3449                            'type': 10002,
3450                            params: ['sys.float.padding_level1'],
3451                            'bundleName': '__harDefaultBundleName__',
3452                            'moduleName': '__harDefaultModuleName__'
3453                        });
3454                    }, Row);
3455                    Row.pop();
3456                });
3457            } else {
3458                this.ifElseBranchUpdateFunction(1, () => {
3459                });
3460            }
3461        }, If);
3462        If.pop();
3463        this.observeComponentCreation2((elmtId, isInitialRender) => {
3464            Row.create();
3465            Row.width('100%');
3466        }, Row);
3467        this.observeComponentCreation2((elmtId, isInitialRender) => {
3468            Text.create(this.secondaryTitle);
3469            Text.fontWeight(FontWeight.Regular);
3470            Text.fontColor(ObservedObject.GetRawObject(this.secondaryTitleFontColorWithTheme));
3471            Text.textAlign(this.titleTextAlign);
3472            Text.fontSize(ObservedObject.GetRawObject(this.secondaryTitleFontSize));
3473            Text.maxFontScale(Math.min(this.appMaxFontScale, MAX_FONT_SCALE));
3474            Text.maxLines(TITLE_MAX_LINES);
3475            Text.heightAdaptivePolicy(TextHeightAdaptivePolicy.MAX_LINES_FIRST);
3476            Text.textOverflow({ overflow: TextOverflow.Ellipsis });
3477            Text.width('100%');
3478        }, Text);
3479        Text.pop();
3480        Row.pop();
3481        Column.pop();
3482    }
3483
3484    /**
3485     * get title area padding
3486     *
3487     * @returns padding
3488     */
3489    getTitleAreaPadding() {
3490        if (this.primaryTitle || this.secondaryTitle) {
3491            return {
3492                top: {
3493                    'id': -1,
3494                    'type': 10002,
3495                    params: ['sys.float.alert_title_padding_top'],
3496                    'bundleName': '__harDefaultBundleName__',
3497                    'moduleName': '__harDefaultModuleName__'
3498                },
3499                right: {
3500                    'id': -1,
3501                    'type': 10002,
3502                    params: ['sys.float.alert_title_padding_right'],
3503                    'bundleName': '__harDefaultBundleName__',
3504                    'moduleName': '__harDefaultModuleName__'
3505                },
3506                left: {
3507                    'id': -1,
3508                    'type': 10002,
3509                    params: ['sys.float.alert_title_padding_left'],
3510                    'bundleName': '__harDefaultBundleName__',
3511                    'moduleName': '__harDefaultModuleName__'
3512                },
3513                bottom: {
3514                    'id': -1,
3515                    'type': 10002,
3516                    params: ['sys.float.alert_title_padding_bottom'],
3517                    'bundleName': '__harDefaultBundleName__',
3518                    'moduleName': '__harDefaultModuleName__'
3519                },
3520            };
3521        }
3522        return {
3523            top: 0,
3524            right: {
3525                'id': -1,
3526                'type': 10002,
3527                params: ['sys.float.alert_title_padding_right'],
3528                'bundleName': '__harDefaultBundleName__',
3529                'moduleName': '__harDefaultModuleName__'
3530            },
3531            left: {
3532                'id': -1,
3533                'type': 10002,
3534                params: ['sys.float.alert_title_padding_left'],
3535                'bundleName': '__harDefaultBundleName__',
3536                'moduleName': '__harDefaultModuleName__'
3537            },
3538            bottom: 0,
3539        };
3540    }
3541
3542    /**
3543     * get tile TextAlign
3544     * @returns TextAlign
3545     */
3546    initTitleTextAlign() {
3547        let textAlign = ALERT_TITLE_ALIGNMENT();
3548        if (textAlign === TextAlign.Start) {
3549            this.titleTextAlign = TextAlign.Start;
3550        } else if (textAlign === TextAlign.Center) {
3551            this.titleTextAlign = TextAlign.Center;
3552        } else if (textAlign === TextAlign.End) {
3553            this.titleTextAlign = TextAlign.End;
3554        } else if (textAlign === TextAlign.JUSTIFY) {
3555            this.titleTextAlign = TextAlign.JUSTIFY;
3556        } else {
3557            this.titleTextAlign = TextAlign.Center;
3558        }
3559    }
3560
3561    /**
3562     * get title area min height
3563     *
3564     * @returns min height
3565     */
3566    getTitleAreaMinHeight() {
3567        if (this.secondaryTitle) {
3568            return {
3569                'id': -1,
3570                'type': 10002,
3571                params: ['sys.float.alert_title_secondary_height'],
3572                'bundleName': '__harDefaultBundleName__',
3573                'moduleName': '__harDefaultModuleName__'
3574            };
3575        } else if (this.primaryTitle) {
3576            return {
3577                'id': -1,
3578                'type': 10002,
3579                params: ['sys.float.alert_title_primary_height'],
3580                'bundleName': '__harDefaultBundleName__',
3581                'moduleName': '__harDefaultModuleName__'
3582            };
3583        } else {
3584            return 0;
3585        }
3586    }
3587
3588    /**
3589     * set state of button focus
3590     */
3591    setDefaultFocusState(buttonList) {
3592        if (!buttonList) {
3593            return;
3594        }
3595        let falseNum = 0;
3596        buttonList.forEach((button) => {
3597            // 遍历查询按钮中存在是否存在默认按钮
3598            if (button.defaultFocus) {
3599                this.isHasDefaultFocus = true;
3600            }
3601            if (button.defaultFocus === false) {
3602                falseNum++;
3603            }
3604        });
3605        // 所有按钮defaultFocus都设置为false
3606        if (falseNum === buttonList.length) {
3607            this.isAllFocusFalse = true;
3608        }
3609    }
3610
3611    ButtonBuilder(parent = null) {
3612        this.observeComponentCreation2((elmtId, isInitialRender) => {
3613            Column.create();
3614            Column.width('100%');
3615            Column.padding(this.getOperationAreaPadding());
3616        }, Column);
3617        this.observeComponentCreation2((elmtId, isInitialRender) => {
3618            If.create();
3619            if (this.buttons && this.buttons.length > 0) {
3620                this.ifElseBranchUpdateFunction(0, () => {
3621                    this.observeComponentCreation2((elmtId, isInitialRender) => {
3622                        If.create();
3623                        if (this.isButtonVertical) {
3624                            this.ifElseBranchUpdateFunction(0, () => {
3625                                this.buildVerticalAlignButtons.bind(this)();
3626                            });
3627                        } else {
3628                            this.ifElseBranchUpdateFunction(1, () => {
3629                                this.buildHorizontalAlignButtons.bind(this)();
3630                            });
3631                        }
3632                    }, If);
3633                    If.pop();
3634                });
3635            } else {
3636                this.ifElseBranchUpdateFunction(1, () => {
3637                });
3638            }
3639        }, If);
3640        If.pop();
3641        Column.pop();
3642    }
3643
3644    isSetCustomButtonTheme() {
3645        // is set fadeout style: now only on TV
3646        if (IS_FADEOUT_ENABLE()) {
3647            // has set button background color prop
3648            if (this.theme?.colors?.compBackgroundTertiary || this.theme?.colors?.backgroundEmphasize) {
3649                return true;
3650            }
3651            // has set button font color prop
3652            if (this.theme?.colors?.fontEmphasize || this.theme?.colors?.fontOnPrimary || this.theme?.colors?.warning) {
3653                return true;
3654            }
3655            return false;
3656        }
3657        return true;
3658    }
3659
3660    buildButton(parent = null) {
3661        this.observeComponentCreation2((elmtId, isInitialRender) => {
3662            If.create();
3663            if (this.isSetCustomButtonTheme()) {
3664                this.ifElseBranchUpdateFunction(0, () => {
3665                    this.observeComponentCreation2((elmtId, isInitialRender) => {
3666                        WithTheme.create({ theme: this.theme, colorMode: this.themeColorMode });
3667                    }, WithTheme);
3668                    this.ButtonBuilder.bind(this)();
3669                    WithTheme.pop();
3670                });
3671            } else {
3672                this.ifElseBranchUpdateFunction(1, () => {
3673                    this.ButtonBuilder.bind(this)();
3674                });
3675            }
3676        }, If);
3677        If.pop();
3678    }
3679
3680    /**
3681     * get operation area padding
3682     *
3683     * @returns padding
3684     */
3685    getOperationAreaPadding() {
3686        if (this.isButtonVertical) {
3687            return {
3688                top: {
3689                    'id': -1,
3690                    'type': 10002,
3691                    params: ['sys.float.alert_button_top_padding'],
3692                    'bundleName': '__harDefaultBundleName__',
3693                    'moduleName': '__harDefaultModuleName__'
3694                },
3695                right: {
3696                    'id': -1,
3697                    'type': 10002,
3698                    params: ['sys.float.alert_right_padding_vertical'],
3699                    'bundleName': '__harDefaultBundleName__',
3700                    'moduleName': '__harDefaultModuleName__'
3701                },
3702                left: {
3703                    'id': -1,
3704                    'type': 10002,
3705                    params: ['sys.float.alert_left_padding_vertical'],
3706                    'bundleName': '__harDefaultBundleName__',
3707                    'moduleName': '__harDefaultModuleName__'
3708                },
3709                bottom: {
3710                    'id': -1,
3711                    'type': 10002,
3712                    params: ['sys.float.alert_button_bottom_padding_vertical'],
3713                    'bundleName': '__harDefaultBundleName__',
3714                    'moduleName': '__harDefaultModuleName__'
3715                },
3716            };
3717        }
3718        return {
3719            top: {
3720                'id': -1,
3721                'type': 10002,
3722                params: ['sys.float.alert_button_top_padding'],
3723                'bundleName': '__harDefaultBundleName__',
3724                'moduleName': '__harDefaultModuleName__'
3725            },
3726            right: {
3727                'id': -1,
3728                'type': 10002,
3729                params: ['sys.float.alert_right_padding_horizontal'],
3730                'bundleName': '__harDefaultBundleName__',
3731                'moduleName': '__harDefaultModuleName__'
3732            },
3733            left: {
3734                'id': -1,
3735                'type': 10002,
3736                params: ['sys.float.alert_left_padding_horizontal'],
3737                'bundleName': '__harDefaultBundleName__',
3738                'moduleName': '__harDefaultModuleName__'
3739            },
3740            bottom: {
3741                'id': -1,
3742                'type': 10002,
3743                params: ['sys.float.alert_button_bottom_padding_horizontal'],
3744                'bundleName': '__harDefaultBundleName__',
3745                'moduleName': '__harDefaultModuleName__'
3746            },
3747        };
3748    }
3749
3750    buildSingleButton(buttonOptions, parent = null) {
3751        this.observeComponentCreation2((elmtId, isInitialRender) => {
3752            If.create();
3753            if (this.isNewPropertiesHighPriority(buttonOptions)) {
3754                this.ifElseBranchUpdateFunction(0, () => {
3755                    this.observeComponentCreation2((elmtId, isInitialRender) => {
3756                        Button.createWithLabel(buttonOptions.value);
3757                        __Button__setButtonProperties(buttonOptions, this.isHasDefaultFocus, this.isAllFocusFalse,
3758                            this.controller);
3759                        Button.role(buttonOptions.role ?? ButtonRole.NORMAL);
3760                        Button.key(`advanced_dialog_button_${this.keyIndex++}`);
3761                        Button.labelStyle({
3762                            maxLines: 1,
3763                            overflow: IS_FADEOUT_ENABLE() ? TextOverflow.MARQUEE : TextOverflow.Ellipsis,
3764                            maxFontSize: this.buttonMaxFontSize,
3765                            minFontSize: this.buttonMinFontSize
3766                        });
3767                    }, Button);
3768                    Button.pop();
3769                });
3770            } else if (buttonOptions.background !== undefined && buttonOptions.fontColor !== undefined) {
3771                this.ifElseBranchUpdateFunction(1, () => {
3772                    this.observeComponentCreation2((elmtId, isInitialRender) => {
3773                        Button.createWithLabel(buttonOptions.value);
3774                        __Button__setButtonProperties(buttonOptions, this.isHasDefaultFocus, this.isAllFocusFalse,
3775                            this.controller);
3776                        Button.backgroundColor(buttonOptions.background);
3777                        Button.fontColor(buttonOptions.fontColor);
3778                        Button.key(`advanced_dialog_button_${this.keyIndex++}`);
3779                        Button.labelStyle({
3780                            maxLines: 1,
3781                            overflow: IS_FADEOUT_ENABLE() ? TextOverflow.MARQUEE : TextOverflow.Ellipsis,
3782                            maxFontSize: this.buttonMaxFontSize,
3783                            minFontSize: this.buttonMinFontSize
3784                        });
3785                    }, Button);
3786                    Button.pop();
3787                });
3788            } else if (buttonOptions.background !== undefined) {
3789                this.ifElseBranchUpdateFunction(2, () => {
3790                    this.observeComponentCreation2((elmtId, isInitialRender) => {
3791                        Button.createWithLabel(buttonOptions.value);
3792                        __Button__setButtonProperties(buttonOptions, this.isHasDefaultFocus, this.isAllFocusFalse,
3793                            this.controller);
3794                        Button.backgroundColor(buttonOptions.background);
3795                        Button.key(`advanced_dialog_button_${this.keyIndex++}`);
3796                        Button.labelStyle({
3797                            maxLines: 1,
3798                            overflow: IS_FADEOUT_ENABLE() ? TextOverflow.MARQUEE : TextOverflow.Ellipsis,
3799                            maxFontSize: this.buttonMaxFontSize,
3800                            minFontSize: this.buttonMinFontSize
3801                        });
3802                    }, Button);
3803                    Button.pop();
3804                });
3805            } else {
3806                this.ifElseBranchUpdateFunction(3, () => {
3807                    this.observeComponentCreation2((elmtId, isInitialRender) => {
3808                        Button.createWithLabel(buttonOptions.value);
3809                        __Button__setButtonProperties(buttonOptions, this.isHasDefaultFocus, this.isAllFocusFalse,
3810                            this.controller);
3811                        Button.fontColor(buttonOptions.fontColor);
3812                        Button.key(`advanced_dialog_button_${this.keyIndex++}`);
3813                        Button.labelStyle({
3814                            maxLines: 1,
3815                            overflow: IS_FADEOUT_ENABLE() ? TextOverflow.MARQUEE : TextOverflow.Ellipsis,
3816                            maxFontSize: this.buttonMaxFontSize,
3817                            minFontSize: this.buttonMinFontSize
3818                        });
3819                    }, Button);
3820                    Button.pop();
3821                });
3822            }
3823        }, If);
3824        If.pop();
3825    }
3826
3827    buildHorizontalAlignButtons(parent = null) {
3828        this.observeComponentCreation2((elmtId, isInitialRender) => {
3829            If.create();
3830            if (this.buttons && this.buttons.length > 0) {
3831                this.ifElseBranchUpdateFunction(0, () => {
3832                    this.observeComponentCreation2((elmtId, isInitialRender) => {
3833                        Row.create();
3834                    }, Row);
3835                    this.buildSingleButton.bind(this)(this.buttons[0]);
3836                    this.observeComponentCreation2((elmtId, isInitialRender) => {
3837                        If.create();
3838                        if (this.buttons.length === HORIZON_BUTTON_MAX_COUNT) {
3839                            this.ifElseBranchUpdateFunction(0, () => {
3840                                this.observeComponentCreation2((elmtId, isInitialRender) => {
3841                                    Row.create();
3842                                    Row.width(BUTTON_HORIZONTAL_SPACE() * 2);
3843                                    Row.justifyContent(FlexAlign.Center);
3844                                }, Row);
3845                                this.observeComponentCreation2((elmtId, isInitialRender) => {
3846                                    Divider.create();
3847                                    Divider.width({
3848                                        'id': -1,
3849                                        'type': 10002,
3850                                        params: ['sys.float.alert_divider_width'],
3851                                        'bundleName': '__harDefaultBundleName__',
3852                                        'moduleName': '__harDefaultModuleName__'
3853                                    });
3854                                    Divider.height({
3855                                        'id': -1,
3856                                        'type': 10002,
3857                                        params: ['sys.float.alert_divider_height'],
3858                                        'bundleName': '__harDefaultBundleName__',
3859                                        'moduleName': '__harDefaultModuleName__'
3860                                    });
3861                                    Divider.color(this.getDividerColor());
3862                                    Divider.vertical(true);
3863                                }, Divider);
3864                                Row.pop();
3865                                this.buildSingleButton.bind(this)(this.buttons[HORIZON_BUTTON_MAX_COUNT - 1]);
3866                            });
3867                        } else {
3868                            this.ifElseBranchUpdateFunction(1, () => {
3869                            });
3870                        }
3871                    }, If);
3872                    If.pop();
3873                    Row.pop();
3874                });
3875            } else {
3876                this.ifElseBranchUpdateFunction(1, () => {
3877                });
3878            }
3879        }, If);
3880        If.pop();
3881    }
3882
3883    buildVerticalAlignButtons(parent = null) {
3884        this.observeComponentCreation2((elmtId, isInitialRender) => {
3885            If.create();
3886            if (this.buttons) {
3887                this.ifElseBranchUpdateFunction(0, () => {
3888                    this.observeComponentCreation2((elmtId, isInitialRender) => {
3889                        Column.create();
3890                    }, Column);
3891                    this.observeComponentCreation2((elmtId, isInitialRender) => {
3892                        ForEach.create();
3893                        const forEachItemGenFunction = (_item, index) => {
3894                            const item = _item;
3895                            this.buildButtonWithDivider.bind(this)(this.buttons?.length === HORIZON_BUTTON_MAX_COUNT ?
3896                                HORIZON_BUTTON_MAX_COUNT - index - 1 : index);
3897                        };
3898                        this.forEachUpdateFunction(elmtId, this.buttons.slice(0, VERTICAL_BUTTON_MAX_COUNT),
3899                            forEachItemGenFunction, (item) => item.value.toString(), true, false);
3900                    }, ForEach);
3901                    ForEach.pop();
3902                    Column.pop();
3903                });
3904            } else {
3905                this.ifElseBranchUpdateFunction(1, () => {
3906                });
3907            }
3908        }, If);
3909        If.pop();
3910    }
3911
3912    /**
3913     * get divider color
3914     *
3915     * @returns divider color
3916     */
3917    getDividerColor() {
3918        if (!this.buttons || this.buttons.length === 0 || !DIALOG_DIVIDER_SHOW()) {
3919            return Color.Transparent;
3920        }
3921        if (this.buttons[0].buttonStyle === ButtonStyleMode.TEXTUAL || this.buttons[0].buttonStyle === undefined) {
3922            if (this.buttons[HORIZON_BUTTON_MAX_COUNT - 1].buttonStyle === ButtonStyleMode.TEXTUAL ||
3923                this.buttons[HORIZON_BUTTON_MAX_COUNT - 1].buttonStyle === undefined) {
3924                return {
3925                    'id': -1,
3926                    'type': 10001,
3927                    params: ['sys.color.alert_divider_color'],
3928                    'bundleName': '__harDefaultBundleName__',
3929                    'moduleName': '__harDefaultModuleName__'
3930                };
3931            }
3932        }
3933        return Color.Transparent;
3934    }
3935
3936    /**
3937     * is button buttonStyle and role properties high priority
3938     *
3939     * @param buttonOptions button properties
3940     * @returns check result
3941     */
3942    isNewPropertiesHighPriority(buttonOptions) {
3943        if (buttonOptions.role === ButtonRole.ERROR) {
3944            return true;
3945        }
3946        if (buttonOptions.buttonStyle !== undefined &&
3947            buttonOptions.buttonStyle !== ALERT_BUTTON_STYLE()) {
3948            return true;
3949        }
3950        if (buttonOptions.background === undefined && buttonOptions.fontColor === undefined) {
3951            return true;
3952        }
3953        return false;
3954    }
3955
3956    buildButtonWithDivider(index, parent = null) {
3957        this.observeComponentCreation2((elmtId, isInitialRender) => {
3958            If.create();
3959            if (this.buttons && this.buttons[index]) {
3960                this.ifElseBranchUpdateFunction(0, () => {
3961                    this.observeComponentCreation2((elmtId, isInitialRender) => {
3962                        Row.create();
3963                    }, Row);
3964                    this.buildSingleButton.bind(this)(this.buttons[index]);
3965                    Row.pop();
3966                    this.observeComponentCreation2((elmtId, isInitialRender) => {
3967                        If.create();
3968                        if ((this.buttons.length === HORIZON_BUTTON_MAX_COUNT ? HORIZON_BUTTON_MAX_COUNT - index - 1 :
3969                            index) <
3970                            Math.min(this.buttons.length, VERTICAL_BUTTON_MAX_COUNT) - 1) {
3971                            this.ifElseBranchUpdateFunction(0, () => {
3972                                this.observeComponentCreation2((elmtId, isInitialRender) => {
3973                                    Row.create();
3974                                    Row.height({
3975                                        'id': -1,
3976                                        'type': 10002,
3977                                        params: ['sys.float.alert_button_vertical_space'],
3978                                        'bundleName': '__harDefaultBundleName__',
3979                                        'moduleName': '__harDefaultModuleName__'
3980                                    });
3981                                }, Row);
3982                                Row.pop();
3983                            });
3984                        } else {
3985                            this.ifElseBranchUpdateFunction(1, () => {
3986                            });
3987                        }
3988                    }, If);
3989                    If.pop();
3990                });
3991            } else {
3992                this.ifElseBranchUpdateFunction(1, () => {
3993                });
3994            }
3995        }, If);
3996        If.pop();
3997    }
3998
3999    isVerticalAlignButton(width) {
4000        if (this.buttons) {
4001            if (this.buttons.length === 1) {
4002                return false;
4003            }
4004            if (this.buttons.length !== HORIZON_BUTTON_MAX_COUNT) {
4005                return true;
4006            }
4007            let isVertical = false;
4008            let maxButtonTextSize = vp2px(width / HORIZON_BUTTON_MAX_COUNT - BUTTON_HORIZONTAL_MARGIN() -
4009            BUTTON_HORIZONTAL_SPACE() - 2 * BUTTON_HORIZONTAL_PADDING);
4010            this.buttons.forEach((button) => {
4011                try {
4012                    let contentSize = measure.measureTextSize({
4013                        textContent: button.value,
4014                        fontSize: this.buttonMaxFontSize
4015                    });
4016                    if (Number(contentSize?.width) > maxButtonTextSize) {
4017                        isVertical = true;
4018                    }
4019                } catch (err) {
4020                    let code = (err).code;
4021                    let message = (err).message;
4022                    hilog.error(0x3900, 'Ace', `Faild to dialog isVerticalAlignButton measureTextSize,cause,
4023                    code: ${code}, message: ${message}`);
4024                }
4025            });
4026            return isVertical;
4027        }
4028        return false;
4029    }
4030
4031    rerender() {
4032        this.updateDirtyElements();
4033    }
4034}
4035
4036function __Button__setButtonProperties(buttonOptions, isHasDefaultFocus, isAllFocusFalse, controller) {
4037    Button.onKeyEvent((event) => {
4038        if (!event) {
4039            return;
4040        }
4041        if ((event.keyCode === KeyCode.KEYCODE_SPACE || event.keyCode === KeyCode.KEYCODE_ENTER) &&
4042            event.type === KeyType.Down) {
4043            if (buttonOptions.action) {
4044                buttonOptions.action();
4045            }
4046            closeDialog(controller, 'onKeyEvent');
4047            event.stopPropagation();
4048        }
4049    });
4050    Button.onClick(() => {
4051        if (buttonOptions.action) {
4052            buttonOptions.action();
4053        }
4054        closeDialog(controller, 'onClick');
4055    });
4056    Button.defaultFocus(isDefaultFocus(buttonOptions, isHasDefaultFocus, isAllFocusFalse));
4057    Button.buttonStyle(buttonOptions.buttonStyle ??
4058        (buttonOptions.role === ButtonRole.ERROR ? ERROR_BUTTON_STYLE() : ALERT_BUTTON_STYLE()));
4059    Button.layoutWeight(BUTTON_LAYOUT_WEIGHT);
4060    Button.type(ButtonType.ROUNDED_RECTANGLE);
4061}
4062
4063function closeDialog(controller, funcName) {
4064    if (controller) {
4065        hilog?.info(0x3900, 'Ace', `AdvancedDialog button ${funcName} controller true`);
4066        controller?.close();
4067    } else {
4068        hilog?.info(0x3900, 'Ace', `AdvancedDialog button ${funcName} controller false`);
4069    }
4070}
4071
4072/**
4073 * is button set default focus
4074 *
4075 * @param singleButton button options
4076 * @param isHasDefaultFocus is button list has default focus button
4077 * @param isAllFocusFalse is all button in button list default focus false
4078 * @returns boolean
4079 */
4080function isDefaultFocus(singleButton, isHasDefaultFocus, isAllFocusFalse) {
4081    try {
4082        // 当前按钮为默认按钮
4083        if (singleButton.defaultFocus) {
4084            return true;
4085        }
4086        let isDefaultFocus = false;
4087        if (isHasDefaultFocus || isAllFocusFalse) {
4088            isDefaultFocus = false; // 存在默认按钮或者所有按钮的defaultFocus都为false
4089        } else {
4090            isDefaultFocus = true; // 默认第一个按钮获焦
4091        }
4092        return isDefaultFocus;
4093    } catch (error) {
4094        let code = error.code;
4095        let message = error.message;
4096        hilog.error(0x3900, 'Ace', `get defaultFocus exist error, code: ${code}, message: ${message}`);
4097        return true;
4098    }
4099}
4100
4101/**
4102 * get resource size
4103 *
4104 * @param resourceId resource id
4105 * @param defaultValue default value
4106 * @returns resource size
4107 */
4108function getNumberByResourceId(resourceId, defaultValue, allowZero) {
4109    try {
4110        let sourceValue = resourceManager.getSystemResourceManager().getNumber(resourceId);
4111        if (sourceValue > 0 || allowZero) {
4112            return sourceValue;
4113        } else {
4114            return defaultValue;
4115        }
4116    } catch (error) {
4117        let code = error.code;
4118        let message = error.message;
4119        hilog.error(0x3900, 'Ace',
4120            `CustomContentDialog getNumberByResourceId error, code: ${code}, message: ${message}`);
4121        return defaultValue;
4122    }
4123}
4124
4125/**
4126 * lazy init
4127 *
4128 * @param initializer  lazy initializer
4129 * @returns lazy init result
4130 */
4131function lazyInit(initializer) {
4132    let value = null;
4133    return () => {
4134        if (value === null) {
4135            value = initializer();
4136        }
4137        return value;
4138    };
4139}
4140
4141/**
4142 * get LengthMetrics size
4143 *
4144 * @param resource resource
4145 * @param defaultValue default value
4146 * @param isAllowZero allow value zero
4147 * @returns LengthMetrics size
4148 */
4149function getLengthMetricsByResource(resource, defaultValue, isAllowZero) {
4150    if (!resource) {
4151        hilog.error(0x3900, 'Ace', 'CustomContentDialog getLengthMetricsByResource error');
4152        return defaultValue;
4153    }
4154    try {
4155        let sourceValue = LengthMetrics.resource(resource).value;
4156        if (sourceValue === 0) {
4157            return isAllowZero ? sourceValue : defaultValue;
4158        }
4159        return sourceValue;
4160    } catch (error) {
4161        let code = error.code;
4162        let message = error.message;
4163        hilog.error(0x3900, 'Ace',
4164            `CustomContentDialog getLengthMetricsByResource error, code: ${code}, message: ${message}`);
4165        return defaultValue;
4166    }
4167}
4168
4169/**
4170 * get string value
4171 *
4172 * @param resourceId Resource id
4173 * @returns resource value
4174 */
4175function getString(resourceId) {
4176    let res = '';
4177    if (resourceId <= 0) {
4178        hilog.error(0x3900, 'Ace', 'CustomContentDialog getString error');
4179        return res;
4180    }
4181    try {
4182        res = getContext().resourceManager.getStringSync(resourceId);
4183    } catch (error) {
4184        let code = error.code;
4185        let message = error.message;
4186        hilog.error(0x3900, 'Ace', `CustomContentDialog getString error, code: ${code}, message: ${message}`);
4187    }
4188    return res;
4189}
4190
4191/**
4192 * 获取SelectDialog无障碍文本
4193 *
4194 * @param resource 资源
4195 * @param selected select state
4196 * @returns string
4197 */
4198function getAccessibilityText(resource, selected) {
4199    try {
4200        let selectText = getContext().resourceManager.getStringSync(125833934);
4201        let resourceString = '';
4202        if (typeof resource === 'string') {
4203            resourceString = resource;
4204        } else {
4205            resourceString = getContext().resourceManager.getStringSync(resource);
4206        }
4207        return selected ? `${selectText},${resourceString}` : resourceString;
4208    } catch (error) {
4209        let code = error.code;
4210        let message = error.message;
4211        hilog.error(0x3900, 'Ace', `getAccessibilityText error, code: ${code}, message: ${message}`);
4212        return '';
4213    }
4214}
4215
4216/**
4217 * get Text Align
4218 *
4219 * @param maxWidth maxWidth
4220 * @param content textContent
4221 * @param fontSize fontSize
4222 * @returns textAlign
4223 */
4224function getTextAlign(maxWidth, content, fontSize) {
4225    let contentSize = measure.measureTextSize({
4226        textContent: content,
4227        fontSize: fontSize,
4228        constraintWidth: maxWidth,
4229    });
4230    let oneLineSize = measure.measureTextSize({
4231        textContent: content,
4232        fontSize: fontSize,
4233    });
4234    if (getTextHeight(contentSize) <= getTextHeight(oneLineSize)) {
4235        return TextAlign.Center;
4236    }
4237    return TextAlign.Start;
4238}
4239
4240/**
4241 * get text height
4242 *
4243 * @param textSize textSize
4244 * @returns text height
4245 */
4246function getTextHeight(textSize) {
4247    if (textSize && textSize.height !== null && textSize.height !== undefined) {
4248        return Number(textSize.height);
4249    }
4250    return 0;
4251}
4252
4253/**
4254 * resolve content area keyEvent
4255 *
4256 * @param event keyEvent
4257 * @param controller the controller of content area
4258 * @returns undefined
4259 */
4260function resolveKeyEvent(event, controller) {
4261    if (event.type === IGNORE_KEY_EVENT_TYPE) {
4262        return;
4263    }
4264    if (event.keyCode === KEYCODE_UP) {
4265        controller.scrollPage({ next: false });
4266        event.stopPropagation();
4267    } else if (event.keyCode === KEYCODE_DOWN) {
4268        if (controller.isAtEnd()) {
4269            return;
4270        } else {
4271            controller.scrollPage({ next: true });
4272            event.stopPropagation();
4273        }
4274    }
4275}
4276
4277/**
4278 * 获取checkTips无障碍文本
4279 *
4280 * @param resource 资源
4281 * @param selected select state
4282 * @returns string
4283 */
4284function getCheckTipsAccessibilityText(resource, selected) {
4285    try {
4286        // 'sys.string.slider_accessibility_selected'
4287        let selectText = getContext().resourceManager.getStringSync(125833934);
4288        // 'sys.string.slider_accessibility_unselected'
4289        let unselectText = getContext().resourceManager.getStringSync(125833935);
4290        // 'sys.string.advanced_dialog_accessibility_checkbox'
4291        let checkBoxText = getContext().resourceManager.getStringSync(125834354);
4292        let resourceString = '';
4293        if (typeof resource === 'string') {
4294            resourceString = resource;
4295        } else {
4296            resourceString = getContext().resourceManager.getStringSync(resource);
4297        }
4298        return selected ? `${selectText},${resourceString},${checkBoxText}` :
4299            `${unselectText},${resourceString},${checkBoxText}`;
4300    } catch (error) {
4301        let code = error.code;
4302        let message = error.message;
4303        hilog.error(0x3900, 'Ace', `getCheckTipsAccessibilityText error, code: ${code}, message: ${message}`);
4304        return '';
4305    }
4306}
4307
4308export class LoadingDialog extends ViewPU {
4309    constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) {
4310        super(parent, __localStorage, elmtId, extraInfo);
4311        if (typeof paramsLambda === 'function') {
4312            this.paramsGenerator_ = paramsLambda;
4313        }
4314        this.controller = undefined;
4315        this.content = '';
4316        this.__fontColorWithTheme = new ObservedPropertyObjectPU({
4317            'id': -1,
4318            'type': 10001,
4319            params: ['sys.color.font_primary'],
4320            'bundleName': '__harDefaultBundleName__',
4321            'moduleName': '__harDefaultModuleName__'
4322        }, this, 'fontColorWithTheme');
4323        this.__loadingProgressIconColorWithTheme = new ObservedPropertyObjectPU({
4324            'id': -1,
4325            'type': 10001,
4326            params: ['sys.color.icon_secondary'],
4327            'bundleName': '__harDefaultBundleName__',
4328            'moduleName': '__harDefaultModuleName__'
4329        }, this, 'loadingProgressIconColorWithTheme');
4330        this.theme = new CustomThemeImpl({});
4331        this.themeColorMode = ThemeColorMode.SYSTEM;
4332        this.__fontSizeScale = new ObservedPropertySimplePU(1, this, 'fontSizeScale');
4333        this.__minContentHeight = new ObservedPropertySimplePU(MIN_CONTENT_HEIGHT, this, 'minContentHeight');
4334        this.setInitiallyProvidedValue(params);
4335        this.finalizeConstruction();
4336    }
4337
4338    setInitiallyProvidedValue(params) {
4339        if (params.controller !== undefined) {
4340            this.controller = params.controller;
4341        }
4342        if (params.content !== undefined) {
4343            this.content = params.content;
4344        }
4345        if (params.fontColorWithTheme !== undefined) {
4346            this.fontColorWithTheme = params.fontColorWithTheme;
4347        }
4348        if (params.loadingProgressIconColorWithTheme !== undefined) {
4349            this.loadingProgressIconColorWithTheme = params.loadingProgressIconColorWithTheme;
4350        }
4351        if (params.theme !== undefined) {
4352            this.theme = params.theme;
4353        }
4354        if (params.themeColorMode !== undefined) {
4355            this.themeColorMode = params.themeColorMode;
4356        }
4357        if (params.fontSizeScale !== undefined) {
4358            this.fontSizeScale = params.fontSizeScale;
4359        }
4360        if (params.minContentHeight !== undefined) {
4361            this.minContentHeight = params.minContentHeight;
4362        }
4363    }
4364
4365    updateStateVars(params) {
4366    }
4367
4368    purgeVariableDependenciesOnElmtId(rmElmtId) {
4369        this.__fontColorWithTheme.purgeDependencyOnElmtId(rmElmtId);
4370        this.__loadingProgressIconColorWithTheme.purgeDependencyOnElmtId(rmElmtId);
4371        this.__fontSizeScale.purgeDependencyOnElmtId(rmElmtId);
4372        this.__minContentHeight.purgeDependencyOnElmtId(rmElmtId);
4373    }
4374
4375    aboutToBeDeleted() {
4376        this.__fontColorWithTheme.aboutToBeDeleted();
4377        this.__loadingProgressIconColorWithTheme.aboutToBeDeleted();
4378        this.__fontSizeScale.aboutToBeDeleted();
4379        this.__minContentHeight.aboutToBeDeleted();
4380        SubscriberManager.Get().delete(this.id__());
4381        this.aboutToBeDeletedInternal();
4382    }
4383
4384    setController(ctr) {
4385        this.controller = ctr;
4386    }
4387
4388    get fontColorWithTheme() {
4389        return this.__fontColorWithTheme.get();
4390    }
4391
4392    set fontColorWithTheme(newValue) {
4393        this.__fontColorWithTheme.set(newValue);
4394    }
4395
4396    get loadingProgressIconColorWithTheme() {
4397        return this.__loadingProgressIconColorWithTheme.get();
4398    }
4399
4400    set loadingProgressIconColorWithTheme(newValue) {
4401        this.__loadingProgressIconColorWithTheme.set(newValue);
4402    }
4403
4404    get fontSizeScale() {
4405        return this.__fontSizeScale.get();
4406    }
4407
4408    set fontSizeScale(newValue) {
4409        this.__fontSizeScale.set(newValue);
4410    }
4411
4412    get minContentHeight() {
4413        return this.__minContentHeight.get();
4414    }
4415
4416    set minContentHeight(newValue) {
4417        this.__minContentHeight.set(newValue);
4418    }
4419
4420    initialRender() {
4421        this.observeComponentCreation2((elmtId, isInitialRender) => {
4422            Column.create();
4423        }, Column);
4424        this.observeComponentCreation2((elmtId, isInitialRender) => {
4425            __Common__.create();
4426            __Common__.constraintSize({ maxHeight: '100%' });
4427        }, __Common__);
4428        {
4429            this.observeComponentCreation2((elmtId, isInitialRender) => {
4430                if (isInitialRender) {
4431                    let componentCall = new CustomDialogContentComponent(this, {
4432                        controller: this.controller,
4433                        contentBuilder: () => {
4434                            this.contentBuilder();
4435                        },
4436                        theme: this.theme,
4437                        themeColorMode: this.themeColorMode,
4438                        fontSizeScale: this.__fontSizeScale,
4439                        minContentHeight: this.__minContentHeight,
4440                    }, undefined, elmtId, () => {
4441                    }, { page: 'library/src/main/ets/components/dialog.ets', line: 1900, col: 7 });
4442                    ViewPU.create(componentCall);
4443                    let paramsLambda = () => {
4444                        return {
4445                            controller: this.controller,
4446                            contentBuilder: () => {
4447                                this.contentBuilder();
4448                            },
4449                            theme: this.theme,
4450                            themeColorMode: this.themeColorMode,
4451                            fontSizeScale: this.fontSizeScale,
4452                            minContentHeight: this.minContentHeight
4453                        };
4454                    };
4455                    componentCall.paramsGenerator_ = paramsLambda;
4456                } else {
4457                    this.updateStateVarsOfChildByElmtId(elmtId, {});
4458                }
4459            }, { name: 'CustomDialogContentComponent' });
4460        }
4461        __Common__.pop();
4462        Column.pop();
4463    }
4464
4465    contentBuilder(parent = null) {
4466        this.observeComponentCreation2((elmtId, isInitialRender) => {
4467            Column.create();
4468        }, Column);
4469        this.observeComponentCreation2((elmtId, isInitialRender) => {
4470            Row.create();
4471            Row.constraintSize({ minHeight: LOADING_MIN_HEIGHT });
4472        }, Row);
4473        this.observeComponentCreation2((elmtId, isInitialRender) => {
4474            Text.create(this.content);
4475            Text.fontSize(`${CONTENT_FONT_SIZE()}fp`);
4476            Text.fontWeight(FontWeight.Regular);
4477            Text.fontColor(ObservedObject.GetRawObject(this.fontColorWithTheme));
4478            Text.layoutWeight(LOADING_TEXT_LAYOUT_WEIGHT);
4479            Text.maxLines(this.fontSizeScale > MAX_FONT_SCALE ? LOADING_MAX_LINES_BIG_FONT : LOADING_MAX_LINES);
4480            Text.focusable(true);
4481            Text.defaultFocus(true);
4482            Text.focusBox({
4483                strokeWidth: LengthMetrics.px(0)
4484            });
4485            Text.textOverflow({ overflow: TextOverflow.Ellipsis });
4486        }, Text);
4487        Text.pop();
4488        this.observeComponentCreation2((elmtId, isInitialRender) => {
4489            LoadingProgress.create();
4490            LoadingProgress.color(ObservedObject.GetRawObject(this.loadingProgressIconColorWithTheme));
4491            LoadingProgress.width(LOADING_PROGRESS_WIDTH);
4492            LoadingProgress.height(LOADING_PROGRESS_HEIGHT);
4493            LoadingProgress.margin({ start: LengthMetrics.vp(LOADING_TEXT_MARGIN_LEFT) });
4494        }, LoadingProgress);
4495        Row.pop();
4496        Column.pop();
4497    }
4498
4499    aboutToAppear() {
4500        this.fontColorWithTheme = this.theme?.colors?.fontPrimary ?
4501        this.theme.colors.fontPrimary : {
4502                'id': -1,
4503                'type': 10001,
4504                params: ['sys.color.font_primary'],
4505                'bundleName': '__harDefaultBundleName__',
4506                'moduleName': '__harDefaultModuleName__'
4507            };
4508        this.loadingProgressIconColorWithTheme = this.theme?.colors?.iconSecondary ?
4509        this.theme.colors.iconSecondary : {
4510                'id': -1,
4511                'type': 10001,
4512                params: ['sys.color.icon_secondary'],
4513                'bundleName': '__harDefaultBundleName__',
4514                'moduleName': '__harDefaultModuleName__'
4515            };
4516    }
4517
4518    rerender() {
4519        this.updateDirtyElements();
4520    }
4521}
4522
4523export class PopoverDialog extends ViewPU {
4524    constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) {
4525        super(parent, __localStorage, elmtId, extraInfo);
4526        if (typeof paramsLambda === 'function') {
4527            this.paramsGenerator_ = paramsLambda;
4528        }
4529        this.__visible = new SynchedPropertySimpleTwoWayPU(params.visible, this, 'visible');
4530        this.__popover = new SynchedPropertyObjectOneWayPU(params.popover, this, 'popover');
4531        this.targetBuilder = undefined;
4532        this.__dialogWidth = new ObservedPropertyObjectPU(this.popover?.width, this, 'dialogWidth');
4533        this.setInitiallyProvidedValue(params);
4534        this.finalizeConstruction();
4535    }
4536
4537    setInitiallyProvidedValue(params) {
4538        if (params.targetBuilder !== undefined) {
4539            this.targetBuilder = params.targetBuilder;
4540        }
4541        if (params.dialogWidth !== undefined) {
4542            this.dialogWidth = params.dialogWidth;
4543        }
4544    }
4545
4546    updateStateVars(params) {
4547        this.__popover.reset(params.popover);
4548    }
4549
4550    purgeVariableDependenciesOnElmtId(rmElmtId) {
4551        this.__visible.purgeDependencyOnElmtId(rmElmtId);
4552        this.__popover.purgeDependencyOnElmtId(rmElmtId);
4553        this.__dialogWidth.purgeDependencyOnElmtId(rmElmtId);
4554    }
4555
4556    aboutToBeDeleted() {
4557        this.__visible.aboutToBeDeleted();
4558        this.__popover.aboutToBeDeleted();
4559        this.__dialogWidth.aboutToBeDeleted();
4560        SubscriberManager.Get().delete(this.id__());
4561        this.aboutToBeDeletedInternal();
4562    }
4563
4564    get visible() {
4565        return this.__visible.get();
4566    }
4567
4568    set visible(newValue) {
4569        this.__visible.set(newValue);
4570    }
4571
4572    get popover() {
4573        return this.__popover.get();
4574    }
4575
4576    set popover(newValue) {
4577        this.__popover.set(newValue);
4578    }
4579
4580    get dialogWidth() {
4581        return this.__dialogWidth.get();
4582    }
4583
4584    set dialogWidth(newValue) {
4585        this.__dialogWidth.set(newValue);
4586    }
4587
4588    emptyBuilder(parent = null) {
4589    }
4590
4591    aboutToAppear() {
4592        if (this.targetBuilder === undefined || this.targetBuilder === null) {
4593            this.targetBuilder = this.emptyBuilder;
4594        }
4595    }
4596
4597    initialRender() {
4598        this.observeComponentCreation2((elmtId, isInitialRender) => {
4599            Column.create();
4600            Column.onClick(() => {
4601                try {
4602                    let screenSize = display.getDefaultDisplaySync();
4603                    let screenWidth = px2vp(screenSize.width);
4604                    if (screenWidth - BUTTON_HORIZONTAL_MARGIN() - BUTTON_HORIZONTAL_MARGIN() > MAX_DIALOG_WIDTH) {
4605                        this.popover.width = this.popover?.width ?? MAX_DIALOG_WIDTH;
4606                    } else {
4607                        this.popover.width = this.dialogWidth;
4608                    }
4609                    this.visible = !this.visible;
4610                } catch (error) {
4611                    let code = error.code;
4612                    let message = error.message;
4613                    hilog.error(0x3900, 'Ace', `dialog popup error, code: ${code}, message: ${message}`);
4614                }
4615            });
4616            Column.bindPopup(this.visible, {
4617                builder: this.popover?.builder,
4618                placement: this.popover?.placement ?? Placement.Bottom,
4619                popupColor: this.popover?.popupColor,
4620                enableArrow: this.popover?.enableArrow ?? true,
4621                autoCancel: this.popover?.autoCancel,
4622                onStateChange: this.popover?.onStateChange ?? ((e) => {
4623                    if (!e.isVisible) {
4624                        this.visible = false;
4625                    }
4626                }),
4627                arrowOffset: this.popover?.arrowOffset,
4628                showInSubWindow: this.popover?.showInSubWindow,
4629                mask: this.popover?.mask,
4630                targetSpace: this.popover?.targetSpace,
4631                offset: this.popover?.offset,
4632                width: this.popover?.width,
4633                arrowPointPosition: this.popover?.arrowPointPosition,
4634                arrowWidth: this.popover?.arrowWidth,
4635                arrowHeight: this.popover?.arrowHeight,
4636                radius: this.popover?.radius ?? {
4637                    'id': -1,
4638                    'type': 10002,
4639                    params: ['sys.float.corner_radius_level16'],
4640                    'bundleName': '__harDefaultBundleName__',
4641                    'moduleName': '__harDefaultModuleName__'
4642                },
4643                shadow: this.popover?.shadow ?? ShadowStyle.OUTER_DEFAULT_MD,
4644                backgroundBlurStyle: this.popover?.backgroundBlurStyle ?? BlurStyle.COMPONENT_ULTRA_THICK,
4645                focusable: this.popover?.focusable,
4646                transition: this.popover?.transition,
4647                onWillDismiss: this.popover?.onWillDismiss
4648            });
4649        }, Column);
4650        this.targetBuilder.bind(this)();
4651        Column.pop();
4652    }
4653
4654    rerender() {
4655        this.updateDirtyElements();
4656    }
4657}
4658
4659export default {
4660    TipsDialog,
4661    ConfirmDialog,
4662    SelectDialog,
4663    AlertDialog,
4664    LoadingDialog,
4665    CustomContentDialog,
4666    PopoverDialog
4667};