previewCIMSymbol-BW3KYEB2.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  1. import {
  2. m as m2
  3. } from "./chunk-XWA3NEEY.js";
  4. import {
  5. Y,
  6. se
  7. } from "./chunk-54X4RLMR.js";
  8. import {
  9. s,
  10. s2
  11. } from "./chunk-MWIFVNKP.js";
  12. import "./chunk-LSDW2622.js";
  13. import "./chunk-IQNZZCQJ.js";
  14. import "./chunk-TODU7HVH.js";
  15. import "./chunk-PZKZIMMP.js";
  16. import "./chunk-YLVXZ2PS.js";
  17. import "./chunk-WFSV2B2I.js";
  18. import "./chunk-Q34L5KZA.js";
  19. import {
  20. l as l2
  21. } from "./chunk-AEFA3FTZ.js";
  22. import {
  23. t
  24. } from "./chunk-Z6GWVH7Z.js";
  25. import "./chunk-MFFE4I2S.js";
  26. import "./chunk-XBH7TGC2.js";
  27. import "./chunk-K3NA3LQS.js";
  28. import {
  29. c as c3,
  30. i,
  31. m
  32. } from "./chunk-7SW2GQFP.js";
  33. import {
  34. e as e2,
  35. n,
  36. r
  37. } from "./chunk-TRK7CKWP.js";
  38. import "./chunk-EGVIPYN2.js";
  39. import "./chunk-7IKYLNB5.js";
  40. import "./chunk-6P6NA7JB.js";
  41. import "./chunk-7256PFPA.js";
  42. import {
  43. p
  44. } from "./chunk-EN7YGJWG.js";
  45. import "./chunk-VBNMTM7L.js";
  46. import "./chunk-3D3QEPRE.js";
  47. import "./chunk-JFNNSBWL.js";
  48. import "./chunk-522WBHUO.js";
  49. import "./chunk-WNCU6BFU.js";
  50. import "./chunk-C43UE3Z5.js";
  51. import {
  52. l
  53. } from "./chunk-7XXXCK2A.js";
  54. import "./chunk-7ZIDBK7B.js";
  55. import "./chunk-65BYCSII.js";
  56. import "./chunk-WZQZRKNH.js";
  57. import "./chunk-LRDX4TO7.js";
  58. import "./chunk-6A4U74YA.js";
  59. import "./chunk-GJXW4HL5.js";
  60. import "./chunk-WJW5DUN6.js";
  61. import "./chunk-PJ7ZQ4VD.js";
  62. import "./chunk-WDLTDV2L.js";
  63. import "./chunk-TERAW6FT.js";
  64. import "./chunk-N2663GRX.js";
  65. import {
  66. e,
  67. u
  68. } from "./chunk-WEMIK25H.js";
  69. import "./chunk-JXW4QTJA.js";
  70. import "./chunk-UXF37FQ4.js";
  71. import "./chunk-ZOEK6QHJ.js";
  72. import "./chunk-XNLG7T2T.js";
  73. import "./chunk-IR4PV7VK.js";
  74. import {
  75. c as c2,
  76. v,
  77. y
  78. } from "./chunk-2Z6LERTI.js";
  79. import "./chunk-OWVBLVP3.js";
  80. import "./chunk-AFZ7XSEW.js";
  81. import "./chunk-4NKD334K.js";
  82. import "./chunk-65K7LC56.js";
  83. import "./chunk-ATPLLI5W.js";
  84. import "./chunk-WJ3OEUD3.js";
  85. import "./chunk-MXB2XLKV.js";
  86. import "./chunk-XH7RUGVZ.js";
  87. import "./chunk-TBBTRX4O.js";
  88. import "./chunk-YBSUITLL.js";
  89. import "./chunk-ALDCDSPV.js";
  90. import "./chunk-DT6EAZQ5.js";
  91. import "./chunk-HNOZUNJ4.js";
  92. import {
  93. U
  94. } from "./chunk-VNFRAYHO.js";
  95. import "./chunk-R5IG2D6H.js";
  96. import "./chunk-VBRY5KJM.js";
  97. import "./chunk-PDKDCAAD.js";
  98. import "./chunk-ECW2QABR.js";
  99. import "./chunk-GCDJLKH4.js";
  100. import "./chunk-MRJEICT6.js";
  101. import "./chunk-Y3WMVFTW.js";
  102. import "./chunk-SAS7RONY.js";
  103. import "./chunk-WSRBH7BF.js";
  104. import "./chunk-IHXECKQQ.js";
  105. import {
  106. f
  107. } from "./chunk-ULGDPLM2.js";
  108. import "./chunk-EMJ4ZSM2.js";
  109. import {
  110. c
  111. } from "./chunk-IKP3YN53.js";
  112. import "./chunk-GZT4BVFP.js";
  113. import "./chunk-A5ICIBVI.js";
  114. // node_modules/@arcgis/core/symbols/cim/CIMSymbolRasterizer.js
  115. var M;
  116. !function(e3) {
  117. e3.Legend = "legend", e3.Preview = "preview";
  118. }(M || (M = {}));
  119. var C = (e3, t2, r3) => {
  120. if (e3 && e3.targetSize) {
  121. let i2;
  122. if (r3) {
  123. const t3 = Math.max(r3.frame.xmax - r3.frame.xmin, r3.frame.ymax - r3.frame.ymin);
  124. i2 = e3.targetSize / u(t3);
  125. } else
  126. i2 = e3.targetSize / t2.referenceSize;
  127. return i2;
  128. }
  129. return e3 && e3.scaleFactor ? e3.scaleFactor : 1;
  130. };
  131. var I = { fill: { legend: { frame: { xmax: 15, xmin: 0, ymax: 15, ymin: 0 }, geometry: { rings: [[[0, 15], [15, 7.5], [15, 0], [0, 0], [0, 15]]] }, canvasPaths: { rings: [[[0, 15], [0, 0], [15, 7.5], [15, 15], [0, 15]]] } }, preview: { frame: { xmax: 100, xmin: 0, ymax: 100, ymin: 0 }, geometry: { rings: [[[0, 100], [100, 100], [100, 0], [0, 0], [0, 100]]] }, canvasPaths: { rings: [[[0, 100], [0, 0], [100, 0], [100, 100], [0, 100]]] } } }, stroke: { legend: { frame: { xmax: 24, xmin: 0, ymax: 2, ymin: -2 }, geometry: { paths: [[[0, 0], [12, 0], [24, 0]]] }, canvasPaths: { paths: [[[0, 2], [12, 2], [24, 2]]] } }, preview: { frame: { xmax: 100, xmin: 0, ymax: 2, ymin: -2 }, geometry: { paths: [[[0, 0], [50, 0], [100, 0]]] }, canvasPaths: { paths: [[[0, 2], [50, 2], [100, 2]]] } } } };
  132. var z = class {
  133. constructor(e3, t2) {
  134. this._spatialReference = e3, this._avoidSDF = t2, this._resourceCache = new Map(), this._pictureMarkerCache = new Map(), this._textRasterizer = new s2(), this._cimResourceManager = new s(), this._rasterizer = new m2(this._cimResourceManager);
  135. }
  136. async rasterizeCIMSymbolAsync(e3, t2, r3, a, i2, o, n3, c4) {
  137. a = a || (t2 ? t2.centroid != null ? "esriGeometryPolygon" : v(t2.geometry) : null) || x(e3);
  138. const l3 = await this.analyzeCIMSymbol(e3, t2 ? P(t2.attributes) : null, r3, a, c4);
  139. return this.rasterizeCIMSymbol(l3, t2, a, i2, o, n3);
  140. }
  141. async analyzeCIMSymbol(e3, t2, a, i2, s4) {
  142. const o = [], n3 = t2 ? { geometryType: i2, spatialReference: this._spatialReference, fields: t2 } : null;
  143. let l3;
  144. await Y(e3.data, n3, this._cimResourceManager, o, this._avoidSDF), f(s4);
  145. for (const r3 of o)
  146. r3.cim.type !== "CIMPictureMarker" && r3.cim.type !== "CIMPictureFill" && r3.cim.type !== "CIMPictureStroke" || (l3 || (l3 = []), l3.push(this._fetchPictureMarkerResource(r3, s4))), a && r3.type === "text" && typeof r3.text == "string" && r3.text.includes("[") && (r3.text = n(a, r3.text, r3.cim.textCase));
  147. return l3 && await Promise.all(l3), o;
  148. }
  149. async _fetchPictureMarkerResource(e3, r3) {
  150. const a = e3.materialHash;
  151. if (!this._pictureMarkerCache.get(a)) {
  152. const i2 = (await U(e3.cim.url, { responseType: "image", signal: r3 && r3.signal })).data;
  153. this._pictureMarkerCache.set(a, i2);
  154. }
  155. }
  156. rasterizeCIMSymbol(e3, t2, r3, a, i2, s4) {
  157. const o = [];
  158. for (const n3 of e3) {
  159. a && typeof a.scaleFactor == "function" && (a.scaleFactor = a.scaleFactor(t2, i2, s4));
  160. const e4 = this._getRasterizedResource(n3, t2, r3, a, i2, s4);
  161. if (!e4)
  162. continue;
  163. let c4 = 0, l3 = e4.anchorX || 0, m3 = e4.anchorY || 0, h = false, f2 = 0, g = 0;
  164. if (r3 === "esriGeometryPoint") {
  165. const e5 = C(a, n3, null);
  166. if (f2 = e2(n3.offsetX, t2, i2, s4) * e5 || 0, g = e2(n3.offsetY, t2, i2, s4) * e5 || 0, n3.type === "marker")
  167. c4 = e2(n3.rotation, t2, i2, s4) || 0, h = !!n3.rotateClockwise && n3.rotateClockwise;
  168. else if (n3.type === "text") {
  169. if (c4 = e2(n3.angle, t2, i2, s4) || 0, n3.horizontalAlignment !== void 0)
  170. switch (n3.horizontalAlignment) {
  171. case "left":
  172. l3 = -0.5;
  173. break;
  174. case "right":
  175. l3 = 0.5;
  176. break;
  177. default:
  178. l3 = 0;
  179. }
  180. if (n3.verticalAlignment !== void 0)
  181. switch (n3.verticalAlignment) {
  182. case "top":
  183. m3 = 0.5;
  184. break;
  185. case "bottom":
  186. m3 = -0.5;
  187. break;
  188. case "baseline":
  189. m3 = -0.25;
  190. break;
  191. default:
  192. m3 = 0;
  193. }
  194. }
  195. }
  196. e4 != null && o.push({ angle: c4, rotateClockWise: h, anchorX: l3, anchorY: m3, offsetX: f2, offsetY: g, rasterizedResource: e4 });
  197. }
  198. return this.getSymbolImage(o);
  199. }
  200. getSymbolImage(e3) {
  201. const t2 = document.createElement("canvas"), r3 = t2.getContext("2d");
  202. let i2 = 0, s4 = 0, o = 0, n3 = 0;
  203. const c4 = [];
  204. for (let f2 = 0; f2 < e3.length; f2++) {
  205. const t3 = e3[f2], l4 = t3.rasterizedResource;
  206. if (!l4)
  207. continue;
  208. const m4 = l4.size, h2 = t3.offsetX, g = t3.offsetY, u2 = t3.anchorX, y2 = t3.anchorY, p2 = t3.rotateClockWise || false;
  209. let d = t3.angle, M2 = u(h2) - m4[0] * (0.5 + u2), C2 = u(g) - m4[1] * (0.5 + y2), I2 = M2 + m4[0], z2 = C2 + m4[1];
  210. if (d) {
  211. p2 && (d = -d);
  212. const e4 = Math.sin(d * Math.PI / 180), t4 = Math.cos(d * Math.PI / 180), r4 = M2 * t4 - C2 * e4, a = M2 * e4 + C2 * t4, i3 = M2 * t4 - z2 * e4, s5 = M2 * e4 + z2 * t4, o2 = I2 * t4 - z2 * e4, n4 = I2 * e4 + z2 * t4, c5 = I2 * t4 - C2 * e4, l5 = I2 * e4 + C2 * t4;
  213. M2 = Math.min(r4, i3, o2, c5), C2 = Math.min(a, s5, n4, l5), I2 = Math.max(r4, i3, o2, c5), z2 = Math.max(a, s5, n4, l5);
  214. }
  215. i2 = M2 < i2 ? M2 : i2, s4 = C2 < s4 ? C2 : s4, o = I2 > o ? I2 : o, n3 = z2 > n3 ? z2 : n3;
  216. const P2 = r3.createImageData(l4.size[0], l4.size[1]);
  217. P2.data.set(new Uint8ClampedArray(l4.image.buffer));
  218. const x2 = { offsetX: h2, offsetY: g, rotateClockwise: p2, angle: d, rasterizedImage: P2, anchorX: u2, anchorY: y2 };
  219. c4.push(x2);
  220. }
  221. t2.width = o - i2, t2.height = n3 - s4;
  222. const l3 = -i2, m3 = n3;
  223. for (let f2 = 0; f2 < c4.length; f2++) {
  224. const e4 = c4[f2], t3 = this._imageDataToCanvas(e4.rasterizedImage), i3 = e4.rasterizedImage.width, s5 = e4.rasterizedImage.height, o2 = l3 - i3 * (0.5 + e4.anchorX), n4 = m3 - s5 * (0.5 - e4.anchorY);
  225. if (e4.angle) {
  226. const i4 = (360 - e4.angle) * Math.PI / 180;
  227. r3.save(), r3.translate(u(e4.offsetX), -u(e4.offsetY)), r3.translate(l3, m3), r3.rotate(i4), r3.translate(-l3, -m3), r3.drawImage(t3, o2, n4), r3.restore();
  228. } else
  229. r3.drawImage(t3, o2 + u(e4.offsetX), n4 - u(e4.offsetY));
  230. }
  231. const h = new p({ x: l3 / t2.width - 0.5, y: m3 / t2.height - 0.5 });
  232. return { imageData: t2.width !== 0 && t2.height !== 0 ? r3.getImageData(0, 0, t2.width, t2.height) : r3.createImageData(1, 1), anchorPosition: h };
  233. }
  234. _imageDataToCanvas(e3) {
  235. this._imageDataCanvas || (this._imageDataCanvas = document.createElement("canvas"));
  236. const t2 = this._imageDataCanvas, r3 = t2.getContext("2d");
  237. return t2.width = e3.width, t2.height = e3.height, r3.putImageData(e3, 0, 0), t2;
  238. }
  239. _imageTo32Array(t2, r3, a, i2) {
  240. this._imageDataCanvas || (this._imageDataCanvas = document.createElement("canvas"));
  241. const s4 = this._imageDataCanvas, o = s4.getContext("2d");
  242. if (s4.width = r3, s4.height = a, o.drawImage(t2, 0, 0, r3, a), i2) {
  243. o.save();
  244. const s5 = new l(i2);
  245. o.fillStyle = s5.toHex(), o.globalCompositeOperation = "multiply", o.fillRect(0, 0, r3, a), o.globalCompositeOperation = "destination-atop", o.drawImage(t2, 0, 0, r3, a), o.restore();
  246. }
  247. return new Uint32Array(o.getImageData(0, 0, r3, a).data.buffer);
  248. }
  249. _getRasterizedResource(e3, t2, r3, a, s4, o) {
  250. let n3, c4, l3, m3, h = null, f2 = null;
  251. if (r3 === "esriGeometryPolyline" || r3 === "esriGeometryPolygon") {
  252. const m4 = a && a.style ? a.style : M.Legend, g2 = r3 === "esriGeometryPolyline" ? I.stroke[m4] : I.fill[m4];
  253. if (e3.type === "line") {
  254. if (e3.cim.type !== "CIMSolidStroke") {
  255. if (e3.cim.type === "CIMPictureStroke") {
  256. const r4 = e2(e3.width, t2, s4, o), a2 = e2(e3.color, t2, s4, o), { image: i2, width: n4, height: c5 } = this._getPictureResource(e3, r4, a2);
  257. return this._rasterizePictureResource(e3, i2, n4, c5, g2, r4);
  258. }
  259. return null;
  260. }
  261. ({ analyzedCIM: n3, hash: l3 } = w(e3, t2, s4, o)), c4 = this._embedCIMLayerInVectorMarker(n3, g2);
  262. } else if (e3.type === "marker") {
  263. if (e3.cim.type === "CIMPictureMarker") {
  264. const r4 = e2(e3.size, t2, s4, o), a2 = e2(e3.color, t2, s4, o), { image: i2, width: n4, height: c5 } = this._getPictureResource(e3, r4, a2);
  265. return this._rasterizePictureResource(e3, i2, n4, c5, g2, r4);
  266. }
  267. if (e3.cim.type !== "CIMVectorMarker")
  268. return null;
  269. e3.cim.offsetX = e2(e3.offsetX, t2, s4, o), e3.cim.offsetY = e2(e3.offsetY, t2, s4, o), e3.cim.rotation = e2(e3.rotation, t2, s4, o), e3.cim.markerPlacement = e3.markerPlacement, { analyzedCIM: n3 } = w(e3, t2, s4, o), l3 = c(JSON.stringify(n3)).toString(), c4 = this._embedCIMLayerInVectorMarker(n3, g2), h = e2(e3.size, t2, s4, o), f2 = e3.path;
  270. } else {
  271. if (e3.type === "text")
  272. return null;
  273. if (e3.type === "fill") {
  274. if (e3.cim.type === "CIMHatchFill" || e3.cim.type === "CIMVectorMarker" || e3.cim.type === "CIMPictureMarker" || e3.cim.type === "CIMPictureFill") {
  275. const r4 = e3.cim.size || e3.cim.height;
  276. let a2, i2, c5;
  277. if (e3.cim.type === "CIMPictureMarker" || e3.cim.type === "CIMPictureFill")
  278. ({ image: a2, width: i2, height: c5 } = this._getPictureResource(e3, r4, e2(e3.color, t2, s4, o)));
  279. else {
  280. ({ analyzedCIM: n3, hash: l3 } = w(e3, t2, s4, o));
  281. const m5 = this._rasterizer.rasterizeJSONResource({ cim: n3, type: e3.type, url: e3.url, mosaicHash: l3, size: r4, path: f2 }, 1, this._avoidSDF);
  282. a2 = m5.image, i2 = m5.size[0], c5 = m5.size[1];
  283. }
  284. return this._rasterizePictureResource(e3, a2, i2, c5, g2, null);
  285. }
  286. if (e3.cim.type !== "CIMSolidFill")
  287. return null;
  288. ({ analyzedCIM: n3, hash: l3 } = w(e3, t2, s4, o)), c4 = this._embedCIMLayerInVectorMarker(n3, g2);
  289. }
  290. }
  291. } else {
  292. if (e3.type === "text")
  293. return m3 = this._rasterizeTextResource(e3, t2, a, s4, o), m3;
  294. ({ analyzedCIM: n3, hash: l3 } = w(e3, t2, s4, o));
  295. const r4 = C(a, e3, null);
  296. if (e3.cim.type === "CIMPictureMarker") {
  297. const a2 = e2(e3.size, t2, s4, o) * r4, { image: i2, width: n4, height: c5 } = this._getPictureResource(e3, a2, e2(e3.color, t2, s4, o));
  298. return m3 = { image: i2, size: [n4, c5], sdf: false, simplePattern: false, anchorX: e3.anchorPoint ? e3.anchorPoint.x : 0, anchorY: e3.anchorPoint ? e3.anchorPoint.y : 0 }, m3;
  299. }
  300. m(n3, r4, { preserveOutlineWidth: false }), c4 = n3;
  301. }
  302. l3 += r3, a && (l3 += JSON.stringify(a));
  303. const g = this._resourceCache;
  304. return g.has(l3) ? g.get(l3) : (m3 = this._rasterizer.rasterizeJSONResource({ cim: c4, type: e3.type, url: e3.url, mosaicHash: l3, size: h, path: f2 }, window.devicePixelRatio || 1, this._avoidSDF), g.set(l3, m3), m3);
  305. }
  306. _rasterizeTextResource(e3, t2, r3, a, i2) {
  307. const s4 = C(r3, e3, null), o = e2(e3.text, t2, a, i2);
  308. if (!o || o.length === 0)
  309. return null;
  310. const n3 = e2(e3.fontName, t2, a, i2), c4 = e2(e3.style, t2, a, i2), l3 = e2(e3.weight, t2, a, i2), m3 = e2(e3.decoration, t2, a, i2), h = e2(e3.size, t2, a, i2) * s4, f2 = e2(e3.horizontalAlignment, t2, a, i2), g = e2(e3.verticalAlignment, t2, a, i2), p2 = r(e2(e3.color, t2, a, i2)), d = r(e2(e3.outlineColor, t2, a, i2)), M2 = { color: p2, size: h, horizontalAlignment: f2, verticalAlignment: g, font: { family: n3, style: c4, weight: l3, decoration: m3 }, halo: { size: e2(e3.outlineSize, t2, a, i2) || 0, color: d, style: c4 }, pixelRatio: 1, premultiplyColors: !this._avoidSDF };
  311. return this._textRasterizer.rasterizeText(o, M2);
  312. }
  313. _rasterizePictureResource(e3, t2, r3, i2, s4, c4) {
  314. const l3 = document.createElement("canvas"), m3 = l3.getContext("2d");
  315. l3.height = u(Math.max(s4.frame.ymax - s4.frame.ymin, c4)), l3.width = u(s4.frame.xmax - s4.frame.xmin);
  316. const h = m3.createImageData(r3, i2);
  317. h.data.set(new Uint8ClampedArray(t2.buffer));
  318. const f2 = this._imageDataToCanvas(h), g = m3.createPattern(f2, "repeat"), u2 = Math.cos((-e3.cim.rotation || 0) * Math.PI / 180), y2 = Math.sin((-e3.cim.rotation || 0) * Math.PI / 180);
  319. g.setTransform({ m11: u2, m12: y2, m21: -y2, m22: u2, m41: u(e3.cim.offsetX) || 0, m42: u(e3.cim.offsetY) || 0 });
  320. const p2 = s4.canvasPaths;
  321. let d, M2, C2;
  322. c2(p2) ? (d = p2.rings, m3.fillStyle = g, M2 = m3.fill, C2 = ["evenodd"]) : y(p2) && (d = p2.paths, m3.strokeStyle = g, m3.lineWidth = c4, M2 = m3.stroke, d[0][0][1] = l3.height / 2, d[0][1][1] = l3.height / 2), m3.beginPath();
  323. for (const o of d) {
  324. const e4 = o ? o.length : 0;
  325. if (e4 > 1) {
  326. let t3 = o[0];
  327. m3.moveTo(u(t3[0]), u(t3[1]));
  328. for (let r4 = 1; r4 < e4; ++r4)
  329. t3 = o[r4], m3.lineTo(u(t3[0]), u(t3[1]));
  330. m3.closePath();
  331. }
  332. }
  333. M2.apply(m3, C2);
  334. const I2 = m3.getImageData(0, 0, l3.width, l3.height), z2 = new Uint8Array(I2.data);
  335. return { size: [l3.width, l3.height], image: new Uint32Array(z2.buffer), sdf: false, simplePattern: false, anchorX: 0, anchorY: 0 };
  336. }
  337. _getPictureResource(e3, t2, r3) {
  338. const i2 = this._pictureMarkerCache.get(e3.materialHash);
  339. if (!i2)
  340. return null;
  341. const s4 = i2.height / i2.width, o = t2 ? s4 > 1 ? u(t2) : u(t2) / s4 : i2.width, n3 = t2 ? s4 > 1 ? u(t2) * s4 : u(t2) : i2.height;
  342. return { image: this._imageTo32Array(i2, o, n3, r3), width: o, height: n3 };
  343. }
  344. _embedCIMLayerInVectorMarker(e3, t2) {
  345. const r3 = c2(t2.geometry) ? "CIMPolygonSymbol" : "CIMLineSymbol", a = t2.frame;
  346. return { type: "CIMVectorMarker", frame: a, size: a.ymax - a.ymin, markerGraphics: [{ type: "CIMMarkerGraphic", geometry: t2.geometry, symbol: { type: r3, symbolLayers: [e3] } }] };
  347. }
  348. };
  349. function P(e3) {
  350. return (e3 ? Object.keys(e3) : []).map((t2) => ({ name: t2, alias: t2, type: typeof e3[t2] == "string" ? "esriFieldTypeString" : "esriFieldTypeDouble" }));
  351. }
  352. function x(e3) {
  353. if (!(e3 && e3.data && e3.data.symbol))
  354. return null;
  355. switch (e3.data.symbol.type) {
  356. case "CIMPointSymbol":
  357. case "CIMTextSymbol":
  358. return "esriGeometryPoint";
  359. case "CIMLineSymbol":
  360. return "esriGeometryPolyline";
  361. case "CIMPolygonSymbol":
  362. return "esriGeometryPolygon";
  363. default:
  364. return null;
  365. }
  366. }
  367. function w(e3, t2, r3, a) {
  368. let i2, s4;
  369. if (typeof e3.materialHash == "function") {
  370. i2 = (0, e3.materialHash)(t2, r3, a), s4 = se(e3.cim, e3.materialOverrides);
  371. } else
  372. i2 = e3.materialHash, s4 = e3.cim;
  373. return { analyzedCIM: s4, hash: i2 };
  374. }
  375. // node_modules/@arcgis/core/symbols/support/previewCIMSymbol.js
  376. var s3 = new z(null, true);
  377. var n2 = t.maxSize;
  378. async function r2(t2, a = {}) {
  379. const { size: r3, maxSize: c4, node: m3, opacity: f2 } = a, p2 = a.cimOptions || a, { feature: y2, fieldMap: h, geometryType: u2, style: d } = p2, g = i(t2), w2 = typeof r3 == "number" ? r3 : null, b = Math.min(w2 != null ? w2 : g, c4 != null ? c4 : e(n2));
  380. b !== g && (t2 = t2.clone(), c3(t2, b, { preserveOutlineWidth: true }));
  381. let M2 = 3;
  382. t2 && t2.data && t2.data.symbol && t2.data.symbol.type !== "CIMPointSymbol" && (M2 = 1);
  383. const S = await s3.rasterizeCIMSymbolAsync(t2, y2, h, u2, { scaleFactor: M2, style: d }), j = document.createElement("canvas");
  384. j.width = S.imageData.width, j.height = S.imageData.height;
  385. j.getContext("2d").putImageData(S.imageData, 0, 0);
  386. let x2 = j.width / M2, z2 = j.height / M2;
  387. if (r3 != null && (a?.scale == null || a?.scale)) {
  388. const e3 = x2 / z2;
  389. x2 = e3 <= 1 ? Math.ceil(b * e3) : b, z2 = e3 <= 1 ? b : Math.ceil(b / e3);
  390. }
  391. const C2 = new Image(x2, z2);
  392. C2.src = j.toDataURL(), f2 != null && (C2.style.opacity = `${f2}`);
  393. let D = C2;
  394. if (a.effectView != null) {
  395. const e3 = { shape: { type: "image", x: 0, y: 0, width: x2, height: z2, src: C2.src }, fill: null, stroke: null, offset: [0, 0] };
  396. D = l2([[e3]], [x2, z2], { effectView: a.effectView });
  397. }
  398. return m3 && m3.appendChild(D), D;
  399. }
  400. export {
  401. r2 as previewCIMSymbol
  402. };
  403. //# sourceMappingURL=previewCIMSymbol-BW3KYEB2.js.map