(function(n){var i=nspace("kd.viz.component.summaries"),t=nspace("kd.events").EventNames;i.LegislativeBoundarySummaryView=Backbone.View.extend({initialize:function(n){if(!n.locationTypeProp)throw"locationTypeProp required";if(this.locationTypeProp=n.locationTypeProp,!n.districtProp)throw"districtProp required";if(this.districtProp=n.districtProp,!n.getDistrictName)throw"getDistrictName is required.";this.getDistrictName=n.getDistrictName,_.bindAll(this),this.model.bind("change:"+this.locationTypeProp,this.handleDistrictChange),this.model.bind("change:"+this.districtProp,this.handleDistrictChangeAndTriggerChange),this.model.bind(t.route.hydrate.name,this.handleDistrictChange)},handleDistrictChange:function(){return n("p",n(this.el)).html(this.getLegislativeSummaryText())},handleDistrictChangeAndTriggerChange:function(){n("p",n(this.el)).html()!==this.getLegislativeSummaryText()&&this.handleDistrictChange().trigger(t.render.complete.name)},getLegislativeSummaryText:function(){var t=this.model.get(this.locationTypeProp),n=this.model.get(this.districtProp);return n&&n.length!=0?n.length==1?this.getDistrictName(t,n[0]):""+n.length+" selected":"None Selected"}})})(jQuery),function(n){var i=nspace("kd.viz.component.summaries"),r=nspace("kd.events").EventNames.route.hydrate.name,t=nspace("kd.events").EventNames;i.SortSummaryView=Backbone.View.extend({initialize:function(n){if(!n.propertyName)throw"propertyName required";if(this.sortProperty=n.propertyName,!n.headerSelector)throw"headerSelector required";if(this.headerSelector=n.headerSelector,!n.bodySelector)throw"bodySelector required";this.bodySelector=n.bodySelector,_.bindAll(this),this.model.bind("change:"+this.sortProperty,this.handleSortChange),this.model.bind(r,this.handleSortChange),this.model.bind(t.route.hydrate.name,this.handleSortPropertyChange),this.model.bind(t.bar.complex.name,this.handleComplexBarGraphs),this.model.bind(t.bar.simple.name,this.handleSimpleBarGraphs)},getSortText:function(){var t=this,n=this.model.get(this.sortProperty);n=_.isArray(n)?_.first(n):n;switch(n){case"loc":case"val":return t.options.getSortName(n);default:return"None selected"}},handleSortPropertyChange:function(n){this.handlePropertyChange(this.options.el,this.getSortText,n)},handlePropertyChange:function(n,i,r){var u=i(),f;(u||(u="None selected"),u!==this.getText(n))&&(f=this.setText(n,u),r&&r.fireEvent)&&f.trigger(t.render.complete.name)},getText:function(t){return n(this.bodySelector,n(t)).html()},setText:function(t,i){return n(this.bodySelector,n(t)).html(i)},handleComplexBarGraphs:function(){n(this.el).hide()},handleSimpleBarGraphs:function(){n(this.el).show()}})}(jQuery),function(n){var i=nspace("kd.viz.component.summaries"),t=nspace("kd.events").EventNames;i.DataTypeSummaryView=Backbone.View.extend({initialize:function(i){if(_.uniq(n('input[data-entity="fmt"]').map(function(){return n(this).val()})).length<2&&this.$el.hide(),!i.headerSelector)throw"headerSelector required";if(this.headerSelector=i.headerSelector,!i.bodySelector)throw"bodySelector required";if(this.bodySelector=i.bodySelector,!i.dataTypeProperty)throw"dataTypeProperty required";if(this.dataTypeProperty=i.dataTypeProperty,!i.getDataName)throw"getDataName is required.";if(this.getDataName=i.getDataName,!i.vizType)throw"vizType is required";this.vizType=i.vizType,_.bindAll(this),this.model.bind("change:"+i.dataTypeProperty,this.handlePropertyChangeAndTriggerEvent),this.model.bind(t.route.hydrate.name,this.handlePropertyChange),this.setTitle("Data Type: ")},handlePropertyChangeAndTriggerEvent:function(){this.handlePropertyChange({fireEvent:!0})},handlePropertyChange:function(n){var i,r;(i=this.getDataTypeText(),i||(i="None selected"),i!==this.getText())&&(r=this.setText(i),n&&n.fireEvent)&&r.trigger(t.render.complete.name)},setTitle:function(t){var i=n(this.headerSelector,n(this.el));i.html(t+" ")},setText:function(t){return n(this.bodySelector,n(this.el)).html(t)},getText:function(){return n(this.bodySelector,n(this.el)).html()},getDataTypeText:function(){var i=this,n=this.model.get(this.dataTypeProperty),r=n==null||n.length==0,t="";return r||(t=_.map(n,function(n){return i.getDataName(n)}).join(", ")),t}})}(jQuery),function(n){var t=nspace("kd.viz.component.summaries"),i=nspace("kd.events").EventNames;t.TimeFrameSummaryView=Backbone.View.extend({initialize:function(r){if(_.uniq(n('select option[data-entity="tf"]').map(function(){return n(this).val()})).length<2&&n("a.helper",this.$el).hide(),!r.headerSelector)throw"headerSelector required";if(this.headerSelector=r.headerSelector,!r.bodySelector)throw"bodySelector required";if(this.bodySelector=r.bodySelector,!r.timeProperty)throw"timeProperty required";if(this.timeProperty=r.timeProperty,!r.getTimeName)throw"getTimeName is required.";if(this.getTimeName=r.getTimeName,!r.vizType)throw"vizType is required";this.vizType=r.vizType,this.timeFrameUtil=new t.util.TimeFrame,_.bindAll(this);var u=this;this.model.bind("change:"+this.timeProperty,function(){u.handleTimePropertyChange({fireEvent:!0})}),this.model.bind(i.route.hydrate.name,this.handleTimePropertyChange),this.setTitle(this.options.el,"Year(s): ")},handleTimePropertyChange:function(n){this.handlePropertyChange(this.options.el,this.getTimeFrameText,n)},handlePropertyChange:function(n,t,r){var u=t(),f;(u||(u="None selected"),u!==this.getText(n))&&(f=this.setText(n,u),r&&r.fireEvent)&&f.trigger(i.render.complete.name)},setTitle:function(t,i){var r=n(this.headerSelector,n(t));r.html(i+" ")},setText:function(t,i){return n(this.bodySelector,n(t)).html(i)},getText:function(t){return n(this.bodySelector,n(t)).html()},getTimeFrameText:function(){var e=this,t=this.model.get(this.timeProperty),o=t==null||t.length==0,r,i,u,f;return o?"None selected":(i=n("select:has([data-entity=tf])").first().find("option[data-entity=tf]"),r=i.filter(function(){return t.indexOf(n(this).data("id"))>-1||t.indexOf(n(this).attr("data-id"))>-1}),f=i.map(function(){return n(this).text()}).toArray(),u=r.map(function(){return n(this).text()}).toArray(),e.timeFrameUtil.getTimeFrameSummary(u,f))}})}(jQuery),function(){var n=nspace("kd.viz.component.summaries");n.TrendTimeFrameSummaryView=n.TimeFrameSummaryView.extend({getTimeFrameText:function(){var t=this,i=this.model.get(this.timeProperty),n;return n=_.map(i,function(n){return t.getTimeName(n)}),t.timeFrameUtil.getTimeFrameSummary(n,n)}})}(jQuery),function(n){var i=nspace("kd.viz.component.summaries"),t=nspace("kd.events").EventNames;i.DistributionSummaryView=Backbone.View.extend({initialize:function(n){var i=this;if(!n.headerSelector)throw"headerSelector required";if(this.headerSelector=n.headerSelector,!n.bodySelector)throw"bodySelector required";if(this.bodySelector=n.bodySelector,this.getDistributions=n.getDistributions||function(){return i.model.get(i.distributionProperty)},!n.getDistributionNames)throw"getDistributionNames required";if(this.getDistributionNames=n.getDistributionNames,!n.getDistributionNames)throw"getDistributionNames required";if(this.getDistributionNames=n.getDistributionNames,!n.getCharacteristicName)throw"getCharacteristicName required";if(this.getCharacteristicName=n.getCharacteristicName,!n.distributionProperty)throw"distributionProperty required";if(this.distributionProperty=n.distributionProperty,!n.getCharacteristicCount)throw"getCharacteristicCount is required";this.getCharacteristicCount=n.getCharacteristicCount,_.bindAll(this),this.model.bind("change:"+n.distributionProperty,this.handlePropertyChangeAndTriggerEvent),this.model.bind(t.route.hydrate.name,this.handlePropertyChange)},handlePropertyChangeAndTriggerEvent:function(){this.handlePropertyChange({fireEvent:!0})},handlePropertyChange:function(t){var i=this,f=this.getDistributions(),r=this.getDistributionNames(),u;if(!f||!r||_.isEmpty(f)||_.isEmpty(r)){n(this.el).hide();return}this.$distributionContainers||(this.$distributionContainers={},u=0,_.each(r,function(t){let f=Object.keys(t)[0];i.$distributionContainers[f]=u==0?i.$el:i.$el.clone(!0).insertAfter(n("div.data-summary.distribution-summary").last()),n(i.headerSelector,i.$distributionContainers[f]).html(r[u][f]+": "),u++})),i.setDistributionSummaryText(f,t)},setDistributionSummaryText:function(i,r){var u=this;_.each(i,function(f,e){var s,o;(s=u.getDistributionSummaryText(i,f,e),o=n(u.bodySelector,u.$distributionContainers[e]),s!==o.html())&&(o.html(s),r&&r.fireEvent)&&o.trigger(t.render.complete.name)})},getDistributionSummaryText:function(n,t,i){var r=this,u;return t&&t.length!=0?t.length==r.getCharacteristicCount(i)?"All":n[i].length==1?(u=_.map(n[i],function(n){return r.getCharacteristicName(n)}),u.join(", ")):""+n[i].length+" selected":"None selected"}})}(jQuery),function(){"use strict";var n=window.nspace("kd.viz.component.summaries.embed"),t=window.nspace("kd.viz.component.summaries");n.DistributionSummaryView=t.DistributionSummaryView.extend({handlePropertyChange:function(n){var t=this,i=t.getDistributions(),r=t.getDistributionNames(),f=t.options.$parentContainer,u=t.options.liIdentifier;(t.$distributionContainers={},$(t.$el.selector).remove(),i&&r&&!_.isEmpty(i)&&!_.isEmpty(r))&&f&&u&&(_.each(i,function(n,i){var e=$("<strong><\/strong>").text(r[i]+": ");t.$distributionContainers[i]=$("<li><\/li>").attr(u.attributeName,u.attributeValue).append(e).append("<span><\/span>"),f.append(t.$distributionContainers[i])}),t.setDistributionSummaryText(i,n))}})}(),function(){var n=nspace("kd.viz.component.summaries"),t=nspace("kd.events").EventNames.route.hydrate.name;n.LocationSummaryView=Backbone.View.extend({initialize:function(n){if(!n.propertyName)throw"propertyName required";this.locProperty=n.propertyName,_.bindAll(this,"handleLocationChange"),this.model.bind("change:"+this.locProperty,this.handleLocationChange),this.model.bind(t,this.handleLocationChange)},handleLocationChange:function(){var n=this.model.get(this.locProperty);n&&n.length!=0?this.$el.html(""+n.length+" selected"):this.$el.html("None selected")}})}(jQuery),function(n){"use strict";var i=nspace("kd.viz.component"),r=window.nspace("kd.viz.component.summaries.embed"),t=nspace("kd.viz");r.EmbedSummaryDefaults={locationSummaryView:{Class:i.summaries.LocationSummaryView,options:{el:".location-summary span",propertyName:t.UrlParams.location}},timeFrameSummaryView:{Class:i.summaries.TimeFrameSummaryView,options:{el:".time-summary",headerSelector:"strong",bodySelector:"span",timeProperty:t.UrlParams.timeFrame,getTimeName:function(i){var r=".modals select:has([data-entity="+t.UrlParams.timeFrame+"]) option[data-id="+i+"]";return n(r).first().text()}}},dataTypeSummaryView:{Class:i.summaries.DataTypeSummaryView,options:{el:".data-type-summary",headerSelector:"strong",bodySelector:"span",dataTypeProperty:t.UrlParams.dataFormat,getDataName:function(i){var r=".modals input:radio[data-entity="+t.UrlParams.dataFormat+"][data-id="+i+"]";return n(r).parent("label").first().text()}}},distributionSummaryView:{Class:r.DistributionSummaryView,options:{el:".distribution-summary",headerSelector:"strong",bodySelector:"span",distributionProperty:t.UrlParams.distribution,$parentContainer:n(".header-content + .details"),liIdentifier:{attributeName:"class",attributeValue:"distribution-summary"},getDistributions:function(){var n,i;return n=_.clone(this.model.get(t.UrlParams.distribution)),i=_.clone(n),_.each(i,function(t,i){t.length!==1&&delete n[i]}),n},getDistributionNames:function(){var r=n(".modals select[data-entity="+t.UrlParams.distribution+"]"),i;return i=_.clone(this.getDistributions()),_.each(i,function(n,t){i[t]=r.filter("[data-id="+t+"]").first().prev("label").text()}),i},getCharacteristicName:function(i){var r=".modals select[data-entity="+t.UrlParams.distribution+"] option[data-id="+i+"]";return n(r).text()},getCharacteristicCount:function(i){var r=".modals select[data-entity="+t.UrlParams.distribution+"][data-id="+i+"]";return n(r).first().find("option[data-entity="+t.UrlParams.characteristic+"]").length}}},pieDistributionSummaryView:{Class:r.DistributionSummaryView,options:{el:".distribution-summary",headerSelector:"strong",bodySelector:"span",distributionProperty:t.UrlParams.distribution,$parentContainer:n(".header-content + .details"),liIdentifier:{attributeName:"class",attributeValue:"distribution-summary"},getDistributions:function(){var n,i;return n=_.clone(this.model.get(t.UrlParams.distribution)),i=_.clone(n),_.each(i,function(t,i){t.length!==1&&delete n[i]}),delete n[this.model.get(t.UrlParams.primaryDist)],n},getDistributionNames:function(){var r=n(".modals select[data-entity="+t.UrlParams.distribution+"]"),i;return i=_.clone(this.getDistributions()),_.each(i,function(n,t){i[t]=r.filter("[data-id="+t+"]").first().prev("label").text()}),i},getCharacteristicName:function(i){var r=".modals select[data-entity="+t.UrlParams.distribution+"] option[data-id="+i+"]";return n(r).text()},getCharacteristicCount:function(i){var r=".modals select[data-entity="+t.UrlParams.distribution+"][data-id="+i+"]";return n(r).first().find("option[data-entity="+t.UrlParams.characteristic+"]").length}}}}}(jQuery),function(n,t){"use strict";var i=window.nspace("kd.viz.component.summaries.util");i.TimeFrame=function(n){var i=this;t.each(n,function(n,t){i[t]=n}),t.bindAll(i)},function(n){n.getTimeFrameSummary=function(n,t){var i,r;if(!n||n.length==null||!t||t.length==null)throw"You need to specify arrays as the values for selectedTexts and availableTexts.";return n.length===0?"None selected":n.length===1?n[0]:(i=n.sort(),r=t.sort(),this.isContinuous(i,r))?i[0]+" to "+i[i.length-1]:n.length+" selected"},n.isContinuous=function(n,t){var u=0,r=0,i;if(n.length===t.length)return!0;for(i=0;i<t.length;i++)if(n[0]===t[i]&&(u=i),n[n.length-1]===t[i]&&(r=i),r)break;return r-u+1===n.length}}(i.TimeFrame.prototype)}(jQuery,_)