@loaders.gl/scientific 5.0.0-beta.2 → 5.0.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -57,7 +57,7 @@ var NetCDFFormat = {
57
57
  };
58
58
 
59
59
  // dist/netcdf/netcdf-loader.js
60
- var VERSION = true ? "5.0.0-beta.2" : "latest";
60
+ var VERSION = true ? "5.0.0-beta.4" : "latest";
61
61
  async function preload() {
62
62
  const { NetCDFLoaderWithParser } = await import("@loaders.gl/scientific/netcdf/netcdf-loader-with-parser");
63
63
  return NetCDFLoaderWithParser;
@@ -88,7 +88,7 @@ var NetCDFLoader = {
88
88
  var NetCDFWorkerLoader = NetCDFLoader;
89
89
 
90
90
  // dist/netcdf/netcdf-source-loader-types.js
91
- var VERSION2 = true ? "5.0.0-beta.2" : "latest";
91
+ var VERSION2 = true ? "5.0.0-beta.4" : "latest";
92
92
  async function preloadNetCDFSourceLoader() {
93
93
  const { NetCDFSourceLoaderWithParser } = await import("@loaders.gl/scientific/netcdf/netcdf-source-loader");
94
94
  return NetCDFSourceLoaderWithParser;
@@ -113,7 +113,7 @@ var NetCDFSourceLoader = {
113
113
  };
114
114
 
115
115
  // dist/zarr/zarr-loader-types.js
116
- var VERSION3 = true ? "5.0.0-beta.2" : "latest";
116
+ var VERSION3 = true ? "5.0.0-beta.4" : "latest";
117
117
  var OMEZarrSourceLoader = {
118
118
  dataType: null,
119
119
  batchType: null,
@@ -242,7 +242,7 @@ var NPYFormat = {
242
242
  };
243
243
 
244
244
  // dist/npy-loader-types.js
245
- var VERSION4 = true ? "5.0.0-beta.2" : "latest";
245
+ var VERSION4 = true ? "5.0.0-beta.4" : "latest";
246
246
  var NPY_MAGIC_NUMBER = new Uint8Array([147, 78, 85, 77, 80, 89]);
247
247
  async function preload2() {
248
248
  const { NPYLoaderWithParser } = await import("@loaders.gl/scientific/npy-loader");
@@ -48,7 +48,7 @@ var NetCDFFormat = {
48
48
  };
49
49
 
50
50
  // dist/netcdf/netcdf-loader.js
51
- var VERSION = true ? "5.0.0-beta.2" : "latest";
51
+ var VERSION = true ? "5.0.0-beta.4" : "latest";
52
52
  async function preload() {
53
53
  const { NetCDFLoaderWithParser } = await import("@loaders.gl/scientific/netcdf/netcdf-loader-with-parser");
54
54
  return NetCDFLoaderWithParser;
@@ -4,7 +4,7 @@
4
4
  import { NetCDFFormat } from "./netcdf-format.js";
5
5
  // __VERSION__ is injected by babel-plugin-version-inline
6
6
  // @ts-ignore TS2304: Cannot find name '__VERSION__'.
7
- const VERSION = typeof "5.0.0-beta.2" !== 'undefined' ? "5.0.0-beta.2" : 'latest';
7
+ const VERSION = typeof "5.0.0-beta.4" !== 'undefined' ? "5.0.0-beta.4" : 'latest';
8
8
  /** Preloads the parser-bearing NetCDF loader implementation. */
9
9
  async function preload() {
10
10
  const { NetCDFLoaderWithParser } = await import('@loaders.gl/scientific/netcdf/netcdf-loader-with-parser');
@@ -4,7 +4,7 @@
4
4
  import { NetCDFFormat } from "./netcdf-format.js";
5
5
  // __VERSION__ is injected by babel-plugin-version-inline
6
6
  // @ts-ignore TS2304: Cannot find name '__VERSION__'.
7
- const VERSION = typeof "5.0.0-beta.2" !== 'undefined' ? "5.0.0-beta.2" : 'latest';
7
+ const VERSION = typeof "5.0.0-beta.4" !== 'undefined' ? "5.0.0-beta.4" : 'latest';
8
8
  /** Loads the parser-bearing NetCDF source through its explicit implementation subpath. */
9
9
  async function preloadNetCDFSourceLoader() {
10
10
  const { NetCDFSourceLoaderWithParser } = await import('@loaders.gl/scientific/netcdf/netcdf-source-loader');
@@ -6,7 +6,7 @@ import { NetCDFFormat } from "./netcdf-format.js";
6
6
  import { NetCDFReader } from "./netcdfjs/netcdf-reader.js";
7
7
  // __VERSION__ is injected by babel-plugin-version-inline
8
8
  // @ts-ignore TS2304: Cannot find name '__VERSION__'.
9
- const VERSION = typeof "5.0.0-beta.2" !== 'undefined' ? "5.0.0-beta.2" : 'latest';
9
+ const VERSION = typeof "5.0.0-beta.4" !== 'undefined' ? "5.0.0-beta.4" : 'latest';
10
10
  /**
11
11
  * NetCDF classic source with header-only discovery and typed variable/slice execution.
12
12
  */
@@ -5,8 +5,8 @@
5
5
  else if (typeof exports === 'object') exports['loaders'] = factory();
6
6
  else root['loaders'] = factory();})(globalThis, function () {
7
7
  "use strict";var __exports__=(()=>{var Wt=Object.create;var Q=Object.defineProperty;var zt=Object.getOwnPropertyDescriptor;var Vt=Object.getOwnPropertyNames;var Gt=Object.getPrototypeOf,Qt=Object.prototype.hasOwnProperty;var D=(t,e,r)=>()=>{if(r)throw r[0];try{return t&&(e=t(t=0)),e}catch(n){throw r=[n],n}};var Jt=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(r){throw e=0,r}},Zt=(t,e)=>{for(var r in e)Q(t,r,{get:e[r],enumerable:!0})},rt=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Vt(e))!Qt.call(t,s)&&s!==r&&Q(t,s,{get:()=>e[s],enumerable:!(n=zt(e,s))||n.enumerable});return t};var Yt=(t,e,r)=>(r=t!=null?Wt(Gt(t)):{},rt(e||!t||!t.__esModule?Q(r,"default",{value:t,enumerable:!0}):r,t)),Kt=t=>rt(Q({},"__esModule",{value:!0}),t);var st=Jt((Zr,nt)=>{nt.exports=globalThis.loaders});var te,Dt=D(()=>{"use strict";te=class t{buffer;byteLength;byteOffset;length;offset;lastWrittenByte;littleEndian;_data;_mark;_marks;textDecoder=new TextDecoder;textEncoder=new TextEncoder;constructor(e=8192,r={}){let n=!1;typeof e=="number"?e=new ArrayBuffer(e):(n=!0,this.lastWrittenByte=e.byteLength);let s=r.offset?r.offset>>>0:0,o=e.byteLength-s,c=s;(ArrayBuffer.isView(e)||e instanceof t)&&(e.byteLength!==e.buffer.byteLength&&(c=e.byteOffset+s),e=e.buffer),n?this.lastWrittenByte=o:this.lastWrittenByte=0,this.buffer=e,this.length=o,this.byteLength=o,this.byteOffset=c,this.offset=0,this.littleEndian=!0,this._data=new DataView(this.buffer,c,o),this._mark=0,this._marks=[]}available(e=1){return this.offset+e<=this.length}isLittleEndian(){return this.littleEndian}setLittleEndian(){return this.littleEndian=!0,this}isBigEndian(){return!this.littleEndian}setBigEndian(){return this.littleEndian=!1,this}skip(e=1){return this.offset+=e,this}seek(e){return this.offset=e,this}mark(){return this._mark=this.offset,this}reset(){return this.offset=this._mark,this}pushMark(){return this._marks.push(this.offset),this}popMark(){let e=this._marks.pop();if(e===void 0)throw new Error("Mark stack empty");return this.seek(e),this}rewind(){return this.offset=0,this}ensureAvailable(e=1){if(!this.available(e)){let n=(this.offset+e)*2,s=new Uint8Array(n);s.set(new Uint8Array(this.buffer)),this.buffer=s.buffer,this.length=this.byteLength=n,this._data=new DataView(this.buffer)}return this}readBoolean(){return this.readUint8()!==0}readInt8(){return this._data.getInt8(this.offset++)}readUint8(){return this._data.getUint8(this.offset++)}readByte(){return this.readUint8()}readBytes(e=1){let r=new Uint8Array(e);for(let n=0;n<e;n++)r[n]=this.readByte();return r}readInt16(){let e=this._data.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}readUint16(){let e=this._data.getUint16(this.offset,this.littleEndian);return this.offset+=2,e}readInt32(){let e=this._data.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}readUint32(){let e=this._data.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}readFloat32(){let e=this._data.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}readFloat64(){let e=this._data.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}readChar(){return String.fromCharCode(this.readInt8())}readChars(e=1){let r="";for(let n=0;n<e;n++)r+=this.readChar();return r}readUtf8(e=1){return this.textDecoder.decode(this.readBytes(e))}writeBoolean(e){return this.writeUint8(e?255:0),this}writeInt8(e){return this.ensureAvailable(1),this._data.setInt8(this.offset++,e),this._updateLastWrittenByte(),this}writeUint8(e){return this.ensureAvailable(1),this._data.setUint8(this.offset++,e),this._updateLastWrittenByte(),this}writeByte(e){return this.writeUint8(e)}writeBytes(e){this.ensureAvailable(e.length);for(let r=0;r<e.length;r++)this._data.setUint8(this.offset++,e[r]);return this._updateLastWrittenByte(),this}writeInt16(e){return this.ensureAvailable(2),this._data.setInt16(this.offset,e,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeUint16(e){return this.ensureAvailable(2),this._data.setUint16(this.offset,e,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeInt32(e){return this.ensureAvailable(4),this._data.setInt32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeUint32(e){return this.ensureAvailable(4),this._data.setUint32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat32(e){return this.ensureAvailable(4),this._data.setFloat32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat64(e){return this.ensureAvailable(8),this._data.setFloat64(this.offset,e,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeChar(e){return this.writeUint8(e.charCodeAt(0))}writeChars(e){for(let r=0;r<e.length;r++)this.writeUint8(e.charCodeAt(r));return this}writeUtf8(e){let r=this.textEncoder.encode(e);return this.writeBytes(r)}toArray(){return new Uint8Array(this.buffer,this.byteOffset,this.lastWrittenByte)}_updateLastWrittenByte(){this.offset>this.lastWrittenByte&&(this.lastWrittenByte=this.offset)}}});function V(t,e,r){switch(e){case m.BYTE:return t.readBytes(r);case m.CHAR:return Br(t.readChars(r));case m.SHORT:return re(r,t.readInt16.bind(t));case m.INT:return re(r,t.readInt32.bind(t));case m.FLOAT:return re(r,t.readFloat32.bind(t));case m.DOUBLE:return re(r,t.readFloat64.bind(t));default:throw new Error(`NetCDF: non valid type ${e}`)}}function Ve(t){switch(Number(t)){case m.BYTE:return"byte";case m.CHAR:return"char";case m.SHORT:return"short";case m.INT:return"int";case m.FLOAT:return"float";case m.DOUBLE:return"double";default:return"undefined"}}function It(t){switch(Number(t)){case m.BYTE:return 1;case m.CHAR:return 1;case m.SHORT:return 2;case m.INT:return 4;case m.FLOAT:return 4;case m.DOUBLE:return 8;default:return-1}}function Ge(t){switch(String(t)){case"byte":return m.BYTE;case"char":return m.CHAR;case"short":return m.SHORT;case"int":return m.INT;case"float":return m.FLOAT;case"double":return m.DOUBLE;default:return-1}}function re(t,e){if(t!==1){let r=new Array(t);for(let n=0;n<t;n++)r[n]=e();return r}return e()}function Br(t){return t.charCodeAt(t.length-1)===0?t.substring(0,t.length-1):t}var m,Qe=D(()=>{"use strict";m={BYTE:1,CHAR:2,SHORT:3,INT:4,FLOAT:5,DOUBLE:6}});function Ut(t,e){let r=t.readUint32(),n=Dr(t),s=Pt(t),o=Ir(t,n.recordId,e);return{version:e,recordDimension:{length:r,id:n.recordId,name:n.recordName,recordStep:o.recordStep},dimensions:n.dimensions,variables:o.variables,attributes:s}}function Dr(t){let e=t.readUint32();if(e===k){if(t.readUint32()!==k)throw new Error("NetCDF: wrong empty tag for list of dimensions");return{recordId:0,recordName:"",dimensions:[]}}if(e!==Nr)throw new Error("NetCDF: wrong tag for list of dimensions");let r=t.readUint32(),n=new Array(r),s,o;for(let c=0;c<r;c++){let d=Je(t),h=t.readUint32();h===Fr&&(s=c,o=d),n[c]={name:d,size:h}}return{dimensions:n,recordId:s,recordName:o}}function Pt(t){let e=t.readUint32();if(e===k){if(t.readUint32()!==k)throw new Error("NetCDF: wrong empty tag for list of attributes");return[]}if(e!==Lr)throw new Error("NetCDF: wrong tag for list of attributes");let r=t.readUint32(),n=new Array(r);for(let s=0;s<r;s++){let o=Je(t),c=t.readUint32();if(c<1||c>6)throw new Error(`NetCDF: non valid type ${c}`);let d=t.readUint32(),h=V(t,c,d);Ot(t),n[s]={name:o,type:Ve(c),value:h}}return n}function Ir(t,e,r){let n=t.readUint32(),s=0;if(n===k){if(t.readUint32()!==k)throw new Error("NetCDF: wrong empty tag for list of variables");return{recordStep:s,variables:[]}}if(n!==vr)throw new Error("NetCDF: wrong tag for list of variables");let o=t.readUint32(),c=new Array(o);for(let d=0;d<o;d++){let h=Je(t),a=t.readUint32(),l=new Array(a);for(let w=0;w<a;w++)l[w]=t.readUint32();let f=Pt(t),u=t.readUint32();if(u<1&&u>6)throw new Error(`NetCDF: non valid type ${u}`);let g=t.readUint32(),p=t.readUint32();if(r===2){if(p>0)throw new Error("NetCDF: offsets larger than 4GB not supported");p=t.readUint32()}let b=!1;typeof e<"u"&&l[0]===e&&(s+=g,b=!0),c[d]={name:h,dimensions:l,attributes:f,type:Ve(u),size:g,offset:p,record:b}}return{variables:c,recordStep:s}}function Je(t){let e=t.readUint32(),r=t.readChars(e);return Ot(t),r}function Ot(t){t.offset%4!==0&&t.skip(4-t.offset%4)}var k,Nr,vr,Lr,Fr,kt=D(()=>{"use strict";Qe();k=0,Nr=10,vr=11,Lr=12,Fr=0});function jt(t,e){let r=Ge(e.type),n=e.size/It(r),s=new Array(n);for(let o=0;o<n;o++)s[o]=V(t,r,1);return s}function $t(t,e,r,n){let s=Ge(e.type),o=e.dimensions.filter(a=>a!==r.id).reduce((a,l)=>a*n[l].size,1),c=r.length,d=new Array(c),h=r.recordStep;for(let a=0;a<c;a++){let l=t.offset;d[a]=V(t,s,o),t.seek(l+h)}return d}var Ht=D(()=>{"use strict";Qe()});var S,Ze=D(()=>{"use strict";Dt();kt();Ht();S=class{header;buffer;constructor(e){let r=new te(e);r.setBigEndian();let n=r.readChars(3);if(n!=="CDF")throw new Error(`NetCDF: file should start with 'CDF', found ${n}`);let s=r.readByte();if(s>2)throw new Error(`NetCDF: unsupported version ${s}`);this.header=Ut(r,s),this.buffer=r}get version(){return this.header.version===1?"classic format":"64-bit offset format"}get recordDimension(){return this.header.recordDimension}get dimensions(){return this.header.dimensions}get attributes(){return this.header.attributes}get variables(){return this.header.variables}attributeExists(e){return this.attributes.find(n=>n.name===e)!==void 0}getAttribute(e){let r=this.attributes.find(n=>n.name===e);return r?r.value:null}dataVariableExists(e){return this.header.variables.find(function(n){return n.name===e})!==void 0}getDataVariableAsString(e){let r=this.getDataVariable(e);return r?r.join(""):null}getDataVariable(e){let r;if(typeof e=="string"?r=this.header.variables.find(function(n){return n.name===e}):r=e,r===void 0){let n;throw typeof e=="string"?n=e:typeof e=="object"&&(n=JSON.stringify(e)),new Error(`NetCDF: variable not found: ${n}`)}return this.buffer.seek(r.offset),r.record?$t(this.buffer,r,this.header.recordDimension,this.header.dimensions):jt(this.buffer,r)}toString(){let e=[];e.push("DIMENSIONS");for(let n of this.dimensions)e.push(` ${n.name.padEnd(30)} = size: ${n.size}`);e.push(""),e.push("GLOBAL ATTRIBUTES");for(let n of this.attributes)e.push(` ${n.name.padEnd(30)} = ${n.value}`);let r=JSON.parse(JSON.stringify(this.variables));e.push(""),e.push("VARIABLES:");for(let n of r){n.value=this.getDataVariable(n);let s=JSON.stringify(n.value);s.length>50&&(s=s.substring(0,50)),Number.isNaN(n.value.length)||(s+=` (length: ${n.value.length})`),e.push(` ${n.name.padEnd(30)} = ${s}`)}return e.join(`
8
- `)}}});var G,Ye=D(()=>{"use strict";G={name:"NetCDF",id:"netcdf",module:"netcdf",encoding:"binary",format:"netcdf",extensions:["cdf","nc"],mimeTypes:["application/x-netcdf"],binary:!0}});var Qr={};Zt(Qr,{FetchError:()=>i.FetchError,JSONLoader:()=>He,NetCDFFormat:()=>G,NetCDFReader:()=>S,NetCDFSourceLoader:()=>se,NullLoader:()=>i.NullLoader,NullWorkerLoader:()=>i.NullWorkerLoader,RequestScheduler:()=>O,_BrowserFileSystem:()=>i._BrowserFileSystem,_fetchProgress:()=>i._fetchProgress,_selectSource:()=>i._selectSource,_unregisterLoaders:()=>i._unregisterLoaders,assert:()=>ae,concatenateArrayBuffersAsync:()=>De,coreApi:()=>i.coreApi,createDataSource:()=>i.createDataSource,document:()=>le,encode:()=>i.encode,encodeInBatches:()=>i.encodeInBatches,encodeSync:()=>i.encodeSync,encodeTable:()=>i.encodeTable,encodeTableAsText:()=>i.encodeTableAsText,encodeTableInBatches:()=>i.encodeTableInBatches,encodeText:()=>i.encodeText,encodeTextSync:()=>i.encodeTextSync,encodeURLtoURL:()=>i.encodeURLtoURL,fetchFile:()=>i.fetchFile,forEach:()=>Fe,getLoaderOptions:()=>i.getLoaderOptions,getPathPrefix:()=>$e,global:()=>fe,isAsyncIterable:()=>Se,isBrowser:()=>de,isIterable:()=>Ee,isIterator:()=>Ae,isPromise:()=>Te,isPureObject:()=>q,isReadableStream:()=>Re,isResponse:()=>_e,isWorker:()=>he,isWritableStream:()=>Ce,load:()=>i.load,loadInBatches:()=>i.loadInBatches,makeIterator:()=>i.makeIterator,makeLineIterator:()=>ve,makeNumberedLineIterator:()=>Le,makeStream:()=>i.makeStream,makeTextDecoderIterator:()=>Be,makeTextEncoderIterator:()=>Ne,parse:()=>i.parse,parseFile:()=>i.parseFile,parseInBatches:()=>i.parseInBatches,parseSync:()=>i.parseSync,preload:()=>i.preload,preloadSync:()=>i.preloadSync,readArrayBuffer:()=>i.readArrayBuffer,registerLoaders:()=>i.registerLoaders,resolvePath:()=>W,selectLoader:()=>i.selectLoader,selectLoaderSync:()=>i.selectLoaderSync,self:()=>ce,setLoaderOptions:()=>i.setLoaderOptions,setPathPrefix:()=>je,window:()=>ue});var i=Yt(st(),1);function ae(t,e){if(!t)throw new Error(e||"loader assertion failed.")}var T={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},ce=T.self||T.window||T.global||{},ue=T.window||T.self||T.global||{},fe=T.global||T.self||T.window||{},le=T.document||{};var de=!!(typeof process!="object"||String(process)!=="[object process]"||process.browser),he=typeof importScripts=="function",ot=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),Xt=ot&&parseFloat(ot[1])||0;var j=globalThis,er=globalThis.document||{},J=globalThis.process||{},tr=globalThis.console,rr=globalThis.navigator||{};function Z(t){if(typeof window<"u"&&window.process?.type==="renderer"||typeof process<"u"&&process.versions?.electron)return!0;let e=typeof navigator<"u"&&navigator.userAgent,r=t||e;return!!(r&&r.indexOf("Electron")>=0)}function R(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||Z()}var me="5.0.0";function I(t,e){if(!t)throw new Error(e||"Assertion failed")}function Y(t){if(!t)return 0;let e;switch(typeof t){case"number":e=t;break;case"object":e=t.logLevel||t.priority||0;break;default:return 0}return I(Number.isFinite(e)&&e>=0),e}function pe(t){let{logLevel:e,message:r}=t;t.logLevel=Y(e);let n=t.args?Array.from(t.args):[];for(;n.length&&n.shift()!==r;);switch(typeof e){case"string":case"function":r!==void 0&&n.unshift(r),t.message=e;break;case"object":Object.assign(t,e);break;default:}typeof t.message=="function"&&(t.message=t.message());let s=typeof t.message;return I(s==="string"||s==="object"),Object.assign(t,{args:n},t.opts)}var C=()=>{},v=class{constructor({level:e=0}={}){this.userData={},this._onceCache=new Set,this._level=e}set level(e){this.setLevel(e)}get level(){return this.getLevel()}setLevel(e){return this._level=e,this}getLevel(){return this._level}warn(e,...r){return this._log("warn",0,e,r,{once:!0})}error(e,...r){return this._log("error",0,e,r)}log(e,r,...n){return this._log("log",e,r,n)}info(e,r,...n){return this._log("info",e,r,n)}once(e,r,...n){return this._log("once",e,r,n,{once:!0})}_log(e,r,n,s,o={}){let c=pe({logLevel:r,message:n,args:this._buildArgs(r,n,s),opts:o});return this._createLogFunction(e,c,o)}_buildArgs(e,r,n){return[e,r,...n]}_createLogFunction(e,r,n){if(!this._shouldLog(r.logLevel))return C;let s=this._getOnceTag(n.tag??r.tag??r.message);if((n.once||r.once)&&s!==void 0){if(this._onceCache.has(s))return C;this._onceCache.add(s)}return this._emit(e,r)}_shouldLog(e){return this.getLevel()>=Y(e)}_getOnceTag(e){if(e!==void 0)try{return typeof e=="string"?e:String(e)}catch{return}}};function sr(t){try{let e=window[t],r="__storage_test__";return e.setItem(r,r),e.removeItem(r),e}catch{return null}}var $=class{constructor(e,r,n="sessionStorage"){this.storage=sr(n),this.id=e,this.config=r,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){let r=JSON.stringify(this.config);this.storage.setItem(this.id,r)}}_loadConfiguration(){let e={};if(this.storage){let r=this.storage.getItem(this.id);e=r?JSON.parse(r):{}}return Object.assign(this.config,e),this}};function it(t){let e;return t<10?e=`${t.toFixed(2)}ms`:t<100?e=`${t.toFixed(1)}ms`:t<1e3?e=`${t.toFixed(0)}ms`:e=`${(t/1e3).toFixed(2)}s`,e}function ge(t,e=8){let r=Math.max(e-t.length,0);return`${" ".repeat(r)}${t}`}var H;(function(t){t[t.BLACK=30]="BLACK",t[t.RED=31]="RED",t[t.GREEN=32]="GREEN",t[t.YELLOW=33]="YELLOW",t[t.BLUE=34]="BLUE",t[t.MAGENTA=35]="MAGENTA",t[t.CYAN=36]="CYAN",t[t.WHITE=37]="WHITE",t[t.BRIGHT_BLACK=90]="BRIGHT_BLACK",t[t.BRIGHT_RED=91]="BRIGHT_RED",t[t.BRIGHT_GREEN=92]="BRIGHT_GREEN",t[t.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",t[t.BRIGHT_BLUE=94]="BRIGHT_BLUE",t[t.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",t[t.BRIGHT_CYAN=96]="BRIGHT_CYAN",t[t.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(H||(H={}));var or=10;function at(t){return typeof t!="string"?t:(t=t.toUpperCase(),H[t]||H.WHITE)}function ye(t,e,r){return!R&&typeof t=="string"&&(e&&(t=`\x1B[${at(e)}m${t}\x1B[39m`),r&&(t=`\x1B[${at(r)+or}m${t}\x1B[49m`)),t}function be(t,e=["constructor"]){let r=Object.getPrototypeOf(t),n=Object.getOwnPropertyNames(r),s=t;for(let o of n){let c=s[o];typeof c=="function"&&(e.find(d=>o===d)||(s[o]=c.bind(t)))}}var K=class{getHighResolutionTimer(){let e;if(R()&&j.performance)e=j?.performance?.now?.();else if("hrtime"in J){let r=J?.hrtime?.();e=r[0]*1e3+r[1]/1e6}else e=Date.now();return e}getMemoryUsageMB(){let r=j?.performance?.memory?.usedJSHeapSize;return r==null?null:Math.trunc(r/1024/1024)}},x=new K;globalThis.Probe=K;globalThis.probe=x;var U={debug:R()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},we={enabled:!0,level:0},E=class extends v{constructor({id:e}={id:""}){super({level:0}),this.VERSION=me,this._startTs=x.getHighResolutionTimer(),this._deltaTs=x.getHighResolutionTimer(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new $(`__probe-${this.id}__`,{[this.id]:we}),this.timeStamp(`${this.id} started`),be(this),Object.seal(this)}isEnabled(){return this._getConfiguration().enabled}getLevel(){return this._getConfiguration().level}getTotal(){return Number((x.getHighResolutionTimer()-this._startTs).toPrecision(10))}getDelta(){return Number((x.getHighResolutionTimer()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._updateConfiguration({enabled:e}),this}setLevel(e){return this._updateConfiguration({level:e}),this}get(e){return this._getConfiguration()[e]}set(e,r){this._updateConfiguration({[e]:r})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,r){if(!e)throw new Error(r||"Assertion failed")}warn(e,...r){return this._log("warn",0,e,r,{method:U.warn,once:!0})}error(e,...r){return this._log("error",0,e,r,{method:U.error})}deprecated(e,r){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${r}\` instead`)}removed(e,r){return this.error(`\`${e}\` has been removed. Use \`${r}\` instead`)}probe(e,r,...n){let s=x.getMemoryUsageMB();if(s!==null){let o=`${s}MB `;typeof r=="function"?r=()=>`${o}${r()}`:typeof r=="string"&&(r=`${o}${r}`)}return this._log("log",e,r,n,{method:U.log,time:!0,once:!0})}log(e,r,...n){return this._log("log",e,r,n,{method:U.debug})}info(e,r,...n){return this._log("info",e,r,n,{method:console.info})}once(e,r,...n){return this._log("once",e,r,n,{method:U.debug||U.info,once:!0})}table(e,r,n){return r?this._log("table",e,r,n&&[n]||[],{method:console.table||C,tag:ar(r)}):C}time(e,r){return this._log("time",e,r,[],{method:console.time?console.time:console.info})}timeEnd(e,r){return this._log("time",e,r,[],{method:console.timeEnd?console.timeEnd:console.info})}timeStamp(e,r){return this._log("time",e,r,[],{method:console.timeStamp||C})}group(e,r,n={collapsed:!1}){let s=(n.collapsed?console.groupCollapsed:console.group)||console.info;return this._log("group",e,r,[],{method:s})}groupCollapsed(e,r,n={}){return this.group(e,r,Object.assign({},n,{collapsed:!0}))}groupEnd(e){return this._log("groupEnd",e,"",[],{method:console.groupEnd||C})}withGroup(e,r,n){this.group(e,r)();try{n()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&super._shouldLog(e)}_emit(e,r){let n=r.method;I(n),r.total=this.getTotal(),r.delta=this.getDelta(),this._deltaTs=x.getHighResolutionTimer();let s=ir(this.id,r.message,r);return n.bind(console,s,...r.args)}_getConfiguration(){return this._storage.config[this.id]||this._updateConfiguration(we),this._storage.config[this.id]}_updateConfiguration(e){let r=this._storage.config[this.id]||{...we};this._storage.setConfiguration({[this.id]:{...r,...e}})}};E.VERSION=me;function ir(t,e,r){if(typeof e=="string"){let n=r.time?ge(it(r.total)):"";e=r.time?`${t}: ${n} ${e}`:`${t}: ${e}`,e=ye(e,r.color,r.background)}return e}function ar(t){for(let e in t)for(let r in t[e])return r||"untitled";return"empty"}globalThis.probe||(globalThis.probe=x);var Xn=new E({id:"@probe.gl/log"});var xe="5.0.0-beta.2",cr=xe[0]>="0"&&xe[0]<="9"?`v${xe}`:"";function ur(){let t=new E({id:"loaders.gl"});return globalThis.loaders||={},globalThis.loaders.log=t,globalThis.loaders.version=cr,globalThis.probe||={},globalThis.probe.loaders=t,t}var ct=ur();var ut=t=>typeof t=="boolean",y=t=>typeof t=="function",B=t=>t!==null&&typeof t=="object",q=t=>B(t)&&t.constructor==={}.constructor;var Te=t=>B(t)&&"then"in t&&y(t.then),Ee=t=>!!t&&y(t[Symbol.iterator]),Se=t=>!!t&&y(t[Symbol.asyncIterator]),Ae=t=>!!t&&y(t.next),_e=t=>typeof Response<"u"&&t instanceof Response||B(t)&&y(t.arrayBuffer)&&y(t.text)&&y(t.json);var ft=t=>B(t)&&y(t.abort)&&y(t.getWriter),lt=t=>typeof ReadableStream<"u"&&t instanceof ReadableStream||B(t)&&y(t.tee)&&y(t.cancel)&&y(t.getReader),dt=t=>B(t)&&y(t.end)&&y(t.write)&&ut(t.writable),ht=t=>B(t)&&y(t.read)&&y(t.pipe)&&ut(t.readable),Re=t=>lt(t)||ht(t),Ce=t=>ft(t)||dt(t);function X(t,e){return mt(t||{},e)}function mt(t,e,r=0){if(r>3)return e;let n={...t};for(let[s,o]of Object.entries(e))q(o)?n[s]=mt(n[s]||{},e[s],r+1):n[s]=e[s];return n}function pt(...t){return fr(t)}function fr(t){let e=t.map(o=>o instanceof ArrayBuffer?new Uint8Array(o):o),r=e.reduce((o,c)=>o+c.byteLength,0),n=new Uint8Array(r),s=0;for(let o of e)n.set(o,s),s+=o.byteLength;return n.buffer}async function*Be(t,e={}){let r=new TextDecoder(void 0,e);for await(let n of t)yield typeof n=="string"?n:r.decode(n,{stream:!0})}async function*Ne(t){let e=new TextEncoder;for await(let r of t)yield typeof r=="string"?e.encode(r).buffer:r}async function*ve(t){let e="";for await(let r of t){e+=r;let n;for(n=e.indexOf(`
8
+ `)}}});var G,Ye=D(()=>{"use strict";G={name:"NetCDF",id:"netcdf",module:"netcdf",encoding:"binary",format:"netcdf",extensions:["cdf","nc"],mimeTypes:["application/x-netcdf"],binary:!0}});var Qr={};Zt(Qr,{FetchError:()=>i.FetchError,JSONLoader:()=>He,NetCDFFormat:()=>G,NetCDFReader:()=>S,NetCDFSourceLoader:()=>se,NullLoader:()=>i.NullLoader,NullWorkerLoader:()=>i.NullWorkerLoader,RequestScheduler:()=>O,_BrowserFileSystem:()=>i._BrowserFileSystem,_fetchProgress:()=>i._fetchProgress,_selectSource:()=>i._selectSource,_unregisterLoaders:()=>i._unregisterLoaders,assert:()=>ae,concatenateArrayBuffersAsync:()=>De,coreApi:()=>i.coreApi,createDataSource:()=>i.createDataSource,document:()=>le,encode:()=>i.encode,encodeInBatches:()=>i.encodeInBatches,encodeSync:()=>i.encodeSync,encodeTable:()=>i.encodeTable,encodeTableAsText:()=>i.encodeTableAsText,encodeTableInBatches:()=>i.encodeTableInBatches,encodeText:()=>i.encodeText,encodeTextSync:()=>i.encodeTextSync,encodeURLtoURL:()=>i.encodeURLtoURL,fetchFile:()=>i.fetchFile,forEach:()=>Fe,getLoaderOptions:()=>i.getLoaderOptions,getPathPrefix:()=>$e,global:()=>fe,isAsyncIterable:()=>Se,isBrowser:()=>de,isIterable:()=>Ee,isIterator:()=>Ae,isPromise:()=>Te,isPureObject:()=>q,isReadableStream:()=>Re,isResponse:()=>_e,isWorker:()=>he,isWritableStream:()=>Ce,load:()=>i.load,loadInBatches:()=>i.loadInBatches,makeIterator:()=>i.makeIterator,makeLineIterator:()=>ve,makeNumberedLineIterator:()=>Le,makeStream:()=>i.makeStream,makeTextDecoderIterator:()=>Be,makeTextEncoderIterator:()=>Ne,parse:()=>i.parse,parseFile:()=>i.parseFile,parseInBatches:()=>i.parseInBatches,parseSync:()=>i.parseSync,preload:()=>i.preload,preloadSync:()=>i.preloadSync,readArrayBuffer:()=>i.readArrayBuffer,registerLoaders:()=>i.registerLoaders,resolvePath:()=>W,selectLoader:()=>i.selectLoader,selectLoaderSync:()=>i.selectLoaderSync,self:()=>ce,setLoaderOptions:()=>i.setLoaderOptions,setPathPrefix:()=>je,window:()=>ue});var i=Yt(st(),1);function ae(t,e){if(!t)throw new Error(e||"loader assertion failed.")}var T={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},ce=T.self||T.window||T.global||{},ue=T.window||T.self||T.global||{},fe=T.global||T.self||T.window||{},le=T.document||{};var de=!!(typeof process!="object"||String(process)!=="[object process]"||process.browser),he=typeof importScripts=="function",ot=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),Xt=ot&&parseFloat(ot[1])||0;var j=globalThis,er=globalThis.document||{},J=globalThis.process||{},tr=globalThis.console,rr=globalThis.navigator||{};function Z(t){if(typeof window<"u"&&window.process?.type==="renderer"||typeof process<"u"&&process.versions?.electron)return!0;let e=typeof navigator<"u"&&navigator.userAgent,r=t||e;return!!(r&&r.indexOf("Electron")>=0)}function R(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||Z()}var me="5.0.0";function I(t,e){if(!t)throw new Error(e||"Assertion failed")}function Y(t){if(!t)return 0;let e;switch(typeof t){case"number":e=t;break;case"object":e=t.logLevel||t.priority||0;break;default:return 0}return I(Number.isFinite(e)&&e>=0),e}function pe(t){let{logLevel:e,message:r}=t;t.logLevel=Y(e);let n=t.args?Array.from(t.args):[];for(;n.length&&n.shift()!==r;);switch(typeof e){case"string":case"function":r!==void 0&&n.unshift(r),t.message=e;break;case"object":Object.assign(t,e);break;default:}typeof t.message=="function"&&(t.message=t.message());let s=typeof t.message;return I(s==="string"||s==="object"),Object.assign(t,{args:n},t.opts)}var C=()=>{},v=class{constructor({level:e=0}={}){this.userData={},this._onceCache=new Set,this._level=e}set level(e){this.setLevel(e)}get level(){return this.getLevel()}setLevel(e){return this._level=e,this}getLevel(){return this._level}warn(e,...r){return this._log("warn",0,e,r,{once:!0})}error(e,...r){return this._log("error",0,e,r)}log(e,r,...n){return this._log("log",e,r,n)}info(e,r,...n){return this._log("info",e,r,n)}once(e,r,...n){return this._log("once",e,r,n,{once:!0})}_log(e,r,n,s,o={}){let c=pe({logLevel:r,message:n,args:this._buildArgs(r,n,s),opts:o});return this._createLogFunction(e,c,o)}_buildArgs(e,r,n){return[e,r,...n]}_createLogFunction(e,r,n){if(!this._shouldLog(r.logLevel))return C;let s=this._getOnceTag(n.tag??r.tag??r.message);if((n.once||r.once)&&s!==void 0){if(this._onceCache.has(s))return C;this._onceCache.add(s)}return this._emit(e,r)}_shouldLog(e){return this.getLevel()>=Y(e)}_getOnceTag(e){if(e!==void 0)try{return typeof e=="string"?e:String(e)}catch{return}}};function sr(t){try{let e=window[t],r="__storage_test__";return e.setItem(r,r),e.removeItem(r),e}catch{return null}}var $=class{constructor(e,r,n="sessionStorage"){this.storage=sr(n),this.id=e,this.config=r,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){let r=JSON.stringify(this.config);this.storage.setItem(this.id,r)}}_loadConfiguration(){let e={};if(this.storage){let r=this.storage.getItem(this.id);e=r?JSON.parse(r):{}}return Object.assign(this.config,e),this}};function it(t){let e;return t<10?e=`${t.toFixed(2)}ms`:t<100?e=`${t.toFixed(1)}ms`:t<1e3?e=`${t.toFixed(0)}ms`:e=`${(t/1e3).toFixed(2)}s`,e}function ge(t,e=8){let r=Math.max(e-t.length,0);return`${" ".repeat(r)}${t}`}var H;(function(t){t[t.BLACK=30]="BLACK",t[t.RED=31]="RED",t[t.GREEN=32]="GREEN",t[t.YELLOW=33]="YELLOW",t[t.BLUE=34]="BLUE",t[t.MAGENTA=35]="MAGENTA",t[t.CYAN=36]="CYAN",t[t.WHITE=37]="WHITE",t[t.BRIGHT_BLACK=90]="BRIGHT_BLACK",t[t.BRIGHT_RED=91]="BRIGHT_RED",t[t.BRIGHT_GREEN=92]="BRIGHT_GREEN",t[t.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",t[t.BRIGHT_BLUE=94]="BRIGHT_BLUE",t[t.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",t[t.BRIGHT_CYAN=96]="BRIGHT_CYAN",t[t.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(H||(H={}));var or=10;function at(t){return typeof t!="string"?t:(t=t.toUpperCase(),H[t]||H.WHITE)}function ye(t,e,r){return!R&&typeof t=="string"&&(e&&(t=`\x1B[${at(e)}m${t}\x1B[39m`),r&&(t=`\x1B[${at(r)+or}m${t}\x1B[49m`)),t}function be(t,e=["constructor"]){let r=Object.getPrototypeOf(t),n=Object.getOwnPropertyNames(r),s=t;for(let o of n){let c=s[o];typeof c=="function"&&(e.find(d=>o===d)||(s[o]=c.bind(t)))}}var K=class{getHighResolutionTimer(){let e;if(R()&&j.performance)e=j?.performance?.now?.();else if("hrtime"in J){let r=J?.hrtime?.();e=r[0]*1e3+r[1]/1e6}else e=Date.now();return e}getMemoryUsageMB(){let r=j?.performance?.memory?.usedJSHeapSize;return r==null?null:Math.trunc(r/1024/1024)}},x=new K;globalThis.Probe=K;globalThis.probe=x;var U={debug:R()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},we={enabled:!0,level:0},E=class extends v{constructor({id:e}={id:""}){super({level:0}),this.VERSION=me,this._startTs=x.getHighResolutionTimer(),this._deltaTs=x.getHighResolutionTimer(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new $(`__probe-${this.id}__`,{[this.id]:we}),this.timeStamp(`${this.id} started`),be(this),Object.seal(this)}isEnabled(){return this._getConfiguration().enabled}getLevel(){return this._getConfiguration().level}getTotal(){return Number((x.getHighResolutionTimer()-this._startTs).toPrecision(10))}getDelta(){return Number((x.getHighResolutionTimer()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._updateConfiguration({enabled:e}),this}setLevel(e){return this._updateConfiguration({level:e}),this}get(e){return this._getConfiguration()[e]}set(e,r){this._updateConfiguration({[e]:r})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,r){if(!e)throw new Error(r||"Assertion failed")}warn(e,...r){return this._log("warn",0,e,r,{method:U.warn,once:!0})}error(e,...r){return this._log("error",0,e,r,{method:U.error})}deprecated(e,r){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${r}\` instead`)}removed(e,r){return this.error(`\`${e}\` has been removed. Use \`${r}\` instead`)}probe(e,r,...n){let s=x.getMemoryUsageMB();if(s!==null){let o=`${s}MB `;typeof r=="function"?r=()=>`${o}${r()}`:typeof r=="string"&&(r=`${o}${r}`)}return this._log("log",e,r,n,{method:U.log,time:!0,once:!0})}log(e,r,...n){return this._log("log",e,r,n,{method:U.debug})}info(e,r,...n){return this._log("info",e,r,n,{method:console.info})}once(e,r,...n){return this._log("once",e,r,n,{method:U.debug||U.info,once:!0})}table(e,r,n){return r?this._log("table",e,r,n&&[n]||[],{method:console.table||C,tag:ar(r)}):C}time(e,r){return this._log("time",e,r,[],{method:console.time?console.time:console.info})}timeEnd(e,r){return this._log("time",e,r,[],{method:console.timeEnd?console.timeEnd:console.info})}timeStamp(e,r){return this._log("time",e,r,[],{method:console.timeStamp||C})}group(e,r,n={collapsed:!1}){let s=(n.collapsed?console.groupCollapsed:console.group)||console.info;return this._log("group",e,r,[],{method:s})}groupCollapsed(e,r,n={}){return this.group(e,r,Object.assign({},n,{collapsed:!0}))}groupEnd(e){return this._log("groupEnd",e,"",[],{method:console.groupEnd||C})}withGroup(e,r,n){this.group(e,r)();try{n()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&super._shouldLog(e)}_emit(e,r){let n=r.method;I(n),r.total=this.getTotal(),r.delta=this.getDelta(),this._deltaTs=x.getHighResolutionTimer();let s=ir(this.id,r.message,r);return n.bind(console,s,...r.args)}_getConfiguration(){return this._storage.config[this.id]||this._updateConfiguration(we),this._storage.config[this.id]}_updateConfiguration(e){let r=this._storage.config[this.id]||{...we};this._storage.setConfiguration({[this.id]:{...r,...e}})}};E.VERSION=me;function ir(t,e,r){if(typeof e=="string"){let n=r.time?ge(it(r.total)):"";e=r.time?`${t}: ${n} ${e}`:`${t}: ${e}`,e=ye(e,r.color,r.background)}return e}function ar(t){for(let e in t)for(let r in t[e])return r||"untitled";return"empty"}globalThis.probe||(globalThis.probe=x);var Xn=new E({id:"@probe.gl/log"});var xe="5.0.0-beta.4",cr=xe[0]>="0"&&xe[0]<="9"?`v${xe}`:"";function ur(){let t=new E({id:"loaders.gl"});return globalThis.loaders||={},globalThis.loaders.log=t,globalThis.loaders.version=cr,globalThis.probe||={},globalThis.probe.loaders=t,t}var ct=ur();var ut=t=>typeof t=="boolean",y=t=>typeof t=="function",B=t=>t!==null&&typeof t=="object",q=t=>B(t)&&t.constructor==={}.constructor;var Te=t=>B(t)&&"then"in t&&y(t.then),Ee=t=>!!t&&y(t[Symbol.iterator]),Se=t=>!!t&&y(t[Symbol.asyncIterator]),Ae=t=>!!t&&y(t.next),_e=t=>typeof Response<"u"&&t instanceof Response||B(t)&&y(t.arrayBuffer)&&y(t.text)&&y(t.json);var ft=t=>B(t)&&y(t.abort)&&y(t.getWriter),lt=t=>typeof ReadableStream<"u"&&t instanceof ReadableStream||B(t)&&y(t.tee)&&y(t.cancel)&&y(t.getReader),dt=t=>B(t)&&y(t.end)&&y(t.write)&&ut(t.writable),ht=t=>B(t)&&y(t.read)&&y(t.pipe)&&ut(t.readable),Re=t=>lt(t)||ht(t),Ce=t=>ft(t)||dt(t);function X(t,e){return mt(t||{},e)}function mt(t,e,r=0){if(r>3)return e;let n={...t};for(let[s,o]of Object.entries(e))q(o)?n[s]=mt(n[s]||{},e[s],r+1):n[s]=e[s];return n}function pt(...t){return fr(t)}function fr(t){let e=t.map(o=>o instanceof ArrayBuffer?new Uint8Array(o):o),r=e.reduce((o,c)=>o+c.byteLength,0),n=new Uint8Array(r),s=0;for(let o of e)n.set(o,s),s+=o.byteLength;return n.buffer}async function*Be(t,e={}){let r=new TextDecoder(void 0,e);for await(let n of t)yield typeof n=="string"?n:r.decode(n,{stream:!0})}async function*Ne(t){let e=new TextEncoder;for await(let r of t)yield typeof r=="string"?e.encode(r).buffer:r}async function*ve(t){let e="";for await(let r of t){e+=r;let n;for(n=e.indexOf(`
9
9
  `);n>=0;){let s=e.slice(0,n+1);e=e.slice(n+1),yield s,n=e.indexOf(`
10
- `)}}e.length>0&&(yield e)}async function*Le(t){let e=1;for await(let r of t)yield{counter:e,line:r},e++}async function Fe(t,e){let r=dr(t);for(;;){let{done:n,value:s}=await r.next();if(n){r.return&&r.return();return}if(e(s))return}}async function De(t){let e=[];for await(let r of t)e.push(lr(r));return pt(...e)}function lr(t){if(t instanceof ArrayBuffer)return t;if(ArrayBuffer.isView(t)){let{buffer:e,byteOffset:r,byteLength:n}=t;return gt(e,r,n)}return gt(t)}function gt(t,e=0,r=t.byteLength-e){let n=new Uint8Array(t,e,r),s=new Uint8Array(n.length);return s.set(n),s.buffer}function dr(t){if(typeof t[Symbol.asyncIterator]=="function")return t[Symbol.asyncIterator]();if(typeof t[Symbol.iterator]=="function"){let e=t[Symbol.iterator]();return hr(e)}return t}function hr(t){return{next(e){return Promise.resolve(t.next(e))},return(e){return typeof t.return=="function"?Promise.resolve(t.return(e)):Promise.resolve({done:!0,value:e})},throw(e){return typeof t.throw=="function"?Promise.resolve(t.throw(e)):Promise.reject(e)}}}function M(){let t;if(typeof window<"u"&&window.performance)t=window.performance.now();else if(typeof process<"u"&&process.hrtime){let e=process.hrtime();t=e[0]*1e3+e[1]/1e6}else t=Date.now();return t}var L=class{constructor(e,r){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=e,this.type=r,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=M(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(M()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}};var P=class{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,r="count"){return this._getOrCreate({name:e,type:r})}get size(){return Object.keys(this.stats).length}reset(){for(let e of Object.values(this.stats))e.reset();return this}forEach(e){for(let r of Object.values(this.stats))e(r)}getTable(){let e={};return this.forEach(r=>{e[r.name]={time:r.time||0,count:r.count||0,average:r.getAverageTime()||0,hz:r.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(r=>this._getOrCreate(r))}_getOrCreate(e){let{name:r,type:n}=e,s=this.stats[r];return s||(e instanceof L?s=e:s=new L(r,n),this.stats[r]=s),s}};var mr="Queued Requests",pr="Active Requests",gr="Cancelled Requests",yr="Queued Requests Ever",br="Active Requests Ever",wr={id:"request-scheduler",throttleRequests:!0,maxRequests:6,debounceTime:0},O=class{props;stats;activeRequestCount=0;requestQueue=[];requestMap=new Map;updateTimer=null;constructor(e={}){this.props={...wr,...e},this.stats=new P({id:this.props.id}),this.stats.get(mr),this.stats.get(pr),this.stats.get(gr),this.stats.get(yr),this.stats.get(br)}setProps(e){e.throttleRequests!==void 0&&(this.props.throttleRequests=e.throttleRequests),e.maxRequests!==void 0&&(this.props.maxRequests=e.maxRequests),e.debounceTime!==void 0&&(this.props.debounceTime=e.debounceTime)}scheduleRequest(e,r=()=>0){if(!this.props.throttleRequests)return Promise.resolve({done:()=>{}});if(this.requestMap.has(e))return this.requestMap.get(e);let n={handle:e,priority:0,getPriority:r},s=new Promise(o=>(n.resolve=o,n));return this.requestQueue.push(n),this.requestMap.set(e,s),this._issueNewRequests(),s}_issueRequest(e){let{handle:r,resolve:n}=e,s=!1,o=()=>{s||(s=!0,this.requestMap.delete(r),this.activeRequestCount--,this.scheduleRefill())};return this.activeRequestCount++,n?n({done:o}):Promise.resolve({done:o})}scheduleRefill(){this.updateTimer===null&&(this.updateTimer=setTimeout(()=>this._issueNewRequestsAsync(),0))}_issueNewRequests(){this.updateTimer!==null&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>this._issueNewRequestsAsync(),this.props.debounceTime)}_issueNewRequestsAsync(){this.updateTimer!==null&&clearTimeout(this.updateTimer),this.updateTimer=null;let e=Math.max(this.props.maxRequests-this.activeRequestCount,0);if(e!==0){this._updateAllRequests();for(let r=0;r<e;++r){let n=this.requestQueue.shift();n&&this._issueRequest(n)}}}_updateAllRequests(){let e=this.requestQueue;for(let r=0;r<e.length;++r){let n=e[r];this._updateRequest(n)||(e.splice(r,1),this.requestMap.delete(n.handle),r--)}e.sort((r,n)=>r.priority-n.priority)}_updateRequest(e){return e.priority=e.getPriority(e.handle),e.priority<0?(e.resolve(null),!1):!0}};function Ue(t,e=[]){return t.every(Ie)?t:t.map((r,n)=>{if(Ie(r))return r;let s=e.find(c=>c.type===r?.type);if(!s)throw new Error(`No authentication class registered for credential at index ${n}.`);let o;try{o=new s(r)}catch{throw new Error(`Invalid authentication configuration at index ${n}.`)}if(!Ie(o))throw new Error(`Authentication class returned an invalid credential at index ${n}.`);return o})}function Pe(t){if(!t.core?.credentials?.length)return t;let e=Ue(t.core.credentials,t.core.authentications);return e===t.core.credentials?t:{...t,core:{...t.core,credentials:e}}}function Ie(t){return!t||typeof t!="object"||typeof t.id!="string"||!Array.isArray(t.origins)?!1:t.type==="request"?typeof t.authenticate=="function":(t.type==="header"||t.type==="query-parameter")&&typeof t.name=="string"&&(typeof t.token=="string"||typeof t.token=="function")&&Array.isArray(t.refreshStatusCodes)}var yt=Symbol("loaders.gl.authenticated-fetch"),Oe=new WeakMap;function xr(t){let e=t.fetch||((f,u)=>fetch(f,u)),r=e[yt],n=new Map(r?.credentialResolutions),s=Ue(t.credentials.map(f=>n.get(f)||f),t.authentications);if(t.credentials.forEach((f,u)=>{n.set(f,s[u])}),!t.fetchOptions&&(!s.length||r?.credentials.length===s.length&&s.every((f,u)=>f===r.credentials[u])))return e;let o=r?.fetch||e,c=r?[...new Set([...s,...r.credentials])]:s,d=bt(r?.fetchOptions||{},t.fetchOptions),h=c.filter(f=>f.type!=="request"),a=c.filter(f=>f.type==="request");for(let f of a)St(f.origins);let l=async(f,u={})=>{if(u=bt(d,u),u.signal?.throwIfAborted(),!c.length)return o(f,u);let g=Sr(f),p=g?await xt(g,u,h):{url:f,options:u,credentials:[]},b=await wt(p,a,"request"),w=await o(b.url,b.options),oe=[];for(let N of p.credentials){let{credential:_}=N;typeof _.token=="function"&&(ee(u)||_.canReplayRequest?.(f,u))&&(ee(b.options)||_.canReplayRequest?.(b.url,b.options))&&(_.refreshStatusCodes.includes(w.status)||await _.shouldRefresh?.(w))&&oe.push(N)}let et=ee(u)&&ee(b.options)&&b.credentials.some(N=>N.refreshStatusCodes?.includes(w.status));if(!oe.length&&!et)return w;u.signal?.throwIfAborted();let ie=new Map;if(await Promise.all(oe.map(async({credential:N})=>{let _=await Tr(N,f,w);_&&ie.set(N,_)})),!ie.size&&!et)return w;await w.body?.cancel().catch(()=>{}),u.signal?.throwIfAborted();let Mt=g?await xt(g,u,h,ie,p.credentials):{url:f,options:u},tt=await wt(Mt,a,"retry",w);return o(tt.url,tt.options)};return Object.defineProperty(l,yt,{value:{fetch:o,credentials:c,credentialResolutions:n,fetchOptions:d}}),l}function Tt(t={}){let e=t.fetch??t.core?.fetch,r;typeof e=="function"?r=e:r=(s,o)=>fetch(s,o);let n=typeof e=="object"&&e?e:void 0;return xr({fetch:r,fetchOptions:t.signal?{...n,signal:t.signal}:n,credentials:t.core?.credentials||[],authentications:t.core?.authentications})}function bt(t,e){let r={...t,...e};if(t.headers||e?.headers){let n=new Headers(t.headers);new Headers(e?.headers).forEach((s,o)=>n.set(o,s)),r.headers=n}return r}async function wt(t,e,r,n){let s=[],o=t.options.signal;for(let c of e){let d=Et(t.url);if(!d||!St(c.origins).includes(d))continue;o?.throwIfAborted();let h=await c.authenticate({url:t.url,options:{...t.options,headers:new Headers(t.options.headers)},reason:r,response:n?{status:n.status,headers:new Headers(n.headers)}:void 0});if(!h||typeof h.url!="string"||!h.options||typeof h.options!="object")throw new Error("Authentication callback returned an invalid request.");t={url:h.url,options:{...h.options,...o?{signal:o}:{}}},s.push(c)}return o?.throwIfAborted(),{...t,credentials:s}}function Et(t){try{let e=new URL(t);return!e.host||e.username||e.password?null:e.origin!=="null"?e.origin:`${e.protocol}//${e.host}`}catch{return null}}function St(t){if(!t.length)throw new Error("Request authentication requires at least one exact origin.");return t.map(e=>{let r=Et(e),n;try{n=new URL(e)}catch{throw new Error("Invalid request authentication origin.")}if(!r||n.pathname&&n.pathname!=="/"||n.search||n.hash)throw new Error("Invalid request authentication origin.");return r})}async function xt(t,e,r,n=new Map,s=[]){let o=new URL(t),c=new Headers(e.headers),d=[],h=new Map(s.map(({credential:a,token:l})=>[a,l]));for(let a of r){if(!a.origins.includes(o.origin))continue;let l=n.get(a),f=h.get(a),u=a.type==="query-parameter"&&f!==void 0,g=a.type==="header"&&f!==void 0;if(a.type==="query-parameter"&&o.searchParams.has(a.name)&&!u||a.type==="header"&&c.has(a.name)&&!g)continue;let p=l??f??await Er(a.token,{url:t.toString(),reason:"request"});p&&(a.type==="query-parameter"?o.searchParams.set(a.name,p):c.set(a.name,`${a.prefix||""}${p}`),d.push({credential:a,token:p}))}return{url:o.toString(),options:{...e,headers:c},credentials:d}}async function Tr(t,e,r){let n=Oe.get(t);if(n)return n;let s=t.token,o=Promise.resolve(s({url:e,reason:"refresh",response:{status:r.status,headers:r.headers}})).finally(()=>Oe.delete(t));return Oe.set(t,o),o}async function Er(t,e){return typeof t=="function"?t(e):t}function Sr(t){try{let e=new URL(t);return["http:","https:"].includes(e.protocol)?e:null}catch{return null}}function ee(t){let e=(t.method||"GET").toUpperCase();return["GET","HEAD","OPTIONS","PUT","DELETE"].includes(e)?!(t.body&&typeof ReadableStream<"u"&&t.body instanceof ReadableStream):!1}var ke="",At={};function je(t){ke=t}function $e(){return ke}function W(t){for(let e in At)if(t.startsWith(e)){let r=At[e];t=t.replace(e,r)}return!t.startsWith("http://")&&!t.startsWith("https://")&&(t=`${ke}${t}`),t}var Ar="5.0.0-beta.2",He={dataType:null,batchType:null,name:"JSON",id:"json",module:"json",version:Ar,encoding:"json",format:"json",extensions:["json","geojson"],mimeTypes:["application/json"],category:"json",text:!0,parseTextSync:_t,parse:async t=>_t(new TextDecoder().decode(t)),options:{}};function _t(t){return JSON.parse(t)}var _r={fetchFile:F("fetchFile"),parse:F("parse"),parseFile:F("parseFile"),parseSync:F("parseSync"),parseInBatches:F("parseInBatches"),load:F("load"),loadInBatches:F("loadInBatches")},z=class t{static defaultOptions={core:{type:"auto",attributions:[],loaders:[],onError:void 0}};optionsType;options;data;url;loadOptions;fetch;coreApi;hasCoreApi;_needsRefresh=!0;constructor(e,r,n,s){this.options=X(X(t.defaultOptions,n||{}),r),this.data=e,this.url=typeof e=="string"?W(e):"";let o=Pe(Ct(this.options));this.loadOptions=o;let c=Rt(o);this.coreApi=s||_r,this.hasCoreApi=!!s,this.fetch=c}setProps(e){let r=X(this.options,e),n=Pe(Ct(r));this.options=r,this.loadOptions=n,this.fetch=Rt(n),this.setNeedsRefresh()}setNeedsRefresh(){this._needsRefresh=!0}getNeedsRefresh(e=!0){let r=this._needsRefresh;return e&&(this._needsRefresh=!1),r}reportError(e,r){let n=Rr(e,r),s=this.options.core?.onError;return s?s(n,this):ct.warn(`${this.constructor.name}: ${n.message}`)(),n}};function Rt(t){return Tt(t)}function Ct(t){if(t.loadOptions!==void 0||t.core?.loadOptions!==void 0)throw new Error("Source loadOptions and core.loadOptions were removed. Use core and root loader namespaces directly.");let e={...t};if(t?.core){e.core={...t.core};let s=e.core;for(let o of["type","attributions","loaders","onError","loadOptions"])delete s[o];Object.keys(s).length===0&&delete e.core}let r=typeof e.baseUri=="string"?e.baseUri:void 0,n=typeof e.baseUrl=="string"?e.baseUrl:void 0;return(r!==void 0||n!==void 0)&&(e.core||={},e.core.baseUrl===void 0&&(e.core.baseUrl=n??r),delete e.baseUri,delete e.baseUrl),e}function Rr(t,e){return t instanceof Error?t:typeof t=="string"?new Error(t):new Error(e)}function F(t){return()=>{throw new Error(`CoreAPI.${t} is unavailable. Use @loaders.gl/core.createDataSource().`)}}function Me(t={}){if(t.coordinateEpoch!==void 0&&!Number.isFinite(t.coordinateEpoch))throw new Error("Spatial reference coordinate epoch must be a finite decimal year");return Object.freeze({crs:Bt(t.crs||{state:"absent",provenance:"unknown"}),vertical:t.vertical?Bt(t.vertical):void 0,coordinateEpoch:t.coordinateEpoch,coordinateFrame:t.coordinateFrame||"unknown",coordinateOrder:Object.freeze([...t.coordinateOrder||[]]),units:t.units?Object.freeze([...t.units]):void 0})}function Bt(t){return t.state==="explicit"||t.state==="default"?Object.freeze({...t,definition:Nt(t.definition),alternatives:t.alternatives?Object.freeze(t.alternatives.map(e=>Object.freeze({...e,definition:Nt(e.definition)}))):void 0}):Object.freeze({...t})}function Nt(t){return typeof t=="string"?t:qe(t)}function qe(t){return Array.isArray(t)?Object.freeze(t.map(e=>qe(e))):t&&typeof t=="object"?Object.freeze(Object.fromEntries(Object.entries(t).map(([e,r])=>[e,qe(r)]))):t}function We(t){Cr(t.queryType,t.execution);let e=Object.freeze({fields:Object.freeze(t.schema.fields.map(n=>Object.freeze({...n,metadata:Object.freeze({...n.metadata})}))),metadata:Object.freeze({...t.schema.metadata})}),r=e.fields.map(n=>Object.freeze({name:n.name,type:n.type,nullable:n.nullable!==!1,role:t.columnRoles?.[n.name]||"attribute",title:vt(n.metadata,"title"),description:vt(n.metadata,"description"),metadata:n.metadata||Object.freeze({})}));return Object.freeze({sourceType:t.sourceType,queryType:t.queryType,execution:Object.freeze({...t.execution}),name:t.name,description:t.description,schema:e,columns:Object.freeze(r),capabilities:Object.freeze({...t.capabilities}),spatial:t.spatial?Object.freeze({...t.spatial,bounds:t.spatial.bounds?Object.freeze({minimum:Object.freeze([...t.spatial.bounds.minimum]),maximum:Object.freeze([...t.spatial.bounds.maximum])}):void 0,coordinateReferenceSystems:t.spatial.coordinateReferenceSystems?Object.freeze([...t.spatial.coordinateReferenceSystems]):void 0,spatialReference:t.spatial.spatialReference?Me(t.spatial.spatialReference):void 0}):void 0,statistics:t.statistics?Object.freeze({...t.statistics}):void 0,levels:t.levels?Object.freeze(t.levels.map(n=>Object.freeze({...n,scale:n.scale?Object.freeze([...n.scale]):void 0}))):void 0})}function Cr(t,e){if(e.status==="metadata-only"){if(!e.reason.trim())throw new Error("Metadata-only scan support requires a concrete reason");return}if(!{table:["read","query"],raster:["getRaster"],"point-cloud":["scan"]}[t].includes(e.method))throw new Error(`Scan execution method "${e.method}" is not valid for ${t} queries`)}function vt(t,e){return t?.[e]||void 0}function ze(t){if(t.width!==void 0&&Lt(t.width,"width"),t.height!==void 0&&Lt(t.height,"height"),t.level!==void 0&&Ft(t.level,"level"),t.bounds)for(let e=0;e<2;e++){let r=t.bounds[0][e],n=t.bounds[1][e];if(!Number.isFinite(r)||!Number.isFinite(n)||r>n)throw new Error("Raster query bounds must contain finite, ordered coordinates.")}for(let e of t.channels||[])Ft(e,"channel");for(let[e,r]of Object.entries(t.slices||{})){if(!e)throw new Error("Raster query slice names must be non-empty.");if(Array.isArray(r)){if(r.length!==2||!r.every(Number.isFinite)||r[0]>r[1])throw new Error(`Raster query slice ${e} must be an ordered finite range.`)}else if(!Number.isFinite(r))throw new Error(`Raster query slice ${e} must be finite.`)}}function Lt(t,e){if(!Number.isSafeInteger(t)||t<1)throw new Error(`Raster query ${e} must be a positive safe integer.`)}function Ft(t,e){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Raster query ${e} must be a non-negative safe integer.`)}Ze();Ye();Ye();Ze();var Ur="5.0.0-beta.2",ne=class t extends z{static HEADER_RANGE_SIZE=64*1024;static MAX_HEADER_RANGE_SIZE=4*1024*1024;headerPromise=null;rasterQueryCapabilities=Object.freeze({bounds:"unsupported",level:"unsupported",variables:"pushdown",slices:"residual",streaming:!1,cancellation:!0});constructor(e,r={}){super(e,r)}async getQueryMetadata(e={}){A(e.signal);let{header:r,byteLength:n}=await this.getHeader(e.signal);A(e.signal);let o={fields:r.variables.map(c=>zr(c,r)),metadata:Vr(r)};return We({sourceType:"netcdf",queryType:"raster",execution:{status:"supported",method:"getRaster"},name:typeof this.data=="string"?this.data.split("/").pop():void 0,schema:o,capabilities:{bounds:"unsupported",levelOfDetail:"unsupported",raster:this.rasterQueryCapabilities},statistics:{byteLength:n,rowCount:r.recordDimension.length||void 0}})}async getRaster(e={}){ze(e),Or(e),A(e.signal);let r=await this.loadReader(e.signal);A(e.signal),jr(r.header,e.slices);let s=kr(r.header,e.variables).map(a=>{A(e.signal);let l=a.dimensions.map(b=>r.header.dimensions[b]?.name||`dimension_${b}`),f=a.dimensions.map(b=>Xe(r.header,b)),u=qt(r.getDataVariable(a)),g=$r(u,l,f,e.slices||{},e.signal),p=Ke(a.type);return{variable:a,dimensionNames:g.dimensionNames,shape:g.shape,data:qr(g.values,p),dtype:p}}),o=s[0];for(let a of s.slice(1))if(a.dtype!==o.dtype||!Wr(a.shape,o.shape))throw new Error("NetCDF raster variables must retain the same shape and numeric type after slicing.");let c=o.shape.at(-1)??1,d=o.shape.length<2?1:o.shape.slice(0,-1).reduce((a,l)=>a*l,1),h=Mr(o.variable);return{data:s.length===1?o.data:s.map(a=>a.data),width:c,height:d,bandCount:s.length,dtype:o.dtype,interleaved:!1,noData:h,metadata:{variables:s.map(a=>a.variable.name),dimensions:o.dimensionNames,shape:o.shape,slices:{...e.slices}}}}async loadReader(e){let r;if(typeof this.data=="string"){let n=await this.fetch(this.url,{signal:e});if(!n.ok)throw new Error(`NetCDF request failed with status ${n.status}.`);r=await n.arrayBuffer()}else r=await this.data.arrayBuffer();return A(e),new S(r)}async getHeader(e){A(e),this.headerPromise||(this.headerPromise=this.loadHeader().catch(n=>{throw this.headerPromise=null,n}));let r=await this.headerPromise;return A(e),r}async loadHeader(){if(typeof this.data!="string"){let o=await this.data.arrayBuffer();return{header:new S(o).header,byteLength:o.byteLength}}let e=t.HEADER_RANGE_SIZE,r=null,n=null,s;for(;e<=t.MAX_HEADER_RANGE_SIZE;){if(r=await this.fetch(this.url,{headers:{Range:`bytes=0-${e-1}`}}),!r.ok)throw new Error(`NetCDF request failed with status ${r.status}.`);n=await r.arrayBuffer();let o=Gr(r,n.byteLength);try{return{header:new S(n).header,byteLength:o}}catch(c){if(s=c,r.status!==206||n.byteLength<e)throw c;e*=2}}throw s||new Error("NetCDF header exceeds the maximum metadata range.")}},se={dataType:null,batchType:null,...G,module:"scientific",name:"NetCDFSourceLoader",version:Ur,type:"netcdf-source",fromUrl:!0,fromBlob:!0,options:{},defaultOptions:{},testURL:t=>/\.(?:cdf|nc)(?:$|[?#])/i.test(t),createDataSource:(t,e)=>new ne(t,e)};function Pr(t){switch(t.toLowerCase()){case"byte":return"int8";case"ubyte":return"uint8";case"short":return"int16";case"ushort":return"uint16";case"int":return"int32";case"uint":return"uint32";case"int64":return"int64";case"uint64":return"uint64";case"float":return"float32";case"double":return"float64";case"char":case"string":return"utf8";default:return"binary"}}function Or(t){if(t.bounds)throw new Error("NetCDF raster bounds are not supported.");if(t.level!==void 0)throw new Error("NetCDF raster levels are not supported.");if(t.width!==void 0||t.height!==void 0)throw new Error("NetCDF raster resampling is not supported.");if(t.channels?.length)throw new Error("NetCDF uses named variables instead of numeric channels.")}function kr(t,e){let r=t.variables.find(s=>s.dimensions.length>0&&Hr(s.type)),n=e?.length?[...e]:r?[r.name]:[];if(n.length===0)throw new Error("NetCDF contains no numeric variables that can be read as raster data.");if(new Set(n).size!==n.length)throw new Error("NetCDF raster variables must not contain duplicates.");return n.map(s=>{let o=t.variables.find(c=>c.name===s);if(!o)throw new Error(`NetCDF variable not found: ${s}`);return Ke(o.type),o})}function jr(t,e){let r=new Set(t.dimensions.map(n=>n.name));for(let n of Object.keys(e||{}))if(!r.has(n))throw new Error(`NetCDF dimension not found: ${n}`)}function $r(t,e,r,n,s){let o=e.map((a,l)=>{let f=r[l],u=n[a];if(u===void 0)return{start:0,stop:f,remove:!1};if(typeof u!="number"){let[g,p]=u;if(!Number.isSafeInteger(g)||!Number.isSafeInteger(p)||g<0||p<g||p>f)throw new Error(`NetCDF slice ${a} must be a valid half-open range within 0..${f}.`);return{start:g,stop:p,remove:!1}}if(!Number.isSafeInteger(u)||u<0||u>=f)throw new Error(`NetCDF slice ${a} must be an index within 0..${f-1}.`);return{start:u,stop:u+1,remove:!0}}),c=r.map((a,l)=>r.slice(l+1).reduce((f,u)=>f*u,1)),d=[],h=(a,l)=>{if(A(s),a===o.length){let u=t[l];if(typeof u!="number")throw new Error("NetCDF raster variables must contain numeric values.");d.push(u);return}let f=o[a];for(let u=f.start;u<f.stop;u++)h(a+1,l+u*c[a])};return h(0,0),{values:d,dimensionNames:e.filter((a,l)=>!o[l].remove),shape:o.map(a=>a.stop-a.start).filter((a,l)=>!o[l].remove)}}function qt(t){return Array.isArray(t)?t.flatMap(qt):ArrayBuffer.isView(t)?Array.from(t):[t]}function Hr(t){try{return Ke(t),!0}catch{return!1}}function Ke(t){switch(t.toLowerCase()){case"byte":return"int8";case"ubyte":return"uint8";case"short":return"int16";case"ushort":return"uint16";case"int":return"int32";case"uint":return"uint32";case"float":return"float32";case"double":return"float64";default:throw new Error(`NetCDF variable type is not supported as raster data: ${t}`)}}function qr(t,e){switch(e){case"int8":return Int8Array.from(t);case"uint8":return Uint8Array.from(t);case"int16":return Int16Array.from(t);case"uint16":return Uint16Array.from(t);case"int32":return Int32Array.from(t);case"uint32":return Uint32Array.from(t);case"float32":return Float32Array.from(t);case"float64":return Float64Array.from(t)}}function Mr(t){let e=t.attributes.find(n=>n.name==="_FillValue"||n.name==="missing_value"),r=Number(e?.value);return e&&Number.isFinite(r)?r:null}function Wr(t,e){return t.length===e.length&&t.every((r,n)=>r===e[n])}function zr(t,e){let n={dimensions:t.dimensions.map(s=>e.dimensions[s]).filter(Boolean).map((s,o)=>`${s.name}[${Xe(e,t.dimensions[o])}]`).join(",")};for(let s of t.attributes)n[s.name]=String(s.value);return{name:t.name,type:Pr(t.type),nullable:!0,metadata:n}}function Vr(t){let e={};for(let[r,n]of t.dimensions.entries())e[`dimension:${n.name}`]=String(Xe(t,r));return e}function Xe(t,e){let r=t.dimensions[e];return e===t.recordDimension.id?t.recordDimension.length:r?.size||0}function Gr(t,e){let n=t.headers.get("content-range")?.match(/\/([0-9]+)$/)?.[1];return Number(n||t.headers.get("content-length")||e)}function A(t){if(t?.aborted)throw new DOMException("The operation was aborted","AbortError")}return Kt(Qr);})();
10
+ `)}}e.length>0&&(yield e)}async function*Le(t){let e=1;for await(let r of t)yield{counter:e,line:r},e++}async function Fe(t,e){let r=dr(t);for(;;){let{done:n,value:s}=await r.next();if(n){r.return&&r.return();return}if(e(s))return}}async function De(t){let e=[];for await(let r of t)e.push(lr(r));return pt(...e)}function lr(t){if(t instanceof ArrayBuffer)return t;if(ArrayBuffer.isView(t)){let{buffer:e,byteOffset:r,byteLength:n}=t;return gt(e,r,n)}return gt(t)}function gt(t,e=0,r=t.byteLength-e){let n=new Uint8Array(t,e,r),s=new Uint8Array(n.length);return s.set(n),s.buffer}function dr(t){if(typeof t[Symbol.asyncIterator]=="function")return t[Symbol.asyncIterator]();if(typeof t[Symbol.iterator]=="function"){let e=t[Symbol.iterator]();return hr(e)}return t}function hr(t){return{next(e){return Promise.resolve(t.next(e))},return(e){return typeof t.return=="function"?Promise.resolve(t.return(e)):Promise.resolve({done:!0,value:e})},throw(e){return typeof t.throw=="function"?Promise.resolve(t.throw(e)):Promise.reject(e)}}}function M(){let t;if(typeof window<"u"&&window.performance)t=window.performance.now();else if(typeof process<"u"&&process.hrtime){let e=process.hrtime();t=e[0]*1e3+e[1]/1e6}else t=Date.now();return t}var L=class{constructor(e,r){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=e,this.type=r,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=M(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(M()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}};var P=class{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,r="count"){return this._getOrCreate({name:e,type:r})}get size(){return Object.keys(this.stats).length}reset(){for(let e of Object.values(this.stats))e.reset();return this}forEach(e){for(let r of Object.values(this.stats))e(r)}getTable(){let e={};return this.forEach(r=>{e[r.name]={time:r.time||0,count:r.count||0,average:r.getAverageTime()||0,hz:r.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(r=>this._getOrCreate(r))}_getOrCreate(e){let{name:r,type:n}=e,s=this.stats[r];return s||(e instanceof L?s=e:s=new L(r,n),this.stats[r]=s),s}};var mr="Queued Requests",pr="Active Requests",gr="Cancelled Requests",yr="Queued Requests Ever",br="Active Requests Ever",wr={id:"request-scheduler",throttleRequests:!0,maxRequests:6,debounceTime:0},O=class{props;stats;activeRequestCount=0;requestQueue=[];requestMap=new Map;updateTimer=null;constructor(e={}){this.props={...wr,...e},this.stats=new P({id:this.props.id}),this.stats.get(mr),this.stats.get(pr),this.stats.get(gr),this.stats.get(yr),this.stats.get(br)}setProps(e){e.throttleRequests!==void 0&&(this.props.throttleRequests=e.throttleRequests),e.maxRequests!==void 0&&(this.props.maxRequests=e.maxRequests),e.debounceTime!==void 0&&(this.props.debounceTime=e.debounceTime)}scheduleRequest(e,r=()=>0){if(!this.props.throttleRequests)return Promise.resolve({done:()=>{}});if(this.requestMap.has(e))return this.requestMap.get(e);let n={handle:e,priority:0,getPriority:r},s=new Promise(o=>(n.resolve=o,n));return this.requestQueue.push(n),this.requestMap.set(e,s),this._issueNewRequests(),s}_issueRequest(e){let{handle:r,resolve:n}=e,s=!1,o=()=>{s||(s=!0,this.requestMap.delete(r),this.activeRequestCount--,this.scheduleRefill())};return this.activeRequestCount++,n?n({done:o}):Promise.resolve({done:o})}scheduleRefill(){this.updateTimer===null&&(this.updateTimer=setTimeout(()=>this._issueNewRequestsAsync(),0))}_issueNewRequests(){this.updateTimer!==null&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>this._issueNewRequestsAsync(),this.props.debounceTime)}_issueNewRequestsAsync(){this.updateTimer!==null&&clearTimeout(this.updateTimer),this.updateTimer=null;let e=Math.max(this.props.maxRequests-this.activeRequestCount,0);if(e!==0){this._updateAllRequests();for(let r=0;r<e;++r){let n=this.requestQueue.shift();n&&this._issueRequest(n)}}}_updateAllRequests(){let e=this.requestQueue;for(let r=0;r<e.length;++r){let n=e[r];this._updateRequest(n)||(e.splice(r,1),this.requestMap.delete(n.handle),r--)}e.sort((r,n)=>r.priority-n.priority)}_updateRequest(e){return e.priority=e.getPriority(e.handle),e.priority<0?(e.resolve(null),!1):!0}};function Ue(t,e=[]){return t.every(Ie)?t:t.map((r,n)=>{if(Ie(r))return r;let s=e.find(c=>c.type===r?.type);if(!s)throw new Error(`No authentication class registered for credential at index ${n}.`);let o;try{o=new s(r)}catch{throw new Error(`Invalid authentication configuration at index ${n}.`)}if(!Ie(o))throw new Error(`Authentication class returned an invalid credential at index ${n}.`);return o})}function Pe(t){if(!t.core?.credentials?.length)return t;let e=Ue(t.core.credentials,t.core.authentications);return e===t.core.credentials?t:{...t,core:{...t.core,credentials:e}}}function Ie(t){return!t||typeof t!="object"||typeof t.id!="string"||!Array.isArray(t.origins)?!1:t.type==="request"?typeof t.authenticate=="function":(t.type==="header"||t.type==="query-parameter")&&typeof t.name=="string"&&(typeof t.token=="string"||typeof t.token=="function")&&Array.isArray(t.refreshStatusCodes)}var yt=Symbol("loaders.gl.authenticated-fetch"),Oe=new WeakMap;function xr(t){let e=t.fetch||((f,u)=>fetch(f,u)),r=e[yt],n=new Map(r?.credentialResolutions),s=Ue(t.credentials.map(f=>n.get(f)||f),t.authentications);if(t.credentials.forEach((f,u)=>{n.set(f,s[u])}),!t.fetchOptions&&(!s.length||r?.credentials.length===s.length&&s.every((f,u)=>f===r.credentials[u])))return e;let o=r?.fetch||e,c=r?[...new Set([...s,...r.credentials])]:s,d=bt(r?.fetchOptions||{},t.fetchOptions),h=c.filter(f=>f.type!=="request"),a=c.filter(f=>f.type==="request");for(let f of a)St(f.origins);let l=async(f,u={})=>{if(u=bt(d,u),u.signal?.throwIfAborted(),!c.length)return o(f,u);let g=Sr(f),p=g?await xt(g,u,h):{url:f,options:u,credentials:[]},b=await wt(p,a,"request"),w=await o(b.url,b.options),oe=[];for(let N of p.credentials){let{credential:_}=N;typeof _.token=="function"&&(ee(u)||_.canReplayRequest?.(f,u))&&(ee(b.options)||_.canReplayRequest?.(b.url,b.options))&&(_.refreshStatusCodes.includes(w.status)||await _.shouldRefresh?.(w))&&oe.push(N)}let et=ee(u)&&ee(b.options)&&b.credentials.some(N=>N.refreshStatusCodes?.includes(w.status));if(!oe.length&&!et)return w;u.signal?.throwIfAborted();let ie=new Map;if(await Promise.all(oe.map(async({credential:N})=>{let _=await Tr(N,f,w);_&&ie.set(N,_)})),!ie.size&&!et)return w;await w.body?.cancel().catch(()=>{}),u.signal?.throwIfAborted();let Mt=g?await xt(g,u,h,ie,p.credentials):{url:f,options:u},tt=await wt(Mt,a,"retry",w);return o(tt.url,tt.options)};return Object.defineProperty(l,yt,{value:{fetch:o,credentials:c,credentialResolutions:n,fetchOptions:d}}),l}function Tt(t={}){let e=t.fetch??t.core?.fetch,r;typeof e=="function"?r=e:r=(s,o)=>fetch(s,o);let n=typeof e=="object"&&e?e:void 0;return xr({fetch:r,fetchOptions:t.signal?{...n,signal:t.signal}:n,credentials:t.core?.credentials||[],authentications:t.core?.authentications})}function bt(t,e){let r={...t,...e};if(t.headers||e?.headers){let n=new Headers(t.headers);new Headers(e?.headers).forEach((s,o)=>n.set(o,s)),r.headers=n}return r}async function wt(t,e,r,n){let s=[],o=t.options.signal;for(let c of e){let d=Et(t.url);if(!d||!St(c.origins).includes(d))continue;o?.throwIfAborted();let h=await c.authenticate({url:t.url,options:{...t.options,headers:new Headers(t.options.headers)},reason:r,response:n?{status:n.status,headers:new Headers(n.headers)}:void 0});if(!h||typeof h.url!="string"||!h.options||typeof h.options!="object")throw new Error("Authentication callback returned an invalid request.");t={url:h.url,options:{...h.options,...o?{signal:o}:{}}},s.push(c)}return o?.throwIfAborted(),{...t,credentials:s}}function Et(t){try{let e=new URL(t);return!e.host||e.username||e.password?null:e.origin!=="null"?e.origin:`${e.protocol}//${e.host}`}catch{return null}}function St(t){if(!t.length)throw new Error("Request authentication requires at least one exact origin.");return t.map(e=>{let r=Et(e),n;try{n=new URL(e)}catch{throw new Error("Invalid request authentication origin.")}if(!r||n.pathname&&n.pathname!=="/"||n.search||n.hash)throw new Error("Invalid request authentication origin.");return r})}async function xt(t,e,r,n=new Map,s=[]){let o=new URL(t),c=new Headers(e.headers),d=[],h=new Map(s.map(({credential:a,token:l})=>[a,l]));for(let a of r){if(!a.origins.includes(o.origin))continue;let l=n.get(a),f=h.get(a),u=a.type==="query-parameter"&&f!==void 0,g=a.type==="header"&&f!==void 0;if(a.type==="query-parameter"&&o.searchParams.has(a.name)&&!u||a.type==="header"&&c.has(a.name)&&!g)continue;let p=l??f??await Er(a.token,{url:t.toString(),reason:"request"});p&&(a.type==="query-parameter"?o.searchParams.set(a.name,p):c.set(a.name,`${a.prefix||""}${p}`),d.push({credential:a,token:p}))}return{url:o.toString(),options:{...e,headers:c},credentials:d}}async function Tr(t,e,r){let n=Oe.get(t);if(n)return n;let s=t.token,o=Promise.resolve(s({url:e,reason:"refresh",response:{status:r.status,headers:r.headers}})).finally(()=>Oe.delete(t));return Oe.set(t,o),o}async function Er(t,e){return typeof t=="function"?t(e):t}function Sr(t){try{let e=new URL(t);return["http:","https:"].includes(e.protocol)?e:null}catch{return null}}function ee(t){let e=(t.method||"GET").toUpperCase();return["GET","HEAD","OPTIONS","PUT","DELETE"].includes(e)?!(t.body&&typeof ReadableStream<"u"&&t.body instanceof ReadableStream):!1}var ke="",At={};function je(t){ke=t}function $e(){return ke}function W(t){for(let e in At)if(t.startsWith(e)){let r=At[e];t=t.replace(e,r)}return!t.startsWith("http://")&&!t.startsWith("https://")&&(t=`${ke}${t}`),t}var Ar="5.0.0-beta.4",He={dataType:null,batchType:null,name:"JSON",id:"json",module:"json",version:Ar,encoding:"json",format:"json",extensions:["json","geojson"],mimeTypes:["application/json"],category:"json",text:!0,parseTextSync:_t,parse:async t=>_t(new TextDecoder().decode(t)),options:{}};function _t(t){return JSON.parse(t)}var _r={fetchFile:F("fetchFile"),parse:F("parse"),parseFile:F("parseFile"),parseSync:F("parseSync"),parseInBatches:F("parseInBatches"),load:F("load"),loadInBatches:F("loadInBatches")},z=class t{static defaultOptions={core:{type:"auto",attributions:[],loaders:[],onError:void 0}};optionsType;options;data;url;loadOptions;fetch;coreApi;hasCoreApi;_needsRefresh=!0;constructor(e,r,n,s){this.options=X(X(t.defaultOptions,n||{}),r),this.data=e,this.url=typeof e=="string"?W(e):"";let o=Pe(Ct(this.options));this.loadOptions=o;let c=Rt(o);this.coreApi=s||_r,this.hasCoreApi=!!s,this.fetch=c}setProps(e){let r=X(this.options,e),n=Pe(Ct(r));this.options=r,this.loadOptions=n,this.fetch=Rt(n),this.setNeedsRefresh()}setNeedsRefresh(){this._needsRefresh=!0}getNeedsRefresh(e=!0){let r=this._needsRefresh;return e&&(this._needsRefresh=!1),r}reportError(e,r){let n=Rr(e,r),s=this.options.core?.onError;return s?s(n,this):ct.warn(`${this.constructor.name}: ${n.message}`)(),n}};function Rt(t){return Tt(t)}function Ct(t){if(t.loadOptions!==void 0||t.core?.loadOptions!==void 0)throw new Error("Source loadOptions and core.loadOptions were removed. Use core and root loader namespaces directly.");let e={...t};if(t?.core){e.core={...t.core};let s=e.core;for(let o of["type","attributions","loaders","onError","loadOptions"])delete s[o];Object.keys(s).length===0&&delete e.core}let r=typeof e.baseUri=="string"?e.baseUri:void 0,n=typeof e.baseUrl=="string"?e.baseUrl:void 0;return(r!==void 0||n!==void 0)&&(e.core||={},e.core.baseUrl===void 0&&(e.core.baseUrl=n??r),delete e.baseUri,delete e.baseUrl),e}function Rr(t,e){return t instanceof Error?t:typeof t=="string"?new Error(t):new Error(e)}function F(t){return()=>{throw new Error(`CoreAPI.${t} is unavailable. Use @loaders.gl/core.createDataSource().`)}}function Me(t={}){if(t.coordinateEpoch!==void 0&&!Number.isFinite(t.coordinateEpoch))throw new Error("Spatial reference coordinate epoch must be a finite decimal year");return Object.freeze({crs:Bt(t.crs||{state:"absent",provenance:"unknown"}),vertical:t.vertical?Bt(t.vertical):void 0,coordinateEpoch:t.coordinateEpoch,coordinateFrame:t.coordinateFrame||"unknown",coordinateOrder:Object.freeze([...t.coordinateOrder||[]]),units:t.units?Object.freeze([...t.units]):void 0})}function Bt(t){return t.state==="explicit"||t.state==="default"?Object.freeze({...t,definition:Nt(t.definition),alternatives:t.alternatives?Object.freeze(t.alternatives.map(e=>Object.freeze({...e,definition:Nt(e.definition)}))):void 0}):Object.freeze({...t})}function Nt(t){return typeof t=="string"?t:qe(t)}function qe(t){return Array.isArray(t)?Object.freeze(t.map(e=>qe(e))):t&&typeof t=="object"?Object.freeze(Object.fromEntries(Object.entries(t).map(([e,r])=>[e,qe(r)]))):t}function We(t){Cr(t.queryType,t.execution);let e=Object.freeze({fields:Object.freeze(t.schema.fields.map(n=>Object.freeze({...n,metadata:Object.freeze({...n.metadata})}))),metadata:Object.freeze({...t.schema.metadata})}),r=e.fields.map(n=>Object.freeze({name:n.name,type:n.type,nullable:n.nullable!==!1,role:t.columnRoles?.[n.name]||"attribute",title:vt(n.metadata,"title"),description:vt(n.metadata,"description"),metadata:n.metadata||Object.freeze({})}));return Object.freeze({sourceType:t.sourceType,queryType:t.queryType,execution:Object.freeze({...t.execution}),name:t.name,description:t.description,schema:e,columns:Object.freeze(r),capabilities:Object.freeze({...t.capabilities}),spatial:t.spatial?Object.freeze({...t.spatial,bounds:t.spatial.bounds?Object.freeze({minimum:Object.freeze([...t.spatial.bounds.minimum]),maximum:Object.freeze([...t.spatial.bounds.maximum])}):void 0,coordinateReferenceSystems:t.spatial.coordinateReferenceSystems?Object.freeze([...t.spatial.coordinateReferenceSystems]):void 0,spatialReference:t.spatial.spatialReference?Me(t.spatial.spatialReference):void 0}):void 0,statistics:t.statistics?Object.freeze({...t.statistics}):void 0,levels:t.levels?Object.freeze(t.levels.map(n=>Object.freeze({...n,scale:n.scale?Object.freeze([...n.scale]):void 0}))):void 0})}function Cr(t,e){if(e.status==="metadata-only"){if(!e.reason.trim())throw new Error("Metadata-only scan support requires a concrete reason");return}if(!{table:["read","query"],raster:["getRaster"],"point-cloud":["scan"]}[t].includes(e.method))throw new Error(`Scan execution method "${e.method}" is not valid for ${t} queries`)}function vt(t,e){return t?.[e]||void 0}function ze(t){if(t.width!==void 0&&Lt(t.width,"width"),t.height!==void 0&&Lt(t.height,"height"),t.level!==void 0&&Ft(t.level,"level"),t.bounds)for(let e=0;e<2;e++){let r=t.bounds[0][e],n=t.bounds[1][e];if(!Number.isFinite(r)||!Number.isFinite(n)||r>n)throw new Error("Raster query bounds must contain finite, ordered coordinates.")}for(let e of t.channels||[])Ft(e,"channel");for(let[e,r]of Object.entries(t.slices||{})){if(!e)throw new Error("Raster query slice names must be non-empty.");if(Array.isArray(r)){if(r.length!==2||!r.every(Number.isFinite)||r[0]>r[1])throw new Error(`Raster query slice ${e} must be an ordered finite range.`)}else if(!Number.isFinite(r))throw new Error(`Raster query slice ${e} must be finite.`)}}function Lt(t,e){if(!Number.isSafeInteger(t)||t<1)throw new Error(`Raster query ${e} must be a positive safe integer.`)}function Ft(t,e){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Raster query ${e} must be a non-negative safe integer.`)}Ze();Ye();Ye();Ze();var Ur="5.0.0-beta.4",ne=class t extends z{static HEADER_RANGE_SIZE=64*1024;static MAX_HEADER_RANGE_SIZE=4*1024*1024;headerPromise=null;rasterQueryCapabilities=Object.freeze({bounds:"unsupported",level:"unsupported",variables:"pushdown",slices:"residual",streaming:!1,cancellation:!0});constructor(e,r={}){super(e,r)}async getQueryMetadata(e={}){A(e.signal);let{header:r,byteLength:n}=await this.getHeader(e.signal);A(e.signal);let o={fields:r.variables.map(c=>zr(c,r)),metadata:Vr(r)};return We({sourceType:"netcdf",queryType:"raster",execution:{status:"supported",method:"getRaster"},name:typeof this.data=="string"?this.data.split("/").pop():void 0,schema:o,capabilities:{bounds:"unsupported",levelOfDetail:"unsupported",raster:this.rasterQueryCapabilities},statistics:{byteLength:n,rowCount:r.recordDimension.length||void 0}})}async getRaster(e={}){ze(e),Or(e),A(e.signal);let r=await this.loadReader(e.signal);A(e.signal),jr(r.header,e.slices);let s=kr(r.header,e.variables).map(a=>{A(e.signal);let l=a.dimensions.map(b=>r.header.dimensions[b]?.name||`dimension_${b}`),f=a.dimensions.map(b=>Xe(r.header,b)),u=qt(r.getDataVariable(a)),g=$r(u,l,f,e.slices||{},e.signal),p=Ke(a.type);return{variable:a,dimensionNames:g.dimensionNames,shape:g.shape,data:qr(g.values,p),dtype:p}}),o=s[0];for(let a of s.slice(1))if(a.dtype!==o.dtype||!Wr(a.shape,o.shape))throw new Error("NetCDF raster variables must retain the same shape and numeric type after slicing.");let c=o.shape.at(-1)??1,d=o.shape.length<2?1:o.shape.slice(0,-1).reduce((a,l)=>a*l,1),h=Mr(o.variable);return{data:s.length===1?o.data:s.map(a=>a.data),width:c,height:d,bandCount:s.length,dtype:o.dtype,interleaved:!1,noData:h,metadata:{variables:s.map(a=>a.variable.name),dimensions:o.dimensionNames,shape:o.shape,slices:{...e.slices}}}}async loadReader(e){let r;if(typeof this.data=="string"){let n=await this.fetch(this.url,{signal:e});if(!n.ok)throw new Error(`NetCDF request failed with status ${n.status}.`);r=await n.arrayBuffer()}else r=await this.data.arrayBuffer();return A(e),new S(r)}async getHeader(e){A(e),this.headerPromise||(this.headerPromise=this.loadHeader().catch(n=>{throw this.headerPromise=null,n}));let r=await this.headerPromise;return A(e),r}async loadHeader(){if(typeof this.data!="string"){let o=await this.data.arrayBuffer();return{header:new S(o).header,byteLength:o.byteLength}}let e=t.HEADER_RANGE_SIZE,r=null,n=null,s;for(;e<=t.MAX_HEADER_RANGE_SIZE;){if(r=await this.fetch(this.url,{headers:{Range:`bytes=0-${e-1}`}}),!r.ok)throw new Error(`NetCDF request failed with status ${r.status}.`);n=await r.arrayBuffer();let o=Gr(r,n.byteLength);try{return{header:new S(n).header,byteLength:o}}catch(c){if(s=c,r.status!==206||n.byteLength<e)throw c;e*=2}}throw s||new Error("NetCDF header exceeds the maximum metadata range.")}},se={dataType:null,batchType:null,...G,module:"scientific",name:"NetCDFSourceLoader",version:Ur,type:"netcdf-source",fromUrl:!0,fromBlob:!0,options:{},defaultOptions:{},testURL:t=>/\.(?:cdf|nc)(?:$|[?#])/i.test(t),createDataSource:(t,e)=>new ne(t,e)};function Pr(t){switch(t.toLowerCase()){case"byte":return"int8";case"ubyte":return"uint8";case"short":return"int16";case"ushort":return"uint16";case"int":return"int32";case"uint":return"uint32";case"int64":return"int64";case"uint64":return"uint64";case"float":return"float32";case"double":return"float64";case"char":case"string":return"utf8";default:return"binary"}}function Or(t){if(t.bounds)throw new Error("NetCDF raster bounds are not supported.");if(t.level!==void 0)throw new Error("NetCDF raster levels are not supported.");if(t.width!==void 0||t.height!==void 0)throw new Error("NetCDF raster resampling is not supported.");if(t.channels?.length)throw new Error("NetCDF uses named variables instead of numeric channels.")}function kr(t,e){let r=t.variables.find(s=>s.dimensions.length>0&&Hr(s.type)),n=e?.length?[...e]:r?[r.name]:[];if(n.length===0)throw new Error("NetCDF contains no numeric variables that can be read as raster data.");if(new Set(n).size!==n.length)throw new Error("NetCDF raster variables must not contain duplicates.");return n.map(s=>{let o=t.variables.find(c=>c.name===s);if(!o)throw new Error(`NetCDF variable not found: ${s}`);return Ke(o.type),o})}function jr(t,e){let r=new Set(t.dimensions.map(n=>n.name));for(let n of Object.keys(e||{}))if(!r.has(n))throw new Error(`NetCDF dimension not found: ${n}`)}function $r(t,e,r,n,s){let o=e.map((a,l)=>{let f=r[l],u=n[a];if(u===void 0)return{start:0,stop:f,remove:!1};if(typeof u!="number"){let[g,p]=u;if(!Number.isSafeInteger(g)||!Number.isSafeInteger(p)||g<0||p<g||p>f)throw new Error(`NetCDF slice ${a} must be a valid half-open range within 0..${f}.`);return{start:g,stop:p,remove:!1}}if(!Number.isSafeInteger(u)||u<0||u>=f)throw new Error(`NetCDF slice ${a} must be an index within 0..${f-1}.`);return{start:u,stop:u+1,remove:!0}}),c=r.map((a,l)=>r.slice(l+1).reduce((f,u)=>f*u,1)),d=[],h=(a,l)=>{if(A(s),a===o.length){let u=t[l];if(typeof u!="number")throw new Error("NetCDF raster variables must contain numeric values.");d.push(u);return}let f=o[a];for(let u=f.start;u<f.stop;u++)h(a+1,l+u*c[a])};return h(0,0),{values:d,dimensionNames:e.filter((a,l)=>!o[l].remove),shape:o.map(a=>a.stop-a.start).filter((a,l)=>!o[l].remove)}}function qt(t){return Array.isArray(t)?t.flatMap(qt):ArrayBuffer.isView(t)?Array.from(t):[t]}function Hr(t){try{return Ke(t),!0}catch{return!1}}function Ke(t){switch(t.toLowerCase()){case"byte":return"int8";case"ubyte":return"uint8";case"short":return"int16";case"ushort":return"uint16";case"int":return"int32";case"uint":return"uint32";case"float":return"float32";case"double":return"float64";default:throw new Error(`NetCDF variable type is not supported as raster data: ${t}`)}}function qr(t,e){switch(e){case"int8":return Int8Array.from(t);case"uint8":return Uint8Array.from(t);case"int16":return Int16Array.from(t);case"uint16":return Uint16Array.from(t);case"int32":return Int32Array.from(t);case"uint32":return Uint32Array.from(t);case"float32":return Float32Array.from(t);case"float64":return Float64Array.from(t)}}function Mr(t){let e=t.attributes.find(n=>n.name==="_FillValue"||n.name==="missing_value"),r=Number(e?.value);return e&&Number.isFinite(r)?r:null}function Wr(t,e){return t.length===e.length&&t.every((r,n)=>r===e[n])}function zr(t,e){let n={dimensions:t.dimensions.map(s=>e.dimensions[s]).filter(Boolean).map((s,o)=>`${s.name}[${Xe(e,t.dimensions[o])}]`).join(",")};for(let s of t.attributes)n[s.name]=String(s.value);return{name:t.name,type:Pr(t.type),nullable:!0,metadata:n}}function Vr(t){let e={};for(let[r,n]of t.dimensions.entries())e[`dimension:${n.name}`]=String(Xe(t,r));return e}function Xe(t,e){let r=t.dimensions[e];return e===t.recordDimension.id?t.recordDimension.length:r?.size||0}function Gr(t,e){let n=t.headers.get("content-range")?.match(/\/([0-9]+)$/)?.[1];return Number(n||t.headers.get("content-length")||e)}function A(t){if(t?.aborted)throw new DOMException("The operation was aborted","AbortError")}return Kt(Qr);})();
11
11
  return __exports__;
12
12
  });
@@ -48,7 +48,7 @@ var NPYFormat = {
48
48
  };
49
49
 
50
50
  // dist/npy-loader-types.js
51
- var VERSION = true ? "5.0.0-beta.2" : "latest";
51
+ var VERSION = true ? "5.0.0-beta.4" : "latest";
52
52
  var NPY_MAGIC_NUMBER = new Uint8Array([147, 78, 85, 77, 80, 89]);
53
53
  async function preload() {
54
54
  const { NPYLoaderWithParser } = await import("@loaders.gl/scientific/npy-loader");
@@ -3,7 +3,7 @@
3
3
  // Copyright (c) vis.gl contributors
4
4
  import { NPYFormat } from "./npy-format.js";
5
5
  // @ts-ignore __VERSION__ is injected by the package build.
6
- const VERSION = typeof "5.0.0-beta.2" !== 'undefined' ? "5.0.0-beta.2" : 'latest';
6
+ const VERSION = typeof "5.0.0-beta.4" !== 'undefined' ? "5.0.0-beta.4" : 'latest';
7
7
  // \x93NUMPY
8
8
  const NPY_MAGIC_NUMBER = new Uint8Array([147, 78, 85, 77, 80, 89]);
9
9
  /** Preloads the parser-bearing NPY loader implementation. */
@@ -239,7 +239,7 @@ var NPYFormat = {
239
239
  };
240
240
 
241
241
  // dist/npy-loader-types.js
242
- var VERSION2 = true ? "5.0.0-beta.2" : "latest";
242
+ var VERSION2 = true ? "5.0.0-beta.4" : "latest";
243
243
  var NPY_MAGIC_NUMBER2 = new Uint8Array([147, 78, 85, 77, 80, 89]);
244
244
  async function preload2() {
245
245
  const { NPYLoaderWithParser: NPYLoaderWithParser3 } = await Promise.resolve().then(() => (init_npy_loader(), npy_loader_exports));