var t = require; var e = module; var i = exports; var r, e = (this && this.__decorate) || function (t, e, i, s) { var o, a = arguments.length, n = a < 3 ? e : null === s ? (s = Object.getOwnPropertyDescriptor(e, i)) : s; if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) n = Reflect.decorate(t, e, i, s); else for (var r = t.length - 1; 0 <= r; r--) (o = t[r]) && (n = (a < 3 ? o(n) : 3 < a ? o(e, i, n) : o(e, i)) || n); return 3 < a && n && Object.defineProperty(e, i, n), n; }; Object.defineProperty(i, "__esModule", {value: !0}), (i.Locator = void 0); const l = t("App"), {ccclass: s} = cc._decorator; t = r = class { static parse(i) { cc.assert(i, "locator string is null"); let t = i.split(/[.,//,>,#]/g), s = 0; return t.map(function (t) { var e = i[s - 1] || ">"; return (s += t.length + 1), {symbol: e, name: t.trim()}; }); } static seekNodeByName(t, e) { if (!t) return null; if (t.name == e) return t; var i = t.children, s = i.length; for (let t = 0; t < s; t++) { var o = i[t], o = this.seekNodeByName(o, e); if (null != o) return o; } return null; } static locateNode(t, e, i) { r.locating || ((this.startTime = Date.now()), (this.locating = !0)); var s = r.parse(e); cc.assert(s && s.length); let o, a = t; for (let t = 0; t < s.length; t++) { var n = s[t]; switch (n.symbol) { case "/": o = a.getChildByName(n.name); break; case ".": o = a[n.name]; break; case ">": o = this.seekNodeByName(a, n.name); } if (!o) { a = null; break; } a = o; } return ( a && a.active && i ? ((this.locating = !1), l.default.TimerManager.setFrameOut( 1, () => { i(null, a); }, this )) : i && (Date.now() - this.startTime > this.timeout ? ((this.locating = !1), i({error: "timeout", locator: e})) : l.default.TimerManager.setTimeOut( 100, () => { this.locateNode(t, e, i); }, this )), a ); } static locateNodeSync(t, e) { return new Promise(i => { this.locateNode(t, e, (t, e) => { i({error: t, node: e}); }); }); } static getNodeFullPath(t) { let e = [], i = t; for (; "GameScene" !== i.name && e.unshift(i.name), (i = i.parent), i && "Canvas" !== i.name; ); return e.join("/"); } }; (t.timeout = 8e3), (t = r = e([s], t)), (i.Locator = t = r);