@oceanum/datamesh 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -28,4 +28,25 @@ const data = await datamesh.query(query);
28
28
  ```
29
29
 
30
30
  [!WARNING]
31
- DO NOT put your Datamesh token directly into browser code. For use in an SPA, you should forward your Datamesh request through a reverse proxy to conceal your token. Read the [library documentation](https://oceanum-js.oceanum.io/datamesh) to learn more.
31
+ DO NOT put your Datamesh token directly into browser code. For use in an SPA, you should forward your Datamesh request through a reverse proxy to conceal your token.
32
+
33
+ ## Using a Datamesh Proxy
34
+
35
+ If you are building a browser application, we recommend using a reverse proxy to keep your Datamesh token secret and to simplify CORS. This package includes an example Cloudflare Worker you can deploy quickly and configure the `Connector` to use.
36
+
37
+ - See the [proxy guide](./proxy/guide.md) for more information.
38
+
39
+ Quick setup:
40
+
41
+ ```ts
42
+ import { Connector } from "@oceanum/datamesh";
43
+
44
+ const PROXY_URL = "https://your-proxy.workers.dev"; // or your own domain
45
+
46
+ const datamesh = new Connector("proxy", {
47
+ service: PROXY_URL,
48
+ gateway: PROXY_URL,
49
+ });
50
+ ```
51
+
52
+ Deploy the example Worker at `proxy/cloudflare/index.js` and add a secret `DATAMESH_TOKEN` with your Datamesh token in the Worker settings.
package/dist/README.md CHANGED
@@ -28,4 +28,25 @@ const data = await datamesh.query(query);
28
28
  ```
29
29
 
30
30
  [!WARNING]
