Spacelab 0.28.0__py3-none-any.whl
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.
- spacelab/__init__.py +6 -0
- spacelab/__main__.py +3 -0
- spacelab/cli.py +97 -0
- spacelab/hlod/__init__.py +8 -0
- spacelab/hlod/__main__.py +5 -0
- spacelab/hlod/build.py +349 -0
- spacelab/hlod/cells.py +82 -0
- spacelab/hlod/cli.py +90 -0
- spacelab/hlod/hashing.py +38 -0
- spacelab/hlod/hilbert.py +91 -0
- spacelab/hlod/read.py +150 -0
- spacelab/hlod/verify.py +142 -0
- spacelab/prep_spatialdata.py +700 -0
- spacelab/server.py +130 -0
- spacelab/static/AI_lens_black.png +0 -0
- spacelab/static/ai-new-logo.png +0 -0
- spacelab/static/aifi_logo.png +0 -0
- spacelab/static/assets/AllenInstitutePlusText-Bold-DxLtQ4oE.woff2 +0 -0
- spacelab/static/assets/AllenInstitutePlusText-BoldItalic-mxzHQhQO.woff2 +0 -0
- spacelab/static/assets/AllenInstitutePlusText-Italic-CaKmxpsW.woff2 +0 -0
- spacelab/static/assets/AllenInstitutePlusText-Light-DUThXl1m.woff2 +0 -0
- spacelab/static/assets/AllenInstitutePlusText-LightItalic-CxfKknzG.woff2 +0 -0
- spacelab/static/assets/AllenInstitutePlusText-Regular-B0ryviHQ.woff2 +0 -0
- spacelab/static/assets/AllenInstitutePlusText-Semibold-3PoiDF1d.woff2 +0 -0
- spacelab/static/assets/AllenInstitutePlusText-SemiboldItalic-uXaVqnFo.woff2 +0 -0
- spacelab/static/assets/blosc-BKQbfHyB.js +18 -0
- spacelab/static/assets/blosc-j6ygecpn.js +18 -0
- spacelab/static/assets/chunk-INHXZS53-D3tQiqtZ.js +2 -0
- spacelab/static/assets/chunk-INHXZS53-QjxmivJp.js +2 -0
- spacelab/static/assets/deflate-BRVR_fNk.js +2 -0
- spacelab/static/assets/hlodTranscripts.worker-CjhNLk56.js +2 -0
- spacelab/static/assets/index-BT-mDgg2.js +5025 -0
- spacelab/static/assets/index-CNIqsj6m.css +1 -0
- spacelab/static/assets/jpeg-JUDfHHDo.js +2 -0
- spacelab/static/assets/lerc-CXQdKTps.js +2 -0
- spacelab/static/assets/lz4-C2MQfzIA.js +16 -0
- spacelab/static/assets/lz4-rzy_Siro.js +16 -0
- spacelab/static/assets/lzw-DBCCrYEo.js +2 -0
- spacelab/static/assets/packbits-LrtZ2mhj.js +2 -0
- spacelab/static/assets/pako.esm-C69tvH9t.js +2 -0
- spacelab/static/assets/polygons.worker-ClOPdWlW.js +2 -0
- spacelab/static/assets/raw-lPmjnySZ.js +2 -0
- spacelab/static/assets/spatialdataExpression.worker-D4W_OHS3.js +4 -0
- spacelab/static/assets/spatialdataShapes.worker-DQV1zeTt.js +974 -0
- spacelab/static/assets/spatialdataTranscripts.worker-DH9L-MwZ.js +974 -0
- spacelab/static/assets/transcripts.worker-CtxyO4n3.js +2 -0
- spacelab/static/assets/umap.worker-BPHuoLPV.js +2 -0
- spacelab/static/assets/webimage-xg0Pp5Jv.js +2 -0
- spacelab/static/assets/zstd-Cp7BEDDH.js +16 -0
- spacelab/static/assets/zstd-WlDjm0Vu.js +16 -0
- spacelab/static/blurred-bg.jpg +0 -0
- spacelab/static/favicon.ico +0 -0
- spacelab/static/index.html +22 -0
- spacelab/static/logo192.png +0 -0
- spacelab/static/logo512.png +0 -0
- spacelab/static/manifest.json +15 -0
- spacelab/static/robots.txt +3 -0
- spacelab-0.28.0.dist-info/METADATA +30 -0
- spacelab-0.28.0.dist-info/RECORD +62 -0
- spacelab-0.28.0.dist-info/WHEEL +4 -0
- spacelab-0.28.0.dist-info/entry_points.txt +2 -0
- spacelab-0.28.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function Qe(t,e){return{...t,...e,headers:{...t.headers,...e.headers}}}function ge(t,e){const n=typeof t=="string"?new URL(t):t;n.pathname.endsWith("/")||(n.pathname+="/");const r=new URL(e.slice(1),n);return r.search=n.search,r}async function we(t){if(t.status!==404){if(t.status===200||t.status===206)return new Uint8Array(await t.arrayBuffer());throw new Error(`Unexpected response status ${t.status} ${t.statusText}`)}}class me{url;#e;#t;#n;constructor(e,n={}){this.url=e,this.#e=n.fetch??(r=>fetch(r)),this.#t=n.overrides??{},this.#n=n.useSuffixRequest??!1}#r(e,n){return new Request(e,Qe(this.#t,n))}async get(e,n={}){let r=ge(this.url,e).href,s=this.#r(r,n),i=await this.#e(s);return we(i)}async getRange(e,n,r={}){let s=ge(this.url,e),i;if("suffixLength"in n)i=await this.#s(s,n.suffixLength,r);else{let a={...r,headers:{...r.headers,Range:`bytes=${n.offset}-${n.offset+n.length-1}`}},o=this.#r(s,a);i=await this.#e(o)}return we(i)}async#s(e,n,r){if(this.#n){let d={...r,headers:{...r.headers,Range:`bytes=-${n}`}};return this.#e(this.#r(e,d))}let s=this.#r(e,{...r,method:"HEAD"}),i=await this.#e(s);if(!i.ok)return i;let a=i.headers.get("Content-Length"),o=Number(a),c=o-n,u={...r,headers:{...r.headers,Range:`bytes=${c}-${o-1}`}};return this.#e(this.#r(e,u))}}class C extends Error{}class I extends C{_tag="NotFoundError";name="NotFoundError";path;found;constructor(e,n={}){super(`Not found: ${e}`,{cause:n.cause}),this.path=n.path,this.found=n.found}}class g extends C{_tag="InvalidMetadataError";name="InvalidMetadataError";path;constructor(e,n={}){super(e,{cause:n.cause}),this.path=n.path}}class Ke extends C{_tag="UnknownCodecError";name="UnknownCodecError";codec;constructor(e){super(`Unknown codec: ${e}`),this.codec=e}}class We extends C{_tag="CodecPipelineError";name="CodecPipelineError";direction;codec;chunkPath;constructor(e){const n=[`Failed to ${e.direction} chunk`,e.codec&&`via codec "${e.codec}"`,e.chunkPath&&`at ${e.chunkPath}`].filter(Boolean);super(n.join(" "),{cause:e.cause}),this.direction=e.direction,this.codec=e.codec,this.chunkPath=e.chunkPath}}class $ extends C{_tag="InvalidSelectionError";name="InvalidSelectionError"}class ne extends C{_tag="UnsupportedError";name="UnsupportedError";feature;constructor(e){super(`Unsupported: ${e}`),this.feature=e}}function T(t){return()=>{throw new ne(`${t} encode`)}}class R{kind="array_to_array";constructor(e,n){if(e.keepbits<0)throw new g("keepbits must be zero or positive")}static fromConfig(e,n){return new R(e,n)}encode=T("bitround");decode(e){return e}}function re(t){return t instanceof ArrayBuffer||t instanceof SharedArrayBuffer}class ze{#e;constructor(e,n,r){typeof e=="number"?this.#e=new Uint8Array(e):re(e)?this.#e=new Uint8Array(e,n,r):this.#e=new Uint8Array(Array.from(e,s=>s?1:0))}get BYTES_PER_ELEMENT(){return 1}get byteOffset(){return this.#e.byteOffset}get byteLength(){return this.#e.byteLength}get buffer(){return this.#e.buffer}get length(){return this.#e.length}get(e){let n=this.#e[e];return typeof n=="number"?n!==0:n}set(e,n){this.#e[e]=n?1:0}fill(e){this.#e.fill(e?1:0)}*[Symbol.iterator](){for(let e=0;e<this.length;e++)yield this.get(e)}}class se{_data;chars;#e;constructor(e,n,r,s){if(this.chars=e,this.#e=new TextEncoder,typeof n=="number")this._data=new Uint8Array(n*e);else if(re(n))s&&(s=s*e),this._data=new Uint8Array(n,r,s);else{let i=Array.from(n);this._data=new Uint8Array(i.length*e);for(let a=0;a<i.length;a++)this.set(a,i[a])}}get BYTES_PER_ELEMENT(){return this.chars}get byteOffset(){return this._data.byteOffset}get byteLength(){return this._data.byteLength}get buffer(){return this._data.buffer}get length(){return this.byteLength/this.BYTES_PER_ELEMENT}get(e){const n=new Uint8Array(this.buffer,this.byteOffset+this.chars*e,this.chars);return new TextDecoder().decode(n).replace(/\x00/g,"")}set(e,n){const r=new Uint8Array(this.buffer,this.byteOffset+this.chars*e,this.chars);r.fill(0),r.set(this.#e.encode(n))}fill(e){const n=this.#e.encode(e);for(let r=0;r<this.length;r++)this._data.set(n,r*this.chars)}*[Symbol.iterator](){for(let e=0;e<this.length;e++)yield this.get(e)}}class L{#e;chars;constructor(e,n,r,s){if(this.chars=e,typeof n=="number")this.#e=new Int32Array(n*e);else if(re(n))s&&(s*=e),this.#e=new Int32Array(n,r,s);else{const i=n,a=new L(e,1);this.#e=new Int32Array(function*(){for(let o of i)a.set(0,o),yield*a.#e}())}}get BYTES_PER_ELEMENT(){return this.#e.BYTES_PER_ELEMENT*this.chars}get byteLength(){return this.#e.byteLength}get byteOffset(){return this.#e.byteOffset}get buffer(){return this.#e.buffer}get length(){return this.#e.length/this.chars}get(e){const n=this.chars*e;let r="";for(let s=0;s<this.chars;s++)r+=String.fromCodePoint(this.#e[n+s]);return r.replace(/\u0000/g,"")}set(e,n){const r=this.chars*e,s=this.#e.subarray(r,r+this.chars);s.fill(0);for(let i=0;i<this.chars;i++)s[i]=n.codePointAt(i)??0}fill(e){this.set(0,e);let n=this.#e.subarray(0,this.chars);for(let r=1;r<this.length;r++)this.#e.set(n,r*this.chars)}*[Symbol.iterator](){for(let e=0;e<this.length;e++)yield this.get(e)}}function Pe(){if(typeof SharedArrayBuffer>"u")throw new Error("SharedArrayBuffer is not available. In browsers, this requires Cross-Origin-Opener-Policy and Cross-Origin-Embedder-Policy headers to be set.")}function De(t,e){return new SharedArrayBuffer(t)}function O(t){const e=new TextDecoder().decode(t);try{return JSON.parse(e)}catch(n){throw new g("Failed to decode JSON",{cause:n})}}function be(t,e){const n=e/2,r=e-1;let s=0;for(let i=0;i<t.length;i+=e)for(let a=0;a<n;a+=1)s=t[i+a],t[i+a]=t[i+r-a],t[i+r-a]=s}function N(t){if(t==="v2:object")return globalThis.Array;let e=t.match(/v2:([US])(\d+)/);if(e){let[,r,s]=e;return(r==="U"?L:se).bind(null,Number(s))}if(t==="string")return globalThis.Array;let n={int8:Int8Array,int16:Int16Array,int32:Int32Array,int64:globalThis.BigInt64Array,uint8:Uint8Array,uint16:Uint16Array,uint32:Uint32Array,uint64:globalThis.BigUint64Array,float16:globalThis.Float16Array,float32:Float32Array,float64:Float64Array,bool:ze}[t];if(!n)throw new g(`Unknown or unsupported dataType: ${t}`);return n}function B(t,e){const n=t.length;typeof e=="string"&&(e=e==="C"?Array.from({length:n},(i,a)=>a):Array.from({length:n},(i,a)=>n-1-a)),b(n===e.length,"Order length must match the number of dimensions.");let r=1,s=new Array(n);for(let i=e.length-1;i>=0;i--)s[e[i]]=r,r*=t[e[i]];return s}function Xe({name:t,configuration:e}){if(t==="default"){const n=e?.separator??"/";return r=>["c",...r].join(n)}if(t==="v2"){const n=e?.separator??".";return r=>r.join(n)||"0"}throw new g(`Unknown chunk key encoding: ${t}`)}function _e(t){if(t==="|O")return{dataType:"v2:object"};let e=t.match(/^([<|>])(.*)$/);if(!e)throw new g(`Invalid dtype: ${t}`);let[,n,r]=e,s={b1:"bool",i1:"int8",u1:"uint8",i2:"int16",u2:"uint16",i4:"int32",u4:"uint32",i8:"int64",u8:"uint64",f2:"float16",f4:"float32",f8:"float64"}[r]??(r.startsWith("S")||r.startsWith("U")?`v2:${r}`:void 0);if(!s)throw new g(`Unsupported or unknown dtype: ${t}`);return n==="|"?{dataType:s}:{dataType:s,endian:n==="<"?"little":"big"}}function Ze(t){return(t.id==="fixedscaleoffset"||t.id==="numcodecs.fixedscaleoffset")&&typeof t.scale=="number"&&typeof t.offset=="number"&&(t.astype===void 0||typeof t.astype=="string")&&(t.dtype===void 0||typeof t.dtype=="string")}function He(t,e={}){let n=[],r=_e(t.dtype);t.order==="F"&&n.push({name:"transpose",configuration:{order:"F"}});for(let i of t.filters??[]){if(i.id==="fixedscaleoffset"||i.id==="numcodecs.fixedscaleoffset"){if(!Ze(i))throw new g(`Invalid fixedscaleoffset filter: ${JSON.stringify(i)}`);n.push({name:"scale_offset",configuration:{scale:i.scale,offset:i.offset}});let c=i.astype??i.dtype;if(c!==void 0&&c!==t.dtype){let u=_e(c).dataType;if(!Z(u,"number")&&!Z(u,"bigint"))throw new g(`fixedscaleoffset astype must be a numeric data type, got ${c}`);n.push({name:"cast_value",configuration:{data_type:u,rounding:"nearest-even",out_of_range:"wrap"}})}continue}let{id:a,...o}=i;n.push({name:`numcodecs.${a}`,configuration:o})}if("endian"in r&&r.endian==="big"&&n.push({name:"bytes",configuration:{endian:"big"}}),t.compressor){let{id:i,...a}=t.compressor;n.push({name:`numcodecs.${i}`,configuration:a})}let s;return globalThis.Array.isArray(e._ARRAY_DIMENSIONS)&&(s=e._ARRAY_DIMENSIONS),{zarr_format:3,node_type:"array",shape:t.shape,data_type:r.dataType,chunk_grid:{name:"regular",configuration:{chunk_shape:t.chunks}},chunk_key_encoding:{name:"v2",configuration:{separator:t.dimension_separator??"."}},codecs:n,fill_value:t.fill_value,dimension_names:s,attributes:e}}function et(t,e={}){return{zarr_format:3,node_type:"group",attributes:e}}function Z(t,e){if(e!=="number"&&e!=="bigint"&&e!=="boolean"&&e!=="object"&&e!=="string")return t===e;let n=t==="bool";if(e==="boolean")return n;let r=t.startsWith("v2:U")||t.startsWith("v2:S")||t==="string";if(e==="string")return r;let s=t==="int64"||t==="uint64";if(e==="bigint")return s;let i=t==="v2:object";return e==="object"?i:!r&&!s&&!n&&!i}function tt(t){return t?.name==="sharding_indexed"}function Ve(t){if((t.data_type==="uint64"||t.data_type==="int64")&&t.fill_value!=null)return BigInt(t.fill_value);let e=t.data_type==="float16"||t.data_type==="float32"||t.data_type==="float64";if(typeof t.fill_value=="string"&&e){let n={NaN:NaN,Infinity:1/0,"-Infinity":-1/0};if(t.fill_value in n)return n[t.fill_value]}return t.fill_value}function nt(t){let e=t.signal,n=t.opts?.signal;return e&&n?AbortSignal.any([e,n]):e??n}function Ye(t,...e){if(!e.some(n=>t instanceof n))throw t}function b(t,e=""){if(!t)throw new Error(e)}async function je(t,{format:e,signal:n}){let r;if(t instanceof ArrayBuffer)r=new Response(t);else{let s=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);r=new Response(s.slice().buffer)}b(r.body,"Response does not contain body.");try{return await new Response(r.body.pipeThrough(new DecompressionStream(e),{signal:n})).arrayBuffer()}catch{throw n?.throwIfAborted(),new Error(`Failed to decode ${e}`)}}const Ee=rt();function rt(){const t=new Uint32Array([305419896]);return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)[0]!==18}function Se(t){return"BYTES_PER_ELEMENT"in t?t.BYTES_PER_ELEMENT:4}class V{kind="array_to_bytes";#e;#t;#n;#r;#s;constructor(e,n){this.#s=e?.endian,this.#t=N(n.dataType),this.#r=n.shape,this.#e=B(n.shape,"C");const r=new this.#t(0);this.#n=r.BYTES_PER_ELEMENT}static fromConfig(e,n){return new V(e,n)}encode(e){let n=new Uint8Array(e.data.buffer);return Ee&&this.#s==="big"&&(n=n.slice(),be(n,Se(this.#t))),n}computeEncodedSize(e){return e}decode(e){return Ee&&this.#s==="big"&&(e=e.slice(),be(e,Se(this.#t))),{data:new this.#t(e.buffer,e.byteOffset,e.byteLength/this.#n),shape:this.#r,stride:this.#e}}}const Ae={NaN:NaN,Infinity:1/0,"-Infinity":-1/0},Je={float16:2,float32:4,float64:8};function v(t){return t in Je}function H(t){return t==="int64"||t==="uint64"}function st(t,e){const n=BigInt(t),r=new ArrayBuffer(e),s=new DataView(r);if(e===2){if(typeof s.getFloat16!="function")throw new ne("float16 hex-encoded scalar decoding (requires DataView.prototype.getFloat16)");return s.setUint16(0,Number(n)),s.getFloat16(0)}return e===4?(s.setUint32(0,Number(n)),s.getFloat32(0)):(s.setBigUint64(0,n),s.getFloat64(0))}function F(t,e){if(H(t)){if(typeof e!="number"||!Number.isInteger(e))throw new g(`Expected an integer value for data type "${t}", got ${JSON.stringify(e)}`);return BigInt(e)}if(typeof e=="number"){if(!v(t)&&!Number.isInteger(e))throw new g(`Expected an integer value for data type "${t}", got ${e}`);return e}if(!v(t))throw new g(`String-encoded scalar "${e}" is not valid for non-float data type "${t}"`);return e in Ae?Ae[e]:st(e,Je[t])}const ke=new Set(["int8","uint8","int16","uint16","int32","uint32","int64","uint64","float16","float32","float64"]),j={int8:[-128,2**7-1],uint8:[0,2**8-1],int16:[-32768,2**15-1],uint16:[0,2**16-1],int32:[-2147483648,2**31-1],uint32:[0,2**32-1]},J={int64:[-(2n**63n),2n**63n-1n],uint64:[0n,2n**64n-1n]};function Te(t,e,n){return t.map(([r,s])=>({src:F(e,r),tgt:F(n,s)}))}function it(t,e){for(const n of e)if(typeof n.src=="number"&&Number.isNaN(n.src)){if(typeof t=="number"&&Number.isNaN(t))return n.tgt}else if(t===n.src)return n.tgt}function at(t){if(!Number.isFinite(t))return t;if(Math.abs(t-Math.trunc(t))===.5){const e=Math.floor(t),n=Math.ceil(t);return e%2===0?e:n}return Math.round(t)}function ot(t){return Math.sign(t)*Math.floor(Math.abs(t)+.5)}function Ce(t){switch(t){case"nearest-even":return at;case"towards-zero":return Math.trunc;case"towards-positive":return Math.ceil;case"towards-negative":return Math.floor;case"nearest-away":return ot}}function G(t,e,n){const r=e-t+1;switch(n){case"clamp":return s=>s<t?t:s>e?e:s;case"wrap":return s=>s>=t&&s<=e?s:((s-t)%r+r)%r+t;default:return s=>{if(s>=t&&s<=e)return s;throw new Error(`Value ${s} out of range [${t}, ${e}]. Set out_of_range='clamp' or out_of_range='wrap' to handle this.`)}}}function q(t,e,n){const r=e-t+1n;switch(n){case"clamp":return s=>s<t?t:s>e?e:s;case"wrap":return s=>s>=t&&s<=e?s:((s-t)%r+r)%r+t;default:return s=>{if(s>=t&&s<=e)return s;throw new Error(`Value ${s} out of range [${t}, ${e}]. Set out_of_range='clamp' or out_of_range='wrap' to handle this.`)}}}class ie{kind="array_to_array";#e;#t;#n;#r;constructor(e,n,r,s,i,a){this.#e=n,this.#t=N(e),this.#n=Ie(n,e,r,s,i),this.#r=Ie(e,n,r,s,a)}getEncodedMeta(e){let n=e.fillValue;return n!=null&&(n=this.#r(n)),{...e,dataType:this.#e,fillValue:n}}static fromConfig(e,n){const r=n.dataType,s=e.data_type;if(!ke.has(r))throw new g(`cast_value codec does not support array data type: ${r}`);if(!ke.has(s))throw new g(`cast_value codec does not support encoded data type: ${s}`);const i=e.rounding??"nearest-even",a=e.scalar_map?.decode?Te(e.scalar_map.decode,s,r):[],o=e.scalar_map?.encode?Te(e.scalar_map.encode,r,s):[];return new ie(r,s,i,e.out_of_range,a,o)}encode=T("cast_value");decode(e){const n=e.data,r=new this.#t(n.length);for(let s=0;s<n.length;s++)r[s]=this.#n(n[s]);return{data:r,shape:e.shape,stride:e.stride}}}function Ie(t,e,n,r,s){const i=v(t),a=H(t),o=v(e),c=H(e);let u;if(i&&o){if(n!=="nearest-even")throw new g(`cast_value float -> float only supports "nearest-even" rounding, got "${n}"`);u=f=>f}else if(i&&!o&&!c){const f=Ce(n),l=G(...j[e],r);u=h=>{if(!Number.isFinite(h))throw new Error(`Cannot cast ${h} to integer type without scalar_map`);return l(f(h))}}else if(i&&c){const f=Ce(n),l=q(...J[e],r);u=h=>{if(!Number.isFinite(h))throw new Error(`Cannot cast ${h} to integer type without scalar_map`);return l(BigInt(f(h)))}}else if(!i&&!a&&o)u=f=>f;else if(a&&o)u=f=>Number(f);else if(!i&&!a&&!o&&!c)u=G(...j[e],r);else if(!i&&!a&&c){const f=q(...J[e],r);u=l=>f(BigInt(l))}else if(a&&!o&&!c){const f=G(...j[e],r);u=l=>f(Number(l))}else if(a&&c)u=q(...J[e],r);else throw new Error(`Unhandled type combination: ${t} -> ${e}`);return s.length===0?u:f=>{const l=it(f,s);return l!==void 0?l:u(f)}}class ae{kind="bytes_to_bytes";static fromConfig(){return new ae}encode=T("crc32c");decode(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength-4)}computeEncodedSize(e){return e+4}}const ct=new Set(["int8","uint8","int16","uint16","int32","uint32","int64","uint64","float16","float32","float64"]);function Ne(t,e){const n=t.length;let r=n===0||e[n-1]===1;for(let i=n-2;i>=0&&r;i--)r=e[i]===e[i+1]*t[i+1];if(r)return;let s=n===0||e[0]===1;for(let i=1;i<n&&s;i++)s=e[i]===e[i-1]*t[i-1];if(!s)throw new Error(`DeltaCodec requires C- or Fortran-contiguous strides, got shape=${JSON.stringify(t)} stride=${JSON.stringify(e)}`)}class oe{kind="array_to_array";#e;constructor(e){this.#e=e}static fromConfig(e,n){if(!ct.has(n.dataType))throw new g(`Delta codec does not support data type: ${n.dataType}`);return new oe(N(n.dataType))}encode(e){Ne(e.shape,e.stride);const n=e.data,r=new this.#e(n.length);r[0]=n[0];for(let s=1;s<n.length;s++)r[s]=n[s]-n[s-1];return{data:r,shape:e.shape,stride:e.stride}}decode(e){Ne(e.shape,e.stride);const n=e.data,r=new this.#e(n.length);r[0]=n[0];for(let s=1;s<n.length;s++)r[s]=r[s-1]+n[s];return{data:r,shape:e.shape,stride:e.stride}}}class ce{kind="bytes_to_bytes";static fromConfig(e){return new ce}encode=T("gzip");async decode(e){const n=await je(e,{format:"gzip"});return new Uint8Array(n)}}function ut(t,e){return b(!Number.isNaN(e),"JsonCodec allow_nan is false but NaN was encountered during encoding."),b(e!==Number.POSITIVE_INFINITY,"JsonCodec allow_nan is false but Infinity was encountered during encoding."),b(e!==Number.NEGATIVE_INFINITY,"JsonCodec allow_nan is false but -Infinity was encountered during encoding."),e}function ft(t,e){return e instanceof Object&&!Array.isArray(e)?Object.keys(e).sort().reduce((n,r)=>(n[r]=e[r],n),{}):e}class z{configuration;kind="array_to_bytes";#e;#t;constructor(e={}){this.configuration=e;const{encoding:n="utf-8",skipkeys:r=!1,ensure_ascii:s=!0,check_circular:i=!0,allow_nan:a=!0,sort_keys:o=!0,indent:c,strict:u=!0}=e;let d=e.separators;d||(c?d=[", ",": "]:d=[",",":"]),this.#e={encoding:n,skipkeys:r,ensure_ascii:s,check_circular:i,allow_nan:a,indent:c,separators:d,sort_keys:o},this.#t={strict:u}}static fromConfig(e){return new z(e)}encode(e){const{indent:n,encoding:r,ensure_ascii:s,check_circular:i,allow_nan:a,sort_keys:o}=this.#e;b(r==="utf-8","JsonCodec does not yet support non-utf-8 encoding.");const c=[];b(i,"JsonCodec does not yet support skipping the check for circular references during encoding."),a||c.push(ut),o&&c.push(ft);const u=Array.from(e.data);u.push("|O"),u.push(e.shape);let d;c.length&&(d=(l,h)=>{let y=h;for(let w of c)y=w(l,y);return y});let f=JSON.stringify(u,d,n);return s&&(f=f.replace(/[\u007F-\uFFFF]/g,l=>{const h=`0000${l.charCodeAt(0).toString(16)}`;return`\\u${h.substring(h.length-4)}`})),new TextEncoder().encode(f)}decode(e){const{strict:n}=this.#t;b(n,"JsonCodec does not yet support non-strict decoding.");const r=O(e),s=r.pop();r.pop(),b(s,"0D not implemented for JsonCodec.");const i=B(s,"C");return{data:r,shape:s,stride:i}}}const dt=new Set(["int8","uint8","int16","uint16","int32","uint32","int64","uint64","float16","float32","float64"]);class ue{kind="array_to_array";#e;#t;#n;constructor(e,n,r){this.#t=e,this.#n=n,this.#e=r}static fromConfig(e,n){if(!dt.has(n.dataType))throw new g(`scale_offset codec does not support data type: ${n.dataType}`);return new ue(F(n.dataType,e.scale??1),F(n.dataType,e.offset??0),N(n.dataType))}encode=T("scale_offset");decode(e){const n=e.data,r=new this.#e(n.length);for(let s=0;s<n.length;s++)r[s]=n[s]/this.#t+this.#n;return{data:r,shape:e.shape,stride:e.stride}}}class fe{kind="bytes_to_bytes";#e;constructor(e,n){if(n){let r=new(N(n.dataType))(0);b("BYTES_PER_ELEMENT"in r,`Shuffle codec requires a fixed-size dtype, got "${n.dataType}"`),this.#e=r.BYTES_PER_ELEMENT}else this.#e=e.elementsize??4}static fromConfig(e,n){return new fe(e,n)}encode(e){return lt(e,this.#e)}decode(e){return ht(e,this.#e)}}function lt(t,e){let n=t.length,r=Math.floor(n/e),s=new Uint8Array(n);for(let i=0;i<e;i++)for(let a=0;a<r;a++)s[i*r+a]=t[a*e+i];return s}function ht(t,e){let n=t.length,r=Math.floor(n/e),s=new Uint8Array(n);for(let i=0;i<e;i++)for(let a=0;a<r;a++)s[a*e+i]=t[i*r+a];return s}function Be(t){return t instanceof ze||t instanceof se||t instanceof L?new Proxy(t,{get(n,r){return n.get(Number(r))},set(n,r,s){return n.set(Number(r),s),!0}}):t}function pt(t,e){let n;return t.data instanceof se||t.data instanceof L?n=new t.data.constructor(t.data.chars,t.data.length):n=new t.data.constructor(t.data.length),{data:n,shape:t.shape,stride:B(t.shape,e)}}function yt(t,e){let n=pt(t,e),r=t.shape.length,s=t.shape.reduce((c,u)=>c*u,1),i=Array(r).fill(0),a=Be(t.data),o=Be(n.data);for(let c=0;c<s;c++){let u=0,d=0;for(let f=0;f<r;f++)u+=i[f]*t.stride[f],d+=i[f]*n.stride[f];o[d]=a[u],i[0]+=1;for(let f=0;f<r;f++)if(i[f]===t.shape[f]){if(f+1===r)break;i[f]=0,i[f+1]+=1}}return n}function gt(t){let e=t.shape.length;return b(e===t.stride.length,"Shape and stride must have the same length."),t.stride.map((n,r)=>({stride:n,index:r})).sort((n,r)=>r.stride-n.stride).map(n=>n.index)}function wt(t,e){let n=gt(t);return b(n.length===e.length,"Orders must match"),n.every((r,s)=>r===e[s])}class de{kind="array_to_array";#e;constructor(e,n){let r=e.order??"C",s=n.shape.length,i=new Array(s);if(r==="C")for(let a=0;a<s;++a)i[a]=a;else if(r==="F")for(let a=0;a<s;++a)i[a]=s-a-1;else{i=r;let a=new Array(s);i.forEach(o=>{b(!a[o],`Invalid permutation: ${JSON.stringify(r)}`),a[o]=!0})}this.#e=i}static fromConfig(e,n){return new de(e,n)}encode(e){return wt(e,this.#e)?e:yt(e,this.#e)}decode(e){return{data:e.data,shape:e.shape,stride:B(e.shape,this.#e)}}}class P{kind="array_to_bytes";#e;#t;constructor(e){this.#e=e,this.#t=B(e,"C")}static fromConfig(e,n){return new P(n.shape)}encode=T("vlen-utf8");decode(e){let n=new TextDecoder,r=new DataView(e.buffer),s=Array(r.getUint32(0,!0)),i=4;for(let a=0;a<s.length;a++){let o=r.getUint32(i,!0);i+=4,s[a]=n.decode(e.buffer.slice(i,i+o)),i+=o}return{data:s,shape:this.#e,stride:this.#t}}}class le{kind="bytes_to_bytes";static fromConfig(e){return new le}encode=T("zlib");async decode(e){const n=await je(e,{format:"deflate"});return new Uint8Array(n)}}function mt(){let t=()=>import("./blosc-j6ygecpn.js").then(i=>i.default),e=()=>import("./lz4-rzy_Siro.js").then(i=>i.default),n=()=>import("./zstd-Cp7BEDDH.js").then(i=>i.default),r=()=>ce,s=()=>le;return new Map().set("blosc",t).set("lz4",e).set("zstd",n).set("gzip",r).set("zlib",s).set("transpose",()=>de).set("bytes",()=>V).set("crc32c",()=>ae).set("vlen-utf8",()=>P).set("json2",()=>z).set("bitround",()=>R).set("cast_value",()=>ie).set("scale_offset",()=>ue).set("numcodecs.blosc",t).set("numcodecs.lz4",e).set("numcodecs.zstd",n).set("numcodecs.gzip",r).set("numcodecs.zlib",s).set("numcodecs.vlen-utf8",()=>P).set("numcodecs.shuffle",()=>fe).set("numcodecs.delta",()=>oe).set("numcodecs.bitround",()=>R).set("numcodecs.json2",()=>z)}const bt=mt();function ee(t){let e;function n(){return e||(e=_t(t)),e}async function r(s,i,a){try{return await a()}catch(o){throw new We({direction:s,codec:i,cause:o})}}return{async encode(s){let i=await n();for(const{name:o,codec:c}of i.arrayToArray)s=await r("encode",o,()=>c.encode(s));let a=await r("encode",i.arrayToBytes.name,()=>i.arrayToBytes.codec.encode(s));for(const{name:o,codec:c}of i.bytesToBytes)a=await r("encode",o,()=>c.encode(a));return a},async decode(s){let i=await n();for(let o=i.bytesToBytes.length-1;o>=0;o--){const{name:c,codec:u}=i.bytesToBytes[o];s=await r("decode",c,()=>u.decode(s))}let a=await r("decode",i.arrayToBytes.name,()=>i.arrayToBytes.codec.decode(s));for(let o=i.arrayToArray.length-1;o>=0;o--){const{name:c,codec:u}=i.arrayToArray[o];a=await r("decode",c,()=>u.decode(a))}return a},async computeEncodedSize(s){let i=await n(),a=xe(i.arrayToBytes.name,i.arrayToBytes.codec,s);for(const{name:o,codec:c}of i.bytesToBytes)a=xe(o,c,a);return a}}}function xe(t,e,n){if(!e.computeEncodedSize)throw new g(`Codec "${t}" cannot compute its encoded size; it is not a fixed-size codec and cannot be used in a sharding index pipeline`);return e.computeEncodedSize(n)}async function _t(t){let e=t.codecs.map(async a=>{let o=await bt.get(a.name)?.();if(!o)throw new Ke(a.name);return{Codec:o,meta:a}}),n=[],r,s=[],i={...t};for await(let{Codec:a,meta:o}of e){let c=a.fromConfig(o.configuration,i);switch(c.kind){case"array_to_array":n.push({name:o.name,codec:c}),c.getEncodedMeta&&(i=c.getEncodedMeta(i));break;case"array_to_bytes":r={name:o.name,codec:c};break;default:s.push({name:o.name,codec:c})}}if(!r){if(!Et(i))throw new g(`Cannot encode ${i.dataType} to bytes without a codec`);r={name:"bytes",codec:V.fromConfig({endian:"little"},i)}}return{arrayToArray:n,arrayToBytes:r,bytesToBytes:s}}function Et(t){return t.dataType!=="v2:object"&&t.dataType!=="string"}const Me=18446744073709551615n;function St(t,e,n,r){if(!t.store.getRange)throw new ne("sharding requires a store with getRange");let s=t.store.getRange.bind(t.store),i=e.map((u,d)=>u/r.chunk_shape[d]),a=ee({dataType:"uint64",shape:[...i,2],codecs:r.index_codecs,fillValue:null}),o=16*i.reduce((u,d)=>u*d,1),c={};return async(u,d)=>{let f=u.map((S,A)=>Math.floor(S/i[A])),l=t.resolve(n(f)).path;l in c||(c[l]=(async()=>{let S=await a.computeEncodedSize(o),A=await s(l,{suffixLength:S},d);return A?await a.decode(A):null})().catch(S=>{throw delete c[l],S}));let h=await c[l];if(h===null)return;let{data:y,shape:w,stride:_}=h,m=u.map((S,A)=>S%w[A]).reduce((S,A,qe)=>S+A*_[qe],0),p=y[m],E=y[m+1];if(!(p===Me&&E===Me))return s(l,{offset:Number(p),length:Number(E)},d)}}class x{store;path;constructor(e,n="/"){this.store=e,this.path=n}resolve(e){let n=new URL(`file://${this.path.endsWith("/")?this.path:`${this.path}/`}`);return new x(this.store,decodeURIComponent(new URL(e,n).pathname))}}class he extends x{kind="group";#e;constructor(e,n,r){super(e,n),this.#e=r}get attrs(){return this.#e.attributes}}function $e(t){return t.find(n=>n.name==="transpose")?.configuration?.order??"C"}function At(t,e){let n=new Map(e.map((r,s)=>[r,s]));return t.filter(r=>n.has(r)).map(r=>n.get(r))}function Le(t){return(e,n)=>{let r=globalThis.Array.isArray(t)&&n?At(t,n):t;return B(e,r)}}const M=Symbol("zarrita.context");function kt(t){return t[M]}function Tt(t,e){let{configuration:n}=e.codecs.find(tt)??{},r={encodeChunkKey:Xe(e.chunk_key_encoding),TypedArray:N(e.data_type),fillValue:e.fill_value};if(n){let i=$e(n.codecs);return{...r,kind:"sharded",chunkShape:n.chunk_shape,codec:ee({dataType:e.data_type,shape:n.chunk_shape,codecs:n.codecs,fillValue:e.fill_value}),getStrides:Le(i),getChunkBytes:St(t,e.chunk_grid.configuration.chunk_shape,r.encodeChunkKey,n)}}let s=$e(e.codecs);return{...r,kind:"regular",chunkShape:e.chunk_grid.configuration.chunk_shape,codec:ee({dataType:e.data_type,shape:e.chunk_grid.configuration.chunk_shape,codecs:e.codecs,fillValue:e.fill_value}),getStrides:Le(s),async getChunkBytes(i,a){let o=r.encodeChunkKey(i),c=t.resolve(o).path;return t.store.get(c,a)}}}let D=class extends x{kind="array";#e;[M];constructor(e,n,r){super(e,n),this.#e={...r,fill_value:Ve(r)},this[M]=Tt(this,this.#e)}get attrs(){return this.#e.attributes}get dimensionNames(){return this.#e.dimension_names}get fillValue(){return this.#e.fill_value}get shape(){return this.#e.shape}get chunks(){return this[M].chunkShape}get dtype(){return this.#e.data_type}async getChunk(e,n,r){r?.useSharedArrayBuffer&&Pe();let s=this[M],i=await s.getChunkBytes(e,n);if(!i){let a=s.chunkShape.reduce((c,u)=>c*u,1),o;if(r?.useSharedArrayBuffer){let c=new s.TypedArray(0);if(!("BYTES_PER_ELEMENT"in c))console.warn("zarrita: useSharedArrayBuffer is not supported for non-buffer-backed data types."),o=new s.TypedArray(a);else{let u=De(a*c.BYTES_PER_ELEMENT);o=new s.TypedArray(u,0,a)}}else o=new s.TypedArray(a);return o.fill(s.fillValue),{data:o,shape:s.chunkShape,stride:s.getStrides(s.chunkShape)}}return s.codec.decode(i)}is(e){return Z(this.dtype,e)}};function Ct(t,e){let n=t;for(let r of e)n instanceof Promise?n=n.then(s=>r(s)):n=r(n);return n}function It(t,...e){return Ct(t,e)}async function Ge(t){let e=t.store.arrayExtensions;return e?.length?await It(t,...e):t}let Y=Nt();function Nt(){let t=new WeakMap;function e(n){let r=t.get(n)??{v2:0,v3:0};return t.set(n,r),r}return{increment(n,r){e(n)[r]+=1},versionMax(n){let r=e(n);return r.v3>r.v2?"v3":"v2"}}}async function Bt(t,e){let n=await t.store.get(t.resolve(".zattrs").path,{signal:e});return n?O(n):{}}async function xt(t,e={}){let n="store"in t?t:new x(t),{signal:r}=e,s={};return(e.attrs??!0)&&(s=await Bt(n,r)),r?.throwIfAborted(),e.kind==="array"?Oe(n,s,r):e.kind==="group"?Ue(n,s,r):Oe(n,s,r).catch(i=>(Ye(i,I,g),Ue(n,s,r)))}async function Oe(t,e,n){let{path:r}=t.resolve(".zarray"),s=await t.store.get(r,{signal:n});if(!s)throw new I("v2 array",{path:r});return Y.increment(t.store,"v2"),Ge(new D(t.store,t.path,He(O(s),e)))}async function Ue(t,e,n){let{path:r}=t.resolve(".zgroup"),s=await t.store.get(r,{signal:n});if(!s)throw new I("v2 group",{path:r});return Y.increment(t.store,"v2"),new he(t.store,t.path,et(O(s),e))}async function Mt(t,e){let{store:n,path:r}=t.resolve("zarr.json"),s=await t.store.get(r,{signal:e});if(!s)throw new I("v3 array or group",{path:r});let i=O(s);return i.node_type==="array"&&(i.fill_value=Ve(i)),i.node_type==="array"?Ge(new D(n,t.path,i)):new he(n,t.path,i)}async function $t(t,e={}){let n="store"in t?t:new x(t),r=await Mt(n,e.signal);if(Y.increment(n.store,"v3"),e.kind===void 0||e.kind==="array"&&r instanceof D||e.kind==="group"&&r instanceof he)return r;let s=r instanceof D?"array":"group";throw new I(`${e.kind} at ${n.path}`,{path:n.path,found:s})}async function k(t,e={}){let n="store"in t?t.store:t,r=Y.versionMax(n),s=r==="v2"?k.v2:k.v3,i=r==="v2"?k.v3:k.v2;return s(t,e).catch(a=>(Ye(a,I,g),i(t,e)))}k.v2=xt;k.v3=$t;function*Lt(t,e,n=1){e===void 0&&(e=t,t=0);for(let r=t;r<e;r+=n)yield r}function*Ot(...t){if(t.length===0)return;const e=t.map(r=>r[Symbol.iterator]()),n=e.map(r=>r.next());if(n.some(r=>r.done))throw new Error("Input contains an empty iterator.");for(let r=0;;){if(n[r].done){if(e[r]=t[r][Symbol.iterator](),n[r]=e[r].next(),++r>=e.length)return}else yield n.map(({value:s})=>s),r=0;n[r]=e[r].next()}}function Ut({start:t,stop:e,step:n},r){if(n===0)throw new $("slice step cannot be zero");n=n??1;const s=n<0,[i,a]=s?[-1,r-1]:[0,r];return t===null?t=s?a:i:t<0?(t+=r,t<i&&(t=i)):t>a&&(t=a),e===null?e=s?i:a:e<0?(e+=r,e<i&&(e=i)):e>a&&(e=a),[t,e,n]}function Q(t){if(t==null)return null;if(typeof t=="bigint"){if(t>Number.MAX_SAFE_INTEGER||t<Number.MIN_SAFE_INTEGER)throw new $(`Cannot safely convert ${t} to a number. Value exceeds Number.MAX_SAFE_INTEGER.`);return Number(t)}return t}function Re(t,e,n=null){return e===void 0&&(e=t,t=null),{start:Q(t),stop:Q(e),step:Q(n)}}function Rt(){const t=[];return{add:e=>t.push(e()),onIdle:()=>Promise.all(t)}}function vt(t,e){throw new $(`too many indicies for array; expected ${e.length}, got ${t.length}`)}function Ft(t){throw new $(`index out of bounds for dimension with length ${t}`)}function zt(){throw new $("only slices with step >= 1 are supported")}function Pt(t,e){t.length>e.length&&vt(t,e)}function Dt(t,e){return t=Math.trunc(t),t<0&&(t=e+t),(t>=e||t<0)&&Ft(e),t}class Vt{dimSel;dimLen;dimChunkLen;nitems;constructor({dimSel:e,dimLen:n,dimChunkLen:r}){e=Dt(e,n),this.dimSel=e,this.dimLen=n,this.dimChunkLen=r,this.nitems=1}*[Symbol.iterator](){const e=Math.floor(this.dimSel/this.dimChunkLen),n=e*this.dimChunkLen,r=this.dimSel-n;yield{dimChunkIx:e,dimChunkSel:r}}}class K{start;stop;step;dimLen;dimChunkLen;nitems;nchunks;constructor({dimSel:e,dimLen:n,dimChunkLen:r}){const[s,i,a]=Ut(e,n);this.start=s,this.stop=i,this.step=a,this.step<1&&zt(),this.dimLen=n,this.dimChunkLen=r,this.nitems=Math.max(0,Math.ceil((this.stop-this.start)/this.step)),this.nchunks=Math.ceil(this.dimLen/this.dimChunkLen)}*[Symbol.iterator](){const e=Math.floor(this.start/this.dimChunkLen),n=Math.ceil(this.stop/this.dimChunkLen);for(const r of Lt(e,n)){const s=r*this.dimChunkLen,i=Math.min(this.dimLen,(r+1)*this.dimChunkLen),a=i-s;let o=0,c=0;if(this.start<s){const h=(s-this.start)%this.step;h&&(c+=this.step-h),o=Math.ceil((s-this.start)/this.step)}else c=this.start-s;const u=this.stop>i?a:this.stop-s,d=[c,u,this.step],f=Math.ceil((u-c)/this.step),l=[o,o+f,1];yield{dimChunkIx:r,dimChunkSel:d,dimOutSel:l}}}}function Yt(t,e){let n=[];return t===null?n=e.map(r=>Re(null)):Array.isArray(t)&&(n=t.map(r=>r??Re(null))),Pt(n,e),n}class jt{dimIndexers;shape;outputAxes;constructor({selection:e,shape:n,chunkShape:r}){this.dimIndexers=Yt(e,n).map((s,i)=>new(typeof s=="number"?Vt:K)({dimSel:s,dimLen:n[i],dimChunkLen:r[i]})),this.shape=this.dimIndexers.filter(s=>s instanceof K).map(s=>s.nitems),this.outputAxes=this.dimIndexers.map((s,i)=>({ixr:s,axis:i})).filter(({ixr:s})=>s instanceof K).map(({axis:s})=>s)}*[Symbol.iterator](){for(const e of Ot(...this.dimIndexers)){const n=e.map(s=>s.dimChunkIx),r=e.map(s=>"dimOutSel"in s?{from:s.dimChunkSel,to:s.dimOutSel}:{from:s.dimChunkSel,to:null});yield{chunkCoords:n,mapping:r}}}}function ve(t,e){return"get"in t?t.get(e):t[e]}async function Jt(t,e,n,r){n.useSharedArrayBuffer&&Pe();let s=nt(n),i=kt(t),a=new jt({selection:e,shape:t.shape,chunkShape:t.chunks});if(t.shape.length===0){let{data:f}=await t.getChunk([],{signal:s},{useSharedArrayBuffer:n.useSharedArrayBuffer});return ve(f,0)}let o=a.shape.reduce((f,l)=>f*l,1),c;if(n.useSharedArrayBuffer){let f=new i.TypedArray(0);if(!("BYTES_PER_ELEMENT"in f))console.warn("zarrita: useSharedArrayBuffer is not supported for non-buffer-backed data types."),c=new i.TypedArray(o);else{let l=De(o*f.BYTES_PER_ELEMENT);c=new i.TypedArray(l,0,o)}}else c=new i.TypedArray(o);let u=r.prepare(c,a.shape,i.getStrides(a.shape,a.outputAxes)),d=n.createQueue?.()??Rt();for(const{chunkCoords:f,mapping:l}of a)d.add(async()=>{s?.throwIfAborted();let{data:h,shape:y,stride:w}=await t.getChunk(f,{signal:s},{useSharedArrayBuffer:n.useSharedArrayBuffer}),_=r.prepare(h,y,w);r.setFromChunk(u,_,l)});return await d.onIdle(),a.shape.length===0?ve(u.data,0):u}function pe(t,e=0,n){let r=n??t.length-e;return{length:r,subarray(s,i=r){return pe(t,e+s,i-s)},set(s,i=0){for(let a=0;a<s.length;a++)t[e+i+a]=s.get(a)},get(s){return t[e+s]}}}function W(t){return globalThis.Array.isArray(t.data)?{data:pe(t.data),stride:t.stride,bytesPerElement:1}:{data:new Uint8Array(t.data.buffer,t.data.byteOffset,t.data.byteLength),stride:t.stride,bytesPerElement:t.data.BYTES_PER_ELEMENT}}function Gt(t){return"chars"in t?t.constructor.bind(null,t.chars):t.constructor}function qt(t,e){if(globalThis.Array.isArray(t.data))return pe([e]);let n=Gt(t.data),r=new n([e]);return new Uint8Array(r.buffer,r.byteOffset,r.byteLength)}const Qt={prepare(t,e,n){return{data:t,shape:e,stride:n}},setScalar(t,e,n){let r=W(t);te(r,e,qt(t,n),r.bytesPerElement)},setFromChunk(t,e,n){let r=W(t);U(r,W(e),r.bytesPerElement,n)}};async function Fe(t,e=null,n={}){return Jt(t,e,n,Qt)}function ye(t,e,n){return n<0&&e<t?Math.floor((t-e-1)/-n)+1:t<e?Math.floor((e-t-1)/n)+1:0}function te(t,e,n,r){if(e.length===0){t.data.set(n,0);return}const[s,...i]=e,[a,...o]=t.stride;if(typeof s=="number"){const l=t.data.subarray(a*s*r);te({data:l,stride:o},i,n,r);return}const[c,u,d]=s,f=ye(c,u,d);if(i.length===0){for(let l=0;l<f;l++)t.data.set(n,a*(c+d*l)*r);return}for(let l=0;l<f;l++){const h=t.data.subarray(a*(c+d*l)*r);te({data:h,stride:o},i,n,r)}}function Kt(t,e,n){if(t.length!==e.length||t.length!==n.length)return null;let r=1,s=0,i=0;for(let a=t.length-1;a>=0;a--){const o=t[a];if(o.from===null||o.to===null||e[a]!==r||n[a]!==r)return null;const[c,u,d]=o.to,[f,,l]=o.from;if(d!==1||l!==1)return null;s+=r*c,i+=r*f,r*=ye(c,u,d)}return{size:r,destOffset:s,srcOffset:i}}function U(t,e,n,r){const s=Kt(r,t.stride,e.stride);if(s!==null){const p=s.srcOffset*n;t.data.set(e.data.subarray(p,p+s.size*n),s.destOffset*n);return}const[i,...a]=r,[o,...c]=t.stride,[u,...d]=e.stride;if(i.from===null){if(a.length===0){t.data.set(e.data.subarray(0,n),o*i.to*n);return}U({data:t.data.subarray(o*i.to*n),stride:c},e,n,a);return}if(i.to===null){if(a.length===0){let p=u*i.from*n;t.data.set(e.data.subarray(p,p+n),0);return}U(t,{data:e.data.subarray(u*i.from*n),stride:d},n,a);return}const[f,l,h]=i.to,[y,w,_]=i.from,m=ye(f,l,h);if(a.length===0){for(let p=0;p<m;p++){let E=u*(y+_*p)*n;t.data.set(e.data.subarray(E,E+n),o*(f+h*p)*n)}return}for(let p=0;p<m;p++)U({data:t.data.subarray(o*(f+p*h)*n),stride:c},{data:e.data.subarray(u*(y+p*_)*n),stride:d},n,a)}function Wt({posData:t,qData:e,totalPoints:n,transcriptQualityScoreThreshold:r,maxPointsPerTranscript:s,omeTiffScaleFactor:i,rng:a=Math.random}){const o=s,c=i,u=Math.min(n,o),d=new Float32Array(u*2),f=new e.constructor(u);let l=0,h=0;for(let m=0;m<n;m++){const p=e[m];if(!(p<r)){if(l++,h<o)d[h*2]=t[m*2]*c,d[h*2+1]=t[m*2+1]*c,f[h]=p;else{const E=Math.floor(a()*(h+1));E<o&&(d[E*2]=t[m*2]*c,d[E*2+1]=t[m*2+1]*c,f[E]=p)}h++}}const y=Math.min(h,o),w=h<o?d.slice(0,y*2):d,_=h<o?f.slice(0,y):f;return{transcriptPositions:w,transcriptQScores:_,nTotalTranscripts:l,nDownsampledTranscripts:y,isDownsampled:h>o}}const Xt=(t,e)=>{const{a:n,b:r,c:s,d:i,tx:a,ty:o}=e;for(let c=0;c+1<t.length;c+=2){const u=t[c],d=t[c+1];t[c]=n*u+r*d+a,t[c+1]=s*u+i*d+o}},X=self;X.onmessage=async t=>{const{transcriptsUrl:e,toWorld:n,transcriptSelection:r,transcriptQualityScoreThreshold:s,maxPointsPerTranscript:i}=t.data;try{const a=r.map(async d=>{const f=new me(`${e}/positions/${d.value}/`),l=new me(`${e}/q_scores/${d.value}/`),[h,y]=await Promise.all([k(f,{kind:"array"}),k(l,{kind:"array"})]),[w,_]=await Promise.all([Fe(h),Fe(y)]);return{transcriptName:d.label,transcriptIndex:d.value,positions:w,qScores:_}}),o=await Promise.all(a),c={},u=[];for(const d of o){const{transcriptName:f,transcriptIndex:l,positions:h,qScores:y}=d,w=Wt({posData:h.data,qData:y.data,totalPoints:h.shape[0],transcriptQualityScoreThreshold:s,maxPointsPerTranscript:i,omeTiffScaleFactor:1});Xt(w.transcriptPositions,n),u.push(w.transcriptPositions.buffer),u.push(w.transcriptQScores.buffer),c[f]={transcriptPositions:w.transcriptPositions,transcriptQScores:w.transcriptQScores,transcriptIndex:l,nTotalTranscripts:w.nTotalTranscripts,nDownsampledTranscripts:w.nDownsampledTranscripts,isDownsampled:w.isDownsampled}}X.postMessage({type:"SUCCESS",payload:c},{transfer:u})}catch(a){console.error(a),X.postMessage({type:"ERROR",payload:"Failed to load transcript positions"})}};
|
|
2
|
+
//# sourceMappingURL=transcripts.worker-CtxyO4n3.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function Ze(t,e){return{...t,...e,headers:{...t.headers,...e.headers}}}function me(t,e){const n=typeof t=="string"?new URL(t):t;n.pathname.endsWith("/")||(n.pathname+="/");const r=new URL(e.slice(1),n);return r.search=n.search,r}async function be(t){if(t.status!==404){if(t.status===200||t.status===206)return new Uint8Array(await t.arrayBuffer());throw new Error(`Unexpected response status ${t.status} ${t.statusText}`)}}class et{url;#e;#t;#n;constructor(e,n={}){this.url=e,this.#e=n.fetch??(r=>fetch(r)),this.#t=n.overrides??{},this.#n=n.useSuffixRequest??!1}#r(e,n){return new Request(e,Ze(this.#t,n))}async get(e,n={}){let r=me(this.url,e).href,s=this.#r(r,n),i=await this.#e(s);return be(i)}async getRange(e,n,r={}){let s=me(this.url,e),i;if("suffixLength"in n)i=await this.#s(s,n.suffixLength,r);else{let o={...r,headers:{...r.headers,Range:`bytes=${n.offset}-${n.offset+n.length-1}`}},a=this.#r(s,o);i=await this.#e(a)}return be(i)}async#s(e,n,r){if(this.#n){let l={...r,headers:{...r.headers,Range:`bytes=-${n}`}};return this.#e(this.#r(e,l))}let s=this.#r(e,{...r,method:"HEAD"}),i=await this.#e(s);if(!i.ok)return i;let o=i.headers.get("Content-Length"),a=Number(o),c=a-n,u={...r,headers:{...r.headers,Range:`bytes=${c}-${a-1}`}};return this.#e(this.#r(e,u))}}class C extends Error{}class T extends C{_tag="NotFoundError";name="NotFoundError";path;found;constructor(e,n={}){super(`Not found: ${e}`,{cause:n.cause}),this.path=n.path,this.found=n.found}}class y extends C{_tag="InvalidMetadataError";name="InvalidMetadataError";path;constructor(e,n={}){super(e,{cause:n.cause}),this.path=n.path}}class tt extends C{_tag="UnknownCodecError";name="UnknownCodecError";codec;constructor(e){super(`Unknown codec: ${e}`),this.codec=e}}class nt extends C{_tag="CodecPipelineError";name="CodecPipelineError";direction;codec;chunkPath;constructor(e){const n=[`Failed to ${e.direction} chunk`,e.codec&&`via codec "${e.codec}"`,e.chunkPath&&`at ${e.chunkPath}`].filter(Boolean);super(n.join(" "),{cause:e.cause}),this.direction=e.direction,this.codec=e.codec,this.chunkPath=e.chunkPath}}class x extends C{_tag="InvalidSelectionError";name="InvalidSelectionError"}class re extends C{_tag="UnsupportedError";name="UnsupportedError";feature;constructor(e){super(`Unsupported: ${e}`),this.feature=e}}function E(t){return()=>{throw new re(`${t} encode`)}}class F{kind="array_to_array";constructor(e,n){if(e.keepbits<0)throw new y("keepbits must be zero or positive")}static fromConfig(e,n){return new F(e,n)}encode=E("bitround");decode(e){return e}}function se(t){return t instanceof ArrayBuffer||t instanceof SharedArrayBuffer}class je{#e;constructor(e,n,r){typeof e=="number"?this.#e=new Uint8Array(e):se(e)?this.#e=new Uint8Array(e,n,r):this.#e=new Uint8Array(Array.from(e,s=>s?1:0))}get BYTES_PER_ELEMENT(){return 1}get byteOffset(){return this.#e.byteOffset}get byteLength(){return this.#e.byteLength}get buffer(){return this.#e.buffer}get length(){return this.#e.length}get(e){let n=this.#e[e];return typeof n=="number"?n!==0:n}set(e,n){this.#e[e]=n?1:0}fill(e){this.#e.fill(e?1:0)}*[Symbol.iterator](){for(let e=0;e<this.length;e++)yield this.get(e)}}class ie{_data;chars;#e;constructor(e,n,r,s){if(this.chars=e,this.#e=new TextEncoder,typeof n=="number")this._data=new Uint8Array(n*e);else if(se(n))s&&(s=s*e),this._data=new Uint8Array(n,r,s);else{let i=Array.from(n);this._data=new Uint8Array(i.length*e);for(let o=0;o<i.length;o++)this.set(o,i[o])}}get BYTES_PER_ELEMENT(){return this.chars}get byteOffset(){return this._data.byteOffset}get byteLength(){return this._data.byteLength}get buffer(){return this._data.buffer}get length(){return this.byteLength/this.BYTES_PER_ELEMENT}get(e){const n=new Uint8Array(this.buffer,this.byteOffset+this.chars*e,this.chars);return new TextDecoder().decode(n).replace(/\x00/g,"")}set(e,n){const r=new Uint8Array(this.buffer,this.byteOffset+this.chars*e,this.chars);r.fill(0),r.set(this.#e.encode(n))}fill(e){const n=this.#e.encode(e);for(let r=0;r<this.length;r++)this._data.set(n,r*this.chars)}*[Symbol.iterator](){for(let e=0;e<this.length;e++)yield this.get(e)}}class R{#e;chars;constructor(e,n,r,s){if(this.chars=e,typeof n=="number")this.#e=new Int32Array(n*e);else if(se(n))s&&(s*=e),this.#e=new Int32Array(n,r,s);else{const i=n,o=new R(e,1);this.#e=new Int32Array(function*(){for(let a of i)o.set(0,a),yield*o.#e}())}}get BYTES_PER_ELEMENT(){return this.#e.BYTES_PER_ELEMENT*this.chars}get byteLength(){return this.#e.byteLength}get byteOffset(){return this.#e.byteOffset}get buffer(){return this.#e.buffer}get length(){return this.#e.length/this.chars}get(e){const n=this.chars*e;let r="";for(let s=0;s<this.chars;s++)r+=String.fromCodePoint(this.#e[n+s]);return r.replace(/\u0000/g,"")}set(e,n){const r=this.chars*e,s=this.#e.subarray(r,r+this.chars);s.fill(0);for(let i=0;i<this.chars;i++)s[i]=n.codePointAt(i)??0}fill(e){this.set(0,e);let n=this.#e.subarray(0,this.chars);for(let r=1;r<this.length;r++)this.#e.set(n,r*this.chars)}*[Symbol.iterator](){for(let e=0;e<this.length;e++)yield this.get(e)}}function Ye(){if(typeof SharedArrayBuffer>"u")throw new Error("SharedArrayBuffer is not available. In browsers, this requires Cross-Origin-Opener-Policy and Cross-Origin-Embedder-Policy headers to be set.")}function Je(t,e){return new SharedArrayBuffer(t)}function $(t){const e=new TextDecoder().decode(t);try{return JSON.parse(e)}catch(n){throw new y("Failed to decode JSON",{cause:n})}}function _e(t,e){const n=e/2,r=e-1;let s=0;for(let i=0;i<t.length;i+=e)for(let o=0;o<n;o+=1)s=t[i+o],t[i+o]=t[i+r-o],t[i+r-o]=s}function I(t){if(t==="v2:object")return globalThis.Array;let e=t.match(/v2:([US])(\d+)/);if(e){let[,r,s]=e;return(r==="U"?R:ie).bind(null,Number(s))}if(t==="string")return globalThis.Array;let n={int8:Int8Array,int16:Int16Array,int32:Int32Array,int64:globalThis.BigInt64Array,uint8:Uint8Array,uint16:Uint16Array,uint32:Uint32Array,uint64:globalThis.BigUint64Array,float16:globalThis.Float16Array,float32:Float32Array,float64:Float64Array,bool:je}[t];if(!n)throw new y(`Unknown or unsupported dataType: ${t}`);return n}function N(t,e){const n=t.length;typeof e=="string"&&(e=e==="C"?Array.from({length:n},(i,o)=>o):Array.from({length:n},(i,o)=>n-1-o)),g(n===e.length,"Order length must match the number of dimensions.");let r=1,s=new Array(n);for(let i=e.length-1;i>=0;i--)s[e[i]]=r,r*=t[e[i]];return s}function rt({name:t,configuration:e}){if(t==="default"){const n=e?.separator??"/";return r=>["c",...r].join(n)}if(t==="v2"){const n=e?.separator??".";return r=>r.join(n)||"0"}throw new y(`Unknown chunk key encoding: ${t}`)}function Ee(t){if(t==="|O")return{dataType:"v2:object"};let e=t.match(/^([<|>])(.*)$/);if(!e)throw new y(`Invalid dtype: ${t}`);let[,n,r]=e,s={b1:"bool",i1:"int8",u1:"uint8",i2:"int16",u2:"uint16",i4:"int32",u4:"uint32",i8:"int64",u8:"uint64",f2:"float16",f4:"float32",f8:"float64"}[r]??(r.startsWith("S")||r.startsWith("U")?`v2:${r}`:void 0);if(!s)throw new y(`Unsupported or unknown dtype: ${t}`);return n==="|"?{dataType:s}:{dataType:s,endian:n==="<"?"little":"big"}}function st(t){return(t.id==="fixedscaleoffset"||t.id==="numcodecs.fixedscaleoffset")&&typeof t.scale=="number"&&typeof t.offset=="number"&&(t.astype===void 0||typeof t.astype=="string")&&(t.dtype===void 0||typeof t.dtype=="string")}function it(t,e={}){let n=[],r=Ee(t.dtype);t.order==="F"&&n.push({name:"transpose",configuration:{order:"F"}});for(let i of t.filters??[]){if(i.id==="fixedscaleoffset"||i.id==="numcodecs.fixedscaleoffset"){if(!st(i))throw new y(`Invalid fixedscaleoffset filter: ${JSON.stringify(i)}`);n.push({name:"scale_offset",configuration:{scale:i.scale,offset:i.offset}});let c=i.astype??i.dtype;if(c!==void 0&&c!==t.dtype){let u=Ee(c).dataType;if(!Z(u,"number")&&!Z(u,"bigint"))throw new y(`fixedscaleoffset astype must be a numeric data type, got ${c}`);n.push({name:"cast_value",configuration:{data_type:u,rounding:"nearest-even",out_of_range:"wrap"}})}continue}let{id:o,...a}=i;n.push({name:`numcodecs.${o}`,configuration:a})}if("endian"in r&&r.endian==="big"&&n.push({name:"bytes",configuration:{endian:"big"}}),t.compressor){let{id:i,...o}=t.compressor;n.push({name:`numcodecs.${i}`,configuration:o})}let s;return globalThis.Array.isArray(e._ARRAY_DIMENSIONS)&&(s=e._ARRAY_DIMENSIONS),{zarr_format:3,node_type:"array",shape:t.shape,data_type:r.dataType,chunk_grid:{name:"regular",configuration:{chunk_shape:t.chunks}},chunk_key_encoding:{name:"v2",configuration:{separator:t.dimension_separator??"."}},codecs:n,fill_value:t.fill_value,dimension_names:s,attributes:e}}function ot(t,e={}){return{zarr_format:3,node_type:"group",attributes:e}}function Z(t,e){if(e!=="number"&&e!=="bigint"&&e!=="boolean"&&e!=="object"&&e!=="string")return t===e;let n=t==="bool";if(e==="boolean")return n;let r=t.startsWith("v2:U")||t.startsWith("v2:S")||t==="string";if(e==="string")return r;let s=t==="int64"||t==="uint64";if(e==="bigint")return s;let i=t==="v2:object";return e==="object"?i:!r&&!s&&!n&&!i}function at(t){return t?.name==="sharding_indexed"}function qe(t){if((t.data_type==="uint64"||t.data_type==="int64")&&t.fill_value!=null)return BigInt(t.fill_value);let e=t.data_type==="float16"||t.data_type==="float32"||t.data_type==="float64";if(typeof t.fill_value=="string"&&e){let n={NaN:NaN,Infinity:1/0,"-Infinity":-1/0};if(t.fill_value in n)return n[t.fill_value]}return t.fill_value}function ct(t){let e=t.signal,n=t.opts?.signal;return e&&n?AbortSignal.any([e,n]):e??n}function Ge(t,...e){if(!e.some(n=>t instanceof n))throw t}function g(t,e=""){if(!t)throw new Error(e)}async function Ke(t,{format:e,signal:n}){let r;if(t instanceof ArrayBuffer)r=new Response(t);else{let s=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);r=new Response(s.slice().buffer)}g(r.body,"Response does not contain body.");try{return await new Response(r.body.pipeThrough(new DecompressionStream(e),{signal:n})).arrayBuffer()}catch{throw n?.throwIfAborted(),new Error(`Failed to decode ${e}`)}}const Se=ut();function ut(){const t=new Uint32Array([305419896]);return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)[0]!==18}function Ae(t){return"BYTES_PER_ELEMENT"in t?t.BYTES_PER_ELEMENT:4}class j{kind="array_to_bytes";#e;#t;#n;#r;#s;constructor(e,n){this.#s=e?.endian,this.#t=I(n.dataType),this.#r=n.shape,this.#e=N(n.shape,"C");const r=new this.#t(0);this.#n=r.BYTES_PER_ELEMENT}static fromConfig(e,n){return new j(e,n)}encode(e){let n=new Uint8Array(e.data.buffer);return Se&&this.#s==="big"&&(n=n.slice(),_e(n,Ae(this.#t))),n}computeEncodedSize(e){return e}decode(e){return Se&&this.#s==="big"&&(e=e.slice(),_e(e,Ae(this.#t))),{data:new this.#t(e.buffer,e.byteOffset,e.byteLength/this.#n),shape:this.#r,stride:this.#e}}}const ke={NaN:NaN,Infinity:1/0,"-Infinity":-1/0},We={float16:2,float32:4,float64:8};function v(t){return t in We}function ee(t){return t==="int64"||t==="uint64"}function ft(t,e){const n=BigInt(t),r=new ArrayBuffer(e),s=new DataView(r);if(e===2){if(typeof s.getFloat16!="function")throw new re("float16 hex-encoded scalar decoding (requires DataView.prototype.getFloat16)");return s.setUint16(0,Number(n)),s.getFloat16(0)}return e===4?(s.setUint32(0,Number(n)),s.getFloat32(0)):(s.setBigUint64(0,n),s.getFloat64(0))}function z(t,e){if(ee(t)){if(typeof e!="number"||!Number.isInteger(e))throw new y(`Expected an integer value for data type "${t}", got ${JSON.stringify(e)}`);return BigInt(e)}if(typeof e=="number"){if(!v(t)&&!Number.isInteger(e))throw new y(`Expected an integer value for data type "${t}", got ${e}`);return e}if(!v(t))throw new y(`String-encoded scalar "${e}" is not valid for non-float data type "${t}"`);return e in ke?ke[e]:ft(e,We[t])}const Ce=new Set(["int8","uint8","int16","uint16","int32","uint32","int64","uint64","float16","float32","float64"]),J={int8:[-128,2**7-1],uint8:[0,2**8-1],int16:[-32768,2**15-1],uint16:[0,2**16-1],int32:[-2147483648,2**31-1],uint32:[0,2**32-1]},q={int64:[-(2n**63n),2n**63n-1n],uint64:[0n,2n**64n-1n]};function Te(t,e,n){return t.map(([r,s])=>({src:z(e,r),tgt:z(n,s)}))}function dt(t,e){for(const n of e)if(typeof n.src=="number"&&Number.isNaN(n.src)){if(typeof t=="number"&&Number.isNaN(t))return n.tgt}else if(t===n.src)return n.tgt}function lt(t){if(!Number.isFinite(t))return t;if(Math.abs(t-Math.trunc(t))===.5){const e=Math.floor(t),n=Math.ceil(t);return e%2===0?e:n}return Math.round(t)}function ht(t){return Math.sign(t)*Math.floor(Math.abs(t)+.5)}function Ie(t){switch(t){case"nearest-even":return lt;case"towards-zero":return Math.trunc;case"towards-positive":return Math.ceil;case"towards-negative":return Math.floor;case"nearest-away":return ht}}function G(t,e,n){const r=e-t+1;switch(n){case"clamp":return s=>s<t?t:s>e?e:s;case"wrap":return s=>s>=t&&s<=e?s:((s-t)%r+r)%r+t;default:return s=>{if(s>=t&&s<=e)return s;throw new Error(`Value ${s} out of range [${t}, ${e}]. Set out_of_range='clamp' or out_of_range='wrap' to handle this.`)}}}function K(t,e,n){const r=e-t+1n;switch(n){case"clamp":return s=>s<t?t:s>e?e:s;case"wrap":return s=>s>=t&&s<=e?s:((s-t)%r+r)%r+t;default:return s=>{if(s>=t&&s<=e)return s;throw new Error(`Value ${s} out of range [${t}, ${e}]. Set out_of_range='clamp' or out_of_range='wrap' to handle this.`)}}}class oe{kind="array_to_array";#e;#t;#n;#r;constructor(e,n,r,s,i,o){this.#e=n,this.#t=I(e),this.#n=Ne(n,e,r,s,i),this.#r=Ne(e,n,r,s,o)}getEncodedMeta(e){let n=e.fillValue;return n!=null&&(n=this.#r(n)),{...e,dataType:this.#e,fillValue:n}}static fromConfig(e,n){const r=n.dataType,s=e.data_type;if(!Ce.has(r))throw new y(`cast_value codec does not support array data type: ${r}`);if(!Ce.has(s))throw new y(`cast_value codec does not support encoded data type: ${s}`);const i=e.rounding??"nearest-even",o=e.scalar_map?.decode?Te(e.scalar_map.decode,s,r):[],a=e.scalar_map?.encode?Te(e.scalar_map.encode,r,s):[];return new oe(r,s,i,e.out_of_range,o,a)}encode=E("cast_value");decode(e){const n=e.data,r=new this.#t(n.length);for(let s=0;s<n.length;s++)r[s]=this.#n(n[s]);return{data:r,shape:e.shape,stride:e.stride}}}function Ne(t,e,n,r,s){const i=v(t),o=ee(t),a=v(e),c=ee(e);let u;if(i&&a){if(n!=="nearest-even")throw new y(`cast_value float -> float only supports "nearest-even" rounding, got "${n}"`);u=f=>f}else if(i&&!a&&!c){const f=Ie(n),d=G(...J[e],r);u=h=>{if(!Number.isFinite(h))throw new Error(`Cannot cast ${h} to integer type without scalar_map`);return d(f(h))}}else if(i&&c){const f=Ie(n),d=K(...q[e],r);u=h=>{if(!Number.isFinite(h))throw new Error(`Cannot cast ${h} to integer type without scalar_map`);return d(BigInt(f(h)))}}else if(!i&&!o&&a)u=f=>f;else if(o&&a)u=f=>Number(f);else if(!i&&!o&&!a&&!c)u=G(...J[e],r);else if(!i&&!o&&c){const f=K(...q[e],r);u=d=>f(BigInt(d))}else if(o&&!a&&!c){const f=G(...J[e],r);u=d=>f(Number(d))}else if(o&&c)u=K(...q[e],r);else throw new Error(`Unhandled type combination: ${t} -> ${e}`);return s.length===0?u:f=>{const d=dt(f,s);return d!==void 0?d:u(f)}}class ae{kind="bytes_to_bytes";static fromConfig(){return new ae}encode=E("crc32c");decode(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength-4)}computeEncodedSize(e){return e+4}}const yt=new Set(["int8","uint8","int16","uint16","int32","uint32","int64","uint64","float16","float32","float64"]);function Oe(t,e){const n=t.length;let r=n===0||e[n-1]===1;for(let i=n-2;i>=0&&r;i--)r=e[i]===e[i+1]*t[i+1];if(r)return;let s=n===0||e[0]===1;for(let i=1;i<n&&s;i++)s=e[i]===e[i-1]*t[i-1];if(!s)throw new Error(`DeltaCodec requires C- or Fortran-contiguous strides, got shape=${JSON.stringify(t)} stride=${JSON.stringify(e)}`)}class ce{kind="array_to_array";#e;constructor(e){this.#e=e}static fromConfig(e,n){if(!yt.has(n.dataType))throw new y(`Delta codec does not support data type: ${n.dataType}`);return new ce(I(n.dataType))}encode(e){Oe(e.shape,e.stride);const n=e.data,r=new this.#e(n.length);r[0]=n[0];for(let s=1;s<n.length;s++)r[s]=n[s]-n[s-1];return{data:r,shape:e.shape,stride:e.stride}}decode(e){Oe(e.shape,e.stride);const n=e.data,r=new this.#e(n.length);r[0]=n[0];for(let s=1;s<n.length;s++)r[s]=r[s-1]+n[s];return{data:r,shape:e.shape,stride:e.stride}}}class ue{kind="bytes_to_bytes";static fromConfig(e){return new ue}encode=E("gzip");async decode(e){const n=await Ke(e,{format:"gzip"});return new Uint8Array(n)}}function pt(t,e){return g(!Number.isNaN(e),"JsonCodec allow_nan is false but NaN was encountered during encoding."),g(e!==Number.POSITIVE_INFINITY,"JsonCodec allow_nan is false but Infinity was encountered during encoding."),g(e!==Number.NEGATIVE_INFINITY,"JsonCodec allow_nan is false but -Infinity was encountered during encoding."),e}function gt(t,e){return e instanceof Object&&!Array.isArray(e)?Object.keys(e).sort().reduce((n,r)=>(n[r]=e[r],n),{}):e}class D{configuration;kind="array_to_bytes";#e;#t;constructor(e={}){this.configuration=e;const{encoding:n="utf-8",skipkeys:r=!1,ensure_ascii:s=!0,check_circular:i=!0,allow_nan:o=!0,sort_keys:a=!0,indent:c,strict:u=!0}=e;let l=e.separators;l||(c?l=[", ",": "]:l=[",",":"]),this.#e={encoding:n,skipkeys:r,ensure_ascii:s,check_circular:i,allow_nan:o,indent:c,separators:l,sort_keys:a},this.#t={strict:u}}static fromConfig(e){return new D(e)}encode(e){const{indent:n,encoding:r,ensure_ascii:s,check_circular:i,allow_nan:o,sort_keys:a}=this.#e;g(r==="utf-8","JsonCodec does not yet support non-utf-8 encoding.");const c=[];g(i,"JsonCodec does not yet support skipping the check for circular references during encoding."),o||c.push(pt),a&&c.push(gt);const u=Array.from(e.data);u.push("|O"),u.push(e.shape);let l;c.length&&(l=(d,h)=>{let w=h;for(let S of c)w=S(d,w);return w});let f=JSON.stringify(u,l,n);return s&&(f=f.replace(/[\u007F-\uFFFF]/g,d=>{const h=`0000${d.charCodeAt(0).toString(16)}`;return`\\u${h.substring(h.length-4)}`})),new TextEncoder().encode(f)}decode(e){const{strict:n}=this.#t;g(n,"JsonCodec does not yet support non-strict decoding.");const r=$(e),s=r.pop();r.pop(),g(s,"0D not implemented for JsonCodec.");const i=N(s,"C");return{data:r,shape:s,stride:i}}}const wt=new Set(["int8","uint8","int16","uint16","int32","uint32","int64","uint64","float16","float32","float64"]);class fe{kind="array_to_array";#e;#t;#n;constructor(e,n,r){this.#t=e,this.#n=n,this.#e=r}static fromConfig(e,n){if(!wt.has(n.dataType))throw new y(`scale_offset codec does not support data type: ${n.dataType}`);return new fe(z(n.dataType,e.scale??1),z(n.dataType,e.offset??0),I(n.dataType))}encode=E("scale_offset");decode(e){const n=e.data,r=new this.#e(n.length);for(let s=0;s<n.length;s++)r[s]=n[s]/this.#t+this.#n;return{data:r,shape:e.shape,stride:e.stride}}}class de{kind="bytes_to_bytes";#e;constructor(e,n){if(n){let r=new(I(n.dataType))(0);g("BYTES_PER_ELEMENT"in r,`Shuffle codec requires a fixed-size dtype, got "${n.dataType}"`),this.#e=r.BYTES_PER_ELEMENT}else this.#e=e.elementsize??4}static fromConfig(e,n){return new de(e,n)}encode(e){return mt(e,this.#e)}decode(e){return bt(e,this.#e)}}function mt(t,e){let n=t.length,r=Math.floor(n/e),s=new Uint8Array(n);for(let i=0;i<e;i++)for(let o=0;o<r;o++)s[i*r+o]=t[o*e+i];return s}function bt(t,e){let n=t.length,r=Math.floor(n/e),s=new Uint8Array(n);for(let i=0;i<e;i++)for(let o=0;o<r;o++)s[o*e+i]=t[i*r+o];return s}function Be(t){return t instanceof je||t instanceof ie||t instanceof R?new Proxy(t,{get(n,r){return n.get(Number(r))},set(n,r,s){return n.set(Number(r),s),!0}}):t}function _t(t,e){let n;return t.data instanceof ie||t.data instanceof R?n=new t.data.constructor(t.data.chars,t.data.length):n=new t.data.constructor(t.data.length),{data:n,shape:t.shape,stride:N(t.shape,e)}}function Et(t,e){let n=_t(t,e),r=t.shape.length,s=t.shape.reduce((c,u)=>c*u,1),i=Array(r).fill(0),o=Be(t.data),a=Be(n.data);for(let c=0;c<s;c++){let u=0,l=0;for(let f=0;f<r;f++)u+=i[f]*t.stride[f],l+=i[f]*n.stride[f];a[l]=o[u],i[0]+=1;for(let f=0;f<r;f++)if(i[f]===t.shape[f]){if(f+1===r)break;i[f]=0,i[f+1]+=1}}return n}function St(t){let e=t.shape.length;return g(e===t.stride.length,"Shape and stride must have the same length."),t.stride.map((n,r)=>({stride:n,index:r})).sort((n,r)=>r.stride-n.stride).map(n=>n.index)}function At(t,e){let n=St(t);return g(n.length===e.length,"Orders must match"),n.every((r,s)=>r===e[s])}class le{kind="array_to_array";#e;constructor(e,n){let r=e.order??"C",s=n.shape.length,i=new Array(s);if(r==="C")for(let o=0;o<s;++o)i[o]=o;else if(r==="F")for(let o=0;o<s;++o)i[o]=s-o-1;else{i=r;let o=new Array(s);i.forEach(a=>{g(!o[a],`Invalid permutation: ${JSON.stringify(r)}`),o[a]=!0})}this.#e=i}static fromConfig(e,n){return new le(e,n)}encode(e){return At(e,this.#e)?e:Et(e,this.#e)}decode(e){return{data:e.data,shape:e.shape,stride:N(e.shape,this.#e)}}}class P{kind="array_to_bytes";#e;#t;constructor(e){this.#e=e,this.#t=N(e,"C")}static fromConfig(e,n){return new P(n.shape)}encode=E("vlen-utf8");decode(e){let n=new TextDecoder,r=new DataView(e.buffer),s=Array(r.getUint32(0,!0)),i=4;for(let o=0;o<s.length;o++){let a=r.getUint32(i,!0);i+=4,s[o]=n.decode(e.buffer.slice(i,i+a)),i+=a}return{data:s,shape:this.#e,stride:this.#t}}}class he{kind="bytes_to_bytes";static fromConfig(e){return new he}encode=E("zlib");async decode(e){const n=await Ke(e,{format:"deflate"});return new Uint8Array(n)}}function kt(){let t=()=>import("./blosc-j6ygecpn.js").then(i=>i.default),e=()=>import("./lz4-rzy_Siro.js").then(i=>i.default),n=()=>import("./zstd-Cp7BEDDH.js").then(i=>i.default),r=()=>ue,s=()=>he;return new Map().set("blosc",t).set("lz4",e).set("zstd",n).set("gzip",r).set("zlib",s).set("transpose",()=>le).set("bytes",()=>j).set("crc32c",()=>ae).set("vlen-utf8",()=>P).set("json2",()=>D).set("bitround",()=>F).set("cast_value",()=>oe).set("scale_offset",()=>fe).set("numcodecs.blosc",t).set("numcodecs.lz4",e).set("numcodecs.zstd",n).set("numcodecs.gzip",r).set("numcodecs.zlib",s).set("numcodecs.vlen-utf8",()=>P).set("numcodecs.shuffle",()=>de).set("numcodecs.delta",()=>ce).set("numcodecs.bitround",()=>F).set("numcodecs.json2",()=>D)}const Ct=kt();function te(t){let e;function n(){return e||(e=Tt(t)),e}async function r(s,i,o){try{return await o()}catch(a){throw new nt({direction:s,codec:i,cause:a})}}return{async encode(s){let i=await n();for(const{name:a,codec:c}of i.arrayToArray)s=await r("encode",a,()=>c.encode(s));let o=await r("encode",i.arrayToBytes.name,()=>i.arrayToBytes.codec.encode(s));for(const{name:a,codec:c}of i.bytesToBytes)o=await r("encode",a,()=>c.encode(o));return o},async decode(s){let i=await n();for(let a=i.bytesToBytes.length-1;a>=0;a--){const{name:c,codec:u}=i.bytesToBytes[a];s=await r("decode",c,()=>u.decode(s))}let o=await r("decode",i.arrayToBytes.name,()=>i.arrayToBytes.codec.decode(s));for(let a=i.arrayToArray.length-1;a>=0;a--){const{name:c,codec:u}=i.arrayToArray[a];o=await r("decode",c,()=>u.decode(o))}return o},async computeEncodedSize(s){let i=await n(),o=Me(i.arrayToBytes.name,i.arrayToBytes.codec,s);for(const{name:a,codec:c}of i.bytesToBytes)o=Me(a,c,o);return o}}}function Me(t,e,n){if(!e.computeEncodedSize)throw new y(`Codec "${t}" cannot compute its encoded size; it is not a fixed-size codec and cannot be used in a sharding index pipeline`);return e.computeEncodedSize(n)}async function Tt(t){let e=t.codecs.map(async o=>{let a=await Ct.get(o.name)?.();if(!a)throw new tt(o.name);return{Codec:a,meta:o}}),n=[],r,s=[],i={...t};for await(let{Codec:o,meta:a}of e){let c=o.fromConfig(a.configuration,i);switch(c.kind){case"array_to_array":n.push({name:a.name,codec:c}),c.getEncodedMeta&&(i=c.getEncodedMeta(i));break;case"array_to_bytes":r={name:a.name,codec:c};break;default:s.push({name:a.name,codec:c})}}if(!r){if(!It(i))throw new y(`Cannot encode ${i.dataType} to bytes without a codec`);r={name:"bytes",codec:j.fromConfig({endian:"little"},i)}}return{arrayToArray:n,arrayToBytes:r,bytesToBytes:s}}function It(t){return t.dataType!=="v2:object"&&t.dataType!=="string"}const Le=18446744073709551615n;function Nt(t,e,n,r){if(!t.store.getRange)throw new re("sharding requires a store with getRange");let s=t.store.getRange.bind(t.store),i=e.map((u,l)=>u/r.chunk_shape[l]),o=te({dataType:"uint64",shape:[...i,2],codecs:r.index_codecs,fillValue:null}),a=16*i.reduce((u,l)=>u*l,1),c={};return async(u,l)=>{let f=u.map((m,b)=>Math.floor(m/i[b])),d=t.resolve(n(f)).path;d in c||(c[d]=(async()=>{let m=await o.computeEncodedSize(a),b=await s(d,{suffixLength:m},l);return b?await o.decode(b):null})().catch(m=>{throw delete c[d],m}));let h=await c[d];if(h===null)return;let{data:w,shape:S,stride:A}=h,B=u.map((m,b)=>m%S[b]).reduce((m,b,Qe)=>m+b*A[Qe],0),p=w[B],M=w[B+1];if(!(p===Le&&M===Le))return s(d,{offset:Number(p),length:Number(M)},l)}}class O{store;path;constructor(e,n="/"){this.store=e,this.path=n}resolve(e){let n=new URL(`file://${this.path.endsWith("/")?this.path:`${this.path}/`}`);return new O(this.store,decodeURIComponent(new URL(e,n).pathname))}}class ye extends O{kind="group";#e;constructor(e,n,r){super(e,n),this.#e=r}get attrs(){return this.#e.attributes}}function xe(t){return t.find(n=>n.name==="transpose")?.configuration?.order??"C"}function Ot(t,e){let n=new Map(e.map((r,s)=>[r,s]));return t.filter(r=>n.has(r)).map(r=>n.get(r))}function Re(t){return(e,n)=>{let r=globalThis.Array.isArray(t)&&n?Ot(t,n):t;return N(e,r)}}const L=Symbol("zarrita.context");function Bt(t){return t[L]}function Mt(t,e){let{configuration:n}=e.codecs.find(at)??{},r={encodeChunkKey:rt(e.chunk_key_encoding),TypedArray:I(e.data_type),fillValue:e.fill_value};if(n){let i=xe(n.codecs);return{...r,kind:"sharded",chunkShape:n.chunk_shape,codec:te({dataType:e.data_type,shape:n.chunk_shape,codecs:n.codecs,fillValue:e.fill_value}),getStrides:Re(i),getChunkBytes:Nt(t,e.chunk_grid.configuration.chunk_shape,r.encodeChunkKey,n)}}let s=xe(e.codecs);return{...r,kind:"regular",chunkShape:e.chunk_grid.configuration.chunk_shape,codec:te({dataType:e.data_type,shape:e.chunk_grid.configuration.chunk_shape,codecs:e.codecs,fillValue:e.fill_value}),getStrides:Re(s),async getChunkBytes(i,o){let a=r.encodeChunkKey(i),c=t.resolve(a).path;return t.store.get(c,o)}}}let V=class extends O{kind="array";#e;[L];constructor(e,n,r){super(e,n),this.#e={...r,fill_value:qe(r)},this[L]=Mt(this,this.#e)}get attrs(){return this.#e.attributes}get dimensionNames(){return this.#e.dimension_names}get fillValue(){return this.#e.fill_value}get shape(){return this.#e.shape}get chunks(){return this[L].chunkShape}get dtype(){return this.#e.data_type}async getChunk(e,n,r){r?.useSharedArrayBuffer&&Ye();let s=this[L],i=await s.getChunkBytes(e,n);if(!i){let o=s.chunkShape.reduce((c,u)=>c*u,1),a;if(r?.useSharedArrayBuffer){let c=new s.TypedArray(0);if(!("BYTES_PER_ELEMENT"in c))console.warn("zarrita: useSharedArrayBuffer is not supported for non-buffer-backed data types."),a=new s.TypedArray(o);else{let u=Je(o*c.BYTES_PER_ELEMENT);a=new s.TypedArray(u,0,o)}}else a=new s.TypedArray(o);return a.fill(s.fillValue),{data:a,shape:s.chunkShape,stride:s.getStrides(s.chunkShape)}}return s.codec.decode(i)}is(e){return Z(this.dtype,e)}};function Lt(t,e){let n=t;for(let r of e)n instanceof Promise?n=n.then(s=>r(s)):n=r(n);return n}function xt(t,...e){return Lt(t,e)}async function Xe(t){let e=t.store.arrayExtensions;return e?.length?await xt(t,...e):t}let Y=Rt();function Rt(){let t=new WeakMap;function e(n){let r=t.get(n)??{v2:0,v3:0};return t.set(n,r),r}return{increment(n,r){e(n)[r]+=1},versionMax(n){let r=e(n);return r.v3>r.v2?"v3":"v2"}}}async function $t(t,e){let n=await t.store.get(t.resolve(".zattrs").path,{signal:e});return n?$(n):{}}async function Ut(t,e={}){let n="store"in t?t:new O(t),{signal:r}=e,s={};return(e.attrs??!0)&&(s=await $t(n,r)),r?.throwIfAborted(),e.kind==="array"?$e(n,s,r):e.kind==="group"?Ue(n,s,r):$e(n,s,r).catch(i=>(Ge(i,T,y),Ue(n,s,r)))}async function $e(t,e,n){let{path:r}=t.resolve(".zarray"),s=await t.store.get(r,{signal:n});if(!s)throw new T("v2 array",{path:r});return Y.increment(t.store,"v2"),Xe(new V(t.store,t.path,it($(s),e)))}async function Ue(t,e,n){let{path:r}=t.resolve(".zgroup"),s=await t.store.get(r,{signal:n});if(!s)throw new T("v2 group",{path:r});return Y.increment(t.store,"v2"),new ye(t.store,t.path,ot($(s),e))}async function Ft(t,e){let{store:n,path:r}=t.resolve("zarr.json"),s=await t.store.get(r,{signal:e});if(!s)throw new T("v3 array or group",{path:r});let i=$(s);return i.node_type==="array"&&(i.fill_value=qe(i)),i.node_type==="array"?Xe(new V(n,t.path,i)):new ye(n,t.path,i)}async function vt(t,e={}){let n="store"in t?t:new O(t),r=await Ft(n,e.signal);if(Y.increment(n.store,"v3"),e.kind===void 0||e.kind==="array"&&r instanceof V||e.kind==="group"&&r instanceof ye)return r;let s=r instanceof V?"array":"group";throw new T(`${e.kind} at ${n.path}`,{path:n.path,found:s})}async function _(t,e={}){let n="store"in t?t.store:t,r=Y.versionMax(n),s=r==="v2"?_.v2:_.v3,i=r==="v2"?_.v3:_.v2;return s(t,e).catch(o=>(Ge(o,T,y),i(t,e)))}_.v2=Ut;_.v3=vt;function*zt(t,e,n=1){e===void 0&&(e=t,t=0);for(let r=t;r<e;r+=n)yield r}function*Dt(...t){if(t.length===0)return;const e=t.map(r=>r[Symbol.iterator]()),n=e.map(r=>r.next());if(n.some(r=>r.done))throw new Error("Input contains an empty iterator.");for(let r=0;;){if(n[r].done){if(e[r]=t[r][Symbol.iterator](),n[r]=e[r].next(),++r>=e.length)return}else yield n.map(({value:s})=>s),r=0;n[r]=e[r].next()}}function Pt({start:t,stop:e,step:n},r){if(n===0)throw new x("slice step cannot be zero");n=n??1;const s=n<0,[i,o]=s?[-1,r-1]:[0,r];return t===null?t=s?o:i:t<0?(t+=r,t<i&&(t=i)):t>o&&(t=o),e===null?e=s?i:o:e<0?(e+=r,e<i&&(e=i)):e>o&&(e=o),[t,e,n]}function W(t){if(t==null)return null;if(typeof t=="bigint"){if(t>Number.MAX_SAFE_INTEGER||t<Number.MIN_SAFE_INTEGER)throw new x(`Cannot safely convert ${t} to a number. Value exceeds Number.MAX_SAFE_INTEGER.`);return Number(t)}return t}function Fe(t,e,n=null){return e===void 0&&(e=t,t=null),{start:W(t),stop:W(e),step:W(n)}}function Vt(){const t=[];return{add:e=>t.push(e()),onIdle:()=>Promise.all(t)}}function jt(t,e){throw new x(`too many indicies for array; expected ${e.length}, got ${t.length}`)}function Yt(t){throw new x(`index out of bounds for dimension with length ${t}`)}function Jt(){throw new x("only slices with step >= 1 are supported")}function qt(t,e){t.length>e.length&&jt(t,e)}function Gt(t,e){return t=Math.trunc(t),t<0&&(t=e+t),(t>=e||t<0)&&Yt(e),t}class Kt{dimSel;dimLen;dimChunkLen;nitems;constructor({dimSel:e,dimLen:n,dimChunkLen:r}){e=Gt(e,n),this.dimSel=e,this.dimLen=n,this.dimChunkLen=r,this.nitems=1}*[Symbol.iterator](){const e=Math.floor(this.dimSel/this.dimChunkLen),n=e*this.dimChunkLen,r=this.dimSel-n;yield{dimChunkIx:e,dimChunkSel:r}}}class X{start;stop;step;dimLen;dimChunkLen;nitems;nchunks;constructor({dimSel:e,dimLen:n,dimChunkLen:r}){const[s,i,o]=Pt(e,n);this.start=s,this.stop=i,this.step=o,this.step<1&&Jt(),this.dimLen=n,this.dimChunkLen=r,this.nitems=Math.max(0,Math.ceil((this.stop-this.start)/this.step)),this.nchunks=Math.ceil(this.dimLen/this.dimChunkLen)}*[Symbol.iterator](){const e=Math.floor(this.start/this.dimChunkLen),n=Math.ceil(this.stop/this.dimChunkLen);for(const r of zt(e,n)){const s=r*this.dimChunkLen,i=Math.min(this.dimLen,(r+1)*this.dimChunkLen),o=i-s;let a=0,c=0;if(this.start<s){const h=(s-this.start)%this.step;h&&(c+=this.step-h),a=Math.ceil((s-this.start)/this.step)}else c=this.start-s;const u=this.stop>i?o:this.stop-s,l=[c,u,this.step],f=Math.ceil((u-c)/this.step),d=[a,a+f,1];yield{dimChunkIx:r,dimChunkSel:l,dimOutSel:d}}}}function Wt(t,e){let n=[];return t===null?n=e.map(r=>Fe(null)):Array.isArray(t)&&(n=t.map(r=>r??Fe(null))),qt(n,e),n}class Xt{dimIndexers;shape;outputAxes;constructor({selection:e,shape:n,chunkShape:r}){this.dimIndexers=Wt(e,n).map((s,i)=>new(typeof s=="number"?Kt:X)({dimSel:s,dimLen:n[i],dimChunkLen:r[i]})),this.shape=this.dimIndexers.filter(s=>s instanceof X).map(s=>s.nitems),this.outputAxes=this.dimIndexers.map((s,i)=>({ixr:s,axis:i})).filter(({ixr:s})=>s instanceof X).map(({axis:s})=>s)}*[Symbol.iterator](){for(const e of Dt(...this.dimIndexers)){const n=e.map(s=>s.dimChunkIx),r=e.map(s=>"dimOutSel"in s?{from:s.dimChunkSel,to:s.dimOutSel}:{from:s.dimChunkSel,to:null});yield{chunkCoords:n,mapping:r}}}}function ve(t,e){return"get"in t?t.get(e):t[e]}async function Ht(t,e,n,r){n.useSharedArrayBuffer&&Ye();let s=ct(n),i=Bt(t),o=new Xt({selection:e,shape:t.shape,chunkShape:t.chunks});if(t.shape.length===0){let{data:f}=await t.getChunk([],{signal:s},{useSharedArrayBuffer:n.useSharedArrayBuffer});return ve(f,0)}let a=o.shape.reduce((f,d)=>f*d,1),c;if(n.useSharedArrayBuffer){let f=new i.TypedArray(0);if(!("BYTES_PER_ELEMENT"in f))console.warn("zarrita: useSharedArrayBuffer is not supported for non-buffer-backed data types."),c=new i.TypedArray(a);else{let d=Je(a*f.BYTES_PER_ELEMENT);c=new i.TypedArray(d,0,a)}}else c=new i.TypedArray(a);let u=r.prepare(c,o.shape,i.getStrides(o.shape,o.outputAxes)),l=n.createQueue?.()??Vt();for(const{chunkCoords:f,mapping:d}of o)l.add(async()=>{s?.throwIfAborted();let{data:h,shape:w,stride:S}=await t.getChunk(f,{signal:s},{useSharedArrayBuffer:n.useSharedArrayBuffer}),A=r.prepare(h,w,S);r.setFromChunk(u,A,d)});return await l.onIdle(),o.shape.length===0?ve(u.data,0):u}function pe(t,e=0,n){let r=n??t.length-e;return{length:r,subarray(s,i=r){return pe(t,e+s,i-s)},set(s,i=0){for(let o=0;o<s.length;o++)t[e+i+o]=s.get(o)},get(s){return t[e+s]}}}function H(t){return globalThis.Array.isArray(t.data)?{data:pe(t.data),stride:t.stride,bytesPerElement:1}:{data:new Uint8Array(t.data.buffer,t.data.byteOffset,t.data.byteLength),stride:t.stride,bytesPerElement:t.data.BYTES_PER_ELEMENT}}function Qt(t){return"chars"in t?t.constructor.bind(null,t.chars):t.constructor}function Zt(t,e){if(globalThis.Array.isArray(t.data))return pe([e]);let n=Qt(t.data),r=new n([e]);return new Uint8Array(r.buffer,r.byteOffset,r.byteLength)}const en={prepare(t,e,n){return{data:t,shape:e,stride:n}},setScalar(t,e,n){let r=H(t);ne(r,e,Zt(t,n),r.bytesPerElement)},setFromChunk(t,e,n){let r=H(t);U(r,H(e),r.bytesPerElement,n)}};async function tn(t,e=null,n={}){return Ht(t,e,n,en)}function ge(t,e,n){return n<0&&e<t?Math.floor((t-e-1)/-n)+1:t<e?Math.floor((e-t-1)/n)+1:0}function ne(t,e,n,r){if(e.length===0){t.data.set(n,0);return}const[s,...i]=e,[o,...a]=t.stride;if(typeof s=="number"){const d=t.data.subarray(o*s*r);ne({data:d,stride:a},i,n,r);return}const[c,u,l]=s,f=ge(c,u,l);if(i.length===0){for(let d=0;d<f;d++)t.data.set(n,o*(c+l*d)*r);return}for(let d=0;d<f;d++){const h=t.data.subarray(o*(c+l*d)*r);ne({data:h,stride:a},i,n,r)}}function nn(t,e,n){if(t.length!==e.length||t.length!==n.length)return null;let r=1,s=0,i=0;for(let o=t.length-1;o>=0;o--){const a=t[o];if(a.from===null||a.to===null||e[o]!==r||n[o]!==r)return null;const[c,u,l]=a.to,[f,,d]=a.from;if(l!==1||d!==1)return null;s+=r*c,i+=r*f,r*=ge(c,u,l)}return{size:r,destOffset:s,srcOffset:i}}function U(t,e,n,r){const s=nn(r,t.stride,e.stride);if(s!==null){const p=s.srcOffset*n;t.data.set(e.data.subarray(p,p+s.size*n),s.destOffset*n);return}const[i,...o]=r,[a,...c]=t.stride,[u,...l]=e.stride;if(i.from===null){if(o.length===0){t.data.set(e.data.subarray(0,n),a*i.to*n);return}U({data:t.data.subarray(a*i.to*n),stride:c},e,n,o);return}if(i.to===null){if(o.length===0){let p=u*i.from*n;t.data.set(e.data.subarray(p,p+n),0);return}U(t,{data:e.data.subarray(u*i.from*n),stride:l},n,o);return}const[f,d,h]=i.to,[w,S,A]=i.from,B=ge(f,d,h);if(o.length===0){for(let p=0;p<B;p++){let M=u*(w+A*p)*n;t.data.set(e.data.subarray(M,M+n),a*(f+h*p)*n)}return}for(let p=0;p<B;p++)U({data:t.data.subarray(a*(f+p*h)*n),stride:c},{data:e.data.subarray(u*(w+p*A)*n),stride:l},n,o)}const we=[[68,1,84],[62,74,137],[38,130,142],[39,176,105],[224,227,30]],ze=(t,e=we)=>{if(!e||e.length<2)return e?.[0]??[128,128,128];const n=t<0?0:t>1?1:t,r=e.length-1,s=n*r,i=Math.min(Math.floor(s),r-1),o=s-i,[a,c,u]=e[i],[l,f,d]=e[i+1];return[Math.round(a+(l-a)*o),Math.round(c+(f-c)*o),Math.round(u+(d-u)*o)]},rn=(t,e,n,r=we)=>Number.isFinite(t)?n===e||!Number.isFinite(n)||!Number.isFinite(e)?ze(.5,r):ze((t-e)/(n-e),r):[128,128,128],De=(t,e,n)=>rn(t,e,n,we),He=200,Q=256,sn=(t,e)=>{const n=new Uint8Array(e*4);for(let r=0;r<e;r++){const s=r*3,i=s+2<t.length;n[r*4]=i?t[s]:128,n[r*4+1]=i?t[s+1]:128,n[r*4+2]=i?t[s+2]:128,n[r*4+3]=He}return n},on=(t,e,n)=>{const r=new Uint8Array(n*4),[s,i]=e,o=i-s,a=Array.from({length:Q},(c,u)=>De(s+u/(Q-1)*o,s,i));for(let c=0;c<n;c++){const u=t[c],[l,f,d]=c>=t.length?[128,128,128]:o>0&&Number.isFinite(u)?a[Math.round(Math.min(1,Math.max(0,(u-s)/o))*(Q-1))]:De(u,s,i);r[c*4]=l,r[c*4+1]=f,r[c*4+2]=d,r[c*4+3]=He}return r},an=(t,e,n)=>{const r=new Uint8Array(n*4),s=new Int32Array(n).fill(-1);for(const i in t){const o=Number(i),a=e[o];if(!a)continue;const c=t[o],u=a[3]>0;for(let l=0;l<c.length;l++){const f=c[l];f>=n||(r[f*4]=a[0],r[f*4+1]=a[1],r[f*4+2]=a[2],r[f*4+3]=a[3],u&&(s[f]=o))}}return{colors:r,categoryOf:s}},k=self;let Pe={},Ve=0;k.onmessage=async t=>{const e=t.data;switch(e.type){case"LOAD":{try{const n=await _(new et(e.url),{kind:"array"}),s=(await tn(n)).data,i=s instanceof Float32Array&&s.byteOffset===0&&s.byteLength===s.buffer.byteLength?s:Float32Array.from(s);k.postMessage({type:"LOADED",requestId:e.requestId,coordinates:i},[i.buffer])}catch(n){k.postMessage({type:"LOAD_ERROR",requestId:e.requestId,message:n instanceof Error?n.message:String(n)})}break}case"SET_CODES":{Pe=e.codes,Ve=e.nPoints;break}case"COLORS_CATEGORICAL":{const{colors:n,categoryOf:r}=an(Pe,e.colorByCat,Ve);k.postMessage({type:"COLORS",requestId:e.requestId,colors:n,categoryOf:r},[n.buffer,r.buffer]);break}case"COLORS_PACKED":{const n=sn(e.rgb,e.nPoints);k.postMessage({type:"COLORS",requestId:e.requestId,colors:n,categoryOf:null},[n.buffer]);break}case"COLORS_EXPRESSION":{const n=on(e.values,e.range,e.nPoints);k.postMessage({type:"COLORS",requestId:e.requestId,colors:n,categoryOf:null},[n.buffer]);break}}};
|
|
2
|
+
//# sourceMappingURL=umap.worker-BPHuoLPV.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{B as r}from"./index-BT-mDgg2.js";class s extends r{constructor(){if(super(),typeof createImageBitmap>"u")throw new Error("Cannot decode WebImage as `createImageBitmap` is not available");if(typeof document>"u"&&typeof OffscreenCanvas>"u")throw new Error("Cannot decode WebImage as neither `document` nor `OffscreenCanvas` is not available")}async decode(i,n){const o=new Blob([n]),e=await createImageBitmap(o);let t;typeof document<"u"?(t=document.createElement("canvas"),t.width=e.width,t.height=e.height):t=new OffscreenCanvas(e.width,e.height);const a=t.getContext("2d");return a.drawImage(e,0,0),a.getImageData(0,0,e.width,e.height).data.buffer}}export{s as default};
|
|
2
|
+
//# sourceMappingURL=webimage-xg0Pp5Jv.js.map
|