featureLayerUtils-4XVGLMTG.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. import {
  2. r as r2
  3. } from "./chunk-KDQ32XYX.js";
  4. import {
  5. i as i2
  6. } from "./chunk-LX2NI53X.js";
  7. import "./chunk-IZUZZJS7.js";
  8. import {
  9. o
  10. } from "./chunk-MYF5A5DJ.js";
  11. import {
  12. a,
  13. c,
  14. f,
  15. i
  16. } from "./chunk-2HUEYG7P.js";
  17. import {
  18. Ze
  19. } from "./chunk-WM52QDLS.js";
  20. import "./chunk-MEZ7BUMM.js";
  21. import "./chunk-7B57NUGF.js";
  22. import "./chunk-AOQ55JXI.js";
  23. import "./chunk-X42TFXOU.js";
  24. import "./chunk-JFSMKLAQ.js";
  25. import "./chunk-LXOC7SMQ.js";
  26. import "./chunk-DN6W4TJU.js";
  27. import "./chunk-OUUXJOLT.js";
  28. import "./chunk-PLQUCCQV.js";
  29. import "./chunk-JZAS4TIG.js";
  30. import "./chunk-VBR5BOXI.js";
  31. import "./chunk-NBKUI76A.js";
  32. import "./chunk-6334AFGG.js";
  33. import "./chunk-NLLFSKB2.js";
  34. import "./chunk-LC3GBQ56.js";
  35. import "./chunk-5GYJGY4C.js";
  36. import "./chunk-OXF7W4BJ.js";
  37. import "./chunk-P24XEEHY.js";
  38. import "./chunk-SAJAEMIJ.js";
  39. import "./chunk-S6EFEKAU.js";
  40. import "./chunk-2RHPWGZL.js";
  41. import "./chunk-XEQ4FTFC.js";
  42. import "./chunk-JM5OVQAD.js";
  43. import "./chunk-S3GK7VUF.js";
  44. import "./chunk-TU7WVKU4.js";
  45. import "./chunk-WWXZOC2Y.js";
  46. import "./chunk-ZOKNWEG3.js";
  47. import "./chunk-NQA5XJGK.js";
  48. import "./chunk-EKYSPJO6.js";
  49. import "./chunk-JAUFBT5U.js";
  50. import "./chunk-W6U6FKJ3.js";
  51. import "./chunk-7C2KDOAI.js";
  52. import "./chunk-RHFU6KWO.js";
  53. import "./chunk-3FNKD2EB.js";
  54. import "./chunk-ZOO4I2U4.js";
  55. import "./chunk-JPUFJK2B.js";
  56. import "./chunk-HZ2WKB3G.js";
  57. import "./chunk-3HCJD762.js";
  58. import "./chunk-RVCE264D.js";
  59. import "./chunk-HKJ7X3BD.js";
  60. import "./chunk-Y74D3LKQ.js";
  61. import "./chunk-PK4W65H4.js";
  62. import "./chunk-7C23ILQ4.js";
  63. import "./chunk-P6VVVEX6.js";
  64. import "./chunk-3Z755LKF.js";
  65. import "./chunk-LTZ5XXDV.js";
  66. import "./chunk-IEU3AM37.js";
  67. import "./chunk-SKKBVHTF.js";
  68. import "./chunk-DLMAGHHC.js";
  69. import "./chunk-WD4J43GZ.js";
  70. import "./chunk-JOYXMSKE.js";
  71. import {
  72. m
  73. } from "./chunk-SZFMKPVM.js";
  74. import "./chunk-YZVAB3DF.js";
  75. import "./chunk-JLYTER4T.js";
  76. import "./chunk-CRHRHOXH.js";
  77. import "./chunk-ZSW35JPD.js";
  78. import "./chunk-JLSNMUQJ.js";
  79. import "./chunk-ECY35CJI.js";
  80. import "./chunk-PT62335L.js";
  81. import "./chunk-JGBXYDGB.js";
  82. import "./chunk-QEWF7QPH.js";
  83. import "./chunk-PJNBFKPF.js";
  84. import "./chunk-C7742RNZ.js";
  85. import "./chunk-FNA5GLRW.js";
  86. import "./chunk-MCWCB5IY.js";
  87. import "./chunk-TV3CFJQR.js";
  88. import "./chunk-TJV6ODRM.js";
  89. import "./chunk-JUWKPBLS.js";
  90. import "./chunk-WLSB4F4I.js";
  91. import "./chunk-GLSWDDR3.js";
  92. import "./chunk-MIQGEDET.js";
  93. import "./chunk-DUEMJ5XS.js";
  94. import "./chunk-VRLXUHP2.js";
  95. import "./chunk-3LVSQLWJ.js";
  96. import "./chunk-4ONPMX2F.js";
  97. import "./chunk-CRGY2SDS.js";
  98. import "./chunk-4T5ZGMEN.js";
  99. import "./chunk-GN35O2ZO.js";
  100. import "./chunk-XTVKPAWY.js";
  101. import "./chunk-3OSQ6GXO.js";
  102. import "./chunk-3WQOA5CB.js";
  103. import "./chunk-PLWDAYK7.js";
  104. import "./chunk-FZQZIM7U.js";
  105. import "./chunk-CZBRZ6SU.js";
  106. import "./chunk-VGWC3IKZ.js";
  107. import "./chunk-2H5MD622.js";
  108. import "./chunk-3RSFVUKZ.js";
  109. import "./chunk-UVVU4UUO.js";
  110. import {
  111. l,
  112. o as o2
  113. } from "./chunk-ICWTATWH.js";
  114. import "./chunk-HWSWTWZD.js";
  115. import "./chunk-O6VYMEIX.js";
  116. import "./chunk-X4SA4ELJ.js";
  117. import "./chunk-5N7JLUJJ.js";
  118. import "./chunk-ZAY3CMAZ.js";
  119. import "./chunk-P3XKUGLS.js";
  120. import "./chunk-2ZSOO377.js";
  121. import {
  122. x as x2
  123. } from "./chunk-YUA3AHKR.js";
  124. import {
  125. j
  126. } from "./chunk-LU5IJZB4.js";
  127. import "./chunk-7IBV2TRE.js";
  128. import "./chunk-ZLNEXZAN.js";
  129. import "./chunk-5UVJ64RB.js";
  130. import "./chunk-SFEFRQCL.js";
  131. import "./chunk-DXVOOCG4.js";
  132. import "./chunk-3GZSQU56.js";
  133. import "./chunk-ZYRIJWLX.js";
  134. import "./chunk-RYY6632W.js";
  135. import "./chunk-DW42UVIT.js";
  136. import "./chunk-YAEIHDJH.js";
  137. import "./chunk-TJNOJH33.js";
  138. import "./chunk-OSHI574D.js";
  139. import "./chunk-ETGAZ7LF.js";
  140. import "./chunk-75U5LM2V.js";
  141. import "./chunk-RMDDCMKS.js";
  142. import "./chunk-VCH45Q2I.js";
  143. import "./chunk-LBW34VZ2.js";
  144. import "./chunk-GSSTTHIT.js";
  145. import "./chunk-YFSLJIO4.js";
  146. import "./chunk-IM3LVQXV.js";
  147. import "./chunk-55RWC67C.js";
  148. import "./chunk-HZRKBTHJ.js";
  149. import "./chunk-DVUG3KID.js";
  150. import "./chunk-FWSQEIAR.js";
  151. import "./chunk-VEGAOVMY.js";
  152. import "./chunk-6T6G6LCQ.js";
  153. import "./chunk-YEJL5NEF.js";
  154. import "./chunk-PQFTYGF5.js";
  155. import "./chunk-2Z2TG5CU.js";
  156. import "./chunk-6KZ2LTDA.js";
  157. import "./chunk-U2XHEJM7.js";
  158. import "./chunk-SQOPWYIT.js";
  159. import {
  160. E,
  161. x
  162. } from "./chunk-V6P2MAQQ.js";
  163. import {
  164. s2,
  165. s3
  166. } from "./chunk-E5O6P5I2.js";
  167. import "./chunk-SPWQ3AWG.js";
  168. import {
  169. s
  170. } from "./chunk-2TIUKVZN.js";
  171. import {
  172. r,
  173. t
  174. } from "./chunk-YXWMMD76.js";
  175. import "./chunk-S5KM4IGW.js";
  176. // node_modules/@arcgis/core/layers/save/featureLayerUtils.js
  177. var I = s2.getLogger("esri.layers.FeatureLayer");
  178. var S = "Feature Service";
  179. function g(e, t2) {
  180. return `Layer (title: ${e.title}, id: ${e.id}) of type '${e.declaredClass}' ${t2}`;
  181. }
  182. function j2(e, r3) {
  183. if (r3.type !== S)
  184. throw new s3("feature-layer:portal-item-wrong-type", g(e, `should have portal item of type "${S}"`));
  185. }
  186. async function L(e) {
  187. if (await e.load(), l(e))
  188. throw new s3("feature-layer:save", g(e, "using an in-memory source cannot be saved to a portal item"));
  189. }
  190. function P(e, r3) {
  191. var _a;
  192. let a2 = ((_a = e.messages) != null ? _a : []).filter(({ type: e2 }) => "error" === e2).map(({ name: e2, message: r4, details: a3 }) => new s3(e2, r4, a3));
  193. if ((r3 == null ? void 0 : r3.ignoreUnsupported) && (a2 = a2.filter(({ name: e2 }) => "layer:unsupported" !== e2 && "symbol:unsupported" !== e2 && "symbol-layer:unsupported" !== e2 && "property:unsupported" !== e2 && "url:unsupported" !== e2)), a2.length > 0)
  194. throw new s3("feature-layer:save", "Failed to save feature layer due to unsupported or invalid content. See 'details.errors' for more detailed information", { errors: a2 });
  195. }
  196. async function J(e, t2, r3) {
  197. "beforeSave" in e && "function" == typeof e.beforeSave && await e.beforeSave();
  198. const a2 = e.write({}, t2);
  199. return P(t2, r3), a2;
  200. }
  201. function N(e) {
  202. const { layer: t2, layerJSON: r3 } = e;
  203. return t2.isTable ? { layers: [], tables: [r3] } : { layers: [r3], tables: [] };
  204. }
  205. function O(e) {
  206. i(e, f.JSAPI), e.typeKeywords && (e.typeKeywords = e.typeKeywords.filter((e2, t2, r3) => r3.indexOf(e2) === t2));
  207. }
  208. function E2(e) {
  209. const r3 = e.portalItem;
  210. if (!r3)
  211. throw I.error("save: requires the portalItem property to be set"), new s3("feature-layer:portal-item-not-set", g(e, "requires the portalItem property to be set"));
  212. if (!r3.loaded)
  213. throw new s3("feature-layer:portal-item-not-loaded", g(e, "cannot be saved to a portal item that does not exist or is inaccessible"));
  214. j2(e, r3);
  215. }
  216. async function T(e, t2) {
  217. var _a;
  218. return /\/\d+\/?$/.test((_a = e.url) != null ? _a : "") ? N(t2[0]) : $(e, t2);
  219. }
  220. async function $(e, t2) {
  221. const { layer: { url: r3, customParameters: a2, apiKey: o3 } } = t2[0];
  222. let s4 = await e.fetchData("json");
  223. s4 && null != s4.layers && null != s4.tables || (s4 = await x3(s4, { url: r3 != null ? r3 : "", customParameters: a2, apiKey: o3 }, t2.map((e2) => e2.layer.layerId)));
  224. for (const l2 of t2)
  225. K(l2.layer, l2.layerJSON, s4);
  226. return s4;
  227. }
  228. async function x3(e, t2, r3) {
  229. var a2, o3;
  230. e || (e = {}), (a2 = e).layers || (a2.layers = []), (o3 = e).tables || (o3.tables = []);
  231. const { url: s4, customParameters: l2, apiKey: i3 } = t2, { serviceJSON: n, layersJSON: u } = await r2(s4, { customParameters: l2, apiKey: i3 }), c2 = A(e.layers, n.layers, r3), y = A(e.tables, n.tables, r3);
  232. e.layers = c2.itemResources, e.tables = y.itemResources;
  233. const d = [...c2.added, ...y.added], m2 = u ? [...u.layers, ...u.tables] : [];
  234. return await U(e, d, s4, m2), e;
  235. }
  236. function A(t2, r3, a2) {
  237. const o3 = s(t2, r3, (e, t3) => e.id === t3.id);
  238. t2 = t2.filter((e) => !o3.removed.some((t3) => t3.id === e.id));
  239. const s4 = o3.added.map(({ id: e }) => ({ id: e }));
  240. return s4.forEach(({ id: e }) => {
  241. t2.push({ id: e });
  242. }), { itemResources: t2, added: s4.filter(({ id: e }) => !a2.includes(e)) };
  243. }
  244. async function U(e, t2, r3, o3) {
  245. const s4 = t2.map(({ id: e2 }) => new Ze({ url: r3, layerId: e2, sourceJSON: o3.find(({ id: t3 }) => t3 === e2) }));
  246. await E(s4.map((e2) => e2.load())), s4.forEach((t3) => {
  247. const { layerId: r4, loaded: o4, defaultPopupTemplate: s5 } = t3;
  248. if (!o4 || t(s5))
  249. return;
  250. K(t3, { id: r4, popupInfo: s5.toJSON() }, e);
  251. });
  252. }
  253. function K(e, t2, r3) {
  254. e.isTable ? F(r3.tables, t2) : F(r3.layers, t2);
  255. }
  256. function F(e, t2) {
  257. if (!e)
  258. return;
  259. const r3 = e.findIndex(({ id: e2 }) => e2 === t2.id);
  260. -1 === r3 ? e.push(t2) : e[r3] = t2;
  261. }
  262. function R(e) {
  263. const { portalItem: t2 } = e;
  264. return o2(e) && !e.dynamicDataSource && !!(t2 == null ? void 0 : t2.loaded) && t2.type === S;
  265. }
  266. async function D(e) {
  267. if (!(e == null ? void 0 : e.length))
  268. throw new s3("feature-layer-utils-saveall:missing-parameters", "'layers' array should contain at least one feature layer");
  269. await Promise.all(e.map((e2) => e2.load()));
  270. for (const o3 of e)
  271. if (!R(o3))
  272. throw new s3("feature-layer-utils-saveall:invalid-parameters", `'layers' array should only contain layers or tables in a feature service loaded from 'Feature Service' item. ${g(o3, "does not conform")}`, { layer: o3 });
  273. const r3 = e.map((e2) => e2.portalItem.id);
  274. if (new Set(r3).size > 1)
  275. throw new s3("feature-layer-utils-saveall:invalid-parameters", "All layers in the 'layers' array should be loaded from the same portal item");
  276. const a2 = e.map((e2) => e2.layerId);
  277. if (new Set(a2).size !== a2.length)
  278. throw new s3("feature-layer-utils-saveall:invalid-parameters", "'layers' array should contain only one instance each of layer or table in a feature service");
  279. }
  280. function _(e, t2) {
  281. var _a, _b;
  282. var r3, a2;
  283. let o3 = x2.from(t2);
  284. return o3.id && (o3 = o3.clone(), o3.id = null), (_a = (r3 = o3).type) != null ? _a : r3.type = S, (_b = (a2 = o3).portal) != null ? _b : a2.portal = j.getDefault(), j2(e, o3), o3;
  285. }
  286. async function q(e, t2) {
  287. const { url: r3, layerId: a2, title: s4, fullExtent: l2, isTable: i3 } = e, n = m(r3), p = r(n) && "FeatureServer" === n.serverType;
  288. t2.url = p ? r3 : `${r3}/${a2}`, t2.title || (t2.title = s4), t2.extent = null, !i3 && r(l2) && (t2.extent = await a(l2)), c(t2, f.METADATA), c(t2, f.MULTI_LAYER), i(t2, f.SINGLE_LAYER), i3 && i(t2, f.TABLE), O(t2);
  289. }
  290. async function z(e, t2, r3) {
  291. var _a;
  292. const a2 = e.portal;
  293. await (a2 == null ? void 0 : a2._signIn()), await ((_a = a2 == null ? void 0 : a2.user) == null ? void 0 : _a.addItem({ item: e, data: t2, folder: r3 == null ? void 0 : r3.folder }));
  294. }
  295. var C = x(M);
  296. async function M(e, t2) {
  297. await L(e), E2(e);
  298. const r3 = e.portalItem, a2 = o(r3), o3 = await J(e, a2, t2), s4 = await T(r3, [{ layer: e, layerJSON: o3 }]);
  299. return O(r3), await r3.update({ data: s4 }), i2(a2), r3;
  300. }
  301. var Y = x(async (e, t2) => {
  302. await D(e);
  303. const r3 = e[0].portalItem, a2 = o(r3), o3 = await Promise.all(e.map((e2) => J(e2, a2, t2))), s4 = await T(r3, e.map((e2, t3) => ({ layer: e2, layerJSON: o3[t3] })));
  304. return O(r3), await r3.update({ data: s4 }), await Promise.all(e.slice(1).map((e2) => e2.portalItem.reload())), i2(a2), r3.clone();
  305. });
  306. var B = x(G);
  307. async function G(e, t2, r3) {
  308. await L(e);
  309. const a2 = _(e, t2), o3 = o(a2), s4 = N({ layer: e, layerJSON: await J(e, o3, r3) });
  310. return await q(e, a2), await z(a2, s4, r3), e.portalItem = a2, i2(o3), a2;
  311. }
  312. export {
  313. C as save,
  314. Y as saveAll,
  315. B as saveAs
  316. };
  317. //# sourceMappingURL=featureLayerUtils-4XVGLMTG.js.map