chunk-Z25OS74A.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. import {
  2. Ke
  3. } from "./chunk-6NQ3AA2U.js";
  4. import {
  5. b
  6. } from "./chunk-EGZW6HC3.js";
  7. import {
  8. B
  9. } from "./chunk-4NKD334K.js";
  10. import {
  11. U
  12. } from "./chunk-VNFRAYHO.js";
  13. import {
  14. n
  15. } from "./chunk-R5IG2D6H.js";
  16. import {
  17. w
  18. } from "./chunk-ULGDPLM2.js";
  19. import {
  20. r,
  21. t
  22. } from "./chunk-GZT4BVFP.js";
  23. // node_modules/@arcgis/core/layers/support/capabilities.js
  24. var t2 = { analytics: { supportsCacheHint: false }, attachment: { supportsContentType: false, supportsExifInfo: false, supportsKeywords: false, supportsName: false, supportsSize: false, supportsCacheHint: false, supportsResize: false }, data: { isVersioned: false, supportsAttachment: false, supportsM: false, supportsZ: false }, editing: { supportsDeleteByAnonymous: false, supportsDeleteByOthers: false, supportsGeometryUpdate: false, supportsGlobalId: false, supportsReturnServiceEditsInSourceSpatialReference: false, supportsRollbackOnFailure: false, supportsUpdateByAnonymous: false, supportsUpdateByOthers: false, supportsUpdateWithoutM: false, supportsUploadWithItemId: false }, metadata: { supportsAdvancedFieldProperties: false }, operations: { supportsCalculate: false, supportsTruncate: false, supportsValidateSql: false, supportsAdd: false, supportsDelete: false, supportsEditing: false, supportsChangeTracking: false, supportsQuery: false, supportsQueryAnalytics: false, supportsQueryAttachments: false, supportsQueryTopFeatures: false, supportsResizeAttachments: false, supportsSync: false, supportsUpdate: false, supportsExceedsLimitStatistics: false }, queryRelated: { supportsCount: false, supportsOrderBy: false, supportsPagination: false, supportsCacheHint: false }, queryTopFeatures: { supportsCacheHint: false }, query: { maxRecordCount: 0, maxRecordCountFactor: 0, standardMaxRecordCount: 0, supportsCacheHint: false, supportsCentroid: false, supportsCompactGeometry: false, supportsDefaultSpatialReference: false, supportsDisjointSpatialRelationship: false, supportsDistance: false, supportsDistinct: false, supportsExtent: false, supportsFormatPBF: false, supportsGeometryProperties: false, supportsHavingClause: false, supportsHistoricMoment: false, supportsMaxRecordCountFactor: false, supportsOrderBy: false, supportsPagination: false, supportsPercentileStatistics: false, supportsQuantization: false, supportsQuantizationEditMode: false, supportsQueryByOthers: false, supportsQueryGeometry: false, supportsResultType: false, supportsSqlExpression: false, supportsStandardizedQueriesOnly: false, supportsTopFeaturesQuery: false, supportsSpatialAggregationStatistics: false, supportedSpatialAggregationStatistics: { envelope: false, centroid: false, convexHull: false }, supportsStatistics: false, tileMaxRecordCount: 0 } };
  25. // node_modules/@arcgis/core/layers/support/FetchAssociatedFeatureLayer.js
  26. var l = class {
  27. constructor(t3, r2, e, a) {
  28. this.parsedUrl = t3, this.portalItem = r2, this.apiKey = e, this.signal = a, this.rootDocument = null;
  29. const s = this.parsedUrl.path.match(/^(.*)\/SceneServer\/layers\/([\d]*)\/?$/i);
  30. s && (this.urlParts = { root: s[1], layerId: parseInt(s[2], 10) });
  31. }
  32. async fetch() {
  33. if (!this.urlParts)
  34. return null;
  35. const t3 = this.portalItem ?? await this._portalItemFromServiceItemId();
  36. if (t(t3))
  37. return this._loadFromUrl();
  38. const r2 = await this._findAndLoadRelatedPortalItem(t3);
  39. return t(r2) ? null : this._loadFeatureLayerFromPortalItem(r2);
  40. }
  41. async fetchPortalItem() {
  42. if (!this.urlParts)
  43. return null;
  44. const t3 = this.portalItem ?? await this._portalItemFromServiceItemId();
  45. return t(t3) ? null : this._findAndLoadRelatedPortalItem(t3);
  46. }
  47. async _fetchRootDocument() {
  48. if (r(this.rootDocument))
  49. return this.rootDocument;
  50. if (t(this.urlParts))
  51. return this.rootDocument = {}, {};
  52. const t3 = { query: { f: "json", token: this.apiKey }, responseType: "json", signal: this.signal }, s = `${this.urlParts.root}/SceneServer`;
  53. try {
  54. const e = await U(s, t3);
  55. this.rootDocument = e.data;
  56. } catch {
  57. this.rootDocument = {};
  58. }
  59. return this.rootDocument;
  60. }
  61. async _fetchServiceOwningPortalUrl() {
  62. const e = n?.findServerInfo(this.parsedUrl.path);
  63. if (e?.owningSystemUrl)
  64. return e.owningSystemUrl;
  65. const a = this.parsedUrl.path.replace(/(.*\/rest)\/.*/i, "$1") + "/info";
  66. try {
  67. const t3 = (await U(a, { query: { f: "json" }, responseType: "json", signal: this.signal })).data.owningSystemUrl;
  68. if (t3)
  69. return t3;
  70. } catch (i) {
  71. w(i);
  72. }
  73. return null;
  74. }
  75. async _findAndLoadRelatedPortalItem(t3) {
  76. try {
  77. return (await t3.fetchRelatedItems({ relationshipType: "Service2Service", direction: "reverse" }, { signal: this.signal })).find((t4) => t4.type === "Feature Service") || null;
  78. } catch (r2) {
  79. return w(r2), null;
  80. }
  81. }
  82. async _loadFeatureLayerFromPortalItem(t3) {
  83. await t3.load({ signal: this.signal });
  84. const r2 = await this._findMatchingAssociatedSublayerUrl(t3.url);
  85. return new Ke({ url: r2, portalItem: t3 }).load({ signal: this.signal });
  86. }
  87. async _loadFromUrl() {
  88. const t3 = await this._findMatchingAssociatedSublayerUrl(`${this.urlParts.root}/FeatureServer`);
  89. return new Ke({ url: t3 }).load({ signal: this.signal });
  90. }
  91. async _findMatchingAssociatedSublayerUrl(t3) {
  92. const e = t3.replace(/^(.*FeatureServer)(\/[\d]*\/?)?$/i, "$1"), a = { query: { f: "json" }, responseType: "json", authMode: "no-prompt", signal: this.signal }, s = this.urlParts.layerId, i = this._fetchRootDocument(), o = U(e, a), [n2, l2] = await Promise.all([o, i]), c = l2 && l2.layers, h = n2.data && n2.data.layers;
  93. if (!Array.isArray(h))
  94. throw new Error("expected layers array");
  95. if (Array.isArray(c))
  96. for (let r2 = 0; r2 < Math.min(c.length, h.length); r2++) {
  97. if (c[r2].id === s)
  98. return `${e}/${h[r2].id}`;
  99. }
  100. else if (s < h.length)
  101. return `${e}/${h[s].id}`;
  102. throw new Error("could not find matching associated sublayer");
  103. }
  104. async _portalItemFromServiceItemId() {
  105. const t3 = (await this._fetchRootDocument()).serviceItemId;
  106. if (!t3)
  107. return null;
  108. const r2 = new b({ id: t3, apiKey: this.apiKey }), e = await this._fetchServiceOwningPortalUrl();
  109. r(e) && (r2.portal = new B({ url: e }));
  110. try {
  111. return r2.load({ signal: this.signal });
  112. } catch (i) {
  113. return w(i), null;
  114. }
  115. }
  116. };
  117. export {
  118. t2 as t,
  119. l
  120. };
  121. //# sourceMappingURL=chunk-Z25OS74A.js.map