chunk-T5IRDDBF.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import {
  2. X,
  3. nt
  4. } from "./chunk-VEGAOVMY.js";
  5. import {
  6. s3 as s
  7. } from "./chunk-E5O6P5I2.js";
  8. import {
  9. r,
  10. t
  11. } from "./chunk-YXWMMD76.js";
  12. // node_modules/@arcgis/core/geometry/support/meshUtils/exporters/gltf/imageutils.js
  13. function i(e) {
  14. const n = c(e);
  15. return r(n) ? n.toDataURL() : "";
  16. }
  17. async function o(t2) {
  18. const r2 = c(t2);
  19. if (t(r2))
  20. throw new s("imageToArrayBuffer", "Unsupported image type");
  21. const a = await m(t2), i2 = await new Promise((e) => r2.toBlob(e, a));
  22. if (!i2)
  23. throw new s("imageToArrayBuffer", "Failed to encode image");
  24. return { data: await i2.arrayBuffer(), type: a };
  25. }
  26. async function m(e) {
  27. if (!(e instanceof HTMLImageElement))
  28. return "image/png";
  29. const t2 = e.src;
  30. if (X(t2)) {
  31. const e2 = nt(t2);
  32. return "image/jpeg" === (e2 == null ? void 0 : e2.mediaType) ? e2.mediaType : "image/png";
  33. }
  34. return /\.png$/i.test(t2) ? "image/png" : /\.(jpg|jpeg)$/i.test(t2) ? "image/jpeg" : "image/png";
  35. }
  36. function c(e) {
  37. if (e instanceof HTMLCanvasElement)
  38. return e;
  39. if (e instanceof HTMLVideoElement)
  40. return null;
  41. const t2 = document.createElement("canvas");
  42. t2.width = e.width, t2.height = e.height;
  43. const n = t2.getContext("2d");
  44. return e instanceof HTMLImageElement ? n.drawImage(e, 0, 0, e.width, e.height) : e instanceof ImageData && n.putImageData(e, 0, 0), t2;
  45. }
  46. function s2(e) {
  47. const t2 = [], n = new Uint8Array(e);
  48. for (let r2 = 0; r2 < n.length; r2++)
  49. t2.push(String.fromCharCode(n[r2]));
  50. return "data:application/octet-stream;base64," + btoa(t2.join(""));
  51. }
  52. function g(e) {
  53. if (e.byteLength < 8)
  54. return false;
  55. const t2 = new Uint8Array(e);
  56. return 137 === t2[0] && 80 === t2[1] && 78 === t2[2] && 71 === t2[3] && 13 === t2[4] && 10 === t2[5] && 26 === t2[6] && 10 === t2[7];
  57. }
  58. export {
  59. i,
  60. o,
  61. c,
  62. s2 as s,
  63. g
  64. };
  65. //# sourceMappingURL=chunk-T5IRDDBF.js.map