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