@uwrl/qc-utils 0.0.18 → 0.0.19
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 +16 -16
- package/dist/index.umd.cjs +1 -1
- package/package.json +1 -1
- package/dist/index.d.ts +0 -4
- package/dist/models/dataSource.d.ts +0 -173
- package/dist/models/index.d.ts +0 -2
- package/dist/models/payload.d.ts +0 -24
- package/dist/models/settings.d.ts +0 -65
- package/dist/models/timestamp.d.ts +0 -150
- package/dist/services/__tests__/createPatchObject.spec.d.ts +0 -1
- package/dist/services/__tests__/requestInterceptor.spec.d.ts +0 -1
- package/dist/services/__tests__/responseInterceptor.spec.d.ts +0 -1
- package/dist/services/api.d.ts +0 -147
- package/dist/services/apiMethods.d.ts +0 -8
- package/dist/services/createPatchObject.d.ts +0 -17
- package/dist/services/getCSRFToken.d.ts +0 -1
- package/dist/services/index.d.ts +0 -6
- package/dist/services/requestInterceptor.d.ts +0 -12
- package/dist/services/responseInterceptor.d.ts +0 -2
- package/dist/types/index.d.ts +0 -372
- package/dist/utils/__tests__/ellapsed-time.spec.d.ts +0 -1
- package/dist/utils/__tests__/format.spec.d.ts +0 -1
- package/dist/utils/__tests__/notifications.spec.d.ts +0 -1
- package/dist/utils/__tests__/observations.spec.d.ts +0 -1
- package/dist/utils/ellapsed-time.d.ts +0 -4
- package/dist/utils/format.d.ts +0 -4
- package/dist/utils/index.d.ts +0 -6
- package/dist/utils/notifications.d.ts +0 -46
- package/dist/utils/observations.d.ts +0 -5
- package/dist/utils/plotting/__tests__/calibration.spec.d.ts +0 -16
- package/dist/utils/plotting/__tests__/mock.d.ts +0 -4
- package/dist/utils/plotting/__tests__/observation-record-paths.spec.d.ts +0 -21
- package/dist/utils/plotting/__tests__/observation-record.spec.d.ts +0 -1
- package/dist/utils/plotting/__tests__/operation-cores.spec.d.ts +0 -12
- package/dist/utils/plotting/__tests__/workerMocks.d.ts +0 -119
- package/dist/utils/plotting/__tests__/workers.spec.d.ts +0 -18
- package/dist/utils/plotting/add-data.worker.d.ts +0 -1
- package/dist/utils/plotting/calibration.d.ts +0 -99
- package/dist/utils/plotting/change-values.worker.d.ts +0 -1
- package/dist/utils/plotting/change.worker.d.ts +0 -1
- package/dist/utils/plotting/delete-data.worker.d.ts +0 -1
- package/dist/utils/plotting/drift-correction.worker.d.ts +0 -1
- package/dist/utils/plotting/fill-gaps.worker.d.ts +0 -1
- package/dist/utils/plotting/find-gaps.worker.d.ts +0 -1
- package/dist/utils/plotting/interpolate.worker.d.ts +0 -1
- package/dist/utils/plotting/observation-record.d.ts +0 -281
- package/dist/utils/plotting/operation-cores.d.ts +0 -139
- package/dist/utils/plotting/persistence.worker.d.ts +0 -1
- package/dist/utils/plotting/rate-of-change.worker.d.ts +0 -1
- package/dist/utils/plotting/shift-datetimes.worker.d.ts +0 -1
- package/dist/utils/plotting/value-threshold.worker.d.ts +0 -1
package/dist/index.js
CHANGED
|
@@ -2532,26 +2532,26 @@ class bn {
|
|
|
2532
2532
|
* 3. Cumulative fill counts before each segment give each worker's output startTarget, ensuring no overlap.
|
|
2533
2533
|
* 4. Each worker copies its segment to the output buffer and inserts its gap fills inline.
|
|
2534
2534
|
*/
|
|
2535
|
-
async _fillGaps(t, r, n, s) {
|
|
2536
|
-
const
|
|
2537
|
-
if (
|
|
2538
|
-
const
|
|
2535
|
+
async _fillGaps(t, r, n, s, a) {
|
|
2536
|
+
const o = this.dataX.length;
|
|
2537
|
+
if (o === 0) return;
|
|
2538
|
+
const i = t[0] * te[t[1]] * 1e3, l = r[0] * te[r[1]] * 1e3, f = a?.[0] ?? 0, u = a?.[1] ?? o - 1, p = this.dataX, g = [], y = [];
|
|
2539
2539
|
let d = 0;
|
|
2540
2540
|
for (let k = f + 1; k <= u; k++)
|
|
2541
|
-
if (p[k] - p[k - 1] >
|
|
2542
|
-
let C = 0, W = p[k - 1] +
|
|
2541
|
+
if (p[k] - p[k - 1] > i) {
|
|
2542
|
+
let C = 0, W = p[k - 1] + l;
|
|
2543
2543
|
for (; W < p[k]; )
|
|
2544
|
-
C++, W +=
|
|
2544
|
+
C++, W += l;
|
|
2545
2545
|
C > 0 && (g.push([k - 1, k]), y.push(C), d += C);
|
|
2546
2546
|
}
|
|
2547
2547
|
if (d === 0) return;
|
|
2548
|
-
const h =
|
|
2548
|
+
const h = o + d, b = h * Float64Array.BYTES_PER_ELEMENT, w = h * Float32Array.BYTES_PER_ELEMENT, m = new SharedArrayBuffer(b, {
|
|
2549
2549
|
maxByteLength: Math.max(this.dataX.buffer.maxByteLength, b)
|
|
2550
2550
|
}), S = new SharedArrayBuffer(w, {
|
|
2551
2551
|
maxByteLength: Math.max(this.dataY.buffer.maxByteLength, w)
|
|
2552
2552
|
});
|
|
2553
2553
|
if (!U(E.FILL_GAPS, {
|
|
2554
|
-
datasetSize:
|
|
2554
|
+
datasetSize: o,
|
|
2555
2555
|
selectionSize: d
|
|
2556
2556
|
}).useWorker) {
|
|
2557
2557
|
const k = new Float64Array(m), B = new Float32Array(S);
|
|
@@ -2562,19 +2562,19 @@ class bn {
|
|
|
2562
2562
|
k,
|
|
2563
2563
|
B,
|
|
2564
2564
|
0,
|
|
2565
|
-
|
|
2565
|
+
o - 1,
|
|
2566
2566
|
0,
|
|
2567
|
-
|
|
2567
|
+
l,
|
|
2568
2568
|
n,
|
|
2569
|
-
|
|
2569
|
+
s
|
|
2570
2570
|
), this.dataset.source.x = k, this.dataset.source.y = B, this._resizeTo(h);
|
|
2571
2571
|
return;
|
|
2572
2572
|
}
|
|
2573
2573
|
this._pendingExecutionMode = "worker";
|
|
2574
|
-
const L = navigator.hardwareConcurrency || 1, T = Math.ceil(
|
|
2574
|
+
const L = navigator.hardwareConcurrency || 1, T = Math.ceil(o / L), I = [];
|
|
2575
2575
|
let j = 0;
|
|
2576
2576
|
for (let k = 0; k < L; k++) {
|
|
2577
|
-
const B = k * T, C = Math.min((k + 1) * T - 1,
|
|
2577
|
+
const B = k * T, C = Math.min((k + 1) * T - 1, o - 1), W = [];
|
|
2578
2578
|
let Z = 0;
|
|
2579
2579
|
for (; j < g.length && g[j][0] <= C; )
|
|
2580
2580
|
W.push(g[j]), Z += y[j], j++;
|
|
@@ -2598,9 +2598,9 @@ class bn {
|
|
|
2598
2598
|
end: C,
|
|
2599
2599
|
gapsSegment: W,
|
|
2600
2600
|
startTarget: Z,
|
|
2601
|
-
fillDelta:
|
|
2601
|
+
fillDelta: l,
|
|
2602
2602
|
interpolate: n,
|
|
2603
|
-
fillValue:
|
|
2603
|
+
fillValue: s
|
|
2604
2604
|
}), fe.onmessage = (Ft) => {
|
|
2605
2605
|
Ct(Ft.data);
|
|
2606
2606
|
};
|
package/dist/index.umd.cjs
CHANGED
|
@@ -12,4 +12,4 @@
|
|
|
12
12
|
`,Ft=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Dt],{type:"text/javascript;charset=utf-8"});function Gr(e){let t;try{if(t=Ft&&(self.URL||self.webkitURL).createObjectURL(Ft),!t)throw"";const r=new Worker(t,{name:e?.name});return r.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),r}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(Dt),{name:e?.name})}}const Pt=`(function(){"use strict";function l(t,i,n,o,h){const f=[];if(o==="Less than")for(let e=i;e<n;e++){const s=t[e-1];(t[e]-s)/Math.abs(s)<h&&f.push(e)}else if(o==="Less than or equal to")for(let e=i;e<n;e++){const s=t[e-1];(t[e]-s)/Math.abs(s)<=h&&f.push(e)}else if(o==="Greater than")for(let e=i;e<n;e++){const s=t[e-1];(t[e]-s)/Math.abs(s)>h&&f.push(e)}else if(o==="Greater than or equal to")for(let e=i;e<n;e++){const s=t[e-1];(t[e]-s)/Math.abs(s)>=h&&f.push(e)}else if(o==="Equal")for(let e=i;e<n;e++){const s=t[e-1];(t[e]-s)/Math.abs(s)==h&&f.push(e)}return f}self.onmessage=t=>{const{bufferY:i,start:n,end:o,comparator:h,value:f}=t.data,e=new Float32Array(i);self.postMessage(l(e,n,o,h,f))}})();
|
|
13
13
|
`,Bt=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Pt],{type:"text/javascript;charset=utf-8"});function Yr(e){let t;try{if(t=Bt&&(self.URL||self.webkitURL).createObjectURL(Bt),!t)throw"";const r=new Worker(t,{name:e?.name});return r.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),r}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(Pt),{name:e?.name})}}const Nt=`(function(){"use strict";function k(i,l,u,r,c){const f=[],b=r.length;for(let a=l;a<u;a++){const t=i[a];let e=!1;for(let n=0;n<b;n++){const o=r[n],s=c[n];if(o===0){if(t<s){e=!0;break}}else if(o===1){if(t<=s){e=!0;break}}else if(o===2){if(t>s){e=!0;break}}else if(o===3){if(t>=s){e=!0;break}}else if(t==s){e=!0;break}}e&&f.push(a)}return f}self.onmessage=i=>{const{bufferY:l,start:u,end:r,ops:c,values:f}=i.data,b=new Float32Array(l);self.postMessage(k(b,u,r,c,f))}})();
|
|
14
14
|
`,jt=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Nt],{type:"text/javascript;charset=utf-8"});function Pe(e){let t;try{if(t=jt&&(self.URL||self.webkitURL).createObjectURL(jt),!t)throw"";const r=new Worker(t,{name:e?.name});return r.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),r}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(Nt),{name:e?.name})}}const Wt=`(function(){"use strict";function e(l,t,o,s){const c=t.length;if(o==="ADD")for(let f=0;f<c;f++)l[t[f]]=l[t[f]]+s;else if(o==="SUB")for(let f=0;f<c;f++)l[t[f]]=l[t[f]]-s;else if(o==="MULT")for(let f=0;f<c;f++)l[t[f]]=l[t[f]]*s;else if(o==="DIV")for(let f=0;f<c;f++)l[t[f]]=l[t[f]]/s;else if(o==="ASSIGN")for(let f=0;f<c;f++)l[t[f]]=s}self.onmessage=l=>{const{bufferY:t,indexes:o,operator:s,value:c}=l.data,f=new Float32Array(t);e(f,o,s,c),self.postMessage("Done")}})();
|
|
15
|
-
`,xt=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Wt],{type:"text/javascript;charset=utf-8"});function Hr(e){let t;try{if(t=xt&&(self.URL||self.webkitURL).createObjectURL(xt),!t)throw"";const r=new Worker(t,{name:e?.name});return r.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),r}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(Wt),{name:e?.name})}}function Gt(e,t,r,n,s){const o=[],a=n.length;for(let i=t;i<r;i++){const l=e[i];let f=!1;for(let u=0;u<a;u++){const p=n[u],g=s[u];if(p===0){if(l<g){f=!0;break}}else if(p===1){if(l<=g){f=!0;break}}else if(p===2){if(l>g){f=!0;break}}else if(p===3){if(l>=g){f=!0;break}}else if(l==g){f=!0;break}}f&&o.push(i)}return o}function zr(e,t,r,n,s){const o=[];if(n==="Less than")for(let a=t;a<r;a++)e[a]-e[a-1]<s&&o.push(a);else if(n==="Less than or equal to")for(let a=t;a<r;a++)e[a]-e[a-1]<=s&&o.push(a);else if(n==="Greater than")for(let a=t;a<r;a++)e[a]-e[a-1]>s&&o.push(a);else if(n==="Greater than or equal to")for(let a=t;a<r;a++)e[a]-e[a-1]>=s&&o.push(a);else if(n==="Equal")for(let a=t;a<r;a++)e[a]-e[a-1]==s&&o.push(a);return o}function Xr(e,t,r,n,s){const o=[];if(n==="Less than")for(let a=t;a<r;a++){const i=e[a-1];(e[a]-i)/Math.abs(i)<s&&o.push(a)}else if(n==="Less than or equal to")for(let a=t;a<r;a++){const i=e[a-1];(e[a]-i)/Math.abs(i)<=s&&o.push(a)}else if(n==="Greater than")for(let a=t;a<r;a++){const i=e[a-1];(e[a]-i)/Math.abs(i)>s&&o.push(a)}else if(n==="Greater than or equal to")for(let a=t;a<r;a++){const i=e[a-1];(e[a]-i)/Math.abs(i)>=s&&o.push(a)}else if(n==="Equal")for(let a=t;a<r;a++){const i=e[a-1];(e[a]-i)/Math.abs(i)==s&&o.push(a)}return o}function Vr(e,t,r,n){const s=[];let o=e[t];for(let a=t+1;a<=r;a++){const i=e[a];i-o>n&&s.push(a-1,a),o=i}return s}function qr(e,t,r){const n=[];if(t>=r)return n;let s=t,o=e[t];for(let a=t+1;a<r;a++){const i=e[a];i!==o&&(n.push(s,a-s,o),s=a,o=i)}return n.push(s,r-s,o),n}function Jr(e,t,r,n,s,o,a,i,l,f,u){let p=0,g=i;for(let y=o;y<=a;y++)if(n[g]=e[y],s[g]=t[y],g++,p<r.length&&y===r[p][0]){const d=r[p][0],h=r[p][1],S=e[d],b=e[h],w=t[d],k=t[h],L=b-S,T=k-w;let $=S+l;for(;$<b;)n[g]=$,s[g]=f?w+($-S)*T/L:u,g++,$+=l;p++}return g-i}function Kr(e,t,r,n,s,o,a,i){let l=o,f=0,u=i;const p=r.length;for(;l<a&&f<p;){const g=r[f][0];e[l]<=g?(n[u]=e[l],s[u]=t[l],l++):(n[u]=g,s[u]=r[f][1],f++),u++}for(;l<a;)n[u]=e[l],s[u]=t[l],l++,u++;for(;f<p;)n[u]=r[f][0],s[u]=r[f][1],f++,u++;return u-i}function Qr(e,t,r,n,s,o,a,i){let l=0,f=i;for(let u=o;u<=a;u++)l<r.length&&u===r[l]?l++:(n[f]=e[u],s[f]=t[u],f++);return f-i}function Zr(e,t,r,n){const s=r.length,o=new Array(s);if(n.isMonth)for(let a=0;a<s;a++){const i=r[a],l=new Date(e[i]);l.setMonth(l.getMonth()+n.amount),o[a]=[l.getTime(),t[i]]}else if(n.isYear)for(let a=0;a<s;a++){const i=r[a],l=new Date(e[i]);l.setFullYear(l.getFullYear()+n.amount),o[a]=[l.getTime(),t[i]]}else for(let a=0;a<s;a++){const i=r[a];o[a]=[e[i]+n.deltaMs,t[i]]}return o}function en(e,t,r){for(let n=0;n<r.length;n++){const{indexes:s,lowerIdx:o,upperIdx:a}=r[n],i=e[o],l=t[o],f=e[a],u=t[a],p=f-i,g=u-l;if(p===0){for(let y=0;y<s.length;y++)t[s[y]]=l;continue}for(let y=0;y<s.length;y++){const d=s[y];t[d]=l+(e[d]-i)*g/p}}}function tn(e,t,r){for(let n=0;n<r.length;n++){const s=r[n][0],o=r[n][1],a=r[n][2];if(o<=s)continue;const i=e[s],l=e[o]-i;if(l!==0)for(let f=s;f<o;f++)t[f]=t[f]+a*((e[f]-i)/l)}}function Yt(e,t,r,n){const s=t.length;if(r==="ADD")for(let o=0;o<s;o++)e[t[o]]=e[t[o]]+n;else if(r==="SUB")for(let o=0;o<s;o++)e[t[o]]=e[t[o]]-n;else if(r==="MULT")for(let o=0;o<s;o++)e[t[o]]=e[t[o]]*n;else if(r==="DIV")for(let o=0;o<s;o++)e[t[o]]=e[t[o]]/n;else if(r==="ASSIGN")for(let o=0;o<s;o++)e[t[o]]=n}const Be="qc-utils:calibration:v1",rn=720*60*60*1e3,fe=5e4,de=2e5,pe={spawnOverheadMs:50,inlineThroughput:5e4,workerThroughput:8e4,hwConcurrency:4,measuredAt:0,userAgent:"default"};let U=hn()??pe,Ne=null,re=null;const je=new Set,We={[v.VALUE_THRESHOLD]:{mode:"calibrated",weight:1,rationale:"O(n) single-pass scan; baseline reference"},[v.CHANGE]:{mode:"calibrated",weight:1.1,rationale:"O(n) with one subtraction per step"},[v.RATE_OF_CHANGE]:{mode:"calibrated",weight:1.4,rationale:"O(n) with division + abs per step"},[v.FIND_GAPS]:{mode:"calibrated",weight:.9,rationale:"O(n) on X only, mostly empty output"},[v.PERSISTENCE]:{mode:"calibrated",weight:1.3,rationale:"O(n) + chunk-boundary stitch"},[v.DATETIME_RANGE]:{mode:"always-inline",weight:0,rationale:"O(log n) binary search; never worth the worker hop"},[v.SELECTION]:{mode:"always-inline",weight:0,rationale:"Pure history bookkeeping"},[E.CHANGE_VALUES]:{mode:"calibrated",weight:.7,rationale:"O(k) in-place arithmetic on selection"},[E.ASSIGN_VALUES_BULK]:{mode:"always-inline",weight:0,rationale:"Single tight loop, already inline"},[E.ASSIGN_DATETIMES_BULK]:{mode:"always-inline",weight:0,rationale:"Composes delete+add which handle their own dispatch"},[E.INTERPOLATE]:{mode:"calibrated",weight:1.5,rationale:"Linear interp per consecutive group; in-place writes"},[E.DRIFT_CORRECTION]:{mode:"calibrated",weight:1.2,rationale:"O(range total) in-place math; one pass per range"},[E.SHIFT_DATETIMES]:{mode:"calibrated",weight:1.1,rationale:"O(k) per-point shift math; inline skips SAB allocation"},[E.ADD_POINTS]:{mode:"calibrated",weight:1.8,rationale:"Single merge pass over Y/X + insertions; fresh SAB per call"},[E.DELETE_POINTS]:{mode:"calibrated",weight:1.4,rationale:"Single skip-on-delete pass over Y/X; fresh SAB per call"},[E.FILL_GAPS]:{mode:"calibrated",weight:1.3,rationale:"Single copy-with-fills pass; fresh SAB sized to newLength"}};function D(e,t){const r=We[e];if(!r)return{useWorker:!0,predictedInlineMs:1/0,predictedWorkerMs:0,reason:"unknown op; keeping default worker path"};if(r.mode==="always-inline")return{useWorker:!1,predictedInlineMs:0,predictedWorkerMs:0,reason:r.rationale};if(typeof SharedArrayBuffer>"u")return{useWorker:!1,predictedInlineMs:0,predictedWorkerMs:1/0,reason:"SharedArrayBuffer unavailable; forced inline"};if(r.mode==="always-worker")return{useWorker:!0,predictedInlineMs:1/0,predictedWorkerMs:0,reason:r.rationale};const n=nn(e,t);if(n<=0)return{useWorker:!1,predictedInlineMs:0,predictedWorkerMs:U.spawnOverheadMs,reason:"zero work units"};const s=Math.max(1,Math.min(t.parallelism??U.hwConcurrency,U.hwConcurrency)),o=r.weight*n/U.inlineThroughput,a=U.spawnOverheadMs+r.weight*n/(U.workerThroughput*s),i=o>a;return{useWorker:i,predictedInlineMs:o,predictedWorkerMs:a,reason:i?`worker faster (${a.toFixed(1)} vs ${o.toFixed(1)} ms)`:`inline faster (${o.toFixed(1)} vs ${a.toFixed(1)} ms)`}}function nn(e,t){switch(e){case E.CHANGE_VALUES:case E.INTERPOLATE:case E.SHIFT_DATETIMES:case E.DRIFT_CORRECTION:return t.selectionSize??0;case E.DELETE_POINTS:return(t.selectionSize??0)+t.datasetSize*.25;case E.ADD_POINTS:{const r=Math.max(1,Math.log2(Math.max(t.datasetSize,2)));return t.datasetSize+(t.selectionSize??0)*r}default:return t.datasetSize}}function sn(e){return je.add(e),()=>je.delete(e)}function an(){return U}function on(){return Ne}function cn(){return Object.keys(We).map(e=>({op:e,...We[e]}))}function ln(){U=pe,Ne=null;try{localStorage.removeItem(Be)}catch{}}async function un(e={}){if(typeof window>"u"||!(e.force||U.measuredAt===0||Date.now()-U.measuredAt>rn))return U;if(re)await re;else{re=Ht().finally(()=>{re=null});const r=await re;U=r,fn(r),Ne=r;for(const n of je)n(U)}return U}async function Ht(){if(!(typeof SharedArrayBuffer<"u"))return{...pe,measuredAt:Date.now(),userAgent:navigator.userAgent,hwConcurrency:navigator.hardwareConcurrency||pe.hwConcurrency,sharedArrayBufferAvailable:!1,samples:{spawnRoundtripMs:[],inlineScanMs:[],workerScanMs:[]}};const t=navigator.hardwareConcurrency||4,r=new Float32Array(fe);for(let h=0;h<fe;h++)r[h]=Math.sin(h);const n=await xe(3,()=>{const h=performance.now();return Gt(r,0,fe,[2],[.5]),performance.now()-h}),s=Ge(n),o=fe/Math.max(s,.001),a=new SharedArrayBuffer(256*Float32Array.BYTES_PER_ELEMENT),i=await xe(3,async()=>{const h=performance.now();return await new Promise(S=>{const b=new Pe;b.onmessage=()=>{b.terminate(),S()},b.postMessage({bufferY:a,start:0,end:256,ops:[2],values:[.5]})}),performance.now()-h}),l=Ge(i),f=new SharedArrayBuffer(de*Float32Array.BYTES_PER_ELEMENT),u=new Float32Array(f);for(let h=0;h<de;h++)u[h]=Math.sin(h);const p=await xe(3,async()=>{const h=performance.now();return await new Promise(S=>{const b=new Pe;b.onmessage=()=>{b.terminate(),S()},b.postMessage({bufferY:f,start:0,end:de,ops:[2],values:[.5]})}),performance.now()-h}),g=Math.max(Ge(p)-l,.1),y=de/g;return{spawnOverheadMs:l,inlineThroughput:o,workerThroughput:y,hwConcurrency:t,measuredAt:Date.now(),userAgent:navigator.userAgent,sharedArrayBufferAvailable:!0,samples:{spawnRoundtripMs:i,inlineScanMs:n,workerScanMs:p}}}async function xe(e,t){const r=[];for(let n=0;n<e;n++)await new Promise(s=>setTimeout(s,0)),r.push(await t());return r}function Ge(e){if(!e.length)return 0;const t=[...e].sort((n,s)=>n-s),r=Math.floor(t.length/2);return t.length%2?t[r]:(t[r-1]+t[r])/2}function hn(){if(typeof localStorage>"u")return null;try{const e=localStorage.getItem(Be);if(!e)return null;const t=JSON.parse(e);return!t||typeof t.spawnOverheadMs!="number"?null:t}catch{return null}}function fn(e){if(!(typeof localStorage>"u"))try{const t={spawnOverheadMs:e.spawnOverheadMs,inlineThroughput:e.inlineThroughput,workerThroughput:e.workerThroughput,hwConcurrency:e.hwConcurrency,measuredAt:e.measuredAt,userAgent:e.userAgent};localStorage.setItem(Be,JSON.stringify(t))}catch{}}const K=20*1e3,dn=1024,pn=["date","value","qualifier"];class yn{dataset={dimensions:pn,source:{x:new Float64Array(new SharedArrayBuffer(K*Float64Array.BYTES_PER_ELEMENT,{maxByteLength:K*Float64Array.BYTES_PER_ELEMENT})),y:new Float32Array(new SharedArrayBuffer(K*Float32Array.BYTES_PER_ELEMENT,{maxByteLength:K*Float32Array.BYTES_PER_ELEMENT}))}};history=[];redoStack=[];_isReplaying=!1;_pendingExecutionMode="inline";loadingTime=null;isLoading=!0;rawData;constructor(t){this.history=[],this.rawData=t,this.loadData(this.rawData)}async loadData(t){if(!t)return;this.isLoading=!0;const r=await ue(()=>{this._growBuffer(t.datetimes.length),this._resizeTo(t.datetimes.length),this.dataX.set(t.datetimes),this.dataY.set(t.dataValues)});this.loadingTime=r.duration,this.history.length=0,this.isLoading=!1}get dataX(){return this.dataset.source.x}get dataY(){return this.dataset.source.y}_resizeTo(t){this.dataset.source.x=new Float64Array(this.dataset.source.x.buffer).subarray(0,t),this.dataset.source.y=new Float32Array(this.dataset.source.y.buffer).subarray(0,t)}_growBuffer(t){const r=t*Float64Array.BYTES_PER_ELEMENT;let n=this.dataX.buffer.byteLength;for(;r>n;)n+=K*Float64Array.BYTES_PER_ELEMENT;if(n*Float64Array.BYTES_PER_ELEMENT>this.dataX.buffer.maxByteLength){const s=new SharedArrayBuffer(this.dataX.buffer.byteLength,{maxByteLength:n*Float64Array.BYTES_PER_ELEMENT}),o=new SharedArrayBuffer(this.dataY.buffer.byteLength,{maxByteLength:n*Float32Array.BYTES_PER_ELEMENT}),a=new Float64Array(s),i=new Float32Array(o);a.set(this.dataX),i.set(this.dataY),this.dataset.source.x=a,this.dataset.source.y=i}this.dataX.buffer.byteLength<t*Float64Array.BYTES_PER_ELEMENT&&(this.dataX.buffer.grow(t*Float64Array.BYTES_PER_ELEMENT),this.dataY.buffer.grow(t*Float32Array.BYTES_PER_ELEMENT))}async reload(){this.loadingTime=null,this.isLoading=!0,this.history.length=0,await this.loadData(this.rawData)}async reloadHistory(t){const r=this.history.slice(0,t+1);return this.redoStack.length=0,await this.reload(),await this.dispatch(r.map(n=>[n.method,...n.args||[]]))}async removeHistoryItem(t){const r=[...this.history];return r.splice(t,1),this.redoStack.length=0,await this.reload(),await this.dispatch(r.map(n=>[n.method,...n.args||[]]))}async undo(){if(!this.history.length)return[];const t=this.history[this.history.length-1],r=this.history.slice(0,-1);await this.reload(),this.redoStack.push(t),this._isReplaying=!0;try{return await this.dispatch(r.map(n=>[n.method,...n.args||[]]))}finally{this._isReplaying=!1}}async redo(){if(!this.redoStack.length)return[];const t=this.redoStack.pop();this._isReplaying=!0;try{return await this.dispatch([[t.method,...t.args||[]]])}finally{this._isReplaying=!1}}get beginTime(){return this.dataset.source.x.length?new Date(this.dataset.source.x[0]):null}get endTime(){return this.dataset.source.x.length?new Date(this.dataset.source.x[this.dataset.source.x.length-1]):null}async dispatchAction(t,...r){const n={[E.ADD_POINTS]:this._addDataPoints,[E.CHANGE_VALUES]:this._changeValues,[E.ASSIGN_VALUES_BULK]:this._assignValuesBulk,[E.DELETE_POINTS]:this._deleteDataPoints,[E.DRIFT_CORRECTION]:this._driftCorrection,[E.INTERPOLATE]:this._interpolate,[E.SHIFT_DATETIMES]:this._shift,[E.ASSIGN_DATETIMES_BULK]:this._assignDatetimesBulk,[E.FILL_GAPS]:this._fillGaps},s={[E.ADD_POINTS]:"mdi-plus",[E.CHANGE_VALUES]:"mdi-pencil",[E.ASSIGN_VALUES_BULK]:"mdi-pencil",[E.DELETE_POINTS]:"mdi-trash-can",[E.DRIFT_CORRECTION]:"mdi-chart-sankey",[E.INTERPOLATE]:"mdi-transit-connection-horizontal",[E.SHIFT_DATETIMES]:"mdi-calendar",[E.ASSIGN_DATETIMES_BULK]:"mdi-calendar",[E.FILL_GAPS]:"mdi-keyboard-space"};let o=[];try{this._isReplaying||(this.redoStack.length=0);const a={method:t,args:r,icon:s[t],isLoading:!0};this.history.push(a);const i=this.history.length-1;this._pendingExecutionMode="inline";const l=await ue(async()=>await n[t].apply(this,r));o=l.response;const f=this.history[i];f&&(f.duration=l.duration,f.executionMode=this._pendingExecutionMode,f.isLoading=!1)}catch(a){console.log(`Failed to execute operation: ${t} with arguments: `,r),console.log(a)}return o}async dispatch(t,...r){const n=async(s,o)=>v[s]?await this.dispatchFilter(s,...o):await this.dispatchAction(s,...o);if(Array.isArray(t)){let s=[];for(let o=0;o<t.length;o++){const a=t[o][0],i=t[o].slice(1,t[o].length);s=await n(a,i)}return s}else return await n(t,r)}async dispatchFilter(t,...r){const n={[v.FIND_GAPS]:this._findGaps,[v.VALUE_THRESHOLD]:this._valueThreshold,[v.DATETIME_RANGE]:this._datetimeRange,[v.PERSISTENCE]:this._persistence,[v.CHANGE]:this._change,[v.RATE_OF_CHANGE]:this._rateOfChange,[v.SELECTION]:this._selection},s={[v.FIND_GAPS]:"mdi-plus",[v.PERSISTENCE]:"mdi-plus",[v.CHANGE]:"mdi-plus",[v.RATE_OF_CHANGE]:"mdi-plus",[v.VALUE_THRESHOLD]:"mdi-plus",[v.DATETIME_RANGE]:"mdi-plus",[v.SELECTION]:"mdi-plus"};let o=[];try{this._isReplaying||(this.redoStack.length=0);const a={method:t,args:r,icon:s[t],isLoading:!0},i=this.history[this.history.length-1];let l;v[i?.method]?(l=this.history.length-1,this.history[l]=a):(this.history.push(a),l=this.history.length-1),this._pendingExecutionMode="inline";const f=await ue(async()=>await n[t].apply(this,r));o=f.response;const u=this.history[l];u&&(u.duration=f.duration,u.executionMode=this._pendingExecutionMode,u.selected=f.response,u.isLoading=!1)}catch(a){console.log(`Failed to execute filter operation: ${t} with arguments: `,r),console.log(a)}return o}async _changeValues(t,r){const n=this.history[this.history.length-2]?.selected;if(!n||n.length===0)return[];const s=n.length;if(!D(E.CHANGE_VALUES,{datasetSize:this.dataset.source.y.length,selectionSize:s}).useWorker||s<dn)return Yt(this.dataY,n,t,r),[];this._pendingExecutionMode="worker";const a=Math.min(navigator.hardwareConcurrency||1,s),i=Math.ceil(s/a),l=[],f=[];for(let u=0;u<a;u++){const p=u*i,g=Math.min((u+1)*i,s);if(p>=g)break;const y=n.slice(p,g);f.push(new Promise(d=>{const h=new Hr;l.push(h),h.postMessage({bufferY:this.dataY.buffer,indexes:y,operator:t,value:r}),h.onmessage=S=>{d(S.data)}}))}return await Promise.all(f),l.forEach(u=>u.terminate()),[]}_applyOperatorInPlace(t,r,n){Yt(this.dataY,t,r,n)}async _assignValuesBulk(t){const r=this.history[this.history.length-2]?.selected;if(!r||!r.length||!t?.length)return[];const n=Math.min(r.length,t.length),s=this.dataY;for(let o=0;o<n;o++)s[r[o]]=t[o];return[]}async _assignDatetimesBulk(t){const r=this.history[this.history.length-2]?.selected;if(!r||!r.length||!t?.length)return[];const n=Math.min(r.length,t.length),s=new Array(n),o=new Array(n);for(let a=0;a<n;a++)s[a]=[t[a],this.dataY[r[a]]],o[a]=r[a];return o.sort((a,i)=>a-i),await this._deleteDataPoints(o),await this._addDataPoints(s),[]}async _interpolate(t){const r=this._getConsecutiveGroups(t);if(r.length===0||r[0].length===0)return;const n=this.dataset.source.y.length,s=r.map(u=>({indexes:u,lowerIdx:Math.max(0,u[0]-1),upperIdx:Math.min(n-1,u[u.length-1]+1)}));if(!D(E.INTERPOLATE,{datasetSize:n,selectionSize:t.length}).useWorker){en(this.dataX,this.dataY,s);return}this._pendingExecutionMode="worker";const a=Math.min(navigator.hardwareConcurrency||1,s.length),i=Math.ceil(s.length/a),l=[],f=[];for(let u=0;u<a;u++){const p=s.slice(u*i,(u+1)*i);if(p.length===0)break;f.push(new Promise(g=>{const y=new Pr;l.push(y),y.postMessage({bufferX:this.dataX.buffer,bufferY:this.dataY.buffer,groups:p}),y.onmessage=d=>{g(d.data)}}))}await Promise.all(f),l.forEach(u=>u.terminate())}async _shift(t,r,n){if(t.length===0)return;const s=n===O.MONTH,o=n===O.YEAR,a=!s&&!o?r*ee[n]*1e3:0,i=t.length;if(!D(E.SHIFT_DATETIMES,{datasetSize:this.dataset.source.x.length,selectionSize:i}).useWorker){const w=Zr(this.dataX,this.dataY,t,{amount:r,isMonth:s,isYear:o,deltaMs:a});await this._deleteDataPoints(t),await this._addDataPoints(w);return}this._pendingExecutionMode="worker";const f=new SharedArrayBuffer(i*Float64Array.BYTES_PER_ELEMENT),u=new SharedArrayBuffer(i*Float32Array.BYTES_PER_ELEMENT),p=Math.min(navigator.hardwareConcurrency||1,i),g=Math.ceil(i/p),y=[],d=[];for(let w=0;w<p;w++){const k=w*g,L=Math.min((w+1)*g,i);if(k>=L)break;const T=t.slice(k,L);d.push(new Promise($=>{const M=new jr;y.push(M),M.postMessage({bufferX:this.dataX.buffer,bufferY:this.dataY.buffer,outputBufferX:f,outputBufferY:u,indexes:T,outStart:k,amount:r,isMonth:s,isYear:o,deltaMs:a}),M.onmessage=z=>{$(z.data)}}))}await Promise.all(d),y.forEach(w=>w.terminate());const h=new Float64Array(f),S=new Float32Array(u),b=new Array(i);for(let w=0;w<i;w++)b[w]=[h[w],S[w]];await this._deleteDataPoints(t),await this._addDataPoints(b)}async _fillGaps(t,r,n,s){const o=this.dataX.length;if(o===0)return;const a=t[0]*ee[t[1]]*1e3,i=r[0]*ee[r[1]]*1e3,l=-9999,f=s?.[0]??0,u=s?.[1]??o-1,p=this.dataX,g=[],y=[];let d=0;for(let A=f+1;A<=u;A++)if(p[A]-p[A-1]>a){let N=0,X=p[A-1]+i;for(;X<p[A];)N++,X+=i;N>0&&(g.push([A-1,A]),y.push(N),d+=N)}if(d===0)return;const h=o+d,S=h*Float64Array.BYTES_PER_ELEMENT,b=h*Float32Array.BYTES_PER_ELEMENT,w=new SharedArrayBuffer(S,{maxByteLength:Math.max(this.dataX.buffer.maxByteLength,S)}),k=new SharedArrayBuffer(b,{maxByteLength:Math.max(this.dataY.buffer.maxByteLength,b)});if(!D(E.FILL_GAPS,{datasetSize:o,selectionSize:d}).useWorker){const A=new Float64Array(w),W=new Float32Array(k);Jr(this.dataX,this.dataY,g,A,W,0,o-1,0,i,n,l),this.dataset.source.x=A,this.dataset.source.y=W,this._resizeTo(h);return}this._pendingExecutionMode="worker";const T=navigator.hardwareConcurrency||1,$=Math.ceil(o/T),M=[];let z=0;for(let A=0;A<T;A++){const W=A*$,N=Math.min((A+1)*$-1,o-1),X=[];let ye=0;for(;z<g.length&&g[z][0]<=N;)X.push(g[z]),ye+=y[z],z++;M.push({start:W,end:N,gapsSegment:X,fillsInSegment:ye})}const Ye=new Array(T).fill(0);for(let A=1;A<T;A++)Ye[A]=Ye[A-1]+M[A-1].fillsInSegment;const zt=[],Xt=[];for(let A=0;A<T;A++){const{start:W,end:N,gapsSegment:X}=M[A],ye=W+Ye[A];Xt.push(new Promise(gn=>{const He=new Fr;zt.push(He),He.postMessage({bufferX:this.dataX.buffer,bufferY:this.dataY.buffer,outputBufferX:w,outputBufferY:k,start:W,end:N,gapsSegment:X,startTarget:ye,fillDelta:i,interpolate:n,fillValue:l}),He.onmessage=mn=>{gn(mn.data)}}))}await Promise.all(Xt),zt.forEach(A=>A.terminate()),this.dataset.source.x=new Float64Array(w),this.dataset.source.y=new Float32Array(k),this._resizeTo(h)}async _deleteDataPoints(t){const r=this.dataX.length,n=r-t.length;if(!D(E.DELETE_POINTS,{datasetSize:r,selectionSize:t.length}).useWorker){const y=new SharedArrayBuffer(this.dataX.buffer.byteLength,{maxByteLength:this.dataX.buffer.maxByteLength}),d=new SharedArrayBuffer(this.dataY.buffer.byteLength,{maxByteLength:this.dataY.buffer.maxByteLength}),h=new Float64Array(y),S=new Float32Array(d);Qr(this.dataX,this.dataY,t,h,S,0,r-1,0),this.dataset.source.x=h,this.dataset.source.y=S,this._resizeTo(n);return}this._pendingExecutionMode="worker";const o=navigator.hardwareConcurrency||1,a=Math.ceil(this.dataX.length/o),i=[],l=[];for(let y=0;y<o;y++){const d=y*a,h=Math.min((y+1)*a-1,this.dataX.length-1),S=te(t,d),b=he(t,h),w=t.slice(S,b+1);l.push({start:d,end:h,deleteSegment:w})}const f=new Array(o).fill(0);for(let y=1;y<o;y++)f[y]=f[y-1]+l[y-1].deleteSegment.length;const u=[],p=new SharedArrayBuffer(this.dataX.buffer.byteLength,{maxByteLength:this.dataX.buffer.maxByteLength}),g=new SharedArrayBuffer(this.dataY.buffer.byteLength,{maxByteLength:this.dataY.buffer.maxByteLength});for(let y=0;y<o;y++){const{start:d,end:h,deleteSegment:S}=l[y],b=d-f[y];u.push(new Promise(w=>{const k=new Dr;i.push(k),k.postMessage({bufferX:this.dataX.buffer,bufferY:this.dataY.buffer,outputBufferX:p,outputBufferY:g,start:d,end:h,deleteSegment:S,startTarget:b}),k.onmessage=L=>{w(L.data)}}))}await Promise.all(u),i.forEach(y=>y.terminate()),this.dataset.source.x=new Float64Array(p),this.dataset.source.y=new Float32Array(g),this._resizeTo(n)}async _driftCorrection(t){if(!t||t.length===0)return;const r=this.dataset.source.x,n=navigator.hardwareConcurrency||1;let s=0;for(const[p,g]of t)g>p&&(s+=g-p);if(!D(E.DRIFT_CORRECTION,{datasetSize:r.length,selectionSize:s}).useWorker){tn(r,this.dataY,t);return}this._pendingExecutionMode="worker";const a=[];for(const[p,g,y]of t){if(g<=p)continue;const d=r[p],h=r[g]-d;if(h===0)continue;const S=g-p,b=Math.max(1,Math.ceil(S/n));for(let w=p;w<g;w+=b)a.push({chunkStart:w,chunkEnd:Math.min(w+b,g),startDatetime:d,value:y,extent:h})}if(a.length===0)return;const i=Math.min(n,a.length),l=Array.from({length:i},()=>[]);a.forEach((p,g)=>l[g%i].push(p));const f=[],u=[];for(const p of l)p.length!==0&&u.push(new Promise(g=>{const y=new Br;f.push(y),y.postMessage({bufferX:this.dataX.buffer,bufferY:this.dataY.buffer,jobs:p}),y.onmessage=d=>{g(d.data)}}));await Promise.all(u),f.forEach(p=>p.terminate())}_getConsecutiveGroups(t){const r=[[]];return t.reduce((n,s)=>{const o=n[n.length-1];return!o.length||s==o[o.length-1]+1?o.push(s):n.push([s]),n},r),r}async _addDataPoints(t){if(t.length===0)return;const r=this.dataX.length,n=r+t.length;t.sort((d,h)=>d[0]-h[0]);const s=n*Float64Array.BYTES_PER_ELEMENT,o=n*Float32Array.BYTES_PER_ELEMENT,a=new SharedArrayBuffer(s,{maxByteLength:Math.max(this.dataX.buffer.maxByteLength,s)}),i=new SharedArrayBuffer(o,{maxByteLength:Math.max(this.dataY.buffer.maxByteLength,o)});if(!D(E.ADD_POINTS,{datasetSize:r,selectionSize:t.length}).useWorker){const d=new Float64Array(a),h=new Float32Array(i);Kr(this.dataX,this.dataY,t,d,h,0,r,0),this.dataset.source.x=d,this.dataset.source.y=h,this._resizeTo(n);return}this._pendingExecutionMode="worker";const f=t.map(d=>he(this.dataX,d[0])+1),u=Math.max(1,Math.min(navigator.hardwareConcurrency||1,Math.max(r,1))),p=Math.ceil(Math.max(r,1)/u),g=[],y=[];for(let d=0;d<u;d++){const h=d*p,S=Math.min((d+1)*p,r),b=te(f,h),w=d===u-1?t.length:te(f,S),k=t.slice(b,w),L=h+b;h>=S&&k.length===0||y.push(new Promise(T=>{const $=new Nr;g.push($),$.postMessage({bufferX:this.dataX.buffer,bufferY:this.dataY.buffer,outputBufferX:a,outputBufferY:i,origStart:h,origEnd:S,insertions:k,outStart:L}),$.onmessage=M=>{T(M.data)}}))}await Promise.all(y),g.forEach(d=>d.terminate()),this.dataset.source.x=new Float64Array(a),this.dataset.source.y=new Float32Array(i),this._resizeTo(n)}async _valueThreshold(t){const r=Object.keys(t);if(r.length===0)return[];const n={[x.LT]:0,[x.LTE]:1,[x.GT]:2,[x.GTE]:3,[x.E]:4},s=r.map(h=>n[h]??4),o=r.map(h=>t[h]),a=this.dataset.source.y,i=a.length;if(i===0)return[];if(!D(v.VALUE_THRESHOLD,{datasetSize:i}).useWorker)return Gt(a,0,i,s,o);this._pendingExecutionMode="worker";const f=Math.min(navigator.hardwareConcurrency||1,i),u=Math.ceil(i/f),p=[],g=[];for(let h=0;h<f;h++){const S=h*u,b=Math.min((h+1)*u,i);if(S>=b)break;g.push(new Promise(w=>{const k=new Pe;p.push(k),k.postMessage({bufferY:this.dataY.buffer,start:S,end:b,ops:s,values:o}),k.onmessage=L=>{w(L.data)}}))}const y=await Promise.all(g);p.forEach(h=>h.terminate());const d=[];for(let h=0;h<y.length;h++){const S=y[h];for(let b=0;b<S.length;b++)d.push(S[b])}return d}async _rateOfChange(t,r){const n=this.dataset.source.y;if(n.length<2)return[];const s=1,o=n.length,a=o-s;if(!D(v.RATE_OF_CHANGE,{datasetSize:n.length}).useWorker)return Xr(n,s,o,t,r);this._pendingExecutionMode="worker";const l=Math.min(navigator.hardwareConcurrency||1,a),f=Math.ceil(a/l),u=[],p=[];for(let d=0;d<l;d++){const h=s+d*f,S=Math.min(s+(d+1)*f,o);if(h>=S)break;p.push(new Promise(b=>{const w=new Yr;u.push(w),w.postMessage({bufferY:this.dataY.buffer,start:h,end:S,comparator:t,value:r}),w.onmessage=k=>{b(k.data)}}))}const g=await Promise.all(p);u.forEach(d=>d.terminate());const y=[];for(let d=0;d<g.length;d++){const h=g[d];for(let S=0;S<h.length;S++)y.push(h[S])}return y}async _datetimeRange(t,r){const n=this.dataset.source.x,s=n.length;if(s===0)return[];const o=t==null?0:te(n,t),a=r==null?s-1:he(n,r);if(o>a)return[];const i=new Array(a-o+1);for(let l=o;l<=a;l++)i[l-o]=l;return i}async _selection(t){return(!t||!t.length)&&this.history.pop(),t}async _change(t,r){const n=this.dataset.source.y;if(n.length<2)return[];const s=1,o=n.length,a=o-s;if(!D(v.CHANGE,{datasetSize:n.length}).useWorker)return zr(n,s,o,t,r);this._pendingExecutionMode="worker";const l=Math.min(navigator.hardwareConcurrency||1,a),f=Math.ceil(a/l),u=[],p=[];for(let d=0;d<l;d++){const h=s+d*f,S=Math.min(s+(d+1)*f,o);if(h>=S)break;p.push(new Promise(b=>{const w=new Gr;u.push(w),w.postMessage({bufferY:this.dataY.buffer,start:h,end:S,comparator:t,value:r}),w.onmessage=k=>{b(k.data)}}))}const g=await Promise.all(p);u.forEach(d=>d.terminate());const y=[];for(let d=0;d<g.length;d++){const h=g[d];for(let S=0;S<h.length;S++)y.push(h[S])}return y}async _findGaps(t,r,n){const s=this.dataset.source.x;let o=0,a=s.length;if(n?.[0]&&n?.[1]&&(o=n[0],a=n[1]),a<=o)return[];const i=t*ee[r]*1e3;if(!D(v.FIND_GAPS,{datasetSize:a-o}).useWorker){const S=Vr(s,o,a-1,i),b=new Set;for(let w=0;w<S.length;w++)b.add(S[w]);return[...b]}this._pendingExecutionMode="worker";const f=a-o,u=Math.min(navigator.hardwareConcurrency||1,f),p=Math.ceil(f/u),g=[],y=[];for(let S=0;S<u;S++){const b=o+S*p,w=Math.min(o+(S+1)*p,a);if(b>=w)break;y.push(new Promise(k=>{const L=new Wr;g.push(L),L.postMessage({bufferX:this.dataX.buffer,start:b,endInclusive:w,threshold:i}),L.onmessage=T=>{k(T.data)}}))}const d=await Promise.all(y);g.forEach(S=>S.terminate());const h=new Set;for(let S=0;S<d.length;S++){const b=d[S];for(let w=0;w<b.length;w++)h.add(b[w])}return[...h]}async _persistence(t,r){const n=this.dataset.source.y;let s=0,o=n.length;if(r?.[0]&&r?.[1]&&(s=r[0],o=r[1]),o<=s)return[];const a=o-s;if(!D(v.PERSISTENCE,{datasetSize:a}).useWorker){const b=qr(n,s,o),w=[];for(let k=0;k<b.length;k+=3){const L=b[k],T=b[k+1];if(T>=t)for(let $=0;$<T;$++)w.push(L+$)}return w}this._pendingExecutionMode="worker";const l=Math.min(navigator.hardwareConcurrency||1,a),f=Math.ceil(a/l),u=[],p=[];for(let b=0;b<l;b++){const w=s+b*f,k=Math.min(s+(b+1)*f,o);if(w>=k)break;p.push(new Promise(L=>{const T=new xr;u.push(T),T.postMessage({bufferY:this.dataY.buffer,start:w,end:k}),T.onmessage=$=>{L($.data)}}))}const g=await Promise.all(p);u.forEach(b=>b.terminate());const y=[],d=[],h=[];for(let b=0;b<g.length;b++){const w=g[b];for(let k=0;k<w.length;k+=3){const L=w[k],T=w[k+1],$=w[k+2],M=y.length-1;M>=0&&h[M]===$&&y[M]+d[M]===L?d[M]+=T:(y.push(L),d.push(T),h.push($))}}const S=[];for(let b=0;b<y.length;b++){const w=d[b];if(w>=t){const k=y[b];for(let L=0;L<w;L++)S.push(k+L)}}return S}}m.ACCOUNT_BASE=F,m.AUTH_BASE=ie,m.ApiKey=ar,m.BASE_URL=C,m.Collaborator=ir,m.DEFAULT_SNACK_DURATION=Le,m.DataSource=Ar,m.Datastream=Jt,m.EnumEditOperations=E,m.EnumFilterOperations=v,m.FilterOperation=x,m.HydroShareArchive=Ve,m.INCREASE_AMOUNT=K,m.Location=qe,m.LogicalOperation=Xe,m.OAuthProvider=sr,m.ObservationRecord=yn,m.ObservedProperty=Zt,m.Operator=ze,m.Organization=rr,m.PROVIDER_BASE=Q,m.Payload=$r,m.PermissionAction=Je,m.PermissionResource=Ke,m.Position=lt,m.PostHydroShareArchive=Vt,m.ProcessingLevel=er,m.ResultQualifier=tr,m.SESSION_BASE=ce,m.Sensor=Qt,m.Snack=ut,m.SnackColor=Te,m.SnackIcon=$e,m.SnackTitle=Re,m.Snackbar=ht,m.TAG_BASE=Ce,m.THINGS_BASE=_,m.Thing=qt,m.TimeUnit=O,m.Unit=Kt,m.User=nr,m.Workspace=or,m.api=Tr,m.apiMethods=c,m.clearCalibration=ln,m.createPatchObject=Ie,m.ensureCalibration=un,m.extractErrorMessage=Qe,m.findFirstGreaterOrEqual=te,m.findLastLessOrEqual=he,m.formatDate=Ur,m.formatDuration=Mr,m.getCSRFToken=ge,m.getCalibration=an,m.getLastBenchmarkDetail=on,m.getObservationsEndpoint=Lr,m.getOperationTable=cn,m.measureEllapsedTime=ue,m.onCalibrationChange=sn,m.requestInterceptor=me,m.responseInterceptor=we,m.runBenchmarks=Ht,m.shouldUseWorker=D,m.subtractHours=Cr,m.timeUnitMultipliers=ee,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})}));
|
|
15
|
+
`,xt=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Wt],{type:"text/javascript;charset=utf-8"});function Hr(e){let t;try{if(t=xt&&(self.URL||self.webkitURL).createObjectURL(xt),!t)throw"";const r=new Worker(t,{name:e?.name});return r.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),r}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(Wt),{name:e?.name})}}function Gt(e,t,r,n,s){const o=[],a=n.length;for(let i=t;i<r;i++){const l=e[i];let f=!1;for(let u=0;u<a;u++){const p=n[u],g=s[u];if(p===0){if(l<g){f=!0;break}}else if(p===1){if(l<=g){f=!0;break}}else if(p===2){if(l>g){f=!0;break}}else if(p===3){if(l>=g){f=!0;break}}else if(l==g){f=!0;break}}f&&o.push(i)}return o}function zr(e,t,r,n,s){const o=[];if(n==="Less than")for(let a=t;a<r;a++)e[a]-e[a-1]<s&&o.push(a);else if(n==="Less than or equal to")for(let a=t;a<r;a++)e[a]-e[a-1]<=s&&o.push(a);else if(n==="Greater than")for(let a=t;a<r;a++)e[a]-e[a-1]>s&&o.push(a);else if(n==="Greater than or equal to")for(let a=t;a<r;a++)e[a]-e[a-1]>=s&&o.push(a);else if(n==="Equal")for(let a=t;a<r;a++)e[a]-e[a-1]==s&&o.push(a);return o}function Xr(e,t,r,n,s){const o=[];if(n==="Less than")for(let a=t;a<r;a++){const i=e[a-1];(e[a]-i)/Math.abs(i)<s&&o.push(a)}else if(n==="Less than or equal to")for(let a=t;a<r;a++){const i=e[a-1];(e[a]-i)/Math.abs(i)<=s&&o.push(a)}else if(n==="Greater than")for(let a=t;a<r;a++){const i=e[a-1];(e[a]-i)/Math.abs(i)>s&&o.push(a)}else if(n==="Greater than or equal to")for(let a=t;a<r;a++){const i=e[a-1];(e[a]-i)/Math.abs(i)>=s&&o.push(a)}else if(n==="Equal")for(let a=t;a<r;a++){const i=e[a-1];(e[a]-i)/Math.abs(i)==s&&o.push(a)}return o}function Vr(e,t,r,n){const s=[];let o=e[t];for(let a=t+1;a<=r;a++){const i=e[a];i-o>n&&s.push(a-1,a),o=i}return s}function qr(e,t,r){const n=[];if(t>=r)return n;let s=t,o=e[t];for(let a=t+1;a<r;a++){const i=e[a];i!==o&&(n.push(s,a-s,o),s=a,o=i)}return n.push(s,r-s,o),n}function Jr(e,t,r,n,s,o,a,i,l,f,u){let p=0,g=i;for(let y=o;y<=a;y++)if(n[g]=e[y],s[g]=t[y],g++,p<r.length&&y===r[p][0]){const d=r[p][0],h=r[p][1],S=e[d],b=e[h],w=t[d],k=t[h],L=b-S,T=k-w;let $=S+l;for(;$<b;)n[g]=$,s[g]=f?w+($-S)*T/L:u,g++,$+=l;p++}return g-i}function Kr(e,t,r,n,s,o,a,i){let l=o,f=0,u=i;const p=r.length;for(;l<a&&f<p;){const g=r[f][0];e[l]<=g?(n[u]=e[l],s[u]=t[l],l++):(n[u]=g,s[u]=r[f][1],f++),u++}for(;l<a;)n[u]=e[l],s[u]=t[l],l++,u++;for(;f<p;)n[u]=r[f][0],s[u]=r[f][1],f++,u++;return u-i}function Qr(e,t,r,n,s,o,a,i){let l=0,f=i;for(let u=o;u<=a;u++)l<r.length&&u===r[l]?l++:(n[f]=e[u],s[f]=t[u],f++);return f-i}function Zr(e,t,r,n){const s=r.length,o=new Array(s);if(n.isMonth)for(let a=0;a<s;a++){const i=r[a],l=new Date(e[i]);l.setMonth(l.getMonth()+n.amount),o[a]=[l.getTime(),t[i]]}else if(n.isYear)for(let a=0;a<s;a++){const i=r[a],l=new Date(e[i]);l.setFullYear(l.getFullYear()+n.amount),o[a]=[l.getTime(),t[i]]}else for(let a=0;a<s;a++){const i=r[a];o[a]=[e[i]+n.deltaMs,t[i]]}return o}function en(e,t,r){for(let n=0;n<r.length;n++){const{indexes:s,lowerIdx:o,upperIdx:a}=r[n],i=e[o],l=t[o],f=e[a],u=t[a],p=f-i,g=u-l;if(p===0){for(let y=0;y<s.length;y++)t[s[y]]=l;continue}for(let y=0;y<s.length;y++){const d=s[y];t[d]=l+(e[d]-i)*g/p}}}function tn(e,t,r){for(let n=0;n<r.length;n++){const s=r[n][0],o=r[n][1],a=r[n][2];if(o<=s)continue;const i=e[s],l=e[o]-i;if(l!==0)for(let f=s;f<o;f++)t[f]=t[f]+a*((e[f]-i)/l)}}function Yt(e,t,r,n){const s=t.length;if(r==="ADD")for(let o=0;o<s;o++)e[t[o]]=e[t[o]]+n;else if(r==="SUB")for(let o=0;o<s;o++)e[t[o]]=e[t[o]]-n;else if(r==="MULT")for(let o=0;o<s;o++)e[t[o]]=e[t[o]]*n;else if(r==="DIV")for(let o=0;o<s;o++)e[t[o]]=e[t[o]]/n;else if(r==="ASSIGN")for(let o=0;o<s;o++)e[t[o]]=n}const Be="qc-utils:calibration:v1",rn=720*60*60*1e3,fe=5e4,de=2e5,pe={spawnOverheadMs:50,inlineThroughput:5e4,workerThroughput:8e4,hwConcurrency:4,measuredAt:0,userAgent:"default"};let U=hn()??pe,Ne=null,re=null;const je=new Set,We={[v.VALUE_THRESHOLD]:{mode:"calibrated",weight:1,rationale:"O(n) single-pass scan; baseline reference"},[v.CHANGE]:{mode:"calibrated",weight:1.1,rationale:"O(n) with one subtraction per step"},[v.RATE_OF_CHANGE]:{mode:"calibrated",weight:1.4,rationale:"O(n) with division + abs per step"},[v.FIND_GAPS]:{mode:"calibrated",weight:.9,rationale:"O(n) on X only, mostly empty output"},[v.PERSISTENCE]:{mode:"calibrated",weight:1.3,rationale:"O(n) + chunk-boundary stitch"},[v.DATETIME_RANGE]:{mode:"always-inline",weight:0,rationale:"O(log n) binary search; never worth the worker hop"},[v.SELECTION]:{mode:"always-inline",weight:0,rationale:"Pure history bookkeeping"},[E.CHANGE_VALUES]:{mode:"calibrated",weight:.7,rationale:"O(k) in-place arithmetic on selection"},[E.ASSIGN_VALUES_BULK]:{mode:"always-inline",weight:0,rationale:"Single tight loop, already inline"},[E.ASSIGN_DATETIMES_BULK]:{mode:"always-inline",weight:0,rationale:"Composes delete+add which handle their own dispatch"},[E.INTERPOLATE]:{mode:"calibrated",weight:1.5,rationale:"Linear interp per consecutive group; in-place writes"},[E.DRIFT_CORRECTION]:{mode:"calibrated",weight:1.2,rationale:"O(range total) in-place math; one pass per range"},[E.SHIFT_DATETIMES]:{mode:"calibrated",weight:1.1,rationale:"O(k) per-point shift math; inline skips SAB allocation"},[E.ADD_POINTS]:{mode:"calibrated",weight:1.8,rationale:"Single merge pass over Y/X + insertions; fresh SAB per call"},[E.DELETE_POINTS]:{mode:"calibrated",weight:1.4,rationale:"Single skip-on-delete pass over Y/X; fresh SAB per call"},[E.FILL_GAPS]:{mode:"calibrated",weight:1.3,rationale:"Single copy-with-fills pass; fresh SAB sized to newLength"}};function D(e,t){const r=We[e];if(!r)return{useWorker:!0,predictedInlineMs:1/0,predictedWorkerMs:0,reason:"unknown op; keeping default worker path"};if(r.mode==="always-inline")return{useWorker:!1,predictedInlineMs:0,predictedWorkerMs:0,reason:r.rationale};if(typeof SharedArrayBuffer>"u")return{useWorker:!1,predictedInlineMs:0,predictedWorkerMs:1/0,reason:"SharedArrayBuffer unavailable; forced inline"};if(r.mode==="always-worker")return{useWorker:!0,predictedInlineMs:1/0,predictedWorkerMs:0,reason:r.rationale};const n=nn(e,t);if(n<=0)return{useWorker:!1,predictedInlineMs:0,predictedWorkerMs:U.spawnOverheadMs,reason:"zero work units"};const s=Math.max(1,Math.min(t.parallelism??U.hwConcurrency,U.hwConcurrency)),o=r.weight*n/U.inlineThroughput,a=U.spawnOverheadMs+r.weight*n/(U.workerThroughput*s),i=o>a;return{useWorker:i,predictedInlineMs:o,predictedWorkerMs:a,reason:i?`worker faster (${a.toFixed(1)} vs ${o.toFixed(1)} ms)`:`inline faster (${o.toFixed(1)} vs ${a.toFixed(1)} ms)`}}function nn(e,t){switch(e){case E.CHANGE_VALUES:case E.INTERPOLATE:case E.SHIFT_DATETIMES:case E.DRIFT_CORRECTION:return t.selectionSize??0;case E.DELETE_POINTS:return(t.selectionSize??0)+t.datasetSize*.25;case E.ADD_POINTS:{const r=Math.max(1,Math.log2(Math.max(t.datasetSize,2)));return t.datasetSize+(t.selectionSize??0)*r}default:return t.datasetSize}}function sn(e){return je.add(e),()=>je.delete(e)}function an(){return U}function on(){return Ne}function cn(){return Object.keys(We).map(e=>({op:e,...We[e]}))}function ln(){U=pe,Ne=null;try{localStorage.removeItem(Be)}catch{}}async function un(e={}){if(typeof window>"u"||!(e.force||U.measuredAt===0||Date.now()-U.measuredAt>rn))return U;if(re)await re;else{re=Ht().finally(()=>{re=null});const r=await re;U=r,fn(r),Ne=r;for(const n of je)n(U)}return U}async function Ht(){if(!(typeof SharedArrayBuffer<"u"))return{...pe,measuredAt:Date.now(),userAgent:navigator.userAgent,hwConcurrency:navigator.hardwareConcurrency||pe.hwConcurrency,sharedArrayBufferAvailable:!1,samples:{spawnRoundtripMs:[],inlineScanMs:[],workerScanMs:[]}};const t=navigator.hardwareConcurrency||4,r=new Float32Array(fe);for(let h=0;h<fe;h++)r[h]=Math.sin(h);const n=await xe(3,()=>{const h=performance.now();return Gt(r,0,fe,[2],[.5]),performance.now()-h}),s=Ge(n),o=fe/Math.max(s,.001),a=new SharedArrayBuffer(256*Float32Array.BYTES_PER_ELEMENT),i=await xe(3,async()=>{const h=performance.now();return await new Promise(S=>{const b=new Pe;b.onmessage=()=>{b.terminate(),S()},b.postMessage({bufferY:a,start:0,end:256,ops:[2],values:[.5]})}),performance.now()-h}),l=Ge(i),f=new SharedArrayBuffer(de*Float32Array.BYTES_PER_ELEMENT),u=new Float32Array(f);for(let h=0;h<de;h++)u[h]=Math.sin(h);const p=await xe(3,async()=>{const h=performance.now();return await new Promise(S=>{const b=new Pe;b.onmessage=()=>{b.terminate(),S()},b.postMessage({bufferY:f,start:0,end:de,ops:[2],values:[.5]})}),performance.now()-h}),g=Math.max(Ge(p)-l,.1),y=de/g;return{spawnOverheadMs:l,inlineThroughput:o,workerThroughput:y,hwConcurrency:t,measuredAt:Date.now(),userAgent:navigator.userAgent,sharedArrayBufferAvailable:!0,samples:{spawnRoundtripMs:i,inlineScanMs:n,workerScanMs:p}}}async function xe(e,t){const r=[];for(let n=0;n<e;n++)await new Promise(s=>setTimeout(s,0)),r.push(await t());return r}function Ge(e){if(!e.length)return 0;const t=[...e].sort((n,s)=>n-s),r=Math.floor(t.length/2);return t.length%2?t[r]:(t[r-1]+t[r])/2}function hn(){if(typeof localStorage>"u")return null;try{const e=localStorage.getItem(Be);if(!e)return null;const t=JSON.parse(e);return!t||typeof t.spawnOverheadMs!="number"?null:t}catch{return null}}function fn(e){if(!(typeof localStorage>"u"))try{const t={spawnOverheadMs:e.spawnOverheadMs,inlineThroughput:e.inlineThroughput,workerThroughput:e.workerThroughput,hwConcurrency:e.hwConcurrency,measuredAt:e.measuredAt,userAgent:e.userAgent};localStorage.setItem(Be,JSON.stringify(t))}catch{}}const K=20*1e3,dn=1024,pn=["date","value","qualifier"];class yn{dataset={dimensions:pn,source:{x:new Float64Array(new SharedArrayBuffer(K*Float64Array.BYTES_PER_ELEMENT,{maxByteLength:K*Float64Array.BYTES_PER_ELEMENT})),y:new Float32Array(new SharedArrayBuffer(K*Float32Array.BYTES_PER_ELEMENT,{maxByteLength:K*Float32Array.BYTES_PER_ELEMENT}))}};history=[];redoStack=[];_isReplaying=!1;_pendingExecutionMode="inline";loadingTime=null;isLoading=!0;rawData;constructor(t){this.history=[],this.rawData=t,this.loadData(this.rawData)}async loadData(t){if(!t)return;this.isLoading=!0;const r=await ue(()=>{this._growBuffer(t.datetimes.length),this._resizeTo(t.datetimes.length),this.dataX.set(t.datetimes),this.dataY.set(t.dataValues)});this.loadingTime=r.duration,this.history.length=0,this.isLoading=!1}get dataX(){return this.dataset.source.x}get dataY(){return this.dataset.source.y}_resizeTo(t){this.dataset.source.x=new Float64Array(this.dataset.source.x.buffer).subarray(0,t),this.dataset.source.y=new Float32Array(this.dataset.source.y.buffer).subarray(0,t)}_growBuffer(t){const r=t*Float64Array.BYTES_PER_ELEMENT;let n=this.dataX.buffer.byteLength;for(;r>n;)n+=K*Float64Array.BYTES_PER_ELEMENT;if(n*Float64Array.BYTES_PER_ELEMENT>this.dataX.buffer.maxByteLength){const s=new SharedArrayBuffer(this.dataX.buffer.byteLength,{maxByteLength:n*Float64Array.BYTES_PER_ELEMENT}),o=new SharedArrayBuffer(this.dataY.buffer.byteLength,{maxByteLength:n*Float32Array.BYTES_PER_ELEMENT}),a=new Float64Array(s),i=new Float32Array(o);a.set(this.dataX),i.set(this.dataY),this.dataset.source.x=a,this.dataset.source.y=i}this.dataX.buffer.byteLength<t*Float64Array.BYTES_PER_ELEMENT&&(this.dataX.buffer.grow(t*Float64Array.BYTES_PER_ELEMENT),this.dataY.buffer.grow(t*Float32Array.BYTES_PER_ELEMENT))}async reload(){this.loadingTime=null,this.isLoading=!0,this.history.length=0,await this.loadData(this.rawData)}async reloadHistory(t){const r=this.history.slice(0,t+1);return this.redoStack.length=0,await this.reload(),await this.dispatch(r.map(n=>[n.method,...n.args||[]]))}async removeHistoryItem(t){const r=[...this.history];return r.splice(t,1),this.redoStack.length=0,await this.reload(),await this.dispatch(r.map(n=>[n.method,...n.args||[]]))}async undo(){if(!this.history.length)return[];const t=this.history[this.history.length-1],r=this.history.slice(0,-1);await this.reload(),this.redoStack.push(t),this._isReplaying=!0;try{return await this.dispatch(r.map(n=>[n.method,...n.args||[]]))}finally{this._isReplaying=!1}}async redo(){if(!this.redoStack.length)return[];const t=this.redoStack.pop();this._isReplaying=!0;try{return await this.dispatch([[t.method,...t.args||[]]])}finally{this._isReplaying=!1}}get beginTime(){return this.dataset.source.x.length?new Date(this.dataset.source.x[0]):null}get endTime(){return this.dataset.source.x.length?new Date(this.dataset.source.x[this.dataset.source.x.length-1]):null}async dispatchAction(t,...r){const n={[E.ADD_POINTS]:this._addDataPoints,[E.CHANGE_VALUES]:this._changeValues,[E.ASSIGN_VALUES_BULK]:this._assignValuesBulk,[E.DELETE_POINTS]:this._deleteDataPoints,[E.DRIFT_CORRECTION]:this._driftCorrection,[E.INTERPOLATE]:this._interpolate,[E.SHIFT_DATETIMES]:this._shift,[E.ASSIGN_DATETIMES_BULK]:this._assignDatetimesBulk,[E.FILL_GAPS]:this._fillGaps},s={[E.ADD_POINTS]:"mdi-plus",[E.CHANGE_VALUES]:"mdi-pencil",[E.ASSIGN_VALUES_BULK]:"mdi-pencil",[E.DELETE_POINTS]:"mdi-trash-can",[E.DRIFT_CORRECTION]:"mdi-chart-sankey",[E.INTERPOLATE]:"mdi-transit-connection-horizontal",[E.SHIFT_DATETIMES]:"mdi-calendar",[E.ASSIGN_DATETIMES_BULK]:"mdi-calendar",[E.FILL_GAPS]:"mdi-keyboard-space"};let o=[];try{this._isReplaying||(this.redoStack.length=0);const a={method:t,args:r,icon:s[t],isLoading:!0};this.history.push(a);const i=this.history.length-1;this._pendingExecutionMode="inline";const l=await ue(async()=>await n[t].apply(this,r));o=l.response;const f=this.history[i];f&&(f.duration=l.duration,f.executionMode=this._pendingExecutionMode,f.isLoading=!1)}catch(a){console.log(`Failed to execute operation: ${t} with arguments: `,r),console.log(a)}return o}async dispatch(t,...r){const n=async(s,o)=>v[s]?await this.dispatchFilter(s,...o):await this.dispatchAction(s,...o);if(Array.isArray(t)){let s=[];for(let o=0;o<t.length;o++){const a=t[o][0],i=t[o].slice(1,t[o].length);s=await n(a,i)}return s}else return await n(t,r)}async dispatchFilter(t,...r){const n={[v.FIND_GAPS]:this._findGaps,[v.VALUE_THRESHOLD]:this._valueThreshold,[v.DATETIME_RANGE]:this._datetimeRange,[v.PERSISTENCE]:this._persistence,[v.CHANGE]:this._change,[v.RATE_OF_CHANGE]:this._rateOfChange,[v.SELECTION]:this._selection},s={[v.FIND_GAPS]:"mdi-plus",[v.PERSISTENCE]:"mdi-plus",[v.CHANGE]:"mdi-plus",[v.RATE_OF_CHANGE]:"mdi-plus",[v.VALUE_THRESHOLD]:"mdi-plus",[v.DATETIME_RANGE]:"mdi-plus",[v.SELECTION]:"mdi-plus"};let o=[];try{this._isReplaying||(this.redoStack.length=0);const a={method:t,args:r,icon:s[t],isLoading:!0},i=this.history[this.history.length-1];let l;v[i?.method]?(l=this.history.length-1,this.history[l]=a):(this.history.push(a),l=this.history.length-1),this._pendingExecutionMode="inline";const f=await ue(async()=>await n[t].apply(this,r));o=f.response;const u=this.history[l];u&&(u.duration=f.duration,u.executionMode=this._pendingExecutionMode,u.selected=f.response,u.isLoading=!1)}catch(a){console.log(`Failed to execute filter operation: ${t} with arguments: `,r),console.log(a)}return o}async _changeValues(t,r){const n=this.history[this.history.length-2]?.selected;if(!n||n.length===0)return[];const s=n.length;if(!D(E.CHANGE_VALUES,{datasetSize:this.dataset.source.y.length,selectionSize:s}).useWorker||s<dn)return Yt(this.dataY,n,t,r),[];this._pendingExecutionMode="worker";const a=Math.min(navigator.hardwareConcurrency||1,s),i=Math.ceil(s/a),l=[],f=[];for(let u=0;u<a;u++){const p=u*i,g=Math.min((u+1)*i,s);if(p>=g)break;const y=n.slice(p,g);f.push(new Promise(d=>{const h=new Hr;l.push(h),h.postMessage({bufferY:this.dataY.buffer,indexes:y,operator:t,value:r}),h.onmessage=S=>{d(S.data)}}))}return await Promise.all(f),l.forEach(u=>u.terminate()),[]}_applyOperatorInPlace(t,r,n){Yt(this.dataY,t,r,n)}async _assignValuesBulk(t){const r=this.history[this.history.length-2]?.selected;if(!r||!r.length||!t?.length)return[];const n=Math.min(r.length,t.length),s=this.dataY;for(let o=0;o<n;o++)s[r[o]]=t[o];return[]}async _assignDatetimesBulk(t){const r=this.history[this.history.length-2]?.selected;if(!r||!r.length||!t?.length)return[];const n=Math.min(r.length,t.length),s=new Array(n),o=new Array(n);for(let a=0;a<n;a++)s[a]=[t[a],this.dataY[r[a]]],o[a]=r[a];return o.sort((a,i)=>a-i),await this._deleteDataPoints(o),await this._addDataPoints(s),[]}async _interpolate(t){const r=this._getConsecutiveGroups(t);if(r.length===0||r[0].length===0)return;const n=this.dataset.source.y.length,s=r.map(u=>({indexes:u,lowerIdx:Math.max(0,u[0]-1),upperIdx:Math.min(n-1,u[u.length-1]+1)}));if(!D(E.INTERPOLATE,{datasetSize:n,selectionSize:t.length}).useWorker){en(this.dataX,this.dataY,s);return}this._pendingExecutionMode="worker";const a=Math.min(navigator.hardwareConcurrency||1,s.length),i=Math.ceil(s.length/a),l=[],f=[];for(let u=0;u<a;u++){const p=s.slice(u*i,(u+1)*i);if(p.length===0)break;f.push(new Promise(g=>{const y=new Pr;l.push(y),y.postMessage({bufferX:this.dataX.buffer,bufferY:this.dataY.buffer,groups:p}),y.onmessage=d=>{g(d.data)}}))}await Promise.all(f),l.forEach(u=>u.terminate())}async _shift(t,r,n){if(t.length===0)return;const s=n===O.MONTH,o=n===O.YEAR,a=!s&&!o?r*ee[n]*1e3:0,i=t.length;if(!D(E.SHIFT_DATETIMES,{datasetSize:this.dataset.source.x.length,selectionSize:i}).useWorker){const w=Zr(this.dataX,this.dataY,t,{amount:r,isMonth:s,isYear:o,deltaMs:a});await this._deleteDataPoints(t),await this._addDataPoints(w);return}this._pendingExecutionMode="worker";const f=new SharedArrayBuffer(i*Float64Array.BYTES_PER_ELEMENT),u=new SharedArrayBuffer(i*Float32Array.BYTES_PER_ELEMENT),p=Math.min(navigator.hardwareConcurrency||1,i),g=Math.ceil(i/p),y=[],d=[];for(let w=0;w<p;w++){const k=w*g,L=Math.min((w+1)*g,i);if(k>=L)break;const T=t.slice(k,L);d.push(new Promise($=>{const M=new jr;y.push(M),M.postMessage({bufferX:this.dataX.buffer,bufferY:this.dataY.buffer,outputBufferX:f,outputBufferY:u,indexes:T,outStart:k,amount:r,isMonth:s,isYear:o,deltaMs:a}),M.onmessage=z=>{$(z.data)}}))}await Promise.all(d),y.forEach(w=>w.terminate());const h=new Float64Array(f),S=new Float32Array(u),b=new Array(i);for(let w=0;w<i;w++)b[w]=[h[w],S[w]];await this._deleteDataPoints(t),await this._addDataPoints(b)}async _fillGaps(t,r,n,s,o){const a=this.dataX.length;if(a===0)return;const i=t[0]*ee[t[1]]*1e3,l=r[0]*ee[r[1]]*1e3,f=o?.[0]??0,u=o?.[1]??a-1,p=this.dataX,g=[],y=[];let d=0;for(let A=f+1;A<=u;A++)if(p[A]-p[A-1]>i){let N=0,X=p[A-1]+l;for(;X<p[A];)N++,X+=l;N>0&&(g.push([A-1,A]),y.push(N),d+=N)}if(d===0)return;const h=a+d,S=h*Float64Array.BYTES_PER_ELEMENT,b=h*Float32Array.BYTES_PER_ELEMENT,w=new SharedArrayBuffer(S,{maxByteLength:Math.max(this.dataX.buffer.maxByteLength,S)}),k=new SharedArrayBuffer(b,{maxByteLength:Math.max(this.dataY.buffer.maxByteLength,b)});if(!D(E.FILL_GAPS,{datasetSize:a,selectionSize:d}).useWorker){const A=new Float64Array(w),W=new Float32Array(k);Jr(this.dataX,this.dataY,g,A,W,0,a-1,0,l,n,s),this.dataset.source.x=A,this.dataset.source.y=W,this._resizeTo(h);return}this._pendingExecutionMode="worker";const T=navigator.hardwareConcurrency||1,$=Math.ceil(a/T),M=[];let z=0;for(let A=0;A<T;A++){const W=A*$,N=Math.min((A+1)*$-1,a-1),X=[];let ye=0;for(;z<g.length&&g[z][0]<=N;)X.push(g[z]),ye+=y[z],z++;M.push({start:W,end:N,gapsSegment:X,fillsInSegment:ye})}const Ye=new Array(T).fill(0);for(let A=1;A<T;A++)Ye[A]=Ye[A-1]+M[A-1].fillsInSegment;const zt=[],Xt=[];for(let A=0;A<T;A++){const{start:W,end:N,gapsSegment:X}=M[A],ye=W+Ye[A];Xt.push(new Promise(gn=>{const He=new Fr;zt.push(He),He.postMessage({bufferX:this.dataX.buffer,bufferY:this.dataY.buffer,outputBufferX:w,outputBufferY:k,start:W,end:N,gapsSegment:X,startTarget:ye,fillDelta:l,interpolate:n,fillValue:s}),He.onmessage=mn=>{gn(mn.data)}}))}await Promise.all(Xt),zt.forEach(A=>A.terminate()),this.dataset.source.x=new Float64Array(w),this.dataset.source.y=new Float32Array(k),this._resizeTo(h)}async _deleteDataPoints(t){const r=this.dataX.length,n=r-t.length;if(!D(E.DELETE_POINTS,{datasetSize:r,selectionSize:t.length}).useWorker){const y=new SharedArrayBuffer(this.dataX.buffer.byteLength,{maxByteLength:this.dataX.buffer.maxByteLength}),d=new SharedArrayBuffer(this.dataY.buffer.byteLength,{maxByteLength:this.dataY.buffer.maxByteLength}),h=new Float64Array(y),S=new Float32Array(d);Qr(this.dataX,this.dataY,t,h,S,0,r-1,0),this.dataset.source.x=h,this.dataset.source.y=S,this._resizeTo(n);return}this._pendingExecutionMode="worker";const o=navigator.hardwareConcurrency||1,a=Math.ceil(this.dataX.length/o),i=[],l=[];for(let y=0;y<o;y++){const d=y*a,h=Math.min((y+1)*a-1,this.dataX.length-1),S=te(t,d),b=he(t,h),w=t.slice(S,b+1);l.push({start:d,end:h,deleteSegment:w})}const f=new Array(o).fill(0);for(let y=1;y<o;y++)f[y]=f[y-1]+l[y-1].deleteSegment.length;const u=[],p=new SharedArrayBuffer(this.dataX.buffer.byteLength,{maxByteLength:this.dataX.buffer.maxByteLength}),g=new SharedArrayBuffer(this.dataY.buffer.byteLength,{maxByteLength:this.dataY.buffer.maxByteLength});for(let y=0;y<o;y++){const{start:d,end:h,deleteSegment:S}=l[y],b=d-f[y];u.push(new Promise(w=>{const k=new Dr;i.push(k),k.postMessage({bufferX:this.dataX.buffer,bufferY:this.dataY.buffer,outputBufferX:p,outputBufferY:g,start:d,end:h,deleteSegment:S,startTarget:b}),k.onmessage=L=>{w(L.data)}}))}await Promise.all(u),i.forEach(y=>y.terminate()),this.dataset.source.x=new Float64Array(p),this.dataset.source.y=new Float32Array(g),this._resizeTo(n)}async _driftCorrection(t){if(!t||t.length===0)return;const r=this.dataset.source.x,n=navigator.hardwareConcurrency||1;let s=0;for(const[p,g]of t)g>p&&(s+=g-p);if(!D(E.DRIFT_CORRECTION,{datasetSize:r.length,selectionSize:s}).useWorker){tn(r,this.dataY,t);return}this._pendingExecutionMode="worker";const a=[];for(const[p,g,y]of t){if(g<=p)continue;const d=r[p],h=r[g]-d;if(h===0)continue;const S=g-p,b=Math.max(1,Math.ceil(S/n));for(let w=p;w<g;w+=b)a.push({chunkStart:w,chunkEnd:Math.min(w+b,g),startDatetime:d,value:y,extent:h})}if(a.length===0)return;const i=Math.min(n,a.length),l=Array.from({length:i},()=>[]);a.forEach((p,g)=>l[g%i].push(p));const f=[],u=[];for(const p of l)p.length!==0&&u.push(new Promise(g=>{const y=new Br;f.push(y),y.postMessage({bufferX:this.dataX.buffer,bufferY:this.dataY.buffer,jobs:p}),y.onmessage=d=>{g(d.data)}}));await Promise.all(u),f.forEach(p=>p.terminate())}_getConsecutiveGroups(t){const r=[[]];return t.reduce((n,s)=>{const o=n[n.length-1];return!o.length||s==o[o.length-1]+1?o.push(s):n.push([s]),n},r),r}async _addDataPoints(t){if(t.length===0)return;const r=this.dataX.length,n=r+t.length;t.sort((d,h)=>d[0]-h[0]);const s=n*Float64Array.BYTES_PER_ELEMENT,o=n*Float32Array.BYTES_PER_ELEMENT,a=new SharedArrayBuffer(s,{maxByteLength:Math.max(this.dataX.buffer.maxByteLength,s)}),i=new SharedArrayBuffer(o,{maxByteLength:Math.max(this.dataY.buffer.maxByteLength,o)});if(!D(E.ADD_POINTS,{datasetSize:r,selectionSize:t.length}).useWorker){const d=new Float64Array(a),h=new Float32Array(i);Kr(this.dataX,this.dataY,t,d,h,0,r,0),this.dataset.source.x=d,this.dataset.source.y=h,this._resizeTo(n);return}this._pendingExecutionMode="worker";const f=t.map(d=>he(this.dataX,d[0])+1),u=Math.max(1,Math.min(navigator.hardwareConcurrency||1,Math.max(r,1))),p=Math.ceil(Math.max(r,1)/u),g=[],y=[];for(let d=0;d<u;d++){const h=d*p,S=Math.min((d+1)*p,r),b=te(f,h),w=d===u-1?t.length:te(f,S),k=t.slice(b,w),L=h+b;h>=S&&k.length===0||y.push(new Promise(T=>{const $=new Nr;g.push($),$.postMessage({bufferX:this.dataX.buffer,bufferY:this.dataY.buffer,outputBufferX:a,outputBufferY:i,origStart:h,origEnd:S,insertions:k,outStart:L}),$.onmessage=M=>{T(M.data)}}))}await Promise.all(y),g.forEach(d=>d.terminate()),this.dataset.source.x=new Float64Array(a),this.dataset.source.y=new Float32Array(i),this._resizeTo(n)}async _valueThreshold(t){const r=Object.keys(t);if(r.length===0)return[];const n={[x.LT]:0,[x.LTE]:1,[x.GT]:2,[x.GTE]:3,[x.E]:4},s=r.map(h=>n[h]??4),o=r.map(h=>t[h]),a=this.dataset.source.y,i=a.length;if(i===0)return[];if(!D(v.VALUE_THRESHOLD,{datasetSize:i}).useWorker)return Gt(a,0,i,s,o);this._pendingExecutionMode="worker";const f=Math.min(navigator.hardwareConcurrency||1,i),u=Math.ceil(i/f),p=[],g=[];for(let h=0;h<f;h++){const S=h*u,b=Math.min((h+1)*u,i);if(S>=b)break;g.push(new Promise(w=>{const k=new Pe;p.push(k),k.postMessage({bufferY:this.dataY.buffer,start:S,end:b,ops:s,values:o}),k.onmessage=L=>{w(L.data)}}))}const y=await Promise.all(g);p.forEach(h=>h.terminate());const d=[];for(let h=0;h<y.length;h++){const S=y[h];for(let b=0;b<S.length;b++)d.push(S[b])}return d}async _rateOfChange(t,r){const n=this.dataset.source.y;if(n.length<2)return[];const s=1,o=n.length,a=o-s;if(!D(v.RATE_OF_CHANGE,{datasetSize:n.length}).useWorker)return Xr(n,s,o,t,r);this._pendingExecutionMode="worker";const l=Math.min(navigator.hardwareConcurrency||1,a),f=Math.ceil(a/l),u=[],p=[];for(let d=0;d<l;d++){const h=s+d*f,S=Math.min(s+(d+1)*f,o);if(h>=S)break;p.push(new Promise(b=>{const w=new Yr;u.push(w),w.postMessage({bufferY:this.dataY.buffer,start:h,end:S,comparator:t,value:r}),w.onmessage=k=>{b(k.data)}}))}const g=await Promise.all(p);u.forEach(d=>d.terminate());const y=[];for(let d=0;d<g.length;d++){const h=g[d];for(let S=0;S<h.length;S++)y.push(h[S])}return y}async _datetimeRange(t,r){const n=this.dataset.source.x,s=n.length;if(s===0)return[];const o=t==null?0:te(n,t),a=r==null?s-1:he(n,r);if(o>a)return[];const i=new Array(a-o+1);for(let l=o;l<=a;l++)i[l-o]=l;return i}async _selection(t){return(!t||!t.length)&&this.history.pop(),t}async _change(t,r){const n=this.dataset.source.y;if(n.length<2)return[];const s=1,o=n.length,a=o-s;if(!D(v.CHANGE,{datasetSize:n.length}).useWorker)return zr(n,s,o,t,r);this._pendingExecutionMode="worker";const l=Math.min(navigator.hardwareConcurrency||1,a),f=Math.ceil(a/l),u=[],p=[];for(let d=0;d<l;d++){const h=s+d*f,S=Math.min(s+(d+1)*f,o);if(h>=S)break;p.push(new Promise(b=>{const w=new Gr;u.push(w),w.postMessage({bufferY:this.dataY.buffer,start:h,end:S,comparator:t,value:r}),w.onmessage=k=>{b(k.data)}}))}const g=await Promise.all(p);u.forEach(d=>d.terminate());const y=[];for(let d=0;d<g.length;d++){const h=g[d];for(let S=0;S<h.length;S++)y.push(h[S])}return y}async _findGaps(t,r,n){const s=this.dataset.source.x;let o=0,a=s.length;if(n?.[0]&&n?.[1]&&(o=n[0],a=n[1]),a<=o)return[];const i=t*ee[r]*1e3;if(!D(v.FIND_GAPS,{datasetSize:a-o}).useWorker){const S=Vr(s,o,a-1,i),b=new Set;for(let w=0;w<S.length;w++)b.add(S[w]);return[...b]}this._pendingExecutionMode="worker";const f=a-o,u=Math.min(navigator.hardwareConcurrency||1,f),p=Math.ceil(f/u),g=[],y=[];for(let S=0;S<u;S++){const b=o+S*p,w=Math.min(o+(S+1)*p,a);if(b>=w)break;y.push(new Promise(k=>{const L=new Wr;g.push(L),L.postMessage({bufferX:this.dataX.buffer,start:b,endInclusive:w,threshold:i}),L.onmessage=T=>{k(T.data)}}))}const d=await Promise.all(y);g.forEach(S=>S.terminate());const h=new Set;for(let S=0;S<d.length;S++){const b=d[S];for(let w=0;w<b.length;w++)h.add(b[w])}return[...h]}async _persistence(t,r){const n=this.dataset.source.y;let s=0,o=n.length;if(r?.[0]&&r?.[1]&&(s=r[0],o=r[1]),o<=s)return[];const a=o-s;if(!D(v.PERSISTENCE,{datasetSize:a}).useWorker){const b=qr(n,s,o),w=[];for(let k=0;k<b.length;k+=3){const L=b[k],T=b[k+1];if(T>=t)for(let $=0;$<T;$++)w.push(L+$)}return w}this._pendingExecutionMode="worker";const l=Math.min(navigator.hardwareConcurrency||1,a),f=Math.ceil(a/l),u=[],p=[];for(let b=0;b<l;b++){const w=s+b*f,k=Math.min(s+(b+1)*f,o);if(w>=k)break;p.push(new Promise(L=>{const T=new xr;u.push(T),T.postMessage({bufferY:this.dataY.buffer,start:w,end:k}),T.onmessage=$=>{L($.data)}}))}const g=await Promise.all(p);u.forEach(b=>b.terminate());const y=[],d=[],h=[];for(let b=0;b<g.length;b++){const w=g[b];for(let k=0;k<w.length;k+=3){const L=w[k],T=w[k+1],$=w[k+2],M=y.length-1;M>=0&&h[M]===$&&y[M]+d[M]===L?d[M]+=T:(y.push(L),d.push(T),h.push($))}}const S=[];for(let b=0;b<y.length;b++){const w=d[b];if(w>=t){const k=y[b];for(let L=0;L<w;L++)S.push(k+L)}}return S}}m.ACCOUNT_BASE=F,m.AUTH_BASE=ie,m.ApiKey=ar,m.BASE_URL=C,m.Collaborator=ir,m.DEFAULT_SNACK_DURATION=Le,m.DataSource=Ar,m.Datastream=Jt,m.EnumEditOperations=E,m.EnumFilterOperations=v,m.FilterOperation=x,m.HydroShareArchive=Ve,m.INCREASE_AMOUNT=K,m.Location=qe,m.LogicalOperation=Xe,m.OAuthProvider=sr,m.ObservationRecord=yn,m.ObservedProperty=Zt,m.Operator=ze,m.Organization=rr,m.PROVIDER_BASE=Q,m.Payload=$r,m.PermissionAction=Je,m.PermissionResource=Ke,m.Position=lt,m.PostHydroShareArchive=Vt,m.ProcessingLevel=er,m.ResultQualifier=tr,m.SESSION_BASE=ce,m.Sensor=Qt,m.Snack=ut,m.SnackColor=Te,m.SnackIcon=$e,m.SnackTitle=Re,m.Snackbar=ht,m.TAG_BASE=Ce,m.THINGS_BASE=_,m.Thing=qt,m.TimeUnit=O,m.Unit=Kt,m.User=nr,m.Workspace=or,m.api=Tr,m.apiMethods=c,m.clearCalibration=ln,m.createPatchObject=Ie,m.ensureCalibration=un,m.extractErrorMessage=Qe,m.findFirstGreaterOrEqual=te,m.findLastLessOrEqual=he,m.formatDate=Ur,m.formatDuration=Mr,m.getCSRFToken=ge,m.getCalibration=an,m.getLastBenchmarkDetail=on,m.getObservationsEndpoint=Lr,m.getOperationTable=cn,m.measureEllapsedTime=ue,m.onCalibrationChange=sn,m.requestInterceptor=me,m.responseInterceptor=we,m.runBenchmarks=Ht,m.shouldUseWorker=D,m.subtractHours=Cr,m.timeUnitMultipliers=ee,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
package/dist/index.d.ts
DELETED
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
import { Datastream } from '@/types';
|
|
2
|
-
import { Payload } from './payload';
|
|
3
|
-
import { Timestamp } from './timestamp';
|
|
4
|
-
export declare const WORKFLOW_TYPES: readonly [{
|
|
5
|
-
readonly title: "ETL";
|
|
6
|
-
readonly value: "ETL";
|
|
7
|
-
}, {
|
|
8
|
-
readonly title: "HydroServer aggregation";
|
|
9
|
-
readonly value: "Aggregation";
|
|
10
|
-
}, {
|
|
11
|
-
readonly title: "HydroServer virtual datastream";
|
|
12
|
-
readonly value: "Virtual";
|
|
13
|
-
}, {
|
|
14
|
-
readonly title: "Streaming Data Loader";
|
|
15
|
-
readonly value: "SDL";
|
|
16
|
-
}];
|
|
17
|
-
export type WorkflowType = (typeof WORKFLOW_TYPES)[number]['value'];
|
|
18
|
-
export declare const CSV_DELIMITER_OPTIONS: readonly [{
|
|
19
|
-
readonly value: ",";
|
|
20
|
-
readonly title: "Comma";
|
|
21
|
-
}, {
|
|
22
|
-
readonly value: "|";
|
|
23
|
-
readonly title: "Pipe";
|
|
24
|
-
}, {
|
|
25
|
-
readonly value: "\t";
|
|
26
|
-
readonly title: "Tab";
|
|
27
|
-
}, {
|
|
28
|
-
readonly value: ";";
|
|
29
|
-
readonly title: "Semicolon";
|
|
30
|
-
}, {
|
|
31
|
-
readonly value: " ";
|
|
32
|
-
readonly title: "Space";
|
|
33
|
-
}];
|
|
34
|
-
export type CSVDelimiterType = (typeof CSV_DELIMITER_OPTIONS)[number]['value'];
|
|
35
|
-
export interface PerPayloadPlaceholder {
|
|
36
|
-
name: string;
|
|
37
|
-
type: 'perPayload';
|
|
38
|
-
}
|
|
39
|
-
export interface RunTimePlaceholder {
|
|
40
|
-
name: string;
|
|
41
|
-
type: 'runTime';
|
|
42
|
-
runTimeValue: 'startTime' | 'now';
|
|
43
|
-
timestamp: Timestamp;
|
|
44
|
-
}
|
|
45
|
-
export type PlaceholderVariable = PerPayloadPlaceholder | RunTimePlaceholder;
|
|
46
|
-
export declare const EXTRACTOR_OPTIONS: readonly ["HTTP", "local"];
|
|
47
|
-
export type ExtractorType = (typeof EXTRACTOR_OPTIONS)[number];
|
|
48
|
-
export type ETLStep = 'extractor' | 'transformer' | 'loader';
|
|
49
|
-
interface BaseExtractor {
|
|
50
|
-
type: ExtractorType;
|
|
51
|
-
sourceUri: string;
|
|
52
|
-
placeholderVariables: PlaceholderVariable[];
|
|
53
|
-
}
|
|
54
|
-
export interface HTTPExtractor extends BaseExtractor {
|
|
55
|
-
type: 'HTTP';
|
|
56
|
-
}
|
|
57
|
-
export interface LocalFileExtractor extends BaseExtractor {
|
|
58
|
-
type: 'local';
|
|
59
|
-
}
|
|
60
|
-
export type ExtractorConfig = HTTPExtractor | LocalFileExtractor;
|
|
61
|
-
export declare const extractorDefaults: Record<ExtractorType, ExtractorConfig>;
|
|
62
|
-
export declare const TRANSFORMER_OPTIONS: readonly ["JSON", "CSV"];
|
|
63
|
-
export type TransformerType = (typeof TRANSFORMER_OPTIONS)[number];
|
|
64
|
-
export declare enum IdentifierType {
|
|
65
|
-
Name = "name",
|
|
66
|
-
Index = "index"
|
|
67
|
-
}
|
|
68
|
-
interface BaseTransformer {
|
|
69
|
-
type: TransformerType;
|
|
70
|
-
timestamp: Timestamp;
|
|
71
|
-
}
|
|
72
|
-
export interface JSONtransformer extends BaseTransformer {
|
|
73
|
-
type: 'JSON';
|
|
74
|
-
JMESPath: string;
|
|
75
|
-
}
|
|
76
|
-
export interface CSVTransformer extends BaseTransformer {
|
|
77
|
-
type: 'CSV';
|
|
78
|
-
headerRow: number | null;
|
|
79
|
-
dataStartRow: number;
|
|
80
|
-
delimiter: CSVDelimiterType;
|
|
81
|
-
identifierType: IdentifierType;
|
|
82
|
-
}
|
|
83
|
-
export type TransformerConfig = JSONtransformer | CSVTransformer;
|
|
84
|
-
export declare const transformerDefaults: Record<TransformerType, TransformerConfig>;
|
|
85
|
-
export declare const LOADER_OPTIONS: readonly ["HydroServer"];
|
|
86
|
-
export type LoaderType = (typeof LOADER_OPTIONS)[number];
|
|
87
|
-
interface BaseLoaderConfig {
|
|
88
|
-
type: LoaderType;
|
|
89
|
-
}
|
|
90
|
-
interface HydroServerLoaderConfig extends BaseLoaderConfig {
|
|
91
|
-
type: 'HydroServer';
|
|
92
|
-
}
|
|
93
|
-
export type LoaderConfig = HydroServerLoaderConfig;
|
|
94
|
-
export declare const loaderDefaults: Record<LoaderType, LoaderConfig>;
|
|
95
|
-
interface EtlConfiguration {
|
|
96
|
-
type: WorkflowType;
|
|
97
|
-
extractor: ExtractorConfig;
|
|
98
|
-
transformer: TransformerConfig;
|
|
99
|
-
loader: LoaderConfig;
|
|
100
|
-
payloads: Payload[];
|
|
101
|
-
}
|
|
102
|
-
export type PartialDatastream = Pick<Datastream, 'name' | 'description' | 'noDataValue' | 'valueCount' | 'phenomenonBeginTime' | 'phenomenonEndTime' | 'aggregationStatistic' | 'timeAggregationInterval' | 'timeAggregationIntervalUnit' | 'intendedTimeSpacing' | 'intendedTimeSpacingUnit'>;
|
|
103
|
-
export declare const DATASOURCE_STATUS_OPTIONS: readonly [{
|
|
104
|
-
readonly color: "green";
|
|
105
|
-
readonly title: "OK";
|
|
106
|
-
}, {
|
|
107
|
-
readonly color: "blue";
|
|
108
|
-
readonly title: "Pending";
|
|
109
|
-
}, {
|
|
110
|
-
readonly color: "red";
|
|
111
|
-
readonly title: "Needs attention";
|
|
112
|
-
}, {
|
|
113
|
-
readonly color: "orange-darken-4";
|
|
114
|
-
readonly title: "Behind schedule";
|
|
115
|
-
}, {
|
|
116
|
-
readonly color: "gray";
|
|
117
|
-
readonly title: "Unknown";
|
|
118
|
-
}, {
|
|
119
|
-
readonly color: "gray";
|
|
120
|
-
readonly title: "Loading paused";
|
|
121
|
-
}];
|
|
122
|
-
export type StatusType = (typeof DATASOURCE_STATUS_OPTIONS)[number]['title'];
|
|
123
|
-
export declare const INTERVAL_UNIT_OPTIONS: {
|
|
124
|
-
value: string;
|
|
125
|
-
title: string;
|
|
126
|
-
}[];
|
|
127
|
-
export type IntervalUnitType = (typeof INTERVAL_UNIT_OPTIONS)[number]['value'];
|
|
128
|
-
export interface Schedule {
|
|
129
|
-
interval: number;
|
|
130
|
-
intervalUnits?: IntervalUnitType;
|
|
131
|
-
crontab?: string;
|
|
132
|
-
startTime?: string;
|
|
133
|
-
endTime?: string;
|
|
134
|
-
}
|
|
135
|
-
export interface Status {
|
|
136
|
-
lastRunSuccessful?: boolean;
|
|
137
|
-
lastRunMessage?: string;
|
|
138
|
-
lastRun?: string;
|
|
139
|
-
nextRun?: string;
|
|
140
|
-
paused: boolean;
|
|
141
|
-
}
|
|
142
|
-
export interface OrchestrationSystem {
|
|
143
|
-
name: string;
|
|
144
|
-
id: string;
|
|
145
|
-
workspaceId: string;
|
|
146
|
-
type: string;
|
|
147
|
-
}
|
|
148
|
-
export declare class DataSource {
|
|
149
|
-
name: string;
|
|
150
|
-
settings: EtlConfiguration;
|
|
151
|
-
id: string;
|
|
152
|
-
workspaceId: string;
|
|
153
|
-
orchestrationSystem: OrchestrationSystem;
|
|
154
|
-
schedule: Schedule;
|
|
155
|
-
status: Status;
|
|
156
|
-
datastreams: Datastream[];
|
|
157
|
-
constructor(init?: Partial<DataSource>);
|
|
158
|
-
switchExtractor(newType: ExtractorType): void;
|
|
159
|
-
switchTransformer(newType: TransformerType): void;
|
|
160
|
-
switchLoader(newType: LoaderType): void;
|
|
161
|
-
}
|
|
162
|
-
export declare function convertDataSourceToPostObject(dataSource: DataSource): {
|
|
163
|
-
name: string;
|
|
164
|
-
settings: EtlConfiguration;
|
|
165
|
-
workspaceId: string;
|
|
166
|
-
orchestrationSystemId: string;
|
|
167
|
-
schedule: Schedule;
|
|
168
|
-
status: Status;
|
|
169
|
-
};
|
|
170
|
-
export declare function getStatusText({ lastRun, lastRunSuccessful, nextRun, paused, }: Status): StatusType;
|
|
171
|
-
export declare function getBadCountText(statusArray: Status[]): string;
|
|
172
|
-
export declare function getBehindScheduleCountText(statusArray: Status[]): string;
|
|
173
|
-
export {};
|
package/dist/models/index.d.ts
DELETED
package/dist/models/payload.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export interface ExpressionDataTransformation {
|
|
2
|
-
type: 'expression';
|
|
3
|
-
expression: string;
|
|
4
|
-
}
|
|
5
|
-
export interface LookupTableDataTransformation {
|
|
6
|
-
lookupTableId: string;
|
|
7
|
-
type: 'lookup';
|
|
8
|
-
}
|
|
9
|
-
export type DataTransformation = ExpressionDataTransformation | LookupTableDataTransformation;
|
|
10
|
-
export interface MappingPath {
|
|
11
|
-
targetIdentifier: string | number;
|
|
12
|
-
dataTransformations: DataTransformation[];
|
|
13
|
-
}
|
|
14
|
-
export interface Mapping {
|
|
15
|
-
sourceIdentifier: string | number;
|
|
16
|
-
paths: MappingPath[];
|
|
17
|
-
}
|
|
18
|
-
export declare class Payload {
|
|
19
|
-
name: string;
|
|
20
|
-
mappings: Mapping[];
|
|
21
|
-
extractorVariables: Record<string, string>;
|
|
22
|
-
constructor(init?: Partial<Payload>);
|
|
23
|
-
}
|
|
24
|
-
export declare function addMapping(payload: Payload): void;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
export interface Provider {
|
|
2
|
-
id: string;
|
|
3
|
-
name: string;
|
|
4
|
-
iconLink: string | null;
|
|
5
|
-
signupEnabled: boolean;
|
|
6
|
-
connectEnabled: boolean;
|
|
7
|
-
}
|
|
8
|
-
export interface AuthenticationConfiguration {
|
|
9
|
-
hydroserverSignupEnabled: boolean;
|
|
10
|
-
providers: Provider[];
|
|
11
|
-
}
|
|
12
|
-
export interface ContactOption {
|
|
13
|
-
title: string;
|
|
14
|
-
text: string | null;
|
|
15
|
-
action: string | null;
|
|
16
|
-
icon: string | null;
|
|
17
|
-
link: string | null;
|
|
18
|
-
}
|
|
19
|
-
export interface AboutInformation {
|
|
20
|
-
showAboutInformation: boolean;
|
|
21
|
-
title: string | null;
|
|
22
|
-
text: string | null;
|
|
23
|
-
contactOptions: ContactOption[];
|
|
24
|
-
}
|
|
25
|
-
export declare enum ElevationService {
|
|
26
|
-
OpenElevation = "openElevation",
|
|
27
|
-
Google = "google"
|
|
28
|
-
}
|
|
29
|
-
export declare enum GeoService {
|
|
30
|
-
Nominatim = "nominatim",
|
|
31
|
-
Google = "google"
|
|
32
|
-
}
|
|
33
|
-
export interface MapLayer {
|
|
34
|
-
name: string;
|
|
35
|
-
source: string;
|
|
36
|
-
attribution: string;
|
|
37
|
-
priority?: number | null;
|
|
38
|
-
}
|
|
39
|
-
export interface MapConfiguration {
|
|
40
|
-
defaultLatitude: number;
|
|
41
|
-
defaultLongitude: number;
|
|
42
|
-
defaultZoomLevel: number;
|
|
43
|
-
defaultBaseLayer: string;
|
|
44
|
-
defaultSatelliteLayer: string;
|
|
45
|
-
elevationService: ElevationService;
|
|
46
|
-
geoService: GeoService;
|
|
47
|
-
basemapLayers: MapLayer[];
|
|
48
|
-
overlayLayers: MapLayer[];
|
|
49
|
-
}
|
|
50
|
-
export interface AnalyticsConfiguration {
|
|
51
|
-
enableClarityAnalytics: boolean;
|
|
52
|
-
clarityProjectId?: string | null;
|
|
53
|
-
}
|
|
54
|
-
export interface LegalInformation {
|
|
55
|
-
termsOfUseLink?: string | null;
|
|
56
|
-
privacyPolicyLink?: string | null;
|
|
57
|
-
copyright?: string | null;
|
|
58
|
-
}
|
|
59
|
-
export interface AppSettings {
|
|
60
|
-
authenticationConfiguration: AuthenticationConfiguration;
|
|
61
|
-
aboutInformation: AboutInformation;
|
|
62
|
-
mapConfiguration: MapConfiguration;
|
|
63
|
-
analyticsConfiguration: AnalyticsConfiguration;
|
|
64
|
-
legalInformation: LegalInformation;
|
|
65
|
-
}
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
export declare const FIXED_OFFSET_TIMEZONES: readonly [{
|
|
2
|
-
readonly title: "UTC-12:00 (International Date Line West)";
|
|
3
|
-
readonly value: "-1200";
|
|
4
|
-
}, {
|
|
5
|
-
readonly title: "UTC-11:00 (Samoa Standard Time)";
|
|
6
|
-
readonly value: "-1100";
|
|
7
|
-
}, {
|
|
8
|
-
readonly title: "UTC-10:00 (Hawaii-Aleutian Standard Time)";
|
|
9
|
-
readonly value: "-1000";
|
|
10
|
-
}, {
|
|
11
|
-
readonly title: "UTC-09:00 (Alaska Standard Time)";
|
|
12
|
-
readonly value: "-0900";
|
|
13
|
-
}, {
|
|
14
|
-
readonly title: "UTC-08:00 (Pacific Standard Time)";
|
|
15
|
-
readonly value: "-0800";
|
|
16
|
-
}, {
|
|
17
|
-
readonly title: "UTC-07:00 (Mountain Standard Time)";
|
|
18
|
-
readonly value: "-0700";
|
|
19
|
-
}, {
|
|
20
|
-
readonly title: "UTC-06:00 (Central Standard Time)";
|
|
21
|
-
readonly value: "-0600";
|
|
22
|
-
}, {
|
|
23
|
-
readonly title: "UTC-05:00 (Eastern Standard Time)";
|
|
24
|
-
readonly value: "-0500";
|
|
25
|
-
}, {
|
|
26
|
-
readonly title: "UTC-04:30 (Venezuelan Standard Time)";
|
|
27
|
-
readonly value: "-0430";
|
|
28
|
-
}, {
|
|
29
|
-
readonly title: "UTC-04:00 (Atlantic Standard Time)";
|
|
30
|
-
readonly value: "-0400";
|
|
31
|
-
}, {
|
|
32
|
-
readonly title: "UTC-03:30 (Newfoundland Standard Time)";
|
|
33
|
-
readonly value: "-0330";
|
|
34
|
-
}, {
|
|
35
|
-
readonly title: "UTC-03:00 (Argentina Standard Time)";
|
|
36
|
-
readonly value: "-0300";
|
|
37
|
-
}, {
|
|
38
|
-
readonly title: "UTC-02:00 (Brazil Time)";
|
|
39
|
-
readonly value: "-0200";
|
|
40
|
-
}, {
|
|
41
|
-
readonly title: "UTC-01:00 (Azores Standard Time)";
|
|
42
|
-
readonly value: "-0100";
|
|
43
|
-
}, {
|
|
44
|
-
readonly title: "UTC+00:00 (Greenwich Mean Time)";
|
|
45
|
-
readonly value: "+0000";
|
|
46
|
-
}, {
|
|
47
|
-
readonly title: "UTC+01:00 (Central European Time)";
|
|
48
|
-
readonly value: "+0100";
|
|
49
|
-
}, {
|
|
50
|
-
readonly title: "UTC+02:00 (Eastern European Time)";
|
|
51
|
-
readonly value: "+0200";
|
|
52
|
-
}, {
|
|
53
|
-
readonly title: "UTC+03:00 (Moscow Standard Time)";
|
|
54
|
-
readonly value: "+0300";
|
|
55
|
-
}, {
|
|
56
|
-
readonly title: "UTC+03:30 (Iran Standard Time)";
|
|
57
|
-
readonly value: "+0330";
|
|
58
|
-
}, {
|
|
59
|
-
readonly title: "UTC+04:00 (Azerbaijan Standard Time)";
|
|
60
|
-
readonly value: "+0400";
|
|
61
|
-
}, {
|
|
62
|
-
readonly title: "UTC+04:30 (Afghanistan Time)";
|
|
63
|
-
readonly value: "+0430";
|
|
64
|
-
}, {
|
|
65
|
-
readonly title: "UTC+05:00 (Pakistan Standard Time)";
|
|
66
|
-
readonly value: "+0500";
|
|
67
|
-
}, {
|
|
68
|
-
readonly title: "UTC+05:30 (Indian Standard Time)";
|
|
69
|
-
readonly value: "+0530";
|
|
70
|
-
}, {
|
|
71
|
-
readonly title: "UTC+05:45 (Nepal Time)";
|
|
72
|
-
readonly value: "+0545";
|
|
73
|
-
}, {
|
|
74
|
-
readonly title: "UTC+06:00 (Bangladesh Standard Time)";
|
|
75
|
-
readonly value: "+0600";
|
|
76
|
-
}, {
|
|
77
|
-
readonly title: "UTC+06:30 (Cocos Islands Time)";
|
|
78
|
-
readonly value: "+0630";
|
|
79
|
-
}, {
|
|
80
|
-
readonly title: "UTC+07:00 (Indochina Time)";
|
|
81
|
-
readonly value: "+0700";
|
|
82
|
-
}, {
|
|
83
|
-
readonly title: "UTC+08:00 (China Standard Time)";
|
|
84
|
-
readonly value: "+0800";
|
|
85
|
-
}, {
|
|
86
|
-
readonly title: "UTC+08:45 (Australia Central Western Standard Time)";
|
|
87
|
-
readonly value: "+0845";
|
|
88
|
-
}, {
|
|
89
|
-
readonly title: "UTC+09:00 (Japan Standard Time)";
|
|
90
|
-
readonly value: "+0900";
|
|
91
|
-
}, {
|
|
92
|
-
readonly title: "UTC+09:30 (Australian Central Standard Time)";
|
|
93
|
-
readonly value: "+0930";
|
|
94
|
-
}, {
|
|
95
|
-
readonly title: "UTC+10:00 (Australian Eastern Standard Time)";
|
|
96
|
-
readonly value: "+1000";
|
|
97
|
-
}, {
|
|
98
|
-
readonly title: "UTC+10:30 (Lord Howe Standard Time)";
|
|
99
|
-
readonly value: "+1030";
|
|
100
|
-
}, {
|
|
101
|
-
readonly title: "UTC+11:00 (Solomon Islands Time)";
|
|
102
|
-
readonly value: "+1100";
|
|
103
|
-
}, {
|
|
104
|
-
readonly title: "UTC+11:30 (Norfolk Island Time)";
|
|
105
|
-
readonly value: "+1130";
|
|
106
|
-
}, {
|
|
107
|
-
readonly title: "UTC+12:00 (Fiji Time)";
|
|
108
|
-
readonly value: "+1200";
|
|
109
|
-
}, {
|
|
110
|
-
readonly title: "UTC+12:45 (Chatham Islands Time)";
|
|
111
|
-
readonly value: "+1245";
|
|
112
|
-
}, {
|
|
113
|
-
readonly title: "UTC+13:00 (Tonga Time)";
|
|
114
|
-
readonly value: "+1300";
|
|
115
|
-
}, {
|
|
116
|
-
readonly title: "UTC+14:00 (Line Islands Time)";
|
|
117
|
-
readonly value: "+1400";
|
|
118
|
-
}];
|
|
119
|
-
export type FixedOffsetTimezone = (typeof FIXED_OFFSET_TIMEZONES)[number]['value'];
|
|
120
|
-
export declare const DST_AWARE_TIMEZONES: {
|
|
121
|
-
title: string;
|
|
122
|
-
value: string;
|
|
123
|
-
}[];
|
|
124
|
-
export type DstAwareTimezone = (typeof DST_AWARE_TIMEZONES)[number]['value'];
|
|
125
|
-
export declare const TIMESTAMP_FORMATS: readonly [{
|
|
126
|
-
readonly text: "Full ISO 8601 (YYYY-MM-DD hh:mm:ss.ssss+hh:mm)";
|
|
127
|
-
readonly value: "ISO8601";
|
|
128
|
-
}, {
|
|
129
|
-
readonly text: "Timezone naive (YYYY-MM-DD hh:mm:ss)";
|
|
130
|
-
readonly value: "naive";
|
|
131
|
-
}, {
|
|
132
|
-
readonly text: "Custom Format";
|
|
133
|
-
readonly value: "custom";
|
|
134
|
-
}];
|
|
135
|
-
export type TimestampFormat = (typeof TIMESTAMP_FORMATS)[number]['value'];
|
|
136
|
-
export type TimezoneMode = 'utc' | 'daylightSavings' | 'fixedOffset' | 'embeddedOffset';
|
|
137
|
-
export interface Timestamp {
|
|
138
|
-
key?: string;
|
|
139
|
-
format: TimestampFormat;
|
|
140
|
-
customFormat?: string;
|
|
141
|
-
/**
|
|
142
|
-
* Determines how we interpret the timestamp’s timezone:
|
|
143
|
-
* - `utc`: timestamp is naive and UTC
|
|
144
|
-
* - `daylightSavings`: use an IANA zone from DST_AWARE_TIMEZONES
|
|
145
|
-
* - `fixedOffset`: use a value from FIXED_OFFSET_TIMEZONES
|
|
146
|
-
* - `embeddedOffset`: rely on the ±HH:MM in the ISO8601 string
|
|
147
|
-
*/
|
|
148
|
-
timezoneMode: TimezoneMode;
|
|
149
|
-
timezone?: FixedOffsetTimezone | DstAwareTimezone;
|
|
150
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|