@hpcc-js/marshaller 3.3.0 → 3.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -15,7 +15,7 @@ import { PropertyEditor as nt } from "@hpcc-js/other";
15
15
  var rt = Object.defineProperty, __name = (e, t) => rt(e, "name", {
16
16
  value: t,
17
17
  configurable: !0
18
- }), it = "@hpcc-js/marshaller", at = "3.3.0", ot = "3.26.0";
18
+ }), it = "@hpcc-js/marshaller", at = "3.3.1", ot = "3.26.1";
19
19
  //#endregion
20
20
  //#region src/ddl2/activities/activity.ts
21
21
  function stringify(e) {
@@ -1,4 +1,4 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@hpcc-js/comms"),require("@hpcc-js/common"),require("@hpcc-js/util"),require("@hpcc-js/ddl-shim"),require("@hpcc-js/chart"),require("@hpcc-js/dgrid"),require("@hpcc-js/form"),require("@hpcc-js/graph"),require("@hpcc-js/map"),require("@hpcc-js/layout"),require("@hpcc-js/phosphor"),require("@hpcc-js/codemirror"),require("@hpcc-js/other")):typeof define==`function`&&define.amd?define([`exports`,`@hpcc-js/comms`,`@hpcc-js/common`,`@hpcc-js/util`,`@hpcc-js/ddl-shim`,`@hpcc-js/chart`,`@hpcc-js/dgrid`,`@hpcc-js/form`,`@hpcc-js/graph`,`@hpcc-js/map`,`@hpcc-js/layout`,`@hpcc-js/phosphor`,`@hpcc-js/codemirror`,`@hpcc-js/other`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e[`@hpcc-js/marshaller`]={},e[`@hpcc-js/comms`],e[`@hpcc-js/common`],e[`@hpcc-js/util`],e[`@hpcc-js/ddl-shim`],e[`@hpcc-js/chart`],e[`@hpcc-js/dgrid`],e[`@hpcc-js/form`],e[`@hpcc-js/graph`],e[`@hpcc-js/map`],e[`@hpcc-js/layout`],e[`@hpcc-js/phosphor`],e[`@hpcc-js/codemirror`],e[`@hpcc-js/other`]))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d,f,ee){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var te=Object.defineProperty,__name=(e,t)=>te(e,`name`,{value:t,configurable:!0}),p=`@hpcc-js/marshaller`,m=`3.3.0`,h=`3.26.0`;function stringify(e){return Array.isArray(e)?`[`+e.map(stringify).join(`, `)+`]`:typeof e!=`object`||!e||e===void 0?JSON.stringify(e):`{ ${Object.keys(e).map(t=>`${t}: ${stringify(e[t])}`).join(`, `)} }`}function schemaType2IFieldType(e){switch(e){case`boolean`:return`boolean`;case`xs:byte`:case`xs:double`:case`xs:decimal`:case`xs:float`:case`xs:int`:case`xs:short`:case`xs:unsignedInt`:case`xs:unsignedShort`:case`xs:unsignedByte`:case`number`:return`number`;case`xs:integer`:case`xs:long`:case`xs:negativeInteger`:case`xs:nonNegativeInteger`:case`xs:nonPositiveInteger`:case`xs:positiveInteger`:case`xs:unsignedLong`:return`number64`;case`string`:return`string`;case`range`:return`range`}return`string`}function schemaRow2IField(e){return e._children&&e._children.length?{type:`dataset`,id:e.name,children:e._children.map(schemaRow2IField)}:{id:e.name,type:schemaType2IFieldType(e.type)}}function wsEclSchemaRow2IField(e){return e}var Activity=class extends n.PropertyExt{_sourceActivity;fixInt64(e){if(!e||e.length===0)return[];let t=this.outFields().filter(t=>{switch(t.type){case`number`:return typeof e[0][t.id]!=`number`;case`number64`:return!0}return!1});return t.length?e.map(e=>{for(let n of t)e[n.id]=+e[n.id];return e}):e}sourceActivity(e){return arguments.length?(this._sourceActivity=e,this):this._sourceActivity}hash(e={}){return(0,r.hashSum)({...e})}refreshMeta(){return this._sourceActivity?this._sourceActivity.refreshMeta():Promise.resolve()}exists(){return!0}validate(){return[]}label(){return this.id()}updatedBy(){return[]}_emptyFields=[];inFields(){return this._sourceActivity?this._sourceActivity.outFields():this._emptyFields}computeFields(e){return()=>e}outFields(){return this.computeFields(this.inFields())()}localFields(){let e=this.inFields().map(e=>e.id);return this.outFields().filter(t=>e.indexOf(t.id)<0)}fieldOrigin(e){return this.localFields().filter(t=>t.id===e).length?this:this.sourceActivity()?this.sourceActivity().fieldOrigin(e):null}resolveFields(e,t){for(let n of t){let t=this.fieldOrigin(n);t&&(e.outputs[t.id()]||(e.outputs[t.id()]=[]),e.outputs[t.id()].indexOf(n)<0&&e.outputs[t.id()].push(n))}}resolveInFields(e,t){return this._sourceActivity&&this._sourceActivity.resolveFields(e,t)}referencedFields(e){this._sourceActivity?.referencedFields(e)}exec(){return this._sourceActivity?this._sourceActivity.exec():Promise.resolve()}_emptyData=[];inData(){return this._sourceActivity&&this._sourceActivity.outData()||this._emptyData}computeData(){return this.inData()}_prevDataHash=``;_prevInData=[];_prevData=[];cachedComputeData(e){let t=this.hash();return(this._prevDataHash!==t||this._prevInData!==e)&&(this._prevDataHash=t,this._prevInData=e,this._prevData=(0,r.update)(this._prevData,this.computeData())),this._prevData}outData(){return this.cachedComputeData(this.inData())}},ActivityArray=class extends Activity{_activities=[];activities(e){return arguments.length?(this._activities=e,this):this._activities}};ActivityArray.prototype._class+=` ActivityArray`;var ActivityPipeline=class extends ActivityArray{activities(e){if(!arguments.length)return super.activities();super.activities(e);let t;for(let n of e)t&&n.sourceActivity(t),t=n;return this}first(){return this.activities()[0]}last(){let e=this.activities();return e[e.length-1]}calcUpdatedGraph(e){return e.updatedBy().map(t=>({from:t,to:e}))}updatedByGraph(){let e=[];for(let t of this.activities())e=e.concat(this.calcUpdatedGraph(t));return e}fetch(e=0,t=Number.MAX_VALUE){return this.exec().then(()=>{let n=this.outData();return e===0&&n.length<=t?n:n.slice(e,e+t)})}hash(e={}){return(0,r.hashSum)({activities:[this.activities().map(e=>e.hash())],...e})}refreshMeta(){return this.last().refreshMeta()}updatedBy(){let e=[];for(let t of this.activities())e=e.concat(t.updatedBy());return e}inFields(){return this.first().inFields()}outFields(){return this.last().outFields()}localFields(){return this.last().localFields()}fieldOrigin(e){return this.last().fieldOrigin(e)}referencedFields(e){this.last().referencedFields(e)}resolveInFields(e,t){this.last().resolveInFields(e,t)}resolveFields(e,t){this.last().resolveFields(e,t)}exec(){return this.last().exec()}outData(){return this.last().outData()}};ActivityPipeline.prototype._class+=` ActivitySequence`;var ActivitySelection=class extends ActivityArray{_selection;_monitorHandle;selection(e){return e===void 0?this._selection:(this._monitorHandle&&this._monitorHandle.remove(),this._selection=e,this._monitorHandle=e.monitor((t,n,r)=>{this.broadcast(t,n,r,e)}),this)}hash(e={}){return(0,r.hashSum)({selection:this.selection().hash(),...e})}label(){return this.selection().label()}refreshMeta(){return this.selection().refreshMeta()}updatedBy(){return this.selection().updatedBy()}inFields(){return this.selection().inFields()}outFields(){return this.selection().outFields()}localFields(){return this.selection().localFields()}fieldOrigin(e){return this.selection().fieldOrigin(e)}referencedFields(e){this.selection().referencedFields(e)}resolveInFields(e,t){this.selection().resolveInFields(e,t)}resolveFields(e,t){this.selection().resolveFields(e,t)}exec(){return this.selection().exec()}outData(){return this.selection().outData()}};ActivitySelection.prototype._class+=` ActivitySelection`;var g=0,Datasource=class extends Activity{constructor(){super(),this._id=`ds_${++g}`}},DatasourceRef=class extends Activity{_origDatasource;constructor(){super()}hash(e={}){return super.hash({datasource:this._datasource?this._datasource.hash(e):void 0,...e})}toDDL(){return{id:this.datasource().id()}}};DatasourceRef.prototype._class+=` DatasourceRef`,DatasourceRef.prototype.publish(`datasource`,null,`widget`,`Datasource Reference`,null,{internal:!0}),DatasourceRef.prototype._origDatasource=DatasourceRef.prototype.datasource,DatasourceRef.prototype.datasource=function(e){let t=DatasourceRef.prototype._origDatasource.apply(this,arguments);return e!==void 0&&this.sourceActivity(e),t};var _=class FormField extends n.PropertyExt{_owner;disableChildField(){return this.type()!==`dataset`}constructor(){super()}toDDL(){return{type:this.type(),id:this.fieldID(),default:this.default(),children:this.type()===`dataset`?this.childFields().map(e=>e.toDDL()):void 0}}fromDDL(e){return this.type(e.type).fieldID(e.id).default(e.default).childFields(e.type===`dataset`&&e.children?e.children.map(FormField.fromDDL):[])}static fromDDL(e){return new FormField().fromDDL(e)}owner(e){return arguments.length?(this._owner=e,this):this._owner}valid(){return!!this.type()&&!!this.fieldID()}coerceFunc(){switch(this.type()){case`boolean`:return e=>!!e;case`number`:return e=>+e;case`string`:return e=>``+e}return e=>e}calcValue(){return this.value_exists()?this.value():this.default()}},v=class Form extends Datasource{constructor(){super()}toDDL(){return{type:`form`,id:this.id(),fields:this.validFields().map(e=>e.toDDL())}}fromDDL(e,t=!1){return(t?this:this.id(e.id)).formFields(e.fields.map(_.fromDDL)),this}static fromDDL(e,t=!1){return new Form().fromDDL(e,t)}validFields(){return this.formFields().filter(e=>e.valid())}hash(e={}){return super.hash({ddl:this.toDDL(),...e})}refreshMeta(){return Promise.resolve()}label(){return`Form`}computeFields(e){let t=this.validFields().map(e=>e.toDDL());return()=>t}exec(){return Promise.resolve()}computeData(){let e={};return this.validFields().forEach(t=>{e[t.fieldID()]=t.calcValue()}),[e]}total(){return 1}};v.prototype._class+=` Form`,_.prototype.publish(`type`,`string`,`set`,`FormField Type`,[`boolean`,`number`,`string`,`dataset`]),_.prototype.publish(`fieldID`,``,`string`,`FormField Label`),_.prototype.publish(`default`,null,`any`,`Default Value`,null,{optional:!0}),_.prototype.publish(`value`,null,`any`,`Default Value`,null,{optional:!0}),_.prototype.publish(`childFields`,[],`propertyArray`,`Child Fields`,null,{autoExpand:_,disable:e=>e.disableChildField()}),v.prototype.publish(`formFields`,[],`propertyArray`,`Multi Fields`,null,{autoExpand:_});function fieldType(e){if((0,r.isArray)(e))return`dataset`;let t=typeof e;switch(t){case`boolean`:case`number`:case`string`:case`object`:return t}return`string`}function rowToFields(e,t){let n=[];for(let r in e){let i={type:fieldType(e[r]),id:r};switch(i.type){case`object`:for(let e of t){let t=!1;for(let n in e[r]){let n=rowToFields(e[r],[e[r]]);i.fields={},n.length&&(n.forEach(e=>i.fields[e.id]=e),t=!0);break}if(t)break}break;case`dataset`:for(let e of t)if(e[r]&&e[r].length){i.children=rowToFields(e[r][0],e[r]);break}break}n.push(i)}return n}var y=class Databomb extends Datasource{_jsonData=[];constructor(){super()}toDDL(e=!1){return{type:`databomb`,id:this.id(),format:this.format(),payload:e?void 0:this.payload(),fields:this.validFields().map(e=>e.toDDL())}}fromDDL(e,t=!1){return(t?this:this.id(e.id)).format(e.format).payload(e.payload).databombFields(e.fields.map(_.fromDDL)),this}static fromDDL(e,t=!1){return new Databomb().fromDDL(e,t)}validFields(){return this.databombFields().filter(e=>e.valid())}updateJsonData(){try{switch(this.format()){case`csv`:this._jsonData=(0,n.csvParse)(this.payload());break;case`tsv`:this._jsonData=(0,n.tsvParse)(this.payload());break;default:this._jsonData=JSON.parse(this.payload());break}this.databombFields(this.preCalcFields().map(_.fromDDL))}catch{this.databombFields([]),this._jsonData=[]}}hash(e){return super.hash({ddl:this.toDDL(!0),...e})+this.payload()}refreshMeta(){return Promise.resolve()}label(){return`Databomb`}preCalcFields(){return this._jsonData.length===0?[]:rowToFields(this._jsonData[0],this._jsonData)}computeFields(e){return()=>this.validFields().map(e=>e.toDDL())}exec(){return Promise.resolve()}computeData(){let e={};return this.validFields().forEach(t=>{e[t.fieldID()]=t.coerceFunc()}),this._jsonData.map(t=>{let n={};for(let r in e)n[r]=e[r](t[r]);return n})}total(){return this._jsonData.length}};y.prototype._class+=` Databomb`,y.prototype.publish(`format`,`json`,`set`,`Databomb Format`,[`json`,`csv`,`tsv`]),y.prototype.publish(`payload`,``,`string`,`Databomb array`,null,{multiline:!0}),y.prototype.publish(`databombFields`,[],`propertyArray`,`Multi Fields`,null,{autoExpand:_});var ne=y.prototype.format;y.prototype.format=function(e){let t=ne.apply(this,arguments);return arguments.length&&this.updateJsonData(),t};var re=y.prototype.payload;y.prototype.payload=function(e){let t=re.apply(this,arguments);return arguments.length&&this.updateJsonData(),t};var b=new y().id(`Empty`).payload(`[]`),DatasourceAdapt=class{_activity;constructor(e){this._activity=e||b}exec(){return this._activity.refreshMeta().then(()=>this._activity.exec())}id(){return this._activity.id()}hash(e={}){return this._activity.hash(e)}label(){return this._activity.label()}outFields(){return this._activity&&this._activity.outFields?this._activity.outFields():[]}total(){return this._activity?this._activity.outData().length:0}fetch(e,t){return this.exec().then(()=>{let n=this._activity.outData();return e===0&&n.length<=t?Promise.resolve(n):Promise.resolve(n.slice(e,e+t))})}},ESPResult=class extends Datasource{_ec;_result;_schema=[];_meta=[];_total;_data=[];constructor(e){super(),this._ec=e,this.samples(this._ec.samples()).sampleSize(this._ec.sampleSize())}hash(e={}){return(0,r.hashSum)({samples:this.samples(),sampleSize:this.sampleSize(),...e})}_prevMetaHash;refreshMetaPromise;refreshMeta(){return this._prevMetaHash!==this.hash()&&(this._prevMetaHash=this.hash(),delete this.refreshMetaPromise),this.refreshMetaPromise||=super.refreshMeta().then(()=>{if(this._result=this._createResult(),this._result)return this._result.refresh();throw Error(`No valid result`)}).then(e=>{this._total=e.Total,this._schema=e.fields(),this._meta=this._meta&&this._meta.length?this._meta:this._schema.map(schemaRow2IField)}).catch(e=>{this._total=0,this._schema=[],this._meta=[]}),this.refreshMetaPromise}responseFields(e){return arguments.length?(this._meta=e,this.refreshMeta(),this):this._meta}computeFields(e){return()=>this.responseFields()}exec(){return this._exec()}_prevExecHash;_exec=(0,r.debounce)(()=>this._prevExecHash===this.hash()?Promise.resolve():(this._prevExecHash=this.hash(),super.exec().then(()=>this.sample()).then(e=>{this._data=this.fixInt64(e)}).catch(e=>{this._data=[]})));inData(){return this._data}computeData(){return this._data}total(){return this._total}async fetch(e,t){return t>this.samples()*this.sampleSize()?this.sample():this._fetch(e,t)}_fetchQ=new r.AsyncOrderedQueue;_fetch(e,t){return this._fetchQ.push(this._result?this._result.fetchRows(e,t).catch(e=>[]):Promise.resolve([]))}sample=(0,r.debounce)((e=this.samples(),t=this.sampleSize())=>{let n=[];if(e*t>=this.total())n.push(this._fetch(0,this.total()));else{let r=this.total()-t;for(let i=0;i<e;++i)n.push(this._fetch(Math.floor(i*r/e),t))}return Promise.all(n).then(e=>{let t=[];for(let n of e)t=t.concat(n);return t})})};ESPResult.prototype._class+=` ESPResult`;var x=class WUResult extends ESPResult{_origWu;_origResultName;constructor(e){super(e),this._wu=new S(this._ec)}url(){return this._wu.url()}wuid(){return this._wu.wuid()}toDDL(){return{type:`wuresult`,id:this.id(),url:this._wu.url(),wuid:this.wuid(),outputs:{[this.resultName()]:{fields:this.responseFields()}}}}fromDDL(e,t=!1){return e.outputs[this.resultName()]?this.responseFields(e.outputs[this.resultName()].fields):this}static fromDDL(e,t,n,r,i=!1){return new WUResult(e).wu(n).resultName(r).fromDDL(t)}_createResult(){if(this._wu.url()&&this.wuid()&&this.resultName())return t.Result.attach({baseUrl:this._wu.url(),hookSend:this._ec.hookSend()},this.wuid(),this.resultName())}sourceHash(){return super.hash({wuid:this.wuid()})}hash(e){return super.hash({ddl:this.toDDL()})}label(){return`${this.wuid()}\n${this.resultName()}`}};x.prototype._class+=` WUResult`;var S=class WU extends Datasource{_ec;_origUrl;_origWuid;_workunit;_outputs={};constructor(e){super(),this._ec=e}toDDL(){let e={};for(let t in this._outputs)e[t]={fields:this._outputs[t].responseFields()};return{type:`wuresult`,id:this.id(),url:this.url(),wuid:this.wuid(),outputs:e}}fromDDL(e,t=!1){(t?this:this.id(e.id)).url(e.url).wuid(e.wuid);let n={};for(let t in e.outputs)n[t]=x.fromDDL(this._ec,e,this,t);return this._outputs=n,this}static fromDDL(e,t,n=!1){return new WU(e).fromDDL(t,n)}hash(){return(0,r.hashSum)({url:this.url(),wuid:this.wuid()})}label(){return this.wuid()}outputs(){let e=[];for(let t in this._outputs)e.push(this._outputs[t]);return e}outputDDL(){let e={};for(let t in this._outputs)e[t]={fields:this._outputs[t].outFields()};return e}output(e){return this._outputs[e]}_prevSourceHash;refreshMetaPromise;_resultNames=[];refreshMeta(){return!this.url()||!this.wuid()?Promise.resolve():(this._prevSourceHash!==this.hash()&&(this._prevSourceHash=this.hash(),delete this.refreshMetaPromise),this.refreshMetaPromise||=super.refreshMeta().then(()=>(this._workunit=t.Workunit.attach({baseUrl:this.url(),hookSend:this._ec.hookSend()},this.wuid()),this._workunit.fetchResults())).then(e=>{this._resultNames=e.map(e=>e.Name)}).catch(e=>{}),this.refreshMetaPromise)}resultNames(){return this._resultNames}};S.prototype._class+=` WU`;var WUResultRef=class extends DatasourceRef{datasource(e){return super.datasource.apply(this,arguments)}resultName(e){return arguments.length?(this.datasource().resultName(e),this):this.datasource().resultName()}toDDL(){return{id:this.datasource().wu().id(),output:this.resultName()}}};WUResultRef.prototype._class+=` WUResultRef`,ESPResult.prototype.publish(`samples`,10,`number`,`Number of samples`),ESPResult.prototype.publish(`sampleSize`,100,`number`,`Sample size`),x.prototype.publish(`wu`,null,`widget`,`Workunit`),x.prototype.publish(`resultName`,``,`set`,`Result Name`,function(){return this._wu===void 0?[]:this._wu.resultNames()}),x.prototype._origWu=x.prototype.wu,x.prototype.wu=function(e){let t=x.prototype._origWu.apply(this,arguments);return e!==void 0&&this._wu.refreshMeta(),t},x.prototype._origResultName=x.prototype.resultName,x.prototype.resultName=function(e){let t=this._resultName,n=x.prototype._origResultName.apply(this,arguments);return e!==void 0&&t!==e&&this.responseFields([]),n},S.prototype.publish(`url`,``,`string`,`ESP Url (http://x.x.x.x:8010)`),S.prototype.publish(`wuid`,``,`string`,`Workunit ID`),S.prototype._origUrl=S.prototype.url,S.prototype.url=function(e){let t=S.prototype._origUrl.apply(this,arguments);return e!==void 0&&this.refreshMeta(),t},S.prototype._origWuid=S.prototype.wuid,S.prototype.wuid=function(e){let t=S.prototype._origWuid.apply(this,arguments);return e!==void 0&&this.refreshMeta(),t};var C=class LogicalFile extends ESPResult{constructor(e){super(e)}toDDL(){return{type:`logicalfile`,id:this.id(),url:this.url(),logicalFile:this.logicalFile(),fields:this.responseFields()}}fromDDL(e,t=!1){return(t?this:this.id(e.id)).url(e.url).logicalFile(e.logicalFile),this}static fromDDL(e,t,n=!1){return new LogicalFile(e).fromDDL(t,n)}_createResult(){return t.Result.attachLogicalFile({baseUrl:this.url(),hookSend:this._ec.hookSend()},this.nodeGroup(),this.logicalFile())}sourceHash(){return super.hash({logicalFile:this.logicalFile()})}hash(e){return super.hash({ddl:this.toDDL()})}label(){return`${this.logicalFile()}`}};C.prototype._class+=` LogicalFile`,C.prototype.publish(`url`,``,`string`,`ESP Url (http://x.x.x.x:8010)`),C.prototype.publish(`nodeGroup`,``,`string`,`Node Group`),C.prototype.publish(`logicalFile`,``,`string`,`Logical File Name`);var w=class RestField extends n.PropertyExt{_owner;constructor(){super()}toDDL(){return{type:`string`,id:this.fieldID()}}fromDDL(e){return this.fieldID(e.id)}static fromDDL(e){return new RestField().fromDDL(e)}owner(e){return arguments.length?(this._owner=e,this):this._owner}valid(){return!!this.fieldID()}},T=class RestService extends Datasource{_ec;_responseFields={};constructor(e){super(),this._ec=e}toDDL(){return{type:`rest`,id:this.id(),url:this.url(),action:this.action(),mode:this.mode(),inputs:this.validRequestFields().map(e=>e.toDDL()),outputs:this.outputDDL()}}fromDDL(e,t=!1){(t?this:this.id(e.id)).url(e.url).action(e.action).mode(e.mode||`get`).requestFields(e.inputs.map(w.fromDDL));for(let t in e.outputs)this.responseFields(t,e.outputs[t].fields);return this}static fromDDL(e,t,n=!1){return new RestService(e).fromDDL(t,n)}hash(e={}){return(0,r.hashSum)({url:this.url(),action:this.action(),mode:this.mode(),...e})}label(){return this.action()}responseFields(e,t){return arguments.length===1?this._responseFields[e]||[]:(this._responseFields[e]=t,this)}validRequestFields(){return this.requestFields().filter(e=>e.valid())}_prevRequestHash;_prevPromise;_submitQ=new r.AsyncOrderedQueue;submit(e){let n=(0,r.hashSum)(e);if(!this._prevPromise||this._prevRequestHash!==n){this._prevRequestHash=n;let r=(0,t.createConnection)({baseUrl:this.url(),type:this.mode()});this._prevPromise=this._submitQ.push(r.send(this.action(),e))}return this._prevPromise}resultNames(){let e=[];for(let t in this._responseFields)e.push(t);return e}outputDDL(){let e={};return this.resultNames().forEach(t=>{e[t]={fields:this._responseFields[t]}}),e}};T.prototype._class+=` RestService`;var E=class RestResult extends Datasource{_ec;_origService;constructor(e){super(),this._ec=e,this._service=new T(this._ec)}validRequestFields(){return this.service().validRequestFields()}toDDL(){return this.service().toDDL()}fromDDL(e){return this.service().fromDDL(e),this}static fromDDL(e,t,n){return new RestResult(e).id(`${t.id()}_${n}`).service(t).resultName(n)}serviceID(){return`${this.service().url()}/${this.service().action()}}`}sourceHash(){return this.service().hash()}requestFields(){return this.service().requestFields().map(e=>e.toDDL())}responseFields(e){return arguments.length?(this.service().responseFields(this.resultName(),e),this):this.service().responseFields(this.resultName())}hash(e={}){return(0,r.hashSum)({source:this.sourceHash(),resultName:this.resultName(),...e})}label(){return`${this.service().label()}\n${this.resultName()}`}_jsonData=[];jsonDataFields(){if(!this._jsonData||!this._jsonData.length)return[];let e=rowToFields(this._jsonData[0],this._jsonData);return this.responseFields(e),e}computeFields(e){return()=>this.jsonDataFields()}computeData(){return this._jsonData}submit(e){return this.service().submit(e).then(e=>{let t=this.resultName(),n=t?t.split(`.`):[];for(let t of n)e=(e||{})[t];return this._jsonData=e,e})}formatRequest(){let e={};return this.service().validRequestFields().forEach(t=>{e[t.fieldID()]=``}),e}exec(){return this.submit(this.formatRequest()).then(e=>{})}};E.prototype._class+=` RestResult`;var D=class Param extends n.PropertyExt{_ec;validate(e){let t=[];return this.source_valid()||t.push({source:`${e}.source.${this.source()}`,msg:`Invalid source: "${this.source()}"`,hint:`expected: ${JSON.stringify(this.visualizationIDs())}`}),this.remoteField_valid()||t.push({source:`${e}.remoteField`,msg:`Invalid remoteField: "${this.remoteField()}"`,hint:`expected: ${JSON.stringify(this.sourceOutFields())}`}),this.value_valid()||t.push({source:`${e}.value`,msg:`Invalid value: "${this.value()}"`,hint:`expected: any value.`}),t}constructor(e){super(),this._ec=e}toDDL(){return{source:this.source(),remoteFieldID:this.remoteField(),localFieldID:this.localField(),value:this.value()}}fromDDL(e){return this.source(e.source).remoteField(e.remoteFieldID).localField(e.localFieldID).value(e.value)}static fromDDL(e,t){return new Param(e).fromDDL(t)}hash(){return(0,r.hashSum)({label:this.localField(),source:this.source(),sourceField:this.remoteField()})}visualizationIDs(){return this._ec.elementIDs()}sourceFields(){return this.sourceOutFields().map(e=>e.id)}sourceViz(){return this._ec.element(this.source())}sourceOutFields(){return this.sourceViz().hipiePipeline().selectionFields()}sourceSelection(){return this.sourceViz().selection()}calcValue(){return this.source_exists()&&this.remoteField_exists()?this.sourceSelection().map(e=>e[this.remoteField()]):this.value_exists()?[this.value()]:[``]}exists(){return this.localField_exists()&&(this.source_exists()&&this.remoteField_exists()||this.value_exists())}};D.prototype._class+=` Param`;var RestResultRef=class extends DatasourceRef{_ec;serviceID(){return this.datasource().serviceID()}_data=[];datasource(e){return super.datasource.apply(this,arguments)}url(){return this.datasource().service().url()}action(){return this.datasource().service().action()}resultName(){return this.datasource().resultName()}validate(){let e=[];for(let t of this.validParams())e=e.concat(t.validate(`request`));return e}constructor(e){super(),this._ec=e}toDDL(){return{id:this.datasource().service().id(),output:this.resultName(),request:this.validParams().map(e=>({source:e.source(),remoteFieldID:e.remoteField(),localFieldID:e.localField(),value:e.value()}))}}sourceHash(){return this.datasource().hash()}requestFieldRefs(e){return arguments.length?(this.request(e.map(e=>D.fromDDL(this._ec,e))),this):this.validParams().map(e=>e.toDDL())}requestFields(){return this.datasource().requestFields()}responseFields(){return this.datasource().responseFields()}hash(){return this.datasource().hash({resultName:this.resultName(),request:this.formatRequest()})}label(){return`${this.datasource().label()}\n${this.datasource().resultName()}`}elementIDs(){return this._ec.elementIDs()}element(e){return this._ec.element(e)}referencedFields(e){super.referencedFields(e);let t=[];for(let t of this.validParams()){let n=t.sourceViz().hipiePipeline();e.inputs[this.id()]||(e.inputs[this.id()]=[]),e.inputs[this.id()].push(t.localField()),n.resolveFields(e,[t.remoteField()])}super.resolveFields(e,t)}validParams(){return this.request().filter(e=>e.exists())}refreshMeta(){return this.datasource().refreshMeta().then(()=>{let e=this.request(),t=(0,r.compare)(e.map(e=>e.localField()),this.datasource().validRequestFields().map(e=>e.fieldID())),n=e.filter(e=>t.update.indexOf(e.localField())>=0);this.request(n.concat(t.enter.map(e=>new D(this._ec).localField(e))))})}updatedBy(){return this.validParams().map(e=>e.source())}computeFields(e){return this.datasource().computeFields(e)}formatRequest(){let e=this.datasource().formatRequest();return this.request().forEach(t=>{e[t.localField()]!==void 0&&(e[t.localField()]=t.calcValue()||e[t.localField()])}),e}_prevRequestHash;_prevRequestPromise;exec(){let e=this.formatRequest(),t=(0,r.hashSum)({hash:this.hash(),request:e});return this._prevRequestHash!==t&&(this._prevRequestHash=t,this._prevRequestPromise=this.datasource().submit(e).then(e=>(this._data=this.fixInt64(e),this._data))),this._prevRequestPromise}inData(){return this._data}computeData(){return this._data}};RestResultRef.prototype._class+=` RestResultRef`,w.prototype.publish(`fieldID`,``,`string`,`RestField Label`),T.prototype.publish(`url`,``,`string`,`REST Url`),T.prototype.publish(`action`,``,`string`,`Query Set`),T.prototype.publish(`mode`,`get`,`set`,`Request mode`,[`get`,`post`]),T.prototype.publish(`requestFields`,[],`propertyArray`,`Multi Fields`,null,{autoExpand:w}),E.prototype.publish(`service`,null,`widget`,`Rest service`),E.prototype.publish(`resultName`,``,`string`,`Result Name`),E.prototype._origService=E.prototype.service,E.prototype.service=function(e){let t=E.prototype._origService.apply(this,arguments);return e!==void 0&&this._service.refreshMeta(),t},D.prototype.publish(`localField`,null,`string`,`Label`),D.prototype.publish(`source`,null,`set`,`Activity`,function(){return this.visualizationIDs()},{optional:!0,disable:e=>e.value_exists(),validate:e=>e.source_disabled()||e.visualizationIDs().indexOf(e.source())>=0}),D.prototype.publish(`remoteField`,null,`set`,`Source Field`,function(){return this.sourceFields()},{optional:!0,disable:e=>!e.source_exists()||e.value_exists(),validate:e=>e.remoteField_disabled()||e.sourceFields().indexOf(e.remoteField())>=0}),D.prototype.publish(`value`,null,`string`,`Static Value`,null,{optional:!0,disable:e=>e.source_exists(),validate:e=>e.value_disabled()||e.value_exists()}),RestResultRef.prototype.publish(`request`,[],`propertyArray`,`Request Fields`);function parseUrl(e){let t=e.split(`/WsEcl/submit/query/`);if(t.length<2)throw Error(`Invalid roxie URL: ${e}`);let n=t[0].split(`:`);if(n.length<3)throw Error(`Invalid roxie URL: ${e}`);let r=t[1].split(`/`);if(r.length<2)throw Error(`Invalid roxie URL: ${e}`);return{url:`${n[0]}:${n[1]}:${n[2]===`18002`?`18010`:`8010`}`,querySet:r[0],queryID:r[1]}}function isHipieRequest(e){return e.length>=8&&e.indexOf(`_changed`)===e.length-8}function isHipieResponse(e){return e.length>=8&&e.indexOf(`_changed`)===e.length-8||[`HIPIE_DDL`,`HIPIE_DDLGLOBALS`,`hipieversion`].indexOf(e)>=0}var O=class RoxieService extends Datasource{_ec;_query;_requestFields;_responseFields={};_type=`roxie`;constructor(e){super(),this._ec=e}toDDL(){return{type:this._type,id:this.id(),url:this.url(),querySet:this.querySet(),queryID:this.queryID(),inputs:this.requestFields(),outputs:this.outputDDL()}}fromDDL(e,t=!1){this._type=e.type,(t?this:this.id(e.id)).url(e.url).querySet(e.querySet).queryID(e.queryID),e.inputs&&e.inputs.length&&this.requestFields(e.inputs);for(let t in e.outputs)this.responseFields(t,e.outputs[t].fields);return this}static fromDDL(e,t,n=!1){return new RoxieService(e).fromDDL(t,n)}hash(e={}){return(0,r.hashSum)({url:this.url(),querySet:this.querySet(),queryId:this.queryID(),ignoreHipieRequest:this.ignoreHipieRequest(),ignoreHipieResponse:this.ignoreHipieResponse(),...e})}label(){return this.queryID()}_prevSourceHash;refreshMetaPromise;refreshMeta(){if(this._prevSourceHash!==this.hash()&&(this._prevSourceHash=this.hash(),delete this.refreshMetaPromise),!this.refreshMetaPromise){let e=!!this._requestFields;this.refreshMetaPromise=new Promise((n,r)=>{let i=t.Query.attach({baseUrl:this.url(),hookSend:this._ec.hookSend()},this.querySet(),this.queryID());(!e||this.ignoreHipieRequest()||this.ignoreHipieResponse())&&n(i.refresh()),n(i)}).then(t=>{this._query=t,(!e||this.ignoreHipieRequest())&&(this._requestFields=t.requestFields().filter(e=>this._type===`roxie`||!isHipieRequest(e.id))),(!e||this.ignoreHipieResponse())&&t.resultNames().filter(e=>this._type===`roxie`||!isHipieResponse(e)).forEach(e=>{this._responseFields[e]=t.resultFields(e)})})}return this.refreshMetaPromise}requestFields(e){return arguments.length?(this._requestFields=e,this):this._requestFields||[]}responseFields(e,t){return arguments.length===1?this._responseFields[e]||[]:(this._responseFields[e]=t,this)}_prevRequestHash;_prevPromise;_submitQ=new r.AsyncOrderedQueue;submit(e){let t=(0,r.hashSum)(e);return(!this._prevPromise||this._prevRequestHash!==t)&&(this._prevRequestHash=t,this._prevPromise=this._submitQ.push(this._query.submit(e))),this._prevPromise}resultNames(){let e=[];for(let t in this._responseFields)e.push(t);return e}outputDDL(){let e={};return this.resultNames().forEach(t=>{e[t]={fields:this._responseFields[t]}}),e}};O.prototype._class+=` RoxieService`,O.prototype.publish(`url`,``,`string`,`ESP Url (http://x.x.x.x:8002)`),O.prototype.publish(`querySet`,``,`string`,`Query Set`),O.prototype.publish(`queryID`,``,`string`,`Query ID`),O.prototype.publish(`ignoreHipieRequest`,!1,`boolean`,`Ignore provided DDL request`),O.prototype.publish(`ignoreHipieResponse`,!1,`boolean`,`Ignore provided DDL response`);var k=class RoxieResult extends Datasource{_ec;_origService;constructor(e){super(),this._ec=e,this._service=new O(this._ec)}toDDL(){return this.service().toDDL()}fromDDL(e){return this.service().fromDDL(e),this}static fromDDL(e,t,n){return new RoxieResult(e).id(`${t.id()}_${n}`).service(t).resultName(n)}serviceID(){return`${this.service().url()}/${this.service().querySet()}/${this.service().queryID()}`}sourceHash(){return this.service().hash()}requestFields(){return this.service().requestFields()}responseFields(e){return arguments.length?(this.service().responseFields(this.resultName(),e),this):this.service().responseFields(this.resultName())}hash(e={}){return(0,r.hashSum)({source:this.sourceHash(),resultName:this.resultName(),...e})}label(){return`${this.service().label()}\n${this.resultName()}`}computeFields(e){return()=>this.service().responseFields(this.resultName())}refreshMeta(){return this.service().refreshMeta()}submit(e){return this.service().submit(e)}};k.prototype._class+=` RoxieResult`,k.prototype.publish(`service`,null,`widget`,`Roxie service`),k.prototype.publish(`resultName`,``,`set`,`Result Name`,function(){return this._service===void 0?[]:this._service.resultNames()}),k.prototype._origService=k.prototype.service,k.prototype.service=function(e){let t=k.prototype._origService.apply(this,arguments);return e!==void 0&&this._service.refreshMeta(),t};var RoxieResultRef=class extends DatasourceRef{_ec;serviceID(){return this.datasource().serviceID()}_data=[];datasource(e){return super.datasource.apply(this,arguments)}url(){return this.datasource().service().url()}querySet(){return this.datasource().service().querySet()}queryID(){return this.datasource().service().queryID()}resultName(){return this.datasource().resultName()}validate(){let e=[];for(let t of this.validParams())e=e.concat(t.validate(`request`));return e}constructor(e){super(),this._ec=e}toDDL(){return{id:this.datasource().service().id(),output:this.resultName(),request:this.validParams().map(e=>({source:e.source(),remoteFieldID:e.remoteField(),localFieldID:e.localField(),value:e.value()}))}}sourceHash(){return this.datasource().hash()}requestFieldRefs(e){return arguments.length?(this.request(e.map(e=>D.fromDDL(this._ec,e))),this):this.validParams().map(e=>e.toDDL())}requestFields(){return this.datasource().requestFields()}responseFields(){return this.datasource().responseFields()}hash(){return this.datasource().hash({resultName:this.resultName(),params:this.request().map(e=>e.hash()),request:this.formatRequest()})}label(){return`${this.datasource().label()}\n${this.datasource().resultName()}`}elementIDs(){return this._ec.elementIDs()}element(e){return this._ec.element(e)}referencedFields(e){super.referencedFields(e);let t=[];for(let n of this.validParams()){t.push(n.localField());let r=n.sourceViz().hipiePipeline();e.inputs[this.id()]||(e.inputs[this.id()]=[]),e.inputs[this.id()].push(n.localField()),r.resolveFields(e,[n.remoteField()])}super.resolveFields(e,t)}validParams(){return this.request().filter(e=>e.exists())}refreshMeta(){return this.datasource().refreshMeta().then(()=>{let e=this.request(),t=(0,r.compare)(e.map(e=>e.localField()),this.datasource().requestFields().map(e=>e.id)),n=e.filter(e=>t.update.indexOf(e.localField())>=0);this.request(n.concat(t.enter.map(e=>new D(this._ec).localField(e))))})}updatedBy(){return this.validParams().map(e=>e.source())}computeFields(e){return()=>this.datasource().responseFields()}formatRequest(){let e={},t=!1,n=this.datasource().requestFields();for(let r of this.validParams()){let i=r.calcValue(),a=n.filter(e=>e.id===r.localField())[0],o;o=a.type===`set`?{Item:i}:i[0],o!==void 0&&(e[r.localField()]=o),t=!0}return t||(e.refresh=!0),e}_prevRequestHash;_prevRequestPromise;exec(){return super.exec().then(()=>{let e=this.formatRequest(),t=(0,r.hashSum)({hash:this.hash(),request:e});return this._prevRequestHash!==t&&(this._prevRequestHash=t,this._prevRequestPromise=this.datasource().submit(e).then(e=>{let t=this.datasource().resultName(),n=e[t];return n||=e[t.toLowerCase().replace(/ /g,`_`)],this.fixInt64(n)})),this._prevRequestPromise}).then(e=>{this._data=e})}inData(){return this._data}computeData(){return this._data}};RoxieResultRef.prototype._class+=` RoxieResultRef`,RoxieResultRef.prototype.publish(`request`,[],`propertyArray`,`Request Fields`);var HipieResultRef=class extends RoxieResultRef{fullUrl(e){let t=parseUrl(e);return this.datasource().service().url(t.url),this.datasource().service().querySet(t.querySet),this.datasource().service().queryID(t.queryID),this}formatRequest(){let e=super.formatRequest(),t={};for(let n in e)t[n]=e[n],t[`${n}_changed`]=!0;return t}};HipieResultRef.prototype._class+=` HipieResultRef`;var A=0,DSPicker=class extends ActivitySelection{_ec;_nullDatasource=b;_origDatasourceID;_origDatasourceRef;datasource(){return this.datasourceRef().datasource()}refreshRef(e){let t=this._ec.datasource(e);t instanceof y||t instanceof v||t instanceof C||t instanceof O?this.selection(new DatasourceRef().datasource(t)):t instanceof x?this.selection(new WUResultRef().datasource(t)):t instanceof k?this.selection(new HipieResultRef(this._ec).datasource(t)):t instanceof E&&this.selection(new RestResultRef(this._ec).datasource(t))}selection(e){let t=super.selection.apply(this,arguments);return arguments.length?(this._datasourceID!==e.datasource().id()&&(this._datasourceID=e.datasource().id()),this):t||this._nullDatasource}validate(){return this.selection().validate()}constructor(e){super(),this._ec=e,this._id=`ds_${++A}`;let t=this._ec.datasources()[0];this.datasourceID(t.id())}toDDL(){return{...this.datasourceRef().toDDL(),id:this.datasourceID()}}hash(e={}){return super.hash({...e})}datasourceIDs(){return this._ec.datasources().map(e=>({value:e.id(),text:`${e.label()} ${e.id()===e.label()?``:` (${e.id()})`}`}))}};DSPicker.prototype._class+=` DSPicker`,DSPicker.prototype.publish(`datasourceID`,``,`set`,`Activity`,function(){return this.datasourceIDs()},{optional:!1}),DSPicker.prototype.publish(`datasourceRef`,``,`widget`,`Activity`),DSPicker.prototype._origDatasourceID=DSPicker.prototype.datasourceID,DSPicker.prototype.datasourceID=function(e){let t=this._datasourceID,n=DSPicker.prototype._origDatasourceID.apply(this,arguments);return e!==void 0&&t!==e&&this.refreshRef(e),n},DSPicker.prototype._origDatasourceRef=DSPicker.prototype.datasourceRef,DSPicker.prototype.datasourceRef=function(e){return ActivitySelection.prototype.selection.apply(this,arguments)};function createFilter(e,t,n){let r=typeof n==`string`;switch(e){case`==`:return e=>r&&typeof e[t]==`string`?e[t].trim()===n:e[t]===n;case`!=`:return e=>r&&typeof e[t]==`string`?e[t].trim()!==n:e[t]!==n;case`<`:return e=>e[t]<n;case`<=`:return e=>e[t]<=n;case`>`:return e=>e[t]>n;case`>=`:return e=>e[t]>=n;default:throw Error(`Unknown filter condition: ${e}`)}}var j=class ColumnMapping extends n.PropertyExt{_owner;validate(e){let t=[];return this.remoteField_valid()||t.push({source:`${e}.remoteField`,msg:`Invalid remoteField: "${this.remoteField()}"`,hint:`expected: ${JSON.stringify(this.sourceOutFields())}`}),this.localField_valid()||t.push({source:`${e}.localField`,msg:`Invalid localField: "${this.localField()}"`,hint:`expected: ${JSON.stringify(this.localFields())}`}),t}constructor(){super()}owner(e){return arguments.length?(this._owner=e,this):this._owner}valid(){return this.localField_exists()||this.remoteField_exists()}toDDL(){return{remoteFieldID:this.remoteField(),localFieldID:this.localField(),condition:this.condition(),nullable:this.nullable()}}fromDDL(e){return this.remoteField(e.remoteFieldID).localField(e.localFieldID).condition(e.condition).nullable(e.nullable)}static fromDDL(e){return new ColumnMapping().fromDDL(e)}hash(){return(0,r.hashSum)({remoteField:this.remoteField(),localField:this.localField(),condition:this.condition(),nullable:this.nullable()})}localFields(){return this._owner.inFields().map(e=>e.id)}sourceOutFields(){return this._owner.sourceOutFields().map(e=>e.id)}remoteValues(e){let t=this.remoteField();return e.map(e=>{let n=e[t];return typeof n==`string`?n.trim():n})}createFilterDescription(e){switch(this.condition()){case`in`:case`range`:return`${this.localField()} ${this.condition()} [${this.remoteValues(e).join(`, `)}]`;default:return`${this.localField()} ${this.condition()} ${this.remoteValues(e)[0]}`}}createFilter(e){let t=this.localField(),n=this.remoteValues(e);switch(this.condition()){case`range`:return this.nullable()&&(n.length<2||n[0]===n[1])?e=>!0:e=>e[t]>=n[0]&&e[t]<=n[1];case`in`:return this.nullable()&&n.length===0?e=>!0:e=>n.some(n=>typeof e[t]==`string`?e[t].trim()===n:e[t]===n);default:let e=n[0];return this.nullable()&&(e==null||e===``)?e=>!0:createFilter(this.condition(),t,e)}}};j.prototype._class+=` ColumnMapping`;var M=class RemoteFilter extends n.PropertyExt{_owner;validate(e){let t=[];this.source_valid()||t.push({source:`${e}.source.${this.source()}`,msg:`Invalid source: "${this.source()}"`,hint:`expected: ${JSON.stringify(this.visualizationIDs())}`}),this.source_exists()&&this.validMappings().length===0&&t.push({source:`${e}.source.${this.source()}`,msg:`Invalid mappings: "${this.source()}"`,hint:`expected minimum of 1 mapping`});for(let n of this.validMappings())t=t.concat(n.validate(`${e}.${this.source()}.mappings`));return t}constructor(){super()}owner(e){return arguments.length?(this._owner=e,this):this._owner}valid(){return!!this.source()&&this.validMappings().length>0}toDDL(){return{viewID:this.source(),mappings:this.ddlMappings()}}fromDDL(e){return this.source(e.viewID).ddlMappings(e.mappings)}static fromDDL(e){return new RemoteFilter().fromDDL(e)}ddlMappings(e){return arguments.length?(this.mappings(e.map(e=>j.fromDDL(e))),this):this.validMappings().map(e=>e.toDDL())}visualizationIDs(){return this._owner.visualizationIDs()}hash(){return(0,r.hashSum)({source:this.source(),mappings:this.validMappings().map(e=>e.hash()),selection:this.sourceSelection()})}validMappings(){return this.mappings().filter(e=>e.valid())}appendMappings(e){for(let t of e)this.mappings().push(new j().owner(this).remoteField(t.remoteField).localField(t.localField).condition(t.condition));return this}inFields(){return this._owner.inFields()}sourceViz(){return this._owner.visualization(this.source())}sourceOutFields(){return this.sourceViz().hipiePipeline().selectionFields()}sourceSelection(){return this.sourceViz().selection()}createFilter(){let e=this.sourceSelection(),t=this.validMappings().map(t=>t.createFilter(e));return e=>t.every(t=>t(e))}createFilterDescription(){let e=this.sourceSelection();return this.validMappings().map(t=>t.createFilterDescription(e)).join(`, `)}};M.prototype._class+=` Filter`;var N=class StaticFilter extends n.PropertyExt{_owner;validate(e){let t=[];return this.localField_valid()||t.push({source:`${e}.localField`,msg:`Invalid localField: "${this.localField()}"`,hint:`expected: ${JSON.stringify(this.localFields())}`}),t}constructor(){super()}owner(e){return arguments.length?(this._owner=e,this):this._owner}coerceValue(e){if(arguments.length===0)switch(this.valueType()){case`number`:return+this.value();default:return``+this.value()}return this.value(e),typeof e==`number`?this.valueType(`number`):this.valueType(`string`),this}valid(){return this.localField_exists()&&this.value_exists()}toDDL(){return{localFieldID:this.localField(),condition:this.condition(),value:this.coerceValue()}}fromDDL(e){return this.localField(e.localFieldID).condition(e.condition).coerceValue(e.value)}static fromDDL(e){return new StaticFilter().fromDDL(e)}hash(){return(0,r.hashSum)({localField:this.localField(),condition:this.condition(),value:this.value(),valueType:this.valueType()})}localFields(){return this._owner.inFields().map(e=>e.id)}createFilterDescription(){return`${this.localField()} ${this.condition()} ${this.coerceValue()}`}createFilter(){return createFilter(this.condition(),this.localField(),this.coerceValue())}};N.prototype._class+=` StaticFilter`;var P=class Filters extends Activity{_ec;static Filter=M;static Mapping=j;validate(){let e=[];for(let t of this.validFilters())e=e.concat(t.validate(`filter`));return e}constructor(e){super(),this._ec=e}toDDL(){return{type:`filter`,conditions:this.conditions()}}fromDDL(e){return this.conditions(e.conditions)}static fromDDL(e,t){return new Filters(e).fromDDL(t)}conditions(e){if(!arguments.length)return this.validFilters().map(e=>e.toDDL());let t=[],n=[];return e.forEach(e=>{i.DDL2.isIFilterCondition(e)?t.push(M.fromDDL(e)):n.push(N.fromDDL(e))}),this.remoteFilter(t),this.staticFilter(n),this}visualizationIDs(){return this._ec.elementIDs()}visualization(e){return this._ec.element(e)}hash(){return(0,r.hashSum)(this.validFilters().map(e=>({filter:e.hash()})))}exists(){return this.validFilters().length>0}updatedBy(){return this.validRemoteFilters().map(e=>e.source())}referencedFields(e){super.referencedFields(e);let t=[];for(let n of this.validRemoteFilters()){let r=n.sourceViz().hipiePipeline(),i=[];for(let e of n.validMappings())t.push(e.localField()),i.push(e.remoteField());r.resolveFields(e,i)}super.resolveInFields(e,t)}exec(){return super.exec()}computeData(){let e=super.computeData();if(e.length===0||!this.exists())return e;let t=this.validFilters().map(e=>e.createFilter());return e.filter(e=>t.every(t=>t(e)))}validRemoteFilters(){return this.remoteFilter().filter(e=>e.valid())}validStaticFilters(){return this.staticFilter().filter(e=>e.valid())}validFilters(){return[...this.validRemoteFilters(),...this.validStaticFilters()]}};P.prototype._class+=` Filters`,j.prototype.publish(`remoteField`,null,`set`,`Filter Fields`,function(){return this.sourceOutFields()},{optional:!0,disable:e=>!e._owner.source(),validate:e=>e.sourceOutFields().indexOf(e.remoteField())>=0}),j.prototype.publish(`localField`,null,`set`,`Local Fields`,function(){return this.localFields()},{optional:!0,disable:e=>!e._owner.source(),validate:e=>e.localFields().indexOf(e.localField())>=0}),j.prototype.publish(`condition`,`==`,`set`,`Filter Fields`,[`==`,`!=`,`>`,`>=`,`<`,`<=`,`range`,`in`]),j.prototype.publish(`nullable`,!1,`boolean`,`Ignore null filters`),M.prototype.publish(`source`,null,`set`,`Activity`,function(){return this.visualizationIDs()},{optional:!0,validate:e=>e.visualizationIDs().indexOf(e.source())>=0}),M.prototype.publish(`mappings`,[],`propertyArray`,`Mappings`,null,{autoExpand:j}),N.prototype.publish(`localField`,null,`set`,`Local Fields`,function(){return this.localFields()},{optional:!0,validate:e=>e.localFields().indexOf(e.localField())>=0}),N.prototype.publish(`condition`,`==`,`set`,`Filter Fields`,[`==`,`!=`,`>`,`>=`,`<`,`<=`]),N.prototype.publish(`value`,``,`any`,`Static Value`),N.prototype.publish(`valueType`,`number`,`set`,`Static Value Type`,[`number`,`string`]),P.prototype.publish(`remoteFilter`,[],`propertyArray`,`Remote Filter`,null,{autoExpand:M}),P.prototype.publish(`staticFilter`,[],`propertyArray`,`Static Filter`,null,{autoExpand:N});var F=class GroupByColumn extends n.PropertyExt{_owner;validate(e){let t=[];return this.label_valid()||t.push({source:`${e}.label`,msg:`Invalid label: "${this.label()}"`,hint:`expected ${JSON.stringify(this.columns())}`}),t}constructor(){super()}owner(e){return arguments.length?(this._owner=e,this):this._owner}valid(){return!!this.label()}toDDL(){return this.label()}fromDDL(e){return this.label(e)}static fromDDL(e){return new GroupByColumn().fromDDL(e)}hash(){return(0,r.hashSum)(this.label())}columns(){return this._owner.inFieldIDs()}};F.prototype._class+=` GroupByColumn`;function localCount(e,t){return e.length}var I={count:localCount,min:n.min,max:n.max,mean:n.mean,median:n.median,variance:n.variance,deviation:n.deviation,sum:n.sum},L=class AggregateField extends n.PropertyExt{_owner;disableAggrColumn(){return!this.fieldID()||!this.aggrType()||this.aggrType()===`count`}disableBaseCountColumn(){return!this.fieldID()||!this.aggrType()||this.aggrType()!==`mean`}validate(e){let t=[];return this.aggrColumn_valid()||t.push({source:`${e}.${this.fieldID()}.aggrColumn`,msg:`Invalid aggrColumn: "${this.aggrColumn()}"`,hint:`expected ${JSON.stringify(this.columns())}`}),this.baseCountColumn_valid()||t.push({source:`${e}.${this.fieldID()}.aggrColumn`,msg:`Invalid baseCountColumn: "${this.baseCountColumn()}"`,hint:`expected ${JSON.stringify(this.columns())}`}),t}constructor(){super()}owner(e){return arguments.length?(this._owner=e,this):this._owner}valid(){return!!this.fieldID()}toDDL(){return this.aggrType()===`count`?{fieldID:this.fieldID(),type:`count`}:{fieldID:this.fieldID(),type:this.aggrType(),inFieldID:this.aggrColumn(),baseCountFieldID:this.baseCountColumn()}}fromDDL(e){let t=this.fieldID(e.fieldID).aggrType(e.type);return e.type!==`count`&&(t.aggrColumn(e.inFieldID),t.baseCountColumn(e.baseCountFieldID)),t}static fromDDL(e){return new AggregateField().fromDDL(e)}hash(){return(0,r.hashSum)({label:this.fieldID(),aggrType:this.aggrType(),aggrColumn:this.aggrColumn()})}columns(){return this._owner.inFieldIDs()}hasColumn(){return this.columns().length}aggregate(e){return I[this.aggrType()](e,e=>+e[this.aggrColumn()])}aggrFunc(){let e=I[this.aggrType()],t=this.aggrColumn(),n=this.baseCountColumn();return n?r=>e(r,e=>e[t]/+e[n]):n=>e(n,e=>+e[t])}};L.prototype._class+=` AggregateField`;var R=class GroupBy extends Activity{validate(){let e=[];for(let t of this.validGroupBy())e=e.concat(t.validate(`GroupBy.column`));for(let t of this.validComputedFields())e=e.concat(t.validate(`GroupBy.computedFields`));return e}constructor(){super()}toDDL(){return{type:`groupby`,groupByIDs:this.fieldIDs(),aggregates:this.aggregates()}}fromDDL(e){return this.fieldIDs(e.groupByIDs).aggregates(e.aggregates)}static fromDDL(e){return new GroupBy().fromDDL(e)}fieldIDs(e){return arguments.length?(this.column(e.map(e=>F.fromDDL(e))),this):this.validGroupBy().map(e=>e.toDDL())}aggregates(e){return arguments.length?(this.computedFields(e.map(e=>L.fromDDL(e))),this):this.validComputedFields().map(e=>e.toDDL())}hash(){return(0,r.hashSum)({groupBy:this.column().map(e=>e.hash()),computedFields:this.computedFields().map(e=>e.hash())})}appendGroupBys(e){for(let t of e)this.column().push(new F().owner(this).label(t.field));return this}validGroupBy(){return this.column().filter(e=>e.valid())}exists(){return this.validGroupBy().length>0}inFieldIDs(){return this.inFields().map(e=>e.id)}field(e){for(let t of this.inFields())if(t.id===e)return t;return null}appendComputedFields(e){for(let t of e){let e=new L().owner(this).fieldID(t.label).aggrType(t.type);t.column!==void 0&&e.aggrColumn(t.column),this.computedFields().push(e)}return this}validComputedFields(){return this.computedFields().filter(e=>e.valid())}hasComputedFields(){return this.validComputedFields().length>0}computeFields(e){if(!this.exists())return super.computeFields(e);let t=[],n=this.validGroupBy();for(let e of n){let n=this.field(e.label()),r={type:n?n.type:`string`,id:e.label()};t.push(r)}for(let e of this.computedFields())if(e.fieldID()){let n={id:e.fieldID(),type:`number`};t.push(n)}if(this.details()){let e=t;if(this.exists()){let n={id:`values`,type:`dataset`,children:[]};t.push(n),e=n.children}let r=n.map(e=>e.label());e.push(...this.inFields().filter(e=>this.fullDetails()||r.indexOf(e.id)<0))}return()=>t}referencedFields(e){super.referencedFields(e);let t=[];for(let e of this.validGroupBy())t.push(e.label());for(let e of this.validComputedFields())e.aggrColumn()&&t.push(e.aggrColumn());super.resolveInFields(e,t)}computeData(){let e=super.computeData();if(e.length===0||!this.exists())return e;let t=this.validGroupBy().map(e=>e.label()),r=this.validComputedFields().map(e=>({label:e.fieldID(),aggrFunc:e.aggrFunc()})),i=(0,n.nest)().key(e=>{let n=``;for(let r of t)n+=`:`+e[r];return n}).entries(e).map(e=>{let n=e;delete n.key;for(let e of t)n[e]=n.values[0][e];for(let e of r)n[e.label]=e.aggrFunc(n.values);return n}),a=this.outFields();return i.map(e=>{let t={};for(let n of a)t[n.id]=e[n.id];return t})}};R.prototype._class+=` GroupBy`,F.prototype.publish(`label`,void 0,`set`,`Field`,function(){return this.columns()},{optional:!0,validate:e=>e.columns().indexOf(e.label())>=0}),L.prototype.publish(`fieldID`,null,`string`,`new Field ID`,null,{optional:!0,disable:e=>!e.hasColumn()}),L.prototype.publish(`aggrType`,`count`,`set`,`Aggregation Type`,[`count`,`min`,`max`,`sum`,`mean`,`median`,`variance`,`deviation`],{optional:!0,disable:e=>!e.fieldID()}),L.prototype.publish(`aggrColumn`,null,`set`,`Aggregation Field`,function(){return this.columns()},{optional:!0,disable:e=>e.disableAggrColumn(),validate:e=>e.columns().indexOf(e.aggrColumn())>=0}),L.prototype.publish(`baseCountColumn`,null,`set`,`Base Count Field`,function(){return this.columns()},{optional:!0,disable:e=>e.disableBaseCountColumn(),validate:e=>e.columns().indexOf(e.baseCountColumn())>=0}),R.prototype.publish(`column`,[],`propertyArray`,`Source Columns`,null,{autoExpand:F}),R.prototype.publish(`computedFields`,[],`propertyArray`,`Computed Fields`,null,{autoExpand:L}),R.prototype.publish(`details`,!1,`boolean`,`Show details`),R.prototype.publish(`fullDetails`,!1,`boolean`,`Show groupBy fileds in details`);var z=class Limit extends Activity{constructor(){super()}toDDL(){return{type:`limit`,limit:this.rows()}}fromDDL(e){return this.rows(e.limit)}static fromDDL(e){return new Limit().fromDDL(e)}hash(){return(0,r.hashSum)({limit:this.rows()})}exists(){return this.rows_exists()&&this.rows()>0}computeData(){let e=super.computeData();return e.length===0||!this.exists()?e:e.slice(0,Math.min(this.rows(),e.length))}};z.prototype._class+=` Limit`,z.prototype.publish(`rows`,void 0,`number`,`Limit output`);var B=class ComputedMapping extends n.PropertyExt{_owner;validate(e){let t=[];return this.value_valid()||t.push({source:`${e}.value`,msg:`Invalid value: "${this.value()}"`,hint:`expected: "any"`}),this.newValue_valid()||t.push({source:`${e}.newValue`,msg:`Invalid value: "${this.newValue()}"`,hint:`expected: "any"`}),t}constructor(){super()}owner(e){return arguments.length?(this._owner=e,this):this._owner}valid(){return!!this.value()&&!!this.newValue()}toDDL(){return{value:this.value(),newValue:this.newValue()}}fromDDL(e){return this.value(e.value).newValue(e.newValue)}static fromDDL(e){return new ComputedMapping().fromDDL(e)}};B.prototype._class+=` ComputedMapping`;var V=class ComputedField extends n.PropertyExt{_owner;disableColumn1(){return!this.label()||[`=`,`*`,`/`,`+`,`-`,`scale`,`map`].indexOf(this.type())<0}disableColumn2(){return!this.label()||[`*`,`/`,`+`,`-`].indexOf(this.type())<0}disableMapping(){return!this.label()||[`map`].indexOf(this.type())<0}disableChildField(){return!this.hasChildren()}validate(e){let t=[];return this.column1_valid()||t.push({source:`${e}.${this.label()}`,msg:`Invalid column1: "${this.column1()}"`,hint:`expected: ${JSON.stringify(this.columns())}`}),this.column2_valid()||t.push({source:`${e}.${this.label()}`,msg:`Invalid column2: "${this.column2()}"`,hint:`expected: ${JSON.stringify(this.columns())}`}),this.disableMapping()||this.validComputedMappings().forEach(t=>t.validate(`${e}.mapping`)),this.disableChildField()||this.validChildFields().forEach(t=>t.validate(`${e}.childField`)),t}hasChildren(){if(!this.label()||this.type()!==`=`||!this.column1())return!1;let e=this._owner.field(this.column1());return!!(e&&e.type===`dataset`&&e.children)}children(){let e=this._owner.field(this.column1());return e&&e.type===`dataset`?e.children:[]}constructor(){super()}owner(e){return arguments.length?(this._owner=e,this):this._owner}valid(){return!!this.label()}validComputedMappings(){return this.mapping().filter(e=>e.valid())}validChildFields(){return this.childField().filter(e=>e.valid())}hasChildFields(){return this.validChildFields().length}toDDL(){switch(this.type()){case`scale`:return{fieldID:this.label(),type:`scale`,sourceFieldID:this.column1(),factor:this.constValue()};case`template`:return{fieldID:this.label(),type:`template`,template:this.template()};case`=`:let e=this.validChildFields().map(e=>e.toDDL());return{fieldID:this.label(),type:`=`,sourceFieldID:this.column1(),transformations:e.length?e:void 0};case`map`:return{fieldID:this.label(),type:`map`,sourceFieldID:this.column1(),default:this.default(),mappings:this.validComputedMappings().map(e=>e.toDDL())};default:return{fieldID:this.label(),type:this.type(),sourceFieldID1:this.column1(),sourceFieldID2:this.column2()}}}fromDDL(e){let t=this.label(e.fieldID).type(e.type);switch(e.type){case`scale`:t.column1(e.sourceFieldID).constValue(e.factor);break;case`template`:t.template(e.template);break;case`=`:t.column1(e.sourceFieldID).childField(e.transformations?e.transformations.map(e=>ComputedField.fromDDL(e)):[]);break;case`map`:t.column1(e.sourceFieldID).default(e.default).mapping(e.mappings?e.mappings.map(e=>B.fromDDL(e)):[]);break;default:t.column1(e.sourceFieldID1).column2(e.sourceFieldID2)}return t}static fromDDL(e){return new ComputedField().fromDDL(e)}hash(){return(0,r.hashSum)(this.toDDL())}columns(){return this._owner.fieldIDs()}computedField(){switch(this.type()){case`=`:let e=this.validChildFields();return e.length===0&&this.hasChildren()&&(e=this.children().map(e=>new ComputedField().owner(this).label(e.id).type(`=`).column1(e.id))),{...this._owner.field(this.column1()),id:this.label(),children:e.length?e.map(e=>e.computedField()):void 0};case`*`:case`/`:case`+`:case`-`:case`scale`:return{id:this.label(),type:`number`};case`template`:return{id:this.label(),type:`string`};case`map`:return{id:this.label(),type:`object`}}return{id:this.label(),type:`string`}}projection(e){let t=this.hasChildFields(),n=this.validChildFields().map(t=>({label:t.label(),func:t.computeFunc(e)}));return r=>{let i=e&&t?{}:{...r};for(let e of n)i[e.label]=e.func(r);return e&&t&&(i.__lparam=r),i}}computeFunc(e){let t=this.column1(),i=this.column2();switch(this.type()){case`=`:return this.hasChildFields()?n=>(n[t].Row&&(0,r.isArray)(n[t].Row)?n[t].Row:n[t]).map(this.projection(e)):e=>e[t];case`*`:return e=>e[t]*+e[i];case`/`:return e=>e[t]/+e[i];case`+`:return e=>+e[t]+ +e[i];case`-`:return e=>e[t]-+e[i];case`scale`:let a=this.constValue();return e=>+e[t]*a;case`template`:let o=this.template();return e=>n.Utility.template(o,e);case`map`:let s=this.default(),c={};for(let e of this.mapping())c[e.value()]=e.newValue();return e=>c[e[t]]||s;default:return e=>e[t]}}fieldIDs(){let e=this._owner.field(this.column1());if(e)switch(e.type){case`dataset`:return e.children.map(e=>e.id);case`object`:return Object.keys(e.fields)}return[]}field(e){let t=this._owner.field(this.column1());if(t)switch(t.type){case`dataset`:for(let n of t.children)if(n.id===e)return n;break;case`object`:return t.fields[e]}}};V.prototype._class+=` ComputedField`;var H=class MultiField extends n.PropertyExt{_owner;constructor(){super()}hash(){return(0,r.hashSum)(this.toDDL())}owner(e){return arguments.length?(this._owner=e,this):this._owner}valid(){return!!this.label()&&this.validMultiFields().length>0}validate(e){let t=[];for(let n of this.validMultiFields())t=t.concat(n.validate(`${e}.computedFields`));return t}toDDL(){return{fieldID:this.label(),type:`multi`,transformations:this.transformations()}}fromDDL(e){return this.label(e.fieldID).transformations(e.transformations)}static fromDDL(e){return new MultiField().fromDDL(e)}validMultiFields(){return this.multiFields().filter(e=>e.valid())}transformations(e){return arguments.length?(this.multiFields(e.map(e=>V.fromDDL(e))),this):this.validMultiFields().map(e=>e.toDDL())}fieldIDs(){return this._owner.fieldIDs()}field(e){return this._owner.field(e)}};H.prototype._class+=` MultiField`;var ProjectBase=class extends Activity{static ComputedField=V;_includeLParam=!1;_trim=!1;validate(){let e=[];for(let t of this.validComputedFields())e=e.concat(t.validate(`${this.classID()}.computedFields`));return e}constructor(){super()}transformations(e){return arguments.length?(this.computedFields(e.map(e=>{switch(e.type){case`multi`:return H.fromDDL(e);default:return V.fromDDL(e)}})),this):this.validComputedFields().map(e=>e.toDDL())}exists(){return this.validComputedFields().length>0}fieldIDs(){return this.inFields().map(e=>e.id)}field(e){for(let t of this.inFields())if(t.id===e)return t;return null}clearComputedFields(){this.computedFields([])}appendComputedFields(e){for(let t of e){let e=new V().owner(this).label(t.label).type(t.type);t.column!==void 0&&e.column1(t.column),this.computedFields().push(e)}return this}validComputedFields(){return this.computedFields().filter(e=>e.valid())}hasComputedFields(){return this.validComputedFields().length}computeFields(e){if(!this.exists())return super.computeFields(e);let t=[],n={};for(let e of this.validComputedFields())if(e instanceof H)for(let r of e.validMultiFields()){let e=r.computedField();t.push(e),n[e.id]=!0}else{let r=e.computedField();t.push(r),n[r.id]=!0}if(this._trim&&this.hasComputedFields()){if(this._includeLParam){let e={id:`__lparam`,type:`object`};t.push(e),n[e.id]=!0}}else t=t.concat(e.filter(e=>!n[e.id]));return()=>t}referencedFields(e){super.referencedFields(e);let t=[];for(let e of this.validComputedFields())if(e instanceof H)for(let n of e.validMultiFields())t.push(n.column1()),n.column2()&&t.push(n.column2());else if(e.type()===`template`)for(let r of n.Utility.templateFields(e.template()))t.push(r);else t.push(e.column1()),e.column2()&&t.push(e.column2());super.resolveInFields(e,t)}projection(){let e=this._trim,t=this.hasComputedFields(),n=[];for(let t of this.validComputedFields())if(t instanceof H)for(let r of t.validMultiFields())n.push({label:r.label(),func:r.computeFunc(e)});else n.push({label:t.label(),func:t.computeFunc(e)});return r=>{let i=e&&t?{}:{...r};for(let e of n)i[e.label]=e.func(r);return e&&t&&this._includeLParam&&(i.__lparam=r),i}}computeData(){let e=super.computeData();return e.length===0||!this.exists()?e:e.map(this.projection())}},U=class Project extends ProjectBase{toDDL(){return{type:`project`,transformations:this.transformations()}}fromDDL(e){return this.transformations(e.transformations)}static fromDDL(e){return new Project().fromDDL(e)}hash(e={}){return super.hash({ddl:this.toDDL(),...e})}};U.prototype._class+=` Project`;var W=class Mappings extends ProjectBase{constructor(){super(),this._trim=!0,this._includeLParam=!0}toDDL(){return{type:`mappings`,transformations:this.transformations()}}fromDDL(e){let t=e||{transformations:[]};return this.transformations(t.transformations)}static fromDDL(e){return new Mappings().fromDDL(e)}hash(e={}){return super.hash({ddl:this.toDDL(),...e})}referencedFields(e){if(this.hasComputedFields())return super.referencedFields(e);this.resolveInFields(e,this.inFields().filter(e=>e.id!==`__lparam`).map(e=>e.id))}};W.prototype._class+=` Mappings`,B.prototype.publish(`value`,null,`any`,`Compare Value`,void 0,{validate:e=>!e.value()&&!e.newValue()||!!e.value()&&!!e.newValue()}),B.prototype.publish(`newValue`,null,`any`,`New Value`,void 0,{validate:e=>!e.value()&&!e.newValue()||!!e.value()&&!!e.newValue()}),V.prototype.publish(`label`,null,`string`,`Label`,null,{optional:!0}),V.prototype.publish(`type`,`mapping`,`set`,`Project type`,[`=`,`*`,`/`,`+`,`-`,`scale`,`template`,`map`],{optional:!0,disable:e=>!e.label()}),V.prototype.publish(`column1`,null,`set`,`Param 1`,function(){return this.columns()},{optional:!0,disable:e=>e.disableColumn1(),validate:e=>e.columns().indexOf(e.column1())>=0}),V.prototype.publish(`column2`,null,`set`,`Param 2`,function(){return this.columns()},{optional:!0,disable:e=>e.disableColumn2(),validate:e=>e.columns().indexOf(e.column2())>=0}),V.prototype.publish(`constValue`,null,`number`,`Const value`,null,{optional:!0,disable:e=>!e.label()||[`scale`].indexOf(e.type())<0}),V.prototype.publish(`template`,null,`string`,`template`,null,{optional:!0,disable:e=>!e.label()||[`template`].indexOf(e.type())<0}),V.prototype.publish(`default`,null,`any`,`Default Value`,null,{optional:!0,disable:e=>!e.label()||[`map`].indexOf(e.type())<0}),V.prototype.publish(`mapping`,[],`propertyArray`,`Mapped Values`,null,{autoExpand:B,disable:e=>e.disableMapping()}),V.prototype.publish(`childField`,[],`propertyArray`,`Child Fields`,null,{autoExpand:V,disable:e=>e.disableChildField()}),H.prototype.publish(`label`,``,`string`,`Label`),H.prototype.publish(`multiFields`,[],`propertyArray`,`Multi Fields`,null,{autoExpand:V}),ProjectBase.prototype.publish(`computedFields`,[],`propertyArray`,`Computed Fields`,null,{autoExpand:V});var G=class SortColumn extends n.PropertyExt{_owner;validate(e){let t=[];return this.fieldID_valid()||t.push({source:`${e}.fieldID`,msg:`Invalid fieldID: ${this.fieldID()}`,hint:`expected ${JSON.stringify(this.fieldIDs())}`}),t}constructor(){super()}owner(e){return arguments.length?(this._owner=e,this):this._owner}valid(){return!!this.fieldID()}toDDL(){return{fieldID:this.fieldID(),descending:this.descending()}}fromDDL(e){return this.fieldID(e.fieldID).descending(e.descending)}static fromDDL(e){return new SortColumn().fromDDL(e)}hash(){return(0,r.hashSum)({sortColumn:this.fieldID(),descending:this.descending()})}fieldIDs(){return this._owner.fieldIDs()}field(e){return this._owner.inFields().filter(t=>t.id===e)[0]}};G.prototype._class+=` SortColumn`;var K=class Sort extends Activity{static Column=G;validate(){let e=[];for(let t of this.validSortBy())e=e.concat(t.validate(`Sort.column`));return e}constructor(){super()}toDDL(){return{type:`sort`,conditions:this.conditions()}}fromDDL(e){return this.conditions(e.conditions),this}static fromDDL(e){return new Sort().fromDDL(e)}conditions(e){return arguments.length?(this.column(e.map(e=>G.fromDDL(e))),this):this.validSortBy().map(e=>e.toDDL())}hash(){return(0,r.hashSum)({Sort:this.column().map(e=>e.hash())})}referencedFields(e){super.referencedFields(e),super.resolveInFields(e,this.validSortBy().map(e=>e.fieldID()))}validSortBy(){return this.column().filter(e=>e.fieldID())}exists(){return this.validSortBy().length>0}fieldIDs(){return this.inFields().map(e=>e.id)}computeData(){let e=super.computeData(),t=[];for(let e of this.validSortBy())t.push({compare:e.descending()?n.descending:n.ascending,id:e.fieldID()});return t.length?[...e].sort((e,n)=>{for(let r of t){let t=r.compare(e[r.id],n[r.id]);if(t!==0)return t}return 0}):e}};K.prototype._class+=` Sort`,G.prototype.publish(`fieldID`,null,`set`,`Sort Field`,function(){return this.fieldIDs()},{optional:!0,validate:e=>e.fieldIDs().indexOf(e.fieldID())>=0}),G.prototype.publish(`descending`,!1,`boolean`,`Sort Field`),K.prototype.publish(`column`,[],`propertyArray`,`Source Columns`,null,{autoExpand:G});var HipiePipeline=class extends ActivityPipeline{_ec;_origDatasource;_origFilters;_origProject;_origGroupBy;_origSort;_origLimit;constructor(e,t){super(),this._ec=e,this._id=t,this._datasource=new DSPicker(this._ec),this._filters=new P(this._ec),this._project=new U,this._groupBy=new R,this._sort=new K,this._limit=new z,this.updateSequence()}activities(e){return super.activities.apply(this,arguments)}updateSequence(){this.activities([this.datasource(),this.filters(),this.project(),this.groupBy(),this.sort(),this.limit()])}selectionFields(){return this.last().outFields()}};HipiePipeline.prototype.publish(`datasource`,null,`widget`,`Data Source 2`),HipiePipeline.prototype.publish(`filters`,null,`widget`,`Client Filters`),HipiePipeline.prototype.publish(`project`,null,`widget`,`Project`),HipiePipeline.prototype.publish(`groupBy`,null,`widget`,`Group By`),HipiePipeline.prototype.publish(`sort`,null,`widget`,`Sort`),HipiePipeline.prototype.publish(`limit`,null,`widget`,`Limit output`);function wrapHipiePipelineProperty(e){let t=`_orig${e.charAt(0).toUpperCase()+e.slice(1)}`;HipiePipeline.prototype[t]=HipiePipeline.prototype[e],HipiePipeline.prototype[e]=function(e){let n=HipiePipeline.prototype[t].apply(this,arguments);return e!==void 0&&this.updateSequence(),n}}wrapHipiePipelineProperty(`datasource`),wrapHipiePipelineProperty(`filters`),wrapHipiePipelineProperty(`project`),wrapHipiePipelineProperty(`groupBy`),wrapHipiePipelineProperty(`sort`),wrapHipiePipelineProperty(`limit`);var NullView=class extends HipiePipeline{hash(){return super.hash()}_fetch(e,t){return Promise.resolve([])}};NullView.prototype._class+=` NullView`;var VizPopupPanel=class extends u.Modal{_owner;_ownerLParam;constructor(e,t){super(),this._owner=e,this._ownerLParam=t,this._drawStartPos=`origin`,this.visible(!1),this.minHeight_default(`240px`),this.minWidth_default(`320px`),this.overflowY_default(`hidden`)}_host;host(e){return arguments.length?(this._host&&this._host!==e&&this._host._togglePopup.selected(!1).render(),this._host=e,this._owner.vizActivation(this._ownerLParam),this):this._host}enter(e,t){e.parentElement.style.position=`absolute`;let n=this.widget().title();n&&(this.title(n),this.widget().titleVisible(!1)),super.enter(e,t)}update(e,t){this.fixedTop(this._pos.y+`px`),this.fixedLeft(this._pos.x+`px`),super.update(e,t)}exit(e,t){super.exit(e,t),this.widget().title()&&this.widget().titleVisible(!0)}closeModal(){super.closeModal(),this._host&&this._host._togglePopup.selected(!1).render()}};VizPopupPanel.prototype._class+=` marshaller_VizPopupPanel`;var VizChartPanel=class extends u.ChartPanel{_popup;_togglePopup=new n.ToggleButton().faChar(`fa-filter`).tooltip(`Filter`).on(`click`,()=>{this._popup.host(this);let e=this.locateClosestAncestor([`marshaller_DashboardDockPanel`,`marshaller_DashboardGrid`]).getBBox(!0),t=this._popup.widget(),n=this._togglePopup.getBBox();this._popup.pos({x:-e.x+n.x+n.width-t.minWidth(),y:-e.y+n.y+n.height}).resize({width:t.minWidth(),height:t.minHeight()}).visible(this._togglePopup.selected()).render(e=>{let t=`#`+e.id()+` .layout_Carousel .common_Widget`,n=e.element().node();if(n){let{height:r,width:i}=n.querySelector(t).getBoundingClientRect();e.resizeBodySync(i,r)}})});_origButtons;_filterButtons;constructor(){super(),this._origButtons=this.buttons(),this._filterButtons=[this._togglePopup,new n.Spacer,...this._origButtons]}popup(e){return arguments.length?(this._popup=e,this._popup||this._togglePopup.selected(!1),this.buttons(this._popup?this._filterButtons:this._origButtons),this):this._popup}};VizChartPanel.prototype._class+=` marshaller_VizChartPanel`,VizChartPanel.prototype.publish(`descriptionTemplate`,``,`string`),VizChartPanel.prototype.publish(`minWidth`,320,`number`,`Min Width`),VizChartPanel.prototype.publish(`minHeight`,240,`number`,`Min Height`);var q={Table:o.Table,FieldForm:s.FieldForm,Area:a.Area,Bubble:a.Bubble,Bar:a.Bar,Column:a.Column,Contour:a.Contour,HexBin:a.HexBin,Line:a.Line,Pie:a.Pie,Radar:a.Radar,RadialBar:a.RadialBar,Scatter:a.Scatter,Step:a.Step,WordCloud:a.WordCloud,USCountiesChoropleth:l.ChoroplethCounties,USStatesChoropleth:l.ChoroplethStates,ClusterPins:l.Leaflet.ClusterPins,EntityRectList:n.EntityRectList,AdjacencyGraph:c.AdjacencyGraph,DataGraph:c.DataGraph},J=[];for(let e in q)J.push(e);function typeClass(e){return q[e]||o.Table}function typeNew(e){let t=new(q[e]||o.Table);return t instanceof s.FieldForm?t.validate(!1).allowEmptyRequest(!0):t instanceof c.AdjacencyGraph&&t.uidColumn(`uid`).labelColumn(`label`).iconColumn(`icon`).linksColumn(`links`).linkUidColumn(`uid`).linkLabelColumn(`label`),t}function typeInputs(e){return typeClass(e).__inputs||[]}var Visualization=class extends n.PropertyExt{_ec;_origVisibility;_origChartType;_origChartPanel;_hipiePipeline;constructor(e,t){super(),this._ec=e,this._hipiePipeline=t,this.mappings(new W),this.chartPanel(new VizChartPanel),this.typeChanged()}visualizationIDs(){return this._ec.elementIDs().filter(e=>e!==this.id())}_prevChartType;typeChanged(){if(this._prevChartType!==this._chartType){this._prevChartType=this._chartType,this.refreshMappings();let e=typeNew(this._chartType);this.chartPanel().widget(e)}}properties(e){return arguments.length?(this.chartPanel().deserialize(e),this):this.chartPanel().serialize()}refreshMappings(){let e=this.mappings();e.sourceActivity(this._hipiePipeline);let t=e.validComputedFields(),n=e.inFields(),r={};return e.computedFields(typeInputs(this._chartType).map((i,a)=>{let o=t[a];if(o)o instanceof H||o.label(i.id);else if(i.multi){o=new H().owner(e).label(i.id);let t=[];for(let e of n)(i.type===`any`||i.type===e.type)&&!r[e.id]&&(r[e.id]=!0,t.push(new V().label(e.id).type(`=`).column1(e.id)));o.multiFields(t)}else{o=new V().owner(e).label(i.id).type(`=`);for(let e of n)if((i.type===`any`||i.type===e.type)&&!r[e.id]){r[e.id]=!0,o.column1(e.id);break}}return o})),this}_prevFields=[];_prevLinkFields=[];_prevData=[];refreshData(){let e=this.mappings(),t=e.outFields(),n=this.toDBFields(t),r,i=[],a=this._ec.element(this.secondaryDataviewID());a&&(r=a.mappings().outFields(),i=this.toDBFields(r));let o=this._prevFields!==t||this._prevLinkFields!==r;if(o)if(this._prevFields=t,this.chartType()===`DataGraph`){let e=this.chartPanel().widget();e.vertexColumns(n.map(e=>e.label())),e.edgeColumns(i.map(e=>e.label()))}else this.chartPanel().fields(n.filter(e=>e.id()!==`__lparam`));else console.warn(`***${this.id()} Immutable Fields***`);let s=e.outData(),c=this._prevData!==s;if(c){this._prevData=s;let e=this.toDBData(n,s);if(this.chartType()===`DataGraph`){let t=this.chartPanel().widget();if(t.vertices(e),a){let e=a.mappings().outData(),n=this.toDBData(i,e);t.edges(n)}}else this.chartPanel().data(e)}else console.warn(`${this.id()} Immutable Data!`);return o||c?this.chartPanel().renderPromise().then(()=>{}):Promise.resolve()}fieldTypeTodbFieldType(e){switch(e){case`dataset`:return`nested`;case`boolean`:return`boolean`;case`number`:return`number`;default:return`string`}}toDBFields(e){let t=[];for(let r of e||[]){let e=new n.Database.Field().type(this.fieldTypeTodbFieldType(r.type)).id(r.id).label(r.id);switch(r.type){case`dataset`:e.children(this.toDBFields(r.children));break;case`object`:break}t.push(e)}return t}toDBData(e,t){return((0,r.isArray)(t)?t:[t]).map(t=>{let n=[];for(let r of e)r.type()===`nested`?n.push(this.toDBData(r.children(),t[r.id()].Row||t[r.id()])):n.push(t[r.label()]);return n})}exec(){let e=[];if(this.secondaryDataviewID_exists()){let t=this.secondaryDataviewID(),n=this._ec.element(t);n&&e.push(n.visualization().exec())}let t=this.mappings();return t.sourceActivity(this._hipiePipeline),e.push(t.refreshMeta().then(()=>t.exec())),Promise.all(e)}refresh(){return this.chartPanel().startProgress&&this.chartPanel().startProgress(),this.exec().then(()=>(this.chartPanel().finishProgress&&this.chartPanel().finishProgress(),this.refreshData()))}click(e,t,n,r){}vertex_click(e,t,n){}};Visualization.prototype._class+=` Visualization`,Visualization.prototype.publishProxy(`title`,`_chartPanel`),Visualization.prototype.publishProxy(`description`,`_chartPanel`),Visualization.prototype.publish(`visibility`,i.DDL2.VisibilitySet[0],`set`,`Type`,i.DDL2.VisibilitySet),Visualization.prototype.publish(`chartType`,`Table`,`set`,`Type`,J),Visualization.prototype.publish(`secondaryDataviewID`,null,`set`,`Secondary Data View (e.g. graph edges)`,function(){return this.visualizationIDs()},{optional:!0}),Visualization.prototype.publish(`mappings`,null,`widget`,`Mappings`,void 0,{render:!1,internal:!0}),Visualization.prototype.publish(`chartPanel`,[],`widget`,`Widget`),Visualization.prototype._origVisibility=Visualization.prototype.visibility,Visualization.prototype.visibility=function(e){let t=this._visibility,n=Visualization.prototype._origVisibility.apply(this,arguments);return e!==void 0&&t!==e&&this.chartPanel().target(null),n},Visualization.prototype._origChartType=Visualization.prototype.chartType,Visualization.prototype.chartType=function(e,t){e!==void 0&&J.indexOf(e)===-1&&(e=`Table`);let n=Visualization.prototype._origChartType.apply(this,arguments);if(e!==void 0&&(this.typeChanged(),t)){let e=this.chartPanel().widget();for(let n in t)typeof e[n]==`function`&&e[n](t[n])}return n},Visualization.prototype._origChartPanel=Visualization.prototype.chartPanel,Visualization.prototype.chartPanel=function(e){let t=Visualization.prototype._origChartPanel.apply(this,arguments);if(e!==void 0){this._chartPanel.on(`click`,(e,t,n,r)=>this.click(e,t,n,r)).on(`vertex_click`,(e,t,n)=>this.vertex_click(e,t,n));for(let e in q)if(this._chartPanel.widget()instanceof q[e]){this._chartType=e;break}}return t};var State=class extends n.PropertyExt{constructor(){super(),this.selection([])}set(e){return(0,r.hashSum)(this.selection())===(0,r.hashSum)(e)?!1:(this.selection(e),!0)}removeInvalid(e){let t=this.selection(),n=[];for(let i of t)(0,r.find)(e,(e,t)=>{for(let t in i)if(i[t]!==e[t])return!1;return!0})&&n.push(i);return n.length===t.length?!1:(this.selection(n),!0)}};State.prototype._class+=` State`,State.prototype.publish(`selection`,[],`array`,`State`);var Y=0,Element=class extends n.PropertyExt{_ec;_vizChartPanel;_origVisualization;constructor(e){for(super(),this._ec=e;Y++,this._id=`e_${Y}`,this._ec.elementExists(this._id););let t=new HipiePipeline(this._ec,this._id);this.hipiePipeline(t),this._vizChartPanel=new Visualization(this._ec,this.hipiePipeline()).id(`viz_${Y}`).title(`Element ${Y}`),this._vizChartPanel.chartPanel().id(`cp_${Y}`),this.visualization(this._vizChartPanel),this.state(new State)}id(e){let t=super.id.apply(this,arguments);return arguments.length&&this._vizChartPanel.id(e),t}chartType(){return this._vizChartPanel.chartType()}chartPanel(e){return arguments.length?(this._vizChartPanel.chartPanel(e),this):this._vizChartPanel.chartPanel()}chart(){return this._vizChartPanel.chartPanel().widget()}mappings(e){return arguments.length?(this._vizChartPanel.mappings(e),this):this._vizChartPanel.mappings()}pipeline(e){return this.hipiePipeline().activities(e),this}updatedBy(){let e=this.hipiePipeline().updatedBy();return this.visualization().secondaryDataviewID_exists()&&e.push(this.visualization().secondaryDataviewID()),e}dataProps(){return this.hipiePipeline()}vizProps(){return this.visualization().chartPanel()}stateProps(){return this.state()}_errors=[];errors(){return this._errors}validate(){if(!this._initialized)return[];this._errors=[];let e=this.hipiePipeline();for(let t of[...e.activities(),this.mappings()])for(let e of t.validate())this._errors.push({elementID:this.id(),...e});return this._errors}_initialized=!1;refresh(){let e=this.hipiePipeline().filters().validFilters().map(e=>e.createFilterDescription());return this.visualization().chartPanel().description(e.join(`, `)),this.visualization().refresh().then(()=>{this._initialized=!0;let e=this.hipiePipeline().outData();this.visualization().chartType()===`FieldForm`?this.state().set([...e])&&this.selectionChanged():this.state().removeInvalid(e)&&this.selectionChanged()})}selection(e){return arguments.length?(this.state().selection(e),this.selectionChanged(),this):this.state().selection()}selectionChanged(){let e=[];for(let t of this._ec.filteredBy(this.id()))e.push(t.refresh());Promise.all(e).then(()=>{this._ec.vizStateChanged(this)})}monitor(e){return this.hipiePipeline().monitor(e)}};Element.prototype._class+=` Viz`,Element.prototype.publish(`hipiePipeline`,null,`widget`,`Data View`),Element.prototype.publish(`visualization`,null,`widget`,`Visualization`),Element.prototype.publish(`state`,null,`widget`,`State`),Element.prototype._origVisualization=Element.prototype.visualization,Element.prototype.visualization=function(e){let t=Element.prototype._origVisualization.apply(this,arguments);return e!==void 0&&this._visualization.on(`click`,(e,t,n,i)=>{if(i&&i.selection)this.selection(n?i.selection.map(e=>e.__lparam||e):[]);else{let t=(0,r.isArray)(e)?e:[e];this.selection(n?t.map(e=>e.__lparam||e):[])}}).on(`vertex_click`,(e,t,n)=>{let i=(0,r.isArray)(e)?e:[e];this.selection(n?i.map(e=>e.__lparam||e):[])}),t};var ElementContainer=class extends n.PropertyExt{_nullElement;_datasources=[b];_elements=[];constructor(){super(),this.clear(),this._nullElement=new Element(this)}clear(e){this._datasources=e===void 0?[b]:this._datasources,this._elements=e===void 0?[]:this._elements.filter(t=>t.id()!==e)}_hookSend;hookSend(e){return arguments.length?(this._hookSend=e,this):this._hookSend}datasources(e){return arguments.length?(this._datasources=e,this):this._datasources}datasource(e){return this._datasources.filter(t=>t.id()===e)[0]}appendDatasource(e){return this._datasources.push(e),this}removeDatasource(e){return this._datasources=this._datasources.filter(t=>t!==e),this}elements(){return[...this._elements]}element(e){let t;return t=typeof e==`string`?this._elements.filter(t=>t.id()===e):e instanceof VizChartPanel?this._elements.filter(t=>t.chartPanel()===e):this._elements.filter(t=>t.vizProps()===e),t.length?t[0]:this._nullElement}elementExists(e){return this.element(e)!==this._nullElement}elementIDs(){return this._elements.map(e=>e.id())}append(e){return this._elements.push(e),this}filteredBy(e){return this._elements.filter(t=>t.updatedBy().indexOf(e)>=0)}views(){return this._elements.map(e=>e.hipiePipeline())}view(e){return this.views().filter(t=>t.id()===e)[0]}normalizePersist(e){let t={};return e.__properties.content.map(e=>{let n=!!e.__properties.widget.__properties.chart,r=e,i=e.__properties.widget,a=n?e.__properties.widget.__properties.chart:e.__properties.widget.__properties.widget,o=e.__properties.widget.__id?e.__properties.widget.__id:e.__properties.widget.__properties.widget.__id;t[o]={id:o,package:a.__class.split(`_`)[0],object:a.__class.split(`_`)[1],cell:_get_params(r,[`chart`,`widget`,`fields`]),panel:_get_params(i,[`chart`,`widget`,`fields`]),widget:_get_params(a,[`fields`])}}),t;function _get_params(e,t){let n={};return Object.keys(e.__properties).filter(e=>t.indexOf(e)===-1).forEach(t=>n[t]=e.__properties[t]),n}}validate(){let e=[];return this._elements.forEach(t=>{e=e.concat(t.validate())}),e}refresh(){return Promise.all(this.elements().map(e=>e.refresh())).then(()=>this)}vizStateChanged(e){}};ElementContainer.prototype._class+=` dashboard_ElementContainer`,ElementContainer.prototype.publish(`samples`,10,`number`,`Number of samples`),ElementContainer.prototype.publish(`sampleSize`,100,`number`,`Sample size`);function responseText(e){if(!e.ok)throw Error(e.status+` `+e.statusText);return e.text()}function text_default(e,t){return fetch(e,t).then(responseText)}__name(text_default,`default`);var PopupManager=class extends n.Widget{_ec;_popups=[];_popupIdx={};popupPanels(){return this._popups||=[],this._popupIdx||={},this._popups}popupChartPanels(){return this.popupPanels().map(e=>e.widget())}addPopup(e){let t=this._ec.element(e),n=this.element().node(),r=new VizPopupPanel(this,t).target(n).widget(e).relativeTargetId(this.id()).size({width:e.minWidth(),height:e.minHeight()});this._popups.push(r),this._popupIdx[e.id()]={panel:r,monitorHandle:e.monitor(t=>{switch(t){case`minWidth`:case`minHeight`:r.resize({width:e.minWidth(),height:e.minHeight()}).render();break}})},this._ec.filteredBy(t.id()).forEach(e=>{e.visualization().chartPanel().popup(r)})}removePopup(e){let t=this._ec.element(e);this._ec.filteredBy(t.id()).forEach(e=>{e.visualization().chartPanel().popup(null)}),this._popupIdx[e.id()].panel.target(null),this._popupIdx[e.id()].monitorHandle.remove(),e.target(null),delete this._popupIdx[e.id()],this._popups=this._popups.filter(t=>t.widget()!==e)}syncPopups(){let e=(0,r.compare)(this.popupChartPanels(),this._ec.elements().filter(e=>e.visualization().visibility()===`flyout`).map(e=>e.visualization().chartPanel()));for(let t of e.exit)this.removePopup(t);for(let t of e.enter)this.addPopup(t);return this}vizActivation(){}},DashboardDockPanel=class extends d.DockPanel{_ec;constructor(e){super(),this._ec=e}tabTitle(e){return this.hideSingleTabs()?e.visualization().title?e.visualization().title():e.visualization().id():e.id()}titleClassed(e,t,n){let r=e.title.className.split(` `);n&&r.indexOf(t)<0?r.push(t):!n&&r.indexOf(t)>0&&(r=r.filter(e=>e!==t)),e.title.className=r.join(` `)}updateTitle(e){let t=this.getWidgetAdapter(e),n=this._ec.element(e),r=n.validate();t.title.label=this.tabTitle(n),this.titleClassed(t,`error`,r.length>0),t.title.caption=r.map(e=>`${e.source}: ${e.msg}`).join(`
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@hpcc-js/comms"),require("@hpcc-js/common"),require("@hpcc-js/util"),require("@hpcc-js/ddl-shim"),require("@hpcc-js/chart"),require("@hpcc-js/dgrid"),require("@hpcc-js/form"),require("@hpcc-js/graph"),require("@hpcc-js/map"),require("@hpcc-js/layout"),require("@hpcc-js/phosphor"),require("@hpcc-js/codemirror"),require("@hpcc-js/other")):typeof define==`function`&&define.amd?define([`exports`,`@hpcc-js/comms`,`@hpcc-js/common`,`@hpcc-js/util`,`@hpcc-js/ddl-shim`,`@hpcc-js/chart`,`@hpcc-js/dgrid`,`@hpcc-js/form`,`@hpcc-js/graph`,`@hpcc-js/map`,`@hpcc-js/layout`,`@hpcc-js/phosphor`,`@hpcc-js/codemirror`,`@hpcc-js/other`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e[`@hpcc-js/marshaller`]={},e[`@hpcc-js/comms`],e[`@hpcc-js/common`],e[`@hpcc-js/util`],e[`@hpcc-js/ddl-shim`],e[`@hpcc-js/chart`],e[`@hpcc-js/dgrid`],e[`@hpcc-js/form`],e[`@hpcc-js/graph`],e[`@hpcc-js/map`],e[`@hpcc-js/layout`],e[`@hpcc-js/phosphor`],e[`@hpcc-js/codemirror`],e[`@hpcc-js/other`]))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d,f,ee){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var te=Object.defineProperty,__name=(e,t)=>te(e,`name`,{value:t,configurable:!0}),p=`@hpcc-js/marshaller`,m=`3.3.1`,h=`3.26.1`;function stringify(e){return Array.isArray(e)?`[`+e.map(stringify).join(`, `)+`]`:typeof e!=`object`||!e||e===void 0?JSON.stringify(e):`{ ${Object.keys(e).map(t=>`${t}: ${stringify(e[t])}`).join(`, `)} }`}function schemaType2IFieldType(e){switch(e){case`boolean`:return`boolean`;case`xs:byte`:case`xs:double`:case`xs:decimal`:case`xs:float`:case`xs:int`:case`xs:short`:case`xs:unsignedInt`:case`xs:unsignedShort`:case`xs:unsignedByte`:case`number`:return`number`;case`xs:integer`:case`xs:long`:case`xs:negativeInteger`:case`xs:nonNegativeInteger`:case`xs:nonPositiveInteger`:case`xs:positiveInteger`:case`xs:unsignedLong`:return`number64`;case`string`:return`string`;case`range`:return`range`}return`string`}function schemaRow2IField(e){return e._children&&e._children.length?{type:`dataset`,id:e.name,children:e._children.map(schemaRow2IField)}:{id:e.name,type:schemaType2IFieldType(e.type)}}function wsEclSchemaRow2IField(e){return e}var Activity=class extends n.PropertyExt{_sourceActivity;fixInt64(e){if(!e||e.length===0)return[];let t=this.outFields().filter(t=>{switch(t.type){case`number`:return typeof e[0][t.id]!=`number`;case`number64`:return!0}return!1});return t.length?e.map(e=>{for(let n of t)e[n.id]=+e[n.id];return e}):e}sourceActivity(e){return arguments.length?(this._sourceActivity=e,this):this._sourceActivity}hash(e={}){return(0,r.hashSum)({...e})}refreshMeta(){return this._sourceActivity?this._sourceActivity.refreshMeta():Promise.resolve()}exists(){return!0}validate(){return[]}label(){return this.id()}updatedBy(){return[]}_emptyFields=[];inFields(){return this._sourceActivity?this._sourceActivity.outFields():this._emptyFields}computeFields(e){return()=>e}outFields(){return this.computeFields(this.inFields())()}localFields(){let e=this.inFields().map(e=>e.id);return this.outFields().filter(t=>e.indexOf(t.id)<0)}fieldOrigin(e){return this.localFields().filter(t=>t.id===e).length?this:this.sourceActivity()?this.sourceActivity().fieldOrigin(e):null}resolveFields(e,t){for(let n of t){let t=this.fieldOrigin(n);t&&(e.outputs[t.id()]||(e.outputs[t.id()]=[]),e.outputs[t.id()].indexOf(n)<0&&e.outputs[t.id()].push(n))}}resolveInFields(e,t){return this._sourceActivity&&this._sourceActivity.resolveFields(e,t)}referencedFields(e){this._sourceActivity?.referencedFields(e)}exec(){return this._sourceActivity?this._sourceActivity.exec():Promise.resolve()}_emptyData=[];inData(){return this._sourceActivity&&this._sourceActivity.outData()||this._emptyData}computeData(){return this.inData()}_prevDataHash=``;_prevInData=[];_prevData=[];cachedComputeData(e){let t=this.hash();return(this._prevDataHash!==t||this._prevInData!==e)&&(this._prevDataHash=t,this._prevInData=e,this._prevData=(0,r.update)(this._prevData,this.computeData())),this._prevData}outData(){return this.cachedComputeData(this.inData())}},ActivityArray=class extends Activity{_activities=[];activities(e){return arguments.length?(this._activities=e,this):this._activities}};ActivityArray.prototype._class+=` ActivityArray`;var ActivityPipeline=class extends ActivityArray{activities(e){if(!arguments.length)return super.activities();super.activities(e);let t;for(let n of e)t&&n.sourceActivity(t),t=n;return this}first(){return this.activities()[0]}last(){let e=this.activities();return e[e.length-1]}calcUpdatedGraph(e){return e.updatedBy().map(t=>({from:t,to:e}))}updatedByGraph(){let e=[];for(let t of this.activities())e=e.concat(this.calcUpdatedGraph(t));return e}fetch(e=0,t=Number.MAX_VALUE){return this.exec().then(()=>{let n=this.outData();return e===0&&n.length<=t?n:n.slice(e,e+t)})}hash(e={}){return(0,r.hashSum)({activities:[this.activities().map(e=>e.hash())],...e})}refreshMeta(){return this.last().refreshMeta()}updatedBy(){let e=[];for(let t of this.activities())e=e.concat(t.updatedBy());return e}inFields(){return this.first().inFields()}outFields(){return this.last().outFields()}localFields(){return this.last().localFields()}fieldOrigin(e){return this.last().fieldOrigin(e)}referencedFields(e){this.last().referencedFields(e)}resolveInFields(e,t){this.last().resolveInFields(e,t)}resolveFields(e,t){this.last().resolveFields(e,t)}exec(){return this.last().exec()}outData(){return this.last().outData()}};ActivityPipeline.prototype._class+=` ActivitySequence`;var ActivitySelection=class extends ActivityArray{_selection;_monitorHandle;selection(e){return e===void 0?this._selection:(this._monitorHandle&&this._monitorHandle.remove(),this._selection=e,this._monitorHandle=e.monitor((t,n,r)=>{this.broadcast(t,n,r,e)}),this)}hash(e={}){return(0,r.hashSum)({selection:this.selection().hash(),...e})}label(){return this.selection().label()}refreshMeta(){return this.selection().refreshMeta()}updatedBy(){return this.selection().updatedBy()}inFields(){return this.selection().inFields()}outFields(){return this.selection().outFields()}localFields(){return this.selection().localFields()}fieldOrigin(e){return this.selection().fieldOrigin(e)}referencedFields(e){this.selection().referencedFields(e)}resolveInFields(e,t){this.selection().resolveInFields(e,t)}resolveFields(e,t){this.selection().resolveFields(e,t)}exec(){return this.selection().exec()}outData(){return this.selection().outData()}};ActivitySelection.prototype._class+=` ActivitySelection`;var g=0,Datasource=class extends Activity{constructor(){super(),this._id=`ds_${++g}`}},DatasourceRef=class extends Activity{_origDatasource;constructor(){super()}hash(e={}){return super.hash({datasource:this._datasource?this._datasource.hash(e):void 0,...e})}toDDL(){return{id:this.datasource().id()}}};DatasourceRef.prototype._class+=` DatasourceRef`,DatasourceRef.prototype.publish(`datasource`,null,`widget`,`Datasource Reference`,null,{internal:!0}),DatasourceRef.prototype._origDatasource=DatasourceRef.prototype.datasource,DatasourceRef.prototype.datasource=function(e){let t=DatasourceRef.prototype._origDatasource.apply(this,arguments);return e!==void 0&&this.sourceActivity(e),t};var _=class FormField extends n.PropertyExt{_owner;disableChildField(){return this.type()!==`dataset`}constructor(){super()}toDDL(){return{type:this.type(),id:this.fieldID(),default:this.default(),children:this.type()===`dataset`?this.childFields().map(e=>e.toDDL()):void 0}}fromDDL(e){return this.type(e.type).fieldID(e.id).default(e.default).childFields(e.type===`dataset`&&e.children?e.children.map(FormField.fromDDL):[])}static fromDDL(e){return new FormField().fromDDL(e)}owner(e){return arguments.length?(this._owner=e,this):this._owner}valid(){return!!this.type()&&!!this.fieldID()}coerceFunc(){switch(this.type()){case`boolean`:return e=>!!e;case`number`:return e=>+e;case`string`:return e=>``+e}return e=>e}calcValue(){return this.value_exists()?this.value():this.default()}},v=class Form extends Datasource{constructor(){super()}toDDL(){return{type:`form`,id:this.id(),fields:this.validFields().map(e=>e.toDDL())}}fromDDL(e,t=!1){return(t?this:this.id(e.id)).formFields(e.fields.map(_.fromDDL)),this}static fromDDL(e,t=!1){return new Form().fromDDL(e,t)}validFields(){return this.formFields().filter(e=>e.valid())}hash(e={}){return super.hash({ddl:this.toDDL(),...e})}refreshMeta(){return Promise.resolve()}label(){return`Form`}computeFields(e){let t=this.validFields().map(e=>e.toDDL());return()=>t}exec(){return Promise.resolve()}computeData(){let e={};return this.validFields().forEach(t=>{e[t.fieldID()]=t.calcValue()}),[e]}total(){return 1}};v.prototype._class+=` Form`,_.prototype.publish(`type`,`string`,`set`,`FormField Type`,[`boolean`,`number`,`string`,`dataset`]),_.prototype.publish(`fieldID`,``,`string`,`FormField Label`),_.prototype.publish(`default`,null,`any`,`Default Value`,null,{optional:!0}),_.prototype.publish(`value`,null,`any`,`Default Value`,null,{optional:!0}),_.prototype.publish(`childFields`,[],`propertyArray`,`Child Fields`,null,{autoExpand:_,disable:e=>e.disableChildField()}),v.prototype.publish(`formFields`,[],`propertyArray`,`Multi Fields`,null,{autoExpand:_});function fieldType(e){if((0,r.isArray)(e))return`dataset`;let t=typeof e;switch(t){case`boolean`:case`number`:case`string`:case`object`:return t}return`string`}function rowToFields(e,t){let n=[];for(let r in e){let i={type:fieldType(e[r]),id:r};switch(i.type){case`object`:for(let e of t){let t=!1;for(let n in e[r]){let n=rowToFields(e[r],[e[r]]);i.fields={},n.length&&(n.forEach(e=>i.fields[e.id]=e),t=!0);break}if(t)break}break;case`dataset`:for(let e of t)if(e[r]&&e[r].length){i.children=rowToFields(e[r][0],e[r]);break}break}n.push(i)}return n}var y=class Databomb extends Datasource{_jsonData=[];constructor(){super()}toDDL(e=!1){return{type:`databomb`,id:this.id(),format:this.format(),payload:e?void 0:this.payload(),fields:this.validFields().map(e=>e.toDDL())}}fromDDL(e,t=!1){return(t?this:this.id(e.id)).format(e.format).payload(e.payload).databombFields(e.fields.map(_.fromDDL)),this}static fromDDL(e,t=!1){return new Databomb().fromDDL(e,t)}validFields(){return this.databombFields().filter(e=>e.valid())}updateJsonData(){try{switch(this.format()){case`csv`:this._jsonData=(0,n.csvParse)(this.payload());break;case`tsv`:this._jsonData=(0,n.tsvParse)(this.payload());break;default:this._jsonData=JSON.parse(this.payload());break}this.databombFields(this.preCalcFields().map(_.fromDDL))}catch{this.databombFields([]),this._jsonData=[]}}hash(e){return super.hash({ddl:this.toDDL(!0),...e})+this.payload()}refreshMeta(){return Promise.resolve()}label(){return`Databomb`}preCalcFields(){return this._jsonData.length===0?[]:rowToFields(this._jsonData[0],this._jsonData)}computeFields(e){return()=>this.validFields().map(e=>e.toDDL())}exec(){return Promise.resolve()}computeData(){let e={};return this.validFields().forEach(t=>{e[t.fieldID()]=t.coerceFunc()}),this._jsonData.map(t=>{let n={};for(let r in e)n[r]=e[r](t[r]);return n})}total(){return this._jsonData.length}};y.prototype._class+=` Databomb`,y.prototype.publish(`format`,`json`,`set`,`Databomb Format`,[`json`,`csv`,`tsv`]),y.prototype.publish(`payload`,``,`string`,`Databomb array`,null,{multiline:!0}),y.prototype.publish(`databombFields`,[],`propertyArray`,`Multi Fields`,null,{autoExpand:_});var ne=y.prototype.format;y.prototype.format=function(e){let t=ne.apply(this,arguments);return arguments.length&&this.updateJsonData(),t};var re=y.prototype.payload;y.prototype.payload=function(e){let t=re.apply(this,arguments);return arguments.length&&this.updateJsonData(),t};var b=new y().id(`Empty`).payload(`[]`),DatasourceAdapt=class{_activity;constructor(e){this._activity=e||b}exec(){return this._activity.refreshMeta().then(()=>this._activity.exec())}id(){return this._activity.id()}hash(e={}){return this._activity.hash(e)}label(){return this._activity.label()}outFields(){return this._activity&&this._activity.outFields?this._activity.outFields():[]}total(){return this._activity?this._activity.outData().length:0}fetch(e,t){return this.exec().then(()=>{let n=this._activity.outData();return e===0&&n.length<=t?Promise.resolve(n):Promise.resolve(n.slice(e,e+t))})}},ESPResult=class extends Datasource{_ec;_result;_schema=[];_meta=[];_total;_data=[];constructor(e){super(),this._ec=e,this.samples(this._ec.samples()).sampleSize(this._ec.sampleSize())}hash(e={}){return(0,r.hashSum)({samples:this.samples(),sampleSize:this.sampleSize(),...e})}_prevMetaHash;refreshMetaPromise;refreshMeta(){return this._prevMetaHash!==this.hash()&&(this._prevMetaHash=this.hash(),delete this.refreshMetaPromise),this.refreshMetaPromise||=super.refreshMeta().then(()=>{if(this._result=this._createResult(),this._result)return this._result.refresh();throw Error(`No valid result`)}).then(e=>{this._total=e.Total,this._schema=e.fields(),this._meta=this._meta&&this._meta.length?this._meta:this._schema.map(schemaRow2IField)}).catch(e=>{this._total=0,this._schema=[],this._meta=[]}),this.refreshMetaPromise}responseFields(e){return arguments.length?(this._meta=e,this.refreshMeta(),this):this._meta}computeFields(e){return()=>this.responseFields()}exec(){return this._exec()}_prevExecHash;_exec=(0,r.debounce)(()=>this._prevExecHash===this.hash()?Promise.resolve():(this._prevExecHash=this.hash(),super.exec().then(()=>this.sample()).then(e=>{this._data=this.fixInt64(e)}).catch(e=>{this._data=[]})));inData(){return this._data}computeData(){return this._data}total(){return this._total}async fetch(e,t){return t>this.samples()*this.sampleSize()?this.sample():this._fetch(e,t)}_fetchQ=new r.AsyncOrderedQueue;_fetch(e,t){return this._fetchQ.push(this._result?this._result.fetchRows(e,t).catch(e=>[]):Promise.resolve([]))}sample=(0,r.debounce)((e=this.samples(),t=this.sampleSize())=>{let n=[];if(e*t>=this.total())n.push(this._fetch(0,this.total()));else{let r=this.total()-t;for(let i=0;i<e;++i)n.push(this._fetch(Math.floor(i*r/e),t))}return Promise.all(n).then(e=>{let t=[];for(let n of e)t=t.concat(n);return t})})};ESPResult.prototype._class+=` ESPResult`;var x=class WUResult extends ESPResult{_origWu;_origResultName;constructor(e){super(e),this._wu=new S(this._ec)}url(){return this._wu.url()}wuid(){return this._wu.wuid()}toDDL(){return{type:`wuresult`,id:this.id(),url:this._wu.url(),wuid:this.wuid(),outputs:{[this.resultName()]:{fields:this.responseFields()}}}}fromDDL(e,t=!1){return e.outputs[this.resultName()]?this.responseFields(e.outputs[this.resultName()].fields):this}static fromDDL(e,t,n,r,i=!1){return new WUResult(e).wu(n).resultName(r).fromDDL(t)}_createResult(){if(this._wu.url()&&this.wuid()&&this.resultName())return t.Result.attach({baseUrl:this._wu.url(),hookSend:this._ec.hookSend()},this.wuid(),this.resultName())}sourceHash(){return super.hash({wuid:this.wuid()})}hash(e){return super.hash({ddl:this.toDDL()})}label(){return`${this.wuid()}\n${this.resultName()}`}};x.prototype._class+=` WUResult`;var S=class WU extends Datasource{_ec;_origUrl;_origWuid;_workunit;_outputs={};constructor(e){super(),this._ec=e}toDDL(){let e={};for(let t in this._outputs)e[t]={fields:this._outputs[t].responseFields()};return{type:`wuresult`,id:this.id(),url:this.url(),wuid:this.wuid(),outputs:e}}fromDDL(e,t=!1){(t?this:this.id(e.id)).url(e.url).wuid(e.wuid);let n={};for(let t in e.outputs)n[t]=x.fromDDL(this._ec,e,this,t);return this._outputs=n,this}static fromDDL(e,t,n=!1){return new WU(e).fromDDL(t,n)}hash(){return(0,r.hashSum)({url:this.url(),wuid:this.wuid()})}label(){return this.wuid()}outputs(){let e=[];for(let t in this._outputs)e.push(this._outputs[t]);return e}outputDDL(){let e={};for(let t in this._outputs)e[t]={fields:this._outputs[t].outFields()};return e}output(e){return this._outputs[e]}_prevSourceHash;refreshMetaPromise;_resultNames=[];refreshMeta(){return!this.url()||!this.wuid()?Promise.resolve():(this._prevSourceHash!==this.hash()&&(this._prevSourceHash=this.hash(),delete this.refreshMetaPromise),this.refreshMetaPromise||=super.refreshMeta().then(()=>(this._workunit=t.Workunit.attach({baseUrl:this.url(),hookSend:this._ec.hookSend()},this.wuid()),this._workunit.fetchResults())).then(e=>{this._resultNames=e.map(e=>e.Name)}).catch(e=>{}),this.refreshMetaPromise)}resultNames(){return this._resultNames}};S.prototype._class+=` WU`;var WUResultRef=class extends DatasourceRef{datasource(e){return super.datasource.apply(this,arguments)}resultName(e){return arguments.length?(this.datasource().resultName(e),this):this.datasource().resultName()}toDDL(){return{id:this.datasource().wu().id(),output:this.resultName()}}};WUResultRef.prototype._class+=` WUResultRef`,ESPResult.prototype.publish(`samples`,10,`number`,`Number of samples`),ESPResult.prototype.publish(`sampleSize`,100,`number`,`Sample size`),x.prototype.publish(`wu`,null,`widget`,`Workunit`),x.prototype.publish(`resultName`,``,`set`,`Result Name`,function(){return this._wu===void 0?[]:this._wu.resultNames()}),x.prototype._origWu=x.prototype.wu,x.prototype.wu=function(e){let t=x.prototype._origWu.apply(this,arguments);return e!==void 0&&this._wu.refreshMeta(),t},x.prototype._origResultName=x.prototype.resultName,x.prototype.resultName=function(e){let t=this._resultName,n=x.prototype._origResultName.apply(this,arguments);return e!==void 0&&t!==e&&this.responseFields([]),n},S.prototype.publish(`url`,``,`string`,`ESP Url (http://x.x.x.x:8010)`),S.prototype.publish(`wuid`,``,`string`,`Workunit ID`),S.prototype._origUrl=S.prototype.url,S.prototype.url=function(e){let t=S.prototype._origUrl.apply(this,arguments);return e!==void 0&&this.refreshMeta(),t},S.prototype._origWuid=S.prototype.wuid,S.prototype.wuid=function(e){let t=S.prototype._origWuid.apply(this,arguments);return e!==void 0&&this.refreshMeta(),t};var C=class LogicalFile extends ESPResult{constructor(e){super(e)}toDDL(){return{type:`logicalfile`,id:this.id(),url:this.url(),logicalFile:this.logicalFile(),fields:this.responseFields()}}fromDDL(e,t=!1){return(t?this:this.id(e.id)).url(e.url).logicalFile(e.logicalFile),this}static fromDDL(e,t,n=!1){return new LogicalFile(e).fromDDL(t,n)}_createResult(){return t.Result.attachLogicalFile({baseUrl:this.url(),hookSend:this._ec.hookSend()},this.nodeGroup(),this.logicalFile())}sourceHash(){return super.hash({logicalFile:this.logicalFile()})}hash(e){return super.hash({ddl:this.toDDL()})}label(){return`${this.logicalFile()}`}};C.prototype._class+=` LogicalFile`,C.prototype.publish(`url`,``,`string`,`ESP Url (http://x.x.x.x:8010)`),C.prototype.publish(`nodeGroup`,``,`string`,`Node Group`),C.prototype.publish(`logicalFile`,``,`string`,`Logical File Name`);var w=class RestField extends n.PropertyExt{_owner;constructor(){super()}toDDL(){return{type:`string`,id:this.fieldID()}}fromDDL(e){return this.fieldID(e.id)}static fromDDL(e){return new RestField().fromDDL(e)}owner(e){return arguments.length?(this._owner=e,this):this._owner}valid(){return!!this.fieldID()}},T=class RestService extends Datasource{_ec;_responseFields={};constructor(e){super(),this._ec=e}toDDL(){return{type:`rest`,id:this.id(),url:this.url(),action:this.action(),mode:this.mode(),inputs:this.validRequestFields().map(e=>e.toDDL()),outputs:this.outputDDL()}}fromDDL(e,t=!1){(t?this:this.id(e.id)).url(e.url).action(e.action).mode(e.mode||`get`).requestFields(e.inputs.map(w.fromDDL));for(let t in e.outputs)this.responseFields(t,e.outputs[t].fields);return this}static fromDDL(e,t,n=!1){return new RestService(e).fromDDL(t,n)}hash(e={}){return(0,r.hashSum)({url:this.url(),action:this.action(),mode:this.mode(),...e})}label(){return this.action()}responseFields(e,t){return arguments.length===1?this._responseFields[e]||[]:(this._responseFields[e]=t,this)}validRequestFields(){return this.requestFields().filter(e=>e.valid())}_prevRequestHash;_prevPromise;_submitQ=new r.AsyncOrderedQueue;submit(e){let n=(0,r.hashSum)(e);if(!this._prevPromise||this._prevRequestHash!==n){this._prevRequestHash=n;let r=(0,t.createConnection)({baseUrl:this.url(),type:this.mode()});this._prevPromise=this._submitQ.push(r.send(this.action(),e))}return this._prevPromise}resultNames(){let e=[];for(let t in this._responseFields)e.push(t);return e}outputDDL(){let e={};return this.resultNames().forEach(t=>{e[t]={fields:this._responseFields[t]}}),e}};T.prototype._class+=` RestService`;var E=class RestResult extends Datasource{_ec;_origService;constructor(e){super(),this._ec=e,this._service=new T(this._ec)}validRequestFields(){return this.service().validRequestFields()}toDDL(){return this.service().toDDL()}fromDDL(e){return this.service().fromDDL(e),this}static fromDDL(e,t,n){return new RestResult(e).id(`${t.id()}_${n}`).service(t).resultName(n)}serviceID(){return`${this.service().url()}/${this.service().action()}}`}sourceHash(){return this.service().hash()}requestFields(){return this.service().requestFields().map(e=>e.toDDL())}responseFields(e){return arguments.length?(this.service().responseFields(this.resultName(),e),this):this.service().responseFields(this.resultName())}hash(e={}){return(0,r.hashSum)({source:this.sourceHash(),resultName:this.resultName(),...e})}label(){return`${this.service().label()}\n${this.resultName()}`}_jsonData=[];jsonDataFields(){if(!this._jsonData||!this._jsonData.length)return[];let e=rowToFields(this._jsonData[0],this._jsonData);return this.responseFields(e),e}computeFields(e){return()=>this.jsonDataFields()}computeData(){return this._jsonData}submit(e){return this.service().submit(e).then(e=>{let t=this.resultName(),n=t?t.split(`.`):[];for(let t of n)e=(e||{})[t];return this._jsonData=e,e})}formatRequest(){let e={};return this.service().validRequestFields().forEach(t=>{e[t.fieldID()]=``}),e}exec(){return this.submit(this.formatRequest()).then(e=>{})}};E.prototype._class+=` RestResult`;var D=class Param extends n.PropertyExt{_ec;validate(e){let t=[];return this.source_valid()||t.push({source:`${e}.source.${this.source()}`,msg:`Invalid source: "${this.source()}"`,hint:`expected: ${JSON.stringify(this.visualizationIDs())}`}),this.remoteField_valid()||t.push({source:`${e}.remoteField`,msg:`Invalid remoteField: "${this.remoteField()}"`,hint:`expected: ${JSON.stringify(this.sourceOutFields())}`}),this.value_valid()||t.push({source:`${e}.value`,msg:`Invalid value: "${this.value()}"`,hint:`expected: any value.`}),t}constructor(e){super(),this._ec=e}toDDL(){return{source:this.source(),remoteFieldID:this.remoteField(),localFieldID:this.localField(),value:this.value()}}fromDDL(e){return this.source(e.source).remoteField(e.remoteFieldID).localField(e.localFieldID).value(e.value)}static fromDDL(e,t){return new Param(e).fromDDL(t)}hash(){return(0,r.hashSum)({label:this.localField(),source:this.source(),sourceField:this.remoteField()})}visualizationIDs(){return this._ec.elementIDs()}sourceFields(){return this.sourceOutFields().map(e=>e.id)}sourceViz(){return this._ec.element(this.source())}sourceOutFields(){return this.sourceViz().hipiePipeline().selectionFields()}sourceSelection(){return this.sourceViz().selection()}calcValue(){return this.source_exists()&&this.remoteField_exists()?this.sourceSelection().map(e=>e[this.remoteField()]):this.value_exists()?[this.value()]:[``]}exists(){return this.localField_exists()&&(this.source_exists()&&this.remoteField_exists()||this.value_exists())}};D.prototype._class+=` Param`;var RestResultRef=class extends DatasourceRef{_ec;serviceID(){return this.datasource().serviceID()}_data=[];datasource(e){return super.datasource.apply(this,arguments)}url(){return this.datasource().service().url()}action(){return this.datasource().service().action()}resultName(){return this.datasource().resultName()}validate(){let e=[];for(let t of this.validParams())e=e.concat(t.validate(`request`));return e}constructor(e){super(),this._ec=e}toDDL(){return{id:this.datasource().service().id(),output:this.resultName(),request:this.validParams().map(e=>({source:e.source(),remoteFieldID:e.remoteField(),localFieldID:e.localField(),value:e.value()}))}}sourceHash(){return this.datasource().hash()}requestFieldRefs(e){return arguments.length?(this.request(e.map(e=>D.fromDDL(this._ec,e))),this):this.validParams().map(e=>e.toDDL())}requestFields(){return this.datasource().requestFields()}responseFields(){return this.datasource().responseFields()}hash(){return this.datasource().hash({resultName:this.resultName(),request:this.formatRequest()})}label(){return`${this.datasource().label()}\n${this.datasource().resultName()}`}elementIDs(){return this._ec.elementIDs()}element(e){return this._ec.element(e)}referencedFields(e){super.referencedFields(e);let t=[];for(let t of this.validParams()){let n=t.sourceViz().hipiePipeline();e.inputs[this.id()]||(e.inputs[this.id()]=[]),e.inputs[this.id()].push(t.localField()),n.resolveFields(e,[t.remoteField()])}super.resolveFields(e,t)}validParams(){return this.request().filter(e=>e.exists())}refreshMeta(){return this.datasource().refreshMeta().then(()=>{let e=this.request(),t=(0,r.compare)(e.map(e=>e.localField()),this.datasource().validRequestFields().map(e=>e.fieldID())),n=e.filter(e=>t.update.indexOf(e.localField())>=0);this.request(n.concat(t.enter.map(e=>new D(this._ec).localField(e))))})}updatedBy(){return this.validParams().map(e=>e.source())}computeFields(e){return this.datasource().computeFields(e)}formatRequest(){let e=this.datasource().formatRequest();return this.request().forEach(t=>{e[t.localField()]!==void 0&&(e[t.localField()]=t.calcValue()||e[t.localField()])}),e}_prevRequestHash;_prevRequestPromise;exec(){let e=this.formatRequest(),t=(0,r.hashSum)({hash:this.hash(),request:e});return this._prevRequestHash!==t&&(this._prevRequestHash=t,this._prevRequestPromise=this.datasource().submit(e).then(e=>(this._data=this.fixInt64(e),this._data))),this._prevRequestPromise}inData(){return this._data}computeData(){return this._data}};RestResultRef.prototype._class+=` RestResultRef`,w.prototype.publish(`fieldID`,``,`string`,`RestField Label`),T.prototype.publish(`url`,``,`string`,`REST Url`),T.prototype.publish(`action`,``,`string`,`Query Set`),T.prototype.publish(`mode`,`get`,`set`,`Request mode`,[`get`,`post`]),T.prototype.publish(`requestFields`,[],`propertyArray`,`Multi Fields`,null,{autoExpand:w}),E.prototype.publish(`service`,null,`widget`,`Rest service`),E.prototype.publish(`resultName`,``,`string`,`Result Name`),E.prototype._origService=E.prototype.service,E.prototype.service=function(e){let t=E.prototype._origService.apply(this,arguments);return e!==void 0&&this._service.refreshMeta(),t},D.prototype.publish(`localField`,null,`string`,`Label`),D.prototype.publish(`source`,null,`set`,`Activity`,function(){return this.visualizationIDs()},{optional:!0,disable:e=>e.value_exists(),validate:e=>e.source_disabled()||e.visualizationIDs().indexOf(e.source())>=0}),D.prototype.publish(`remoteField`,null,`set`,`Source Field`,function(){return this.sourceFields()},{optional:!0,disable:e=>!e.source_exists()||e.value_exists(),validate:e=>e.remoteField_disabled()||e.sourceFields().indexOf(e.remoteField())>=0}),D.prototype.publish(`value`,null,`string`,`Static Value`,null,{optional:!0,disable:e=>e.source_exists(),validate:e=>e.value_disabled()||e.value_exists()}),RestResultRef.prototype.publish(`request`,[],`propertyArray`,`Request Fields`);function parseUrl(e){let t=e.split(`/WsEcl/submit/query/`);if(t.length<2)throw Error(`Invalid roxie URL: ${e}`);let n=t[0].split(`:`);if(n.length<3)throw Error(`Invalid roxie URL: ${e}`);let r=t[1].split(`/`);if(r.length<2)throw Error(`Invalid roxie URL: ${e}`);return{url:`${n[0]}:${n[1]}:${n[2]===`18002`?`18010`:`8010`}`,querySet:r[0],queryID:r[1]}}function isHipieRequest(e){return e.length>=8&&e.indexOf(`_changed`)===e.length-8}function isHipieResponse(e){return e.length>=8&&e.indexOf(`_changed`)===e.length-8||[`HIPIE_DDL`,`HIPIE_DDLGLOBALS`,`hipieversion`].indexOf(e)>=0}var O=class RoxieService extends Datasource{_ec;_query;_requestFields;_responseFields={};_type=`roxie`;constructor(e){super(),this._ec=e}toDDL(){return{type:this._type,id:this.id(),url:this.url(),querySet:this.querySet(),queryID:this.queryID(),inputs:this.requestFields(),outputs:this.outputDDL()}}fromDDL(e,t=!1){this._type=e.type,(t?this:this.id(e.id)).url(e.url).querySet(e.querySet).queryID(e.queryID),e.inputs&&e.inputs.length&&this.requestFields(e.inputs);for(let t in e.outputs)this.responseFields(t,e.outputs[t].fields);return this}static fromDDL(e,t,n=!1){return new RoxieService(e).fromDDL(t,n)}hash(e={}){return(0,r.hashSum)({url:this.url(),querySet:this.querySet(),queryId:this.queryID(),ignoreHipieRequest:this.ignoreHipieRequest(),ignoreHipieResponse:this.ignoreHipieResponse(),...e})}label(){return this.queryID()}_prevSourceHash;refreshMetaPromise;refreshMeta(){if(this._prevSourceHash!==this.hash()&&(this._prevSourceHash=this.hash(),delete this.refreshMetaPromise),!this.refreshMetaPromise){let e=!!this._requestFields;this.refreshMetaPromise=new Promise((n,r)=>{let i=t.Query.attach({baseUrl:this.url(),hookSend:this._ec.hookSend()},this.querySet(),this.queryID());(!e||this.ignoreHipieRequest()||this.ignoreHipieResponse())&&n(i.refresh()),n(i)}).then(t=>{this._query=t,(!e||this.ignoreHipieRequest())&&(this._requestFields=t.requestFields().filter(e=>this._type===`roxie`||!isHipieRequest(e.id))),(!e||this.ignoreHipieResponse())&&t.resultNames().filter(e=>this._type===`roxie`||!isHipieResponse(e)).forEach(e=>{this._responseFields[e]=t.resultFields(e)})})}return this.refreshMetaPromise}requestFields(e){return arguments.length?(this._requestFields=e,this):this._requestFields||[]}responseFields(e,t){return arguments.length===1?this._responseFields[e]||[]:(this._responseFields[e]=t,this)}_prevRequestHash;_prevPromise;_submitQ=new r.AsyncOrderedQueue;submit(e){let t=(0,r.hashSum)(e);return(!this._prevPromise||this._prevRequestHash!==t)&&(this._prevRequestHash=t,this._prevPromise=this._submitQ.push(this._query.submit(e))),this._prevPromise}resultNames(){let e=[];for(let t in this._responseFields)e.push(t);return e}outputDDL(){let e={};return this.resultNames().forEach(t=>{e[t]={fields:this._responseFields[t]}}),e}};O.prototype._class+=` RoxieService`,O.prototype.publish(`url`,``,`string`,`ESP Url (http://x.x.x.x:8002)`),O.prototype.publish(`querySet`,``,`string`,`Query Set`),O.prototype.publish(`queryID`,``,`string`,`Query ID`),O.prototype.publish(`ignoreHipieRequest`,!1,`boolean`,`Ignore provided DDL request`),O.prototype.publish(`ignoreHipieResponse`,!1,`boolean`,`Ignore provided DDL response`);var k=class RoxieResult extends Datasource{_ec;_origService;constructor(e){super(),this._ec=e,this._service=new O(this._ec)}toDDL(){return this.service().toDDL()}fromDDL(e){return this.service().fromDDL(e),this}static fromDDL(e,t,n){return new RoxieResult(e).id(`${t.id()}_${n}`).service(t).resultName(n)}serviceID(){return`${this.service().url()}/${this.service().querySet()}/${this.service().queryID()}`}sourceHash(){return this.service().hash()}requestFields(){return this.service().requestFields()}responseFields(e){return arguments.length?(this.service().responseFields(this.resultName(),e),this):this.service().responseFields(this.resultName())}hash(e={}){return(0,r.hashSum)({source:this.sourceHash(),resultName:this.resultName(),...e})}label(){return`${this.service().label()}\n${this.resultName()}`}computeFields(e){return()=>this.service().responseFields(this.resultName())}refreshMeta(){return this.service().refreshMeta()}submit(e){return this.service().submit(e)}};k.prototype._class+=` RoxieResult`,k.prototype.publish(`service`,null,`widget`,`Roxie service`),k.prototype.publish(`resultName`,``,`set`,`Result Name`,function(){return this._service===void 0?[]:this._service.resultNames()}),k.prototype._origService=k.prototype.service,k.prototype.service=function(e){let t=k.prototype._origService.apply(this,arguments);return e!==void 0&&this._service.refreshMeta(),t};var RoxieResultRef=class extends DatasourceRef{_ec;serviceID(){return this.datasource().serviceID()}_data=[];datasource(e){return super.datasource.apply(this,arguments)}url(){return this.datasource().service().url()}querySet(){return this.datasource().service().querySet()}queryID(){return this.datasource().service().queryID()}resultName(){return this.datasource().resultName()}validate(){let e=[];for(let t of this.validParams())e=e.concat(t.validate(`request`));return e}constructor(e){super(),this._ec=e}toDDL(){return{id:this.datasource().service().id(),output:this.resultName(),request:this.validParams().map(e=>({source:e.source(),remoteFieldID:e.remoteField(),localFieldID:e.localField(),value:e.value()}))}}sourceHash(){return this.datasource().hash()}requestFieldRefs(e){return arguments.length?(this.request(e.map(e=>D.fromDDL(this._ec,e))),this):this.validParams().map(e=>e.toDDL())}requestFields(){return this.datasource().requestFields()}responseFields(){return this.datasource().responseFields()}hash(){return this.datasource().hash({resultName:this.resultName(),params:this.request().map(e=>e.hash()),request:this.formatRequest()})}label(){return`${this.datasource().label()}\n${this.datasource().resultName()}`}elementIDs(){return this._ec.elementIDs()}element(e){return this._ec.element(e)}referencedFields(e){super.referencedFields(e);let t=[];for(let n of this.validParams()){t.push(n.localField());let r=n.sourceViz().hipiePipeline();e.inputs[this.id()]||(e.inputs[this.id()]=[]),e.inputs[this.id()].push(n.localField()),r.resolveFields(e,[n.remoteField()])}super.resolveFields(e,t)}validParams(){return this.request().filter(e=>e.exists())}refreshMeta(){return this.datasource().refreshMeta().then(()=>{let e=this.request(),t=(0,r.compare)(e.map(e=>e.localField()),this.datasource().requestFields().map(e=>e.id)),n=e.filter(e=>t.update.indexOf(e.localField())>=0);this.request(n.concat(t.enter.map(e=>new D(this._ec).localField(e))))})}updatedBy(){return this.validParams().map(e=>e.source())}computeFields(e){return()=>this.datasource().responseFields()}formatRequest(){let e={},t=!1,n=this.datasource().requestFields();for(let r of this.validParams()){let i=r.calcValue(),a=n.filter(e=>e.id===r.localField())[0],o;o=a.type===`set`?{Item:i}:i[0],o!==void 0&&(e[r.localField()]=o),t=!0}return t||(e.refresh=!0),e}_prevRequestHash;_prevRequestPromise;exec(){return super.exec().then(()=>{let e=this.formatRequest(),t=(0,r.hashSum)({hash:this.hash(),request:e});return this._prevRequestHash!==t&&(this._prevRequestHash=t,this._prevRequestPromise=this.datasource().submit(e).then(e=>{let t=this.datasource().resultName(),n=e[t];return n||=e[t.toLowerCase().replace(/ /g,`_`)],this.fixInt64(n)})),this._prevRequestPromise}).then(e=>{this._data=e})}inData(){return this._data}computeData(){return this._data}};RoxieResultRef.prototype._class+=` RoxieResultRef`,RoxieResultRef.prototype.publish(`request`,[],`propertyArray`,`Request Fields`);var HipieResultRef=class extends RoxieResultRef{fullUrl(e){let t=parseUrl(e);return this.datasource().service().url(t.url),this.datasource().service().querySet(t.querySet),this.datasource().service().queryID(t.queryID),this}formatRequest(){let e=super.formatRequest(),t={};for(let n in e)t[n]=e[n],t[`${n}_changed`]=!0;return t}};HipieResultRef.prototype._class+=` HipieResultRef`;var A=0,DSPicker=class extends ActivitySelection{_ec;_nullDatasource=b;_origDatasourceID;_origDatasourceRef;datasource(){return this.datasourceRef().datasource()}refreshRef(e){let t=this._ec.datasource(e);t instanceof y||t instanceof v||t instanceof C||t instanceof O?this.selection(new DatasourceRef().datasource(t)):t instanceof x?this.selection(new WUResultRef().datasource(t)):t instanceof k?this.selection(new HipieResultRef(this._ec).datasource(t)):t instanceof E&&this.selection(new RestResultRef(this._ec).datasource(t))}selection(e){let t=super.selection.apply(this,arguments);return arguments.length?(this._datasourceID!==e.datasource().id()&&(this._datasourceID=e.datasource().id()),this):t||this._nullDatasource}validate(){return this.selection().validate()}constructor(e){super(),this._ec=e,this._id=`ds_${++A}`;let t=this._ec.datasources()[0];this.datasourceID(t.id())}toDDL(){return{...this.datasourceRef().toDDL(),id:this.datasourceID()}}hash(e={}){return super.hash({...e})}datasourceIDs(){return this._ec.datasources().map(e=>({value:e.id(),text:`${e.label()} ${e.id()===e.label()?``:` (${e.id()})`}`}))}};DSPicker.prototype._class+=` DSPicker`,DSPicker.prototype.publish(`datasourceID`,``,`set`,`Activity`,function(){return this.datasourceIDs()},{optional:!1}),DSPicker.prototype.publish(`datasourceRef`,``,`widget`,`Activity`),DSPicker.prototype._origDatasourceID=DSPicker.prototype.datasourceID,DSPicker.prototype.datasourceID=function(e){let t=this._datasourceID,n=DSPicker.prototype._origDatasourceID.apply(this,arguments);return e!==void 0&&t!==e&&this.refreshRef(e),n},DSPicker.prototype._origDatasourceRef=DSPicker.prototype.datasourceRef,DSPicker.prototype.datasourceRef=function(e){return ActivitySelection.prototype.selection.apply(this,arguments)};function createFilter(e,t,n){let r=typeof n==`string`;switch(e){case`==`:return e=>r&&typeof e[t]==`string`?e[t].trim()===n:e[t]===n;case`!=`:return e=>r&&typeof e[t]==`string`?e[t].trim()!==n:e[t]!==n;case`<`:return e=>e[t]<n;case`<=`:return e=>e[t]<=n;case`>`:return e=>e[t]>n;case`>=`:return e=>e[t]>=n;default:throw Error(`Unknown filter condition: ${e}`)}}var j=class ColumnMapping extends n.PropertyExt{_owner;validate(e){let t=[];return this.remoteField_valid()||t.push({source:`${e}.remoteField`,msg:`Invalid remoteField: "${this.remoteField()}"`,hint:`expected: ${JSON.stringify(this.sourceOutFields())}`}),this.localField_valid()||t.push({source:`${e}.localField`,msg:`Invalid localField: "${this.localField()}"`,hint:`expected: ${JSON.stringify(this.localFields())}`}),t}constructor(){super()}owner(e){return arguments.length?(this._owner=e,this):this._owner}valid(){return this.localField_exists()||this.remoteField_exists()}toDDL(){return{remoteFieldID:this.remoteField(),localFieldID:this.localField(),condition:this.condition(),nullable:this.nullable()}}fromDDL(e){return this.remoteField(e.remoteFieldID).localField(e.localFieldID).condition(e.condition).nullable(e.nullable)}static fromDDL(e){return new ColumnMapping().fromDDL(e)}hash(){return(0,r.hashSum)({remoteField:this.remoteField(),localField:this.localField(),condition:this.condition(),nullable:this.nullable()})}localFields(){return this._owner.inFields().map(e=>e.id)}sourceOutFields(){return this._owner.sourceOutFields().map(e=>e.id)}remoteValues(e){let t=this.remoteField();return e.map(e=>{let n=e[t];return typeof n==`string`?n.trim():n})}createFilterDescription(e){switch(this.condition()){case`in`:case`range`:return`${this.localField()} ${this.condition()} [${this.remoteValues(e).join(`, `)}]`;default:return`${this.localField()} ${this.condition()} ${this.remoteValues(e)[0]}`}}createFilter(e){let t=this.localField(),n=this.remoteValues(e);switch(this.condition()){case`range`:return this.nullable()&&(n.length<2||n[0]===n[1])?e=>!0:e=>e[t]>=n[0]&&e[t]<=n[1];case`in`:return this.nullable()&&n.length===0?e=>!0:e=>n.some(n=>typeof e[t]==`string`?e[t].trim()===n:e[t]===n);default:let e=n[0];return this.nullable()&&(e==null||e===``)?e=>!0:createFilter(this.condition(),t,e)}}};j.prototype._class+=` ColumnMapping`;var M=class RemoteFilter extends n.PropertyExt{_owner;validate(e){let t=[];this.source_valid()||t.push({source:`${e}.source.${this.source()}`,msg:`Invalid source: "${this.source()}"`,hint:`expected: ${JSON.stringify(this.visualizationIDs())}`}),this.source_exists()&&this.validMappings().length===0&&t.push({source:`${e}.source.${this.source()}`,msg:`Invalid mappings: "${this.source()}"`,hint:`expected minimum of 1 mapping`});for(let n of this.validMappings())t=t.concat(n.validate(`${e}.${this.source()}.mappings`));return t}constructor(){super()}owner(e){return arguments.length?(this._owner=e,this):this._owner}valid(){return!!this.source()&&this.validMappings().length>0}toDDL(){return{viewID:this.source(),mappings:this.ddlMappings()}}fromDDL(e){return this.source(e.viewID).ddlMappings(e.mappings)}static fromDDL(e){return new RemoteFilter().fromDDL(e)}ddlMappings(e){return arguments.length?(this.mappings(e.map(e=>j.fromDDL(e))),this):this.validMappings().map(e=>e.toDDL())}visualizationIDs(){return this._owner.visualizationIDs()}hash(){return(0,r.hashSum)({source:this.source(),mappings:this.validMappings().map(e=>e.hash()),selection:this.sourceSelection()})}validMappings(){return this.mappings().filter(e=>e.valid())}appendMappings(e){for(let t of e)this.mappings().push(new j().owner(this).remoteField(t.remoteField).localField(t.localField).condition(t.condition));return this}inFields(){return this._owner.inFields()}sourceViz(){return this._owner.visualization(this.source())}sourceOutFields(){return this.sourceViz().hipiePipeline().selectionFields()}sourceSelection(){return this.sourceViz().selection()}createFilter(){let e=this.sourceSelection(),t=this.validMappings().map(t=>t.createFilter(e));return e=>t.every(t=>t(e))}createFilterDescription(){let e=this.sourceSelection();return this.validMappings().map(t=>t.createFilterDescription(e)).join(`, `)}};M.prototype._class+=` Filter`;var N=class StaticFilter extends n.PropertyExt{_owner;validate(e){let t=[];return this.localField_valid()||t.push({source:`${e}.localField`,msg:`Invalid localField: "${this.localField()}"`,hint:`expected: ${JSON.stringify(this.localFields())}`}),t}constructor(){super()}owner(e){return arguments.length?(this._owner=e,this):this._owner}coerceValue(e){if(arguments.length===0)switch(this.valueType()){case`number`:return+this.value();default:return``+this.value()}return this.value(e),typeof e==`number`?this.valueType(`number`):this.valueType(`string`),this}valid(){return this.localField_exists()&&this.value_exists()}toDDL(){return{localFieldID:this.localField(),condition:this.condition(),value:this.coerceValue()}}fromDDL(e){return this.localField(e.localFieldID).condition(e.condition).coerceValue(e.value)}static fromDDL(e){return new StaticFilter().fromDDL(e)}hash(){return(0,r.hashSum)({localField:this.localField(),condition:this.condition(),value:this.value(),valueType:this.valueType()})}localFields(){return this._owner.inFields().map(e=>e.id)}createFilterDescription(){return`${this.localField()} ${this.condition()} ${this.coerceValue()}`}createFilter(){return createFilter(this.condition(),this.localField(),this.coerceValue())}};N.prototype._class+=` StaticFilter`;var P=class Filters extends Activity{_ec;static Filter=M;static Mapping=j;validate(){let e=[];for(let t of this.validFilters())e=e.concat(t.validate(`filter`));return e}constructor(e){super(),this._ec=e}toDDL(){return{type:`filter`,conditions:this.conditions()}}fromDDL(e){return this.conditions(e.conditions)}static fromDDL(e,t){return new Filters(e).fromDDL(t)}conditions(e){if(!arguments.length)return this.validFilters().map(e=>e.toDDL());let t=[],n=[];return e.forEach(e=>{i.DDL2.isIFilterCondition(e)?t.push(M.fromDDL(e)):n.push(N.fromDDL(e))}),this.remoteFilter(t),this.staticFilter(n),this}visualizationIDs(){return this._ec.elementIDs()}visualization(e){return this._ec.element(e)}hash(){return(0,r.hashSum)(this.validFilters().map(e=>({filter:e.hash()})))}exists(){return this.validFilters().length>0}updatedBy(){return this.validRemoteFilters().map(e=>e.source())}referencedFields(e){super.referencedFields(e);let t=[];for(let n of this.validRemoteFilters()){let r=n.sourceViz().hipiePipeline(),i=[];for(let e of n.validMappings())t.push(e.localField()),i.push(e.remoteField());r.resolveFields(e,i)}super.resolveInFields(e,t)}exec(){return super.exec()}computeData(){let e=super.computeData();if(e.length===0||!this.exists())return e;let t=this.validFilters().map(e=>e.createFilter());return e.filter(e=>t.every(t=>t(e)))}validRemoteFilters(){return this.remoteFilter().filter(e=>e.valid())}validStaticFilters(){return this.staticFilter().filter(e=>e.valid())}validFilters(){return[...this.validRemoteFilters(),...this.validStaticFilters()]}};P.prototype._class+=` Filters`,j.prototype.publish(`remoteField`,null,`set`,`Filter Fields`,function(){return this.sourceOutFields()},{optional:!0,disable:e=>!e._owner.source(),validate:e=>e.sourceOutFields().indexOf(e.remoteField())>=0}),j.prototype.publish(`localField`,null,`set`,`Local Fields`,function(){return this.localFields()},{optional:!0,disable:e=>!e._owner.source(),validate:e=>e.localFields().indexOf(e.localField())>=0}),j.prototype.publish(`condition`,`==`,`set`,`Filter Fields`,[`==`,`!=`,`>`,`>=`,`<`,`<=`,`range`,`in`]),j.prototype.publish(`nullable`,!1,`boolean`,`Ignore null filters`),M.prototype.publish(`source`,null,`set`,`Activity`,function(){return this.visualizationIDs()},{optional:!0,validate:e=>e.visualizationIDs().indexOf(e.source())>=0}),M.prototype.publish(`mappings`,[],`propertyArray`,`Mappings`,null,{autoExpand:j}),N.prototype.publish(`localField`,null,`set`,`Local Fields`,function(){return this.localFields()},{optional:!0,validate:e=>e.localFields().indexOf(e.localField())>=0}),N.prototype.publish(`condition`,`==`,`set`,`Filter Fields`,[`==`,`!=`,`>`,`>=`,`<`,`<=`]),N.prototype.publish(`value`,``,`any`,`Static Value`),N.prototype.publish(`valueType`,`number`,`set`,`Static Value Type`,[`number`,`string`]),P.prototype.publish(`remoteFilter`,[],`propertyArray`,`Remote Filter`,null,{autoExpand:M}),P.prototype.publish(`staticFilter`,[],`propertyArray`,`Static Filter`,null,{autoExpand:N});var F=class GroupByColumn extends n.PropertyExt{_owner;validate(e){let t=[];return this.label_valid()||t.push({source:`${e}.label`,msg:`Invalid label: "${this.label()}"`,hint:`expected ${JSON.stringify(this.columns())}`}),t}constructor(){super()}owner(e){return arguments.length?(this._owner=e,this):this._owner}valid(){return!!this.label()}toDDL(){return this.label()}fromDDL(e){return this.label(e)}static fromDDL(e){return new GroupByColumn().fromDDL(e)}hash(){return(0,r.hashSum)(this.label())}columns(){return this._owner.inFieldIDs()}};F.prototype._class+=` GroupByColumn`;function localCount(e,t){return e.length}var I={count:localCount,min:n.min,max:n.max,mean:n.mean,median:n.median,variance:n.variance,deviation:n.deviation,sum:n.sum},L=class AggregateField extends n.PropertyExt{_owner;disableAggrColumn(){return!this.fieldID()||!this.aggrType()||this.aggrType()===`count`}disableBaseCountColumn(){return!this.fieldID()||!this.aggrType()||this.aggrType()!==`mean`}validate(e){let t=[];return this.aggrColumn_valid()||t.push({source:`${e}.${this.fieldID()}.aggrColumn`,msg:`Invalid aggrColumn: "${this.aggrColumn()}"`,hint:`expected ${JSON.stringify(this.columns())}`}),this.baseCountColumn_valid()||t.push({source:`${e}.${this.fieldID()}.aggrColumn`,msg:`Invalid baseCountColumn: "${this.baseCountColumn()}"`,hint:`expected ${JSON.stringify(this.columns())}`}),t}constructor(){super()}owner(e){return arguments.length?(this._owner=e,this):this._owner}valid(){return!!this.fieldID()}toDDL(){return this.aggrType()===`count`?{fieldID:this.fieldID(),type:`count`}:{fieldID:this.fieldID(),type:this.aggrType(),inFieldID:this.aggrColumn(),baseCountFieldID:this.baseCountColumn()}}fromDDL(e){let t=this.fieldID(e.fieldID).aggrType(e.type);return e.type!==`count`&&(t.aggrColumn(e.inFieldID),t.baseCountColumn(e.baseCountFieldID)),t}static fromDDL(e){return new AggregateField().fromDDL(e)}hash(){return(0,r.hashSum)({label:this.fieldID(),aggrType:this.aggrType(),aggrColumn:this.aggrColumn()})}columns(){return this._owner.inFieldIDs()}hasColumn(){return this.columns().length}aggregate(e){return I[this.aggrType()](e,e=>+e[this.aggrColumn()])}aggrFunc(){let e=I[this.aggrType()],t=this.aggrColumn(),n=this.baseCountColumn();return n?r=>e(r,e=>e[t]/+e[n]):n=>e(n,e=>+e[t])}};L.prototype._class+=` AggregateField`;var R=class GroupBy extends Activity{validate(){let e=[];for(let t of this.validGroupBy())e=e.concat(t.validate(`GroupBy.column`));for(let t of this.validComputedFields())e=e.concat(t.validate(`GroupBy.computedFields`));return e}constructor(){super()}toDDL(){return{type:`groupby`,groupByIDs:this.fieldIDs(),aggregates:this.aggregates()}}fromDDL(e){return this.fieldIDs(e.groupByIDs).aggregates(e.aggregates)}static fromDDL(e){return new GroupBy().fromDDL(e)}fieldIDs(e){return arguments.length?(this.column(e.map(e=>F.fromDDL(e))),this):this.validGroupBy().map(e=>e.toDDL())}aggregates(e){return arguments.length?(this.computedFields(e.map(e=>L.fromDDL(e))),this):this.validComputedFields().map(e=>e.toDDL())}hash(){return(0,r.hashSum)({groupBy:this.column().map(e=>e.hash()),computedFields:this.computedFields().map(e=>e.hash())})}appendGroupBys(e){for(let t of e)this.column().push(new F().owner(this).label(t.field));return this}validGroupBy(){return this.column().filter(e=>e.valid())}exists(){return this.validGroupBy().length>0}inFieldIDs(){return this.inFields().map(e=>e.id)}field(e){for(let t of this.inFields())if(t.id===e)return t;return null}appendComputedFields(e){for(let t of e){let e=new L().owner(this).fieldID(t.label).aggrType(t.type);t.column!==void 0&&e.aggrColumn(t.column),this.computedFields().push(e)}return this}validComputedFields(){return this.computedFields().filter(e=>e.valid())}hasComputedFields(){return this.validComputedFields().length>0}computeFields(e){if(!this.exists())return super.computeFields(e);let t=[],n=this.validGroupBy();for(let e of n){let n=this.field(e.label()),r={type:n?n.type:`string`,id:e.label()};t.push(r)}for(let e of this.computedFields())if(e.fieldID()){let n={id:e.fieldID(),type:`number`};t.push(n)}if(this.details()){let e=t;if(this.exists()){let n={id:`values`,type:`dataset`,children:[]};t.push(n),e=n.children}let r=n.map(e=>e.label());e.push(...this.inFields().filter(e=>this.fullDetails()||r.indexOf(e.id)<0))}return()=>t}referencedFields(e){super.referencedFields(e);let t=[];for(let e of this.validGroupBy())t.push(e.label());for(let e of this.validComputedFields())e.aggrColumn()&&t.push(e.aggrColumn());super.resolveInFields(e,t)}computeData(){let e=super.computeData();if(e.length===0||!this.exists())return e;let t=this.validGroupBy().map(e=>e.label()),r=this.validComputedFields().map(e=>({label:e.fieldID(),aggrFunc:e.aggrFunc()})),i=(0,n.nest)().key(e=>{let n=``;for(let r of t)n+=`:`+e[r];return n}).entries(e).map(e=>{let n=e;delete n.key;for(let e of t)n[e]=n.values[0][e];for(let e of r)n[e.label]=e.aggrFunc(n.values);return n}),a=this.outFields();return i.map(e=>{let t={};for(let n of a)t[n.id]=e[n.id];return t})}};R.prototype._class+=` GroupBy`,F.prototype.publish(`label`,void 0,`set`,`Field`,function(){return this.columns()},{optional:!0,validate:e=>e.columns().indexOf(e.label())>=0}),L.prototype.publish(`fieldID`,null,`string`,`new Field ID`,null,{optional:!0,disable:e=>!e.hasColumn()}),L.prototype.publish(`aggrType`,`count`,`set`,`Aggregation Type`,[`count`,`min`,`max`,`sum`,`mean`,`median`,`variance`,`deviation`],{optional:!0,disable:e=>!e.fieldID()}),L.prototype.publish(`aggrColumn`,null,`set`,`Aggregation Field`,function(){return this.columns()},{optional:!0,disable:e=>e.disableAggrColumn(),validate:e=>e.columns().indexOf(e.aggrColumn())>=0}),L.prototype.publish(`baseCountColumn`,null,`set`,`Base Count Field`,function(){return this.columns()},{optional:!0,disable:e=>e.disableBaseCountColumn(),validate:e=>e.columns().indexOf(e.baseCountColumn())>=0}),R.prototype.publish(`column`,[],`propertyArray`,`Source Columns`,null,{autoExpand:F}),R.prototype.publish(`computedFields`,[],`propertyArray`,`Computed Fields`,null,{autoExpand:L}),R.prototype.publish(`details`,!1,`boolean`,`Show details`),R.prototype.publish(`fullDetails`,!1,`boolean`,`Show groupBy fileds in details`);var z=class Limit extends Activity{constructor(){super()}toDDL(){return{type:`limit`,limit:this.rows()}}fromDDL(e){return this.rows(e.limit)}static fromDDL(e){return new Limit().fromDDL(e)}hash(){return(0,r.hashSum)({limit:this.rows()})}exists(){return this.rows_exists()&&this.rows()>0}computeData(){let e=super.computeData();return e.length===0||!this.exists()?e:e.slice(0,Math.min(this.rows(),e.length))}};z.prototype._class+=` Limit`,z.prototype.publish(`rows`,void 0,`number`,`Limit output`);var B=class ComputedMapping extends n.PropertyExt{_owner;validate(e){let t=[];return this.value_valid()||t.push({source:`${e}.value`,msg:`Invalid value: "${this.value()}"`,hint:`expected: "any"`}),this.newValue_valid()||t.push({source:`${e}.newValue`,msg:`Invalid value: "${this.newValue()}"`,hint:`expected: "any"`}),t}constructor(){super()}owner(e){return arguments.length?(this._owner=e,this):this._owner}valid(){return!!this.value()&&!!this.newValue()}toDDL(){return{value:this.value(),newValue:this.newValue()}}fromDDL(e){return this.value(e.value).newValue(e.newValue)}static fromDDL(e){return new ComputedMapping().fromDDL(e)}};B.prototype._class+=` ComputedMapping`;var V=class ComputedField extends n.PropertyExt{_owner;disableColumn1(){return!this.label()||[`=`,`*`,`/`,`+`,`-`,`scale`,`map`].indexOf(this.type())<0}disableColumn2(){return!this.label()||[`*`,`/`,`+`,`-`].indexOf(this.type())<0}disableMapping(){return!this.label()||[`map`].indexOf(this.type())<0}disableChildField(){return!this.hasChildren()}validate(e){let t=[];return this.column1_valid()||t.push({source:`${e}.${this.label()}`,msg:`Invalid column1: "${this.column1()}"`,hint:`expected: ${JSON.stringify(this.columns())}`}),this.column2_valid()||t.push({source:`${e}.${this.label()}`,msg:`Invalid column2: "${this.column2()}"`,hint:`expected: ${JSON.stringify(this.columns())}`}),this.disableMapping()||this.validComputedMappings().forEach(t=>t.validate(`${e}.mapping`)),this.disableChildField()||this.validChildFields().forEach(t=>t.validate(`${e}.childField`)),t}hasChildren(){if(!this.label()||this.type()!==`=`||!this.column1())return!1;let e=this._owner.field(this.column1());return!!(e&&e.type===`dataset`&&e.children)}children(){let e=this._owner.field(this.column1());return e&&e.type===`dataset`?e.children:[]}constructor(){super()}owner(e){return arguments.length?(this._owner=e,this):this._owner}valid(){return!!this.label()}validComputedMappings(){return this.mapping().filter(e=>e.valid())}validChildFields(){return this.childField().filter(e=>e.valid())}hasChildFields(){return this.validChildFields().length}toDDL(){switch(this.type()){case`scale`:return{fieldID:this.label(),type:`scale`,sourceFieldID:this.column1(),factor:this.constValue()};case`template`:return{fieldID:this.label(),type:`template`,template:this.template()};case`=`:let e=this.validChildFields().map(e=>e.toDDL());return{fieldID:this.label(),type:`=`,sourceFieldID:this.column1(),transformations:e.length?e:void 0};case`map`:return{fieldID:this.label(),type:`map`,sourceFieldID:this.column1(),default:this.default(),mappings:this.validComputedMappings().map(e=>e.toDDL())};default:return{fieldID:this.label(),type:this.type(),sourceFieldID1:this.column1(),sourceFieldID2:this.column2()}}}fromDDL(e){let t=this.label(e.fieldID).type(e.type);switch(e.type){case`scale`:t.column1(e.sourceFieldID).constValue(e.factor);break;case`template`:t.template(e.template);break;case`=`:t.column1(e.sourceFieldID).childField(e.transformations?e.transformations.map(e=>ComputedField.fromDDL(e)):[]);break;case`map`:t.column1(e.sourceFieldID).default(e.default).mapping(e.mappings?e.mappings.map(e=>B.fromDDL(e)):[]);break;default:t.column1(e.sourceFieldID1).column2(e.sourceFieldID2)}return t}static fromDDL(e){return new ComputedField().fromDDL(e)}hash(){return(0,r.hashSum)(this.toDDL())}columns(){return this._owner.fieldIDs()}computedField(){switch(this.type()){case`=`:let e=this.validChildFields();return e.length===0&&this.hasChildren()&&(e=this.children().map(e=>new ComputedField().owner(this).label(e.id).type(`=`).column1(e.id))),{...this._owner.field(this.column1()),id:this.label(),children:e.length?e.map(e=>e.computedField()):void 0};case`*`:case`/`:case`+`:case`-`:case`scale`:return{id:this.label(),type:`number`};case`template`:return{id:this.label(),type:`string`};case`map`:return{id:this.label(),type:`object`}}return{id:this.label(),type:`string`}}projection(e){let t=this.hasChildFields(),n=this.validChildFields().map(t=>({label:t.label(),func:t.computeFunc(e)}));return r=>{let i=e&&t?{}:{...r};for(let e of n)i[e.label]=e.func(r);return e&&t&&(i.__lparam=r),i}}computeFunc(e){let t=this.column1(),i=this.column2();switch(this.type()){case`=`:return this.hasChildFields()?n=>(n[t].Row&&(0,r.isArray)(n[t].Row)?n[t].Row:n[t]).map(this.projection(e)):e=>e[t];case`*`:return e=>e[t]*+e[i];case`/`:return e=>e[t]/+e[i];case`+`:return e=>+e[t]+ +e[i];case`-`:return e=>e[t]-+e[i];case`scale`:let a=this.constValue();return e=>+e[t]*a;case`template`:let o=this.template();return e=>n.Utility.template(o,e);case`map`:let s=this.default(),c={};for(let e of this.mapping())c[e.value()]=e.newValue();return e=>c[e[t]]||s;default:return e=>e[t]}}fieldIDs(){let e=this._owner.field(this.column1());if(e)switch(e.type){case`dataset`:return e.children.map(e=>e.id);case`object`:return Object.keys(e.fields)}return[]}field(e){let t=this._owner.field(this.column1());if(t)switch(t.type){case`dataset`:for(let n of t.children)if(n.id===e)return n;break;case`object`:return t.fields[e]}}};V.prototype._class+=` ComputedField`;var H=class MultiField extends n.PropertyExt{_owner;constructor(){super()}hash(){return(0,r.hashSum)(this.toDDL())}owner(e){return arguments.length?(this._owner=e,this):this._owner}valid(){return!!this.label()&&this.validMultiFields().length>0}validate(e){let t=[];for(let n of this.validMultiFields())t=t.concat(n.validate(`${e}.computedFields`));return t}toDDL(){return{fieldID:this.label(),type:`multi`,transformations:this.transformations()}}fromDDL(e){return this.label(e.fieldID).transformations(e.transformations)}static fromDDL(e){return new MultiField().fromDDL(e)}validMultiFields(){return this.multiFields().filter(e=>e.valid())}transformations(e){return arguments.length?(this.multiFields(e.map(e=>V.fromDDL(e))),this):this.validMultiFields().map(e=>e.toDDL())}fieldIDs(){return this._owner.fieldIDs()}field(e){return this._owner.field(e)}};H.prototype._class+=` MultiField`;var ProjectBase=class extends Activity{static ComputedField=V;_includeLParam=!1;_trim=!1;validate(){let e=[];for(let t of this.validComputedFields())e=e.concat(t.validate(`${this.classID()}.computedFields`));return e}constructor(){super()}transformations(e){return arguments.length?(this.computedFields(e.map(e=>{switch(e.type){case`multi`:return H.fromDDL(e);default:return V.fromDDL(e)}})),this):this.validComputedFields().map(e=>e.toDDL())}exists(){return this.validComputedFields().length>0}fieldIDs(){return this.inFields().map(e=>e.id)}field(e){for(let t of this.inFields())if(t.id===e)return t;return null}clearComputedFields(){this.computedFields([])}appendComputedFields(e){for(let t of e){let e=new V().owner(this).label(t.label).type(t.type);t.column!==void 0&&e.column1(t.column),this.computedFields().push(e)}return this}validComputedFields(){return this.computedFields().filter(e=>e.valid())}hasComputedFields(){return this.validComputedFields().length}computeFields(e){if(!this.exists())return super.computeFields(e);let t=[],n={};for(let e of this.validComputedFields())if(e instanceof H)for(let r of e.validMultiFields()){let e=r.computedField();t.push(e),n[e.id]=!0}else{let r=e.computedField();t.push(r),n[r.id]=!0}if(this._trim&&this.hasComputedFields()){if(this._includeLParam){let e={id:`__lparam`,type:`object`};t.push(e),n[e.id]=!0}}else t=t.concat(e.filter(e=>!n[e.id]));return()=>t}referencedFields(e){super.referencedFields(e);let t=[];for(let e of this.validComputedFields())if(e instanceof H)for(let n of e.validMultiFields())t.push(n.column1()),n.column2()&&t.push(n.column2());else if(e.type()===`template`)for(let r of n.Utility.templateFields(e.template()))t.push(r);else t.push(e.column1()),e.column2()&&t.push(e.column2());super.resolveInFields(e,t)}projection(){let e=this._trim,t=this.hasComputedFields(),n=[];for(let t of this.validComputedFields())if(t instanceof H)for(let r of t.validMultiFields())n.push({label:r.label(),func:r.computeFunc(e)});else n.push({label:t.label(),func:t.computeFunc(e)});return r=>{let i=e&&t?{}:{...r};for(let e of n)i[e.label]=e.func(r);return e&&t&&this._includeLParam&&(i.__lparam=r),i}}computeData(){let e=super.computeData();return e.length===0||!this.exists()?e:e.map(this.projection())}},U=class Project extends ProjectBase{toDDL(){return{type:`project`,transformations:this.transformations()}}fromDDL(e){return this.transformations(e.transformations)}static fromDDL(e){return new Project().fromDDL(e)}hash(e={}){return super.hash({ddl:this.toDDL(),...e})}};U.prototype._class+=` Project`;var W=class Mappings extends ProjectBase{constructor(){super(),this._trim=!0,this._includeLParam=!0}toDDL(){return{type:`mappings`,transformations:this.transformations()}}fromDDL(e){let t=e||{transformations:[]};return this.transformations(t.transformations)}static fromDDL(e){return new Mappings().fromDDL(e)}hash(e={}){return super.hash({ddl:this.toDDL(),...e})}referencedFields(e){if(this.hasComputedFields())return super.referencedFields(e);this.resolveInFields(e,this.inFields().filter(e=>e.id!==`__lparam`).map(e=>e.id))}};W.prototype._class+=` Mappings`,B.prototype.publish(`value`,null,`any`,`Compare Value`,void 0,{validate:e=>!e.value()&&!e.newValue()||!!e.value()&&!!e.newValue()}),B.prototype.publish(`newValue`,null,`any`,`New Value`,void 0,{validate:e=>!e.value()&&!e.newValue()||!!e.value()&&!!e.newValue()}),V.prototype.publish(`label`,null,`string`,`Label`,null,{optional:!0}),V.prototype.publish(`type`,`mapping`,`set`,`Project type`,[`=`,`*`,`/`,`+`,`-`,`scale`,`template`,`map`],{optional:!0,disable:e=>!e.label()}),V.prototype.publish(`column1`,null,`set`,`Param 1`,function(){return this.columns()},{optional:!0,disable:e=>e.disableColumn1(),validate:e=>e.columns().indexOf(e.column1())>=0}),V.prototype.publish(`column2`,null,`set`,`Param 2`,function(){return this.columns()},{optional:!0,disable:e=>e.disableColumn2(),validate:e=>e.columns().indexOf(e.column2())>=0}),V.prototype.publish(`constValue`,null,`number`,`Const value`,null,{optional:!0,disable:e=>!e.label()||[`scale`].indexOf(e.type())<0}),V.prototype.publish(`template`,null,`string`,`template`,null,{optional:!0,disable:e=>!e.label()||[`template`].indexOf(e.type())<0}),V.prototype.publish(`default`,null,`any`,`Default Value`,null,{optional:!0,disable:e=>!e.label()||[`map`].indexOf(e.type())<0}),V.prototype.publish(`mapping`,[],`propertyArray`,`Mapped Values`,null,{autoExpand:B,disable:e=>e.disableMapping()}),V.prototype.publish(`childField`,[],`propertyArray`,`Child Fields`,null,{autoExpand:V,disable:e=>e.disableChildField()}),H.prototype.publish(`label`,``,`string`,`Label`),H.prototype.publish(`multiFields`,[],`propertyArray`,`Multi Fields`,null,{autoExpand:V}),ProjectBase.prototype.publish(`computedFields`,[],`propertyArray`,`Computed Fields`,null,{autoExpand:V});var G=class SortColumn extends n.PropertyExt{_owner;validate(e){let t=[];return this.fieldID_valid()||t.push({source:`${e}.fieldID`,msg:`Invalid fieldID: ${this.fieldID()}`,hint:`expected ${JSON.stringify(this.fieldIDs())}`}),t}constructor(){super()}owner(e){return arguments.length?(this._owner=e,this):this._owner}valid(){return!!this.fieldID()}toDDL(){return{fieldID:this.fieldID(),descending:this.descending()}}fromDDL(e){return this.fieldID(e.fieldID).descending(e.descending)}static fromDDL(e){return new SortColumn().fromDDL(e)}hash(){return(0,r.hashSum)({sortColumn:this.fieldID(),descending:this.descending()})}fieldIDs(){return this._owner.fieldIDs()}field(e){return this._owner.inFields().filter(t=>t.id===e)[0]}};G.prototype._class+=` SortColumn`;var K=class Sort extends Activity{static Column=G;validate(){let e=[];for(let t of this.validSortBy())e=e.concat(t.validate(`Sort.column`));return e}constructor(){super()}toDDL(){return{type:`sort`,conditions:this.conditions()}}fromDDL(e){return this.conditions(e.conditions),this}static fromDDL(e){return new Sort().fromDDL(e)}conditions(e){return arguments.length?(this.column(e.map(e=>G.fromDDL(e))),this):this.validSortBy().map(e=>e.toDDL())}hash(){return(0,r.hashSum)({Sort:this.column().map(e=>e.hash())})}referencedFields(e){super.referencedFields(e),super.resolveInFields(e,this.validSortBy().map(e=>e.fieldID()))}validSortBy(){return this.column().filter(e=>e.fieldID())}exists(){return this.validSortBy().length>0}fieldIDs(){return this.inFields().map(e=>e.id)}computeData(){let e=super.computeData(),t=[];for(let e of this.validSortBy())t.push({compare:e.descending()?n.descending:n.ascending,id:e.fieldID()});return t.length?[...e].sort((e,n)=>{for(let r of t){let t=r.compare(e[r.id],n[r.id]);if(t!==0)return t}return 0}):e}};K.prototype._class+=` Sort`,G.prototype.publish(`fieldID`,null,`set`,`Sort Field`,function(){return this.fieldIDs()},{optional:!0,validate:e=>e.fieldIDs().indexOf(e.fieldID())>=0}),G.prototype.publish(`descending`,!1,`boolean`,`Sort Field`),K.prototype.publish(`column`,[],`propertyArray`,`Source Columns`,null,{autoExpand:G});var HipiePipeline=class extends ActivityPipeline{_ec;_origDatasource;_origFilters;_origProject;_origGroupBy;_origSort;_origLimit;constructor(e,t){super(),this._ec=e,this._id=t,this._datasource=new DSPicker(this._ec),this._filters=new P(this._ec),this._project=new U,this._groupBy=new R,this._sort=new K,this._limit=new z,this.updateSequence()}activities(e){return super.activities.apply(this,arguments)}updateSequence(){this.activities([this.datasource(),this.filters(),this.project(),this.groupBy(),this.sort(),this.limit()])}selectionFields(){return this.last().outFields()}};HipiePipeline.prototype.publish(`datasource`,null,`widget`,`Data Source 2`),HipiePipeline.prototype.publish(`filters`,null,`widget`,`Client Filters`),HipiePipeline.prototype.publish(`project`,null,`widget`,`Project`),HipiePipeline.prototype.publish(`groupBy`,null,`widget`,`Group By`),HipiePipeline.prototype.publish(`sort`,null,`widget`,`Sort`),HipiePipeline.prototype.publish(`limit`,null,`widget`,`Limit output`);function wrapHipiePipelineProperty(e){let t=`_orig${e.charAt(0).toUpperCase()+e.slice(1)}`;HipiePipeline.prototype[t]=HipiePipeline.prototype[e],HipiePipeline.prototype[e]=function(e){let n=HipiePipeline.prototype[t].apply(this,arguments);return e!==void 0&&this.updateSequence(),n}}wrapHipiePipelineProperty(`datasource`),wrapHipiePipelineProperty(`filters`),wrapHipiePipelineProperty(`project`),wrapHipiePipelineProperty(`groupBy`),wrapHipiePipelineProperty(`sort`),wrapHipiePipelineProperty(`limit`);var NullView=class extends HipiePipeline{hash(){return super.hash()}_fetch(e,t){return Promise.resolve([])}};NullView.prototype._class+=` NullView`;var VizPopupPanel=class extends u.Modal{_owner;_ownerLParam;constructor(e,t){super(),this._owner=e,this._ownerLParam=t,this._drawStartPos=`origin`,this.visible(!1),this.minHeight_default(`240px`),this.minWidth_default(`320px`),this.overflowY_default(`hidden`)}_host;host(e){return arguments.length?(this._host&&this._host!==e&&this._host._togglePopup.selected(!1).render(),this._host=e,this._owner.vizActivation(this._ownerLParam),this):this._host}enter(e,t){e.parentElement.style.position=`absolute`;let n=this.widget().title();n&&(this.title(n),this.widget().titleVisible(!1)),super.enter(e,t)}update(e,t){this.fixedTop(this._pos.y+`px`),this.fixedLeft(this._pos.x+`px`),super.update(e,t)}exit(e,t){super.exit(e,t),this.widget().title()&&this.widget().titleVisible(!0)}closeModal(){super.closeModal(),this._host&&this._host._togglePopup.selected(!1).render()}};VizPopupPanel.prototype._class+=` marshaller_VizPopupPanel`;var VizChartPanel=class extends u.ChartPanel{_popup;_togglePopup=new n.ToggleButton().faChar(`fa-filter`).tooltip(`Filter`).on(`click`,()=>{this._popup.host(this);let e=this.locateClosestAncestor([`marshaller_DashboardDockPanel`,`marshaller_DashboardGrid`]).getBBox(!0),t=this._popup.widget(),n=this._togglePopup.getBBox();this._popup.pos({x:-e.x+n.x+n.width-t.minWidth(),y:-e.y+n.y+n.height}).resize({width:t.minWidth(),height:t.minHeight()}).visible(this._togglePopup.selected()).render(e=>{let t=`#`+e.id()+` .layout_Carousel .common_Widget`,n=e.element().node();if(n){let{height:r,width:i}=n.querySelector(t).getBoundingClientRect();e.resizeBodySync(i,r)}})});_origButtons;_filterButtons;constructor(){super(),this._origButtons=this.buttons(),this._filterButtons=[this._togglePopup,new n.Spacer,...this._origButtons]}popup(e){return arguments.length?(this._popup=e,this._popup||this._togglePopup.selected(!1),this.buttons(this._popup?this._filterButtons:this._origButtons),this):this._popup}};VizChartPanel.prototype._class+=` marshaller_VizChartPanel`,VizChartPanel.prototype.publish(`descriptionTemplate`,``,`string`),VizChartPanel.prototype.publish(`minWidth`,320,`number`,`Min Width`),VizChartPanel.prototype.publish(`minHeight`,240,`number`,`Min Height`);var q={Table:o.Table,FieldForm:s.FieldForm,Area:a.Area,Bubble:a.Bubble,Bar:a.Bar,Column:a.Column,Contour:a.Contour,HexBin:a.HexBin,Line:a.Line,Pie:a.Pie,Radar:a.Radar,RadialBar:a.RadialBar,Scatter:a.Scatter,Step:a.Step,WordCloud:a.WordCloud,USCountiesChoropleth:l.ChoroplethCounties,USStatesChoropleth:l.ChoroplethStates,ClusterPins:l.Leaflet.ClusterPins,EntityRectList:n.EntityRectList,AdjacencyGraph:c.AdjacencyGraph,DataGraph:c.DataGraph},J=[];for(let e in q)J.push(e);function typeClass(e){return q[e]||o.Table}function typeNew(e){let t=new(q[e]||o.Table);return t instanceof s.FieldForm?t.validate(!1).allowEmptyRequest(!0):t instanceof c.AdjacencyGraph&&t.uidColumn(`uid`).labelColumn(`label`).iconColumn(`icon`).linksColumn(`links`).linkUidColumn(`uid`).linkLabelColumn(`label`),t}function typeInputs(e){return typeClass(e).__inputs||[]}var Visualization=class extends n.PropertyExt{_ec;_origVisibility;_origChartType;_origChartPanel;_hipiePipeline;constructor(e,t){super(),this._ec=e,this._hipiePipeline=t,this.mappings(new W),this.chartPanel(new VizChartPanel),this.typeChanged()}visualizationIDs(){return this._ec.elementIDs().filter(e=>e!==this.id())}_prevChartType;typeChanged(){if(this._prevChartType!==this._chartType){this._prevChartType=this._chartType,this.refreshMappings();let e=typeNew(this._chartType);this.chartPanel().widget(e)}}properties(e){return arguments.length?(this.chartPanel().deserialize(e),this):this.chartPanel().serialize()}refreshMappings(){let e=this.mappings();e.sourceActivity(this._hipiePipeline);let t=e.validComputedFields(),n=e.inFields(),r={};return e.computedFields(typeInputs(this._chartType).map((i,a)=>{let o=t[a];if(o)o instanceof H||o.label(i.id);else if(i.multi){o=new H().owner(e).label(i.id);let t=[];for(let e of n)(i.type===`any`||i.type===e.type)&&!r[e.id]&&(r[e.id]=!0,t.push(new V().label(e.id).type(`=`).column1(e.id)));o.multiFields(t)}else{o=new V().owner(e).label(i.id).type(`=`);for(let e of n)if((i.type===`any`||i.type===e.type)&&!r[e.id]){r[e.id]=!0,o.column1(e.id);break}}return o})),this}_prevFields=[];_prevLinkFields=[];_prevData=[];refreshData(){let e=this.mappings(),t=e.outFields(),n=this.toDBFields(t),r,i=[],a=this._ec.element(this.secondaryDataviewID());a&&(r=a.mappings().outFields(),i=this.toDBFields(r));let o=this._prevFields!==t||this._prevLinkFields!==r;if(o)if(this._prevFields=t,this.chartType()===`DataGraph`){let e=this.chartPanel().widget();e.vertexColumns(n.map(e=>e.label())),e.edgeColumns(i.map(e=>e.label()))}else this.chartPanel().fields(n.filter(e=>e.id()!==`__lparam`));else console.warn(`***${this.id()} Immutable Fields***`);let s=e.outData(),c=this._prevData!==s;if(c){this._prevData=s;let e=this.toDBData(n,s);if(this.chartType()===`DataGraph`){let t=this.chartPanel().widget();if(t.vertices(e),a){let e=a.mappings().outData(),n=this.toDBData(i,e);t.edges(n)}}else this.chartPanel().data(e)}else console.warn(`${this.id()} Immutable Data!`);return o||c?this.chartPanel().renderPromise().then(()=>{}):Promise.resolve()}fieldTypeTodbFieldType(e){switch(e){case`dataset`:return`nested`;case`boolean`:return`boolean`;case`number`:return`number`;default:return`string`}}toDBFields(e){let t=[];for(let r of e||[]){let e=new n.Database.Field().type(this.fieldTypeTodbFieldType(r.type)).id(r.id).label(r.id);switch(r.type){case`dataset`:e.children(this.toDBFields(r.children));break;case`object`:break}t.push(e)}return t}toDBData(e,t){return((0,r.isArray)(t)?t:[t]).map(t=>{let n=[];for(let r of e)r.type()===`nested`?n.push(this.toDBData(r.children(),t[r.id()].Row||t[r.id()])):n.push(t[r.label()]);return n})}exec(){let e=[];if(this.secondaryDataviewID_exists()){let t=this.secondaryDataviewID(),n=this._ec.element(t);n&&e.push(n.visualization().exec())}let t=this.mappings();return t.sourceActivity(this._hipiePipeline),e.push(t.refreshMeta().then(()=>t.exec())),Promise.all(e)}refresh(){return this.chartPanel().startProgress&&this.chartPanel().startProgress(),this.exec().then(()=>(this.chartPanel().finishProgress&&this.chartPanel().finishProgress(),this.refreshData()))}click(e,t,n,r){}vertex_click(e,t,n){}};Visualization.prototype._class+=` Visualization`,Visualization.prototype.publishProxy(`title`,`_chartPanel`),Visualization.prototype.publishProxy(`description`,`_chartPanel`),Visualization.prototype.publish(`visibility`,i.DDL2.VisibilitySet[0],`set`,`Type`,i.DDL2.VisibilitySet),Visualization.prototype.publish(`chartType`,`Table`,`set`,`Type`,J),Visualization.prototype.publish(`secondaryDataviewID`,null,`set`,`Secondary Data View (e.g. graph edges)`,function(){return this.visualizationIDs()},{optional:!0}),Visualization.prototype.publish(`mappings`,null,`widget`,`Mappings`,void 0,{render:!1,internal:!0}),Visualization.prototype.publish(`chartPanel`,[],`widget`,`Widget`),Visualization.prototype._origVisibility=Visualization.prototype.visibility,Visualization.prototype.visibility=function(e){let t=this._visibility,n=Visualization.prototype._origVisibility.apply(this,arguments);return e!==void 0&&t!==e&&this.chartPanel().target(null),n},Visualization.prototype._origChartType=Visualization.prototype.chartType,Visualization.prototype.chartType=function(e,t){e!==void 0&&J.indexOf(e)===-1&&(e=`Table`);let n=Visualization.prototype._origChartType.apply(this,arguments);if(e!==void 0&&(this.typeChanged(),t)){let e=this.chartPanel().widget();for(let n in t)typeof e[n]==`function`&&e[n](t[n])}return n},Visualization.prototype._origChartPanel=Visualization.prototype.chartPanel,Visualization.prototype.chartPanel=function(e){let t=Visualization.prototype._origChartPanel.apply(this,arguments);if(e!==void 0){this._chartPanel.on(`click`,(e,t,n,r)=>this.click(e,t,n,r)).on(`vertex_click`,(e,t,n)=>this.vertex_click(e,t,n));for(let e in q)if(this._chartPanel.widget()instanceof q[e]){this._chartType=e;break}}return t};var State=class extends n.PropertyExt{constructor(){super(),this.selection([])}set(e){return(0,r.hashSum)(this.selection())===(0,r.hashSum)(e)?!1:(this.selection(e),!0)}removeInvalid(e){let t=this.selection(),n=[];for(let i of t)(0,r.find)(e,(e,t)=>{for(let t in i)if(i[t]!==e[t])return!1;return!0})&&n.push(i);return n.length===t.length?!1:(this.selection(n),!0)}};State.prototype._class+=` State`,State.prototype.publish(`selection`,[],`array`,`State`);var Y=0,Element=class extends n.PropertyExt{_ec;_vizChartPanel;_origVisualization;constructor(e){for(super(),this._ec=e;Y++,this._id=`e_${Y}`,this._ec.elementExists(this._id););let t=new HipiePipeline(this._ec,this._id);this.hipiePipeline(t),this._vizChartPanel=new Visualization(this._ec,this.hipiePipeline()).id(`viz_${Y}`).title(`Element ${Y}`),this._vizChartPanel.chartPanel().id(`cp_${Y}`),this.visualization(this._vizChartPanel),this.state(new State)}id(e){let t=super.id.apply(this,arguments);return arguments.length&&this._vizChartPanel.id(e),t}chartType(){return this._vizChartPanel.chartType()}chartPanel(e){return arguments.length?(this._vizChartPanel.chartPanel(e),this):this._vizChartPanel.chartPanel()}chart(){return this._vizChartPanel.chartPanel().widget()}mappings(e){return arguments.length?(this._vizChartPanel.mappings(e),this):this._vizChartPanel.mappings()}pipeline(e){return this.hipiePipeline().activities(e),this}updatedBy(){let e=this.hipiePipeline().updatedBy();return this.visualization().secondaryDataviewID_exists()&&e.push(this.visualization().secondaryDataviewID()),e}dataProps(){return this.hipiePipeline()}vizProps(){return this.visualization().chartPanel()}stateProps(){return this.state()}_errors=[];errors(){return this._errors}validate(){if(!this._initialized)return[];this._errors=[];let e=this.hipiePipeline();for(let t of[...e.activities(),this.mappings()])for(let e of t.validate())this._errors.push({elementID:this.id(),...e});return this._errors}_initialized=!1;refresh(){let e=this.hipiePipeline().filters().validFilters().map(e=>e.createFilterDescription());return this.visualization().chartPanel().description(e.join(`, `)),this.visualization().refresh().then(()=>{this._initialized=!0;let e=this.hipiePipeline().outData();this.visualization().chartType()===`FieldForm`?this.state().set([...e])&&this.selectionChanged():this.state().removeInvalid(e)&&this.selectionChanged()})}selection(e){return arguments.length?(this.state().selection(e),this.selectionChanged(),this):this.state().selection()}selectionChanged(){let e=[];for(let t of this._ec.filteredBy(this.id()))e.push(t.refresh());Promise.all(e).then(()=>{this._ec.vizStateChanged(this)})}monitor(e){return this.hipiePipeline().monitor(e)}};Element.prototype._class+=` Viz`,Element.prototype.publish(`hipiePipeline`,null,`widget`,`Data View`),Element.prototype.publish(`visualization`,null,`widget`,`Visualization`),Element.prototype.publish(`state`,null,`widget`,`State`),Element.prototype._origVisualization=Element.prototype.visualization,Element.prototype.visualization=function(e){let t=Element.prototype._origVisualization.apply(this,arguments);return e!==void 0&&this._visualization.on(`click`,(e,t,n,i)=>{if(i&&i.selection)this.selection(n?i.selection.map(e=>e.__lparam||e):[]);else{let t=(0,r.isArray)(e)?e:[e];this.selection(n?t.map(e=>e.__lparam||e):[])}}).on(`vertex_click`,(e,t,n)=>{let i=(0,r.isArray)(e)?e:[e];this.selection(n?i.map(e=>e.__lparam||e):[])}),t};var ElementContainer=class extends n.PropertyExt{_nullElement;_datasources=[b];_elements=[];constructor(){super(),this.clear(),this._nullElement=new Element(this)}clear(e){this._datasources=e===void 0?[b]:this._datasources,this._elements=e===void 0?[]:this._elements.filter(t=>t.id()!==e)}_hookSend;hookSend(e){return arguments.length?(this._hookSend=e,this):this._hookSend}datasources(e){return arguments.length?(this._datasources=e,this):this._datasources}datasource(e){return this._datasources.filter(t=>t.id()===e)[0]}appendDatasource(e){return this._datasources.push(e),this}removeDatasource(e){return this._datasources=this._datasources.filter(t=>t!==e),this}elements(){return[...this._elements]}element(e){let t;return t=typeof e==`string`?this._elements.filter(t=>t.id()===e):e instanceof VizChartPanel?this._elements.filter(t=>t.chartPanel()===e):this._elements.filter(t=>t.vizProps()===e),t.length?t[0]:this._nullElement}elementExists(e){return this.element(e)!==this._nullElement}elementIDs(){return this._elements.map(e=>e.id())}append(e){return this._elements.push(e),this}filteredBy(e){return this._elements.filter(t=>t.updatedBy().indexOf(e)>=0)}views(){return this._elements.map(e=>e.hipiePipeline())}view(e){return this.views().filter(t=>t.id()===e)[0]}normalizePersist(e){let t={};return e.__properties.content.map(e=>{let n=!!e.__properties.widget.__properties.chart,r=e,i=e.__properties.widget,a=n?e.__properties.widget.__properties.chart:e.__properties.widget.__properties.widget,o=e.__properties.widget.__id?e.__properties.widget.__id:e.__properties.widget.__properties.widget.__id;t[o]={id:o,package:a.__class.split(`_`)[0],object:a.__class.split(`_`)[1],cell:_get_params(r,[`chart`,`widget`,`fields`]),panel:_get_params(i,[`chart`,`widget`,`fields`]),widget:_get_params(a,[`fields`])}}),t;function _get_params(e,t){let n={};return Object.keys(e.__properties).filter(e=>t.indexOf(e)===-1).forEach(t=>n[t]=e.__properties[t]),n}}validate(){let e=[];return this._elements.forEach(t=>{e=e.concat(t.validate())}),e}refresh(){return Promise.all(this.elements().map(e=>e.refresh())).then(()=>this)}vizStateChanged(e){}};ElementContainer.prototype._class+=` dashboard_ElementContainer`,ElementContainer.prototype.publish(`samples`,10,`number`,`Number of samples`),ElementContainer.prototype.publish(`sampleSize`,100,`number`,`Sample size`);function responseText(e){if(!e.ok)throw Error(e.status+` `+e.statusText);return e.text()}function text_default(e,t){return fetch(e,t).then(responseText)}__name(text_default,`default`);var PopupManager=class extends n.Widget{_ec;_popups=[];_popupIdx={};popupPanels(){return this._popups||=[],this._popupIdx||={},this._popups}popupChartPanels(){return this.popupPanels().map(e=>e.widget())}addPopup(e){let t=this._ec.element(e),n=this.element().node(),r=new VizPopupPanel(this,t).target(n).widget(e).relativeTargetId(this.id()).size({width:e.minWidth(),height:e.minHeight()});this._popups.push(r),this._popupIdx[e.id()]={panel:r,monitorHandle:e.monitor(t=>{switch(t){case`minWidth`:case`minHeight`:r.resize({width:e.minWidth(),height:e.minHeight()}).render();break}})},this._ec.filteredBy(t.id()).forEach(e=>{e.visualization().chartPanel().popup(r)})}removePopup(e){let t=this._ec.element(e);this._ec.filteredBy(t.id()).forEach(e=>{e.visualization().chartPanel().popup(null)}),this._popupIdx[e.id()].panel.target(null),this._popupIdx[e.id()].monitorHandle.remove(),e.target(null),delete this._popupIdx[e.id()],this._popups=this._popups.filter(t=>t.widget()!==e)}syncPopups(){let e=(0,r.compare)(this.popupChartPanels(),this._ec.elements().filter(e=>e.visualization().visibility()===`flyout`).map(e=>e.visualization().chartPanel()));for(let t of e.exit)this.removePopup(t);for(let t of e.enter)this.addPopup(t);return this}vizActivation(){}},DashboardDockPanel=class extends d.DockPanel{_ec;constructor(e){super(),this._ec=e}tabTitle(e){return this.hideSingleTabs()?e.visualization().title?e.visualization().title():e.visualization().id():e.id()}titleClassed(e,t,n){let r=e.title.className.split(` `);n&&r.indexOf(t)<0?r.push(t):!n&&r.indexOf(t)>0&&(r=r.filter(e=>e!==t)),e.title.className=r.join(` `)}updateTitle(e){let t=this.getWidgetAdapter(e),n=this._ec.element(e),r=n.validate();t.title.label=this.tabTitle(n),this.titleClassed(t,`error`,r.length>0),t.title.caption=r.map(e=>`${e.source}: ${e.msg}`).join(`
2
2
  `)}activate(e){let t=this.getWidgetAdapter(e.visualization().chartPanel());t&&t.activate()}syncMinSize(e){return e.minWidth_exists()||e.minHeight_exists()?((0,n.select)(this.getWidgetAdapter(e).node).style(`min-width`,`${e.minWidth()}px`).style(`min-height`,`${e.minHeight()}px`),!0):!1}syncWidgets(){let e=(0,r.compare)(this.widgets(),this._ec.elements().filter(e=>e.visualization().visibility()===`normal`).map(e=>e.visualization().chartPanel())),t=!1;for(let t of e.exit)this.removeWidget(t);for(let n of e.enter){let e=this._ec.element(n);this.addWidget(n,this.tabTitle(e),`split-bottom`,void 0,this.hideSingleTabs()?void 0:this),t=this.syncMinSize(n)||t}for(let n of e.update)this.updateTitle(n),t=this.syncMinSize(n)||t;return t&&this.refit(),this}childActivation(e,t){super.childActivation(e,t),this.vizActivation(this._ec.element(e));for(let e of this.widgetAdapters())e===t?(e.addClass(`active`),this.titleClassed(e,`active`,!0),e.title.iconClass=`active`):(e.removeClass(`active`),this.titleClassed(e,`active`,!1),e.title.iconClass=``)}vizActivation(e){}canClose(e,t){let n=this._ec.element(e).id(),r=window.confirm(`Remove Widget "${n}"?`);return r&&(this._ec.clear(n),this.syncWidgets(),this.vizActivation(void 0)),r}syncPopups(){}};DashboardDockPanel.prototype._class+=` marshaller_DashboardDockPanel`,DashboardDockPanel.prototype.mixin(PopupManager);var DashboardGrid=class extends u.Grid{_ec;_layoutCache=[];constructor(e){super(),this._ec=e,this.designMode(!1),this.surfacePadding(`0`),this.surfaceBorderWidth(0)}updateGrid(e,t=0,n=!1){super.updateGrid(e,t,n),this._layoutCache=this.content().map(e=>({id:e.widget().id(),position:[e.gridCol(),e.gridRow(),e.gridColSpan(),e.gridRowSpan()]}))}layoutObj(e){if(e)if(e.main){let t=ddl2_layout(e,10,10);this._layoutCache=t}else e instanceof Array&&(this._layoutCache=e);return this;function ddl2_layout(e,t,n){let r=[];return dive(e.main,0,0,t,n),r;function dive(e,t,n,i,a){e.children?e.type===`split-area`?e.orientation===`horizontal`?e.children.forEach((r,o)=>{let s=e.sizes[o]*i,c=a,l=o===0?t:t+e.sizes[0]*i,u=n;dive(e.children[o],l,u,s,c)}):e.orientation===`vertical`?e.children.forEach((r,o)=>{let s=i,c=e.sizes[o]*a,l=t,u=o===0?n:n+e.sizes[0]*a;dive(e.children[o],l,u,s,c)}):console.error(`wtf`):e.type===`tab-area`&&e.children.forEach((r,o)=>{let s=i,c=e.sizes[o]*a,l=t,u=o===0?n:n+e.sizes[0]*a;dive(e.children[o],l,u,s,c)}):r.push([t,n,i,a].map(Math.round))}}}layout(){return this._layoutCache}widgets(){return this.content().map(e=>e.widget())}hideSingleTabs(){return!0}getWidgetAdapter(){}tabTitle(e){return this.hideSingleTabs()?e.visualization().title?e.visualization().title():e.visualization().id():e.id()}updateTitle(e){let t=this.getWidgetCell(e.id()),n=this._ec.element(e),r=this.tabTitle(n);t.widget().title(r)}activate(e){}removeWidget(e){let t=this.getWidgetCell(e.id());this.clearContent(t)}syncMinSize(e){return e.minWidth_exists()||e.minHeight_exists()?(this.getWidgetCell(e.id()).element().style(`min-width`,`${e.minWidth()}px`).style(`min-height`,`${e.minHeight()}px`),!0):!1}syncWidgets(){let e=(0,r.compare)(this.widgets(),this._ec.elements().filter(e=>e.visualization().visibility()===`normal`).map(e=>e.visualization().chartPanel()));for(let t of e.exit)this.removeWidget(t);let t=0,n=0,i=[];for(let r of e.enter){let e=this._ec.element(r),a=this.content().length;if(this._layoutCache&&this._layoutCache[a]){let a=this._layoutCache.find(e=>e.id===r.id());if(a){let[r,i,o,s]=a.position;this.setContent(i,r,e.visualization().chartPanel(),``,s,o),r+o>t&&(t=r+o),i+s>n&&(n=i+s)}else i.push(e.visualization().chartPanel())}else i.push(e.visualization().chartPanel())}let a=this.content().reduce((e,t)=>Math.max(e,t.gridRow()+t.gridRowSpan()),0);i.forEach(e=>{this.setContent(a,0,e,``,3,3),a+=3});for(let t of e.update)this.updateTitle(t);return this}childActivation(e,t){this.vizActivation(this._ec.element(e))}postSelectionChange(){super.postSelectionChange();let e=this._selectionBag.get();e.length>0&&this.childActivation(e[0].widget.widget())}vizActivation(e){}canClose(e,t){let n=this._ec.element(e).id(),r=window.confirm(`Remove Widget "${n}"?`);return r&&(this._ec.clear(n),this.syncWidgets(),this.vizActivation(void 0)),r}syncPopups(){}};DashboardGrid.prototype._class+=` marshaller_DashboardGrid`,DashboardGrid.prototype.mixin(PopupManager);var X=(0,r.scopedLogger)(`marshaller/ddl2/ddl`),DDLDatasourceAdapter=class{_dsDedup;constructor(){}clear(){this._dsDedup={}}id(e){return e instanceof S?`${e.url()}/${e.wuid()}`:e instanceof O?`${e.url()}/${e.querySet()}/${e.queryID()}`:e instanceof T?`${e.url()}/${e.action()}`:e.id()}_resolveID(e){return this._dsDedup[this.id(e)].ds.id()}resolveID(e){if(e instanceof WUResultRef)return this._resolveID(e.datasource().wu());if(e instanceof RoxieResultRef||e instanceof HipieResultRef||e instanceof RestResultRef)return this._resolveID(e.datasource().service())}append(e){let t=e instanceof DSPicker?e.datasource():e,n=e instanceof DSPicker?e.datasourceRef():void 0,r=t.id(),i=t instanceof x?t.wu():t instanceof k||t instanceof E?t.service():t,a=this.id(i);this._dsDedup[a]||(this._dsDedup[a]={ds:i,result:{}}),this._dsDedup[a].result[r]||(this._dsDedup[a].result[r]={refType:t,ref:n})}getAll(){let e=[];for(let t in this._dsDedup){let n=this._dsDedup[t].ds.toDDL();if(n.type===`roxie`||n.type===`hipie`||n.type===`rest`){let e={};for(let n in this._dsDedup[t].result){let r=this._dsDedup[t].result[n].refType.toDDL(),i={inputs:{},outputs:{}};this._dsDedup[t].result[n].ref.referencedFields(i);for(let t in i.inputs)i.inputs[t].forEach(t=>{e[t]=r.inputs.filter(e=>e.id===t)[0]})}n.inputs=[];for(let t in e)n.inputs.push(e[t])}if(n.type===`wuresult`||n.type===`roxie`||n.type===`hipie`||n.type===`rest`){let e={};for(let n in this._dsDedup[t].result){let r=this._dsDedup[t].result[n].refType.toDDL();if(r.type===`wuresult`||r.type===`roxie`||r.type===`hipie`||r.type===`rest`)for(let t in r.outputs)e[t]=r.outputs[t]}n.outputs={};for(let t in e)n.outputs[t]=e[t]}e.push(n)}return e}},DDLAdapter=class{_dashboard;_ec;_dsWriteDedup=new DDLDatasourceAdapter;_dsReadDedup={};constructor(e){this._dashboard=e,this._ec=this._dashboard.elementContainer()}writeDatasources(){for(let e of this._ec.elements())this._dsWriteDedup.append(e.hipiePipeline().datasource());return this._dsWriteDedup.getAll()}writeFilters(e){if(e.exists())return e.toDDL()}readFilters(e,t){return P.fromDDL(t,e)}writeProject(e){if(e.exists())return e.toDDL()}readProject(e){return U.fromDDL(e)}writeMappings(e){return e.exists()?e.toDDL():{type:`mappings`,transformations:[]}}readMappings(e){return W.fromDDL(e)}writeGroupBy(e){if(e.exists())return e.toDDL()}readGroupBy(e){return R.fromDDL(e)}writeSort(e){if(e.exists())return e.toDDL()}readSort(e){return K.fromDDL(e)}writeLimit(e){if(e.exists())return e.toDDL()}readLimit(e){return z.fromDDL(e)}readDatasourceRef(e,t,n){if(i.DDL2.isWUResultRef(e)){let n=this._dsReadDedup[e.id];t.datasourceID(n.output(e.output).id())}else i.DDL2.isRoxieServiceRef(e)?(t.datasourceID(`${e.id}_${e.output}`),t.datasourceRef().request(e.request.map(e=>D.fromDDL(this._ec,e)))):t.datasourceID(e.id);return this}writeActivities(e){return e.activities().map(e=>{if(e instanceof P)return this.writeFilters(e);if(e instanceof U)return this.writeProject(e);if(e instanceof R)return this.writeGroupBy(e);if(e instanceof K)return this.writeSort(e);if(e instanceof z)return this.writeLimit(e);if(e instanceof W)return this.writeMappings(e);e instanceof DSPicker||X.warning(`Unknown activity type: ${e.classID()}`)}).filter(e=>!!e)}writeVisualization(e){return{id:e.chartPanel().id(),title:e.title(),description:e.description(),visibility:e.visibility(),chartType:e.chartType(),__class:e.chartPanel().widget().classID(),mappings:this.writeMappings(e.mappings()),properties:e.properties()}}readVisualization(e,t){let n=this.readMappings(e.mappings);return t.chartPanel().id(e.id),t.title(e.title).description(e.description).visibility(e.visibility).chartType(e.chartType).properties(e.properties).mappings(n),this}writeViewDatasource(e){let t=e.toDDL();return t.id=this._dsWriteDedup.resolveID(e)||t.id,t}writeDDLViews(){let e={inputs:{},outputs:{}};for(let t of this._ec.elements())t.visualization().mappings().referencedFields(e);return this._ec.elements().map(e=>{let t=e.hipiePipeline(),n=t.datasource();if(n instanceof DSPicker){let r=n.datasourceRef();return{id:e.id(),datasource:this.writeViewDatasource(r),activities:this.writeActivities(t),visualization:this.writeVisualization(e.visualization())}}throw Error(`Missing DSPicker?`)})}writeProperties(){return{name:p,version:m,buildVersion:h,layout:this._dashboard.layout()}}readDDLViews(e){for(let t of e){let e=new Element(this._ec).id(t.id);this._ec.append(e);let n=e.hipiePipeline();this.readDatasourceRef(t.datasource,n.datasource(),this._ec);for(let e of t.activities){if(i.DDL2.isProjectActivity(e)){let t=this.readProject(e);n.project(t)}if(i.DDL2.isFilterActivity(e)){let t=this.readFilters(e,this._ec);n.filters(t)}if(i.DDL2.isGroupByActivity(e)){let t=this.readGroupBy(e);n.groupBy(t)}if(i.DDL2.isSortActivity(e)){let t=this.readSort(e);n.sort(t)}if(i.DDL2.isLimitActivity(e)){let t=this.readLimit(e);n.limit(t)}}this.readVisualization(t.visualization,e.visualization())}}readProperties(e){e&&e.layout&&this._dashboard.layoutObj(e.layout)}write(){return this._dsWriteDedup.clear(),{version:`2.2.1`,createdBy:{name:p,version:m},datasources:this.writeDatasources(),dataviews:this.writeDDLViews(),properties:this.writeProperties(),hipieProperties:this._dashboard.hipieProps()}}read(e){this._dsWriteDedup.clear();for(let t of e.datasources)switch(t.type){case`databomb`:this._ec.appendDatasource(y.fromDDL(t));break;case`form`:this._ec.appendDatasource(v.fromDDL(t));break;case`logicalfile`:this._ec.appendDatasource(C.fromDDL(this._ec,t));break;case`wuresult`:let e=S.fromDDL(this._ec,t);this._dsReadDedup[e.id()]=e;for(let n in t.outputs)this._ec.appendDatasource(e.output(n));break;case`roxie`:case`hipie`:let n=O.fromDDL(this._ec,t);this._dsReadDedup[n.id()]=n;for(let e in t.outputs)this._ec.appendDatasource(k.fromDDL(this._ec,n,e));break;case`rest`:let r=T.fromDDL(this._ec,t);this._dsReadDedup[r.id()]=r;for(let e in t.outputs)this._ec.appendDatasource(E.fromDDL(this._ec,r,e));break;default:X.warning(`Unknown ddl datasource type: ${t.type} `)}this.readDDLViews(e.dataviews),this.readProperties(e.properties),this._dashboard.hipieProps(e.hipieProperties)}},Imports=class{_moduleMap={};append(e){this._moduleMap[e.module]||(this._moduleMap[e.module]={}),this._moduleMap[e.module][e.class]=!0}write(){let e=[];for(let t in this._moduleMap){let n=[];for(let e in this._moduleMap[t])n.push(e);n.sort(),e.push(`import { ${n.join(`, `)} } from "${t}";`)}return e.join(`
3
3
  `)}};function createProps(e){let t={};for(let n of e.publishedProperties())if(e[n.id+`_modified`]()&&n.id!==`fields`){let r=e[n.id]();switch(n.type){case`propertyArray`:let e=r.map(createProps);e&&(t[n.id]=e);break;default:t[n.id]=r}}return t}var JavaScriptAdapter=class{_dashboard;_ec;_ddlAdapter;_ddlSchema;constructor(e){this._dashboard=e,this._ec=this._dashboard.elementContainer(),this._ddlAdapter=new DDLAdapter(this._dashboard),this._ddlSchema=this._ddlAdapter.write()}createProps(e,t,n=``){let r=[];for(let i of t.publishedProperties())if(t[i.id+`_exists`]())switch(i.type){case`string`:case`set`:r.push(`${e}.${i.id}("${t[i.id]()}")${n};`);break;case`number`:case`boolean`:r.push(`${e}.${i.id}(${t[i.id]()})${n};`);break;case`widget`:r=r.concat(this.createProps(`${e}.${i.id}()`,t[i.id]()));break;case`propertyArray`:i.ext&&r.push(`${e}.${i.id}([${t[i.id]()}])${n};`);break;default:break}return r}writeMeta(e){return``}safeID(e){return e&&e.replace(/ /g,`_`).replace(/\./g,`_`)}datasourceRefID(e){let t=e.datasource;return i.DDL2.isRoxieServiceRef(t)?`${this.safeID(t.id)}_${this.safeID(t.output)}_${this.safeID(e.id)}`:i.DDL2.isWUResultRef(t)?`${this.safeID(t.id)}_${this.safeID(t.output)}`:`${this.safeID(t.id)}`}_dedup={};writeDatasource(e){let t=e.datasource,n=[],r=this._ddlSchema.datasources.filter(e=>e.id===t.id)[0],i=t.output,a=this.datasourceRefID(e);if(!this._dedup[a])switch(this._dedup[a]=!0,r.type){case`wuresult`:let o=this.safeID(e.datasource.id);this._dedup[o]||(this._dedup[o]=!0,n.push(` export const ${o} = new marshaller.WU()
4
4
  .url("${r.url}")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hpcc-js/marshaller",
3
- "version": "3.3.0",
3
+ "version": "3.3.1",
4
4
  "description": "hpcc-js - Viz Marshaller",
5
5
  "type": "module",
6
6
  "main": "./dist/index.umd.cjs",
@@ -21,7 +21,7 @@
21
21
  "types/*"
22
22
  ],