31
- DO NOT put your Datamesh token directly into browser code. For use in an SPA, you should forward your Datamesh request through a reverse proxy to conceal your token. Read the [library documentation](https://oceanum-js.oceanum.io/datamesh) to learn more.
31
+ DO NOT put your Datamesh token directly into browser code. For use in an SPA, you should forward your Datamesh request through a reverse proxy to conceal your token.
32
+
33
+ ## Using a Datamesh Proxy
34
+
35
+ If you are building a browser application, we recommend using a reverse proxy to keep your Datamesh token secret and to simplify CORS. This package includes an example Cloudflare Worker you can deploy quickly and configure the `Connector` to use.
36
+
37
+ - See the [proxy guide](./proxy/guide.md) for more information.
38
+
39
+ Quick setup:
40
+
41
+ ```ts
42
+ import { Connector } from "@oceanum/datamesh";
43
+
44
+ const PROXY_URL = "https://your-proxy.workers.dev"; // or your own domain
45
+
46
+ const datamesh = new Connector("proxy", {
47
+ service: PROXY_URL,
48
+ gateway: PROXY_URL,
49
+ });
50
+ ```
51
+
52
+ Deploy the example Worker at `proxy/cloudflare/index.js` and add a secret `DATAMESH_TOKEN` with your Datamesh token in the Worker settings.
package/dist/index.cjs CHANGED
@@ -16,4 +16,4 @@
16
16
  Use "options.replacer" or "options.ignoreUnknown"
17
17
  `)},_domwindow:function(){return S("domwindow")},_bigint:function(w){return S("bigint:"+w.toString())},_process:function(){return S("process")},_timer:function(){return S("timer")},_pipe:function(){return S("pipe")},_tcp:function(){return S("tcp")},_udp:function(){return S("udp")},_tty:function(){return S("tty")},_statwatcher:function(){return S("statwatcher")},_securecontext:function(){return S("securecontext")},_connection:function(){return S("connection")},_zlib:function(){return S("zlib")},_context:function(){return S("context")},_nodescript:function(){return S("nodescript")},_httpparser:function(){return S("httpparser")},_dataview:function(){return S("dataview")},_signal:function(){return S("signal")},_fsevent:function(){return S("fsevent")},_tlswrap:function(){return S("tlswrap")}}}function G(){return{buf:"",write:function(A){this.buf+=A},end:function(A){this.buf+=A},read:function(){return this.buf}}}o.writeToStream=function(A,O,m){return m===void 0&&(m=O,O={}),V(O=P(A,O),m).dispatch(A)}}).call(this,e("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/fake_9a5aa49d.js","/")},{buffer:3,crypto:5,lYpoI2:11}],2:[function(e,n,o){(function(i,a,c,f,p,g,v,C,F){(function(T){var U=typeof Uint8Array<"u"?Uint8Array:Array,M=43,k=47,P=48,R=97,V=65,G=45,A=95;function O(m){return m=m.charCodeAt(0),m===M||m===G?62:m===k||m===A?63:m<P?-1:m<P+10?m-P+26+26:m<V+26?m-V:m<R+26?m-R+26:void 0}T.toByteArray=function(m){var S,w;if(0<m.length%4)throw new Error("Invalid string. Length must be a multiple of 4");var B=m.length,B=m.charAt(B-2)==="="?2:m.charAt(B-1)==="="?1:0,N=new U(3*m.length/4-B),Q=0<B?m.length-4:m.length,z=0;function L(D){N[z++]=D}for(S=0;S<Q;S+=4,0)L((16711680&(w=O(m.charAt(S))<<18|O(m.charAt(S+1))<<12|O(m.charAt(S+2))<<6|O(m.charAt(S+3))))>>16),L((65280&w)>>8),L(255&w);return B==2?L(255&(w=O(m.charAt(S))<<2|O(m.charAt(S+1))>>4)):B==1&&(L((w=O(m.charAt(S))<<10|O(m.charAt(S+1))<<4|O(m.charAt(S+2))>>2)>>8&255),L(255&w)),N},T.fromByteArray=function(m){var S,w,B,N,Q=m.length%3,z="";function L(D){return"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(D)}for(S=0,B=m.length-Q;S<B;S+=3)w=(m[S]<<16)+(m[S+1]<<8)+m[S+2],z+=L((N=w)>>18&63)+L(N>>12&63)+L(N>>6&63)+L(63&N);switch(Q){case 1:z=(z+=L((w=m[m.length-1])>>2))+L(w<<4&63)+"==";break;case 2:z=(z=(z+=L((w=(m[m.length-2]<<8)+m[m.length-1])>>10))+L(w>>4&63))+L(w<<2&63)+"="}return z}})(o===void 0?this.base64js={}:o)}).call(this,e("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/base64-js/lib/b64.js","/node_modules/gulp-browserify/node_modules/base64-js/lib")},{buffer:3,lYpoI2:11}],3:[function(e,n,o){(function(i,a,M,f,p,g,v,C,F){var T=e("base64-js"),U=e("ieee754");function M(y,_,E){if(!(this instanceof M))return new M(y,_,E);var j,$,J,bt,Nt=typeof y;if(_==="base64"&&Nt=="string")for(y=(bt=y).trim?bt.trim():bt.replace(/^\s+|\s+$/g,"");y.length%4!=0;)y+="=";if(Nt=="number")j=Z(y);else if(Nt=="string")j=M.byteLength(y,_);else{if(Nt!="object")throw new Error("First argument needs to be a number, array or string.");j=Z(y.length)}if(M._useTypedArrays?$=M._augment(new Uint8Array(j)):(($=this).length=j,$._isBuffer=!0),M._useTypedArrays&&typeof y.byteLength=="number")$._set(y);else if(X(bt=y)||M.isBuffer(bt)||bt&&typeof bt=="object"&&typeof bt.length=="number")for(J=0;J<j;J++)M.isBuffer(y)?$[J]=y.readUInt8(J):$[J]=y[J];else if(Nt=="string")$.write(y,0,_);else if(Nt=="number"&&!M._useTypedArrays&&!E)for(J=0;J<j;J++)$[J]=0;return $}function k(y,_,E,j){return M._charsWritten=xt(function($){for(var J=[],bt=0;bt<$.length;bt++)J.push(255&$.charCodeAt(bt));return J}(_),y,E,j)}function P(y,_,E,j){return M._charsWritten=xt(function($){for(var J,bt,Nt=[],kt=0;kt<$.length;kt++)bt=$.charCodeAt(kt),J=bt>>8,bt=bt%256,Nt.push(bt),Nt.push(J);return Nt}(_),y,E,j)}function R(y,_,E){var j="";E=Math.min(y.length,E);for(var $=_;$<E;$++)j+=String.fromCharCode(y[$]);return j}function V(y,_,E,J){J||(W(typeof E=="boolean","missing or invalid endian"),W(_!=null,"missing offset"),W(_+1<y.length,"Trying to read beyond buffer length"));var $,J=y.length;if(!(J<=_))return E?($=y[_],_+1<J&&($|=y[_+1]<<8)):($=y[_]<<8,_+1<J&&($|=y[_+1])),$}function G(y,_,E,J){J||(W(typeof E=="boolean","missing or invalid endian"),W(_!=null,"missing offset"),W(_+3<y.length,"Trying to read beyond buffer length"));var $,J=y.length;if(!(J<=_))return E?(_+2<J&&($=y[_+2]<<16),_+1<J&&($|=y[_+1]<<8),$|=y[_],_+3<J&&($+=y[_+3]<<24>>>0)):(_+1<J&&($=y[_+1]<<16),_+2<J&&($|=y[_+2]<<8),_+3<J&&($|=y[_+3]),$+=y[_]<<24>>>0),$}function A(y,_,E,j){if(j||(W(typeof E=="boolean","missing or invalid endian"),W(_!=null,"missing offset"),W(_+1<y.length,"Trying to read beyond buffer length")),!(y.length<=_))return j=V(y,_,E,!0),32768&j?-1*(65535-j+1):j}function O(y,_,E,j){if(j||(W(typeof E=="boolean","missing or invalid endian"),W(_!=null,"missing offset"),W(_+3<y.length,"Trying to read beyond buffer length")),!(y.length<=_))return j=G(y,_,E,!0),2147483648&j?-1*(4294967295-j+1):j}function m(y,_,E,j){return j||(W(typeof E=="boolean","missing or invalid endian"),W(_+3<y.length,"Trying to read beyond buffer length")),U.read(y,_,E,23,4)}function S(y,_,E,j){return j||(W(typeof E=="boolean","missing or invalid endian"),W(_+7<y.length,"Trying to read beyond buffer length")),U.read(y,_,E,52,8)}function w(y,_,E,j,$){if($||(W(_!=null,"missing value"),W(typeof j=="boolean","missing or invalid endian"),W(E!=null,"missing offset"),W(E+1<y.length,"trying to write beyond buffer length"),Pt(_,65535)),$=y.length,!($<=E))for(var J=0,bt=Math.min($-E,2);J<bt;J++)y[E+J]=(_&255<<8*(j?J:1-J))>>>8*(j?J:1-J)}function B(y,_,E,j,$){if($||(W(_!=null,"missing value"),W(typeof j=="boolean","missing or invalid endian"),W(E!=null,"missing offset"),W(E+3<y.length,"trying to write beyond buffer length"),Pt(_,4294967295)),$=y.length,!($<=E))for(var J=0,bt=Math.min($-E,4);J<bt;J++)y[E+J]=_>>>8*(j?J:3-J)&255}function N(y,_,E,j,$){$||(W(_!=null,"missing value"),W(typeof j=="boolean","missing or invalid endian"),W(E!=null,"missing offset"),W(E+1<y.length,"Trying to write beyond buffer length"),Zt(_,32767,-32768)),y.length<=E||w(y,0<=_?_:65535+_+1,E,j,$)}function Q(y,_,E,j,$){$||(W(_!=null,"missing value"),W(typeof j=="boolean","missing or invalid endian"),W(E!=null,"missing offset"),W(E+3<y.length,"Trying to write beyond buffer length"),Zt(_,2147483647,-2147483648)),y.length<=E||B(y,0<=_?_:4294967295+_+1,E,j,$)}function z(y,_,E,j,$){$||(W(_!=null,"missing value"),W(typeof j=="boolean","missing or invalid endian"),W(E!=null,"missing offset"),W(E+3<y.length,"Trying to write beyond buffer length"),Gt(_,34028234663852886e22,-34028234663852886e22)),y.length<=E||U.write(y,_,E,j,23,4)}function L(y,_,E,j,$){$||(W(_!=null,"missing value"),W(typeof j=="boolean","missing or invalid endian"),W(E!=null,"missing offset"),W(E+7<y.length,"Trying to write beyond buffer length"),Gt(_,17976931348623157e292,-17976931348623157e292)),y.length<=E||U.write(y,_,E,j,52,8)}o.Buffer=M,o.SlowBuffer=M,o.INSPECT_MAX_BYTES=50,M.poolSize=8192,M._useTypedArrays=function(){try{var y=new ArrayBuffer(0),_=new Uint8Array(y);return _.foo=function(){return 42},_.foo()===42&&typeof _.subarray=="function"}catch{return!1}}(),M.isEncoding=function(y){switch(String(y).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},M.isBuffer=function(y){return!(y==null||!y._isBuffer)},M.byteLength=function(y,_){var E;switch(y+="",_||"utf8"){case"hex":E=y.length/2;break;case"utf8":case"utf-8":E=q(y).length;break;case"ascii":case"binary":case"raw":E=y.length;break;case"base64":E=rt(y).length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":E=2*y.length;break;default:throw new Error("Unknown encoding")}return E},M.concat=function(y,_){if(W(X(y),`Usage: Buffer.concat(list, [totalLength])
18
18
  list should be an Array.`),y.length===0)return new M(0);if(y.length===1)return y[0];if(typeof _!="number")for($=_=0;$<y.length;$++)_+=y[$].length;for(var E=new M(_),j=0,$=0;$<y.length;$++){var J=y[$];J.copy(E,j),j+=J.length}return E},M.prototype.write=function(y,_,E,j){isFinite(_)?isFinite(E)||(j=E,E=void 0):(kt=j,j=_,_=E,E=kt),_=Number(_)||0;var $,J,bt,Nt,kt=this.length-_;switch((!E||kt<(E=Number(E)))&&(E=kt),j=String(j||"utf8").toLowerCase()){case"hex":$=function(Ht,Vt,$t,Mt){$t=Number($t)||0;var mt=Ht.length-$t;(!Mt||mt<(Mt=Number(Mt)))&&(Mt=mt),W((mt=Vt.length)%2==0,"Invalid hex string"),mt/2<Mt&&(Mt=mt/2);for(var Qt=0;Qt<Mt;Qt++){var ir=parseInt(Vt.substr(2*Qt,2),16);W(!isNaN(ir),"Invalid hex string"),Ht[$t+Qt]=ir}return M._charsWritten=2*Qt,Qt}(this,y,_,E);break;case"utf8":case"utf-8":J=this,bt=_,Nt=E,$=M._charsWritten=xt(q(y),J,bt,Nt);break;case"ascii":case"binary":$=k(this,y,_,E);break;case"base64":J=this,bt=_,Nt=E,$=M._charsWritten=xt(rt(y),J,bt,Nt);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":$=P(this,y,_,E);break;default:throw new Error("Unknown encoding")}return $},M.prototype.toString=function(y,_,E){var j,$,J,bt,Nt=this;if(y=String(y||"utf8").toLowerCase(),_=Number(_)||0,(E=E!==void 0?Number(E):Nt.length)===_)return"";switch(y){case"hex":j=function(kt,Ht,Vt){var $t=kt.length;(!Ht||Ht<0)&&(Ht=0),(!Vt||Vt<0||$t<Vt)&&(Vt=$t);for(var Mt="",mt=Ht;mt<Vt;mt++)Mt+=K(kt[mt]);return Mt}(Nt,_,E);break;case"utf8":case"utf-8":j=function(kt,Ht,Vt){var $t="",Mt="";Vt=Math.min(kt.length,Vt);for(var mt=Ht;mt<Vt;mt++)kt[mt]<=127?($t+=Ut(Mt)+String.fromCharCode(kt[mt]),Mt=""):Mt+="%"+kt[mt].toString(16);return $t+Ut(Mt)}(Nt,_,E);break;case"ascii":case"binary":j=R(Nt,_,E);break;case"base64":$=Nt,bt=E,j=(J=_)===0&&bt===$.length?T.fromByteArray($):T.fromByteArray($.slice(J,bt));break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":j=function(kt,Ht,Vt){for(var $t=kt.slice(Ht,Vt),Mt="",mt=0;mt<$t.length;mt+=2)Mt+=String.fromCharCode($t[mt]+256*$t[mt+1]);return Mt}(Nt,_,E);break;default:throw new Error("Unknown encoding")}return j},M.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},M.prototype.copy=function(y,_,E,j){if(_=_||0,(j=j||j===0?j:this.length)!==(E=E||0)&&y.length!==0&&this.length!==0){W(E<=j,"sourceEnd < sourceStart"),W(0<=_&&_<y.length,"targetStart out of bounds"),W(0<=E&&E<this.length,"sourceStart out of bounds"),W(0<=j&&j<=this.length,"sourceEnd out of bounds"),j>this.length&&(j=this.length);var $=(j=y.length-_<j-E?y.length-_+E:j)-E;if($<100||!M._useTypedArrays)for(var J=0;J<$;J++)y[J+_]=this[J+E];else y._set(this.subarray(E,E+$),_)}},M.prototype.slice=function(y,_){var E=this.length;if(y=Y(y,E,0),_=Y(_,E,E),M._useTypedArrays)return M._augment(this.subarray(y,_));for(var j=_-y,$=new M(j,void 0,!0),J=0;J<j;J++)$[J]=this[J+y];return $},M.prototype.get=function(y){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(y)},M.prototype.set=function(y,_){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(y,_)},M.prototype.readUInt8=function(y,_){if(_||(W(y!=null,"missing offset"),W(y<this.length,"Trying to read beyond buffer length")),!(y>=this.length))return this[y]},M.prototype.readUInt16LE=function(y,_){return V(this,y,!0,_)},M.prototype.readUInt16BE=function(y,_){return V(this,y,!1,_)},M.prototype.readUInt32LE=function(y,_){return G(this,y,!0,_)},M.prototype.readUInt32BE=function(y,_){return G(this,y,!1,_)},M.prototype.readInt8=function(y,_){if(_||(W(y!=null,"missing offset"),W(y<this.length,"Trying to read beyond buffer length")),!(y>=this.length))return 128&this[y]?-1*(255-this[y]+1):this[y]},M.prototype.readInt16LE=function(y,_){return A(this,y,!0,_)},M.prototype.readInt16BE=function(y,_){return A(this,y,!1,_)},M.prototype.readInt32LE=function(y,_){return O(this,y,!0,_)},M.prototype.readInt32BE=function(y,_){return O(this,y,!1,_)},M.prototype.readFloatLE=function(y,_){return m(this,y,!0,_)},M.prototype.readFloatBE=function(y,_){return m(this,y,!1,_)},M.prototype.readDoubleLE=function(y,_){return S(this,y,!0,_)},M.prototype.readDoubleBE=function(y,_){return S(this,y,!1,_)},M.prototype.writeUInt8=function(y,_,E){E||(W(y!=null,"missing value"),W(_!=null,"missing offset"),W(_<this.length,"trying to write beyond buffer length"),Pt(y,255)),_>=this.length||(this[_]=y)},M.prototype.writeUInt16LE=function(y,_,E){w(this,y,_,!0,E)},M.prototype.writeUInt16BE=function(y,_,E){w(this,y,_,!1,E)},M.prototype.writeUInt32LE=function(y,_,E){B(this,y,_,!0,E)},M.prototype.writeUInt32BE=function(y,_,E){B(this,y,_,!1,E)},M.prototype.writeInt8=function(y,_,E){E||(W(y!=null,"missing value"),W(_!=null,"missing offset"),W(_<this.length,"Trying to write beyond buffer length"),Zt(y,127,-128)),_>=this.length||(0<=y?this.writeUInt8(y,_,E):this.writeUInt8(255+y+1,_,E))},M.prototype.writeInt16LE=function(y,_,E){N(this,y,_,!0,E)},M.prototype.writeInt16BE=function(y,_,E){N(this,y,_,!1,E)},M.prototype.writeInt32LE=function(y,_,E){Q(this,y,_,!0,E)},M.prototype.writeInt32BE=function(y,_,E){Q(this,y,_,!1,E)},M.prototype.writeFloatLE=function(y,_,E){z(this,y,_,!0,E)},M.prototype.writeFloatBE=function(y,_,E){z(this,y,_,!1,E)},M.prototype.writeDoubleLE=function(y,_,E){L(this,y,_,!0,E)},M.prototype.writeDoubleBE=function(y,_,E){L(this,y,_,!1,E)},M.prototype.fill=function(y,_,E){if(_=_||0,E=E||this.length,W(typeof(y=typeof(y=y||0)=="string"?y.charCodeAt(0):y)=="number"&&!isNaN(y),"value is not a number"),W(_<=E,"end < start"),E!==_&&this.length!==0){W(0<=_&&_<this.length,"start out of bounds"),W(0<=E&&E<=this.length,"end out of bounds");for(var j=_;j<E;j++)this[j]=y}},M.prototype.inspect=function(){for(var y=[],_=this.length,E=0;E<_;E++)if(y[E]=K(this[E]),E===o.INSPECT_MAX_BYTES){y[E+1]="...";break}return"<Buffer "+y.join(" ")+">"},M.prototype.toArrayBuffer=function(){if(typeof Uint8Array>"u")throw new Error("Buffer.toArrayBuffer not supported in this browser");if(M._useTypedArrays)return new M(this).buffer;for(var y=new Uint8Array(this.length),_=0,E=y.length;_<E;_+=1)y[_]=this[_];return y.buffer};var D=M.prototype;function Y(y,_,E){return typeof y!="number"?E:_<=(y=~~y)?_:0<=y||0<=(y+=_)?y:0}function Z(y){return(y=~~Math.ceil(+y))<0?0:y}function X(y){return(Array.isArray||function(_){return Object.prototype.toString.call(_)==="[object Array]"})(y)}function K(y){return y<16?"0"+y.toString(16):y.toString(16)}function q(y){for(var _=[],E=0;E<y.length;E++){var j=y.charCodeAt(E);if(j<=127)_.push(y.charCodeAt(E));else for(var $=E,J=(55296<=j&&j<=57343&&E++,encodeURIComponent(y.slice($,E+1)).substr(1).split("%")),bt=0;bt<J.length;bt++)_.push(parseInt(J[bt],16))}return _}function rt(y){return T.toByteArray(y)}function xt(y,_,E,j){for(var $=0;$<j&&!($+E>=_.length||$>=y.length);$++)_[$+E]=y[$];return $}function Ut(y){try{return decodeURIComponent(y)}catch{return"�"}}function Pt(y,_){W(typeof y=="number","cannot write a non-number as a number"),W(0<=y,"specified a negative value for writing an unsigned value"),W(y<=_,"value is larger than maximum value for type"),W(Math.floor(y)===y,"value has a fractional component")}function Zt(y,_,E){W(typeof y=="number","cannot write a non-number as a number"),W(y<=_,"value larger than maximum allowed value"),W(E<=y,"value smaller than minimum allowed value"),W(Math.floor(y)===y,"value has a fractional component")}function Gt(y,_,E){W(typeof y=="number","cannot write a non-number as a number"),W(y<=_,"value larger than maximum allowed value"),W(E<=y,"value smaller than minimum allowed value")}function W(y,_){if(!y)throw new Error(_||"Failed assertion")}M._augment=function(y){return y._isBuffer=!0,y._get=y.get,y._set=y.set,y.get=D.get,y.set=D.set,y.write=D.write,y.toString=D.toString,y.toLocaleString=D.toString,y.toJSON=D.toJSON,y.copy=D.copy,y.slice=D.slice,y.readUInt8=D.readUInt8,y.readUInt16LE=D.readUInt16LE,y.readUInt16BE=D.readUInt16BE,y.readUInt32LE=D.readUInt32LE,y.readUInt32BE=D.readUInt32BE,y.readInt8=D.readInt8,y.readInt16LE=D.readInt16LE,y.readInt16BE=D.readInt16BE,y.readInt32LE=D.readInt32LE,y.readInt32BE=D.readInt32BE,y.readFloatLE=D.readFloatLE,y.readFloatBE=D.readFloatBE,y.readDoubleLE=D.readDoubleLE,y.readDoubleBE=D.readDoubleBE,y.writeUInt8=D.writeUInt8,y.writeUInt16LE=D.writeUInt16LE,y.writeUInt16BE=D.writeUInt16BE,y.writeUInt32LE=D.writeUInt32LE,y.writeUInt32BE=D.writeUInt32BE,y.writeInt8=D.writeInt8,y.writeInt16LE=D.writeInt16LE,y.writeInt16BE=D.writeInt16BE,y.writeInt32LE=D.writeInt32LE,y.writeInt32BE=D.writeInt32BE,y.writeFloatLE=D.writeFloatLE,y.writeFloatBE=D.writeFloatBE,y.writeDoubleLE=D.writeDoubleLE,y.writeDoubleBE=D.writeDoubleBE,y.fill=D.fill,y.inspect=D.inspect,y.toArrayBuffer=D.toArrayBuffer,y}}).call(this,e("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/buffer/index.js","/node_modules/gulp-browserify/node_modules/buffer")},{"base64-js":2,buffer:3,ieee754:10,lYpoI2:11}],4:[function(e,n,o){(function(i,a,T,f,p,g,v,C,F){var T=e("buffer").Buffer,U=4,M=new T(U);M.fill(0),n.exports={hash:function(k,P,R,V){for(var G=P(function(w,B){w.length%U!=0&&(N=w.length+(U-w.length%U),w=T.concat([w,M],N));for(var N,Q=[],z=B?w.readInt32BE:w.readInt32LE,L=0;L<w.length;L+=U)Q.push(z.call(w,L));return Q}(k=T.isBuffer(k)?k:new T(k),V),8*k.length),P=V,A=new T(R),O=P?A.writeInt32BE:A.writeInt32LE,m=0;m<G.length;m++)O.call(A,G[m],4*m,!0);return A}}}).call(this,e("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/helpers.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{buffer:3,lYpoI2:11}],5:[function(e,n,o){(function(i,a,T,f,p,g,v,C,F){var T=e("buffer").Buffer,U=e("./sha"),M=e("./sha256"),k=e("./rng"),P={sha1:U,sha256:M,md5:e("./md5")},R=64,V=new T(R);function G(w,B){var N=P[w=w||"sha1"],Q=[];return N||A("algorithm:",w,"is not yet supported"),{update:function(z){return T.isBuffer(z)||(z=new T(z)),Q.push(z),z.length,this},digest:function(z){var L=T.concat(Q),L=B?function(D,Y,Z){T.isBuffer(Y)||(Y=new T(Y)),T.isBuffer(Z)||(Z=new T(Z)),Y.length>R?Y=D(Y):Y.length<R&&(Y=T.concat([Y,V],R));for(var X=new T(R),K=new T(R),q=0;q<R;q++)X[q]=54^Y[q],K[q]=92^Y[q];return Z=D(T.concat([X,Z])),D(T.concat([K,Z]))}(N,B,L):N(L);return Q=null,z?L.toString(z):L}}}function A(){var w=[].slice.call(arguments).join(" ");throw new Error([w,"we accept pull requests","http://github.com/dominictarr/crypto-browserify"].join(`
19
- `))}V.fill(0),o.createHash=function(w){return G(w)},o.createHmac=G,o.randomBytes=function(w,B){if(!B||!B.call)return new T(k(w));try{B.call(this,void 0,new T(k(w)))}catch(N){B(N)}};var O,m=["createCredentials","createCipher","createCipheriv","createDecipher","createDecipheriv","createSign","createVerify","createDiffieHellman","pbkdf2"],S=function(w){o[w]=function(){A("sorry,",w,"is not implemented yet")}};for(O in m)S(m[O])}).call(this,e("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/index.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./md5":6,"./rng":7,"./sha":8,"./sha256":9,buffer:3,lYpoI2:11}],6:[function(e,n,o){(function(i,a,c,f,p,g,v,C,F){var T=e("./helpers");function U(A,O){A[O>>5]|=128<<O%32,A[14+(O+64>>>9<<4)]=O;for(var m=1732584193,S=-271733879,w=-1732584194,B=271733878,N=0;N<A.length;N+=16){var Q=m,z=S,L=w,D=B,m=k(m,S,w,B,A[N+0],7,-680876936),B=k(B,m,S,w,A[N+1],12,-389564586),w=k(w,B,m,S,A[N+2],17,606105819),S=k(S,w,B,m,A[N+3],22,-1044525330);m=k(m,S,w,B,A[N+4],7,-176418897),B=k(B,m,S,w,A[N+5],12,1200080426),w=k(w,B,m,S,A[N+6],17,-1473231341),S=k(S,w,B,m,A[N+7],22,-45705983),m=k(m,S,w,B,A[N+8],7,1770035416),B=k(B,m,S,w,A[N+9],12,-1958414417),w=k(w,B,m,S,A[N+10],17,-42063),S=k(S,w,B,m,A[N+11],22,-1990404162),m=k(m,S,w,B,A[N+12],7,1804603682),B=k(B,m,S,w,A[N+13],12,-40341101),w=k(w,B,m,S,A[N+14],17,-1502002290),m=P(m,S=k(S,w,B,m,A[N+15],22,1236535329),w,B,A[N+1],5,-165796510),B=P(B,m,S,w,A[N+6],9,-1069501632),w=P(w,B,m,S,A[N+11],14,643717713),S=P(S,w,B,m,A[N+0],20,-373897302),m=P(m,S,w,B,A[N+5],5,-701558691),B=P(B,m,S,w,A[N+10],9,38016083),w=P(w,B,m,S,A[N+15],14,-660478335),S=P(S,w,B,m,A[N+4],20,-405537848),m=P(m,S,w,B,A[N+9],5,568446438),B=P(B,m,S,w,A[N+14],9,-1019803690),w=P(w,B,m,S,A[N+3],14,-187363961),S=P(S,w,B,m,A[N+8],20,1163531501),m=P(m,S,w,B,A[N+13],5,-1444681467),B=P(B,m,S,w,A[N+2],9,-51403784),w=P(w,B,m,S,A[N+7],14,1735328473),m=R(m,S=P(S,w,B,m,A[N+12],20,-1926607734),w,B,A[N+5],4,-378558),B=R(B,m,S,w,A[N+8],11,-2022574463),w=R(w,B,m,S,A[N+11],16,1839030562),S=R(S,w,B,m,A[N+14],23,-35309556),m=R(m,S,w,B,A[N+1],4,-1530992060),B=R(B,m,S,w,A[N+4],11,1272893353),w=R(w,B,m,S,A[N+7],16,-155497632),S=R(S,w,B,m,A[N+10],23,-1094730640),m=R(m,S,w,B,A[N+13],4,681279174),B=R(B,m,S,w,A[N+0],11,-358537222),w=R(w,B,m,S,A[N+3],16,-722521979),S=R(S,w,B,m,A[N+6],23,76029189),m=R(m,S,w,B,A[N+9],4,-640364487),B=R(B,m,S,w,A[N+12],11,-421815835),w=R(w,B,m,S,A[N+15],16,530742520),m=V(m,S=R(S,w,B,m,A[N+2],23,-995338651),w,B,A[N+0],6,-198630844),B=V(B,m,S,w,A[N+7],10,1126891415),w=V(w,B,m,S,A[N+14],15,-1416354905),S=V(S,w,B,m,A[N+5],21,-57434055),m=V(m,S,w,B,A[N+12],6,1700485571),B=V(B,m,S,w,A[N+3],10,-1894986606),w=V(w,B,m,S,A[N+10],15,-1051523),S=V(S,w,B,m,A[N+1],21,-2054922799),m=V(m,S,w,B,A[N+8],6,1873313359),B=V(B,m,S,w,A[N+15],10,-30611744),w=V(w,B,m,S,A[N+6],15,-1560198380),S=V(S,w,B,m,A[N+13],21,1309151649),m=V(m,S,w,B,A[N+4],6,-145523070),B=V(B,m,S,w,A[N+11],10,-1120210379),w=V(w,B,m,S,A[N+2],15,718787259),S=V(S,w,B,m,A[N+9],21,-343485551),m=G(m,Q),S=G(S,z),w=G(w,L),B=G(B,D)}return Array(m,S,w,B)}function M(A,O,m,S,w,B){return G((O=G(G(O,A),G(S,B)))<<w|O>>>32-w,m)}function k(A,O,m,S,w,B,N){return M(O&m|~O&S,A,O,w,B,N)}function P(A,O,m,S,w,B,N){return M(O&S|m&~S,A,O,w,B,N)}function R(A,O,m,S,w,B,N){return M(O^m^S,A,O,w,B,N)}function V(A,O,m,S,w,B,N){return M(m^(O|~S),A,O,w,B,N)}function G(A,O){var m=(65535&A)+(65535&O);return(A>>16)+(O>>16)+(m>>16)<<16|65535&m}n.exports=function(A){return T.hash(A,U,16)}}).call(this,e("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/md5.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],7:[function(e,n,o){(function(i,a,c,f,p,g,v,C,F){n.exports=function(T){for(var U,M=new Array(T),k=0;k<T;k++)(3&k)==0&&(U=4294967296*Math.random()),M[k]=U>>>((3&k)<<3)&255;return M}}).call(this,e("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/rng.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{buffer:3,lYpoI2:11}],8:[function(e,n,o){(function(i,a,c,f,p,g,v,C,F){var T=e("./helpers");function U(P,R){P[R>>5]|=128<<24-R%32,P[15+(R+64>>9<<4)]=R;for(var V,G,A,O=Array(80),m=1732584193,S=-271733879,w=-1732584194,B=271733878,N=-1009589776,Q=0;Q<P.length;Q+=16){for(var z=m,L=S,D=w,Y=B,Z=N,X=0;X<80;X++){O[X]=X<16?P[Q+X]:k(O[X-3]^O[X-8]^O[X-14]^O[X-16],1);var K=M(M(k(m,5),(K=S,G=w,A=B,(V=X)<20?K&G|~K&A:!(V<40)&&V<60?K&G|K&A|G&A:K^G^A)),M(M(N,O[X]),(V=X)<20?1518500249:V<40?1859775393:V<60?-1894007588:-899497514)),N=B,B=w,w=k(S,30),S=m,m=K}m=M(m,z),S=M(S,L),w=M(w,D),B=M(B,Y),N=M(N,Z)}return Array(m,S,w,B,N)}function M(P,R){var V=(65535&P)+(65535&R);return(P>>16)+(R>>16)+(V>>16)<<16|65535&V}function k(P,R){return P<<R|P>>>32-R}n.exports=function(P){return T.hash(P,U,20,!0)}}).call(this,e("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/sha.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],9:[function(e,n,o){(function(i,a,c,f,p,g,v,C,F){function T(R,V){var G=(65535&R)+(65535&V);return(R>>16)+(V>>16)+(G>>16)<<16|65535&G}function U(R,V){var G,A=new Array(1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298),O=new Array(1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225),m=new Array(64);R[V>>5]|=128<<24-V%32,R[15+(V+64>>9<<4)]=V;for(var S,w,B=0;B<R.length;B+=16){for(var N=O[0],Q=O[1],z=O[2],L=O[3],D=O[4],Y=O[5],Z=O[6],X=O[7],K=0;K<64;K++)m[K]=K<16?R[K+B]:T(T(T((w=m[K-2],k(w,17)^k(w,19)^P(w,10)),m[K-7]),(w=m[K-15],k(w,7)^k(w,18)^P(w,3))),m[K-16]),G=T(T(T(T(X,k(w=D,6)^k(w,11)^k(w,25)),D&Y^~D&Z),A[K]),m[K]),S=T(k(S=N,2)^k(S,13)^k(S,22),N&Q^N&z^Q&z),X=Z,Z=Y,Y=D,D=T(L,G),L=z,z=Q,Q=N,N=T(G,S);O[0]=T(N,O[0]),O[1]=T(Q,O[1]),O[2]=T(z,O[2]),O[3]=T(L,O[3]),O[4]=T(D,O[4]),O[5]=T(Y,O[5]),O[6]=T(Z,O[6]),O[7]=T(X,O[7])}return O}var M=e("./helpers"),k=function(R,V){return R>>>V|R<<32-V},P=function(R,V){return R>>>V};n.exports=function(R){return M.hash(R,U,32,!0)}}).call(this,e("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/sha256.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],10:[function(e,n,o){(function(i,a,c,f,p,g,v,C,F){o.read=function(T,U,M,k,B){var R,V,G=8*B-k-1,A=(1<<G)-1,O=A>>1,m=-7,S=M?B-1:0,w=M?-1:1,B=T[U+S];for(S+=w,R=B&(1<<-m)-1,B>>=-m,m+=G;0<m;R=256*R+T[U+S],S+=w,m-=8);for(V=R&(1<<-m)-1,R>>=-m,m+=k;0<m;V=256*V+T[U+S],S+=w,m-=8);if(R===0)R=1-O;else{if(R===A)return V?NaN:1/0*(B?-1:1);V+=Math.pow(2,k),R-=O}return(B?-1:1)*V*Math.pow(2,R-k)},o.write=function(T,U,M,k,P,N){var V,G,A=8*N-P-1,O=(1<<A)-1,m=O>>1,S=P===23?Math.pow(2,-24)-Math.pow(2,-77):0,w=k?0:N-1,B=k?1:-1,N=U<0||U===0&&1/U<0?1:0;for(U=Math.abs(U),isNaN(U)||U===1/0?(G=isNaN(U)?1:0,V=O):(V=Math.floor(Math.log(U)/Math.LN2),U*(k=Math.pow(2,-V))<1&&(V--,k*=2),2<=(U+=1<=V+m?S/k:S*Math.pow(2,1-m))*k&&(V++,k/=2),O<=V+m?(G=0,V=O):1<=V+m?(G=(U*k-1)*Math.pow(2,P),V+=m):(G=U*Math.pow(2,m-1)*Math.pow(2,P),V=0));8<=P;T[M+w]=255&G,w+=B,G/=256,P-=8);for(V=V<<P|G,A+=P;0<A;T[M+w]=255&V,w+=B,V/=256,A-=8);T[M+w-B]|=128*N}}).call(this,e("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/ieee754/index.js","/node_modules/gulp-browserify/node_modules/ieee754")},{buffer:3,lYpoI2:11}],11:[function(e,n,o){(function(i,a,c,f,p,g,v,C,F){var T,U,M;function k(){}(i=n.exports={}).nextTick=(U=typeof window<"u"&&window.setImmediate,M=typeof window<"u"&&window.postMessage&&window.addEventListener,U?function(P){return window.setImmediate(P)}:M?(T=[],window.addEventListener("message",function(P){var R=P.source;R!==window&&R!==null||P.data!=="process-tick"||(P.stopPropagation(),0<T.length&&T.shift()())},!0),function(P){T.push(P),window.postMessage("process-tick","*")}):function(P){setTimeout(P,0)}),i.title="browser",i.browser=!0,i.env={},i.argv=[],i.on=k,i.addListener=k,i.once=k,i.off=k,i.removeListener=k,i.removeAllListeners=k,i.emit=k,i.binding=function(P){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(P){throw new Error("process.chdir is not supported")}}).call(this,e("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/process/browser.js","/node_modules/gulp-browserify/node_modules/process")},{buffer:3,lYpoI2:11}]},{},[1])(1)})}(ki)),ki.exports}var Jf=Yf();const Hf=Ts(Jf);function qf(r){return new Promise(t=>setTimeout(t,r))}class Kf{cache;url;params;cache_prefix;fetchOptions;timeout;_pending={};constructor(t,e,n={}){const o={...e};n.parameters&&(o["x-parameters"]=JSON.stringify(n.parameters)),n.chunks&&(o["x-chunks"]=n.chunks),n.downsample&&(o["x-downsample"]=JSON.stringify(n.downsample)),o["x-filtered"]="True",this.params={},e["x-datamesh-auth"]&&(this.params.auth=e["x-datamesh-auth"]),e["x-datamesh-sig"]&&(this.params.sig=e["x-datamesh-sig"]),this.fetchOptions={headers:o},this.url=t;const i=t.split("/").pop();n.nocache||typeof window>"u"?this.cache=void 0:this.cache=iu("zarr","cache"),this.cache_prefix=Hf({datasource:i,...n.parameters,chunks:n.chunks,downsample:n.downsample}),this.timeout=n.timeout||6e4}async get(t,e,n=0){const o=`${this.cache_prefix}${t}`;let i=null;if(this.cache&&(i=await Zf(o,this.cache),i&&delete this._pending[o],this._pending[o]))if(await qf(200),n>this.timeout){await Ni(o,this.cache),delete this._pending[o],console.error("Zarr timeout");return}else return await this.get(t,e,n+200);if(!i){this._pending[o]=!0;try{const a={...this.fetchOptions,...e,headers:{...this.fetchOptions.headers||{},...e?.headers||{}},signal:AbortSignal.timeout(this.timeout)},c=new URLSearchParams(this.params).toString(),f=await fetch(`${this.url}${t}?${c}`,a);if(f.status===404){this.cache&&await Ni(o,this.cache);return}if(f.status>=400)throw new Error(`HTTP error: ${f.status}`);i=new Uint8Array(await f.arrayBuffer()),this.cache&&await Gf(o,i,this.cache)}catch(a){if(console.debug("Zarr retry:"+o),n<this.timeout/200)return delete this._pending[o],await this.get(t,e,n+200);this.cache&&await Ni(o,this.cache),console.error(a);return}finally{delete this._pending[o]}}return i}}const Po=async(r,t=".zarray")=>{const{path:e}=r.resolve(t),n=await r.store.get(e);return n?JSON.parse(new TextDecoder().decode(n)):{}};async function Xf(r){const t=await Po(r,".zattrs"),e=await Po(r);e.dtype.startsWith("<M8")&&(t._dtype=e.dtype);const n=[];e.order==="F"&&n.push({name:"transpose",configuration:{order:"F"}}),typeof e.dtype=="string"&&e.dtype.startsWith(">")&&n.push({name:"bytes",configuration:{endian:"big"}});for(const{id:i,...a}of e.filters??[])n.push({name:i,configuration:a});if(e.compressor){const{id:i,...a}=e.compressor;n.push({name:i,configuration:a})}const o={zarr_format:3,node_type:"array",shape:e.shape,data_type:"int64",chunk_grid:{name:"regular",configuration:{chunk_shape:e.chunks}},chunk_key_encoding:{name:"v2",configuration:{separator:e.dimension_separator??"."}},codecs:n,fill_value:e.fill_value,attributes:t};return new Br(r.store,r.path,o)}function bi(r,t,e){const n=e.value;return e.value=async function(...o){const i=Date.now(),a=await n.apply(this,o),f=Date.now()-i;return console.debug(`${t} took ${f}ms`),a},e}var Qf=Object.defineProperty,td=Object.getOwnPropertyDescriptor,ed=(r,t,e,n)=>{for(var o=td(t,e),i=r.length-1,a;i>=0;i--)(a=r[i])&&(o=a(t,e,o)||o);return o&&Qf(t,e,o),o};const su=r=>{const t=new nu.Buffer(r,"base64");return Vf.Geometry.parse(t).toGeoJSON()},ci=r=>r&&(Array.isArray(r)||ArrayBuffer.isView(r)),rd=r=>{const t=[];if(!ci(r))return t;for(;t.push(r.length),ci(r[0]);)r=r[0];return t},nd=r=>{for(;Array.isArray(r);)r=r[0];if(r==null)return"uint8";switch(r.constructor.name){case"Boolean":return"bool";case"Number":return"float32";case"Int8Array":return"int8";case"Int16Array":return"int16";case"Int32Array":return"int32";case"BigInt64Array":return"int64";case"Uint8Array":return"uint8";case"Uint16Array":return"uint16";case"Uint32Array":return"uint32";case"Float32Array":return"float32";case"Float64Array":return"float64";case"String":return"v2:object";case"Object":return"v2:object"}throw new Error("Unsupported data type: "+r.constructor.name)},id=r=>{let t=r.toString().toLowerCase();return r.typeId==5?t="v2:object":r.typeId==1&&(t="uint8"),t},sd=r=>{if(!Array.isArray(r))return r;const t=r.flat(1/0);if(ci(t[0])){const e=t[0].length,n=new t[0].constructor(t.length*e);for(let o=0;o<t.length;o++)n.set(t[o],o*e);return n}else return t},od=r=>{const t=r.length,e=Array(t);for(let n=t-1,o=1;n>=0;n--)e[n]=o,o*=r[n];return e},Fs=(r,t,e,n=0)=>{if(t.length===0)return r[0];if(t.length===1){const i=new r.constructor(t[0]);return i.set(r.slice(n,n+t[0])),i}const o=new Array(t[0]);for(let i=0;i<t[0];i++)o[i]=Fs(r,t.slice(1),e.slice(1),n+i*e[0]);return o},ad=(r,t)=>{const[e,n]=t.split("<M8"),o=new Float64Array(r.data.length);let i=1n;switch(n){case"[ms]":i=1000n;break;case"[us]":i=1000000n;break;case"[ns]":i=1000000000n;break;default:i=1n;break}for(let a=0;a<r.data.length;a++)o[a]=Number(r.data[a]/i);return Fs(o,r.shape,r.stride)},ou=(r,t,e)=>{const n=Object.keys(t),o={};for(const i in r)ci(r[i].data)&&(o[i]=!0);if(n.length==1)for(let i=0;i<t[n[0]];i++){const a={};for(const c in r)o[c]?r[c].data.length>1&&(a[c]=r[c].data[i]):a[c]=r[c].data;e.push(a)}else for(let i=0;i<t[n[0]];i++){const a={};for(const f in r)r[f].dimensions.includes(n[0])?a[f]={attributes:r[f].attributes,data:r[f].data[i],dimensions:r[f].dimensions.slice(1)}:a[f]=r[f];const c={...t};delete c[n[0]],ou(a,c,e)}return e};class ui{id;dimensions;attributes;arr;constructor(t,e,n,o){this.id=t,this.dimensions=e,this.attributes=n,this.arr=o}async get(t){if(this.arr.shape.length==0||this.arr.shape[0]==0)return[];const e=t&&t.map(o=>{if(typeof o=="string"){const[i,a,c]=o.split(":");return Ui(parseInt(i),parseInt(a),parseInt(c))}else return o}),n=await ih(this.arr,e);return this.arr.dtype=="v2:object"||!n.shape?n.data:this.arr.dtype=="bool"?[...n.data]:this.arr.attrs._dtype?.startsWith("<M8")?ad(n,this.arr.attrs._dtype):Fs(n.data,n.shape,n.stride)}}ed([bi],ui.prototype,"get");class Ge{dimensions;variables;attributes;coordkeys;root;constructor(t,e,n,o,i){this.dimensions=t,this.variables=e,this.attributes=n,this.coordkeys=o,this.root=i}static async zarr(t,e,n={}){const o=new Kf(t,e,{chunks:n.chunks,downsample:n.downsample,parameters:n.parameters,timeout:n.timeout,nocache:n.nocache}),i=await $u(o),a=await Ze(i,{kind:"group"}),c={},f={};for(const g of i.contents())if(g.kind=="array"){let v;try{v=await Ze(a.resolve(g.path),{kind:"array"})}catch(T){if(T.message.includes("<M8"))v=await Xf(a.resolve(g.path));else throw T}const C=v.attrs._ARRAY_DIMENSIONS,F=g.path.split("/").pop();c[F]=new ui(F,C||[],v.attrs,v),C&&C.map((T,U)=>{const M=v.shape[U];if(f[T]&&f[T]!=M)throw new Error(`Inconsistent dimension size for ${T}: ${f[T]} != ${M}`);f[T]=M})}const p=JSON.parse(a.attrs._coordinates)||{};return new Ge(f,c,a.attrs,n.coordkeys||p,a)}static async fromArrow(t,e){const n={},o={record:t.numRows},i={};return t.schema.fields.forEach(a=>{const c=t.getChild(a.name);let f={},p=c?.toArray(),g=id(a.type);if(tt.isTimestamp(a.type)){const v=new Float64Array(p.length),C=BigInt(1e3**(a.type.unit-0));for(let F=0;F<p.length;F++)v[F]=Number(p[F]/C);p=v,g="float64",f={unit:"Unix timestamp (s)"}}else if(tt.isBinary(a.type)){const v=[];for(let C=0;C<p.length;C++)v.push(new nu.Buffer(p[C]).toString("base64"));p=v,g="v2:object"}i[a.name]={dimensions:["record"],attributes:f,data:p,dtype:g}}),await Ge.init({dimensions:o,variables:i,attributes:n},e)}static async fromGeojson(t,e){if(!("features"in t&&Array.isArray(t.features))&&!("geometry"in t))throw new Error("Invalid GeoJSON");const n="features"in t&&t.features?t.features:[t];if(n.length===0)throw new Error("FeatureCollection contains no features");const o=new Set;n.forEach(f=>{f.properties&&Object.keys(f.properties).forEach(p=>o.add(p))});const i=n.map(f=>{const p={geometry:f.geometry};return f.properties&&Object.assign(p,f.properties),p}),a={dimensions:{index:i.length},variables:{},attributes:{}},c=await Ge.init(a,{...e,g:"geometry"});await c.assign("geometry",["index"],i.map(f=>f.geometry),{description:"GeoJSON geometry"});for(const f of o){const p=i.map(g=>g[f]);await c.assign(f,["index"],p,{description:`Property: ${f}`})}return c}static async init(t,e){const n=await js(new Map,{attributes:{created:new Date}}),o=new Ge(t.dimensions,{},t.attributes||{},e||{},n);for(const i in t.variables){const{dimensions:a,attributes:c,data:f,dtype:p}=t.variables[i];await o.assign(i,a,f,c,p&&p==="string"?"v2:object":p)}return o}async asDataframe(){const t={},e=[];for(const o in this.variables)t[o]={attributes:this.variables[o].attributes,dimensions:this.variables[o].dimensions},t[o].data=await this.variables[o].get(),this.variables[o].arr.dtype=="int64"&&e.push(o);const n=ou(t,{...this.dimensions},[]);if(this.coordkeys.t)for(let o=0;o<n.length;o++)n[o][this.coordkeys.t]=new Date(1e3*n[o][this.coordkeys.t]).toISOString();if(e.length>0)for(const o of e)for(let i=0;i<n.length;i++)n[i][o]=Number(n[i][o]);return n}async asGeojson(t){if(!this.coordkeys.g&&!t)throw new Error("No geometry found");const e=[],n=await this.asDataframe();for(let o=0;o<n.length;o++){const{...i}=n[o];let a=t;if(!a&&this.coordkeys.g){delete i[this.coordkeys.g];const c=n[o][this.coordkeys.g];c.slice(0,7)=='{"type:'?a=JSON.parse(c):a=su(c)}e.push({type:"Feature",geometry:a,properties:i})}return{type:"FeatureCollection",features:e}}async assign(t,e,n,o,i,a){const c=rd(n);if(c.length!=e.length)throw new Error("Data shape does not match dimensions");e.map((v,C)=>{if(this.dimensions[v]){if(this.dimensions[v]!=c[C])throw new Error(`Existing size of dimension ${v} does not match new data`)}else this.dimensions[v]=c[C]});const f=i||nd(n),p=await js(this.root.resolve(t),{shape:c,data_type:f,chunk_shape:a||c,codecs:f=="v2:object"?[{name:"json2"}]:[]});let g=sd(n);g.length==0?g=null:f=="bool"?g=new qi(g):Array.isArray(g)&&f=="float32"?g=Float32Array.from(g,v=>v??NaN):Array.isArray(g)&&f=="float64"?g=Float64Array.from(g,v=>v??NaN):Array.isArray(g)&&f=="int8"?g=Int8Array.from(g):Array.isArray(g)&&f=="int16"?g=Int16Array.from(g):Array.isArray(g)&&f=="int32"?g=Int32Array.from(g):Array.isArray(g)&&f=="int64"?g=BigInt64Array.from(g.map(v=>BigInt(v))):Array.isArray(g)&&f=="uint8"?g=Uint8Array.from(g):Array.isArray(g)&&f=="uint16"?g=Uint16Array.from(g):Array.isArray(g)&&f=="uint32"?g=Uint32Array.from(g):Array.isArray(g)&&f=="uint64"&&(g=BigUint64Array.from(g.map(v=>BigInt(v)))),g&&await sh(p,c.map(()=>null),{data:g,shape:c,stride:od(c)}),this.variables[t]=new ui(t,e,o||{},p)}}var cd=Object.defineProperty,ud=Object.getOwnPropertyDescriptor,hd=(r,t,e,n)=>{for(var o=ud(t,e),i=r.length-1,a;i>=0;i--)(a=r[i])&&(o=a(t,e,o)||o);return o&&cd(t,e,o),o};const au=class Hi{id;user;creationTime;endTime;write;verified=!1;_connection;static async acquire(t,e={}){if(!t._isV1){const n=new Hi;return n.id="dummy_session",n.user="dummy_user",n.creationTime=new Date,n.endTime=new Date(Date.now()+(e.duration||1)*60*60*1e3),n.write=!1,n.verified=!1,n._connection=t,typeof process<"u"&&process.on&&process.on("beforeExit",()=>{n.close()}),n}try{const n={...t._authHeaders};n["Cache-Control"]="no-store";const o={duration:e.duration||1},i=await fetch(`${t._gateway}/session/?`+new URLSearchParams(o),{headers:n});if(i.status!==200)throw new Error(`Failed to create session: ${await i.text()}`);const a=await i.json(),c=new Hi;return c.id=a.id,c.user=a.user,c.creationTime=new Date(a.creation_time),c.endTime=new Date(a.end_time),c.write=a.write,c.verified=a.verified||!1,c._connection=t,typeof process<"u"&&process.on&&process.on("beforeExit",()=>{c.close()}),c}catch(n){throw new Error(`Error when acquiring datamesh session: ${n}`)}}get header(){return{"X-DATAMESH-SESSIONID":this.id}}addHeader(t){return{...t,...this.header}}async close(t=!1){if(this._connection._isV1)try{typeof process<"u"&&process.off&&process.off("beforeExit",this.close);const e=await fetch(`${this._connection._gateway}/session/${this.id}`,{method:"DELETE",headers:this.header,body:JSON.stringify({finalise_write:t})});if(e.status!==204){if(t)throw new Error(`Failed to finalise write: ${await e.text()}`);console.warn(`Failed to close session: ${await e.text()}`)}}catch(e){if(t)throw new Error(`Error when closing datamesh session: ${e}`);console.warn(`Error when closing datamesh session: ${e}`)}}async enter(){return this}async exit(t){await this.close(t===void 0)}};hd([bi],au,"acquire");let ld=au;var fd=Object.defineProperty,dd=Object.getOwnPropertyDescriptor,cu=(r,t,e,n)=>{for(var o=dd(t,e),i=r.length-1,a;i>=0;i--)(a=r[i])&&(o=a(t,e,o)||o);return o&&fd(t,e,o),o};const pd=typeof process<"u"&&process.env?.DATAMESH_SERVICE?process.env.DATAMESH_SERVICE:"https://datamesh.oceanum.io",Ns=class uu{static LAZY_LOAD_SIZE=1e8;_token;_host;_authHeaders;_gateway;_nocache=!1;_isV1=!1;_sessionParams={};_currentSession=null;service;gateway;constructor(t=typeof process<"u"&&process.env?.DATAMESH_TOKEN?process.env.DATAMESH_TOKEN:"$DATAMESH_TOKEN",e){if(!t&&!e?.jwtAuth)throw new Error("A valid datamesh token must be supplied as a connector constructor argument or defined in environment variables as DATAMESH_TOKEN");this._token=t,this._nocache=e?.nocache??!1;const n=new URL(e?.service||pd);this._host=`${n.protocol}//${n.hostname}`,this._authHeaders=e?.jwtAuth?{Authorization:`Bearer ${e.jwtAuth}`}:{Authorization:`Token ${this._token}`,"X-DATAMESH-TOKEN":this._token},this._gateway=e?.gateway||this._host,this._host.split(".").slice(-1)[0]!==this._gateway.split(".").slice(-1)[0]&&console.warn("Datamesh gateway and service domains do not match"),e?.sessionDuration&&typeof e.sessionDuration=="number"&&(this._sessionParams={duration:e.sessionDuration}),this._checkApiVersion()}async _checkApiVersion(){try{(await fetch(`${this._gateway}/session`,{headers:this._authHeaders})).status===200?(this._isV1=!0,console.info("Using datamesh API version 1")):(this._isV1=!1,console.info("Using datamesh API version 0"))}catch{this._isV1=!1,console.info("Using datamesh API version 0")}}get host(){return this._host}async status(){return(await fetch(this._host,{headers:this._authHeaders})).status===200}async validateResponse(t){if(t.status>=400){let e;try{e=(await t.json()).detail}catch{e=`Datamesh server error: ${await t.text()}`}throw new Error(e)}}async createSession(t={}){const e={duration:t.duration||this._sessionParams.duration||1};return this._currentSession=await ld.acquire(this,e),this._currentSession}async getSession(){return this._currentSession?this._currentSession:this.createSession()}async getSessionHeaders(t={}){return this._isV1&&!this._currentSession&&await this.createSession(),this._currentSession?this._currentSession.addHeader({...this._authHeaders,...t}):{...this._authHeaders,...t}}async metadataRequest(t="",e={}){const n=new URL(`${this._host}/datasource/${t}`);Object.keys(e).forEach(a=>n.searchParams.append(a,e[a]));const o=await this.getSessionHeaders(),i=await fetch(n.toString(),{headers:o});if(i.status===403)throw new Error(`Datasource ${t} not authorized`);return await this.validateResponse(i),i}async dataRequest(t,e="application/vnd.apache.arrow.file"){const n=await this.getSessionHeaders({Accept:e}),o=await fetch(`${this._gateway}/oceanql/${t}?f=arrow`,{headers:n});return await this.validateResponse(o),Xc(await o.arrayBuffer())}async stageRequest(t){const e=JSON.stringify(t),n=await this.getSessionHeaders({"Content-Type":"application/json"}),o=await fetch(`${this._gateway}/oceanql/stage/`,{method:"POST",headers:n,body:e});if(o.status>=400){const i=await o.json();throw new Error(i.detail)}else return o.status===204?null:o.json()}async query(t,e={}){const n=await this.stageRequest(t);if(!n)return console.warn("No data found for query"),null;if(n.size<uu.LAZY_LOAD_SIZE&&n.container!="dataset"){const f=await this.dataRequest(n.qhash);return await Ge.fromArrow(f,n.coordkeys)}const o=`${this._gateway}/zarr/${this._isV1?"query/":""}${n.qhash}`,i=t.parameters,a=await this.getSessionHeaders(),c=await Ge.zarr(o,a,{parameters:i,timeout:e.timeout||6e4,nocache:this._nocache});if(t.variables)for(const f of Object.keys(c.variables))!t.variables.includes(f)&&!Object.values(c.coordkeys).includes(f)&&delete c.variables[f];return c}async getDatasource(t){const n=await(await this.metadataRequest(t)).json();return{id:t,geom:n.geometry,...n.properties}}async loadDatasource(t,e={}){const n={datasource:t,parameters:e};return await this.query(n)}async closeSession(t=!1){this._currentSession&&(await this._currentSession.close(t),this._currentSession=null)}};cu([bi],Ns.prototype,"stageRequest");cu([bi],Ns.prototype,"query");let yd=Ns;var Mn={exports:{}},gd=Mn.exports,$o;function md(){return $o||($o=1,function(r,t){(function(e,n){r.exports=n()})(gd,function(){var e=1e3,n=6e4,o=36e5,i="millisecond",a="second",c="minute",f="hour",p="day",g="week",v="month",C="quarter",F="year",T="date",U="Invalid Date",M=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,k=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,P={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(z){var L=["th","st","nd","rd"],D=z%100;return"["+z+(L[(D-20)%10]||L[D]||L[0])+"]"}},R=function(z,L,D){var Y=String(z);return!Y||Y.length>=L?z:""+Array(L+1-Y.length).join(D)+z},V={s:R,z:function(z){var L=-z.utcOffset(),D=Math.abs(L),Y=Math.floor(D/60),Z=D%60;return(L<=0?"+":"-")+R(Y,2,"0")+":"+R(Z,2,"0")},m:function z(L,D){if(L.date()<D.date())return-z(D,L);var Y=12*(D.year()-L.year())+(D.month()-L.month()),Z=L.clone().add(Y,v),X=D-Z<0,K=L.clone().add(Y+(X?-1:1),v);return+(-(Y+(D-Z)/(X?Z-K:K-Z))||0)},a:function(z){return z<0?Math.ceil(z)||0:Math.floor(z)},p:function(z){return{M:v,y:F,w:g,d:p,D:T,h:f,m:c,s:a,ms:i,Q:C}[z]||String(z||"").toLowerCase().replace(/s$/,"")},u:function(z){return z===void 0}},G="en",A={};A[G]=P;var O="$isDayjsObject",m=function(z){return z instanceof N||!(!z||!z[O])},S=function z(L,D,Y){var Z;if(!L)return G;if(typeof L=="string"){var X=L.toLowerCase();A[X]&&(Z=X),D&&(A[X]=D,Z=X);var K=L.split("-");if(!Z&&K.length>1)return z(K[0])}else{var q=L.name;A[q]=L,Z=q}return!Y&&Z&&(G=Z),Z||!Y&&G},w=function(z,L){if(m(z))return z.clone();var D=typeof L=="object"?L:{};return D.date=z,D.args=arguments,new N(D)},B=V;B.l=S,B.i=m,B.w=function(z,L){return w(z,{locale:L.$L,utc:L.$u,x:L.$x,$offset:L.$offset})};var N=function(){function z(D){this.$L=S(D.locale,null,!0),this.parse(D),this.$x=this.$x||D.x||{},this[O]=!0}var L=z.prototype;return L.parse=function(D){this.$d=function(Y){var Z=Y.date,X=Y.utc;if(Z===null)return new Date(NaN);if(B.u(Z))return new Date;if(Z instanceof Date)return new Date(Z);if(typeof Z=="string"&&!/Z$/i.test(Z)){var K=Z.match(M);if(K){var q=K[2]-1||0,rt=(K[7]||"0").substring(0,3);return X?new Date(Date.UTC(K[1],q,K[3]||1,K[4]||0,K[5]||0,K[6]||0,rt)):new Date(K[1],q,K[3]||1,K[4]||0,K[5]||0,K[6]||0,rt)}}return new Date(Z)}(D),this.init()},L.init=function(){var D=this.$d;this.$y=D.getFullYear(),this.$M=D.getMonth(),this.$D=D.getDate(),this.$W=D.getDay(),this.$H=D.getHours(),this.$m=D.getMinutes(),this.$s=D.getSeconds(),this.$ms=D.getMilliseconds()},L.$utils=function(){return B},L.isValid=function(){return this.$d.toString()!==U},L.isSame=function(D,Y){var Z=w(D);return this.startOf(Y)<=Z&&Z<=this.endOf(Y)},L.isAfter=function(D,Y){return w(D)<this.startOf(Y)},L.isBefore=function(D,Y){return this.endOf(Y)<w(D)},L.$g=function(D,Y,Z){return B.u(D)?this[Y]:this.set(Z,D)},L.unix=function(){return Math.floor(this.valueOf()/1e3)},L.valueOf=function(){return this.$d.getTime()},L.startOf=function(D,Y){var Z=this,X=!!B.u(Y)||Y,K=B.p(D),q=function(y,_){var E=B.w(Z.$u?Date.UTC(Z.$y,_,y):new Date(Z.$y,_,y),Z);return X?E:E.endOf(p)},rt=function(y,_){return B.w(Z.toDate()[y].apply(Z.toDate("s"),(X?[0,0,0,0]:[23,59,59,999]).slice(_)),Z)},xt=this.$W,Ut=this.$M,Pt=this.$D,Zt="set"+(this.$u?"UTC":"");switch(K){case F:return X?q(1,0):q(31,11);case v:return X?q(1,Ut):q(0,Ut+1);case g:var Gt=this.$locale().weekStart||0,W=(xt<Gt?xt+7:xt)-Gt;return q(X?Pt-W:Pt+(6-W),Ut);case p:case T:return rt(Zt+"Hours",0);case f:return rt(Zt+"Minutes",1);case c:return rt(Zt+"Seconds",2);case a:return rt(Zt+"Milliseconds",3);default:return this.clone()}},L.endOf=function(D){return this.startOf(D,!1)},L.$set=function(D,Y){var Z,X=B.p(D),K="set"+(this.$u?"UTC":""),q=(Z={},Z[p]=K+"Date",Z[T]=K+"Date",Z[v]=K+"Month",Z[F]=K+"FullYear",Z[f]=K+"Hours",Z[c]=K+"Minutes",Z[a]=K+"Seconds",Z[i]=K+"Milliseconds",Z)[X],rt=X===p?this.$D+(Y-this.$W):Y;if(X===v||X===F){var xt=this.clone().set(T,1);xt.$d[q](rt),xt.init(),this.$d=xt.set(T,Math.min(this.$D,xt.daysInMonth())).$d}else q&&this.$d[q](rt);return this.init(),this},L.set=function(D,Y){return this.clone().$set(D,Y)},L.get=function(D){return this[B.p(D)]()},L.add=function(D,Y){var Z,X=this;D=Number(D);var K=B.p(Y),q=function(Ut){var Pt=w(X);return B.w(Pt.date(Pt.date()+Math.round(Ut*D)),X)};if(K===v)return this.set(v,this.$M+D);if(K===F)return this.set(F,this.$y+D);if(K===p)return q(1);if(K===g)return q(7);var rt=(Z={},Z[c]=n,Z[f]=o,Z[a]=e,Z)[K]||1,xt=this.$d.getTime()+D*rt;return B.w(xt,this)},L.subtract=function(D,Y){return this.add(-1*D,Y)},L.format=function(D){var Y=this,Z=this.$locale();if(!this.isValid())return Z.invalidDate||U;var X=D||"YYYY-MM-DDTHH:mm:ssZ",K=B.z(this),q=this.$H,rt=this.$m,xt=this.$M,Ut=Z.weekdays,Pt=Z.months,Zt=Z.meridiem,Gt=function(_,E,j,$){return _&&(_[E]||_(Y,X))||j[E].slice(0,$)},W=function(_){return B.s(q%12||12,_,"0")},y=Zt||function(_,E,j){var $=_<12?"AM":"PM";return j?$.toLowerCase():$};return X.replace(k,function(_,E){return E||function(j){switch(j){case"YY":return String(Y.$y).slice(-2);case"YYYY":return B.s(Y.$y,4,"0");case"M":return xt+1;case"MM":return B.s(xt+1,2,"0");case"MMM":return Gt(Z.monthsShort,xt,Pt,3);case"MMMM":return Gt(Pt,xt);case"D":return Y.$D;case"DD":return B.s(Y.$D,2,"0");case"d":return String(Y.$W);case"dd":return Gt(Z.weekdaysMin,Y.$W,Ut,2);case"ddd":return Gt(Z.weekdaysShort,Y.$W,Ut,3);case"dddd":return Ut[Y.$W];case"H":return String(q);case"HH":return B.s(q,2,"0");case"h":return W(1);case"hh":return W(2);case"a":return y(q,rt,!0);case"A":return y(q,rt,!1);case"m":return String(rt);case"mm":return B.s(rt,2,"0");case"s":return String(Y.$s);case"ss":return B.s(Y.$s,2,"0");case"SSS":return B.s(Y.$ms,3,"0");case"Z":return K}return null}(_)||K.replace(":","")})},L.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},L.diff=function(D,Y,Z){var X,K=this,q=B.p(Y),rt=w(D),xt=(rt.utcOffset()-this.utcOffset())*n,Ut=this-rt,Pt=function(){return B.m(K,rt)};switch(q){case F:X=Pt()/12;break;case v:X=Pt();break;case C:X=Pt()/3;break;case g:X=(Ut-xt)/6048e5;break;case p:X=(Ut-xt)/864e5;break;case f:X=Ut/o;break;case c:X=Ut/n;break;case a:X=Ut/e;break;default:X=Ut}return Z?X:B.a(X)},L.daysInMonth=function(){return this.endOf(v).$D},L.$locale=function(){return A[this.$L]},L.locale=function(D,Y){if(!D)return this.$L;var Z=this.clone(),X=S(D,Y,!0);return X&&(Z.$L=X),Z},L.clone=function(){return B.w(this.$d,this)},L.toDate=function(){return new Date(this.valueOf())},L.toJSON=function(){return this.isValid()?this.toISOString():null},L.toISOString=function(){return this.$d.toISOString()},L.toString=function(){return this.$d.toUTCString()},z}(),Q=N.prototype;return w.prototype=Q,[["$ms",i],["$s",a],["$m",c],["$H",f],["$W",p],["$M",v],["$y",F],["$D",T]].forEach(function(z){Q[z[1]]=function(L){return this.$g(L,z[0],z[1])}}),w.extend=function(z,L){return z.$i||(z(L,N,w),z.$i=!0),w},w.locale=S,w.isDayjs=m,w.unix=function(z){return w(1e3*z)},w.en=A[G],w.Ls=A,w.p={},w})}(Mn)),Mn.exports}var wd=md();const gr=Ts(wd);var Fn={exports:{}},bd=Fn.exports,zo;function _d(){return zo||(zo=1,function(r,t){(function(e,n){r.exports=n()})(bd,function(){var e,n,o=1e3,i=6e4,a=36e5,c=864e5,f=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,p=31536e6,g=2628e6,v=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/,C={years:p,months:g,days:c,hours:a,minutes:i,seconds:o,milliseconds:1,weeks:6048e5},F=function(A){return A instanceof V},T=function(A,O,m){return new V(A,m,O.$l)},U=function(A){return n.p(A)+"s"},M=function(A){return A<0},k=function(A){return M(A)?Math.ceil(A):Math.floor(A)},P=function(A){return Math.abs(A)},R=function(A,O){return A?M(A)?{negative:!0,format:""+P(A)+O}:{negative:!1,format:""+A+O}:{negative:!1,format:""}},V=function(){function A(m,S,w){var B=this;if(this.$d={},this.$l=w,m===void 0&&(this.$ms=0,this.parseFromMilliseconds()),S)return T(m*C[U(S)],this);if(typeof m=="number")return this.$ms=m,this.parseFromMilliseconds(),this;if(typeof m=="object")return Object.keys(m).forEach(function(z){B.$d[U(z)]=m[z]}),this.calMilliseconds(),this;if(typeof m=="string"){var N=m.match(v);if(N){var Q=N.slice(2).map(function(z){return z!=null?Number(z):0});return this.$d.years=Q[0],this.$d.months=Q[1],this.$d.weeks=Q[2],this.$d.days=Q[3],this.$d.hours=Q[4],this.$d.minutes=Q[5],this.$d.seconds=Q[6],this.calMilliseconds(),this}}return this}var O=A.prototype;return O.calMilliseconds=function(){var m=this;this.$ms=Object.keys(this.$d).reduce(function(S,w){return S+(m.$d[w]||0)*C[w]},0)},O.parseFromMilliseconds=function(){var m=this.$ms;this.$d.years=k(m/p),m%=p,this.$d.months=k(m/g),m%=g,this.$d.days=k(m/c),m%=c,this.$d.hours=k(m/a),m%=a,this.$d.minutes=k(m/i),m%=i,this.$d.seconds=k(m/o),m%=o,this.$d.milliseconds=m},O.toISOString=function(){var m=R(this.$d.years,"Y"),S=R(this.$d.months,"M"),w=+this.$d.days||0;this.$d.weeks&&(w+=7*this.$d.weeks);var B=R(w,"D"),N=R(this.$d.hours,"H"),Q=R(this.$d.minutes,"M"),z=this.$d.seconds||0;this.$d.milliseconds&&(z+=this.$d.milliseconds/1e3,z=Math.round(1e3*z)/1e3);var L=R(z,"S"),D=m.negative||S.negative||B.negative||N.negative||Q.negative||L.negative,Y=N.format||Q.format||L.format?"T":"",Z=(D?"-":"")+"P"+m.format+S.format+B.format+Y+N.format+Q.format+L.format;return Z==="P"||Z==="-P"?"P0D":Z},O.toJSON=function(){return this.toISOString()},O.format=function(m){var S=m||"YYYY-MM-DDTHH:mm:ss",w={Y:this.$d.years,YY:n.s(this.$d.years,2,"0"),YYYY:n.s(this.$d.years,4,"0"),M:this.$d.months,MM:n.s(this.$d.months,2,"0"),D:this.$d.days,DD:n.s(this.$d.days,2,"0"),H:this.$d.hours,HH:n.s(this.$d.hours,2,"0"),m:this.$d.minutes,mm:n.s(this.$d.minutes,2,"0"),s:this.$d.seconds,ss:n.s(this.$d.seconds,2,"0"),SSS:n.s(this.$d.milliseconds,3,"0")};return S.replace(f,function(B,N){return N||String(w[B])})},O.as=function(m){return this.$ms/C[U(m)]},O.get=function(m){var S=this.$ms,w=U(m);return w==="milliseconds"?S%=1e3:S=w==="weeks"?k(S/C[w]):this.$d[w],S||0},O.add=function(m,S,w){var B;return B=S?m*C[U(S)]:F(m)?m.$ms:T(m,this).$ms,T(this.$ms+B*(w?-1:1),this)},O.subtract=function(m,S){return this.add(m,S,!0)},O.locale=function(m){var S=this.clone();return S.$l=m,S},O.clone=function(){return T(this.$ms,this)},O.humanize=function(m){return e().add(this.$ms,"ms").locale(this.$l).fromNow(!m)},O.valueOf=function(){return this.asMilliseconds()},O.milliseconds=function(){return this.get("milliseconds")},O.asMilliseconds=function(){return this.as("milliseconds")},O.seconds=function(){return this.get("seconds")},O.asSeconds=function(){return this.as("seconds")},O.minutes=function(){return this.get("minutes")},O.asMinutes=function(){return this.as("minutes")},O.hours=function(){return this.get("hours")},O.asHours=function(){return this.as("hours")},O.days=function(){return this.get("days")},O.asDays=function(){return this.as("days")},O.weeks=function(){return this.get("weeks")},O.asWeeks=function(){return this.as("weeks")},O.months=function(){return this.get("months")},O.asMonths=function(){return this.as("months")},O.years=function(){return this.get("years")},O.asYears=function(){return this.as("years")},A}(),G=function(A,O,m){return A.add(O.years()*m,"y").add(O.months()*m,"M").add(O.days()*m,"d").add(O.hours()*m,"h").add(O.minutes()*m,"m").add(O.seconds()*m,"s").add(O.milliseconds()*m,"ms")};return function(A,O,m){e=m,n=m().$utils(),m.duration=function(B,N){var Q=m.locale();return T(B,{$l:Q},N)},m.isDuration=F;var S=O.prototype.add,w=O.prototype.subtract;O.prototype.add=function(B,N){return F(B)?G(this,B,1):S.bind(this)(B,N)},O.prototype.subtract=function(B,N){return F(B)?G(this,B,-1):w.bind(this)(B,N)}}})}(Fn)),Fn.exports}var Sd=_d();const Id=Ts(Sd);gr.extend(Id);const Bd=r=>{if(r instanceof Date)return gr(r).toISOString();if(r instanceof gr)return r.toISOString();if(r instanceof gr.duration)return r.toISOString();try{return gr.duration(r).toISOString()}catch{return gr(r).toISOString()}},vd=r=>{const t=r.times.map(e=>Bd(e));return{type:r.type||"range",times:t,resolution:r.resolution,resample:r.resample}};class Ad{datasource;parameters;description;variables;timefilter;geofilter;levelfilter;coordfilter;crs;aggregate;limit;id;constructor(t){this.datasource=t.datasource,this.parameters=t.parameters,this.description=t.description,this.variables=t.variables,this.timefilter=t.timefilter&&vd(t.timefilter),this.geofilter=t.geofilter,this.levelfilter=t.levelfilter,this.coordfilter=t.coordfilter,this.crs=t.crs,this.aggregate=t.aggregate,this.limit=t.limit,this.id=t.id}toJSON(){return{datasource:this.datasource,parameters:this.parameters,description:this.description,variables:this.variables,timefilter:this.timefilter,geofilter:this.geofilter,levelfilter:this.levelfilter,coordfilter:this.coordfilter,crs:this.crs,aggregate:this.aggregate,limit:this.limit,id:this.id}}}exports.Connector=yd;exports.DataVar=ui;exports.Dataset=Ge;exports.Query=Ad;exports.wkb_to_geojson=su;
19
+ `))}V.fill(0),o.createHash=function(w){return G(w)},o.createHmac=G,o.randomBytes=function(w,B){if(!B||!B.call)return new T(k(w));try{B.call(this,void 0,new T(k(w)))}catch(N){B(N)}};var O,m=["createCredentials","createCipher","createCipheriv","createDecipher","createDecipheriv","createSign","createVerify","createDiffieHellman","pbkdf2"],S=function(w){o[w]=function(){A("sorry,",w,"is not implemented yet")}};for(O in m)S(m[O])}).call(this,e("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/index.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./md5":6,"./rng":7,"./sha":8,"./sha256":9,buffer:3,lYpoI2:11}],6:[function(e,n,o){(function(i,a,c,f,p,g,v,C,F){var T=e("./helpers");function U(A,O){A[O>>5]|=128<<O%32,A[14+(O+64>>>9<<4)]=O;for(var m=1732584193,S=-271733879,w=-1732584194,B=271733878,N=0;N<A.length;N+=16){var Q=m,z=S,L=w,D=B,m=k(m,S,w,B,A[N+0],7,-680876936),B=k(B,m,S,w,A[N+1],12,-389564586),w=k(w,B,m,S,A[N+2],17,606105819),S=k(S,w,B,m,A[N+3],22,-1044525330);m=k(m,S,w,B,A[N+4],7,-176418897),B=k(B,m,S,w,A[N+5],12,1200080426),w=k(w,B,m,S,A[N+6],17,-1473231341),S=k(S,w,B,m,A[N+7],22,-45705983),m=k(m,S,w,B,A[N+8],7,1770035416),B=k(B,m,S,w,A[N+9],12,-1958414417),w=k(w,B,m,S,A[N+10],17,-42063),S=k(S,w,B,m,A[N+11],22,-1990404162),m=k(m,S,w,B,A[N+12],7,1804603682),B=k(B,m,S,w,A[N+13],12,-40341101),w=k(w,B,m,S,A[N+14],17,-1502002290),m=P(m,S=k(S,w,B,m,A[N+15],22,1236535329),w,B,A[N+1],5,-165796510),B=P(B,m,S,w,A[N+6],9,-1069501632),w=P(w,B,m,S,A[N+11],14,643717713),S=P(S,w,B,m,A[N+0],20,-373897302),m=P(m,S,w,B,A[N+5],5,-701558691),B=P(B,m,S,w,A[N+10],9,38016083),w=P(w,B,m,S,A[N+15],14,-660478335),S=P(S,w,B,m,A[N+4],20,-405537848),m=P(m,S,w,B,A[N+9],5,568446438),B=P(B,m,S,w,A[N+14],9,-1019803690),w=P(w,B,m,S,A[N+3],14,-187363961),S=P(S,w,B,m,A[N+8],20,1163531501),m=P(m,S,w,B,A[N+13],5,-1444681467),B=P(B,m,S,w,A[N+2],9,-51403784),w=P(w,B,m,S,A[N+7],14,1735328473),m=R(m,S=P(S,w,B,m,A[N+12],20,-1926607734),w,B,A[N+5],4,-378558),B=R(B,m,S,w,A[N+8],11,-2022574463),w=R(w,B,m,S,A[N+11],16,1839030562),S=R(S,w,B,m,A[N+14],23,-35309556),m=R(m,S,w,B,A[N+1],4,-1530992060),B=R(B,m,S,w,A[N+4],11,1272893353),w=R(w,B,m,S,A[N+7],16,-155497632),S=R(S,w,B,m,A[N+10],23,-1094730640),m=R(m,S,w,B,A[N+13],4,681279174),B=R(B,m,S,w,A[N+0],11,-358537222),w=R(w,B,m,S,A[N+3],16,-722521979),S=R(S,w,B,m,A[N+6],23,76029189),m=R(m,S,w,B,A[N+9],4,-640364487),B=R(B,m,S,w,A[N+12],11,-421815835),w=R(w,B,m,S,A[N+15],16,530742520),m=V(m,S=R(S,w,B,m,A[N+2],23,-995338651),w,B,A[N+0],6,-198630844),B=V(B,m,S,w,A[N+7],10,1126891415),w=V(w,B,m,S,A[N+14],15,-1416354905),S=V(S,w,B,m,A[N+5],21,-57434055),m=V(m,S,w,B,A[N+12],6,1700485571),B=V(B,m,S,w,A[N+3],10,-1894986606),w=V(w,B,m,S,A[N+10],15,-1051523),S=V(S,w,B,m,A[N+1],21,-2054922799),m=V(m,S,w,B,A[N+8],6,1873313359),B=V(B,m,S,w,A[N+15],10,-30611744),w=V(w,B,m,S,A[N+6],15,-1560198380),S=V(S,w,B,m,A[N+13],21,1309151649),m=V(m,S,w,B,A[N+4],6,-145523070),B=V(B,m,S,w,A[N+11],10,-1120210379),w=V(w,B,m,S,A[N+2],15,718787259),S=V(S,w,B,m,A[N+9],21,-343485551),m=G(m,Q),S=G(S,z),w=G(w,L),B=G(B,D)}return Array(m,S,w,B)}function M(A,O,m,S,w,B){return G((O=G(G(O,A),G(S,B)))<<w|O>>>32-w,m)}function k(A,O,m,S,w,B,N){return M(O&m|~O&S,A,O,w,B,N)}function P(A,O,m,S,w,B,N){return M(O&S|m&~S,A,O,w,B,N)}function R(A,O,m,S,w,B,N){return M(O^m^S,A,O,w,B,N)}function V(A,O,m,S,w,B,N){return M(m^(O|~S),A,O,w,B,N)}function G(A,O){var m=(65535&A)+(65535&O);return(A>>16)+(O>>16)+(m>>16)<<16|65535&m}n.exports=function(A){return T.hash(A,U,16)}}).call(this,e("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/md5.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],7:[function(e,n,o){(function(i,a,c,f,p,g,v,C,F){n.exports=function(T){for(var U,M=new Array(T),k=0;k<T;k++)(3&k)==0&&(U=4294967296*Math.random()),M[k]=U>>>((3&k)<<3)&255;return M}}).call(this,e("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/rng.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{buffer:3,lYpoI2:11}],8:[function(e,n,o){(function(i,a,c,f,p,g,v,C,F){var T=e("./helpers");function U(P,R){P[R>>5]|=128<<24-R%32,P[15+(R+64>>9<<4)]=R;for(var V,G,A,O=Array(80),m=1732584193,S=-271733879,w=-1732584194,B=271733878,N=-1009589776,Q=0;Q<P.length;Q+=16){for(var z=m,L=S,D=w,Y=B,Z=N,X=0;X<80;X++){O[X]=X<16?P[Q+X]:k(O[X-3]^O[X-8]^O[X-14]^O[X-16],1);var K=M(M(k(m,5),(K=S,G=w,A=B,(V=X)<20?K&G|~K&A:!(V<40)&&V<60?K&G|K&A|G&A:K^G^A)),M(M(N,O[X]),(V=X)<20?1518500249:V<40?1859775393:V<60?-1894007588:-899497514)),N=B,B=w,w=k(S,30),S=m,m=K}m=M(m,z),S=M(S,L),w=M(w,D),B=M(B,Y),N=M(N,Z)}return Array(m,S,w,B,N)}function M(P,R){var V=(65535&P)+(65535&R);return(P>>16)+(R>>16)+(V>>16)<<16|65535&V}function k(P,R){return P<<R|P>>>32-R}n.exports=function(P){return T.hash(P,U,20,!0)}}).call(this,e("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/sha.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],9:[function(e,n,o){(function(i,a,c,f,p,g,v,C,F){function T(R,V){var G=(65535&R)+(65535&V);return(R>>16)+(V>>16)+(G>>16)<<16|65535&G}function U(R,V){var G,A=new Array(1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298),O=new Array(1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225),m=new Array(64);R[V>>5]|=128<<24-V%32,R[15+(V+64>>9<<4)]=V;for(var S,w,B=0;B<R.length;B+=16){for(var N=O[0],Q=O[1],z=O[2],L=O[3],D=O[4],Y=O[5],Z=O[6],X=O[7],K=0;K<64;K++)m[K]=K<16?R[K+B]:T(T(T((w=m[K-2],k(w,17)^k(w,19)^P(w,10)),m[K-7]),(w=m[K-15],k(w,7)^k(w,18)^P(w,3))),m[K-16]),G=T(T(T(T(X,k(w=D,6)^k(w,11)^k(w,25)),D&Y^~D&Z),A[K]),m[K]),S=T(k(S=N,2)^k(S,13)^k(S,22),N&Q^N&z^Q&z),X=Z,Z=Y,Y=D,D=T(L,G),L=z,z=Q,Q=N,N=T(G,S);O[0]=T(N,O[0]),O[1]=T(Q,O[1]),O[2]=T(z,O[2]),O[3]=T(L,O[3]),O[4]=T(D,O[4]),O[5]=T(Y,O[5]),O[6]=T(Z,O[6]),O[7]=T(X,O[7])}return O}var M=e("./helpers"),k=function(R,V){return R>>>V|R<<32-V},P=function(R,V){return R>>>V};n.exports=function(R){return M.hash(R,U,32,!0)}}).call(this,e("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/sha256.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],10:[function(e,n,o){(function(i,a,c,f,p,g,v,C,F){o.read=function(T,U,M,k,B){var R,V,G=8*B-k-1,A=(1<<G)-1,O=A>>1,m=-7,S=M?B-1:0,w=M?-1:1,B=T[U+S];for(S+=w,R=B&(1<<-m)-1,B>>=-m,m+=G;0<m;R=256*R+T[U+S],S+=w,m-=8);for(V=R&(1<<-m)-1,R>>=-m,m+=k;0<m;V=256*V+T[U+S],S+=w,m-=8);if(R===0)R=1-O;else{if(R===A)return V?NaN:1/0*(B?-1:1);V+=Math.pow(2,k),R-=O}return(B?-1:1)*V*Math.pow(2,R-k)},o.write=function(T,U,M,k,P,N){var V,G,A=8*N-P-1,O=(1<<A)-1,m=O>>1,S=P===23?Math.pow(2,-24)-Math.pow(2,-77):0,w=k?0:N-1,B=k?1:-1,N=U<0||U===0&&1/U<0?1:0;for(U=Math.abs(U),isNaN(U)||U===1/0?(G=isNaN(U)?1:0,V=O):(V=Math.floor(Math.log(U)/Math.LN2),U*(k=Math.pow(2,-V))<1&&(V--,k*=2),2<=(U+=1<=V+m?S/k:S*Math.pow(2,1-m))*k&&(V++,k/=2),O<=V+m?(G=0,V=O):1<=V+m?(G=(U*k-1)*Math.pow(2,P),V+=m):(G=U*Math.pow(2,m-1)*Math.pow(2,P),V=0));8<=P;T[M+w]=255&G,w+=B,G/=256,P-=8);for(V=V<<P|G,A+=P;0<A;T[M+w]=255&V,w+=B,V/=256,A-=8);T[M+w-B]|=128*N}}).call(this,e("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/ieee754/index.js","/node_modules/gulp-browserify/node_modules/ieee754")},{buffer:3,lYpoI2:11}],11:[function(e,n,o){(function(i,a,c,f,p,g,v,C,F){var T,U,M;function k(){}(i=n.exports={}).nextTick=(U=typeof window<"u"&&window.setImmediate,M=typeof window<"u"&&window.postMessage&&window.addEventListener,U?function(P){return window.setImmediate(P)}:M?(T=[],window.addEventListener("message",function(P){var R=P.source;R!==window&&R!==null||P.data!=="process-tick"||(P.stopPropagation(),0<T.length&&T.shift()())},!0),function(P){T.push(P),window.postMessage("process-tick","*")}):function(P){setTimeout(P,0)}),i.title="browser",i.browser=!0,i.env={},i.argv=[],i.on=k,i.addListener=k,i.once=k,i.off=k,i.removeListener=k,i.removeAllListeners=k,i.emit=k,i.binding=function(P){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(P){throw new Error("process.chdir is not supported")}}).call(this,e("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/process/browser.js","/node_modules/gulp-browserify/node_modules/process")},{buffer:3,lYpoI2:11}]},{},[1])(1)})}(ki)),ki.exports}var Jf=Yf();const Hf=Ts(Jf);function qf(r){return new Promise(t=>setTimeout(t,r))}class Kf{cache;url;params;cache_prefix;fetchOptions;timeout;_pending={};constructor(t,e,n={}){const o={...e};n.parameters&&(o["x-parameters"]=JSON.stringify(n.parameters)),n.chunks&&(o["x-chunks"]=n.chunks),n.downsample&&(o["x-downsample"]=JSON.stringify(n.downsample)),o["x-filtered"]="True",this.params={},e["x-datamesh-auth"]&&(this.params.auth=e["x-datamesh-auth"]),e["x-datamesh-sig"]&&(this.params.sig=e["x-datamesh-sig"]),this.fetchOptions={headers:o},this.url=t;const i=t.split("/").pop();n.nocache||typeof window>"u"?this.cache=void 0:this.cache=iu("zarr","cache"),this.cache_prefix=Hf({datasource:i,...n.parameters,chunks:n.chunks,downsample:n.downsample}),this.timeout=n.timeout||6e4}async get(t,e,n=0){const o=`${this.cache_prefix}${t}`;let i=null;if(this.cache&&(i=await Zf(o,this.cache),i&&delete this._pending[o],this._pending[o]))if(await qf(200),n>this.timeout){await Ni(o,this.cache),delete this._pending[o],console.error("Zarr timeout");return}else return await this.get(t,e,n+200);if(!i){this._pending[o]=!0;try{const a={...this.fetchOptions,...e,headers:{...this.fetchOptions.headers||{},...e?.headers||{}},signal:AbortSignal.timeout(this.timeout)},c=new URLSearchParams(this.params).toString(),f=await fetch(`${this.url}${t}?${c}`,a);if(f.status===404){this.cache&&await Ni(o,this.cache);return}if(f.status>=400)throw new Error(`HTTP error: ${f.status}`);i=new Uint8Array(await f.arrayBuffer()),this.cache&&await Gf(o,i,this.cache)}catch(a){if(console.debug("Zarr retry:"+o),n<this.timeout/200)return delete this._pending[o],await this.get(t,e,n+200);this.cache&&await Ni(o,this.cache),console.error(a);return}finally{delete this._pending[o]}}return i}}const Po=async(r,t=".zarray")=>{const{path:e}=r.resolve(t),n=await r.store.get(e);return n?JSON.parse(new TextDecoder().decode(n)):{}};async function Xf(r){const t=await Po(r,".zattrs"),e=await Po(r);e.dtype.startsWith("<M8")&&(t._dtype=e.dtype);const n=[];e.order==="F"&&n.push({name:"transpose",configuration:{order:"F"}}),typeof e.dtype=="string"&&e.dtype.startsWith(">")&&n.push({name:"bytes",configuration:{endian:"big"}});for(const{id:i,...a}of e.filters??[])n.push({name:i,configuration:a});if(e.compressor){const{id:i,...a}=e.compressor;n.push({name:i,configuration:a})}const o={zarr_format:3,node_type:"array",shape:e.shape,data_type:"int64",chunk_grid:{name:"regular",configuration:{chunk_shape:e.chunks}},chunk_key_encoding:{name:"v2",configuration:{separator:e.dimension_separator??"."}},codecs:n,fill_value:e.fill_value,attributes:t};return new Br(r.store,r.path,o)}function bi(r,t,e){const n=e.value;return e.value=async function(...o){const i=Date.now(),a=await n.apply(this,o),f=Date.now()-i;return console.debug(`${t} took ${f}ms`),a},e}var Qf=Object.defineProperty,td=Object.getOwnPropertyDescriptor,ed=(r,t,e,n)=>{for(var o=td(t,e),i=r.length-1,a;i>=0;i--)(a=r[i])&&(o=a(t,e,o)||o);return o&&Qf(t,e,o),o};const su=r=>{const t=new nu.Buffer(r,"base64");return Vf.Geometry.parse(t).toGeoJSON()},ci=r=>r&&(Array.isArray(r)||ArrayBuffer.isView(r)),rd=r=>{const t=[];if(!ci(r))return t;for(;t.push(r.length),ci(r[0]);)r=r[0];return t},nd=r=>{for(;Array.isArray(r);)r=r[0];if(r==null)return"uint8";switch(r.constructor.name){case"Boolean":return"bool";case"Number":return"float32";case"Int8Array":return"int8";case"Int16Array":return"int16";case"Int32Array":return"int32";case"BigInt64Array":return"int64";case"Uint8Array":return"uint8";case"Uint16Array":return"uint16";case"Uint32Array":return"uint32";case"Float32Array":return"float32";case"Float64Array":return"float64";case"String":return"v2:object";case"Object":return"v2:object"}throw new Error("Unsupported data type: "+r.constructor.name)},id=r=>{let t=r.toString().toLowerCase();return r.typeId==5?t="v2:object":r.typeId==1&&(t="uint8"),t},sd=r=>{if(!Array.isArray(r))return r;const t=r.flat(1/0);if(ci(t[0])){const e=t[0].length,n=new t[0].constructor(t.length*e);for(let o=0;o<t.length;o++)n.set(t[o],o*e);return n}else return t},od=r=>{const t=r.length,e=Array(t);for(let n=t-1,o=1;n>=0;n--)e[n]=o,o*=r[n];return e},Fs=(r,t,e,n=0)=>{if(t.length===0)return r[0];if(t.length===1){const i=new r.constructor(t[0]);return i.set(r.slice(n,n+t[0])),i}const o=new Array(t[0]);for(let i=0;i<t[0];i++)o[i]=Fs(r,t.slice(1),e.slice(1),n+i*e[0]);return o},ad=(r,t)=>{const[e,n]=t.split("<M8"),o=new Float64Array(r.data.length);let i=1n;switch(n){case"[ms]":i=1000n;break;case"[us]":i=1000000n;break;case"[ns]":i=1000000000n;break;default:i=1n;break}for(let a=0;a<r.data.length;a++){const c=r.data[a];o[a]=Number(c/i)}return Fs(o,r.shape,r.stride)},ou=(r,t,e)=>{const n=Object.keys(t),o={};for(const i in r)ci(r[i].data)&&(o[i]=!0);if(n.length==1)for(let i=0;i<t[n[0]];i++){const a={};for(const c in r)o[c]?r[c].data.length>1&&(a[c]=r[c].data[i]):a[c]=r[c].data;e.push(a)}else for(let i=0;i<t[n[0]];i++){const a={};for(const f in r)r[f].dimensions.includes(n[0])?a[f]={attributes:r[f].attributes,data:r[f].data[i],dimensions:r[f].dimensions.slice(1)}:a[f]=r[f];const c={...t};delete c[n[0]],ou(a,c,e)}return e};class ui{id;dimensions;attributes;arr;constructor(t,e,n,o){this.id=t,this.dimensions=e,this.attributes=n,this.arr=o}async get(t){if(this.arr.shape.length==0||this.arr.shape[0]==0)return[];const e=t&&t.map(o=>{if(typeof o=="string"){const[i,a,c]=o.split(":");return Ui(parseInt(i),parseInt(a),parseInt(c))}else return o}),n=await ih(this.arr,e);if(this.arr.dtype=="v2:object"||!n.shape)return n.data;if(this.arr.dtype=="bool")return[...n.data];{const o=this.arr.attrs._dtype;return o?.startsWith("<M8")?ad(n,o):Fs(n.data,n.shape,n.stride)}}}ed([bi],ui.prototype,"get");class Ge{dimensions;variables;attributes;coordkeys;root;constructor(t,e,n,o,i){this.dimensions=t,this.variables=e,this.attributes=n,this.coordkeys=o,this.root=i}static async zarr(t,e,n={}){const o=new Kf(t,e,{chunks:n.chunks,downsample:n.downsample,parameters:n.parameters,timeout:n.timeout,nocache:n.nocache}),i=await $u(o),a=await Ze(i,{kind:"group"}),c={},f={};for(const g of i.contents())if(g.kind=="array"){let v;try{v=await Ze(a.resolve(g.path),{kind:"array"})}catch(T){const U=typeof T=="object"&&T&&"message"in T?String(T.message):void 0;if(U&&U.includes("<M8"))v=await Xf(a.resolve(g.path));else throw T}const C=v.attrs._ARRAY_DIMENSIONS,F=g.path.split("/").pop();c[F]=new ui(F,C||[],v.attrs,v),C&&C.map((T,U)=>{const M=v.shape[U];if(f[T]&&f[T]!=M)throw new Error(`Inconsistent dimension size for ${T}: ${f[T]} != ${M}`);f[T]=M})}const p=JSON.parse(a.attrs._coordinates)||{};return new Ge(f,c,a.attrs,n.coordkeys||p,a)}static async fromArrow(t,e){const n={},o={record:t.numRows},i={};return t.schema.fields.forEach(a=>{const c=t.getChild(a.name);let f={},p=c?.toArray(),g=id(a.type);if(tt.isTimestamp(a.type)){const v=new Float64Array(p.length),C=BigInt(1e3**(a.type.unit-0));for(let F=0;F<p.length;F++)v[F]=Number(p[F]/C);p=v,g="float64",f={unit:"Unix timestamp (s)"}}else if(tt.isBinary(a.type)){const v=[];for(let C=0;C<p.length;C++)v.push(new nu.Buffer(p[C]).toString("base64"));p=v,g="v2:object"}i[a.name]={dimensions:["record"],attributes:f,data:p,dtype:g}}),await Ge.init({dimensions:o,variables:i,attributes:n},e)}static async fromGeojson(t,e){if(!("features"in t&&Array.isArray(t.features))&&!("geometry"in t))throw new Error("Invalid GeoJSON");const n="features"in t&&t.features?t.features:[t];if(n.length===0)throw new Error("FeatureCollection contains no features");const o=new Set;n.forEach(f=>{f.properties&&Object.keys(f.properties).forEach(p=>o.add(p))});const i=n.map(f=>{const p={geometry:f.geometry};return f.properties&&Object.assign(p,f.properties),p}),a={dimensions:{index:i.length},variables:{},attributes:{}},c=await Ge.init(a,{...e,g:"geometry"});await c.assign("geometry",["index"],i.map(f=>f.geometry),{description:"GeoJSON geometry"});for(const f of o){const p=i.map(g=>g[f]);await c.assign(f,["index"],p,{description:`Property: ${f}`})}return c}static async init(t,e){const n=await js(new Map,{attributes:{created:new Date}}),o=new Ge(t.dimensions,{},t.attributes||{},e||{},n);for(const i in t.variables){const{dimensions:a,attributes:c,data:f,dtype:p}=t.variables[i];await o.assign(i,a,f,c,p&&p==="string"?"v2:object":p)}return o}async asDataframe(){const t={},e=[];for(const o in this.variables)t[o]={attributes:this.variables[o].attributes,dimensions:this.variables[o].dimensions},t[o].data=await this.variables[o].get(),this.variables[o].arr.dtype=="int64"&&e.push(o);const n=ou(t,{...this.dimensions},[]);if(this.coordkeys.t)for(let o=0;o<n.length;o++)n[o][this.coordkeys.t]=new Date(1e3*n[o][this.coordkeys.t]).toISOString();if(e.length>0)for(const o of e)for(let i=0;i<n.length;i++)n[i][o]=Number(n[i][o]);return n}async asGeojson(t){if(!this.coordkeys.g&&!t)throw new Error("No geometry found");const e=[],n=await this.asDataframe();for(let o=0;o<n.length;o++){const{...i}=n[o];let a=t;if(!a&&this.coordkeys.g){delete i[this.coordkeys.g];const c=n[o][this.coordkeys.g];c.slice(0,7)=='{"type:'?a=JSON.parse(c):a=su(c)}e.push({type:"Feature",geometry:a,properties:i})}return{type:"FeatureCollection",features:e}}async assign(t,e,n,o,i,a){const c=rd(n);if(c.length!=e.length)throw new Error("Data shape does not match dimensions");e.map((v,C)=>{if(this.dimensions[v]){if(this.dimensions[v]!=c[C])throw new Error(`Existing size of dimension ${v} does not match new data`)}else this.dimensions[v]=c[C]});const f=i||nd(n),p=await js(this.root.resolve(t),{shape:c,data_type:f,chunk_shape:a||c,codecs:f=="v2:object"?[{name:"json2"}]:[]});let g=sd(n);g.length==0?g=null:f=="bool"?g=new qi(g):Array.isArray(g)&&f=="float32"?g=Float32Array.from(g,v=>v??NaN):Array.isArray(g)&&f=="float64"?g=Float64Array.from(g,v=>v??NaN):Array.isArray(g)&&f=="int8"?g=Int8Array.from(g):Array.isArray(g)&&f=="int16"?g=Int16Array.from(g):Array.isArray(g)&&f=="int32"?g=Int32Array.from(g):Array.isArray(g)&&f=="int64"?g=BigInt64Array.from(g.map(v=>BigInt(v))):Array.isArray(g)&&f=="uint8"?g=Uint8Array.from(g):Array.isArray(g)&&f=="uint16"?g=Uint16Array.from(g):Array.isArray(g)&&f=="uint32"?g=Uint32Array.from(g):Array.isArray(g)&&f=="uint64"&&(g=BigUint64Array.from(g.map(v=>BigInt(v)))),g&&await sh(p,c.map(()=>null),{data:g,shape:c,stride:od(c)}),this.variables[t]=new ui(t,e,o||{},p)}}var cd=Object.defineProperty,ud=Object.getOwnPropertyDescriptor,hd=(r,t,e,n)=>{for(var o=ud(t,e),i=r.length-1,a;i>=0;i--)(a=r[i])&&(o=a(t,e,o)||o);return o&&cd(t,e,o),o};const au=class Hi{id;user;creationTime;endTime;write;verified=!1;_connection;static async acquire(t,e={}){if(!t._isV1){const n=new Hi;return n.id="dummy_session",n.user="dummy_user",n.creationTime=new Date,n.endTime=new Date(Date.now()+(e.duration||3600)*1e3),n.write=!1,n.verified=!1,n._connection=t,typeof process<"u"&&process.on&&process.on("beforeExit",()=>{n.close()}),n}try{const n={...t._authHeaders};n["Cache-Control"]="no-store";const o=new URLSearchParams({duration:String(e.duration??3600)}),i=await fetch(`${t._gateway}/session/?${o.toString()}`,{headers:n});if(i.status!==200)throw new Error(`Failed to create session: ${await i.text()}`);const a=await i.json(),c=new Hi;return c.id=a.id,c.user=a.user,c.creationTime=new Date(a.creation_time),c.endTime=new Date(a.end_time),c.write=a.write,c.verified=a.verified||!1,c._connection=t,typeof process<"u"&&process.on&&process.on("beforeExit",()=>{c.close()}),c}catch(n){throw new Error(`Error when acquiring datamesh session: ${n}`)}}get header(){return{"X-DATAMESH-SESSIONID":this.id}}addHeader(t){return{...t,...this.header}}async close(t=!1){if(this._connection._isV1)try{typeof process<"u"&&process.off&&process.off("beforeExit",this.close);const e=await fetch(`${this._connection._gateway}/session/${this.id}`,{method:"DELETE",headers:this.header,body:JSON.stringify({finalise_write:t})});if(e.status!==204){if(t)throw new Error(`Failed to finalise write: ${await e.text()}`);console.warn(`Failed to close session: ${await e.text()}`)}}catch(e){if(t)throw new Error(`Error when closing datamesh session: ${e}`);console.warn(`Error when closing datamesh session: ${e}`)}}async enter(){return this}async exit(t){await this.close(t===void 0)}};hd([bi],au,"acquire");let ld=au;var fd=Object.defineProperty,dd=Object.getOwnPropertyDescriptor,cu=(r,t,e,n)=>{for(var o=dd(t,e),i=r.length-1,a;i>=0;i--)(a=r[i])&&(o=a(t,e,o)||o);return o&&fd(t,e,o),o};const pd=typeof process<"u"&&process.env?.DATAMESH_SERVICE?process.env.DATAMESH_SERVICE:"https://datamesh.oceanum.io",Ns=class uu{static LAZY_LOAD_SIZE=1e8;_token;_host;_authHeaders;_gateway;_nocache=!1;_isV1=!1;_sessionParams={};_currentSession=null;service;gateway;constructor(t=typeof process<"u"&&process.env?.DATAMESH_TOKEN?process.env.DATAMESH_TOKEN:"$DATAMESH_TOKEN",e){if(!t&&!e?.jwtAuth)throw new Error("A valid datamesh token must be supplied as a connector constructor argument or defined in environment variables as DATAMESH_TOKEN");this._token=t,this._nocache=e?.nocache??!1;const n=new URL(e?.service||pd);this._host=`${n.protocol}//${n.hostname}`,this._authHeaders=e?.jwtAuth?{Authorization:`Bearer ${e.jwtAuth}`}:{Authorization:`Token ${this._token}`,"X-DATAMESH-TOKEN":this._token},this._gateway=e?.gateway||this._host,this._host.split(".").slice(-1)[0]!==this._gateway.split(".").slice(-1)[0]&&console.warn("Datamesh gateway and service domains do not match"),e?.sessionDuration&&typeof e.sessionDuration=="number"&&(this._sessionParams={duration:e.sessionDuration}),this._checkApiVersion()}async _checkApiVersion(){try{(await fetch(`${this._gateway}/session`,{headers:this._authHeaders})).status===200?(this._isV1=!0,console.info("Using datamesh API version 1")):(this._isV1=!1,console.info("Using datamesh API version 0"))}catch{this._isV1=!1,console.info("Using datamesh API version 0")}}get host(){return this._host}async status(){return(await fetch(this._host,{headers:this._authHeaders})).status===200}async validateResponse(t){if(t.status>=400){let e;try{e=(await t.json()).detail}catch{e=`Datamesh server error: ${await t.text()}`}throw new Error(e)}}async createSession(t={}){const e={duration:t.duration||this._sessionParams.duration||1};return this._currentSession=await ld.acquire(this,e),this._currentSession}async getSession(){return this._currentSession?this._currentSession:this.createSession()}async getSessionHeaders(t={}){return this._isV1&&!this._currentSession&&await this.createSession(),this._currentSession?this._currentSession.addHeader({...this._authHeaders,...t}):{...this._authHeaders,...t}}async metadataRequest(t="",e={}){const n=new URL(`${this._host}/datasource/${t}`);Object.keys(e).forEach(a=>n.searchParams.append(a,e[a]));const o=await this.getSessionHeaders(),i=await fetch(n.toString(),{headers:o});if(i.status===403)throw new Error(`Datasource ${t} not authorized`);return await this.validateResponse(i),i}async dataRequest(t,e="application/vnd.apache.arrow.file"){const n=await this.getSessionHeaders({Accept:e}),o=await fetch(`${this._gateway}/oceanql/${t}?f=arrow`,{headers:n});return await this.validateResponse(o),Xc(await o.arrayBuffer())}async stageRequest(t){const e=JSON.stringify(t),n=await this.getSessionHeaders({"Content-Type":"application/json"}),o=await fetch(`${this._gateway}/oceanql/stage/`,{method:"POST",headers:n,body:e});if(o.status>=400){const i=await o.json();throw new Error(i.detail)}else return o.status===204?null:o.json()}async query(t,e={}){const n=await this.stageRequest(t);if(!n)return console.warn("No data found for query"),null;if(n.size<uu.LAZY_LOAD_SIZE&&n.container!="dataset"){const f=await this.dataRequest(n.qhash);return await Ge.fromArrow(f,n.coordkeys)}const o=`${this._gateway}/zarr/${this._isV1?"query/":""}${n.qhash}`,i=t.parameters,a=await this.getSessionHeaders(),c=await Ge.zarr(o,a,{parameters:i,timeout:e.timeout||6e4,nocache:this._nocache});if(t.variables)for(const f of Object.keys(c.variables))!t.variables.includes(f)&&!Object.values(c.coordkeys).includes(f)&&delete c.variables[f];return c}async getDatasource(t){const n=await(await this.metadataRequest(t)).json();return{id:t,geom:n.geometry,...n.properties}}async loadDatasource(t,e={}){const n={datasource:t,parameters:e};return await this.query(n)}async closeSession(t=!1){this._currentSession&&(await this._currentSession.close(t),this._currentSession=null)}};cu([bi],Ns.prototype,"stageRequest");cu([bi],Ns.prototype,"query");let yd=Ns;var Mn={exports:{}},gd=Mn.exports,$o;function md(){return $o||($o=1,function(r,t){(function(e,n){r.exports=n()})(gd,function(){var e=1e3,n=6e4,o=36e5,i="millisecond",a="second",c="minute",f="hour",p="day",g="week",v="month",C="quarter",F="year",T="date",U="Invalid Date",M=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,k=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,P={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(z){var L=["th","st","nd","rd"],D=z%100;return"["+z+(L[(D-20)%10]||L[D]||L[0])+"]"}},R=function(z,L,D){var Y=String(z);return!Y||Y.length>=L?z:""+Array(L+1-Y.length).join(D)+z},V={s:R,z:function(z){var L=-z.utcOffset(),D=Math.abs(L),Y=Math.floor(D/60),Z=D%60;return(L<=0?"+":"-")+R(Y,2,"0")+":"+R(Z,2,"0")},m:function z(L,D){if(L.date()<D.date())return-z(D,L);var Y=12*(D.year()-L.year())+(D.month()-L.month()),Z=L.clone().add(Y,v),X=D-Z<0,K=L.clone().add(Y+(X?-1:1),v);return+(-(Y+(D-Z)/(X?Z-K:K-Z))||0)},a:function(z){return z<0?Math.ceil(z)||0:Math.floor(z)},p:function(z){return{M:v,y:F,w:g,d:p,D:T,h:f,m:c,s:a,ms:i,Q:C}[z]||String(z||"").toLowerCase().replace(/s$/,"")},u:function(z){return z===void 0}},G="en",A={};A[G]=P;var O="$isDayjsObject",m=function(z){return z instanceof N||!(!z||!z[O])},S=function z(L,D,Y){var Z;if(!L)return G;if(typeof L=="string"){var X=L.toLowerCase();A[X]&&(Z=X),D&&(A[X]=D,Z=X);var K=L.split("-");if(!Z&&K.length>1)return z(K[0])}else{var q=L.name;A[q]=L,Z=q}return!Y&&Z&&(G=Z),Z||!Y&&G},w=function(z,L){if(m(z))return z.clone();var D=typeof L=="object"?L:{};return D.date=z,D.args=arguments,new N(D)},B=V;B.l=S,B.i=m,B.w=function(z,L){return w(z,{locale:L.$L,utc:L.$u,x:L.$x,$offset:L.$offset})};var N=function(){function z(D){this.$L=S(D.locale,null,!0),this.parse(D),this.$x=this.$x||D.x||{},this[O]=!0}var L=z.prototype;return L.parse=function(D){this.$d=function(Y){var Z=Y.date,X=Y.utc;if(Z===null)return new Date(NaN);if(B.u(Z))return new Date;if(Z instanceof Date)return new Date(Z);if(typeof Z=="string"&&!/Z$/i.test(Z)){var K=Z.match(M);if(K){var q=K[2]-1||0,rt=(K[7]||"0").substring(0,3);return X?new Date(Date.UTC(K[1],q,K[3]||1,K[4]||0,K[5]||0,K[6]||0,rt)):new Date(K[1],q,K[3]||1,K[4]||0,K[5]||0,K[6]||0,rt)}}return new Date(Z)}(D),this.init()},L.init=function(){var D=this.$d;this.$y=D.getFullYear(),this.$M=D.getMonth(),this.$D=D.getDate(),this.$W=D.getDay(),this.$H=D.getHours(),this.$m=D.getMinutes(),this.$s=D.getSeconds(),this.$ms=D.getMilliseconds()},L.$utils=function(){return B},L.isValid=function(){return this.$d.toString()!==U},L.isSame=function(D,Y){var Z=w(D);return this.startOf(Y)<=Z&&Z<=this.endOf(Y)},L.isAfter=function(D,Y){return w(D)<this.startOf(Y)},L.isBefore=function(D,Y){return this.endOf(Y)<w(D)},L.$g=function(D,Y,Z){return B.u(D)?this[Y]:this.set(Z,D)},L.unix=function(){return Math.floor(this.valueOf()/1e3)},L.valueOf=function(){return this.$d.getTime()},L.startOf=function(D,Y){var Z=this,X=!!B.u(Y)||Y,K=B.p(D),q=function(y,_){var E=B.w(Z.$u?Date.UTC(Z.$y,_,y):new Date(Z.$y,_,y),Z);return X?E:E.endOf(p)},rt=function(y,_){return B.w(Z.toDate()[y].apply(Z.toDate("s"),(X?[0,0,0,0]:[23,59,59,999]).slice(_)),Z)},xt=this.$W,Ut=this.$M,Pt=this.$D,Zt="set"+(this.$u?"UTC":"");switch(K){case F:return X?q(1,0):q(31,11);case v:return X?q(1,Ut):q(0,Ut+1);case g:var Gt=this.$locale().weekStart||0,W=(xt<Gt?xt+7:xt)-Gt;return q(X?Pt-W:Pt+(6-W),Ut);case p:case T:return rt(Zt+"Hours",0);case f:return rt(Zt+"Minutes",1);case c:return rt(Zt+"Seconds",2);case a:return rt(Zt+"Milliseconds",3);default:return this.clone()}},L.endOf=function(D){return this.startOf(D,!1)},L.$set=function(D,Y){var Z,X=B.p(D),K="set"+(this.$u?"UTC":""),q=(Z={},Z[p]=K+"Date",Z[T]=K+"Date",Z[v]=K+"Month",Z[F]=K+"FullYear",Z[f]=K+"Hours",Z[c]=K+"Minutes",Z[a]=K+"Seconds",Z[i]=K+"Milliseconds",Z)[X],rt=X===p?this.$D+(Y-this.$W):Y;if(X===v||X===F){var xt=this.clone().set(T,1);xt.$d[q](rt),xt.init(),this.$d=xt.set(T,Math.min(this.$D,xt.daysInMonth())).$d}else q&&this.$d[q](rt);return this.init(),this},L.set=function(D,Y){return this.clone().$set(D,Y)},L.get=function(D){return this[B.p(D)]()},L.add=function(D,Y){var Z,X=this;D=Number(D);var K=B.p(Y),q=function(Ut){var Pt=w(X);return B.w(Pt.date(Pt.date()+Math.round(Ut*D)),X)};if(K===v)return this.set(v,this.$M+D);if(K===F)return this.set(F,this.$y+D);if(K===p)return q(1);if(K===g)return q(7);var rt=(Z={},Z[c]=n,Z[f]=o,Z[a]=e,Z)[K]||1,xt=this.$d.getTime()+D*rt;return B.w(xt,this)},L.subtract=function(D,Y){return this.add(-1*D,Y)},L.format=function(D){var Y=this,Z=this.$locale();if(!this.isValid())return Z.invalidDate||U;var X=D||"YYYY-MM-DDTHH:mm:ssZ",K=B.z(this),q=this.$H,rt=this.$m,xt=this.$M,Ut=Z.weekdays,Pt=Z.months,Zt=Z.meridiem,Gt=function(_,E,j,$){return _&&(_[E]||_(Y,X))||j[E].slice(0,$)},W=function(_){return B.s(q%12||12,_,"0")},y=Zt||function(_,E,j){var $=_<12?"AM":"PM";return j?$.toLowerCase():$};return X.replace(k,function(_,E){return E||function(j){switch(j){case"YY":return String(Y.$y).slice(-2);case"YYYY":return B.s(Y.$y,4,"0");case"M":return xt+1;case"MM":return B.s(xt+1,2,"0");case"MMM":return Gt(Z.monthsShort,xt,Pt,3);case"MMMM":return Gt(Pt,xt);case"D":return Y.$D;case"DD":return B.s(Y.$D,2,"0");case"d":return String(Y.$W);case"dd":return Gt(Z.weekdaysMin,Y.$W,Ut,2);case"ddd":return Gt(Z.weekdaysShort,Y.$W,Ut,3);case"dddd":return Ut[Y.$W];case"H":return String(q);case"HH":return B.s(q,2,"0");case"h":return W(1);case"hh":return W(2);case"a":return y(q,rt,!0);case"A":return y(q,rt,!1);case"m":return String(rt);case"mm":return B.s(rt,2,"0");case"s":return String(Y.$s);case"ss":return B.s(Y.$s,2,"0");case"SSS":return B.s(Y.$ms,3,"0");case"Z":return K}return null}(_)||K.replace(":","")})},L.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},L.diff=function(D,Y,Z){var X,K=this,q=B.p(Y),rt=w(D),xt=(rt.utcOffset()-this.utcOffset())*n,Ut=this-rt,Pt=function(){return B.m(K,rt)};switch(q){case F:X=Pt()/12;break;case v:X=Pt();break;case C:X=Pt()/3;break;case g:X=(Ut-xt)/6048e5;break;case p:X=(Ut-xt)/864e5;break;case f:X=Ut/o;break;case c:X=Ut/n;break;case a:X=Ut/e;break;default:X=Ut}return Z?X:B.a(X)},L.daysInMonth=function(){return this.endOf(v).$D},L.$locale=function(){return A[this.$L]},L.locale=function(D,Y){if(!D)return this.$L;var Z=this.clone(),X=S(D,Y,!0);return X&&(Z.$L=X),Z},L.clone=function(){return B.w(this.$d,this)},L.toDate=function(){return new Date(this.valueOf())},L.toJSON=function(){return this.isValid()?this.toISOString():null},L.toISOString=function(){return this.$d.toISOString()},L.toString=function(){return this.$d.toUTCString()},z}(),Q=N.prototype;return w.prototype=Q,[["$ms",i],["$s",a],["$m",c],["$H",f],["$W",p],["$M",v],["$y",F],["$D",T]].forEach(function(z){Q[z[1]]=function(L){return this.$g(L,z[0],z[1])}}),w.extend=function(z,L){return z.$i||(z(L,N,w),z.$i=!0),w},w.locale=S,w.isDayjs=m,w.unix=function(z){return w(1e3*z)},w.en=A[G],w.Ls=A,w.p={},w})}(Mn)),Mn.exports}var wd=md();const gr=Ts(wd);var Fn={exports:{}},bd=Fn.exports,zo;function _d(){return zo||(zo=1,function(r,t){(function(e,n){r.exports=n()})(bd,function(){var e,n,o=1e3,i=6e4,a=36e5,c=864e5,f=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,p=31536e6,g=2628e6,v=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/,C={years:p,months:g,days:c,hours:a,minutes:i,seconds:o,milliseconds:1,weeks:6048e5},F=function(A){return A instanceof V},T=function(A,O,m){return new V(A,m,O.$l)},U=function(A){return n.p(A)+"s"},M=function(A){return A<0},k=function(A){return M(A)?Math.ceil(A):Math.floor(A)},P=function(A){return Math.abs(A)},R=function(A,O){return A?M(A)?{negative:!0,format:""+P(A)+O}:{negative:!1,format:""+A+O}:{negative:!1,format:""}},V=function(){function A(m,S,w){var B=this;if(this.$d={},this.$l=w,m===void 0&&(this.$ms=0,this.parseFromMilliseconds()),S)return T(m*C[U(S)],this);if(typeof m=="number")return this.$ms=m,this.parseFromMilliseconds(),this;if(typeof m=="object")return Object.keys(m).forEach(function(z){B.$d[U(z)]=m[z]}),this.calMilliseconds(),this;if(typeof m=="string"){var N=m.match(v);if(N){var Q=N.slice(2).map(function(z){return z!=null?Number(z):0});return this.$d.years=Q[0],this.$d.months=Q[1],this.$d.weeks=Q[2],this.$d.days=Q[3],this.$d.hours=Q[4],this.$d.minutes=Q[5],this.$d.seconds=Q[6],this.calMilliseconds(),this}}return this}var O=A.prototype;return O.calMilliseconds=function(){var m=this;this.$ms=Object.keys(this.$d).reduce(function(S,w){return S+(m.$d[w]||0)*C[w]},0)},O.parseFromMilliseconds=function(){var m=this.$ms;this.$d.years=k(m/p),m%=p,this.$d.months=k(m/g),m%=g,this.$d.days=k(m/c),m%=c,this.$d.hours=k(m/a),m%=a,this.$d.minutes=k(m/i),m%=i,this.$d.seconds=k(m/o),m%=o,this.$d.milliseconds=m},O.toISOString=function(){var m=R(this.$d.years,"Y"),S=R(this.$d.months,"M"),w=+this.$d.days||0;this.$d.weeks&&(w+=7*this.$d.weeks);var B=R(w,"D"),N=R(this.$d.hours,"H"),Q=R(this.$d.minutes,"M"),z=this.$d.seconds||0;this.$d.milliseconds&&(z+=this.$d.milliseconds/1e3,z=Math.round(1e3*z)/1e3);var L=R(z,"S"),D=m.negative||S.negative||B.negative||N.negative||Q.negative||L.negative,Y=N.format||Q.format||L.format?"T":"",Z=(D?"-":"")+"P"+m.format+S.format+B.format+Y+N.format+Q.format+L.format;return Z==="P"||Z==="-P"?"P0D":Z},O.toJSON=function(){return this.toISOString()},O.format=function(m){var S=m||"YYYY-MM-DDTHH:mm:ss",w={Y:this.$d.years,YY:n.s(this.$d.years,2,"0"),YYYY:n.s(this.$d.years,4,"0"),M:this.$d.months,MM:n.s(this.$d.months,2,"0"),D:this.$d.days,DD:n.s(this.$d.days,2,"0"),H:this.$d.hours,HH:n.s(this.$d.hours,2,"0"),m:this.$d.minutes,mm:n.s(this.$d.minutes,2,"0"),s:this.$d.seconds,ss:n.s(this.$d.seconds,2,"0"),SSS:n.s(this.$d.milliseconds,3,"0")};return S.replace(f,function(B,N){return N||String(w[B])})},O.as=function(m){return this.$ms/C[U(m)]},O.get=function(m){var S=this.$ms,w=U(m);return w==="milliseconds"?S%=1e3:S=w==="weeks"?k(S/C[w]):this.$d[w],S||0},O.add=function(m,S,w){var B;return B=S?m*C[U(S)]:F(m)?m.$ms:T(m,this).$ms,T(this.$ms+B*(w?-1:1),this)},O.subtract=function(m,S){return this.add(m,S,!0)},O.locale=function(m){var S=this.clone();return S.$l=m,S},O.clone=function(){return T(this.$ms,this)},O.humanize=function(m){return e().add(this.$ms,"ms").locale(this.$l).fromNow(!m)},O.valueOf=function(){return this.asMilliseconds()},O.milliseconds=function(){return this.get("milliseconds")},O.asMilliseconds=function(){return this.as("milliseconds")},O.seconds=function(){return this.get("seconds")},O.asSeconds=function(){return this.as("seconds")},O.minutes=function(){return this.get("minutes")},O.asMinutes=function(){return this.as("minutes")},O.hours=function(){return this.get("hours")},O.asHours=function(){return this.as("hours")},O.days=function(){return this.get("days")},O.asDays=function(){return this.as("days")},O.weeks=function(){return this.get("weeks")},O.asWeeks=function(){return this.as("weeks")},O.months=function(){return this.get("months")},O.asMonths=function(){return this.as("months")},O.years=function(){return this.get("years")},O.asYears=function(){return this.as("years")},A}(),G=function(A,O,m){return A.add(O.years()*m,"y").add(O.months()*m,"M").add(O.days()*m,"d").add(O.hours()*m,"h").add(O.minutes()*m,"m").add(O.seconds()*m,"s").add(O.milliseconds()*m,"ms")};return function(A,O,m){e=m,n=m().$utils(),m.duration=function(B,N){var Q=m.locale();return T(B,{$l:Q},N)},m.isDuration=F;var S=O.prototype.add,w=O.prototype.subtract;O.prototype.add=function(B,N){return F(B)?G(this,B,1):S.bind(this)(B,N)},O.prototype.subtract=function(B,N){return F(B)?G(this,B,-1):w.bind(this)(B,N)}}})}(Fn)),Fn.exports}var Sd=_d();const Id=Ts(Sd);gr.extend(Id);const Bd=r=>{if(r instanceof Date)return gr(r).toISOString();if(r instanceof gr)return r.toISOString();if(r instanceof gr.duration)return r.toISOString();try{return gr.duration(r).toISOString()}catch{return gr(r).toISOString()}},vd=r=>{const t=r.times.map(e=>Bd(e));return{type:r.type||"range",times:t,resolution:r.resolution,resample:r.resample}};class Ad{datasource;parameters;description;variables;timefilter;geofilter;levelfilter;coordfilter;crs;aggregate;limit;id;constructor(t){this.datasource=t.datasource,this.parameters=t.parameters,this.description=t.description,this.variables=t.variables,this.timefilter=t.timefilter&&vd(t.timefilter),this.geofilter=t.geofilter,this.levelfilter=t.levelfilter,this.coordfilter=t.coordfilter,this.crs=t.crs,this.aggregate=t.aggregate,this.limit=t.limit,this.id=t.id}toJSON(){return{datasource:this.datasource,parameters:this.parameters,description:this.description,variables:this.variables,timefilter:this.timefilter,geofilter:this.geofilter,levelfilter:this.levelfilter,coordfilter:this.coordfilter,crs:this.crs,aggregate:this.aggregate,limit:this.limit,id:this.id}}}exports.Connector=yd;exports.DataVar=ui;exports.Dataset=Ge;exports.Query=Ad;exports.wkb_to_geojson=su;
package/dist/index.js CHANGED
@@ -12751,8 +12751,10 @@ const ed = (r) => {
12751
12751
  i = 1n;
12752
12752
  break;
12753
12753
  }
12754
- for (let a = 0; a < r.data.length; a++)
12755
- o[a] = Number(r.data[a] / i);
12754
+ for (let a = 0; a < r.data.length; a++) {
12755
+ const c = r.data[a];
12756
+ o[a] = Number(c / i);
12757
+ }
12756
12758
  return Fs(o, r.shape, r.stride);
12757
12759
  }, su = (r, t, e) => {
12758
12760
  const n = Object.keys(t), o = {};
@@ -12812,7 +12814,14 @@ class Ji {
12812
12814
  this.arr,
12813
12815
  e
12814
12816
  );
12815
- return this.arr.dtype == "v2:object" || !n.shape ? n.data : this.arr.dtype == "bool" ? [...n.data] : this.arr.attrs._dtype?.startsWith("<M8") ? ad(n, this.arr.attrs._dtype) : Fs(n.data, n.shape, n.stride);
12817
+ if (this.arr.dtype == "v2:object" || !n.shape)
12818
+ return n.data;
12819
+ if (this.arr.dtype == "bool")
12820
+ return [...n.data];
12821
+ {
12822
+ const o = this.arr.attrs._dtype;
12823
+ return o?.startsWith("<M8") ? ad(n, o) : Fs(n.data, n.shape, n.stride);
12824
+ }
12816
12825
  }
