!function(n){"use strict";"function"==typeof define&&define.amd?define(["jquery"],n):"undefined"!=typeof module&&module.exports?module.exports=n(require("jquery")):n(jQuery)}(function(n,t){"use strict";var c,l,o,v;if(!n.jstree){var p=0,f=!1,u=!1,e=!1,y=[],a=n("script:last").attr("src"),i=window.document,h=i.createElement("LI"),r,s;if(h.setAttribute("role","treeitem"),r=i.createElement("I"),r.className="jstree-icon jstree-ocl",r.setAttribute("role","presentation"),h.appendChild(r),r=i.createElement("A"),r.className="jstree-anchor",r.setAttribute("href","#"),r.setAttribute("tabindex","-1"),s=i.createElement("I"),s.className="jstree-icon jstree-themeicon",s.setAttribute("role","presentation"),r.appendChild(s),h.appendChild(r),r=s=null,n.jstree={version:"3.2.1",defaults:{plugins:[]},plugins:{},path:a&&-1!==a.indexOf("/")?a.replace(/\/[^\/]+$/,""):"",idregex:/[\\:&!^|()\[\]<>@*'+~#";.,=\- \/${}%?`]/g,root:"#"},n.jstree.create=function(t,i){var r=new n.jstree.core(++p),u=i;return i=n.extend(!0,{},n.jstree.defaults,i),u&&u.plugins&&(i.plugins=u.plugins),n.each(i.plugins,function(n,t){"core"!==n&&(r=r.plugin(t,i[t]))}),n(t).data("jstree",r),r.init(t,i),r},n.jstree.destroy=function(){n(".jstree:jstree").jstree("destroy"),n(i).off(".jstree")},n.jstree.core=function(n){this._id=n,this._cnt=0,this._wrk=null,this._data={core:{themes:{name:!1,dots:!1,icons:!1},selected:[],last_error:{},working:!1,worker_queue:[],focused:null}}},n.jstree.reference=function(t){var r=null,i=null;if(!t||!t.id||t.tagName&&t.nodeType||(t=t.id),!i||!i.length)try{i=n(t)}catch(u){}if(!i||!i.length)try{i=n("#"+t.replace(n.jstree.idregex,"\\$&"))}catch(u){}return i&&i.length&&(i=i.closest(".jstree")).length&&(i=i.data("jstree"))?r=i:n(".jstree").each(function(){var i=n(this).data("jstree");if(i&&i._model.data[t])return r=i,!1}),r},n.fn.jstree=function(i){var u="string"==typeof i,f=Array.prototype.slice.call(arguments,1),r=null;return i!==!0||this.length?(this.each(function(){var e=n.jstree.reference(this),o=u&&e?e[i]:null;return r=u&&o?o.apply(e,f):null,e||u||i!==t&&!n.isPlainObject(i)||n.jstree.create(this,i),(e&&!u||i===!0)&&(r=e||!1),null!==r&&r!==t?!1:void 0}),null!==r&&r!==t?r:this):!1},n.expr[":"].jstree=n.expr.createPseudo(function(){return function(i){return n(i).hasClass("jstree")&&n(i).data("jstree")!==t}}),n.jstree.defaults.core={data:!1,strings:!1,check_callback:!1,error:n.noop,animation:200,multiple:!0,themes:{name:!1,url:!1,dir:!1,dots:!0,icons:!0,stripes:!1,variant:!1,responsive:!1},expand_selected_onload:!0,worker:!0,force_text:!1,dblclick_toggle:!0},n.jstree.core.prototype={plugin:function(t,i){var r=n.jstree.plugins[t];return r?(this._data[t]={},r.prototype=this,new r(i,this)):this},init:function(t,i){this._model={data:{},changed:[],force_full_redraw:!1,redraw_timeout:!1,default_state:{loaded:!0,opened:!1,selected:!1,disabled:!1}},this._model.data[n.jstree.root]={id:n.jstree.root,parent:null,parents:[],children:[],children_d:[],state:{loaded:!1}},this.element=n(t).addClass("jstree jstree-"+this._id),this.settings=i,this._data.core.ready=!1,this._data.core.loaded=!1,this._data.core.rtl="rtl"===this.element.css("direction"),this.element[this._data.core.rtl?"addClass":"removeClass"]("jstree-rtl"),this.element.attr("role","tree"),this.settings.core.multiple&&this.element.attr("aria-multiselectable",!0),this.element.attr("tabindex")||this.element.attr("tabindex","0"),this.bind(),this.trigger("init"),this._data.core.original_container_html=this.element.find(" > ul > li").clone(!0),this._data.core.original_container_html.find("li").addBack().contents().filter(function(){return 3===this.nodeType&&(!this.nodeValue||/^\s+$/.test(this.nodeValue))}).remove(),this.element.html("<ul class='jstree-container-ul jstree-children' role='group'><li id='j"+this._id+"_loading' class='jstree-initial-node jstree-loading jstree-leaf jstree-last' role='tree-item'><i class='jstree-icon jstree-ocl'><\/i><a class='jstree-anchor' href='#'><i class='jstree-icon jstree-themeicon-hidden'><\/i>"+this.get_string("Loading ...")+"<\/a><\/li><\/ul>"),this.element.attr("aria-activedescendant","j"+this._id+"_loading"),this._data.core.li_height=this.get_container_ul().children("li").first().height()||24,this.trigger("loading"),this.load_node(n.jstree.root)},destroy:function(n){if(this._wrk)try{window.URL.revokeObjectURL(this._wrk),this._wrk=null}catch(t){}n||this.element.empty(),this.teardown()},teardown:function(){this.unbind(),this.element.removeClass("jstree").removeData("jstree").find("[class^='jstree']").addBack().attr("class",function(){return this.className.replace(/jstree[^ ]*|$/gi,"")}),this.element=null},bind:function(){var t="",r=null,u=0;this.element.on("dblclick.jstree",function(n){if(n.target.tagName&&"input"===n.target.tagName.toLowerCase())return!0;if(i.selection&&i.selection.empty)i.selection.empty();else if(window.getSelection){var t=window.getSelection();try{t.removeAllRanges(),t.collapse()}catch(r){}}}).on("mousedown.jstree",n.proxy(function(n){n.target===this.element[0]&&(n.preventDefault(),u=+new Date)},this)).on("mousedown.jstree",".jstree-ocl",function(n){n.preventDefault()}).on("click.jstree",".jstree-ocl",n.proxy(function(n){this.toggle_node(n.target)},this)).on("dblclick.jstree",".jstree-anchor",n.proxy(function(n){return n.target.tagName&&"input"===n.target.tagName.toLowerCase()?!0:void(this.settings.core.dblclick_toggle&&this.toggle_node(n.target))},this)).on("click.jstree",".jstree-anchor",n.proxy(function(t){t.preventDefault(),t.currentTarget!==i.activeElement&&n(t.currentTarget).focus(),this.activate_node(t.currentTarget,t)},this)).on("keydown.jstree",".jstree-anchor",n.proxy(function(t){if(t.target.tagName&&"input"===t.target.tagName.toLowerCase()||32!==t.which&&13!==t.which&&(t.shiftKey||t.ctrlKey||t.altKey||t.metaKey))return!0;var i=null;switch(this._data.core.rtl&&(37===t.which?t.which=39:39===t.which&&(t.which=37)),t.which){case 32:t.ctrlKey&&(t.type="click",n(t.currentTarget).trigger(t));break;case 13:t.type="click",n(t.currentTarget).trigger(t);break;case 37:t.preventDefault(),this.is_open(t.currentTarget)?this.close_node(t.currentTarget):(i=this.get_parent(t.currentTarget),i&&i.id!==n.jstree.root&&this.get_node(i,!0).children(".jstree-anchor").focus());break;case 38:t.preventDefault(),i=this.get_prev_dom(t.currentTarget),i&&i.length&&i.children(".jstree-anchor").focus();break;case 39:t.preventDefault(),this.is_closed(t.currentTarget)?this.open_node(t.currentTarget,function(n){this.get_node(n,!0).children(".jstree-anchor").focus()}):this.is_open(t.currentTarget)&&(i=this.get_node(t.currentTarget,!0).children(".jstree-children")[0],i&&n(this._firstChild(i)).children(".jstree-anchor").focus());break;case 40:t.preventDefault(),i=this.get_next_dom(t.currentTarget),i&&i.length&&i.children(".jstree-anchor").focus();break;case 106:this.open_all();break;case 36:t.preventDefault(),i=this._firstChild(this.get_container_ul()[0]),i&&n(i).children(".jstree-anchor").filter(":visible").focus();break;case 35:t.preventDefault(),this.element.find(".jstree-anchor").filter(":visible").last().focus()}},this)).on("load_node.jstree",n.proxy(function(t,i){i.status&&(i.node.id!==n.jstree.root||this._data.core.loaded||(this._data.core.loaded=!0,this._firstChild(this.get_container_ul()[0])&&this.element.attr("aria-activedescendant",this._firstChild(this.get_container_ul()[0]).id),this.trigger("loaded")),this._data.core.ready||setTimeout(n.proxy(function(){if(this.element&&!this.get_container_ul().find(".jstree-loading").length){if(this._data.core.ready=!0,this._data.core.selected.length){if(this.settings.core.expand_selected_onload){for(var i=[],t=0,r=this._data.core.selected.length;r>t;t++)i=i.concat(this._model.data[this._data.core.selected[t]].parents);for(i=n.vakata.array_unique(i),t=0,r=i.length;r>t;t++)this.open_node(i[t],!1,0)}this.trigger("changed",{action:"ready",selected:this._data.core.selected})}this.trigger("ready")}},this),0))},this)).on("keypress.jstree",n.proxy(function(u){if(u.target.tagName&&"input"===u.target.tagName.toLowerCase())return!0;r&&clearTimeout(r),r=setTimeout(function(){t=""},500);var o=String.fromCharCode(u.which).toLowerCase(),e=this.element.find(".jstree-anchor").filter(":visible"),s=e.index(i.activeElement)||0,f=!1;if(t+=o,t.length>1){if(e.slice(s).each(n.proxy(function(i,r){if(0===n(r).text().toLowerCase().indexOf(t))return n(r).focus(),f=!0,!1},this)),f)return;if(e.slice(0,s).each(n.proxy(function(i,r){if(0===n(r).text().toLowerCase().indexOf(t))return n(r).focus(),f=!0,!1},this)),f)return}if(new RegExp("^"+o.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")+"+$").test(t)){if(e.slice(s+1).each(n.proxy(function(t,i){if(n(i).text().toLowerCase().charAt(0)===o)return n(i).focus(),f=!0,!1},this)),f)return;if(e.slice(0,s+1).each(n.proxy(function(t,i){if(n(i).text().toLowerCase().charAt(0)===o)return n(i).focus(),f=!0,!1},this)),f)return}},this)).on("init.jstree",n.proxy(function(){var n=this.settings.core.themes;this._data.core.themes.dots=n.dots,this._data.core.themes.stripes=n.stripes,this._data.core.themes.icons=n.icons,this.set_theme(n.name||"default",n.url),this.set_theme_variant(n.variant)},this)).on("loading.jstree",n.proxy(function(){this[this._data.core.themes.dots?"show_dots":"hide_dots"](),this[this._data.core.themes.icons?"show_icons":"hide_icons"](),this[this._data.core.themes.stripes?"show_stripes":"hide_stripes"]()},this)).on("blur.jstree",".jstree-anchor",n.proxy(function(t){this._data.core.focused=null,n(t.currentTarget).filter(".jstree-hovered").mouseleave(),this.element.attr("tabindex","0")},this)).on("focus.jstree",".jstree-anchor",n.proxy(function(t){var i=this.get_node(t.currentTarget);i&&i.id&&(this._data.core.focused=i.id),this.element.find(".jstree-hovered").not(t.currentTarget).mouseleave(),n(t.currentTarget).mouseenter(),this.element.attr("tabindex","-1")},this)).on("focus.jstree",n.proxy(function(){if(+new Date-u>500&&!this._data.core.focused){u=0;var n=this.get_node(this.element.attr("aria-activedescendant"),!0);n&&n.find("> .jstree-anchor").focus()}},this)).on("mouseenter.jstree",".jstree-anchor",n.proxy(function(n){this.hover_node(n.currentTarget)},this)).on("mouseleave.jstree",".jstree-anchor",n.proxy(function(n){this.dehover_node(n.currentTarget)},this))},unbind:function(){this.element.off(".jstree"),n(i).off(".jstree-"+this._id)},trigger:function(n,t){t||(t={}),t.instance=this,this.element.triggerHandler(n.replace(".jstree","")+".jstree",t)},get_container:function(){return this.element},get_container_ul:function(){return this.element.children(".jstree-children").first()},get_string:function(t){var i=this.settings.core.strings;return n.isFunction(i)?i.call(this,t):i&&i[t]?i[t]:t},_firstChild:function(n){for(n=n?n.firstChild:null;null!==n&&1!==n.nodeType;)n=n.nextSibling;return n},_nextSibling:function(n){for(n=n?n.nextSibling:null;null!==n&&1!==n.nodeType;)n=n.nextSibling;return n},_previousSibling:function(n){for(n=n?n.previousSibling:null;null!==n&&1!==n.nodeType;)n=n.previousSibling;return n},get_node:function(t,i){t&&t.id&&(t=t.id);var r;try{if(this._model.data[t])t=this._model.data[t];else if("string"==typeof t&&this._model.data[t.replace(/^#/,"")])t=this._model.data[t.replace(/^#/,"")];else if("string"==typeof t&&(r=n("#"+t.replace(n.jstree.idregex,"\\$&"),this.element)).length&&this._model.data[r.closest(".jstree-node").attr("id")])t=this._model.data[r.closest(".jstree-node").attr("id")];else if((r=n(t,this.element)).length&&this._model.data[r.closest(".jstree-node").attr("id")])t=this._model.data[r.closest(".jstree-node").attr("id")];else{if(!(r=n(t,this.element)).length||!r.hasClass("jstree"))return!1;t=this._model.data[n.jstree.root]}return i&&(t=t.id===n.jstree.root?this.element:n("#"+t.id.replace(n.jstree.idregex,"\\$&"),this.element)),t}catch(u){return!1}},get_path:function(t,i,r){if(t=t.parents?t:this.get_node(t),!t||t.id===n.jstree.root||!t.parents)return!1;var f,e,u=[];for(u.push(r?t.id:t.text),f=0,e=t.parents.length;e>f;f++)u.push(r?t.parents[f]:this.get_text(t.parents[f]));return u=u.reverse().slice(1),i?u.join(i):u},get_next_dom:function(t,i){var r;if(t=this.get_node(t,!0),t[0]===this.element[0]){for(r=this._firstChild(this.get_container_ul()[0]);r&&0===r.offsetHeight;)r=this._nextSibling(r);return r?n(r):!1}if(!t||!t.length)return!1;if(i){r=t[0];do r=this._nextSibling(r);while(r&&0===r.offsetHeight);return r?n(r):!1}if(t.hasClass("jstree-open")){for(r=this._firstChild(t.children(".jstree-children")[0]);r&&0===r.offsetHeight;)r=this._nextSibling(r);if(null!==r)return n(r)}r=t[0];do r=this._nextSibling(r);while(r&&0===r.offsetHeight);return null!==r?n(r):t.parentsUntil(".jstree",".jstree-node").nextAll(".jstree-node:visible").first()},get_prev_dom:function(t,i){var r;if(t=this.get_node(t,!0),t[0]===this.element[0]){for(r=this.get_container_ul()[0].lastChild;r&&0===r.offsetHeight;)r=this._previousSibling(r);return r?n(r):!1}if(!t||!t.length)return!1;if(i){r=t[0];do r=this._previousSibling(r);while(r&&0===r.offsetHeight);return r?n(r):!1}r=t[0];do r=this._previousSibling(r);while(r&&0===r.offsetHeight);if(null!==r){for(t=n(r);t.hasClass("jstree-open");)t=t.children(".jstree-children").first().children(".jstree-node:visible:last");return t}return r=t[0].parentNode.parentNode,r&&r.className&&-1!==r.className.indexOf("jstree-node")?n(r):!1},get_parent:function(t){return t=this.get_node(t),t&&t.id!==n.jstree.root?t.parent:!1},get_children_dom:function(n){return n=this.get_node(n,!0),n[0]===this.element[0]?this.get_container_ul().children(".jstree-node"):n&&n.length?n.children(".jstree-children").children(".jstree-node"):!1},is_parent:function(n){return n=this.get_node(n),n&&(n.state.loaded===!1||n.children.length>0)},is_loaded:function(n){return n=this.get_node(n),n&&n.state.loaded},is_loading:function(n){return n=this.get_node(n),n&&n.state&&n.state.loading},is_open:function(n){return n=this.get_node(n),n&&n.state.opened},is_closed:function(n){return n=this.get_node(n),n&&this.is_parent(n)&&!n.state.opened},is_leaf:function(n){return!this.is_parent(n)},load_node:function(t,i){var r,f,u,e,o;if(n.isArray(t))return this._load_nodes(t.slice(),i),!0;if(t=this.get_node(t),!t)return i&&i.call(this,t,!1),!1;if(t.state.loaded){for(t.state.loaded=!1,r=0,f=t.children_d.length;f>r;r++){for(u=0,e=t.parents.length;e>u;u++)this._model.data[t.parents[u]].children_d=n.vakata.array_remove_item(this._model.data[t.parents[u]].children_d,t.children_d[r]);this._model.data[t.children_d[r]].state.selected&&(o=!0,this._data.core.selected=n.vakata.array_remove_item(this._data.core.selected,t.children_d[r])),delete this._model.data[t.children_d[r]]}t.children=[],t.children_d=[],o&&this.trigger("changed",{action:"load_node",node:t,selected:this._data.core.selected})}return t.state.failed=!1,t.state.loading=!0,this.get_node(t,!0).addClass("jstree-loading").attr("aria-busy",!0),this._load_node(t,n.proxy(function(n){t=this._model.data[t.id],t.state.loading=!1,t.state.loaded=n,t.state.failed=!t.state.loaded;for(var r=this.get_node(t,!0),u=0,o=0,f=this._model.data,e=!1,u=0,o=t.children.length;o>u;u++)if(f[t.children[u]]&&!f[t.children[u]].state.hidden){e=!0;break}t.state.loaded&&!e&&r&&r.length&&!r.hasClass("jstree-leaf")&&r.removeClass("jstree-closed jstree-open").addClass("jstree-leaf"),r.removeClass("jstree-loading").attr("aria-busy",!1),this.trigger("load_node",{node:t,status:n}),i&&i.call(this,t,n)},this)),!0},_load_nodes:function(n,t,i){for(var e=!0,s=function(){this._load_nodes(n,t,!0)},u=this._model.data,o=[],r=0,f=n.length;f>r;r++)!u[n[r]]||(u[n[r]].state.loaded||u[n[r]].state.failed)&&i||(this.is_loading(n[r])||this.load_node(n[r],s),e=!1);if(e){for(r=0,f=n.length;f>r;r++)u[n[r]]&&u[n[r]].state.loaded&&o.push(n[r]);t&&!t.done&&(t.call(this,o),t.done=!0)}},load_all:function(t,i){if(t||(t=n.jstree.root),t=this.get_node(t),!t)return!1;var f=[],e=this._model.data,u=e[t.id].children_d,r,o;for(t.state&&!t.state.loaded&&f.push(t.id),r=0,o=u.length;o>r;r++)e[u[r]]&&e[u[r]].state&&!e[u[r]].state.loaded&&f.push(u[r]);f.length?this._load_nodes(f,function(){this.load_all(t,i)}):(i&&i.call(this,t),this.trigger("load_all",{node:t}))},_load_node:function(t,i){var r=this.settings.core.data,u;return r?n.isFunction(r)?r.call(this,t,n.proxy(function(r){r===!1&&i.call(this,!1),this["string"==typeof r?"_append_html_data":"_append_json_data"](t,"string"==typeof r?n(n.parseHTML(r)).filter(function(){return 3!==this.nodeType}):r,function(n){i.call(this,n)})},this)):"object"==typeof r?r.url?(r=n.extend(!0,{},r),n.isFunction(r.url)&&(r.url=r.url.call(this,t)),n.isFunction(r.data)&&(r.data=r.data.call(this,t)),n.ajax(r).done(n.proxy(function(r,u,f){var e=f.getResponseHeader("Content-Type");return e&&-1!==e.indexOf("json")||"object"==typeof r?this._append_json_data(t,r,function(n){i.call(this,n)}):e&&-1!==e.indexOf("html")||"string"==typeof r?this._append_html_data(t,n(n.parseHTML(r)).filter(function(){return 3!==this.nodeType}),function(n){i.call(this,n)}):(this._data.core.last_error={error:"ajax",plugin:"core",id:"core_04",reason:"Could not load node",data:JSON.stringify({id:t.id,xhr:f})},this.settings.core.error.call(this,this._data.core.last_error),i.call(this,!1))},this)).fail(n.proxy(function(n){i.call(this,!1),this._data.core.last_error={error:"ajax",plugin:"core",id:"core_04",reason:"Could not load node",data:JSON.stringify({id:t.id,xhr:n})},this.settings.core.error.call(this,this._data.core.last_error)},this))):(u=n.isArray(r)||n.isPlainObject(r)?JSON.parse(JSON.stringify(r)):r,t.id===n.jstree.root?this._append_json_data(t,u,function(n){i.call(this,n)}):(this._data.core.last_error={error:"nodata",plugin:"core",id:"core_05",reason:"Could not load node",data:JSON.stringify({id:t.id})},this.settings.core.error.call(this,this._data.core.last_error),i.call(this,!1))):"string"==typeof r?t.id===n.jstree.root?this._append_html_data(t,n(n.parseHTML(r)).filter(function(){return 3!==this.nodeType}),function(n){i.call(this,n)}):(this._data.core.last_error={error:"nodata",plugin:"core",id:"core_06",reason:"Could not load node",data:JSON.stringify({id:t.id})},this.settings.core.error.call(this,this._data.core.last_error),i.call(this,!1)):i.call(this,!1):t.id===n.jstree.root?this._append_html_data(t,this._data.core.original_container_html.clone(!0),function(n){i.call(this,n)}):i.call(this,!1)},_node_changed:function(n){n=this.get_node(n),n&&this._model.changed.push(n.id)},_append_html_data:function(t,i,r){t=this.get_node(t),t.children=[],t.children_d=[];var a=i.is("ul")?i.children():i,o=t.id,c=[],u=[],s=this._model.data,f=s[o],v=this._data.core.selected.length,e,h,l;for(a.each(n.proxy(function(t,i){e=this._parse_model_from_html(n(i),o,f.parents.concat()),e&&(c.push(e),u.push(e),s[e].children_d.length&&(u=u.concat(s[e].children_d)))},this)),f.children=c,f.children_d=u,h=0,l=f.parents.length;l>h;h++)s[f.parents[h]].children_d=s[f.parents[h]].children_d.concat(u);this.trigger("model",{nodes:u,parent:o}),o!==n.jstree.root?(this._node_changed(o),this.redraw()):(this.get_container_ul().children(".jstree-initial-node").remove(),this.redraw(!0)),this._data.core.selected.length!==v&&this.trigger("changed",{action:"model",selected:this._data.core.selected}),r.call(this,!0)},_append_json_data:function(t,i,r,u){if(null!==this.element){t=this.get_node(t),t.children=[],t.children_d=[],i.d&&(i=i.d,"string"==typeof i&&(i=JSON.parse(i))),n.isArray(i)||(i=[i]);var f=null,e={df:this._model.default_state,dat:i,par:t.id,m:this._model.data,t_id:this._id,t_cnt:this._cnt,sel:this._data.core.selected},o=function(n,t){n.data&&(n=n.data);var u=n.dat,c=n.par,y=[],o=[],l=[],h=n.df,k=n.t_id,v=n.t_cnt,r=n.m,f=r[c],p=n.sel,s,i,e,a,w=function(n,i,u){u=u?u.concat():[],i&&u.unshift(i);var c=n.id.toString(),e,a,o,s,f={id:c,text:n.text||"",icon:n.icon!==t?n.icon:!0,parent:i,parents:u,children:n.children||[],children_d:n.children_d||[],data:n.data,state:{},li_attr:{id:!1},a_attr:{href:"#"},original:!1};for(e in h)h.hasOwnProperty(e)&&(f.state[e]=h[e]);if(n&&n.data&&n.data.jstree&&n.data.jstree.icon&&(f.icon=n.data.jstree.icon),(f.icon===t||null===f.icon||""===f.icon)&&(f.icon=!0),n&&n.data&&(f.data=n.data,n.data.jstree))for(e in n.data.jstree)n.data.jstree.hasOwnProperty(e)&&(f.state[e]=n.data.jstree[e]);if(n&&"object"==typeof n.state)for(e in n.state)n.state.hasOwnProperty(e)&&(f.state[e]=n.state[e]);if(n&&"object"==typeof n.li_attr)for(e in n.li_attr)n.li_attr.hasOwnProperty(e)&&(f.li_attr[e]=n.li_attr[e]);if(f.li_attr.id||(f.li_attr.id=c),n&&"object"==typeof n.a_attr)for(e in n.a_attr)n.a_attr.hasOwnProperty(e)&&(f.a_attr[e]=n.a_attr[e]);for(n&&n.children&&n.children===!0&&(f.state.loaded=!1,f.children=[],f.children_d=[]),r[f.id]=f,e=0,a=f.children.length;a>e;e++)o=w(r[f.children[e]],f.id,u),s=r[o],f.children_d.push(o),s.children_d.length&&(f.children_d=f.children_d.concat(s.children_d));return delete n.data,delete n.children,r[f.id].original=n,f.state.selected&&l.push(f.id),f.id},b=function(n,i,u){u=u?u.concat():[],i&&u.unshift(i);var o=!1,e,a,s,c,f;do o="j"+k+"_"+ ++v;while(r[o]);f={id:!1,text:"string"==typeof n?n:"",icon:"object"==typeof n&&n.icon!==t?n.icon:!0,parent:i,parents:u,children:[],children_d:[],data:null,state:{},li_attr:{id:!1},a_attr:{href:"#"},original:!1};for(e in h)h.hasOwnProperty(e)&&(f.state[e]=h[e]);if(n&&n.id&&(f.id=n.id.toString()),n&&n.text&&(f.text=n.text),n&&n.data&&n.data.jstree&&n.data.jstree.icon&&(f.icon=n.data.jstree.icon),(f.icon===t||null===f.icon||""===f.icon)&&(f.icon=!0),n&&n.data&&(f.data=n.data,n.data.jstree))for(e in n.data.jstree)n.data.jstree.hasOwnProperty(e)&&(f.state[e]=n.data.jstree[e]);if(n&&"object"==typeof n.state)for(e in n.state)n.state.hasOwnProperty(e)&&(f.state[e]=n.state[e]);if(n&&"object"==typeof n.li_attr)for(e in n.li_attr)n.li_attr.hasOwnProperty(e)&&(f.li_attr[e]=n.li_attr[e]);if(f.li_attr.id&&!f.id&&(f.id=f.li_attr.id.toString()),f.id||(f.id=o),f.li_attr.id||(f.li_attr.id=f.id),n&&"object"==typeof n.a_attr)for(e in n.a_attr)n.a_attr.hasOwnProperty(e)&&(f.a_attr[e]=n.a_attr[e]);if(n&&n.children&&n.children.length){for(e=0,a=n.children.length;a>e;e++)s=b(n.children[e],f.id,u),c=r[s],f.children.push(s),c.children_d.length&&(f.children_d=f.children_d.concat(c.children_d));f.children_d=f.children_d.concat(f.children)}return n&&n.children&&n.children===!0&&(f.state.loaded=!1,f.children=[],f.children_d=[]),delete n.data,delete n.children,f.original=n,r[f.id]=f,f.state.selected&&l.push(f.id),f.id};if(u.length&&u[0].id!==t&&u[0].parent!==t){for(i=0,e=u.length;e>i;i++)u[i].children||(u[i].children=[]),r[u[i].id.toString()]=u[i];for(i=0,e=u.length;e>i;i++)r[u[i].parent.toString()].children.push(u[i].id.toString()),f.children_d.push(u[i].id.toString());for(i=0,e=f.children.length;e>i;i++)s=w(r[f.children[i]],c,f.parents.concat()),o.push(s),r[s].children_d.length&&(o=o.concat(r[s].children_d));for(i=0,e=f.parents.length;e>i;i++)r[f.parents[i]].children_d=r[f.parents[i]].children_d.concat(o);a={cnt:v,mod:r,sel:p,par:c,dpc:o,add:l}}else{for(i=0,e=u.length;e>i;i++)s=b(u[i],c,f.parents.concat()),s&&(y.push(s),o.push(s),r[s].children_d.length&&(o=o.concat(r[s].children_d)));for(f.children=y,f.children_d=o,i=0,e=f.parents.length;e>i;i++)r[f.parents[i]].children_d=r[f.parents[i]].children_d.concat(o);a={cnt:v,mod:r,sel:p,par:c,dpc:o,add:l}}return"undefined"!=typeof window&&"undefined"!=typeof window.document?a:void postMessage(a)},s=function(t,i){if(null!==this.element){if(this._cnt=t.cnt,this._model.data=t.mod,i){var u,o,h=t.add,f=t.sel,e=this._data.core.selected.slice(),s=this._model.data;if(f.length!==e.length||n.vakata.array_unique(f.concat(e)).length!==f.length){for(u=0,o=f.length;o>u;u++)-1===n.inArray(f[u],h)&&-1===n.inArray(f[u],e)&&(s[f[u]].state.selected=!1);for(u=0,o=e.length;o>u;u++)-1===n.inArray(e[u],f)&&(s[e[u]].state.selected=!0)}}t.add.length&&(this._data.core.selected=this._data.core.selected.concat(t.add)),this.trigger("model",{nodes:t.dpc,parent:t.par}),t.par!==n.jstree.root?(this._node_changed(t.par),this.redraw()):this.redraw(!0),t.add.length&&this.trigger("changed",{action:"model",selected:this._data.core.selected}),r.call(this,!0)}};if(this.settings.core.worker&&window.Blob&&window.URL&&window.Worker)try{null===this._wrk&&(this._wrk=window.URL.createObjectURL(new window.Blob(["self.onmessage = "+o.toString()],{type:"text/javascript"}))),!this._data.core.working||u?(this._data.core.working=!0,f=new window.Worker(this._wrk),f.onmessage=n.proxy(function(n){s.call(this,n.data,!0);try{f.terminate(),f=null}catch(t){}this._data.core.worker_queue.length?this._append_json_data.apply(this,this._data.core.worker_queue.shift()):this._data.core.working=!1},this),e.par?f.postMessage(e):this._data.core.worker_queue.length?this._append_json_data.apply(this,this._data.core.worker_queue.shift()):this._data.core.working=!1):this._data.core.worker_queue.push([t,i,r,!0])}catch(h){s.call(this,o(e),!1),this._data.core.worker_queue.length?this._append_json_data.apply(this,this._data.core.worker_queue.shift()):this._data.core.working=!1}else s.call(this,o(e),!1)}},_parse_model_from_html:function(i,r,u){u=u?[].concat(u):[],r&&u.unshift(r);var s,h,l=this._model.data,f={id:!1,text:!1,icon:!0,parent:r,parents:u,children:[],children_d:[],data:null,state:{},li_attr:{id:!1},a_attr:{href:"#"},original:!1},o,e,c;for(o in this._model.default_state)this._model.default_state.hasOwnProperty(o)&&(f.state[o]=this._model.default_state[o]);if(e=n.vakata.attributes(i,!0),n.each(e,function(t,i){return i=n.trim(i),i.length?(f.li_attr[t]=i,void("id"===t&&(f.id=i.toString()))):!0}),e=i.children("a").first(),e.length&&(e=n.vakata.attributes(e,!0),n.each(e,function(t,i){i=n.trim(i),i.length&&(f.a_attr[t]=i)})),e=i.children("a").first().length?i.children("a").first().clone():i.clone(),e.children("ins, i, ul").remove(),e=e.html(),e=n("<div />").html(e),f.text=this.settings.core.force_text?e.text():e.html(),e=i.data(),f.data=e?n.extend(!0,{},e):null,f.state.opened=i.hasClass("jstree-open"),f.state.selected=i.children("a").hasClass("jstree-clicked"),f.state.disabled=i.children("a").hasClass("jstree-disabled"),f.data&&f.data.jstree)for(o in f.data.jstree)f.data.jstree.hasOwnProperty(o)&&(f.state[o]=f.data.jstree[o]);e=i.children("a").children(".jstree-themeicon"),e.length&&(f.icon=e.hasClass("jstree-themeicon-hidden")?!1:e.attr("rel")),f.state.icon!==t&&(f.icon=f.state.icon),(f.icon===t||null===f.icon||""===f.icon)&&(f.icon=!0),e=i.children("ul").children("li");do c="j"+this._id+"_"+ ++this._cnt;while(l[c]);return f.id=f.li_attr.id?f.li_attr.id.toString():c,e.length?(e.each(n.proxy(function(t,i){s=this._parse_model_from_html(n(i),f.id,u),h=this._model.data[s],f.children.push(s),h.children_d.length&&(f.children_d=f.children_d.concat(h.children_d))},this)),f.children_d=f.children_d.concat(f.children)):i.hasClass("jstree-closed")&&(f.state.loaded=!1),f.li_attr["class"]&&(f.li_attr["class"]=f.li_attr["class"].replace("jstree-closed","").replace("jstree-open","")),f.a_attr["class"]&&(f.a_attr["class"]=f.a_attr["class"].replace("jstree-clicked","").replace("jstree-disabled","")),l[f.id]=f,f.state.selected&&this._data.core.selected.push(f.id),f.id},_parse_model_from_flat_json:function(n,i,r){r=r?r.concat():[],i&&r.unshift(i);var c=n.id.toString(),e=this._model.data,o=this._model.default_state,f,l,s,h,u={id:c,text:n.text||"",icon:n.icon!==t?n.icon:!0,parent:i,parents:r,children:n.children||[],children_d:n.children_d||[],data:n.data,state:{},li_attr:{id:!1},a_attr:{href:"#"},original:!1};for(f in o)o.hasOwnProperty(f)&&(u.state[f]=o[f]);if(n&&n.data&&n.data.jstree&&n.data.jstree.icon&&(u.icon=n.data.jstree.icon),(u.icon===t||null===u.icon||""===u.icon)&&(u.icon=!0),n&&n.data&&(u.data=n.data,n.data.jstree))for(f in n.data.jstree)n.data.jstree.hasOwnProperty(f)&&(u.state[f]=n.data.jstree[f]);if(n&&"object"==typeof n.state)for(f in n.state)n.state.hasOwnProperty(f)&&(u.state[f]=n.state[f]);if(n&&"object"==typeof n.li_attr)for(f in n.li_attr)n.li_attr.hasOwnProperty(f)&&(u.li_attr[f]=n.li_attr[f]);if(u.li_attr.id||(u.li_attr.id=c),n&&"object"==typeof n.a_attr)for(f in n.a_attr)n.a_attr.hasOwnProperty(f)&&(u.a_attr[f]=n.a_attr[f]);for(n&&n.children&&n.children===!0&&(u.state.loaded=!1,u.children=[],u.children_d=[]),e[u.id]=u,f=0,l=u.children.length;l>f;f++)s=this._parse_model_from_flat_json(e[u.children[f]],u.id,r),h=e[s],u.children_d.push(s),h.children_d.length&&(u.children_d=u.children_d.concat(h.children_d));return delete n.data,delete n.children,e[u.id].original=n,u.state.selected&&this._data.core.selected.push(u.id),u.id},_parse_model_from_json:function(n,i,r){r=r?r.concat():[],i&&r.unshift(i);var e=!1,f,l,o,s,h=this._model.data,c=this._model.default_state,u;do e="j"+this._id+"_"+ ++this._cnt;while(h[e]);u={id:!1,text:"string"==typeof n?n:"",icon:"object"==typeof n&&n.icon!==t?n.icon:!0,parent:i,parents:r,children:[],children_d:[],data:null,state:{},li_attr:{id:!1},a_attr:{href:"#"},original:!1};for(f in c)c.hasOwnProperty(f)&&(u.state[f]=c[f]);if(n&&n.id&&(u.id=n.id.toString()),n&&n.text&&(u.text=n.text),n&&n.data&&n.data.jstree&&n.data.jstree.icon&&(u.icon=n.data.jstree.icon),(u.icon===t||null===u.icon||""===u.icon)&&(u.icon=!0),n&&n.data&&(u.data=n.data,n.data.jstree))for(f in n.data.jstree)n.data.jstree.hasOwnProperty(f)&&(u.state[f]=n.data.jstree[f]);if(n&&"object"==typeof n.state)for(f in n.state)n.state.hasOwnProperty(f)&&(u.state[f]=n.state[f]);if(n&&"object"==typeof n.li_attr)for(f in n.li_attr)n.li_attr.hasOwnProperty(f)&&(u.li_attr[f]=n.li_attr[f]);if(u.li_attr.id&&!u.id&&(u.id=u.li_attr.id.toString()),u.id||(u.id=e),u.li_attr.id||(u.li_attr.id=u.id),n&&"object"==typeof n.a_attr)for(f in n.a_attr)n.a_attr.hasOwnProperty(f)&&(u.a_attr[f]=n.a_attr[f]);if(n&&n.children&&n.children.length){for(f=0,l=n.children.length;l>f;f++)o=this._parse_model_from_json(n.children[f],u.id,r),s=h[o],u.children.push(o),s.children_d.length&&(u.children_d=u.children_d.concat(s.children_d));u.children_d=u.children_d.concat(u.children)}return n&&n.children&&n.children===!0&&(u.state.loaded=!1,u.children=[],u.children_d=[]),delete n.data,delete n.children,u.original=n,h[u.id]=u,u.state.selected&&this._data.core.selected.push(u.id),u.id},_redraw:function(){for(var f=this._model.force_full_redraw?this._model.data[n.jstree.root].children.concat([]):this._model.changed.concat([]),r=i.createElement("UL"),t,e=this._data.core.focused,u=0,o=f.length;o>u;u++)t=this.redraw_node(f[u],!0,this._model.force_full_redraw),t&&this._model.force_full_redraw&&r.appendChild(t);this._model.force_full_redraw&&(r.className=this.get_container_ul()[0].className,r.setAttribute("role","group"),this.element.empty().append(r)),null!==e&&(t=this.get_node(e,!0),t&&t.length&&t.children(".jstree-anchor")[0]!==i.activeElement?t.children(".jstree-anchor").focus():this._data.core.focused=null),this._model.force_full_redraw=!1,this._model.changed=[],this.trigger("redraw",{nodes:f})},redraw:function(n){n&&(this._model.force_full_redraw=!0),this._redraw()},draw_children:function(t){var r=this.get_node(t),f=!1,e=!1,u=!1,o=i;if(!r)return!1;if(r.id===n.jstree.root)return this.redraw(!0);if(t=this.get_node(t,!0),!t||!t.length)return!1;if(t.children(".jstree-children").remove(),t=t[0],r.children.length&&r.state.loaded){for(u=o.createElement("UL"),u.setAttribute("role","group"),u.className="jstree-children",f=0,e=r.children.length;e>f;f++)u.appendChild(this.redraw_node(r.children[f],!0,!0));t.appendChild(u)}},redraw_node:function(t,r,u,f){var e=this.get_node(t),s=!1,p=!1,b=!1,o=!1,c=!1,y=!1,l="",k=i,a=this._model.data,d=!1,it=!1,v=null,g=0,nt=0,tt=!1,w=!1;if(!e)return!1;if(e.id===n.jstree.root)return this.redraw(!0);if(r=r||0===e.children.length,t=i.querySelector?this.element[0].querySelector("#"+(-1!=="0123456789".indexOf(e.id[0])?"\\3"+e.id[0]+" "+e.id.substr(1).replace(n.jstree.idregex,"\\$&"):e.id.replace(n.jstree.idregex,"\\$&"))):i.getElementById(e.id))t=n(t),u||(s=t.parent().parent()[0],s===this.element[0]&&(s=null),p=t.index()),r||!e.children.length||t.children(".jstree-children").length||(r=!0),r||(b=t.children(".jstree-children")[0]),d=t.children(".jstree-anchor")[0]===i.activeElement,t.remove();else if(r=!0,!u){if(s=e.parent!==n.jstree.root?n("#"+e.parent.replace(n.jstree.idregex,"\\$&"),this.element)[0]:null,!(null===s||s&&a[e.parent].state.opened))return!1;p=n.inArray(e.id,null===s?a[n.jstree.root].children:a[e.parent].children)}t=h.cloneNode(!0),l="jstree-node ";for(o in e.li_attr)if(e.li_attr.hasOwnProperty(o)){if("id"===o)continue;"class"!==o?t.setAttribute(o,e.li_attr[o]):l+=e.li_attr[o]}for(e.a_attr.id||(e.a_attr.id=e.id+"_anchor"),t.setAttribute("aria-selected",!!e.state.selected),t.setAttribute("aria-level",e.parents.length),t.setAttribute("aria-labelledby",e.a_attr.id),e.state.disabled&&t.setAttribute("aria-disabled",!0),o=0,c=e.children.length;c>o;o++)if(!a[e.children[o]].state.hidden){tt=!0;break}if(null!==e.parent&&a[e.parent]&&!e.state.hidden&&(o=n.inArray(e.id,a[e.parent].children),w=e.id,-1!==o))for(o++,c=a[e.parent].children.length;c>o;o++)if(a[a[e.parent].children[o]].state.hidden||(w=a[e.parent].children[o]),w!==e.id)break;e.state.hidden&&(l+=" jstree-hidden"),e.state.loaded&&!tt?l+=" jstree-leaf":(l+=e.state.opened&&e.state.loaded?" jstree-open":" jstree-closed",t.setAttribute("aria-expanded",e.state.opened&&e.state.loaded)),w===e.id&&(l+=" jstree-last"),t.id=e.id,t.className=l,l=(e.state.selected?" jstree-clicked":"")+(e.state.disabled?" jstree-disabled":"");for(c in e.a_attr)if(e.a_attr.hasOwnProperty(c)){if("href"===c&&"#"===e.a_attr[c])continue;"class"!==c?t.childNodes[1].setAttribute(c,e.a_attr[c]):l+=" "+e.a_attr[c]}if(l.length&&(t.childNodes[1].className="jstree-anchor "+l),(e.icon&&e.icon!==!0||e.icon===!1)&&(e.icon===!1?t.childNodes[1].childNodes[0].className+=" jstree-themeicon-hidden":-1===e.icon.indexOf("/")&&-1===e.icon.indexOf(".")?t.childNodes[1].childNodes[0].className+=" "+e.icon+" jstree-themeicon-custom":(t.childNodes[1].childNodes[0].style.backgroundImage="url("+e.icon+")",t.childNodes[1].childNodes[0].style.backgroundPosition="center center",t.childNodes[1].childNodes[0].style.backgroundSize="auto",t.childNodes[1].childNodes[0].className+=" jstree-themeicon-custom")),this.settings.core.force_text?t.childNodes[1].appendChild(k.createTextNode(e.text)):t.childNodes[1].innerHTML+=e.text,r&&e.children.length&&(e.state.opened||f)&&e.state.loaded){for(y=k.createElement("UL"),y.setAttribute("role","group"),y.className="jstree-children",o=0,c=e.children.length;c>o;o++)y.appendChild(this.redraw_node(e.children[o],r,!0));t.appendChild(y)}if(b&&t.appendChild(b),!u){for(s||(s=this.element[0]),o=0,c=s.childNodes.length;c>o;o++)if(s.childNodes[o]&&s.childNodes[o].className&&-1!==s.childNodes[o].className.indexOf("jstree-children")){v=s.childNodes[o];break}v||(v=k.createElement("UL"),v.setAttribute("role","group"),v.className="jstree-children",s.appendChild(v)),s=v,p<s.childNodes.length?s.insertBefore(t,s.childNodes[p]):s.appendChild(t),d&&(g=this.element[0].scrollTop,nt=this.element[0].scrollLeft,t.childNodes[1].focus(),this.element[0].scrollTop=g,this.element[0].scrollLeft=nt)}return e.state.opened&&!e.state.loaded&&(e.state.opened=!1,setTimeout(n.proxy(function(){this.open_node(e.id,!1,0)},this),0)),t},open_node:function(i,r,u){var e,o,f,s;if(n.isArray(i)){for(i=i.slice(),e=0,o=i.length;o>e;e++)this.open_node(i[e],r,u);return!0}return i=this.get_node(i),i&&i.id!==n.jstree.root?(u=u===t?this.settings.core.animation:u,this.is_closed(i)?this.is_loaded(i)?(f=this.get_node(i,!0),s=this,f.length&&(u&&f.children(".jstree-children").length&&f.children(".jstree-children").stop(!0,!0),i.children.length&&!this._firstChild(f.children(".jstree-children")[0])&&this.draw_children(i),u?(this.trigger("before_open",{node:i}),f.children(".jstree-children").css("display","none").end().removeClass("jstree-closed").addClass("jstree-open").attr("aria-expanded",!0).children(".jstree-children").stop(!0,!0).slideDown(u,function(){this.style.display="",s.trigger("after_open",{node:i})})):(this.trigger("before_open",{node:i}),f[0].className=f[0].className.replace("jstree-closed","jstree-open"),f[0].setAttribute("aria-expanded",!0))),i.state.opened=!0,r&&r.call(this,i,!0),f.length||this.trigger("before_open",{node:i}),this.trigger("open_node",{node:i}),u&&f.length||this.trigger("after_open",{node:i}),!0):this.is_loading(i)?setTimeout(n.proxy(function(){this.open_node(i,r,u)},this),500):void this.load_node(i,function(n,t){return t?this.open_node(n,r,u):r?r.call(this,n,!1):!1}):(r&&r.call(this,i,!1),!1)):!1},_open_to:function(t){if(t=this.get_node(t),!t||t.id===n.jstree.root)return!1;for(var r=t.parents,i=0,u=r.length;u>i;i+=1)i!==n.jstree.root&&this.open_node(r[i],!1,0);return n("#"+t.id.replace(n.jstree.idregex,"\\$&"),this.element)},close_node:function(i,r){var f,e,o,u;if(n.isArray(i)){for(i=i.slice(),f=0,e=i.length;e>f;f++)this.close_node(i[f],r);return!0}return i=this.get_node(i),i&&i.id!==n.jstree.root?this.is_closed(i)?!1:(r=r===t?this.settings.core.animation:r,o=this,u=this.get_node(i,!0),i.state.opened=!1,this.trigger("close_node",{node:i}),void(r&&u.length?u.length&&(r?u.children(".jstree-children").attr("style","display:block !important").end().removeClass("jstree-open").addClass("jstree-closed").attr("aria-expanded",!1).children(".jstree-children").stop(!0,!0).slideUp(r,function(){this.style.display="",u.children(".jstree-children").remove(),o.trigger("after_close",{node:i})}):(u[0].className=u[0].className.replace("jstree-open","jstree-closed"),u.attr("aria-expanded",!1).children(".jstree-children").remove())):this.trigger("after_close",{node:i}))):!1},toggle_node:function(t){var i,r;if(n.isArray(t)){for(t=t.slice(),i=0,r=t.length;r>i;i++)this.toggle_node(t[i]);return!0}return this.is_closed(t)?this.open_node(t):this.is_open(t)?this.close_node(t):void 0},open_all:function(t,i,r){if(t||(t=n.jstree.root),t=this.get_node(t),!t)return!1;var u=t.id===n.jstree.root?this.get_container_ul():this.get_node(t,!0),f,e,o;if(!u.length){for(f=0,e=t.children_d.length;e>f;f++)this.is_closed(this._model.data[t.children_d[f]])&&(this._model.data[t.children_d[f]].state.opened=!0);return this.trigger("open_all",{node:t})}r=r||u,o=this,u=this.is_closed(t)?u.find(".jstree-closed").addBack():u.find(".jstree-closed"),u.each(function(){o.open_node(this,function(n,t){t&&this.is_parent(n)&&this.open_all(n,i,r)},i||0)}),0===r.find(".jstree-closed").length&&this.trigger("open_all",{node:this.get_node(r)})},close_all:function(t,i){if(t||(t=n.jstree.root),t=this.get_node(t),!t)return!1;var r=t.id===n.jstree.root?this.get_container_ul():this.get_node(t,!0),e=this,u,f;for(r.length&&(r=this.is_open(t)?r.find(".jstree-open").addBack():r.find(".jstree-open"),n(r.get().reverse()).each(function(){e.close_node(this,i||0)})),u=0,f=t.children_d.length;f>u;u++)this._model.data[t.children_d[u]].state.opened=!1;this.trigger("close_all",{node:t})},is_disabled:function(n){return n=this.get_node(n),n&&n.state&&n.state.disabled},enable_node:function(t){var i,r;if(n.isArray(t)){for(t=t.slice(),i=0,r=t.length;r>i;i++)this.enable_node(t[i]);return!0}return t=this.get_node(t),t&&t.id!==n.jstree.root?(t.state.disabled=!1,this.get_node(t,!0).children(".jstree-anchor").removeClass("jstree-disabled").attr("aria-disabled",!1),void this.trigger("enable_node",{node:t})):!1},disable_node:function(t){var i,r;if(n.isArray(t)){for(t=t.slice(),i=0,r=t.length;r>i;i++)this.disable_node(t[i]);return!0}return t=this.get_node(t),t&&t.id!==n.jstree.root?(t.state.disabled=!0,this.get_node(t,!0).children(".jstree-anchor").addClass("jstree-disabled").attr("aria-disabled",!0),void this.trigger("disable_node",{node:t})):!1},hide_node:function(t,i){var r,u;if(n.isArray(t)){for(t=t.slice(),r=0,u=t.length;u>r;r++)this.hide_node(t[r],!0);return this.redraw(),!0}return t=this.get_node(t),t&&t.id!==n.jstree.root?void(t.state.hidden||(t.state.hidden=!0,this._node_changed(t.parent),i||this.redraw(),this.trigger("hide_node",{node:t}))):!1},show_node:function(t,i){var r,u;if(n.isArray(t)){for(t=t.slice(),r=0,u=t.length;u>r;r++)this.show_node(t[r],!0);return this.redraw(),!0}return t=this.get_node(t),t&&t.id!==n.jstree.root?void(t.state.hidden&&(t.state.hidden=!1,this._node_changed(t.parent),i||this.redraw(),this.trigger("show_node",{node:t}))):!1},hide_all:function(t){var i,r=this._model.data,u=[];for(i in r)r.hasOwnProperty(i)&&i!==n.jstree.root&&!r[i].state.hidden&&(r[i].state.hidden=!0,u.push(i));return this._model.force_full_redraw=!0,t||this.redraw(),this.trigger("hide_all",{nodes:u}),u},show_all:function(t){var i,r=this._model.data,u=[];for(i in r)r.hasOwnProperty(i)&&i!==n.jstree.root&&r[i].state.hidden&&(r[i].state.hidden=!1,u.push(i));return this._model.force_full_redraw=!0,t||this.redraw(),this.trigger("show_all",{nodes:u}),u},activate_node:function(n,i){if(this.is_disabled(n))return!1;if(i&&"object"==typeof i||(i={}),this._data.core.last_clicked=this._data.core.last_clicked&&this._data.core.last_clicked.id!==t?this.get_node(this._data.core.last_clicked.id):null,this._data.core.last_clicked&&!this._data.core.last_clicked.state.selected&&(this._data.core.last_clicked=null),!this._data.core.last_clicked&&this._data.core.selected.length&&(this._data.core.last_clicked=this.get_node(this._data.core.selected[this._data.core.selected.length-1])),this.settings.core.multiple&&(i.metaKey||i.ctrlKey||i.shiftKey)&&(!i.shiftKey||this._data.core.last_clicked&&this.get_parent(n)&&this.get_parent(n)===this._data.core.last_clicked.parent))if(i.shiftKey){for(var e=this.get_node(n).id,o=this._data.core.last_clicked.id,u=this.get_node(this._data.core.last_clicked.parent).children,f=!1,r=0,s=u.length;s>r;r+=1)u[r]===e&&(f=!f),u[r]===o&&(f=!f),this.is_disabled(u[r])||!f&&u[r]!==e&&u[r]!==o?this.deselect_node(u[r],!0,i):this.select_node(u[r],!0,!1,i);this.trigger("changed",{action:"select_node",node:this.get_node(n),selected:this._data.core.selected,event:i})}else this.is_selected(n)?this.deselect_node(n,!1,i):this.select_node(n,!1,!1,i);else!this.settings.core.multiple&&(i.metaKey||i.ctrlKey||i.shiftKey)&&this.is_selected(n)?this.deselect_node(n,!1,i):(this.deselect_all(!0),this.select_node(n,!1,!1,i),this._data.core.last_clicked=this.get_node(n));this.trigger("activate_node",{node:this.get_node(n),event:i})},hover_node:function(n){if(n=this.get_node(n,!0),!n||!n.length||n.children(".jstree-hovered").length)return!1;var t=this.element.find(".jstree-hovered"),i=this.element;t&&t.length&&this.dehover_node(t),n.children(".jstree-anchor").addClass("jstree-hovered"),this.trigger("hover_node",{node:this.get_node(n)}),setTimeout(function(){i.attr("aria-activedescendant",n[0].id)},0)},dehover_node:function(n){return n=this.get_node(n,!0),n&&n.length&&n.children(".jstree-hovered").length?(n.children(".jstree-anchor").removeClass("jstree-hovered"),void this.trigger("dehover_node",{node:this.get_node(n)})):!1},select_node:function(t,i,r,u){var f,e,o,s;if(n.isArray(t)){for(t=t.slice(),e=0,o=t.length;o>e;e++)this.select_node(t[e],i,r,u);return!0}return t=this.get_node(t),t&&t.id!==n.jstree.root?(f=this.get_node(t,!0),void(t.state.selected||(t.state.selected=!0,this._data.core.selected.push(t.id),r||(f=this._open_to(t)),f&&f.length&&f.attr("aria-selected",!0).children(".jstree-anchor").addClass("jstree-clicked"),this.trigger("select_node",{node:t,selected:this._data.core.selected,event:u}),i||this.trigger("changed",{action:"select_node",node:t,selected:this._data.core.selected,event:u})))):!1},deselect_node:function(t,i,r){var u,e,f;if(n.isArray(t)){for(t=t.slice(),u=0,e=t.length;e>u;u++)this.deselect_node(t[u],i,r);return!0}return t=this.get_node(t),t&&t.id!==n.jstree.root?(f=this.get_node(t,!0),void(t.state.selected&&(t.state.selected=!1,this._data.core.selected=n.vakata.array_remove_item(this._data.core.selected,t.id),f.length&&f.attr("aria-selected",!1).children(".jstree-anchor").removeClass("jstree-clicked"),this.trigger("deselect_node",{node:t,selected:this._data.core.selected,event:r}),i||this.trigger("changed",{action:"deselect_node",node:t,selected:this._data.core.selected,event:r})))):!1},select_all:function(t){var u=this._data.core.selected.concat([]),i,r;for(this._data.core.selected=this._model.data[n.jstree.root].children_d.concat(),i=0,r=this._data.core.selected.length;r>i;i++)this._model.data[this._data.core.selected[i]]&&(this._model.data[this._data.core.selected[i]].state.selected=!0);this.redraw(!0),this.trigger("select_all",{selected:this._data.core.selected}),t||this.trigger("changed",{action:"select_all",selected:this._data.core.selected,old_selection:u})},deselect_all:function(n){for(var i=this._data.core.selected.concat([]),t=0,r=this._data.core.selected.length;r>t;t++)this._model.data[this._data.core.selected[t]]&&(this._model.data[this._data.core.selected[t]].state.selected=!1);this._data.core.selected=[],this.element.find(".jstree-clicked").removeClass("jstree-clicked").parent().attr("aria-selected",!1),this.trigger("deselect_all",{selected:this._data.core.selected,node:i}),n||this.trigger("changed",{action:"deselect_all",selected:this._data.core.selected,old_selection:i})},is_selected:function(t){return t=this.get_node(t),t&&t.id!==n.jstree.root?t.state.selected:!1},get_selected:function(t){return t?n.map(this._data.core.selected,n.proxy(function(n){return this.get_node(n)},this)):this._data.core.selected.slice()},get_top_selected:function(t){for(var r=this.get_selected(!0),u={},f,o,i=0,e=r.length;e>i;i++)u[r[i].id]=r[i];for(i=0,e=r.length;e>i;i++)for(f=0,o=r[i].children_d.length;o>f;f++)u[r[i].children_d[f]]&&delete u[r[i].children_d[f]];r=[];for(i in u)u.hasOwnProperty(i)&&r.push(i);return t?n.map(r,n.proxy(function(n){return this.get_node(n)},this)):r},get_bottom_selected:function(t){for(var r=this.get_selected(!0),u=[],i=0,f=r.length;f>i;i++)r[i].children.length||u.push(r[i].id);return t?n.map(u,n.proxy(function(n){return this.get_node(n)},this)):u},get_state:function(){var i={core:{open:[],scroll:{left:this.element.scrollLeft(),top:this.element.scrollTop()},selected:[]}},t;for(t in this._model.data)this._model.data.hasOwnProperty(t)&&t!==n.jstree.root&&(this._model.data[t].state.opened&&i.core.open.push(t),this._model.data[t].state.selected&&i.core.selected.push(t));return i},set_state:function(i,r){if(i){if(i.core){var e,o,s,f,u;if(i.core.open)return n.isArray(i.core.open)&&i.core.open.length?this._load_nodes(i.core.open,function(n){this.open_node(n,!1,0),delete i.core.open,this.set_state(i,r)},!0):(delete i.core.open,this.set_state(i,r)),!1;if(i.core.scroll)return i.core.scroll&&i.core.scroll.left!==t&&this.element.scrollLeft(i.core.scroll.left),i.core.scroll&&i.core.scroll.top!==t&&this.element.scrollTop(i.core.scroll.top),delete i.core.scroll,this.set_state(i,r),!1;if(i.core.selected)return f=this,this.deselect_all(),n.each(i.core.selected,function(n,t){f.select_node(t,!1,!0)}),delete i.core.selected,this.set_state(i,r),!1;for(u in i)i.hasOwnProperty(u)&&"core"!==u&&-1===n.inArray(u,this.settings.plugins)&&delete i[u];if(n.isEmptyObject(i.core))return delete i.core,this.set_state(i,r),!1}return n.isEmptyObject(i)?(i=null,r&&r.call(this),this.trigger("set_state"),!1):!0}return!1},refresh:function(t,i){this._data.core.state=i===!0?{}:this.get_state(),i&&n.isFunction(i)&&(this._data.core.state=i.call(this,this._data.core.state)),this._cnt=0,this._model.data={},this._model.data[n.jstree.root]={id:n.jstree.root,parent:null,parents:[],children:[],children_d:[],state:{loaded:!1}},this._data.core.selected=[],this._data.core.last_clicked=null,this._data.core.focused=null;var r=this.get_container_ul()[0].className;t||(this.element.html("<ul class='"+r+"' role='group'><li class='jstree-initial-node jstree-loading jstree-leaf jstree-last' role='treeitem' id='j"+this._id+"_loading'><i class='jstree-icon jstree-ocl'><\/i><a class='jstree-anchor' href='#'><i class='jstree-icon jstree-themeicon-hidden'><\/i>"+this.get_string("Loading ...")+"<\/a><\/li><\/ul>"),this.element.attr("aria-activedescendant","j"+this._id+"_loading")),this.load_node(n.jstree.root,function(t,i){i&&(this.get_container_ul()[0].className=r,this._firstChild(this.get_container_ul()[0])&&this.element.attr("aria-activedescendant",this._firstChild(this.get_container_ul()[0]).id),this.set_state(n.extend(!0,{},this._data.core.state),function(){this.trigger("refresh")})),this._data.core.state=null})},refresh_node:function(t){if(t=this.get_node(t),!t||t.id===n.jstree.root)return!1;var i=[],r=[],u=this._data.core.selected.concat([]);r.push(t.id),t.state.opened===!0&&i.push(t.id),this.get_node(t,!0).find(".jstree-open").each(function(){r.push(this.id),i.push(this.id)}),this._load_nodes(r,n.proxy(function(n){this.open_node(i,!1,0),this.select_node(this._data.core.selected),this.trigger("refresh_node",{node:t,nodes:n})},this))},set_id:function(t,i){if(t=this.get_node(t),!t||t.id===n.jstree.root)return!1;var r,f,u=this._model.data;for(i=i.toString(),u[t.parent].children[n.inArray(t.id,u[t.parent].children)]=i,r=0,f=t.parents.length;f>r;r++)u[t.parents[r]].children_d[n.inArray(t.id,u[t.parents[r]].children_d)]=i;for(r=0,f=t.children.length;f>r;r++)u[t.children[r]].parent=i;for(r=0,f=t.children_d.length;f>r;r++)u[t.children_d[r]].parents[n.inArray(t.id,u[t.children_d[r]].parents)]=i;return r=n.inArray(t.id,this._data.core.selected),-1!==r&&(this._data.core.selected[r]=i),r=this.get_node(t.id,!0),r&&(r.attr("id",i).children(".jstree-anchor").attr("id",i+"_anchor").end().attr("aria-labelledby",i+"_anchor"),this.element.attr("aria-activedescendant")===t.id&&this.element.attr("aria-activedescendant",i)),delete u[t.id],t.id=i,t.li_attr.id=i,u[i]=t,!0},get_text:function(t){return t=this.get_node(t),t&&t.id!==n.jstree.root?t.text:!1},set_text:function(t,i){var r,u;if(n.isArray(t)){for(t=t.slice(),r=0,u=t.length;u>r;r++)this.set_text(t[r],i);return!0}return t=this.get_node(t),t&&t.id!==n.jstree.root?(t.text=i,this.get_node(t,!0).length&&this.redraw_node(t.id),this.trigger("set_text",{obj:t,text:i}),!0):!1},get_json:function(t,i,r){if(t=this.get_node(t||n.jstree.root),!t)return!1;i&&i.flat&&!r&&(r=[]);var u={id:t.id,text:t.text,icon:this.get_icon(t),li_attr:n.extend(!0,{},t.li_attr),a_attr:n.extend(!0,{},t.a_attr),state:{},data:i&&i.no_data?!1:n.extend(!0,{},t.data)},f,e;if(i&&i.flat?u.parent=t.parent:u.children=[],!i||!i.no_state)for(f in t.state)t.state.hasOwnProperty(f)&&(u.state[f]=t.state[f]);if(i&&i.no_id&&(delete u.id,u.li_attr&&u.li_attr.id&&delete u.li_attr.id,u.a_attr&&u.a_attr.id&&delete u.a_attr.id),i&&i.flat&&t.id!==n.jstree.root&&r.push(u),!i||!i.no_children)for(f=0,e=t.children.length;e>f;f++)i&&i.flat?this.get_json(t.children[f],i,r):u.children.push(this.get_json(t.children[f],i));return i&&i.flat?r:t.id===n.jstree.root?u.children:u},create_node:function(i,r,u,f,e){if(null===i&&(i=n.jstree.root),i=this.get_node(i),!i)return!1;if(u=u===t?"last":u,!u.toString().match(/^(before|after)$/)&&!e&&!this.is_loaded(i))return this.load_node(i,function(){this.create_node(i,r,u,f,!0)});r||(r={text:this.get_string("New node")}),"string"==typeof r&&(r={text:r}),r.text===t&&(r.text=this.get_string("New node"));var o,h,s,c;switch(i.id===n.jstree.root&&("before"===u&&(u="first"),"after"===u&&(u="last")),u){case"before":o=this.get_node(i.parent),u=n.inArray(i.id,o.children),i=o;break;case"after":o=this.get_node(i.parent),u=n.inArray(i.id,o.children)+1,i=o;break;case"inside":case"first":u=0;break;case"last":u=i.children.length;break;default:u||(u=0)}if(u>i.children.length&&(u=i.children.length),r.id||(r.id=!0),!this.check("create_node",r,i,u))return this.settings.core.error.call(this,this._data.core.last_error),!1;if(r.id===!0&&delete r.id,r=this._parse_model_from_json(r,i.id,i.parents.concat()),!r)return!1;for(o=this.get_node(r),h=[],h.push(r),h=h.concat(o.children_d),this.trigger("model",{nodes:h,parent:i.id}),i.children_d=i.children_d.concat(h),s=0,c=i.parents.length;c>s;s++)this._model.data[i.parents[s]].children_d=this._model.data[i.parents[s]].children_d.concat(h);for(r=o,o=[],s=0,c=i.children.length;c>s;s++)o[s>=u?s+1:s]=i.children[s];return o[u]=r.id,i.children=o,this.redraw_node(i,!0),f&&f.call(this,this.get_node(r)),this.trigger("create_node",{node:this.get_node(r),parent:i.id,position:u}),r.id},rename_node:function(t,i){var r,u,f;if(n.isArray(t)){for(t=t.slice(),r=0,u=t.length;u>r;r++)this.rename_node(t[r],i);return!0}return t=this.get_node(t),t&&t.id!==n.jstree.root?(f=t.text,this.check("rename_node",t,this.get_parent(t),i)?(this.set_text(t,i),this.trigger("rename_node",{node:t,text:i,old:f}),!0):(this.settings.core.error.call(this,this._data.core.last_error),!1)):!1},delete_node:function(t){var o,c,i,r,f,e,l,u,s,h,a,v;if(n.isArray(t)){for(t=t.slice(),o=0,c=t.length;c>o;o++)this.delete_node(t[o]);return!0}if(t=this.get_node(t),!t||t.id===n.jstree.root)return!1;if(i=this.get_node(t.parent),r=n.inArray(t.id,i.children),h=!1,!this.check("delete_node",t,i,r))return this.settings.core.error.call(this,this._data.core.last_error),!1;for(-1!==r&&(i.children=n.vakata.array_remove(i.children,r)),f=t.children_d.concat([]),f.push(t.id),u=0,s=f.length;s>u;u++){for(e=0,l=t.parents.length;l>e;e++)r=n.inArray(f[u],this._model.data[t.parents[e]].children_d),-1!==r&&(this._model.data[t.parents[e]].children_d=n.vakata.array_remove(this._model.data[t.parents[e]].children_d,r));this._model.data[f[u]].state.selected&&(h=!0,r=n.inArray(f[u],this._data.core.selected),-1!==r&&(this._data.core.selected=n.vakata.array_remove(this._data.core.selected,r)))}for(this.trigger("delete_node",{node:t,parent:i.id}),h&&this.trigger("changed",{action:"delete_node",node:t,selected:this._data.core.selected,parent:i.id}),u=0,s=f.length;s>u;u++)delete this._model.data[f[u]];return-1!==n.inArray(this._data.core.focused,f)&&(this._data.core.focused=null,a=this.element[0].scrollTop,v=this.element[0].scrollLeft,i.id===n.jstree.root?this.get_node(this._model.data[n.jstree.root].children[0],!0).children(".jstree-anchor").focus():this.get_node(i,!0).children(".jstree-anchor").focus(),this.element[0].scrollTop=a,this.element[0].scrollLeft=v),this.redraw_node(i,!0),!0},check:function(t,i,r,u,f){i=i&&i.id?i:this.get_node(i),r=r&&r.id?r:this.get_node(r);var e=t.match(/^move_node|copy_node|create_node$/i)?r:i,o=this.settings.core.check_callback;return"move_node"!==t&&"copy_node"!==t||f&&f.is_multi||i.id!==r.id&&n.inArray(i.id,r.children)!==u&&-1===n.inArray(r.id,i.children_d)?(e&&e.data&&(e=e.data),e&&e.functions&&(e.functions[t]===!1||e.functions[t]===!0)?(e.functions[t]===!1&&(this._data.core.last_error={error:"check",plugin:"core",id:"core_02",reason:"Node data prevents function: "+t,data:JSON.stringify({chk:t,pos:u,obj:i&&i.id?i.id:!1,par:r&&r.id?r.id:!1})}),e.functions[t]):o===!1||n.isFunction(o)&&o.call(this,t,i,r,u,f)===!1||o&&o[t]===!1?(this._data.core.last_error={error:"check",plugin:"core",id:"core_03",reason:"User config for core.check_callback prevents function: "+t,data:JSON.stringify({chk:t,pos:u,obj:i&&i.id?i.id:!1,par:r&&r.id?r.id:!1})},!1):!0):(this._data.core.last_error={error:"check",plugin:"core",id:"core_01",reason:"Moving parent inside child",data:JSON.stringify({chk:t,pos:u,obj:i&&i.id?i.id:!1,par:r&&r.id?r.id:!1})},!1)},last_error:function(){return this._data.core.last_error},move_node:function(i,r,u,f,e,o,s){var k,d,y,g,l,c,nt,v,a,h,p,b,tt,w;if(r=this.get_node(r),u=u===t?0:u,!r)return!1;if(!u.toString().match(/^(before|after)$/)&&!e&&!this.is_loaded(r))return this.load_node(r,function(){this.move_node(i,r,u,f,!0,!1,s)});if(n.isArray(i)){if(1!==i.length){for(k=0,d=i.length;d>k;k++)(a=this.move_node(i[k],r,u,f,e,!1,s))&&(r=a,u="after");return this.redraw(),!0}i=i[0]}if(i=i&&i.id?i:this.get_node(i),!i||i.id===n.jstree.root)return!1;if(y=(i.parent||n.jstree.root).toString(),l=u.toString().match(/^(before|after)$/)&&r.id!==n.jstree.root?this.get_node(r.parent):r,c=s?s:this._model.data[i.id]?this:n.jstree.reference(i.id),nt=!c||!c._id||this._id!==c._id,g=c&&c._id&&y&&c._model.data[y]&&c._model.data[y].children?n.inArray(i.id,c._model.data[y].children):-1,c&&c._id&&(i=c._model.data[i.id]),nt)return(a=this.copy_node(i,r,u,f,e,!1,s))?(c&&c.delete_node(i),a):!1;switch(r.id===n.jstree.root&&("before"===u&&(u="first"),"after"===u&&(u="last")),u){case"before":u=n.inArray(r.id,l.children);break;case"after":u=n.inArray(r.id,l.children)+1;break;case"inside":case"first":u=0;break;case"last":u=l.children.length;break;default:u||(u=0)}if(u>l.children.length&&(u=l.children.length),!this.check("move_node",i,l,u,{core:!0,origin:s,is_multi:c&&c._id&&c._id!==this._id,is_foreign:!c||!c._id}))return this.settings.core.error.call(this,this._data.core.last_error),!1;if(i.parent===l.id){for(v=l.children.concat(),a=n.inArray(i.id,v),-1!==a&&(v=n.vakata.array_remove(v,a),u>a&&u--),a=[],h=0,p=v.length;p>h;h++)a[h>=u?h+1:h]=v[h];a[u]=i.id,l.children=a,this._node_changed(l.id),this.redraw(l.id===n.jstree.root)}else{for(a=i.children_d.concat(),a.push(i.id),h=0,p=i.parents.length;p>h;h++){for(v=[],w=c._model.data[i.parents[h]].children_d,b=0,tt=w.length;tt>b;b++)-1===n.inArray(w[b],a)&&v.push(w[b]);c._model.data[i.parents[h]].children_d=v}for(c._model.data[y].children=n.vakata.array_remove_item(c._model.data[y].children,i.id),h=0,p=l.parents.length;p>h;h++)this._model.data[l.parents[h]].children_d=this._model.data[l.parents[h]].children_d.concat(a);for(v=[],h=0,p=l.children.length;p>h;h++)v[h>=u?h+1:h]=l.children[h];for(v[u]=i.id,l.children=v,l.children_d.push(i.id),l.children_d=l.children_d.concat(i.children_d),i.parent=l.id,a=l.parents.concat(),a.unshift(l.id),w=i.parents.length,i.parents=a,a=a.concat(),h=0,p=i.children_d.length;p>h;h++)this._model.data[i.children_d[h]].parents=this._model.data[i.children_d[h]].parents.slice(0,-1*w),Array.prototype.push.apply(this._model.data[i.children_d[h]].parents,a);(y===n.jstree.root||l.id===n.jstree.root)&&(this._model.force_full_redraw=!0),this._model.force_full_redraw||(this._node_changed(y),this._node_changed(l.id)),o||this.redraw()}return f&&f.call(this,i,l,u),this.trigger("move_node",{node:i,parent:l.id,position:u,old_parent:y,old_position:g,is_multi:c&&c._id&&c._id!==this._id,is_foreign:!c||!c._id,old_instance:c,new_instance:this}),i.id},copy_node:function(i,r,u,f,e,o,s){var w,k,v,a,l,b,y,p,c,h,d;if(r=this.get_node(r),u=u===t?0:u,!r)return!1;if(!u.toString().match(/^(before|after)$/)&&!e&&!this.is_loaded(r))return this.load_node(r,function(){this.copy_node(i,r,u,f,!0,!1,s)});if(n.isArray(i)){if(1!==i.length){for(w=0,k=i.length;k>w;w++)(a=this.copy_node(i[w],r,u,f,e,!0,s))&&(r=a,u="after");return this.redraw(),!0}i=i[0]}if(i=i&&i.id?i:this.get_node(i),!i||i.id===n.jstree.root)return!1;switch(p=(i.parent||n.jstree.root).toString(),c=u.toString().match(/^(before|after)$/)&&r.id!==n.jstree.root?this.get_node(r.parent):r,h=s?s:this._model.data[i.id]?this:n.jstree.reference(i.id),d=!h||!h._id||this._id!==h._id,h&&h._id&&(i=h._model.data[i.id]),r.id===n.jstree.root&&("before"===u&&(u="first"),"after"===u&&(u="last")),u){case"before":u=n.inArray(r.id,c.children);break;case"after":u=n.inArray(r.id,c.children)+1;break;case"inside":case"first":u=0;break;case"last":u=c.children.length;break;default:u||(u=0)}if(u>c.children.length&&(u=c.children.length),!this.check("copy_node",i,c,u,{core:!0,origin:s,is_multi:h&&h._id&&h._id!==this._id,is_foreign:!h||!h._id}))return this.settings.core.error.call(this,this._data.core.last_error),!1;if((y=h?h.get_json(i,{no_id:!0,no_data:!0,no_state:!0}):i,!y)||(y.id===!0&&delete y.id,y=this._parse_model_from_json(y,c.id,c.parents.concat()),!y))return!1;for(a=this.get_node(y),i&&i.state&&i.state.loaded===!1&&(a.state.loaded=!1),v=[],v.push(y),v=v.concat(a.children_d),this.trigger("model",{nodes:v,parent:c.id}),l=0,b=c.parents.length;b>l;l++)this._model.data[c.parents[l]].children_d=this._model.data[c.parents[l]].children_d.concat(v);for(v=[],l=0,b=c.children.length;b>l;l++)v[l>=u?l+1:l]=c.children[l];return v[u]=a.id,c.children=v,c.children_d.push(a.id),c.children_d=c.children_d.concat(a.children_d),c.id===n.jstree.root&&(this._model.force_full_redraw=!0),this._model.force_full_redraw||this._node_changed(c.id),o||this.redraw(c.id===n.jstree.root),f&&f.call(this,a,c,u),this.trigger("copy_node",{node:a,original:i,parent:c.id,position:u,old_parent:p,old_position:h&&h._id&&p&&h._model.data[p]&&h._model.data[p].children?n.inArray(i.id,h._model.data[p].children):-1,is_multi:h&&h._id&&h._id!==this._id,is_foreign:!h||!h._id,old_instance:h,new_instance:this}),a.id},cut:function(t){if(t||(t=this._data.core.selected.concat()),n.isArray(t)||(t=[t]),!t.length)return!1;for(var o=[],i,r=0,s=t.length;s>r;r++)i=this.get_node(t[r]),i&&i.id&&i.id!==n.jstree.root&&o.push(i);return o.length?(f=o,e=this,u="move_node",void this.trigger("cut",{node:t})):!1},copy:function(t){if(t||(t=this._data.core.selected.concat()),n.isArray(t)||(t=[t]),!t.length)return!1;for(var o=[],i,r=0,s=t.length;s>r;r++)i=this.get_node(t[r]),i&&i.id&&i.id!==n.jstree.root&&o.push(i);return o.length?(f=o,e=this,u="copy_node",void this.trigger("copy",{node:t})):!1},get_buffer:function(){return{mode:u,node:f,inst:e}},can_paste:function(){return u!==!1&&f!==!1},paste:function(n,t){return n=this.get_node(n),n&&u&&u.match(/^(copy_node|move_node)$/)&&f?(this[u](f,n,t,!1,!1,!1,e)&&this.trigger("paste",{parent:n.id,node:f,mode:u}),f=!1,u=!1,void(e=!1)):!1},clear_buffer:function(){f=!1,u=!1,e=!1,this.trigger("clear_buffer")},edit:function(t,i,r){var a,c,u,o,f,s,h,l,e,v=!1;return(t=this.get_node(t))?this.settings.core.check_callback===!1?(this._data.core.last_error={error:"check",plugin:"core",id:"core_07",reason:"Could not edit node because of check_callback"},this.settings.core.error.call(this,this._data.core.last_error),!1):(e=t,i="string"==typeof i?i:t.text,this.set_text(t,""),t=this._open_to(t),e.text=i,a=this._data.core.rtl,c=this.element.width(),this._data.core.focused=e.id,u=t.children(".jstree-anchor").focus(),o=n("<span>"),f=i,s=n("<div />",{css:{position:"absolute",top:"-200px",left:a?"0px":"-1000px",visibility:"hidden"}}).appendTo("body"),h=n("<input />",{value:f,"class":"jstree-rename-input",css:{padding:"0",border:"1px solid silver","box-sizing":"border-box",display:"inline-block",height:this._data.core.li_height+"px",lineHeight:this._data.core.li_height+"px",width:"150px"},blur:n.proxy(function(i){i.stopImmediatePropagation(),i.preventDefault();var a=o.children(".jstree-rename-input"),h=a.val(),l=this.settings.core.force_text,c;""===h&&(h=f),s.remove(),o.replaceWith(u),o.remove(),f=l?f:n("<div><\/div>").append(n.parseHTML(f)).html(),this.set_text(t,f),c=!!this.rename_node(t,l?n("<div><\/div>").text(h).text():n("<div><\/div>").append(n.parseHTML(h)).html()),c||this.set_text(t,f),this._data.core.focused=e.id,setTimeout(n.proxy(function(){var n=this.get_node(e.id,!0);n.length&&(this._data.core.focused=e.id,n.children(".jstree-anchor").focus())},this),0),r&&r.call(this,e,c,v)},this),keydown:function(n){var t=n.which;27===t&&(v=!0,this.value=f),(27===t||13===t||37===t||38===t||39===t||40===t||32===t)&&n.stopImmediatePropagation(),(27===t||13===t)&&(n.preventDefault(),this.blur())},click:function(n){n.stopImmediatePropagation()},mousedown:function(n){n.stopImmediatePropagation()},keyup:function(){h.width(Math.min(s.text("pW"+this.value).width(),c))},keypress:function(n){if(13===n.which)return!1}}),l={fontFamily:u.css("fontFamily")||"",fontSize:u.css("fontSize")||"",fontWeight:u.css("fontWeight")||"",fontStyle:u.css("fontStyle")||"",fontStretch:u.css("fontStretch")||"",fontVariant:u.css("fontVariant")||"",letterSpacing:u.css("letterSpacing")||"",wordSpacing:u.css("wordSpacing")||""},o.attr("class",u.attr("class")).append(u.contents().clone()).append(h),u.replaceWith(o),s.css(l),void h.css(l).width(Math.min(s.text("pW"+h[0].value).width(),c))[0].select()):!1},set_theme:function(t,i){if(!t)return!1;if(i===!0){var r=this.settings.core.themes.dir;r||(r=n.jstree.path+"/themes"),i=r+"/"+t+"/style.css"}i&&-1===n.inArray(i,y)&&(n("head").append('<link rel="stylesheet" href="'+i+'" type="text/css" />'),y.push(i)),this._data.core.themes.name&&this.element.removeClass("jstree-"+this._data.core.themes.name),this._data.core.themes.name=t,this.element.addClass("jstree-"+t),this.element[this.settings.core.themes.responsive?"addClass":"removeClass"]("jstree-"+t+"-responsive"),this.trigger("set_theme",{theme:t})},get_theme:function(){return this._data.core.themes.name},set_theme_variant:function(n){this._data.core.themes.variant&&this.element.removeClass("jstree-"+this._data.core.themes.name+"-"+this._data.core.themes.variant),this._data.core.themes.variant=n,n&&this.element.addClass("jstree-"+this._data.core.themes.name+"-"+this._data.core.themes.variant)},get_theme_variant:function(){return this._data.core.themes.variant},show_stripes:function(){this._data.core.themes.stripes=!0,this.get_container_ul().addClass("jstree-striped")},hide_stripes:function(){this._data.core.themes.stripes=!1,this.get_container_ul().removeClass("jstree-striped")},toggle_stripes:function(){this._data.core.themes.stripes?this.hide_stripes():this.show_stripes()},show_dots:function(){this._data.core.themes.dots=!0,this.get_container_ul().removeClass("jstree-no-dots")},hide_dots:function(){this._data.core.themes.dots=!1,this.get_container_ul().addClass("jstree-no-dots")},toggle_dots:function(){this._data.core.themes.dots?this.hide_dots():this.show_dots()},show_icons:function(){this._data.core.themes.icons=!0,this.get_container_ul().removeClass("jstree-no-icons")},hide_icons:function(){this._data.core.themes.icons=!1,this.get_container_ul().addClass("jstree-no-icons")},toggle_icons:function(){this._data.core.themes.icons?this.hide_icons():this.show_icons()},set_icon:function(i,r){var e,o,f,u;if(n.isArray(i)){for(i=i.slice(),e=0,o=i.length;o>e;e++)this.set_icon(i[e],r);return!0}return i=this.get_node(i),i&&i.id!==n.jstree.root?(u=i.icon,i.icon=r===!0||null===r||r===t||""===r?!0:r,f=this.get_node(i,!0).children(".jstree-anchor").children(".jstree-themeicon"),r===!1?this.hide_icon(i):r===!0||null===r||r===t||""===r?(f.removeClass("jstree-themeicon-custom "+u).css("background","").removeAttr("rel"),u===!1&&this.show_icon(i)):-1===r.indexOf("/")&&-1===r.indexOf(".")?(f.removeClass(u).css("background",""),f.addClass(r+" jstree-themeicon-custom").attr("rel",r),u===!1&&this.show_icon(i)):(f.removeClass(u).css("background",""),f.addClass("jstree-themeicon-custom").css("background","url('"+r+"') center center no-repeat").attr("rel",r),u===!1&&this.show_icon(i)),!0):!1},get_icon:function(t){return t=this.get_node(t),t&&t.id!==n.jstree.root?t.icon:!1},hide_icon:function(t){var i,r;if(n.isArray(t)){for(t=t.slice(),i=0,r=t.length;r>i;i++)this.hide_icon(t[i]);return!0}return t=this.get_node(t),t&&t!==n.jstree.root?(t.icon=!1,this.get_node(t,!0).children(".jstree-anchor").children(".jstree-themeicon").addClass("jstree-themeicon-hidden"),!0):!1},show_icon:function(t){var i,u,r;if(n.isArray(t)){for(t=t.slice(),i=0,u=t.length;u>i;i++)this.show_icon(t[i]);return!0}return t=this.get_node(t),t&&t!==n.jstree.root?(r=this.get_node(t,!0),t.icon=r.length?r.children(".jstree-anchor").children(".jstree-themeicon").attr("rel"):!0,t.icon||(t.icon=!0),r.children(".jstree-anchor").children(".jstree-themeicon").removeClass("jstree-themeicon-hidden"),!0):!1}},n.vakata={},n.vakata.attributes=function(t,i){t=n(t)[0];var r=i?{}:[];return t&&t.attributes&&n.each(t.attributes,function(t,u){-1===n.inArray(u.name.toLowerCase(),["style","contenteditable","hasfocus","tabindex"])&&null!==u.value&&""!==n.trim(u.value)&&(i?r[u.name]=u.value:r.push(u.name))}),r},n.vakata.array_unique=function(n){for(var r=[],e,u={},i=0,f=n.length;f>i;i++)u[n[i]]===t&&(r.push(n[i]),u[n[i]]=!0);return r},n.vakata.array_remove=function(n,t,i){var r=n.slice((i||t)+1||n.length);return n.length=0>t?n.length+t:t,n.push.apply(n,r),n},n.vakata.array_remove_item=function(t,i){var r=n.inArray(i,t);return-1!==r?n.vakata.array_remove(t,r):t},n.jstree.plugins.changed=function(n,t){var i=[];this.trigger=function(n,r){var u,f,e;if(r||(r={}),"changed"===n.replace(".jstree","")){for(r.changed={selected:[],deselected:[]},e={},u=0,f=i.length;f>u;u++)e[i[u]]=1;for(u=0,f=r.selected.length;f>u;u++)e[r.selected[u]]?e[r.selected[u]]=2:r.changed.selected.push(r.selected[u]);for(u=0,f=i.length;f>u;u++)1===e[i[u]]&&r.changed.deselected.push(i[u]);i=r.selected.slice()}t.trigger.call(this,n,r)},this.refresh=function(){return i=[],t.refresh.apply(this,arguments)}},c=i.createElement("I"),c.className="jstree-icon jstree-checkbox",c.setAttribute("role","presentation"),n.jstree.defaults.checkbox={visible:!0,three_state:!0,whole_node:!0,keep_selected_style:!0,cascade:"",tie_selection:!0},n.jstree.plugins.checkbox=function(i,r){this.bind=function(){r.bind.call(this),this._data.checkbox.uto=!1,this._data.checkbox.selected=[],this.settings.checkbox.three_state&&(this.settings.checkbox.cascade="up+down+undetermined"),this.element.on("init.jstree",n.proxy(function(){this._data.checkbox.visible=this.settings.checkbox.visible,this.settings.checkbox.keep_selected_style||this.element.addClass("jstree-checkbox-no-clicked"),this.settings.checkbox.tie_selection&&this.element.addClass("jstree-checkbox-selection")},this)).on("loading.jstree",n.proxy(function(){this[this._data.checkbox.visible?"show_checkboxes":"hide_checkboxes"]()},this)),-1!==this.settings.checkbox.cascade.indexOf("undetermined")&&this.element.on("changed.jstree uncheck_node.jstree check_node.jstree uncheck_all.jstree check_all.jstree move_node.jstree copy_node.jstree redraw.jstree open_node.jstree",n.proxy(function(){this._data.checkbox.uto&&clearTimeout(this._data.checkbox.uto),this._data.checkbox.uto=setTimeout(n.proxy(this._undetermined,this),50)},this)),this.settings.checkbox.tie_selection||this.element.on("model.jstree",n.proxy(function(n,t){for(var u=this._model.data,e=u[t.parent],r=t.nodes,i=0,f=r.length;f>i;i++)u[r[i]].state.checked=u[r[i]].state.checked||u[r[i]].original&&u[r[i]].original.state&&u[r[i]].original.state.checked,u[r[i]].state.checked&&this._data.checkbox.selected.push(r[i])},this)),(-1!==this.settings.checkbox.cascade.indexOf("up")||-1!==this.settings.checkbox.cascade.indexOf("down"))&&this.element.on("model.jstree",n.proxy(function(t,i){var e=this._model.data,u=e[i.parent],s=i.nodes,c=[],v,r,o,h,l,a,y=this.settings.checkbox.cascade,f=this.settings.checkbox.tie_selection;if(-1!==y.indexOf("down"))if(u.state[f?"selected":"checked"]){for(r=0,o=s.length;o>r;r++)e[s[r]].state[f?"selected":"checked"]=!0;this._data[f?"core":"checkbox"].selected=this._data[f?"core":"checkbox"].selected.concat(s)}else for(r=0,o=s.length;o>r;r++)if(e[s[r]].state[f?"selected":"checked"]){for(h=0,l=e[s[r]].children_d.length;l>h;h++)e[e[s[r]].children_d[h]].state[f?"selected":"checked"]=!0;this._data[f?"core":"checkbox"].selected=this._data[f?"core":"checkbox"].selected.concat(e[s[r]].children_d)}if(-1!==y.indexOf("up")){for(r=0,o=u.children_d.length;o>r;r++)e[u.children_d[r]].children.length||c.push(e[u.children_d[r]].parent);for(c=n.vakata.array_unique(c),h=0,l=c.length;l>h;h++)for(u=e[c[h]];u&&u.id!==n.jstree.root;){for(v=0,r=0,o=u.children.length;o>r;r++)v+=e[u.children[r]].state[f?"selected":"checked"];if(v!==o)break;u.state[f?"selected":"checked"]=!0,this._data[f?"core":"checkbox"].selected.push(u.id),a=this.get_node(u,!0),a&&a.length&&a.attr("aria-selected",!0).children(".jstree-anchor").addClass(f?"jstree-clicked":"jstree-checked"),u=this.get_node(u.parent)}}this._data[f?"core":"checkbox"].selected=n.vakata.array_unique(this._data[f?"core":"checkbox"].selected)},this)).on(this.settings.checkbox.tie_selection?"select_node.jstree":"check_node.jstree",n.proxy(function(t,i){var o=i.node,l=this._model.data,u=this.get_node(o.parent),a=this.get_node(o,!0),f,s,h,r,c=this.settings.checkbox.cascade,e=this.settings.checkbox.tie_selection;if(-1!==c.indexOf("down"))for(this._data[e?"core":"checkbox"].selected=n.vakata.array_unique(this._data[e?"core":"checkbox"].selected.concat(o.children_d)),f=0,s=o.children_d.length;s>f;f++)r=l[o.children_d[f]],r.state[e?"selected":"checked"]=!0,r&&r.original&&r.original.state&&r.original.state.undetermined&&(r.original.state.undetermined=!1);if(-1!==c.indexOf("up"))while(u&&u.id!==n.jstree.root){for(h=0,f=0,s=u.children.length;s>f;f++)h+=l[u.children[f]].state[e?"selected":"checked"];if(h!==s)break;u.state[e?"selected":"checked"]=!0,this._data[e?"core":"checkbox"].selected.push(u.id),r=this.get_node(u,!0),r&&r.length&&r.attr("aria-selected",!0).children(".jstree-anchor").addClass(e?"jstree-clicked":"jstree-checked"),u=this.get_node(u.parent)}-1!==c.indexOf("down")&&a.length&&a.find(".jstree-anchor").addClass(e?"jstree-clicked":"jstree-checked").parent().attr("aria-selected",!0)},this)).on(this.settings.checkbox.tie_selection?"deselect_all.jstree":"uncheck_all.jstree",n.proxy(function(){for(var f=this.get_node(n.jstree.root),o=this._model.data,r,u=0,e=f.children_d.length;e>u;u++)r=o[f.children_d[u]],r&&r.original&&r.original.state&&r.original.state.undetermined&&(r.original.state.undetermined=!1)},this)).on(this.settings.checkbox.tie_selection?"deselect_node.jstree":"uncheck_node.jstree",n.proxy(function(t,i){var f=i.node,h=this.get_node(f,!0),u,o,r,s=this.settings.checkbox.cascade,e=this.settings.checkbox.tie_selection;if(f&&f.original&&f.original.state&&f.original.state.undetermined&&(f.original.state.undetermined=!1),-1!==s.indexOf("down"))for(u=0,o=f.children_d.length;o>u;u++)r=this._model.data[f.children_d[u]],r.state[e?"selected":"checked"]=!1,r&&r.original&&r.original.state&&r.original.state.undetermined&&(r.original.state.undetermined=!1);if(-1!==s.indexOf("up"))for(u=0,o=f.parents.length;o>u;u++)r=this._model.data[f.parents[u]],r.state[e?"selected":"checked"]=!1,r&&r.original&&r.original.state&&r.original.state.undetermined&&(r.original.state.undetermined=!1),r=this.get_node(f.parents[u],!0),r&&r.length&&r.attr("aria-selected",!1).children(".jstree-anchor").removeClass(e?"jstree-clicked":"jstree-checked");for(r=[],u=0,o=this._data[e?"core":"checkbox"].selected.length;o>u;u++)-1!==s.indexOf("down")&&-1!==n.inArray(this._data[e?"core":"checkbox"].selected[u],f.children_d)||-1!==s.indexOf("up")&&-1!==n.inArray(this._data[e?"core":"checkbox"].selected[u],f.parents)||r.push(this._data[e?"core":"checkbox"].selected[u]);this._data[e?"core":"checkbox"].selected=n.vakata.array_unique(r),-1!==s.indexOf("down")&&h.length&&h.find(".jstree-anchor").removeClass(e?"jstree-clicked":"jstree-checked").parent().attr("aria-selected",!1)},this)),-1!==this.settings.checkbox.cascade.indexOf("up")&&this.element.on("delete_node.jstree",n.proxy(function(t,i){for(var r=this.get_node(i.parent),h=this._model.data,f,e,s,o,u=this.settings.checkbox.tie_selection;r&&r.id!==n.jstree.root&&!r.state[u?"selected":"checked"];){for(s=0,f=0,e=r.children.length;e>f;f++)s+=h[r.children[f]].state[u?"selected":"checked"];if(!(e>0&&s===e))break;r.state[u?"selected":"checked"]=!0,this._data[u?"core":"checkbox"].selected.push(r.id),o=this.get_node(r,!0),o&&o.length&&o.attr("aria-selected",!0).children(".jstree-anchor").addClass(u?"jstree-clicked":"jstree-checked"),r=this.get_node(r.parent)}},this)).on("move_node.jstree",n.proxy(function(t,i){var c=i.is_multi,l=i.old_parent,a=this.get_node(i.parent),h=this._model.data,r,s,e,o,f,u=this.settings.checkbox.tie_selection;if(!c)for(r=this.get_node(l);r&&r.id!==n.jstree.root&&!r.state[u?"selected":"checked"];){for(s=0,e=0,o=r.children.length;o>e;e++)s+=h[r.children[e]].state[u?"selected":"checked"];if(!(o>0&&s===o))break;r.state[u?"selected":"checked"]=!0,this._data[u?"core":"checkbox"].selected.push(r.id),f=this.get_node(r,!0),f&&f.length&&f.attr("aria-selected",!0).children(".jstree-anchor").addClass(u?"jstree-clicked":"jstree-checked"),r=this.get_node(r.parent)}for(r=a;r&&r.id!==n.jstree.root;){for(s=0,e=0,o=r.children.length;o>e;e++)s+=h[r.children[e]].state[u?"selected":"checked"];if(s===o)r.state[u?"selected":"checked"]||(r.state[u?"selected":"checked"]=!0,this._data[u?"core":"checkbox"].selected.push(r.id),f=this.get_node(r,!0),f&&f.length&&f.attr("aria-selected",!0).children(".jstree-anchor").addClass(u?"jstree-clicked":"jstree-checked"));else{if(!r.state[u?"selected":"checked"])break;r.state[u?"selected":"checked"]=!1,this._data[u?"core":"checkbox"].selected=n.vakata.array_remove_item(this._data[u?"core":"checkbox"].selected,r.id),f=this.get_node(r,!0),f&&f.length&&f.attr("aria-selected",!1).children(".jstree-anchor").removeClass(u?"jstree-clicked":"jstree-checked")}r=this.get_node(r.parent)}},this))},this._undetermined=function(){if(null!==this.element){for(var i,s,f={},e=this._model.data,c=this.settings.checkbox.tie_selection,u=this._data[c?"core":"checkbox"].selected,o=[],l=this,r=0,h=u.length;h>r;r++)if(e[u[r]]&&e[u[r]].parents)for(i=0,s=e[u[r]].parents.length;s>i;i++)f[e[u[r]].parents[i]]===t&&e[u[r]].parents[i]!==n.jstree.root&&(f[e[u[r]].parents[i]]=!0,o.push(e[u[r]].parents[i]));for(this.element.find(".jstree-closed").not(":has(.jstree-children)").each(function(){var u=l.get_node(this),c;if(u.state.loaded){for(r=0,h=u.children_d.length;h>r;r++)if(c=e[u.children_d[r]],!c.state.loaded&&c.original&&c.original.state&&c.original.state.undetermined&&c.original.state.undetermined===!0)for(f[c.id]===t&&c.id!==n.jstree.root&&(f[c.id]=!0,o.push(c.id)),i=0,s=c.parents.length;s>i;i++)f[c.parents[i]]===t&&c.parents[i]!==n.jstree.root&&(f[c.parents[i]]=!0,o.push(c.parents[i]))}else if(u.original&&u.original.state&&u.original.state.undetermined&&u.original.state.undetermined===!0)for(f[u.id]===t&&u.id!==n.jstree.root&&(f[u.id]=!0,o.push(u.id)),i=0,s=u.parents.length;s>i;i++)f[u.parents[i]]===t&&u.parents[i]!==n.jstree.root&&(f[u.parents[i]]=!0,o.push(u.parents[i]))}),this.element.find(".jstree-undetermined").removeClass("jstree-undetermined"),r=0,h=o.length;h>r;r++)e[o[r]].state[c?"selected":"checked"]||(u=this.get_node(o[r],!0),u&&u.length&&u.children(".jstree-anchor").children(".jstree-checkbox").addClass("jstree-undetermined"))}},this.redraw_node=function(t,i,u){if(t=r.redraw_node.apply(this,arguments)){for(var o=null,s=null,e=0,h=t.childNodes.length;h>e;e++)if(t.childNodes[e]&&t.childNodes[e].className&&-1!==t.childNodes[e].className.indexOf("jstree-anchor")){o=t.childNodes[e];break}o&&(!this.settings.checkbox.tie_selection&&this._model.data[t.id].state.checked&&(o.className+=" jstree-checked"),s=c.cloneNode(!1),this._model.data[t.id].state.checkbox_disabled&&(s.className+=" jstree-checkbox-disabled"),o.insertBefore(s,o.childNodes[0]))}return u||-1===this.settings.checkbox.cascade.indexOf("undetermined")||(this._data.checkbox.uto&&clearTimeout(this._data.checkbox.uto),this._data.checkbox.uto=setTimeout(n.proxy(this._undetermined,this),50)),t},this.show_checkboxes=function(){this._data.core.themes.checkboxes=!0,this.get_container_ul().removeClass("jstree-no-checkboxes")},this.hide_checkboxes=function(){this._data.core.themes.checkboxes=!1,this.get_container_ul().addClass("jstree-no-checkboxes")},this.toggle_checkboxes=function(){this._data.core.themes.checkboxes?this.hide_checkboxes():this.show_checkboxes()},this.is_undetermined=function(t){t=this.get_node(t);var r=this.settings.checkbox.cascade,i,u,f=this.settings.checkbox.tie_selection,o=this._data[f?"core":"checkbox"].selected,e=this._model.data;if(!t||t.state[f?"selected":"checked"]===!0||-1===r.indexOf("undetermined")||-1===r.indexOf("down")&&-1===r.indexOf("up"))return!1;if(!t.state.loaded&&t.original.state.undetermined===!0)return!0;for(i=0,u=t.children_d.length;u>i;i++)if(-1!==n.inArray(t.children_d[i],o)||!e[t.children_d[i]].state.loaded&&e[t.children_d[i]].original.state.undetermined)return!0;return!1},this.disable_checkbox=function(t){var i,u,r;if(n.isArray(t)){for(t=t.slice(),i=0,u=t.length;u>i;i++)this.disable_checkbox(t[i]);return!0}return t=this.get_node(t),t&&t.id!==n.jstree.root?(r=this.get_node(t,!0),void(t.state.checkbox_disabled||(t.state.checkbox_disabled=!0,r&&r.length&&r.children(".jstree-anchor").children(".jstree-checkbox").addClass("jstree-checkbox-disabled"),this.trigger("disable_checkbox",{node:t})))):!1},this.enable_checkbox=function(t){var i,u,r;if(n.isArray(t)){for(t=t.slice(),i=0,u=t.length;u>i;i++)this.enable_checkbox(t[i]);return!0}return t=this.get_node(t),t&&t.id!==n.jstree.root?(r=this.get_node(t,!0),void(t.state.checkbox_disabled&&(t.state.checkbox_disabled=!1,r&&r.length&&r.children(".jstree-anchor").children(".jstree-checkbox").removeClass("jstree-checkbox-disabled"),this.trigger("enable_checkbox",{node:t})))):!1},this.activate_node=function(t,i){return n(i.target).hasClass("jstree-checkbox-disabled")?!1:(this.settings.checkbox.tie_selection&&(this.settings.checkbox.whole_node||n(i.target).hasClass("jstree-checkbox"))&&(i.ctrlKey=!0),this.settings.checkbox.tie_selection||!this.settings.checkbox.whole_node&&!n(i.target).hasClass("jstree-checkbox")?r.activate_node.call(this,t,i):this.is_disabled(t)?!1:(this.is_checked(t)?this.uncheck_node(t,i):this.check_node(t,i),void this.trigger("activate_node",{node:this.get_node(t)})))},this.check_node=function(t,i){if(this.settings.checkbox.tie_selection)return this.select_node(t,!1,!0,i);var r,u,f,e;if(n.isArray(t)){for(t=t.slice(),u=0,f=t.length;f>u;u++)this.check_node(t[u],i);return!0}return t=this.get_node(t),t&&t.id!==n.jstree.root?(r=this.get_node(t,!0),void(t.state.checked||(t.state.checked=!0,this._data.checkbox.selected.push(t.id),r&&r.length&&r.children(".jstree-anchor").addClass("jstree-checked"),this.trigger("check_node",{node:t,selected:this._data.checkbox.selected,event:i})))):!1},this.uncheck_node=function(t,i){if(this.settings.checkbox.tie_selection)return this.deselect_node(t,!1,i);var r,f,u;if(n.isArray(t)){for(t=t.slice(),r=0,f=t.length;f>r;r++)this.uncheck_node(t[r],i);return!0}return t=this.get_node(t),t&&t.id!==n.jstree.root?(u=this.get_node(t,!0),void(t.state.checked&&(t.state.checked=!1,this._data.checkbox.selected=n.vakata.array_remove_item(this._data.checkbox.selected,t.id),u.length&&u.children(".jstree-anchor").removeClass("jstree-checked"),this.trigger("uncheck_node",{node:t,selected:this._data.checkbox.selected,event:i})))):!1},this.check_all=function(){if(this.settings.checkbox.tie_selection)return this.select_all();var r=this._data.checkbox.selected.concat([]),t,i;for(this._data.checkbox.selected=this._model.data[n.jstree.root].children_d.concat(),t=0,i=this._data.checkbox.selected.length;i>t;t++)this._model.data[this._data.checkbox.selected[t]]&&(this._model.data[this._data.checkbox.selected[t]].state.checked=!0);this.redraw(!0),this.trigger("check_all",{selected:this._data.checkbox.selected})},this.uncheck_all=function(){if(this.settings.checkbox.tie_selection)return this.deselect_all();for(var i=this._data.checkbox.selected.concat([]),n=0,t=this._data.checkbox.selected.length;t>n;n++)this._model.data[this._data.checkbox.selected[n]]&&(this._model.data[this._data.checkbox.selected[n]].state.checked=!1);this._data.checkbox.selected=[],this.element.find(".jstree-checked").removeClass("jstree-checked"),this.trigger("uncheck_all",{selected:this._data.checkbox.selected,node:i})},this.is_checked=function(t){return this.settings.checkbox.tie_selection?this.is_selected(t):(t=this.get_node(t),t&&t.id!==n.jstree.root?t.state.checked:!1)},this.get_checked=function(t){return this.settings.checkbox.tie_selection?this.get_selected(t):t?n.map(this._data.checkbox.selected,n.proxy(function(n){return this.get_node(n)},this)):this._data.checkbox.selected},this.get_top_checked=function(t){if(this.settings.checkbox.tie_selection)return this.get_top_selected(t);for(var r=this.get_checked(!0),u={},f,o,i=0,e=r.length;e>i;i++)u[r[i].id]=r[i];for(i=0,e=r.length;e>i;i++)for(f=0,o=r[i].children_d.length;o>f;f++)u[r[i].children_d[f]]&&delete u[r[i].children_d[f]];r=[];for(i in u)u.hasOwnProperty(i)&&r.push(i);return t?n.map(r,n.proxy(function(n){return this.get_node(n)},this)):r},this.get_bottom_checked=function(t){if(this.settings.checkbox.tie_selection)return this.get_bottom_selected(t);for(var r=this.get_checked(!0),u=[],i=0,f=r.length;f>i;i++)r[i].children.length||u.push(r[i].id);return t?n.map(u,n.proxy(function(n){return this.get_node(n)},this)):u},this.load_node=function(t){var f,e,s,h,o,u;if(!n.isArray(t)&&!this.settings.checkbox.tie_selection&&(u=this.get_node(t),u&&u.state.loaded))for(f=0,e=u.children_d.length;e>f;f++)this._model.data[u.children_d[f]].state.checked&&(o=!0,this._data.checkbox.selected=n.vakata.array_remove_item(this._data.checkbox.selected,u.children_d[f]));return r.load_node.apply(this,arguments)},this.get_state=function(){var n=r.get_state.apply(this,arguments);return this.settings.checkbox.tie_selection?n:(n.checkbox=this._data.checkbox.selected.slice(),n)},this.set_state=function(t,i){var u=r.set_state.apply(this,arguments),f;return u&&t.checkbox?(this.settings.checkbox.tie_selection||(this.uncheck_all(),f=this,n.each(t.checkbox,function(n,t){f.check_node(t)})),delete t.checkbox,this.set_state(t,i),!1):u},this.refresh=function(){return this.settings.checkbox.tie_selection||(this._data.checkbox.selected=[]),r.refresh.apply(this,arguments)}},n.jstree.defaults.conditionalselect=function(){return!0},n.jstree.plugins.conditionalselect=function(n,t){this.activate_node=function(n,i){this.settings.conditionalselect.call(this,this.get_node(n),i)&&t.activate_node.call(this,n,i)}},n.jstree.defaults.contextmenu={select_node:!0,show_at_node:!0,items:function(){return{create:{separator_before:!1,separator_after:!0,_disabled:!1,label:"Create",action:function(t){var i=n.jstree.reference(t.reference),r=i.get_node(t.reference);i.create_node(r,{},"last",function(n){setTimeout(function(){i.edit(n)},0)})}},rename:{separator_before:!1,separator_after:!1,_disabled:!1,label:"Rename",action:function(t){var i=n.jstree.reference(t.reference),r=i.get_node(t.reference);i.edit(r)}},remove:{separator_before:!1,icon:!1,separator_after:!1,_disabled:!1,label:"Delete",action:function(t){var i=n.jstree.reference(t.reference),r=i.get_node(t.reference);i.is_selected(r)?i.delete_node(i.get_selected()):i.delete_node(r)}},ccp:{separator_before:!0,icon:!1,separator_after:!1,label:"Edit",action:!1,submenu:{cut:{separator_before:!1,separator_after:!1,label:"Cut",action:function(t){var i=n.jstree.reference(t.reference),r=i.get_node(t.reference);i.is_selected(r)?i.cut(i.get_top_selected()):i.cut(r)}},copy:{separator_before:!1,icon:!1,separator_after:!1,label:"Copy",action:function(t){var i=n.jstree.reference(t.reference),r=i.get_node(t.reference);i.is_selected(r)?i.copy(i.get_top_selected()):i.copy(r)}},paste:{separator_before:!1,icon:!1,_disabled:function(t){return!n.jstree.reference(t.reference).can_paste()},separator_after:!1,label:"Paste",action:function(t){var i=n.jstree.reference(t.reference),r=i.get_node(t.reference);i.paste(r)}}}}}}},n.jstree.plugins.contextmenu=function(r,u){this.bind=function(){u.bind.call(this);var r=0,t=null,f,e;this.element.on("contextmenu.jstree",".jstree-anchor",n.proxy(function(n,i){n.preventDefault(),r=n.ctrlKey?+new Date:0,(i||t)&&(r=+new Date+1e4),t&&clearTimeout(t),this.is_loading(n.currentTarget)||this.show_contextmenu(n.currentTarget,n.pageX,n.pageY,n)},this)).on("click.jstree",".jstree-anchor",n.proxy(function(){this._data.contextmenu.visible&&(!r||+new Date-r>250)&&n.vakata.context.hide(),r=0},this)).on("touchstart.jstree",".jstree-anchor",function(i){i.originalEvent&&i.originalEvent.changedTouches&&i.originalEvent.changedTouches[0]&&(f=i.pageX,e=i.pageY,t=setTimeout(function(){n(i.currentTarget).trigger("contextmenu",!0)},750))}).on("touchmove.vakata.jstree",function(n){t&&n.originalEvent&&n.originalEvent.changedTouches&&n.originalEvent.changedTouches[0]&&(Math.abs(f-n.pageX)>50||Math.abs(e-n.pageY)>50)&&clearTimeout(t)}).on("touchend.vakata.jstree",function(){t&&clearTimeout(t)}),n(i).on("context_hide.vakata.jstree",n.proxy(function(){this._data.contextmenu.visible=!1},this))},this.teardown=function(){this._data.contextmenu.visible&&n.vakata.context.hide(),u.teardown.call(this)},this.show_contextmenu=function(i,r,u,f){if(i=this.get_node(i),!i||i.id===n.jstree.root)return!1;var s=this.settings.contextmenu,h=this.get_node(i,!0),c=h.children(".jstree-anchor"),o=!1,e=!1;(s.show_at_node||r===t||u===t)&&(o=c.offset(),r=o.left,u=o.top+this._data.core.li_height),this.settings.contextmenu.select_node&&!this.is_selected(i)&&this.activate_node(i,f),e=s.items,n.isFunction(e)&&(e=e.call(this,i,n.proxy(function(n){this._show_contextmenu(i,r,u,n)},this))),n.isPlainObject(e)&&this._show_contextmenu(i,r,u,e)},this._show_contextmenu=function(t,r,u,f){var e=this.get_node(t,!0),o=e.children(".jstree-anchor");n(i).one("context_show.vakata.jstree",n.proxy(function(t,i){var r="jstree-contextmenu jstree-"+this.get_theme()+"-contextmenu";n(i.element).addClass(r)},this)),this._data.contextmenu.visible=!0,n.vakata.context.show(o,{x:r,y:u},f),this.trigger("show_contextmenu",{node:t,x:r,y:u})}},function(n){var r=!1,t={element:!1,reference:!1,position_x:0,position_y:0,items:[],html:"",is_visible:!1};n.vakata.context={settings:{hide_onmouseleave:0,icons:!0},_trigger:function(r){n(i).triggerHandler("context_"+r+".vakata",{reference:t.reference,element:t.element,position:{x:t.position_x,y:t.position_y}})},_execute:function(i){return i=t.items[i],i&&(!i._disabled||n.isFunction(i._disabled)&&!i._disabled({item:i,reference:t.reference,element:t.element}))&&i.action?i.action.call(null,{item:i,reference:t.reference,element:t.element,position:{x:t.position_x,y:t.position_y}}):!1},_parse:function(i,r){if(!i)return!1;r||(t.html="",t.items=[]);var u="",f=!1,e;return r&&(u+="<ul>"),n.each(i,function(i,r){return r?(t.items.push(r),!f&&r.separator_before&&(u+="<li class='vakata-context-separator'><a href='#' "+(n.vakata.context.settings.icons?"":'style="margin-left:0px;"')+">&#160;<\/a><\/li>"),f=!1,u+="<li class='"+(r._class||"")+(r._disabled===!0||n.isFunction(r._disabled)&&r._disabled({item:r,reference:t.reference,element:t.element})?" vakata-contextmenu-disabled ":"")+"' "+(r.shortcut?" data-shortcut='"+r.shortcut+"' ":"")+">",u+="<a href='#' rel='"+(t.items.length-1)+"'>",n.vakata.context.settings.icons&&(u+="<i ",r.icon&&(u+=-1!==r.icon.indexOf("/")||-1!==r.icon.indexOf(".")?" style='background:url(\""+r.icon+"\") center center no-repeat' ":" class='"+r.icon+"' "),u+="><\/i><span class='vakata-contextmenu-sep'>&#160;<\/span>"),u+=(n.isFunction(r.label)?r.label({item:i,reference:t.reference,element:t.element}):r.label)+(r.shortcut?' <span class="vakata-contextmenu-shortcut vakata-contextmenu-shortcut-'+r.shortcut+'">'+(r.shortcut_label||"")+"<\/span>":"")+"<\/a>",r.submenu&&(e=n.vakata.context._parse(r.submenu,!0),e&&(u+=e)),u+="<\/li>",void(r.separator_after&&(u+="<li class='vakata-context-separator'><a href='#' "+(n.vakata.context.settings.icons?"":'style="margin-left:0px;"')+">&#160;<\/a><\/li>",f=!0))):!0}),u=u.replace(/<li class\='vakata-context-separator'\><\/li\>$/,""),r&&(u+="<\/ul>"),r||(t.html=u,n.vakata.context._trigger("parse")),u.length>10?u:!1},_show_submenu:function(t){if(t=n(t),t.length&&t.children("ul").length){var i=t.children("ul"),u=t.offset().left+t.outerWidth(),e=t.offset().top,f=i.width(),o=i.height(),s=n(window).width()+n(window).scrollLeft(),h=n(window).height()+n(window).scrollTop();r?t[u-(f+10+t.outerWidth())<0?"addClass":"removeClass"]("vakata-context-left"):t[u+f+10>s?"addClass":"removeClass"]("vakata-context-right"),e+o+10>h&&i.css("bottom","-1px"),i.show()}},show:function(i,u,f){var h,o,e,s,c,l,a,v,y=!0;switch(t.element&&t.element.length&&t.element.width(""),y){case!u&&!i:return!1;case!!u&&!!i:t.reference=i,t.position_x=u.x,t.position_y=u.y;break;case!u&&!!i:t.reference=i,h=i.offset(),t.position_x=h.left+i.outerHeight(),t.position_y=h.top;break;case!!u&&!i:t.position_x=u.x,t.position_y=u.y}i&&!f&&n(i).data("vakata_contextmenu")&&(f=n(i).data("vakata_contextmenu")),n.vakata.context._parse(f)&&t.element.html(t.html),t.items.length&&(t.element.appendTo("body"),o=t.element,e=t.position_x,s=t.position_y,c=o.width(),l=o.height(),a=n(window).width()+n(window).scrollLeft(),v=n(window).height()+n(window).scrollTop(),r&&(e-=o.outerWidth()-n(i).outerWidth(),e<n(window).scrollLeft()+20&&(e=n(window).scrollLeft()+20)),e+c+20>a&&(e=a-(c+20)),s+l+20>v&&(s=v-(l+20)),t.element.css({left:e,top:s}).show().find("a").first().focus().parent().addClass("vakata-context-hover"),t.is_visible=!0,n.vakata.context._trigger("show"))},hide:function(){t.is_visible&&(t.element.hide().find("ul").hide().end().find(":focus").blur().end().detach(),t.is_visible=!1,n.vakata.context._trigger("hide"))}},n(function(){r="rtl"===n("body").css("direction");var u=!1;t.element=n("<ul class='vakata-context'><\/ul>"),t.element.on("mouseenter","li",function(i){i.stopImmediatePropagation(),n.contains(this,i.relatedTarget)||(u&&clearTimeout(u),t.element.find(".vakata-context-hover").removeClass("vakata-context-hover").end(),n(this).siblings().find("ul").hide().end().end().parentsUntil(".vakata-context","li").addBack().addClass("vakata-context-hover"),n.vakata.context._show_submenu(this))}).on("mouseleave","li",function(t){n.contains(this,t.relatedTarget)||n(this).find(".vakata-context-hover").addBack().removeClass("vakata-context-hover")}).on("mouseleave",function(){n(this).find(".vakata-context-hover").removeClass("vakata-context-hover"),n.vakata.context.settings.hide_onmouseleave&&(u=setTimeout(function(){return function(){n.vakata.context.hide()}}(this),n.vakata.context.settings.hide_onmouseleave))}).on("click","a",function(t){t.preventDefault(),n(this).blur().parent().hasClass("vakata-context-disabled")||n.vakata.context._execute(n(this).attr("rel"))===!1||n.vakata.context.hide()}).on("keydown","a",function(i){var r=null;switch(i.which){case 13:case 32:i.type="mouseup",i.preventDefault(),n(i.currentTarget).trigger(i);break;case 37:t.is_visible&&(t.element.find(".vakata-context-hover").last().closest("li").first().find("ul").hide().find(".vakata-context-hover").removeClass("vakata-context-hover").end().end().children("a").focus(),i.stopImmediatePropagation(),i.preventDefault());break;case 38:t.is_visible&&(r=t.element.find("ul:visible").addBack().last().children(".vakata-context-hover").removeClass("vakata-context-hover").prevAll("li:not(.vakata-context-separator)").first(),r.length||(r=t.element.find("ul:visible").addBack().last().children("li:not(.vakata-context-separator)").last()),r.addClass("vakata-context-hover").children("a").focus(),i.stopImmediatePropagation(),i.preventDefault());break;case 39:t.is_visible&&(t.element.find(".vakata-context-hover").last().children("ul").show().children("li:not(.vakata-context-separator)").removeClass("vakata-context-hover").first().addClass("vakata-context-hover").children("a").focus(),i.stopImmediatePropagation(),i.preventDefault());break;case 40:t.is_visible&&(r=t.element.find("ul:visible").addBack().last().children(".vakata-context-hover").removeClass("vakata-context-hover").nextAll("li:not(.vakata-context-separator)").first(),r.length||(r=t.element.find("ul:visible").addBack().last().children("li:not(.vakata-context-separator)").first()),r.addClass("vakata-context-hover").children("a").focus(),i.stopImmediatePropagation(),i.preventDefault());break;case 27:n.vakata.context.hide(),i.preventDefault()}}).on("keydown",function(n){n.preventDefault();var i=t.element.find(".vakata-contextmenu-shortcut-"+n.which).parent();i.parent().not(".vakata-context-disabled")&&i.click()}),n(i).on("mousedown.vakata.jstree",function(i){t.is_visible&&!n.contains(t.element[0],i.target)&&n.vakata.context.hide()}).on("context_show.vakata.jstree",function(){t.element.find("li:has(ul)").children("a").addClass("vakata-context-parent"),r&&t.element.addClass("vakata-context-rtl").css("direction","rtl"),t.element.find("ul").hide().end()})})}(n),n.jstree.defaults.dnd={copy:!0,open_timeout:500,is_draggable:!0,check_while_dragging:!0,always_copy:!1,inside_pos:0,drag_selection:!0,touch:!0,large_drop_target:!1,large_drag_target:!1},n.jstree.plugins.dnd=function(t,i){this.bind=function(){i.bind.call(this),this.element.on("mousedown.jstree touchstart.jstree",this.settings.dnd.large_drag_target?".jstree-node":".jstree-anchor",n.proxy(function(t){if(this.settings.dnd.large_drag_target&&n(t.target).closest(".jstree-node")[0]!==t.currentTarget||"touchstart"===t.type&&(!this.settings.dnd.touch||"selected"===this.settings.dnd.touch&&!n(t.currentTarget).closest(".jstree-node").children(".jstree-anchor").hasClass("jstree-clicked")))return!0;var i=this.get_node(t.target),r=this.is_selected(i)&&this.settings.dnd.drag_selection?this.get_top_selected().length:1,u=r>1?r+" "+this.get_string("nodes"):this.get_text(t.currentTarget);return this.settings.core.force_text&&(u=n.vakata.html.escape(u)),i&&i.id&&i.id!==n.jstree.root&&(1===t.which||"touchstart"===t.type)&&(this.settings.dnd.is_draggable===!0||n.isFunction(this.settings.dnd.is_draggable)&&this.settings.dnd.is_draggable.call(this,r>1?this.get_top_selected(!0):[i],t))?(this.element.trigger("mousedown.jstree"),n.vakata.dnd.start(t,{jstree:!0,origin:this,obj:this.get_node(i,!0),nodes:r>1?this.get_top_selected():[i.id]},'<div id="jstree-dnd" class="jstree-'+this.get_theme()+" jstree-"+this.get_theme()+"-"+this.get_theme_variant()+" "+(this.settings.core.themes.responsive?" jstree-dnd-responsive":"")+'"><i class="jstree-icon jstree-er"><\/i>'+u+'<ins class="jstree-copy" style="display:none;">+<\/ins><\/div>')):void 0},this))}},n(function(){var t=!1,f=!1,r=!1,e=!1,u=n('<div id="jstree-marker">&#160;<\/div>').hide();n(i).on("dnd_start.vakata.jstree",function(n,i){t=!1,r=!1,i&&i.data&&i.data.jstree&&u.appendTo("body")}).on("dnd_move.vakata.jstree",function(i,o){if(e&&clearTimeout(e),o&&o.data&&o.data.jstree&&(!o.event.target.id||"jstree-marker"!==o.event.target.id)){r=o.event;var s=n.jstree.reference(o.event.target),h=!1,a=!1,k=!1,ft,d,g,v,y,p,nt,l,c,tt,rt,it,ut,w,b;if(s&&s._data&&s._data.dnd)if(u.attr("class","jstree-"+s.get_theme()+(s.settings.core.themes.responsive?" jstree-dnd-responsive":"")),o.helper.children().attr("class","jstree-"+s.get_theme()+" jstree-"+s.get_theme()+"-"+s.get_theme_variant()+" "+(s.settings.core.themes.responsive?" jstree-dnd-responsive":"")).find(".jstree-copy").first()[o.data.origin&&(o.data.origin.settings.dnd.always_copy||o.data.origin.settings.dnd.copy&&(o.event.metaKey||o.event.ctrlKey))?"show":"hide"](),o.event.target!==s.element[0]&&o.event.target!==s.get_container_ul()[0]||0!==s.get_container_ul().children().length){if(h=s.settings.dnd.large_drop_target?n(o.event.target).closest(".jstree-node").children(".jstree-anchor"):n(o.event.target).closest(".jstree-anchor"),h&&h.length&&h.parent().is(".jstree-closed, .jstree-open, .jstree-leaf")&&(a=h.offset(),k=o.event.pageY-a.top,v=h.outerHeight(),nt=v/3>k?["b","i","a"]:k>v-v/3?["a","i","b"]:k>v/2?["i","a","b"]:["i","b","a"],n.each(nt,function(i,r){switch(r){case"b":d=a.left-6,g=a.top,y=s.get_parent(h),p=h.parent().index();break;case"i":w=s.settings.dnd.inside_pos,b=s.get_node(h.parent()),d=a.left-2,g=a.top+v/2+1,y=b.id,p="first"===w?0:"last"===w?b.children.length:Math.min(w,b.children.length);break;case"a":d=a.left-6,g=a.top+v,y=s.get_parent(h),p=h.parent().index()+1}for(l=!0,c=0,tt=o.data.nodes.length;tt>c;c++)if(rt=o.data.origin&&(o.data.origin.settings.dnd.always_copy||o.data.origin.settings.dnd.copy&&(o.event.metaKey||o.event.ctrlKey))?"copy_node":"move_node",it=p,"move_node"===rt&&"a"===r&&o.data.origin&&o.data.origin===s&&y===s.get_parent(o.data.nodes[c])&&(ut=s.get_node(y),it>n.inArray(o.data.nodes[c],ut.children)&&(it-=1)),l=l&&(s&&s.settings&&s.settings.dnd&&s.settings.dnd.check_while_dragging===!1||s.check(rt,o.data.origin&&o.data.origin!==s?o.data.origin.get_node(o.data.nodes[c]):o.data.nodes[c],y,it,{dnd:!0,ref:s.get_node(h.parent()),pos:r,origin:o.data.origin,is_multi:o.data.origin&&o.data.origin!==s,is_foreign:!o.data.origin})),!l){s&&s.last_error&&(f=s.last_error());break}return"i"===r&&h.parent().is(".jstree-closed")&&s.settings.dnd.open_timeout&&(e=setTimeout(function(n,t){return function(){n.open_node(t)}}(s,h),s.settings.dnd.open_timeout)),l?(t={ins:s,par:y,pos:"i"!==r||"last"!==w||0!==p||s.is_loaded(b)?p:"last"},u.css({left:d+"px",top:g+"px"}).show(),o.helper.find(".jstree-icon").first().removeClass("jstree-er").addClass("jstree-ok"),f={},nt=!0,!1):void 0}),nt===!0))return}else{for(l=!0,c=0,tt=o.data.nodes.length;tt>c;c++)if(l=l&&s.check(o.data.origin&&(o.data.origin.settings.dnd.always_copy||o.data.origin.settings.dnd.copy&&(o.event.metaKey||o.event.ctrlKey))?"copy_node":"move_node",o.data.origin&&o.data.origin!==s?o.data.origin.get_node(o.data.nodes[c]):o.data.nodes[c],n.jstree.root,"last",{dnd:!0,ref:s.get_node(n.jstree.root),pos:"i",origin:o.data.origin,is_multi:o.data.origin&&o.data.origin!==s,is_foreign:!o.data.origin}),!l)break;if(l)return t={ins:s,par:n.jstree.root,pos:"last"},u.hide(),void o.helper.find(".jstree-icon").first().removeClass("jstree-er").addClass("jstree-ok")}t=!1,o.helper.find(".jstree-icon").removeClass("jstree-ok").addClass("jstree-er"),u.hide()}}).on("dnd_scroll.vakata.jstree",function(n,i){i&&i.data&&i.data.jstree&&(u.hide(),t=!1,r=!1,i.helper.find(".jstree-icon").first().removeClass("jstree-ok").addClass("jstree-er"))}).on("dnd_stop.vakata.jstree",function(i,o){if(e&&clearTimeout(e),o&&o.data&&o.data.jstree){u.hide().detach();var s,h,c=[];if(t){for(s=0,h=o.data.nodes.length;h>s;s++)c[s]=o.data.origin?o.data.origin.get_node(o.data.nodes[s]):o.data.nodes[s];t.ins[o.data.origin&&(o.data.origin.settings.dnd.always_copy||o.data.origin.settings.dnd.copy&&(o.event.metaKey||o.event.ctrlKey))?"copy_node":"move_node"](c,t.par,t.pos,!1,!1,!1,o.data.origin)}else s=n(o.event.target).closest(".jstree"),s.length&&f&&f.error&&"check"===f.error&&(s=s.jstree(!0),s&&s.settings.core.error.call(this,f));r=!1,t=!1}}).on("keyup.jstree keydown.jstree",function(t,i){i=n.vakata.dnd._get(),i&&i.data&&i.data.jstree&&(i.helper.find(".jstree-copy").first()[i.data.origin&&(i.data.origin.settings.dnd.always_copy||i.data.origin.settings.dnd.copy&&(t.metaKey||t.ctrlKey))?"show":"hide"](),r&&(r.metaKey=t.metaKey,r.ctrlKey=t.ctrlKey,n.vakata.dnd._trigger("move",r)))})}),function(n){n.vakata.html={div:n("<div />"),escape:function(t){return n.vakata.html.div.text(t).html()},strip:function(t){return n.vakata.html.div.empty().append(n.parseHTML(t)).text()}};var t={element:!1,target:!1,is_down:!1,is_drag:!1,helper:!1,helper_w:0,data:!1,init_x:0,init_y:0,scroll_l:0,scroll_t:0,scroll_e:!1,scroll_i:!1,is_touch:!1};n.vakata.dnd={settings:{scroll_speed:10,scroll_proximity:20,helper_left:5,helper_top:10,threshold:5,threshold_touch:50},_trigger:function(t,r){var u=n.vakata.dnd._get();u.event=r,n(i).triggerHandler("dnd_"+t+".vakata",u)},_get:function(){return{data:t.data,element:t.element,helper:t.helper}},_clean:function(){t.helper&&t.helper.remove(),t.scroll_i&&(clearInterval(t.scroll_i),t.scroll_i=!1),t={element:!1,target:!1,is_down:!1,is_drag:!1,helper:!1,helper_w:0,data:!1,init_x:0,init_y:0,scroll_l:0,scroll_t:0,scroll_e:!1,scroll_i:!1,is_touch:!1},n(i).off("mousemove.vakata.jstree touchmove.vakata.jstree",n.vakata.dnd.drag),n(i).off("mouseup.vakata.jstree touchend.vakata.jstree",n.vakata.dnd.stop)},_scroll:function(i){if(!t.scroll_e||!t.scroll_l&&!t.scroll_t)return t.scroll_i&&(clearInterval(t.scroll_i),t.scroll_i=!1),!1;if(!t.scroll_i)return t.scroll_i=setInterval(n.vakata.dnd._scroll,100),!1;if(i===!0)return!1;var r=t.scroll_e.scrollTop(),u=t.scroll_e.scrollLeft();t.scroll_e.scrollTop(r+t.scroll_t*n.vakata.dnd.settings.scroll_speed),t.scroll_e.scrollLeft(u+t.scroll_l*n.vakata.dnd.settings.scroll_speed),(r!==t.scroll_e.scrollTop()||u!==t.scroll_e.scrollLeft())&&n.vakata.dnd._trigger("scroll",t.scroll_e)},start:function(r,u,f){"touchstart"===r.type&&r.originalEvent&&r.originalEvent.changedTouches&&r.originalEvent.changedTouches[0]&&(r.pageX=r.originalEvent.changedTouches[0].pageX,r.pageY=r.originalEvent.changedTouches[0].pageY,r.target=i.elementFromPoint(r.originalEvent.changedTouches[0].pageX-window.pageXOffset,r.originalEvent.changedTouches[0].pageY-window.pageYOffset)),t.is_drag&&n.vakata.dnd.stop({});try{r.currentTarget.unselectable="on",r.currentTarget.onselectstart=function(){return!1},r.currentTarget.style&&(r.currentTarget.style.MozUserSelect="none")}catch(e){}return t.init_x=r.pageX,t.init_y=r.pageY,t.data=u,t.is_down=!0,t.element=r.currentTarget,t.target=r.target,t.is_touch="touchstart"===r.type,f!==!1&&(t.helper=n("<div id='vakata-dnd'><\/div>").html(f).css({display:"block",margin:"0",padding:"0",position:"absolute",top:"-2000px",lineHeight:"16px",zIndex:"10000"})),n(i).on("mousemove.vakata.jstree touchmove.vakata.jstree",n.vakata.dnd.drag),n(i).on("mouseup.vakata.jstree touchend.vakata.jstree",n.vakata.dnd.stop),!1},drag:function(r){if("touchmove"===r.type&&r.originalEvent&&r.originalEvent.changedTouches&&r.originalEvent.changedTouches[0]&&(r.pageX=r.originalEvent.changedTouches[0].pageX,r.pageY=r.originalEvent.changedTouches[0].pageY,r.target=i.elementFromPoint(r.originalEvent.changedTouches[0].pageX-window.pageXOffset,r.originalEvent.changedTouches[0].pageY-window.pageYOffset)),t.is_down){if(!t.is_drag){if(!(Math.abs(r.pageX-t.init_x)>(t.is_touch?n.vakata.dnd.settings.threshold_touch:n.vakata.dnd.settings.threshold)||Math.abs(r.pageY-t.init_y)>(t.is_touch?n.vakata.dnd.settings.threshold_touch:n.vakata.dnd.settings.threshold)))return;t.helper&&(t.helper.appendTo("body"),t.helper_w=t.helper.outerWidth()),t.is_drag=!0,n.vakata.dnd._trigger("start",r)}var u=!1,l=!1,f=!1,o=!1,e=!1,s=!1,a=!1,v=!1,h=!1,c=!1;return t.scroll_t=0,t.scroll_l=0,t.scroll_e=!1,n(n(r.target).parentsUntil("body").addBack().get().reverse()).filter(function(){return/^auto|scroll$/.test(n(this).css("overflow"))&&(this.scrollHeight>this.offsetHeight||this.scrollWidth>this.offsetWidth)}).each(function(){var u=n(this),i=u.offset();return this.scrollHeight>this.offsetHeight&&(i.top+u.height()-r.pageY<n.vakata.dnd.settings.scroll_proximity&&(t.scroll_t=1),r.pageY-i.top<n.vakata.dnd.settings.scroll_proximity&&(t.scroll_t=-1)),this.scrollWidth>this.offsetWidth&&(i.left+u.width()-r.pageX<n.vakata.dnd.settings.scroll_proximity&&(t.scroll_l=1),r.pageX-i.left<n.vakata.dnd.settings.scroll_proximity&&(t.scroll_l=-1)),t.scroll_t||t.scroll_l?(t.scroll_e=n(this),!1):void 0}),t.scroll_e||(u=n(i),l=n(window),f=u.height(),o=l.height(),e=u.width(),s=l.width(),a=u.scrollTop(),v=u.scrollLeft(),f>o&&r.pageY-a<n.vakata.dnd.settings.scroll_proximity&&(t.scroll_t=-1),f>o&&o-(r.pageY-a)<n.vakata.dnd.settings.scroll_proximity&&(t.scroll_t=1),e>s&&r.pageX-v<n.vakata.dnd.settings.scroll_proximity&&(t.scroll_l=-1),e>s&&s-(r.pageX-v)<n.vakata.dnd.settings.scroll_proximity&&(t.scroll_l=1),(t.scroll_t||t.scroll_l)&&(t.scroll_e=u)),t.scroll_e&&n.vakata.dnd._scroll(!0),t.helper&&(h=parseInt(r.pageY+n.vakata.dnd.settings.helper_top,10),c=parseInt(r.pageX+n.vakata.dnd.settings.helper_left,10),f&&h+25>f&&(h=f-50),e&&c+t.helper_w>e&&(c=e-(t.helper_w+2)),t.helper.css({left:c+"px",top:h+"px"})),n.vakata.dnd._trigger("move",r),!1}},stop:function(r){if("touchend"===r.type&&r.originalEvent&&r.originalEvent.changedTouches&&r.originalEvent.changedTouches[0]&&(r.pageX=r.originalEvent.changedTouches[0].pageX,r.pageY=r.originalEvent.changedTouches[0].pageY,r.target=i.elementFromPoint(r.originalEvent.changedTouches[0].pageX-window.pageXOffset,r.originalEvent.changedTouches[0].pageY-window.pageYOffset)),t.is_drag)n.vakata.dnd._trigger("stop",r);else if("touchend"===r.type&&r.target===t.target){var u=setTimeout(function(){n(r.target).click()},100);n(r.target).one("click",function(){u&&clearTimeout(u)})}return n.vakata.dnd._clean(),!1}}}(n),n.jstree.defaults.massload=null,n.jstree.plugins.massload=function(t,i){this.init=function(n,t){i.init.call(this,n,t),this._data.massload={}},this._load_nodes=function(t,r,u){var f=this.settings.massload;return u&&!n.isEmptyObject(this._data.massload)?i._load_nodes.call(this,t,r,u):n.isFunction(f)?f.call(this,t,n.proxy(function(n){if(n)for(var f in n)n.hasOwnProperty(f)&&(this._data.massload[f]=n[f]);i._load_nodes.call(this,t,r,u)},this)):"object"==typeof f&&f&&f.url?(f=n.extend(!0,{},f),n.isFunction(f.url)&&(f.url=f.url.call(this,t)),n.isFunction(f.data)&&(f.data=f.data.call(this,t)),n.ajax(f).done(n.proxy(function(n){if(n)for(var o in n)n.hasOwnProperty(o)&&(this._data.massload[o]=n[o]);i._load_nodes.call(this,t,r,u)},this)).fail(n.proxy(function(){i._load_nodes.call(this,t,r,u)},this))):i._load_nodes.call(this,t,r,u)},this._load_node=function(t,r){var u=this._data.massload[t.id];return u?this["string"==typeof u?"_append_html_data":"_append_json_data"](t,"string"==typeof u?n(n.parseHTML(u)).filter(function(){return 3!==this.nodeType}):u,function(n){r.call(this,n),delete this._data.massload[t.id]}):i._load_node.call(this,t,r)}},n.jstree.defaults.search={ajax:!1,fuzzy:!1,case_sensitive:!1,show_only_matches:!1,show_only_matches_children:!1,close_opened_onclear:!0,search_leaves_only:!1,search_callback:!1},n.jstree.plugins.search=function(i,r){this.bind=function(){r.bind.call(this),this._data.search.str="",this._data.search.dom=n(),this._data.search.res=[],this._data.search.opn=[],this._data.search.som=!1,this._data.search.smc=!1,this._data.search.hdn=[],this.element.on("search.jstree",n.proxy(function(t,i){if(this._data.search.som&&i.res.length){for(var f=this._model.data,r=[],u=0,e=i.res.length;e>u;u++)f[i.res[u]]&&!f[i.res[u]].state.hidden&&(r.push(i.res[u]),r=r.concat(f[i.res[u]].parents),this._data.search.smc&&(r=r.concat(f[i.res[u]].children_d)));r=n.vakata.array_remove_item(n.vakata.array_unique(r),n.jstree.root),this._data.search.hdn=this.hide_all(!0),this.show_node(r)}},this)).on("clear_search.jstree",n.proxy(function(n,t){this._data.search.som&&t.res.length&&this.show_node(this._data.search.hdn)},this))},this.search=function(i,r,u,f,e,o){if(i===!1||""===n.trim(i.toString()))return this.clear_search();f=this.get_node(f),f=f&&f.id?f.id:null,i=i.toString();var h=this.settings.search,s=h.ajax?h.ajax:!1,v=this._model.data,y=null,a=[],c=[],l,p;if(this._data.search.res.length&&!e&&this.clear_search(),u===t&&(u=h.show_only_matches),o===t&&(o=h.show_only_matches_children),!r&&s!==!1)return n.isFunction(s)?s.call(this,i,n.proxy(function(t){t&&t.d&&(t=t.d),this._load_nodes(n.isArray(t)?n.vakata.array_unique(t):[],function(){this.search(i,!0,u,f,e)},!0)},this),f):(s=n.extend({},s),s.data||(s.data={}),s.data.str=i,f&&(s.data.inside=f),n.ajax(s).fail(n.proxy(function(){this._data.core.last_error={error:"ajax",plugin:"search",id:"search_01",reason:"Could not load search parents",data:JSON.stringify(s)},this.settings.core.error.call(this,this._data.core.last_error)},this)).done(n.proxy(function(t){t&&t.d&&(t=t.d),this._load_nodes(n.isArray(t)?n.vakata.array_unique(t):[],function(){this.search(i,!0,u,f,e)},!0)},this)));if(e||(this._data.search.str=i,this._data.search.dom=n(),this._data.search.res=[],this._data.search.opn=[],this._data.search.som=u,this._data.search.smc=o),y=new n.vakata.search(i,!0,{caseSensitive:h.case_sensitive,fuzzy:h.fuzzy}),n.each(v[f?f:n.jstree.root].children_d,function(n,t){var r=v[t];r.text&&(!h.search_leaves_only||r.state.loaded&&0===r.children.length)&&(h.search_callback&&h.search_callback.call(this,i,r)||!h.search_callback&&y.search(r.text).isMatch)&&(a.push(t),c=c.concat(r.parents))}),a.length){for(c=n.vakata.array_unique(c),l=0,p=c.length;p>l;l++)c[l]!==n.jstree.root&&v[c[l]]&&this.open_node(c[l],null,0)===!0&&this._data.search.opn.push(c[l]);e?(this._data.search.dom=this._data.search.dom.add(n(this.element[0].querySelectorAll("#"+n.map(a,function(t){return-1!=="0123456789".indexOf(t[0])?"\\3"+t[0]+" "+t.substr(1).replace(n.jstree.idregex,"\\$&"):t.replace(n.jstree.idregex,"\\$&")}).join(", #")))),this._data.search.res=n.vakata.array_unique(this._data.search.res.concat(a))):(this._data.search.dom=n(this.element[0].querySelectorAll("#"+n.map(a,function(t){return-1!=="0123456789".indexOf(t[0])?"\\3"+t[0]+" "+t.substr(1).replace(n.jstree.idregex,"\\$&"):t.replace(n.jstree.idregex,"\\$&")}).join(", #"))),this._data.search.res=a),this._data.search.dom.children(".jstree-anchor").addClass("jstree-search")}this.trigger("search",{nodes:this._data.search.dom,str:i,res:this._data.search.res,show_only_matches:u})},this.clear_search=function(){this.settings.search.close_opened_onclear&&this.close_node(this._data.search.opn,0),this.trigger("clear_search",{nodes:this._data.search.dom,str:this._data.search.str,res:this._data.search.res}),this._data.search.res.length&&(this._data.search.dom=n(this.element[0].querySelectorAll("#"+n.map(this._data.search.res,function(t){return-1!=="0123456789".indexOf(t[0])?"\\3"+t[0]+" "+t.substr(1).replace(n.jstree.idregex,"\\$&"):t.replace(n.jstree.idregex,"\\$&")}).join(", #"))),this._data.search.dom.children(".jstree-anchor").removeClass("jstree-search")),this._data.search.str="",this._data.search.res=[],this._data.search.opn=[],this._data.search.dom=n()},this.redraw_node=function(t){if(t=r.redraw_node.apply(this,arguments),t&&-1!==n.inArray(t.id,this._data.search.res)){for(var o=null,e=0,s=t.childNodes.length;s>e;e++)if(t.childNodes[e]&&t.childNodes[e].className&&-1!==t.childNodes[e].className.indexOf("jstree-anchor")){o=t.childNodes[e];break}o&&(o.className+=" jstree-search")}return t}},function(n){n.vakata.search=function(t,i,r){r=r||{},r=n.extend({},n.vakata.search.defaults,r),r.fuzzy!==!1&&(r.fuzzy=!0),t=r.caseSensitive?t:t.toLowerCase();var f=r.location,s=r.distance,l=r.threshold,u=t.length,h,c,e,o;return u>32&&(r.fuzzy=!1),r.fuzzy&&(h=1<<u-1,c=function(){for(var i={},n=0,n=0;u>n;n++)i[t.charAt(n)]=0;for(n=0;u>n;n++)i[t.charAt(n)]|=1<<u-n-1;return i}(),e=function(n,t){var i=n/u,r=Math.abs(f-t);return s?i+r/s:r?1:i}),o=function(n){if(n=r.caseSensitive?n:n.toLowerCase(),t===n||-1!==n.indexOf(t))return{isMatch:!0,score:0};if(!r.fuzzy)return{isMatch:!1,score:1};var a,i,tt=n.length,v=l,o=n.indexOf(t,f),p,s,w=u+tt,b,g,k,y,nt,d=1,it=[];for(-1!==o&&(v=Math.min(e(0,o),v),o=n.lastIndexOf(t,f+u),-1!==o&&(v=Math.min(e(0,o),v))),o=-1,a=0;u>a;a++){for(p=0,s=w;s>p;)e(a,f+s)<=v?p=s:w=s,s=Math.floor((w-p)/2+p);for(w=s,g=Math.max(1,f-s+1),k=Math.min(f+s,tt)+u,y=new Array(k+2),y[k+1]=(1<<a)-1,i=k;i>=g;i--)if(nt=c[n.charAt(i-1)],y[i]=0===a?(y[i+1]<<1|1)&nt:(y[i+1]<<1|1)&nt|(b[i+1]|b[i])<<1|1|b[i+1],y[i]&h&&(d=e(a,i-1),v>=d)){if(v=d,o=i-1,it.push(o),!(o>f))break;g=Math.max(1,2*f-o)}if(e(a+1,f)>v)break;b=y}return{isMatch:o>=0,score:d}},i===!0?{search:o}:o(i)},n.vakata.search.defaults={location:0,distance:100,threshold:.6,fuzzy:!1,caseSensitive:!1}}(n),n.jstree.defaults.sort=function(n,t){return this.get_text(n)>this.get_text(t)?1:-1},n.jstree.plugins.sort=function(t,i){this.bind=function(){i.bind.call(this),this.element.on("model.jstree",n.proxy(function(n,t){this.sort(t.parent,!0)},this)).on("rename_node.jstree create_node.jstree",n.proxy(function(n,t){this.sort(t.parent||t.node.parent,!1),this.redraw_node(t.parent||t.node.parent,!0)},this)).on("move_node.jstree copy_node.jstree",n.proxy(function(n,t){this.sort(t.parent,!1),this.redraw_node(t.parent,!0)},this))},this.sort=function(t,i){var r,u;if(t=this.get_node(t),t&&t.children&&t.children.length&&(t.children.sort(n.proxy(this.settings.sort,this)),i))for(r=0,u=t.children_d.length;u>r;r++)this.sort(t.children_d[r],!1)}},l=!1,n.jstree.defaults.state={key:"jstree",events:"changed.jstree open_node.jstree close_node.jstree check_node.jstree uncheck_node.jstree",ttl:!1,filter:!1},n.jstree.plugins.state=function(t,i){this.bind=function(){i.bind.call(this);var t=n.proxy(function(){this.element.on(this.settings.state.events,n.proxy(function(){l&&clearTimeout(l),l=setTimeout(n.proxy(function(){this.save_state()},this),100)},this)),this.trigger("state_ready")},this);this.element.on("ready.jstree",n.proxy(function(){this.element.one("restore_state.jstree",t),this.restore_state()||t()},this))},this.save_state=function(){var t={state:this.get_state(),ttl:this.settings.state.ttl,sec:+new Date};n.vakata.storage.set(this.settings.state.key,JSON.stringify(t))},this.restore_state=function(){var t=n.vakata.storage.get(this.settings.state.key);if(t)try{t=JSON.parse(t)}catch(i){return!1}return t&&t.ttl&&t.sec&&+new Date-t.sec>t.ttl?!1:(t&&t.state&&(t=t.state),t&&n.isFunction(this.settings.state.filter)&&(t=this.settings.state.filter.call(this,t)),t?(this.element.one("set_state.jstree",function(i,r){r.instance.trigger("restore_state",{state:n.extend(!0,{},t)})}),this.set_state(t),!0):!1)},this.clear_state=function(){return n.vakata.storage.del(this.settings.state.key)}},function(n){n.vakata.storage={set:function(n,t){return window.localStorage.setItem(n,t)},get:function(n){return window.localStorage.getItem(n)},del:function(n){return window.localStorage.removeItem(n)}}}(n),n.jstree.defaults.types={"default":{}},n.jstree.defaults.types[n.jstree.root]={},n.jstree.plugins.types=function(i,r){this.init=function(i,u){var f,e;if(u&&u.types&&u.types["default"])for(f in u.types)if("default"!==f&&f!==n.jstree.root&&u.types.hasOwnProperty(f))for(e in u.types["default"])u.types["default"].hasOwnProperty(e)&&u.types[f][e]===t&&(u.types[f][e]=u.types["default"][e]);r.init.call(this,i,u),this._model.data[n.jstree.root].type=n.jstree.root},this.refresh=function(t,i){r.refresh.call(this,t,i),this._model.data[n.jstree.root].type=n.jstree.root},this.bind=function(){this.element.on("model.jstree",n.proxy(function(i,r){for(var f=this._model.data,e=r.nodes,s=this.settings.types,o="default",u=0,h=e.length;h>u;u++)o="default",f[e[u]].original&&f[e[u]].original.type&&s[f[e[u]].original.type]&&(o=f[e[u]].original.type),f[e[u]].data&&f[e[u]].data.jstree&&f[e[u]].data.jstree.type&&s[f[e[u]].data.jstree.type]&&(o=f[e[u]].data.jstree.type),f[e[u]].type=o,f[e[u]].icon===!0&&s[o].icon!==t&&(f[e[u]].icon=s[o].icon);f[n.jstree.root].type=n.jstree.root},this)),r.bind.call(this)},this.get_json=function(t,i,u){var e,s,o=this._model.data,h=i?n.extend(!0,{},i,{no_id:!1}):{},f=r.get_json.call(this,t,h,u);if(f===!1)return!1;if(n.isArray(f))for(e=0,s=f.length;s>e;e++)f[e].type=f[e].id&&o[f[e].id]&&o[f[e].id].type?o[f[e].id].type:"default",i&&i.no_id&&(delete f[e].id,f[e].li_attr&&f[e].li_attr.id&&delete f[e].li_attr.id,f[e].a_attr&&f[e].a_attr.id&&delete f[e].a_attr.id);else f.type=f.id&&o[f.id]&&o[f.id].type?o[f.id].type:"default",i&&i.no_id&&(f=this._delete_ids(f));return f},this._delete_ids=function(t){if(n.isArray(t)){for(var i=0,r=t.length;r>i;i++)t[i]=this._delete_ids(t[i]);return t}return delete t.id,t.li_attr&&t.li_attr.id&&delete t.li_attr.id,t.a_attr&&t.a_attr.id&&delete t.a_attr.id,t.children&&n.isArray(t.children)&&(t.children=this._delete_ids(t.children)),t},this.check=function(i,u,f,e,o){if(r.check.call(this,i,u,f,e,o)===!1)return!1;u=u&&u.id?u:this.get_node(u),f=f&&f.id?f:this.get_node(f);var c=u&&u.id?o&&o.origin?o.origin:n.jstree.reference(u.id):null,s,h,l,a;switch(c=c&&c._model&&c._model.data?c._model.data:null,i){case"create_node":case"move_node":case"copy_node":if("move_node"!==i||-1===n.inArray(u.id,f.children)){if(s=this.get_rules(f),s.max_children!==t&&-1!==s.max_children&&s.max_children===f.children.length)return this._data.core.last_error={error:"check",plugin:"types",id:"types_01",reason:"max_children prevents function: "+i,data:JSON.stringify({chk:i,pos:e,obj:u&&u.id?u.id:!1,par:f&&f.id?f.id:!1})},!1;if(s.valid_children!==t&&-1!==s.valid_children&&-1===n.inArray(u.type||"default",s.valid_children))return this._data.core.last_error={error:"check",plugin:"types",id:"types_02",reason:"valid_children prevents function: "+i,data:JSON.stringify({chk:i,pos:e,obj:u&&u.id?u.id:!1,par:f&&f.id?f.id:!1})},!1;if(c&&u.children_d&&u.parents){for(h=0,l=0,a=u.children_d.length;a>l;l++)h=Math.max(h,c[u.children_d[l]].parents.length);h=h-u.parents.length+1}(0>=h||h===t)&&(h=1);do{if(s.max_depth!==t&&-1!==s.max_depth&&s.max_depth<h)return this._data.core.last_error={error:"check",plugin:"types",id:"types_03",reason:"max_depth prevents function: "+i,data:JSON.stringify({chk:i,pos:e,obj:u&&u.id?u.id:!1,par:f&&f.id?f.id:!1})},!1;f=this.get_node(f.parent),s=this.get_rules(f),h++}while(f)}}return!0},this.get_rules=function(n){if(n=this.get_node(n),!n)return!1;var i=this.get_type(n,!0);return i.max_depth===t&&(i.max_depth=-1),i.max_children===t&&(i.max_children=-1),i.valid_children===t&&(i.valid_children=-1),i},this.get_type=function(t,i){return t=this.get_node(t),t?i?n.extend({type:t.type},this.settings.types[t.type]):t.type:!1},this.set_type=function(i,r){var u,f,s,e,o;if(n.isArray(i)){for(i=i.slice(),f=0,s=i.length;s>f;f++)this.set_type(i[f],r);return!0}return u=this.settings.types,i=this.get_node(i),u[r]&&i?(e=i.type,o=this.get_icon(i),i.type=r,(o===!0||u[e]&&u[e].icon!==t&&o===u[e].icon)&&this.set_icon(i,u[r].icon!==t?u[r].icon:!0),!0):!1}},n.jstree.defaults.unique={case_sensitive:!1,duplicate:function(n,t){return n+" ("+t+")"}},n.jstree.plugins.unique=function(i,r){this.check=function(t,i,u,f,e){if(r.check.call(this,t,i,u,f,e)===!1)return!1;if(i=i&&i.id?i:this.get_node(i),u=u&&u.id?u:this.get_node(u),!u||!u.children)return!0;for(var s="rename_node"===t?f:i.text,h=[],c=this.settings.unique.case_sensitive,l=this._model.data,o=0,a=u.children.length;a>o;o++)h.push(c?l[u.children[o]].text:l[u.children[o]].text.toLowerCase());switch(c||(s=s.toLowerCase()),t){case"delete_node":return!0;case"rename_node":return o=-1===n.inArray(s,h)||i.text&&i.text[c?"toString":"toLowerCase"]()===s,o||(this._data.core.last_error={error:"check",plugin:"unique",id:"unique_01",reason:"Child with name "+s+" already exists. Preventing: "+t,data:JSON.stringify({chk:t,pos:f,obj:i&&i.id?i.id:!1,par:u&&u.id?u.id:!1})}),o;case"create_node":return o=-1===n.inArray(s,h),o||(this._data.core.last_error={error:"check",plugin:"unique",id:"unique_04",reason:"Child with name "+s+" already exists. Preventing: "+t,data:JSON.stringify({chk:t,pos:f,obj:i&&i.id?i.id:!1,par:u&&u.id?u.id:!1})}),o;case"copy_node":return o=-1===n.inArray(s,h),o||(this._data.core.last_error={error:"check",plugin:"unique",id:"unique_02",reason:"Child with name "+s+" already exists. Preventing: "+t,data:JSON.stringify({chk:t,pos:f,obj:i&&i.id?i.id:!1,par:u&&u.id?u.id:!1})}),o;case"move_node":return o=i.parent===u.id&&(!e||!e.is_multi)||-1===n.inArray(s,h),o||(this._data.core.last_error={error:"check",plugin:"unique",id:"unique_03",reason:"Child with name "+s+" already exists. Preventing: "+t,data:JSON.stringify({chk:t,pos:f,obj:i&&i.id?i.id:!1,par:u&&u.id?u.id:!1})}),o}return!0},this.create_node=function(i,u,f,e,o){if(!u||u.text===t){if((null===i&&(i=n.jstree.root),i=this.get_node(i),!i)||(f=f===t?"last":f,!f.toString().match(/^(before|after)$/)&&!o&&!this.is_loaded(i)))return r.create_node.call(this,i,u,f,e,o);u||(u={});var l,h,c,s,a,v=this._model.data,y=this.settings.unique.case_sensitive,p=this.settings.unique.duplicate;for(h=l=this.get_string("New node"),c=[],s=0,a=i.children.length;a>s;s++)c.push(y?v[i.children[s]].text:v[i.children[s]].text.toLowerCase());for(s=1;-1!==n.inArray(y?h:h.toLowerCase(),c);)h=p.call(this,l,++s).toString();u.text=h}return r.create_node.call(this,i,u,f,e,o)}},o=i.createElement("DIV"),o.setAttribute("unselectable","on"),o.setAttribute("role","presentation"),o.className="jstree-wholerow",o.innerHTML="&#160;",n.jstree.plugins.wholerow=function(t,i){this.bind=function(){i.bind.call(this),this.element.on("ready.jstree set_state.jstree",n.proxy(function(){this.hide_dots()},this)).on("init.jstree loading.jstree ready.jstree",n.proxy(function(){this.get_container_ul().addClass("jstree-wholerow-ul")},this)).on("deselect_all.jstree",n.proxy(function(){this.element.find(".jstree-wholerow-clicked").removeClass("jstree-wholerow-clicked")},this)).on("changed.jstree",n.proxy(function(n,t){this.element.find(".jstree-wholerow-clicked").removeClass("jstree-wholerow-clicked");for(var i=!1,r=0,u=t.selected.length;u>r;r++)i=this.get_node(t.selected[r],!0),i&&i.length&&i.children(".jstree-wholerow").addClass("jstree-wholerow-clicked")},this)).on("open_node.jstree",n.proxy(function(n,t){this.get_node(t.node,!0).find(".jstree-clicked").parent().children(".jstree-wholerow").addClass("jstree-wholerow-clicked")},this)).on("hover_node.jstree dehover_node.jstree",n.proxy(function(n,t){"hover_node"===n.type&&this.is_disabled(t.node)||this.get_node(t.node,!0).children(".jstree-wholerow")["hover_node"===n.type?"addClass":"removeClass"]("jstree-wholerow-hovered")},this)).on("contextmenu.jstree",".jstree-wholerow",n.proxy(function(t){t.preventDefault();var i=n.Event("contextmenu",{metaKey:t.metaKey,ctrlKey:t.ctrlKey,altKey:t.altKey,shiftKey:t.shiftKey,pageX:t.pageX,pageY:t.pageY});n(t.currentTarget).closest(".jstree-node").children(".jstree-anchor").first().trigger(i)},this)).on("click.jstree",".jstree-wholerow",function(t){t.stopImmediatePropagation();var i=n.Event("click",{metaKey:t.metaKey,ctrlKey:t.ctrlKey,altKey:t.altKey,shiftKey:t.shiftKey});n(t.currentTarget).closest(".jstree-node").children(".jstree-anchor").first().trigger(i).focus()}).on("click.jstree",".jstree-leaf > .jstree-ocl",n.proxy(function(t){t.stopImmediatePropagation();var i=n.Event("click",{metaKey:t.metaKey,ctrlKey:t.ctrlKey,altKey:t.altKey,shiftKey:t.shiftKey});n(t.currentTarget).closest(".jstree-node").children(".jstree-anchor").first().trigger(i).focus()},this)).on("mouseover.jstree",".jstree-wholerow, .jstree-icon",n.proxy(function(n){return n.stopImmediatePropagation(),this.is_disabled(n.currentTarget)||this.hover_node(n.currentTarget),!1},this)).on("mouseleave.jstree",".jstree-node",n.proxy(function(n){this.dehover_node(n.currentTarget)},this))},this.teardown=function(){this.settings.wholerow&&this.element.find(".jstree-wholerow").remove(),i.teardown.call(this)},this.redraw_node=function(t){if(t=i.redraw_node.apply(this,arguments)){var e=o.cloneNode(!0);-1!==n.inArray(t.id,this._data.core.selected)&&(e.className+=" jstree-wholerow-clicked"),this._data.core.focused&&this._data.core.focused===t.id&&(e.className+=" jstree-wholerow-hovered"),t.insertBefore(e,t.childNodes[0])}return t}},i.registerElement&&Object&&Object.create){v=Object.create(HTMLElement.prototype),v.createdCallback=function(){var i={core:{},plugins:[]},t;for(t in n.jstree.plugins)n.jstree.plugins.hasOwnProperty(t)&&this.attributes[t]&&(i.plugins.push(t),this.getAttribute(t)&&JSON.parse(this.getAttribute(t))&&(i[t]=JSON.parse(this.getAttribute(t))));for(t in n.jstree.defaults.core)n.jstree.defaults.core.hasOwnProperty(t)&&this.attributes[t]&&(i.core[t]=JSON.parse(this.getAttribute(t))||this.getAttribute(t));n(this).jstree(i)};try{i.registerElement("vakata-jstree",{prototype:v})}catch(w){}}}})