"use strict";module.exports=ReflectionObject,ReflectionObject.className="ReflectionObject";var Root,util=require("./util");function ReflectionObject(t,e){if(!util.isString(t))throw TypeError("name must be a string");if(e&&!util.isObject(e))throw TypeError("options must be an object");this.options=e,this.parsedOptions=null,this.name=t,this.parent=null,this.resolved=!1,this.comment=null,this.filename=null}Object.defineProperties(ReflectionObject.prototype,{root:{get:function(){for(var t=this;null!==t.parent;)t=t.parent;return t}},fullName:{get:function(){for(var t=[this.name],e=this.parent;e;)t.unshift(e.name),e=e.parent;return t.join(".")}}}),ReflectionObject.prototype.toJSON=function(){throw Error()},ReflectionObject.prototype.onAdd=function(t){this.parent&&this.parent!==t&&this.parent.remove(this),this.parent=t,this.resolved=!1;var e=t.root;e instanceof Root&&e._handleAdd(this)},ReflectionObject.prototype.onRemove=function(t){var e=t.root;e instanceof Root&&e._handleRemove(this),this.parent=null,this.resolved=!1},ReflectionObject.prototype.resolve=function(){return this.resolved||this.root instanceof Root&&(this.resolved=!0),this},ReflectionObject.prototype.getOption=function(t){if(this.options)return this.options[t]},ReflectionObject.prototype.setOption=function(t,e,o){return o&&this.options&&void 0!==this.options[t]||((this.options||(this.options={}))[t]=e),this},ReflectionObject.prototype.setParsedOption=function(t,e,o){this.parsedOptions||(this.parsedOptions=[]);var i=this.parsedOptions;if(o){var n=i.find(function(e){return Object.prototype.hasOwnProperty.call(e,t)});if(n){var r=n[t];util.setProperty(r,o,e)}else(n={})[t]=util.setProperty({},o,e),i.push(n)}else{var s={};s[t]=e,i.push(s)}return this},ReflectionObject.prototype.setOptions=function(t,e){if(t)for(var o=Object.keys(t),i=0;i<o.length;++i)this.setOption(o[i],t[o[i]],e);return this},ReflectionObject.prototype.toString=function(){var t=this.constructor.className,e=this.fullName;return e.length?t+" "+e:t},ReflectionObject._configure=function(t){Root=t};