12817
12826
  }
12818
12827
  td([
@@ -12864,7 +12873,8 @@ class Xe {
12864
12873
  kind: "array"
12865
12874
  });
12866
12875
  } catch (T) {
12867
- if (T.message.includes("<M8"))
12876
+ const U = typeof T == "object" && T && "message" in T ? String(T.message) : void 0;
12877
+ if (U && U.includes("<M8"))
12868
12878
  v = await Kf(a.resolve(g.path));
12869
12879
  else
12870
12880
  throw T;
@@ -13124,7 +13134,7 @@ const ou = class Hi {
13124
13134
  if (!t._isV1) {
13125
13135
  const n = new Hi();
13126
13136
  return n.id = "dummy_session", n.user = "dummy_user", n.creationTime = /* @__PURE__ */ new Date(), n.endTime = new Date(
13127
- Date.now() + (e.duration || 1) * 60 * 60 * 1e3
13137
+ Date.now() + (e.duration || 3600) * 1e3
13128
13138
  ), n.write = !1, n.verified = !1, n._connection = t, typeof process < "u" && process.on && process.on("beforeExit", () => {
13129
13139
  n.close();
13130
13140
  }), n;
@@ -13132,8 +13142,10 @@ const ou = class Hi {
13132
13142
  try {
13133
13143
  const n = { ...t._authHeaders };
13134
13144
  n["Cache-Control"] = "no-store";
13135
- const o = { duration: e.duration || 1 }, i = await fetch(
13136
- `${t._gateway}/session/?` + new URLSearchParams(o),
13145
+ const o = new URLSearchParams({
13146
+ duration: String(e.duration ?? 3600)
13147
+ }), i = await fetch(
13148
+ `${t._gateway}/session/?${o.toString()}`,
13137
13149
  { headers: n }
13138
13150
  );
13139
13151
  if (i.status !== 200)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oceanum/datamesh",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "scripts": {
5
5
  "build:docs": "typedoc"
6
6
  },
@@ -32,7 +32,8 @@ export default {
32
32
  ...response.headers,
33
33
  "Access-Control-Allow-Origin": "*",
34
34
  "Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS",
35
- "Access-Control-Allow-Headers": "Content-Type, Authorization",
35
+ "Access-Control-Allow-Headers":
36
+ "Content-Type, Authorization, X-DATAMESH-TOKEN",
36
37
  },
37
38
  });
38
39
 
@@ -0,0 +1,54 @@
1
+ # Node Express Proxy (Example)
2
+
3
+ Example reverse proxy for Oceanum Datamesh using Node.js + Express.
4
+
5
+ ## Prerequisites
6
+
7
+ - Node.js v18+ (native `fetch` and web streams)
8
+ - Environment variable `DATAMESH_TOKEN` set to your Datamesh token
9
+ - Optional: `DATAMESH_URL` (defaults to `https://datamesh.oceanum.io`)
10
+ - Optional: `PORT` (defaults to `8787`)
11
+
12
+ ## Install and run
13
+
14
+ Create a small project in this directory and install Express:
15
+
16
+ ```sh
17
+ npm init -y
18
+ npm install express
19
+ ```
20
+
21
+ Run the proxy:
22
+
23
+ ```sh
24
+ DATAMESH_TOKEN=your_token_here node index.js
25
+ # or with a custom upstream and port
26
+ DATAMESH_TOKEN=your_token_here DATAMESH_URL=https://datamesh.oceanum.io PORT=8080 node index.js
27
+ ```
28
+
29
+ ## What it does
30
+
31
+ - Forwards all incoming requests to `DATAMESH_URL`.
32
+ - Injects/overwrites the `x-DATAMESH-TOKEN` header with your secret token.
33
+ - Adds permissive CORS headers for browser apps.
34
+
35
+ ## Use with @oceanum/datamesh
36
+
37
+ Point both `service` and `gateway` to your proxy origin:
38
+
39
+ ```ts
40
+ import { Connector } from "@oceanum/datamesh";
41
+
42
+ const PROXY_URL = "http://localhost:8787"; // or your deployed proxy
43
+
44
+ const connector = new Connector("proxy", {
45
+ service: PROXY_URL,
46
+ gateway: PROXY_URL,
47
+ });
48
+ ```
49
+
50
+ ## Security notes
51
+
52
+ - Never commit your real token. Use env vars or a secret store.
53
+ - Consider tightening CORS and limiting allowed origins in production.
54
+ - This is an example; adapt logging/error handling and header allowlists to your needs.
@@ -0,0 +1,126 @@
1
+ /*
2
+ Example Node Express reverse proxy for Oceanum Datamesh
3
+
4
+ Requirements
5
+ - Node.js v18+ (for native fetch and web streams)
6
+ - Environment variable DATAMESH_TOKEN set to your Datamesh token
7
+ - Optional: DATAMESH_URL (defaults to https://datamesh.oceanum.io)
8
+ - Optional: PORT (defaults to 8787)
9
+
10
+ Usage
11
+ DATAMESH_TOKEN=xxxx npm start
12
+ # or
13
+ DATAMESH_TOKEN=xxxx node index.js
14
+ */
15
+
16
+ const express = require("express");
17
+
18
+ const app = express();
19
+ const PORT = process.env.PORT || 8787;
20
+ const TARGET = process.env.DATAMESH_URL || "https://datamesh.oceanum.io";
21
+
22
+ if (!process.env.DATAMESH_TOKEN) {
23
+ console.warn(
24
+ "Warning: DATAMESH_TOKEN is not set. Requests to Datamesh will fail with 401/403."
25
+ );
26
+ }
27
+
28
+ // Basic CORS support (adjust for production as needed)
29
+ app.use((req, res, next) => {
30
+ res.setHeader("Access-Control-Allow-Origin", "*");
31
+ res.setHeader(
32
+ "Access-Control-Allow-Methods",
33
+ "GET, POST, PUT, DELETE, OPTIONS"
34
+ );
35
+ res.setHeader(
36
+ "Access-Control-Allow-Headers",
37
+ "Content-Type, Authorization, x-requested-with, x-datamesh-token"
38
+ );
39
+ if (req.method === "OPTIONS") {
40
+ return res.sendStatus(204);
41
+ }
42
+ next();
43
+ });
44
+
45
+ // Proxy all routes to Datamesh, injecting the token
46
+ app.use(async (req, res) => {
47
+ try {
48
+ const upstreamUrl = new URL(req.originalUrl, TARGET);
49
+
50
+ // Rebuild headers to a fresh Headers instance
51
+ const headers = new Headers();
52
+ for (const [key, value] of Object.entries(req.headers)) {
53
+ if (typeof value === "string") headers.set(key, value);
54
+ else if (Array.isArray(value)) headers.set(key, value.join(", "));
55
+ }
56
+
57
+ // Ensure correct Host and token header (overwrite any client-supplied values)
58
+ headers.delete("host");
59
+ headers.set("x-DATAMESH-TOKEN", process.env.DATAMESH_TOKEN || "");
60
+
61
+ // Prepare request init
62
+ const method = req.method.toUpperCase();
63
+ const hasBody = !["GET", "HEAD"].includes(method);
64
+ const init = {
65
+ method,
66
+ headers,
67
+ body: hasBody ? req : undefined, // Stream the incoming request body
68
+ };
69
+
70
+ const response = await fetch(upstreamUrl, init);
71
+
72
+ // Forward headers from upstream
73
+ response.headers.forEach((value, key) => {
74
+ // Skip hop-by-hop or problematic headers if necessary
75
+ if (key.toLowerCase() === "transfer-encoding") return;
76
+ res.setHeader(key, value);
77
+ });
78
+
79
+ // We already added CORS above; ensure it's present in case upstream overrides
80
+ res.setHeader("Access-Control-Allow-Origin", "*");
81
+ res.setHeader(
82
+ "Access-Control-Allow-Methods",
83
+ "GET, POST, PUT, DELETE, OPTIONS"
84
+ );
85
+ res.setHeader(
86
+ "Access-Control-Allow-Headers",
87
+ "Content-Type, Authorization, x-requested-with"
88
+ );
89
+
90
+ // Status
91
+ res.status(response.status);
92
+
93
+ // Stream body
94
+ if (response.body) {
95
+ response.body
96
+ .pipeTo(
97
+ new WritableStream({
98
+ write(chunk) {
99
+ res.write(Buffer.from(chunk));
100
+ },
101
+ close() {
102
+ res.end();
103
+ },
104
+ abort(err) {
105
+ console.error("Proxy stream aborted:", err);
106
+ res.end();
107
+ },
108
+ })
109
+ )
110
+ .catch((err) => {
111
+ console.error("Proxy piping error:", err);
112
+ res.end();
113
+ });
114
+ } else {
115
+ res.end();
116
+ }
117
+ } catch (err) {
118
+ console.error("Proxy error:", err);
119
+ res.status(502).json({ detail: "Proxy error", error: String(err) });
120
+ }
121
+ });
122
+
123
+ app.listen(PORT, () => {
124
+ console.log(`Datamesh proxy listening on http://localhost:${PORT}`);
125
+ console.log(`Forwarding to ${TARGET}`);
126
+ });