@arcgis/core 4.28.2 → 4.28.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/023fc8504d032762ad82.js +1 -0
  3. package/assets/esri/core/workers/chunks/02e86a792dbe2fdec974.js +1 -0
  4. package/assets/esri/core/workers/chunks/{18e0c5bfeb1aa7213dfa.js → 076ac767b5148357f1b5.js} +1 -1
  5. package/assets/esri/core/workers/chunks/{5386b166f2e5dc0d9143.js → 12797aa1d6a2b49abb3f.js} +1 -1
  6. package/assets/esri/core/workers/chunks/1687431f7b233d950195.js +1 -0
  7. package/assets/esri/core/workers/chunks/{a1e16c33f1843dbdce26.js → 175bbe8a048f17dd482b.js} +1 -1
  8. package/assets/esri/core/workers/chunks/1c855f091d1305b82594.js +1 -0
  9. package/assets/esri/core/workers/chunks/{d0119dff8771e749436a.js → 30d3b31df52d40e5b2e6.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{768271a12dc7e1781447.js → 32fbd4355a4a649623a7.js} +1 -1
  11. package/assets/esri/core/workers/chunks/3dbc399eedd347b0fbbb.js +1 -0
  12. package/assets/esri/core/workers/chunks/{d5fec54e98c8622349a4.js → 46ddc52fe9cdd573a614.js} +1 -1
  13. package/assets/esri/core/workers/chunks/4747741429e8ff7112bb.js +1 -0
  14. package/assets/esri/core/workers/chunks/4a5d0b49a641d182b5ea.js +1 -0
  15. package/assets/esri/core/workers/chunks/4ae8308e5b9c7772a11f.js +1 -0
  16. package/assets/esri/core/workers/chunks/{da124ccd18d2745195fe.js → 4bd342f13002888b6467.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{7756ed853b4ba54cd081.js → 5247c00088303da7ef3b.js} +1 -1
  18. package/assets/esri/core/workers/chunks/534726130ef1698ec89e.js +1 -0
  19. package/assets/esri/core/workers/chunks/551bc697e3e17983c2bc.js +1 -0
  20. package/assets/esri/core/workers/chunks/{65d8135c89ffdd17a3c1.js → 59d3f4c0d1a43180aff3.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{2d92df1e3ba4f05e0510.js → 633b34a5817f1f719e22.js} +1 -1
  22. package/assets/esri/core/workers/chunks/{c7bd63103f101c09b1ea.js → 6996537249869c41e736.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{41778f8c49febe1f9404.js → 6fa0cccd4f3e1fa71421.js} +1 -1
  24. package/assets/esri/core/workers/chunks/{78e49a70193e5adea17c.js → 77f557359a5033d7e429.js} +1 -1
  25. package/assets/esri/core/workers/chunks/7cc56b132c46c5922dac.js +1 -0
  26. package/assets/esri/core/workers/chunks/80831e90fe1a52f8f982.js +1 -0
  27. package/assets/esri/core/workers/chunks/{ea9ae9d2aef01af90896.js → 80d9bb9f247ecdfa266f.js} +1 -1
  28. package/assets/esri/core/workers/chunks/846e5e51dc278bc3f80f.js +1 -0
  29. package/assets/esri/core/workers/chunks/{f73563b23fd8dc6cf2fe.js → 86df7357a2bac73c0ef4.js} +1 -1
  30. package/assets/esri/core/workers/chunks/8b541cbf82a5ba0317ee.js +1 -0
  31. package/assets/esri/core/workers/chunks/{08a98e85e86ce560d005.js → 8bd621693692050d76aa.js} +1 -1
  32. package/assets/esri/core/workers/chunks/{630b31a205d9db7147d0.js → 8cdece03397d01767593.js} +1 -1
  33. package/assets/esri/core/workers/chunks/{b9a726f3bbad6fd4d65a.js → 8e91be2e38010391e351.js} +1 -1
  34. package/assets/esri/core/workers/chunks/{cbddfcf57f72428a6992.js → 90f96a2ddfb25d851d4d.js} +1 -1
  35. package/assets/esri/core/workers/chunks/91a3181071874525ed44.js +1 -0
  36. package/assets/esri/core/workers/chunks/{b7c81a5bbcdd94b8a7f6.js → 9979ff59a144fe1df80b.js} +1 -1
  37. package/assets/esri/core/workers/chunks/{0422c5160491fbcf01dc.js → 9d97a20f69047d0c47cc.js} +1 -1
  38. package/assets/esri/core/workers/chunks/9f0e8dd5c9bacfc0f03c.js +1 -0
  39. package/assets/esri/core/workers/chunks/{a8e4726c1db23324eb54.js → 9fc1206ad378f0829e0a.js} +1 -1
  40. package/assets/esri/core/workers/chunks/{09e8babe75407c2e64c4.js → a351ab5082772b267895.js} +1 -1
  41. package/assets/esri/core/workers/chunks/{43575b9acf9819f195f9.js → a3bbf5da4f7830d2a2a1.js} +1 -1
  42. package/assets/esri/core/workers/chunks/{b03eaba5fa75d6ef834a.js → a47f74fc959b11f029a5.js} +1 -1
  43. package/assets/esri/core/workers/chunks/{cb4b17f5cf96a9e36781.js → a8cf23c3a55c1834178c.js} +1 -1
  44. package/assets/esri/core/workers/chunks/{dd55151bfac60b0deaac.js → ac4636e82a103e2c27ca.js} +1 -1
  45. package/assets/esri/core/workers/chunks/ae7ba94af6d4fd97dd8b.js +1 -0
  46. package/assets/esri/core/workers/chunks/af13150c711ba7b7f3ac.js +1 -0
  47. package/assets/esri/core/workers/chunks/{4adf3a8c6b49c381a633.js → b0653f63745e756f55fe.js} +1 -1
  48. package/assets/esri/core/workers/chunks/bab0aa000c65d5c256b7.js +1 -0
  49. package/assets/esri/core/workers/chunks/{e06cd10b6f8f363b5131.js → bdc751a752a7ff1387de.js} +1 -1
  50. package/assets/esri/core/workers/chunks/{70aa04b09143b7dd2ecb.js → c2199fb8f7a54a0ef18a.js} +1 -1
  51. package/assets/esri/core/workers/chunks/c3f462d11ed570482e7a.js +1 -0
  52. package/assets/esri/core/workers/chunks/{830d99e6c58a52a58973.js → c8cb5fe1d23145c4842b.js} +1 -1
  53. package/assets/esri/core/workers/chunks/{1f87f22e00e3218661c6.js → ce53413dd3e2062e8378.js} +1 -1
  54. package/assets/esri/core/workers/chunks/cfa6d1b63b794febe70a.js +1 -0
  55. package/assets/esri/core/workers/chunks/de30ff1fcb6079178958.js +1 -0
  56. package/assets/esri/core/workers/chunks/e076c5523dfb6c53a825.js +1 -0
  57. package/assets/esri/core/workers/chunks/e12090768e945091cc5d.js +1 -0
  58. package/assets/esri/core/workers/chunks/e3950975030412ff6e20.js +1 -0
  59. package/assets/esri/core/workers/chunks/e8b7d1c586aff229484c.js +1 -0
  60. package/assets/esri/core/workers/chunks/{710a6268de62003af825.js → e8d1f91dc97b42d0c4f6.js} +1 -1
  61. package/assets/esri/core/workers/chunks/{6747503826bfc94bc6c0.js → eb5213ffb83d83a4dd05.js} +1 -1
  62. package/assets/esri/core/workers/chunks/{eea0fb90cd5cc80de388.js → fa750885bb27bbb03e7d.js} +1 -1
  63. package/assets/esri/core/workers/chunks/{e67c4b7ad06d8404895a.js → fab4ee57b7c5376c9ccd.js} +1 -1
  64. package/core/date.js +1 -1
  65. package/interfaces.d.ts +4 -4
  66. package/kernel.js +1 -1
  67. package/layers/StreamLayer.js +1 -1
  68. package/layers/graphics/data/QueryEngineResult.js +1 -1
  69. package/layers/graphics/sources/geojson/geojson.js +1 -1
  70. package/layers/support/RangeDomain.js +1 -1
  71. package/layers/support/domainUtils.js +1 -1
  72. package/layers/support/fieldUtils.js +1 -1
  73. package/layers/support/labelFormatUtils.js +1 -1
  74. package/package.json +1 -1
  75. package/support/revision.js +1 -1
  76. package/views/2d/engine/webgl/Painter.js +1 -1
  77. package/views/3d/layers/graphics/elevationAlignPointsInFeatures.js +1 -1
  78. package/views/3d/layers/i3s/I3SIndex.js +1 -1
  79. package/views/PopupView.js +1 -1
  80. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorker.js +1 -1
  81. package/views/interactive/snapping/featureSources/snappingCandidateElevationAlignment.js +1 -1
  82. package/widgets/FeatureForm/FieldInput.js +1 -1
  83. package/widgets/FeatureForm/featureFormUtils.js +1 -1
  84. package/widgets/FeatureForm.js +1 -1
  85. package/widgets/Features.js +1 -1
  86. package/widgets/Legend/LegendViewModel.js +1 -1
  87. package/widgets/Popup.js +1 -1
  88. package/widgets/support/dataUtils.js +5 -0
  89. package/widgets/support/dateUtils.js +1 -1
  90. package/assets/esri/core/workers/chunks/020825b9c12f2b6386a7.js +0 -1
  91. package/assets/esri/core/workers/chunks/02d235849ba93541d7ad.js +0 -1
  92. package/assets/esri/core/workers/chunks/0a3da4b73beeaacd4667.js +0 -1
  93. package/assets/esri/core/workers/chunks/10dc578a90e1194c8720.js +0 -1
  94. package/assets/esri/core/workers/chunks/1eb5468c7cf653338d53.js +0 -1
  95. package/assets/esri/core/workers/chunks/1f30ea1a598ddd2e5df3.js +0 -1
  96. package/assets/esri/core/workers/chunks/2304b7456ced997904f6.js +0 -1
  97. package/assets/esri/core/workers/chunks/366cf9bba6989342e447.js +0 -1
  98. package/assets/esri/core/workers/chunks/43f7d9366d06d69e7c50.js +0 -1
  99. package/assets/esri/core/workers/chunks/4672504d6fe649da19f2.js +0 -1
  100. package/assets/esri/core/workers/chunks/56a61a8bff08ae273de4.js +0 -1
  101. package/assets/esri/core/workers/chunks/580e7d3cbf6797a50ded.js +0 -1
  102. package/assets/esri/core/workers/chunks/6046be598e8c673eeb1f.js +0 -1
  103. package/assets/esri/core/workers/chunks/6334a8a7b671d4042108.js +0 -1
  104. package/assets/esri/core/workers/chunks/69c1c850af7ee33258e0.js +0 -1
  105. package/assets/esri/core/workers/chunks/6bc1f6f8a2408fa4bb6a.js +0 -1
  106. package/assets/esri/core/workers/chunks/8f7997e8e6ee9e56239f.js +0 -1
  107. package/assets/esri/core/workers/chunks/a160576f21ada91995ac.js +0 -1
  108. package/assets/esri/core/workers/chunks/a50ec5b647a160199cb2.js +0 -1
  109. package/assets/esri/core/workers/chunks/abcfe3bda6f40318b092.js +0 -1
  110. package/assets/esri/core/workers/chunks/b138196d304883efd5f6.js +0 -1
  111. package/assets/esri/core/workers/chunks/b3f5e97b47e896c6008a.js +0 -1
  112. package/assets/esri/core/workers/chunks/c447f4bf0e5f012f8f9b.js +0 -1
  113. package/assets/esri/core/workers/chunks/c87e9280681c20d042b5.js +0 -1
  114. package/assets/esri/core/workers/chunks/cc86c8c88124d916e1b3.js +0 -1
  115. package/assets/esri/core/workers/chunks/d878bb6409df183ea0ce.js +0 -1
  116. package/assets/esri/core/workers/chunks/ef757269fb3fe0e74ef8.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../core/Error.js";import{getDeepValue as n,setDeepValue as i}from"../../core/object.js";import{union as t}from"../../core/SetUtils.js";import{parseWhereClause as r}from"../../core/sql.js";import{validateDomainValue as l,getDomainRange as o,DomainValidationError as s}from"./domainUtils.js";import{loadArcade as a}from"../../support/arcadeOnDemand.js";const u=/^([0-9_])/,f=/[^a-z0-9_\u0080-\uffff]+/gi;function d(e){if(null==e)return null;return e.trim().replaceAll(f,"_").replace(u,"F$1")||null}const c=["field","field2","field3","normalizationField","rotationInfo.field","proportionalSymbolInfo.field","proportionalSymbolInfo.normalizationField","colorInfo.field","colorInfo.normalizationField"],p=["field","normalizationField"];function m(e,n){if(null!=e&&null!=n)for(const i of Array.isArray(e)?e:[e])if(y(c,i,n),"visualVariables"in i&&i.visualVariables)for(const e of i.visualVariables)y(p,e,n)}function y(e,t,r){if(e)for(const l of e){const e=n(l,t),o=e&&"function"!=typeof e&&r.get(e);o&&i(l,o.name,t)}}function g(e,n){if(null!=e&&n?.fields?.length)if("startField"in e){const i=n.get(e.startField),t=n.get(e.endField);e.startField=i?.name??null,e.endField=t?.name??null}else{const i=n.get(e.startTimeField),t=n.get(e.endTimeField);e.startTimeField=i?.name??null,e.endTimeField=t?.name??null}}const F=new Set;function I(e,n){return e&&n?(F.clear(),b(F,e,n),Array.from(F).sort()):[]}function b(e,n,i){if(i)if(n?.fields?.length)if(i.includes("*"))for(const{name:t}of n.fields)e.add(t);else for(const t of i)T(e,n,t);else{if(i.includes("*"))return e.clear(),void e.add("*");for(const n of i)null!=n&&e.add(n)}}function T(e,n,i){if("string"==typeof i)if(n){const t=n.get(i);t&&e.add(t.name)}else e.add(i)}function x(e,n){return null==n||null==e?[]:n.includes("*")?(e.fields??[]).map((e=>e.name)):n}function w(e,n,i=1){if(!n||!e)return[];if(n.includes("*"))return["*"];const t=I(e,n);return t.length/e.fields.length>=i?["*"]:t}async function h(e,n,i){if(!i)return;const{arcadeUtils:t}=await a(),r=t.extractFieldNames(i,n?.fields?.map((e=>e.name)));for(const l of r)T(e,n,l)}async function _(n,i,t){if(t&&"1=1"!==t){const l=await r(t,i);if(!l.isStandardized)throw new e("fieldUtils:collectFilterFields","Where clause is not standardized",{where:t});b(n,i,l.fieldNames)}}function E({displayField:e,fields:n}){return e||(n?.length?v(n,"name-or-title")||v(n,"unique-identifier")||v(n,"type-or-category")||S(n):null)}function S(e){for(const n of e){if(!n?.name)continue;const e=n.name.toLowerCase();if(e.includes("name")||e.includes("title"))return n.name}return null}function v(e,n){for(const i of e)if(i?.valueType&&i.valueType===n)return i.name;return null}async function A(e){if(!e)return[];const n=new Set;return await N(n,e),Array.from(n).sort()}async function N(e,n){if(!n)return;const i=n.elevationInfo?.featureExpressionInfo;return i?i.collectRequiredFields(e,n.fieldsIndex):void 0}function $(e,n,i){i.onStatisticExpression?h(e,n,i.onStatisticExpression.expression):e.add(i.onStatisticField)}async function D(e,n,i){if(!n||!i||!("fields"in i))return;const t=[],r=i.popupTemplate;t.push(L(e,n,r)),i.fields&&t.push(...i.fields.map((async i=>$(e,n.fieldsIndex,i)))),await Promise.all(t)}async function L(e,n,i){const t=[];i?.expressionInfos&&t.push(...i.expressionInfos.map((i=>h(e,n.fieldsIndex,i.expression))));const r=i?.content;if(Array.isArray(r))for(const l of r)"expression"===l.type&&l.expressionInfo&&t.push(h(e,n.fieldsIndex,l.expressionInfo.expression));await Promise.all(t)}async function O(e,n,i){n&&(n.timeInfo&&i?.timeExtent&&b(e,n.fieldsIndex,[n.timeInfo.startField,n.timeInfo.endField]),n.floorInfo&&b(e,n.fieldsIndex,[n.floorInfo.floorField]),null!=i?.where&&await _(e,n.fieldsIndex,i.where))}async function V(e,n,i){n&&i&&await Promise.all(i.map((i=>j(e,n,i))))}async function j(e,n,i){n&&i&&(i.valueExpression?await h(e,n.fieldsIndex,i.valueExpression):i.field&&T(e,n.fieldsIndex,i.field))}async function U(e){if(!e)return[];const n="timeInfo"in e&&e.timeInfo;return n?I(e.fieldsIndex,[e.trackIdField,n.startField,n.endField]):[]}function C(e){return e?I(e.fieldsIndex,B(e)):[]}function R(e){if(!e)return[];const n=e.geometryFieldsInfo;return n?I(e.fieldsIndex,[n.shapeAreaField,n.shapeLengthField]):[]}const k=new Set(["oid","global-id","guid"]),z=new Set(["oid","global-id"]),G=[/^fnode_$/i,/^tnode_$/i,/^lpoly_$/i,/^rpoly_$/i,/^poly_$/i,/^subclass$/i,/^subclass_$/i,/^rings_ok$/i,/^rings_nok$/i,/shape/i,/perimeter/i,/objectid/i,/_i$/i];function P(e){const n=new Set;M(e).forEach((e=>n.add(e))),R(e).forEach((e=>n.add(e.toLowerCase())));const i=e&&"infoFor3D"in e?e.infoFor3D:void 0;return i&&(Object.values(i.assetMapFieldRoles).forEach((e=>n.add(e.toLowerCase()))),Object.values(i.transformFieldRoles).forEach((e=>n.add(e.toLowerCase())))),Array.from(n)}function B(e){if(!e)return[];const n="editFieldsInfo"in e&&e.editFieldsInfo;if(!n)return[];const{creationDateField:i,creatorField:t,editDateField:r,editorField:l}=n;return[i,t,r,l].filter(Boolean)}function M(e){return B(e).map((e=>e.toLowerCase()))}function X(e,n){return e.editable&&!k.has(e.type)&&!M(n).includes(e.name?.toLowerCase()??"")}function q(e,n){const i=e.name?.toLowerCase()??"";return!(null!=n?.objectIdField&&i===n.objectIdField.toLowerCase()||null!=n?.globalIdField&&i===n.globalIdField.toLowerCase()||P(n).includes(i)||z.has(e.type)||G.some((e=>e.test(i))))}async function Y(e){if(!e)return[];const n=new Set;return await J(n,e),Array.from(n).sort()}async function J(e,n){const{labelingInfo:i,fieldsIndex:t}=n;i?.length&&await Promise.all(i.map((n=>W(e,t,n))))}async function W(e,n,i){if(!i)return;const t=i.getLabelExpression(),r=i.where;if("arcade"===t.type)await h(e,n,t.expression);else{const i=t.expression.match(/{[^}]*}/g);i&&i.forEach((i=>{T(e,n,i.slice(1,-1))}))}await _(e,n,r)}function H(e){const n=e.defaultValue;return void 0!==n&&re(e,n)?n:e.nullable?null:void 0}function K(e){const n="string"==typeof e?{type:e}:e;return ye(n)?255:"esriFieldTypeDate"===n.type||"date"===n.type?8:void 0}function Q(e){return"number"==typeof e&&!isNaN(e)&&isFinite(e)}function Z(e){return null===e||Q(e)}function ee(e){return null===e||Number.isInteger(e)}function ne(e){return null!=e&&"string"==typeof e}function ie(e){return null===e||ne(e)}function te(){return!0}function re(e,n){let i;switch(e.type){case"date":case"integer":case"long":case"small-integer":case"big-integer":case"esriFieldTypeDate":case"esriFieldTypeInteger":case"esriFieldTypeLong":case"esriFieldTypeSmallInteger":case"esriFieldTypeBigInteger":i=e.nullable?ee:Number.isInteger;break;case"double":case"single":case"esriFieldTypeSingle":case"esriFieldTypeDouble":i=e.nullable?Z:Q;break;case"string":case"esriFieldTypeString":i=e.nullable?ie:ne;break;default:i=te}return 1===arguments.length?i:i(n)}const le=["integer","small-integer","big-integer"],oe=["single","double"],se=[...le,...oe],ae=["esriFieldTypeInteger","esriFieldTypeSmallInteger","esriFieldTypeBigInteger"],ue=["esriFieldTypeSingle","esriFieldTypeDouble"],fe=new Set([...le,...ae]),de=new Set([...oe,...ue]),ce=t(fe,de);function pe(e){return null!=e&&fe.has(e.type)}function me(e){return null!=e&&ce.has(e.type)}function ye(e){return null!=e&&("string"===e.type||"esriFieldTypeString"===e.type)}function ge(e){return null!=e&&("date"===e.type||"esriFieldTypeDate"===e.type)}function Fe(e){return null!=e&&("date-only"===e.type||"esriFieldTypeDateOnly"===e.type)}function Ie(e){return null!=e&&("timestamp-offset"===e.type||"esriFieldTypeTimestampOffset"===e.type)}function be(e){return null!=e&&("time-only"===e.type||"esriFieldTypeTimeOnly"===e.type)}function Te(e){return null!=e&&("oid"===e.type||"esriFieldTypeOID"===e.type)}function xe(e){return null!=e&&("global-id"===e.type||"esriFieldTypeGlobalID"===e.type)}function we(e,n){return null===Se(e,n)}var he,_e;function Ee(e){return null==e||"number"==typeof e&&isNaN(e)?null:e}function Se(e,n){return null==e||e.nullable&&null===n?null:me(e)&&!ve(e.type,Number(n))?he.OUT_OF_RANGE:re(e,n)?e.domain?l(e.domain,n):null:_e.INVALID_TYPE}function ve(e,n){const i="string"==typeof e?Ne(e):e;if(!i)return!1;const t=i.min,r=i.max;return i.isInteger?Number.isInteger(n)&&n>=t&&n<=r:n>=t&&n<=r}function Ae(e){const n=o(e.domain);return n||(me(e)?Ne(e.type):void 0)}function Ne(e){switch(e){case"esriFieldTypeSmallInteger":case"small-integer":return De;case"esriFieldTypeInteger":case"integer":return Le;case"esriFieldTypeBigInteger":case"big-integer":return Oe;case"esriFieldTypeSingle":case"single":return Ve;case"esriFieldTypeDouble":case"double":return je}}function $e(e){if(!Q(e))return null;if(Number.isInteger(e)){if(e>=De.min&&e<=De.max)return"esriFieldTypeSmallInteger";if(e>=Le.min&&e<=Le.max)return"esriFieldTypeInteger";if(e>=Oe.min&&e<=Oe.max)return"esriFieldTypeBigInteger"}return e>=Ve.min&&e<=Ve.max?"esriFieldTypeSingle":"esriFieldTypeDouble"}!function(e){e.OUT_OF_RANGE="numeric-range-validation-error::out-of-range"}(he||(he={})),function(e){e.INVALID_TYPE="type-validation-error::invalid-type"}(_e||(_e={}));const De={min:-32768,max:32767,isInteger:!0},Le={min:-2147483648,max:2147483647,isInteger:!0},Oe={min:-Number.MAX_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,isInteger:!0},Ve={min:-34e37,max:12e37,isInteger:!1},je={min:-Number.MAX_VALUE,max:Number.MAX_VALUE,isInteger:!1};function Ue(e,n,i){switch(e){case s.INVALID_CODED_VALUE:return`Value ${i} is not in the coded domain - field: ${n.name}, domain: ${JSON.stringify(n.domain)}`;case s.VALUE_OUT_OF_RANGE:return`Value ${i} is out of the range of valid values - field: ${n.name}, domain: ${JSON.stringify(n.domain)}`;case _e.INVALID_TYPE:return`Value ${i} is not a valid value for the field type - field: ${n.name}, type: ${n.type}, nullable: ${n.nullable}`;case he.OUT_OF_RANGE:{const{min:e,max:t}=Ne(n.type);return`Value ${i} is out of range for the number type - field: ${n.name}, type: ${n.type}, value range is ${e} to ${t}`}}}function Ce(e,n){return!Re(e,n,null)}function Re(e,n,i){if(!n?.attributes||!e){if(null!=i)for(const n of e??[])i.add(n);return!0}const t=new Set(Object.keys(n.attributes));let r=!1;for(const l of e)if(!t.has(l)){if(r=!0,null==i)break;i.add(l)}return r}async function ke(e,n){const i=new Set;for(const t of n)await h(i,e.fieldsIndex,t);return Array.from(i).sort()}function ze(e){return!!e&&["raster.itempixelvalue","raster.servicepixelvalue"].some((n=>e.toLowerCase().startsWith(n)))}export{he as NumericRangeValidationError,_e as TypeValidationError,Oe as bigIntegerRange,h as collectArcadeFieldNames,N as collectElevationFields,D as collectFeatureReductionFields,T as collectField,b as collectFields,O as collectFilterFields,J as collectLabelingFields,V as collectOrderByInfos,L as collectPopupTemplateFields,je as doubleRange,Ce as featureHasFields,I as fixFields,m as fixRendererFields,g as fixTimeInfoFields,ue as floatJSONTypes,oe as floatTypes,E as getDisplayFieldName,B as getEditTrackingFields,A as getElevationFields,ke as getExpressionFields,C as getFeatureEditFields,R as getFeatureGeometryFields,K as getFieldDefaultLength,H as getFieldDefaultValue,Ae as getFieldRange,Y as getLabelingFields,P as getLowerCaseDefaultHiddenFields,M as getLowerCaseEditTrackingFields,$e as getNumericTypeForValue,U as getTimeFields,ae as integerJSONTypes,Le as integerRange,le as integerTypes,ge as isDateField,Fe as isDateOnlyField,X as isFieldEditable,q as isFieldVisibleByDefault,xe as isGlobalIDField,pe as isIntegerField,ve as isNumberInRange,me as isNumericField,Te as isObjectIDField,ze as isRasterPixelValueField,ye as isStringField,be as isTimeOnlyField,Ie as isTimestampOffsetField,we as isValidFieldValue,re as isValueMatchingFieldType,d as normalizeFieldName,se as numericTypes,w as packFields,Re as populateMissingFields,c as rendererFields,Ee as sanitizeNullFieldValue,Ve as singleRange,De as smallIntegerRange,x as unpackFieldNames,Se as validateFieldValue,Ue as validationErrorToString,p as visualVariableFields};
5
+ import e from"../../core/Error.js";import{getDeepValue as n,setDeepValue as i}from"../../core/object.js";import{union as t}from"../../core/SetUtils.js";import{parseWhereClause as r}from"../../core/sql.js";import{validateDomainValue as l,getDomainRange as o,DomainValidationError as s}from"./domainUtils.js";import{loadArcade as a}from"../../support/arcadeOnDemand.js";const u=/^([0-9_])/,f=/[^a-z0-9_\u0080-\uffff]+/gi;function d(e){if(null==e)return null;return e.trim().replaceAll(f,"_").replace(u,"F$1")||null}const c=["field","field2","field3","normalizationField","rotationInfo.field","proportionalSymbolInfo.field","proportionalSymbolInfo.normalizationField","colorInfo.field","colorInfo.normalizationField"],m=["field","normalizationField"];function p(e,n){if(null!=e&&null!=n)for(const i of Array.isArray(e)?e:[e])if(y(c,i,n),"visualVariables"in i&&i.visualVariables)for(const e of i.visualVariables)y(m,e,n)}function y(e,t,r){if(e)for(const l of e){const e=n(l,t),o=e&&"function"!=typeof e&&r.get(e);o&&i(l,o.name,t)}}function g(e,n){if(null!=e&&n?.fields?.length)if("startField"in e){const i=n.get(e.startField),t=n.get(e.endField);e.startField=i?.name??null,e.endField=t?.name??null}else{const i=n.get(e.startTimeField),t=n.get(e.endTimeField);e.startTimeField=i?.name??null,e.endTimeField=t?.name??null}}const F=new Set;function I(e,n){return e&&n?(F.clear(),b(F,e,n),Array.from(F).sort()):[]}function b(e,n,i){if(i)if(n?.fields?.length)if(i.includes("*"))for(const{name:t}of n.fields)e.add(t);else for(const t of i)w(e,n,t);else{if(i.includes("*"))return e.clear(),void e.add("*");for(const n of i)null!=n&&e.add(n)}}function w(e,n,i){if("string"==typeof i)if(n){const t=n.get(i);t&&e.add(t.name)}else e.add(i)}function x(e,n){return null==n||null==e?[]:n.includes("*")?(e.fields??[]).map((e=>e.name)):n}function T(e,n,i=1){if(!n||!e)return[];if(n.includes("*"))return["*"];const t=I(e,n);return t.length/e.fields.length>=i?["*"]:t}async function h(e,n,i){if(!i)return;const{arcadeUtils:t}=await a(),r=t.extractFieldNames(i,n?.fields?.map((e=>e.name)));for(const l of r)w(e,n,l)}async function E(n,i,t){if(t&&"1=1"!==t){const l=await r(t,i);if(!l.isStandardized)throw new e("fieldUtils:collectFilterFields","Where clause is not standardized",{where:t});b(n,i,l.fieldNames)}}function _({displayField:e,fields:n}){return e||(n?.length?N(n,"name-or-title")||N(n,"unique-identifier")||N(n,"type-or-category")||A(n):null)}function A(e){for(const n of e){if(!n?.name)continue;const e=n.name.toLowerCase();if(e.includes("name")||e.includes("title"))return n.name}return null}function N(e,n){for(const i of e)if(i?.valueType&&i.valueType===n)return i.name;return null}async function S(e){if(!e)return[];const n=new Set;return await v(n,e),Array.from(n).sort()}async function v(e,n){if(!n)return;const i=n.elevationInfo?.featureExpressionInfo;return i?i.collectRequiredFields(e,n.fieldsIndex):void 0}function $(e,n,i){i.onStatisticExpression?h(e,n,i.onStatisticExpression.expression):e.add(i.onStatisticField)}async function L(e,n,i){if(!n||!i||!("fields"in i))return;const t=[],r=i.popupTemplate;t.push(D(e,n,r)),i.fields&&t.push(...i.fields.map((async i=>$(e,n.fieldsIndex,i)))),await Promise.all(t)}async function D(e,n,i){const t=[];i?.expressionInfos&&t.push(...i.expressionInfos.map((i=>h(e,n.fieldsIndex,i.expression))));const r=i?.content;if(Array.isArray(r))for(const l of r)"expression"===l.type&&l.expressionInfo&&t.push(h(e,n.fieldsIndex,l.expressionInfo.expression));await Promise.all(t)}async function M(e,n,i){n&&(n.timeInfo&&i?.timeExtent&&b(e,n.fieldsIndex,[n.timeInfo.startField,n.timeInfo.endField]),n.floorInfo&&b(e,n.fieldsIndex,[n.floorInfo.floorField]),null!=i?.where&&await E(e,n.fieldsIndex,i.where))}async function O(e,n,i){n&&i&&await Promise.all(i.map((i=>V(e,n,i))))}async function V(e,n,i){n&&i&&(i.valueExpression?await h(e,n.fieldsIndex,i.valueExpression):i.field&&w(e,n.fieldsIndex,i.field))}async function U(e){if(!e)return[];const n="timeInfo"in e&&e.timeInfo;return n?I(e.fieldsIndex,[e.trackIdField,n.startField,n.endField]):[]}function j(e){return e?I(e.fieldsIndex,z(e)):[]}function C(e){if(!e)return[];const n=e.geometryFieldsInfo;return n?I(e.fieldsIndex,[n.shapeAreaField,n.shapeLengthField]):[]}const R=new Set(["oid","global-id","guid"]),G=new Set(["oid","global-id"]),k=[/^fnode_$/i,/^tnode_$/i,/^lpoly_$/i,/^rpoly_$/i,/^poly_$/i,/^subclass$/i,/^subclass_$/i,/^rings_ok$/i,/^rings_nok$/i,/shape/i,/perimeter/i,/objectid/i,/_i$/i];function X(e){const n=new Set;P(e).forEach((e=>n.add(e))),C(e).forEach((e=>n.add(e.toLowerCase())));const i=e&&"infoFor3D"in e?e.infoFor3D:void 0;return i&&(Object.values(i.assetMapFieldRoles).forEach((e=>n.add(e.toLowerCase()))),Object.values(i.transformFieldRoles).forEach((e=>n.add(e.toLowerCase())))),Array.from(n)}function z(e){if(!e)return[];const n="editFieldsInfo"in e&&e.editFieldsInfo;if(!n)return[];const{creationDateField:i,creatorField:t,editDateField:r,editorField:l}=n;return[i,t,r,l].filter(Boolean)}function P(e){return z(e).map((e=>e.toLowerCase()))}function B(e,n){return e.editable&&!R.has(e.type)&&!P(n).includes(e.name?.toLowerCase()??"")}function q(e,n){const i=e.name?.toLowerCase()??"";return!(null!=n?.objectIdField&&i===n.objectIdField.toLowerCase()||null!=n?.globalIdField&&i===n.globalIdField.toLowerCase()||X(n).includes(i)||G.has(e.type)||k.some((e=>e.test(i))))}async function Y(e){if(!e)return[];const n=new Set;return await J(n,e),Array.from(n).sort()}async function J(e,n){const{labelingInfo:i,fieldsIndex:t}=n;i?.length&&await Promise.all(i.map((n=>W(e,t,n))))}async function W(e,n,i){if(!i)return;const t=i.getLabelExpression(),r=i.where;if("arcade"===t.type)await h(e,n,t.expression);else{const i=t.expression.match(/{[^}]*}/g);i&&i.forEach((i=>{w(e,n,i.slice(1,-1))}))}await E(e,n,r)}function H(e){const n=e.defaultValue;return void 0!==n&&re(e,n)?n:e.nullable?null:void 0}function K(e){const n="string"==typeof e?{type:e}:e;return ye(n)?255:"esriFieldTypeDate"===n.type||"date"===n.type?8:void 0}function Q(e){return"number"==typeof e&&!isNaN(e)&&isFinite(e)}function Z(e){return null===e||Q(e)}function ee(e){return null===e||Number.isInteger(e)}function ne(e){return null!=e&&"string"==typeof e}function ie(e){return null===e||ne(e)}function te(){return!0}function re(e,n){let i;switch(e.type){case"date":case"integer":case"long":case"small-integer":case"big-integer":case"esriFieldTypeDate":case"esriFieldTypeInteger":case"esriFieldTypeLong":case"esriFieldTypeSmallInteger":case"esriFieldTypeBigInteger":i=e.nullable?ee:Number.isInteger;break;case"double":case"single":case"esriFieldTypeSingle":case"esriFieldTypeDouble":i=e.nullable?Z:Q;break;case"string":case"esriFieldTypeString":i=e.nullable?ie:ne;break;default:i=te}return 1===arguments.length?i:i(n)}const le=["integer","small-integer","big-integer"],oe=["single","double"],se=[...le,...oe],ae=["esriFieldTypeInteger","esriFieldTypeSmallInteger","esriFieldTypeBigInteger"],ue=["esriFieldTypeSingle","esriFieldTypeDouble"],fe=new Set([...le,...ae]),de=new Set([...oe,...ue]),ce=t(fe,de);function me(e){return null!=e&&fe.has(e.type)}function pe(e){return null!=e&&ce.has(e.type)}function ye(e){return null!=e&&("string"===e.type||"esriFieldTypeString"===e.type)}function ge(e){return null!=e&&("date"===e.type||"esriFieldTypeDate"===e.type)}function Fe(e){return null!=e&&("date-only"===e.type||"esriFieldTypeDateOnly"===e.type)}function Ie(e){return null!=e&&("timestamp-offset"===e.type||"esriFieldTypeTimestampOffset"===e.type)}function be(e){return null!=e&&("time-only"===e.type||"esriFieldTypeTimeOnly"===e.type)}function we(e){return null!=e&&("oid"===e.type||"esriFieldTypeOID"===e.type)}function xe(e){return null!=e&&("global-id"===e.type||"esriFieldTypeGlobalID"===e.type)}function Te(e,n){return null===Ae(e,n)}var he,Ee;function _e(e){return null==e||"number"==typeof e&&isNaN(e)?null:e}function Ae(e,n){return null==e||e.nullable&&null===n?null:pe(e)&&!Ne(e.type,Number(n))?he.OUT_OF_RANGE:re(e,n)?e.domain?l(e,n):null:Ee.INVALID_TYPE}function Ne(e,n){const i="string"==typeof e?ve(e):e;if(!i)return!1;const t=i.min,r=i.max;return i.isInteger?Number.isInteger(n)&&n>=t&&n<=r:n>=t&&n<=r}function Se(e,n){const i=o(e,n);return i||(pe(e)?ve(e.type):void 0)}function ve(e){switch(e){case"esriFieldTypeSmallInteger":case"small-integer":return Le;case"esriFieldTypeInteger":case"integer":return De;case"esriFieldTypeBigInteger":case"big-integer":return Me;case"esriFieldTypeSingle":case"single":return Oe;case"esriFieldTypeDouble":case"double":return Ve}}function $e(e){if(!Q(e))return null;if(Number.isInteger(e)){if(e>=Le.min&&e<=Le.max)return"esriFieldTypeSmallInteger";if(e>=De.min&&e<=De.max)return"esriFieldTypeInteger";if(e>=Me.min&&e<=Me.max)return"esriFieldTypeBigInteger"}return e>=Oe.min&&e<=Oe.max?"esriFieldTypeSingle":"esriFieldTypeDouble"}!function(e){e.OUT_OF_RANGE="numeric-range-validation-error::out-of-range"}(he||(he={})),function(e){e.INVALID_TYPE="type-validation-error::invalid-type"}(Ee||(Ee={}));const Le={min:-32768,max:32767,isInteger:!0,rawMin:-32768,rawMax:32767},De={min:-2147483648,max:2147483647,isInteger:!0,rawMin:-2147483648,rawMax:2147483647},Me={min:-Number.MAX_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,isInteger:!0,rawMin:-Number.MAX_SAFE_INTEGER,rawMax:Number.MAX_SAFE_INTEGER},Oe={min:-34e37,max:12e37,isInteger:!1,rawMin:-34e37,rawMax:12e37},Ve={min:-Number.MAX_VALUE,max:Number.MAX_VALUE,isInteger:!1,rawMin:-Number.MAX_VALUE,rawMax:Number.MAX_VALUE};function Ue(e,n,i){switch(e){case s.INVALID_CODED_VALUE:return`Value ${i} is not in the coded domain - field: ${n.name}, domain: ${JSON.stringify(n.domain)}`;case s.VALUE_OUT_OF_RANGE:return`Value ${i} is out of the range of valid values - field: ${n.name}, domain: ${JSON.stringify(n.domain)}`;case Ee.INVALID_TYPE:return`Value ${i} is not a valid value for the field type - field: ${n.name}, type: ${n.type}, nullable: ${n.nullable}`;case he.OUT_OF_RANGE:{const{min:e,max:t}=ve(n.type);return`Value ${i} is out of range for the number type - field: ${n.name}, type: ${n.type}, value range is ${e} to ${t}`}}}function je(e,n){return!Ce(e,n,null)}function Ce(e,n,i){if(!n?.attributes||!e){if(null!=i)for(const n of e??[])i.add(n);return!0}const t=new Set(Object.keys(n.attributes));let r=!1;for(const l of e)if(!t.has(l)){if(r=!0,null==i)break;i.add(l)}return r}async function Re(e,n){const i=new Set;for(const t of n)await h(i,e.fieldsIndex,t);return Array.from(i).sort()}function Ge(e){return!!e&&["raster.itempixelvalue","raster.servicepixelvalue"].some((n=>e.toLowerCase().startsWith(n)))}export{he as NumericRangeValidationError,Ee as TypeValidationError,Me as bigIntegerRange,h as collectArcadeFieldNames,v as collectElevationFields,L as collectFeatureReductionFields,w as collectField,b as collectFields,M as collectFilterFields,J as collectLabelingFields,O as collectOrderByInfos,D as collectPopupTemplateFields,Ve as doubleRange,je as featureHasFields,I as fixFields,p as fixRendererFields,g as fixTimeInfoFields,ue as floatJSONTypes,oe as floatTypes,_ as getDisplayFieldName,z as getEditTrackingFields,S as getElevationFields,Re as getExpressionFields,j as getFeatureEditFields,C as getFeatureGeometryFields,K as getFieldDefaultLength,H as getFieldDefaultValue,Se as getFieldRange,Y as getLabelingFields,X as getLowerCaseDefaultHiddenFields,P as getLowerCaseEditTrackingFields,$e as getNumericTypeForValue,U as getTimeFields,ae as integerJSONTypes,De as integerRange,le as integerTypes,ge as isDateField,Fe as isDateOnlyField,B as isFieldEditable,q as isFieldVisibleByDefault,xe as isGlobalIDField,me as isIntegerField,Ne as isNumberInRange,pe as isNumericField,we as isObjectIDField,Ge as isRasterPixelValueField,ye as isStringField,be as isTimeOnlyField,Ie as isTimestampOffsetField,Te as isValidFieldValue,re as isValueMatchingFieldType,d as normalizeFieldName,se as numericTypes,T as packFields,Ce as populateMissingFields,c as rendererFields,_e as sanitizeNullFieldValue,Oe as singleRange,Le as smallIntegerRange,x as unpackFieldNames,Ae as validateFieldValue,Ue as validationErrorToString,m as visualVariableFields};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../core/Error.js";import r from"../../core/Logger.js";import{parseWhereClause as t}from"../../core/sql.js";import{formatDate as n,convertDateFormatToIntlOptions as a}from"../../intl/date.js";import{formatNumber as o}from"../../intl/number.js";import{isDateField as i,isNumericField as l}from"./fieldUtils.js";import{getLabelExpression as u,getSingleFieldArcadeExpression as s}from"./labelUtils.js";import{createLabelExpression as c}from"../../support/arcadeOnDemand.js";const f=r.getLogger("esri.layers.support.labelFormatUtils"),m={type:"simple",evaluate:()=>null},p={getAttribute:(e,r)=>e.field(r)};async function d(r,n,a){if(!r||!r.symbol||!n)return m;const o=r.where,i=u(r);let l;if("arcade"===i.type){const r=await c(i.expression,a,n);if(null==r)return m;l={type:"arcade",evaluate(t,n){try{const e="attributes"in t?r.repurposeFeature(t):t;e.contextTimeZone=n??null;const a=r.evaluate({$view:{timeZone:n},$feature:e},r.services);if(null!=a)return a.toString()}catch(a){f.error(new e("arcade-expression-error","Encountered an error when evaluating label expression for feature",{error:a,feature:t,expression:i}))}return null},needsHydrationToEvaluate:()=>null==s(i.expression)}}else l={type:"simple",evaluate:e=>i.expression.replaceAll(/{[^}]*}/g,(r=>{const t=r.slice(1,-1),a=n.get(t);if(!a)return r;let o=null;if("attributes"in e){e&&e.attributes&&(o=e.attributes[a.name])}else o=e.field(a.name);return null==o?"":g(o,a)}))};if(o){let r;try{r=await t(o,n)}catch(d){return f.error(new e("bad-where-clause","Encountered an error when evaluating where clause, ignoring",{where:o,error:d})),m}const a=l.evaluate;l.evaluate=(t,n)=>{const i="attributes"in t?void 0:p;try{if(r.testFeature(t,i))return a(t,n)}catch(d){f.error(new e("bad-where-clause","Encountered an error when evaluating where clause for feature",{where:o,feature:t,error:d}))}return null}}return l}function g(e,r){if(null==e)return"";const t=r.domain;if(t)if("codedValue"===t.type||"coded-value"===t.type){const r=e;for(const e of t.codedValues)if(e.code===r)return e.name}else if("range"===t.type){const r=+e,n="range"in t?t.range[0]:t.minValue,a="range"in t?t.range[1]:t.maxValue;if(n<=r&&r<=a)return t.name}let u=e;return i(r)?u=n(u,a("short-date")):l(r)&&(u=o(+u)),u||""}export{d as createLabelFunction,g as formatField};
5
+ import e from"../../core/Error.js";import r from"../../core/Logger.js";import{parseWhereClause as t}from"../../core/sql.js";import{formatDate as n,convertDateFormatToIntlOptions as o}from"../../intl/date.js";import{formatNumber as a}from"../../intl/number.js";import{getDomainRange as l}from"./domainUtils.js";import{isDateField as i,isNumericField as s}from"./fieldUtils.js";import{getLabelExpression as u,getSingleFieldArcadeExpression as c}from"./labelUtils.js";import{createLabelExpression as f}from"../../support/arcadeOnDemand.js";const m=r.getLogger("esri.layers.support.labelFormatUtils"),p={type:"simple",evaluate:()=>null},d={getAttribute:(e,r)=>e.field(r)};async function w(r,n,o){if(!r||!r.symbol||!n)return p;const a=r.where,l=u(r);let i;if("arcade"===l.type){const r=await f(l.expression,o,n);if(null==r)return p;i={type:"arcade",evaluate(t,n){try{const e="attributes"in t?r.repurposeFeature(t):t;e.contextTimeZone=n??null;const o=r.evaluate({$view:{timeZone:n},$feature:e},r.services);if(null!=o)return o.toString()}catch(o){m.error(new e("arcade-expression-error","Encountered an error when evaluating label expression for feature",{error:o,feature:t,expression:l}))}return null},needsHydrationToEvaluate:()=>null==c(l.expression)}}else i={type:"simple",evaluate:e=>l.expression.replaceAll(/{[^}]*}/g,(r=>{const t=r.slice(1,-1),o=n.get(t);if(!o)return r;let a=null;if("attributes"in e){e&&e.attributes&&(a=e.attributes[o.name])}else a=e.field(o.name);return null==a?"":g(a,o)}))};if(a){let r;try{r=await t(a,n)}catch(s){return m.error(new e("bad-where-clause","Encountered an error when evaluating where clause, ignoring",{where:a,error:s})),p}const o=i.evaluate;i.evaluate=(t,n)=>{const l="attributes"in t?void 0:d;try{if(r.testFeature(t,l))return o(t,n)}catch(s){m.error(new e("bad-where-clause","Encountered an error when evaluating where clause for feature",{where:a,feature:t,error:s}))}return null}}return i}function g(e,r){if(null==e)return"";const t=r.domain;if(t)if("codedValue"===t.type||"coded-value"===t.type){const r=e;for(const e of t.codedValues)if(e.code===r)return e.name}else if("range"===t.type){const{max:n,min:o}=l(r),a=+e;if(null!=o&&null!=n&&o<=a&&a<=n)return t.name}let u=e;return i(r)?u=n(u,o("short-date")):s(r)&&(u=a(+u)),u||""}export{w as createLabelFunction,g as formatField};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/core",
3
- "version": "4.28.2",
3
+ "version": "4.28.4",
4
4
  "homepage": "https://js.arcgis.com",
5
5
  "description": "ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API",
6
6
  "keywords": [
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- const c="20231026",e="312082a124d0009833f072034bebec075f541acc";export{c as buildDate,e as commitHash};
5
+ const c="20231030",b="3a1dbcf6ca66ff827c68b22ba716b8223f3d53ec";export{c as buildDate,b as commitHash};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../core/has.js";import{disposeMaybe as e}from"../../../../core/maybe.js";import{brushes as t}from"../brushes.js";import s from"../vectorTiles/shaders/VTLMaterialManager.js";import{BitBlitRenderer as r}from"./BitBlitRenderer.js";import{WGLDrawPhase as i,WGLGeometryType as n,WGLSymbologyType as o}from"./enums.js";import a from"./MaterialManager.js";import f from"./TextureManager.js";import{TextureUploadManager as h}from"./TextureUploadManager.js";import{WorldExtentRenderer as l}from"./WorldExtentClipRenderer.js";import{AnimationEffect as c}from"./effects/AnimationEffect.js";import{BlendEffect as d}from"./effects/BlendEffect.js";import{FeatureEffect as u}from"./effects/FeatureEffect.js";import _ from"./effects/HighlightEffect.js";import{HittestEffect as b}from"./effects/HittestEffect.js";import{HittestEffectVTL as p}from"./effects/HittestEffectVTL.js";import{EffectManager as E}from"./effects/post-processing/EffectManager.js";import g from"./painter/RenderPass.js";import{ContextType as m}from"../../../webgl/contextUtils.js";import{TextureSamplingMode as w,TextureWrapMode as M,CompareFunction as B,BlendFactor as F,RenderbufferFormat as T}from"../../../webgl/enums.js";import{FramebufferObject as C}from"../../../webgl/FramebufferObject.js";import{Renderbuffer as R}from"../../../webgl/Renderbuffer.js";import{RenderbufferDescriptor as P}from"../../../webgl/RenderbufferDescriptor.js";import{TextureDescriptor as O}from"../../../webgl/TextureDescriptor.js";function j(e,s){switch(e){case n.LINE:return t.line;case n.TEXT:return t.text;case n.LABEL:return t.label;case n.FILL:return s===o.DOT_DENSITY?t.dotDensity:t.fill;case n.MARKER:switch(s){case o.HEATMAP:return t.heatmap;case o.PIE_CHART:return t.pieChart;default:return t.marker}}}class x{constructor(e,t,i){this.context=e,this._blitRenderer=new r,this._worldExtentRenderer=new l,this._brushCache=new Map,this._lastWidth=null,this._lastHeight=null,this._vtlMaterialManager=new s,this._blendEffect=new d,this._stencilBuf=null,this._prevBeforeLayerFBOStack=[],this._fboPool=[],this.effects={highlight:new _,hittest:new b,hittestVTL:new p,integrate:new c,insideEffect:new u("inside"),outsideEffect:new u("outside")},this.materialManager=new a(e),this.textureManager=new f(t,i,e.type===m.WEBGL2),this.textureUploadManager=new h(e,t),this._effectsManager=new E}dispose(){if(this.materialManager.dispose(),this.textureManager.dispose(),this.textureUploadManager.destroy(),this._blitRenderer=e(this._blitRenderer),this._worldExtentRenderer=e(this._worldExtentRenderer),this._brushCache&&(this._brushCache.forEach((e=>e.dispose())),this._brushCache.clear(),this._brushCache=null),this._fbos){let e;for(e in this._fbos)this._fbos[e]&&this._fbos[e].dispose()}for(const e of this._fboPool)e.dispose();if(this._fboPool.length=0,this.effects){let e;for(e in this.effects)this.effects[e]&&this.effects[e].dispose()}this._effectsManager.dispose(),this._blendEffect.dispose(this.context),this._vtlMaterialManager=e(this._vtlMaterialManager)}get blitRenderer(){return this._blitRenderer}get vectorTilesMaterialManager(){return this._vtlMaterialManager}getFbos(){if(!this._fbos)throw new Error("InternalError: Painter FBOs not initialized");return this._fbos}acquireFbo(e,t){let s;if(this._fboPool.length>0)s=this._fboPool.pop();else{const r=new O(e,t);r.samplingMode=w.NEAREST,r.wrapMode=M.CLAMP_TO_EDGE,s=new C(this.context,r,this._stencilBuf)}return s.width===e&&s.height===t||s.resize(e,t),s}releaseFbo(e){this._fboPool.push(e)}getSharedStencilBuffer(){return this._stencilBuf}beforeRenderPhases(e,t,s){const{context:r}=e;this._worldExtentRenderer.render(e,t,s);const{width:i,height:n}=r.getViewport();if(this.updateFBOs(i,n),this._prevFBO=r.getBoundFramebufferObject(),r.bindFramebuffer(this.getFbos().output),r.setColorMask(!0,!0,!0,!0),null!=t){const{r:e,g:s,b:i,a:n}=t;r.setClearColor(n*e/255,n*s/255,n*i/255,n)}else r.setClearColor(0,0,0,0);r.setDepthWriteEnabled(!0),r.setClearDepth(1),r.clear(r.gl.COLOR_BUFFER_BIT|r.gl.DEPTH_BUFFER_BIT),r.setDepthWriteEnabled(!1)}afterRenderPhases(e){const{context:t}=e;t.bindFramebuffer(this._prevFBO),t.setStencilFunction(B.EQUAL,1,255),t.setStencilTestEnabled(!0),t.setDepthTestEnabled(!1),this.blitTexture(t,this.getFbos().output.colorTexture,w.NEAREST)}beforeRenderLayer(e,t,s){const{context:r,blendMode:i,effects:n,drawPhase:o,requireFBO:a}=e;if(a||S(o,i,n,s)){const e=r.getBoundFramebufferObject();this._prevBeforeLayerFBOStack.push(e);const{width:t,height:s}=r.getViewport(),i=this.acquireFbo(t,s);r.bindFramebuffer(i),r.setColorMask(!0,!0,!0,!0),r.setClearColor(0,0,0,0),r.setDepthWriteEnabled(!0),r.setClearDepth(1),r.clear(r.gl.COLOR_BUFFER_BIT|r.gl.DEPTH_BUFFER_BIT),r.setDepthWriteEnabled(!1)}r.setDepthWriteEnabled(!1),r.setDepthTestEnabled(!1),r.setStencilTestEnabled(!0),r.setClearStencil(t),r.setStencilWriteMask(255),r.clear(r.gl.STENCIL_BUFFER_BIT)}afterRenderLayer(e,t){const{context:s,blendMode:r,effects:n,requireFBO:o,drawPhase:a}=e;if(o||S(a,r,n,t)){const o=s.getBoundFramebufferObject();null!=n&&n.length>0&&a===i.MAP&&this._applyEffects(e,n,o),s.bindFramebuffer(this._prevBeforeLayerFBOStack.pop()),s.setStencilTestEnabled(!1),s.setStencilWriteMask(0),s.setBlendingEnabled(!0),s.setBlendFunctionSeparate(F.ONE,F.ONE_MINUS_SRC_ALPHA,F.ONE,F.ONE_MINUS_SRC_ALPHA),s.setColorMask(!0,!0,!0,!0);const f=null==r||a===i.HIGHLIGHT?"normal":r;this._blendEffect.draw(e,o.colorTexture,w.NEAREST,f,t),this.releaseFbo(o)}}getBrush(e,t){const s=j(e,t);let r=this._brushCache.get(s);return void 0===r&&(r=new s,this._brushCache.set(s,r)),r}renderObject(e,s,r,i){const n=t[r];if(!n)return;let o=this._brushCache.get(n);void 0===o&&(o=new n,this._brushCache.set(n,o)),o.prepareState(e,i),o.draw(e,s,i)}renderObjects(e,s,r,i){const n=t[r];if(!n)return;let o=this._brushCache.get(n);void 0===o&&(o=new n,this._brushCache.set(n,o)),o.drawMany(e,s,i)}registerRenderPass(e){const t=e.brushes.map((e=>(this._brushCache.has(e)||this._brushCache.set(e,new e),this._brushCache.get(e))));return new g(t,e)}blitTexture(e,t,s,r=1){e.setBlendingEnabled(!0),e.setBlendFunctionSeparate(F.ONE,F.ONE_MINUS_SRC_ALPHA,F.ONE,F.ONE_MINUS_SRC_ALPHA),e.setColorMask(!0,!0,!0,!0),this._blitRenderer.render(e,t,s,r)}getPostProcessingEffects(e){return this._effectsManager.getPostProcessingEffects(e)}updateFBOs(e,t){if(e!==this._lastWidth||t!==this._lastHeight){if(this._lastWidth=e,this._lastHeight=t,this._fbos){let s;for(s in this._fbos)this._fbos[s].resize(e,t);return}const s=new O(e,t);s.samplingMode=w.NEAREST,s.wrapMode=M.CLAMP_TO_EDGE;const r=new P(T.DEPTH_STENCIL,e,t);this._stencilBuf=new R(this.context,r),this._fbos={output:new C(this.context,s,this._stencilBuf),effect0:new C(this.context,s,this._stencilBuf)}}}_applyEffects(e,t,s){const{context:r}=e,i=this._effectsManager.getPostProcessingEffects(t);for(const{postProcessingEffect:n,effect:o}of i)r.bindFramebuffer(s),n.draw(e,s,o)}}function S(e,t,s,r){return e!==i.HIGHLIGHT&&(1!==r||null!=t&&"normal"!==t||null!=s&&s.length>0)}export{x as default};
5
+ import"../../../../core/has.js";import{disposeMaybe as e}from"../../../../core/maybe.js";import{brushes as t}from"../brushes.js";import s from"../vectorTiles/shaders/VTLMaterialManager.js";import{BitBlitRenderer as r}from"./BitBlitRenderer.js";import{WGLDrawPhase as i,WGLGeometryType as n,WGLSymbologyType as o}from"./enums.js";import a from"./MaterialManager.js";import f from"./TextureManager.js";import{TextureUploadManager as h}from"./TextureUploadManager.js";import{WorldExtentRenderer as l}from"./WorldExtentClipRenderer.js";import{AnimationEffect as c}from"./effects/AnimationEffect.js";import{BlendEffect as d}from"./effects/BlendEffect.js";import{FeatureEffect as u}from"./effects/FeatureEffect.js";import _ from"./effects/HighlightEffect.js";import{HittestEffect as b}from"./effects/HittestEffect.js";import{HittestEffectVTL as p}from"./effects/HittestEffectVTL.js";import{EffectManager as E}from"./effects/post-processing/EffectManager.js";import g from"./painter/RenderPass.js";import{ContextType as m}from"../../../webgl/contextUtils.js";import{TextureSamplingMode as w,TextureWrapMode as M,CompareFunction as B,BlendFactor as F,RenderbufferFormat as T}from"../../../webgl/enums.js";import{FramebufferObject as C}from"../../../webgl/FramebufferObject.js";import{Renderbuffer as R}from"../../../webgl/Renderbuffer.js";import{RenderbufferDescriptor as P}from"../../../webgl/RenderbufferDescriptor.js";import{TextureDescriptor as L}from"../../../webgl/TextureDescriptor.js";function O(e,s){switch(e){case n.LINE:return t.line;case n.TEXT:return t.text;case n.LABEL:return t.label;case n.FILL:return s===o.DOT_DENSITY?t.dotDensity:t.fill;case n.MARKER:switch(s){case o.HEATMAP:return t.heatmap;case o.PIE_CHART:return t.pieChart;default:return t.marker}}}class j{constructor(e,t,i){this.context=e,this._blitRenderer=new r,this._worldExtentRenderer=new l,this._brushCache=new Map,this._lastWidth=null,this._lastHeight=null,this._vtlMaterialManager=new s,this._blendEffect=new d,this._stencilBuf=null,this._prevBeforeLayerFBOStack=[],this._fboPool=[],this.effects={highlight:new _,hittest:new b,hittestVTL:new p,integrate:new c,insideEffect:new u("inside"),outsideEffect:new u("outside")},this.materialManager=new a(e),this.textureManager=new f(t,i,e.type===m.WEBGL2),this.textureUploadManager=new h(e,t),this._effectsManager=new E}dispose(){if(this.materialManager.dispose(),this.textureManager.dispose(),this.textureUploadManager.destroy(),this._blitRenderer=e(this._blitRenderer),this._worldExtentRenderer=e(this._worldExtentRenderer),this._brushCache&&(this._brushCache.forEach((e=>e.dispose())),this._brushCache.clear(),this._brushCache=null),this._fbos){let e;for(e in this._fbos)this._fbos[e]&&this._fbos[e].dispose()}for(const e of this._fboPool)e.dispose();if(this._fboPool.length=0,this.effects){let e;for(e in this.effects)this.effects[e]&&this.effects[e].dispose()}this._effectsManager.dispose(),this._blendEffect.dispose(this.context),this._vtlMaterialManager=e(this._vtlMaterialManager)}get blitRenderer(){return this._blitRenderer}get vectorTilesMaterialManager(){return this._vtlMaterialManager}getFbos(){if(!this._fbos)throw new Error("InternalError: Painter FBOs not initialized");return this._fbos}acquireFbo(e,t){let s;if(this._fboPool.length>0)s=this._fboPool.pop();else{const r=new L(e,t);r.samplingMode=w.NEAREST,r.wrapMode=M.CLAMP_TO_EDGE,s=new C(this.context,r,this._stencilBuf)}return s.width===e&&s.height===t||s.resize(e,t),s}releaseFbo(e){this._fboPool.push(e)}getSharedStencilBuffer(){return this._stencilBuf}beforeRenderPhases(e,t,s){const{context:r}=e;this._worldExtentRenderer.render(e,t,s);const{width:i,height:n}=r.getViewport();if(this.updateFBOs(i,n),this._prevFBO=r.getBoundFramebufferObject(),r.bindFramebuffer(this.getFbos().output),r.setColorMask(!0,!0,!0,!0),null!=t){const{r:e,g:s,b:i,a:n}=t;r.setClearColor(n*e/255,n*s/255,n*i/255,n)}else r.setClearColor(0,0,0,0);r.setDepthWriteEnabled(!0),r.setClearDepth(1),r.clear(r.gl.COLOR_BUFFER_BIT|r.gl.DEPTH_BUFFER_BIT),r.setDepthWriteEnabled(!1)}afterRenderPhases(e){const{context:t}=e;t.bindFramebuffer(this._prevFBO),t.setStencilFunction(B.EQUAL,1,255),t.setStencilTestEnabled(!0),t.setDepthTestEnabled(!1),this.blitTexture(t,this.getFbos().output.colorTexture,w.NEAREST)}beforeRenderLayer(e,t,s){const{context:r,blendMode:i,effects:n,drawPhase:o,requireFBO:a}=e;if(a||x(o,i,n,s)){const e=r.getBoundFramebufferObject();this._prevBeforeLayerFBOStack.push(e);const{width:t,height:s}=r.getViewport(),i=this.acquireFbo(t,s);r.bindFramebuffer(i),r.setColorMask(!0,!0,!0,!0),r.setClearColor(0,0,0,0),r.setDepthWriteEnabled(!0),r.setClearDepth(1),r.clear(r.gl.COLOR_BUFFER_BIT|r.gl.DEPTH_BUFFER_BIT),r.setDepthWriteEnabled(!1)}r.setDepthWriteEnabled(!1),r.setDepthTestEnabled(!1),r.setStencilTestEnabled(!0),r.setClearStencil(t),r.setStencilWriteMask(255),r.clear(r.gl.STENCIL_BUFFER_BIT)}afterRenderLayer(e,t){const{context:s,blendMode:r,effects:n,requireFBO:o,drawPhase:a}=e;if(o||x(a,r,n,t)){const o=s.getBoundFramebufferObject();null!=n&&n.length>0&&a===i.MAP&&this._applyEffects(e,n,o),s.bindFramebuffer(this._prevBeforeLayerFBOStack.pop()),s.setStencilTestEnabled(!1),s.setStencilWriteMask(0),s.setBlendingEnabled(!0),s.setBlendFunctionSeparate(F.ONE,F.ONE_MINUS_SRC_ALPHA,F.ONE,F.ONE_MINUS_SRC_ALPHA),s.setColorMask(!0,!0,!0,!0);const f=null==r||a===i.HIGHLIGHT?"normal":r;this._blendEffect.draw(e,o.colorTexture,w.NEAREST,f,t),this.releaseFbo(o)}}getBrush(e,t){const s=O(e,t);let r=this._brushCache.get(s);return void 0===r&&(r=new s,this._brushCache.set(s,r)),r}renderObject(e,s,r,i){const n=t[r];if(!n)return;let o=this._brushCache.get(n);void 0===o&&(o=new n,this._brushCache.set(n,o)),o.prepareState(e,i),o.draw(e,s,i)}renderObjects(e,s,r,i){const n=t[r];if(!n)return;let o=this._brushCache.get(n);void 0===o&&(o=new n,this._brushCache.set(n,o)),o.drawMany(e,s,i)}registerRenderPass(e){const t=e.brushes.map((e=>(this._brushCache.has(e)||this._brushCache.set(e,new e),this._brushCache.get(e))));return new g(t,e)}blitTexture(e,t,s,r=1){e.setBlendingEnabled(!0),e.setBlendFunctionSeparate(F.ONE,F.ONE_MINUS_SRC_ALPHA,F.ONE,F.ONE_MINUS_SRC_ALPHA),e.setColorMask(!0,!0,!0,!0),this._blitRenderer.render(e,t,s,r)}getPostProcessingEffects(e){return this._effectsManager.getPostProcessingEffects(e)}updateFBOs(e,t){if(e!==this._lastWidth||t!==this._lastHeight){if(this._lastWidth=e,this._lastHeight=t,this._fbos){let s;for(s in this._fbos)this._fbos[s].resize(e,t);return}const s=new L(e,t);s.samplingMode=w.NEAREST,s.wrapMode=M.CLAMP_TO_EDGE;const r=new P(T.DEPTH_STENCIL,e,t);this._stencilBuf=new R(this.context,r),this._fbos={output:new C(this.context,s,this._stencilBuf),effect0:new C(this.context,s,this._stencilBuf)}}}_applyEffects(e,t,s){const{context:r}=e,i=this._effectsManager.getPostProcessingEffects(t);for(const{postProcessingEffect:n,effect:o}of i)r.bindFramebuffer(s),n.draw(e,s,o)}}function x(e,t,s,r){return e!==i.LABEL_ALPHA&&e!==i.LABEL&&e!==i.HIGHLIGHT&&(1!==r||null!=t&&"normal"!==t||null!=s&&s.length>0)}export{j as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../geometry.js";import{throwIfAborted as e}from"../../../../core/promiseUtils.js";import{makeDehydratedPoint as o}from"../../../../layers/graphics/dehydratedPoint.js";import{getGeometryEffectiveElevationInfo as t}from"../../../../support/elevationInfoUtils.js";import{evaluateElevationInfoAtPoint as r,SampleElevationInfo as n}from"./elevationAlignmentUtils.js";import{ElevationContext as s}from"./ElevationContext.js";import{extractExpressionInfo as i,createContext as a}from"./featureExpressionInfoUtils.js";import p from"../../../../geometry/SpatialReference.js";async function f(o,n,s,f,d){const{elevationProvider:j,renderCoordsHelper:u}=o,{elevationInfo:I}=n,{pointsInFeatures:v,spatialReference:y}=f,g=p.fromJSON(y),x=i(I,!0),h=await a(x,g,d);e(d);const w=[],S=new Set,z=new Set;c.spatialReference=g;for(const{objectId:e,points:i}of v){const o=s(e);if(null==o){for(const e of i)w.push(e.z??0);S.add(e);continue}o.isDraped&&z.add(e);const a=o.graphic.geometry;m.setFromElevationInfo(t(a,I)),m.updateFeatureExpressionInfoContext(h,o.graphic,n);for(const{x:e,y:t,z:n}of i)c.x=e,c.y=t,c.z=n??0,r(c,j,m,u,l),w.push(l.z)}return{elevations:w,drapedObjectIds:z,failedObjectIds:S}}const m=new s,c=o(0,0,0,p.WGS84),l=new n;export{f as elevationAlignPointsInFeatures};
5
+ import"../../../../geometry.js";import{throwIfAborted as e}from"../../../../core/promiseUtils.js";import{projectPointToVectorWithEngine as o}from"../../../../geometry/projection/projectPointToVectorWithEngine.js";import{makeDehydratedPoint as t}from"../../../../layers/graphics/dehydratedPoint.js";import{getGeometryEffectiveElevationInfo as r}from"../../../../support/elevationInfoUtils.js";import{evaluateElevationInfoAtPoint as n,SampleElevationInfo as i}from"./elevationAlignmentUtils.js";import{ElevationContext as s}from"./ElevationContext.js";import{extractExpressionInfo as a,createContext as p}from"./featureExpressionInfoUtils.js";import f from"../../../../geometry/SpatialReference.js";async function c(t,i,s,c,u){const{elevationProvider:g,renderCoordsHelper:v}=t,{elevationInfo:y}=i,{pointsInFeatures:I,spatialReference:h}=c,x=f.fromJSON(h),w=a(y,!0),E=await p(w,x,u);e(u);const R=[],S=new Set,z=new Set;l.spatialReference=x;const P=t.elevationProvider.spatialReference??t.spatialReference;for(const{objectId:e,points:a}of I){const t=s(e);if(null==t){for(const e of a)R.push(e.z??0);S.add(e);continue}t.isDraped&&z.add(e);const p=t.graphic.geometry;m.setFromElevationInfo(r(p,y)),m.updateFeatureExpressionInfoContext(E,t.graphic,i);for(const{x:e,y:r,z:i}of a)l.x=e,l.y=r,l.z=i??0,await o(l,j,P,0,{signal:u}),n(j,g,m,v,d),R.push(d.z)}return{elevations:R,drapedObjectIds:z,failedObjectIds:S}}const m=new s,l=t(0,0,0,f.WGS84),d=new i,j=[0,0,0];export{c as elevationAlignPointsInFeatures};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import has from"../../../../core/has.js";import e from"../../../../core/PooledArray.js";import{isAbortError as t}from"../../../../core/promiseUtils.js";import{l as i}from"../../../../chunks/vec3.js";import{projectBoundingSphere as s}from"../../../../geometry/projection/projectBoundingSphere.js";import{f as n,h as o,u as r,c as a}from"../../../../chunks/sphere.js";import{i3sPatchingEnabled as l}from"../../../../support/featureFlags.js";import{expandElevationRange as d}from"./ElevationRange.js";import{LodMetric as h,NodeBase as u,Node as c,NodeFilterImpact as g,NodeIMModificationImpact as _,NodeTraversalState as f}from"./I3SNode.js";import{invalidateMbs as m,invalidateObb as v,addWraparound as N}from"./I3SUtil.js";import{clone as p}from"../../support/orientedBoundingBox.js";class b{constructor(e,t,i,s,n){this.childOffset=e,this.childCount=t,this.visibilityCache=i,this.ref=s,this.node=n,this.useAsHole=0,this.filterImpact=g.NotChecked,this.traversalState=null,this.parent=-1}}class P{constructor(e=[],t=[]){this.nodes=e,this.children=t,this.lastTraversed=0,this.numNodesWithLoadedChildren=0}}class y{get _useNodePages(){return this._pageSize>0}constructor(t,i,s,n,o,r,a,d,u,c,g,_,f,m,v){this._layer=t,this._streamDataController=s,this._clientNodeLoader=n,this._viewportQueries=o,this._logger=r,this.holeFilling=a,this._isLoaded=d,this._isReloading=u,this._isSelected=c,this._enable=g,this._needsUpdate=_,this._canRequest=f,this._computeVisibilityObb=m,this._computeNodeFiltering=v,this._dirty=!0,this._nodePages=new Map,this._clientNodePage=null,this._pageSize=0,this._rootIndex=0,this._lodMetric=h.None,this._lodConversion=e=>e,this._isEditable=!1,this._urlPrefix="",this._loadingNodes=new Set,this._loadingPages=new Set,this._failedNodes=new Set,this._failedPages=new Set,this._indexMissing=1,this._maxUnloadedPrio=Number.NEGATIVE_INFINITY,this._maxProcessingPrio=Number.POSITIVE_INFINITY,this._version=S(0),this._visibilityCacheVersion=S(0),this._maxLevel=1,this._featureEstimate={estimate:0,leavesReached:!1},this._unloadedMemoryEstimate=0,this._missingPagesAndNodes=new e({deallocator:null}),this._prefetchNodes=new e({deallocator:null}),this._updates=new I(this._missingPagesAndNodes),this._imModificationUncategorized=new e({deallocator:null}),this.ignoreServiceObb=!1,this.progressiveLoadPenalty=0,this._pageQueue=new Array,this._newPages=new Array,this.needNodeElevationRange=!1,this.layerHasModifications=!1,this._layerHasFilter=!1,this._frameNumber=0,this._isEditable=l()&&null!=t.associatedLayer?.infoFor3D,t.serviceUpdateTimeStamp?.lastUpdate&&(this._lastUpdate=`${t.serviceUpdateTimeStamp.lastUpdate}`),this._maxLodLevel=this._viewportQueries?this._viewportQueries.maxLodLevel:1,this._init(i)}_init(e){if("page"===e.type){const t=e.rootPage;switch(this._urlPrefix=e.urlPrefix,this._pageSize=e.pageSize,e.lodMetric){case"maxScreenThreshold":this._lodMetric=h.MaxScreenThreshold;break;case"maxScreenThresholdSQ":this._lodMetric=h.MaxScreenThreshold,this._lodConversion=F}if(this._isEditable){this._rootIndex=-1;const i=A(e.rootIndex,e.pageSize),s=t.nodes[i],n={nodes:[{index:this._rootIndex,children:[e.rootIndex],mesh:void 0,obb:s.obb,lodThreshold:s.lodThreshold}]};this._addPage(O(this._rootIndex,this._pageSize),n),this.getNode(-1).serviceObb=void 0}else this._rootIndex=e.rootIndex;this._addPage(O(e.rootIndex,this._pageSize),t),this._updateParentsAndLevel()}else if("node"===e.type){this._urlPrefix=e.urlPrefix;const t=new P;if(this._nodePages.set(0,t),this._isEditable){this._clientNodePage=new P;const t={id:"-1",version:null,mbs:e.rootNode.mbs,obb:e.rootNode.obb,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:[{id:"root",href:"../root",mbs:e.rootNode.mbs,obb:e.rootNode.obb}]};this._rootIndex=this._makeClientRefNode(new u(t.id,null),-1);const i=this._validateNode(t.id,t);i&&this._addNode(i,this._rootIndex)}else this._rootIndex=this._makeRefNode(new u(e.rootNode.id,null),-1);const i=this._validateNode(e.rootNode.id,e.rootNode);i&&this._addNode(i,0)}}addClientNodeToIndex(e,t){const i=-1,s=new u(e,t),n=this._makeClientRefNode(s,i);return this._linkChildToParentNode(i,n),this.requestUpdate(),n}removeClientNodeFromIndex(e,t,i){this._destroyClientRefNode(e,t,i),this.requestUpdate()}_loadPage(e){this._loadingPages.add(e);const i=this._urlPrefix+e;this._streamDataController.request(i,"json").then((t=>{this._pageQueue.push({pageIndex:e,page:t})})).catch((i=>{this._loadingPages.delete(e),t(i)||(this._failedPages.add(e),this._logger.error("#loadPage()",this._layer,`Error when loading page ${e}`,i))}))}_addQueuedPages(e){for(;this._pageQueue.length>0&&!e.done;){const{pageIndex:t,page:i}=this._pageQueue.shift();this._addPage(t,i),this._loadingPages.delete(t),e.madeProgress(),this.needNodeElevationRange&&this._newPages.push(t)}this._updateParentsAndLevel()}_invalidateElevationRangeForNewPages(e){if(this.needNodeElevationRange)for(;this._newPages.length>0&&!e.done;){const e=this._nodePages.get(this._newPages.shift());if(null==e)continue;const t=e.nodes;for(let i=0;i<this._pageSize;i++){let e=t[i].parent;for(;null!=e&&e!==this._rootIndex;){const t=this.getNode(e);t&&!Number.isNaN(t?.elevationRangeMin)&&(t.invalidateElevationRange(),this.invalidateBoundingVolumeCache(e)),e=this.getParentIndex(e)}}}}_addPage(e,t){const s=[],o=[],r=t.nodes.map(((t,r)=>{const a=s.length,l=t.children?t.children.length:0;o.push(this._rootIndex);for(let e=0;e<l;e++)s.push(t.children[e]);const d=`${t.index}`,h=p(t.obb),u=n(h.center[0],h.center[1],h.center[2],i(h.halfSize)),g=t.mesh?.attribute,_=t.mesh?.geometry,f=t.mesh?.material,m={hasSharedResource:!1,isEmpty:null==_,attributes:null!=g?.resource?`${g.resource}`:void 0,geometry:null!=_?.resource?`${_.resource}`:void 0,texture:null!=f?.resource?`${f.resource}`:void 0,geometryDefinition:_?_.definition:-1,materialDefinition:f?f.definition:-1},v=new c(d,V(r,e,this._pageSize),u,l,0,m,this._lastUpdate,this._lodMetric,this._lodConversion(t.lodThreshold),_?_.featureCount:null);return v.serviceObb=h,v.visibilityObb=this._computeVisibilityObb(v),v.vertexCount=_?_.vertexCount:0,new b(a,l,w(this._visibilityCacheVersion),null,v)})),a=new P(r,s);-1===e?this._clientNodePage=a:this._nodePages.set(e,a)}_updateParentsAndLevel(){const e=new Array,t=(t,i,s)=>{const n=this._getPage(t);if(null!=n){const o=A(t,this._pageSize),r=n.nodes[o];r.parent=null!=i?i:-1;const a=r.node;null!=a&&(a.level=s,e.push(t))}};for(t(this._rootIndex,null,0);e.length;){const i=e.pop(),s=this.getNode(i);if(null!=s)for(let e=0;e<s.childCount;e++){t(this.getChildIndex(s.index,e),i,s.level+1),this._maxLevel=Math.max(this._maxLevel,s.level+1)}}}_getPage(e){const t=O(e,this._pageSize);return t<0?this._clientNodePage:this._nodePages.get(t)}_getNodeInternal(e){const t=this._getPage(e);return null==t?null:(t.lastTraversed=this._frameNumber,t.nodes[A(e,this._pageSize)])}_addNode(e,t){null!=e.children&&this.populateChildren(t,e.children);const i=this.getParent(t),s=null!=i?i.level+1:0;this._maxLevel=Math.max(this._maxLevel,e.children?s+1:s);const{lodMetric:n,maxError:o}=k(e.lodSelection),r=this._getNodeInternal(t);return r.node=new c(e.id,t,e.mbs,r.childCount,s,e.resources,e.version,n,o,e.numFeatures),e.obb&&(r.node.serviceObb=p(e.obb)),r.node.visibilityObb=this._computeVisibilityObb(r.node),null!=r.ref&&(null==r.ref.mbs&&(r.ref.mbs=e.mbs),r.node.renderMbs=r.ref.renderMbs,r.node.serviceObbInRenderSR=r.ref.serviceObbInRenderSR,r.ref.visibilityObb=r.node.visibilityObb),r.node}_makeRefNode(e,t){const i=this._nodePages.get(0);if(t<-1)return this._makeClientRefNode(e,t);if(null==i)return-1;const s=i.nodes.length,n=new b(0,0,w(this._visibilityCacheVersion),e,null);return i.nodes.push(n),n.parent=t,m(e.renderMbs),v(e.serviceObbInRenderSR),s}_makeClientRefNode(e,t){const i=this._clientNodePage;if(null==i)return-1;if(t>=0)throw new Error("I3SIndex::client side nodes can not be made children of service side nodes.");const s=-(i.nodes.length+1),n=new b(0,0,w(this._visibilityCacheVersion),e,null);return i.nodes.push(n),n.parent=t,m(e.renderMbs),v(e.serviceObbInRenderSR),s}_linkChildToParentNode(e,t){const i=this._clientNodePage;if(null==i||e>=0)return;const s=A(e,this._pageSize),n=A(t,this._pageSize),o=i.nodes[s],r=o.childOffset;i.children.splice(o.childOffset+o.childCount,0,t);const a=1;o.childCount+=a,null!=o.node&&(o.node.childCount+=a);for(const l of i.nodes)l.childOffset>r&&(l.childOffset+=a);i.nodes[n].parent=e,this._updateParentBoundingInformation(e)}_destroyClientRefNode(e,t,i){const s=this._clientNodePage;if(null==s)return;const n=this.getParentIndex(e);if(null==n)return;const o=new Set,r=new Map,a=e=>{const i=A(e,this._pageSize),n=s.nodes[i];if(n.childCount>0)for(let t=n.childOffset;t<n.childOffset+n.childCount;++t)a(s.children[t]);const r=n.node?.id??n.ref?.id;if(null==r)throw new Error("Node has no id");t(r,e),o.add(n)};a(e);const l=s.nodes,d=s.children,h=s.nodes.map((()=>-1)),u=[],c=[];for(let g=0;g<l.length;++g){const e=l[g];if(o.has(e))continue;const t=u.length,s=V(g,-1,this._pageSize),n=V(t,-1,this._pageSize);if(e.node&&(e.node.index=n),h[g]=n,u.push(e),s!==n){const t=e.node?.id??e.ref?.id;if(null==t)throw new Error("Node has no id");i(t,s,n),r.set(s,n)}}for(let g=0;g<u.length;++g){const e=V(g,-1,this._pageSize),t=u[g],i=c.length;for(let s=t.childOffset;s<t.childOffset+t.childCount;++s){const t=d[s];if(t>=0)c.push(t);else{const i=A(t,this._pageSize),s=l[i];if(o.has(s))continue;const n=h[i];c.push(n),s.parent=e}}t.childOffset=i,t.childCount=c.length-i,t.node&&(t.node.childCount=t.childCount)}s.nodes=u,s.children=c,this._updateParentBoundingInformation(h[A(n,this._pageSize)])}_updateParentBoundingInformation(e){let t=e;do{let e=null;const i=this._clientNodeLoader.indexSR,n=this._clientNodeLoader.renderSR,l=this._getNodeInternal(t);if(null==l)return;for(let a=0;a<l.childCount;a++){const l=this.getChildIndex(t,a),d=this._getNodeInternal(l),h=null!=d?d.ref||d.node:null;if(null!=h&&h.mbs[3]>0)if(null==e)e=o(h.mbs,T);else{const t=D,o=U,a=Q;s(h.mbs,i,t,n),s(e,i,o,n),r(t,o,a),s(a,n,e,i)}}const d=l.ref||l.node;null!=d&&(null!=e?d.mbs=o(e,null!=d.mbs?d.mbs:a()):m(d.mbs),m(d.renderMbs),v(d.serviceObbInRenderSR),d.geometryObb=null),this.invalidateNodeVisibilityCacheInternal(l),t=this.getParentIndex(t)}while(null!=t)}populateChildren(e,t){const i=this._getNodeInternal(e),s=this._getPage(e);i.childOffset=s.children.length,i.childCount=t.length;for(let n=0;n<t.length;n++){const i=this._makeRefNode(t[n],e);s.children.push(i)}}getNode(e){const t=this._getNodeInternal(e);return null!=t?t.node:null}getIndexById(e){let t;return this._forAllNodes(((i,s)=>{(null!=i.node&&i.node.id===e||null!=i.ref&&i.ref.id===e)&&(t=s)})),t}getNodeById(e){const t=this.getIndexById(e);return null!=t&&t>=0?this.getNode(t):null}getChildIndex(e,t){const i=this._getPage(e);if(null==i)return-1;const s=i.nodes[A(e,this._pageSize)];return i.children[s.childOffset+t]}getParentIndex(e){const t=this._getPage(e);return null!=t&&e!==this._rootIndex?t.nodes[A(e,this._pageSize)].parent:null}getParent(e){const t=this.getParentIndex(e);return null!=t?this.getNode(t):null}isLeaf(e){const t=this._getNodeInternal(e);return null!=t&&0===t.childCount}get rootNode(){return this.getNode(this._rootIndex)}get isEditable(){return this._isEditable}removeAllGeometryObbs(){this._forAllNodes((e=>{null!=e.node&&(e.node.geometryObb=null)}))}invalidateVisibilityCache(){this._visibilityCacheVersion=S(this._visibilityCacheVersion)}invalidateNodeVisibilityCache(e){const t=this._getNodeInternal(e);null!=t&&this.invalidateNodeVisibilityCacheInternal(t)}invalidateNodeVisibilityCacheInternal(e){e.visibilityCache=w(this._visibilityCacheVersion)}invalidateBoundingVolumeCache(e){const t=this._getNodeInternal(e);null!=t&&(C(t),this.invalidateNodeVisibilityCacheInternal(t))}updateElevationChanged(e){const t=this._getNodeInternal(e);if(null==t)return;if(!this.needNodeElevationRange)return void this.invalidateBoundingVolumeCache(e);const i=null!=t.node?t.node:t.ref;null!=i&&i.invalidateElevationRange()}invalidateGeometryVisibility(e){const t=this._getNodeInternal(e);null!=t?.node&&(t.node.geometryObb=null,m(t.node.renderMbs),v(t.node.serviceObbInRenderSR))}invalidateVisibilityObbs(){null!=this.rootNode&&this.traverse(this.rootNode,(e=>(e.visibilityObb=this._computeVisibilityObb(e),e.geometryObb=null,!0)))}_updateElevationRange(e){this._updateElevationRangeInternal(e,null)}_updateElevationRangeInternal(e,t){const i=this._getNodeInternal(e);if(!i)return!1;const s=i?.node??i?.ref;if(!s)return!1;const n=s.elevationRangeMin;if(!Number.isNaN(n))return d(t,s),!0;const o={elevationRangeMin:1/0,elevationRangeMax:-1/0};let r=!1;for(let l=0;l<i.childCount;l++){const t=this.getChildIndex(e,l);this._updateElevationRangeInternal(t,o)||(r=!0)}if(0===i.childCount||r){const e=!i.node?.resources.isEmpty;this._viewportQueries.expandElevationRange(s,e,o)}const a=s.elevationRangeMax;return Number.isNaN(n)||n!==o.elevationRangeMin||a!==o.elevationRangeMax?(i.node&&(i.node.elevationRangeMin=o.elevationRangeMin,i.node.elevationRangeMax=o.elevationRangeMax),i.ref&&(i.ref.elevationRangeMin=o.elevationRangeMin,i.ref.elevationRangeMax=o.elevationRangeMax),this.invalidateBoundingVolumeCache(e),d(t,s),!0):(d(t,s),!0)}isNodeVisible(e){const t=this._getNodeInternal(e);if(null==t||null!=t.ref&&!t.ref.mbs)return!0;if(this.needNodeElevationRange&&this._updateElevationRange(e),!M(t.visibilityCache,this._visibilityCacheVersion)){const e=t.node,i=!e||t.ref&&!e.visibilityObb?t.ref??null:e;if(this._layerHasFilter&&this._computeNodeFiltering&&(null!=e||null!=t.ref)&&t.filterImpact===g.NotChecked){const i=null!=e?e.mbs:null!=t.ref?t.ref.mbs:null;t.filterImpact=null!=i?this._computeNodeFiltering(i):g.Unmodified}const s=null!=e&&t.filterImpact===g.Culled,n=!(null!=e&&e.imModificationImpact===_.Culled)&&(!i||this._viewportQueries.isNodeVisible(i))&&!s;return t.visibilityCache=R(n,this._visibilityCacheVersion),n}return E(t.visibilityCache)}isGeometryVisible(e){if(!this.isNodeVisible(e))return!1;const t=this._getNodeInternal(e);return!!(null==t?.node?.geometryObb||this.layerHasModifications&&t.node.imModificationImpact===_.NotChecked)||this._viewportQueries.isGeometryVisible(t.node)}_traverseCoverage(e,t,i,s,n){const o=this._getPage(e);if(null==o||0===t.childCount)return;const r=t.childOffset+t.childCount,a=new Array;for(let l=t.childOffset;l<r;++l){const e=o.children[l],t=this._getNodeInternal(e);null!=t?.node&&this.isGeometryVisible(e)&&a.push(t)}s/=a.length;for(const l of a){const e=l.node.index;this._isLoaded(e)||this._isReloading(e)?(n.delta=Math.max(n.delta,i),n.coverage+=s):this._traverseCoverage(e,l,i+1,s,n)}}useNodeAsHole(e){if("off"===this.holeFilling)return!1;const t=this._getNodeInternal(e);if(null==t)return!1;if("always"===this.holeFilling)return!0;if(M(t.useAsHole,this._version))return E(t.useAsHole);const i={delta:0,coverage:0};this._traverseCoverage(e,t,0,1,i);const s=i.delta*i.coverage<=.5;return t.useAsHole=R(s,this._version),s}get maxLevel(){return this._maxLevel}get dirty(){return this._dirty}destroy(){this._updates.add.prune(),this._updates.update.prune()}requestUpdate(){this._dirty=!0,this._indexMissing=1,this._version=S(this._version)}imModificationsChanged(e){this.layerHasModifications=e,this._forAllNodes((({node:e})=>{null!=e&&(e.imModificationImpact=_.NotChecked,e.visibilityObb=this._computeVisibilityObb(e),e.hasModifications&&this.invalidateGeometryVisibility(e.index))})),this.invalidateVisibilityCache()}layerFilterChanged(e){this._layerHasFilter=e,this._forAllNodes((e=>{if(null!=e){e.filterImpact=g.NotChecked;const t=e.node;null!=t&&this.invalidateNodeVisibilityCache(t.index)}})),this.invalidateVisibilityCache()}update(e,t,i){if(!this._dirty)return;this._pageQueue.length>0&&this._addQueuedPages(t),this._invalidateElevationRangeForNewPages(t),this._maxUnloadedPrio=Number.NEGATIVE_INFINITY,this._maxProcessingPrio=Number.NEGATIVE_INFINITY,this._missingPagesAndNodes.clear(),this._prefetchNodes.clear(),this._updates.reset(e),x.clear();let s=!0;const n=new z,o=new z,r=this._imModificationUncategorized;r.clear();const a=new Set;let l=0;const d=(d,h,u)=>{const c=O(d,this._pageSize);if(a.add(c),null==h){let e=this._entryPriority(d);return e===1/0&&(e=this._entryPriority(u)),x.set(c,Math.max(e,x.get(c)||0)),this._loadingPages.has(c)||this._failedPages.has(c)||(this._missingPagesAndNodes.push(c),++l),void(this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e))}const g=h.node;if(this._updateNodeFeatureEstimate(g,o),null==g){const e=this._entryPriority(d);return this._loadingNodes.has(d)||this._failedNodes.has(d)||(this._missingPagesAndNodes.push(d),x.set(d,e)),void(this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e))}const f=this._getPage(d);if(0===this._missingPagesAndNodes.length&&!this._useNodePages)for(let e=0;e<h.childCount;e++){const t=f.children[h.childOffset+e],i=this._getNodeInternal(t);null==i||i.node||this._loadingNodes.has(t)||this._failedNodes.has(t)||(x.set(t,this._entryPriority(t)),this._prefetchNodes.push(t))}if(g.failed||g.resources.isEmpty)return void(s&&h.childCount>0&&this._isSelected(g)&&(s=!1));if(this._isLoaded(d)){if(n.known+=g.memory,++n.knownNodes,this._isSelected(g)?h.childCount>0&&(s=!1):(n.unremoved+=g.memory,s=!1),this._needsUpdate(g)){const e=this._entryPriority(d);x.set(d,e),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e),this._updates.update.push(d)}return}if(g.memory&&(n.known+=g.memory,++n.knownNodes),!this._isSelected(g))return void(this._isReloading(d)&&this._updates.remove.push(d));if(h.childCount>0&&(s=!1),g.memory?(n.missing+=g.memory,n.known+=g.memory,++n.knownNodes):++n.missingNodes,e.includes(g.index))return this._maxProcessingPrio=Math.max(this._maxProcessingPrio,this._entryPriority(d)),void(this._updates.cancel=this._updates.cancel.filter((e=>e!==g.index)));if(!t.done&&this._enable(g))return void t.madeProgress();const m=this._entryPriority(d);x.set(d,m),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,m),this._updates.add.push(d),this.layerHasModifications&&i&&null!=g&&g.imModificationImpact===_.NotChecked&&r.push(d)};this.traverseVisible(d),this._frameNumber++,this._missingPagesAndNodes.sort(((e,t)=>e-t)),this._missingPagesAndNodes.filterInPlace(((e,t)=>t<1||this._missingPagesAndNodes.data[t-1]!==e)),this._missingPagesAndNodes.sort(((e,t)=>x.get(e)-x.get(t))),this._missingPagesAndNodes.length>0&&(this._maxUnloadedPrio=x.get(this._missingPagesAndNodes.back()),this._prefetchNodes.clear()),this._removeUnusedNodePages(a,l);const h=this._updates.add;h.length>0&&this.layerHasModifications&&(r.length>0&&i?.(r),h.filterInPlace((e=>{const t=this._getNodeInternal(e),i=null==t?.node||t.node.imModificationImpact!==_.Culled;return i||this.invalidateNodeVisibilityCache(e),i}))),this._unloadedMemoryEstimate=n.missing-n.unremoved,n.knownNodes>3&&n.missingNodes>0&&(this._unloadedMemoryEstimate+=n.known/n.knownNodes*n.missingNodes),this._unloadedMemoryEstimate=.8*Math.max(0,this._unloadedMemoryEstimate),this._featureEstimate.estimate=this._computeFeatureEstimate(o),this._featureEstimate.leavesReached=s,this._updates.add.filterInPlace((e=>x.get(e)>=this._maxUnloadedPrio)).sort(((e,t)=>x.get(e)-x.get(t))),this._updates.update.sort(((e,t)=>x.get(e)-x.get(t))),this._indexMissing=this._loadingPages.size+this._loadingNodes.size+this._missingPagesAndNodes.length,this._dirty=this._indexMissing>0,x.clear()}checkFeatureTarget(e,t){const i=this._viewportQueries.updateScreenSpaceErrorBias(t);let s=t,n=t,o=i,r=10;for(;r--;){const i=new z;this._updateFeatureEstimate(s,i);if(this._computeFeatureEstimate(i)<=e){if(s>=t||i.missingNodes>0||0===r)break;o=s,s=.5*(s+n)}else n=s,s=.5*(s+o)}return this._version=S(this._version),this._viewportQueries.updateScreenSpaceErrorBias(i),Math.min(t,s)}_removeUnusedNodePages(e,t){if(!this._useNodePages)return;const i=this._nodePages,s=e.size,n=i.size+this._loadingPages.size+t;if(n>$&&n>s){const t=new Array;for(const[s,n]of i)0!==n.numNodesWithLoadedChildren||e.has(s)||t.push([n.lastTraversed,s]);t.sort(((e,t)=>e[0]-t[0])).some((e=>{const t=e[1];return this._deleteNodePage(t),i.size<=$}))}}_updateFeatureEstimate(e,t){this._version=S(this._version),this._viewportQueries.updateScreenSpaceErrorBias(e),this.traverseVisible(((e,i)=>this._updateNodeFeatureEstimate(null!=i?i.node:void 0,t)))}_updateNodeFeatureEstimate(e,t){null==e||e.failed||null==e.numFeatures||this._isSelected(e)&&(null!=e.numFeatures?(t.missing+=e.numFeatures,t.known+=e.numFeatures,++t.knownNodes):++t.missingNodes)}_computeFeatureEstimate(e){let t=e.known-e.unremoved;return e.knownNodes>3&&e.missingNodes>0&&(t+=e.known/e.knownNodes*e.missingNodes),Math.max(0,t)}load(){return this._load(this._missingPagesAndNodes)}prefetch(){return this._prefetchNodes.sort(((e,t)=>x.get(e)-x.get(t))),this._load(this._prefetchNodes)}_load(e){if(0===e.length||!this._canRequest())return!1;for(;e.length>0&&this._canRequest();){const t=e.pop();this._useNodePages&&t>=0?this._loadPage(t):this._loadNode(t)}return!0}get isLoading(){return this._indexMissing>0}get isPrefetching(){return this._prefetchNodes.length>0}get indexLoading(){return this._loadingPages.size+this._loadingNodes.size}get indexMissing(){return this._indexMissing}get unloadedMemoryEstimate(){return this._unloadedMemoryEstimate}get updates(){return this._updates}get featureEstimate(){return this._featureEstimate}get maxPriority(){return Math.max(this._maxProcessingPrio,this._maxUnloadedPrio)}nodeTraversalState(e){if(null==e)return null;const t=e.index,i=this._getNodeInternal(t);if(!i)return null;let s=i?.traversalState;if(s&&M(s.version,this._version))return s;const n=this._viewportQueries.getLodLevel(e),o=this._viewportQueries.hasLOD(e);let r=!0;if(o){const e=this.getParentIndex(t);if(null!=e){const t=this._getNodeInternal(e),i=t?.traversalState;r=!!i&&n>i.lodLevel}else r=n>0}else r=0===e.childCount;return s?(s.lodLevel=n,s.isChosen=r,s.version=R(!0,this._version),s):(s=new f(o,r,n,R(!0,this._version)),i.traversalState=s,s)}async _loadNode(e){this._loadingNodes.add(e);const i=this._getNodeInternal(e).ref;if(null==i)return void this._failedNodes.add(e);const s=i.id,n=this._urlPrefix+s,o=()=>{this._loadingNodes.delete(e),0===this._missingPagesAndNodes.length&&0===this._loadingNodes.size&&this.requestUpdate()};let r=null;try{r=e>=0?await this._streamDataController.request(n,"json"):await this._clientNodeLoader.loadNodeJSON(s)}catch(d){return o(),void(t(d)||(this._logger.error("#loadNode()",this._layer,"Error loading node: "+n),this._failedNodes.add(e)))}o();const a=this._validateNode(s,r);if(null==a)return;a.obb&&this.invalidateNodeVisibilityCache(e);const l=this._addNode(a,e);this.nodeTraversalState(l)}_validateNode(e,t){if(null==t||"object"!=typeof t||t.id!==e)return this._logger.error("#validateNode()",this._layer,`Invalid node. Wrong type or wrong id "${e}"`),null;if(!Array.isArray(t.mbs))return this._logger.error("#validateNode()",this._layer,`Invalid bounding volume on node ${e}.`),null;t.sharedResource&&"./shared"!==t.sharedResource.href&&"./shared/"!==t.sharedResource.href&&this._logger.warn("#validateNode()",this._layer,`Invalid shared resource href on node "${e}"`);const i=t.geometryData;null==i||Array.isArray(i)&&0===i.length||Array.isArray(i)&&1===i.length&&"./geometries/0"===i[0].href||this._logger.warn("#validateNode()",this._layer,`Invalid geometry data on node "${e}"`);const s=t.attributeData,n=this._layer.attributeStorageInfo;null==s||Array.isArray(s)&&!s.some(((e,t)=>e.href!==`./attributes/${n?.[t]?.key??`f_${t}`}/0`))||this._logger.warn("#validateNode()",this._layer,`Invalid attribute data on node "${e}"`),t.featureData&&t.featureData.length>1&&this._logger.warn("#validateNode()",this._layer,`Node ${e} has ${t.featureData.length} bundles. Only the first bundle will be loaded.`);const o=t.hasOwnProperty("obb")&&!this.ignoreServiceObb?t.obb:null,r=t.featureData&&1===t.featureData.length&&t.featureData[0].featureRange?t.featureData[0].featureRange[1]-t.featureData[0].featureRange[0]+1:void 0,a=t=>{if(null==t)return null;const i=t=>this._logger.error("#validateNode()",this._layer,`Invalid node reference on node ${e}: ${t}`);if("number"==typeof t.id)i(`id ${t.id} is a number instead of a string.`);else if("string"!=typeof t.id||!Array.isArray(t.mbs))return i("Missing or invalid id."),null;if(!Array.isArray(t.mbs))return i(`Invalid bounding volume on reference ${t.id}.`),null;t.href&&t.href!=="../"+t.id&&this._logger.error("#validateNode()",this._layer,`Invalid node href on node "${e}"`);const s=t.hasOwnProperty("obb")&&!this.ignoreServiceObb?t.obb:null,n=new u(`${t.id}`,t.mbs);return n.serviceObb=s,n.visibilityObb=this._computeVisibilityObb(n),n},l=Array.isArray(t.children)?t.children.map(a).filter((e=>null!=e)):null,d=t.featureData?.length??!1,h=!0===t.isEmpty;return{id:e,mbs:t.mbs,obb:o,children:l,resources:{isEmpty:!d&&h,hasSharedResource:null!=t.sharedResource,attributes:t.attributeData?e:void 0,texture:t.textureData&&t.textureData.length>0?e:void 0,geometry:null!=t.geometryData?e:void 0},version:"string"==typeof t.version?t.version:null,lodSelection:Array.isArray(t.lodSelection)?t.lodSelection:null,numFeatures:r}}resetFailedNodes(){this._failedNodes.clear(),this._failedPages.clear(),this._forAllNodes((e=>{null!=e.node&&(e.node.failed=!1)}))}_entryPriority(e){const t=this._getNodeInternal(e),i=this.getParentIndex(e);if(null==t||null==i&&null==t.node)return null==i?1/0:this._entryPriority(i);let s=0;if(t.node&&null!=i){const e=this._getNodeInternal(i).traversalState;null!=e&&(s=e.lodLevel)}let n=this.progressiveLoadPenalty;for(let r=e;null!=r;r=this.getParentIndex(r))if(this._isLoaded(r)){n=0;break}const o=null!=t.ref?this._viewportQueries.distToPOI(t.ref):null!=t.node?this._viewportQueries.distToPOI(t.node):0;return-o-s*(o+this.progressiveLoadPenalty)+n}traverseVisible(e){const t=this._getNodeInternal(this._rootIndex);null!=t?this._traverseVisible(this._rootIndex,null,t,e):e(this._rootIndex,null,null)}_traverseVisible(e,t,i,s){if(i.node&&0===i.childCount)return void(this.isGeometryVisible(e)&&s(e,i,t));if(!this.isNodeVisible(e))return;if(s(e,i,t),null==i.node)return;const n=this.nodeTraversalState(i.node);if(n?.nodeHasLOD&&n.lodLevel===this._maxLodLevel)return;const o=this._getPage(e);for(let r=0;r<i.childCount;r++){const t=o.children[i.childOffset+r],n=this._getNodeInternal(t);n?this._traverseVisible(t,e,n,s):s(t,null,e)}}traverse(e,t){t(e)&&this.traverseChildren(e,t)}traverseChildren(e,t){const i=e.index,s=this._getNodeInternal(i);null!=s&&this._traverseChildren(i,s,t)}_traverseChildren(e,t,i){const s=this._getPage(e);if(null==s)return;const n=t.childOffset+t.childCount;for(let o=t.childOffset;o<n;++o){const e=s.children[o],t=this._getNodeInternal(e);null!=t?.node&&i(t.node)&&this._traverseChildren(e,t,i)}}updateChildrenLoaded(e,t){let i=this.getNode(e);for(;null!=i;){const e=i.childrenLoaded,s=e+t;i.childrenLoaded=s;const n=0===e?1:0===s?-1:0,o=i.index;if(0!==n){this._getPage(o).numNodesWithLoadedChildren+=n}i=this.getParent(o)}}checkChildrenLoadedInvariant(){if(null==this.rootNode)return!0;const e=[],t=i=>{let s=this._isLoaded(i.index)||this._isReloading(i.index)?1:0;return this.traverseChildren(i,(e=>(s+=t(e),!1))),i.childrenLoaded!==s&&e.push(i.index),s};return t(this.rootNode),e.length&&this._logger.error("childrenLoaded invariant broken at following nodes: "+e.join(",")),e.length>0}updateStats(e){if(this._updates.add.length>0&&(e.nodes+=" + "+this._updates.add.length),e.index=this._nodePages.size*(this._pageSize||1)+(this._clientNodePage?.nodes.length??0),e.prio=this._maxProcessingPrio,(this._indexMissing||this._prefetchNodes.length>0)&&(e.index+=" + "+this._indexMissing||this._prefetchNodes.length),this._featureEstimate.estimate){const t=this._featureEstimate.estimate-e.features;t>0?e.features+=" + "+t:t<0&&(e.features+=" - "+-t)}}updateElevationInfo(e,t){this.needNodeElevationRange=t&&!!e&&("relative-to-ground"===e.mode||"on-the-ground"===e.mode),this._viewportQueries.updateElevationInfo(e),this.invalidateAllElevationRanges()}invalidateAllElevationRanges(){this._forAllNodes((e=>{C(e),null!=e.node&&e.node.invalidateElevationRange(),null!=e.ref&&e.ref.invalidateElevationRange()}))}_forAllNodes(e){if(null!=this._clientNodePage){const t=this._clientNodePage;for(let i=0;i<t.nodes.length;i++)e(t.nodes[i],-(i+1))}for(const[t,i]of this._nodePages){const s=t*this._pageSize;for(let t=0;t<i.nodes.length;t++)e(i.nodes[t],s+t)}}clearCaches(){if(this._useNodePages){const e=this._nodePages,t=new Set;this.traverseVisible((e=>t.add(O(e,this._pageSize))));for(const[i,s]of e)if(0!==s.numNodesWithLoadedChildren||t.has(i))for(const e of s.nodes)e.traversalState=null;else this._deleteNodePage(i)}}_deleteNodePage(e){this._nodePages.delete(e)}get test(){return{addNode:(e,t)=>this._addNode(e,t),getNodeInternal:e=>this._getNodeInternal(e),getPageIndex:e=>O(e,this._pageSize),getIndexWithinPage:e=>A(e,this._pageSize),getNodePage:e=>e<0?this._clientNodePage:this._nodePages.get(e),getChildIndices:e=>{const t=this._getNodeInternal(e),i=this._getPage(e);if(null==t||null==i)return[];const s=[];for(let n=t.childOffset;n<t.childOffset+t.childCount;++n)s.push(i.children[n]);return s},rootIndex:this._rootIndex,clientNodePage:this._clientNodePage,nodePages:this._nodePages}}}const x=new Map;class I{constructor(t){this.missing=t,this.update=new e({deallocator:null}),this.add=new e({deallocator:null}),this.remove=new e({deallocator:null}),this.cancel=[]}reset(e){this.add.clear(),this.update.clear(),this.cancel=e}}function C(e){null!=e.node&&(m(e.node.renderMbs),v(e.node.serviceObbInRenderSR)),null!=e.ref&&(m(e.ref.renderMbs),v(e.ref.serviceObbInRenderSR))}function w(e){return N(e,-2)}function S(e){return N(e,2)}function R(e,t){return t+(e?1:0)}function M(e,t){return(-2&e)===t}function E(e){return 1==(1&e)}function O(e,t){return e<0?-1:t>0?e/t|0:0}function A(e,t){return e<0?-e-1:0===t?e:e%t}function V(e,t,i){return-1===t?-(e+1):0===i?e:t*i+e}const L=[["maxScreenThreshold",h.MaxScreenThreshold],["screenSpaceRelative",h.ScreenSpaceRelative],["removedFeatureDiameter",h.RemovedFeatureDiameter],["distanceRangeFromDefaultCamera",h.DistanceRangeFromDefaultCamera]];function k(e){if(e)for(let t=0;t<e.length;t++)for(const i of L)if(i[0]===e[t].metricType)return{lodMetric:i[1],maxError:e[t].maxError};return{lodMetric:h.None,maxError:0}}class z{constructor(){this.known=0,this.knownNodes=0,this.missing=0,this.missingNodes=0,this.unremoved=0}}function F(e){return Math.sqrt(e*(4/Math.PI))}const T=a(),D=a(),U=a(),Q=a(),$=has("esri-mobile")?100:300;export{y as I3SIndex,k as selectErrorMetric};
5
+ import e from"../../../../core/PooledArray.js";import{isAbortError as t}from"../../../../core/promiseUtils.js";import{l as i}from"../../../../chunks/vec3.js";import{projectBoundingSphere as s}from"../../../../geometry/projection/projectBoundingSphere.js";import{f as n,h as o,u as r,c as a}from"../../../../chunks/sphere.js";import{i3sPatchingEnabled as l}from"../../../../support/featureFlags.js";import{expandElevationRange as d}from"./ElevationRange.js";import{LodMetric as h,NodeBase as u,Node as c,NodeFilterImpact as g,NodeIMModificationImpact as _,NodeTraversalState as f}from"./I3SNode.js";import{invalidateMbs as m,invalidateObb as v,addWraparound as N}from"./I3SUtil.js";import{clone as p}from"../../support/orientedBoundingBox.js";class b{constructor(e,t,i,s,n){this.childOffset=e,this.childCount=t,this.visibilityCache=i,this.ref=s,this.node=n,this.useAsHole=0,this.filterImpact=g.NotChecked,this.traversalState=null,this.parent=-1}}class y{constructor(e=[],t=[]){this.nodes=e,this.children=t,this.lastTraversed=0,this.numNodesWithLoadedChildren=0}}class P{get _useNodePages(){return this._pageSize>0}constructor(t,i,s,n,o,r,a,d,u,c,g,_,f,m,v){this._layer=t,this._streamDataController=s,this._clientNodeLoader=n,this._viewportQueries=o,this._logger=r,this.holeFilling=a,this._isLoaded=d,this._isReloading=u,this._isSelected=c,this._enable=g,this._needsUpdate=_,this._canRequest=f,this._computeVisibilityObb=m,this._computeNodeFiltering=v,this._dirty=!0,this._nodePages=new Map,this._clientNodePage=null,this._pageSize=0,this._rootIndex=0,this._lodMetric=h.None,this._lodConversion=e=>e,this._isEditable=!1,this._urlPrefix="",this._loadingNodes=new Set,this._loadingPages=new Set,this._failedNodes=new Set,this._failedPages=new Set,this._indexMissing=1,this._maxUnloadedPrio=Number.NEGATIVE_INFINITY,this._maxProcessingPrio=Number.POSITIVE_INFINITY,this._version=S(0),this._visibilityCacheVersion=S(0),this._maxLevel=1,this._featureEstimate={estimate:0,leavesReached:!1},this._unloadedMemoryEstimate=0,this._missingPagesAndNodes=new e({deallocator:null}),this._prefetchNodes=new e({deallocator:null}),this._updates=new I(this._missingPagesAndNodes),this._imModificationUncategorized=new e({deallocator:null}),this.ignoreServiceObb=!1,this.progressiveLoadPenalty=0,this._pageQueue=new Array,this._newPages=new Array,this.needNodeElevationRange=!1,this.layerHasModifications=!1,this._layerHasFilter=!1,this._frameNumber=0,this._isEditable=l()&&null!=t.associatedLayer?.infoFor3D,t.serviceUpdateTimeStamp?.lastUpdate&&(this._lastUpdate=`${t.serviceUpdateTimeStamp.lastUpdate}`),this._maxLodLevel=this._viewportQueries?this._viewportQueries.maxLodLevel:1,this._init(i)}_init(e){if("page"===e.type){const t=e.rootPage;switch(this._urlPrefix=e.urlPrefix,this._pageSize=e.pageSize,e.lodMetric){case"maxScreenThreshold":this._lodMetric=h.MaxScreenThreshold;break;case"maxScreenThresholdSQ":this._lodMetric=h.MaxScreenThreshold,this._lodConversion=z}if(this._isEditable){this._rootIndex=-1;const i=A(e.rootIndex,e.pageSize),s=t.nodes[i],n={nodes:[{index:this._rootIndex,children:[e.rootIndex],mesh:void 0,obb:s.obb,lodThreshold:s.lodThreshold}]};this._addPage(O(this._rootIndex,this._pageSize),n),this.getNode(-1).serviceObb=void 0}else this._rootIndex=e.rootIndex;this._addPage(O(e.rootIndex,this._pageSize),t),this._updateParentsAndLevel()}else if("node"===e.type){this._urlPrefix=e.urlPrefix;const t=new y;if(this._nodePages.set(0,t),this._isEditable){this._clientNodePage=new y;const t={id:"-1",version:null,mbs:e.rootNode.mbs,obb:e.rootNode.obb,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:[{id:"root",href:"../root",mbs:e.rootNode.mbs,obb:e.rootNode.obb}]};this._rootIndex=this._makeClientRefNode(new u(t.id,null),-1);const i=this._validateNode(t.id,t);i&&this._addNode(i,this._rootIndex)}else this._rootIndex=this._makeRefNode(new u(e.rootNode.id,null),-1);const i=this._validateNode(e.rootNode.id,e.rootNode);i&&this._addNode(i,0)}}addClientNodeToIndex(e,t){const i=-1,s=new u(e,t),n=this._makeClientRefNode(s,i);return this._linkChildToParentNode(i,n),this.requestUpdate(),n}removeClientNodeFromIndex(e,t,i){this._destroyClientRefNode(e,t,i),this.requestUpdate()}_loadPage(e){this._loadingPages.add(e);const i=this._urlPrefix+e;this._streamDataController.request(i,"json").then((t=>{this._pageQueue.push({pageIndex:e,page:t})})).catch((i=>{this._loadingPages.delete(e),t(i)||(this._failedPages.add(e),this._logger.error("#loadPage()",this._layer,`Error when loading page ${e}`,i))}))}_addQueuedPages(e){for(;this._pageQueue.length>0&&!e.done;){const{pageIndex:t,page:i}=this._pageQueue.shift();this._addPage(t,i),this._loadingPages.delete(t),e.madeProgress(),this.needNodeElevationRange&&this._newPages.push(t)}this._updateParentsAndLevel()}_invalidateElevationRangeForNewPages(e){if(this.needNodeElevationRange)for(;this._newPages.length>0&&!e.done;){const e=this._nodePages.get(this._newPages.shift());if(null==e)continue;const t=e.nodes;for(let i=0;i<this._pageSize;i++){let e=t[i].parent;for(;null!=e&&e!==this._rootIndex;){const t=this.getNode(e);t&&!Number.isNaN(t?.elevationRangeMin)&&(t.invalidateElevationRange(),this.invalidateBoundingVolumeCache(e)),e=this.getParentIndex(e)}}}}_addPage(e,t){const s=[],o=[],r=t.nodes.map(((t,r)=>{const a=s.length,l=t.children?t.children.length:0;o.push(this._rootIndex);for(let e=0;e<l;e++)s.push(t.children[e]);const d=`${t.index}`,h=p(t.obb),u=n(h.center[0],h.center[1],h.center[2],i(h.halfSize)),g=t.mesh?.attribute,_=t.mesh?.geometry,f=t.mesh?.material,m={hasSharedResource:!1,isEmpty:null==_,attributes:null!=g?.resource?`${g.resource}`:void 0,geometry:null!=_?.resource?`${_.resource}`:void 0,texture:null!=f?.resource?`${f.resource}`:void 0,geometryDefinition:_?_.definition:-1,materialDefinition:f?f.definition:-1},v=new c(d,V(r,e,this._pageSize),u,l,0,m,this._lastUpdate,this._lodMetric,this._lodConversion(t.lodThreshold),_?_.featureCount:null);return v.serviceObb=h,v.visibilityObb=this._computeVisibilityObb(v),v.vertexCount=_?_.vertexCount:0,new b(a,l,w(this._visibilityCacheVersion),null,v)})),a=new y(r,s);-1===e?this._clientNodePage=a:this._nodePages.set(e,a)}_updateParentsAndLevel(){const e=new Array,t=(t,i,s)=>{const n=this._getPage(t);if(null!=n){const o=A(t,this._pageSize),r=n.nodes[o];r.parent=null!=i?i:-1;const a=r.node;null!=a&&(a.level=s,e.push(t))}};for(t(this._rootIndex,null,0);e.length;){const i=e.pop(),s=this.getNode(i);if(null!=s)for(let e=0;e<s.childCount;e++){t(this.getChildIndex(s.index,e),i,s.level+1),this._maxLevel=Math.max(this._maxLevel,s.level+1)}}}_getPage(e){const t=O(e,this._pageSize);return t<0?this._clientNodePage:this._nodePages.get(t)}_getNodeInternal(e){const t=this._getPage(e);return null==t?null:(t.lastTraversed=this._frameNumber,t.nodes[A(e,this._pageSize)])}_addNode(e,t){null!=e.children&&this.populateChildren(t,e.children);const i=this.getParent(t),s=null!=i?i.level+1:0;this._maxLevel=Math.max(this._maxLevel,e.children?s+1:s);const{lodMetric:n,maxError:o}=k(e.lodSelection),r=this._getNodeInternal(t);return r.node=new c(e.id,t,e.mbs,r.childCount,s,e.resources,e.version,n,o,e.numFeatures),e.obb&&(r.node.serviceObb=p(e.obb)),r.node.visibilityObb=this._computeVisibilityObb(r.node),null!=r.ref&&(null==r.ref.mbs&&(r.ref.mbs=e.mbs),r.node.renderMbs=r.ref.renderMbs,r.node.serviceObbInRenderSR=r.ref.serviceObbInRenderSR,r.ref.visibilityObb=r.node.visibilityObb),r.node}_makeRefNode(e,t){const i=this._nodePages.get(0);if(t<-1)return this._makeClientRefNode(e,t);if(null==i)return-1;const s=i.nodes.length,n=new b(0,0,w(this._visibilityCacheVersion),e,null);return i.nodes.push(n),n.parent=t,m(e.renderMbs),v(e.serviceObbInRenderSR),s}_makeClientRefNode(e,t){const i=this._clientNodePage;if(null==i)return-1;if(t>=0)throw new Error("I3SIndex::client side nodes can not be made children of service side nodes.");const s=-(i.nodes.length+1),n=new b(0,0,w(this._visibilityCacheVersion),e,null);return i.nodes.push(n),n.parent=t,m(e.renderMbs),v(e.serviceObbInRenderSR),s}_linkChildToParentNode(e,t){const i=this._clientNodePage;if(null==i||e>=0)return;const s=A(e,this._pageSize),n=A(t,this._pageSize),o=i.nodes[s],r=o.childOffset;i.children.splice(o.childOffset+o.childCount,0,t);const a=1;o.childCount+=a,null!=o.node&&(o.node.childCount+=a);for(const l of i.nodes)l.childOffset>r&&(l.childOffset+=a);i.nodes[n].parent=e,this._updateParentBoundingInformation(e)}_destroyClientRefNode(e,t,i){const s=this._clientNodePage;if(null==s)return;const n=this.getParentIndex(e);if(null==n)return;const o=new Set,r=new Map,a=e=>{const i=A(e,this._pageSize),n=s.nodes[i];if(n.childCount>0)for(let t=n.childOffset;t<n.childOffset+n.childCount;++t)a(s.children[t]);const r=n.node?.id??n.ref?.id;if(null==r)throw new Error("Node has no id");t(r,e),o.add(n)};a(e);const l=s.nodes,d=s.children,h=s.nodes.map((()=>-1)),u=[],c=[];for(let g=0;g<l.length;++g){const e=l[g];if(o.has(e))continue;const t=u.length,s=V(g,-1,this._pageSize),n=V(t,-1,this._pageSize);if(e.node&&(e.node.index=n),h[g]=n,u.push(e),s!==n){const t=e.node?.id??e.ref?.id;if(null==t)throw new Error("Node has no id");i(t,s,n),r.set(s,n)}}for(let g=0;g<u.length;++g){const e=V(g,-1,this._pageSize),t=u[g],i=c.length;for(let s=t.childOffset;s<t.childOffset+t.childCount;++s){const t=d[s];if(t>=0)c.push(t);else{const i=A(t,this._pageSize),s=l[i];if(o.has(s))continue;const n=h[i];c.push(n),s.parent=e}}t.childOffset=i,t.childCount=c.length-i,t.node&&(t.node.childCount=t.childCount)}s.nodes=u,s.children=c,this._updateParentBoundingInformation(h[A(n,this._pageSize)])}_updateParentBoundingInformation(e){let t=e;do{let e=null;const i=this._clientNodeLoader.indexSR,n=this._clientNodeLoader.renderSR,l=this._getNodeInternal(t);if(null==l)return;for(let a=0;a<l.childCount;a++){const l=this.getChildIndex(t,a),d=this._getNodeInternal(l),h=null!=d?d.ref||d.node:null;if(null!=h&&h.mbs[3]>0)if(null==e)e=o(h.mbs,D);else{const t=T,o=Q,a=U;s(h.mbs,i,t,n),s(e,i,o,n),r(t,o,a),s(a,n,e,i)}}const d=l.ref||l.node;null!=d&&(null!=e?d.mbs=o(e,null!=d.mbs?d.mbs:a()):m(d.mbs),m(d.renderMbs),v(d.serviceObbInRenderSR),d.geometryObb=null),this.invalidateNodeVisibilityCacheInternal(l),t=this.getParentIndex(t)}while(null!=t)}populateChildren(e,t){const i=this._getNodeInternal(e),s=this._getPage(e);i.childOffset=s.children.length,i.childCount=t.length;for(let n=0;n<t.length;n++){const i=this._makeRefNode(t[n],e);s.children.push(i)}}getNode(e){const t=this._getNodeInternal(e);return null!=t?t.node:null}getIndexById(e){let t;return this._forAllNodes(((i,s)=>{(null!=i.node&&i.node.id===e||null!=i.ref&&i.ref.id===e)&&(t=s)})),t}getNodeById(e){const t=this.getIndexById(e);return null!=t&&t>=0?this.getNode(t):null}getChildIndex(e,t){const i=this._getPage(e);if(null==i)return-1;const s=i.nodes[A(e,this._pageSize)];return i.children[s.childOffset+t]}getParentIndex(e){const t=this._getPage(e);return null!=t&&e!==this._rootIndex?t.nodes[A(e,this._pageSize)].parent:null}getParent(e){const t=this.getParentIndex(e);return null!=t?this.getNode(t):null}isLeaf(e){const t=this._getNodeInternal(e);return null!=t&&0===t.childCount}get rootNode(){return this.getNode(this._rootIndex)}get isEditable(){return this._isEditable}removeAllGeometryObbs(){this._forAllNodes((e=>{null!=e.node&&(e.node.geometryObb=null)}))}invalidateVisibilityCache(){this._visibilityCacheVersion=S(this._visibilityCacheVersion)}invalidateNodeVisibilityCache(e){const t=this._getNodeInternal(e);null!=t&&this.invalidateNodeVisibilityCacheInternal(t)}invalidateNodeVisibilityCacheInternal(e){e.visibilityCache=w(this._visibilityCacheVersion)}invalidateBoundingVolumeCache(e){const t=this._getNodeInternal(e);null!=t&&(C(t),this.invalidateNodeVisibilityCacheInternal(t))}updateElevationChanged(e){const t=this._getNodeInternal(e);if(null==t)return;if(!this.needNodeElevationRange)return void this.invalidateBoundingVolumeCache(e);const i=null!=t.node?t.node:t.ref;null!=i&&i.invalidateElevationRange()}invalidateGeometryVisibility(e){const t=this._getNodeInternal(e);null!=t?.node&&(t.node.geometryObb=null,m(t.node.renderMbs),v(t.node.serviceObbInRenderSR))}invalidateVisibilityObbs(){null!=this.rootNode&&this.traverse(this.rootNode,(e=>(e.visibilityObb=this._computeVisibilityObb(e),e.geometryObb=null,!0)))}_updateElevationRange(e){this._updateElevationRangeInternal(e,null)}_updateElevationRangeInternal(e,t){const i=this._getNodeInternal(e);if(!i)return!1;const s=i?.node??i?.ref;if(!s)return!1;const n=s.elevationRangeMin;if(!Number.isNaN(n))return d(t,s),!0;const o={elevationRangeMin:1/0,elevationRangeMax:-1/0};let r=!1;for(let l=0;l<i.childCount;l++){const t=this.getChildIndex(e,l);this._updateElevationRangeInternal(t,o)||(r=!0)}if(0===i.childCount||r){const e=!i.node?.resources.isEmpty;this._viewportQueries.expandElevationRange(s,e,o)}const a=s.elevationRangeMax;return Number.isNaN(n)||n!==o.elevationRangeMin||a!==o.elevationRangeMax?(i.node&&(i.node.elevationRangeMin=o.elevationRangeMin,i.node.elevationRangeMax=o.elevationRangeMax),i.ref&&(i.ref.elevationRangeMin=o.elevationRangeMin,i.ref.elevationRangeMax=o.elevationRangeMax),this.invalidateBoundingVolumeCache(e),d(t,s),!0):(d(t,s),!0)}isNodeVisible(e){const t=this._getNodeInternal(e);if(null==t||null!=t.ref&&!t.ref.mbs)return!0;if(this.needNodeElevationRange&&this._updateElevationRange(e),!M(t.visibilityCache,this._visibilityCacheVersion)){const e=t.node,i=!e||t.ref&&!e.visibilityObb?t.ref??null:e;if(this._layerHasFilter&&this._computeNodeFiltering&&(null!=e||null!=t.ref)&&t.filterImpact===g.NotChecked){const i=null!=e?e.mbs:null!=t.ref?t.ref.mbs:null;t.filterImpact=null!=i?this._computeNodeFiltering(i):g.Unmodified}const s=null!=e&&t.filterImpact===g.Culled,n=!(null!=e&&e.imModificationImpact===_.Culled)&&(!i||this._viewportQueries.isNodeVisible(i))&&!s;return t.visibilityCache=R(n,this._visibilityCacheVersion),n}return E(t.visibilityCache)}isGeometryVisible(e){if(!this.isNodeVisible(e))return!1;const t=this._getNodeInternal(e);return!!(null==t?.node?.geometryObb||this.layerHasModifications&&t.node.imModificationImpact===_.NotChecked)||this._viewportQueries.isGeometryVisible(t.node)}_traverseCoverage(e,t,i,s,n){const o=this._getPage(e);if(null==o||0===t.childCount)return;const r=t.childOffset+t.childCount,a=new Array;for(let l=t.childOffset;l<r;++l){const e=o.children[l],t=this._getNodeInternal(e);null!=t?.node&&this.isGeometryVisible(e)&&a.push(t)}s/=a.length;for(const l of a){const e=l.node.index;this._isLoaded(e)||this._isReloading(e)?(n.delta=Math.max(n.delta,i),n.coverage+=s):this._traverseCoverage(e,l,i+1,s,n)}}useNodeAsHole(e){if("off"===this.holeFilling)return!1;const t=this._getNodeInternal(e);if(null==t)return!1;if("always"===this.holeFilling)return!0;if(M(t.useAsHole,this._version))return E(t.useAsHole);const i={delta:0,coverage:0};this._traverseCoverage(e,t,0,1,i);const s=i.delta*i.coverage<=.5;return t.useAsHole=R(s,this._version),s}get maxLevel(){return this._maxLevel}get dirty(){return this._dirty}destroy(){this._updates.add.prune(),this._updates.update.prune()}requestUpdate(){this._dirty=!0,this._indexMissing=1,this._version=S(this._version)}imModificationsChanged(e){this.layerHasModifications=e,this._forAllNodes((({node:e})=>{null!=e&&(e.imModificationImpact=_.NotChecked,e.visibilityObb=this._computeVisibilityObb(e),e.hasModifications&&this.invalidateGeometryVisibility(e.index))})),this.invalidateVisibilityCache()}layerFilterChanged(e){this._layerHasFilter=e,this._forAllNodes((e=>{if(null!=e){e.filterImpact=g.NotChecked;const t=e.node;null!=t&&this.invalidateNodeVisibilityCache(t.index)}})),this.invalidateVisibilityCache()}update(e,t,i){if(!this._dirty)return;this._pageQueue.length>0&&this._addQueuedPages(t),this._invalidateElevationRangeForNewPages(t),this._maxUnloadedPrio=Number.NEGATIVE_INFINITY,this._maxProcessingPrio=Number.NEGATIVE_INFINITY,this._missingPagesAndNodes.clear(),this._prefetchNodes.clear(),this._updates.reset(e),x.clear();let s=!0;const n=new F,o=new F,r=this._imModificationUncategorized;r.clear();const a=new Set,l=(l,d,h)=>{const u=O(l,this._pageSize);if(a.add(u),null==d){let e=this._entryPriority(l);return e===1/0&&(e=this._entryPriority(h)),x.set(u,Math.max(e,x.get(u)||0)),this._loadingPages.has(u)||this._failedPages.has(u)||this._missingPagesAndNodes.push(u),void(this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e))}const c=d.node;if(this._updateNodeFeatureEstimate(c,o),null==c){const e=this._entryPriority(l);return this._loadingNodes.has(l)||this._failedNodes.has(l)||(this._missingPagesAndNodes.push(l),x.set(l,e)),void(this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e))}const g=this._getPage(l);if(0===this._missingPagesAndNodes.length&&!this._useNodePages)for(let e=0;e<d.childCount;e++){const t=g.children[d.childOffset+e],i=this._getNodeInternal(t);null==i||i.node||this._loadingNodes.has(t)||this._failedNodes.has(t)||(x.set(t,this._entryPriority(t)),this._prefetchNodes.push(t))}if(c.failed||c.resources.isEmpty)return void(s&&d.childCount>0&&this._isSelected(c)&&(s=!1));if(this._isLoaded(l)){if(n.known+=c.memory,++n.knownNodes,this._isSelected(c)?d.childCount>0&&(s=!1):(n.unremoved+=c.memory,s=!1),this._needsUpdate(c)){const e=this._entryPriority(l);x.set(l,e),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e),this._updates.update.push(l)}return}if(c.memory&&(n.known+=c.memory,++n.knownNodes),!this._isSelected(c))return void(this._isReloading(l)&&this._updates.remove.push(l));if(d.childCount>0&&(s=!1),c.memory?(n.missing+=c.memory,n.known+=c.memory,++n.knownNodes):++n.missingNodes,e.includes(c.index))return this._maxProcessingPrio=Math.max(this._maxProcessingPrio,this._entryPriority(l)),void(this._updates.cancel=this._updates.cancel.filter((e=>e!==c.index)));if(!t.done&&this._enable(c))return void t.madeProgress();const f=this._entryPriority(l);x.set(l,f),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,f),this._updates.add.push(l),this.layerHasModifications&&i&&null!=c&&c.imModificationImpact===_.NotChecked&&r.push(l)};this.traverseVisible(l),this._frameNumber++,this._missingPagesAndNodes.sort(((e,t)=>e-t)),this._missingPagesAndNodes.filterInPlace(((e,t)=>t<1||this._missingPagesAndNodes.data[t-1]!==e)),this._missingPagesAndNodes.sort(((e,t)=>x.get(e)-x.get(t))),this._missingPagesAndNodes.length>0&&(this._maxUnloadedPrio=x.get(this._missingPagesAndNodes.back()),this._prefetchNodes.clear());const d=this._updates.add;d.length>0&&this.layerHasModifications&&(r.length>0&&i?.(r),d.filterInPlace((e=>{const t=this._getNodeInternal(e),i=null==t?.node||t.node.imModificationImpact!==_.Culled;return i||this.invalidateNodeVisibilityCache(e),i}))),this._unloadedMemoryEstimate=n.missing-n.unremoved,n.knownNodes>3&&n.missingNodes>0&&(this._unloadedMemoryEstimate+=n.known/n.knownNodes*n.missingNodes),this._unloadedMemoryEstimate=.8*Math.max(0,this._unloadedMemoryEstimate),this._featureEstimate.estimate=this._computeFeatureEstimate(o),this._featureEstimate.leavesReached=s,this._updates.add.filterInPlace((e=>x.get(e)>=this._maxUnloadedPrio)).sort(((e,t)=>x.get(e)-x.get(t))),this._updates.update.sort(((e,t)=>x.get(e)-x.get(t))),this._indexMissing=this._loadingPages.size+this._loadingNodes.size+this._missingPagesAndNodes.length,this._dirty=this._indexMissing>0,x.clear()}checkFeatureTarget(e,t){const i=this._viewportQueries.updateScreenSpaceErrorBias(t);let s=t,n=t,o=i,r=10;for(;r--;){const i=new F;this._updateFeatureEstimate(s,i);if(this._computeFeatureEstimate(i)<=e){if(s>=t||i.missingNodes>0||0===r)break;o=s,s=.5*(s+n)}else n=s,s=.5*(s+o)}return this._version=S(this._version),this._viewportQueries.updateScreenSpaceErrorBias(i),Math.min(t,s)}_updateFeatureEstimate(e,t){this._version=S(this._version),this._viewportQueries.updateScreenSpaceErrorBias(e),this.traverseVisible(((e,i)=>this._updateNodeFeatureEstimate(null!=i?i.node:void 0,t)))}_updateNodeFeatureEstimate(e,t){null==e||e.failed||null==e.numFeatures||this._isSelected(e)&&(null!=e.numFeatures?(t.missing+=e.numFeatures,t.known+=e.numFeatures,++t.knownNodes):++t.missingNodes)}_computeFeatureEstimate(e){let t=e.known-e.unremoved;return e.knownNodes>3&&e.missingNodes>0&&(t+=e.known/e.knownNodes*e.missingNodes),Math.max(0,t)}load(){return this._load(this._missingPagesAndNodes)}prefetch(){return this._prefetchNodes.sort(((e,t)=>x.get(e)-x.get(t))),this._load(this._prefetchNodes)}_load(e){if(0===e.length||!this._canRequest())return!1;for(;e.length>0&&this._canRequest();){const t=e.pop();this._useNodePages&&t>=0?this._loadPage(t):this._loadNode(t)}return!0}get isLoading(){return this._indexMissing>0}get isPrefetching(){return this._prefetchNodes.length>0}get indexLoading(){return this._loadingPages.size+this._loadingNodes.size}get indexMissing(){return this._indexMissing}get unloadedMemoryEstimate(){return this._unloadedMemoryEstimate}get updates(){return this._updates}get featureEstimate(){return this._featureEstimate}get maxPriority(){return Math.max(this._maxProcessingPrio,this._maxUnloadedPrio)}nodeTraversalState(e){if(null==e)return null;const t=e.index,i=this._getNodeInternal(t);if(!i)return null;let s=i?.traversalState;if(s&&M(s.version,this._version))return s;const n=this._viewportQueries.getLodLevel(e),o=this._viewportQueries.hasLOD(e);let r=!0;if(o){const e=this.getParentIndex(t);if(null!=e){const t=this._getNodeInternal(e),i=t?.traversalState;r=!!i&&n>i.lodLevel}else r=n>0}else r=0===e.childCount;return s?(s.lodLevel=n,s.isChosen=r,s.version=R(!0,this._version),s):(s=new f(o,r,n,R(!0,this._version)),i.traversalState=s,s)}async _loadNode(e){this._loadingNodes.add(e);const i=this._getNodeInternal(e).ref;if(null==i)return void this._failedNodes.add(e);const s=i.id,n=this._urlPrefix+s,o=()=>{this._loadingNodes.delete(e),0===this._missingPagesAndNodes.length&&0===this._loadingNodes.size&&this.requestUpdate()};let r=null;try{r=e>=0?await this._streamDataController.request(n,"json"):await this._clientNodeLoader.loadNodeJSON(s)}catch(d){return o(),void(t(d)||(this._logger.error("#loadNode()",this._layer,"Error loading node: "+n),this._failedNodes.add(e)))}o();const a=this._validateNode(s,r);if(null==a)return;a.obb&&this.invalidateNodeVisibilityCache(e);const l=this._addNode(a,e);this.nodeTraversalState(l)}_validateNode(e,t){if(null==t||"object"!=typeof t||t.id!==e)return this._logger.error("#validateNode()",this._layer,`Invalid node. Wrong type or wrong id "${e}"`),null;if(!Array.isArray(t.mbs))return this._logger.error("#validateNode()",this._layer,`Invalid bounding volume on node ${e}.`),null;t.sharedResource&&"./shared"!==t.sharedResource.href&&"./shared/"!==t.sharedResource.href&&this._logger.warn("#validateNode()",this._layer,`Invalid shared resource href on node "${e}"`);const i=t.geometryData;null==i||Array.isArray(i)&&0===i.length||Array.isArray(i)&&1===i.length&&"./geometries/0"===i[0].href||this._logger.warn("#validateNode()",this._layer,`Invalid geometry data on node "${e}"`);const s=t.attributeData,n=this._layer.attributeStorageInfo;null==s||Array.isArray(s)&&!s.some(((e,t)=>e.href!==`./attributes/${n?.[t]?.key??`f_${t}`}/0`))||this._logger.warn("#validateNode()",this._layer,`Invalid attribute data on node "${e}"`),t.featureData&&t.featureData.length>1&&this._logger.warn("#validateNode()",this._layer,`Node ${e} has ${t.featureData.length} bundles. Only the first bundle will be loaded.`);const o=t.hasOwnProperty("obb")&&!this.ignoreServiceObb?t.obb:null,r=t.featureData&&1===t.featureData.length&&t.featureData[0].featureRange?t.featureData[0].featureRange[1]-t.featureData[0].featureRange[0]+1:void 0,a=t=>{if(null==t)return null;const i=t=>this._logger.error("#validateNode()",this._layer,`Invalid node reference on node ${e}: ${t}`);if("number"==typeof t.id)i(`id ${t.id} is a number instead of a string.`);else if("string"!=typeof t.id||!Array.isArray(t.mbs))return i("Missing or invalid id."),null;if(!Array.isArray(t.mbs))return i(`Invalid bounding volume on reference ${t.id}.`),null;t.href&&t.href!=="../"+t.id&&this._logger.error("#validateNode()",this._layer,`Invalid node href on node "${e}"`);const s=t.hasOwnProperty("obb")&&!this.ignoreServiceObb?t.obb:null,n=new u(`${t.id}`,t.mbs);return n.serviceObb=s,n.visibilityObb=this._computeVisibilityObb(n),n},l=Array.isArray(t.children)?t.children.map(a).filter((e=>null!=e)):null,d=t.featureData?.length??!1,h=!0===t.isEmpty;return{id:e,mbs:t.mbs,obb:o,children:l,resources:{isEmpty:!d&&h,hasSharedResource:null!=t.sharedResource,attributes:t.attributeData?e:void 0,texture:t.textureData&&t.textureData.length>0?e:void 0,geometry:null!=t.geometryData?e:void 0},version:"string"==typeof t.version?t.version:null,lodSelection:Array.isArray(t.lodSelection)?t.lodSelection:null,numFeatures:r}}resetFailedNodes(){this._failedNodes.clear(),this._failedPages.clear(),this._forAllNodes((e=>{null!=e.node&&(e.node.failed=!1)}))}_entryPriority(e){const t=this._getNodeInternal(e),i=this.getParentIndex(e);if(null==t||null==i&&null==t.node)return null==i?1/0:this._entryPriority(i);let s=0;if(t.node&&null!=i){const e=this._getNodeInternal(i).traversalState;null!=e&&(s=e.lodLevel)}let n=this.progressiveLoadPenalty;for(let r=e;null!=r;r=this.getParentIndex(r))if(this._isLoaded(r)){n=0;break}const o=null!=t.ref?this._viewportQueries.distToPOI(t.ref):null!=t.node?this._viewportQueries.distToPOI(t.node):0;return-o-s*(o+this.progressiveLoadPenalty)+n}traverseVisible(e){const t=this._getNodeInternal(this._rootIndex);null!=t?this._traverseVisible(this._rootIndex,null,t,e):e(this._rootIndex,null,null)}_traverseVisible(e,t,i,s){if(i.node&&0===i.childCount)return void(this.isGeometryVisible(e)&&s(e,i,t));if(!this.isNodeVisible(e))return;if(s(e,i,t),null==i.node)return;const n=this.nodeTraversalState(i.node);if(n?.nodeHasLOD&&n.lodLevel===this._maxLodLevel)return;const o=this._getPage(e);for(let r=0;r<i.childCount;r++){const t=o.children[i.childOffset+r],n=this._getNodeInternal(t);n?this._traverseVisible(t,e,n,s):s(t,null,e)}}traverse(e,t){t(e)&&this.traverseChildren(e,t)}traverseChildren(e,t){const i=e.index,s=this._getNodeInternal(i);null!=s&&this._traverseChildren(i,s,t)}_traverseChildren(e,t,i){const s=this._getPage(e);if(null==s)return;const n=t.childOffset+t.childCount;for(let o=t.childOffset;o<n;++o){const e=s.children[o],t=this._getNodeInternal(e);null!=t?.node&&i(t.node)&&this._traverseChildren(e,t,i)}}updateChildrenLoaded(e,t){let i=this.getNode(e);for(;null!=i;){const e=i.childrenLoaded,s=e+t;i.childrenLoaded=s;const n=0===e?1:0===s?-1:0,o=i.index;if(0!==n){this._getPage(o).numNodesWithLoadedChildren+=n}i=this.getParent(o)}}checkChildrenLoadedInvariant(){if(null==this.rootNode)return!0;const e=[],t=i=>{let s=this._isLoaded(i.index)||this._isReloading(i.index)?1:0;return this.traverseChildren(i,(e=>(s+=t(e),!1))),i.childrenLoaded!==s&&e.push(i.index),s};return t(this.rootNode),e.length&&this._logger.error("childrenLoaded invariant broken at following nodes: "+e.join(",")),e.length>0}updateStats(e){if(this._updates.add.length>0&&(e.nodes+=" + "+this._updates.add.length),e.index=this._nodePages.size*(this._pageSize||1)+(this._clientNodePage?.nodes.length??0),e.prio=this._maxProcessingPrio,(this._indexMissing||this._prefetchNodes.length>0)&&(e.index+=" + "+this._indexMissing||this._prefetchNodes.length),this._featureEstimate.estimate){const t=this._featureEstimate.estimate-e.features;t>0?e.features+=" + "+t:t<0&&(e.features+=" - "+-t)}}updateElevationInfo(e,t){this.needNodeElevationRange=t&&!!e&&("relative-to-ground"===e.mode||"on-the-ground"===e.mode),this._viewportQueries.updateElevationInfo(e),this.invalidateAllElevationRanges()}invalidateAllElevationRanges(){this._forAllNodes((e=>{C(e),null!=e.node&&e.node.invalidateElevationRange(),null!=e.ref&&e.ref.invalidateElevationRange()}))}_forAllNodes(e){if(null!=this._clientNodePage){const t=this._clientNodePage;for(let i=0;i<t.nodes.length;i++)e(t.nodes[i],-(i+1))}for(const[t,i]of this._nodePages){const s=t*this._pageSize;for(let t=0;t<i.nodes.length;t++)e(i.nodes[t],s+t)}}clearCaches(){if(this._useNodePages){const e=this._nodePages,t=new Set;this.traverseVisible((e=>t.add(O(e,this._pageSize))));for(const[i,s]of e)if(0!==s.numNodesWithLoadedChildren||t.has(i))for(const e of s.nodes)e.traversalState=null;else this._deleteNodePage(i)}}_deleteNodePage(e){this._nodePages.delete(e)}get test(){return{addNode:(e,t)=>this._addNode(e,t),getNodeInternal:e=>this._getNodeInternal(e),getPageIndex:e=>O(e,this._pageSize),getIndexWithinPage:e=>A(e,this._pageSize),getNodePage:e=>e<0?this._clientNodePage:this._nodePages.get(e),getChildIndices:e=>{const t=this._getNodeInternal(e),i=this._getPage(e);if(null==t||null==i)return[];const s=[];for(let n=t.childOffset;n<t.childOffset+t.childCount;++n)s.push(i.children[n]);return s},rootIndex:this._rootIndex,clientNodePage:this._clientNodePage,nodePages:this._nodePages}}}const x=new Map;class I{constructor(t){this.missing=t,this.update=new e({deallocator:null}),this.add=new e({deallocator:null}),this.remove=new e({deallocator:null}),this.cancel=[]}reset(e){this.add.clear(),this.update.clear(),this.cancel=e}}function C(e){null!=e.node&&(m(e.node.renderMbs),v(e.node.serviceObbInRenderSR)),null!=e.ref&&(m(e.ref.renderMbs),v(e.ref.serviceObbInRenderSR))}function w(e){return N(e,-2)}function S(e){return N(e,2)}function R(e,t){return t+(e?1:0)}function M(e,t){return(-2&e)===t}function E(e){return 1==(1&e)}function O(e,t){return e<0?-1:t>0?e/t|0:0}function A(e,t){return e<0?-e-1:0===t?e:e%t}function V(e,t,i){return-1===t?-(e+1):0===i?e:t*i+e}const L=[["maxScreenThreshold",h.MaxScreenThreshold],["screenSpaceRelative",h.ScreenSpaceRelative],["removedFeatureDiameter",h.RemovedFeatureDiameter],["distanceRangeFromDefaultCamera",h.DistanceRangeFromDefaultCamera]];function k(e){if(e)for(let t=0;t<e.length;t++)for(const i of L)if(i[0]===e[t].metricType)return{lodMetric:i[1],maxError:e[t].maxError};return{lodMetric:h.None,maxError:0}}class F{constructor(){this.known=0,this.knownNodes=0,this.missing=0,this.missingNodes=0,this.unremoved=0}}function z(e){return Math.sqrt(e*(4/Math.PI))}const D=a(),T=a(),Q=a(),U=a();export{P as I3SIndex,k as selectErrorMetric};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import{createTask as p}from"../core/asyncUtils.js";import{deprecated as t}from"../core/deprecate.js";import i from"../core/Error.js";import s from"../core/Logger.js";import{eachAlwaysValues as o,throwIfAborted as r}from"../core/promiseUtils.js";import{watch as a,initial as n,whenOnce as u}from"../core/reactiveUtils.js";import{property as l}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as c}from"../core/accessorSupport/decorators/subclass.js";import{ViewEventPriorities as h}from"./input/InputManager.js";function d(e){return null!=e&&"open"in e&&"declaredClass"in e}function y(e){return null!=e&&"declaredClass"in e&&"dockOptions"in e}const w=w=>{let m=class extends w{constructor(){super(...arguments),this._popupSetupTask=null,this.popup={},this.popupEnabled=!0}initialize(){this.addHandles([a((()=>[this.ui,this.popup]),(([e,p],t)=>{const i="popup",s="manual";if(t){const[e,p]=t;e&&d(p)&&(p.view=null,y(p)&&e.remove(p,i))}e&&d(p)&&(p.view=this,y(p)&&e.add(p,{key:i,position:s,internal:!0}))}),n),this.on("click",(e=>{this.popup&&this.popupEnabled&&("mouse"!==e.pointerType||0===e.button)&&(!d(this.popup)&&"autoOpenEnabled"in this.popup&&!1===this.popup.autoOpenEnabled||(d(this.popup)?this.popup.viewModel.handleViewClick(e):e.async((async()=>{await this.setupPopup(),d(this.popup)&&!this.destroyed&&this.ready&&this.popupEnabled&&this.popup.viewModel.handleViewClick(e)}))))}),h.WIDGET)]),u((()=>this.ready&&this.popupEnabled&&!this.updating)).then((()=>{import("../widgets/Popup.js")}))}destroy(){this.destroyed||this.closePopup()}async openPopup(e){d(this.popup)&&this.popup.open(e);try{if(await this.setupPopup(),!this.popup)return void s.getLogger(this).error(new i("view:null-popup","Popup is null and can't be opened"));this.popup.open(e)}catch{}}closePopup(){this._popupSetupTask?.abort(),d(this.popup)&&this.popup.close()}async fetchPopupFeatures(e,p){await this.when();const{location:t,queryArea:i,layerViewsAndGraphics:s,clientOnlyGraphics:r}=await this._prepareFetchPopupFeatures(e,p),a=Promise.resolve(r),n=this._queryLayerPopupFeatures(i,s,p),u=n.map((e=>e.promise));return{location:t,clientOnlyGraphics:r,allGraphicsPromise:o([a,...u]).then((e=>Array.from(new Set(e.flat())))),promisesPerLayerView:n}}async setupPopup(){if(this._popupSetupTask?.abort(),this.popup&&!d(this.popup))return this._popupSetupTask=p((async e=>{const{default:p}=await import("../widgets/Popup.js");if(r(e),!this.popup||d(this.popup))return;const t=this.popup;delete t.open,delete t.close,this.popup=new p(t)})),this._popupSetupTask.promise}_queryLayerPopupFeatures(e,p,t){return p.map((({layerView:p,graphics:i})=>{const s={clientGraphics:i,event:null!=t?t.event:void 0,signal:null!=t?t.signal:void 0,defaultPopupTemplateEnabled:null!=t&&!!t.defaultPopupTemplateEnabled},o=p.fetchPopupFeatures(e,s);return{layerView:p,promise:o}}))}_isValidPopupGraphic(e,p){return e&&!!e.getEffectivePopupTemplate(null!=p&&p.defaultPopupTemplateEnabled)}async _prepareFetchPopupFeatures(e,p){const{clientGraphics:t,queryArea:i,location:s}=await this._popupHitTestGraphics(e,p),o=this._getFetchPopupLayerViews(),{layerViewsAndGraphics:r,clientOnlyGraphics:a}=this._graphicsPerFetchPopupLayerView(t,o);return{clientOnlyGraphics:a,layerViewsAndGraphics:r,queryArea:i,location:s}}async _popupHitTestGraphics(e,p){const t=await this.popupHitTest(e),i=t.results,s=t.mapPoint,o=i.filter((e=>"graphic"===e.type&&this._isValidPopupGraphic(e.graphic,p))),r=o.length?o[0].mapPoint:null;return{clientGraphics:o.map((e=>e.graphic)),queryArea:s,location:s||r}}_getFetchPopupLayerViews(){const e=[];return this.allLayerViews.forEach((p=>{this._isValidPopupLayerView(p)&&e.push(p)})),null!=this.graphicsView&&this._isValidPopupLayerView(this.graphicsView)&&e.push(this.graphicsView),e.reverse()}_isValidPopupLayerView(e){return null!=e&&(!("layer"in e)||!e.suspended)&&"fetchPopupFeatures"in e}_graphicsPerFetchPopupLayerView(e,p){const t=[],i=new Map,s=p.map((e=>{const p=[];return"layer"in e?i.set(e.layer,p):i.set(e.graphics,p),{layerView:e,graphics:p}}));for(const o of e){const e=i.get(o.layer)||i.get(o.sourceLayer)||null;e?e.push(o):t.push(o)}return{layerViewsAndGraphics:s,clientOnlyGraphics:t}}};return e([l({cast(e){return!e||d(e)||"object"==typeof e&&(e.open=e=>(t(s.getLogger(this),"view.popup is no longer created by default. view.popup.open() will stop working when the popup isn't created",{replacement:"Use view.openPopup() instead.",version:"4.27"}),this.openPopup(e)),e.close=()=>(t(s.getLogger(this),"view.popup is no longer created by default. view.popup.close() will stop working when the popup isn't created",{replacement:"Use view.closePopup() instead.",version:"4.27"}),this.closePopup())),e}})],m.prototype,"popup",void 0),e([l()],m.prototype,"popupEnabled",void 0),m=e([c("esri.views.PopupView")],m),m};export{w as PopupView};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import{createTask as p}from"../core/asyncUtils.js";import{deprecated as t}from"../core/deprecate.js";import i from"../core/Error.js";import s from"../core/Logger.js";import{eachAlwaysValues as o,throwIfAborted as r}from"../core/promiseUtils.js";import{watch as a,initial as n,whenOnce as u}from"../core/reactiveUtils.js";import{property as l}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as c}from"../core/accessorSupport/decorators/subclass.js";import{ViewEventPriorities as h}from"./input/InputManager.js";function d(e){return null!=e&&"open"in e&&"declaredClass"in e}function y(e){return null!=e&&"declaredClass"in e&&"dockOptions"in e}const w=w=>{let m=class extends w{constructor(){super(...arguments),this._popupSetupTask=null,this.popup={},this.popupEnabled=!0}initialize(){this.addHandles([a((()=>[this.ui,this.popup]),(([e,p],t)=>{const i="popup",s="manual";if(t){const[e,p]=t;e&&d(p)&&(p.view=null,y(p)&&e.remove(p,i))}e&&d(p)&&(p.view=this,y(p)&&e.add(p,{key:i,position:s,internal:!0}))}),n),this.on("click",(e=>{this.popup&&this.popupEnabled&&("mouse"!==e.pointerType||0===e.button)&&(!d(this.popup)&&"autoOpenEnabled"in this.popup&&!1===this.popup.autoOpenEnabled||(d(this.popup)?this.popup.viewModel.handleViewClick(e):e.async((async()=>{await this.setupPopup(),d(this.popup)&&!this.destroyed&&this.ready&&this.popupEnabled&&this.popup.viewModel.handleViewClick(e)}))))}),h.WIDGET)]),u((()=>this.ready&&this.popupEnabled&&!this.updating)).then((()=>{import("../widgets/Popup.js")}))}destroy(){this.destroyed||this.closePopup()}async openPopup(e){if(d(this.popup))return this.popup.open(e);try{if(await this.setupPopup(),!this.popup)return void s.getLogger(this).error(new i("view:null-popup","Popup is null and can't be opened"));this.popup.open(e)}catch{}}closePopup(){this._popupSetupTask?.abort(),d(this.popup)&&this.popup.close()}async fetchPopupFeatures(e,p){await this.when();const{location:t,queryArea:i,layerViewsAndGraphics:s,clientOnlyGraphics:r}=await this._prepareFetchPopupFeatures(e,p),a=Promise.resolve(r),n=this._queryLayerPopupFeatures(i,s,p),u=n.map((e=>e.promise));return{location:t,clientOnlyGraphics:r,allGraphicsPromise:o([a,...u]).then((e=>Array.from(new Set(e.flat())))),promisesPerLayerView:n}}async setupPopup(){if(this._popupSetupTask?.abort(),this.popup&&!d(this.popup))return this._popupSetupTask=p((async e=>{const{default:p}=await import("../widgets/Popup.js");if(r(e),!this.popup||d(this.popup))return;const t=this.popup;delete t.open,delete t.close,this.popup=new p(t)})),this._popupSetupTask.promise}_queryLayerPopupFeatures(e,p,t){return p.map((({layerView:p,graphics:i})=>{const s={clientGraphics:i,event:null!=t?t.event:void 0,signal:null!=t?t.signal:void 0,defaultPopupTemplateEnabled:null!=t&&!!t.defaultPopupTemplateEnabled},o=p.fetchPopupFeatures(e,s);return{layerView:p,promise:o}}))}_isValidPopupGraphic(e,p){return e&&!!e.getEffectivePopupTemplate(null!=p&&p.defaultPopupTemplateEnabled)}async _prepareFetchPopupFeatures(e,p){const{clientGraphics:t,queryArea:i,location:s}=await this._popupHitTestGraphics(e,p),o=this._getFetchPopupLayerViews(),{layerViewsAndGraphics:r,clientOnlyGraphics:a}=this._graphicsPerFetchPopupLayerView(t,o);return{clientOnlyGraphics:a,layerViewsAndGraphics:r,queryArea:i,location:s}}async _popupHitTestGraphics(e,p){const t=await this.popupHitTest(e),i=t.results,s=t.mapPoint,o=i.filter((e=>"graphic"===e.type&&this._isValidPopupGraphic(e.graphic,p))),r=o.length?o[0].mapPoint:null;return{clientGraphics:o.map((e=>e.graphic)),queryArea:s,location:s||r}}_getFetchPopupLayerViews(){const e=[];return this.allLayerViews.forEach((p=>{this._isValidPopupLayerView(p)&&e.push(p)})),null!=this.graphicsView&&this._isValidPopupLayerView(this.graphicsView)&&e.push(this.graphicsView),e.reverse()}_isValidPopupLayerView(e){return null!=e&&(!("layer"in e)||!e.suspended)&&"fetchPopupFeatures"in e}_graphicsPerFetchPopupLayerView(e,p){const t=[],i=new Map,s=p.map((e=>{const p=[];return"layer"in e?i.set(e.layer,p):i.set(e.graphics,p),{layerView:e,graphics:p}}));for(const o of e){const e=i.get(o.layer)||i.get(o.sourceLayer)||null;e?e.push(o):t.push(o)}return{layerViewsAndGraphics:s,clientOnlyGraphics:t}}};return e([l({cast(e){return!e||d(e)||"object"==typeof e&&(e.open=e=>(t(s.getLogger(this),"view.popup is no longer created by default. view.popup.open() will stop working when the popup isn't created",{replacement:"Use view.openPopup() instead.",version:"4.27"}),this.openPopup(e)),e.close=()=>(t(s.getLogger(this),"view.popup is no longer created by default. view.popup.close() will stop working when the popup isn't created",{replacement:"Use view.closePopup() instead.",version:"4.27"}),this.closePopup())),e}})],m.prototype,"popup",void 0),e([l()],m.prototype,"popupEnabled",void 0),m=e([c("esri.views.PopupView")],m),m};export{w as PopupView};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../chunks/tslib.es6.js";import"../../../../../geometry.js";import t from"../../../../../core/Evented.js";import{createResolver as i,throwIfAborted as s}from"../../../../../core/promiseUtils.js";import{watch as r,whenOnce as n,sync as a}from"../../../../../core/reactiveUtils.js";import{property as o}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import{subclass as l}from"../../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as d}from"../../../../../core/support/UpdatingHandles.js";import p from"../../../../../geometry/SpatialReference.js";import u from"../../../../../layers/graphics/data/FeatureStore.js";import{QueryEngine as c}from"../../../../../layers/graphics/data/QueryEngine.js";import h from"../../../../../layers/support/TileInfo.js";import f from"../../../../../rest/support/Query.js";import g from"../../../../../symbols/support/ElevationInfo.js";import{getSnappingCandidateElevationAligner as m}from"../snappingCandidateElevationAlignment.js";import{getSnappingCandidateElevationFilter as y}from"../snappingCandidateElevationFilter.js";import{getSymbologySnappingCandidatesFetcher as _}from"../symbologySnappingCandidates.js";import{FeatureServiceTiledFetcher as S}from"./FeatureServiceTiledFetcher.js";import{FeatureServiceTileStore as F}from"./FeatureServiceTileStore.js";import{fromJSON as v}from"../../../../../geometry/support/jsonUtils.js";let w=class extends t.EventedAccessor{constructor(){super(...arguments),this._isInitializing=!0,this.remoteClient=null,this._whenSetup=i(),this._elevationAligner=m(),this._elevationFilter=y(),this._symbologyCandidatesFetcher=_(),this._updatingHandles=new d,this._editsUpdatingHandles=new d,this._pendingApplyEdits=new Map,this._alignPointsInFeatures=async(e,t)=>{const i={query:e},r=await this.remoteClient.invoke("alignElevation",i,{signal:t});return s(t),r},this._getSymbologyCandidates=async(e,t)=>{const i={candidates:e,spatialReference:this._spatialReference.toJSON()},r=await this.remoteClient.invoke("getSymbologyCandidates",i,{signal:t});return s(t),r}}get updating(){return this.updatingExcludingEdits||this._editsUpdatingHandles.updating||this._featureFetcher.updating}get updatingExcludingEdits(){return this._featureFetcher.updatingExcludingEdits||this._isInitializing||this._updatingHandles.updating}destroy(){this._featureFetcher?.destroy(),this._queryEngine?.destroy(),this._featureStore?.clear()}async setup(e){if(this.destroyed)return{result:{}};const{geometryType:t,objectIdField:i,timeInfo:s,fieldsIndex:n}=e.serviceInfo,{hasZ:o}=e,l=p.fromJSON(e.spatialReference);this._spatialReference=l,this._featureStore=new u({...e.serviceInfo,hasZ:o,hasM:!1}),this._queryEngine=new c({spatialReference:e.spatialReference,featureStore:this._featureStore,geometryType:t,fieldsIndex:n,hasZ:o,hasM:!1,objectIdField:i,timeInfo:s}),this._featureFetcher=new S({store:new F({featureStore:this._featureStore}),url:e.serviceInfo.url,objectIdField:e.serviceInfo.objectIdField,globalIdField:e.serviceInfo.globalIdField,capabilities:e.serviceInfo.capabilities,spatialReference:l,sourceSpatialReference:p.fromJSON(e.serviceInfo.spatialReference)});const d="3d"===e.configuration.viewType;return this._elevationAligner=m(d,{elevationInfo:null!=e.elevationInfo?g.fromJSON(e.elevationInfo):null,alignPointsInFeatures:this._alignPointsInFeatures}),this._elevationFilter=y(d),this.addHandles([r((()=>this._featureFetcher.availability),(e=>this.emit("notify-availability",{availability:e})),a),r((()=>this.updating),(()=>this._notifyUpdating()))]),this._whenSetup.resolve(),this._isInitializing=!1,this.configure(e.configuration)}async configure(e){return await this._updatingHandles.addPromise(this._whenSetup.promise),this._updateFeatureFetcherConfiguration(e),j}async setSuspended(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),s(t),this._featureFetcher.suspended=e,j}async updateOutFields(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),s(t),this._featureFetcher.outFields=new Set(e??[]),j}async fetchCandidates(e,t){await this._whenSetup.promise,s(t);const i=b(e),r=t?.signal,n=await this._queryEngine.executeQueryForSnapping(i,r);s(r);const a=await this._elevationAligner.alignCandidates(n.candidates,e.point.spatialReference??p.WGS84,r);s(r);const o=await this._symbologyCandidatesFetcher.fetch(a,r);s(r);const l=0===o.length?a:a.concat(o);return{result:{candidates:this._elevationFilter.filter(i,l)}}}async updateTiles(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),s(t),this._featureFetcher.tileSize=e.tileSize,this._featureFetcher.tilesOfInterest=e.tiles,this._featureFetcher.tileInfo=null!=e.tileInfo?h.fromJSON(e.tileInfo):null,j}async refresh(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),s(t),this._featureFetcher.refresh(),j}async whenNotUpdating(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),s(t),await n((()=>!this.updatingExcludingEdits),t),s(t),j}async getDebugInfo(e,t){return s(t),{result:this._featureFetcher.debugInfo}}async beginApplyEdits(e,t){this._updatingHandles.addPromise(this._whenSetup.promise),s(t);const r=i();return this._pendingApplyEdits.set(e.id,r),this._featureFetcher.applyEdits(r.promise),this._editsUpdatingHandles.addPromise(r.promise),j}async endApplyEdits(e,t){const i=this._pendingApplyEdits.get(e.id);return i&&i.resolve(e.edits),s(t),j}async notifyElevationSourceChange(e,t){return this._elevationAligner.notifyElevationSourceChange(),j}async notifySymbologyChange(e,t){return this._symbologyCandidatesFetcher.notifySymbologyChange(),j}async setSymbologySnappingSupported(e){return this._symbologyCandidatesFetcher=_(e,this._getSymbologyCandidates),j}_updateFeatureFetcherConfiguration(e){this._featureFetcher.filter=null!=e.filter?f.fromJSON(e.filter):null,this._featureFetcher.customParameters=e.customParameters}_notifyUpdating(){this.emit("notify-updating",{updating:this.updating})}};e([o({readOnly:!0})],w.prototype,"updating",null),e([o({readOnly:!0})],w.prototype,"updatingExcludingEdits",null),e([o()],w.prototype,"_isInitializing",void 0),w=e([l("esri.views.interactive.snapping.featureSources.featureServiceSource.FeatureServiceSnappingSourceWorker")],w);const I=w;function b(e){if(!e.filter)return{...e,query:{where:"1=1"}};const{distance:t,units:i,spatialRel:s,where:r,timeExtent:n,objectIds:a}=e.filter,o={geometry:e.filter.geometry?v(e.filter.geometry):void 0,distance:t,units:i,spatialRel:s,timeExtent:n,objectIds:a,where:r??"1=1"};return{...e,query:o}}const j={result:{}};export{I as default};
5
+ import{_ as e}from"../../../../../chunks/tslib.es6.js";import"../../../../../geometry.js";import t from"../../../../../core/Evented.js";import{createResolver as i,throwIfAborted as s}from"../../../../../core/promiseUtils.js";import{watch as r,whenOnce as n,sync as a}from"../../../../../core/reactiveUtils.js";import{property as o}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import{subclass as l}from"../../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as d}from"../../../../../core/support/UpdatingHandles.js";import p from"../../../../../geometry/SpatialReference.js";import u from"../../../../../layers/graphics/data/FeatureStore.js";import{QueryEngine as c}from"../../../../../layers/graphics/data/QueryEngine.js";import h from"../../../../../layers/support/TileInfo.js";import f from"../../../../../rest/support/Query.js";import g from"../../../../../symbols/support/ElevationInfo.js";import{getSnappingCandidateElevationAligner as m}from"../snappingCandidateElevationAlignment.js";import{getSnappingCandidateElevationFilter as y}from"../snappingCandidateElevationFilter.js";import{getSymbologySnappingCandidatesFetcher as _}from"../symbologySnappingCandidates.js";import{FeatureServiceTiledFetcher as S}from"./FeatureServiceTiledFetcher.js";import{FeatureServiceTileStore as F}from"./FeatureServiceTileStore.js";import{fromJSON as v}from"../../../../../geometry/support/jsonUtils.js";let w=class extends t.EventedAccessor{constructor(){super(...arguments),this._isInitializing=!0,this.remoteClient=null,this._whenSetup=i(),this._elevationAligner=m(),this._elevationFilter=y(),this._symbologyCandidatesFetcher=_(),this._updatingHandles=new d,this._editsUpdatingHandles=new d,this._pendingApplyEdits=new Map,this._alignPointsInFeatures=async(e,t)=>{const i={query:e},r=await this.remoteClient.invoke("alignElevation",i,{signal:t});return s(t),r},this._getSymbologyCandidates=async(e,t)=>{const i={candidates:e,spatialReference:this._spatialReference.toJSON()},r=await this.remoteClient.invoke("getSymbologyCandidates",i,{signal:t});return s(t),r}}get updating(){return this.updatingExcludingEdits||this._editsUpdatingHandles.updating||this._featureFetcher.updating}get updatingExcludingEdits(){return this._featureFetcher.updatingExcludingEdits||this._isInitializing||this._updatingHandles.updating}destroy(){this._featureFetcher?.destroy(),this._queryEngine?.destroy(),this._featureStore?.clear()}async setup(e){if(this.destroyed)return{result:{}};const{geometryType:t,objectIdField:i,timeInfo:s,fieldsIndex:n}=e.serviceInfo,{hasZ:o}=e,l=p.fromJSON(e.spatialReference);this._spatialReference=l,this._featureStore=new u({...e.serviceInfo,hasZ:o,hasM:!1}),this._queryEngine=new c({spatialReference:e.spatialReference,featureStore:this._featureStore,geometryType:t,fieldsIndex:n,hasZ:o,hasM:!1,objectIdField:i,timeInfo:s}),this._featureFetcher=new S({store:new F({featureStore:this._featureStore}),url:e.serviceInfo.url,objectIdField:e.serviceInfo.objectIdField,globalIdField:e.serviceInfo.globalIdField,capabilities:e.serviceInfo.capabilities,spatialReference:l,sourceSpatialReference:p.fromJSON(e.serviceInfo.spatialReference)});const d="3d"===e.configuration.viewType;return this._elevationAligner=m(d,{elevationInfo:null!=e.elevationInfo?g.fromJSON(e.elevationInfo):null,alignPointsInFeatures:this._alignPointsInFeatures}),this._elevationFilter=y(d),this.addHandles([r((()=>this._featureFetcher.availability),(e=>this.emit("notify-availability",{availability:e})),a),r((()=>this.updating),(()=>this._notifyUpdating()))]),this._whenSetup.resolve(),this._isInitializing=!1,this.configure(e.configuration)}async configure(e){return await this._updatingHandles.addPromise(this._whenSetup.promise),this._updateFeatureFetcherConfiguration(e),j}async setSuspended(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),s(t),this._featureFetcher.suspended=e,j}async updateOutFields(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),s(t),this._featureFetcher.outFields=new Set(e??[]),j}async fetchCandidates(e,t){await this._whenSetup.promise,s(t);const i=b(e),r=t?.signal,n=await this._queryEngine.executeQueryForSnapping(i,r);s(r);const a=await this._elevationAligner.alignCandidates(n.candidates,p.fromJSON(e.point.spatialReference)??p.WGS84,r);s(r);const o=await this._symbologyCandidatesFetcher.fetch(a,r);s(r);const l=0===o.length?a:a.concat(o);return{result:{candidates:this._elevationFilter.filter(i,l)}}}async updateTiles(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),s(t),this._featureFetcher.tileSize=e.tileSize,this._featureFetcher.tilesOfInterest=e.tiles,this._featureFetcher.tileInfo=null!=e.tileInfo?h.fromJSON(e.tileInfo):null,j}async refresh(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),s(t),this._featureFetcher.refresh(),j}async whenNotUpdating(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),s(t),await n((()=>!this.updatingExcludingEdits),t),s(t),j}async getDebugInfo(e,t){return s(t),{result:this._featureFetcher.debugInfo}}async beginApplyEdits(e,t){this._updatingHandles.addPromise(this._whenSetup.promise),s(t);const r=i();return this._pendingApplyEdits.set(e.id,r),this._featureFetcher.applyEdits(r.promise),this._editsUpdatingHandles.addPromise(r.promise),j}async endApplyEdits(e,t){const i=this._pendingApplyEdits.get(e.id);return i&&i.resolve(e.edits),s(t),j}async notifyElevationSourceChange(e,t){return this._elevationAligner.notifyElevationSourceChange(),j}async notifySymbologyChange(e,t){return this._symbologyCandidatesFetcher.notifySymbologyChange(),j}async setSymbologySnappingSupported(e){return this._symbologyCandidatesFetcher=_(e,this._getSymbologyCandidates),j}_updateFeatureFetcherConfiguration(e){this._featureFetcher.filter=null!=e.filter?f.fromJSON(e.filter):null,this._featureFetcher.customParameters=e.customParameters}_notifyUpdating(){this.emit("notify-updating",{updating:this.updating})}};e([o({readOnly:!0})],w.prototype,"updating",null),e([o({readOnly:!0})],w.prototype,"updatingExcludingEdits",null),e([o()],w.prototype,"_isInitializing",void 0),w=e([l("esri.views.interactive.snapping.featureSources.featureServiceSource.FeatureServiceSnappingSourceWorker")],w);const I=w;function b(e){if(!e.filter)return{...e,query:{where:"1=1"}};const{distance:t,units:i,spatialRel:s,where:r,timeExtent:n,objectIds:a}=e.filter,o={geometry:e.filter.geometry?v(e.filter.geometry):void 0,distance:t,units:i,spatialRel:s,timeExtent:n,objectIds:a,where:r??"1=1"};return{...e,query:o}}const j={result:{}};export{I as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../core/has.js";import{LRUCache as e}from"../../../../core/LRUCache.js";import{getOrCreateMapValue as t}from"../../../../core/MapUtils.js";import{throwIfAborted as s}from"../../../../core/promiseUtils.js";import{getMetersPerVerticalUnitForSR as n}from"../../../../core/unitUtils.js";import{getMetersPerUnit as o}from"../../../../symbols/support/unitConversionUtils.js";function i(e=!1,t){if(e){const{elevationInfo:e,alignPointsInFeatures:s}=t;return new c(e,s)}return new a}class a{async alignCandidates(e,t,s){return e}notifyElevationSourceChange(){}}const r=1024;class c{constructor(t,s){this._elevationInfo=t,this._alignPointsInFeatures=s,this._alignmentsCache=new e(r),this._cacheVersion=0}async alignCandidates(e,t,s){const n=this._elevationInfo;return null==n||"absolute-height"!==n.mode||n.featureExpressionInfo?this._alignComputedElevationCandidates(e,t,s):(this._alignAbsoluteElevationCandidates(e,t,n),e)}notifyElevationSourceChange(){this._alignmentsCache.clear(),this._cacheVersion++}_alignAbsoluteElevationCandidates(e,t,s){const{offset:i,unit:a}=s;if(null==i)return;const r=n(t),c=i*(o(a??"meters")/r);for(const n of e)switch(n.type){case"edge":n.start.z+=c,n.end.z+=c;continue;case"vertex":n.target.z+=c;continue}}async _alignComputedElevationCandidates(e,n,o){const i=new Map;for(const s of e)t(i,s.objectId,d).push(s);const[a,r,c]=this._prepareQuery(i,n),l=await this._alignPointsInFeatures(a,o);s(o);if(c!==this._cacheVersion)return this._alignComputedElevationCandidates(e,n,o);this._applyCacheAndResponse(a,l,r);const{drapedObjectIds:h,failedObjectIds:u}=l,p=[];for(const t of e){const{objectId:e}=t;h.has(e)&&"edge"===t.type&&(t.draped=!0),u.has(e)||p.push(t)}return p}_prepareQuery(e,t){const s=[],n=[];for(const[o,i]of e){const e=[];for(const t of i)this._addToQueriesOrCachedResult(o,t.target,e,n),"edge"===t.type&&(this._addToQueriesOrCachedResult(o,t.start,e,n),this._addToQueriesOrCachedResult(o,t.end,e,n));0!==e.length&&s.push({objectId:o,points:e})}return[{spatialReference:t,pointsInFeatures:s},n,this._cacheVersion]}_addToQueriesOrCachedResult(e,t,s,n){const o=h(e,t),i=this._alignmentsCache.get(o);null==i?s.push(t):n.push(new l(t,i))}_applyCacheAndResponse(e,{elevations:t,drapedObjectIds:s,failedObjectIds:n},o){for(const r of o)r.apply();let i=0;const a=this._alignmentsCache;for(const{objectId:r,points:c}of e.pointsInFeatures){if(n.has(r)){i+=c.length;continue}const e=!s.has(r);for(const s of c){const n=h(r,s),o=t[i++];s.z=o,e&&a.put(n,o,1)}}}}class l{constructor(e,t){this.point=e,this.z=t}apply(){this.point.z=this.z}}function h(e,{x:t,y:s,z:n,spatialReference:o}){return`${e}-${t}-${s}-${n??0}}-wkid:${o?.wkid}`}function d(){return[]}export{i as getSnappingCandidateElevationAligner};
5
+ import"../../../../core/has.js";import{LRUCache as e}from"../../../../core/LRUCache.js";import{getOrCreateMapValue as t}from"../../../../core/MapUtils.js";import{throwIfAborted as s}from"../../../../core/promiseUtils.js";import{getMetersPerVerticalUnitForSR as n}from"../../../../core/unitUtils.js";import{getMetersPerUnit as o}from"../../../../symbols/support/unitConversionUtils.js";function i(e=!1,t){if(e){const{elevationInfo:e,alignPointsInFeatures:s}=t;return new c(e,s)}return new a}class a{async alignCandidates(e,t,s){return e}notifyElevationSourceChange(){}}const r=1024;class c{constructor(t,s){this._elevationInfo=t,this._alignPointsInFeatures=s,this._alignmentsCache=new e(r),this._cacheVersion=0}async alignCandidates(e,t,s){const n=this._elevationInfo;return null==n||"absolute-height"!==n.mode||n.featureExpressionInfo?this._alignComputedElevationCandidates(e,t,s):(this._alignAbsoluteElevationCandidates(e,t,n),e)}notifyElevationSourceChange(){this._alignmentsCache.clear(),this._cacheVersion++}_alignAbsoluteElevationCandidates(e,t,s){const{offset:i,unit:a}=s;if(null==i)return;const r=n(t),c=i*(o(a??"meters")/r);for(const n of e)switch(n.type){case"edge":n.start.z+=c,n.end.z+=c;continue;case"vertex":n.target.z+=c;continue}}async _alignComputedElevationCandidates(e,n,o){const i=new Map;for(const s of e)t(i,s.objectId,d).push(s);const[a,r,c]=this._prepareQuery(i,n),l=await this._alignPointsInFeatures(a,o);s(o);if(c!==this._cacheVersion)return this._alignComputedElevationCandidates(e,n,o);this._applyCacheAndResponse(a,l,r);const{drapedObjectIds:h,failedObjectIds:u}=l,p=[];for(const t of e){const{objectId:e}=t;h.has(e)&&"edge"===t.type&&(t.draped=!0),u.has(e)||p.push(t)}return p}_prepareQuery(e,t){const s=[],n=[];for(const[o,i]of e){const e=[];for(const t of i)this._addToQueriesOrCachedResult(o,t.target,e,n),"edge"===t.type&&(this._addToQueriesOrCachedResult(o,t.start,e,n),this._addToQueriesOrCachedResult(o,t.end,e,n));0!==e.length&&s.push({objectId:o,points:e})}return[{spatialReference:t.toJSON(),pointsInFeatures:s},n,this._cacheVersion]}_addToQueriesOrCachedResult(e,t,s,n){const o=h(e,t),i=this._alignmentsCache.get(o);null==i?s.push(t):n.push(new l(t,i))}_applyCacheAndResponse(e,{elevations:t,drapedObjectIds:s,failedObjectIds:n},o){for(const r of o)r.apply();let i=0;const a=this._alignmentsCache;for(const{objectId:r,points:c}of e.pointsInFeatures){if(n.has(r)){i+=c.length;continue}const e=!s.has(r);for(const s of c){const n=h(r,s),o=t[i++];s.z=o,e&&a.put(n,o,1)}}}}class l{constructor(e,t){this.point=e,this.z=t}apply(){this.point.z=this.z}}function h(e,{x:t,y:s,z:n,spatialReference:o}){return`${e}-${t}-${s}-${n??0}}-wkid:${o?.wkid}`}function d(){return[]}export{i as getSnappingCandidateElevationAligner};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Error.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import{CodedValue as n}from"../../layers/support/CodedValue.js";import r from"../../layers/support/CodedValueDomain.js";import"../../layers/support/Domain.js";import"../../layers/support/InheritedDomain.js";import"../../layers/support/RangeDomain.js";import{getDomainRange as s,validateDomainValue as u}from"../../layers/support/domainUtils.js";import{isFieldVisibleByDefault as o,getLowerCaseEditTrackingFields as a,isNumericField as p,isStringField as d,isTimeOnlyField as m,getFieldRange as y,TypeValidationError as h,NumericRangeValidationError as f,validateFieldValue as c}from"../../layers/support/fieldUtils.js";import{isAnyDateField as g}from"../../smartMapping/support/utils.js";import{isRelatableFeatureSupportedLayer as b}from"../Feature/support/featureUtils.js";import v from"./EditableInput.js";import{parseFormTemplateString as E,getNormalizedFeatureTypeInfo as x,isFieldElementWithInputType as _,valueIsInvalidSwitchValue as V,isFieldElementWithTextInput as T,isFieldElementWithShowNoValueOptionInput as F,LengthValidationError as D}from"./featureFormUtils.js";import{timeResolutionToStepMap as w,isArcadeDate as N,arcadeDateToFieldValue as I,valueIsInRange as j}from"../support/dateUtils.js";var O;!function(e){e.Text="text",e.Number="number",e.Date="date",e.Unsupported="unsupported"}(O||(O={}));const A="__internal-type-based-coded-value-domain__";let L=class extends v{constructor(e){super(e),this._storedValue=null,this.error=null,this.preservesValueWhenHidden=!0,this.field=null,this.group=null,this.requiredExpressionExecutor=null,this.type="field",this._fieldInputWasVisibleDuringLifetime=!1,this.valueExpressionExecutor=null}get _dateRange(){const{element:e}=this;if("datetime-picker"===e?.input?.type){const{max:t,min:i}=e.input;return{max:t,min:i}}return{min:null,max:null}}get _configAllowsEdits(){const{element:e,layer:t,name:i}=this;if(null!=e)return e.editableExpression?!!this.evaluatedEditableExpression:!1!==e.editable;if(t?.userHasUpdateItemPrivileges)return!0;const l=t&&"popupTemplate"in t?t?.popupTemplate?.fieldInfos?.find((({fieldName:e})=>e===i)):null;return l?.isEditable??!0}get _layerAndFieldAllowEdits(){return this.layerAllowsEdits&&this.field?.editable}get _isVisibleByDefault(){const{field:e,layer:t}=this;return!!e?.visible&&o(e,t)}get _isEditTrackingField(){return a(this.layer).includes(this.name?.toLowerCase())}get _shouldUseValueExpression(){return this._layerAndFieldAllowEdits&&!this._configAllowsEdits&&null!=this.valueExpressionExecutor}get _isSubtypeField(){const{layer:e}=this;if(e&&"subtypeField"in e){const{subtypeField:t,fieldsIndex:i}=e;return(i.get(t)?.name??t)===this.name}return!1}get test(){return{_isSubtypeField:this._isSubtypeField}}get dataType(){const{field:e}=this;return p(e)?O.Number:d(e)?O.Text:g(e)||m(e)?O.Date:O.Unsupported}get dateDataType(){if(this.dataType===O.Date)return"date"!==this.field.type?"string":"number"}get description(){const{element:e,feature:t,layer:i,timeZone:l}=this,n=e?.description;return null!=i&&null!=n?E({label:n,attributes:t.attributes,fieldsIndex:i.fieldsIndex,timeZone:l}):n}get domain(){const{layer:e}=this,{typeFieldName:t,types:i}=x(e);if(this._isSubtypeField&&"subtypes"in e&&e.subtypes)return new r({name:A,codedValues:e.subtypes.map((({code:e,name:t})=>new n({code:e,name:t})))});if(t===this.name&&null==this.field.domain)return new r({name:A,codedValues:i.map((({code:e,name:t})=>new n({code:e,name:t})))});const{feature:l}=this,s=e?.getFieldDomain(this.name,{feature:l}),u=this.element?.domain;return null!=u&&this._isDomainCompatible(u)?u:s}get editable(){return!!this._layerAndFieldAllowEdits&&(this.evaluatedEditableExpression??this._configAllowsEdits)}get evaluatedRequiredExpression(){const{requiredExpressionExecutor:e}=this;return null!=e?!!e.lastEvaluatedValue:null}get evaluatedValueExpression(){const{valueExpressionExecutor:e}=this;return null!=e?e.lastEvaluatedValue:null}get hint(){return this.element?.hint}get includeDate(){return!(this.dataType!==O.Date||"time-only"===this.field.type)}get includeTime(){const{element:e,field:t}=this;if(this.dataType!==O.Date)return!1;if("time-only"===t.type)return!0;if("date-only"===t.type)return!1;const i="datetime-picker"===e?.input?.type?e.input.includeTime:void 0;return void 0===i||i}get includeTimeOffset(){if("timestamp-offset"!==this.field.type)return!1;const e=this.element?.input;return!e||"datetimeoffset-picker"===e.type&&e.includeTimeOffset}set initialFeature(e){this._set("initialFeature",e),this.notifyChange("valid")}get inputType(){return this.element?.input?.type}get hasInvalidSwitchValue(){const{element:e}=this,t=_(e,"switch")?e.input:null;return!t||V(this.value,t)}get isRelationshipKeyField(){const{field:e,layer:t}=this;return b(t)&&!!t.relationships?.some((t=>t.keyField===e.name))}get label(){const{element:e,feature:t,field:i,layer:l,timeZone:n}=this;return null!=l&&null!=e?.label?E({label:e.label,attributes:t.attributes,fieldsIndex:l.fieldsIndex,timeZone:n}):e?.label||i.alias||i.name}get maxLength(){const e=-1;if(this.dataType===O.Date)return e;const{field:t,element:i}=this,l=t?.length??-1,n=T(i)?i.input.maxLength:NaN;return null!=n&&!isNaN(n)&&n>=e&&(l===e||n<=l)?n:l}get minLength(){const e=-1;if(this.dataType===O.Date)return e;const{field:t,element:i}=this,l=t?.length??-1,n=T(i)?i.input.minLength:NaN;return null!=n&&!isNaN(n)&&n>=e&&(l===e||n<=l)?n:e}get name(){return this.field?.name}get range(){const{_dateRange:e,domain:t,field:i}=this,{max:l,min:n}=e,r=null!=l&&S(l)?l.getTime():null,u=null!=n&&S(n)?n.getTime():null,o=s(t)||y(i);if(!o)return{max:r,min:u};const a=o.max===Number.MAX_VALUE?null:o.max,p=o.min===Number.MIN_VALUE?null:o.min;return{max:null!=r&&(null===a||null!=a&&r<a)?r:a,min:null!=u&&(null===p||null!=p&&u>p)?u:p}}get required(){const{editable:e,evaluatedRequiredExpression:t,field:i,visible:l,_isSubtypeField:n}=this;return!!e&&(!1===i?.nullable||(!!n||!(!l||null==t)&&t))}set required(e){this._overrideIfSome("required",e)}get showNoValueOptionEnabled(){const{element:e}=this;return!this.required&&(!F(e)||e.input.showNoValueOption)}get showNoValueLabel(){const{element:e}=this;return F(e)?e.input.noValueOptionLabel:null}get submittable(){const{field:e,required:t,valid:i,value:l}=this;return(!t||null!=l)&&(!!i||this.initialFeature.getAttribute(e.name)===l)}get timeResolution(){const e=this.element?.input;if(e&&("datetimeoffset-picker"===e.type||"time-picker"===e.type))return e.timeResolution??"minutes"}get timeStep(){return null!=this.timeResolution?w.get(this.timeResolution):void 0}get updating(){const{editableExpressionExecutor:e,valueExpressionExecutor:t,visibilityExpressionExecutor:i,preservesValueWhenHidden:l}=this;return null!=t&&t.updating||null!=e&&e.updating||!1===l&&null!=i&&i.updating}get valid(){const e=this.editable?this._validate():null;return this._set("error",e),null===e}get value(){if(this._fieldInputWasVisibleDuringLifetime=this._fieldInputWasVisibleDuringLifetime||this.visible&&!1!==this.group?.visible,!1===this.preservesValueWhenHidden&&this._fieldInputWasVisibleDuringLifetime&&(!1===this.evaluatedVisibilityExpression||!1===this.group?.evaluatedVisibilityExpression))return null!==this._storedValue&&this.set("_storedValue",null),null;if(this._shouldUseValueExpression){const e=this.evaluatedValueExpression;return this.dataType===O.Date?this._arcadeOutputToDateFieldValue(e):null!=e&&"object"==typeof e?e.toString():e}return this._storedValue}set value(e){this.notifyChange("evaluatedVisibilityExpression"),this.set("_storedValue",e)}get visible(){return!this._isEditTrackingField&&(null!=this.evaluatedVisibilityExpression?this.evaluatedVisibilityExpression:null!=this.element||this._isVisibleByDefault)}_arcadeOutputToDateFieldValue(e){const i=this.field.type;try{if("object"==typeof e){if(null===e)throw new t("feature-form:invalid-date-value");if(N(e))return I(e,i);if("getTime"in e&&"function"==typeof e.getTime&&"date"===i)return parseInt(e.getTime(),10);if("date-only"===i||"time-only"===i||"timestamp-offset"===i)return e.toString()}else{if("string"==typeof e)return"date"===i?parseInt(e,10):e;if("number"==typeof e&&"date"===i)return e}throw new t("feature-form:invalid-date-value")}catch{return"date"===i?NaN:""}}_isDomainCompatible(e){const{field:t}=this;if("coded-value"===e?.type){const i=typeof e.codedValues[0].code;if("string"===i&&d(t)||"number"===i&&p(t))return!0}return!!("range"===e?.type&&p(t)||g(t)||m(t))}_validate(){const{dataType:e,domain:t,field:i,initialFeature:l,minLength:n,range:r,required:s,valid:o,value:a}=this,p=s&&null==a,d=void 0!==o;return!p&&l.getAttribute(i.name)===a&&d?null:p?h.INVALID_TYPE:"text"===e&&n>-1&&"string"==typeof a&&a.length<n?D.TOO_SHORT:"date"===i.type&&null!=a&&r&&!j({value:a,max:r.max,min:r.min})?f.OUT_OF_RANGE:t?null!==a||s?u(t,a):null:c(i,a)}};e([i()],L.prototype,"_storedValue",void 0),e([i()],L.prototype,"_configAllowsEdits",null),e([i()],L.prototype,"_layerAndFieldAllowEdits",null),e([i()],L.prototype,"_isVisibleByDefault",null),e([i()],L.prototype,"_isEditTrackingField",null),e([i()],L.prototype,"_shouldUseValueExpression",null),e([i()],L.prototype,"_isSubtypeField",null),e([i()],L.prototype,"dataType",null),e([i()],L.prototype,"dateDataType",null),e([i()],L.prototype,"description",null),e([i()],L.prototype,"domain",null),e([i()],L.prototype,"editable",null),e([i({readOnly:!0})],L.prototype,"error",void 0),e([i({constructOnly:!0})],L.prototype,"preservesValueWhenHidden",void 0),e([i()],L.prototype,"evaluatedRequiredExpression",null),e([i()],L.prototype,"evaluatedValueExpression",null),e([i()],L.prototype,"field",void 0),e([i()],L.prototype,"group",void 0),e([i({readOnly:!0})],L.prototype,"hint",null),e([i()],L.prototype,"includeDate",null),e([i()],L.prototype,"includeTime",null),e([i()],L.prototype,"includeTimeOffset",null),e([i()],L.prototype,"initialFeature",null),e([i({readOnly:!0})],L.prototype,"inputType",null),e([i()],L.prototype,"hasInvalidSwitchValue",null),e([i()],L.prototype,"isRelationshipKeyField",null),e([i()],L.prototype,"label",null),e([i()],L.prototype,"maxLength",null),e([i()],L.prototype,"minLength",null),e([i({readOnly:!0})],L.prototype,"name",null),e([i()],L.prototype,"range",null),e([i()],L.prototype,"required",null),e([i()],L.prototype,"requiredExpressionExecutor",void 0),e([i()],L.prototype,"showNoValueOptionEnabled",null),e([i()],L.prototype,"submittable",null),e([i()],L.prototype,"timeResolution",null),e([i()],L.prototype,"timeStep",null),e([i({readOnly:!0})],L.prototype,"type",void 0),e([i()],L.prototype,"updating",null),e([i()],L.prototype,"valid",null),e([i({value:null})],L.prototype,"value",null),e([i()],L.prototype,"valueExpressionExecutor",void 0),e([i()],L.prototype,"visible",null),L=e([l("esri.widgets.FeatureForm.FieldInput")],L);const S=e=>e&&!Number.isNaN(e.valueOf()),R=L;export{R as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Error.js";import{watch as i,sync as l}from"../../core/reactiveUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as r}from"../../core/accessorSupport/decorators/subclass.js";import{CodedValue as s}from"../../layers/support/CodedValue.js";import a from"../../layers/support/CodedValueDomain.js";import"../../layers/support/Domain.js";import"../../layers/support/InheritedDomain.js";import"../../layers/support/RangeDomain.js";import{getDomainRange as u,dateTimeFieldValuesToNumericRange as o,validateDomainValue as p}from"../../layers/support/domainUtils.js";import{isFieldVisibleByDefault as d,getLowerCaseEditTrackingFields as m,isNumericField as y,isStringField as h,isTimeOnlyField as f,getFieldRange as c,TypeValidationError as g,NumericRangeValidationError as b,validateFieldValue as x}from"../../layers/support/fieldUtils.js";import{isAnyDateField as v}from"../../smartMapping/support/utils.js";import{isRelatableFeatureSupportedLayer as E}from"../Feature/support/featureUtils.js";import _ from"./EditableInput.js";import{parseFormTemplateString as V,getNormalizedFeatureTypeInfo as w,isFieldElementWithInputType as T,valueIsInvalidSwitchValue as F,isFieldElementWithTextInput as D,isFieldElementWithShowNoValueOptionInput as N,LengthValidationError as j}from"./featureFormUtils.js";import{isNumber as I}from"../support/dataUtils.js";import{timeResolutionToStepMap as A,isArcadeDate as O,arcadeDateToFieldValue as M,dateTimeIsInRange as R}from"../support/dateUtils.js";var L;!function(e){e.Text="text",e.Number="number",e.Date="date",e.Unsupported="unsupported"}(L||(L={}));const S="__internal-type-based-coded-value-domain__";let U=class extends _{constructor(e){super(e),this._storedValue=null,this.error=null,this.preservesValueWhenHidden=!0,this.field=null,this.group=null,this.requiredExpressionExecutor=null,this.type="field",this._fieldInputWasVisibleDuringLifetime=!1,this.valueExpressionExecutor=null}initialize(){this.addHandles(i((()=>this.feature),(()=>this._fieldInputWasVisibleDuringLifetime=!1),l))}get _dateFormRange(){const{element:e,field:t}=this;if("date"!==this.dataType)return{};const i=e?.domain?u(t,e.domain):null;if(!e?.input)return i??{};const l=e.input,{type:n}=l;let r={};if("date-picker"!==n&&"time-picker"!==n&&"datetimeoffset-picker"!==n||(r=o(t,l.max,l.min)),"datetime-picker"===n){const{max:e,min:t}=l;r={max:null!=e&&k(e)?e.getTime():null,min:null!=t&&k(t)?t.getTime():null}}const{max:s,min:a}=r;if(i){const{max:e,min:t}=i,l=I(e)&&(null==s||null!=s&&e<s),n=I(t)&&(null==a||null!=a&&t>a);return{max:l?e:s??null,min:n?t:a??null,rawMax:l?i.rawMax:r?.rawMax??null,rawMin:n?i.rawMin:r?.rawMin??null}}return{min:a,max:s,rawMax:r?.rawMax??null,rawMin:r?.rawMin??null}}get _dateRange(){const{_dateFormRange:e,field:t}=this;if("date"!==this.dataType)return{};const i=u(t);if(!i)return e;const{max:l,min:n,rawMax:r,rawMin:s}=e;if("date"===t.type){const{max:e,min:t}=i;return{max:I(l)&&(null===e||null!=e&&l<e)?l:e??null,min:I(n)&&(null===t||null!=t&&n>t)?n:t??null}}if("date-only"===t.type||"time-only"===t.type||"timestamp-offset"===t.type){const{max:e,min:t,rawMax:a,rawMin:u}=i,o=I(l)&&r&&(null==e||l<e);return{max:o?l:e,min:I(n)&&s&&(null==t||n>t)?n:t,rawMax:o?r:a,rawMin:o?s:u}}return{max:null,min:null}}get _configAllowsEdits(){const{element:e,layer:t,name:i}=this;if(null!=e)return e.editableExpression?!!this.evaluatedEditableExpression:!1!==e.editable;if(t?.userHasUpdateItemPrivileges)return!0;const l=t&&"popupTemplate"in t?t?.popupTemplate?.fieldInfos?.find((({fieldName:e})=>e===i)):null;return l?.isEditable??!0}get _layerAndFieldAllowEdits(){return this.layerAllowsEdits&&this.field?.editable}get _isVisibleByDefault(){const{field:e,layer:t}=this;return!!e?.visible&&d(e,t)}get _isEditTrackingField(){return m(this.layer).includes(this.name?.toLowerCase())}get _shouldUseValueExpression(){return this._layerAndFieldAllowEdits&&!this._configAllowsEdits&&null!=this.valueExpressionExecutor}get _isSubtypeField(){const{layer:e}=this;if(e&&"subtypeField"in e){const{subtypeField:t,fieldsIndex:i}=e;return(i.get(t)?.name??t)===this.name}return!1}get test(){return{_isSubtypeField:this._isSubtypeField}}get dataType(){const{field:e}=this;return y(e)?L.Number:h(e)?L.Text:v(e)||f(e)?L.Date:L.Unsupported}get dateDataType(){if(this.dataType===L.Date)return"date"!==this.field.type?"string":"number"}get description(){const{element:e,feature:t,layer:i,timeZone:l}=this,n=e?.description;return null!=i&&null!=n?V({label:n,attributes:t.attributes,fieldsIndex:i.fieldsIndex,timeZone:l}):n}get domain(){const{layer:e}=this,{typeFieldName:t,types:i}=w(e);if(this._isSubtypeField&&"subtypes"in e&&e.subtypes)return new a({name:S,codedValues:e.subtypes.map((({code:e,name:t})=>new s({code:e,name:t})))});if(t===this.name&&null==this.field.domain)return new a({name:S,codedValues:i.map((({code:e,name:t})=>new s({code:e,name:t})))});const{feature:l}=this,n=e?.getFieldDomain(this.name,{feature:l}),r=this.element?.domain;return null!=r&&this._isDomainCompatible(r)?r:n}get editable(){return!!this._layerAndFieldAllowEdits&&(this.evaluatedEditableExpression??this._configAllowsEdits)}get evaluatedRequiredExpression(){const{requiredExpressionExecutor:e}=this;return null!=e?!!e.lastEvaluatedValue:null}get evaluatedValueExpression(){const{valueExpressionExecutor:e}=this;return null!=e?e.lastEvaluatedValue:null}get hint(){return this.element?.hint}get includeDate(){return!(this.dataType!==L.Date||"time-only"===this.field.type)}get includeTime(){const{element:e,field:t}=this;if(this.dataType!==L.Date)return!1;if("time-only"===t.type)return!0;if("date-only"===t.type)return!1;const i="datetime-picker"===e?.input?.type?e.input.includeTime:void 0;return void 0===i||i}get includeTimeOffset(){if("timestamp-offset"!==this.field.type)return!1;const e=this.element?.input;return!e||"datetimeoffset-picker"===e.type&&e.includeTimeOffset}set initialFeature(e){this._set("initialFeature",e),this.notifyChange("valid")}get inputType(){return this.element?.input?.type}get hasInvalidSwitchValue(){const{element:e}=this,t=T(e,"switch")?e.input:null;return!t||F(this.value,t)}get isRelationshipKeyField(){const{field:e,layer:t}=this;return E(t)&&!!t.relationships?.some((t=>t.keyField===e.name))}get label(){const{element:e,feature:t,field:i,layer:l,timeZone:n}=this;return null!=l&&null!=e?.label?V({label:e.label,attributes:t.attributes,fieldsIndex:l.fieldsIndex,timeZone:n}):e?.label||i.alias||i.name}get maxLength(){const e=-1;if(this.dataType===L.Date)return e;const{field:t,element:i}=this,l=t?.length??-1,n=D(i)?i.input.maxLength:NaN;return null!=n&&!isNaN(n)&&n>=e&&(l===e||n<=l)?n:l}get minLength(){const e=-1;if(this.dataType===L.Date)return e;const{field:t,element:i}=this,l=t?.length??-1,n=D(i)?i.input.minLength:NaN;return null!=n&&!isNaN(n)&&n>=e&&(l===e||n<=l)?n:e}get name(){return this.field?.name}get range(){const{domain:e,element:t,field:i}=this;if("date"===this.dataType)return this._dateRange;const l=u(i,e)||c(i,e),n=l?.max===Number.MAX_VALUE?null:l?.max??null,r=l?.min===-Number.MAX_VALUE?null:l?.min??null;if(!t?.domain||"range"!==t.domain.type)return{max:n,min:r};const{max:s,min:a}=u(i)||{};return{max:null!=s&&(null===n||null!=n&&s<n)?s:n,min:null!=a&&(null===r||null!=r&&a>r)?a:r}}get required(){const{editable:e,evaluatedRequiredExpression:t,field:i,visible:l,_isSubtypeField:n}=this;return!!e&&(!1===i?.nullable||(!!n||!(!l||null==t)&&t))}set required(e){this._overrideIfSome("required",e)}get showNoValueOptionEnabled(){const{element:e}=this;return!this.required&&(!N(e)||e.input.showNoValueOption)}get showNoValueLabel(){const{element:e}=this;return N(e)?e.input.noValueOptionLabel:null}get submittable(){const{field:e,required:t,valid:i,value:l}=this;return(!t||null!=l)&&(!!i||this.initialFeature.getAttribute(e.name)===l)}get timeResolution(){const e=this.element?.input;if(e&&("datetimeoffset-picker"===e.type||"time-picker"===e.type))return e.timeResolution??"minutes"}get timeStep(){return null!=this.timeResolution?A.get(this.timeResolution):void 0}get updating(){const{editableExpressionExecutor:e,valueExpressionExecutor:t,visibilityExpressionExecutor:i,preservesValueWhenHidden:l}=this;return null!=t&&t.updating||null!=e&&e.updating||!1===l&&null!=i&&i.updating}get valid(){const e=this.editable?this._validate():null;return this._set("error",e),null===e}get value(){if(this._fieldInputWasVisibleDuringLifetime=this._fieldInputWasVisibleDuringLifetime||this.visible&&!1!==this.group?.visible,!1===this.preservesValueWhenHidden&&this._fieldInputWasVisibleDuringLifetime&&(!1===this.visibilityExpressionExecutor?.lastEvaluatedValue||!1===this.group?.visibilityExpressionExecutor?.lastEvaluatedValue))return null!==this._storedValue&&this.set("_storedValue",null),null;if(this._shouldUseValueExpression){const e=this.evaluatedValueExpression;return this.dataType===L.Date?this._arcadeOutputToDateFieldValue(e):null!=e&&"object"==typeof e?e.toString():e}return this._storedValue}set value(e){this.notifyChange("evaluatedVisibilityExpression"),this.set("_storedValue",e)}get visible(){return!this._isEditTrackingField&&(null!=this.evaluatedVisibilityExpression?this.evaluatedVisibilityExpression:null!=this.element||this._isVisibleByDefault)}_arcadeOutputToDateFieldValue(e){const i=this.field.type;try{if("object"==typeof e){if(null===e)throw new t("feature-form:invalid-date-value");if(O(e))return M(e,i);if("getTime"in e&&"function"==typeof e.getTime&&"date"===i)return parseInt(e.getTime(),10);if("date-only"===i||"time-only"===i||"timestamp-offset"===i)return e.toString()}else{if("string"==typeof e)return"date"===i?parseInt(e,10):e;if("number"==typeof e&&"date"===i)return e}throw new t("feature-form:invalid-date-value")}catch{return"date"===i?NaN:""}}_isDomainCompatible(e){const{field:t}=this;if("coded-value"===e?.type){const i=typeof e.codedValues[0].code;if("string"===i&&h(t)||"number"===i&&y(t))return!0}return!!("range"===e?.type&&y(t)||v(t)||f(t))}_validate(){const{dataType:e,domain:t,field:i,initialFeature:l,minLength:n,range:r,required:s,valid:a,value:u}=this,o=s&&null==u,d=void 0!==a;return!o&&l.getAttribute(i.name)===u&&d?null:o?g.INVALID_TYPE:"text"===e&&n>-1&&"string"==typeof u&&u.length<n?j.TOO_SHORT:"date"!==e||null==u||R({type:i.type,range:r,value:u})?t?null!==u||s?p(i,u):null:x(i,u):b.OUT_OF_RANGE}};e([n()],U.prototype,"_dateFormRange",null),e([n()],U.prototype,"_dateRange",null),e([n()],U.prototype,"_storedValue",void 0),e([n()],U.prototype,"_configAllowsEdits",null),e([n()],U.prototype,"_layerAndFieldAllowEdits",null),e([n()],U.prototype,"_isVisibleByDefault",null),e([n()],U.prototype,"_isEditTrackingField",null),e([n()],U.prototype,"_shouldUseValueExpression",null),e([n()],U.prototype,"_isSubtypeField",null),e([n()],U.prototype,"dataType",null),e([n()],U.prototype,"dateDataType",null),e([n()],U.prototype,"description",null),e([n()],U.prototype,"domain",null),e([n()],U.prototype,"editable",null),e([n({readOnly:!0})],U.prototype,"error",void 0),e([n({constructOnly:!0})],U.prototype,"preservesValueWhenHidden",void 0),e([n()],U.prototype,"evaluatedRequiredExpression",null),e([n()],U.prototype,"evaluatedValueExpression",null),e([n()],U.prototype,"field",void 0),e([n()],U.prototype,"group",void 0),e([n({readOnly:!0})],U.prototype,"hint",null),e([n()],U.prototype,"includeDate",null),e([n()],U.prototype,"includeTime",null),e([n()],U.prototype,"includeTimeOffset",null),e([n()],U.prototype,"initialFeature",null),e([n({readOnly:!0})],U.prototype,"inputType",null),e([n()],U.prototype,"hasInvalidSwitchValue",null),e([n()],U.prototype,"isRelationshipKeyField",null),e([n()],U.prototype,"label",null),e([n()],U.prototype,"maxLength",null),e([n()],U.prototype,"minLength",null),e([n({readOnly:!0})],U.prototype,"name",null),e([n()],U.prototype,"range",null),e([n()],U.prototype,"required",null),e([n()],U.prototype,"requiredExpressionExecutor",void 0),e([n()],U.prototype,"showNoValueOptionEnabled",null),e([n()],U.prototype,"submittable",null),e([n()],U.prototype,"timeResolution",null),e([n()],U.prototype,"timeStep",null),e([n({readOnly:!0})],U.prototype,"type",void 0),e([n()],U.prototype,"updating",null),e([n()],U.prototype,"valid",null),e([n({value:null})],U.prototype,"value",null),e([n()],U.prototype,"valueExpressionExecutor",void 0),e([n()],U.prototype,"visible",null),U=e([r("esri.widgets.FeatureForm.FieldInput")],U);const k=e=>e&&!Number.isNaN(e.valueOf()),q=U;export{q as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import"../../intl.js";import{isSome as e}from"../../core/arrayUtils.js";import{neverReached as t}from"../../core/compilerUtils.js";import{templateHasKey as n,replace as r}from"../../core/string.js";import{DomainValidationError as o}from"../../layers/support/domainUtils.js";import{isTimeOnlyField as i,NumericRangeValidationError as a,TypeValidationError as l}from"../../layers/support/fieldUtils.js";import{isAnyDateField as s}from"../../smartMapping/support/utils.js";import{getLabelForDateFieldValue as u}from"../support/dateUtils.js";import{substitute as p}from"../../intl/substitute.js";const m=e=>"field"===e?.type,d=e=>"group"===e?.type,c=e=>"relationship"===e?.type,f=e=>!d(e)&&null!=e.group,y=e=>"field"===e.type,b=e=>"group"===e.type,T=e=>"relationship"===e.type,E=e=>e.reduce(((e,t)=>d(t)?[...e,...t.inputs]:[...e,t]),[]),g=e=>E(e).filter(m),v=e=>E(e).filter(c),O=e=>null!=e&&(j(e,"combo-box")||j(e,"radio-buttons")),j=(e,t)=>null!=e&&e.input?.type===t,x=e=>null!=e&&(j(e,"text-box")||j(e,"text-area")),V=({domain:e,inputType:t="text-box",dataType:n})=>"number"===n&&"text-box"===t&&(!e||"coded-value"!==e.type),h=e=>"items"in e,U={typeFieldName:null,types:[]};function N(t){const{attributes:r,fieldsIndex:o,label:i,timeZone:a}=t,l=Object.keys(r).filter((e=>n(i,e))),s=l.map((e=>r[e])),u=l.map((e=>o.get(e))).filter(e);return A(i,_({values:s,fields:u,timeZone:a}))}function _(e){const{fields:t,values:n,timeZone:r}=e,o=t.map(((e,t)=>{let o=n[t];if(e.domain&&"coded-value"===e.domain.type){const t=e.domain.codedValues.find((e=>e.code===o));t?.name&&(o=t.name)}return(s(e)||i(e))&&(o=u(e,o,{timeZone:"date"===e.type&&null!=r?r:void 0})),[e.name,o]}));return Object.fromEntries(o)}function A(e,t){return r(r(e,(e=>`{${e.toLowerCase()}}`)),Object.fromEntries(Object.entries(t).map((([e,t])=>[e.toLowerCase(),t]))))}const I=e=>e?"subtype-sublayer"===e.type?{typeFieldName:e.parent?.subtypeField,types:e.parent?.subtypes??[]}:"types"in e&&e.types?{typeFieldName:e.typeIdField,types:e.types.map((({id:e,name:t,domains:n})=>({code:e,name:t,domains:n})))}:U:U,L=(e,t)=>{if(!e)return!0;const{operations:n}=e;switch(t){case"INSERT":return n.supportsAdd;case"UPDATE":case"DELETE":return n.supportsUpdate;default:return!0}};var F;!function(e){e.TOO_SHORT="length-validation-error::too-short"}(F||(F={}));const D={type:"number"},R={type:"number",intlOptions:{notation:"scientific"}},Z={day:"2-digit",month:"2-digit",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric"};function w(e){return e>=1e7||e<=-1e7}const C=(e,t,n)=>{const{dataType:r,error:i,minLength:s,value:u,required:m}=e;if(!t||!i)return null;if(m&&null===u)return t.validationErrors.cannotBeNull;if(i===o.VALUE_OUT_OF_RANGE||i===a.OUT_OF_RANGE){const o=e.range,i={type:"date",intlOptions:{...Z,timeZone:n??void 0}};return p(t.validationErrors.outsideRange,o,{format:{max:"date"===r?i:w(o.max)?R:D,min:"date"===r?i:w(o.min)?R:D}})}return i===o.INVALID_CODED_VALUE?t.validationErrors.invalidCodedValue:i===l.INVALID_TYPE?t.validationErrors.invalidType:i===F.TOO_SHORT?p(t.validationErrors.tooShort,{min:s}):null},S=e=>{if(!e)return;const t=e.layer,n=t&&"geometryType"in t?t.geometryType:void 0,r=e.geometry?.type;return"polyline"===r||"polyline"===n?"line":r||n||"table"},G=e=>{const t=[];if(e.formTemplate){const{description:r,title:o}=e.formTemplate;e.fields?.forEach((e=>{const i=o&&n(o,e.name),a=r&&n(r,e.name);(i||a)&&t.push(e.name)}))}return t};function H(e){if("formTemplate"in e&&e.formTemplate){return(e.formTemplate.elements?.filter(y)??[]).some((({fieldName:t})=>!e.fieldsIndex.get(t)))}return!1}function P(e,t){return null==e||t.onValue!==e&&t.offValue!==e}function k(e,n){switch(n.objectType){case"any":return!0;case"null":return null==e;case"code":return e===n.codedValue?.code;case"range":return null!=e&&null!=n.minValue&&null!=n.maxValue&&+e>=n.minValue&&+e<=n.maxValue;default:return t(n.objectType),!1}}export{F as LengthValidationError,L as capabilitiesAllowEditType,g as flattenFieldInputs,E as flattenInputs,v as flattenRelationshipInputs,H as formTemplateHasInvalidFields,_ as getComputedAttributes,C as getErrorMessageForFieldInput,G as getFieldsInTitleAndDesc,S as getIconForFeature,I as getNormalizedFeatureTypeInfo,y as isFieldElement,j as isFieldElementWithInputType,O as isFieldElementWithShowNoValueOptionInput,x as isFieldElementWithTextInput,m as isFieldInput,b as isGroupElement,d as isGroupInput,f as isInputInGroupInput,V as isNumberFieldInput,T as isRelationshipElement,c as isRelationshipInput,h as isTemplateItemGroup,N as parseFormTemplateString,A as substituteFieldTemplatesInString,P as valueIsInvalidSwitchValue,k as valueIsValidContingentValue};
5
+ import"../../intl.js";import{isSome as e}from"../../core/arrayUtils.js";import{neverReached as t}from"../../core/compilerUtils.js";import{templateHasKey as n,replace as r}from"../../core/string.js";import{DomainValidationError as i}from"../../layers/support/domainUtils.js";import{isTimeOnlyField as o,NumericRangeValidationError as l,TypeValidationError as a}from"../../layers/support/fieldUtils.js";import{isAnyDateField as s}from"../../smartMapping/support/utils.js";import{getLabelForDateFieldValue as u}from"../support/dateUtils.js";import{substitute as p}from"../../intl/substitute.js";const m=e=>"field"===e?.type,d=e=>"group"===e?.type,c=e=>"relationship"===e?.type,f=e=>!d(e)&&null!=e.group,y=e=>"field"===e.type,b=e=>"group"===e.type,T=e=>"relationship"===e.type,E=e=>e.reduce(((e,t)=>d(t)?[...e,...t.inputs]:[...e,t]),[]),g=e=>E(e).filter(m),v=e=>E(e).filter(c),O=e=>null!=e&&(x(e,"combo-box")||x(e,"radio-buttons")),x=(e,t)=>null!=e&&e.input?.type===t,j=e=>null!=e&&(x(e,"text-box")||x(e,"text-area")),V=({domain:e,inputType:t="text-box",dataType:n})=>"number"===n&&"text-box"===t&&(!e||"coded-value"!==e.type),h=e=>"items"in e,U={typeFieldName:null,types:[]};function N(t){const{attributes:r,fieldsIndex:i,label:o,timeZone:l}=t,a=Object.keys(r).filter((e=>n(o,e))),s=a.map((e=>r[e])),u=a.map((e=>i.get(e))).filter(e);return A(o,_({values:s,fields:u,timeZone:l}))}function _(e){const{fields:t,values:n,timeZone:r}=e,i=t.map(((e,t)=>{let i=n[t];if(e.domain&&"coded-value"===e.domain.type){const t=e.domain.codedValues.find((e=>e.code===i));t?.name&&(i=t.name)}return(s(e)||o(e))&&(i=u(e,i,{timeZone:"date"===e.type&&null!=r?r:void 0})),[e.name,i]}));return Object.fromEntries(i)}function A(e,t){return r(r(e,(e=>`{${e.toLowerCase()}}`)),Object.fromEntries(Object.entries(t).map((([e,t])=>[e.toLowerCase(),t]))))}const I=e=>e?"subtype-sublayer"===e.type?{typeFieldName:e.parent?.subtypeField,types:e.parent?.subtypes??[]}:"types"in e&&e.types?{typeFieldName:e.typeIdField,types:e.types.map((({id:e,name:t,domains:n})=>({code:e,name:t,domains:n})))}:U:U,L=(e,t)=>{if(!e)return!0;const{operations:n}=e;switch(t){case"INSERT":return n.supportsAdd;case"UPDATE":case"DELETE":return n.supportsUpdate;default:return!0}};var F;!function(e){e.TOO_SHORT="length-validation-error::too-short"}(F||(F={}));const D={type:"number"},R={type:"number",intlOptions:{notation:"scientific"}},Z={day:"2-digit",month:"2-digit",year:"numeric"},w={hour:"numeric",minute:"numeric",second:"numeric"},C={...Z,...w};function S(e){return e>=1e7||e<=-1e7}const G=(e,t,n)=>{const{dataType:r,error:o,minLength:s,value:u,required:m}=e;if(!t||!o)return null;if(m&&null===u)return t.validationErrors.cannotBeNull;if(o===i.VALUE_OUT_OF_RANGE||o===l.OUT_OF_RANGE){const{field:i,range:o}=e,l={type:"date",intlOptions:{..."time-only"===i.type?w:"date-only"===i.type?Z:C,timeZone:n??void 0}};return p(t.validationErrors.outsideRange,o,{format:{max:"date"===r?l:null!=o.max&&S(o.max)?R:D,min:"date"===r?l:null!=o.min&&S(o.min)?R:D}})}return o===i.INVALID_CODED_VALUE?t.validationErrors.invalidCodedValue:o===a.INVALID_TYPE?t.validationErrors.invalidType:o===F.TOO_SHORT?p(t.validationErrors.tooShort,{min:s}):null},H=e=>{if(!e)return;const t=e.layer,n=t&&"geometryType"in t?t.geometryType:void 0,r=e.geometry?.type;return"polyline"===r||"polyline"===n?"line":r||n||"table"},P=e=>{const t=[];if(e.formTemplate){const{description:r,title:i}=e.formTemplate;e.fields?.forEach((e=>{const o=i&&n(i,e.name),l=r&&n(r,e.name);(o||l)&&t.push(e.name)}))}return t};function k(e){if("formTemplate"in e&&e.formTemplate){return(e.formTemplate.elements?.filter(y)??[]).some((({fieldName:t})=>!e.fieldsIndex.get(t)))}return!1}function q(e,t){return null==e||t.onValue!==e&&t.offValue!==e}function B(e,n){switch(n.objectType){case"any":return!0;case"null":return null==e;case"code":return e===n.codedValue?.code;case"range":return null!=e&&null!=n.minValue&&null!=n.maxValue&&+e>=n.minValue&&+e<=n.maxValue;default:return t(n.objectType),!1}}export{F as LengthValidationError,L as capabilitiesAllowEditType,g as flattenFieldInputs,E as flattenInputs,v as flattenRelationshipInputs,k as formTemplateHasInvalidFields,_ as getComputedAttributes,G as getErrorMessageForFieldInput,P as getFieldsInTitleAndDesc,H as getIconForFeature,I as getNormalizedFeatureTypeInfo,y as isFieldElement,x as isFieldElementWithInputType,O as isFieldElementWithShowNoValueOptionInput,j as isFieldElementWithTextInput,m as isFieldInput,b as isGroupElement,d as isGroupInput,f as isInputInGroupInput,V as isNumberFieldInput,T as isRelationshipElement,c as isRelationshipInput,h as isTemplateItemGroup,N as parseFormTemplateString,A as substituteFieldTemplatesInString,q as valueIsInvalidSwitchValue,B as valueIsValidContingentValue};