UNPKG

@jaak.ai/file-uploader

Version:
1 lines 394 kB
import{r as t,c as e,h as i,F as s,H as r,g as n}from"./p-67a8e768.js";import{a as h,c as a}from"./p-585e0c37.js";class o{static fract(t){return t-Math.floor(t)}static smoothStep(t,e,i){const s=(i-t)/(e-t);const r=o.clamp(s,0,1);return r*r*(3-2*r)}static mix(t,e,i){return t*(1-i)+e*i}static sign(t){return t<0?-1:t>0?1:0}static step(t,e){return e<t?0:1}static length3(t,e,i){return Math.sqrt(t*t+e*e+i*i)}static gcd(t,e){let i=Math.abs(t);let s=Math.abs(e);while(s){const t=s;s=i%s;i=t}return i}static clamp(t,e,i){return Math.max(e,Math.min(t,i))}static clampInt(t,e,i){return Math.trunc(o.clamp(t,e,i))}static clampInt255(t){return Math.trunc(o.clamp(t,0,255))}}class u extends Error{toString(){return`${this.constructor.name} (${this.message})`}}var l;(function(t){t[t["uint1"]=0]="uint1";t[t["uint2"]=1]="uint2";t[t["uint4"]=2]="uint4";t[t["uint8"]=3]="uint8";t[t["uint16"]=4]="uint16";t[t["uint32"]=5]="uint32";t[t["int8"]=6]="int8";t[t["int16"]=7]="int16";t[t["int32"]=8]="int32";t[t["float16"]=9]="float16";t[t["float32"]=10]="float32";t[t["float64"]=11]="float64"})(l||(l={}));var c;(function(t){t[t["uint"]=0]="uint";t[t["int"]=1]="int";t[t["float"]=2]="float"})(c||(c={}));const f=new Map([[l.uint1,1],[l.uint2,1],[l.uint4,1],[l.uint8,1],[l.uint16,2],[l.uint32,4],[l.int8,1],[l.int16,2],[l.int32,4],[l.float16,2],[l.float32,4],[l.float64,8]]);const d=new Map([[l.uint1,1],[l.uint2,3],[l.uint4,15],[l.uint8,255],[l.uint16,65535],[l.uint32,4294967295],[l.int8,127],[l.int16,32767],[l.int32,2147483647],[l.float16,1],[l.float32,1],[l.float64,1]]);function g(t,e,i){return i===l.uint1?Math.ceil(t*e/8):i===l.uint2?Math.ceil(t*e/4):i===l.uint4?Math.ceil(t*e/2):t*e*f.get(i)}function m(t,e,i){if(e===i){return t}switch(e){case l.uint1:return t===0?0:d.get(i);case l.uint2:switch(i){case l.uint1:return t===0?0:1;case l.uint2:return t;case l.uint4:return t*5;case l.uint8:return t*75;case l.uint16:return t*21845;case l.uint32:return t*1431655765;case l.int8:return t*42;case l.int16:return t*10922;case l.int32:return t*715827882;case l.float16:case l.float32:case l.float64:return t/3}break;case l.uint4:switch(i){case l.uint1:return t===0?0:1;case l.uint2:return Math.trunc(t)>>>1;case l.uint4:return t;case l.uint8:return t*17;case l.uint16:return t*4369;case l.uint32:return t*286331153;case l.int8:return t*8;case l.int16:return t*2184;case l.int32:return t*143165576;case l.float16:case l.float32:case l.float64:return t/3}break;case l.uint8:switch(i){case l.uint1:return t===0?0:1;case l.uint2:return Math.trunc(t)>>>6;case l.uint4:return Math.trunc(t)>>>4;case l.uint8:return t;case l.uint16:return t*257;case l.uint32:return t*16843009;case l.int8:return Math.trunc(t)>>>1;case l.int16:return t*128;case l.int32:return t*8421504;case l.float16:case l.float32:case l.float64:return t/255}break;case l.uint16:switch(i){case l.uint1:return t===0?0:1;case l.uint2:return Math.trunc(t)>>>14;case l.uint4:return Math.trunc(t)>>>12;case l.uint8:return Math.trunc(t)>>>8;case l.uint16:return t;case l.uint32:return Math.trunc(t)<<8;case l.int8:return Math.trunc(t)>>>9;case l.int16:return Math.trunc(t)>>>1;case l.int32:return t*524296;case l.float16:case l.float32:case l.float64:return t/65535}break;case l.uint32:switch(i){case l.uint1:return t===0?0:1;case l.uint2:return Math.trunc(t)>>>30;case l.uint4:return Math.trunc(t)>>>28;case l.uint8:return Math.trunc(t)>>>24;case l.uint16:return Math.trunc(t)>>>16;case l.uint32:return t;case l.int8:return Math.trunc(t)>>>25;case l.int16:return Math.trunc(t)>>>17;case l.int32:return Math.trunc(t)>>>1;case l.float16:case l.float32:case l.float64:return t/4294967295}break;case l.int8:switch(i){case l.uint1:return t===0?0:1;case l.uint2:return t<=0?0:Math.trunc(t)>>>5;case l.uint4:return t<=0?0:Math.trunc(t)>>>3;case l.uint8:return t<=0?0:Math.trunc(t)<<1;case l.uint16:return t<=0?0:Math.trunc(t)*516;case l.uint32:return t<=0?0:Math.trunc(t)*33818640;case l.int8:return t;case l.int16:return t*258;case l.int32:return t*16909320;case l.float16:case l.float32:case l.float64:return t/127}break;case l.int16:switch(i){case l.uint1:return t===0?0:1;case l.uint2:return t<=0?0:Math.trunc(t)>>>15;case l.uint4:return t<=0?0:Math.trunc(t)>>>11;case l.uint8:return t<=0?0:Math.trunc(t)>>>7;case l.uint16:return t<=0?0:Math.trunc(t)<<1;case l.uint32:return t<=0?0:Math.trunc(t)*131076;case l.int8:return Math.trunc(t)>>>8;case l.int16:return t;case l.int32:return Math.trunc(t)*65538;case l.float16:case l.float32:case l.float64:return t/32767}break;case l.int32:switch(i){case l.uint1:return t===0?0:1;case l.uint2:return t<=0?0:Math.trunc(t)>>>29;case l.uint4:return t<=0?0:Math.trunc(t)>>>27;case l.uint8:return t<=0?0:Math.trunc(t)>>>23;case l.uint16:return t<=0?0:Math.trunc(t)>>>16;case l.uint32:return t<=0?0:Math.trunc(t)<<1;case l.int8:return Math.trunc(t)>>>24;case l.int16:return Math.trunc(t)>>>16;case l.int32:return t;case l.float16:case l.float32:case l.float64:return t/2147483647}break;case l.float16:case l.float32:case l.float64:switch(i){case l.uint1:return t===0?0:1;case l.uint2:return Math.trunc(o.clamp(t,0,1)*3);case l.uint4:return Math.trunc(o.clamp(t,0,1)*15);case l.uint8:return Math.trunc(o.clamp(t,0,1)*255);case l.uint16:return Math.trunc(o.clamp(t,0,1)*65535);case l.uint32:return Math.trunc(o.clamp(t,0,1)*4294967295);case l.int8:return Math.trunc(t<0?o.clamp(t,-1,1)*128:o.clamp(t,-1,1)*127);case l.int16:return Math.trunc(t<0?o.clamp(t,-1,1)*32768:o.clamp(t,-1,1)*32767);case l.int32:return Math.trunc(t<0?o.clamp(t,-1,1)*2147483648:o.clamp(t,-1,1)*2147483647);case l.float16:case l.float32:case l.float64:return t}break}throw new u("Unknown format.")}class w{get numerator(){return this._numerator}get denominator(){return this._denominator}get toInt(){return this.denominator!==0?Math.trunc(this.numerator/this.denominator):0}get toDouble(){return this.denominator!==0?this.numerator/this.denominator:0}constructor(t,e){this._numerator=t;this._denominator=e}simplify(){const t=o.gcd(this.numerator,this.denominator);if(t!==0){this._numerator=Math.trunc(this.numerator/t);this._denominator=Math.trunc(this.denominator/t)}}equals(t){return this._numerator===t._numerator&&this._denominator===t._denominator}toString(){return`${this.constructor.name} (${this._numerator}/${this._denominator})`}}class p{static copyInt8(t,e,i){return Int8Array.from(t.subarray(e,i))}static copyUint8(t,e,i){return Uint8Array.from(t.subarray(e,i))}static copyInt16(t,e,i){return Int16Array.from(t.subarray(e,i))}static copyUint16(t,e,i){return Uint16Array.from(t.subarray(e,i))}static copyInt32(t,e,i){return Int32Array.from(t.subarray(e,i))}static copyUint32(t,e,i){return Uint32Array.from(t.subarray(e,i))}static copyFloat32(t,e,i){return Float32Array.from(t.subarray(e,i))}static copyFloat64(t,e,i){return Float64Array.from(t.subarray(e,i))}static copy(t,e,i){if(t instanceof Int8Array){return p.copyInt8(t,e,i)}else if(t instanceof Uint8Array){return p.copyUint8(t,e,i)}else if(t instanceof Int16Array){return p.copyInt16(t,e,i)}else if(t instanceof Uint16Array){return p.copyUint16(t,e,i)}else if(t instanceof Int32Array){return p.copyInt32(t,e,i)}else if(t instanceof Uint32Array){return p.copyUint32(t,e,i)}else if(t instanceof Float32Array){return p.copyFloat32(t,e,i)}else if(t instanceof Float64Array){return p.copyFloat64(t,e,i)}throw new u("Unknown array type")}static copyRange(t,e,i,s,r){const n=t.subarray(e,e+r);i.set(n,s)}static fill(t,e){const i=new Array(t);return i.fill(e)}static generate(t,e){const i=new Array(t);for(let s=0;s<t;++s){i[s]=e(s)}return i}static equals(t,e){if(t===e)return true;if(t.length!==e.length)return false;for(let i=0,s=t.length;i<s;i++){if(p.isNumArrayOrTypedArray(t[i])&&p.isNumArrayOrTypedArray(e[i])){if(!p.equals(t[i],e[i]))return false}else if(t[i]!==e[i]){return false}}return true}static equalsRationalArray(t,e){if(t===e)return true;if(t.length!==e.length)return false;for(let i=0,s=t.length;i<s;i++){if(!t[i].equals(e[i])){return false}}return true}static getNumEnumValues(t){return Object.values(t).filter((t=>typeof t==="number"))}static isNumArrayOrTypedArray(t){return Boolean(t&&typeof t==="object"&&(Array.isArray(t)&&t.every((t=>typeof t==="number"))||ArrayBuffer.isView(t)&&!(t instanceof DataView)))}static isArrayOfRational(t){return Boolean(t&&typeof t==="object"&&Array.isArray(t)&&t.every((t=>t instanceof w)))}}class b{static countTrailingZeroBits(t){let e=32;const i=t&-t;if(i!==0)e--;if((i&65535)!==0)e-=16;if((i&16711935)!==0)e-=8;if((i&252645135)!==0)e-=4;if((i&858993459)!==0)e-=2;if((i&1431655765)!==0)e-=1;return e}static reverseByte(t){return this._reverseByteTable[t]}static sshR(t,e){return t>>e}static ushR(t,e){return t>>>e}static sshL(t,e){return t<<e}static ushL(t,e){return t<<e>>>0}static uint8ToInt8(t){this._uint8[0]=t;return this._uint8ToInt8[0]}static int8ToUint8(t){this._int8[0]=t;return this._int8ToUint8[0]}static uint16ToInt16(t){this._uint16[0]=t;return this._uint16ToInt16[0]}static int16ToUint16(t){this._int16[0]=t;return this._int16ToUint16[0]}static uint32ToInt32(t){this._uint32[0]=t;return this._uint32ToInt32[0]}static uint32ToFloat32(t){this._uint32[0]=t;return this._uint32ToFloat32[0]}static uint64ToFloat64(t){this._uint64[0]=t;return this._uint64ToFloat64[0]}static int32ToUint32(t){this._int32[0]=t;return this._int32ToUint32[0]}static float32ToUint32(t){this._float32[0]=t;return this._float32ToUint32[0]}static debugBits32(t){if(t===undefined){return"undefined"}const e=32;let i="";for(let s=e;s>-1;s--){i+=(t&1<<s)===0?"0":"1"}return i}}b._uint8=new Uint8Array(1);b._uint8ToInt8=new Int8Array(b._uint8.buffer);b._int8=new Int8Array(1);b._int8ToUint8=new Uint8Array(b._int8.buffer);b._uint16=new Uint16Array(1);b._uint16ToInt16=new Int16Array(b._uint16.buffer);b._int16=new Int16Array(1);b._int16ToUint16=new Uint16Array(b._int16.buffer);b._uint32=new Uint32Array(1);b._uint32ToInt32=new Int32Array(b._uint32.buffer);b._uint32ToFloat32=new Float32Array(b._uint32.buffer);b._int32=new Int32Array(1);b._int32ToUint32=new Uint32Array(b._int32.buffer);b._float32=new Float32Array(1);b._float32ToUint32=new Uint32Array(b._float32.buffer);b._uint64=new BigUint64Array(1);b._uint64ToFloat64=new Float64Array(b._uint64.buffer);b._reverseByteTable=[0,128,64,192,32,160,96,224,16,144,80,208,48,176,112,240,8,136,72,200,40,168,104,232,24,152,88,216,56,184,120,248,4,132,68,196,36,164,100,228,20,148,84,212,52,180,116,244,12,140,76,204,44,172,108,236,28,156,92,220,60,188,124,252,2,130,66,194,34,162,98,226,18,146,82,210,50,178,114,242,10,138,74,202,42,170,106,234,26,154,90,218,58,186,122,250,6,134,70,198,38,166,102,230,22,150,86,214,54,182,118,246,14,142,78,206,46,174,110,238,30,158,94,222,62,190,126,254,1,129,65,193,33,161,97,225,17,145,81,209,49,177,113,241,9,137,73,201,41,169,105,233,25,153,89,217,57,185,121,249,5,133,69,197,37,165,101,229,21,149,85,213,53,181,117,245,13,141,77,205,45,173,109,237,29,157,93,221,61,189,125,253,3,131,67,195,35,163,99,227,19,147,83,211,51,179,115,243,11,139,75,203,43,171,107,235,27,155,91,219,59,187,123,251,7,135,71,199,39,167,103,231,23,151,87,215,55,183,119,247,15,143,79,207,47,175,111,239,31,159,95,223,63,191,127,255];class y{static getCodePoints(t){const e=new Uint8Array(t.length);for(let i=0;i<t.length;i++){const s=t.codePointAt(i);if(s!==undefined){if(0<=s&&s<256){e[i]=s}else{throw new u(`Error encoding text "${t}": unknown character code point ${s}`)}}else{throw new u(`Error encoding text "${t}"`)}}return e}}y.utf8Decoder=new TextDecoder("utf8");y.latin1Decoder=new TextDecoder("latin1");class v{set buffer(t){this._buffer=t}get buffer(){return this._buffer}set bigEndian(t){this._bigEndian=t}get bigEndian(){return this._bigEndian}set offset(t){this._offset=t}get offset(){return this._offset}get start(){return this._start}get end(){return this._end}get position(){return this._offset-this._start}get length(){return this._end-this._offset}get isEOS(){return this._offset>=this._end}constructor(t){var e,i;this._buffer=t.buffer;this._bigEndian=(e=t.bigEndian)!==null&&e!==void 0?e:false;this._offset=(i=t.offset)!==null&&i!==void 0?i:0;this._start=this._offset;this._end=t.length!==undefined?this._start+t.length:this._buffer.length}static from(t,e,i){const s=e!==null&&e!==void 0?e:0;const r=new v({buffer:t._buffer,bigEndian:t._bigEndian,offset:t._offset+s,length:i});r._start=t._start;r._end=i!==undefined?t.offset+s+i:t._end;return r}rewind(){this._offset=this._start}get(t){return this._buffer[this._offset+t]}set(t,e){return this._buffer[this._offset+t]=e}memcpy(t,e,i,s=0){if(i instanceof v){p.copyRange(i.buffer,i.offset+s,this._buffer,this.offset+t,e)}else{p.copyRange(i,s,this._buffer,this.offset+t,e)}}memset(t,e,i){this._buffer.fill(i,this._offset+t,this._offset+t+e)}subarray(t,e,i=0){let s=e!==undefined?this._start+e:this._offset;s+=i;return new v({buffer:this._buffer,bigEndian:this._bigEndian,offset:s,length:t})}indexOf(t,e=0){const i=this.offset+this.length;for(let s=this.offset+e;s<i;++s){if(this._buffer[s]===t){return s-this._start}}return-1}peek(t,e=0){return this.subarray(t,undefined,e)}skip(t){this._offset+=t}read(){return this._buffer[this._offset++]}readRange(t){const e=this.subarray(t);this._offset+=e.length;return e}readInt8(){return b.uint8ToInt8(this.read())}readString(t){if(t===undefined){const t=[];while(!this.isEOS){const e=this.read();if(e===0){return String.fromCodePoint(...t)}t.push(e)}throw new u("EOF reached without finding string terminator.")}const e=this.readRange(t);const i=e.toUint8Array();const s=String.fromCodePoint(...i);return s}readStringLine(t=256){const e=[];while(!this.isEOS){const i=this.read();e.push(i);if(i===10||e.length>=t){return String.fromCodePoint(...e)}}return String.fromCodePoint(...e)}readStringUtf8(){const t=[];while(!this.isEOS){const e=this.read();if(e===0){const e=new Uint8Array(t);return y.utf8Decoder.decode(e)}t.push(e)}const e=new Uint8Array(t);return y.utf8Decoder.decode(e)}readUint16(){const t=this._buffer[this._offset++]&255;const e=this._buffer[this._offset++]&255;if(this._bigEndian){return t<<8|e}return e<<8|t}readInt16(){return b.uint16ToInt16(this.readUint16())}readUint24(){const t=this._buffer[this._offset++]&255;const e=this._buffer[this._offset++]&255;const i=this._buffer[this._offset++]&255;if(this._bigEndian){return i|e<<8|t<<16}return t|e<<8|i<<16}readUint32(){return b.int32ToUint32(this.readInt32())}readInt32(){const t=this._buffer[this._offset++]&255;const e=this._buffer[this._offset++]&255;const i=this._buffer[this._offset++]&255;const s=this._buffer[this._offset++]&255;return this._bigEndian?t<<24|e<<16|i<<8|s:s<<24|i<<16|e<<8|t}readFloat32(){return b.uint32ToFloat32(this.readUint32())}readFloat64(){return b.uint64ToFloat64(this.readUint64())}readUint64(){const t=this._buffer[this._offset++]&255;const e=this._buffer[this._offset++]&255;const i=this._buffer[this._offset++]&255;const s=this._buffer[this._offset++]&255;const r=this._buffer[this._offset++]&255;const n=this._buffer[this._offset++]&255;const h=this._buffer[this._offset++]&255;const a=this._buffer[this._offset++]&255;if(this._bigEndian){return BigInt(t<<56)|BigInt(e<<48)|BigInt(i<<40)|BigInt(s<<32)|BigInt(r<<24)|BigInt(n<<16)|BigInt(h<<8)|BigInt(a)}return BigInt(a<<56)|BigInt(h<<48)|BigInt(n<<40)|BigInt(r<<32)|BigInt(s<<24)|BigInt(i<<16)|BigInt(e<<8)|BigInt(t)}toUint8Array(t=0,e){const i=e!==null&&e!==void 0?e:this.length-t;if(this._buffer instanceof Uint8Array){return new Uint8Array(this._buffer.buffer,this._buffer.byteOffset+this._offset+t,i)}return Uint8Array.from(this._buffer.subarray(this._offset+t,this._offset+t+i))}toUint32Array(t=0){if(this._buffer instanceof Uint8Array){return new Uint32Array(this._buffer.buffer,this._buffer.byteOffset+this._offset+t)}const e=this.toUint8Array();return new Uint32Array(e.buffer)}}var M;(function(t){t[t["rgba"]=0]="rgba";t[t["bgra"]=1]="bgra";t[t["abgr"]=2]="abgr";t[t["argb"]=3]="argb";t[t["rgb"]=4]="rgb";t[t["bgr"]=5]="bgr";t[t["grayAlpha"]=6]="grayAlpha";t[t["red"]=7]="red"})(M||(M={}));const x=new Map([[M.rgba,4],[M.bgra,4],[M.abgr,4],[M.argb,4],[M.rgb,3],[M.bgr,3],[M.grayAlpha,2],[M.red,1]]);var A;(function(t){t[t["red"]=0]="red";t[t["green"]=1]="green";t[t["blue"]=2]="blue";t[t["alpha"]=3]="alpha";t[t["luminance"]=4]="luminance"})(A||(A={}));class C{static get _toFloatFloat32(){return this._toFloatFloat32Data!==undefined?this._toFloatFloat32Data:this.initialize()}constructor(t){this.bits=t!==undefined?C.doubleToFloat16(t):0}static convert(t){const e=t>>>16&32768;let i=(t>>>23&255)-(127-15);let s=t&8388607;if(i<=0){if(i<-10){return e}s|=8388608;const t=14-i;const r=(1<<t-1)-1;const n=s>>>t&1;s=s+r+n>>>t;return e|s}else if(i===255-(127-15)){if(s===0){return e|31744}else{s>>>=13;return e|31744|s|(s===0?1:0)}}else{s=s+4095+(s>>>13&1);if((s&8388608)!==0){s=0;i+=1}if(i>30){return e|31744}return e|i<<10|s>>>13}}static initialize(){if(this._toFloatFloat32Data!==undefined){return this._toFloatFloat32Data}const t=new Uint32Array(1<<16);this._toFloatFloat32Data=new Float32Array(t.buffer);this._eLut=new Uint16Array(1<<9);for(let t=0;t<256;t++){const e=(t&255)-(127-15);if(e<=0||e>=30){this._eLut[t]=0;this._eLut[t|256]=0}else{this._eLut[t]=e<<10;this._eLut[t|256]=e<<10|32768}}const e=1<<16;for(let i=0;i<e;i++){t[i]=this.halfToFloat(i)}return this._toFloatFloat32Data}static halfToFloat(t){const e=t>>>15&1;let i=t>>>10&31;let s=t&1023;if(i===0){if(s===0){return e<<31}else{while((s&1024)===0){s<<=1;i-=1}i+=1;s&=~1024}}else if(i===31){if(s===0){return e<<31|2139095040}else{return e<<31|2139095040|s<<13}}i+=127-15;s<<=13;return e<<31|i<<23|s}static from(t){const e=new C;e.bits=t.bits;return e}static fromBits(t){const e=new C;e.bits=t;return e}static float16ToDouble(t){return this._toFloatFloat32[t]}static doubleToFloat16(t){const e=t;const i=b.float32ToUint32(e);if(e===0){return i>>>16}if(this._toFloatFloat32Data===undefined){this.initialize()}let s=i>>>23&511;s=this._eLut[s];if(s!==0){const t=i&8388607;return s+(t+4095+(t>>>13&1)>>>13)}return this.convert(i)}static posInf(){return C.fromBits(31744)}static negInf(){return C.fromBits(64512)}static qNan(){return C.fromBits(32767)}static sNan(){return C.fromBits(32255)}toDouble(){return C._toFloatFloat32[this.bits]}minus(){return C.fromBits(this.bits^32768)}add(t){const e=t instanceof C?t.toDouble():typeof t==="number"?t:0;return new C(this.toDouble()+e)}sub(t){const e=t instanceof C?t.toDouble():typeof t==="number"?t:0;return new C(this.toDouble()-e)}mul(t){const e=t instanceof C?t.toDouble():typeof t==="number"?t:0;return new C(this.toDouble()*e)}div(t){const e=t instanceof C?t.toDouble():typeof t==="number"?t:0;return new C(this.toDouble()/e)}round(t){if(t>=10){return C.from(this)}const e=this.bits&32768;let i=this.bits&32767;i>>>=9-t;i+=i&1;i<<=9-t;if(i>=31744){i=this.bits;i>>>=10-t;i<<=10-t}return C.fromBits(e|i)}isFinite(){const t=this.bits>>>10&31;return t<31}isNormalized(){const t=this.bits>>>10&31;return t>0&&t<31}isDenormalized(){const t=this.bits>>>10&31;const e=this.bits&1023;return t===0&&e!==0}isZero(){return(this.bits&32767)===0}isNaN(){const t=this.bits>>>10&31;const e=this.bits&1023;return t===31&&e!==0}isInfinity(){const t=this.bits>>>10&31;const e=this.bits&1023;return t===31&&e===0}isNegative(){return(this.bits&32768)!==0}}class S{get format(){return l.float16}get length(){return this.data.length}get maxChannelValue(){return 1}get maxIndexValue(){return 1}get isLdrFormat(){return false}get isHdrFormat(){return true}get hasPalette(){return false}get palette(){return undefined}get index(){return this.r}set index(t){this.r=t}get r(){return this.getChannel(0)}set r(t){this.setChannel(0,t)}get g(){return this.getChannel(1)}set g(t){this.setChannel(1,t)}get b(){return this.getChannel(2)}set b(t){this.setChannel(2,t)}get a(){return this.getChannel(3)}set a(t){this.setChannel(3,t)}get rNormalized(){return this.r/this.maxChannelValue}set rNormalized(t){this.r=t*this.maxChannelValue}get gNormalized(){return this.g/this.maxChannelValue}set gNormalized(t){this.g=t*this.maxChannelValue}get bNormalized(){return this.b/this.maxChannelValue}set bNormalized(t){this.b=t*this.maxChannelValue}get aNormalized(){return this.a/this.maxChannelValue}set aNormalized(t){this.a=t*this.maxChannelValue}get luminance(){return L.getLuminance(this)}get luminanceNormalized(){return L.getLuminanceNormalized(this)}constructor(t){if(typeof t==="number"){this.data=new Uint16Array(t)}else{this.data=t.slice()}}static from(t){const e=new S(t.length);e.data=t.data;return e}static fromArray(t){const e=new S(t);const i=t.length;for(let s=0;s<i;++s){e.data[s]=C.doubleToFloat16(t[s])}return e}static rgb(t,e,i){const s=new Uint16Array([C.doubleToFloat16(t),C.doubleToFloat16(e),C.doubleToFloat16(i)]);return new S(s)}static rgba(t,e,i,s){const r=new Uint16Array([C.doubleToFloat16(t),C.doubleToFloat16(e),C.doubleToFloat16(i),C.doubleToFloat16(s)]);return new S(r)}getChannel(t){if(t===A.luminance){return this.luminance}else{return t<this.data.length?C.float16ToDouble(this.data[t]):0}}getChannelNormalized(t){return this.getChannel(t)/this.maxChannelValue}setChannel(t,e){if(t<this.data.length){this.data[t]=C.doubleToFloat16(e)}}set(t){this.setRgba(t.r,t.g,t.b,t.a)}setRgb(t,e,i){this.data[0]=C.doubleToFloat16(t);const s=this.data.length;if(s>1){this.data[1]=C.doubleToFloat16(e);if(s>2){this.data[2]=C.doubleToFloat16(i)}}}setRgba(t,e,i,s){this.data[0]=C.doubleToFloat16(t);const r=this.data.length;if(r>1){this.data[1]=C.doubleToFloat16(e);if(r>2){this.data[2]=C.doubleToFloat16(i);if(r>3){this.data[3]=C.doubleToFloat16(s)}}}}toArray(){return p.generate(this.length,(t=>this.getChannel(t)))}clone(){return S.from(this)}equals(t){if(t.length!==this.length){return false}for(let e=0;e<this.length;e++){if(t.getChannel(e)!==this.getChannel(e)){return false}}return true}convert(t){return L.convertColor({from:this,format:t===null||t===void 0?void 0:t.format,numChannels:t===null||t===void 0?void 0:t.numChannels,alpha:t===null||t===void 0?void 0:t.alpha})}}class P{get format(){return l.float32}get length(){return this.data.length}get maxChannelValue(){return 1}get maxIndexValue(){return 1}get isLdrFormat(){return false}get isHdrFormat(){return true}get hasPalette(){return false}get palette(){return undefined}get index(){return this.r}set index(t){this.r=t}get r(){return this.getChannel(0)}set r(t){this.setChannel(0,t)}get g(){return this.getChannel(1)}set g(t){this.setChannel(1,t)}get b(){return this.getChannel(2)}set b(t){this.setChannel(2,t)}get a(){return this.getChannel(3)}set a(t){this.setChannel(3,t)}get rNormalized(){return this.r/this.maxChannelValue}set rNormalized(t){this.r=t*this.maxChannelValue}get gNormalized(){return this.g/this.maxChannelValue}set gNormalized(t){this.g=t*this.maxChannelValue}get bNormalized(){return this.b/this.maxChannelValue}set bNormalized(t){this.b=t*this.maxChannelValue}get aNormalized(){return this.a/this.maxChannelValue}set aNormalized(t){this.a=t*this.maxChannelValue}get luminance(){return L.getLuminance(this)}get luminanceNormalized(){return L.getLuminanceNormalized(this)}constructor(t){if(typeof t==="number"){this.data=new Float32Array(t)}else{this.data=t.slice()}}static from(t){const e=new P(t.length);e.data=t.data;return e}static fromArray(t){return new P(t)}static rgb(t,e,i){const s=new Float32Array([t,e,i]);return new P(s)}static rgba(t,e,i,s){const r=new Float32Array([t,e,i,s]);return new P(r)}getChannel(t){if(t===A.luminance){return this.luminance}else{return t<this.data.length?this.data[t]:0}}getChannelNormalized(t){return this.getChannel(t)/this.maxChannelValue}setChannel(t,e){if(t<this.data.length){this.data[t]=e}}set(t){this.setRgba(t.r,t.g,t.b,t.a)}setRgb(t,e,i){this.data[0]=t;const s=this.data.length;if(s>1){this.data[1]=e;if(s>2){this.data[2]=i}}}setRgba(t,e,i,s){this.data[0]=t;const r=this.data.length;if(r>1){this.data[1]=e;if(r>2){this.data[2]=i;if(r>3){this.data[3]=s}}}}toArray(){return p.generate(this.length,(t=>this.getChannel(t)))}clone(){return P.from(this)}equals(t){if(t.length!==this.length){return false}for(let e=0;e<this.length;e++){if(t.getChannel(e)!==this.getChannel(e)){return false}}return true}convert(t){return L.convertColor({from:this,format:t===null||t===void 0?void 0:t.format,numChannels:t===null||t===void 0?void 0:t.numChannels,alpha:t===null||t===void 0?void 0:t.alpha})}}class z{get format(){return l.float64}get length(){return this.data.length}get maxChannelValue(){return 1}get maxIndexValue(){return 1}get isLdrFormat(){return true}get isHdrFormat(){return false}get hasPalette(){return false}get palette(){return undefined}get index(){return this.r}set index(t){this.r=t}get r(){return this.getChannel(0)}set r(t){this.setChannel(0,t)}get g(){return this.getChannel(1)}set g(t){this.setChannel(1,t)}get b(){return this.getChannel(2)}set b(t){this.setChannel(2,t)}get a(){return this.getChannel(3)}set a(t){this.setChannel(3,t)}get rNormalized(){return this.r/this.maxChannelValue}set rNormalized(t){this.r=t*this.maxChannelValue}get gNormalized(){return this.g/this.maxChannelValue}set gNormalized(t){this.g=t*this.maxChannelValue}get bNormalized(){return this.b/this.maxChannelValue}set bNormalized(t){this.b=t*this.maxChannelValue}get aNormalized(){return this.a/this.maxChannelValue}set aNormalized(t){this.a=t*this.maxChannelValue}get luminance(){return L.getLuminance(this)}get luminanceNormalized(){return L.getLuminanceNormalized(this)}constructor(t){if(typeof t==="number"){this.data=new Float64Array(t)}else{this.data=t.slice()}}static from(t){const e=new z(t.length);e.data=t.data;return e}static fromArray(t){return new z(t)}static rgb(t,e,i){const s=new Float64Array([t,e,i]);return new z(s)}static rgba(t,e,i,s){const r=new Float64Array([t,e,i,s]);return new z(r)}getChannel(t){if(t===A.luminance){return this.luminance}else{return t<this.data.length?this.data[t]:0}}getChannelNormalized(t){return this.getChannel(t)/this.maxChannelValue}setChannel(t,e){if(t<this.data.length){this.data[t]=e}}set(t){this.setRgba(t.r,t.g,t.b,t.a)}setRgb(t,e,i){this.data[0]=t;const s=this.data.length;if(s>1){this.data[1]=e;if(s>2){this.data[2]=i}}}setRgba(t,e,i,s){this.data[0]=t;const r=this.data.length;if(r>1){this.data[1]=e;if(r>2){this.data[2]=i;if(r>3){this.data[3]=s}}}}toArray(){return p.generate(this.length,(t=>this.getChannel(t)))}clone(){return z.from(this)}equals(t){if(t.length!==this.length){return false}for(let e=0;e<this.length;e++){if(t.getChannel(e)!==this.getChannel(e)){return false}}return true}convert(t){return L.convertColor({from:this,format:t===null||t===void 0?void 0:t.format,numChannels:t===null||t===void 0?void 0:t.numChannels,alpha:t===null||t===void 0?void 0:t.alpha})}}class N{get format(){return l.int16}get length(){return this._data.length}get maxChannelValue(){return 32767}get maxIndexValue(){return 32767}get isLdrFormat(){return false}get isHdrFormat(){return true}get hasPalette(){return false}get palette(){return undefined}get index(){return this.r}set index(t){this.r=t}get r(){return this._data.length>0?this._data[0]:0}set r(t){if(this._data.length>0){this._data[0]=Math.trunc(t)}}get g(){return this._data.length>1?this._data[1]:0}set g(t){if(this._data.length>1){this._data[1]=Math.trunc(t)}}get b(){return this._data.length>2?this._data[2]:0}set b(t){if(this._data.length>2){this._data[2]=Math.trunc(t)}}get a(){return this._data.length>3?this._data[3]:0}set a(t){if(this._data.length>3){this._data[3]=Math.trunc(t)}}get rNormalized(){return this.r/this.maxChannelValue}set rNormalized(t){this.r=t*this.maxChannelValue}get gNormalized(){return this.g/this.maxChannelValue}set gNormalized(t){this.g=t*this.maxChannelValue}get bNormalized(){return this.b/this.maxChannelValue}set bNormalized(t){this.b=t*this.maxChannelValue}get aNormalized(){return this.a/this.maxChannelValue}set aNormalized(t){this.a=t*this.maxChannelValue}get luminance(){return L.getLuminance(this)}get luminanceNormalized(){return L.getLuminanceNormalized(this)}constructor(t){if(typeof t==="number"){this._data=new Int16Array(t)}else{this._data=t.slice()}}static from(t){const e=new N(t.length);e._data=t._data;return e}static fromArray(t){const e=new Int16Array(t);return new N(e)}static rgb(t,e,i){const s=new Int16Array([t,e,i]);return new N(s)}static rgba(t,e,i,s){const r=new Int16Array([t,e,i,s]);return new N(r)}getChannel(t){if(t===A.luminance){return this.luminance}else{return t<this._data.length?this._data[t]:0}}getChannelNormalized(t){return this.getChannel(t)/this.maxChannelValue}setChannel(t,e){if(t<this._data.length){this._data[t]=Math.trunc(e)}}set(t){this.setRgba(t.r,t.g,t.b,t.a)}setRgb(t,e,i){this._data[0]=Math.trunc(t);const s=this._data.length;if(s>1){this._data[1]=Math.trunc(e);if(s>2){this._data[2]=Math.trunc(i)}}}setRgba(t,e,i,s){this._data[0]=Math.trunc(t);const r=this._data.length;if(r>1){this._data[1]=Math.trunc(e);if(r>2){this._data[2]=Math.trunc(i);if(r>3){this._data[3]=Math.trunc(s)}}}}toArray(){return p.generate(this.length,(t=>this.getChannel(t)))}clone(){return N.from(this)}equals(t){if(t.length!==this.length){return false}for(let e=0;e<this.length;e++){if(t.getChannel(e)!==this.getChannel(e)){return false}}return true}convert(t){return L.convertColor({from:this,format:t===null||t===void 0?void 0:t.format,numChannels:t===null||t===void 0?void 0:t.numChannels,alpha:t===null||t===void 0?void 0:t.alpha})}}class I{get format(){return l.int32}get length(){return this._data.length}get maxChannelValue(){return 2147483647}get maxIndexValue(){return 2147483647}get isLdrFormat(){return false}get isHdrFormat(){return true}get hasPalette(){return false}get palette(){return undefined}get index(){return this.r}set index(t){this.r=t}get r(){return this._data.length>0?this._data[0]:0}set r(t){if(this._data.length>0){this._data[0]=Math.trunc(t)}}get g(){return this._data.length>1?this._data[1]:0}set g(t){if(this._data.length>1){this._data[1]=Math.trunc(t)}}get b(){return this._data.length>2?this._data[2]:0}set b(t){if(this._data.length>2){this._data[2]=Math.trunc(t)}}get a(){return this._data.length>3?this._data[3]:0}set a(t){if(this._data.length>3){this._data[3]=Math.trunc(t)}}get rNormalized(){return this.r/this.maxChannelValue}set rNormalized(t){this.r=t*this.maxChannelValue}get gNormalized(){return this.g/this.maxChannelValue}set gNormalized(t){this.g=t*this.maxChannelValue}get bNormalized(){return this.b/this.maxChannelValue}set bNormalized(t){this.b=t*this.maxChannelValue}get aNormalized(){return this.a/this.maxChannelValue}set aNormalized(t){this.a=t*this.maxChannelValue}get luminance(){return L.getLuminance(this)}get luminanceNormalized(){return L.getLuminanceNormalized(this)}constructor(t){if(typeof t==="number"){this._data=new Int32Array(t)}else{this._data=t.slice()}}static from(t){const e=new I(t.length);e._data=t._data;return e}static fromArray(t){const e=new Int32Array(t);return new I(e)}static rgb(t,e,i){const s=new Int32Array([t,e,i]);return new I(s)}static rgba(t,e,i,s){const r=new Int32Array([t,e,i,s]);return new I(r)}getChannel(t){if(t===A.luminance){return this.luminance}else{return t<this._data.length?this._data[t]:0}}getChannelNormalized(t){return this.getChannel(t)/this.maxChannelValue}setChannel(t,e){if(t<this._data.length){this._data[t]=Math.trunc(e)}}set(t){this.setRgba(t.r,t.g,t.b,t.a)}setRgb(t,e,i){this._data[0]=Math.trunc(t);const s=this._data.length;if(s>1){this._data[1]=Math.trunc(e);if(s>2){this._data[2]=Math.trunc(i)}}}setRgba(t,e,i,s){this._data[0]=Math.trunc(t);const r=this._data.length;if(r>1){this._data[1]=Math.trunc(e);if(r>2){this._data[2]=Math.trunc(i);if(r>3){this._data[3]=Math.trunc(s)}}}}toArray(){return p.generate(this.length,(t=>this.getChannel(t)))}clone(){return I.from(this)}equals(t){if(t.length!==this.length){return false}for(let e=0;e<this.length;e++){if(t.getChannel(e)!==this.getChannel(e)){return false}}return true}convert(t){return L.convertColor({from:this,format:t===null||t===void 0?void 0:t.format,numChannels:t===null||t===void 0?void 0:t.numChannels,alpha:t===null||t===void 0?void 0:t.alpha})}}class R{get format(){return l.int8}get length(){return this._data.length}get maxChannelValue(){return 127}get maxIndexValue(){return 127}get isLdrFormat(){return false}get isHdrFormat(){return true}get hasPalette(){return false}get palette(){return undefined}get index(){return this.r}set index(t){this.r=t}get r(){return this._data.length>0?this._data[0]:0}set r(t){if(this._data.length>0){this._data[0]=Math.trunc(t)}}get g(){return this._data.length>1?this._data[1]:0}set g(t){if(this._data.length>1){this._data[1]=Math.trunc(t)}}get b(){return this._data.length>2?this._data[2]:0}set b(t){if(this._data.length>2){this._data[2]=Math.trunc(t)}}get a(){return this._data.length>3?this._data[3]:0}set a(t){if(this._data.length>3){this._data[3]=Math.trunc(t)}}get rNormalized(){return this.r/this.maxChannelValue}set rNormalized(t){this.r=t*this.maxChannelValue}get gNormalized(){return this.g/this.maxChannelValue}set gNormalized(t){this.g=t*this.maxChannelValue}get bNormalized(){return this.b/this.maxChannelValue}set bNormalized(t){this.b=t*this.maxChannelValue}get aNormalized(){return this.a/this.maxChannelValue}set aNormalized(t){this.a=t*this.maxChannelValue}get luminance(){return L.getLuminance(this)}get luminanceNormalized(){return L.getLuminanceNormalized(this)}constructor(t){if(typeof t==="number"){this._data=new Int8Array(t)}else{this._data=t.slice()}}static from(t){const e=new R(t.length);e._data=t._data;return e}static fromArray(t){const e=new Int8Array(t);return new R(e)}static rgb(t,e,i){const s=new Int8Array([t,e,i]);return new R(s)}static rgba(t,e,i,s){const r=new Int8Array([t,e,i,s]);return new R(r)}getChannel(t){if(t===A.luminance){return this.luminance}else{return t<this._data.length?this._data[t]:0}}getChannelNormalized(t){return this.getChannel(t)/this.maxChannelValue}setChannel(t,e){if(t<this._data.length){this._data[t]=Math.trunc(e)}}set(t){this.setRgba(t.r,t.g,t.b,t.a)}setRgb(t,e,i){this._data[0]=Math.trunc(t);const s=this._data.length;if(s>1){this._data[1]=Math.trunc(e);if(s>2){this._data[2]=Math.trunc(i)}}}setRgba(t,e,i,s){this._data[0]=Math.trunc(t);const r=this._data.length;if(r>1){this._data[1]=Math.trunc(e);if(r>2){this._data[2]=Math.trunc(i);if(r>3){this._data[3]=Math.trunc(s)}}}}toArray(){return p.generate(this.length,(t=>this.getChannel(t)))}clone(){return R.from(this)}equals(t){if(t.length!==this.length){return false}for(let e=0;e<this.length;e++){if(t.getChannel(e)!==this.getChannel(e)){return false}}return true}convert(t){return L.convertColor({from:this,format:t===null||t===void 0?void 0:t.format,numChannels:t===null||t===void 0?void 0:t.numChannels,alpha:t===null||t===void 0?void 0:t.alpha})}}class F{get format(){return l.uint1}get length(){return this._length}get maxChannelValue(){return 1}get maxIndexValue(){return 1}get isLdrFormat(){return true}get isHdrFormat(){return false}get hasPalette(){return false}get palette(){return undefined}get index(){return this.r}set index(t){this.r=t}get r(){return this.getChannel(0)}set r(t){this.setChannel(0,t)}get g(){return this.getChannel(1)}set g(t){this.setChannel(1,t)}get b(){return this.getChannel(2)}set b(t){this.setChannel(2,t)}get a(){return this.getChannel(3)}set a(t){this.setChannel(3,t)}get rNormalized(){return this.r/this.maxChannelValue}set rNormalized(t){this.r=t*this.maxChannelValue}get gNormalized(){return this.g/this.maxChannelValue}set gNormalized(t){this.g=t*this.maxChannelValue}get bNormalized(){return this.b/this.maxChannelValue}set bNormalized(t){this.b=t*this.maxChannelValue}get aNormalized(){return this.a/this.maxChannelValue}set aNormalized(t){this.a=t*this.maxChannelValue}get luminance(){return L.getLuminance(this)}get luminanceNormalized(){return L.getLuminanceNormalized(this)}constructor(t){if(typeof t==="number"){this._length=t;this._data=0}else{this._length=t.length;this._data=0;this.setRgba(t.length>0?t[0]:0,t.length>1?t[1]:0,t.length>2?t[2]:0,t.length>3?t[3]:0)}}static from(t){const e=new F(t._length);e._data=t._data;return e}static fromArray(t){return new F(t)}static rgb(t,e,i){return new F([t,e,i])}static rgba(t,e,i,s){return new F([t,e,i,s])}getChannel(t){return t<this.length?this._data>>>7-t&1:0}getChannelNormalized(t){return this.getChannel(t)/this.maxChannelValue}setChannel(t,e){let i=t;if(i>=this.length){return}i=7-i;let s=this._data;if(e!==0){s|=1<<i}else{s&=~(1<<i&255)}this._data=s}set(t){this.setRgba(t.r,t.g,t.b,t.a)}setRgb(t,e,i){this.r=t;this.g=e;this.b=i}setRgba(t,e,i,s){this.r=t;this.g=e;this.b=i;this.a=s}toArray(){return p.generate(this.length,(t=>this.getChannel(t)))}clone(){return F.from(this)}equals(t){if(t.length!==this.length){return false}for(let e=0;e<this.length;e++){if(t.getChannel(e)!==this.getChannel(e)){return false}}return true}convert(t){return L.convertColor({from:this,format:t===null||t===void 0?void 0:t.format,numChannels:t===null||t===void 0?void 0:t.numChannels,alpha:t===null||t===void 0?void 0:t.alpha})}}class U{get format(){return l.uint16}get length(){return this.data.length}get maxChannelValue(){return 65535}get maxIndexValue(){return 65535}get isLdrFormat(){return false}get isHdrFormat(){return true}get hasPalette(){return false}get palette(){return undefined}get index(){return this.r}set index(t){this.r=t}get r(){return this.getChannel(0)}set r(t){this.setChannel(0,t)}get g(){return this.getChannel(1)}set g(t){this.setChannel(1,t)}get b(){return this.getChannel(2)}set b(t){this.setChannel(2,t)}get a(){return this.getChannel(3)}set a(t){this.setChannel(3,t)}get rNormalized(){return this.r/this.maxChannelValue}set rNormalized(t){this.r=t*this.maxChannelValue}get gNormalized(){return this.g/this.maxChannelValue}set gNormalized(t){this.g=t*this.maxChannelValue}get bNormalized(){return this.b/this.maxChannelValue}set bNormalized(t){this.b=t*this.maxChannelValue}get aNormalized(){return this.a/this.maxChannelValue}set aNormalized(t){this.a=t*this.maxChannelValue}get luminance(){return L.getLuminance(this)}get luminanceNormalized(){return L.getLuminanceNormalized(this)}constructor(t){if(typeof t==="number"){this.data=new Uint16Array(t)}else{this.data=t.slice()}}static from(t){const e=new U(t.length);e.data=t.data;return e}static fromArray(t){return new U(t)}static rgb(t,e,i){const s=new Uint16Array([t,e,i]);return new U(s)}static rgba(t,e,i,s){const r=new Uint16Array([t,e,i,s]);return new U(r)}getChannel(t){if(t===A.luminance){return this.luminance}else{return t<this.data.length?this.data[t]:0}}getChannelNormalized(t){return this.getChannel(t)/this.maxChannelValue}setChannel(t,e){if(t<this.data.length){this.data[t]=Math.trunc(e)}}set(t){this.setRgba(t.r,t.g,t.b,t.a)}setRgb(t,e,i){this.data[0]=Math.trunc(t);const s=this.data.length;if(s>1){this.data[1]=Math.trunc(e);if(s>2){this.data[2]=Math.trunc(i)}}}setRgba(t,e,i,s){this.data[0]=Math.trunc(t);const r=this.data.length;if(r>1){this.data[1]=Math.trunc(e);if(r>2){this.data[2]=Math.trunc(i);if(r>3){this.data[3]=Math.trunc(s)}}}}toArray(){return p.generate(this.length,(t=>this.getChannel(t)))}clone(){return U.from(this)}equals(t){if(t.length!==this.length){return false}for(let e=0;e<this.length;e++){if(t.getChannel(e)!==this.getChannel(e)){return false}}return true}convert(t){return L.convertColor({from:this,format:t===null||t===void 0?void 0:t.format,numChannels:t===null||t===void 0?void 0:t.numChannels,alpha:t===null||t===void 0?void 0:t.alpha})}}class T{get format(){return l.uint2}get length(){return this._length}get maxChannelValue(){return 3}get maxIndexValue(){return 3}get isLdrFormat(){return true}get isHdrFormat(){return false}get hasPalette(){return false}get palette(){return undefined}get index(){return this.r}set index(t){this.r=t}get r(){return this.getChannel(0)}set r(t){this.setChannel(0,t)}get g(){return this.getChannel(1)}set g(t){this.setChannel(1,t)}get b(){return this.getChannel(2)}set b(t){this.setChannel(2,t)}get a(){return this.getChannel(3)}set a(t){this.setChannel(3,t)}get rNormalized(){return this.r/this.maxChannelValue}set rNormalized(t){this.r=t*this.maxChannelValue}get gNormalized(){return this.g/this.maxChannelValue}set gNormalized(t){this.g=t*this.maxChannelValue}get bNormalized(){return this.b/this.maxChannelValue}set bNormalized(t){this.b=t*this.maxChannelValue}get aNormalized(){return this.a/this.maxChannelValue}set aNormalized(t){this.a=t*this.maxChannelValue}get luminance(){return L.getLuminance(this)}get luminanceNormalized(){return L.getLuminanceNormalized(this)}constructor(t){if(typeof t==="number"){this._length=t;this._data=0}else{this._length=t.length;this._data=0;this.setRgba(t.length>0?t[0]:0,t.length>1?t[1]:0,t.length>2?t[2]:0,t.length>3?t[3]:0)}}static from(t){const e=new T(t._length);e._data=t._data;return e}static fromArray(t){return new T(t)}static rgb(t,e,i){return new T([t,e,i])}static rgba(t,e,i,s){return new T([t,e,i,s])}getChannel(t){return t<this.length?this._data>>>6-(t<<1)&3:0}getChannelNormalized(t){return this.getChannel(t)/this.maxChannelValue}setChannel(t,e){const i=t;if(i>=this.length){return}const s=[~(3<<6-(0<<1))&255,~(3<<6-(1<<1))&255,~(3<<6-(2<<1))&255,~(3<<6-(3<<1))&255];const r=s[t];const n=Math.trunc(e)&3;this._data=this._data&r|n<<6-(t<<1)}set(t){this.setRgba(t.r,t.g,t.b,t.a)}setRgb(t,e,i){this.r=t;this.g=e;this.b=i}setRgba(t,e,i,s){this.r=t;this.g=e;this.b=i;this.a=s}toArray(){return p.generate(this.length,(t=>this.getChannel(t)))}clone(){return T.from(this)}equals(t){if(t.length!==this.length){return false}for(let e=0;e<this.length;e++){if(t.getChannel(e)!==this.getChannel(e)){return false}}return true}convert(t){return L.convertColor({from:this,format:t===null||t===void 0?void 0:t.format,numChannels:t===null||t===void 0?void 0:t.numChannels,alpha:t===null||t===void 0?void 0:t.alpha})}}class k{get format(){return l.uint32}get length(){return this.data.length}get maxChannelValue(){return 4294967295}get maxIndexValue(){return 4294967295}get isLdrFormat(){return false}get isHdrFormat(){return true}get hasPalette(){return false}get palette(){return undefined}get index(){return this.r}set index(t){this.r=t}get r(){return this.getChannel(0)}set r(t){this.setChannel(0,t)}get g(){return this.getChannel(1)}set g(t){this.setChannel(1,t)}get b(){return this.getChannel(2)}set b(t){this.setChannel(2,t)}get a(){return this.getChannel(3)}set a(t){this.setChannel(3,t)}get rNormalized(){return this.r/this.maxChannelValue}set rNormalized(t){this.r=t*this.maxChannelValue}get gNormalized(){return this.g/this.maxChannelValue}set gNormalized(t){this.g=t*this.maxChannelValue}get bNormalized(){return this.b/this.maxChannelValue}set bNormalized(t){this.b=t*this.maxChannelValue}get aNormalized(){return this.a/this.maxChannelValue}set aNormalized(t){this.a=t*this.maxChannelValue}get luminance(){return L.getLuminance(this)}get luminanceNormalized(){return L.getLuminanceNormalized(this)}constructor(t){if(typeof t==="number"){this.data=new Uint32Array(t)}else{this.data=t.slice()}}static from(t){const e=new k(t.length);e.data=t.data;return e}static fromArray(t){return new k(t)}static rgb(t,e,i){const s=new Uint32Array([t,e,i]);return new k(s)}static rgba(t,e,i,s){const r=new Uint32Array([t,e,i,s]);return new k(r)}getChannel(t){if(t===A.luminance){return this.luminance}else{return t<this.data.length?this.data[t]:0}}getChannelNormalized(t){return this.getChannel(t)/this.maxChannelValue}setChannel(t,e){if(t<this.data.length){this.data[t]=Math.trunc(e)}}set(t){this.setRgba(t.r,t.g,t.b,t.a)}setRgb(t,e,i){this.data[0]=Math.trunc(t);const s=this.data.length;if(s>1){this.data[1]=Math.trunc(e);if(s>2){this.data[2]=Math.trunc(i)}}}setRgba(t,e,i,s){this.data[0]=Math.trunc(t);const r=this.data.length;if(r>1){this.data[1]=Math.trunc(e);if(r>2){this.data[2]=Math.trunc(i);if(r>3){this.data[3]=Math.trunc(s)}}}}toArray(){return p.generate(this.length,(t=>this.getChannel(t)))}clone(){return k.from(this)}equals(t){if(t.length!==this.length){return false}for(let e=0;e<this.length;e++){if(t.getChannel(e)!==this.getChannel(e)){return false}}return true}convert(t){return L.convertColor({from:this,format:t===null||t===void 0?void 0:t.format,numChannels:t===null||t===void 0?void 0:t.numChannels,alpha:t===null||t===void 0?void 0:t.alpha})}}class D{get format(){return l.uint4}get length(){return this._length}get maxChannelValue(){return 15}get maxIndexValue(){return 15}get isLdrFormat(){return true}get isHdrFormat(){return false}get hasPalette(){return false}get palette(){return undefined}get index(){return this.r}set index(t){this.r=t}get r(){return this.getChannel(0)}set r(t){this.setChannel(0,t)}get g(){return this.getChannel(1)}set g(t){this.setChannel(1,t)}get b(){return this.getChannel(2)}set b(t){this.setChannel(2,t)}get a(){return this.getChannel(3)}set a(t){this.setChannel(3,t)}get rNormalized(){return this.r/this.maxChannelValue}set rNormalized(t){this.r=t*this.maxChannelValue}get gNormalized(){return this.g/this.maxChannelValue}set gNormalized(t){this.g=t*this.maxChannelValue}get bNormalized(){return this.b/this.maxChannelValue}set bNormalized(t){this.b=t*this.maxChannelValue}get aNormalized(){return this.a/this.maxChannelValue}set aNormalized(t){this.a=t*this.maxChannelValue}get luminance(){return L.getLuminance(this)}get luminanceNormalized(){return L.getLuminanceNormalized(this)}constructor(t){if(typeof t==="number"){this._length=t;this._data=new Uint8Array(this.length<3?1:2)}else{this._length=t.length;this._data=new Uint8Array(this._length<3?1:2);this.setRgba(this._length>0?t[0]:0,this._length>1?t[1]:0,this._length>2?t[2]:0,this._length>3?t[3]:0)}}static from(t){const e=new D(t._length);e._data=t._data;return e}static fromArray(t){return new D(t)}static rgb(t,e,i){const s=new D(3);s.setRgb(t,e,i);return s}static rgba(t,e,i,s){const r=new D(4);r.setRgba(t,e,i,s);return r}getChannel(t){return t<0||t>=this.length?0:t<2?this._data[0]>>>4-(t<<2)&15:this._data[1]>>>4-((t&1)<<2)&15}getChannelNormalized(t){return this.getChannel(t)/this.maxChannelValue}setChannel(t,e){let i=t;if(i>=this.length){return}const s=o.clamp(Math.trunc(e),0,15);let r=0;if(i>1){i&=1;r=1}if(i===0){this._data[r]=this._data[r]&15|s<<4}else if(i===1){this._data[r]=this._data[r]&240|s}}set(t){this.setRgba(t.r,t.g,t.b,t.a)}setRgb(t,e,i){this.r=t;this.g=e;this.b=i}setRgba(t,e,i,s){this.r=t;this.g=e;this.b=i;this.a=s}toArray(){return p.generate(this.length,(t=>this.getChannel(t)))}clone(){return D.from(this)}equals(t){if(t.length!==this.length){return false}for(let e=0;e<this.length;e++){if(t.getChannel(e)!==this.getChannel(e)){return false}}return true}convert(t){return L.convertColor({from:this,format:t===null||t===void 0?void 0:t.format,numChannels:t===null||t===void 0?void 0:t.numChannels,alpha:t===null||t===void 0?void 0:t.alpha})}}class L{static convertColorInternal(t,e,i){var s,r;const n=e.length;const h=e.format;const a=(r=(s=t.palette)===null||s===void 0?void 0:s.format)!==null&&r!==void 0?r:t.format;const o=t.length;if(n===1){const i=Math.trunc(t.length>2?t.luminance:t.getChannel(0));e.setChannel(0,m(i,a,h))}else if(n<=o){for(let i=0;i<n;++i){e.setChannel(i,m(t.getChannel(i),a,h))}}else{if(o===2){const i=m(t.getChannel(0),a,h);if(n===3){e.setChannel(0,i);e.setChannel(1,i);e.setChannel(2,i)}else{const s=m(t.getChannel(1),a,h);e.setChannel(0,i);e.setChannel(1,i);e.setChannel(2,i);e.setChannel(3,s)}}else{for(let i=0;i<o;++i){e.setChannel(i,m(t.getChannel(i),a,h))}const s=o===1?e.getChannel(0):0;for(let t=o;t<n;++t){e.setChannel(t,t===3?i:s)}}}return e}static uint32ToRed(t){return t&255}static uint32ToGreen(t){return t>>>8&255}static uint32ToBlue(t){return t>>>16&255}static uint32ToAlpha(t){return t>>>24&255}static rgbaToUint32(t,e,i,s){return o.clampInt255(t)|o.clampInt255(e)<<8|o.clampInt255(i)<<16|o.clampInt255(s)<<24}static convertColor(t){var e,i,s,r,n,h,a,o,c,f,d,g,m,w,p,b,y,v,M,x,A;const C=(i=(e=t.from.palette)===null||e===void 0?void 0:e.format)!==null&&i!==void 0?i:t.from.format;const L=(n=(r=(s=t.to)===null||s===void 0?void 0:s.format)!==null&&r!==void 0?r:t.format)!==null&&n!==void 0?n:t.from.format;const V=(o=(a=(h=t.to)===null||h===void 0?void 0:h.length)!==null&&a!==void 0?a:t.numChannels)!==null&&o!==void 0?o:t.from.length;const $=(c=t.alpha)!==null&&c!==void 0?c:0;if(L===C&&V===t.from.length){if(t.to===undefined){return t.from.clone()}t.to.set(t.from);return t.to}switch(L){case l.uint8:{const e=(f=t.to)!==null&&f!==void 0?f:new B(V);return this.convertColorInternal(t.from,e,$)}case l.uint1:{const e=(d=t.to)!==null&&d!==void 0?d:new F(V);return this.convertColorInternal(t.from,e,$)}case l.uint2:{const e=(g=t.to)!==null&&g!==void 0?g:new T(V);return this.convertColorInternal(t.from,e,$)}case l.uint4:{const e=(m=t.to)!==null&&m!==void 0?m:new D(V);return this.convertColorInternal(t.from,e,$)}case l.uint16:{const e=(w=t.to)!==null&&w!==void 0?w:new U(V);return this.convertColorInternal(t.from,e,$)}case l.uint32:{const e=(p=t.to)!==null&&p!==void 0?p:new k(V);return this.convertColorInternal(t.from,e,$)}case l.int8:{const e=(b=t.to)!==null&&b!==void 0?b:new R(V);return this.convertColorInternal(t.from,e,$)}case l.int16:{const e=(y=t.to)!==null&&y!==void 0?y:new N(V);return this.convertColorInternal(t.from,e,$)}case l.int32:{const e=(v=t.to)!==null&&v!==void 0?v:new I(V);return this.convertColorInternal(t.from,e,$)}case l.float16:{const e=(M=t.to)!==null&&M!==void 0?M:new S(V);return this.convertColorInternal(t.from,e,$)}case l.float32:{const e=(x=t.to)!==null&&x!==void 0?x:new P(V);return this.convertColorInternal(t.from,e,$)}case l.float64:{const e=(A=t.to)!==null&&A!==void 0?A:new z(V);return this.convertColorInternal(t.from,e,$)}}throw new u("Unknown format.")}static getLuminance(t){return.299*t.r+.587*t.g+.114*t.b}static getLuminanceNormalized(t){return.299*t.rNormalized+.587*t.gNormalized+.114*t.bNormalized}static getLuminanceRgb(t,e,i){return.299*t+.587*e+.114*i}static hslToRgb(t,e,i){if(e===0){const t=Math.trunc(i*255);return[t,t,t]}const s=(t,e,i)=>{let s=i;if(s<0){s+=1}if(s>1){s-=1}if(s<1/6){return t+(e-t)*6*s}if(s<1/2){return e}if(s<2/3){return t+(e-t)*(2/3-s)*6}return t};const r=i<.5?i*(1+e):i+e-i*e;const n