text: define("cilantro/utils/numbers",[],function(){var t=[[3,"K"],[6,"million"],[9,"billion"],[12,"trillion"],[15,"quadrillion"],[18,"quintillion"],[21,"sextillion"],[24,"septillion"],[27,"octillion"],[30,"nonillion"],[33,"decillion"],[100,"googol"]],e=function(t){return!(void 0===t||null===t||""===t)},i=function(i,o){if(e(i)){if(1e3>i&&(null===o||void 0===o))return n(i);if(o>=i)return i;for(var r,s,a,l,c=0;c<t.length;c++)if(r=t[c][0],s=t[c][1],a=Math.pow(10,r),1e3*a>i)return l=Math.round(10*(i/a))/10,""+l+" "+s}},n=function(t,i){if(e(t)){void 0===i&&(i=",");for(var n=t.toString().split("."),o=n[0],r=n[1],s=o.toString().split(""),a=s.length,l=a%3||3;a>l;)s.splice(l,0,i),l+=4;var c=s.join("");return r&&(c+="."+r),c}},o=function(t,n){if(e(t)){if(0!==t){if(Math.abs(t)<.01)return t.toExponential(2);Math.round(t)!==t&&(t=t.toPrecision(3))}return i(t,n)}};return{toSuffixedNumber:i,toDelimitedNumber:n,prettyNumber:o}}),define("cilantro/utils/url",["jquery"],function(t){var e=function(t){var e=document.createElement("a");return e.href=t,e},i=function(i,n){if(!n)return i;for(var o=e(i),r={},s=o.search.substr(1).split("&"),a=0;a<s.length;a++){var l=s[a].split("=");l[0]&&(r[l[0]]=decodeURIComponent(l[1].replace("+"," ")))}return t.extend(r,n),o.search="?"+t.param(r),o.href};return{linkParser:e,alterUrlParams:i}}),define("cilantro/utils/version",[],function(){var t=/^\d+\.\d+\.\d+$/,e=function(e){e||(e="");for(var i=e.replace(/[abrf].*$/g,""),n=i.split("."),o=0;3>o;o++)n[o]=n[o]||0;var r;if(!t.test(r=n.join(".")))throw new Error("Bad version string: "+e);return r},i=function(t){var i=e(t).split(".");return{major:parseInt(i[0],10),minor:parseInt(i[1],10),micro:parseInt(i[2],10)}},n=function(t,e){switch(t=i(t),e=i(e),!0){case t.major>e.major:return 1;case t.major<e.major:return-1}switch(!0){case t.minor>e.minor:return 1;case t.minor<e.minor:return-1}switch(!0){case t.micro>e.micro:return 1;case t.micro<e.micro:return-1}return 0},o=function(t,e){return 0===n(t,e)},r=function(t,e){return 1===n(t,e)},s=function(t,e){return n(t,e)>-1},a=function(t,e){return-1===n(t,e)},l=function(t,e){return n(t,e)<1},c=function(t,e,i){return s(t,e)&&l(t,i)};return{cleanVersionString:e,parseVersionString:i,compareVersions:n,versionIsEqual:o,versionIsGt:r,versionIsGte:s,versionIsLt:a,versionIsLte:l,versionInRange:c}}),define("cilantro/utils",["jquery","./utils/numbers","./utils/url","./utils/version"],function(t){var e=Array.prototype.slice.call(arguments,1),i=function(t,e){document.cookie=t+"="+window.escape(e)+"; path=/"},n=function(t){for(var e=t+"=",i=document.cookie.split(";"),n=0;n<i.length;n++){var o=i[n].trim();if(0===o.indexOf(e))return o.substring(e.length,o.length)}},o=function(t,e,i){for(var n=e.split("."),o=0;o<n.length;o++)if(t=t[n[o]],void 0===t)return i;return"function"==typeof t?t.apply():t},r=function(e,i,n){if("object"==typeof i)return n===!0?t.extend(!0,{},i):t.extend(!0,e,i);for(var o,r=i.split("."),s=r.pop(),a=0;a<r.length;a++)o=r[a],void 0===e[o]&&(e[o]={}),e=e[o];e[s]=n},s=function(t){console.log(JSON.stringify(t,null,4))};return e.unshift({pprint:s,getDotProp:o,getCookie:n,setCookie:i,setDotProp:r}),t.extend.apply(null,e)}),define("cilantro/config",["jquery","./utils"],function(t,e){var i={debug:!1,root:"/",main:"#cilantro-main",session:{defaults:{url:null,credentials:null,ping:3e4,data:{}}},url:null,credentials:null,threshold:null,timeouts:{control:1e4},templates:{},controls:{},concepts:{defaults:{},types:{},instances:{}},fields:{defaults:{form:{controls:["search"]}},types:{choice:{form:{controls:["infograph"]}},number:{form:{chart:!0,controls:["number"]}},date:{form:{chart:!0,controls:["date"]}},time:{form:{chart:!0,controls:["date"]}},datetime:{form:{chart:!0,controls:["date"]}}},instances:{}}},n=function(){this.reset.apply(this,arguments)};return n.prototype.reset=function(){var e=[].slice.call(arguments);this.options=t.extend.apply(null,[!0,{},i].concat(e))},n.prototype.get=function(t,i){return e.getDotProp(this.options,t,i)},n.prototype.set=function(t,i){e.setDotProp(this.options,t,i)},n.prototype.unset=function(t){e.setDotProp(this.options,t,void 0)},{Config:n,defaultOptions:i}}),define("cilantro/channels",{FIELD_FOCUS:"field:focus",FIELD_BLUR:"field:blur",CONCEPT_FOCUS:"concept:focus",CONCEPT_BLUR:"concept:blur",CONTEXT_CHANGED:"context:changed",CONTEXT_SYNCING:"context:syncing",CONTEXT_SYNCED:"context:synced",CONTEXT_PAUSE:"context:pause",CONTEXT_RESUME:"context:resume",CONTEXT_CLEAR:"context:clear",CONTEXT_SAVE:"context:save",CONTEXT_REQUIRED:"context:required",CONTEXT_INVALID:"context:invalid",VIEW_CHANGED:"view:changed",VIEW_SYNCING:"view:syncing",VIEW_SYNCED:"view:synced",VIEW_PAUSE:"view:pause",VIEW_RESUME:"view:resume",VIEW_CLEAR:"view:clear",VIEW_SAVE:"view:save"}),define("plugins/js",[],function(){String.prototype.trim||(String.prototype.ltrim=function(){return this.replace(/^\s+/,"")},String.prototype.rtrim=function(){return this.replace(/\s+$/,"")},String.prototype.trim=function(){this.ltrim().rtrim()})}),define("plugins/jquery-ajax-queue",["jquery"],function(t){function e(e,n,r){r!==!1&&(r=!0),r&&(s=!0),n.done(e.success).fail(e.error).always(e.complete);var a={complete:function(){r&&i()},success:function(){n.resolveWith(this,arguments)},error:function(){n.rejectWith(this,arguments)}},l=o(t.extend({},e,a));n.abort=l.abort}function i(){var t,i,n;(t=r.shift())?(i=t[0],n=t[1],e(i,n)):s=!1}function n(i){var n,o,a;if(n=t.Deferred(),o=(i.type||"get").toLowerCase(),a=null!==i.queue?i.queue:"get"===o?!1:!0,a&&s){var l=[i,n];n.abort=function(){var t=r.indexOf(l);t>-1&&r.splice(t,1),[].unshift.call(arguments,"abort"),n.rejectWith(n,arguments)},r.push(l)}else e(i,n,a);return n}var o=t.ajax,r=[],s=!1;t.ajax=function(t,e){return"string"==typeof t&&(e.url=t,t=e),n(t)},t.hasPendingRequest=function(){return s}}),define("cilantro/core",["underscore","backbone","./config","./channels","./utils","plugins/js","plugins/jquery-ajax-queue",void 0===JSON?"json2":null],function(t,e,i,n,o){var r={version:"2.2.30",minSerranoVersion:"2.0.16",maxSerranoVersion:"2.3.5",getSerranoVersion:function(){return this.session?this.utils.cleanVersionString(this.session.version):void 0},isSupported:function(t){var e=this.minSerranoVersion,i=this.maxSerranoVersion,n=this.getSerranoVersion();return o.versionIsLt(n,i)&&(i=n),o.versionInRange(t,e,i)},config:new i.Config(this.cilantro),utils:o};return t.extend(r,e.Events,n),r}),define("cilantro/models/base",["underscore","backbone"],function(t,e){var i=e.Model.extend({constructor:function(i,n){n=t.defaults({parse:!0},n),this.links={},e.Model.prototype.constructor.call(this,i,n),this.on("change:_links",this._parseLinks)},url:function(){return this.isNew()?e.Model.prototype.url.call(this):this.links.self},_parseLinks:function(e,i){var n={};t.each(i,function(t,e){n[e]=t.href}),e.links=n},parse:function(t){return t&&t._links&&this._parseLinks(this,t._links),t}}),n=e.Collection.extend({model:i}),o=n.extend({initialize:function(){this.session=this.add({session:!0})},reset:function(t,i){i=i||{},t=t||[];for(var o,r,s=0;s<t.length;s++)if(o=t[s],o instanceof e.Model?o.get("session")===!0&&(r=o.toJSON()):o&&o.session===!0&&(r=o),r){this.session.set(r,i),t.splice(s,1);break}return t.push(this.session),n.prototype.reset.call(this,t,i)},get:function(t){var i=!1;return t instanceof e.Model&&(i=t.get("session")),("session"===t||"object"==typeof t&&t.session)&&(i=!0),i?this.findWhere({session:!0}):n.prototype.get.call(this,t)},getSession:function(){return this.session}});return{Model:i,Collection:n,SessionCollection:o}}),define("cilantro/models/stats",["backbone"],function(t){var e=t.Model.extend({idAttribute:"key"}),i=t.Collection.extend({model:e,parse:function(t){var e,i,n=[];for(e in t)i=t[e],"_"!==e.charAt(0)&&n.push({key:e,value:i});var o=["min","max"];return n.sort(function(t,e){var i=o.indexOf(t.key),n=o.indexOf(e.key);return i>=0&&n>=0?i-n:0>i&&0>n?t.key>e.key:i>=0?-1:1}),n}});return{StatModel:e,StatCollection:i}}),define("cilantro/models/field",["underscore","backbone","../core","./base","./stats"],function(t,e,i,n,o){var r=function(t){var e=i.config.get("fields.instances."+t.id+".type");return e?e:t.type?t.type:(e=t.simple_type,t.enumerable||"boolean"===e?"choice":e)},s=n.Model.extend({constructor:function(){n.Model.prototype.constructor.apply(this,arguments);var t=this;this.links.stats&&(this.stats=new o.StatCollection,this.stats.url=function(){return t.links.stats})},parse:function(){this._cache={};var t=n.Model.prototype.parse.apply(this,arguments);return t.type=r(t),t},distribution:function(t,i){if(i!==!1&&(i=!0),void 0===this.links.distribution)return t(),void 0;if(i&&void 0!==this._cache.distribution)t(this._cache.distribution);else{var n=this;e.ajax({url:this.links.distribution,dataType:"json",success:function(e){return i&&(n._cache.distribution=e),t(e)}})}},values:function(t,i,n){if(n!==!1&&(n=!0),"function"==typeof t?(i=t,n=i,t={}):t&&(n=!1,"string"==typeof t&&(t={query:t})),!this.links.values)return i(),void 0;var o=e.$.Deferred();if(i&&o.done(i),n&&void 0!==this._cache.values)o.resolve(this._cache.values);else{var r=this;e.ajax({url:this.links.values,data:t,dataType:"json",success:function(t){n&&(r._cache.values=t),o.resolve(t)},error:function(){o.reject()}})}return o.promise()}}),a=n.Collection.extend({model:s,search:function(i,n){e.ajax({url:t.result(this,"url"),data:{query:i},dataType:"json",success:function(t){n(t)}})}});return{FieldModel:s,FieldCollection:a}}),define("cilantro/models/concept",["underscore","backbone","../core","./base","./field"],function(t,e,i,n,o){var r=n.Model.extend({constructor:function(){this.fields=new o.FieldCollection,n.Model.prototype.constructor.apply(this,arguments)},initialize:function(){n.Model.prototype.initialize.call(this,arguments),i.on(i.CONCEPT_FOCUS,function(t){this.id===t&&0===this.fields.length&&this.fields.fetch({reset:!0})},this)},parse:function(t,e){n.Model.prototype.parse.call(this,t,e);var i=this;return this.fields.url=function(){return i.links.fields},t?(t.fields&&(this.fields.set(t.fields,e),delete t.fields),t):void 0}}),s=n.Collection.extend({model:r,search:function(i,n){return e.ajax({url:t.result(this,"url"),data:{query:i,brief:1},dataType:"json",success:function(t){n(t)}})}}),a=s.extend({constructor:function(){this.queryable=new s,this.viewable=new s;var e=this;this.queryable.url=function(){return t.result(e,"url")},this.viewable.url=function(){return t.result(e,"url")},s.prototype.constructor.apply(this,arguments)},initialize:function(){this.on("add remove reset",function(){this.queryable.reset(this.filter(function(t){return!!t.get("queryable")||!!t.get("queryview")})),this.viewable.reset(this.filter(function(t){return!!t.get("viewable")||!!t.get("formatter_name")}))})}});return{Concept:r,Concepts:a}}),define("cilantro/models/filters",["jquery","underscore","backbone"],function(t,e,i){var n=function(t){var e="";if(t.concept&&(e+="c"+t.concept),t.field&&(e+="f"+t.field),!e)throw new Error("Cannot generate id for filter");return e},o=i.Model.extend({constructor:function(t,e){t&&!t.id&&(t[this.idAttribute]=n(t)),i.Model.prototype.constructor.call(this,t,e)},generateId:function(t){return n(t)},clear:function(t){var i=e.clone(this.attributes);delete i.id,delete i.field,delete i.concept,this.set(i,e.defaults({unset:!0},t))},sync:function(){},apply:function(t){this.trigger("apply",this,t)},unapply:function(t){this.trigger("unapply",this,t)},toJSON:function(i){i=e.defaults(i||{},{id:!1});var n=t.extend(!0,{},this.attributes);return i.id||delete n[this.idAttribute],n},isEnabled:function(){return this.get("enabled")!==!1},toggleEnabled:function(){this.set("enabled",!this.isEnabled())}}),r=i.Collection.extend({model:o,constructor:function(t,n){n=e.defaults({parse:!0},n),i.Collection.prototype.constructor.call(this,t,n)},sync:function(){},apply:function(t){this.trigger("apply",this,t)},unapply:function(t){this.trigger("unapply",this,t)},parse:function(t){if(e.isArray(t))e.each(t,function(t){t.id||(t.id=this.model.prototype.generateId(t))});else{var i=t||{};if(t=[],i.field){var n=this.model.prototype.generateId(i);t.push(e.extend({id:n},i))}else if(i.children){var o=i.concept;e.each(i.children,function(i){void 0!==o&&(i=e.extend({concept:o},i)),t=t.concat(this.parse(i))},this)}}return t}});return{Filter:o,Filters:r}}),define("cilantro/models/context",["underscore","backbone","loglevel","../core","./base","./filters"],function(t,e,i,n,o,r){var s=function(){var e=[];t.each(n.config.get("filters.required"),function(t){e.push(t)});var o=n.config.get("query.concepts.required");return o&&(i.warn('The "query.concepts.required" option is deprecated, use "filters.required" instead with fully qualified lookups.'),t.each(o,function(t){e.push({concept:t})})),e},a=o.Model.extend({options:{saveDelay:300},initialize:function(e,i){e=e||{},this.requiredFilters=s(),this._filters=new r.Filters(e.json,t.defaults({parse:!0},i)),this.filters=new r.Filters(e.json,t.defaults({parse:!0},i)),this.listenTo(this._filters,{apply:this.apply,unapply:this.unapply}),this.listenTo(this.filters,{unapply:this.unapply,"change:enabled":function(){this._save()}}),this.on("change:json",function(e,i,n){this.filters.set(i,t.defaults({parse:!0},n)),n.reset&&this._filters.set(i,t.defaults({parse:!0,remove:!1},n)),this.filters.each(function(t){this.isFilterRequired(t.attributes)?t.set("required",!0):t.unset("required")},this)}),this.on("sync",function(t,e,i){i=i||{},this.validate(),i.silent!==!0&&n.trigger(n.CONTEXT_SYNCED,this,"success")}),this._save=t.debounce(this.save,this.options.saveDelay)},validate:function(){var e=[];return t.each(this.requiredFilters,function(i){var n,o=this.filters.findWhere(i);o?o.isEnabled()||(n="disabled"):n="undefined",n&&e.push(t.extend({reason:n},i))},this),e.length?(n.trigger(n.CONTEXT_INVALID,e),"One or more filters are invalid"):void 0},isFilterRequired:function(e){return t.any(this.requiredFilters,function(i){return t.isEqual(t.pick(e,t.keys(i)),i)})},_apply:function(t,e){var i=t.toJSON({id:!0});i.required=this.isFilterRequired(i);var n=this.filters.get(i.id);n?(n.clear({silent:!0}),n.set(i)):n=this.filters.add(i,e),n.set("enabled",!0,{silent:!0});var o=this._filters.get(n);o.trigger("applied",o,e),n.stopListening(this),n.listenToOnce(this,"request",function(t,e,i){this.trigger("request",this,e,i)}),n.listenToOnce(this,"sync",function(t,e,i){this.trigger("sync",this,this.toJSON(),i)})},apply:function(i,n){i instanceof e.Collection?i=i.slice():t.isArray(i)||(i=[i]),t.each(i,function(t){this._apply(t,n)},this),n&&n.save===!1||this._save()},_unapply:function(t,e){var n=t.toJSON({id:!0});if(this.isFilterRequired(n))return i.debug("skipping unapplying required filter",n),void 0;var o=this.filters.remove(n,e);if(o){var r=this._filters.get(o);r.trigger("unapplied",r,e),o.stopListening(this)}},unapply:function(i,n){i instanceof e.Collection?i=i.slice():t.isArray(i)||(i=[i]),t.each(i,function(t){this._unapply(t,n)},this),n&&n.save===!1||this._save()},define:function(t){var e=this._filters.model.prototype.generateId(t),i=this._filters.get(e);return i||(i=this._filters.create(t)),i},toJSON:function(){var t=o.Model.prototype.toJSON.call(this),e=this.filters.toJSON();return t.json=e.length?{type:"and",children:e}:null,t},isSession:function(){return this.get("session")},isArchived:function(){return this.get("archived")},isFilterApplied:function(t){return void 0!==this.filters.get(t)},hasFilterChanged:function(e,i){var n=this.filters.get(e);if(n)return i||(i=t.keys(e.attributes)),t.any(i,function(i){return!t.isEqual(e.get(i),n.get(i))})}}),l=o.SessionCollection.extend({model:a});return{Context:a,ContextCollection:l}}),define("cilantro/models/view",["underscore","backbone","../core","./base"],function(t,e,i,n){var o=e.Model.extend({idAttribute:"concept"}),r=e.Collection.extend({model:o}),s=n.Model.extend({constructor:function(){this.facets=new r,this.on("change:json",function(t,e){return this.jsonToFacets(e)}),n.Model.prototype.constructor.apply(this,arguments)},initialize:function(){var t=this;return this.on("request",function(){return i.trigger(i.VIEW_SYNCING,this)}),this.on("sync",function(t,e,n){return n||(n={}),n.silent!==!0?i.trigger(i.VIEW_SYNCED,this,"success"):void 0}),this.on("error",function(){return i.trigger(i.VIEW_SYNCED,this,"error")}),this.on("change",function(){return i.trigger(i.VIEW_CHANGED,this)}),i.on(i.VIEW_SAVE,function(e){return t.id===e||!e&&t.isSession()?t.save():void 0})},isSession:function(){return this.get("session")},isArchived:function(){return this.get("archived")},toJSON:function(){var t=n.Model.prototype.toJSON.apply(this,arguments);return t.json=this.facetsToJSON(),t},parse:function(t){return n.Model.prototype.parse.apply(this,arguments),this.jsonToFacets(t.json),t},jsonToFacets:function(e){if(e||(e={}),t.isArray(e))return this.facets.reset(e),void 0;for(var i,n,o,r=[],s=e.columns||[],a=e.ordering||[],l=0;l<s.length;l++){n=s[l],i={concept:n};for(var c=0;c<a.length;c++)o=a[c],n===o[0]&&(i.sort=o[1],i.sort_index=c);r.push(i)}return this.facets.reset(r)},facetsToJSON:function(){var t={ordering:[],columns:[]};return this.facets.each(function(e){var i,n,o;return t.columns.push(e.get("concept")),(i=e.get("sort"))?(n=e.get("sort_index"),o=[e.get("concept"),i],t.ordering.splice(n,0,o)):void 0}),t}}),a=n.SessionCollection.extend({model:s});return{ViewModel:s,ViewCollection:a}}),define("cilantro/models/paginator",["underscore","backbone","../core"],function(t,e,i){var n={comparator:"page_num",refresh:function(){var e=t.result(this,"url");if(this.pending){if(e===this.pending.url)return;this.pending.abort()}var i=this;this.pending=this.fetch({reset:!0}).done(function(){delete i.pending,i.setCurrentPage(i.models[0].id)}),this.pending.url=e},parse:function(t,e){return e.reset||this.reset(null,{silent:!0}),this.perPage=t.per_page,this.trigger("change:pagesize",this,this.perPage),this.numPages=t.num_pages,this.trigger("change:pagecount",this,this.numPages),this.objectCount=t.object_count,this.trigger("change:objectcount",this,this.objectCount),this.currentPageNum=null,this.setCurrentPage(t.page_num),[t]},hasPage:function(t){return t>=1&&t<=this.numPages},hasNextPage:function(t){return t||(t=this.currentPageNum),t<this.numPages},hasPreviousPage:function(t){return t||(t=this.currentPageNum),t>1},setCurrentPage:function(t){if(t!==this.currentPageNum){if(!this.hasPage(t))throw new Error("Cannot set the current page out of bounds");return this.previousPageNum=this.currentPageNum,this.currentPageNum=t,this.trigger.apply(this,["change:currentpage",this].concat([].slice.call(this.getCurrentPageStats())))}},getPage:function(t,e){if(e||(e={}),this.hasPage(t)){var i=this.get(t);return i||e.load===!1||(i=new this.model({page_num:t}),i.pending=!0,this.add(i),i.fetch().done(function(){delete i.pending})),i&&e.active!==!1&&this.setCurrentPage(t),i}},getCurrentPage:function(t){return this.getPage(this.currentPageNum,t)},getFirstPage:function(t){return this.getPage(1,t)},getLastPage:function(t){return this.getPage(this.numPages,t)},getNextPage:function(t,e){return t||(t=this.currentPageNum),this.getPage(t+1,e)},getPreviousPage:function(t,e){return t||(t=this.currentPageNum),this.getPage(t-1,e)},pageIsLoading:function(t){t||(t=this.currentPageNum);var e=this.getPage(t,{active:!1,load:!1});return e?!!e.pending:void 0},getPageCount:function(){return this.numPages},getCurrentPageStats:function(){return[this.currentPageNum,{previous:this.previousPageNum,first:1===this.currentPageNum,last:this.currentPageNum===this.numPages}]}},o=e.Model.extend({idAttribute:"page_num",url:function(){var e=t.result(this.collection,"url");return i.utils.alterUrlParams(e,{page:this.id,per_page:this.collection.perPage})}}),r=e.Collection.extend({model:o});return t.extend(r.prototype,n),{PaginatorMixin:n,Page:o,Paginator:r}}),define("cilantro/constants",{INPUT_DELAY:400,CLICK_DELAY:300});var __hasProp={}.hasOwnProperty,__extends=function(t,e){function i(){this.constructor=t}for(var n in e)__hasProp.call(e,n)&&(t[n]=e[n]);return i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype,t},__bind=function(t,e){return function(){return t.apply(e,arguments)}};define("cilantro/structs",["underscore","backbone","./models/base"],function(t,e,i){var n,o,r,s,a,l,c,u,h,d;return s=function(t){function e(){return h=e.__super__.constructor.apply(this,arguments)}return __extends(e,t),e.prototype.defaults={visible:!0},e.prototype.show=function(){return this.set({visible:!0})},e.prototype.hide=function(){return this.set({visible:!1})},e}(e.Model),a=function(t){function e(){return d=e.__super__.constructor.apply(this,arguments)}return __extends(e,t),e.prototype.model=s,e}(e.Collection),n=function(t){function e(t,i,n){i instanceof s||(i=new s(i)),this.index=i,e.__super__.constructor.call(this,t,n)}return __extends(e,t),e.prototype.size=function(){return 1},e.prototype.width=function(){return 1},e}(e.Model),c=function(e){function i(t,e,n){this.model=__bind(this.model,this),this.indexes=e,i.__super__.constructor.call(this,t,n)}return __extends(i,e),i.prototype.model=function(e){var i;return i=this.indexes.at(t.keys(this._byId).length),new n({value:e},i)},i}(e.Collection),l=function(e){function i(e,n,o){var r;null==o&&(o={}),n instanceof a||(n=new a(n)),this.indexes=n,t.isArray(e)?(r=e,e=null):o.parse=!0,this.data=new c(r,n),i.__super__.constructor.call(this,e,o)}return __extends(i,e),i.prototype.parse=function(t,e){return this.data.reset(t.values,e),delete t.values,t},i.prototype.isColumn=function(){return 1===this.width()},i.prototype.isRow=function(){return!this.isColumn()},i.prototype.size=function(){return this.isColumn()?this.data.length:1},i.prototype.width=function(){return this.indexes.length},i}(e.Model),u=function(t){function e(t,i,n){this.model=__bind(this.model,this),this.indexes=i,e.__super__.constructor.call(this,t,n)}return __extends(e,t),e.prototype.model=function(t,e){return new l(t,this.indexes,e)},e}(e.Collection),o=function(e){function i(e,n,o){var r;null==o&&(o={}),n instanceof a||(n=new a(n)),this.indexes=n,t.isArray(e)?(r=e,e=null):o.parse=!0,this.series=new u(r,n),i.__super__.constructor.call(this,e,o)}return __extends(i,e),i.prototype.parse=function(t,e){return i.__super__.parse.call(this,t,e),this.indexes.reset(t.keys,e),this.series.reset(t.objects,e),delete t.keys,delete t.objects,t},i.prototype.size=function(){return this.series.length},i.prototype.width=function(){return this.indexes.length},i.prototype.column=function(t){var e;return e=this.series.map(function(e){return e.data.at(t)}),new l(e,this.indexes.at(t))},i}(i.Model),r=function(t){function e(t,i){this.indexes=new a,this.on("reset",function(t){var e;return(e=t.models[0])?this.indexes.reset(e.indexes.models):void 0}),this.on("add",function(t,e){return 1===e.length?this.indexes.reset(t.indexes.models):void 0}),e.__super__.constructor.call(this,t,i)}return __extends(e,t),e.prototype.model=o,e}(i.Collection),{FrameArray:r,Frame:o,Series:l,Datum:n,Index:s,Indexes:a}}),define("cilantro/models/results",["underscore","../core","../constants","../structs","./paginator"],function(t,e,i,n,o){var r=n.Frame.extend({idAttribute:"page_num",url:function(){var i=t.result(this.collection,"url");return e.utils.alterUrlParams(i,{page:this.id,per_page:this.collection.perPage})}}),s=n.FrameArray.extend({initialize:function(){t.bindAll(this,"fetch","markAsDirty","onWorkspaceUnload","onWorkspaceLoad","refresh"),this.isDirty=!0,this.isWorkspaceOpen=!1,this._refresh=t.debounce(this.refresh,i.CLICK_DELAY),e.on(e.VIEW_SYNCED,this.markAsDirty),e.on(e.CONTEXT_SYNCED,this.markAsDirty),this.on("workspace:load",this.onWorkspaceLoad),this.on("workspace:unload",this.onWorkspaceUnload)},onWorkspaceLoad:function(){this.isWorkspaceOpen=!0,this._refresh()},onWorkspaceUnload:function(){this.isWorkspaceOpen=!1},markAsDirty:function(){this.isDirty=!0,this._refresh()},fetch:function(t){t||(t={});var i;if(null!==(i=e.config.get("session.defaults.data.preview"))&&(t.type="POST",t.contentType="application/json",t.data=JSON.stringify(i)),this.isDirty&&this.isWorkspaceOpen)return this.isDirty=!1,void 0===t.cache&&(t.cache=!1),n.FrameArray.prototype.fetch.call(this,arguments);var o=this;return{done:function(){return delete o.pending}}}});return t.extend(s.prototype,o.PaginatorMixin),s.prototype.model=r,{Results:s}}),define("cilantro/models/exporter",["underscore","./base"],function(t,e){var i=function(t){if(!t.href)return"Untitled";var e,i=t.href;return e="/"===i.charAt(i.length-1)?i.substr(0,i.length-1).split("/"):i.split("/"),e.length>0?e[e.length-1].toUpperCase():"Untitled "+i},n=e.Model.extend({idAttribute:"type"}),o=e.Collection.extend({model:n,parse:function(e){var n=[];return t.each(e._links,function(e,o){"self"!==o&&(e=t.extend({type:o},e),e.title||(e.title=i(e)),n.push(e))}),n}});return{ExporterModel:n,ExporterCollection:o}}),define("cilantro/models/query",["./base","../core","./context","./view"],function(t,e,i,n){var o=t.Model.extend({constructor:function(e,o){e=e||{},this.context=new i.Context({json:e.context_json}),this.view=new n.ViewModel({json:e.view_json}),t.Model.prototype.constructor.call(this,e,o)},parse:function(e,i){return e&&(e&&!e.shared_users&&(e.shared_users=[]),this.context.set({json:e.context_json}),this.view.set({json:e.view_json})),t.Model.prototype.parse.call(this,e,i)}}),r=t.Collection.extend({model:o});return{Query:o,Queries:r}}),define("cilantro/models/value",["underscore","backbone","../structs","../constants"],function(t,e,i,n){var o=e.Model.extend({idAttribute:"label",defaults:{valid:null,pending:!1},fetch:function(){},toJSON:function(t){return t&&t.flat?this.pluck("value"):this.pick("value","label")},destroy:function(t){this.trigger("destroy",this,this.collection,t)}}),r=e.Collection.extend({model:o,options:{check:!0},initialize:function(e,i){i=t.extend({},this.options,i||{}),i.check&&this.on("add",t.debounce(this.check,n.INPUT_DELAY))},fetch:function(){},create:function(t,e){this.add(t,e)},check:function(){var i=this.where({valid:null,pending:!1});if(i.length){t.each(i,function(t){t.set("pending",!0)});var n=this;e.ajax({url:this.url(),type:"POST",data:JSON.stringify(i),contentType:"application/json",success:function(t){n.set(t,{add:!1,remove:!1})},complete:function(){t.each(i,function(t){t.set("pending",!1)})}})}}});return{Value:o,Values:r}}),define("cilantro/models",["underscore","./models/base","./models/field","./models/concept","./models/context","./models/filters","./models/view","./models/paginator","./models/results","./models/exporter","./models/query","./models/value"],function(t){var e=[].slice.call(arguments,1);return t.extend.apply(null,[{}].concat(e))}),define("cilantro/router",["backbone","underscore","loglevel"],function(t,e,i){var n=t.Router.extend({options:{main:"body",root:null},initialize:function(t){this.options=e.extend({},e.result(this,"options"),t),this._loaded=[],this._routes={},this._handlers={},this._registered={},e.bindAll(this,"_unloadAll","_loadAll","_unload","_load","_render")},_unloadAll:function(){var t=[].slice.call(arguments);e.each(this._loaded.slice(),function(e){this._unload.apply(this,[this._registered[e],!1].concat(t))},this)},_loadAll:function(t){var i=this._routes[t];if(i){var n=[].slice.call(arguments,1);e.each(i,function(t){this._load.apply(this,[this._registered[t]].concat(n))},this)}},_unload:function(e,i){void 0===i&&(i=!0);var n=this._loaded.indexOf(e.id);if((e.route||i&&n>=0)&&(this._loaded.splice(n,1),e._view)){e._view.$el.hide();var o=[].slice.call(arguments,2);e._view.trigger.apply(e._view,["router:unload",this,t.history.fragment].concat(o))}},_load:function(t){var n=[].slice.call(arguments,1);if(!t._view){if(e.isString(t.view)){var o=this;return require([t.view],function(e){t._view=new e(t.options),o._render.apply(o,[t].concat(n)),o._loaded.push(t.id)},function(t){i.error(t)}),void 0}t._view=t.view}this._render.apply(this,[t].concat(n)),this._loaded.push(t.id)},_render:function(e){var i=[].slice.call(arguments,1),n=e._view;if(!n._rendered&&(n._rendered=!0,e.el!==!1)){var o;o=e.el?t.$(e.el,this.options.main):t.$(this.options.main),o.append(n.el),n.render()}n.$el.show(),n.trigger.apply(n,["router:load",this,t.history.fragment].concat(i))},_register:function(t){if(this._registered[t.id])throw new Error('Route "'+t.id+'" already registered');if(t=e.clone(t),t.route){if(!this._handlers[t.route]){this._routes[t.route]=[];var i=e.bind(function(){var e=[].slice.call(arguments);this._unloadAll.apply(this,e),this._loadAll.apply(this,[t.route].concat(e))},this);this._handlers[t.route]=i,this.route(t.route,t.id,i)}}else this._load(t);t.route&&this._routes[t.route].push(t.id),this._registered[t.id]=t},get:function(t){return this._registered[t]},isNavigable:function(t){var e=this.get(t);return e&&e.navigable!==!1},isCurrent:function(i){if(i===t.history.fragment)return!0;var n=this._routes[t.history.fragment]||[];return e.any(n,function(t){return i===t})},hasRoute:function(t){return this._routes.hasOwnProperty(t)},navigate:function(e,i){return this.isNavigable(e)&&(e=this.get(e).route),t.Router.prototype.navigate.call(this,e,i)},register:function(t){t&&(e.isArray(t)||(t=[t]),e.each(t,function(t){t.view&&this._register(t)},this))},unregister:function(t){if(void 0===t)return e.each(this._registered,function(t,e){this.unregister(e)},this),void 0;var i=this._registered[t];if(!i)throw new Error('No route registered by id "'+t+'"');this._unload(i),delete this._registered[t];var n=this._routes[i.route];n&&n.indexOf(t)>=0&&this._routes[i.route].splice(n.indexOf(t),1)},start:function(i){if(!t.History.started){var n=this.options.root||"/";return"/"!==n.charAt(n.length-1)&&(n+="/"),i=e.extend({root:n,pushState:!0},i),t.history.start(i)}}});return{Router:n}}),define("cilantro/session",["jquery","underscore","backbone","./models","./utils","./router","./core"],function(t,e,i,n,o,r,s){var a={SESSION_OPENING:"session:opening",SESSION_ERROR:"session:error",SESSION_UNAUTHORIZED:"session:unauthorized",SESSION_OPENED:"session:opened",SESSION_CLOSED:"session:closed"},l={concepts:n.Concepts,fields:n.FieldCollection,contexts:n.ContextCollection,views:n.ViewCollection,preview:n.Results,exporter:n.ExporterCollection,queries:n.Queries,public_queries:n.Queries},c=n.Model.extend({idAttribute:"url",options:function(){return s.config.get("session.defaults")},initialize:function(t,i){this.options=e.extend({},e.result(this,"options"),i),this.opened=!1,this.started=!1,this.opening=!1,this.state={},e.bindAll(this,"ping","startPing","stopPing")},validate:function(t){return t&&t.url?void 0:"url is required"},startPing:function(){this.links.ping&&this.options.ping&&!this._ping&&(this.ping(),this._ping=setInterval(this.ping,this.options.ping))},stopPing:function(){clearTimeout(this._ping),delete this._ping},ping:function(){var t=this;i.ajax({type:"GET",url:this.links.ping,dataType:"json",success:function(e){"timeout"===e.status&&(t.stopPing(),t.timeout(e.location))},error:function(e,i,n){t.stopPing(),"FOUND"===n&&this.timeout(e.getResponseHeader("Location"))}})},timeout:function(t){var e;e=t?'Your session timed out. Please <a href="'+t+'">refresh the page</a>.':"Your session timed out. Please refresh the page.",s.notify({header:"Session Timeout",message:e,dismissable:!1,timeout:!1,level:"warning"}),setTimeout(function(){t?window.location=location:window.location.reload()},5e3)},parse:function(t){t=t||{},this.title=t.title,this.version=t.version,this.data={};var i;e.each(t._links,function(t,e){(i=l[e])&&(this.data[e]=new i,this.data[e].url=t.href,this.data[e].fetch({reset:!0}))},this),this.router=new r.Router({main:s.config.get("main"),root:s.config.get("root")});var n=this.get("routes");if(n)if("string"==typeof n){var o=this;require([n],function(t){o.router.register(t)})}else"function"==typeof n&&(n=n()),this.router.register(n);return t},open:function(){if(this.opened||this.opening)return this._opening.promise();if(!this.isValid())throw new Error(this.validationError);this.opening=!0,this._opening=t.Deferred();
  var e={url:this.get("url"),type:"GET",dataType:"json"},i=this.get("credentials");i&&t.extend(e,{type:"POST",contentType:"application/json",data:JSON.stringify(i)});var n=this;return this.fetch(e).always(function(){n.opening=!1}).done(function(t,e,i){n.opened=!0,n._opening.resolveWith(n,[n,t,e,i])}).fail(function(t,e,i){n.error=i,n._opening.rejectWith(n,[this,t,e,i])}),this._opening.promise()},close:function(){this.end(),this.opening=this.opened=!1,e.each(this.data,function(t){t.reset(),delete t.url}),delete this._opening,delete this.data},start:function(t,e){if(this.started)return!1;if(!this.opened)throw new Error("Session must be opened before loaded");this.started=!0,t&&this.router.register(t),this.router.start(e),this.startPing(),this.listenTo(s,{visible:this.startPing,hidden:this.stopPing}),s.isSupported(s.getSerranoVersion())||s.notify({header:"Serrano Version Unsupported",level:"warning",timeout:!1,message:"You are connecting to an unsupported version of Serrano. Some functionality may be broken or missing due to compatibility issues."})},end:function(){this.started=!1,this.stopPing(),this.stopListening(s,"visible hidden"),this.router.unregister()}}),u=i.Collection.extend({_switch:function(t){this.active!==t&&(delete this.pending,this.close(),this.active=t,this.trigger(a.SESSION_OPENED,t))},open:function(t,e){"object"==typeof t?e=t:(e=e||{},e.url=t);var i=this.get(e.url);i||(i=new c(e),this.add(i)),i!==this.active&&i!==this.pending&&(this.pending=i,this.trigger(a.SESSION_OPENING,i));var n=this;return i.open().done(function(){n.pending===i&&n._switch(i)}).fail(function(t,e,o,r){if(n.pending===i){n.pending=null;var s;s=401===e.statusCode||403===e.statusCode?a.SESSION_UNAUTHORIZED:a.SESSION_ERROR,n.trigger(s,i,r)}})},close:function(){if(this.active){var t=this.active;delete this.active,this.remove(t),t.close(),this.trigger(a.SESSION_CLOSED,t)}},clear:function(){this.close(),this.reset()}});return e.extend({SessionManager:u,Session:c,events:a})}),define("text",["module"],function(t){var e,i,n,o,r,s=["Msxml2.XMLHTTP","Microsoft.XMLHTTP","Msxml2.XMLHTTP.4.0"],a=/^\s*<\?xml(\s)+version=[\'\"](\d)*.(\d)*[\'\"](\s)*\?>/im,l=/<body[^>]*>\s*([\s\S]+)\s*<\/body>/im,c="undefined"!=typeof location&&location.href,u=c&&location.protocol&&location.protocol.replace(/\:/,""),h=c&&location.hostname,d=c&&(location.port||void 0),p={},f=t.config&&t.config()||{};return e={version:"2.0.12",strip:function(t){if(t){t=t.replace(a,"");var e=t.match(l);e&&(t=e[1])}else t="";return t},jsEscape:function(t){return t.replace(/(['\\])/g,"\\$1").replace(/[\f]/g,"\\f").replace(/[\b]/g,"\\b").replace(/[\n]/g,"\\n").replace(/[\t]/g,"\\t").replace(/[\r]/g,"\\r").replace(/[\u2028]/g,"\\u2028").replace(/[\u2029]/g,"\\u2029")},createXhr:f.createXhr||function(){var t,e,i;if("undefined"!=typeof XMLHttpRequest)return new XMLHttpRequest;if("undefined"!=typeof ActiveXObject)for(e=0;3>e;e+=1){i=s[e];try{t=new ActiveXObject(i)}catch(n){}if(t){s=[i];break}}return t},parseName:function(t){var e,i,n,o=!1,r=t.indexOf("."),s=0===t.indexOf("./")||0===t.indexOf("../");return-1!==r&&(!s||r>1)?(e=t.substring(0,r),i=t.substring(r+1,t.length)):e=t,n=i||e,r=n.indexOf("!"),-1!==r&&(o="strip"===n.substring(r+1),n=n.substring(0,r),i?i=n:e=n),{moduleName:e,ext:i,strip:o}},xdRegExp:/^((\w+)\:)?\/\/([^\/\\]+)/,useXhr:function(t,i,n,o){var r,s,a,l=e.xdRegExp.exec(t);return l?(r=l[2],s=l[3],s=s.split(":"),a=s[1],s=s[0],!(r&&r!==i||s&&s.toLowerCase()!==n.toLowerCase()||(a||s)&&a!==o)):!0},finishLoad:function(t,i,n,o){n=i?e.strip(n):n,f.isBuild&&(p[t]=n),o(n)},load:function(t,i,n,o){if(o&&o.isBuild&&!o.inlineText)return n(),void 0;f.isBuild=o&&o.isBuild;var r=e.parseName(t),s=r.moduleName+(r.ext?"."+r.ext:""),a=i.toUrl(s),l=f.useXhr||e.useXhr;return 0===a.indexOf("empty:")?(n(),void 0):(!c||l(a,u,h,d)?e.get(a,function(i){e.finishLoad(t,r.strip,i,n)},function(t){n.error&&n.error(t)}):i([s],function(t){e.finishLoad(r.moduleName+"."+r.ext,r.strip,t,n)}),void 0)},write:function(t,i,n){if(p.hasOwnProperty(i)){var o=e.jsEscape(p[i]);n.asModule(t+"!"+i,"define(function () { return '"+o+"';});\n")}},writeFile:function(t,i,n,o,r){var s=e.parseName(i),a=s.ext?"."+s.ext:"",l=s.moduleName+a,c=n.toUrl(s.moduleName+a)+".js";e.load(l,n,function(){var i=function(t){return o(c,t)};i.asModule=function(t,e){return o.asModule(t,c,e)},e.write(t,l,i,r)},r)}},"node"===f.env||!f.env&&"undefined"!=typeof process&&process.versions&&process.versions.node&&!process.versions["node-webkit"]?(i=require.nodeRequire("fs"),e.get=function(t,e,n){try{var o=i.readFileSync(t,"utf8");0===o.indexOf("﻿")&&(o=o.substring(1)),e(o)}catch(r){n&&n(r)}}):"xhr"===f.env||!f.env&&e.createXhr()?e.get=function(t,i,n,o){var r,s=e.createXhr();if(s.open("GET",t,!0),o)for(r in o)o.hasOwnProperty(r)&&s.setRequestHeader(r.toLowerCase(),o[r]);f.onXhr&&f.onXhr(s,t),s.onreadystatechange=function(){var e,o;4===s.readyState&&(e=s.status||0,e>399&&600>e?(o=new Error(t+" HTTP status: "+e),o.xhr=s,n&&n(o)):i(s.responseText),f.onXhrComplete&&f.onXhrComplete(s,t))},s.send(null)}:"rhino"===f.env||!f.env&&"undefined"!=typeof Packages&&"undefined"!=typeof java?e.get=function(t,e){var i,n,o="utf-8",r=new java.io.File(t),s=java.lang.System.getProperty("line.separator"),a=new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(r),o)),l="";try{for(i=new java.lang.StringBuffer,n=a.readLine(),n&&n.length()&&65279===n.charAt(0)&&(n=n.substring(1)),null!==n&&i.append(n);null!==(n=a.readLine());)i.append(s),i.append(n);l=String(i.toString())}finally{a.close()}e(l)}:("xpconnect"===f.env||!f.env&&"undefined"!=typeof Components&&Components.classes&&Components.interfaces)&&(n=Components.classes,o=Components.interfaces,Components.utils["import"]("resource://gre/modules/FileUtils.jsm"),r="@mozilla.org/windows-registry-key;1"in n,e.get=function(t,e){var i,s,a,l={};r&&(t=t.replace(/\//g,"\\")),a=new FileUtils.File(t);try{i=n["@mozilla.org/network/file-input-stream;1"].createInstance(o.nsIFileInputStream),i.init(a,1,0,!1),s=n["@mozilla.org/intl/converter-input-stream;1"].createInstance(o.nsIConverterInputStream),s.init(i,"utf-8",i.available(),o.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER),s.readString(i.available(),l),s.close(),i.close(),e(l.value)}catch(c){throw new Error((a&&a.path||"")+": "+c)}}),e}),define("tpl",["module","text","underscore"],function(module,text,_){var settings=module.config()||{};return{load:function(t,e,i,n){return n.isBuild?(text.load.call(text,t,e,i,n),void 0):(e(["text!"+t],function(e){var n=e?_.template(e,void 0,settings):function(){return""};n._moduleName=t,i(n)}),void 0)},write:function(pluginName,moduleName,write,config){text.write.call(text,pluginName,moduleName,{asModule:function(name,contents){contents=contents.substr(contents.indexOf("return")+7),contents=contents.substr(0,contents.lastIndexOf(";")-3);try{var template=_.template(eval(contents),void 0,settings);write.asModule(pluginName+"!"+moduleName,"define(function() { var func = "+template.source+"; func._moduleName = '"+moduleName+"'; return func; });")}catch(err){throw console.error("~~~~~"),console.error("FAILED TO COMPILE "+pluginName+"!"+moduleName),console.error("Error:		"+String(err)),console.error("\n"),err&&err.source&&(console.error("Error Source:\n"),console.error(err.source),console.error("\n\n")),console.error("Original Contents:\n"),console.error(contents),console.error("\n\n"),err}}},config)}}}),define("tpl!templates/count.html",[],function(){var t=function(){var t="";return Array.prototype.join,t+="<span class=count></span>\n<span class=count-label></span>\n"};return t._moduleName="templates/count.html",t}),define("tpl!templates/notification.html",[],function(){var t=function(t){var e,i="";return Array.prototype.join,i+='<button class="close" data-dismiss="alert">&times;</button>\n<strong>'+(null==(e=t.header)?"":e)+"</strong>\n<span>"+(null==(e=t.message)?"":e)+"</span>\n"};return t._moduleName="templates/notification.html",t}),define("tpl!templates/paginator.html",[],function(){var t=function(){var t="";return Array.prototype.join,t+="<button class=\"btn btn-mini\" data-page=first data-toggle=tooltip title='First Page'>\n    <i class=icon-double-angle-left></i>\n    <span class='text large-display-button-text'>First</span>\n</button>\n<button class=\"btn btn-mini\" data-page=prev data-toggle=tooltip title='Previous Page' href=#>\n    <i class=icon-angle-left></i>\n    <span class='text large-display-button-text'>Prev</span>\n</button>\n<button class=\"btn btn-mini\" data-page=next data-toggle=tooltip title='Next Page' href=#>\n    <span class='text large-display-button-text'>Next</span>\n    <i class=icon-angle-right></i>\n</button>\n<button class=\"btn btn-mini\" data-page=last data-toggle=tooltip title='Last Page' href=#>\n    <span class='text large-display-button-text'>Last</span>\n    <i class=icon-double-angle-right></i>\n</button>\n<span class=page-numbers>\n    page <span class=current-page>-</span> / <span class=page-count>-</span>\n</span>\n"};return t._moduleName="templates/paginator.html",t}),define("tpl!templates/panel.html",[],function(){var t=function(){var t="";return Array.prototype.join,t+='<div class="panel-toggle"></div>\n<div class="panel-content"></div>\n'};return t._moduleName="templates/panel.html",t}),define("tpl!templates/search.html",[],function(){var t=function(){var t="";return Array.prototype.join,t+='<input type=text class="input-block-level" autocomplete=off>\n'};return t._moduleName="templates/search.html",t}),define("tpl!templates/welcome.html",[],function(){var t=function(){var t="";return Array.prototype.join,t+="<h2>Welcome!</h2>\n\n<p>If this is your <strong>first time</strong>, welcome to your data\ndiscovery and query workspace.</p>\n\n<p>Get started by <strong>searching</strong> or <strong>browsing</strong>\nsomething you are curious about on the left side. We've broken up the various\ndata you are interested into (hopefully) intuitive categories.</p>\n\n<p>When you select one of the items on the left to view, you will be\npresented with some <strong>description information</strong>,\n<strong>distribution charts</strong> (for numerical data), and various\n<strong>statistics</strong> about the data.</p>\n"};return t._moduleName="templates/welcome.html",t}),define("tpl!templates/accordion/group.html",[],function(){var t=function(t){var e,i="";return Array.prototype.join,i+='<div class=heading>\n    <span data-toggle=expand title="Expand"><i class="icon-plus icon-fixed-width"></i></span>\n    <span data-toggle=collapse title="Collapse"><i class="icon-minus icon-fixed-width"></i></span>\n    '+(null==(e=t.name)?"":e)+'\n</div>\n<div class="inner collapse">\n    <div class=sections></div>\n</div>\n'};return t._moduleName="templates/accordion/group.html",t}),define("tpl!templates/accordion/section.html",[],function(){var t=function(t){var e,i="";return Array.prototype.join,i+="<div class=heading>"+(null==(e=t.name)?"":e)+'</div>\n<ul class="items nav nav-list"></ul>\n'};return t._moduleName="templates/accordion/section.html",t}),define("tpl!templates/accordion/item.html",[],function(){var t=function(t){var e,i="";return Array.prototype.join,i+="<a href=#>"+(null==(e=t.name)?"":e)+"</a>\n"};return t._moduleName="templates/accordion/item.html",t}),define("tpl!templates/base/error-overlay.html",[],function(){var t=function(){var t="";return Array.prototype.join,t+='<h3><i class="icon-exclamation text-error"></i> Whoops, sorry.</h3>\n\n<p><strong>There was a problem syncing with the server.</strong>\n    Don\'t worry only the last change you made will have to be repeated.\n    Please refresh your browser and give it another try.</p>\n'};return t._moduleName="templates/base/error-overlay.html",t}),define("tpl!templates/button/select-option.html",[],function(){var t=function(t){var e,i="";return Array.prototype.join,i+='<a tabindex="-1" href=#>'+(null==(e=t.label)?"":e)+"</a>\n"};return t._moduleName="templates/button/select-option.html",t}),define("tpl!templates/button/select.html",[],function(){var t=function(){var t="";return Array.prototype.join,t+='<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">\n    <span class=dropdown-selection></span>\n    <span class="caret"></span>\n</a>\n<ul class="dropdown-menu"></ul>\n'};return t._moduleName="templates/button/select.html",t}),define("tpl!templates/charts/chart.html",[],function(){var t=function(){var t="";return Array.prototype.join,t+="<div class=chart-toolbar>\n    <span class=title></span>\n    <span class=status></span>\n</div>\n<div class=chart></div>\n"};return t._moduleName="templates/charts/chart.html",t}),define("tpl!templates/charts/editable-chart.html",[],function(){var t=function(){var t="";return Array.prototype.join,t+='<div class=btn-toolbar>\n    <div class=btn-group>\n        <button class="btn btn-mini fullsize" title="Toggle Fullsize"><i class=icon-resize-full alt="Toggle Fullsize"></i></button>\n        <button class="btn btn-mini outliers" title="Show Outliers" disabled><i class=icon-eye-open alt="Show Outliers"></i></button>\n    </div>\n    <div class=btn-group>\n        <button class="btn btn-mini edit" title="Edit"><i class=icon-wrench alt="Edit"></i></button>\n    </div>\n    <div class=btn-group>\n        <button class="btn btn-danger btn-mini remove" title="Remove"><i class=icon-remove alt="Remove"></i></button>\n    </div>\n</div>\n<div class=heading>\n    <span class=title></span>\n    <span class=status></span>\n</div>\n<div class=editable>\n    <form class=form>\n        <fieldset>\n            <label>X-Axis <select name=x-axis></select></label>\n            <label>Y-Axis <select name=y-axis></select></label>\n            <label>Series <select name=series></select></label>\n            <button class="btn btn-primary">Update</button>\n        </fieldset>\n    </form>\n</div>\n<div class=chart></div>\n'};return t._moduleName="templates/charts/editable-chart.html",t}),define("tpl!templates/concept/columns/available-group.html",[],function(){var t=function(t){var e,i="";return Array.prototype.join,i+="<div class=heading>\n    "+(null==(e=t.name)?"":e)+'\n    <button data-action=add-group class="btn btn-mini pull-right" title="Add items in '+(null==(e=t.name)?"":e)+'"><i class="icon-plus text-success"></i> Group</button>\n</div>\n<div class="inner collapse">\n    <div class=sections></div>\n</div>\n'};return t._moduleName="templates/concept/columns/available-group.html",t}),define("tpl!templates/concept/columns/available-section.html",[],function(){var t=function(t){var e,i="";return Array.prototype.join,i+="<div class=heading>\n    "+(null==(e=t.name)?"":e)+'\n    <button data-action=add-section class="btn btn-mini pull-right" title="Add items in '+(null==(e=t.name)?"":e)+'"><i class="icon-plus text-success"></i> Section</button>\n</div>\n<ul class="items nav nav-list"></ul>\n'};return t._moduleName="templates/concept/columns/available-section.html",t}),define("tpl!templates/concept/columns/available-item.html",[],function(){var t=function(t){var e,i="";return Array.prototype.join,i+="<span class=name>"+(null==(e=t.name)?"":e)+'</span>\n<button data-action=add class="btn btn-mini" title="Add '+(null==(e=t.name)?"":e)+'"><i class="icon-plus text-success"></i></button>\n'};return t._moduleName="templates/concept/columns/available-item.html",t}),define("tpl!templates/concept/columns/selected-item.html",[],function(){var t=function(t){var e,i="";return Array.prototype.join,i+="<span class=name>"+(null==(e=t.name)?"":e)+'</span>\n<button data-action=remove class="btn btn-mini"><i class="icon-remove text-error"></i></button>\n'};return t._moduleName="templates/concept/columns/selected-item.html",t}),define("tpl!templates/concept/columns/layout.html",[],function(){var t=function(){var t="";return Array.prototype.join,t+='<div class=available-column>\n    <div class="search-region"></div>\n    <div class="available-region"></div>\n</div>\n\n<div class=selected-column>\n    <div class=toolbar>\n        <button type=button data-action=clear class="btn btn-mini btn-danger"><i class="icon-remove icon-white"></i> Clear</button>\n        <strong>Click, drag and drop</strong> to change the order.\n    </div>\n    <div class="selected-region"></div>\n</div>\n'};return t._moduleName="templates/concept/columns/layout.html",t}),define("tpl!templates/concept/columns/dialog.html",[],function(){var t=function(){var t="";return Array.prototype.join,t+="<div class=modal-header>\n    <h3>Change Columns <small>Add, remove, and reorder columns for output</small></h3>\n</div>\n\n<div class=modal-body>\n    <div data-target=error class='alert alert-error alert-block hide'></div>\n    <div class='row-fluid concept-columns-region'></div>\n</div>\n\n<div class=modal-footer>\n    <button data-dismiss=modal class=btn>Cancel</button>\n    <button data-save class='btn btn-primary'>Save</button>\n</div>\n"};return t._moduleName="templates/concept/columns/dialog.html",t}),define("tpl!templates/concept/error.html",[],function(){var t=function(t){var e,i="";return Array.prototype.join,i+='<h3><i class="icon-exclamation text-error"></i> Whoops, sorry.</h3>\n\n<strong>There was a problem loading "'+(null==(e=t.name)?"":e)+'"</strong>\n'};return t._moduleName="templates/concept/error.html",t}),define("tpl!templates/concept/form.html",[],function(){var t=function(){var t="";return Array.prototype.join,t+="<div class=info-region></div>\n<div class=links-region></div>\n<div class=fields-region></div>\n"};return t._moduleName="templates/concept/form.html",t}),define("tpl!templates/concept/info.html",[],function(){var t=function(t){var e,i="";return Array.prototype.join,i+="",t.category&&(i+="\n    <p class=category>\n        ",t.category.parent&&(i+="\n            <a href='#' class=category-link>"+(null==(e=t.category.parent.name)?"":e)+"</a>\n            <i class=icon-angle-right></i>\n        "),i+="\n        <a href='#' class=category-link>"+(null==(e=t.category.name)?"":e)+"</a>\n    </p>\n"),i+="\n\n<p class=name>\n    "+(null==(e=t.name)?"":e)+"\n    ",t.unit&&(i+="\n        <small class=unit>"+(null==(e=t.unit)?"":e)+"</small>\n    "),i+="\n</p>\n\n",t.description&&(i+='\n    <div class="description ellipsis">\n        <div class="text">'+(null==(e=t.description)?"":e)+"</div>\n        <a class=toggle href=#>read more</a>\n    </div>\n"),i+="\n"};return t._moduleName="templates/concept/info.html",t}),define("tpl!templates/concept/panel.html",[],function(){var t=function(){var t="";return Array.prototype.join,t+="<div class=panel-content>\n    <div class=search-region></div>\n    <div class=index-region></div>\n</div>\n"};return t._moduleName="templates/concept/panel.html",t}),define("tpl!templates/concept/workspace.html",[],function(){var t=function(){var t="";return Array.prototype.join,t+='<div class="main-region"></div>\n'};return t._moduleName="templates/concept/workspace.html",t}),define("tpl!templates/concept/popover.html",[],function(){var t=function(t){var e,i="";return Array.prototype.join,i+='<div class="arrow"></div>\n<h4 class="popover-title">'+(null==(e=t.name)?"":e)+'</h4>\n<div class="popover-content">\n    <p>'+(null==(e=t.description)?"":e)+"</p>\n    ",t.fields&&(i+="\n        <p class=muted>Included fields: "+(null==(e=t.fields)?"":e)+"</p>\n    "),i+="\n</div>\n"};return t._moduleName="templates/concept/popover.html",t}),define("tpl!templates/export/dialog.html",[],function(){var t=function(){var t="";return Array.prototype.join,t+='<div class=modal-header>\n    <a class=close data-dismiss=modal><i class=icon-remove></i></a>\n    <h3>Exporter<small> Choose export options and pages</small></h3>\n</div>\n\n<div class=modal-body>\n    <div data-target=error class="alert alert-error alert-block hide"></div>\n\n    <div class=row-fluid>\n        <div class=span6>\n            <h4>Types</h4>\n\n            <div data-target="types"></div>\n        </div>\n\n        <div class=span6>\n            <h4>Pages</h4>\n\n            <label class=radio>\n                <input type=radio name=pages value=all checked> All pages\n            </label>\n\n            <label class=radio>\n                <input type=radio name=pages value=range> Single page or range\n                <input type=text name=page-range placeholder="e.g. 1, 1...4" disabled>\n            </label>\n        </div>\n    </div>\n\n    <div data-target="progress"></div>\n</div>\n\n<div class=modal-footer>\n    <button data-dismiss=modal class=btn>Close</button>\n    <button data-toggle=save class="btn btn-primary">Export</button>\n</div>\n'};return t._moduleName="templates/export/dialog.html",t}),define("tpl!templates/export/option.html",[],function(){var t=function(t){var e,i="";return Array.prototype.join,i+='<input type=checkbox value="'+(null==(e=t.type)?"":e)+'" title="'+(null==(e=t.title)?"":e)+'"> '+(null==(e=t.title)?"":e)+"\n"};return t._moduleName="templates/export/option.html",t}),define("tpl!templates/export/batch.html",[],function(){var t=function(){var t="";return Array.prototype.join,t+="<h4>Downloads</h4>\n"};return t._moduleName="templates/export/batch.html",t}),define("tpl!templates/export/progress.html",[],function(){var t=function(t){var e,i="";return Array.prototype.join,i+="<div class=row-fluid>\n    <div class=span2>\n        <span>"+(null==(e=t.title)?"":e)+'</span>\n    </div>\n    <div class=span8>\n        <span data-target=status><span class="label">Pending...</span></span>\n    </div>\n    <div class=span2>\n        <a href=# data-target=cancel class=text-error><i class="icon-remove" /> Cancel</a>\n    </div>\n</div>\n\n'};return t._moduleName="templates/export/progress.html",t}),define("tpl!templates/context/panel.html",[],function(){var t=function(){var t="";return Array.prototype.join,t+='<div class="panel-content">\n    <div class=actions-region></div>\n    <div class=filters-region></div>\n    <div class=info-region></div>\n</div>\n'};return t._moduleName="templates/context/panel.html",t}),define("tpl!templates/context/actions.html",[],function(){var t=function(t){var e,i="";return Array.prototype.join,i+='<div class=pull-right>\n    <button data-action=remove class="btn btn-danger btn-mini" title="Remove All Filters" disabled><i class="icon-remove icon-white"></i></button>\n</div>\n\n<div class=count-label>\n    ',i+=null==t.count?"\n        <span class=count>All</span>\n    ":'\n        <span class=count title="'+(null==(e=t.count)?"":e)+'">'+(null==(e=t.prettyCount)?"":e)+"</span>\n    ",i+="\n    <span class=units>\n        ",i+=1==t.count?"\n            "+(null==(e=t.object_name)?"":e)+"\n        ":"\n            "+(null==(e=t.object_name_plural)?"":e)+"\n        ",i+='\n    </span>\n    <i class="icon-spinner icon-spin hide"></i>\n</div>\n'};return t._moduleName="templates/context/actions.html",t}),define("tpl!templates/context/info.html",[],function(){var t=function(){var t="";return Array.prototype.join,t+='<button data-route=query class="btn btn-primary input-block-level"><i class=icon-search></i> Refine Query</button>\n<button data-route=results class="btn btn-primary input-block-level"><i class=icon-table></i> View Results</button>\n'};return t._moduleName="templates/context/info.html",t}),define("tpl!templates/context/empty.html",[],function(){var t=function(){var t="";return Array.prototype.join,t+="<h4>No filters are applied</h4>\n\n<p class='no-filters-query-workspace'>Explore the available filters on the left side or click \"View Results\"\nto immediately preview some data.</p>\n<p class='no-filters-results-workspace'>Browse the data in the table to the left or click \"Refine Query\"\nto create and add filters.</p>\n"};return t._moduleName="templates/context/empty.html",t}),define("tpl!templates/context/filter.html",[],function(){var t=function(t){var e,i="";return Array.prototype.join,i+='<div data-target=actions>\n    <button data-action=remove class="btn btn-mini" title="Remove"><i class=icon-remove></i></button>\n</div>\n<input data-action=enable type=checkbox title="Disable" checked>\n<span data-target=required class=text-warning title="This filter is required and cannot be disabled or removed, only changed"><i class="icon-lock"></i></span>\n<div data-target=description>'+(null==(e=t.language)?"":e)+'</div>\n<div data-target=loader class=hide><i class="icon-spinner icon-spin"></i></div>\n'};return t._moduleName="templates/context/filter.html",t}),define("tpl!templates/controls/infograph/bar.html",[],function(){var t=function(t){var e,i="";return Array.prototype.join,i+='<div class=bar style="width:'+(null==(e=t.width)?"":e)+'%"></div>\n<div class=bar-mask>\n    <span class=bar-label>'+(null==(e=t.value)?"":e)+"</span>\n    <span class=bar-count>\n        "+(null==(e=t.count)?"":e)+"\n        <span class=bar-percentage>("+(null==(e=t.percentage)?"":e)+"%)</span>\n    </span>\n</div>\n"};return t._moduleName="templates/controls/infograph/bar.html",t}),define("tpl!templates/controls/infograph/layout.html",[],function(){var t=function(){var t="";return Array.prototype.join,t+="<div class=toolbar-region></div>\n<div data-target='loading-indicator'>\n    <i class=\"icon-spinner icon-spin\"></i> Loading values...\n</div>\n<div class=bars-region></div>\n"};return t._moduleName="templates/controls/infograph/layout.html",t}),define("tpl!templates/controls/infograph/toolbar.html",[],function(){var t=function(){var t="";return Array.prototype.join,t+="<div class=navbar-inner>\n    <div class=btn-toolbar>\n        <div class=\"navbar-form\">\n            <button class=\"btn invert-button\" name=invert title=\"Invert Selection\">Invert Selection</button>\n            <span class='filter-container'>\n                <input class=filter-text type=text name=filter placeholder=\"Filter values...\">\n            </span>\n            <div class='exclude-container'>\n                <input class='exclude-checkbox' type='checkbox' name='exclude' /> <span class='exclude-label'>Exclude selected values</span>\n            </div>\n        </div>\n    </div>\n</div>\n<div class=sort-region>\n    <span class=sort-value-header>Value <i class=icon-sort></i></span><span class=sort-count-header>Count <i class=icon-sort-down></i></span>\n</div>\n"};return t._moduleName="templates/controls/infograph/toolbar.html",t}),define("tpl!templates/controls/range/layout.html",[],function(){var t=function(){var t="";return Array.prototype.join,t+='<input type=text class="range-lower" placeholder="[lower bound]" />\n<span class=muted> and </span>\n<input type=text class="range-upper" placeholder="[upper bound]"/>\n<a class="btn range-help-button" href="#" title="Show/hide help text"><i class="icon-question-sign"></i></a>\n<span class="help-block">Entering a value on the left while leaving the right empty represents a filter matching all values greater than or equal to the supplied value. Conversely, entering a value on the right and leaving the left empty represents a filter matching all values less than or equal to the supplied value. Entering values in both boxes will match all values within the range specified. The opposite applies when <strong>not between</strong> is selected from the choices above.</span>\n'};return t._moduleName="templates/controls/range/layout.html",t}),define("tpl!templates/controls/select/layout.html",[],function(){var t=function(){var t="";return Array.prototype.join,t+="<div class=select-region></div>\n"};return t._moduleName="templates/controls/select/layout.html",t}),define("tpl!templates/controls/select/list.html",[],function(){var t=function(){var t="";return Array.prototype.join,t+="<select class=items>\n</select>\n"};return t._moduleName="templates/controls/select/list.html",t}),define("tpl!templates/controls/search/layout.html",[],function(){var t=function(){var t="";return Array.prototype.join,t+="<div class=row-fluid>\n    <div class='span6'>\n        <div class=toolbar>\n            <button type=button data-action=clear class='btn btn-mini btn-danger'>\n                <i class='icon-remove icon-white'></i>Clear\n            </button>\n            <div class=paginator-region></div>\n        </div>\n        <div class=search-region></div>\n        <div class=browse-region></div>\n    </div>\n    <div class='span6 values-region'></div>\n</div>\n"};return t._moduleName="templates/controls/search/layout.html",t}),define("tpl!templates/controls/search/item.html",[],function(){var t=function(t){var e,i="";return Array.prototype.join,i+='<div class=actions>\n    <button class="btn btn-mini add-item-button"><i class="icon-plus text-success"></i></button>\n    <button class="btn btn-mini hide remove-item-button"><i class="icon-minus text-error"></i></button>\n</div>\n<span class=value-label>'+(null==(e=t.label)?"":e)+"</span>\n"};return t._moduleName="templates/controls/search/item.html",t}),define("tpl!templates/controls/null/layout.html",[],function(){var t=function(){var t="";return Array.prototype.join,t+="<select data-target='null-selector'>\n    <option data-target='not-null-option' value='false'>Exists</option>\n    <option data-target='null-option' value='true'>Does not exist</option>\n</select>\n"};return t._moduleName="templates/controls/null/layout.html",t}),define("tpl!templates/controls/text/layout.html",[],function(){var t=function(){var t="";return Array.prototype.join,t+="<div data-target='search-region'></div>\n<p class='muted'>Wrap two or more words with quotes to match explicitly. Prefix a single keyword or quoted text with a \"+\" (plus sign) to require matching on the keyword or \"-\" (minus sign) to prevent matching on the keyword.</p>\n<div data-target='preview-region'></div>\n"};return t._moduleName="templates/controls/text/layout.html",t}),define("tpl!templates/controls/text/preview-list.html",[],function(){var t=function(){var t="";return Array.prototype.join,t+="<h4>Preview</h4>\n\n<p class=muted>Note, these preview texts may not be in your final query results depending on the other filters applied.</p>\n\n<div class='items'></div>\n"};return t._moduleName="templates/controls/text/preview-list.html",t}),define("tpl!templates/controls/text/preview-item.html",[],function(){var t=function(t){var e,i="";return Array.prototype.join,i+=""+(null==(e=t.label)?"":e)+"\n"};return t._moduleName="templates/controls/text/preview-item.html",t}),define("tpl!templates/controls/vocab/layout.html",[],function(){var t=function(){var t="";return Array.prototype.join,t+="<div class=row-fluid>\n    <div class='span6'>\n        <div class=toolbar>\n            <div class=paginator-region></div>\n        </div>\n        <div class=search-region></div>\n        <div class=path-region></div>\n        <div class=browse-region></div>\n    </div>\n    <div class='span6 buckets-region'></div>\n</div>\n"};return t._moduleName="templates/controls/vocab/layout.html",t}),define("tpl!templates/controls/vocab/path.html",[],function(){var t=function(t){var e,i="";return Array.prototype.join,i+="<div class=toolbar>\n    <button class='btn btn-mini' ",t.url||(i+="disabled"),i+="><i class='icon-angle-left'></i> Back</button>\n    <strong class='path-label' title='"+(null==(e=t.label)?"":e)+"'>"+(null==(e=t.label)?"":e)+"</strong>\n</div>\n"};return t._moduleName="templates/controls/vocab/path.html",t}),define("tpl!templates/controls/vocab/item.html",[],function(){var t=function(t){var e,i="";return Array.prototype.join,i+="<div class=actions>\n    <button class='btn btn-mini add-item-button'><i class='icon-plus text-success'></i></button>\n    <button class='btn btn-mini hide remove-item-button'><i class='icon-minus text-error'></i></button>\n</div>\n",i+=t.url?"\n    <a class=value-label href='"+(null==(e=t.url)?"":e)+"'>"+(null==(e=t.label)?"":e)+"</a>\n":"\n    <span class=value-label>"+(null==(e=t.label)?"":e)+"</span>\n",i+="\n"};return t._moduleName="templates/controls/vocab/item.html",t}),define("tpl!templates/controls/vocab/bucket.html",[],function(){var t=function(t){var e,i="";return Array.prototype.join,i+="<strong>"+(null==(e=t.name)?"":e)+"</strong>\n<div class=value-list data-target=items></div>\n"
  };return t._moduleName="templates/controls/vocab/bucket.html",t}),define("tpl!templates/controls/vocab/bucket-item.html",[],function(){var t=function(t){var e,i="";return Array.prototype.join,i+="<div class=actions>\n    <button data-target=remove class='btn btn-mini'><i class='icon-minus text-error'></i></button>\n</div>\n<span class=value-label data-value='"+(null==(e=t.value)?"":e)+"'>"+(null==(e=t.label)?"":e)+"</span>\n"};return t._moduleName="templates/controls/vocab/bucket-item.html",t}),define("tpl!templates/field/form-condensed.html",[],function(){var t=function(){var t="";return Array.prototype.join,t+="<div class=row-fluid>\n    <div class=span4>\n        <div class=info-region></div>\n        <div class=stats-region></div>\n    </div>\n    <div class=span8>\n        <div class=controls-region></div>\n    </div>\n</div>\n"};return t._moduleName="templates/field/form-condensed.html",t}),define("tpl!templates/field/form.html",[],function(){var t=function(){var t="";return Array.prototype.join,t+='<div class=info-region></div>\n<div class=stats-region></div>\n<div class=chart-region></div>\n<div class=controls-region></div>\n\n<div class=actions-region>\n    <button data-action=update class="btn btn-primary btn-small">Update Filter</button>\n    <button data-action=apply class="btn btn-success btn-small">Apply Filter</button>\n    <div data-target=state class="alert hide"></div>\n</div>\n'};return t._moduleName="templates/field/form.html",t}),define("tpl!templates/field/info.html",[],function(){var t=function(t){var e,i="";return Array.prototype.join,i+="<h4 class=name>\n    "+(null==(e=t.alt_name||t.name)?"":e)+"\n    ",t.unit&&(i+="\n        <small class=unit>"+(null==(e=t.unit)?"":e)+"</small>\n    "),i+="\n</h4>\n\n",t.description&&(i+="\n    <p class=field-description>"+(null==(e=t.description)?"":e)+"</p>\n"),i+="\n"};return t._moduleName="templates/field/info.html",t}),define("tpl!templates/field/stats.html",[],function(){var t=function(){var t="";return Array.prototype.join,t+="<div class=stats-values></div>\n<div class=stats-chart></div>\n"};return t._moduleName="templates/field/stats.html",t}),define("tpl!templates/field/links.html",[],function(){var t=function(){var t="";return Array.prototype.join,t+='Jump to: <ul class="links" data-target="links"></ul>\n'};return t._moduleName="templates/field/links.html",t}),define("tpl!templates/field/link.html",[],function(){var t=function(t){var e,i="";return Array.prototype.join,i+="<a>"+(null==(e=t.name)?"":e)+"</a>\n"};return t._moduleName="templates/field/link.html",t}),define("tpl!templates/query/delete-dialog.html",[],function(){var t=function(){var t="";return Array.prototype.join,t+='<div class=modal-header>\n    <h4></h4>\n</div>\n\n<div class=modal-body>\n    <div class="alert alert-error hide"></div>\n    <p>Are you sure you want to delete this query?</p>\n</div>\n\n<div class=modal-footer>\n    <button data-dismiss=modal class=btn>No</button>\n    <button class="btn btn-primary delete-query-button">Yes</button>\n</div>\n'};return t._moduleName="templates/query/delete-dialog.html",t}),define("tpl!templates/query/edit-dialog.html",[],function(){var t=function(){var t="";return Array.prototype.join,t+='<div class=modal-header>\n    <h4></h4>\n</div>\n\n<div class=modal-body>\n    <div class="alert alert-error hide"></div>\n    <form class="form-inline">\n        <div class="control-group row-fluid">\n            <label class=control-label>Name</label>\n            <div class=controls>\n                <input type=text class="query-name span12" placeholder="Query name (required)..." />\n            </div>\n        </div>\n        <div class="control-group row-fluid">\n            <label class=control-label>Description</label>\n            <div class=controls>\n                <input type=text class="query-description span12" placeholder="Additional description or details (optional)..." />\n            </div>\n        </div>\n        <div class="checkbox">\n            <label>\n                <input type=checkbox name=\'query-publicity\' class="query-publicity" />Should this query be publicly available to all users?\n            </label>\n        </div>\n        <div class="control-group row-fluid">\n            <label class=control-label>Share</label>\n            <div class=controls>\n                <textarea rows=6 class="query-emails span12" placeholder="Enter the email addresses or usernames of the users to share this query with. Separate multiple entries using a comma (optional)..."></textarea>\n            </div>\n        </div>\n    </form>\n</div>\n\n<div class=modal-footer>\n    <button data-dismiss=modal class=btn>Cancel</button>\n    <button data-save class="btn btn-primary">Save</button>\n</div>\n'};return t._moduleName="templates/query/edit-dialog.html",t}),define("tpl!templates/query/item.html",[],function(){var t=function(t){var e,i="";return Array.prototype.join,i+="<span class='owner'>\n    <button data-toggle=edit-query-modal class='btn btn-mini edit-query'><i class=icon-pencil></i> Edit</button>\n    <button data-toggle=delete-query-modal class='btn btn-mini delete-query'><i class='icon-remove text-error'></i> Delete</button>\n    <i class='public-icon icon-external-link-sign muted' title='Private query'></i>\n    <i class='icon-group share-count muted' title='Not shared'> <strong>"+(null==(e=t.shared_users.length)?"":e)+"</strong></i>\n</span>\n\n<span class='non-owner'>\n    shared by <em>"+(null==(e=t.user.username)?"":e)+"</em>\n</span>\n\n<span class='name-label'>\n    <a data-target='query' href='#'>"+(null==(e=t.name)?"":e)+"</a>\n    <a data-target=toggle-details href=#>Show details</a>\n</span>\n\n<div class='details' data-target=details></div>\n"};return t._moduleName="templates/query/item.html",t}),define("tpl!templates/query/list.html",[],function(){var t=function(){var t="";return Array.prototype.join,t+='<div class=query-list>\n    <div class=header>\n        <h4 class=\'title\'></h4>\n    </div>\n    <div class="empty-message"></div>\n    <div class="loading-indicator hide">\n        <i class="icon-spinner icon-spin"></i> Loading...\n    </div>\n    <div class="alert alert-danger error-message hide">There was a problem retrieving the queries. Please reload the page to try to reload the queries.</div>\n    <div class=items></div>\n</div>\n'};return t._moduleName="templates/query/list.html",t}),define("tpl!templates/query/loader.html",[],function(){var t=function(){var t="";return Array.prototype.join,t+="<div class='loading-message'>\n    <i class=\"icon-spinner icon-spin\"></i> Loading Query...\n</div>\n<div class='error-message alert alert-block hide'>\n    <i class=\"icon-exclamation\"></i> <strong>Uh oh.</strong> There was an error opening the query. Your filters and view have not been changed. It is possible that this query has been removed. To try opening this query again, please navigate to the Workspace page and clicking on the query from the list shown on that page.\n</div>\n"};return t._moduleName="templates/query/loader.html",t}),define("tpl!templates/values/item.html",[],function(){var t=function(t){var e,i="";return Array.prototype.join,i+=""+(null==(e=t.label)?"":e)+"\n"};return t._moduleName="templates/values/item.html",t}),define("tpl!templates/values/list.html",[],function(){var t=function(){var t="";return Array.prototype.join,t+='<textarea placeholder="Enter or paste a list of values (one per line) or search and add values one-by-one from the left..."></textarea>\n'};return t._moduleName="templates/values/list.html",t}),define("tpl!templates/workflows/query.html",[],function(){var t=function(){var t="";return Array.prototype.join,t+='<div class="concept-workspace-region"></div>\n'};return t._moduleName="templates/workflows/query.html",t}),define("tpl!templates/workflows/results.html",[],function(){var t=function(){var t="";return Array.prototype.join,t+='<div class="navbar navbar-masthead results-workflow-navbar">\n    <div class="navbar-inner">\n        <div class="navbar-text pull-right">\n            <span class="paginator-region"></span>\n            <button data-toggle=columns-dialog class="btn btn-primary btn-mini" title="Change Columns">\n                <i class=icon-columns></i> <span class=large-display-button-text>Change Columns...</span>\n            </button>\n            <button data-toggle=exporter-dialog class="btn btn-primary btn-mini" title="Export Data">\n                <i class=icon-file></i> <span class=large-display-button-text>Export...</span>\n            </button>\n            <button data-toggle=query-dialog class="btn btn-primary btn-mini" title="Save New Query">\n                <i class=icon-save></i> <span class=large-display-button-text>Save Query...</span>\n            </button>\n            <button data-toggle=context-panel class="btn btn-primary btn-mini expand-collapse" title="Hide Filter Panel">\n                <i class=icon-expand-alt></i> <span class=large-display-button-text>Hide Filters</span>\n            </button>\n        </div>\n        <span class="navbar-text count-region"></span>\n    </div>\n</div>\n\n<div class="loading-overlay hide">\n    <h4><i class="icon-spinner icon-spin"></i> Loading Results</h4>\n</div>\n\n<div class=table-region></div>\n'};return t._moduleName="templates/workflows/results.html",t}),define("tpl!templates/workflows/workspace.html",[],function(){var t=function(){var t="";return Array.prototype.join,t+='<div class=row-fluid>\n    <div class="query-region span6"></div>\n    <div class="public-query-region span6"></div>\n</div>\n'};return t._moduleName="templates/workflows/workspace.html",t}),define("cilantro/ui/templates",["underscore","loglevel","tpl!templates/count.html","tpl!templates/notification.html","tpl!templates/paginator.html","tpl!templates/panel.html","tpl!templates/search.html","tpl!templates/welcome.html","tpl!templates/accordion/group.html","tpl!templates/accordion/section.html","tpl!templates/accordion/item.html","tpl!templates/base/error-overlay.html","tpl!templates/button/select-option.html","tpl!templates/button/select.html","tpl!templates/charts/chart.html","tpl!templates/charts/editable-chart.html","tpl!templates/concept/columns/available-group.html","tpl!templates/concept/columns/available-section.html","tpl!templates/concept/columns/available-item.html","tpl!templates/concept/columns/selected-item.html","tpl!templates/concept/columns/layout.html","tpl!templates/concept/columns/dialog.html","tpl!templates/concept/error.html","tpl!templates/concept/form.html","tpl!templates/concept/info.html","tpl!templates/concept/panel.html","tpl!templates/concept/workspace.html","tpl!templates/concept/popover.html","tpl!templates/export/dialog.html","tpl!templates/export/option.html","tpl!templates/export/batch.html","tpl!templates/export/progress.html","tpl!templates/context/panel.html","tpl!templates/context/actions.html","tpl!templates/context/info.html","tpl!templates/context/empty.html","tpl!templates/context/filter.html","tpl!templates/controls/infograph/bar.html","tpl!templates/controls/infograph/layout.html","tpl!templates/controls/infograph/toolbar.html","tpl!templates/controls/range/layout.html","tpl!templates/controls/select/layout.html","tpl!templates/controls/select/list.html","tpl!templates/controls/search/layout.html","tpl!templates/controls/search/item.html","tpl!templates/controls/null/layout.html","tpl!templates/controls/text/layout.html","tpl!templates/controls/text/preview-list.html","tpl!templates/controls/text/preview-item.html","tpl!templates/controls/vocab/layout.html","tpl!templates/controls/vocab/path.html","tpl!templates/controls/vocab/item.html","tpl!templates/controls/vocab/bucket.html","tpl!templates/controls/vocab/bucket-item.html","tpl!templates/field/form-condensed.html","tpl!templates/field/form.html","tpl!templates/field/info.html","tpl!templates/field/stats.html","tpl!templates/field/links.html","tpl!templates/field/link.html","tpl!templates/query/delete-dialog.html","tpl!templates/query/edit-dialog.html","tpl!templates/query/item.html","tpl!templates/query/list.html","tpl!templates/query/loader.html","tpl!templates/values/item.html","tpl!templates/values/list.html","tpl!templates/workflows/query.html","tpl!templates/workflows/results.html","tpl!templates/workflows/workspace.html"],function(t,e){var i={},n={},o=function(t){return"/"===t.charAt(0)&&(t=t.substr(1)),t=t.replace(/\.\.\//g,""),t.replace(/templates\//,"").replace(/\.html$/,"")},r=[].slice.call(arguments,2);t.each(r,function(t){t.templateId=o(t._moduleName),i[t.templateId]=t});var s=0,a=function(t,i){s++,require([i],function(e){t||(t=e,e=null),l(t,e),s--},function(t){e.debug(t),s--})},l=function(t,e){if("function"==typeof t){if(e=t,!e._moduleName)throw new Error("cannot register anonymous template");t=o(e._moduleName)}else e||(e=t,t=null);switch(typeof e){case"function":n[t]=e;break;case"string":a(t,e);break;default:throw new Error("template must be a function or AMD module")}};return{get:function(t){return n[t]||i[t]},set:function(e,i){t.isArray(e)?t.each(e,function(t){this.set(t)},this):t.isFunction(e)?l(e):t.isObject(e)?t.each(e,function(t,e){this.set(e,t)},this):l(e,i)},ready:function(){return 0===s},clear:function(){n={}}}}),define("cilantro/ui/controls/base",["jquery","underscore","backbone","marionette","../../core"],function(t,e,i,n,o){var r=function(){},s={className:"control",attrNames:["concept","field","operator","value"],attrGetters:{concept:"getConcept",field:"getField",operator:"getOperator",value:"getValue"},attrSetters:{concept:"setConcept",field:"setField",operator:"setOperator",value:"setValue"},_get:function(t,e){var i,n;if(i=this.attrGetters[t]){if(n=this[i])return n.call(this,e);throw new Error("Getter declared, but not defined for "+t)}},_set:function(t,e,i){var n,o;if(n=this.attrSetters[t]){if(o=this[n])return o.call(this,e,i);throw new Error("Setter declared, but not defined for "+t)}},wait:function(){if(!this._waiting){this._waiting=!0;var t=this,e=setTimeout(function(){t.trigger("error")},o.config.get("timeouts.control"));this.on("beforeready error",function(){clearTimeout(e)})}},ready:function(t){t&&this._waiting||(delete this._waiting,this.trigger("beforeready"),this.trigger("ready"))},get:function(t,i){if(e.isObject(t)&&(i=t,t=null),t)return this._get(t,i);for(var n,o={},r=0;r<this.attrNames.length;r++)t=this.attrNames[r],void 0!==(n=this._get(t,i))&&(o[t]=n);return o},set:function(t,n,o){var r;e.isObject(t)?(r=t instanceof i.Model?t.toJSON():t,o=n):(r={})[t]=n;for(t in r)void 0!==(n=r[t])&&this._set(t,n,o)},clear:function(t,i){e.isObject(t)&&(i=t,t=null);var n={};if(t)n[t]=void 0;else for(var o=0;o<this.attrNames.length;o++)t=this.attrNames[o],n[t]=void 0;this._set(n,i)},change:function(){this._changing=!0,this.trigger("change",this,this.get()),delete this._changing},validate:function(){},getConcept:r,getField:r,getOperator:r,getValue:r,setConcept:r,setField:r,setOperator:r,setValue:r},a=n.View.extend({}),l=n.ItemView.extend({}),c=n.CollectionView.extend({}),u=n.CompositeView.extend({}),h=n.Layout.extend({});return e.defaults(a.prototype,s),e.defaults(l.prototype,s),e.defaults(c.prototype,s),e.defaults(u.prototype,s),e.defaults(h.prototype,s),{ControlViewMixin:s,ControlView:a,ControlItemView:l,ControlCollectionView:c,ControlCompositeView:u,ControlLayout:h,Control:h}});var __hasProp={}.hasOwnProperty,__extends=function(t,e){function i(){this.constructor=t}for(var n in e)__hasProp.call(e,n)&&(t[n]=e[n]);return i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype,t};define("cilantro/ui/button",["underscore","backbone","marionette"],function(t,e,i){var n,o,r,s,a;return o=function(t){function e(){return s=e.__super__.constructor.apply(this,arguments)}return __extends(e,t),e.prototype.className="disabled",e.prototype.tagName="li",e.prototype.template="button/select-option",e.prototype.events={click:"prevent"},e.prototype.prevent=function(t){return null!=t?t.preventDefault():void 0},e.prototype.serializeData=function(){return{label:"No options are available"}},e}(i.ItemView),r=function(t){function e(){return a=e.__super__.constructor.apply(this,arguments)}return __extends(e,t),e.prototype.tagName="li",e.prototype.template="button/select-option",e.prototype.events={click:"select"},e.prototype.serializeData=function(){return{label:this.model.get("label")||this.model.get("value")}},e.prototype.select=function(t){return null!=t&&t.preventDefault(),this.model.set("selected",!0)},e}(i.ItemView),n=function(t){function i(t){var n,o;null==t&&(t={}),t.collection instanceof e.Collection||(null!=(n=t.collection)&&"object"!=typeof n[0]&&(n=function(){var t,e,i;for(i=[],t=0,e=n.length;e>t;t++)o=n[t],i.push({value:o,label:o});return i}()),t.collection=new e.Collection(n)),i.__super__.constructor.call(this,t)}return __extends(i,t),i.prototype.className="btn-group btn-select",i.prototype.template="button/select",i.prototype.itemView=r,i.prototype.itemViewContainer=".dropdown-menu",i.prototype.emptyView=o,i.prototype.options={placeholder:"----"},i.prototype.ui={toggle:".dropdown-toggle",menu:".dropdown-menu",selection:".dropdown-selection"},i.prototype.collectionEvents={"change:selected":"updateSelection"},i.prototype.setSelection=function(t){var e;return(e=this.collection.findWhere({value:t}))?e.set("selected",!0):void 0},i.prototype.getSelection=function(){var t;return(t=this.collection.findWhere({selected:!0}))?t.get("value"):void 0},i.prototype.updateSelection=function(t,e,i){var n;if(e)return n=t.get("value"),this.collection.each(function(e){return e!==t?e.set("selected",!1,{silent:!0}):void 0}),this.ui.selection.html(t.get("label")||n),this.$el.trigger("change",n),this.trigger("change",t,n,i)},i.prototype.onRender=function(){var t;return/^(small|large|mini)$/.test(this.options.size)&&this.ui.toggle.addClass("btn-"+this.options.size),this.ui.toggle.dropdown(),(t=this.collection.findWhere({selected:!0}))?this.updateSelection(t,!0):this.ui.selection.html(this.options.placeholder)},i}(i.CompositeView),{ButtonSelect:n}}),define("cilantro/ui/controls/range",["underscore","./base","../button","../../constants"],function(t,e,i,n){var o=e.Control.extend({template:"controls/range/layout",events:{"keyup .range-lower, .range-upper":"_change","change .btn-select":"_change","click .range-help-button":"toggleHelpText"},ui:{operatorSelect:".btn-select",lowerBound:".range-lower",upperBound:".range-upper",help:".help-block"},initialize:function(){this._change=t.debounce(this.change,n.INPUT_DELAY)},onRender:function(){this.operatorSelect=new i.ButtonSelect({collection:[{value:"range",label:"between",selected:!0},{value:"-range",label:"not between"}]}),this.operatorSelect.render().$el.prependTo(this.$el),this.ui.help.hide(),this.renderBounds(),this.listenTo(this.model.stats,"reset",this.renderBounds)},renderBounds:function(){this.readMinMaxStats(),t.isUndefined(this.minLowerBound)||this.setLowerBoundPlaceholder(this.minLowerBound),t.isUndefined(this.maxUpperBound)||this.setUpperBoundPlaceholder(this.maxUpperBound)},parseMinStat:function(t){return t},parseMaxStat:function(t){return t},readMinMaxStats:function(){var e=this.model.stats.get("min"),i=this.model.stats.get("max");t.isUndefined(e)||(this.minLowerBound=this.parseMinStat(e.get("value"))),t.isUndefined(i)||(this.maxUpperBound=this.parseMaxStat(i.get("value")))},toggleHelpText:function(t){t.preventDefault(),this.ui.help.toggle()},getField:function(){return this.model.id},getOperator:function(){var t=this.ui.lowerBound.val(),e=this.ui.upperBound.val(),i=this.operatorSelect.getSelection(),n="range"!==i;return i=""!==t&&""!==e?i:""!==t?n?"lte":"gte":""!==e?n?"gte":"lte":void 0},getLowerBoundValue:function(){return this.ui.lowerBound.val()},getUpperBoundValue:function(){return this.ui.upperBound.val()},getValue:function(){var t,e=this.getLowerBoundValue(),i=this.getUpperBoundValue();return t=""!==e&&""!==i?[e,i]:""!==e?e:""!==i?i:null},setOperator:function(t){"-range"!==t&&(t="range"),this.operatorSelect.setSelection(t)},setLowerBoundPlaceholder:function(t){this.ui.lowerBound.prop("placeholder",t)},setLowerBoundValue:function(t){this.ui.lowerBound.val(t)},setUpperBoundPlaceholder:function(t){this.ui.upperBound.prop("placeholder",t)},setUpperBoundValue:function(t){this.ui.upperBound.val(t)},set:function(e){this.setOperator(e.operator),this.setUpperBoundValue(),this.setLowerBoundValue();var i=e.value;t.isArray(i)?(t.isUndefined(i[0])||this.setLowerBoundValue(i[0]),t.isUndefined(i[1])||this.setUpperBoundValue(i[1])):t.isUndefined(i)||("gte"===e.operator?this.setLowerBoundValue(i):this.setUpperBoundValue(i))},validate:function(e){return t.isUndefined(e.value)||t.isNull(e.value)?"A lower or upper value must be defined":t.isArray(e.value)&&e.value[0]>e.value[1]?"The lower bound cannot be greater than the upper":void 0}});return{RangeControl:o}}),define("cilantro/ui/controls/date",["underscore","./range"],function(t,e){var i=e.RangeControl.extend({events:function(){return t.extend({"changeDate .range-lower,.range-upper":"_change"},e.RangeControl.prototype.events)},onRender:function(){e.RangeControl.prototype.onRender.apply(this,arguments),this.ui.lowerBound.datepicker({autoclose:!0}),this.ui.upperBound.datepicker({autoclose:!0})},_setPlaceholder:function(t,e){var i=e.replace(/T.*$/,""),n=i.split("-");3===n.length&&(i=""+n[1]+"/"+n[2]+"/"+n[0],t.attr("placeholder",i))},setLowerBoundPlaceholder:function(t){this._setPlaceholder(this.ui.lowerBound,t)},setUpperBoundPlaceholder:function(t){this._setPlaceholder(this.ui.upperBound,t)}});return{DateControl:i}}),define("cilantro/ui/controls/number",["./range"],function(t){var e=t.RangeControl.extend({getLowerBoundValue:function(){var t=this.ui.lowerBound.val().trim();return t?parseFloat(t):void 0},getUpperBoundValue:function(){var t=this.ui.upperBound.val().trim();return t?parseFloat(t):void 0}});return{NumberControl:e}}),define("cilantro/ui/base",["jquery","underscore","marionette"],function(t,e,i){var n=i.ItemView.extend({align:"center",constructor:function(t){if(i.ItemView.prototype.constructor.call(this,t),!this.template)if(this.options.template)this.template=this.options.template;else{var n=[],o=e.result(this.options,"icon")||e.result(this,"icon"),r=e.result(this.options,"message")||e.result(this,"message");o&&n.push(o),r&&n.push(r),this.template=function(){return n.join(" ")}}this.align&&this.$el.css("text-align",this.align)}}),o=n.extend({className:"empty-view",icon:'<i class="icon-info"></i>',message:"No data available"}),r=o.extend({className:"empty-search-view",icon:'<i class="icon-search icon-2x"></i>',message:"We could not find anything related to your search"}),s=n.extend({className:"error-view",icon:'<i class="icon-exclamation"></i>',message:"Something went awry.."}),a=s.extend({className:"error-overlay-view",template:"base/error-overlay",onRender:function(){t(this.options.target).append(this.$el)}}),l=n.extend({className:"load-view",icon:'<i class="icon-spinner icon-spin"></i>',message:"Loading..."});return{EmptyView:o,EmptySearchView:r,ErrorView:s,ErrorOverlayView:a,LoadView:l}});var __hasProp={}.hasOwnProperty,__extends=function(t,e){function i(){this.constructor=t}for(var n in e)__hasProp.call(e,n)&&(t[n]=e[n]);return i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype,t},__slice=[].slice;define("cilantro/ui/paginator",["underscore","marionette","./base"],function(t,e,i){var n,o,r,s,a,l,c,u,h,d,p,f;return n=function(t){function e(){return c=e.__super__.constructor.apply(this,arguments)}return __extends(e,t),e.prototype.message="No page results",e}(i.EmptyView),r=function(t){function e(){return u=e.__super__.constructor.apply(this,arguments)}return __extends(e,t),e.prototype.message="Loading page...",e}(i.LoadView),l=function(e){function i(){return h=i.__super__.constructor.apply(this,arguments)}return __extends(i,e),i.prototype.template="paginator",i.prototype.requestDelay=250,i.prototype.className="paginator",i.prototype.ui={first:"[data-page=first]",prev:"[data-page=prev]",next:"[data-page=next]",last:"[data-page=last]",pageCount:".page-count",currentPage:".current-page",buttons:"[data-toggle=tooltip]"},i.prototype.modelEvents={"change:pagecount":"renderPageCount","change:currentpage":"renderCurrentPage"},i.prototype.events={"click [data-page=first]":"requestChangePage","click [data-page=prev]":"requestChangePage","click [data-page=next]":"requestChangePage","click [data-page=last]":"requestChangePage"},i.prototype.initialize=function(){return this._changePage=t.debounce(this.changePage,this.requestDelay)},i.prototype.onRender=function(){return this.ui.buttons.tooltip({animation:!1,placement:"bottom"}),this.model.pageIsLoading()?void 0:(this.renderPageCount(this.model,this.model.getPageCount()),this.renderCurrentPage.apply(this,[this.model].concat(__slice.call(this.model.getCurrentPageStats()))))},i.prototype.renderPageCount=function(t,e){return this.ui.pageCount.text(e)},i.prototype.renderCurrentPage=function(t,e,i){return this.ui.currentPage.text(e),this.ui.first.prop("disabled",!!i.first),this.ui.prev.prop("disabled",!!i.first),this.ui.next.prop("disabled",!!i.last),this.ui.last.prop("disabled",!!i.last),i.first&&(this.ui.first.tooltip("hide"),this.ui.prev.tooltip("hide")),i.last?(this.ui.next.tooltip("hide"),this.ui.last.tooltip("hide")):void 0},i.prototype.changePage=function(t){switch(t){case"first":return this.model.getFirstPage();case"prev":return this.model.getPreviousPage();case"next":return this.model.getNextPage();case"last":return this.model.getLastPage();default:throw new Error("Unknown paginator direction: "+t)}},i.prototype.requestChangePage=function(t){return this._changePage($(t.currentTarget).data("page"))},i}(e.ItemView),s=function(t){function e(){return d=e.__super__.constructor.apply(this,arguments)}return __extends(e,t),e}(e.ItemView),o=function(e){function i(){return p=i.__super__.constructor.apply(this,arguments)}return __extends(i,e),i.prototype.itemView=s,i.prototype.emptyPage=n,i.prototype.itemViewOptions=function(e,i){return t.defaults({model:e,index:i},this.options)},i}(e.CollectionView),a=function(e){function i(){return f=i.__super__.constructor.apply(this,arguments)}return __extends(i,e),i.prototype.options={list:!0},i.prototype.itemView=s,i.prototype.listView=o,i.prototype.emptyView=r,i.prototype.getItemView=function(){return this.options.list?this.listView:this.itemView},i.prototype.listViewOptions=function(t){return{collection:t.items}},i.prototype.itemViewOptions=function(e,i){var n;return n={model:e,index:i},this.options.list&&t.extend(n,this.listViewOptions(e,i)),t.defaults(n,this.options)},i.prototype.collectionEvents={"change:currentpage":"showCurentPage"},i.prototype.showCurentPage=function(t,e){return this.children.each(function(t){return t.$el.toggle(t.model.id===e)})},i}(e.CollectionView),{Paginator:l,Page:s,ListingPage:o,PageRoll:a}}),define("cilantro/ui/values",["jquery","underscore","marionette","./base","../core","../models","../constants"],function(t,e,i,n,o,r,s){var a=i.ItemView.extend({className:"value-item",template:"values/item"}),l=i.ItemView.extend({className:"value-list",template:"values/list",collectionEvents:{add:"reloadText",remove:"reloadText",reset:"clearText"},ui:{textarea:"textarea"},clear:function(t){t&&t.preventDefault(),this.collection.reset()},clearText:function(){this.ui.textarea.val("")},initialize:function(){this._parseText=e.debounce(this.parseText,s.INPUT_DELAY)},reloadText:function(){this.ui.textarea.val(this.collection.pluck("label").join("\n"))},parseText:function(){for(var e,i,n=[],r=t.trim(this.ui.textarea.val()).split("\n"),s=0;s<r.length;s++)if(i=t.trim(r[s]))if(e=this.collection.get(i))e.set("index",s),n.push(e);else if(o.isSupported("2.3.2"))n.push({label:i,index:s});else{n.push({value:i,index:s});var a=console.warn||console.log;a("Serrano 2.3.2+ is required for proper validation of search values")}this.collection.set(n,{sort:!1})},onRender:function(){var t=this;this.ui.textarea.on("input propertychange",function(){t._parseText()})}});return{ValueItem:a,ValueList:l}}),define("cilantro/ui/search",["underscore","marionette","../constants"],function(t,e,i){var n=e.ItemView.extend({className:"search",template:"search",options:{placeholder:"Search...",delay:i.INPUT_DELAY},ui:{input:"input"},events:{"input @ui.input":"_triggerSearch"},constructor:function(i){i=i||{};var n=i.delay||t.result(this,"options").delay;this._triggerSearch=t.debounce(this.triggerSearch,n),e.ItemView.prototype.constructor.call(this,i),this.on("search",this.renderInputValue),this.search&&this.on("search",this.search)},onRender:function(){this.ui.input.attr("placeholder",this.options.placeholder);var e=this;t.defer(function(){e._isRendered&&!e.isClosed&&e.ui.input.focus()})},renderInputValue:function(t){this._triggering||this.ui.input.val(t)},triggerSearch:function(){var t=this.ui.input.val();this._triggering=!0,this.trigger("search",t),this._triggering=!1}});return{Search:n}}),define("cilantro/ui/controls/search",["jquery","underscore","marionette","./base","../../models","../../constants","../paginator","../values","../search"],function(t,e,i,n,o,r,s,a,l){var c=o.Page.extend({constructor:function(t,e){(e=e||{}).parse=!0,this.items=new o.Values,o.Page.prototype.constructor.call(this,t,e)},parse:function(t,e){return this.items.reset(t.values,e),delete t.values,t}}),u=o.Paginator.extend({model:c,initialize:function(t,e){e=e||{},this.field=e.field,this.currentUrl=null,o.Paginator.prototype.initialize.call(this,t,e)},url:function(){var e=this.currentUrl||this.field.links.values;return this.urlParams&&(e=e+"?"+t.param(this.urlParams)),e}}),h=i.ItemView.extend({className:"value-item",template:"controls/search/item",ui:{actions:".actions",addButton:".add-item-button",removeButton:".remove-item-button",label:".value-label"},events:{"click .add-item-button":"addItem","click .remove-item-button":"removeItem"},constructor:function(t){t=t||{},(this.values=t.values)&&(this.listenTo(this.values,"add",this.setState),this.listenTo(this.values,"remove",this.setState),this.listenTo(this.values,"reset",this.setState)),i.ItemView.prototype.constructor.call(this,t)},addItem:function(){var t=e.extend(this.model.toJSON(),{valid:!0});this.values.add(t)},removeItem:function(){this.values.remove(this.model)},setState:function(){this.values.get(this.model)?(this.ui.addButton.hide(),this.ui.removeButton.show()):(this.ui.addButton.show(),this.ui.removeButton.hide())},onRender:function(){this.setState(),""===this.ui.label.html()?this.ui.label.html("(empty)"):"null"===this.ui.label.html()&&this.ui.label.html("(null)")}}),d=s.ListingPage.extend({className:"search-value-list",itemView:h}),p=s.PageRoll.extend({listView:d}),f=n.ControlLayout.extend({className:"field-value-search",template:"controls/search/layout",searchPaginator:u,events:{"click [data-action=clear]":"clearValues"},regions:{search:".search-region",paginator:".paginator-region",browse:".browse-region",values:".values-region"},regionViews:{search:l.Search,paginator:s.Paginator,browse:p,values:a.ValueList},initialize:function(){if(!this.collection){this.collection=new o.Values;var t=this;this.collection.url=function(){return t.model.links.values}}this.listenTo(this.collection,"all",this.change),this.valuesPaginator=new this.searchPaginator(null,{field:this.model}),this.valuesPaginator.refresh()},onRender:function(){var t=new this.regionViews.search({model:this.model,placeholder:"Search "+this.model.get("plural_name")+"..."});this.listenTo(t,"search",this.handleSearch);var e=new this.regionViews.browse({collection:this.valuesPaginator,values:this.collection}),i=new this.regionViews.paginator({className:"paginator mini",model:this.valuesPaginator}),n=new this.regionViews.values({collection:this.collection});this.search.show(t),this.browse.show(e),this.paginator.show(i),this.values.show(n)},handleSearch:function(t){this.valuesPaginator.urlParams=t?{query:t}:null,this.valuesPaginator.refresh()},clearValues:function(){this.values.currentView.clear()
  },getField:function(){return this.model?this.model.id:void 0},getOperator:function(){return"in"},getValue:function(){return this.collection.toJSON()},setValue:function(t){this.collection.set(t,{merge:!1})},validate:function(t){var e,i=[];return(e=this.collection.any(function(t){return t.get("pending")===!0}))?"The values are being checked, please wait a few seconds then click &quot;Apply Filter&quot; again.":(this.collection.each(function(t){t.get("valid")||i.push(t.get("label"))}),i.length?"Remove the following invalid labels then click &quot;Apply Filter&quot; again: "+i.join(", "):!t||t.value&&t.value.length?void 0:"At least one value must be selected")}});return{SearchControl:f,SearchItem:h,SearchPage:d,SearchPageRoll:p,SearchPaginator:u}});var __hasProp={}.hasOwnProperty,__extends=function(t,e){function i(){this.constructor=t}for(var n in e)__hasProp.call(e,n)&&(t[n]=e[n]);return i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype,t},__bind=function(t,e){return function(){return t.apply(e,arguments)}},__indexOf=[].indexOf||function(t){for(var e=0,i=this.length;i>e;e++)if(e in this&&this[e]===t)return e;return-1},__slice=[].slice;define("cilantro/ui/controls/infograph",["underscore","backbone","marionette","./base","../button"],function(t,e,i,n){var o,r,s,a,l,c,u,h,d,p,f,m;return u=function(e){return function(i){var n;return n=i.get(e),t.isString(n)&&(n=n.toLowerCase()),n}},a=function(t){function e(){return h=e.__super__.constructor.apply(this,arguments)}return __extends(e,t),e.prototype.parse=function(t){return t.value=t.values[0],t},e}(e.Model),s=function(t){function e(){return d=e.__super__.constructor.apply(this,arguments)}return __extends(e,t),e.prototype.model=a,e.prototype.comparator=function(t){return-t.get("count")},e.prototype.sortModelsBy=function(t){var e;(e="-"===t.charAt(0))&&(t=t.slice(1)),this.models=this.sortBy(u(t)),e&&this.models.reverse(),this.trigger("sort",this)},e}(e.Collection),o=function(t){function e(){return this.onExcludedChange=__bind(this.onExcludedChange,this),p=e.__super__.constructor.apply(this,arguments)}return __extends(e,t),e.prototype.className="info-bar",e.prototype.template="controls/infograph/bar",e.prototype.options={total:null},e.prototype.ui={bar:".bar",barLabel:".bar-label"},e.prototype.events={click:"toggleSelected"},e.prototype.modelEvents={"change:selected":"setSelected","change:visible":"setVisible"},e.prototype.initialize=function(){return this.listenTo(this.model.collection,"change:excluded",this.onExcludedChange)},e.prototype.serializeData=function(){var t,e;return t=this.model.toJSON(),t.value=t.values[0],e=this.getPercentage(),t.width=e,t.percentage=1>e?"<1":parseInt(e),t},e.prototype.onRender=function(){return this.setSelected(this.model,!!this.model.get("selected")),""===this.ui.barLabel.html()&&this.ui.barLabel.html("(empty)"),"null"===this.ui.barLabel.html()?this.ui.barLabel.html("(null)"):void 0},e.prototype.getPercentage=function(){return 100*(this.model.get("count")/this.options.total)},e.prototype.toggleSelected=function(){return this.model.set("selected",!this.model.get("selected"))},e.prototype.onExcludedChange=function(){return this.$el.toggleClass("excluded",this.model.get("excluded"))},e.prototype.setSelected=function(t,e){return this.$el.toggleClass("selected",e),e||t.get("visible")!==!1?void 0:this.$el.removeClass("filtered").hide()},e.prototype.setVisible=function(t,e){return e?this.$el.removeClass("filtered").show():t.get("selected")?this.$el.addClass("filtered"):this.$el.hide()},e}(i.ItemView),l=function(e){function i(){return f=i.__super__.constructor.apply(this,arguments)}return __extends(i,e),i.prototype.className="info-bar-chart",i.prototype.itemView=o,i.prototype.itemViewOptions=function(t){return{model:t,total:this.calcTotal()}},i.prototype.collectionEvents={change:"change",sort:"sortChildren"},i.prototype.initialize=function(){var t=this;return this.wait(),this.model.distribution(function(e){return t.collection.reset(e.data,{parse:!0}),t.ready()})},i.prototype.calcTotal=function(){var t,e,i,n,o;for(e=0,o=this.collection.pluck("count"),i=0,n=o.length;n>i;i++)t=o[i],e+=t;return e},i.prototype.sortChildren=function(){var t=this;this.collection.each(function(e){var i;return i=t.children.findByModel(e),t.$el.append(i.el)})},i.prototype.getField=function(){return this.model.id},i.prototype.getOperator=function(){return this.collection.where({excluded:!0}).length>0?"-in":"in"},i.prototype.getValue=function(){return t.map(this.collection.where({selected:!0}),function(t){return t.get("value")})},i.prototype.setValue=function(t){null==t&&(t=[]),this.collection.each(function(e){var i;return e.set("selected",(i=e.get("value"),__indexOf.call(t,i)>=0))})},i.prototype.setOperator=function(t){"-in"===t&&(this.collection.each(function(t){return t.set("excluded",!0)}),$("input[name=exclude]").attr("checked",!0))},i}(n.ControlCollectionView),r=function(e){function i(){return this.toggle=__bind(this.toggle,this),m=i.__super__.constructor.apply(this,arguments)}return __extends(i,e),i.prototype.className="navbar navbar-toolbar",i.prototype.template="controls/infograph/toolbar",i.prototype.events={"keyup [name=filter]":"filterBars","click [name=invert]":"invertSelection","click .sort-value-header, .sort-count-header":"sortBy","change [name=exclude]":"excludeCheckboxChanged"},i.prototype.ui={toolbar:".btn-toolbar",filterInput:"[name=filter]",invertButton:"[name=invert]",sortValueHeader:".sort-value-header",sortCountHeader:".sort-count-header",excludeCheckbox:"[name=exclude]"},i.prototype.initialize=function(){return this.sortDirection="-count"},i.prototype.sortBy=function(t){switch(this.sortDirection="sort-value-header"===t.currentTarget.className?"-value"===this.sortDirection?"value":"-value":"-count"===this.sortDirection?"count":"-count",this.sortDirection){case"-count":this.ui.sortValueHeader.html("Value <i class=icon-sort></i>"),this.ui.sortCountHeader.html("Count <i class=icon-sort-down></i>");break;case"count":this.ui.sortValueHeader.html("Value <i class=icon-sort></i>"),this.ui.sortCountHeader.html("Count <i class=icon-sort-up></i>");break;case"-value":this.ui.sortValueHeader.html("Value <i class=icon-sort-down></i>"),this.ui.sortCountHeader.html("Count <i class=icon-sort></i>");break;case"value":this.ui.sortValueHeader.html("Value <i class=icon-sort-up></i>"),this.ui.sortCountHeader.html("Count <i class=icon-sort></i>")}return this.collection.sortModelsBy(this.sortDirection)},i.prototype.toggle=function(t){return this.ui.filterInput.toggle(t),this.ui.invertButton.toggle(t),this.ui.sortValueHeader.toggle(t),this.ui.sortCountHeader.toggle(t)},i.prototype.filterBars=function(e){var i,n;t.isString(e)?n=e:(null!=e&&e.stopPropagation(),n=this.ui.filterInput.val()),i=new RegExp(n,"i"),this.collection.each(function(t){return t.set("visible",!n||i.test(t.get("value")))})},i.prototype.invertSelection=function(){this.collection.each(function(t){return t.get("visible")!==!1||t.get("selected")?t.set("selected",!t.get("selected")):void 0}),this.collection.trigger("change")},i.prototype.excludeCheckboxChanged=function(){var t=this;this.collection.each(function(e){return e.set("excluded",t.ui.excludeCheckbox.prop("checked"),{silent:!0})}),this.collection.trigger("change:excluded")},i}(i.ItemView),c=function(e){function i(t){this.toggleToolbar=__bind(this.toggleToolbar,this);var e,n,o,r,a,c=this;for(null==t.collection&&(t.collection=new s),i.__super__.constructor.call(this,t),this.barsControl=new l({model:this.model,collection:this.collection}),a=["set","get","when","ready","wait"],n=function(t){return c[t]=function(){var e,i;return e=1<=arguments.length?__slice.call(arguments,0):[],(i=c.barsControl)[t].apply(i,e)}},o=0,r=a.length;r>o;o++)e=a[o],n(e);this.listenTo(this.barsControl,"all",function(){var t,e;return e=arguments[0],t=2<=arguments.length?__slice.call(arguments,1):[],("change"===e||"beforeready"===e||"ready"===e)&&this.trigger.apply(this,[e].concat(__slice.call(t))),"ready"===e?this.ui.loading.hide():void 0})}return __extends(i,e),i.prototype.template="controls/infograph/layout",i.prototype.events={change:"change"},i.prototype.options={minValuesForToolbar:10},i.prototype.regions={bars:".bars-region",toolbar:".toolbar-region"},i.prototype.ui={loading:"[data-target=loading-indicator]"},i.prototype.collectionEvents={reset:"toggleToolbar"},i.prototype.toggleToolbar=function(){return this.toolbar.currentView?this.toolbar.currentView.toggle(this.collection.length>=this.options.minValuesForToolbar):void 0},i.prototype.onRender=function(){return this.bars.show(this.barsControl),this.toolbar.show(new r({collection:this.collection})),this.toggleToolbar()},i.prototype.validate=function(e){return t.isUndefined(e.value)||0===e.value.length?"Select at least one value":void 0},i}(n.ControlLayout),{InfographControl:c}});var __hasProp={}.hasOwnProperty,__extends=function(t,e){function i(){this.constructor=t}for(var n in e)__hasProp.call(e,n)&&(t[n]=e[n]);return i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype,t},__indexOf=[].indexOf||function(t){for(var e=0,i=this.length;i>e;e++)if(e in this&&this[e]===t)return e;return-1};define("cilantro/ui/controls/select",["underscore","backbone","marionette","../../core","./base"],function(t,e,i,n,o){var r,s,a,l,c,u;return s=function(t){function e(){return l=e.__super__.constructor.apply(this,arguments)}return __extends(e,t),e.prototype.template=function(){},e.prototype.tagName="option",e.prototype.modelEvents=function(){return{"change:selected":"render"}},e.prototype.onRender=function(){var t;return t=this.model.get("label"),""===t?this.$el.text("(empty)"):"null"===t?this.$el.text("(null)"):this.$el.text(t),this.$el.attr("value",this.model.get("value")),this.$el.attr("selected",this.model.get("selected"))},e}(i.ItemView),a=function(i){function o(){return c=o.__super__.constructor.apply(this,arguments)}return __extends(o,i),o.prototype.className="selection-list",o.prototype.itemView=s,o.prototype.itemViewOptions=function(t){return{model:t}},o.prototype.itemViewContainer=".items",o.prototype.template="controls/select/list",o.prototype.ui={items:".items"},o.prototype.events={"change .items":"onSelectionChange"},o.prototype.collectionEvents={reset:"onCollectionSync"},o.prototype.initialize=function(){var t,i=this;return this.wait(),this.collection||(this.collection=new e.Collection,t=n.isSupported("2.3.1")?0:1e3,this.model.values({limit:t}).done(function(t){return i.collection.reset(t.values),i.ready()})),this.on("ready",function(){return this.change()})},o.prototype.onCollectionSync=function(){return this.render()},o.prototype.onSelectionChange=function(){return this.change()},o.prototype.getField=function(){return this.model.id},o.prototype.getOperator=function(){return"exact"},o.prototype.getValue=function(){return this.ui.items.val()},o.prototype.setValue=function(t){return this.ui.items.val(t)},o.prototype.validate=function(e){return t.isNull(e.value)||t.isUndefined(e.value)?"An option must be selected":void 0},o}(o.ControlCompositeView),r=function(e){function i(){return u=i.__super__.constructor.apply(this,arguments)}return __extends(i,e),i.prototype.onCollectionSync=function(){return this.render()},i.prototype.onSelectionChange=function(){var t=this;return this.ui.items.children().each(function(e,i){return t.collection.models[e].set("selected",i.selected)}),this.change()},i.prototype.onRender=function(){return this.ui.items.attr("multiple",!0)},i.prototype.getOperator=function(){return"in"},i.prototype.getValue=function(){return t.map(this.collection.where({selected:!0}),function(t){return t.get("value")})},i.prototype.setValue=function(t){return null==t&&(t=[]),this.collection.each(function(e){var i;return e.set("selected",(i=e.get("value"),__indexOf.call(t,i)>=0))})},i.prototype.validate=function(t){return t.value&&t.value.length?void 0:"At least one option must be selected"},i}(a),{SingleSelectionList:a,MultiSelectionList:r}}),define("cilantro/ui/controls/null",["./base"],function(t){var e=t.Control.extend({template:"controls/null/layout",ui:{select:"[data-target=null-selector]",nullOption:"[data-target=null-option]",notNullOption:"[data-target=not-null-option]"},events:{"change [data-target=null-selector]":"change"},initialize:function(){this.on("ready",this.change)},onRender:function(){this.options.isNullLabel&&this.ui.nullOption.text(this.options.isNullLabel),this.options.isNotNullLabel&&this.ui.notNullOption.text(this.options.isNotNullLabel)},getOperator:function(){return"isnull"},getValue:function(){return"true"===this.ui.select.val()},setValue:function(t){this.ui.select.val(t.toString())}});return{NullSelector:e}}),define("cilantro/ui/controls/text",["underscore","backbone","marionette","../../core","../search","../base","./base"],function(t,e,i,n,o,r,s){var a={a:!0,about:!0,above:!0,across:!0,after:!0,afterwards:!0,again:!0,against:!0,all:!0,almost:!0,alone:!0,along:!0,already:!0,also:!0,although:!0,always:!0,am:!0,among:!0,amongst:!0,amoungst:!0,amount:!0,an:!0,and:!0,another:!0,any:!0,anyhow:!0,anyone:!0,anything:!0,anyway:!0,anywhere:!0,are:!0,around:!0,as:!0,at:!0,back:!0,be:!0,became:!0,because:!0,become:!0,becomes:!0,becoming:!0,been:!0,before:!0,beforehand:!0,behind:!0,being:!0,below:!0,beside:!0,besides:!0,between:!0,beyond:!0,bill:!0,both:!0,bottom:!0,but:!0,by:!0,call:!0,can:!0,cannot:!0,cant:!0,co:!0,con:!0,could:!0,couldnt:!0,cry:!0,de:!0,describe:!0,detail:!0,"do":!0,does:!0,done:!0,down:!0,due:!0,during:!0,each:!0,eg:!0,eight:!0,either:!0,eleven:!0,"else":!0,elsewhere:!0,empty:!0,enough:!0,etc:!0,even:!0,ever:!0,every:!0,everyone:!0,everything:!0,everywhere:!0,except:!0,few:!0,fifteen:!0,fify:!0,fill:!0,find:!0,fire:!0,first:!0,five:!0,"for":!0,former:!0,formerly:!0,forty:!0,found:!0,four:!0,from:!0,front:!0,full:!0,further:!0,get:!0,give:!0,go:!0,had:!0,has:!0,hasnt:!0,have:!0,he:!0,hence:!0,her:!0,here:!0,hereafter:!0,hereby:!0,herein:!0,hereupon:!0,hers:!0,herself:!0,him:!0,himself:!0,his:!0,how:!0,however:!0,hundred:!0,ie:!0,"if":!0,"in":!0,inc:!0,indeed:!0,interest:!0,into:!0,is:!0,it:!0,its:!0,itself:!0,keep:!0,last:!0,latter:!0,latterly:!0,least:!0,less:!0,ltd:!0,made:!0,many:!0,may:!0,me:!0,meanwhile:!0,might:!0,mill:!0,mine:!0,more:!0,moreover:!0,most:!0,mostly:!0,move:!0,much:!0,must:!0,my:!0,myself:!0,name:!0,namely:!0,neither:!0,never:!0,nevertheless:!0,next:!0,nine:!0,no:!0,nobody:!0,none:!0,noone:!0,nor:!0,not:!0,nothing:!0,now:!0,nowhere:!0,of:!0,off:!0,often:!0,on:!0,once:!0,one:!0,only:!0,onto:!0,or:!0,other:!0,others:!0,otherwise:!0,our:!0,ours:!0,ourselves:!0,out:!0,over:!0,own:!0,part:!0,per:!0,perhaps:!0,please:!0,put:!0,rather:!0,re:!0,same:!0,see:!0,seem:!0,seemed:!0,seeming:!0,seems:!0,serious:!0,several:!0,she:!0,should:!0,show:!0,side:!0,since:!0,sincere:!0,six:!0,sixty:!0,so:!0,some:!0,somehow:!0,someone:!0,something:!0,sometime:!0,sometimes:!0,somewhere:!0,still:!0,such:!0,system:!0,take:!0,ten:!0,than:!0,that:!0,the:!0,their:!0,them:!0,themselves:!0,then:!0,thence:!0,there:!0,thereafter:!0,thereby:!0,therefore:!0,therein:!0,thereupon:!0,these:!0,they:!0,thickv:!0,thin:!0,third:!0,"this":!0,those:!0,though:!0,three:!0,through:!0,throughout:!0,thru:!0,thus:!0,to:!0,together:!0,too:!0,top:!0,toward:!0,towards:!0,twelve:!0,twenty:!0,two:!0,un:!0,under:!0,until:!0,up:!0,upon:!0,us:!0,very:!0,via:!0,was:!0,way:!0,we:!0,well:!0,were:!0,what:!0,whatever:!0,when:!0,whence:!0,whenever:!0,where:!0,whereafter:!0,whereas:!0,whereby:!0,wherein:!0,whereupon:!0,wherever:!0,whether:!0,which:!0,"while":!0,whither:!0,who:!0,whoever:!0,whole:!0,whom:!0,whose:!0,why:!0,will:!0,"with":!0,within:!0,without:!0,would:!0,yet:!0,you:!0,your:!0,yours:!0,yourself:!0,yourselves:!0,didnt:!0,doesnt:!0,dont:!0,isnt:!0,wasnt:!0,youre:!0,hes:!0,ive:!0,theyll:!0,whos:!0,wheres:!0,whens:!0,whys:!0,hows:!0,whats:!0,shes:!0,im:!0,thats:!0},l=function(t){for(var e,i=[],n=0;n<t.length;n++)e=t[n],(/^[+-]?["']/.test(e)||(e=e.toLowerCase().replace(/[^a-zA-Z]/,""),!a[e]))&&i.push(t[n]);return i},c=/[+-]?(?:[^\s"']+|"([^"]*)"|'([^']*)')/g,u=function(t){var e=t.match(c)||[];return e.length&&(e=l(e)),e},h=function(t){return t.replace(/^[\-\+]?["']?/,"").replace(/["']?$/,"")},d=1,p=3,f=13,m=function(t,e,i){if(t.nodeType===p){var n=t.data.search(e);if(n>=0&&t.data.length>0){var o=t.data.match(e),r=document.createElement("span"),s=t.splitText(n);return s.splitText(o[0].length),r.appendChild(s.cloneNode(!0)),r.className=i,s.parentNode.replaceChild(r,s),!0}}else if(t.nodeType===d&&t.childNodes&&!/(script|style)/i.test(t.tagName))for(var a=0;a<t.childNodes.length;)m(t.childNodes[a],e,i)&&a++,a++},g=function(e,i,n){t.isRegExp(i)||(i=new RegExp(i,"ig")),e.each(function(){return m(this,i,n)})},v=i.ItemView.extend({tagName:"p",template:"controls/text/preview-item"}),y=i.CompositeView.extend({template:"controls/text/preview-list",itemView:v,itemViewContainer:".items",onRender:function(){var e=t.map(u(this.options.query),function(t){return h(t)}),i=this.$(this.itemViewContainer).children();g(i,e.join("|"),"highlight")}}),w=e.Collection.extend({parse:function(t){return t.objects||t.values}}),b=s.ControlLayout.extend({template:"controls/text/layout",options:{preview:!1},regions:{search:"[data-target=search-region]",preview:"[data-target=preview-region]"},regionViews:{search:o.Search,preview:y},collectionEvents:{request:"showPreviewLoading",error:"showPreviewError",sync:"showPreview"},events:{"keyup [data-target=search-region] input":"triggerPreview"},constructor:function(t){t.collection=new w,t.collection.url=function(){return t.model.links.values},s.ControlLayout.prototype.constructor.call(this,t)},onRender:function(){var t=new this.regionViews.search;this.listenTo(t,"search",this.change),this.search.show(t)},triggerPreview:function(t){if(this.options.preview&&t&&t.which===f){t.preventDefault(),t.stopPropagation(),this.showPreviewLoading();var e=this.get(),i=this.previewQuery=e.query;this.context?this.context.set({json:e}):this.context=n.data.contexts.add({json:e});var o=this;this.context.save().fail(function(){o.showPreviewError()}).done(function(){o.previewQuery===i&&o.collection.fetch({reset:!0,data:{aware:1,limit:5,context:o.context.id}})})}},showPreviewLoading:function(){this.preview.show(new r.LoadView({message:"Loading preview..."}))},showPreviewError:function(){this.preview.show(new r.ErrorView({message:"There was an error loading the preview."}))},showPreview:function(){var t=new this.regionViews.preview({query:this.previewQuery,collection:this.collection});this.preview.show(t)},validate:function(t){return t.children||t.value?void 0:"At least one keyword must be entered"},get:function(){var e=this.search.currentView.ui.input.val(),i=u(e);if(i.length){var n=this.model.id,o={field:n,type:"and",children:[]},r=[],s=[],a=[];return t.each(i,function(t){var e=t.charAt(0);"+"===e?r.push(h(t)):"-"===e?s.push(h(t)):a.push(h(t))}),1===r.length?o.children.push({field:n,operator:"icontains",value:r[0]}):r.length>1&&o.children.push({field:n,type:"and",children:t.map(r,function(t){return{field:n,operator:"icontains",value:t}})}),1===s.length?o.children.push({field:n,operator:"-icontains",value:s[0]}):s.length>1&&o.children.push({field:n,type:"and",children:t.map(s,function(t){return{field:n,operator:"-icontains",value:t}})}),1===a.length?o.children.push({field:n,operator:"icontains",value:a[0]}):a.length>1&&o.children.push({field:n,operator:"iregex",value:"("+a.join("|")+")"}),1===o.children.length&&(o=o.children[0]),o.query=e,o}},set:function(t){this._changing||t.query&&this.search.currentView.ui.input.val(t.query)}});return{TextControl:b}}),define("cilantro/ui/controls/vocab",["jquery","underscore","backbone","marionette","./base","./search","../search","../values","../paginator","../../models"],function(t,e,i,n,o,r,s,a,l,c){var u=i.Collection.extend({_matches:function(t){var e=t.attributes||t;return this.matcher(e)},initialize:function(t,i){this.matcher=i.matcher,this.values=i.collection,this.listenTo(this.values,{change:function(t,e){this._matches(t)?this.add(t,e):this.remove(t,e)},add:function(t,e,i){this._matches(t)&&this.add(t,i)},remove:function(t,e,i){this._matches(t)&&this.remove(t,i)},reset:function(t,i,n){var o=null;o=t&&t.length?e.filter(t,this._matches):[],o&&this.reset(o,n)}})}}),h=c.Value.extend({defaults:{operator:"in"}}),d=c.Values.extend({model:h}),p=a.ValueItem.extend({template:"controls/vocab/bucket-item",ui:{remove:"[data-target=remove]"},events:{"click @ui.remove":"removeItem"},removeItem:function(){this.model.destroy()}}),f=n.CompositeView.extend({className:"vocab-bucket",template:"controls/vocab/bucket",itemView:p,itemViewContainer:"[data-target=items]",options:{name:"Bucket"},ui:{items:"[data-target=items]"},events:{"sortreceive [data-target=items]":"receiveItem"},collectionEvents:{"add remove reset":"renderListState"},serializeData:function(){return{name:this.options.name}},receiveItem:function(t,e){var i=e.item.find("[data-value]").data("value"),n=this.collection.values.findWhere({value:parseInt(i,10)});n.set("operator",this.options.operator)},onRender:function(){this.ui.items.sortable({forcePlaceholderSize:!0,forceHelperSize:!0,placeholder:"placeholder",scroll:!1,opacity:.7,cursor:"move",connectWith:".vocab-bucket [data-target=items]"}),this.renderListState()},renderListState:function(){this.$el.toggleClass("empty",0===this.collection.length)}}),m=n.View.extend({initialize:function(){var t=this.model.get("alt_name").toLowerCase(),e=this.model.get("alt_plural_name").toLowerCase();this.buckets=[{name:"At least one "+t+" must match",operator:"in",collection:new u(null,{collection:this.collection,matcher:function(t){return"in"===t.operator}})},{name:"All the "+e+" must match",operator:"all",collection:new u(null,{collection:this.collection,matcher:function(t){return"all"===t.operator}})},{name:"The combination of "+e+" cannot match",operator:"-all",collection:new u(null,{collection:this.collection,matcher:function(t){return"-all"===t.operator}})},{name:"None of the "+e+" can match",operator:"-in",collection:new u(null,{collection:this.collection,matcher:function(t){return"-in"===t.operator}})}]},render:function(){for(var t=0;t<this.buckets.length;t++){var e=new f(this.buckets[t]);e.render(),this.$el.append(e.el)}return this.el}}),g=n.ItemView.extend({template:"controls/vocab/path",className:"vocab-path"}),v=n.ItemView.extend({className:"value-item",template:"controls/vocab/item",ui:{actions:".actions",addButton:".add-item-button",removeButton:".remove-item-button"},events:{"click .add-item-button":"addItem","click .remove-item-button":"removeItem"},constructor:function(t){t=t||{},(this.values=t.values)&&(this.listenTo(this.values,"add",this.setState),this.listenTo(this.values,"remove",this.setState),this.listenTo(this.values,"reset",this.setState)),n.ItemView.prototype.constructor.call(this,t)},serializeData:function(){var t=this.model.get("_links").children;return{url:t?t.href:null,label:this.model.get("label")}},addItem:function(){var t=e.extend(this.model.toJSON(),{valid:!0});this.values.add(t)},removeItem:function(){this.values.remove(this.model)},setState:function(){this.values.get(this.model)?(this.ui.addButton.hide(),this.ui.removeButton.show()):(this.ui.addButton.show(),this.ui.removeButton.hide())},onRender:function(){this.setState()}}),y=l.ListingPage.extend({className:"search-value-list",itemView:v}),w=l.PageRoll.extend({listView:y}),b=o.ControlLayout.extend({className:"vocab-control",template:"controls/vocab/layout",events:{"click [data-action=clear]":"clearValues","click .browse-region a":"triggerDescend","click .path-region button":"triggerAscend"},options:{resetPathOnSearch:!1},regions:{paginator:".paginator-region",search:".search-region",path:".path-region",browse:".browse-region",buckets:".buckets-region"},regionViews:{search:s.Search,paginator:l.Paginator,path:g,browse:w,buckets:m},initialize:function(){this.selectedValues=new d,this.listenTo(this.selectedValues,"all",this.change),this.valuesPaginator=new r.SearchPaginator(null,{field:this.model}),this._path=new i.Collection},triggerDescend:function(e){e.preventDefault(),e.stopPropagation();var i=t(e.target);this._path.push({label:i.text(),url:i.prop("href")})},triggerAscend:function(){event.preventDefault(),event.stopPropagation(),this._path.pop()},refreshPaginator:function(){var t=this._path.last();this.path.show(new this.regionViews.path({model:t})),this.valuesPaginator.currentUrl=t.get("url"),this.valuesPaginator.refresh()},onRender:function(){var t=new this.regionViews.search({model:this.model,placeholder:"Search "+this.model.get("plural_name")+"..."});this.listenTo(t,"search",this.handleSearch);var e=new this.regionViews.browse({collection:this.valuesPaginator,values:this.selectedValues}),i=new this.regionViews.paginator({className:"paginator mini",model:this.valuesPaginator}),n=new this.regionViews.buckets({model:this.model,collection:this.selectedValues});this.search.show(t),this.browse.show(e),this.paginator.show(i),this.buckets.show(n),this.listenTo(this._path,"add remove",this.refreshPaginator),this._path.push({label:"Top-level"})},handleSearch:function(t){this.options.resetPathOnSearch&&(this.valuesPaginator.currentUrl=null),this.valuesPaginator.urlParams=t?{query:t}:null,this.valuesPaginator.refresh()},get:function(){var t,i={};this.selectedValues.each(function(e){t=e.get("operator"),i[t]||(i[t]=[]),i[t].push(e.pick("label","value"))});var n=e.keys(i);if(n.length)return 1===n.length?{field:this.model.id,operator:n[0],value:i[n[0]]}:{type:"and",children:e.map(i,function(t,e){return{field:this.model.id,operator:e,value:t}},this)}},_mapSetValues:function(t,i){return e.map(t,function(t){return t=e.clone(t),t.operator=i,t})},set:function(t){if(t){var i=[];t.children?e.each(t.children,function(t){i=i.concat(this._mapSetValues(t.value,t.operator))},this):i=this._mapSetValues(t.value,t.operator),this.selectedValues.set(i,{remove:!1})}}});return{VocabControl:b}}),define("cilantro/ui/controls/registry",["underscore","loglevel","../../core","./date","./number","./search","./select","./infograph","./null","./text","./vocab"],function(t,e,i,n,o,r,s,a,l,c,u){var h={infograph:a.InfographControl,number:o.NumberControl,date:n.DateControl,search:r.SearchControl,singleSelectionList:s.SingleSelectionList,multiSelectionList:s.MultiSelectionList,nullSelector:l.NullSelector,text:c.TextControl,vocab:u.VocabControl},d={},p=0,f=function(t,i){p++,require([i],function(e){d[t]=e,p--},function(t){e.debug(t),p--})},m=function(t,e){switch(typeof e){case"function":d[t]=e;break;case"string":f(t,e);break;default:throw new Error("control must be a function or AMD module")}};return{get:function(t){return d[t]||h[t]},set:function(e,i){"object"==typeof e?t.each(e,function(t,e){m(e,t)}):m(e,i)},ready:function(){return 0===p},clear:function(){d={}}}}),define("cilantro/ui/controls",["underscore","./controls/base","./controls/range","./controls/date","./controls/number","./controls/search","./controls/infograph","./controls/registry","./controls/null","./controls/text","./controls/vocab"],function(t){var e=Array.prototype.slice.call(arguments,1);return t.extend.apply(t,[{}].concat(e))}),define("cilantro/ui/dom",[],function(){var t=function(t,e,i){var n=t.children(),o=n.size();return 0>e&&(e=Math.max(0,o+1+e)),t.append(i),o>e&&n.eq(e).before(n.last()),t};return{insertAt:t}}),define("plugins/bootstrap-datepicker",["jquery"],function(t){var e=function(e,n){if(this.element=t(e),this.format=i.parseFormat(n.format||this.element.data("date-format")||"mm/dd/yyyy"),this.picker=t(i.template).appendTo("body").on({click:t.proxy(this.click,this)}),this.isInput=this.element.is("input"),this.component=this.element.is(".date")?this.element.find(".add-on"):!1,this.isInput?this.element.on({focus:t.proxy(this.show,this),keyup:t.proxy(this.update,this)}):this.component?this.component.on("click",t.proxy(this.show,this)):this.element.on("click",t.proxy(this.show,this)),this.minViewMode=n.minViewMode||this.element.data("date-minviewmode")||0,"string"==typeof this.minViewMode)switch(this.minViewMode){case"months":this.minViewMode=1;break;case"years":this.minViewMode=2;break;default:this.minViewMode=0}if(this.viewMode=n.viewMode||this.element.data("date-viewmode")||0,"string"==typeof this.viewMode)switch(this.viewMode){case"months":this.viewMode=1;break;case"years":this.viewMode=2;break;default:this.viewMode=0}this.startViewMode=this.viewMode,this.weekStart=n.weekStart||this.element.data("date-weekstart")||0,this.weekEnd=0===this.weekStart?6:this.weekStart-1,this.onRender=n.onRender,this.fillDow(),this.fillMonths(),this.update(),this.showMode()};e.prototype={constructor:e,show:function(e){this.picker.show(),this.height=this.component?this.component.outerHeight():this.element.outerHeight(),this.place(),t(window).on("resize",t.proxy(this.place,this)),e&&(e.stopPropagation(),e.preventDefault()),!this.isInput;var i=this;t(document).on("mousedown",function(e){0==t(e.target).closest(".datepicker").length&&i.hide()}),this.element.trigger({type:"show",date:this.date})},hide:function(){this.picker.hide(),t(window).off("resize",this.place),this.viewMode=this.startViewMode,this.showMode(),this.isInput||t(document).off("mousedown",this.hide),this.element.trigger({type:"hide",date:this.date})},set:function(){var t=i.formatDate(this.date,this.format);this.isInput?this.element.prop("value",t):(this.component&&this.element.find("input").prop("value",t),this.element.data("date",t))},setValue:function(t){this.date="string"==typeof t?i.parseDate(t,this.format):new Date(t),this.set(),this.viewDate=new Date(this.date.getFullYear(),this.date.getMonth(),1,0,0,0,0),this.fill()},place:function(){var t=this.component?this.component.offset():this.element.offset();this.picker.css({top:t.top+this.height,left:t.left})},update:function(t){this.date=i.parseDate("string"==typeof t?t:this.isInput?this.element.prop("value"):this.element.data("date"),this.format),this.viewDate=new Date(this.date.getFullYear(),this.date.getMonth(),1,0,0,0,0),this.fill()},fillDow:function(){for(var t=this.weekStart,e="<tr>";t<this.weekStart+7;)e+='<th class="dow">'+i.dates.daysMin[t++%7]+"</th>";e+="</tr>",this.picker.find(".datepicker-days thead").append(e)},fillMonths:function(){for(var t="",e=0;12>e;)t+='<span class="month">'+i.dates.monthsShort[e++]+"</span>";this.picker.find(".datepicker-months td").append(t)},fill:function(){var t=new Date(this.viewDate),e=t.getFullYear(),n=t.getMonth(),o=this.date.valueOf();this.picker.find(".datepicker-days th:eq(1)").text(i.dates.months[n]+" "+e);var r=new Date(e,n-1,28,0,0,0,0),s=i.getDaysInMonth(r.getFullYear(),r.getMonth());r.setDate(s),r.setDate(s-(r.getDay()-this.weekStart+7)%7);var a=new Date(r);a.setDate(a.getDate()+42),a=a.valueOf();for(var l,c,u,h=[];r.valueOf()<a;)r.getDay()===this.weekStart&&h.push("<tr>"),l=this.onRender(r),c=r.getFullYear(),u=r.getMonth(),n>u&&c===e||e>c?l+=" old":(u>n&&c===e||c>e)&&(l+=" new"),r.valueOf()===o&&(l+=" active"),h.push('<td class="day '+l+'">'+r.getDate()+"</td>"),r.getDay()===this.weekEnd&&h.push("</tr>"),r.setDate(r.getDate()+1);this.picker.find(".datepicker-days tbody").empty().append(h.join(""));var d=this.date.getFullYear(),p=this.picker.find(".datepicker-months").find("th:eq(1)").text(e).end().find("span").removeClass("active");d===e&&p.eq(this.date.getMonth()).addClass("active"),h="",e=10*parseInt(e/10,10);var f=this.picker.find(".datepicker-years").find("th:eq(1)").text(e+"-"+(e+9)).end().find("td");e-=1;for(var m=-1;11>m;m++)h+='<span class="year'+(-1===m||10===m?" old":"")+(d===e?" active":"")+'">'+e+"</span>",e+=1;f.html(h)},click:function(e){e.stopPropagation(),e.preventDefault();var n=t(e.target).closest("span, td, th");if(1===n.length)switch(n[0].nodeName.toLowerCase()){case"th":switch(n[0].className){case"switch":this.showMode(1);break;case"prev":case"next":this.viewDate["set"+i.modes[this.viewMode].navFnc].call(this.viewDate,this.viewDate["get"+i.modes[this.viewMode].navFnc].call(this.viewDate)+i.modes[this.viewMode].navStep*("prev"===n[0].className?-1:1)),this.fill(),this.set()
  }break;case"span":if(n.is(".month")){var o=n.parent().find("span").index(n);this.viewDate.setMonth(o)}else{var r=parseInt(n.text(),10)||0;this.viewDate.setFullYear(r)}0!==this.viewMode&&(this.date=new Date(this.viewDate),this.element.trigger({type:"changeDate",date:this.date,viewMode:i.modes[this.viewMode].clsName})),this.showMode(-1),this.fill(),this.set();break;case"td":if(n.is(".day")&&!n.is(".disabled")){var s=parseInt(n.text(),10)||1,o=this.viewDate.getMonth();n.is(".old")?o-=1:n.is(".new")&&(o+=1);var r=this.viewDate.getFullYear();this.date=new Date(r,o,s,0,0,0,0),this.viewDate=new Date(r,o,Math.min(28,s),0,0,0,0),this.fill(),this.set(),this.element.trigger({type:"changeDate",date:this.date,viewMode:i.modes[this.viewMode].clsName})}}},mousedown:function(t){t.stopPropagation(),t.preventDefault()},showMode:function(t){t&&(this.viewMode=Math.max(this.minViewMode,Math.min(2,this.viewMode+t))),this.picker.find(">div").hide().filter(".datepicker-"+i.modes[this.viewMode].clsName).show()}},t.fn.datepicker=function(i,n){return this.each(function(){var o=t(this),r=o.data("datepicker"),s="object"==typeof i&&i;r||o.data("datepicker",r=new e(this,t.extend({},t.fn.datepicker.defaults,s))),"string"==typeof i&&r[i](n)})},t.fn.datepicker.defaults={onRender:function(){return""}},t.fn.datepicker.Constructor=e;var i={modes:[{clsName:"days",navFnc:"Month",navStep:1},{clsName:"months",navFnc:"FullYear",navStep:1},{clsName:"years",navFnc:"FullYear",navStep:10}],dates:{days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],daysShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat","Sun"],daysMin:["Su","Mo","Tu","We","Th","Fr","Sa","Su"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],monthsShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]},isLeapYear:function(t){return 0===t%4&&0!==t%100||0===t%400},getDaysInMonth:function(t,e){return[31,i.isLeapYear(t)?29:28,31,30,31,30,31,31,30,31,30,31][e]},parseFormat:function(t){var e=t.match(/[.\/\-\s].*?/),i=t.split(/\W+/);if(!e||!i||0===i.length)throw new Error("Invalid date format.");return{separator:e,parts:i}},parseDate:function(t,e){var i,n=t.split(e.separator),t=new Date;if(t.setHours(0),t.setMinutes(0),t.setSeconds(0),t.setMilliseconds(0),n.length===e.parts.length){for(var o=t.getFullYear(),r=t.getDate(),s=t.getMonth(),a=0,l=e.parts.length;l>a;a++)switch(i=parseInt(n[a],10)||1,e.parts[a]){case"dd":case"d":r=i,t.setDate(i);break;case"mm":case"m":s=i-1,t.setMonth(i-1);break;case"yy":o=2e3+i,t.setFullYear(2e3+i);break;case"yyyy":o=i,t.setFullYear(i)}t=new Date(o,s,r,0,0,0)}return t},formatDate:function(t,e){var i={d:t.getDate(),m:t.getMonth()+1,yy:t.getFullYear().toString().substring(2),yyyy:t.getFullYear()};i.dd=(i.d<10?"0":"")+i.d,i.mm=(i.m<10?"0":"")+i.m;for(var t=[],n=0,o=e.parts.length;o>n;n++)t.push(i[e.parts[n]]);return t.join(e.separator)},headTemplate:'<thead><tr><th class="prev">&lsaquo;</th><th colspan="5" class="switch"></th><th class="next">&rsaquo;</th></tr></thead>',contTemplate:'<tbody><tr><td colspan="7"></td></tr></tbody>'};i.template='<div class="datepicker dropdown-menu"><div class="datepicker-days"><table class=" table-condensed">'+i.headTemplate+"<tbody></tbody>"+"</table>"+"</div>"+'<div class="datepicker-months">'+'<table class="table-condensed">'+i.headTemplate+i.contTemplate+"</table>"+"</div>"+'<div class="datepicker-years">'+'<table class="table-condensed">'+i.headTemplate+i.contTemplate+"</table>"+"</div>"+"</div>"}),define("plugins/jquery-ui",["jquery"],function(t){!function(t,e){function i(e,i){var o,r,s,a=e.nodeName.toLowerCase();return"area"===a?(o=e.parentNode,r=o.name,e.href&&r&&"map"===o.nodeName.toLowerCase()?(s=t("img[usemap=#"+r+"]")[0],!!s&&n(s)):!1):(/input|select|textarea|button|object/.test(a)?!e.disabled:"a"===a?e.href||i:i)&&n(e)}function n(e){return t.expr.filters.visible(e)&&!t(e).parents().addBack().filter(function(){return"hidden"===t.css(this,"visibility")}).length}var o=0,r=/^ui-id-\d+$/;t.ui=t.ui||{},t.extend(t.ui,{version:"1.10.3",keyCode:{BACKSPACE:8,COMMA:188,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,LEFT:37,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SPACE:32,TAB:9,UP:38}}),t.fn.extend({focus:function(e){return function(i,n){return"number"==typeof i?this.each(function(){var e=this;setTimeout(function(){t(e).focus(),n&&n.call(e)},i)}):e.apply(this,arguments)}}(t.fn.focus),scrollParent:function(){var e;return e=t.ui.ie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?this.parents().filter(function(){return/(relative|absolute|fixed)/.test(t.css(this,"position"))&&/(auto|scroll)/.test(t.css(this,"overflow")+t.css(this,"overflow-y")+t.css(this,"overflow-x"))}).eq(0):this.parents().filter(function(){return/(auto|scroll)/.test(t.css(this,"overflow")+t.css(this,"overflow-y")+t.css(this,"overflow-x"))}).eq(0),/fixed/.test(this.css("position"))||!e.length?t(document):e},zIndex:function(i){if(i!==e)return this.css("zIndex",i);if(this.length)for(var n,o,r=t(this[0]);r.length&&r[0]!==document;){if(n=r.css("position"),("absolute"===n||"relative"===n||"fixed"===n)&&(o=parseInt(r.css("zIndex"),10),!isNaN(o)&&0!==o))return o;r=r.parent()}return 0},uniqueId:function(){return this.each(function(){this.id||(this.id="ui-id-"+ ++o)})},removeUniqueId:function(){return this.each(function(){r.test(this.id)&&t(this).removeAttr("id")})}}),t.extend(t.expr[":"],{data:t.expr.createPseudo?t.expr.createPseudo(function(e){return function(i){return!!t.data(i,e)}}):function(e,i,n){return!!t.data(e,n[3])},focusable:function(e){return i(e,!isNaN(t.attr(e,"tabindex")))},tabbable:function(e){var n=t.attr(e,"tabindex"),o=isNaN(n);return(o||n>=0)&&i(e,!o)}}),t("<a>").outerWidth(1).jquery||t.each(["Width","Height"],function(i,n){function o(e,i,n,o){return t.each(r,function(){i-=parseFloat(t.css(e,"padding"+this))||0,n&&(i-=parseFloat(t.css(e,"border"+this+"Width"))||0),o&&(i-=parseFloat(t.css(e,"margin"+this))||0)}),i}var r="Width"===n?["Left","Right"]:["Top","Bottom"],s=n.toLowerCase(),a={innerWidth:t.fn.innerWidth,innerHeight:t.fn.innerHeight,outerWidth:t.fn.outerWidth,outerHeight:t.fn.outerHeight};t.fn["inner"+n]=function(i){return i===e?a["inner"+n].call(this):this.each(function(){t(this).css(s,o(this,i)+"px")})},t.fn["outer"+n]=function(e,i){return"number"!=typeof e?a["outer"+n].call(this,e):this.each(function(){t(this).css(s,o(this,e,!0,i)+"px")})}}),t.fn.addBack||(t.fn.addBack=function(t){return this.add(null==t?this.prevObject:this.prevObject.filter(t))}),t("<a>").data("a-b","a").removeData("a-b").data("a-b")&&(t.fn.removeData=function(e){return function(i){return arguments.length?e.call(this,t.camelCase(i)):e.call(this)}}(t.fn.removeData)),t.ui.ie=!!/msie [\w.]+/.exec(navigator.userAgent.toLowerCase()),t.support.selectstart="onselectstart"in document.createElement("div"),t.fn.extend({disableSelection:function(){return this.bind((t.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(t){t.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}}),t.extend(t.ui,{plugin:{add:function(e,i,n){var o,r=t.ui[e].prototype;for(o in n)r.plugins[o]=r.plugins[o]||[],r.plugins[o].push([i,n[o]])},call:function(t,e,i){var n,o=t.plugins[e];if(o&&t.element[0].parentNode&&11!==t.element[0].parentNode.nodeType)for(n=0;n<o.length;n++)t.options[o[n][0]]&&o[n][1].apply(t.element,i)}},hasScroll:function(e,i){if("hidden"===t(e).css("overflow"))return!1;var n=i&&"left"===i?"scrollLeft":"scrollTop",o=!1;return e[n]>0?!0:(e[n]=1,o=e[n]>0,e[n]=0,o)}})}(t),function(t,e){var i=0,n=Array.prototype.slice,o=t.cleanData;t.cleanData=function(e){for(var i,n=0;null!=(i=e[n]);n++)try{t(i).triggerHandler("remove")}catch(r){}o(e)},t.widget=function(e,i,n){var o,r,s,a,l={},c=e.split(".")[0];e=e.split(".")[1],o=c+"-"+e,n||(n=i,i=t.Widget),t.expr[":"][o.toLowerCase()]=function(e){return!!t.data(e,o)},t[c]=t[c]||{},r=t[c][e],s=t[c][e]=function(t,e){return this._createWidget?(arguments.length&&this._createWidget(t,e),void 0):new s(t,e)},t.extend(s,r,{version:n.version,_proto:t.extend({},n),_childConstructors:[]}),a=new i,a.options=t.widget.extend({},a.options),t.each(n,function(e,n){return t.isFunction(n)?(l[e]=function(){var t=function(){return i.prototype[e].apply(this,arguments)},o=function(t){return i.prototype[e].apply(this,t)};return function(){var e,i=this._super,r=this._superApply;return this._super=t,this._superApply=o,e=n.apply(this,arguments),this._super=i,this._superApply=r,e}}(),void 0):(l[e]=n,void 0)}),s.prototype=t.widget.extend(a,{widgetEventPrefix:r?a.widgetEventPrefix:e},l,{constructor:s,namespace:c,widgetName:e,widgetFullName:o}),r?(t.each(r._childConstructors,function(e,i){var n=i.prototype;t.widget(n.namespace+"."+n.widgetName,s,i._proto)}),delete r._childConstructors):i._childConstructors.push(s),t.widget.bridge(e,s)},t.widget.extend=function(i){for(var o,r,s=n.call(arguments,1),a=0,l=s.length;l>a;a++)for(o in s[a])r=s[a][o],s[a].hasOwnProperty(o)&&r!==e&&(i[o]=t.isPlainObject(r)?t.isPlainObject(i[o])?t.widget.extend({},i[o],r):t.widget.extend({},r):r);return i},t.widget.bridge=function(i,o){var r=o.prototype.widgetFullName||i;t.fn[i]=function(s){var a="string"==typeof s,l=n.call(arguments,1),c=this;return s=!a&&l.length?t.widget.extend.apply(null,[s].concat(l)):s,a?this.each(function(){var n,o=t.data(this,r);return o?t.isFunction(o[s])&&"_"!==s.charAt(0)?(n=o[s].apply(o,l),n!==o&&n!==e?(c=n&&n.jquery?c.pushStack(n.get()):n,!1):void 0):t.error("no such method '"+s+"' for "+i+" widget instance"):t.error("cannot call methods on "+i+" prior to initialization; "+"attempted to call method '"+s+"'")}):this.each(function(){var e=t.data(this,r);e?e.option(s||{})._init():t.data(this,r,new o(s,this))}),c}},t.Widget=function(){},t.Widget._childConstructors=[],t.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"<div>",options:{disabled:!1,create:null},_createWidget:function(e,n){n=t(n||this.defaultElement||this)[0],this.element=t(n),this.uuid=i++,this.eventNamespace="."+this.widgetName+this.uuid,this.options=t.widget.extend({},this.options,this._getCreateOptions(),e),this.bindings=t(),this.hoverable=t(),this.focusable=t(),n!==this&&(t.data(n,this.widgetFullName,this),this._on(!0,this.element,{remove:function(t){t.target===n&&this.destroy()}}),this.document=t(n.style?n.ownerDocument:n.document||n),this.window=t(this.document[0].defaultView||this.document[0].parentWindow)),this._create(),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:t.noop,_getCreateEventData:t.noop,_create:t.noop,_init:t.noop,destroy:function(){this._destroy(),this.element.unbind(this.eventNamespace).removeData(this.widgetName).removeData(this.widgetFullName).removeData(t.camelCase(this.widgetFullName)),this.widget().unbind(this.eventNamespace).removeAttr("aria-disabled").removeClass(this.widgetFullName+"-disabled "+"ui-state-disabled"),this.bindings.unbind(this.eventNamespace),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")},_destroy:t.noop,widget:function(){return this.element},option:function(i,n){var o,r,s,a=i;if(0===arguments.length)return t.widget.extend({},this.options);if("string"==typeof i)if(a={},o=i.split("."),i=o.shift(),o.length){for(r=a[i]=t.widget.extend({},this.options[i]),s=0;s<o.length-1;s++)r[o[s]]=r[o[s]]||{},r=r[o[s]];if(i=o.pop(),n===e)return r[i]===e?null:r[i];r[i]=n}else{if(n===e)return this.options[i]===e?null:this.options[i];a[i]=n}return this._setOptions(a),this},_setOptions:function(t){var e;for(e in t)this._setOption(e,t[e]);return this},_setOption:function(t,e){return this.options[t]=e,"disabled"===t&&(this.widget().toggleClass(this.widgetFullName+"-disabled ui-state-disabled",!!e).attr("aria-disabled",e),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")),this},enable:function(){return this._setOption("disabled",!1)},disable:function(){return this._setOption("disabled",!0)},_on:function(e,i,n){var o,r=this;"boolean"!=typeof e&&(n=i,i=e,e=!1),n?(i=o=t(i),this.bindings=this.bindings.add(i)):(n=i,i=this.element,o=this.widget()),t.each(n,function(n,s){function a(){return e||r.options.disabled!==!0&&!t(this).hasClass("ui-state-disabled")?("string"==typeof s?r[s]:s).apply(r,arguments):void 0}"string"!=typeof s&&(a.guid=s.guid=s.guid||a.guid||t.guid++);var l=n.match(/^(\w+)\s*(.*)$/),c=l[1]+r.eventNamespace,u=l[2];u?o.delegate(u,c,a):i.bind(c,a)})},_off:function(t,e){e=(e||"").split(" ").join(this.eventNamespace+" ")+this.eventNamespace,t.unbind(e).undelegate(e)},_delay:function(t,e){function i(){return("string"==typeof t?n[t]:t).apply(n,arguments)}var n=this;return setTimeout(i,e||0)},_hoverable:function(e){this.hoverable=this.hoverable.add(e),this._on(e,{mouseenter:function(e){t(e.currentTarget).addClass("ui-state-hover")},mouseleave:function(e){t(e.currentTarget).removeClass("ui-state-hover")}})},_focusable:function(e){this.focusable=this.focusable.add(e),this._on(e,{focusin:function(e){t(e.currentTarget).addClass("ui-state-focus")},focusout:function(e){t(e.currentTarget).removeClass("ui-state-focus")}})},_trigger:function(e,i,n){var o,r,s=this.options[e];if(n=n||{},i=t.Event(i),i.type=(e===this.widgetEventPrefix?e:this.widgetEventPrefix+e).toLowerCase(),i.target=this.element[0],r=i.originalEvent)for(o in r)o in i||(i[o]=r[o]);return this.element.trigger(i,n),!(t.isFunction(s)&&s.apply(this.element[0],[i].concat(n))===!1||i.isDefaultPrevented())}},t.each({show:"fadeIn",hide:"fadeOut"},function(e,i){t.Widget.prototype["_"+e]=function(n,o,r){"string"==typeof o&&(o={effect:o});var s,a=o?o===!0||"number"==typeof o?i:o.effect||i:e;o=o||{},"number"==typeof o&&(o={duration:o}),s=!t.isEmptyObject(o),o.complete=r,o.delay&&n.delay(o.delay),s&&t.effects&&t.effects.effect[a]?n[e](o):a!==e&&n[a]?n[a](o.duration,o.easing,r):n.queue(function(i){t(this)[e](),r&&r.call(n[0]),i()})}})}(t),function(t){var e=!1;t(document).mouseup(function(){e=!1}),t.widget("ui.mouse",{version:"1.10.3",options:{cancel:"input,textarea,button,select,option",distance:1,delay:0},_mouseInit:function(){var e=this;this.element.bind("mousedown."+this.widgetName,function(t){return e._mouseDown(t)}).bind("click."+this.widgetName,function(i){return!0===t.data(i.target,e.widgetName+".preventClickEvent")?(t.removeData(i.target,e.widgetName+".preventClickEvent"),i.stopImmediatePropagation(),!1):void 0}),this.started=!1},_mouseDestroy:function(){this.element.unbind("."+this.widgetName),this._mouseMoveDelegate&&t(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate)},_mouseDown:function(i){if(!e){this._mouseStarted&&this._mouseUp(i),this._mouseDownEvent=i;var n=this,o=1===i.which,r="string"==typeof this.options.cancel&&i.target.nodeName?t(i.target).closest(this.options.cancel).length:!1;return o&&!r&&this._mouseCapture(i)?(this.mouseDelayMet=!this.options.delay,this.mouseDelayMet||(this._mouseDelayTimer=setTimeout(function(){n.mouseDelayMet=!0},this.options.delay)),this._mouseDistanceMet(i)&&this._mouseDelayMet(i)&&(this._mouseStarted=this._mouseStart(i)!==!1,!this._mouseStarted)?(i.preventDefault(),!0):(!0===t.data(i.target,this.widgetName+".preventClickEvent")&&t.removeData(i.target,this.widgetName+".preventClickEvent"),this._mouseMoveDelegate=function(t){return n._mouseMove(t)},this._mouseUpDelegate=function(t){return n._mouseUp(t)},t(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate),i.preventDefault(),e=!0,!0)):!0}},_mouseMove:function(e){return t.ui.ie&&(!document.documentMode||document.documentMode<9)&&!e.button?this._mouseUp(e):this._mouseStarted?(this._mouseDrag(e),e.preventDefault()):(this._mouseDistanceMet(e)&&this._mouseDelayMet(e)&&(this._mouseStarted=this._mouseStart(this._mouseDownEvent,e)!==!1,this._mouseStarted?this._mouseDrag(e):this._mouseUp(e)),!this._mouseStarted)},_mouseUp:function(e){return t(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate),this._mouseStarted&&(this._mouseStarted=!1,e.target===this._mouseDownEvent.target&&t.data(e.target,this.widgetName+".preventClickEvent",!0),this._mouseStop(e)),!1},_mouseDistanceMet:function(t){return Math.max(Math.abs(this._mouseDownEvent.pageX-t.pageX),Math.abs(this._mouseDownEvent.pageY-t.pageY))>=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return!0}})}(t),function(t){function e(t,e,i){return t>e&&e+i>t}function i(t){return/left|right/.test(t.css("float"))||/inline|table-cell/.test(t.css("display"))}t.widget("ui.sortable",t.ui.mouse,{version:"1.10.3",widgetEventPrefix:"sort",ready:!1,options:{appendTo:"parent",axis:!1,connectWith:!1,containment:!1,cursor:"auto",cursorAt:!1,dropOnEmpty:!0,forcePlaceholderSize:!1,forceHelperSize:!1,grid:!1,handle:!1,helper:"original",items:"> *",opacity:!1,placeholder:!1,revert:!1,scroll:!0,scrollSensitivity:20,scrollSpeed:20,scope:"default",tolerance:"intersect",zIndex:1e3,activate:null,beforeStop:null,change:null,deactivate:null,out:null,over:null,receive:null,remove:null,sort:null,start:null,stop:null,update:null},_create:function(){var t=this.options;this.containerCache={},this.element.addClass("ui-sortable"),this.refresh(),this.floating=this.items.length?"x"===t.axis||i(this.items[0].item):!1,this.offset=this.element.offset(),this._mouseInit(),this.ready=!0},_destroy:function(){this.element.removeClass("ui-sortable ui-sortable-disabled"),this._mouseDestroy();for(var t=this.items.length-1;t>=0;t--)this.items[t].item.removeData(this.widgetName+"-item");return this},_setOption:function(e,i){"disabled"===e?(this.options[e]=i,this.widget().toggleClass("ui-sortable-disabled",!!i)):t.Widget.prototype._setOption.apply(this,arguments)},_mouseCapture:function(e,i){var n=null,o=!1,r=this;return this.reverting?!1:this.options.disabled||"static"===this.options.type?!1:(this._refreshItems(e),t(e.target).parents().each(function(){return t.data(this,r.widgetName+"-item")===r?(n=t(this),!1):void 0}),t.data(e.target,r.widgetName+"-item")===r&&(n=t(e.target)),n?!this.options.handle||i||(t(this.options.handle,n).find("*").addBack().each(function(){this===e.target&&(o=!0)}),o)?(this.currentItem=n,this._removeCurrentsFromItems(),!0):!1:!1)},_mouseStart:function(e,i,n){var o,r,s=this.options;if(this.currentContainer=this,this.refreshPositions(),this.helper=this._createHelper(e),this._cacheHelperProportions(),this._cacheMargins(),this.scrollParent=this.helper.scrollParent(),this.offset=this.currentItem.offset(),this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left},t.extend(this.offset,{click:{left:e.pageX-this.offset.left,top:e.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()}),this.helper.css("position","absolute"),this.cssPosition=this.helper.css("position"),this.originalPosition=this._generatePosition(e),this.originalPageX=e.pageX,this.originalPageY=e.pageY,s.cursorAt&&this._adjustOffsetFromHelper(s.cursorAt),this.domPosition={prev:this.currentItem.prev()[0],parent:this.currentItem.parent()[0]},this.helper[0]!==this.currentItem[0]&&this.currentItem.hide(),this._createPlaceholder(),s.containment&&this._setContainment(),s.cursor&&"auto"!==s.cursor&&(r=this.document.find("body"),this.storedCursor=r.css("cursor"),r.css("cursor",s.cursor),this.storedStylesheet=t("<style>*{ cursor: "+s.cursor+" !important; }</style>").appendTo(r)),s.opacity&&(this.helper.css("opacity")&&(this._storedOpacity=this.helper.css("opacity")),this.helper.css("opacity",s.opacity)),s.zIndex&&(this.helper.css("zIndex")&&(this._storedZIndex=this.helper.css("zIndex")),this.helper.css("zIndex",s.zIndex)),this.scrollParent[0]!==document&&"HTML"!==this.scrollParent[0].tagName&&(this.overflowOffset=this.scrollParent.offset()),this._trigger("start",e,this._uiHash()),this._preserveHelperProportions||this._cacheHelperProportions(),!n)for(o=this.containers.length-1;o>=0;o--)this.containers[o]._trigger("activate",e,this._uiHash(this));return t.ui.ddmanager&&(t.ui.ddmanager.current=this),t.ui.ddmanager&&!s.dropBehaviour&&t.ui.ddmanager.prepareOffsets(this,e),this.dragging=!0,this.helper.addClass("ui-sortable-helper"),this._mouseDrag(e),!0},_mouseDrag:function(e){var i,n,o,r,s=this.options,a=!1;for(this.position=this._generatePosition(e),this.positionAbs=this._convertPositionTo("absolute"),this.lastPositionAbs||(this.lastPositionAbs=this.positionAbs),this.options.scroll&&(this.scrollParent[0]!==document&&"HTML"!==this.scrollParent[0].tagName?(this.overflowOffset.top+this.scrollParent[0].offsetHeight-e.pageY<s.scrollSensitivity?this.scrollParent[0].scrollTop=a=this.scrollParent[0].scrollTop+s.scrollSpeed:e.pageY-this.overflowOffset.top<s.scrollSensitivity&&(this.scrollParent[0].scrollTop=a=this.scrollParent[0].scrollTop-s.scrollSpeed),this.overflowOffset.left+this.scrollParent[0].offsetWidth-e.pageX<s.scrollSensitivity?this.scrollParent[0].scrollLeft=a=this.scrollParent[0].scrollLeft+s.scrollSpeed:e.pageX-this.overflowOffset.left<s.scrollSensitivity&&(this.scrollParent[0].scrollLeft=a=this.scrollParent[0].scrollLeft-s.scrollSpeed)):(e.pageY-t(document).scrollTop()<s.scrollSensitivity?a=t(document).scrollTop(t(document).scrollTop()-s.scrollSpeed):t(window).height()-(e.pageY-t(document).scrollTop())<s.scrollSensitivity&&(a=t(document).scrollTop(t(document).scrollTop()+s.scrollSpeed)),e.pageX-t(document).scrollLeft()<s.scrollSensitivity?a=t(document).scrollLeft(t(document).scrollLeft()-s.scrollSpeed):t(window).width()-(e.pageX-t(document).scrollLeft())<s.scrollSensitivity&&(a=t(document).scrollLeft(t(document).scrollLeft()+s.scrollSpeed))),a!==!1&&t.ui.ddmanager&&!s.dropBehaviour&&t.ui.ddmanager.prepareOffsets(this,e)),this.positionAbs=this._convertPositionTo("absolute"),this.options.axis&&"y"===this.options.axis||(this.helper[0].style.left=this.position.left+"px"),this.options.axis&&"x"===this.options.axis||(this.helper[0].style.top=this.position.top+"px"),i=this.items.length-1;i>=0;i--)if(n=this.items[i],o=n.item[0],r=this._intersectsWithPointer(n),r&&n.instance===this.currentContainer&&o!==this.currentItem[0]&&this.placeholder[1===r?"next":"prev"]()[0]!==o&&!t.contains(this.placeholder[0],o)&&("semi-dynamic"===this.options.type?!t.contains(this.element[0],o):!0)){if(this.direction=1===r?"down":"up","pointer"!==this.options.tolerance&&!this._intersectsWithSides(n))break;this._rearrange(e,n),this._trigger("change",e,this._uiHash());break}return this._contactContainers(e),t.ui.ddmanager&&t.ui.ddmanager.drag(this,e),this._trigger("sort",e,this._uiHash()),this.lastPositionAbs=this.positionAbs,!1},_mouseStop:function(e,i){if(e){if(t.ui.ddmanager&&!this.options.dropBehaviour&&t.ui.ddmanager.drop(this,e),this.options.revert){var n=this,o=this.placeholder.offset(),r=this.options.axis,s={};r&&"x"!==r||(s.left=o.left-this.offset.parent.left-this.margins.left+(this.offsetParent[0]===document.body?0:this.offsetParent[0].scrollLeft)),r&&"y"!==r||(s.top=o.top-this.offset.parent.top-this.margins.top+(this.offsetParent[0]===document.body?0:this.offsetParent[0].scrollTop)),this.reverting=!0,t(this.helper).animate(s,parseInt(this.options.revert,10)||500,function(){n._clear(e)})}else this._clear(e,i);return!1}},cancel:function(){if(this.dragging){this._mouseUp({target:null}),"original"===this.options.helper?this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"):this.currentItem.show();for(var e=this.containers.length-1;e>=0;e--)this.containers[e]._trigger("deactivate",null,this._uiHash(this)),this.containers[e].containerCache.over&&(this.containers[e]._trigger("out",null,this._uiHash(this)),this.containers[e].containerCache.over=0)}return this.placeholder&&(this.placeholder[0].parentNode&&this.placeholder[0].parentNode.removeChild(this.placeholder[0]),"original"!==this.options.helper&&this.helper&&this.helper[0].parentNode&&this.helper.remove(),t.extend(this,{helper:null,dragging:!1,reverting:!1,_noFinalSort:null}),this.domPosition.prev?t(this.domPosition.prev).after(this.currentItem):t(this.domPosition.parent).prepend(this.currentItem)),this},serialize:function(e){var i=this._getItemsAsjQuery(e&&e.connected),n=[];return e=e||{},t(i).each(function(){var i=(t(e.item||this).attr(e.attribute||"id")||"").match(e.expression||/(.+)[\-=_](.+)/);i&&n.push((e.key||i[1]+"[]")+"="+(e.key&&e.expression?i[1]:i[2]))}),!n.length&&e.key&&n.push(e.key+"="),n.join("&")},toArray:function(e){var i=this._getItemsAsjQuery(e&&e.connected),n=[];return e=e||{},i.each(function(){n.push(t(e.item||this).attr(e.attribute||"id")||"")}),n},_intersectsWith:function(t){var e=this.positionAbs.left,i=e+this.helperProportions.width,n=this.positionAbs.top,o=n+this.helperProportions.height,r=t.left,s=r+t.width,a=t.top,l=a+t.height,c=this.offset.click.top,u=this.offset.click.left,h="x"===this.options.axis||n+c>a&&l>n+c,d="y"===this.options.axis||e+u>r&&s>e+u,p=h&&d;return"pointer"===this.options.tolerance||this.options.forcePointerForContainers||"pointer"!==this.options.tolerance&&this.helperProportions[this.floating?"width":"height"]>t[this.floating?"width":"height"]?p:r<e+this.helperProportions.width/2&&i-this.helperProportions.width/2<s&&a<n+this.helperProportions.height/2&&o-this.helperProportions.height/2<l},_intersectsWithPointer:function(t){var i="x"===this.options.axis||e(this.positionAbs.top+this.offset.click.top,t.top,t.height),n="y"===this.options.axis||e(this.positionAbs.left+this.offset.click.left,t.left,t.width),o=i&&n,r=this._getDragVerticalDirection(),s=this._getDragHorizontalDirection();return o?this.floating?s&&"right"===s||"down"===r?2:1:r&&("down"===r?2:1):!1},_intersectsWithSides:function(t){var i=e(this.positionAbs.top+this.offset.click.top,t.top+t.height/2,t.height),n=e(this.positionAbs.left+this.offset.click.left,t.left+t.width/2,t.width),o=this._getDragVerticalDirection(),r=this._getDragHorizontalDirection();return this.floating&&r?"right"===r&&n||"left"===r&&!n:o&&("down"===o&&i||"up"===o&&!i)},_getDragVerticalDirection:function(){var t=this.positionAbs.top-this.lastPositionAbs.top;return 0!==t&&(t>0?"down":"up")},_getDragHorizontalDirection:function(){var t=this.positionAbs.left-this.lastPositionAbs.left;return 0!==t&&(t>0?"right":"left")},refresh:function(t){return this._refreshItems(t),this.refreshPositions(),this},_connectWith:function(){var t=this.options;return t.connectWith.constructor===String?[t.connectWith]:t.connectWith},_getItemsAsjQuery:function(e){var i,n,o,r,s=[],a=[],l=this._connectWith();if(l&&e)for(i=l.length-1;i>=0;i--)for(o=t(l[i]),n=o.length-1;n>=0;n--)r=t.data(o[n],this.widgetFullName),r&&r!==this&&!r.options.disabled&&a.push([t.isFunction(r.options.items)?r.options.items.call(r.element):t(r.options.items,r.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),r]);for(a.push([t.isFunction(this.options.items)?this.options.items.call(this.element,null,{options:this.options,item:this.currentItem}):t(this.options.items,this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),this]),i=a.length-1;i>=0;i--)a[i][0].each(function(){s.push(this)});return t(s)},_removeCurrentsFromItems:function(){var e=this.currentItem.find(":data("+this.widgetName+"-item)");this.items=t.grep(this.items,function(t){for(var i=0;i<e.length;i++)if(e[i]===t.item[0])return!1;return!0})},_refreshItems:function(e){this.items=[],this.containers=[this];var i,n,o,r,s,a,l,c,u=this.items,h=[[t.isFunction(this.options.items)?this.options.items.call(this.element[0],e,{item:this.currentItem}):t(this.options.items,this.element),this]],d=this._connectWith();if(d&&this.ready)for(i=d.length-1;i>=0;i--)for(o=t(d[i]),n=o.length-1;n>=0;n--)r=t.data(o[n],this.widgetFullName),r&&r!==this&&!r.options.disabled&&(h.push([t.isFunction(r.options.items)?r.options.items.call(r.element[0],e,{item:this.currentItem}):t(r.options.items,r.element),r]),this.containers.push(r));for(i=h.length-1;i>=0;i--)for(s=h[i][1],a=h[i][0],n=0,c=a.length;c>n;n++)l=t(a[n]),l.data(this.widgetName+"-item",s),u.push({item:l,instance:s,width:0,height:0,left:0,top:0})},refreshPositions:function(e){this.offsetParent&&this.helper&&(this.offset.parent=this._getParentOffset());var i,n,o,r;for(i=this.items.length-1;i>=0;i--)n=this.items[i],n.instance!==this.currentContainer&&this.currentContainer&&n.item[0]!==this.currentItem[0]||(o=this.options.toleranceElement?t(this.options.toleranceElement,n.item):n.item,e||(n.width=o.outerWidth(),n.height=o.outerHeight()),r=o.offset(),n.left=r.left,n.top=r.top);if(this.options.custom&&this.options.custom.refreshContainers)this.options.custom.refreshContainers.call(this);else for(i=this.containers.length-1;i>=0;i--)r=this.containers[i].element.offset(),this.containers[i].containerCache.left=r.left,this.containers[i].containerCache.top=r.top,this.containers[i].containerCache.width=this.containers[i].element.outerWidth(),this.containers[i].containerCache.height=this.containers[i].element.outerHeight();return this},_createPlaceholder:function(e){e=e||this;var i,n=e.options;n.placeholder&&n.placeholder.constructor!==String||(i=n.placeholder,n.placeholder={element:function(){var n=e.currentItem[0].nodeName.toLowerCase(),o=t("<"+n+">",e.document[0]).addClass(i||e.currentItem[0].className+" ui-sortable-placeholder").removeClass("ui-sortable-helper");return"tr"===n?e.currentItem.children().each(function(){t("<td>&#160;</td>",e.document[0]).attr("colspan",t(this).attr("colspan")||1).appendTo(o)}):"img"===n&&o.attr("src",e.currentItem.attr("src")),i||o.css("visibility","hidden"),o},update:function(t,o){(!i||n.forcePlaceholderSize)&&(o.height()||o.height(e.currentItem.innerHeight()-parseInt(e.currentItem.css("paddingTop")||0,10)-parseInt(e.currentItem.css("paddingBottom")||0,10)),o.width()||o.width(e.currentItem.innerWidth()-parseInt(e.currentItem.css("paddingLeft")||0,10)-parseInt(e.currentItem.css("paddingRight")||0,10)))}}),e.placeholder=t(n.placeholder.element.call(e.element,e.currentItem)),e.currentItem.after(e.placeholder),n.placeholder.update(e,e.placeholder)},_contactContainers:function(n){var o,r,s,a,l,c,u,h,d,p,f=null,m=null;for(o=this.containers.length-1;o>=0;o--)if(!t.contains(this.currentItem[0],this.containers[o].element[0]))if(this._intersectsWith(this.containers[o].containerCache)){if(f&&t.contains(this.containers[o].element[0],f.element[0]))continue;f=this.containers[o],m=o}else this.containers[o].containerCache.over&&(this.containers[o]._trigger("out",n,this._uiHash(this)),this.containers[o].containerCache.over=0);if(f)if(1===this.containers.length)this.containers[m].containerCache.over||(this.containers[m]._trigger("over",n,this._uiHash(this)),this.containers[m].containerCache.over=1);else{for(s=1e4,a=null,p=f.floating||i(this.currentItem),l=p?"left":"top",c=p?"width":"height",u=this.positionAbs[l]+this.offset.click[l],r=this.items.length-1;r>=0;r--)t.contains(this.containers[m].element[0],this.items[r].item[0])&&this.items[r].item[0]!==this.currentItem[0]&&(!p||e(this.positionAbs.top+this.offset.click.top,this.items[r].top,this.items[r].height))&&(h=this.items[r].item.offset()[l],d=!1,Math.abs(h-u)>Math.abs(h+this.items[r][c]-u)&&(d=!0,h+=this.items[r][c]),Math.abs(h-u)<s&&(s=Math.abs(h-u),a=this.items[r],this.direction=d?"up":"down"));if(!a&&!this.options.dropOnEmpty)return;if(this.currentContainer===this.containers[m])return;a?this._rearrange(n,a,null,!0):this._rearrange(n,null,this.containers[m].element,!0),this._trigger("change",n,this._uiHash()),this.containers[m]._trigger("change",n,this._uiHash(this)),this.currentContainer=this.containers[m],this.options.placeholder.update(this.currentContainer,this.placeholder),this.containers[m]._trigger("over",n,this._uiHash(this)),this.containers[m].containerCache.over=1
  }},_createHelper:function(e){var i=this.options,n=t.isFunction(i.helper)?t(i.helper.apply(this.element[0],[e,this.currentItem])):"clone"===i.helper?this.currentItem.clone():this.currentItem;return n.parents("body").length||t("parent"!==i.appendTo?i.appendTo:this.currentItem[0].parentNode)[0].appendChild(n[0]),n[0]===this.currentItem[0]&&(this._storedCSS={width:this.currentItem[0].style.width,height:this.currentItem[0].style.height,position:this.currentItem.css("position"),top:this.currentItem.css("top"),left:this.currentItem.css("left")}),(!n[0].style.width||i.forceHelperSize)&&n.width(this.currentItem.width()),(!n[0].style.height||i.forceHelperSize)&&n.height(this.currentItem.height()),n},_adjustOffsetFromHelper:function(e){"string"==typeof e&&(e=e.split(" ")),t.isArray(e)&&(e={left:+e[0],top:+e[1]||0}),"left"in e&&(this.offset.click.left=e.left+this.margins.left),"right"in e&&(this.offset.click.left=this.helperProportions.width-e.right+this.margins.left),"top"in e&&(this.offset.click.top=e.top+this.margins.top),"bottom"in e&&(this.offset.click.top=this.helperProportions.height-e.bottom+this.margins.top)},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var e=this.offsetParent.offset();return"absolute"===this.cssPosition&&this.scrollParent[0]!==document&&t.contains(this.scrollParent[0],this.offsetParent[0])&&(e.left+=this.scrollParent.scrollLeft(),e.top+=this.scrollParent.scrollTop()),(this.offsetParent[0]===document.body||this.offsetParent[0].tagName&&"html"===this.offsetParent[0].tagName.toLowerCase()&&t.ui.ie)&&(e={top:0,left:0}),{top:e.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:e.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if("relative"===this.cssPosition){var t=this.currentItem.position();return{top:t.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:t.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.currentItem.css("marginLeft"),10)||0,top:parseInt(this.currentItem.css("marginTop"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var e,i,n,o=this.options;"parent"===o.containment&&(o.containment=this.helper[0].parentNode),("document"===o.containment||"window"===o.containment)&&(this.containment=[0-this.offset.relative.left-this.offset.parent.left,0-this.offset.relative.top-this.offset.parent.top,t("document"===o.containment?document:window).width()-this.helperProportions.width-this.margins.left,(t("document"===o.containment?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top]),/^(document|window|parent)$/.test(o.containment)||(e=t(o.containment)[0],i=t(o.containment).offset(),n="hidden"!==t(e).css("overflow"),this.containment=[i.left+(parseInt(t(e).css("borderLeftWidth"),10)||0)+(parseInt(t(e).css("paddingLeft"),10)||0)-this.margins.left,i.top+(parseInt(t(e).css("borderTopWidth"),10)||0)+(parseInt(t(e).css("paddingTop"),10)||0)-this.margins.top,i.left+(n?Math.max(e.scrollWidth,e.offsetWidth):e.offsetWidth)-(parseInt(t(e).css("borderLeftWidth"),10)||0)-(parseInt(t(e).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left,i.top+(n?Math.max(e.scrollHeight,e.offsetHeight):e.offsetHeight)-(parseInt(t(e).css("borderTopWidth"),10)||0)-(parseInt(t(e).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top])},_convertPositionTo:function(e,i){i||(i=this.position);var n="absolute"===e?1:-1,o="absolute"!==this.cssPosition||this.scrollParent[0]!==document&&t.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,r=/(html|body)/i.test(o[0].tagName);return{top:i.top+this.offset.relative.top*n+this.offset.parent.top*n-("fixed"===this.cssPosition?-this.scrollParent.scrollTop():r?0:o.scrollTop())*n,left:i.left+this.offset.relative.left*n+this.offset.parent.left*n-("fixed"===this.cssPosition?-this.scrollParent.scrollLeft():r?0:o.scrollLeft())*n}},_generatePosition:function(e){var i,n,o=this.options,r=e.pageX,s=e.pageY,a="absolute"!==this.cssPosition||this.scrollParent[0]!==document&&t.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,l=/(html|body)/i.test(a[0].tagName);return"relative"!==this.cssPosition||this.scrollParent[0]!==document&&this.scrollParent[0]!==this.offsetParent[0]||(this.offset.relative=this._getRelativeOffset()),this.originalPosition&&(this.containment&&(e.pageX-this.offset.click.left<this.containment[0]&&(r=this.containment[0]+this.offset.click.left),e.pageY-this.offset.click.top<this.containment[1]&&(s=this.containment[1]+this.offset.click.top),e.pageX-this.offset.click.left>this.containment[2]&&(r=this.containment[2]+this.offset.click.left),e.pageY-this.offset.click.top>this.containment[3]&&(s=this.containment[3]+this.offset.click.top)),o.grid&&(i=this.originalPageY+Math.round((s-this.originalPageY)/o.grid[1])*o.grid[1],s=this.containment?i-this.offset.click.top>=this.containment[1]&&i-this.offset.click.top<=this.containment[3]?i:i-this.offset.click.top>=this.containment[1]?i-o.grid[1]:i+o.grid[1]:i,n=this.originalPageX+Math.round((r-this.originalPageX)/o.grid[0])*o.grid[0],r=this.containment?n-this.offset.click.left>=this.containment[0]&&n-this.offset.click.left<=this.containment[2]?n:n-this.offset.click.left>=this.containment[0]?n-o.grid[0]:n+o.grid[0]:n)),{top:s-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+("fixed"===this.cssPosition?-this.scrollParent.scrollTop():l?0:a.scrollTop()),left:r-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+("fixed"===this.cssPosition?-this.scrollParent.scrollLeft():l?0:a.scrollLeft())}},_rearrange:function(t,e,i,n){i?i[0].appendChild(this.placeholder[0]):e.item[0].parentNode.insertBefore(this.placeholder[0],"down"===this.direction?e.item[0]:e.item[0].nextSibling),this.counter=this.counter?++this.counter:1;var o=this.counter;this._delay(function(){o===this.counter&&this.refreshPositions(!n)})},_clear:function(t,e){this.reverting=!1;var i,n=[];if(!this._noFinalSort&&this.currentItem.parent().length&&this.placeholder.before(this.currentItem),this._noFinalSort=null,this.helper[0]===this.currentItem[0]){for(i in this._storedCSS)("auto"===this._storedCSS[i]||"static"===this._storedCSS[i])&&(this._storedCSS[i]="");this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper")}else this.currentItem.show();for(this.fromOutside&&!e&&n.push(function(t){this._trigger("receive",t,this._uiHash(this.fromOutside))}),!this.fromOutside&&this.domPosition.prev===this.currentItem.prev().not(".ui-sortable-helper")[0]&&this.domPosition.parent===this.currentItem.parent()[0]||e||n.push(function(t){this._trigger("update",t,this._uiHash())}),this!==this.currentContainer&&(e||(n.push(function(t){this._trigger("remove",t,this._uiHash())}),n.push(function(t){return function(e){t._trigger("receive",e,this._uiHash(this))}}.call(this,this.currentContainer)),n.push(function(t){return function(e){t._trigger("update",e,this._uiHash(this))}}.call(this,this.currentContainer)))),i=this.containers.length-1;i>=0;i--)e||n.push(function(t){return function(e){t._trigger("deactivate",e,this._uiHash(this))}}.call(this,this.containers[i])),this.containers[i].containerCache.over&&(n.push(function(t){return function(e){t._trigger("out",e,this._uiHash(this))}}.call(this,this.containers[i])),this.containers[i].containerCache.over=0);if(this.storedCursor&&(this.document.find("body").css("cursor",this.storedCursor),this.storedStylesheet.remove()),this._storedOpacity&&this.helper.css("opacity",this._storedOpacity),this._storedZIndex&&this.helper.css("zIndex","auto"===this._storedZIndex?"":this._storedZIndex),this.dragging=!1,this.cancelHelperRemoval){if(!e){for(this._trigger("beforeStop",t,this._uiHash()),i=0;i<n.length;i++)n[i].call(this,t);this._trigger("stop",t,this._uiHash())}return this.fromOutside=!1,!1}if(e||this._trigger("beforeStop",t,this._uiHash()),this.placeholder[0].parentNode.removeChild(this.placeholder[0]),this.helper[0]!==this.currentItem[0]&&this.helper.remove(),this.helper=null,!e){for(i=0;i<n.length;i++)n[i].call(this,t);this._trigger("stop",t,this._uiHash())}return this.fromOutside=!1,!0},_trigger:function(){t.Widget.prototype._trigger.apply(this,arguments)===!1&&this.cancel()},_uiHash:function(e){var i=e||this;return{helper:i.helper,placeholder:i.placeholder||t([]),position:i.position,originalPosition:i.originalPosition,offset:i.positionAbs,item:i.currentItem,sender:e?e.element:null}}})}(t)}),define("plugins/jquery-easing",["jquery"],function(t){t.easing.jswing=t.easing.swing,t.extend(t.easing,{def:"easeOutQuad",swing:function(e,i,n,o,r){return t.easing[t.easing.def](e,i,n,o,r)},easeInQuad:function(t,e,i,n,o){return n*(e/=o)*e+i},easeOutQuad:function(t,e,i,n,o){return-n*(e/=o)*(e-2)+i},easeInOutQuad:function(t,e,i,n,o){return(e/=o/2)<1?n/2*e*e+i:-n/2*(--e*(e-2)-1)+i},easeInCubic:function(t,e,i,n,o){return n*(e/=o)*e*e+i},easeOutCubic:function(t,e,i,n,o){return n*((e=e/o-1)*e*e+1)+i},easeInOutCubic:function(t,e,i,n,o){return(e/=o/2)<1?n/2*e*e*e+i:n/2*((e-=2)*e*e+2)+i},easeInQuart:function(t,e,i,n,o){return n*(e/=o)*e*e*e+i},easeOutQuart:function(t,e,i,n,o){return-n*((e=e/o-1)*e*e*e-1)+i},easeInOutQuart:function(t,e,i,n,o){return(e/=o/2)<1?n/2*e*e*e*e+i:-n/2*((e-=2)*e*e*e-2)+i},easeInQuint:function(t,e,i,n,o){return n*(e/=o)*e*e*e*e+i},easeOutQuint:function(t,e,i,n,o){return n*((e=e/o-1)*e*e*e*e+1)+i},easeInOutQuint:function(t,e,i,n,o){return(e/=o/2)<1?n/2*e*e*e*e*e+i:n/2*((e-=2)*e*e*e*e+2)+i},easeInSine:function(t,e,i,n,o){return-n*Math.cos(e/o*(Math.PI/2))+n+i},easeOutSine:function(t,e,i,n,o){return n*Math.sin(e/o*(Math.PI/2))+i},easeInOutSine:function(t,e,i,n,o){return-n/2*(Math.cos(Math.PI*e/o)-1)+i},easeInExpo:function(t,e,i,n,o){return 0==e?i:n*Math.pow(2,10*(e/o-1))+i},easeOutExpo:function(t,e,i,n,o){return e==o?i+n:n*(-Math.pow(2,-10*e/o)+1)+i},easeInOutExpo:function(t,e,i,n,o){return 0==e?i:e==o?i+n:(e/=o/2)<1?n/2*Math.pow(2,10*(e-1))+i:n/2*(-Math.pow(2,-10*--e)+2)+i},easeInCirc:function(t,e,i,n,o){return-n*(Math.sqrt(1-(e/=o)*e)-1)+i},easeOutCirc:function(t,e,i,n,o){return n*Math.sqrt(1-(e=e/o-1)*e)+i},easeInOutCirc:function(t,e,i,n,o){return(e/=o/2)<1?-n/2*(Math.sqrt(1-e*e)-1)+i:n/2*(Math.sqrt(1-(e-=2)*e)+1)+i},easeInElastic:function(t,e,i,n,o){var r=1.70158,s=0,a=n;if(0==e)return i;if(1==(e/=o))return i+n;if(s||(s=.3*o),a<Math.abs(n)){a=n;var r=s/4}else var r=s/(2*Math.PI)*Math.asin(n/a);return-(a*Math.pow(2,10*(e-=1))*Math.sin((e*o-r)*2*Math.PI/s))+i},easeOutElastic:function(t,e,i,n,o){var r=1.70158,s=0,a=n;if(0==e)return i;if(1==(e/=o))return i+n;if(s||(s=.3*o),a<Math.abs(n)){a=n;var r=s/4}else var r=s/(2*Math.PI)*Math.asin(n/a);return a*Math.pow(2,-10*e)*Math.sin((e*o-r)*2*Math.PI/s)+n+i},easeInOutElastic:function(t,e,i,n,o){var r=1.70158,s=0,a=n;if(0==e)return i;if(2==(e/=o/2))return i+n;if(s||(s=o*.3*1.5),a<Math.abs(n)){a=n;var r=s/4}else var r=s/(2*Math.PI)*Math.asin(n/a);return 1>e?-.5*a*Math.pow(2,10*(e-=1))*Math.sin((e*o-r)*2*Math.PI/s)+i:.5*a*Math.pow(2,-10*(e-=1))*Math.sin((e*o-r)*2*Math.PI/s)+n+i},easeInBack:function(t,e,i,n,o,r){return void 0==r&&(r=1.70158),n*(e/=o)*e*((r+1)*e-r)+i},easeOutBack:function(t,e,i,n,o,r){return void 0==r&&(r=1.70158),n*((e=e/o-1)*e*((r+1)*e+r)+1)+i},easeInOutBack:function(t,e,i,n,o,r){return void 0==r&&(r=1.70158),(e/=o/2)<1?n/2*e*e*(((r*=1.525)+1)*e-r)+i:n/2*((e-=2)*e*(((r*=1.525)+1)*e+r)+2)+i},easeInBounce:function(e,i,n,o,r){return o-t.easing.easeOutBounce(e,r-i,0,o,r)+n},easeOutBounce:function(t,e,i,n,o){return(e/=o)<1/2.75?n*7.5625*e*e+i:2/2.75>e?n*(7.5625*(e-=1.5/2.75)*e+.75)+i:2.5/2.75>e?n*(7.5625*(e-=2.25/2.75)*e+.9375)+i:n*(7.5625*(e-=2.625/2.75)*e+.984375)+i},easeInOutBounce:function(e,i,n,o,r){return r/2>i?.5*t.easing.easeInBounce(e,2*i,0,o,r)+n:.5*t.easing.easeOutBounce(e,2*i-r,0,o,r)+.5*o+n}})}),define("plugins/jquery-panels",["jquery"],function(t){var e=function(t,e){e=e||{};var i=t.outerWidth(),n=t.children(".panel-toggle");return e.full!==!1&&n[0]?i-n.outerWidth():i},i=function(e,i){this.element=t(e),this.options=t.extend({side:"left",closed:!1},i),this.opened=!0,this.side="right"===this.options.side||this.element.hasClass("panel-right")?"right":"left",this.element.addClass("panel-"+this.side),(this.options.closed===!0||this.element.hasClass("closed"))&&(this.opened=!1,this.element.addClass("closed").hide());var n=this;return this.element.on("click",".panel-toggle",function(){n.toggle()}),this};i.prototype={constructor:i,open:function(t){if(!this.opened){t=t||{},this.opened=!0;var i={},n={};i[this.side]=-e(this.element,t),n[this.side]=0,this.element.css(i).show().stop(),t.animate!==!1?this.element.animate(n,300):this.element.css(n),this.element.removeClass("closed")}},close:function(t){if(this.opened){t=t||{},this.opened=!1;var i={},n=e(this.element,t);i[this.side]=-n,this.element.stop(),t.animate!==!1?this.element.animate(i,300):this.element.css(i),this.element.addClass("closed")}},toggle:function(){this.opened?this.close():this.open()},isOpen:function(){return this.opened},isClosed:function(){return!this.opened}},t.fn.panel=function(e,n){"object"==typeof e&&(n=e),this.each(function(){var o=t(this),r=o.data("panel");r||(r=new i(this,n),o.data("panel",r)),"string"==typeof e&&r[e](n)})},t.fn.panel.Constructor=i,t(function(){t(".panel").panel(),t("[data-toggle*=panel]").each(function(){var e=t(this);e.on("click",function(){var i;i=e.data("target")?t(e.data("target")):e.parent(),i.panel("toggle")})})})}),define("plugins/jquery-scroller",["jquery","underscore"],function(t,e){var i={container:window,threshold:.75,autofill:!1,resize:!0,trigger:null},n=function(n,o){this.element=t(n),this.options=t.extend({},i,o),this.container=t(o.container);var r=this;return this.options.resize&&t(window).on("resize",e.debounce(function(){r.reset()},100)),this.container.on("scroll",e.debounce(function(){var t=r.container.scrollTop(),e=(this.element.height()-this.container.height())*this.options.threshold;!this.reached&&t>=e&&(this.reached=!0,this.element.trigger("scroller"))},100)),this.options.trigger&&this.element.on("scroller",this.options.trigger),this};n.prototype={constructor:n,reset:function(){this.reached=!1;var t=this.element.height()-this.container.height();return this.options.autofill&&0>t&&this.element.trigger("scroller"),this}},t.fn.scroller=function(e,i){"object"==typeof e&&(i=e),this.each(function(){var o=t(this),r=o.data("scroller");r||(r=new n(this,i),o.data("scroller",r)),"string"==typeof e&&r[e](i)})},t.fn.scroller.Constructor=n}),define("cilantro/ui/core",["../core","./templates","./controls","./dom","bootstrap","plugins/bootstrap-datepicker","plugins/jquery-ui","plugins/jquery-easing","plugins/jquery-panels","plugins/jquery-scroller"],function(t,e,i,n){return t.templates=e,t.controls=i,t.dom=n,t}),define("cilantro/ui/accordion",["underscore","marionette","./base"],function(t,e,i){var n=e.ItemView.extend({tagName:"li",template:"accordion/item"}),o=e.CompositeView.extend({className:"section",itemView:n,template:"accordion/section",itemViewContainer:".items",ui:{heading:".heading"},isEmpty:function(){return 0===this.collection.length},onCompositeCollectionRendered:function(){this.$el.toggle(!this.isEmpty())}}),r=e.CompositeView.extend({className:"group",template:"accordion/group",itemView:o,itemViewContainer:".sections",itemSectionItems:"items",options:{collapsable:!0,collapsed:!0},ui:{heading:".heading",icon:".heading [data-toggle]",inner:".inner"},events:{"click > .heading":"toggleCollapse"},itemViewOptions:function(t,e){return{model:t,index:e,collection:t[this.itemSectionItems]}},initialize:function(){this.collapsed=this.options.collapsed},onRender:function(){this.options.collapsable?this.collapsed&&this.renderCollapsed():(this.renderExpanded(),this.ui.icon.hide())},isEmpty:function(){if(this.collection.length>0)return!1;for(var t=0;t<this.collection.length;t++)if(this.collection.models[t].items.length>0)return!1;return!0},onCompositeCollectionRendered:function(){if(this.$el.toggle(!this.isEmpty()),this.collection.length>0){var t=this.collection.at(0),e=this.children.findByModel(t);e.ui.heading.toggle(this.collection.length>1||t.id>-1)}},collapse:function(t){this.options.collapsable&&(this.collapsed=!0,this.renderCollapsed(t))},expand:function(t){this.options.collapsable&&(this.collapsed=!1,this.renderExpanded(t))},toggleCollapse:function(t){t.preventDefault(),this.options.collapsable&&(this.collapsed?this.expand({animate:!0}):this.collapse({animate:!0}))},renderState:function(t){this.collapsed&&this.options.collapsable?this.renderCollapsed(t):this.renderExpanded(t)},renderExpanded:function(t){t=t||{},this.$el.removeClass("collapsed"),t.animate?this.ui.inner.collapse("show"):this.ui.inner.addClass("in")},renderCollapsed:function(t){t=t||{},this.$el.addClass("collapsed"),t.animate?this.ui.inner.collapse("hide"):this.ui.inner.removeClass("in")}}),s=e.CollectionView.extend({className:"accordion",itemView:r,emptyView:i.EmptyView,itemGroupSections:"sections",options:{collapsable:!0},itemViewOptions:function(t,e){return{model:t,index:e,collection:t[this.itemGroupSections],collapsable:this.options.collapsable}}});return{Accordion:s,AccordionGroup:r,AccordionSection:o,AccordionItem:n}}),define("cilantro/ui/charts/options",[],function(){var t,e;return t={chart:{style:{fontFamily:'"Helvetica Neue", Helvetica, Arial, sans-serif'}},title:{text:"",align:"right"},subtitle:{align:"right"},exporting:{enabled:!1},credits:{enabled:!1},tooltip:{snap:1,useHTML:!0,borderWidth:1,borderRadius:3},plotOptions:{series:{cursor:"pointer",shadow:!1,borderWidth:0,borderColor:"#4b8cf7",animation:{duration:400},color:"#777",states:{select:{color:"#0088cc"},hover:{enabled:!1}}},area:{lineWidth:1,shadow:!1,stacking:"normal",states:{hover:{lineWidth:1}},marker:{enabled:!1,states:{hover:{enabled:!0,radius:5}}},fillOpacity:.1},areaspline:{lineWidth:1,shadow:!1,states:{hover:{lineWidth:1}},marker:{enabled:!1,states:{hover:{enabled:!0}}},fillOpacity:.1},bar:{borderWidth:0,minPointLength:2},column:{borderWidth:0,minPointLength:2},pie:{allowPointSelect:!0,cursor:"pointer",showInLegend:!0},scatter:{marker:{radius:5,states:{hover:{enabled:!1}}},states:{hover:{marker:{enabled:!1}}}}}},e={chart:{defaultSeriesType:"areaspline",margin:[0,0,0,0],height:40},title:{text:"",align:"left",y:0,x:0,style:{fontSize:"8px",color:"#333333"}},credits:{enabled:!1},legend:{enabled:!1},tooltip:{enabled:!1},xAxis:{startOnTick:!0,labels:{enabled:!1}},yAxis:{endOnTick:!1,labels:{enabled:!1}},plotOptions:{series:{lineWidth:1,shadow:!1,states:{hover:{enabled:!1}},marker:{enabled:!1}},areaspline:{fillOpacity:.1},area:{fillOpacity:.1}}},{defaults:t,sparkline:e}});var __hasProp={}.hasOwnProperty,__extends=function(t,e){function i(){this.constructor=t}for(var n in e)__hasProp.call(e,n)&&(t[n]=e[n]);return i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype,t};define("cilantro/ui/charts/core",["jquery","underscore","backbone","highcharts","../base","../controls","./options"],function(t,e,i,n,o,r,s){var a,l,c,u,h,d,p,f,m,g,v,y,w,b,x,_,C,k,S,P,T,E;return p={el:"chart.renderTo",type:"chart.type",height:"chart.height",width:"chart.width",labelFormatter:"plotOptions.series.dataLabels.formatter",tooltipFormatter:"tooltip.formatter",animate:"plotOptions.series.animation",categories:"xAxis.categories",title:"title.text",subtitle:"subtitle.text",xAxis:"xAxis.title.text",yAxis:"yAxis.title.text",stacking:"plotOptions.series.stacking",legend:"legend.enabled",suffix:"tooltip.valueSuffix",prefix:"tooltip.valuePrefix",series:"series"},u=function(i){function r(){return w=r.__super__.constructor.apply(this,arguments)}return __extends(r,i),r.prototype.template=function(){},r.prototype.emptyView=o.EmptyView,r.prototype.loadView=o.LoadView,r.prototype.chartOptions=s.defaults,r.prototype.initialize=function(i){var n,o,a;if(s=e.extend({},i.chart),null!=s){for(n in s)o=s[n],p[n]&&(this.setOption(p[n],o),delete s[n]);this.chartOptions=t.extend(!0,{},this.chartOptions,s)}r.__super__.initialize.call(this,i),null==(a=this.chartOptions).el&&(a.el=this.el)},r.prototype.setOption=function(t,e){var i,n,o,r,s,a;for(n=this.chartOptions,r=t.split("."),i=r.pop(),s=0,a=r.length;a>s;s++)o=r[s],null==n[o]&&(n[o]={}),n=n[o];return n[i]=e},r.prototype.getChartOptions=function(){return this.chartOptions},r.prototype.showEmptyView=function(){var t;return t=new this.emptyView({message:"No data is available for charting"}),this.$el.html(t.render().el)},r.prototype.onChartLoaded=function(){return t(".load-view").remove()},r.prototype.renderChart=function(t){var e,i;return e=new this.loadView({message:"Loading chart"}),this.$el.append(e.render().el),t.chart.events={load:this.onChartLoaded},this.chart&&"function"==typeof(i=this.chart).destroy&&i.destroy(),this.chart=new n.Chart(t)},r}(r.Control),u.setDefaultOption=function(t,i){var n,o,r,s,a,l,c,u;for(o=this.prototype.chartOptions=e.clone(this.prototype.chartOptions),l=t.split("."),n=l.pop(),r=null,s=null,c=0,u=l.length;u>c;c++)a=l[c],r=o,o=null!=r[a]?e.clone(r[a]):{},r[a]=o;return o[n]=i},a=function(t){function e(){return b=e.__super__.constructor.apply(this,arguments)}return __extends(e,t),e}(u),a.setDefaultOption("chart.type","area"),l=function(t){function e(){return x=e.__super__.constructor.apply(this,arguments)}return __extends(e,t),e}(u),l.setDefaultOption("chart.type","areaspline"),c=function(t){function e(){return _=e.__super__.constructor.apply(this,arguments)}return __extends(e,t),e}(u),c.setDefaultOption("chart.type","bar"),h=function(t){function e(){return C=e.__super__.constructor.apply(this,arguments)}return __extends(e,t),e}(u),h.setDefaultOption("chart.type","column"),d=function(t){function e(){return k=e.__super__.constructor.apply(this,arguments)}return __extends(e,t),e}(u),d.setDefaultOption("chart.type","line"),f=function(t){function e(){return S=e.__super__.constructor.apply(this,arguments)}return __extends(e,t),e}(u),f.setDefaultOption("chart.type","pie"),f.setDefaultOption("legend.enabled",!0),m=function(t){function e(){return P=e.__super__.constructor.apply(this,arguments)}return __extends(e,t),e}(u),m.setDefaultOption("chart.type","scatter"),v=function(t){function e(){return T=e.__super__.constructor.apply(this,arguments)}return __extends(e,t),e}(u),v.setDefaultOption("chart.type","spline"),g=function(t){function e(){return E=e.__super__.constructor.apply(this,arguments)}return __extends(e,t),e.prototype.chartOptions=s.sparkline,e}(u),y={Chart:u,AreaChart:a,AreaSplineChart:l,BarChart:c,ColumnChart:h,LineChart:d,PieChart:f,ScatterChart:m,SplineChart:v,Sparkline:g},e.extend(i,y),y}),define("cilantro/ui/charts/utils",["underscore","highcharts"],function(t,e){var i,n,o,r,s;return n=function(t){var i;return i=e.getOptions().colors,i[t%i.length]},i=/\d{4}-\d{2]-\d{2]/,r=function(t){var e,i,n;return n=parseInt(t.substr(0,4)),i=parseInt(t.substr(5,2))-1,e=parseInt(t.substr(8,2)),Date.UTC(n,i,e)},s=function(t,i,o){var s,a,l,c,u,h,d,p,f,m,g,v,y,w,b,x,_,C,k,S,P,T,E,N,A,O,I,V,M,D,L,q,j,F,R,$,B,H;if(i.length>2)throw new Error("3-dimensional charts are not supported.                Specify which field the series applies to.");if(!i)throw new Error("The field instances must be supplied");for(T=[],M=[],P=i[0],V=i[1],E=P.get("name"),S=P.get("enumerable")||"boolean"===P.get("simple_type"),N="date"===P.get("simple_type")?"datetime":"linear",V?(D=V.get("name"),I=V.get("enumerable")||"boolean"===V.get("simple_type"),L="date"===V.get("simple_type")?"datetime":"linear"):(D="Frequency",I=!1,L="linear"),S&&I?(a="scatter",T.push(" "),M.push(" ")):a=!V||S||I?I?"scatter":"datetime"===N||"datetime"===L?"line":"column":"scatter",b={},l=t.clustered,B=t.data,h=j=0,R=B.length;R>j;h=++j)y=B[h],C=null!=o?y.values.slice(o,o+1)[0]:"",(w=b[C])?(w.data.push(y),w.stats.min=Math.min(w.stats.min,y.count),w.stats.max=Math.max(w.stats.max,y.count),w.stats.sum+=y.count):(w=b[C]={name:C,stats:{min:y.count,max:y.count,sum:y.count}},w.data=S&&I?[{x:0,y:0,radius:0,sentinel:!0},y]:[y]),k=y.values[0],null===k&&(k="(no data)"),S?(-1===(d=T.indexOf(k.toString()))&&(d=T.push(k.toString())-1),k=d):"datetime"===N&&(k=r(k)),V?(O=y.values[1],null===O&&(O="(no data)"),I?(-1===(d=M.indexOf(O.toString()))&&(d=M.push(O.toString())-1),O=d):"datetime"===L&&(O=r(O))):O=y.count,y.x=k,y.y=O;x=[],S&&I&&(A=T.push(" ")-1,q=M.push(" ")-1),_=0;for(f in b){if(w=b[f],S&&I&&(w.data.push({x:0,y:q,radius:0,sentinel:!0}),w.data.push({x:A,y:q,radius:0,sentinel:!0}),w.data.push({x:A,y:q,radius:0,sentinel:!0})),x.push(w),s=w.stats.avg=w.stats.sum/parseFloat(w.data.length,10),p=w.stats.max,"scatter"===a)for(H=w.data,F=0,$=H.length;$>F;F++)v=H[F],v.sentinel||(m=Math.min(Math.max(parseInt(5*(parseFloat(v.count,10)/s))/10,.05),1),c=e.Color(n(_)).setOpacity(m),v.marker={fillColor:c.get()},S&&(v.marker.radius=7));_++}return u="scatter"===a&&S?x[1]?function(){return"<h5>"+this.series.name+"</h5><br /><b>"+E+":</b> "+this.series.xAxis.categories[this.point.x]+"<br /><b>"+D+":</b> "+this.series.yAxis.categories[this.point.y]}:function(){return"<b>"+E+":</b> "+this.series.xAxis.categories[this.point.x]+"<br /><b>"+D+":</b> "+this.series.yAxis.categories[this.point.y]}:"column"===a&&S?x[1]?function(){return"<h5>"+this.series.name+"</h5><br /><b>"+E+":</b> "+this.series.xAxis.categories[this.point.x]+"<br /><b>"+D+":</b> "+e.numberFormat(parseFloat(this.y))}:function(){return"<b>"+E+":</b> "+this.series.xAxis.categories[this.point.x]+"<br /><b>"+D+":</b> "+e.numberFormat(parseFloat(this.y))}:x[1]?function(){return"<h5>"+this.series.name+"</h5><br /><b>"+E+":</b> "+e.numberFormat(parseFloat(this.x))+"<br /><b>"+D+":</b> "+e.numberFormat(parseFloat(this.y))}:function(){return"<b>"+E+":</b> "+e.numberFormat(parseFloat(this.x))+"<br /><b>"+D+":</b> "+e.numberFormat(parseFloat(this.y))},g={clustered:l,chart:{type:a},title:{text:V?""+E+" vs. "+D:""+E+" "+D},series:x,xAxis:{title:{text:E},type:N},yAxis:{title:{text:D},type:L},tooltip:{formatter:u}},T.length&&(g.xAxis.categories=T),M.length&&(g.yAxis.categories=M),x[1]||(g.legend={enabled:!1}),"scatter"===a&&(g.yAxis.gridLineWidth=0,S||(g.chart.zoomType="xy")),g},o=function(e){var i,n,o,r,s;for(o=[],r=0,s=e.length;s>r;r++)i=e[r],n=t.clone(i),n.x=i.values[0],n.y=null!=i.values[1]?i.values[1]:i.count,o.push(n);return{data:t.sortBy(o,"x")}},{processResponse:s,getSeries:o}});var __hasProp={}.hasOwnProperty,__extends=function(t,e){function i(){this.constructor=t}for(var n in e)__hasProp.call(e,n)&&(t[n]=e[n]);return i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype,t},__bind=function(t,e){return function(){return t.apply(e,arguments)}},__indexOf=[].indexOf||function(t){for(var e=0,i=this.length;i>e;e++)if(e in this&&this[e]===t)return e;return-1};define("cilantro/ui/charts/dist",["jquery","underscore","../base","./core","./utils"],function(t,e,i,n,o){var r,s,a,l;return r=function(t){function e(){return a=e.__super__.constructor.apply(this,arguments)}return __extends(e,t),e.prototype.message="Chart loading...",e}(i.LoadView),s=function(i){function n(){return this.setValue=__bind(this.setValue,this),this.chartClick=__bind(this.chartClick,this),l=n.__super__.constructor.apply(this,arguments)}return __extends(n,i),n.prototype.template="charts/chart",n.prototype.loadView=r,n.prototype.ui={chart:".chart",heading:".heading",status:".heading .status"},n.prototype.showLoadView=function(){var t;return(t=new this.loadView).render(),this.ui.chart.html(t.el)},n.prototype.chartClick=function(t){var e,i;return e=null!=(i=t.point.category)?i:t.point.name,t.point.select(!t.point.selected,!0),this.change()},n.prototype.interactive=function(t){var e,i;return"pie"===(e=null!=(i=t.chart)?i.type:void 0)?!0:"column"===e&&null!=t.xAxis.categories?!0:!1},n.prototype.getChartOptions=function(e){var i;return i=o.processResponse(e,[this.model]),i.clustered?this.ui.status.text("Clustered").show():this.ui.status.hide(),this.interactive(i)&&this.setOption("plotOptions.series.events.click",this.chartClick),t.extend(!0,i,this.chartOptions),i.chart.renderTo=this.ui.chart[0],i},n.prototype.getField=function(){return this.model.id},n.prototype.getValue=function(){var t,e;return e=this.chart.getSelectedPoints(),function(){var i,n,o;for(o=[],i=0,n=e.length;n>i;i++)t=e[i],o.push(t.category);return o}()},n.prototype.getOperator=function(){return"in"},n.prototype.removeChart=function(){return n.__super__.removeChart.apply(this,arguments),this.node?this.node.destroy():void 0},n.prototype.onRender=function(){var t=this;return null!=this.options.parentView&&this.ui.chart.width(this.options.parentView.$el.width()),this.showLoadView(),this.model.distribution(function(e){var i;if(!t.isClosed)return i=t.getChartOptions(e),e.size?t.renderChart(i):t.showEmptyView(i)})},n.prototype.setValue=function(t){var i,n,o,r,s,a;if(e.isArray(t)||(t=[]),null!=this.chart)for(n=this.chart.series[0].points,o=0,r=n.length;r>o;o++)i=n[o],i.select(null!=(s=i.name)?s:(a=i.category,__indexOf.call(t,a)>=0),!0)},n}(n.Chart),{FieldChart:s}});var __bind=function(t,e){return function(){return t.apply(e,arguments)}},__hasProp={}.hasOwnProperty,__extends=function(t,e){function i(){this.constructor=t}for(var n in e)__hasProp.call(e,n)&&(t[n]=e[n]);return i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype,t};define("cilantro/ui/charts/axis",["marionette"],function(t){var e,i;return e=function(t){function e(){return this.render=__bind(this.render,this),i=e.__super__.constructor.apply(this,arguments)}return __extends(e,t),e.prototype.tagName="select",e.prototype.options={enumerableOnly:!1},e.prototype.initialize=function(){return this.collection.when(this.render)},e.prototype.render=function(){var t,e,i,n;for(this.$el.append("<option value=>---</option>"),n=this.collection.models,e=0,i=n.length;i>e;e++)t=n[e],t.get("searchable")||(!this.options.enumerableOnly||t.get("enumerable"))&&this.$el.append('<option value="'+t.id+'">'+t.get("name")+"</option>");return this.$el},e.prototype.getSelected=function(){return this.collection.get(parseInt(this.$el.val()))},e}(t.ItemView),{FieldAxis:e}});var __hasProp={}.hasOwnProperty,__extends=function(t,e){function i(){this.constructor=t}for(var n in e)__hasProp.call(e,n)&&(t[n]=e[n]);return i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype,t};define("cilantro/ui/charts/editable",["jquery","underscore","./dist","./axis"],function(t,e,i,n){var o,r;return o=function(o){function s(){return r=s.__super__.constructor.apply(this,arguments)}return __extends(s,o),s.prototype.template="charts/editable-chart",s.prototype.events=e.extend({"click .fullsize":"toggleExpanded"},i.FieldChart.prototype.events),s.prototype.ui=e.extend({toolbar:".btn-toolbar",fullsizeToggle:".fullsize",form:".editable",xAxis:"[name=x-Axis]",yAxis:"[name=y-Axis]",series:"[name=series]"},i.FieldChart.prototype.ui),s.prototype.onRender=function(){var t;return this.options.editable===!1?(this.ui.form.detach(),this.ui.toolbar.detach()):(this.xAxis=new n.FieldAxis({el:this.ui.xAxis,collection:this.collection}),this.yAxis=new n.FieldAxis({el:this.ui.yAxis,collection:this.collection}),this.series=new n.FieldAxis({el:this.ui.series,enumerableOnly:!0,collection:this.collection}),this.model?(this.model.get("xAxis")&&this.ui.form.hide(),(t=this.model.get("expanded"))?this.expand():this.contract()):void 0)},s.prototype.customizeOptions=function(e){var i;return this.ui.status.detach(),this.ui.heading.text(e.title.text),e.title.text="",e.series[0]?(this.ui.form.hide(),i=[],e.clustered&&i.push("Clustered"),i[0]&&(this.ui.status.text(i.join(", ")).show(),this.ui.heading.append(this.$status)),this.interactive(e)&&this.enableChartEvents(),t.extend(!0,e,this.chartOptions),e.chart.renderTo=this.ui.chart[0],e):(this.ui.chart.html("<p class=no-data>Unfortunately, there is                    no data to graph here.</p>"),void 0)
  },s.prototype.changeChart=function(t){var e=this;return t&&t.preventDefault(),this.collection.when(function(){var i,n,o,r,s,a,l;return null==t&&((a=e.model.get("xAxis"))&&e.xAxis.$el.val(a.toString()),(l=e.model.get("yAxis"))&&e.yAxis.$el.val(l.toString()),(o=e.model.get("series"))&&e.series.$el.val(o.toString())),a=e.xAxis.getSelected(),l=e.yAxis.getSelected(),o=e.series.getSelected(),a?(s=e.model.get("_links").distribution.href,n=[a],i="dimension="+a.id,l&&(n.push(l),i=i+"&dimension="+l.id),o&&(r=l?2:1,i=i+"&dimension="+o.id),t&&e.model&&e.model.set({xAxis:a.id,yAxis:l?l.id:void 0,series:o?o.id:void 0}),e.update(s,i,n,r)):void 0})},s.prototype.disableSelected=function(e){var i,n;return i=t(e.target),this.xAxis.el===e.target?(this.yAxis.$("option").prop("disabled",!1),this.series.$("option").prop("disabled",!1)):this.yAxis.el===e.target?(this.xAxis.$("option").prop("disabled",!1),this.series.$("option").prop("disabled",!1)):(this.xAxis.$("option").prop("disabled",!1),this.yAxis.$("option").prop("disabled",!1)),""!==(n=i.val())?this.xAxis.el===e.target?(this.yAxis.$("option[value="+n+"]").prop("disabled",!0).val(""),this.series.$("option[value="+n+"]").prop("disabled",!0).val("")):this.yAxis.el===e.target?(this.xAxis.$("option[value="+n+"]").prop("disabled",!0).val(""),this.series.$("option[value="+n+"]").prop("disabled",!0).val("")):(this.xAxis.$("option[value="+n+"]").prop("disabled",!0).val(""),this.yAxis.$("option[value="+n+"]").prop("disabled",!0).val("")):void 0},s.prototype.toggleExpanded=function(){var t;return t=this.model.get("expanded"),t?this.contract():this.expand(),this.model.save({expanded:!t})},s.prototype.resize=function(){var t;return t=this.ui.chart.width(),this.chart?this.chart.setSize(t,null,!1):void 0},s.prototype.expand=function(){return this.$fullsizeToggle.children("i").removeClass("icon-resize-small").addClass("icon-resize-full"),this.$el.addClass("expanded"),this.resize()},s.prototype.contract=function(){return this.$fullsizeToggle.children("i").removeClass("icon-resize-full").addClass("icon-resize-small"),this.$el.removeClass("expanded"),this.resize()},s.prototype.hideToolbar=function(){return this.ui.toolbar.fadeOut(200)},s.prototype.showToolbar=function(){return this.ui.toolbar.fadeIn(200)},s.prototype.toggleEdit=function(){return this.ui.form.is(":visible")?this.ui.form.fadeOut(300):this.ui.form.fadeIn(300)},s}(i.FieldChart),{EditableFieldChart:o}});var __slice=[].slice;define("cilantro/ui/charts",["underscore","./charts/dist","./charts/axis","./charts/editable"],function(){var t,e;return e=arguments[0],t=2<=arguments.length?__slice.call(arguments,1):[],e.extend.apply(e,[{}].concat(__slice.call(t)))}),define("cilantro/ui/concept/info",["jquery","underscore","marionette","../core"],function(t,e,i,n){var o=i.ItemView.extend({className:"concept-info",template:"concept/info",ui:{name:".name",category:".category",description:".description",descriptionText:".description .text",descriptionToggle:".description .toggle"},events:{"click .category-link":"onCategoryLinkClick","click @ui.descriptionToggle":"toggleDescription"},initialize:function(){e.bindAll(this,"renderDescriptionToggle"),0===this.model.fields.length&&this.listenToOnce(this.model.fields,"reset",function(){this.render()})},onCategoryLinkClick:function(e){var i=t(e.target);n.panels.concept.triggerSearch(i.text())},serializeData:function(){var t=this.model.toJSON();if(1===this.model.fields.length){var e=this.model.fields.at(0);t.description||(t.description=e.get("description")),t.unit||(t.unit=e.get("unit"))}return t},onRender:function(){e.defer(this.renderDescriptionToggle),t(window).on("resize",this.renderDescriptionToggle)},onClose:function(){t(window).off("resize",this.renderDescriptionToggle)},descriptionOverflows:function(){var t=this.ui.descriptionText.prop("scrollWidth"),e=this.ui.descriptionText.prop("offsetWidth");return t>e},renderDescriptionToggle:function(){var t=this.ui.description.hasClass("ellipsis");this.ui.description.addClass("ellipsis"),this.descriptionOverflows()?(this.ui.descriptionToggle.show(),this.ui.description.toggleClass("ellipsis",t)):(this.ui.descriptionToggle.hide(),this.ui.description.addClass("ellipsis"))},toggleDescription:function(){if(this.ui.description.hasClass("ellipsis")){if(!this.descriptionOverflows())return;this.ui.description.removeClass("ellipsis")}else this.ui.description.addClass("ellipsis")}});return{ConceptInfo:o}}),define("cilantro/ui/concept/search",["underscore","../search"],function(t,e){var i=e.Search.extend({className:"concept-search search",options:function(){return t.extend({},e.Search.prototype.options,{placeholder:"Search by name, description, or data..."})},initialize:function(){if(this._request=null,!this.options.handler)throw new Error("no search handler defined")},search:function(t){this._request&&this._request.abort();var e=this.options.handler;t?this._request=this.collection.search(t,function(i){e(t,i)}):e(null,[])}});return{ConceptSearch:i}}),define("cilantro/ui/concept/index",["backbone","../core","../base","../accordion"],function(t,e,i,n){var o=n.AccordionItem.extend({events:{"click a":"click"},initialize:function(){this.listenTo(e,e.CONCEPT_FOCUS,this.toggleFocus)},click:function(t){t.preventDefault(),e.trigger(e.CONCEPT_FOCUS,this.model.id)},toggleFocus:function(t){this.$el.toggleClass("active",t===this.model.id)}}),r=n.AccordionSection.extend({itemView:o,filter:function(t,e){var i=!1;return this.children.each(function(n){!t||e[n.model.id]?(n.$el.show(),i=!0):n.$el.hide()}),this.$el.toggle(i),i}}),s=n.AccordionGroup.extend({itemView:r,filter:function(t,e){var i=!1;return this.children.each(function(n){n.filter(t,e)&&(i=!0)}),t?i?(this.$el.show(),this.renderExpanded()):this.$el.hide():(this.$el.show(),this.renderState()),i},find:function(t){var e,i,n;for(e in this.children._views)if(i=this.children._views[e],i.children&&(n=i.children.findByModel(t)))return n}}),a=n.Accordion.extend({className:"concept-index accordion",itemView:s,emptySearchView:i.EmptySearchView,showCollection:function(){this.resetGroups();var t=this;this.groups.each(function(e,i){t.addItemView(e,t.getItemView(e),i)})},getGroup:function(t){if(t.category){for(var e=t.category;e.parent;)e=e.parent;return e}return{id:-1,name:"Other"}},getSection:function(t){return t.category&&t.category.parent?t.category:{id:-1,name:"Other"}},resetGroups:function(){this.groups?this.groups.reset():this.groups=new t.Collection(null,{comparator:"order"});var e=this;this.collection.each(function(t){e.groupModel(t)})},groupModel:function(e){var i=this.getGroup(e.attributes),n=this.getSection(e.attributes),o=this.groups.get(i.id);o||(o=new t.Model(i),o.sections=new t.Collection(null,{comparator:"order"}),this.groups.add(o));var r=o.sections.get(n.id);r||(r=new t.Model(n),r.items=new t.Collection(null,{comparator:"order"}),o.sections.add(r)),r.items.add(e)},filter:function(t,e){var i={};if(t){var n,o,r;for(n=0;n<e.length;n++)o=e[n],(r=this.collection.get(o.id))&&(i[r.id]=r)}var s=!1;return this.children.each(function(e){e.filter(t,i)&&(s=!0)}),s?this.closeEmptySearchView():this.showEmptySearchView(t),s},find:function(t){var e,i,n;for(e in this.children._views)if(i=this.children._views[e],n=i.find(t))return n},showEmptySearchView:function(t){this.closeEmptySearchView(),this._emptyView=new this.emptySearchView({message:'<p>We could not find anything related to "'+t+'"</p>'}),this.$el.append(this._emptyView.render().el)},closeEmptySearchView:function(){this._emptyView&&(this._emptyView.remove(),delete this._emptyView)}});return{ConceptIndex:a,ConceptGroup:s,ConceptSection:r,ConceptItem:o}}),define("cilantro/ui/concept/panel",["underscore","marionette","./index","./search"],function(t,e,i,n){var o=e.Layout.extend({id:"concept-panel",className:"panel panel-left closed",template:"concept/panel",regions:{search:".search-region",index:".index-region"},regionViews:{search:n.ConceptSearch,index:i.ConceptIndex},onRender:function(){this.$el.panel();var t=new this.regionViews.index({collection:this.collection}),e=new this.regionViews.search({collection:this.collection,handler:function(e,i){t.filter(e,i)}});this.search.show(e),this.index.show(t)},triggerSearch:function(t){this.search.currentView.trigger("search",t)},openPanel:function(t){this.$el.panel("open",t)},closePanel:function(t){this.$el.panel("close",t)},isPanelOpen:function(t){return this.$el.data("panel").isOpen(t)},isPanelClosed:function(t){this.$el.data("panel").isClosed(t)}});return{ConceptPanel:o}}),define("cilantro/ui/field/info",["underscore","marionette"],function(t,e){var i=e.ItemView.extend({className:"field-info",template:"field/info"});return{FieldInfo:i}}),define("cilantro/ui/config",["underscore","./core"],function(t,e){var i=function(i,n){var o,r,s=[{}],a=e.config.get(n+".instances."+i.id+".form");t.isFunction(a)?o=a:t.isString(a)?r=a:t.isObject(a)&&s.push(a);var l=e.config.get(n+".types."+i.get("type")+".form");!o&&t.isFunction(l)?o=l:!r&&t.isString(l)?r=l:s.push(l);var c=e.config.get(n+".defaults.form");return!o&&t.isFunction(c)?o=c:!r&&t.isString(c)?r=c:s.push(c),s=t.defaults.apply(null,s),{view:o,module:r,options:s}};return{resolveFormOptions:i}}),define("cilantro/ui/field/stats",["jquery","underscore","backbone","marionette","../core","../base","../charts","../charts/utils"],function(t,e,i,n,o,r,s,a){var l=function(t){return e.isNumber(t)?o.utils.prettyNumber(t):t},c=n.ItemView.extend({tagName:"li",template:function(t){var e={min:"Min",max:"Max",avg:"Average",count:"Count",distinct_count:"Unique values"};return"<span class=stat-label>"+(e[t.key]||t.key)+'</span> <span class=stat-value title="'+t.value+'">'+l(t.value)+"</span>"}}),u=n.CollectionView.extend({tagName:"ul",itemView:c});s.FieldChart.extend({className:"sparkline",chartOptions:i.Sparkline.prototype.chartOptions,getChartOptions:function(e){var i={series:[a.getSeries(e.data)]};return t.extend(!0,i,this.chartOptions),i.chart.renderTo=this.ui.chart[0],i}});var h=n.Layout.extend({className:"field-stats",template:"field/stats",regions:{values:".stats-values",chart:".stats-chart"},onRender:function(){this.model.stats&&(this.values.show(new u({collection:this.model.stats})),this.model.stats.length||this.model.stats.fetch({reset:!0}))}});return{FieldStats:h}}),define("cilantro/ui/field/controls",["underscore","marionette","loglevel","../../core","../base","../controls"],function(t,e,i,n,o,r){var s=function(t,e){e&&(e.listenTo(t,"change",function(t,i){e.clear(),e.set(i)}),t.listenTo(e,"change",function(e){t._changing||t.set(e.toJSON())}))},a=function(t,e){e.stopListening(t),t.stopListening(e)},l=o.ErrorView.extend({message:"Error rendering field control"}),c=o.LoadView.extend({message:"Loading and rendering field controls..."}),u=e.ItemView.extend({errorView:l,template:function(){},initialize:function(){var e=this.model.get("control");if(e=r.get(e)||e,t.isFunction(e))this.viewClass=e;else{var n=this;require([e],function(t){n.viewClass=t,n.render()},function(t){n.showErrorView(),i.debug(t)})}},onRender:function(){this.viewClass&&(this.view=new this.viewClass(this.model.toJSON()),this.view.render(),this.$el.html(this.view.el),this.listenTo(this.view,{beforeready:this.onControlBeforeReady,error:this.onControlError}),this.view.ready(!0))},onBeforeClose:function(){if(this.view){var t=this.model.get("filter");a(this.view,t),this.view.close()}},onControlBeforeReady:function(){var t=this.model.get("filter");this.view.set(t.toJSON()),s(this.view,t)},onControlError:function(){this.showErrorView()},showErrorView:function(){this.view=new this.errorView(this.model.toJSON()),this.view.render(),this.$el.html(this.view.el)}}),h=e.CollectionView.extend({itemView:u,emptyView:c});return{FieldControls:h}}),define("cilantro/ui/field/form",["underscore","backbone","marionette","loglevel","../../core","../base","../charts","../config","./info","./stats","./controls"],function(t,e,i,n,o,r,s,a,l,c,u){var h=r.LoadView.extend({message:"Loading fields..."}),d=i.Layout.extend({className:"field-form",getTemplate:function(){return this.options.condensed?"field/form-condensed":"field/form"},options:{info:!0,chart:!1,stats:!0,controls:!0,condensed:!1},ui:{apply:"[data-action=apply]",update:"[data-action=update]",state:"[data-target=state]"},events:{"click @ui.apply":"applyFilter","click @ui.update":"applyFilter"},filterEvents:{applied:"renderFilter",unapplied:"renderFilter",change:"renderFilter"},regions:{info:".info-region",stats:".stats-region",chart:".chart-region",controls:".controls-region"},regionViews:{info:l.FieldInfo,stats:c.FieldStats,chart:s.FieldChart,controls:u.FieldControls},initialize:function(t){if(this.data={},!(this.data.concept=t.concept))throw new Error("concept required");if(!(this.data.context=t.context))throw new Error("context required");t.filter||(t.filter=this.data.context.define({concept:this.data.concept.id,field:this.model.id})),this.data.filter=t.filter},onRender:function(){this.$el.attr("id",this.data.filter.id),this.options.condensed&&this.$el.addClass("condensed"),this.options.info&&this.renderInfo(),this.options.stats&&this.model.stats&&this.renderStats(),this.options.controls&&this.renderControls(),this.options.chart&&this.model.links.distribution&&this.renderChart(),this.renderFilter(),i.bindEntityEvents(this,this.data.filter,i.getOption(this,"filterEvents"))},renderInfo:function(){var e={model:this.model};t.isObject(this.options.info)&&t.extend(e,this.options.info),this.info.show(new this.regionViews.info(e))},renderStats:function(){var e={model:this.model,collection:this.model.stats};t.isObject(this.options.stats)&&t.extend(e,this.options.stats),this.stats.show(new this.regionViews.stats(e))},renderControls:function(){var i=[];if(t.each(this.options.controls,function(e){var n={model:this.model,filter:this.data.filter};t.isObject(e)?t.extend(n,e):n.control=e,i.push(n)},this),i.length>0){var n=new this.regionViews.controls({collection:new e.Collection(i)});this.controls.show(n)}},renderChart:function(){var e;e=this.options.condensed?{chart:{height:100}}:{chart:{height:200}},e.context=this.context,e.model=this.model,t.isObject(this.options.chart)&&t.extend(e,this.options.chart),this.chart.show(new this.regionViews.chart(e))},renderFilter:function(){if(this.ui.apply.prop("disabled",!0),this.ui.update.prop("disabled",!0),this.ui.state.hide(),this.data.context.isFilterApplied(this.data.filter)){this.ui.apply.hide(),this.ui.update.show();var e=[];this.controls.currentView.children.each(function(i){i.view&&(e=e.concat(t.keys(i.view.get())))}),this.data.context.hasFilterChanged(this.data.filter,e)&&this.validateFilter({silent:!0})&&(this.ui.apply.prop("disabled",!1),this.ui.update.prop("disabled",!1))}else this.ui.apply.show(),this.ui.update.hide(),this.validateFilter({silent:!0})&&this.ui.apply.prop("disabled",!1)},validateFilter:function(e){e=t.extend({},e);var i,n=[],o=this.data.filter.toJSON();return this.controls.currentView.children.each(function(t){t.view&&(i=t.view.validate(o),i&&n.push(i))}),n.length?(this.validationErrors=n,e.silent||this.ui.state.html(n.join("<br>")).show(),!1):(this.validationErrors=null,this.ui.state.text("").hide(),!0)},applyFilter:function(t){t.preventDefault(),this.validateFilter()&&this.data.filter.apply()}}),p=r.ErrorView.extend({}),f=i.View.extend({itemView:d,emptyView:h,errorView:p,collectionEvents:{reset:"render"},initialize:function(){if(this.data={},!(this.data.concept=this.options.concept))throw new Error("concept required");if(!(this.data.context=this.options.context))throw new Error("context required")},render:function(){if(this.collection.length){var t=this;this.collection.each(function(e,i){t.renderItem(e,i)})}return this},renderItem:function(e,i){var o=t.extend({},this.options,{model:e,context:this.data.context,concept:this.data.concept,index:i});this.collection.length<2?o.info=!1:i>0&&this.options.condense&&(o.condensed=!0);var r=a.resolveFormOptions(e,"fields");if(t.extend(o,r.options),r.module){var s=this;require([r.module],function(t){s.createView(t,o)},function(t){s.showErrorView(e),n.debug(t)})}else this.createView(r.view||this.itemView,o)},createView:function(t,e){try{var i=new t(e);i.render(),o.dom.insertAt(this.$el,e.index,i.el)}catch(n){if(this.showErrorView(e.model),o.config.get("debug"))throw n}},showErrorView:function(t){var e=new this.errorView({model:t});e.render(),this.$el.html(e.el)}}),m=i.ItemView.extend({tagName:"li",template:"field/link",ui:{anchor:"a"},serializeData:function(){return{name:this.model.get("alt_name")||this.model.get("name")}}}),g=i.CompositeView.extend({template:"field/links",itemView:m,itemViewContainer:"[data-target=links]",onAfterItemAdded:function(t){var e=this.options.concept,i="c"+e.id+"f"+t.model.id;t.ui.anchor.attr("href","#"+i)}});return{FieldForm:d,FieldFormCollection:f,FieldLinkCollection:g}}),define("cilantro/ui/field",["underscore","./field/info","./field/form","./field/stats","./field/controls"],function(t){var e=[].slice.call(arguments,1);return t.extend.apply(null,[{}].concat(e))}),define("cilantro/ui/concept/form",["jquery","underscore","marionette","../../core","../field","../charts","./info"],function(t,e,i,n,o,r,s){var a=i.Layout.extend({className:"concept-form",template:"concept/form",options:{condense:!1,linksMinFields:2},events:{"click [data-target=links] a":"jumpToField"},regions:{info:".info-region",links:".links-region",fields:".fields-region"},regionViews:{info:s.ConceptInfo,links:o.FieldLinkCollection,fields:o.FieldFormCollection},constructor:function(t){if(t=t||{},!t.model)throw new Error("concept model required");i.Layout.prototype.constructor.call(this,t)},initialize:function(){if(this.data={},!(this.data.context=this.options.context))throw new Error("context required")},onRender:function(){var t=new this.regionViews.info({model:this.model}),i=new o.FieldFormCollection(e.defaults({context:this.data.context,concept:this.model,collection:this.model.fields},this.options));this.info.show(t),this.fields.show(i);var n=this.options.linksMinFields;n!==!1&&(0===this.model.fields.length?this.listenToOnce(this.model.fields,"reset",function(t){t.length>=n&&this._renderLinks()}):this.model.fields.length>this.options.linksMinFields&&this._renderLinks())},_renderLinks:function(){var t=new this.regionViews.links({concept:this.model,collection:this.model.fields});this.links.show(t)},jumpToField:function(e){e.preventDefault();var i=t(e.target.hash).offset().top-20;t("html,body").animate({scrollTop:i})}});return{ConceptForm:a}});var __hasProp={}.hasOwnProperty,__extends=function(t,e){function i(){this.constructor=t}for(var n in e)__hasProp.call(e,n)&&(t[n]=e[n]);return i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype,t};define("cilantro/ui/welcome",["underscore","marionette"],function(t,e){var i,n;return i=function(t){function e(){return n=e.__super__.constructor.apply(this,arguments)}return __extends(e,t),e.prototype.className="welcome",e.prototype.template="welcome",e}(e.ItemView),{Welcome:i}}),define("cilantro/ui/concept/workspace",["underscore","marionette","loglevel","../core","../base","../welcome","../config","./form"],function(t,e,i,n,o,r,s,a){var l=o.ErrorView.extend({template:"concept/error"}),c=e.Layout.extend({className:"concept-workspace",template:"concept/workspace",itemView:a.ConceptForm,errorView:l,regions:{main:".main-region"},regionViews:{main:r.Welcome},initialize:function(){if(this.data={},!(this.data.concepts=this.options.concepts))throw new Error("concept collection required");if(!(this.data.context=this.options.context))throw new Error("context model required");this.listenTo(n,n.CONCEPT_FOCUS,this.showItem)},_ensureModel:function(t){return t instanceof n.models.Concept||(t=this.data.concepts.get(t)),t},showItem:function(e){var o=this._ensureModel(e);if(!o)return i.debug("unknown workspace concept: "+(e.id||e)),void 0;if(n.router.navigate("query",{trigger:!0}),!this.currentView||this.currentView.model.id!==o.id){var r={model:o,context:this.data.context},a=s.resolveFormOptions(o,"concepts");if(r=t.extend(r,a.options),a.module){var l=this;require([a.module],function(t){l.createView(t,r)},function(t){l.showErrorView(o),i.debug(t)})}else this.createView(a.view||this.itemView,r)}},createView:function(t,e){try{var i=new t(e);this.setView(i)}catch(o){if(this.showErrorView(e.model),n.config.get("debug"))throw o}},showErrorView:function(t){var e=new this.errorView({model:t});this.currentView=e,this.main.show(e)},setView:function(t){this.currentView=t,this.main.show(t)},onRender:function(){var t=new this.regionViews.main;this.main.show(t)}});return{ConceptWorkspace:c}}),define("cilantro/ui/concept/columns/available",["../index"],function(t){var e=t.ConceptItem.extend({template:"concept/columns/available-item",events:{mouseover:"triggerDetails",mouseout:"triggerDetails","click [data-action=add]":"triggerAdd"},modelEvents:{"columns:add":"disable","columns:remove":"enable"},triggerAdd:function(t){t.preventDefault(),this.model.trigger("columns:add",this.model)},triggerDetails:function(t){t.preventDefault(),t.stopPropagation(),this.model.trigger("columns:detail",this.model,t)},enable:function(){this.$el.removeClass("disabled")},disable:function(){this.$el.addClass("disabled")}}),i=t.ConceptSection.extend({template:"concept/columns/available-section",itemView:e,events:{"click [data-action=add-section]":"triggerAdd"},triggerAdd:function(t){t.preventDefault(),this.model.items.each(function(t){t.trigger("columns:add",t)})}}),n=t.ConceptGroup.extend({template:"concept/columns/available-group",itemView:i,events:{"click [data-action=add-group]":"triggerAdd"},triggerAdd:function(t){t.preventDefault(),this.model.sections.each(function(t){t.items.each(function(t){t.trigger("columns:add",t)})})}}),o=t.ConceptIndex.extend({itemView:n,className:"available-columns accordion"});return{AvailableItem:e,AvailableSection:i,AvailableGroup:n,AvailableColumns:o}}),define("cilantro/ui/concept/columns/selected",["marionette","../../base"],function(t,e){var i=t.ItemView.extend({tagName:"li",template:"concept/columns/selected-item",events:{"click [data-action=remove]":"triggerRemove",sortupdate:"updateIndex"},modelEvents:{"columns:remove":"remove"},triggerRemove:function(t){t.preventDefault(),this.model.trigger("columns:remove",this.model)},updateIndex:function(t,e){t.stopPropagation(),this.collection.remove(this.model,{silent:!0}),this.collection.add(this.model,{at:e,silent:!0})}}),n=e.EmptyView.extend({message:"No columns selected."}),o=t.CollectionView.extend({tagName:"ul",className:"selected-columns",itemView:i,emptyView:n,events:{sortupdate:"triggerItemSort"},itemViewOptions:function(t,e){return{model:t,index:e,collection:this.collection}},onRender:function(){this.$el.sortable({cursor:"move",forcePlaceholderSize:!0,placeholder:"placeholder"})},triggerItemSort:function(t,e){e.item.trigger(t,[e.item.index()])}});return{SelectedItem:i,SelectedColumns:o}}),define("cilantro/ui/concept/columns/layout",["jquery","underscore","backbone","marionette","../search","./available","./selected"],function(t,e,i,n,o,r,s){var a=n.ItemView.extend({className:"popover right",template:"concept/popover",initialize:function(){this.$el.css({position:"fixed",zIndex:1200,minWidth:300,minHeight:100}).hide()},serializeData:function(){var t=this.model.toJSON(),e=this.model.fields;return 0===e.length?t.description||(t.description='<i class="icon-spinner icon-spin"></i>'):1===e.length?t.description||(t.description=e.models[0].get("description")):t.fields=e.map(function(t){return t.get("name")}).join(", "),t.description||t.fields||(t.description="<em>No description is available</em>"),t},onRender:function(){0===this.model.fields.length&&(this.listenTo(this.model.fields,"reset",this.show),this.model.fields.fetch({reset:!0}))},update:function(t){this.stopListening(),this.options=t,this.model=t.model,this.show()},show:function(){this.render(),this.shown()?this.$el.stop().animate({left:this.options.left,top:this.options.top-this.$el.outerHeight()/2},200):this.$el.show().css({left:this.options.left,top:this.options.top-this.$el.outerHeight()/2}).fadeIn(200)},shown:function(){return this.$el.is(":visible")},hide:function(){this.$el.fadeOut(200)}}),l=n.Layout.extend({className:"concept-columns",template:"concept/columns/layout",events:{click:"hideDetailsPopover","click [data-action=clear]":"triggerRemoveAll"},regions:{search:".search-region",available:".available-region",selected:".selected-region"},regionViews:{search:o.ConceptSearch,available:r.AvailableColumns,selected:s.SelectedColumns},initialize:function(){if(this.data={},!(this.data.view=this.options.view))throw new Error("view required");if(!(this.data.concepts=this.options.concepts))throw new Error("concepts collection required");this.listenTo(this.data.concepts,"columns:detail",this.handleDetailsPopover),this.data.selected=new i.Collection,this.data.selected.listenTo(this.data.concepts,"columns:add",function(t){this.add(t)}),this.data.selected.on("columns:remove",function(t){this.remove(t)})},handleDetailsPopover:function(i,n){var o=this,r=t(n.currentTarget);if(clearTimeout(this._detailsDelay),"mouseover"===n.type){var s=this.popover.shown()?100:500;this._detailsDelay=e.delay(function(){o.showDetailsPopover(i,r)},s)}else"mouseout"===n.type&&(this._detailsDelay=e.delay(function(){o.hideDetailsPopover(i,r)},200))},showDetailsPopover:function(e,i){i=t(i);var n=i.offset();this.popover.update({model:e,top:n.top+i.outerHeight()/2,left:n.left+i.outerWidth()})},hideDetailsPopover:function(){this.popover&&this.popover.hide()},resetSelected:function(){this.data.selected.reset();var t=this.data.concepts;this.data.view.facets.each(function(e){var i=t.get(e.get("concept"));i&&i.trigger("columns:add",i)})},selectedToFacets:function(){var t=this;return this.data.selected.map(function(e){var i=t.data.view.facets.get(e.id);return i?i.toJSON():{concept:e.id}})},onRender:function(){this.$el.modal({show:!1});var t=new this.regionViews.search({placeholder:"Search available columns by name, description, or data value...",collection:this.data.concepts,handler:function(t,i){e.filter(t,i)}}),e=new this.regionViews.available({collapsable:!1,collection:this.data.concepts}),i=new this.regionViews.selected({collection:this.data.selected});this.search.show(t),this.available.show(e),this.selected.show(i),this.popover=new a,this.$el.append(this.popover.el),this.data.view.facets.length>0&&this.data.concepts.length?this.resetSelected():(this.listenToOnce(this.data.view.facets,"reset",this.resetSelected),this.listenToOnce(this.data.concepts,"reset",this.resetSelected))},triggerRemoveAll:function(){var t=this.data.selected.slice(0);e.each(t,function(t){t.trigger("columns:remove",t)})}});return{ConceptColumnsLayout:l}}),define("cilantro/ui/concept/columns/dialog",["underscore","marionette","./layout"],function(t,e,i){var n=e.Layout.extend({className:"columns-modal modal hide full",template:"concept/columns/dialog",events:{"click [data-save]":"save","click [data-dismiss]":"cancel"},ui:{error:"[data-target=error]"},regions:{body:".concept-columns-region"},regionViews:{body:i.ConceptColumnsLayout},initialize:function(){if(this.data={},!(this.data.view=this.options.view))throw new Error("view required");if(!(this.data.concepts=this.options.concepts))throw new Error("concepts collection required")},onRender:function(){this.$el.modal({show:!1,keyboard:!1,backdrop:"static"}),this.columns=new this.regionViews.body({view:this.data.view,concepts:this.data.concepts}),this.body.show(this.columns)},cancel:function(){var e=this;t.delay(function(){e.columns.resetSelected()},25)},save:function(){this.ui.error.hide();var t=this.columns.selectedToFacets();return 0===t.length?(this.ui.error.html("<p>You must select one or more columns.</p>").show(),void 0):(this.data.view.facets.reset(t),this.data.view.save(),this.close(),void 0)},open:function(){this.ui.error.hide(),this.$el.modal("show")},close:function(){this.$el.modal("hide")}});return{ConceptColumnsDialog:n}}),define("cilantro/ui/concept/columns",["underscore","./columns/dialog"],function(t){var e=[].slice.call(arguments,1);return t.extend.apply(t,[{}].concat(e))}),define("cilantro/ui/concept",["underscore","./concept/info","./concept/search","./concept/index","./concept/panel","./concept/form","./concept/workspace","./concept/columns"],function(t){var e=[].slice.call(arguments,1);return t.extend.apply(t,[{}].concat(e))}),define("cilantro/ui/context/filters",["underscore","marionette","../base","../core"],function(t,e,i,n){var o=function(e,i,n,r){return e?(i||(i=[]),r!==!1&&(r=!0),r&&i.push("<ul>"),e.language?i.push("<li>"+e.language+"</li>"):e.type&&e.children.length&&(n&&i.push("<li><small>"+e.type.toUpperCase()+"</small><ul>"),t.each(e.children,function(t){o(t,i,n,!1)}),n&&i.push("</ul></li>")),r&&i.push("</ul>"),i.join("")):""},r=e.ItemView.extend({className:"context-filter",template:"context/filter",ui:{actions:"[data-target=actions]",loader:"[data-target=loader]",remove:"[data-action=remove]",enable:"[data-action=enable]",description:"[data-target=description]",required:"[data-target=required]"},events:{click:"clickShow","click @ui.remove":"clickRemove","click @ui.enable":"toggleEnabled"},modelEvents:{request:"showLoadView",sync:"hideLoadView",error:"hideLoadView",change:"render"},clickShow:function(){n.trigger(n.CONCEPT_FOCUS,this.model.get("concept"))},clickRemove:function(t){t.stopPropagation(),this.model.unapply()},toggleEnabled:function(t){t.stopPropagation(),this.model.toggleEnabled()},renderEnabled:function(){this.$el.removeClass("disabled"),this.ui.enable.attr("title","Disable"),this.ui.enable.prop("checked",!0)},renderDisabled:function(){this.$el.addClass("disabled"),this.ui.enable.attr("title","Enable"),this.ui.enable.prop("checked",!1)},renderState:function(){this.model.get("enabled")!==!1?this.renderEnabled():this.renderDisabled()},renderDescription:function(){var t=o(this.model.attributes);this.ui.description.html(t)},showLoadView:function(){this.ui.loader.show(),this.ui.description.hide()},hideLoadView:function(){this.ui.loader.hide(),this.ui.description.show()},onRender:function(){this.ui.actions.toggle(!this.model.get("required")),this.ui.enable.toggle(!this.model.get("required")),this.ui.required.toggle(this.model.get("required")===!0),this.ui.required.tooltip({container:"body",placement:"left",delay:500}),this.renderDescription(),this.renderState()}}),s=i.EmptyView.extend({template:"context/empty",ui:{noFiltersResultsMessage:".no-filters-results-workspace",noFiltersQueryMessage:".no-filters-query-workspace"},onRender:function(){this.listenTo(n.router,"route",this.toggleMessage),this.toggleMessage()},onClose:function(){this.stopListening(n.router)},toggleMessage:function(){n.router.isCurrent("results")?(this.ui.noFiltersQueryMessage.hide(),this.ui.noFiltersResultsMessage.show()):n.router.isCurrent("query")&&(this.ui.noFiltersQueryMessage.show(),this.ui.noFiltersResultsMessage.hide())}}),a=e.CollectionView.extend({itemView:r,emptyView:s});return{ContextFilter:r,ContextFilters:a,ContextNoFilters:s,flattenLanguage:o}}),define("cilantro/ui/context/info",["underscore","marionette","../core"],function(t,e,i){var n=e.ItemView.extend({template:"context/info",ui:{query:"[data-route=query]",results:"[data-route=results]"},initialize:function(){t.bindAll(this,"toggleButton"),i.router.on("route",this.toggleButton)},toggleButton:function(){this.ui.query.toggle(i.router.isCurrent("results")),this.ui.results.toggle(i.router.isCurrent("query"))},onRender:function(){this.toggleButton()}});return{ContextInfo:n}}),define("cilantro/ui/context/actions",["underscore","marionette","../core"],function(t,e,i){var n=e.ItemView.extend({template:"context/actions",ui:{removeAll:"[data-action=remove]"},events:{"click @ui.removeAll":"clickRemoveAll"},modelEvents:{"change:count":"render"},collectionEvents:{"add remove reset change":"renderRemoveAll"},serializeData:function(){var e=t.clone(this.model.attributes);return e.prettyCount=i.utils.prettyNumber(e.count,i.config.get("threshold")),e
  },clickRemoveAll:function(){this.collection.unapply()},onRender:function(){this.renderRemoveAll()},renderRemoveAll:function(){var t=this.collection.reject(function(t){return t.get("required")===!0});this.ui.removeAll.prop("disabled",!t.length)}});return{ContextActions:n}}),define("cilantro/ui/context/panel",["underscore","marionette","../base","../core","./filters","./info","./actions"],function(t,e,i,n,o,r,s){var a=e.Layout.extend({id:"context-panel",className:"panel panel-right closed",template:"context/panel",errorView:i.ErrorOverlayView,modelEvents:{sync:"hideLoadView",error:"showErrorView",request:"showLoadView"},regions:{info:".info-region",filters:".filters-region",actions:".actions-region"},regionViews:{info:r.ContextInfo,filters:o.ContextFilters,actions:s.ContextActions},showLoadView:function(){this._errorView&&(this._errorView.remove(),delete this._errorView),this.$el.addClass("loading")},hideLoadView:function(){this.$el.removeClass("loading")},showErrorView:function(){this._errorView||(this._errorView=new this.errorView({target:this.$el}),this._errorView.render())},onRender:function(){this.$el.panel();var t=new this.regionViews.info({model:this.model}),e=new this.regionViews.actions({model:this.model,collection:this.model.filters}),i=new this.regionViews.filters({model:this.model,collection:this.model.filters});this.info.show(t),this.actions.show(e),this.filters.show(i)},openPanel:function(t){this.$el.panel("open",t)},closePanel:function(t){this.$el.panel("close",t)},isPanelOpen:function(t){return this.$el.data("panel").isOpen(t)},isPanelClosed:function(t){return this.$el.data("panel").isClosed(t)}});return{ContextPanel:a}}),define("cilantro/ui/context",["underscore","./context/panel"],function(t){var e=[].slice.call(arguments,1);return t.extend.apply(t,[{}].concat(e))}),define("cilantro/ui/exporter",["jquery","underscore","backbone","marionette","./base","./core"],function(t,e,i,n,o,r){var s=n.ItemView.extend({tagName:"label",className:"checkbox",template:"export/option"}),a=o.EmptyView.extend({message:"No exporters available."}),l=n.CollectionView.extend({itemView:s,emptyView:a}),c=n.ItemView.extend({template:"export/progress",ui:{status:"[data-target=status]",cancel:"[data-target=cancel]"},events:{"click @ui.cancel":"cancel"},modelEvents:{"change:status":"renderStatus"},getCookieName:function(){return"export-type-"+this.model.get("type")},getExportUrl:function(){var t=this.model.get("href");return"/"!==t.charAt(t.length-1)&&(t+="/"),t+(this.model.get("pages")||"")},initialize:function(){var e=this.getCookieName(),i=this.getExportUrl();this.iframe=t("<iframe />").attr("src",i).css("display","none"),this.model.set({url:i,cookie:e,status:"pending",time:0})},start:function(t){if("canceled"!==this.model.get("status")){r.utils.setCookie(this.model.get("cookie"),null),this.$el.append(this.iframe);var e=this,i=setInterval(function(){e.check()},t.monitorDelay);this.model.set({interval:i,status:"loading"})}},cancel:function(){var t=this.model.get("cookie"),e=this.model.get("interval");clearInterval(e),r.utils.setCookie(t,null),this.iframe.remove(),this.model.set("status","canceled")},check:function(){var t=this.model.get("cookie"),e=this.model.get("time"),i=this.model.get("interval");e+=this.monitorDelay,"complete"===r.utils.getCookie(t)?(clearInterval(i),r.utils.setCookie(t,null),this.model.set("status","complete")):e>=this.options.monitorTimeout?(clearInterval(i),this.model.set("status","timeout")):this.checkError()&&(clearInterval(i),this.model.set("status","error"))},checkError:function(){return this.iframe[0].document?0!==this.iframe.contents()[0].body.children.length:!1},renderStatus:function(t,e){var i,n=!0;switch(e){case"error":i='<span class="label label-important">Error</span>';break;case"timeout":i='<span class="label label-warning">Request Timed Out</span>';break;case"complete":i='<span class="label label-success">Complete</span>';break;case"loading":i='<div class="label label-info"><i class="icon-spinner icon-spin"></i> Downloading...</span>',n=!1;break;case"canceled":i='<span class="label label-warning">Canceled</span>'}this.ui.cancel.hide(),this.ui.status.html(i),this.model.set("done",n)}}),u=n.CompositeView.extend({className:"export-batch",template:"export/batch",itemView:c,start:function(){var t=this.options;this.children.each(function(i,n){e.delay(function(){i.start(t)},n*t.requestDelay)})},finish:function(){var t=this;this.$el.html('<h3><i class="icon-ok-sign text-success" /> Export Done</h3>').css("text-align","center"),e.delay(function(){t.$el.slideUp({duration:300,easing:"easeInOutQuad",complete:function(){t.close()}})},2e3)}}),h=/^[0-9]+(\.\.\.[0-9]+)?$/,d=n.Layout.extend({template:"export/dialog",id:"exporter-dialog",className:"modal hide",options:{requestDelay:500,monitorDelay:200,monitorTimeout:6e5},ui:{pageOption:"[name=pages]",pageRange:"[name=page-range]",error:"[data-target=error]",save:"[data-toggle=save]"},events:{"click @ui.save":"exportData","click @ui.pageOption":"togglePageOption","click [data-action=change-columns]":"changeColumnsClicked"},regions:{types:"[data-target=types]",progress:"[data-target=progress]"},initialize:function(){if(this.data={},!(this.data.exporters=this.options.exporters))throw new Error("exporters collection required")},open:function(){this.$el.modal("show")},hide:function(){this.$el.modal("hide")},onRender:function(){this.$el.modal({show:!1});var t=new l({collection:this.data.exporters});this.types.show(t)},togglePageOption:function(){this.ui.pageRange.prop("disabled",!this.pageRangeSelected())},getSelectedOptions:function(){return this.types.currentView.$(":checked").map(function(){return this.value})},getPageRange:function(){return this.pageRangeSelected()?this.ui.pageRange.val():void 0},pageRangeSelected:function(){return"range"===this.ui.pageOption.filter(":checked").val()},isPageRangeValid:function(){return h.test(this.getPageRange())},changeColumnsClicked:function(){r.dialogs.columns.open()},validate:function(){var t=[],e=this.getSelectedOptions();return this.pageRangeSelected()&&!this.isPageRangeValid()&&t.push("<p>The page range entered is invalid. It must be a single page, e.g. 1, or a range of pages, e.g. 2...5.</p>"),0===e.length&&t.push("<p>An export type must be selected.</p>"),0===r.data.views.session.facets.length&&t.push("<p>One or more columns must be selected. Click <a data-action=change-columns>here</a> to select columns.</p>"),t},exportData:function(){this.ui.error.hide();var t=this.getSelectedOptions(),n=this.validate();if(n.length)return this.ui.error.html(n).show(),void 0;this.ui.save.prop("disabled",!0);var o,r=this,s=e.map(t,function(t){return o=r.data.exporters.get(t).toJSON(),o.pages=r.getPageRange(),o}),a=new i.Collection(s);this.listenTo(a,"change:status",function(){a.where({done:!0}).length===a.length&&(this.stopListening(a),this.ui.save.prop("disabled",!1),e.delay(function(){l.finish()},1e3))});var l=new u(e.extend({collection:a},this.options));this.progress.show(l),l.start()}});return{ExporterDialog:d}}),define("cilantro/ui/notify",["underscore","backbone","marionette"],function(t,e,i){var n=e.Model.extend({defaults:{level:"info",timeout:4e3,dismissable:!0,header:null,message:""}}),o=i.ItemView.extend({className:"alert",template:"notification",ui:{dismiss:"[data-dismiss]",header:"h4",message:"div"},events:{"click [data-dismiss]":"dismiss",mouseover:"hold",mouseout:"release"},dismiss:function(){clearTimeout(this._dismissTimer)},hold:function(){this._startTime&&(clearTimeout(this._dismissTimer),this.$el.stop().show())},release:function(){if(this._startTime){var t=this._startTime+this.model.get("timeout"),e=Math.max(t-(new Date).getTime(),1e3),i=this;this._dismissTimer=setTimeout(function(){i.$el.fadeOut()},e)}},onRender:function(){this.$el.addClass("alert-"+this.model.get("level")),this.ui.header.toggle(!!this.model.get("header")),this.ui.dismiss.toggle(this.model.get("dismissable"));var t=this.model.get("timeout");t&&(this._startTime=(new Date).getTime(),this.release())}}),r=i.CollectionView.extend({className:"notifications",itemView:o,constructor:function(n){n=n||{},n.collection||(n.collection=new e.Collection),i.CollectionView.prototype.constructor.call(this,n),t.bindAll(this,"notify")},notify:function(t){"string"==typeof t&&(t={message:t});var e=new n(t);return this.collection.add(e),this.children.findByModel(e)}});return{Notifications:r,Notification:o}}),define("cilantro/ui/query/dialog",["underscore","marionette","../core"],function(t,e,i){var n=e.ItemView.extend({className:"modal hide",template:"query/delete-dialog",options:{header:"Delete Query"},events:{"click .delete-query-button":"deleteQuery"},ui:{header:".modal-header h4",alert:".alert"},showError:function(t){this.ui.alert.html(t).show()},hideError:function(){this.ui.alert.hide()},deleteQuery:function(){this.hideError();var t=this.model,e=this;this.model.destroy().fail(function(){e.open(t),e.showError("Sorry, there was a problem deleting your query. Please try again.")}),this.close()},onRender:function(){this.ui.header.text(this.options.header),this.$el.modal({show:!1,keyboard:!1,backdrop:"static"})},open:function(t){this.hideError(),this.model=t,this.$el.modal("show")},close:function(){delete this.model,this.$el.modal("hide")}}),o=e.ItemView.extend({className:"modal hide",template:"query/edit-dialog",options:{header:"Query Properties"},events:{"click [data-save]":"saveQuery"},ui:{header:".modal-header h4",alert:".alert",name:".query-name",description:".query-description",email:".query-emails",publicity:".query-publicity"},initialize:function(){if(this.data={},!(this.data.context=this.options.context))throw new Error("context model required");if(!(this.data.view=this.options.view))throw new Error("view model required")},showError:function(t){this.ui.alert.html(t).show()},hideError:function(){this.ui.alert.hide()},saveQuery:function(){if(this.hideError(),!this.ui.name.val())return this.showError("Please supply a name for the query"),void 0;var t={name:this.ui.name.val(),description:this.ui.description.val(),usernames_or_emails:this.ui.email.val(),"public":this.ui.publicity.prop("checked")};this.model||(this.model=new this.collection.model,t.context_json=this.data.context.toJSON().json,t.view_json=this.data.view.toJSON().json),this.model.collection||this.collection.add(this.model);var e=this.model,n=this;this.model.save(t).done(function(){i.notify({header:"Saved",level:"info",timeout:5e3,message:"Successfully saved your query"})}).fail(function(){n.open(e),n.showError("Sorry, there was a problem saving your query. Please try again.")}),this.close()},onRender:function(){this.ui.header.text(this.options.header),this.$el.modal({show:!1,keyboard:!1,backdrop:"static"})},open:function(e){this.hideError(),this.model=e;var i,n,o,r;if(e)i=this.model.get("name"),n=this.model.get("description"),o=t.pluck(this.model.get("shared_users"),"email").join(", "),r=this.model.get("public");else{var s=Date().toString().split(" ");i="Query on "+s.slice(0,5).join(" "),n="",o="",r=!1}this.ui.name.val(i),this.ui.description.val(n),this.ui.email.val(o),this.ui.publicity.prop("checked",r),this.$el.modal("show")},close:function(){delete this.model,this.$el.modal("hide")}});return{DeleteQueryDialog:n,EditQueryDialog:o}}),define("cilantro/ui/query/item",["underscore","marionette","../base","../core","../context/filters"],function(t,e,i,n,o){var r=i.LoadView.extend({align:"left"}),s=e.ItemView.extend({className:"query-item",template:"query/item",options:{editable:!1},ui:{owner:".owner",nonOwner:".non-owner",shareCount:".share-count",publicIcon:".public-icon",details:"[data-target=details]",toggleDetails:"[data-target=toggle-details]",actions:".owner button"},events:{"click [data-toggle=delete-query-modal]":"showDeleteQueryModal","click [data-toggle=edit-query-modal]":"showEditQueryModal","click [data-target=query]":"loadQuery","click @ui.toggleDetails":"toggleDetails",mouseover:"showActions",mouseout:"hideActions"},modelEvents:{sync:"render"},initialize:function(){if(this.data={},!(this.data.context=this.options.context))throw new Error("context model required");if(!(this.data.view=this.options.view))throw new Error("view model required")},serializeData:function(){var t=this.model.toJSON();return t.shared_users||(t.shared_users=[]),t.user||(t.user={}),t},showActions:function(){this.ui.actions.show()},hideActions:function(){this.ui.actions.hide()},loadQuery:function(t){t.preventDefault(),t.stopPropagation(),this.data.view.save("json",this.model.get("view_json")),this.data.context.save("json",this.model.get("context_json"),{reset:!0}),n.router.navigate("results",{trigger:!0})},showEditQueryModal:function(){this.trigger("showEditQueryModal",this.model)},showDeleteQueryModal:function(){this.trigger("showDeleteQueryModal",this.model)},toggleDetails:function(t){t.preventDefault(),this.ui.details.is(":visible")?(this.ui.toggleDetails.text("Show details"),this.ui.details.hide()):(this.ui.toggleDetails.text("Hide details"),this.ui.details.show())},renderDetails:function(){var e=["<div class=row-fluid><div class=span6>"];e.push("<h6>Filters</h6>");var i=this.model.context.get("json");!i||t.isEmpty(i)?e.push("<p class=muted>No filters were specified for this query.</p>"):o.flattenLanguage(i,e),e.push("</div><div class=span6>"),n.config.get("session.defaults.data.preview")||(e.push("<h6>Columns</h6>"),this.model.view.facets.length?(e.push("<ul>"),this.model.view.facets.each(function(t){var i=n.data.concepts.get(t.get("concept")).get("name"),o=t.get("sort");e.push("<li>"+i),"asc"===o?e.push(' <i class=icon-caret-up title="Ascending Order"></i>'):"desc"===o&&e.push(' <i class=icon-caret-down title="Descending Order"></i>'),e.push("</li>")}),e.push("</ul>")):e.push("<p class=muted>No columns were selected this query.</p>")),e.push("</div></div>"),this.ui.details.html(e.join(""))},onRender:function(){if(this.renderDetails(),!this.options.editable)return this.ui.publicIcon.hide(),this.ui.nonOwner.hide(),this.ui.owner.hide(),void 0;if(this.model.get("public")&&this.ui.publicIcon.removeClass("muted").attr("title","Public query"),this.ui.publicIcon.tooltip({html:!0,animation:!1,placement:"right",container:"body"}),this.model.get("is_owner")){this.ui.nonOwner.hide();var e=t.pluck(this.model.get("shared_users"),"email");e.length&&this.ui.shareCount.removeClass("muted").attr("title",e.join(", ")),this.ui.shareCount.tooltip({html:!0,animation:!1,placement:"right",container:"body"})}else this.ui.owner.hide()}});return{LoadingQueryItem:r,QueryItem:s}}),define("cilantro/ui/query/list",["underscore","marionette","../core","./item"],function(t,e,i,n){var o=e.CompositeView.extend({itemView:n.QueryItem,itemViewContainer:".items",template:"query/list",options:{title:"Queries",editable:!1,emptyMessage:'You have not yet created any queries nor have had any shared with you. You can create a new query by navigating to the "Results" page and clicking on the "Save Query..." button. This will save a query with the current filters and column view.'},ui:{title:".title",publicIndicator:".header > div"},collectionEvents:{sync:"onCollectionSync",error:"onCollectionError",request:"onCollectionRequest",destroy:"onCollectionDestroy"},itemViewOptions:function(t,e){return{model:t,view:this.data.view,context:this.data.context,editable:this.options.editable,index:e}},initialize:function(){if(this.data={},!(this.data.context=this.options.context))throw new Error("context model required");if(!(this.data.view=this.options.view))throw new Error("view model required");this.options.editable&&(this.on("itemview:showEditQueryModal",function(t){i.dialogs.query.open(t.model)}),this.on("itemview:showDeleteQueryModal",function(t){i.dialogs.deleteQuery.open(t.model)}))},_refreshList:function(){this.$(".error-message").hide(),this.$(".loading-indicator").hide(),this.checkForEmptyCollection()},onCollectionDestroy:function(){this._refreshList()},onCollectionError:function(){this.$(".empty-message").hide(),this.$(".error-message").show(),this.$(".loading-indicator").hide()},onCollectionRequest:function(){this.$(".empty-message").hide(),this.$(".error-message").hide(),this.$(".loading-indicator").show()},onCollectionSync:function(){this._refreshList()},checkForEmptyCollection:function(){0===this.collection.length?this.$(".empty-message").show():this.$(".empty-message").hide()},onRender:function(){this.ui.title.html(this.options.title),this.options.editable||this.ui.publicIndicator.hide(),this.$(".empty-message").html(this.options.emptyMessage),this.checkForEmptyCollection()}});return{QueryList:o}}),define("cilantro/ui/query/loader",["underscore","marionette","../core"],function(t,e,i){var n=e.ItemView.extend({className:"query-loader",template:"query/loader",ui:{loadingMessage:".loading-message",errorMessage:".error-message"},initialize:function(){if(this.data={},!(this.data.context=this.options.context))throw new Error("context model required");if(!(this.data.view=this.options.view))throw new Error("view model required");if(!(this.data.queries=this.options.queries))throw new Error("queries collection required");this.on("router:load",this.onRouterLoad),this.listenTo(this.data.queries,"sync",this.loadRequestedQuery)},onRouterLoad:function(t,e,i){this.requestedQueryId=parseInt(i)||null},loadRequestedQuery:function(){if(this.requestedQueryId){var t=this.data.queries.get(this.requestedQueryId);delete this.requestedQueryId,t?(this.data.view.save("json",t.get("view_json")),this.data.context.save("json",t.get("context_json"),{reset:!0}),i.router.navigate("results",{trigger:!0})):(this.ui.loadingMessage.hide(),this.ui.errorMessage.show())}}});return{QueryLoader:n}}),define("cilantro/ui/query",["underscore","./query/dialog","./query/item","./query/list","./query/loader"],function(t){var e=[].slice.call(arguments,1);return t.extend.apply(null,[{}].concat(e))});var __hasProp={}.hasOwnProperty,__extends=function(t,e){function i(){this.constructor=t}for(var n in e)__hasProp.call(e,n)&&(t[n]=e[n]);return i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype,t};define("cilantro/ui/tables/cell",["marionette"],function(t){var e,i;return e=function(t){function e(){return i=e.__super__.constructor.apply(this,arguments)}return __extends(e,t),e.prototype.tagName="td",e.prototype.initialize=function(){return this.listenTo(this.model.index,"change:visible",this.toggleVisible,this)},e.prototype.render=function(){return this.toggleVisible(),this.$el.html(this.model.get("value")),this},e.prototype.toggleVisible=function(){return this.$el.toggle(this.model.index.get("visible"))},e}(t.View),{Cell:e}});var __bind=function(t,e){return function(){return t.apply(e,arguments)}},__hasProp={}.hasOwnProperty,__extends=function(t,e){function i(){this.constructor=t}for(var n in e)__hasProp.call(e,n)&&(t[n]=e[n]);return i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype,t};define("cilantro/ui/tables/row",["underscore","marionette","../base","./cell"],function(t,e,i,n){var o,r,s,a;return r=function(e){function i(){return this.itemViewOptions=__bind(this.itemViewOptions,this),s=i.__super__.constructor.apply(this,arguments)}return __extends(i,e),i.prototype.tagName="tr",i.prototype.template=function(){},i.prototype.itemView=n.Cell,i.prototype.itemViewOptions=function(e){return t.extend({},this.options,{model:e})},i}(e.CollectionView),o=function(t){function e(){return a=e.__super__.constructor.apply(this,arguments)}return __extends(e,t),e.prototype.align="left",e.prototype.tagName="tr",e}(i.LoadView),{Row:r,EmptyRow:o}});var __hasProp={}.hasOwnProperty,__extends=function(t,e){function i(){this.constructor=t}for(var n in e)__hasProp.call(e,n)&&(t[n]=e[n]);return i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype,t};define("cilantro/ui/tables/header",["underscore","marionette","./row"],function(t,e,i){var n,o,r,s,a;return o=function(e){function i(t){if(null==t.view)throw new Error("ViewModel instance required");this.view=t.view,delete t.view,i.__super__.constructor.call(this,t)}return __extends(i,e),i.prototype.tagName="th",i.prototype.onClick=function(){return t.each(this.view.facets.models,function(t){var e;return t.get("concept")===this.model.id?(e=t.get("sort"),null!=e?"asc"===e.toLowerCase()?(t.set("sort","desc"),t.set("sort_index",0)):(t.unset("sort"),t.unset("sort_index")):(t.set("sort","asc"),t.set("sort_index",0))):(t.unset("sort"),t.unset("sort_index"))},this),this.view.save()},i.prototype.initialize=function(){return this.listenTo(this.model,"change:visible",this.toggleVisible)},i.prototype.events={click:"onClick"},i.prototype.getSortIconClass=function(){var e,i,n=this;if(i=t.find(this.view.facets.models,function(t){return n.model.id===t.get("concept")}),null!=i)switch(e=(i.get("sort")||"").toLowerCase()){case"asc":return"icon-sort-up";case"desc":return"icon-sort-down";default:return"icon-sort"}},i.prototype.render=function(){var t;return this.toggleVisible(),t=this.getSortIconClass(),this.$el.html("<span>"+this.model.get("name")+" <i class="+t+"></i></span>"),this.$el.attr("title",this.model.get("name")),this},i.prototype.toggleVisible=function(){return this.$el.toggle(this.model.get("visible"))},i}(e.ItemView),r=function(t){function e(){return s=e.__super__.constructor.apply(this,arguments)}return __extends(e,t),e.prototype.itemView=o,e}(i.Row),n=function(e){function n(){return a=n.__super__.constructor.apply(this,arguments)}return __extends(n,e),n.prototype.tagName="thead",n.prototype.render=function(){return i=new r(t.extend({},this.options,{collection:this.collection})),this.$el.html(i.el),i.render(),this},n}(e.ItemView),{Header:n}});var __hasProp={}.hasOwnProperty,__extends=function(t,e){function i(){this.constructor=t}for(var n in e)__hasProp.call(e,n)&&(t[n]=e[n]);return i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype,t};define("cilantro/ui/tables/footer",["marionette","./row"],function(t){var e,i;return e=function(t){function e(){return i=e.__super__.constructor.apply(this,arguments)}return __extends(e,t),e.prototype.tagName="tfoot",e.prototype.template=function(){},e}(t.ItemView),{Footer:e}});var __bind=function(t,e){return function(){return t.apply(e,arguments)}},__hasProp={}.hasOwnProperty,__extends=function(t,e){function i(){this.constructor=t}for(var n in e)__hasProp.call(e,n)&&(t[n]=e[n]);return i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype,t};define("cilantro/ui/tables/body",["underscore","marionette","./row"],function(t,e,i){var n,o;return n=function(e){function n(){return this.itemViewOptions=__bind(this.itemViewOptions,this),o=n.__super__.constructor.apply(this,arguments)}return __extends(n,e),n.prototype.tagName="tbody",n.prototype.template=function(){},n.prototype.itemView=i.Row,n.prototype.itemViewOptions=function(e){return t.defaults({collection:e.data},this.options)},n}(e.CollectionView),{Body:n}});var __hasProp={}.hasOwnProperty,__extends=function(t,e){function i(){this.constructor=t}for(var n in e)__hasProp.call(e,n)&&(t[n]=e[n]);return i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype,t};define("cilantro/ui/tables/table",["underscore","marionette","./body","./header","./footer"],function(t,e,i,n,o){var r,s;return r=function(e){function r(){return s=r.__super__.constructor.apply(this,arguments)}return __extends(r,e),r.prototype.tagName="table",r.prototype.className="table table-striped",r.prototype.itemView=i.Body,r.prototype.itemViewOptions=function(e){return t.defaults({collection:e.series},this.options)},r.prototype.collectionEvents={"change:currentpage":"showCurrentPage"},r.prototype.initialize=function(){var e=this;return this.header=new n.Header(t.defaults({collection:this.collection.indexes},this.options)),this.footer=new o.Footer(t.defaults({collection:this.collection.indexes},this.options)),this.header.render(),this.footer.render(),this.$el.append(this.header.el,this.footer.el),this.collection.on("reset",function(){return 0===e.collection.objectCount?e.$el.hide():e.$el.show()})},r.prototype.showCurrentPage=function(t,e){return this.children.each(function(t){return t.$el.toggle(t.model.id===e)})},r}(e.CollectionView),{Table:r}});var __slice=[].slice;define("cilantro/ui/tables",["underscore","./tables/cell","./tables/row","./tables/header","./tables/footer","./tables/body","./tables/table"],function(){var t,e;return e=arguments[0],t=2<=arguments.length?__slice.call(arguments,1):[],e.extend.apply(e,[{}].concat(__slice.call(t)))}),define("cilantro/ui/workflows/query",["marionette","../core","../concept"],function(t,e,i){var n=t.Layout.extend({className:"query-workflow",template:"workflows/query",regions:{workspace:".concept-workspace-region"},regionViews:{workspace:i.ConceptWorkspace},initialize:function(){if(this.data={},!(this.data.context=this.options.context))throw new Error("context model required");if(!(this.data.concepts=this.options.concepts))throw new Error("concept collection required");this.on("router:load",function(){e.panels.concept.openPanel(),e.panels.context.openPanel()}),this.on("router:unload",function(){e.panels.concept.closePanel()})},onRender:function(){var t=new this.regionViews.workspace({context:this.data.context,concepts:this.data.concepts});this.workspace.show(t)}});return{QueryWorkflow:n}}),define("cilantro/ui/numbers",["./core"],function(t){return{renderCount:function(e,i,n){return null==n&&(n="<em>n/a</em>"),null==i?e.html(n):e.html(t.utils.prettyNumber(i,t.config.get("threshold"))).attr("title",t.utils.toDelimitedNumber(i))}}}),define("cilantro/ui/workflows/results",["jquery","underscore","marionette","../core","../paginator","../numbers","../tables"],function(t,e,i,n,o,r,s){var a=i.ItemView.extend({tagName:"span",className:"result-count",template:"count",ui:{count:".count",label:".count-label"},modelEvents:{"change:objectcount":"renderCount"},onRender:function(){void 0!==this.model.objectCount?this.renderCount(this.model,this.model.objectCount):this.renderCount(this.model,"")},renderCount:function(t,e){r.renderCount(this.ui.count,e),this.ui.label.text("records")}}),l=i.Layout.extend({className:"results-workflow",template:"workflows/results",ui:{toggleFiltersButton:"[data-toggle=context-panel]",toggleFiltersIcon:"[data-toggle=context-panel] i",toggleFiltersText:"[data-toggle=context-panel] span",navbar:".results-workflow-navbar",resultsContainer:".results-container",navbarButtons:".results-workflow-navbar button",loadingOverlay:".loading-overlay"},events:{"click [data-toggle=columns-dialog]":"showColumnsDialog","click [data-toggle=exporter-dialog]":"showExporterDialog","click [data-toggle=query-dialog]":"showQueryDialog","click [data-toggle=context-panel]":"toggleContextPanel"},regions:{count:".count-region",table:".table-region",paginator:".paginator-region"},initialize:function(){if(e.bindAll(this,"onPageScroll"),this.data={},!(this.data.view=this.options.view))throw new Error("view model required");if(!(this.data.results=this.options.results))throw new Error("results collection required");this.listenTo(this.data.results,"request",this.showLoadingOverlay),this.listenTo(this.data.results,"sync",this.hideLoadingOverlay),this.on("router:load",this.onRouterLoad),this.on("router:unload",this.onRouterUnload)},onRouterLoad:function(){this.data.results.trigger("workspace:load"),this.hideContextPanel()},onRouterUnload:function(){this.data.results.trigger("workspace:unload")},showLoadingOverlay:function(){this.isClosed!==!0&&this.ui.loadingOverlay.show()},hideLoadingOverlay:function(){this.isClosed!==!0&&this.ui.loadingOverlay.hide()},toggleContextPanel:function(){n.panels.context.isPanelClosed()?this.showContextPanel():this.hideContextPanel()},showContextPanel:function(){n.panels.context.openPanel(),this.$el.addClass("panel-open"),this.ui.toggleFiltersButton.tooltip("hide").attr("data-original-title","Hide Filter Panel").tooltip("fixTitle"),this.ui.toggleFiltersIcon.removeClass("icon-collapse-alt"),this.ui.toggleFiltersIcon.addClass("icon-expand-alt"),this.ui.toggleFiltersText.html("Hide Filters")},hideContextPanel:function(){n.panels.context.closePanel({full:!0}),this.$el.removeClass("panel-open"),this.ui.toggleFiltersButton.tooltip("hide").attr("data-original-title","Show Filter Panel").tooltip("fixTitle"),this.ui.toggleFiltersIcon.addClass("icon-collapse-alt"),this.ui.toggleFiltersIcon.removeClass("icon-expand-alt"),this.ui.toggleFiltersText.html("Show Filters")},onPageScroll:function(){var e=t(document).scrollTop();if(void 0===this.navbarVerticalOffset&&(this.navbarVerticalOffset=this.ui.navbar.offset().top),void 0===this.topNavbarHeight){var i=t(".navbar-fixed-top");this.topNavbarHeight=i.length>0?i.height():0}this.ui.navbar.hasClass("navbar-fixed-top")?e<this.navbarVerticalOffset-this.topNavbarHeight&&this.ui.navbar.removeClass("navbar-fixed-top"):e>=this.navbarVerticalOffset-this.topNavbarHeight&&(this.ui.navbar.css("top",this.topNavbarHeight),this.ui.navbar.addClass("navbar-fixed-top"))},onRender:function(){t(document).on("scroll",this.onPageScroll),n.isSupported("2.1.0")||(this.ui.saveQueryToggle.remove(),this.ui.saveQuery.remove()),this.paginator.show(new o.Paginator({model:this.data.results})),this.count.show(new a({model:this.data.results})),this.table.show(new s.Table({view:this.data.view,collection:this.data.results})),this.ui.navbarButtons.tooltip({animation:!1,placement:"bottom"}),this.listenTo(this.data.view.facets,"reset",function(){0!==this.data.view.facets.length||n.config.get("session.defaults.data.preview")||n.notify({header:"No Columns Selected: ",level:"warning",timeout:!1,message:'No data can be displayed. Click the "Change Columns" button on the toolbar to select columns to display.'})})},onClose:function(){t(document).off("scroll",this.onPageScroll)},showExporterDialog:function(){n.dialogs.exporter.open()},showColumnsDialog:function(){n.dialogs.columns.open()},showQueryDialog:function(){n.dialogs.query.open()}});return{ResultCount:a,ResultsWorkflow:l}}),define("cilantro/ui/workflows/workspace",["marionette","../core","../query"],function(t,e,i){var n=t.Layout.extend({className:"workspace-workflow",template:"workflows/workspace",regions:{queries:".query-region",publicQueries:".public-query-region"},regionViews:{queries:i.QueryList,publicQueries:i.QueryList},initialize:function(){if(this.data={},e.isSupported("2.2.0")&&!(this.data.publicQueries=this.options.public_queries))throw new Error("public queries collection required");if(!(this.data.queries=this.options.queries))throw new Error("queries collection required");if(!(this.data.context=this.options.context))throw new Error("context model required");if(!(this.data.view=this.options.view))throw new Error("view model required");this.on("router:load",function(){e.panels.context.closePanel({full:!0}),e.panels.concept.closePanel({full:!0})})},onRender:function(){var t=new this.regionViews.queries({collection:this.data.queries,context:this.data.context,view:this.data.view,editable:!0});if(this.queries.show(t),e.isSupported("2.2.0")){var i=new this.regionViews.publicQueries({collection:this.data.publicQueries,context:this.data.context,view:this.data.view,title:"Public Queries",emptyMessage:"There are no public queries. You can create a new, public query by navigating to the 'Results'page and clicking on the 'Save Query...' button. While filling out the query form, you can mark the query as public which will make it visible to all users and cause it to be listed here."});this.publicQueries.show(i),this.listenTo(this.data.queries,"sync",function(){this.data.publicQueries.fetch({reset:!0})})}this.listenTo(e.data.concepts,"reset",function(){this.queries.show(t),this.publicQueries&&this.publicQueries.show(i)})}});return{WorkspaceWorkflow:n}}),define("cilantro/ui/workflows",["underscore","./workflows/query","./workflows/results","./workflows/workspace"],function(t){var e=[].slice.call(arguments,1);return t.extend.apply(null,[{}].concat(e))}),define("cilantro/ui",["underscore","./ui/core","./ui/accordion","./ui/base","./ui/button","./ui/charts","./ui/concept","./ui/context","./ui/controls","./ui/exporter","./ui/field","./ui/notify","./ui/paginator","./ui/query","./ui/tables","./ui/workflows"],function(t){var e=[].slice.call(arguments,2);
  return t.extend.apply(null,[{}].concat(e))}),define("cilantro/setup",["backbone","marionette","jquery","loglevel","./core","./ui"],function(t,e,i,n,o,r){function s(t){t=t||window.event;var e;e=t.type in h?h[t.type]:!this[u],e===!0?o.trigger("visible"):e===!1&&o.trigger("hidden")}o.templates.set(o.config.get("templates",{})),o.controls.set(o.config.get("controls",{}));var a=e.TemplateCache.prototype.loadTemplate,l=e.TemplateCache.prototype.compileTemplate;e.TemplateCache.prototype.loadTemplate=function(t){var e=o.templates.get(t);return e||(e=a.call(this,t)),e},e.TemplateCache.prototype.compileTemplate=function(t){return"function"!=typeof t&&(t=l(t)),t};var c=new r.Notifications({id:"cilantro-notifications"});i("body").append(c.render().el),o.notify=c.notify,i.ajaxPrefilter(function(t){t.xhrFields={withCredentials:!0}}),o.config.get("debug")&&(n.setLevel("debug"),o.on("all",function(){n.info.apply(n.info,[].slice.call(arguments,0))})),i(window).on("beforeunload",function(){return!o.config.get("debug")&&i.hasPendingRequest()?"Wow, you're quick! Your data is being saved. It will only take a moment.":void 0}),i(document).ajaxError(function(t,e,i,n){if("abort"!==e.statusText){var r="";r=0===e.status&&""===n?"The application is no longer responding.":'There is a communication problem with the server. <a href="#" onclick="location.reload()">Refreshing</a> the page may help.',o.notify({timeout:null,dismissable:!1,level:"error",header:"Uh oh.",message:r})}}),i(document).on("click","a",function(e){if(o.router){var i=this.pathname;"/"!==i.charAt(0)&&(i="/"+i);var n=t.history.root||"/";i.slice(0,n.length)===n&&(i=i.slice(n.length)),o.router.hasRoute(i)&&(e.preventDefault(),o.router.navigate(i,{trigger:!0}))}}),i(document).on("click","[data-route]",function(t){if(o.router){var e=i(t.target).attr("data-route");o.router.isNavigable(e)&&(t.preventDefault(),o.router.navigate(e,{trigger:!0}))}});var u="hidden",h={focus:!0,focusin:!0,pageshow:!0,blur:!1,focusout:!1,pagehide:!1};u in document?document.addEventListener("visibilitychange",s):(u="mozHidden")in document?document.addEventListener("mozvisibilitychange",s):(u="webkitHidden")in document?document.addEventListener("webkitvisibilitychange",s):(u="msHidden")in document?document.addEventListener("msvisibilitychange",s):"onfocusin"in document?document.onfocusin=document.onfocusout=s:window.onpageshow=window.onpagehide=window.onfocus=window.onblur=s}),define("cilantro",["underscore","./cilantro/core","./cilantro/session","./cilantro/models","./cilantro/ui","./cilantro/setup"],function(t,e,i,n,o){t.extend(e,i.events),e.sessions=new i.SessionManager,e.models=n,e.ui=o,e.sessions.on(e.SESSION_OPENED,function(t){e.session=t,e.router=t.router,e.data=t.data}),e.sessions.on(e.SESSION_CLOSED,function(){delete e.session,delete e.router,delete e.data});var r=!1;return e.ready=function(t){if(r)return t&&t(),void 0;var i=setInterval(function(){r=e.templates.ready()&&e.controls.ready(),r&&(clearTimeout(n),clearTimeout(i),e.trigger("ready",e),t&&t())},15),n=setTimeout(function(){clearTimeout(i),e.notify({timeout:null,dismissable:!1,level:"error",header:"Too long getting ready.",message:'Sorry about that, a few of the components needed to display the page took too longer to load. A <a href="#" onclick="location.reload()">refresh</a> sometimes resolves the issue.'})},500)},this.cilantro=e,t.each(e.config.get("events"),function(t,i){e.on(i,t)}),e.trigger("init",e),e});