pipicar/public/lib/inspire-tree/js/inspire-tree.js

25 lines
90 KiB
JavaScript

/* Inspire Tree
* @version 4.3.1
* https://github.com/helion3/inspire-tree
* @copyright Copyright 2015 Helion3, and other contributors
* @license Licensed under MIT
* see https://github.com/helion3/inspire-tree/blob/master/LICENSE
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("lodash")):"function"==typeof define&&define.amd?define(["lodash"],t):e.InspireTree=t(e._)}(this,function(e){"use strict";function t(){throw new Error("Dynamic requires are not currently supported by rollup-plugin-commonjs")}function n(e,t){return t={exports:{}},e(t,t.exports),t.exports}function i(e,t){var n=t||0,i=_;return i[e[n++]]+i[e[n++]]+i[e[n++]]+i[e[n++]]+"-"+i[e[n++]]+i[e[n++]]+"-"+i[e[n++]]+i[e[n++]]+"-"+i[e[n++]]+i[e[n++]]+"-"+i[e[n++]]+i[e[n++]]+i[e[n++]]+i[e[n++]]+i[e[n++]]+i[e[n++]]}function r(e,t,n){var i=t&&n||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var r=(e=e||{}).random||(e.rng||k)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t)for(var s=0;s<16;++s)t[i+s]=r[s];return t||m(r)}function s(t){return e.each(t._tree.defaultState,function(e,n){t.state(n,e)}),t}function o(e,t,n,i,r){return i.state(e)!==t&&(i._tree.batch(),i._tree.config.nodes.resetStateOnRestore&&"restored"===n&&s(i),i.state(e,t),i._tree.emit("node."+n,i,!1),r&&i.hasChildren()&&i.children.recurseDown(function(i){o(e,t,n,i)}),i.markDirty(),i._tree.end()),i}function a(e,t){if(t)return this.extract(e);var n=c(e);return this.flatten(function(t){return("removed"===e||!t.removed())&&n(t)})}function u(t,n,i,r){return n=e.castArray(n),t._tree.batch(),t[r?"recurseDown":"each"](function(t){e.each(n,function(n){e.isFunction(t[n])&&t[n].apply(t,i)})}),t._tree.end(),t}function c(t){var n=t;return e.isString(t)&&(n=function(n){return e.isFunction(n[t])?n[t]():n[t]}),n}function l(t,n){var i=void 0;return t instanceof P?e.each(t,function(e){return i=l(e,n)}):t instanceof S&&!1!==(i=n(t))&&t.hasChildren()&&(i=l(t.children,n)),i}function h(t){return new w(function(n,i){if(!e.isObject(t))return i(new Error("Invalid Promise"));e.isFunction(t.then)&&t.then(n),e.isFunction(t.error)?t.error(i):e.isFunction(t.catch)&&t.catch(i)})}function d(t,n){var i={};return(n=e.castArray(n)).push("ref"),e.each(t,function(t,r){e.includes(n,r)||(i[r]=e.cloneDeep(t))}),i}function f(t,n,i){n.id=n.id||b(),"string"!=typeof n.id&&"number"!=typeof n.id&&(n.id=n.id.toString());var r=n.itree=n.itree||{};r.icon=r.icon||!1,r.dirty=!1;var s=r.li=r.li||{};s.attributes=s.attributes||{};var o=r.a=r.a||{};o.attributes=o.attributes||{};var a=r.state=r.state||{};return a.collapsed="boolean"==typeof a.collapsed?a.collapsed:t.defaultState.collapsed,a.selectable="boolean"==typeof a.selectable?a.selectable:t.defaultState.selectable,a.draggable="boolean"==typeof a.draggable?a.draggable:t.defaultState.draggable,a["drop-target"]="boolean"==typeof a["drop-target"]?a["drop-target"]:t.defaultState["drop-target"],a.checked="boolean"==typeof a.checked&&a.checked,a.editable="boolean"==typeof a.editable?a.editable:t.defaultState.editable,a.editing="boolean"==typeof a.editing?a.editing:t.defaultState.editing,a.focused=a.focused||t.defaultState.focused,a.hidden=a.hidden||t.defaultState.hidden,a.indeterminate=a.indeterminate||t.defaultState.indeterminate,a.loading=a.loading||t.defaultState.loading,a.removed=a.removed||t.defaultState.removed,a.rendered=a.rendered||t.defaultState.rendered,a.selected=a.selected||t.defaultState.selected,n.itree.parent=i,n=e.assign(new S(t),n),e.isArrayLike(n.children)&&(n.children=v(t,n.children,n)),t.allowsLoadEvents&&e.each(t.config.allowLoadEvents,function(e){a[e]&&t.emit("node."+e,n,!0)}),n}function v(t,n,i){var r=new P(t);return t.config.sort&&(n=e.sortBy(n,t.config.sort)),e.each(n,function(e){r.push(f(t,e,i))}),r._context=i,r}function y(e,t,n){return e.model[t].apply(e.model,n)}for(var p="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},k=n(function(e){var t="undefined"!=typeof crypto&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&msCrypto.getRandomValues.bind(msCrypto);if(t){var n=new Uint8Array(16);e.exports=function(){return t(n),n}}else{var i=new Array(16);e.exports=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),i[t]=e>>>((3&t)<<3)&255;return i}}}),_=[],g=0;g<256;++g)_[g]=(g+256).toString(16).substr(1);var m=i,b=r,w=n(function(e,n){/*!
* @overview es6-promise - a tiny implementation of Promises/A+.
* @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
* @license Licensed under MIT license
* See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE
* @version v4.2.2+97478eb6
*/
!function(n,i){e.exports=function(){function e(e){var t=typeof e;return null!==e&&("object"===t||"function"===t)}function n(e){return"function"==typeof e}function i(e){q=e}function r(e){H=e}function s(){return void 0!==U?function(){U(a)}:o()}function o(){var e=setTimeout;return function(){return e(a,1)}}function a(){for(var e=0;e<R;e+=2)(0,J[e])(J[e+1]),J[e]=void 0,J[e+1]=void 0;R=0}function u(e,t){var n=this,i=new this.constructor(l);void 0===i[X]&&E(i);var r=n._state;if(r){var s=arguments[r-1];H(function(){return C(r,i,s,n._result)})}else x(n,i,e,t);return i}function c(e){var t=this;if(e&&"object"==typeof e&&e.constructor===t)return e;var n=new t(l);return g(n,e),n}function l(){}function h(){return new TypeError("You cannot resolve a promise with itself")}function d(){return new TypeError("A promises callback cannot return that same promise.")}function f(e){try{return e.then}catch(e){return te.error=e,te}}function v(e,t,n,i){try{e.call(t,n,i)}catch(e){return e}}function y(e,t,n){H(function(e){var i=!1,r=v(n,t,function(n){i||(i=!0,t!==n?g(e,n):b(e,n))},function(t){i||(i=!0,w(e,t))},"Settle: "+(e._label||" unknown promise"));!i&&r&&(i=!0,w(e,r))},e)}function k(e,t){t._state===$?b(e,t._result):t._state===ee?w(e,t._result):x(t,void 0,function(t){return g(e,t)},function(t){return w(e,t)})}function _(e,t,i){t.constructor===e.constructor&&i===u&&t.constructor.resolve===c?k(e,t):i===te?(w(e,te.error),te.error=null):void 0===i?b(e,t):n(i)?y(e,t,i):b(e,t)}function g(t,n){t===n?w(t,h()):e(n)?_(t,n,f(n)):b(t,n)}function m(e){e._onerror&&e._onerror(e._result),D(e)}function b(e,t){e._state===Z&&(e._result=t,e._state=$,0!==e._subscribers.length&&H(D,e))}function w(e,t){e._state===Z&&(e._state=ee,e._result=t,H(m,e))}function x(e,t,n,i){var r=e._subscribers,s=r.length;e._onerror=null,r[s]=t,r[s+$]=n,r[s+ee]=i,0===s&&e._state&&H(D,e)}function D(e){var t=e._subscribers,n=e._state;if(0!==t.length){for(var i=void 0,r=void 0,s=e._result,o=0;o<t.length;o+=3)i=t[o],r=t[o+n],i?C(n,i,r,s):r(s);e._subscribers.length=0}}function A(){this.error=null}function L(e,t){try{return e(t)}catch(e){return ne.error=e,ne}}function C(e,t,i,r){var s=n(i),o=void 0,a=void 0,u=void 0,c=void 0;if(s){if(o=L(i,r),o===ne?(c=!0,a=o.error,o.error=null):u=!0,t===o)return void w(t,d())}else o=r,u=!0;t._state!==Z||(s&&u?g(t,o):c?w(t,a):e===$?b(t,o):e===ee&&w(t,o))}function P(e,t){try{t(function(t){g(e,t)},function(t){w(e,t)})}catch(t){w(e,t)}}function S(){return ie++}function E(e){e[X]=ie++,e._state=void 0,e._result=void 0,e._subscribers=[]}function O(){return new Error("Array Methods must be provided an Array")}function j(e){return new re(this,e).promise}function N(e){var t=this;return new t(B(e)?function(n,i){for(var r=e.length,s=0;s<r;s++)t.resolve(e[s]).then(n,i)}:function(e,t){return t(new TypeError("You must pass an array to race."))})}function T(e){var t=new this(l);return w(t,e),t}function M(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function F(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function V(){var e=void 0;if(void 0!==p)e=p;else if("undefined"!=typeof self)e=self;else try{e=Function("return this")()}catch(e){throw new Error("polyfill failed because global object is unavailable in this environment")}var t=e.Promise;if(t){var n=null;try{n=Object.prototype.toString.call(t.resolve())}catch(e){}if("[object Promise]"===n&&!t.cast)return}e.Promise=se}var I=void 0,B=I=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},R=0,U=void 0,q=void 0,H=function(e,t){J[R]=e,J[R+1]=t,2===(R+=2)&&(q?q(a):Q())},W="undefined"!=typeof window?window:void 0,z=W||{},Y=z.MutationObserver||z.WebKitMutationObserver,K="undefined"==typeof self&&"undefined"!=typeof process&&"[object process]"==={}.toString.call(process),G="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,J=new Array(1e3),Q=void 0;Q=K?function(){return function(){return process.nextTick(a)}}():Y?function(){var e=0,t=new Y(a),n=document.createTextNode("");return t.observe(n,{characterData:!0}),function(){n.data=e=++e%2}}():G?function(){var e=new MessageChannel;return e.port1.onmessage=a,function(){return e.port2.postMessage(0)}}():void 0===W&&"function"==typeof t?function(){try{var e=t("vertx");return U=e.runOnLoop||e.runOnContext,s()}catch(e){return o()}}():o();var X=Math.random().toString(36).substring(16),Z=void 0,$=1,ee=2,te=new A,ne=new A,ie=0,re=function(){function e(e,t){this._instanceConstructor=e,this.promise=new e(l),this.promise[X]||E(this.promise),B(t)?(this.length=t.length,this._remaining=t.length,this._result=new Array(this.length),0===this.length?b(this.promise,this._result):(this.length=this.length||0,this._enumerate(t),0===this._remaining&&b(this.promise,this._result))):w(this.promise,O())}return e.prototype._enumerate=function(e){for(var t=0;this._state===Z&&t<e.length;t++)this._eachEntry(e[t],t)},e.prototype._eachEntry=function(e,t){var n=this._instanceConstructor,i=n.resolve;if(i===c){var r=f(e);if(r===u&&e._state!==Z)this._settledAt(e._state,t,e._result);else if("function"!=typeof r)this._remaining--,this._result[t]=e;else if(n===se){var s=new n(l);_(s,e,r),this._willSettleAt(s,t)}else this._willSettleAt(new n(function(t){return t(e)}),t)}else this._willSettleAt(i(e),t)},e.prototype._settledAt=function(e,t,n){var i=this.promise;i._state===Z&&(this._remaining--,e===ee?w(i,n):this._result[t]=n),0===this._remaining&&b(i,this._result)},e.prototype._willSettleAt=function(e,t){var n=this;x(e,void 0,function(e){return n._settledAt($,t,e)},function(e){return n._settledAt(ee,t,e)})},e}(),se=function(){function e(t){this[X]=S(),this._result=this._state=void 0,this._subscribers=[],l!==t&&("function"!=typeof t&&M(),this instanceof e?P(this,t):F())}return e.prototype.catch=function(e){return this.then(null,e)},e.prototype.finally=function(e){var t=this,n=t.constructor;return t.then(function(t){return n.resolve(e()).then(function(){return t})},function(t){return n.resolve(e()).then(function(){throw t})})},e}();return se.prototype.then=u,se.all=j,se.race=N,se.resolve=c,se.reject=T,se._setScheduler=i,se._setAsap=r,se._asap=H,se.polyfill=V,se.Promise=se,se}()}()}).Promise,x=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},D=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),A=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},L=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},C=function(e){return Array.isArray(e)?e:Array.from(e)},P=function(t){function n(t,i){x(this,n);var r=L(this,(n.__proto__||Object.getPrototypeOf(n)).call(this));if(e.isFunction(e.get(t,"isTree"))&&!t.isTree(t))throw new TypeError("Invalid tree instance.");return r._tree=t,r.length=0,r._pagination={limit:t.config.pagination.limit,total:0},(e.isArray(i)||i instanceof n)&&e.each(i,function(e){e instanceof S?r.push(e.clone()):r.addNode(e)}),r}return A(n,t),D(n,[{key:"addNode",value:function(t){var n=this.length;return this._tree.config.sort&&(n=e.sortedIndexBy(this,t,this._tree.config.sort)),this.insertAt(n,t)}},{key:"available",value:function(e){return a.call(this,"available",e)}},{key:"blur",value:function(){return this.invoke("blur")}},{key:"blurDeep",value:function(){return this.invokeDeep("blur")}},{key:"checked",value:function(e){return a.call(this,"checked",e)}},{key:"clean",value:function(){return this.invoke("clean")}},{key:"clone",value:function(){return new n(this._tree,this)}},{key:"collapse",value:function(){return this.invoke("collapse")}},{key:"collapsed",value:function(e){return a.call(this,"collapsed",e)}},{key:"collapseDeep",value:function(){return this.invokeDeep("collapse")}},{key:"concat",value:function(t){var i=new n(this._tree);i._context=this._context;var r=function(e){e instanceof S&&i.push(e)};return e.each(this,r),e.each(t,r),i._pagination.limit=this._pagination.limit,i}},{key:"context",value:function(){return this._context||this._tree}},{key:"copy",value:function(t){var i=this;return{to:function(r){if(!e.isFunction(r.addNodes))throw new Error("Destination must be an Inspire Tree instance.");var s=new n(i._tree);return e.each(i,function(e){s.push(e.copy(t).to(r))}),s}}}},{key:"deepest",value:function(){var e=new n(this._tree);return this.recurseDown(function(t){t.children||e.push(t)}),e}},{key:"deselect",value:function(){return this.invoke("deselect")}},{key:"deselectDeep",value:function(){return this.invokeDeep("deselect")}},{key:"each",value:function(t){return e.each(this,t),this}},{key:"editable",value:function(e){return a.call(this,"editable",e)}},{key:"editing",value:function(e){return a.call(this,"editing",e)}},{key:"expand",value:function(){return this.invoke("expand")}},{key:"expanded",value:function(e){return a.call(this,"expanded",e)}},{key:"expandDeep",value:function(){var e=this;return new w(function(t){var n=0,i=function(){0==--n&&t(e)};e.recurseDown(function(e){n++,e.children?e.expand().catch(i).then(function(){e.children.expandDeep().catch(i).then(i)}):i()})})}},{key:"expandParents",value:function(){return this.invoke("expandParents")}},{key:"extract",value:function(t){var i=this.flatten(t),r=new n(this._tree);return e.each(i,function(e){r.addNode(e.copyHierarchy())}),r}},{key:"filterBy",value:function(t){var i=c(t),r=new n(this._tree);return e.each(this,function(e){i(e)&&r.push(e)}),r}},{key:"flatten",value:function(e){var t=new n(this._tree),i=c(e);return this.recurseDown(function(e){i(e)&&t.push(e)}),t}},{key:"focused",value:function(e){return a.call(this,"focused",e)}},{key:"forEach",value:function(e){return this.each(e)}},{key:"get",value:function(e){return this[e]}},{key:"hidden",value:function(e){return a.call(this,"hidden",e)}},{key:"hide",value:function(){return this.invoke("hide")}},{key:"hideDeep",value:function(){return this.invokeDeep("hide")}},{key:"indeterminate",value:function(e){return a.call(this,"indeterminate",e)}},{key:"insertAt",value:function(t,i){if(i.id){var r=this.node(i.id);if(r)return r.restore().show(),e.isArrayLike(i.children)?(e.isArrayLike(r.children)||(r.children=new n(this._tree),r.children._context=r),e.each(i.children,function(e){r.children.addNode(e)})):i.children&&e.isBoolean(r.children)&&(r.children=i.children),r.markDirty(),this._tree.applyChanges(),r}var s=this._tree.constructor.isTreeNode(i)?i:f(this._tree,i);return this.splice(t,0,s),this._context&&(s.itree.parent=this._context,this._context.refreshIndeterminateState().markDirty()),this._tree.emit("node.added",s),s.markDirty(),this.length-1!==t&&this.invoke("markDirty"),this._tree.applyChanges(),s}},{key:"invoke",value:function(e,t){return u(this,e,t)}},{key:"invokeDeep",value:function(e,t){return u(this,e,t,!0)}},{key:"loading",value:function(e){return a.call(this,"loading",e)}},{key:"loadMore",value:function(t){var n=this;if(this._loading)return w.reject(new Error("Pending loadMore call must complete before being invoked again."));var i=void 0;return this._pagination.limit===this._pagination.total?w.resolve():(this._loading=!0,this._tree.batch(),e.invoke(this._context,"markDirty"),this._pagination.limit+=this._tree.config.pagination.limit,this._tree.emit("node.paginated",this._context||this._tree,this.pagination,t),this._tree.config.deferredLoading?i=this._context?this._context.loadChildren():this._tree.load(this._tree.config.data):(this._loading=!1,i=w.resolve()),this._tree.end(),this._tree.config.deferredLoading&&i.then(function(){n._loading=!1,n._tree.applyChanges()}).catch(function(){n._loading=!1,n._tree.applyChanges()}),i)}},{key:"matched",value:function(e){return a.call(this,"matched",e)}},{key:"move",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this;this._tree.batch();var i=this[e].remove(),r=n.insertAt(t,i);return this._tree.emit("node.moved",r,this,e,n,t),this._tree.end(),r}},{key:"node",value:function(e){var t=void 0;return this.recurseDown(function(n){if(n.id===e)return t=n,!1}),t}},{key:"nodes",value:function(t){var i=void 0;return e.isArray(t)&&(i=new n(this._tree),this.recurseDown(function(e){t.indexOf(e.id)>-1&&i.push(e)})),e.isArray(t)?i:this}},{key:"pagination",value:function(){return this._pagination}},{key:"recurseDown",value:function(e){return l(this,e),this}},{key:"remove",value:function(t){return e.remove(this,{id:t.id}),e.invoke(this._context,"markDirty"),this._tree.applyChanges(),this}},{key:"removed",value:function(e){return a.call(this,"removed",e)}},{key:"restore",value:function(){return this.invoke("restore")}},{key:"restoreDeep",value:function(){return this.invokeDeep("restore")}},{key:"select",value:function(){return this.invoke("select")}},{key:"selectable",value:function(e){return a.call(this,"selectable",e)}},{key:"selectDeep",value:function(){return this.invokeDeep("select")}},{key:"selected",value:function(e){return a.call(this,"selected",e)}},{key:"show",value:function(){return this.invoke("show")}},{key:"showDeep",value:function(){return this.invokeDeep("show")}},{key:"softRemove",value:function(){return this.invoke("softRemove")}},{key:"sortBy",value:function(t){var n=this;if(t=t||this._tree.config.sort){var i=e.sortBy(this,t);this.length=0,e.each(i,function(e){n.push(e)})}return this}},{key:"state",value:function(){return this.invoke("state",arguments)}},{key:"stateDeep",value:function(){return this.invokeDeep("state",arguments)}},{key:"swap",value:function(e,t){this._tree.batch();var n=e.context(),i=t.context(),r=n.indexOf(e),s=i.indexOf(t);return n===i?(this[r]=t,this[s]=e,this._tree.emit("node.moved",e,n,r,i,s),this._tree.emit("node.moved",t,i,s,n,r)):(n.move(r,i.indexOf(t),i),i.move(i.indexOf(t),r,n)),this._tree.end(),this._tree.emit("node.swapped",e,n,r,t,i,s),this}},{key:"tree",value:function(){return this._tree}},{key:"toArray",value:function(){var t=[];return e.each(this,function(e){t.push(e.toObject())}),t}},{key:"visible",value:function(e){return a.call(this,"visible",e)}}]),n}(function(e){function t(){e.apply(this,arguments)}return t.prototype=Object.create(e.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e,t}(Array)),S=function(){function t(n,i,r){var s=this;x(this,t),this._tree=n,i instanceof t&&((r=e.castArray(r)).push("_tree"),e.each(i,function(t,n){e.includes(r,n)||(e.isObject(t)?s[n]=t instanceof P?t.clone():"itree"===n?d(t):e.cloneDeep(t):s[n]=t)}))}return D(t,[{key:"addChild",value:function(t){return!e.isArray(this.children)&&e.isArrayLike(this.children)||(this.children=new P(this._tree),this.children._context=this),this.children.addNode(t)}},{key:"addChildren",value:function(t){var n=this,i=new P(this._tree);return this._tree.batch(),e.each(t,function(e){i.push(n.addChild(e))}),this._tree.end(),i}},{key:"allowDynamicLoad",value:function(){return this._tree.isDynamic&&(e.isArrayLike(this.children)||!0===this.children)}},{key:"available",value:function(){return!this.hidden()&&!this.removed()}},{key:"blur",value:function(){return this.state("editing",!1),o("focused",!1,"blurred",this)}},{key:"check",value:function(e){return this._tree.batch(),o("checked",!0,"checked",this,!e&&this._tree.config.checkbox.autoCheckChildren),this.state("indeterminate",!1),this.hasParent()&&this.getParent().refreshIndeterminateState(),this._tree.end(),this}},{key:"checked",value:function(){return this.state("checked")}},{key:"clean",value:function(){return this.recurseUp(function(e){if(e.hasParent()){var t=e.getParent();t.hasVisibleChildren()||t.hide()}}),this}},{key:"clone",value:function(e){return new t(this._tree,this,e)}},{key:"collapse",value:function(){return o("collapsed",!0,"collapsed",this)}},{key:"collapsed",value:function(){return this.state("collapsed")}},{key:"context",value:function(){return this.hasParent()?this.getParent().children:this._tree.model}},{key:"copy",value:function(t){var n=this;return t&&(n=n.copyHierarchy()),{to:function(t){if(!e.isFunction(t.addNode))throw new Error("Destination must be an Inspire Tree instance.");return t.addNode(n.toObject())}}}},{key:"copyHierarchy",value:function(t){var n=[],i=this.getParents();if(e.each(i,function(e){n.push(e.toObject(t))}),i=n.reverse(),!t){var r=this.toObject(!0);this.hasChildren()&&(r.children=this.children.filterBy(function(e){return!e.state("hidden")}).toArray(),r.children._context=r),n.push(r)}var s=n[0],o=s,a=n.length;return e.each(n,function(e,t){var i=[];t+1<a&&(i.push(n[t+1]),o.children=i,o=o.children[0])}),f(this._tree,s)}},{key:"deselect",value:function(e){return this.selected()&&(!this._tree.config.selection.require||this._tree.selected().length>1)&&(this._tree.batch(),o("selected",!1,"deselected",this,!e&&this._tree.config.selection.autoSelectChildren),this._tree.end()),this}},{key:"editable",value:function(){return this._tree.config.editable&&this._tree.config.editing.edit&&this.state("editable")}},{key:"editing",value:function(){return this.state("editing")}},{key:"expand",value:function(){var e=this;return new w(function(t,n){(e.hasChildren()||e._tree.isDynamic&&!0===e.children)&&(e.collapsed()||e.hidden())?(e.state("collapsed",!1),e.state("hidden",!1),e._tree.emit("node.expanded",e),e._tree.isDynamic&&!0===e.children?e.loadChildren().then(t).catch(n):(e.markDirty(),e._tree.applyChanges(),t(e))):t(e)})}},{key:"expanded",value:function(){return!this.collapsed()}},{key:"expandParents",value:function(){return this.hasParent()&&this.getParent().recurseUp(function(e){e.expand()}),this}},{key:"focus",value:function(){return this.focused()||(this._tree.batch(),this._tree.blurDeep(),this.state("focused",!0),this._tree.emit("node.focused",this),this.markDirty(),this._tree.end()),this}},{key:"focused",value:function(){return this.state("focused")}},{key:"getChildren",value:function(){return this.hasChildren()?this.children:new P(this._tree)}},{key:"getParent",value:function(){return this.itree.parent}},{key:"getParents",value:function(){var e=new P(this._tree);return this.hasParent()&&this.getParent().recurseUp(function(t){e.push(t)}),e}},{key:"getTextualHierarchy",value:function(){var e=[];return this.recurseUp(function(t){e.unshift(t.text)}),e}},{key:"hasAncestor",value:function(e){var t=!1;return this.recurseUp(function(n){return!(t=n.id===e.id)}),t}},{key:"hasChildren",value:function(){return e.isArrayLike(this.children)&&this.children.length>0}},{key:"hasLoadedChildren",value:function(){return e.isArrayLike(this.children)}},{key:"hasOrWillHaveChildren",value:function(){return e.isArrayLike(this.children)?Boolean(this.children.length):this.allowDynamicLoad()}},{key:"hasParent",value:function(){return Boolean(this.itree.parent)}},{key:"hasVisibleChildren",value:function(){var e=!1;return this.hasChildren()&&(e=this.children.filterBy("available").length>0),e}},{key:"hide",value:function(){var e=o("hidden",!0,"hidden",this);return e.hasChildren()&&e.children.hide(),e}},{key:"hidden",value:function(){return this.state("hidden")}},{key:"indexPath",value:function(){var t=[];return this.recurseUp(function(n){t.push(e.indexOf(n.context(),n))}),t.reverse().join(".")}},{key:"indeterminate",value:function(){return this.state("indeterminate")}},{key:"lastDeepestVisibleChild",value:function(){var t=void 0;if(this.hasChildren()&&!this.collapsed()){var n=(t=e.findLast(this.children,function(e){return e.visible()})).lastDeepestVisibleChild();n&&(t=n)}return t}},{key:"loadChildren",value:function(){var t=this;return new w(function(n,i){if(!t.allowDynamicLoad())return i(new Error("Node does not have or support dynamic children."));t.state("loading",!0),t.markDirty(),t._tree.applyChanges();var r=function(r,s){if(!e.isArrayLike(r))return i(new TypeError("Loader requires an array-like `nodes` parameter."));t._tree.batch(),t.state("loading",!1);var o=v(t._tree,r,t);e.isArrayLike(t.children)?t.children=t.children.concat(o):t.children=o,e.parseInt(s)>r.length&&(t.children._pagination.total=e.parseInt(s)),"checkbox"===t._tree.config.selection.mode&&t.selected()&&t.children.select(),t.markDirty(),t._tree.end(),n(t.children),t._tree.emit("children.loaded",t)},s=function(e){t.state("loading",!1),t.children=new P(t._tree),t.children._context=t,t.markDirty(),t._tree.applyChanges(),i(e),t._tree.emit("tree.loaderror",e)},o=t._tree.constructor.isTreeNodes(t.children)?t.children.pagination():null,a=t._tree.config.data(t,r,s,o);e.isObject(a)&&h(a).then(r).catch(s)})}},{key:"loading",value:function(){return this.state("loading")}},{key:"loadMore",value:function(){return this.children&&!0!==this.children?this.children.loadMore():w.reject(new Error("Children have not yet been loaded."))}},{key:"markDirty",value:function(){return this.itree.dirty||(this.itree.dirty=!0,this.hasParent()&&this.getParent().markDirty()),this}},{key:"matched",value:function(){return this.state("matched")}},{key:"nextVisibleAncestralSiblingNode",value:function(){var e=void 0;if(this.hasParent()){var t=this.getParent();(e=t.nextVisibleSiblingNode())||(e=t.nextVisibleAncestralSiblingNode())}return e}},{key:"nextVisibleChildNode",value:function(){var t=void 0;return this.hasChildren()&&(t=e.find(this.children,function(e){return e.visible()})),t}},{key:"nextVisibleNode",value:function(){var e=void 0;return(e=this.nextVisibleChildNode())||(e=this.nextVisibleSiblingNode()),e||(e=this.nextVisibleAncestralSiblingNode()),e}},{key:"nextVisibleSiblingNode",value:function(){var t=this.hasParent()?this.getParent().children:this._tree.nodes(),n=e.findIndex(t,{id:this.id});return e.find(e.slice(t,n+1),function(e){return e.visible()})}},{key:"pagination",value:function(){return e.get(this,"children._pagination")}},{key:"previousVisibleNode",value:function(){var e=void 0;return(e=this.previousVisibleSiblingNode())&&e.hasChildren()&&!e.collapsed()&&(e=e.lastDeepestVisibleChild()),!e&&this.hasParent()&&(e=this.getParent()),e}},{key:"previousVisibleSiblingNode",value:function(){var t=this.hasParent()?this.getParent().children:this._tree.nodes(),n=e.findIndex(t,{id:this.id});return e.findLast(e.slice(t,0,n),function(e){return e.visible()})}},{key:"recurseDown",value:function(e){return l(this,e),this}},{key:"recurseUp",value:function(e){return!1!==e(this)&&this.hasParent()&&this.getParent().recurseUp(e),this}},{key:"refreshIndeterminateState",value:function(){var e=this.indeterminate();if(this.state("indeterminate",!1),this.hasChildren()){var t=this.children.length,n=0,i=0;this.children.each(function(e){e.checked()&&i++,e.indeterminate()&&n++}),i===t?o("checked",!0,"checked",this):o("checked",!1,"unchecked",this),this.checked()||this.state("indeterminate",n>0||t>0&&i>0&&i<t)}return this.hasParent()&&this.getParent().refreshIndeterminateState(),e!==this.state("indeterminate")&&this.markDirty(),this}},{key:"reload",value:function(){var e=this;return new w(function(t,n){if(!e.allowDynamicLoad())return n(new Error("Node or tree does not support dynamic children."));e.children=!0,e.collapse(),e.loadChildren().then(t).catch(n)})}},{key:"remove",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.getParent();this.context().remove(this),t&&(t.refreshIndeterminateState(),t.markDirty()),(t?t.pagination():this._tree.pagination()).total--;var n=this.toObject(!1,e);return this._tree.emit("node.removed",n,t),this._tree.applyChanges(),n}},{key:"removed",value:function(){return this.state("removed")}},{key:"rendered",value:function(){return this.state("rendered")}},{key:"restore",value:function(){return o("removed",!1,"restored",this)}},{key:"select",value:function(e){if(!this.selected()&&this.selectable()){if(this._tree.batch(),this._tree.canAutoDeselect()){var t=this._tree.config.selection.require;this._tree.config.selection.require=!1,this._tree.deselectDeep(),this._tree.config.selection.require=t}o("selected",!0,"selected",this,!e&&this._tree.config.selection.autoSelectChildren),this._tree._lastSelectedNode=this,this.markDirty(),this._tree.end()}return this}},{key:"selectable",value:function(){var e=this._tree.config.selection.allow(this);return"boolean"==typeof e?e:this.state("selectable")}},{key:"selected",value:function(){return this.state("selected")}},{key:"set",value:function(e,t){return this[e]=t,this.markDirty(),this._tree.applyChanges(),this}},{key:"show",value:function(){return o("hidden",!1,"shown",this)}},{key:"state",value:function(e,t){var n=this.itree.state[e];return void 0!==t&&n!==t&&(this.itree.state[e]=t,"rendered"!==e&&this.markDirty(),this._tree.emit("node.state.changed",this,e,n,t)),n}},{key:"states",value:function(t,n){var i=this,r=[];return this._tree.batch(),e.each(t,function(e){r.push(i.state(e,n))}),this._tree.end(),r}},{key:"swap",value:function(e){return this.context().swap(this,e),this}},{key:"softRemove",value:function(){return o("removed",!0,"softremoved",this,"softRemove")}},{key:"toggleCheck",value:function(){return this.checked()?this.uncheck():this.check()}},{key:"toggleCollapse",value:function(){return this.collapsed()?this.expand():this.collapse()}},{key:"toggleEditing",value:function(){return this.state("editing",!this.state("editing")),this.markDirty(),this._tree.applyChanges(),this}},{key:"toggleSelect",value:function(){return this.selected()?this.deselect():this.select()}},{key:"toObject",value:function(){var t=this,n=arguments.length>0&&void 0!==arguments[0]&&arguments[0],i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r={},s=e.pull(Object.keys(this),"_tree","children","itree");e.each(s,function(e){r[e]=t[e]});var o=r.itree={};return o.a=this.itree.a,o.icon=this.itree.icon,o.li=this.itree.li,i&&(o.state=this.itree.state),!n&&this.hasChildren()&&e.isFunction(this.children.toArray)&&(r.children=this.children.toArray()),r}},{key:"toString",value:function(){return this.text}},{key:"tree",value:function(){return this.context().tree()}},{key:"uncheck",value:function(e){return this._tree.batch(),o("checked",!1,"unchecked",this,!e&&this._tree.config.checkbox.autoCheckChildren),this.state("indeterminate",!1),this.hasParent()&&this.getParent().refreshIndeterminateState(),this._tree.end(),this}},{key:"visible",value:function(){return!(this.hidden()||this.removed()||this._tree.usesNativeDOM&&!this.rendered())&&(!this.hasParent()||!this.getParent().collapsed()&&this.getParent().visible())}}]),t}();return function(t){function n(t){x(this,n);var i=L(this,(n.__proto__||Object.getPrototypeOf(n)).call(this)),r=i;r._lastSelectedNode,r._muted=!1,r.allowsLoadEvents=!1,r.batching=0,r.id=b(),r.initialized=!1,r.isDynamic=!1,r.opts=t,r.preventDeselection=!1,r.config=e.defaultsDeep({},t,{allowLoadEvents:[],checkbox:{autoCheckChildren:!0},contextMenu:!1,data:!1,editable:!1,editing:{add:!1,edit:!1,remove:!1},nodes:{resetStateOnRestore:!0},pagination:{limit:-1},renderer:!1,search:{matcher:!1,matchProcessor:!1},selection:{allow:e.noop,autoDeselect:!0,autoSelectChildren:!1,disableDirectDeselection:!1,mode:"default",multiple:!1,require:!1},showCheckboxes:!1,sort:!1}),"checkbox"===r.config.selection.mode&&(r.config.selection.autoSelectChildren=!0,r.on("node.checked",function(e){e.selected()||e.select(!0)}),r.on("node.selected",function(e){e.checked()||e.check(!0)}),r.on("node.unchecked",function(e){e.selected()&&e.deselect(!0)}),r.on("node.deselected",function(e){e.checked()&&e.uncheck(!0)})),r.config.selection.autoSelectChildren&&(r.config.selection.multiple=!0,r.config.selection.autoDeselect=!1),t.editable&&!t.editing&&(r.config.editing.add=!0,r.config.editing.edit=!0,r.config.editing.remove=!0),e.isFunction(t.search)&&(r.config.search={matcher:t.search,matchProcessor:!1}),r.defaultState={collapsed:!0,editable:e.get(r,"config.editing.edit"),editing:!1,draggable:!0,"drop-target":!0,focused:!1,hidden:!1,indeterminate:!1,loading:!1,matched:!1,removed:!1,rendered:!1,selectable:!0,selected:!1},r.allowsLoadEvents=e.isArray(r.config.allowLoadEvents)&&r.config.allowLoadEvents.length>0,r.isDynamic=e.isFunction(r.config.data);var s=r.emit;return r.emit=function(t){if(!r.isEventMuted(t)){if(e.isFunction(e.get(arguments,"[1].preventDefault"))){var n=arguments[1];n.treeDefaultPrevented=!1,n.preventTreeDefault=function(){n.treeDefaultPrevented=!0}}s.apply(r,arguments)}},r.model=new P(r),r.config.data&&r.load(r.config.data),r.initialized=!0,i}return A(n,t),D(n,[{key:"addNode",value:function(){return y(this,"addNode",arguments)}},{key:"addNodes",value:function(t){var n=this;this.batch();var i=new P(this);return e.each(t,function(e){i.push(n.addNode(e))}),this.end(),i}},{key:"applyChanges",value:function(){this.batching>0||this.emit("changes.applied")}},{key:"available",value:function(){return y(this,"available",arguments)}},{key:"batch",value:function(){this.batching<0&&(this.batching=0),this.batching++}},{key:"blur",value:function(){return y(this,"blur",arguments)}},{key:"blurDeep",value:function(){return y(this,"blurDeep",arguments)}},{key:"boundingNodes",value:function(){var t=e.transform(arguments,function(e,t){e[t.indexPath().replace(/\./g,"")]=t},{}),n=e.sortBy(Object.keys(t)),i=C(n),r=i[0],s=i.slice(1);return[e.get(t,r),e.get(t,s)]}},{key:"canAutoDeselect",value:function(){return this.config.selection.autoDeselect&&!this.preventDeselection}},{key:"checked",value:function(){return y(this,"checked",arguments)}},{key:"clean",value:function(){return y(this,"clean",arguments)}},{key:"clearSearch",value:function(){return this.matched().state("matched",!1),this.showDeep().collapseDeep().tree()}},{key:"clone",value:function(){return y(this,"clone",arguments)}},{key:"collapse",value:function(){return y(this,"collapse",arguments)}},{key:"collapsed",value:function(){return y(this,"collapsed",arguments)}},{key:"collapseDeep",value:function(){return y(this,"collapseDeep",arguments)}},{key:"concat",value:function(){return y(this,"concat",arguments)}},{key:"copy",value:function(){return y(this,"copy",arguments)}},{key:"createNode",value:function(e){return n.isTreeNode(e)?e:f(this,e)}},{key:"deepest",value:function(){return y(this,"deepest",arguments)}},{key:"deselect",value:function(){return y(this,"deselect",arguments)}},{key:"deselectDeep",value:function(){return y(this,"deselectDeep",arguments)}},{key:"disableDeselection",value:function(){return this.config.selection.multiple&&(this.preventDeselection=!0),this}},{key:"each",value:function(){return y(this,"each",arguments)}},{key:"every",value:function(){return y(this,"every",arguments)}},{key:"editable",value:function(){return y(this,"editable",arguments)}},{key:"editing",value:function(){return y(this,"editing",arguments)}},{key:"enableDeselection",value:function(){return this.preventDeselection=!1,this}},{key:"end",value:function(){0===--this.batching&&this.applyChanges()}},{key:"expand",value:function(){return y(this,"expand",arguments)}},{key:"expandDeep",value:function(){return y(this,"expandDeep",arguments)}},{key:"expanded",value:function(){return y(this,"expanded",arguments)}},{key:"extract",value:function(){return y(this,"extract",arguments)}},{key:"filter",value:function(){return y(this,"filter",arguments)}},{key:"filterBy",value:function(){return y(this,"filterBy",arguments)}},{key:"flatten",value:function(){return y(this,"flatten",arguments)}},{key:"focused",value:function(){return y(this,"focused",arguments)}},{key:"forEach",value:function(){return y(this,"each",arguments)}},{key:"get",value:function(){return y(this,"get",arguments)}},{key:"hidden",value:function(){return y(this,"hidden",arguments)}},{key:"hide",value:function(){return y(this,"hide",arguments)}},{key:"hideDeep",value:function(){return y(this,"hideDeep",arguments)}},{key:"indeterminate",value:function(){return y(this,"indeterminate",arguments)}},{key:"indexOf",value:function(){return y(this,"indexOf",arguments)}},{key:"insertAt",value:function(){return y(this,"insertAt",arguments)}},{key:"invoke",value:function(){return y(this,"invoke",arguments)}},{key:"invokeDeep",value:function(){return y(this,"invokeDeep",arguments)}},{key:"isEventMuted",value:function(t){return e.isBoolean(this.muted())?this.muted():e.includes(this.muted(),t)}},{key:"isTree",value:function(e){return e instanceof n}},{key:"join",value:function(){return y(this,"join",arguments)}},{key:"lastSelectedNode",value:function(){return this._lastSelectedNode}},{key:"load",value:function(t){var n=this,i=new w(function(i,r){var s=function(t,s){if(!e.isArrayLike(t))return r(new TypeError("Loader requires an array-like `nodes` parameter."));!n.initialized&&e.isArrayLike(t)?setTimeout(function(){n.emit("data.loaded",t)}):n.emit("data.loaded",t);var o=v(n,t);n.config.deferredLoading?n.model=n.model.concat(o):n.model=o,n.model._pagination.total=t.length,e.parseInt(s)>t.length&&(n.model._pagination.total=e.parseInt(s)),s||n.model.recurseDown(function(e){e.hasChildren()&&(e.children._pagination.total=e.children.length)}),n.config.selection.require&&!n.selected().length&&n.selectFirstAvailableNode();var a=function(){n.emit("model.loaded",n.model),i(n.model),n.applyChanges()};!n.initialized&&e.isArray(t)?setTimeout(a):a()};if(e.isArrayLike(t))s(t);else if(e.isFunction(t)){var o=t(null,s,r,n.pagination());o&&(t=o)}e.isObject(t)?h(t).then(s).catch(r):error(new Error("Invalid data loader."))});return i.catch(function(e){n.emit("data.loaderror",e)}),this._loader={promise:i},i}},{key:"loading",value:function(){return y(this,"loading",arguments)}},{key:"loadMore",value:function(){return y(this,"loadMore",arguments)}},{key:"map",value:function(){return y(this,"map",arguments)}},{key:"matched",value:function(){return y(this,"matched",arguments)}},{key:"move",value:function(){return y(this,"move",arguments)}},{key:"mute",value:function(t){return e.isString(t)||e.isArray(t)?this._muted=e.castArray(t):this._muted=!0,this}},{key:"muted",value:function(){return this._muted}},{key:"node",value:function(){return y(this,"node",arguments)}},{key:"nodes",value:function(){return y(this,"nodes",arguments)}},{key:"pagination",value:function(){return y(this,"pagination",arguments)}},{key:"pop",value:function(){return y(this,"pop",arguments)}},{key:"push",value:function(){return y(this,"push",arguments)}},{key:"recurseDown",value:function(){return y(this,"recurseDown",arguments)}},{key:"reduce",value:function(){return y(this,"reduce",arguments)}},{key:"reduceRight",value:function(){return y(this,"reduceRight",arguments)}},{key:"reload",value:function(){return this.removeAll(),this.load(this.opts.data||this.config.data)}},{key:"remove",value:function(){return y(this,"remove",arguments)}},{key:"removeAll",value:function(){return this.model=new P(this),this.applyChanges(),this}},{key:"removed",value:function(){return y(this,"removed",arguments)}},{key:"restore",value:function(){return y(this,"restore",arguments)}},{key:"restoreDeep",value:function(){return y(this,"restoreDeep",arguments)}},{key:"reverse",value:function(){return y(this,"reverse",arguments)}},{key:"search",value:function(t){var i=this,r=this.config.search,s=r.matcher,o=r.matchProcessor;return!t||e.isString(t)&&e.isEmpty(t)?w.resolve(this.clearSearch()):(this.batch(),this.recurseDown(function(e){e.state("hidden",!0),e.state("matched",!1)}),this.end(),s=e.isFunction(s)?s:function(t,n){var r=new P(i);e.isString(t)&&(t=new RegExp(t,"i"));var s=void 0;s=e.isRegExp(t)?function(e){return t.test(e.text)}:t,i.model.recurseDown(function(e){e.removed()||s(e)&&r.push(e)}),n(r)},o=e.isFunction(o)?o:function(e){e.each(function(e){e.show().state("matched",!0),e.expandParents().collapse(),e.hasChildren()&&e.children.showDeep()})},new w(function(r,a){s(t,function(t){n.isTreeNodes(t)||(t=i.nodes(e.map(t,"id"))),i.batch(),o(t),i.end(),r(t)},a)}))}},{key:"select",value:function(){return y(this,"select",arguments)}},{key:"selectable",value:function(){return y(this,"selectable",arguments)}},{key:"selectBetween",value:function(e,t){this.batch();for(var n=e.nextVisibleNode();n.id!==t.id;)n.select(),n=n.nextVisibleNode();return this.end(),this}},{key:"selectDeep",value:function(){return y(this,"selectDeep",arguments)}},{key:"selected",value:function(){return y(this,"selected",arguments)}},{key:"selectFirstAvailableNode",value:function(){var e=this.model.filterBy("available").get(0);return e&&e.select(),e}},{key:"shift",value:function(){return y(this,"shift",arguments)}},{key:"show",value:function(){return y(this,"show",arguments)}},{key:"showDeep",value:function(){return y(this,"showDeep",arguments)}},{key:"slice",value:function(){return y(this,"slice",arguments)}},{key:"softRemove",value:function(){return y(this,"softRemove",arguments)}},{key:"some",value:function(){return y(this,"some",arguments)}},{key:"sort",value:function(){return y(this,"sort",arguments)}},{key:"sortBy",value:function(){return y(this,"sortBy",arguments)}},{key:"splice",value:function(){return y(this,"slice",arguments)}},{key:"state",value:function(){return y(this,"state",arguments)}},{key:"stateDeep",value:function(){return y(this,"stateDeep",arguments)}},{key:"swap",value:function(){return y(this,"swap",arguments)}},{key:"toArray",value:function(){return y(this,"toArray",arguments)}},{key:"toString",value:function(){return y(this,"toString",arguments)}},{key:"unmute",value:function(t){return e.isString(t)||e.isArray(t)?(this._muted=e.difference(this._muted,e.castArray(t)),this._muted.length||(this._muted=!1)):this._muted=!1,this}},{key:"unshift",value:function(){return y(this,"unshift",arguments)}},{key:"visible",value:function(){return y(this,"visible",arguments)}}],[{key:"isTreeNode",value:function(e){return e instanceof S}},{key:"isTreeNodes",value:function(e){return e instanceof P}}]),n}(n(function(e,t){!function(t){function n(){this._events={},this._conf&&i.call(this,this._conf)}function i(e){e?(this._conf=e,e.delimiter&&(this.delimiter=e.delimiter),this._maxListeners=e.maxListeners!==t?e.maxListeners:c,e.wildcard&&(this.wildcard=e.wildcard),e.newListener&&(this._newListener=e.newListener),e.removeListener&&(this._removeListener=e.removeListener),e.verboseMemoryLeak&&(this.verboseMemoryLeak=e.verboseMemoryLeak),this.wildcard&&(this.listenerTree={})):this._maxListeners=c}function r(e,t){var n="(node) warning: possible EventEmitter memory leak detected. "+e+" listeners added. Use emitter.setMaxListeners() to increase limit.";if(this.verboseMemoryLeak&&(n+=" Event name: "+t+"."),"undefined"!=typeof process&&process.emitWarning){var i=new Error(n);i.name="MaxListenersExceededWarning",i.emitter=this,i.count=e,process.emitWarning(i)}else console.error(n),console.trace&&console.trace()}function s(e){this._events={},this._newListener=!1,this._removeListener=!1,this.verboseMemoryLeak=!1,i.call(this,e)}function o(e,t,n,i){if(!n)return[];var r,s,a,u,c,l,h,d=[],f=t.length,v=t[i],y=t[i+1];if(i===f&&n._listeners){if("function"==typeof n._listeners)return e&&e.push(n._listeners),[n];for(r=0,s=n._listeners.length;r<s;r++)e&&e.push(n._listeners[r]);return[n]}if("*"===v||"**"===v||n[v]){if("*"===v){for(a in n)"_listeners"!==a&&n.hasOwnProperty(a)&&(d=d.concat(o(e,t,n[a],i+1)));return d}if("**"===v){(h=i+1===f||i+2===f&&"*"===y)&&n._listeners&&(d=d.concat(o(e,t,n,f)));for(a in n)"_listeners"!==a&&n.hasOwnProperty(a)&&("*"===a||"**"===a?(n[a]._listeners&&!h&&(d=d.concat(o(e,t,n[a],f))),d=d.concat(o(e,t,n[a],i))):d=a===y?d.concat(o(e,t,n[a],i+2)):d.concat(o(e,t,n[a],i)));return d}d=d.concat(o(e,t,n[v],i+1))}if((u=n["*"])&&o(e,t,u,i+1),c=n["**"])if(i<f){c._listeners&&o(e,t,c,f);for(a in c)"_listeners"!==a&&c.hasOwnProperty(a)&&(a===y?o(e,t,c[a],i+2):a===v?o(e,t,c[a],i+1):((l={})[a]=c[a],o(e,t,{"**":l},i+1)))}else c._listeners?o(e,t,c,f):c["*"]&&c["*"]._listeners&&o(e,t,c["*"],f);return d}function a(e,n){for(var i=0,s=(e="string"==typeof e?e.split(this.delimiter):e.slice()).length;i+1<s;i++)if("**"===e[i]&&"**"===e[i+1])return;for(var o=this.listenerTree,a=e.shift();a!==t;){if(o[a]||(o[a]={}),o=o[a],0===e.length)return o._listeners?("function"==typeof o._listeners&&(o._listeners=[o._listeners]),o._listeners.push(n),!o._listeners.warned&&this._maxListeners>0&&o._listeners.length>this._maxListeners&&(o._listeners.warned=!0,r.call(this,o._listeners.length,a))):o._listeners=n,!0;a=e.shift()}return!0}var u=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},c=10;s.EventEmitter2=s,s.prototype.delimiter=".",s.prototype.setMaxListeners=function(e){e!==t&&(this._maxListeners=e,this._conf||(this._conf={}),this._conf.maxListeners=e)},s.prototype.event="",s.prototype.once=function(e,t){return this._once(e,t,!1)},s.prototype.prependOnceListener=function(e,t){return this._once(e,t,!0)},s.prototype._once=function(e,t,n){return this._many(e,1,t,n),this},s.prototype.many=function(e,t,n){return this._many(e,t,n,!1)},s.prototype.prependMany=function(e,t,n){return this._many(e,t,n,!0)},s.prototype._many=function(e,t,n,i){function r(){return 0==--t&&s.off(e,r),n.apply(this,arguments)}var s=this;if("function"!=typeof n)throw new Error("many only accepts instances of Function");return r._origin=n,this._on(e,r,i),s},s.prototype.emit=function(){this._events||n.call(this);var e=arguments[0];if("newListener"===e&&!this._newListener&&!this._events.newListener)return!1;var t,i,r,s,a,u=arguments.length;if(this._all&&this._all.length){if(a=this._all.slice(),u>3)for(t=new Array(u),s=0;s<u;s++)t[s]=arguments[s];for(r=0,i=a.length;r<i;r++)switch(this.event=e,u){case 1:a[r].call(this,e);break;case 2:a[r].call(this,e,arguments[1]);break;case 3:a[r].call(this,e,arguments[1],arguments[2]);break;default:a[r].apply(this,t)}}if(this.wildcard){a=[];var c="string"==typeof e?e.split(this.delimiter):e.slice();o.call(this,a,c,this.listenerTree,0)}else{if("function"==typeof(a=this._events[e])){switch(this.event=e,u){case 1:a.call(this);break;case 2:a.call(this,arguments[1]);break;case 3:a.call(this,arguments[1],arguments[2]);break;default:for(t=new Array(u-1),s=1;s<u;s++)t[s-1]=arguments[s];a.apply(this,t)}return!0}a&&(a=a.slice())}if(a&&a.length){if(u>3)for(t=new Array(u-1),s=1;s<u;s++)t[s-1]=arguments[s];for(r=0,i=a.length;r<i;r++)switch(this.event=e,u){case 1:a[r].call(this);break;case 2:a[r].call(this,arguments[1]);break;case 3:a[r].call(this,arguments[1],arguments[2]);break;default:a[r].apply(this,t)}return!0}if(!this._all&&"error"===e)throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.");return!!this._all},s.prototype.emitAsync=function(){this._events||n.call(this);var e=arguments[0];if("newListener"===e&&!this._newListener&&!this._events.newListener)return Promise.resolve([!1]);var t,i,r,s,a,u=[],c=arguments.length;if(this._all){if(c>3)for(t=new Array(c),s=1;s<c;s++)t[s]=arguments[s];for(r=0,i=this._all.length;r<i;r++)switch(this.event=e,c){case 1:u.push(this._all[r].call(this,e));break;case 2:u.push(this._all[r].call(this,e,arguments[1]));break;case 3:u.push(this._all[r].call(this,e,arguments[1],arguments[2]));break;default:u.push(this._all[r].apply(this,t))}}if(this.wildcard){a=[];var l="string"==typeof e?e.split(this.delimiter):e.slice();o.call(this,a,l,this.listenerTree,0)}else a=this._events[e];if("function"==typeof a)switch(this.event=e,c){case 1:u.push(a.call(this));break;case 2:u.push(a.call(this,arguments[1]));break;case 3:u.push(a.call(this,arguments[1],arguments[2]));break;default:for(t=new Array(c-1),s=1;s<c;s++)t[s-1]=arguments[s];u.push(a.apply(this,t))}else if(a&&a.length){if(a=a.slice(),c>3)for(t=new Array(c-1),s=1;s<c;s++)t[s-1]=arguments[s];for(r=0,i=a.length;r<i;r++)switch(this.event=e,c){case 1:u.push(a[r].call(this));break;case 2:u.push(a[r].call(this,arguments[1]));break;case 3:u.push(a[r].call(this,arguments[1],arguments[2]));break;default:u.push(a[r].apply(this,t))}}else if(!this._all&&"error"===e)return arguments[1]instanceof Error?Promise.reject(arguments[1]):Promise.reject("Uncaught, unspecified 'error' event.");return Promise.all(u)},s.prototype.on=function(e,t){return this._on(e,t,!1)},s.prototype.prependListener=function(e,t){return this._on(e,t,!0)},s.prototype.onAny=function(e){return this._onAny(e,!1)},s.prototype.prependAny=function(e){return this._onAny(e,!0)},s.prototype.addListener=s.prototype.on,s.prototype._onAny=function(e,t){if("function"!=typeof e)throw new Error("onAny only accepts instances of Function");return this._all||(this._all=[]),t?this._all.unshift(e):this._all.push(e),this},s.prototype._on=function(e,t,i){if("function"==typeof e)return this._onAny(e,t),this;if("function"!=typeof t)throw new Error("on only accepts instances of Function");return this._events||n.call(this),this._newListener&&this.emit("newListener",e,t),this.wildcard?(a.call(this,e,t),this):(this._events[e]?("function"==typeof this._events[e]&&(this._events[e]=[this._events[e]]),i?this._events[e].unshift(t):this._events[e].push(t),!this._events[e].warned&&this._maxListeners>0&&this._events[e].length>this._maxListeners&&(this._events[e].warned=!0,r.call(this,this._events[e].length,e))):this._events[e]=t,this)},s.prototype.off=function(e,n){function i(e){if(e!==t){var n=Object.keys(e);for(var r in n){var s=n[r],o=e[s];o instanceof Function||"object"!=typeof o||null===o||(Object.keys(o).length>0&&i(e[s]),0===Object.keys(o).length&&delete e[s])}}}if("function"!=typeof n)throw new Error("removeListener only takes instances of Function");var r,s=[];if(this.wildcard){var a="string"==typeof e?e.split(this.delimiter):e.slice();s=o.call(this,null,a,this.listenerTree,0)}else{if(!this._events[e])return this;r=this._events[e],s.push({_listeners:r})}for(var c=0;c<s.length;c++){var l=s[c];if(r=l._listeners,u(r)){for(var h=-1,d=0,f=r.length;d<f;d++)if(r[d]===n||r[d].listener&&r[d].listener===n||r[d]._origin&&r[d]._origin===n){h=d;break}if(h<0)continue;return this.wildcard?l._listeners.splice(h,1):this._events[e].splice(h,1),0===r.length&&(this.wildcard?delete l._listeners:delete this._events[e]),this._removeListener&&this.emit("removeListener",e,n),this}(r===n||r.listener&&r.listener===n||r._origin&&r._origin===n)&&(this.wildcard?delete l._listeners:delete this._events[e],this._removeListener&&this.emit("removeListener",e,n))}return i(this.listenerTree),this},s.prototype.offAny=function(e){var t,n=0,i=0;if(e&&this._all&&this._all.length>0){for(n=0,i=(t=this._all).length;n<i;n++)if(e===t[n])return t.splice(n,1),this._removeListener&&this.emit("removeListenerAny",e),this}else{if(t=this._all,this._removeListener)for(n=0,i=t.length;n<i;n++)this.emit("removeListenerAny",t[n]);this._all=[]}return this},s.prototype.removeListener=s.prototype.off,s.prototype.removeAllListeners=function(e){if(e===t)return!this._events||n.call(this),this;if(this.wildcard)for(var i="string"==typeof e?e.split(this.delimiter):e.slice(),r=o.call(this,null,i,this.listenerTree,0),s=0;s<r.length;s++)r[s]._listeners=null;else this._events&&(this._events[e]=null);return this},s.prototype.listeners=function(e){if(this.wildcard){var t=[],i="string"==typeof e?e.split(this.delimiter):e.slice();return o.call(this,t,i,this.listenerTree,0),t}return this._events||n.call(this),this._events[e]||(this._events[e]=[]),u(this._events[e])||(this._events[e]=[this._events[e]]),this._events[e]},s.prototype.eventNames=function(){return Object.keys(this._events)},s.prototype.listenerCount=function(e){return this.listeners(e).length},s.prototype.listenersAny=function(){return this._all?this._all:[]},"function"==typeof t&&t.amd?t(function(){return s}):e.exports=s}()}).EventEmitter2)});
/* Inspire Tree DOM
* @version 4.0.6
* https://github.com/helion3/inspire-tree-dom
* @copyright Copyright 2015 Helion3, and other contributors
* @license Licensed under MIT
* see https://github.com/helion3/inspire-tree-dom/blob/master/LICENSE
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("lodash"),require("inspire-tree")):"function"==typeof define&&define.amd?define(["lodash","inspire-tree"],t):e.InspireTreeDOM=t(e._,e.InspireTree)}(this,function(l,i){"use strict";i=i&&i.hasOwnProperty("default")?i.default:i;var m="$NO_OP",a="a runtime error occured! Use Inferno in development environment to find the error.",e=!("undefined"==typeof window||!window.document),u=Array.isArray;function p(e){var t=typeof e;return"string"===t||"number"===t}function D(e){return g(e)||y(e)}function f(e){return y(e)||!1===e||!0===e||g(e)}function _(e){return"function"==typeof e}function h(e){return"string"==typeof e}function v(e){return"number"==typeof e}function y(e){return null===e}function g(e){return void 0===e}function b(e,t){var n={};if(e)for(var o in e)n[o]=e[o];if(t)for(var r in t)n[r]=t[r];return n}var k="$";function C(e,t,n,o,r,i,a,s){return{childFlags:e,children:t,className:n,dom:null,flags:o,key:void 0===r?null:r,parentVNode:null,props:void 0===i?null:i,ref:void 0===a?null:a,type:s}}function s(e,t,n,o,r,i,a,s){var l=void 0===r?1:r,d=C(l,o,n,e,a,i,s,t);return 0===l&&S(d,d.children),d}function d(e,t,n,o,r){0<(2&e)&&(e=t.prototype&&_(t.prototype.render)?4:8);var i=t.defaultProps;if(!D(i))for(var a in n||(n={}),i)g(n[a])&&(n[a]=i[a]);if(0<(8&e)){var s=t.defaultHooks;if(!D(s))if(r)for(var l in s)g(r[l])&&(r[l]=s[l]);else r=s}var d=C(1,null,null,e,o,n,r,t),c=P.createVNode;return _(c)&&c(d),d}function $(e,t){return C(1,D(e)?"":e,null,16,t,null,null,null)}function c(e){var t=e.props;if(t){var n=e.flags;481&n&&(void 0!==t.children&&D(e.children)&&S(e,t.children),void 0!==t.className&&(e.className=t.className||null,t.className=void 0)),void 0!==t.key&&(e.key=t.key,t.key=void 0),void 0!==t.ref&&(e.ref=8&n?b(e.ref,t.ref):t.ref,t.ref=void 0)}return e}function w(e){var t,n=e.flags;if(14&n){var o,r=e.props;if(!y(r))for(var i in o={},r)o[i]=r[i];t=d(n,e.type,o,e.key,e.ref)}else 481&n?t=s(n,e.type,e.className,e.children,e.childFlags,e.props,e.key,e.ref):16&n?t=$(e.children,e.key):1024&n&&(t=e);return t}function x(){return $("",null)}function N(e,t,n,o){for(var r=e.length;n<r;n++){var i=e[n];if(!f(i)){var a=o+k+n;if(u(i))N(i,t,0,a);else{if(p(i))i=$(i,a);else{var s=i.key,l=h(s)&&s[0]===k;y(i.dom)&&!l||(i=w(i)),y(s)||l?i.key=a:i.key=o+s}t.push(i)}}}}function S(e,t){var n,o=1;if(f(t))n=t;else if(h(t))o=2,n=$(t);else if(v(t))o=2,n=$(t+"");else if(u(t)){var r=t.length;if(0===r)n=null,o=1;else{(Object.isFrozen(t)||!0===t.$)&&(t=t.slice()),o=8;for(var i=0;i<r;i++){var a=t[i];if(f(a)||u(a)){N(t,n=n||t.slice(0,i),i,"");break}if(p(a))(n=n||t.slice(0,i)).push($(a,k+i));else{var s=a.key,l=y(a.dom),d=y(s),c=!d&&s[0]===k;!l||d||c?(n=n||t.slice(0,i),l&&!c||(a=w(a)),(d||c)&&(a.key=k+i),n.push(a)):n&&n.push(a)}}(n=n||t).$=!0}}else y((n=t).dom)||(n=w(t)),o=2;return e.children=n,e.childFlags=o,e}var P={afterRender:null,beforeRender:null,createVNode:null,renderComplete:null},t="http://www.w3.org/1999/xlink",n="http://www.w3.org/XML/1998/namespace",O="http://www.w3.org/2000/svg",T={"xlink:actuate":t,"xlink:arcrole":t,"xlink:href":t,"xlink:role":t,"xlink:show":t,"xlink:title":t,"xlink:type":t,"xml:base":n,"xml:lang":n,"xml:space":n},L={},U=[];function M(e,t){e.appendChild(t)}function E(e,t,n){D(n)?M(e,t):e.insertBefore(t,n)}function F(e,t,n){e.replaceChild(t,n)}function I(e){for(var t;void 0!==(t=e.shift());)t()}var A={},V={};function R(e,t,n){var r,o,i=A[e],a=n.$EV;t?(i||(V[e]=(r=e,o=function(e){var t=e.type,n="click"===t||"dblclick"===t;if(n&&0!==e.button)return e.stopPropagation(),!1;e.stopPropagation=B;var o={dom:document};Object.defineProperty(e,"currentTarget",{configurable:!0,get:function(){return o.dom}}),function(e,t,n,o,r){var i=t;for(;!y(i);){if(n&&i.disabled)return;var a=i.$EV;if(a){var s=a[o];if(s&&(r.dom=i,s.event?s.event(s.data,e):s(e),e.cancelBubble))return}i=i.parentNode}}(e,e.target,n,r,o)},document.addEventListener(j(r),o),o),A[e]=0),a||(a=n.$EV={}),a[e]||A[e]++,a[e]=t):a&&a[e]&&(A[e]--,1===i&&(document.removeEventListener(j(e),V[e]),V[e]=null),a[e]=t)}function j(e){return e.substr(2).toLowerCase()}function B(){this.cancelBubble=!0,this.immediatePropagationStopped||this.stopImmediatePropagation()}function W(e,t){var n=document.createElement("i");return n.innerHTML=t,n.innerHTML===e.innerHTML}function H(e,t,n){if(e[t]){var o=e[t];o.event?o.event(o.data,n):o(n)}else{var r=t.toLowerCase();e[r]&&e[r](n)}}function o(s,l){var e=function(e){e.stopPropagation();var t=this.$V;if(t){var n=t.props||L,o=t.dom;if(h(s))H(n,s,e);else for(var r=0;r<s.length;r++)H(n,s[r],e);if(_(l)){var i=this.$V,a=i.props||L;l(a,o,!1,i)}}};return Object.defineProperty(e,"wrapped",{configurable:!1,enumerable:!1,value:!0,writable:!1}),e}function q(e){return"checkbox"===e||"radio"===e}var K=o("onInput",z),X=o(["onClick","onChange"],z);function Q(e){e.stopPropagation()}function z(e,t){var n=e.type,o=e.value,r=e.checked,i=e.multiple,a=e.defaultValue,s=!D(o);n&&n!==t.type&&t.setAttribute("type",n),D(i)||i===t.multiple||(t.multiple=i),D(a)||s||(t.defaultValue=a+""),q(n)?(s&&(t.value=o),D(r)||(t.checked=r)):s&&t.value!==o?(t.defaultValue=o,t.value=o):D(r)||(t.checked=r)}function G(e,t){if("optgroup"===e.type){var n=e.children,o=e.childFlags;if(12&o)for(var r=0,i=n.length;r<i;r++)Y(n[r],t);else 2===o&&Y(n,t)}else Y(e,t)}function Y(e,t){var n=e.props||L,o=e.dom;o.value=n.value,u(t)&&-1!==t.indexOf(n.value)||n.value===t?o.selected=!0:D(t)&&D(n.selected)||(o.selected=n.selected||!1)}Q.wrapped=!0;var J=o("onChange",Z);function Z(e,t,n,o){var r=Boolean(e.multiple);D(e.multiple)||r===t.multiple||(t.multiple=r);var i=o.childFlags;if(0==(1&i)){var a=o.children,s=e.value;if(n&&D(s)&&(s=e.defaultValue),12&i)for(var l=0,d=a.length;l<d;l++)G(a[l],s);else 2===i&&G(a,s)}}var ee=o("onInput",ne),te=o("onChange");function ne(e,t,n){var o=e.value,r=t.value;if(D(o)){if(n){var i=e.defaultValue;D(i)||i===r||(t.defaultValue=i,t.value=i)}}else r!==o&&(t.defaultValue=o,t.value=o)}function oe(e,t,n,o,r,i){64&e?z(o,n):256&e?Z(o,n,r,t):128&e&&ne(o,n,r),i&&(n.$V=t)}function re(e,t,n){var o,r,i;64&e?(i=t,q(n.type)?(i.onchange=X,i.onclick=Q):i.oninput=K):256&e?t.onchange=J:128&e&&(r=n,(o=t).oninput=ee,r.onChange&&(o.onchange=te))}function ie(e){return e.type&&q(e.type)?!D(e.checked):!D(e.value)}function ae(e,t){var n,o;se(e),t&&e.dom&&(n=t,o=e.dom,n.removeChild(o),e.dom=null)}function se(e){var t=e.flags;if(481&t){var n=e.ref,o=e.props;_(n)&&n(null);var r=e.children,i=e.childFlags;if(12&i?le(r):2===i&&se(r),!y(o))for(var a in o)switch(a){case"onClick":case"onDblClick":case"onFocusIn":case"onFocusOut":case"onKeyDown":case"onKeyPress":case"onKeyUp":case"onMouseDown":case"onMouseMove":case"onMouseUp":case"onSubmit":case"onTouchEnd":case"onTouchMove":case"onTouchStart":R(a,null,e.dom)}}else{var s=e.children;if(s)if(14&t){var l=e.ref;4&t?(_(s.componentWillUnmount)&&s.componentWillUnmount(),_(l)&&l(null),s.$UN=!0,s.$LI&&se(s.$LI)):(!D(l)&&_(l.onComponentWillUnmount)&&l.onComponentWillUnmount(e.dom,e.props||L),se(s))}else 1024&t&&ae(s,e.type)}}function le(e){for(var t=0,n=e.length;t<n;t++)se(e[t])}function de(e,t){le(t),e.textContent=""}function ce(e,t){switch(e){case"animationIterationCount":case"borderImageOutset":case"borderImageSlice":case"borderImageWidth":case"boxFlex":case"boxFlexGroup":case"boxOrdinalGroup":case"columnCount":case"fillOpacity":case"flex":case"flexGrow":case"flexNegative":case"flexOrder":case"flexPositive":case"flexShrink":case"floodOpacity":case"fontWeight":case"gridColumn":case"gridRow":case"lineClamp":case"lineHeight":case"opacity":case"order":case"orphans":case"stopOpacity":case"strokeDasharray":case"strokeDashoffset":case"strokeMiterlimit":case"strokeOpacity":case"strokeWidth":case"tabSize":case"widows":case"zIndex":case"zoom":return t;default:return t+"px"}}function ue(e,t,n,o,r,i,a){switch(e){case"onClick":case"onDblClick":case"onFocusIn":case"onFocusOut":case"onKeyDown":case"onKeyPress":case"onKeyUp":case"onMouseDown":case"onMouseMove":case"onMouseUp":case"onSubmit":case"onTouchEnd":case"onTouchMove":case"onTouchStart":R(e,n,o);break;case"children":case"childrenType":case"className":case"defaultValue":case"key":case"multiple":case"ref":break;case"autoFocus":o.autofocus=!!n;break;case"allowfullscreen":case"autoplay":case"capture":case"checked":case"controls":case"default":case"disabled":case"hidden":case"indeterminate":case"loop":case"muted":case"novalidate":case"open":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"selected":o[e]=!!n;break;case"defaultChecked":case"value":case"volume":if(i&&"value"===e)return;var s=D(n)?"":n;o[e]!==s&&(o[e]=s);break;case"dangerouslySetInnerHTML":var l=t&&t.__html||"",d=n&&n.__html||"";l!==d&&(D(d)||W(o,d)||(y(a)||(12&a.childFlags?le(a.children):2===a.childFlags&&se(a.children),a.children=null,a.childFlags=1),o.innerHTML=d));break;default:"o"===e[0]&&"n"===e[1]?function(e,t,n,o){var r,i,a=e.toLowerCase();if(_(n)||D(n)){var s=o[a];s&&s.wrapped||(o[a]=n)}else{var l=n.event;l&&_(l)&&(o[a]=(r=l,i=n,function(e){r(i.data,e)}))}}(e,0,n,o):D(n)?o.removeAttribute(e):"style"===e?function(e,t,n){var o,r,i=n.style;if(h(t))i.cssText=t;else if(D(e)||h(e))for(o in t)r=t[o],i[o]=v(r)?ce(o,r):r;else{for(o in t)(r=t[o])!==e[o]&&(i[o]=v(r)?ce(o,r):r);for(o in e)D(t[o])&&(i[o]="")}}(t,n,o):r&&T[e]?o.setAttributeNS(T[e],e,n):o.setAttribute(e,n)}}function pe(e,t,n,o,r){var i=!1,a=0<(448&t);for(var s in a&&(i=ie(n))&&re(t,o,n),n)ue(s,null,n[s],o,r,i,null);a&&oe(t,e,o,n,!0,i)}function fe(e,t,n,o){var r=new t(n,o);if((e.children=r).$V=e,r.$BS=!1,r.context=o,r.props===L&&(r.props=n),r.$UN=!1,_(r.componentWillMount)){if(r.$BR=!0,r.componentWillMount(),r.$PSS){var i=r.state,a=r.$PS;if(y(i))r.state=a;else for(var s in a)i[s]=a[s];r.$PSS=!1,r.$PS=null}r.$BR=!1}_(P.beforeRender)&&P.beforeRender(r);var l,d=he(r.render(n,r.state,o),e);return _(r.getChildContext)&&(l=r.getChildContext()),D(l)?r.$CX=o:r.$CX=b(o,l),_(P.afterRender)&&P.afterRender(r),r.$LI=d,r}function he(e,t){return f(e)?e=x():p(e)?e=$(e,null):(e.dom&&(e=w(e)),14&e.flags&&(e.parentVNode=t)),e}function ve(e,t,n,o){var r=e.flags;return 481&r?me(e,t,n,o):14&r?function(e,t,n,o,r){var i,a=e.type,s=e.props||L,l=e.ref;if(r){var d=fe(e,a,s,n);e.dom=i=ve(d.$LI,null,d.$CX,o),be(e,l,d),d.$UPD=!1}else{var c=he(a(s,n),e);e.children=c,e.dom=i=ve(c,null,n,o),ke(s,l,i)}y(t)||M(t,i);return i}(e,t,n,o,0<(4&r)):512&r||16&r?ge(e,t):1024&r?(ve(e.children,e.type,n,!1),e.dom=ge(x(),t)):void 0}function ge(e,t){var n=e.dom=document.createTextNode(e.children);return y(t)||M(t,n),n}function me(e,t,n,o){var r=e.flags,i=e.children,a=e.props,s=e.className,l=e.ref,d=e.childFlags;o=o||0<(32&r);var c,u=(c=e.type,!0===o?document.createElementNS(O,c):document.createElement(c));if(e.dom=u,D(s)||""===s||(o?u.setAttribute("class",s):u.className=s),y(t)||M(t,u),0==(1&d)){var p=!0===o&&"foreignObject"!==e.type;2===d?ve(i,u,n,p):12&d&&ye(i,u,n,p)}return y(a)||pe(e,r,a,u,o),_(l)&&Ce(u,l),u}function ye(e,t,n,o){for(var r=0,i=e.length;r<i;r++){var a=e[r];y(a.dom)||(e[r]=a=w(a)),ve(a,t,n,o)}}function be(e,t,n){var o;_(t)&&t(n),_(n.componentDidMount)&&U.push((o=n,function(){o.componentDidMount()}))}function ke(e,t,n){var o,r,i;D(t)||(_(t.onComponentWillMount)&&t.onComponentWillMount(e),_(t.onComponentDidMount)&&U.push((o=t,r=n,i=e,function(){return o.onComponentDidMount(r,i)})))}function Ce(e,t){U.push(function(){return t(e)})}function $e(e,t,n,o){var r,i,a=e.children,s=e.props,l=e.className,d=e.flags,c=e.ref;if(o=o||0<(32&d),1!==t.nodeType||t.tagName.toLowerCase()!==e.type){var u=me(e,null,n,o);e.dom=u,F(t.parentNode,u,t)}else{var p=(e.dom=t).firstChild,f=e.childFlags;if(0==(1&f)){for(var h=null;p;)h=p.nextSibling,8===p.nodeType&&("!"===p.data?t.replaceChild(document.createTextNode(""),p):t.removeChild(p)),p=h;if(p=t.firstChild,2===f)y(p)?ve(a,t,n,o):(h=p.nextSibling,De(a,p,n,o),p=h);else if(12&f)for(var v=0,g=a.length;v<g;v++){var m=a[v];y(p)?ve(m,t,n,o):(h=p.nextSibling,De(m,p,n,o),p=h)}for(;p;)h=p.nextSibling,t.removeChild(p),p=h}else y(t.firstChild)||(r=t,i=s,Boolean(i&&i.dangerouslySetInnerHTML&&i.dangerouslySetInnerHTML.__html&&W(r,i.dangerouslySetInnerHTML.__html)))||(t.textContent="",448&d&&(t.defaultValue=""));y(s)||pe(e,d,s,t,o),D(l)?""!==t.className&&t.removeAttribute("class"):o?t.setAttribute("class",l):t.className=l,_(c)&&Ce(t,c)}}function De(e,t,n,o){var r=e.flags;14&r?function(e,t,n,o,r){var i=e.type,a=e.ref,s=e.props||L;if(r){var l=fe(e,i,s,n),d=l.$LI;De(d,t,l.$CX,o),e.dom=d.dom,be(0,a,l),l.$UPD=!1}else{var c=he(i(s,n),e);De(c,t,n,o),e.children=c,e.dom=c.dom,ke(s,a,t)}}(e,t,n,o,0<(4&r)):481&r?$e(e,t,n,o):16&r?function(e,t){if(3!==t.nodeType){var n=ge(e,null);e.dom=n,F(t.parentNode,n,t)}else{var o=e.children;t.nodeValue!==o&&(t.nodeValue=o),e.dom=t}}(e,t):512&r?e.dom=t:function(e){throw e||(e=a),new Error("Inferno Error: "+e)}()}function _e(e,t,n,o,r){se(e),F(n,ve(t,null,o,r),e.dom)}function xe(e,t,n,o,r){if(e!==t){var i=0|t.flags;e.flags!==i||2048&i?_e(e,t,n,o,r):481&i?function(e,t,n,o,r){var i=t.type;if(e.type!==i)_e(e,t,n,o,r);else{var a,s=e.dom,l=t.flags,d=e.props,c=t.props,u=!1,p=!1;if(t.dom=s,r=r||0<(32&l),d!==c){var f=d||L;if((a=c||L)!==L)for(var h in(u=0<(448&l))&&(p=ie(a)),a){var v=f[h],g=a[h];v!==g&&ue(h,v,g,s,r,p,e)}if(f!==L)for(var m in f)a.hasOwnProperty(m)||D(f[m])||ue(m,f[m],null,s,r,p,e)}var y=e.children,b=t.children,k=t.ref,C=e.className,$=t.className;y!==b&&we(e.childFlags,t.childFlags,y,b,s,o,r&&"foreignObject"!==i),u&&oe(l,t,s,a,!1,p),C!==$&&(D($)?s.removeAttribute("class"):r?s.setAttribute("class",$):s.className=$),_(k)&&e.ref!==k&&Ce(s,k)}}(e,t,n,o,r):14&i?function(e,t,n,o,r,i){var a=t.type,s=e.key,l=t.key;if(e.type!==a||s!==l)_e(e,t,n,o,r);else{var d=t.props||L;if(i){var c=e.children;c.$UPD=!0,c.$V=t,Ne(c,c.state,t,d,n,o,r,!1,!1),c.$UPD=!1}else{var u=!0,p=e.props,f=t.ref,h=!D(f),v=e.children;if(t.dom=e.dom,t.children=v,h&&_(f.onComponentShouldUpdate)&&(u=f.onComponentShouldUpdate(p,d)),!1!==u){h&&_(f.onComponentWillUpdate)&&f.onComponentWillUpdate(p,d);var g=a(d,o);g!==m&&(g=he(g,t),xe(v,g,n,o,r),t.children=g,t.dom=g.dom,h&&_(f.onComponentDidUpdate)&&f.onComponentDidUpdate(p,d))}else 14&v.flags&&(v.parentVNode=t)}}}(e,t,n,o,r,0<(4&i)):16&i?function(e,t,n){var o,r=t.children;y(n.firstChild)?(n.textContent=r,o=n.firstChild):(o=e.dom,r!==e.children&&(o.nodeValue=r));t.dom=o}(e,t,n):512&i?t.dom=e.dom:function(e,t,n){var o=e.type,r=t.type,i=t.children;if(we(e.childFlags,t.childFlags,e.children,i,o,n,!1),t.dom=e.dom,o!==r&&!f(i)){var a=i.dom;o.removeChild(a),r.appendChild(a)}}(e,t,o)}}function we(e,t,n,o,r,i,a){switch(e){case 2:switch(t){case 2:xe(n,o,r,i,a);break;case 1:ae(n,r);break;default:ae(n,r),ye(o,r,i,a)}break;case 1:switch(t){case 2:ve(o,r,i,a);break;case 1:break;default:ye(o,r,i,a)}break;default:if(12&t){var s=n.length,l=o.length;0===s?0<l&&ye(o,r,i,a):0===l?de(r,n):8===t&&8===e?function(e,t,n,o,r,i,a){var s,l,d=i-1,c=a-1,u=0,p=e[u],f=t[u];e:{for(;p.key===f.key;){if(f.dom&&(t[u]=f=w(f)),xe(p,f,n,o,r),e[u]=f,d<++u||c<u)break e;p=e[u],f=t[u]}for(p=e[d],f=t[c];p.key===f.key;){if(f.dom&&(t[c]=f=w(f)),xe(p,f,n,o,r),e[d]=f,c--,--d<u||c<u)break e;p=e[d],f=t[c]}}if(d<u){if(u<=c)for(var h=(l=c+1)<a?t[l].dom:null;u<=c;)(f=t[u]).dom&&(t[u]=f=w(f)),u++,E(n,ve(f,null,o,r),h)}else if(c<u)for(;u<=d;)ae(e[u++],n);else{var v=u,g=u,m=d-u+1,y=c-u+1,b=[];for(s=0;s<y;s++)b.push(0);var k=m===i,C=!1,$=0,D=0;if(a<4||(m|y)<32)for(s=v;s<=d;s++)if(p=e[s],D<y){for(u=g;u<=c;u++)if(f=t[u],p.key===f.key){if(b[u-g]=s+1,k)for(k=!1;v<s;)ae(e[v++],n);u<$?C=!0:$=u,f.dom&&(t[u]=f=w(f)),xe(p,f,n,o,r),D++;break}!k&&c<u&&ae(p,n)}else k||ae(p,n);else{var _={};for(s=g;s<=c;s++)_[t[s].key]=s;for(s=v;s<=d;s++)if(p=e[s],D<y)if(void 0!==(u=_[p.key])){if(k)for(k=!1;v<s;)ae(e[v++],n);f=t[u],b[u-g]=s+1,u<$?C=!0:$=u,f.dom&&(t[u]=f=w(f)),xe(p,f,n,o,r),D++}else k||ae(p,n);else k||ae(p,n)}if(k)de(n,e),ye(t,n,o,r);else if(C){var x=function(e){var t,n,o,r,i,a=e.slice(),s=[0],l=e.length;for(t=0;t<l;t++){var d=e[t];if(0!==d){if(n=s[s.length-1],e[n]<d){a[t]=n,s.push(t);continue}for(o=0,r=s.length-1;o<r;)e[s[i=(o+r)/2|0]]<d?o=i+1:r=i;d<e[s[o]]&&(0<o&&(a[t]=s[o-1]),s[o]=t)}}o=s.length,r=s[o-1];for(;0<o--;)s[o]=r,r=a[r];return s}(b);for(u=x.length-1,s=y-1;0<=s;s--)0===b[s]?((f=t[$=s+g]).dom&&(t[$]=f=w(f)),l=$+1,E(n,ve(f,null,o,r),l<a?t[l].dom:null)):u<0||s!==x[u]?(f=t[$=s+g],l=$+1,E(n,f.dom,l<a?t[l].dom:null)):u--}else if(D!==y)for(s=y-1;0<=s;s--)0===b[s]&&((f=t[$=s+g]).dom&&(t[$]=f=w(f)),l=$+1,E(n,ve(f,null,o,r),l<a?t[l].dom:null))}}(n,o,r,i,a,s,l):function(e,t,n,o,r,i,a){for(var s,l,d=a<i?a:i,c=0;c<d;c++)s=t[c],l=e[c],s.dom&&(s=t[c]=w(s)),xe(l,s,n,o,r),e[c]=s;if(i<a)for(c=d;c<a;c++)(s=t[c]).dom&&(s=t[c]=w(s)),ve(s,n,o,r);else if(a<i)for(c=d;c<i;c++)ae(e[c],n)}(n,o,r,i,a,s,l)}else 1===t?de(r,n):(de(r,n),ve(o,r,i,a))}}function Ne(e,t,n,o,r,i,a,s,l){var d,c=e.state,u=e.props;if(!(n.children=e).$UN){if(u!==o||o===L){if(!l&&_(e.componentWillReceiveProps)){if(e.$BR=!0,e.componentWillReceiveProps(o,i),e.$UN)return;e.$BR=!1}e.$PSS&&(t=b(t,e.$PS),e.$PSS=!1,e.$PS=null)}var p=Boolean(e.shouldComponentUpdate);if(s||!p||p&&e.shouldComponentUpdate(o,t,i)){_(e.componentWillUpdate)&&(e.$BS=!0,e.componentWillUpdate(o,t,i),e.$BS=!1),e.props=o,e.state=t,e.context=i,_(P.beforeRender)&&P.beforeRender(e),d=e.render(o,t,i),_(P.afterRender)&&P.afterRender(e);var f,h=d!==m;if(_(e.getChildContext)&&(f=e.getChildContext()),f=D(f)?i:b(i,f),e.$CX=f,h)xe(e.$LI,e.$LI=he(d,n),r,f,a),_(e.componentDidUpdate)&&e.componentDidUpdate(u,c)}else e.props=o,e.state=t,e.context=i;n.dom=e.$LI.dom}}e&&document.body;function r(e,t,n){if(e!==m){var o=t.$V;return D(o)?f(e)||(e.dom&&(e=w(e)),y(t.firstChild)?(ve(e,t,L,!1),t.$V=e):function(e,t,n){var o=t.firstChild;if(!y(o))for(f(e)||De(e,o,L,!1),o=t.firstChild;o=o.nextSibling;)t.removeChild(o);0<U.length&&I(U),t.$V=e,_(n)&&n()}(e,t),o=e):D(e)?(ae(o,t),t.$V=null):(e.dom&&(e=w(e)),xe(o,e,t,L,!1),o=t.$V=e),0<U.length&&I(U),_(n)&&n(),_(P.renderComplete)&&P.renderComplete(o),o&&14&o.flags?o.children:void 0}}var Se="undefined"==typeof Promise?null:Promise.resolve(),Pe="undefined"==typeof requestAnimationFrame?setTimeout:requestAnimationFrame.bind(window);function Oe(e,t,n,o){_(t)&&(t=t(e.state,e.props,e.context));var r,i,a,s=e.$PS;if(D(s))e.$PS=t;else for(var l in t)s[l]=t[l];if(e.$PSS||e.$BR)e.$PSS=!0,e.$BR&&_(n)&&U.push(n.bind(e));else if(e.$UPD){var d=e.$QU;y(d)&&(d=e.$QU=[],i=e,a=d,r=function(){i.$QU=null,i.$UPD=!0,Te(i,!1,function(){for(var e=0,t=a.length;e<t;e++)a[e].call(i)}),i.$UPD=!1},Se?Se.then(r):Pe(r)),_(n)&&d.push(n)}else e.$PSS=!0,e.$UPD=!0,Te(e,o,n),e.$UPD=!1}function Te(e,t,n){if(!e.$UN){if(t||!e.$BR){e.$PSS=!1;var o=e.$PS,r=b(e.state,o),i=e.props,a=e.context;e.$PS=null;var s=e.$V,l=e.$LI;if(Ne(e,r,s,i,l.dom&&l.dom.parentNode,a,0<(32&s.flags),t,!0),e.$UN)return;if(0==(1024&e.$LI.flags))for(var d=e.$LI.dom;!y(s=s.parentVNode);)0<(14&s.flags)&&(s.dom=d);0<U.length&&I(U)}else e.state=e.$PS,e.$PS=null;_(n)&&n.call(e)}}var Le=function(e,t){this.state=null,this.$BR=!1,this.$BS=!0,this.$PSS=!1,this.$PS=null,this.$LI=null,this.$V=null,this.$UN=!1,this.$CX=null,this.$UPD=!0,this.$QU=null,this.props=e||L,this.context=t||L};Le.prototype.forceUpdate=function(e){this.$UN||Oe(this,{},e,!0)},Le.prototype.setState=function(e,t){this.$UN||this.$BS||Oe(this,e,t,!1)},Le.prototype.render=function(e,t,n){};var Ue=12,Me=37,Ee=38,Fe=39,Ie=40;var Ae=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},Ve=function(){function o(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(e,t,n){return t&&o(e.prototype,t),n&&o(e,n),e}}(),Re=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},je=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},Be=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},We=function(e){function t(){return Ae(this,t),Be(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return je(t,Le),Ve(t,[{key:"click",value:function(e){var t=this,n=function(){t.props.node.toggleCheck()};this.props.dom._tree.emit("node.click",e,this.props.node,n),e.treeDefaultPrevented||n()}},{key:"render",value:function(){return s(64,"input",null,null,1,{checked:this.props.checked,indeterminate:this.props.indeterminate,onClick:this.click.bind(this),type:"checkbox"})}}]),t}(),He=function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"li",n=e.itree[t].attributes,o=[],r=n.class||n.className;return l.isFunction(r)&&(r=r(e)),l.isEmpty(r)||(l.isString(r)?o=o.concat(r.split(/[\s\.]+/)):l.isArray(r)&&(o=o.concat(r))),o},qe=function(e){function t(){return Ae(this,t),Be(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return je(t,Le),Ve(t,[{key:"shouldComponentUpdate",value:function(){return!1}},{key:"add",value:function(e){e.stopPropagation(),this.props.node.addChild({text:"New Node",itree:{state:{editing:!0,focused:!0}}}),this.props.node.expand()}},{key:"edit",value:function(e){e.stopPropagation(),this.props.node.toggleEditing()}},{key:"remove",value:function(e){e.stopPropagation(),this.props.node.remove()}},{key:"render",value:function(){var e=[];return this.props.dom._tree.config.editing.edit&&e.push(s(1,"a","btn icon icon-pencil",null,1,{onclick:this.edit.bind(this),title:"Edit this node"})),this.props.dom._tree.config.editing.add&&e.push(s(1,"a","btn icon icon-plus",null,1,{onclick:this.add.bind(this),title:"Add a child node"})),this.props.dom._tree.config.editing.remove&&e.push(s(1,"a","btn icon icon-minus",null,1,{onclick:this.remove.bind(this),title:"Remove this node"})),s(1,"span","btn-group",e,0)}}]),t}(),Ke=function(e){function t(){return Ae(this,t),Be(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return je(t,Le),Ve(t,[{key:"render",value:function(){return s(1,"ol",null,s(1,"li","leaf",s(1,"span","title icon icon-file-empty empty",this.props.text,0),2),2)}}]),t}();function Xe(t,n){var o=n.dirty||!1;return o||l.each(Object.keys(n),function(e){if("dirty"!==e&&n[e]!==t[e])return!(o=!0)}),o}var Qe=function(e){function n(e){Ae(this,n);var t=Be(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e));return t.state=t.getStateFromNodes(e.node),t}return je(n,Le),Ve(n,[{key:"getStateFromNodes",value:function(e){return{text:e.text}}},{key:"componentWillReceiveProps",value:function(e){this.setState(this.getStateFromNodes(e.node))}},{key:"shouldComponentUpdate",value:function(e,t){return Xe(this.state,t)}},{key:"click",value:function(e){var t=this,n=function(){t.props.node.toggleCheck()};this.props.dom._tree.emit("node.click",e,this.props.node,n),e.treeDefaultPrevented||n()}},{key:"keypress",value:function(e){if(e.which===Ue)return this.save()}},{key:"input",value:function(e){this.setState({text:e.target.value})}},{key:"cancel",value:function(e){e&&e.stopPropagation(),this.props.node.toggleEditing()}},{key:"save",value:function(e){e&&e.stopPropagation();var t=this.props.node.text,n=this.ref.value;this.props.node.set("text",n),this.props.node.state("editing",!1),this.props.node.markDirty(),this.props.dom._tree.applyChanges(),t!==n&&this.props.dom._tree.emit("node.edited",this.props.node,t,n)}},{key:"render",value:function(){var t=this;return s(1,"form",null,[s(64,"input",null,null,1,{onClick:function(e){return e.stopPropagation},onInput:this.input.bind(this),onKeyPress:this.keypress.bind(this),value:this.state.text},null,function(e){return t.ref=e}),s(1,"span","btn-group",[s(1,"button","btn icon icon-check",null,1,{onClick:this.save.bind(this),title:"Save",type:"button"}),s(1,"button","btn icon icon-cross",null,1,{onClick:this.cancel.bind(this),title:"Cancel",type:"button"})],4)],4,{onsubmit:function(e){return e.preventDefault}})}}]),n}(),ze=function(e){function t(){return Ae(this,t),Be(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return je(t,Le),Ve(t,[{key:"blur",value:function(){this.props.node.blur()}},{key:"click",value:function(t){var n=this,e=this.props,o=e.node,r=e.dom,i=function(){if(t.preventDefault(),!n.props.editing){if((t.metaKey||t.ctrlKey||t.shiftKey)&&r._tree.disableDeselection(),t.shiftKey){r.clearSelection();var e=r._tree.lastSelectedNode();e&&r._tree.selectBetween.apply(r._tree,r._tree.boundingNodes(e,o))}o.selected()?r._tree.config.selection.disableDirectDeselection||o.deselect():o.select(),r._tree.enableDeselection()}};r._tree.emit("node.click",t,o,i),t.treeDefaultPrevented||i()}},{key:"contextMenu",value:function(e){var t=this.props,n=t.node;t.dom._tree.emit("node.contextmenu",e,n)}},{key:"dblclick",value:function(e){var t=this.props,n=t.node,o=t.dom,r=function(){o.clearSelection(),n.toggleCollapse()};o._tree.emit("node.dblclick",e,n,r),e.treeDefaultPrevented||r()}},{key:"focus",value:function(e){this.props.node.focus(e)}},{key:"mousedown",value:function(){this.props.dom.isDragDropEnabled&&(this.props.dom.isMouseHeld=!0)}},{key:"render",value:function(){var e=this.props.node,t=l.clone(e.itree.a.attributes)||{};t.tabindex=1,t.unselectable="on";var n=He(e,"a").concat(["title","icon"]);if(!this.props.dom.config.showCheckboxes){var o=this.props.expanded?"icon-folder-open":"icon-folder";n.push(e.itree.icon||(this.props.hasOrWillHaveChildren?o:"icon-file-empty"))}t.class=t.className=n.join(" ");var r=e.text;return e.editing()&&(r=d(2,Qe,{dom:this.props.dom,node:this.props.node})),c(s(1,"a",null,r,0,Re({"data-uid":e.id,onBlur:this.blur.bind(this),onClick:this.click.bind(this),onContextMenu:this.contextMenu.bind(this),onDblClick:this.dblclick.bind(this),onFocus:this.focus.bind(this),onMouseDown:this.mousedown.bind(this)},t)))}}]),t}(),Ge=function(e){function t(){return Ae(this,t),Be(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return je(t,Le),Ve(t,[{key:"className",value:function(){return"toggle icon "+(this.props.collapsed?"icon-expand":"icon-collapse")}},{key:"render",value:function(){return s(1,"a",this.className(),null,1,{onClick:this.props.node.toggleCollapse.bind(this.props.node)})}}]),t}(),Ye=function(e){function n(e){Ae(this,n);var t=Be(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e));return t.state=t.stateFromNode(e.node),t}return je(n,Le),Ve(n,[{key:"stateFromNode",value:function(e){return{dirty:e.itree.dirty}}},{key:"componentWillReceiveProps",value:function(e){this.setState(this.stateFromNode(e.node))}},{key:"shouldComponentUpdate",value:function(e,t){return t.dirty}},{key:"getAttributes",value:function(){var e=this.props.node,t=l.clone(e.itree.li.attributes)||{};return t.class=t.className=this.getClassNames(),t["data-uid"]=e.id,this.props.dom.config.dragAndDrop.enabled&&(t.draggable=e.state("draggable"),t.onDragEnd=this.onDragEnd.bind(this),t.onDragEnter=this.onDragEnter.bind(this),t.onDragLeave=this.onDragLeave.bind(this),t.onDragStart=this.onDragStart.bind(this),e.state("drop-target")?(t.onDragOver=this.onDragOver.bind(this),t.onDrop=this.onDrop.bind(this)):(t.onDragOver=null,t.onDrop=null)),t}},{key:"getClassNames",value:function(){var e=this.props.node,t=e.itree.state,n=He(e);return l.each(Object.keys(t),function(e){t[e]&&n.push(e)}),!e.hidden()&&e.removed()&&n.push("hidden"),e.expanded()&&n.push("expanded"),n.push(e.hasOrWillHaveChildren()?"folder":"leaf"),n.join(" ")}},{key:"getTargetDirection",value:function(e,t){var n=e.clientY,o=t.getBoundingClientRect(),r=o.top+o.height/3,i=o.bottom-o.height/3,a=0;return n<=r?a=-1:i<=n&&(a=1),a}},{key:"onDragStart",value:function(e){e.stopPropagation(),e.dataTransfer.effectAllowed="move",e.dataTransfer.dropEffect="move";var n=this.props.node;if(this.props.dom._activeDragNode=n,e.dataTransfer.setData("treeId",n.tree().id),e.dataTransfer.setData("nodeId",n.id),n.state("drop-target",!1),n.hasChildren()&&n.children.stateDeep("drop-target",!1),"dragstart"===this.props.dom.config.dragAndDrop.validateOn){var o=this.props.dom.config.dragAndDrop.validate,r=l.isFunction(o);this.props.dom._tree.batch(),function t(e,n){i.isTreeNodes(e)?l.each(e,function(e){t(e,n)}):i.isTreeNode(e)&&!1!==n(e)&&e.hasChildren()&&t(e.children,n)}(this.props.dom._tree.model,function(e){var t=e.id!==n.id;return t&&(t=!e.hasAncestor(n)),t&&r&&(t=o(n,e)),e.state("drop-target",t),t}),this.props.dom._tree.end()}this.props.dom._tree.emit("node.dragstart",e)}},{key:"onDragEnd",value:function(e){e.preventDefault(),e.stopPropagation(),this.unhighlightTarget(),this.props.dom._tree.emit("node.dragend",e)}},{key:"onDragEnter",value:function(e){e.preventDefault(),e.stopPropagation(),this.props.node.recurseUp(this.unhighlightTarget),this.props.node.state("drag-targeting",!0),this.props.dom._tree.emit("node.dragenter",e)}},{key:"onDragLeave",value:function(e){e.preventDefault(),e.stopPropagation(),this.unhighlightTarget(),this.props.dom._tree.emit("node.dragleave",e)}},{key:"onDragOver",value:function(e){e.preventDefault(),e.stopPropagation();var t=this.props.dom._activeDragNode,n=this.props.node,o=this.getTargetDirection(e,n.itree.ref.querySelector("a"));if("dragover"===this.props.dom.config.dragAndDrop.validateOn){var r=this.props.dom.config.dragAndDrop.validate,i=l.isFunction(r),a=t.id!==n.id;if(a&&(a=!n.hasAncestor(t)),a&&i&&(a=r(t,n,o)),n.state("drop-target",a),this.props.dom._tree.applyChanges(),!a)return}this.props.dom._tree.batch(),n.state("drag-targeting",!0),n.state("drag-targeting-above",-1===o),n.state("drag-targeting-below",1===o),n.state("drag-targeting-insert",0===o),this.props.dom._tree.end(),this.props.dom._tree.emit("node.dragover",e,o)}},{key:"onDrop",value:function(e){e.preventDefault(),e.stopPropagation(),this.unhighlightTarget();var t=e.dataTransfer.getData("treeId"),n=e.dataTransfer.getData("nodeId"),o=this.props.node;this.props.dom._activeDragNode=null;var r=this.getTargetDirection(e,e.target),i=void 0;t===this.props.dom._tree.id?i=this.props.dom._tree:t&&(i=document.querySelector('[data-uid="'+t+'"]').inspireTree);var a=void 0,s=void 0;if(i){var l=i.node(n);l.state("drop-target",!0);var d=l.remove(!0),c=o.context().indexOf(o);0===r?(a=o.addChild(d),s=o.children.indexOf(a),o.expand()):(s=1===r?++c:c,a=o.context().insertAt(s,d))}this.props.dom._tree.emit("node.drop",e,a,o,s)}},{key:"unhighlightTarget",value:function(e){(e||this.props.node).states(["drag-targeting","drag-targeting-above","drag-targeting-below","drag-targeting-insert"],!1)}},{key:"renderCheckbox",value:function(){var e=this.props.node;if(this.props.dom.config.showCheckboxes)return d(2,We,{checked:e.checked(),dom:this.props.dom,indeterminate:e.indeterminate(),node:e})}},{key:"renderChildren",value:function(){var e=this.props,t=e.node,n=e.dom;if(t.hasChildren()){var o=t.children,r=n.loading,i=o.pagination();return d(2,Je,{context:t,dom:n,limit:i.limit,loading:r,nodes:o,total:i.total})}if(this.props.dom.isDynamic&&t.children)return t.hasLoadedChildren()?d(2,Ke,{text:"No Results"}):d(2,Ke,{text:"Loading..."})}},{key:"renderEditToolbar",value:function(){if(this.props.dom._tree.config.editing.edit&&!this.props.node.editing())return d(2,qe,{dom:this.props.dom,node:this.props.node})}},{key:"renderToggle",value:function(){var e=this.props.node;if(this.props.dom.isDynamic?Boolean(e.children):e.hasVisibleChildren())return d(2,Ge,{collapsed:e.collapsed(),node:e})}},{key:"render",value:function(){var t=this,e=this.props.node,n=c(s(1,"li",null,[this.renderEditToolbar(),s(1,"div","title-wrap",[this.renderToggle(),this.renderCheckbox(),d(2,ze,{dom:this.props.dom,editing:e.editing(),expanded:e.expanded(),hasOrWillHaveChildren:e.hasOrWillHaveChildren(),node:e,text:e.text})],0),s(1,"div","wholerow"),this.renderChildren()],0,Re({},this.getAttributes()),null,function(e){return t.node=t.props.node.itree.ref=e}));return this.props.node.state("rendered",!0),this.props.node.itree.dirty=!1,n}}]),n}(),Je=function(e){function t(){return Ae(this,t),Be(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return je(t,Le),Ve(t,[{key:"shouldComponentUpdate",value:function(e){return l.find(e.nodes,"itree.dirty")||Xe(this.props,e)}},{key:"isDeferred",value:function(){return this.props.dom.config.deferredRendering||this.props.dom._tree.config.deferredLoading}},{key:"loadMore",value:function(e){e.preventDefault(),this.props.context?this.props.context.loadMore(e):this.props.dom._tree.loadMore(e)}},{key:"renderLoadMoreNode",value:function(){return s(1,"li","leaf detached",s(1,"a","title icon icon-more load-more",$("Load More"),2,{onClick:this.loadMore.bind(this)}),2)}},{key:"renderLoadingTextNode",value:function(){return s(1,"li","leaf",s(1,"span","title icon icon-more",$("Loading..."),2),2)}},{key:"render",value:function(){var t=this,e=this.props.nodes,n=e.pagination();if(this.props.dom.config.deferredRendering){var o=0;e=this.props.nodes.filter(function(e){var t=!(e.hidden()||e.removed());return t&&o++,o<=n.limit&&t})}var r=l.map(e,function(e){return d(2,Ye,{dom:t.props.dom,node:e},e.id)});return this.isDeferred()&&n.limit<n.total&&(this.props.loading?r.push(this.renderLoadingTextNode()):r.push(this.renderLoadMoreNode())),s(1,"ol",null,[r,this.props.children],0)}}]),t}(),Ze=function(e){function t(){return Ae(this,t),Be(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return je(t,Le),Ve(t,[{key:"add",value:function(){this.props.dom._tree.focused().blur(),this.props.dom._tree.addNode({text:"New Node",itree:{state:{editing:!0,focused:!0}}})}},{key:"renderAddLink",value:function(){if(this.props.dom._tree.config.editing.add)return s(1,"li",null,s(1,"a","btn icon icon-plus",null,1,{onClick:this.add.bind(this),title:"Add a new root node"}),2)}},{key:"render",value:function(){var e=this.props,t=e.dom,n=e.nodes,o=t.loading,r=n.pagination();return d(2,Je,{dom:t,limit:r.limit,loading:o,nodes:n,total:r.total,children:this.renderAddLink()})}}]),t}();return function(){function s(e,t){var n=this;if(Ae(this,s),!(e instanceof i))throw new TypeError("Tree argument is not an InspireTree instance.");if(this._tree=e,this.batching=0,this.dropTargets=[],this.$scrollLayer,!t.target)throw new TypeError("Invalid `target` property - must be a selector, HTMLElement, or jQuery element.");var o={enabled:!(e.usesNativeDOM=!0),validateOn:"dragstart",validate:null};this.config=l.defaultsDeep({},t,{autoLoadMore:!0,deferredRendering:!1,dragAndDrop:o,nodeHeight:25,showCheckboxes:!1,tabindex:-1,target:!1}),!0===t.dragAndDrop&&(this.config.dragAndDrop=o,this.config.dragAndDrop.enabled=!0),"checkbox"!==e.config.selection.mode||l.isBoolean(l.get(t,"showCheckboxes"))||(this.config.showCheckboxes=!0),this.isDynamic=l.isFunction(this._tree.config.data),this.attach(this.config.target);var r=!0;e.on("changes.applied",function(){n.renderNodes(),r&&(n.scrollSelectedIntoView(),r=!1)}),this.renderNodes()}return Ve(s,[{key:"attach",value:function(e){if(this.$target=this.getElement(e),this.$scrollLayer=this.getScrollableAncestor(this.$target),!this.$target)throw new Error("No valid element to attach to.");this.$target.setAttribute("data-uid",this._tree.id);var n=this.$target.className.split(" ");if(n.push("inspire-tree"),this._tree.config.editable&&(n.push("editable"),l.each(l.pickBy(this._tree.config.editing,l.identity),function(e,t){n.push("editable-"+t)})),this.$target.className=n.join(" "),this.$target.setAttribute("tabindex",this.config.tabindex||0),this.$target.addEventListener("keydown",this.keyboardListener.bind(this)),this.config.dragAndDrop.enabled&&(this.$target.addEventListener("dragenter",this.onDragEnter.bind(this),!1),this.$target.addEventListener("dragleave",this.onDragLeave.bind(this),!1),this.$target.addEventListener("dragover",this.onDragOver.bind(this),!1),this.$target.addEventListener("drop",this.onDrop.bind(this),!1),this.$target.classList.add("drag-and-drop")),this._tree.on("node.focused",function(e){var t=e.itree.ref.querySelector(".title");t!==document.activeElement&&t.focus()}),this.config.deferredRendering||this._tree.config.deferredLoading){var t=this._tree.config.pagination.limit;this._tree.config.pagination.limit=0<t?t:l.ceil(this.$scrollLayer.clientHeight/this.config.nodeHeight),this.config.autoLoadMore&&this.$target.addEventListener("scroll",l.throttle(this.scrollListener.bind(this),20))}this.$target.inspireTree=this._tree}},{key:"clearSelection",value:function(){document.selection&&document.selection.empty?document.selection.empty():window.getSelection&&window.getSelection().removeAllRanges()}},{key:"getElement",value:function(e){var t=void 0;if(e instanceof HTMLElement)t=e;else if(l.isObject(e)&&l.isObject(e[0]))t=e[0];else if(l.isString(e)){var n=document.querySelector(e);n&&(t=n)}return t}},{key:"getScrollableAncestor",value:function(e){e instanceof Element&&("auto"!==getComputedStyle(e).overflow&&e.parentNode&&(e=this.getScrollableAncestor(e.parentNode)));return e}},{key:"keyboardListener",value:function(e){if(e.stopPropagation(),!([Ie,Ue,Me,Fe,Ee].indexOf(e.which)<0)){var t=this._tree.focused();if(t.length)switch(e.preventDefault(),e.which){case Ie:this.moveFocusDownFrom(t[0]);break;case Ue:t[0].toggleSelect();break;case Me:t[0].collapse();break;case Fe:t[0].expand();break;case Ee:this.moveFocusUpFrom(t[0])}}}},{key:"moveFocusDownFrom",value:function(e){var t=e.nextVisibleNode();t&&t.focus()}},{key:"moveFocusUpFrom",value:function(e){var t=e.previousVisibleNode();t&&t.focus()}},{key:"nodeFromTitleDOMElement",value:function(e){var t=e.parentNode.parentNode.getAttribute("data-uid");return this._tree.node(t)}},{key:"onDragEnter",value:function(e){e.preventDefault(),e.target.classList.add("drag-targeting","drag-targeting-insert")}},{key:"onDragLeave",value:function(e){e.preventDefault(),this.unhighlightTarget(e.target)}},{key:"onDragOver",value:function(e){e.preventDefault()}},{key:"onDrop",value:function(e){e.preventDefault(),this.unhighlightTarget(e.target);var t=e.dataTransfer.getData("treeId"),n=e.dataTransfer.getData("nodeId"),o=s.getTreeById(t).node(n);o.state("drop-target",!0);var r=o.remove(!0),i=this._tree.addNode(r),a=this._tree.indexOf(i);this._tree.emit("node.drop",e,i,null,a)}},{key:"renderNodes",value:function(e){r(d(2,Ze,{dom:this,nodes:e||this._tree.nodes()}),this.$target)}},{key:"scrollListener",value:function(r){var i=this;if(!this.rendering&&!this.loading){var a=this.$scrollLayer.getBoundingClientRect(),e=document.querySelectorAll(".load-more");l.each(e,function(e){var t=e.getBoundingClientRect();if(!(a.right<t.left||a.left>t.right||a.bottom<t.top||a.top>t.bottom)){var n=void 0,o=e.parentNode.parentNode.parentNode;"LI"===o.tagName&&(n=i._tree.node(o.getAttribute("data-uid"))),i._tree.loadMore(n,r)}})}}},{key:"scrollSelectedIntoView",value:function(){var e=this.$target.querySelector(".selected");e&&this.$scrollLayer&&(this.$scrollLayer.scrollTop=e.offsetTop)}},{key:"unhighlightTarget",value:function(e){e&&e.classList.remove("drag-targeting","drag-targeting-insert")}}],[{key:"getTreeById",value:function(e){var t=document.querySelector('[data-uid="'+e+'"]');if(t)return t.inspireTree}}]),s}()});