• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023-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/// <reference path="../../state_mgmt/distRelease/stateMgmt.d.ts" />
16var NodeRenderType;
17(function (NodeRenderType) {
18    NodeRenderType[NodeRenderType["RENDER_TYPE_DISPLAY"] = 0] = "RENDER_TYPE_DISPLAY";
19    NodeRenderType[NodeRenderType["RENDER_TYPE_TEXTURE"] = 1] = "RENDER_TYPE_TEXTURE";
20})(NodeRenderType || (NodeRenderType = {}));
21class BaseNode extends ViewBuildNodeBase {
22    constructor(uiContext, options) {
23        super(false);
24        let baseNode = new __JSBaseNode__(options);
25        this.builderBaseNode_ = baseNode;
26        if (uiContext === undefined) {
27            throw Error('Node constructor error, param uiContext error');
28        }
29        else {
30            if (!(typeof uiContext === 'object') || !('instanceId_' in uiContext)) {
31                throw Error('Node constructor error, param uiContext is invalid');
32            }
33        }
34        this.instanceId_ = uiContext.instanceId_;
35    }
36    getInstanceId() {
37        return this.instanceId_;
38    }
39    updateInstance(uiContext) {
40        this.instanceId_ = uiContext.instanceId_;
41    }
42    create(builder, params, update, updateConfiguration, supportLazyBuild) {
43        return this.builderBaseNode_.create(builder.bind(this), params, update.bind(this), updateConfiguration.bind(this), supportLazyBuild);
44    }
45    finishUpdateFunc() {
46        return this.builderBaseNode_.finishUpdateFunc();
47    }
48    postTouchEvent(touchEvent) {
49        return this.builderBaseNode_.postTouchEvent(touchEvent);
50    }
51    disposeNode() {
52        return this.builderBaseNode_.disposeNode();
53    }
54    updateStart() {
55        return this.builderBaseNode_.updateStart();
56    }
57    updateEnd() {
58        return this.builderBaseNode_.updateEnd();
59    }
60    onRecycleWithBindObject() {
61        return this.builderBaseNode_.onRecycleWithBindObject();
62    }
63    onReuseWithBindObject(object) {
64        return this.builderBaseNode_.onReuseWithBindObject(object);
65    }
66}
67/*
68 * Copyright (c) 2023 Huawei Device Co., Ltd.
69 * Licensed under the Apache License, Version 2.0 (the "License");
70 * you may not use this file except in compliance with the License.
71 * You may obtain a copy of the License at
72 *
73 *     http://www.apache.org/licenses/LICENSE-2.0
74 *
75 * Unless required by applicable law or agreed to in writing, software
76 * distributed under the License is distributed on an "AS IS" BASIS,
77 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
78 * See the License for the specific language governing permissions and
79 * limitations under the License.
80 */
81/// <reference path="../../state_mgmt/src/lib/common/ifelse_native.d.ts" />
82/// <reference path="../../state_mgmt/src/lib/puv2_common/puv2_viewstack_processor.d.ts" />
83class BuilderNode {
84    constructor(uiContext, options) {
85        let jsBuilderNode = new JSBuilderNode(uiContext, options);
86        this._JSBuilderNode = jsBuilderNode;
87        let id = Symbol('BuilderRootFrameNode');
88        BuilderNodeFinalizationRegisterProxy.ElementIdToOwningBuilderNode_.set(id, jsBuilderNode);
89        BuilderNodeFinalizationRegisterProxy.register(this, { name: 'BuilderRootFrameNode', idOfNode: id });
90    }
91    update(params) {
92        this._JSBuilderNode.update(params);
93    }
94    build(builder, params, options) {
95        this._JSBuilderNode.build(builder, params, options);
96        this.nodePtr_ = this._JSBuilderNode.getNodePtr();
97    }
98    getNodePtr() {
99        return this._JSBuilderNode.getValidNodePtr();
100    }
101    getFrameNode() {
102        return this._JSBuilderNode.getFrameNode();
103    }
104    getFrameNodeWithoutCheck() {
105        return this._JSBuilderNode.getFrameNodeWithoutCheck();
106    }
107    postTouchEvent(touchEvent) {
108        __JSScopeUtil__.syncInstanceId(this._JSBuilderNode.getInstanceId());
109        let ret = this._JSBuilderNode.postTouchEvent(touchEvent);
110        __JSScopeUtil__.restoreInstanceId();
111        return ret;
112    }
113    dispose() {
114        this._JSBuilderNode.dispose();
115    }
116    reuse(param) {
117        this._JSBuilderNode.reuse(param);
118    }
119    recycle() {
120        this._JSBuilderNode.recycle();
121    }
122    updateConfiguration() {
123        this._JSBuilderNode.updateConfiguration();
124    }
125    onReuseWithBindObject(param) {
126        this._JSBuilderNode.onReuseWithBindObject(param);
127    }
128    onRecycleWithBindObject() {
129        this._JSBuilderNode.onRecycleWithBindObject();
130    }
131}
132class JSBuilderNode extends BaseNode {
133    constructor(uiContext, options) {
134        super(uiContext, options);
135        this.uiContext_ = uiContext;
136        this.updateFuncByElmtId = new UpdateFuncsByElmtId();
137        this._supportNestingBuilder = false;
138    }
139    reuse(param) {
140        this.updateStart();
141        this.childrenWeakrefMap_.forEach((weakRefChild) => {
142            const child = weakRefChild.deref();
143            if (child) {
144                if (child instanceof ViewPU) {
145                    child.aboutToReuseInternal(param);
146                }
147                else {
148                    // FIXME fix for mixed V2 - V3 Hierarchies
149                    throw new Error('aboutToReuseInternal: Recycle not implemented for ViewV2, yet');
150                }
151            } // if child
152        });
153        this.updateEnd();
154    }
155    recycle() {
156        this.childrenWeakrefMap_.forEach((weakRefChild) => {
157            const child = weakRefChild.deref();
158            if (child) {
159                if (child instanceof ViewPU) {
160                    child.aboutToRecycleInternal();
161                }
162                else {
163                    // FIXME fix for mixed V2 - V3 Hierarchies
164                    throw new Error('aboutToRecycleInternal: Recycle not yet implemented for ViewV2');
165                }
166            } // if child
167        });
168    }
169    onReuseWithBindObject(param) {
170        __JSScopeUtil__.syncInstanceId(this.instanceId_);
171        super.onReuseWithBindObject(param);
172        __JSScopeUtil__.restoreInstanceId();
173    }
174    onRecycleWithBindObject() {
175        __JSScopeUtil__.syncInstanceId(this.instanceId_);
176        super.onRecycleWithBindObject();
177        __JSScopeUtil__.restoreInstanceId();
178    }
179    getCardId() {
180        return -1;
181    }
182    isObject(param) {
183        const typeName = Object.prototype.toString.call(param);
184        const objectName = `[object Object]`;
185        if (typeName === objectName) {
186            return true;
187        }
188        else {
189            return false;
190        }
191    }
192    buildWithNestingBuilder(builder, supportLazyBuild) {
193        if (this._supportNestingBuilder && this.isObject(this.params_)) {
194            this._proxyObjectParam = new Proxy(this.params_, {
195                set(target, property, val) {
196                    throw Error(`@Builder : Invalid attempt to set(write to) parameter '${property.toString()}' error!`);
197                },
198                get: (target, property, receiver) => { return this.params_?.[property]; }
199            });
200            this.nodePtr_ = super.create(builder.builder?.bind(this.bindedViewOfBuilderNode ? this.bindedViewOfBuilderNode : this), this._proxyObjectParam, this.updateNodeFromNative, this.updateConfiguration, supportLazyBuild);
201        }
202        else {
203            this.nodePtr_ = super.create(builder.builder?.bind(this.bindedViewOfBuilderNode ? this.bindedViewOfBuilderNode : this), this.params_, this.updateNodeFromNative, this.updateConfiguration, supportLazyBuild);
204        }
205    }
206    build(builder, params, options) {
207        __JSScopeUtil__.syncInstanceId(this.instanceId_);
208        this._supportNestingBuilder = options?.nestingBuilderSupported ? options.nestingBuilderSupported : false;
209        const supportLazyBuild = options?.lazyBuildSupported ? options.lazyBuildSupported : false;
210        this.bindedViewOfBuilderNode = options?.bindedViewOfBuilderNode;
211        this.params_ = params;
212        this.updateFuncByElmtId.clear();
213        if (this.bindedViewOfBuilderNode) {
214            globalThis.__viewPuStack__?.push(this.bindedViewOfBuilderNode);
215        }
216        this.buildWithNestingBuilder(builder, supportLazyBuild);
217        if (this.bindedViewOfBuilderNode) {
218            globalThis.__viewPuStack__?.pop();
219        }
220        this._nativeRef = getUINativeModule().nativeUtils.createNativeStrongRef(this.nodePtr_);
221        if (this.frameNode_ === undefined || this.frameNode_ === null) {
222            this.frameNode_ = new BuilderRootFrameNode(this.uiContext_);
223        }
224        this.frameNode_.setNodePtr(this._nativeRef, this.nodePtr_);
225        this.frameNode_.setRenderNode(this._nativeRef);
226        this.frameNode_.setBaseNode(this);
227        __JSScopeUtil__.restoreInstanceId();
228    }
229    update(param) {
230        __JSScopeUtil__.syncInstanceId(this.instanceId_);
231        this.updateStart();
232        this.purgeDeletedElmtIds();
233        this.params_ = param;
234        Array.from(this.updateFuncByElmtId.keys()).sort((a, b) => {
235            return (a < b) ? -1 : (a > b) ? 1 : 0;
236        }).forEach(elmtId => this.UpdateElement(elmtId));
237        this.updateEnd();
238        __JSScopeUtil__.restoreInstanceId();
239    }
240    updateConfiguration() {
241        __JSScopeUtil__.syncInstanceId(this.instanceId_);
242        this.updateStart();
243        this.purgeDeletedElmtIds();
244        Array.from(this.updateFuncByElmtId.keys()).sort((a, b) => {
245            return (a < b) ? -1 : (a > b) ? 1 : 0;
246        }).forEach(elmtId => this.UpdateElement(elmtId));
247        for (const child of this.childrenWeakrefMap_.values()) {
248            const childView = child.deref();
249            if (childView) {
250                childView.forceCompleteRerender(true);
251            }
252        }
253        this.updateEnd();
254        __JSScopeUtil__.restoreInstanceId();
255    }
256    UpdateElement(elmtId) {
257        // do not process an Element that has been marked to be deleted
258        const obj = this.updateFuncByElmtId.get(elmtId);
259        const updateFunc = (typeof obj === 'object') ? obj.getUpdateFunc() : null;
260        if (typeof updateFunc === 'function') {
261            updateFunc(elmtId, /* isFirstRender */ false);
262            this.finishUpdateFunc();
263        }
264    }
265    purgeDeleteElmtId(rmElmtId) {
266        const result = this.updateFuncByElmtId.delete(rmElmtId);
267        if (result) {
268            UINodeRegisterProxy.ElementIdToOwningViewPU_.delete(rmElmtId);
269        }
270        return result;
271    }
272    getFrameNode() {
273        if (this.frameNode_ !== undefined &&
274            this.frameNode_ !== null &&
275            this.frameNode_.getNodePtr() !== null) {
276            return this.frameNode_;
277        }
278        return null;
279    }
280    getFrameNodeWithoutCheck() {
281        return this.frameNode_;
282    }
283    observeComponentCreation(func) {
284        let elmId = ViewStackProcessor.AllocateNewElmetIdForNextComponent();
285        UINodeRegisterProxy.ElementIdToOwningViewPU_.set(elmId, new WeakRef(this));
286        try {
287            func(elmId, true);
288        }
289        catch (error) {
290            // avoid the incompatible change that move set function before updateFunc.
291            UINodeRegisterProxy.ElementIdToOwningViewPU_.delete(elmId);
292            throw error;
293        }
294    }
295    observeComponentCreation2(compilerAssignedUpdateFunc, classObject) {
296        const _componentName = classObject && 'name' in classObject ? Reflect.get(classObject, 'name') : 'unspecified UINode';
297        const _popFunc = classObject && 'pop' in classObject ? classObject.pop : () => { };
298        const updateFunc = (elmtId, isFirstRender) => {
299            __JSScopeUtil__.syncInstanceId(this.instanceId_);
300            ViewBuildNodeBase.arkThemeScopeManager?.onComponentCreateEnter(_componentName, elmtId, isFirstRender, this);
301            ViewStackProcessor.StartGetAccessRecordingFor(elmtId);
302            // if V2 @Observed/@Track used anywhere in the app (there is no more fine grained criteria),
303            // enable V2 object deep observation
304            // FIXME: A @Component should only use PU or V2 state, but ReactNative dynamic viewer uses both.
305            if (ConfigureStateMgmt.instance.needsV2Observe()) {
306                // FIXME: like in V2 setting bindId_ in ObserveV2 does not work with 'stacked'
307                // update + initial render calls, like in if and ForEach case, convert to stack as well
308                ObserveV2.getObserve().startRecordDependencies(this, elmtId, true);
309            }
310            if (this._supportNestingBuilder) {
311                compilerAssignedUpdateFunc(elmtId, isFirstRender);
312            }
313            else {
314                compilerAssignedUpdateFunc(elmtId, isFirstRender, this.params_);
315            }
316            if (!isFirstRender) {
317                _popFunc();
318            }
319            if (ConfigureStateMgmt.instance.needsV2Observe()) {
320                ObserveV2.getObserve().stopRecordDependencies();
321            }
322            ViewStackProcessor.StopGetAccessRecording();
323            ViewBuildNodeBase.arkThemeScopeManager?.onComponentCreateExit(elmtId);
324            __JSScopeUtil__.restoreInstanceId();
325        };
326        const elmtId = ViewStackProcessor.AllocateNewElmetIdForNextComponent();
327        // needs to move set before updateFunc.
328        // make sure the key and object value exist since it will add node in attributeModifier during updateFunc.
329        this.updateFuncByElmtId.set(elmtId, { updateFunc: updateFunc, classObject: classObject });
330        UINodeRegisterProxy.ElementIdToOwningViewPU_.set(elmtId, new WeakRef(this));
331        try {
332            updateFunc(elmtId, /* is first render */ true);
333        }
334        catch (error) {
335            // avoid the incompatible change that move set function before updateFunc.
336            this.updateFuncByElmtId.delete(elmtId);
337            UINodeRegisterProxy.ElementIdToOwningViewPU_.delete(elmtId);
338            throw error;
339        }
340    }
341    /**
342     Partial updates for ForEach.
343     * @param elmtId ID of element.
344     * @param itemArray Array of items for use of itemGenFunc.
345     * @param itemGenFunc Item generation function to generate new elements. If index parameter is
346     *                    given set itemGenFuncUsesIndex to true.
347     * @param idGenFunc   ID generation function to generate unique ID for each element. If index parameter is
348     *                    given set idGenFuncUsesIndex to true.
349     * @param itemGenFuncUsesIndex itemGenFunc optional index parameter is given or not.
350     * @param idGenFuncUsesIndex idGenFunc optional index parameter is given or not.
351     */
352    forEachUpdateFunction(elmtId, itemArray, itemGenFunc, idGenFunc, itemGenFuncUsesIndex = false, idGenFuncUsesIndex = false) {
353        if (itemArray === null || itemArray === undefined) {
354            return;
355        }
356        if (itemGenFunc === null || itemGenFunc === undefined) {
357            return;
358        }
359        if (idGenFunc === undefined) {
360            idGenFuncUsesIndex = true;
361            // catch possible error caused by Stringify and re-throw an Error with a meaningful (!) error message
362            idGenFunc = (item, index) => {
363                try {
364                    return `${index}__${JSON.stringify(item)}`;
365                }
366                catch (e) {
367                    throw new Error(` ForEach id ${elmtId}: use of default id generator function not possible on provided data structure. Need to specify id generator function (ForEach 3rd parameter). Application Error!`);
368                }
369            };
370        }
371        let diffIndexArray = []; // New indexes compared to old one.
372        let newIdArray = [];
373        let idDuplicates = [];
374        const arr = itemArray; // just to trigger a 'get' onto the array
375        // ID gen is with index.
376        if (idGenFuncUsesIndex) {
377            // Create array of new ids.
378            arr.forEach((item, indx) => {
379                newIdArray.push(idGenFunc(item, indx));
380            });
381        }
382        else {
383            // Create array of new ids.
384            arr.forEach((item, index) => {
385                newIdArray.push(`${itemGenFuncUsesIndex ? index + '_' : ''}` + idGenFunc(item));
386            });
387        }
388        // removedChildElmtIds will be filled with the elmtIds of all children and their children will be deleted in response to foreach change
389        let removedChildElmtIds = [];
390        // Set new array on C++ side.
391        // C++ returns array of indexes of newly added array items.
392        // these are indexes in new child list.
393        ForEach.setIdArray(elmtId, newIdArray, diffIndexArray, idDuplicates, removedChildElmtIds);
394        // Item gen is with index.
395        diffIndexArray.forEach((indx) => {
396            ForEach.createNewChildStart(newIdArray[indx], this);
397            if (itemGenFuncUsesIndex) {
398                itemGenFunc(arr[indx], indx);
399            }
400            else {
401                itemGenFunc(arr[indx]);
402            }
403            ForEach.createNewChildFinish(newIdArray[indx], this);
404        });
405        // un-registers the removed child elementIDs using proxy
406        UINodeRegisterProxy.unregisterRemovedElmtsFromViewPUs(removedChildElmtIds);
407        // purging these elmtIds from state mgmt will make sure no more update function on any deleted child will be executed
408        this.purgeDeletedElmtIds();
409    }
410    getNodePtr() {
411        return this.nodePtr_;
412    }
413    getValidNodePtr() {
414        return this._nativeRef?.getNativeHandle();
415    }
416    dispose() {
417        this.frameNode_?.dispose();
418    }
419    disposeNode() {
420        super.disposeNode();
421        this.nodePtr_ = null;
422        this._nativeRef = null;
423        this.frameNode_?.resetNodePtr();
424    }
425    updateInstance(uiContext) {
426        this.uiContext_ = uiContext;
427        this.instanceId_ = uiContext.instanceId_;
428        if (this.frameNode_ !== undefined && this.frameNode_ !== null) {
429            this.frameNode_.updateInstance(uiContext);
430        }
431    }
432    updateNodePtr(nodePtr) {
433        if (nodePtr != this.nodePtr_) {
434            this.dispose();
435            this.nodePtr_ = nodePtr;
436            this._nativeRef = getUINativeModule().nativeUtils.createNativeStrongRef(this.nodePtr_);
437            this.frameNode_.setNodePtr(this._nativeRef, this.nodePtr_);
438        }
439    }
440    updateInstanceId(instanceId) {
441        this.instanceId_ = instanceId;
442    }
443    updateNodeFromNative(instanceId, nodePtr) {
444        this.updateNodePtr(nodePtr);
445        this.updateInstanceId(instanceId);
446    }
447    observeRecycleComponentCreation(name, recycleUpdateFunc) {
448        throw new Error('custom component in @Builder used by BuilderNode does not support @Reusable');
449    }
450    ifElseBranchUpdateFunctionDirtyRetaken() { }
451    forceCompleteRerender(deep) { }
452    forceRerenderNode(elmtId) { }
453}
454/*
455 * Copyright (c) 2024 Huawei Device Co., Ltd.
456 * Licensed under the Apache License, Version 2.0 (the "License");
457 * you may not use this file except in compliance with the License.
458 * You may obtain a copy of the License at
459 *
460 *     http://www.apache.org/licenses/LICENSE-2.0
461 *
462 * Unless required by applicable law or agreed to in writing, software
463 * distributed under the License is distributed on an "AS IS" BASIS,
464 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
465 * See the License for the specific language governing permissions and
466 * limitations under the License.
467 */
468class NodeAdapter {
469    constructor() {
470        this.nodeRefs_ = new Array();
471        this.count_ = 0;
472        this.nativeRef_ = getUINativeModule().nodeAdapter.createAdapter();
473        this.nativePtr_ = this.nativeRef_.getNativeHandle();
474        getUINativeModule().nodeAdapter.setCallbacks(this.nativePtr_, this, this.onAttachToNodePtr, this.onDetachFromNodePtr, this.onGetChildId !== undefined ? this.onGetChildId : undefined, this.onCreateChild !== undefined ? this.onCreateNewNodePtr : undefined, this.onDisposeChild !== undefined ? this.onDisposeNodePtr : undefined, this.onUpdateChild !== undefined ? this.onUpdateNodePtr : undefined);
475    }
476    dispose() {
477        let hostNode = this.attachedNodeRef_.deref();
478        if (hostNode !== undefined) {
479            NodeAdapter.detachNodeAdapter(hostNode);
480        }
481        this.nativeRef_.dispose();
482        this.nativePtr_ = null;
483    }
484    set totalNodeCount(count) {
485        if (count < 0) {
486            return;
487        }
488        getUINativeModule().nodeAdapter.setTotalNodeCount(this.nativePtr_, count);
489        this.count_ = count;
490    }
491    get totalNodeCount() {
492        return this.count_;
493    }
494    reloadAllItems() {
495        getUINativeModule().nodeAdapter.notifyItemReloaded(this.nativePtr_);
496    }
497    reloadItem(start, count) {
498        if (start < 0 || count < 0) {
499            return;
500        }
501        getUINativeModule().nodeAdapter.notifyItemChanged(this.nativePtr_, start, count);
502    }
503    removeItem(start, count) {
504        if (start < 0 || count < 0) {
505            return;
506        }
507        getUINativeModule().nodeAdapter.notifyItemRemoved(this.nativePtr_, start, count);
508    }
509    insertItem(start, count) {
510        if (start < 0 || count < 0) {
511            return;
512        }
513        getUINativeModule().nodeAdapter.notifyItemInserted(this.nativePtr_, start, count);
514    }
515    moveItem(from, to) {
516        if (from < 0 || to < 0) {
517            return;
518        }
519        getUINativeModule().nodeAdapter.notifyItemMoved(this.nativePtr_, from, to);
520    }
521    getAllAvailableItems() {
522        let result = new Array();
523        let nodes = getUINativeModule().nodeAdapter.getAllItems(this.nativePtr_);
524        if (nodes !== undefined) {
525            nodes.forEach(node => {
526                let nodeId = node.nodeId;
527                if (FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.has(nodeId)) {
528                    let frameNode = FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.get(nodeId).deref();
529                    result.push(frameNode);
530                }
531            });
532        }
533        return result;
534    }
535    onAttachToNodePtr(target) {
536        let nodeId = target.nodeId;
537        if (FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.has(nodeId)) {
538            let frameNode = FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.get(nodeId).deref();
539            if (frameNode === undefined) {
540                return;
541            }
542            frameNode.setAdapterRef(this);
543            this.attachedNodeRef_ = new WeakRef(frameNode);
544            if (this.onAttachToNode !== undefined) {
545                this.onAttachToNode(frameNode);
546            }
547        }
548    }
549    onDetachFromNodePtr() {
550        if (this === undefined) {
551            return;
552        }
553        if (this.onDetachFromNode !== undefined) {
554            this.onDetachFromNode();
555        }
556        let attachedNode = this.attachedNodeRef_.deref();
557        if (attachedNode !== undefined) {
558            attachedNode.setAdapterRef(undefined);
559        }
560        this.nodeRefs_.splice(0, this.nodeRefs_.length);
561    }
562    onCreateNewNodePtr(index) {
563        if (this.onCreateChild !== undefined) {
564            let node = this.onCreateChild(index);
565            if (!this.nodeRefs_.includes(node)) {
566                this.nodeRefs_.push(node);
567            }
568            return node.getNodePtr();
569        }
570        return null;
571    }
572    onDisposeNodePtr(id, node) {
573        let nodeId = node.nodeId;
574        if (FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.has(nodeId)) {
575            let frameNode = FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.get(nodeId).deref();
576            if (this.onDisposeChild !== undefined && frameNode !== undefined) {
577                this.onDisposeChild(id, frameNode);
578                let index = this.nodeRefs_.indexOf(frameNode);
579                if (index > -1) {
580                    this.nodeRefs_.splice(index, 1);
581                }
582            }
583        }
584    }
585    onUpdateNodePtr(id, node) {
586        let nodeId = node.nodeId;
587        if (FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.has(nodeId)) {
588            let frameNode = FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.get(nodeId).deref();
589            if (this.onUpdateChild !== undefined && frameNode !== undefined) {
590                this.onUpdateChild(id, frameNode);
591            }
592        }
593    }
594    static attachNodeAdapter(adapter, node) {
595        if (node === null || node === undefined) {
596            return false;
597        }
598        if (!node.isModifiable()) {
599            return false;
600        }
601        const hasAttributeProperty = Object.prototype.hasOwnProperty.call(node, 'attribute_');
602        if (hasAttributeProperty) {
603            let frameeNode = node;
604            if (frameeNode.attribute_.allowChildCount !== undefined) {
605                const allowCount = frameeNode.attribute_.allowChildCount();
606                if (allowCount <= 1) {
607                    return false;
608                }
609            }
610        }
611        return getUINativeModule().nodeAdapter.attachNodeAdapter(adapter.nativePtr_, node.getNodePtr());
612    }
613    static detachNodeAdapter(node) {
614        if (node === null || node === undefined) {
615            return;
616        }
617        getUINativeModule().nodeAdapter.detachNodeAdapter(node.getNodePtr());
618    }
619}
620/*
621 * Copyright (c) 2024 Huawei Device Co., Ltd.
622 * Licensed under the Apache License, Version 2.0 (the "License");
623 * you may not use this file except in compliance with the License.
624 * You may obtain a copy of the License at
625 *
626 *     http://www.apache.org/licenses/LICENSE-2.0
627 *
628 * Unless required by applicable law or agreed to in writing, software
629 * distributed under the License is distributed on an "AS IS" BASIS,
630 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
631 * See the License for the specific language governing permissions and
632 * limitations under the License.
633 */
634class BuilderNodeFinalizationRegisterProxy {
635    constructor() {
636        this.finalizationRegistry_ = new FinalizationRegistry((heldValue) => {
637            if (heldValue.name === 'BuilderRootFrameNode') {
638                const builderNode = BuilderNodeFinalizationRegisterProxy.ElementIdToOwningBuilderNode_.get(heldValue.idOfNode);
639                BuilderNodeFinalizationRegisterProxy.ElementIdToOwningBuilderNode_.delete(heldValue.idOfNode);
640                builderNode.dispose();
641            }
642        });
643    }
644    static register(target, heldValue) {
645        BuilderNodeFinalizationRegisterProxy.instance_.finalizationRegistry_.register(target, heldValue);
646    }
647}
648BuilderNodeFinalizationRegisterProxy.instance_ = new BuilderNodeFinalizationRegisterProxy();
649BuilderNodeFinalizationRegisterProxy.ElementIdToOwningBuilderNode_ = new Map();
650class FrameNodeFinalizationRegisterProxy {
651    constructor() {
652        this.finalizationRegistry_ = new FinalizationRegistry((heldValue) => {
653            FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.delete(heldValue);
654        });
655    }
656    static register(target, heldValue) {
657        FrameNodeFinalizationRegisterProxy.instance_.finalizationRegistry_.register(target, heldValue);
658    }
659}
660FrameNodeFinalizationRegisterProxy.instance_ = new FrameNodeFinalizationRegisterProxy();
661FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_ = new Map();
662FrameNodeFinalizationRegisterProxy.FrameNodeInMainTree_ = new Map();
663class NodeControllerRegisterProxy {
664}
665NodeControllerRegisterProxy.instance_ = new NodeControllerRegisterProxy();
666NodeControllerRegisterProxy.__NodeControllerMap__ = new Map();
667globalThis.__AddToNodeControllerMap__ = function __AddToNodeControllerMap__(containerId, nodeController) {
668    NodeControllerRegisterProxy.__NodeControllerMap__.set(containerId, nodeController);
669};
670globalThis.__RemoveFromNodeControllerMap__ = function __RemoveFromNodeControllerMap__(containerId) {
671    let nodeController = NodeControllerRegisterProxy.__NodeControllerMap__.get(containerId);
672    if (nodeController) {
673        nodeController._nodeContainerId.__rootNodeOfNodeController__ = undefined;
674        nodeController._nodeContainerId._value = -1;
675        NodeControllerRegisterProxy.__NodeControllerMap__.delete(containerId);
676    }
677};
678globalThis.__viewPuStack__ = new Array();
679globalThis.__CheckIsInBuilderNode__ = function __CheckIsInBuilderNode__(parent) {
680    if (globalThis.__viewPuStack__ === undefined || globalThis.__viewPuStack__.length === 0) {
681        return false;
682    }
683    const _BuilderNodeView = globalThis.__viewPuStack__?.pop();
684    if (_BuilderNodeView) {
685        globalThis.__viewPuStack__?.push(_BuilderNodeView);
686    }
687    return (_BuilderNodeView !== undefined && _BuilderNodeView === parent) ? true : false;
688};
689/*
690 * Copyright (c) 2023 Huawei Device Co., Ltd.
691 * Licensed under the Apache License, Version 2.0 (the "License");
692 * you may not use this file except in compliance with the License.
693 * You may obtain a copy of the License at
694 *
695 *     http://www.apache.org/licenses/LICENSE-2.0
696 *
697 * Unless required by applicable law or agreed to in writing, software
698 * distributed under the License is distributed on an "AS IS" BASIS,
699 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
700 * See the License for the specific language governing permissions and
701 * limitations under the License.
702 */
703class __InternalField__ {
704    constructor() {
705        this._value = -1;
706    }
707}
708class NodeController {
709    constructor() {
710        this._nodeContainerId = new __InternalField__();
711    }
712    __makeNode__(UIContext) {
713        this._nodeContainerId.__rootNodeOfNodeController__ = this.makeNode(UIContext);
714        return this._nodeContainerId.__rootNodeOfNodeController__;
715    }
716    rebuild() {
717        if (this._nodeContainerId !== undefined && this._nodeContainerId !== null && this._nodeContainerId._value >= 0) {
718            getUINativeModule().nodeContainer.rebuild(this._nodeContainerId._value);
719        }
720    }
721}
722/*
723 * Copyright (c) 2023-2024 Huawei Device Co., Ltd.
724 * Licensed under the Apache License, Version 2.0 (the "License");
725 * you may not use this file except in compliance with the License.
726 * You may obtain a copy of the License at
727 *
728 *     http://www.apache.org/licenses/LICENSE-2.0
729 *
730 * Unless required by applicable law or agreed to in writing, software
731 * distributed under the License is distributed on an "AS IS" BASIS,
732 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
733 * See the License for the specific language governing permissions and
734 * limitations under the License.
735 */
736var ExpandMode;
737(function (ExpandMode) {
738    ExpandMode[ExpandMode["NOT_EXPAND"] = 0] = "NOT_EXPAND";
739    ExpandMode[ExpandMode["EXPAND"] = 1] = "EXPAND";
740    ExpandMode[ExpandMode["LAZY_EXPAND"] = 2] = "LAZY_EXPAND";
741})(ExpandMode || (ExpandMode = {}));
742class FrameNode {
743    constructor(uiContext, type, options) {
744        if (uiContext === undefined) {
745            throw Error('Node constructor error, param uiContext error');
746        }
747        else {
748            if (!(typeof uiContext === "object") || !("instanceId_" in uiContext)) {
749                throw Error('Node constructor error, param uiContext is invalid');
750            }
751        }
752        this.instanceId_ = uiContext.instanceId_;
753        this.uiContext_ = uiContext;
754        this._nodeId = -1;
755        this._childList = new Map();
756        if (type === 'BuilderRootFrameNode') {
757            this.renderNode_ = new RenderNode(type);
758            this.renderNode_.setFrameNode(new WeakRef(this));
759            return;
760        }
761        if (type === 'ProxyFrameNode') {
762            return;
763        }
764        let result;
765        __JSScopeUtil__.syncInstanceId(this.instanceId_);
766        if (type === undefined || type === "CustomFrameNode") {
767            this.renderNode_ = new RenderNode('CustomFrameNode');
768            result = getUINativeModule().frameNode.createFrameNode(this);
769        }
770        else {
771            result = getUINativeModule().frameNode.createTypedFrameNode(this, type, options);
772        }
773        __JSScopeUtil__.restoreInstanceId();
774        this._nativeRef = result?.nativeStrongRef;
775        this._nodeId = result?.nodeId;
776        this.nodePtr_ = this._nativeRef?.getNativeHandle();
777        this.renderNode_?.setNodePtr(result?.nativeStrongRef);
778        this.renderNode_?.setFrameNode(new WeakRef(this));
779        if (result === undefined || this._nodeId === -1) {
780            return;
781        }
782        FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.set(this._nodeId, new WeakRef(this));
783        FrameNodeFinalizationRegisterProxy.register(this, this._nodeId);
784    }
785    invalidate() {
786        if (this.nodePtr_ === undefined || this.nodePtr_ === null) {
787            return;
788        }
789        getUINativeModule().frameNode.invalidate(this.nodePtr_);
790    }
791    getType() {
792        return 'CustomFrameNode';
793    }
794    setRenderNode(nativeRef) {
795        this.renderNode_?.setNodePtr(nativeRef);
796    }
797    getRenderNode() {
798        if (this.renderNode_ !== undefined &&
799            this.renderNode_ !== null &&
800            this.renderNode_.getNodePtr() !== null) {
801            return this.renderNode_;
802        }
803        return null;
804    }
805    setNodePtr(nativeRef, nodePtr) {
806        FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.delete(this._nodeId);
807        this._nativeRef = nativeRef;
808        this.nodePtr_ = nodePtr ? nodePtr : this._nativeRef?.getNativeHandle();
809        __JSScopeUtil__.syncInstanceId(this.instanceId_);
810        this._nodeId = getUINativeModule().frameNode.getIdByNodePtr(this.nodePtr_);
811        __JSScopeUtil__.restoreInstanceId();
812        if (this._nodeId === -1) {
813            return;
814        }
815        FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.set(this._nodeId, new WeakRef(this));
816        FrameNodeFinalizationRegisterProxy.register(this, this._nodeId);
817    }
818    resetNodePtr() {
819        FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.delete(this._nodeId);
820        this._nodeId = -1;
821        this._nativeRef = null;
822        this.nodePtr_ = null;
823        this.renderNode_?.resetNodePtr();
824    }
825    setBaseNode(baseNode) {
826        this.baseNode_ = baseNode;
827        this.renderNode_?.setBaseNode(baseNode);
828    }
829    setAdapterRef(adapter) {
830        this.nodeAdapterRef_ = adapter;
831    }
832    getNodePtr() {
833        return this.nodePtr_;
834    }
835    getValidNodePtr() {
836        const node = this.getNodePtr();
837        if (node === null) {
838            throw Error('The FrameNode has been disposed!');
839        } else {
840            return node;
841        }
842    }
843    dispose() {
844        this.renderNode_?.dispose();
845        FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.delete(this._nodeId);
846        this._nodeId = -1;
847        this._nativeRef = null;
848        this.nodePtr_ = null;
849    }
850    static disposeTreeRecursively(node) {
851        if (node === null) {
852            return;
853        }
854        let child = node.getFirstChildWithoutExpand();
855        FrameNode.disposeTreeRecursively(child);
856        let sibling = node.getNextSiblingWithoutExpand();
857        FrameNode.disposeTreeRecursively(sibling);
858        node.dispose();
859    }
860    disposeTree() {
861        let parent = this.getParent();
862        if (parent?.getNodeType() === "NodeContainer") {
863            getUINativeModule().nodeContainer.clean(parent?.getNodePtr());
864        }
865        else {
866            parent?.removeChild(this);
867        }
868        FrameNode.disposeTreeRecursively(this);
869    }
870    checkType() {
871        if (!this.isModifiable()) {
872            throw { message: 'The FrameNode is not modifiable.', code: 100021 };
873        }
874    }
875    isModifiable() {
876        return this._nativeRef !== undefined && this._nativeRef !== null;
877    }
878    convertToFrameNode(nodePtr, nodeId = -1) {
879        if (nodeId === -1) {
880            __JSScopeUtil__.syncInstanceId(this.instanceId_);
881            nodeId = getUINativeModule().frameNode.getIdByNodePtr(nodePtr);
882            __JSScopeUtil__.restoreInstanceId();
883        }
884        if (nodeId !== -1 && !getUINativeModule().frameNode.isModifiable(nodePtr)) {
885            __JSScopeUtil__.syncInstanceId(this.instanceId_);
886            let frameNode = new ProxyFrameNode(this.uiContext_);
887            let node = getUINativeModule().nativeUtils.createNativeWeakRef(nodePtr);
888            __JSScopeUtil__.restoreInstanceId();
889            frameNode.setNodePtr(node);
890            frameNode._nodeId = nodeId;
891            FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.set(frameNode._nodeId, new WeakRef(frameNode));
892            FrameNodeFinalizationRegisterProxy.register(frameNode, frameNode._nodeId);
893            return frameNode;
894        }
895        return null;
896    }
897    checkValid(node) {
898        return true;
899    }
900    appendChild(node) {
901        if (node === undefined || node === null) {
902            return;
903        }
904        if (node.getType() === 'ProxyFrameNode' || !this.checkValid(node)) {
905            throw { message: 'The FrameNode is not modifiable.', code: 100021 };
906        }
907        __JSScopeUtil__.syncInstanceId(this.instanceId_);
908        let flag = getUINativeModule().frameNode.appendChild(this.nodePtr_, node.nodePtr_);
909        __JSScopeUtil__.restoreInstanceId();
910        if (!flag) {
911            throw { message: 'The FrameNode is not modifiable.', code: 100021 };
912        }
913        this._childList.set(node._nodeId, node);
914    }
915    addComponentContent(content) {
916        if (content === undefined || content === null || content.getNodePtr() === null || content.getNodePtr() == undefined) {
917            return;
918        }
919        if (!this.checkValid() || !this.isModifiable()) {
920            throw { message: 'The FrameNode is not modifiable.', code: 100021 };
921        }
922        __JSScopeUtil__.syncInstanceId(this.instanceId_);
923        let flag = getUINativeModule().frameNode.appendChild(this.nodePtr_, content.getNodeWithoutProxy());
924        __JSScopeUtil__.restoreInstanceId();
925        if (!flag) {
926            throw { message: 'The FrameNode is not modifiable.', code: 100021 };
927        }
928        else {
929            content.setAttachedParent(new WeakRef(this));
930        }
931    }
932    removeComponentContent(content) {
933        if (content === undefined || content === null || content.getNodePtr() === null || content.getNodePtr() === undefined) {
934            return;
935        }
936        __JSScopeUtil__.syncInstanceId(this.instanceId_);
937        getUINativeModule().frameNode.removeChild(this.nodePtr_, content.getNodePtr());
938        content.setAttachedParent(undefined);
939        __JSScopeUtil__.restoreInstanceId();
940    }
941    insertChildAfter(child, sibling) {
942        if (child === undefined || child === null) {
943            return;
944        }
945        if (child.getType() === 'ProxyFrameNode' || !this.checkValid(child)) {
946            throw { message: 'The FrameNode is not modifiable.', code: 100021 };
947        }
948        let flag = true;
949        __JSScopeUtil__.syncInstanceId(this.instanceId_);
950        if (sibling === undefined || sibling === null) {
951            flag = getUINativeModule().frameNode.insertChildAfter(this.nodePtr_, child.nodePtr_, null);
952        }
953        else {
954            flag = getUINativeModule().frameNode.insertChildAfter(this.nodePtr_, child.nodePtr_, sibling.getNodePtr());
955        }
956        __JSScopeUtil__.restoreInstanceId();
957        if (!flag) {
958            throw { message: 'The FrameNode is not modifiable.', code: 100021 };
959        }
960        this._childList.set(child._nodeId, child);
961    }
962    removeChild(node) {
963        if (node === undefined || node === null) {
964            return;
965        }
966        __JSScopeUtil__.syncInstanceId(this.instanceId_);
967        getUINativeModule().frameNode.removeChild(this.nodePtr_, node.nodePtr_);
968        __JSScopeUtil__.restoreInstanceId();
969        this._childList.delete(node._nodeId);
970    }
971    clearChildren() {
972        __JSScopeUtil__.syncInstanceId(this.instanceId_);
973        getUINativeModule().frameNode.clearChildren(this.nodePtr_);
974        __JSScopeUtil__.restoreInstanceId();
975        this._childList.clear();
976    }
977    moveTo(targetParent, index) {
978        if (targetParent === undefined || targetParent === null) {
979            return;
980        }
981        if (index === undefined || index === null) {
982            index = -1;
983        }
984        const oldParent = this.getParent();
985        if (oldParent && !oldParent.isModifiable() || !targetParent.isModifiable() || !targetParent.checkValid(this)) {
986            throw { message: 'The FrameNode is not modifiable.', code: 100021 };
987        }
988        __JSScopeUtil__.syncInstanceId(this.instanceId_);
989        getUINativeModule().frameNode.moveTo(this.nodePtr_, targetParent.nodePtr_, index);
990        __JSScopeUtil__.restoreInstanceId();
991        if (oldParent) {
992            oldParent._childList.delete(this._nodeId);
993        }
994        targetParent._childList.set(this._nodeId, this);
995    }
996    getChild(index, expandMode) {
997        const result = getUINativeModule().frameNode.getChild(this.getNodePtr(), index, expandMode);
998        const nodeId = result?.nodeId;
999        if (nodeId === undefined || nodeId === -1) {
1000            return null;
1001        }
1002        if (FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.has(nodeId)) {
1003            let frameNode = FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.get(nodeId).deref();
1004            return frameNode === undefined ? null : frameNode;
1005        }
1006        return this.convertToFrameNode(result.nodePtr, result.nodeId);
1007    }
1008    getFirstChildIndexWithoutExpand() {
1009        return getUINativeModule().frameNode.getFirstChildIndexWithoutExpand(this.getNodePtr());
1010    }
1011    getLastChildIndexWithoutExpand() {
1012        return getUINativeModule().frameNode.getLastChildIndexWithoutExpand(this.getNodePtr());
1013    }
1014    getFirstChild(isExpanded) {
1015        const result = getUINativeModule().frameNode.getFirst(this.getNodePtr(), isExpanded);
1016        const nodeId = result?.nodeId;
1017        if (nodeId === undefined || nodeId === -1) {
1018            return null;
1019        }
1020        if (FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.has(nodeId)) {
1021            let frameNode = FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.get(nodeId).deref();
1022            return frameNode === undefined ? null : frameNode;
1023        }
1024        return this.convertToFrameNode(result.nodePtr, result.nodeId);
1025    }
1026    getFirstChildWithoutExpand() {
1027        const result = getUINativeModule().frameNode.getFirst(this.getNodePtr(), false);
1028        const nodeId = result?.nodeId;
1029        if (nodeId === undefined || nodeId === -1) {
1030            return null;
1031        }
1032        if (FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.has(nodeId)) {
1033            let frameNode = FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.get(nodeId).deref();
1034            return frameNode === undefined ? null : frameNode;
1035        }
1036        return this.convertToFrameNode(result.nodePtr, result.nodeId);
1037    }
1038    getNextSibling(isExpanded) {
1039        const result = getUINativeModule().frameNode.getNextSibling(this.getNodePtr(), isExpanded);
1040        const nodeId = result?.nodeId;
1041        if (nodeId === undefined || nodeId === -1) {
1042            return null;
1043        }
1044        if (FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.has(nodeId)) {
1045            let frameNode = FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.get(nodeId).deref();
1046            return frameNode === undefined ? null : frameNode;
1047        }
1048        return this.convertToFrameNode(result.nodePtr, result.nodeId);
1049    }
1050    getNextSiblingWithoutExpand() {
1051        const result = getUINativeModule().frameNode.getNextSibling(this.getNodePtr(), false);
1052        const nodeId = result?.nodeId;
1053        if (nodeId === undefined || nodeId === -1) {
1054            return null;
1055        }
1056        if (FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.has(nodeId)) {
1057            let frameNode = FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.get(nodeId).deref();
1058            return frameNode === undefined ? null : frameNode;
1059        }
1060        return this.convertToFrameNode(result.nodePtr, result.nodeId);
1061    }
1062    getPreviousSibling(isExpanded) {
1063        const result = getUINativeModule().frameNode.getPreviousSibling(this.getNodePtr(), isExpanded);
1064        const nodeId = result?.nodeId;
1065        if (nodeId === undefined || nodeId === -1) {
1066            return null;
1067        }
1068        if (FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.has(nodeId)) {
1069            let frameNode = FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.get(nodeId).deref();
1070            return frameNode === undefined ? null : frameNode;
1071        }
1072        return this.convertToFrameNode(result.nodePtr, result.nodeId);
1073    }
1074    getParent() {
1075        __JSScopeUtil__.syncInstanceId(this.instanceId_);
1076        const result = getUINativeModule().frameNode.getParent(this.getNodePtr());
1077        const nodeId = result?.nodeId;
1078        __JSScopeUtil__.restoreInstanceId();
1079        if (nodeId === undefined || nodeId === -1) {
1080            return null;
1081        }
1082        if (FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.has(nodeId)) {
1083            let frameNode = FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.get(nodeId).deref();
1084            return frameNode === undefined ? null : frameNode;
1085        }
1086        return this.convertToFrameNode(result.nodePtr, result.nodeId);
1087    }
1088    getChildrenCount(isExpanded) {
1089        __JSScopeUtil__.syncInstanceId(this.instanceId_);
1090        const childrenCount = getUINativeModule().frameNode.getChildrenCount(this.nodePtr_, isExpanded);
1091        __JSScopeUtil__.restoreInstanceId();
1092        return childrenCount;
1093    }
1094    getPositionToParent() {
1095        const position = getUINativeModule().frameNode.getPositionToParent(this.getNodePtr());
1096        return { x: position[0], y: position[1] };
1097    }
1098    getPositionToScreen() {
1099        const position = getUINativeModule().frameNode.getPositionToScreen(this.getNodePtr());
1100        return { x: position[0], y: position[1] };
1101    }
1102    getPositionToWindow() {
1103        const position = getUINativeModule().frameNode.getPositionToWindow(this.getNodePtr());
1104        return { x: position[0], y: position[1] };
1105    }
1106    getPositionToParentWithTransform() {
1107        const position = getUINativeModule().frameNode.getPositionToParentWithTransform(this.getNodePtr());
1108        return { x: position[0], y: position[1] };
1109    }
1110    getPositionToScreenWithTransform() {
1111        const position = getUINativeModule().frameNode.getPositionToScreenWithTransform(this.getNodePtr());
1112        return { x: position[0], y: position[1] };
1113    }
1114    getPositionToWindowWithTransform() {
1115        const position = getUINativeModule().frameNode.getPositionToWindowWithTransform(this.getNodePtr());
1116        return { x: position[0], y: position[1] };
1117    }
1118    getMeasuredSize() {
1119        const size = getUINativeModule().frameNode.getMeasuredSize(this.getValidNodePtr());
1120        return { width: size[0], height: size[1] };
1121    }
1122    getLayoutPosition() {
1123        const position = getUINativeModule().frameNode.getLayoutPosition(this.getValidNodePtr());
1124        return { x: position[0], y: position[1] };
1125    }
1126    getUserConfigBorderWidth() {
1127        const borderWidth = getUINativeModule().frameNode.getConfigBorderWidth(this.getNodePtr());
1128        return {
1129            top: new LengthMetrics(borderWidth[0], borderWidth[1]),
1130            right: new LengthMetrics(borderWidth[2], borderWidth[3]),
1131            bottom: new LengthMetrics(borderWidth[4], borderWidth[5]),
1132            left: new LengthMetrics(borderWidth[6], borderWidth[7])
1133        };
1134    }
1135    getUserConfigPadding() {
1136        const borderWidth = getUINativeModule().frameNode.getConfigPadding(this.getNodePtr());
1137        return {
1138            top: new LengthMetrics(borderWidth[0], borderWidth[1]),
1139            right: new LengthMetrics(borderWidth[2], borderWidth[3]),
1140            bottom: new LengthMetrics(borderWidth[4], borderWidth[5]),
1141            left: new LengthMetrics(borderWidth[6], borderWidth[7])
1142        };
1143    }
1144    getUserConfigMargin() {
1145        const margin = getUINativeModule().frameNode.getConfigMargin(this.getNodePtr());
1146        return {
1147            top: new LengthMetrics(margin[0], margin[1]),
1148            right: new LengthMetrics(margin[2], margin[3]),
1149            bottom: new LengthMetrics(margin[4], margin[5]),
1150            left: new LengthMetrics(margin[6], margin[7])
1151        };
1152    }
1153    getUserConfigSize() {
1154        const size = getUINativeModule().frameNode.getConfigSize(this.getNodePtr());
1155        return {
1156            width: new LengthMetrics(size[0], size[1]),
1157            height: new LengthMetrics(size[2], size[3])
1158        };
1159    }
1160    getId() {
1161        return getUINativeModule().frameNode.getId(this.getNodePtr());
1162    }
1163    getUniqueId() {
1164        return getUINativeModule().frameNode.getIdByNodePtr(this.getNodePtr());
1165    }
1166    getNodeType() {
1167        return getUINativeModule().frameNode.getNodeType(this.getNodePtr());
1168    }
1169    getOpacity() {
1170        return getUINativeModule().frameNode.getOpacity(this.getNodePtr());
1171    }
1172    isVisible() {
1173        return getUINativeModule().frameNode.isVisible(this.getNodePtr());
1174    }
1175    isClipToFrame() {
1176        return getUINativeModule().frameNode.isClipToFrame(this.getNodePtr());
1177    }
1178    isAttached() {
1179        return getUINativeModule().frameNode.isAttached(this.getNodePtr());
1180    }
1181    getInspectorInfo() {
1182        __JSScopeUtil__.syncInstanceId(this.instanceId_);
1183        const inspectorInfoStr = getUINativeModule().frameNode.getInspectorInfo(this.getNodePtr());
1184        __JSScopeUtil__.restoreInstanceId();
1185        const inspectorInfo = JSON.parse(inspectorInfoStr);
1186        return inspectorInfo;
1187    }
1188    getCustomProperty(key) {
1189        if (key === undefined) {
1190            return undefined;
1191        }
1192        let value = __getCustomProperty__(this._nodeId, key);
1193        if (value === undefined) {
1194            const valueStr = getUINativeModule().frameNode.getCustomPropertyCapiByKey(this.getNodePtr(), key);
1195            value = valueStr === undefined ? undefined : valueStr;
1196        }
1197        return value;
1198    }
1199    setMeasuredSize(size) {
1200        getUINativeModule().frameNode.setMeasuredSize(this.getNodePtr(), Math.max(size.width, 0), Math.max(size.height, 0));
1201    }
1202    setLayoutPosition(position) {
1203        getUINativeModule().frameNode.setLayoutPosition(this.getNodePtr(), position.x, position.y);
1204    }
1205    measure(constraint) {
1206        const minSize = constraint.minSize;
1207        const maxSize = constraint.maxSize;
1208        const percentReference = constraint.percentReference;
1209        __JSScopeUtil__.syncInstanceId(this.instanceId_);
1210        getUINativeModule().frameNode.measureNode(this.getNodePtr(), minSize.width, minSize.height, maxSize.width, maxSize.height, percentReference.width, percentReference.height);
1211        __JSScopeUtil__.restoreInstanceId();
1212    }
1213    layout(position) {
1214        __JSScopeUtil__.syncInstanceId(this.instanceId_);
1215        getUINativeModule().frameNode.layoutNode(this.getNodePtr(), position.x, position.y);
1216        __JSScopeUtil__.restoreInstanceId();
1217    }
1218    setNeedsLayout() {
1219        getUINativeModule().frameNode.setNeedsLayout(this.getNodePtr());
1220    }
1221    setCrossLanguageOptions(options) {
1222        if (!this.isModifiable()) {
1223            throw { message: 'The FrameNode cannot be set whether to support cross-language common attribute setting.', code: 100022 };
1224        }
1225        __JSScopeUtil__.syncInstanceId(this.instanceId_);
1226        const result = getUINativeModule().frameNode.setCrossLanguageOptions(this.getNodePtr(), options.attributeSetting ?? false);
1227        __JSScopeUtil__.restoreInstanceId();
1228        if (result !== 0) {
1229            throw { message: 'The FrameNode cannot be set whether to support cross-language common attribute setting.', code: 100022 };
1230        }
1231    }
1232    getCrossLanguageOptions() {
1233        __JSScopeUtil__.syncInstanceId(this.instanceId_);
1234        const attributeSetting = getUINativeModule().frameNode.getCrossLanguageOptions(this.getNodePtr());
1235        __JSScopeUtil__.restoreInstanceId();
1236        return { attributeSetting: attributeSetting ?? false };
1237    }
1238    checkIfCanCrossLanguageAttributeSetting() {
1239        return this.isModifiable() || getUINativeModule().frameNode.checkIfCanCrossLanguageAttributeSetting(this.getNodePtr());
1240    }
1241    get commonAttribute() {
1242        if (this._commonAttribute === undefined) {
1243            this._commonAttribute = new ArkComponent(this.nodePtr_, ModifierType.FRAME_NODE);
1244        }
1245        this._commonAttribute.setNodePtr(this.nodePtr_);
1246        this._commonAttribute.setInstanceId((this.uiContext_ === undefined || this.uiContext_ === null) ? -1 : this.uiContext_.instanceId_);
1247        return this._commonAttribute;
1248    }
1249    get commonEvent() {
1250        let node = this.getNodePtr();
1251        if (this._commonEvent === undefined) {
1252            this._commonEvent = new UICommonEvent(node);
1253        }
1254        this._commonEvent.setNodePtr(node);
1255        this._commonEvent.setInstanceId((this.uiContext_ === undefined || this.uiContext_ === null) ? -1 : this.uiContext_.instanceId_);
1256        return this._commonEvent;
1257    }
1258    get gestureEvent() {
1259        if (this._gestureEvent === undefined) {
1260            this._gestureEvent = new UIGestureEvent();
1261            this._gestureEvent.setNodePtr(this.nodePtr_);
1262            let weakPtr = getUINativeModule().nativeUtils.createNativeWeakRef(this.nodePtr_);
1263            this._gestureEvent.setWeakNodePtr(weakPtr);
1264            __JSScopeUtil__.syncInstanceId(this.instanceId_);
1265            this._gestureEvent.registerFrameNodeDeletedCallback(this.nodePtr_);
1266            __JSScopeUtil__.restoreInstanceId();
1267        }
1268        return this._gestureEvent;
1269    }
1270    updateInstance(uiContext) {
1271        this.uiContext_ = uiContext;
1272        this.instanceId_ = uiContext.instanceId_;
1273    }
1274    triggerOnReuse() {
1275        getUINativeModule().frameNode.triggerOnReuse(this.getNodePtr());
1276    }
1277    triggerOnRecycle() {
1278        getUINativeModule().frameNode.triggerOnRecycle(this.getNodePtr());
1279    }
1280    reuse() {
1281        this.triggerOnReuse();
1282    }
1283    recycle() {
1284        this.triggerOnRecycle();
1285    }
1286}
1287class ImmutableFrameNode extends FrameNode {
1288    isModifiable() {
1289        return false;
1290    }
1291    invalidate() {
1292        return;
1293    }
1294    appendChild(node) {
1295        throw { message: 'The FrameNode is not modifiable.', code: 100021 };
1296    }
1297    insertChildAfter(child, sibling) {
1298        throw { message: 'The FrameNode is not modifiable.', code: 100021 };
1299    }
1300    removeChild(node) {
1301        throw { message: 'The FrameNode is not modifiable.', code: 100021 };
1302    }
1303    clearChildren() {
1304        throw { message: 'The FrameNode is not modifiable.', code: 100021 };
1305    }
1306    get commonAttribute() {
1307        if (this._commonAttribute === undefined) {
1308            this._commonAttribute = new ArkComponent(undefined, ModifierType.FRAME_NODE);
1309        }
1310        this._commonAttribute.setNodePtr(undefined);
1311        return this._commonAttribute;
1312    }
1313}
1314class BuilderRootFrameNode extends ImmutableFrameNode {
1315    constructor(uiContext, type = 'BuilderRootFrameNode') {
1316        super(uiContext, type);
1317    }
1318    getType() {
1319        return 'BuilderRootFrameNode';
1320    }
1321}
1322class ProxyFrameNode extends ImmutableFrameNode {
1323    constructor(uiContext, type = 'ProxyFrameNode') {
1324        super(uiContext, type);
1325    }
1326    setNodePtr(nativeRef) {
1327        this._nativeRef = nativeRef;
1328        this.nodePtr_ = this._nativeRef.getNativeHandle();
1329    }
1330    getType() {
1331        return 'ProxyFrameNode';
1332    }
1333    getRenderNode() {
1334        return null;
1335    }
1336    getNodePtr() {
1337        if (this._nativeRef === undefined || this._nativeRef === null || this._nativeRef.invalid()) {
1338            return null;
1339        }
1340        return this.nodePtr_;
1341    }
1342    dispose() {
1343        this.renderNode_?.dispose();
1344        FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.delete(this._nodeId);
1345        this._nodeId = -1;
1346        this._nativeRef = undefined;
1347        this.nodePtr_ = undefined;
1348    }
1349    moveTo(targetParent, index) {
1350        throw { message: 'The FrameNode is not modifiable.', code: 100021 };
1351    }
1352}
1353class FrameNodeUtils {
1354    static searchNodeInRegisterProxy(nodePtr) {
1355        let nodeId = getUINativeModule().frameNode.getIdByNodePtr(nodePtr);
1356        if (nodeId === -1) {
1357            return null;
1358        }
1359        if (FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.has(nodeId)) {
1360            let frameNode = FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.get(nodeId).deref();
1361            return frameNode === undefined ? null : frameNode;
1362        }
1363        return null;
1364    }
1365    static createFrameNode(uiContext, nodePtr) {
1366        let nodeId = getUINativeModule().frameNode.getIdByNodePtr(nodePtr);
1367        if (nodeId !== -1 && !getUINativeModule().frameNode.isModifiable(nodePtr)) {
1368            let frameNode = new ProxyFrameNode(uiContext);
1369            let node = getUINativeModule().nativeUtils.createNativeWeakRef(nodePtr);
1370            frameNode.setNodePtr(node);
1371            frameNode._nodeId = nodeId;
1372            FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.set(nodeId, new WeakRef(frameNode));
1373            FrameNodeFinalizationRegisterProxy.register(frameNode, nodeId);
1374            return frameNode;
1375        }
1376        return null;
1377    }
1378}
1379class TypedFrameNode extends FrameNode {
1380    constructor(uiContext, type, attrCreator, options) {
1381        super(uiContext, type, options);
1382        this.attrCreator_ = attrCreator;
1383    }
1384    initialize(...args) {
1385        return this.attribute.initialize(args);
1386    }
1387    get attribute() {
1388        if (this.attribute_ === undefined) {
1389            this.attribute_ = this.attrCreator_(this.nodePtr_, ModifierType.FRAME_NODE);
1390        }
1391        this.attribute_.setNodePtr(this.nodePtr_);
1392        this.attribute_.setInstanceId((this.uiContext_ === undefined || this.uiContext_ === null) ? -1 : this.uiContext_.instanceId_);
1393        return this.attribute_;
1394    }
1395    checkValid(node) {
1396        if (this.attribute_ === undefined) {
1397            this.attribute_ = this.attrCreator_(this.nodePtr_, ModifierType.FRAME_NODE);
1398        }
1399        if (this.attribute_.allowChildCount !== undefined) {
1400            const allowCount = this.attribute_.allowChildCount();
1401            if (this.getChildrenCount() >= allowCount) {
1402                return false;
1403            }
1404        }
1405        if (this.attribute_.allowChildTypes !== undefined && node !== undefined) {
1406            const childType = node.getNodeType();
1407            const allowTypes = this.attribute_.allowChildTypes();
1408            let isValid = false;
1409            allowTypes.forEach((nodeType) => {
1410                if (nodeType === childType) {
1411                    isValid = true;
1412                }
1413            });
1414            return isValid;
1415        }
1416        return true;
1417    }
1418}
1419const __creatorMap__ = new Map([
1420    ['Text', (context) => {
1421            return new TypedFrameNode(context, 'Text', (node, type) => {
1422                return new ArkTextComponent(node, type);
1423            });
1424        }],
1425    ['Column', (context) => {
1426            return new TypedFrameNode(context, 'Column', (node, type) => {
1427                return new ArkColumnComponent(node, type);
1428            });
1429        }],
1430    ['Row', (context) => {
1431            return new TypedFrameNode(context, 'Row', (node, type) => {
1432                return new ArkRowComponent(node, type);
1433            });
1434        }],
1435    ['Stack', (context) => {
1436            return new TypedFrameNode(context, 'Stack', (node, type) => {
1437                return new ArkStackComponent(node, type);
1438            });
1439        }],
1440    ['GridRow', (context) => {
1441            let node = new TypedFrameNode(context, 'GridRow', (node, type) => {
1442                return new ArkGridRowComponent(node, type);
1443            });
1444            node.initialize();
1445            return node;
1446        }],
1447    ['TextInput', (context) => {
1448            return new TypedFrameNode(context, 'TextInput', (node, type) => {
1449                return new ArkTextInputComponent(node, type);
1450            });
1451        }],
1452    ['GridCol', (context) => {
1453            let node = new TypedFrameNode(context, 'GridCol', (node, type) => {
1454                return new ArkGridColComponent(node, type);
1455            });
1456            node.initialize();
1457            return node;
1458        }],
1459    ['Blank', (context) => {
1460            return new TypedFrameNode(context, 'Blank', (node, type) => {
1461                return new ArkBlankComponent(node, type);
1462            });
1463        }],
1464    ['Image', (context) => {
1465            return new TypedFrameNode(context, 'Image', (node, type) => {
1466                return new ArkImageComponent(node, type);
1467            });
1468        }],
1469    ['Flex', (context) => {
1470            return new TypedFrameNode(context, 'Flex', (node, type) => {
1471                return new ArkFlexComponent(node, type);
1472            });
1473        }],
1474    ['Swiper', (context) => {
1475            return new TypedFrameNode(context, 'Swiper', (node, type) => {
1476                return new ArkSwiperComponent(node, type);
1477            });
1478        }],
1479    ['Progress', (context) => {
1480            return new TypedFrameNode(context, 'Progress', (node, type) => {
1481                return new ArkProgressComponent(node, type);
1482            });
1483        }],
1484    ['Scroll', (context) => {
1485            return new TypedFrameNode(context, 'Scroll', (node, type) => {
1486                return new ArkScrollComponent(node, type);
1487            });
1488        }],
1489    ['RelativeContainer', (context) => {
1490            return new TypedFrameNode(context, 'RelativeContainer', (node, type) => {
1491                return new ArkRelativeContainerComponent(node, type);
1492            });
1493        }],
1494    ['List', (context) => {
1495            return new TypedFrameNode(context, 'List', (node, type) => {
1496                return new ArkListComponent(node, type);
1497            });
1498        }],
1499    ['ListItem', (context) => {
1500            return new TypedFrameNode(context, 'ListItem', (node, type) => {
1501                return new ArkListItemComponent(node, type);
1502            });
1503        }],
1504    ['Divider', (context) => {
1505            return new TypedFrameNode(context, 'Divider', (node, type) => {
1506                return new ArkDividerComponent(node, type);
1507            });
1508        }],
1509    ['LoadingProgress', (context) => {
1510            return new TypedFrameNode(context, 'LoadingProgress', (node, type) => {
1511                return new ArkLoadingProgressComponent(node, type);
1512            });
1513        }],
1514    ['Search', (context) => {
1515            return new TypedFrameNode(context, 'Search', (node, type) => {
1516                return new ArkSearchComponent(node, type);
1517            });
1518        }],
1519    ['Button', (context) => {
1520            return new TypedFrameNode(context, 'Button', (node, type) => {
1521                return new ArkButtonComponent(node, type);
1522            });
1523        }],
1524    ['XComponent', (context, options) => {
1525            return new TypedFrameNode(context, 'XComponent', (node, type) => {
1526                return new ArkXComponentComponent(node, type);
1527            }, options);
1528        }],
1529    ['ListItemGroup', (context) => {
1530            return new TypedFrameNode(context, 'ListItemGroup', (node, type) => {
1531                return new ArkListItemGroupComponent(node, type);
1532            });
1533        }],
1534    ['WaterFlow', (context) => {
1535            return new TypedFrameNode(context, 'WaterFlow', (node, type) => {
1536                return new ArkWaterFlowComponent(node, type);
1537            });
1538        }],
1539    ['SymbolGlyph', (context) => {
1540            return new TypedFrameNode(context, 'SymbolGlyph', (node, type) => {
1541                return new ArkSymbolGlyphComponent(node, type);
1542            });
1543        }],
1544    ['FlowItem', (context) => {
1545            return new TypedFrameNode(context, 'FlowItem', (node, type) => {
1546                return new ArkFlowItemComponent(node, type);
1547            });
1548        }],
1549    ['QRCode', (context) => {
1550            return new TypedFrameNode(context, 'QRCode', (node, type) => {
1551                return new ArkQRCodeComponent(node, type);
1552            });
1553        }],
1554    ['Badge', (context) => {
1555            return new TypedFrameNode(context, 'Badge', (node, type) => {
1556                return new ArkBadgeComponent(node, type);
1557            });
1558        }],
1559    ['Grid', (context) => {
1560            return new TypedFrameNode(context, 'Grid', (node, type) => {
1561                return new ArkGridComponent(node, type);
1562            });
1563        }],
1564    ['GridItem', (context) => {
1565            return new TypedFrameNode(context, 'GridItem', (node, type) => {
1566                return new ArkGridItemComponent(node, type);
1567            });
1568        }],
1569    ['TextClock', (context) => {
1570            return new TypedFrameNode(context, 'TextClock', (node, type) => {
1571                return new ArkTextClockComponent(node, type);
1572            });
1573        }],
1574    ['TextTimer', (context) => {
1575            return new TypedFrameNode(context, 'TextTimer', (node, type) => {
1576                return new ArkTextTimerComponent(node, type);
1577            });
1578        }],
1579    ['Marquee', (context) => {
1580            return new TypedFrameNode(context, 'Marquee', (node, type) => {
1581                return new ArkMarqueeComponent(node, type);
1582            });
1583        }],
1584    ['TextArea', (context) => {
1585            return new TypedFrameNode(context, 'TextArea', (node, type) => {
1586                return new ArkTextAreaComponent(node, type);
1587            });
1588        }],
1589    ['Checkbox', (context) => {
1590            return new TypedFrameNode(context, 'Checkbox', (node, type) => {
1591                return new ArkCheckboxComponent(node, type);
1592            });
1593        }],
1594    ['CheckboxGroup', (context) => {
1595            return new TypedFrameNode(context, 'CheckboxGroup', (node, type) => {
1596                return new ArkCheckboxGroupComponent(node, type);
1597            });
1598        }],
1599    ['Radio', (context) => {
1600            return new TypedFrameNode(context, 'Radio', (node, type) => {
1601                return new ArkRadioComponent(node, type);
1602            });
1603        }],
1604    ['Rating', (context) => {
1605            return new TypedFrameNode(context, 'Rating', (node, type) => {
1606                return new ArkRatingComponent(node, type);
1607            });
1608        }],
1609    ['Slider', (context) => {
1610            return new TypedFrameNode(context, 'Slider', (node, type) => {
1611                return new ArkSliderComponent(node, type);
1612            });
1613        }],
1614    ['Select', (context) => {
1615            return new TypedFrameNode(context, 'Select', (node, type) => {
1616                return new ArkSelectComponent(node, type);
1617            });
1618        }],
1619    ['Toggle', (context, options) => {
1620            return new TypedFrameNode(context, 'Toggle', (node, type) => {
1621                return new ArkToggleComponent(node, type);
1622            }, options);
1623        }],
1624]);
1625const __attributeMap__ = new Map([
1626    ['Scroll', (node) => {
1627            if (node._componentAttribute) {
1628                return node._componentAttribute;
1629            }
1630            if (!node.getNodePtr()) {
1631                return undefined;
1632            }
1633            node._componentAttribute = new ArkScrollComponent(node.getNodePtr(), ModifierType.FRAME_NODE);
1634            return node._componentAttribute;
1635        }],
1636]);
1637class typeNode {
1638    static createNode(context, type, options) {
1639        let creator = __creatorMap__.get(type);
1640        if (creator === undefined) {
1641            return undefined;
1642        }
1643        return creator(context, options);
1644    }
1645    static getAttribute(node, nodeType) {
1646        if (node === undefined || node === null || node.getNodeType() !== nodeType) {
1647            return undefined;
1648        }
1649        if (!node.checkIfCanCrossLanguageAttributeSetting()) {
1650            return undefined;
1651        }
1652        let attribute = __attributeMap__.get(nodeType);
1653        if (attribute === undefined || attribute === null) {
1654            return undefined;
1655        }
1656        return attribute(node);
1657    }
1658    static bindController(node, controller, nodeType) {
1659        if (node === undefined || node === null || controller === undefined || controller === null ||
1660            node.getNodeType() !== nodeType || node.getNodePtr() === null || node.getNodePtr() === undefined) {
1661            throw { message: 'Parameter error. Possible causes: 1. The type of the node is error; 2. The node is null or undefined.', code: 401 };
1662        }
1663        if (!node.checkIfCanCrossLanguageAttributeSetting()) {
1664            throw { message: 'The FrameNode is not modifiable.', code: 100021 };
1665        }
1666        getUINativeModule().scroll.setScrollInitialize(node.getNodePtr(), controller);
1667    }
1668}
1669/*
1670 * Copyright (c) 2023 Huawei Device Co., Ltd.
1671 * Licensed under the Apache License, Version 2.0 (the "License");
1672 * you may not use this file except in compliance with the License.
1673 * You may obtain a copy of the License at
1674 *
1675 *     http://www.apache.org/licenses/LICENSE-2.0
1676 *
1677 * Unless required by applicable law or agreed to in writing, software
1678 * distributed under the License is distributed on an "AS IS" BASIS,
1679 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1680 * See the License for the specific language governing permissions and
1681 * limitations under the License.
1682 */
1683var BorderStyle;
1684(function (BorderStyle) {
1685    BorderStyle[BorderStyle["SOLID"] = 0] = "SOLID";
1686    BorderStyle[BorderStyle["DASHED"] = 1] = "DASHED";
1687    BorderStyle[BorderStyle["DOTTED"] = 2] = "DOTTED";
1688    BorderStyle[BorderStyle["NONE"] = 3] = "NONE";
1689})(BorderStyle || (BorderStyle = {}));
1690var LengthUnit;
1691(function (LengthUnit) {
1692    LengthUnit[LengthUnit["PX"] = 0] = "PX";
1693    LengthUnit[LengthUnit["VP"] = 1] = "VP";
1694    LengthUnit[LengthUnit["FP"] = 2] = "FP";
1695    LengthUnit[LengthUnit["PERCENT"] = 3] = "PERCENT";
1696    LengthUnit[LengthUnit["LPX"] = 4] = "LPX";
1697})(LengthUnit || (LengthUnit = {}));
1698var LengthMetricsUnit;
1699(function (LengthMetricsUnit) {
1700    LengthMetricsUnit[LengthMetricsUnit["DEFAULT"] = 0] = "DEFAULT";
1701    LengthMetricsUnit[LengthMetricsUnit["PX"] = 1] = "PX";
1702})(LengthMetricsUnit || (LengthMetricsUnit = {}));
1703class LengthMetrics {
1704    constructor(value, unit) {
1705        if (unit in LengthUnit) {
1706            this.unit = unit;
1707            this.value = value;
1708        }
1709        else {
1710            this.unit = LengthUnit.VP;
1711            this.value = unit === undefined ? value : 0;
1712        }
1713    }
1714    static px(value) {
1715        return new LengthMetrics(value, LengthUnit.PX);
1716    }
1717    static vp(value) {
1718        return new LengthMetrics(value, LengthUnit.VP);
1719    }
1720    static fp(value) {
1721        return new LengthMetrics(value, LengthUnit.FP);
1722    }
1723    static percent(value) {
1724        return new LengthMetrics(value, LengthUnit.PERCENT);
1725    }
1726    static lpx(value) {
1727        return new LengthMetrics(value, LengthUnit.LPX);
1728    }
1729    static resource(res) {
1730        let length = getUINativeModule().nativeUtils.resoureToLengthMetrics(res);
1731        return new LengthMetrics(length[0], length[1]);
1732    }
1733}
1734const MAX_CHANNEL_VALUE = 0xFF;
1735const MAX_ALPHA_VALUE = 1;
1736const ERROR_CODE_RESOURCE_GET_FAILED = 180003;
1737const ERROR_CODE_COLOR_PARAMETER_INCORRECT = 401;
1738class ColorMetrics {
1739    constructor(red, green, blue, alpha = MAX_CHANNEL_VALUE) {
1740        this.red_ = ColorMetrics.clamp(red);
1741        this.green_ = ColorMetrics.clamp(green);
1742        this.blue_ = ColorMetrics.clamp(blue);
1743        this.alpha_ = ColorMetrics.clamp(alpha);
1744    }
1745    static clamp(value) {
1746        return Math.min(Math.max(value, 0), MAX_CHANNEL_VALUE);
1747    }
1748    toNumeric() {
1749        return (this.alpha_ << 24) + (this.red_ << 16) + (this.green_ << 8) + this.blue_;
1750    }
1751    static numeric(value) {
1752        const red = (value >> 16) & 0x000000FF;
1753        const green = (value >> 8) & 0x000000FF;
1754        const blue = value & 0x000000FF;
1755        const alpha = (value >> 24) & 0x000000FF;
1756        if (alpha === 0) {
1757            return new ColorMetrics(red, green, blue);
1758        }
1759        return new ColorMetrics(red, green, blue, alpha);
1760    }
1761    static rgba(red, green, blue, alpha = MAX_ALPHA_VALUE) {
1762        return new ColorMetrics(red, green, blue, alpha * MAX_CHANNEL_VALUE);
1763    }
1764    static rgbOrRGBA(format) {
1765        const rgbPattern = /^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i;
1766        const rgbaPattern = /^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+(\.\d+)?)\s*\)$/i;
1767        const rgbMatch = rgbPattern.exec(format);
1768        const rgbaMatch = rgbaPattern.exec(format);
1769        if (rgbMatch) {
1770            const [, red, green, blue] = rgbMatch;
1771            return new ColorMetrics(Number.parseInt(red, 10), Number.parseInt(green, 10), Number.parseInt(blue, 10));
1772        }
1773        else if (rgbaMatch) {
1774            const [, red, green, blue, alpha] = rgbaMatch;
1775            return new ColorMetrics(Number.parseInt(red, 10), Number.parseInt(green, 10), Number.parseInt(blue, 10), Number.parseFloat(alpha) * MAX_CHANNEL_VALUE);
1776        }
1777        else {
1778            const error = new Error('Parameter error. The format of the input color string is not RGB or RGBA.');
1779            error.code = ERROR_CODE_COLOR_PARAMETER_INCORRECT;
1780            throw error;
1781        }
1782    }
1783    static resourceColor(color) {
1784        if (color === undefined || color === null) {
1785            const error = new Error('Parameter error. The type of the input color parameter is not ResourceColor.');
1786            error.code = ERROR_CODE_COLOR_PARAMETER_INCORRECT;
1787            throw error;
1788        }
1789        let chanels = [];
1790        if (typeof color === 'object') {
1791            chanels = getUINativeModule().nativeUtils.parseResourceColor(color);
1792            if (chanels === undefined) {
1793                const error = new Error('Failed to obtain the color resource.');
1794                error.code = ERROR_CODE_RESOURCE_GET_FAILED;
1795                throw error;
1796            }
1797            const red = chanels[0];
1798            const green = chanels[1];
1799            const blue = chanels[2];
1800            const alpha = chanels[3];
1801            const resourceId = chanels[4];
1802            const colorMetrics = new ColorMetrics(red, green, blue, alpha);
1803            colorMetrics.setResourceId(resourceId);
1804            return colorMetrics;
1805        }
1806        else if (typeof color === 'number') {
1807            return ColorMetrics.numeric(color);
1808        }
1809        else if (typeof color === 'string') {
1810            if (ColorMetrics.isHexFormat(color)) {
1811                return ColorMetrics.hex(color);
1812            }
1813            else {
1814                return ColorMetrics.rgbOrRGBA(color);
1815            }
1816        }
1817        else {
1818            const error = new Error('Parameter error. The type of the input color parameter is not ResourceColor.');
1819            error.code = ERROR_CODE_COLOR_PARAMETER_INCORRECT;
1820            throw error;
1821        }
1822    }
1823    static isHexFormat(format) {
1824        return /#(([0-9A-Fa-f]{3})|([0-9A-Fa-f]{6})|([0-9A-Fa-f]{4})|([0-9A-Fa-f]{8}))/.test(format);
1825    }
1826    static hex(hexFormat) {
1827        let r = 0;
1828        let g = 0;
1829        let b = 0;
1830        let a = 255;
1831        if (hexFormat.length === 4) {
1832            r = parseInt(hexFormat.slice(1, 2).repeat(2), 16);
1833            g = parseInt(hexFormat.slice(2, 3).repeat(2), 16);
1834            b = parseInt(hexFormat.slice(3).repeat(2), 16);
1835        }
1836        else if (hexFormat.length === 7) {
1837            r = parseInt(hexFormat.slice(1, 3), 16);
1838            g = parseInt(hexFormat.slice(3, 5), 16);
1839            b = parseInt(hexFormat.slice(5), 16);
1840        }
1841        else if (hexFormat.length === 5) {
1842            a = parseInt(hexFormat.slice(1, 2).repeat(2), 16);
1843            r = parseInt(hexFormat.slice(2, 3).repeat(2), 16);
1844            g = parseInt(hexFormat.slice(3, 4).repeat(2), 16);
1845            b = parseInt(hexFormat.slice(4).repeat(2), 16);
1846        }
1847        else if (hexFormat.length === 9) {
1848            a = parseInt(hexFormat.slice(1, 3), 16);
1849            r = parseInt(hexFormat.slice(3, 5), 16);
1850            g = parseInt(hexFormat.slice(5, 7), 16);
1851            b = parseInt(hexFormat.slice(7), 16);
1852        }
1853        return new ColorMetrics(r, g, b, a);
1854    }
1855    blendColor(overlayColor) {
1856        if (overlayColor === undefined || overlayColor === null) {
1857            const error = new Error('Parameter error. The type of the input parameter is not ColorMetrics.');
1858            error.code = ERROR_CODE_COLOR_PARAMETER_INCORRECT;
1859            throw error;
1860        }
1861        const chanels = getUINativeModule().nativeUtils.blendColor(this.toNumeric(), overlayColor.toNumeric());
1862        if (chanels === undefined) {
1863            const error = new Error('Parameter error. The type of the input parameter is not ColorMetrics.');
1864            error.code = ERROR_CODE_COLOR_PARAMETER_INCORRECT;
1865            throw error;
1866        }
1867        const red = chanels[0];
1868        const green = chanels[1];
1869        const blue = chanels[2];
1870        const alpha = chanels[3];
1871        return new ColorMetrics(red, green, blue, alpha);
1872    }
1873    get color() {
1874        return `rgba(${this.red_}, ${this.green_}, ${this.blue_}, ${this.alpha_ / MAX_CHANNEL_VALUE})`;
1875    }
1876    get red() {
1877        return this.red_;
1878    }
1879    get green() {
1880        return this.green_;
1881    }
1882    get blue() {
1883        return this.blue_;
1884    }
1885    get alpha() {
1886        return this.alpha_;
1887    }
1888    setResourceId(resourceId) {
1889        this.resourceId_ = resourceId;
1890    }
1891    getResourceId() {
1892        return this.resourceId_;
1893    }
1894}
1895class BaseShape {
1896    constructor() {
1897        this.rect = null;
1898        this.roundRect = null;
1899        this.circle = null;
1900        this.oval = null;
1901        this.path = null;
1902    }
1903    setRectShape(rect) {
1904        this.rect = rect;
1905        this.roundRect = null;
1906        this.circle = null;
1907        this.oval = null;
1908        this.path = null;
1909    }
1910    setRoundRectShape(roundRect) {
1911        this.roundRect = roundRect;
1912        this.rect = null;
1913        this.circle = null;
1914        this.oval = null;
1915        this.path = null;
1916    }
1917    setCircleShape(circle) {
1918        this.circle = circle;
1919        this.rect = null;
1920        this.roundRect = null;
1921        this.oval = null;
1922        this.path = null;
1923    }
1924    setOvalShape(oval) {
1925        this.oval = oval;
1926        this.rect = null;
1927        this.circle = null;
1928        this.roundRect = null;
1929        this.path = null;
1930    }
1931    setCommandPath(path) {
1932        this.path = path;
1933        this.oval = null;
1934        this.rect = null;
1935        this.circle = null;
1936        this.roundRect = null;
1937    }
1938}
1939class ShapeClip extends BaseShape {
1940}
1941class ShapeMask extends BaseShape {
1942    constructor(...args) {
1943        super(...args);
1944        this.fillColor = 0XFF000000;
1945        this.strokeColor = 0XFF000000;
1946        this.strokeWidth = 0;
1947    }
1948}
1949class RenderNode {
1950    constructor(type) {
1951        this.nodePtr = null;
1952        this.childrenList = [];
1953        this.parentRenderNode = null;
1954        this.backgroundColorValue = 0;
1955        this.apiTargetVersion = getUINativeModule().common.getApiTargetVersion();
1956        this.clipToFrameValue = true;
1957        if (this.apiTargetVersion && this.apiTargetVersion < 12) {
1958            this.clipToFrameValue = false;
1959        }
1960        this.frameValue = { x: 0, y: 0, width: 0, height: 0 };
1961        this.opacityValue = 1.0;
1962        this.pivotValue = { x: 0.5, y: 0.5 };
1963        this.rotationValue = { x: 0, y: 0, z: 0 };
1964        this.scaleValue = { x: 1.0, y: 1.0 };
1965        this.shadowColorValue = 0;
1966        this.shadowOffsetValue = { x: 0, y: 0 };
1967        this.labelValue = '';
1968        this.shadowAlphaValue = 0;
1969        this.shadowElevationValue = 0;
1970        this.shadowRadiusValue = 0;
1971        this.transformValue = [1, 0, 0, 0,
1972            0, 1, 0, 0,
1973            0, 0, 1, 0,
1974            0, 0, 0, 1];
1975        this.translationValue = { x: 0, y: 0 };
1976        this.lengthMetricsUnitValue = LengthMetricsUnit.DEFAULT;
1977        this.markNodeGroupValue = false;
1978        if (type === 'BuilderRootFrameNode' || type === 'CustomFrameNode') {
1979            return;
1980        }
1981        this._nativeRef = getUINativeModule().renderNode.createRenderNode(this);
1982        this.nodePtr = this._nativeRef?.getNativeHandle();
1983        if (this.apiTargetVersion && this.apiTargetVersion < 12) {
1984            this.clipToFrame = false;
1985        }
1986        else {
1987            this.clipToFrame = true;
1988        }
1989    }
1990    set backgroundColor(color) {
1991        this.backgroundColorValue = this.checkUndefinedOrNullWithDefaultValue(color, 0);
1992        getUINativeModule().renderNode.setBackgroundColor(this.nodePtr, this.backgroundColorValue);
1993    }
1994    set clipToFrame(useClip) {
1995        this.clipToFrameValue = this.checkUndefinedOrNullWithDefaultValue(useClip, true);
1996        getUINativeModule().renderNode.setClipToFrame(this.nodePtr, this.clipToFrameValue);
1997    }
1998    set frame(frame) {
1999        if (frame === undefined || frame === null) {
2000            this.frameValue = { x: 0, y: 0, width: 0, height: 0 };
2001        }
2002        else {
2003            this.size = { width: frame.width, height: frame.height };
2004            this.position = { x: frame.x, y: frame.y };
2005        }
2006    }
2007    set opacity(value) {
2008        this.opacityValue = this.checkUndefinedOrNullWithDefaultValue(value, 1.0);
2009        getUINativeModule().common.setOpacity(this.nodePtr, this.opacityValue);
2010    }
2011    set pivot(pivot) {
2012        if (pivot === undefined || pivot === null) {
2013            this.pivotValue = { x: 0.5, y: 0.5 };
2014        }
2015        else {
2016            this.pivotValue.x = this.checkUndefinedOrNullWithDefaultValue(pivot.x, 0.5);
2017            this.pivotValue.y = this.checkUndefinedOrNullWithDefaultValue(pivot.y, 0.5);
2018        }
2019        getUINativeModule().renderNode.setPivot(this.nodePtr, this.pivotValue.x, this.pivotValue.y);
2020    }
2021    set position(position) {
2022        if (position === undefined || position === null) {
2023            this.frameValue.x = 0;
2024            this.frameValue.y = 0;
2025        }
2026        else {
2027            this.frameValue.x = this.checkUndefinedOrNullWithDefaultValue(position.x, 0);
2028            this.frameValue.y = this.checkUndefinedOrNullWithDefaultValue(position.y, 0);
2029        }
2030        getUINativeModule().renderNode.setPosition(this.nodePtr, this.frameValue.x, this.frameValue.y, this.lengthMetricsUnitValue);
2031    }
2032    set rotation(rotation) {
2033        if (rotation === undefined || rotation === null) {
2034            this.rotationValue = { x: 0, y: 0, z: 0 };
2035        }
2036        else {
2037            this.rotationValue.x = this.checkUndefinedOrNullWithDefaultValue(rotation.x, 0);
2038            this.rotationValue.y = this.checkUndefinedOrNullWithDefaultValue(rotation.y, 0);
2039            this.rotationValue.z = this.checkUndefinedOrNullWithDefaultValue(rotation.z, 0);
2040        }
2041        getUINativeModule().renderNode.setRotation(this.nodePtr, this.rotationValue.x, this.rotationValue.y, this.rotationValue.z, this.lengthMetricsUnitValue);
2042    }
2043    set scale(scale) {
2044        if (scale === undefined || scale === null) {
2045            this.scaleValue = { x: 1.0, y: 1.0 };
2046        }
2047        else {
2048            this.scaleValue.x = this.checkUndefinedOrNullWithDefaultValue(scale.x, 1.0);
2049            this.scaleValue.y = this.checkUndefinedOrNullWithDefaultValue(scale.y, 1.0);
2050        }
2051        getUINativeModule().renderNode.setScale(this.nodePtr, this.scaleValue.x, this.scaleValue.y);
2052    }
2053    set shadowColor(color) {
2054        this.shadowColorValue = this.checkUndefinedOrNullWithDefaultValue(color, 0);
2055        getUINativeModule().renderNode.setShadowColor(this.nodePtr, this.shadowColorValue);
2056    }
2057    set shadowOffset(offset) {
2058        if (offset === undefined || offset === null) {
2059            this.shadowOffsetValue = { x: 0, y: 0 };
2060        }
2061        else {
2062            this.shadowOffsetValue.x = this.checkUndefinedOrNullWithDefaultValue(offset.x, 0);
2063            this.shadowOffsetValue.y = this.checkUndefinedOrNullWithDefaultValue(offset.y, 0);
2064        }
2065        getUINativeModule().renderNode.setShadowOffset(this.nodePtr, this.shadowOffsetValue.x, this.shadowOffsetValue.y, this.lengthMetricsUnitValue);
2066    }
2067    set label(label) {
2068        this.labelValue = this.checkUndefinedOrNullWithDefaultValue(label, '');
2069        getUINativeModule().renderNode.setLabel(this.nodePtr, this.labelValue);
2070    }
2071    set shadowAlpha(alpha) {
2072        this.shadowAlphaValue = this.checkUndefinedOrNullWithDefaultValue(alpha, 0);
2073        getUINativeModule().renderNode.setShadowAlpha(this.nodePtr, this.shadowAlphaValue);
2074    }
2075    set shadowElevation(elevation) {
2076        this.shadowElevationValue = this.checkUndefinedOrNullWithDefaultValue(elevation, 0);
2077        getUINativeModule().renderNode.setShadowElevation(this.nodePtr, this.shadowElevationValue);
2078    }
2079    set shadowRadius(radius) {
2080        this.shadowRadiusValue = this.checkUndefinedOrNullWithDefaultValue(radius, 0);
2081        getUINativeModule().renderNode.setShadowRadius(this.nodePtr, this.shadowRadiusValue);
2082    }
2083    set size(size) {
2084        if (size === undefined || size === null) {
2085            this.frameValue.width = 0;
2086            this.frameValue.height = 0;
2087        }
2088        else {
2089            this.frameValue.width = this.checkUndefinedOrNullWithDefaultValue(size.width, 0);
2090            this.frameValue.height = this.checkUndefinedOrNullWithDefaultValue(size.height, 0);
2091        }
2092        getUINativeModule().renderNode.setSize(this.nodePtr, this.frameValue.width, this.frameValue.height, this.lengthMetricsUnitValue);
2093    }
2094    set transform(transform) {
2095        if (transform === undefined || transform === null) {
2096            this.transformValue = [1, 0, 0, 0,
2097                0, 1, 0, 0,
2098                0, 0, 1, 0,
2099                0, 0, 0, 1];
2100        }
2101        else {
2102            let i = 0;
2103            while (i < transform.length && i < 16) {
2104                if (i % 5 === 0) {
2105                    this.transformValue[i] = this.checkUndefinedOrNullWithDefaultValue(transform[i], 1);
2106                }
2107                else {
2108                    this.transformValue[i] = this.checkUndefinedOrNullWithDefaultValue(transform[i], 0);
2109                }
2110                i = i + 1;
2111            }
2112        }
2113        getUINativeModule().common.setTransform(this.nodePtr, this.transformValue);
2114    }
2115    set translation(translation) {
2116        if (translation === undefined || translation === null) {
2117            this.translationValue = { x: 0, y: 0 };
2118        }
2119        else {
2120            this.translationValue.x = this.checkUndefinedOrNullWithDefaultValue(translation.x, 0);
2121            this.translationValue.y = this.checkUndefinedOrNullWithDefaultValue(translation.y, 0);
2122        }
2123        getUINativeModule().renderNode.setTranslate(this.nodePtr, this.translationValue.x, this.translationValue.y, 0);
2124    }
2125    set lengthMetricsUnit(unit) {
2126        if (unit === undefined || unit == null) {
2127            this.lengthMetricsUnitValue = LengthMetricsUnit.DEFAULT;
2128        }
2129        else {
2130            this.lengthMetricsUnitValue = unit;
2131        }
2132    }
2133    set markNodeGroup(isNodeGroup) {
2134        if (isNodeGroup === undefined || isNodeGroup === null) {
2135            this.markNodeGroupValue = false;
2136        }
2137        else {
2138            this.markNodeGroupValue = isNodeGroup;
2139        }
2140        getUINativeModule().renderNode.setMarkNodeGroup(this.nodePtr, this.markNodeGroupValue);
2141    }
2142    get backgroundColor() {
2143        return this.backgroundColorValue;
2144    }
2145    get clipToFrame() {
2146        return this.clipToFrameValue;
2147    }
2148    get opacity() {
2149        return this.opacityValue;
2150    }
2151    get frame() {
2152        return this.frameValue;
2153    }
2154    get pivot() {
2155        return this.pivotValue;
2156    }
2157    get position() {
2158        return { x: this.frameValue.x, y: this.frameValue.y };
2159    }
2160    get rotation() {
2161        return this.rotationValue;
2162    }
2163    get scale() {
2164        return this.scaleValue;
2165    }
2166    get shadowColor() {
2167        return this.shadowColorValue;
2168    }
2169    get shadowOffset() {
2170        return this.shadowOffsetValue;
2171    }
2172    get label() {
2173        return this.labelValue;
2174    }
2175    get shadowAlpha() {
2176        return this.shadowAlphaValue;
2177    }
2178    get shadowElevation() {
2179        return this.shadowElevationValue;
2180    }
2181    get shadowRadius() {
2182        return this.shadowRadiusValue;
2183    }
2184    get size() {
2185        return { width: this.frameValue.width, height: this.frameValue.height };
2186    }
2187    get transform() {
2188        return this.transformValue;
2189    }
2190    get translation() {
2191        return this.translationValue;
2192    }
2193    get lengthMetricsUnit() {
2194        return this.lengthMetricsUnitValue;
2195    }
2196    get markNodeGroup() {
2197        return this.markNodeGroupValue;
2198    }
2199    checkUndefinedOrNullWithDefaultValue(arg, defaultValue) {
2200        if (arg === undefined || arg === null) {
2201            return defaultValue;
2202        }
2203        else {
2204            return arg;
2205        }
2206    }
2207    appendChild(node) {
2208        if (node === undefined || node === null) {
2209            return;
2210        }
2211        if (this.childrenList.findIndex(element => element === node) !== -1) {
2212            return;
2213        }
2214        this.childrenList.push(node);
2215        node.parentRenderNode = new WeakRef(this);
2216        getUINativeModule().renderNode.appendChild(this.nodePtr, node.nodePtr);
2217    }
2218    insertChildAfter(child, sibling) {
2219        if (child === undefined || child === null) {
2220            return;
2221        }
2222        let indexOfNode = this.childrenList.findIndex(element => element === child);
2223        if (indexOfNode !== -1) {
2224            return;
2225        }
2226        child.parentRenderNode = new WeakRef(this);
2227        let indexOfSibling = this.childrenList.findIndex(element => element === sibling);
2228        if (indexOfSibling === -1) {
2229            sibling === null;
2230        }
2231        if (sibling === undefined || sibling === null) {
2232            this.childrenList.splice(0, 0, child);
2233            getUINativeModule().renderNode.insertChildAfter(this.nodePtr, child.nodePtr, null);
2234        }
2235        else {
2236            this.childrenList.splice(indexOfSibling + 1, 0, child);
2237            getUINativeModule().renderNode.insertChildAfter(this.nodePtr, child.nodePtr, sibling.nodePtr);
2238        }
2239    }
2240    removeChild(node) {
2241        if (node === undefined || node === null) {
2242            return;
2243        }
2244        const index = this.childrenList.findIndex(element => element === node);
2245        if (index === -1) {
2246            return;
2247        }
2248        const child = this.childrenList[index];
2249        child.parentRenderNode = null;
2250        this.childrenList.splice(index, 1);
2251        getUINativeModule().renderNode.removeChild(this.nodePtr, node.nodePtr);
2252    }
2253    clearChildren() {
2254        this.childrenList = new Array();
2255        getUINativeModule().renderNode.clearChildren(this.nodePtr);
2256    }
2257    getChild(index) {
2258        if (this.childrenList.length > index && index >= 0) {
2259            return this.childrenList[index];
2260        }
2261        return null;
2262    }
2263    getFirstChild() {
2264        if (this.childrenList.length > 0) {
2265            return this.childrenList[0];
2266        }
2267        return null;
2268    }
2269    getNextSibling() {
2270        if (this.parentRenderNode === undefined || this.parentRenderNode === null) {
2271            return null;
2272        }
2273        let parent = this.parentRenderNode.deref();
2274        if (parent === undefined || parent === null) {
2275            return null;
2276        }
2277        let siblingList = parent.childrenList;
2278        const index = siblingList.findIndex(element => element === this);
2279        if (index === -1) {
2280            return null;
2281        }
2282        return parent.getChild(index + 1);
2283    }
2284    getPreviousSibling() {
2285        if (this.parentRenderNode === undefined || this.parentRenderNode === null) {
2286            return null;
2287        }
2288        let parent = this.parentRenderNode.deref();
2289        if (parent === undefined || parent === null) {
2290            return null;
2291        }
2292        let siblingList = parent.childrenList;
2293        const index = siblingList.findIndex(element => element === this);
2294        if (index === -1) {
2295            return null;
2296        }
2297        return parent.getChild(index - 1);
2298    }
2299    setFrameNode(frameNode) {
2300        this._frameNode = frameNode;
2301    }
2302    setNodePtr(nativeRef) {
2303        this._nativeRef = nativeRef;
2304        this.nodePtr = this._nativeRef?.getNativeHandle();
2305    }
2306    setBaseNode(baseNode) {
2307        this.baseNode_ = baseNode;
2308    }
2309    resetNodePtr() {
2310        this.nodePtr = null;
2311        this._nativeRef = null;
2312    }
2313    dispose() {
2314        this._nativeRef?.dispose();
2315        this.baseNode_?.disposeNode();
2316        this._frameNode?.deref()?.resetNodePtr();
2317        this._nativeRef = null;
2318        this.nodePtr = null;
2319    }
2320    getNodePtr() {
2321        return this.nodePtr;
2322    }
2323    invalidate() {
2324        getUINativeModule().renderNode.invalidate(this.nodePtr);
2325    }
2326    set borderStyle(style) {
2327        if (style === undefined || style === null) {
2328            this.borderStyleValue = { left: BorderStyle.NONE, top: BorderStyle.NONE, right: BorderStyle.NONE, bottom: BorderStyle.NONE };
2329        }
2330        else {
2331            this.borderStyleValue = style;
2332        }
2333        getUINativeModule().renderNode.setBorderStyle(this.nodePtr, this.borderStyleValue.left, this.borderStyleValue.top, this.borderStyleValue.right, this.borderStyleValue.bottom);
2334    }
2335    get borderStyle() {
2336        return this.borderStyleValue;
2337    }
2338    set borderWidth(width) {
2339        if (width === undefined || width === null) {
2340            this.borderWidthValue = { left: 0, top: 0, right: 0, bottom: 0 };
2341        }
2342        else {
2343            this.borderWidthValue = width;
2344        }
2345        getUINativeModule().renderNode.setBorderWidth(this.nodePtr, this.borderWidthValue.left, this.borderWidthValue.top, this.borderWidthValue.right, this.borderWidthValue.bottom, this.lengthMetricsUnitValue);
2346    }
2347    get borderWidth() {
2348        return this.borderWidthValue;
2349    }
2350    set borderColor(color) {
2351        if (color === undefined || color === null) {
2352            this.borderColorValue = { left: 0XFF000000, top: 0XFF000000, right: 0XFF000000, bottom: 0XFF000000 };
2353        }
2354        else {
2355            this.borderColorValue = color;
2356        }
2357        getUINativeModule().renderNode.setBorderColor(this.nodePtr, this.borderColorValue.left, this.borderColorValue.top, this.borderColorValue.right, this.borderColorValue.bottom);
2358    }
2359    get borderColor() {
2360        return this.borderColorValue;
2361    }
2362    set borderRadius(radius) {
2363        if (radius === undefined || radius === null) {
2364            this.borderRadiusValue = { topLeft: 0, topRight: 0, bottomLeft: 0, bottomRight: 0 };
2365        }
2366        else {
2367            this.borderRadiusValue = radius;
2368        }
2369        getUINativeModule().renderNode.setBorderRadius(this.nodePtr, this.borderRadiusValue.topLeft, this.borderRadiusValue.topRight, this.borderRadiusValue.bottomLeft, this.borderRadiusValue.bottomRight, this.lengthMetricsUnitValue);
2370    }
2371    get borderRadius() {
2372        return this.borderRadiusValue;
2373    }
2374    set shapeMask(shapeMask) {
2375        if (shapeMask === undefined || shapeMask === null) {
2376            this.shapeMaskValue = new ShapeMask();
2377        }
2378        else {
2379            this.shapeMaskValue = shapeMask;
2380        }
2381        if (this.shapeMaskValue.rect !== null) {
2382            const rectMask = this.shapeMaskValue.rect;
2383            getUINativeModule().renderNode.setRectMask(this.nodePtr, rectMask.left, rectMask.top, rectMask.right, rectMask.bottom, this.shapeMaskValue.fillColor, this.shapeMaskValue.strokeColor, this.shapeMaskValue.strokeWidth);
2384        }
2385        else if (this.shapeMaskValue.circle !== null) {
2386            const circle = this.shapeMaskValue.circle;
2387            getUINativeModule().renderNode.setCircleMask(this.nodePtr, circle.centerX, circle.centerY, circle.radius, this.shapeMaskValue.fillColor, this.shapeMaskValue.strokeColor, this.shapeMaskValue.strokeWidth);
2388        }
2389        else if (this.shapeMaskValue.roundRect !== null) {
2390            const roundRect = this.shapeMask.roundRect;
2391            const corners = roundRect.corners;
2392            const rect = roundRect.rect;
2393            getUINativeModule().renderNode.setRoundRectMask(this.nodePtr, corners.topLeft.x, corners.topLeft.y, corners.topRight.x, corners.topRight.y, corners.bottomLeft.x, corners.bottomLeft.y, corners.bottomRight.x, corners.bottomRight.y, rect.left, rect.top, rect.right, rect.bottom, this.shapeMaskValue.fillColor, this.shapeMaskValue.strokeColor, this.shapeMaskValue.strokeWidth);
2394        }
2395        else if (this.shapeMaskValue.oval !== null) {
2396            const oval = this.shapeMaskValue.oval;
2397            getUINativeModule().renderNode.setOvalMask(this.nodePtr, oval.left, oval.top, oval.right, oval.bottom, this.shapeMaskValue.fillColor, this.shapeMaskValue.strokeColor, this.shapeMaskValue.strokeWidth);
2398        }
2399        else if (this.shapeMaskValue.path !== null) {
2400            const path = this.shapeMaskValue.path;
2401            getUINativeModule().renderNode.setPath(this.nodePtr, path.commands, this.shapeMaskValue.fillColor, this.shapeMaskValue.strokeColor, this.shapeMaskValue.strokeWidth);
2402        }
2403    }
2404    get shapeMask() {
2405        return this.shapeMaskValue;
2406    }
2407    set shapeClip(shapeClip) {
2408        if (shapeClip === undefined || shapeClip === null) {
2409            this.shapeClipValue = new ShapeClip();
2410        }
2411        else {
2412            this.shapeClipValue = shapeClip;
2413        }
2414        if (this.shapeClipValue.rect !== null) {
2415            const rectClip = this.shapeClipValue.rect;
2416            getUINativeModule().renderNode.setRectClip(this.nodePtr, rectClip.left, rectClip.top, rectClip.right, rectClip.bottom);
2417        }
2418        else if (this.shapeClipValue.circle !== null) {
2419            const circle = this.shapeClipValue.circle;
2420            getUINativeModule().renderNode.setCircleClip(this.nodePtr, circle.centerX, circle.centerY, circle.radius);
2421        }
2422        else if (this.shapeClipValue.roundRect !== null) {
2423            const roundRect = this.shapeClipValue.roundRect;
2424            const corners = roundRect.corners;
2425            const rect = roundRect.rect;
2426            getUINativeModule().renderNode.setRoundRectClip(this.nodePtr, corners.topLeft.x, corners.topLeft.y, corners.topRight.x, corners.topRight.y, corners.bottomLeft.x, corners.bottomLeft.y, corners.bottomRight.x, corners.bottomRight.y, rect.left, rect.top, rect.right, rect.bottom);
2427        }
2428        else if (this.shapeClipValue.oval !== null) {
2429            const oval = this.shapeClipValue.oval;
2430            getUINativeModule().renderNode.setOvalClip(this.nodePtr, oval.left, oval.top, oval.right, oval.bottom);
2431        }
2432        else if (this.shapeClipValue.path !== null) {
2433            const path = this.shapeClipValue.path;
2434            getUINativeModule().renderNode.setPathClip(this.nodePtr, path.commands);
2435        }
2436    }
2437    get shapeClip() {
2438        this.shapeClipValue = this.shapeClipValue ? this.shapeClipValue : new ShapeClip();
2439        return this.shapeClipValue;
2440    }
2441}
2442function edgeColors(all) {
2443    return { left: all, top: all, right: all, bottom: all };
2444}
2445function edgeWidths(all) {
2446    return { left: all, top: all, right: all, bottom: all };
2447}
2448function borderStyles(all) {
2449    return { left: all, top: all, right: all, bottom: all };
2450}
2451function borderRadiuses(all) {
2452    return { topLeft: all, topRight: all, bottomLeft: all, bottomRight: all };
2453}
2454/*
2455 * Copyright (c) 2023 Huawei Device Co., Ltd.
2456 * Licensed under the Apache License, Version 2.0 (the "License");
2457 * you may not use this file except in compliance with the License.
2458 * You may obtain a copy of the License at
2459 *
2460 *     http://www.apache.org/licenses/LICENSE-2.0
2461 *
2462 * Unless required by applicable law or agreed to in writing, software
2463 * distributed under the License is distributed on an "AS IS" BASIS,
2464 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2465 * See the License for the specific language governing permissions and
2466 * limitations under the License.
2467 */
2468class XComponentNode extends FrameNode {
2469    constructor(uiContext, options, id, type, libraryname, controller) {
2470        super(uiContext, 'XComponentNode');
2471        const elmtId = ViewStackProcessor.AllocateNewElmetIdForNextComponent();
2472        this.xcomponentNode_ = getUINativeModule().xcomponentNode;
2473        this.renderType_ = options.type;
2474        const surfaceId = options.surfaceId;
2475        const selfIdealWidth = options.selfIdealSize.width;
2476        const selfIdealHeight = options.selfIdealSize.height;
2477        this.nativeModule_ = this.xcomponentNode_.create(elmtId, id, type, this.renderType_, surfaceId, selfIdealWidth, selfIdealHeight, libraryname, controller);
2478        this.xcomponentNode_.registerOnCreateCallback(this.nativeModule_, this.onCreate);
2479        this.xcomponentNode_.registerOnDestroyCallback(this.nativeModule_, this.onDestroy);
2480        this.nodePtr_ = this.xcomponentNode_.getFrameNode(this.nativeModule_);
2481        this.setNodePtr(getUINativeModule().nativeUtils.createNativeStrongRef(this.nodePtr_), this.nodePtr_);
2482    }
2483    onCreate(event) { }
2484    onDestroy() { }
2485    changeRenderType(type) {
2486        if (this.renderType_ === type) {
2487            return true;
2488        }
2489        if (this.xcomponentNode_.changeRenderType(this.nativeModule_, type)) {
2490            this.renderType_ = type;
2491            return true;
2492        }
2493        return false;
2494    }
2495}
2496/*
2497 * Copyright (c) 2024 Huawei Device Co., Ltd.
2498 * Licensed under the Apache License, Version 2.0 (the "License");
2499 * you may not use this file except in compliance with the License.
2500 * You may obtain a copy of the License at
2501 *
2502 *     http://www.apache.org/licenses/LICENSE-2.0
2503 *
2504 * Unless required by applicable law or agreed to in writing, software
2505 * distributed under the License is distributed on an "AS IS" BASIS,
2506 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2507 * See the License for the specific language governing permissions and
2508 * limitations under the License.
2509 */
2510class Content {
2511    constructor() { }
2512    onAttachToWindow() { }
2513    onDetachFromWindow() { }
2514}
2515/*
2516 * Copyright (c) 2024 Huawei Device Co., Ltd.
2517 * Licensed under the Apache License, Version 2.0 (the "License");
2518 * you may not use this file except in compliance with the License.
2519 * You may obtain a copy of the License at
2520 *
2521 *     http://www.apache.org/licenses/LICENSE-2.0
2522 *
2523 * Unless required by applicable law or agreed to in writing, software
2524 * distributed under the License is distributed on an "AS IS" BASIS,
2525 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2526 * See the License for the specific language governing permissions and
2527 * limitations under the License.
2528 */
2529class ComponentContent extends Content {
2530    constructor(uiContext, builder, params, options) {
2531        super();
2532        let builderNode = new BuilderNode(uiContext, {});
2533        this.builderNode_ = builderNode;
2534        this.builderNode_.build(builder, params ?? undefined, options);
2535    }
2536    update(params) {
2537        this.builderNode_.update(params);
2538    }
2539    getFrameNode() {
2540        return this.builderNode_.getFrameNodeWithoutCheck();
2541    }
2542    setAttachedParent(parent) {
2543        this.parentWeak_ = parent;
2544    }
2545    getNodePtr() {
2546        if (this.attachNodeRef_ !== undefined) {
2547            return this.attachNodeRef_.getNativeHandle();
2548        }
2549        return this.builderNode_.getNodePtr();
2550    }
2551    reuse(param) {
2552        this.builderNode_.reuse(param);
2553    }
2554    recycle() {
2555        this.builderNode_.recycle();
2556    }
2557    onReuseWithBindObject(param) {
2558        this.builderNode_.onReuseWithBindObject(param);
2559    }
2560    onRecycleWithBindObject() {
2561        this.builderNode_.onRecycleWithBindObject();
2562    }
2563    dispose() {
2564        this.detachFromParent();
2565        this.attachNodeRef_?.dispose();
2566        this.builderNode_?.dispose();
2567    }
2568    detachFromParent() {
2569        if (this.parentWeak_ === undefined) {
2570            return;
2571        }
2572        let parent = this.parentWeak_.deref();
2573        if (parent !== undefined) {
2574            parent.removeComponentContent(this);
2575        }
2576    }
2577    getNodeWithoutProxy() {
2578        const node = this.getNodePtr();
2579        const nodeType = getUINativeModule().frameNode.getNodeType(node);
2580        if (nodeType === "BuilderProxyNode") {
2581            const result = getUINativeModule().frameNode.getFirstUINode(node);
2582            this.attachNodeRef_ = getUINativeModule().nativeUtils.createNativeStrongRef(result);
2583            getUINativeModule().frameNode.removeChild(node, result);
2584            return result;
2585        }
2586        return node;
2587    }
2588    updateConfiguration() {
2589        this.builderNode_.updateConfiguration();
2590    }
2591}
2592/*
2593 * Copyright (c) 2024 Huawei Device Co., Ltd.
2594 * Licensed under the Apache License, Version 2.0 (the "License");
2595 * you may not use this file except in compliance with the License.
2596 * You may obtain a copy of the License at
2597 *
2598 *     http://www.apache.org/licenses/LICENSE-2.0
2599 *
2600 * Unless required by applicable law or agreed to in writing, software
2601 * distributed under the License is distributed on an "AS IS" BASIS,
2602 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2603 * See the License for the specific language governing permissions and
2604 * limitations under the License.
2605 */
2606class NodeContent extends Content {
2607    constructor() {
2608        super();
2609        this.nativeRef_ = getUINativeModule().frameNode.createNodeContent();
2610        this.nativePtr_ = this.nativeRef_.getNativeHandle();
2611        this.nodeArray_ = new Array();
2612    }
2613    addFrameNode(node) {
2614        if (this.nodeArray_.includes(node)) {
2615            return;
2616        }
2617        if (getUINativeModule().frameNode.addFrameNodeToNodeContent(node.getNodePtr(), this.nativePtr_)) {
2618            this.nodeArray_.push(node);
2619        }
2620    }
2621    removeFrameNode(node) {
2622        if (!this.nodeArray_.includes(node)) {
2623            return;
2624        }
2625        if (getUINativeModule().frameNode.removeFrameNodeFromNodeContent(node.getNodePtr(), this.nativePtr_)) {
2626            let index = this.nodeArray_.indexOf(node);
2627            if (index > -1) {
2628                this.nodeArray_.splice(index, 1);
2629            }
2630        }
2631    }
2632}
2633
2634export default {
2635    NodeController, BuilderNode, BaseNode, RenderNode, FrameNode, FrameNodeUtils,
2636    NodeRenderType, XComponentNode, LengthMetrics, ColorMetrics, LengthUnit, LengthMetricsUnit, ShapeMask, ShapeClip,
2637    edgeColors, edgeWidths, borderStyles, borderRadiuses, Content, ComponentContent, NodeContent,
2638    typeNode, NodeAdapter, ExpandMode
2639};
2640