UNPKG

turnilo

Version:

Business intelligence, data exploration and visualization web application for Druid, formerly known as Swiv and Pivot

2 lines 2.37 MB
/*! For license information please see main.js.LICENSE.txt */ !function(e){function t(t){for(var n,r,i=t[0],a=t[1],c=0,p=[];c<i.length;c++)r=i[c],Object.prototype.hasOwnProperty.call(o,r)&&o[r]&&p.push(o[r][0]),o[r]=0;for(n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n]);for(s&&s(t);p.length;)p.shift()()}var n={},r={6:0},o={6:0};function i(t){if(n[t])return n[t].exports;var r=n[t]={i:t,l:!1,exports:{}};return e[t].call(r.exports,r,r.exports,i),r.l=!0,r.exports}i.e=function(e){var t=[];r[e]?t.push(r[e]):0!==r[e]&&{0:1,1:1,2:1,3:1,5:1,7:1,8:1,9:1}[e]&&t.push(r[e]=new Promise((function(t,n){for(var o=({0:"default~bar-chart~grid~heatmap~line-chart~scatterplot~table~totals",1:"bar-chart",2:"grid",3:"heatmap",4:"highlighter",5:"line-chart",7:"scatterplot",8:"table",9:"totals",10:"vendors~heatmap",11:"vendors~highlighter",12:"vendors~iconv-lite"}[e]||e)+".css",a=i.p+o,c=document.getElementsByTagName("link"),p=0;p<c.length;p++){var s=(b=c[p]).getAttribute("data-href")||b.getAttribute("href");if("stylesheet"===b.rel&&(s===o||s===a))return t()}var u=document.getElementsByTagName("style");for(p=0;p<u.length;p++){var b;if((s=(b=u[p]).getAttribute("data-href"))===o||s===a)return t()}var M=document.createElement("link");M.rel="stylesheet",M.type="text/css";M.onerror=M.onload=function(o){if(M.onerror=M.onload=null,"load"===o.type)t();else{var i=o&&("load"===o.type?"missing":o.type),c=o&&o.target&&o.target.href||a,p=new Error("Loading CSS chunk "+e+" failed.\n("+c+")");p.code="CSS_CHUNK_LOAD_FAILED",p.type=i,p.request=c,delete r[e],M.parentNode.removeChild(M),n(p)}},M.href=a,document.head.appendChild(M)})).then((function(){r[e]=0})));var n=o[e];if(0!==n)if(n)t.push(n[2]);else{var a=new Promise((function(t,r){n=o[e]=[t,r]}));t.push(n[2]=a);var c,p=document.createElement("script");p.charset="utf-8",p.timeout=120,i.nc&&p.setAttribute("nonce",i.nc),p.src=function(e){return i.p+""+({0:"default~bar-chart~grid~heatmap~line-chart~scatterplot~table~totals",1:"bar-chart",2:"grid",3:"heatmap",4:"highlighter",5:"line-chart",7:"scatterplot",8:"table",9:"totals",10:"vendors~heatmap",11:"vendors~highlighter",12:"vendors~iconv-lite"}[e]||e)+".3630a1be5ee7fd1212b2.js"}(e);var s=new Error;c=function(t){p.onerror=p.onload=null,clearTimeout(u);var n=o[e];if(0!==n){if(n){var r=t&&("load"===t.type?"missing":t.type),i=t&&t.target&&t.target.src;s.message="Loading chunk "+e+" failed.\n("+r+": "+i+")",s.name="ChunkLoadError",s.type=r,s.request=i,n[1](s)}o[e]=void 0}};var u=setTimeout((function(){c({type:"timeout",target:p})}),12e4);p.onerror=p.onload=c,document.head.appendChild(p)}return Promise.all(t)},i.m=e,i.c=n,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)i.d(n,r,function(t){return e[t]}.bind(null,r));return n},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i.oe=function(e){throw console.error(e),e};var a=window.webpackJsonp=window.webpackJsonp||[],c=a.push.bind(a);a.push=t,a=a.slice();for(var p=0;p<a.length;p++)t(a[p]);var s=c;i(i.s=470)}([function(e,t,n){"use strict";e.exports=n(297)},function(e,t,n){"use strict";function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}n.d(t,"a",(function(){return r}))},function(e,t,n){"use strict";var r=n(5),o=n(307),i=n(308),a=n(312),c=a.Readable,p=a.Writable,s=a.Transform,u=a.PassThrough,b=n(47),M=b.generalEqual,l=b.generalLookupsEqual,f=b.isImmutableClass,z=b.immutableEqual,d=b.immutableArraysEqual,O=b.immutableLookupsEqual,h=b.SimpleArray,A=b.NamedArray,q=n(11),m=q.Timezone,g=q.Duration,v=q.moment,y=q.isDate,W=q.parseISODate,w={},R=(t.version="0.21.10",t.verboseRequesterFactory=function(e){var t=e.requester,n=e.name||"rq"+String(Math.random()).substr(2,5);e.preQuery&&(console.warn("verboseRequesterFactory option preQuery has been renamed to onQuery"),e.onQuery=e.preQuery);var r=e.printLine||function(e){console.log(e)},o=e.onQuery||function(e){r("vvvvvvvvvvvvvvvvvvvvvvvvvv");var t=e.context?" [context: "+JSON.stringify(e.context)+"]":"";r("Requester "+e.name+" sending query "+e.queryNumber+":"+t),r(JSON.stringify(e.query,null,2)),r("^^^^^^^^^^^^^^^^^^^^^^^^^^")},i=e.onSuccess||function(e){r("vvvvvvvvvvvvvvvvvvvvvvvvvv"),r("Requester "+e.name+" got result from query "+e.queryNumber+": (in "+e.time+"ms)"),r(JSON.stringify(e.data,null,2)),r("^^^^^^^^^^^^^^^^^^^^^^^^^^")},a=e.onError||function(e){r("vvvvvvvvvvvvvvvvvvvvvvvvvv"),r("Requester "+e.name+" got error in query "+e.queryNumber+": "+e.error.message+" (in "+e.time+"ms)"),r("^^^^^^^^^^^^^^^^^^^^^^^^^^")},c=0;return function(e){var r=++c;o({name:n,queryNumber:r,query:e.query,context:e.context});var p=Date.now(),s=t(e),u=!1;s.on("error",(function(t){u=!0,a({name:n,queryNumber:r,query:e.query,context:e.context,time:Date.now()-p,error:t})}));var b=[];return s.on("data",(function(e){b.push(JSON.parse(JSON.stringify(e)))})),s.on("end",(function(){u||i({name:n,queryNumber:r,query:e.query,context:e.context,time:Date.now()-p,data:b})})),s}},t.retryRequesterFactory=function(e){var t=e.requester,n=e.delay||500,r=e.retry||3,o=Boolean(e.retryOnTimeout);if("number"!=typeof n)throw new TypeError("delay should be a number");if("number"!=typeof r)throw new TypeError("retry should be a number");return function(e){var i=0,a=!1,c=new u({objectMode:!0});return function p(){i++;var s=!1,u=!1,b=t(e);b.on("error",(function(e){u=!0,s||i>r||"timeout"===e.message&&!o?(b.unpipe(c),c.emit("error",e),a=!0,c.end()):setTimeout(p,n)})),b.on("meta",(function(e){c.emit("meta",e)})),b.on("data",(function(e){s=!0})),b.on("end",(function(){a||u||c.end()})),b.pipe(c,{end:!1})}(),c}},t.concurrentLimitRequesterFactory=function(e){var t=e.requester,n=e.concurrentLimit||5;if("number"!=typeof n)throw new TypeError("concurrentLimit should be a number");var r=[],o=0;function i(){if(o--,r.length&&o<n){var e=r.shift();o++;var a=t(e.request);a.on("error",i),a.on("end",i),j(a,e.stream)}}return function(e){if(o<n)return o++,(a=t(e)).on("error",i),a.on("end",i),a;var a=new u({objectMode:!0});return r.push({request:e,stream:a}),a}},t.promiseWhile=function(e,t){var n=function(){return e()?Promise.resolve(t()).then(n):Promise.resolve(null)};return Promise.resolve(null).then(n)}),_=function(e){function t(t,n){void 0===n&&(n={});var r=e.call(this,n)||this,o="string"==typeof t?new Error(t):t;return setTimeout((function(){r.emit("error",o)}),1),r}return r.__extends(t,e),t.prototype._read=function(){},t}(c);t.ReadableError=_;var L=function(e){function t(t){var n=e.call(this,t)||this;return n.next=t.next,n.currentStream=null,n.streamIndex=0,n._nextStream(),n}return r.__extends(t,e),t.prototype._nextStream=function(){var e=this;this.currentStream=null,this.currentStream=this.next(),null==this.currentStream?this.push(null):(this.currentStream.pipe(this,{end:!1}),this.currentStream.on("error",(function(t){return e.emit("error",t)})),this.currentStream.on("end",this._nextStream.bind(this)))},t}(u);t.StreamConcat=L;var E=t.repeat=function(e,t){return new Array(t+1).join(e)},S=t.indentBy=function(e,t){var n=E(" ",t);return e.split("\n").map((function(e){return n+e})).join("\n")},T=t.dictEqual=function(e,t){if(e===t)return!0;if(!e!=!t)return!1;var n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(var r=0,o=n;r<o.length;r++){var i=o[r];if(e[i]!==t[i])return!1}return!0},N=t.shallowCopy=function(e){var t={};for(var n in e)o(e,n)&&(t[n]=e[n]);return t},x=t.deduplicateSort=function(e){for(var t=[],n=null,r=0,o=e=e.sort();r<o.length;r++){var i=o[r];i!==n&&t.push(i),n=i}return t},B=(t.mapLookup=function(e,t){var n=Object.create(null);for(var r in e)o(e,r)&&(n[r]=t(e[r]));return n},t.emptyLookup=function(e){for(var t in e)if(o(e,t))return!1;return!0}),C=t.nonEmptyLookup=function(e){return!B(e)},k=t.clip=function(e){var t=Math.round(e);return Math.abs(e-t)<1e-5?t:e},X=(t.safeAdd=function(e,t){var n=String(t),r=n.indexOf(".");if(-1===r||18===n.length)return e+t;var o=Math.pow(10,n.length-r-1);return(e*o+t*o)/o},t.safeRange=function(e,t){var n=String(t),r=n.indexOf(".");if(-1===r||18===n.length)return{start:e,end:e+t};var o=Math.pow(10,n.length-r-1);return{start:e=k(e*o)/o,end:(e*o+t*o)/o}}),D=t.continuousFloorExpression=function(e,t,n,r){var o=e;return 0!==r&&(o=o+" - "+r),0!==r&&1!==n&&(o="("+o+")"),1!==n&&(o=o+" / "+n),o=t+"("+o+")",1!==n&&(o=o+" * "+n),0!==r&&(o=o+" + "+r),o},I=function(e){function t(t){var n=e.call(this,t)||this;return n.name=n.constructor.name,n.message=t,"function"==typeof Error.captureStackTrace?Error.captureStackTrace(n,n.constructor):n.stack=new Error(t).stack,n}return r.__extends(t,e),t}(Error);t.ExtendableError=I;var P=t.pluralIfNeeded=function(e,t){return e+" "+t+(1===e?"":"s")},j=t.pipeWithError=function(e,t){return e.pipe(t),e.on("error",(function(e){return t.emit("error",e)})),t},U=function(){function e(){this.escapedTableName=null}return e.prototype.setTable=function(e){this.escapedTableName=e?this.escapeName(e):null},e.prototype.nullConstant=function(){return"NULL"},e.prototype.constantGroupBy=function(){return"GROUP BY ''"},e.prototype.escapeName=function(e){return'"'+(e=e.replace(/"/g,'""'))+'"'},e.prototype.maybeNamespacedName=function(e){var t=this.escapeName(e);return this.escapedTableName?this.escapedTableName+"."+t:t},e.prototype.escapeLiteral=function(e){return null===e?this.nullConstant():"'"+(e=e.replace(/'/g,"''"))+"'"},e.prototype.booleanToSQL=function(e){return(""+e).toUpperCase()},e.prototype.floatDivision=function(e,t){return"("+e+"/"+t+")"},e.prototype.numberOrTimeToSQL=function(e){return null===e?this.nullConstant():e.toISOString?this.timeToSQL(e):this.numberToSQL(e)},e.prototype.numberToSQL=function(e){return null===e?this.nullConstant():""+e},e.prototype.dateToSQLDateString=function(e){return e.toISOString().replace("T"," ").replace("Z","").replace(/\.000$/,"").replace(/ 00:00:00$/,"")},e.prototype.aggregateFilterIfNeeded=function(e,t,n){void 0===n&&(n=null);var r=e.indexOf(" WHERE ");if(-1===r)return t;var o=e.substr(r+7);return this.ifThenElseExpression(o,t,n)},e.prototype.concatExpression=function(e,t){throw new Error("must implement")},e.prototype.containsExpression=function(e,t){throw new Error("must implement")},e.prototype.substrExpression=function(e,t,n){return"SUBSTR("+e+","+(t+1)+","+n+")"},e.prototype.coalesceExpression=function(e,t){return"COALESCE("+e+", "+t+")"},e.prototype.ifThenElseExpression=function(e,t,n){return void 0===n&&(n=null),"CASE WHEN "+e+" THEN "+t+(null!=n?" ELSE "+n:"")+" END"},e.prototype.isNotDistinctFromExpression=function(e,t){var n=this.nullConstant();return e===n?t+" IS "+n:t===n?e+" IS "+n:"("+e+" IS NOT DISTINCT FROM "+t+")"},e.prototype.regexpExpression=function(e,t){return"("+e+" REGEXP "+this.escapeLiteral(t)+")"},e.prototype.inExpression=function(e,t,n,r){if(t===n&&"[]"===r)return e+"="+t;var o=null;t!==this.nullConstant()&&(o=t+("["===r[0]?"<=":"<")+e);var i=null;return n!==this.nullConstant()&&(i=e+("]"===r[1]?"<=":"<")+n),o?i?"("+o+" AND "+i+")":o:i||"TRUE"},e.prototype.lengthExpression=function(e){return"CHAR_LENGTH("+e+")"},e.prototype.logExpression=function(e,t){return e===String(Math.E)?"LN("+t+")":"LOG("+e+","+t+")"},e}();t.SQLDialect=U;var F=function(e){function t(){return e.call(this)||this}return r.__extends(t,e),t.prototype.escapeName=function(e){return"`"+(e=e.replace(/`/g,"``"))+"`"},t.prototype.escapeLiteral=function(e){return null===e?this.nullConstant():JSON.stringify(e)},t.prototype.timeToSQL=function(e){return e?"TIMESTAMP('"+this.dateToSQLDateString(e)+"')":this.nullConstant()},t.prototype.concatExpression=function(e,t){return"CONCAT("+e+","+t+")"},t.prototype.containsExpression=function(e,t){return"LOCATE("+e+","+t+")>0"},t.prototype.isNotDistinctFromExpression=function(e,t){return"("+e+"<=>"+t+")"},t.prototype.castExpression=function(e,n,r){var o=t.CAST_TO_FUNCTION[r][e];if(!o)throw new Error("unsupported cast from "+e+" to "+r+" in MySQL dialect");return o.replace(/\$\$/g,n)},t.prototype.utcToWalltime=function(e,t){return t.isUTC()?e:"CONVERT_TZ("+e+",'+0:00','"+t+"')"},t.prototype.walltimeToUTC=function(e,t){return t.isUTC()?e:"CONVERT_TZ("+e+",'"+t+"','+0:00')"},t.prototype.timeFloorExpression=function(e,n,r){var o=t.TIME_BUCKETING[n.toString()];if(!o)throw new Error("unsupported duration '"+n+"'");return this.walltimeToUTC("DATE_FORMAT("+this.utcToWalltime(e,r)+",'"+o+"')",r)},t.prototype.timeBucketExpression=function(e,t,n){return this.timeFloorExpression(e,t,n)},t.prototype.timePartExpression=function(e,n,r){var o=t.TIME_PART_TO_FUNCTION[n];if(!o)throw new Error("unsupported part "+n+" in MySQL dialect");return o.replace(/\$\$/g,this.utcToWalltime(e,r))},t.prototype.timeShiftExpression=function(e,t,n,r){if(0===n)return e;var o=n>0?"DATE_ADD(":"DATE_SUB(",i=t.multiply(Math.abs(n)).valueOf();if(i.week)return o+e+", INTERVAL "+String(i.week)+" WEEK)";(i.year||i.month)&&(e=o+e+", INTERVAL '"+(String(i.year||0)+"-"+String(i.month||0))+"' YEAR_MONTH)");(i.day||i.hour||i.minute||i.second)&&(e=o+e+", INTERVAL '"+(String(i.day||0)+" "+[i.hour||0,i.minute||0,i.second||0].join(":"))+"' DAY_SECOND)");return e},t.prototype.extractExpression=function(e,t){throw new Error("MySQL must implement extractExpression (https://github.com/mysqludf/lib_mysqludf_preg)")},t.prototype.indexOfExpression=function(e,t){return"LOCATE("+t+", "+e+") - 1"},t.TIME_BUCKETING={PT1S:"%Y-%m-%d %H:%i:%SZ",PT1M:"%Y-%m-%d %H:%i:00Z",PT1H:"%Y-%m-%d %H:00:00Z",P1D:"%Y-%m-%d 00:00:00Z",P1M:"%Y-%m-01 00:00:00Z",P1Y:"%Y-01-01 00:00:00Z"},t.TIME_PART_TO_FUNCTION={SECOND_OF_MINUTE:"SECOND($$)",SECOND_OF_HOUR:"(MINUTE($$)*60+SECOND($$))",SECOND_OF_DAY:"((HOUR($$)*60+MINUTE($$))*60+SECOND($$))",SECOND_OF_WEEK:"(((WEEKDAY($$)*24)+HOUR($$)*60+MINUTE($$))*60+SECOND($$))",SECOND_OF_MONTH:"((((DAYOFMONTH($$)-1)*24)+HOUR($$)*60+MINUTE($$))*60+SECOND($$))",SECOND_OF_YEAR:"((((DAYOFYEAR($$)-1)*24)+HOUR($$)*60+MINUTE($$))*60+SECOND($$))",MINUTE_OF_HOUR:"MINUTE($$)",MINUTE_OF_DAY:"HOUR($$)*60+MINUTE($$)",MINUTE_OF_WEEK:"(WEEKDAY($$)*24)+HOUR($$)*60+MINUTE($$)",MINUTE_OF_MONTH:"((DAYOFMONTH($$)-1)*24)+HOUR($$)*60+MINUTE($$)",MINUTE_OF_YEAR:"((DAYOFYEAR($$)-1)*24)+HOUR($$)*60+MINUTE($$)",HOUR_OF_DAY:"HOUR($$)",HOUR_OF_WEEK:"(WEEKDAY($$)*24+HOUR($$))",HOUR_OF_MONTH:"((DAYOFMONTH($$)-1)*24+HOUR($$))",HOUR_OF_YEAR:"((DAYOFYEAR($$)-1)*24+HOUR($$))",DAY_OF_WEEK:"(WEEKDAY($$)+1)",DAY_OF_MONTH:"DAYOFMONTH($$)",DAY_OF_YEAR:"DAYOFYEAR($$)",WEEK_OF_YEAR:"WEEK($$)",MONTH_OF_YEAR:"MONTH($$)",YEAR:"YEAR($$)"},t.CAST_TO_FUNCTION={TIME:{NUMBER:"FROM_UNIXTIME($$ / 1000)"},NUMBER:{TIME:"UNIX_TIMESTAMP($$) * 1000",STRING:"CAST($$ AS SIGNED)"},STRING:{NUMBER:"CAST($$ AS CHAR)"}},t}(U);t.MySQLDialect=F;var H=function(e){function t(){return e.call(this)||this}return r.__extends(t,e),t.prototype.constantGroupBy=function(){return"GROUP BY ''=''"},t.prototype.timeToSQL=function(e){return e?"TIMESTAMP '"+this.dateToSQLDateString(e)+"'":this.nullConstant()},t.prototype.concatExpression=function(e,t){return"("+e+"||"+t+")"},t.prototype.containsExpression=function(e,t){return"POSITION("+e+" IN "+t+")>0"},t.prototype.regexpExpression=function(e,t){return"("+e+" ~ '"+t+"')"},t.prototype.castExpression=function(e,n,r){var o=t.CAST_TO_FUNCTION[r][e];if(!o)throw new Error("unsupported cast from "+e+" to "+r+" in Postgres dialect");return o.replace(/\$\$/g,n)},t.prototype.utcToWalltime=function(e,t){return t.isUTC()?e:"("+e+" AT TIME ZONE 'UTC' AT TIME ZONE '"+t+"')"},t.prototype.walltimeToUTC=function(e,t){return t.isUTC()?e:"("+e+" AT TIME ZONE '"+t+"' AT TIME ZONE 'UTC')"},t.prototype.timeFloorExpression=function(e,n,r){var o=t.TIME_BUCKETING[n.toString()];if(!o)throw new Error("unsupported duration '"+n+"'");return this.walltimeToUTC("DATE_TRUNC('"+o+"',"+this.utcToWalltime(e,r)+")",r)},t.prototype.timeBucketExpression=function(e,t,n){return this.timeFloorExpression(e,t,n)},t.prototype.timePartExpression=function(e,n,r){var o=t.TIME_PART_TO_FUNCTION[n];if(!o)throw new Error("unsupported part "+n+" in Postgres dialect");return o.replace(/\$\$/g,this.utcToWalltime(e,r))},t.prototype.timeShiftExpression=function(e,t,n,r){if(0===n)return e;var o=n>0?"DATE_ADD(":"DATE_SUB(",i=t.multiply(Math.abs(n)).valueOf();if(i.week)return o+e+", INTERVAL "+String(i.week)+" WEEK)";(i.year||i.month)&&(e=o+e+", INTERVAL '"+(String(i.year||0)+"-"+String(i.month||0))+"' YEAR_MONTH)");(i.day||i.hour||i.minute||i.second)&&(e=o+e+", INTERVAL '"+(String(i.day||0)+" "+[i.hour||0,i.minute||0,i.second||0].join(":"))+"' DAY_SECOND)");return e},t.prototype.extractExpression=function(e,t){return"(SELECT (REGEXP_MATCHES("+e+", '"+t+"'))[1])"},t.prototype.indexOfExpression=function(e,t){return"POSITION("+t+" IN "+e+") - 1"},t.TIME_BUCKETING={PT1S:"second",PT1M:"minute",PT1H:"hour",P1D:"day",P1W:"week",P1M:"month",P3M:"quarter",P1Y:"year"},t.TIME_PART_TO_FUNCTION={SECOND_OF_MINUTE:"DATE_PART('second',$$)",SECOND_OF_HOUR:"(DATE_PART('minute',$$)*60+DATE_PART('second',$$))",SECOND_OF_DAY:"((DATE_PART('hour',$$)*60+DATE_PART('minute',$$))*60+DATE_PART('second',$$))",SECOND_OF_WEEK:"((((CAST((DATE_PART('dow',$$)+6) AS int)%7)*24)+DATE_PART('hour',$$)*60+DATE_PART('minute',$$))*60+DATE_PART('second',$$))",SECOND_OF_MONTH:"((((DATE_PART('day',$$)-1)*24)+DATE_PART('hour',$$)*60+DATE_PART('minute',$$))*60+DATE_PART('second',$$))",SECOND_OF_YEAR:"((((DATE_PART('doy',$$)-1)*24)+DATE_PART('hour',$$)*60+DATE_PART('minute',$$))*60+DATE_PART('second',$$))",MINUTE_OF_HOUR:"DATE_PART('minute',$$)",MINUTE_OF_DAY:"DATE_PART('hour',$$)*60+DATE_PART('minute',$$)",MINUTE_OF_WEEK:"((CAST((DATE_PART('dow',$$)+6) AS int)%7)*24)+DATE_PART('hour',$$)*60+DATE_PART('minute',$$)",MINUTE_OF_MONTH:"((DATE_PART('day',$$)-1)*24)+DATE_PART('hour',$$)*60+DATE_PART('minute',$$)",MINUTE_OF_YEAR:"((DATE_PART('doy',$$)-1)*24)+DATE_PART('hour',$$)*60+DATE_PART('minute',$$)",HOUR_OF_DAY:"DATE_PART('hour',$$)",HOUR_OF_WEEK:"((CAST((DATE_PART('dow',$$)+6) AS int)%7)*24+DATE_PART('hour',$$))",HOUR_OF_MONTH:"((DATE_PART('day',$$)-1)*24+DATE_PART('hour',$$))",HOUR_OF_YEAR:"((DATE_PART('doy',$$)-1)*24+DATE_PART('hour',$$))",DAY_OF_WEEK:"(CAST((DATE_PART('dow',$$)+6) AS int)%7)+1",DAY_OF_MONTH:"DATE_PART('day',$$)",DAY_OF_YEAR:"DATE_PART('doy',$$)",WEEK_OF_YEAR:"DATE_PART('week',$$)",MONTH_OF_YEAR:"DATE_PART('month',$$)",YEAR:"DATE_PART('year',$$)"},t.CAST_TO_FUNCTION={TIME:{NUMBER:"TO_TIMESTAMP($$::double precision / 1000)"},NUMBER:{TIME:"EXTRACT(EPOCH FROM $$) * 1000",STRING:"$$::float"},STRING:{NUMBER:"$$::text"}},t}(U);t.PostgresDialect=H;var G=function(e){function t(){return e.call(this)||this}return r.__extends(t,e),t.prototype.dateToSQLDateString=function(e){return e.toISOString().replace("T"," ").replace("Z","").replace(/\.000$/,"")},t.prototype.floatDivision=function(e,t){return"("+e+"*1.0/"+t+")"},t.prototype.constantGroupBy=function(){return"GROUP BY ''"},t.prototype.timeToSQL=function(e){return e?"TIMESTAMP '"+this.dateToSQLDateString(e)+"'":this.nullConstant()},t.prototype.concatExpression=function(e,t){return"("+e+"||"+t+")"},t.prototype.containsExpression=function(e,t){return"POSITION("+e+" IN "+t+")>0"},t.prototype.substrExpression=function(e,t,n){return"SUBSTRING("+e+","+(t+1)+","+n+")"},t.prototype.isNotDistinctFromExpression=function(e,t){var n=this.nullConstant();return e===n?t+" IS "+n:t===n?e+" IS "+n:"("+e+"="+t+")"},t.prototype.castExpression=function(e,n,r){var o=t.CAST_TO_FUNCTION[r][e];if(!o)throw new Error("unsupported cast from "+e+" to "+r+" in Druid dialect");return o.replace(/\$\$/g,n)},t.prototype.operandAsTimestamp=function(e){return e.includes("__time")?e:"TIME_PARSE("+e+")"},t.prototype.timeFloorExpression=function(e,t,n){return"TIME_FLOOR("+this.operandAsTimestamp(e)+", "+this.escapeLiteral(t.toString())+", NULL, "+this.escapeLiteral(n.toString())+")"},t.prototype.timeBucketExpression=function(e,t,n){return this.timeFloorExpression(e,t,n)},t.prototype.timePartExpression=function(e,n,r){var o=t.TIME_PART_TO_FUNCTION[n];if(!o)throw new Error("unsupported part "+n+" in Druid dialect");return o.replace(/\$\$/g,this.operandAsTimestamp(e)).replace(/##/g,this.escapeLiteral(r.toString()))},t.prototype.timeShiftExpression=function(e,t,n,r){return"TIME_SHIFT("+this.operandAsTimestamp(e)+", "+this.escapeLiteral(t.toString())+", "+n+", "+this.escapeLiteral(r.toString())+")"},t.prototype.extractExpression=function(e,t){return"REGEXP_EXTRACT("+e+", "+this.escapeLiteral(t)+", 1)"},t.prototype.regexpExpression=function(e,t){return"REGEXP_LIKE("+e+", "+this.escapeLiteral(t)+")"},t.prototype.indexOfExpression=function(e,t){return"POSITION("+t+" IN "+e+") - 1"},t.prototype.logExpression=function(e,t){return e===String(Math.E)?"LN("+t+")":"10"===e?"LOG10("+t+")":"LN("+t+")/LN("+e+")"},t.TIME_PART_TO_FUNCTION={SECOND_OF_MINUTE:"TIME_EXTRACT($$,'SECOND',##)",SECOND_OF_HOUR:"(TIME_EXTRACT($$,'MINUTE',##)*60+TIME_EXTRACT($$,'SECOND',##))",SECOND_OF_DAY:"((TIME_EXTRACT($$,'HOUR',##)*60+TIME_EXTRACT($$,'MINUTE',##))*60+TIME_EXTRACT($$,'SECOND',##))",SECOND_OF_WEEK:"(((MOD(CAST((TIME_EXTRACT($$,'DOW',##)+6) AS int),7)*24)+TIME_EXTRACT($$,'HOUR',##)*60+TIME_EXTRACT($$,'MINUTE',##))*60+TIME_EXTRACT($$,'SECOND',##))",SECOND_OF_MONTH:"((((TIME_EXTRACT($$,'DAY',##)-1)*24)+TIME_EXTRACT($$,'HOUR',##)*60+TIME_EXTRACT($$,'MINUTE',##))*60+TIME_EXTRACT($$,'SECOND',##))",SECOND_OF_YEAR:"((((TIME_EXTRACT($$,'DOY',##)-1)*24)+TIME_EXTRACT($$,'HOUR',##)*60+TIME_EXTRACT($$,'MINUTE',##))*60+TIME_EXTRACT($$,'SECOND',##))",MINUTE_OF_HOUR:"TIME_EXTRACT($$,'MINUTE',##)",MINUTE_OF_DAY:"TIME_EXTRACT($$,'HOUR',##)*60+TIME_EXTRACT($$,'MINUTE',##)",MINUTE_OF_WEEK:"(MOD(CAST((TIME_EXTRACT($$,'DOW',##)+6) AS int),7)*24)+TIME_EXTRACT($$,'HOUR',##)*60+TIME_EXTRACT($$,'MINUTE',##)",MINUTE_OF_MONTH:"((TIME_EXTRACT($$,'DAY',##)-1)*24)+TIME_EXTRACT($$,'HOUR',##)*60+TIME_EXTRACT($$,'MINUTE',##)",MINUTE_OF_YEAR:"((TIME_EXTRACT($$,'DOY',##)-1)*24)+TIME_EXTRACT($$,'HOUR',##)*60+TIME_EXTRACT($$,'MINUTE',##)",HOUR_OF_DAY:"TIME_EXTRACT($$,'HOUR',##)",HOUR_OF_WEEK:"(MOD(CAST((TIME_EXTRACT($$,'DOW',##)+6) AS int),7)*24+TIME_EXTRACT($$,'HOUR',##))",HOUR_OF_MONTH:"((TIME_EXTRACT($$,'DAY',##)-1)*24+TIME_EXTRACT($$,'HOUR',##))",HOUR_OF_YEAR:"((TIME_EXTRACT($$,'DOY',##)-1)*24+TIME_EXTRACT($$,'HOUR',##))",DAY_OF_WEEK:"MOD(CAST((TIME_EXTRACT($$,'DOW',##)+6) AS int),7)+1",DAY_OF_MONTH:"TIME_EXTRACT($$,'DAY',##)",DAY_OF_YEAR:"TIME_EXTRACT($$,'DOY',##)",WEEK_OF_YEAR:"TIME_EXTRACT($$,'WEEK',##)",MONTH_OF_YEAR:"TIME_EXTRACT($$,'MONTH',##)",YEAR:"TIME_EXTRACT($$,'YEAR',##)"},t.CAST_TO_FUNCTION={TIME:{NUMBER:"MILLIS_TO_TIMESTAMP(CAST($$ AS BIGINT))"},NUMBER:{TIME:"CAST($$ AS BIGINT)",STRING:"CAST($$ AS FLOAT)"},STRING:{NUMBER:"CAST($$ AS VARCHAR)"}},t}(U);t.DruidDialect=G;var V=t.getValueType=function(e){var t=typeof e;if("object"===t){if(null===e)return"NULL";if(y(e))return"TIME";if(o(e,"start")&&o(e,"end")){if(y(e.start)||y(e.end))return"TIME_RANGE";if("number"==typeof e.start||"number"==typeof e.end)return"NUMBER_RANGE";if("string"==typeof e.start||"string"==typeof e.end)return"STRING_RANGE";throw new Error("unrecognizable range")}var n=e.constructor.type;if(!n)throw e instanceof Ce?new Error("expression used as datum value "+e):new Error("can not have an object without a type: "+JSON.stringify(e));return"SET"===n&&(n+="/"+e.setType),n}if("boolean"!==t&&"number"!==t&&"string"!==t)throw new TypeError("unsupported JS type "+t);return t.toUpperCase()},J=t.getFullType=function(e){var t=V(e);return"DATASET"===t?e.getFullType():{type:t}},Y=t.getFullTypeFromDatum=function(e){var t={};for(var n in e)o(e,n)&&(t[n]=J(e[n]));return{type:"DATASET",datasetType:t}};var $=t.valueFromJS=function(e,t){if(void 0===t&&(t=null),null==e)return null;if(Array.isArray(e))return e.length&&"object"!=typeof e[0]?le.fromJS(e):ye.fromJS(e);var n=typeof e;if("object"===n)switch(t||e.type){case"NUMBER":var r=Number(e.value);if(isNaN(r))throw new Error("bad number value '"+e.value+"'");return r;case"NUMBER_RANGE":return ie.fromJS(e);case"STRING_RANGE":return se.fromJS(e);case"TIME":return function(e){switch(typeof e){case"string":case"number":return new Date(e);case"object":if(e.toISOString)return e;if(null===e)return null;if(e.value)return new Date(e.value);throw new Error("can not interpret "+JSON.stringify(e)+" as TIME");default:throw new Error("can not interpret "+e+" as TIME")}}(e);case"TIME_RANGE":return pe.fromJS(e);case"SET":return le.fromJS(e);case"DATASET":return ye.fromJS(e);default:if(0===String(t).indexOf("SET")||Array.isArray(e.elements))return le.fromJS(e);if(e.toISOString)return e;throw t?new Error("unknown type "+t+" on "+JSON.stringify(e)):new Error("can not have an object without a 'type' as a datum value: "+JSON.stringify(e))}else{if("string"===n&&"TIME"===t)return new Date(e);if("number"===n&&isNaN(e))return null}return e},K=t.valueToJS=function(e){if(null==e)return null;var t=typeof e;if("object"===t){if(e.toISOString)return e;if(e.toJS)return e.toJS();throw new Error("can not convert "+JSON.stringify(e)+" to JS")}return"number"!==t||isFinite(e)?e:String(e)},Q=t.datumHasExternal=function(e){for(var t in e){var n=e[t];if(n instanceof rn)return!0;if(n instanceof ye&&n.hasExternal())return!0}return!1},Z=t.introspectDatum=function(e){var t=[],n=Object.create(null);return Object.keys(e).forEach((function(r){var o=e[r];o instanceof rn&&o.needsIntrospect()?t.push(o.introspect().then((function(e){n[r]=e}))):n[r]=o})),Promise.all(t).then((function(){return n}))},ee=t.failIfIntrospectNeededInDatum=function(e){Object.keys(e).forEach((function(t){var n=e[t];if(n instanceof rn&&n.needsIntrospect())throw new Error("Can not have un-introspected external")}))},te=function(){function e(e){if("string"!=typeof e.name)throw new Error("name must be a string");if(this.name=e.name,this.type=e.type||"NULL",!Ue.validType(this.type))throw new Error("invalid type: "+this.type);this.unsplitable=Boolean(e.unsplitable),this.maker=e.maker,e.nativeType&&(this.nativeType=e.nativeType),e.cardinality&&(this.cardinality=e.cardinality),e.range&&(this.range=e.range),e.termsDelegate&&(this.termsDelegate=e.termsDelegate)}return e.isAttributeInfo=function(t){return t instanceof e},e.fromJS=function(t){if("object"!=typeof t)throw new Error("unrecognizable attributeMeta");var n={name:t.name};t.type&&(n.type=t.type);var r=t.nativeType;!r&&o(t,"special")&&(r=e.NATIVE_TYPE_FROM_SPECIAL[t.special],n.type="NULL"),n.nativeType=r,t.unsplitable&&(n.unsplitable=!0);var i=t.maker||t.makerAction;return i&&(n.maker=Ce.fromJS(i)),t.cardinality&&(n.cardinality=t.cardinality),t.range&&(n.range=re.fromJS(t.range)),t.termsDelegate&&(n.termsDelegate=t.termsDelegate),new e(n)},e.fromJSs=function(t){if(!Array.isArray(t))throw new TypeError("invalid attributeJSs");return t.map((function(t){return e.fromJS(t)}))},e.toJSs=function(e){return e.map((function(e){return e.toJS()}))},e.override=function(e,t){return A.overridesByName(e,t)},e.prototype.toString=function(){var e=this.nativeType?"["+this.nativeType+"]":"";return this.name+"::"+this.type+e},e.prototype.valueOf=function(){return{name:this.name,type:this.type,unsplitable:this.unsplitable,nativeType:this.nativeType,maker:this.maker,cardinality:this.cardinality,range:this.range,termsDelegate:this.termsDelegate}},e.prototype.toJS=function(){var e={name:this.name,type:this.type};return this.nativeType&&(e.nativeType=this.nativeType),this.unsplitable&&(e.unsplitable=!0),this.maker&&(e.maker=this.maker.toJS()),this.cardinality&&(e.cardinality=this.cardinality),this.range&&(e.range=this.range.toJS()),this.termsDelegate&&(e.termsDelegate=this.termsDelegate),e},e.prototype.toJSON=function(){return this.toJS()},e.prototype.equals=function(t){return t instanceof e&&this.name===t.name&&this.type===t.type&&this.nativeType===t.nativeType&&this.unsplitable===t.unsplitable&&z(this.maker,t.maker)&&this.cardinality===t.cardinality&&z(this.range,t.range)&&this.termsDelegate===t.termsDelegate},e.prototype.dropOriginInfo=function(){var t=this.valueOf();return delete t.maker,delete t.nativeType,t.unsplitable=!1,delete t.cardinality,delete t.range,new e(t)},e.prototype.get=function(e){return this[e]},e.prototype.deepGet=function(e){return this.get(e)},e.prototype.change=function(t,n){var r=this.valueOf();if(!o(r,t))throw new Error("Unknown property: "+t);return r[t]=n,new e(r)},e.prototype.deepChange=function(e,t){return this.change(e,t)},e.prototype.changeType=function(t){var n=this.valueOf();return n.type=t,new e(n)},e.prototype.getUnsplitable=function(){return this.unsplitable},e.prototype.changeUnsplitable=function(t){var n=this.valueOf();return n.unsplitable=t,new e(n)},e.prototype.changeRange=function(t){var n=this.valueOf();return n.range=t,new e(n)},e.NATIVE_TYPE_FROM_SPECIAL={unique:"hyperUnique",theta:"thetaSketch",histogram:"approximateHistogram"},e}();t.AttributeInfo=te;var ne=/^[\[(][\])]$/,re=function(){function e(t,n,r){if(r){if(!ne.test(r))throw new Error("invalid bounds "+r)}else r=e.DEFAULT_BOUNDS;if(null!==t&&null!==n&&this._endpointEqual(t,n))"[]"!==r&&(t=n=this._zeroEndpoint()),"(]"!==r&&"()"!==r||(this.bounds="[)");else{if(null!==t&&null!==n&&n<t)throw new Error("must have start <= end");null===t&&"["===r[0]&&(r="("+r[1]),null===n&&"]"===r[1]&&(r=r[0]+")")}this.start=t,this.end=n,this.bounds=r}return e.isRange=function(t){return t instanceof e},e.isRangeType=function(e){return e&&e.indexOf("_RANGE")>0},e.unwrapRangeType=function(t){return t?e.isRangeType(t)?t.substr(0,t.length-6):t:null},e.register=function(t){var n=t.type.replace("_RANGE","").toLowerCase();e.classMap[n]=t},e.fromJS=function(t){var n;return n="number"==typeof t.start||"number"==typeof t.end?"number":"string"==typeof t.start||"string"==typeof t.end?"string":"time",e.classMap[n].fromJS(t)},e.prototype._zeroEndpoint=function(){return 0},e.prototype._endpointEqual=function(e,t){return e===t},e.prototype._endpointToString=function(e,t){return String(e)},e.prototype._equalsHelper=function(e){return Boolean(e)&&this.bounds===e.bounds&&this._endpointEqual(this.start,e.start)&&this._endpointEqual(this.end,e.end)},e.prototype.toJSON=function(){return this.toJS()},e.prototype.toString=function(e){var t=this.bounds;return"["+("("===t[0]?"~":"")+this._endpointToString(this.start,e)+","+this._endpointToString(this.end,e)+(")"===t[1]?"":"!")+"]"},e.prototype.compare=function(e){var t=this.start,n=e.start;return t<n?-1:n<t?1:0},e.prototype.openStart=function(){return"("===this.bounds[0]},e.prototype.openEnd=function(){return")"===this.bounds[1]},e.prototype.empty=function(){return this._endpointEqual(this.start,this.end)&&"[)"===this.bounds},e.prototype.degenerate=function(){return this._endpointEqual(this.start,this.end)&&"[]"===this.bounds},e.prototype.contains=function(t){if(t instanceof e){var n=t.start,r=t.end,o=t.bounds;if("["===o[0]){if(!this.containsValue(n))return!1}else if(!this.containsValue(n)&&n.valueOf()!==this.start.valueOf())return!1;if("]"===o[1]){if(!this.containsValue(r))return!1}else if(!this.containsValue(r)&&r.valueOf()!==this.end.valueOf())return!1;return!0}return this.containsValue(t)},e.prototype.validMemberType=function(e){return"number"==typeof e},e.prototype.containsValue=function(e){if(null===e)return!1;if(e=e.valueOf(),!this.validMemberType(e))return!1;var t=this.start,n=this.end,r=this.bounds;if("["===r[0]){if(e<t)return!1}else if(null!==t&&e<=t)return!1;if("]"===r[1]){if(n<e)return!1}else if(null!==n&&n<=e)return!1;return!0},e.prototype.intersects=function(e){return this.containsValue(e.start)||this.containsValue(e.end)||e.containsValue(this.start)||e.containsValue(this.end)||this._equalsHelper(e)},e.prototype.adjacent=function(e){return this._endpointEqual(this.end,e.start)&&this.openEnd()!==e.openStart()||this._endpointEqual(this.start,e.end)&&this.openStart()!==e.openEnd()},e.prototype.mergeable=function(e){return this.intersects(e)||this.adjacent(e)},e.prototype.union=function(e){return this.mergeable(e)?this.extend(e):null},e.prototype.extent=function(){return this},e.prototype.extend=function(e){var t,n,r,o,i=this.start,a=this.end,c=e.start,p=e.end;return null===i||null===c?(t=null,n="("):i<c?(t=i,n=this.bounds[0]):(t=c,n=e.bounds[0]),null===a||null===p?(r=null,o=")"):a<p?(r=p,o=e.bounds[1]):(r=a,o=this.bounds[1]),new this.constructor({start:t,end:r,bounds:n+o})},e.prototype.intersect=function(e){if(!this.mergeable(e))return null;var t,n,r,o,i=this.start,a=this.end,c=e.start,p=e.end;return null===i||null===c?null===c?(t=i,n=this.bounds[0]):(t=c,n=e.bounds[0]):c<i?(t=i,n=this.bounds[0]):(t=c,n=e.bounds[0]),null===a||null===p?null==a?(r=p,o=e.bounds[1]):(r=a,o=this.bounds[1]):p<a?(r=p,o=e.bounds[1]):(r=a,o=this.bounds[1]),new this.constructor({start:t,end:r,bounds:n+o})},e.prototype.isFinite=function(){return null!==this.start&&null!==this.end},e.DEFAULT_BOUNDS="[)",e.classMap={},e}();function oe(e){return isNaN(e)||isFinite(e)?e:null}t.Range=re;var ie=function(e){function t(t){if(isNaN(t.start))throw new TypeError("`start` must be a number");if(isNaN(t.end))throw new TypeError("`end` must be a number");return e.call(this,t.start,t.end,t.bounds)||this}return r.__extends(t,e),t.isNumberRange=function(e){return e instanceof t},t.numberBucket=function(e,n,r){var o=Math.floor((e-r)/n)*n+r;return new t({start:o,end:o+n,bounds:re.DEFAULT_BOUNDS})},t.fromNumber=function(e){return new t({start:e,end:e,bounds:"[]"})},t.fromJS=function(e){if("object"!=typeof e)throw new Error("unrecognizable numberRange");var n=e.start,r=e.end;return new t({start:null===n?null:oe(Number(n)),end:null===r?null:oe(Number(r)),bounds:e.bounds})},t.prototype.valueOf=function(){return{start:this.start,end:this.end,bounds:this.bounds}},t.prototype.toJS=function(){var e={start:this.start,end:this.end};return this.bounds!==re.DEFAULT_BOUNDS&&(e.bounds=this.bounds),e},t.prototype.equals=function(e){return e instanceof t&&this._equalsHelper(e)},t.prototype.midpoint=function(){return(this.start+this.end)/2},t.prototype.rebaseOnStart=function(e){var n=this.start,r=this.end,o=this.bounds;return n?new t({start:e,end:r?r-n+e:r,bounds:o}):this},t.type="NUMBER_RANGE",t}(re);function ae(e,t){if(null===e)return null;var n=typeof e;if("undefined"===n)throw new TypeError("timeRange must have a "+t);if("string"===n){var r=W(e,Ce.defaultParserTimezone);if(!r)throw new Error("could not parse '"+e+"' as date");e=r}else"number"===n&&(e=new Date(e));if(!e.getDay)throw new TypeError("timeRange must have a "+t+" that is a Date");return e}t.NumberRange=ie,re.register(ie);function ce(e){return e.toISOString().replace(".000Z","Z").replace(":00Z","Z").replace(":00Z","Z")}var pe=function(e){function t(t){return e.call(this,t.start,t.end,t.bounds)||this}return r.__extends(t,e),t.isTimeRange=function(e){return e instanceof t},t.intervalFromDate=function(e){return ce(e)+"/"+ce(new Date(e.valueOf()+1))},t.timeBucket=function(e,n,r){if(!e)return null;var o=n.floor(e,r);return new t({start:o,end:n.shift(o,r,1),bounds:re.DEFAULT_BOUNDS})},t.fromTime=function(e){return new t({start:e,end:e,bounds:"[]"})},t.fromJS=function(e){if("object"!=typeof e)throw new Error("unrecognizable timeRange");return new t({start:ae(e.start,"start"),end:ae(e.end,"end"),bounds:e.bounds})},t.prototype._zeroEndpoint=function(){return new Date(0)},t.prototype._endpointEqual=function(e,t){return null===e?null===t:null!==t&&e.valueOf()===t.valueOf()},t.prototype._endpointToString=function(e,t){return e?m.formatDateWithTimezone(e,t):"null"},t.prototype.valueOf=function(){return{start:this.start,end:this.end,bounds:this.bounds}},t.prototype.toJS=function(){var e={start:this.start,end:this.end};return this.bounds!==re.DEFAULT_BOUNDS&&(e.bounds=this.bounds),e},t.prototype.equals=function(e){return e instanceof t&&this._equalsHelper(e)},t.prototype.toInterval=function(){var e=this.start,t=this.end,n=this.bounds,r=["1000","3000"];return e&&("("===n[0]&&(e=new Date(e.valueOf()+1)),r[0]=ce(e)),t&&("]"===n[1]&&(t=new Date(t.valueOf()+1)),r[1]=ce(t)),r.join("/")},t.prototype.midpoint=function(){return new Date((this.start.valueOf()+this.end.valueOf())/2)},t.prototype.changeToNumber=function(){return new ie({bounds:this.bounds,start:this.start?this.start.valueOf():null,end:this.end?this.end.valueOf():null})},t.prototype.isAligned=function(e,t){var n=this.start,r=this.end;return(!n||e.isAligned(n,t))&&(!r||e.isAligned(r,t))},t.prototype.rebaseOnStart=function(e){var n=this.start,r=this.end,o=this.bounds;return n?new t({start:e,end:r?new Date(r.valueOf()-n.valueOf()+e.valueOf()):r,bounds:o}):this},t.type="TIME_RANGE",t}(re);t.TimeRange=pe,re.register(pe);var se=function(e){function t(t){var n=t.start,r=t.end;if("string"!=typeof n&&null!==n)throw new TypeError("`start` must be a string");if("string"!=typeof r&&null!==r)throw new TypeError("`end` must be a string");return e.call(this,n,r,t.bounds)||this}return r.__extends(t,e),t.isStringRange=function(e){return e instanceof t},t.fromString=function(e){return new t({start:e,end:e,bounds:"[]"})},t.fromJS=function(e){if("object"!=typeof e)throw new Error("unrecognizable StringRange");return new t({start:e.start,end:e.end,bounds:e.bounds})},t.prototype.valueOf=function(){return{start:this.start,end:this.end,bounds:this.bounds}},t.prototype.toJS=function(){var e={start:this.start,end:this.end};return this.bounds!==re.DEFAULT_BOUNDS&&(e.bounds=this.bounds),e},t.prototype.equals=function(e){return e instanceof t&&this._equalsHelper(e)},t.prototype.midpoint=function(){throw new Error("midpoint not supported in string range")},t.prototype._zeroEndpoint=function(){return""},t.prototype.validMemberType=function(e){return"string"==typeof e},t.type="STRING_RANGE",t}(re);function ue(e){return e.toISOString()}function be(e,t){return e.map((function(e){return $(e,t)}))}t.StringRange=se,re.register(se);var Me={NUMBER:"NUMBER_RANGE",TIME:"TIME_RANGE",STRING:"STRING_RANGE"},le=function(){function e(e){var t=e.setType;this.setType=t;var n="TIME"===t?ue:String;this.keyFn=n;for(var r=e.elements,o=null,i=Object.create(null),a=0;a<r.length;a++){var c=r[a],p=n(c);i[p]?o||(o=r.slice(0,a)):(i[p]=c,o&&o.push(c))}o&&(r=o),this.elements=r,this.hash=i}return e.unifyElements=function(e){for(var t=Object.create(null),n=0,r=e;n<r.length;n++){for(var o=r[n],i=0,a=Object.keys(t);i<a.length;i++){var c=a[i],p=t[c],s=o.union(p);s&&(o=s,delete t[c])}t[o.toString()]=o}var u=Object.keys(t);return u.length<e.length?u.map((function(e){return t[e]})):e},e.intersectElements=function(e,t){for(var n=[],r=0,o=e;r<o.length;r++)for(var i=o[r],a=0,c=t;a<c.length;a++){var p=c[a],s=i.intersect(p);s&&n.push(s)}return n},e.isSet=function(t){return t instanceof e},e.isAtomicType=function(e){return e&&"NULL"!==e&&-1===e.indexOf("SET/")},e.isSetType=function(e){return e&&0===e.indexOf("SET/")},e.wrapSetType=function(t){return t?e.isSetType(t)?t:"SET/"+t:null},e.unwrapSetType=function(t){return t?e.isSetType(t)?t.substr(4):t:null},e.cartesianProductOf=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e.reduce((function(e,t){return[].concat.apply([],e.map((function(e){return t.map((function(t){return e.concat([t])}))})))}),[[]])},e.crossBinary=function(t,n,r){if(t instanceof e||n instanceof e){var o=t instanceof e?t.elements:[t],i=n instanceof e?n.elements:[n],a=e.cartesianProductOf(o,i);return e.fromJS(a.map((function(e){return r(e[0],e[1])})))}return r(t,n)},e.crossBinaryBoolean=function(t,n,r){if(t instanceof e||n instanceof e){var o=t instanceof e?t.elements:[t],i=n instanceof e?n.elements:[n];return e.cartesianProductOf(o,i).some((function(e){return r(e[0],e[1])}))}return r(t,n)},e.crossUnary=function(t,n){if(t instanceof e){var r=t instanceof e?t.elements:[t];return e.fromJS(r.map((function(e){return n(e)})))}return n(t)},e.crossUnaryBoolean=function(t,n){return t instanceof e?(t instanceof e?t.elements:[t]).some((function(e){return n(e)})):n(t)},e.convertToSet=function(t){var n=V(t);return e.isSetType(n)?t:e.fromJS({setType:n,elements:[t]})},e.unionCover=function(t,n){var r=e.convertToSet(t),o=e.convertToSet(n),i=r.setType,a=o.setType;if(Me[i]===a)r=r.upgradeType();else if(Me[a]===i)o=o.upgradeType();else if(i!==a)return null;return r.union(o).simplifyCover()},e.intersectCover=function(t,n){var r=e.convertToSet(t),o=e.convertToSet(n),i=r.setType,a=o.setType;if(Me[i]===a)r=r.upgradeType();else if(Me[a]===i)o=o.upgradeType();else if(i!==a)return null;return r.intersect(o).simplifyCover()},e.fromPlywoodValue=function(t){return t instanceof e?t:e.fromJS([t])},e.fromJS=function(t){if(Array.isArray(t)&&(t={elements:t}),"object"!=typeof t)throw new Error("unrecognizable set");var n=t.setType,r=t.elements;return n||"NULL"===(n=V(r.length?r[0]:null))&&r.length>1&&(n=V(r[1])),new e({setType:n,elements:be(r,n)})},e.prototype.valueOf=function(){return{setType:this.setType,elements:this.elements}},e.prototype.toJS=function(){return{setType:this.setType,elements:this.elements.map(K)}},e.prototype.toJSON=function(){return this.toJS()},e.prototype.toString=function(e){var t=this.setType,n=null;return"NULL"===t?"null":(n="TIME_RANGE"===t?function(t){return t?t.toString(e):"null"}:"TIME"===t?function(t){return t?m.formatDateWithTimezone(t,e):"null"}:String,""+this.elements.map(n).join(", "))},e.prototype.equals=function(t){return t instanceof e&&this.setType===t.setType&&this.elements.length===t.elements.length&&this.elements.slice().sort().join("")===t.elements.slice().sort().join("")},e.prototype.changeElements=function(t){if(this.elements===t)return this;var n=this.valueOf();return n.elements=t,new e(n)},e.prototype.cardinality=function(){return this.size()},e.prototype.size=function(){return this.elements.length},e.prototype.empty=function(){return 0===this.elements.length},e.prototype.isNullSet=function(){return"NULL"===this.setType},e.prototype.unifyElements=function(){return re.isRangeType(this.setType)?this.changeElements(e.unifyElements(this.elements)):this},e.prototype.simplifyCover=function(){var e=this.unifyElements().downgradeType(),t=e.elements;return 1===t.length?t[0]:e},e.prototype.getType=function(){return"SET/"+this.setType},e.prototype.upgradeType=function(){return"NUMBER"===this.setType?e.fromJS({setType:"NUMBER_RANGE",elements:this.elements.map(ie.fromNumber)}):"TIME"===this.setType?e.fromJS({setType:"TIME_RANGE",elements:this.elements.map(pe.fromTime)}):"STRING"===this.setType?e.fromJS({setType:"STRING_RANGE",elements:this.elements.map(se.fromString)}):this},e.prototype.downgradeType=function(){if(!re.isRangeType(this.setType))return this;for(var t=[],n=0,r=this.elements;n<r.length;n++){var o=r[n];if(!o.degenerate())return this;t.push(o.start)}return e.fromJS(t)},e.prototype.extent=function(){var e=this.setType;if(o(Me,e))return this.upgradeType().extent();if(!re.isRangeType(e))return null;for(var t=this.elements,n=t[0]||null,r=1;r<t.length;r++)n=n.extend(t[r]);return n},e.prototype.union=function(e){if(this.empty())return e;if(e.empty())return this;if(this.setType!==e.setType)throw new TypeError("can not union sets of different types");return this.changeElements(this.elements.concat(e.elements)).unifyElements()},e.prototype.intersect=function(t){if(this.empty()||t.empty())return e.EMPTY;var n=this.setType;if(this.setType!==t.setType)throw new TypeError("can not intersect sets of different types");var r,o=this.elements;if("NUMBER_RANGE"===n||"TIME_RANGE"===n||"STRING_RANGE"===n){var i=t.elements;r=e.intersectElements(o,i)}else{r=[];for(var a=0,c=o;a<c.length;a++){var p=c[a];t.contains(p)&&r.push(p)}}return this.changeElements(r)},e.prototype.overlap=function(e){if(this.empty()||e.empty())return!1;if(this.setType!==e.setType)throw new TypeError("can determine overlap sets of different types");for(var t=0,n=this.elements;t<n.length;t++){var r=n[t];if(e.contains(r))return!0}return!1},e.prototype.has=function(e){var t=this.keyFn(e);return o(this.hash,t)&&M(this.hash[t],e)},e.prototype.contains=function(t){var n=this;return t instanceof e?t.elements.every((function(e){return n.contains(e)})):re.isRangeType(this.setType)?!!(t instanceof re&&this.has(t))||this.elements.some((function(e){return e.contains(t)})):this.has(t)},e.prototype.add=function(t){var n=this.setType,r=V(t);if("NULL"===n&&(n=r),"NULL"!==r&&n!==r)throw new Error("value type must match");return this.contains(t)?this:new e({setType:n,elements:this.elements.concat([t])})},e.prototype.remove=function(t){if(!this.contains(t))return this;var n=this.keyFn,r=n(t);return new e({setType:this.setType,elements:this.elements.filter((function(e){return n(e)!==r}))})},e.prototype.toggle=function(e){return this.contains(e)?this.remove(e):this.add(e)},e.type="SET",e}();t.Set=le,le.EMPTY=le.fromJS([]);var fe=t.fillExpressionExternalAlteration=function(e,t){for(var n in e){var r=e[n];Array.isArray(r)?de(r,t):r.result=t(r.external,Boolean(r.terminal))}},ze=t.sizeOfExpressionExternalAlteration=function(e){var t=0;for(var n in e){var r=e[n];Array.isArray(r)?t+=Oe(r):t++}return t},de=t.fillDatasetExternalAlterations=function(e,t){for(var n=0,r=e;n<r.length;n++){var o=r[n];if(o.external)o.result=t(o.external,o.terminal);else if(o.datasetAlterations)de(o.datasetAlterations,t);else{if(!o.expressionAlterations)throw new Error("fell through");fe(o.expressionAlterations,t)}}},Oe=t.sizeOfDatasetExternalAlterations=function(e){for(var t=0,n=0,r=e;n<r.length;n++){var o=r[n];if(o.external)t+=1;else if(o.datasetAlterations)t+=Oe(o.datasetAlterations);else{if(!o.expressionAlterations)throw new Error("fell through");t+=ze(o.expressionAlterations)}}return t},he={ascending:function(e,t){return null==e?null==t?0:-1:e.compare?e.compare(t):null==t?1:e<t?-1:e>t?1:e>=t?0:NaN},descending:function(e,t){return null==t?null==e?0:-1:t.compare?t.compare(e):null==e?1:t<e?-1:t>e?1:t>=e?0:NaN}};function Ae(e){return e.replace(/(?:\r\n|\r|\n)/g," ")}var qe={NULL:0,TIME:1,TIME_RANGE:2,"SET/TIME":3,"SET/TIME_RANGE":4,STRING:5,"SET/STRING":6,BOOLEAN:7,NUMBER:8,NUMBER_RANGE:9,"SET/NUMBER":10,"SET/NUMBER_RANGE":11,DATASET:12};function me(e,t){if(null==t)return null;if(y(t))return new te({name:e,type:"TIME"});if(!0===(r=t)||!1===r)return new te({name:e,type:"BOOLEAN"});if(null===(n=t)||isNaN(Number(n))){if("string"==typeof t)return new te({name:e,type:"STRING"});if(t instanceof ie)return new te({name:e,type:"NUMBER_RANGE"});if(t instanceof se)return new te({name:e,type:"STRING_RANGE"});if(t instanceof pe)return new te({name:e,type:"TIME_RANGE"});if(t instanceof le)return new te({name:e,type:t.getType()});if(t instanceof ye||t instanceof rn)return new te({name:e,type:"DATASET"});throw new Error("Could not introspect "+t)}return new te({name:e,type:"NUMBER"});var n,r}function ge(e,t){var n=Object.create(null);for(var r in t)n[r]=t[r];for(var r in e)n[r]=e[r];return n}function ve(e){var t,n={};for(t in e)o(e,t)&&(n[t]=e[t]);return n}var ye=function(){function e(t){this.attributes=null,!0===t.suppress&&(this.suppress=!0),this.keys=t.keys||[];var n=t.data;if(!Array.isArray(n))throw new TypeError("must have a `data` array");this.data=n;var r=t.attributes;r||(r=e.getAttributesFromData(n)),this.attributes=r}return e.datumToLine=function(t,n,r,o,i,a){return n.map((function(n){var a=t[n.name],c=null!=a?n.type:"NULL",p=o[c]||e.DEFAULT_FORMATTER[c],s=String(p(a,r));return i(s)})).join(a)},e.isDataset=function(t){return t instanceof e},e.datumFromJS=function(e,t){if(void 0===t&&(t={}),"object"!=typeof e)throw new TypeError("datum must be an object");var n=Object.create(null);for(var r in e)o(e,r)&&(n[r]=$(e[r],o(t,r)?t[r].type:null));return n},e.datumToJS=function(e){var t={};for(var n in e){var r=e[n];r&&r.suppress||(t[n]=K(r))}return t},e.getAttributesFromData=function(e){if(!e.length)return[];for(var t=Object.keys(e[0]),n=[],r=0,o=e;r<o.length;r++){for(var i=o[r],a=[],c=0,p=t;c<p.length;c++){var s=p[c],u=me(s,i[s]);u?n.push(u):a.push(s)}if(!(t=a).length)break}for(var b=0,M=t;b<M.length;b++){var l=M[b];n.push(new te({name:l,type:"STRING"}))}return n.sort((function(e,t){var n=qe[e.type]-qe[t.type];return n||e.name.localeCompare(t.name)})),n},e.parseJSON=function(e){var t=(e=e.trim())[0];if("["!==t[0]){if("{"===t[0])return e.split(/\r?\n/).map((function(e,t){try{return JSON.parse(e)}catch(n){throw new Error("problem in line: "+t+": '"+e+"'")}}));throw new Error("Unsupported start, starts with '"+t[0]+"'")}try{return JSON.parse(e)}catch(e){throw new Error("could not parse")}},e.fromJS=function(t){if(Array.isArray(t)&&(t={data:t}),!Array.isArray(t.data))throw new Error("must have data");var n=void 0,r={};if(t.attributes)for(var o=0,i=n=te.fromJSs(t.attributes);o<i.length;o++){var a=i[o];r[a.name]=a}return new e({attributes:n,keys:t.keys||[],data:t.data.map((function(t){return e.datumFromJS(t,r)}))})},e.prototype.valueOf=function(){var e={keys:this.keys,attributes:this.attributes,data:this.data};return this.suppress&&(e.suppress=!0),e},e.prototype.toJS=function(){var t={};return this.keys.length&&(t.keys=this.keys),this.attributes&&(t.attributes=te.toJSs(this.attributes)),t.data=this.data.map(e.datumToJS),t},e.prototype.toString=function(){return"Dataset("+this.data.length+")"},e.prototype.toJSON=function(){return this.toJS()},e.prototype.equals=function(t){return t instanceof e&&this.data.length===t.data.length},e.prototype.hide=function(){var t=this.valueOf();return t.suppress=!0,new e(t)},e.prototype.changeData=function(t){var n=this.valueOf();return n.data=t,new e(n)},e.prototype.basis=function(){var e=this.data;return 1===e.length&&0===Object.keys(e[0]).length},e.prototype.hasExternal=function(){return!!this.data.length&&Q(this.data[0])},e.prototype.getFullType=function(){var t=this.attributes;if(!t)throw ne