text: /**
   * skylark-jstree - A version of jstree that ported to running on skylarkjs ui.
   * @author Hudaokeji, Inc.
   * @version v0.9.0
   * @link https://github.com/skylarkui/skylark-jstree/
   * @license MIT
   */
  define(["skylark-langx/langx","skylark-utils-dom/browser","skylark-utils-dom/eventer","skylark-utils-dom/noder","skylark-utils-dom/geom","skylark-utils-dom/query","../tree"],function(e,a,s,t,r,h,i){"use strict";if(!h.jstree.plugins.search)return h.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},h.jstree.plugins.search=function(e,a){this.bind=function(){a.bind.call(this),this._data.search.str="",this._data.search.dom=h(),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",h.proxy(function(e,a){if(this._data.search.som&&a.res.length){var s,t,r,i,c=this._model.data,n=[];for(s=0,t=a.res.length;s<t;s++)if(c[a.res[s]]&&!c[a.res[s]].state.hidden&&(n.push(a.res[s]),n=n.concat(c[a.res[s]].parents),this._data.search.smc))for(r=0,i=c[a.res[s]].children_d.length;r<i;r++)c[c[a.res[s]].children_d[r]]&&!c[c[a.res[s]].children_d[r]].state.hidden&&n.push(c[a.res[s]].children_d[r]);n=h.vakata.array_remove_item(h.vakata.array_unique(n),h.jstree.root),this._data.search.hdn=this.hide_all(!0),this.show_node(n,!0),this.redraw(!0)}},this)).on("clear_search.jstree",h.proxy(function(e,a){this._data.search.som&&a.res.length&&(this.show_node(this._data.search.hdn,!0),this.redraw(!0))},this))},this.search=function(e,a,s,t,r,i){if(e===!1||""===h.trim(e.toString()))return this.clear_search();t=this.get_node(t),t=t&&t.id?t.id:null,e=e.toString();var c,n,d=this.settings.search,o=!!d.ajax&&d.ajax,l=this._model.data,_=null,u=[],f=[];if(this._data.search.res.length&&!r&&this.clear_search(),void 0===s&&(s=d.show_only_matches),void 0===i&&(i=d.show_only_matches_children),!a&&o!==!1)return h.isFunction(o)?o.call(this,e,h.proxy(function(a){a&&a.d&&(a=a.d),this._load_nodes(h.isArray(a)?h.vakata.array_unique(a):[],function(){this.search(e,!0,s,t,r,i)})},this),t):(o=h.extend({},o),o.data||(o.data={}),o.data.str=e,t&&(o.data.inside=t),this._data.search.lastRequest&&this._data.search.lastRequest.abort(),this._data.search.lastRequest=h.ajax(o).fail(h.proxy(function(){this._data.core.last_error={error:"ajax",plugin:"search",id:"search_01",reason:"Could not load search parents",data:JSON.stringify(o)},this.settings.core.error.call(this,this._data.core.last_error)},this)).done(h.proxy(function(a){a&&a.d&&(a=a.d),this._load_nodes(h.isArray(a)?h.vakata.array_unique(a):[],function(){this.search(e,!0,s,t,r,i)})},this)),this._data.search.lastRequest);if(r||(this._data.search.str=e,this._data.search.dom=h(),this._data.search.res=[],this._data.search.opn=[],this._data.search.som=s,this._data.search.smc=i),_=new h.vakata.search(e,(!0),{caseSensitive:d.case_sensitive,fuzzy:d.fuzzy}),h.each(l[t?t:h.jstree.root].children_d,function(a,s){var t=l[s];t.text&&!t.state.hidden&&(!d.search_leaves_only||t.state.loaded&&0===t.children.length)&&(d.search_callback&&d.search_callback.call(this,e,t)||!d.search_callback&&_.search(t.text).isMatch)&&(u.push(s),f=f.concat(t.parents))}),u.length){for(f=h.vakata.array_unique(f),c=0,n=f.length;c<n;c++)f[c]!==h.jstree.root&&l[f[c]]&&this.open_node(f[c],null,0)===!0&&this._data.search.opn.push(f[c]);r?(this._data.search.dom=this._data.search.dom.add(h(this.element[0].querySelectorAll("#"+h.map(u,function(e){return"0123456789".indexOf(e[0])!==-1?"\\3"+e[0]+" "+e.substr(1).replace(h.jstree.idregex,"\\$&"):e.replace(h.jstree.idregex,"\\$&")}).join(", #")))),this._data.search.res=h.vakata.array_unique(this._data.search.res.concat(u))):(this._data.search.dom=h(this.element[0].querySelectorAll("#"+h.map(u,function(e){return"0123456789".indexOf(e[0])!==-1?"\\3"+e[0]+" "+e.substr(1).replace(h.jstree.idregex,"\\$&"):e.replace(h.jstree.idregex,"\\$&")}).join(", #"))),this._data.search.res=u),this._data.search.dom.children(".jstree-anchor").addClass("jstree-search")}this.trigger("search",{nodes:this._data.search.dom,str:e,res:this._data.search.res,show_only_matches:s})},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=h(this.element[0].querySelectorAll("#"+h.map(this._data.search.res,function(e){return"0123456789".indexOf(e[0])!==-1?"\\3"+e[0]+" "+e.substr(1).replace(h.jstree.idregex,"\\$&"):e.replace(h.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=h()},this.redraw_node=function(e,s,t,r){if(e=a.redraw_node.apply(this,arguments),e&&h.inArray(e.id,this._data.search.res)!==-1){var i,c,n=null;for(i=0,c=e.childNodes.length;i<c;i++)if(e.childNodes[i]&&e.childNodes[i].className&&e.childNodes[i].className.indexOf("jstree-anchor")!==-1){n=e.childNodes[i];break}n&&(n.className+=" jstree-search")}return e}},function(e){e.vakata.search=function(a,s,t){t=t||{},t=e.extend({},e.vakata.search.defaults,t),t.fuzzy!==!1&&(t.fuzzy=!0),a=t.caseSensitive?a:a.toLowerCase();var r,h,i,c,n=t.location,d=t.distance,o=t.threshold,l=a.length;return l>32&&(t.fuzzy=!1),t.fuzzy&&(r=1<<l-1,h=function(){var e={},s=0;for(s=0;s<l;s++)e[a.charAt(s)]=0;for(s=0;s<l;s++)e[a.charAt(s)]|=1<<l-s-1;return e}(),i=function(e,a){var s=e/l,t=Math.abs(n-a);return d?s+t/d:t?1:s}),c=function(e){if(e=t.caseSensitive?e:e.toLowerCase(),a===e||e.indexOf(a)!==-1)return{isMatch:!0,score:0};if(!t.fuzzy)return{isMatch:!1,score:1};var s,c,d,_,u,f,m,y,g,p=e.length,v=o,x=e.indexOf(a,n),k=l+p,j=1,z=[];for(x!==-1&&(v=Math.min(i(0,x),v),x=e.lastIndexOf(a,n+l),x!==-1&&(v=Math.min(i(0,x),v))),x=-1,s=0;s<l;s++){for(d=0,_=k;d<_;)i(s,n+_)<=v?d=_:k=_,_=Math.floor((k-d)/2+d);for(k=_,f=Math.max(1,n-_+1),m=Math.min(n+_,p)+l,y=new Array(m+2),y[m+1]=(1<<s)-1,c=m;c>=f;c--)if(g=h[e.charAt(c-1)],0===s?y[c]=(y[c+1]<<1|1)&g:y[c]=(y[c+1]<<1|1)&g|((u[c+1]|u[c])<<1|1)|u[c+1],y[c]&r&&(j=i(s,c-1),j<=v)){if(v=j,x=c-1,z.push(x),!(x>n))break;f=Math.max(1,2*n-x)}if(i(s+1,n)>v)break;u=y}return{isMatch:x>=0,score:j}},s===!0?{search:c}:c(s)},e.vakata.search.defaults={location:0,distance:100,threshold:.6,fuzzy:!1,caseSensitive:!1}}(h),h});
  //# sourceMappingURL=../sourcemaps/plugin/search.js.map
  