(function(n){"use strict";typeof define=="function"&&define.amd?define(["jquery"],n):typeof module!="undefined"&&module.exports?module.exports=n(require("jquery")):n(jQuery)})(function(n,t){"use strict";var l,h,a,v,o,p;if(!n.jstree){var b=0,f=!1,u=!1,e=!1,w=[],y=n("script:last").attr("src"),i=window.document,c=i.createElement("LI"),r,s;if(c.setAttribute("role","treeitem"),r=i.createElement("I"),r.className="jstree-icon jstree-ocl",r.setAttribute("role","presentation"),c.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),c.appendChild(r),r=s=null,n.jstree={version:"3.3.0",defaults:{plugins:[]},plugins:{},path:y&&y.indexOf("/")!==-1?y.replace(/\/[^\/]+$/,""):"",idregex:/[\\:&!^|()\[\]<>@*'+~#";.,=\- \/${}%?`]/g,root:"#"},n.jstree.create=function(t,i){var r=new n.jstree.core(++b),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){n!=="core"&&(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=typeof i=="string",f=Array.prototype.slice.call(arguments,1),r=null;return i===!0&&!this.length?!1:(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),r!==null&&r!==t?!1:void 0}),r!==null&&r!==t?r:this)},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=this.element.css("direction")==="rtl";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 this.nodeType===3&&(!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[^ ]*|$/ig,"")});this.element=null},bind:function(){var t="",r=null,u=0;this.element.on("dblclick.jstree",function(n){if(n.target.tagName&&n.target.tagName.toLowerCase()==="input")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){if(n.target.tagName&&n.target.tagName.toLowerCase()==="input")return!0;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&&t.target.tagName.toLowerCase()==="input"||t.which!==32&&t.which!==13&&(t.shiftKey||t.ctrlKey||t.altKey||t.metaKey))return!0;var i=null;this._data.core.rtl&&(t.which===37?t.which=39:t.which===39&&(t.which=37));switch(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();break;case 113:t.preventDefault();this.edit(t.currentTarget)}},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;t<r;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;t<r;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&&u.target.tagName.toLowerCase()==="input")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(n(r).text().toLowerCase().indexOf(t)===0)return n(r).focus(),f=!0,!1},this)),f)return;if(e.slice(0,s).each(n.proxy(function(i,r){if(n(r).text().toLowerCase().indexOf(t)===0)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;n!==null&&n.nodeType!==1;)n=n.nextSibling;return n},_nextSibling:function(n){for(n=n?n.nextSibling:null;n!==null&&n.nodeType!==1;)n=n.nextSibling;return n},_previousSibling:function(n){for(n=n?n.previousSibling:null;n!==null&&n.nodeType!==1;)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(typeof t=="string"&&this._model.data[t.replace(/^#/,"")])t=this._model.data[t.replace(/^#/,"")];else if(typeof t=="string"&&(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"))t=this._model.data[n.jstree.root];else return!1;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;f<e;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&&r.offsetHeight===0;)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&&r.offsetHeight===0);return r?n(r):!1}if(t.hasClass("jstree-open")){for(r=this._firstChild(t.children(".jstree-children")[0]);r&&r.offsetHeight===0;)r=this._nextSibling(r);if(r!==null)return n(r)}r=t[0];do r=this._nextSibling(r);while(r&&r.offsetHeight===0);return r!==null?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&&r.offsetHeight===0;)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&&r.offsetHeight===0);return r?n(r):!1}r=t[0];do r=this._previousSibling(r);while(r&&r.offsetHeight===0);if(r!==null){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&&r.className.indexOf("jstree-node")!==-1?n(r):!1},get_parent:function(t){return(t=this.get_node(t),!t||t.id===n.jstree.root)?!1:t.parent},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?!1:n.children(".jstree-children").children(".jstree-node")},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,e,u,o,f;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,u=0,o=t.parents.length;u<o;u++)this._model.data[t.parents[u]].children_d=n.vakata.array_filter(this._model.data[t.parents[u]].children_d,function(i){return n.inArray(i,t.children_d)===-1});for(r=0,e=t.children_d.length;r<e;r++)this._model.data[t.children_d[r]].state.selected&&(f=!0),delete this._model.data[t.children_d[r]];f&&(this._data.core.selected=n.vakata.array_filter(this._data.core.selected,function(i){return n.inArray(i,t.children_d)===-1}));t.children=[];t.children_d=[];f&&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,f=0,e=this._model.data,o=!1,u=0,f=t.children.length;u<f;u++)if(e[t.children[u]]&&!e[t.children[u]].state.hidden){o=!0;break}t.state.loaded&&r&&r.length&&(r.removeClass("jstree-closed jstree-open jstree-leaf"),o?r.addClass(t.state.opened?"jstree-open":"jstree-closed"):r.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,r){for(var o=!0,h=function(){this._load_nodes(n,t,!0)},f=this._model.data,s=[],u=0,e=n.length;u<e;u++)!f[n[u]]||(f[n[u]].state.loaded||f[n[u]].state.failed)&&(i||!r)||(this.is_loading(n[u])||this.load_node(n[u],h),o=!1);if(o){for(u=0,e=n.length;u<e;u++)f[n[u]]&&f[n[u]].state.loaded&&s.push(n[u]);t&&!t.done&&(t.call(this,s),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;r<o;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[typeof r=="string"?"_append_html_data":"_append_json_data"](t,typeof r=="string"?n(n.parseHTML(r)).filter(function(){return this.nodeType!==3}):r,function(n){i.call(this,n)})},this)):typeof r=="object"?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&&e.indexOf("json")!==-1||typeof r=="object"?this._append_json_data(t,r,function(n){i.call(this,n)}):e&&e.indexOf("html")!==-1||typeof r=="string"?this._append_html_data(t,n(n.parseHTML(r)).filter(function(){return this.nodeType!==3}),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))):typeof r=="string"?t.id===n.jstree.root?this._append_html_data(t,n(n.parseHTML(r)).filter(function(){return this.nodeType!==3}),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;h<l;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(this.element!==null){t=this.get_node(t);t.children=[];t.children_d=[];i.d&&(i=i.d,typeof i=="string"&&(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||f.icon===null||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&&typeof n.state=="object")for(e in n.state)n.state.hasOwnProperty(e)&&(f.state[e]=n.state[e]);if(n&&typeof n.li_attr=="object")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&&typeof n.a_attr=="object")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;e<a;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:typeof n=="string"?n:"",icon:typeof n=="object"&&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||f.icon===null||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&&typeof n.state=="object")for(e in n.state)n.state.hasOwnProperty(e)&&(f.state[e]=n.state[e]);if(n&&typeof n.li_attr=="object")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&&typeof n.a_attr=="object")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;e<a;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;i<e;i++)u[i].children||(u[i].children=[]),r[u[i].id.toString()]=u[i];for(i=0,e=u.length;i<e;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;i<e;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;i<e;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;i<e;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;i<e;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}}if(typeof window=="undefined"||typeof window.document=="undefined")postMessage(a);else return a},s=function(t,i){var u,f;if(this.element!==null){this._cnt=t.cnt;f=this._model.data;for(u in f)f.hasOwnProperty(u)&&f[u].state&&f[u].state.loading&&t.mod[u]&&(t.mod[u].state.loading=!0);if(this._model.data=t.mod,i){var s,h=t.add,e=t.sel,o=this._data.core.selected.slice();if(f=this._model.data,e.length!==o.length||n.vakata.array_unique(e.concat(o)).length!==e.length){for(u=0,s=e.length;u<s;u++)n.inArray(e[u],h)===-1&&n.inArray(e[u],o)===-1&&(f[e[u]].state.selected=!1);for(u=0,s=o.length;u<s;u++)n.inArray(o[u],e)===-1&&(f[o[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{this._wrk===null&&(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){if(i=n.trim(i),!i.length)return!0;f.li_attr[t]=i;t==="id"&&(f.id=i.toString())}),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||f.icon===null||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||u.icon===null||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&&typeof n.state=="object")for(f in n.state)n.state.hasOwnProperty(f)&&(u.state[f]=n.state[f]);if(n&&typeof n.li_attr=="object")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&&typeof n.a_attr=="object")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;f<l;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:typeof n=="string"?n:"",icon:typeof n=="object"&&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||u.icon===null||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&&typeof n.state=="object")for(f in n.state)n.state.hasOwnProperty(f)&&(u.state[f]=n.state[f]);if(n&&typeof n.li_attr=="object")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&&typeof n.a_attr=="object")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;f<l;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,o=this._data.core.focused,u=0,e=f.length;u<e;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));o!==null&&(t=this.get_node(o,!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;f<e;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,h=!1,y=!1,l="",k=i,a=this._model.data,d=!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||e.children.length===0,t=i.querySelector?this.element[0].querySelector("#"+("0123456789".indexOf(e.id[0])!==-1?"\\3"+e.id[0]+" "+e.id.substr(1).replace(n.jstree.idregex,"\\$&"):e.id.replace(n.jstree.idregex,"\\$&"))):i.getElementById(e.id),t)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,s!==null&&(!s||!a[e.parent].state.opened))return!1;p=n.inArray(e.id,s===null?a[n.jstree.root].children:a[e.parent].children)}t=c.cloneNode(!0);l="jstree-node ";for(o in e.li_attr)if(e.li_attr.hasOwnProperty(o)){if(o==="id")continue;o!=="class"?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,h=e.children.length;o<h;o++)if(!a[e.children[o]].state.hidden){tt=!0;break}if(e.parent!==null&&a[e.parent]&&!e.state.hidden&&(o=n.inArray(e.id,a[e.parent].children),w=e.id,o!==-1))for(o++,h=a[e.parent].children.length;o<h;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(h in e.a_attr)if(e.a_attr.hasOwnProperty(h)){if(h==="href"&&e.a_attr[h]==="#")continue;h!=="class"?t.childNodes[1].setAttribute(h,e.a_attr[h]):l+=" "+e.a_attr[h]}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":e.icon.indexOf("/")===-1&&e.icon.indexOf(".")===-1?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,h=e.children.length;o<h;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,h=s.childNodes.length;o<h;o++)if(s.childNodes[o]&&s.childNodes[o].className&&s.childNodes[o].className.indexOf("jstree-children")!==-1){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;e<o;e++)this.open_node(i[e],r,u);return!0}if(i=this.get_node(i),!i||i.id===n.jstree.root)return!1;if(u=u===t?this.settings.core.animation:u,!this.is_closed(i))return r&&r.call(this,i,!1),!1;if(this.is_loaded(i))return 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;if(this.is_loading(i))return setTimeout(n.proxy(function(){this.open_node(i,r,u)},this),500);this.load_node(i,function(n,t){return t?this.open_node(n,r,u):r?r.call(this,n,!1):!1})},_open_to:function(t){if(t=this.get_node(t),!t||t.id===n.jstree.root)return!1;for(var u=t.parents,i=0,r=u.length;i<r;i+=1)i!==n.jstree.root&&this.open_node(u[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;f<e;f++)this.close_node(i[f],r);return!0}if((i=this.get_node(i),!i||i.id===n.jstree.root)||this.is_closed(i))return!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});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})):this.trigger("after_close",{node:i})},toggle_node:function(t){var i,r;if(n.isArray(t)){for(t=t.slice(),i=0,r=t.length;i<r;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;f<e;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)});r.find(".jstree-closed").length===0&&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;u<f;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;i<r;i++)this.enable_node(t[i]);return!0}if(t=this.get_node(t),!t||t.id===n.jstree.root)return!1;t.state.disabled=!1;this.get_node(t,!0).children(".jstree-anchor").removeClass("jstree-disabled").attr("aria-disabled",!1);this.trigger("enable_node",{node:t})},disable_node:function(t){var i,r;if(n.isArray(t)){for(t=t.slice(),i=0,r=t.length;i<r;i++)this.disable_node(t[i]);return!0}if(t=this.get_node(t),!t||t.id===n.jstree.root)return!1;t.state.disabled=!0;this.get_node(t,!0).children(".jstree-anchor").addClass("jstree-disabled").attr("aria-disabled",!0);this.trigger("disable_node",{node:t})},is_hidden:function(n){return n=this.get_node(n),n.state.hidden===!0},hide_node:function(t,i){var r,u;if(n.isArray(t)){for(t=t.slice(),r=0,u=t.length;r<u;r++)this.hide_node(t[r],!0);return i||this.redraw(),!0}if(t=this.get_node(t),!t||t.id===n.jstree.root)return!1;t.state.hidden||(t.state.hidden=!0,this._node_changed(t.parent),i||this.redraw(),this.trigger("hide_node",{node:t}))},show_node:function(t,i){var r,u;if(n.isArray(t)){for(t=t.slice(),r=0,u=t.length;r<u;r++)this.show_node(t[r],!0);return i||this.redraw(),!0}if(t=this.get_node(t),!t||t.id===n.jstree.root)return!1;t.state.hidden&&(t.state.hidden=!1,this._node_changed(t.parent),i||this.redraw(),this.trigger("show_node",{node:t}))},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&&typeof i=="object"||(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;r<s;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.is_hidden(u[r])||this.select_node(u[r],!0,!1,i):this.deselect_node(u[r],!0,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){if(n=this.get_node(n,!0),!n||!n.length||!n.children(".jstree-hovered").length)return!1;n.children(".jstree-anchor").removeClass("jstree-hovered");this.trigger("dehover_node",{node:this.get_node(n)})},select_node:function(t,i,r,u){var f,e,o;if(n.isArray(t)){for(t=t.slice(),e=0,o=t.length;e<o;e++)this.select_node(t[e],i,r,u);return!0}if(t=this.get_node(t),!t||t.id===n.jstree.root)return!1;f=this.get_node(t,!0);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}))},deselect_node:function(t,i,r){var u,e,f;if(n.isArray(t)){for(t=t.slice(),u=0,e=t.length;u<e;u++)this.deselect_node(t[u],i,r);return!0}if(t=this.get_node(t),!t||t.id===n.jstree.root)return!1;f=this.get_node(t,!0);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}))},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;i<r;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;t<r;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)?!1:t.state.selected},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;i<e;i++)u[r[i].id]=r[i];for(i=0,e=r.length;i<e;i++)for(f=0,o=r[i].children_d.length;f<o;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;i<f;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:[]}};for(var 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 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)&&u!=="core"&&n.inArray(u,this.settings.plugins)===-1&&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(u);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,e=t.id;for(i=i.toString(),u[t.parent].children[n.inArray(t.id,u[t.parent].children)]=i,r=0,f=t.parents.length;r<f;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;r<f;r++)u[t.children[r]].parent=i;for(r=0,f=t.children_d.length;r<f;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),r!==-1&&(this._data.core.selected[r]=i),r=this.get_node(t.id,!0),r&&(r.attr("id",i),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,this.trigger("set_id",{node:t,"new":t.id,old:e}),!0},get_text:function(t){return t=this.get_node(t),!t||t.id===n.jstree.root?!1:t.text},set_text:function(t,i){var r,u;if(n.isArray(t)){for(t=t.slice(),r=0,u=t.length;r<u;r++)this.set_text(t[r],i);return!0}return(t=this.get_node(t),!t||t.id===n.jstree.root)?!1:(t.text=i,this.get_node(t,!0).length&&this.redraw_node(t.id),this.trigger("set_text",{obj:t,text:i}),!0)},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;f<e;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(i===null&&(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")});typeof r=="string"&&(r={text:r});r.text===t&&(r.text=this.get_string("New node"));var o,h,s,c;i.id===n.jstree.root&&(u==="before"&&(u="first"),u==="after"&&(u="last"));switch(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;s<c;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;s<c;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;r<u;r++)this.rename_node(t[r],i);return!0}return(t=this.get_node(t),!t||t.id===n.jstree.root)?!1:(f=t.text,!this.check("rename_node",t,this.get_parent(t),i))?(this.settings.core.error.call(this,this._data.core.last_error),!1):(this.set_text(t,i),this.trigger("rename_node",{node:t,text:i,old:f}),!0)},delete_node:function(t){var e,c,i,o,r,f,l,u,s,h,a,v;if(n.isArray(t)){for(t=t.slice(),e=0,c=t.length;e<c;e++)this.delete_node(t[e]);return!0}if(t=this.get_node(t),!t||t.id===n.jstree.root)return!1;if(i=this.get_node(t.parent),o=n.inArray(t.id,i.children),h=!1,!this.check("delete_node",t,i,o))return this.settings.core.error.call(this,this._data.core.last_error),!1;for(o!==-1&&(i.children=n.vakata.array_remove(i.children,o)),r=t.children_d.concat([]),r.push(t.id),f=0,l=t.parents.length;f<l;f++)this._model.data[t.parents[f]].children_d=n.vakata.array_filter(this._model.data[t.parents[f]].children_d,function(t){return n.inArray(t,r)===-1});for(u=0,s=r.length;u<s;u++)if(this._model.data[r[u]].state.selected){h=!0;break}for(h&&(this._data.core.selected=n.vakata.array_filter(this._data.core.selected,function(t){return n.inArray(t,r)===-1})),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=r.length;u<s;u++)delete this._model.data[r[u]];return n.inArray(this._data.core.focused,r)!==-1&&(this._data.core.focused=null,a=this.element[0].scrollTop,v=this.element[0].scrollLeft,i.id===n.jstree.root?this._model.data[n.jstree.root].children[0]&&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(t==="move_node"||t==="copy_node")&&(!f||!f.is_multi)&&(i.id===r.id||t==="move_node"&&n.inArray(i.id,r.children)===u||n.inArray(r.id,i.children_d)!==-1)?(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):(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},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(i.length===1)i=i[0];else{for(k=0,d=i.length;k<d;k++)(a=this.move_node(i[k],r,u,f,e,!1,s))&&(r=a,u="after");return this.redraw(),!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?r:this.get_node(r.parent),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;r.id===n.jstree.root&&(u==="before"&&(u="first"),u==="after"&&(u="last"));switch(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),a!==-1&&(v=n.vakata.array_remove(v,a),u>a&&u--),a=[],h=0,p=v.length;h<p;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;h<p;h++){for(v=[],w=c._model.data[i.parents[h]].children_d,b=0,tt=w.length;b<tt;b++)n.inArray(w[b],a)===-1&&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;h<p;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;h<p;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;h<p;h++)this._model.data[i.children_d[h]].parents=this._model.data[i.children_d[h]].parents.slice(0,w*-1),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(i.length===1)i=i[0];else{for(w=0,k=i.length;w<k;w++)(a=this.copy_node(i[w],r,u,f,e,!0,s))&&(r=a,u="after");return this.redraw(),!0}if(i=i&&i.id?i:this.get_node(i),!i||i.id===n.jstree.root)return!1;p=(i.parent||n.jstree.root).toString();c=!u.toString().match(/^(before|after)$/)||r.id===n.jstree.root?r:this.get_node(r.parent);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&&(u==="before"&&(u="first"),u==="after"&&(u="last"));switch(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;l<b;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;l<b;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;r<s;r++)i=this.get_node(t[r]),i&&i.id&&i.id!==n.jstree.root&&o.push(i);if(!o.length)return!1;f=o;e=this;u="move_node";this.trigger("cut",{node:t})},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;r<s;r++)i=this.get_node(t[r]),i&&i.id&&i.id!==n.jstree.root&&o.push(i);if(!o.length)return!1;f=o;e=this;u="copy_node";this.trigger("copy",{node:t})},get_buffer:function(){return{mode:u,node:f,inst:e}},can_paste:function(){return u!==!1&&f!==!1},paste:function(n,t){if(n=this.get_node(n),!n||!u||!u.match(/^(copy_node|move_node)$/)||!f)return!1;this[u](f,n,t,!1,!1,!1,e)&&this.trigger("paste",{parent:n.id,node:f,mode:u});f=!1;u=!1;e=!1},clear_buffer:function(){f=!1;u=!1;e=!1;this.trigger("clear_buffer")},edit:function(t,r,u){var v,l,f,h,e,c,o,a,s,y=!1;if(t=this.get_node(t),!t)return!1;if(this.settings.core.check_callback===!1)return 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;s=t;r=typeof r=="string"?r:t.text;this.set_text(t,"");t=this._open_to(t);s.text=r;v=this._data.core.rtl;l=this.element.width();this._data.core.focused=s.id;f=t.children(".jstree-anchor").focus();h=n("<span>");e=r;c=n("<div />",{css:{position:"absolute",top:"-200px",left:v?"0px":"-1000px",visibility:"hidden"}}).appendTo("body");o=n("<input />",{value:e,"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 v=h.children(".jstree-rename-input"),r=v.val(),a=this.settings.core.force_text,l;r===""&&(r=e);c.remove();h.replaceWith(f);h.remove();e=a?e:n("<div><\/div>").append(n.parseHTML(e)).html();this.set_text(t,e);l=!!this.rename_node(t,a?n("<div><\/div>").text(r).text():n("<div><\/div>").append(n.parseHTML(r)).html());l||this.set_text(t,e);this._data.core.focused=s.id;setTimeout(n.proxy(function(){var n=this.get_node(s.id,!0);n.length&&(this._data.core.focused=s.id,n.children(".jstree-anchor").focus())},this),0);u&&u.call(this,s,l,y);o=null},this),keydown:function(n){var t=n.which;t===27&&(y=!0,this.value=e);(t===27||t===13||t===37||t===38||t===39||t===40||t===32)&&n.stopImmediatePropagation();(t===27||t===13)&&(n.preventDefault(),this.blur())},click:function(n){n.stopImmediatePropagation()},mousedown:function(n){n.stopImmediatePropagation()},keyup:function(){o.width(Math.min(c.text("pW"+this.value).width(),l))},keypress:function(n){if(n.which===13)return!1}});a={fontFamily:f.css("fontFamily")||"",fontSize:f.css("fontSize")||"",fontWeight:f.css("fontWeight")||"",fontStyle:f.css("fontStyle")||"",fontStretch:f.css("fontStretch")||"",fontVariant:f.css("fontVariant")||"",letterSpacing:f.css("letterSpacing")||"",wordSpacing:f.css("wordSpacing")||""};h.attr("class",f.attr("class")).append(f.contents().clone()).append(o);f.replaceWith(h);c.css(a);o.css(a).width(Math.min(c.text("pW"+o[0].value).width(),l))[0].select();n(i).one("mousedown.jstree touchstart.jstree dnd_start.vakata",function(t){o&&t.target!==o&&n(o).blur()})},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&&n.inArray(i,w)===-1&&(n("head").append('<link rel="stylesheet" href="'+i+'" type="text/css" />'),w.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;e<o;e++)this.set_icon(i[e],r);return!0}return(i=this.get_node(i),!i||i.id===n.jstree.root)?!1:(u=i.icon,i.icon=r===!0||r===null||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||r===null||r===t||r===""?(f.removeClass("jstree-themeicon-custom "+u).css("background","").removeAttr("rel"),u===!1&&this.show_icon(i)):r.indexOf("/")===-1&&r.indexOf(".")===-1?(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)},get_icon:function(t){return t=this.get_node(t),!t||t.id===n.jstree.root?!1:t.icon},hide_icon:function(t){var i,r;if(n.isArray(t)){for(t=t.slice(),i=0,r=t.length;i<r;i++)this.hide_icon(t[i]);return!0}return(t=this.get_node(t),!t||t===n.jstree.root)?!1:(t.icon=!1,this.get_node(t,!0).children(".jstree-anchor").children(".jstree-themeicon").addClass("jstree-themeicon-hidden"),!0)},show_icon:function(t){var i,u,r;if(n.isArray(t)){for(t=t.slice(),i=0,u=t.length;i<u;i++)this.show_icon(t[i]);return!0}return(t=this.get_node(t),!t||t===n.jstree.root)?!1:(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)}},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){n.inArray(u.name.toLowerCase(),["style","contenteditable","hasfocus","tabindex"])===-1&&u.value!==null&&n.trim(u.value)!==""&&(i?r[u.name]=u.value:r.push(u.name))}),r},n.vakata.array_unique=function(n){for(var r=[],f={},i=0,u=n.length;i<u;i++)f[n[i]]===t&&(r.push(n[i]),f[n[i]]=!0);return r},n.vakata.array_remove=function(n,t){return n.splice(t,1),n},n.vakata.array_remove_item=function(t,i){var r=n.inArray(i,t);return r!==-1?n.vakata.array_remove(t,r):t},n.vakata.array_filter=function(n,t,i,r,u){if(n.filter)return n.filter(t,i);r=[];for(u in n)~~u+""==u+""&&u>=0&&t.call(i,n[u],+u,n)&&r.push(n[u]);return r},n.jstree.plugins.changed=function(n,t){var i=[];this.trigger=function(n,r){var u,f,e;if(r||(r={}),n.replace(".jstree","")==="changed"){for(r.changed={selected:[],deselected:[]},e={},u=0,f=i.length;u<f;u++)e[i[u]]=1;for(u=0,f=r.selected.length;u<f;u++)e[r.selected[u]]?e[r.selected[u]]=2:r.changed.selected.push(r.selected[u]);for(u=0,f=i.length;u<f;u++)e[i[u]]===1&&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)}},l=i.createElement("I"),l.className="jstree-icon jstree-checkbox",l.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));if(this.settings.checkbox.cascade.indexOf("undetermined")!==-1)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));if(!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;i<f;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));if(this.settings.checkbox.cascade.indexOf("up")!==-1||this.settings.checkbox.cascade.indexOf("down")!==-1)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(y.indexOf("down")!==-1)if(u.state[f?"selected":"checked"]){for(r=0,o=s.length;r<o;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;r<o;r++)if(e[s[r]].state[f?"selected":"checked"]){for(h=0,l=e[s[r]].children_d.length;h<l;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(y.indexOf("up")!==-1){for(r=0,o=u.children_d.length;r<o;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;h<l;h++)for(u=e[c[h]];u&&u.id!==n.jstree.root;){for(v=0,r=0,o=u.children.length;r<o;r++)v+=e[u.children[r]].state[f?"selected":"checked"];if(v===o)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");else break;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){for(var s=i.node,v=this._model.data,f=this.get_node(s.parent),y=this.get_node(s,!0),l,u,a=this.settings.checkbox.cascade,o=this.settings.checkbox.tie_selection,h={},c=this._data[o?"core":"checkbox"].selected,r=0,e=c.length;r<e;r++)h[c[r]]=!0;if(a.indexOf("down")!==-1)for(r=0,e=s.children_d.length;r<e;r++)h[s.children_d[r]]=!0,u=v[s.children_d[r]],u.state[o?"selected":"checked"]=!0,u&&u.original&&u.original.state&&u.original.state.undetermined&&(u.original.state.undetermined=!1);if(a.indexOf("up")!==-1)while(f&&f.id!==n.jstree.root){for(l=0,r=0,e=f.children.length;r<e;r++)l+=v[f.children[r]].state[o?"selected":"checked"];if(l===e)f.state[o?"selected":"checked"]=!0,h[f.id]=!0,u=this.get_node(f,!0),u&&u.length&&u.attr("aria-selected",!0).children(".jstree-anchor").addClass(o?"jstree-clicked":"jstree-checked");else break;f=this.get_node(f.parent)}c=[];for(r in h)h.hasOwnProperty(r)&&c.push(r);this._data[o?"core":"checkbox"].selected=c;a.indexOf("down")!==-1&&y.length&&y.find(".jstree-anchor").addClass(o?"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 r=this.get_node(n.jstree.root),f=this._model.data,t,i=0,u=r.children_d.length;i<u;i++)t=f[r.children_d[i]],t&&t.original&&t.original.state&&t.original.state.undetermined&&(t.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,l=this.get_node(f,!0),r,o,u,h=this.settings.checkbox.cascade,s=this.settings.checkbox.tie_selection,e=this._data[s?"core":"checkbox"].selected,c={};if(f&&f.original&&f.original.state&&f.original.state.undetermined&&(f.original.state.undetermined=!1),h.indexOf("down")!==-1)for(r=0,o=f.children_d.length;r<o;r++)u=this._model.data[f.children_d[r]],u.state[s?"selected":"checked"]=!1,u&&u.original&&u.original.state&&u.original.state.undetermined&&(u.original.state.undetermined=!1);if(h.indexOf("up")!==-1)for(r=0,o=f.parents.length;r<o;r++)u=this._model.data[f.parents[r]],u.state[s?"selected":"checked"]=!1,u&&u.original&&u.original.state&&u.original.state.undetermined&&(u.original.state.undetermined=!1),u=this.get_node(f.parents[r],!0),u&&u.length&&u.attr("aria-selected",!1).children(".jstree-anchor").removeClass(s?"jstree-clicked":"jstree-checked");for(c={},r=0,o=e.length;r<o;r++)(h.indexOf("down")===-1||n.inArray(e[r],f.children_d)===-1)&&(h.indexOf("up")===-1||n.inArray(e[r],f.parents)===-1)&&(c[e[r]]=!0);e=[];for(r in c)c.hasOwnProperty(r)&&e.push(r);this._data[s?"core":"checkbox"].selected=e;h.indexOf("down")!==-1&&l.length&&l.find(".jstree-anchor").removeClass(s?"jstree-clicked":"jstree-checked").parent().attr("aria-selected",!1)},this));if(this.settings.checkbox.cascade.indexOf("up")!==-1)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;f<e;f++)s+=h[r.children[f]].state[u?"selected":"checked"];if(e>0&&s===e)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");else break;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;e<o;e++)s+=h[r.children[e]].state[u?"selected":"checked"];if(o>0&&s===o)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 break;r=this.get_node(r.parent)}for(r=a;r&&r.id!==n.jstree.root;){for(s=0,e=0,o=r.children.length;e<o;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"])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");else break;r=this.get_node(r.parent)}},this))};this._undetermined=function(){if(this.element!==null){for(var i,h,f={},e=this._model.data,c=this.settings.checkbox.tie_selection,u=this._data[c?"core":"checkbox"].selected,o=[],l=this,r=0,s=u.length;r<s;r++)if(e[u[r]]&&e[u[r]].parents)for(i=0,h=e[u[r]].parents.length;i<h;i++){if(f[e[u[r]].parents[i]]!==t)break;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,s=u.children_d.length;r<s;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,h=c.parents.length;i<h;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,h=u.parents.length;i<h;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,s=o.length;r<s;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),t){for(var e=null,o=null,f=0,s=t.childNodes.length;f<s;f++)if(t.childNodes[f]&&t.childNodes[f].className&&t.childNodes[f].className.indexOf("jstree-anchor")!==-1){e=t.childNodes[f];break}e&&(!this.settings.checkbox.tie_selection&&this._model.data[t.id].state.checked&&(e.className+=" jstree-checked"),o=l.cloneNode(!1),this._model.data[t.id].state.checkbox_disabled&&(o.className+=" jstree-checkbox-disabled"),e.insertBefore(o,e.childNodes[0]))}return u||this.settings.checkbox.cascade.indexOf("undetermined")===-1||(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||r.indexOf("undetermined")===-1||r.indexOf("down")===-1&&r.indexOf("up")===-1)return!1;if(!t.state.loaded&&t.original.state.undetermined===!0)return!0;for(i=0,u=t.children_d.length;i<u;i++)if(n.inArray(t.children_d[i],o)!==-1||!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;i<u;i++)this.disable_checkbox(t[i]);return!0}if(t=this.get_node(t),!t||t.id===n.jstree.root)return!1;r=this.get_node(t,!0);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}))};this.enable_checkbox=function(t){var i,u,r;if(n.isArray(t)){for(t=t.slice(),i=0,u=t.length;i<u;i++)this.enable_checkbox(t[i]);return!0}if(t=this.get_node(t),!t||t.id===n.jstree.root)return!1;r=this.get_node(t,!0);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}))};this.activate_node=function(t,i){if(n(i.target).hasClass("jstree-checkbox-disabled"))return!1;if(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"))return r.activate_node.call(this,t,i);if(this.is_disabled(t))return!1;this.is_checked(t)?this.uncheck_node(t,i):this.check_node(t,i);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;if(n.isArray(t)){for(t=t.slice(),u=0,f=t.length;u<f;u++)this.check_node(t[u],i);return!0}if(t=this.get_node(t),!t||t.id===n.jstree.root)return!1;r=this.get_node(t,!0);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}))};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;r<f;r++)this.uncheck_node(t[r],i);return!0}if(t=this.get_node(t),!t||t.id===n.jstree.root)return!1;u=this.get_node(t,!0);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}))};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;t<i;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;n<t;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)?!1:t.state.checked};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;i<e;i++)u[r[i].id]=r[i];for(i=0,e=r.length;i<e;i++)for(f=0,o=r[i].children_d.length;f<o;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;i<f;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 u,f,e,i;if(!n.isArray(t)&&!this.settings.checkbox.tie_selection&&(i=this.get_node(t),i&&i.state.loaded))for(u=0,f=i.children_d.length;u<f;u++)this._model.data[i.children_d[u]].state.checked&&(e=!0,this._data.checkbox.selected=n.vakata.array_remove_item(this._data.checkbox.selected,i.children_d[u]));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(n,t){this._data.contextmenu.visible=!1;t.reference.removeClass("jstree-context")},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 o=this.get_node(t,!0),e=o.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);e.addClass("jstree-context")},this));this._data.contextmenu.visible=!0;n.vakata.context.show(e,{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){if(!r)return!0;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+=r.icon.indexOf("/")!==-1||r.icon.indexOf(".")!==-1?" 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>";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)}),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"),e=t.offset().left,f=e+t.outerWidth(),s=t.offset().top,u=i.width(),h=i.height(),o=n(window).width()+n(window).scrollLeft(),c=n(window).height()+n(window).scrollTop();r?t[f-(u+10+t.outerWidth())<0?"addClass":"removeClass"]("vakata-context-left"):t[f+u>o&&e>o-f?"addClass":"removeClass"]("vakata-context-right");s+h+10>c&&i.css("bottom","-1px");t.hasClass("vakata-context-right")?e<u&&i.css("margin-right",e-u):o-f<u&&i.css("margin-left",o-f-u);i.show()}},show:function(i,u,f){var h,o,e,s,c,l,a,v;t.element&&t.element.length&&t.element.width("");switch(!0){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=n("body").css("direction")==="rtl";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,use_html5:!1},n.jstree.plugins.dnd=function(t,r){this.init=function(n,t){r.init.call(this,n,t);this.settings.dnd.use_html5=this.settings.dnd.use_html5&&"draggable"in i.createElement("span")};this.bind=function(){r.bind.call(this);this.element.on(this.settings.dnd.use_html5?"dragstart.jstree":"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||t.type==="touchstart"&&(!this.settings.dnd.touch||this.settings.dnd.touch==="selected"&&!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);if(this.settings.core.force_text&&(u=n.vakata.html.escape(u)),i&&i.id&&i.id!==n.jstree.root&&(t.which===1||t.type==="touchstart"||t.type==="dragstart")&&(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)))if(h={jstree:!0,origin:this,obj:this.get_node(i,!0),nodes:r>1?this.get_top_selected():[i.id]},a=t.currentTarget,this.settings.dnd.use_html5)n.vakata.dnd._trigger("start",t,{helper:n(),element:a,data:h});else return this.element.trigger("mousedown.jstree"),n.vakata.dnd.start(t,h,'<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>')},this));if(this.settings.dnd.use_html5)this.element.on("dragover.jstree",function(t){return t.preventDefault(),n.vakata.dnd._trigger("move",t,{helper:n(),element:a,data:h}),!1}).on("drop.jstree",n.proxy(function(t){return t.preventDefault(),n.vakata.dnd._trigger("stop",t,{helper:n(),element:a,data:h}),!1},this))};this.redraw_node=function(n){if(n=r.redraw_node.apply(this,arguments),n&&this.settings.dnd.use_html5)if(this.settings.dnd.large_drag_target)n.setAttribute("draggable",!0);else{for(var i=null,t=0,u=n.childNodes.length;t<u;t++)if(n.childNodes[t]&&n.childNodes[t].className&&n.childNodes[t].className.indexOf("jstree-anchor")!==-1){i=n.childNodes[t];break}i&&i.setAttribute("draggable",!0)}return n}},n(function(){var r=!1,o=!1,u=!1,f=!1,e=n('<div id="jstree-marker">&#160;<\/div>').hide();n(i).on("dnd_start.vakata.jstree",function(n,t){(r=!1,u=!1,t&&t.data&&t.data.jstree)&&e.appendTo("body")}).on("dnd_move.vakata.jstree",function(i,s){if((f&&(s.event&&s.event.type==="dragover"&&s.event.target===u.target||clearTimeout(f)),s&&s.data&&s.data.jstree)&&(!s.event.target.id||s.event.target.id!=="jstree-marker")){u=s.event;var h=n.jstree.reference(s.event.target),c=!1,v=!1,d=!1,g,nt,y,p,w,tt,a,l,it,ft,rt,et,b,k,ut;if(h&&h._data&&h._data.dnd)if(e.attr("class","jstree-"+h.get_theme()+(h.settings.core.themes.responsive?" jstree-dnd-responsive":"")),ut=s.data.origin&&(s.data.origin.settings.dnd.always_copy||s.data.origin.settings.dnd.copy&&(s.event.metaKey||s.event.ctrlKey)),s.helper.children().attr("class","jstree-"+h.get_theme()+" jstree-"+h.get_theme()+"-"+h.get_theme_variant()+" "+(h.settings.core.themes.responsive?" jstree-dnd-responsive":"")).find(".jstree-copy").first()[ut?"show":"hide"](),(s.event.target===h.element[0]||s.event.target===h.get_container_ul()[0])&&h.get_container_ul().children().length===0){for(a=!0,l=0,it=s.data.nodes.length;l<it;l++)if(a=a&&h.check(s.data.origin&&(s.data.origin.settings.dnd.always_copy||s.data.origin.settings.dnd.copy&&(s.event.metaKey||s.event.ctrlKey))?"copy_node":"move_node",s.data.origin&&s.data.origin!==h?s.data.origin.get_node(s.data.nodes[l]):s.data.nodes[l],n.jstree.root,"last",{dnd:!0,ref:h.get_node(n.jstree.root),pos:"i",origin:s.data.origin,is_multi:s.data.origin&&s.data.origin!==h,is_foreign:!s.data.origin}),!a)break;if(a){r={ins:h,par:n.jstree.root,pos:"last"};e.hide();s.helper.find(".jstree-icon").first().removeClass("jstree-er").addClass("jstree-ok");s.event.originalEvent&&s.event.originalEvent.dataTransfer&&(s.event.originalEvent.dataTransfer.dropEffect=ut?"copy":"move");return}}else if(c=h.settings.dnd.large_drop_target?n(s.event.target).closest(".jstree-node").children(".jstree-anchor"):n(s.event.target).closest(".jstree-anchor"),c&&c.length&&c.parent().is(".jstree-closed, .jstree-open, .jstree-leaf")&&(v=c.offset(),d=(s.event.pageY!==t?s.event.pageY:s.event.originalEvent.pageY)-v.top,y=c.outerHeight(),tt=d<y/3?["b","i","a"]:d>y-y/3?["a","i","b"]:d>y/2?["i","a","b"]:["i","b","a"],n.each(tt,function(t,i){switch(i){case"b":g=v.left-6;nt=v.top;p=h.get_parent(c);w=c.parent().index();break;case"i":b=h.settings.dnd.inside_pos;k=h.get_node(c.parent());g=v.left-2;nt=v.top+y/2+1;p=k.id;w=b==="first"?0:b==="last"?k.children.length:Math.min(b,k.children.length);break;case"a":g=v.left-6;nt=v.top+y;p=h.get_parent(c);w=c.parent().index()+1}for(a=!0,l=0,it=s.data.nodes.length;l<it;l++)if(ft=s.data.origin&&(s.data.origin.settings.dnd.always_copy||s.data.origin.settings.dnd.copy&&(s.event.metaKey||s.event.ctrlKey))?"copy_node":"move_node",rt=w,ft==="move_node"&&i==="a"&&s.data.origin&&s.data.origin===h&&p===h.get_parent(s.data.nodes[l])&&(et=h.get_node(p),rt>n.inArray(s.data.nodes[l],et.children)&&(rt-=1)),a=a&&(h&&h.settings&&h.settings.dnd&&h.settings.dnd.check_while_dragging===!1||h.check(ft,s.data.origin&&s.data.origin!==h?s.data.origin.get_node(s.data.nodes[l]):s.data.nodes[l],p,rt,{dnd:!0,ref:h.get_node(c.parent()),pos:i,origin:s.data.origin,is_multi:s.data.origin&&s.data.origin!==h,is_foreign:!s.data.origin})),!a){h&&h.last_error&&(o=h.last_error());break}return i==="i"&&c.parent().is(".jstree-closed")&&h.settings.dnd.open_timeout&&(f=setTimeout(function(n,t){return function(){n.open_node(t)}}(h,c),h.settings.dnd.open_timeout)),a?(r={ins:h,par:p,pos:i==="i"&&b==="last"&&w===0&&!h.is_loaded(k)?"last":w},e.css({left:g+"px",top:nt+"px"}).show(),s.helper.find(".jstree-icon").first().removeClass("jstree-er").addClass("jstree-ok"),s.event.originalEvent&&s.event.originalEvent.dataTransfer&&(s.event.originalEvent.dataTransfer.dropEffect=ut?"copy":"move"),o={},tt=!0,!1):void 0}),tt===!0))return;r=!1;s.helper.find(".jstree-icon").removeClass("jstree-ok").addClass("jstree-er");s.event.originalEvent&&s.event.originalEvent.dataTransfer&&(s.event.originalEvent.dataTransfer.dropEffect="none");e.hide()}}).on("dnd_scroll.vakata.jstree",function(n,t){t&&t.data&&t.data.jstree&&(e.hide(),r=!1,u=!1,t.helper.find(".jstree-icon").first().removeClass("jstree-ok").addClass("jstree-er"))}).on("dnd_stop.vakata.jstree",function(t,i){if(f&&clearTimeout(f),i&&i.data&&i.data.jstree){e.hide().detach();var s,h,c=[];if(r){for(s=0,h=i.data.nodes.length;s<h;s++)c[s]=i.data.origin?i.data.origin.get_node(i.data.nodes[s]):i.data.nodes[s];r.ins[i.data.origin&&(i.data.origin.settings.dnd.always_copy||i.data.origin.settings.dnd.copy&&(i.event.metaKey||i.event.ctrlKey))?"copy_node":"move_node"](c,r.par,r.pos,!1,!1,!1,i.data.origin)}else s=n(i.event.target).closest(".jstree"),s.length&&o&&o.error&&o.error==="check"&&(s=s.jstree(!0),s&&s.settings.core.error.call(this,o));u=!1;r=!1}}).on("keyup.jstree keydown.jstree",function(t,i){i=n.vakata.dnd._get();i&&i.data&&i.data.jstree&&(t.type==="keyup"&&t.which===27?(f&&clearTimeout(f),r=!1,o=!1,u=!1,f=!1,e.hide().detach(),n.vakata.dnd._clean()):(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"](),u&&(u.metaKey=t.metaKey,u.ctrlKey=t.ctrlKey,n.vakata.dnd._trigger("move",u))))})}),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 r={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(r,u,f){f===t&&(f=n.vakata.dnd._get());f.event=u;n(i).triggerHandler("dnd_"+r+".vakata",f)},_get:function(){return{data:r.data,element:r.element,helper:r.helper}},_clean:function(){r.helper&&r.helper.remove();r.scroll_i&&(clearInterval(r.scroll_i),r.scroll_i=!1);r={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(t){if(!r.scroll_e||!r.scroll_l&&!r.scroll_t)return r.scroll_i&&(clearInterval(r.scroll_i),r.scroll_i=!1),!1;if(!r.scroll_i)return r.scroll_i=setInterval(n.vakata.dnd._scroll,100),!1;if(t===!0)return!1;var i=r.scroll_e.scrollTop(),u=r.scroll_e.scrollLeft();r.scroll_e.scrollTop(i+r.scroll_t*n.vakata.dnd.settings.scroll_speed);r.scroll_e.scrollLeft(u+r.scroll_l*n.vakata.dnd.settings.scroll_speed);(i!==r.scroll_e.scrollTop()||u!==r.scroll_e.scrollLeft())&&n.vakata.dnd._trigger("scroll",r.scroll_e)},start:function(t,u,f){t.type==="touchstart"&&t.originalEvent&&t.originalEvent.changedTouches&&t.originalEvent.changedTouches[0]&&(t.pageX=t.originalEvent.changedTouches[0].pageX,t.pageY=t.originalEvent.changedTouches[0].pageY,t.target=i.elementFromPoint(t.originalEvent.changedTouches[0].pageX-window.pageXOffset,t.originalEvent.changedTouches[0].pageY-window.pageYOffset));r.is_drag&&n.vakata.dnd.stop({});try{t.currentTarget.unselectable="on";t.currentTarget.onselectstart=function(){return!1};t.currentTarget.style&&(t.currentTarget.style.touchAction="none",t.currentTarget.style.msTouchAction="none",t.currentTarget.style.MozUserSelect="none")}catch(e){}r.init_x=t.pageX;r.init_y=t.pageY;r.data=u;r.is_down=!0;r.element=t.currentTarget;r.target=t.target;r.is_touch=t.type==="touchstart";f!==!1&&(r.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);return!1},drag:function(t){if(t.type==="touchmove"&&t.originalEvent&&t.originalEvent.changedTouches&&t.originalEvent.changedTouches[0]&&(t.pageX=t.originalEvent.changedTouches[0].pageX,t.pageY=t.originalEvent.changedTouches[0].pageY,t.target=i.elementFromPoint(t.originalEvent.changedTouches[0].pageX-window.pageXOffset,t.originalEvent.changedTouches[0].pageY-window.pageYOffset)),r.is_down){if(!r.is_drag)if(Math.abs(t.pageX-r.init_x)>(r.is_touch?n.vakata.dnd.settings.threshold_touch:n.vakata.dnd.settings.threshold)||Math.abs(t.pageY-r.init_y)>(r.is_touch?n.vakata.dnd.settings.threshold_touch:n.vakata.dnd.settings.threshold))r.helper&&(r.helper.appendTo("body"),r.helper_w=r.helper.outerWidth()),r.is_drag=!0,n.vakata.dnd._trigger("start",t);else return;var u=!1,l=!1,f=!1,o=!1,e=!1,s=!1,a=!1,v=!1,h=!1,c=!1;return r.scroll_t=0,r.scroll_l=0,r.scroll_e=!1,n(n(t.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()-t.pageY<n.vakata.dnd.settings.scroll_proximity&&(r.scroll_t=1),t.pageY-i.top<n.vakata.dnd.settings.scroll_proximity&&(r.scroll_t=-1)),this.scrollWidth>this.offsetWidth&&(i.left+u.width()-t.pageX<n.vakata.dnd.settings.scroll_proximity&&(r.scroll_l=1),t.pageX-i.left<n.vakata.dnd.settings.scroll_proximity&&(r.scroll_l=-1)),r.scroll_t||r.scroll_l?(r.scroll_e=n(this),!1):void 0}),r.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&&t.pageY-a<n.vakata.dnd.settings.scroll_proximity&&(r.scroll_t=-1),f>o&&o-(t.pageY-a)<n.vakata.dnd.settings.scroll_proximity&&(r.scroll_t=1),e>s&&t.pageX-v<n.vakata.dnd.settings.scroll_proximity&&(r.scroll_l=-1),e>s&&s-(t.pageX-v)<n.vakata.dnd.settings.scroll_proximity&&(r.scroll_l=1),(r.scroll_t||r.scroll_l)&&(r.scroll_e=u)),r.scroll_e&&n.vakata.dnd._scroll(!0),r.helper&&(h=parseInt(t.pageY+n.vakata.dnd.settings.helper_top,10),c=parseInt(t.pageX+n.vakata.dnd.settings.helper_left,10),f&&h+25>f&&(h=f-50),e&&c+r.helper_w>e&&(c=e-(r.helper_w+2)),r.helper.css({left:c+"px",top:h+"px"})),n.vakata.dnd._trigger("move",t),!1}},stop:function(t){if(t.type==="touchend"&&t.originalEvent&&t.originalEvent.changedTouches&&t.originalEvent.changedTouches[0]&&(t.pageX=t.originalEvent.changedTouches[0].pageX,t.pageY=t.originalEvent.changedTouches[0].pageY,t.target=i.elementFromPoint(t.originalEvent.changedTouches[0].pageX-window.pageXOffset,t.originalEvent.changedTouches[0].pageY-window.pageYOffset)),r.is_drag)n.vakata.dnd._trigger("stop",t);else if(t.type==="touchend"&&t.target===r.target){var u=setTimeout(function(){n(t.target).click()},100);n(t.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){this._data.massload={};i.init.call(this,n,t)};this._load_nodes=function(t,r,u,f){var e=this.settings.massload,a=JSON.stringify(t),h=[],c=this._model.data,s,l,o;if(!u){for(s=0,l=t.length;s<l;s++)c[t[s]]&&(c[t[s]].state.loaded||c[t[s]].state.failed)&&!f||(h.push(t[s]),o=this.get_node(t[s],!0),o&&o.length&&o.addClass("jstree-loading").attr("aria-busy",!0));if(this._data.massload={},h.length){if(n.isFunction(e))return e.call(this,h,n.proxy(function(n){var e,s;if(n)for(e in n)n.hasOwnProperty(e)&&(this._data.massload[e]=n[e]);for(e=0,s=t.length;e<s;e++)o=this.get_node(t[e],!0),o&&o.length&&o.removeClass("jstree-loading").attr("aria-busy",!1);i._load_nodes.call(this,t,r,u,f)},this));if(typeof e=="object"&&e&&e.url)return e=n.extend(!0,{},e),n.isFunction(e.url)&&(e.url=e.url.call(this,h)),n.isFunction(e.data)&&(e.data=e.data.call(this,h)),n.ajax(e).done(n.proxy(function(n){var e,s;if(n)for(e in n)n.hasOwnProperty(e)&&(this._data.massload[e]=n[e]);for(e=0,s=t.length;e<s;e++)o=this.get_node(t[e],!0),o&&o.length&&o.removeClass("jstree-loading").attr("aria-busy",!1);i._load_nodes.call(this,t,r,u,f)},this)).fail(n.proxy(function(){i._load_nodes.call(this,t,r,u,f)},this))}}return i._load_nodes.call(this,t,r,u,f)};this._load_node=function(t,r){var u=this._data.massload[t.id],e=null,f;return u?(e=this[typeof u=="string"?"_append_html_data":"_append_json_data"](t,typeof u=="string"?n(n.parseHTML(u)).filter(function(){return this.nodeType!==3}):u,function(n){r.call(this,n)}),f=this.get_node(t.id,!0),f&&f.length&&f.removeClass("jstree-loading").attr("aria-busy",!1),delete this._data.massload[t.id],e):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,u=[],r=0,e=i.res.length;r<e;r++)f[i.res[r]]&&!f[i.res[r]].state.hidden&&(u.push(i.res[r]),u=u.concat(f[i.res[r]].parents),this._data.search.smc&&(u=u.concat(f[i.res[r]].children_d)));u=n.vakata.array_remove_item(n.vakata.array_unique(u),n.jstree.root);this._data.search.hdn=this.hide_all(!0);this.show_node(u,!0);this.redraw(!0)}},this)).on("clear_search.jstree",n.proxy(function(n,t){this._data.search.som&&t.res.length&&(this.show_node(this._data.search.hdn,!0),this.redraw(!0))},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)})},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)})},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&&r.children.length===0)&&(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;l<p;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"0123456789".indexOf(t[0])!==-1?"\\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"0123456789".indexOf(t[0])!==-1?"\\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"0123456789".indexOf(t[0])!==-1?"\\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&&n.inArray(t.id,this._data.search.res)!==-1){for(var u=null,i=0,f=t.childNodes.length;i<f;i++)if(t.childNodes[i]&&t.childNodes[i].className&&t.childNodes[i].className.indexOf("jstree-anchor")!==-1){u=t.childNodes[i];break}u&&(u.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;n<u;n++)i[t.charAt(n)]=0;for(n=0;n<u;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||n.indexOf(t)!==-1)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(o!==-1&&(v=Math.min(e(0,o),v),o=n.lastIndexOf(t,f+u),o!==-1&&(v=Math.min(e(0,o),v))),o=-1,a=0;a<u;a++){for(p=0,s=w;p<s;)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]=a===0?(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),d<=v))if(v=d,o=i-1,it.push(o),o>f)g=Math.max(1,2*f-o);else break;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;r<u;r++)this.sort(t.children_d[r],!1)}},v=!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(){v&&clearTimeout(v);v=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}if(!!t&&t.ttl&&t.sec&&+new Date-t.sec>t.ttl)return!1;if(!!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)})});return this.set_state(t),!0}return!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(f!=="default"&&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",h,u=0,c=e.length;u<c;u++){if(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),s[o].li_attr!==t&&typeof s[o].li_attr=="object")for(h in s[o].li_attr)if(s[o].li_attr.hasOwnProperty(h))if(h==="id")continue;else f[e[u]].li_attr[h]===t?f[e[u]].li_attr[h]=s[o].li_attr[h]:h==="class"&&(f[e[u]].li_attr["class"]=s[o].li_attr["class"]+" "+f[e[u]].li_attr["class"]);if(s[o].a_attr!==t&&typeof s[o].a_attr=="object")for(h in s[o].a_attr)if(s[o].a_attr.hasOwnProperty(h))if(h==="id")continue;else f[e[u]].a_attr[h]===t?f[e[u]].a_attr[h]=s[o].a_attr[h]:h==="href"&&f[e[u]].a_attr[h]==="#"?f[e[u]].a_attr.href=s[o].a_attr.href:h==="class"&&(f[e[u]].a_attr["class"]=s[o].a_attr["class"]+" "+f[e[u]].a_attr["class"])}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;e<s;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;i<r;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;c=c&&c._model&&c._model.data?c._model.data:null;switch(i){case"create_node":case"move_node":case"copy_node":if(i!=="move_node"||n.inArray(u.id,f.children)===-1){if(s=this.get_rules(f),s.max_children!==t&&s.max_children!==-1&&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&&s.valid_children!==-1&&n.inArray(u.type||"default",s.valid_children)===-1)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;l<a;l++)h=Math.max(h,c[u.children_d[l]].parents.length);h=h-u.parents.length+1}(h<=0||h===t)&&(h=1);do{if(s.max_depth!==t&&s.max_depth!==-1&&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 e=this._model.data,f,c,a,o,l,u,h,s;if(n.isArray(i)){for(i=i.slice(),c=0,a=i.length;c<a;c++)this.set_type(i[c],r);return!0}if(f=this.settings.types,i=this.get_node(i),!f[r]||!i)return!1;if(h=this.get_node(i,!0),h&&h.length&&(s=h.children(".jstree-anchor")),o=i.type,l=this.get_icon(i),i.type=r,(l===!0||f[o]&&f[o].icon!==t&&l===f[o].icon)&&this.set_icon(i,f[r].icon!==t?f[r].icon:!0),f[o].li_attr!==t&&typeof f[o].li_attr=="object")for(u in f[o].li_attr)if(f[o].li_attr.hasOwnProperty(u))if(u==="id")continue;else u==="class"?(e[i.id].li_attr["class"]=(e[i.id].li_attr["class"]||"").replace(f[o].li_attr[u],""),h&&h.removeClass(f[o].li_attr[u])):e[i.id].li_attr[u]===f[o].li_attr[u]&&(e[i.id].li_attr[u]=null,h&&h.removeAttr(u));if(f[o].a_attr!==t&&typeof f[o].a_attr=="object")for(u in f[o].a_attr)if(f[o].a_attr.hasOwnProperty(u))if(u==="id")continue;else u==="class"?(e[i.id].a_attr["class"]=(e[i.id].a_attr["class"]||"").replace(f[o].a_attr[u],""),s&&s.removeClass(f[o].a_attr[u])):e[i.id].a_attr[u]===f[o].a_attr[u]&&(u==="href"?(e[i.id].a_attr[u]="#",s&&s.attr("href","#")):(delete e[i.id].a_attr[u],s&&s.removeAttr(u)));if(f[r].li_attr!==t&&typeof f[r].li_attr=="object")for(u in f[r].li_attr)if(f[r].li_attr.hasOwnProperty(u))if(u==="id")continue;else e[i.id].li_attr[u]===t?(e[i.id].li_attr[u]=f[r].li_attr[u],h&&(u==="class"?h.addClass(f[r].li_attr[u]):h.attr(u,f[r].li_attr[u]))):u==="class"&&(e[i.id].li_attr["class"]=f[r].li_attr[u]+" "+e[i.id].li_attr["class"],h&&h.addClass(f[r].li_attr[u]));if(f[r].a_attr!==t&&typeof f[r].a_attr=="object")for(u in f[r].a_attr)if(f[r].a_attr.hasOwnProperty(u))if(u==="id")continue;else e[i.id].a_attr[u]===t?(e[i.id].a_attr[u]=f[r].a_attr[u],s&&(u==="class"?s.addClass(f[r].a_attr[u]):s.attr(u,f[r].a_attr[u]))):u==="href"&&e[i.id].a_attr[u]==="#"?(e[i.id].a_attr.href=f[r].a_attr.href,s&&s.attr("href",f[r].a_attr.href)):u==="class"&&(e[i.id].a_attr["class"]=f[r].a_attr["class"]+" "+e[i.id].a_attr["class"],s&&s.addClass(f[r].a_attr[u]));return!0}},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=t==="rename_node"?f:i.text,h=[],c=this.settings.unique.case_sensitive,l=this._model.data,o=0,a=u.children.length;o<a;o++)h.push(c?l[u.children[o]].text:l[u.children[o]].text.toLowerCase());c||(s=s.toLowerCase());switch(t){case"delete_node":return!0;case"rename_node":return o=n.inArray(s,h)===-1||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=n.inArray(s,h)===-1,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=n.inArray(s,h)===-1,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)||n.inArray(s,h)===-1,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((i===null&&(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;s<a;s++)c.push(y?v[i.children[s]].text:v[i.children[s]].text.toLowerCase());for(s=1;n.inArray(y?h:h.toLowerCase(),c)!==-1;)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;r<u;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){n.type==="hover_node"&&this.is_disabled(t.node)||this.get_node(t.node,!0).children(".jstree-wholerow")[n.type==="hover_node"?"addClass":"removeClass"]("jstree-wholerow-hovered")},this)).on("contextmenu.jstree",".jstree-wholerow",n.proxy(function(t){if(this._data.contextmenu){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),t){var r=o.cloneNode(!0);n.inArray(t.id,this._data.core.selected)!==-1&&(r.className+=" jstree-wholerow-clicked");this._data.core.focused&&this._data.core.focused===t.id&&(r.className+=" jstree-wholerow-hovered");t.insertBefore(r,t.childNodes[0])}return t}},i.registerElement&&Object&&Object.create){p=Object.create(HTMLElement.prototype);p.createdCallback=function(){var i={core:{},plugins:[]};for(var 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:p})}catch(k){}}}})