"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _debounce=require("../shared/debounce"),_throttle=require("../shared/throttle"),_isEmpty=require("../shared/isEmpty");function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function _defineProperty(t,e,n){return(e=_toPropertyKey(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function _toPropertyKey(t){t=_toPrimitive(t,"string");return"symbol"==_typeof(t)?t:String(t)}function _toPrimitive(t,e){if("object"!=_typeof(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0===n)return("string"===e?String:Number)(t);n=n.call(t,e||"default");if("object"!=_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}function bindFunc(t,e,n){var r=t[e];t[e]=function(t){n&&n.call(this,t,_defineProperty({},e,!0)),r&&r.call(this,t)}}var methods=["linked","linkChanged","unlinked"],extProps=["observer"],isNamePath=function(t){return/^..\//.test(t)},_default=exports.default=Behavior({lifetimes:{created:function(){this.useThrottleFn=function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,n=2<arguments.length?arguments[2]:void 0,t=(0,_throttle.throttle)(t.bind(this),e,n);return this._throttledFns.push(t),{run:t,cancel:t.cancel,flush:t.flush}},this._throttledFns=[],this.callDebounceFn=function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,n=2<arguments.length?arguments[2]:void 0;return(this._debounced=this._debounced||(0,_debounce.debounce)(t.bind(this),e,n)).call(this)},this._debounced=null},detached:function(){this._debounced&&this._debounced.cancel&&this._debounced.cancel(),0<this._throttledFns.length&&(this._throttledFns.forEach(function(t){t.cancel()}),this._throttledFns=[])}},definitionFilter:function(t){var r=t.relations;if(!(0,_isEmpty.isEmpty)(r))for(var n in r)!function(){var e=r[n];methods.forEach(function(t){return bindFunc(e,t,e.observer)}),extProps.forEach(function(t){return delete e[t]})}();Object.assign(t.methods=t.methods||{},{getRelations:function(){var e=this,n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:["parent","child","ancestor","descendant"];return(0,_isEmpty.isEmpty)(r)?[]:Object.keys(r).map(function(t){return r[t]&&n.includes(r[t].type)?t:null}).filter(function(t){return!!t}).map(function(t){return e.getRelationsByName(t)[0]}).filter(function(t){return!!t})},getRelationsByName:function(t){return this.getRelationNodes(isNamePath(t)?t:"../".concat(t,"/index"))},getRelationsByType:function(t){return this.getRelations([t])},querySelector:function(t){return this.selectComponent(t)},querySelectorAll:function(t){return this.selectAllComponents(t)}})}});