chunk-TDS6IBMU.js 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885
  1. import {
  2. s as s3
  3. } from "./chunk-YEJL5NEF.js";
  4. import {
  5. e,
  6. l3 as l,
  7. n5 as n,
  8. y3 as y2
  9. } from "./chunk-2Z2TG5CU.js";
  10. import {
  11. s2 as s,
  12. s3 as s2
  13. } from "./chunk-E5O6P5I2.js";
  14. import {
  15. y
  16. } from "./chunk-SPWQ3AWG.js";
  17. import {
  18. e as e2,
  19. r,
  20. t
  21. } from "./chunk-YXWMMD76.js";
  22. // node_modules/@arcgis/core/layers/support/SimpleBandStatistics.js
  23. var l2 = class {
  24. constructor(l3 = null, a2 = null, t2 = null) {
  25. this.minValue = l3, this.maxValue = a2, this.noDataValue = t2;
  26. }
  27. };
  28. // node_modules/@arcgis/core/layers/support/PixelBlock.js
  29. var p;
  30. var u = p = class extends l {
  31. constructor(t2) {
  32. super(t2), this.width = null, this.height = null, this.pixelType = "f32", this.validPixelCount = null, this.mask = null, this.maskIsAlpha = false, this.statistics = null;
  33. }
  34. static createEmptyBand(t2, e3) {
  35. return new (p.getPixelArrayConstructor(t2))(e3);
  36. }
  37. static getPixelArrayConstructor(t2) {
  38. let e3;
  39. switch (t2) {
  40. case "u1":
  41. case "u2":
  42. case "u4":
  43. case "u8":
  44. e3 = Uint8Array;
  45. break;
  46. case "u16":
  47. e3 = Uint16Array;
  48. break;
  49. case "u32":
  50. e3 = Uint32Array;
  51. break;
  52. case "s8":
  53. e3 = Int8Array;
  54. break;
  55. case "s16":
  56. e3 = Int16Array;
  57. break;
  58. case "s32":
  59. e3 = Int32Array;
  60. break;
  61. case "f32":
  62. case "c64":
  63. case "c128":
  64. case "unknown":
  65. e3 = Float32Array;
  66. break;
  67. case "f64":
  68. e3 = Float64Array;
  69. }
  70. return e3;
  71. }
  72. castPixelType(t2) {
  73. if (!t2)
  74. return "f32";
  75. let e3 = t2.toLowerCase();
  76. return ["u1", "u2", "u4"].includes(e3) ? e3 = "u8" : ["unknown", "u8", "s8", "u16", "s16", "u32", "s32", "f32", "f64"].includes(e3) || (e3 = "f32"), e3;
  77. }
  78. getPlaneCount() {
  79. var _a;
  80. return (_a = this.pixels) == null ? void 0 : _a.length;
  81. }
  82. addData(t2) {
  83. var _a;
  84. if (!t2.pixels || t2.pixels.length !== this.width * this.height)
  85. throw new s2("pixelblock:invalid-or-missing-pixels", "add data requires valid pixels array that has same length defined by pixel block width * height");
  86. this.pixels || (this.pixels = []), this.statistics || (this.statistics = []), this.pixels.push(t2.pixels), this.statistics.push((_a = t2.statistics) != null ? _a : new l2());
  87. }
  88. getAsRGBA() {
  89. const t2 = new ArrayBuffer(this.width * this.height * 4);
  90. switch (this.pixelType) {
  91. case "s8":
  92. case "s16":
  93. case "u16":
  94. case "s32":
  95. case "u32":
  96. case "f32":
  97. case "f64":
  98. this._fillFromNon8Bit(t2);
  99. break;
  100. default:
  101. this._fillFrom8Bit(t2);
  102. }
  103. return new Uint8ClampedArray(t2);
  104. }
  105. getAsRGBAFloat() {
  106. const t2 = new Float32Array(this.width * this.height * 4);
  107. return this._fillFrom32Bit(t2), t2;
  108. }
  109. updateStatistics() {
  110. if (!this.pixels)
  111. return;
  112. this.statistics = this.pixels.map((t3) => this._calculateBandStatistics(t3, this.mask));
  113. const t2 = this.mask;
  114. let e3 = 0;
  115. if (r(t2))
  116. for (let s5 = 0; s5 < t2.length; s5++)
  117. t2[s5] && e3++;
  118. else
  119. e3 = this.width * this.height;
  120. this.validPixelCount = e3;
  121. }
  122. clamp(t2) {
  123. if (!t2 || "f64" === t2 || "f32" === t2 || !this.pixels)
  124. return;
  125. let e3;
  126. switch (t2) {
  127. case "u8":
  128. e3 = [0, 255];
  129. break;
  130. case "u16":
  131. e3 = [0, 65535];
  132. break;
  133. case "u32":
  134. e3 = [0, 4294967295];
  135. break;
  136. case "s8":
  137. e3 = [-128, 127];
  138. break;
  139. case "s16":
  140. e3 = [-32768, 32767];
  141. break;
  142. case "s32":
  143. e3 = [-2147483648, 2147483647];
  144. break;
  145. default:
  146. e3 = [-34e38, 34e38];
  147. }
  148. const [s5, i2] = e3, r3 = this.pixels, l3 = this.width * this.height, a2 = r3.length;
  149. let o2, h2, n2;
  150. const c2 = [];
  151. for (let u3 = 0; u3 < a2; u3++) {
  152. n2 = p.createEmptyBand(t2, l3), o2 = r3[u3];
  153. for (let t3 = 0; t3 < l3; t3++)
  154. h2 = o2[t3], n2[t3] = h2 > i2 ? i2 : h2 < s5 ? s5 : h2;
  155. c2.push(n2);
  156. }
  157. this.pixels = c2, this.pixelType = t2;
  158. }
  159. extractBands(t2) {
  160. const { pixels: e3, statistics: s5 } = this;
  161. if (t(t2) || 0 === t2.length || !e3 || 0 === e3.length)
  162. return this;
  163. const i2 = e3.length, r3 = t2.some((t3) => t3 >= e3.length), l3 = i2 === t2.length && !t2.some((t3, e4) => t3 !== e4);
  164. return r3 || l3 ? this : new p({ pixelType: this.pixelType, width: this.width, height: this.height, mask: this.mask, validPixelCount: this.validPixelCount, maskIsAlpha: this.maskIsAlpha, pixels: t2.map((t3) => e3[t3]), statistics: s5 && t2.map((t3) => s5[t3]) });
  165. }
  166. clone() {
  167. const t2 = new p({ width: this.width, height: this.height, pixelType: this.pixelType, maskIsAlpha: this.maskIsAlpha, validPixelCount: this.validPixelCount });
  168. let e3;
  169. r(this.mask) && (this.mask instanceof Uint8Array ? t2.mask = new Uint8Array(this.mask) : t2.mask = this.mask.slice(0));
  170. const s5 = p.getPixelArrayConstructor(this.pixelType);
  171. if (this.pixels && this.pixels.length > 0) {
  172. t2.pixels = [];
  173. const i2 = !!this.pixels[0].slice;
  174. for (e3 = 0; e3 < this.pixels.length; e3++)
  175. t2.pixels[e3] = i2 ? this.pixels[e3].slice(0, this.pixels[e3].length) : new s5(this.pixels[e3]);
  176. }
  177. if (this.statistics)
  178. for (t2.statistics = [], e3 = 0; e3 < this.statistics.length; e3++)
  179. t2.statistics[e3] = y(this.statistics[e3]);
  180. return t2;
  181. }
  182. _fillFrom8Bit(t2) {
  183. const { mask: e3, maskIsAlpha: s5, pixels: i2 } = this;
  184. if (!t2 || !i2 || !i2.length)
  185. return void s.getLogger(this.declaredClass).error("getAsRGBA()", "Unable to convert to RGBA. The input pixel block is empty.");
  186. let a2, o2, h2, n2;
  187. a2 = o2 = h2 = i2[0], i2.length >= 3 ? (o2 = i2[1], h2 = i2[2]) : 2 === i2.length && (o2 = i2[1]);
  188. const c2 = new Uint32Array(t2), p3 = this.width * this.height;
  189. if (a2.length === p3)
  190. if (r(e3) && e3.length === p3)
  191. if (s5)
  192. for (n2 = 0; n2 < p3; n2++)
  193. e3[n2] && (c2[n2] = e3[n2] << 24 | h2[n2] << 16 | o2[n2] << 8 | a2[n2]);
  194. else
  195. for (n2 = 0; n2 < p3; n2++)
  196. e3[n2] && (c2[n2] = 255 << 24 | h2[n2] << 16 | o2[n2] << 8 | a2[n2]);
  197. else
  198. for (n2 = 0; n2 < p3; n2++)
  199. c2[n2] = 255 << 24 | h2[n2] << 16 | o2[n2] << 8 | a2[n2];
  200. else
  201. s.getLogger(this.declaredClass).error("getAsRGBA()", "Unable to convert to RGBA. The pixelblock is invalid.");
  202. }
  203. _fillFromNon8Bit(t2) {
  204. const { pixels: e3, mask: s5, statistics: i2 } = this;
  205. if (!t2 || !e3 || !e3.length)
  206. return void s.getLogger(this.declaredClass).error("getAsRGBA()", "Unable to convert to RGBA. The input pixel block is empty.");
  207. const a2 = this.pixelType;
  208. let o2 = 1, h2 = 0, n2 = 1;
  209. if (i2 && i2.length > 0) {
  210. for (const t3 of i2)
  211. if (null != t3.minValue && (h2 = Math.min(h2, t3.minValue)), null != t3.maxValue && null != t3.minValue) {
  212. const e4 = t3.maxValue - t3.minValue;
  213. n2 = Math.max(n2, e4);
  214. }
  215. o2 = 255 / n2;
  216. } else {
  217. let t3 = 255;
  218. "s8" === a2 ? (h2 = -128, t3 = 127) : "u16" === a2 ? t3 = 65535 : "s16" === a2 ? (h2 = -32768, t3 = 32767) : "u32" === a2 ? t3 = 4294967295 : "s32" === a2 ? (h2 = -2147483648, t3 = 2147483647) : "f32" === a2 ? (h2 = -34e38, t3 = 34e38) : "f64" === a2 && (h2 = -Number.MAX_VALUE, t3 = Number.MAX_VALUE), o2 = 255 / (t3 - h2);
  219. }
  220. const c2 = new Uint32Array(t2), p3 = this.width * this.height;
  221. let u3, g3, f2, m2, d2;
  222. if (u3 = g3 = f2 = e3[0], u3.length !== p3)
  223. return s.getLogger(this.declaredClass).error("getAsRGBA()", "Unable to convert to RGBA. The pixelblock is invalid.");
  224. if (e3.length >= 2)
  225. if (g3 = e3[1], e3.length >= 3 && (f2 = e3[2]), r(s5) && s5.length === p3)
  226. for (m2 = 0; m2 < p3; m2++)
  227. s5[m2] && (c2[m2] = 255 << 24 | (f2[m2] - h2) * o2 << 16 | (g3[m2] - h2) * o2 << 8 | (u3[m2] - h2) * o2);
  228. else
  229. for (m2 = 0; m2 < p3; m2++)
  230. c2[m2] = 255 << 24 | (f2[m2] - h2) * o2 << 16 | (g3[m2] - h2) * o2 << 8 | (u3[m2] - h2) * o2;
  231. else if (r(s5) && s5.length === p3)
  232. for (m2 = 0; m2 < p3; m2++)
  233. d2 = (u3[m2] - h2) * o2, s5[m2] && (c2[m2] = 255 << 24 | d2 << 16 | d2 << 8 | d2);
  234. else
  235. for (m2 = 0; m2 < p3; m2++)
  236. d2 = (u3[m2] - h2) * o2, c2[m2] = 255 << 24 | d2 << 16 | d2 << 8 | d2;
  237. }
  238. _fillFrom32Bit(t2) {
  239. const { pixels: e3, mask: s5 } = this;
  240. if (!t2 || !e3 || !e3.length)
  241. return s.getLogger(this.declaredClass).error("getAsRGBAFloat()", "Unable to convert to RGBA. The input pixel block is empty.");
  242. let i2, a2, o2, h2;
  243. i2 = a2 = o2 = e3[0], e3.length >= 3 ? (a2 = e3[1], o2 = e3[2]) : 2 === e3.length && (a2 = e3[1]);
  244. const n2 = this.width * this.height;
  245. if (i2.length !== n2)
  246. return s.getLogger(this.declaredClass).error("getAsRGBAFloat()", "Unable to convert to RGBA. The pixelblock is invalid.");
  247. let c2 = 0;
  248. if (r(s5) && s5.length === n2)
  249. for (h2 = 0; h2 < n2; h2++)
  250. t2[c2++] = i2[h2], t2[c2++] = a2[h2], t2[c2++] = o2[h2], t2[c2++] = 1 & s5[h2];
  251. else
  252. for (h2 = 0; h2 < n2; h2++)
  253. t2[c2++] = i2[h2], t2[c2++] = a2[h2], t2[c2++] = o2[h2], t2[c2++] = 1;
  254. }
  255. _calculateBandStatistics(t2, e3) {
  256. let s5 = 1 / 0, i2 = -1 / 0;
  257. const r3 = t2.length;
  258. let a2, o2 = 0;
  259. if (r(e3))
  260. for (a2 = 0; a2 < r3; a2++)
  261. e3[a2] && (o2 = t2[a2], s5 = o2 < s5 ? o2 : s5, i2 = o2 > i2 ? o2 : i2);
  262. else
  263. for (a2 = 0; a2 < r3; a2++)
  264. o2 = t2[a2], s5 = o2 < s5 ? o2 : s5, i2 = o2 > i2 ? o2 : i2;
  265. return new l2(s5, i2);
  266. }
  267. };
  268. e([y2({ json: { write: true } })], u.prototype, "width", void 0), e([y2({ json: { write: true } })], u.prototype, "height", void 0), e([y2({ json: { write: true } })], u.prototype, "pixelType", void 0), e([s3("pixelType")], u.prototype, "castPixelType", null), e([y2({ json: { write: true } })], u.prototype, "validPixelCount", void 0), e([y2({ json: { write: true } })], u.prototype, "mask", void 0), e([y2({ json: { write: true } })], u.prototype, "maskIsAlpha", void 0), e([y2({ json: { write: true } })], u.prototype, "pixels", void 0), e([y2({ json: { write: true } })], u.prototype, "statistics", void 0), u = p = e([n("esri.layers.support.PixelBlock")], u);
  269. var g = u;
  270. // node_modules/@arcgis/core/layers/support/rasterFunctions/pixelUtils.js
  271. var i;
  272. var o;
  273. function r2(e3) {
  274. return r(e3) && "esri.layers.support.PixelBlock" === e3.declaredClass && e3.pixels && e3.pixels.length > 0;
  275. }
  276. function s4(t2, e3) {
  277. if (!(e3 == null ? void 0 : e3.length) || !r2(t2))
  278. return t2;
  279. const n2 = t2.pixels.length;
  280. return e3 && e3.some((t3) => t3 >= n2) || 1 === n2 && 1 === e3.length && 0 === e3[0] ? t2 : n2 !== e3.length || e3.some((t3, e4) => t3 !== e4) ? new g({ pixelType: t2.pixelType, width: t2.width, height: t2.height, mask: t2.mask, validPixelCount: t2.validPixelCount, maskIsAlpha: t2.maskIsAlpha, pixels: e3.map((e4) => t2.pixels[e4]), statistics: t2.statistics && e3.map((e4) => t2.statistics[e4]) }) : t2;
  281. }
  282. function h(e3) {
  283. if (!(e3 == null ? void 0 : e3.length) || e3.some((t2) => !r2(t2)))
  284. return null;
  285. if (1 === e3.length)
  286. return r(e3[0]) ? e3[0].clone() : null;
  287. const n2 = e3, { width: i2, height: o2, pixelType: s5 } = n2[0];
  288. if (n2.some((t2) => t2.width !== i2 || t2.height !== o2))
  289. return null;
  290. const h2 = n2.map(({ mask: t2 }) => t2).filter((t2) => null != t2);
  291. let a2 = null;
  292. h2.length && (a2 = new Uint8Array(i2 * o2), a2.set(h2[0]), h2.length > 1 && g2(h2.slice(1), a2));
  293. const f2 = [];
  294. n2.forEach(({ pixels: t2 }) => f2.push(...t2));
  295. const c2 = n2.map(({ statistics: t2 }) => t2).filter((t2) => t2 == null ? void 0 : t2.length), u3 = [];
  296. return c2.forEach((t2) => u3.push(...t2)), new g({ pixelType: s5, width: i2, height: o2, mask: a2, pixels: f2, statistics: u3.length ? u3 : null });
  297. }
  298. function a(t2) {
  299. if (!t2)
  300. return;
  301. const e3 = t2.colormap;
  302. if (!e3 || 0 === e3.length)
  303. return;
  304. const n2 = e3.sort((t3, e4) => t3[0] - e4[0]);
  305. let l3 = 0;
  306. n2[0][0] < 0 && (l3 = n2[0][0]);
  307. const i2 = Math.max(256, n2[n2.length - 1][0] - l3 + 1), o2 = new Uint8Array(4 * i2), r3 = [];
  308. let s5, h2 = 0, a2 = 0;
  309. const f2 = 5 === n2[0].length;
  310. if (i2 > 65536)
  311. return n2.forEach((t3) => {
  312. r3[t3[0] - l3] = f2 ? t3.slice(1) : t3.slice(1).concat([255]);
  313. }), { indexed2DColormap: r3, offset: l3, alphaSpecified: f2 };
  314. if (t2.fillUnspecified)
  315. for (s5 = n2[a2], h2 = s5[0] - l3; h2 < i2; h2++)
  316. o2[4 * h2] = s5[1], o2[4 * h2 + 1] = s5[2], o2[4 * h2 + 2] = s5[3], o2[4 * h2 + 3] = f2 ? s5[4] : 255, h2 === s5[0] - l3 && (s5 = a2 === n2.length - 1 ? s5 : n2[++a2]);
  317. else
  318. for (h2 = 0; h2 < n2.length; h2++)
  319. s5 = n2[h2], a2 = 4 * (s5[0] - l3), o2[a2] = s5[1], o2[a2 + 1] = s5[2], o2[a2 + 2] = s5[3], o2[a2 + 3] = f2 ? s5[4] : 255;
  320. return { indexedColormap: o2, offset: l3, alphaSpecified: f2 };
  321. }
  322. function f(e3, n2) {
  323. if (!r2(e3))
  324. return e3;
  325. if (!n2 || !n2.indexedColormap && !n2.indexed2DColormap)
  326. return e3;
  327. const l3 = e3.clone(), i2 = l3.pixels;
  328. let o2 = l3.mask;
  329. const s5 = l3.width * l3.height;
  330. if (1 !== i2.length)
  331. return e3;
  332. const { indexedColormap: h2, indexed2DColormap: a2, offset: f2, alphaSpecified: c2 } = n2;
  333. let u3 = 0;
  334. const p3 = i2[0], x2 = new Uint8Array(p3.length), m2 = new Uint8Array(p3.length), d2 = new Uint8Array(p3.length);
  335. let g3, y4 = 0;
  336. if (h2) {
  337. const e4 = h2.length - 1;
  338. if (r(o2))
  339. for (u3 = 0; u3 < s5; u3++)
  340. o2[u3] && (y4 = 4 * (p3[u3] - f2), y4 < f2 || y4 > e4 ? o2[u3] = 0 : (x2[u3] = h2[y4], m2[u3] = h2[y4 + 1], d2[u3] = h2[y4 + 2], o2[u3] = h2[y4 + 3]));
  341. else {
  342. for (o2 = new Uint8Array(s5), u3 = 0; u3 < s5; u3++)
  343. y4 = 4 * (p3[u3] - f2), y4 < f2 || y4 > e4 ? o2[u3] = 0 : (x2[u3] = h2[y4], m2[u3] = h2[y4 + 1], d2[u3] = h2[y4 + 2], o2[u3] = h2[y4 + 3]);
  344. l3.mask = o2;
  345. }
  346. } else if (a2)
  347. if (r(o2))
  348. for (u3 = 0; u3 < s5; u3++)
  349. o2[u3] && (g3 = a2[p3[u3]], x2[u3] = g3[0], m2[u3] = g3[1], d2[u3] = g3[2], o2[u3] = g3[3]);
  350. else {
  351. for (o2 = new Uint8Array(s5), u3 = 0; u3 < s5; u3++)
  352. g3 = a2[p3[u3]], x2[u3] = g3[0], m2[u3] = g3[1], d2[u3] = g3[2], o2[u3] = g3[3];
  353. l3.mask = o2;
  354. }
  355. return l3.pixels = [x2, m2, d2], l3.statistics = null, l3.pixelType = "u8", l3.maskIsAlpha = c2, l3;
  356. }
  357. function c(t2, e3) {
  358. if (!r2(t2))
  359. return null;
  360. const { pixels: n2, mask: i2 } = t2, o2 = n2.length;
  361. let s5 = e3.lut;
  362. const { offset: h2 } = e3;
  363. s5 && 1 === s5[0].length && (s5 = n2.map(() => s5));
  364. const a2 = [], f2 = e3.outputPixelType || "u8";
  365. for (let l3 = 0; l3 < o2; l3++) {
  366. const t3 = u2(n2[l3], i2, s5[l3], h2 || 0, f2);
  367. a2.push(t3);
  368. }
  369. const c2 = new g({ width: t2.width, height: t2.height, pixels: a2, mask: i2, pixelType: f2 });
  370. return c2.updateStatistics(), c2;
  371. }
  372. function u2(t2, e3, n2, i2, o2) {
  373. const r3 = t2.length, s5 = g.createEmptyBand(o2, r3);
  374. if (e3)
  375. for (let l3 = 0; l3 < r3; l3++)
  376. e3[l3] && (s5[l3] = n2[t2[l3] - i2]);
  377. else
  378. for (let l3 = 0; l3 < r3; l3++)
  379. s5[l3] = n2[t2[l3] - i2];
  380. return s5;
  381. }
  382. function p2(t2, e3) {
  383. if (!r2(t2))
  384. return null;
  385. const n2 = t2.clone(), { pixels: l3 } = n2, i2 = n2.width * n2.height, o2 = e3.length, s5 = Math.floor(o2 / 2), h2 = e3[Math.floor(s5)], a2 = l3[0];
  386. let f2, c2, u3, p3, x2, m2, d2 = false;
  387. const g3 = new Uint8Array(i2), y4 = new Uint8Array(i2), w2 = new Uint8Array(i2);
  388. let k2 = n2.mask;
  389. const M2 = 4 === e3[0].mappedColor.length;
  390. for (k2 || (k2 = new Uint8Array(i2), k2.fill(M2 ? 255 : 1), n2.mask = k2), x2 = 0; x2 < i2; x2++)
  391. if (k2[x2]) {
  392. for (f2 = a2[x2], d2 = false, m2 = s5, c2 = h2, u3 = 0, p3 = o2 - 1; p3 - u3 > 1; ) {
  393. if (f2 === c2.value) {
  394. d2 = true;
  395. break;
  396. }
  397. f2 > c2.value ? u3 = m2 : p3 = m2, m2 = Math.floor((u3 + p3) / 2), c2 = e3[Math.floor(m2)];
  398. }
  399. d2 || (f2 === e3[u3].value ? (c2 = e3[u3], d2 = true) : f2 === e3[p3].value ? (c2 = e3[p3], d2 = true) : f2 < e3[u3].value ? (d2 = false, c2 = null) : f2 > e3[u3].value && (f2 < e3[p3].value ? (c2 = e3[u3], d2 = true) : p3 === o2 - 1 ? (d2 = false, c2 = null) : (c2 = e3[p3], d2 = true))), d2 ? (g3[x2] = c2.mappedColor[0], y4[x2] = c2.mappedColor[1], w2[x2] = c2.mappedColor[2], k2[x2] = c2.mappedColor[3]) : g3[x2] = y4[x2] = w2[x2] = k2[x2] = 0;
  400. }
  401. return n2.pixels = [g3, y4, w2], n2.mask = k2, n2.pixelType = "u8", n2.maskIsAlpha = M2, n2;
  402. }
  403. function x(t2, e3) {
  404. if (!r2(t2))
  405. return null;
  406. const { width: n2, height: i2 } = t2, { inputRanges: o2, outputValues: s5, outputPixelType: h2, noDataRanges: a2, allowUnmatched: f2 } = e3, c2 = t2.pixels[0], u3 = g.createEmptyBand(h2, c2.length);
  407. f2 && u3.set(c2);
  408. const p3 = t2.mask, x2 = o2.length / 2;
  409. for (let l3 = 0; l3 < i2; l3++)
  410. for (let t3 = 0; t3 < n2; t3++) {
  411. const e4 = l3 * n2 + t3;
  412. if (!p3 || p3[e4]) {
  413. const t4 = c2[e4];
  414. for (let n3 = x2 - 1; n3 >= 0; n3--)
  415. if (t4 >= o2[2 * n3] && t4 <= o2[2 * n3 + 1]) {
  416. u3[e4] = s5[n3];
  417. break;
  418. }
  419. }
  420. }
  421. let m2 = p3;
  422. if (a2 == null ? void 0 : a2.length) {
  423. m2 = new Uint8Array(n2 * i2), p3 && m2.set(p3);
  424. for (let t3 = 0; t3 < i2; t3++)
  425. for (let e4 = 0; e4 < n2; e4++) {
  426. const l3 = t3 * n2 + e4;
  427. if (!p3 || p3[l3]) {
  428. const t4 = c2[l3];
  429. for (let e5 = 0; e5 < x2; e5 += 2)
  430. if (t4 >= a2[e5] && t4 <= a2[e5 + 1]) {
  431. u3[l3] = 0, m2[l3] = 0;
  432. break;
  433. }
  434. }
  435. }
  436. }
  437. return new g({ width: n2, height: i2, pixelType: h2, pixels: [u3], mask: m2 });
  438. }
  439. function m(t2, e3, n2, l3) {
  440. const i2 = null != n2 && n2.length >= 2 ? new Set(n2) : null, o2 = 1 === (n2 == null ? void 0 : n2.length) ? n2[0] : null, r3 = !!(e3 == null ? void 0 : e3.length);
  441. for (let s5 = 0; s5 < t2.length; s5++)
  442. if (l3[s5]) {
  443. const n3 = t2[s5];
  444. if (r3) {
  445. let t3 = false;
  446. for (let l4 = 0; l4 < e3.length; l4 += 2)
  447. if (n3 >= e3[l4] && n3 <= e3[l4 + 1]) {
  448. t3 = true;
  449. break;
  450. }
  451. t3 || (l3[s5] = 0);
  452. }
  453. l3[s5] && (n3 === o2 || (i2 == null ? void 0 : i2.has(n3))) && (l3[s5] = 0);
  454. }
  455. }
  456. function d(t2, e3) {
  457. const n2 = t2[0].length;
  458. for (let l3 = 0; l3 < n2; l3++)
  459. if (e3[l3]) {
  460. let n3 = false;
  461. for (let e4 = 0; e4 < t2.length; e4++)
  462. if (t2[e4][l3]) {
  463. n3 = true;
  464. break;
  465. }
  466. n3 || (e3[l3] = 0);
  467. }
  468. }
  469. function g2(t2, e3) {
  470. const n2 = t2[0].length;
  471. for (let l3 = 0; l3 < n2; l3++)
  472. if (e3[l3]) {
  473. let n3 = false;
  474. for (let e4 = 0; e4 < t2.length; e4++)
  475. if (0 === t2[e4][l3]) {
  476. n3 = true;
  477. break;
  478. }
  479. n3 && (e3[l3] = 0);
  480. }
  481. }
  482. function y3(t2, e3) {
  483. if (!r2(t2))
  484. return null;
  485. const { width: n2, height: i2, pixels: o2 } = t2, s5 = n2 * i2, h2 = new Uint8Array(s5);
  486. t2.mask ? h2.set(t2.mask) : h2.fill(255);
  487. const a2 = o2.length, { includedRanges: f2, noDataValues: c2, outputPixelType: p3, matchAll: x2, lookup: y4 } = e3;
  488. if (y4) {
  489. const t3 = [];
  490. for (let e4 = 0; e4 < a2; e4++) {
  491. const n3 = u2(o2[e4], h2, y4.lut, y4.offset || 0, "u8");
  492. t3.push(n3);
  493. }
  494. 1 === t3.length ? h2.set(t3[0]) : x2 ? d(t3, h2) : g2(t3, h2);
  495. } else if (x2) {
  496. const t3 = [];
  497. for (let e4 = 0; e4 < a2; e4++) {
  498. const n3 = new Uint8Array(s5);
  499. n3.set(h2), m(o2[e4], f2, c2, n3), t3.push(n3);
  500. }
  501. 1 === t3.length ? h2.set(t3[0]) : d(t3, h2);
  502. } else
  503. for (let l3 = 0; l3 < a2; l3++)
  504. m(o2[l3], f2, c2, h2);
  505. return new g({ width: n2, height: i2, pixelType: p3, pixels: o2, mask: h2 });
  506. }
  507. function w(t2, e3, n2) {
  508. if ("u8" !== t2 && "s8" !== t2 && "u16" !== t2 && "s16" !== t2)
  509. return null;
  510. const i2 = t2.includes("16") ? 65536 : 256, o2 = t2.includes("s") ? -i2 / 2 : 0, r3 = g.createEmptyBand(t2, i2);
  511. for (let l3 = 0; l3 < e3.length; l3++) {
  512. const t3 = n2[l3], i3 = Math.ceil(e3[2 * l3] - o2), s5 = Math.floor(e3[2 * l3 + 1] - o2);
  513. for (let e4 = i3; e4 <= s5; e4++)
  514. r3[e4] = t3;
  515. }
  516. return { lut: r3, offset: o2 };
  517. }
  518. function k(t2, e3, n2) {
  519. if ("u8" !== t2 && "s8" !== t2 && "u16" !== t2 && "s16" !== t2)
  520. return null;
  521. const l3 = t2.includes("16") ? 65536 : 256, i2 = t2.includes("s") ? -l3 / 2 : 0, o2 = new Uint8Array(l3);
  522. if (e3)
  523. for (let r3 = 0; r3 < e3.length; r3++) {
  524. const t3 = Math.ceil(e3[2 * r3] - i2), n3 = Math.floor(e3[2 * r3 + 1] - i2);
  525. for (let e4 = t3; e4 <= n3; e4++)
  526. o2[e4] = 255;
  527. }
  528. if (n2)
  529. for (let r3 = 0; r3 < n2.length; r3++)
  530. o2[n2[r3] - i2] = 0;
  531. return { lut: o2, offset: i2 };
  532. }
  533. function M(t2, e3, n2, l3, i2, o2, r3, s5) {
  534. return { xmin: i2 <= n2 * t2 ? 0 : i2 < n2 * t2 + t2 ? i2 - n2 * t2 : t2, ymin: o2 <= l3 * e3 ? 0 : o2 < l3 * e3 + e3 ? o2 - l3 * e3 : e3, xmax: i2 + r3 <= n2 * t2 ? 0 : i2 + r3 < n2 * t2 + t2 ? i2 + r3 - n2 * t2 : t2, ymax: o2 + s5 <= l3 * e3 ? 0 : o2 + s5 < l3 * e3 + e3 ? o2 + s5 - l3 * e3 : e3 };
  535. }
  536. function A(t2, n2) {
  537. if (!t2 || 0 === t2.length)
  538. return null;
  539. const l3 = t2.find((t3) => t3.pixelBlock);
  540. if (!l3 || t(l3.pixelBlock))
  541. return null;
  542. const i2 = (l3.extent.xmax - l3.extent.xmin) / l3.pixelBlock.width, o2 = (l3.extent.ymax - l3.extent.ymin) / l3.pixelBlock.height, r3 = 0.01 * Math.min(i2, o2), s5 = t2.sort((t3, e3) => Math.abs(t3.extent.ymax - e3.extent.ymax) > r3 ? e3.extent.ymax - t3.extent.ymax : Math.abs(t3.extent.xmin - e3.extent.xmin) > r3 ? t3.extent.xmin - e3.extent.xmin : 0), h2 = Math.min.apply(null, s5.map((t3) => t3.extent.xmin)), a2 = Math.min.apply(null, s5.map((t3) => t3.extent.ymin)), f2 = Math.max.apply(null, s5.map((t3) => t3.extent.xmax)), c2 = Math.max.apply(null, s5.map((t3) => t3.extent.ymax)), u3 = { x: Math.round((n2.xmin - h2) / i2), y: Math.round((c2 - n2.ymax) / o2) }, p3 = { width: Math.round((f2 - h2) / i2), height: Math.round((c2 - a2) / o2) }, x2 = { width: Math.round((n2.xmax - n2.xmin) / i2), height: Math.round((n2.ymax - n2.ymin) / o2) };
  543. if (Math.round(p3.width / l3.pixelBlock.width) * Math.round(p3.height / l3.pixelBlock.height) !== s5.length || u3.x < 0 || u3.y < 0 || p3.width < x2.width || p3.height < x2.height)
  544. return null;
  545. return { extent: n2, pixelBlock: T(s5.map((t3) => t3.pixelBlock), p3, { clipOffset: u3, clipSize: x2 }) };
  546. }
  547. function U(t2, e3, n2, l3, i2, o2) {
  548. var _a;
  549. const { width: r3, height: s5 } = n2.block, { x: h2, y: a2 } = n2.offset, { width: f2, height: c2 } = n2.mosaic, u3 = M(r3, s5, l3, i2, h2, a2, f2, c2);
  550. let p3 = 0, x2 = 0;
  551. if (o2) {
  552. const t3 = o2.hasGCSSShiftTransform ? 360 : (_a = o2.halfWorldWidth) != null ? _a : 0, e4 = r3 * o2.resolutionX, n3 = o2.startX + l3 * e4, i3 = n3 + e4;
  553. n3 < t3 && i3 > t3 ? x2 = o2.rightPadding : n3 >= t3 && (p3 = o2.leftMargin - o2.rightPadding, x2 = 0);
  554. }
  555. if (u3.xmax -= x2, "number" != typeof e3)
  556. for (let m2 = u3.ymin; m2 < u3.ymax; m2++) {
  557. const n3 = (i2 * s5 + m2 - a2) * f2 + (l3 * r3 - h2) + p3, o3 = m2 * r3;
  558. for (let l4 = u3.xmin; l4 < u3.xmax; l4++)
  559. t2[n3 + l4] = e3[o3 + l4];
  560. }
  561. else
  562. for (let m2 = u3.ymin; m2 < u3.ymax; m2++) {
  563. const n3 = (i2 * s5 + m2 - a2) * f2 + (l3 * r3 - h2) + p3;
  564. for (let l4 = u3.xmin; l4 < u3.xmax; l4++)
  565. t2[n3 + l4] = e3;
  566. }
  567. }
  568. function T(n2, i2, o2 = {}) {
  569. const { clipOffset: s5, clipSize: h2, alignmentInfo: a2, blockWidths: f2 } = o2;
  570. if (f2)
  571. return C(n2, i2, { blockWidths: f2 });
  572. const c2 = n2.find((t2) => r2(t2));
  573. if (t(c2))
  574. return null;
  575. const u3 = h2 ? h2.width : i2.width, p3 = h2 ? h2.height : i2.height, x2 = c2.width, m2 = c2.height, d2 = i2.width / x2, g3 = i2.height / m2, y4 = { offset: s5 || { x: 0, y: 0 }, mosaic: h2 || i2, block: { width: x2, height: m2 } }, w2 = c2.pixelType, k2 = g.getPixelArrayConstructor(w2), M2 = c2.pixels.length, A2 = [];
  576. let T2, b2;
  577. for (let t2 = 0; t2 < M2; t2++) {
  578. b2 = new k2(u3 * p3);
  579. for (let e3 = 0; e3 < g3; e3++)
  580. for (let l3 = 0; l3 < d2; l3++) {
  581. const i3 = n2[e3 * d2 + l3];
  582. r2(i3) && (T2 = i3.pixels[t2], U(b2, T2, y4, l3, e3, a2));
  583. }
  584. A2.push(b2);
  585. }
  586. let S2;
  587. if (n2.some((n3) => t(n3) || r(n3.mask) && n3.mask.length > 0)) {
  588. S2 = new Uint8Array(u3 * p3);
  589. for (let e3 = 0; e3 < g3; e3++)
  590. for (let l3 = 0; l3 < d2; l3++) {
  591. const i3 = n2[e3 * d2 + l3], o3 = r(i3) ? i3.mask : null;
  592. r(o3) ? U(S2, o3, y4, l3, e3, a2) : U(S2, i3 ? 1 : 0, y4, l3, e3, a2);
  593. }
  594. }
  595. const B2 = new g({ width: u3, height: p3, pixels: A2, pixelType: w2, mask: S2 });
  596. return B2.updateStatistics(), B2;
  597. }
  598. function C(i2, o2, s5) {
  599. const h2 = i2.find((e3) => r(e3));
  600. if (t(h2))
  601. return null;
  602. const a2 = i2.some((e3) => !r(e3) || !!e3.mask), { width: f2, height: c2 } = o2, u3 = a2 ? new Uint8Array(f2 * c2) : null, { blockWidths: p3 } = s5, x2 = [], m2 = h2.getPlaneCount(), d2 = g.getPixelArrayConstructor(h2.pixelType);
  603. if (a2)
  604. for (let t2 = 0, e3 = 0; t2 < i2.length; e3 += p3[t2], t2++) {
  605. const l3 = i2[t2];
  606. if (!r2(l3))
  607. continue;
  608. const o3 = e2(l3.mask);
  609. for (let n2 = 0; n2 < c2; n2++)
  610. for (let i3 = 0; i3 < p3[t2]; i3++)
  611. u3[n2 * f2 + i3 + e3] = null == o3 ? 255 : o3[n2 * l3.width + i3];
  612. }
  613. for (let t2 = 0; t2 < m2; t2++) {
  614. const e3 = new d2(f2 * c2);
  615. for (let n2 = 0, l3 = 0; n2 < i2.length; l3 += p3[n2], n2++) {
  616. const o3 = i2[n2];
  617. if (!r2(o3))
  618. continue;
  619. const s6 = o3.pixels[t2];
  620. if (null != s6)
  621. for (let t3 = 0; t3 < c2; t3++)
  622. for (let i3 = 0; i3 < p3[n2]; i3++)
  623. e3[t3 * f2 + i3 + l3] = s6[t3 * o3.width + i3];
  624. }
  625. x2.push(e3);
  626. }
  627. const g3 = new g({ width: f2, height: c2, mask: u3, pixels: x2, pixelType: h2.pixelType });
  628. return g3.updateStatistics(), g3;
  629. }
  630. function b(t2, e3, n2) {
  631. if (!r2(t2))
  632. return null;
  633. const { width: l3, height: i2 } = t2, o2 = e3.x, s5 = e3.y, h2 = n2.width + o2, a2 = n2.height + s5;
  634. if (o2 < 0 || s5 < 0 || h2 > l3 || a2 > i2)
  635. return t2;
  636. if (0 === o2 && 0 === s5 && h2 === l3 && a2 === i2)
  637. return t2;
  638. t2.mask || (t2.mask = new Uint8Array(l3 * i2));
  639. const f2 = t2.mask;
  640. for (let r3 = 0; r3 < i2; r3++) {
  641. const t3 = r3 * l3;
  642. for (let e4 = 0; e4 < l3; e4++)
  643. f2[t3 + e4] = r3 < s5 || r3 >= a2 || e4 < o2 || e4 >= h2 ? 0 : 1;
  644. }
  645. return t2.updateStatistics(), t2;
  646. }
  647. function S(t2) {
  648. if (!r2(t2))
  649. return null;
  650. const e3 = t2.clone(), { width: l3, height: i2, pixels: o2 } = t2, s5 = o2[0], h2 = e3.pixels[0], a2 = e2(t2.mask);
  651. for (let n2 = 2; n2 < i2 - 1; n2++) {
  652. const t3 = /* @__PURE__ */ new Map();
  653. for (let i3 = n2 - 2; i3 < n2 + 2; i3++)
  654. for (let e5 = 0; e5 < 4; e5++) {
  655. const n3 = i3 * l3 + e5;
  656. v(t3, s5[n3], a2 ? a2[n3] : 1);
  657. }
  658. h2[n2 * l3] = B(t3), h2[n2 * l3 + 1] = h2[n2 * l3 + 2] = h2[n2 * l3];
  659. let e4 = 3;
  660. for (; e4 < l3 - 1; e4++) {
  661. let i3 = (n2 - 2) * l3 + e4 + 1;
  662. v(t3, s5[i3], a2 ? a2[i3] : 1), i3 = (n2 - 1) * l3 + e4 + 1, v(t3, s5[i3], a2 ? a2[i3] : 1), i3 = n2 * l3 + e4 + 1, v(t3, s5[i3], a2 ? a2[i3] : 1), i3 = (n2 + 1) * l3 + e4 + 1, v(t3, s5[i3], a2 ? a2[i3] : 1), i3 = (n2 - 2) * l3 + e4 - 3, P(t3, s5[i3], a2 ? a2[i3] : 1), i3 = (n2 - 1) * l3 + e4 - 3, P(t3, s5[i3], a2 ? a2[i3] : 1), i3 = n2 * l3 + e4 - 3, P(t3, s5[i3], a2 ? a2[i3] : 1), i3 = (n2 + 1) * l3 + e4 - 3, P(t3, s5[i3], a2 ? a2[i3] : 1), h2[n2 * l3 + e4] = B(t3);
  663. }
  664. h2[n2 * l3 + e4 + 1] = h2[n2 * l3 + e4];
  665. }
  666. for (let n2 = 0; n2 < l3; n2++)
  667. h2[n2] = h2[l3 + n2] = h2[2 * l3 + n2], h2[(i2 - 1) * l3 + n2] = h2[(i2 - 2) * l3 + n2];
  668. return e3.updateStatistics(), e3;
  669. }
  670. function B(t2) {
  671. if (0 === t2.size)
  672. return 0;
  673. let e3 = 0, n2 = -1, l3 = 0;
  674. const i2 = t2.keys();
  675. let o2 = i2.next();
  676. for (; !o2.done; )
  677. l3 = t2.get(o2.value), l3 > e3 && (n2 = o2.value, e3 = l3), o2 = i2.next();
  678. return n2;
  679. }
  680. function P(t2, e3, n2) {
  681. if (0 === n2)
  682. return;
  683. const l3 = t2.get(e3);
  684. 1 === l3 ? t2.delete(e3) : t2.set(e3, l3 - 1);
  685. }
  686. function v(t2, e3, n2) {
  687. 0 !== n2 && t2.set(e3, t2.has(e3) ? t2.get(e3) + 1 : 1);
  688. }
  689. function _(t2, e3, i2) {
  690. let { x: o2, y: s5 } = e3;
  691. const { width: h2, height: a2 } = i2;
  692. if (0 === o2 && 0 === s5 && a2 === t2.height && h2 === t2.width)
  693. return t2;
  694. const { width: f2, height: c2 } = t2, u3 = Math.max(0, s5), p3 = Math.max(0, o2), x2 = Math.min(o2 + h2, f2), m2 = Math.min(s5 + a2, c2);
  695. if (x2 < 0 || m2 < 0 || !r2(t2))
  696. return null;
  697. o2 = Math.max(0, -o2), s5 = Math.max(0, -s5);
  698. const { pixels: d2 } = t2, g3 = h2 * a2, y4 = d2.length, w2 = [];
  699. for (let n2 = 0; n2 < y4; n2++) {
  700. const e4 = d2[n2], i3 = g.createEmptyBand(t2.pixelType, g3);
  701. for (let t3 = u3; t3 < m2; t3++) {
  702. const n3 = t3 * f2;
  703. let l3 = (t3 + s5 - u3) * h2 + o2;
  704. for (let t4 = p3; t4 < x2; t4++)
  705. i3[l3++] = e4[n3 + t4];
  706. }
  707. w2.push(i3);
  708. }
  709. const k2 = new Uint8Array(g3), M2 = e2(t2.mask);
  710. for (let n2 = u3; n2 < m2; n2++) {
  711. const t3 = n2 * f2;
  712. let e4 = (n2 + s5 - u3) * h2 + o2;
  713. for (let n3 = p3; n3 < x2; n3++)
  714. k2[e4++] = M2 ? M2[t3 + n3] : 1;
  715. }
  716. const A2 = new g({ width: i2.width, height: i2.height, pixelType: t2.pixelType, pixels: w2, mask: k2 });
  717. return A2.updateStatistics(), A2;
  718. }
  719. function E(e3, n2 = true) {
  720. if (!r2(e3))
  721. return null;
  722. const { pixels: i2, width: o2, height: s5, mask: h2, pixelType: a2 } = e3, f2 = [], c2 = Math.round(o2 / 2), u3 = Math.round(s5 / 2), p3 = s5 - 1, x2 = o2 - 1;
  723. for (let t2 = 0; t2 < i2.length; t2++) {
  724. const e4 = i2[t2], r3 = g.createEmptyBand(a2, c2 * u3);
  725. let h3 = 0;
  726. for (let t3 = 0; t3 < s5; t3 += 2)
  727. for (let l3 = 0; l3 < o2; l3 += 2) {
  728. const i3 = e4[t3 * o2 + l3];
  729. if (n2) {
  730. const n3 = l3 === x2 ? i3 : e4[t3 * o2 + l3 + 1], s6 = t3 === p3 ? i3 : e4[t3 * o2 + l3 + o2], a3 = l3 === x2 ? s6 : t3 === p3 ? n3 : e4[t3 * o2 + l3 + o2 + 1];
  731. r3[h3++] = (i3 + n3 + s6 + a3) / 4;
  732. } else
  733. r3[h3++] = i3;
  734. }
  735. f2.push(r3);
  736. }
  737. let m2 = null;
  738. if (r(h2)) {
  739. m2 = new Uint8Array(c2 * u3);
  740. let t2 = 0;
  741. for (let e4 = 0; e4 < s5; e4 += 2)
  742. for (let l3 = 0; l3 < o2; l3 += 2) {
  743. const i3 = h2[e4 * o2 + l3];
  744. if (n2) {
  745. const n3 = l3 === x2 ? i3 : h2[e4 * o2 + l3 + 1], r3 = e4 === p3 ? i3 : h2[e4 * o2 + l3 + o2], s6 = l3 === x2 ? r3 : e4 === p3 ? n3 : h2[e4 * o2 + l3 + o2 + 1];
  746. m2[t2++] = i3 * n3 * r3 * s6 ? 1 : 0;
  747. } else
  748. m2[t2++] = i3;
  749. }
  750. }
  751. return new g({ width: c2, height: u3, pixelType: a2, pixels: f2, mask: m2 });
  752. }
  753. function W(t2, e3, n2) {
  754. if (!r2(t2))
  755. return null;
  756. const { width: l3, height: i2 } = e3;
  757. let { width: o2, height: s5 } = t2;
  758. const h2 = /* @__PURE__ */ new Map(), a2 = { x: 0, y: 0 }, f2 = null == n2 ? 1 : 1 + n2;
  759. let c2 = t2;
  760. for (let r3 = 0; r3 < f2; r3++) {
  761. const t3 = Math.ceil(o2 / l3), n3 = Math.ceil(s5 / i2);
  762. for (let o3 = 0; o3 < n3; o3++) {
  763. a2.y = o3 * i2;
  764. for (let n4 = 0; n4 < t3; n4++) {
  765. a2.x = n4 * l3;
  766. const t4 = _(c2, a2, e3);
  767. h2.set(`${r3}/${o3}/${n4}`, t4);
  768. }
  769. }
  770. r3 < f2 - 1 && (c2 = E(c2)), o2 = Math.round(o2 / 2), s5 = Math.round(s5 / 2);
  771. }
  772. return h2;
  773. }
  774. function I(t2, e3, n2, l3, i2 = 0.5) {
  775. const { width: o2, height: r3 } = t2, { width: s5, height: h2 } = e3, a2 = l3.cols, f2 = l3.rows, c2 = Math.ceil(s5 / a2 - 0.1 / a2), u3 = Math.ceil(h2 / f2 - 0.1 / f2);
  776. let p3, x2, m2, d2, g3, y4, w2;
  777. const k2 = c2 * a2, M2 = k2 * u3 * f2, A2 = new Float32Array(M2), U2 = new Float32Array(M2), T2 = new Uint32Array(M2), C2 = new Uint32Array(M2);
  778. let b2, S2, B2 = 0;
  779. for (let P2 = 0; P2 < u3; P2++)
  780. for (let t3 = 0; t3 < c2; t3++) {
  781. p3 = 12 * (P2 * c2 + t3), x2 = n2[p3], m2 = n2[p3 + 1], d2 = n2[p3 + 2], g3 = n2[p3 + 3], y4 = n2[p3 + 4], w2 = n2[p3 + 5];
  782. for (let e4 = 0; e4 < f2; e4++) {
  783. B2 = (P2 * f2 + e4) * k2 + t3 * a2, S2 = (e4 + 0.5) / f2;
  784. for (let t4 = 0; t4 < e4; t4++)
  785. b2 = (t4 + 0.5) / a2, A2[B2 + t4] = (x2 * b2 + m2 * S2 + d2) * o2 - i2, U2[B2 + t4] = (g3 * b2 + y4 * S2 + w2) * r3 - i2, T2[B2 + t4] = Math.round(A2[B2 + t4]), C2[B2 + t4] = Math.round(U2[B2 + t4]);
  786. }
  787. p3 += 6, x2 = n2[p3], m2 = n2[p3 + 1], d2 = n2[p3 + 2], g3 = n2[p3 + 3], y4 = n2[p3 + 4], w2 = n2[p3 + 5];
  788. for (let e4 = 0; e4 < f2; e4++) {
  789. B2 = (P2 * f2 + e4) * k2 + t3 * a2, S2 = (e4 + 0.5) / f2;
  790. for (let t4 = e4; t4 < a2; t4++)
  791. b2 = (t4 + 0.5) / a2, A2[B2 + t4] = (x2 * b2 + m2 * S2 + d2) * o2 - i2, U2[B2 + t4] = (g3 * b2 + y4 * S2 + w2) * r3 - i2, T2[B2 + t4] = Math.round(A2[B2 + t4]), C2[B2 + t4] = Math.round(U2[B2 + t4]);
  792. }
  793. }
  794. return { offsets_x: A2, offsets_y: U2, offsets_xi: T2, offsets_yi: C2, gridWidth: k2 };
  795. }
  796. function j(t2, e3) {
  797. const { coefficients: n2, spacing: l3 } = e3, { offsets_x: i2, offsets_y: o2, gridWidth: r3 } = I(t2, t2, n2, { rows: l3[0], cols: l3[1] }, 0.5), { width: s5, height: h2 } = t2, a2 = new Float32Array(s5 * h2), f2 = 180 / Math.PI;
  798. for (let c2 = 0; c2 < h2; c2++)
  799. for (let t3 = 0; t3 < s5; t3++) {
  800. const e4 = c2 * r3 + t3, n3 = 0 === c2 ? e4 : e4 - r3, l4 = c2 === h2 - 1 ? e4 : e4 + r3, u3 = i2[n3] - i2[l4], p3 = o2[l4] - o2[n3];
  801. if (isNaN(u3) || isNaN(p3))
  802. a2[c2 * s5 + t3] = 90;
  803. else {
  804. let e5 = Math.atan2(p3, u3) * f2;
  805. e5 = (360 + e5) % 360, a2[c2 * s5 + t3] = e5;
  806. }
  807. }
  808. return a2;
  809. }
  810. function D(e3, n2, i2, o2, s5 = "nearest") {
  811. if (!r2(e3))
  812. return null;
  813. "majority" === s5 && (e3 = S(e3));
  814. const { pixels: h2, mask: a2, pixelType: f2 } = e3, c2 = e3.width, u3 = e3.height, p3 = g.getPixelArrayConstructor(f2), x2 = h2.length, { width: m2, height: d2 } = n2;
  815. let g3 = false;
  816. for (let t2 = 0; t2 < i2.length; t2 += 3)
  817. -1 === i2[t2] && -1 === i2[t2 + 1] && -1 === i2[t2 + 2] && (g3 = true);
  818. const { offsets_x: y4, offsets_y: w2, offsets_xi: k2, offsets_yi: M2, gridWidth: A2 } = I({ width: c2, height: u3 }, n2, i2, o2, "majority" === s5 ? 0 : 0.5);
  819. let U2;
  820. const T2 = (t2, e4, n3) => {
  821. const l3 = t2 instanceof Float32Array || t2 instanceof Float64Array ? 0 : 0.5;
  822. for (let i3 = 0; i3 < d2; i3++) {
  823. U2 = i3 * A2;
  824. for (let o3 = 0; o3 < m2; o3++) {
  825. if (y4[U2] < 0 || w2[U2] < 0)
  826. t2[i3 * m2 + o3] = 0;
  827. else if (n3)
  828. t2[i3 * m2 + o3] = e4[k2[U2] + M2[U2] * c2];
  829. else {
  830. const n4 = Math.floor(y4[U2]), r3 = Math.floor(w2[U2]), s6 = Math.ceil(y4[U2]), h3 = Math.ceil(w2[U2]), f3 = y4[U2] - n4, u4 = w2[U2] - r3;
  831. if (!a2 || a2[n4 + r3 * c2] && a2[n4 + r3 * c2] && a2[n4 + h3 * c2] && a2[s6 + h3 * c2]) {
  832. const a3 = (1 - f3) * e4[n4 + r3 * c2] + f3 * e4[s6 + r3 * c2], p4 = (1 - f3) * e4[n4 + h3 * c2] + f3 * e4[s6 + h3 * c2];
  833. t2[i3 * m2 + o3] = (1 - u4) * a3 + u4 * p4 + l3;
  834. } else
  835. t2[i3 * m2 + o3] = e4[k2[U2] + M2[U2] * c2];
  836. }
  837. U2++;
  838. }
  839. }
  840. }, C2 = [];
  841. let b2;
  842. for (let t2 = 0; t2 < x2; t2++)
  843. b2 = new p3(m2 * d2), T2(b2, h2[t2], "nearest" === s5 || "majority" === s5), C2.push(b2);
  844. const B2 = new g({ width: m2, height: d2, pixelType: f2, pixels: C2 });
  845. if (r(a2))
  846. B2.mask = new Uint8Array(m2 * d2), T2(B2.mask, a2, true);
  847. else if (g3) {
  848. B2.mask = new Uint8Array(m2 * d2);
  849. for (let t2 = 0; t2 < m2 * d2; t2++)
  850. B2.mask[t2] = y4[t2] < 0 || w2[t2] < 0 ? 0 : 1;
  851. }
  852. return B2.updateStatistics(), B2;
  853. }
  854. !function(t2) {
  855. t2[t2.matchAny = 0] = "matchAny", t2[t2.matchAll = 1] = "matchAll";
  856. }(i || (i = {})), function(t2) {
  857. t2[t2.bestMatch = 0] = "bestMatch", t2[t2.fail = 1] = "fail";
  858. }(o || (o = {}));
  859. export {
  860. g,
  861. i,
  862. o,
  863. r2 as r,
  864. s4 as s,
  865. h,
  866. a,
  867. f,
  868. c,
  869. p2 as p,
  870. x,
  871. y3 as y,
  872. w,
  873. k,
  874. A,
  875. T,
  876. b,
  877. W,
  878. j,
  879. D
  880. };
  881. //# sourceMappingURL=chunk-TDS6IBMU.js.map