23
23
  "scripts": {
24
- "clean": "rimraf --glob lib* types dist *.tsbuildinfo .turbo",
24
+ "clean": "rimraf --glob lib* types types-3.4 dist *.tsbuildinfo .turbo",
25
25
  "bundle": "vite build",
26
26
  "bundle-watch": "vite build --watch",
27
27
  "bundle-serve": "vite --port 5520",
@@ -39,23 +39,23 @@
39
39
  "update-major": "npx --yes npm-check-updates -u"
40
40
  },
41
41
  "dependencies": {
42
- "@hpcc-js/chart": "^3.8.0",
43
- "@hpcc-js/codemirror": "^3.8.0",
44
- "@hpcc-js/common": "^3.8.0",
45
- "@hpcc-js/comms": "^3.17.0",
46
- "@hpcc-js/composite": "^3.6.0",
47
- "@hpcc-js/ddl-shim": "^3.4.0",
48
- "@hpcc-js/dgrid": "^3.9.0",
49
- "@hpcc-js/form": "^3.5.0",
50
- "@hpcc-js/graph": "^3.8.0",
51
- "@hpcc-js/layout": "^3.6.0",
52
- "@hpcc-js/map": "^3.6.0",
53
- "@hpcc-js/other": "^3.6.0",
54
- "@hpcc-js/phosphor": "^3.7.0",
55
- "@hpcc-js/util": "^3.6.0"
42
+ "@hpcc-js/chart": "^3.8.1",
43
+ "@hpcc-js/codemirror": "^3.8.1",
44
+ "@hpcc-js/common": "^3.8.1",
45
+ "@hpcc-js/comms": "^3.17.1",
46
+ "@hpcc-js/composite": "^3.6.1",
47
+ "@hpcc-js/ddl-shim": "^3.4.1",
48
+ "@hpcc-js/dgrid": "^3.9.1",
49
+ "@hpcc-js/form": "^3.5.1",
50
+ "@hpcc-js/graph": "^3.8.1",
51
+ "@hpcc-js/layout": "^3.6.1",
52
+ "@hpcc-js/map": "^3.6.1",
53
+ "@hpcc-js/other": "^3.6.1",
54
+ "@hpcc-js/phosphor": "^3.7.1",
55
+ "@hpcc-js/util": "^3.6.1"
56
56
  },
57
57
  "devDependencies": {
58
- "@hpcc-js/esbuild-plugins": "^1.9.0",
58
+ "@hpcc-js/esbuild-plugins": "^1.9.1",
59
59
  "d3-array": "^1",
60
60
  "d3-collection": "^1",
61
61
  "d3-dsv": "^1",
@@ -73,5 +73,5 @@
73
73
  "url": "https://github.com/hpcc-systems/Visualization/issues"
74
74
  },
75
75
  "homepage": "https://github.com/hpcc-systems/Visualization",
76
- "gitHead": "b762adfab7d03d06ea8cfab59059456100ea757c"
76
+ "gitHead": "0cfcae9b4ccbd0b3c9f21381f4581bf121392585"
77
77
  }