'use strict';
import { isFunction } from '@flint/infra/analysis/node-type-type-guards';
import { isNull } from '@flint/infra/analysis/nullish-analysis';

var __defProp=Object['defineProperty'],__name=(_0xeb573d,_0xa9428)=>__defProp(_0xeb573d,'name',{'value':_0xa9428,'configurable':!![]});function iterateChildren(_0x623b67,_0x4e775a,_0x15aa15){return (_0x4e775a[_0x623b67['type']]??[])['reduce']((_0x47f598,_0x7822a9)=>{const _0x18acbc=Reflect['get'](_0x623b67,_0x7822a9,_0x623b67);if(isNull(_0x18acbc)||_0x18acbc===void(0xb03*0x1+0xd*0x25d+0x14de*-0x2))return _0x47f598;if(Array['isArray'](_0x18acbc))for(let _0x1aff1e=0x115*0x8+-0x8f2+0x4a;_0x1aff1e<_0x18acbc['length'];++_0x1aff1e){_0x47f598['push']({'value':_0x18acbc[_0x1aff1e],'metadata':{'parent':_0x15aa15,'key':_0x7822a9,'index':_0x1aff1e}});}else _0x47f598['push']({'value':_0x18acbc,'metadata':{'parent':_0x15aa15,'key':_0x7822a9}});return _0x47f598;},[]);}__name(iterateChildren,'iterateChildren');function*iterateDescendants(_0x4bd53e,_0x2772a6,_0x3becbf=Infinity){yield*iterateTreeNode(_0x4bd53e,_0x2772a6,_0x3becbf,-0x23a1+-0x21*0x7f+-0x200*-0x1a);}__name(iterateDescendants,'iterateDescendants');function getFirstParentOfType(_0x394a56,_0x3f1892){let _0x30d955,_0x35ecac=_0x394a56['parent'];while(_0x35ecac){if(_0x35ecac['type']===_0x3f1892){_0x30d955=_0x35ecac;break;}_0x35ecac=_0x35ecac['parent'];}return _0x30d955;}__name(getFirstParentOfType,'getFirstParentOfType');function hasFunctionAncestor(_0x5ae0b5,_0x378902){let _0x306b3d=_0x5ae0b5?_0x5ae0b5['parent']:void(0x1a29+0x1*0x20c+-0x1c35),_0x989467=![];while(_0x306b3d&&_0x306b3d['value']!==_0x378902&&!_0x989467){isFunction(_0x306b3d['value'])&&(_0x989467=!![]),_0x306b3d=_0x306b3d['metadata']?_0x306b3d['metadata']['parent']:void(0x9e9+0x2466+-0x2e4f);}return _0x989467;}__name(hasFunctionAncestor,'hasFunctionAncestor');function getEnclosingFunctionFromNode(_0xc82f48){let _0x4cc257=_0xc82f48['parent'],_0x41c25a;while(_0x4cc257&&!_0x41c25a){isFunction(_0x4cc257)&&(_0x41c25a=_0x4cc257),_0x4cc257=_0x4cc257['parent'];}return _0x41c25a;}__name(getEnclosingFunctionFromNode,'getEnclosingFunctionFromNode');function*iterateTreeNode(_0x4b6c08,_0x3d9d9c,_0x108f76,_0x5dfd90,_0x13ccf8){if(_0x5dfd90>=_0x108f76)return;const _0x3ba855=iterateChildren(_0x4b6c08,_0x3d9d9c,_0x13ccf8??{'value':_0x4b6c08});for(const _0x441355 of _0x3ba855){yield _0x441355;if(Array['isArray'](_0x441355['value']))for(const _0x14f63f of _0x441355['value']){yield*iterateTreeNode(_0x14f63f,_0x3d9d9c,_0x108f76,_0x5dfd90+(-0x2504+0xe89+-0x4*-0x59f),_0x441355);}else yield*iterateTreeNode(_0x441355['value'],_0x3d9d9c,_0x108f76,_0x5dfd90+(0x9e*0x2+-0x116e+-0xd*-0x13f),_0x441355);}}__name(iterateTreeNode,'iterateTreeNode');

export { getEnclosingFunctionFromNode, getFirstParentOfType, hasFunctionAncestor, iterateChildren, iterateDescendants };
