@arcgis/core 5.1.0-next.44 → 5.1.0-next.45

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 (134) hide show
  1. package/applications/Components/featureUtils.d.ts +11 -7
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/{45cf181c1945e6c77a4b.js → 0155e5679ded9de5c327.js} +1 -1
  4. package/assets/esri/core/workers/chunks/128799741dd3c6fc69b9.js +1 -0
  5. package/assets/esri/core/workers/chunks/13eb0162d95b4d27389c.js +1 -0
  6. package/assets/esri/core/workers/chunks/1a481f3ae3146682eb00.js +1 -0
  7. package/assets/esri/core/workers/chunks/1cce2f8837ad765acf44.js +1 -0
  8. package/assets/esri/core/workers/chunks/2379c64b0ca30814a815.js +1 -0
  9. package/assets/esri/core/workers/chunks/23a9070e9362b8439770.js +1 -0
  10. package/assets/esri/core/workers/chunks/{9aa1ad8b436b5b0dd5f5.js → 288bd32831e94e81653e.js} +1 -1
  11. package/assets/esri/core/workers/chunks/2b3a8a53cd68f666676b.js +1 -0
  12. package/assets/esri/core/workers/chunks/{4d16b6ac52e25bd7e6aa.js → 32a51ce8e1a362115c89.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{392941013107bbd96503.js → 365ad1ffd496ed86637b.js} +1 -1
  14. package/assets/esri/core/workers/chunks/375eac59c9f88c7572db.js +2 -0
  15. package/assets/esri/core/workers/chunks/{eab74d830c2eaa9d133b.js → 4869e2f35aaf6b058281.js} +1 -1
  16. package/assets/esri/core/workers/chunks/{10941b50f5933d168df6.js → 521a671182b0f79e3624.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{c2f3fc1b34a6782b431f.js → 5351e71ce7839636d06d.js} +1 -1
  18. package/assets/esri/core/workers/chunks/5b515b5741733bcb4645.js +1 -0
  19. package/assets/esri/core/workers/chunks/{1669f1bf959c4e3083da.js → 5c0b3c76a7bc971c61dc.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{5f81f9e586b3ba0c34d4.js → 5c830cce32710d70dfa6.js} +1 -1
  21. package/assets/esri/core/workers/chunks/5e9bd5ed6ecee5b15127.js +1 -0
  22. package/assets/esri/core/workers/chunks/617328964d480d4a3a45.js +1 -0
  23. package/assets/esri/core/workers/chunks/650614a9e4871714c42e.js +1 -0
  24. package/assets/esri/core/workers/chunks/66baacbef23291eab853.js +1 -0
  25. package/assets/esri/core/workers/chunks/7278cc37e85f0242f19b.js +1 -0
  26. package/assets/esri/core/workers/chunks/{3c597d8ef898627b8f93.js → 768bbc910be6c65ac107.js} +1 -1
  27. package/assets/esri/core/workers/chunks/{a1f36240a31057f998da.js → 79dc7045d9a2d43ba8df.js} +1 -1
  28. package/assets/esri/core/workers/chunks/{f9da5c81535eaffc8b9c.js → 7f07f490c6fcc794c8d9.js} +1 -1
  29. package/assets/esri/core/workers/chunks/{2b386374330d96387aec.js → 851fc5290497991ba001.js} +1 -1
  30. package/assets/esri/core/workers/chunks/{c9f5d72b86ecb2a30587.js → 8cafdd4addd366795600.js} +1 -1
  31. package/assets/esri/core/workers/chunks/{30cdb2d1d9f018f1642d.js → 9032c040b214b5af775b.js} +1 -1
  32. package/assets/esri/core/workers/chunks/{ff8ec6369c8a1bee9bb4.js → 908f171b9c512d738dea.js} +1 -1
  33. package/assets/esri/core/workers/chunks/{c7799ba861ac5af08e6a.js → 92d4e962284e13ba2fc5.js} +1 -1
  34. package/assets/esri/core/workers/chunks/970d971551e42f7ae08d.js +1 -0
  35. package/assets/esri/core/workers/chunks/9802770413ad814dab29.js +1 -0
  36. package/assets/esri/core/workers/chunks/{6e8cfe69617876ee0dac.js → a69f1879735a031f62e9.js} +1 -1
  37. package/assets/esri/core/workers/chunks/{af804beb43d4d10c54d9.js → a9f35127c3f5bf42036b.js} +1 -1
  38. package/assets/esri/core/workers/chunks/beb53b372d356800f333.js +1 -0
  39. package/assets/esri/core/workers/chunks/{3c7ee71f0d8582e6d78f.js → bf4d2f42d31861ea1046.js} +1 -1
  40. package/assets/esri/core/workers/chunks/c2aa3b1344b42a904234.js +1 -0
  41. package/assets/esri/core/workers/chunks/{4140d4c8b6b122fc2cd4.js → ca88a364ef911526102e.js} +1 -1
  42. package/assets/esri/core/workers/chunks/cdeb6aec578a1c07d663.js +1 -0
  43. package/assets/esri/core/workers/chunks/cf5e4cf9b1aa37eeb6b0.js +1 -0
  44. package/assets/esri/core/workers/chunks/d0adf059085ddf7151dd.js +1 -0
  45. package/assets/esri/core/workers/chunks/d2af5342fbe80e2d8c60.js +1 -0
  46. package/assets/esri/core/workers/chunks/d3d024b3d2bb8fbbf760.js +1 -0
  47. package/assets/esri/core/workers/chunks/{c0cc4ca138db47052845.js → dbafe96ce37bb82d0584.js} +1 -1
  48. package/assets/esri/core/workers/chunks/e4e0c5a45cf32973d5d5.js +1 -0
  49. package/assets/esri/core/workers/chunks/{6cc5c37d6bdaf5483bd4.js → e5927f9d0e757ec4c22a.js} +1 -1
  50. package/assets/esri/core/workers/chunks/{465cc0e00f03cdb640b2.js → e7402dfd683f82878360.js} +1 -1
  51. package/assets/esri/core/workers/chunks/{8838ff9668b472af16a1.js → ef0eae13408cbf83a64f.js} +1 -1
  52. package/assets/esri/core/workers/chunks/f1767b8ba82fdd9bd947.js +1 -0
  53. package/assets/esri/core/workers/chunks/{fb69a0bb025b7a5ec588.js → f6e3954ddbb5993d56df.js} +1 -1
  54. package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
  55. package/assets/esri/libs/lyr3d/lyr3DWorker.wasm +0 -0
  56. package/assets/esri/libs/vxl/vxlLayer.wasm +0 -0
  57. package/assets/esri/themes/base/widgets/_Grid.scss +5 -0
  58. package/assets/esri/themes/dark/main.css +1 -1
  59. package/assets/esri/themes/light/main.css +1 -1
  60. package/assets/esri/themes/light/view.css +1 -1
  61. package/chunks/Jpg.js +1 -1
  62. package/chunks/Zlib.js +1 -1
  63. package/chunks/lyr3DMain.js +1 -1
  64. package/chunks/lyr3DWorker.js +1 -1
  65. package/chunks/vxlLayer.js +1 -1
  66. package/config.js +1 -1
  67. package/geometry/support/zscale.js +1 -1
  68. package/kernel.js +1 -1
  69. package/layers/Lyr3DWasmPerSceneView.js +1 -1
  70. package/layers/graphics/featureConversionUtils.js +1 -1
  71. package/layers/ogc/ogcFeatureUtils.js +1 -1
  72. package/layers/raster/formats/ImageCanvasDecoder.js +1 -1
  73. package/layers/raster/formats/JpgPlus.js +1 -1
  74. package/layers/raster/formats/RasterCodec.js +1 -1
  75. package/layers/raster/formats/TiffDecoder.js +1 -1
  76. package/layers/save/featureLayerUtils.js +1 -1
  77. package/layers/save/groupLayerUtils.js +1 -1
  78. package/layers/save/mapImageLayerUtils.js +1 -1
  79. package/layers/support/SubtypeSublayer.js +1 -1
  80. package/layers/support/layerUtils.js +1 -1
  81. package/package.json +2 -2
  82. package/rest/query/operations/pbfFeatureSetUtils.js +1 -1
  83. package/rest/query/operations/pbfFlatFeatureSet.js +1 -1
  84. package/rest/query/operations/pbfOptimizedFeatureSet.js +1 -1
  85. package/support/revision.js +1 -1
  86. package/third-party-notices.txt +2 -2
  87. package/views/2d/engine/ManagedCanvas.js +1 -1
  88. package/views/2d/engine/vectorTiles/VTLPainter3D.js +1 -1
  89. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  90. package/views/2d/layers/FeatureLikeLayerView2D.js +1 -1
  91. package/views/2d/layers/TileLayerView2D.js +1 -1
  92. package/views/2d/layers/features/FeaturePipelineWorker.js +1 -1
  93. package/views/2d/layers/features/Processor.js +1 -1
  94. package/views/2d/layers/features/processor/AProcessorStrategy.js +1 -1
  95. package/views/2d/layers/features/processor/ClusterStrategy.js +1 -1
  96. package/views/2d/layers/imagery/BaseImageryTileSubView2D.js +1 -1
  97. package/views/3d/layers/i3s/I3SClientMaterialUtil.js +1 -1
  98. package/views/3d/webgl-engine/collections/Component/ComponentDrawParameters.js +1 -1
  99. package/views/3d/webgl-engine/core/renderPasses/RenderPassManager.js +1 -1
  100. package/views/3d/webgl-engine/effects/WeatherFader.js +1 -1
  101. package/views/interactive/GraphicManipulator.js +1 -1
  102. package/widgets/AreaMeasurement2D/AreaMeasurement2DTool.js +1 -1
  103. package/widgets/DistanceMeasurement2D/DistanceMeasurement2DTool.js +1 -1
  104. package/widgets/Editor/EditorViewModel.d.ts +1 -1
  105. package/widgets/Editor.d.ts +2 -1
  106. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  107. package/widgets/FeatureTable.js +1 -1
  108. package/widgets/Sketch/support/PluginManager.js +1 -1
  109. package/assets/esri/core/workers/chunks/02a0a58ca5916db1db19.js +0 -1
  110. package/assets/esri/core/workers/chunks/03c8453ae72a4e190252.js +0 -1
  111. package/assets/esri/core/workers/chunks/0e669a04999feb9f98c9.js +0 -1
  112. package/assets/esri/core/workers/chunks/244dd7a948ca8a7dc6ef.js +0 -1
  113. package/assets/esri/core/workers/chunks/26cafd20c8d03c274389.js +0 -1
  114. package/assets/esri/core/workers/chunks/2cd0934163cb627ce251.js +0 -1
  115. package/assets/esri/core/workers/chunks/2fa86dacc8a12a6a6c43.js +0 -1
  116. package/assets/esri/core/workers/chunks/3e26f9af6b8c75bad97a.js +0 -1
  117. package/assets/esri/core/workers/chunks/5a6a6e7151085a3cd3dd.js +0 -1
  118. package/assets/esri/core/workers/chunks/5eb9fdb076488de9cd83.js +0 -1
  119. package/assets/esri/core/workers/chunks/65865c25487d23dd2e31.js +0 -1
  120. package/assets/esri/core/workers/chunks/65ea5028eb12457a3aeb.js +0 -1
  121. package/assets/esri/core/workers/chunks/8333561a938bcdf6c2e6.js +0 -1
  122. package/assets/esri/core/workers/chunks/848c6989a6a222c7a1d8.js +0 -2
  123. package/assets/esri/core/workers/chunks/91718795fc4ca6516ac7.js +0 -1
  124. package/assets/esri/core/workers/chunks/9b80569819cd1c72a9ff.js +0 -1
  125. package/assets/esri/core/workers/chunks/a4a2e7bc3369434c5cfa.js +0 -1
  126. package/assets/esri/core/workers/chunks/b056b4c79bcd542dd1d2.js +0 -1
  127. package/assets/esri/core/workers/chunks/b553264db0f10bb8c5f7.js +0 -1
  128. package/assets/esri/core/workers/chunks/c4f64195e44986644993.js +0 -1
  129. package/assets/esri/core/workers/chunks/ca6012135929b028ea1b.js +0 -1
  130. package/assets/esri/core/workers/chunks/de79645e559a2d1ffa67.js +0 -1
  131. package/assets/esri/core/workers/chunks/df5788d42787ee8bf523.js +0 -1
  132. package/assets/esri/core/workers/chunks/f0e6a26a3625068b08ab.js +0 -1
  133. package/assets/esri/core/workers/chunks/f36a234ef35faf8ca04d.js +0 -1
  134. /package/assets/esri/core/workers/chunks/{848c6989a6a222c7a1d8.js.LICENSE.txt → 375eac59c9f88c7572db.js.LICENSE.txt} +0 -0
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import t from"../../../core/Error.js";import{isAborted as e,createAbortError as a}from"../../../core/promiseUtils.js";import{Z as n}from"../../../chunks/Zlib.js";class i{constructor(t){this._canvas=null,this._ctx=null,t&&(this._canvas=t.canvas,this._ctx=t.ctx||t.canvas&&t.canvas.getContext("2d"))}decode(n,s,r){if(!n||n.byteLength<10)throw new t("imagecanvasdecoder: decode","required a valid encoded data as input.");let{width:c=0,height:h=0,format:o}=s;const{applyJpegMask:l}=s;if(l&&(!c||!h))throw new t("imagecanvasdecoder: decode","image width and height are needed to apply jpeg mask directly to canvas");return new Promise((t,d)=>{let g=null;"jpg"===o&&l&&(g=i._getMask(n,{width:c,height:h}));const w=new Blob([new Uint8Array(n)],{type:"image/"+o=="jpg"?"jpeg":o}),v=URL.createObjectURL(w),m=new Image;m.src=v,m.onload=()=>{if(URL.revokeObjectURL(v),e(r))return void d(a());c=m.width,h=m.height,this._canvas&&this._ctx?(this._canvas.width===c&&this._canvas.height===h||(this._canvas.width=c,this._canvas.height=h),this._ctx.clearRect(0,0,c,h)):(this._canvas=document.createElement("canvas"),this._canvas.width=c,this._canvas.height=h,this._ctx=this._canvas.getContext("2d")),this._ctx.drawImage(m,0,0);const n=this._ctx.getImageData(0,0,c,h),i=n.data;if(s.renderOnCanvas){if(g)for(let t=0;t<g.length;t++)g[t]?i[4*t+3]=255:i[4*t+3]=0;return this._ctx.putImageData(n,0,0),void t(null)}const o=c*h,l=new Uint8Array(o),w=new Uint8Array(o),_=new Uint8Array(o);if(g)for(let t=0;t<o;t++)l[t]=i[4*t],w[t]=i[4*t+1],_[t]=i[4*t+2];else{g=new Uint8Array(o);for(let t=0;t<o;t++)l[t]=i[4*t],w[t]=i[4*t+1],_[t]=i[4*t+2],g[t]=i[4*t+3]}t({width:c,height:h,pixels:[l,w,_],mask:g,pixelType:"u8"})},m.onerror=()=>{URL.revokeObjectURL(v),d("cannot load image")}})}static _getMask(t,e){let a=null;try{const i=new Uint8Array(t),s=Math.ceil(i.length/2);let r=0;const c=i.length-2;for(r=s;r<c&&(255!==i[r]||217!==i[r+1]);r++);if(r+=2,r<i.length-1){const t=new n(i.subarray(r)).getBytes();a=new Uint8Array(e.width*e.height);let s=0;for(let e=0;e<t.length;e++)for(let n=7;n>=0;n--)a[s++]=t[e]>>n&1}}catch(i){}return a}}export{i as default};
2
+ import t from"../../../core/Error.js";import{isAborted as e,createAbortError as a}from"../../../core/promiseUtils.js";import{F as n}from"../../../chunks/Zlib.js";class i{constructor(t){this._canvas=null,this._ctx=null,t&&(this._canvas=t.canvas,this._ctx=t.ctx||t.canvas&&t.canvas.getContext("2d"))}decode(n,s,r){if(!n||n.byteLength<10)throw new t("imagecanvasdecoder: decode","required a valid encoded data as input.");let{width:c=0,height:h=0,format:o}=s;const{applyJpegMask:l}=s;if(l&&(!c||!h))throw new t("imagecanvasdecoder: decode","image width and height are needed to apply jpeg mask directly to canvas");return new Promise((t,d)=>{let g=null;"jpg"===o&&l&&(g=i._getMask(n,{width:c,height:h}));const w=new Blob([new Uint8Array(n)],{type:"image/"+o=="jpg"?"jpeg":o}),v=URL.createObjectURL(w),m=new Image;m.src=v,m.onload=()=>{if(URL.revokeObjectURL(v),e(r))return void d(a());c=m.width,h=m.height,this._canvas&&this._ctx?(this._canvas.width===c&&this._canvas.height===h||(this._canvas.width=c,this._canvas.height=h),this._ctx.clearRect(0,0,c,h)):(this._canvas=document.createElement("canvas"),this._canvas.width=c,this._canvas.height=h,this._ctx=this._canvas.getContext("2d")),this._ctx.drawImage(m,0,0);const n=this._ctx.getImageData(0,0,c,h),i=n.data;if(s.renderOnCanvas){if(g)for(let t=0;t<g.length;t++)g[t]?i[4*t+3]=255:i[4*t+3]=0;return this._ctx.putImageData(n,0,0),void t(null)}const o=c*h,l=new Uint8Array(o),w=new Uint8Array(o),_=new Uint8Array(o);if(g)for(let t=0;t<o;t++)l[t]=i[4*t],w[t]=i[4*t+1],_[t]=i[4*t+2];else{g=new Uint8Array(o);for(let t=0;t<o;t++)l[t]=i[4*t],w[t]=i[4*t+1],_[t]=i[4*t+2],g[t]=i[4*t+3]}t({width:c,height:h,pixels:[l,w,_],mask:g,pixelType:"u8"})},m.onerror=()=>{URL.revokeObjectURL(v),d("cannot load image")}})}static _getMask(t,e){let a=null;try{const i=new Uint8Array(t),s=Math.ceil(i.length/2);let r=0;const c=i.length-2;for(r=s;r<c&&(255!==i[r]||217!==i[r+1]);r++);if(r+=2,r<i.length-1){const t=new n(i.subarray(r)).getBytes();a=new Uint8Array(e.width*e.height);let s=0;for(let e=0;e<t.length;e++)for(let n=7;n>=0;n--)a[s++]=t[e]>>n&1}}catch(i){}return a}}export{i as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{J as t}from"../../../chunks/Jpg.js";import{Z as e}from"../../../chunks/Zlib.js";class r{static decode(r,n=!1){const s=new Uint8Array(r),l=new t;l.parse(s);const{width:o,height:a,numComponents:i,eof:f}=l,h=l.getData(o,a,!0),c=o*a;let u,g=null;if(!n&&f<s.length-1)try{const t=new e(s.subarray(f)).getBytes();g=new Uint8Array(c);let r=0;for(let e=0;e<t.length;e++)for(let n=7;n>=0;n--)g[r++]=t[e]>>n&1}catch{}if(1===i&&h.length===o*a){const t=new Uint8Array(h.buffer);u=[t,t,t]}else{u=[];for(let e=0;e<3;e++)u.push(new Uint8Array(c));let t=0;for(let e=0;e<c;e++)for(let r=0;r<3;r++)u[r][e]=h[t++]}return{width:o,height:a,pixels:u,mask:g}}}export{r as default};
2
+ import{J as t}from"../../../chunks/Jpg.js";import{F as e}from"../../../chunks/Zlib.js";class r{static decode(r,n=!1){const s=new Uint8Array(r),l=new t;l.parse(s);const{width:o,height:a,numComponents:i,eof:f}=l,h=l.getData(o,a,!0),c=o*a;let u,g=null;if(!n&&f<s.length-1)try{const t=new e(s.subarray(f)).getBytes();g=new Uint8Array(c);let r=0;for(let e=0;e<t.length;e++)for(let n=7;n>=0;n--)g[r++]=t[e]>>n&1}catch{}if(1===i&&h.length===o*a){const t=new Uint8Array(h.buffer);u=[t,t,t]}else{u=[];for(let e=0;e<3;e++)u.push(new Uint8Array(c));let t=0;for(let e=0;e<c;e++)for(let r=0;r<3;r++)u[r][e]=h[t++]}return{width:o,height:a,pixels:u,mask:g}}}export{r as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import t from"../../../core/Error.js";import{assertIsSome as e}from"../../../core/maybe.js";import a from"./ImageCanvasDecoder.js";import i from"./JpgPlus.js";import{load as s,decode as r}from"./Lerc.js";import{decode as n}from"./Lzw.js";import{convertNoDataToMask as o}from"./pixelRangeUtils.js";import{Z as h}from"../../../chunks/Zlib.js";import{load as c,decode as l}from"./Qb3.js";import p from"./Raw.js";import{decodeTileOrStrip as d,decode as u}from"./TiffDecoder.js";import{isPlatformLittleEndian as f}from"./utils.js";import m from"../../support/PixelBlock.js";import w from"../../support/SimpleBandStatistics.js";var g=function(t){var e,a,i,s,r,n;function o(t){var e,a,i,s,r,n,o,h,c,l,p,d,u;for(this.data=t,this.pos=8,this.palette=[],this.imgData=[],this.transparency={},this.animation=null,this.text={},r=null;;){switch(e=this.readUInt32(),h=function(){var t,e;for(e=[],t=0;t<4;++t)e.push(String.fromCharCode(this.data[this.pos++]));return e}.call(this).join(""),h){case"IHDR":this.width=this.readUInt32(),this.height=this.readUInt32(),this.bits=this.data[this.pos++],this.colorType=this.data[this.pos++],this.compressionMethod=this.data[this.pos++],this.filterMethod=this.data[this.pos++],this.interlaceMethod=this.data[this.pos++];break;case"acTL":this.animation={numFrames:this.readUInt32(),numPlays:this.readUInt32()||1/0,frames:[]};break;case"PLTE":this.palette=this.read(e);break;case"fcTL":r&&this.animation.frames.push(r),this.pos+=4,r={width:this.readUInt32(),height:this.readUInt32(),xOffset:this.readUInt32(),yOffset:this.readUInt32()},s=this.readUInt16(),i=this.readUInt16()||100,r.delay=1e3*s/i,r.disposeOp=this.data[this.pos++],r.blendOp=this.data[this.pos++],r.data=[];break;case"IDAT":case"fdAT":for("fdAT"===h&&(this.pos+=4,e-=4),t=(null!=r?r.data:void 0)||this.imgData,p=0;0<=e?p<e:p>e;0<=e?++p:--p)t.push(this.data[this.pos++]);break;case"tRNS":switch(this.transparency={},this.colorType){case 3:if(this.transparency.indexed=this.read(e),(c=255-this.transparency.indexed.length)>0)for(d=0;0<=c?d<c:d>c;0<=c?++d:--d)this.transparency.indexed.push(255);break;case 0:this.transparency.grayscale=this.read(e)[0];break;case 2:this.transparency.rgb=this.read(e)}break;case"tEXt":n=(l=this.read(e)).indexOf(0),o=String.fromCharCode.apply(String,l.slice(0,n)),this.text[o]=String.fromCharCode.apply(String,l.slice(n+1));break;case"IEND":return r&&this.animation.frames.push(r),this.colors=function(){switch(this.colorType){case 0:case 3:case 4:return 1;case 2:case 6:return 3}}.call(this),this.hasAlphaChannel=4===(u=this.colorType)||6===u,a=this.colors+(this.hasAlphaChannel?1:0),this.pixelBitlength=this.bits*a,this.colorSpace=function(){switch(this.colors){case 1:return"DeviceGray";case 3:return"DeviceRGB"}}.call(this),void(this.imgData=new Uint8Array(this.imgData));default:this.pos+=e}if(this.pos+=4,this.pos>this.data.length)throw new Error("Incomplete or corrupt PNG file")}}return o.load=function(t,e,a){var i;return"function"==typeof e&&(a=e),(i=new XMLHttpRequest).open("GET",t,!0),i.responseType="arraybuffer",i.onload=function(){var t;return t=new o(new Uint8Array(i.response||i.mozResponseArrayBuffer)),"function"==typeof(null!=e?e.getContext:void 0)&&t.render(e),"function"==typeof a?a(t):void 0},i.send(null)},a=1,i=2,e=0,o.prototype.read=function(t){var e,a;for(a=[],e=0;0<=t?e<t:e>t;0<=t?++e:--e)a.push(this.data[this.pos++]);return a},o.prototype.readUInt32=function(){return this.data[this.pos++]<<24|this.data[this.pos++]<<16|this.data[this.pos++]<<8|this.data[this.pos++]},o.prototype.readUInt16=function(){return this.data[this.pos++]<<8|this.data[this.pos++]},o.prototype.decodePixels=function(t){var e,a,i,s,r,n,o,c,l,p,d,u,f,m,w,g,y,x,b,k,T,C,I;if(null==t&&(t=this.imgData),0===t.length)return new Uint8Array(0);for(t=(t=new h(t)).getBytes(),g=(u=this.pixelBitlength/8)*this.width,f=new Uint8Array(g*this.height),n=t.length,w=0,m=0,a=0;m<n;){switch(t[m++]){case 0:for(s=b=0;b<g;s=b+=1)f[a++]=t[m++];break;case 1:for(s=k=0;k<g;s=k+=1)e=t[m++],r=s<u?0:f[a-u],f[a++]=(e+r)%256;break;case 2:for(s=T=0;T<g;s=T+=1)e=t[m++],i=(s-s%u)/u,y=w&&f[(w-1)*g+i*u+s%u],f[a++]=(y+e)%256;break;case 3:for(s=C=0;C<g;s=C+=1)e=t[m++],i=(s-s%u)/u,r=s<u?0:f[a-u],y=w&&f[(w-1)*g+i*u+s%u],f[a++]=(e+Math.floor((r+y)/2))%256;break;case 4:for(s=I=0;I<g;s=I+=1)e=t[m++],i=(s-s%u)/u,r=s<u?0:f[a-u],0===w?y=x=0:(y=f[(w-1)*g+i*u+s%u],x=i&&f[(w-1)*g+(i-1)*u+s%u]),o=r+y-x,c=Math.abs(o-r),p=Math.abs(o-y),d=Math.abs(o-x),l=c<=p&&c<=d?r:p<=d?y:x,f[a++]=(e+l)%256;break;default:throw new Error("Invalid filter algorithm: "+t[m-1])}w++}return f},o.prototype.decodePalette=function(){var t,e,a,i,s,r,n,o,h;for(a=this.palette,r=this.transparency.indexed||[],s=new Uint8Array((r.length||0)+a.length),i=0,a.length,t=0,e=n=0,o=a.length;n<o;e=n+=3)s[i++]=a[e],s[i++]=a[e+1],s[i++]=a[e+2],s[i++]=null!=(h=r[t++])?h:255;return s},o.prototype.copyToImageData=function(t,e){var a,i,s,r,n,o,h,c,l,p,d;if(i=this.colors,l=null,a=this.hasAlphaChannel,this.palette.length&&(l=null!=(d=this._decodedPalette)?d:this._decodedPalette=this.decodePalette(),i=4,a=!0),c=(s=t.data||t).length,n=l||e,r=o=0,1===i)for(;r<c;)h=l?4*e[r/4]:o,p=n[h++],s[r++]=p,s[r++]=p,s[r++]=p,s[r++]=a?n[h++]:this.transparency.grayscale&&this.transparency.grayscale===p?0:255,o=h;else for(;r<c;)h=l?4*e[r/4]:o,s[r++]=n[h++],s[r++]=n[h++],s[r++]=n[h++],s[r++]=a?n[h++]:this.transparency.rgb&&this.transparency.rgb[1]===n[h-3]&&this.transparency.rgb[3]===n[h-2]&&this.transparency.rgb[5]===n[h-1]?0:255,o=h},o.prototype.decode=function(){var t;return t=new Uint8Array(this.width*this.height*4),this.copyToImageData(t,this.decodePixels()),t},r=t.document&&t.document.createElement("canvas"),n=r&&r.getContext("2d"),s=function(t){var e;return n.width=t.width,n.height=t.height,n.clearRect(0,0,t.width,t.height),n.putImageData(t,0,0),(e=new Image).src=r.toDataURL(),e},o.prototype.decodeFrames=function(t){var e,a,i,r,n,o,h,c;if(this.animation){for(c=[],a=n=0,o=(h=this.animation.frames).length;n<o;a=++n)e=h[a],i=t.createImageData(e.width,e.height),r=this.decodePixels(new Uint8Array(e.data)),this.copyToImageData(i,r),e.imageData=i,c.push(e.image=s(i));return c}},o.prototype.renderFrame=function(t,s){var r,n,o;return r=(n=this.animation.frames)[s],o=n[s-1],0===s&&t.clearRect(0,0,this.width,this.height),(null!=o?o.disposeOp:void 0)===a?t.clearRect(o.xOffset,o.yOffset,o.width,o.height):(null!=o?o.disposeOp:void 0)===i&&t.putImageData(o.imageData,o.xOffset,o.yOffset),r.blendOp===e&&t.clearRect(r.xOffset,r.yOffset,r.width,r.height),t.drawImage(r.image,r.xOffset,r.yOffset)},o.prototype.animate=function(t){var e,a,i,s,r,n,o=this;return a=0,n=this.animation,s=n.numFrames,i=n.frames,r=n.numPlays,(e=function(){var n,h;if(n=a++%s,h=i[n],o.renderFrame(t,n),s>1&&a/s<r)return o.animation._timeout=setTimeout(e,h.delay)})()},o.prototype.stopAnimation=function(){var t;return clearTimeout(null!=(t=this.animation)?t._timeout:void 0)},o.prototype.render=function(t){var e,a;return t._png&&t._png.stopAnimation(),t._png=this,t.width=this.width,t.height=this.height,e=t.getContext("2d"),this.animation?(this.decodeFrames(e),this.animate(e)):(a=e.createImageData(this.width,this.height),this.copyToImageData(a,this.decodePixels()),e.putImageData(a,0,0))},o}(self);const y=new Set(["jpg","png","bmp","gif"]);async function x(e,a){if(!f)throw new t("rasterCoded:decode","lerc decoder is not supported on big endian platform");await s();const{offset:i}=a,{width:n,height:o,pixelType:h,statistics:c,depthCount:l,noDataValues:p,bandMasks:d,pixels:u,mask:g}=r(e,{inputOffset:i,returnInterleaved:a.returnInterleaved}),y=new m({width:n,height:o,pixelType:h.toLowerCase(),pixels:u,mask:g,statistics:c.map(({minValue:t,maxValue:e})=>new w(t,e)),bandMasks:d,depthCount:l,noDataValues:p});return c?.length||y.updateStatistics(),y}async function b(e,a){await c();const i=l(e);if(!i)throw new t("rasterCodec:decode","failed to decode the input data.");const{width:s,height:r,pixels:n,pixelType:o}=i,h=new m({width:s,height:r,pixelType:o,pixels:n});return h.updateStatistics(),h}async function k(t,a){const i=await u(t,{...a,noDataValue:a.tiffNoDataValue,matchAllNoData:a.matchAllNoData});e(i);const s=new m({width:i.width,height:i.height,pixels:i.pixels,pixelType:i.pixelType.toLowerCase(),mask:i.mask,bandMasks:i.bandMasks,statistics:null});return s.updateStatistics(),s}async function T(t,e){const a=await d(t,e.customOptions),i=new m({width:a.width,height:a.height,pixels:a.pixels,pixelType:a.pixelType.toLowerCase(),mask:a.mask,statistics:null});return i.updateStatistics(),i}function C(t,e){const a=e.pixelType||"u8",i=m.getPixelArrayConstructor(a),s="u8"===a?t:new i(t.buffer),r=[],n=e.planes||1;if(1===n)r.push(s);else for(let h=0;h<n;h++){const a=(e.width||1)*(e.height||t.length),o=new i(a);for(let t=0;t<a;t++)o[t]=s[t*n+h];r.push(o)}const o=new m({width:e.width||1,height:e.height||t.length,pixels:r,pixelType:a,statistics:null});return o.updateStatistics(),o}function I(t,e){return C(new h(new Uint8Array(t)).getBytes(),e)}function A(t,e){return C(n(t,e.offset,e.eof,!e.isInputBigEndian),e)}function v(t,e,a){const{pixelTypeCtor:i}=P(e.pixelType),s=(0,p.decode)(t,{width:e.width,height:e.height,pixelType:i,format:a}),r=new m({width:e.width,height:e.height,pixels:s.pixels,pixelType:e.pixelType,mask:s.mask,statistics:null});return r.updateStatistics(),r}function D(t,e){const a=i.decode(t,e.hasNoZlibMask??void 0),s=new m({width:a.width,height:a.height,pixels:a.pixels,pixelType:"u8",mask:a.mask,statistics:null});return s.updateStatistics(),s}function U(t,e){const a=new Uint8Array(t),i=new g(a),{width:s,height:r}=e,n=s*r,o=i.decode();let h,c=0,l=0;const p=new Uint8Array(n);for(c=0;c<n;c++)p[c]=o[4*c+3];const d=new m({width:s,height:r,pixels:[],pixelType:"u8",mask:p,statistics:[]});for(c=0;c<3;c++){for(h=new Uint8Array(n),l=0;l<n;l++)h[l]=o[4*l+c];d.addData({pixels:h})}return d.updateStatistics(),d}async function S(t,e,i,s){const r=new a,n={applyJpegMask:!1,format:e,...i},o=await r.decode(t,n,s),h=new m(o);return h.updateStatistics(),h}function j(e){if(null==e)throw new t("rasterCodec:decode","parameter encodeddata is required.");const a=new Uint8Array(e,0,10);let i="";return 255===a[0]&&216===a[1]?i="jpg":137===a[0]&&80===a[1]&&78===a[2]&&71===a[3]?i="png":67===a[0]&&110===a[1]&&116===a[2]&&90===a[3]&&73===a[4]&&109===a[5]&&97===a[6]&&103===a[7]&&101===a[8]&&32===a[9]?i="lerc":76===a[0]&&101===a[1]&&114===a[2]&&99===a[3]&&50===a[4]&&32===a[5]?i="lerc2":73===a[0]&&73===a[1]&&42===a[2]&&0===a[3]||77===a[0]&&77===a[1]&&0===a[2]&&42===a[3]||73===a[0]&&73===a[1]&&43===a[2]&&0===a[3]||77===a[0]&&77===a[1]&&0===a[2]&&43===a[3]?i="tiff":71===a[0]&&73===a[1]&&70===a[2]?i="gif":66===a[0]&&77===a[1]?i="bmp":81===a[0]&&66===a[1]&&51===a[2]?i="qb3":String.fromCharCode.apply(null,a).toLowerCase().includes("error")&&(i="error"),i}function O(e){let a=null;switch(e){case"lerc":case"lerc2":a=x;break;case"jpg":a=D;break;case"png":a=U;break;case"bsq":case"bip":a=(t,a)=>v(t,a,e);break;case"tiff":a=k;break;case"deflate":a=I;break;case"lzw":a=A;break;case"qb3":a=b;break;case"error":a=()=>{throw new t("rasterCodec:decode","input data contains error")};break;default:a=()=>{throw new t("rasterCodec:decode","unsupported raster format")}}return a}function P(t){let e=null,a=null;switch(t?t.toLowerCase():"f32"){case"u1":case"u2":case"u4":case"u8":a=255,e=Uint8Array;break;case"u16":a=a||65535,e=Uint16Array;break;case"u32":a=a||2**32-1,e=Uint32Array;break;case"s8":a=a||-128,e=Int8Array;break;case"s16":a=a||-32768,e=Int16Array;break;case"s32":a=a||0-2**31,e=Int32Array;break;default:e=Float32Array}return{pixelTypeCtor:e,noDataValue:a}}function M(t,e=1){if(!t)return;const{pixels:a,width:i,height:s,mask:r}=t;if(!a||0===a.length)return;const n=i-1,o=s-1,h=[];let c=null;const l=m.getPixelArrayConstructor(t.pixelType);if(0===e){for(const t of a){const e=new l(n*o);for(let a=0;a<o;a++){const s=a*i;for(let i=0;i<n;i++)e[a*n+i]=t[s+i]}h.push(e)}if(null!=r){c=new Uint8Array(n*o);for(let t=0;t<o;t++){const e=t*i;for(let a=0;a<n;a++)c[t*n+a]=r[e+a]}}}else{for(const t of a){const e=new l(n*o);for(let a=0;a<o;a++){const s=a*i;for(let r=0;r<n;r++)e[a*n+r]=(t[s+r]+t[s+r+1]+t[s+i+r]+t[s+i+r+1])/4}h.push(e)}if(r){c=new Uint8Array(n*o);for(let t=0;t<o;t++){const e=t*i;for(let a=0;a<n;a++)c[t*n+a]=Math.min.apply(null,[r[e+a],r[e+a+1],r[e+i+a],r[e+i+a+1]])}}}t.width=n,t.height=o,t.mask=c,t.pixels=h}function L(t){let e=j(t);return"lerc2"===e?e="lerc":"error"===e&&(e=""),e}async function R(e,a={},i){if(null==e)throw new t("rasterCodec:decode","missing encodeddata parameter.");let s=a.format?.toLowerCase();if(!("bsq"!==s&&"bip"!==s||null!=a.width&&null!=a.height))throw new t("rasterCodec:decode","requires width and height in options parameter.");if("tiff"===s&&a.customOptions)return T(e,a);if((!s||"bsq"!==s&&"bip"!==s&&"deflate"!==s&&"lzw"!==s)&&(s=j(e)),a.useCanvas&&y.has(s))return S(e,s,a,i);const r=O(s);let n;a.isPoint&&(null!=(a={...a}).width&&a.width++,null!=a.height&&a.height++);const{offsets:h}=a;if(h&&h.length>1){const t=h.map((t,i)=>r(e.slice(t,h[i+1]),a)),i=await Promise.all(t);n=i[0],n.pixels=i.map(t=>t.pixels[0]);const s=i.map(t=>t.mask);i.some(t=>null!=t)&&(s.forEach((t,e)=>{null==t&&(s[e]=new Uint8Array(n.width*n.height).fill(255))}),n.bandMasks=s,n.mask=m.combineBandMasks(s)),n.updateStatistics()}else n=await r(e,{...a,offset:h?.[0]??a.offset});return"jpg"!==s&&null!=a.noDataValue&&1===n.depthCount&&o(n,a.noDataValue,{customFloatTolerance:a.tolerance}),a.isPoint&&M(n),n}export{R as decode,L as getFormat};
2
+ import t from"../../../core/Error.js";import{assertIsSome as e}from"../../../core/maybe.js";import a from"./ImageCanvasDecoder.js";import i from"./JpgPlus.js";import{load as s,decode as r}from"./Lerc.js";import{decode as n}from"./Lzw.js";import{convertNoDataToMask as o}from"./pixelRangeUtils.js";import{F as h}from"../../../chunks/Zlib.js";import{load as c,decode as l}from"./Qb3.js";import p from"./Raw.js";import{decodeTileOrStrip as d,decode as u}from"./TiffDecoder.js";import{isPlatformLittleEndian as f}from"./utils.js";import m from"../../support/PixelBlock.js";import w from"../../support/SimpleBandStatistics.js";var g=function(t){var e,a,i,s,r,n;function o(t){var e,a,i,s,r,n,o,h,c,l,p,d,u;for(this.data=t,this.pos=8,this.palette=[],this.imgData=[],this.transparency={},this.animation=null,this.text={},r=null;;){switch(e=this.readUInt32(),h=function(){var t,e;for(e=[],t=0;t<4;++t)e.push(String.fromCharCode(this.data[this.pos++]));return e}.call(this).join(""),h){case"IHDR":this.width=this.readUInt32(),this.height=this.readUInt32(),this.bits=this.data[this.pos++],this.colorType=this.data[this.pos++],this.compressionMethod=this.data[this.pos++],this.filterMethod=this.data[this.pos++],this.interlaceMethod=this.data[this.pos++];break;case"acTL":this.animation={numFrames:this.readUInt32(),numPlays:this.readUInt32()||1/0,frames:[]};break;case"PLTE":this.palette=this.read(e);break;case"fcTL":r&&this.animation.frames.push(r),this.pos+=4,r={width:this.readUInt32(),height:this.readUInt32(),xOffset:this.readUInt32(),yOffset:this.readUInt32()},s=this.readUInt16(),i=this.readUInt16()||100,r.delay=1e3*s/i,r.disposeOp=this.data[this.pos++],r.blendOp=this.data[this.pos++],r.data=[];break;case"IDAT":case"fdAT":for("fdAT"===h&&(this.pos+=4,e-=4),t=(null!=r?r.data:void 0)||this.imgData,p=0;0<=e?p<e:p>e;0<=e?++p:--p)t.push(this.data[this.pos++]);break;case"tRNS":switch(this.transparency={},this.colorType){case 3:if(this.transparency.indexed=this.read(e),(c=255-this.transparency.indexed.length)>0)for(d=0;0<=c?d<c:d>c;0<=c?++d:--d)this.transparency.indexed.push(255);break;case 0:this.transparency.grayscale=this.read(e)[0];break;case 2:this.transparency.rgb=this.read(e)}break;case"tEXt":n=(l=this.read(e)).indexOf(0),o=String.fromCharCode.apply(String,l.slice(0,n)),this.text[o]=String.fromCharCode.apply(String,l.slice(n+1));break;case"IEND":return r&&this.animation.frames.push(r),this.colors=function(){switch(this.colorType){case 0:case 3:case 4:return 1;case 2:case 6:return 3}}.call(this),this.hasAlphaChannel=4===(u=this.colorType)||6===u,a=this.colors+(this.hasAlphaChannel?1:0),this.pixelBitlength=this.bits*a,this.colorSpace=function(){switch(this.colors){case 1:return"DeviceGray";case 3:return"DeviceRGB"}}.call(this),void(this.imgData=new Uint8Array(this.imgData));default:this.pos+=e}if(this.pos+=4,this.pos>this.data.length)throw new Error("Incomplete or corrupt PNG file")}}return o.load=function(t,e,a){var i;return"function"==typeof e&&(a=e),(i=new XMLHttpRequest).open("GET",t,!0),i.responseType="arraybuffer",i.onload=function(){var t;return t=new o(new Uint8Array(i.response||i.mozResponseArrayBuffer)),"function"==typeof(null!=e?e.getContext:void 0)&&t.render(e),"function"==typeof a?a(t):void 0},i.send(null)},a=1,i=2,e=0,o.prototype.read=function(t){var e,a;for(a=[],e=0;0<=t?e<t:e>t;0<=t?++e:--e)a.push(this.data[this.pos++]);return a},o.prototype.readUInt32=function(){return this.data[this.pos++]<<24|this.data[this.pos++]<<16|this.data[this.pos++]<<8|this.data[this.pos++]},o.prototype.readUInt16=function(){return this.data[this.pos++]<<8|this.data[this.pos++]},o.prototype.decodePixels=function(t){var e,a,i,s,r,n,o,c,l,p,d,u,f,m,w,g,y,x,b,k,T,C,I;if(null==t&&(t=this.imgData),0===t.length)return new Uint8Array(0);for(t=(t=new h(t)).getBytes(),g=(u=this.pixelBitlength/8)*this.width,f=new Uint8Array(g*this.height),n=t.length,w=0,m=0,a=0;m<n;){switch(t[m++]){case 0:for(s=b=0;b<g;s=b+=1)f[a++]=t[m++];break;case 1:for(s=k=0;k<g;s=k+=1)e=t[m++],r=s<u?0:f[a-u],f[a++]=(e+r)%256;break;case 2:for(s=T=0;T<g;s=T+=1)e=t[m++],i=(s-s%u)/u,y=w&&f[(w-1)*g+i*u+s%u],f[a++]=(y+e)%256;break;case 3:for(s=C=0;C<g;s=C+=1)e=t[m++],i=(s-s%u)/u,r=s<u?0:f[a-u],y=w&&f[(w-1)*g+i*u+s%u],f[a++]=(e+Math.floor((r+y)/2))%256;break;case 4:for(s=I=0;I<g;s=I+=1)e=t[m++],i=(s-s%u)/u,r=s<u?0:f[a-u],0===w?y=x=0:(y=f[(w-1)*g+i*u+s%u],x=i&&f[(w-1)*g+(i-1)*u+s%u]),o=r+y-x,c=Math.abs(o-r),p=Math.abs(o-y),d=Math.abs(o-x),l=c<=p&&c<=d?r:p<=d?y:x,f[a++]=(e+l)%256;break;default:throw new Error("Invalid filter algorithm: "+t[m-1])}w++}return f},o.prototype.decodePalette=function(){var t,e,a,i,s,r,n,o,h;for(a=this.palette,r=this.transparency.indexed||[],s=new Uint8Array((r.length||0)+a.length),i=0,a.length,t=0,e=n=0,o=a.length;n<o;e=n+=3)s[i++]=a[e],s[i++]=a[e+1],s[i++]=a[e+2],s[i++]=null!=(h=r[t++])?h:255;return s},o.prototype.copyToImageData=function(t,e){var a,i,s,r,n,o,h,c,l,p,d;if(i=this.colors,l=null,a=this.hasAlphaChannel,this.palette.length&&(l=null!=(d=this._decodedPalette)?d:this._decodedPalette=this.decodePalette(),i=4,a=!0),c=(s=t.data||t).length,n=l||e,r=o=0,1===i)for(;r<c;)h=l?4*e[r/4]:o,p=n[h++],s[r++]=p,s[r++]=p,s[r++]=p,s[r++]=a?n[h++]:this.transparency.grayscale&&this.transparency.grayscale===p?0:255,o=h;else for(;r<c;)h=l?4*e[r/4]:o,s[r++]=n[h++],s[r++]=n[h++],s[r++]=n[h++],s[r++]=a?n[h++]:this.transparency.rgb&&this.transparency.rgb[1]===n[h-3]&&this.transparency.rgb[3]===n[h-2]&&this.transparency.rgb[5]===n[h-1]?0:255,o=h},o.prototype.decode=function(){var t;return t=new Uint8Array(this.width*this.height*4),this.copyToImageData(t,this.decodePixels()),t},r=t.document&&t.document.createElement("canvas"),n=r&&r.getContext("2d"),s=function(t){var e;return n.width=t.width,n.height=t.height,n.clearRect(0,0,t.width,t.height),n.putImageData(t,0,0),(e=new Image).src=r.toDataURL(),e},o.prototype.decodeFrames=function(t){var e,a,i,r,n,o,h,c;if(this.animation){for(c=[],a=n=0,o=(h=this.animation.frames).length;n<o;a=++n)e=h[a],i=t.createImageData(e.width,e.height),r=this.decodePixels(new Uint8Array(e.data)),this.copyToImageData(i,r),e.imageData=i,c.push(e.image=s(i));return c}},o.prototype.renderFrame=function(t,s){var r,n,o;return r=(n=this.animation.frames)[s],o=n[s-1],0===s&&t.clearRect(0,0,this.width,this.height),(null!=o?o.disposeOp:void 0)===a?t.clearRect(o.xOffset,o.yOffset,o.width,o.height):(null!=o?o.disposeOp:void 0)===i&&t.putImageData(o.imageData,o.xOffset,o.yOffset),r.blendOp===e&&t.clearRect(r.xOffset,r.yOffset,r.width,r.height),t.drawImage(r.image,r.xOffset,r.yOffset)},o.prototype.animate=function(t){var e,a,i,s,r,n,o=this;return a=0,n=this.animation,s=n.numFrames,i=n.frames,r=n.numPlays,(e=function(){var n,h;if(n=a++%s,h=i[n],o.renderFrame(t,n),s>1&&a/s<r)return o.animation._timeout=setTimeout(e,h.delay)})()},o.prototype.stopAnimation=function(){var t;return clearTimeout(null!=(t=this.animation)?t._timeout:void 0)},o.prototype.render=function(t){var e,a;return t._png&&t._png.stopAnimation(),t._png=this,t.width=this.width,t.height=this.height,e=t.getContext("2d"),this.animation?(this.decodeFrames(e),this.animate(e)):(a=e.createImageData(this.width,this.height),this.copyToImageData(a,this.decodePixels()),e.putImageData(a,0,0))},o}(self);const y=new Set(["jpg","png","bmp","gif"]);async function x(e,a){if(!f)throw new t("rasterCoded:decode","lerc decoder is not supported on big endian platform");await s();const{offset:i}=a,{width:n,height:o,pixelType:h,statistics:c,depthCount:l,noDataValues:p,bandMasks:d,pixels:u,mask:g}=r(e,{inputOffset:i,returnInterleaved:a.returnInterleaved}),y=new m({width:n,height:o,pixelType:h.toLowerCase(),pixels:u,mask:g,statistics:c.map(({minValue:t,maxValue:e})=>new w(t,e)),bandMasks:d,depthCount:l,noDataValues:p});return c?.length||y.updateStatistics(),y}async function b(e,a){await c();const i=l(e);if(!i)throw new t("rasterCodec:decode","failed to decode the input data.");const{width:s,height:r,pixels:n,pixelType:o}=i,h=new m({width:s,height:r,pixelType:o,pixels:n});return h.updateStatistics(),h}async function k(t,a){const i=await u(t,{...a,noDataValue:a.tiffNoDataValue,matchAllNoData:a.matchAllNoData});e(i);const s=new m({width:i.width,height:i.height,pixels:i.pixels,pixelType:i.pixelType.toLowerCase(),mask:i.mask,bandMasks:i.bandMasks,statistics:null});return s.updateStatistics(),s}async function T(t,e){const a=await d(t,e.customOptions),i=new m({width:a.width,height:a.height,pixels:a.pixels,pixelType:a.pixelType.toLowerCase(),mask:a.mask,statistics:null});return i.updateStatistics(),i}function C(t,e){const a=e.pixelType||"u8",i=m.getPixelArrayConstructor(a),s="u8"===a?t:new i(t.buffer),r=[],n=e.planes||1;if(1===n)r.push(s);else for(let h=0;h<n;h++){const a=(e.width||1)*(e.height||t.length),o=new i(a);for(let t=0;t<a;t++)o[t]=s[t*n+h];r.push(o)}const o=new m({width:e.width||1,height:e.height||t.length,pixels:r,pixelType:a,statistics:null});return o.updateStatistics(),o}function I(t,e){return C(new h(new Uint8Array(t)).getBytes(),e)}function A(t,e){return C(n(t,e.offset,e.eof,!e.isInputBigEndian),e)}function v(t,e,a){const{pixelTypeCtor:i}=P(e.pixelType),s=(0,p.decode)(t,{width:e.width,height:e.height,pixelType:i,format:a}),r=new m({width:e.width,height:e.height,pixels:s.pixels,pixelType:e.pixelType,mask:s.mask,statistics:null});return r.updateStatistics(),r}function D(t,e){const a=i.decode(t,e.hasNoZlibMask??void 0),s=new m({width:a.width,height:a.height,pixels:a.pixels,pixelType:"u8",mask:a.mask,statistics:null});return s.updateStatistics(),s}function U(t,e){const a=new Uint8Array(t),i=new g(a),{width:s,height:r}=e,n=s*r,o=i.decode();let h,c=0,l=0;const p=new Uint8Array(n);for(c=0;c<n;c++)p[c]=o[4*c+3];const d=new m({width:s,height:r,pixels:[],pixelType:"u8",mask:p,statistics:[]});for(c=0;c<3;c++){for(h=new Uint8Array(n),l=0;l<n;l++)h[l]=o[4*l+c];d.addData({pixels:h})}return d.updateStatistics(),d}async function S(t,e,i,s){const r=new a,n={applyJpegMask:!1,format:e,...i},o=await r.decode(t,n,s),h=new m(o);return h.updateStatistics(),h}function j(e){if(null==e)throw new t("rasterCodec:decode","parameter encodeddata is required.");const a=new Uint8Array(e,0,10);let i="";return 255===a[0]&&216===a[1]?i="jpg":137===a[0]&&80===a[1]&&78===a[2]&&71===a[3]?i="png":67===a[0]&&110===a[1]&&116===a[2]&&90===a[3]&&73===a[4]&&109===a[5]&&97===a[6]&&103===a[7]&&101===a[8]&&32===a[9]?i="lerc":76===a[0]&&101===a[1]&&114===a[2]&&99===a[3]&&50===a[4]&&32===a[5]?i="lerc2":73===a[0]&&73===a[1]&&42===a[2]&&0===a[3]||77===a[0]&&77===a[1]&&0===a[2]&&42===a[3]||73===a[0]&&73===a[1]&&43===a[2]&&0===a[3]||77===a[0]&&77===a[1]&&0===a[2]&&43===a[3]?i="tiff":71===a[0]&&73===a[1]&&70===a[2]?i="gif":66===a[0]&&77===a[1]?i="bmp":81===a[0]&&66===a[1]&&51===a[2]?i="qb3":String.fromCharCode.apply(null,a).toLowerCase().includes("error")&&(i="error"),i}function O(e){let a=null;switch(e){case"lerc":case"lerc2":a=x;break;case"jpg":a=D;break;case"png":a=U;break;case"bsq":case"bip":a=(t,a)=>v(t,a,e);break;case"tiff":a=k;break;case"deflate":a=I;break;case"lzw":a=A;break;case"qb3":a=b;break;case"error":a=()=>{throw new t("rasterCodec:decode","input data contains error")};break;default:a=()=>{throw new t("rasterCodec:decode","unsupported raster format")}}return a}function P(t){let e=null,a=null;switch(t?t.toLowerCase():"f32"){case"u1":case"u2":case"u4":case"u8":a=255,e=Uint8Array;break;case"u16":a=a||65535,e=Uint16Array;break;case"u32":a=a||2**32-1,e=Uint32Array;break;case"s8":a=a||-128,e=Int8Array;break;case"s16":a=a||-32768,e=Int16Array;break;case"s32":a=a||0-2**31,e=Int32Array;break;default:e=Float32Array}return{pixelTypeCtor:e,noDataValue:a}}function M(t,e=1){if(!t)return;const{pixels:a,width:i,height:s,mask:r}=t;if(!a||0===a.length)return;const n=i-1,o=s-1,h=[];let c=null;const l=m.getPixelArrayConstructor(t.pixelType);if(0===e){for(const t of a){const e=new l(n*o);for(let a=0;a<o;a++){const s=a*i;for(let i=0;i<n;i++)e[a*n+i]=t[s+i]}h.push(e)}if(null!=r){c=new Uint8Array(n*o);for(let t=0;t<o;t++){const e=t*i;for(let a=0;a<n;a++)c[t*n+a]=r[e+a]}}}else{for(const t of a){const e=new l(n*o);for(let a=0;a<o;a++){const s=a*i;for(let r=0;r<n;r++)e[a*n+r]=(t[s+r]+t[s+r+1]+t[s+i+r]+t[s+i+r+1])/4}h.push(e)}if(r){c=new Uint8Array(n*o);for(let t=0;t<o;t++){const e=t*i;for(let a=0;a<n;a++)c[t*n+a]=Math.min.apply(null,[r[e+a],r[e+a+1],r[e+i+a],r[e+i+a+1]])}}}t.width=n,t.height=o,t.mask=c,t.pixels=h}function L(t){let e=j(t);return"lerc2"===e?e="lerc":"error"===e&&(e=""),e}async function R(e,a={},i){if(null==e)throw new t("rasterCodec:decode","missing encodeddata parameter.");let s=a.format?.toLowerCase();if(!("bsq"!==s&&"bip"!==s||null!=a.width&&null!=a.height))throw new t("rasterCodec:decode","requires width and height in options parameter.");if("tiff"===s&&a.customOptions)return T(e,a);if((!s||"bsq"!==s&&"bip"!==s&&"deflate"!==s&&"lzw"!==s)&&(s=j(e)),a.useCanvas&&y.has(s))return S(e,s,a,i);const r=O(s);let n;a.isPoint&&(null!=(a={...a}).width&&a.width++,null!=a.height&&a.height++);const{offsets:h}=a;if(h&&h.length>1){const t=h.map((t,i)=>r(e.slice(t,h[i+1]),a)),i=await Promise.all(t);n=i[0],n.pixels=i.map(t=>t.pixels[0]);const s=i.map(t=>t.mask);i.some(t=>null!=t)&&(s.forEach((t,e)=>{null==t&&(s[e]=new Uint8Array(n.width*n.height).fill(255))}),n.bandMasks=s,n.mask=m.combineBandMasks(s)),n.updateStatistics()}else n=await r(e,{...a,offset:h?.[0]??a.offset});return"jpg"!==s&&null!=a.noDataValue&&1===n.depthCount&&o(n,a.noDataValue,{customFloatTolerance:a.tolerance}),a.isPoint&&M(n),n}export{R as decode,L as getFormat};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import"../../../core/has.js";import{bytesToUTF8 as e}from"../datasets/byteStreamUtils.js";import{J as t}from"../../../chunks/Jpg.js";import{load as n,decode as a}from"./Lerc.js";import{decode as i}from"./Lzw.js";import{convertNoDataToMask as r}from"./pixelRangeUtils.js";import{tiffTags as s,ifdTags as l,getTagName as o,geoKeys as f}from"./tiffTag.js";import{isPlatformLittleEndian as u}from"./utils.js";import{Z as c}from"../../../chunks/Zlib.js";const h=[0,1,1,2,4,8,1,1,2,4,8,4,8,-1,-1,-1,8,8,8],g=4294967296,E=new Set([1,5,6,7,8,34712,34887]);function I(e,t){let n="unknown";return 3===e?n=64===t?"f64":"f32":1===e?1===t?n="u1":2===t?n="u2":4===t?n="u4":t<=8?n="u8":t<=16?n="u16":t<=32&&(n="u32"):2===e&&(t<=8?n="s8":t<=16?n="s16":t<=32&&(n="s32")),n}function T(e){let t=null;switch(e?e.toLowerCase():"f32"){case"u1":case"u2":case"u4":case"u8":t=Uint8Array;break;case"u16":t=Uint16Array;break;case"u32":t=Uint32Array;break;case"s8":t=Int8Array;break;case"s16":t=Int16Array;break;case"s32":t=Int32Array;break;case"f64":t=Float64Array;break;default:t=Float32Array}return t}function w(e,t){return{x:t[0]*e.x+t[1]*e.y+t[2],y:t[3]*e.x+t[4]*e.y+t[5]}}function p(e,t){return e.get(t)?.values}function d(e,t){return e.get(t)?.values}function m(e,t){return e.get(t)?.values?.[0]}function y(e,t){return e.get(t)?.values?.[0]}function A(e,t,n,a=0,i=s,r=4){const l=8===r,f=l?B(new DataView(e,n,8),0,t):new DataView(e,n,2).getUint16(0,t),u=4+2*r,c=l?8:2,h=c+f*u;if(n+h>e.byteLength)return{success:!1,ifd:null,nextIFD:null,requiredBufferSize:h};const g=8===r?8:4,E=n+h+g<=e.byteLength?W(new DataView(e,n+h,g),0,t,8===r):null,I=n+c,T=new Map;let w,p,d,m,y,A=0,S=0;for(let s=0;s<f;s++){p=new DataView(e,I+u*s,u),d=p.getUint16(0,t),y=p.getUint16(2,t),m=o(d,i);const n=[];2===r?(A=p.getUint16(4,t),S=p.getUint16(6,t)):4===r?(A=p.getUint32(4,t),S=p.getUint32(8,t)):8===r&&(A=W(p,4,t,!0),S=W(p,12,t,!0),n.push(p.getUint32(12,t)),n.push(p.getUint32(16,t))),w={id:d,type:y,valueCount:A,valueOffset:S,valueOffsets:n,values:null},N(e,t,w,a,!1,r),T.set(m,w)}return{success:!0,ifd:T,nextIFD:E,requiredBufferSize:h}}const S=(e,t)=>a(e,{inputOffset:t}).pixels[0];function M(e,t){if(t%8==0)return e;const n=t>16?32:t>8?16:8;n>8&&(e=b(e,32===n?4:2));const a=32===n?Uint32Array:16===n?Uint16Array:Uint8Array,i=new a(e),r=Math.floor(8*e.byteLength/t+1e-6),s=new a(r),l=(1<<t)-1;let o=0,f=0,u=0;for(let c=0;c<r;c++)if(0===f&&(u=i[o++],f=n),f>=t)s[c]=u>>>f-t&l,f-=t;else{const e=t-f;let a=(u&l)<<e&l;u=i[o++],f=n-e,a+=u>>>f,s[c]=a}return s.buffer}function P(e,n,a){const i=new t;i.parse(e),i.colorTransform=6===a?-1:0;const r=i.getData(i.width,i.height,1!==n&&4!==n);return new Uint8Array(r.buffer)}function O(e){const t=new c(e).getBytes(),n=new ArrayBuffer(t.length),a=new Uint8Array(n);return a.set(t),a}function b(e,t){const n=new Uint8Array(e),a=new Uint8Array(n.length);if(2===t)for(let i=0;i<n.length;i+=2)a[i]=n[i+1],a[i+1]=n[i];else if(4===t)for(let i=0;i<n.length;i+=4)a[i]=n[i+3],a[i+1]=n[i+2],a[i+2]=n[i+1],a[i+3]=n[i];else for(let i=0;i<n.length;i+=8)a[i]=n[i+7],a[i+1]=n[i+6],a[i+2]=n[i+5],a[i+3]=n[i+4],a[i+4]=n[i+3],a[i+5]=n[i+2],a[i+6]=n[i+1],a[i+7]=n[i];return a.buffer}async function x(e,t,a,r,s){const l=u===t,o=y(a,"BITSPERSAMPLE"),f=y(a,"SAMPLESPERPIXEL")??1,c=y(a,"PHOTOMETRICINTERPRETATION"),h=y(a,"SAMPLEFORMAT")??1,g=I(h,o),E=y(a,"COMPRESSION")??1,w=T(g);let p,d,m;if(34887===E)return await n(),S(e,r);if(1===E)p=e.slice(r,r+s),d=new Uint8Array(p);else if(8===E||32946===E)d=new Uint8Array(e,r,s),d=O(d),p=d.buffer;else if(6===E)d=new Uint8Array(e,r,s),d=P(d,f,c),p=d.buffer;else if(7===E){const t=a.get("JPEGTABLES").values,n=t.length-2;d=new Uint8Array(n+s-2);for(let e=0;e<n;e++)d[e]=t[e];const i=new Uint8Array(e,r+2,s-2);for(let e=0;e<i.length;e++)d[n+e]=i[e];d=P(d,f,c),p=d.buffer}else{if(5!==E)throw new Error("tiff-decode: unsupport compression "+E);d=i(e,r,s,t),p=d.buffer}if(p=M(p,o),l||o<=8)m=new w(p);else{const e=o>32?8:o>16?4:2;m=new w(b(d.buffer,e))}const A=y(a,"PREDICTOR")??1,x=y(a,"TILEWIDTH"),L=y(a,"TILELENGTH");if(A>1&&(5===E||8===E||32946===E)&&x&&L){const e=C(a),t=new w(m.length);t.set(m),m=j(t,L,x,3===h&&3===A,e?1:f)}return m}async function L(e,t,n){const a=d(n,"TILEOFFSETS");if(void 0===a)return null;const i=d(n,"TILEBYTECOUNTS"),{width:r,height:s,pixelType:l,tileWidth:o,tileHeight:f}=k([n]),u=C(n,t),c=y(n,"SAMPLESPERPIXEL")||t.planes,h=r*s,g=y(n,"BITSPERSAMPLE"),E=34887===(y(n,"COMPRESSION")??1),I=T(l),w=[];for(let T=0;T<c;T++)w.push(new I(h));const p=Math.ceil(r/o),m=new Uint8Array(h).fill(255);let A=null,S=!1;if(g%8==0)if(E&&u&&c>1){const l=Math.round(a.length/c);for(let u=0;u<l;u++){const l=Math.floor(u/p)*f,h=u%p*o,g=l*r+h;for(let E=0;E<c;E++){const I=u*c+E;0===i[I]?(A=null,S=!0):A=await x(e,t.littleEndian,n,a[I],i[I]);const T=Math.min(o,r-h),p=Math.min(f,s-l),d=w[E];for(let e=0;e<p;e++){let t=g+e*r,n=e*o;for(let e=0;e<T;e++,t++,n++)A?d[t]=A[n]:m[t]=0}}}}else for(let T=0;T<a.length;T++){const l=Math.floor(T/p)*f,h=T%p*o,g=l*r+h;0===i[T]?(A=null,S=!0):A=await x(e,t.littleEndian,n,a[T],i[T]);const I=Math.min(o,r-h),d=Math.min(f,s-l);for(let e=0;e<c;e++){const t=w[e];if(u||E)for(let n=0;n<d;n++){let a=g+n*r,i=o*f*e+n*o;for(let e=0;e<I;e++,a++,i++)A?t[a]=A[i]:m[a]=0}else for(let n=0;n<d;n++){let a=g+n*r,i=n*o*c+e;for(let e=0;e<I;e++,a++,i+=c)A?t[a]=A[i]:m[a]=0}}}return{width:r,height:s,pixelType:l,pixels:w,mask:S?m:void 0}}const R=(e,t,n)=>{const a=u===t.littleEndian,r=d(n,"STRIPOFFSETS");if(void 0===r)return null;const{width:s,height:l,pixelType:o}=k([n]),f=y(n,"SAMPLESPERPIXEL")||t.planes,c=y(n,"PHOTOMETRICINTERPRETATION"),h=s*l,g=y(n,"BITSPERSAMPLE"),E=T(o),I=new E(h*f),w=d(n,"STRIPBYTECOUNTS"),p=y(n,"ROWSPERSTRIP"),m=y(n,"COMPRESSION")??1;let A,S,b,x;if(g%8==0)for(let u=0;u<r.length;u++){const n=u*(p*s)*f;if("u8"===o||"s8"===o||a)8===m||32946===m?(b=new Uint8Array(e,r[u],w[u]),b=O(b),S=b.buffer):6===m?(b=new Uint8Array(e,r[u],w[u]),b=P(b,f,c),S=b.buffer):5===m?(b=i(e,r[u],w[u],t.littleEndian),S=b.buffer):S=e.slice(r[u],r[u]+w[u]),S=M(S,g),A=new E(S);else{switch(6===m||8===m||32946===m?(b=new Uint8Array(e,r[u],w[u]),x=O(b),S=x.buffer):(S=new ArrayBuffer(w[u]),b=new Uint8Array(e,r[u],w[u]),x=new Uint8Array(S)),o){case"u16":case"s16":for(let e=0;e<b.length;e+=2)x[e]=b[e+1],x[e+1]=b[e];break;case"u32":case"s32":case"f32":for(let e=0;e<b.length;e+=4)x[e]=b[e+3],x[e+1]=b[e+2],x[e+2]=b[e+1],x[e+3]=b[e]}S=M(S,g),A=new E(S)}I.set(A,n)}const L=[];if(1===f)L.push(I);else for(let i=0;i<f;i++){const e=new E(h);for(let t=0;t<h;t++)e[t]=I[t*f+i];L.push(e)}return{width:s,height:l,pixelType:o,pixels:L}},D=(e,t,n)=>{if(!(e&&e.length>0&&t&&n))return null;let a,i,r;const s=e[0].length,l=e.length,o=new Uint8Array(s);for(let f=0;f<l;f++)if(a=e[f],i=t[f],r=n[f],0===f)for(let e=0;e<s;e++)o[e]=a[e]<i||a[e]>r?0:1;else for(let e=0;e<s;e++)o[e]&&(o[e]=a[e]<i||a[e]>r?0:1);return o},U=e=>{if(!e)return null;const t=e.match(/<Item(.*?)Item>/gi);if(!t||0===t.length)return null;const n=new Map;let a,i,r,s,l;for(let w=0;w<t.length;w++)a=t[w],i=a.slice(6,a.indexOf(">")),s=a.indexOf("sample="),s>-1&&(l=a.slice(s+8,a.indexOf('"',s+8))),s=a.indexOf("name="),s>-1&&(i=a.slice(s+6,a.indexOf('"',s+6))),i&&(r=a.slice(a.indexOf(">")+1,a.indexOf("</Item>")).trim(),null!=l?n.has(i)?n.get(i)[l]=r:n.set(i,[r]):n.set(i,r)),l=null;const o=n.get("STATISTICS_MINIMUM"),f=n.get("STATISTICS_MAXIMUM"),u=n.get("STATISTICS_MEAN"),c=n.get("STATISTICS_STDDEV");let h=null;if(o&&f){h=[];for(let e=0;e<o.length;e++)h.push({min:parseFloat(o[e]),max:parseFloat(f[e]),avg:u&&parseFloat(u[e]),stddev:c&&parseFloat(c[e])})}const g=n.get("BandName"),E=n.get("WavelengthMin"),I=n.get("WavelengthMax");let T=null;if(g){T=[];for(let e=0;e<g.length;e++)T.push({BandName:g[e],WavelengthMin:E&&parseFloat(E[e]),WavelengthMax:I&&parseFloat(I[e])})}return{statistics:h,bandProperties:T,dataType:n.get("DataType"),rawMetadata:n}};function N(e,t,n,a=0,i=!1,r=4){if(n.values)return!0;const s=n.type,l=n.valueCount;let o=n.valueOffset,f=[];const u=h[s],c=8*u,E=l*u,I=l*h[s]*8;let T,w;const p=8===r?64:32,d=n.valueOffsets;if(I>p){if(E>(i?e.byteLength:e?e.byteLength-o+a:0))return n.offlineOffsetSize=[o,E],n.values=null,!1}if(I<=p){if(!t)if(p<=32)o>>>=32-I;else{const e=d?.length?d[0]:o>>>0,t=d?.length?d[1]:Math.round((o-e)/g);I<=32?(o=e>>>32-I,d[0]=o):(o=e*2**(32-I)+(t>>>32-I),d[0]=e,d[1]=t>>>32-I)}if(1===l&&c===p)f=[o];else if(64===p){const e=d?.length?d[0]:o>>>0,t=d?.length?d[1]:Math.round((o-e)/g);let n=e,a=32;for(w=1;w<=l;w++){const e=32-c*w%32;if(a<c){const i=n<<e>>>32-a,r=t<<32-a>>>32-a;n=t,f.push(i+r*2**(c-a)),a-=32-(c-a)}else f.push(n<<e>>>32-c),a-=c;0===a&&(a=32,n=t)}}else for(w=1;w<=l;w++){const e=32-c*w;f.push(o<<e>>>32-c)}}else{o-=a,i&&(o=0);for(let n=o;n<o+E;n+=u){switch(s){case 1:case 2:case 7:T=new DataView(e,n,1).getUint8(0);break;case 3:T=new DataView(e,n,2).getUint16(0,t);break;case 4:case 13:T=new DataView(e,n,4).getUint32(0,t);break;case 5:T=new DataView(e,n,4).getUint32(0,t)/new DataView(e,n+4,4).getUint32(0,t);break;case 6:T=new DataView(e,n,1).getInt8(0);break;case 8:T=new DataView(e,n,2).getInt16(0,t);break;case 9:T=new DataView(e,n,4).getInt32(0,t);break;case 10:T=new DataView(e,n,4).getInt32(0,t)/new DataView(e,n+4,4).getInt32(0,t);break;case 11:T=new DataView(e,n,4).getFloat32(0,t);break;case 12:T=new DataView(e,n,8).getFloat64(0,t);break;case 16:case 18:T=B(new DataView(e,n,8),0,t);break;case 17:T=V(new DataView(e,n,8),0,t);break;default:T=null}f.push(T)}}if(2===s){let e="";const t=f;for(f=[],w=0;w<t.length;w++)0===t[w]&&""!==e?(f.push(e),e=""):e+=String.fromCharCode(t[w]);""===e&&0!==f.length||f.push(e)}return n.values=f,!0}function k(e){const t=e[0],n=y(t,"TILEWIDTH"),a=y(t,"TILELENGTH"),i=y(t,"IMAGEWIDTH"),r=y(t,"IMAGELENGTH"),s=y(t,"BITSPERSAMPLE"),l=y(t,"SAMPLESPERPIXEL"),o=y(t,"SAMPLEFORMAT")??1,f=I(o,s),u=C(t),c=p(t,"GDAL_NODATA");let h=null;c?.length&&(h=c.map(e=>parseFloat(e)),h.some(e=>isNaN(e))&&(h=null));const g=y(t,"COMPRESSION")??1;let T;switch(g){case 1:T="NONE";break;case 2:case 3:case 4:case 32771:T="CCITT";break;case 5:T="LZW";break;case 6:case 7:T="JPEG";break;case 32773:T="PACKBITS";break;case 8:case 32946:T="DEFLATE";break;case 34712:T="JPEG2000";break;case 34887:T="LERC";break;default:T=String(g)}let A=!0,S="";E.has(g)||(A=!1,S+="unsupported tag compression "+g),o>3&&(A=!1,S+="unsupported tag sampleFormat "+o),s>32&&64!==s&&(A=!1,S+="unsupported tag bitsPerSample "+s);const M=m(t,"GEOASCIIPARAMS");let P;if(M){const e=M.split("|").find(e=>e.includes("ESRI PE String = ")),t=e?e.replace("ESRI PE String = ",""):"";P=t.startsWith("COMPD_CS")||t.startsWith("PROJCS")||t.startsWith("GEOGCS")?{wkid:null,wkt:t}:null}const O=d(t,"GEOTIEPOINTS"),b=d(t,"GEOPIXELSCALE"),x=d(t,"GEOTRANSMATRIX"),L=t.has("GEOKEYDIRECTORY")?t.get("GEOKEYDIRECTORY").data:null;let R,D,N=!1,k=!1;if(L){N=2===y(L,"GTRasterTypeGeoKey");const e=y(L,"GTModelTypeGeoKey");if(2===e){const e=y(L,"GeographicTypeGeoKey");e>=1024&&e<=32766&&(P={wkid:e}),P||32767!==e||(k=!0,P={wkid:4326})}else if(1===e){const e=y(L,"ProjectedCSTypeGeoKey");e>=1024&&e<=32766&&(P={wkid:e})}}if(b&&O&&O.length>=6?(R=[b[0],0,O[3]-O[0]*b[0],0,-Math.abs(b[1]),O[4]-O[1]*b[1]],N&&(R[2]-=.5*R[0]+.5*R[1],R[5]-=.5*R[3]+.5*R[4])):x&&16===x.length&&(R=N?[x[0],x[1],x[3]-.5*x[0],x[4],x[5],x[7]-.5*x[5]]:[x[0],x[1],x[3],x[4],x[5],x[7]]),R){const e=[{x:0,y:r},{x:0,y:0},{x:i,y:r},{x:i,y:0}];let t,n=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY;for(let i=0;i<e.length;i++)t=w(e[i],R),n=t.x>n?n:t.x,s=t.x<s?s:t.x,a=t.y>a?a:t.y,l=t.y<l?l:t.y;D={xmin:n,xmax:s,ymin:a,ymax:l,spatialReference:P}}else D={xmin:-.5,ymin:.5-r,xmax:i-.5,ymax:.5,spatialReference:P};k&&(D.xmax-D.xmin>400||Math.max(Math.abs(D.xmin),Math.abs(D.xmax))>361)&&(P=null,D.spatialReference=null);const F=G(e);let B,V,W,H,Y;if(F.length>0){W=Math.round(Math.log(i/y(F[0],"IMAGEWIDTH"))/Math.LN2);const e=F[F.length-1];H=F.length,B=y(e,"TILEWIDTH"),V=y(e,"TILELENGTH")}B=null!=H&&H>0?B||n:null,V=null!=H&&H>0?V||a:null,n&&(Y=[{maxCol:Math.ceil(i/n)-1,maxRow:Math.ceil(r/a)-1,minRow:0,minCol:0}],F.forEach(e=>{Y.push({maxCol:Math.ceil(y(e,"IMAGEWIDTH")/y(e,"TILEWIDTH"))-1,maxRow:Math.ceil(y(e,"IMAGELENGTH")/y(e,"TILELENGTH"))-1,minRow:0,minCol:0})}));const j=m(e[0],"GDAL_METADATA"),X=U(j);S+=" "+_({width:i,height:r,tileWidth:n,tileHeight:a,planes:l,ifds:e});const K=v(e).length===F.length+1,J=F?.length?F.map(e=>({x:i/y(e,"IMAGEWIDTH"),y:r/y(e,"IMAGELENGTH")})):void 0;return{width:i,height:r,tileWidth:n,tileHeight:a,planes:l,isBSQ:u,pixelType:f,compression:T,noData:h,hasMaskBand:K,isSupported:A,pyramidResolutions:J,message:S,extent:D,isPseudoGeographic:k,affine:b?null:R,firstPyramidLevel:W,maximumPyramidLevel:H,pyramidBlockWidth:B,pyramidBlockHeight:V,tileBoundary:Y,metadata:X}}function C(e,t){const n=p(e,"PLANARCONFIGURATION");return n?2===n[0]:!!t&&t.isBSQ}function G(e){return e.filter(e=>1===y(e,"NEWSUBFILETYPE"))}function v(e){return e.filter(e=>{const t=!(4&~(y(e,"NEWSUBFILETYPE")??0)),n=4===y(e,"PHOTOMETRICINTERPRETATION");return t&&n})}function F(e){const{littleEndian:t,isBigTiff:n,firstIFDPos:a}=H(e);let i=a;const r=[];do{const a=Y(e,t,i,0,s,n?8:4);if(!a.success)break;r.push(a.ifd),i=a.nextIFD}while(i>0);return{...k(r),littleEndian:t,isBigTiff:n,ifds:r,pyramidIFDs:G(r),maskIFDs:v(r)}}function B(e,t,n){const a=e.getUint32(t,n),i=e.getUint32(t+4,n);return n?i*g+a:a*g+i}function V(e,t,n){let a=n?e.getInt32(t,n):e.getUint32(t,n),i=n?e.getUint32(t+4,n):e.getInt32(t+4,n);const r=(n?a:i)>=0?1:-1;n?a*=r:i*=r;return r*(n?i*g+a:a*g+i)}function W(e,t,n,a){return a?B(e,t,n):e.getUint32(t,n)}function H(e){const t=new DataView(e,0,16),n=t.getUint16(0,!1);let a=null;if(18761===n)a=!0;else{if(19789!==n)throw new Error("unexpected endianess byte");a=!1}const i=t.getUint16(2,a);if(42!==i&&43!==i)throw new Error("unexpected tiff identifier");let r=4;const s=43===i;if(s){const e=t.getUint16(r,a);if(r+=2,8!==e)throw new Error("unsupported bigtiff version");if(0!==t.getUint16(r,a))throw new Error("unsupported bigtiff version");r+=2}return{littleEndian:a,isBigTiff:s,firstIFDPos:W(t,r,a,s)}}function Y(t,n,a,i=0,r=s,o=4){const u=A(t,n,a,i,r,o);let c;const h=u.ifd;if(h){if(l.forEach((e,a)=>{h.has(a)&&(c=h.get(a),c.data=A(t,n,c.valueOffset-i,i,e).ifd)}),h.has("GEOKEYDIRECTORY")){c=h.get("GEOKEYDIRECTORY");const e=c.values;if(e&&e.length>4){const a=e[0]+"."+e[1]+"."+e[2];c.data=A(t,n,c.valueOffset+6-i,i,f,2).ifd,c.data&&c.data.set("GEOTIFFVersion",{id:0,type:2,valueCount:1,valueOffset:null,values:[a]})}}if(h.has("XMP")){c=h.get("XMP");const t=c.values;"number"==typeof t[0]&&7===c.type&&(c.values=[e(new Uint8Array(t))])}}return u}function _(e){const{width:t,height:n,tileHeight:a,tileWidth:i}=e,r=e.planes,s=i?i*a:t*n,l=y(e.ifds[0],"BITSPERSAMPLE");let o="";return s*r>2**30/(l>8?l/8:1)&&(o=i?"tiled tiff exceeding 1 gigabits per tile is not supported":"scanline tiff exceeding 1 gigabits is not supported"),o}function j(e,t,n,a,i){const r=a?4:1,s=n*r*i;a&&(e=new Uint8Array(e.buffer));for(let f=0;f<t;f++){const t=f*s;for(let n=i;n<s;n++)e[t+n]+=e[t+n-i]}if(!a)return e;const l=new Uint8Array(e.length),o=n*i;for(let f=0;f<t;f++){const t=f*s;for(let n=0;n<o;n++)for(let a=0;a<r;a++)l[t+n*r+a]=e[t+n+(r-a-1)*o]}return new Float32Array(l.buffer)}async function X(e,t){const{headerInfo:n,ifd:a,offsets:i,sizes:s}=t,l=[];for(let r=0;r<i.length;r++){s[r];const t=await x(e,n.littleEndian,a,i[r],s[r]||e.byteLength);l.push(t)}const o=C(a,n),f=y(a,"BITSPERSAMPLE"),u=I(y(a,"SAMPLEFORMAT")??1,f),c=y(a,"SAMPLESPERPIXEL")||n.planes,h=T(u),g=y(a,"TILEWIDTH"),E=y(a,"TILELENGTH"),w=y(a,"COMPRESSION")??1,p=g*E;let d;const m=[];let A=l[0];const S=34887===w;for(let r=0;r<c;r++){if(d=new h(p),l.length===c)A=l[r],A.length===p&&(d=A);else if(A.length)if(o||S)d=A.length===p?A:A.slice(p*r,p*(r+1));else for(let e=0;e<p;e++)d[e]=A[e*c+r];m.push(d)}const M=n.noData?n.noData[0]:t.noDataValue,P=n.metadata?n.metadata.statistics:null,O=P?P.map(e=>e.min):null,b=P?P.map(e=>e.max):null,L={pixelType:u,width:g,height:E,pixels:m,noDataValue:M};return null!=M?r(L,M,{matchAllNoData:t?.matchAllNoData}):O&&b&&t.applyMinMaxConstraint&&(L.mask=D(m,O,b)),L}async function K(e,t={}){const n=t.pyramidLevel||0,a=t.headerInfo||F(e),{ifds:i,noData:s}=a;if(0===i.length)throw new Error("no valid image file directory");const l=_(a);if(l)throw l;let o=null;const f=-1===n?i[i.length-1]:i[n],u=s??t.noDataValue;if(o=a.tileWidth?await L(e,a,f):R(e,a,f),!o)return o;if(null!=u){r(o,u,{matchAllNoData:null==s&&t?.matchAllNoData})}return o}export{K as decode,X as decodeTileOrStrip,k as getImageInfo,v as getMaskIFDs,G as getPyramidIFDs,C as isBSQConfig,N as parseFieldValues,F as parseHeader,Y as parseIFD,H as parseSignature,M as unpackBits};
2
+ import"../../../core/has.js";import{bytesToUTF8 as e}from"../datasets/byteStreamUtils.js";import{J as t}from"../../../chunks/Jpg.js";import{load as n,decode as a}from"./Lerc.js";import{decode as i}from"./Lzw.js";import{convertNoDataToMask as r}from"./pixelRangeUtils.js";import{tiffTags as s,ifdTags as l,getTagName as o,geoKeys as f}from"./tiffTag.js";import{isPlatformLittleEndian as u}from"./utils.js";import{F as c}from"../../../chunks/Zlib.js";const h=[0,1,1,2,4,8,1,1,2,4,8,4,8,-1,-1,-1,8,8,8],g=4294967296,E=new Set([1,5,6,7,8,34712,34887]);function I(e,t){let n="unknown";return 3===e?n=64===t?"f64":"f32":1===e?1===t?n="u1":2===t?n="u2":4===t?n="u4":t<=8?n="u8":t<=16?n="u16":t<=32&&(n="u32"):2===e&&(t<=8?n="s8":t<=16?n="s16":t<=32&&(n="s32")),n}function T(e){let t=null;switch(e?e.toLowerCase():"f32"){case"u1":case"u2":case"u4":case"u8":t=Uint8Array;break;case"u16":t=Uint16Array;break;case"u32":t=Uint32Array;break;case"s8":t=Int8Array;break;case"s16":t=Int16Array;break;case"s32":t=Int32Array;break;case"f64":t=Float64Array;break;default:t=Float32Array}return t}function w(e,t){return{x:t[0]*e.x+t[1]*e.y+t[2],y:t[3]*e.x+t[4]*e.y+t[5]}}function p(e,t){return e.get(t)?.values}function d(e,t){return e.get(t)?.values}function m(e,t){return e.get(t)?.values?.[0]}function y(e,t){return e.get(t)?.values?.[0]}function A(e,t,n,a=0,i=s,r=4){const l=8===r,f=l?B(new DataView(e,n,8),0,t):new DataView(e,n,2).getUint16(0,t),u=4+2*r,c=l?8:2,h=c+f*u;if(n+h>e.byteLength)return{success:!1,ifd:null,nextIFD:null,requiredBufferSize:h};const g=8===r?8:4,E=n+h+g<=e.byteLength?W(new DataView(e,n+h,g),0,t,8===r):null,I=n+c,T=new Map;let w,p,d,m,y,A=0,S=0;for(let s=0;s<f;s++){p=new DataView(e,I+u*s,u),d=p.getUint16(0,t),y=p.getUint16(2,t),m=o(d,i);const n=[];2===r?(A=p.getUint16(4,t),S=p.getUint16(6,t)):4===r?(A=p.getUint32(4,t),S=p.getUint32(8,t)):8===r&&(A=W(p,4,t,!0),S=W(p,12,t,!0),n.push(p.getUint32(12,t)),n.push(p.getUint32(16,t))),w={id:d,type:y,valueCount:A,valueOffset:S,valueOffsets:n,values:null},N(e,t,w,a,!1,r),T.set(m,w)}return{success:!0,ifd:T,nextIFD:E,requiredBufferSize:h}}const S=(e,t)=>a(e,{inputOffset:t}).pixels[0];function M(e,t){if(t%8==0)return e;const n=t>16?32:t>8?16:8;n>8&&(e=b(e,32===n?4:2));const a=32===n?Uint32Array:16===n?Uint16Array:Uint8Array,i=new a(e),r=Math.floor(8*e.byteLength/t+1e-6),s=new a(r),l=(1<<t)-1;let o=0,f=0,u=0;for(let c=0;c<r;c++)if(0===f&&(u=i[o++],f=n),f>=t)s[c]=u>>>f-t&l,f-=t;else{const e=t-f;let a=(u&l)<<e&l;u=i[o++],f=n-e,a+=u>>>f,s[c]=a}return s.buffer}function P(e,n,a){const i=new t;i.parse(e),i.colorTransform=6===a?-1:0;const r=i.getData(i.width,i.height,1!==n&&4!==n);return new Uint8Array(r.buffer)}function O(e){const t=new c(e).getBytes(),n=new ArrayBuffer(t.length),a=new Uint8Array(n);return a.set(t),a}function b(e,t){const n=new Uint8Array(e),a=new Uint8Array(n.length);if(2===t)for(let i=0;i<n.length;i+=2)a[i]=n[i+1],a[i+1]=n[i];else if(4===t)for(let i=0;i<n.length;i+=4)a[i]=n[i+3],a[i+1]=n[i+2],a[i+2]=n[i+1],a[i+3]=n[i];else for(let i=0;i<n.length;i+=8)a[i]=n[i+7],a[i+1]=n[i+6],a[i+2]=n[i+5],a[i+3]=n[i+4],a[i+4]=n[i+3],a[i+5]=n[i+2],a[i+6]=n[i+1],a[i+7]=n[i];return a.buffer}async function x(e,t,a,r,s){const l=u===t,o=y(a,"BITSPERSAMPLE"),f=y(a,"SAMPLESPERPIXEL")??1,c=y(a,"PHOTOMETRICINTERPRETATION"),h=y(a,"SAMPLEFORMAT")??1,g=I(h,o),E=y(a,"COMPRESSION")??1,w=T(g);let p,d,m;if(34887===E)return await n(),S(e,r);if(1===E)p=e.slice(r,r+s),d=new Uint8Array(p);else if(8===E||32946===E)d=new Uint8Array(e,r,s),d=O(d),p=d.buffer;else if(6===E)d=new Uint8Array(e,r,s),d=P(d,f,c),p=d.buffer;else if(7===E){const t=a.get("JPEGTABLES").values,n=t.length-2;d=new Uint8Array(n+s-2);for(let e=0;e<n;e++)d[e]=t[e];const i=new Uint8Array(e,r+2,s-2);for(let e=0;e<i.length;e++)d[n+e]=i[e];d=P(d,f,c),p=d.buffer}else{if(5!==E)throw new Error("tiff-decode: unsupport compression "+E);d=i(e,r,s,t),p=d.buffer}if(p=M(p,o),l||o<=8)m=new w(p);else{const e=o>32?8:o>16?4:2;m=new w(b(d.buffer,e))}const A=y(a,"PREDICTOR")??1,x=y(a,"TILEWIDTH"),L=y(a,"TILELENGTH");if(A>1&&(5===E||8===E||32946===E)&&x&&L){const e=C(a),t=new w(m.length);t.set(m),m=j(t,L,x,3===h&&3===A,e?1:f)}return m}async function L(e,t,n){const a=d(n,"TILEOFFSETS");if(void 0===a)return null;const i=d(n,"TILEBYTECOUNTS"),{width:r,height:s,pixelType:l,tileWidth:o,tileHeight:f}=k([n]),u=C(n,t),c=y(n,"SAMPLESPERPIXEL")||t.planes,h=r*s,g=y(n,"BITSPERSAMPLE"),E=34887===(y(n,"COMPRESSION")??1),I=T(l),w=[];for(let T=0;T<c;T++)w.push(new I(h));const p=Math.ceil(r/o),m=new Uint8Array(h).fill(255);let A=null,S=!1;if(g%8==0)if(E&&u&&c>1){const l=Math.round(a.length/c);for(let u=0;u<l;u++){const l=Math.floor(u/p)*f,h=u%p*o,g=l*r+h;for(let E=0;E<c;E++){const I=u*c+E;0===i[I]?(A=null,S=!0):A=await x(e,t.littleEndian,n,a[I],i[I]);const T=Math.min(o,r-h),p=Math.min(f,s-l),d=w[E];for(let e=0;e<p;e++){let t=g+e*r,n=e*o;for(let e=0;e<T;e++,t++,n++)A?d[t]=A[n]:m[t]=0}}}}else for(let T=0;T<a.length;T++){const l=Math.floor(T/p)*f,h=T%p*o,g=l*r+h;0===i[T]?(A=null,S=!0):A=await x(e,t.littleEndian,n,a[T],i[T]);const I=Math.min(o,r-h),d=Math.min(f,s-l);for(let e=0;e<c;e++){const t=w[e];if(u||E)for(let n=0;n<d;n++){let a=g+n*r,i=o*f*e+n*o;for(let e=0;e<I;e++,a++,i++)A?t[a]=A[i]:m[a]=0}else for(let n=0;n<d;n++){let a=g+n*r,i=n*o*c+e;for(let e=0;e<I;e++,a++,i+=c)A?t[a]=A[i]:m[a]=0}}}return{width:r,height:s,pixelType:l,pixels:w,mask:S?m:void 0}}const R=(e,t,n)=>{const a=u===t.littleEndian,r=d(n,"STRIPOFFSETS");if(void 0===r)return null;const{width:s,height:l,pixelType:o}=k([n]),f=y(n,"SAMPLESPERPIXEL")||t.planes,c=y(n,"PHOTOMETRICINTERPRETATION"),h=s*l,g=y(n,"BITSPERSAMPLE"),E=T(o),I=new E(h*f),w=d(n,"STRIPBYTECOUNTS"),p=y(n,"ROWSPERSTRIP"),m=y(n,"COMPRESSION")??1;let A,S,b,x;if(g%8==0)for(let u=0;u<r.length;u++){const n=u*(p*s)*f;if("u8"===o||"s8"===o||a)8===m||32946===m?(b=new Uint8Array(e,r[u],w[u]),b=O(b),S=b.buffer):6===m?(b=new Uint8Array(e,r[u],w[u]),b=P(b,f,c),S=b.buffer):5===m?(b=i(e,r[u],w[u],t.littleEndian),S=b.buffer):S=e.slice(r[u],r[u]+w[u]),S=M(S,g),A=new E(S);else{switch(6===m||8===m||32946===m?(b=new Uint8Array(e,r[u],w[u]),x=O(b),S=x.buffer):(S=new ArrayBuffer(w[u]),b=new Uint8Array(e,r[u],w[u]),x=new Uint8Array(S)),o){case"u16":case"s16":for(let e=0;e<b.length;e+=2)x[e]=b[e+1],x[e+1]=b[e];break;case"u32":case"s32":case"f32":for(let e=0;e<b.length;e+=4)x[e]=b[e+3],x[e+1]=b[e+2],x[e+2]=b[e+1],x[e+3]=b[e]}S=M(S,g),A=new E(S)}I.set(A,n)}const L=[];if(1===f)L.push(I);else for(let i=0;i<f;i++){const e=new E(h);for(let t=0;t<h;t++)e[t]=I[t*f+i];L.push(e)}return{width:s,height:l,pixelType:o,pixels:L}},D=(e,t,n)=>{if(!(e&&e.length>0&&t&&n))return null;let a,i,r;const s=e[0].length,l=e.length,o=new Uint8Array(s);for(let f=0;f<l;f++)if(a=e[f],i=t[f],r=n[f],0===f)for(let e=0;e<s;e++)o[e]=a[e]<i||a[e]>r?0:1;else for(let e=0;e<s;e++)o[e]&&(o[e]=a[e]<i||a[e]>r?0:1);return o},U=e=>{if(!e)return null;const t=e.match(/<Item(.*?)Item>/gi);if(!t||0===t.length)return null;const n=new Map;let a,i,r,s,l;for(let w=0;w<t.length;w++)a=t[w],i=a.slice(6,a.indexOf(">")),s=a.indexOf("sample="),s>-1&&(l=a.slice(s+8,a.indexOf('"',s+8))),s=a.indexOf("name="),s>-1&&(i=a.slice(s+6,a.indexOf('"',s+6))),i&&(r=a.slice(a.indexOf(">")+1,a.indexOf("</Item>")).trim(),null!=l?n.has(i)?n.get(i)[l]=r:n.set(i,[r]):n.set(i,r)),l=null;const o=n.get("STATISTICS_MINIMUM"),f=n.get("STATISTICS_MAXIMUM"),u=n.get("STATISTICS_MEAN"),c=n.get("STATISTICS_STDDEV");let h=null;if(o&&f){h=[];for(let e=0;e<o.length;e++)h.push({min:parseFloat(o[e]),max:parseFloat(f[e]),avg:u&&parseFloat(u[e]),stddev:c&&parseFloat(c[e])})}const g=n.get("BandName"),E=n.get("WavelengthMin"),I=n.get("WavelengthMax");let T=null;if(g){T=[];for(let e=0;e<g.length;e++)T.push({BandName:g[e],WavelengthMin:E&&parseFloat(E[e]),WavelengthMax:I&&parseFloat(I[e])})}return{statistics:h,bandProperties:T,dataType:n.get("DataType"),rawMetadata:n}};function N(e,t,n,a=0,i=!1,r=4){if(n.values)return!0;const s=n.type,l=n.valueCount;let o=n.valueOffset,f=[];const u=h[s],c=8*u,E=l*u,I=l*h[s]*8;let T,w;const p=8===r?64:32,d=n.valueOffsets;if(I>p){if(E>(i?e.byteLength:e?e.byteLength-o+a:0))return n.offlineOffsetSize=[o,E],n.values=null,!1}if(I<=p){if(!t)if(p<=32)o>>>=32-I;else{const e=d?.length?d[0]:o>>>0,t=d?.length?d[1]:Math.round((o-e)/g);I<=32?(o=e>>>32-I,d[0]=o):(o=e*2**(32-I)+(t>>>32-I),d[0]=e,d[1]=t>>>32-I)}if(1===l&&c===p)f=[o];else if(64===p){const e=d?.length?d[0]:o>>>0,t=d?.length?d[1]:Math.round((o-e)/g);let n=e,a=32;for(w=1;w<=l;w++){const e=32-c*w%32;if(a<c){const i=n<<e>>>32-a,r=t<<32-a>>>32-a;n=t,f.push(i+r*2**(c-a)),a-=32-(c-a)}else f.push(n<<e>>>32-c),a-=c;0===a&&(a=32,n=t)}}else for(w=1;w<=l;w++){const e=32-c*w;f.push(o<<e>>>32-c)}}else{o-=a,i&&(o=0);for(let n=o;n<o+E;n+=u){switch(s){case 1:case 2:case 7:T=new DataView(e,n,1).getUint8(0);break;case 3:T=new DataView(e,n,2).getUint16(0,t);break;case 4:case 13:T=new DataView(e,n,4).getUint32(0,t);break;case 5:T=new DataView(e,n,4).getUint32(0,t)/new DataView(e,n+4,4).getUint32(0,t);break;case 6:T=new DataView(e,n,1).getInt8(0);break;case 8:T=new DataView(e,n,2).getInt16(0,t);break;case 9:T=new DataView(e,n,4).getInt32(0,t);break;case 10:T=new DataView(e,n,4).getInt32(0,t)/new DataView(e,n+4,4).getInt32(0,t);break;case 11:T=new DataView(e,n,4).getFloat32(0,t);break;case 12:T=new DataView(e,n,8).getFloat64(0,t);break;case 16:case 18:T=B(new DataView(e,n,8),0,t);break;case 17:T=V(new DataView(e,n,8),0,t);break;default:T=null}f.push(T)}}if(2===s){let e="";const t=f;for(f=[],w=0;w<t.length;w++)0===t[w]&&""!==e?(f.push(e),e=""):e+=String.fromCharCode(t[w]);""===e&&0!==f.length||f.push(e)}return n.values=f,!0}function k(e){const t=e[0],n=y(t,"TILEWIDTH"),a=y(t,"TILELENGTH"),i=y(t,"IMAGEWIDTH"),r=y(t,"IMAGELENGTH"),s=y(t,"BITSPERSAMPLE"),l=y(t,"SAMPLESPERPIXEL"),o=y(t,"SAMPLEFORMAT")??1,f=I(o,s),u=C(t),c=p(t,"GDAL_NODATA");let h=null;c?.length&&(h=c.map(e=>parseFloat(e)),h.some(e=>isNaN(e))&&(h=null));const g=y(t,"COMPRESSION")??1;let T;switch(g){case 1:T="NONE";break;case 2:case 3:case 4:case 32771:T="CCITT";break;case 5:T="LZW";break;case 6:case 7:T="JPEG";break;case 32773:T="PACKBITS";break;case 8:case 32946:T="DEFLATE";break;case 34712:T="JPEG2000";break;case 34887:T="LERC";break;default:T=String(g)}let A=!0,S="";E.has(g)||(A=!1,S+="unsupported tag compression "+g),o>3&&(A=!1,S+="unsupported tag sampleFormat "+o),s>32&&64!==s&&(A=!1,S+="unsupported tag bitsPerSample "+s);const M=m(t,"GEOASCIIPARAMS");let P;if(M){const e=M.split("|").find(e=>e.includes("ESRI PE String = ")),t=e?e.replace("ESRI PE String = ",""):"";P=t.startsWith("COMPD_CS")||t.startsWith("PROJCS")||t.startsWith("GEOGCS")?{wkid:null,wkt:t}:null}const O=d(t,"GEOTIEPOINTS"),b=d(t,"GEOPIXELSCALE"),x=d(t,"GEOTRANSMATRIX"),L=t.has("GEOKEYDIRECTORY")?t.get("GEOKEYDIRECTORY").data:null;let R,D,N=!1,k=!1;if(L){N=2===y(L,"GTRasterTypeGeoKey");const e=y(L,"GTModelTypeGeoKey");if(2===e){const e=y(L,"GeographicTypeGeoKey");e>=1024&&e<=32766&&(P={wkid:e}),P||32767!==e||(k=!0,P={wkid:4326})}else if(1===e){const e=y(L,"ProjectedCSTypeGeoKey");e>=1024&&e<=32766&&(P={wkid:e})}}if(b&&O&&O.length>=6?(R=[b[0],0,O[3]-O[0]*b[0],0,-Math.abs(b[1]),O[4]-O[1]*b[1]],N&&(R[2]-=.5*R[0]+.5*R[1],R[5]-=.5*R[3]+.5*R[4])):x&&16===x.length&&(R=N?[x[0],x[1],x[3]-.5*x[0],x[4],x[5],x[7]-.5*x[5]]:[x[0],x[1],x[3],x[4],x[5],x[7]]),R){const e=[{x:0,y:r},{x:0,y:0},{x:i,y:r},{x:i,y:0}];let t,n=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY;for(let i=0;i<e.length;i++)t=w(e[i],R),n=t.x>n?n:t.x,s=t.x<s?s:t.x,a=t.y>a?a:t.y,l=t.y<l?l:t.y;D={xmin:n,xmax:s,ymin:a,ymax:l,spatialReference:P}}else D={xmin:-.5,ymin:.5-r,xmax:i-.5,ymax:.5,spatialReference:P};k&&(D.xmax-D.xmin>400||Math.max(Math.abs(D.xmin),Math.abs(D.xmax))>361)&&(P=null,D.spatialReference=null);const F=G(e);let B,V,W,H,Y;if(F.length>0){W=Math.round(Math.log(i/y(F[0],"IMAGEWIDTH"))/Math.LN2);const e=F[F.length-1];H=F.length,B=y(e,"TILEWIDTH"),V=y(e,"TILELENGTH")}B=null!=H&&H>0?B||n:null,V=null!=H&&H>0?V||a:null,n&&(Y=[{maxCol:Math.ceil(i/n)-1,maxRow:Math.ceil(r/a)-1,minRow:0,minCol:0}],F.forEach(e=>{Y.push({maxCol:Math.ceil(y(e,"IMAGEWIDTH")/y(e,"TILEWIDTH"))-1,maxRow:Math.ceil(y(e,"IMAGELENGTH")/y(e,"TILELENGTH"))-1,minRow:0,minCol:0})}));const j=m(e[0],"GDAL_METADATA"),X=U(j);S+=" "+_({width:i,height:r,tileWidth:n,tileHeight:a,planes:l,ifds:e});const K=v(e).length===F.length+1,J=F?.length?F.map(e=>({x:i/y(e,"IMAGEWIDTH"),y:r/y(e,"IMAGELENGTH")})):void 0;return{width:i,height:r,tileWidth:n,tileHeight:a,planes:l,isBSQ:u,pixelType:f,compression:T,noData:h,hasMaskBand:K,isSupported:A,pyramidResolutions:J,message:S,extent:D,isPseudoGeographic:k,affine:b?null:R,firstPyramidLevel:W,maximumPyramidLevel:H,pyramidBlockWidth:B,pyramidBlockHeight:V,tileBoundary:Y,metadata:X}}function C(e,t){const n=p(e,"PLANARCONFIGURATION");return n?2===n[0]:!!t&&t.isBSQ}function G(e){return e.filter(e=>1===y(e,"NEWSUBFILETYPE"))}function v(e){return e.filter(e=>{const t=!(4&~(y(e,"NEWSUBFILETYPE")??0)),n=4===y(e,"PHOTOMETRICINTERPRETATION");return t&&n})}function F(e){const{littleEndian:t,isBigTiff:n,firstIFDPos:a}=H(e);let i=a;const r=[];do{const a=Y(e,t,i,0,s,n?8:4);if(!a.success)break;r.push(a.ifd),i=a.nextIFD}while(i>0);return{...k(r),littleEndian:t,isBigTiff:n,ifds:r,pyramidIFDs:G(r),maskIFDs:v(r)}}function B(e,t,n){const a=e.getUint32(t,n),i=e.getUint32(t+4,n);return n?i*g+a:a*g+i}function V(e,t,n){let a=n?e.getInt32(t,n):e.getUint32(t,n),i=n?e.getUint32(t+4,n):e.getInt32(t+4,n);const r=(n?a:i)>=0?1:-1;n?a*=r:i*=r;return r*(n?i*g+a:a*g+i)}function W(e,t,n,a){return a?B(e,t,n):e.getUint32(t,n)}function H(e){const t=new DataView(e,0,16),n=t.getUint16(0,!1);let a=null;if(18761===n)a=!0;else{if(19789!==n)throw new Error("unexpected endianess byte");a=!1}const i=t.getUint16(2,a);if(42!==i&&43!==i)throw new Error("unexpected tiff identifier");let r=4;const s=43===i;if(s){const e=t.getUint16(r,a);if(r+=2,8!==e)throw new Error("unsupported bigtiff version");if(0!==t.getUint16(r,a))throw new Error("unsupported bigtiff version");r+=2}return{littleEndian:a,isBigTiff:s,firstIFDPos:W(t,r,a,s)}}function Y(t,n,a,i=0,r=s,o=4){const u=A(t,n,a,i,r,o);let c;const h=u.ifd;if(h){if(l.forEach((e,a)=>{h.has(a)&&(c=h.get(a),c.data=A(t,n,c.valueOffset-i,i,e).ifd)}),h.has("GEOKEYDIRECTORY")){c=h.get("GEOKEYDIRECTORY");const e=c.values;if(e&&e.length>4){const a=e[0]+"."+e[1]+"."+e[2];c.data=A(t,n,c.valueOffset+6-i,i,f,2).ifd,c.data&&c.data.set("GEOTIFFVersion",{id:0,type:2,valueCount:1,valueOffset:null,values:[a]})}}if(h.has("XMP")){c=h.get("XMP");const t=c.values;"number"==typeof t[0]&&7===c.type&&(c.values=[e(new Uint8Array(t))])}}return u}function _(e){const{width:t,height:n,tileHeight:a,tileWidth:i}=e,r=e.planes,s=i?i*a:t*n,l=y(e.ifds[0],"BITSPERSAMPLE");let o="";return s*r>2**30/(l>8?l/8:1)&&(o=i?"tiled tiff exceeding 1 gigabits per tile is not supported":"scanline tiff exceeding 1 gigabits is not supported"),o}function j(e,t,n,a,i){const r=a?4:1,s=n*r*i;a&&(e=new Uint8Array(e.buffer));for(let f=0;f<t;f++){const t=f*s;for(let n=i;n<s;n++)e[t+n]+=e[t+n-i]}if(!a)return e;const l=new Uint8Array(e.length),o=n*i;for(let f=0;f<t;f++){const t=f*s;for(let n=0;n<o;n++)for(let a=0;a<r;a++)l[t+n*r+a]=e[t+n+(r-a-1)*o]}return new Float32Array(l.buffer)}async function X(e,t){const{headerInfo:n,ifd:a,offsets:i,sizes:s}=t,l=[];for(let r=0;r<i.length;r++){s[r];const t=await x(e,n.littleEndian,a,i[r],s[r]||e.byteLength);l.push(t)}const o=C(a,n),f=y(a,"BITSPERSAMPLE"),u=I(y(a,"SAMPLEFORMAT")??1,f),c=y(a,"SAMPLESPERPIXEL")||n.planes,h=T(u),g=y(a,"TILEWIDTH"),E=y(a,"TILELENGTH"),w=y(a,"COMPRESSION")??1,p=g*E;let d;const m=[];let A=l[0];const S=34887===w;for(let r=0;r<c;r++){if(d=new h(p),l.length===c)A=l[r],A.length===p&&(d=A);else if(A.length)if(o||S)d=A.length===p?A:A.slice(p*r,p*(r+1));else for(let e=0;e<p;e++)d[e]=A[e*c+r];m.push(d)}const M=n.noData?n.noData[0]:t.noDataValue,P=n.metadata?n.metadata.statistics:null,O=P?P.map(e=>e.min):null,b=P?P.map(e=>e.max):null,L={pixelType:u,width:g,height:E,pixels:m,noDataValue:M};return null!=M?r(L,M,{matchAllNoData:t?.matchAllNoData}):O&&b&&t.applyMinMaxConstraint&&(L.mask=D(m,O,b)),L}async function K(e,t={}){const n=t.pyramidLevel||0,a=t.headerInfo||F(e),{ifds:i,noData:s}=a;if(0===i.length)throw new Error("no valid image file directory");const l=_(a);if(l)throw l;let o=null;const f=-1===n?i[i.length-1]:i[n],u=s??t.noDataValue;if(o=a.tileWidth?await L(e,a,f):R(e,a,f),!o)return o;if(null!=u){r(o,u,{matchAllNoData:null==s&&t?.matchAllNoData})}return o}export{K as decode,X as decodeTileOrStrip,k as getImageInfo,v as getMaskIFDs,G as getPyramidIFDs,C as isBSQConfig,N as parseFieldValues,F as parseHeader,Y as parseIFD,H as parseSignature,M as unpackBits};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{isSome as e,equals as r,difference as a}from"../../core/arrayUtils.js";import t from"../../core/Error.js";import{updateOrigins as n}from"../../core/accessorSupport/originUtils.js";import{saveAs as s,save as o,getLayerJSON as l,getPortalItem as i,addItem as c,ensureLayerConfig as u,ensureItemConfig as y,setCommonItemProperties as p,createErrorMessage as f}from"./utils.js";import{parse as m}from"../support/arcgisLayerUrl.js";import{fetchFeatureService as d,getLayerModuleType as h}from"../support/fetchService.js";import{isLayerWithFeatureLayerSource as b}from"../support/layerUtils.js";import{createForItemWrite as w}from"../../portal/support/jsonContext.js";import{getWGS84ExtentForItem as T,toggleTypeKeyword as v,typeKeyword as S,removeTypeKeyword as L,hasTypeKeyword as I}from"../../portal/support/portalItemUtils.js";const g="Feature Service",E="feature-layer-utils",P=`${E}-save`,O=`${E}-save-as`,A=`${E}-saveall`,x=`${E}-saveall-as`;function N(e){return{isValid:b(e)&&(!("dynamicDataSource"in e)||!e.dynamicDataSource),errorMessage:"Feature layer should be a layer or table in a map or feature service"}}function $(e,r){const a=w(e,"portal-item");return r?.isTable&&(a.layerContainerType="tables"),a}function j(e){const r=$(e),a=$(e);return a.layerContainerType="tables",{forLayers:r,forTables:a}}function U(e){const r=[],a=[];for(const{layer:t,layerJSON:n}of e)R(t)?a.push(n):r.push(n);return{layers:r,tables:a}}function R(e,r){return e.isTable}function C(e){return U([e])}async function J(e,r){return/\/\d+\/?$/.test(e.url)?C(r[0]):G(r,e)}async function G(e,r){if(e.reverse(),!r)return U(e);const a=await _(r,e);for(const t of e)V(t.layer,t.layerJSON,a);return M(a,e),a}async function _(e,r){let a=await e.fetchData("json");if(D(a)&&!I(e,S.HOSTED_SERVICE))return a;a||={},F(a);const{layer:{url:t,customParameters:n,apiKey:s}}=r[0];return await B(a,{url:t??"",customParameters:n,apiKey:s},r.map(e=>e.layer.layerId)),a}function D(e){return!!(e&&Array.isArray(e.layers)&&Array.isArray(e.tables))}function F(e){e.layers||=[],e.tables||=[]}function M(e,r){const a=[],t=[];for(const{layer:n}of r){const{isTable:e,layerId:r}=n;e?t.push(r):a.push(r)}Y(e.layers,a),Y(e.tables,t)}function Y(e,a){if(e.length<2)return;const t=[];for(const{id:r}of e)t.push(r);r(t.sort(k),a.slice().sort(k))&&e.sort((e,r)=>{const t=a.indexOf(e.id),n=a.indexOf(r.id);return t<n?-1:t>n?1:0})}function k(e,r){return e<r?-1:e>r?1:0}async function B(e,r,a){const{url:t,customParameters:n,apiKey:s}=r,{serviceJSON:o,layersJSON:l}=await d(t,{customParameters:n,apiKey:s}),i=K(e.layers,o.layers,a),c=K(e.tables,o.tables,a);e.layers=i.itemResources,e.tables=c.itemResources;const u=[...i.added,...c.added],y=l?[...l.layers,...l.tables]:[];await z(e,u,t,y)}function K(e,r,t){const n=a(e,r,(e,r)=>e.id===r.id);e=e.filter(e=>!n.removed.some(r=>r.id===e.id));const s=n.added;return s.forEach(({id:r})=>{e.push({id:r})}),{itemResources:e,added:s.filter(({id:e})=>!t.includes(e))}}async function z(e,r,a,t){const n=await H(r),s=r.map(({id:e,type:r})=>new(n.get(r))({url:a,layerId:e,sourceJSON:t.find(({id:r})=>r===e)}));await Promise.allSettled(s.map(e=>e.load())),s.forEach(r=>{const{layerId:a,loaded:t,defaultPopupTemplate:n}=r;if(!t||null==n)return;const s={id:a,popupInfo:n.toJSON()};V(r,"ArcGISFeatureLayer"===r.operationalLayerType?s:{...s,layerType:r.operationalLayerType},e)})}async function H(e){const r=[];e.forEach(({type:e})=>{switch(h(e)){case"CatalogLayer":r.push(import("../CatalogLayer.js").then(e=>e.default));break;case"FeatureLayer":r.push(import("../FeatureLayer.js").then(e=>e.default));break;case"OrientedImageryLayer":r.push(import("../OrientedImageryLayer.js").then(e=>e.default))}});const a=await Promise.all(r),t=new Map;return e.forEach(({type:e},r)=>{t.set(e,a[r])}),t}function V(e,r,a){e.isTable?q(a.tables,r):q(a.layers,r)}function q(e,r){const a=e.findIndex(({id:e})=>e===r.id);-1===a?e.push(r):e[a]=r}function Q(e,r){if(!e.length)throw new t(`${r}:missing-parameters`,"'layers' array should contain at least one feature layer")}function W(e,r){const a=e.map(e=>e.portalItem.id);if(new Set(a).size>1)throw new t(`${r}:invalid-parameters`,"All layers in the 'layers' array should be loaded from the same portal item")}function X(e,r){const a=e.map(e=>e.layerId);if(new Set(a).size!==a.length)throw new t(`${r}:invalid-parameters`,"'layers' array should contain only one instance each of layer or table in a feature service")}async function Z(e){Q(e,A),await Promise.all(e.map(e=>e.load()));for(const r of e)u(r,A,N),y({layer:r,itemType:g,errorNamePrefix:A});W(e,A),X(e,A)}function ee(e){if(!("layerType"in e))return!!e.charts?.length;switch(e.layerType){case"OrientedImageryLayer":return!!e.charts?.length;case"SubtypeGroupLayer":return!!e.layers.some(e=>!!e.charts?.length);case"SubtypeGroupTable":return!!e.tables.some(e=>!!e.charts?.length);case"CatalogLayer":return!!e.footprintLayer?.charts?.length}}function re(e,r){let a=0,t=0,n=0,s=0;for(const o of[...r.layers,...r.tables])if(ee(o)&&s++,"layerType"in o)switch(o.layerType){case"OrientedImageryLayer":a++;break;case"SubtypeGroupLayer":t++;break;case"SubtypeGroupTable":n++}v(e,S.ORIENTED_IMAGERY_LAYER,a>0),v(e,S.SUBTYPE_GROUP_LAYER,t>0),v(e,S.SUBTYPE_GROUP_TABLE,n>0),v(e,S.CHARTS,s>0)}function ae(e,r,a){L(r,S.METADATA),v(r,S.MULTI_LAYER,e.length>1),v(r,S.SINGLE_LAYER,1===e.length),v(r,S.TABLE,a.tables.length>0&&0===a.layers.length),re(r,a)}async function te(e,r,a){re(r,a)}async function ne(e,r,a){const{url:t,layerId:n,title:s,fullExtent:o,isTable:l}=e,i=m(t);r.url=("FeatureServer"===i?.serverType?t:`${t}/${n}`)??null,r.title||=s,r.extent=null,l||null==o||(r.extent=await T(o)),ae([e],r,a)}function se(e,r){for(const o of e){const a=o.parsedUrl.path,n=m(a),s=n?.url.path;if(!s)throw new t(`${r}:invalid-parameters`,f(o,`has unsupported url pattern: ${a}`),{layer:o});const l=n?.serverType;if("FeatureServer"!==l&&"MapServer"!==l)throw new t(`${r}:invalid-parameters`,f(o,`has unsupported server type: ${l}`),{layer:o});if("MapServer"===l&&e.length>1)throw new t(`${r}:invalid-parameters`,"Only one layer or table in a map service can be saved")}const a=m(e[0].parsedUrl.path),n=a?.url.path,s=e.every(e=>{const r=m(e.parsedUrl.path);return r?.url.path===n});if(!s)throw new t(`${r}:invalid-parameters`,"'layers' array should only contain layers or tables that belong to the same feature service")}async function oe(e){Q(e,x),await Promise.all(e.map(e=>e.load()));for(const r of e)u(r,x,N);se(e,x),X(e,x)}function le(e,r){re(e,r),p(e)}async function ie(r,a,t){let n=0;for(const{isTable:e}of r)e||n++;const s=r[0].parsedUrl.path,o=m(s);if(a.url="FeatureServer"===o?.serverType?o.url.path:s,a.title||=o.title,a.extent=null,n>0){const t=r.map(e=>e.fullExtent).filter(e).reduce((e,r)=>e.clone().union(r));t&&(a.extent=await T(t))}ae(r,a,t),p(a)}async function ce(e,r){return o({layer:e,itemType:g,validateLayer:N,createJSONContext:r=>$(r,e),createItemData:(e,r)=>J(r,[e]),errorNamePrefix:P,setItemProperties:te},r)}async function ue(e,r){await Z(e);const a=e[0].portalItem,t=j(a),s=await Promise.all(e.map(e=>l(e,e.isTable?t.forTables:t.forLayers,r))),o=await J(a,e.map((e,r)=>({layer:e,layerJSON:s[r]})));return le(a,o),await a.update({data:o}),await Promise.all(e.slice(1).map(e=>e.portalItem.reload())),n(t.forLayers),n(t.forTables),a.clone()}async function ye(e,r,a){return s({layer:e,itemType:g,validateLayer:N,createJSONContext:r=>$(r,e),createItemData:(e,r)=>Promise.resolve(C(e)),errorNamePrefix:O,newItem:r,setItemProperties:ne},a)}async function pe(e,r,a){await oe(e);const t=i({itemType:g,errorNamePrefix:x,newItem:r}),s=j(t),o=await Promise.all(e.map(e=>l(e,e.isTable?s.forTables:s.forLayers,a))),u=await G(e.map((e,r)=>({layer:e,layerJSON:o[r]})));await ie(e,t,u),await c(t,u,a);for(const n of e)n.portalItem=t.clone();return n(s.forLayers),n(s.forTables),t}export{ce as save,ue as saveAll,pe as saveAllAs,ye as saveAs};
2
+ import{isSome as e,equals as r,difference as a}from"../../core/arrayUtils.js";import t from"../../core/Error.js";import{updateOrigins as n}from"../../core/accessorSupport/originUtils.js";import{saveAs as s,save as o,getLayerJSON as l,getPortalItem as i,addItem as c,ensureLayerConfig as u,ensureItemConfig as y,setCommonItemProperties as p,createErrorMessage as f}from"./utils.js";import{parse as m}from"../support/arcgisLayerUrl.js";import{fetchFeatureService as d,getLayerModuleType as h}from"../support/fetchService.js";import{isLayerWithFeatureLayerSource as b}from"../support/layerUtils.js";import{createForItemWrite as w}from"../../portal/support/jsonContext.js";import{getWGS84ExtentForItem as T,toggleTypeKeyword as v,typeKeyword as S,removeTypeKeyword as L,hasTypeKeyword as I}from"../../portal/support/portalItemUtils.js";const g="Feature Service",E="feature-layer-utils",P=`${E}-save`,O=`${E}-save-as`,A=`${E}-saveall`,x=`${E}-saveall-as`;function N(e){return{isValid:b(e)&&(!("dynamicDataSource"in e)||!e.dynamicDataSource),errorMessage:"Feature layer should be a layer or table in a map or feature service"}}function $(e,r){const a=w(e,"portal-item");return r?.isTable&&(a.layerContainerType="tables"),a}function j(e){const r=$(e),a=$(e);return a.layerContainerType="tables",{forLayers:r,forTables:a}}function U(e){const r=[],a=[];for(const{layer:t,layerJSON:n}of e)R(t)?a.push(n):r.push(n);return{layers:r,tables:a}}function R(e,r){return e.isTable}function C(e){return U([e])}async function J(e,r){return/\/\d+\/?$/.test(e.url)?C(r[0]):G(r,e)}async function G(e,r){if(e.reverse(),!r)return U(e);const a=await _(r,e);for(const t of e)V(t.layer,t.layerJSON,a);return M(a,e),a}async function _(e,r){let a=await e.fetchData("json");if(D(a)&&!I(e,S.HOSTED_SERVICE))return a;a||={},F(a);const{layer:{url:t,customParameters:n,apiKey:s}}=r[0];return await B(a,{url:t??"",customParameters:n,apiKey:s},r.map(e=>e.layer.layerId)),a}function D(e){return!!(e&&Array.isArray(e.layers)&&Array.isArray(e.tables))}function F(e){e.layers||=[],e.tables||=[]}function M(e,r){const a=[],t=[];for(const{layer:n}of r){const{isTable:e,layerId:r}=n;e?t.push(r):a.push(r)}Y(e.layers,a),Y(e.tables,t)}function Y(e,a){if(e.length<2)return;const t=[];for(const{id:r}of e)t.push(r);r(t.sort(k),a.slice().sort(k))&&e.sort((e,r)=>{const t=a.indexOf(e.id),n=a.indexOf(r.id);return t<n?-1:t>n?1:0})}function k(e,r){return e<r?-1:e>r?1:0}async function B(e,r,a){const{url:t,customParameters:n,apiKey:s}=r,{serviceJSON:o,layersJSON:l}=await d(t,{customParameters:n,apiKey:s}),i=K(e.layers,o.layers,a),c=K(e.tables,o.tables,a);e.layers=i.itemResources,e.tables=c.itemResources;const u=[...i.added,...c.added],y=l?[...l.layers,...l.tables]:[];await z(e,u,t,y)}function K(e,r,t){const n=a(e,r,(e,r)=>e.id===r.id);e=e.filter(e=>!n.removed.some(r=>r.id===e.id));const s=n.added;return s.forEach(({id:r})=>{e.push({id:r})}),{itemResources:e,added:s.filter(({id:e})=>!t.includes(e))}}async function z(e,r,a,t){const n=await H(r),s=r.map(({id:e,type:r})=>new(n.get(r))({url:a,layerId:e,sourceJSON:t.find(({id:r})=>r===e)}));await Promise.allSettled(s.map(e=>e.load())),s.forEach(r=>{const{layerId:a,loaded:t,defaultPopupTemplate:n}=r;if(!t||null==n)return;const s={id:a,popupInfo:n.toJSON()};V(r,"ArcGISFeatureLayer"===r.operationalLayerType?s:{...s,layerType:r.operationalLayerType},e)})}async function H(e){const r=[];e.forEach(({type:e})=>{switch(h(e)){case"CatalogLayer":r.push(import("../CatalogLayer.js").then(e=>e.default));break;case"FeatureLayer":r.push(import("../FeatureLayer.js").then(e=>e.default));break;case"OrientedImageryLayer":r.push(import("../OrientedImageryLayer.js").then(e=>e.default))}});const a=await Promise.all(r),t=new Map;return e.forEach(({type:e},r)=>{t.set(e,a[r])}),t}function V(e,r,a){e.isTable?q(a.tables,r):q(a.layers,r)}function q(e,r){const a=e.findIndex(({id:e})=>e===r.id);-1===a?e.push(r):e[a]=r}function Q(e,r){if(!e.length)throw new t(`${r}:missing-parameters`,"'layers' array should contain at least one feature layer")}function W(e,r){const a=e.map(e=>e.portalItem.id);if(new Set(a).size>1)throw new t(`${r}:invalid-parameters`,"All layers in the 'layers' array should be loaded from the same portal item")}function X(e,r){const a=e.map(e=>e.layerId);if(new Set(a).size!==a.length)throw new t(`${r}:invalid-parameters`,"'layers' array should contain only one instance each of layer or table in a feature service")}async function Z(e){Q(e,A),await Promise.all(e.map(e=>e.load()));for(const r of e)u(r,A,N),y({layer:r,itemType:g,errorNamePrefix:A});W(e,A),X(e,A)}function ee(e){if(!("layerType"in e))return!!e.charts?.length;switch(e.layerType){case"OrientedImageryLayer":return!!e.charts?.length;case"SubtypeGroupLayer":return!!e.layers.some(e=>!!e.charts?.length);case"SubtypeGroupTable":return!!e.tables.some(e=>!!e.charts?.length);case"CatalogLayer":return!!e.footprintLayer?.charts?.length}}function re(e,r){let a=0,t=0,n=0,s=0;for(const o of[...r.layers,...r.tables])if(ee(o)&&s++,"layerType"in o)switch(o.layerType){case"OrientedImageryLayer":a++;break;case"SubtypeGroupLayer":t++;break;case"SubtypeGroupTable":n++}v(e,S.ORIENTED_IMAGERY_LAYER,a>0),v(e,S.SUBTYPE_GROUP_LAYER,t>0),v(e,S.SUBTYPE_GROUP_TABLE,n>0),v(e,S.CHARTS,s>0)}function ae(e,r,a){L(r,S.METADATA),v(r,S.MULTI_LAYER,e.length>1),v(r,S.SINGLE_LAYER,1===e.length),v(r,S.TABLE,a.tables.length>0&&0===a.layers.length),re(r,a)}function te(e,r,a){re(r,a)}async function ne(e,r,a){const{url:t,layerId:n,title:s,fullExtent:o,isTable:l}=e,i=m(t);r.url=("FeatureServer"===i?.serverType?t:`${t}/${n}`)??null,r.title||=s,r.extent=null,l||null==o||(r.extent=await T(o)),ae([e],r,a)}function se(e,r){for(const o of e){const a=o.parsedUrl.path,n=m(a),s=n?.url.path;if(!s)throw new t(`${r}:invalid-parameters`,f(o,`has unsupported url pattern: ${a}`),{layer:o});const l=n?.serverType;if("FeatureServer"!==l&&"MapServer"!==l)throw new t(`${r}:invalid-parameters`,f(o,`has unsupported server type: ${l}`),{layer:o});if("MapServer"===l&&e.length>1)throw new t(`${r}:invalid-parameters`,"Only one layer or table in a map service can be saved")}const a=m(e[0].parsedUrl.path),n=a?.url.path,s=e.every(e=>{const r=m(e.parsedUrl.path);return r?.url.path===n});if(!s)throw new t(`${r}:invalid-parameters`,"'layers' array should only contain layers or tables that belong to the same feature service")}async function oe(e){Q(e,x),await Promise.all(e.map(e=>e.load()));for(const r of e)u(r,x,N);se(e,x),X(e,x)}function le(e,r){re(e,r),p(e)}async function ie(r,a,t){let n=0;for(const{isTable:e}of r)e||n++;const s=r[0].parsedUrl.path,o=m(s);if(a.url="FeatureServer"===o?.serverType?o.url.path:s,a.title||=o.title,a.extent=null,n>0){const t=r.map(e=>e.fullExtent).filter(e).reduce((e,r)=>e.clone().union(r));t&&(a.extent=await T(t))}ae(r,a,t),p(a)}async function ce(e,r){return o({layer:e,itemType:g,validateLayer:N,createJSONContext:r=>$(r,e),createItemData:(e,r)=>J(r,[e]),errorNamePrefix:P,setItemProperties:te},r)}async function ue(e,r){await Z(e);const a=e[0].portalItem,t=j(a),s=await Promise.all(e.map(e=>l(e,e.isTable?t.forTables:t.forLayers,r))),o=await J(a,e.map((e,r)=>({layer:e,layerJSON:s[r]})));return le(a,o),await a.update({data:o}),await Promise.all(e.slice(1).map(e=>e.portalItem.reload())),n(t.forLayers),n(t.forTables),a.clone()}async function ye(e,r,a){return s({layer:e,itemType:g,validateLayer:N,createJSONContext:r=>$(r,e),createItemData:(e,r)=>Promise.resolve(C(e)),errorNamePrefix:O,newItem:r,setItemProperties:ne},a)}async function pe(e,r,a){await oe(e);const t=i({itemType:g,errorNamePrefix:x,newItem:r}),s=j(t),o=await Promise.all(e.map(e=>l(e,e.isTable?s.forTables:s.forLayers,a))),u=await G(e.map((e,r)=>({layer:e,layerJSON:o[r]})));await ie(e,t,u),await c(t,u,a);for(const n of e)n.portalItem=t.clone();return n(s.forLayers),n(s.forTables),t}export{ce as save,ue as saveAll,pe as saveAllAs,ye as saveAs};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{saveAs as e,save as r}from"./utils.js";import{createForItemWrite as t}from"../../portal/support/jsonContext.js";import{typeKeyword as o,hasTypeKeyword as a,removeTypeKeyword as s,addTypeKeyword as n}from"../../portal/support/portalItemUtils.js";import{saveResources as i}from"../../webdoc/support/resourceUtils.js";const u="Group Layer",c="group-layer-save",l="group-layer-save-as",p=o.GROUP_LAYER_MAP;function m(e){return{isValid:"group"===e.type,errorMessage:"Layer.type should be 'group'"}}function y(e){return{isValid:a(e,p),errorMessage:`Layer.portalItem.typeKeywords should have '${p}'`}}function f(e,r){return{...t(e,"web-map",!0),initiator:r}}function v(e){const r=e.layerJSON;return Promise.resolve(r&&Object.keys(r).length?r:null)}async function d(e,r){r.title||=e.title,s(r,o.METADATA),n(r,p)}async function I(e,t){return r({layer:e,itemType:u,validateLayer:m,validateItem:y,createJSONContext:r=>f(r,e),createItemData:v,errorNamePrefix:c,saveResources:async(r,t)=>(e.sourceIsPortalItem||await r.removeAllResources().catch(()=>{}),i(e.resourceReferences,t))},t)}async function g(r,t,o){return e({layer:r,itemType:u,validateLayer:m,createJSONContext:e=>f(e,r),createItemData:v,errorNamePrefix:l,newItem:t,setItemProperties:d,saveResources:(e,t)=>i(r.resourceReferences,t)},o)}export{I as save,g as saveAs};
2
+ import{saveAs as e,save as r}from"./utils.js";import{createForItemWrite as t}from"../../portal/support/jsonContext.js";import{typeKeyword as o,hasTypeKeyword as s,removeTypeKeyword as a,addTypeKeyword as n,toggleTypeKeyword as i}from"../../portal/support/portalItemUtils.js";import{saveResources as u}from"../../webdoc/support/resourceUtils.js";import{hasCharts as c}from"../../webdoc/support/saveUtils.js";const p="Group Layer",l="group-layer-save",m="group-layer-save-as",y=o.GROUP_LAYER_MAP;function f(e){return{isValid:"group"===e.type,errorMessage:"Layer.type should be 'group'"}}function v(e){return{isValid:s(e,y),errorMessage:`Layer.portalItem.typeKeywords should have '${y}'`}}function d(e,r){return{...t(e,"web-map",!0),initiator:r}}function I(e){const r=e.layerJSON;return Promise.resolve(r&&Object.keys(r).length?r:null)}function A(e,r){i(r,o.CHARTS,c(e))}function P(e,r){A(e,r)}async function R(e,r){r.title||=e.title,a(r,o.METADATA),n(r,y),A(e,r)}async function g(e,t){return r({layer:e,itemType:p,validateLayer:f,validateItem:v,createJSONContext:r=>d(r,e),createItemData:I,errorNamePrefix:l,setItemProperties:P,saveResources:async(r,t)=>(e.sourceIsPortalItem||await r.removeAllResources().catch(()=>{}),u(e.resourceReferences,t))},t)}async function j(r,t,o){return e({layer:r,itemType:p,validateLayer:f,createJSONContext:e=>d(e,r),createItemData:I,errorNamePrefix:m,newItem:t,setItemProperties:R,saveResources:(e,t)=>u(r.resourceReferences,t)},o)}export{g as save,j as saveAs};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{saveAs as e,save as t}from"./utils.js";import{getWGS84ExtentForItem as r,removeTypeKeyword as a,typeKeyword as n,addTypeKeyword as s,toggleTypeKeyword as i}from"../../portal/support/portalItemUtils.js";const o="Map Service",l="map-image-layer-save",m="map-image-layer-save-as";function c(e){return{isValid:"map-image"===e.type&&!e.sourceJSON?.tileInfo,errorMessage:"Layer.type should be 'map-image' and reference a dynamic (non-cached) map service"}}function p(e){const t=e.layerJSON;return Promise.resolve(t&&Object.keys(t).length?t:null)}function u(e,t){return f(e,t),Promise.resolve()}async function y(e,t){const{parsedUrl:s,title:i,fullExtent:o}=e;t.url=s.path,t.title||=i,t.extent=o?await r(o):null,a(t,n.METADATA),f(e,t)}function f(e,t){s(t,n.DYNAMIC);const r=e.sublayers?.length??0;i(t,n.MULTI_LAYER,r>1),i(t,n.SINGLE_LAYER,1===r)}async function v(e,r){return t({layer:e,itemType:o,validateLayer:c,createItemData:p,errorNamePrefix:l,setItemProperties:u},r)}async function I(t,r,a){return e({layer:t,itemType:o,validateLayer:c,createItemData:p,errorNamePrefix:m,newItem:r,setItemProperties:y},a)}export{v as save,I as saveAs};
2
+ import{saveAs as e,save as t}from"./utils.js";import{getWGS84ExtentForItem as a,removeTypeKeyword as r,typeKeyword as n,addTypeKeyword as s,toggleTypeKeyword as i}from"../../portal/support/portalItemUtils.js";const o="Map Service",l="map-image-layer-save",m="map-image-layer-save-as";function c(e){return{isValid:"map-image"===e.type&&!e.sourceJSON?.tileInfo,errorMessage:"Layer.type should be 'map-image' and reference a dynamic (non-cached) map service"}}function p(e){const t=e.layerJSON;return Promise.resolve(t&&Object.keys(t).length?t:null)}function u(e,t){f(e,t)}async function y(e,t){const{parsedUrl:s,title:i,fullExtent:o}=e;t.url=s.path,t.title||=i,t.extent=o?await a(o):null,r(t,n.METADATA),f(e,t)}function f(e,t){s(t,n.DYNAMIC);const a=e.sublayers?.length??0;i(t,n.MULTI_LAYER,a>1),i(t,n.SINGLE_LAYER,1===a)}async function I(e,a){return t({layer:e,itemType:o,validateLayer:c,createItemData:p,errorNamePrefix:l,setItemProperties:u},a)}async function v(t,a,r){return e({layer:t,itemType:o,validateLayer:c,createItemData:p,errorNamePrefix:m,newItem:a,setItemProperties:y},r)}export{I as save,v as saveAs};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../PopupTemplate.js";import{ClonableMixin as r}from"../../core/Clonable.js";import i from"../../core/Error.js";import{IdentifiableMixin as n}from"../../core/Identifiable.js";import{clone as o}from"../../core/lang.js";import{Loadable as s}from"../../core/Loadable.js";import l from"../../core/Logger.js";import{destroyMaybe as a}from"../../core/maybe.js";import{MultiOriginJSONSupportMixin as p}from"../../core/MultiOriginJSONSupport.js";import{setDeepValue as d}from"../../core/object.js";import{sqlAnd as u}from"../../core/sql.js";import{property as y,subclass as c}from"../../core/accessorSupport/decorators.js";import{excludeTables as m}from"../../core/accessorSupport/layerContainerType.js";import f from"../../form/FormTemplate.js";import h from"../../geometry/SpatialReference.js";import b from"../../graphic/SubtypeGroupGraphicOrigin.js";import{labelsVisible as g,legendEnabled as v,minScale as j,maxScale as w,popupEnabled as F}from"./commonProperties.js";import{createQuery as T,computeDomainFromSubtypes as O}from"./featureLayerUtils.js";import I from"./FeatureTemplate.js";import{defineFieldProperties as S}from"./fieldProperties.js";import{fixRendererFields as C}from"./fieldUtils.js";import A from"./LabelClass.js";import{reader as E}from"./labelingInfo.js";import{rendererReader as q,supportedRendererTypes as x}from"./subtypeGroupLayerUtils.js";import R from"./TitleCreator.js";import _ from"../../renderers/SimpleRenderer.js";import P from"../../rest/support/AttachmentQuery.js";import L from"../../rest/support/Query.js";import{createPopupTemplate as G}from"../../support/popupUtils.js";import{defaultPolygonSymbol2D as D,defaultPolylineSymbol2D as N,defaultPointSymbol2D as $}from"../../symbols/support/defaults.js";import U from"../../tables/AttributeTableTemplate.js";import{writer as V}from"../../core/accessorSupport/decorators/writer.js";import{reader as M}from"../../core/accessorSupport/decorators/reader.js";const Q=S();let k=0;function B(e,t){let r=e.json.write;return"object"!=typeof r&&(r=e.json.write={}),r.ignoreOrigin=!0,t?.spatialOnly&&(r.layerContainerTypes=m),e}function H(e){const t={write:{ignoreOrigin:!0}};return e?.name&&(t.name=e.name),"object"==typeof t.write&&(e?.spatialOnly&&(t.write.layerContainerTypes=m),e?.target&&(t.write.target=e.target)),t}function J(e){return new _({symbol:W(e)})}function W(e){switch(e){case"point":case"multipoint":return $.clone();case"polyline":return N.clone();case"polygon":case"multipatch":return D.clone();default:return null}}function z(e,t){return!!t&&("unique-value"===e?.type&&null!=e.field&&e.field.toLowerCase()===t.toLowerCase()&&!e.field2&&!e.field3&&!e.valueExpression)}function K(e){return Y(e,"user")===e}function X(e){return Y(e,"service")}function Y(e,t){const r=e.parent?.getAtOrigin("sublayers",t);return r?.find(({subtypeCode:t})=>t===e.subtypeCode)}function Z(e,t){return null==e?null:t.subtypes?.find(t=>t.code===e)}function ee(e,t){let r=null;switch(t.geometryType){case"esriGeometryPoint":case"esriGeometryMultipoint":r="point";break;case"esriGeometryPolyline":r="line";break;case"esriGeometryPolygon":case"esriGeometryMultiPatch":r="polygon";break;default:t.type,r=null}const i={},n=Z(e,t);if(null!=n){const{defaultValues:e}=n;for(const t in e)i[t]=e[t]}return i[t.subtypeField]=e,new I({name:"New Feature",drawingTool:r,prototype:{attributes:i}})}let te=class extends(p(r(n(s)))){constructor(e){super(e),this.attributeTableTemplate=null,this.charts=null,this.editingEnabled=!0,this.fieldOverrides=null,this.fieldsIndex=null,this.formTemplate=null,this.graphicOrigin=new b(this),this.id=`${Date.now().toString(16)}-subtype-sublayer-${k++}`,this.type="subtype-sublayer",this.labelsVisible=!0,this.labelingInfo=null,this.layerType="ArcGISFeatureLayer",this.legendEnabled=!0,this.listMode="show",this.minScale=0,this.maxScale=0,this.opacity=1,this.parent=null,this.popupEnabled=!0,this.popupTemplate=null,this.subtypeCode=null,this.visible=!0}load(e){return C(this.renderer,this.fieldsIndex),Promise.resolve(this)}get _titleCreator(){const e=this._get("_titleCreator");return a(e),new R({fieldsIndex:this.fieldsIndex,objectIdField:this.objectIdField,displayField:this.parent?.displayField??"",fields:this.fields,effectivePopupTemplate:this.popupTemplate??this.defaultPopupTemplate})}get capabilities(){return this.parent?.capabilities}get effectiveCapabilities(){return this.parent?.effectiveCapabilities}get effectiveEditingEnabled(){const{parent:e}=this;return e?e.effectiveEditingEnabled&&this.editingEnabled:this.editingEnabled}get elevationInfo(){return this.parent?.elevationInfo}get featureTitleFields(){return[...this._titleCreator.requiredFields]}writeFieldOverrides(e,t,r){const{fields:i,parent:n}=this;let s;if(i){s=[];let e=0;i.forEach(({name:t,alias:r,editable:i,visible:o})=>{if(!o)return;const l=n?.fields?.find(e=>e.name===t);if(!l)return;const a={name:t};let p=!1;r!==l.alias&&(a.alias=r,p=!0),i!==l.editable&&(a.editable=i,p=!0),s.push(a),p&&e++}),0===e&&s.length===i.length&&(s=null)}else s=o(e);s?.length&&d(r,s,t)}get fields(){const{parent:e,fieldOverrides:t,subtypeCode:r}=this,i=e?.fields;if(!e||!i?.length)return null;const{subtypes:n,subtypeField:o}=e,s=n?.find(e=>e.code===r),l=s?.defaultValues,a=s?.domains,p=[];for(const d of i){const e=d.clone(),{name:i}=e,n=t?.find(e=>e.name===i);if(e.visible=!t?.length||!!n,n){const{alias:t,editable:r}=n;t&&(e.alias=t),!1===r&&(e.editable=!1)}const s=l?.[i]??null;e.defaultValue=i===o?r:s;const u=a?.[i]??null;e.domain=i===o?null:u?"inherited"===u.type?e.domain:u.clone():null,p.push(e)}return p}get floorInfo(){return this.parent?.floorInfo}get isTable(){return!!this.parent?.isTable}get geometryType(){return this.parent?.geometryType}get globalIdField(){return this.parent?this.parent.globalIdField:(l.getLogger(this).error(ne("globalIdField")),null)}get effectiveScaleRange(){const{minScale:e,maxScale:t}=this;return{minScale:e,maxScale:t}}get objectIdField(){return this.parent||l.getLogger(this).error(ne("objectIdField")),this.parent?.objectIdField}get defaultPopupTemplate(){return this.createPopupTemplate()}get relationships(){return this.parent?.relationships}set renderer(e){C(e,this.fieldsIndex),this._override("renderer",e)}get renderer(){if(this._isOverridden("renderer"))return this._get("renderer");const{parent:e}=this;return e&&!e.isTable&&"mesh"!==e.geometryType?(K(this)?o(X(this)?.renderer):null)??J(e.geometryType):null}readRendererFromService(e,t,r){if("Table"===t.type)return null;const i=t.drawingInfo?.renderer,n=q(i,t,r);let o;const{subtypeCode:s}=this;if(null!=s&&z(n,t.subtypeField)){const e=n.uniqueValueInfos?.find(({value:e})=>(e="number"==typeof e?String(e):e)===String(s));e&&(o=new _({symbol:e.symbol}))}else"simple"!==n?.type||n.visualVariables?.length||(o=n);return o}readRenderer(e,t,r){const i=t?.layerDefinition?.drawingInfo?.renderer;if(i)return q(i,t,r)||void 0}get spatialReference(){return this.parent?.spatialReference??h.WGS84}get subtypeField(){return this.parent?.subtypeField}get templates(){if(this._isOverridden("templates"))return this._get("templates");const e=K(this)?X(this):null;return o(e?.templates)}set templates(e){this._override("templates",e)}readTemplatesFromService(e,t){return[ee(this.subtypeCode,t)]}get title(){if(this._isOverridden("title"))return this._get("title");const e=K(this)?X(this):null;return e?.title}set title(e){this._override("title",e)}readTitleFromService(e,t){const r=Z(this.subtypeCode,t);return null!=r?r.name:null}get url(){return this.parent?.url}get userHasUpdateItemPrivileges(){return!!this.parent?.userHasUpdateItemPrivileges}async addAttachment(e,t){const{parent:r}=this;if(!r)throw ne("addAttachment");if(e.getAttribute(r.subtypeField)!==this.subtypeCode)throw new i("subtype-sublayer:addAttachment","The feature provided does not belong to this SubtypeSublayer");return r.addAttachment(e,t)}async updateAttachment(e,t,r){const{parent:n}=this;if(!n)throw ne("updateAttachment");if(e.getAttribute(n.subtypeField)!==this.subtypeCode)throw new i("subtype-sublayer:updateAttachment","The feature provided does not belong to this SubtypeSublayer");return n.updateAttachment(e,t,r)}async deleteAttachments(e,t){const{parent:r}=this;if(!r)throw ne("deleteAttachments");if(e.getAttribute(r.subtypeField)!==this.subtypeCode)throw new i("subtype-sublayer:deleteAttachments","The feature provided does not belong to this SubtypeSublayer");return r.deleteAttachments(e,t)}async applyEdits(e,t){if(!this.parent)throw ne("applyEdits");return this.parent.applyEdits(e,t)}createPopupTemplate(e){let t=this;const{parent:r,fields:i,title:n}=this;if(r){const{displayField:e,editFieldsInfo:o,objectIdField:s}=r;t={displayField:e,editFieldsInfo:o,fields:i,objectIdField:s,title:n}}return G(t,e)}createQuery(){if(!this.parent)throw ne("createQuery");const e=T(this.parent),t=`${this.parent.subtypeField}=${this.subtypeCode}`;return e.where=u(t,this.parent.definitionExpression),e}getFeatureTitle(e,t){return this._titleCreator.getTitle(this,e,t)}getFeatureTitles(e,t){return this._titleCreator.getTitles(this,e,t)}getField(e){return this.fieldsIndex.get(e)}getFieldDomain(e,t){if(!t?.excludeImpliedDomains&&this.parent){const t=O(this.parent,e);if(t)return t}return this._getLayerDomain(e)}async queryAttachments(e,t){const r=await this.load();if(!r.parent)throw ne("queryAttachments");const i=e instanceof P?e.clone():new P(e);return i.where=ie(i.where,r.parent.subtypeField,r.subtypeCode),r.parent.queryAttachments(i,t)}async queryFeatureCount(e,t){const r=await this.load();if(!r.parent)throw ne("queryFeatureCount");return r.parent.queryFeatureCount(re(r.parent,r,e),t)}async queryFeatures(e,t){const r=await this.load();if(!r.parent)throw ne("queryFeatures");return r.parent.queryFeatures(re(r.parent,r,e),t)}async queryObjectIds(e,t){const r=await this.load();if(!r.parent)throw ne("queryObjectIds");return r.parent.queryObjectIds(re(r.parent,r,e),t)}async queryRelatedFeatures(e,t){const r=await this.load();if(!r.parent)throw ne("queryRelatedFeatures");return r.parent.queryRelatedFeatures(e,t)}async queryRelatedFeaturesCount(e,t){const r=await this.load();if(!r.parent)throw ne("queryRelatedFeaturesCount");return r.parent.queryRelatedFeaturesCount(e,t)}_getLayerDomain(e){const t=this.fieldsIndex.get(e);return t?t.domain:null}};e([y({clonable:!1,readOnly:!0})],te.prototype,"_titleCreator",null),e([y({type:U,json:H({name:"attributeTableInfo"})})],te.prototype,"attributeTableTemplate",void 0),e([y({readOnly:!0,json:{read:!1}})],te.prototype,"capabilities",null),e([y({readOnly:!0,json:{read:!1}})],te.prototype,"effectiveCapabilities",null),e([y({json:H()})],te.prototype,"charts",void 0),e([y({type:Boolean,nonNullable:!0,json:H({name:"enableEditing"})})],te.prototype,"editingEnabled",void 0),e([y({type:Boolean,readOnly:!0})],te.prototype,"effectiveEditingEnabled",null),e([y({readOnly:!0,json:{read:!1}})],te.prototype,"elevationInfo",null),e([y({clonable:!1,readOnly:!0})],te.prototype,"featureTitleFields",null),e([y({json:{name:"layerDefinition.fieldOverrides",origins:{service:{read:!1}},write:{ignoreOrigin:!0,allowNull:!0}}})],te.prototype,"fieldOverrides",void 0),e([V("fieldOverrides")],te.prototype,"writeFieldOverrides",null),e([y({...Q.fields,readOnly:!0,json:{read:!1}})],te.prototype,"fields",null),e([y(Q.fieldsIndex)],te.prototype,"fieldsIndex",void 0),e([y({readOnly:!0,json:{read:!1}})],te.prototype,"floorInfo",null),e([y({type:f,json:H({name:"formInfo"})})],te.prototype,"formTemplate",void 0),e([y({readOnly:!0,clonable:!1})],te.prototype,"graphicOrigin",void 0),e([y({type:String,clonable:!1,json:{origins:{service:{read:!1},"portal-item":{read:!1}},write:{ignoreOrigin:!0}}})],te.prototype,"id",void 0),e([y({readOnly:!0,json:{read:!1}})],te.prototype,"isTable",null),e([y({readOnly:!0,json:{read:!1}})],te.prototype,"geometryType",null),e([y({readOnly:!0,json:{read:!1}})],te.prototype,"globalIdField",null),e([y({readOnly:!0,json:{read:!1}})],te.prototype,"type",void 0),e([y(B(o(g)))],te.prototype,"labelsVisible",void 0),e([y({type:[A],json:{name:"layerDefinition.drawingInfo.labelingInfo",origins:{service:{read:!1}},read:{reader:E},write:{ignoreOrigin:!0,layerContainerTypes:m}}})],te.prototype,"labelingInfo",void 0),e([y({type:["ArcGISFeatureLayer"],readOnly:!0,json:{read:!1,write:{ignoreOrigin:!0,layerContainerTypes:m}}})],te.prototype,"layerType",void 0),e([y(B(o(v)))],te.prototype,"legendEnabled",void 0),e([y({type:["show","hide"]})],te.prototype,"listMode",void 0),e([y((()=>{const e=o(j);return e.json.origins.service.read=!1,B(e,{spatialOnly:!0})})())],te.prototype,"minScale",void 0),e([y((()=>{const e=o(w);return e.json.origins.service.read=!1,B(e,{spatialOnly:!0})})())],te.prototype,"maxScale",void 0),e([y({readOnly:!0})],te.prototype,"effectiveScaleRange",null),e([y({readOnly:!0,json:{read:!1}})],te.prototype,"objectIdField",null),e([y({type:Number,range:{min:0,max:1},nonNullable:!0,json:H({spatialOnly:!0})})],te.prototype,"opacity",void 0),e([y({clonable:!1})],te.prototype,"parent",void 0),e([y(B(o(F)))],te.prototype,"popupEnabled",void 0),e([y({type:t,json:H({name:"popupInfo"})})],te.prototype,"popupTemplate",void 0),e([y({readOnly:!0})],te.prototype,"defaultPopupTemplate",null),e([y({readOnly:!0,json:{read:!1}})],te.prototype,"relationships",null),e([y({types:x,json:H({target:"layerDefinition.drawingInfo.renderer",spatialOnly:!0})})],te.prototype,"renderer",null),e([M("service","renderer",["drawingInfo.renderer","subtypeField","type"])],te.prototype,"readRendererFromService",null),e([M("renderer",["layerDefinition.drawingInfo.renderer"])],te.prototype,"readRenderer",null),e([y({readOnly:!0,json:{read:!1}})],te.prototype,"spatialReference",null),e([y({type:Number,json:{origins:{service:{read:!1}},write:{ignoreOrigin:!0}}})],te.prototype,"subtypeCode",void 0),e([y({readOnly:!0,json:{read:!1}})],te.prototype,"subtypeField",null),e([y({type:[I],json:H({name:"layerDefinition.templates"})})],te.prototype,"templates",null),e([M("service","templates",["geometryType","subtypeField","subtypes","type"])],te.prototype,"readTemplatesFromService",null),e([y({type:String,json:H()})],te.prototype,"title",null),e([M("service","title",["subtypes"])],te.prototype,"readTitleFromService",null),e([y({readOnly:!0,json:{read:!1}})],te.prototype,"url",null),e([y({readOnly:!0})],te.prototype,"userHasUpdateItemPrivileges",null),e([y({type:Boolean,nonNullable:!0,json:H({name:"visibility",spatialOnly:!0})})],te.prototype,"visible",void 0),te=e([c("esri.layers.support.SubtypeSublayer")],te);const re=(e,t,r)=>{if(!r)return t.createQuery();const i=L.from(r);return i.where=ie(i.where,e.subtypeField,t.subtypeCode),i},ie=(e,t,r)=>{const i=new RegExp(`${t}\\s*=\\s*\\d+`),n=`${t}=${r}`,o=e??"";return i.test(o)?o.replace(i,n):u(n,o)},ne=e=>new i("subtype-sublayer:parent-missing",`This sublayer must have a parent SubtypeGroupLayer in order to use ${e}`);export{te as default};
2
+ import{__decorate as e}from"tslib";import t from"../../PopupTemplate.js";import{ClonableMixin as r}from"../../core/Clonable.js";import i from"../../core/Error.js";import{IdentifiableMixin as n}from"../../core/Identifiable.js";import{clone as o}from"../../core/lang.js";import{Loadable as s}from"../../core/Loadable.js";import l from"../../core/Logger.js";import{destroyMaybe as a}from"../../core/maybe.js";import{MultiOriginJSONSupportMixin as p}from"../../core/MultiOriginJSONSupport.js";import{setDeepValue as d}from"../../core/object.js";import{sqlAnd as u}from"../../core/sql.js";import{property as y,subclass as c}from"../../core/accessorSupport/decorators.js";import{excludeTables as m}from"../../core/accessorSupport/layerContainerType.js";import f from"../../form/FormTemplate.js";import h from"../../geometry/SpatialReference.js";import b from"../../graphic/SubtypeGroupGraphicOrigin.js";import{labelsVisible as g,legendEnabled as v,minScale as j,maxScale as w,popupEnabled as F}from"./commonProperties.js";import{createQuery as T,computeDomainFromSubtypes as O}from"./featureLayerUtils.js";import I from"./FeatureTemplate.js";import{defineFieldProperties as S}from"./fieldProperties.js";import{fixRendererFields as C}from"./fieldUtils.js";import A from"./LabelClass.js";import{reader as E}from"./labelingInfo.js";import{rendererReader as q,supportedRendererTypes as x}from"./subtypeGroupLayerUtils.js";import R from"./TitleCreator.js";import _ from"../../renderers/SimpleRenderer.js";import P from"../../rest/support/AttachmentQuery.js";import L from"../../rest/support/Query.js";import{createPopupTemplate as G}from"../../support/popupUtils.js";import{defaultPolygonSymbol2D as D,defaultPolylineSymbol2D as N,defaultPointSymbol2D as $}from"../../symbols/support/defaults.js";import U from"../../tables/AttributeTableTemplate.js";import{writer as V}from"../../core/accessorSupport/decorators/writer.js";import{reader as M}from"../../core/accessorSupport/decorators/reader.js";const Q=S();let k=0;function B(e,t){let r=e.json.write;return"object"!=typeof r&&(r=e.json.write={}),r.ignoreOrigin=!0,t?.spatialOnly&&(r.layerContainerTypes=m),e}function H(e){const t={write:{ignoreOrigin:!0}};return e?.name&&(t.name=e.name),"object"==typeof t.write&&(e?.spatialOnly&&(t.write.layerContainerTypes=m),e?.target&&(t.write.target=e.target)),t}function J(e){return new _({symbol:W(e)})}function W(e){switch(e){case"point":case"multipoint":return $.clone();case"polyline":return N.clone();case"polygon":case"multipatch":return D.clone();default:return null}}function z(e,t){return!!t&&("unique-value"===e?.type&&null!=e.field&&e.field.toLowerCase()===t.toLowerCase()&&!e.field2&&!e.field3&&!e.valueExpression)}function K(e){return Z(e,"user")===e}function X(e){return Z(e,"service")}function Y(e){return Z(e,"portal-item")}function Z(e,t){const r=e.parent?.getAtOrigin("sublayers",t);return r?.find(({subtypeCode:t})=>t===e.subtypeCode)}function ee(e,t){return null==e?null:t.subtypes?.find(t=>t.code===e)}function te(e,t){let r=null;switch(t.geometryType){case"esriGeometryPoint":case"esriGeometryMultipoint":r="point";break;case"esriGeometryPolyline":r="line";break;case"esriGeometryPolygon":case"esriGeometryMultiPatch":r="polygon";break;default:t.type,r=null}const i={},n=ee(e,t);if(null!=n){const{defaultValues:e}=n;for(const t in e)i[t]=e[t]}return i[t.subtypeField]=e,new I({name:"New Feature",drawingTool:r,prototype:{attributes:i}})}let re=class extends(p(r(n(s)))){constructor(e){super(e),this.attributeTableTemplate=null,this.charts=null,this.editingEnabled=!0,this.fieldOverrides=null,this.fieldsIndex=null,this.formTemplate=null,this.graphicOrigin=new b(this),this.id=`${Date.now().toString(16)}-subtype-sublayer-${k++}`,this.type="subtype-sublayer",this.labelsVisible=!0,this.labelingInfo=null,this.layerType="ArcGISFeatureLayer",this.legendEnabled=!0,this.listMode="show",this.minScale=0,this.maxScale=0,this.opacity=1,this.parent=null,this.popupEnabled=!0,this.popupTemplate=null,this.subtypeCode=null,this.visible=!0}load(e){return C(this.renderer,this.fieldsIndex),Promise.resolve(this)}get _titleCreator(){const e=this._get("_titleCreator");return a(e),new R({fieldsIndex:this.fieldsIndex,objectIdField:this.objectIdField,displayField:this.parent?.displayField??"",fields:this.fields,effectivePopupTemplate:this.popupTemplate??this.defaultPopupTemplate})}get capabilities(){return this.parent?.capabilities}get effectiveCapabilities(){return this.parent?.effectiveCapabilities}get effectiveEditingEnabled(){const{parent:e}=this;return e?e.effectiveEditingEnabled&&this.editingEnabled:this.editingEnabled}get elevationInfo(){return this.parent?.elevationInfo}get featureTitleFields(){return[...this._titleCreator.requiredFields]}writeFieldOverrides(e,t,r){const{fields:i,parent:n}=this;let s;if(i){s=[];let e=0;i.forEach(({name:t,alias:r,editable:i,visible:o})=>{if(!o)return;const l=n?.fields?.find(e=>e.name===t);if(!l)return;const a={name:t};let p=!1;r!==l.alias&&(a.alias=r,p=!0),i!==l.editable&&(a.editable=i,p=!0),s.push(a),p&&e++}),0===e&&s.length===i.length&&(s=null)}else s=o(e);s?.length&&d(r,s,t)}get fields(){const{parent:e,fieldOverrides:t,subtypeCode:r}=this,i=e?.fields;if(!e||!i?.length)return null;const{subtypes:n,subtypeField:o}=e,s=n?.find(e=>e.code===r),l=s?.defaultValues,a=s?.domains,p=[];for(const d of i){const e=d.clone(),{name:i}=e,n=t?.find(e=>e.name===i);if(e.visible=!t?.length||!!n,n){const{alias:t,editable:r}=n;t&&(e.alias=t),!1===r&&(e.editable=!1)}const s=l?.[i]??null;e.defaultValue=i===o?r:s;const u=a?.[i]??null;e.domain=i===o?null:u?"inherited"===u.type?e.domain:u.clone():null,p.push(e)}return p}get floorInfo(){return this.parent?.floorInfo}get isTable(){return!!this.parent?.isTable}get geometryType(){return this.parent?.geometryType}get globalIdField(){return this.parent?this.parent.globalIdField:(l.getLogger(this).error(oe("globalIdField")),null)}get effectiveScaleRange(){const{minScale:e,maxScale:t}=this;return{minScale:e,maxScale:t}}get objectIdField(){return this.parent||l.getLogger(this).error(oe("objectIdField")),this.parent?.objectIdField}get defaultPopupTemplate(){return this.createPopupTemplate()}get relationships(){return this.parent?.relationships}set renderer(e){C(e,this.fieldsIndex),this._override("renderer",e)}get renderer(){if(this._isOverridden("renderer"))return this._get("renderer");const{parent:e}=this;return e&&!e.isTable&&"mesh"!==e.geometryType?(K(this)?o(X(this)?.renderer):null)??J(e.geometryType):null}readRendererFromService(e,t,r){if("Table"===t.type)return null;const i=t.drawingInfo?.renderer,n=q(i,t,r);let o;const{subtypeCode:s}=this;if(null!=s&&z(n,t.subtypeField)){const e=n.uniqueValueInfos?.find(({value:e})=>(e="number"==typeof e?String(e):e)===String(s));e&&(o=new _({symbol:e.symbol}))}else"simple"!==n?.type||n.visualVariables?.length||(o=n);return o}readRenderer(e,t,r){const i=t?.layerDefinition?.drawingInfo?.renderer;if(i)return q(i,t,r)||void 0}get spatialReference(){return this.parent?.spatialReference??h.WGS84}get subtypeField(){return this.parent?.subtypeField}get templates(){return this._isOverridden("templates")?this._get("templates"):o(K(this)?X(this)?.templates:Y(this)?.templates||X(this)?.templates)}set templates(e){this._override("templates",e)}readTemplatesFromService(e,t){return[te(this.subtypeCode,t)]}get title(){if(this._isOverridden("title"))return this._get("title");const e=K(this)?X(this):null;return e?.title}set title(e){this._override("title",e)}readTitleFromService(e,t){const r=ee(this.subtypeCode,t);return null!=r?r.name:null}get url(){return this.parent?.url}get userHasUpdateItemPrivileges(){return!!this.parent?.userHasUpdateItemPrivileges}async addAttachment(e,t){const{parent:r}=this;if(!r)throw oe("addAttachment");if(e.getAttribute(r.subtypeField)!==this.subtypeCode)throw new i("subtype-sublayer:addAttachment","The feature provided does not belong to this SubtypeSublayer");return r.addAttachment(e,t)}async updateAttachment(e,t,r){const{parent:n}=this;if(!n)throw oe("updateAttachment");if(e.getAttribute(n.subtypeField)!==this.subtypeCode)throw new i("subtype-sublayer:updateAttachment","The feature provided does not belong to this SubtypeSublayer");return n.updateAttachment(e,t,r)}async deleteAttachments(e,t){const{parent:r}=this;if(!r)throw oe("deleteAttachments");if(e.getAttribute(r.subtypeField)!==this.subtypeCode)throw new i("subtype-sublayer:deleteAttachments","The feature provided does not belong to this SubtypeSublayer");return r.deleteAttachments(e,t)}async applyEdits(e,t){if(!this.parent)throw oe("applyEdits");return this.parent.applyEdits(e,t)}createPopupTemplate(e){let t=this;const{parent:r,fields:i,title:n}=this;if(r){const{displayField:e,editFieldsInfo:o,objectIdField:s}=r;t={displayField:e,editFieldsInfo:o,fields:i,objectIdField:s,title:n}}return G(t,e)}createQuery(){if(!this.parent)throw oe("createQuery");const e=T(this.parent),t=`${this.parent.subtypeField}=${this.subtypeCode}`;return e.where=u(t,this.parent.definitionExpression),e}getFeatureTitle(e,t){return this._titleCreator.getTitle(this,e,t)}getFeatureTitles(e,t){return this._titleCreator.getTitles(this,e,t)}getField(e){return this.fieldsIndex.get(e)}getFieldDomain(e,t){if(!t?.excludeImpliedDomains&&this.parent){const t=O(this.parent,e);if(t)return t}return this._getLayerDomain(e)}async queryAttachments(e,t){const r=await this.load();if(!r.parent)throw oe("queryAttachments");const i=e instanceof P?e.clone():new P(e);return i.where=ne(i.where,r.parent.subtypeField,r.subtypeCode),r.parent.queryAttachments(i,t)}async queryFeatureCount(e,t){const r=await this.load();if(!r.parent)throw oe("queryFeatureCount");return r.parent.queryFeatureCount(ie(r.parent,r,e),t)}async queryFeatures(e,t){const r=await this.load();if(!r.parent)throw oe("queryFeatures");return r.parent.queryFeatures(ie(r.parent,r,e),t)}async queryObjectIds(e,t){const r=await this.load();if(!r.parent)throw oe("queryObjectIds");return r.parent.queryObjectIds(ie(r.parent,r,e),t)}async queryRelatedFeatures(e,t){const r=await this.load();if(!r.parent)throw oe("queryRelatedFeatures");return r.parent.queryRelatedFeatures(e,t)}async queryRelatedFeaturesCount(e,t){const r=await this.load();if(!r.parent)throw oe("queryRelatedFeaturesCount");return r.parent.queryRelatedFeaturesCount(e,t)}_getLayerDomain(e){const t=this.fieldsIndex.get(e);return t?t.domain:null}};e([y({clonable:!1,readOnly:!0})],re.prototype,"_titleCreator",null),e([y({type:U,json:H({name:"attributeTableInfo"})})],re.prototype,"attributeTableTemplate",void 0),e([y({readOnly:!0,json:{read:!1}})],re.prototype,"capabilities",null),e([y({readOnly:!0,json:{read:!1}})],re.prototype,"effectiveCapabilities",null),e([y({json:H()})],re.prototype,"charts",void 0),e([y({type:Boolean,nonNullable:!0,json:H({name:"enableEditing"})})],re.prototype,"editingEnabled",void 0),e([y({type:Boolean,readOnly:!0})],re.prototype,"effectiveEditingEnabled",null),e([y({readOnly:!0,json:{read:!1}})],re.prototype,"elevationInfo",null),e([y({clonable:!1,readOnly:!0})],re.prototype,"featureTitleFields",null),e([y({json:{name:"layerDefinition.fieldOverrides",origins:{service:{read:!1}},write:{ignoreOrigin:!0,allowNull:!0}}})],re.prototype,"fieldOverrides",void 0),e([V("fieldOverrides")],re.prototype,"writeFieldOverrides",null),e([y({...Q.fields,readOnly:!0,json:{read:!1}})],re.prototype,"fields",null),e([y(Q.fieldsIndex)],re.prototype,"fieldsIndex",void 0),e([y({readOnly:!0,json:{read:!1}})],re.prototype,"floorInfo",null),e([y({type:f,json:H({name:"formInfo"})})],re.prototype,"formTemplate",void 0),e([y({readOnly:!0,clonable:!1})],re.prototype,"graphicOrigin",void 0),e([y({type:String,clonable:!1,json:{origins:{service:{read:!1},"portal-item":{read:!1}},write:{ignoreOrigin:!0}}})],re.prototype,"id",void 0),e([y({readOnly:!0,json:{read:!1}})],re.prototype,"isTable",null),e([y({readOnly:!0,json:{read:!1}})],re.prototype,"geometryType",null),e([y({readOnly:!0,json:{read:!1}})],re.prototype,"globalIdField",null),e([y({readOnly:!0,json:{read:!1}})],re.prototype,"type",void 0),e([y(B(o(g)))],re.prototype,"labelsVisible",void 0),e([y({type:[A],json:{name:"layerDefinition.drawingInfo.labelingInfo",origins:{service:{read:!1}},read:{reader:E},write:{ignoreOrigin:!0,layerContainerTypes:m}}})],re.prototype,"labelingInfo",void 0),e([y({type:["ArcGISFeatureLayer"],readOnly:!0,json:{read:!1,write:{ignoreOrigin:!0,layerContainerTypes:m}}})],re.prototype,"layerType",void 0),e([y(B(o(v)))],re.prototype,"legendEnabled",void 0),e([y({type:["show","hide"]})],re.prototype,"listMode",void 0),e([y((()=>{const e=o(j);return e.json.origins.service.read=!1,B(e,{spatialOnly:!0})})())],re.prototype,"minScale",void 0),e([y((()=>{const e=o(w);return e.json.origins.service.read=!1,B(e,{spatialOnly:!0})})())],re.prototype,"maxScale",void 0),e([y({readOnly:!0})],re.prototype,"effectiveScaleRange",null),e([y({readOnly:!0,json:{read:!1}})],re.prototype,"objectIdField",null),e([y({type:Number,range:{min:0,max:1},nonNullable:!0,json:H({spatialOnly:!0})})],re.prototype,"opacity",void 0),e([y({clonable:!1})],re.prototype,"parent",void 0),e([y(B(o(F)))],re.prototype,"popupEnabled",void 0),e([y({type:t,json:H({name:"popupInfo"})})],re.prototype,"popupTemplate",void 0),e([y({readOnly:!0})],re.prototype,"defaultPopupTemplate",null),e([y({readOnly:!0,json:{read:!1}})],re.prototype,"relationships",null),e([y({types:x,json:H({target:"layerDefinition.drawingInfo.renderer",spatialOnly:!0})})],re.prototype,"renderer",null),e([M("service","renderer",["drawingInfo.renderer","subtypeField","type"])],re.prototype,"readRendererFromService",null),e([M("renderer",["layerDefinition.drawingInfo.renderer"])],re.prototype,"readRenderer",null),e([y({readOnly:!0,json:{read:!1}})],re.prototype,"spatialReference",null),e([y({type:Number,json:{origins:{service:{read:!1}},write:{ignoreOrigin:!0}}})],re.prototype,"subtypeCode",void 0),e([y({readOnly:!0,json:{read:!1}})],re.prototype,"subtypeField",null),e([y({type:[I],json:H({name:"layerDefinition.templates"})})],re.prototype,"templates",null),e([M("service","templates",["geometryType","subtypeField","subtypes","type"])],re.prototype,"readTemplatesFromService",null),e([y({type:String,json:H()})],re.prototype,"title",null),e([M("service","title",["subtypes"])],re.prototype,"readTitleFromService",null),e([y({readOnly:!0,json:{read:!1}})],re.prototype,"url",null),e([y({readOnly:!0})],re.prototype,"userHasUpdateItemPrivileges",null),e([y({type:Boolean,nonNullable:!0,json:H({name:"visibility",spatialOnly:!0})})],re.prototype,"visible",void 0),re=e([c("esri.layers.support.SubtypeSublayer")],re);const ie=(e,t,r)=>{if(!r)return t.createQuery();const i=L.from(r);return i.where=ne(i.where,e.subtypeField,t.subtypeCode),i},ne=(e,t,r)=>{const i=new RegExp(`${t}\\s*=\\s*\\d+`),n=`${t}=${r}`,o=e??"";return i.test(o)?o.replace(i,n):u(n,o)},oe=e=>new i("subtype-sublayer:parent-missing",`This sublayer must have a parent SubtypeGroupLayer in order to use ${e}`);export{re as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{id as e}from"../../kernel.js";import t from"../../request.js";import n from"../../core/Collection.js";import"../../core/urlUtils.js";import{isLayerFromCatalog as r}from"../catalog/catalogUtils.js";import{isBasemap as i}from"../../support/userTypeGuards/isBasemap.js";function u(e){return d(e)||y(e)}function o(e){return null!=e&&"object"==typeof e&&"type"in e&&"feature"===e.type}function s(e){return null!=e&&"object"==typeof e&&"type"in e&&"graphics"===e.type}function c(e){return null!=e&&"object"==typeof e&&"type"in e&&"map-image"===e.type}function a(e){return null!=e&&"object"==typeof e&&"type"in e&&"map-notes"===e.type&&"sublayers"in e}function l(e){return null!=e&&"object"==typeof e&&"type"in e&&"knowledge-graph"===e.type&&"layers"in e}function f(e){return null!=e&&"object"==typeof e&&"type"in e&&"knowledge-graph-sublayer"===e.type}function p(e){return null!=e&&"object"==typeof e&&"type"in e&&"link-chart"===e.type&&"layers"in e}function y(e){return null!=e&&"object"==typeof e&&"type"in e&&"scene"===e.type}function g(e){return null!=e&&"object"==typeof e&&"type"in e&&"subtype-group"===e.type&&"sublayers"in e}function b(e){return"subtype-sublayer"===e?.type}function d(e){const t=e?.type;return"imagery-tile"===t||"tile"===t||"open-street-map"===t||"vector-tile"===t||"web-tile"===t||"wmts"===t}function m(e){const t=e?.type;return"base-tile"===t||"tile"===t||"elevation"===t||"imagery-tile"===t||"base-elevation"===t||"open-street-map"===t||"wcs"===t||"web-tile"===t||"wmts"===t||"vector-tile"===t}function h(e){return null!=e&&"type"in e&&"group"===e.type}const j={Point:"SceneLayer","3DObject":"SceneLayer",IntegratedMesh:"IntegratedMeshLayer",PointCloud:"PointCloudLayer",Building:"BuildingSceneLayer"};function v(e){const t=e?.type;return"building-scene"===t||"integrated-mesh"===t||"point-cloud"===t||"scene"===t}function w(e){return"integrated-mesh"===e.type||"integrated-mesh-3dtiles"===e.type}function L(e){return"integrated-mesh-3dtiles"===e.type}function S(e){return"voxel"===e?.type}function E(e){return"imagery-tile"===e?.type}function k(e,t){return i(e?.parent)&&e.parent[t].includes(e)}function C(e){return k(e,"baseLayers")}function x(e){return k(e,"referenceLayers")}function T(e){return"feature"===e?.type&&!e.url&&"memory"===e.source?.type}function U(e){const t=e?.type;return("feature"===t||"subtype-group"===t||"oriented-imagery"===t)&&"feature-layer"===e?.source?.type}function M(e){return"feature"===e?.type&&"feature-layer"===e.source?.type}function O(e){return o(e)&&M(e)}function P(e){const t=e?.type;return"binning"===t||"cluster"===t}function B(e,t){if(!O(e))return;const n=t?.graphic,r=e.featureReduction;if(n){if(n.isAggregate){const e=n.origin;return e&&("featureReductionProvider"in e&&r)?P(r)?r:null:void 0}return e}return t?.checkFeatureReduction&&r?P(r)?r:null:e}function I(e){const t=/[:;]/,n=[];let r=!1;if(e&&(e.forEach((e,i)=>{n.push([i,e]),!r&&t.test(e)&&(r=!0)}),n.length>0)){let e;if(r){const t={};n.forEach(e=>{t[e[0]]=e[1]}),e=JSON.stringify(t)}else{const t=[];n.forEach(e=>{t.push(e[0]+":"+e[1])}),e=t.join(";")}return e}return null}function R(e){if(!e)return;const t=[];return e.forEach((e,n)=>{t.push('"'+n+'":'+JSON.stringify(e))}),t.length?"{"+t.join(",")+"}":void 0}function q(e){if(e.activeLayer){const t=e.activeLayer.tileMatrixSet;if(t)return t;const n=e.activeLayer.tileMatrixSets;if(n)return n}return null}async function F(n,r){const i=e?.findServerInfo(n);if(null!=i?.currentVersion)return i.owningSystemUrl||null;const u=n.toLowerCase().indexOf("/rest/services");if(-1===u)return null;const o=`${n.slice(0,u)}/rest/info`,s=null!=r?r.signal:null,{data:c}=await t(o,{query:{f:"json"},responseType:"json",signal:s});return c?.owningSystemUrl||null}function J(e){if(!("capabilities"in e))return!1;switch(e.type){case"catalog":case"catalog-footprint":case"csv":case"feature":case"geojson":case"imagery":case"knowledge-graph-sublayer":case"ogc-feature":case"oriented-imagery":case"scene":case"sublayer":case"subtype-group":case"subtype-sublayer":case"wfs":return!0;default:return!1}}function N(e){return null!=e&&"object"==typeof e&&"isTable"in e&&!!e.isTable}function A(e){return J(e)?"effectiveCapabilities"in e?e.effectiveCapabilities:e.capabilities:null}function D(e){if(!("editingEnabled"in e))return!1;switch(e.type){case"csv":case"feature":case"geojson":case"oriented-imagery":case"scene":case"subtype-group":case"subtype-sublayer":case"knowledge-graph-sublayer":return!0;default:return!1}}function G(e){return!!D(e)&&("effectiveEditingEnabled"in e?e.effectiveEditingEnabled:e.editingEnabled)}function V(e){if(!e)return[];return("subtypes"in e?e.subtypes:g(e.parent)?e.parent.subtypes:[])??[]}function $(e){return("imagery"===e.type||"imagery-tile"===e.type)&&"flow"===e.renderer?.type}function z(e){const t=new n;for(const n of e.allLayers.concat(e.allTables))"csv"===n.type||r(n)||("charts"in n&&t.push(n),"subtype-group"===n.type&&t.push(...n.sublayers));return t}function H(e,t){return null}function K(e){return null}function Q(e){return!e||"Feature Service"===e.type&&!e.sourceUrl}function W(e,t){if(!t||!Q(e))return;const n=H(e.url);n&&(e.url=n)}export{W as applyPreferredHostToPortalItem,G as getEffectiveEditingEnabled,A as getEffectiveLayerCapabilities,B as getFieldConfigurationsContainer,z as getLayersWithChartSupport,F as getOwningPortalUrl,K as getPreferredHost,H as getPreferredUrl,V as getSubtypesFromLayer,q as getTileMaxtrixSetFromActiveLayer,C as isBaseLayer,u as isBasemap3DSupportedLayer,d as isBasemapSupportedTiledLayer,T as isFeatureCollectionLayer,o as isFeatureLayer,M as isFeatureServiceLayer,s as isGraphicsLayer,h as isGroupLayer,E as isImageryTileLayer,L as isIntegratedMesh3DTilesLayer,w as isIntegratedMeshLayer,l as isKnowledgeGraphLayer,f as isKnowledgeGraphSublayer,J as isLayerWithFeatureCapabilities,U as isLayerWithFeatureLayerSource,$ as isLayerWithFlowRenderer,p as isLinkChartLayer,c as isMapImageLayer,a as isMapNotesLayer,Q as isPreferredUrlApplicable,x as isReferenceLayer,y as isSceneLayer,v as isSceneServiceLayer,g as isSubtypeGroupLayer,b as isSubtypeSublayer,N as isTable,m as isTiledLayer,S as isVoxelLayer,j as sceneServiceLayerTypeToClassName,I as serializeLayerDefinitions,R as serializeTimeOptions,O as supportsFieldConfiguration};
2
+ import{id as e}from"../../kernel.js";import t from"../../request.js";import n from"../../core/Collection.js";import"../../core/urlUtils.js";import{isLayerFromCatalog as r}from"../catalog/catalogUtils.js";import{isBasemap as i}from"../../support/userTypeGuards/isBasemap.js";function u(e){return d(e)||y(e)}function o(e){return null!=e&&"object"==typeof e&&"type"in e&&"feature"===e.type}function s(e){return null!=e&&"object"==typeof e&&"type"in e&&"graphics"===e.type}function c(e){return null!=e&&"object"==typeof e&&"type"in e&&"map-image"===e.type}function a(e){return null!=e&&"object"==typeof e&&"type"in e&&"map-notes"===e.type&&"sublayers"in e}function l(e){return null!=e&&"object"==typeof e&&"type"in e&&"knowledge-graph"===e.type&&"layers"in e}function f(e){return null!=e&&"object"==typeof e&&"type"in e&&"knowledge-graph-sublayer"===e.type}function p(e){return null!=e&&"object"==typeof e&&"type"in e&&"link-chart"===e.type&&"layers"in e}function y(e){return null!=e&&"object"==typeof e&&"type"in e&&"scene"===e.type}function g(e){return null!=e&&"object"==typeof e&&"type"in e&&"subtype-group"===e.type&&"sublayers"in e}function b(e){return"subtype-sublayer"===e?.type}function d(e){const t=e?.type;return"imagery-tile"===t||"tile"===t||"open-street-map"===t||"vector-tile"===t||"web-tile"===t||"wmts"===t}function m(e){const t=e?.type;return"base-tile"===t||"tile"===t||"elevation"===t||"imagery-tile"===t||"base-elevation"===t||"open-street-map"===t||"wcs"===t||"web-tile"===t||"wmts"===t||"vector-tile"===t}function h(e){return null!=e&&"type"in e&&"group"===e.type}function j(e){const t=e.parent;return h(t)&&t.tables.includes(e)}const v={Point:"SceneLayer","3DObject":"SceneLayer",IntegratedMesh:"IntegratedMeshLayer",PointCloud:"PointCloudLayer",Building:"BuildingSceneLayer"};function w(e){const t=e?.type;return"building-scene"===t||"integrated-mesh"===t||"point-cloud"===t||"scene"===t}function L(e){return"integrated-mesh"===e.type||"integrated-mesh-3dtiles"===e.type}function S(e){return"integrated-mesh-3dtiles"===e.type}function E(e){return"voxel"===e?.type}function k(e){return"imagery-tile"===e?.type}function C(e,t){return i(e?.parent)&&e.parent[t].includes(e)}function x(e){return C(e,"baseLayers")}function T(e){return C(e,"referenceLayers")}function U(e){return"feature"===e?.type&&!e.url&&"memory"===e.source?.type}function M(e){const t=e?.type;return("feature"===t||"subtype-group"===t||"oriented-imagery"===t)&&"feature-layer"===e?.source?.type}function O(e){return"feature"===e?.type&&"feature-layer"===e.source?.type}function P(e){return o(e)&&O(e)}function B(e){const t=e?.type;return"binning"===t||"cluster"===t}function I(e,t){if(!P(e))return;const n=t?.graphic,r=e.featureReduction;if(n){if(n.isAggregate){const e=n.origin;return e&&("featureReductionProvider"in e&&r)?B(r)?r:null:void 0}return e}return t?.checkFeatureReduction&&r?B(r)?r:null:e}function R(e){const t=/[:;]/,n=[];let r=!1;if(e&&(e.forEach((e,i)=>{n.push([i,e]),!r&&t.test(e)&&(r=!0)}),n.length>0)){let e;if(r){const t={};n.forEach(e=>{t[e[0]]=e[1]}),e=JSON.stringify(t)}else{const t=[];n.forEach(e=>{t.push(e[0]+":"+e[1])}),e=t.join(";")}return e}return null}function q(e){if(!e)return;const t=[];return e.forEach((e,n)=>{t.push('"'+n+'":'+JSON.stringify(e))}),t.length?"{"+t.join(",")+"}":void 0}function F(e){if(e.activeLayer){const t=e.activeLayer.tileMatrixSet;if(t)return t;const n=e.activeLayer.tileMatrixSets;if(n)return n}return null}async function J(n,r){const i=e?.findServerInfo(n);if(null!=i?.currentVersion)return i.owningSystemUrl||null;const u=n.toLowerCase().indexOf("/rest/services");if(-1===u)return null;const o=`${n.slice(0,u)}/rest/info`,s=null!=r?r.signal:null,{data:c}=await t(o,{query:{f:"json"},responseType:"json",signal:s});return c?.owningSystemUrl||null}function N(e){if(!("capabilities"in e))return!1;switch(e.type){case"catalog":case"catalog-footprint":case"csv":case"feature":case"geojson":case"imagery":case"knowledge-graph-sublayer":case"ogc-feature":case"oriented-imagery":case"scene":case"sublayer":case"subtype-group":case"subtype-sublayer":case"wfs":return!0;default:return!1}}function A(e){return null!=e&&"object"==typeof e&&"isTable"in e&&!!e.isTable}function D(e){return N(e)?"effectiveCapabilities"in e?e.effectiveCapabilities:e.capabilities:null}function G(e){if(!("editingEnabled"in e))return!1;switch(e.type){case"csv":case"feature":case"geojson":case"oriented-imagery":case"scene":case"subtype-group":case"subtype-sublayer":case"knowledge-graph-sublayer":return!0;default:return!1}}function V(e){return!!G(e)&&("effectiveEditingEnabled"in e?e.effectiveEditingEnabled:e.editingEnabled)}function $(e){if(!e)return[];return("subtypes"in e?e.subtypes:g(e.parent)?e.parent.subtypes:[])??[]}function z(e){return("imagery"===e.type||"imagery-tile"===e.type)&&"flow"===e.renderer?.type}function H(e){const t=new n;for(const n of e.allLayers.concat(e.allTables))r(n)||j(n)||("charts"in n&&t.push(n),"subtype-group"===n.type&&t.push(...n.sublayers));return t}function K(e,t){return null}function Q(e){return null}function W(e){return!e||"Feature Service"===e.type&&!e.sourceUrl}function X(e,t){if(!t||!W(e))return;const n=K(e.url);n&&(e.url=n)}export{X as applyPreferredHostToPortalItem,V as getEffectiveEditingEnabled,D as getEffectiveLayerCapabilities,I as getFieldConfigurationsContainer,H as getLayersWithChartSupport,J as getOwningPortalUrl,Q as getPreferredHost,K as getPreferredUrl,$ as getSubtypesFromLayer,F as getTileMaxtrixSetFromActiveLayer,x as isBaseLayer,u as isBasemap3DSupportedLayer,d as isBasemapSupportedTiledLayer,U as isFeatureCollectionLayer,o as isFeatureLayer,O as isFeatureServiceLayer,s as isGraphicsLayer,h as isGroupLayer,k as isImageryTileLayer,S as isIntegratedMesh3DTilesLayer,L as isIntegratedMeshLayer,l as isKnowledgeGraphLayer,f as isKnowledgeGraphSublayer,N as isLayerWithFeatureCapabilities,M as isLayerWithFeatureLayerSource,z as isLayerWithFlowRenderer,p as isLinkChartLayer,c as isMapImageLayer,a as isMapNotesLayer,W as isPreferredUrlApplicable,T as isReferenceLayer,y as isSceneLayer,w as isSceneServiceLayer,g as isSubtypeGroupLayer,b as isSubtypeSublayer,A as isTable,m as isTiledLayer,E as isVoxelLayer,v as sceneServiceLayerTypeToClassName,R as serializeLayerDefinitions,q as serializeTimeOptions,P as supportsFieldConfiguration};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/core",
3
- "version": "5.1.0-next.44",
3
+ "version": "5.1.0-next.45",
4
4
  "homepage": "https://js.arcgis.com",
5
5
  "description": "ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API",
6
6
  "keywords": [
@@ -19,7 +19,7 @@
19
19
  "license": "SEE LICENSE IN LICENSE.md",
20
20
  "dependencies": {
21
21
  "@amcharts/amcharts5": "~5.16.1",
22
- "@arcgis/toolkit": "^5.1.0-next.44",
22
+ "@arcgis/toolkit": "^5.1.0-next.45",
23
23
  "@esri/arcgis-html-sanitizer": "~4.1.0",
24
24
  "@esri/calcite-components": "^5.0.2",
25
25
  "@vaadin/grid": "~25.0.8",
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import r from"../../../core/Logger.js";function t(r){return class{constructor(){for(const t of r)this[t]=null}}}function e(r,t=1){const{transform:e,hasZ:o,hasM:s}=r;if(null==e)return o&&1!==t?r=>{r[2]*=t}:null;const[i,u]=n(e,o,s,t),f=r.hasZ?3:2;return r=>{for(let t=0;t<r.length&&(t!==f||0!==r[t]);++t)r[t]=r[t]*i[t]+u[t]}}function n(r,t,e,n){let{scale:o,translate:s,originPosition:i}=r;return"upperLeft"===i&&(o=o.map((r,t)=>1===t?-r:r)),t&&(o=o.map((r,t)=>2===t?r*n:r)),!t&&e&&(o=o.filter((r,t)=>2!==t),s=s.filter((r,t)=>2!==t)),[o,s]}function o(){return r.getLogger("esri.rest.query.operations.pbfFeatureServiceParser")}export{o as getLogger,t as makeAttributesClass,e as makeVertexTransformer};
2
+ import r from"../../../core/Logger.js";function t(r){return class{constructor(){for(const t of r)this[t]=null}}}function e(r,t=1){const{transform:e,hasZ:o,hasM:s}=r;if(null==e)return o&&1!==t?r=>{r[2]*=t}:null;const[i,u]=n(e,o,s,t),a=r.hasZ?3:2;return r=>{for(let t=0;t<r.length&&(t!==a||0!==r[t]);++t)r[t]=r[t]*i[t]+u[t]}}function n(r,t,e,n){let{scale:o,translate:s,originPosition:i}=r;return"upperLeft"===i&&(o=o.map((r,t)=>1===t?-r:r)),t&&(o=o.map((r,t)=>2===t?r*n:r),s=s.map((r,t)=>2===t?r*n:r)),!t&&e&&(o=o.filter((r,t)=>2!==t),s=s.filter((r,t)=>2!==t)),[o,s]}function o(){return r.getLogger("esri.rest.query.operations.pbfFeatureServiceParser")}export{o as getLogger,t as makeAttributesClass,e as makeVertexTransformer};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{allocateFlatGeometry as t,writeBezierCurveSegment as e,writeCircularArcSegment as s,writeEllipticArc7Segment as r}from"../../../geometry/FlatGeometry.js";import{featureGeometryTypeKebabDictionary as i}from"../../../geometry/support/typeUtils.js";import{zScale as h}from"../../../geometry/support/zscale.js";import{FlatFeature as o}from"../../../layers/graphics/FlatFeature.js";import{FlatFeatureSet as a}from"../../../layers/graphics/FlatFeatureSet.js";import _ from"../../../layers/graphics/OptimizedGeometry.js";import{createFeatureId as n}from"../../../layers/graphics/data/createFeatureId.js";import{makeAttributesClass as f,makeVertexTransformer as m}from"./pbfFeatureSetUtils.js";class u{constructor(t){this._options=t,this.featureSet=new a,this.parseOnly=null,this._idInfo=null,this._transformInPlace=null,this._transformInPlaceXY=null,this._push=u._pushXY,this._attributesClass=null,this._previousX=0,this._previousY=0,this._vertex=[],this._i=0,this._geometry=null,this._iVertex=0,this._iPart=0,this._isPolygon=!1,this._ringEndsAt=-1}queryGeometryType(){return this.featureSet.queryGeometryType}queryGeometry(){return this.featureSet.queryGeometry}idField(t){"string"==typeof t?this._idInfo??={type:"object-id",fieldName:t}:this._idInfo={type:"unique-id-simple",fieldName:t.name}}finish(){if(this._idInfo)for(const s of this.featureSet.features)s.objectId=n(s,this._idInfo);const{spatialReference:t,features:e}=this.featureSet;if(t)for(const{geometry:s}of e)s&&(s.spatialReference=t);this.featureSet.transform=null}feature(){this._attributesClass??=f(this.featureSet.fields?.map(t=>t.name)??[]),this.featureSet.features.push(new o(null,new this._attributesClass,null,0)),this._setVertexTransformer()}centroid(t){const{hasZ:e,hasM:s}=this.featureSet;this.featureSet.features.at(-1).centroid=new _([],t,e,s)}geometry(e,s,r){this._previousX=this._previousY=0,this._i=this._iVertex=this._iPart=0;let{hasZ:h,hasM:o}=this.featureSet;h??=!1,o??=!1,this._vertex=[0,0],h&&this._vertex.push(0),o&&this._vertex.push(0);const a=i.fromJSON(s);this._isPolygon="polygon"===a;const _=Number(this._isPolygon),n="point"===a?1:r.reduce((t,e)=>t+e-_,0),f=r.length;if(this._geometry=t(a,n,f,h,o,!1),this._push=h?o?u._pushXYZM:u._pushXYZ:o?u._pushXYM:u._pushXY,this._geometry.isMultipart()){this._geometry.partOffsets[0]=0;for(let t=0;t<f;++t)this._geometry.partOffsets[t+1]=this._geometry.partOffsets[t]+r[t]-_}this._ringEndsAt=_?this._geometry.partOffsets.at(1)??0:-1,1===e?(this.featureSet.queryGeometry=this._geometry,this.featureSet.queryGeometryType=s):this.featureSet.features.at(-1).geometry=this._geometry}coord(t){const e=this._vertex;e[this._i++]=t,this._i<e.length||(this._i=0,e[0]+=this._previousX,e[1]+=this._previousY,[this._previousX,this._previousY]=e,this._iVertex===this._ringEndsAt&&(++this._iPart,this._ringEndsAt=this._geometry.partOffsets[this._iPart+1],this._previousX=this._previousY=0,this._isPolygon)||(this._transformInPlace?.(e),this._push(this)))}curvedGeometry(e,s,r,h){let{hasZ:o,hasM:a}=this.featureSet;o??=!1,a??=!1,this._i=this._iVertex=this._iPart=0;const _=i.fromJSON(e);this._isPolygon="polygon"===_;const n=Number(!this._isPolygon),f=s.length;let m=0,u=0,l=n*f;for(let t=0;t<r.length;++t)switch(l+=h[t],r[t]){case 1:case 3:m+=h[t];continue;case 2:u+=h[t]}this._geometry=t(_,l,f,o,a,!0,m,u);const{partOffsets:p}=this._geometry;p[0]=0;for(let t=0,i=0;t<f;++t){p[t+1]=p[t]+n;for(let e=0;e<s[t];++e)p[t+1]+=h[i++]}switch(e){case"esriGeometryPoint":case"esriGeometryMultipoint":throw new Error(`Curved ${e} does not make sense`)}this.featureSet.features.at(-1).geometry=this._geometry}startCurvedPart(t){}finishCurvedPart(t){this._isPolygon||(this._transform(t,this._vertex),this._push(this)),++this._iPart}lineSegment(t,e){this._transform(t,this._vertex),this._push(this)}bezierSegment(t,s,r,i){this._transform(t,this._vertex),this._push(this),this._transformXY(s,y.b[0]),this._transformXY(r,y.b[1]),this._transformXY(i,y.b[2]),this._i=e(this._vertex,y,this._geometry,this._iVertex-1,this._i)}circularArcSegment(t,e,r){this._transform(t,this._vertex),this._push(this),this._transformXY(e,l.c[0]),this._transformXY(r,l.c[1]),this._i=s(this._vertex,l,this._geometry,this._iVertex-1,this._i)}ellipticArcSegment(t,e,s,i,h,o,a,_){this._transform(t,this._vertex),this._push(this),this._transformXY(e,p.a[0]),this._transformXY(s,p.a[1]),p.a[2]=i,p.a[3]=h,p.a[4]=o,p.a[5]=a,p.a[6]=_,this._i=r(this._vertex,p,this._geometry,this._iVertex-1,this._i)}static _pushXY(t){const e=t._iVertex++,{vertexXY:s}=t._geometry;[s[2*e],s[2*e+1]]=t._vertex}static _pushXYZ(t){const e=t._iVertex++,{vertexXY:s,vertexZ:r}=t._geometry;[s[2*e],s[2*e+1],r[e]]=t._vertex}static _pushXYM(t){const e=t._iVertex++,{vertexXY:s,vertexM:r}=t._geometry;[s[2*e],s[2*e+1],r[e]]=t._vertex}static _pushXYZM(t){const e=t._iVertex++,{vertexXY:s,vertexM:r,vertexZ:i}=t._geometry;[s[2*e],s[2*e+1],i[e],r[e]]=t._vertex}_setVertexTransformer(){const{sourceSpatialReference:t}=this._options,{spatialReference:e,hasZ:s,transform:r}=this.featureSet,i=s?h(t,e):1;this._transformInPlace??=m(this.featureSet,i),this._transformInPlaceXY??=m({transform:r})}_transform(t,e){for(let s=0;s<t.length;++s)e[s]=t[s];this._transformInPlace?.(e)}_transformXY(t,e){e[0]=t[0],e[1]=t[1],this._transformInPlaceXY?.(e)}}const l={c:[[0,0],[0,0]]},p={a:[[0,0],[0,0],0,0,0,0,0]},y={b:[[0,0],[0,0],[0,0]]};export{u as FlatFeatureSetParserContext};
2
+ import{allocateFlatGeometry as t,writeBezierCurveSegment as e,writeCircularArcSegment as s,writeEllipticArc7Segment as r}from"../../../geometry/FlatGeometry.js";import{featureGeometryTypeKebabDictionary as i}from"../../../geometry/support/typeUtils.js";import{zScale as h}from"../../../geometry/support/zscale.js";import{FlatFeature as o}from"../../../layers/graphics/FlatFeature.js";import{FlatFeatureSet as a}from"../../../layers/graphics/FlatFeatureSet.js";import _ from"../../../layers/graphics/OptimizedGeometry.js";import{createFeatureId as n}from"../../../layers/graphics/data/createFeatureId.js";import{makeAttributesClass as f,makeVertexTransformer as m}from"./pbfFeatureSetUtils.js";class u{constructor(t){this._options=t,this.featureSet=new a,this.parseOnly=null,this._idInfo=null,this._transformInPlace=null,this._transformInPlaceXY=null,this._push=u._pushXY,this._attributesClass=null,this._previousX=0,this._previousY=0,this._vertex=[],this._i=0,this._geometry=null,this._iVertex=0,this._iPart=0,this._isPolygon=!1,this._ringEndsAt=-1}queryGeometryType(){return this.featureSet.queryGeometryType}queryGeometry(){return this.featureSet.queryGeometry}idField(t){"string"==typeof t?this._idInfo??={type:"object-id",fieldName:t}:this._idInfo={type:"unique-id-simple",fieldName:t.name}}finish(){if(this._idInfo)for(const s of this.featureSet.features)s.objectId=n(s,this._idInfo);const{spatialReference:t,features:e}=this.featureSet;if(t)for(const{geometry:s}of e)s&&(s.spatialReference=t);this.featureSet.transform=null}feature(){this._attributesClass??=f(this.featureSet.fields?.map(t=>t.name)??[]),this.featureSet.features.push(new o(null,new this._attributesClass,null,0)),this._setVertexTransformer()}centroid(t){const{hasZ:e,hasM:s}=this.featureSet;this.featureSet.features.at(-1).centroid=new _([],t,e,s)}geometry(e,s,r){this._previousX=this._previousY=0,this._i=this._iVertex=this._iPart=0;let{hasZ:h,hasM:o}=this.featureSet;h??=!1,o??=!1,this._vertex=[0,0],h&&this._vertex.push(0),o&&this._vertex.push(0);const a=i.fromJSON(s);this._isPolygon="polygon"===a;const _=Number(this._isPolygon),n="point"===a?1:r.reduce((t,e)=>t+e-_,0),f="point"===a?0:r.length;if(this._geometry=t(a,n,f,h,o,!1),this._push=h?o?u._pushXYZM:u._pushXYZ:o?u._pushXYM:u._pushXY,this._geometry.isMultipart()){this._geometry.partOffsets[0]=0;for(let t=0;t<f;++t)this._geometry.partOffsets[t+1]=this._geometry.partOffsets[t]+r[t]-_}this._ringEndsAt=_?this._geometry.partOffsets.at(1)??0:-1,1===e?(this.featureSet.queryGeometry=this._geometry,this.featureSet.queryGeometryType=s):this.featureSet.features.at(-1).geometry=this._geometry}coord(t){const e=this._vertex;e[this._i++]=t,this._i<e.length||(this._i=0,e[0]+=this._previousX,e[1]+=this._previousY,[this._previousX,this._previousY]=e,this._iVertex===this._ringEndsAt&&(++this._iPart,this._ringEndsAt=this._geometry.partOffsets[this._iPart+1],this._previousX=this._previousY=0,this._isPolygon)||(this._transformInPlace?.(e),this._push(this)))}curvedGeometry(e,s,r,h){let{hasZ:o,hasM:a}=this.featureSet;o??=!1,a??=!1,this._i=this._iVertex=this._iPart=0;const _=i.fromJSON(e);this._isPolygon="polygon"===_;const n=Number(!this._isPolygon),f=s.length;let m=0,u=0,p=n*f;for(let t=0;t<r.length;++t)switch(p+=h[t],r[t]){case 1:case 3:m+=h[t];continue;case 2:u+=h[t]}this._geometry=t(_,p,f,o,a,!0,m,u);const{partOffsets:l}=this._geometry;l[0]=0;for(let t=0,i=0;t<f;++t){l[t+1]=l[t]+n;for(let e=0;e<s[t];++e)l[t+1]+=h[i++]}switch(e){case"esriGeometryPoint":case"esriGeometryMultipoint":throw new Error(`Curved ${e} does not make sense`)}this.featureSet.features.at(-1).geometry=this._geometry}startCurvedPart(t){}finishCurvedPart(t){this._isPolygon||(this._transform(t,this._vertex),this._push(this)),++this._iPart}lineSegment(t,e){this._transform(t,this._vertex),this._push(this)}bezierSegment(t,s,r,i){this._transform(t,this._vertex),this._push(this),this._transformXY(s,y.b[0]),this._transformXY(r,y.b[1]),this._transformXY(i,y.b[2]),this._i=e(this._vertex,y,this._geometry,this._iVertex-1,this._i)}circularArcSegment(t,e,r){this._transform(t,this._vertex),this._push(this),this._transformXY(e,p.c[0]),this._transformXY(r,p.c[1]),this._i=s(this._vertex,p,this._geometry,this._iVertex-1,this._i)}ellipticArcSegment(t,e,s,i,h,o,a,_){this._transform(t,this._vertex),this._push(this),this._transformXY(e,l.a[0]),this._transformXY(s,l.a[1]),l.a[2]=i,l.a[3]=h,l.a[4]=o,l.a[5]=a,l.a[6]=_,this._i=r(this._vertex,l,this._geometry,this._iVertex-1,this._i)}static _pushXY(t){const e=t._iVertex++,{vertexXY:s}=t._geometry;[s[2*e],s[2*e+1]]=t._vertex}static _pushXYZ(t){const e=t._iVertex++,{vertexXY:s,vertexZ:r}=t._geometry;[s[2*e],s[2*e+1],r[e]]=t._vertex}static _pushXYM(t){const e=t._iVertex++,{vertexXY:s,vertexM:r}=t._geometry;[s[2*e],s[2*e+1],r[e]]=t._vertex}static _pushXYZM(t){const e=t._iVertex++,{vertexXY:s,vertexM:r,vertexZ:i}=t._geometry;[s[2*e],s[2*e+1],i[e],r[e]]=t._vertex}_setVertexTransformer(){const{sourceSpatialReference:t}=this._options,{spatialReference:e,hasZ:s,transform:r}=this.featureSet,i=s?h(t,e):1;this._transformInPlace??=m(this.featureSet,i),this._transformInPlaceXY??=m({transform:r})}_transform(t,e){for(let s=0;s<t.length;++s)e[s]=t[s];this._transformInPlace?.(e)}_transformXY(t,e){e[0]=t[0],e[1]=t[1],this._transformInPlaceXY?.(e)}}const p={c:[[0,0],[0,0]]},l={a:[[0,0],[0,0],0,0,0,0,0]},y={b:[[0,0],[0,0],[0,0]]};export{u as FlatFeatureSetParserContext};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{zScale as e}from"../../../geometry/support/zscale.js";import{OptimizedFeature as t}from"../../../layers/graphics/OptimizedFeature.js";import r from"../../../layers/graphics/OptimizedFeatureSet.js";import s from"../../../layers/graphics/OptimizedGeometry.js";import{createFeatureId as i}from"../../../layers/graphics/data/createFeatureId.js";class o{constructor(e){this._options=e,this.featureSet=new r,this.parseOnly=null,this._idInfo=null,this._coords=null}queryGeometryType(){return this.featureSet.queryGeometryType}queryGeometry(){return this.featureSet.queryGeometry}idField(e){"string"==typeof e?this._idInfo??={type:"object-id",fieldName:e}:this._idInfo={type:"unique-id-simple",fieldName:e.name}}finish(){if(this._idInfo)for(const e of this.featureSet.features)e.objectId=i(e,this._idInfo);const{hasZ:t,hasM:r,spatialReference:s}=this.featureSet,{sourceSpatialReference:o}=this._options,a=t?e(o,s):1;if(1!==a){const e=2+Number(t)+Number(r);for(let t=2;t<this._coords.length;t+=e)this._coords[t]*=a}}feature(){this.featureSet.features.push(new t(null,{},null,0))}centroid(e){const{hasZ:t,hasM:r}=this.featureSet;this.featureSet.features.at(-1).centroid=new s([],e,t,r)}geometry(e,t,r){this._coords=[];const{hasZ:i,hasM:o}=this.featureSet,a=new s(r,this._coords,i,o);return 1===e?(this.featureSet.queryGeometry=a,this.featureSet.queryGeometryType=t):this.featureSet.features.at(-1).geometry=a,0}coord(e){this._coords?.push(e)}}export{o as OptimizedFeatureSetParserContext};
2
+ import{zScale as e}from"../../../geometry/support/zscale.js";import{OptimizedFeature as t}from"../../../layers/graphics/OptimizedFeature.js";import r from"../../../layers/graphics/OptimizedFeatureSet.js";import s from"../../../layers/graphics/OptimizedGeometry.js";import{createFeatureId as i}from"../../../layers/graphics/data/createFeatureId.js";class o{constructor(e){this._options=e,this.featureSet=new r,this.parseOnly=null,this._idInfo=null,this._coords=null}queryGeometryType(){return this.featureSet.queryGeometryType}queryGeometry(){return this.featureSet.queryGeometry}idField(e){"string"==typeof e?this._idInfo??={type:"object-id",fieldName:e}:this._idInfo={type:"unique-id-simple",fieldName:e.name}}finish(){if(this._idInfo)for(const e of this.featureSet.features)e.objectId=i(e,this._idInfo);const{hasZ:t,hasM:r,spatialReference:s}=this.featureSet,{sourceSpatialReference:o}=this._options,a=t?e(o,s):1;if(1!==a){const e=2+Number(t)+Number(r);for(let t=2;t<this._coords.length;t+=e)this._coords[t]*=a}}feature(){this.featureSet.features.push(new t(null,{},null,0))}centroid(e){const{hasZ:t,hasM:r}=this.featureSet;this.featureSet.features.at(-1).centroid=new s([],e,t,r)}geometry(e,t,r){this._coords=[];const{hasZ:i,hasM:o}=this.featureSet;"esriGeometryPoint"===t&&(r=[]);const a=new s(r,this._coords,i,o);if(1===e?(this.featureSet.queryGeometry=a,this.featureSet.queryGeometryType=t):this.featureSet.features.at(-1).geometry=a,"esriGeometryPoint"!==t)return 0}coord(e){this._coords?.push(e)}}export{o as OptimizedFeatureSetParserContext};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- const a="20260317",e="0ef336ad8d94307d964a50ef0b09a6a67e60a207";export{a as buildDate,e as commitHash};
2
+ const a="20260318",b="c521ba44d274f2808cd0f9680a053a6a59aba7b2";export{a as buildDate,b as commitHash};
@@ -1091,7 +1091,7 @@ IN THE SOFTWARE.
1091
1091
 
1092
1092
  --------------------------------------------------------------------------------
1093
1093
 
1094
- esri/layers/rasterFormats/Jpg.js
1094
+ esri/layers/rasterFormats/Jpg.mjs
1095
1095
 
1096
1096
  Extracted from pdf.js project.
1097
1097
  pdf.js: A general-purpose, web standards-based platform for parsing and rendering PDFs.
@@ -1254,7 +1254,7 @@ You may obtain a copy of the License at
1254
1254
 
1255
1255
  -------------------------------------------------------------------------------
1256
1256
 
1257
- esri/layers/rasterFormats/Zlib.js
1257
+ esri/layers/rasterFormats/Zlib.mjs
1258
1258
 
1259
1259
  Extracted from png.js project
1260
1260
  png.js: A (animated) PNG decoder in JavaScript for the HTML5 canvas element and Node.js.
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{EventEmitter as e}from"../../../core/Evented.js";import{on as t}from"../../../core/events.js";import{handlesGroup as a}from"../../../core/handleUtils.js";import has from"../../../core/has.js";import{deg2rad as s}from"../../../core/mathUtils.js";import{identity as r,scale as n,rotate as i,translate as o}from"../../../core/libs/gl-matrix-2/math/mat2d.js";import{create as h}from"../../../core/libs/gl-matrix-2/factories/mat2df64.js";class c{constructor(s,r={}){this.events=new e,this._hasMajorPerformanceCaveat=!1,this._lastRenderFrameCounter=0,null!=s?(this._canvas=document.createElement("canvas"),this._canvas.setAttribute("style","width: 100%; height:100%; display:block; willChange:transform"),s.contains(this._canvas)||s.appendChild(this._canvas)):null!=r.canvas&&(this._canvas=r.canvas);const n={failIfMajorPerformanceCaveat:!0,alpha:!0,antialias:!1,depth:!0,stencil:!0,powerPreference:"high-performance"};let i=this._canvas.getContext("webgl2",n);i||(i=this._canvas.getContext("webgl2",{...n,failIfMajorPerformanceCaveat:!1}),this._hasMajorPerformanceCaveat=!0),this._gl=i,this._handles=a([t(this._canvas,"webglcontextlost",e=>this.events.emit("webgl-context-lost",e))])}destroy(){this._canvas.remove(),this._canvas=null,this._handles.remove(),this._gl=null}get gl(){return this._gl}get canvas(){return this._canvas}render(e,t){if(this._hasMajorPerformanceCaveat||has("esri-force-performance-mode")){if(++this._lastRenderFrameCounter>=has("esri-performance-mode-frames-between-render")&&(t(),this._lastRenderViewState=e.state.clone(),this._lastRenderFrameCounter=0),this._lastRenderViewState){const[t,a,s,r,n,i]=this._computeViewTransform(this._lastRenderViewState,e.state);this._canvas.style.transform=`matrix(${t}, ${a}, ${s}, ${r}, ${n}, ${i})`}}else t()}resize(e){const t=this._canvas,a=t.style,{state:{size:s},pixelRatio:r}=e,n=s[0],i=s[1],o=Math.round(n*r),h=Math.round(i*r);t.width===o&&t.height===h||(t.width=o,t.height=h),a.width=n+"px",a.height=i+"px"}_computeViewTransform(e,t){const[a,c]=e.center,[l,m]=t.center,[f,_]=e.toScreen([0,0],l,m),[d,v]=e.toScreen([0,0],a,c),p=d-f,g=v-_,u=e.scale/t.scale,w=t.rotation-e.rotation,j=h();return r(j),n(j,j,[u,u]),i(j,j,s(w)),o(j,j,[p,g]),j}}export{c as ManagedCanvas};
2
+ import{EventEmitter as e}from"../../../core/Evented.js";import{on as t}from"../../../core/events.js";import{handlesGroup as a}from"../../../core/handleUtils.js";import has from"../../../core/has.js";import{deg2rad as s}from"../../../core/mathUtils.js";import{identity as r,scale as n,rotate as i,translate as o}from"../../../core/libs/gl-matrix-2/math/mat2d.js";import{create as h}from"../../../core/libs/gl-matrix-2/factories/mat2df64.js";class c{constructor(s,r={}){this.events=new e,this._hasMajorPerformanceCaveat=!1,this._lastRenderFrameCounter=0,null!=s?(this._canvas=document.createElement("canvas"),this._canvas.setAttribute("style","width: 100%; height:100%; display:block; willChange:transform"),s.contains(this._canvas)||s.appendChild(this._canvas)):null!=r.canvas&&(this._canvas=r.canvas);const n={failIfMajorPerformanceCaveat:!0,alpha:!0,antialias:!1,depth:!0,stencil:!0,powerPreference:"high-performance"};let i=this._canvas.getContext("webgl2",n);i||(i=this._canvas.getContext("webgl2",{...n,failIfMajorPerformanceCaveat:!1}),this._hasMajorPerformanceCaveat=!0,has.add("mapview-transitions-duration",0,!0,!0)),this._gl=i,this._handles=a([t(this._canvas,"webglcontextlost",e=>this.events.emit("webgl-context-lost",e))])}destroy(){this._canvas.remove(),this._canvas=null,this._handles.remove(),this._gl=null}get gl(){return this._gl}get canvas(){return this._canvas}render(e,t){if(this._hasMajorPerformanceCaveat||has("esri-force-performance-mode")){if(++this._lastRenderFrameCounter>=has("esri-performance-mode-frames-between-render")&&(t(),this._lastRenderViewState=e.state.clone(),this._lastRenderFrameCounter=0),this._lastRenderViewState){const[t,a,s,r,n,i]=this._computeViewTransform(this._lastRenderViewState,e.state);this._canvas.style.transform=`matrix(${t}, ${a}, ${s}, ${r}, ${n}, ${i})`}}else t()}resize(e){const t=this._canvas,a=t.style,{state:{size:s},pixelRatio:r}=e,n=s[0],i=s[1],o=Math.round(n*r),h=Math.round(i*r);t.width===o&&t.height===h||(t.width=o,t.height=h),a.width=n+"px",a.height=i+"px"}_computeViewTransform(e,t){const[a,c]=e.center,[l,m]=t.center,[d,f]=e.toScreen([0,0],l,m),[v,_]=e.toScreen([0,0],a,c),p=v-d,g=_-f,u=e.scale/t.scale,w=t.rotation-e.rotation,j=h();return r(j),n(j,j,[u,u]),i(j,j,s(w)),o(j,j,[p,g]),j}}export{c as ManagedCanvas};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{RenderingDevice as e}from"../webgl/RenderingDevice.js";import{simplePipelineState as t}from"../webgl/shaderGraph/utils.js";import{VTLTechniquesRepo as i}from"../webgl/shaderGraph/techniques/vectorTiles/VTLTechniques.js";const s=1e-6;class n{constructor(s,n){this.spriteMosaic=s,this.glyphMosaic=n,this._vtlTechniques=new i,this._context=null,this._vtlTechniques.startup(),this._renderingDevice=new e,this._pipelineState=t}dispose(){this._vtlTechniques&&this._vtlTechniques.shutdown(this._context),this.spriteMosaic.dispose(),this.glyphMosaic.dispose(),this._renderingDevice.dispose(),this._context=null}drawSymbols(e,t,i){const n=i.layers;e.renderPass="translucent";const a=this._vtlTechniques.getTechnique(3);r[0]=t;for(let l=0;l<n.length;l++){const t=n[l];if(3!==t.type)continue;const i=t.getLayoutProperty("visibility");if(i&&1===i.getValue())continue;const o=e.displayLevel;void 0!==t.minzoom&&t.minzoom>o+s||void 0!==t.maxzoom&&t.maxzoom<=o-s||(e.styleLayerUID=t.uid,e.styleLayer=t,a.render(e,{tiles:r}))}r[0]=null}drawBackground(e,t,i){if(0===i.backgroundBucketIds.length)return;const{displayLevel:n,requiredLevel:a}=e;t.key.level=a,this._renderingDevice.setPipelineState({...this._pipelineState,color:{write:[!0,!0,!0,!0],blendMode:"composite"},stencil:!1,depth:!1}),e.renderPass="background";const l=this._vtlTechniques.getTechnique(0);r[0]=t,i.backgroundBucketIds.forEach(t=>{const a=i.getLayerById(t);if(0!==a.type)return;const o=a.getLayoutProperty("visibility");o&&1===o.getValue()||void 0!==a.minzoom&&a.minzoom>n+s||void 0!==a.maxzoom&&a.maxzoom<=n-s||(e.styleLayerUID=a.uid,e.styleLayer=a,l.render(e,{tiles:r}))}),r[0]=null}drawTile(e,i,s,n){const r=s.layers,{context:a}=e,l=a.getPipelineState(),{depthWrite:o}=l;let c=0,h=1;o&&void 0!==o.zNear&&void 0!==o.zFar&&(c=o.zNear,h=o.zFar),this._pipelineState={...t,color:{write:[!0,!0,!0,!0],blendMode:"none"},depth:{write:{zNear:c,zFar:h},test:515}},this._renderingDevice.setPipelineState(this._pipelineState);const u=r.filter(e=>{if(null!=n&&n!==e.type||!i.layerData.has(e.uid))return!1;const t=e.getLayoutProperty("visibility");return 1!==t?.getValue()});e.renderPass="opaque";for(let t=u.length-1;t>=0;--t)this._renderStyleLayer(u[t],e,i);this._pipelineState={...t,color:{write:[!0,!0,!0,!0],blendMode:"composite"},depth:{write:!1,test:515}},this._renderingDevice.setPipelineState(this._pipelineState),e.renderPass="translucent",u.forEach(t=>this._renderStyleLayer(t,e,i)),this._renderingDevice.setPipelineState({...this._pipelineState,depth:!1}),this._context||(this._context=e.context)}setShader(e){return this._renderingDevice.setShader(e)}setPipelineState(e){return this._renderingDevice.setPipelineState(e)}getPipelineState(){return this._renderingDevice.getPipelineState()}submitDraw(e,t,i){return this._renderingDevice.submitDraw(e,t,i)}submitDrawMesh(e,t,i,s){this._renderingDevice.submitDrawMesh(e,t,i,s)}submitDrawMeshUntyped(e,t,i,s){this._renderingDevice.submitDrawMeshUntyped(e,t,i,s)}updatePipelineState(e){return this._renderingDevice.updatePipelineState(e)}setStencilRef(e,t){return this._renderingDevice.setStencilRef(e,t)}_renderStyleLayer(e,t,i){const{renderPass:n}=t;let a;switch(e.type){case 0:if("background"!==n)return;a=this._vtlTechniques.getTechnique(0);break;case 1:if("opaque"!==n&&"translucent"!==t.renderPass)return;a=this._vtlTechniques.getTechnique(1);break;case 2:if("translucent"!==n)return;a=this._vtlTechniques.getTechnique(2);break;case 4:if("translucent"!==n)return;a=this._vtlTechniques.getTechnique(4);break;case 3:if("translucent"!==n)return;a=this._vtlTechniques.getTechnique(3)}const{displayLevel:l}=t,{minzoom:o,maxzoom:c}=e;void 0!==o&&o>l+s||void 0!==c&&c<=l-s||!a||(this._renderingDevice.setPipelineState({...this._pipelineState,stencil:{write:{mask:0},test:!1}}),t.styleLayerUID=e.uid,t.styleLayer=e,r[0]=i,a.render(t,{tiles:r}),r[0]=null)}}const r=[null];export{n as default};
2
+ import{RenderingDevice as e}from"../webgl/RenderingDevice.js";import{simplePipelineState as t}from"../webgl/shaderGraph/utils.js";import{VTLTechniquesRepo as i}from"../webgl/shaderGraph/techniques/vectorTiles/VTLTechniques.js";const s=1e-6;class n{constructor(s,n){this.spriteMosaic=s,this.glyphMosaic=n,this._vtlTechniques=new i,this._context=null,this._vtlTechniques.startup(),this._renderingDevice=new e,this._pipelineState=t}dispose(){this._vtlTechniques&&this._vtlTechniques.shutdown(this._context),this.spriteMosaic.dispose(),this.glyphMosaic.dispose(),this._renderingDevice.dispose(),this._context=null}drawSymbols(e,t,i){const n=i.layers;e.renderPass="translucent";const a=this._vtlTechniques.getTechnique(3);r[0]=t;for(let l=0;l<n.length;l++){const t=n[l];if(3!==t.type)continue;const i=t.getLayoutProperty("visibility");if(i&&1===i.getValue())continue;const o=e.displayLevel;void 0!==t.minzoom&&t.minzoom>o+s||void 0!==t.maxzoom&&t.maxzoom<=o-s||(e.styleLayerUID=t.uid,e.styleLayer=t,a.render(e,{tiles:r}))}r[0]=null}drawBackground(e,t,i){if(0===i.backgroundBucketIds.length)return;const{displayLevel:n,requiredLevel:a}=e;t.key.level=a,this._renderingDevice.setPipelineState({...this._pipelineState,color:{write:[!0,!0,!0,!0],blendMode:"composite"},stencil:!1,depth:!1}),e.renderPass="background";const l=this._vtlTechniques.getTechnique(0);r[0]=t,i.backgroundBucketIds.forEach(t=>{const a=i.getLayerById(t);if(0!==a.type)return;const o=a.getLayoutProperty("visibility");o&&1===o.getValue()||void 0!==a.minzoom&&a.minzoom>n+s||void 0!==a.maxzoom&&a.maxzoom<=n-s||(e.styleLayerUID=a.uid,e.styleLayer=a,l.render(e,{tiles:r}))}),r[0]=null}drawTile(e,i,s,n){const r=s.layers,{context:a}=e,l=a.getPipelineState(),{depthWrite:o}=l;let c=0,h=1;void 0!==o?.zNear&&void 0!==o.zFar&&(c=o.zNear,h=o.zFar),this._pipelineState={...t,color:{write:[!0,!0,!0,!0],blendMode:"none"},depth:{write:{zNear:c,zFar:h},test:515}},this._renderingDevice.setPipelineState(this._pipelineState);const u=r.filter(e=>{if(null!=n&&n!==e.type||!i.layerData.has(e.uid))return!1;const t=e.getLayoutProperty("visibility");return 1!==t?.getValue()});e.renderPass="opaque";for(let t=u.length-1;t>=0;--t)this._renderStyleLayer(u[t],e,i);this._pipelineState={...t,color:{write:[!0,!0,!0,!0],blendMode:"composite"},depth:{write:!1,test:515}},this._renderingDevice.setPipelineState(this._pipelineState),e.renderPass="translucent",u.forEach(t=>this._renderStyleLayer(t,e,i)),this._renderingDevice.setPipelineState({...this._pipelineState,depth:!1}),this._context||(this._context=e.context)}setShader(e){return this._renderingDevice.setShader(e)}setPipelineState(e){return this._renderingDevice.setPipelineState(e)}getPipelineState(){return this._renderingDevice.getPipelineState()}submitDraw(e,t,i){return this._renderingDevice.submitDraw(e,t,i)}submitDrawMesh(e,t,i,s){this._renderingDevice.submitDrawMesh(e,t,i,s)}submitDrawMeshUntyped(e,t,i,s){this._renderingDevice.submitDrawMeshUntyped(e,t,i,s)}updatePipelineState(e){return this._renderingDevice.updatePipelineState(e)}setStencilRef(e,t){return this._renderingDevice.setStencilRef(e,t)}_renderStyleLayer(e,t,i){const{renderPass:n}=t;let a;switch(e.type){case 0:if("background"!==n)return;a=this._vtlTechniques.getTechnique(0);break;case 1:if("opaque"!==n&&"translucent"!==t.renderPass)return;a=this._vtlTechniques.getTechnique(1);break;case 2:if("translucent"!==n)return;a=this._vtlTechniques.getTechnique(2);break;case 4:if("translucent"!==n)return;a=this._vtlTechniques.getTechnique(4);break;case 3:if("translucent"!==n)return;a=this._vtlTechniques.getTechnique(3)}const{displayLevel:l}=t,{minzoom:o,maxzoom:c}=e;void 0!==o&&o>l+s||void 0!==c&&c<=l-s||!a||(this._renderingDevice.setPipelineState({...this._pipelineState,stencil:{write:{mask:0},test:!1}}),t.styleLayerUID=e.uid,t.styleLayer=e,r[0]=i,a.render(t,{tiles:r}),r[0]=null)}}const r=[null];export{n as default};