import { i as i2 } from "./chunk-5ZZSM3DU.js"; import "./chunk-BQ7UE3XL.js"; import { b as b2 } from "./chunk-KA2TGIQA.js"; import { a as a2, c, f, i } from "./chunk-UYC6KGJA.js"; import { o } from "./chunk-ILURGS2L.js"; import "./chunk-QNKN2AAB.js"; import { Ke } from "./chunk-6NQ3AA2U.js"; import "./chunk-524XACB7.js"; import "./chunk-XKHC7KKF.js"; import "./chunk-HGDNY7J3.js"; import "./chunk-GD5TMIPM.js"; import "./chunk-ZRX5UNQH.js"; import "./chunk-VEAEIBHK.js"; import "./chunk-6SASJ6IM.js"; import "./chunk-3OHML7FO.js"; import "./chunk-JGOAMEPM.js"; import "./chunk-Z64YKYHD.js"; import "./chunk-2VFJVI2I.js"; import "./chunk-F37AVPUF.js"; import "./chunk-FUEX356Y.js"; import "./chunk-DH2OBAUC.js"; import "./chunk-TNLRDNTC.js"; import "./chunk-OSNKP4CI.js"; import "./chunk-435DJNTD.js"; import "./chunk-T3EUPDKL.js"; import "./chunk-2SJEIKRW.js"; import { a, l } from "./chunk-4FQG6M7Q.js"; import "./chunk-PHRSJJ3U.js"; import "./chunk-VVBOYBFX.js"; import "./chunk-S7R5EXHN.js"; import "./chunk-FMKGHOGD.js"; import "./chunk-6URTNEGN.js"; import "./chunk-KN7TOKVN.js"; import "./chunk-RQJNTZAL.js"; import "./chunk-QTOOFNRV.js"; import "./chunk-7O56JPWQ.js"; import "./chunk-6B2LQBKM.js"; import "./chunk-MFI6BALW.js"; import "./chunk-CIG5OHC7.js"; import "./chunk-FUD7XO3N.js"; import "./chunk-6EU7GFUT.js"; import "./chunk-MFUAILAT.js"; import "./chunk-HZJYXMI6.js"; import "./chunk-27P5ZSC7.js"; import "./chunk-UPD4MTCL.js"; import "./chunk-GRBROWI6.js"; import "./chunk-5NKYXKIA.js"; import "./chunk-MPWGHCZG.js"; import "./chunk-FTI5VP6T.js"; import "./chunk-RZFGRBD7.js"; import "./chunk-PUSPZYFZ.js"; import "./chunk-EN7YGJWG.js"; import "./chunk-VBNMTM7L.js"; import "./chunk-3D3QEPRE.js"; import "./chunk-JFNNSBWL.js"; import "./chunk-UD63WBG3.js"; import { m } from "./chunk-X7DBH4KK.js"; import "./chunk-LY74KTXV.js"; import "./chunk-EWE6EXPY.js"; import "./chunk-KUXNUNAI.js"; import "./chunk-KMAHKQ2G.js"; import "./chunk-522WBHUO.js"; import "./chunk-WNCU6BFU.js"; import "./chunk-PIGRDDRG.js"; import "./chunk-BJHM4JNS.js"; import "./chunk-F6A2QQ26.js"; import "./chunk-XLV7RUSE.js"; import "./chunk-NTUXR253.js"; import "./chunk-EOSZHC5H.js"; import "./chunk-C43UE3Z5.js"; import "./chunk-H2KDMZTR.js"; import "./chunk-RMX2AZ4P.js"; import "./chunk-NE3ESGA6.js"; import "./chunk-YIS6BAC3.js"; import "./chunk-7XXXCK2A.js"; import "./chunk-7ZIDBK7B.js"; import "./chunk-KHA63LLS.js"; import "./chunk-FGKNEJKJ.js"; import "./chunk-PSV473TI.js"; import "./chunk-I3OBGWNS.js"; import "./chunk-FONIFA5N.js"; import "./chunk-EG5OI4V4.js"; import "./chunk-65BYCSII.js"; import "./chunk-WZQZRKNH.js"; import "./chunk-LRDX4TO7.js"; import "./chunk-6A4U74YA.js"; import "./chunk-CYI7KFYB.js"; import "./chunk-5LXROFTA.js"; import "./chunk-GJXW4HL5.js"; import "./chunk-WJW5DUN6.js"; import "./chunk-W72F6AS3.js"; import "./chunk-PJ7ZQ4VD.js"; import "./chunk-WDLTDV2L.js"; import "./chunk-TERAW6FT.js"; import "./chunk-N2663GRX.js"; import "./chunk-O4FY3ITT.js"; import "./chunk-WEMIK25H.js"; import "./chunk-4DDBH2K5.js"; import "./chunk-7N4X6GF3.js"; import "./chunk-JXW4QTJA.js"; import "./chunk-UXF37FQ4.js"; import "./chunk-ZOEK6QHJ.js"; import "./chunk-XNLG7T2T.js"; import "./chunk-IR4PV7VK.js"; import "./chunk-2Z6LERTI.js"; import "./chunk-OWVBLVP3.js"; import "./chunk-AFZ7XSEW.js"; import { b } from "./chunk-EGZW6HC3.js"; import { B } from "./chunk-4NKD334K.js"; import "./chunk-65K7LC56.js"; import "./chunk-ATPLLI5W.js"; import "./chunk-WJ3OEUD3.js"; import "./chunk-MXB2XLKV.js"; import "./chunk-XH7RUGVZ.js"; import "./chunk-TBBTRX4O.js"; import "./chunk-YBSUITLL.js"; import "./chunk-ALDCDSPV.js"; import "./chunk-DT6EAZQ5.js"; import "./chunk-HNOZUNJ4.js"; import "./chunk-VNFRAYHO.js"; import "./chunk-R5IG2D6H.js"; import "./chunk-VBRY5KJM.js"; import "./chunk-PDKDCAAD.js"; import "./chunk-ECW2QABR.js"; import "./chunk-GCDJLKH4.js"; import "./chunk-MRJEICT6.js"; import "./chunk-Y3WMVFTW.js"; import "./chunk-SAS7RONY.js"; import "./chunk-WSRBH7BF.js"; import "./chunk-IHXECKQQ.js"; import { E, x } from "./chunk-ULGDPLM2.js"; import { s as s2, s3 } from "./chunk-EMJ4ZSM2.js"; import "./chunk-IKP3YN53.js"; import { r, s2 as s, t } from "./chunk-GZT4BVFP.js"; import "./chunk-A5ICIBVI.js"; // node_modules/@arcgis/core/layers/save/featureLayerUtils.js var I = s2.getLogger("esri.layers.FeatureLayer"); var S = "Feature Service"; function g(e, t2) { return `Layer (title: ${e.title}, id: ${e.id}) of type '${e.declaredClass}' ${t2}`; } function j(e, a3) { if (a3.type !== S) throw new s3("feature-layer:portal-item-wrong-type", g(e, `should have portal item of type "${S}"`)); } async function L(e) { if (await e.load(), a(e)) throw new s3("feature-layer:save", g(e, "using an in-memory source cannot be saved to a portal item")); } function P(e, a3) { let r2 = e.messages.filter(({ type: e2 }) => e2 === "error").map(({ name: e2, message: a4, details: r3 }) => new s3(e2, a4, r3)); if (a3?.ignoreUnsupported && (r2 = r2.filter(({ name: e2 }) => e2 !== "layer:unsupported" && e2 !== "symbol:unsupported" && e2 !== "symbol-layer:unsupported" && e2 !== "property:unsupported" && e2 !== "url:unsupported")), r2.length > 0) 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: r2 }); } async function J(e, t2, a3) { "beforeSave" in e && typeof e.beforeSave == "function" && await e.beforeSave(); const r2 = e.write({}, t2); return P(t2, a3), r2; } function N(e) { const { layer: t2, layerJSON: a3 } = e; return t2.isTable ? { layers: [], tables: [a3] } : { layers: [a3], tables: [] }; } function O(e) { i(e, f.JSAPI), e.typeKeywords && (e.typeKeywords = e.typeKeywords.filter((e2, t2, a3) => a3.indexOf(e2) === t2)); } function E2(e) { const a3 = e.portalItem; if (!a3) 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")); if (!a3.loaded) 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")); j(e, a3); } async function T(e, t2) { return /\/\d+\/?$/.test(e.url) ? N(t2[0]) : $(e, t2); } async function $(e, t2) { const { layer: { url: a3, customParameters: r2, apiKey: o2 } } = t2[0]; let s4 = await e.fetchData("json"); s4 && s4.layers != null && s4.tables != null || (s4 = await x2(s4, { url: a3, customParameters: r2, apiKey: o2 }, t2.map((e2) => e2.layer.layerId))); for (const l2 of t2) K(l2.layer, l2.layerJSON, s4); return s4; } async function x2(e, t2, a3) { var r2, o2; e || (e = {}), (r2 = e).layers || (r2.layers = []), (o2 = e).tables || (o2.tables = []); const { url: s4, customParameters: l2, apiKey: i3 } = t2, { serviceJSON: n, layersJSON: p } = await b2(s4, { customParameters: l2, apiKey: i3 }), c2 = A(e.layers, n.layers, a3), y = A(e.tables, n.tables, a3); e.layers = c2.itemResources, e.tables = y.itemResources; const d = [...c2.added, ...y.added], m2 = p ? [...p.layers, ...p.tables] : []; return await U(e, d, s4, m2), e; } function A(t2, a3, r2) { const o2 = s(t2, a3, (e, t3) => e.id === t3.id); t2 = t2.filter((e) => !o2.removed.some((t3) => t3.id === e.id)); const s4 = o2.added.map(({ id: e }) => ({ id: e })); return s4.forEach(({ id: e }) => { t2.push({ id: e }); }), { itemResources: t2, added: s4.filter(({ id: e }) => !r2.includes(e)) }; } async function U(e, t2, a3, o2) { const s4 = t2.map(({ id: e2 }) => new Ke({ url: a3, layerId: e2, sourceJSON: o2.find(({ id: t3 }) => t3 === e2) })); await E(s4.map((e2) => e2.load())), s4.forEach((t3) => { const { layerId: a4, loaded: o3, defaultPopupTemplate: s5 } = t3; if (!o3 || t(s5)) return; K(t3, { id: a4, popupInfo: s5.toJSON() }, e); }); } function K(e, t2, a3) { e.isTable ? F(a3.tables, t2) : F(a3.layers, t2); } function F(e, t2) { const a3 = e.findIndex(({ id: e2 }) => e2 === t2.id); a3 === -1 ? e.push(t2) : e[a3] = t2; } function R(e) { const { portalItem: t2 } = e; return l(e) && !e.dynamicDataSource && !!t2?.loaded && t2.type === S; } async function D(e) { if (!e?.length) throw new s3("feature-layer-utils-saveall:missing-parameters", "'layers' array should contain at least one feature layer"); await Promise.all(e.map((e2) => e2.load())); for (const o2 of e) if (!R(o2)) 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(o2, "does not conform")}`, { layer: o2 }); const a3 = e.map((e2) => e2.portalItem.id); if (new Set(a3).size > 1) throw new s3("feature-layer-utils-saveall:invalid-parameters", "All layers in the 'layers' array should be loaded from the same portal item"); const r2 = e.map((e2) => e2.layerId); if (new Set(r2).size !== r2.length) 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"); } function _(e, t2) { var a3, r2; let o2 = b.from(t2); return o2.id && (o2 = o2.clone(), o2.id = null), (a3 = o2).type ?? (a3.type = S), (r2 = o2).portal ?? (r2.portal = B.getDefault()), j(e, o2), o2; } async function q(e, t2) { const { url: a3, layerId: r2, title: s4, fullExtent: l2, isTable: i3 } = e, n = m(a3), u = r(n) && n.serverType === "FeatureServer"; t2.url = u ? a3 : `${a3}/${r2}`, t2.title || (t2.title = s4), t2.extent = null, !i3 && r(l2) && (t2.extent = await a2(l2)), c(t2, f.METADATA), c(t2, f.MULTI_LAYER), i(t2, f.SINGLE_LAYER), i3 && i(t2, f.TABLE), O(t2); } async function z(e, t2, a3) { const r2 = e.portal; await r2._signIn(), await r2.user.addItem({ item: e, data: t2, folder: a3?.folder }); } var C = x(M); async function M(e, t2) { await L(e), E2(e); const a3 = e.portalItem, r2 = o(a3), o2 = await J(e, r2, t2), s4 = await T(a3, [{ layer: e, layerJSON: o2 }]); return O(a3), await a3.update({ data: s4 }), i2(r2), a3; } var Y = x(async (e, t2) => { await D(e); const a3 = e[0].portalItem, r2 = o(a3), o2 = await Promise.all(e.map((e2) => J(e2, r2, t2))), s4 = await T(a3, e.map((e2, t3) => ({ layer: e2, layerJSON: o2[t3] }))); return O(a3), await a3.update({ data: s4 }), await Promise.all(e.slice(1).map((e2) => e2.portalItem.reload())), i2(r2), a3.clone(); }); var B2 = x(G); async function G(e, t2, a3) { await L(e); const r2 = _(e, t2), o2 = o(r2), s4 = N({ layer: e, layerJSON: await J(e, o2, a3) }); return await q(e, r2), await z(r2, s4, a3), e.portalItem = r2, i2(o2), r2; } export { C as save, Y as saveAll, B2 as saveAs }; //# sourceMappingURL=featureLayerUtils-SGDU7QQB.js.map