require.config({paths:{selectize:"../../../webjars/selectize.js/0.12.5/js/standalone/selectize.min"},shim:{selectize:["jquery"]}});define("xwiki-selectize",["jquery","selectize","xwiki-events-bridge"],function(e){var i=['<div class="xwiki-selectize-option" data-value="">','<span class="xwiki-selectize-option-icon" />','<span class="xwiki-selectize-option-label" />',"</div>"].join("");var f=function(p){var k=e(i);var q=(p&&typeof p==="object")?p.value:p;k.attr("data-value",q);var o=p&&p.icon;if(typeof o==="object"){if(!o.iconSetType&&o.url){o.iconSetType="IMAGE"}else{if(!o.iconSetType&&o.cssClass){o.iconSetType="FONT"}}if(o.iconSetType==="IMAGE"){var r=e('<img class="xwiki-selectize-option-icon" alt="" />').attr("src",o.url);k.find(".xwiki-selectize-option-icon").replaceWith(r)}else{if(o.iconSetType==="FONT"){k.find(".xwiki-selectize-option-icon").addClass(o.cssClass)}else{k.find(".xwiki-selectize-option-icon").remove()}}}else{k.find(".xwiki-selectize-option-icon").remove()}var n=p&&p.url;if(typeof n==="string"){var m=e('<a class="xwiki-selectize-option-label" />').attr("href",n);k.find(".xwiki-selectize-option-label").replaceWith(m)}var l=(p&&typeof p==="object")?(p.label||p.value):p;k.find(".xwiki-selectize-option-label").text(l);return k};var b=function(l){var k=f(l);k.addClass("option");k.find(".xwiki-selectize-option-icon").wrap('<span class="xwiki-selectize-option-icon-wrapper"/>');var m=l&&l.hint;if(typeof m==="string"&&m!==""){k.append(e('<div class="xwiki-selectize-option-hint"/>').text(m))}return k};var d=function(l){var k=f(l);var m=l&&l.hint;if(typeof m==="string"&&m!==""){k.attr("title",m)}return k};var g={copyClassesToDropdown:false,dropdownParent:"body",highlight:false,labelField:"label",loadThrottle:500,onDropdownClose:function(k){k.removeClass("active")},onDropdownOpen:function(k){k.addClass("active")},persist:false,preload:"focus",render:{item:d,option:b,option_create:function(l,m){var n="Select {0} ...";var k=e('<div class="create option"/>').html(m(n).replace("{0}","<em/>"));k.find("em").text(l.input);return k}},searchField:["value","label"],onType:function(k){if(!this.loadedSearches.hasOwnProperty(k)){var l=this.$wrapper;l.addClass(this.settings.loadingClass)}},onInitialize:function(){var k=this.$control;k.on("click","a.xwiki-selectize-option-label",function(l){l.preventDefault()})}};var c=function(){var k=e(this).val();if(!e.isArray(k)){k=[k]}var l=this.selectize;var m=l.$wrapper;m.addClass(l.settings.loadingClass);l.loading++;k.reduce(function(n,o){return n.then(function(){return j(l,o)})},e.Deferred().resolve()).always(function(){l.loading=Math.max(l.loading-1,0);if(!l.loading){m.removeClass(l.settings.loadingClass)}})};var j=function(l,n){var k=e.Deferred();var m;if(typeof l.settings.loadSelected==="function"){m=l.settings.loadSelected}else{m=l.settings.load}if(n&&typeof m==="function"){m(n,function(o){e.isArray(o)&&o.forEach(function(p){var q=p[l.settings.valueField];if(l.options.hasOwnProperty(q)){l.updateOption(q,p)}else{l.addOption(p)}});k.resolve()})}else{k.resolve()}return k.promise()};var h=function(){if(a(this)==="auto"){var k=this.selectize.positionDropdown;this.selectize.positionDropdown=function(){k.call(this);var l=this.$dropdown;l.css({width:"","min-width":l.css("width")})}}};var a=function(k){if(k.selectize.settings.hasOwnProperty("dropdownWidth")){return this.selectize.settings.dropdownWidth}else{if(e(k).closest(".xform").length===0){return"auto"}}};e.fn.xwikiSelectize=function(k){return this.not(".selectized, .selectize-control").selectize(e.extend({},g,k)).each(c).each(h).on("change",function(l){var m=e(this).closest(".xwiki-livetable-display-header-filter").closest(".xwiki-livetable").attr("id");m&&e(document).trigger("xwiki:livetable:"+m+":filtersChanged")})}});