cortex.js
Version:
Cortex, the application framework that tickles your senses
98 lines (97 loc) • 46.8 kB
JavaScript
/*
backbone.js
Helper function to correctly set up the prototype chain, for subclasses.
Similar to `goog.inherits`, but uses a hash of prototype properties and
class properties to be extended.
*/
(function(R,t){function na(){}function s(h,g){"function"===typeof h&&(g=h,h=s.importing);c[h]=g()}var X=Array.prototype.slice,va=Object.prototype.toString,ca=document.documentElement,qa=0,S=R.Cortex,ra=R.$,c=R.Cortex={};c.version="0.0.0";c.noConflict=function(h){h?ra&&(R.$=ra):S&&(R.Cortex=S)};c.is=function(h,g){var b=va.call(h).slice(8,-1).toLowerCase();return g?b===g:b};c.forEach=c.each=function(h,g,b){if(h){var a=0;if("forEach"in h)h.forEach(g,b);else if(Array.isArray(h))for(var e=h.length;a<e&&
!1!==g.call(b,h[a],a,h);a++);else for(a in h)if(!1===g.call(b,h[a],a,h))break;return this}};c.filter=c.select=function(h,g,b){var a=[];if(!h)return a;if("filter"in h)return h.filter(g,b);c.forEach(h,function(h){g.apply(b,arguments)||a.push(h)});return a};c.map=c.collect=function(h,g,b){var a=[];if(!h)return a;if("map"in h&&"function"===typeof h.map)return h.map(g,b);c.forEach(h,function(h,d,c){a.push(g.call(b,h,d,c))});return a};c.matchesSelector=function(h,g){return 1!==g.nodeType?!1:c._matchesSelector?
c._matchesSelector.call(g,h):c.Sizzle.matchesSelector(g,h)};c._matchesSelector=ca.matchesSelector||ca.mozMatchesSelector||ca.webkitMatchesSelector||ca.oMatchesSelector||ca.msMatchesSelector;c.extend=function(h){c.forEach(X.call(arguments,1),function(g){for(var b in g)h[b]=g[b]});return h};c.property=function(h,g){return h&&g in h?"function"===typeof h[g]?h[g]():h[g]:null};var Z=/\,\s+/,L=c.EventEmitter={on:function(h,g,b){var a=Z.test(h)?h.split(Z):[h];for(this.events=this.events||(this.events={});h=
a.shift();)h&&(this.events[h]=this.events[h]||[]).push({context:b,callback:g});return this},off:function(h,g,b){function a(a){return!(a.callback===g&&(b?a.context===b:1))}var e=Z.test(h)?h.split(Z):[h];if(!arguments.length||!this.events)return this.events={},this;for(;h=e.shift();)this.events[h]&&h&&(g?this.events[h]=this.events[h].filter(a):delete this.events[h]);return this},emit:function(h){function g(b){b.callback.apply(b.context,a);e=!0}if(this.suppressed||!this.events)return!1;for(var b=Z.test(h)?
h.split(Z):[h],a=X.call(arguments,1),e=!1;h=b.shift();)this.events[h]&&h&&this.events[h].forEach(g);return e},once:function(h,g,b){function a(){e.off(h,a);g.apply(this,arguments)}var e=this;a.handle=g;return this.on(h,a,b)},enabled:function(){this.suppressed=this.suppressed||0;0>--this.suppressed&&(this.suppressed=0);return this},disable:function(){this.suppressed&&++this.suppressed;return this}};L.addListener=L.on;L.removeListener=L.off;var O=c.Structure=function(h,g){var b;h=this.parse(h);if(b=
c.property(this,"defaults"))h=c.extend({},b,h);c.extend(this,g);this.history={};this.id=qa++ +":"+ +new Date;this.attributes={};c.is(h,"object")&&!Object.keys(h).length||this.set(h,{silent:!0});this.initialize&&this.initialize.apply(this,arguments)};c.extend(O.prototype,L,{get:function(h){if(!~h.indexOf("."))return this.attributes[h];for(var g=h,b=this.attributes,a=h.split("."),e=0,c=a.length;e<c&&b;e++)b=g=b[+a[e]||a[e]];return g||this.attributes[h]},has:function(h){return!!this.get(h)},set:function(h,
g,b){var a;"object"===typeof h?(a=h,b=g):(a={},a[h]=g);b=b||{};if(!a)return this;a instanceof O&&(a=a.plain());var e=this.attributes,d=this,k={},p={};c.forEach(a,function(a,g){if(b.unset)return d.remove(g);g in e&&e[g]!==a&&(k[g]=!0);g in e||(p[g]=!0);d.history[g]=e[g];e[g]=a});c.forEach(k,function(a,b){d.emit("changed:"+b,e[b],d.attributes[b]);d.emit("changed",b,e[b],d.attributes[b])});c.forEach(p,function(a,b){d.emit("added:"+b,a);d.emit("added",b,a)});this.attributes=e;return this},remove:function(h){var g=
this.attributes[h];delete this.attributes[h];delete this.history[h];this.emit("deleted:"+h,g);this.emit("deleted",h,g);return this},clear:function(h){(h||(h={})).unset=!0;return this.set(this.attributes,h)},clone:function(){return new this.constructor(this.attributes)},previous:function(h){return this.history[h]},parse:function(h){return h},plain:function(h,g){"object"===typeof h&&(h=null);return h===t?this.attributes:this.attributes[h]}});var da=c.Collection=function(h,g){g=g||{};c.extend(this,g);
this.length=0;this.structures=[];this.structureId={};this.initialize&&this.initialize.apply(this,arguments);h&&this.add(h,{silent:!0})};c.extend(da.prototype,L,{structure:O,plain:function(h,g){"object"===typeof h&&(g=h,h=null);var b=this.structures.map(function(a){return a.plain(g)});return h!==t?b[h]:b},add:function(h,g){h=Array.isArray(h)?h.slice():[h];h=this.parse(h);g=g||{};for(var b=[],a=0,e=h.length,c;a<e;a++)c=this.prepare(h[a],g),!c||c.id in this.structureId||"dupe"in this&&this.dupe(c)||
(this.structureId[c.id]=c,this.structures.push(c),b.push(c),c.emit("collection:add",this,g));this.length=this.structures.length;b.length&&this.emit("add",b);return this},remove:function(h,g){h=Array.isArray(h)?h.slice():[h];g=g||{};for(var b=[],a=0,e;a<length;a++)if(e=this.get(h[a]))this.structures.splice(this.structures.indexOf(h),1),delete this.structureId[e.id],this.length--,b.push(e),e.emit("collection:remove",this,g),e.collection=t;this.emit("remove",b);return this},has:function(h,g){return!!~(g&&
g.plain?this.plain():this.structures).indexOf(h)},get:function(h){return h?this.structureId[h.id?h.id:h]:null},index:function(h){return h?this.structures[h]:null},last:function(){return this.structures[this.length-1]},prepare:function(h,g){g=g||{};h instanceof O?h.collection=this:(g.collection=this,h=new this.structure(h,g));return h},parse:function(h){return h}});c.forEach("forEach each map collect filter select".split(" "),function(h){da.prototype[h]=function(){return c[h].apply(this,[this.structures].concat(X.call(arguments,
0)))}});var P=c.View=function(h){h=h||{};this.id=qa++ +":"+ +new Date;c.extend(this,h);this.configure();this.initialize&&this.initialize.apply(this,arguments)};c.extend(P.prototype,L,{selector:"div",entityMap:{"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},delegate:{},$:function(h){return this.$el.find(h)},escape:function(h){var g=this.entityMap;return String(h).replace(/[&<>"'\/]/g,function(b){return g[b]})},template:function g(b,a){var e=b in g&&g[b]?g[b]:g[b]=$("#plates-"+
b).get("innerHTML");a=a||this.structure;if(a instanceof O||a instanceof da)a=a.plain();var c=new ha.Map({create:!0});c.toString=function(){delete c.toString;return ha.bind(e,a,this)};return c},configure:function(){this.$el=$(this.selector);this.el=this.$el.plain();var g="string"===typeof this.selector?this.selector.split(/[\s+]?\,[\s+]?/):[];c.forEach(g,function(b){b=b?b+" ":"";c.forEach(this.delegate,function(a,g){if(!this[a]||"function"!==typeof this[a])throw Error("Undefined callback for delegated event "+
g);var c=g.split(/^(\S+)\s*(.*)$/);g="<"===c[2].charAt(0)?c[2].slice(2):b+c[2];sa.add(c[1],g,this[a],this)},this)},this)}});O.extend=da.extend=P.extend=function(g,b){var a=c.inherits(this,g,b);a.extend=this.extend;return a};c.inherits=function(g,b,a){var e;e=b&&b.hasOwnProperty("constructor")?b.constructor:function(){g.apply(this,arguments)};c.extend(e,g);na.prototype=g.prototype;e.prototype=new na;b&&c.extend(e.prototype,b);a&&c.extend(e,a);e.prototype.constructor=e;e.__super__=g.prototype;return e};
c.Node=O.extend({initialize:function(g){this.attributes="string"===typeof g?this.factory(g):g},get:function(g){var b=this.attributes,a;return g in b&&b[g]?b[g]||"":(a=b.getAttribute(g))?a:"dataset"in b&&"object"===typeof b.dataset&&g in b.dataset?b.dataset[g]||"":b.getAttribute("data-"+g)||""},set:function(g,b,a){var e;if("object"===typeof g&&"nodeType"in g&&1===g.nodeType)return this.attributes=g,this;"object"===typeof g?(e=g,a=b):(e={},e[g]=b);a=a||{};if(!e)return this;e instanceof O&&(e=e.plain());
var d=this.attributes,k=this,p={},l={};c.forEach(e,function(b,g){if(a.unset)return k.remove(g);var e=g in d,c=d.hasAttribute("data-"+g),ya=k.get(g);if(e||c&&ya!==b)p[g]=!0;e||c||(l[g]=!0);k.history[g]=ya;e?d[g]=b:d.setAttribute("data-"+g,b)});c.forEach(p,function(b,a){k.emit("changed:"+a,d[a],k.attributes[a]);k.emit("changed",a,d[a],k.attributes[a])});c.forEach(l,function(a,b){k.emit("added:"+b,a);k.emit("added",b,a)});this.attributes=d;return this},factory:function(g){var b=document.createElement("div");
b.innerHTML=g;return b.firstChild},destroy:function(){this.attributes.parentNode.removeChild(this.attributes);return!0},show:function(){this.attributes.style.display="none"===this.attributes.style.display?"":"block";return this},hide:function(){this.attributes.style.display="none";return this},addClass:function(g){var b=this.attributes.className,a=b.split(" ");g=g.split(" ");for(var e=g.length;e--;)b&&~a.indexOf(g[e])||(b+=" "+g[e]);this.attributes.className=b;return this},removeClass:function(g){var b=
this.attributes.className;g=g.split(" ");for(var a=g.length;a--;)b=b.replace(RegExp("[\\s*]?\\b"+g[a]+"\\b","g"),"");this.attributes.className=b;return this}});var ea=c.Nodelist=da.extend({structure:c.Node,selector:"",find:function(g){var b=[];c.forEach(this.plain(),function(a){a=$(g,a);a.length&&Array.prototype.push.apply(b,a.plain())});return new ea(b,{selector:this.selector+" "+g,wrapper:this})},end:function(){return this.wrapper||this},parent:function(g){var b=[],a=this.plain();g?c.forEach(a,
function(a){for(a=a.parentNode;a;){if(c.matchesSelector(g,a))return b.push(a);a=a.parentNode}}):c.forEach(a,function(a){b.push(a.parentNode)});return new ea(b,{selector:g||this.selector,wrapper:this})}});c.forEach("show hide addClass removeClass get set destroy".split(" "),function(g){ea.prototype[g]=function(){var b=X.call(arguments,0),a=!1,c=[];this.forEach(function(d){var k=d[g].apply(d,b);a||(a=k===d);k!==t&&k!==d&&c.push(k)});return a?this:c.length?1===c.length?c[0]:c:t}});var sa=c.Events={listeners:{},
add:function(g,b,a,e){if(this.listeners[g])return this.listeners[g].on(b,a,e);this.listeners[g]=c.extend({type:g,listener:ca.addEventListener(g,this.process.bind(t,g),!0)},L);return this.listeners[g].on(b,a,e)},remove:function(g,b,a){if(!this.listeners[g])return this;this.listeners[g].off(b,a)},process:function(g,b){b=b||window.event;var a=b.target,e=sa.listeners[g];if(g){for(var d=Object.keys(e.events),k=[a],p={};a=a.parentNode;)k.push(a);c.forEach(d,function(a){for(var b=0,g=k.length;b<g;b++)if(c.matchesSelector(a,
k[b])){p[a]=k[b];break}});c.forEach(p,function(a,g){b.element=a;e.emit(g,b)})}}};c.push=function(g,b){if(g in c.push)return this;c.push[g]="function"===typeof b?b(c):(new Function("Cortex",b))(c);return this};c.find=R.$=function(g,b){b=b||document;var a=[],e=/^[\#\.\w]?[\w\-]+$/.test(g);"string"===typeof g?e?(e=g.charAt(0),"#"===e?(e=b.getElementById(g.slice(1)))&&a.push(e):a="."===e?X.call(b.getElementsByClassName(g.slice(1)),0):X.call(b.getElementsByTagName(g),0)):"<"===g.charAt(0)&&">"===g.charAt(g.length-
1)?a.push(g):a=c.Sizzle(g,b):(a.push(g),g=g.nodeName?g.nodeName.toLowerCase():g);return new ea(a,{selector:g})};c.active=function(g){if(c.configured)return g.call(c,null,c.cerebral),this;c.active.on("loaded",function(){var b={};c.find('script[type="cerebral/cortex"]').forEach(function(a){(a=a.get("innerHTML"))&&c.extend(b,(new Function("return "+a.trim()))())});c.cerebral=c.configuration=b;c.configured=!0;g.call(c,null,b)});return this};c.extend(c.active,L);c.app=function b(a,e,d){function k(){c.active(function(k,
l){if(!b[a]&&!k){d=c.extend(d||{},l[a]||l);var t=b[a]=new e(d);"emit"in t&&t.emit("cortex:app",d)}})}a=a.toLowerCase();if(1===arguments.length)return b[a];if(b[a])return this;if(d&&d.once)c.active.once(d.once,k);else k();return this};s.importing="undefined";s.amd=!0;var ha="undefined"!==typeof module&&"id"in module&&"undefined"!==typeof exports?exports:{};!function(b,a,c){function d(a,b,d,k,l){l=b.dataKey||l;if(b.dataKey&&"function"===typeof b.dataKey)return b.dataKey(a,d||"",k||"",l);if(!~l.indexOf("."))return a[l];
b=l;d=a;k=l.split(".");for(var p=0,D=k.length;p<D&&d;p++)d=b=d[+k[p]||k[p]];return b!==c?b:a[l]}function k(a){a=a.slice(0);a.sort(function(a,b){if(!a.attribute)return 1;if(!b.attribute)return-1;if(a.attribute!==b.attribute)return a.attribute<b.attribute?-1:1;if(a.value!==b.value)return a.value<b.value?-1:1;if(!("replace"in a||"replace"in b))throw Error("Conflicting mappings for attribute "+a.attribute+" and value "+a.value);return a.replace?1:-1});return a}function p(a){if(!(this instanceof p))return new p(a);
this.mappings=[];this.conf=a||{}}function l(a){a&&this.mappings.push({});(a=this.mappings[this.mappings.length-1])&&a.attribute&&a.value&&a.dataKey&&a.replace?a.re=RegExp(a.attribute+"=(['\"]?)"+a.value+"\\1"):a&&delete a.re;return a}var t=Object.prototype.toString;[].indexOf||(Array.prototype.indexOf=function(a,b,c){c=this.length;for(b=(c+~~b)%c;b<c&&(!(b in this)||this[b]!==a);b++);return b^c?b:-1});Array.isArray||(Array.isArray=function(a){return"[object Array]"===t.call(a)});var s=function(){};
s.prototype={nest:[],tag:/<\s*(\/?)\s*([-:\w]+)\s*((?:[-\w]+(?:\s*=\s*(?:\w+|["|'](?:.*)["|']))?)*)\s*(\/?)\s*>/,attr:/([\-\w]*)\s*=\s*(?:(["\'])([\-\.\w\s\/:;&#]*)\2)/gi,selfClosing:/^(area|base|br|col|command|embed|hr|img|input|keygen|link|meta|param|source|track|wbr)$/,hasClass:function(a,b){return~a.split(" ").indexOf(b)},iterate:function(a,b,c,e,d,k){var l="",p="</"+e+">",H=RegExp("< *"+e+"( *|>)","g"),t=0,I=-1,r,m,N;for(m=r=a.search(c.input);-1<m&&t!==I;)m=a.indexOf(p,m),-1<m&&(m+=e.length+
3,t++,N=a.slice(r,m),I=N.match(H).length);if(-1===m)throw Error("Unmatched tag "+e+" in "+a);a=N;p={};if(Array.isArray(b)){c=0;for(e=b.length;c<e;c++)d?p[d]=b[c]:p=b[c],l+=this.bind(a,p,k);return l}return"object"===typeof b?(a=a.slice(c.input.length,-(e.length+3)),l+this.bind(a,b,k)):b},bind:function(a,b,l){if(Array.isArray(b)){for(var p="",M=0,s=b.length;M<s;M++)p+=this.bind(a,b[M],l);return p}a=(a||"").toString();b=b||{};for(var D=this,G=p=0,H,U,I=l&&k(l.mappings),r=!1,m="",N=!1,Y=!1,T=!1,Q=!1,
L=l&&l.conf&&l.conf.create,u,w="",x,M=0,s=a.length;M<s;M++)if(U=a.charAt(M),"!"===U&&r&&!Q)r=!1,w+=a.slice(x,M+1);else if("<"!==U||r)if(">"===U&&r)if(r=!1,u=a.slice(x,M+1),H=this.tag.exec(u)){N=H[1];m=H[2];U=H[3];T=H[4];Y=this.selfClosing.test(m);Q&&(N?0>=p?Q=!1:--p:Y||++p);if(!N&&!Q)if(I&&0<I.length)for(var J=I.length-1;0<=J;J--){var F=!1,f=I[J],B=f.re&&U.match(f.re);if("tag"in f&&!this.attr.test(u)&&f.tag===m)u+=d(b,f,"",u);else if(u=u.replace(this.attr,function(C,K,z,n,k){if(!(B&&f.replace!==K||
G)){if(B||"undefined"!==typeof f.replacePartial1)return F=!0,z="undefined"!==typeof f.replacePartial2?n.replace(f.replacePartial1,f.replacePartial2):"undefined"!==typeof f.replacePartial1&&f.dataKey?n.replace(f.replacePartial1,d(b,f,n,u,K)):d(b,f,n,u,K),K+'="'+(z||"")+'"';!f.replace&&f.attribute===K&&(f.value===n||D.hasClass(n,f.value||I.conf.where===K)||"[object RegExp]"===t.call(f.value)&&null!==f.value.exec(n))&&(f.remove?Y||G++:f.plates?(n=D.bind(f.plates,"string"===typeof f.data?d(b,{dataKey:f.data}):
f.data||b,f.mapper),w+=u+D.iterate(a,n,H,m,c,l)):(K=z=d(b,f,n,u,K),z=u+z,Array.isArray(K)?(z=D.iterate(a,K,H,m,n,l),D.nest.push(m)):"object"===typeof K&&(z=u+D.iterate(a,K,H,m,n,l)),w+=z||""),Q=!0)}return C}),L&&B&&!F){var C=T?"/>":">";x=u.substr(0,u.length-(T?2:1));" "===x[x.length-1]&&(x=x.substr(0,x.length-1),T&&(C=" "+C));u=[x," ",f.replace,'="',d(b,f),'"',C].join("")}}else u.replace(this.attr,function(B,c,e,n,C){if(c===l&&l.conf.where||b[n])c=b[n],n=(B=Array.isArray(c))||"object"===typeof c?
D.iterate(a.substr(x),c,H,m,n,l):c,B&&D.nest.push(m),w+=B?n:u+n,Q=!0});Q||0!==D.nest.length?!Q&&D.nest.length&&this.nest.pop():(G||(w+=u),G&&N&&--G)}else r=!0;else r||Q||G||(w+=U);else r=!0,x=M;return w}};p.prototype={replace:function(a,b){var c=l.call(this);c.replacePartial1=a;c.replacePartial2=b;return this},use:function(a){l.call(this).dataKey=a;return l.call(this)&&this},where:function(a){l.call(this,!0).attribute=a;return l.call(this)&&this},"class":function(a){return this.where("class").is(a)},
tag:function(a){l.call(this,!0).tag=a;return this},is:function(a){l.call(this).value=a;return l.call(this)&&this},has:function(a){l.call(this).value=a;this.replace(a);return l.call(this)&&this},insert:function(a){var b=l.call(this);b.replace=b.attribute;b.dataKey=a;return l.call(this)&&this},as:function(a){l.call(this).replace=a;return l.call(this)&&this},remove:function(){l.call(this).remove=!0;return l.call(this,!0)},append:function(d,k,t){var s=l.call(this);k instanceof p&&(t=k,k=c);/<[^<]+?>/.test(d)||
b.cache[d]||(b.cache[d]="document"in a&&"getElementById"in a.document?document.getElementById(d).innerHTML:require("fs").readFileSync(require("path").join(process.cwd(),d),"utf8"));s.plates=b.cache[d]||d;s.data=k;s.mapper=t;return l.call(this,!0)}};p.prototype.className=p.prototype["class"];p.prototype.partial=p.prototype.append;p.prototype.to=p.prototype.use;b.cache={};b.bind=function(a,b,c){return(new s).bind(a,b,c)};b.Map=p}(ha,this);s.importing="reqwest";!function(b,a,c){"undefined"!=typeof module&&
module.exports?module.exports=c():"function"==typeof s&&s.amd?s(c):a[b]=c()}("reqwest",this,function(){function b(a,b,c){return function(){if(a._aborted)return c(a.request);a.request&&4==a.request[r]&&(a.request.onreadystatechange=w,U.test(a.request.status)?b(a.request):c(a.request))}}function a(a,b){var c=b.headers||{},e;c.Accept=c.Accept||J.accept[b.type]||J.accept["*"];var d="function"===typeof FormData&&b.data instanceof FormData;b.crossOrigin||c[N]||(c[N]=J.requestedWith);c[m]||d||(c[m]=b.contentType||
J.contentType);for(e in c)c.hasOwnProperty(e)&&"setRequestHeader"in a&&a.setRequestHeader(e,c[e])}function c(a){ia=a}function d(a,b){return a+(/\?/.test(a)?"&":"?")+b}function k(a,b,k,l){var z=T++,n=a.jsonpCallback||"callback";a=a.jsonpCallbackName||E.getcallbackPrefix(z);var m=RegExp("((^|\\?|&)"+n+")=([^&]+)"),p=l.match(m),f=H.createElement("script"),u=0,s=-1!==navigator.userAgent.indexOf("MSIE 10.0");p?"?"===p[3]?l=l.replace(m,"$1="+a):a=p[3]:l=d(l,n+"="+a);G[a]=c;f.type="text/javascript";f.src=
l;f.async=!0;"undefined"===typeof f.onreadystatechange||s||(f.htmlFor=f.id="_reqwest_"+z);f.onload=f.onreadystatechange=function(){if(f[r]&&"complete"!==f[r]&&"loaded"!==f[r]||u)return!1;f.onload=f.onreadystatechange=null;f.onclick&&f.onclick();b(ia);ia=t;Y.removeChild(f);u=1};Y.appendChild(f);return{abort:function(){f.onload=f.onreadystatechange=null;k({},"Request is aborted: timeout",{});ia=t;Y.removeChild(f);u=1}}}function p(c,e){var f=this.o,l=(f.method||"GET").toUpperCase(),z="string"===typeof f?
f:f.url,n=!1!==f.processData&&f.data&&"string"!==typeof f.data?E.toQueryString(f.data):f.data||null,m,p=!1;"jsonp"!=f.type&&"GET"!=l||!n||(z=d(z,n),n=null);if("jsonp"==f.type)return k(f,c,e,z);m=f.xhr&&f.xhr(f)||F(f);m.open(l,z,!1===f.async?!1:!0);a(m,f);"undefined"!==typeof f.withCredentials&&"undefined"!==typeof m.withCredentials&&(m.withCredentials=!!f.withCredentials);G[u]&&m instanceof G[u]?(m.onload=c,m.onerror=e,m.onprogress=function(){},p=!0):m.onreadystatechange=b(this,c,e);f.before&&f.before(m);
p?setTimeout(function(){m.send(n)},200):m.send(n);return m}function l(a,b){this.o=a;this.fn=b;L.apply(this,arguments)}function s(a){if(a.match("json"))return"json";if(a.match("javascript"))return"js";if(a.match("text"))return"html";if(a.match("xml"))return"xml"}function L(a,b){function c(b){a.timeout&&clearTimeout(d.timeout);for(d.timeout=null;0<d._completeHandlers.length;)d._completeHandlers.shift()(b)}function e(a,b,B){a=d.request;d._responseArgs.resp=a;d._responseArgs.msg=b;d._responseArgs.t=B;
for(d._erred=!0;0<d._errorHandlers.length;)d._errorHandlers.shift()(a,b,B);c(a)}this.url="string"==typeof a?a:a.url;this.timeout=null;this._fulfilled=!1;this._successHandler=function(){};this._fulfillmentHandlers=[];this._errorHandlers=[];this._completeHandlers=[];this._erred=!1;this._responseArgs={};var d=this;b=b||function(){};a.timeout&&(this.timeout=setTimeout(function(){d.abort()},a.timeout));a.success&&(this._successHandler=function(){a.success.apply(a,arguments)});a.error&&this._errorHandlers.push(function(){a.error.apply(a,
arguments)});a.complete&&this._completeHandlers.push(function(){a.complete.apply(a,arguments)});this.request=p.call(this,function(n){var m=a.type||s(n.getResponseHeader("Content-Type"));n="jsonp"!==m?d.request:n;var k=f.dataFilter(n.responseText,m);try{n.responseText=k}catch(l){}if(k)switch(m){case "json":try{n=G.JSON?G.JSON.parse(k):eval("("+k+")")}catch(p){return e(n,"Could not parse JSON in response",p)}break;case "js":n=eval(k);break;case "html":n=k;break;case "xml":n=n.responseXML&&n.responseXML.parseError&&
n.responseXML.parseError.errorCode&&n.responseXML.parseError.reason?null:n.responseXML}d._responseArgs.resp=n;d._fulfilled=!0;b(n);for(d._successHandler(n);0<d._fulfillmentHandlers.length;)n=d._fulfillmentHandlers.shift()(n);c(n)},e)}function E(a,b){return new l(a,b)}function P(a){return a?a.replace(/\r?\n/g,"\r\n"):""}function O(a,b){var c=a.name,e=a.tagName.toLowerCase(),d=function(a){a&&!a.disabled&&b(c,P(a.attributes.value&&a.attributes.value.specified?a.value:a.text))},f;if(!a.disabled&&c)switch(e){case "input":/reset|button|image|file/i.test(a.type)||
(d=/checkbox/i.test(a.type),e=/radio/i.test(a.type),f=a.value,(!d&&!e||a.checked)&&b(c,P(d&&""===f?"on":f)));break;case "textarea":b(c,P(a.value));break;case "select":if("select-one"===a.type.toLowerCase())d(0<=a.selectedIndex?a.options[a.selectedIndex]:null);else for(e=0;a.length&&e<a.length;e++)a.options[e].selected&&d(a.options[e])}}function S(){var a,b;for(b=0;b<arguments.length;b++){a=arguments[b];/input|select|textarea/i.test(a.tagName)&&O(a,this);for(var c=["input","select","textarea"],e=void 0,
d=void 0,f=void 0,e=0;e<c.length;e++)for(f=a[I](c[e]),d=0;d<f.length;d++)O(f[d],this)}}function M(){return E.toQueryString(E.serializeArray.apply(null,arguments))}function R(){var a={};S.apply(function(b,c){b in a?(a[b]&&!x(a[b])&&(a[b]=[a[b]]),a[b].push(c)):a[b]=c},arguments);return a}function D(a,b,c,e){var d,f,m=/\[\]$/;if(x(b))for(d=0;b&&d<b.length;d++)f=b[d],c||m.test(a)?e(a,f):D(a+"["+("object"===typeof f?d:"")+"]",f,c,e);else if(b&&"[object Object]"===b.toString())for(d in b)D(a+"["+d+"]",
b[d],c,e);else e(a,b)}var G=window,H=document,U=/^(20\d|1223)$/,I="getElementsByTagName",r="readyState",m="Content-Type",N="X-Requested-With",Y=H[I]("head")[0],T=0,Q="reqwest_"+ +new Date,ia,u="XDomainRequest",w=function(){},x="function"==typeof Array.isArray?Array.isArray:function(a){return a instanceof Array},J={contentType:"application/x-www-form-urlencoded",requestedWith:"XMLHttpRequest",accept:{"*":"text/javascript, text/html, application/xml, text/xml, */*",xml:"application/xml, text/xml",html:"text/html",
text:"text/plain",json:"application/json, text/javascript",js:"application/javascript, text/javascript"}},F=function(a){if(!0===a.crossOrigin){if((a=G.XMLHttpRequest?new XMLHttpRequest:null)&&"withCredentials"in a)return a;if(G[u])return new XDomainRequest;throw Error("Browser does not support cross-origin requests");}return G.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP")},f={dataFilter:function(a){return a}};l.prototype={abort:function(){this._aborted=!0;this.request.abort()},
retry:function(){L.call(this,this.o,this.fn)},then:function(a,b){a=a||function(){};b=b||function(){};this._fulfilled?this._responseArgs.resp=a(this._responseArgs.resp):this._erred?b(this._responseArgs.resp,this._responseArgs.msg,this._responseArgs.t):(this._fulfillmentHandlers.push(a),this._errorHandlers.push(b));return this},always:function(a){this._fulfilled||this._erred?a(this._responseArgs.resp):this._completeHandlers.push(a);return this},fail:function(a){this._erred?a(this._responseArgs.resp,
this._responseArgs.msg,this._responseArgs.t):this._errorHandlers.push(a);return this},catch:function(a){return this.fail(a)}};E.serializeArray=function(){var a=[];S.apply(function(b,c){a.push({name:b,value:c})},arguments);return a};E.serialize=function(){if(0===arguments.length)return"";var a,b=Array.prototype.slice.call(arguments,0);(a=b.pop())&&a.nodeType&&b.push(a)&&(a=null);a&&(a=a.type);return("map"==a?R:"array"==a?E.serializeArray:M).apply(null,b)};E.toQueryString=function(a,b){var c,e=b||!1,
d=[],f=encodeURIComponent,m=function(a,b){b="function"===typeof b?b():null==b?"":b;d[d.length]=f(a)+"="+f(b)};if(x(a))for(c=0;a&&c<a.length;c++)m(a[c].name,a[c].value);else for(c in a)a.hasOwnProperty(c)&&D(c,a[c],e,m);return d.join("&").replace(/%20/g,"+")};E.getcallbackPrefix=function(){return Q};E.compat=function(a,b){a&&(a.type&&(a.method=a.type)&&delete a.type,a.dataType&&(a.type=a.dataType),a.jsonpCallback&&(a.jsonpCallbackName=a.jsonpCallback)&&delete a.jsonpCallback,a.jsonp&&(a.jsonpCallback=
a.jsonp));return new l(a,b)};E.ajaxSetup=function(a){a=a||{};for(var b in a)f[b]=a[b]};return E});s.importing="Sizzle";(function(b){function a(a,b,q,c){var e,d,f,m,k;(b?b.ownerDocument||b:V)!==F&&J(b);b=b||F;q=q||[];if(!a||"string"!==typeof a)return q;if(1!==(m=b.nodeType)&&9!==m)return[];if(B&&!c){if(e=Aa.exec(a))if(f=e[1])if(9===m)if((d=b.getElementById(f))&&d.parentNode){if(d.id===f)return q.push(d),q}else return q;else{if(b.ownerDocument&&(d=b.ownerDocument.getElementById(f))&&z(b,d)&&d.id===
f)return q.push(d),q}else{if(e[2])return fa.apply(q,b.getElementsByTagName(a)),q;if((f=e[3])&&r.getElementsByClassName)return fa.apply(q,b.getElementsByClassName(f)),q}if(r.qsa&&(!C||!C.test(a))){d=e=n;f=b;k=9===m&&a;if(1===m&&"object"!==b.nodeName.toLowerCase()){m=T(a);(e=b.getAttribute("id"))?d=e.replace(Ba,"\\$&"):b.setAttribute("id",d);d="[id='"+d+"'] ";for(f=m.length;f--;)m[f]=d+R(m[f]);f=wa.test(a)&&O(b.parentNode)||b;k=m.join(",")}if(k)try{return fa.apply(q,f.querySelectorAll(k)),q}catch(l){}finally{e||
b.removeAttribute("id")}}}return ia(a.replace(ta,"$1"),b,q,c)}function c(){function a(q,c){b.push(q+" ")>m.cacheLength&&delete a[b.shift()];return a[q+" "]=c}var b=[];return a}function d(a){a[n]=!0;return a}function k(a){var b=F.createElement("div");try{return!!a(b)}catch(q){return!1}finally{b.parentNode&&b.parentNode.removeChild(b)}}function p(a,b){for(var q=a.split("|"),c=a.length;c--;)m.attrHandle[q[c]]=b}function l(a,b){var q=b&&a,c=q&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||na)-(~a.sourceIndex||
na);if(c)return c;if(q)for(;q=q.nextSibling;)if(q===b)return-1;return a?1:-1}function L(a){return function(b){return"input"===b.nodeName.toLowerCase()&&b.type===a}}function P(a){return function(b){var q=b.nodeName.toLowerCase();return("input"===q||"button"===q)&&b.type===a}}function E(a){return d(function(b){b=+b;return d(function(q,c){for(var d,e=a([],q.length,b),f=e.length;f--;)q[d=e[f]]&&(q[d]=!(c[d]=q[d]))})})}function O(a){return a&&typeof a.getElementsByTagName!==oa&&a}function S(){}function R(a){for(var b=
0,q=a.length,c="";b<q;b++)c+=a[b].value;return c}function M(a,b,q){var c=b.dir,d=q&&"parentNode"===c,e=ca++;return b.first?function(b,q,A){for(;b=b[c];)if(1===b.nodeType||d)return a(b,q,A)}:function(b,q,A){var f,m,k=[W,e];if(A)for(;b=b[c];){if((1===b.nodeType||d)&&a(b,q,A))return!0}else for(;b=b[c];)if(1===b.nodeType||d){m=b[n]||(b[n]={});if((f=m[c])&&f[0]===W&&f[1]===e)return k[2]=f[2];m[c]=k;if(k[2]=a(b,q,A))return!0}}}function X(a){return 1<a.length?function(b,q,c){for(var d=a.length;d--;)if(!a[d](b,
q,c))return!1;return!0}:a[0]}function D(a,b,q,c,d){for(var e,f=[],m=0,k=a.length,n=null!=b;m<k;m++)if(e=a[m])if(!q||q(e,c,d))f.push(e),n&&b.push(m);return f}function G(b,c,q,e,f,m){e&&!e[n]&&(e=G(e));f&&!f[n]&&(f=G(f,m));return d(function(d,m,k,n){var l,la,p=[],r=[],u=m.length,s;if(!(s=d)){s=c||"*";for(var y=k.nodeType?[k]:k,w=[],t=0,x=y.length;t<x;t++)a(s,y[t],w);s=w}s=!b||!d&&c?s:D(s,p,b,k,n);y=q?f||(d?b:u||e)?[]:m:s;q&&q(s,y,k,n);if(e)for(l=D(y,r),e(l,[],k,n),k=l.length;k--;)if(la=l[k])y[r[k]]=
!(s[r[k]]=la);if(d){if(f||b){if(f){l=[];for(k=y.length;k--;)(la=y[k])&&l.push(s[k]=la);f(null,y=[],l,n)}for(k=y.length;k--;)(la=y[k])&&-1<(l=f?ma.call(d,la):p[k])&&(d[l]=!(m[l]=la))}}else y=D(y===m?y.splice(u,y.length):y),f?f(null,m,y,n):fa.apply(m,y)})}function H(a){var b,q,c,d=a.length,e=m.relative[a[0].type];q=e||m.relative[" "];for(var f=e?1:0,k=M(function(a){return a===b},q,!0),l=M(function(a){return-1<ma.call(b,a)},q,!0),p=[function(a,v,c){return!e&&(c||v!==u)||((b=v).nodeType?k(a,v,c):l(a,
v,c))}];f<d;f++)if(q=m.relative[a[f].type])p=[M(X(p),q)];else{q=m.filter[a[f].type].apply(null,a[f].matches);if(q[n]){for(c=++f;c<d&&!m.relative[a[c].type];c++);return G(1<f&&X(p),1<f&&R(a.slice(0,f-1).concat({value:" "===a[f-2].type?"*":""})).replace(ta,"$1"),q,f<c&&H(a.slice(f,c)),c<d&&H(a=a.slice(c)),c<d&&R(a))}p.push(q)}return X(p)}function U(b,c){var q=0<c.length,e=0<b.length,f=function(d,f,k,l,n){var ka,p,r,s=0,t="0",w=d&&[],y=[],x=u,z=d||e&&m.find.TAG("*",n),B=W+=null==x?1:Math.random()||0.1,
C=z.length;for(n&&(u=f!==F&&f);t!==C&&null!=(ka=z[t]);t++){if(e&&ka){for(p=0;r=b[p++];)if(r(ka,f,k)){l.push(ka);break}n&&(W=B)}q&&((ka=!r&&ka)&&s--,d&&w.push(ka))}s+=t;if(q&&t!==s){for(p=0;r=c[p++];)r(w,y,f,k);if(d){if(0<s)for(;t--;)w[t]||y[t]||(y[t]=ra.call(l));y=D(y)}fa.apply(l,y);n&&!d&&0<y.length&&1<s+c.length&&a.uniqueSort(l)}n&&(W=B,u=x);return w};return q?d(f):f}var I,r,m,N,Y,T,Q,ia,u,w,x,J,F,f,B,C,ja,K,z,n="sizzle"+-new Date,V=b.document,W=0,ca=0,Z=c(),da=c(),ha=c(),ea=function(a,b){a===b&&
(x=!0);return 0},oa=typeof t,na=-2147483648,qa={}.hasOwnProperty,ga=[],ra=ga.pop,sa=ga.push,fa=ga.push,za=ga.slice,ma=ga.indexOf||function(a){for(var b=0,c=this.length;b<c;b++)if(this[b]===a)return b;return-1},ta=/^[\x20\t\r\n\f]+|((?:^|[^\\])(?:\\.)*)[\x20\t\r\n\f]+$/g,va=/^[\x20\t\r\n\f]*,[\x20\t\r\n\f]*/,xa=/^[\x20\t\r\n\f]*([>+~]|[\x20\t\r\n\f])[\x20\t\r\n\f]*/,Ca=/=[\x20\t\r\n\f]*([^\]'"]*?)[\x20\t\r\n\f]*\]/g,Da=RegExp(":((?:\\\\.|[\\w-]|[^\\x00-\\xa0])+)(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|\\[[\\x20\\t\\r\\n\\f]*((?:\\\\.|[\\w-]|[^\\x00-\\xa0])+)(?:[\\x20\\t\\r\\n\\f]*([*^$|!~]?=)[\\x20\\t\\r\\n\\f]*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|((?:\\\\.|[\\w-]|[^\\x00-\\xa0])+))|)[\\x20\\t\\r\\n\\f]*\\])*)|.*)\\)|)"),
Ea=/^(?:\\.|[\w-]|[^\x00-\xa0])+$/,ua={ID:/^#((?:\\.|[\w-]|[^\x00-\xa0])+)/,CLASS:/^\.((?:\\.|[\w-]|[^\x00-\xa0])+)/,TAG:/^((?:\\.|[\w-]|[^\x00-\xa0])+|[*])/,ATTR:RegExp("^\\[[\\x20\\t\\r\\n\\f]*((?:\\\\.|[\\w-]|[^\\x00-\\xa0])+)(?:[\\x20\\t\\r\\n\\f]*([*^$|!~]?=)[\\x20\\t\\r\\n\\f]*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|((?:\\\\.|[\\w-]|[^\\x00-\\xa0])+))|)[\\x20\\t\\r\\n\\f]*\\]"),PSEUDO:RegExp("^:((?:\\\\.|[\\w-]|[^\\x00-\\xa0])+)(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|\\[[\\x20\\t\\r\\n\\f]*((?:\\\\.|[\\w-]|[^\\x00-\\xa0])+)(?:[\\x20\\t\\r\\n\\f]*([*^$|!~]?=)[\\x20\\t\\r\\n\\f]*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|((?:\\\\.|[\\w-]|[^\\x00-\\xa0])+))|)[\\x20\\t\\r\\n\\f]*\\])*)|.*)\\)|)"),
CHILD:RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\([\\x20\\t\\r\\n\\f]*(even|odd|(([+-]|)(\\d*)n|)[\\x20\\t\\r\\n\\f]*(?:([+-]|)[\\x20\\t\\r\\n\\f]*(\\d+)|))[\\x20\\t\\r\\n\\f]*\\)|)","i"),bool:RegExp("^(?:checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped)$","i"),needsContext:RegExp("^[\\x20\\t\\r\\n\\f]*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\([\\x20\\t\\r\\n\\f]*((?:-\\d)?\\d*)[\\x20\\t\\r\\n\\f]*\\)|)(?=[^-]|$)",
"i")},Fa=/^(?:input|select|textarea|button)$/i,Ga=/^h\d$/i,pa=/^[^{]+\{\s*\[native \w/,Aa=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,wa=/[+~]/,Ba=/'|\\/g,aa=/\\([\da-f]{1,6}[\x20\t\r\n\f]?|([\x20\t\r\n\f])|.)/ig,ba=function(a,b,c){a="0x"+b-65536;return a!==a||c?b:0>a?String.fromCharCode(a+65536):String.fromCharCode(a>>10|55296,a&1023|56320)};try{fa.apply(ga=za.call(V.childNodes),V.childNodes),ga[V.childNodes.length].nodeType}catch(Ha){fa={apply:ga.length?function(a,b){sa.apply(a,za.call(b))}:function(a,b){for(var c=
a.length,d=0;a[c++]=b[d++];);a.length=c-1}}}r=a.support={};Y=a.isXML=function(a){return(a=a&&(a.ownerDocument||a).documentElement)?"HTML"!==a.nodeName:!1};J=a.setDocument=function(a){var b=a?a.ownerDocument||a:V;a=b.defaultView;if(b===F||9!==b.nodeType||!b.documentElement)return F;F=b;f=b.documentElement;B=!Y(b);a&&a!==a.top&&(a.addEventListener?a.addEventListener("unload",function(){J()},!1):a.attachEvent&&a.attachEvent("onunload",function(){J()}));r.attributes=k(function(a){a.className="i";return!a.getAttribute("className")});
r.getElementsByTagName=k(function(a){a.appendChild(b.createComment(""));return!a.getElementsByTagName("*").length});r.getElementsByClassName=pa.test(b.getElementsByClassName);r.getById=k(function(a){f.appendChild(a).id=n;return!b.getElementsByName||!b.getElementsByName(n).length});r.getById?(m.find.ID=function(a,b){if(typeof b.getElementById!==oa&&B){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},m.filter.ID=function(a){var b=a.replace(aa,ba);return function(a){return a.getAttribute("id")===
b}}):(delete m.find.ID,m.filter.ID=function(a){var b=a.replace(aa,ba);return function(a){return(a=typeof a.getAttributeNode!==oa&&a.getAttributeNode("id"))&&a.value===b}});m.find.TAG=r.getElementsByTagName?function(a,b){if(typeof b.getElementsByTagName!==oa)return b.getElementsByTagName(a)}:function(a,b){var c,v=[],d=0,e=b.getElementsByTagName(a);if("*"===a){for(;c=e[d++];)1===c.nodeType&&v.push(c);return v}return e};m.find.CLASS=r.getElementsByClassName&&function(a,b){if(B)return b.getElementsByClassName(a)};
ja=[];C=[];if(r.qsa=pa.test(b.querySelectorAll))k(function(a){a.innerHTML="<select msallowcapture=''><option selected=''></option></select>";a.querySelectorAll("[msallowcapture^='']").length&&C.push("[*^$]=[\\x20\\t\\r\\n\\f]*(?:''|\"\")");a.querySelectorAll("[selected]").length||C.push("\\[[\\x20\\t\\r\\n\\f]*(?:value|checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped)");a.querySelectorAll(":checked").length||C.push(":checked")}),
k(function(a){var c=b.createElement("input");c.setAttribute("type","hidden");a.appendChild(c).setAttribute("name","D");a.querySelectorAll("[name=d]").length&&C.push("name[\\x20\\t\\r\\n\\f]*[*^$|!~]?=");a.querySelectorAll(":enabled").length||C.push(":enabled",":disabled");a.querySelectorAll("*,:x");C.push(",.*:")});(r.matchesSelector=pa.test(K=f.matches||f.webkitMatchesSelector||f.mozMatchesSelector||f.oMatchesSelector||f.msMatchesSelector))&&k(function(a){r.disconnectedMatch=K.call(a,"div");K.call(a,
"[s!='']:x");ja.push("!=",":((?:\\\\.|[\\w-]|[^\\x00-\\xa0])+)(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|\\[[\\x20\\t\\r\\n\\f]*((?:\\\\.|[\\w-]|[^\\x00-\\xa0])+)(?:[\\x20\\t\\r\\n\\f]*([*^$|!~]?=)[\\x20\\t\\r\\n\\f]*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|((?:\\\\.|[\\w-]|[^\\x00-\\xa0])+))|)[\\x20\\t\\r\\n\\f]*\\])*)|.*)\\)|)")});C=C.length&&RegExp(C.join("|"));ja=ja.length&&RegExp(ja.join("|"));z=(a=pa.test(f.compareDocumentPosition))||pa.test(f.contains)?
function(a,b){var c=9===a.nodeType?a.documentElement:a,v=b&&b.parentNode;return a===v||!!(v&&1===v.nodeType&&(c.contains?c.contains(v):a.compareDocumentPosition&&a.compareDocumentPosition(v)&16))}:function(a,b){if(b)for(;b=b.parentNode;)if(b===a)return!0;return!1};ea=a?function(a,c){if(a===c)return x=!0,0;var v=!a.compareDocumentPosition-!c.compareDocumentPosition;if(v)return v;v=(a.ownerDocument||a)===(c.ownerDocument||c)?a.compareDocumentPosition(c):1;return v&1||!r.sortDetached&&c.compareDocumentPosition(a)===
v?a===b||a.ownerDocument===V&&z(V,a)?-1:c===b||c.ownerDocument===V&&z(V,c)?1:w?ma.call(w,a)-ma.call(w,c):0:v&4?-1:1}:function(a,c){if(a===c)return x=!0,0;var v,d=0;v=a.parentNode;var e=c.parentNode,f=[a],k=[c];if(!v||!e)return a===b?-1:c===b?1:v?-1:e?1:w?ma.call(w,a)-ma.call(w,c):0;if(v===e)return l(a,c);for(v=a;v=v.parentNode;)f.unshift(v);for(v=c;v=v.parentNode;)k.unshift(v);for(;f[d]===k[d];)d++;return d?l(f[d],k[d]):f[d]===V?-1:k[d]===V?1:0};return b};a.matches=function(b,c){return a(b,null,null,
c)};a.matchesSelector=function(b,c){(b.ownerDocument||b)!==F&&J(b);c=c.replace(Ca,"='$1']");if(r.matchesSelector&&B&&!(ja&&ja.test(c)||C&&C.test(c)))try{var d=K.call(b,c);if(d||r.disconnectedMatch||b.document&&11!==b.document.nodeType)return d}catch(e){}return 0<a(c,F,null,[b]).length};a.contains=function(a,b){(a.ownerDocument||a)!==F&&J(a);return z(a,b)};a.attr=function(a,b){(a.ownerDocument||a)!==F&&J(a);var c=m.attrHandle[b.toLowerCase()],c=c&&qa.call(m.attrHandle,b.toLowerCase())?c(a,b,!B):t;
return c!==t?c:r.attributes||!B?a.getAttribute(b):(c=a.getAttributeNode(b))&&c.specified?c.value:null};a.error=function(a){throw Error("Syntax error, unrecognized expression: "+a);};a.uniqueSort=function(a){var b,c=[],d=0,e=0;x=!r.detectDuplicates;w=!r.sortStable&&a.slice(0);a.sort(ea);if(x){for(;b=a[e++];)b===a[e]&&(d=c.push(e));for(;d--;)a.splice(c[d],1)}w=null;return a};N=a.getText=function(a){var b,c="",d=0;b=a.nodeType;if(!b)for(;b=a[d++];)c+=N(b);else if(1===b||9===b||11===b){if("string"===
typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=N(a)}else if(3===b||4===b)return a.nodeValue;return c};m=a.selectors={cacheLength:50,createPseudo:d,match:ua,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){a[1]=a[1].replace(aa,ba);a[3]=(a[3]||a[4]||a[5]||"").replace(aa,ba);"~="===a[2]&&(a[3]=" "+a[3]+" ");return a.slice(0,4)},CHILD:function(b){b[1]=
b[1].toLowerCase();"nth"===b[1].slice(0,3)?(b[3]||a.error(b[0]),b[4]=+(b[4]?b[5]+(b[6]||1):2*("even"===b[3]||"odd"===b[3])),b[5]=+(b[7]+b[8]||"odd"===b[3])):b[3]&&a.error(b[0]);return b},PSEUDO:function(a){var b,c=!a[6]&&a[2];if(ua.CHILD.test(a[0]))return null;a[3]?a[2]=a[4]||a[5]||"":c&&Da.test(c)&&(b=T(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b));return a.slice(0,3)}},filter:{TAG:function(a){var b=a.replace(aa,ba).toLowerCase();return"*"===a?function(){return!0}:
function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=Z[a+" "];return b||(b=RegExp("(^|[\\x20\\t\\r\\n\\f])"+a+"([\\x20\\t\\r\\n\\f]|$)"))&&Z(a,function(a){return b.test("string"===typeof a.className&&a.className||typeof a.getAttribute!==oa&&a.getAttribute("class")||"")})},ATTR:function(b,c,d){return function(e){e=a.attr(e,b);if(null==e)return"!="===c;if(!c)return!0;e+="";return"="===c?e===d:"!="===c?e!==d:"^="===c?d&&0===e.indexOf(d):"*="===c?d&&-1<e.indexOf(d):"$="===
c?d&&e.slice(-d.length)===d:"~="===c?-1<(" "+e+" ").indexOf(d):"|="===c?e===d||e.slice(0,d.length+1)===d+"-":!1}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),k="last"!==a.slice(-4),m="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,q){var l,A,p,r,s;c=f!==k?"nextSibling":"previousSibling";var t=b.parentNode,u=m&&b.nodeName.toLowerCase();q=!q&&!m;if(t){if(f){for(;c;){for(A=b;A=A[c];)if(m?A.nodeName.toLowerCase()===u:1===A.nodeType)return!1;s=c="only"===a&&!s&&
"nextSibling"}return!0}s=[k?t.firstChild:t.lastChild];if(k&&q)for(q=t[n]||(t[n]={}),l=q[a]||[],r=l[0]===W&&l[1],p=l[0]===W&&l[2],A=r&&t.childNodes[r];A=++r&&A&&A[c]||(p=r=0)||s.pop();){if(1===A.nodeType&&++p&&A===b){q[a]=[W,r,p];break}}else if(q&&(l=(b[n]||(b[n]={}))[a])&&l[0]===W)p=l[1];else for(;(A=++r&&A&&A[c]||(p=r=0)||s.pop())&&((m?A.nodeName.toLowerCase()!==u:1!==A.nodeType)||!++p||(q&&((A[n]||(A[n]={}))[a]=[W,p]),A!==b)););p-=e;return p===d||0===p%d&&0<=p/d}}},PSEUDO:function(b,c){var e,f=
m.pseudos[b]||m.setFilters[b.toLowerCase()]||a.error("unsupported pseudo: "+b);return f[n]?f(c):1<f.length?(e=[b,b,"",c],m.setFilters.hasOwnProperty(b.toLowerCase())?d(function(a,b){for(var d,e=f(a,c),v=e.length;v--;)d=ma.call(a,e[v]),a[d]=!(b[d]=e[v])}):function(a){return f(a,0,e)}):f}},pseudos:{not:d(function(a){var b=[],c=[],e=Q(a.replace(ta,"$1"));return e[n]?d(function(a,b,c,d){d=e(a,null,d,[]);for(var f=a.length;f--;)if(c=d[f])a[f]=!(b[f]=c)}):function(a,d,f){b[0]=a;e(b,null,f,c);return!c.pop()}}),
has:d(function(b){return function(c){return 0<a(b,c).length}}),contains:d(function(a){a=a.replace(aa,ba);return function(b){return-1<(b.textContent||b.innerText||N(b)).indexOf(a)}}),lang:d(function(b){Ea.test(b||"")||a.error("unsupported lang: "+b);b=b.replace(aa,ba).toLowerCase();return function(a){var c;do if(c=B?a.lang:a.getAttribute("xml:lang")||a.getAttribute("lang"))return c=c.toLowerCase(),c===b||0===c.indexOf(b+"-");while((a=a.parentNode)&&1===a.nodeType);return!1}}),target:function(a){var c=
b.location&&b.location.hash;return c&&c.slice(1)===a.id},root:function(a){return a===f},focus:function(a){return a===F.activeElement&&(!F.hasFocus||F.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return!1===a.disabled},disabled:function(a){return!0===a.disabled},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){a.parentNode&&a.parentNode.selectedIndex;return!0===a.selected},empty:function(a){for(a=
a.firstChild;a;a=a.nextSibling)if(6>a.nodeType)return!1;return!0},parent:function(a){return!m.pseudos.empty(a)},header:function(a){return Ga.test(a.nodeName)},input:function(a){return Fa.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:E(function(){return[0]}),last:E(function(a,b){return[b-
1]}),eq:E(function(a,b,c){return[0>c?c+b:c]}),even:E(function(a,b){for(var c=0;c<b;c+=2)a.push(c);return a}),odd:E(function(a,b){for(var c=1;c<b;c+=2)a.push(c);return a}),lt:E(function(a,b,c){for(b=0>c?c+b:c;0<=--b;)a.push(b);return a}),gt:E(function(a,b,c){for(c=0>c?c+b:c;++c<b;)a.push(c);return a})}};m.pseudos.nth=m.pseudos.eq;for(I in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})m.pseudos[I]=L(I);for(I in{submit:!0,reset:!0})m.pseudos[I]=P(I);S.prototype=m.filters=m.pseudos;m.setFilters=
new S;T=a.tokenize=function(b,c){var d,e,f,k,l,n,p;if(l=da[b+" "])return c?0:l.slice(0);l=b;n=[];for(p=m.preFilter;l;){if(!d||(e=va.exec(l)))e&&(l=l.slice(e[0].length)||l),n.push(f=[]);d=!1;if(e=xa.exec(l))d=e.shift(),f.push({value:d,type:e[0].replace(ta," ")}),l=l.slice(d.length);for(k in m.filter)!(e=ua[k].exec(l))||p[k]&&!(e=p[k](e))||(d=e.shift(),f.push({value:d,type:k,matches:e}),l=l.slice(d.length));if(!d)break}return c?l.length:l?a.error(b):da(b,n).slice(0)};Q=a.compile=function(a,b){var c,
d=[],e=[],f=ha[a+" "];if(!f){b||(b=T(a));for(c=b.length;c--;)f=H(b[c]),f[n]?d.push(f):e.push(f);f=ha(a,U(e,d));f.selector=a}return f};ia=a.select=function(a,b,c,d){var e,f,k,l,n="function"===typeof a&&a,p=!d&&T(a=n.selector||a);c=c||[];if(1===p.length){f=p[0]=p[0].slice(0);if(2<f.length&&"ID"===(k=f[0]).type&&r.getById&&9===b.nodeType&&B&&m.relative[f[1].type]){b=(m.find.ID(k.matches[0].replace(aa,ba),b)||[])[0];if(!b)return c;n&&(b=b.parentNode);a=a.slice(f.shift().value.length)}for(e=ua.needsContext.test(a)?
0:f.length;e--;){k=f[e];if(m.relative[l=k.type])break;if(l=m.find[l])if(d=l(k.matches[0].replace(aa,ba),wa.test(f[0].type)&&O(b.parentNode)||b)){f.splice(e,1);a=d.length&&R(f);if(!a)return fa.apply(c,d),c;break}}}(n||Q(a,p))(d,b,!B,c,wa.test(a)&&O(b.parentNode)||b);return c};r.sortStable=n.split("").sort(ea).join("")===n;r.detectDuplicates=!!x;J();r.sortDetached=k(function(a){return a.compareDocumentPosition(F.createElement("div"))&1});k(function(a){a.innerHTML="<a href='#'></a>";return"#"===a.firstChild.getAttribute("href")})||
p("type|href|height|width",function(a,b,c){if(!c)return a.getAttribute(b,"type"===b.toLowerCase()?1:2)});r.attributes&&k(function(a){a.innerHTML="<input/>";a.firstChild.setAttribute("value","");return""===a.firstChild.getAttribute("value")})||p("value",function(a,b,c){if(!c&&"input"===a.nodeName.toLowerCase())return a.defaultValue});k(function(a){return null==a.getAttribute("disabled")})||p("checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
function(a,b,c){var d;if(!c)return!0===a[b]?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null});"function"===typeof s&&s.amd?s(function(){return a}):"undefined"!==typeof module&&module.exports?module.exports=a:b.Sizzle=a})(window);c.Plates=ha;c.request=c.reqwest;[].map||(Array.prototype.map=function(b,a){for(var c=[],d=0;d<this;)c[d]=d in this?b.call(a,this[d],d++,this):void 0;return c});[].filter||(Array.prototype.filter=function(b,a,c,d,k){c=this;d=[];for(k in c)~~k+""==k&&0<=
k&&b.call(a,c[k],+k,c)&&d.push(c[k]);return d});[].indexOf||(Array.prototype.indexOf=function(b,a,c){c=this.length;for(a=(c+~~a)%c;a<c&&(!(a in this)||this[a]!==b);a++);return a^c?a:-1});Array.isArray||(Array.isArray=function(b){return""+b!==b&&"[object Array]"=={}.toString.call(b)});"".trim||(String.prototype.trim=function(){return this.replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g,"")});Function.prototype.bind=Function.prototype.bind||function(b){var a=Array.prototype.slice.call(arguments,1),c=this,d=function(){},
k=function(){return c.apply(this instanceof d&&b?this:b,a.concat(Array.prototype.slice.call(arguments)))};d.prototype=this.prototype;k.prototype=new d;return k};P=c.View.extend({selector:"input[placeholder]",delegate:{focus:"focus",change:"blur",mousedown:"readable",mouseout:"blur",blur:"blur"},className:"placeholder-polyfill",initialize:function(){this.prepare()},prepare:function(){$(this.selector).forEach(function(b){var a=b.get("value")||"";b.get("input-type")||b.set("input-type",b.get("type")||
"text");""===a&&b.set("value",b.get("placeholder"));b.get("value")===b.get("placeholder")&&b.addClass(this.className).set("type","text").set("readOnly",!0)},this)},readable:function(b){b.element.readOnly=!1;delete b.element.readOnly;b.element.removeAttribute("readOnly",0)},focus:function(b){var a=$(b.element),c=a.get("value")||"",d=a.get("placeholder");a.set("value",c===d?"":c);(a.get("value")||"")===d?a.addClass(this.className).set("type","text").set("readOnly",!0):(this.readable(b),a.removeClass(this.className).set("type",
a.get("input-type")))},blur:function(b){var a=$(b.element),c=a.get("value")||"",d=a.get("placeholder");a.set("value",""===c?d:c);(a.get("value")||"")===d?a.addClass(this.className).set("type","text").set("readOnly",!0):(this.readable(b),a.removeClass(this.className).set("type",a.get("input-type")))}});"placeholder"in document.createElement("input")||c.app("placeholder",P);if(Array.isArray(S)&&0===S.length%2)for(var P=0,xa=S.length;P<xa;P++)c.push(S[P],S[++P]);c.readyState="loading";document.addEventListener("cortex",
function(){c.readyState="loaded";c.active.emit("loaded")},!1)})(this);