dispatch.to("Foundry/2.1 Core Plugins").at(function($){$.IE=function(){for(var undef,v=3,div=document.createElement("div"),all=div.getElementsByTagName("i");v++,div.innerHTML="<!--[if gt IE "+v+"]><i></i><![endif]-->",all[0];);return v>4?v:undef}(),$.uid=function(p,s){return(p?p:"")+Math.random().toString().replace(".","")+(s?s:"")},$.isDeferred=function(obj){return obj&&$.isFunction(obj.always)},$.distinct=function(items){var uniqueElements=$.unique;if(!(items.length<1)){if(items[0].nodeType)return uniqueElements.apply(this,arguments);
if("object"==typeof items[0]){var unique=Math.random(),uniqueObjects=[];return $.each(items,function(i){items[i][unique]||(uniqueObjects.push(items[i]),items[i][unique]=!0)}),$.each(uniqueObjects,function(i){delete uniqueObjects[i][unique]}),uniqueObjects}return $.grep(items,function(item,i){return $.inArray(item,items)===i})}},$.trimSeparators=function(keyword,separator,removeDuplicates){var s=separator;return keyword=keyword.replace(new RegExp("^["+s+"\\s]+|["+s+",\\s]+$","g"),"").replace(new RegExp(s+"["+s+"\\s]*"+s,"g"),s).replace(new RegExp("[\\s]+"+s,"g"),s).replace(new RegExp(s+"[\\s]+","g"),s),removeDuplicates&&(keyword=$.distinct(keyword.split(s)).join(s)),keyword
},$.isNumeric=function(n){return!isNaN(parseFloat(n))&&isFinite(n)},$.Number={rotate:function(n,min,max,offset){return void 0===offset&&(offset=0),n+=offset,min>n?n+=max+1:n>max&&(n-=max+1),n}},$.fn.stretchToFit=function(){return $.each(this,function(){var $this=$(this);$this.css("width","100%").css("width",2*$this.width()-$this.outerWidth(!0)-parseInt($this.css("borderLeftWidth"))-parseInt($this.css("borderRightWidth")))})},$.fn.serializeJSON=function(stringify){var obj={};return $.each($(this).serializeArray(),function(i,prop){obj.hasOwnProperty(prop.name)?($.isArray(obj[prop.name])||(obj[prop.name]=[obj[prop.name]]),obj[prop.name].push(prop.value)):obj[prop.name]=prop.value
}),stringify&&(obj=(JSON.stringify||$.toJSON).apply(this,obj)),obj},$.fn.toHTML=function(){return $("<div>").html(this).html()},function(){var Bloop=function(items){this.items=items,this.start=0,this.end=items.length-1,this.node=null,this.stopped=!1};$.extend(Bloop.prototype,{isLooping:function(){return this.stopped?!1:Math.abs(this.start-this.end)>1?(this.node=Math.floor((this.start+this.end)/2),!0):!1},flip:function(flip){flip?this.end=this.node-1:this.start=this.node+1},stop:function(){this.stop=!0}}),$.Bloop=function(items){return new Bloop(items)
}}(),$.remap=function(to,from,props){return $.each(props,function(i,prop){to[prop]=from[prop]}),obj},$.deletes=function(obj,props){$.each(props,function(i,prop){delete obj[prop]})},function(){var Threads=function(options){this.threads=[],this.threadCount=0,this.threadLimit=options.threadLimit||1,this.threadDelay=options.threadDelay||0};$.extend(Threads.prototype,{add:function(thread,type){$.isFunction(thread)&&(thread.type=type||"normal","deferred"==type&&(thread.deferred=$.Deferred().always($.proxy(this.next,this))),this.threads.push(thread),this.run())
},addDeferred:function(thread){return this.add(thread,"deferred")},next:function(){this.threadCount--,this.run()},run:function(){var self=this;setTimeout(function(){if(!(self.threads.length<1)&&self.threadCount<self.threadLimit){self.threadCount++;var thread=self.threads.shift();try{thread.call(thread,thread.deferred)}catch(e){console.error(e)}!thread.deferred&&self.next()}},self.threadDelay)}}),$.Threads=function(options){return new Threads(options)}}(),function(){var isFunction=$.isFunction,Enqueue=function(){this.lastId=0
};Enqueue.prototype.queue=function(filter){var self=this,id=$.uid();return self.lastId=id,function(){if(self.lastId===id){var args=arguments,args=isFunction(filter)?filter.apply(this,args):args;return isFunction(self.fn)?self.fn.apply(this,args):args}}},$.Enqueue=function(fn){var self=new Enqueue;$.isFunction(fn)&&(self.fn=fn);var func=$.proxy(self.queue,self);return func.reset=function(){self.lastId=0},func}}(),function(){var instance="___eventable",publicMethods=["on","off","fire"],getEventName=function(name){return name.split(".")[0]
},Eventable=function(mode){this.fnList={},this.events={},this.mode=mode};$.extend(Eventable.prototype,{createEvent:function(name){return this.events[name]=$.Callbacks(this.mode)},on:function(name,fn){if(!name||!$.isFunction(fn))return this;var fnList=this.fnList;(fnList[name]||(fnList[name]=[])).push(fn);var basename=getEventName(name);return(this.events[basename]||this.createEvent(basename)).add(fn),this},off:function(name){if(!name)return this;var basename=getEventName(name),event=this.events[basename];if(!event)return this;
var removeCallbacks=function(fnList){$.each(fnList,function(i,fn){event.remove(fn)})};return basename!==name?$.each(this.fnList,function(name,fnList){name.indexOf(basename)>-1&&removeCallbacks(fnList)}):removeCallbacks(this.fnList[name]),this},fire:function(name){var event=this.events[name];if(event)return event.fire.apply(event,$.makeArray(arguments).slice(1)),this},destroy:function(){for(name in this.events)this.events[name].disable()}}),$.eventable=function(obj,mode){var eventable=obj[instance];return eventable&&"destroy"===mode?(eventable.destroy(),$.deletes(obj,publicMethods),delete obj[instance]):(eventable=obj[instance]=new Eventable(mode),obj.on=$.proxy(eventable.on,eventable),obj.off=$.proxy(eventable.off,eventable),obj.fire=$.proxy(eventable.fire,eventable),obj)
}}(),$.Chunk=function(array,options){$.isArray(array)&&(array=[]);var options=$.extend({},{size:256,every:1e3},options),self=$.extend($.Deferred(),{size:options.size,every:options.every,from:0,to:array.length,process:function(callback){return self.process.fn=callback,self},chunkStart:function(callback){return self.chunkStart.fn=callback,self},chunkEnd:function(callback){return self.chunkEnd.fn=callback,self},start:function(){return self.stopped=!1,self.iterate(),self},iterate:function(){if(!self.stopped){var iterator=self.process.fn;
if(iterator){self.to=from.size+self.size;var max=array.length;self.to>max&&(self.to=max);var range={from:self.from,to:self.to};for(self.chunkStart.fn&&self.chunkStart.fn.call(self,range.from,range.to);self.from<self.to&&!self.stopped;)iterator.call(self,array[self.from]),self.from++;return self.chunkEnd.fn&&self.chunkEnd.fn.call(self,range.from,range.to),self.completed=self.from>=array.length-1,self.completed?self.resolveWith(self):self.nextIteration=setTimeout(self.iterate,self.every),self}}},pause:function(){return self.stopped=!0,clearTimeout(self.nextIteration),self
},restart:function(){return"rejected"===self.state()?self:(self.from=0,self.start(),self)},stop:function(){return self.pause(),self.rejectWith(self,[self.from]),self}});return self},$.fn.disabled=function(x){return void 0===x?this.hasClass("disabled"):this.toggleClass("disabled",!!x)},$.fn.enabled=function(x){return void 0===x?!this.disabled():this.disabled(!x)},function(){var self=$.Ajax=function(options){var request=$.Deferred(),args=arguments;return $.isPlainObject(options)&&$.isFunction(options.beforeCreate)&&options.beforeCreate(request),self.queue.addDeferred(function(queue){request.xhr=$.ajax.apply(null,args).pipe(request.resolve,request.reject,request.notify),setTimeout(queue.resolve,self.requestInterval)
}),request};self.queue=$.Threads({threadLimit:1}),self.requestInterval=1200}()});