1/*
2 * Copyright (c) 2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to  in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16var __decorate = (this && this.__decorate) || function (m10, n10, o10, p10) {
17    var q10 = arguments.length, r10 = q10 < 3 ? n10 : p10 === null ? p10 = Object.getOwnPropertyDescriptor(n10, o10) : p10, s10;
18    if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
19        r10 = Reflect.decorate(m10, n10, o10, p10);
20    else
21        for (var t10 = m10.length - 1; t10 >= 0; t10--)
22            if (s10 = m10[t10])
23                r10 = (q10 < 3 ? s10(r10) : q10 > 3 ? s10(n10, o10, r10) : s10(n10, o10)) || r10;
24    return q10 > 3 && r10 && Object.defineProperty(n10, o10, r10), r10;
25};
26if (!("finalizeConstruction" in ViewPU.prototype)) {
27    Reflect.set(ViewPU.prototype, "finalizeConstruction", () => { });
28}
29
30const hilog = requireNapi('hilog');
31const deviceInfo = requireNapi('deviceInfo');
32const display = requireNapi('display');
33const mediaquery = requireNapi('mediaquery');
34
35const TAG = 'DeviceHelper';
36export class DeviceHelper {
37    static isPhone() {
38        return (DeviceHelper.DEVICE_TYPE === DeviceHelper.TYPE_PHONE || DeviceHelper.DEVICE_TYPE === DeviceHelper.TYPE_DEFAULT);
39    }
40    static isTablet() {
41        return DeviceHelper.DEVICE_TYPE === DeviceHelper.TYPE_TABLET;
42    }
43    static isFold() {
44        let k10 = false;
45        try {
46            k10 = display.isFoldable();
47        }
48        catch (l10) {
49            hilog.error(0x0000, TAG, 'isFold -> isFoldable try error:', l10);
50        }
51        return k10;
52    }
53    static isExpanded() {
54        let i10 = false;
55        try {
56            i10 = display.getFoldStatus() === display.FoldStatus.FOLD_STATUS_EXPANDED;
57        }
58        catch (j10) {
59            hilog.error(0x0000, TAG, 'isExpanded -> try error:', j10);
60        }
61        return i10;
62    }
63    static isColumn() {
64        let g10 = false;
65        try {
66            g10 = display.isFoldable() && (display.getFoldStatus() === display.FoldStatus.FOLD_STATUS_EXPANDED ||
67                display.getFoldStatus() === display.FoldStatus.FOLD_STATUS_HALF_FOLDED);
68        }
69        catch (h10) {
70            hilog.error(0x0000, TAG, 'isColumn -> try error:', h10);
71        }
72        return g10;
73    }
74    static isStraightProduct() {
75        return DeviceHelper.isPhone() && !DeviceHelper.isFold();
76    }
77}
78DeviceHelper.TYPE_DEFAULT = 'default';
79DeviceHelper.TYPE_PHONE = 'phone';
80DeviceHelper.TYPE_TABLET = 'tablet';
81DeviceHelper.DEVICE_TYPE = deviceInfo.deviceType;
82export class DeviceListenerManager {
83    constructor() {
84        this.portraitListener = mediaquery.matchMediaSync('(orientation: portrait)');
85        this.drawableWidthLargeListener = mediaquery.matchMediaSync('(width >= 600vp)');
86        this.isPortrait = undefined;
87        this.onOrientationChange = undefined;
88        this.isLarge = undefined;
89        this.onDrawableWidthChange = undefined;
90    }
91    static getInstance() {
92        if (DeviceListenerManager.instance === undefined) {
93            DeviceListenerManager.instance = new DeviceListenerManager();
94        }
95        return DeviceListenerManager.instance;
96    }
97    onPortraitChange(e10) {
98        let f10 = false;
99        if (DeviceListenerManager.getInstance().isPortrait === undefined) {
100            DeviceListenerManager.getInstance().isPortrait = e10.matches;
101            f10 = true;
102        }
103        else {
104            if (e10.matches) {
105                if (!DeviceListenerManager.getInstance().isPortrait) {
106                    DeviceListenerManager.getInstance().isPortrait = true;
107                    f10 = true;
108                    hilog.debug(0x0000, 'MultiNavigation', 'display portrait');
109                }
110            }
111            else {
112                if (DeviceListenerManager.getInstance().isPortrait) {
113                    DeviceListenerManager.getInstance().isPortrait = false;
114                    f10 = true;
115                    hilog.debug(0x0000, 'MultiNavigation', 'display landscape');
116                }
117            }
118        }
119        if (f10) {
120            DeviceListenerManager.getInstance().notifyOrientationChange();
121        }
122    }
123    notifyOrientationChange() {
124        this.onOrientationChange && this.onOrientationChange(this.isPortrait);
125    }
126    onDrawableWidthLargeChange(c10) {
127        let d10 = false;
128        if (DeviceListenerManager.getInstance().isLarge === undefined) {
129            DeviceListenerManager.getInstance().isLarge = c10.matches;
130            d10 = true;
131        }
132        else {
133            if (c10.matches) {
134                if (!DeviceListenerManager.getInstance().isLarge) {
135                    DeviceListenerManager.getInstance().isLarge = true;
136                    d10 = true;
137                    hilog.debug(0x0000, 'MultiNavigation', 'display isLarge');
138                }
139            }
140            else {
141                if (DeviceListenerManager.getInstance().isLarge) {
142                    DeviceListenerManager.getInstance().isLarge = false;
143                    d10 = true;
144                    hilog.debug(0x0000, 'MultiNavigation', 'display not large');
145                }
146            }
147        }
148        if (d10) {
149            DeviceListenerManager.getInstance().notifyWidthChange();
150        }
151    }
152    notifyWidthChange() {
153        this.onDrawableWidthChange && this.onDrawableWidthChange(this.isLarge);
154    }
155    registerOrientationLister(b10) {
156        this.onOrientationChange = b10;
157        this.onOrientationChange && this.isPortrait && this.onOrientationChange(this.isPortrait);
158    }
159    unregisterOrientationLister() {
160        this.onOrientationChange = undefined;
161    }
162    registerDrawableWidthLister(a10) {
163        this.onDrawableWidthChange = a10;
164        this.onDrawableWidthChange && this.isLarge && this.onDrawableWidthChange(this.isLarge);
165    }
166    unregisterDrawableWidthLister() {
167        this.onDrawableWidthChange = undefined;
168    }
169    initListener() {
170        this.portraitListener.on('change', this.onPortraitChange);
171        this.drawableWidthLargeListener.on('change', this.onDrawableWidthLargeChange);
172    }
173    finalizeListener() {
174        this.portraitListener.off('change', this.onPortraitChange);
175        this.drawableWidthLargeListener.off('change', this.onDrawableWidthLargeChange);
176    }
177}
178let NavWidthRangeAttrModifier = class NavWidthRangeAttrModifier {
179    constructor() {
180        this.isApplicationSet = false;
181        this.minHomeWidth = '50%';
182        this.maxHomeWidth = '50%';
183    }
184    applyNormalAttribute(z9) {
185        if (this.isApplicationSet) {
186            z9.navBarWidthRange([this.minHomeWidth, this.maxHomeWidth]);
187        }
188    }
189};
190NavWidthRangeAttrModifier = __decorate([
191    Observed
192], NavWidthRangeAttrModifier);
193export { NavWidthRangeAttrModifier };
194export class SubNavigation extends ViewPU {
195    constructor(s9, t9, u9, v9 = -1, w9 = undefined, x9) {
196        super(s9, u9, v9, x9);
197        if (typeof w9 === "function") {
198            this.paramsGenerator_ = w9;
199        }
200        this.__isPortrait = new SynchedPropertySimpleTwoWayPU(t9.isPortrait, this, "isPortrait");
201        this.__displayMode = new ObservedPropertySimplePU(0, this, "displayMode");
202        this.__multiStack = new SynchedPropertyNesedObjectPU(t9.multiStack, this, "multiStack");
203        this.navDestination = undefined;
204        this.primaryStack = new MyNavPathStack();
205        this.__secondaryStack = new ObservedPropertyObjectPU(new MyNavPathStack(), this, "secondaryStack");
206        this.__primaryWidth = new ObservedPropertySimplePU('50%', this, "primaryWidth");
207        this.__needRenderIsFullScreen = new SynchedPropertyNesedObjectPU(t9.needRenderIsFullScreen, this, "needRenderIsFullScreen");
208        this.__needRenderLeftClickCount = new SynchedPropertyNesedObjectPU(t9.needRenderLeftClickCount, this, "needRenderLeftClickCount");
209        this.__navWidthRangeModifier = new SynchedPropertyNesedObjectPU(t9.navWidthRangeModifier, this, "navWidthRangeModifier");
210        this.__needRenderDisplayMode = new SynchedPropertyNesedObjectPU(t9.needRenderDisplayMode, this, "needRenderDisplayMode");
211        this.onNavigationModeChange = (y9) => { };
212        this.setInitiallyProvidedValue(t9);
213        this.finalizeConstruction();
214    }
215    setInitiallyProvidedValue(r9) {
216        if (r9.displayMode !== undefined) {
217            this.displayMode = r9.displayMode;
218        }
219        this.__multiStack.set(r9.multiStack);
220        if (r9.navDestination !== undefined) {
221            this.navDestination = r9.navDestination;
222        }
223        if (r9.primaryStack !== undefined) {
224            this.primaryStack = r9.primaryStack;
225        }
226        if (r9.secondaryStack !== undefined) {
227            this.secondaryStack = r9.secondaryStack;
228        }
229        if (r9.primaryWidth !== undefined) {
230            this.primaryWidth = r9.primaryWidth;
231        }
232        this.__needRenderIsFullScreen.set(r9.needRenderIsFullScreen);
233        this.__needRenderLeftClickCount.set(r9.needRenderLeftClickCount);
234        this.__navWidthRangeModifier.set(r9.navWidthRangeModifier);
235        this.__needRenderDisplayMode.set(r9.needRenderDisplayMode);
236        if (r9.onNavigationModeChange !== undefined) {
237            this.onNavigationModeChange = r9.onNavigationModeChange;
238        }
239    }
240    updateStateVars(q9) {
241        this.__multiStack.set(q9.multiStack);
242        this.__needRenderIsFullScreen.set(q9.needRenderIsFullScreen);
243        this.__needRenderLeftClickCount.set(q9.needRenderLeftClickCount);
244        this.__navWidthRangeModifier.set(q9.navWidthRangeModifier);
245        this.__needRenderDisplayMode.set(q9.needRenderDisplayMode);
246    }
247    purgeVariableDependenciesOnElmtId(p9) {
248        this.__isPortrait.purgeDependencyOnElmtId(p9);
249        this.__displayMode.purgeDependencyOnElmtId(p9);
250        this.__multiStack.purgeDependencyOnElmtId(p9);
251        this.__secondaryStack.purgeDependencyOnElmtId(p9);
252        this.__primaryWidth.purgeDependencyOnElmtId(p9);
253        this.__needRenderIsFullScreen.purgeDependencyOnElmtId(p9);
254        this.__needRenderLeftClickCount.purgeDependencyOnElmtId(p9);
255        this.__navWidthRangeModifier.purgeDependencyOnElmtId(p9);
256        this.__needRenderDisplayMode.purgeDependencyOnElmtId(p9);
257    }
258    aboutToBeDeleted() {
259        this.__isPortrait.aboutToBeDeleted();
260        this.__displayMode.aboutToBeDeleted();
261        this.__multiStack.aboutToBeDeleted();
262        this.__secondaryStack.aboutToBeDeleted();
263        this.__primaryWidth.aboutToBeDeleted();
264        this.__needRenderIsFullScreen.aboutToBeDeleted();
265        this.__needRenderLeftClickCount.aboutToBeDeleted();
266        this.__navWidthRangeModifier.aboutToBeDeleted();
267        this.__needRenderDisplayMode.aboutToBeDeleted();
268        SubscriberManager.Get().delete(this.id__());
269        this.aboutToBeDeletedInternal();
270    }
271    get isPortrait() {
272        return this.__isPortrait.get();
273    }
274    set isPortrait(o9) {
275        this.__isPortrait.set(o9);
276    }
277    get displayMode() {
278        return this.__displayMode.get();
279    }
280    set displayMode(n9) {
281        this.__displayMode.set(n9);
282    }
283    get multiStack() {
284        return this.__multiStack.get();
285    }
286    get secondaryStack() {
287        return this.__secondaryStack.get();
288    }
289    set secondaryStack(m9) {
290        this.__secondaryStack.set(m9);
291    }
292    get primaryWidth() {
293        return this.__primaryWidth.get();
294    }
295    set primaryWidth(l9) {
296        this.__primaryWidth.set(l9);
297    }
298    get needRenderIsFullScreen() {
299        return this.__needRenderIsFullScreen.get();
300    }
301    get needRenderLeftClickCount() {
302        return this.__needRenderLeftClickCount.get();
303    }
304    get navWidthRangeModifier() {
305        return this.__navWidthRangeModifier.get();
306    }
307    get needRenderDisplayMode() {
308        return this.__needRenderDisplayMode.get();
309    }
310    SubNavDestination(i9, j9, k9 = null) {
311        this.navDestination.bind(this)(i9, j9);
312    }
313    getMode() {
314        this.displayMode = this.needRenderDisplayMode.displayMode;
315        if (DeviceHelper.isPhone() && DeviceHelper.isStraightProduct()) {
316            return NavigationMode.Stack;
317        }
318        if (this.displayMode === display.FoldStatus.FOLD_STATUS_UNKNOWN) {
319            this.displayMode = display.getFoldStatus();
320        }
321        if (DeviceHelper.isTablet() && this.isPortrait) {
322            hilog.info(0x0000, 'MultiNavigation', 'SubNavigation getMode tablet portrait');
323            return NavigationMode.Stack;
324        }
325        if (this.needRenderIsFullScreen.isFullScreen == undefined) {
326            if (DeviceHelper.isPhone()) {
327                return this.secondaryStack.size() > 0 && DeviceHelper.isColumn() ? NavigationMode.Auto : NavigationMode.Stack;
328            }
329            return this.secondaryStack.size() > 0 ? NavigationMode.Auto : NavigationMode.Stack;
330        }
331        return this.needRenderIsFullScreen.isFullScreen ? NavigationMode.Stack : NavigationMode.Auto;
332    }
333    aboutToAppear() {
334        hilog.debug(0x0000, 'MultiNavigation', 'SubNavigation aboutToAppear param = ' + JSON.stringify(this.primaryStack));
335    }
336    initialRender() {
337        this.observeComponentCreation2((a9, b9) => {
338            NavDestination.create(() => {
339                this.observeComponentCreation2((f9, g9) => {
340                    Navigation.create(this.secondaryStack, { moduleName: "MultiNavigation", pagePath: "", isUserCreateStack: true });
341                    Navigation.mode(this.getMode());
342                    Navigation.onNavigationModeChange(this?.onNavigationModeChange);
343                    Navigation.hideBackButton(true);
344                    Navigation.hideTitleBar(true);
345                    Navigation.navDestination({ builder: this.SubNavDestination.bind(this) });
346                    Navigation.navBarWidth(this.primaryWidth);
347                    Navigation.attributeModifier.bind(this)(ObservedObject.GetRawObject(this.navWidthRangeModifier));
348                    Navigation.onTouch((h9) => {
349                        if (h9.type === TouchType.Down) {
350                            hilog.info(0x0000, 'MultiNavigation', 'outer navigation this.outerStack.leftClickCount ' +
351                                this.needRenderLeftClickCount.leftClickCount);
352                            this.needRenderLeftClickCount.leftClickCount--;
353                        }
354                    });
355                }, Navigation);
356                this.observeComponentCreation2((c9, d9) => {
357                    Navigation.create(this.primaryStack, { moduleName: "MultiNavigation", pagePath: "", isUserCreateStack: true });
358                    Navigation.hideNavBar(true);
359                    Navigation.mode(NavigationMode.Stack);
360                    Navigation.navDestination({ builder: this.SubNavDestination.bind(this) });
361                    Navigation.hideTitleBar(true);
362                    Navigation.hideToolBar(true);
363                    Navigation.hideBackButton(true);
364                    Navigation.onTouch((e9) => {
365                        if (e9.type === TouchType.Down) {
366                            this.needRenderLeftClickCount.leftClickCount = 2;
367                        }
368                    });
369                }, Navigation);
370                Navigation.pop();
371                Navigation.pop();
372            }, { moduleName: "MultiNavigation", pagePath: "" });
373            NavDestination.onBackPressed(() => {
374                hilog.debug(0x0000, 'MultiNavigation', 'subNavigation NavDestination onBackPressed');
375                if (this.multiStack && this.secondaryStack.size() === 1) {
376                    hilog.info(0x0000, 'MultiNavigation', 'subNavigation NavDestination onBackPressed multiStack.pop');
377                    this.multiStack.pop();
378                    return true;
379                }
380                return false;
381            });
382            NavDestination.hideTitleBar(true);
383        }, NavDestination);
384        NavDestination.pop();
385    }
386    rerender() {
387        this.updateDirtyElements();
388    }
389}
390export var SplitPolicy;
391(function (z8) {
392    z8[z8["HOME_PAGE"] = 0] = "HOME_PAGE";
393    z8[z8["DETAIL_PAGE"] = 1] = "DETAIL_PAGE";
394    z8[z8["FULL_PAGE"] = 2] = "FULL_PAGE";
395    z8[z8["PlACE_HOLDER_PAGE"] = 3] = "PlACE_HOLDER_PAGE";
396})(SplitPolicy || (SplitPolicy = {}));
397let that;
398export class MultiNavigation extends ViewPU {
399    constructor(q8, r8, s8, t8 = -1, u8 = undefined, v8) {
400        super(q8, s8, t8, v8);
401        if (typeof u8 === "function") {
402            this.paramsGenerator_ = u8;
403        }
404        this.foldStatusCallback = (y8) => {
405            hilog.info(0x0000, 'MultiNavigation', 'foldStatusCallback data.valueOf()=' + y8.valueOf());
406            this.multiStack.needRenderDisplayMode.displayMode = y8.valueOf();
407            this.multiStack.handleRefreshPlaceHolderIfNeeded();
408        };
409        this.__multiStack = new ObservedPropertyObjectPU(new MultiNavPathStack(), this, "multiStack");
410        this.navDestination = undefined;
411        this.mode = undefined;
412        this.onNavigationModeChangeCallback = (x8) => {
413        };
414        this.onHomeShowOnTop = (w8) => { };
415        this.__isPortrait = new ObservedPropertySimplePU(false, this, "isPortrait");
416        this.setInitiallyProvidedValue(r8);
417        this.finalizeConstruction();
418    }
419    setInitiallyProvidedValue(p8) {
420        if (p8.foldStatusCallback !== undefined) {
421            this.foldStatusCallback = p8.foldStatusCallback;
422        }
423        if (p8.multiStack !== undefined) {
424            this.multiStack = p8.multiStack;
425        }
426        if (p8.navDestination !== undefined) {
427            this.navDestination = p8.navDestination;
428        }
429        if (p8.mode !== undefined) {
430            this.mode = p8.mode;
431        }
432        if (p8.onNavigationModeChangeCallback !== undefined) {
433            this.onNavigationModeChangeCallback = p8.onNavigationModeChangeCallback;
434        }
435        if (p8.onHomeShowOnTop !== undefined) {
436            this.onHomeShowOnTop = p8.onHomeShowOnTop;
437        }
438        if (p8.isPortrait !== undefined) {
439            this.isPortrait = p8.isPortrait;
440        }
441    }
442    updateStateVars(o8) {
443    }
444    purgeVariableDependenciesOnElmtId(n8) {
445        this.__multiStack.purgeDependencyOnElmtId(n8);
446        this.__isPortrait.purgeDependencyOnElmtId(n8);
447    }
448    aboutToBeDeleted() {
449        this.__multiStack.aboutToBeDeleted();
450        this.__isPortrait.aboutToBeDeleted();
451        SubscriberManager.Get().delete(this.id__());
452        this.aboutToBeDeletedInternal();
453    }
454    get multiStack() {
455        return this.__multiStack.get();
456    }
457    set multiStack(m8) {
458        this.__multiStack.set(m8);
459    }
460    get isPortrait() {
461        return this.__isPortrait.get();
462    }
463    set isPortrait(l8) {
464        this.__isPortrait.set(l8);
465    }
466    MultiNavDestination(c8, d8, e8 = null) {
467        this.observeComponentCreation2((f8, g8) => {
468            If.create();
469            if (c8 === 'SubNavigation') {
470                this.ifElseBranchUpdateFunction(0, () => {
471                    {
472                        this.observeComponentCreation2((h8, i8) => {
473                            if (i8) {
474                                let j8 = new SubNavigation(this, {
475                                    isPortrait: this.__isPortrait,
476                                    multiStack: this.multiStack,
477                                    navDestination: this.navDestination,
478                                    primaryStack: d8.primaryStack,
479                                    secondaryStack: d8.secondaryStack,
480                                    needRenderIsFullScreen: d8.needRenderIsFullScreen,
481                                    needRenderLeftClickCount: this.multiStack.needRenderLeftClickCount,
482                                    navWidthRangeModifier: this.multiStack.navWidthRangeModifier,
483                                    onNavigationModeChange: this?.callback,
484                                    needRenderDisplayMode: this.multiStack.needRenderDisplayMode,
485                                }, undefined, h8, () => { }, { page: "MultiNavigation/src/main/ets/components/MultiNavigation.ets", line: 333, col: 7 });
486                                ViewPU.create(j8);
487                                let k8 = () => {
488                                    return {
489                                        isPortrait: this.isPortrait,
490                                        multiStack: this.multiStack,
491                                        navDestination: this.navDestination,
492                                        primaryStack: d8.primaryStack,
493                                        secondaryStack: d8.secondaryStack,
494                                        needRenderIsFullScreen: d8.needRenderIsFullScreen,
495                                        needRenderLeftClickCount: this.multiStack.needRenderLeftClickCount,
496                                        navWidthRangeModifier: this.multiStack.navWidthRangeModifier,
497                                        onNavigationModeChange: this?.callback,
498                                        needRenderDisplayMode: this.multiStack.needRenderDisplayMode
499                                    };
500                                };
501                                j8.paramsGenerator_ = k8;
502                            }
503                            else {
504                                this.updateStateVarsOfChildByElmtId(h8, {
505                                    multiStack: this.multiStack,
506                                    needRenderIsFullScreen: d8.needRenderIsFullScreen,
507                                    needRenderLeftClickCount: this.multiStack.needRenderLeftClickCount,
508                                    navWidthRangeModifier: this.multiStack.navWidthRangeModifier,
509                                    needRenderDisplayMode: this.multiStack.needRenderDisplayMode
510                                });
511                            }
512                        }, { name: "SubNavigation" });
513                    }
514                });
515            }
516            else {
517                this.ifElseBranchUpdateFunction(1, () => {
518                    this.navDestination.bind(this)(c8, d8);
519                });
520            }
521        }, If);
522        If.pop();
523    }
524    callback(b8) {
525        if (that.onNavigationModeChangeCallback !== undefined) {
526            if (b8 !== that.mode || that.mode === undefined) {
527                that?.onNavigationModeChangeCallback(b8);
528            }
529            that.mode = b8;
530        }
531    }
532    aboutToAppear() {
533        that = this;
534        hilog.info(0x0000, 'MultiNavigation', 'MultiNavigation aboutToAppear');
535        try {
536            display.on('foldStatusChange', this.foldStatusCallback);
537        }
538        catch (a8) {
539            console.error('Failed to register callback. Code: ' + JSON.stringify(a8));
540        }
541        DeviceListenerManager.getInstance().registerOrientationLister((z7) => {
542            hilog.info(0x0000, 'MultiNavigation', 'MultiNavigation orientation change ' + z7);
543            this.isPortrait = z7;
544            this.multiStack.isPortrait = z7;
545            this.multiStack.handleRefreshPlaceHolderIfNeeded();
546        });
547        DeviceListenerManager.getInstance().registerDrawableWidthLister((y7) => {
548            hilog.debug(0x0000, 'MultiNavigation', 'MultiNavigation Drawable width change ' + y7);
549            this.multiStack.isLarge = y7;
550            this.multiStack.handleRefreshPlaceHolderIfNeeded();
551        });
552        this.multiStack.needRenderDisplayMode.displayMode = display.getFoldStatus();
553        DeviceListenerManager.getInstance().initListener();
554        this.multiStack.registerHomeChangeListener({
555            onHomeShowOnTop: (x7) => {
556                this.onHomeShowOnTop?.(x7);
557            },
558        });
559    }
560    aboutToDisappear() {
561        try {
562            display.off('foldStatusChange');
563        }
564        catch (w7) {
565            console.error('Failed to unregister callback. Code: ' + JSON.stringify(w7));
566        }
567        DeviceListenerManager.getInstance().unregisterOrientationLister();
568        DeviceListenerManager.getInstance().unregisterDrawableWidthLister();
569        DeviceListenerManager.getInstance().finalizeListener();
570        this.multiStack.unregisterHomeChangeListener();
571    }
572    initialRender() {
573        this.observeComponentCreation2((u7, v7) => {
574            Navigation.create(this.multiStack.outerStack, { moduleName: "MultiNavigation", pagePath: "", isUserCreateStack: true });
575            Navigation.mode(NavigationMode.Stack);
576            Navigation.navDestination({ builder: this.MultiNavDestination.bind(this) });
577            Navigation.hideBackButton(true);
578            Navigation.hideTitleBar(true);
579            Navigation.hideToolBar(true);
580            Navigation.hideNavBar(true);
581        }, Navigation);
582        Navigation.pop();
583    }
584    rerender() {
585        this.updateDirtyElements();
586    }
587}
588let MultiNavPathStack = class MultiNavPathStack extends NavPathStack {
589    constructor() {
590        super();
591        this.outerStack = new MyNavPathStack();
592        this.totalStack = [];
593        this.subStackList = new Array();
594        this.needRenderLeftClickCount = new NeedRenderLeftClickCount();
595        this.needRenderDisplayMode = new NeedRenderDisplayMode();
596        this.disableAllAnimation = false;
597        this.mPolicyMap = new Map();
598        this.navWidthRangeModifier = new NavWidthRangeAttrModifier();
599        this.homeWidthPercents = [50, 50];
600        this.keepBottomPageFlag = false;
601        this.homeChangeListener = undefined;
602        this.placeHolderPolicyInfo = undefined;
603        this.isPortrait = false;
604        this.isLarge = false;
605        this.navPathStackOperate = {
606            onPrimaryPop: () => {
607                hilog.info(0x0000, 'MultiNavigation', 'MyNavPathStack onPrimaryPop');
608                this.totalStack.pop();
609                this.subStackList.pop();
610                this.outerStack.popInner(false);
611            },
612            onSecondaryPop: () => {
613                hilog.info(0x0000, 'MultiNavigation', 'MyNavPathStack onSecondaryPop');
614                this.totalStack.pop();
615                this.checkAndNotifyHomeChange();
616            }
617        };
618        this.outerStackOperate = {
619            onSystemPop: () => {
620                hilog.info(0x0000, 'MultiNavigation', 'MyNavPathStack onOuterPop');
621                this.totalStack.pop();
622                this.subStackList.pop();
623                this.checkAndNotifyHomeChange();
624            }
625        };
626        this.outerStack.registerStackOperateCallback(this.outerStackOperate);
627    }
628    pushPath(l7, m7, n7) {
629        hilog.info(0x0000, 'MultiNavigation', 'pushPath policy = ' + n7 + ', info.name = ' + l7.name);
630        let o7 = true;
631        if (m7 !== undefined) {
632            if (typeof m7 === 'boolean') {
633                o7 = m7;
634            }
635            else if (m7.animated !== undefined) {
636                o7 = m7.animated;
637            }
638            else {
639            }
640        }
641        n7 = (n7 === undefined) ? SplitPolicy.DETAIL_PAGE : n7;
642        const p7 = this.subStackList.length;
643        const q7 = new MultiNavPolicyInfo(n7, l7);
644        hilog.info(0x0000, 'MultiNavigation', 'pushPath subStackLength = ' + p7);
645        if (p7 > 0) {
646            hilog.info(0x0000, 'MultiNavigation', 'pushPath currentTopPrimaryPolicy = ' +
647                this.subStackList[p7 - 1].getPrimaryPolicy());
648        }
649        if (n7 === SplitPolicy.DETAIL_PAGE && p7 > 0 &&
650            this.subStackList[p7 - 1].getPrimaryPolicy() === SplitPolicy.HOME_PAGE) {
651            let s7 = this.subStackList[p7 - 1].getSecondaryInfoList().length;
652            hilog.info(0x0000, 'MultiNavigation', 'pushPath detailSize = ' + s7);
653            if (s7 === 0) {
654                this.subStackList[p7 - 1].pushSecondaryPath(q7, o7);
655            }
656            else {
657                if (this.needRenderLeftClickCount.leftClickCount > 0) {
658                    if (this.placeHolderPolicyInfo === undefined) {
659                        this.subStackList[p7 - 1].clearSecondary(false);
660                        this.totalStack.splice(this.totalStack.length - s7);
661                        this.subStackList[p7 - 1].pushSecondaryPath(q7, false);
662                    }
663                    else {
664                        const t7 = this.subStackList[p7 - 1].getSecondaryInfoList()[0].policy;
665                        if (t7 === SplitPolicy.PlACE_HOLDER_PAGE) {
666                            if (s7 === 1) {
667                                this.subStackList[p7 - 1].pushSecondaryPath(q7, o7);
668                            }
669                            else {
670                                this.subStackList[p7 - 1].clearSecondaryKeepPlaceHolder(false);
671                                this.totalStack.splice(this.totalStack.length - s7 + 1);
672                                this.subStackList[p7 - 1].pushSecondaryPath(q7, false);
673                            }
674                        }
675                        else {
676                            this.subStackList[p7 - 1].clearSecondary(false);
677                            this.totalStack.splice(this.totalStack.length - s7);
678                            this.subStackList[p7 - 1].pushSecondaryPath(q7, false);
679                        }
680                    }
681                }
682                else {
683                    this.subStackList[p7 - 1].pushSecondaryPath(q7, o7);
684                }
685            }
686        }
687        else {
688            let r7 = new SubNavigationStack();
689            r7.registerMultiStackOperateCallback(this.navPathStackOperate);
690            r7.disableAnimation(this.disableAllAnimation);
691            r7.pushPrimaryPath(q7, false);
692            this.subStackList.push(r7);
693            this.outerStack.pushPath({ name: 'SubNavigation', param: r7 }, o7);
694        }
695        this.totalStack.push(q7);
696        if (n7 === SplitPolicy.HOME_PAGE && this.placeHolderPolicyInfo !== undefined &&
697            this.needShowPlaceHolder()) {
698            this.pushPlaceHolder(p7);
699        }
700        hilog.info(0x0000, 'MultiNavigation', 'MultiNavPathStack pushPath policy = ' + n7 +
701            ' stackSize = ' + this.totalStack.length +
702            ' this.leftClickCount = ' + this.needRenderLeftClickCount.leftClickCount);
703        this.needRenderLeftClickCount.leftClickCount = 0;
704    }
705    pushPathByName(g7, h7, i7, j7, k7) {
706        if (i7 !== undefined && typeof i7 !== 'boolean') {
707            this.pushPath({ name: g7, param: h7, onPop: i7 }, j7, k7);
708            return;
709        }
710        if (typeof i7 === 'boolean') {
711            this.pushPath({ name: g7, param: h7 }, i7, j7);
712            return;
713        }
714        if (j7 !== undefined && typeof j7 !== 'boolean') {
715            this.pushPath({ name: g7, param: h7 }, undefined, j7);
716            return;
717        }
718        if (typeof j7 === 'boolean') {
719            this.pushPath({ name: g7, param: h7 }, j7, k7);
720            return;
721        }
722        this.pushPath({ name: g7, param: h7 }, undefined, k7);
723    }
724    pushDestination(c7, d7, e7) {
725        hilog.error(0x0000, 'MultiNavigation', 'pushDestination is not support');
726        let f7 = Promise.reject({ message: 'not support' });
727        return f7;
728    }
729    pushDestinationByName(w6, x6, y6, z6, a7) {
730        hilog.error(0x0000, 'MultiNavigation', 'pushDestinationByName is not support');
731        let b7 = Promise.reject({ message: 'not support' });
732        return b7;
733    }
734    replacePath(p6, q6) {
735        let r6 = true;
736        if (q6 !== undefined) {
737            if (typeof q6 === 'boolean') {
738                r6 = q6;
739            }
740            else if (q6.animated !== undefined) {
741                r6 = q6.animated;
742            }
743            else {
744            }
745        }
746        let s6 = this.totalStack.length;
747        let t6 = this.subStackList.length;
748        if (s6 < 1 || t6 < 1) {
749            hilog.error(0x0000, 'MultiNavigation', 'replacePath fail stack is empty');
750            return;
751        }
752        let u6 = this.totalStack[s6 - 1].policy;
753        if (u6 === SplitPolicy.PlACE_HOLDER_PAGE) {
754            hilog.warn(0x0000, 'MultiNavigation', 'replacePath fail, not support replace placeHolder');
755            return;
756        }
757        const v6 = new MultiNavPolicyInfo(u6, p6);
758        this.subStackList[t6 - 1].replacePath(v6, r6);
759        this.totalStack.pop();
760        this.totalStack.push(v6);
761    }
762    replacePathByName(m6, n6, o6) {
763        this.replacePath({ name: m6, param: n6 }, o6);
764    }
765    removeByIndexes(x5) {
766        let y5 = x5.length;
767        hilog.info(0x0000, 'MultiNavigation', 'removeByIndexes indexesLength=' + y5);
768        if (y5 <= 0) {
769            return 0;
770        }
771        let z5 = this.totalStack.length;
772        hilog.info(0x0000, 'MultiNavigation', 'removeByIndexes oriStackSize=' + z5);
773        x5.sort((k6, l6) => k6 - l6);
774        let a6 = 0;
775        let b6 = 0;
776        let c6 = [];
777        hilog.info(0x0000, 'MultiNavigation', 'removeByIndexes this.subStackList.length=' + this.subStackList.length +
778            ', oriStackSize=' + z5);
779        this.subStackList.forEach((g6, h6) => {
780            let i6 = b6;
781            b6 += g6.getAllInfoLength();
782            const j6 = [];
783            for (; a6 < x5.length;) {
784                if (x5[a6] < b6) {
785                    j6.push(x5[a6] - i6);
786                    a6++;
787                }
788                else {
789                    break;
790                }
791            }
792            g6.removeByIndexes(j6);
793            if (!g6.hasPrimaryInfo()) {
794                c6.push(h6);
795            }
796        });
797        hilog.info(0x0000, 'MultiNavigation', 'removeByIndexes outerIndexes.length=' + c6.length);
798        this.outerStack.removeByIndexes(c6);
799        this.subStackList = this.subStackList.filter((f6) => {
800            return f6.hasPrimaryInfo();
801        });
802        this.totalStack = [];
803        this.subStackList.forEach((e6) => {
804            this.totalStack.push(...e6.getPrimaryInfoList());
805            this.totalStack.push(...e6.getSecondaryInfoList());
806        });
807        this.handleRefreshPlaceHolderIfNeeded();
808        this.checkAndNotifyHomeChange();
809        let d6 = z5 - this.totalStack.length;
810        hilog.info(0x0000, 'MultiNavigation', 'removeByIndexes size=' + d6);
811        return d6;
812    }
813    removeByName(p5) {
814        let q5 = this.totalStack.length;
815        hilog.info(0x0000, 'MultiNavigation', 'removeByName name=' + p5 + ', oriStackSize=' + q5);
816        let r5 = [];
817        this.subStackList.forEach((v5, w5) => {
818            v5.removeByName(p5);
819            if (!v5.hasPrimaryInfo()) {
820                r5.push(w5);
821            }
822        });
823        this.outerStack.removeByIndexes(r5);
824        hilog.info(0x0000, 'MultiNavigation', 'removeByName outerIndexes.length=' + r5.length);
825        this.subStackList = this.subStackList.filter((u5) => {
826            return u5.hasPrimaryInfo();
827        });
828        this.totalStack = [];
829        this.subStackList.forEach((t5) => {
830            this.totalStack.push(...t5.getPrimaryInfoList());
831            this.totalStack.push(...t5.getSecondaryInfoList());
832        });
833        this.handleRefreshPlaceHolderIfNeeded();
834        this.checkAndNotifyHomeChange();
835        let s5 = q5 - this.totalStack.length;
836        hilog.info(0x0000, 'MultiNavigation', 'removeByName size=' + s5);
837        return s5;
838    }
839    pop(f5, g5) {
840        let h5 = this.totalStack.length;
841        let i5 = this.subStackList.length;
842        if (h5 < 1 || i5 < 1) {
843            hilog.error(0x0000, 'MultiNavigation', 'MultiNavPathStack pop fail stack is empty!');
844            return undefined;
845        }
846        hilog.info(0x0000, 'MultiNavigation', 'MultiNavPathStack pop totalSize=' + h5 +
847            ', subStackLength' + i5);
848        if (this.keepBottomPageFlag && (h5 === 1 ||
849            (this.placeHolderPolicyInfo !== undefined && h5 === 2 &&
850                this.totalStack[1].policy === SplitPolicy.PlACE_HOLDER_PAGE))) {
851            hilog.info(0x0000, 'MultiNavigation', 'MultiNavPathStack pop fail for keep bottom');
852            return undefined;
853        }
854        let j5 = this.totalStack[h5 - 1].navInfo;
855        let k5 = this.subStackList[i5 - 1].getAllInfoLength();
856        if (k5 < 1) {
857            hilog.error(0x0000, 'MultiNavigation', 'MultiNavPathStack pop fail sub stack is empty');
858            return undefined;
859        }
860        let l5 = undefined;
861        if (k5 > 1) {
862            l5 = this.subStackList[i5 - 1].getSecondaryInfoList()[0].policy;
863        }
864        hilog.info(0x0000, 'MultiNavigation', 'MultiNavPathStack pop allInfoLength=' + k5 +
865            ', secondaryStackFirstPolice' + l5);
866        this.totalStack.pop();
867        if (k5 === 1) {
868            this.outerStack.popInner(g5);
869            let o5 = this.subStackList.pop();
870            setTimeout(() => {
871                o5?.pop(false);
872                o5 = undefined;
873            }, 300);
874        }
875        else {
876            if (k5 === 2) {
877                if (this.placeHolderPolicyInfo !== undefined) {
878                    if (l5 === SplitPolicy.PlACE_HOLDER_PAGE) {
879                        this.outerStack.popInner(g5);
880                        let n5 = this.subStackList.pop();
881                        setTimeout(() => {
882                            n5?.clear(false);
883                            n5 = undefined;
884                        }, 300);
885                        j5 = this.totalStack.pop()?.navInfo;
886                    }
887                    else {
888                        if (this.needShowPlaceHolder()) {
889                            this.subStackList[i5 - 1].pop(g5);
890                            this.pushPlaceHolder(i5 - 1);
891                        }
892                        else {
893                            this.subStackList[i5 - 1].pop(g5);
894                        }
895                    }
896                }
897                else {
898                    this.subStackList[i5 - 1].pop(g5);
899                }
900            }
901            else {
902                this.subStackList[i5 - 1].pop(g5);
903            }
904        }
905        hilog.info(0x0000, 'MultiNavigation', 'MultiNavPathStack pop currentPath.name = ' + j5?.name);
906        if (f5 !== undefined && typeof f5 !== 'boolean' &&
907            j5 !== undefined && j5.onPop !== undefined) {
908            let m5 = {
909                info: j5,
910                result: f5,
911            };
912            j5.onPop(m5);
913        }
914        this.handleRefreshPlaceHolderIfNeeded();
915        this.checkAndNotifyHomeChange();
916        hilog.info(0x0000, 'MultiNavigation', 'MultiNavPathStack pop stackSize = ' + this.totalStack.length);
917        return j5;
918    }
919    popToName(r4, s4, t4) {
920        let u4 = this.totalStack.findIndex((e5) => {
921            return e5.navInfo?.name === r4;
922        });
923        let v4 = this.totalStack.length;
924        let w4 = this.subStackList.length;
925        if (v4 < 1 || w4 < 1) {
926            hilog.error(0x0000, 'MultiNavigation', 'popToName fail stack is empty!');
927            return -1;
928        }
929        if (u4 !== -1) {
930            let x4 = this.totalStack[v4 - 1].navInfo;
931            let y4 = [];
932            this.subStackList.forEach((c5, d5) => {
933                y4.push(this.subStackList[d5].secondaryStack.size());
934            });
935            let z4 = 0;
936            for (let b5 = 0; b5 < w4; b5++) {
937                z4++;
938                if (u4 === z4 - 1) {
939                    this.subStackList[b5]?.secondaryStack.clear();
940                    this.subStackList[b5].secondaryStack.policyInfoList.splice(0);
941                    this.totalStack.splice(u4 + 1);
942                    this.clearTrashStack(b5 + 1, s4, t4);
943                    break;
944                }
945                else if (u4 > z4 - 1 && u4 < z4 + y4[b5]) {
946                    this.subStackList[b5].secondaryStack.popToIndex(u4 - z4);
947                    this.subStackList[b5].secondaryStack.policyInfoList.splice(u4 - z4 + 1);
948                    this.totalStack.splice(u4 + 1);
949                    this.clearTrashStack(b5 + 1, s4, t4);
950                }
951                z4 += y4[b5];
952            }
953            if (s4 !== undefined && typeof s4 !== 'boolean' &&
954                x4 !== undefined && x4.onPop !== undefined) {
955                let a5 = {
956                    info: x4,
957                    result: s4,
958                };
959                x4.onPop(a5);
960            }
961        }
962        this.handleRefreshPlaceHolderIfNeeded();
963        this.checkAndNotifyHomeChange();
964        return u4;
965    }
966    popToIndex(f4, g4, h4) {
967        hilog.info(0x0000, 'MultiNavigation', 'MultiNavPathStack popToIndex index = ' + f4);
968        if (f4 > this.totalStack.length || f4 < 0) {
969            hilog.error(0x0000, 'MultiNavigation', 'popToIndex fail wrong index');
970            return;
971        }
972        let i4 = this.totalStack.length;
973        let j4 = this.subStackList.length;
974        if (i4 < 1 || j4 < 1) {
975            hilog.error(0x0000, 'MultiNavigation', 'popToIndex fail stack is empty!');
976            return;
977        }
978        let k4 = this.totalStack[i4 - 1].navInfo;
979        let l4 = [];
980        this.subStackList.forEach((p4, q4) => {
981            l4.push(this.subStackList[q4].secondaryStack.size());
982        });
983        let m4 = 0;
984        for (let o4 = 0; o4 < j4; o4++) {
985            m4++;
986            if (f4 === m4 - 1) {
987                hilog.info(0x0000, 'MultiNavigation', 'MultiNavPathStack popToIndex home' + o4);
988                this.subStackList[o4]?.secondaryStack.clear();
989                this.subStackList[o4].secondaryStack.policyInfoList.splice(0);
990                this.totalStack.splice(f4 + 1);
991                this.clearTrashStack(o4 + 1, g4, h4);
992                hilog.info(0x0000, 'MultiNavigation', 'MultiNavPathStack popToIndex totalStack=' + this.totalStack.length);
993                break;
994            }
995            else if (f4 > m4 - 1 && f4 < m4 + l4[o4]) {
996                this.subStackList[o4].secondaryStack.popToIndex(f4 - m4);
997                this.subStackList[o4].secondaryStack.policyInfoList.splice(f4 - m4 + 1);
998                this.totalStack.splice(f4 + 1);
999                this.clearTrashStack(o4 + 1, g4, h4);
1000            }
1001            m4 += l4[o4];
1002        }
1003        if (g4 !== undefined && typeof g4 !== 'boolean' &&
1004            k4 !== undefined && k4.onPop !== undefined) {
1005            let n4 = {
1006                info: k4,
1007                result: g4,
1008            };
1009            k4.onPop(n4);
1010        }
1011        this.handleRefreshPlaceHolderIfNeeded();
1012        this.checkAndNotifyHomeChange();
1013    }
1014    clearTrashStack(b4, c4, d4) {
1015        hilog.info(0x0000, 'MultiNavigation', 'MultiNavPathStack popToIndex clearTrashStack' + b4);
1016        for (let e4 = b4; e4 < this.subStackList.length; e4++) {
1017            hilog.info(0x0000, 'MultiNavigation', 'MultiNavPathStack popToIndex subStackList' + b4);
1018            this.subStackList[e4].primaryStack.clear();
1019            this.subStackList[e4].secondaryStack.clear();
1020            this.subStackList[e4].primaryStack.policyInfoList.splice(0);
1021            this.subStackList[e4].secondaryStack.policyInfoList.splice(0);
1022        }
1023        this.subStackList.splice(b4);
1024        hilog.info(0x0000, 'MultiNavigation', 'MultiNavPathStack popToIndex subStackList.length=' + this.subStackList.length);
1025        this.outerStack.popToIndex(b4 - 1, c4, d4);
1026        hilog.info(0x0000, 'MultiNavigation', 'MultiNavPathStack popToIndex outerStack.size=' + this.outerStack.size());
1027    }
1028    moveToTop(x3, y3) {
1029        hilog.info(0x0000, 'MultiNavigation', 'MultiNavPathStack moveToTop name=' + x3);
1030        let z3 = this.totalStack.findIndex((a4) => {
1031            return a4.navInfo?.name === x3;
1032        });
1033        if (z3 !== -1) {
1034            this.moveIndexToTop(z3, y3);
1035        }
1036        return z3;
1037    }
1038    moveIndexToTop(m3, n3) {
1039        hilog.info(0x0000, 'MultiNavigation', 'MultiNavPathStack moveIndexToTop index=' + m3);
1040        if (m3 < 0 || m3 > this.totalStack.length) {
1041            hilog.error(0x0000, 'MultiNavigation', 'MultiNavPathStack moveIndexToTop wrong index');
1042            return;
1043        }
1044        let o3 = this.subStackList.length;
1045        let p3 = 0;
1046        let q3 = -1;
1047        for (let t3 = 0; t3 < o3; t3++) {
1048            let u3 = p3;
1049            p3 += this.subStackList[t3].getAllInfoLength();
1050            if (m3 < p3) {
1051                q3 = t3;
1052                if (this.subStackList[t3].getPrimaryPolicy() === SplitPolicy.HOME_PAGE) {
1053                    let v3 = m3 - u3;
1054                    if (v3 !== 0) {
1055                        this.subStackList[t3].secondaryStack.moveIndexToTop(v3 - 1, n3);
1056                        const w3 = this.subStackList[t3].secondaryStack.policyInfoList.splice(v3 - 1, 1);
1057                        this.subStackList[t3].secondaryStack.policyInfoList.push(...w3);
1058                    }
1059                }
1060                break;
1061            }
1062        }
1063        if (q3 !== -1) {
1064            let s3 = this.subStackList.splice(q3, 1);
1065            this.subStackList.push(...s3);
1066            this.outerStack.moveIndexToTop(q3, n3);
1067        }
1068        this.totalStack = [];
1069        this.subStackList.forEach((r3) => {
1070            this.totalStack.push(...r3.getPrimaryInfoList());
1071            this.totalStack.push(...r3.getSecondaryInfoList());
1072        });
1073        this.handleRefreshPlaceHolderIfNeeded();
1074        this.checkAndNotifyHomeChange();
1075    }
1076    clear(i3) {
1077        hilog.info(0x0000, 'MultiNavigation', 'MultiNavPathStack clear animated = ' + i3 + ', keepBottomPageFlag=' +
1078            this.keepBottomPageFlag);
1079        if (this.subStackList.length === 0 || this.totalStack.length === 0) {
1080            hilog.info(0x0000, 'MultiNavigation', 'MultiNavPathStack clear return size is 0');
1081            return;
1082        }
1083        if (this.keepBottomPageFlag) {
1084            let k3 = this.subStackList.length;
1085            for (let l3 = 1; l3 < k3; l3++) {
1086                this.subStackList[l3].clear(i3);
1087            }
1088            this.outerStack.popToIndex(0, i3);
1089            this.subStackList.splice(1);
1090            if (this.placeHolderPolicyInfo !== undefined) {
1091                if (this.subStackList[0].getSecondaryInfoList().length > 1 &&
1092                    this.subStackList[0].secondaryStack.policyInfoList[0].policy === SplitPolicy.PlACE_HOLDER_PAGE) {
1093                    this.subStackList[0].clearSecondaryKeepPlaceHolder(i3);
1094                    this.totalStack.splice(2);
1095                }
1096                else {
1097                    this.subStackList[0].clearSecondary(i3);
1098                    this.totalStack.splice(1);
1099                    if (this.needShowPlaceHolder()) {
1100                        this.subStackList[0].pushSecondaryPath(this.placeHolderPolicyInfo, i3);
1101                        this.totalStack.push(this.placeHolderPolicyInfo);
1102                    }
1103                }
1104            }
1105            else {
1106                this.subStackList[0].clearSecondary(i3);
1107                this.totalStack.splice(1);
1108            }
1109            this.checkAndNotifyHomeChange();
1110            return;
1111        }
1112        this.subStackList.forEach((j3) => {
1113            j3.clear(i3);
1114        });
1115        this.outerStack.clear(i3);
1116        this.subStackList.splice(0);
1117        this.totalStack.splice(0);
1118    }
1119    getAllPathName() {
1120        let g3 = [];
1121        this.totalStack.forEach((h3) => {
1122            if (h3.navInfo !== undefined) {
1123                g3.push(h3.navInfo.name);
1124            }
1125        });
1126        return g3;
1127    }
1128    getParamByIndex(e3) {
1129        let f3 = undefined;
1130        if (e3 >= 0 && e3 < this.totalStack.length) {
1131            f3 = this.totalStack[e3].navInfo?.param;
1132        }
1133        return f3;
1134    }
1135    getParamByName(b3) {
1136        let c3 = [];
1137        this.totalStack.forEach((d3) => {
1138            if (d3.navInfo !== undefined && d3.navInfo.name == b3) {
1139                c3.push(d3.navInfo.param);
1140            }
1141        });
1142        return c3;
1143    }
1144    getIndexByName(y2) {
1145        let z2 = [];
1146        for (let a3 = 0; a3 < this.totalStack.length; a3++) {
1147            if (this.totalStack[a3].navInfo?.name === y2) {
1148                z2.push(a3);
1149            }
1150        }
1151        return z2;
1152    }
1153    getParent() {
1154        hilog.error(0x0000, 'MultiNavigation', 'getParent is not support!');
1155        throw new Error('getParent is not support in multi navigation');
1156    }
1157    size() {
1158        return this.totalStack.length;
1159    }
1160    disableAnimation(w2) {
1161        for (const x2 of this.subStackList) {
1162            x2.disableAnimation(w2);
1163        }
1164        this.outerStack.disableAnimation(w2);
1165        this.disableAllAnimation = w2;
1166    }
1167    setInterception(v2) {
1168        hilog.error(0x0000, 'MultiNavigation', 'setInterception is not support!');
1169        throw new Error('setInterception is not support in multi navigation');
1170    }
1171    setPagePolicy(u2) {
1172        this.mPolicyMap = u2;
1173    }
1174    switchFullScreenState(r2) {
1175        let s2 = this.totalStack.length;
1176        let t2 = this.subStackList.length;
1177        if (t2 < 1 || s2 < 1) {
1178            return false;
1179        }
1180        if (this.subStackList[t2 - 1].getPrimaryPolicy() !== SplitPolicy.HOME_PAGE) {
1181            return false;
1182        }
1183        if (this.totalStack[s2 - 1].policy === SplitPolicy.PlACE_HOLDER_PAGE) {
1184            return false;
1185        }
1186        if (this.totalStack[s2 - 1].isFullScreen === r2) {
1187            hilog.info(0x0000, 'MultiNavigation', 'switchFullScreen is same:' + r2);
1188            return true;
1189        }
1190        hilog.info(0x0000, 'MultiNavigation', 'switchFullScreen name=' +
1191            this.totalStack[s2 - 1].navInfo?.name +
1192            ', from ' + this.totalStack[s2 - 1].isFullScreen + ' to ' + r2);
1193        this.totalStack[s2 - 1].isFullScreen = r2;
1194        this.subStackList[t2 - 1].refreshFullScreen();
1195        return true;
1196    }
1197    setHomeWidthRange(p2, q2) {
1198        if (!this.checkInputPercent(p2) || !this.checkInputPercent(q2)) {
1199            hilog.error(0x0000, 'MultiNavigation', 'setHomeWidthRange failed, wrong param:' +
1200                ', ' + p2 + ', ' + q2);
1201            return;
1202        }
1203        this.homeWidthPercents = [p2, q2];
1204        this.refreshHomeWidth();
1205    }
1206    keepBottomPage(o2) {
1207        this.keepBottomPageFlag = o2;
1208    }
1209    registerHomeChangeListener(n2) {
1210        if (this.homeChangeListener === undefined) {
1211            this.homeChangeListener = n2;
1212        }
1213    }
1214    unregisterHomeChangeListener() {
1215        this.homeChangeListener = undefined;
1216    }
1217    setPlaceholderPage(m2) {
1218        this.placeHolderPolicyInfo = new MultiNavPolicyInfo(SplitPolicy.PlACE_HOLDER_PAGE, m2);
1219    }
1220    handleRefreshPlaceHolderIfNeeded() {
1221        if (this.placeHolderPolicyInfo === undefined) {
1222            return;
1223        }
1224        const i2 = this.subStackList.length;
1225        if (i2 < 1) {
1226            return;
1227        }
1228        const j2 = this.subStackList[i2 - 1].getPrimaryPolicy();
1229        if (j2 !== SplitPolicy.HOME_PAGE) {
1230            return;
1231        }
1232        const k2 = this.subStackList[i2 - 1].getAllInfoLength();
1233        let l2 = undefined;
1234        if (k2 > 1) {
1235            l2 = this.subStackList[i2 - 1].getSecondaryInfoList()[0].policy;
1236        }
1237        if (this.needShowPlaceHolder()) {
1238            if (k2 === 1) {
1239                this.pushPlaceHolder(i2 - 1);
1240            }
1241        }
1242        else {
1243            if (l2 === SplitPolicy.PlACE_HOLDER_PAGE) {
1244                if (k2 === 2) {
1245                    this.popPlaceHolder(i2 - 1);
1246                }
1247                else {
1248                    this.removeFirstPlaceHolder(i2 - 1);
1249                }
1250            }
1251        }
1252    }
1253    removeFirstPlaceHolder(g2) {
1254        this.subStackList[g2].removeByIndexes([1]);
1255        this.totalStack = [];
1256        this.subStackList.forEach((h2) => {
1257            this.totalStack.push(...h2.getPrimaryInfoList());
1258            this.totalStack.push(...h2.getSecondaryInfoList());
1259        });
1260    }
1261    pushPlaceHolder(f2) {
1262        this.subStackList[f2].pushSecondaryPath(this.placeHolderPolicyInfo, false);
1263        this.totalStack.push(this.placeHolderPolicyInfo);
1264    }
1265    popPlaceHolder(e2) {
1266        this.subStackList[e2].pop(false);
1267        this.totalStack.pop();
1268        this.checkAndNotifyHomeChange();
1269    }
1270    needShowPlaceHolder() {
1271        if (!this.isLarge) {
1272            hilog.info(0x0000, 'MultiNavigation', 'do not show placeHolder for drawable width is less then breakpoint');
1273            return false;
1274        }
1275        if (DeviceHelper.isStraightProduct()) {
1276            hilog.info(0x0000, 'MultiNavigation', 'do not show placeHolder for straight product');
1277            return false;
1278        }
1279        if (DeviceHelper.isPhone() && DeviceHelper.isFold() &&
1280            this.needRenderDisplayMode.displayMode === display.FoldStatus.FOLD_STATUS_FOLDED) {
1281            hilog.info(0x0000, 'MultiNavigation', 'do not show placeHolder for fold status');
1282            return false;
1283        }
1284        if (DeviceHelper.isTablet() && this.isPortrait) {
1285            hilog.info(0x0000, 'MultiNavigation', 'do not show placeHolder for portrait tablet');
1286            return false;
1287        }
1288        return true;
1289    }
1290    checkAndNotifyHomeChange() {
1291        if (this.totalStack.length === 0) {
1292            return;
1293        }
1294        let c2 = this.totalStack[this.totalStack.length - 1];
1295        if (c2 === undefined) {
1296            return;
1297        }
1298        if (c2.policy === SplitPolicy.HOME_PAGE && c2.navInfo !== undefined) {
1299            this.homeChangeListener && this.homeChangeListener.onHomeShowOnTop(c2.navInfo.name);
1300        }
1301        if (this.totalStack.length <= 1) {
1302            return;
1303        }
1304        let d2 = this.totalStack[this.totalStack.length - 2];
1305        if (d2 === undefined) {
1306            return;
1307        }
1308        if (c2.policy === SplitPolicy.PlACE_HOLDER_PAGE &&
1309            d2.policy === SplitPolicy.HOME_PAGE && d2.navInfo !== undefined) {
1310            this.homeChangeListener && this.homeChangeListener.onHomeShowOnTop(d2.navInfo.name);
1311        }
1312    }
1313    refreshHomeWidth() {
1314        this.navWidthRangeModifier.minHomeWidth = `${this.homeWidthPercents[0]}%`;
1315        this.navWidthRangeModifier.maxHomeWidth = `${this.homeWidthPercents[1]}%`;
1316        this.navWidthRangeModifier.isApplicationSet = true;
1317    }
1318    checkInputPercent(b2) {
1319        return (0 <= b2 && b2 <= 100);
1320    }
1321};
1322MultiNavPathStack = __decorate([
1323    Observed
1324], MultiNavPathStack);
1325export { MultiNavPathStack };
1326let NeedRenderIsFullScreen = class NeedRenderIsFullScreen {
1327    constructor() {
1328        this.isFullScreen = undefined;
1329    }
1330};
1331NeedRenderIsFullScreen = __decorate([
1332    Observed
1333], NeedRenderIsFullScreen);
1334export { NeedRenderIsFullScreen };
1335let NeedRenderLeftClickCount = class NeedRenderLeftClickCount {
1336    constructor() {
1337        this.leftClickCount = 0;
1338    }
1339};
1340NeedRenderLeftClickCount = __decorate([
1341    Observed
1342], NeedRenderLeftClickCount);
1343export { NeedRenderLeftClickCount };
1344let NeedRenderDisplayMode = class NeedRenderDisplayMode {
1345    constructor() {
1346        this.displayMode = 0;
1347    }
1348};
1349NeedRenderDisplayMode = __decorate([
1350    Observed
1351], NeedRenderDisplayMode);
1352export { NeedRenderDisplayMode };
1353class MultiNavPolicyInfo {
1354    constructor(z1, a2) {
1355        this.policy = SplitPolicy.DETAIL_PAGE;
1356        this.navInfo = undefined;
1357        this.isFullScreen = undefined;
1358        this.policy = z1;
1359        this.navInfo = a2;
1360    }
1361}
1362export class MyNavPathStack extends NavPathStack {
1363    constructor() {
1364        super(...arguments);
1365        this.operates = [];
1366        this.type = 'NavPathStack';
1367        this.policyInfoList = [];
1368    }
1369    registerStackOperateCallback(w1) {
1370        let x1 = this.operates.findIndex((y1) => { return y1 === w1; });
1371        if (x1 === -1) {
1372            this.operates.push(w1);
1373        }
1374    }
1375    unregisterStackOperateCallback(t1) {
1376        let u1 = this.operates.findIndex((v1) => { return v1 === t1; });
1377        if (u1 !== -1) {
1378            this.operates.splice(u1, 1);
1379        }
1380    }
1381    popInner(r1, s1) {
1382        hilog.info(0x0000, 'MultiNavigation', 'MyNavPathStack pop from inner:');
1383        return super.pop(r1, s1);
1384    }
1385    pop(n1, o1) {
1386        hilog.info(0x0000, 'MultiNavigation', 'MyNavPathStack pop from system:');
1387        let p1 = undefined;
1388        if (typeof o1 === 'boolean') {
1389            p1 = super.pop(o1);
1390        }
1391        else {
1392            p1 = super.pop(n1, o1);
1393        }
1394        this.policyInfoList.pop();
1395        this.operates.forEach((q1) => {
1396            q1.onSystemPop?.();
1397        });
1398        return p1;
1399    }
1400}
1401class SubNavigationStack {
1402    constructor() {
1403        this.primaryStack = new MyNavPathStack();
1404        this.secondaryStack = new MyNavPathStack();
1405        this.needRenderIsFullScreen = new NeedRenderIsFullScreen();
1406        this.multiOperates = [];
1407        this.primaryNavPathStackOperate = {
1408            onSystemPop: () => {
1409                this.multiOperates.forEach((m1) => {
1410                    m1.onPrimaryPop?.();
1411                });
1412            }
1413        };
1414        this.secondaryNavPathStackOperate = {
1415            onSystemPop: () => {
1416                this.multiOperates.forEach((l1) => {
1417                    l1.onSecondaryPop?.();
1418                });
1419                this.refreshFullScreen();
1420            }
1421        };
1422        this.primaryStack.registerStackOperateCallback(this.primaryNavPathStackOperate);
1423        this.secondaryStack.registerStackOperateCallback(this.secondaryNavPathStackOperate);
1424    }
1425    registerMultiStackOperateCallback(i1) {
1426        let j1 = this.multiOperates.findIndex((k1) => { return k1 === i1; });
1427        if (j1 === -1) {
1428            this.multiOperates.push(i1);
1429        }
1430    }
1431    unregisterMultiStackOperateCallback(f1) {
1432        let g1 = this.multiOperates.findIndex((h1) => { return h1 === f1; });
1433        if (g1 !== -1) {
1434            this.multiOperates.splice(g1, 1);
1435        }
1436    }
1437    getPrimaryPolicy() {
1438        if (this.primaryStack.policyInfoList.length < 1) {
1439            return undefined;
1440        }
1441        return this.primaryStack.policyInfoList[0].policy;
1442    }
1443    getPrimaryInfoList() {
1444        return this.primaryStack.policyInfoList.slice();
1445    }
1446    getSecondaryInfoList() {
1447        return this.secondaryStack.policyInfoList.slice();
1448    }
1449    getAllInfoLength() {
1450        return this.primaryStack.size() + this.secondaryStack.size();
1451    }
1452    hasPrimaryInfo() {
1453        return this.primaryStack.size() !== 0;
1454    }
1455    hasSecondaryInfo() {
1456        return this.secondaryStack.size() !== 0;
1457    }
1458    pushPrimaryPath(d1, e1) {
1459        this.primaryStack.policyInfoList.push(d1);
1460        this.primaryStack.pushPath(d1.navInfo, e1);
1461        this.refreshFullScreen();
1462    }
1463    pushSecondaryPath(b1, c1) {
1464        this.secondaryStack.policyInfoList.push(b1);
1465        this.secondaryStack.pushPath(b1.navInfo, c1);
1466        this.refreshFullScreen();
1467    }
1468    removeByIndexes(w) {
1469        if (w.length < 1) {
1470            return;
1471        }
1472        if (w[0] === 0) {
1473            hilog.info(0x0000, 'MultiNavigation', 'SubNavigationStack removeByIndexes primaryStack');
1474            this.primaryStack.removeByIndexes([0]);
1475            this.primaryStack.policyInfoList.pop();
1476            this.clear(false);
1477            return;
1478        }
1479        if (w.length !== 0) {
1480            let x = [];
1481            w.forEach((a1) => {
1482                x.push(a1 - 1);
1483            });
1484            this.secondaryStack.removeByIndexes(x);
1485            this.secondaryStack.policyInfoList = this.secondaryStack.policyInfoList.filter((y, z) => {
1486                return y && !x.includes(z);
1487            });
1488        }
1489        this.refreshFullScreen();
1490    }
1491    removeByName(t) {
1492        this.primaryStack.removeByName(t);
1493        this.primaryStack.policyInfoList = this.primaryStack.policyInfoList.filter((v) => {
1494            return v.navInfo?.name !== t;
1495        });
1496        if (!this.hasPrimaryInfo()) {
1497            this.clear(false);
1498            return;
1499        }
1500        this.secondaryStack.removeByName(t);
1501        this.secondaryStack.policyInfoList = this.secondaryStack.policyInfoList.filter((u) => {
1502            return u.navInfo?.name !== t;
1503        });
1504        this.refreshFullScreen();
1505    }
1506    pop(q, r) {
1507        let s = undefined;
1508        if (this.secondaryStack.policyInfoList.length > 0) {
1509            s = this.popSecondary(q, r);
1510        }
1511        else {
1512            s = this.popPrimary(q, r);
1513        }
1514        this.refreshFullScreen();
1515        return s;
1516    }
1517    clearSecondary(p) {
1518        this.secondaryStack.clear(p);
1519        this.secondaryStack.policyInfoList.splice(0);
1520        this.refreshFullScreen();
1521    }
1522    clearSecondaryKeepPlaceHolder(o) {
1523        this.secondaryStack.popToIndex(0, o);
1524        this.secondaryStack.policyInfoList.splice(1);
1525        this.refreshFullScreen();
1526    }
1527    clear(n) {
1528        this.secondaryStack.clear(n);
1529        this.primaryStack.clear(n);
1530        this.secondaryStack.policyInfoList.splice(0);
1531        this.primaryStack.policyInfoList.splice(0);
1532    }
1533    disableAnimation(m) {
1534        this.primaryStack.disableAnimation(m);
1535        this.secondaryStack.disableAnimation(m);
1536    }
1537    replacePath(k, l) {
1538        if (this.secondaryStack.policyInfoList.length > 0) {
1539            this.replaceSecond(k, l);
1540        }
1541        else {
1542            this.replacePrimary(k, l);
1543        }
1544        this.refreshFullScreen();
1545    }
1546    refreshFullScreen() {
1547        let i = this.secondaryStack.policyInfoList.length;
1548        if (i > 0) {
1549            this.needRenderIsFullScreen.isFullScreen = this.secondaryStack.policyInfoList[i - 1].isFullScreen;
1550            return;
1551        }
1552        let j = this.primaryStack.policyInfoList.length;
1553        if (j > 0) {
1554            this.needRenderIsFullScreen.isFullScreen = this.primaryStack.policyInfoList[j - 1].isFullScreen;
1555        }
1556    }
1557    replacePrimary(g, h) {
1558        this.primaryStack.policyInfoList.pop();
1559        this.primaryStack.policyInfoList.push(g);
1560        return this.primaryStack.replacePath(g.navInfo, h);
1561    }
1562    replaceSecond(e, f) {
1563        this.secondaryStack.policyInfoList.pop();
1564        this.secondaryStack.policyInfoList.push(e);
1565        return this.secondaryStack.replacePath(e.navInfo, f);
1566    }
1567    popPrimary(c, d) {
1568        this.primaryStack.policyInfoList.pop();
1569        return this.primaryStack.popInner(c, d);
1570    }
1571    popSecondary(a, b) {
1572        this.secondaryStack.policyInfoList.pop();
1573        return this.secondaryStack.popInner(a, b);
1574    }
1575}
1576
1577export default { MultiNavigation, MultiNavPathStack, SplitPolicy }