/**
 * @license RequireJS text 2.0.10 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
 * Available via the MIT or new BSD license.
 * see: http://github.com/requirejs/text for details
 */

/*
 RequireJS order 1.0.5 Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
 Available via the MIT or new BSD license.
 see: http://github.com/jrburke/requirejs for details
*/

define("page",["classy","kizzy","signals","hasher","loadmask","json2"],function(e,t,i,s){return e.$extend({__init__:function(e){this.name=e,this.settings=t(this.name),this.loadSignal=new i.Signal,this.unloadSignal=new i.Signal},load:function(e){this.settings.clearExpireds(),this.$class.pushRequest(e),this.loadSignal.dispatch(e),this.isLoaded=!0},unload:function(){this.settings.clearExpireds(),this.unloadSignal.dispatch(),this.isLoaded=!1},toString:function(){return"[Page "+this.name+"]"},__classvars__:{requests:[],setHash:function(e){s.setHash(e)},showLoadMask:function(e,t){t=t||$("#pagecontent"),e='<span class="loading">'+(e||this.LOADING_MESSAGE)+"</span>",t.mask(e)},hideLoadMask:function(e){e=e||$("#pagecontent"),e.unmask()},pushRequest:function(e){this.requests.length>=10&&this.requests.shift(),this.requests.push(e)},errorHandler:function(e,t){var i=$("#pagecontent");if(e&&t){var s=this.generateErrorJSON(e);$.ajax({url:t,type:"POST",data:{json:s}})}i.mask('An error has occurred, and has been logged.  </br>If refreshing the page does not solve the issue, </br>try returning to the main page and making</br> another selection')},clearErrorMessage:function(){$("#pagecontent").unmask()},generateErrorJSON:function(e){return JSON.stringify($.extend(!0,{},e,{browser:$.browser,requests:this.requests}))},LOADING_MESSAGE:"Loading..."}})}),define("text",["module"],function(e){"use strict";var t,i,s,n,a,r=["Msxml2.XMLHTTP","Microsoft.XMLHTTP","Msxml2.XMLHTTP.4.0"],o=/^\s*<\?xml(\s)+version=[\'\"](\d)*.(\d)*[\'\"](\s)*\?>/im,l=/<body[^>]*>\s*([\s\S]+)\s*<\/body>/im,d="undefined"!=typeof location&&location.href,c=d&&location.protocol&&location.protocol.replace(/\:/,""),h=d&&location.hostname,u=d&&(location.port||void 0),p={},m=e.config&&e.config()||{};return t={version:"2.0.10",strip:function(e){if(e){e=e.replace(o,"");var t=e.match(l);t&&(e=t[1])}else e="";return e},jsEscape:function(e){return e.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:m.createXhr||function(){var e,t,i;if("undefined"!=typeof XMLHttpRequest)return new XMLHttpRequest;if("undefined"!=typeof ActiveXObject)for(t=0;t<3;t+=1){i=r[t];try{e=new ActiveXObject(i)}catch(e){}if(e){r=[i];break}}return e},parseName:function(e){var t,i,s,n=!1,a=e.indexOf("."),r=0===e.indexOf("./")||0===e.indexOf("../");return-1!==a&&(!r||a>1)?(t=e.substring(0,a),i=e.substring(a+1,e.length)):t=e,s=i||t,a=s.indexOf("!"),-1!==a&&(n="strip"===s.substring(a+1),s=s.substring(0,a),i?i=s:t=s),{moduleName:t,ext:i,strip:n}},xdRegExp:/^((\w+)\:)?\/\/([^\/\\]+)/,useXhr:function(e,i,s,n){var a,r,o,l=t.xdRegExp.exec(e);return!l||(a=l[2],r=l[3],r=r.split(":"),o=r[1],r=r[0],!(a&&a!==i||r&&r.toLowerCase()!==s.toLowerCase()||(o||r)&&o!==n))},finishLoad:function(e,i,s,n){s=i?t.strip(s):s,m.isBuild&&(p[e]=s),n(s)},load:function(e,i,s,n){if(n.isBuild&&!n.inlineText)return void s();m.isBuild=n.isBuild;var a=t.parseName(e),r=a.moduleName+(a.ext?"."+a.ext:""),o=i.toUrl(r),l=m.useXhr||t.useXhr;if(0===o.indexOf("empty:"))return void s();!d||l(o,c,h,u)?t.get(o,function(i){t.finishLoad(e,a.strip,i,s)},function(e){s.error&&s.error(e)}):i([r],function(e){t.finishLoad(a.moduleName+"."+a.ext,a.strip,e,s)})},write:function(e,i,s,n){if(p.hasOwnProperty(i)){var a=t.jsEscape(p[i]);s.asModule(e+"!"+i,"define(function () { return '"+a+"';});\n")}},writeFile:function(e,i,s,n,a){var r=t.parseName(i),o=r.ext?"."+r.ext:"",l=r.moduleName+o,d=s.toUrl(r.moduleName+o)+".js";t.load(l,s,function(i){var s=function(e){return n(d,e)};s.asModule=function(e,t){return n.asModule(e,d,t)},t.write(e,l,s,a)},a)}},"node"===m.env||!m.env&&"undefined"!=typeof process&&process.versions&&process.versions.node&&!process.versions["node-webkit"]?(i=require.nodeRequire("fs"),t.get=function(e,t,s){try{var n=i.readFileSync(e,"utf8");0===n.indexOf("\ufeff")&&(n=n.substring(1)),t(n)}catch(e){s(e)}}):"xhr"===m.env||!m.env&&t.createXhr()?t.get=function(e,i,s,n){var a,r=t.createXhr();if(r.open("GET",e,!0),n)for(a in n)n.hasOwnProperty(a)&&r.setRequestHeader(a.toLowerCase(),n[a]);m.onXhr&&m.onXhr(r,e),r.onreadystatechange=function(t){var n,a;4===r.readyState&&(n=r.status,n>399&&n<600?(a=new Error(e+" HTTP status: "+n),a.xhr=r,s(a)):i(r.responseText),m.onXhrComplete&&m.onXhrComplete(r,e))},r.send(null)}:"rhino"===m.env||!m.env&&"undefined"!=typeof Packages&&"undefined"!=typeof java?t.get=function(e,t){var i,s,n=new java.io.File(e),a=java.lang.System.getProperty("line.separator"),r=new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(n),"utf-8")),o="";try{for(i=new java.lang.StringBuffer,s=r.readLine(),s&&s.length()&&65279===s.charAt(0)&&(s=s.substring(1)),null!==s&&i.append(s);null!==(s=r.readLine());)i.append(a),i.append(s);o=String(i.toString())}finally{r.close()}t(o)}:("xpconnect"===m.env||!m.env&&"undefined"!=typeof Components&&Components.classes&&Components.interfaces)&&(s=Components.classes,n=Components.interfaces,Components.utils.import("resource://gre/modules/FileUtils.jsm"),a="@mozilla.org/windows-registry-key;1"in s,t.get=function(e,t){var i,r,o,l={};a&&(e=e.replace(/\//g,"\\")),o=new FileUtils.File(e);try{i=s["@mozilla.org/network/file-input-stream;1"].createInstance(n.nsIFileInputStream),i.init(o,1,0,!1),r=s["@mozilla.org/intl/converter-input-stream;1"].createInstance(n.nsIConverterInputStream),r.init(i,"utf-8",i.available(),n.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER),r.readString(i.available(),l),r.close(),i.close(),t(l.value)}catch(e){throw new Error((o&&o.path||"")+": "+e)}}),t}),define("text!status.json",[],function(){return'{"debug": true}'}),define("js/Facade",["puremvc","text!status.json","json2"],function(e,t){var i=JSON.parse(t);return e.Facade.$extend({sendNotification:function(e,t,s){Date.now=Date.now||function(){return+new Date},console.log(Date.now()+" : "+e+(s?" : "+s:""));try{this.$super(e,t,s)}catch(t){if("undefined"!=typeof console&&"function"==typeof console.log&&(console.log("ERROR: "+t.name+" : "+t.message),console.log(t.stack)),i.debug)throw t;this.$super(this.$class.ERROR,t,e)}},__classvars__:{STARTUP:"startup",RELOAD:"reload",UNLOAD:"unload",PARAMETER_PROXY_UPDATED:"parameterProxyUpdated",TABLE_RENDERED:"tableRendered",UPDATE_VISUALIZATION_VIEW_STACK:"updateVisualizationViewStack",TABLEDATA_UPDATED:"tableDataUpdated",CHART_DATA_UPDATED:"chartDataUpdated",DEFAULT_CHART_SET:"defaultChartSet",MAP_DATA_UPDATED:"mapDataUpdated",CSV_DATA_GENERATED:"csvDownloadDataGenerated",TIME_PERIOD_PARAM_UPDATED:"timePeriodParamUpdated",FREQUENCY_PARAM_UPDATED:"frequencyParamUpdated",CASE_PARAM_UPDATED:"caseParamUpdated",TABLE_PARAMS_UPDATED:"tableParamsUpdated",CHART_PARAMS_UPDATED:"chartParamsUpdated",CTYPE_PARAM_UPDATED:"ctypeParamUpdated",REGION_PARAM_UPDATED:"regionParamUpdated",MAP_TYPE_PARAM_UPDATED:"mapTypeParamUpdated",PIN_SOURCEKEY_PARAM_UPDATED:"pinSourcekeyParamUpdated",TABLE_SELECTION_CHANGED:"tableSelectionChanged",TIME_SELECTION_UPDATED:"timeSelectionUpdated",CASE_SELECTION_CHANGED:"caseSelectionChanged",FREQUENCY_SELECTION_UPDATED:"frequencySelectionUpdated",CHART_SELECTION_UPDATED:"chartSelectionUpdated",REGION_SELECTION_UPDATED:"regionSelectionUpdated",MAP_TYPE_SELECTION_UPDATED:"mapTypeSelectionUpdated",DOWNLOAD_OPTION_SELECTED:"downloadOptionSelected",PIN_SOURCEKEY_SELECTED:"pinSourcekeySelected",SOURCE_KEY_SELECTED:"sourcekeySelected",ERROR:"error"}})}),define("js/model/ConfigProxy",["puremvc","text!configJSON","json2"],function(e,t){var i=JSON.parse(t);return e.Proxy.$extend({topicMap:null,__init__:function(){this.$super(this.$class.NAME,i)},getStudies:function(){return this.getData().studies},getVisualizations:function(){return this.getData().visualizations},setVisualizations:function(e){this.getData().visualizations=e},setDownloadParameters:function(e){this.getData().downloadParameters=e},getDownloadParameters:function(){return this.getData().downloadParameters},getDefaultFrequency:function(){return"A"},getValidFrequencies:function(){return["A","Q"]},getDefaultStart:function(e){return e.start},getDefaultEnd:function(e){return e.end},__classvars__:{NAME:"ConfigProxy"}})}),define("js/model/RequestProxy",["puremvc"],function(e){return e.Proxy.$extend({__init__:function(e){this.$super(this.$class.NAME,e)},getQuery:function(){return this.getData().query},getSelectedTable:function(){return this.getQuery().id},getSelectedCase:function(){return this.getQuery().cases},getFrequency:function(){return this.getQuery().f},getStartPeriod:function(){return this.getQuery().start},getEndPeriod:function(){return this.getQuery().end},__classvars__:{NAME:"RequestProxy"}})}),define("js/model/ParameterProxy",["puremvc","js/Facade","js/model/ConfigProxy","js/model/RequestProxy","text!defaults","json2"],function(e,t,i,s,n){var a=JSON.parse(n);return e.Proxy.$extend({__init__:function(){this.$super(this.$class.NAME,{query:$.extend({},a)})},getQuery:function(){return this.getData().query},getQueryKeys:function(){return["id","region","cases","start","end","f","linechart","map","ctype","chartindexed","maptype","columnvalues","sid","sourcekey"]},getConfig:function(){return this.facade.retrieveProxy(i.NAME).getData()},getQueryString:function(e){var t,i,s=$.extend({},this.getQuery(),e),n="?",a=this.getQueryKeys();for(t=0;t<a.length;t++)i=a[t],s.hasOwnProperty(i)&&(n+=i+"="+s[i]+"&");return n.substring(0,n.length-1)},update:function(e){this.note=e;var i=this.facade.retrieveProxy(s.NAME),n=!1,a=void 0===i.getSelectedTable(),r=void 0===i.getSelectedCase(),o=void 0===i.getFrequency(),l=void 0===i.getStartPeriod()||void 0===i.getEndPeriod(),d=!("region"in i.getQuery())&&this.hasRegions(this.getSelectedTable()),c=!("ctype"in i.getQuery()),h=!1,u=!1,p=!1;this.updateQuery(i.getQuery(),function(e,t,i){n=!0,a|="id"==e,r|="cases"==e,o|="f"==e,l|="start"==e||"end"==e,$.each(["linechart","map","sid"],function(t,i){u|=e==i}),c|="ctype"==e,u|="chartindexed"==e,d|="region"==e,h|="maptype"==e,u|="columnvalues"==e,p|="sourcekey"==e}),n&&this.sendNotification(t.PARAMETER_PROXY_UPDATED),a|=r||d,u|=c,a&&this.sendNotification(t.TABLE_PARAMS_UPDATED),c&&(this.sendNotification(t.UPDATE_VISUALIZATION_VIEW_STACK),this.sendNotification(t.CTYPE_PARAM_UPDATED)),r&&this.sendNotification(t.CASE_PARAM_UPDATED),o&&this.sendNotification(t.FREQUENCY_PARAM_UPDATED),l&&this.sendNotification(t.TIME_PERIOD_PARAM_UPDATED),u&&this.sendNotification(t.CHART_PARAMS_UPDATED),d&&this.sendNotification(t.REGION_PARAM_UPDATED),h&&this.sendNotification(t.MAP_TYPE_PARAM_UPDATED),p&&this.sendNotification(t.PIN_SOURCEKEY_PARAM_UPDATED)},copyQuery:function(e,t,i,s){var n,a,r={},o={};for(n in t)t.hasOwnProperty(n)&&(a=n.toLowerCase(),e[a]=t[n],i[a]!=t[n]?r[a]=n:o[a]=n);for(a in i)i.hasOwnProperty(a)&&(a in r||a in o||(e[a]=void 0,r[a]=a));for(a in r)r.hasOwnProperty(a)&&s.call(this,a,e[a],i[a])},updateQuery:function(e,t){var i={};this.copyQuery(i,e,this.getQuery(),t),this.validateQuery(i),$.extend(this.getData(),{query:i})},checkVal:function(e,t,i,s){e[t]=void 0===e[t]||s&&!s(e[t])?i:e[t]},validateQuery:function(e){this.validateId(e),this.validateFrequency(e),this.validateStartEnd(e)},validateFrequency:function(e){var t=this.facade.retrieveProxy(i.NAME),s=t.getDefaultFrequency();this.checkVal(e,"f",s,function(e){return $.inArray(e,t.getValidFrequencies())>-1})},validateStartEnd:function(e){var t=this.facade.retrieveProxy(i.NAME);e.start=parseInt(e.start),e.end=parseInt(e.end);var s=t.getDefaultStart(this.getTableById(e.id)),n=t.getDefaultEnd(this.getTableById(e.id));this.checkVal(e,"start",s,function(e){return e>=s&&e<=n}),this.checkVal(e,"end",n,function(t){return t>e.start&&t<=n})},validateId:function(e){var t,s,n,r=this.facade.retrieveProxy(i.NAME),o=a.id,l=r.getStudies(),d=!1,c=!1;if(this.checkVal(e,"id",o,function(e){s=e.split("-")[1];for(var i=0;i<l.length;i++)if(l[i].id==s){t=l[i],d=!0;for(var a=0;a<t.tables.length;a++)if(t.tables[a].id==e)return n=t.tables[a],c=!0,!0}return!1}),d?c||(n=t.tables[0],e.id=n.id):(n=this.getTableById(a.id),t=this.getStudyByTableId(n.id),e.id=a.id),this.checkVal(e,"region",n.regions[0].id,function(e){for(var t=0;t<n.regions.length;t++)if(n.regions[t].id==e)return!0;return!1}),this.checkVal(e,"sourcekey",0,function(e){return!(!e&&e)}),void 0!==e.cases){for(var h=e.cases.split("~"),u=0;u<h.length;u++){for(var p=!1,m=0;m<t.cases.length;m++)if(t.cases[m].scenario==h[u]){p=!0;break}p||(h.splice(u,1),u--)}e.cases=h.join("~")}var g=[];for(oneCase=0;oneCase<t.cases.length;oneCase++)1==t.cases[oneCase].default_case&&g.push(t.cases[oneCase].scenario);g.length?defaultCases=g.join("~"):defaultCases=t.cases[0].scenario,this.checkVal(e,"cases",defaultCases,function(e){return void 0!==e&&e.length>0})},getGAString:function(e){return this.getQueryString(e)},getTableParamsString:function(){var e=this.getQuery().id.split("-")[1],t=this.getSelectedTable().id,i=this.getQuery().cases?this.getCaseIdsByArgs(this.getQuery().cases):this.getSelectedStudy().cases[0].id,s=this.getQuery().f?this.getQuery().f:"A";return"?studyID="+e+"&tableID="+t+"&caseID="+i+"®ionID="+(this.getQuery().region?this.getQuery().region:this.getTableById(t).regions[0].id)+"&freq="+s+"&sid="+this.getPinnedIds().join("~")},getMapParamsString:function(e){var t=e.uuid.split(".")[1].split("-");return"?tableID="+(t=t[1]+"-"+t[2])+"&caseID="+e.uuid.split(".")[0]+"&rowID="+e.rowId},resetStartEnd:function(e){var t=(this.facade.retrieveProxy(s.NAME),this.getLastHistorical()),i=this.getQuery();if(e)switch(e){case"Q":parseInt(i.start)>parseInt(t)?parseInt(i.start)-parseInt(t)<5?i.start=(5*Math.ceil(parseInt(i.start)/5)).toString():i.start=(5*Math.round(parseInt(i.start)/5)).toString():i.start=i.start,parseInt(i.end)>parseInt(t)?parseInt(i.end)-parseInt(t)<5?i.end=(5*Math.ceil(parseInt(i.end)/5)).toString():i.end=(5*Math.round(parseInt(i.end)/5)).toString():i.end=i.end;break;default:i.start=i.start,i.end=i.end}else delete i.start,delete i.end},resetFrequency:function(){delete this.getQuery().f},getChartParams:function(){var e=(this.facade.retrieveProxy(i.NAME),{chartindexed:this.getChartIndexed(),ctype:this.getChartType(),columnendpoints:this.getColumnEndpoints(),columnvalues:this.getColumnValues()});return $.extend(e,this.getTimeParams())},getChartedIds:function(e){var t=this.getCharted(e);return t?t.split("~"):[]},getCharted:function(e){return this.getQuery()[e]},setDefaultCharted:function(e,t){this.getQuery()[e]=t},getChartIndexed:function(){return this.getQuery().chartindexed},getChartType:function(){return this.getQuery().ctype?this.getQuery().ctype:"linechart"},getMapType:function(){return this.getQuery().maptype?this.getQuery().maptype:0},getColumnEndpoints:function(){return this.getQuery().columnendpoints},getColumnValues:function(){return this.getQuery().columnvalues},getSelectedStudy:function(){return this.getStudyByTableId(this.getQuery().id)},getStudyByTableId:function(e){for(var e=e.split("-")[1],t=this.getConfig().studies,i=0;i<t.length;i++)if(t[i].id==e)return t[i]},getSelectedTable:function(){return this.getTableById(this.getQuery().id)},getLastHistorical:function(){return this.getSelectedTable().lastHistorical},getTableById:function(e){for(var t=this.getStudyByTableId(e).tables,i=0;i<t.length;i++)if(t[i].id==e)return t[i]},getTimeParams:function(){return{start:this.getQuery().start?parseInt(this.getQuery().start):parseInt(this.getSelectedTable().start),end:this.getQuery().end?parseInt(this.getQuery().end):parseInt(this.getSelectedTable().end),f:this.getQuery().f?this.getQuery().f:"A",ctype:this.getQuery().ctype?this.getQuery().ctype:"linechart"}},getSelectedCases:function(){return this.getQuery().cases.split("~")},getSelectedRegion:function(){return this.getQuery().region?this.getQuery().region:this.getSelectedTable().regions[0].id},getPinned:function(){return this.getQuery().sid},getPinnedIds:function(){var e=this.getPinned();if(void 0===e)return[];var t=e?e.split("~"):[];return $.each(t,function(e,i){""==t[e]&&(t[e]=null)}),t},getUpdatedPinnedIds:function(e,t){var i=this.getPinnedIds().slice();e=e instanceof Array?e:[e];for(var s=0;s<e.length;s++){var n=e[s],a=$.inArray(n,i);if(~a||!0===t)~a&&!1!==t&&(i[a]=null);else{var r=$.inArray(null,i);~r?i[r]=n:i.push(n)}}return i},getUpdatedPinned:function(e,t){return this.getUpdatedPinnedIds(e,t).join("~")},getUpdatedCharted:function(e,t,i){return this.getUpdatedChartedIds(e,t,i).join("~")},getUpdatedChartedIds:function(e,t,i){var s=this.getChartedIds(t).slice();e=e instanceof Array?e:[e];for(var n=0;n<e.length;n++){var a=e[n],r=$.inArray(a,s);if(~r||!0===i)~r&&!1!==i&&(s[r]=null);else{var o=$.inArray(null,s);~o?s[o]=a:s.push(a)}}return s},getPinSourcekey:function(){return this.getQuery().sourcekey},resetCase:function(){delete this.getQuery().cases},resetRegion:function(){delete this.getQuery().region},resetCharted:function(){var e=this.facade.retrieveProxy(i.NAME),t=(e.getVisualizations(),this.getQuery());delete t.map,delete t.linechart,delete t.ctype},resetChartindexed:function(){delete this.getQuery().chartindexed},getCaseIdsByArgs:function(e){for(var t=e.split("~"),i=[],s=this.getSelectedStudy().cases,n=0;n<s.length;n++)-1!=$.inArray(s[n].scenario,t)&&i.push(s[n].id);return i.join(",")},getCaseIDsArray:function(){return(this.getQuery().cases?this.getCaseIdsByArgs(this.getQuery().cases):this.getSelectedStudy().cases[0].id).split(",")},getCaseNameById:function(e){for(var t=this.getSelectedStudy().cases,i=0;i<t.length;i++)if(t[i].id==e)return t[i].description;return""},hasRegions:function(e){return e.regions.length>1},isMappable:function(e){if(e.regions.length>1){for(var t=0;t<e.regions.length;t++)if(1!=e.regions[t].region_group_id)return!1;return!0}return!1},__classvars__:{NAME:"ParameterProxy"}})}),define("js/model/DataProxy",["puremvc"],function(e){return e.Proxy.$extend({__init__:function(){this.$super(this.$class.NAME),this.cache={},this.cacheKeys=[]},setData:function(e,t){this.$super(t),this.addToCache(e,t)},setDataFromCache:function(e){this.data=this.getFromCache(e)},inCache:function(e){return e in this.cache},addToCache:function(e,t){this.inCache(e)?this.cache[e]=t:(this.cacheKeys.length>=this.$class.CACHE_LIMIT&&delete this.cache[this.cacheKeys.shift()],this.cacheKeys.push(e),this.cache[e]=t)},getFromCache:function(e){return this.cache[e]},__classvars__:{CACHE_LIMIT:5}})}),define("js/model/TableDataProxy",["js/Facade","js/model/DataProxy","js/model/ParameterProxy","js/model/ConfigProxy"],function(e,t,s,n){return t.$extend({combinedRows:[],pinData:[],getItemMetadata:function(e){var t={cssClasses:""},i=this[e];return t.cssClasses+="level_"+i.LEVEL,i.HAS_DATA||(t.cssClasses+=" NO_DATA"),t},getDataColumns:function(e){var t=this.facade.retrieveProxy(s.NAME),i=t.getLastHistorical(),n=[],a=[],r=this.getData().tabledata.datacolumns;for(col in r)if(a.push(r[col]),-1!=i)i==r[col]&&(i=-1),n.push(r[col]);else switch(e){case"Q":(isNaN(parseInt(r[col]))||parseInt(r[col])%5==0)&&n.push(r[col]);break;default:n.push(r[col])}return n},getDataColsNoGrowth:function(e){var t=this.facade.retrieveProxy(s.NAME),i=t.getLastHistorical(),n=[],a=[],r=this.getData().tabledata.datacolumns;for(col in r)if(a.push(r[col]),-1!=i)i==r[col]&&(i=-1),n.push(r[col]);else switch(e){case"Q":(isNaN(parseInt(r[col]))||parseInt(r[col])%5==0)&&n.push(r[col]);break;default:n.push(r[col])}return n.pop(),n},getTableData:function(){return this.getData()?this.getData().tabledata.rows:{}},getFootnotes:function(){return this.getData()?this.getData().tabledata.footnotes:[]},getCombinedData:function(e){var t,i=(this.facade.retrieveProxy(n.NAME),this.facade.retrieveProxy(s.NAME)),a=i.getLastHistorical(),r=(i.getSelectedTable().id,i.getSelectedStudy()),o=[],l=[],d=-1;if(void 0===e)return this.combinedRows;t=e,Object.keys||(Object.keys=function(e){var t=[];for(var i in e)e.hasOwnProperty(i)&&t.push(i);return t});for(var c in t)if(t[c].description&&null!=t[c].description&&void 0!=t[c].description&&""!=t[c].description){if(o.push(t[c]),d++,o[d].description=o[d].description+"<sup>"+o[d].footnoteLineNumber+"</sup>",o[d].last_historical=a,o[d].show_units=!0,1===t[c].has_data){var h=i.getCaseIDsArray();if(h.length>1){for(var u=0,p=0;p<h.length;p++){var m=h[p],g=t[c].data[m];o.push(JSON.parse(JSON.stringify(t[c]))),d++,o[d].uuid=m+"."+o[d].rowId+(o[d].regionId&&"0-0"!==o[d].regionId?"."+o[d].regionId:"");var f=o[d].uuid.split(".")[1].split("-");if(f=f[1]+"-"+f[2],o[d].uuid.split(".").length>2)for(var v=i.getTableById(f).regions,b=0;b<v.length;b++)if(v[b].id==o[d].uuid.split(".")[2]){o[d].regionTitle=v[b].title;break}o[d].caseTitle=i.getCaseNameById(o[d].uuid.split(".")[0]),o[d].PIN=$.inArray(o[d].uuid,i.getPinnedIds())>-1,o[d].description=i.getCaseNameById(m),o[d].isPinned?o[d].indentLevel=1:o[d].indentLevel++,o[d].data=void 0===g?{}:g,o[d].last_historical=a,1===r.inAPI&&(o[d].series_id=r.id.substr(0,3)+"."+r.id.substr(3,4)+"."+m.split("-")[0].toUpperCase()+"."+o[d].varName.toUpperCase()+".A"),o[d].show_units=!0,o[d].is_chartable=!0,i.isMappable(i.getTableById(f))&&(o[d].is_mappable=!0),u++}o[d-h.length].data={},o[d-h.length].has_data=!1,o[d-h.length].show_units=!1,o[d-h.length].is_chartable=!0,o[d-h.length].is_mappable=!1,o[d-h.length].uuid=void 0}else o[d].uuid=o[d].uuid[0],1===r.inAPI&&(o[d].series_id=r.id.substr(0,3)+"."+r.id.substr(3,4)+"."+h[0].split("-")[0].toUpperCase()+"."+o[d].varName.toUpperCase()+".A"),o[d].PIN=$.inArray(o[d].uuid,i.getPinnedIds())>-1,$.each(t[c].data,function(e,t){o[d].data=t,o[d].is_chartable=!0;var s=o[d].uuid.split(".")[1].split("-");if(s=s[1]+"-"+s[2],o[d].uuid.split(".").length>2){var s=o[d].uuid.split(".")[1].split("-");s=s[1]+"-"+s[2];for(var n=i.getTableById(s).regions,a=0;a<n.length;a++)if(n[a].id==o[d].uuid.split(".")[2]){o[d].regionTitle=n[a].title;break}}o[d].caseTitle=i.getCaseNameById(o[d].uuid.split(".")[0]),i.isMappable(i.getTableById(s))&&(o[d].is_mappable=!0)})}o[d].isPinned&&l.push(o[d])}return this.setPinData(l),o},getTableUnits:function(){return"Unknown Units"},getTableTitle:function(){return this.data.tabledata.description},getChildRows:function(e){for(var t=[],i=this.combinedRows,s=e+1;s<i.length&&i[s].indentLevel>i[e].indentLevel;s++)i[s].has_data&&t.push(s);return t},getChildData:function(e){var t=this.getChildRows(e),s=this.combinedRows,n=[];for(i=0;i<t.length;i++)n.push(s[t[i]]);return n},loadTableData:function(){var t=this.facade.retrieveProxy(s.NAME),i=t.getTableParamsString(),a=(this.facade.retrieveProxy(n.NAME),this);this.isUpdating=!0,$.ajax(encodeURI("data/index.php"+i+"&type=data"),{dataType:"json",error:function(){a.sendNotification(e.ERROR)},success:function(s){s.tabledata.rows;a.combinedRows=a.getCombinedData(s.tabledata.rows),s.chartData={},a.setData(i,s),a.createIDMap(),a.processLevels(a.combinedRows),a.processChartData(t.getChartType()),a.processPinData(),a.isUpdating=!1,a.sendNotification(e.TABLEDATA_UPDATED)}})},processLevels:function(e){var t,i,s,n,a,r=[],o=[];for(t=e.length-1;t>=0;t--){for(a=e[t],a.levelGroups=[],a.indentLevel=a.indentLevel-1,n=a.indentLevel,i=r.slice(0).length-1;i>n;i--)r.pop();for(s=n;s>0;s--)void 0===r[s]?s==n&&(a.isLast=!0,a.levelGroups[s]=r[s]=void 0!==o[s]?++o[s]:o[s]=0):a.levelGroups[s]=r[s]}},processChartData:function(t,i){for(var a,r,o,l,d,c,h=this.facade.retrieveProxy(s.NAME),u=this.facade.retrieveProxy(n.NAME),p=[],m=[],g=this.combinedRows,f=this.getTableData(),v=this.getIDMap(),b=$.map(u.getVisualizations(),function(e){return e.class}),o=0;o<b.length;o++)if(b[o]!=t)for(var a=0;a<g.length;a++)g[a][b[o]]&&(g[a][b[o]]=!1,p.push(a));else{m=[];var _=h.getChartedIds(t);if(0==_.length&&!i){var C=h.getSelectedTable().default_row,y=!1;if(!isNaN(parseInt(C))&&C>=0&&C<g.length)for(a=0;a<g.length;a++){for(;a<g.length&&g[a].num==C&&g[a].has_data;)_.push(g[a].uuid),y=!0,a++;if(y)break}if(y)h.setDefaultCharted("map",_[0]);else{var T=!1,w=[];for(a=0;a<g.length;a++){for(var A=g[a].num;a<g.length&&g[a].has_data&&!g[a].isPinned&&g[a].num==A;)_.push(g[a].uuid),y=!0,g[a].is_mappable&&(w.push(g[a].uuid),T=!0),a++;if(y)break}if(!T)for(a=0;a<g.length;a++){for(var A=g[a].num;a<g.length&&g[a].has_data&&g[a].is_mappable&&g[a].num==A;)w.push(g[a].uuid),T=!0,a++;if(T)break}h.setDefaultCharted("map",w[0])}h.setDefaultCharted("linechart",_.join("~"))}var S=_.slice(),x=this.getChartData(t)||[];if(S.length>0)for(a=0;a<S.length;a++){var D=!1,E=v[S[a]];if(E){for(r=0;r<E.length;r++)if(l=g[E[r]],l.has_data&&(l[t]=!0,p.push(E[r]),!D)){D=!0,m.push(l);var P=$.inArray(l,x);P>=0&&x.splice(P,1)}}else null==S[a]?m.push(null):_.splice(a,1)}if(_.length<1&&"pin"!=t&&"sourcekey"!=t&&t==h.getChartType()){if(!i||"map"==t){h.getQuery();for(a=0,r=0;a<f.length&&r<1;r++){for(l=null,a;a<f.length&&(!l||!l.has_data);l=f[a++]);l[t]=!0,m.push(l),_.push(l.uuid),p=p.concat(v[l.uuid])}if("map"==t&&1==_.length){var E=p;E&&E.length>0&&$.each(E,function(e,i){g[i][t]=!0})}}this.sendNotification(e.DEFAULT_CHART_SET,_,t)}for(a=0;a<x.length;a++)if(null!=(l=x[a])&&!~$.inArray(l.uuid,_))for(var E=v[l.uuid],r=0;r<E.length;r++)l=g[E[r]],l.has_data&&(l[t]=!1,p.push(E[r]));if("linechart"==b[o])for(a=0;a<g.length;a++)if(l=g[a],!l.has_data&&l.levelGroups&&l.description.indexOf("Pinned Series")<0){for(d=this.getChildData(a),c=d.length>0,r=0;r<d.length;r++)c&=d[r][t];l[t]!=c&&p.push(a),l[t]=c}void 0===this.getData().chartData&&(this.getData().chartData={}),this.getData().chartData[t]=m}return p},createIDMap:function(){for(var e=this.combinedRows,t={},i=0;i<e.length;i++){var s=e[i].uuid;t[s]||(t[s]=[]),t[s].push(i)}return this.getData().IDMAP=t,t},getIDMap:function(){return this.getData().IDMAP},getChartData:function(e){return void 0!==e?this.getData().chartData[e]:this.getData().chartData},getPinData:function(){return this.pinData||[]},setPinData:function(e){this.pinData=e},processPinData:function(){var e,t,i=this.facade.retrieveProxy(s.NAME),n=this.combinedRows,a=this.getIDMap(),r=i.getPinnedIds(),o=this.getPinData(),l=[],d=0;i.getSelectedRegion();for(t=0;t<n.length;t++)if(e=n[t],void 0!==e.PIN){var c=-1!=$.inArray(e.uuid,r),h=e.PIN;e.PIN=c;var u=e.uuid.split(".");u=u.length>2?u[2]:"0-0";var p="";if(e.isPinned){if("0-0"!=u){var m=e.uuid.split(".")[1].split("-");m=m[1]+"-"+m[2];for(var g=i.getTableById(m).regions,f=0;f<g.length;f++){p+=": "+g[f].title;break}}var v=i.getCaseNameById(e.uuid.split(".")[0]);p+=": "+v,0!=n[t].chart_name.indexOf(e.uuid.split(".")[1].split("-")[2])&&(n[t].chart_name=e.uuid.split(".")[1].split("-")[2]+": "+n[t].chart_name),n[t].description=n[t].chart_name+p}if(c!=h&&e.has_data){var b=$.extend(!0,[],n);if(c){if(b[a[e.uuid][0]].level=1,b[a[e.uuid][0]].indentLevel=1,b[a[e.uuid][0]].chart_name=e.uuid.split(".")[1].split("-")[2]+": "+b[a[e.uuid][0]].chart_name,b[a[e.uuid][0]].description=b[a[e.uuid][0]].chart_name,"0-0"!=i.getSelectedRegion())for(var g=i.getSelectedTable().regions,f=0;f<g.length;f++)if(g[f].id==i.getSelectedRegion()){b[a[e.uuid][0]].description+=": "+g[f].title;break}var v=i.getCaseNameById(e.uuid.split(".")[0]);b[a[e.uuid][0]].description+=": "+v,l.push(b[a[e.uuid][0]])}else if(1==e.level){var _=a[e.uuid][0];void 0!==_&&$.each(a,function(e,t){var i=$.inArray(_,t);if(i>-1)return t.splice(i,1),!1}),n.splice(t,1);var C;$.each(o,function(t,i){if(i.uuid==e.uuid)return C=t,!1}),void 0!==C&&(o.splice(C,1),d--,t--)}}}n&&n[0]&&n[0].description.indexOf("Pinned Series")<0&&l.length>0?(n.unshift({chart_name:"",data:[],description:"Pinned Series",has_data:!1,level:0,pinned_name:"",precision:0,series_id:"",in_api:!1,units:"",indentLevel:0,isPinned:!0}),d++):o.length<1&&d<0&&(n.splice(0,1),d--),l.reverse(),$.each(l,function(e,t){n.splice(1,0,t),o.push(t),d++}),l.reverse();var y=1;$.each(l,function(e,t){t.uuid&&a[t.uuid].unshift(y++-d)}),0!=d&&$.each(a,function(e,t){$.each(t,function(e,i){(d>0||_<i)&&(t[e]=parseInt(i)+d)})}),this.setPinData(o)},updateChartData:function(){var t=this.facade.retrieveProxy(s.NAME),i=t.getChartType(),n=this.processChartData(i,!0);this.processPinData(),this.sendNotification(e.CHART_DATA_UPDATED,n)},getObjectLength:function(e){var t=0;return $.each(e,function(e,i){t++}),t},__classvars__:{NAME:"TableDataProxy",PROXY_URL:"dataService.cfc",PROXY_METHOD:"getData"}})}),define("js/Controller",["puremvc","page","js/model/ConfigProxy","js/model/RequestProxy","js/model/ParameterProxy","js/model/TableDataProxy","json2"],function(e,t,i,s,n,a){var r=e.SimpleCommand.$extend({execute:function(e){var i=e.getBody(),n=this.facade.retrieveProxy(s.NAME);t.errorHandler(i?{route:n?n.getData():null,notification:e.getType(),error:i.name+" "+i.message,stack:i.stack}:void 0,"errorService.cfc?method=logError")}}),o=e.SimpleCommand.$extend({execute:function(e){this.facade.retrieveProxy(s.NAME).setData(e.getBody())}}),l=e.SimpleCommand.$extend({execute:function(e){this.facade.retrieveProxy(n.NAME).update(e)}}),d=e.SimpleCommand.$extend({execute:function(){t.showLoadMask()}}),c=e.SimpleCommand.$extend({execute:function(e){t.hideLoadMask()}}),h=e.SimpleCommand.$extend({execute:function(e){var i=this.facade.retrieveProxy(n.NAME),s=e.getBody(),a=e.getType();if(void 0!==s.id&&""!=s.id||(s.id=i.getSelectedTable().id),a){var r=i.getGAString(s);"undefined"!=typeof _gaq?_gaq.push(["_trackEvent","AEO",a,r]):"undefined"!=typeof console&&"function"==typeof console.log&&console.log("_trackEvent : AEO : "+a+" : "+r)}t.setHash(i.getGAString(s))}}),u=e.SimpleCommand.$extend({execute:function(e){var t,i,s=this.facade.retrieveProxy(a.NAME),r=this.facade.retrieveProxy(n.NAME),o=e.getType();if(o){var l=r.getGAString({});"undefined"!=typeof _gaq?_gaq.push(["_trackEvent","AEO",o,l]):"undefined"!=typeof console&&"function"==typeof console.log&&console.log("_trackEvent : AEO : "+o+" : "+l)}var d=JSON.stringify(e.getBody()),c=d.replace(/<sup>/g,"").replace(/<\/sup>/g,"");t=$('<input type="hidden" name="csvArr"/>').val(c);var h=s.getTableTitle().replace(/,/g,"").replace(/\s+/g,"_");i=$('<input type="hidden" name="fileName"/>').val(h),jQuery('<form style="display:none;" action="'+this.$class.POST_URL+'" method="post"></form>').append(t).append(i).appendTo("body").submit().remove()},__classvars__:{POST_URL:"/global/scripts/jquery/highcharts/exporting-server/csv_exporter.php"}}),p=e.SimpleCommand.$extend({execute:function(e){window.open("/opendata/series.php?sdid="+e.getBody())}}),m=e.MacroCommand.$extend({initializeMacroCommand:function(){this.addSubCommand(d),this.addSubCommand(g)}}),g=e.SimpleCommand.$extend({execute:function(e){this.facade.retrieveProxy(a.NAME).loadTableData()}}),f=e.MacroCommand.$extend({initializeMacroCommand:function(){this.addSubCommand(h)}}),v=e.MacroCommand.$extend({initializeMacroCommand:function(){this.addSubCommand(h)}}),b=e.MacroCommand.$extend({initializeMacroCommand:function(){this.addSubCommand(_),this.addSubCommand(h)}}),_=e.SimpleCommand.$extend({execute:function(e){this.facade.retrieveProxy(n.NAME).resetStartEnd(e.body.f)}}),C=e.SimpleCommand.$extend({execute:function(e){var t=this.facade.retrieveProxy(n.NAME);"undefined"!=typeof body&&void 0!==body.newStudy&&void 0!==body.oldStudy&&body.newStudy==body.oldStudy||t.resetFrequency()}}),y=e.SimpleCommand.$extend({execute:function(e){var t=this.facade.retrieveProxy(n.NAME),i=e.getBody();void 0!==i&&void 0!==i.newStudy&&void 0!==i.oldStudy&&i.newStudy==i.oldStudy||t.resetCase()}}),T=e.SimpleCommand.$extend({execute:function(e){var t=this.facade.retrieveProxy(n.NAME);t.resetCharted(e.getType()),t.updateCharted(t.getUpdatedCharted(e.getBody(),e.getType()),e.getType())}}),w=e.SimpleCommand.$extend({execute:function(e){var t=this.facade.retrieveProxy(a.NAME);t.isUpdating||t.updateChartData()}}),A=e.SimpleCommand.$extend({execute:function(e){this.facade.retrieveProxy(n.NAME).resetCharted()}}),S=e.SimpleCommand.$extend({execute:function(e){this.facade.retrieveProxy(n.NAME).resetChartindexed()}}),x=e.SimpleCommand.$extend({execute:function(e){this.facade.retrieveProxy(n.NAME).resetRegion()}});return{ErrorCommand:r,UpdateRequestProxyCommand:o,UpdateParameterProxyCommand:l,
UpdateChartedCommand:T,UpdateChartDataCommand:w,ShowLoadMaskCommand:d,HideLoadMaskCommand:c,UpdateHashCommand:h,OpenAPIWindowCommand:p,ResetChartedCommand:A,ResetChartindexedCommand:S,ResetStartEndommand:_,OutputToCSVCommand:u,TableParamsUpdatedCommand:m,FrequencySelectionUpdatedCommand:b,TimeSelectionUpdatedCommand:f,RegionSelectionUpdatedCommand:v,ResetCaseCommand:y,UpdateDataProxyCommand:g,ResetRegionCommand:x,ResetFrequencyCommand:C}}),define("js/view/components/help.js",[],function(){return function(){return[{selector:"div#v1.pub_button",tip:"First, select a publication & table.",position:"bottomMiddle"},{selector:".chartIndexing:visible",tip:"These controls change the charting options. For time-series charts, you may index the chart to the first point by value or percent.",position:"topMiddle",xAdjust:-100,yAdjust:-5},{selector:"div#v2.pub_button",tip:"First, select a publication & table.",position:"leftMiddle"},{selector:"div#case_button",tip:"Second, you can optionally select cases and/or scenarios to compare.",position:"topMiddle",xAdjust:-80},{selector:"div#region_button",tip:"Third, you can optionally select a region (for tables with regional data)",position:"rightMiddle",xAdjust:-3,yAdjust:-3,width:225},{selector:"#help_button",tip:'<iframe width="230" height="200" src="https://www.youtube.com/embed/33ayOFVwdcw" frameborder="0" allowfullscreen=""></iframe>Play the short video to learn how to use this tool.  Click anywhere else to close these help tips.',position:"rightMiddle",xAdjust:153,yAdjust:-165},{selector:"#main_download_button",tip:'This menu provides options to download the table or graphic data in <span class="ico_csv">CSV</span> format, as well as an <span class="ico_img ico_pdf">image</span> or <span class="ico_pdf">PDF</span> of the graphic. You can also embed the graph with the <span class="ico_embed">EMBED</span> option.',position:"rightBottom",yAdjust:-20},{selector:"#time_selection_container",tip:"Use the Annual and Every 5th Year buttons buttons to adjust the level of granularity of the data. Use the slider controls to adjust the time span shown in the table below.",position:"bottomMiddle",xAdjust:-71},{selector:".linechart:first",tip:'Click on the <span class="ico linechart selected"></span>or <span class="ico map selected"></span>icons to visualize in the chart or map above.',position:"rightMiddle",xAdjust:260,yAdjust:185},{selector:".slick-header-column:last",tip:"This column shows the Compound Annual Growth Rate for all years available for each series.",position:"rightBottom",xAdjust:-80,yAdjust:-10,width:355},{selector:"#timeSliderContainer",tip:"Set the start and/or end year for the table and chart.",position:"bottomMiddle",xAdjust:0,yAdjust:-15,width:325},{selector:".pinkey_header",tip:'Use this menu to change the icons in this column. The <span class="ico sourcekey selected"></span>API icon provides a link to EIA\'s API for each series. The <span class="ico pin selected"></span>pin series icon allows you to preserve a series for comparison across data sets.',position:"leftBottom",yAdjust:-10},{selector:"#visualizationSelectorContainer",tip:'Use this menu to change the action associated with the icons in the table. The <span class="ico linechart selected"></span>time-series chart and <span class="ico map selected"></span>map selections change the type of graphic displayed above.',position:"leftMiddle",width:350,xAdjust:20,yAdjust:10},{selector:"div#animated_map_type_container",tip:"The map controls allow you to switch between coloring the states based on the current period value or the percent change from the previous period. You can also play the map over time or scroll to a specific period.",position:"rightMiddle",yAdjust:-10,width:275},{selector:".animated_map_button_container",tip:"Use this interface to play the map over time or scroll to a specific period.",position:"rightMiddle",width:275}]}}),define("js/model/HelpTooltipProxy",["puremvc","js/view/components/help.js"],function(e,t){return e.Proxy.$extend({__init__:function(){this.$super(this.$class.NAME,t)},getHelpTooltips:function(){return this.getData()()},__classvars__:{NAME:"HelpTooltipProxy"}})}),define("js/model/MapDataProxy",["js/Facade","js/model/DataProxy","js/model/ParameterProxy","js/model/ConfigProxy"],function(e,t,i,s){return t.$extend({__init__:function(){this.hasData=!1,this.$super(this.$class.NAME)},updateMapData:function(t){var n=this;if(t&&void 0!==t){var a=this.facade.retrieveProxy(i.NAME),r=a.getCaseNameById(t.uuid.split(".")[0]),o=(t.rowId,t.chart_name+": "+r),l=t.units,d=t.precision,c=(this.facade.retrieveProxy(s.NAME),a.getMapParamsString(t));c&&(c in this.cache?(this.data=this.cache[c],this.hasData=!0,this.sendNotification(e.MAP_DATA_UPDATED)):$.ajax(encodeURI("data/index.php"+c+"&type=mapData"),{dataType:"json",error:function(){n.sendNotification(e.ERROR)},success:function(t){o=o;for(var i in t.data)if(t.data.hasOwnProperty(i)){var s=t.data[i];for(var a in s)s.hasOwnProperty(a)&&isNaN(s[a])&&delete s[a]}n.data=n.cache[c]=$.extend(t,{title:o,units:l,precision:d}),n.hasData=!0,n.sendNotification(e.MAP_DATA_UPDATED)}}))}},__classvars__:{NAME:"MapDataProxy"}})}),define("js/view/components/DateCodeUtil",[],function(){return{months:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],parseDateCode:function(e,t){e=e.toString();var i,s,n=e.substring(0,4);switch(t.toUpperCase()){case"A":s=0;break;case"Q":s=3*(e.substring(4)-1);break;case"M":s=e.substring(4)-1}return void 0!==s&&(i=new Date(Date.UTC(n,s,1,0,0))),i},createDateCode:function(e,t){var i,s,n=e.getFullYear().toString();switch(t.toUpperCase()){case"A":s="";break;case"Q":s=Math.ceil((e.getMonth()+1)/3),s=s<10?"0"+s:s;break;case"M":s=e.getMonth()+1,s=s<10?"0"+s:s}return void 0!==s&&(i=n+""+s),i},formatDateCode:function(e,t){var i=e.toString().substring(0,4),s=e.toString().substring(4,6),n="";switch(t){case"A":n=i;break;case"Q":n="Q"+parseInt(s,10)+" "+i;break;case"M":n=this.months[parseInt(s,10)-1]+" "+i}return n},deincrementDateCode:function(e,t){return this.deincrementOrIncrementDateCode(e,t,!1)},incrementDateCode:function(e,t){return this.deincrementOrIncrementDateCode(e,t,!0)},deincrementOrIncrementDateCode:function(e,t,i){var s=this.parseDateCode(e,t);switch(t){case"A":s=new Date(s.getFullYear()+(i?1:-1),0);break;case"Q":s=new Date(s.getFullYear(),s.getMonth()+(i?3:-3));break;case"M":s=new Date(s.getFullYear(),s.getMonth()+(i?1:-1))}return this.createDateCode(s,t)},getNumberOfDataPoints:function(e,t,i){var s=0,n=this.parseDateCode(e,i),a=this.parseDateCode(t,i);switch(i){case"A":s=a.getFullYear()-n.getFullYear()+1;break;case"Q":s=4*(a.getFullYear()-n.getFullYear()+1)-n.getMonth()/3-(3-a.getMonth()/3);break;case"M":s=12*(a.getFullYear()-n.getFullYear()+1)-n.getMonth()-(11-a.getMonth())}return s}}}),define("js/view/components/GridFormatters",[],function(){return{nestedPropertyResolver:function(e,t){for(var i=e.split("."),s=t,n=0;n<i.length&&((s=s[i[n]])&&void 0!==s);n++);return s},descriptionFormatter:function(e,t,i,s,n){var a=n.indentLevel,r=n.levelGroups,o='<span class="description_wrapper '+(r?"level_group_"+a+"_"+r[a]:"")+'">',l='<span class="description_text_wrapper';"number"==typeof n.footnoteLineNumber&&(l+=" footnote"+n.footnoteLineNumber),l+=(void 0===a?" bold":"")+'"',n.chart_name&&(l+=' title="'+n.chart_name),l+='">';var d,c,h="";for(d=a;d>0;d--)c='<span class="description_spacer',(r&&void 0!==r[d]||d==a)&&(c+=" spacer_group_"+d+"_"+r[d]),d!=a?void 0!==r[d]?c+=" pre":c+=" blank":n.isLast?c+=" last":c+=" intermediate",c+='"></span>',h=c+h;var u="";return 1==n.has_data&&(u=" ("+n.units+")"),o+h+l+(i+u)+"</span></span>"},numericalDataFormatter:function(e,t,i,s,n){if(0==n.has_data)return"";var a=isNaN(parseFloat(i))?i:Highcharts.numberFormat(i,void 0!==s.precision?s.precision:void 0!==n.precision?n.precision:0,void 0,",");return void 0===a||""==a?"--":a},rseNumericalDataFormatter:function(e,t,i,s,n){},chartButtonFormatter:function(e,t,i,s,n){var a="ico",r="";if("map"===s.iconClass&&(!i||n.ACTION)||n.description.indexOf("Pinned Series")>=0)return"";if(n.ACTION)return a+=" remove",r="Click to clear chart",'<span class="'+a+'" title="'+r+'"></span>';if(a+=" "+s.iconClass,"map"==s.iconClass){if(!n.is_mappable)return"";n[s.iconClass]&&(a+=" selected"),r="Click to view a U.S. map of this series"}else n.has_data?n[s.iconClass]?(a+=" selected",r="Click to remove this series from the chart"):r="Click to add this series to the chart":(a+=" parent",n[s.iconClass]?(a+=" selected",r="Click to remove all child series from the chart"):r="Click to add all child series to the chart");return i||n.levelGroups?'<span class="'+a+'" title="'+r+'"></span>':""},pinSeriesFormatter:function(e,t,i,s,n){var a="ico",r="";if("sourcekey"==s.iconClass&&(!i||n.ACTION)||void 0===n[s.iconClass.toUpperCase()])return"";if(n.ACTION&&"pin"==s.iconClass)return a+=" remove",r="Click to remove all pinned series",'<span class="'+a+'" title="'+r+'"></span>';if(a+=" "+s.iconClass,"sourcekey"==s.iconClass)r="Click to view series in API Browser";else if(void 0!==i&&""!=i)n[s.iconClass.toUpperCase()]?(a+=" selected",r="Click to unpin this series"):r="Click to pin this series for comparison across data sets";else{if(a+=" parent",void 0===n[s.iconClass.toUpperCase()])return"";n[s.iconClass.toUpperCase()]?(a+=" selected",r="Click to unpin all child series"):r="Click to pin all child series for comparison across data sets"}return i||n.levelGroups?'<span class="'+a+'" title="'+r+'"></span>':""},sourceKeyFormatter:function(e,t,i,s,n){return(i||n.levelGroups)&&n.varName?'<span class="ico '+s.iconClass+(i?"":" parent")+(n[s.iconClass]?" selected":"")+'"></span>':""}}}),define("text!templates/main.html",[],function(){return'\x3c!-- This is the main Mustache template that the other templates build off of --\x3e\r\n<span id="selection_container"></span>\r\n<div class="carousel blue_top" id="chart_area"></div>\r\n\r\n<div id="middle_selections_container">\r\n\t\x3c!-- Button: PUBLICATIONS & TABLES --\x3e\r\n\t<div class="pub_button_container float_left">\r\n\t    <div id="v2" class="pub_button">\r\n\t        <span class="pub_button_text">Publications & Tables</span>\r\n\t    </div>\r\n\t</div>\r\n\r\n\t\x3c!-- Spacer between Publications & Tables button, and Cases & Scenarios button --\x3e\r\n\t<div style="float:left; padding-left:15px;"> </div>\r\n\r\n\t\x3c!-- Button: CASES/SCENARIOS --\x3e\r\n\t<div class="case_button_container float_left">\r\n\t    <div id="case_button" class="case_button">\r\n\t        <span class="case_button_text">Cases & Scenarios</span>\r\n\t    </div>\r\n\t</div>\r\n\r\n\t\x3c!-- Spacing --\x3e\r\n\t<div style="float:left; padding-left:15px;"> </div>\r\n\r\n\t\x3c!-- Button: REGIONS --\x3e\r\n\t<div class="region_button_container float_left">\r\n\t\t<div id="region_button" class="region_button">\r\n\t        <span class="region_button_text">Regions</span>\r\n\t    </div>\r\n\t</div>\r\n\r\n\t\x3c!-- Button: DOWNLOAD --\x3e\r\n\t<div id="download_dialog_wrap">\r\n\t\t<div id="download_dialog_container">\r\n\t\t\t{{#overlayDownloadButtonOpts}}\r\n\t\t\t\t{{>download_button}}\r\n\t\t\t{{/overlayDownloadButtonOpts}}\r\n\t\t\t<div id="download_dialog"></div>\r\n\t\t</div>\r\n\t</div>\r\n\t{{#mainDownloadButtonOpts}}\r\n\t\t {{>download_button}}\r\n\t{{/mainDownloadButtonOpts}}\r\n\r\n\t\x3c!-- Button: HELP --\x3e\r\n\t<div id="help_button" class="help_button">\r\n\t\t<span class="help_icon"> </span><span class="help_button_text">Help</span>\r\n\t</div>\r\n</div>\r\n\r\n\x3c!-- Chart/Map controls will be inserted here --\x3e\r\n<div id="controls_container" class="grey_side ltblue">\r\n\t\x3c!-- Retain in case we add periodicity other than annual in the future:\r\n\t<div id="frequency_container"></div>\r\n\t--\x3e\r\n\t\x3c!-- Time slider will be inserted here --\x3e\r\n\t<div id="time_selection_container"></div>\r\n</div>\r\n<div class="clear"></div>\r\n\r\n\x3c!-- Data table will be inserted here --\x3e\r\n<div id="tableContainer"></div>\r\n<div class="clear"></div>\r\n\r\n<div id="footnote_container"></div>\r\n\r\n\x3c!-- Publications/Tables modal dialog will be inserted here, and positioned based on which of the two buttons is clicked --\x3e\r\n<div id="pubstables_dialog_wrap">\r\n\t<div id="pubstables_dialog_container">\r\n\t\t<div id="pubstables_dialog"></div>\r\n\t</div>\r\n</div>\r\n\r\n\x3c!-- Cases/Scenarios modal dialog will be inserted here --\x3e\r\n<div id="cases_dialog_wrap">\r\n\t<div id="cases_dialog_container">\r\n\t\t<div id="cases_dialog"></div>\r\n\t</div>\r\n</div>\r\n\r\n\x3c!-- Regions modal dialog will be inserted here --\x3e\r\n<div id="regions_dialog_wrap">\r\n\t<div id="regions_dialog_container">\r\n\t\t<div id="regions_dialog"></div>\r\n\t</div>\r\n</div>\r\n'}),define("text!templates/download_button.html",[],function(){return'\x3c!-- This Mustache template displays the Download button  --\x3e\r\n<div\r\n\t{{#id}}\r\n\t\tid="{{id}}"\r\n\t{{/id}}\r\n\tclass="download_button\r\n\t\t{{#selected}}\r\n\t\t\tselected\r\n\t\t{{/selected}}\r\n\t"\r\n>\r\n\t<span class="download_icon"> </span><span class="download_button_text">Download</span>\r\n</div>'}),define("js/view/components/PageLayout",["classy","text!templates/main.html","text!templates/download_button.html","mustache"],function(e,t,i){return e.$extend({container:null,__init__:function(e,s){this.container=e,this.container.empty().html(Mustache.render(t,s,{download_button:i}))},getSelectionContainer:function(){return $("#selection_container",this.container)},getCaseSelectionContainer:function(){return $("#case_container",this.container)},getRegionSelectionContainer:function(){return $("#region_container",this.container)},getTimeSelectionContainer:function(){return $("#time_selection_container",this.container)},getChartContainer:function(){return $("#chart_area",this.container)},getTableContainer:function(){return $("#tableContainer",this.container)},getDownloadContainer:function(){return $("#download_dialog",this.container)},getFootnoteContainer:function(){return $("#footnote_container",this.container)}})}),define("text!templates/pubstables_selection.html",[],function(){return'\x3c!-- This Mustache template is used to build the Publications & Tables modal dialog --\x3e\r\n<div class="inner_container ltblue grey_side blue_side_border" id="selection_titles_container">\r\n    {{#selectedStudy}}\r\n    <h1 id="study_title">{{name}}</h1>\r\n    {{/selectedStudy}}\r\n    {{#selectedTable}}\r\n    <h2 id="table_title">Table: {{description}}</h2>  \r\n    {{/selectedTable}}\r\n\r\n    <div id="subtitle_mid" style="font-size:15px;font-style:italic;">\r\n        <span id="subtitle_case"></span>\r\n        <span id="subtitle_region"></span>\r\n    </div>\r\n\r\n</div>\r\n<div id="blue_arrow">\r\n    <div id="shaft"></div>\r\n    <div id="head"></div>\r\n</div>\r\n<div class="pub_button_container">\r\n    <div id="v1" class="pub_button">\r\n        <span class="pub_button_text">Publications & Tables</span>\r\n    </div>\r\n</div>\r\n<div class="clear"></div>\r\n\x3c!-- NOTE: The modal dialog was moved to publications_tables_template.html --\x3e\r\n\r\n<style>\r\n/* NOTE: CAN THE FOLLOWING BE APPLIED TO BOTH TABLE_ITEM AND CASE_ITEM IN MAIN.LESS? */\r\n.table_item {\r\n    padding: 2px 8px;\r\n    margin-bottom: 5px;\r\n    line-height: 15px;\r\n}\r\n.table_item.selected {\r\n    background-color: #189bd7; \r\n    color: #fff;\r\n}\r\n.table_item:hover{\r\n    text-decoration: none;\r\n    background-color: #189bd7; \r\n    color: #fff;\r\n    cursor: pointer;\r\n}\r\n</style>\r\n'}),define("text!templates/publications.html",[],function(){return'\x3c!--- NOTE: Currently all the CSS for this template is in selection.html, and needs to be moved to main.css --\x3e\r\n<div id="table_select" class="blue_top" style="display:block">\x3c!-- NOTE: This was hidden initially, and faded in with jQuery --\x3e\r\n    <div id="table_select_inner">\r\n        <div id="table_select_cancel"><span>CANCEL</span><div> </div></div>\r\n        <div id="table_select_left">\r\n            <div class="table_select_title">Publications</div>\r\n            <div class="pubs_tables_scroller ui-slider ui-slider-vertical ui-widget ui-widget-content ui-corner-all" aria-disabled="false">\r\n                <a class="ui-slider-handle ui-state-default ui-corner-all" href="#" style="bottom: 0%;"></a>\r\n            </div>\r\n            <div class=\'scrollable_list\'>\r\n            {{#studies}}\r\n                <div class="pub_item" value="{{id}}">{{name}}</div>\r\n            {{/studies}}\r\n            </div>\r\n        </div>\r\n        <div id="table_select_right">\r\n            <div class="table_select_title">\r\n                Tables\r\n                <div id="sort-options">Browse: \r\n                    <span id="bysubject">By Subject</span> |\r\n                    <span id="alltables">All Tables</span>\r\n                </div>\r\n            </div>\r\n\r\n            <div>\r\n                <input type="text" id="tableFilter" placeholder="search for a table">\r\n            </div>\r\n            <div id="search-button"></div>\r\n\r\n            <div class="pubs_tables_scroller ui-slider ui-slider-vertical ui-widget ui-widget-content ui-corner-all" aria-disabled="false">\r\n                <a class="ui-slider-handle ui-state-default ui-corner-all" href="#" style="bottom: 0%;"></a>\r\n            </div>\r\n            <div class=\'scrollable_list\'>\r\n            </div>\r\n        </div>\r\n    </div>\r\n</div>\r\n'}),define("text!templates/tables.html",[],function(){return'\x3c!-- This Mustache template displays each data table --\x3e\r\n{{#tables}}<div id="{{id}}" class="table_item">{{description}}</div>{{/tables}}'}),define("js/view/components/Selection",["classy","signals","text!templates/pubstables_selection.html","text!templates/publications.html","text!templates/tables.html","mustache","simpleModal","json2"],function(e,t,i,s,n){return e.$extend({viewSelect:null,lastTab:null,tableSelectionChanged:null,__init__:function(e){this.container=e,this.tableSelectionChanged=new t.Signal},create:function(e,t,i){this.updateTableSelection(e,t,i)},updateTableSelection:function(e,t,s){var n=this;this.selectedStudy=e,this.studies=t,this.selectedTable=s,this.container.html(Mustache.render(i,{selectedStudy:this.selectedStudy,selectedTable:this.selectedTable})),$(".pub_button").off("click").on("click",function(e){n.openPubsTablesDialog($(this))})},openPubsTablesDialog:function(e){function t(e){var i=$(e.data);return e.data!=e.target?i.data("open")?(i.css("width",i.data("originalWidth")),i.data("open",!1)):i.data("open",!0):setTimeout(function(){i.data("open")?(i.css("width",i.data("originalWidth")),i.data("open",!1)):i.data("open",!0)},100),"function"==typeof t&&$("body").unbind("mouseup",t),!0}var i=this;this.buttonObject=e;var n=$(Mustache.to_html(s,{selectedStudy:i.selectedStudy,selectedTable:i.selectedTable,studies:i.studies})),a=$("div#pubstables_dialog");a.empty(),a.append(n),this.pubsTablesDialogContainer=$("div#pubstables_dialog_container");var r=this.pubsTablesDialogContainer.parent();this.pubsTablesDialogContainer.appendTo("body").css({position:"absolute",display:"block",left:-9999,top:-9999});var o=this.pubsTablesDialogContainer.height();this.pubsTablesDialogContainer.appendTo(r).css({position:"relative",left:0,top:0}),this.pubsTablesDialogContainer.modal({autoPosition:!1,overlayClose:!0,fixed:!1,persist:!0,minHeight:o,maxHeight:o,close:!1,onClose:function(){i.pubsTablesDialogContainer.find(".pub_button").remove(),$(window).off("resize.selection"),$.modal.close()}}),e.clone().prependTo(this.pubsTablesDialogContainer),this.pubsTablesDialogContainer.find(".pub_button").addClass("selected"),this.positionPubsTablesDialog(),$(window).on("resize.selection",this.resizeCallback=function(){i.positionPubsTablesDialog()});var l=$(window).height(),d=$("div#simplemodal-container").position().top+$("#simplemodal-container").height(),c=$("div#table_select").height(),h=$("body").scrollTop(),u=d-l+c+10;h<u&&$("html, body").animate({scrollTop:u},600,"swing",function(){});var p=$("#table_select_left").find(".scrollable_list").children();p.disableSelection();for(var m=($("#table_select_cancel").on("click",function(e){$.modal.close()}),0);m<p.length;m++)$(p[m]).attr("value")==this.selectedStudy.id&&$(p[m]).addClass("selected");if($(p).on("click",function(e){$("#tableFilter").val(""),i.publicationSelected($(this))}),$("#table_select").find(".scrollable_list").bind("scroll",function(){$(this).siblings(".pubs_tables_scroller").slider("value",this.scrollHeight-this.offsetHeight==0?100:100-100*this.scrollTop/(this.scrollHeight-this.offsetHeight))}),$(".pubs_tables_scroller").each(function(){ele=$(this),ele.slider({orientation:"vertical",min:0,max:100,value:100,slide:function(e,t){(function(){this.scrollTop=(this.scrollHeight-this.offsetHeight)*((100-t.value)/100)}).call($(t.handle).parent().siblings(".scrollable_list").get(0))}}).mousedown(function(e){$.browser.msie&&e.stopPropagation()})}),"Microsoft Internet Explorer"==navigator.appName){var g=navigator.userAgent;null!=new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})").exec(g)&&(rv=parseFloat(RegExp.$1),rv<9&&this.container.find("select").each(function(){var e=$(this);e.css("min-width",e.width()),e.data("originalWidth",e.width())}).bind("mousedown",function(e){var i=$(this),s=$(this).clone();return s.css("width","auto"),i.parent().append(s.css("visible","false")),s.width()>i.width()&&i.css("width","auto"),s.remove(),i.css("position","relative"),$("body").bind("mouseup",this,t),!0}).bind("change blur",function(e){var t=$(this);return t.css("width",t.data("originalWidth")),t.data("open",!1),!0}))}"alltables"!=i.lastTab?this.generateTablesList(this.selectedStudy,"bysubject",!1):this.generateTablesList(this.selectedStudy,"alltables",!1),$("span#alltables a").on("click",function(e){i.lastTab="alltables",i.generateTablesList(i.selectedStudy,"alltables",!1),$("span#alltables").addClass("selected"),$("span#bysubject").removeClass("selected"),i.checkScrollbar()}),$("span#bysubject a").on("click",function(e){i.lastTab="bysubject",i.generateTablesList(i.selectedStudy,"bysubject",!1),$("span#bysubject").addClass("selected"),$("span#alltables").removeClass("selected"),i.checkScrollbar()})},positionPubsTablesDialog:function(){var e=this.buttonObject.offset();if("v1"==this.buttonObject.attr("id"))xPos=e.left+this.buttonObject.width()-$("#table_select").width()+4,this.pubsTablesDialogContainer.find(".pub_button").css({position:"relative",left:$("#table_select").width()-this.buttonObject.width()-4});else{if("v2"!=this.buttonObject.attr("id"))return void alert("ERROR: id= "+this.buttonObject.attr("id"));xPos=e.left}$("#simplemodal-container").css({top:e.top,left:xPos})},publicationSelected:function(e){var t=this;this.selectedStudy=this.getStudyById(e.attr("value")),e.siblings().removeClass("selected"),e.addClass("selected"),this.table_list.fadeOut(200,function(){t.generateTablesList(t.selectedStudy,"bysubject",!0),$("span#alltables").removeClass("selected"),$("span#bysubject").addClass("selected")}).fadeIn(200,function(){t.checkScrollbar()}),$("#table_select_right .scrollable_list").prop("scrollTop",0)},getStudyById:function(e){for(var t=0;t<this.studies.length;t++)if(this.studies[t].id==e)return this.studies[t]},generateTablesList:function(e,t,i){var s=this;this.table_list=$("#table_select_right").find(".scrollable_list");var a=s.selectedTable.id;if(i)for(oneTable=0;oneTable<e.tables.length;oneTable++)if(1==e.tables[oneTable].default_table){var a=e.tables[oneTable].id;break}if("alltables"==t){$("#alltables").addClass("selected"),$("#table_select_right").toggleClass("all_tables",!0),$("#tableFilter").show(),$("#search-button").show();var r=e.subjects[0].tables;this.table_list.html(Mustache.render(n,{tables:r})),$("#search-button").css({position:"absolute",height:"16px",width:"16px",background:"url('/global/images/sprites/gc_sprite.png') no-repeat -316px -245px","margin-left":"167px","margin-top":"-22px"}),$("#tableFilter").keyup(function(e){$("#tableFilter").parent().parent().find(".table_item").each(function(e,t){$(t).html().toUpperCase().indexOf($("#tableFilter").val().toUpperCase())>=0?$(t).show():$(t).hide()})}),this.table_list.children().each(function(){$(this)[0].id==a&&$(this).addClass("selected")}),this.table_list.children().on("click",function(e){$.modal.close(),s.tableSelectionChanged.dispatch(this.id),$("#tableContainer div.slick-pane.slick-pane-top.slick-pane-right > div.slick-viewport.slick-viewport-top.slick-viewport-right").prop("scrollTop",0)})}else if("bysubject"==t){$("#bysubject").addClass("selected"),$("#table_select_right").toggleClass("all_tables",!1),$("#tableFilter").hide(),$("#search-button").hide();var o=e.subjects;for(oneSubject=0;oneSubject<o.length;oneSubject++){var l=o[oneSubject];for(oneSubjectTable=0;oneSubjectTable<l.tables.length;oneSubjectTable++)for(oneTable=0;oneTable<e.tables.length;oneTable++)e.tables[oneTable].id!=l.tables[oneSubjectTable]||(l.tables[oneSubjectTable]=e.tables[oneTable])}theSubjects=$.grep(e.subjects,function(e,t){return"All Tables"!=e.name}),this.table_list.html('<ul class="tablesTree">'+Mustache.render('{{#subjects}}<li id="{{id}}" class="subjectItem"><img src="css/images/img_trans.gif" class="accordion-open" height="10" width="10">{{name}}<ul class="menuHide">{{#tables}}<li class="table_item" id="{{id}}">{{description}}</li>{{/tables}}</ul></li>{{/subjects}}',{subjects:theSubjects})+"</ul>"),$("li.subjectItem").disableSelection(),$("li.subjectItem li.table_item").each(function(){$(this)[0].id==a&&$(this).addClass("selected")});var d=$("div#table_select_right li.table_item.selected").parent();d.show(),s.checkScrollbar(),d.prev().removeClass("accordion-open").addClass("accordion-close"),$("li.subjectItem").on("click",function(e){var t=$(this),i=$(this).find("img");if(i.hasClass("accordion-open")){var n=t.offset().top-t.parent().offset().top,a=$("#table_select_right .scrollable_list").height(),r=1-n/a;i.parent().children("ul").stop().slideDown(400*r,"swing",function(){$("#table_select_right .scrollable_list").prop("scrollTop",n),s.checkScrollbar()}),i.removeClass("accordion-open"),i.addClass("accordion-close")}else i.hasClass("accordion-close")&&(i.parent().children("ul").stop().slideUp(400,"swing",function(){s.checkScrollbar()}),i.removeClass("accordion-close"),i.addClass("accordion-open"))}),$("li.table_item").on("click",function(e){$.modal.close(),s.tableSelectionChanged.dispatch(this.id),$("#tableContainer div.slick-pane.slick-pane-top.slick-pane-right > div.slick-viewport.slick-viewport-top.slick-viewport-right").prop("scrollTop",0)})}else alert("ERROR: No handler for sortBy= "+t)},checkScrollbar:function(){var e=$("div#table_select_right .scrollable_list"),t=$("#table_select_right .pubs_tables_scroller");e.innerHeight()==e.get(0).scrollHeight?t.slider("option","disabled",!0):t.slider("option","disabled",!1)}})}),define("dateCodeUtils",[],{months:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],parseDateCode:function(e,t){e=e.toString();var i,s,n=e.substring(0,4);switch(t.toUpperCase()){case"A":s=0;break;case"Q":s=3*(e.substring(4)-1);break;case"M":s=e.substring(4)-1}return void 0!==s&&(i=new Date(n,s)),i},createDateCode:function(e,t){var i,s,n=e.getFullYear().toString();switch(t.toUpperCase()){case"A":s="";break;case"Q":s=Math.ceil((e.getMonth()+1)/3),s=s<10?"0"+s:s;break;case"M":s=e.getMonth()+1,s=s<10?"0"+s:s}return void 0!==s&&(i=n+""+s),i},formatDateCode:function(e,t){var i=e.toString().substring(0,4),s=e.toString().substring(4,6),n="";switch(t){case"A":n=i;break;case"Q":n="Q"+parseInt(s,10)+" "+i;break;case"M":n=this.months[parseInt(s,10)-1]+" "+i}return n},deincrementDateCode:function(e,t){return this.deincrementOrIncrementDateCode(e,t,!1)},incrementDateCode:function(e,t){return this.deincrementOrIncrementDateCode(e,t,!0)},deincrementOrIncrementDateCode:function(e,t,i){var s=this.parseDateCode(e,t);switch(t){case"A":s=new Date(s.getFullYear()+(i?1:-1),0);break;case"Q":s=new Date(s.getFullYear(),s.getMonth()+(i?3:-3));break;case"M":s=new Date(s.getFullYear(),s.getMonth()+(i?1:-1))}return this.createDateCode(s,t)}}),define("text-time_slider.html",[],function(){return'<div id="timeSliderContainer">\r\n\t<div class="labelContainer"></div>\r\n\t<div class="timeSlider{{#selectDateRange}} range{{/selectDateRange}}"></div>\r\n</div>'}),define("timeSlider",["signals","classy","text-time_slider.html","dateCodeUtils","mustache"],function(e,t,i,s){return t.$extend({sliderType:null,timeSelectionChanged:null,suppressSignals:!1,isCreated:!1,timeSlider:null,lowLabel:null,highLabel:null,lowHandle:null,highHandle:null,values:null,highVal:null,lowVal:null,freq:null,__init__:function(t){this.container=t,this.timeSelectionChanged=new e.Signal},create:function(e,t,s,n,a){this.freq=t.toUpperCase(),this.values=s,this.lowVal=n,this.highVal=a,this.container.html(Mustache.render(i,e)),this.timeSlider=$(".timeSlider",this.container),this.sliderType=this.timeSlider.hasClass("range")?this.$class.RANGE_SLIDER:this.$class.SINGLE_SLIDER,this.createSlider(),this.isCreated=!0,this.updateTimeSelection(t,s,n,a)},createSlider:function(){var e,t,i,s=this;switch(this.sliderType){case this.$class.RANGE_SLIDER:e=function(e,t){return!(t.values[0]>=t.values[1]||t.values[0]<0||t.values[0]>s.values.length||t.values[1]<0||t.values[1]>s.values.length)&&(s.lowVal=s.values[t.values[0]],s.highVal=s.values[t.values[1]],s.updateLabel(!0),s.updateLabel(!1),!0)},t=function(e,t){s.lowVal=t.values[0]<0||t.values[0]>s.values.length?s.values[0]:s.values[t.values[0]],s.highVal=t.values[1]<0||t.values[1]>s.values.length?s.values[s.values.length-1]:s.values[t.values[1]],s.updateLabel(!0),s.updateLabel(!1),s.suppressSignals||s.timeSelectionChanged.dispatch(s.lowVal,s.highVal)},i=!0;break;case this.$class.SINGLE_SLIDER:e=function(e,t){return s.lowVal=s.values[t.value],s.updateLabel(!0),!0},t=function(e,t){s.lowVal=s.values[t.value],s.updateLabel(!0),s.suppressSignals||s.timeSelectionChanged.dispatch(s.lowVal)},i=!1}this.timeSlider.slider({orientation:"horizontal",slide:e,change:t,range:i});var n=this.timeSlider.children(".ui-slider-handle");switch(this.lowHandle=n.eq(0),this.highHandle=n.eq(1),this.lowLabel=$('<div class="time_slider_tooltip"></div>').append("<span/>").css({position:"absolute"}),this.sliderType===this.$class.SINGLE_SLIDER?this.lowLabel.appendTo(this.lowHandle):(this.highLabel=$('<div class="time_slider_tooltip"></div>').append("<span/>"),this.lowLabel.appendTo(this.timeSlider),this.highLabel.appendTo(this.timeSlider),this.lowLabel.css({left:0}),this.highLabel.css({position:"absolute"})),this.updateLabel(!0),this.updateLabel(!1),this.sliderType){case this.$class.RANGE_SLIDER:this.lowHandle.add(this.highHandle).addClass("dual_slider_handle");break;case this.$class.SINGLE_SLIDER:this.lowHandle.addClass("single_slider_handle")}},updateTimeSelection:function(e,t,i,s){this.suppressSignals=!0,this.values=t,this.freq=e,this.lowVal=i,this.highVal=s,this.updateTimeSlider(),this.suppressSignals=!1},updateLabel:function(e){var t=e?this.lowLabel:this.highLabel;if(t&&t.length>0){var i=e?this.lowVal:this.highVal,s=e?this.lowHandle:this.highHandle,n=t.find("span");n.text(this.formatLabel(i)),this.sliderType===this.$class.SINGLE_SLIDER?t.css({left:-.5*n.width()+.5*s.width()}):e||t.css({left:this.timeSlider.width()-n.width()})}},updateTimeSlider:function(){switch(this.timeSlider.slider("option",{min:0,max:this.values.length-1}),this.sliderType){case this.$class.RANGE_SLIDER:this.timeSlider.slider("option",{values:[$.inArray(this.lowVal,this.values),$.inArray(this.highVal,this.values)]});break;case this.$class.SINGLE_SLIDER:this.timeSlider.slider("option",{value:$.inArray(this.lowVal,this.values)})}},formatLabel:function(e){
return s.formatDateCode(e,this.freq)},__classvars__:{RANGE_SLIDER:"rangeSlider",SINGLE_SLIDER:"singleSlider"}})}),define("text!templates/time_selector.html",[],function(){return'\x3c!-- This Mustache template displays the Map Type buttons, Periodicity buttons, and Time Slider --\x3e\r\n<div id="visualizationSelectorContainer">\r\n\t<input type="radio" name="vizSelectorGroup" value="linechart" id="timeseriesbutton"/><label for="timeseriesbutton"><span class="ico linechart"></span>Time-series</label>\r\n\t<input type="radio" name="vizSelectorGroup" value="map" id="mapbutton"/><label for="mapbutton"><span class="ico map"></span>Map</label>\r\n</div>\r\n<div id="frequencySelectorContainer">\r\n\t<div class="labelContainer"></div>\r\n\t<input type="radio" name="freqSelectorGroup" value="A" id="annual"/><label for="annual">Annual</label>\r\n\t<input type="radio" name="freqSelectorGroup" value="Q" id="quinquennial"/><label for="quinquennial">Every 5th Year</label>\r\n</div>\r\n<div id="timeSliderContainer">\r\n\t<div class="labelContainer"></div>\r\n\t<div class="timeSlider range"></div>\r\n</div>\r\n'}),define("js/view/components/TimeSelection",["timeSlider","signals","text!templates/time_selector.html"],function(e,t,i){return e.$extend({visualizationSelectionChanged:null,frequencySelectionChanged:null,vizSelectors:null,freqSelectors:null,isCreated:!1,__init__:function(e){this.$super(e),this.visualizationSelectionChanged=new t.Signal,this.frequencySelectionChanged=new t.Signal},create:function(e,t,s,n,a,r){var o=this;this.freq=t,this.values=s,this.lowVal=n,this.highVal=a,this.container.html(Mustache.render(i,e)),$("#visualizationSelectorContainer",this.container).buttonset(),this.vizSelectors=$("input:radio[name=vizSelectorGroup]",this.container),this.vizSelectors.change(function(){o.suppressSignals||o.visualizationSelectionChanged.dispatch(o.vizSelectors.filter(":checked").val())}),$("#frequencySelectorContainer",this.container).buttonset(),this.freqSelectors=$("input:radio[name=freqSelectorGroup]",this.container),this.freqSelectors.change(function(){o.suppressSignals||o.frequencySelectionChanged.dispatch(o.freqSelectors.filter(":checked").val())}),this.timeSlider=$(".timeSlider",this.container),this.sliderType=this.timeSlider.hasClass("range")?this.$class.RANGE_SLIDER:this.$class.SINGLE_SLIDER,this.createSlider(),this.isCreated=!0,this.updateTimeSelection(t,s,n,a,r)},updateTimeSelection:function(e,t,i,s,n){this.$super("A",t,i,s),this.suppressSignals=!0,this.updateFreqSelectors(e),this.updateVizSelectors(n),this.suppressSignals=!1},updateFreqSelectors:function(e){this.freqSelectors.filter("[value="+e+"]").prop("checked",!0),$("#frequencySelectorContainer",this.container).buttonset("refresh")},updateVizSelectors:function(e){this.vizSelectors.filter("[value="+e+"]").prop("checked",!0),$("#visualizationSelectorContainer",this.container).buttonset("refresh")},disableMapButton:function(e){"mapbutton"==$("#visualizationSelectorContainer input:checked").attr("id")&&e&&$("input#timeseriesbutton").attr("checked",!0),$("input#mapbutton",this.container).button({disabled:e})}})}),define("text!templates/case_selection.html",[],function(){return'\x3c!-- This Mustache template displays the Cases/Scenarios modal dialog --\x3e\r\n<div id="case_select" class="blue_top">\r\n    <div id="case_select_inner">\r\n        <div id="case_select_controls">\r\n            <div id="case_select_cancel"><span>CANCEL</span><div> </div></div>\r\n            <div id="case_select_submit"><span>SUBMIT</span><div> </div></div>    \r\n        </div>\r\n        <div id="cases_options"><span id="cases_selected"></span>   |   <a id="reset" href="javascript:void(0);">reset to default</a></div>\r\n\r\n        <div class="filter_tree_scroller ui-slider ui-slider-vertical ui-widget ui-widget-content ui-corner-all" aria-disabled="false">\r\n            <a class="ui-slider-handle ui-state-default ui-corner-all" href="#" style="bottom: 0%;"></a>\r\n        </div>\r\n        <div class=\'scrollable_list\'>\r\n        {{#cases}}\r\n            <div class="case_item" alt="{{long_description}}" title="{{long_description}}">\r\n                <img src="css/images/img_trans.gif" height="1" width="1" value="{{scenario}}" class="checkBox">\r\n                <span>{{description}}</span>\r\n            </div>\r\n        {{/cases}}\r\n        </div>\r\n        <div class="clear"></div>\r\n        <div id="cases_warning" style=""></div>\r\n    </div>\r\n</div>\r\n'}),define("js/view/components/CaseSelection",["classy","signals","text!templates/case_selection.html","mustache","simpleModal","json2"],function(e,t,i){return e.$extend({viewSelect:null,caseSelectionChanged:null,__init__:function(e){this.container=e,this.caseSelectionChanged=new t.Signal,this.maxCases=3},create:function(e,t,i,s){var n=this;$("#case_button").off("click").on("click",function(){n.openCasesScenariosDialog($(this))})},updateCaseSubtitle:function(e,t,i,s){var n="";if(this.selectedStudy=e,this.selectedTable=i,this.selectedCases=s,this.selectedCases.length>1)n="Multiple Cases";else for(var a=0;a<this.selectedStudy.cases.length;a++)if(this.selectedStudy.cases[a].scenario==this.selectedCases[0]){n=this.selectedStudy.cases[a].description;break}$("#subtitle_case").html("Case: "+n)},openCasesScenariosDialog:function(e){function t(e){var i=$(e.data);return e.data!=e.target?i.data("open")?(i.css("width",i.data("originalWidth")),i.data("open",!1)):i.data("open",!0):setTimeout(function(){i.data("open")?(i.css("width",i.data("originalWidth")),i.data("open",!1)):i.data("open",!0)},100),"function"==typeof t&&$("body").unbind("mouseup",t),!0}var s=this;this.buttonObject=e;var n=$(Mustache.to_html(i,{cases:s.selectedStudy.cases})),a=$("div#cases_dialog");a.empty(),a.append(n),this.casesDialogContainer=$("div#cases_dialog_container");var r=this.casesDialogContainer.parent();this.casesDialogContainer.appendTo("body").css({position:"absolute",display:"block",left:-9999,top:-9999});var o=this.casesDialogContainer.height();this.casesDialogContainer.appendTo(r).css({position:"relative",left:0,top:0}),this.casesDialogContainer.modal({autoPosition:!1,overlayClose:!0,fixed:!1,persist:!0,minHeight:o,maxHeight:o,close:!1,onClose:function(){s.casesDialogContainer.find(".case_button").remove(),$(window).off("resize.caseselection"),$.modal.close()}}),e.clone().prependTo(this.casesDialogContainer),this.casesDialogContainer.find(".case_button").addClass("selected"),this.positionCasesScenariosDialog(),$(window).on("resize.caseselection",this.resizeCallback=function(){s.positionCasesScenariosDialog()});var l=$(window).height(),d=$("div#simplemodal-container").position().top+$("#simplemodal-container").height(),c=$("div#case_select").height(),h=$("body").scrollTop(),u=d-l+c+10;h<u&&$("html, body").animate({scrollTop:u},600,"swing",function(){});var p=$("#case_select_inner").find(".scrollable_list").children();p.disableSelection();$("#case_select_cancel").on("click",function(){$.modal.close()});this.checkboxes=p.children("img"),this.numSelected=0;for(var m=0;m<this.checkboxes.length;m++)-1!=$.inArray($(this.checkboxes[m]).attr("value"),this.selectedCases)?($(this.checkboxes[m]).addClass("checked"),this.numSelected++):$(this.checkboxes[m]).addClass("unchecked");this.updateCasesSelected(),p.on("click",function(){thisCheckbox=$(this).children("img"),thisCheckbox.hasClass("checked")?(thisCheckbox.removeClass("checked"),thisCheckbox.addClass("unchecked"),s.numSelected--):(thisCheckbox.removeClass("unchecked"),thisCheckbox.addClass("checked"),s.numSelected++),s.updateCasesSelected()});$("#case_select_submit").on("click",function(){for(var e=[],t=0;t<s.checkboxes.length;t++)$(s.checkboxes[t]).hasClass("checked")&&e.push($(s.checkboxes[t]).attr("value"));s.caseSelectionChanged.dispatch(e.join("~")),$.modal.close()}),$("a#reset").on("click",function(){for(var e=0;e<s.checkboxes.length;e++)0==e?($(s.checkboxes[e]).removeClass("unchecked"),$(s.checkboxes[e]).addClass("checked")):($(s.checkboxes[e]).removeClass("checked"),$(s.checkboxes[e]).addClass("unchecked"));s.numSelected=1,s.updateCasesSelected()});if($("#case_select").find(".scrollable_list").bind("scroll",function(){$(this).siblings(".filter_tree_scroller").slider("value",this.scrollHeight-this.offsetHeight==0?100:100-100*this.scrollTop/(this.scrollHeight-this.offsetHeight))}),$(".filter_tree_scroller").each(function(){ele=$(this),ele.slider({orientation:"vertical",min:0,max:100,value:100,slide:function(e,t){(function(){this.scrollTop=(this.scrollHeight-this.offsetHeight)*((100-t.value)/100)}).call($(t.handle).parent().siblings(".scrollable_list").get(0))}}).mousedown(function(e){$.browser.msie&&e.stopPropagation()});var e=ele.siblings(".scrollable_list");e.innerHeight()==e.get(0).scrollHeight&&ele.slider("option","disabled",!0)}),"Microsoft Internet Explorer"==navigator.appName){var g=navigator.userAgent;null!=new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})").exec(g)&&(rv=parseFloat(RegExp.$1),rv<9&&this.container.find("select").each(function(){var e=$(this);e.css("min-width",e.width()),e.data("originalWidth",e.width())}).bind("mousedown",function(e){var i=$(this),s=$(this).clone();return s.css("width","auto"),i.parent().append(s.css("visible","false")),s.width()>i.width()&&i.css("width","auto"),s.remove(),i.css("position","relative"),$("body").bind("mouseup",this,t),!0}).bind("change blur",function(e){var t=$(this);return t.css("width",t.data("originalWidth")),t.data("open",!1),!0}))}},positionCasesScenariosDialog:function(){buttonOffset=this.buttonObject.offset(),$("#simplemodal-container").css({top:buttonOffset.top,left:buttonOffset.left})},updateCasesSelected:function(){$("span#cases_selected").html(this.numSelected.toString()+" selected"),$("span#cases_selected").css("color","green"),$("span#cases_selected").css("font-weight","normal")}})}),define("text!templates/region_selection.html",[],function(){return'\x3c!-- This Mustache template displays the Regions modal dialog  --\x3e\r\n<div id="region_select" class="blue_top">\r\n    <div id="region_select_inner">\r\n        <div id="region_select_controls">\r\n            <div id="region_select_cancel"><span>CANCEL</span><div> </div></div>\r\n            <div id="region_select_submit"><span>SUBMIT</span><div> </div></div>    \r\n        </div>\r\n        <div style="border-bottom: 1px #999 solid; margin:5px 0;"> </div>\r\n        <div class="filter_tree_scroller ui-slider ui-slider-vertical ui-widget ui-widget-content ui-corner-all" aria-disabled="false">\r\n            <a class="ui-slider-handle ui-state-default ui-corner-all" href="#" style="bottom: 0%;"></a>\r\n        </div>\r\n        <div class=\'scrollable_list\'>\r\n        {{#regions}}\r\n            <div id="{{id}}" class="region_item">\r\n            <label><input type="radio" value="{{id}}" name="regions">{{title}}</label>\r\n            </div>\r\n        {{/regions}}\r\n        </div>\r\n    </div>\r\n</div>\r\n'}),define("js/view/components/RegionSelection",["classy","signals","text!templates/region_selection.html","mustache","simpleModal","json2"],function(e,t,i){return e.$extend({regionSelectionChanged:null,__init__:function(e){this.container=e,this.regionSelectionChanged=new t.Signal},create:function(e,t,i){var s=this;$("#region_button").off("click").on("click",function(){s.openRegionsDialog($(this))})},update:function(e,t,i){var s="";if(this.selectedTable=e,this.selectedRegion=t,i){$("div#region_button").addClass("active");for(var n=0;n<this.selectedTable.regions.length;n++)this.selectedTable.regions[n].id==this.selectedRegion&&(s=this.selectedTable.regions[n].title);$("#subtitle_region").html(" | Region: "+s)}else $("div#region_button").removeClass("active"),$("#subtitle_region").html("")},openRegionsDialog:function(e){function t(e){var i=$(e.data);return e.data!=e.target?i.data("open")?(i.css("width",i.data("originalWidth")),i.data("open",!1)):i.data("open",!0):setTimeout(function(){i.data("open")?(i.css("width",i.data("originalWidth")),i.data("open",!1)):i.data("open",!0)},100),"function"==typeof t&&$("body").unbind("mouseup",t),!0}var s=this;this.buttonObject=e;var n=$(Mustache.to_html(i,{regions:s.selectedTable.regions})),a=$("div#regions_dialog");a.empty(),a.append(n);var r=$("#region_select_inner").find(".scrollable_list").children();r.disableSelection();for(var o=0;o<r.length;o++)if($(r[o]).attr("id")==this.selectedRegion){$(r[o]).find("input").attr("checked","checked");break}this.regionsDialogContainer=$("div#regions_dialog_container");var l=this.regionsDialogContainer.parent();this.regionsDialogContainer.appendTo("body").css({position:"absolute",display:"block",left:-9999,top:-9999});var d=this.regionsDialogContainer.height();this.regionsDialogContainer.appendTo(l).css({position:"relative",left:0,top:0}),this.regionsDialogContainer.modal({autoPosition:!1,overlayClose:!0,fixed:!1,persist:!0,minHeight:d,maxHeight:d,close:!1,onClose:function(){s.regionsDialogContainer.find(".region_button").remove(),$(window).off("resize.regionselection"),$.modal.close()}}),e.clone().prependTo(this.regionsDialogContainer),this.regionsDialogContainer.find(".region_button").addClass("selected"),this.positionRegionsDialog(),$(window).on("resize.regionselection",this.resizeCallback=function(){s.positionRegionsDialog()});var c=$(window).height(),h=$("div#simplemodal-container").position().top+$("#simplemodal-container").height(),u=$("div#region_select").height(),p=$("body").scrollTop(),m=h-c+u+10;p<m&&$("html, body").animate({scrollTop:m},600,"swing",function(){});$("#region_select_submit").click(function(){for(var e=0;e<r.length;e++)if("checked"==$(r[e]).find("input").attr("checked")){selected=$(r[e]).attr("id"),s.regionSelectionChanged.dispatch(selected),$.modal.close();break}}),$("#region_select_cancel").on("click",function(){$.modal.close()});if($("#region_select").find(".scrollable_list").bind("scroll",function(){$(this).siblings(".filter_tree_scroller").slider("value",this.scrollHeight-this.offsetHeight==0?100:100-100*this.scrollTop/(this.scrollHeight-this.offsetHeight))}),$(".filter_tree_scroller").each(function(){ele=$(this),ele.slider({orientation:"vertical",min:0,max:100,value:100,slide:function(e,t){(function(){this.scrollTop=(this.scrollHeight-this.offsetHeight)*((100-t.value)/100)}).call($(t.handle).parent().siblings(".scrollable_list").get(0))}}).mousedown(function(e){$.browser.msie&&e.stopPropagation()});var e=ele.siblings(".scrollable_list");e.innerHeight()==e.get(0).scrollHeight&&ele.slider("option","disabled",!0)}),"Microsoft Internet Explorer"==navigator.appName){var g=navigator.userAgent;null!=new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})").exec(g)&&(rv=parseFloat(RegExp.$1),rv<9&&this.container.find("select").each(function(){var e=$(this);e.css("min-width",e.width()),e.data("originalWidth",e.width())}).bind("mousedown",function(e){var i=$(this),s=$(this).clone();return s.css("width","auto"),i.parent().append(s.css("visible","false")),s.width()>i.width()&&i.css("width","auto"),s.remove(),i.css("position","relative"),$("body").bind("mouseup",this,t),!0}).bind("change blur",function(e){var t=$(this);return t.css("width",t.data("originalWidth")),t.data("open",!1),!0}))}},positionRegionsDialog:function(){buttonOffset=this.buttonObject.offset(),$("#simplemodal-container").css({top:buttonOffset.top,left:buttonOffset.left})}})}),define("text!templates/lineChart.html",[],function(){return'\x3c!-- This Mustache template displays the Highchart indexing options --\x3e\r\n<div id="lineChartContainer"></div>\r\n<div class="chartIndexing">\r\n\t<form id="chartOptions">\r\n\t\t<div id="indexContainer">\r\n\t\t\t<span class="optionsLabel">Chart Indexing Options: </span>\r\n\t\t\t<input type="radio" id="index0" name="index" value="0" checked="checked"/><label for="index0">None</label>\r\n\t\t\t<input type="radio" id="index1" name="index" value="1"/><label for="index1">Index to Start as Percent</label> \r\n\t\t\t<input type="radio" id="index2" name="index" value="2"/><label for="index2">Index to Start as Value</label>\r\n\t\t</div>\r\n\t</form>\r\n</div>'}),define("js/view/components/LineChart",["signals","classy","js/view/components/DateCodeUtil","text!templates/lineChart.html"],function(e,t,i,s){return t.$extend({container:null,chart:null,indexingChanged:null,indexing:null,data:null,dataMap:null,dataColumns:null,freq:null,units:null,axis:null,series:null,seriesMap:null,seriesColorQueue:null,seriesSymbolQueue:null,__init__:function(t){var i=this;this.indexing=null,this.data=[],this.dataMap={},this.dataColumns=[],this.freq="",this.units={},this.axis=[],this.series=[],this.seriesMap={},this.seriesColorQueue=this.$class.seriesColors.slice(0),this.container=t,this.indexingChanged=new e.Signal,this.container.html(Mustache.render(s)),$("#indexContainer",this.container).buttonset(),$('form input[name="index"]',this.container).on("change",function(e){i.indexingChanged.dispatch($(e.target).val())})},embed:function(){this.chart.openAPIEmbed()},createSeriesOpts:function(e,t,i,s,n,a,r){var o=e.chart_name;if(e.regionTitle){var l=": "+e.regionTitle;if(r&&r.indexOf("Region:")>=0){r.substr(r.indexOf("Region:")+8).indexOf(e.regionTitle)>=0&&(l="")}"All"==o?o=e.regionTitle:o+=l}if(e.caseTitle){var d=": "+e.caseTitle;if(r&&r.indexOf("Case:")>=0){var c=r.substr(r.indexOf("Case:")+6);c.indexOf("|")>=0&&(c=c.substr(0,c.indexOf("|"))),c.indexOf(e.caseTitle)>=0&&(d="")}"All"==o?o=e.caseTitle:o+=d}var h={data:[],color:this.claimNextColor(),marker:{symbol:this.claimNextSymbol()},stickyTracking:!1,xType:function(){switch(i){case"A":return Highcharts.xTypes.annual}}(),region:e.regionTitle,case:e.caseTitle};h.name=(n?e.pinned_name:o)+(s?" ("+e.units+")":"");return this.indexSeries(e,t,i,h,a)},resetColorQueue:function(){this.seriesColorQueue=this.$class.seriesColors.slice(0)},claimNextColor:function(){return color=this.seriesColorQueue.shift(),this.seriesColorQueue.push(color),color},releaseColor:function(e){this.seriesColorQueue.splice($.inArray(e,this.seriesColorQueue),1),this.seriesColorQueue.unshift(e)},resetSymbolQueue:function(){this.seriesSymbolQueue=this.$class.seriesSymbols.slice(0)},claimNextSymbol:function(){return symbol=this.seriesSymbolQueue.shift(),this.seriesSymbolQueue.push(symbol),symbol},releaseSymbol:function(e){this.seriesSymbolQueue.splice($.inArray(e,this.seriesSymbolQueue),1),this.seriesSymbolQueue.unshift(e)},update:function(e,t,s,n,a,r,o,l,d,c,h){var u,p,m,g,f=this,v=[],b=[],_={},C=!1,y=!1,T=[];if(this.data=t,this.dataColumns=s,this.freq=n,this.indexing=a,this.seriesMap={},this.resetColorQueue(),this.resetSymbolQueue(),this.setIndexed(this.indexing),1!=this.indexing)for(u=0;u<this.data.length;u++)null!=t[u]&&(m=t[u],(g=m.units)in _||(_[g]=b.length,b.push($.extend(!0,{title:{text:g},opposite:b.length%2},this.$class.defaultYAxisOptions))));else g="Percent",_[g]=0,b.push($.extend({title:{text:g}},this.$class.defaultYAxisOptions));for(u=0;u<this.data.length;u++)if(null!=t[u]){m=t[u];for(var w=(m.uuid.split(".")[1].split("-")[2].replace("ER","").replace("AEO",""),m.uuid.split(".")[0].split("-")[0],0);w<h.length;w++){h[w].id==m.uuid.split(".")[1].split("-")[2]&&h[w].inAPI&&(!0,T.push(m.series_id.toUpperCase()))}$.each(m.data,function(e,t){return isNaN(t)||(C=C||t<0,y=y||t>0),!(C&&y)});var A=null;("1"!==a&&"2"!==a||isNaN(m.data[r]))&&"0"!==a&&void 0!==a||(A=this.createSeriesOpts(m,s,n,b.length>1,l,r,c),$.each(A,function(e,t){A[e]=$.extend(A[e],{yAxis:"1"===a?0:_[m.units]}),v.push(A[e])}))}else this.claimNextColor(),this.claimNextSymbol();switch(this.destroy(),p=$.extend(!0,{chart:{renderTo:$("#lineChartContainer",this.container).get(0),spacingBottom:20},title:{text:e},subtitle:{text:c},yAxis:b,xAxis:{min:i.parseDateCode(r,n).getTime(),max:i.parseDateCode(o,n).getTime()},series:v,userGenerated:d,tooltip:{formatter:function(){var e=new Date(this.x).getUTCFullYear();this.series.linkedSeries.length||this.series.linkedParent.xData[this.series.linkedParent.xData.length-1]==this.x||(e+=" (Projected)");var t="<b>"+this.series.name+"</b><br>Year: "+e+"<br>";this.series.userOptions.region&&(t+="Region: "+this.series.userOptions.region+"<br>"),this.series.userOptions.case&&(t+="Case: "+this.series.userOptions.case+"<br>");var i=1==this.indexing?2:0==m.precision?1:m.precision;return t+=Highcharts.numberFormat(this.y,i,void 0,",")+" "+m.units}}},this.$class.defaultChartOptions),1==t.length&&(p.legend={enabled:!1}),$.extend(!0,p,{exporting:{embedOptions:{series_id:null,relation_mode:"line"}}}),T.length>0&&(p.exporting.embedOptions.series_id=T.join(";")),"A"==n&&(p.xAxis.tickInterval=31536e6),s.length>20&&(p.xAxis.tickInterval*=2),a){case"1":$.extend(!0,p,{yAxis:Highcharts.map(p.yAxis,function(e){return $.extend(!0,e,{min:null,title:{text:"Indexed to "+i.formatDateCode(r,n)+" as percent",align:p.yAxis.length>2?"middle":"above"}})})});break;case"2":$.extend(!0,p,{yAxis:Highcharts.map(p.yAxis,function(e){return $.extend(!0,e,{min:null,title:{text:"Indexed to "+i.formatDateCode(r,n)+" as value",align:p.yAxis.length>2?"middle":"above"}})})});break;default:$.extend(!0,p,{yAxis:Highcharts.map(p.yAxis,function(e){return $.extend(!0,e,{min:y&&!C?0:null,max:C&&!y?0:null,title:{align:p.yAxis.length>2?"middle":"above"}})})})}this.units=_,this.axis=b,this.chart=new this.$class.chartConstructor(p),this.series=this.chart.series.slice(0),$.each(this.series,function(e,t){f.seriesMap[t.name]=e})},setStartEnd:function(e,t,s){switch(this.chart.xAxis&&this.chart.xAxis.length>0&&this.chart.xAxis[0].setExtremes(i.parseDateCode(e,s).getTime(),i.parseDateCode(t,s).getTime()),this.indexing){case"1":this.chart.yAxis[0].setTitle({text:"Indexed to "+i.formatDateCode(e,s)+" as percent"});break;case"2":this.chart.yAxis[0].setTitle({text:"Indexed to "+i.formatDateCode(e,s)+" as value"})}for(var n=[],a=0;a<this.data.length;a++)null!=this.data[a]&&(n=n.concat(this.indexSeries(this.data[a],this.dataColumns,s,{data:[]},e)));for(var a=0;a<n.length;a++)this.chart.series[a].setData(n[a].data,!1);this.chart.redraw()},download:function(e){if(this.chart)if("csv"==e)this.chart.generateCSV();else{var t;switch(e){case"pdf":t={url:"/global/scripts/jquery/highcharts/exporting-server/index.php",type:"application/pdf"};break;case"png":default:t={url:"/global/scripts/jquery/highcharts/exporting-server/index.php"}}this.chart.exportChart(t)}},setIndexed:function(e){void 0===e&&(e=0),$('form input[name="index"]').filter("[value="+e+"]").prop("checked",!0),$("#indexContainer",this.container).buttonset("refresh")},removeSeries:function(e){this.highchartSeries[e.chart_name].remove(),delete this.seriesOptions[e.chart_name]},indexSeries:function(e,t,s,n,a){var r=null;switch(e.indexed={},this.indexing){case"1":$.each(e.data,function(t,i){t>=a&&""!=i&&null==r&&(r=i),e.indexed[t]=null!=r?i/r*100-100:null});break;case"2":$.each(e.data,function(t,i){t>=a&&""!=i&&null==r&&(r=i),e.indexed[t]=null!=r?i-r:null});break;default:e.indexed=e.data}var o,l,d=[n];for(l=0;l<t.length;l++){var c=parseInt(t[l].toString());isNaN(c)||d[0].data.push([i.parseDateCode(c,s).getTime(),isNaN(o=parseFloat(e.indexed[c]))?null:o])}return void 0!==e.last_historical&&(d[0].lastHistoricalPeriod=e.last_historical),[n]},destroy:function(){null!=this.chart&&(1==this.chart.hasRendered&&this.chart.destroy(),$(".chartCaptionsContainer",this.container).remove(),this.chart=null)},__classvars__:{chartConstructor:Highcharts.Chart,seriesColors:Highcharts.getOptions().colors,seriesSymbols:Highcharts.getOptions().symbols,defaultYAxisOptions:{labels:{x:null,y:null}},defaultChartOptions:{chart:{zoomType:"",panning:!1,lineUpYAxisZeros:!0},xAxis:{maxZoom:1,type:"datetime",labels:{y:20},startOnTick:!1,showFirstLabel:!0},navigator:{enabled:!1},rangeSelector:{enabled:!1},scrollbar:{enabled:!1}}}})}),define("animatedComponent",["classy"],function(e){return e.$extend({__init__:function(){this.animation={enabled:!1,stepSize:1e3,iteration:0,interval:null}},update:function(e){$.extend(this.animation,e)},play:function(e,t){var i=this,s=function(){var t;i.animation.maxIteration&&(e?t=i.animation.iteration%i.animation.maxIteration:(t=Math.min(i.animation.iteration,i.animation.maxIteration))==i.animation.maxIteration&&i.stop()),i.animation.callback&&i.animation.callback.call(i,t),(void 0===i.animation.maxIteration||t+1<=i.animation.maxIteration)&&(i.animation.iteration=t+1)};this.animation.interval&&this.stop(),s(),this.animation.interval=setInterval(s,t||this.animation.stepSize)},stop:function(){clearInterval(this.animation.interval),this.animation.interval=null},reset:function(e){this.animation.iteration=Math.min(e,this.animation.maxIteration),this.animation.callback&&this.animation.callback.call(this,e)},destroy:function(){this.stop()}})}),function(){function e(e){var t,i=e.currentTarget||e.srcElement;if("load"===e.type||a.test(i.readyState)){for(e=i.getAttribute("data-requiremodule"),o[e]=!0,e=0;(t=r[e])&&o[t.name];e++)t.req([t.name],t.onLoad);e>0&&r.splice(0,e),setTimeout(function(){i.parentNode.removeChild(i)},15)}}function t(e){var t,i;for(e.setAttribute("data-orderloaded","loaded"),e=0;(i=d[e])&&((t=l[i])&&"loaded"===t.getAttribute("data-orderloaded"));e++)delete l[i],require.addScriptToDom(t);e>0&&d.splice(0,e)}var i="undefined"!=typeof document&&"undefined"!=typeof window&&document.createElement("script"),s=i&&(i.async||window.opera&&"[object Opera]"===Object.prototype.toString.call(window.opera)||"MozAppearance"in document.documentElement.style),n=i&&"uninitialized"===i.readyState,a=/^(complete|loaded)$/,r=[],o={},l={},d=[],i=null;define("order",{version:"1.0.5",load:function(i,a,o,c){var h;a.nameToUrl?(h=a.nameToUrl(i,null),require.s.skipAsync[h]=!0,s||c.isBuild?a([i],o):n?(c=require.s.contexts._,!c.urlFetched[h]&&!c.loaded[i]&&(c.urlFetched[h]=!0,require.resourcesReady(!1),c.scriptCount+=1,h=require.attach(h,c,i,null,null,t),l[i]=h,d.push(i)),a([i],o)):a.specified(i)?a([i],o):(r.push({name:i,req:a,onLoad:o}),require.attach(h,null,i,e,"script/cache"))):a([i],o)}})}(),define("map",["animatedComponent","signals","order!jVectorMap","order!usa-en"],function(e,t,i){return e.$extend({__init__:function(e,i){this.$super(),this.container=e,this.regionClicked=new t.Signal,this.markerClicked=new t.Signal,this.mapContainer=$("#mapContainer",this.container),this.legendContainer=$("#map_legend",this.container),this.titleContainer=$("#mapTitle",this.container),0==this.titleContainer.length&&(this.titleContainer=$('<h2 id="mapTitle"></h2>').appendTo(this.container)),0==this.mapContainer.length&&(this.mapContainer=$('<div id="mapContainer"></div>').appendTo(this.container)),0==this.legendContainer.length&&(this.legendContainer=$('<div id="map_legend"></div>').appendTo(this.container)),this.counts=null,this.map=null,this.colors={},this.basemap=null==i?"usa_en":i,this.options={animation:{callback:function(e){this.colors?this.worldMap.series.regions[0].setValues(this.getCurrentColors()):this.worldMap.series.regions&&this.worldMap.series.regions.length>0?this.worldMap.series.regions[0].setValues(this.getCurrentCounts()):this.worldMap.series.markers&&this.worldMap.series.markers.length>0&&this.worldMap.series.markers[0].setValues(this.getCurrentCounts())}},map:this.basemap,normalizeFunction:"polynomial",hoverOpacity:.7,hoverColor:!1,backgroundColor:"white",dataPrecision:0}},play:function(e,t){this.$super(e,t)},update:function(e,t,i){var s=this;void 0!==i&&void 0!==i.map&&(this.basemap=i.map,this.options.map=i.map),this.counts=$.map(e instanceof Array?e:[e],function(e){var t={};for(var i in e)e.hasOwnProperty(i)&&(jvm.WorldMap.maps[s.basemap].paths.hasOwnProperty(i.toUpperCase())?t[i.toUpperCase()]=e[i]:jvm.WorldMap.maps[s.basemap].paths.hasOwnProperty(i.toLowerCase())?t[i.toLowerCase()]=e[i]:t[i]=e[i]);return t}),this.options=$.extend(this.options||{},i),this.$super($.extend(!0,this.animation,this.options.animation,{maxIteration:e.length-1})),this.setTitle(t),this.calculateMinMax(),"function"==typeof this.assignColors&&this.assignColors(),this.createLegend(),this.setContainerHeight(),this.createMap()},setContainerHeight:function(){this.mapContainer.height(this.mapContainer.parent().height()-(this.titleContainer.outerHeight(!0)+this.legendContainer.outerHeight(!0)+parseInt(this.mapContainer.css("paddingTop"))+parseInt(this.mapContainer.css("paddingBottom"))+10))},calculateMinMax:function(){this.min=this.max=null;for(var e=0;e<this.counts.length;e++)for(var t in this.counts[e])this.counts[e].hasOwnProperty(t)&&(this.min=null==this.min||this.counts[e][t]<this.min?this.counts[e][t]:this.min,this.max=null==this.max||this.counts[e][t]>this.max?this.counts[e][t]:this.max);null!==this.min&&(this.min=parseFloat(Highcharts.numberFormat(this.min,this.options.dataPrecision,".",""))),null!==this.max&&(this.max=parseFloat(Highcharts.numberFormat(this.max,this.options.dataPrecision,".","")))},setTitle:function(e){this.titleContainer.text(e)},createRegionOps:function(){return[{values:this.colors?this.getCurrentColors():this.getCurrentCounts(),min:this.min,max:this.max,scale:this.colors?void 0:this.$class.palette}]},createMarkerOps:function(){return this.options.markers?[{values:this.colors?this.getCurrentColors():this.getCurrentCounts(),min:this.min,max:this.max,scale:this.colors?void 0:this.$class.palette}]:null},createMap:function(){var e=this;this.worldMap&&this.worldMap.remove(),this.regionOps=this.createRegionOps(),this.markerOps=this.createMarkerOps();var t={};this.regionOps&&(t.regions=this.regionOps),this.markerOps&&(t.markers=this.markerOps),this.mapContainer.empty(),this.map=$('<div style="height:100%;width:100%;" class="map_inside_container"></div>').appendTo(this.mapContainer).vectorMap($.extend(!0,{regionStyle:{initial:{fill:"#CCCCCC","fill-opacity":1,stroke:"none","stroke-width":0,"stroke-opacity":1},hover:{"fill-opacity":.8},selected:{fill:"yellow"}},series:t,onRegionClick:function(t,i){e.regionClicked.dispatch(i.toUpperCase(),t)},onMarkerClick:function(t,i){e.markerClicked.dispatch(e.options.markers[i],t)},zoomOnScroll:!1},this.options)),this.worldMap=this.mapContainer.find(".jvectormap-container").data("mapObject")},createLegend:function(e,t){},getCurrentColors:function(){var e={};return $.each(jvm.WorldMap.maps[this.basemap].paths,function(t,i){e[t]=""}),$.extend(e,this.colors[this.animation.iteration])},getCurrentCounts:function(){return this.counts[this.animation.iteration]},destroy:function(){this.worldMap&&this.worldMap.remove(),this.mapContainer.empty(),this.legendContainer.empty(),this.titleContainer.empty()},assignColors:function(e,t,i){},exportMap:function(e){if(!window.SVGAngle)throw"SVG not supported";var t=$(".jvectormap-container").html(),i=($(".jvectormap-container").html(),$(".jvectormap-container").find("svg").attr("height"));i=parseInt(i)+20;var s=t.indexOf("height");s=t.indexOf('"',s);var n=t.indexOf('"',s+1);t=t.slice(0,s+1)+i+t.slice(n),t=t.replace(/<div[^<]+<\/div>/gi,""),t=t.replace(/<svg /gi,'<svg xmlns="http://www.w3.org/2000/svg"  version="1.1" '),t=t.replace(/<g><\/g>/gi,""),t=t.replace(/<g/,'<rect x="0" y="0" width="100%" height="100%" fill="white"></rect><g'),t=t.replace(/zIndex="[^"]+"/g,"").replace(/isShadow="[^"]+"/g,"").replace(/symbolName="[^"]+"/g,"").replace(/jQuery[0-9]+="[^"]+"/g,"").replace(/isTracker="[^"]+"/g,"").replace(/url\([^#]+#/g,"url(#").replace(/ /g," ").replace(/­/g,"­").replace(/id=([^" >]+)/g,'id="$1"').replace(/class=([^" ]+)/g,'class="$1"').replace(/ transform /g," ").replace(/:(path|rect)/g,"$1").replace(/style="([^"]+)"/g,function(e){return e.toLowerCase()}),t=t.replace(/(url\(#highcharts-[0-9]+)"/g,"$1").replace(/"/g,"'"),t.match(/ xmlns="/g)&&2===t.match(/ xmlns="/g).length&&(t=t.replace(/xmlns="[^"]+"/,""));var a="";switch(e){case"svg":a="image/svg+xml";break;case"pdf":a="application/pdf";break;case"png":default:a="image/png"}String.prototype.replaceAll=function(e,t){return t?this.replace(new RegExp("["+e+"]","g"),t):this}
;var r=$('<form action="/global/scripts/jquery/highcharts/exporting-server/index.php" method="POST"><input type="hidden" name="svg" id="hiddensvg"><input type="hidden" name="type" value="'+a+'"><input type="hidden" name="filename" value="map_of_'+this.titleContainer.text().replaceAll(":",",").replaceAll(" ","_")+'"></form>');$("body").append(r),r.find("input[id=hiddensvg]").val(t),r.submit(),r.remove()},__classvars__:{palette:["#7ce3ff","#4cc9ff","#0196d8","#00628c","#00355b"]}})}),define("continuousMap",["signals","map","order!jVectorMap","order!usa-en"],function(e,t,i){return t.$extend({__init__:function(e,t){this.$super(e,t)},createLegend:function(e){var t,i,s=this;this.legendContainer.empty();var n=$('<span style="display: inline-block; text-align:center;"></span>').appendTo(this.legendContainer);this.options.legendTitle&&($('<span class="map_legend_title">'+this.options.legendTitle+"</span>").appendTo(n),$("<br />").appendTo(n)),s.options.legendItemFormatter?(t=s.options.legendItemFormatter.call(s,this.min),i=s.options.legendItemFormatter.call(s,this.max)):(t=this.min,i=this.max),s.$class.drawGradient(n,s.$class.palette[0],s.$class.palette[s.$class.palette.length-1],t,i),$("<br />").appendTo(n),$("<br />").appendTo(n);var a=$("<div/>").appendTo(n);$("<span/>").appendTo(a).attr("style","display:inline-block;margin-right:10px;width:20px;height:20px;background-color:#CCC"),$("<span>Value is not available</span>").appendTo(a).attr("style","margin-top:3px;display:inline-block;")},assignColors:function(){for(var e,t,i,s,n,a,r=[],o=this.max,l=this.min,d=parseInt(this.$class.palette[0].substring(1,3),16),c=parseInt(this.$class.palette[this.$class.palette.length-1].substring(1,3),16),h=parseInt(this.$class.palette[0].substring(3,5),16),u=parseInt(this.$class.palette[this.$class.palette.length-1].substring(3,5),16),p=parseInt(this.$class.palette[0].substring(5),16),m=parseInt(this.$class.palette[this.$class.palette.length-1].substring(5),16),g=0;g<this.counts.length;g++)for(e in this.counts[g]){switch(r[g]||(r[g]={}),t=parseFloat(Highcharts.numberFormat(this.counts[g][e],this.options.dataPrecision,".","")),i=(t-l)/(o-l),this.scaleType){case"logarithmic":i=(Math.log(t)-Math.log(l))/(Math.log(o)-Math.log(l))}s=parseInt(i*c-(i-1)*d,10).toString(16).replace(/^(\w{1})$/,"0$1"),n=parseInt(i*u-(i-1)*h,10).toString(16).replace(/^(\w{1})$/,"0$1"),a=parseInt(i*m-(i-1)*p,10).toString(16).replace(/^(\w{1})$/,"0$1"),r[g][e]="#"+s+n+a}this.colors=r},__classvars__:{drawGradient:function(e,t,i,s,n){var a="";a+="background-image: -ms-linear-gradient(left, "+t+" 0%, "+i+" 100%);",a+='-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr='+t+", endColorstr="+i+', gradientType=1)";',a+="filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="+t+", endColorstr="+i+", gradientType=1)",a+="background-image: -webkit-gradient(linear, left bottom, right bottom, from("+t+"), to("+i+"));",a+="background-image: -webkit-linear-gradient(left, "+t+", "+i+");",a+="background-image:    -moz-linear-gradient(left, "+t+", "+i+");",a+="background-image:      -o-linear-gradient(left, "+t+", "+i+";",a+="background-image:         linear-gradient(to left, "+t+","+i+");",$("<span>"+s+"</span>").appendTo(e),$('<span class="map_legend_gradient"></span>').appendTo(e).attr("style",a),$("<span>"+n+"</span>").appendTo(e)}}})}),define("growthMap",["map"],function(e){return e.$extend({__init__:function(e,t){this.$super(e,t)},update:function(e,t,i){e=$.map(e,function(t,i){var s={};for(var n in t)t.hasOwnProperty(n)&&i>0&&void 0!==e[i-1]&&e[i-1].hasOwnProperty(n)&&t[n]*e[i-1][n]>0&&(s[n]=100*(t[n]-e[i-1][n])/e[i-1][n]);return s}),this.$super(e,t,$.extend({},i,{backgroundColor:"#ffffff"}))},createRegionOps:function(){return[{attributes:this.getCurrentColors()}]},createLegend:function(){var e,t,i=this;this.legendContainer.empty();var s=$('<span style="display: inline-block; text-align:center;"></span>').appendTo(this.legendContainer);this.options.legendTitle&&($('<span class="map_legend_title">'+this.options.legendTitle+"</span>").appendTo(s),$("<br />").appendTo(s)),i.options.legendItemFormatter?(e=i.options.legendItemFormatter.call(i,this.min),t=i.options.legendItemFormatter.call(i,this.max)):(e=this.min,t=this.max);var n="",a="";n+="background-image: -ms-linear-gradient(left, "+this.$class.palette[0]+" 0%, "+this.$class.palette[1]+" 100%);",n+='-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr='+this.$class.palette[0]+", endColorstr="+this.$class.palette[1]+', gradientType=1)";',n+="filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="+this.$class.palette[0]+", endColorstr="+this.$class.palette[1]+", gradientType=1)",n+="background-image: -webkit-gradient(linear, left bottom, right bottom, from("+this.$class.palette[0]+"), to("+this.$class.palette[1]+"));",n+="background-image: -webkit-linear-gradient(left, "+this.$class.palette[0]+", "+this.$class.palette[1]+");",n+="background-image:    -moz-linear-gradient(left, "+this.$class.palette[0]+", "+this.$class.palette[1]+");",n+="background-image:      -o-linear-gradient(left, "+this.$class.palette[0]+", "+this.$class.palette[1]+";",n+="background-image:         linear-gradient(to left, "+this.$class.palette[0]+","+this.$class.palette[1]+");",a+="background-image: -ms-linear-gradient(left, "+this.$class.palette[3]+" 0%, "+this.$class.palette[4]+" 100%);",a+='-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr='+this.$class.palette[3]+", endColorstr="+this.$class.palette[4]+', gradientType=1)";',a+="filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="+this.$class.palette[3]+", endColorstr="+this.$class.palette[4]+", gradientType=1)",a+="background-image: -webkit-gradient(linear, left bottom, right bottom, from("+this.$class.palette[3]+"), to("+this.$class.palette[4]+"));",a+="background-image: -webkit-linear-gradient(left, "+this.$class.palette[3]+", "+this.$class.palette[4]+");",a+="background-image:    -moz-linear-gradient(left, "+this.$class.palette[3]+", "+this.$class.palette[4]+");",a+="background-image:      -o-linear-gradient(left, "+this.$class.palette[3]+", "+this.$class.palette[4]+";",a+="background-image:         linear-gradient(to left, "+this.$class.palette[3]+","+this.$class.palette[4]+");",$("<span>"+e+"</span>").appendTo(s);var r=$('<span class="map_legend_gradient"></span>').appendTo(s);$('<span class="growth_gradient_component"></span>').attr("style",n).appendTo(r),$('<span class="growth_gradient_component"></span>').attr("style",a).appendTo(r),$("<span>"+t+"</span>").appendTo(s),$("<br />").appendTo(s),$("<br />").appendTo(s);var o=$("<div/>").appendTo(s);$("<span></span").appendTo(o).attr("style","display:inline-block;margin-right:10px;width:20px;height:20px;background-color:#CCC"),$("<span>Value is not available</span>").appendTo(o).attr("style","margin-top:3px;display:inline-block;")},calculateMinMax:function(){void 0!==this.options.extremes?(this.min=this.options.extremes.min,this.max=this.options.extremes.max):(this.$super(),this.max>0&&this.min<0&&(Math.abs(this.min)>this.max?this.max=Math.abs(this.min):this.min=-1*this.max))},assignColors:function(){for(var e,t,i,s,n,a,r,o,l,d,c,h,u=[],p=this.max,m=this.min,g=0;g<this.counts.length;g++)for(r in this.counts[g])o=parseFloat(Highcharts.numberFormat(this.counts[g][r],this.options.dataPrecision,".","")),o<0?(l=(o-m)/(-1*m),e=parseInt(this.$class.palette[0].substring(1,3),16),t=parseInt(this.$class.palette[1].substring(1,3),16),i=parseInt(this.$class.palette[0].substring(3,5),16),s=parseInt(this.$class.palette[1].substring(3,5),16),n=parseInt(this.$class.palette[0].substring(5),16),a=parseInt(this.$class.palette[1].substring(5),16),d=(e<t?Math.max:Math.min).call(window,parseInt(l*t-(l-1)*e,10),e).toString(16).replace(/^(\w{1})$/,"0$1"),c=(i<s?Math.max:Math.min).call(window,parseInt(l*s-(l-1)*i,10),i).toString(16).replace(/^(\w{1})$/,"0$1"),h=(n<a?Math.max:Math.min).call(window,parseInt(l*a-(l-1)*n,10),n).toString(16).replace(/^(\w{1})$/,"0$1")):o>0?(l=o/p,e=parseInt(this.$class.palette[3].substring(1,3),16),t=parseInt(this.$class.palette[4].substring(1,3),16),i=parseInt(this.$class.palette[3].substring(3,5),16),s=parseInt(this.$class.palette[4].substring(3,5),16),n=parseInt(this.$class.palette[3].substring(5),16),a=parseInt(this.$class.palette[4].substring(5),16),d=(e>t?Math.max:Math.min).call(window,parseInt(l*t-(l-1)*e,10),t).toString(16).replace(/^(\w{1})$/,"0$1"),c=(i>s?Math.max:Math.min).call(window,parseInt(l*s-(l-1)*i,10),s).toString(16).replace(/^(\w{1})$/,"0$1"),h=(n>a?Math.max:Math.min).call(window,parseInt(l*a-(l-1)*n,10),a).toString(16).replace(/^(\w{1})$/,"0$1")):(d=this.$class.palette[2].substring(1,3),c=this.$class.palette[2].substring(3,5),h=this.$class.palette[2].substring(5)),u[g]||(u[g]={}),u[g][r]="#"+d+c+h;this.colors=u},__classvars__:{palette:["#6F2EA4","#C5ABDB","#CCCCCC","#BED5AD","#5D9732"]}})}),define("text!templates/animatedMap.html",[],function(){return'\x3c!-- This Mustache template displays the jVectorMap --\x3e\r\n<h2 id="mapTitle"></h2>\r\n<div id="mapContainer"></div>\r\n<div id="map_controls_container">\r\n\t<h2>Map controls & legend</h2>\r\n\t<div class="animated_map_button_container">\r\n\t\t<div id="animated_map_type_container">\r\n\t\t\t<span class="optionsLabel">Value options:</span>\r\n\t\t\t{{#mapTypes}}\r\n\t\t\t<input id="radio_{{id}}" type="radio" name="animated_map_type_radio" value="{{id}}" /><label for="radio_{{id}}">{{title}}</label>\r\n\t\t\t{{/mapTypes}}\r\n\t\t</div>\r\n\t\t<br/>\t\r\n\t\t<div id="animated_map_slider"></div>\r\n\t\t<br/>\r\n\t\t<div id="animated_map_transport_container">\r\n\t\t\t<input type="checkbox" id="play_button"></input><label for="play_button">Play</label>\r\n\t\t\t<input type="checkbox" id="pause_button"></input><label for="pause_button">Pause</label>\r\n\t\t\t<button id="reset_button">Reset</button>\r\n\t\t</div>\r\n\t\t<hr>\r\n\t\t<div id="map_units_label_container">\r\n\t\t\t<span id="map_units_label"></span>\r\n\t\t</div>\r\n\t\t<div id="map_legend"></div>\r\n\t</div>\r\n</div>\r\n'}),define("js/view/components/AnimatedMap",["classy","continuousMap","growthMap","signals","js/view/components/DateCodeUtil","text!templates/animatedMap.html","mustache","us-census-merc-en"],function(e,t,i,s,n,a){return e.$extend({__init__:function(e){this.ContinuousMapClass=t=t.$extend({__classvars__:{palette:["#b0efff","#001F37"]}}),this.GrowthMapClass=i;var n=this;this.container=e,this.container.html(Mustache.render(a,{mapTypes:[{id:this.$class.CONTINUOUS_MAP,title:"Values"},{id:this.$class.GROWTH_MAP,title:"Growth"}]})),this.createPlayerControls(),this.mapTypeButtonset=$("#animated_map_type_container",this.container).buttonset(),this.mapTypeSelector=$("[name=animated_map_type_radio]",this.container),this.unitsLabel=$("#map_units_label",this.container),this.mapTypeChangeRequested=new s.Signal,this.mapTypeSelectorHandler=function(e){n.mapTypeChangeRequested.dispatch(n.mapTypeSelector.filter(":checked").val())}},createPlayerControls:function(){var e=this;this.playButton=$("#play_button",this.container).button({icons:{primary:"map_play_icon"}}),this.pauseButton=$("#pause_button",this.container).button({icons:{primary:"map_pause_icon"}}),this.resetButton=$("#reset_button",this.container).button({icons:{primary:"map_reset_icon"}}),this.slider=$("#animated_map_slider",this.container).slider(),this.handle=$("#animated_map_slider",this.container).children(".ui-slider-handle"),this.sliderLabel=$('<div class="map_slider_tooltip" style="margin-top: -18px;"></div>').css({position:"absolute"}).appendTo(this.handle),this.playHandler=function(){e.map.stop(),e.position==e.displayColumns[e.displayColumns.length-1]&&e.map.reset(0),e.setButtonState(!0),e.map.play(!1,300)},this.pauseHandler=function(){e.map.stop(),e.setButtonState(!1)},this.resetHandler=function(){e.map.stop(),e.map.reset(e.displayColumns.length-1),e.position=e.displayColumns[e.displayColumns.length-1],e.map.setTitle(e.title+" "+e.displayColumns[e.displayColumns.length-1]),e.setButtonState(!1),$("#reset_button").removeClass("red")},this.sliderHandler=function(t,i){e.map.stop(),e.map.reset(i.value),e.position=e.displayColumns[i.value],e.setButtonState(!1)},$('label[for="'+this.pauseButton.attr("id")+'"]').hide()},destroy:function(){this.map&&this.map.destroy()},update:function(e,t,i,s,a,r,o){var l=this,d=0;switch(this.displayColumns=[],this.counts=[],this.basemap=void 0===o?"us_census_merc_en":o,this.title=e.TITLE,this.data=e,this.mapType=t,this.start=i,this.end=s,this.options=r,this.map&&(this.map.stop(),this.map.destroy()),this.setButtonState(!1),t){case this.$class.GROWTH_MAP:this.map=new this.GrowthMapClass(this.container,this.basemap),this.units="Percent change from prior",this.precision=2;break;default:this.map=new this.ContinuousMapClass(this.container,this.basemap),this.units=e.UNITS||"",this.precision=e.PRECISION}this.unitsLabel.text(this.units),this.mapTypeSelector.filter("[value="+t+"]").attr("checked","true"),this.mapTypeButtonset.buttonset("refresh"),$.each(e.DATACOLUMNS,function(t,n){n>=i&&n<=s&&(l.displayColumns.push(n),l.counts.push(e.DATA[n]))}),void 0!==this.position?~(d=$.inArray(this.position,this.displayColumns))||(d=this.displayColumns.length-1):d=this.displayColumns.length-1,this.map.animation.enabled=!0,this.map.update(this.counts,this.title+" "+this.displayColumns[d],$.extend({animation:{enabled:!0,callback:function(e){this.colors?this.worldMap.series.regions[0].setValues(this.getCurrentColors()):this.worldMap.series.regions&&this.worldMap.series.regions.length>0&&this.worldMap.series.regions[0].setValues(this.getCurrentCounts());var t={},i=l.displayColumns[e];l.position=i;var s=void 0===i||null==i?"":n.formatDateCode(i,a);l.map.setTitle(l.title+" "+s),l.sliderLabel.text(s),t.left=-.5*l.sliderLabel.width()+.5*l.handle.width(),l.sliderLabel.height()>1.5*parseInt(l.sliderLabel.css("font-size").slice(0,-2),10)?t.top=-.5*l.sliderLabel.height():t.top=0,l.sliderLabel.css(t),l.slider.slider("option","value",e),e==l.displayColumns.length-1&&l.setButtonState(!1)},iteration:d},continuous:!0,isGrowth:!0,dataPrecision:3,extremes:{min:-100,max:100},legendItemFormatter:function(e){var i;return t==l.$class.GROWTH_MAP?(i=Highcharts.numberFormat(e,l.precision)+"%",e>0&&(i+="+")):i=Highcharts.numberFormat(e,l.precision),i},zoomOnScroll:!0,onRegionLabelShow:function(e,t,i){if(i){var s=l.map.getCurrentCounts()[i];void 0!==s&&$(t).html($(t).html()+" "+Highcharts.numberFormat(s,l.precision)+" "+(l.mapType==l.$class.GROWTH_MAP?"% change from "+n.formatDateCode(n.deincrementDateCode(l.position,a),a)+" to "+n.formatDateCode(l.position,a):l.units))}else t.empty()}},r)),this.map.reset(d),this.slider.slider("option","min",0),this.slider.slider("option","max",this.displayColumns.length-1),this.slider.slider("option","value",d),"function"==typeof this.sliderHandler&&this.slider.unbind("slide",this.sliderHandler),this.slider.bind("slide",this.sliderHandler),"function"==typeof this.playHandler&&this.playButton.unbind("click",this.playHandler),this.playButton.bind("click",this.playHandler),"function"==typeof this.pauseHandler&&this.pauseButton.unbind("click",this.pauseHandler),this.pauseButton.bind("click",this.pauseHandler),"function"==typeof this.resetHandler&&this.resetButton.unbind("click",this.resetHandler),this.resetButton.bind("click",this.resetHandler),"function"==typeof this.mapTypeSelectorHandler&&this.mapTypeSelector.unbind("change",this.mapTypeSelectorHandler),this.mapTypeSelector.bind("change",this.mapTypeSelectorHandler)},setButtonState:function(e){e&&(this.playButton.attr("checked",!1),$('label[for="'+this.playButton.attr("id")+'"]').hide(),$('label[for="'+this.pauseButton.attr("id")+'"]').show()),e||(this.pauseButton.attr("checked",!1),$('label[for="'+this.pauseButton.attr("id")+'"]').hide(),$('label[for="'+this.playButton.attr("id")+'"]').show()),this.playButton.button("refresh"),this.pauseButton.button("refresh")},outputToArrOfArrs:function(){var e,t,i,s,n=[],a=[],r=this.map.worldMap.regions;for(e in r)r.hasOwnProperty(e)&&a.push(e);a.sort(),n.push(["Units: "+(this.mapType==this.$class.GROWTH_MAP?"percent change from previous period":this.data.UNITS)]);var o=this.displayColumns.slice();for(o.unshift(""),n.push(o),i=0;i<a.length;i++)for(e=a[i],n.push(s=['"'+e+'"']),t=0;t<this.counts.length;t++)s.push(this.map.counts[t][e]||"");return n},__classvars__:{CONTINUOUS_MAP:"0",GROWTH_MAP:"1"}})}),define("text!templates/downloadBox.html",[],function(){return'\x3c!-- This Mustache template displays the Download modal dialog  --\x3e\r\n<div class="style2">\r\n\t\t<dl class="download_menu">\r\n\t\t\t{{#downloadItems}}\r\n\t\t\t<dt>{{#id}}<a id="{{id}}" class="download_option {{class}}">{{/id}}{{label}}{{#id}}</a>{{/id}}</dt>\r\n\t\t\t{{#children}}\r\n\t\t\t\t<dd><a id="{{id}}" class="download_option {{class}}">{{label}}</a></dd>\r\n\t\t\t{{/children}}\r\n\t\t\t{{/downloadItems}}\r\n\t\t\t<dt class="clear"/>\r\n\t\t</dl>\r\n</div>'}),define("js/view/components/Download",["classy","text!templates/downloadBox.html","signals","mustache","simpleModal"],function(e,t,i){return e.$extend({__init__:function(e){var t=this;this.container=e,this.button=$("#main_download_button"),this.downloadButtonClicked=new i.Signal,this.downloadOptionClicked=new i.Signal,this.button.click(function(e){t.button.hasClass("disabled")||t.downloadButtonClicked.dispatch()}),this.container.delegate(".download_option","click",function(e){t.hideDownload(),t.downloadOptionClicked.dispatch(t.idMap[$(e.target).attr("id")])}),this.modalCloseHandler=function(e){0==$(e.target).parents("#download_dialog_container").length&&t.hideDownload()}},generateDownload:function(e,i){this.idMap=function(){for(var e={},t=0;t<i.length;t++){var s=i[t];if(s.id)e[s.id]=s;else if(i[t].children)for(var n=0;n<s.children.length;n++)e[s.children[n].id]=s.children[n]}return e}(),e.empty();var s=$(Mustache.to_html(t,{downloadItems:i}));e.append(s)},showDownload:function(e){var t=this,i=t.button.offset();this.generateDownload(this.container,e),$("#download_dialog_container").modal({autoPosition:!1,overlayClose:!0,fixed:!1,close:!1,persist:!0}),$("#simplemodal-container").css({top:i.top,left:i.left}),$("body").one("click",function(){$("body").bind("click",t.modalCloseHandler)}),this.container.css({left:this.button.outerWidth()-this.container.outerWidth()}),$(window).resize(this.resizeCallback=function(){var e=t.button.offset();$("#simplemodal-container").css({top:e.top,left:e.left})})},hideDownload:function(){$.modal.close(),"function"==typeof this.resizeCallback&&$(window).unbind("resize",this.resizeCallback),"function"==typeof this.modalCloseHandler&&$("body").unbind("click",this.modalCloseHandler),this.resizeCallback=null}})}),define("text!templates/footnotes.html",[],function(){return"\x3c!-- This Mustache template is used to display all the footnotes --\x3e\r\n{{#footnotes}}\r\n\t<div class='footnote' style='font-size: 12px;'>{{&.}}</div>\r\n{{/footnotes}}\r\n"}),define("js/view/components/Footnotes",["classy","signals","text!templates/footnotes.html","mustache","simpleModal","json2"],function(e,t,i){return e.$extend({__init__:function(e){this.container=e},create:function(e){},updateFootnotes:function(e){this.footnotes=e,this.container.html(Mustache.render(i,{footnotes:e}))}})}),function(e){e("datagrid",["signals","classy","order!dragevent","order!mousewheel","order!slickcore","order!slickgrid","order!slickdataview"],function(e,t){return t.$extend({__init__:function(t){var i=this;this.isFiltered=!1,this.slickgrid=null,this.container=t.empty(),this.innerGridContainer=$(this.$class.innerSlickGridHTML).appendTo(this.container),this.vSlider=null,this.hSliderTop=null,this.hSliderBottom=null,this.filteredColumns=[],this.columns=[],this.data=[],this.options={},this.onClick=new e.Signal,this.onColumnOrderChanged=new e.Signal,this.onHeaderClick=new e.Signal,this.onHeaderCellRendered=new e.Signal,this.onViewRowCountChanged=function(e,t){i.slickgrid.updateRowCount(),i.slickgrid.render()},this.onViewRowsChanged=function(e,t){i.slickgrid.invalidateRows(t.rows),i.slickgrid.render()}},update:function(e,t,i,s,n){var a,r=this,o=void 0!==s&&void 0!==n;t=void 0===t?this.columns:t,i=void 0===i?this.options:i,this.slickgrid?(this.setData(e),this.setColumns(t,!0),this.setOptions(i),o?this.filterNumericColumns(s,n):this.slickgrid.setColumns(t),this.resetHSliders(),this.checkScroll()):(this.setData(e),this.setColumns(t),this.setOptions(i),a=o?this.filterNumericColumns(s,n):this.filterHiddenColumns(this.options.addSpacerColumn?this.columns.concat([this.$class.spacerColumnOps]):this.columns),this.slickgrid=new Slick.Grid(this.innerGridContainer,this.data,a,this.options),this.slickgrid.onClick.subscribe(function(e,t){r.onClick.dispatch(t.row,t.cell,r.slickgrid.getDataItem(t.row),e)}),this.slickgrid.onSort.subscribe(function(e,t){r.data.sort(function(e,i){var s=t.sortCol.field,n=t.sortAsc?1:-1,a=e[s],r=i[s],o=(a==r?0:a>r?1:-1)*n;return o=void 0===a||"string"==typeof a&&""==a?1:void 0===r||"string"==typeof r&&""==r?-1:o,0!=o?o:0}),r.slickgrid.invalidate(),r.slickgrid.render()}),this.slickgrid.onColumnsReordered.subscribe(function(e,t){r.resetHSliders(),r.checkScroll(),r.onColumnOrderChanged.dispatch(e,t)}),this.slickgrid.onColumnsResized.subscribe(function(e,t){r.resetHSliders(),r.checkScroll()}),this.slickgrid.onHeaderClick.subscribe(function(e,t){r.onHeaderClick.dispatch(e,t)}),this.slickgrid.onHeaderCellRendered.subscribe(function(e,t){r.onHeaderCellRendered.dispatch(e,t)}),this.checkScroll(),this.options.scrollToRight&&this.scrollToRight())},outputToArrOfArrs:function(e){e=void 0===e||e;var t,i,s,n,a,r,o,l,d=e&&this.isFiltered?this.filteredColumns:this.columns,c=[];for(c.push(n=[]),t=0;t<d.length;t++)a=d[t],(void 0===a.output||a.output)&&n.push('"'+(void 0!==a.name?a.name:a.id)+'"');for(t=0;t<(this.data.getLength?this.data.getLength():this.data.length);t++)for(s=this.data.getItem?this.data.getItem(t):this.data[t],c.push(n=[]),i=0;i<d.length;i++)a=d[i],(void 0===a.output||a.output)&&(r=[t,i,a&&"function"==typeof this.options.dataItemColumnValueExtractor?this.options.dataItemColumnValueExtractor(s,a):s[a.field],a,s],o=a.outputFormatter?a.outputFormatter.apply(this,r):a.dataFormatter?a.dataFormatter.apply(this,r):null!==r[2]&&void 0!==r[2]?r[2]:"",l=o.toString().replace(/,/g,""),n.push(isNaN(l)?'"'+(o||"")+'"':l));return c},processColumns:function(e){var t,i;for(t=0;t<e.length;t++)i=e[t],i.formatter=this.$class.defaultFormatter;return e},filterHiddenColumns:function(e){return $.map(e,function(e){return!1===e.display?null:e})},checkScroll:function(){var e,t,i,s=this,n=$(".slick-viewport",this.container),a=$(".slick-pane",this.container);this.options.frozenColumn>=0?(t=n.filter(".slick-viewport-top.slick-viewport-right"),e=a.filter(".slick-pane-top.slick-pane-right")):(t=n.filter(".slick-viewport-top.slick-viewport-left"),e=a.filter(".slick-pane-top.slick-pane-left")),(i=function(){this.vSlider?this.vSlider.css("height",t.height()-30):(this.vSlider=$("<div/>").appendTo(this.container).css({position:"relative",float:"left",height:t.height()-30,marginTop:20,marginBottom:10,marginLeft:10}).slider({orientation:"vertical",min:0,max:100,value:100,slide:function(e,i){(function(){this.scrollTop=(this.scrollHeight-this.offsetHeight)*((100-i.value)/100)}).call(t.get(0))}}),t.scroll(function(){s.vSlider.slider("value",100-100*this.scrollTop/(this.scrollHeight-this.offsetHeight))}),this.innerGridContainer.width(this.container.width()-this.vSlider.width()-20).css("float","left"),this.slickgrid.resizeCanvas()),t.get(0).scrollHeight>t.height()?this.vSlider.slider("option","disabled",!1):this.vSlider.slider("option","disabled",!0)}).call(this),function(){var s,n,r,o=this;this.hSliderTop||this.hSliderBottom?(this.hSliderTop.css("width",t.width()-28),this.hSliderBottom.css("width",t.width()-28)):(s=a.find(".slick-header").eq(0),r=s.position(),n=e.position(),this.hSliderTop=$("<div/>").appendTo(this.container).css({position:"absolute",top:r.top+s.height()-13,left:n.left,width:t.width()-28,marginRight:30}).slider({min:0,max:100,value:0,slide:function(e,i){(function(){this.scrollLeft=(this.scrollWidth-this.offsetWidth)*(i.value/100),o.hSliderBottom.slider("value",i.value)}).call(t.get(0))}}).addClass("hSliderTop"),this.hSliderBottom=$("<div/>").appendTo(this.container).css({position:"absolute",bottom:0,left:n.left,width:t.width()-28,marginRight:30}).slider({min:0,max:100,value:0,slide:function(e,i){(function(){this.scrollLeft=(this.scrollWidth-this.offsetWidth)*(i.value/100),o.hSliderTop.slider("value",i.value)}).call(t.get(0))}}).addClass("hSliderBottom"),t.scroll(function(){o.hSliderTop.slider("value",100*this.scrollLeft/(this.scrollWidth-this.offsetWidth)),o.hSliderBottom.slider("value",100*this.scrollLeft/(this.scrollWidth-this.offsetWidth))}),this.innerGridContainer.height(this.container.height()-this.hSliderBottom.height()-20),i.call(this)),t.get(0).scrollWidth>t.width()?(this.hSliderBottom.slider("option","disabled",!1),this.hSliderTop.slider("option","disabled",!1),t.scroll()):(t.scroll(),this.hSliderBottom.slider("option","disabled",!0),this.hSliderTop.slider("option","disabled",!0),this.slickgrid.autosizeColumns())}.call(this)},scrollToRight:function(){var e,t=$(".slick-viewport",this.container);e=this.options.frozenColumn>=0?t.filter(".slick-viewport-top.slick-viewport-right"):t.filter(".slick-viewport-top.slick-viewport-left"),e.get(0).scrollLeft=e.get(0).scrollWidth},filterNumericColumns:function(e,t){var i,s;for(this.filteredColumns=[],i=0;i<this.columns.length;i++)s=this.columns[i],isNaN(s.id)?this.filteredColumns.push(s):s.id>=e&&s.id<=t&&this.filteredColumns.push(s);var n=this.filterHiddenColumns(this.options.addSpacerColumn?this.filteredColumns.concat([this.$class.spacerColumnOps]):this.filteredColumns);return this.slickgrid&&(this.slickgrid.setColumns(n),this.isFiltered=!0,this.resetHSliders(),this.checkScroll(),this.options.scrollToRight&&this.scrollToRight()),n},setColumns:function(e,t){this.columns=this.processColumns(e),this.isFiltered=!1,this.slickgrid&&!t&&(this.slickgrid.setColumns(this.filterHiddenColumns(this.options.addSpacerColumn?this.columns.concat([this.$class.spacerColumnOps]):this.columns)),this.resetHSliders(),this.checkScroll(),this.options.scrollToRight&&this.scrollToRight())},setData:function(e){this.data=e,this.slickgrid&&(this.slickgrid.setData(e),this.resetHSliders(),this.checkScroll())},setOptions:function(e){this.options=$.extend(!0,{},this.$class.defaultOptions,e),this.slickgrid&&this.slickgrid.setOptions(this.options)},redraw:function(e){e?this.slickgrid.invalidateRows(e):this.slickgrid.invalidateAllRows(),this.slickgrid.render()},resetHSliders:function(){this.hSliderBottom.remove(),this.hSliderTop.remove(),this.hSliderBottom=this.hSliderTop=null},destroy:function(){this.slickgrid&&(this.slickgrid.destroy(),this.slickgrid=null),this.vSlider&&(this.vSlider.slider("destroy"),this.vSlider.remove(),this.vSlider=null),this.hSliderTop&&(this.hSliderTop.slider("destroy"),this.hSliderTop.remove(),this.hSliderTop=null),this.hSliderBottom&&(this.hSliderBottom.slider("destroy"),this.hSliderBottom.remove(),this.hSliderBottom=null),this.innerGridContainer.empty()},__classvars__:{defaultOptions:{enableCellNavigation:!1,enableColumnReorder:!1},spacerColumnOps:{id:"spacer",name:" ",autoWidth:!0},innerSlickGridHTML:'<div class="inner-slickgrid-container"></div>',defaultFormatter:function(e,t,i,s,n){var a=s.dataFormatter?s.dataFormatter.apply(this,arguments):i;return s.displayFormatter?s.displayFormatter.call(this,e,t,a,s,n):a},autosizeColumn:function(e,t,i,s){var n,a,r,o,l=$("<div/>").addClass("slick-cell").addClass("ui-widget").css({width:"auto",position:"absolute",top:1e3,left:0}).appendTo("body"),d=e[t],c=0;for(n=0;n<(i.getLength?i.getLength():i.length);n++)a=i.getItem?i.getItem(n):i[n],r=a[d.field],l.html(d.formatter?d.formatter(n,t,r,d,a):d.displayFormatter?d.displayFormatter(n,t,r,d,a):d.dataFormatter?d.dataFormatter(n,t,r,d,a):r),c=Math.max(c,l.outerWidth());o=c+(void 0!=s?s:0),l.remove(),d.width=void 0!==d.maxWidth?Math.min(o,d.maxWidth):o},linkSelectorFunction:function(e,t,i){var s,n,a,r={},o=$(e),l=o.offset(),d=$(),c=0;return r[e]||(r[e]=$(".slick-row",o).get(),r[e].sort(function(e,t){var i=$(e).offset().top,s=$(t).offset().top;return i<s?-1:i>s?1:0})),$.each(r[e],function(e,r){return n=$(r),!(n.offset().top>l.top&&(a=$(t,n),a.each(function(t,n){if(d=$(n),d.offset().left>l.left){if(void 0===s&&(s=Math.min(i,a.length-e)),c==s)return!1;c++}}),1))}),d}}})})}("function"==typeof define&&"object"==typeof define.amd?define:function(e,t){var i;for(i=0;i<e.length;i++)e[i]=this[e[i]];this.datagrid=t.apply(this,e)}),define("qTipsHelp",["classy","signals","qtips"],function(e,t){return e.$extend({__init__:function(){var e=this;this.tooltipsShown=!1,this.button=$("#help_button"),this.helpButtonClicked=new t.Signal,this.button.click(function(t){e.button.hasClass("disabled")||e.helpButtonClicked.dispatch()}),this.windowMouseDownHandler=function(t){var i=function(e){for(var i=t.target;i.parentNode;){if(i.parentNode==e)return!0;i=i.parentNode}return!1}(e.button.get(0));e.tooltipsShown&&!i&&e.hideHelpTooltips()}},toggleHelpTooltips:function(e){this.tooltipsShown?this.hideHelpTooltips():this.showHelpTooltips(e)},showHelpTooltips:function(e){var t=this;this.button.css("cursor","wait").addClass("selected");for(var i=0;i<e.length;i++){var s="function"==typeof e[i].selector?e[i].selector():$(e[i].selector);$.each($(s),function(s,n){$(n).is(":visible")&&($(n).attr("class",$(n).attr("class")+" help_target"),$(n).qtip({content:{prerender:!0,text:e[i].tip},show:"null",hide:"null",style:{tip:!0,name:"cream",width:e[i].width?e[i].width:250},position:{corner:{target:e[i].position,tooltip:t.$class.qtipsOpposite[e[i].position]},adjust:{x:e[i].xAdjust?e[i].xAdjust:0,y:e[i].yAdjust?e[i].yAdjust:0}}}))})}$(".help_target").qtip("show"),this.button.css("cursor","default"),$("body").width(Math.max($(window).width(),1600)).mousedown(this.windowMouseDownHandler),$(window).scrollLeft(($("body").width()-$(window).width())/2).resize(),this.tooltipsShown=!0},hideHelpTooltips:function(){this.button.removeClass("selected"),$(".qtip iframe").hide(),$(".help_target").removeClass("help_target").qtip("destroy"),$("body").width("100%").scroll().unbind("mousedown",this.windowMouseDownHandler),this.tooltipsShown=!1,$(window).resize()},__classvars__:{qtipsOpposite:{topLeft:"bottomRight",topMiddle:"bottomMiddle",topRight:"bottomLeft",bottomLeft:"topRight",bottomMiddle:"topMiddle",bottomRight:"topLeft",leftTop:"rightBottom",leftMiddle:"rightMiddle",leftBottom:"rightTop",rightTop:"leftBottom",rightMiddle:"leftMiddle",rightBottom:"leftTop",center:"center"}}})}),define("viewStack",["classy"],function(e){return e.$extend({__init__:function(e){this.container=e,this.viewNames=[],this.viewsMap={}},addView:function(e,t){return t||(t=$("<div/>").attr("id",e)),this.container.append(t),this.viewNames.push(e),this.viewsMap[e]=t,1==this.viewNames.length?this.setActiveView(e):this.positionView(t,!1),t},removeView:function(e){if(this.viewsMap.hasOwnProperty(e)){var t=this.viewsMap[e];delete this.viewsMap[e],this.viewNames.splice($.indexOf(this.viewNames,e),1),t.remove(),this.activeName==e&&this.viewNames.length>0&&this.setActiveView(this.viewNames[0])}},getView:function(e){return this.viewsMap[e]},hasView:function(e){return e in this.viewsMap},setActiveView:function(e){if(e!=this.activeName){if(!(e in this.viewsMap))throw new Error("Invalid View Name");this.activeName=e;for(var t in this.viewsMap)if(this.viewsMap.hasOwnProperty(t)){var i=this.viewsMap[t];this.positionView(i,t==e)}}},positionView:function(e,t){e.css({display:t?"block":"none"})}})}),define("js/view/mediators/Selection",["puremvc","js/Facade","js/model/ParameterProxy","js/model/ConfigProxy","js/model/TableDataProxy"],function(e,t,i,s,n){return e.Mediator.$extend({__init__:function(e){
this.$super(this.$class.NAME,e)},onRegister:function(){var e=this,a=this.facade.retrieveProxy(i.NAME),r=this.facade.retrieveProxy(s.NAME);this.facade.retrieveProxy(n.NAME);this.getViewComponent().create(a.getSelectedStudy(),r.getStudies(),a.getSelectedTable()),this.getViewComponent().tableSelectionChanged.add(function(i){e.sendNotification(t.TABLE_SELECTION_CHANGED,{id:i,newStudy:i.split("-")[1],oldStudy:a.getSelectedStudy().id},"TableChanged")})},listNotificationInterests:function(){return this.$super().concat([t.TABLE_PARAMS_UPDATED])},handleNotification:function(e){var a=this.facade.retrieveProxy(i.NAME),r=this.facade.retrieveProxy(s.NAME);this.facade.retrieveProxy(n.NAME);switch(e.getName()){case t.TABLE_PARAMS_UPDATED:this.getViewComponent().updateTableSelection(a.getSelectedStudy(),r.getStudies(),a.getSelectedTable());break;default:this.$super(e)}},__classvars__:{NAME:"SelectionMediator"}})}),define("js/view/mediators/TimeSelection",["puremvc","js/Facade","js/model/TableDataProxy","js/model/ConfigProxy","js/model/ParameterProxy"],function(e,t,i,s,n){return e.Mediator.$extend({__init__:function(e){this.$super(this.$class.NAME,e)},onRegister:function(){var e=this;this.getViewComponent().timeSelectionChanged.add(function(i,s){e.sendNotification(t.TIME_SELECTION_UPDATED,{start:i,end:s})}),this.getViewComponent().frequencySelectionChanged.add(function(i){e.sendNotification(t.FREQUENCY_SELECTION_UPDATED,{f:i},"FrequencyChanged")}),this.getViewComponent().visualizationSelectionChanged.add(function(i){var s={};s.ctype=i,e.sendNotification(t.CHART_SELECTION_UPDATED,s)})},listNotificationInterests:function(){return this.$super().concat([t.FREQUENCY_PARAM_UPDATED,t.TIME_PERIOD_PARAM_UPDATED,t.TABLEDATA_UPDATED,t.CHART_PARAMS_UPDATED,t.CTYPE_PARAM_UPDATED])},handleNotification:function(e){var a=this.facade.retrieveProxy(n.NAME),r=this.facade.retrieveProxy(i.NAME),o=(this.facade.retrieveProxy(s.NAME),a.getTimeParams());switch(e.getName()){case t.FREQUENCY_PARAM_UPDATED:case t.TIME_PERIOD_PARAM_UPDATED:case t.TABLEDATA_UPDATED:case t.CHART_PARAMS_UPDATED:case t.CTYPE_PARAM_UPDATED:if(!r.isUpdating){this.getViewComponent().isCreated?this.getViewComponent().updateTimeSelection(o.f,r.getDataColsNoGrowth(o.f),o.start,o.end,o.ctype):this.getViewComponent().create({},o.f,r.getDataColsNoGrowth(),o.start,o.end,o.ctype);for(var l=a.isMappable(a.getSelectedTable()),d=a.getPinnedIds(),c=0;c<d.length;c++)if(d[c]){var h=d[c].split(".")[1].split("-");h=h[1]+"-"+h[2],l=l||a.isMappable(a.getTableById(h))}this.getViewComponent().disableMapButton(!l)}break;default:this.$super(e)}},__classvars__:{NAME:"TimeSelectionMediator"}})}),define("js/view/mediators/CaseSelection",["puremvc","js/Facade","js/model/ParameterProxy","js/model/ConfigProxy"],function(e,t,i,s){return e.Mediator.$extend({__init__:function(e){this.$super(this.$class.NAME,e)},onRegister:function(){var e=this,n=this.facade.retrieveProxy(i.NAME),a=this.facade.retrieveProxy(s.NAME);this.getViewComponent().create(n.getSelectedStudy(),a.getStudies(),n.getSelectedTable(),n.getSelectedCases()),this.getViewComponent().caseSelectionChanged.add(function(i){e.sendNotification(t.CASE_SELECTION_CHANGED,{cases:i},"CasesChanged")})},listNotificationInterests:function(){return this.$super().concat([t.TABLE_PARAMS_UPDATED,t.CASE_PARAM_UPDATED])},handleNotification:function(e){var n=this.facade.retrieveProxy(i.NAME),a=this.facade.retrieveProxy(s.NAME);switch(e.getName()){case t.CASE_PARAM_UPDATED:case t.TABLE_PARAMS_UPDATED:this.getViewComponent().updateCaseSubtitle(n.getSelectedStudy(),a.getStudies(),n.getSelectedTable(),n.getSelectedCases());break;default:this.$super(e)}},__classvars__:{NAME:"CaseSelectionMediator"}})}),define("js/view/mediators/RegionSelection",["puremvc","js/Facade","js/model/ParameterProxy","js/model/ConfigProxy"],function(e,t,i,s){return e.Mediator.$extend({__init__:function(e){this.$super(this.$class.NAME,e)},onRegister:function(){var e=this,n=this.facade.retrieveProxy(i.NAME);this.facade.retrieveProxy(s.NAME);this.getViewComponent().create(n.getSelectedTable(),n.getSelectedRegion(),n.hasRegions(n.getSelectedTable())),this.getViewComponent().regionSelectionChanged.add(function(i){e.sendNotification(t.REGION_SELECTION_UPDATED,{region:i},"RegionSelectionUpdated")})},listNotificationInterests:function(){return this.$super().concat([t.TABLE_PARAMS_UPDATED,t.CASE_PARAM_UPDATED,t.REGION_PARAM_UPDATED])},handleNotification:function(e){var n=this.facade.retrieveProxy(i.NAME);this.facade.retrieveProxy(s.NAME);switch(e.getName()){case t.CASE_PARAM_UPDATED:case t.TABLE_PARAMS_UPDATED:case t.REGION_PARAM_UPDATED:if(this.getViewComponent().update(n.getSelectedTable(),n.getSelectedRegion(),n.hasRegions(n.getSelectedTable())),e.getName()==t.REGION_PARAM_UPDATED){var a=n.getSelectedRegion(),r=["linechart","map"],o={};for(var l in r){for(var d=n.getChartedIds(r[l]),c=n.getPinnedIds(),h=[],u=0;u<d.length;u++)if(""==d[u])h.push(d[u]);else{var p=d[u].split(".");p.length<=2?h.indexOf(d[u])<0&&h.push(d[u]):(newid="0.0"==a?p[0]+"."+p[1]:p[0]+"."+p[1]+"."+a,h.indexOf(newid)<0&&h.push(newid),c.indexOf(d[u])>=0&&h.indexOf(d[u])<0&&h.push(d[u]))}o[r[l]]=h.join("~")}var m=!1;for(var l in r)""!=o[r[l]]&&(m=!0);m&&this.sendNotification(t.CHART_SELECTION_UPDATED,o)}break;default:this.$super(e)}},__classvars__:{NAME:"RegionSelectionMediator"}})}),define("js/view/mediators/ViewStack",["puremvc","js/Facade","js/model/ConfigProxy","js/model/ParameterProxy"],function(e,t,i,s){return e.Mediator.$extend({__init__:function(e){this.$super(this.$class.NAME,e)},onRegister:function(){var e=this.facade.retrieveProxy(i.NAME);"function"==typeof e.setViews&&e.setViews(this.getViewComponent().viewNames)},listNotificationInterests:function(){return this.$super().concat([t.UPDATE_VISUALIZATION_VIEW_STACK])},handleNotification:function(e){var n=this.getViewComponent(),a=this.facade.retrieveProxy(s.NAME),r=this.facade.retrieveProxy(i.NAME);switch(e.getName()){case t.UPDATE_VISUALIZATION_VIEW_STACK:var o=a.getChartType();n.hasView(o)&&("function"==typeof r.setCurrentView&&r.setCurrentView(o),n.setActiveView(o));break;default:this.$super(e)}},__classvars__:{NAME:"ViewStackMediator"}})}),define("js/view/mediators/LineChart",["puremvc","js/Facade","js/model/TableDataProxy","js/model/ConfigProxy","js/model/ParameterProxy"],function(e,t,i,s,n){return e.Mediator.$extend({__init__:function(e){this.$super(this.$class.NAME,e)},onRegister:function(){var e=this;this.getViewComponent().indexingChanged.add(function(i){e.sendNotification(t.CHART_SELECTION_UPDATED,{chartindexed:i})})},listNotificationInterests:function(){return this.$super().concat([t.TABLEDATA_UPDATED,t.CHART_DATA_UPDATED,t.TIME_PERIOD_PARAM_UPDATED,t.UNLOAD,t.DOWNLOAD_OPTION_SELECTED])},handleNotification:function(e){for(var a=this.facade.retrieveProxy(i.NAME),r=this.facade.retrieveProxy(n.NAME),o=this.facade.retrieveProxy(s.NAME),l=r.getChartParams(),d=r.getChartType(),c=[],h=[],u=r.getChartedIds("linechart"),p=a.getTableData(),m=0;m<u.length;m++)for(var g in p){var f=[];$.isArray(p[g].uuid)?f=p[g].uuid:f.push(p[g].uuid);for(var v in f)if(u[m]&&f[v]==u[m]){var b,_;b=f[v].split(".")[0],_=f[v].split(".")[1].split("-"),_=_[1]+"-"+_[2];var C=r.getStudyByTableId(_),y=r.getTableById(_),T=r.hasRegions(y);if(T)for(var w=f[v].split(".")[2],A=0;A<y.regions.length;A++)y.regions[A].id==w&&h.indexOf(y.regions[A].title)<0&&h.push(y.regions[A].title);else h.push("");for(var A=0;A<C.cases.length;A++)C.cases[A].scenario==b.split("-")[0]&&c.indexOf(C.cases[A].description)<0&&c.push(C.cases[A].description)}}var S="";if(1==c.length&&(S=c[0]),S.length)var x="Case: "+S;else var x="";switch(1==h.length&&""!=h[0]&&(x.length&&(x+=" |  "),x+="Region: "+h[0]),e.getName()){case t.TABLEDATA_UPDATED:case t.CHART_DATA_UPDATED:if("linechart"==d||"pin"==d||"sourcekey"==d){var D=$.extend(!0,[],a.getChartData("linechart"));if(0==D.length){var E="";regionString=""}else if(1==D.length)oneSeriesObject=D[0],E=oneSeriesObject.chart_name;else{var P=[],M=[];for(oneSeries in D){oneSeriesObject=D[oneSeries];var N=oneSeriesObject.chart_name.split(": ");M.push(N),N.length>P.length&&(P=N)}var k="";for(onePiece in P){for(var I=!0,R=0;R<M.length;R++)if(P[onePiece]!=M[R][onePiece]){I=!1;break}if(!I)break;k.length&&(k+=": "),k+=P[onePiece]}if(k.length){E=k;for(oneSeries in D)oneSeriesObject=D[oneSeries],newSeriesName=oneSeriesObject.chart_name.substr(k.length+2),newSeriesName?oneSeriesObject.chart_name=newSeriesName:oneSeriesObject.chart_name="All"}else E="Custom Chart"}this.getViewComponent().update(E,D,a.getDataColumns(),"A",l.chartindexed,r.getTimeParams().start,r.getTimeParams().end,!1,!1,x,o.getStudies())}break;case t.TIME_PERIOD_PARAM_UPDATED:a.isUpdating||"linechart"!=d&&"pin"!=d&&"sourcekey"!=d||this.getViewComponent().setStartEnd(r.getTimeParams().start,r.getTimeParams().end,"A");break;case t.UNLOAD:this.getViewComponent().destroy();break;case t.DOWNLOAD_OPTION_SELECTED:"embed"==e.body.type?this.getViewComponent().embed():"linechart"==e.body.target&&this.getViewComponent().download(e.body.type);break;default:this.$super(e)}},__classvars__:{NAME:"ChartMediator"}})}),define("text!templates/pin_sourcekey_header.html",[],function(){return'<div class="pin_button {{#pin}}selected{{/pin}}">\r\n    <span class="ico"></span>\r\n    <span class="text">Pin</span>\r\n</div>\r\n<div class="api_button {{#sourcekey}}selected{{/sourcekey}}">\r\n    <span class="ico"></span>\r\n    <span class="text">API</span>\r\n</div>'}),define("js/view/mediators/DataGrid",["puremvc","js/Facade","js/model/ConfigProxy","js/model/ParameterProxy","js/model/TableDataProxy","js/view/components/DateCodeUtil","js/view/components/GridFormatters","datagrid","text!templates/pin_sourcekey_header.html"],function(e,t,i,s,n,a,r,o,l){return e.Mediator.$extend({__init__:function(e){this.$super(this.$class.NAME,e)},onRegister:function(){var e=this;this.getViewComponent().onClick.add(this.dataGridClick,this),$(this.getViewComponent().container).on("click",".slick-header-column.deselect_header",function(i){var n=e.facade.retrieveProxy(s.NAME).getChartType(),a={};a[n]="",e.sendNotification(t.CHART_SELECTION_UPDATED,a)}),$(this.getViewComponent().container).on("click",".pinkey_header .slick-column-name > div",function(i){var s={};s.sourcekey=$(i.currentTarget).hasClass("pin_button")?0:1,e.sendNotification(t.PIN_SOURCEKEY_SELECTED,s)}),$("#tableContainer").css("height",this.calculateDataTableHeight()+"px"),$(window).on("resize.datagrid",function(){e.resizeDataTable()})},listNotificationInterests:function(){return this.$super().concat([t.TABLEDATA_UPDATED,t.TIME_PERIOD_PARAM_UPDATED,t.CHART_DATA_UPDATED,t.DOWNLOAD_OPTION_SELECTED,t.UNLOAD,t.PIN_SOURCEKEY_PARAM_UPDATED,t.FREQUENCY_PARAM_UPDATED,t.CTYPE_PARAM_UPDATED])},handleNotification:function(e){this.getViewComponent();switch(e.getName()){case t.TABLEDATA_UPDATED:for(var a,o=this.facade.retrieveProxy(n.NAME),l=this.facade.retrieveProxy(s.NAME),d=(this.facade.retrieveProxy(i.NAME),l.getTimeParams()),c=o.getTableTitle(),h=o.getCombinedData(),u=o.data.tabledata.footnotes,p={},m=0;m<u.length&&"Btu"!=u[m].substring(0,3);m++)u[m].indexOf("<sup>")>=0?(a=u[m].split("</sup>"),p[a[0].split("<sup>")[1]]=$.trim(a[1]),a=a[0].split("<sup>")[1]):a&&(p[a]=p[a].concat(" "+u[m]));$(".pagecontent").off().on("mouseover","span.description_text_wrapper",function(e){if($(e.currentTarget).find("sup").length){var t=$(e.currentTarget).find("sup")[0].innerText;""!=t&&void 0!==t&&$(e.currentTarget).qtip({content:"Footnote "+t+": "+p[t],show:{when:!1,ready:!0},hide:"mouseout",position:{corner:{target:"topRight",tooltip:"bottomLeft"}},style:{name:"blue",width:500}})}});var g=this.generateColumns(o.getDataColumns(d.f),h,"A",o.getTableUnits(),c,l.getPinSourcekey());this.getViewComponent().update(h,g,{frozenColumn:2,dataItemColumnValueExtractor:function(e,t){return t&&t.field?r.nestedPropertyResolver(t.field,e):null},scrollToRight:!0,addSpacerColumn:!0,rowHeight:22},d.start,d.end),"map"==d.ctype&&$("div.deselect_header").css("display","none"),this.sendNotification(t.TABLE_RENDERED);break;case t.TIME_PERIOD_PARAM_UPDATED:var o=this.facade.retrieveProxy(n.NAME),l=this.facade.retrieveProxy(s.NAME);if(!o.isUpdating){var d=l.getTimeParams();this.getViewComponent().filterNumericColumns(d.start,d.end,!0),"map"==d.ctype&&$("div.deselect_header").css("display","none")}break;case t.FREQUENCY_PARAM_UPDATED:case t.CTYPE_PARAM_UPDATED:case t.PIN_SOURCEKEY_PARAM_UPDATED:var o=this.facade.retrieveProxy(n.NAME),l=this.facade.retrieveProxy(s.NAME);if(!o.isUpdating){var d=l.getTimeParams(),g=this.generateColumns(o.getDataColumns(d.f),o.getCombinedData(),"A",o.getTableUnits(),o.getTableTitle(),l.getPinSourcekey());this.getViewComponent().setColumns(g),this.getViewComponent().filterNumericColumns(d.start,d.end,!0),"map"==d.ctype&&$("div.deselect_header").css("display","none")}break;case t.CHART_DATA_UPDATED:this.getViewComponent().redraw();break;case t.DOWNLOAD_OPTION_SELECTED:if("table"==e.body.target&&"csv"==e.body.type){var o=this.facade.retrieveProxy(n.NAME),l=this.facade.retrieveProxy(s.NAME),f=this.getViewComponent().outputToArrOfArrs();f[0][1]="full name",f[0][2]="api key";for(var v=l.getPinnedIds(),b=[],_=0;_<o.combinedRows.length;_++){datum=o.combinedRows[_],'"true"'==f[1+_][1]&&(f[1+_][1]=f[1+_][0]);var C=document.createElement("div");C.innerHTML=datum.description,$("sup",$(C)).remove(),f[1+_][0]=C.textContent||C.innerText||"",datum.caseTitle&&(f[1+_][1]+=": "+datum.caseTitle),datum.series_id&&(f[1+_][2]+=datum.series_id)}for(var _=0;_<v.length;_++)v[_]&&b.push(v[_]);if(b.length)for(var _=0;_<b.length;_++)f[2+_][0]=o.combinedRows[1+_].description;var y=[['"'+o.getTableTitle()+'"'],['"'+window.location.href+'"'],['"'+Date()+'"'],['"Source: U.S. Energy Information Administration"']].concat(f);this.sendNotification(t.CSV_DATA_GENERATED,y)}break;case t.UNLOAD:this.getViewComponent().destroy();break;default:this.$super(e)}},generateColumns:function(e,t,n,l,d,c){var h,u,p=this.facade.retrieveProxy(s.NAME),m=(this.facade.retrieveProxy(i.NAME),p.getChartType());$(".description").length&&(u=$(".description").outerWidth());var g=[this.getPinSourcekeyColumn(parseInt(c)),{id:"description",name:"",field:"description",displayFormatter:r.descriptionFormatter,outputFormatter:this.$class.descriptionOutputFormatter,cssClass:"description aggregate",headerCssClass:"description",maxWidth:600,width:u||375},{id:m,field:"is_chartable",width:25,displayFormatter:r.chartButtonFormatter,output:!0,cssClass:"chart_column",iconClass:m,resizable:!1,headerCssClass:"deselect_header",toolTip:"Click to clear this table"},{id:"source key",name:"source key",field:"id",display:!1},{id:"units",name:"units",field:"units",display:!1}];for(o.autosizeColumn(g,0,t,5),h=0;h<e.length-1;h++){var f=parseInt(e[h]).toString();"NaN"==f&&(f="9999"),g.push({id:f,name:a.formatDateCode(f,n),field:"data."+f.toString(),displayFormatter:r.numericalDataFormatter,dataFormatter:null,f:n,width:70})}var v=e[e.length-1],b=v.split(" ");return v="Growth "+b[2],g.push({id:v,name:v,toolTip:"Growth Rate "+b[2],field:"data.9999",displayFormatter:null,dataFormatter:function(e,t,i,s,n){var a=r.numericalDataFormatter(e,t,i,s,n);return isNaN(parseFloat(a))?a:a+"%"},f:n,width:127,precision:1}),g},getPinSourcekeyColumn:function(e){return{id:e?"sourcekey":"pin",field:"series_id",width:40,displayFormatter:e?r.sourceKeyFormatter:r.pinSeriesFormatter,output:!1,cssClass:"chart_column",iconClass:e?"sourcekey":"pin",resizable:!1,headerCssClass:"pinkey_header",name:function(e){var t=e?{sourcekey:!0}:{pin:!0};return Mustache.render(l,t)}(e)}},dataGridClick:function(e,i,a){var r=this.getViewComponent(),o=r.columns,l=o[i].iconClass;if("linechart"==o[i].id||"map"==o[i].id||"pin"==o[i].id||"sourcekey"==o[i].id)if(a.ACTION){var d={};d[l]="",this.sendNotification(t.CHART_SELECTION_UPDATED,d)}else switch(o[i].id){case"linechart":var c=this.facade.retrieveProxy(n.NAME),h=this.facade.retrieveProxy(s.NAME);if(a.has_data){var d={};d[l]=h.getUpdatedCharted(a.uuid,l),d.ctype=o[i].id,this.sendNotification(t.CHART_SELECTION_UPDATED,d)}else{var c=this.facade.retrieveProxy(n.NAME),u=c.getChildData(e),p=!0,m=$.map(u,function(e){return e.has_data&&!e.linechart&&(p=!1),e.has_data?e.uuid:null});if(m.length>0){var d={};d[l]=h.getUpdatedCharted(m,l,p),this.sendNotification(t.CHART_SELECTION_UPDATED,d)}}break;case"map":if(a.is_mappable){var h=this.facade.retrieveProxy(s.NAME);if(a.has_data){var d={};d[l]=a.uuid,d.ctype=o[i].id,this.sendNotification(t.CHART_SELECTION_UPDATED,d)}}break;case"pin":var h=this.facade.retrieveProxy(s.NAME);if(a.uuid){var d={};d.sid=h.getUpdatedPinned(a.uuid),this.sendNotification(t.CHART_SELECTION_UPDATED,d)}break;case"sourcekey":this.sendNotification(t.SOURCE_KEY_SELECTED,a.series_id)}},calculateDataTableHeight:function(){return.85*$(window).height()},resizeDataTable:function(){$("#tableContainer").css("height",this.calculateDataTableHeight()+"px"),$(".inner-slickgrid-container").css("height",this.calculateDataTableHeight()+"px"),this.getViewComponent().slickgrid.resizeCanvas(),this.getViewComponent().checkScroll()},__classvars__:{NAME:"DataGridMediator",linkCellFormatter:function(e,t,i,s,n){return""!==i&&n.filterQuery?'<span class="link_cell">'+i+"</span>":i},descriptionOutputFormatter:function(e,t,i,s,n){return n.chart_name||i}}})}),define("js/view/mediators/HelpTooltip",["puremvc","js/Facade","js/model/HelpTooltipProxy"],function(e,t,i){return e.Mediator.$extend({__init__:function(e){this.$super(this.$class.NAME,e)},listNotificationInterests:function(){return this.$super().concat([t.UNLOAD])},onRegister:function(){var e=this;this.getViewComponent().helpButtonClicked.add(function(){var t=e.facade.retrieveProxy(i.NAME);e.getViewComponent().toggleHelpTooltips(t.getHelpTooltips())})},handleNotification:function(e){switch(e.getName()){case t.UNLOAD:this.getViewComponent().hideHelpTooltips();break;default:this.$super(e)}},onRemove:function(){this.$super(),this.getViewComponent().hideHelpTooltips()},__classvars__:{NAME:"HelpTooltipMediator"}})}),define("js/view/mediators/AnimatedMap",["puremvc","js/Facade","js/model/TableDataProxy","js/model/MapDataProxy","js/model/ConfigProxy","js/model/ParameterProxy","us-merc-en","coal-basin-merc-en"],function(e,t,i,s,n,a){return e.Mediator.$extend({__init__:function(e,t){this.$super(void 0===t?this.$class.NAME:t,e)},onRegister:function(){var e=this;this.viewComponent.mapTypeChangeRequested.add(function(i){e.sendNotification(t.MAP_TYPE_SELECTION_UPDATED,{maptype:i})})},listNotificationInterests:function(){return this.$super().concat([t.MAP_DATA_UPDATED,t.TIME_PARAMS_UPDATED,t.MAP_TYPE_PARAM_UPDATED,t.DOWNLOAD_OPTION_SELECTED,t.REGION_TYPE_PARAM_UPDATED,t.TIME_PERIOD_PARAM_UPDATED,t.CTYPE_PARAM_UPDATED,t.UNLOAD])},handleNotification:function(e){var r=this.facade.retrieveProxy(i.NAME),o=this.facade.retrieveProxy(a.NAME),l=this.facade.retrieveProxy(s.NAME);this.facade.retrieveProxy(n.NAME);switch(e.name){case t.TIME_PARAMS_UPDATED:case t.MAP_DATA_UPDATED:case t.MAP_TYPE_PARAM_UPDATED:case t.REGION_TYPE_PARAM_UPDATED:case t.TIME_PERIOD_PARAM_UPDATED:case t.CTYPE_PARAM_UPDATED:if(!r.isUpdating&&l.hasData){var d=o.getTimeParams(),c=l.getData(),h=[];$.each(c.data,function(e,t){h.push(e)}),this.viewComponent.update({DATA:c.data,DATACOLUMNS:h,PRECISION:c.precision,TITLE:c.title,UNITS:c.units},o.getMapType(),d.start,d.end,"A",{onRegionOver:function(e,t){return!0},regionStyle:{hover:{stroke:"#FFFF96","fill-opacity":1,"stroke-width":3,"stroke-opacity":1}}},"us_census_merc_en")}break;case t.DOWNLOAD_OPTION_SELECTED:if("map"==e.body.target&&"csv"==e.body.type){c=l.getData();var u=[['"'+c.title+'"'],['"'+window.location.href+'"'],['"'+Date()+'"'],['"Source: U.S. Energy Information Administration"']].concat(this.getViewComponent().outputToArrOfArrs());this.sendNotification(t.CSV_DATA_GENERATED,u)}else"map"==e.body.target&&"png"==e.body.type&&this.getViewComponent().map.exportMap(e.body.type);break;case t.UNLOAD:this.getViewComponent().destroy();break;default:this.$super(e)}},onRemove:function(){this.$super(),this.getViewComponent().destroy()},__classvars:{NAME:"AnimatedMapMediator"}})}),define("js/view/mediators/Download",["puremvc","js/Facade","js/model/ConfigProxy","js/model/ParameterProxy"],function(e,t,i,s){return e.Mediator.$extend({__init__:function(e){this.$super(this.$class.NAME,e)},onRegister:function(){var e=this;this.getViewComponent().downloadButtonClicked.add(function(t){var n=e.facade.retrieveProxy(s.NAME),a=e.facade.retrieveProxy(i.NAME);e.getViewComponent().showDownload(a.getDownloadParameters()[n.getChartType()])}),this.getViewComponent().downloadOptionClicked.add(function(i){e.getViewComponent().hideDownload(),e.sendNotification(t.DOWNLOAD_OPTION_SELECTED,i)})},__classvars__:{NAME:"DownloadMediator"}})}),define("js/view/mediators/Footnotes",["puremvc","js/Facade","js/model/TableDataProxy"],function(e,t,i){return e.Mediator.$extend({__init__:function(e){this.$super(this.$class.NAME,e)},onRegister:function(){var e=this.facade.retrieveProxy(i.NAME);this.getViewComponent().create(e.getFootnotes())},listNotificationInterests:function(){return this.$super().concat([t.TABLEDATA_UPDATED])},handleNotification:function(e){var s=this.facade.retrieveProxy(i.NAME);switch(e.getName()){case t.TABLEDATA_UPDATED:this.getViewComponent().updateFootnotes(s.getFootnotes());break;default:this.$super(e)}},__classvars__:{NAME:"FootnotesMediator"}})}),define("js/pages/DefaultPage",["hasher","signals","puremvc","classy","page","js/Facade","js/Controller","js/model/ConfigProxy","js/model/RequestProxy","js/model/ParameterProxy","js/model/TableDataProxy","js/model/HelpTooltipProxy","js/model/MapDataProxy","js/view/components/DateCodeUtil","js/view/components/GridFormatters","js/view/components/PageLayout","js/view/components/Selection","js/view/components/TimeSelection","js/view/components/CaseSelection","js/view/components/RegionSelection","js/view/components/LineChart","js/view/components/AnimatedMap","js/view/components/Download","js/view/components/Footnotes","datagrid","qTipsHelp","viewStack","js/view/mediators/Selection","js/view/mediators/TimeSelection","js/view/mediators/CaseSelection","js/view/mediators/RegionSelection","js/view/mediators/ViewStack","js/view/mediators/LineChart","js/view/mediators/DataGrid","js/view/mediators/HelpTooltip","js/view/mediators/AnimatedMap","js/view/mediators/Download","js/view/mediators/Footnotes","simpleModal"],function(e,t,i,s,n,a,r,o,l,d,c,h,u,p,m,g,f,v,b,_,C,y,T,w,A,S,x,D,E,P,M,N,k,I,R,O,U,j){var L=null,H=n.$extend({load:function(e){this.$super(e),n.clearErrorMessage(),L?L.sendNotification(F.RELOAD,e):(L=F.getInstance(this.name),L.sendNotification(F.STARTUP,e))},unload:function(){L.sendNotification(F.UNLOAD),F.removeCore(this.name),L=null,this.$super()}})("js/pages/defaultPage"),F=a.$extend({initializeController:function(){this.$super(),this.registerCommand(this.$class.STARTUP,B),this.registerCommand(this.$class.RELOAD,V),this.registerCommand(this.$class.TABLE_PARAMS_UPDATED,r.TableParamsUpdatedCommand),this.registerCommand(this.$class.TABLE_RENDERED,r.HideLoadMaskCommand),this.registerCommand(this.$class.CHART_DATA_UPDATED,W),this.registerCommand(this.$class.TABLEDATA_UPDATED,W),this.registerCommand(this.$class.TABLE_SELECTION_CHANGED,G),this.registerCommand(this.$class.CASE_SELECTION_CHANGED,Y),this.registerCommand(this.$class.TIME_SELECTION_UPDATED,z),this.registerCommand(this.$class.CHART_SELECTION_UPDATED,r.UpdateHashCommand),this.registerCommand(this.$class.PIN_SOURCEKEY_SELECTED,r.UpdateHashCommand),this.registerCommand(this.$class.CHART_PARAMS_UPDATED,r.UpdateChartDataCommand),this.registerCommand(this.$class.FREQUENCY_SELECTION_UPDATED,r.FrequencySelectionUpdatedCommand),this.registerCommand(this.$class.CSV_DATA_GENERATED,r.OutputToCSVCommand),this.registerCommand(this.$class.ERROR,r.ErrorCommand),this.registerCommand(this.$class.REGION_SELECTION_UPDATED,r.RegionSelectionUpdatedCommand),this.registerCommand(this.$class.MAP_TYPE_SELECTION_UPDATED,r.UpdateHashCommand),this.registerCommand(this.$class.SOURCE_KEY_SELECTED,r.OpenAPIWindowCommand)},__classvars__:{getInstance:function(e){return i.Facade.hasCore(e)||new F(e),i.Facade.getInstance(e)}}}),B=i.MacroCommand.$extend({initializeMacroCommand:function(e){this.addSubCommand(q),this.addSubCommand(Q),this.addSubCommand(r.UpdateParameterProxyCommand)}}),V=i.MacroCommand.$extend({initializeMacroCommand:function(){this.addSubCommand(r.UpdateRequestProxyCommand),this.addSubCommand(r.UpdateParameterProxyCommand)}}),q=i.SimpleCommand.$extend({execute:function(e){var t=new o;this.facade.registerProxy(t);var i=new l(e.getBody());this.facade.registerProxy(i);var s=new d;this.facade.registerProxy(s);var n=new c;this.facade.registerProxy(n);var a=new h;this.facade.registerProxy(a);var r=new u;this.facade.registerProxy(r),t.setVisualizations([{name:"visualizations",class:"linechart",description:"Time-series chart",label:"Time-series"},{name:"visualizations",class:"map",description:"U.S. map over time",label:"U.S. map"}]);var p={id:"csv_table",type:"csv",class:"ico_csv",target:"table",label:"Table (CSV)"};t.setDownloadParameters({map:window.SVGAngle?[{label:"Map",children:[{id:"map_png",type:"png",class:"ico_img",target:"map",label:"Map (PNG)"},{id:"map_embed",type:"embed",class:"ico_embed",target:"map",label:"Map Embed"}]},{label:"Data",children:[{id:"map_csv",type:"csv",class:"ico_csv",target:"map",label:"Map (CSV)"},p]}]:[{label:"Data",children:[{id:"map_csv",type:"csv",class:"ico_csv",target:"map",label:"Map (CSV)"},p]}],linechart:[{label:"Chart",children:[{id:"linechart_pdf",type:"pdf",class:"ico_pdf",target:"linechart",label:"PDF"},{id:"linechart_png",type:"png",class:"ico_img",target:"linechart",label:"PNG"},{id:"linechart_embed",type:"embed",class:"ico_embed",target:"linechart",label:"EMBED"}]},{label:"Data",children:[{id:"linechart_csv",type:"csv",class:"ico_csv",target:"linechart",label:"Chart (CSV)"},p]}]})}}),Q=i.SimpleCommand.$extend({execute:function(){var e=new g($("#pagecontent")),t=new X(e);this.facade.registerMediator(t)}}),G=i.MacroCommand.$extend({initializeMacroCommand:function(){this.addSubCommand(r.ResetRegionCommand),this.addSubCommand(r.ResetChartedCommand),this.addSubCommand(r.ResetChartindexedCommand),this.addSubCommand(r.ResetCaseCommand),this.addSubCommand(r.ResetFrequencyCommand),this.addSubCommand(r.FrequencySelectionUpdatedCommand),this.addSubCommand(r.UpdateHashCommand)}}),z=i.MacroCommand.$extend({initializeMacroCommand:function(){this.addSubCommand(r.UpdateHashCommand)}}),Y=i.MacroCommand.$extend({initializeMacroCommand:function(){this.addSubCommand(r.ResetChartedCommand),this.addSubCommand(r.UpdateHashCommand)}}),W=i.SimpleCommand.$extend({execute:function(e){var t=this.facade.retrieveProxy(d.NAME),i=this.facade.retrieveProxy(c.NAME),s=this.facade.retrieveProxy(u.NAME);"map"==t.getChartType()&&s.updateMapData(i.getChartData("map")[0])}}),X=i.Mediator.$extend({__init__:function(e){this.$super(this.$class.NAME,e)},onRegister:function(){var e=this.getViewComponent(),t=(this.facade.retrieveProxy(o.NAME),this.facade.retrieveProxy(l.NAME),this.facade.retrieveProxy(d.NAME),new A(e.getTableContainer())),i=new f(e.getSelectionContainer()),s=new v(e.getTimeSelectionContainer()),n=new b(e.getCaseSelectionContainer()),a=new _(e.getRegionSelectionContainer()),r=new S,c=new x(e.getChartContainer()),h=c.addView("linechart"),u=c.addView("map"),p=new C(h),m=new y(u),g=new T(e.getDownloadContainer()),$=new w(e.getFootnoteContainer()),L=new I(t),H=new D(i),F=new E(s),B=new P(n),V=new M(a),q=new R(r),Q=new N(c),G=new k(p),z=new O(m),Y=new U(g),W=new j($);this.facade.registerMediator(L),this.facade.registerMediator(H),this.facade.registerMediator(F),this.facade.registerMediator(B),this.facade.registerMediator(V),this.facade.registerMediator(q),this.facade.registerMediator(Q),this.facade.registerMediator(G),this.facade.registerMediator(z),this.facade.registerMediator(Y),this.facade.registerMediator(W)},listNotificationInterests:function(){return this.$super().concat([a.PARAMETER_PROXY_UPDATED,a.TABLEDATA_UPDATED,a.TABLE_RENDERED])},handleNotification:function(e){this.getViewComponent(),this.facade.retrieveProxy(l.NAME),this.facade.retrieveProxy(c.NAME),this.facade.retrieveProxy(d.NAME),this.facade.retrieveProxy(o.NAME);switch(e.getName()){case a.PARAMETER_PROXY_UPDATED:break;default:this.$super(e)}},__classvars__:{NAME:"PageMediator"}}),g=g.$extend({__init__:function(){this.$super($("#pagecontent"),{mainDownloadButtonOpts:{selected:!1,id:"main_download_button"},overlayDownloadButtonOpts:{selected:!0,id:"overlay_download_button"}})}});return H}),define("js/routes",["js/pages/DefaultPage"],{defaultHash:"",patterns:[{pattern:/.*/,moduleURI:"js/pages/DefaultPage"}]}),define("js/router",["js/routes","crossroads","hasher","page","text!status.json","json2"],function(e,t,i,s,n){function a(e,t){if(e.indexOf)return e.indexOf(t);for(var i=e.length;i--;)if(e[i]===t)return i;return-1}function r(e){for(var t,i=(e||"").replace("?","").split("&"),s=i.length,n={};s--;)i[s]=i[s].split("="),t=i[s][1],n[i[s][0]]=t;return n}function o(e,t){function i(t,s){if(t)if("object"==typeof t){var r={};$.extend(r,t,a.query),a.query=r}else"function"==typeof t?i(t.call(n,e,a),s):void 0==a[s]&&(a[s]=t)}var s,n=this,a={query:{}};for(s in t)t.hasOwnProperty(s)&&void 0!==t[s]&&(a[s]=t[s],("query"==s||"string"==typeof t[s]&&0==t[s].indexOf("?"))&&$.extend(a.query,r(t[s])));if(n.defaults)for(s in t)t.hasOwnProperty(s)&&i(n.defaults[s],s);return[a]}function l(e){var t,i,s;if(t=e.rules)for(i in t)t.hasOwnProperty(i)&&"normalize_"!=i&&(s=t[i],t[i]=function(t){return function(i,s,n){var r=!0;return t instanceof RegExp?r=t.test(i):t instanceof Array?r=-1!==a(t,i):t instanceof Function&&(r=t(i,s,n)),!r&&e.defaultHash&&(g=e.defaultHash),r}}(s));else t=e.rules={};return t.normalize_=function(t,i){return o.call(e,t,i)},e}function d(e,t){"undefined"!=typeof console&&"function"==typeof console.log&&console.log(e)}function c(i){var s;if(g){if(g==i)throw"Bad redirect hash: "+g;s=g,g=null,t.parse(s)}else t.parse(e.defaultHash)}function h(){var e=arguments;try{require([this.moduleURI],function(t){v!=t&&u();try{t.load.apply(t,e)}catch(i){if(f.debug)throw i;s.errorHandler({module:t.toString(),route:e[0],error:i.name+" "+i.message,stack:i.stack})}v=t})}catch(t){if(f.debug)throw t;s.errorHandler({module:this.moduleURI,route:e[0],error:t.name+" "+t.message,stack:t.stack})}}function u(){v&&(v.unload(),v=null)}function p(e,i,s){var n=t.addRoute(e);s&&(n.rules=s),n.matched.add(h,{moduleURI:i})}function m(){var s,n;for(s=0;s<e.patterns.length;s++)n=l(e.patterns[s]),p(n.pattern,n.moduleURI,n.rules);t.routed.add(d),t.bypassed.add(c),t.shouldTypecast=!0,i.initialized.add(t.parse,t),i.changed.add(t.parse,t),i.init(),""==i.getHash()&&e.defaultHash&&""!=e.defaultHash&&t.parse(e.defaultHash)}var g,f=JSON.parse(n),v=null;return{init:m}}),require(["js/router","page"],function(e,t){t.showLoadMask(),$(e.init)}),define("js/main",function(){});