@uwrl/qc-utils 0.0.20 → 0.0.21

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.
@@ -1,15 +1,15 @@
1
- (function(m,O){typeof exports=="object"&&typeof module<"u"?O(exports):typeof define=="function"&&define.amd?define(["exports"],O):(m=typeof globalThis<"u"?globalThis:m||self,O(m["@uwrl/qc-utils"]={}))})(this,(function(m){"use strict";var O=(e=>(e.SECOND="s",e.MINUTE="m",e.HOUR="h",e.DAY="D",e.WEEK="W",e.MONTH="M",e.YEAR="Y",e))(O||{}),E=(e=>(e.ADD_POINTS="ADD_POINTS",e.CHANGE_VALUES="CHANGE_VALUES",e.ASSIGN_VALUES_BULK="ASSIGN_VALUES_BULK",e.DELETE_POINTS="DELETE_POINTS",e.DRIFT_CORRECTION="DRIFT_CORRECTION",e.INTERPOLATE="INTERPOLATE",e.SHIFT_DATETIMES="SHIFT_DATETIMES",e.ASSIGN_DATETIMES_BULK="ASSIGN_DATETIMES_BULK",e.FILL_GAPS="FILL_GAPS",e))(E||{}),v=(e=>(e.FIND_GAPS="FIND_GAPS",e.PERSISTENCE="PERSISTENCE",e.CHANGE="CHANGE",e.RATE_OF_CHANGE="RATE_OF_CHANGE",e.VALUE_THRESHOLD="VALUE_THRESHOLD",e.DATETIME_RANGE="DATETIME_RANGE",e.SELECTION="SELECTION",e))(v||{}),G=(e=>(e.LT="Less than",e.LTE="Less than or equal to",e.GT="Greater than",e.GTE="Greater than or equal to",e.E="Equal",e))(G||{}),Xe=(e=>(e.ADD="ADD",e.SUB="SUB",e.MULT="MULT",e.DIV="DIV",e.ASSIGN="ASSIGN",e))(Xe||{}),Ve=(e=>(e.LT="Less than",e.LTE="Less than or equal to",e.GT="Greater than",e.GTE="Greater than or equal to",e.E="Equal",e))(Ve||{});class qe{id;thingId;link;frequency;path;datastreamIds;publicResource;constructor(){this.id="",this.thingId="",this.link="",this.frequency=null,this.path="HydroShare",this.datastreamIds=[],this.publicResource=!1}}class Jt extends qe{resourceTitle;resourceAbstract;resourceKeywords;constructor(){super(),this.resourceTitle=void 0,this.resourceAbstract=void 0,this.resourceKeywords=void 0}}class Je{latitude;longitude;elevation_m;elevationDatum;state;county;country;constructor(){this.elevationDatum="WGS84",this.state="",this.county="",this.country=""}}class Kt{id;workspaceId;name;location=new Je;tags;hydroShareArchive;siteType;samplingFeatureCode;isPrivate;description;samplingFeatureType;dataDisclaimer;constructor(){this.id="",this.workspaceId="",this.name="",this.tags=[],this.siteType="",this.samplingFeatureCode="",this.isPrivate=!1,this.description="",this.samplingFeatureType="Site",this.dataDisclaimer=""}}class Qt{id;workspaceId;name;description;thingId;observationType;resultType;status;sampledMedium;noDataValue;aggregationStatistic;unitId;observedPropertyId;sensorId;processingLevelId;isPrivate;isVisible;phenomenonBeginTime;phenomenonEndTime;intendedTimeSpacing;intendedTimeSpacingUnit;timeAggregationInterval;timeAggregationIntervalUnit;dataSourceId;valueCount;constructor(t){this.id="",this.workspaceId="",this.name="",this.description="",this.thingId=t||"",this.observationType="OM_Measurement",this.resultType="Time Series Coverage",this.sampledMedium="",this.noDataValue=-9999,this.aggregationStatistic="",this.unitId="",this.observedPropertyId="",this.sensorId="",this.processingLevelId="",this.timeAggregationInterval=null,this.timeAggregationIntervalUnit="seconds",this.isPrivate=!0,this.isVisible=!0,this.valueCount=0}}class Zt{id;workspaceId;name;symbol;definition;type;constructor(){this.id="",this.workspaceId="",this.name="",this.symbol="",this.definition="",this.type=""}}class er{id;workspaceId;name;description;manufacturer;model;methodType;methodCode;methodLink;encodingType;modelLink;constructor(){this.id="",this.workspaceId="",this.name="",this.description="",this.manufacturer="",this.model="",this.methodType="Instrument Deployment",this.methodCode="",this.methodLink="",this.encodingType="application/json",this.modelLink=""}}class tr{id;workspaceId;name;definition;description;type;code;constructor(){this.id="",this.workspaceId="",this.name="",this.definition="",this.description="",this.type="Hydrology",this.code=""}}class rr{id;workspaceId;code;definition;explanation;constructor(){this.id="",this.workspaceId="",this.code="",this.definition="",this.explanation=""}}class nr{id;workspaceId;code;description;constructor(){this.id="",this.workspaceId="",this.code="",this.description=""}}class sr{name;code;type;description;link;constructor(){}}class or{id;email;password;firstName;middleName;lastName;phone;address;organization;type;link;accountType;hydroShareConnected;constructor(){this.id="",this.email="",this.password="",this.firstName="",this.middleName="",this.lastName="",this.phone="",this.address="",this.type="",this.link="",this.accountType="standard",this.hydroShareConnected=!1}}class ar{id;name;iconLink;signupEnabled;connectEnabled;constructor(){this.id="",this.name="",this.iconLink="",this.signupEnabled=!0,this.connectEnabled=!0}}var Ke=(e=>(e.Global="*",e.View="view",e.Create="create",e.Edit="edit",e.Delete="delete",e))(Ke||{}),Qe=(e=>(e.Global="*",e.Workspace="Workspace",e.Collaborator="Collaborator",e.Thing="Thing",e.Datastream="Datastream",e.Sensor="Sensor",e.Unit="Unit",e.ObservedProperty="ObservedProperty",e.ProcessingLevel="ProcessingLevel",e.Observation="Observation",e))(Qe||{});class ir{id="";key="";name="";description="";isActive=!0;expiresAt="";createdAt="";lastUsed="";workspaceId="";role=null;constructor(t){Object.assign(this,t)}}class cr{id;name;isPrivate;owner;collaboratorRole;pendingTransferTo;constructor(){this.id="",this.name="",this.isPrivate=!1,this.owner=null,this.collaboratorRole=null,this.pendingTransferTo=null}}class lr{user;role;constructor(){this.user={phone:"",address:"",link:"",type:"",name:"",email:"",organizationName:""},this.role={name:"",description:"",id:"",isApikeyRole:!1,isUserRole:!1,workspaceId:"",permissions:[]}}}function me(){const e="csrftoken=",r=decodeURIComponent(document.cookie).split(";");for(const n of r){const s=n.trim();if(s.startsWith(e))return s.substring(e.length)}return null}function we(e){let t=e.headers?{...e.headers}:{},r;return e.body!==void 0&&(r=typeof e.body=="string"||e.body instanceof FormData?e.body:JSON.stringify(e.body)),t["X-CSRFToken"]=me()||"",{...e,headers:t,body:r,credentials:"omit"}}function Ze(e){if(Array.isArray(e?.errors)&&e.errors.length&&(e=e.errors[0]),typeof e!="object"||e===null)return"An unknown error occurred.";const t=["message","detail","error"];for(const r of t)if(e[r])return e[r];return"An unknown error occurred."}async function be(e){if(e.headers.get("Content-Length")==="0"||e.statusText==="No Content")return null;const t=e.headers.get("content-type")||"";let r=null;if(t.includes("application/json"))try{r=await e.json()}catch(s){console.error("Failed to parse error JSON:",s)}else if(t.includes("text/csv"))try{r=await e.blob()}catch(s){console.error("Failed to parse error JSON:",s)}if(e.ok||e.status===401)return r;const n={status:e.status,message:Ze(r)};throw console.error("API response not OK:",n.message),n}var Se=function(e,t){return Se=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(r[s]=n[s])},Se(e,t)};function se(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Se(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}function Ee(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function ke(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),s,a=[],o;try{for(;(t===void 0||t-- >0)&&!(s=n.next()).done;)a.push(s.value)}catch(i){o={error:i}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return a}function ve(e,t,r){if(r||arguments.length===2)for(var n=0,s=t.length,a;n<s;n++)(a||!(n in t))&&(a||(a=Array.prototype.slice.call(t,0,n)),a[n]=t[n]);return e.concat(a||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;function N(e){return typeof e=="function"}function et(e){var t=function(n){Error.call(n),n.stack=new Error().stack},r=e(t);return r.prototype=Object.create(Error.prototype),r.prototype.constructor=r,r}var _e=et(function(e){return function(r){e(this),this.message=r?r.length+` errors occurred during unsubscription:
1
+ (function(w,U){typeof exports=="object"&&typeof module<"u"?U(exports):typeof define=="function"&&define.amd?define(["exports"],U):(w=typeof globalThis<"u"?globalThis:w||self,U(w["@uwrl/qc-utils"]={}))})(this,(function(w){"use strict";var U=(e=>(e.SECOND="s",e.MINUTE="m",e.HOUR="h",e.DAY="D",e.WEEK="W",e.MONTH="M",e.YEAR="Y",e))(U||{}),v=(e=>(e.ADD_POINTS="ADD_POINTS",e.CHANGE_VALUES="CHANGE_VALUES",e.ASSIGN_VALUES_BULK="ASSIGN_VALUES_BULK",e.DELETE_POINTS="DELETE_POINTS",e.DRIFT_CORRECTION="DRIFT_CORRECTION",e.INTERPOLATE="INTERPOLATE",e.SHIFT_DATETIMES="SHIFT_DATETIMES",e.ASSIGN_DATETIMES_BULK="ASSIGN_DATETIMES_BULK",e.FILL_GAPS="FILL_GAPS",e))(v||{}),T=(e=>(e.FIND_GAPS="FIND_GAPS",e.PERSISTENCE="PERSISTENCE",e.CHANGE="CHANGE",e.RATE_OF_CHANGE="RATE_OF_CHANGE",e.VALUE_THRESHOLD="VALUE_THRESHOLD",e.DATETIME_RANGE="DATETIME_RANGE",e.SELECTION="SELECTION",e))(T||{}),H=(e=>(e.LT="Less than",e.LTE="Less than or equal to",e.GT="Greater than",e.GTE="Greater than or equal to",e.E="Equal",e))(H||{}),Ve=(e=>(e.ADD="ADD",e.SUB="SUB",e.MULT="MULT",e.DIV="DIV",e.ASSIGN="ASSIGN",e))(Ve||{}),qe=(e=>(e.LT="Less than",e.LTE="Less than or equal to",e.GT="Greater than",e.GTE="Greater than or equal to",e.E="Equal",e))(qe||{});class Je{id;thingId;link;frequency;path;datastreamIds;publicResource;constructor(){this.id="",this.thingId="",this.link="",this.frequency=null,this.path="HydroShare",this.datastreamIds=[],this.publicResource=!1}}class Qt extends Je{resourceTitle;resourceAbstract;resourceKeywords;constructor(){super(),this.resourceTitle=void 0,this.resourceAbstract=void 0,this.resourceKeywords=void 0}}class Qe{latitude;longitude;elevation_m;elevationDatum;state;county;country;constructor(){this.elevationDatum="WGS84",this.state="",this.county="",this.country=""}}class Kt{id;workspaceId;name;location=new Qe;tags;hydroShareArchive;siteType;samplingFeatureCode;isPrivate;description;samplingFeatureType;dataDisclaimer;constructor(){this.id="",this.workspaceId="",this.name="",this.tags=[],this.siteType="",this.samplingFeatureCode="",this.isPrivate=!1,this.description="",this.samplingFeatureType="Site",this.dataDisclaimer=""}}class Zt{id;workspaceId;name;description;thingId;observationType;resultType;status;sampledMedium;noDataValue;aggregationStatistic;unitId;observedPropertyId;sensorId;processingLevelId;isPrivate;isVisible;phenomenonBeginTime;phenomenonEndTime;intendedTimeSpacing;intendedTimeSpacingUnit;timeAggregationInterval;timeAggregationIntervalUnit;dataSourceId;valueCount;constructor(t){this.id="",this.workspaceId="",this.name="",this.description="",this.thingId=t||"",this.observationType="OM_Measurement",this.resultType="Time Series Coverage",this.sampledMedium="",this.noDataValue=-9999,this.aggregationStatistic="",this.unitId="",this.observedPropertyId="",this.sensorId="",this.processingLevelId="",this.timeAggregationInterval=null,this.timeAggregationIntervalUnit="seconds",this.isPrivate=!0,this.isVisible=!0,this.valueCount=0}}class er{id;workspaceId;name;symbol;definition;type;constructor(){this.id="",this.workspaceId="",this.name="",this.symbol="",this.definition="",this.type=""}}class tr{id;workspaceId;name;description;manufacturer;model;methodType;methodCode;methodLink;encodingType;modelLink;constructor(){this.id="",this.workspaceId="",this.name="",this.description="",this.manufacturer="",this.model="",this.methodType="Instrument Deployment",this.methodCode="",this.methodLink="",this.encodingType="application/json",this.modelLink=""}}class rr{id;workspaceId;name;definition;description;type;code;constructor(){this.id="",this.workspaceId="",this.name="",this.definition="",this.description="",this.type="Hydrology",this.code=""}}class nr{id;workspaceId;code;definition;explanation;constructor(){this.id="",this.workspaceId="",this.code="",this.definition="",this.explanation=""}}class sr{id;workspaceId;code;description;constructor(){this.id="",this.workspaceId="",this.code="",this.description=""}}class or{name;code;type;description;link;constructor(){}}class ar{id;email;password;firstName;middleName;lastName;phone;address;organization;type;link;accountType;hydroShareConnected;constructor(){this.id="",this.email="",this.password="",this.firstName="",this.middleName="",this.lastName="",this.phone="",this.address="",this.type="",this.link="",this.accountType="standard",this.hydroShareConnected=!1}}class ir{id;name;iconLink;signupEnabled;connectEnabled;constructor(){this.id="",this.name="",this.iconLink="",this.signupEnabled=!0,this.connectEnabled=!0}}var Ke=(e=>(e.Global="*",e.View="view",e.Create="create",e.Edit="edit",e.Delete="delete",e))(Ke||{}),Ze=(e=>(e.Global="*",e.Workspace="Workspace",e.Collaborator="Collaborator",e.Thing="Thing",e.Datastream="Datastream",e.Sensor="Sensor",e.Unit="Unit",e.ObservedProperty="ObservedProperty",e.ProcessingLevel="ProcessingLevel",e.Observation="Observation",e))(Ze||{});class cr{id="";key="";name="";description="";isActive=!0;expiresAt="";createdAt="";lastUsed="";workspaceId="";role=null;constructor(t){Object.assign(this,t)}}class lr{id;name;isPrivate;owner;collaboratorRole;pendingTransferTo;constructor(){this.id="",this.name="",this.isPrivate=!1,this.owner=null,this.collaboratorRole=null,this.pendingTransferTo=null}}class ur{user;role;constructor(){this.user={phone:"",address:"",link:"",type:"",name:"",email:"",organizationName:""},this.role={name:"",description:"",id:"",isApikeyRole:!1,isUserRole:!1,workspaceId:"",permissions:[]}}}function we(){const e="csrftoken=",r=decodeURIComponent(document.cookie).split(";");for(const n of r){const s=n.trim();if(s.startsWith(e))return s.substring(e.length)}return null}function be(e){let t=e.headers?{...e.headers}:{},r;return e.body!==void 0&&(r=typeof e.body=="string"||e.body instanceof FormData?e.body:JSON.stringify(e.body)),t["X-CSRFToken"]=we()||"",{...e,headers:t,body:r,credentials:"omit"}}function et(e){if(Array.isArray(e?.errors)&&e.errors.length&&(e=e.errors[0]),typeof e!="object"||e===null)return"An unknown error occurred.";const t=["message","detail","error"];for(const r of t)if(e[r])return e[r];return"An unknown error occurred."}async function Se(e){if(e.headers.get("Content-Length")==="0"||e.statusText==="No Content")return null;const t=e.headers.get("content-type")||"";let r=null;if(t.includes("application/json"))try{r=await e.json()}catch(s){console.error("Failed to parse error JSON:",s)}else if(t.includes("text/csv"))try{r=await e.blob()}catch(s){console.error("Failed to parse error JSON:",s)}if(e.ok||e.status===401)return r;const n={status:e.status,message:et(r)};throw console.error("API response not OK:",n.message),n}var Ee=function(e,t){return Ee=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(r[s]=n[s])},Ee(e,t)};function ae(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Ee(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}function ve(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function ke(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),s,o=[],a;try{for(;(t===void 0||t-- >0)&&!(s=n.next()).done;)o.push(s.value)}catch(i){a={error:i}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(a)throw a.error}}return o}function _e(e,t,r){if(r||arguments.length===2)for(var n=0,s=t.length,o;n<s;n++)(o||!(n in t))&&(o||(o=Array.prototype.slice.call(t,0,n)),o[n]=t[n]);return e.concat(o||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;function B(e){return typeof e=="function"}function tt(e){var t=function(n){Error.call(n),n.stack=new Error().stack},r=e(t);return r.prototype=Object.create(Error.prototype),r.prototype.constructor=r,r}var Ae=tt(function(e){return function(r){e(this),this.message=r?r.length+` errors occurred during unsubscription:
2
2
  `+r.map(function(n,s){return s+1+") "+n.toString()}).join(`
3
- `):"",this.name="UnsubscriptionError",this.errors=r}});function Ae(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var oe=(function(){function e(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var t,r,n,s,a;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var i=Ee(o),l=i.next();!l.done;l=i.next()){var f=l.value;f.remove(this)}}catch(h){t={error:h}}finally{try{l&&!l.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}else o.remove(this);var u=this.initialTeardown;if(N(u))try{u()}catch(h){a=h instanceof _e?h.errors:[h]}var p=this._finalizers;if(p){this._finalizers=null;try{for(var g=Ee(p),y=g.next();!y.done;y=g.next()){var d=y.value;try{nt(d)}catch(h){a=a??[],h instanceof _e?a=ve(ve([],ke(a)),ke(h.errors)):a.push(h)}}}catch(h){n={error:h}}finally{try{y&&!y.done&&(s=g.return)&&s.call(g)}finally{if(n)throw n.error}}}if(a)throw new _e(a)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)nt(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(r=this._finalizers)!==null&&r!==void 0?r:[]).push(t)}},e.prototype._hasParent=function(t){var r=this._parentage;return r===t||Array.isArray(r)&&r.includes(t)},e.prototype._addParent=function(t){var r=this._parentage;this._parentage=Array.isArray(r)?(r.push(t),r):r?[r,t]:t},e.prototype._removeParent=function(t){var r=this._parentage;r===t?this._parentage=null:Array.isArray(r)&&Ae(r,t)},e.prototype.remove=function(t){var r=this._finalizers;r&&Ae(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=(function(){var t=new e;return t.closed=!0,t})(),e})(),tt=oe.EMPTY;function rt(e){return e instanceof oe||e&&"closed"in e&&N(e.remove)&&N(e.add)&&N(e.unsubscribe)}function nt(e){N(e)?e():e.unsubscribe()}var ur={Promise:void 0},hr={setTimeout:function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setTimeout.apply(void 0,ve([e,t],ke(r)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function fr(e){hr.setTimeout(function(){throw e})}function st(){}function ae(e){e()}var ot=(function(e){se(t,e);function t(r){var n=e.call(this)||this;return n.isStopped=!1,r?(n.destination=r,rt(r)&&r.add(n)):n.destination=yr,n}return t.create=function(r,n,s){return new Te(r,n,s)},t.prototype.next=function(r){this.isStopped||this._next(r)},t.prototype.error=function(r){this.isStopped||(this.isStopped=!0,this._error(r))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(r){this.destination.next(r)},t.prototype._error=function(r){try{this.destination.error(r)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t})(oe),dr=(function(){function e(t){this.partialObserver=t}return e.prototype.next=function(t){var r=this.partialObserver;if(r.next)try{r.next(t)}catch(n){ie(n)}},e.prototype.error=function(t){var r=this.partialObserver;if(r.error)try{r.error(t)}catch(n){ie(n)}else ie(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(r){ie(r)}},e})(),Te=(function(e){se(t,e);function t(r,n,s){var a=e.call(this)||this,o;return N(r)||!r?o={next:r??void 0,error:n??void 0,complete:s??void 0}:o=r,a.destination=new dr(o),a}return t})(ot);function ie(e){fr(e)}function pr(e){throw e}var yr={closed:!0,next:st,error:pr,complete:st},gr=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function mr(e){return e}function wr(e){return e.length===0?mr:e.length===1?e[0]:function(r){return e.reduce(function(n,s){return s(n)},r)}}var at=(function(){function e(t){t&&(this._subscribe=t)}return e.prototype.lift=function(t){var r=new e;return r.source=this,r.operator=t,r},e.prototype.subscribe=function(t,r,n){var s=this,a=Sr(t)?t:new Te(t,r,n);return ae(function(){var o=s,i=o.operator,l=o.source;a.add(i?i.call(a,l):l?s._subscribe(a):s._trySubscribe(a))}),a},e.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(r){t.error(r)}},e.prototype.forEach=function(t,r){var n=this;return r=it(r),new r(function(s,a){var o=new Te({next:function(i){try{t(i)}catch(l){a(l),o.unsubscribe()}},error:a,complete:s});n.subscribe(o)})},e.prototype._subscribe=function(t){var r;return(r=this.source)===null||r===void 0?void 0:r.subscribe(t)},e.prototype[gr]=function(){return this},e.prototype.pipe=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return wr(t)(this)},e.prototype.toPromise=function(t){var r=this;return t=it(t),new t(function(n,s){var a;r.subscribe(function(o){return a=o},function(o){return s(o)},function(){return n(a)})})},e.create=function(t){return new e(t)},e})();function it(e){var t;return(t=e??ur.Promise)!==null&&t!==void 0?t:Promise}function br(e){return e&&N(e.next)&&N(e.error)&&N(e.complete)}function Sr(e){return e&&e instanceof ot||br(e)&&rt(e)}var Er=et(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),ct=(function(e){se(t,e);function t(){var r=e.call(this)||this;return r.closed=!1,r.currentObservers=null,r.observers=[],r.isStopped=!1,r.hasError=!1,r.thrownError=null,r}return t.prototype.lift=function(r){var n=new lt(this,this);return n.operator=r,n},t.prototype._throwIfClosed=function(){if(this.closed)throw new Er},t.prototype.next=function(r){var n=this;ae(function(){var s,a;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var o=Ee(n.currentObservers),i=o.next();!i.done;i=o.next()){var l=i.value;l.next(r)}}catch(f){s={error:f}}finally{try{i&&!i.done&&(a=o.return)&&a.call(o)}finally{if(s)throw s.error}}}})},t.prototype.error=function(r){var n=this;ae(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=r;for(var s=n.observers;s.length;)s.shift().error(r)}})},t.prototype.complete=function(){var r=this;ae(function(){if(r._throwIfClosed(),!r.isStopped){r.isStopped=!0;for(var n=r.observers;n.length;)n.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var r;return((r=this.observers)===null||r===void 0?void 0:r.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(r){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,r)},t.prototype._subscribe=function(r){return this._throwIfClosed(),this._checkFinalizedStatuses(r),this._innerSubscribe(r)},t.prototype._innerSubscribe=function(r){var n=this,s=this,a=s.hasError,o=s.isStopped,i=s.observers;return a||o?tt:(this.currentObservers=null,i.push(r),new oe(function(){n.currentObservers=null,Ae(i,r)}))},t.prototype._checkFinalizedStatuses=function(r){var n=this,s=n.hasError,a=n.thrownError,o=n.isStopped;s?r.error(a):o&&r.complete()},t.prototype.asObservable=function(){var r=new at;return r.source=this,r},t.create=function(r,n){return new lt(r,n)},t})(at),lt=(function(e){se(t,e);function t(r,n){var s=e.call(this)||this;return s.destination=r,s.source=n,s}return t.prototype.next=function(r){var n,s;(s=(n=this.destination)===null||n===void 0?void 0:n.next)===null||s===void 0||s.call(n,r)},t.prototype.error=function(r){var n,s;(s=(n=this.destination)===null||n===void 0?void 0:n.error)===null||s===void 0||s.call(n,r)},t.prototype.complete=function(){var r,n;(n=(r=this.destination)===null||r===void 0?void 0:r.complete)===null||n===void 0||n.call(r)},t.prototype._subscribe=function(r){var n,s;return(s=(n=this.source)===null||n===void 0?void 0:n.subscribe(r))!==null&&s!==void 0?s:tt},t})(ct);const Le=3e3;var $e=(e=>(e.Warning="warning",e.Success="success",e.Error="error",e.Info="info",e))($e||{}),Re=(e=>(e.Success="mdi-checkbox-marked-circle",e.Warning="mdi-alert",e.Error="mdi-alert-circle",e.Info="mdi-information",e.None="none",e))(Re||{}),Ie=(e=>(e.Warning="Warning",e.Success="Success",e.Error="Error",e.Info="Info",e))(Ie||{}),ut=(e=>(e.Center="center",e.Left="left",e.Right="right",e.Bottom="bottom",e.Top="top",e))(ut||{});class ht{constructor(t="",r="info",n="none",s="Info",a=Le,o="center",i=!1){this.message=t,this.color=r,this.icon=n,this.title=s,this.timeout=a,this.position=o,this.visible=i}}class ft{static subject=new ct;static get snack$(){return this.subject.asObservable()}static createSnackbar(t,r){this.subject.next(new ht(t,$e[r],Re[r],Ie[r],Le,"bottom",!0))}static success(t){this.createSnackbar(t,"Success")}static warn(t){this.createSnackbar(t,"Warning")}static error(t){this.createSnackbar(t,"Error")}static info(t){this.createSnackbar(t,"Info")}}function Oe(e,t){const r={};for(let n in t)if(Array.isArray(t[n]))JSON.stringify(e[n])!==JSON.stringify(t[n])&&(r[n]=t[n]);else if(e[n]&&typeof e[n]=="object"&&t[n]&&typeof t[n]=="object"){const s=Oe(e[n],t[n]);Object.keys(s).length>0&&(r[n]=s)}else JSON.stringify(e[n])!==JSON.stringify(t[n])&&(r[n]=t[n]);return r}function kr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Ue,dt;function vr(){if(dt)return Ue;dt=1;class e{constructor(n){this.value=n,this.next=void 0}}class t{constructor(){this.clear()}enqueue(n){const s=new e(n);this._head?(this._tail.next=s,this._tail=s):(this._head=s,this._tail=s),this._size++}dequeue(){const n=this._head;if(n)return this._head=this._head.next,this._size--,n.value}clear(){this._head=void 0,this._tail=void 0,this._size=0}get size(){return this._size}*[Symbol.iterator](){let n=this._head;for(;n;)yield n.value,n=n.next}}return Ue=t,Ue}var Me,pt;function _r(){if(pt)return Me;pt=1;const e=vr();return Me=r=>{if(!((Number.isInteger(r)||r===1/0)&&r>0))throw new TypeError("Expected `concurrency` to be a number from 1 and up");const n=new e;let s=0;const a=()=>{s--,n.size>0&&n.dequeue()()},o=async(f,u,...p)=>{s++;const g=(async()=>f(...p))();u(g);try{await g}catch{}a()},i=(f,u,...p)=>{n.enqueue(o.bind(null,f,u,...p)),(async()=>(await Promise.resolve(),s<r&&n.size>0&&n.dequeue()()))()},l=(f,...u)=>new Promise(p=>{i(f,p,...u)});return Object.defineProperties(l,{activeCount:{get:()=>s},pendingCount:{get:()=>n.size},clearQueue:{value:()=>{n.clear()}}}),l},Me}var Ar=_r();const Y=kr(Ar)(10),Tr=1e3;async function q(e,t){const r=we(t);try{const n=await fetch(e,r);return await be(n)}catch(n){throw n instanceof TypeError&&ft.error("Network error. Please check your connection."),n}}const c={async fetch(e,t={}){return t.method="GET",await Y(()=>q(e,t))},async patch(e,t,r=null,n={}){if(n.method="PATCH",n.body=r?Oe(r,t):t,Object.keys(n.body).length!==0)return await Y(()=>q(e,n))},async post(e,t=void 0,r={}){return r.method="POST",r.body=t,await Y(()=>q(e,r))},async put(e,t=void 0,r={}){return r.method="PUT",r.body=t,await Y(()=>q(e,r))},async delete(e,t=void 0,r={}){return r.method="DELETE",r.body=t,await Y(()=>q(e,r))},async paginatedFetch(e,t){const r=t??Tr,n=e.includes("?")?"&":"?",s=`${e}${n}page_size=${r}&page=1`,a=we({method:"GET"}),o=await Y(()=>fetch(s,a)),i=Number(o.headers.get("x-total-pages"))||1,f=[...await be(o)];for(let u=2;u<=i;u++){const p=`${e}${n}page_size=${r}&page=${u}`,g=await Y(()=>q(p,{method:"GET"}));f.push(...g)}return f}},yt={HTTP:{type:"HTTP",sourceUri:"",placeholderVariables:[]},local:{type:"local",sourceUri:"",placeholderVariables:[]}},gt={JSON:{type:"JSON",timestamp:{key:"",format:"ISO8601",timezoneMode:"embeddedOffset"},JMESPath:""},CSV:{type:"CSV",timestamp:{key:"",format:"ISO8601",timezoneMode:"embeddedOffset"},headerRow:1,dataStartRow:2,delimiter:",",identifierType:"name"}},mt={HydroServer:{type:"HydroServer"}};class Lr{name="";settings={type:"SDL",extractor:JSON.parse(JSON.stringify(yt.local)),transformer:JSON.parse(JSON.stringify(gt.CSV)),loader:JSON.parse(JSON.stringify(mt.HydroServer)),payloads:[]};id="";workspaceId="";orchestrationSystem={id:"",name:"",workspaceId:"",type:""};schedule={interval:15,intervalUnits:"minutes"};status={paused:!0};datastreams=[];constructor(t){Object.assign(this,t)}switchExtractor(t){this.settings.extractor=JSON.parse(JSON.stringify(yt[t]))}switchTransformer(t){this.settings.transformer=JSON.parse(JSON.stringify(gt[t]))}switchLoader(t){this.settings.loader=JSON.parse(JSON.stringify(mt[t]))}}function wt(e){return{name:e.name,settings:e.settings,workspaceId:e.workspaceId,orchestrationSystemId:e.orchestrationSystem.id,schedule:e.schedule,status:e.status}}const D="https://lro.hydroserver.org/api",ce=`${D}/auth`,P=`${ce}/browser/account`,le=`${ce}/browser/session`,Z=`${ce}/browser/provider`,R=`${D}/data/workspaces`,Ce=`${D}/data/roles`,I=`${D}/data/datastreams`,W=`${D}/data/sensors`,_=`${D}/data/things`,De=`${_}/tags`,J=`${D}/data/orchestration-systems`,B=`${D}/data/data-sources`,H=`${D}/data/observed-properties`,K=`${D}/data/processing-levels`,ee=`${D}/data/result-qualifiers`,z=`${D}/data/units`,$r=(e,t,r,n,s)=>{let a=`${I}/${e}/observations?format=column`;return a+=`&order_by=phenomenonTime&page_size=${t}`,a+=`&phenomenon_time_min=${encodeURIComponent(r)}`,n&&(a+=`&phenomenon_time_max=${encodeURIComponent(n)}`),s&&(a+=`&page=${s}`),a},Rr={fetchSession:async()=>c.fetch(`${le}`),login:async(e,t)=>c.post(`${le}`,{email:e,password:t}),logout:async()=>c.delete(`${le}`),fetchUser:async()=>c.fetch(`${P}`),signup:async e=>c.post(`${P}`,e),updateUser:async(e,t)=>c.patch(`${P}`,e,t),deleteUser:async()=>c.delete(`${P}`),sendVerificationEmail:async e=>c.put(`${P}/email/verify`,{email:e}),verifyEmailWithCode:async e=>c.post(`${P}/email/verify`,{key:e}),requestPasswordReset:async e=>c.post(`${P}/password/request`,{email:e}),resetPassword:async(e,t)=>c.post(`${P}/password/reset`,{key:e,password:t}),fetchWorkspaces:async()=>c.paginatedFetch(`${R}`),fetchAssociatedWorkspaces:async()=>c.paginatedFetch(`${R}?is_associated=true`),fetchWorkspace:async e=>c.fetch(`${R}/${e}`),createWorkspace:async e=>c.post(R,e),updateWorkspace:async(e,t=null)=>c.patch(`${R}/${e.id}`,e,t),deleteWorkspace:async e=>c.delete(`${R}/${e}`),transferWorkspace:async(e,t)=>c.post(`${R}/${e}/transfer`,{newOwner:t}),acceptWorkspaceTransfer:async e=>c.put(`${R}/${e}/transfer`),rejectWorkspaceTransfer:async e=>c.delete(`${R}/${e}/transfer`),getCollaboratorRoles:async e=>c.paginatedFetch(`${Ce}?is_user_role=true`),getAPIKeyRoles:async e=>c.paginatedFetch(`${Ce}?is_apikey_role=true`),getRole:async e=>c.fetch(`${Ce}/${e}`),getCollaborators:async e=>c.paginatedFetch(`${R}/${e}/collaborators`),addCollaborator:async(e,t,r)=>c.post(`${R}/${e}/collaborators`,{email:t,roleId:r}),updateCollaboratorRole:async(e,t,r)=>c.put(`${R}/${e}/collaborators`,{email:t,roleId:r}),removeCollaborator:async(e,t)=>c.delete(`${R}/${e}/collaborators`,{email:t}),fetchApiKeys:async e=>c.paginatedFetch(`${R}/${e}/api-keys?expand_related=true`),fetchApiKey:async(e,t)=>c.fetch(`${R}/${e}/api-keys/${t}?expand_related=true`),createApiKey:async e=>c.post(`${R}/${e.workspaceId}/api-keys?expand_related=true`,{name:e.name,description:e.description,isActive:!0,roleId:e.role.id}),updateApiKey:async(e,t)=>c.patch(`${R}/${e.workspaceId}/api-keys/${e.id}?expand_related=true`,{name:e.name,description:e.description,isActive:!0,roleId:e.role.id},t&&{name:t.name,description:t.description,isActive:!0,roleId:t.role.id}),regenerateApiKey:async(e,t)=>c.put(`${R}/${e}/api-keys/${t}/regenerate?expand_related=true`),deleteApiKey:async(e,t)=>c.delete(`${R}/${e}/api-keys/${t}`),fetchConnectedProviders:async()=>c.fetch(`${Z}/connections`),providerRedirect:(e,t,r)=>{const n={provider:e,callback_url:t,process:r},s=me(),a=document.createElement("form");if(a.method="POST",a.action=`${Z}/redirect`,s){const o=document.createElement("input");o.type="hidden",o.name="csrfmiddlewaretoken",o.value=s,a.appendChild(o)}for(const o in n){const i=document.createElement("input");i.type="hidden",i.name=o,i.value=n[o]||"",a.appendChild(i)}document.body.appendChild(a),a.submit()},providerSignup:async e=>c.post(`${Z}/signup`,e),deleteProvider:async(e,t)=>c.delete(`${Z}/connections`,{provider:e,account:t}),createUnit:async e=>c.post(z,e),fetchUnits:async()=>c.paginatedFetch(`${z}`),fetchWorkspaceUnits:async e=>c.paginatedFetch(`${z}?workspace_id=${e}`),updateUnit:async(e,t=null)=>c.patch(`${z}/${e.id}`,e,t),deleteUnit:async e=>c.delete(`${z}/${e}`),getUnit:async e=>c.fetch(`${z}/${e}`),removeThingOwner:async(e,t)=>c.patch(`${_}/${e}/ownership`,{email:t,removeOwner:!0}),addSecondaryOwner:async(e,t)=>c.patch(`${_}/${e}/ownership`,{email:t,makeOwner:!0}),transferPrimaryOwnership:async(e,t)=>c.patch(`${_}/${e}/ownership`,{email:t,transferPrimary:!0}),createThing:async e=>c.post(_,e),fetchThings:async()=>c.paginatedFetch(`${_}`),fetchThingsForWorkspace:async e=>c.paginatedFetch(`${_}?workspace_id=${e}`),fetchOwnedThings:async()=>c.paginatedFetch(`${_}?owned_only=true`),fetchThing:async e=>c.fetch(`${_}/${e}`),updateThing:async e=>c.patch(`${_}/${e.id}`,e),updateThingPrivacy:async(e,t)=>c.patch(`${_}/${e}`,{isPrivate:t}),deleteThing:async e=>c.delete(`${_}/${e}`),fetchMetadataForThingOwner:async e=>c.paginatedFetch(`${_}/${e}/metadata?include_assignable_metadata=true`),fetchMetadataForThing:async e=>c.fetch(`${_}/${e}/metadata`),uploadSitePhotos:async(e,t)=>c.post(`${_}/${e}/photos`,t),fetchSitePhotos:async e=>c.paginatedFetch(`${_}/${e}/photos`),deleteSitePhoto:async(e,t)=>c.delete(`${_}/${e}/photos`,{name:t}),createSiteTag:async(e,t)=>c.post(`${_}/${e}/tags`,t),editSiteTag:async(e,t)=>c.put(`${_}/${e}/tags`,t),fetchSiteTags:async e=>c.fetch(`${_}/${e}/tags`),fetchUsersSiteTags:async()=>c.fetch(`${De}`),deleteSiteTag:async(e,t)=>c.delete(`${_}/${e}/tags`,t),fetchWorkspaceTags:async e=>c.fetch(`${De}/keys?workspace_id=${e}`),createHydroShareArchive:async e=>c.post(`${_}/${e.thingId}/archive`,e),updateHydroShareArchive:async(e,t)=>c.patch(`${_}/${e.thingId}/archive`,e,t),fetchHydroShareArchive:async e=>c.fetch(`${_}/${e}/archive`),deleteHydroShareArchive:async e=>c.delete(`${_}/${e}/archive`),archiveToHydroShare:async e=>c.post(`${_}/${e}/archive/trigger`),createDatastream:async e=>c.post(I,e),fetchDatastreams:async e=>{const t=[];if(e)for(const[n,s]of Object.entries(e))t.push(`${encodeURIComponent(n)}=${encodeURIComponent(s)}`);const r=t.length?`?${t.join("&")}`:"";return c.paginatedFetch(`${I}${r}`)},fetchDatastreamsForThing:async e=>c.paginatedFetch(`${I}?thing_id=${e}`),fetchExpandedDatastreamsForThing:async e=>c.paginatedFetch(`${I}?thing_id=${e}&expand_related=true`),fetchDatastreamsForDataSource:async e=>c.paginatedFetch(`${I}?data_source_id=${e}`),fetchDatastream:async e=>c.fetch(`${I}/${e}`),fetchDatastreamExpanded:async e=>c.fetch(`${I}/${e}?expand_related=true`),fetchUsersDatastreams:async()=>c.paginatedFetch(`${I}?exclude_unowned=true`),updateDatastream:async(e,t=null)=>c.patch(`${I}/${e.id}`,e,t),deleteDatastream:async e=>c.delete(`${I}/${e}`),downloadDatastreamCSV:async e=>c.fetch(`${I}/${e}/csv`),createObservedProperty:async e=>c.post(H,e),fetchObservedProperty:async e=>c.fetch(`${H}/${e}`),fetchObservedProperties:async()=>c.paginatedFetch(`${H}`),fetchWorkspaceObservedProperties:async e=>c.paginatedFetch(`${H}?workspace_id=${e}`),updateObservedProperty:async(e,t=null)=>c.patch(`${H}/${e.id}`,e,t),deleteObservedProperty:async e=>c.delete(`${H}/${e}`),createProcessingLevel:async e=>c.post(K,e),fetchProcessingLevels:async()=>c.paginatedFetch(`${K}`),fetchProcessingLevel:async e=>c.fetch(`${K}/${e}`),fetchWorkspaceProcessingLevels:async e=>c.paginatedFetch(`${K}?workspace_id=${e}`),updateProcessingLevel:async(e,t=null)=>c.patch(`${K}/${e.id}`,e,t),deleteProcessingLevel:async e=>c.delete(`${K}/${e}`),createSensor:async e=>c.post(W,e),fetchSensors:async()=>c.paginatedFetch(`${W}`),fetchSensor:async e=>c.fetch(`${W}/${e}`),fetchWorkspaceSensors:async e=>c.paginatedFetch(`${W}?workspace_id=${e}`),updateSensor:async(e,t=null)=>c.patch(`${W}/${e.id}`,e,t),deleteSensor:async e=>c.delete(`${W}/${e}`),createResultQualifier:async e=>c.post(ee,e),fetchResultQualifiers:async()=>c.paginatedFetch(`${ee}`),fetchWorkspaceResultQualifiers:async e=>c.paginatedFetch(`${ee}?workspace_id=${e}`),updateResultQualifier:async(e,t=null)=>c.patch(`${ee}/${e.id}`,e,t),deleteResultQualifier:async e=>c.delete(`${ee}/${e}`),createOrchestrationSystem:async e=>c.post(J,e),fetchOrchestrationSystems:async()=>c.paginatedFetch(J),fetchWorkspaceOrchestrationSystems:async e=>c.paginatedFetch(`${J}?workspace_id=${e}`),fetchOrchestrationSystem:async e=>c.fetch(`${J}/${e}`),updateOrchestrationSystem:async(e,t)=>c.patch(`${J}/${e}`,t),deleteOrchestrationSystem:async e=>c.delete(`${J}/${e}`),createDataSource:async e=>c.post(`${B}?expand_related=true`,wt(e)),fetchDataSources:async()=>c.paginatedFetch(`${B}?expand_related=true`),fetchWorkspaceDataSources:async e=>c.paginatedFetch(`${B}?workspace_id=${e}&expand_related=true`),fetchDataSource:async e=>c.fetch(`${B}/${e}?expand_related=true`),updateDataSource:async e=>c.patch(`${B}/${e.id}?expand_related=true`,wt(e)),updateDataSourcePartial:async e=>c.patch(`${B}/${e.id}?expand_related=true`,e),deleteDataSource:async e=>c.delete(`${B}/${e}`),linkDatastreamToDataSource:async(e,t)=>c.post(`${B}/${e}/datastreams/${t}`),unlinkDatastreamFromDataSource:async(e,t)=>c.delete(`${B}/${e}/datastreams/${t}`),fetchObservations:async e=>c.fetch(e),deleteObservationsForDatastream:async e=>c.post(`${I}/${e}/observations/bulk-delete`,{phenomenonTimeStart:null,phenomenonTimeEnd:null}),fetchUserTypes:async()=>c.fetch(`${P}/user-types`),fetchOrganizationTypes:async()=>c.fetch(`${P}/organization-types`),fetchSiteTypes:async()=>c.fetch(`${_}/site-types`),fetchSamplingFeatureTypes:async()=>c.paginatedFetch(`${_}/sampling-feature-types`),fetchSensorEncodingTypes:async()=>c.paginatedFetch(`${W}/encoding-types`),fetchMethodTypes:async()=>c.paginatedFetch(`${W}/method-types`),fetchVariableTypes:async()=>c.paginatedFetch(`${H}/variable-types`),fetchUnitTypes:async()=>c.paginatedFetch(`${z}/types`),fetchDatastreamStatuses:async()=>c.paginatedFetch(`${I}/statuses`),fetchDatastreamAggregations:async()=>c.paginatedFetch(`${I}/aggregation-statistics`),fetchSampledMediums:async()=>c.paginatedFetch(`${I}/sampled-mediums`)};class Ir{name="";mappings=[];extractorVariables={};constructor(t){Object.assign(this,t)}}const bt=1,ue=bt*60,Fe=ue*60,Pe=Fe*24,Or=Pe*7,Ur=Fe*30,Mr=Pe*365,te={[O.SECOND]:bt,[O.MINUTE]:ue,[O.HOUR]:Fe,[O.DAY]:Pe,[O.WEEK]:Or,[O.MONTH]:Ur,[O.YEAR]:Mr},Cr=e=>e.toLocaleString(void 0,{year:"numeric",month:"short",day:"2-digit",hour:"2-digit",hour12:!1,minute:"2-digit",second:"2-digit"}),Dr=e=>{let t,r;e>=ue*1e3?(t=e/(ue*1e3),r="m"):e>=1e3?(t=e/1e3,r="s"):(t=e,r="ms");let n;return r==="ms"?n=Math.round(t).toString():n=t.toFixed(2),`${n} ${r}`},he=async(e,t)=>{t&&console.info(t);const r=performance.now(),n=await e(),s=performance.now();console.info(` Done in ${(s-r).toFixed(2)} ms`);const a=+(s-r);return{response:n,duration:a}};function Fr(e,t){const r=new Date(e);return r.setHours(r.getHours()-t),r.toISOString()}const re=(e,t)=>{let r=0,n=e.length;for(;r<n;){const s=r+n>>1;e[s]<t?r=s+1:n=s}return r},fe=(e,t)=>{let r=0,n=e.length;for(;r<n;){const s=r+n>>1;e[s]>t?n=s:r=s+1}return r-1},St=`(function(){"use strict";function c(n,s,a,u,f,l,y,o){let r=0,e=o;for(let t=l;t<=y;t++)r<a.length&&t===a[r]?r++:(u[e]=n[t],f[e]=s[t],e++);return e-o}self.onmessage=n=>{const{bufferX:s,bufferY:a,outputBufferX:u,outputBufferY:f,start:l,end:y,deleteSegment:o,startTarget:r}=n.data,e=new Float64Array(s),t=new Float32Array(a),A=new Float64Array(u),g=new Float32Array(f);c(e,t,o,A,g,l,y,r),self.postMessage("Done")}})();
4
- `,Et=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",St],{type:"text/javascript;charset=utf-8"});function Pr(e){let t;try{if(t=Et&&(self.URL||self.webkitURL).createObjectURL(Et),!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(St),{name:e?.name})}}const kt=`(function(){"use strict";function F(n,l,a,o,s,y,g,f,i,w,A){let e=0,t=f;for(let r=y;r<=g;r++)if(o[t]=n[r],s[t]=l[r],t++,e<a.length&&r===a[e][0]){const u=a[e][0],c=a[e][1],d=n[u],h=n[c],m=l[u],D=l[c],x=h-d,P=D-m;let p=d+i;for(;p<h;)o[t]=p,s[t]=w?m+(p-d)*P/x:A,t++,p+=i;e++}return t-f}self.onmessage=n=>{const{bufferX:l,bufferY:a,outputBufferX:o,outputBufferY:s,start:y,end:g,gapsSegment:f,startTarget:i,fillDelta:w,interpolate:A,fillValue:e}=n.data,t=new Float64Array(l),r=new Float32Array(a),u=new Float64Array(o),c=new Float32Array(s);F(t,r,f,u,c,y,g,i,w,A,e),self.postMessage("Done")}})();
5
- `,vt=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",kt],{type:"text/javascript;charset=utf-8"});function Nr(e){let t;try{if(t=vt&&(self.URL||self.webkitURL).createObjectURL(vt),!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(kt),{name:e?.name})}}const _t=`(function(){"use strict";function g(o,n,c){for(let s=0;s<c.length;s++){const{indexes:t,lowerIdx:l,upperIdx:r}=c[s],i=o[l],f=n[l],a=o[r],d=n[r],p=a-i,w=d-f;if(p===0){for(let e=0;e<t.length;e++)n[t[e]]=f;continue}for(let e=0;e<t.length;e++){const u=t[e];n[u]=f+(o[u]-i)*w/p}}}self.onmessage=o=>{const{bufferX:n,bufferY:c,groups:s}=o.data,t=new Float64Array(n),l=new Float32Array(c);g(t,l,s),self.postMessage("Done")}})();
6
- `,At=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",_t],{type:"text/javascript;charset=utf-8"});function Br(e){let t;try{if(t=At&&(self.URL||self.webkitURL).createObjectURL(At),!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(_t),{name:e?.name})}}const Tt=`(function(){"use strict";self.onmessage=r=>{const{bufferX:s,bufferY:o,jobs:a}=r.data,f=new Float64Array(s),n=new Float32Array(o);for(let e=0;e<a.length;e++){const{chunkStart:c,chunkEnd:l,startDatetime:u,value:i,extent:y}=a[e];for(let t=c;t<l;t++)n[t]=n[t]+i*((f[t]-u)/y)}self.postMessage("Done")}})();
7
- `,Lt=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Tt],{type:"text/javascript;charset=utf-8"});function jr(e){let t;try{if(t=Lt&&(self.URL||self.webkitURL).createObjectURL(Lt),!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(Tt),{name:e?.name})}}const $t=`(function(){"use strict";function u(f,o,a,n,l,c,s,i){let r=c,e=0,t=i;const w=a.length;for(;r<s&&e<w;){const y=a[e][0];f[r]<=y?(n[t]=f[r],l[t]=o[r],r++):(n[t]=y,l[t]=a[e][1],e++),t++}for(;r<s;)n[t]=f[r],l[t]=o[r],r++,t++;for(;e<w;)n[t]=a[e][0],l[t]=a[e][1],e++,t++;return t-i}self.onmessage=f=>{const{bufferX:o,bufferY:a,outputBufferX:n,outputBufferY:l,origStart:c,origEnd:s,insertions:i,outStart:r}=f.data,e=new Float64Array(o),t=new Float32Array(a),w=new Float64Array(n),y=new Float32Array(l);u(e,t,i,w,y,c,s,r),self.postMessage("Done")}})();
8
- `,Rt=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",$t],{type:"text/javascript;charset=utf-8"});function Wr(e){let t;try{if(t=Rt&&(self.URL||self.webkitURL).createObjectURL(Rt),!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($t),{name:e?.name})}}const It=`(function(){"use strict";self.onmessage=i=>{const{bufferX:c,bufferY:g,outputBufferX:d,outputBufferY:y,indexes:n,outStart:r,amount:f,isMonth:Y,isYear:h,deltaMs:w}=i.data,s=new Float64Array(c),a=new Float32Array(g),l=new Float64Array(d),u=new Float32Array(y);if(Y)for(let t=0;t<n.length;t++){const e=n[t],o=new Date(s[e]);o.setMonth(o.getMonth()+f),l[r+t]=o.getTime(),u[r+t]=a[e]}else if(h)for(let t=0;t<n.length;t++){const e=n[t],o=new Date(s[e]);o.setFullYear(o.getFullYear()+f),l[r+t]=o.getTime(),u[r+t]=a[e]}else for(let t=0;t<n.length;t++){const e=n[t];l[r+t]=s[e]+w,u[r+t]=a[e]}self.postMessage("Done")}})();
9
- `,Ot=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",It],{type:"text/javascript;charset=utf-8"});function xr(e){let t;try{if(t=Ot&&(self.URL||self.webkitURL).createObjectURL(Ot),!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(It),{name:e?.name})}}const Ut=`(function(){"use strict";function a(e,t,o,c){const n=[];let r=e[t];for(let s=t+1;s<=o;s++){const f=e[s];f-r>c&&n.push(s-1,s),r=f}return n}self.onmessage=e=>{const{bufferX:t,start:o,endInclusive:c,threshold:n}=e.data,r=new Float64Array(t);self.postMessage(a(r,o,c,n))}})();
10
- `,Mt=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Ut],{type:"text/javascript;charset=utf-8"});function Gr(e){let t;try{if(t=Mt&&(self.URL||self.webkitURL).createObjectURL(Mt),!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(Ut),{name:e?.name})}}const Ct=`(function(){"use strict";function c(u,s,t){const n=[];if(s>=t)return n;let e=s,o=u[s];for(let r=s+1;r<t;r++){const f=u[r];f!==o&&(n.push(e,r-e,o),e=r,o=f)}return n.push(e,t-e,o),n}self.onmessage=u=>{const{bufferY:s,start:t,end:n}=u.data,e=new Float32Array(s);self.postMessage(c(e,t,n))}})();
11
- `,Dt=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Ct],{type:"text/javascript;charset=utf-8"});function Yr(e){let t;try{if(t=Dt&&(self.URL||self.webkitURL).createObjectURL(Dt),!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(Ct),{name:e?.name})}}const Ft=`(function(){"use strict";function o(s,i,t,n,l){const f=[];if(n==="Less than")for(let e=i;e<t;e++)s[e]-s[e-1]<l&&f.push(e);else if(n==="Less than or equal to")for(let e=i;e<t;e++)s[e]-s[e-1]<=l&&f.push(e);else if(n==="Greater than")for(let e=i;e<t;e++)s[e]-s[e-1]>l&&f.push(e);else if(n==="Greater than or equal to")for(let e=i;e<t;e++)s[e]-s[e-1]>=l&&f.push(e);else if(n==="Equal")for(let e=i;e<t;e++)s[e]-s[e-1]==l&&f.push(e);return f}self.onmessage=s=>{const{bufferY:i,start:t,end:n,comparator:l,value:f}=s.data,e=new Float32Array(i);self.postMessage(o(e,t,n,l,f))}})();
12
- `,Pt=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Ft],{type:"text/javascript;charset=utf-8"});function Hr(e){let t;try{if(t=Pt&&(self.URL||self.webkitURL).createObjectURL(Pt),!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(Ft),{name:e?.name})}}const Nt=`(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
- `,Bt=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Nt],{type:"text/javascript;charset=utf-8"});function zr(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(Nt),{name:e?.name})}}const jt=`(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
- `,Wt=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",jt],{type:"text/javascript;charset=utf-8"});function Ne(e){let t;try{if(t=Wt&&(self.URL||self.webkitURL).createObjectURL(Wt),!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(jt),{name:e?.name})}}const xt=`(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
- `,Gt=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",xt],{type:"text/javascript;charset=utf-8"});function Xr(e){let t;try{if(t=Gt&&(self.URL||self.webkitURL).createObjectURL(Gt),!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(xt),{name:e?.name})}}function Yt(e,t,r,n,s){const a=[],o=n.length;for(let i=t;i<r;i++){const l=e[i];let f=!1;for(let u=0;u<o;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&&a.push(i)}return a}function Vr(e,t,r,n,s){const a=[];if(n==="Less than")for(let o=t;o<r;o++)e[o]-e[o-1]<s&&a.push(o);else if(n==="Less than or equal to")for(let o=t;o<r;o++)e[o]-e[o-1]<=s&&a.push(o);else if(n==="Greater than")for(let o=t;o<r;o++)e[o]-e[o-1]>s&&a.push(o);else if(n==="Greater than or equal to")for(let o=t;o<r;o++)e[o]-e[o-1]>=s&&a.push(o);else if(n==="Equal")for(let o=t;o<r;o++)e[o]-e[o-1]==s&&a.push(o);return a}function qr(e,t,r,n,s){const a=[];if(n==="Less than")for(let o=t;o<r;o++){const i=e[o-1];(e[o]-i)/Math.abs(i)<s&&a.push(o)}else if(n==="Less than or equal to")for(let o=t;o<r;o++){const i=e[o-1];(e[o]-i)/Math.abs(i)<=s&&a.push(o)}else if(n==="Greater than")for(let o=t;o<r;o++){const i=e[o-1];(e[o]-i)/Math.abs(i)>s&&a.push(o)}else if(n==="Greater than or equal to")for(let o=t;o<r;o++){const i=e[o-1];(e[o]-i)/Math.abs(i)>=s&&a.push(o)}else if(n==="Equal")for(let o=t;o<r;o++){const i=e[o-1];(e[o]-i)/Math.abs(i)==s&&a.push(o)}return a}function Jr(e,t,r,n){const s=[];let a=e[t];for(let o=t+1;o<=r;o++){const i=e[o];i-a>n&&s.push(o-1,o),a=i}return s}function Kr(e,t,r){const n=[];if(t>=r)return n;let s=t,a=e[t];for(let o=t+1;o<r;o++){const i=e[o];i!==a&&(n.push(s,o-s,a),s=o,a=i)}return n.push(s,r-s,a),n}function Qr(e,t,r,n,s,a,o,i,l,f,u){let p=0,g=i;for(let y=a;y<=o;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],T=b-S,L=k-w;let $=S+l;for(;$<b;)n[g]=$,s[g]=f?w+($-S)*L/T:u,g++,$+=l;p++}return g-i}function Zr(e,t,r,n,s,a,o,i){let l=a,f=0,u=i;const p=r.length;for(;l<o&&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<o;)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 en(e,t,r,n,s,a,o,i){let l=0,f=i;for(let u=a;u<=o;u++)l<r.length&&u===r[l]?l++:(n[f]=e[u],s[f]=t[u],f++);return f-i}function tn(e,t,r,n){const s=r.length,a=new Array(s);if(n.isMonth)for(let o=0;o<s;o++){const i=r[o],l=new Date(e[i]);l.setMonth(l.getMonth()+n.amount),a[o]=[l.getTime(),t[i]]}else if(n.isYear)for(let o=0;o<s;o++){const i=r[o],l=new Date(e[i]);l.setFullYear(l.getFullYear()+n.amount),a[o]=[l.getTime(),t[i]]}else for(let o=0;o<s;o++){const i=r[o];a[o]=[e[i]+n.deltaMs,t[i]]}return a}function rn(e,t,r){for(let n=0;n<r.length;n++){const{indexes:s,lowerIdx:a,upperIdx:o}=r[n],i=e[a],l=t[a],f=e[o],u=t[o],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 nn(e,t,r){for(let n=0;n<r.length;n++){const s=r[n][0],a=r[n][1],o=r[n][2];if(a<=s)continue;const i=e[s],l=e[a]-i;if(l!==0)for(let f=s;f<a;f++)t[f]=t[f]+o*((e[f]-i)/l)}}function Ht(e,t,r,n){const s=t.length;if(r==="ADD")for(let a=0;a<s;a++)e[t[a]]=e[t[a]]+n;else if(r==="SUB")for(let a=0;a<s;a++)e[t[a]]=e[t[a]]-n;else if(r==="MULT")for(let a=0;a<s;a++)e[t[a]]=e[t[a]]*n;else if(r==="DIV")for(let a=0;a<s;a++)e[t[a]]=e[t[a]]/n;else if(r==="ASSIGN")for(let a=0;a<s;a++)e[t[a]]=n}const Be="qc-utils:calibration:v1",sn=720*60*60*1e3,de=5e4,pe=2e5,ye={spawnOverheadMs:50,inlineThroughput:5e4,workerThroughput:8e4,hwConcurrency:4,measuredAt:0,userAgent:"default"};let U=dn()??ye,je=null,ne=null;const We=new Set,xe={[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 F(e,t){const r=xe[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=on(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)),a=r.weight*n/U.inlineThroughput,o=U.spawnOverheadMs+r.weight*n/(U.workerThroughput*s),i=a>o;return{useWorker:i,predictedInlineMs:a,predictedWorkerMs:o,reason:i?`worker faster (${o.toFixed(1)} vs ${a.toFixed(1)} ms)`:`inline faster (${a.toFixed(1)} vs ${o.toFixed(1)} ms)`}}function on(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 an(e){return We.add(e),()=>We.delete(e)}function cn(){return U}function ln(){return je}function un(){return Object.keys(xe).map(e=>({op:e,...xe[e]}))}function hn(){U=ye,je=null;try{localStorage.removeItem(Be)}catch{}}async function fn(e={}){if(typeof window>"u"||!(e.force||U.measuredAt===0||Date.now()-U.measuredAt>sn))return U;if(ne)await ne;else{ne=zt().finally(()=>{ne=null});const r=await ne;U=r,pn(r),je=r;for(const n of We)n(U)}return U}async function zt(){if(!(typeof SharedArrayBuffer<"u"))return{...ye,measuredAt:Date.now(),userAgent:navigator.userAgent,hwConcurrency:navigator.hardwareConcurrency||ye.hwConcurrency,sharedArrayBufferAvailable:!1,samples:{spawnRoundtripMs:[],inlineScanMs:[],workerScanMs:[]}};const t=navigator.hardwareConcurrency||4,r=new Float32Array(de);for(let h=0;h<de;h++)r[h]=Math.sin(h);const n=await Ge(3,()=>{const h=performance.now();return Yt(r,0,de,[2],[.5]),performance.now()-h}),s=Ye(n),a=de/Math.max(s,.001),o=new SharedArrayBuffer(256*Float32Array.BYTES_PER_ELEMENT),i=await Ge(3,async()=>{const h=performance.now();return await new Promise(S=>{const b=new Ne;b.onmessage=()=>{b.terminate(),S()},b.postMessage({bufferY:o,start:0,end:256,ops:[2],values:[.5]})}),performance.now()-h}),l=Ye(i),f=new SharedArrayBuffer(pe*Float32Array.BYTES_PER_ELEMENT),u=new Float32Array(f);for(let h=0;h<pe;h++)u[h]=Math.sin(h);const p=await Ge(3,async()=>{const h=performance.now();return await new Promise(S=>{const b=new Ne;b.onmessage=()=>{b.terminate(),S()},b.postMessage({bufferY:f,start:0,end:pe,ops:[2],values:[.5]})}),performance.now()-h}),g=Math.max(Ye(p)-l,.1),y=pe/g;return{spawnOverheadMs:l,inlineThroughput:a,workerThroughput:y,hwConcurrency:t,measuredAt:Date.now(),userAgent:navigator.userAgent,sharedArrayBufferAvailable:!0,samples:{spawnRoundtripMs:i,inlineScanMs:n,workerScanMs:p}}}async function Ge(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 Ye(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 dn(){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 pn(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 Q=20*1e3,yn=1024,gn=["date","value","qualifier"],mn=typeof SharedArrayBuffer<"u";function C(e,t){return mn?t!==void 0?new SharedArrayBuffer(e,{maxByteLength:t}):new SharedArrayBuffer(e):t!==void 0?new ArrayBuffer(e,{maxByteLength:t}):new ArrayBuffer(e)}function Xt(e,t){const r=e;typeof r.grow=="function"?r.grow(t):typeof r.resize=="function"&&r.resize(t)}class wn{dataset={dimensions:gn,source:{x:new Float64Array(C(Q*Float64Array.BYTES_PER_ELEMENT,Q*Float64Array.BYTES_PER_ELEMENT)),y:new Float32Array(C(Q*Float32Array.BYTES_PER_ELEMENT,Q*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 he(()=>{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+=Q*Float64Array.BYTES_PER_ELEMENT;if(n*Float64Array.BYTES_PER_ELEMENT>this.dataX.buffer.maxByteLength){const s=C(this.dataX.buffer.byteLength,n*Float64Array.BYTES_PER_ELEMENT),a=C(this.dataY.buffer.byteLength,n*Float32Array.BYTES_PER_ELEMENT),o=new Float64Array(s),i=new Float32Array(a);o.set(this.dataX),i.set(this.dataY),this.dataset.source.x=o,this.dataset.source.y=i}this.dataX.buffer.byteLength<t*Float64Array.BYTES_PER_ELEMENT&&(Xt(this.dataX.buffer,t*Float64Array.BYTES_PER_ELEMENT),Xt(this.dataY.buffer,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 a=[];try{this._isReplaying||(this.redoStack.length=0);const o={method:t,args:r,icon:s[t],isLoading:!0};this.history.push(o);const i=this.history.length-1;this._pendingExecutionMode="inline";const l=await he(async()=>await n[t].apply(this,r));a=l.response;const f=this.history[i];f&&(f.duration=l.duration,f.executionMode=this._pendingExecutionMode,f.isLoading=!1)}catch(o){console.log(`Failed to execute operation: ${t} with arguments: `,r),console.log(o)}return a}async dispatch(t,...r){const n=async(s,a)=>v[s]?await this.dispatchFilter(s,...a):await this.dispatchAction(s,...a);if(Array.isArray(t)){let s=[];for(let a=0;a<t.length;a++){const o=t[a][0],i=t[a].slice(1,t[a].length);s=await n(o,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 a=[];try{this._isReplaying||(this.redoStack.length=0);const o={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]=o):(this.history.push(o),l=this.history.length-1),this._pendingExecutionMode="inline";const f=await he(async()=>await n[t].apply(this,r));a=f.response;const u=this.history[l];u&&(u.duration=f.duration,u.executionMode=this._pendingExecutionMode,u.selected=f.response,u.isLoading=!1)}catch(o){console.log(`Failed to execute filter operation: ${t} with arguments: `,r),console.log(o)}return a}async _changeValues(t,r){const n=this.history[this.history.length-2]?.selected;if(!n||n.length===0)return[];const s=n.length;if(!F(E.CHANGE_VALUES,{datasetSize:this.dataset.source.y.length,selectionSize:s}).useWorker||s<yn)return Ht(this.dataY,n,t,r),[];this._pendingExecutionMode="worker";const o=Math.min(navigator.hardwareConcurrency||1,s),i=Math.ceil(s/o),l=[],f=[];for(let u=0;u<o;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 Xr;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){Ht(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 a=0;a<n;a++)s[r[a]]=t[a];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),a=new Array(n);for(let o=0;o<n;o++)s[o]=[t[o],this.dataY[r[o]]],a[o]=r[o];return a.sort((o,i)=>o-i),await this._deleteDataPoints(a),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(!F(E.INTERPOLATE,{datasetSize:n,selectionSize:t.length}).useWorker){rn(this.dataX,this.dataY,s);return}this._pendingExecutionMode="worker";const o=Math.min(navigator.hardwareConcurrency||1,s.length),i=Math.ceil(s.length/o),l=[],f=[];for(let u=0;u<o;u++){const p=s.slice(u*i,(u+1)*i);if(p.length===0)break;f.push(new Promise(g=>{const y=new Br;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,a=n===O.YEAR,o=!s&&!a?r*te[n]*1e3:0,i=t.length;if(!F(E.SHIFT_DATETIMES,{datasetSize:this.dataset.source.x.length,selectionSize:i}).useWorker){const w=tn(this.dataX,this.dataY,t,{amount:r,isMonth:s,isYear:a,deltaMs:o});await this._deleteDataPoints(t),await this._addDataPoints(w);return}this._pendingExecutionMode="worker";const f=C(i*Float64Array.BYTES_PER_ELEMENT),u=C(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,T=Math.min((w+1)*g,i);if(k>=T)break;const L=t.slice(k,T);d.push(new Promise($=>{const M=new xr;y.push(M),M.postMessage({bufferX:this.dataX.buffer,bufferY:this.dataY.buffer,outputBufferX:f,outputBufferY:u,indexes:L,outStart:k,amount:r,isMonth:s,isYear:a,deltaMs:o}),M.onmessage=X=>{$(X.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,a){const o=this.dataX.length;if(o===0)return;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=[];let d=0;for(let A=f+1;A<=u;A++)if(p[A]-p[A-1]>i){let j=0,V=p[A-1]+l;for(;V<p[A];)j++,V+=l;j>0&&(g.push([A-1,A]),y.push(j),d+=j)}if(d===0)return;const h=o+d,S=h*Float64Array.BYTES_PER_ELEMENT,b=h*Float32Array.BYTES_PER_ELEMENT,w=C(S,Math.max(this.dataX.buffer.maxByteLength,S)),k=C(b,Math.max(this.dataY.buffer.maxByteLength,b));if(!F(E.FILL_GAPS,{datasetSize:o,selectionSize:d}).useWorker){const A=new Float64Array(w),x=new Float32Array(k);Qr(this.dataX,this.dataY,g,A,x,0,o-1,0,l,n,s),this.dataset.source.x=A,this.dataset.source.y=x,this._resizeTo(h);return}this._pendingExecutionMode="worker";const L=navigator.hardwareConcurrency||1,$=Math.ceil(o/L),M=[];let X=0;for(let A=0;A<L;A++){const x=A*$,j=Math.min((A+1)*$-1,o-1),V=[];let ge=0;for(;X<g.length&&g[X][0]<=j;)V.push(g[X]),ge+=y[X],X++;M.push({start:x,end:j,gapsSegment:V,fillsInSegment:ge})}const He=new Array(L).fill(0);for(let A=1;A<L;A++)He[A]=He[A-1]+M[A-1].fillsInSegment;const Vt=[],qt=[];for(let A=0;A<L;A++){const{start:x,end:j,gapsSegment:V}=M[A],ge=x+He[A];qt.push(new Promise(bn=>{const ze=new Nr;Vt.push(ze),ze.postMessage({bufferX:this.dataX.buffer,bufferY:this.dataY.buffer,outputBufferX:w,outputBufferY:k,start:x,end:j,gapsSegment:V,startTarget:ge,fillDelta:l,interpolate:n,fillValue:s}),ze.onmessage=Sn=>{bn(Sn.data)}}))}await Promise.all(qt),Vt.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(!F(E.DELETE_POINTS,{datasetSize:r,selectionSize:t.length}).useWorker){const y=C(this.dataX.buffer.byteLength,this.dataX.buffer.maxByteLength),d=C(this.dataY.buffer.byteLength,this.dataY.buffer.maxByteLength),h=new Float64Array(y),S=new Float32Array(d);en(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 a=navigator.hardwareConcurrency||1,o=Math.ceil(this.dataX.length/a),i=[],l=[];for(let y=0;y<a;y++){const d=y*o,h=Math.min((y+1)*o-1,this.dataX.length-1),S=re(t,d),b=fe(t,h),w=t.slice(S,b+1);l.push({start:d,end:h,deleteSegment:w})}const f=new Array(a).fill(0);for(let y=1;y<a;y++)f[y]=f[y-1]+l[y-1].deleteSegment.length;const u=[],p=C(this.dataX.buffer.byteLength,this.dataX.buffer.maxByteLength),g=C(this.dataY.buffer.byteLength,this.dataY.buffer.maxByteLength);for(let y=0;y<a;y++){const{start:d,end:h,deleteSegment:S}=l[y],b=d-f[y];u.push(new Promise(w=>{const k=new Pr;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=T=>{w(T.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(!F(E.DRIFT_CORRECTION,{datasetSize:r.length,selectionSize:s}).useWorker){nn(r,this.dataY,t);return}this._pendingExecutionMode="worker";const o=[];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)o.push({chunkStart:w,chunkEnd:Math.min(w+b,g),startDatetime:d,value:y,extent:h})}if(o.length===0)return;const i=Math.min(n,o.length),l=Array.from({length:i},()=>[]);o.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 jr;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 a=n[n.length-1];return!a.length||s==a[a.length-1]+1?a.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,a=n*Float32Array.BYTES_PER_ELEMENT,o=C(s,Math.max(this.dataX.buffer.maxByteLength,s)),i=C(a,Math.max(this.dataY.buffer.maxByteLength,a));if(!F(E.ADD_POINTS,{datasetSize:r,selectionSize:t.length}).useWorker){const d=new Float64Array(o),h=new Float32Array(i);Zr(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=>fe(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=re(f,h),w=d===u-1?t.length:re(f,S),k=t.slice(b,w),T=h+b;h>=S&&k.length===0||y.push(new Promise(L=>{const $=new Wr;g.push($),$.postMessage({bufferX:this.dataX.buffer,bufferY:this.dataY.buffer,outputBufferX:o,outputBufferY:i,origStart:h,origEnd:S,insertions:k,outStart:T}),$.onmessage=M=>{L(M.data)}}))}await Promise.all(y),g.forEach(d=>d.terminate()),this.dataset.source.x=new Float64Array(o),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={[G.LT]:0,[G.LTE]:1,[G.GT]:2,[G.GTE]:3,[G.E]:4},s=r.map(h=>n[h]??4),a=r.map(h=>t[h]),o=this.dataset.source.y,i=o.length;if(i===0)return[];if(!F(v.VALUE_THRESHOLD,{datasetSize:i}).useWorker)return Yt(o,0,i,s,a);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 Ne;p.push(k),k.postMessage({bufferY:this.dataY.buffer,start:S,end:b,ops:s,values:a}),k.onmessage=T=>{w(T.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,a=n.length,o=a-s;if(!F(v.RATE_OF_CHANGE,{datasetSize:n.length}).useWorker)return qr(n,s,a,t,r);this._pendingExecutionMode="worker";const l=Math.min(navigator.hardwareConcurrency||1,o),f=Math.ceil(o/l),u=[],p=[];for(let d=0;d<l;d++){const h=s+d*f,S=Math.min(s+(d+1)*f,a);if(h>=S)break;p.push(new Promise(b=>{const w=new zr;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 a=t==null?0:re(n,t),o=r==null?s-1:fe(n,r);if(a>o)return[];const i=new Array(o-a+1);for(let l=a;l<=o;l++)i[l-a]=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,a=n.length,o=a-s;if(!F(v.CHANGE,{datasetSize:n.length}).useWorker)return Vr(n,s,a,t,r);this._pendingExecutionMode="worker";const l=Math.min(navigator.hardwareConcurrency||1,o),f=Math.ceil(o/l),u=[],p=[];for(let d=0;d<l;d++){const h=s+d*f,S=Math.min(s+(d+1)*f,a);if(h>=S)break;p.push(new Promise(b=>{const w=new Hr;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 a=0,o=s.length;if(n?.[0]&&n?.[1]&&(a=n[0],o=n[1]),o<=a)return[];const i=t*te[r]*1e3;if(!F(v.FIND_GAPS,{datasetSize:o-a}).useWorker){const S=Jr(s,a,o-1,i),b=new Set;for(let w=0;w<S.length;w++)b.add(S[w]);return[...b]}this._pendingExecutionMode="worker";const f=o-a,u=Math.min(navigator.hardwareConcurrency||1,f),p=Math.ceil(f/u),g=[],y=[];for(let S=0;S<u;S++){const b=a+S*p,w=Math.min(a+(S+1)*p,o);if(b>=w)break;y.push(new Promise(k=>{const T=new Gr;g.push(T),T.postMessage({bufferX:this.dataX.buffer,start:b,endInclusive:w,threshold:i}),T.onmessage=L=>{k(L.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,a=n.length;if(r?.[0]&&r?.[1]&&(s=r[0],a=r[1]),a<=s)return[];const o=a-s;if(!F(v.PERSISTENCE,{datasetSize:o}).useWorker){const b=Kr(n,s,a),w=[];for(let k=0;k<b.length;k+=3){const T=b[k],L=b[k+1];if(L>=t)for(let $=0;$<L;$++)w.push(T+$)}return w}this._pendingExecutionMode="worker";const l=Math.min(navigator.hardwareConcurrency||1,o),f=Math.ceil(o/l),u=[],p=[];for(let b=0;b<l;b++){const w=s+b*f,k=Math.min(s+(b+1)*f,a);if(w>=k)break;p.push(new Promise(T=>{const L=new Yr;u.push(L),L.postMessage({bufferY:this.dataY.buffer,start:w,end:k}),L.onmessage=$=>{T($.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 T=w[k],L=w[k+1],$=w[k+2],M=y.length-1;M>=0&&h[M]===$&&y[M]+d[M]===T?d[M]+=L:(y.push(T),d.push(L),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 T=0;T<w;T++)S.push(k+T)}}return S}}m.ACCOUNT_BASE=P,m.AUTH_BASE=ce,m.ApiKey=ir,m.BASE_URL=D,m.Collaborator=lr,m.DEFAULT_SNACK_DURATION=Le,m.DataSource=Lr,m.Datastream=Qt,m.EnumEditOperations=E,m.EnumFilterOperations=v,m.FilterOperation=G,m.HydroShareArchive=qe,m.INCREASE_AMOUNT=Q,m.Location=Je,m.LogicalOperation=Ve,m.OAuthProvider=ar,m.ObservationRecord=wn,m.ObservedProperty=tr,m.Operator=Xe,m.Organization=sr,m.PROVIDER_BASE=Z,m.Payload=Ir,m.PermissionAction=Ke,m.PermissionResource=Qe,m.Position=ut,m.PostHydroShareArchive=Jt,m.ProcessingLevel=rr,m.ResultQualifier=nr,m.SESSION_BASE=le,m.Sensor=er,m.Snack=ht,m.SnackColor=$e,m.SnackIcon=Re,m.SnackTitle=Ie,m.Snackbar=ft,m.TAG_BASE=De,m.THINGS_BASE=_,m.Thing=Kt,m.TimeUnit=O,m.Unit=Zt,m.User=or,m.Workspace=cr,m.api=Rr,m.apiMethods=c,m.clearCalibration=hn,m.createPatchObject=Oe,m.ensureCalibration=fn,m.extractErrorMessage=Ze,m.findFirstGreaterOrEqual=re,m.findLastLessOrEqual=fe,m.formatDate=Cr,m.formatDuration=Dr,m.getCSRFToken=me,m.getCalibration=cn,m.getLastBenchmarkDetail=ln,m.getObservationsEndpoint=$r,m.getOperationTable=un,m.measureEllapsedTime=he,m.onCalibrationChange=an,m.requestInterceptor=we,m.responseInterceptor=be,m.runBenchmarks=zt,m.shouldUseWorker=F,m.subtractHours=Fr,m.timeUnitMultipliers=te,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})}));
3
+ `):"",this.name="UnsubscriptionError",this.errors=r}});function Te(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var ie=(function(){function e(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var t,r,n,s,o;if(!this.closed){this.closed=!0;var a=this._parentage;if(a)if(this._parentage=null,Array.isArray(a))try{for(var i=ve(a),l=i.next();!l.done;l=i.next()){var f=l.value;f.remove(this)}}catch(u){t={error:u}}finally{try{l&&!l.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}else a.remove(this);var h=this.initialTeardown;if(B(h))try{h()}catch(u){o=u instanceof Ae?u.errors:[u]}var y=this._finalizers;if(y){this._finalizers=null;try{for(var p=ve(y),g=p.next();!g.done;g=p.next()){var d=g.value;try{st(d)}catch(u){o=o??[],u instanceof Ae?o=_e(_e([],ke(o)),ke(u.errors)):o.push(u)}}}catch(u){n={error:u}}finally{try{g&&!g.done&&(s=p.return)&&s.call(p)}finally{if(n)throw n.error}}}if(o)throw new Ae(o)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)st(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(r=this._finalizers)!==null&&r!==void 0?r:[]).push(t)}},e.prototype._hasParent=function(t){var r=this._parentage;return r===t||Array.isArray(r)&&r.includes(t)},e.prototype._addParent=function(t){var r=this._parentage;this._parentage=Array.isArray(r)?(r.push(t),r):r?[r,t]:t},e.prototype._removeParent=function(t){var r=this._parentage;r===t?this._parentage=null:Array.isArray(r)&&Te(r,t)},e.prototype.remove=function(t){var r=this._finalizers;r&&Te(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=(function(){var t=new e;return t.closed=!0,t})(),e})(),rt=ie.EMPTY;function nt(e){return e instanceof ie||e&&"closed"in e&&B(e.remove)&&B(e.add)&&B(e.unsubscribe)}function st(e){B(e)?e():e.unsubscribe()}var hr={Promise:void 0},fr={setTimeout:function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setTimeout.apply(void 0,_e([e,t],ke(r)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function dr(e){fr.setTimeout(function(){throw e})}function ot(){}function ce(e){e()}var at=(function(e){ae(t,e);function t(r){var n=e.call(this)||this;return n.isStopped=!1,r?(n.destination=r,nt(r)&&r.add(n)):n.destination=gr,n}return t.create=function(r,n,s){return new Le(r,n,s)},t.prototype.next=function(r){this.isStopped||this._next(r)},t.prototype.error=function(r){this.isStopped||(this.isStopped=!0,this._error(r))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(r){this.destination.next(r)},t.prototype._error=function(r){try{this.destination.error(r)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t})(ie),pr=(function(){function e(t){this.partialObserver=t}return e.prototype.next=function(t){var r=this.partialObserver;if(r.next)try{r.next(t)}catch(n){le(n)}},e.prototype.error=function(t){var r=this.partialObserver;if(r.error)try{r.error(t)}catch(n){le(n)}else le(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(r){le(r)}},e})(),Le=(function(e){ae(t,e);function t(r,n,s){var o=e.call(this)||this,a;return B(r)||!r?a={next:r??void 0,error:n??void 0,complete:s??void 0}:a=r,o.destination=new pr(a),o}return t})(at);function le(e){dr(e)}function yr(e){throw e}var gr={closed:!0,next:ot,error:yr,complete:ot},mr=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function wr(e){return e}function br(e){return e.length===0?wr:e.length===1?e[0]:function(r){return e.reduce(function(n,s){return s(n)},r)}}var it=(function(){function e(t){t&&(this._subscribe=t)}return e.prototype.lift=function(t){var r=new e;return r.source=this,r.operator=t,r},e.prototype.subscribe=function(t,r,n){var s=this,o=Er(t)?t:new Le(t,r,n);return ce(function(){var a=s,i=a.operator,l=a.source;o.add(i?i.call(o,l):l?s._subscribe(o):s._trySubscribe(o))}),o},e.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(r){t.error(r)}},e.prototype.forEach=function(t,r){var n=this;return r=ct(r),new r(function(s,o){var a=new Le({next:function(i){try{t(i)}catch(l){o(l),a.unsubscribe()}},error:o,complete:s});n.subscribe(a)})},e.prototype._subscribe=function(t){var r;return(r=this.source)===null||r===void 0?void 0:r.subscribe(t)},e.prototype[mr]=function(){return this},e.prototype.pipe=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return br(t)(this)},e.prototype.toPromise=function(t){var r=this;return t=ct(t),new t(function(n,s){var o;r.subscribe(function(a){return o=a},function(a){return s(a)},function(){return n(o)})})},e.create=function(t){return new e(t)},e})();function ct(e){var t;return(t=e??hr.Promise)!==null&&t!==void 0?t:Promise}function Sr(e){return e&&B(e.next)&&B(e.error)&&B(e.complete)}function Er(e){return e&&e instanceof at||Sr(e)&&nt(e)}var vr=tt(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),lt=(function(e){ae(t,e);function t(){var r=e.call(this)||this;return r.closed=!1,r.currentObservers=null,r.observers=[],r.isStopped=!1,r.hasError=!1,r.thrownError=null,r}return t.prototype.lift=function(r){var n=new ut(this,this);return n.operator=r,n},t.prototype._throwIfClosed=function(){if(this.closed)throw new vr},t.prototype.next=function(r){var n=this;ce(function(){var s,o;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var a=ve(n.currentObservers),i=a.next();!i.done;i=a.next()){var l=i.value;l.next(r)}}catch(f){s={error:f}}finally{try{i&&!i.done&&(o=a.return)&&o.call(a)}finally{if(s)throw s.error}}}})},t.prototype.error=function(r){var n=this;ce(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=r;for(var s=n.observers;s.length;)s.shift().error(r)}})},t.prototype.complete=function(){var r=this;ce(function(){if(r._throwIfClosed(),!r.isStopped){r.isStopped=!0;for(var n=r.observers;n.length;)n.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var r;return((r=this.observers)===null||r===void 0?void 0:r.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(r){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,r)},t.prototype._subscribe=function(r){return this._throwIfClosed(),this._checkFinalizedStatuses(r),this._innerSubscribe(r)},t.prototype._innerSubscribe=function(r){var n=this,s=this,o=s.hasError,a=s.isStopped,i=s.observers;return o||a?rt:(this.currentObservers=null,i.push(r),new ie(function(){n.currentObservers=null,Te(i,r)}))},t.prototype._checkFinalizedStatuses=function(r){var n=this,s=n.hasError,o=n.thrownError,a=n.isStopped;s?r.error(o):a&&r.complete()},t.prototype.asObservable=function(){var r=new it;return r.source=this,r},t.create=function(r,n){return new ut(r,n)},t})(it),ut=(function(e){ae(t,e);function t(r,n){var s=e.call(this)||this;return s.destination=r,s.source=n,s}return t.prototype.next=function(r){var n,s;(s=(n=this.destination)===null||n===void 0?void 0:n.next)===null||s===void 0||s.call(n,r)},t.prototype.error=function(r){var n,s;(s=(n=this.destination)===null||n===void 0?void 0:n.error)===null||s===void 0||s.call(n,r)},t.prototype.complete=function(){var r,n;(n=(r=this.destination)===null||r===void 0?void 0:r.complete)===null||n===void 0||n.call(r)},t.prototype._subscribe=function(r){var n,s;return(s=(n=this.source)===null||n===void 0?void 0:n.subscribe(r))!==null&&s!==void 0?s:rt},t})(lt);const $e=3e3;var Re=(e=>(e.Warning="warning",e.Success="success",e.Error="error",e.Info="info",e))(Re||{}),Ie=(e=>(e.Success="mdi-checkbox-marked-circle",e.Warning="mdi-alert",e.Error="mdi-alert-circle",e.Info="mdi-information",e.None="none",e))(Ie||{}),Oe=(e=>(e.Warning="Warning",e.Success="Success",e.Error="Error",e.Info="Info",e))(Oe||{}),ht=(e=>(e.Center="center",e.Left="left",e.Right="right",e.Bottom="bottom",e.Top="top",e))(ht||{});class ft{constructor(t="",r="info",n="none",s="Info",o=$e,a="center",i=!1){this.message=t,this.color=r,this.icon=n,this.title=s,this.timeout=o,this.position=a,this.visible=i}}class dt{static subject=new lt;static get snack$(){return this.subject.asObservable()}static createSnackbar(t,r){this.subject.next(new ft(t,Re[r],Ie[r],Oe[r],$e,"bottom",!0))}static success(t){this.createSnackbar(t,"Success")}static warn(t){this.createSnackbar(t,"Warning")}static error(t){this.createSnackbar(t,"Error")}static info(t){this.createSnackbar(t,"Info")}}function Ue(e,t){const r={};for(let n in t)if(Array.isArray(t[n]))JSON.stringify(e[n])!==JSON.stringify(t[n])&&(r[n]=t[n]);else if(e[n]&&typeof e[n]=="object"&&t[n]&&typeof t[n]=="object"){const s=Ue(e[n],t[n]);Object.keys(s).length>0&&(r[n]=s)}else JSON.stringify(e[n])!==JSON.stringify(t[n])&&(r[n]=t[n]);return r}function kr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Me,pt;function _r(){if(pt)return Me;pt=1;class e{constructor(n){this.value=n,this.next=void 0}}class t{constructor(){this.clear()}enqueue(n){const s=new e(n);this._head?(this._tail.next=s,this._tail=s):(this._head=s,this._tail=s),this._size++}dequeue(){const n=this._head;if(n)return this._head=this._head.next,this._size--,n.value}clear(){this._head=void 0,this._tail=void 0,this._size=0}get size(){return this._size}*[Symbol.iterator](){let n=this._head;for(;n;)yield n.value,n=n.next}}return Me=t,Me}var Ce,yt;function Ar(){if(yt)return Ce;yt=1;const e=_r();return Ce=r=>{if(!((Number.isInteger(r)||r===1/0)&&r>0))throw new TypeError("Expected `concurrency` to be a number from 1 and up");const n=new e;let s=0;const o=()=>{s--,n.size>0&&n.dequeue()()},a=async(f,h,...y)=>{s++;const p=(async()=>f(...y))();h(p);try{await p}catch{}o()},i=(f,h,...y)=>{n.enqueue(a.bind(null,f,h,...y)),(async()=>(await Promise.resolve(),s<r&&n.size>0&&n.dequeue()()))()},l=(f,...h)=>new Promise(y=>{i(f,y,...h)});return Object.defineProperties(l,{activeCount:{get:()=>s},pendingCount:{get:()=>n.size},clearQueue:{value:()=>{n.clear()}}}),l},Ce}var Tr=Ar();const z=kr(Tr)(10),Lr=1e3;async function Q(e,t){const r=be(t);try{const n=await fetch(e,r);return await Se(n)}catch(n){throw n instanceof TypeError&&dt.error("Network error. Please check your connection."),n}}const c={async fetch(e,t={}){return t.method="GET",await z(()=>Q(e,t))},async patch(e,t,r=null,n={}){if(n.method="PATCH",n.body=r?Ue(r,t):t,Object.keys(n.body).length!==0)return await z(()=>Q(e,n))},async post(e,t=void 0,r={}){return r.method="POST",r.body=t,await z(()=>Q(e,r))},async put(e,t=void 0,r={}){return r.method="PUT",r.body=t,await z(()=>Q(e,r))},async delete(e,t=void 0,r={}){return r.method="DELETE",r.body=t,await z(()=>Q(e,r))},async paginatedFetch(e,t){const r=t??Lr,n=e.includes("?")?"&":"?",s=`${e}${n}page_size=${r}&page=1`,o=be({method:"GET"}),a=await z(()=>fetch(s,o)),i=Number(a.headers.get("x-total-pages"))||1,f=[...await Se(a)];for(let h=2;h<=i;h++){const y=`${e}${n}page_size=${r}&page=${h}`,p=await z(()=>Q(y,{method:"GET"}));f.push(...p)}return f}},gt={HTTP:{type:"HTTP",sourceUri:"",placeholderVariables:[]},local:{type:"local",sourceUri:"",placeholderVariables:[]}},mt={JSON:{type:"JSON",timestamp:{key:"",format:"ISO8601",timezoneMode:"embeddedOffset"},JMESPath:""},CSV:{type:"CSV",timestamp:{key:"",format:"ISO8601",timezoneMode:"embeddedOffset"},headerRow:1,dataStartRow:2,delimiter:",",identifierType:"name"}},wt={HydroServer:{type:"HydroServer"}};class $r{name="";settings={type:"SDL",extractor:JSON.parse(JSON.stringify(gt.local)),transformer:JSON.parse(JSON.stringify(mt.CSV)),loader:JSON.parse(JSON.stringify(wt.HydroServer)),payloads:[]};id="";workspaceId="";orchestrationSystem={id:"",name:"",workspaceId:"",type:""};schedule={interval:15,intervalUnits:"minutes"};status={paused:!0};datastreams=[];constructor(t){Object.assign(this,t)}switchExtractor(t){this.settings.extractor=JSON.parse(JSON.stringify(gt[t]))}switchTransformer(t){this.settings.transformer=JSON.parse(JSON.stringify(mt[t]))}switchLoader(t){this.settings.loader=JSON.parse(JSON.stringify(wt[t]))}}function bt(e){return{name:e.name,settings:e.settings,workspaceId:e.workspaceId,orchestrationSystemId:e.orchestrationSystem.id,schedule:e.schedule,status:e.status}}const D="https://lro.hydroserver.org/api",ue=`${D}/auth`,N=`${ue}/browser/account`,he=`${ue}/browser/session`,te=`${ue}/browser/provider`,R=`${D}/data/workspaces`,De=`${D}/data/roles`,O=`${D}/data/datastreams`,x=`${D}/data/sensors`,_=`${D}/data/things`,Fe=`${_}/tags`,K=`${D}/data/orchestration-systems`,j=`${D}/data/data-sources`,X=`${D}/data/observed-properties`,Z=`${D}/data/processing-levels`,re=`${D}/data/result-qualifiers`,V=`${D}/data/units`,Rr=(e,t,r,n,s)=>{let o=`${O}/${e}/observations?format=column`;return o+=`&order_by=phenomenonTime&page_size=${t}`,o+=`&phenomenon_time_min=${encodeURIComponent(r)}`,n&&(o+=`&phenomenon_time_max=${encodeURIComponent(n)}`),s&&(o+=`&page=${s}`),o},Ir={fetchSession:async()=>c.fetch(`${he}`),login:async(e,t)=>c.post(`${he}`,{email:e,password:t}),logout:async()=>c.delete(`${he}`),fetchUser:async()=>c.fetch(`${N}`),signup:async e=>c.post(`${N}`,e),updateUser:async(e,t)=>c.patch(`${N}`,e,t),deleteUser:async()=>c.delete(`${N}`),sendVerificationEmail:async e=>c.put(`${N}/email/verify`,{email:e}),verifyEmailWithCode:async e=>c.post(`${N}/email/verify`,{key:e}),requestPasswordReset:async e=>c.post(`${N}/password/request`,{email:e}),resetPassword:async(e,t)=>c.post(`${N}/password/reset`,{key:e,password:t}),fetchWorkspaces:async()=>c.paginatedFetch(`${R}`),fetchAssociatedWorkspaces:async()=>c.paginatedFetch(`${R}?is_associated=true`),fetchWorkspace:async e=>c.fetch(`${R}/${e}`),createWorkspace:async e=>c.post(R,e),updateWorkspace:async(e,t=null)=>c.patch(`${R}/${e.id}`,e,t),deleteWorkspace:async e=>c.delete(`${R}/${e}`),transferWorkspace:async(e,t)=>c.post(`${R}/${e}/transfer`,{newOwner:t}),acceptWorkspaceTransfer:async e=>c.put(`${R}/${e}/transfer`),rejectWorkspaceTransfer:async e=>c.delete(`${R}/${e}/transfer`),getCollaboratorRoles:async e=>c.paginatedFetch(`${De}?is_user_role=true`),getAPIKeyRoles:async e=>c.paginatedFetch(`${De}?is_apikey_role=true`),getRole:async e=>c.fetch(`${De}/${e}`),getCollaborators:async e=>c.paginatedFetch(`${R}/${e}/collaborators`),addCollaborator:async(e,t,r)=>c.post(`${R}/${e}/collaborators`,{email:t,roleId:r}),updateCollaboratorRole:async(e,t,r)=>c.put(`${R}/${e}/collaborators`,{email:t,roleId:r}),removeCollaborator:async(e,t)=>c.delete(`${R}/${e}/collaborators`,{email:t}),fetchApiKeys:async e=>c.paginatedFetch(`${R}/${e}/api-keys?expand_related=true`),fetchApiKey:async(e,t)=>c.fetch(`${R}/${e}/api-keys/${t}?expand_related=true`),createApiKey:async e=>c.post(`${R}/${e.workspaceId}/api-keys?expand_related=true`,{name:e.name,description:e.description,isActive:!0,roleId:e.role.id}),updateApiKey:async(e,t)=>c.patch(`${R}/${e.workspaceId}/api-keys/${e.id}?expand_related=true`,{name:e.name,description:e.description,isActive:!0,roleId:e.role.id},t&&{name:t.name,description:t.description,isActive:!0,roleId:t.role.id}),regenerateApiKey:async(e,t)=>c.put(`${R}/${e}/api-keys/${t}/regenerate?expand_related=true`),deleteApiKey:async(e,t)=>c.delete(`${R}/${e}/api-keys/${t}`),fetchConnectedProviders:async()=>c.fetch(`${te}/connections`),providerRedirect:(e,t,r)=>{const n={provider:e,callback_url:t,process:r},s=we(),o=document.createElement("form");if(o.method="POST",o.action=`${te}/redirect`,s){const a=document.createElement("input");a.type="hidden",a.name="csrfmiddlewaretoken",a.value=s,o.appendChild(a)}for(const a in n){const i=document.createElement("input");i.type="hidden",i.name=a,i.value=n[a]||"",o.appendChild(i)}document.body.appendChild(o),o.submit()},providerSignup:async e=>c.post(`${te}/signup`,e),deleteProvider:async(e,t)=>c.delete(`${te}/connections`,{provider:e,account:t}),createUnit:async e=>c.post(V,e),fetchUnits:async()=>c.paginatedFetch(`${V}`),fetchWorkspaceUnits:async e=>c.paginatedFetch(`${V}?workspace_id=${e}`),updateUnit:async(e,t=null)=>c.patch(`${V}/${e.id}`,e,t),deleteUnit:async e=>c.delete(`${V}/${e}`),getUnit:async e=>c.fetch(`${V}/${e}`),removeThingOwner:async(e,t)=>c.patch(`${_}/${e}/ownership`,{email:t,removeOwner:!0}),addSecondaryOwner:async(e,t)=>c.patch(`${_}/${e}/ownership`,{email:t,makeOwner:!0}),transferPrimaryOwnership:async(e,t)=>c.patch(`${_}/${e}/ownership`,{email:t,transferPrimary:!0}),createThing:async e=>c.post(_,e),fetchThings:async()=>c.paginatedFetch(`${_}`),fetchThingsForWorkspace:async e=>c.paginatedFetch(`${_}?workspace_id=${e}`),fetchOwnedThings:async()=>c.paginatedFetch(`${_}?owned_only=true`),fetchThing:async e=>c.fetch(`${_}/${e}`),updateThing:async e=>c.patch(`${_}/${e.id}`,e),updateThingPrivacy:async(e,t)=>c.patch(`${_}/${e}`,{isPrivate:t}),deleteThing:async e=>c.delete(`${_}/${e}`),fetchMetadataForThingOwner:async e=>c.paginatedFetch(`${_}/${e}/metadata?include_assignable_metadata=true`),fetchMetadataForThing:async e=>c.fetch(`${_}/${e}/metadata`),uploadSitePhotos:async(e,t)=>c.post(`${_}/${e}/photos`,t),fetchSitePhotos:async e=>c.paginatedFetch(`${_}/${e}/photos`),deleteSitePhoto:async(e,t)=>c.delete(`${_}/${e}/photos`,{name:t}),createSiteTag:async(e,t)=>c.post(`${_}/${e}/tags`,t),editSiteTag:async(e,t)=>c.put(`${_}/${e}/tags`,t),fetchSiteTags:async e=>c.fetch(`${_}/${e}/tags`),fetchUsersSiteTags:async()=>c.fetch(`${Fe}`),deleteSiteTag:async(e,t)=>c.delete(`${_}/${e}/tags`,t),fetchWorkspaceTags:async e=>c.fetch(`${Fe}/keys?workspace_id=${e}`),createHydroShareArchive:async e=>c.post(`${_}/${e.thingId}/archive`,e),updateHydroShareArchive:async(e,t)=>c.patch(`${_}/${e.thingId}/archive`,e,t),fetchHydroShareArchive:async e=>c.fetch(`${_}/${e}/archive`),deleteHydroShareArchive:async e=>c.delete(`${_}/${e}/archive`),archiveToHydroShare:async e=>c.post(`${_}/${e}/archive/trigger`),createDatastream:async e=>c.post(O,e),fetchDatastreams:async e=>{const t=[];if(e)for(const[n,s]of Object.entries(e))t.push(`${encodeURIComponent(n)}=${encodeURIComponent(s)}`);const r=t.length?`?${t.join("&")}`:"";return c.paginatedFetch(`${O}${r}`)},fetchDatastreamsForThing:async e=>c.paginatedFetch(`${O}?thing_id=${e}`),fetchExpandedDatastreamsForThing:async e=>c.paginatedFetch(`${O}?thing_id=${e}&expand_related=true`),fetchDatastreamsForDataSource:async e=>c.paginatedFetch(`${O}?data_source_id=${e}`),fetchDatastream:async e=>c.fetch(`${O}/${e}`),fetchDatastreamExpanded:async e=>c.fetch(`${O}/${e}?expand_related=true`),fetchUsersDatastreams:async()=>c.paginatedFetch(`${O}?exclude_unowned=true`),updateDatastream:async(e,t=null)=>c.patch(`${O}/${e.id}`,e,t),deleteDatastream:async e=>c.delete(`${O}/${e}`),downloadDatastreamCSV:async e=>c.fetch(`${O}/${e}/csv`),createObservedProperty:async e=>c.post(X,e),fetchObservedProperty:async e=>c.fetch(`${X}/${e}`),fetchObservedProperties:async()=>c.paginatedFetch(`${X}`),fetchWorkspaceObservedProperties:async e=>c.paginatedFetch(`${X}?workspace_id=${e}`),updateObservedProperty:async(e,t=null)=>c.patch(`${X}/${e.id}`,e,t),deleteObservedProperty:async e=>c.delete(`${X}/${e}`),createProcessingLevel:async e=>c.post(Z,e),fetchProcessingLevels:async()=>c.paginatedFetch(`${Z}`),fetchProcessingLevel:async e=>c.fetch(`${Z}/${e}`),fetchWorkspaceProcessingLevels:async e=>c.paginatedFetch(`${Z}?workspace_id=${e}`),updateProcessingLevel:async(e,t=null)=>c.patch(`${Z}/${e.id}`,e,t),deleteProcessingLevel:async e=>c.delete(`${Z}/${e}`),createSensor:async e=>c.post(x,e),fetchSensors:async()=>c.paginatedFetch(`${x}`),fetchSensor:async e=>c.fetch(`${x}/${e}`),fetchWorkspaceSensors:async e=>c.paginatedFetch(`${x}?workspace_id=${e}`),updateSensor:async(e,t=null)=>c.patch(`${x}/${e.id}`,e,t),deleteSensor:async e=>c.delete(`${x}/${e}`),createResultQualifier:async e=>c.post(re,e),fetchResultQualifiers:async()=>c.paginatedFetch(`${re}`),fetchWorkspaceResultQualifiers:async e=>c.paginatedFetch(`${re}?workspace_id=${e}`),updateResultQualifier:async(e,t=null)=>c.patch(`${re}/${e.id}`,e,t),deleteResultQualifier:async e=>c.delete(`${re}/${e}`),createOrchestrationSystem:async e=>c.post(K,e),fetchOrchestrationSystems:async()=>c.paginatedFetch(K),fetchWorkspaceOrchestrationSystems:async e=>c.paginatedFetch(`${K}?workspace_id=${e}`),fetchOrchestrationSystem:async e=>c.fetch(`${K}/${e}`),updateOrchestrationSystem:async(e,t)=>c.patch(`${K}/${e}`,t),deleteOrchestrationSystem:async e=>c.delete(`${K}/${e}`),createDataSource:async e=>c.post(`${j}?expand_related=true`,bt(e)),fetchDataSources:async()=>c.paginatedFetch(`${j}?expand_related=true`),fetchWorkspaceDataSources:async e=>c.paginatedFetch(`${j}?workspace_id=${e}&expand_related=true`),fetchDataSource:async e=>c.fetch(`${j}/${e}?expand_related=true`),updateDataSource:async e=>c.patch(`${j}/${e.id}?expand_related=true`,bt(e)),updateDataSourcePartial:async e=>c.patch(`${j}/${e.id}?expand_related=true`,e),deleteDataSource:async e=>c.delete(`${j}/${e}`),linkDatastreamToDataSource:async(e,t)=>c.post(`${j}/${e}/datastreams/${t}`),unlinkDatastreamFromDataSource:async(e,t)=>c.delete(`${j}/${e}/datastreams/${t}`),fetchObservations:async e=>c.fetch(e),deleteObservationsForDatastream:async e=>c.post(`${O}/${e}/observations/bulk-delete`,{phenomenonTimeStart:null,phenomenonTimeEnd:null}),fetchUserTypes:async()=>c.fetch(`${N}/user-types`),fetchOrganizationTypes:async()=>c.fetch(`${N}/organization-types`),fetchSiteTypes:async()=>c.fetch(`${_}/site-types`),fetchSamplingFeatureTypes:async()=>c.paginatedFetch(`${_}/sampling-feature-types`),fetchSensorEncodingTypes:async()=>c.paginatedFetch(`${x}/encoding-types`),fetchMethodTypes:async()=>c.paginatedFetch(`${x}/method-types`),fetchVariableTypes:async()=>c.paginatedFetch(`${X}/variable-types`),fetchUnitTypes:async()=>c.paginatedFetch(`${V}/types`),fetchDatastreamStatuses:async()=>c.paginatedFetch(`${O}/statuses`),fetchDatastreamAggregations:async()=>c.paginatedFetch(`${O}/aggregation-statistics`),fetchSampledMediums:async()=>c.paginatedFetch(`${O}/sampled-mediums`)};class Or{name="";mappings=[];extractorVariables={};constructor(t){Object.assign(this,t)}}const St=1,fe=St*60,Pe=fe*60,Ne=Pe*24,Ur=Ne*7,Mr=Pe*30,Cr=Ne*365,ne={[U.SECOND]:St,[U.MINUTE]:fe,[U.HOUR]:Pe,[U.DAY]:Ne,[U.WEEK]:Ur,[U.MONTH]:Mr,[U.YEAR]:Cr},Dr=e=>e.toLocaleString(void 0,{year:"numeric",month:"short",day:"2-digit",hour:"2-digit",hour12:!1,minute:"2-digit",second:"2-digit"}),Fr=e=>{let t,r;e>=fe*1e3?(t=e/(fe*1e3),r="m"):e>=1e3?(t=e/1e3,r="s"):(t=e,r="ms");let n;return r==="ms"?n=Math.round(t).toString():n=t.toFixed(2),`${n} ${r}`},de=async(e,t)=>{t&&console.info(t);const r=performance.now(),n=await e(),o=+(performance.now()-r);return{response:n,duration:o}};function Pr(e,t){const r=new Date(e);return r.setHours(r.getHours()-t),r.toISOString()}const G=(e,t)=>{let r=0,n=e.length;for(;r<n;){const s=r+n>>1;e[s]<t?r=s+1:n=s}return r},q=(e,t)=>{let r=0,n=e.length;for(;r<n;){const s=r+n>>1;e[s]>t?n=s:r=s+1}return r-1},Et=`(function(){"use strict";function c(n,s,a,u,f,l,y,o){let r=0,e=o;for(let t=l;t<=y;t++)r<a.length&&t===a[r]?r++:(u[e]=n[t],f[e]=s[t],e++);return e-o}self.onmessage=n=>{const{bufferX:s,bufferY:a,outputBufferX:u,outputBufferY:f,start:l,end:y,deleteSegment:o,startTarget:r}=n.data,e=new Float64Array(s),t=new Float32Array(a),A=new Float64Array(u),g=new Float32Array(f);c(e,t,o,A,g,l,y,r),self.postMessage("Done")}})();
4
+ `,vt=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Et],{type:"text/javascript;charset=utf-8"});function Nr(e){let t;try{if(t=vt&&(self.URL||self.webkitURL).createObjectURL(vt),!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(Et),{name:e?.name})}}const kt=`(function(){"use strict";function F(n,l,a,o,s,y,g,f,i,w,A){let e=0,t=f;for(let r=y;r<=g;r++)if(o[t]=n[r],s[t]=l[r],t++,e<a.length&&r===a[e][0]){const u=a[e][0],c=a[e][1],d=n[u],h=n[c],m=l[u],D=l[c],x=h-d,P=D-m;let p=d+i;for(;p<h;)o[t]=p,s[t]=w?m+(p-d)*P/x:A,t++,p+=i;e++}return t-f}self.onmessage=n=>{const{bufferX:l,bufferY:a,outputBufferX:o,outputBufferY:s,start:y,end:g,gapsSegment:f,startTarget:i,fillDelta:w,interpolate:A,fillValue:e}=n.data,t=new Float64Array(l),r=new Float32Array(a),u=new Float64Array(o),c=new Float32Array(s);F(t,r,f,u,c,y,g,i,w,A,e),self.postMessage("Done")}})();
5
+ `,_t=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",kt],{type:"text/javascript;charset=utf-8"});function Br(e){let t;try{if(t=_t&&(self.URL||self.webkitURL).createObjectURL(_t),!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(kt),{name:e?.name})}}const At=`(function(){"use strict";function g(o,n,c){for(let s=0;s<c.length;s++){const{indexes:t,lowerIdx:l,upperIdx:r}=c[s],i=o[l],f=n[l],a=o[r],d=n[r],p=a-i,w=d-f;if(p===0){for(let e=0;e<t.length;e++)n[t[e]]=f;continue}for(let e=0;e<t.length;e++){const u=t[e];n[u]=f+(o[u]-i)*w/p}}}self.onmessage=o=>{const{bufferX:n,bufferY:c,groups:s}=o.data,t=new Float64Array(n),l=new Float32Array(c);g(t,l,s),self.postMessage("Done")}})();
6
+ `,Tt=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",At],{type:"text/javascript;charset=utf-8"});function jr(e){let t;try{if(t=Tt&&(self.URL||self.webkitURL).createObjectURL(Tt),!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(At),{name:e?.name})}}const Lt=`(function(){"use strict";self.onmessage=r=>{const{bufferX:s,bufferY:o,jobs:a}=r.data,f=new Float64Array(s),n=new Float32Array(o);for(let e=0;e<a.length;e++){const{chunkStart:c,chunkEnd:l,startDatetime:u,value:i,extent:y}=a[e];for(let t=c;t<l;t++)n[t]=n[t]+i*((f[t]-u)/y)}self.postMessage("Done")}})();
7
+ `,$t=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Lt],{type:"text/javascript;charset=utf-8"});function Wr(e){let t;try{if(t=$t&&(self.URL||self.webkitURL).createObjectURL($t),!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(Lt),{name:e?.name})}}const Rt=`(function(){"use strict";function u(f,o,a,n,l,c,s,i){let r=c,e=0,t=i;const w=a.length;for(;r<s&&e<w;){const y=a[e][0];f[r]<=y?(n[t]=f[r],l[t]=o[r],r++):(n[t]=y,l[t]=a[e][1],e++),t++}for(;r<s;)n[t]=f[r],l[t]=o[r],r++,t++;for(;e<w;)n[t]=a[e][0],l[t]=a[e][1],e++,t++;return t-i}self.onmessage=f=>{const{bufferX:o,bufferY:a,outputBufferX:n,outputBufferY:l,origStart:c,origEnd:s,insertions:i,outStart:r}=f.data,e=new Float64Array(o),t=new Float32Array(a),w=new Float64Array(n),y=new Float32Array(l);u(e,t,i,w,y,c,s,r),self.postMessage("Done")}})();
8
+ `,It=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Rt],{type:"text/javascript;charset=utf-8"});function xr(e){let t;try{if(t=It&&(self.URL||self.webkitURL).createObjectURL(It),!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(Rt),{name:e?.name})}}const Ot=`(function(){"use strict";self.onmessage=i=>{const{bufferX:c,bufferY:g,outputBufferX:d,outputBufferY:y,indexes:n,outStart:r,amount:f,isMonth:Y,isYear:h,deltaMs:w}=i.data,s=new Float64Array(c),a=new Float32Array(g),l=new Float64Array(d),u=new Float32Array(y);if(Y)for(let t=0;t<n.length;t++){const e=n[t],o=new Date(s[e]);o.setMonth(o.getMonth()+f),l[r+t]=o.getTime(),u[r+t]=a[e]}else if(h)for(let t=0;t<n.length;t++){const e=n[t],o=new Date(s[e]);o.setFullYear(o.getFullYear()+f),l[r+t]=o.getTime(),u[r+t]=a[e]}else for(let t=0;t<n.length;t++){const e=n[t];l[r+t]=s[e]+w,u[r+t]=a[e]}self.postMessage("Done")}})();
9
+ `,Ut=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Ot],{type:"text/javascript;charset=utf-8"});function Gr(e){let t;try{if(t=Ut&&(self.URL||self.webkitURL).createObjectURL(Ut),!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(Ot),{name:e?.name})}}const Mt=`(function(){"use strict";function a(e,t,o,c){const n=[];let r=e[t];for(let s=t+1;s<=o;s++){const f=e[s];f-r>c&&n.push(s-1,s),r=f}return n}self.onmessage=e=>{const{bufferX:t,start:o,endInclusive:c,threshold:n}=e.data,r=new Float64Array(t);self.postMessage(a(r,o,c,n))}})();
10
+ `,Ct=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Mt],{type:"text/javascript;charset=utf-8"});function Yr(e){let t;try{if(t=Ct&&(self.URL||self.webkitURL).createObjectURL(Ct),!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(Mt),{name:e?.name})}}const Dt=`(function(){"use strict";function c(u,s,t){const n=[];if(s>=t)return n;let e=s,o=u[s];for(let r=s+1;r<t;r++){const f=u[r];f!==o&&(n.push(e,r-e,o),e=r,o=f)}return n.push(e,t-e,o),n}self.onmessage=u=>{const{bufferY:s,start:t,end:n}=u.data,e=new Float32Array(s);self.postMessage(c(e,t,n))}})();
11
+ `,Ft=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Dt],{type:"text/javascript;charset=utf-8"});function Hr(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 o(s,i,t,n,l){const f=[];if(n==="Less than")for(let e=i;e<t;e++)s[e]-s[e-1]<l&&f.push(e);else if(n==="Less than or equal to")for(let e=i;e<t;e++)s[e]-s[e-1]<=l&&f.push(e);else if(n==="Greater than")for(let e=i;e<t;e++)s[e]-s[e-1]>l&&f.push(e);else if(n==="Greater than or equal to")for(let e=i;e<t;e++)s[e]-s[e-1]>=l&&f.push(e);else if(n==="Equal")for(let e=i;e<t;e++)s[e]-s[e-1]==l&&f.push(e);return f}self.onmessage=s=>{const{bufferY:i,start:t,end:n,comparator:l,value:f}=s.data,e=new Float32Array(i);self.postMessage(o(e,t,n,l,f))}})();
12
+ `,Nt=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Pt],{type:"text/javascript;charset=utf-8"});function zr(e){let t;try{if(t=Nt&&(self.URL||self.webkitURL).createObjectURL(Nt),!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 Bt=`(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
+ `,jt=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Bt],{type:"text/javascript;charset=utf-8"});function Xr(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(Bt),{name:e?.name})}}const Wt=`(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
+ `,xt=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Wt],{type:"text/javascript;charset=utf-8"});function Be(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})}}const Gt=`(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
+ `,Yt=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Gt],{type:"text/javascript;charset=utf-8"});function Vr(e){let t;try{if(t=Yt&&(self.URL||self.webkitURL).createObjectURL(Yt),!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(Gt),{name:e?.name})}}function Ht(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 h=0;h<a;h++){const y=n[h],p=s[h];if(y===0){if(l<p){f=!0;break}}else if(y===1){if(l<=p){f=!0;break}}else if(y===2){if(l>p){f=!0;break}}else if(y===3){if(l>=p){f=!0;break}}else if(l==p){f=!0;break}}f&&o.push(i)}return o}function qr(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 Jr(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 Qr(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 Kr(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 Zr(e,t,r,n,s,o,a,i,l,f,h){let y=0,p=i;for(let g=o;g<=a;g++)if(n[p]=e[g],s[p]=t[g],p++,y<r.length&&g===r[y][0]){const d=r[y][0],u=r[y][1],b=e[d],S=e[u],m=t[d],E=t[u],k=S-b,L=E-m;let $=b+l;for(;$<S;)n[p]=$,s[p]=f?m+($-b)*L/k:h,p++,$+=l;y++}return p-i}function en(e,t,r,n,s,o,a,i){let l=o,f=0,h=i;const y=r.length;for(;l<a&&f<y;){const p=r[f][0];e[l]<=p?(n[h]=e[l],s[h]=t[l],l++):(n[h]=p,s[h]=r[f][1],f++),h++}for(;l<a;)n[h]=e[l],s[h]=t[l],l++,h++;for(;f<y;)n[h]=r[f][0],s[h]=r[f][1],f++,h++;return h-i}function tn(e,t,r,n,s,o,a,i){let l=0,f=i;for(let h=o;h<=a;h++)l<r.length&&h===r[l]?l++:(n[f]=e[h],s[f]=t[h],f++);return f-i}function rn(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 nn(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],h=t[a],y=f-i,p=h-l;if(y===0){for(let g=0;g<s.length;g++)t[s[g]]=l;continue}for(let g=0;g<s.length;g++){const d=s[g];t[d]=l+(e[d]-i)*p/y}}}function sn(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 zt(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 je="qc-utils:calibration:v1",on=720*60*60*1e3,pe=5e4,ye=2e5,ge={spawnOverheadMs:50,inlineThroughput:5e4,workerThroughput:8e4,hwConcurrency:4,measuredAt:0,userAgent:"default"};let M=pn()??ge,We=null,se=null;const xe=new Set,Ge={[T.VALUE_THRESHOLD]:{mode:"calibrated",weight:1,rationale:"O(n) single-pass scan; baseline reference"},[T.CHANGE]:{mode:"calibrated",weight:1.1,rationale:"O(n) with one subtraction per step"},[T.RATE_OF_CHANGE]:{mode:"calibrated",weight:1.4,rationale:"O(n) with division + abs per step"},[T.FIND_GAPS]:{mode:"calibrated",weight:.9,rationale:"O(n) on X only, mostly empty output"},[T.PERSISTENCE]:{mode:"calibrated",weight:1.3,rationale:"O(n) + chunk-boundary stitch"},[T.DATETIME_RANGE]:{mode:"always-inline",weight:0,rationale:"O(log n) binary search; never worth the worker hop"},[T.SELECTION]:{mode:"always-inline",weight:0,rationale:"Pure history bookkeeping"},[v.CHANGE_VALUES]:{mode:"calibrated",weight:.7,rationale:"O(k) in-place arithmetic on selection"},[v.ASSIGN_VALUES_BULK]:{mode:"always-inline",weight:0,rationale:"Single tight loop, already inline"},[v.ASSIGN_DATETIMES_BULK]:{mode:"always-inline",weight:0,rationale:"Composes delete+add which handle their own dispatch"},[v.INTERPOLATE]:{mode:"calibrated",weight:1.5,rationale:"Linear interp per consecutive group; in-place writes"},[v.DRIFT_CORRECTION]:{mode:"calibrated",weight:1.2,rationale:"O(range total) in-place math; one pass per range"},[v.SHIFT_DATETIMES]:{mode:"calibrated",weight:1.1,rationale:"O(k) per-point shift math; inline skips SAB allocation"},[v.ADD_POINTS]:{mode:"calibrated",weight:1.8,rationale:"Single merge pass over Y/X + insertions; fresh SAB per call"},[v.DELETE_POINTS]:{mode:"calibrated",weight:1.4,rationale:"Single skip-on-delete pass over Y/X; fresh SAB per call"},[v.FILL_GAPS]:{mode:"calibrated",weight:1.3,rationale:"Single copy-with-fills pass; fresh SAB sized to newLength"}};function F(e,t){const r=Ge[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=an(e,t);if(n<=0)return{useWorker:!1,predictedInlineMs:0,predictedWorkerMs:M.spawnOverheadMs,reason:"zero work units"};const s=Math.max(1,Math.min(t.parallelism??M.hwConcurrency,M.hwConcurrency)),o=r.weight*n/M.inlineThroughput,a=M.spawnOverheadMs+r.weight*n/(M.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 an(e,t){switch(e){case v.CHANGE_VALUES:case v.INTERPOLATE:case v.SHIFT_DATETIMES:case v.DRIFT_CORRECTION:return t.selectionSize??0;case v.DELETE_POINTS:return(t.selectionSize??0)+t.datasetSize*.25;case v.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 cn(e){return xe.add(e),()=>xe.delete(e)}function ln(){return M}function un(){return We}function hn(){return Object.keys(Ge).map(e=>({op:e,...Ge[e]}))}function fn(){M=ge,We=null;try{localStorage.removeItem(je)}catch{}}async function dn(e={}){if(typeof window>"u"||!(e.force||M.measuredAt===0||Date.now()-M.measuredAt>on))return M;if(se)await se;else{se=Xt().finally(()=>{se=null});const r=await se;M=r,yn(r),We=r;for(const n of xe)n(M)}return M}async function Xt(){if(!(typeof SharedArrayBuffer<"u"))return{...ge,measuredAt:Date.now(),userAgent:navigator.userAgent,hwConcurrency:navigator.hardwareConcurrency||ge.hwConcurrency,sharedArrayBufferAvailable:!1,samples:{spawnRoundtripMs:[],inlineScanMs:[],workerScanMs:[]}};const t=navigator.hardwareConcurrency||4,r=new Float32Array(pe);for(let u=0;u<pe;u++)r[u]=Math.sin(u);const n=await Ye(3,()=>{const u=performance.now();return Ht(r,0,pe,[2],[.5]),performance.now()-u}),s=He(n),o=pe/Math.max(s,.001),a=new SharedArrayBuffer(256*Float32Array.BYTES_PER_ELEMENT),i=await Ye(3,async()=>{const u=performance.now();return await new Promise(b=>{const S=new Be;S.onmessage=()=>{S.terminate(),b()},S.postMessage({bufferY:a,start:0,end:256,ops:[2],values:[.5]})}),performance.now()-u}),l=He(i),f=new SharedArrayBuffer(ye*Float32Array.BYTES_PER_ELEMENT),h=new Float32Array(f);for(let u=0;u<ye;u++)h[u]=Math.sin(u);const y=await Ye(3,async()=>{const u=performance.now();return await new Promise(b=>{const S=new Be;S.onmessage=()=>{S.terminate(),b()},S.postMessage({bufferY:f,start:0,end:ye,ops:[2],values:[.5]})}),performance.now()-u}),p=Math.max(He(y)-l,.1),g=ye/p;return{spawnOverheadMs:l,inlineThroughput:o,workerThroughput:g,hwConcurrency:t,measuredAt:Date.now(),userAgent:navigator.userAgent,sharedArrayBufferAvailable:!0,samples:{spawnRoundtripMs:i,inlineScanMs:n,workerScanMs:y}}}async function Ye(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 He(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 pn(){if(typeof localStorage>"u")return null;try{const e=localStorage.getItem(je);if(!e)return null;const t=JSON.parse(e);return!t||typeof t.spawnOverheadMs!="number"?null:t}catch{return null}}function yn(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(je,JSON.stringify(t))}catch{}}const ee=20*1e3,gn=1024,mn=["date","value","qualifier"],wn=typeof SharedArrayBuffer<"u";function C(e,t){return wn?t!==void 0?new SharedArrayBuffer(e,{maxByteLength:t}):new SharedArrayBuffer(e):t!==void 0?new ArrayBuffer(e,{maxByteLength:t}):new ArrayBuffer(e)}function Vt(e,t){const r=e;typeof r.grow=="function"?r.grow(t):typeof r.resize=="function"&&r.resize(t)}function bn(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}function Sn(e,t){switch(e){case v.ADD_POINTS:case v.FILL_GAPS:return!1;default:return!0}}class En{dataset={dimensions:mn,source:{x:new Float64Array(C(ee*Float64Array.BYTES_PER_ELEMENT,ee*Float64Array.BYTES_PER_ELEMENT)),y:new Float32Array(C(ee*Float32Array.BYTES_PER_ELEMENT,ee*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 de(()=>{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+=ee*Float64Array.BYTES_PER_ELEMENT;if(n*Float64Array.BYTES_PER_ELEMENT>this.dataX.buffer.maxByteLength){const s=C(this.dataX.buffer.byteLength,n*Float64Array.BYTES_PER_ELEMENT),o=C(this.dataY.buffer.byteLength,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&&(Vt(this.dataX.buffer,t*Float64Array.BYTES_PER_ELEMENT),Vt(this.dataY.buffer,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={[v.ADD_POINTS]:this._addDataPoints,[v.CHANGE_VALUES]:this._changeValues,[v.ASSIGN_VALUES_BULK]:this._assignValuesBulk,[v.DELETE_POINTS]:this._deleteDataPointsFromSelection,[v.DRIFT_CORRECTION]:this._driftCorrectionFromSelection,[v.INTERPOLATE]:this._interpolateFromSelection,[v.SHIFT_DATETIMES]:this._shiftFromSelection,[v.ASSIGN_DATETIMES_BULK]:this._assignDatetimesBulk,[v.FILL_GAPS]:this._fillGaps};let s=[],o=null;try{this._isReplaying||(this.redoStack.length=0),o={method:t,args:r,isLoading:!0},this.history.push(o),Sn(t,r)||this.history[this.history.length-2]?.method===T.SELECTION&&this.history.splice(this.history.length-2,1),this._pendingExecutionMode="inline";const a=await de(async()=>await n[t].apply(this,r));s=a.response;const i=this.history.indexOf(o),l=i>=0?this.history[i]:void 0;l&&(l.duration=a.duration,l.executionMode=this._pendingExecutionMode,l.status="success",l.isLoading=!1)}catch(a){if(console.log(`Failed to execute operation: ${t} with arguments: `,r),console.log(a),o){const i=this.history.indexOf(o),l=i>=0?this.history[i]:void 0;l&&(l.status="failed",l.isLoading=!1)}}return s}async dispatch(t,...r){const n=async(s,o)=>T[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={[T.FIND_GAPS]:this._findGaps,[T.VALUE_THRESHOLD]:this._valueThreshold,[T.DATETIME_RANGE]:this._datetimeRange,[T.PERSISTENCE]:this._persistence,[T.CHANGE]:this._change,[T.RATE_OF_CHANGE]:this._rateOfChange,[T.SELECTION]:this._selection};let s=[],o=null;try{const a=t===T.SELECTION,i=a&&(!r[0]||Array.isArray(r[0])&&r[0].length===0);!this._isReplaying&&!i&&(this.redoStack.length=0),o={method:t,args:r,isLoading:!0};const l=this.history[this.history.length-1],f=!!T[l?.method],h=l?.method===t||f&&!a;let y;h?(y=this.history.length-1,this.history[y]=o):(this.history.push(o),y=this.history.length-1),this._pendingExecutionMode="inline";const p=await de(async()=>await n[t].apply(this,r));s=p.response;const g=this.history.indexOf(o),d=g>=0?this.history[g]:void 0;d&&(d.duration=p.duration,d.executionMode=this._pendingExecutionMode,d.selected=p.response,d.status="success",d.isLoading=!1)}catch(a){if(console.log(`Failed to execute filter operation: ${t} with arguments: `,r),console.log(a),o){const i=this.history.indexOf(o),l=i>=0?this.history[i]:void 0;l&&(l.status="failed",l.isLoading=!1)}}return s}async _changeValues(t,r){const n=this.history[this.history.length-2]?.selected;if(!n||n.length===0)return[];const s=n.length;if(!F(v.CHANGE_VALUES,{datasetSize:this.dataset.source.y.length,selectionSize:s}).useWorker||s<gn)return zt(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 h=0;h<a;h++){const y=h*i,p=Math.min((h+1)*i,s);if(y>=p)break;const g=n.slice(y,p);f.push(new Promise(d=>{const u=new Vr;l.push(u),u.postMessage({bufferY:this.dataY.buffer,indexes:g,operator:t,value:r}),u.onmessage=b=>{d(b.data)}}))}return await Promise.all(f),l.forEach(h=>h.terminate()),[]}_applyOperatorInPlace(t,r,n){zt(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 _interpolateFromSelection(){const t=this.history[this.history.length-2]?.selected;if(!(!t||t.length===0))return this._interpolate(t)}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(h=>({indexes:h,lowerIdx:Math.max(0,h[0]-1),upperIdx:Math.min(n-1,h[h.length-1]+1)}));if(!F(v.INTERPOLATE,{datasetSize:n,selectionSize:t.length}).useWorker){nn(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 h=0;h<a;h++){const y=s.slice(h*i,(h+1)*i);if(y.length===0)break;f.push(new Promise(p=>{const g=new jr;l.push(g),g.postMessage({bufferX:this.dataX.buffer,bufferY:this.dataY.buffer,groups:y}),g.onmessage=d=>{p(d.data)}}))}await Promise.all(f),l.forEach(h=>h.terminate())}async _shiftFromSelection(t,r){const n=this.history[this.history.length-2]?.selected;if(!(!n||n.length===0))return this._shift(n,t,r)}async _shift(t,r,n){if(t.length===0)return;const s=n===U.MONTH,o=n===U.YEAR,a=!s&&!o?r*ne[n]*1e3:0,i=t.length;if(!F(v.SHIFT_DATETIMES,{datasetSize:this.dataset.source.x.length,selectionSize:i}).useWorker){const m=rn(this.dataX,this.dataY,t,{amount:r,isMonth:s,isYear:o,deltaMs:a});await this._deleteDataPoints(t),await this._addDataPoints(m);return}this._pendingExecutionMode="worker";const f=C(i*Float64Array.BYTES_PER_ELEMENT),h=C(i*Float32Array.BYTES_PER_ELEMENT),y=Math.min(navigator.hardwareConcurrency||1,i),p=Math.ceil(i/y),g=[],d=[];for(let m=0;m<y;m++){const E=m*p,k=Math.min((m+1)*p,i);if(E>=k)break;const L=t.slice(E,k);d.push(new Promise($=>{const I=new Gr;g.push(I),I.postMessage({bufferX:this.dataX.buffer,bufferY:this.dataY.buffer,outputBufferX:f,outputBufferY:h,indexes:L,outStart:E,amount:r,isMonth:s,isYear:o,deltaMs:a}),I.onmessage=P=>{$(P.data)}}))}await Promise.all(d),g.forEach(m=>m.terminate());const u=new Float64Array(f),b=new Float32Array(h),S=new Array(i);for(let m=0;m<i;m++)S[m]=[u[m],b[m]];await this._deleteDataPoints(t),await this._addDataPoints(S)}async _fillGaps(t,r,n,s,o){const a=this.dataX.length;if(a===0)return;const i=t[0]*ne[t[1]]*1e3,l=r[0]*ne[r[1]]*1e3,f=this.dataX,h=o?.[0]!=null&&Number.isFinite(o[0])?G(f,o[0]):0,y=o?.[1]!=null&&Number.isFinite(o[1])?q(f,o[1]):a-1,p=[],g=[];let d=0;for(let A=h+1;A<=y;A++)if(f[A]-f[A-1]>i){let W=0,J=f[A-1]+l;for(;J<f[A];)W++,J+=l;W>0&&(p.push([A-1,A]),g.push(W),d+=W)}if(d===0)return;const u=a+d,b=u*Float64Array.BYTES_PER_ELEMENT,S=u*Float32Array.BYTES_PER_ELEMENT,m=C(b,Math.max(this.dataX.buffer.maxByteLength,b)),E=C(S,Math.max(this.dataY.buffer.maxByteLength,S));if(!F(v.FILL_GAPS,{datasetSize:a,selectionSize:d}).useWorker){const A=new Float64Array(m),Y=new Float32Array(E);Zr(this.dataX,this.dataY,p,A,Y,0,a-1,0,l,n,s),this.dataset.source.x=A,this.dataset.source.y=Y,this._resizeTo(u);return}this._pendingExecutionMode="worker";const L=navigator.hardwareConcurrency||1,$=Math.ceil(a/L),I=[];let P=0;for(let A=0;A<L;A++){const Y=A*$,W=Math.min((A+1)*$-1,a-1),J=[];let me=0;for(;P<p.length&&p[P][0]<=W;)J.push(p[P]),me+=g[P],P++;I.push({start:Y,end:W,gapsSegment:J,fillsInSegment:me})}const ze=new Array(L).fill(0);for(let A=1;A<L;A++)ze[A]=ze[A-1]+I[A-1].fillsInSegment;const qt=[],Jt=[];for(let A=0;A<L;A++){const{start:Y,end:W,gapsSegment:J}=I[A],me=Y+ze[A];Jt.push(new Promise(Tn=>{const Xe=new Br;qt.push(Xe),Xe.postMessage({bufferX:this.dataX.buffer,bufferY:this.dataY.buffer,outputBufferX:m,outputBufferY:E,start:Y,end:W,gapsSegment:J,startTarget:me,fillDelta:l,interpolate:n,fillValue:s}),Xe.onmessage=Ln=>{Tn(Ln.data)}}))}await Promise.all(Jt),qt.forEach(A=>A.terminate()),this.dataset.source.x=new Float64Array(m),this.dataset.source.y=new Float32Array(E),this._resizeTo(u)}async _deleteDataPointsFromSelection(){const t=this.history[this.history.length-2]?.selected;if(!(!t||t.length===0))return this._deleteDataPoints(t)}async _deleteDataPoints(t){const r=this.dataX.length,n=r-t.length;if(!F(v.DELETE_POINTS,{datasetSize:r,selectionSize:t.length}).useWorker){const g=C(this.dataX.buffer.byteLength,this.dataX.buffer.maxByteLength),d=C(this.dataY.buffer.byteLength,this.dataY.buffer.maxByteLength),u=new Float64Array(g),b=new Float32Array(d);tn(this.dataX,this.dataY,t,u,b,0,r-1,0),this.dataset.source.x=u,this.dataset.source.y=b,this._resizeTo(n);return}this._pendingExecutionMode="worker";const o=navigator.hardwareConcurrency||1,a=Math.ceil(this.dataX.length/o),i=[],l=[];for(let g=0;g<o;g++){const d=g*a,u=Math.min((g+1)*a-1,this.dataX.length-1),b=G(t,d),S=q(t,u),m=t.slice(b,S+1);l.push({start:d,end:u,deleteSegment:m})}const f=new Array(o).fill(0);for(let g=1;g<o;g++)f[g]=f[g-1]+l[g-1].deleteSegment.length;const h=[],y=C(this.dataX.buffer.byteLength,this.dataX.buffer.maxByteLength),p=C(this.dataY.buffer.byteLength,this.dataY.buffer.maxByteLength);for(let g=0;g<o;g++){const{start:d,end:u,deleteSegment:b}=l[g],S=d-f[g];h.push(new Promise(m=>{const E=new Nr;i.push(E),E.postMessage({bufferX:this.dataX.buffer,bufferY:this.dataY.buffer,outputBufferX:y,outputBufferY:p,start:d,end:u,deleteSegment:b,startTarget:S}),E.onmessage=k=>{m(k.data)}}))}await Promise.all(h),i.forEach(g=>g.terminate()),this.dataset.source.x=new Float64Array(y),this.dataset.source.y=new Float32Array(p),this._resizeTo(n)}async _driftCorrectionFromSelection(t){const r=this.history[this.history.length-2]?.selected;if(!r||r.length===0)return;const n=this._getConsecutiveGroups(r),s=[];for(const o of n)o.length!==0&&s.push([o[0],o[o.length-1],t]);if(s.length!==0)return this._driftCorrection(s)}async _driftCorrection(t){if(!t||t.length===0)return;const r=this.dataset.source.x,n=navigator.hardwareConcurrency||1;let s=0;for(const[y,p]of t)p>y&&(s+=p-y);if(!F(v.DRIFT_CORRECTION,{datasetSize:r.length,selectionSize:s}).useWorker){sn(r,this.dataY,t);return}this._pendingExecutionMode="worker";const a=[];for(const[y,p,g]of t){if(p<=y)continue;const d=r[y],u=r[p]-d;if(u===0)continue;const b=p-y,S=Math.max(1,Math.ceil(b/n));for(let m=y;m<p;m+=S)a.push({chunkStart:m,chunkEnd:Math.min(m+S,p),startDatetime:d,value:g,extent:u})}if(a.length===0)return;const i=Math.min(n,a.length),l=Array.from({length:i},()=>[]);a.forEach((y,p)=>l[p%i].push(y));const f=[],h=[];for(const y of l)y.length!==0&&h.push(new Promise(p=>{const g=new Wr;f.push(g),g.postMessage({bufferX:this.dataX.buffer,bufferY:this.dataY.buffer,jobs:y}),g.onmessage=d=>{p(d.data)}}));await Promise.all(h),f.forEach(y=>y.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,u)=>d[0]-u[0]);const s=n*Float64Array.BYTES_PER_ELEMENT,o=n*Float32Array.BYTES_PER_ELEMENT,a=C(s,Math.max(this.dataX.buffer.maxByteLength,s)),i=C(o,Math.max(this.dataY.buffer.maxByteLength,o));if(!F(v.ADD_POINTS,{datasetSize:r,selectionSize:t.length}).useWorker){const d=new Float64Array(a),u=new Float32Array(i);en(this.dataX,this.dataY,t,d,u,0,r,0),this.dataset.source.x=d,this.dataset.source.y=u,this._resizeTo(n);return}this._pendingExecutionMode="worker";const f=t.map(d=>q(this.dataX,d[0])+1),h=Math.max(1,Math.min(navigator.hardwareConcurrency||1,Math.max(r,1))),y=Math.ceil(Math.max(r,1)/h),p=[],g=[];for(let d=0;d<h;d++){const u=d*y,b=Math.min((d+1)*y,r),S=G(f,u),m=d===h-1?t.length:G(f,b),E=t.slice(S,m),k=u+S;u>=b&&E.length===0||g.push(new Promise(L=>{const $=new xr;p.push($),$.postMessage({bufferX:this.dataX.buffer,bufferY:this.dataY.buffer,outputBufferX:a,outputBufferY:i,origStart:u,origEnd:b,insertions:E,outStart:k}),$.onmessage=I=>{L(I.data)}}))}await Promise.all(g),p.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={[H.LT]:0,[H.LTE]:1,[H.GT]:2,[H.GTE]:3,[H.E]:4},s=r.map(u=>n[u]??4),o=r.map(u=>t[u]),a=this.dataset.source.y,i=a.length;if(i===0)return[];if(!F(T.VALUE_THRESHOLD,{datasetSize:i}).useWorker)return Ht(a,0,i,s,o);this._pendingExecutionMode="worker";const f=Math.min(navigator.hardwareConcurrency||1,i),h=Math.ceil(i/f),y=[],p=[];for(let u=0;u<f;u++){const b=u*h,S=Math.min((u+1)*h,i);if(b>=S)break;p.push(new Promise(m=>{const E=new Be;y.push(E),E.postMessage({bufferY:this.dataY.buffer,start:b,end:S,ops:s,values:o}),E.onmessage=k=>{m(k.data)}}))}const g=await Promise.all(p);y.forEach(u=>u.terminate());const d=[];for(let u=0;u<g.length;u++){const b=g[u];for(let S=0;S<b.length;S++)d.push(b[S])}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(!F(T.RATE_OF_CHANGE,{datasetSize:n.length}).useWorker)return Jr(n,s,o,t,r);this._pendingExecutionMode="worker";const l=Math.min(navigator.hardwareConcurrency||1,a),f=Math.ceil(a/l),h=[],y=[];for(let d=0;d<l;d++){const u=s+d*f,b=Math.min(s+(d+1)*f,o);if(u>=b)break;y.push(new Promise(S=>{const m=new Xr;h.push(m),m.postMessage({bufferY:this.dataY.buffer,start:u,end:b,comparator:t,value:r}),m.onmessage=E=>{S(E.data)}}))}const p=await Promise.all(y);h.forEach(d=>d.terminate());const g=[];for(let d=0;d<p.length;d++){const u=p[d];for(let b=0;b<u.length;b++)g.push(u[b])}return g}async _datetimeRange(t,r){const n=this.dataset.source.x,s=n.length;if(s===0)return[];const o=t==null?0:G(n,t),a=r==null?s-1:q(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){const r=this.history[this.history.length-2],n=!!r&&r.method!==T.SELECTION&&!!T[r.method],s=n&&Array.isArray(r.selected)?r.selected:void 0;return!t||!t.length?(this.history.pop(),s&&s.length>0&&this.history.pop(),t):(s&&bn(s,t)?this.history.pop():n&&this.history.splice(this.history.length-2,1),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(!F(T.CHANGE,{datasetSize:n.length}).useWorker)return qr(n,s,o,t,r);this._pendingExecutionMode="worker";const l=Math.min(navigator.hardwareConcurrency||1,a),f=Math.ceil(a/l),h=[],y=[];for(let d=0;d<l;d++){const u=s+d*f,b=Math.min(s+(d+1)*f,o);if(u>=b)break;y.push(new Promise(S=>{const m=new zr;h.push(m),m.postMessage({bufferY:this.dataY.buffer,start:u,end:b,comparator:t,value:r}),m.onmessage=E=>{S(E.data)}}))}const p=await Promise.all(y);h.forEach(d=>d.terminate());const g=[];for(let d=0;d<p.length;d++){const u=p[d];for(let b=0;b<u.length;b++)g.push(u[b])}return g}async _findGaps(t,r,n){const s=this.dataset.source.x;let o=0,a=s.length;if(n!=null){const[b,S]=n;b!=null&&Number.isFinite(b)&&(o=G(s,b)),S!=null&&Number.isFinite(S)&&(a=q(s,S)+1)}if(a<=o)return[];const i=t*ne[r]*1e3;if(!F(T.FIND_GAPS,{datasetSize:a-o}).useWorker){const b=Qr(s,o,a-1,i),S=new Set;for(let m=0;m<b.length;m++)S.add(b[m]);return[...S]}this._pendingExecutionMode="worker";const f=a-o,h=Math.min(navigator.hardwareConcurrency||1,f),y=Math.ceil(f/h),p=[],g=[];for(let b=0;b<h;b++){const S=o+b*y,m=Math.min(o+(b+1)*y,a);if(S>=m)break;g.push(new Promise(E=>{const k=new Yr;p.push(k),k.postMessage({bufferX:this.dataX.buffer,start:S,endInclusive:m,threshold:i}),k.onmessage=L=>{E(L.data)}}))}const d=await Promise.all(g);p.forEach(b=>b.terminate());const u=new Set;for(let b=0;b<d.length;b++){const S=d[b];for(let m=0;m<S.length;m++)u.add(S[m])}return[...u]}async _persistence(t,r){const n=this.dataset.source.x,s=this.dataset.source.y;let o=0,a=s.length;if(r!=null){const[m,E]=r;m!=null&&Number.isFinite(m)&&(o=G(n,m)),E!=null&&Number.isFinite(E)&&(a=q(n,E)+1)}if(a<=o)return[];const i=a-o;if(!F(T.PERSISTENCE,{datasetSize:i}).useWorker){const m=Kr(s,o,a),E=[];for(let k=0;k<m.length;k+=3){const L=m[k],$=m[k+1];if($>=t)for(let I=0;I<$;I++)E.push(L+I)}return E}this._pendingExecutionMode="worker";const f=Math.min(navigator.hardwareConcurrency||1,i),h=Math.ceil(i/f),y=[],p=[];for(let m=0;m<f;m++){const E=o+m*h,k=Math.min(o+(m+1)*h,a);if(E>=k)break;p.push(new Promise(L=>{const $=new Hr;y.push($),$.postMessage({bufferY:this.dataY.buffer,start:E,end:k}),$.onmessage=I=>{L(I.data)}}))}const g=await Promise.all(p);y.forEach(m=>m.terminate());const d=[],u=[],b=[];for(let m=0;m<g.length;m++){const E=g[m];for(let k=0;k<E.length;k+=3){const L=E[k],$=E[k+1],I=E[k+2],P=d.length-1;P>=0&&b[P]===I&&d[P]+u[P]===L?u[P]+=$:(d.push(L),u.push($),b.push(I))}}const S=[];for(let m=0;m<d.length;m++){const E=u[m];if(E>=t){const k=d[m];for(let L=0;L<E;L++)S.push(k+L)}}return S}}const oe="1",vn=new Set([...Object.values(v),...Object.values(T)]);function kn(e,t){const r=e.history.map(n=>{const s={method:n.method,args:n.args?[...n.args]:[]};return n.status==="failed"&&(s.status="failed"),s});return{version:oe,createdAt:new Date().toISOString(),window:{startDate:t.startDate,endDate:t.endDate},operations:r}}function _n(e){if(!e||typeof e!="object")throw new Error("QC script must be a JSON object.");const t=e;if(t.version!==oe)throw new Error(`Unsupported QC script version: ${String(t.version)}. This loader understands version "${oe}".`);if(typeof t.createdAt!="string")throw new Error("QC script is missing `createdAt` (ISO-8601 string).");const r=t.window;if(!r||typeof r!="object")throw new Error("QC script is missing `window`.");if(typeof r.startDate!="string"||typeof r.endDate!="string")throw new Error("`window.startDate` and `window.endDate` must be ISO-8601 strings.");if(!Array.isArray(t.operations))throw new Error("QC script `operations` must be an array.");const n=t.operations.map((s,o)=>{if(!s||typeof s!="object")throw new Error(`Operation ${o} must be an object.`);const a=s;if(typeof a.method!="string")throw new Error(`Operation ${o} missing string \`method\`.`);if(!vn.has(a.method))throw new Error(`Operation ${o} has unknown method: "${a.method}".`);if(!Array.isArray(a.args))throw new Error(`Operation ${o} \`args\` must be an array.`);const i={method:a.method,args:[...a.args]};return a.status==="failed"&&(i.status="failed"),i});return{version:oe,createdAt:t.createdAt,window:{startDate:r.startDate,endDate:r.endDate},operations:n}}async function An(e,t){e.history.length=0,e.redoStack.length=0,await e.reload();const r={applied:0,failed:[]};for(let n=0;n<t.operations.length;n++){const s=t.operations[n];try{await e.dispatch(s.method,...s.args),e.history[e.history.length-1]?.status==="failed"?r.failed.push({index:n,method:s.method,error:"Operation handler reported failure (see console)."}):r.applied++}catch(o){r.failed.push({index:n,method:s.method,error:o instanceof Error?o.message:String(o)})}}return r}w.ACCOUNT_BASE=N,w.AUTH_BASE=ue,w.ApiKey=cr,w.BASE_URL=D,w.Collaborator=ur,w.DEFAULT_SNACK_DURATION=$e,w.DataSource=$r,w.Datastream=Zt,w.EnumEditOperations=v,w.EnumFilterOperations=T,w.FilterOperation=H,w.HydroShareArchive=Je,w.INCREASE_AMOUNT=ee,w.Location=Qe,w.LogicalOperation=qe,w.OAuthProvider=ir,w.ObservationRecord=En,w.ObservedProperty=rr,w.Operator=Ve,w.Organization=or,w.PROVIDER_BASE=te,w.Payload=Or,w.PermissionAction=Ke,w.PermissionResource=Ze,w.Position=ht,w.PostHydroShareArchive=Qt,w.ProcessingLevel=nr,w.QC_SCRIPT_VERSION=oe,w.ResultQualifier=sr,w.SESSION_BASE=he,w.Sensor=tr,w.Snack=ft,w.SnackColor=Re,w.SnackIcon=Ie,w.SnackTitle=Oe,w.Snackbar=dt,w.TAG_BASE=Fe,w.THINGS_BASE=_,w.Thing=Kt,w.TimeUnit=U,w.Unit=er,w.User=ar,w.Workspace=lr,w.api=Ir,w.apiMethods=c,w.applyScript=An,w.clearCalibration=fn,w.createPatchObject=Ue,w.ensureCalibration=dn,w.extractErrorMessage=et,w.findFirstGreaterOrEqual=G,w.findLastLessOrEqual=q,w.formatDate=Dr,w.formatDuration=Fr,w.getCSRFToken=we,w.getCalibration=ln,w.getLastBenchmarkDetail=un,w.getObservationsEndpoint=Rr,w.getOperationTable=hn,w.measureEllapsedTime=de,w.onCalibrationChange=cn,w.parseScript=_n,w.requestInterceptor=be,w.responseInterceptor=Se,w.runBenchmarks=Xt,w.serializeHistory=kn,w.shouldUseWorker=F,w.subtractHours=Pr,w.timeUnitMultipliers=ne,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})}));
@@ -66,7 +66,6 @@ export declare enum LogicalOperation {
66
66
  }
67
67
  export type HistoryItem = {
68
68
  method: EnumEditOperations | EnumFilterOperations;
69
- icon: string;
70
69
  isLoading: boolean;
71
70
  args?: any[];
72
71
  duration?: number;
@@ -83,6 +82,41 @@ export type HistoryItem = {
83
82
  */
84
83
  executionMode?: "worker" | "inline";
85
84
  };
85
+ /** The wall-clock window the script was authored against. The
86
+ * loader is responsible for fetching this exact range of
87
+ * observations into the target `ObservationRecord` before
88
+ * replaying. ISO-8601 strings (not `Date`) so the type round-trips
89
+ * cleanly through `JSON.stringify`/`JSON.parse`. */
90
+ export type QcScriptWindow = {
91
+ startDate: string;
92
+ endDate: string;
93
+ };
94
+ /** A single replayable operation entry. Mirrors the
95
+ * `[method, ...args]` tuple shape that
96
+ * `ObservationRecord.dispatch` accepts. `status` round-trips
97
+ * author-time failures so failed steps stay visibly failed across
98
+ * save / load. */
99
+ export type QcScriptOperation = {
100
+ method: EnumEditOperations | EnumFilterOperations;
101
+ args: any[];
102
+ status?: "success" | "failed";
103
+ };
104
+ /** A serialized QC history. Schema `version: "1"`. */
105
+ export type QcScript = {
106
+ version: "1";
107
+ createdAt: string;
108
+ window: QcScriptWindow;
109
+ operations: QcScriptOperation[];
110
+ };
111
+ /** Returned by `applyScript` — per-op success/failure tally. */
112
+ export type ApplyScriptReport = {
113
+ applied: number;
114
+ failed: Array<{
115
+ index: number;
116
+ method: string;
117
+ error: string;
118
+ }>;
119
+ };
86
120
  export type DataPoint = {
87
121
  date: Date;
88
122
  value: number;
@@ -4,3 +4,4 @@ export * from './notifications';
4
4
  export * from './observations';
5
5
  export * from './plotting/observation-record';
6
6
  export * from './plotting/calibration';
7
+ export * from './plotting/script';
@@ -0,0 +1 @@
1
+ export {};
@@ -96,7 +96,19 @@ export declare class ObservationRecord {
96
96
  redo(): Promise<number[]>;
97
97
  get beginTime(): Date | null;
98
98
  get endTime(): Date | null;
99
- /** Dispatch an operation and log its signature in hisotry */
99
+ /**
100
+ * Dispatch an operation and log its signature in history.
101
+ *
102
+ * The selection-consuming entries below (DELETE_POINTS, INTERPOLATE,
103
+ * SHIFT_DATETIMES, DRIFT_CORRECTION) route to thin
104
+ * `*FromSelection` wrappers that read the target indices off
105
+ * `history[length - 2].selected` at dispatch time, mirroring the
106
+ * pattern CHANGE_VALUES already uses. The internal handlers
107
+ * (`_deleteDataPoints`, `_shift`, etc.) keep their explicit-
108
+ * indices signatures so other internal callers (e.g.
109
+ * `_assignDatetimesBulk` → `_deleteDataPoints` + `_addDataPoints`)
110
+ * can pass locally-computed indices without going through history.
111
+ */
100
112
  dispatchAction(action: EnumEditOperations, ...args: any): Promise<number[]>;
101
113
  dispatch(actions: EnumEditOperations | EnumFilterOperations | [EnumEditOperations | EnumFilterOperations, ...any][], ...args: any): Promise<number[]>;
102
114
  /** Filter operations do not transform the data and return a selection */
@@ -144,6 +156,14 @@ export declare class ObservationRecord {
144
156
  * [[SELECTION, indices], [ASSIGN_DATETIMES_BULK, datetimes]]
145
157
  */
146
158
  private _assignDatetimesBulk;
159
+ /**
160
+ * Dispatch wrapper around `_interpolate` — reads target indices
161
+ * from `history[length - 2].selected` (the SELECTION the caller
162
+ * dispatched immediately before this op). External callers go
163
+ * through here; internal callers can keep using `_interpolate`
164
+ * directly with explicit indices.
165
+ */
166
+ private _interpolateFromSelection;
147
167
  /**
148
168
  * Multi-threaded linear interpolation over the selected indexes.
149
169
  * 1. Main thread partitions the selected indexes into consecutive groups and computes each group's lower/upper anchors.
@@ -152,6 +172,12 @@ export declare class ObservationRecord {
152
172
  */
153
173
  private _interpolate;
154
174
  /** Interpolate existing values in the data source */
175
+ /**
176
+ * Dispatch wrapper around `_shift` — reads target indices from
177
+ * `history[length - 2].selected`. The `amount` and `unit` args
178
+ * stay parametric on the public dispatch signature.
179
+ */
180
+ private _shiftFromSelection;
155
181
  /**
156
182
  * Shifts the selected indexes by specified amount of units. Elements are reinserted according to their datetime.
157
183
  * @param index The index of the elements to shift
@@ -167,7 +193,22 @@ export declare class ObservationRecord {
167
193
  * 3. Cumulative fill counts before each segment give each worker's output startTarget, ensuring no overlap.
168
194
  * 4. Each worker copies its segment to the output buffer and inserts its gap fills inline.
169
195
  */
196
+ /**
197
+ * @param range Optional `[startTs, endTs]` window in epoch
198
+ * milliseconds. Both bounds inclusive; snapped to the nearest
199
+ * enclosed point via binary search. Datetime-addressed (not
200
+ * index-addressed) so the same call survives data growth and is
201
+ * portable across datasets for QC script replay.
202
+ */
170
203
  private _fillGaps;
204
+ /**
205
+ * Dispatch wrapper around `_deleteDataPoints` — reads target
206
+ * indices from `history[length - 2].selected`. Internal callers
207
+ * (`_shift`, `_assignDatetimesBulk`'s delete + add chain) keep
208
+ * using `_deleteDataPoints` directly with locally-computed
209
+ * indices; only the external dispatch path goes through here.
210
+ */
211
+ private _deleteDataPointsFromSelection;
171
212
  /**
172
213
  Deletes data points from a large array using worker threads.
173
214
  1. The main thread divides the original array into equal parts to distribute work among workers.
@@ -177,6 +218,16 @@ export declare class ObservationRecord {
177
218
  * @param deleteIndices
178
219
  */
179
220
  private _deleteDataPoints;
221
+ /**
222
+ * Dispatch wrapper around `_driftCorrection` — reads target
223
+ * indices from `history[length - 2].selected`, partitions them
224
+ * into consecutive groups, and applies the same `value` drift to
225
+ * each group as one logged operation. The internal
226
+ * `_driftCorrection` retains its per-range `[start, end, value]`
227
+ * signature so future callers that need distinct per-range values
228
+ * can still use it directly.
229
+ */
230
+ private _driftCorrectionFromSelection;
180
231
  /**
181
232
  *
182
233
  * @param start The start index
@@ -240,8 +291,29 @@ export declare class ObservationRecord {
240
291
  */
241
292
  private _datetimeRange;
242
293
  /**
243
- * @param index
244
- * @returns
294
+ * SELECTION filter handler — also acts as the cleanup site for the
295
+ * SELECTION-vs-preceding-filter interaction. `dispatchFilter` always
296
+ * pushes (never replaces) a SELECTION when the previous entry is a
297
+ * non-SELECTION filter; this method then decides what to keep based
298
+ * on what the SELECTION's indices look like relative to the filter:
299
+ *
300
+ * | incoming SELECTION | preceding non-SEL filter | result |
301
+ * | -------------------------- | -------------------------- | ------------------------------------- |
302
+ * | empty | had non-empty `selected` | pop both — user cleared the filter |
303
+ * | empty | had empty `selected` | pop SELECTION — no-op echo on a |
304
+ * | | | zero-result filter, keep filter |
305
+ * | empty | none / non-filter prev | pop SELECTION (clear) |
306
+ * | non-empty matches prev | (any filter) | pop SELECTION — Plotly relayout echo |
307
+ * | | | of the filter's `selected` |
308
+ * | non-empty differs from prev| (any filter) | splice prev — user override takes |
309
+ * | | | ownership; SELECTION stands alone |
310
+ * | non-empty (other cases) | n/a | keep as-is (already pushed) |
311
+ *
312
+ * The "Plotly echo" case exists because consumers commonly chain
313
+ * `dispatchFilter(SOMETHING)` with `dispatchSelection(result)` for
314
+ * visual highlighting; Plotly's debounced relayout listener then
315
+ * fires a SELECTION carrying the same indices. Without this dedup
316
+ * the script would grow a phantom SELECTION after every real filter.
245
317
  */
246
318
  private _selection;
247
319
  /**
@@ -264,7 +336,12 @@ export declare class ObservationRecord {
264
336
  * 3. Main thread collects all pairs and dedups via Set — identical return shape to the original implementation.
265
337
  * @param value The time value
266
338
  * @param unit The time unit (TimeUnit)
267
- * @param range If specified, the gaps will be found only within the range
339
+ * @param range If specified, gap detection is restricted to this
340
+ * `[startTs, endTs]` window in epoch milliseconds. Both bounds
341
+ * are inclusive and snapped to the nearest enclosed point via
342
+ * binary search. Datetime-addressed (not index-addressed) so the
343
+ * same call survives data growth and is portable across datasets
344
+ * for QC script replay.
268
345
  */
269
346
  private _findGaps;
270
347
  /**
@@ -275,7 +352,12 @@ export declare class ObservationRecord {
275
352
  *
276
353
  * Matches the Python reference implementation in `edit_service.py::persistence` — every member of a qualifying run is selected (including the run's first index).
277
354
  * @param times The minimum run length to qualify
278
- * @param range If specified, the points will be found only within the range
355
+ * @param range If specified, persistence detection is restricted
356
+ * to this `[startTs, endTs]` window in epoch milliseconds. Both
357
+ * bounds are inclusive and snapped to the nearest enclosed point
358
+ * via binary search on `dataX`. Datetime-addressed (not index-
359
+ * addressed) so the same call survives data growth and is
360
+ * portable across datasets for QC script replay.
279
361
  */
280
362
  private _persistence;
281
363
  }