@arcgis/core 4.31.0-next.20240729 → 4.31.0-next.20240730

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 (146) hide show
  1. package/Color.js +1 -1
  2. package/analysis/Viewshed.js +1 -1
  3. package/arcade/ArcadeModuleResolver.js +1 -1
  4. package/arcade/featureset/sources/FeatureLayerDynamic.js +1 -1
  5. package/arcade/featureset/support/Guid.js +1 -1
  6. package/arcade/functions/string.js +1 -1
  7. package/assets/esri/core/workers/RemoteClient.js +1 -1
  8. package/assets/esri/core/workers/chunks/{4569efca36cb1d33cc34.js → 08cfd58b135c7df113d0.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{d3b2dd1e285bd8195b93.js → 11ceb6b3e110447a51cc.js} +1 -1
  10. package/assets/esri/core/workers/chunks/1e7ce327435e0f4a4bec.js +1 -0
  11. package/assets/esri/core/workers/chunks/1fd5b2454281092053e8.js +1 -0
  12. package/assets/esri/core/workers/chunks/28128b24dc3c4072f978.js +1 -0
  13. package/assets/esri/core/workers/chunks/2f5cc8fabb004beff962.js +1 -0
  14. package/assets/esri/core/workers/chunks/3069746dbd4f4c92eea2.js +1 -0
  15. package/assets/esri/core/workers/chunks/33d509b4b47d88516944.js +1 -0
  16. package/assets/esri/core/workers/chunks/3b3c8362359a82c66793.js +1 -0
  17. package/assets/esri/core/workers/chunks/{bb0d3ce359b0d8aaf919.js → 3fe1efb6581c25a0fdc3.js} +1 -1
  18. package/assets/esri/core/workers/chunks/45a42396afa72643c9aa.js +1 -0
  19. package/assets/esri/core/workers/chunks/492c5cd5c33405e90aaf.js +1 -0
  20. package/assets/esri/core/workers/chunks/49c7c9524bbac9544ad8.js +1 -0
  21. package/assets/esri/core/workers/chunks/4debb78e479fba8273d8.js +1 -0
  22. package/assets/esri/core/workers/chunks/541275aa071f411163db.js +1 -0
  23. package/assets/esri/core/workers/chunks/576c49d3ca4c96fd962e.js +1 -0
  24. package/assets/esri/core/workers/chunks/{a4a87e204bf66da86725.js → 6934b90c24a3b9ebfe54.js} +1 -1
  25. package/assets/esri/core/workers/chunks/699eea2d15771ea1fe9d.js +1 -0
  26. package/assets/esri/core/workers/chunks/6d1d2c624d9cd2338d8d.js +1 -0
  27. package/assets/esri/core/workers/chunks/8337a9583df5397d4160.js +1 -0
  28. package/assets/esri/core/workers/chunks/920557db2bd107a3c579.js +1 -0
  29. package/assets/esri/core/workers/chunks/945a3cc2191606f3a917.js +1 -0
  30. package/assets/esri/core/workers/chunks/9661398ce832137461f6.js +1 -0
  31. package/assets/esri/core/workers/chunks/9eb4fc93260aec7e2bfd.js +1 -0
  32. package/assets/esri/core/workers/chunks/9f3c484d410f06c9bcbe.js +1 -0
  33. package/assets/esri/core/workers/chunks/{9f5805ecd88d78f092cc.js → a8d109d2bd5285de2841.js} +1 -1
  34. package/assets/esri/core/workers/chunks/cd8a7de1d0ec332133a0.js +1 -0
  35. package/assets/esri/core/workers/chunks/d2befd55b1777e433f34.js +1 -0
  36. package/assets/esri/core/workers/chunks/d36c5ee1d5b560b229b8.js +1 -0
  37. package/assets/esri/core/workers/chunks/{28b1c46fa9c81a36ce50.js → d36ef30f2d8123e34242.js} +1 -1
  38. package/assets/esri/core/workers/chunks/d73501f39b079d9d2d69.js +1 -0
  39. package/assets/esri/core/workers/chunks/e5bfc712c756362dd43c.js +1 -0
  40. package/assets/esri/core/workers/chunks/f0b6fddc7a390258241f.js +1 -0
  41. package/assets/esri/core/workers/chunks/fd74973e45c54f6213cf.js +1 -0
  42. package/assets/esri/geometry/support/pe-wasm.wasm +0 -0
  43. package/assets/esri/themes/base/_mixins.scss +5 -0
  44. package/assets/esri/themes/base/widgets/_BasemapGallery.scss +6 -0
  45. package/assets/esri/themes/base/widgets/_BuildingLevelPicker.scss +6 -2
  46. package/assets/esri/themes/base/widgets/_BuildingPhasePicker.scss +66 -52
  47. package/assets/esri/themes/dark/main.css +1 -1
  48. package/assets/esri/themes/light/main.css +1 -1
  49. package/assets/esri/themes/light/view.css +1 -1
  50. package/chunks/HUDMaterial.glsl.js +24 -11
  51. package/chunks/pe-wasm.js +1 -1
  52. package/chunks/pe.js +1 -1
  53. package/colorUtils.js +1 -1
  54. package/core/BidiEngine.js +1 -1
  55. package/core/date.js +1 -1
  56. package/core/handleUtils.js +1 -1
  57. package/core/number.js +1 -1
  58. package/core/urlUtils.js +1 -1
  59. package/geohash/geohashUtils.js +1 -1
  60. package/geometry/pe.js +1 -1
  61. package/identity/IdentityManagerBase.js +1 -1
  62. package/interfaces.d.ts +109 -0
  63. package/layers/ViewshedLayer.d.ts +4 -0
  64. package/layers/ViewshedLayer.js +1 -1
  65. package/layers/WebTileLayer.js +1 -1
  66. package/layers/graphics/sources/csv/csv.js +1 -1
  67. package/layers/mixins/SceneService.js +1 -1
  68. package/layers/support/layerUtils.js +1 -1
  69. package/layers/support/rasterDatasets/DBFParser.js +1 -1
  70. package/layers/support/rasterDatasets/multipartParser.js +1 -1
  71. package/layers/support/rasterDatasets/wcsCapabilitiesParser.js +1 -1
  72. package/layers/support/rasterDatasets/wcsCoverageParser.js +1 -1
  73. package/layers/support/wmsUtils.js +1 -1
  74. package/layers/support/wmtsUtils.js +1 -1
  75. package/layers/video/VideoController.js +1 -1
  76. package/package.json +2 -2
  77. package/portal/Portal.js +1 -1
  78. package/renderers/support/DictionaryLoader.js +1 -1
  79. package/rest/print.js +1 -1
  80. package/rest/route/utils.js +1 -1
  81. package/rest/support/JobInfo.js +1 -1
  82. package/statistics/utils.js +1 -1
  83. package/support/revision.js +1 -1
  84. package/symbols/IconSymbol3DLayer.js +1 -1
  85. package/symbols/cim/OverrideHelper.js +1 -1
  86. package/symbols/cim/Rasterizer.js +1 -1
  87. package/symbols/cim/cimAnalyzer.js +1 -1
  88. package/symbols/cim/effects/EffectDashes.js +1 -1
  89. package/symbols/cim/utils.js +1 -1
  90. package/views/2d/engine/webgl/TextureManager.js +1 -1
  91. package/views/2d/engine/webgl/animations/instructions.js +1 -1
  92. package/views/2d/engine/webgl/shaders/MaterialPrograms.js +1 -1
  93. package/views/3d/analysis/Viewshed/ViewshedAnalysisVisualization.js +1 -1
  94. package/views/3d/analysis/Viewshed/ViewshedTool.js +1 -1
  95. package/views/3d/analysis/Viewshed/ViewshedVisualization.js +1 -1
  96. package/views/3d/analysis/ViewshedAnalysisView3D.js +1 -1
  97. package/views/3d/environment/Stars.js +1 -1
  98. package/views/3d/interactive/editingTools/reshape/ReshapeOperation.js +1 -1
  99. package/views/3d/interactive/editingTools/reshape/ReshapeTool3D.js +1 -1
  100. package/views/3d/layers/ViewshedLayerView3D.js +1 -1
  101. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  102. package/views/3d/layers/graphics/wosrLoader.js +1 -1
  103. package/views/3d/layers/i3s/I3SNodeLoader.js +1 -1
  104. package/views/3d/layers/i3s/I3SUtil.js +1 -1
  105. package/views/3d/layers/support/FeatureTile.js +1 -1
  106. package/views/3d/layers/support/FeatureTileFetcher3D.js +1 -1
  107. package/views/3d/layers/support/featureReference.js +1 -1
  108. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  109. package/views/3d/webgl-engine/shaders/HUDMaterialTechniqueConfiguration.js +1 -1
  110. package/views/interactive/tooltip/Tooltip.js +1 -1
  111. package/views/interactive/tooltip/content/TooltipContent.js +1 -1
  112. package/views/layers/ViewshedLayerView.d.ts +4 -0
  113. package/views/layers/ViewshedLayerView.js +5 -0
  114. package/widgets/BasemapGallery.js +1 -1
  115. package/widgets/BuildingExplorer/BuildingPhasePicker/BuildingPhasePicker.js +1 -1
  116. package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
  117. package/widgets/ScaleRangeSlider/scalePreviewUtils.js +1 -1
  118. package/widgets/Sketch/SketchViewModel.js +1 -1
  119. package/assets/esri/core/workers/chunks/08c65ff4c69c265ac1c4.js +0 -1
  120. package/assets/esri/core/workers/chunks/0f1ecdaaa51341094a29.js +0 -1
  121. package/assets/esri/core/workers/chunks/0f1f32f338b23dc70fd3.js +0 -1
  122. package/assets/esri/core/workers/chunks/12b8ec4dc75d06fc4095.js +0 -1
  123. package/assets/esri/core/workers/chunks/1309e728ceb94b4b8a95.js +0 -1
  124. package/assets/esri/core/workers/chunks/18146a9d578998e017f5.js +0 -1
  125. package/assets/esri/core/workers/chunks/1fe6f533d6db25561cdb.js +0 -1
  126. package/assets/esri/core/workers/chunks/2123ab24163a532ebc8d.js +0 -1
  127. package/assets/esri/core/workers/chunks/34b5bab6239c7277f854.js +0 -1
  128. package/assets/esri/core/workers/chunks/3d96e76033a18217e642.js +0 -1
  129. package/assets/esri/core/workers/chunks/3f2a3b66531325aa4f12.js +0 -1
  130. package/assets/esri/core/workers/chunks/4b86031a57e2e9cab638.js +0 -1
  131. package/assets/esri/core/workers/chunks/623e01cef5b4451405f3.js +0 -1
  132. package/assets/esri/core/workers/chunks/623fad912190898f78fd.js +0 -1
  133. package/assets/esri/core/workers/chunks/7bef0353afe585410d88.js +0 -1
  134. package/assets/esri/core/workers/chunks/846e23efd5b2d8894518.js +0 -1
  135. package/assets/esri/core/workers/chunks/8ce1c76f9a76136e19e5.js +0 -1
  136. package/assets/esri/core/workers/chunks/95c9a1dcdc0b48e09cbb.js +0 -1
  137. package/assets/esri/core/workers/chunks/9899a823559c06a75c74.js +0 -1
  138. package/assets/esri/core/workers/chunks/9cc4dc1b133ad601bdfb.js +0 -1
  139. package/assets/esri/core/workers/chunks/a88f906a57c0e9b90229.js +0 -1
  140. package/assets/esri/core/workers/chunks/cd16c79f144532461138.js +0 -1
  141. package/assets/esri/core/workers/chunks/d03a6fcfbd53974f0c17.js +0 -1
  142. package/assets/esri/core/workers/chunks/d46854ea8bccb2276a57.js +0 -1
  143. package/assets/esri/core/workers/chunks/e4ce6e5c8c30d37ff7e1.js +0 -1
  144. package/assets/esri/core/workers/chunks/f59f8f881a7097669a97.js +0 -1
  145. package/assets/esri/core/workers/chunks/f8f5d7b381995833061d.js +0 -1
  146. package/assets/esri/core/workers/chunks/fdf0bcd0389918a00650.js +0 -1
package/Color.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{hsla2rgba as t,isNamedColor as r,getNamedColor as s}from"./colorUtils.js";import{clamp as i}from"./core/mathUtils.js";import{ensureInteger as n}from"./core/accessorSupport/ensureType.js";function a(t){return i(n(t),0,255)}function e(t,r,s){return t=Number(t),isNaN(t)?s:t<r?r:t>s?s:t}function o(t,r){const s=t.toString(16).padStart(2,"0");return r?s.substring(0,1):s}class h{static blendColors(t,r,s,i=new h){return i.r=Math.round(t.r+(r.r-t.r)*s),i.g=Math.round(t.g+(r.g-t.g)*s),i.b=Math.round(t.b+(r.b-t.b)*s),i.a=t.a+(r.a-t.a)*s,i._sanitize()}static fromRgb(r,s){const i=r.toLowerCase().match(/^(rgba?|hsla?)\(([\s.\-,%0-9]+)\)/);if(i){const r=i[2].split(/\s*,\s*/),n=i[1];if("rgb"===n&&3===r.length||"rgba"===n&&4===r.length){const t=r[0];if("%"===t.charAt(t.length-1)){const t=r.map((t=>2.56*parseFloat(t)));return 4===r.length&&(t[3]=parseFloat(r[3])),h.fromArray(t,s)}return h.fromArray(r.map((t=>parseFloat(t))),s)}if("hsl"===n&&3===r.length||"hsla"===n&&4===r.length)return h.fromArray(t(parseFloat(r[0]),parseFloat(r[1])/100,parseFloat(r[2])/100,parseFloat(r[3])),s)}return null}static fromHex(t,r=new h){if("#"!==t[0]||isNaN(Number(`0x${t.substring(1)}`)))return null;switch(t.length){case 4:case 5:{const s=parseInt(t.substring(1,2),16),i=parseInt(t.substring(2,3),16),n=parseInt(t.substring(3,4),16),a=5===t.length?15:parseInt(t.substring(4),16);return h.fromArray([s+16*s,i+16*i,n+16*n,(a+16*a)/255],r)}case 7:case 9:{const s=parseInt(t.substring(1,3),16),i=parseInt(t.substring(3,5),16),n=parseInt(t.substring(5,7),16),a=7===t.length?255:parseInt(t.substring(7),16);return h.fromArray([s,i,n,a/255],r)}default:return null}}static fromArray(t,r=new h){return r._set(Number(t[0]),Number(t[1]),Number(t[2]),Number(t[3])),isNaN(r.a)&&(r.a=1),r._sanitize()}static fromString(t,i){const n=r(t)?s(t):null;return n&&h.fromArray(n,i)||h.fromRgb(t,i)||h.fromHex(t,i)}static fromJSON(t){return null!=t?new h([t[0],t[1],t[2],(t[3]??255)/255]):void 0}static toUnitRGB(t){return null!=t?[t.r/255,t.g/255,t.b/255]:null}static toUnitRGBA(t){return null!=t?[t.r/255,t.g/255,t.b/255,null!=t.a?t.a:1]:null}constructor(t){this.r=255,this.g=255,this.b=255,this.a=1,t&&this.setColor(t)}get isBright(){return.299*this.r+.587*this.g+.114*this.b>=127}setColor(t){return"string"==typeof t?h.fromString(t,this):Array.isArray(t)?h.fromArray(t,this):(this._set(t.r??0,t.g??0,t.b??0,t.a??1),t instanceof h||this._sanitize()),this}toRgb(){return[this.r,this.g,this.b]}toRgba(){return[this.r,this.g,this.b,this.a]}toHex(t){const r=t?.capitalize??!1,s=t?.digits??6,i=3===s||4===s,n=4===s||8===s,a=`#${o(this.r,i)}${o(this.g,i)}${o(this.b,i)}${n?o(Math.round(255*this.a),i):""}`;return r?a.toUpperCase():a}toCss(t=!1){const r=this.r+", "+this.g+", "+this.b;return t?`rgba(${r}, ${this.a})`:`rgb(${r})`}toString(){return this.toCss(!0)}toJSON(){return this.toArray()}toArray(t=h.AlphaMode.ALWAYS){const r=a(this.r),s=a(this.g),i=a(this.b);return t===h.AlphaMode.ALWAYS||1!==this.a?[r,s,i,a(255*this.a)]:[r,s,i]}clone(){return new h(this.toRgba())}hash(){return this.r<<24|this.g<<16|this.b<<8|255*this.a}equals(t){return null!=t&&t.r===this.r&&t.g===this.g&&t.b===this.b&&t.a===this.a}_sanitize(){return this.r=Math.round(e(this.r,0,255)),this.g=Math.round(e(this.g,0,255)),this.b=Math.round(e(this.b,0,255)),this.a=e(this.a,0,1),this}_set(t,r,s,i){this.r=t,this.g=r,this.b=s,this.a=i}}h.prototype.declaredClass="esri.Color",function(t){var r;(r=t.AlphaMode||(t.AlphaMode={}))[r.ALWAYS=0]="ALWAYS",r[r.UNLESS_OPAQUE=1]="UNLESS_OPAQUE"}(h||(h={}));const u=h;export{u as default};
5
+ import{hsla2rgba as t,isNamedColor as r,getNamedColor as s}from"./colorUtils.js";import{clamp as e}from"./core/mathUtils.js";import{ensureInteger as i}from"./core/accessorSupport/ensureType.js";function a(t){return e(i(t),0,255)}function n(t,r,s){return t=Number(t),isNaN(t)?s:t<r?r:t>s?s:t}function o(t,r){const s=t.toString(16).padStart(2,"0");return r?s.slice(0,1):s}class h{static blendColors(t,r,s,e=new h){return e.r=Math.round(t.r+(r.r-t.r)*s),e.g=Math.round(t.g+(r.g-t.g)*s),e.b=Math.round(t.b+(r.b-t.b)*s),e.a=t.a+(r.a-t.a)*s,e._sanitize()}static fromRgb(r,s){const e=r.toLowerCase().match(/^(rgba?|hsla?)\(([\s.\-,%0-9]+)\)/);if(e){const r=e[2].split(/\s*,\s*/),i=e[1];if("rgb"===i&&3===r.length||"rgba"===i&&4===r.length){const t=r[0];if("%"===t.charAt(t.length-1)){const t=r.map((t=>2.56*parseFloat(t)));return 4===r.length&&(t[3]=parseFloat(r[3])),h.fromArray(t,s)}return h.fromArray(r.map((t=>parseFloat(t))),s)}if("hsl"===i&&3===r.length||"hsla"===i&&4===r.length)return h.fromArray(t(parseFloat(r[0]),parseFloat(r[1])/100,parseFloat(r[2])/100,parseFloat(r[3])),s)}return null}static fromHex(t,r=new h){if("#"!==t[0]||isNaN(Number(`0x${t.slice(1)}`)))return null;switch(t.length){case 4:case 5:{const s=parseInt(t.slice(1,2),16),e=parseInt(t.slice(2,3),16),i=parseInt(t.slice(3,4),16),a=5===t.length?15:parseInt(t.slice(4),16);return h.fromArray([s+16*s,e+16*e,i+16*i,(a+16*a)/255],r)}case 7:case 9:{const s=parseInt(t.slice(1,3),16),e=parseInt(t.slice(3,5),16),i=parseInt(t.slice(5,7),16),a=7===t.length?255:parseInt(t.slice(7),16);return h.fromArray([s,e,i,a/255],r)}default:return null}}static fromArray(t,r=new h){return r._set(Number(t[0]),Number(t[1]),Number(t[2]),Number(t[3])),isNaN(r.a)&&(r.a=1),r._sanitize()}static fromString(t,e){const i=r(t)?s(t):null;return i&&h.fromArray(i,e)||h.fromRgb(t,e)||h.fromHex(t,e)}static fromJSON(t){return null!=t?new h([t[0],t[1],t[2],(t[3]??255)/255]):void 0}static toUnitRGB(t){return null!=t?[t.r/255,t.g/255,t.b/255]:null}static toUnitRGBA(t){return null!=t?[t.r/255,t.g/255,t.b/255,null!=t.a?t.a:1]:null}constructor(t){this.r=255,this.g=255,this.b=255,this.a=1,t&&this.setColor(t)}get isBright(){return.299*this.r+.587*this.g+.114*this.b>=127}setColor(t){return"string"==typeof t?h.fromString(t,this):Array.isArray(t)?h.fromArray(t,this):(this._set(t.r??0,t.g??0,t.b??0,t.a??1),t instanceof h||this._sanitize()),this}toRgb(){return[this.r,this.g,this.b]}toRgba(){return[this.r,this.g,this.b,this.a]}toHex(t){const r=t?.capitalize??!1,s=t?.digits??6,e=3===s||4===s,i=4===s||8===s,a=`#${o(this.r,e)}${o(this.g,e)}${o(this.b,e)}${i?o(Math.round(255*this.a),e):""}`;return r?a.toUpperCase():a}toCss(t=!1){const r=this.r+", "+this.g+", "+this.b;return t?`rgba(${r}, ${this.a})`:`rgb(${r})`}toString(){return this.toCss(!0)}toJSON(){return this.toArray()}toArray(t=h.AlphaMode.ALWAYS){const r=a(this.r),s=a(this.g),e=a(this.b);return t===h.AlphaMode.ALWAYS||1!==this.a?[r,s,e,a(255*this.a)]:[r,s,e]}clone(){return new h(this.toRgba())}hash(){return this.r<<24|this.g<<16|this.b<<8|255*this.a}equals(t){return null!=t&&t.r===this.r&&t.g===this.g&&t.b===this.b&&t.a===this.a}_sanitize(){return this.r=Math.round(n(this.r,0,255)),this.g=Math.round(n(this.g,0,255)),this.b=Math.round(n(this.b,0,255)),this.a=n(this.a,0,1),this}_set(t,r,s,e){this.r=t,this.g=r,this.b=s,this.a=e}}h.prototype.declaredClass="esri.Color",function(t){var r;(r=t.AlphaMode||(t.AlphaMode={}))[r.ALWAYS=0]="ALWAYS",r[r.UNLESS_OPAQUE=1]="UNLESS_OPAQUE"}(h||(h={}));const l=h;export{l 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.31/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import"../geometry.js";import r from"../core/Accessor.js";import{ClonableMixin as o}from"../core/Clonable.js";import{cyclicalDegrees as t}from"../core/Cyclical.js";import{equalsMaybe as i}from"../core/maybe.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import{cast as a}from"../core/accessorSupport/decorators/cast.js";import"../core/RandomLCG.js";import"../core/has.js";import{subclass as l}from"../core/accessorSupport/decorators/subclass.js";import{ensureNumber as n}from"../core/accessorSupport/ensureType.js";import p from"../geometry/Point.js";let c=class extends(o(r)){constructor(e){super(e),this.observer=null,this.farDistance=1e3,this.heading=0,this.tilt=90,this.horizontalFieldOfView=45,this.verticalFieldOfView=45}isValid(){return null!=this.observer&&this.farDistance>0}equals(e){return i(this.observer,e.observer)&&this.farDistance===e.farDistance&&this.heading===e.heading&&this.tilt===e.tilt&&this.horizontalFieldOfView===e.horizontalFieldOfView&&this.verticalFieldOfView===e.verticalFieldOfView}};e([s({type:p})],c.prototype,"observer",void 0),e([s({type:Number,nonNullable:!0,range:{min:0}})],c.prototype,"farDistance",void 0),e([s({type:Number,nonNullable:!0}),a((e=>t.normalize(n(e))))],c.prototype,"heading",void 0),e([s({type:Number,nonNullable:!0,range:{min:0,max:180}})],c.prototype,"tilt",void 0),e([s({type:Number,nonNullable:!0,range:{min:0,max:360}})],c.prototype,"horizontalFieldOfView",void 0),e([s({type:Number,nonNullable:!0,range:{min:0,max:180}})],c.prototype,"verticalFieldOfView",void 0),e([s()],c.prototype,"isValid",null),c=e([l("esri.analysis.Viewshed")],c);const m=c;export{m as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import"../geometry.js";import r from"../core/Accessor.js";import{ClonableMixin as o}from"../core/Clonable.js";import{cyclicalDegrees as t}from"../core/Cyclical.js";import{equalsMaybe as i}from"../core/maybe.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import{cast as a}from"../core/accessorSupport/decorators/cast.js";import"../core/RandomLCG.js";import"../core/has.js";import{subclass as l}from"../core/accessorSupport/decorators/subclass.js";import{ensureNumber as n}from"../core/accessorSupport/ensureType.js";import p from"../geometry/Point.js";let c=class extends(o(r)){constructor(e){super(e),this.observer=null,this.farDistance=1e3,this.heading=0,this.tilt=90,this.horizontalFieldOfView=45,this.verticalFieldOfView=45}isValid(){return null!=this.observer&&this.farDistance>0}equals(e){return i(this.observer,e.observer)&&this.farDistance===e.farDistance&&this.heading===e.heading&&this.tilt===e.tilt&&this.horizontalFieldOfView===e.horizontalFieldOfView&&this.verticalFieldOfView===e.verticalFieldOfView}};e([s({type:p})],c.prototype,"observer",void 0),e([s({type:Number,nonNullable:!0,range:{min:0}})],c.prototype,"farDistance",void 0),e([s({type:Number,nonNullable:!0}),a((e=>t.normalize(n(e),void 0,!0)))],c.prototype,"heading",void 0),e([s({type:Number,nonNullable:!0,range:{min:0,max:180}})],c.prototype,"tilt",void 0),e([s({type:Number,nonNullable:!0,range:{min:0,max:360}})],c.prototype,"horizontalFieldOfView",void 0),e([s({type:Number,nonNullable:!0,range:{min:0,max:180}})],c.prototype,"verticalFieldOfView",void 0),e([s()],c.prototype,"isValid",null),c=e([l("esri.analysis.Viewshed")],c);const m=c;export{m 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.31/esri/copyright.txt for details.
4
4
  */
5
- import e from"../request.js";import{ModuleError as t,ModuleErrorCodes as r}from"./executionError.js";import{parseScript as o}from"./parser.js";import s from"./featureset/support/RecentlyUsedCache.js";import i from"../portal/Portal.js";class l{constructor(e){this.portalUri=e}normalizeModuleUri(e){const o=/^[a-z0-9A-Z]+(@[0-9]+\.[0-9]+\.[0-9]+)?([?|/].*)?$/gi,s=/(?<portalurl>.+)\/home\/item\.html\?id=(?<itemid>.+)$/gi,c=/(?<portalurl>.+)\/sharing\/rest\/content\/users\/[a-zA-Z0-9]+\/items\/(?<itemid>.+)$/gi,u=/(?<portalurl>.+)\/sharing\/rest\/content\/items\/(?<itemid>.+)$/gi,n=/(?<itemid>.*)@(?<versionstring>[0-9]+\.[0-9]+\.[0-9]+)([?|/].*)?$/gi;if(e.startsWith("portal+")){let l=e.substring(7),a="",m=l,d=!1;for(const e of[s,u,c]){const t=e.exec(l);if(null!==t){const e=t.groups;m=e.itemid,a=e.portalurl,d=!0;break}}if(!1===d){if(!o.test(l))throw new t(r.UnsupportedUriProtocol,{uri:e});m=l,a=this.portalUri}m.includes("/")&&(m=m.split("/")[0]),m.includes("?")&&(m=m.split("?")[0]);let h="current";const p=n.exec(m);if(null!==p){const e=p.groups;m=e.itemid,h=e.versionstring}return l=new i({url:a}).restUrl+"/content/items/"+m+"/resources/"+h+".arc",{url:l,scheme:"portal",uri:"PO:"+l}}if(e.startsWith("mock")){if("mock"===e){return{url:"",scheme:"mock",data:'\n export var hello = 1;\n export function helloWorld() {\n return "Hello World " + hello;\n }\n ',uri:"mock"}}const t=e.replace("mock:","");if(void 0!==l.mocks[t])return{url:"",scheme:"mock",data:l.mocks[t],uri:e}}throw new t(r.UnrecognizedUri,{uri:e})}async fetchModule(e){const t=l.cachedModules.getFromCache(e.uri);if(t)return t;const r=this.fetchSource(e);l.cachedModules.addToCache(e.uri,r);let o=null;try{o=await r}catch(s){throw l.cachedModules.removeFromCache(e.uri),s}return o}async fetchSource(s){if("portal"===s.scheme){const t=await e(s.url,{responseType:"text",query:{}});if(t.data)return o(t.data,[])}if("mock"===s.scheme)return o(s.data??"",[]);throw new t(r.UnsupportedUriProtocol)}static create(e){return new l(e)}static getDefault(){return this._default??(l._default=l._moduleResolverFactory())}static set moduleResolverClass(e){this._moduleResolverFactory=e,this._default=null}}l.mocks={},l.cachedModules=new s(30),l._default=null,l._moduleResolverFactory=()=>{const e=i.getDefault();return new l(e.url)};export{l as ArcadeModuleResolver};
5
+ import e from"../request.js";import{ModuleError as t,ModuleErrorCodes as r}from"./executionError.js";import{parseScript as o}from"./parser.js";import s from"./featureset/support/RecentlyUsedCache.js";import i from"../portal/Portal.js";class l{constructor(e){this.portalUri=e}normalizeModuleUri(e){const o=/^[a-z0-9A-Z]+(@[0-9]+\.[0-9]+\.[0-9]+)?([?|/].*)?$/gi,s=/(?<portalurl>.+)\/home\/item\.html\?id=(?<itemid>.+)$/gi,c=/(?<portalurl>.+)\/sharing\/rest\/content\/users\/[a-zA-Z0-9]+\/items\/(?<itemid>.+)$/gi,u=/(?<portalurl>.+)\/sharing\/rest\/content\/items\/(?<itemid>.+)$/gi,n=/(?<itemid>.*)@(?<versionstring>[0-9]+\.[0-9]+\.[0-9]+)([?|/].*)?$/gi;if(e.startsWith("portal+")){let l=e.slice(7),a="",m=l,d=!1;for(const e of[s,u,c]){const t=e.exec(l);if(null!==t){const e=t.groups;m=e.itemid,a=e.portalurl,d=!0;break}}if(!1===d){if(!o.test(l))throw new t(r.UnsupportedUriProtocol,{uri:e});m=l,a=this.portalUri}m.includes("/")&&(m=m.split("/")[0]),m.includes("?")&&(m=m.split("?")[0]);let h="current";const p=n.exec(m);if(null!==p){const e=p.groups;m=e.itemid,h=e.versionstring}return l=new i({url:a}).restUrl+"/content/items/"+m+"/resources/"+h+".arc",{url:l,scheme:"portal",uri:"PO:"+l}}if(e.startsWith("mock")){if("mock"===e){return{url:"",scheme:"mock",data:'\n export var hello = 1;\n export function helloWorld() {\n return "Hello World " + hello;\n }\n ',uri:"mock"}}const t=e.replace("mock:","");if(void 0!==l.mocks[t])return{url:"",scheme:"mock",data:l.mocks[t],uri:e}}throw new t(r.UnrecognizedUri,{uri:e})}async fetchModule(e){const t=l.cachedModules.getFromCache(e.uri);if(t)return t;const r=this.fetchSource(e);l.cachedModules.addToCache(e.uri,r);let o=null;try{o=await r}catch(s){throw l.cachedModules.removeFromCache(e.uri),s}return o}async fetchSource(s){if("portal"===s.scheme){const t=await e(s.url,{responseType:"text",query:{}});if(t.data)return o(t.data,[])}if("mock"===s.scheme)return o(s.data??"",[]);throw new t(r.UnsupportedUriProtocol)}static create(e){return new l(e)}static getDefault(){return this._default??(l._default=l._moduleResolverFactory())}static set moduleResolverClass(e){this._moduleResolverFactory=e,this._default=null}}l.mocks={},l.cachedModules=new s(30),l._default=null,l._moduleResolverFactory=()=>{const e=i.getDefault();return new l(e.url)};export{l as ArcadeModuleResolver};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../Graphic.js";import{id as t}from"../../../kernel.js";import i from"../../../request.js";import s from"../../Attachment.js";import r from"../../Dictionary.js";import{FeatureSetError as a,FeatureSetErrorCodes as n}from"../support/errorsupport.js";import l from"../support/FeatureSet.js";import o from"../support/IdSet.js";import{defaultMaxRecords as u,stableStringify as d,FeatureServiceDatabaseType as h,IdState as c,extractServiceUrl as p}from"../support/shared.js";import{toWhereClause as y,isSingleField as f}from"../support/sqlUtils.js";import{decodeStatType as _}from"../support/stats.js";import{createMD5Hash as m,outputTypes as g}from"../../../core/MD5.js";import{fromJSON as w}from"../../../geometry/support/jsonUtils.js";import{srToRESTValue as R}from"../../../geometry/support/spatialReferenceUtils.js";import b from"../../../layers/FeatureLayer.js";import{executeForCount as F}from"../../../rest/query/executeForCount.js";import{executeForIds as S}from"../../../rest/query/executeForIds.js";import{executeQuery as I}from"../../../rest/query/executeQuery.js";import{executeQueryJSON as D}from"../../../rest/query/executeQueryJSON.js";import x from"../../../rest/support/AttachmentQuery.js";import C from"../../../rest/support/Query.js";import P from"../../../rest/support/StatisticDefinition.js";class T extends l{constructor(e){super(e),this.declaredClass="esri.arcade.featureset.sources.FeatureLayerDynamic",this._removeGeometry=!1,this._overrideFields=null,this.formulaCredential=null,this._pageJustIds=!1,this._requestStandardised=!1,this._useDefinitionExpression=!0,e.spatialReference&&(this.spatialReference=e.spatialReference),this._transparent=!0,this._maxProcessing=1e3,this._layer=e.layer,this._wset=null,void 0!==e.outFields&&(this._overrideFields=e.outFields),void 0!==e.includeGeometry&&(this._removeGeometry=!1===e.includeGeometry)}_maxQueryRate(){return u}end(){return this._layer}optimisePagingFeatureQueries(e){this._pageJustIds=e}get urlQueryPath(){return this._layer.parsedUrl.path||""}convertQueryToLruCacheKey(e){const t=this.urlQueryPath+","+d(e.toJSON());return m(t,g.String)}async loadImpl(){return!0===this._layer.loaded?(this._initialiseFeatureSet(),this):(await this._layer.load(),this._initialiseFeatureSet(),this)}_initialiseFeatureSet(){if(null==this.spatialReference&&(this.spatialReference=this._layer.spatialReference),this.geometryType=this._layer.geometryType,this.fields=this._layer.fields.slice(),this.hasZ=!0===this._layer?.capabilities?.data?.supportsZ,this.hasM=!0===this._layer?.capabilities?.data?.supportsM,null!==this._overrideFields)if(1===this._overrideFields.length&&"*"===this._overrideFields[0])this._overrideFields=null;else{const e=[],t=[];for(const i of this.fields)if("oid"===i.type)e.push(i),t.push(i.name);else for(const s of this._overrideFields)if(s.toLowerCase()===i.name.toLowerCase()){e.push(i),t.push(i.name);break}this.fields=e,this._overrideFields=t}if(this._layer.source&&this._layer.source.sourceJSON){const e=this._layer.source.sourceJSON.currentVersion;!0===this._layer.source.sourceJSON.useStandardizedQueries?(this._databaseType=h.StandardisedNoInterval,null!=e&&e>=10.61&&(this._databaseType=h.Standardised)):null!=e&&(e>=10.5&&(this._databaseType=h.StandardisedNoInterval,this._requestStandardised=!0),e>=10.61&&(this._databaseType=h.Standardised))}this.objectIdField=this._layer.objectIdField;for(const e of this.fields)"global-id"===e.type&&(this.globalIdField=e.name);"subtype-group"===this._layer.type?(this.subtypeField=this._layer.subtypeField??"",this.subtypes=this._layer.subtypes,this.types=null,this.typeIdField=null):"oriented-imagery"===this._layer.type?(this.subtypeField=null,this.subtypes=null,this.typeIdField=this._layer.typeIdField??"",this.types=this._layer.types):(this.subtypeField=this._layer.subtypeField,this.subtypes=this._layer.subtypes,this.typeIdField=this._layer.typeIdField??"",this.types=this._layer.types)}_isInFeatureSet(){return c.InFeatureSet}async _refineSetBlock(e){return e}_candidateIdTransform(e){return e}async _getSet(e){if(null===this._wset){await this._ensureLoaded();const t=await this._getFilteredSet("",null,null,null,e);return this._wset=t,t}return this._wset}async _runDatabaseProbe(e){await this._ensureLoaded();const t=new C;this.datesInUnknownTimezone&&(t.timeReferenceUnknownClient=!0),t.where=e.replace("OBJECTID",this._layer.objectIdField);try{return await this._layer.queryObjectIds(t),!0}catch(i){return!1}}_canUsePagination(){return!(!this._layer.capabilities||!this._layer.capabilities.query||!0!==this._layer.capabilities.query.supportsPagination)}_cacheableFeatureSetSourceKey(){return this._layer.url}pbfSupportedForQuery(e){const t=this._layer?.capabilities?.query;return!e.outStatistics&&!0===t?.supportsFormatPBF&&!0===t?.supportsQuantizationEditMode}async queryPBF(e){return e.quantizationParameters={mode:"edit"},(await I(this._layer.parsedUrl,e,{format:"pbf"},{})).unquantize()}get gdbVersion(){return this._layer&&this._layer.capabilities&&this._layer.capabilities.data&&this._layer.capabilities.data.isVersioned?this._layer.gdbVersion||"SDE.DEFAULT":""}nativeCapabilities(){return{title:this._layer.title??"",source:this,canQueryRelated:!0,capabilities:this._layer.capabilities,databaseType:this._databaseType,requestStandardised:this._requestStandardised}}executeQuery(e,t){e.returnZ=this.hasZ,e.returnM=this.hasM;const i="execute"===t?D:"executeForCount"===t?F:S,s="execute"===t&&this.pbfSupportedForQuery(e);let r=null;if(this.recentlyUsedQueries){const t=this.convertQueryToLruCacheKey(e);r=this.recentlyUsedQueries.getFromCache(t),null===r&&(r=!0!==s?i(this._layer.parsedUrl.path,e):this.queryPBF(e),this.recentlyUsedQueries.addToCache(t,r),r=r.catch((e=>{throw this.recentlyUsedQueries?.removeFromCache(t),e})))}return this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:e,method:t}),null===r&&(r=!0!==s?i(this._layer.parsedUrl.path,e):this.queryPBF(e)),r}async _getFilteredSet(e,t,i,s,r){const a=await this.databaseType();if(this.isTable()&&t&&null!==e&&""!==e){return new o([],[],!0,null)}if(this._canUsePagination())return this._getFilteredSetUsingPaging(e,t,i,s,r);let n="",l=!1;null!==s&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(n=s.constructClause(),l=!0);const u=new C;this.datesInUnknownTimezone&&(u.timeReferenceUnknownClient=!0),u.where=null===i?null===t?"1=1":"":y(i,a),this._requestStandardised&&(u.sqlFormat="standard"),u.spatialRelationship=this._makeRelationshipEnum(e),u.outSpatialReference=this.spatialReference,u.orderByFields=""!==n?n.split(","):null,u.geometry=null===t?null:t,u.relationParameter=this._makeRelationshipParam(e);let d=await this.executeQuery(u,"executeForIds");null===d&&(d=[]),this._checkCancelled(r);return new o([],d,l,null)}_expandPagedSet(e,t,i,s,r){return this._expandPagedSetFeatureSet(e,t,i,s,r)}async _getFilteredSetUsingPaging(e,t,i,s,r){let a="",n=!1;null!==s&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(a=s.constructClause(),n=!0);const l=await this.databaseType();let u=null===i?null===t?"1=1":"":y(i,l);this._layer.definitionExpression&&this._useDefinitionExpression&&(u=""!==u?"(("+this._layer.definitionExpression+") AND ("+u+"))":this._layer.definitionExpression);let d=this._maxQueryRate();const h=this._layer.capabilities?.query.maxRecordCount;null!=h&&h<d&&(d=h);let c=null;if(!0===this._pageJustIds)c=new o([],["GETPAGES"],n,{spatialRel:this._makeRelationshipEnum(e),relationParam:this._makeRelationshipParam(e),outFields:this._layer.objectIdField,resultRecordCount:d,resultOffset:0,geometry:null===t?null:t,where:u,orderByFields:a,returnGeometry:!1,returnIdsOnly:"false",internal:{set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}});else{let i=!0;!0===this._removeGeometry&&(i=!1);const s=this._overrideFields??this._fieldsIncludingObjectId(["*"]);c=new o([],["GETPAGES"],n,{spatialRel:this._makeRelationshipEnum(e),relationParam:this._makeRelationshipParam(e),outFields:s.join(","),resultRecordCount:d,resultOffset:0,geometry:null===t?null:t,where:u,orderByFields:a,returnGeometry:i,returnIdsOnly:"false",internal:{set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}})}return await this._expandPagedSet(c,d,0,1,r),c}_clonePageDefinition(e){return null===e?null:!0!==e.groupbypage?{groupbypage:!1,spatialRel:e.spatialRel,relationParam:e.relationParam,outFields:e.outFields,resultRecordCount:e.resultRecordCount,resultOffset:e.resultOffset,geometry:e.geometry,where:e.where,orderByFields:e.orderByFields,returnGeometry:e.returnGeometry,returnIdsOnly:e.returnIdsOnly,internal:e.internal}:{groupbypage:!0,spatialRel:e.spatialRel,relationParam:e.relationParam,outFields:e.outFields,resultRecordCount:e.resultRecordCount,useOIDpagination:e.useOIDpagination,generatedOid:e.generatedOid,groupByFieldsForStatistics:e.groupByFieldsForStatistics,resultOffset:e.resultOffset,outStatistics:e.outStatistics,geometry:e.geometry,where:e.where,orderByFields:e.orderByFields,returnGeometry:e.returnGeometry,returnIdsOnly:e.returnIdsOnly,internal:e.internal}}async _getPhysicalPage(e,t,i){const s=e.pagesDefinition.internal.lastRetrieved,r=s,a=e.pagesDefinition.internal.lastPage,n=new C;this._requestStandardised&&(n.sqlFormat="standard"),this.datesInUnknownTimezone&&(n.timeReferenceUnknownClient=!0),n.spatialRelationship=e.pagesDefinition.spatialRel,n.relationParameter=e.pagesDefinition.relationParam,n.outFields=e.pagesDefinition.outFields.split(","),n.num=e.pagesDefinition.resultRecordCount,n.start=e.pagesDefinition.internal.lastPage,n.geometry=e.pagesDefinition.geometry,n.where=e.pagesDefinition.where,n.orderByFields=""!==e.pagesDefinition.orderByFields?e.pagesDefinition.orderByFields.split(","):null,n.returnGeometry=e.pagesDefinition.returnGeometry,n.outSpatialReference=this.spatialReference;const l=await this.executeQuery(n,"execute");if(this._checkCancelled(i),e.pagesDefinition.internal.lastPage!==a)return"done";const o=this._layer.objectIdField;for(let u=0;u<l.features.length;u++)e.pagesDefinition.internal.set[r+u]=l.features[u].attributes[o];if(!1===this._pageJustIds)for(let u=0;u<l.features.length;u++)this._featureCache[l.features[u].attributes[o]]=l.features[u];return(void 0===l.exceededTransferLimit&&l.features.length!==e.pagesDefinition.resultRecordCount||!1===l.exceededTransferLimit)&&(e.pagesDefinition.internal.fullyResolved=!0),e.pagesDefinition.internal.lastRetrieved=s+l.features.length,e.pagesDefinition.internal.lastPage+=e.pagesDefinition.resultRecordCount,"done"}_fieldsIncludingObjectId(e){if(null===e)return[this.objectIdField];const t=e.slice();if(t.includes("*"))return t;let i=!1;for(const s of t)if(s.toUpperCase()===this.objectIdField.toUpperCase()){i=!0;break}return!1===i&&t.push(this.objectIdField),t}async _getFeatures(e,t,i,s){const r=[];if(-1!==t&&void 0===this._featureCache[t]&&r.push(t),!0===this._checkIfNeedToExpandKnownPage(e,this._maxProcessingRate()))return await this._expandPagedSet(e,this._maxProcessingRate(),0,0,s),this._getFeatures(e,t,i,s);let l=0;for(let a=e._lastFetchedIndex;a<e._known.length;a++){if(e._lastFetchedIndex+=1,l++,void 0===this._featureCache[e._known[a]]){let i=!1;if(null!==this._layer._mode&&void 0!==this._layer._mode){const t=this._layer._mode;if(void 0!==t._featureMap[e._known[a]]){const s=t._featureMap[e._known[a]];null!==s&&(i=!0,this._featureCache[e._known[a]]=s)}}if(!1===i&&(e._known[a]!==t&&r.push(e._known[a]),r.length>=this._maxProcessingRate()-1))break}if(l>=i&&0===r.length)break}if(0===r.length)return"success";const o=new C;this._requestStandardised&&(o.sqlFormat="standard"),this.datesInUnknownTimezone&&(o.timeReferenceUnknownClient=!0),o.objectIds=r,o.outFields=this._overrideFields??this._fieldsIncludingObjectId(["*"]),o.returnGeometry=!0,!0===this._removeGeometry&&(o.returnGeometry=!1),o.outSpatialReference=this.spatialReference;const u=await this.executeQuery(o,"execute");if(this._checkCancelled(s),void 0!==u.error)throw new a(n.RequestFailed,{reason:u.error});const d=this._layer.objectIdField;for(let a=0;a<u.features.length;a++)this._featureCache[u.features[a].attributes[d]]=u.features[a];return"success"}async _getDistinctPages(e,t,i,s,r,l,o,u,d){await this._ensureLoaded();const h=await this.databaseType();let c=i.parseTree.column;const p=this._layer.fields??[];for(let a=0;a<p.length;a++)if(p[a].name.toLowerCase()===c.toLowerCase()){c=p[a].name;break}const f=new C;this._requestStandardised&&(f.sqlFormat="standard"),this.datesInUnknownTimezone&&(f.timeReferenceUnknownClient=!0);let _=null===l?null===r?"1=1":"":y(l,h);this._layer.definitionExpression&&this._useDefinitionExpression&&(_=""!==_?"(("+this._layer.definitionExpression+") AND ("+_+"))":this._layer.definitionExpression),f.where=_,f.spatialRelationship=this._makeRelationshipEnum(s),f.relationParameter=this._makeRelationshipParam(s),f.geometry=null===r?null:r,f.returnDistinctValues=!0,f.returnGeometry=!1,f.outFields=[c];const m=await this.executeQuery(f,"execute");if(this._checkCancelled(d),!m.hasOwnProperty("features"))throw new a(n.InvalidStatResponse);let g=!1;for(let a=0;a<p.length;a++)if(p[a].name===c){"date"===p[a].type&&(g=!0);break}for(let a=0;a<m.features.length;a++){if(g){const e=m.features[a].attributes[c];null!==e?u.push(new Date(e)):u.push(e)}else u.push(m.features[a].attributes[c]);if(u.length>=o)break}if(0===m.features.length)return u;if(m.features.length===this._layer.capabilities?.query.maxRecordCount&&u.length<o){return{calculated:!0,result:await this._getDistinctPages(e+m.features.length,t,i,s,r,l,o,u,d)}}return u}async _distinctStat(e,t,i,s,r,a,n){return{calculated:!0,result:await this._getDistinctPages(0,e,t,i,s,r,a,[],n)}}isTable(){return this._layer.isTable||null===this._layer.geometryType||"table"===this._layer.type||""===this._layer.geometryType||"esriGeometryNull"===this._layer.geometryType}async _countstat(e,t,i,s){const r=await this.databaseType(),a=new C;if(this._requestStandardised&&(a.sqlFormat="standard"),this.isTable()&&i&&null!==t&&""!==t)return{calculated:!0,result:0};let n=null===s?null===i?"1=1":"":y(s,r);this._layer.definitionExpression&&this._useDefinitionExpression&&(n=""!==n?"(("+this._layer.definitionExpression+") AND ("+n+"))":this._layer.definitionExpression),a.where=n,this.datesInUnknownTimezone&&(a.timeReferenceUnknownClient=!0),a.where=n,a.spatialRelationship=this._makeRelationshipEnum(t),a.relationParameter=this._makeRelationshipParam(t),a.geometry=null===i?null:i,a.returnGeometry=!1;return{calculated:!0,result:await this.executeQuery(a,"executeForCount")}}async _stats(e,t,i,s,r,l,o){await this._ensureLoaded();const u=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsSqlExpression,d=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsStatistics,h=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsDistinct;if("count"===e)return h?this._countstat(e,i,s,r):{calculated:!1};if(!1===d||!1===f(t)&&!1===u||!1===t.isStandardized)return""!==i||null!==r?{calculated:!1}:this._manualStat(e,t,l,o);if("distinct"===e)return!1===h?""!==i||null!==r?{calculated:!1}:this._manualStat(e,t,l,o):this._distinctStat(e,t,i,s,r,l,o);const c=await this.databaseType();if(this.isTable()&&s&&null!==i&&""!==i)return{calculated:!0,result:null};const p=new C;this._requestStandardised&&(p.sqlFormat="standard");let m=null===r?null===s?"1=1":"":y(r,c);this._layer.definitionExpression&&this._useDefinitionExpression&&(m=""!==m?"(("+this._layer.definitionExpression+") AND ("+m+"))":this._layer.definitionExpression),p.where=m,p.spatialRelationship=this._makeRelationshipEnum(i),p.relationParameter=this._makeRelationshipParam(i),p.geometry=null===s?null:s,this.datesInUnknownTimezone&&(p.timeReferenceUnknownClient=!0);const g=new P;g.statisticType=_(e),g.onStatisticField=y(t,c),g.outStatisticFieldName="ARCADE_STAT_RESULT",p.returnGeometry=!1;let w="ARCADE_STAT_RESULT";p.outStatistics=[g];const R=await this.executeQuery(p,"execute");if(!R.hasOwnProperty("features")||0===R.features.length)throw new a(n.InvalidStatResponse);let b=!1;const F=R.fields??[];for(let a=0;a<F.length;a++)if("ARCADE_STAT_RESULT"===F[a].name.toUpperCase()){w=F[a].name,"date"===F[a].type&&(b=!0);break}if(b){let e=R.features[0].attributes[w];return null!==e&&(e=new Date(R.features[0].attributes[w])),{calculated:!0,result:e}}return{calculated:!0,result:R.features[0].attributes[w]}}_stat(e,t,i,s,r,a,n){return this._stats(e,t,i,s,r,a,n)}async _canDoAggregates(e,t){await this._ensureLoaded();let i=!1;const s=this._layer.capabilities?.query,r=!0===s?.supportsSqlExpression;if(null!=s&&!0===s.supportsStatistics&&!0===s.supportsOrderBy&&(i=!0),i)for(let a=0;a<t.length-1;a++)(!1===t[a].workingexpr?.isStandardized||!1===f(t[a].workingexpr)&&!1===r)&&(i=!1);return!1!==i}_makeRelationshipEnum(e){if(e.includes("esriSpatialRelRelation"))return"relation";switch(e){case"esriSpatialRelRelation":return"relation";case"esriSpatialRelIntersects":return"intersects";case"esriSpatialRelContains":return"contains";case"esriSpatialRelOverlaps":return"overlaps";case"esriSpatialRelWithin":return"within";case"esriSpatialRelTouches":return"touches";case"esriSpatialRelCrosses":return"crosses";case"esriSpatialRelEnvelopeIntersects":return"envelope-intersects"}return e}_makeRelationshipParam(e){return e.includes("esriSpatialRelRelation")?e.split(":")[1]:""}async _getAggregatePagesDataSourceDefinition(e,t,i,s,r,a,n){await this._ensureLoaded();const l=await this.databaseType();let u="",d=!1,h=!1;null!==a&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(u=a.constructClause(),h=!0),this._layer.capabilities&&this._layer.capabilities.query&&!1===this._layer.capabilities.query.supportsPagination&&(h=!1,d=!0,u=this._layer.objectIdField);const c=[];for(let o=0;o<t.length;o++){const e=new P;e.onStatisticField=null!==t[o].workingexpr?y(t[o].workingexpr,l):"",e.outStatisticFieldName=t[o].field,e.statisticType=t[o].toStatisticsName(),c.push(e)}""===u&&(u=e.join(","));let p=this._maxQueryRate();const f=this._layer.capabilities?.query.maxRecordCount;null!=f&&f<p&&(p=f);let _=null===r?null===s?"1=1":"":y(r,l);this._layer.definitionExpression&&this._useDefinitionExpression&&(_=""!==_?"(("+this._layer.definitionExpression+") AND ("+_+"))":this._layer.definitionExpression);return new o([],["GETPAGES"],h,{groupbypage:!0,spatialRel:this._makeRelationshipEnum(i),relationParam:this._makeRelationshipParam(i),outFields:["*"],useOIDpagination:d,generatedOid:n,resultRecordCount:p,resultOffset:0,groupByFieldsForStatistics:e,outStatistics:c,geometry:null===s?null:s,where:_,orderByFields:u,returnGeometry:!1,returnIdsOnly:!1,internal:{lastMaxId:-1,set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}})}async _getAgregagtePhysicalPage(t,i,s){let r=t.pagesDefinition.where;!0===t.pagesDefinition.useOIDpagination&&(r=""!==r?"("+r+") AND ("+t.pagesDefinition.generatedOid+">"+t.pagesDefinition.internal.lastMaxId.toString()+")":t.pagesDefinition.generatedOid+">"+t.pagesDefinition.internal.lastMaxId.toString());const l=t.pagesDefinition.internal.lastRetrieved,o=l,u=t.pagesDefinition.internal.lastPage,d=new C;if(this._requestStandardised&&(d.sqlFormat="standard"),d.where=r,d.spatialRelationship=t.pagesDefinition.spatialRel,d.relationParameter=t.pagesDefinition.relationParam,d.outFields=t.pagesDefinition.outFields,d.outStatistics=t.pagesDefinition.outStatistics,d.geometry=t.pagesDefinition.geometry,d.groupByFieldsForStatistics=t.pagesDefinition.groupByFieldsForStatistics,d.num=t.pagesDefinition.resultRecordCount,d.start=t.pagesDefinition.internal.lastPage,d.returnGeometry=t.pagesDefinition.returnGeometry,this.datesInUnknownTimezone&&(d.timeReferenceUnknownClient=!0),d.orderByFields=""!==t.pagesDefinition.orderByFields?t.pagesDefinition.orderByFields.split(","):null,this.isTable()&&d.geometry&&d.spatialRelationship)return[];const h=await this.executeQuery(d,"execute");if(this._checkCancelled(s),!h.hasOwnProperty("features"))throw new a(n.InvalidStatResponse);const c=[];if(t.pagesDefinition.internal.lastPage!==u)return[];h.features.length>0&&void 0===h.features[0].attributes[t.pagesDefinition.generatedOid]&&(t.pagesDefinition.generatedOid=t.pagesDefinition.generatedOid.toLowerCase());for(let e=0;e<h.features.length;e++)t.pagesDefinition.internal.set[o+e]=h.features[e].attributes[t.pagesDefinition.generatedOid];for(let a=0;a<h.features.length;a++)c.push(new e({attributes:h.features[a].attributes,geometry:null}));return!0===t.pagesDefinition.useOIDpagination?0===h.features.length?t.pagesDefinition.internal.fullyResolved=!0:t.pagesDefinition.internal.lastMaxId=h.features[h.features.length-1].attributes[t.pagesDefinition.generatedOid]:(void 0===h.exceededTransferLimit&&h.features.length!==t.pagesDefinition.resultRecordCount||!1===h.exceededTransferLimit)&&(t.pagesDefinition.internal.fullyResolved=!0),t.pagesDefinition.internal.lastRetrieved=l+h.features.length,t.pagesDefinition.internal.lastPage+=t.pagesDefinition.resultRecordCount,c}static create(e,t,i,s,r){const a=new b({url:e,outFields:null===t?["*"]:t});return new T({layer:a,spatialReference:i,lrucache:s,interceptor:r})}relationshipMetaData(){return this._layer&&this._layer.source&&this._layer.source.sourceJSON?.relationships?this._layer.source.sourceJSON.relationships:[]}serviceUrl(){return p(this._layer.parsedUrl.path)}async queryAttachments(e,t,i,a,n){function l(e){const t=e.capabilities;return t?.data.supportsAttachment&&t?.operations.supportsQueryAttachments}const o=this._layer;if(l(o)){const l={objectIds:[e],returnMetadata:n};(t&&t>0||i&&i>0)&&(l.size=[t&&t>0?t:0,i&&i>0?i:t+1]),a&&a.length>0&&(l.attachmentTypes=a),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:o,query:l,method:"attachments"});const u=await o.queryAttachments(new x(l)),d=[];return u&&u[e]&&u[e].forEach((t=>{const i=this._layer.parsedUrl.path+"/"+e.toString()+"/attachments/"+t.id.toString();let a=null;n&&t.exifInfo&&(a=r.convertJsonToArcade(t.exifInfo,"system",!0)),d.push(new s(t.id,t.name,t.contentType,t.size,i,a,t.keywords??null))})),d}return[]}async queryRelatedFeatures(t){const s={f:"json",relationshipId:t.relationshipId.toString(),definitionExpression:t.where,outFields:t.outFields?.join(","),returnGeometry:t.returnGeometry.toString()};void 0!==t.resultOffset&&null!==t.resultOffset&&(s.resultOffset=t.resultOffset.toString()),void 0!==t.resultRecordCount&&null!==t.resultRecordCount&&(s.resultRecordCount=t.resultRecordCount.toString()),t.orderByFields&&(s.orderByFields=t.orderByFields.join(",")),t.objectIds&&t.objectIds.length>0&&(s.objectIds=t.objectIds.join(",")),t.outSpatialReference&&(s.outSR=R(t.outSpatialReference)),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preRequestCallback({layer:this._layer,queryPayload:s,method:"relatedrecords",url:this._layer.parsedUrl.path+"/queryRelatedRecords"});const r=await i(this._layer.parsedUrl.path+"/queryRelatedRecords",{responseType:"json",query:s});if(r.data){const t={},i=r.data;if(i?.relatedRecordGroups){const s=i.spatialReference;for(const r of i.relatedRecordGroups){const a=r.objectId,n=[];for(const t of r.relatedRecords){t.geometry&&(t.geometry.spatialReference=s);const i=new e({geometry:t.geometry?w(t.geometry):null,attributes:t.attributes});n.push(i)}t[a]={features:n,exceededTransferLimit:!0===i.exceededTransferLimit}}}return t}throw new a(n.InvalidRequest)}async getFeatureByObjectId(e,t){const i=new C;i.outFields=t,i.returnGeometry=!1,i.outSpatialReference=this.spatialReference,i.where=this.objectIdField+"="+e.toString(),this.datesInUnknownTimezone&&(i.timeReferenceUnknownClient=!0),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:i,method:"execute"});const s=await D(this._layer.parsedUrl.path,i);return 1===s.features.length?s.features[0]:null}async getIdentityUser(){await this.load();const e=t?.findCredential(this._layer.url);return e?e.userId:null}async getOwningSystemUrl(){await this.load();const e=t?.findServerInfo(this._layer.url);if(e)return e.owningSystemUrl;let s=this._layer.url;const r=s.toLowerCase().indexOf("/rest/services");if(s=r>-1?s.substring(0,r):s,s){s+="/rest/info";try{const e=await i(s,{query:{f:"json"}});let t="";return e.data?.owningSystemUrl&&(t=e.data.owningSystemUrl),t}catch(a){return""}}return""}getDataSourceFeatureSet(){const e=new T({layer:this._layer,spatialReference:this.spatialReference??void 0,outFields:this._overrideFields??void 0,includeGeometry:!this._removeGeometry,lrucache:this.recentlyUsedQueries??void 0,interceptor:this.featureSetQueryInterceptor??void 0});return e._useDefinitionExpression=!1,e}get preferredTimeZone(){return this._layer.preferredTimeZone??null}get dateFieldsTimeZone(){return this._layer.dateFieldsTimeZone??null}get datesInUnknownTimezone(){return this._layer.datesInUnknownTimezone??!1}get editFieldsInfo(){return this._layer.editFieldsInfo??null}get timeInfo(){return this._layer.timeInfo??null}async getFeatureSetInfo(){if(this.fsetInfo)return this.fsetInfo;let e=null,t=this._layer.serviceItemId??null;const s=this._layer.parsedUrl.path;if(s){const r=await i(s,{responseType:"json",query:{f:"json"}});e=r?.data?.name??null,t=r?.data?.serviceItemId??null}const r=this._layer.title&&null!==(this._layer.parent??null);return this.featureSetInfo={layerId:this._layer.layerId,layerName:""===e?null:e,itemId:""===t?null:t,serviceLayerUrl:""===s?null:s,webMapLayerId:r?this._layer.id??null:null,webMapLayerTitle:r?this._layer.title??null:null,className:null,objectClassId:null},this.fsetInfo}}export{T as default};
5
+ import e from"../../../Graphic.js";import{id as t}from"../../../kernel.js";import i from"../../../request.js";import s from"../../Attachment.js";import r from"../../Dictionary.js";import{FeatureSetError as a,FeatureSetErrorCodes as n}from"../support/errorsupport.js";import l from"../support/FeatureSet.js";import o from"../support/IdSet.js";import{defaultMaxRecords as u,stableStringify as d,FeatureServiceDatabaseType as h,IdState as c,extractServiceUrl as p}from"../support/shared.js";import{toWhereClause as y,isSingleField as f}from"../support/sqlUtils.js";import{decodeStatType as _}from"../support/stats.js";import{createMD5Hash as m,outputTypes as g}from"../../../core/MD5.js";import{fromJSON as w}from"../../../geometry/support/jsonUtils.js";import{srToRESTValue as R}from"../../../geometry/support/spatialReferenceUtils.js";import b from"../../../layers/FeatureLayer.js";import{executeForCount as F}from"../../../rest/query/executeForCount.js";import{executeForIds as S}from"../../../rest/query/executeForIds.js";import{executeQuery as I}from"../../../rest/query/executeQuery.js";import{executeQueryJSON as D}from"../../../rest/query/executeQueryJSON.js";import x from"../../../rest/support/AttachmentQuery.js";import C from"../../../rest/support/Query.js";import P from"../../../rest/support/StatisticDefinition.js";class T extends l{constructor(e){super(e),this.declaredClass="esri.arcade.featureset.sources.FeatureLayerDynamic",this._removeGeometry=!1,this._overrideFields=null,this.formulaCredential=null,this._pageJustIds=!1,this._requestStandardised=!1,this._useDefinitionExpression=!0,e.spatialReference&&(this.spatialReference=e.spatialReference),this._transparent=!0,this._maxProcessing=1e3,this._layer=e.layer,this._wset=null,void 0!==e.outFields&&(this._overrideFields=e.outFields),void 0!==e.includeGeometry&&(this._removeGeometry=!1===e.includeGeometry)}_maxQueryRate(){return u}end(){return this._layer}optimisePagingFeatureQueries(e){this._pageJustIds=e}get urlQueryPath(){return this._layer.parsedUrl.path||""}convertQueryToLruCacheKey(e){const t=this.urlQueryPath+","+d(e.toJSON());return m(t,g.String)}async loadImpl(){return!0===this._layer.loaded?(this._initialiseFeatureSet(),this):(await this._layer.load(),this._initialiseFeatureSet(),this)}_initialiseFeatureSet(){if(null==this.spatialReference&&(this.spatialReference=this._layer.spatialReference),this.geometryType=this._layer.geometryType,this.fields=this._layer.fields.slice(),this.hasZ=!0===this._layer?.capabilities?.data?.supportsZ,this.hasM=!0===this._layer?.capabilities?.data?.supportsM,null!==this._overrideFields)if(1===this._overrideFields.length&&"*"===this._overrideFields[0])this._overrideFields=null;else{const e=[],t=[];for(const i of this.fields)if("oid"===i.type)e.push(i),t.push(i.name);else for(const s of this._overrideFields)if(s.toLowerCase()===i.name.toLowerCase()){e.push(i),t.push(i.name);break}this.fields=e,this._overrideFields=t}if(this._layer.source&&this._layer.source.sourceJSON){const e=this._layer.source.sourceJSON.currentVersion;!0===this._layer.source.sourceJSON.useStandardizedQueries?(this._databaseType=h.StandardisedNoInterval,null!=e&&e>=10.61&&(this._databaseType=h.Standardised)):null!=e&&(e>=10.5&&(this._databaseType=h.StandardisedNoInterval,this._requestStandardised=!0),e>=10.61&&(this._databaseType=h.Standardised))}this.objectIdField=this._layer.objectIdField;for(const e of this.fields)"global-id"===e.type&&(this.globalIdField=e.name);"subtype-group"===this._layer.type?(this.subtypeField=this._layer.subtypeField??"",this.subtypes=this._layer.subtypes,this.types=null,this.typeIdField=null):"oriented-imagery"===this._layer.type?(this.subtypeField=null,this.subtypes=null,this.typeIdField=this._layer.typeIdField??"",this.types=this._layer.types):(this.subtypeField=this._layer.subtypeField,this.subtypes=this._layer.subtypes,this.typeIdField=this._layer.typeIdField??"",this.types=this._layer.types)}_isInFeatureSet(){return c.InFeatureSet}async _refineSetBlock(e){return e}_candidateIdTransform(e){return e}async _getSet(e){if(null===this._wset){await this._ensureLoaded();const t=await this._getFilteredSet("",null,null,null,e);return this._wset=t,t}return this._wset}async _runDatabaseProbe(e){await this._ensureLoaded();const t=new C;this.datesInUnknownTimezone&&(t.timeReferenceUnknownClient=!0),t.where=e.replace("OBJECTID",this._layer.objectIdField);try{return await this._layer.queryObjectIds(t),!0}catch(i){return!1}}_canUsePagination(){return!(!this._layer.capabilities||!this._layer.capabilities.query||!0!==this._layer.capabilities.query.supportsPagination)}_cacheableFeatureSetSourceKey(){return this._layer.url}pbfSupportedForQuery(e){const t=this._layer?.capabilities?.query;return!e.outStatistics&&!0===t?.supportsFormatPBF&&!0===t?.supportsQuantizationEditMode}async queryPBF(e){return e.quantizationParameters={mode:"edit"},(await I(this._layer.parsedUrl,e,{format:"pbf"},{})).unquantize()}get gdbVersion(){return this._layer&&this._layer.capabilities&&this._layer.capabilities.data&&this._layer.capabilities.data.isVersioned?this._layer.gdbVersion||"SDE.DEFAULT":""}nativeCapabilities(){return{title:this._layer.title??"",source:this,canQueryRelated:!0,capabilities:this._layer.capabilities,databaseType:this._databaseType,requestStandardised:this._requestStandardised}}executeQuery(e,t){e.returnZ=this.hasZ,e.returnM=this.hasM;const i="execute"===t?D:"executeForCount"===t?F:S,s="execute"===t&&this.pbfSupportedForQuery(e);let r=null;if(this.recentlyUsedQueries){const t=this.convertQueryToLruCacheKey(e);r=this.recentlyUsedQueries.getFromCache(t),null===r&&(r=!0!==s?i(this._layer.parsedUrl.path,e):this.queryPBF(e),this.recentlyUsedQueries.addToCache(t,r),r=r.catch((e=>{throw this.recentlyUsedQueries?.removeFromCache(t),e})))}return this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:e,method:t}),null===r&&(r=!0!==s?i(this._layer.parsedUrl.path,e):this.queryPBF(e)),r}async _getFilteredSet(e,t,i,s,r){const a=await this.databaseType();if(this.isTable()&&t&&null!==e&&""!==e){return new o([],[],!0,null)}if(this._canUsePagination())return this._getFilteredSetUsingPaging(e,t,i,s,r);let n="",l=!1;null!==s&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(n=s.constructClause(),l=!0);const u=new C;this.datesInUnknownTimezone&&(u.timeReferenceUnknownClient=!0),u.where=null===i?null===t?"1=1":"":y(i,a),this._requestStandardised&&(u.sqlFormat="standard"),u.spatialRelationship=this._makeRelationshipEnum(e),u.outSpatialReference=this.spatialReference,u.orderByFields=""!==n?n.split(","):null,u.geometry=null===t?null:t,u.relationParameter=this._makeRelationshipParam(e);let d=await this.executeQuery(u,"executeForIds");null===d&&(d=[]),this._checkCancelled(r);return new o([],d,l,null)}_expandPagedSet(e,t,i,s,r){return this._expandPagedSetFeatureSet(e,t,i,s,r)}async _getFilteredSetUsingPaging(e,t,i,s,r){let a="",n=!1;null!==s&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(a=s.constructClause(),n=!0);const l=await this.databaseType();let u=null===i?null===t?"1=1":"":y(i,l);this._layer.definitionExpression&&this._useDefinitionExpression&&(u=""!==u?"(("+this._layer.definitionExpression+") AND ("+u+"))":this._layer.definitionExpression);let d=this._maxQueryRate();const h=this._layer.capabilities?.query.maxRecordCount;null!=h&&h<d&&(d=h);let c=null;if(!0===this._pageJustIds)c=new o([],["GETPAGES"],n,{spatialRel:this._makeRelationshipEnum(e),relationParam:this._makeRelationshipParam(e),outFields:this._layer.objectIdField,resultRecordCount:d,resultOffset:0,geometry:null===t?null:t,where:u,orderByFields:a,returnGeometry:!1,returnIdsOnly:"false",internal:{set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}});else{let i=!0;!0===this._removeGeometry&&(i=!1);const s=this._overrideFields??this._fieldsIncludingObjectId(["*"]);c=new o([],["GETPAGES"],n,{spatialRel:this._makeRelationshipEnum(e),relationParam:this._makeRelationshipParam(e),outFields:s.join(","),resultRecordCount:d,resultOffset:0,geometry:null===t?null:t,where:u,orderByFields:a,returnGeometry:i,returnIdsOnly:"false",internal:{set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}})}return await this._expandPagedSet(c,d,0,1,r),c}_clonePageDefinition(e){return null===e?null:!0!==e.groupbypage?{groupbypage:!1,spatialRel:e.spatialRel,relationParam:e.relationParam,outFields:e.outFields,resultRecordCount:e.resultRecordCount,resultOffset:e.resultOffset,geometry:e.geometry,where:e.where,orderByFields:e.orderByFields,returnGeometry:e.returnGeometry,returnIdsOnly:e.returnIdsOnly,internal:e.internal}:{groupbypage:!0,spatialRel:e.spatialRel,relationParam:e.relationParam,outFields:e.outFields,resultRecordCount:e.resultRecordCount,useOIDpagination:e.useOIDpagination,generatedOid:e.generatedOid,groupByFieldsForStatistics:e.groupByFieldsForStatistics,resultOffset:e.resultOffset,outStatistics:e.outStatistics,geometry:e.geometry,where:e.where,orderByFields:e.orderByFields,returnGeometry:e.returnGeometry,returnIdsOnly:e.returnIdsOnly,internal:e.internal}}async _getPhysicalPage(e,t,i){const s=e.pagesDefinition.internal.lastRetrieved,r=s,a=e.pagesDefinition.internal.lastPage,n=new C;this._requestStandardised&&(n.sqlFormat="standard"),this.datesInUnknownTimezone&&(n.timeReferenceUnknownClient=!0),n.spatialRelationship=e.pagesDefinition.spatialRel,n.relationParameter=e.pagesDefinition.relationParam,n.outFields=e.pagesDefinition.outFields.split(","),n.num=e.pagesDefinition.resultRecordCount,n.start=e.pagesDefinition.internal.lastPage,n.geometry=e.pagesDefinition.geometry,n.where=e.pagesDefinition.where,n.orderByFields=""!==e.pagesDefinition.orderByFields?e.pagesDefinition.orderByFields.split(","):null,n.returnGeometry=e.pagesDefinition.returnGeometry,n.outSpatialReference=this.spatialReference;const l=await this.executeQuery(n,"execute");if(this._checkCancelled(i),e.pagesDefinition.internal.lastPage!==a)return"done";const o=this._layer.objectIdField;for(let u=0;u<l.features.length;u++)e.pagesDefinition.internal.set[r+u]=l.features[u].attributes[o];if(!1===this._pageJustIds)for(let u=0;u<l.features.length;u++)this._featureCache[l.features[u].attributes[o]]=l.features[u];return(void 0===l.exceededTransferLimit&&l.features.length!==e.pagesDefinition.resultRecordCount||!1===l.exceededTransferLimit)&&(e.pagesDefinition.internal.fullyResolved=!0),e.pagesDefinition.internal.lastRetrieved=s+l.features.length,e.pagesDefinition.internal.lastPage+=e.pagesDefinition.resultRecordCount,"done"}_fieldsIncludingObjectId(e){if(null===e)return[this.objectIdField];const t=e.slice();if(t.includes("*"))return t;let i=!1;for(const s of t)if(s.toUpperCase()===this.objectIdField.toUpperCase()){i=!0;break}return!1===i&&t.push(this.objectIdField),t}async _getFeatures(e,t,i,s){const r=[];if(-1!==t&&void 0===this._featureCache[t]&&r.push(t),!0===this._checkIfNeedToExpandKnownPage(e,this._maxProcessingRate()))return await this._expandPagedSet(e,this._maxProcessingRate(),0,0,s),this._getFeatures(e,t,i,s);let l=0;for(let a=e._lastFetchedIndex;a<e._known.length;a++){if(e._lastFetchedIndex+=1,l++,void 0===this._featureCache[e._known[a]]){let i=!1;if(null!==this._layer._mode&&void 0!==this._layer._mode){const t=this._layer._mode;if(void 0!==t._featureMap[e._known[a]]){const s=t._featureMap[e._known[a]];null!==s&&(i=!0,this._featureCache[e._known[a]]=s)}}if(!1===i&&(e._known[a]!==t&&r.push(e._known[a]),r.length>=this._maxProcessingRate()-1))break}if(l>=i&&0===r.length)break}if(0===r.length)return"success";const o=new C;this._requestStandardised&&(o.sqlFormat="standard"),this.datesInUnknownTimezone&&(o.timeReferenceUnknownClient=!0),o.objectIds=r,o.outFields=this._overrideFields??this._fieldsIncludingObjectId(["*"]),o.returnGeometry=!0,!0===this._removeGeometry&&(o.returnGeometry=!1),o.outSpatialReference=this.spatialReference;const u=await this.executeQuery(o,"execute");if(this._checkCancelled(s),void 0!==u.error)throw new a(n.RequestFailed,{reason:u.error});const d=this._layer.objectIdField;for(let a=0;a<u.features.length;a++)this._featureCache[u.features[a].attributes[d]]=u.features[a];return"success"}async _getDistinctPages(e,t,i,s,r,l,o,u,d){await this._ensureLoaded();const h=await this.databaseType();let c=i.parseTree.column;const p=this._layer.fields??[];for(let a=0;a<p.length;a++)if(p[a].name.toLowerCase()===c.toLowerCase()){c=p[a].name;break}const f=new C;this._requestStandardised&&(f.sqlFormat="standard"),this.datesInUnknownTimezone&&(f.timeReferenceUnknownClient=!0);let _=null===l?null===r?"1=1":"":y(l,h);this._layer.definitionExpression&&this._useDefinitionExpression&&(_=""!==_?"(("+this._layer.definitionExpression+") AND ("+_+"))":this._layer.definitionExpression),f.where=_,f.spatialRelationship=this._makeRelationshipEnum(s),f.relationParameter=this._makeRelationshipParam(s),f.geometry=null===r?null:r,f.returnDistinctValues=!0,f.returnGeometry=!1,f.outFields=[c];const m=await this.executeQuery(f,"execute");if(this._checkCancelled(d),!m.hasOwnProperty("features"))throw new a(n.InvalidStatResponse);let g=!1;for(let a=0;a<p.length;a++)if(p[a].name===c){"date"===p[a].type&&(g=!0);break}for(let a=0;a<m.features.length;a++){if(g){const e=m.features[a].attributes[c];null!==e?u.push(new Date(e)):u.push(e)}else u.push(m.features[a].attributes[c]);if(u.length>=o)break}if(0===m.features.length)return u;if(m.features.length===this._layer.capabilities?.query.maxRecordCount&&u.length<o){return{calculated:!0,result:await this._getDistinctPages(e+m.features.length,t,i,s,r,l,o,u,d)}}return u}async _distinctStat(e,t,i,s,r,a,n){return{calculated:!0,result:await this._getDistinctPages(0,e,t,i,s,r,a,[],n)}}isTable(){return this._layer.isTable||null===this._layer.geometryType||"table"===this._layer.type||""===this._layer.geometryType||"esriGeometryNull"===this._layer.geometryType}async _countstat(e,t,i,s){const r=await this.databaseType(),a=new C;if(this._requestStandardised&&(a.sqlFormat="standard"),this.isTable()&&i&&null!==t&&""!==t)return{calculated:!0,result:0};let n=null===s?null===i?"1=1":"":y(s,r);this._layer.definitionExpression&&this._useDefinitionExpression&&(n=""!==n?"(("+this._layer.definitionExpression+") AND ("+n+"))":this._layer.definitionExpression),a.where=n,this.datesInUnknownTimezone&&(a.timeReferenceUnknownClient=!0),a.where=n,a.spatialRelationship=this._makeRelationshipEnum(t),a.relationParameter=this._makeRelationshipParam(t),a.geometry=null===i?null:i,a.returnGeometry=!1;return{calculated:!0,result:await this.executeQuery(a,"executeForCount")}}async _stats(e,t,i,s,r,l,o){await this._ensureLoaded();const u=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsSqlExpression,d=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsStatistics,h=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsDistinct;if("count"===e)return h?this._countstat(e,i,s,r):{calculated:!1};if(!1===d||!1===f(t)&&!1===u||!1===t.isStandardized)return""!==i||null!==r?{calculated:!1}:this._manualStat(e,t,l,o);if("distinct"===e)return!1===h?""!==i||null!==r?{calculated:!1}:this._manualStat(e,t,l,o):this._distinctStat(e,t,i,s,r,l,o);const c=await this.databaseType();if(this.isTable()&&s&&null!==i&&""!==i)return{calculated:!0,result:null};const p=new C;this._requestStandardised&&(p.sqlFormat="standard");let m=null===r?null===s?"1=1":"":y(r,c);this._layer.definitionExpression&&this._useDefinitionExpression&&(m=""!==m?"(("+this._layer.definitionExpression+") AND ("+m+"))":this._layer.definitionExpression),p.where=m,p.spatialRelationship=this._makeRelationshipEnum(i),p.relationParameter=this._makeRelationshipParam(i),p.geometry=null===s?null:s,this.datesInUnknownTimezone&&(p.timeReferenceUnknownClient=!0);const g=new P;g.statisticType=_(e),g.onStatisticField=y(t,c),g.outStatisticFieldName="ARCADE_STAT_RESULT",p.returnGeometry=!1;let w="ARCADE_STAT_RESULT";p.outStatistics=[g];const R=await this.executeQuery(p,"execute");if(!R.hasOwnProperty("features")||0===R.features.length)throw new a(n.InvalidStatResponse);let b=!1;const F=R.fields??[];for(let a=0;a<F.length;a++)if("ARCADE_STAT_RESULT"===F[a].name.toUpperCase()){w=F[a].name,"date"===F[a].type&&(b=!0);break}if(b){let e=R.features[0].attributes[w];return null!==e&&(e=new Date(R.features[0].attributes[w])),{calculated:!0,result:e}}return{calculated:!0,result:R.features[0].attributes[w]}}_stat(e,t,i,s,r,a,n){return this._stats(e,t,i,s,r,a,n)}async _canDoAggregates(e,t){await this._ensureLoaded();let i=!1;const s=this._layer.capabilities?.query,r=!0===s?.supportsSqlExpression;if(null!=s&&!0===s.supportsStatistics&&!0===s.supportsOrderBy&&(i=!0),i)for(let a=0;a<t.length-1;a++)(!1===t[a].workingexpr?.isStandardized||!1===f(t[a].workingexpr)&&!1===r)&&(i=!1);return!1!==i}_makeRelationshipEnum(e){if(e.includes("esriSpatialRelRelation"))return"relation";switch(e){case"esriSpatialRelRelation":return"relation";case"esriSpatialRelIntersects":return"intersects";case"esriSpatialRelContains":return"contains";case"esriSpatialRelOverlaps":return"overlaps";case"esriSpatialRelWithin":return"within";case"esriSpatialRelTouches":return"touches";case"esriSpatialRelCrosses":return"crosses";case"esriSpatialRelEnvelopeIntersects":return"envelope-intersects"}return e}_makeRelationshipParam(e){return e.includes("esriSpatialRelRelation")?e.split(":")[1]:""}async _getAggregatePagesDataSourceDefinition(e,t,i,s,r,a,n){await this._ensureLoaded();const l=await this.databaseType();let u="",d=!1,h=!1;null!==a&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(u=a.constructClause(),h=!0),this._layer.capabilities&&this._layer.capabilities.query&&!1===this._layer.capabilities.query.supportsPagination&&(h=!1,d=!0,u=this._layer.objectIdField);const c=[];for(let o=0;o<t.length;o++){const e=new P;e.onStatisticField=null!==t[o].workingexpr?y(t[o].workingexpr,l):"",e.outStatisticFieldName=t[o].field,e.statisticType=t[o].toStatisticsName(),c.push(e)}""===u&&(u=e.join(","));let p=this._maxQueryRate();const f=this._layer.capabilities?.query.maxRecordCount;null!=f&&f<p&&(p=f);let _=null===r?null===s?"1=1":"":y(r,l);this._layer.definitionExpression&&this._useDefinitionExpression&&(_=""!==_?"(("+this._layer.definitionExpression+") AND ("+_+"))":this._layer.definitionExpression);return new o([],["GETPAGES"],h,{groupbypage:!0,spatialRel:this._makeRelationshipEnum(i),relationParam:this._makeRelationshipParam(i),outFields:["*"],useOIDpagination:d,generatedOid:n,resultRecordCount:p,resultOffset:0,groupByFieldsForStatistics:e,outStatistics:c,geometry:null===s?null:s,where:_,orderByFields:u,returnGeometry:!1,returnIdsOnly:!1,internal:{lastMaxId:-1,set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}})}async _getAgregagtePhysicalPage(t,i,s){let r=t.pagesDefinition.where;!0===t.pagesDefinition.useOIDpagination&&(r=""!==r?"("+r+") AND ("+t.pagesDefinition.generatedOid+">"+t.pagesDefinition.internal.lastMaxId.toString()+")":t.pagesDefinition.generatedOid+">"+t.pagesDefinition.internal.lastMaxId.toString());const l=t.pagesDefinition.internal.lastRetrieved,o=l,u=t.pagesDefinition.internal.lastPage,d=new C;if(this._requestStandardised&&(d.sqlFormat="standard"),d.where=r,d.spatialRelationship=t.pagesDefinition.spatialRel,d.relationParameter=t.pagesDefinition.relationParam,d.outFields=t.pagesDefinition.outFields,d.outStatistics=t.pagesDefinition.outStatistics,d.geometry=t.pagesDefinition.geometry,d.groupByFieldsForStatistics=t.pagesDefinition.groupByFieldsForStatistics,d.num=t.pagesDefinition.resultRecordCount,d.start=t.pagesDefinition.internal.lastPage,d.returnGeometry=t.pagesDefinition.returnGeometry,this.datesInUnknownTimezone&&(d.timeReferenceUnknownClient=!0),d.orderByFields=""!==t.pagesDefinition.orderByFields?t.pagesDefinition.orderByFields.split(","):null,this.isTable()&&d.geometry&&d.spatialRelationship)return[];const h=await this.executeQuery(d,"execute");if(this._checkCancelled(s),!h.hasOwnProperty("features"))throw new a(n.InvalidStatResponse);const c=[];if(t.pagesDefinition.internal.lastPage!==u)return[];h.features.length>0&&void 0===h.features[0].attributes[t.pagesDefinition.generatedOid]&&(t.pagesDefinition.generatedOid=t.pagesDefinition.generatedOid.toLowerCase());for(let e=0;e<h.features.length;e++)t.pagesDefinition.internal.set[o+e]=h.features[e].attributes[t.pagesDefinition.generatedOid];for(let a=0;a<h.features.length;a++)c.push(new e({attributes:h.features[a].attributes,geometry:null}));return!0===t.pagesDefinition.useOIDpagination?0===h.features.length?t.pagesDefinition.internal.fullyResolved=!0:t.pagesDefinition.internal.lastMaxId=h.features[h.features.length-1].attributes[t.pagesDefinition.generatedOid]:(void 0===h.exceededTransferLimit&&h.features.length!==t.pagesDefinition.resultRecordCount||!1===h.exceededTransferLimit)&&(t.pagesDefinition.internal.fullyResolved=!0),t.pagesDefinition.internal.lastRetrieved=l+h.features.length,t.pagesDefinition.internal.lastPage+=t.pagesDefinition.resultRecordCount,c}static create(e,t,i,s,r){const a=new b({url:e,outFields:null===t?["*"]:t});return new T({layer:a,spatialReference:i,lrucache:s,interceptor:r})}relationshipMetaData(){return this._layer&&this._layer.source&&this._layer.source.sourceJSON?.relationships?this._layer.source.sourceJSON.relationships:[]}serviceUrl(){return p(this._layer.parsedUrl.path)}async queryAttachments(e,t,i,a,n){function l(e){const t=e.capabilities;return t?.data.supportsAttachment&&t?.operations.supportsQueryAttachments}const o=this._layer;if(l(o)){const l={objectIds:[e],returnMetadata:n};(t&&t>0||i&&i>0)&&(l.size=[t&&t>0?t:0,i&&i>0?i:t+1]),a&&a.length>0&&(l.attachmentTypes=a),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:o,query:l,method:"attachments"});const u=await o.queryAttachments(new x(l)),d=[];return u&&u[e]&&u[e].forEach((t=>{const i=this._layer.parsedUrl.path+"/"+e.toString()+"/attachments/"+t.id.toString();let a=null;n&&t.exifInfo&&(a=r.convertJsonToArcade(t.exifInfo,"system",!0)),d.push(new s(t.id,t.name,t.contentType,t.size,i,a,t.keywords??null))})),d}return[]}async queryRelatedFeatures(t){const s={f:"json",relationshipId:t.relationshipId.toString(),definitionExpression:t.where,outFields:t.outFields?.join(","),returnGeometry:t.returnGeometry.toString()};void 0!==t.resultOffset&&null!==t.resultOffset&&(s.resultOffset=t.resultOffset.toString()),void 0!==t.resultRecordCount&&null!==t.resultRecordCount&&(s.resultRecordCount=t.resultRecordCount.toString()),t.orderByFields&&(s.orderByFields=t.orderByFields.join(",")),t.objectIds&&t.objectIds.length>0&&(s.objectIds=t.objectIds.join(",")),t.outSpatialReference&&(s.outSR=R(t.outSpatialReference)),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preRequestCallback({layer:this._layer,queryPayload:s,method:"relatedrecords",url:this._layer.parsedUrl.path+"/queryRelatedRecords"});const r=await i(this._layer.parsedUrl.path+"/queryRelatedRecords",{responseType:"json",query:s});if(r.data){const t={},i=r.data;if(i?.relatedRecordGroups){const s=i.spatialReference;for(const r of i.relatedRecordGroups){const a=r.objectId,n=[];for(const t of r.relatedRecords){t.geometry&&(t.geometry.spatialReference=s);const i=new e({geometry:t.geometry?w(t.geometry):null,attributes:t.attributes});n.push(i)}t[a]={features:n,exceededTransferLimit:!0===i.exceededTransferLimit}}}return t}throw new a(n.InvalidRequest)}async getFeatureByObjectId(e,t){const i=new C;i.outFields=t,i.returnGeometry=!1,i.outSpatialReference=this.spatialReference,i.where=this.objectIdField+"="+e.toString(),this.datesInUnknownTimezone&&(i.timeReferenceUnknownClient=!0),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:i,method:"execute"});const s=await D(this._layer.parsedUrl.path,i);return 1===s.features.length?s.features[0]:null}async getIdentityUser(){await this.load();const e=t?.findCredential(this._layer.url);return e?e.userId:null}async getOwningSystemUrl(){await this.load();const e=t?.findServerInfo(this._layer.url);if(e)return e.owningSystemUrl;let s=this._layer.url;const r=s.toLowerCase().indexOf("/rest/services");if(s=r>-1?s.slice(0,r):s,s){s+="/rest/info";try{const e=await i(s,{query:{f:"json"}});let t="";return e.data?.owningSystemUrl&&(t=e.data.owningSystemUrl),t}catch(a){return""}}return""}getDataSourceFeatureSet(){const e=new T({layer:this._layer,spatialReference:this.spatialReference??void 0,outFields:this._overrideFields??void 0,includeGeometry:!this._removeGeometry,lrucache:this.recentlyUsedQueries??void 0,interceptor:this.featureSetQueryInterceptor??void 0});return e._useDefinitionExpression=!1,e}get preferredTimeZone(){return this._layer.preferredTimeZone??null}get dateFieldsTimeZone(){return this._layer.dateFieldsTimeZone??null}get datesInUnknownTimezone(){return this._layer.datesInUnknownTimezone??!1}get editFieldsInfo(){return this._layer.editFieldsInfo??null}get timeInfo(){return this._layer.timeInfo??null}async getFeatureSetInfo(){if(this.fsetInfo)return this.fsetInfo;let e=null,t=this._layer.serviceItemId??null;const s=this._layer.parsedUrl.path;if(s){const r=await i(s,{responseType:"json",query:{f:"json"}});e=r?.data?.name??null,t=r?.data?.serviceItemId??null}const r=this._layer.title&&null!==(this._layer.parent??null);return this.featureSetInfo={layerId:this._layer.layerId,layerName:""===e?null:e,itemId:""===t?null:t,serviceLayerUrl:""===s?null:s,webMapLayerId:r?this._layer.id??null:null,webMapLayerTitle:r?this._layer.title??null:null,className:null,objectClassId:null},this.fsetInfo}}export{T 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.31/esri/copyright.txt for details.
4
4
  */
5
- const t=new RegExp("^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$","i");function e(t){let e="";for(let r=0;r<t;r++)e+=(65536*(1+Math.random())|0).toString(16).substring(1);return e}class r{constructor(t){if(this._value="",!t)throw new TypeError("Invalid argument; `value` has no value.");this._value=r.EMPTY,t&&t instanceof r?this._value=t.toString():t&&"[object String]"===Object.prototype.toString.call(t)&&r.isGuid(t)&&(this._value=t)}equals(t){return r.isGuid(t)&&this._value===t}isEmpty(){return this._value===r.EMPTY}toString(){return this._value}toJSON(){return this._value}static isGuid(e){return e&&(e instanceof r||t.test(e.toString()))}static create(){return new r([e(2),e(1),e(1),e(1),e(3)].join("-"))}static raw(){return[e(2),e(1),e(1),e(1),e(3)].join("-")}}r.EMPTY="00000000-0000-0000-0000-000000000000";export{r as default};
5
+ const t=new RegExp("^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$","i");function e(t){let e="";for(let r=0;r<t;r++)e+=(65536*(1+Math.random())|0).toString(16).slice(1);return e}class r{constructor(t){if(this._value="",!t)throw new TypeError("Invalid argument; `value` has no value.");this._value=r.EMPTY,t&&t instanceof r?this._value=t.toString():t&&"[object String]"===Object.prototype.toString.call(t)&&r.isGuid(t)&&(this._value=t)}equals(t){return r.isGuid(t)&&this._value===t}isEmpty(){return this._value===r.EMPTY}toString(){return this._value}toJSON(){return this._value}static isGuid(e){return e&&(e instanceof r||t.test(e.toString()))}static create(){return new r([e(2),e(1),e(1),e(1),e(3)].join("-"))}static raw(){return[e(2),e(1),e(1),e(1),e(3)].join("-")}}r.EMPTY="00000000-0000-0000-0000-000000000000";export{r 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.31/esri/copyright.txt for details.
4
4
  */
5
- import t from"../ArcadePortal.js";import e from"../Attachment.js";import r from"../Dictionary.js";import{ArcadeExecutionError as n,ExecutionErrorCodes as a}from"../executionError.js";import{H as o,j as i,P as u,g as s,B as l,K as d,h as p,t as c,o as f,q as h,T as y,r as m,U as g,N as A,V as w,W as I,X as v,Y as U,c as b,Z as j,k as x,m as N,n as P,a as F,b as T,i as C,u as O,s as k}from"../../chunks/languageUtils.js";import{layerFieldEsriConstants as L}from"../featureset/support/shared.js";import{convertDirection as S}from"./convertdirection.js";import{XXH as z}from"./hash.js";import{hasSamePortal as D}from"../../core/urlUtils.js";import{generateUUID as R}from"../../core/uuid.js";import H from"../../geometry/Extent.js";import M from"../../geometry/Multipoint.js";import V from"../../geometry/Point.js";import W from"../../geometry/Polygon.js";import J from"../../geometry/Polyline.js";import B from"../../geometry/SpatialReference.js";import Z from"../../portal/Portal.js";function E(t){if("loaded"===t.loadStatus&&t.user?.sourceJSON){return t.user.sourceJSON}return null}function q(t,e){return!!t&&D(t,e?.restUrl||"")}function K(t,e){if(!t||!e)return t===e;if(t.x===e.x&&t.y===e.y){if(t.hasZ){if(t.z!==e.z)return!1}else if(e.hasZ)return!1;if(t.hasM){if(t.m!==e.m)return!1}else if(e.hasM)return!1;return!0}return!1}function X(o,i,u){if(null!==o)if(f(o)){if(i.updateUint8Array([61]),u.map.has(o)){const t=u.map.get(o);i.updateIntArray([61237541^t])}else{u.map.set(o,u.currentLength++);for(const t of o)X(t,i,u);u.map.delete(o),u.currentLength--}i.updateUint8Array([199])}else if(h(o)){if(i.updateUint8Array([61]),u.map.has(o)){const t=u.map.get(o);i.updateIntArray([61237541^t])}else{u.map.set(o,u.currentLength++);for(const t of o.toArray())X(t,i,u);u.map.delete(o),u.currentLength--}i.updateUint8Array([199])}else{if(x(o))return i.updateIntArray([o.toNumber()]),void i.updateUint8Array([241]);if(N(o))return i.updateIntArray([o.toNumber()]),void i.updateIntArray([257]);if(P(o))return i.updateIntArray([o.toNumber()]),void i.updateIntArray([263]);if(b(o))return i.updateIntArray([o.length]),i.updateWithString(o),void i.updateUint8Array([41]);if(F(o))i.updateUint8Array([!0===o?1:0,113]);else{if(T(o))return i.updateFloatArray([o]),void i.updateUint8Array([173]);if(o instanceof e)throw new n(u.context,a.UnsupportedHashType,u.node);if(o instanceof t)throw new n(u.context,a.UnsupportedHashType,u.node);if(!(o instanceof r)){if(m(o))throw new n(u.context,a.UnsupportedHashType,u.node);if(o instanceof V)return i.updateIntArray([3833836621]),i.updateIntArray([0]),i.updateFloatArray([o.x]),i.updateIntArray([1]),i.updateFloatArray([o.y]),o.hasZ&&(i.updateIntArray([2]),i.updateFloatArray([o.z])),o.hasM&&(i.updateIntArray([3]),i.updateFloatArray([o.m])),i.updateIntArray([3765347959]),void X(o.spatialReference.wkid,i,u);if(o instanceof W){i.updateIntArray([1266616829]);for(let t=0;t<o.rings.length;t++){const e=o.rings[t],r=[];let n=null,a=null;for(let i=0;i<e.length;i++){const u=o.getPoint(t,i);if(0===i)n=u;else if(K(a,u))continue;a=u,i===e.length-1&&K(n,u)||r.push(u)}i.updateIntArray([1397116793,r.length]);for(let t=0;t<r.length;t++){const e=r[t];i.updateIntArray([3962308117,t]),X(e,i,u),i.updateIntArray([2716288009])}i.updateIntArray([2278822459])}return i.updateIntArray([3878477243]),void X(o.spatialReference.wkid,i,u)}if(o instanceof J){i.updateIntArray([4106883559]);for(let t=0;t<o.paths.length;t++){const e=o.paths[t];i.updateIntArray([1397116793,e.length]);for(let r=0;r<e.length;r++)i.updateIntArray([3962308117,r]),X(o.getPoint(t,r),i,u),i.updateIntArray([2716288009]);i.updateIntArray([2278822459])}return i.updateIntArray([2568784753]),void X(o.spatialReference.wkid,i,u)}if(o instanceof M){i.updateIntArray([588535921,o.points.length]);for(let t=0;t<o.points.length;t++){const e=o.getPoint(t);i.updateIntArray([t]),X(e,i,u)}return i.updateIntArray([1700171621]),void X(o.spatialReference.wkid,i,u)}if(o instanceof H)return i.updateIntArray([3483648373]),i.updateIntArray([0]),i.updateFloatArray([o.xmax]),i.updateIntArray([1]),i.updateFloatArray([o.xmin]),i.updateIntArray([2]),i.updateFloatArray([o.ymax]),i.updateIntArray([3]),i.updateFloatArray([o.ymin]),o.hasZ&&(i.updateIntArray([4]),i.updateFloatArray([o.zmax]),i.updateIntArray([5]),i.updateFloatArray([o.zmin])),o.hasM&&(i.updateIntArray([6]),i.updateFloatArray([o.mmax]),i.updateIntArray([7]),i.updateFloatArray([o.mmin])),i.updateIntArray([3622027469]),void X(o.spatialReference.wkid,i,u);if(o instanceof B)return i.updateIntArray([14]),void 0!==o.wkid&&null!==o.wkid&&i.updateIntArray([o.wkid]),o.wkt&&i.updateWithString(o.wkt),void(o.wkt2&&i.updateWithString(o.wkt2));if(C(o))throw new n(u.context,a.UnsupportedHashType,u.node);if(O(o))throw new n(u.context,a.UnsupportedHashType,u.node);if(k(o))throw new n(u.context,a.UnsupportedHashType,u.node);if(o===l)throw new n(u.context,a.UnsupportedHashType,u.node);throw new n(u.context,a.UnsupportedHashType,u.node)}if(i.updateUint8Array([223]),u.map.has(o)){const t=u.map.get(o);i.updateIntArray([61237541^t])}else{u.map.set(o,u.currentLength++);for(const t of o.keys()){i.updateIntArray([t.length]),i.updateWithString(t),i.updateUint8Array([251]);X(o.field(t),i,u),i.updateUint8Array([239])}u.map.delete(o),u.currentLength--}i.updateUint8Array([73])}}else i.updateUint8Array([0,139])}function Y(e,x){e.portal=function(e,r){return x(e,r,((n,a,u)=>(o(u,1,1,e,r),new t(i(u[0])))))},e.typeof=function(t,e){return x(t,e,((r,i,s)=>{o(s,1,1,t,e);const l=u(s[0]);if("Unrecognized Type"===l)throw new n(t,a.UnrecognizedType,e);return l}))},e.trim=function(t,e){return x(t,e,((r,n,a)=>(o(a,1,1,t,e),i(a[0]).trim())))},e.tohex=function(t,e){return x(t,e,((r,n,a)=>{o(a,1,1,t,e);const i=s(a[0]);return isNaN(i)?i:i.toString(16)}))},e.upper=function(t,e){return x(t,e,((r,n,a)=>(o(a,1,1,t,e),i(a[0]).toUpperCase())))},e.proper=function(t,e){return x(t,e,((r,n,a)=>{o(a,1,2,t,e);let u=1;2===a.length&&"firstword"===i(a[1]).toLowerCase()&&(u=2);const s=/\s/,l=i(a[0]);let d="",p=!0;for(let t=0;t<l.length;t++){let e=l[t];if(s.test(e))1===u&&(p=!0);else{e.toUpperCase()!==e.toLowerCase()&&(p?(e=e.toUpperCase(),p=!1):e=e.toLowerCase())}d+=e}return d}))},e.lower=function(t,e){return x(t,e,((r,n,a)=>(o(a,1,1,t,e),i(a[0]).toLowerCase())))},e.guid=function(t,e){return x(t,e,((r,n,a)=>{if(o(a,0,1,t,e),a.length>0)switch(i(a[0]).toLowerCase()){case"digits":return R().replace("-","").replace("-","").replace("-","").replace("-","");case"digits-hyphen":return R();case"digits-hyphen-braces":return"{"+R()+"}";case"digits-hyphen-parentheses":return"("+R()+")"}return"{"+R()+"}"}))},e.standardizeguid=function(t,e){return x(t,e,((r,n,a)=>{o(a,2,2,t,e);let u=i(a[0]);if(""===u||null===u)return"";const s=/^(\{|\()?(?<partA>[0-9a-z]{8})(-?)(?<partB>[0-9a-z]{4})(-?)(?<partC>[0-9a-z]{4})(-?)(?<partD>[0-9a-z]{4})(-?)(?<partE>[0-9a-z]{12})(\}|\))?$/gim.exec(u);if(!s)return"";const l=s.groups;switch(u=l.partA+"-"+l.partB+"-"+l.partC+"-"+l.partD+"-"+l.partE,i(a[1]).toLowerCase()){case"digits":return u.replace("-","").replace("-","").replace("-","").replace("-","");case"digits-hyphen":return u;case"digits-hyphen-braces":return"{"+u+"}";case"digits-hyphen-parentheses":return"("+u+")"}return"{"+u+"}"}))},e.console=function(t,e){return x(t,e,((e,r,n)=>(0===n.length||(1===n.length?t.console(i(n[0])):t.console(i(n))),l)))},e.mid=function(t,e){return x(t,e,((r,n,a)=>{o(a,2,3,t,e);let u=s(a[1]);if(isNaN(u))return"";if(u<0&&(u=0),2===a.length)return i(a[0]).substring(u);let l=s(a[2]);return isNaN(l)?"":(l<0&&(l=0),i(a[0]).substring(u,u+l))}))},e.find=function(t,e){return x(t,e,((r,n,a)=>{o(a,2,3,t,e);let u=0;if(a.length>2){if(u=s(d(a[2],0)),isNaN(u))return-1;u<0&&(u=0)}return i(a[1]).indexOf(i(a[0]),u)}))},e.left=function(t,e){return x(t,e,((r,n,a)=>{o(a,2,2,t,e);let u=s(a[1]);return isNaN(u)?"":(u<0&&(u=0),i(a[0]).substring(0,u))}))},e.right=function(t,e){return x(t,e,((r,n,a)=>{o(a,2,2,t,e);const u=s(a[1]);if(isNaN(u)||u<=0)return"";return i(a[0]).slice(-u)}))},e.split=function(t,e){return x(t,e,((r,n,a)=>{let u;o(a,2,4,t,e);let l=s(d(a[2],-1));const c=p(d(a[3],!1));if(-1===l||null===l||!0===c?u=i(a[0]).split(i(a[1])):(isNaN(l)&&(l=-1),l<-1&&(l=-1),u=i(a[0]).split(i(a[1]),l)),!1===c)return u;const f=[];for(let t=0;t<u.length&&!(-1!==l&&f.length>=l);t++)""!==u[t]&&void 0!==u[t]&&f.push(u[t]);return f}))},e.text=function(t,e){return x(t,e,((r,n,a)=>(o(a,1,2,t,e),c(a[0],a[1]))))},e.concatenate=function(t,e){return x(t,e,((t,e,r)=>{const n=[];if(r.length<1)return"";if(f(r[0])){const t=d(r[2],"");for(let e=0;e<r[0].length;e++)n[e]=c(r[0][e],t);return r.length>1?n.join(r[1]):n.join("")}if(h(r[0])){const t=d(r[2],"");for(let e=0;e<r[0].length();e++)n[e]=c(r[0].get(e),t);return r.length>1?n.join(r[1]):n.join("")}for(let a=0;a<r.length;a++)n[a]=c(r[a]);return n.join("")}))},e.reverse=function(t,e){return x(t,e,((r,i,u)=>{if(o(u,1,1,t,e),f(u[0])){const t=u[0].slice();return t.reverse(),t}if(h(u[0])){const t=u[0].toArray().slice();return t.reverse(),t}throw new n(t,a.InvalidParameter,e)}))},e.replace=function(t,e){return x(t,e,((r,n,a)=>{o(a,3,4,t,e);const u=i(a[0]),s=i(a[1]),l=i(a[2]);return 4!==a.length||p(a[3])?y(u,s,l):u.replace(s,l)}))},e.schema=function(t,e){return x(t,e,((o,i,u)=>{if(m(u[0])){const e=g(u[0]);return e?r.convertObjectToArcadeDictionary(e,A(t)):null}throw new n(t,a.InvalidParameter,e)}))},e.subtypes=function(t,e){return x(t,e,((i,u,s)=>{if(o(s,1,1,t,e),m(s[0])){const e=w(s[0]);return e?r.convertObjectToArcadeDictionary(e,A(t)):null}throw new n(t,a.InvalidParameter,e)}))},e.subtypecode=function(t,e){return x(t,e,((r,i,u)=>{if(o(u,1,1,t,e),m(u[0])){const t=w(u[0]);if(!t)return null;if(t.subtypeField&&u[0].hasField(t.subtypeField)){const e=u[0].field(t.subtypeField);for(const r of t.subtypes)if(r.code===e)return r.code;return null}return null}throw new n(t,a.InvalidParameter,e)}))},e.subtypename=function(t,e){return x(t,e,((r,i,u)=>{if(o(u,1,1,t,e),m(u[0])){const t=w(u[0]);if(!t)return"";if(t.subtypeField&&u[0].hasField(t.subtypeField)){const e=u[0].field(t.subtypeField);for(const r of t.subtypes)if(r.code===e)return r.name;return""}return""}throw new n(t,a.InvalidParameter,e)}))},e.gdbversion=function(t,e){return x(t,e,((r,i,u)=>{if(o(u,1,1,t,e),m(u[0]))return u[0].gdbVersion();throw new n(t,a.InvalidParameter,e)}))},e.domain=function(t,e){return x(t,e,((u,s,l)=>{if(o(l,2,3,t,e),m(l[0])){const e=I(l[0],i(l[1]),void 0===l[2]?void 0:l[2]);return e&&e.domain?"coded-value"===e.domain.type||"codedValue"===e.domain.type?r.convertObjectToArcadeDictionary({type:"codedValue",name:e.domain.name,dataType:L[e.field.type],codedValues:e.domain.codedValues.map((t=>({name:t.name,code:t.code})))},A(t)):r.convertObjectToArcadeDictionary({type:"range",name:e.domain.name,dataType:L[e.field.type],min:e.domain.minValue,max:e.domain.maxValue},A(t)):null}throw new n(t,a.InvalidParameter,e)}))},e.domainname=function(t,e){return x(t,e,((r,u,s)=>{if(o(s,2,4,t,e),m(s[0]))return v(s[0],i(s[1]),s[2],void 0===s[3]?void 0:s[3]);throw new n(t,a.InvalidParameter,e)}))},e.domaincode=function(t,e){return x(t,e,((r,u,s)=>{if(o(s,2,4,t,e),m(s[0]))return U(s[0],i(s[1]),s[2],void 0===s[3]?void 0:s[3]);throw new n(t,a.InvalidParameter,e)}))},e.urlencode=function(t,e){return x(t,e,((n,a,u)=>{if(o(u,1,1,t,e),null===u[0])return"";if(u[0]instanceof r){let t="";for(const e of u[0].keys()){const r=u[0].field(e);""!==t&&(t+="&"),t+=null===r?encodeURIComponent(e)+"=":encodeURIComponent(e)+"="+encodeURIComponent(r)}return t}return encodeURIComponent(i(u[0]))}))},e.hash=function(t,e){return x(t,e,((r,n,a)=>{o(a,1,1,t,e);const i=new z(0);return X(a[0],i,{context:t,node:e,map:new Map,currentLength:0}),i.digest()}))},e.convertdirection=function(t,e){return x(t,e,((r,n,a)=>(o(a,3,3,t,e),S(a[0],a[1],a[2]))))},e.fromjson=function(t,e){return x(t,e,((u,s,l)=>{if(o(l,1,1,t,e),!1===b(l[0]))throw new n(t,a.InvalidParameter,e);return r.convertJsonToArcade(JSON.parse(i(l[0])),A(t))}))},e.expects=function(t,e){return x(t,e,((r,o,i)=>{if(i.length<1)throw new n(t,a.WrongNumberOfParameters,e);return l}))},e.tocharcode=function(t,e){return x(t,e,((r,u,l)=>{o(l,1,2,t,e);const p=s(d(l[1],0)),c=i(l[0]);if(0===c.length&&1===l.length)return null;if(c.length<=p||p<0)throw new n(t,a.OutOfBounds,e);return c.charCodeAt(p)}))},e.tocodepoint=function(t,e){return x(t,e,((r,u,l)=>{o(l,1,2,t,e);const p=s(d(l[1],0)),c=i(l[0]);if(0===c.length&&1===l.length)return null;if(c.length<=p||p<0)throw new n(t,a.OutOfBounds,e);return c.codePointAt(p)}))},e.fromcharcode=function(t,e){return x(t,e,((r,o,i)=>{if(i.length<1)throw new n(t,a.WrongNumberOfParameters,e);const u=i.map((t=>Math.trunc(s(t)))).filter((t=>t>=0&&t<=65535));return 0===u.length?null:String.fromCharCode.apply(null,u)}))},e.fromcodepoint=function(t,e){return x(t,e,((r,o,i)=>{if(i.length<1)throw new n(t,a.WrongNumberOfParameters,e);let u;try{u=i.map((t=>Math.trunc(s(t)))).filter((t=>t<=1114111&&t>>>0===t))}catch(l){return null}return 0===u.length?null:String.fromCodePoint.apply(null,u)}))},e.getuser=function(e,u){return x(e,u,((s,l,p)=>{o(p,0,2,e,u);let c=d(p[1],"");if(c=!0===c||!1===c?"":i(c),null!==c&&""!==c)return null;if(0===p.length||p[0]instanceof t){let t=null;if(t=e.services?.portal?e.services.portal:Z.getDefault(),p.length>0){if(!q(p[0].field("url"),t))return null}if(!t)return null;if(""===c){const n=E(t);if(n){const t=JSON.parse(JSON.stringify(n));for(const e of["lastLogin","created","modified"])void 0!==t[e]&&null!==t[e]&&(t[e]=new Date(t[e]));return r.convertObjectToArcadeDictionary(t,A(e))}}return null}throw new n(e,a.InvalidParameter,u)}))},e.getenvironment=function(t,e){return x(t,e,((n,a,i)=>(o(i,0,0,t,e),r.convertObjectToArcadeDictionary(j(A(t),t.spatialReference),A(t),!0))))}}export{Y as registerFunctions};
5
+ import t from"../ArcadePortal.js";import e from"../Attachment.js";import r from"../Dictionary.js";import{ArcadeExecutionError as n,ExecutionErrorCodes as a}from"../executionError.js";import{H as o,j as i,P as u,g as s,B as l,K as c,h as d,t as p,o as f,q as h,T as y,r as m,U as g,N as A,V as w,W as I,X as v,Y as U,c as j,Z as x,k as b,m as N,n as P,a as F,b as T,i as C,u as O,s as k}from"../../chunks/languageUtils.js";import{layerFieldEsriConstants as L}from"../featureset/support/shared.js";import{convertDirection as S}from"./convertdirection.js";import{XXH as z}from"./hash.js";import{hasSamePortal as D}from"../../core/urlUtils.js";import{generateUUID as R}from"../../core/uuid.js";import H from"../../geometry/Extent.js";import M from"../../geometry/Multipoint.js";import V from"../../geometry/Point.js";import W from"../../geometry/Polygon.js";import J from"../../geometry/Polyline.js";import B from"../../geometry/SpatialReference.js";import Z from"../../portal/Portal.js";function E(t){if("loaded"===t.loadStatus&&t.user?.sourceJSON){return t.user.sourceJSON}return null}function q(t,e){return!!t&&D(t,e?.restUrl||"")}function K(t,e){if(!t||!e)return t===e;if(t.x===e.x&&t.y===e.y){if(t.hasZ){if(t.z!==e.z)return!1}else if(e.hasZ)return!1;if(t.hasM){if(t.m!==e.m)return!1}else if(e.hasM)return!1;return!0}return!1}function X(o,i,u){if(null!==o)if(f(o)){if(i.updateUint8Array([61]),u.map.has(o)){const t=u.map.get(o);i.updateIntArray([61237541^t])}else{u.map.set(o,u.currentLength++);for(const t of o)X(t,i,u);u.map.delete(o),u.currentLength--}i.updateUint8Array([199])}else if(h(o)){if(i.updateUint8Array([61]),u.map.has(o)){const t=u.map.get(o);i.updateIntArray([61237541^t])}else{u.map.set(o,u.currentLength++);for(const t of o.toArray())X(t,i,u);u.map.delete(o),u.currentLength--}i.updateUint8Array([199])}else{if(b(o))return i.updateIntArray([o.toNumber()]),void i.updateUint8Array([241]);if(N(o))return i.updateIntArray([o.toNumber()]),void i.updateIntArray([257]);if(P(o))return i.updateIntArray([o.toNumber()]),void i.updateIntArray([263]);if(j(o))return i.updateIntArray([o.length]),i.updateWithString(o),void i.updateUint8Array([41]);if(F(o))i.updateUint8Array([!0===o?1:0,113]);else{if(T(o))return i.updateFloatArray([o]),void i.updateUint8Array([173]);if(o instanceof e)throw new n(u.context,a.UnsupportedHashType,u.node);if(o instanceof t)throw new n(u.context,a.UnsupportedHashType,u.node);if(!(o instanceof r)){if(m(o))throw new n(u.context,a.UnsupportedHashType,u.node);if(o instanceof V)return i.updateIntArray([3833836621]),i.updateIntArray([0]),i.updateFloatArray([o.x]),i.updateIntArray([1]),i.updateFloatArray([o.y]),o.hasZ&&(i.updateIntArray([2]),i.updateFloatArray([o.z])),o.hasM&&(i.updateIntArray([3]),i.updateFloatArray([o.m])),i.updateIntArray([3765347959]),void X(o.spatialReference.wkid,i,u);if(o instanceof W){i.updateIntArray([1266616829]);for(let t=0;t<o.rings.length;t++){const e=o.rings[t],r=[];let n=null,a=null;for(let i=0;i<e.length;i++){const u=o.getPoint(t,i);if(0===i)n=u;else if(K(a,u))continue;a=u,i===e.length-1&&K(n,u)||r.push(u)}i.updateIntArray([1397116793,r.length]);for(let t=0;t<r.length;t++){const e=r[t];i.updateIntArray([3962308117,t]),X(e,i,u),i.updateIntArray([2716288009])}i.updateIntArray([2278822459])}return i.updateIntArray([3878477243]),void X(o.spatialReference.wkid,i,u)}if(o instanceof J){i.updateIntArray([4106883559]);for(let t=0;t<o.paths.length;t++){const e=o.paths[t];i.updateIntArray([1397116793,e.length]);for(let r=0;r<e.length;r++)i.updateIntArray([3962308117,r]),X(o.getPoint(t,r),i,u),i.updateIntArray([2716288009]);i.updateIntArray([2278822459])}return i.updateIntArray([2568784753]),void X(o.spatialReference.wkid,i,u)}if(o instanceof M){i.updateIntArray([588535921,o.points.length]);for(let t=0;t<o.points.length;t++){const e=o.getPoint(t);i.updateIntArray([t]),X(e,i,u)}return i.updateIntArray([1700171621]),void X(o.spatialReference.wkid,i,u)}if(o instanceof H)return i.updateIntArray([3483648373]),i.updateIntArray([0]),i.updateFloatArray([o.xmax]),i.updateIntArray([1]),i.updateFloatArray([o.xmin]),i.updateIntArray([2]),i.updateFloatArray([o.ymax]),i.updateIntArray([3]),i.updateFloatArray([o.ymin]),o.hasZ&&(i.updateIntArray([4]),i.updateFloatArray([o.zmax]),i.updateIntArray([5]),i.updateFloatArray([o.zmin])),o.hasM&&(i.updateIntArray([6]),i.updateFloatArray([o.mmax]),i.updateIntArray([7]),i.updateFloatArray([o.mmin])),i.updateIntArray([3622027469]),void X(o.spatialReference.wkid,i,u);if(o instanceof B)return i.updateIntArray([14]),void 0!==o.wkid&&null!==o.wkid&&i.updateIntArray([o.wkid]),o.wkt&&i.updateWithString(o.wkt),void(o.wkt2&&i.updateWithString(o.wkt2));if(C(o))throw new n(u.context,a.UnsupportedHashType,u.node);if(O(o))throw new n(u.context,a.UnsupportedHashType,u.node);if(k(o))throw new n(u.context,a.UnsupportedHashType,u.node);if(o===l)throw new n(u.context,a.UnsupportedHashType,u.node);throw new n(u.context,a.UnsupportedHashType,u.node)}if(i.updateUint8Array([223]),u.map.has(o)){const t=u.map.get(o);i.updateIntArray([61237541^t])}else{u.map.set(o,u.currentLength++);for(const t of o.keys()){i.updateIntArray([t.length]),i.updateWithString(t),i.updateUint8Array([251]);X(o.field(t),i,u),i.updateUint8Array([239])}u.map.delete(o),u.currentLength--}i.updateUint8Array([73])}}else i.updateUint8Array([0,139])}function Y(e,b){e.portal=function(e,r){return b(e,r,((n,a,u)=>(o(u,1,1,e,r),new t(i(u[0])))))},e.typeof=function(t,e){return b(t,e,((r,i,s)=>{o(s,1,1,t,e);const l=u(s[0]);if("Unrecognized Type"===l)throw new n(t,a.UnrecognizedType,e);return l}))},e.trim=function(t,e){return b(t,e,((r,n,a)=>(o(a,1,1,t,e),i(a[0]).trim())))},e.tohex=function(t,e){return b(t,e,((r,n,a)=>{o(a,1,1,t,e);const i=s(a[0]);return isNaN(i)?i:i.toString(16)}))},e.upper=function(t,e){return b(t,e,((r,n,a)=>(o(a,1,1,t,e),i(a[0]).toUpperCase())))},e.proper=function(t,e){return b(t,e,((r,n,a)=>{o(a,1,2,t,e);let u=1;2===a.length&&"firstword"===i(a[1]).toLowerCase()&&(u=2);const s=/\s/,l=i(a[0]);let c="",d=!0;for(let t=0;t<l.length;t++){let e=l[t];if(s.test(e))1===u&&(d=!0);else{e.toUpperCase()!==e.toLowerCase()&&(d?(e=e.toUpperCase(),d=!1):e=e.toLowerCase())}c+=e}return c}))},e.lower=function(t,e){return b(t,e,((r,n,a)=>(o(a,1,1,t,e),i(a[0]).toLowerCase())))},e.guid=function(t,e){return b(t,e,((r,n,a)=>{if(o(a,0,1,t,e),a.length>0)switch(i(a[0]).toLowerCase()){case"digits":return R().replace("-","").replace("-","").replace("-","").replace("-","");case"digits-hyphen":return R();case"digits-hyphen-braces":return"{"+R()+"}";case"digits-hyphen-parentheses":return"("+R()+")"}return"{"+R()+"}"}))},e.standardizeguid=function(t,e){return b(t,e,((r,n,a)=>{o(a,2,2,t,e);let u=i(a[0]);if(""===u||null===u)return"";const s=/^(\{|\()?(?<partA>[0-9a-z]{8})(-?)(?<partB>[0-9a-z]{4})(-?)(?<partC>[0-9a-z]{4})(-?)(?<partD>[0-9a-z]{4})(-?)(?<partE>[0-9a-z]{12})(\}|\))?$/gim.exec(u);if(!s)return"";const l=s.groups;switch(u=l.partA+"-"+l.partB+"-"+l.partC+"-"+l.partD+"-"+l.partE,i(a[1]).toLowerCase()){case"digits":return u.replace("-","").replace("-","").replace("-","").replace("-","");case"digits-hyphen":return u;case"digits-hyphen-braces":return"{"+u+"}";case"digits-hyphen-parentheses":return"("+u+")"}return"{"+u+"}"}))},e.console=function(t,e){return b(t,e,((e,r,n)=>(0===n.length||(1===n.length?t.console(i(n[0])):t.console(i(n))),l)))},e.mid=function(t,e){return b(t,e,((r,n,a)=>{o(a,2,3,t,e);let u=s(a[1]);if(isNaN(u))return"";if(u=Math.max(0,u),2===a.length)return i(a[0]).slice(u);let l=s(a[2]);return isNaN(l)?"":(l<0&&(l=0),i(a[0]).slice(u,u+l))}))},e.find=function(t,e){return b(t,e,((r,n,a)=>{o(a,2,3,t,e);let u=0;if(a.length>2){if(u=s(c(a[2],0)),isNaN(u))return-1;u<0&&(u=0)}return i(a[1]).indexOf(i(a[0]),u)}))},e.left=function(t,e){return b(t,e,((r,n,a)=>{o(a,2,2,t,e);let u=s(a[1]);return isNaN(u)?"":(u<0&&(u=0),i(a[0]).slice(0,u))}))},e.right=function(t,e){return b(t,e,((r,n,a)=>{o(a,2,2,t,e);const u=s(a[1]);if(isNaN(u)||u<=0)return"";return i(a[0]).slice(-u)}))},e.split=function(t,e){return b(t,e,((r,n,a)=>{let u;o(a,2,4,t,e);let l=s(c(a[2],-1));const p=d(c(a[3],!1));if(-1===l||null===l||!0===p?u=i(a[0]).split(i(a[1])):(isNaN(l)&&(l=-1),l<-1&&(l=-1),u=i(a[0]).split(i(a[1]),l)),!1===p)return u;const f=[];for(let t=0;t<u.length&&!(-1!==l&&f.length>=l);t++)""!==u[t]&&void 0!==u[t]&&f.push(u[t]);return f}))},e.text=function(t,e){return b(t,e,((r,n,a)=>(o(a,1,2,t,e),p(a[0],a[1]))))},e.concatenate=function(t,e){return b(t,e,((t,e,r)=>{const n=[];if(r.length<1)return"";if(f(r[0])){const t=c(r[2],"");for(let e=0;e<r[0].length;e++)n[e]=p(r[0][e],t);return r.length>1?n.join(r[1]):n.join("")}if(h(r[0])){const t=c(r[2],"");for(let e=0;e<r[0].length();e++)n[e]=p(r[0].get(e),t);return r.length>1?n.join(r[1]):n.join("")}for(let a=0;a<r.length;a++)n[a]=p(r[a]);return n.join("")}))},e.reverse=function(t,e){return b(t,e,((r,i,u)=>{if(o(u,1,1,t,e),f(u[0])){const t=u[0].slice();return t.reverse(),t}if(h(u[0])){const t=u[0].toArray().slice();return t.reverse(),t}throw new n(t,a.InvalidParameter,e)}))},e.replace=function(t,e){return b(t,e,((r,n,a)=>{o(a,3,4,t,e);const u=i(a[0]),s=i(a[1]),l=i(a[2]);return 4!==a.length||d(a[3])?y(u,s,l):u.replace(s,l)}))},e.schema=function(t,e){return b(t,e,((o,i,u)=>{if(m(u[0])){const e=g(u[0]);return e?r.convertObjectToArcadeDictionary(e,A(t)):null}throw new n(t,a.InvalidParameter,e)}))},e.subtypes=function(t,e){return b(t,e,((i,u,s)=>{if(o(s,1,1,t,e),m(s[0])){const e=w(s[0]);return e?r.convertObjectToArcadeDictionary(e,A(t)):null}throw new n(t,a.InvalidParameter,e)}))},e.subtypecode=function(t,e){return b(t,e,((r,i,u)=>{if(o(u,1,1,t,e),m(u[0])){const t=w(u[0]);if(!t)return null;if(t.subtypeField&&u[0].hasField(t.subtypeField)){const e=u[0].field(t.subtypeField);for(const r of t.subtypes)if(r.code===e)return r.code;return null}return null}throw new n(t,a.InvalidParameter,e)}))},e.subtypename=function(t,e){return b(t,e,((r,i,u)=>{if(o(u,1,1,t,e),m(u[0])){const t=w(u[0]);if(!t)return"";if(t.subtypeField&&u[0].hasField(t.subtypeField)){const e=u[0].field(t.subtypeField);for(const r of t.subtypes)if(r.code===e)return r.name;return""}return""}throw new n(t,a.InvalidParameter,e)}))},e.gdbversion=function(t,e){return b(t,e,((r,i,u)=>{if(o(u,1,1,t,e),m(u[0]))return u[0].gdbVersion();throw new n(t,a.InvalidParameter,e)}))},e.domain=function(t,e){return b(t,e,((u,s,l)=>{if(o(l,2,3,t,e),m(l[0])){const e=I(l[0],i(l[1]),void 0===l[2]?void 0:l[2]);return e&&e.domain?"coded-value"===e.domain.type||"codedValue"===e.domain.type?r.convertObjectToArcadeDictionary({type:"codedValue",name:e.domain.name,dataType:L[e.field.type],codedValues:e.domain.codedValues.map((t=>({name:t.name,code:t.code})))},A(t)):r.convertObjectToArcadeDictionary({type:"range",name:e.domain.name,dataType:L[e.field.type],min:e.domain.minValue,max:e.domain.maxValue},A(t)):null}throw new n(t,a.InvalidParameter,e)}))},e.domainname=function(t,e){return b(t,e,((r,u,s)=>{if(o(s,2,4,t,e),m(s[0]))return v(s[0],i(s[1]),s[2],void 0===s[3]?void 0:s[3]);throw new n(t,a.InvalidParameter,e)}))},e.domaincode=function(t,e){return b(t,e,((r,u,s)=>{if(o(s,2,4,t,e),m(s[0]))return U(s[0],i(s[1]),s[2],void 0===s[3]?void 0:s[3]);throw new n(t,a.InvalidParameter,e)}))},e.urlencode=function(t,e){return b(t,e,((n,a,u)=>{if(o(u,1,1,t,e),null===u[0])return"";if(u[0]instanceof r){let t="";for(const e of u[0].keys()){const r=u[0].field(e);""!==t&&(t+="&"),t+=null===r?encodeURIComponent(e)+"=":encodeURIComponent(e)+"="+encodeURIComponent(r)}return t}return encodeURIComponent(i(u[0]))}))},e.hash=function(t,e){return b(t,e,((r,n,a)=>{o(a,1,1,t,e);const i=new z(0);return X(a[0],i,{context:t,node:e,map:new Map,currentLength:0}),i.digest()}))},e.convertdirection=function(t,e){return b(t,e,((r,n,a)=>(o(a,3,3,t,e),S(a[0],a[1],a[2]))))},e.fromjson=function(t,e){return b(t,e,((u,s,l)=>{if(o(l,1,1,t,e),!1===j(l[0]))throw new n(t,a.InvalidParameter,e);return r.convertJsonToArcade(JSON.parse(i(l[0])),A(t))}))},e.expects=function(t,e){return b(t,e,((r,o,i)=>{if(i.length<1)throw new n(t,a.WrongNumberOfParameters,e);return l}))},e.tocharcode=function(t,e){return b(t,e,((r,u,l)=>{o(l,1,2,t,e);const d=s(c(l[1],0)),p=i(l[0]);if(0===p.length&&1===l.length)return null;if(p.length<=d||d<0)throw new n(t,a.OutOfBounds,e);return p.charCodeAt(d)}))},e.tocodepoint=function(t,e){return b(t,e,((r,u,l)=>{o(l,1,2,t,e);const d=s(c(l[1],0)),p=i(l[0]);if(0===p.length&&1===l.length)return null;if(p.length<=d||d<0)throw new n(t,a.OutOfBounds,e);return p.codePointAt(d)}))},e.fromcharcode=function(t,e){return b(t,e,((r,o,i)=>{if(i.length<1)throw new n(t,a.WrongNumberOfParameters,e);const u=i.map((t=>Math.trunc(s(t)))).filter((t=>t>=0&&t<=65535));return 0===u.length?null:String.fromCharCode.apply(null,u)}))},e.fromcodepoint=function(t,e){return b(t,e,((r,o,i)=>{if(i.length<1)throw new n(t,a.WrongNumberOfParameters,e);let u;try{u=i.map((t=>Math.trunc(s(t)))).filter((t=>t<=1114111&&t>>>0===t))}catch(l){return null}return 0===u.length?null:String.fromCodePoint.apply(null,u)}))},e.getuser=function(e,u){return b(e,u,((s,l,d)=>{o(d,0,2,e,u);let p=c(d[1],"");if(p=!0===p||!1===p?"":i(p),null!==p&&""!==p)return null;if(0===d.length||d[0]instanceof t){let t=null;if(t=e.services?.portal?e.services.portal:Z.getDefault(),d.length>0){if(!q(d[0].field("url"),t))return null}if(!t)return null;if(""===p){const n=E(t);if(n){const t=JSON.parse(JSON.stringify(n));for(const e of["lastLogin","created","modified"])void 0!==t[e]&&null!==t[e]&&(t[e]=new Date(t[e]));return r.convertObjectToArcadeDictionary(t,A(e))}}return null}throw new n(e,a.InvalidParameter,u)}))},e.getenvironment=function(t,e){return b(t,e,((n,a,i)=>(o(i,0,0,t,e),r.convertObjectToArcadeDictionary(x(A(t),t.spatialReference),A(t),!0))))}}export{Y as registerFunctions};