chunk-VNFRAYHO.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. import {
  2. n
  3. } from "./chunk-R5IG2D6H.js";
  4. import {
  5. A,
  6. Bt,
  7. D,
  8. E,
  9. F,
  10. H,
  11. I,
  12. J,
  13. St,
  14. V,
  15. W,
  16. X,
  17. b,
  18. j,
  19. mt,
  20. z
  21. } from "./chunk-VBRY5KJM.js";
  22. import {
  23. g,
  24. m as m2,
  25. p,
  26. v
  27. } from "./chunk-ULGDPLM2.js";
  28. import {
  29. r as r2,
  30. s3 as s
  31. } from "./chunk-EMJ4ZSM2.js";
  32. import {
  33. m
  34. } from "./chunk-IKP3YN53.js";
  35. import {
  36. a,
  37. e,
  38. r
  39. } from "./chunk-GZT4BVFP.js";
  40. // node_modules/@arcgis/core/support/apiKeyUtils.js
  41. var t = ["elevation3d.arcgis.com", "js.arcgis.com", "jsdev.arcgis.com", "jsqa.arcgis.com", "static.arcgis.com"];
  42. function r3(c) {
  43. const r4 = H(c, true);
  44. return r4 && r4.endsWith(".arcgis.com") && !t.includes(r4) && !c.endsWith("/sharing/rest/generateToken");
  45. }
  46. // node_modules/@arcgis/core/support/requestUtils.js
  47. function a2(r4, n2, s2 = false, i) {
  48. return new Promise((c, a3) => {
  49. if (p(i))
  50. return void a3(m3());
  51. let u2 = () => {
  52. l(), a3(new Error(`Unable to load ${n2}`));
  53. }, d2 = () => {
  54. const e2 = r4;
  55. l(), c(e2);
  56. }, f2 = () => {
  57. if (!r4)
  58. return;
  59. const e2 = r4;
  60. l(), e2.src = "", a3(m3());
  61. };
  62. const l = () => {
  63. a("esri-image-decode") || (r4.removeEventListener("error", u2), r4.removeEventListener("load", d2)), u2 = null, d2 = null, r4 = null, r(i) && i.removeEventListener("abort", f2), f2 = null, s2 && URL.revokeObjectURL(n2);
  64. };
  65. r(i) && i.addEventListener("abort", f2), a("esri-image-decode") ? r4.decode().then(d2, u2) : (r4.addEventListener("error", u2), r4.addEventListener("load", d2));
  66. });
  67. }
  68. function m3() {
  69. try {
  70. return new DOMException("Aborted", "AbortError");
  71. } catch {
  72. const r4 = new Error();
  73. return r4.name = "AbortError", r4;
  74. }
  75. }
  76. function u(e2) {
  77. r2.request.crossOriginNoCorsDomains || (r2.request.crossOriginNoCorsDomains = {});
  78. const o = r2.request.crossOriginNoCorsDomains;
  79. for (let r4 of e2)
  80. r4 = r4.toLowerCase(), /^https?:\/\//.test(r4) ? o[H(r4)] = 0 : (o[H("http://" + r4)] = 0, o[H("https://" + r4)] = 0);
  81. }
  82. function d(e2) {
  83. const o = r2.request.crossOriginNoCorsDomains;
  84. if (o) {
  85. let r4 = H(e2);
  86. if (r4)
  87. return r4 = r4.toLowerCase(), !z(r4, b()) && o[r4] < Date.now() - 36e5;
  88. }
  89. return false;
  90. }
  91. async function f(e2) {
  92. const o = r2.request.crossOriginNoCorsDomains;
  93. o && (o[H(e2).toLowerCase()] = Date.now());
  94. const t2 = j(e2);
  95. e2 = t2.path, t2.query?.f === "json" && (e2 += "?f=json");
  96. try {
  97. await fetch(e2, { mode: "no-cors", credentials: "include" });
  98. } catch {
  99. }
  100. }
  101. // node_modules/@arcgis/core/request.js
  102. async function U(e2, r4) {
  103. const t2 = X(e2), o = V(e2);
  104. o || t2 || (e2 = F(e2));
  105. const i = { url: e2, requestOptions: { ...e(r4) } };
  106. let l = W(e2);
  107. if (l) {
  108. const e3 = await G(l, i);
  109. if (e3 != null)
  110. return { data: e3, getHeader: M, requestOptions: i.requestOptions, url: i.url };
  111. l.after || l.error || (l = null);
  112. }
  113. if (e2 = i.url, (r4 = i.requestOptions).responseType === "image") {
  114. if (a("host-webworker") || a("host-node"))
  115. throw N("request:invalid-parameters", new Error("responseType 'image' is not supported in Web Workers or Node environment"), i);
  116. } else if (t2)
  117. throw N("request:invalid-parameters", new Error("Data URLs are not supported for responseType = " + r4.responseType), i);
  118. if (r4.method === "head") {
  119. if (r4.body)
  120. throw N("request:invalid-parameters", new Error("body parameter cannot be set when method is 'head'"), i);
  121. if (t2 || o)
  122. throw N("request:invalid-parameters", new Error("data and blob URLs are not supported for method 'head'"), i);
  123. }
  124. if (await B(), j2)
  125. return j2.execute(e2, r4);
  126. const u2 = new AbortController();
  127. v(r4, () => u2.abort());
  128. const m4 = { controller: u2, credential: null, credentialToken: null, fetchOptions: null, hasToken: false, interceptor: l, params: i, redoRequest: false, useIdentity: P.useIdentity, useProxy: false, useSSL: false, withCredentials: false }, f2 = await Q(m4);
  129. return l?.after?.(f2), f2;
  130. }
  131. var j2;
  132. var P = r2.request;
  133. var D2 = "FormData" in globalThis;
  134. var _ = [499, 498, 403, 401];
  135. var F2 = ["COM_0056", "COM_0057", "SB_0008"];
  136. var I2 = [/\/arcgis\/tokens/i, /\/sharing(\/rest)?\/generatetoken/i, /\/rest\/info/i];
  137. var M = () => null;
  138. var R = Symbol();
  139. function H2(e2) {
  140. const r4 = H(e2);
  141. r4 && !U._corsServers.includes(r4) && U._corsServers.push(r4);
  142. }
  143. function A2(e2) {
  144. const r4 = H(e2);
  145. return !r4 || r4.endsWith(".arcgis.com") || U._corsServers.includes(r4) || D(r4);
  146. }
  147. function N(e2, r4, s2, n2) {
  148. let a3 = "Error";
  149. const u2 = { url: s2.url, requestOptions: s2.requestOptions, getHeader: M, ssl: false };
  150. if (r4 instanceof s)
  151. return r4.details ? (r4.details = m(r4.details), r4.details.url = s2.url, r4.details.requestOptions = s2.requestOptions) : r4.details = u2, r4;
  152. if (r4) {
  153. const e3 = n2 && ((e4) => n2.headers.get(e4)), t2 = n2 && n2.status, s3 = r4.message;
  154. s3 && (a3 = s3), e3 && (u2.getHeader = e3), u2.httpStatus = (r4.httpCode != null ? r4.httpCode : r4.code) || t2 || 0, u2.subCode = r4.subcode, u2.messageCode = r4.messageCode, typeof r4.details == "string" ? u2.messages = [r4.details] : u2.messages = r4.details, u2.raw = R in r4 ? r4[R] : r4;
  155. }
  156. return g(r4) ? m2() : new s(e2, a3, u2);
  157. }
  158. async function B() {
  159. a("host-webworker") ? j2 || (j2 = await import("./request-6QW67QAT.js")) : U._abortableFetch || (U._abortableFetch = globalThis.fetch.bind(globalThis));
  160. }
  161. async function $() {
  162. n || await import("./IdentityManager-CNNYIJFK.js");
  163. }
  164. async function z2(t2) {
  165. const s2 = t2.params.url, o = t2.params.requestOptions, n2 = t2.controller.signal, a3 = o.body;
  166. let i = null, l = null;
  167. if (D2 && "HTMLFormElement" in globalThis && (a3 instanceof FormData ? i = a3 : a3 instanceof HTMLFormElement && (i = new FormData(a3))), typeof a3 == "string" && (l = a3), t2.fetchOptions = { cache: o.cacheBust && !U._abortableFetch.polyfill ? "no-cache" : "default", credentials: "same-origin", headers: o.headers || {}, method: o.method === "head" ? "HEAD" : "GET", mode: "cors", priority: P.priority, redirect: "follow", signal: n2 }, (i || l) && (t2.fetchOptions.body = i || l), o.authMode === "anonymous" && (t2.useIdentity = false), t2.hasToken = !!(/token=/i.test(s2) || o.query?.token || i?.get("token")), !t2.hasToken && r2.apiKey && r3(s2) && (o.query || (o.query = {}), o.query.token = r2.apiKey, t2.hasToken = true), t2.useIdentity && !t2.hasToken && !t2.credentialToken && !K(s2) && !p(n2)) {
  168. let e2;
  169. o.authMode === "immediate" ? (await $(), e2 = await n.getCredential(s2, { signal: n2 }), t2.credential = e2) : o.authMode === "no-prompt" ? (await $(), e2 = await n.getCredential(s2, { prompt: false, signal: n2 }).catch(() => {
  170. }), t2.credential = e2) : n && (e2 = n.findCredential(s2)), e2 && (t2.credentialToken = e2.token, t2.useSSL = !!e2.ssl);
  171. }
  172. }
  173. function K(e2) {
  174. return I2.some((r4) => r4.test(e2));
  175. }
  176. async function W2(e2) {
  177. let t2 = e2.params.url;
  178. const o = e2.params.requestOptions, n2 = e2.fetchOptions, a3 = V(t2) || X(t2), i = o.responseType || "json", u2 = a3 ? 0 : o.timeout != null ? o.timeout : P.timeout;
  179. let p2 = false;
  180. if (!a3) {
  181. e2.useSSL && (t2 = mt(t2)), o.cacheBust && n2.cache === "default" && (t2 = St(t2, "request.preventCache", Date.now()));
  182. let a4 = { ...o.query };
  183. e2.credentialToken && (a4.token = e2.credentialToken);
  184. let i2 = I(a4);
  185. a("esri-url-encodes-apostrophe") && (i2 = i2.replace(/'/g, "%27"));
  186. const l = t2.length + 1 + i2.length;
  187. let u3;
  188. p2 = o.method === "delete" || o.method === "post" || o.method === "put" || !!o.body || l > P.maxUrlLength;
  189. const c = o.useProxy || !!J(t2);
  190. if (c) {
  191. const e3 = A(t2);
  192. u3 = e3.path, !p2 && u3.length + 1 + l > P.maxUrlLength && (p2 = true), e3.query && (a4 = { ...e3.query, ...a4 });
  193. }
  194. if (n2.method === "HEAD" && (p2 || c)) {
  195. if (p2) {
  196. if (l > P.maxUrlLength)
  197. throw N("request:invalid-parameters", new Error("URL exceeds maximum length"), e2.params);
  198. throw N("request:invalid-parameters", new Error("cannot use POST request when method is 'head'"), e2.params);
  199. }
  200. if (c)
  201. throw N("request:invalid-parameters", new Error("cannot use proxy when method is 'head'"), e2.params);
  202. }
  203. if (p2 ? (n2.method = o.method === "delete" ? "DELETE" : o.method === "put" ? "PUT" : "POST", o.body ? t2 = Bt(t2, a4) : (n2.body = I(a4), n2.headers["Content-Type"] = "application/x-www-form-urlencoded")) : t2 = Bt(t2, a4), c && (e2.useProxy = true, t2 = `${u3}?${t2}`), a4.token && D2 && n2.body instanceof FormData && !/\/(sharing|usrsvcs)\/(appservices|servers)\//i.test(t2) && n2.body.set("token", a4.token), o.hasOwnProperty("withCredentials"))
  204. e2.withCredentials = o.withCredentials;
  205. else if (!z(t2, b())) {
  206. if (D(t2))
  207. e2.withCredentials = true;
  208. else if (n) {
  209. const s2 = n.findServerInfo(t2);
  210. s2 && s2.webTierAuth && (e2.withCredentials = true);
  211. }
  212. }
  213. e2.withCredentials && (n2.credentials = "include", d(t2) && await f(p2 ? Bt(t2, a4) : t2));
  214. }
  215. let h, C, x = 0, L = false;
  216. u2 > 0 && (x = setTimeout(() => {
  217. L = true, e2.controller.abort();
  218. }, u2));
  219. try {
  220. if (o.responseType === "native-request-init")
  221. C = n2, C.url = t2;
  222. else if (o.responseType !== "image" || n2.cache !== "default" || n2.method !== "GET" || p2 || J2(o.headers) || !a3 && !e2.useProxy && P.proxyUrl && !A2(t2)) {
  223. if (h = await U._abortableFetch(t2, n2), e2.useProxy || H2(t2), o.responseType === "native")
  224. C = h;
  225. else if (n2.method !== "HEAD")
  226. if (h.ok) {
  227. switch (i) {
  228. case "array-buffer":
  229. C = await h.arrayBuffer();
  230. break;
  231. case "blob":
  232. case "image":
  233. C = await h.blob();
  234. break;
  235. default:
  236. C = await h.text();
  237. }
  238. if (x && (clearTimeout(x), x = 0), i === "json" || i === "xml" || i === "document")
  239. if (C)
  240. switch (i) {
  241. case "json":
  242. C = JSON.parse(C);
  243. break;
  244. case "xml":
  245. C = X2(C, "application/xml");
  246. break;
  247. case "document":
  248. C = X2(C, "text/html");
  249. }
  250. else
  251. C = null;
  252. if (C) {
  253. if (i === "array-buffer" || i === "blob") {
  254. const e3 = h.headers.get("Content-Type");
  255. if (/application\/json|text\/plain/i.test(e3) && C[i === "blob" ? "size" : "byteLength"] <= 750)
  256. try {
  257. const e4 = await new Response(C).json();
  258. e4.error && (C = e4);
  259. } catch {
  260. }
  261. }
  262. i === "image" && C instanceof Blob && (C = await Y(URL.createObjectURL(C), e2, true));
  263. }
  264. } else
  265. C = await h.text();
  266. } else
  267. C = await Y(t2, e2);
  268. } catch (j3) {
  269. if (j3.name === "AbortError") {
  270. if (L)
  271. throw new Error("Timeout exceeded");
  272. throw m2("Request canceled");
  273. }
  274. if (!(!h && j3 instanceof TypeError && P.proxyUrl) || o.body || o.method === "delete" || o.method === "head" || o.method === "post" || o.method === "put" || e2.useProxy || A2(t2))
  275. throw j3;
  276. e2.redoRequest = true, E({ proxyUrl: P.proxyUrl, urlPrefix: H(t2) });
  277. } finally {
  278. x && clearTimeout(x);
  279. }
  280. return [h, C];
  281. }
  282. async function G(e2, r4) {
  283. if (e2.responseData != null)
  284. return e2.responseData;
  285. if (e2.headers && (r4.requestOptions.headers = { ...r4.requestOptions.headers, ...e2.headers }), e2.query && (r4.requestOptions.query = { ...r4.requestOptions.query, ...e2.query }), e2.before) {
  286. let o, n2;
  287. try {
  288. n2 = await e2.before(r4);
  289. } catch (s2) {
  290. o = N("request:interceptor", s2, r4);
  291. }
  292. if ((n2 instanceof Error || n2 instanceof s) && (o = N("request:interceptor", n2, r4)), o)
  293. throw e2.error && e2.error(o), o;
  294. return n2;
  295. }
  296. }
  297. function J2(e2) {
  298. if (e2) {
  299. for (const r4 of Object.getOwnPropertyNames(e2))
  300. if (e2[r4])
  301. return true;
  302. }
  303. return false;
  304. }
  305. function X2(e2, r4) {
  306. let t2;
  307. try {
  308. t2 = new DOMParser().parseFromString(e2, r4);
  309. } catch {
  310. }
  311. if (!t2 || t2.getElementsByTagName("parsererror").length)
  312. throw new SyntaxError("XML Parse error");
  313. return t2;
  314. }
  315. async function Q(e2) {
  316. let t2, s2;
  317. await z2(e2);
  318. try {
  319. do {
  320. [t2, s2] = await W2(e2);
  321. } while (!await V2(e2, t2, s2));
  322. } catch (a3) {
  323. const r4 = N("request:server", a3, e2.params, t2);
  324. throw r4.details.ssl = e2.useSSL, e2.interceptor && e2.interceptor.error && e2.interceptor.error(r4), r4;
  325. }
  326. const o = e2.params.url;
  327. if (s2 && /\/sharing\/rest\/(accounts|portals)\/self/i.test(o)) {
  328. if (!e2.hasToken && !e2.credentialToken && s2.user?.username && !D(o)) {
  329. const e3 = H(o, true);
  330. e3 && P.trustedServers.push(e3);
  331. }
  332. Array.isArray(s2.authorizedCrossOriginNoCorsDomains) && u(s2.authorizedCrossOriginNoCorsDomains);
  333. }
  334. const n2 = e2.credential;
  335. if (n2 && n) {
  336. const e3 = n.findServerInfo(n2.server);
  337. let t3 = e3 && e3.owningSystemUrl;
  338. if (t3) {
  339. t3 = t3.replace(/\/?$/, "/sharing");
  340. const e4 = n.findCredential(t3, n2.userId);
  341. e4 && n._getIdenticalSvcIdx(t3, e4) === -1 && e4.resources.unshift(t3);
  342. }
  343. }
  344. return { data: s2, getHeader: t2 ? (e3) => t2.headers.get(e3) : M, requestOptions: e2.params.requestOptions, ssl: e2.useSSL, url: e2.params.url };
  345. }
  346. async function V2(e2, t2, s2) {
  347. if (e2.redoRequest)
  348. return e2.redoRequest = false, false;
  349. const o = e2.params.requestOptions;
  350. if (!t2 || o.responseType === "native" || o.responseType === "native-request-init")
  351. return true;
  352. let n2, a3, i, l;
  353. if (!t2.ok)
  354. throw n2 = new Error(`Unable to load ${t2.url} status: ${t2.status}`), n2[R] = s2, n2;
  355. s2?.error && (n2 = s2.error), n2 && (a3 = Number(n2.code), i = n2.hasOwnProperty("subcode") ? Number(n2.subcode) : null, l = n2.messageCode, l = l && l.toUpperCase());
  356. const u2 = o.authMode;
  357. if (a3 === 403 && (i === 4 || n2.message && n2.message.toLowerCase().includes("ssl") && !n2.message.toLowerCase().includes("permission"))) {
  358. if (!e2.useSSL)
  359. return e2.useSSL = true, false;
  360. } else if (!e2.hasToken && e2.useIdentity && (u2 !== "no-prompt" || a3 === 498) && _.includes(a3) && !K(e2.params.url) && (a3 !== 403 || !F2.includes(l) && (i == null || i === 2 && e2.credentialToken))) {
  361. await $();
  362. try {
  363. const t3 = await n.getCredential(e2.params.url, { error: N("request:server", n2, e2.params), prompt: u2 !== "no-prompt", signal: e2.controller.signal, token: e2.credentialToken });
  364. return e2.credential = t3, e2.credentialToken = t3.token, e2.useSSL = e2.useSSL || t3.ssl, false;
  365. } catch (c) {
  366. if (u2 === "no-prompt")
  367. return e2.credential = null, e2.credentialToken = null, false;
  368. n2 = c;
  369. }
  370. }
  371. if (n2)
  372. throw n2;
  373. return true;
  374. }
  375. function Y(e2, r4, t2 = false) {
  376. const s2 = r4.controller.signal, o = new Image();
  377. return r4.withCredentials ? o.crossOrigin = "use-credentials" : o.crossOrigin = "anonymous", o.alt = "", o.fetchPriority = P.priority, o.src = e2, a2(o, e2, t2, s2);
  378. }
  379. U._abortableFetch = null, U._corsServers = ["https://server.arcgisonline.com", "https://services.arcgisonline.com"];
  380. export {
  381. r3 as r,
  382. a2 as a,
  383. U
  384. };
  385. //# sourceMappingURL=chunk-VNFRAYHO.js.map