"use strict";function e(e,t){return!!e&&(!!t&&t.some((t=>t.contains(e))))}require("react");class t{get size(){return this.fastMap.size}getTreeNode(e){return this.fastMap.get(e)}addTreeNode(e,t,s){let o=this.fastMap.get(null!=t?t:null);if(!o)return;let n=new r({scopeRef:e});o.addChild(n),n.parent=o,this.fastMap.set(e,n),s&&(n.nodeToRestore=s)}addNode(e){this.fastMap.set(e.scopeRef,e)}removeTreeNode(t){if(null===t)return;let r=this.fastMap.get(t);if(!r)return;let s=r.parent;for(let t of this.traverse())t!==r&&r.nodeToRestore&&t.nodeToRestore&&r.scopeRef&&r.scopeRef.current&&e(t.nodeToRestore,r.scopeRef.current)&&(t.nodeToRestore=r.nodeToRestore);let o=r.children;s&&(s.removeChild(r),o.size>0&&o.forEach((e=>s&&s.addChild(e)))),this.fastMap.delete(r.scopeRef)}traverse(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.root;return function*(){if(null!=t.scopeRef&&(yield t),t.children.size>0)for(let r of t.children)yield*e.traverse(r)}()}clone(){var e;let r=new t;var s;for(let t of this.traverse())r.addTreeNode(t.scopeRef,null!==(s=null===(e=t.parent)||void 0===e?void 0:e.scopeRef)&&void 0!==s?s:null,t.nodeToRestore);return r}constructor(){this.fastMap=new Map,this.root=new r({scopeRef:null}),this.fastMap.set(null,this.root)}}class r{addChild(e){this.children.add(e),e.parent=this}removeChild(e){this.children.delete(e),e.parent=void 0}constructor(e){this.children=new Set,this.contain=!1,this.scopeRef=e.scopeRef}}new t;
//# sourceMappingURL=FocusScope.mjs.js.map
