@platforma-sdk/model 1.24.0 → 1.24.9

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.
@@ -2,6 +2,10 @@ import { AxisSpec, JoinEntry, PColumn, PColumnIdAndSpec, PColumnSpec, PColumnVal
2
2
  import { RenderCtx, TreeNodeAccessor } from '../render';
3
3
  /** Data table state */
4
4
  export type PlDataTableGridState = {
5
+ /**
6
+ * Hash of the specs for now, but in the future it will be a stable id of the source
7
+ */
8
+ sourceId?: string;
5
9
  /** Includes column ordering */
6
10
  columnOrder?: {
7
11
  /** All colIds in order */
@@ -25,6 +29,8 @@ export type PlDataTableGridState = {
25
29
  /** current sheet selections */
26
30
  sheets?: Record<string, string | number>;
27
31
  };
32
+ /** TODO: refactor to use sheets in the grid state */
33
+ export type PlDataTableGridStateWithoutSheets = Omit<PlDataTableGridState, 'sheets'>;
28
34
  export type PlDataTableSheet = {
29
35
  /** spec of the axis to use */
30
36
  axis: AxisSpec;
@@ -1 +1 @@
1
- {"version":3,"file":"PlDataTable.d.ts","sourceRoot":"","sources":["../../src/components/PlDataTable.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAGR,SAAS,EAET,OAAO,EACP,gBAAgB,EAChB,WAAW,EACX,aAAa,EAEb,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACd,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAExD,uBAAuB;AACvB,MAAM,MAAM,oBAAoB,GAAG;IACjC,+BAA+B;IAC/B,WAAW,CAAC,EAAE;QACZ,0BAA0B;QAC1B,aAAa,EAAE,MAAM,EAAE,CAAC;KACzB,CAAC;IACF,kDAAkD;IAClD,IAAI,CAAC,EAAE;QACL,6CAA6C;QAC7C,SAAS,EAAE;YACT,sCAAsC;YACtC,KAAK,EAAE,MAAM,CAAC;YACd,qBAAqB;YACrB,IAAI,EAAE,KAAK,GAA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AoE;AACpE,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,CAAC,EACpC,GAAG,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EACpB,OAAO,EAAE,OAAO,CAAC,gBAAgB,GAAG,aAAa,CAAC,EAAE,EACpD,UAAU,EAAE,gBAAgB,GAAG,SAAS,EACxC,OAAO,EAAE,kBAAkB,EAAE,GAC5B,YAAY,GAAG,SAAS,CAAC;AA6F5B,2CAA2C;AAC3C,wBAAgB,sBAAsB,CAAC,CAAC,EAAE,CAAC,EACzC,GAAG,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EACpB,IAAI,EAAE,QAAQ,EACd,MAAM,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,GAC1B,gBAAgB,CAUlB"}
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var Ce=Object.defineProperty;var we=(t,e,n)=>e in t?Ce(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var w=(t,e,n)=>we(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@milaboratories/pl-model-common"),O=require("zod");class re extends Error{constructor(e,n){super(`${e.length}${n?"+":""} errors, first error: `+e[0]),this.errors=e,this.moreErrors=n}}function ie(t){if(!t.ok)throw new re(t.errors,t.moreErrors);return t.value}function Re(t){return new Proxy(t,{get(e,n){return ie(e[n])}})}function b(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"||t===null?D(t):t}function x(t){return{type:"GetFromCtx",variable:t}}function Te(t){return{type:"Isolate",cfg:t}}const Oe=x("$args"),xe=x("$it"),Fe=x("$prod"),Le=x("$staging"),De=x("$ui");function D(t){return{type:"Immediate",value:t}}function Z(t){const e={};for(const[n,s]of Object.entries(t))e[n]=b(s);return{type:"MakeObject",template:e}}function Ee(...t){const e=[];for(const n of t)e.push(b(n));return{type:"MakeArray",template:e}}function k(t,e){return{type:"GetJsonField",source:b(t),field:b(e)}}function ke(t,e,n="$it"){return{type:"MapRecordValues",source:t,mapping:e,itVar:n}}function Ve(t,e,n="$it"){return{type:"MapArrayValues",source:t,mapping:e,itVar:n}}function je(t){return{type:"Flatten",source:t}}function Ne(t){return{type:"IsEmpty",arg:t}}function Ue(t){return{type:"Not",operand:t}}function Be(t,e){return{type:"And",operand1:t,operand2:e}}function Me(t,e){return{type:"Or",operand1:t,operand2:e}}function Je(t,e){return{type:"GetResourceField",source:b(t),field:b(e)}}function $e(){return function(t){return{type:"GetResourceValueAsJson",source:b(t)}}}function Ge(t,e,n="$it"){return{type:"MapResourceFields",source:t,mapping:e,itVar:n}}function We(t){return{type:"GetBlobContent",source:b(t)}}function Ke(t){return{type:"GetBlobContentAsString",source:b(t)}}function He(){return function(t){return{type:"GetBlobContentAsJson",source:b(t)}}}function ze(t){return{type:"GetDownloadedBlobContent",source:b(t)}}function qe(t){return{type:"GetOnDemandBlobContent",source:b(t)}}function Ye(t,e){return{type:"ExtractArchiveAndGetURL",format:e,source:b(t)}}function Xe(t){return{type:"GetImportProgress",source:b(t)}}function Qe(t,e){return{type:"GetLastLogs",source:b(t),lines:e}}function Ze(t,e){return{type:"GetProgressLog",source:b(t),patternToSearch:e}}function et(t,e){return{type:"GetProgressLogWithInfo",source:b(t),patternToSearch:e}}function tt(t){return{type:"GetLogHandle",source:b(t)}}function nt(){return typeof globalThis.getPlatforma<"u"||typeof globalThis.platforma<"u"}function oe(t){if(t&&typeof globalThis.getPlatforma=="function")return globalThis.getPlatforma(t);if(typeof globalThis.platforma<"u")return globalThis.platforma;throw new Error("Can't get platforma instance.")}function st(){if(typeof globalThis.cfgRenderCtx<"u")return globalThis.cfgRenderCtx}function h(){if(typeof globalThis.cfgRenderCtx<"u")return globalThis.cfgRenderCtx;throw new Error("Not in config rendering context")}function j(t,e){const n=st();if(n===void 0)return!1;if(t in n.callbackRegistry)throw new Error(`Callback with key ${t} already registered.`);return n.callbackRegistry[t]=e,!0}const K=new Map;function rt(t,e){t in h().callbackRegistry||(h().callbackRegistry[t]=n=>{for(const s of K.get(t))s(n)},K.set(t,[])),K.get(t).push(e)}class A{constructor(e,n=s=>s){w(this,"isResolved",!1);w(this,"resolvedValue");this.handle=e,this.postProcess=n,rt(e,s=>{this.resolvedValue=n(s),this.isResolved=!0})}map(e){return new A(this.handle,n=>e(this.postProcess(n)))}mapDefined(e){return new A(this.handle,n=>{const s=this.postProcess(n);return s?e(s):void 0})}toJSON(){return this.isResolved?this.resolvedValue:{__awaited_futures__:[this.handle]}}}function M(t,e){return t===void 0?void 0:e(t)}class I{constructor(e,n){this.handle=e,this.resolvePath=n}resolve(...e){const n=e.map(s=>({assertFieldType:"Input",...typeof s=="string"?{field:s}:s}));return this.resolveWithCommon({},...n)}resolveOutput(...e){const n=e.map(s=>({assertFieldType:"Output",...typeof s=="string"?{field:s}:s}));return this.resolveWithCommon({},...n)}resolveInput(...e){const n=e.map(s=>({assertFieldType:"Input",...typeof s=="string"?{field:s}:s}));return this.resolveWithCommon({},...n)}resolveAny(...e){return this.resolveWithCommon({},...e)}resolveWithCommon(e,...n){const s=[...this.resolvePath,...n.map(r=>typeof r=="string"?r:r.field)];return M(h().resolveWithCommon(this.handle,e,...n),r=>new I(r,s))}get resourceType(){return h().getResourceType(this.handle)}getInputsLocked(){return h().getInputsLocked(this.handle)}getOutputsLocked(){return h().getOutputsLocked(this.handle)}getIsReadyOrError(){return h().getIsReadyOrError(this.handle)}getIsFinal(){return h().getIsFinal(this.handle)}getError(){const e=[...this.resolvePath,"error"];return M(h().getError(this.handle),n=>new I(n,e))}listInputFields(){return h().listInputFields(this.handle)}listOutputFields(){return h().listOutputFields(this.handle)}listDynamicFields(){return h().listDynamicFields(this.handle)}getKeyValueBase64(e){return h().getKeyValueBase64(this.handle,e)}getKeyValueAsString(e){return h().getKeyValueAsString(this.handle,e)}getKeyValueAsJson(e){const n=this.getKeyValueAsString(e);if(n==null)throw new Error("Resource has no content.");return JSON.parse(n)}getDataBase64(){return h().getDataBase64(this.handle)}getDataAsString(){return h().getDataAsString(this.handle)}getDataAsJson(){const e=this.getDataAsString();if(e==null)throw new Error("Resource has no content.");return JSON.parse(e)}getPColumns(e=!1,n=""){const s=this.parsePObjectCollection(e,n);return s===void 0?void 0:Object.entries(s).map(([,i])=>{if(!u.isPColumn(i))throw new Error(`not a PColumn (kind = ${i.spec.kind})`);return i})}parsePObjectCollection(e=!1,n=""){const s=h().parsePObjectCollection(this.handle,e,n,...this.resolvePath);if(s===void 0)return;const r={};for(const[i,o]of Object.entries(s)){const l=[...this.resolvePath,i];r[i]=u.mapPObjectData(o,a=>new I(a,l))}return r}getFileContentAsBase64(){return new A(h().getBlobContentAsBase64(this.handle))}getFileContentAsString(){return new A(h().getBlobContentAsString(this.handle))}getFileContentAsJson(){return new A(h().getBlobContentAsString(this.handle)).mapDefined(e=>JSON.parse(e))}getBlobContentAsBase64(){return this.getFileContentAsBase64()}getBlobContentAsString(){return this.getFileContentAsString()}getFileHandle(){return new A(h().getDownloadedBlobContentHandle(this.handle))}getDownloadedBlobHandle(){return this.getFileHandle()}getRemoteFileHandle(){return new A(h().getOnDemandBlobContentHandle(this.handle))}getOnDemandBlobHandle(){return this.getRemoteFileHandle()}extractArchiveAndGetURL(e){return new A(h().extractArchiveAndGetURL(this.handle,e))}getImportProgress(){return new A(h().getImportProgress(this.handle))}getLastLogs(e){return new A(h().getLastLogs(this.handle,e))}getProgressLog(e){return new A(h().getProgressLog(this.handle,e))}getProgressLogWithInfo(e){return new A(h().getProgressLogWithInfo(this.handle,e))}getLogHandle(){return new A(h().getLogHandle(this.handle))}allFieldsResolved(e="Input"){switch(e){case"Input":return this.getInputsLocked()&&this.listInputFields().every(n=>this.resolve({field:n,assertFieldType:"Input"})!==void 0);case"Output":return this.getOutputsLocked()&&this.listOutputFields().every(n=>this.resolve({field:n,assertFieldType:"Output"})!==void 0)}}mapFields(e,n){const{fieldType:s,requireLocked:r,skipUnresolved:i}={fieldType:"Input",requireLocked:!0,skipUnresolved:!1,...n},o=e;if(r&&(s==="Input"&&!this.getInputsLocked()||s==="Output"&&!this.getOutputsLocked()))return;let a=(s==="Input"?this.listInputFields():s==="Output"?this.listOutputFields():this.listDynamicFields()).map(c=>[c,this.resolve({field:c,assertFieldType:s})]);return i&&(a=a.filter(c=>c[1]!==void 0)),a.map(([c,m])=>o(c,m))}}const ae="staging",le="main",it={inlineColumnsSupport:!0,activeArgs:!0};function ue(t){return typeof t=="object"&&t!==null&&"__awaited_futures__"in t}function H(t,e,n){if(e.has(n))return;if(e.add(n),typeof n==="object")if(ue(n))n.__awaited_futures__.forEach(r=>t.add(r));else if(Array.isArray(n))for(const r of n)H(t,e,r);else for(const[,r]of Object.entries(n))r!==n&&H(t,e,r)}function ot(t){const e=new Set;return H(e,new Set,t),e}const at=Object.freeze(Object.defineProperty({__proto__:null,GlobalCfgRenderCtxFeatureFlags:it,MainAccessorName:le,StagingAccessorName:ae,getAllFutureAwaits:ot,isFutureAwait:ue},Symbol.toStringTag,{value:"Module"})),ce="pl7.app/label",de="pl7.app/trace",pe=O.z.object({type:O.z.string(),importance:O.z.number().optional(),id:O.z.string().optional(),label:O.z.string()}),fe=O.z.array(pe),lt=.001,ut="__LABEL__",te="__LABEL__@1";function z(t,e,n={}){const s=new Map,r=new Map,i=t.map(p=>{var P,ee;const g=e(p),f=(P=g.annotations)==null?void 0:P[ce],v=(ee=g.annotations)==null?void 0:ee[de],y=(v?fe.safeParse(JSON.parse(v)).data:void 0)??[];if(f){const R={label:f,type:ut,importance:-2};n.addLabelAsSuffix?y.push(R):y.splice(0,0,R)}const C=[],_=new Map;for(let R=y.length-1;R>=0;--R){const{type:G}=y[R],Se=y[R].importance??0,W=(_.get(G)??0)+1;_.set(G,W);const F=`${G}@${W}`;r.set(F,(r.get(F)??0)+1),s.set(F,Math.max(s.get(F)??Number.NEGATIVE_INFINITY,Se-(y.length-R)*lt)),C.push({...y[R],fullType:F,occurenceIndex:W})}return C.reverse(),{value:p,spec:g,label:f,fullTrace:C}}),o=[],l=[],a=[...s];a.sort(([,p],[,g])=>g-p);for(const[p]of a)p.endsWith("@1")||r.get(p)===t.length?o.push(p):l.push(p);const c=p=>i.map(g=>{const f=g.fullTrace.filter(y=>p.has(y.fullType)).map(y=>y.label),v=n.separator??" / ";return{label:f.join(v),value:g.value}});if(o.length===0){if(l.length!==0)throw new Error("Assertion error.");return c(new Set(te))}let m=0,d=0;for(;m<o.length;){const p=new Set;n.includeNativeLabel&&p.add(te);for(let f=0;f<m;++f)p.add(o[f]);p.add(o[d]);const g=c(p);if(new Set(g.map(f=>f.label)).size===t.length)return g;d++,d==o.length&&(m++,d=m)}return c(new Set([...o,...l]))}class he{constructor(){w(this,"ctx",h());w(this,"defaultLabelFn",(e,n)=>{var s;return((s=e.annotations)==null?void 0:s["pl7.app/label"])??"Unlabelled"})}calculateOptions(e){return this.ctx.calculateOptions(e)}getOptions(e,n){const s=typeof e=="function"?e:u.selectorsToPredicate(e),r=this.getSpecs().entries.filter(i=>s(i.obj));return typeof n=="object"||typeof n>"u"?z(r,i=>i.obj,n??{}).map(({value:{ref:i},label:o})=>({ref:i,label:o})):r.map(i=>({ref:i.ref,label:n(i.obj,i.ref)}))}getCanonicalOptions(e,n,s){const r={};if(!(e instanceof u.AnchorIdDeriver))for(const[a,c]of Object.entries(e))if(u.isPlRef(c)){const m=this.getPColumnSpecByRef(c);if(!m)return;r[a]=m}else r[a]=c;const i=typeof n=="function"?n:u.selectorsToPredicate(Array.isArray(n)?n.map(a=>u.resolveAnchors(r,a)):u.resolveAnchors(r,n)),o=this.getSpecs().entries.filter(({obj:a})=>u.isPColumnSpec(a)?i(a):!1),l=e instanceof u.AnchorIdDeriver?e:new u.AnchorIdDeriver(r);return z(o,a=>a.obj,s??{}).map(({value:{obj:a},label:c})=>({value:l.deriveCanonical(a),label:c}))}getDataFromResultPool(){return this.getData()}getData(){const e=this.ctx.getDataFromResultPool();return{isComplete:e.isComplete,entries:e.entries.map(n=>({ref:n.ref,obj:{...n.obj,data:new I(n.obj.data,[n.ref.blockId,n.ref.name])}}))}}getDataWithErrorsFromResultPool(){return this.getDataWithErrors()}getDataWithErrors(){const e=this.ctx.getDataWithErrorsFromResultPool();return{isComplete:e.isComplete,entries:e.entries.map(n=>({ref:n.ref,obj:{...n.obj,data:u.mapValueInVOE(n.obj.data,s=>new I(s,[n.ref.blockId,n.ref.name]))}}))}}getSpecsFromResultPool(){return this.getSpecs()}getSpecs(){return this.ctx.getSpecsFromResultPool()}getDataByRef(e){var n;return typeof this.ctx.getDataFromResultPoolByRef>"u"?(n=this.getData().entries.find(s=>s.ref.blockId===e.blockId&&s.ref.name===e.name))==null?void 0:n.obj:u.mapPObjectData(this.ctx.getDataFromResultPoolByRef(e.blockId,e.name),s=>new I(s,[e.blockId,e.name]))}getPColumnByRef(e){const n=this.getDataByRef(e);if(n)return u.ensurePColumn(n)}getPColumnSpecByRef(e){const n=this.getSpecByRef(e);if(n){if(!u.isPColumnSpec(n))throw new Error(`not a PColumn spec (kind = ${n.kind})`);return n}}getSpecByRef(e){return this.ctx.getSpecFromResultPoolByRef(e.blockId,e.name)}findDataWithCompatibleSpec(e){const n=[];e:for(const s of this.getData().entries){if(!u.isPColumnSpec(s.obj.spec))continue;const r=s.obj.spec;if(e.name===r.name&&e.valueType===r.valueType&&e.axesSpec.length===r.axesSpec.length&&q(e.domain,r.domain)){for(let i=0;i<e.axesSpec.length;++i){const o=e.axesSpec[i],l=r.axesSpec[i];if(o.name!==l.name||o.type!==l.type||!q(o.domain,l.domain))continue e}n.push(s.obj)}}return n}}function q(t,e){if(t===void 0)return e===void 0;if(e===void 0)return!0;for(const n in e)if(t[n]!==e[n])return!1;return!0}class L{constructor(){w(this,"ctx");w(this,"args");w(this,"uiState");w(this,"_activeArgsCache");w(this,"resultPool",new he);this.ctx=h(),this.args=JSON.parse(this.ctx.args),this.uiState=this.ctx.uiState!==void 0?JSON.parse(this.ctx.uiState):{}}get activeArgs(){return this._activeArgsCache===void 0&&(this._activeArgsCache={v:this.ctx.activeArgs?JSON.parse(this.ctx.activeArgs):void 0}),this._activeArgsCache.v}getNamedAccessor(e){return M(this.ctx.getAccessorHandleByName(e),n=>new I(n,[e]))}get prerun(){return this.getNamedAccessor(ae)}get outputs(){return this.getNamedAccessor(le)}findLabels(e){const n=this.resultPool.getData();for(const s of n.entries){if(!u.isPColumn(s.obj))continue;const r=s.obj.spec;if(r.name==="pl7.app/label"&&r.axesSpec.length===1&&r.axesSpec[0].name===e.name&&r.axesSpec[0].type===e.type&&q(e.domain,r.axesSpec[0].domain)){if(s.obj.data.resourceType.name!=="PColumnData/Json")throw Error(`Expected JSON column for labels, got: ${s.obj.data.resourceType.name}`);return Object.fromEntries(Object.entries(s.obj.data.getDataAsJson().data).map(o=>[JSON.parse(o[0])[0],o[1]]))}}}verifyInlineColumnsSupport(e){var r;const n=e.some(i=>!(i.data instanceof I)),s=((r=this.ctx.featureFlags)==null?void 0:r.inlineColumnsSupport)===!0;if(n&&!s)throw Error("inline columns not supported")}createPFrame(e){return this.verifyInlineColumnsSupport(e),this.ctx.createPFrame(e.map(n=>u.mapPObjectData(n,s=>s instanceof I?s.handle:s)))}createPTable(e){let n;return"columns"in e?n={src:{type:"full",entries:e.columns.map(s=>({type:"column",column:s}))},filters:e.filters??[],sorting:e.sorting??[]}:n=e,this.verifyInlineColumnsSupport(u.extractAllColumns(n.src)),this.ctx.createPTable(u.mapPTableDef(n,s=>u.mapPObjectData(s,r=>r instanceof I?r.handle:r)))}getBlockLabel(e){return this.ctx.getBlockLabel(e)}getCurrentUnstableMarker(){if(!(typeof this.ctx.getCurrentUnstableMarker>"u"))return this.ctx.getCurrentUnstableMarker()}}const V="PColumnData/",J=V+"ResourceMap",$=V+"Partitioned/ResourceMap",Y=V+"JsonPartitioned",N=V+"BinaryPartitioned",ge=V+"Partitioned/",X=ge+"JsonPartitioned",U=ge+"BinaryPartitioned";function me(t,e,n,s=[],r){if(t===void 0)return!1;switch(t.resourceType.name){case J:{let i=t.getInputsLocked();for(const o of t.listInputFields()){const l=t.resolve({field:o,assertFieldType:"Input"}),a=[...s,...JSON.parse(o)],c=l===void 0?void 0:e(l);c===void 0&&(i=!1),(c!==void 0||r)&&n.push({key:a,value:c})}return i}case $:{let i=t.getInputsLocked();for(const o of t.listInputFields()){const l=t.resolve({field:o,assertFieldType:"Input"});if(l===void 0)i=!1;else{const a=[...s,...JSON.parse(o)],c=me(l,e,n,a,r);i=i&&c}}return i}default:throw new Error(`Unknown resource type: ${t.resourceType.name}`)}}function ct(t,e,n=!1){const s=[];return{isComplete:me(t,e,s,[],n),data:s}}const ne=t=>{if(!t.endsWith(".index")){if(t.endsWith(".values"))return t.substring(0,t.length-7);throw Error(`key must ends on .index/.values for binary p-column, got: ${t}`)}};function ye(t){if(!t)return;const e=t.resourceType.name,n=t.getDataAsJson(),s=[];let r=0;switch(e){case J:r=n.keyLength;break;case $:r=n.partitionKeyLength+n.keyLength;break;case Y:case N:r=n.partitionKeyLength;break;case U:case X:r=n.superPartitionKeyLength+n.partitionKeyLength;break}switch(e){case J:case Y:case N:for(let i of t.listInputFields()){if(e===N){const l=ne(i);if(l)i=l;else continue}const o=[...JSON.parse(i)];s.push(o)}break;case $:case U:case X:for(const i of t.listInputFields()){const o=[...JSON.parse(i)],l=t.resolve({field:i,assertFieldType:"Input"});if(l!==void 0)for(let a of l.listInputFields()){if(e===U){const m=ne(a);if(m)a=m;else continue}const c=[...o,...JSON.parse(a)];s.push(c)}}break}return{data:s,keyLength:r}}function dt(t){const e=ye(t);if(!e)return;const{data:n,keyLength:s}=e,r=[];for(let i=0;i<s;++i)r.push(new Set);for(const i of n){if(i.length!==s)throw new Error("key length does not match partition length");for(let o=0;o<s;++o)r[o].add(i[o])}return r.map(i=>Array.from(i.values()))}const E="1.24.0";function be(t){return t.__renderLambda===!0}function B(t){if(t!==void 0)return be(t)?t.handle:t}function T(t){if(t!==void 0)return typeof t=="string"?{__renderLambda:!0,handle:t,retentive:!1}:t}function pt(t){if(t.v3!==void 0){const{initialArgs:e,initialUiState:n,inputsValid:s,outputs:r,renderingMode:i,sdkVersion:o,sections:l,title:a}=t.v3,{code:c}=t;return{initialArgs:e,initialUiState:n,inputsValid:s,outputs:r,renderingMode:i,sdkVersion:o,sections:l,title:a,code:c}}else if(t.inputsValid!==void 0){const{sdkVersion:e,renderingMode:n,outputs:s,inputsValid:r,sections:i,initialArgs:o,code:l}=t,a=Object.keys(t);if(e===void 0||n===void 0||s===void 0||r===void 0||i===void 0||o===void 0)throw new Error(`Malformed config v2. SDK version ${e}; Fields = ${a.join(", ")}`);return{sdkVersion:e,renderingMode:n,initialArgs:o,outputs:Object.fromEntries(Object.entries(s).map(([c,m])=>[c,T(m)])),inputsValid:T(r),sections:T(i),initialUiState:void 0,code:l}}else if(t.renderingMode!==void 0){const{sdkVersion:e,canRun:n,renderingMode:s,outputs:r,sections:i,initialArgs:o,code:l}=t,a=Object.keys(t);if(s===void 0||r===void 0||n===void 0||i===void 0||o===void 0)throw new Error(`Malformed config v1. SDK version ${e}; Fields = ${a.join(", ")}`);return{sdkVersion:e??"unknown",renderingMode:s,initialArgs:o,outputs:Object.fromEntries(Object.entries(r).map(([c,m])=>[c,T(m)])),inputsValid:T(n),sections:T(i),initialUiState:void 0,code:l}}else{const{sdkVersion:e}=t,n=Object.keys(t);throw new Error(`Config format not supported: SDK = ${e}; Fields = ${n.join(", ")}`)}}class S{constructor(e,n,s,r,i,o,l){this._renderingMode=e,this._initialArgs=n,this._initialUiState=s,this._outputs=r,this._inputsValid=i,this._sections=o,this._title=l}static create(e="Heavy"){return new S(e,void 0,{},{},D(!0),D([]),void 0)}output(e,n,s={}){if(typeof n=="function"){const r=`output#${e}`;return j(r,()=>n(new L)),new S(this._renderingMode,this._initialArgs,this._initialUiState,{...this._outputs,[e]:{__renderLambda:!0,handle:r,...s}},this._inputsValid,this._sections,this._title)}else return new S(this._renderingMode,this._initialArgs,this._initialUiState,{...this._outputs,[e]:n},this._inputsValid,this._sections,this._title)}retentiveOutput(e,n){return this.output(e,n,{retentive:!0})}argsValid(e){return typeof e=="function"?(j("inputsValid",()=>e(new L)),new S(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,{__renderLambda:!0,handle:"inputsValid"},this._sections,this._title)):new S(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,e,this._sections,this._title)}sections(e){return Array.isArray(e)?this.sections(D(e)):typeof e=="function"?(j("sections",()=>e(new L)),new S(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,this._inputsValid,{__renderLambda:!0,handle:"sections"},this._title)):new S(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,this._inputsValid,e,this._title)}title(e){return j("title",()=>e(new L)),new S(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,this._inputsValid,this._sections,{__renderLambda:!0,handle:"title"})}initialArgs(e){return new S(this._renderingMode,e,this._initialUiState,this._outputs,this._inputsValid,this._sections,this._title)}withArgs(e){return new S(this._renderingMode,e,this._initialUiState,this._outputs,this._inputsValid,this._sections,this._title)}withUiState(e){return new S(this._renderingMode,this._initialArgs,e,this._outputs,this._inputsValid,this._sections,this._title)}done(){if(this._initialArgs===void 0)throw new Error("Initial arguments not set.");const e={v3:{sdkVersion:E,renderingMode:this._renderingMode,initialArgs:this._initialArgs,initialUiState:this._initialUiState,inputsValid:this._inputsValid,sections:this._sections,title:this._title,outputs:this._outputs},sdkVersion:E,renderingMode:this._renderingMode,initialArgs:this._initialArgs,inputsValid:B(this._inputsValid),sections:B(this._sections),outputs:Object.fromEntries(Object.entries(this._outputs).map(([n,s])=>[n,B(s)]))};return nt()?oe({sdkVersion:E}):{config:e}}}function ft(t,e,n,s){var c,m;Array.isArray(s)&&(s={filters:s});const r=t.resultPool.getData().entries.map(d=>d.obj).filter(u.isPColumn).filter(d=>d.spec.name==="pl7.app/label"&&d.spec.axesSpec.length===1),i=(d,p)=>{let g=d.toString();if(p)for(const f in p)g+=f,g+=p[f];return g},o=new Map;for(const d of e)for(const p of d.spec.axesSpec){const g=u.getAxisId(p);for(const f of r){const v=f.spec.axesSpec[0],y=u.getAxisId(f.spec.axesSpec[0]);if(u.matchAxisId(g,y)){const C=Object.keys(g.domain??{}).length,_=Object.keys(y.domain??{}).length;if(C>_){const P=i(f.id,g.domain);o.set(P,{id:P,spec:{...f.spec,axesSpec:[{...g,annotations:v.annotations}]},data:f.data})}else o.set(i(f.id),f)}}}if([...e,...o.values()].some(d=>d.data instanceof I&&!d.data.getIsReadyOrError()))return;let l=e;const a=[];if(s!=null&&s.coreColumnPredicate){l=[];for(const d of e)s.coreColumnPredicate(d.spec)?l.push(d):a.push(d)}return a.push(...o.values()),t.createPTable({src:{type:"outer",primary:{type:(s==null?void 0:s.coreJoinType)??"full",entries:l.map(d=>({type:"column",column:d}))},secondary:a.map(d=>({type:"column",column:d}))},filters:[...(s==null?void 0:s.filters)??[],...((c=n==null?void 0:n.pTableParams)==null?void 0:c.filters)??[]],sorting:((m=n==null?void 0:n.pTableParams)==null?void 0:m.sorting)??[]})}function ht(t,e,n){const s=t.findLabels(e);return{axis:e,options:n.map(r=>({value:r,label:(s==null?void 0:s[r])??r.toString()})),defaultValue:n[0]}}const gt=(t,e)=>{let n=t.toString();return e==null||e.forEach(s=>{if(s)for(const[r,i]of Object.entries(s))n+=r,n+=i}),n};function mt(t){if(!t.length)return[];let e=[[]];return t.forEach(n=>{const s=[];n.forEach(r=>{s.push(...e.map(i=>[...i,r]))}),e=s}),e}function yt(t,e){const n=t.spec.axesSpec.map(u.getAxisId);return e.spec.axesSpec.map(u.getAxisId).every(r=>n.some(i=>u.matchAxisId(i,r)&&u.matchAxisId(r,i)))}function ve(t,e){const n=t.spec.axesSpec.map(u.getAxisId);return e.spec.axesSpec.map(u.getAxisId).every(r=>n.some(i=>u.matchAxisId(i,r)))}const Ae="pl7.app/graph/isVirtual",Q="pl7.app/label";function se(t,e){const n=t.spec.axesSpec.map(u.getAxisId),s=e.spec.axesSpec.map(u.getAxisId);if(yt(t,e))return[];if(!ve(t,e))return[];const o=s.map(d=>n.filter(p=>u.matchAxisId(p,d))),l=mt(o),a=new Set,c=new Set,m=l.map(d=>{const p=new Set;return d.map((g,f)=>{const v=e.spec.axesSpec[f].domain,y=g.domain;return Object.entries(y??{}).forEach(([C,_])=>{if((v==null?void 0:v[C])===void 0){const P=JSON.stringify([C,_]);p.add(P),a.add(P)}}),{...g,annotations:e.spec.axesSpec[f].annotations}}),p});return[...a].forEach(d=>{m.some(p=>!p.has(d))&&c.add(d)}),l.map((d,p)=>{var C;const g=gt(e.id,d.map(_=>_.domain)),f=((C=e.spec.annotations)==null?void 0:C[Q])??"",v=[...m[p]].filter(_=>c.has(_)).sort().map(_=>{var P;return(P=JSON.parse(_))==null?void 0:P[1]}).join(" / "),y={...e.spec.annotations,[Ae]:"true"};return(f||v)&&(y[Q]=f&&v?f+" / "+v:f+v),{id:g,spec:{...e.spec,axesSpec:d.map((_,P)=>({..._,annotations:e.spec.axesSpec[P].annotations})),annotations:y},data:e.data}})}function _e(t){const e=[];for(let n=0;n<t.length;n++)for(let s=n+1;s<t.length;s++){const r=t[n],i=t[s];e.push(...se(r,i),...se(i,r))}return e}function Ie(t,e){const n=[...t];for(const s of e)for(const r of t){if(r.id===s.id)break;if(ve(r,s)){n.push(s);break}}return n}const bt=["Int","Long","Float","Double","String","Bytes"];function vt(t,e){if(e===void 0)return;const n=t.resultPool.getData().entries.map(i=>i.obj).filter(u.isPColumn).filter(i=>bt.includes(i.spec.valueType)),s=Ie(e,n),r=[...s,..._e(s)];if(!r.some(i=>i.data instanceof I&&!i.data.getIsReadyOrError()))return t.createPFrame(r)}class At{constructor(e){this.handle=e}async findColumns(e){return await platforma.pFrameDriver.findColumns(this.handle,e)}async getColumnSpec(e){return await platforma.pFrameDriver.getColumnSpec(this.handle,e)}async listColumns(){return await platforma.pFrameDriver.listColumns(this.handle)}async calculateTableData(e){return await platforma.pFrameDriver.calculateTableData(this.handle,e)}async getUniqueValues(e){return await platforma.pFrameDriver.getUniqueValues(this.handle,e)}}function Pe(t){return Z({__isRef:!0,blockId:k(t,"blockId"),name:k(t,"name")})}function _t(t){return Z({ref:Pe(k(t,"ref")),label:k(t,"label")})}const It={sdkVersion:E};function Pt(){return oe({sdkVersion:E})}function St(t){if(typeof globalThis.getEnvironmentValue=="function")return globalThis.getEnvironmentValue(t)}exports.Args=Oe;exports.BlockModel=S;exports.CurrentSdkInfo=It;exports.FutureRef=A;exports.IS_VIRTUAL_COLUMN=Ae;exports.It=xe;exports.JsRenderInternal=at;exports.LABEL_ANNOTATION=Q;exports.MainOutputs=Fe;exports.OutputError=re;exports.PAnnotationLabel=ce;exports.PAnnotationTrace=de;exports.PFrameImpl=At;exports.RT_BINARY_PARTITIONED=N;exports.RT_BINARY_SUPER_PARTITIONED=U;exports.RT_JSON_PARTITIONED=Y;exports.RT_JSON_SUPER_PARTITIONED=X;exports.RT_RESOURCE_MAP=J;exports.RT_RESOURCE_MAP_PARTITIONED=$;exports.RenderCtx=L;exports.ResultPool=he;exports.StagingOutputs=Le;exports.Trace=fe;exports.TraceEntry=pe;exports.TreeNodeAccessor=I;exports.UiState=De;exports.and=Be;exports.createPFrameForGraphs=vt;exports.createPlDataTable=ft;exports.createPlDataTableSheet=ht;exports.deriveLabels=z;exports.downgradeCfgOrLambda=B;exports.enrichColumnsWithCompatible=Ie;exports.extractArchiveAndGetURL=Ye;exports.extractConfig=pt;exports.flatten=je;exports.fromPlOption=_t;exports.fromPlRef=Pe;exports.getAdditionalColumns=_e;exports.getBlobContent=We;exports.getBlobContentAsJson=He;exports.getBlobContentAsString=Ke;exports.getDownloadedBlobContent=ze;exports.getEnvironmentValue=St;exports.getFromCfg=x;exports.getImmediate=D;exports.getImportProgress=Xe;exports.getJsonField=k;exports.getLastLogs=Qe;exports.getLogHandle=tt;exports.getOnDemandBlobContent=qe;exports.getPartitionKeysList=ye;exports.getProgressLog=Ze;exports.getProgressLogWithInfo=et;exports.getRawPlatformaInstance=Pt;exports.getResourceField=Je;exports.getResourceValueAsJson=$e;exports.getUniquePartitionKeys=dt;exports.ifDef=M;exports.isConfigLambda=be;exports.isEmpty=Ne;exports.isolate=Te;exports.makeArray=Ee;exports.makeObject=Z;exports.mapArrayValues=Ve;exports.mapRecordValues=ke;exports.mapResourceFields=Ge;exports.not=Ue;exports.or=Me;exports.parseResourceMap=ct;exports.readOutput=ie;exports.wrapOutputs=Re;Object.keys(u).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>u[t]})});
1
+ "use strict";var Ce=Object.defineProperty;var we=(t,e,n)=>e in t?Ce(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var w=(t,e,n)=>we(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@milaboratories/pl-model-common"),O=require("zod");class re extends Error{constructor(e,n){super(`${e.length}${n?"+":""} errors, first error: `+e[0]),this.errors=e,this.moreErrors=n}}function ie(t){if(!t.ok)throw new re(t.errors,t.moreErrors);return t.value}function Re(t){return new Proxy(t,{get(e,n){return ie(e[n])}})}function b(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"||t===null?D(t):t}function x(t){return{type:"GetFromCtx",variable:t}}function Te(t){return{type:"Isolate",cfg:t}}const Oe=x("$args"),xe=x("$it"),Fe=x("$prod"),Le=x("$staging"),De=x("$ui");function D(t){return{type:"Immediate",value:t}}function Z(t){const e={};for(const[n,s]of Object.entries(t))e[n]=b(s);return{type:"MakeObject",template:e}}function Ee(...t){const e=[];for(const n of t)e.push(b(n));return{type:"MakeArray",template:e}}function k(t,e){return{type:"GetJsonField",source:b(t),field:b(e)}}function ke(t,e,n="$it"){return{type:"MapRecordValues",source:t,mapping:e,itVar:n}}function Ve(t,e,n="$it"){return{type:"MapArrayValues",source:t,mapping:e,itVar:n}}function je(t){return{type:"Flatten",source:t}}function Ne(t){return{type:"IsEmpty",arg:t}}function Ue(t){return{type:"Not",operand:t}}function Be(t,e){return{type:"And",operand1:t,operand2:e}}function Me(t,e){return{type:"Or",operand1:t,operand2:e}}function Je(t,e){return{type:"GetResourceField",source:b(t),field:b(e)}}function $e(){return function(t){return{type:"GetResourceValueAsJson",source:b(t)}}}function Ge(t,e,n="$it"){return{type:"MapResourceFields",source:t,mapping:e,itVar:n}}function We(t){return{type:"GetBlobContent",source:b(t)}}function Ke(t){return{type:"GetBlobContentAsString",source:b(t)}}function He(){return function(t){return{type:"GetBlobContentAsJson",source:b(t)}}}function ze(t){return{type:"GetDownloadedBlobContent",source:b(t)}}function qe(t){return{type:"GetOnDemandBlobContent",source:b(t)}}function Ye(t,e){return{type:"ExtractArchiveAndGetURL",format:e,source:b(t)}}function Xe(t){return{type:"GetImportProgress",source:b(t)}}function Qe(t,e){return{type:"GetLastLogs",source:b(t),lines:e}}function Ze(t,e){return{type:"GetProgressLog",source:b(t),patternToSearch:e}}function et(t,e){return{type:"GetProgressLogWithInfo",source:b(t),patternToSearch:e}}function tt(t){return{type:"GetLogHandle",source:b(t)}}function nt(){return typeof globalThis.getPlatforma<"u"||typeof globalThis.platforma<"u"}function oe(t){if(t&&typeof globalThis.getPlatforma=="function")return globalThis.getPlatforma(t);if(typeof globalThis.platforma<"u")return globalThis.platforma;throw new Error("Can't get platforma instance.")}function st(){if(typeof globalThis.cfgRenderCtx<"u")return globalThis.cfgRenderCtx}function h(){if(typeof globalThis.cfgRenderCtx<"u")return globalThis.cfgRenderCtx;throw new Error("Not in config rendering context")}function j(t,e){const n=st();if(n===void 0)return!1;if(t in n.callbackRegistry)throw new Error(`Callback with key ${t} already registered.`);return n.callbackRegistry[t]=e,!0}const K=new Map;function rt(t,e){t in h().callbackRegistry||(h().callbackRegistry[t]=n=>{for(const s of K.get(t))s(n)},K.set(t,[])),K.get(t).push(e)}class A{constructor(e,n=s=>s){w(this,"isResolved",!1);w(this,"resolvedValue");this.handle=e,this.postProcess=n,rt(e,s=>{this.resolvedValue=n(s),this.isResolved=!0})}map(e){return new A(this.handle,n=>e(this.postProcess(n)))}mapDefined(e){return new A(this.handle,n=>{const s=this.postProcess(n);return s?e(s):void 0})}toJSON(){return this.isResolved?this.resolvedValue:{__awaited_futures__:[this.handle]}}}function M(t,e){return t===void 0?void 0:e(t)}class I{constructor(e,n){this.handle=e,this.resolvePath=n}resolve(...e){const n=e.map(s=>({assertFieldType:"Input",...typeof s=="string"?{field:s}:s}));return this.resolveWithCommon({},...n)}resolveOutput(...e){const n=e.map(s=>({assertFieldType:"Output",...typeof s=="string"?{field:s}:s}));return this.resolveWithCommon({},...n)}resolveInput(...e){const n=e.map(s=>({assertFieldType:"Input",...typeof s=="string"?{field:s}:s}));return this.resolveWithCommon({},...n)}resolveAny(...e){return this.resolveWithCommon({},...e)}resolveWithCommon(e,...n){const s=[...this.resolvePath,...n.map(r=>typeof r=="string"?r:r.field)];return M(h().resolveWithCommon(this.handle,e,...n),r=>new I(r,s))}get resourceType(){return h().getResourceType(this.handle)}getInputsLocked(){return h().getInputsLocked(this.handle)}getOutputsLocked(){return h().getOutputsLocked(this.handle)}getIsReadyOrError(){return h().getIsReadyOrError(this.handle)}getIsFinal(){return h().getIsFinal(this.handle)}getError(){const e=[...this.resolvePath,"error"];return M(h().getError(this.handle),n=>new I(n,e))}listInputFields(){return h().listInputFields(this.handle)}listOutputFields(){return h().listOutputFields(this.handle)}listDynamicFields(){return h().listDynamicFields(this.handle)}getKeyValueBase64(e){return h().getKeyValueBase64(this.handle,e)}getKeyValueAsString(e){return h().getKeyValueAsString(this.handle,e)}getKeyValueAsJson(e){const n=this.getKeyValueAsString(e);if(n==null)throw new Error("Resource has no content.");return JSON.parse(n)}getDataBase64(){return h().getDataBase64(this.handle)}getDataAsString(){return h().getDataAsString(this.handle)}getDataAsJson(){const e=this.getDataAsString();if(e==null)throw new Error("Resource has no content.");return JSON.parse(e)}getPColumns(e=!1,n=""){const s=this.parsePObjectCollection(e,n);return s===void 0?void 0:Object.entries(s).map(([,i])=>{if(!u.isPColumn(i))throw new Error(`not a PColumn (kind = ${i.spec.kind})`);return i})}parsePObjectCollection(e=!1,n=""){const s=h().parsePObjectCollection(this.handle,e,n,...this.resolvePath);if(s===void 0)return;const r={};for(const[i,o]of Object.entries(s)){const l=[...this.resolvePath,i];r[i]=u.mapPObjectData(o,a=>new I(a,l))}return r}getFileContentAsBase64(){return new A(h().getBlobContentAsBase64(this.handle))}getFileContentAsString(){return new A(h().getBlobContentAsString(this.handle))}getFileContentAsJson(){return new A(h().getBlobContentAsString(this.handle)).mapDefined(e=>JSON.parse(e))}getBlobContentAsBase64(){return this.getFileContentAsBase64()}getBlobContentAsString(){return this.getFileContentAsString()}getFileHandle(){return new A(h().getDownloadedBlobContentHandle(this.handle))}getDownloadedBlobHandle(){return this.getFileHandle()}getRemoteFileHandle(){return new A(h().getOnDemandBlobContentHandle(this.handle))}getOnDemandBlobHandle(){return this.getRemoteFileHandle()}extractArchiveAndGetURL(e){return new A(h().extractArchiveAndGetURL(this.handle,e))}getImportProgress(){return new A(h().getImportProgress(this.handle))}getLastLogs(e){return new A(h().getLastLogs(this.handle,e))}getProgressLog(e){return new A(h().getProgressLog(this.handle,e))}getProgressLogWithInfo(e){return new A(h().getProgressLogWithInfo(this.handle,e))}getLogHandle(){return new A(h().getLogHandle(this.handle))}allFieldsResolved(e="Input"){switch(e){case"Input":return this.getInputsLocked()&&this.listInputFields().every(n=>this.resolve({field:n,assertFieldType:"Input"})!==void 0);case"Output":return this.getOutputsLocked()&&this.listOutputFields().every(n=>this.resolve({field:n,assertFieldType:"Output"})!==void 0)}}mapFields(e,n){const{fieldType:s,requireLocked:r,skipUnresolved:i}={fieldType:"Input",requireLocked:!0,skipUnresolved:!1,...n},o=e;if(r&&(s==="Input"&&!this.getInputsLocked()||s==="Output"&&!this.getOutputsLocked()))return;let a=(s==="Input"?this.listInputFields():s==="Output"?this.listOutputFields():this.listDynamicFields()).map(c=>[c,this.resolve({field:c,assertFieldType:s})]);return i&&(a=a.filter(c=>c[1]!==void 0)),a.map(([c,m])=>o(c,m))}}const ae="staging",le="main",it={inlineColumnsSupport:!0,activeArgs:!0};function ue(t){return typeof t=="object"&&t!==null&&"__awaited_futures__"in t}function H(t,e,n){if(e.has(n))return;if(e.add(n),typeof n==="object")if(ue(n))n.__awaited_futures__.forEach(r=>t.add(r));else if(Array.isArray(n))for(const r of n)H(t,e,r);else for(const[,r]of Object.entries(n))r!==n&&H(t,e,r)}function ot(t){const e=new Set;return H(e,new Set,t),e}const at=Object.freeze(Object.defineProperty({__proto__:null,GlobalCfgRenderCtxFeatureFlags:it,MainAccessorName:le,StagingAccessorName:ae,getAllFutureAwaits:ot,isFutureAwait:ue},Symbol.toStringTag,{value:"Module"})),ce="pl7.app/label",de="pl7.app/trace",pe=O.z.object({type:O.z.string(),importance:O.z.number().optional(),id:O.z.string().optional(),label:O.z.string()}),fe=O.z.array(pe),lt=.001,ut="__LABEL__",te="__LABEL__@1";function z(t,e,n={}){const s=new Map,r=new Map,i=t.map(p=>{var P,ee;const g=e(p),f=(P=g.annotations)==null?void 0:P[ce],v=(ee=g.annotations)==null?void 0:ee[de],y=(v?fe.safeParse(JSON.parse(v)).data:void 0)??[];if(f){const R={label:f,type:ut,importance:-2};n.addLabelAsSuffix?y.push(R):y.splice(0,0,R)}const C=[],_=new Map;for(let R=y.length-1;R>=0;--R){const{type:G}=y[R],Se=y[R].importance??0,W=(_.get(G)??0)+1;_.set(G,W);const F=`${G}@${W}`;r.set(F,(r.get(F)??0)+1),s.set(F,Math.max(s.get(F)??Number.NEGATIVE_INFINITY,Se-(y.length-R)*lt)),C.push({...y[R],fullType:F,occurenceIndex:W})}return C.reverse(),{value:p,spec:g,label:f,fullTrace:C}}),o=[],l=[],a=[...s];a.sort(([,p],[,g])=>g-p);for(const[p]of a)p.endsWith("@1")||r.get(p)===t.length?o.push(p):l.push(p);const c=p=>i.map(g=>{const f=g.fullTrace.filter(y=>p.has(y.fullType)).map(y=>y.label),v=n.separator??" / ";return{label:f.join(v),value:g.value}});if(o.length===0){if(l.length!==0)throw new Error("Assertion error.");return c(new Set(te))}let m=0,d=0;for(;m<o.length;){const p=new Set;n.includeNativeLabel&&p.add(te);for(let f=0;f<m;++f)p.add(o[f]);p.add(o[d]);const g=c(p);if(new Set(g.map(f=>f.label)).size===t.length)return g;d++,d==o.length&&(m++,d=m)}return c(new Set([...o,...l]))}class he{constructor(){w(this,"ctx",h());w(this,"defaultLabelFn",(e,n)=>{var s;return((s=e.annotations)==null?void 0:s["pl7.app/label"])??"Unlabelled"})}calculateOptions(e){return this.ctx.calculateOptions(e)}getOptions(e,n){const s=typeof e=="function"?e:u.selectorsToPredicate(e),r=this.getSpecs().entries.filter(i=>s(i.obj));return typeof n=="object"||typeof n>"u"?z(r,i=>i.obj,n??{}).map(({value:{ref:i},label:o})=>({ref:i,label:o})):r.map(i=>({ref:i.ref,label:n(i.obj,i.ref)}))}getCanonicalOptions(e,n,s){const r={};if(!(e instanceof u.AnchorIdDeriver))for(const[a,c]of Object.entries(e))if(u.isPlRef(c)){const m=this.getPColumnSpecByRef(c);if(!m)return;r[a]=m}else r[a]=c;const i=typeof n=="function"?n:u.selectorsToPredicate(Array.isArray(n)?n.map(a=>u.resolveAnchors(r,a)):u.resolveAnchors(r,n)),o=this.getSpecs().entries.filter(({obj:a})=>u.isPColumnSpec(a)?i(a):!1),l=e instanceof u.AnchorIdDeriver?e:new u.AnchorIdDeriver(r);return z(o,a=>a.obj,s??{}).map(({value:{obj:a},label:c})=>({value:l.deriveCanonical(a),label:c}))}getDataFromResultPool(){return this.getData()}getData(){const e=this.ctx.getDataFromResultPool();return{isComplete:e.isComplete,entries:e.entries.map(n=>({ref:n.ref,obj:{...n.obj,data:new I(n.obj.data,[n.ref.blockId,n.ref.name])}}))}}getDataWithErrorsFromResultPool(){return this.getDataWithErrors()}getDataWithErrors(){const e=this.ctx.getDataWithErrorsFromResultPool();return{isComplete:e.isComplete,entries:e.entries.map(n=>({ref:n.ref,obj:{...n.obj,data:u.mapValueInVOE(n.obj.data,s=>new I(s,[n.ref.blockId,n.ref.name]))}}))}}getSpecsFromResultPool(){return this.getSpecs()}getSpecs(){return this.ctx.getSpecsFromResultPool()}getDataByRef(e){var n;return typeof this.ctx.getDataFromResultPoolByRef>"u"?(n=this.getData().entries.find(s=>s.ref.blockId===e.blockId&&s.ref.name===e.name))==null?void 0:n.obj:u.mapPObjectData(this.ctx.getDataFromResultPoolByRef(e.blockId,e.name),s=>new I(s,[e.blockId,e.name]))}getPColumnByRef(e){const n=this.getDataByRef(e);if(n)return u.ensurePColumn(n)}getPColumnSpecByRef(e){const n=this.getSpecByRef(e);if(n){if(!u.isPColumnSpec(n))throw new Error(`not a PColumn spec (kind = ${n.kind})`);return n}}getSpecByRef(e){return this.ctx.getSpecFromResultPoolByRef(e.blockId,e.name)}findDataWithCompatibleSpec(e){const n=[];e:for(const s of this.getData().entries){if(!u.isPColumnSpec(s.obj.spec))continue;const r=s.obj.spec;if(e.name===r.name&&e.valueType===r.valueType&&e.axesSpec.length===r.axesSpec.length&&q(e.domain,r.domain)){for(let i=0;i<e.axesSpec.length;++i){const o=e.axesSpec[i],l=r.axesSpec[i];if(o.name!==l.name||o.type!==l.type||!q(o.domain,l.domain))continue e}n.push(s.obj)}}return n}}function q(t,e){if(t===void 0)return e===void 0;if(e===void 0)return!0;for(const n in e)if(t[n]!==e[n])return!1;return!0}class L{constructor(){w(this,"ctx");w(this,"args");w(this,"uiState");w(this,"_activeArgsCache");w(this,"resultPool",new he);this.ctx=h(),this.args=JSON.parse(this.ctx.args),this.uiState=this.ctx.uiState!==void 0?JSON.parse(this.ctx.uiState):{}}get activeArgs(){return this._activeArgsCache===void 0&&(this._activeArgsCache={v:this.ctx.activeArgs?JSON.parse(this.ctx.activeArgs):void 0}),this._activeArgsCache.v}getNamedAccessor(e){return M(this.ctx.getAccessorHandleByName(e),n=>new I(n,[e]))}get prerun(){return this.getNamedAccessor(ae)}get outputs(){return this.getNamedAccessor(le)}findLabels(e){const n=this.resultPool.getData();for(const s of n.entries){if(!u.isPColumn(s.obj))continue;const r=s.obj.spec;if(r.name==="pl7.app/label"&&r.axesSpec.length===1&&r.axesSpec[0].name===e.name&&r.axesSpec[0].type===e.type&&q(e.domain,r.axesSpec[0].domain)){if(s.obj.data.resourceType.name!=="PColumnData/Json")throw Error(`Expected JSON column for labels, got: ${s.obj.data.resourceType.name}`);return Object.fromEntries(Object.entries(s.obj.data.getDataAsJson().data).map(o=>[JSON.parse(o[0])[0],o[1]]))}}}verifyInlineColumnsSupport(e){var r;const n=e.some(i=>!(i.data instanceof I)),s=((r=this.ctx.featureFlags)==null?void 0:r.inlineColumnsSupport)===!0;if(n&&!s)throw Error("inline columns not supported")}createPFrame(e){return this.verifyInlineColumnsSupport(e),this.ctx.createPFrame(e.map(n=>u.mapPObjectData(n,s=>s instanceof I?s.handle:s)))}createPTable(e){let n;return"columns"in e?n={src:{type:"full",entries:e.columns.map(s=>({type:"column",column:s}))},filters:e.filters??[],sorting:e.sorting??[]}:n=e,this.verifyInlineColumnsSupport(u.extractAllColumns(n.src)),this.ctx.createPTable(u.mapPTableDef(n,s=>u.mapPObjectData(s,r=>r instanceof I?r.handle:r)))}getBlockLabel(e){return this.ctx.getBlockLabel(e)}getCurrentUnstableMarker(){if(!(typeof this.ctx.getCurrentUnstableMarker>"u"))return this.ctx.getCurrentUnstableMarker()}}const V="PColumnData/",J=V+"ResourceMap",$=V+"Partitioned/ResourceMap",Y=V+"JsonPartitioned",N=V+"BinaryPartitioned",ge=V+"Partitioned/",X=ge+"JsonPartitioned",U=ge+"BinaryPartitioned";function me(t,e,n,s=[],r){if(t===void 0)return!1;switch(t.resourceType.name){case J:{let i=t.getInputsLocked();for(const o of t.listInputFields()){const l=t.resolve({field:o,assertFieldType:"Input"}),a=[...s,...JSON.parse(o)],c=l===void 0?void 0:e(l);c===void 0&&(i=!1),(c!==void 0||r)&&n.push({key:a,value:c})}return i}case $:{let i=t.getInputsLocked();for(const o of t.listInputFields()){const l=t.resolve({field:o,assertFieldType:"Input"});if(l===void 0)i=!1;else{const a=[...s,...JSON.parse(o)],c=me(l,e,n,a,r);i=i&&c}}return i}default:throw new Error(`Unknown resource type: ${t.resourceType.name}`)}}function ct(t,e,n=!1){const s=[];return{isComplete:me(t,e,s,[],n),data:s}}const ne=t=>{if(!t.endsWith(".index")){if(t.endsWith(".values"))return t.substring(0,t.length-7);throw Error(`key must ends on .index/.values for binary p-column, got: ${t}`)}};function ye(t){if(!t)return;const e=t.resourceType.name,n=t.getDataAsJson(),s=[];let r=0;switch(e){case J:r=n.keyLength;break;case $:r=n.partitionKeyLength+n.keyLength;break;case Y:case N:r=n.partitionKeyLength;break;case U:case X:r=n.superPartitionKeyLength+n.partitionKeyLength;break}switch(e){case J:case Y:case N:for(let i of t.listInputFields()){if(e===N){const l=ne(i);if(l)i=l;else continue}const o=[...JSON.parse(i)];s.push(o)}break;case $:case U:case X:for(const i of t.listInputFields()){const o=[...JSON.parse(i)],l=t.resolve({field:i,assertFieldType:"Input"});if(l!==void 0)for(let a of l.listInputFields()){if(e===U){const m=ne(a);if(m)a=m;else continue}const c=[...o,...JSON.parse(a)];s.push(c)}}break}return{data:s,keyLength:r}}function dt(t){const e=ye(t);if(!e)return;const{data:n,keyLength:s}=e,r=[];for(let i=0;i<s;++i)r.push(new Set);for(const i of n){if(i.length!==s)throw new Error("key length does not match partition length");for(let o=0;o<s;++o)r[o].add(i[o])}return r.map(i=>Array.from(i.values()))}const E="1.24.9";function be(t){return t.__renderLambda===!0}function B(t){if(t!==void 0)return be(t)?t.handle:t}function T(t){if(t!==void 0)return typeof t=="string"?{__renderLambda:!0,handle:t,retentive:!1}:t}function pt(t){if(t.v3!==void 0){const{initialArgs:e,initialUiState:n,inputsValid:s,outputs:r,renderingMode:i,sdkVersion:o,sections:l,title:a}=t.v3,{code:c}=t;return{initialArgs:e,initialUiState:n,inputsValid:s,outputs:r,renderingMode:i,sdkVersion:o,sections:l,title:a,code:c}}else if(t.inputsValid!==void 0){const{sdkVersion:e,renderingMode:n,outputs:s,inputsValid:r,sections:i,initialArgs:o,code:l}=t,a=Object.keys(t);if(e===void 0||n===void 0||s===void 0||r===void 0||i===void 0||o===void 0)throw new Error(`Malformed config v2. SDK version ${e}; Fields = ${a.join(", ")}`);return{sdkVersion:e,renderingMode:n,initialArgs:o,outputs:Object.fromEntries(Object.entries(s).map(([c,m])=>[c,T(m)])),inputsValid:T(r),sections:T(i),initialUiState:void 0,code:l}}else if(t.renderingMode!==void 0){const{sdkVersion:e,canRun:n,renderingMode:s,outputs:r,sections:i,initialArgs:o,code:l}=t,a=Object.keys(t);if(s===void 0||r===void 0||n===void 0||i===void 0||o===void 0)throw new Error(`Malformed config v1. SDK version ${e}; Fields = ${a.join(", ")}`);return{sdkVersion:e??"unknown",renderingMode:s,initialArgs:o,outputs:Object.fromEntries(Object.entries(r).map(([c,m])=>[c,T(m)])),inputsValid:T(n),sections:T(i),initialUiState:void 0,code:l}}else{const{sdkVersion:e}=t,n=Object.keys(t);throw new Error(`Config format not supported: SDK = ${e}; Fields = ${n.join(", ")}`)}}class S{constructor(e,n,s,r,i,o,l){this._renderingMode=e,this._initialArgs=n,this._initialUiState=s,this._outputs=r,this._inputsValid=i,this._sections=o,this._title=l}static create(e="Heavy"){return new S(e,void 0,{},{},D(!0),D([]),void 0)}output(e,n,s={}){if(typeof n=="function"){const r=`output#${e}`;return j(r,()=>n(new L)),new S(this._renderingMode,this._initialArgs,this._initialUiState,{...this._outputs,[e]:{__renderLambda:!0,handle:r,...s}},this._inputsValid,this._sections,this._title)}else return new S(this._renderingMode,this._initialArgs,this._initialUiState,{...this._outputs,[e]:n},this._inputsValid,this._sections,this._title)}retentiveOutput(e,n){return this.output(e,n,{retentive:!0})}argsValid(e){return typeof e=="function"?(j("inputsValid",()=>e(new L)),new S(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,{__renderLambda:!0,handle:"inputsValid"},this._sections,this._title)):new S(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,e,this._sections,this._title)}sections(e){return Array.isArray(e)?this.sections(D(e)):typeof e=="function"?(j("sections",()=>e(new L)),new S(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,this._inputsValid,{__renderLambda:!0,handle:"sections"},this._title)):new S(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,this._inputsValid,e,this._title)}title(e){return j("title",()=>e(new L)),new S(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,this._inputsValid,this._sections,{__renderLambda:!0,handle:"title"})}initialArgs(e){return new S(this._renderingMode,e,this._initialUiState,this._outputs,this._inputsValid,this._sections,this._title)}withArgs(e){return new S(this._renderingMode,e,this._initialUiState,this._outputs,this._inputsValid,this._sections,this._title)}withUiState(e){return new S(this._renderingMode,this._initialArgs,e,this._outputs,this._inputsValid,this._sections,this._title)}done(){if(this._initialArgs===void 0)throw new Error("Initial arguments not set.");const e={v3:{sdkVersion:E,renderingMode:this._renderingMode,initialArgs:this._initialArgs,initialUiState:this._initialUiState,inputsValid:this._inputsValid,sections:this._sections,title:this._title,outputs:this._outputs},sdkVersion:E,renderingMode:this._renderingMode,initialArgs:this._initialArgs,inputsValid:B(this._inputsValid),sections:B(this._sections),outputs:Object.fromEntries(Object.entries(this._outputs).map(([n,s])=>[n,B(s)]))};return nt()?oe({sdkVersion:E}):{config:e}}}function ft(t,e,n,s){var c,m;Array.isArray(s)&&(s={filters:s});const r=t.resultPool.getData().entries.map(d=>d.obj).filter(u.isPColumn).filter(d=>d.spec.name==="pl7.app/label"&&d.spec.axesSpec.length===1),i=(d,p)=>{let g=d.toString();if(p)for(const f in p)g+=f,g+=p[f];return g},o=new Map;for(const d of e)for(const p of d.spec.axesSpec){const g=u.getAxisId(p);for(const f of r){const v=f.spec.axesSpec[0],y=u.getAxisId(f.spec.axesSpec[0]);if(u.matchAxisId(g,y)){const C=Object.keys(g.domain??{}).length,_=Object.keys(y.domain??{}).length;if(C>_){const P=i(f.id,g.domain);o.set(P,{id:P,spec:{...f.spec,axesSpec:[{...g,annotations:v.annotations}]},data:f.data})}else o.set(i(f.id),f)}}}if([...e,...o.values()].some(d=>d.data instanceof I&&!d.data.getIsReadyOrError()))return;let l=e;const a=[];if(s!=null&&s.coreColumnPredicate){l=[];for(const d of e)s.coreColumnPredicate(d.spec)?l.push(d):a.push(d)}return a.push(...o.values()),t.createPTable({src:{type:"outer",primary:{type:(s==null?void 0:s.coreJoinType)??"full",entries:l.map(d=>({type:"column",column:d}))},secondary:a.map(d=>({type:"column",column:d}))},filters:[...(s==null?void 0:s.filters)??[],...((c=n==null?void 0:n.pTableParams)==null?void 0:c.filters)??[]],sorting:((m=n==null?void 0:n.pTableParams)==null?void 0:m.sorting)??[]})}function ht(t,e,n){const s=t.findLabels(e);return{axis:e,options:n.map(r=>({value:r,label:(s==null?void 0:s[r])??r.toString()})),defaultValue:n[0]}}const gt=(t,e)=>{let n=t.toString();return e==null||e.forEach(s=>{if(s)for(const[r,i]of Object.entries(s))n+=r,n+=i}),n};function mt(t){if(!t.length)return[];let e=[[]];return t.forEach(n=>{const s=[];n.forEach(r=>{s.push(...e.map(i=>[...i,r]))}),e=s}),e}function yt(t,e){const n=t.spec.axesSpec.map(u.getAxisId);return e.spec.axesSpec.map(u.getAxisId).every(r=>n.some(i=>u.matchAxisId(i,r)&&u.matchAxisId(r,i)))}function ve(t,e){const n=t.spec.axesSpec.map(u.getAxisId);return e.spec.axesSpec.map(u.getAxisId).every(r=>n.some(i=>u.matchAxisId(i,r)))}const Ae="pl7.app/graph/isVirtual",Q="pl7.app/label";function se(t,e){const n=t.spec.axesSpec.map(u.getAxisId),s=e.spec.axesSpec.map(u.getAxisId);if(yt(t,e))return[];if(!ve(t,e))return[];const o=s.map(d=>n.filter(p=>u.matchAxisId(p,d))),l=mt(o),a=new Set,c=new Set,m=l.map(d=>{const p=new Set;return d.map((g,f)=>{const v=e.spec.axesSpec[f].domain,y=g.domain;return Object.entries(y??{}).forEach(([C,_])=>{if((v==null?void 0:v[C])===void 0){const P=JSON.stringify([C,_]);p.add(P),a.add(P)}}),{...g,annotations:e.spec.axesSpec[f].annotations}}),p});return[...a].forEach(d=>{m.some(p=>!p.has(d))&&c.add(d)}),l.map((d,p)=>{var C;const g=gt(e.id,d.map(_=>_.domain)),f=((C=e.spec.annotations)==null?void 0:C[Q])??"",v=[...m[p]].filter(_=>c.has(_)).sort().map(_=>{var P;return(P=JSON.parse(_))==null?void 0:P[1]}).join(" / "),y={...e.spec.annotations,[Ae]:"true"};return(f||v)&&(y[Q]=f&&v?f+" / "+v:f+v),{id:g,spec:{...e.spec,axesSpec:d.map((_,P)=>({..._,annotations:e.spec.axesSpec[P].annotations})),annotations:y},data:e.data}})}function _e(t){const e=[];for(let n=0;n<t.length;n++)for(let s=n+1;s<t.length;s++){const r=t[n],i=t[s];e.push(...se(r,i),...se(i,r))}return e}function Ie(t,e){const n=[...t];for(const s of e)for(const r of t){if(r.id===s.id)break;if(ve(r,s)){n.push(s);break}}return n}const bt=["Int","Long","Float","Double","String","Bytes"];function vt(t,e){if(e===void 0)return;const n=t.resultPool.getData().entries.map(i=>i.obj).filter(u.isPColumn).filter(i=>bt.includes(i.spec.valueType)),s=Ie(e,n),r=[...s,..._e(s)];if(!r.some(i=>i.data instanceof I&&!i.data.getIsReadyOrError()))return t.createPFrame(r)}class At{constructor(e){this.handle=e}async findColumns(e){return await platforma.pFrameDriver.findColumns(this.handle,e)}async getColumnSpec(e){return await platforma.pFrameDriver.getColumnSpec(this.handle,e)}async listColumns(){return await platforma.pFrameDriver.listColumns(this.handle)}async calculateTableData(e){return await platforma.pFrameDriver.calculateTableData(this.handle,e)}async getUniqueValues(e){return await platforma.pFrameDriver.getUniqueValues(this.handle,e)}}function Pe(t){return Z({__isRef:!0,blockId:k(t,"blockId"),name:k(t,"name")})}function _t(t){return Z({ref:Pe(k(t,"ref")),label:k(t,"label")})}const It={sdkVersion:E};function Pt(){return oe({sdkVersion:E})}function St(t){if(typeof globalThis.getEnvironmentValue=="function")return globalThis.getEnvironmentValue(t)}exports.Args=Oe;exports.BlockModel=S;exports.CurrentSdkInfo=It;exports.FutureRef=A;exports.IS_VIRTUAL_COLUMN=Ae;exports.It=xe;exports.JsRenderInternal=at;exports.LABEL_ANNOTATION=Q;exports.MainOutputs=Fe;exports.OutputError=re;exports.PAnnotationLabel=ce;exports.PAnnotationTrace=de;exports.PFrameImpl=At;exports.RT_BINARY_PARTITIONED=N;exports.RT_BINARY_SUPER_PARTITIONED=U;exports.RT_JSON_PARTITIONED=Y;exports.RT_JSON_SUPER_PARTITIONED=X;exports.RT_RESOURCE_MAP=J;exports.RT_RESOURCE_MAP_PARTITIONED=$;exports.RenderCtx=L;exports.ResultPool=he;exports.StagingOutputs=Le;exports.Trace=fe;exports.TraceEntry=pe;exports.TreeNodeAccessor=I;exports.UiState=De;exports.and=Be;exports.createPFrameForGraphs=vt;exports.createPlDataTable=ft;exports.createPlDataTableSheet=ht;exports.deriveLabels=z;exports.downgradeCfgOrLambda=B;exports.enrichColumnsWithCompatible=Ie;exports.extractArchiveAndGetURL=Ye;exports.extractConfig=pt;exports.flatten=je;exports.fromPlOption=_t;exports.fromPlRef=Pe;exports.getAdditionalColumns=_e;exports.getBlobContent=We;exports.getBlobContentAsJson=He;exports.getBlobContentAsString=Ke;exports.getDownloadedBlobContent=ze;exports.getEnvironmentValue=St;exports.getFromCfg=x;exports.getImmediate=D;exports.getImportProgress=Xe;exports.getJsonField=k;exports.getLastLogs=Qe;exports.getLogHandle=tt;exports.getOnDemandBlobContent=qe;exports.getPartitionKeysList=ye;exports.getProgressLog=Ze;exports.getProgressLogWithInfo=et;exports.getRawPlatformaInstance=Pt;exports.getResourceField=Je;exports.getResourceValueAsJson=$e;exports.getUniquePartitionKeys=dt;exports.ifDef=M;exports.isConfigLambda=be;exports.isEmpty=Ne;exports.isolate=Te;exports.makeArray=Ee;exports.makeObject=Z;exports.mapArrayValues=Ve;exports.mapRecordValues=ke;exports.mapResourceFields=Ge;exports.not=Ue;exports.or=Me;exports.parseResourceMap=ct;exports.readOutput=ie;exports.wrapOutputs=Re;Object.keys(u).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>u[t]})});
2
2
  //# sourceMappingURL=index.js.map