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
16if (!("finalizeConstruction" in ViewPU.prototype)) {
17    Reflect.set(ViewPU.prototype, "finalizeConstruction", () => { });
18}
19const DEFAULT_BAR_WIDTH = 96;
20const DEFAULT_BAR_HEIGHT = 52;
21export class AtomicServiceTabs extends ViewPU {
22    constructor(m1, n1, o1, p1 = -1, q1 = undefined, r1) {
23        super(m1, o1, p1, r1);
24        if (typeof q1 === "function") {
25            this.paramsGenerator_ = q1;
26        }
27        this.tabContents = undefined;
28        this.__tabBarOptionsArray = new SynchedPropertyObjectOneWayPU(n1.tabBarOptionsArray, this, "tabBarOptionsArray");
29        this.__tabBarPosition = new SynchedPropertySimpleOneWayPU(n1.tabBarPosition, this, "tabBarPosition");
30        this.__barBackgroundColor = new SynchedPropertyObjectOneWayPU(n1.barBackgroundColor, this, "barBackgroundColor");
31        this.__index = new SynchedPropertyObjectOneWayPU(n1.index, this, "index");
32        this.__barOverlap = new SynchedPropertySimpleOneWayPU(n1.barOverlap, this, "barOverlap");
33        this.controller = new TabsController();
34        this.onChange = undefined;
35        this.onTabBarClick = undefined;
36        this.onContentWillChange = undefined;
37        this.setInitiallyProvidedValue(n1);
38        this.finalizeConstruction();
39    }
40    setInitiallyProvidedValue(l1) {
41        if (l1.tabContents !== undefined) {
42            this.tabContents = l1.tabContents;
43        }
44        if (l1.tabBarPosition === undefined) {
45            this.__tabBarPosition.set(TabBarPosition.BOTTOM);
46        }
47        if (l1.barBackgroundColor === undefined) {
48            this.__barBackgroundColor.set(Color.Transparent);
49        }
50        if (l1.index === undefined) {
51            this.__index.set(0);
52        }
53        if (l1.barOverlap === undefined) {
54            this.__barOverlap.set(true);
55        }
56        if (l1.controller !== undefined) {
57            this.controller = l1.controller;
58        }
59        if (l1.onChange !== undefined) {
60            this.onChange = l1.onChange;
61        }
62        if (l1.onTabBarClick !== undefined) {
63            this.onTabBarClick = l1.onTabBarClick;
64        }
65        if (l1.onContentWillChange !== undefined) {
66            this.onContentWillChange = l1.onContentWillChange;
67        }
68    }
69    updateStateVars(k1) {
70        this.__tabBarOptionsArray.reset(k1.tabBarOptionsArray);
71        this.__tabBarPosition.reset(k1.tabBarPosition);
72        this.__barBackgroundColor.reset(k1.barBackgroundColor);
73        this.__index.reset(k1.index);
74        this.__barOverlap.reset(k1.barOverlap);
75    }
76    purgeVariableDependenciesOnElmtId(j1) {
77        this.__tabBarOptionsArray.purgeDependencyOnElmtId(j1);
78        this.__tabBarPosition.purgeDependencyOnElmtId(j1);
79        this.__barBackgroundColor.purgeDependencyOnElmtId(j1);
80        this.__index.purgeDependencyOnElmtId(j1);
81        this.__barOverlap.purgeDependencyOnElmtId(j1);
82    }
83    aboutToBeDeleted() {
84        this.__tabBarOptionsArray.aboutToBeDeleted();
85        this.__tabBarPosition.aboutToBeDeleted();
86        this.__barBackgroundColor.aboutToBeDeleted();
87        this.__index.aboutToBeDeleted();
88        this.__barOverlap.aboutToBeDeleted();
89        SubscriberManager.Get().delete(this.id__());
90        this.aboutToBeDeletedInternal();
91    }
92    get tabBarOptionsArray() {
93        return this.__tabBarOptionsArray.get();
94    }
95    set tabBarOptionsArray(i1) {
96        this.__tabBarOptionsArray.set(i1);
97    }
98    get tabBarPosition() {
99        return this.__tabBarPosition.get();
100    }
101    set tabBarPosition(h1) {
102        this.__tabBarPosition.set(h1);
103    }
104    get barBackgroundColor() {
105        return this.__barBackgroundColor.get();
106    }
107    set barBackgroundColor(g1) {
108        this.__barBackgroundColor.set(g1);
109    }
110    get index() {
111        return this.__index.get();
112    }
113    set index(f1) {
114        this.__index.set(f1);
115    }
116    get barOverlap() {
117        return this.__barOverlap.get();
118    }
119    set barOverlap(e1) {
120        this.__barOverlap.set(e1);
121    }
122    initialRender() {
123        this.observeComponentCreation2((c1, d1) => {
124            Tabs.create({
125                barPosition: this.tabBarPosition === TabBarPosition.LEFT ? BarPosition.Start : BarPosition.End,
126                index: this.index,
127                controller: this.controller
128            });
129            Tabs.barBackgroundColor(ObservedObject.GetRawObject(this.barBackgroundColor));
130            Tabs.divider(null);
131            Tabs.vertical(this.tabBarPosition === TabBarPosition.LEFT ? true : false);
132            Tabs.scrollable(false);
133            Tabs.barOverlap(this.barOverlap);
134            Tabs.barBackgroundBlurStyle(BlurStyle.COMPONENT_THICK);
135            Tabs.onChange(this.onChange);
136            Tabs.onTabBarClick(this.onTabBarClick);
137            Tabs.onContentWillChange(this.onContentWillChange);
138            Tabs.width((!this.tabContents && this.tabBarPosition === TabBarPosition.LEFT) ? DEFAULT_BAR_WIDTH : '100%');
139            Tabs.height((!this.tabContents && this.tabBarPosition === TabBarPosition.BOTTOM) ? DEFAULT_BAR_HEIGHT : '100%');
140        }, Tabs);
141        this.observeComponentCreation2((h, i) => {
142            ForEach.create();
143            const j = (l, m) => {
144                const n = l;
145                this.observeComponentCreation2((p, q) => {
146                    If.create();
147                    if (n) {
148                        this.ifElseBranchUpdateFunction(0, () => {
149                            this.observeComponentCreation2((u, v) => {
150                                TabContent.create(() => {
151                                    this.observeComponentCreation2((y, z) => {
152                                        If.create();
153                                        if (this.tabContents && this.tabContents[m]) {
154                                            this.ifElseBranchUpdateFunction(0, () => {
155                                                this.tabContents[m]?.bind(this)?.(this);
156                                            });
157                                        }
158                                        else {
159                                            this.ifElseBranchUpdateFunction(1, () => {
160                                            });
161                                        }
162                                    }, If);
163                                    If.pop();
164                                });
165                                TabContent.tabBar(BottomTabBarStyle.of(n.icon, n.text)
166                                    .labelStyle({ unselectedColor: n.unselectedColor, selectedColor: n.selectedColor })
167                                    .iconStyle({ unselectedColor: n.unselectedColor, selectedColor: n.selectedColor }));
168                                TabContent.width((!this.tabContents && this.tabBarPosition === TabBarPosition.LEFT) ? DEFAULT_BAR_WIDTH : '100%');
169                                TabContent.height((!this.tabContents && this.tabBarPosition === TabBarPosition.BOTTOM) ? DEFAULT_BAR_HEIGHT : '100%');
170                            }, TabContent);
171                            TabContent.pop();
172                        });
173                    }
174                    else {
175                        this.ifElseBranchUpdateFunction(1, () => {
176                        });
177                    }
178                }, If);
179                If.pop();
180            };
181            this.forEachUpdateFunction(h, this.tabBarOptionsArray, j, undefined, true, false);
182        }, ForEach);
183        ForEach.pop();
184        Tabs.pop();
185    }
186    rerender() {
187        this.updateDirtyElements();
188    }
189}
190export class TabBarOptions {
191    constructor(b, c, d, e) {
192        this.icon = b;
193        this.text = c;
194        this.unselectedColor = d;
195        this.selectedColor = e;
196    }
197}
198
199export var TabBarPosition;
200(function (a) {
201    a[a["LEFT"] = 0] = "LEFT";
202    a[a["BOTTOM"] = 1] = "BOTTOM";
203})(TabBarPosition || (TabBarPosition = {}));
204
205export default { AtomicServiceTabs, TabBarOptions, TabBarPosition};