@arcgis/core 4.31.0-next.20240520 → 4.31.0-next.20240521

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 (212) hide show
  1. package/applications/Components/drawUtils.d.ts +4 -0
  2. package/applications/Components/getContrastingBackgroundTheme.d.ts +4 -0
  3. package/applications/Components/gfxUtils.d.ts +4 -0
  4. package/applications/Components/gfxUtils.js +1 -1
  5. package/applications/Components/layerOriginUtils.d.ts +4 -0
  6. package/applications/Components/styleUtils.d.ts +4 -0
  7. package/applications/Components/svgUtils.d.ts +4 -0
  8. package/applications/Components/webStyleSymbolUtils.d.ts +4 -0
  9. package/assets/esri/core/workers/RemoteClient.js +1 -1
  10. package/assets/esri/core/workers/chunks/{9bf758be13aaa5ebba64.js → 1b4c91833fb7b99c6cfe.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{1476f4b9ed8a7d3330ce.js → 2f8a51d6b8229a90c240.js} +1 -1
  12. package/assets/esri/core/workers/chunks/3ad5de35a52b16be8dd5.js +1 -0
  13. package/assets/esri/core/workers/chunks/ba988cd3a49987a0fb83.js +1 -0
  14. package/assets/esri/core/workers/chunks/bd0545bb100b3393fd85.js +1 -0
  15. package/assets/esri/core/workers/chunks/{17d52156928ff61a02bf.js → fe59b594d2d8c536e649.js} +1 -1
  16. package/assets/esri/themes/base/widgets/_FeatureTable.scss +1 -0
  17. package/assets/esri/themes/base/widgets/_Grid.scss +4 -0
  18. package/assets/esri/themes/base/widgets/_Widget.scss +1 -0
  19. package/assets/esri/themes/dark/main.css +1 -1
  20. package/assets/esri/themes/light/main.css +1 -1
  21. package/assets/esri/themes/light/view.css +1 -1
  22. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_ar.json +1 -1
  23. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_bg.json +1 -1
  24. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_bs.json +1 -1
  25. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_ca.json +1 -1
  26. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_cs.json +1 -1
  27. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_da.json +1 -1
  28. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_de.json +1 -1
  29. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_el.json +1 -1
  30. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_es.json +1 -1
  31. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_et.json +1 -1
  32. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_fi.json +1 -1
  33. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_fr.json +1 -1
  34. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_he.json +1 -1
  35. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_hr.json +1 -1
  36. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_hu.json +1 -1
  37. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_id.json +1 -1
  38. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_it.json +1 -1
  39. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_ja.json +1 -1
  40. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_ko.json +1 -1
  41. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_lt.json +1 -1
  42. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_lv.json +1 -1
  43. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_nb.json +1 -1
  44. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_nl.json +1 -1
  45. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_pl.json +1 -1
  46. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_pt-BR.json +1 -1
  47. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_pt-PT.json +1 -1
  48. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_ro.json +1 -1
  49. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_ru.json +1 -1
  50. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_sk.json +1 -1
  51. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_sl.json +1 -1
  52. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_sr.json +1 -1
  53. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_sv.json +1 -1
  54. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_th.json +1 -1
  55. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_tr.json +1 -1
  56. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_uk.json +1 -1
  57. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_vi.json +1 -1
  58. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_zh-CN.json +1 -1
  59. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_zh-HK.json +1 -1
  60. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_zh-TW.json +1 -1
  61. package/assets/esri/widgets/LayerList/t9n/LayerList_ar.json +1 -1
  62. package/assets/esri/widgets/LayerList/t9n/LayerList_bg.json +1 -1
  63. package/assets/esri/widgets/LayerList/t9n/LayerList_bs.json +1 -1
  64. package/assets/esri/widgets/LayerList/t9n/LayerList_ca.json +1 -1
  65. package/assets/esri/widgets/LayerList/t9n/LayerList_cs.json +1 -1
  66. package/assets/esri/widgets/LayerList/t9n/LayerList_da.json +1 -1
  67. package/assets/esri/widgets/LayerList/t9n/LayerList_de.json +1 -1
  68. package/assets/esri/widgets/LayerList/t9n/LayerList_el.json +1 -1
  69. package/assets/esri/widgets/LayerList/t9n/LayerList_es.json +1 -1
  70. package/assets/esri/widgets/LayerList/t9n/LayerList_et.json +1 -1
  71. package/assets/esri/widgets/LayerList/t9n/LayerList_fi.json +1 -1
  72. package/assets/esri/widgets/LayerList/t9n/LayerList_fr.json +1 -1
  73. package/assets/esri/widgets/LayerList/t9n/LayerList_he.json +1 -1
  74. package/assets/esri/widgets/LayerList/t9n/LayerList_hr.json +1 -1
  75. package/assets/esri/widgets/LayerList/t9n/LayerList_hu.json +1 -1
  76. package/assets/esri/widgets/LayerList/t9n/LayerList_id.json +1 -1
  77. package/assets/esri/widgets/LayerList/t9n/LayerList_it.json +1 -1
  78. package/assets/esri/widgets/LayerList/t9n/LayerList_ja.json +1 -1
  79. package/assets/esri/widgets/LayerList/t9n/LayerList_ko.json +1 -1
  80. package/assets/esri/widgets/LayerList/t9n/LayerList_lt.json +1 -1
  81. package/assets/esri/widgets/LayerList/t9n/LayerList_lv.json +1 -1
  82. package/assets/esri/widgets/LayerList/t9n/LayerList_nb.json +1 -1
  83. package/assets/esri/widgets/LayerList/t9n/LayerList_nl.json +1 -1
  84. package/assets/esri/widgets/LayerList/t9n/LayerList_pl.json +1 -1
  85. package/assets/esri/widgets/LayerList/t9n/LayerList_pt-BR.json +1 -1
  86. package/assets/esri/widgets/LayerList/t9n/LayerList_pt-PT.json +1 -1
  87. package/assets/esri/widgets/LayerList/t9n/LayerList_ro.json +1 -1
  88. package/assets/esri/widgets/LayerList/t9n/LayerList_ru.json +1 -1
  89. package/assets/esri/widgets/LayerList/t9n/LayerList_sk.json +1 -1
  90. package/assets/esri/widgets/LayerList/t9n/LayerList_sl.json +1 -1
  91. package/assets/esri/widgets/LayerList/t9n/LayerList_sr.json +1 -1
  92. package/assets/esri/widgets/LayerList/t9n/LayerList_sv.json +1 -1
  93. package/assets/esri/widgets/LayerList/t9n/LayerList_th.json +1 -1
  94. package/assets/esri/widgets/LayerList/t9n/LayerList_tr.json +1 -1
  95. package/assets/esri/widgets/LayerList/t9n/LayerList_uk.json +1 -1
  96. package/assets/esri/widgets/LayerList/t9n/LayerList_vi.json +1 -1
  97. package/assets/esri/widgets/LayerList/t9n/LayerList_zh-CN.json +1 -1
  98. package/assets/esri/widgets/LayerList/t9n/LayerList_zh-HK.json +1 -1
  99. package/assets/esri/widgets/LayerList/t9n/LayerList_zh-TW.json +1 -1
  100. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ar.json +1 -1
  101. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_bg.json +1 -1
  102. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_bs.json +1 -1
  103. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ca.json +1 -1
  104. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_cs.json +1 -1
  105. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_da.json +1 -1
  106. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_de.json +1 -1
  107. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_el.json +1 -1
  108. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_es.json +1 -1
  109. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_et.json +1 -1
  110. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_fi.json +1 -1
  111. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_fr.json +1 -1
  112. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_he.json +1 -1
  113. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_hr.json +1 -1
  114. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_hu.json +1 -1
  115. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_id.json +1 -1
  116. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_it.json +1 -1
  117. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ja.json +1 -1
  118. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ko.json +1 -1
  119. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_lt.json +1 -1
  120. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_lv.json +1 -1
  121. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_nb.json +1 -1
  122. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_nl.json +1 -1
  123. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_pl.json +1 -1
  124. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_pt-BR.json +1 -1
  125. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_pt-PT.json +1 -1
  126. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ro.json +1 -1
  127. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ru.json +1 -1
  128. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_sk.json +1 -1
  129. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_sl.json +1 -1
  130. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_sr.json +1 -1
  131. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_sv.json +1 -1
  132. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_th.json +1 -1
  133. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_tr.json +1 -1
  134. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_uk.json +1 -1
  135. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_vi.json +1 -1
  136. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_zh-CN.json +1 -1
  137. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_zh-HK.json +1 -1
  138. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_zh-TW.json +1 -1
  139. package/assets/esri/widgets/Print/t9n/Print_ar.json +1 -1
  140. package/assets/esri/widgets/Print/t9n/Print_bg.json +1 -1
  141. package/assets/esri/widgets/Print/t9n/Print_bs.json +1 -1
  142. package/assets/esri/widgets/Print/t9n/Print_ca.json +1 -1
  143. package/assets/esri/widgets/Print/t9n/Print_cs.json +1 -1
  144. package/assets/esri/widgets/Print/t9n/Print_da.json +1 -1
  145. package/assets/esri/widgets/Print/t9n/Print_de.json +1 -1
  146. package/assets/esri/widgets/Print/t9n/Print_el.json +1 -1
  147. package/assets/esri/widgets/Print/t9n/Print_es.json +1 -1
  148. package/assets/esri/widgets/Print/t9n/Print_et.json +1 -1
  149. package/assets/esri/widgets/Print/t9n/Print_fi.json +1 -1
  150. package/assets/esri/widgets/Print/t9n/Print_fr.json +1 -1
  151. package/assets/esri/widgets/Print/t9n/Print_he.json +1 -1
  152. package/assets/esri/widgets/Print/t9n/Print_hr.json +1 -1
  153. package/assets/esri/widgets/Print/t9n/Print_hu.json +1 -1
  154. package/assets/esri/widgets/Print/t9n/Print_id.json +1 -1
  155. package/assets/esri/widgets/Print/t9n/Print_it.json +1 -1
  156. package/assets/esri/widgets/Print/t9n/Print_ja.json +1 -1
  157. package/assets/esri/widgets/Print/t9n/Print_ko.json +1 -1
  158. package/assets/esri/widgets/Print/t9n/Print_lt.json +1 -1
  159. package/assets/esri/widgets/Print/t9n/Print_lv.json +1 -1
  160. package/assets/esri/widgets/Print/t9n/Print_nb.json +1 -1
  161. package/assets/esri/widgets/Print/t9n/Print_nl.json +1 -1
  162. package/assets/esri/widgets/Print/t9n/Print_pl.json +1 -1
  163. package/assets/esri/widgets/Print/t9n/Print_pt-BR.json +1 -1
  164. package/assets/esri/widgets/Print/t9n/Print_pt-PT.json +1 -1
  165. package/assets/esri/widgets/Print/t9n/Print_ro.json +1 -1
  166. package/assets/esri/widgets/Print/t9n/Print_ru.json +1 -1
  167. package/assets/esri/widgets/Print/t9n/Print_sk.json +1 -1
  168. package/assets/esri/widgets/Print/t9n/Print_sl.json +1 -1
  169. package/assets/esri/widgets/Print/t9n/Print_sr.json +1 -1
  170. package/assets/esri/widgets/Print/t9n/Print_sv.json +1 -1
  171. package/assets/esri/widgets/Print/t9n/Print_th.json +1 -1
  172. package/assets/esri/widgets/Print/t9n/Print_tr.json +1 -1
  173. package/assets/esri/widgets/Print/t9n/Print_uk.json +1 -1
  174. package/assets/esri/widgets/Print/t9n/Print_vi.json +1 -1
  175. package/assets/esri/widgets/Print/t9n/Print_zh-CN.json +1 -1
  176. package/assets/esri/widgets/Print/t9n/Print_zh-HK.json +1 -1
  177. package/assets/esri/widgets/Print/t9n/Print_zh-TW.json +1 -1
  178. package/core/Accessor.js +1 -1
  179. package/core/Collection.js +1 -1
  180. package/core/Handles.js +1 -1
  181. package/core/a11yUtils.js +1 -1
  182. package/interfaces.d.ts +145 -2
  183. package/layers/CatalogLayer.js +1 -1
  184. package/layers/MapImageLayer.js +1 -1
  185. package/layers/catalog/CatalogDynamicGroupLayer.js +1 -1
  186. package/layers/support/layerUtils.js +1 -1
  187. package/package.json +1 -1
  188. package/rest/support/RelationshipQuery.js +1 -1
  189. package/support/revision.js +1 -1
  190. package/views/2d/AnimationManager.js +1 -1
  191. package/views/2d/GoToManager.js +1 -1
  192. package/views/2d/engine/vectorTiles/decluttering/SymbolRepository.js +1 -1
  193. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  194. package/views/2d/layers/features/RenderState.js +1 -1
  195. package/views/2d/navigation/actions/Pan.js +1 -1
  196. package/views/SelectionManager.js +1 -1
  197. package/views/navigation/Navigation.js +1 -1
  198. package/views/ui/UI.js +1 -1
  199. package/widgets/BasemapLayerList.js +1 -1
  200. package/widgets/Feature/FeatureRelationship/FeatureRelationshipViewModel.js +1 -1
  201. package/widgets/Feature/support/featureUtils.js +1 -1
  202. package/widgets/FeatureTable/Grid/Column.js +1 -1
  203. package/widgets/FeatureTable/support/FeatureStore.js +1 -1
  204. package/widgets/FeatureTable.js +1 -1
  205. package/widgets/Features/FeaturesRelatedRecords.js +1 -1
  206. package/widgets/LayerList/support/layerListUtils.js +1 -1
  207. package/widgets/LayerList.js +1 -1
  208. package/widgets/Print/PrintViewModel.js +1 -1
  209. package/widgets/Print.js +1 -1
  210. package/assets/esri/core/workers/chunks/47edce5f7ab667a0b8af.js +0 -1
  211. package/assets/esri/core/workers/chunks/92979bf325405d87c090.js +0 -1
  212. package/assets/esri/core/workers/chunks/ed24ad7c7fbb02c307aa.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import t from"../core/Collection.js";import{watch as i,sync as l,initial as o,on as s}from"../core/reactiveUtils.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import a from"./Widget.js";import d from"./FeatureTable/ColumnMenuVisibleElements.js";import c from"./FeatureTable/FeatureTableViewModel.js";import h from"./FeatureTable/VisibleElements.js";import p from"./FeatureTable/support/FieldColumnTemplate.js";import m from"./FeatureTable/support/TableTemplate.js";import{uniqueColumnNames as u,isIFeatureTableSupportedLayerWithAttachments as g}from"./FeatureTable/support/tableUtils.js";import{loadCalciteComponents as b}from"./support/componentsUtils.js";import{globalCss as w}from"./support/globalCss.js";import{Heading as v}from"./support/Heading.js";import{renderingSanitizer as y}from"./support/widgetUtils.js";import{messageBundle as f}from"./support/decorators/messageBundle.js";import{vmEvent as _}from"./support/decorators/vmEvent.js";import{tsx as M}from"./support/jsxFactory.js";import{substitute as C}from"../intl/substitute.js";var S;const E="esri-feature-table",T=`${E}__prompt`,A={base:E,content:`${E}__content`,menuPopover:`${E}__menu-popover`,tableContainer:`${E}__table-container`,tableNavigation:`${E}__table-navigation`,expanded:`${E}__expanded`,collapsed:`${E}__collapsed`,promptContainer:T,promptHeader:`${T}__header`,promptHeading:`${T}__header__heading`,promptMessage:`${T}__message`,promptDivider:`${T}__divider`,promptActions:`${T}__actions`},I={clearSelection:"clear-selection",delete:"trash",refresh:"refresh",showAll:"selection-x",showSelected:"selection-filter",zoomToSelection:"zoom-to-object"};let R=S=class extends a{constructor(e,i){super(e,i),this._columnVisibilityActions=new Map,this._prompt=null,this._showAllTablesEnabled=!1,this.disabled=!1,this.menuConfig=null,this.relatedTables=new t,this.tableParent=null,this.title=null,this.viewModel=new c,this.visibleElements=new h,this.visibleElementsOverride=null,this._showDeletePrompt=this._showDeletePrompt.bind(this),this._onDeleteSelectionClick=this._onDeleteSelectionClick.bind(this)}initialize(){this.addHandles([i((()=>[this.viewModel.store.querying,this.viewModel.store.syncing,this.editingEnabled]),(()=>this.scheduleRender())),i((()=>({visibleElements:this._effectiveVisibleElements,items:this.columns.length})),(({visibleElements:e})=>{this.columns.forEach((t=>t.visibleElements=e)),this.refreshCellContent()}),l),i((()=>this._effectiveVisibleElements.selectionColumn),(e=>{this.grid&&(this.grid.selectionColumnEnabled=e)}),o),s((()=>this.viewModel),"show-related-table",(e=>this._onShowRelatedTable(e))),i((()=>this.viewModel.state),(e=>{"disabled"===e&&this.relatedTables.length&&this._drainRelatedTables()}))])}loadDependencies(){return b({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel.js"),popover:()=>import("@esri/calcite-components/dist/components/calcite-popover.js"),progress:()=>import("@esri/calcite-components/dist/components/calcite-progress.js"),scrim:()=>import("@esri/calcite-components/dist/components/calcite-scrim.js"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch.js"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip.js"),"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar.js"),dropdown:()=>import("@esri/calcite-components/dist/components/calcite-dropdown.js"),"dropdown-group":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-group.js"),"dropdown-item":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-item.js"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker.js"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker.js"),"input-time-zone":()=>import("@esri/calcite-components/dist/components/calcite-input-time-zone.js")})}destroy(){this._clearPrompt()}get _effectiveTitle(){const{layer:e,messages:t,state:i,highlightIds:l,title:o,viewModel:s}=this;if(o)return y.sanitize("function"==typeof o?o():o);if(!e)return t.noLayer;switch(i){case"disabled":return t.errorLayer;case"ready":return y.sanitize(e.title);case"loading":return t.loading;case"error":return t.errorData}return C(t.header,{title:y.sanitize(e.title),count:s.size,selected:l.length})}get _effectiveVisibleElements(){return this.visibleElementsOverride??this.visibleElements}get _hasCustomMenuItems(){return!!this.menuConfig?.items?.length}get _hasDefaultMenuItems(){return!!(this._showClearSelectionAction||this._showDeleteSelectionAction||this._showRefreshDataAction||this._showZoomToSelectionAction||this._showSelectedRecordsShowSelectedAction||this._showSelectedRecordsShowAllAction||this._showColumnsVisibilityAction)}get _shouldShowMenu(){const{header:e,menu:t}=this._effectiveVisibleElements;return!(!e||!t||!this._hasDefaultMenuItems&&!this._hasCustomMenuItems)}get _showClearSelectionAction(){return!(!this.highlightIds.length||!this._effectiveVisibleElements.menuItems?.clearSelection||this.relatedTables.length)}get _showColumnsVisibilityAction(){const{header:e,menu:t,menuItems:i}=this._effectiveVisibleElements;return!(!(e&&t&&i?.toggleColumns)||this.showRelatedTableCallback||this._showAllTablesEnabled)}get _showDeleteSelectionAction(){return!!(this.highlightIds.length&&this._effectiveVisibleElements.menuItems?.deleteSelection&&this.editingEnabled&&this.layer?.capabilities?.operations?.supportsDelete)}get _showRefreshDataAction(){return!!this._effectiveVisibleElements.menuItems?.refreshData}get _showSelectedRecordsShowSelectedAction(){const e=this.objectIds.length,t=this.highlightIds.length;return!(!t||!this._effectiveVisibleElements.menuItems?.selectedRecordsShowSelectedToggle||e&&t===e||this.relatedTables.length)}get _showSelectedRecordsShowAllAction(){return!(!this._effectiveVisibleElements.menuItems?.selectedRecordsShowAllToggle||!this.objectIds.length||this.relatedTables.length)}get _showZoomToSelectionAction(){return!!(this.view&&this.highlightIds.length&&this._effectiveVisibleElements.menuItems?.zoomToSelection)}get actionColumnConfig(){return this.viewModel.actionColumnConfig}set actionColumnConfig(e){this.viewModel.actionColumnConfig=e}get activeFilters(){return this.viewModel.activeFilters}get activeSortOrders(){return this.viewModel.activeSortOrders}get attachmentsEnabled(){return this.viewModel.attachmentsEnabled}set attachmentsEnabled(e){this.viewModel.attachmentsEnabled=e}get autoRefreshEnabled(){return this.viewModel.autoRefreshEnabled}set autoRefreshEnabled(e){this.viewModel.autoRefreshEnabled=e}get columnPerformanceModeEnabled(){return this.viewModel.columnPerformanceModeEnabled}set columnPerformanceModeEnabled(e){this.viewModel.columnPerformanceModeEnabled=e}get columnReorderingEnabled(){return this.viewModel.columnReorderingEnabled}set columnReorderingEnabled(e){this.viewModel.columnReorderingEnabled=e}get columns(){return this.viewModel.columns}get editingEnabled(){return this.viewModel.editingEnabled}set editingEnabled(e){this.viewModel.editingEnabled=e}get filterGeometry(){return this.viewModel.filterGeometry}set filterGeometry(e){this.viewModel.filterGeometry=e}get filterBySelectionEnabled(){return this.viewModel.filterBySelectionEnabled}set filterBySelectionEnabled(e){this.viewModel.filterBySelectionEnabled=e}get grid(){return this.viewModel.grid}get hiddenFields(){return this.viewModel.hiddenFields}set hiddenFields(e){this.viewModel.hiddenFields=e}get highlightEnabled(){return this.viewModel.highlightEnabled}set highlightEnabled(e){this.viewModel.highlightEnabled=e}get highlightIds(){return this.viewModel.highlightIds}set highlightIds(e){this.viewModel.highlightIds=e}get icon(){return"table"}set icon(e){this._overrideIfSome("icon",e)}get isQueryingOrSyncing(){return this.viewModel.isQueryingOrSyncing||this.relatedTables.some((e=>!!e.isQueryingOrSyncing))}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get layerView(){return this.viewModel.layerView}get messages(){return this.viewModel.messages}set messages(e){this.viewModel.messages=e}get messagesCommon(){return this.viewModel.messagesCommon}set messagesCommon(e){this.viewModel.messagesCommon=e}get messagesURIUtils(){return this.viewModel.messagesURIUtils}set messagesURIUtils(e){this.viewModel.messagesURIUtils=e}get multipleSelectionEnabled(){return this.viewModel.multipleSelectionEnabled}set multipleSelectionEnabled(e){this.viewModel.multipleSelectionEnabled=e}get multiSortEnabled(){return this.viewModel.multiSortEnabled}set multiSortEnabled(e){this.viewModel.multiSortEnabled=e}get objectIds(){return this.viewModel.objectIds}set objectIds(e){this.viewModel.objectIds=e}get pageSize(){return this.viewModel.pageSize}set pageSize(e){this.viewModel.pageSize=e}get relatedRecordsEnabled(){return this.viewModel.relatedRecordsEnabled}set relatedRecordsEnabled(e){this.viewModel.relatedRecordsEnabled=e}get relatedTable(){return this.relatedTables.at(-1)}get relationship(){return this.viewModel.relationship}get relationshipColumnConfigs(){return this.viewModel.relationshipColumnConfigs}set relationshipColumnConfigs(e){this.viewModel.relationshipColumnConfigs=e}get relationshipConfig(){return this.viewModel.relationshipConfig}set relationshipConfig(e){this.viewModel.relationshipConfig=e}get returnGeometryEnabled(){return this.viewModel.returnGeometryEnabled}set returnGeometryEnabled(e){this.viewModel.returnGeometryEnabled=e}get rowHighlightIds(){return this.viewModel.rowHighlightIds}set rowHighlightIds(e){this.viewModel.rowHighlightIds=e}get selectionSource(){return this.viewModel.selectionSource}set selectionSource(e){this.viewModel.selectionSource=e}get showRelatedTableCallback(){return this.viewModel.showRelatedTableCallback}set showRelatedTableCallback(e){this.viewModel.showRelatedTableCallback=e}get size(){return this.viewModel.size}get state(){return this.viewModel.state}get tableTemplate(){return this.viewModel.tableTemplate}set tableTemplate(e){this.viewModel.tableTemplate=e}get tableTemplateOverride(){return this.viewModel.tableTemplateOverride}set tableTemplateOverride(e){this.viewModel.tableTemplateOverride=e}get timeExtent(){return this.viewModel.timeExtent}set timeExtent(e){this.viewModel.timeExtent=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}clearSelectionFilter(){this.viewModel.clearSelectionFilter()}deleteSelection(e){return this.highlightIds.length?e?(this._showDeletePrompt(),this.scheduleRender(),Promise.resolve()):this.viewModel.deleteSelection():Promise.resolve()}filterBySelection(){this.viewModel.filterBySelection()}findColumn(e){return this.viewModel.findColumn(e)}hideColumn(e){this.grid?.hideColumn(e)}async refresh(){this.relatedTables.forEach((async e=>await e.refresh())),await this.viewModel.refresh()}refreshCellContent(){this.viewModel.refreshCellContent()}showAllColumns(){this.viewModel.showAllColumns()}showColumn(e){this.grid?.showColumn(e)}sortColumn(e,t){this.viewModel.sortColumn(e,t)}scrollToIndex(e){this.viewModel.scrollToIndex(e)}toggleColumnVisibility(e){this.viewModel.toggleColumnVisibility(e)}zoomToSelection(){this.viewModel.zoomToSelection()}render(){const{_prompt:e,_effectiveVisibleElements:t,isQueryingOrSyncing:i,menuConfig:l,state:o}=this;return M("div",{bind:this,class:this.classes(A.base,w.widget)},M("calcite-panel",{bind:this,class:A.content,closable:t.close,disabled:this.disabled||"disabled"===o,heading:t.header?this._effectiveTitle:void 0,loading:"loading"===o,menuOpen:!!l?.open,overlayPositioning:"fixed",onCalcitePanelClose:e=>{e.target.closed=!1,this.emit("close")}},t.progress?M("calcite-progress",{type:i?"indeterminate":"determinate"}):null,this._renderColumnVisibilityAction(),this._renderHeaderMenuActions(),this._renderRelatedTableNavigationBar(),M("div",{class:A.tableContainer},this._renderTables())),e?M("calcite-scrim",null,this._renderPrompt(e)):null)}_renderTables(){const{_showAllTablesEnabled:e,grid:t,relatedTables:i}=this;return i.length?M("calcite-panel",null,M("div",null,M("div",{class:this.classes(A.base,{[A.expanded]:e,[A.collapsed]:!e})},t?.render()),...i.toArray().map(((t,i)=>M("div",{class:this.classes(A.base,e?A.expanded:A.collapsed),key:`related-${i}`},t.render()))))):t?.render()}_clearPrompt(){this._prompt=null}_renderPrompt({title:e,message:t,context:i,actions:l}){const o=M("calcite-button",{appearance:"solid",key:"prompt-primary-button",kind:"danger"===i?"danger":"brand",onclick:l.primary.action,width:l.secondary?"half":"full"},l.primary.label),s=l.secondary?M("calcite-button",{appearance:"outline",key:"prompt-secondary-button",kind:"danger"===i?"danger":"brand",onclick:l.secondary.action,width:"half"},l.secondary.label):null;return M("div",{class:`${A.promptContainer}--${i}`},M("div",{class:A.promptHeader},M("calcite-icon",{icon:"exclamation-mark-triangle"}),M(v,{class:A.promptHeading,level:2},e)),M("div",{class:A.promptMessage},t),M("div",{class:A.promptDivider}),M("div",{class:A.promptActions},s,o))}_showDeletePrompt(){const{messages:e,messagesCommon:t}=this,i=C(e.deleteSelectionCount,{count:this.highlightIds.length});this._prompt={title:i,message:e.deleteRecordsRemoved,context:"danger",actions:{primary:{label:t.delete,action:this._onDeleteSelectionClick},secondary:{label:e.keepRecords,action:()=>this._clearPrompt()}}}}async _onDeleteSelectionClick(){try{await this.viewModel.deleteSelection()}finally{this._clearPrompt()}}_renderHeaderMenuAction(e){const{disabled:t,hidden:i,icon:l,text:o,clickFunction:s}=e;if(!i)return M("calcite-action",{disabled:t??this.menuConfig?.disabled,icon:l??void 0,key:o,onclick:()=>s(),slot:"header-menu-actions",text:o,textEnabled:!0,title:o})}_renderHeaderMenuActions(){return this._shouldShowMenu?[this._renderDefaultHeaderMenuActions(),this._renderCustomHeaderMenuActions()]:[]}_renderDefaultHeaderMenuActions(){if(!this._hasDefaultMenuItems)return[];const{messages:e}=this,t=[];return this._showRefreshDataAction&&t.push(this._renderHeaderMenuAction({icon:I.refresh,text:e.refreshData,clickFunction:()=>this.refresh()})),this._showDeleteSelectionAction&&t.push(this._renderHeaderMenuAction({icon:I.delete,text:e.deleteSelection,clickFunction:()=>this.deleteSelection(!0)})),this._showClearSelectionAction&&t.push(this._renderHeaderMenuAction({icon:I.clearSelection,text:e.clearSelection,clickFunction:()=>this.highlightIds?.removeAll()})),this._showZoomToSelectionAction&&t.push(this._renderHeaderMenuAction({icon:I.zoomToSelection,text:e.zoomToSelection,clickFunction:()=>this.zoomToSelection()})),this._showSelectedRecordsShowSelectedAction&&t.push(this._renderHeaderMenuAction({icon:I.showSelected,text:e.showSelected,clickFunction:()=>{const{objectIds:e}=this;e.removeAll(),e.addMany(this.highlightIds.toArray())}})),this._showSelectedRecordsShowAllAction&&t.push(this._renderHeaderMenuAction({icon:I.showAll,text:e.showAllRecords,clickFunction:()=>this.objectIds.removeAll()})),t}_renderCustomHeaderMenuActions(){return this.menuConfig?.items?.map((({disabled:e,hidden:t,icon:i,label:l,clickFunction:o})=>this._renderHeaderMenuAction({hidden:"function"==typeof t?t():t,icon:i,text:l,disabled:e,clickFunction:e=>o(e)})))??[]}_renderColumnVisibilityAction(){if(!this._showColumnsVisibilityAction)return[];const{_columnVisibilityActions:e,_effectiveVisibleElements:t,id:i,messages:l}=this,o=this.relatedTables.at(-1)||this,s=o.columns.toArray(),n=l?.toggleColumns,r=`${i}__toggle-columns-action`,a=[M("calcite-action",{afterCreate:t=>e.set(i,t),afterRemoved:()=>e.delete(i),appearance:"transparent",bind:this,disabled:o.menuConfig?.disabled,icon:"show-column",id:r,slot:"header-actions-end",text:n},t.tooltips?M("calcite-tooltip",{closeOnClick:!0,overlayPositioning:"fixed",placement:"bottom-end",slot:"tooltip"},n):null)];return o.menuConfig?.disabled||a.push(M("calcite-popover",{autoClose:!0,class:A.menuPopover,label:n,overlayPositioning:"fixed",placement:"top-end",pointerDisabled:!0,referenceElement:e.get(i)},M("calcite-list",{filterEnabled:!0,selectionMode:"multiple"},...s.map((({effectiveLabel:e,fieldName:t,hidden:i})=>M("calcite-list-item",{key:`toggle-columns__item-${t}`,label:e,selected:!i,value:t,onCalciteListItemSelect:({target:e})=>o.toggleColumnVisibility(e.value)})))))),a}_onShowRelatedTable(e){if(this.showRelatedTableCallback)return;const{relatedTables:t}=this,{length:i}=t,l=i?t.getItemAt(i-1):this;this._collapseRelatedTable(l,e),this._createRelatedTable(e)}_renderRelatedTableNavigationBar(){const e=this.messages.exitRelatedRecords;if(this.relatedTables.length&&!this.showRelatedTableCallback)return M("div",{class:A.tableNavigation,key:"table-nav"},M("calcite-action",{icon:"move-up",key:e,onclick:()=>this._drainRelatedTables(),text:e,title:e}),this.relatedTables.toArray().map(((e,t)=>this._renderRelatedTableNavigationAction(e,t))),M("div",null,M("calcite-label",{layout:"inline"},"Show all tables",M("calcite-switch",{checked:this._showAllTablesEnabled,onCalciteSwitchChange:e=>{const{relatedTables:t}=this,i=!!e.target.checked,l=t.at(-1);this._showAllTablesEnabled=i,l&&(i?this._enterShowAllView(l):this._exitShowAllView(l))}}))))}_renderRelatedTableNavigationAction(e,t){const i=this._getLabelForRelatedTableNavigationAction(e);return M("calcite-action",{icon:"chevron-right",key:t,onclick:()=>this._drainRelatedTablesAboveIndex(t),text:i,textEnabled:!0,title:e.layer?.title||""})}_getLabelForRelatedTableNavigationAction(e){const t=e.layer?.title;if(!t)return"";const{relatedTables:i}=this;if(i.length<=1)return t;return i.indexOf(e)!==i.length-1&&t.length>20?`${t.slice(0,20)}...`:t}_drainRelatedTables(){this.relatedTables.drain((e=>!e.destroyed&&e.destroy())),this.set({multipleSelectionEnabled:!0,tableTemplateOverride:null,relationshipColumnConfigs:null,visibleElementsOverride:null}),this.hiddenFields.removeMany([u.action,u.attachments])}_drainRelatedTablesAboveIndex(e){const t=this.relatedTables,i=t.filter(((t,i)=>i>e));i.forEach((e=>!e.destroyed&&e.destroy())),t.removeMany(i);const l=t.at(-1);if(!l?.layer||!l?.relationship)return;const{layer:o,relationship:s}=l;this._showAllTablesEnabled?this._enterShowAllView(l):l.set({multipleSelectionEnabled:!0,tableTemplateOverride:null,relationshipColumnConfigs:this._getRelationshipIdsToShow(o,s.id),visibleElementsOverride:null}),l.hiddenFields.removeMany([u.action,u.attachments])}_getRelatedTableMenuItemConfig(e,t,i){return t.fields.map((({alias:l,name:o})=>({selected:o===i,label:l||o,clickFunction:i=>{i.stopPropagation(),e.tableTemplateOverride=new m({columnTemplates:[this._createRelatedFieldColumnTemplate(e,t,o)]})}})))}_createRelatedFieldColumnTemplate(e,t,i){return new p({fieldName:i,editable:!1,menuConfig:{selectionMode:"single",icon:"chevron-down",items:this._getRelatedTableMenuItemConfig(e,t,i)},resizable:!1})}_enterShowAllView(e){const t=e.layer;if(!t)return;const i=e===this,{visibleElements:l}=e,o=t.displayField||t.objectIdField;e.set({relationshipColumnConfigs:[],tableTemplateOverride:new m({columnTemplates:[this._createRelatedFieldColumnTemplate(e,t,o)]}),visibleElementsOverride:new h({header:i&&l.header,progress:i&&l.progress,columnMenus:l.columnMenus,close:l.close,tooltips:l.tooltips,selectionColumn:!1,columnMenuItems:new d({sortAscending:!1,sortDescending:!1})})}),e.hiddenFields.addMany([u.action,u.attachments])}_exitShowAllView(e){const{layer:t,relationship:i}=e;t&&null!=i?.id&&(e.set({relationshipColumnConfigs:this._getRelationshipIdsToShow(t,i.id),tableTemplateOverride:null,visibleElementsOverride:null}),e.hiddenFields.removeMany([u.action,u.attachments]))}_collapseRelatedTable(e,i){const{relatedLayer:l,feature:o,relationshipId:s}=i,n=l.relationships?.find((({id:e})=>e===s)),{objectIdField:r}=l,a=l.displayField||n?.keyField||r,c=o.getObjectId()??o.attributes[r],p=e===this,{visibleElements:g}=e;e.set({highlightIds:new t([c]),multipleSelectionEnabled:!1,relationshipColumnConfigs:[{relationshipId:s,collapsed:!0}],tableTemplateOverride:new m({columnTemplates:[this._createRelatedFieldColumnTemplate(e,l,a)]}),visibleElementsOverride:new h({header:p&&g.header,progress:p&&g.progress,columnMenus:g.columnMenus,close:g.close,tooltips:g.tooltips,selectionColumn:!1,columnMenuItems:new d({sortAscending:!1,sortDescending:!1})})}),e.hiddenFields.addMany([u.action,u.attachments])}_getRelationshipIdsToShow(e,t){return(e.relationships??[]).filter((e=>!(e.id===t&&"one-to-one"===e.cardinality))).map((({id:e})=>({relationshipId:e})))}async _createRelatedTable(e){const{editingEnabled:t,relatedTables:i,view:l,viewModel:o}=this,{layer:n,feature:r,relatedLayer:a,relationshipId:d}=e,c=r.getObjectId()??r.attributes[a.objectIdField],p=i.length,m=p?i.getItemAt(p-1):this;await n.load();const u=this.attachmentsEnabled&&g(n),b=new S({layer:n,attachmentsEnabled:u,editingEnabled:t,relatedRecordsEnabled:!0,relationshipConfig:{objectId:c,relatedLayer:a,relationshipId:d},relationshipColumnConfigs:this._getRelationshipIdsToShow(n,d),tableParent:m,view:l,visibleElements:new h({header:!1,progress:!1}),showRelatedTableCallback:({feature:e,layer:t,relatedLayer:i,relationshipId:l})=>{null!=(e.getObjectId()??e.attributes[i.objectIdField])&&o.emit("show-related-table",{feature:e,layer:t,relatedLayer:i,relationshipId:l})}});b.addHandles([s((()=>m.highlightIds),"change",(({added:e})=>{const t=e[0];null!=t&&(b.highlightIds.removeAll(),b.relationshipConfig={objectId:t,relatedLayer:a,relationshipId:d})})),s((()=>m),"cell-click",(e=>{const{feature:t}=e;if(t){const e=t.getObjectId()??t.attributes[a.objectIdField];null!=e&&m.highlightIds.add(e)}}))]),this.relatedTables.add(b),this.scheduleRender()}};e([n()],R.prototype,"_columnVisibilityActions",void 0),e([n()],R.prototype,"_effectiveTitle",null),e([n()],R.prototype,"_effectiveVisibleElements",null),e([n()],R.prototype,"_hasCustomMenuItems",null),e([n()],R.prototype,"_hasDefaultMenuItems",null),e([n()],R.prototype,"_prompt",void 0),e([n()],R.prototype,"_shouldShowMenu",null),e([n()],R.prototype,"_showAllTablesEnabled",void 0),e([n()],R.prototype,"_showClearSelectionAction",null),e([n()],R.prototype,"_showColumnsVisibilityAction",null),e([n()],R.prototype,"_showDeleteSelectionAction",null),e([n()],R.prototype,"_showRefreshDataAction",null),e([n()],R.prototype,"_showSelectedRecordsShowSelectedAction",null),e([n()],R.prototype,"_showSelectedRecordsShowAllAction",null),e([n()],R.prototype,"_showZoomToSelectionAction",null),e([n()],R.prototype,"actionColumnConfig",null),e([n({readOnly:!0})],R.prototype,"activeFilters",null),e([n({readOnly:!0})],R.prototype,"activeSortOrders",null),e([n()],R.prototype,"attachmentsEnabled",null),e([n()],R.prototype,"autoRefreshEnabled",null),e([n()],R.prototype,"columnPerformanceModeEnabled",null),e([n()],R.prototype,"columnReorderingEnabled",null),e([n({readOnly:!0})],R.prototype,"columns",null),e([n()],R.prototype,"disabled",void 0),e([n()],R.prototype,"editingEnabled",null),e([n()],R.prototype,"filterGeometry",null),e([n()],R.prototype,"filterBySelectionEnabled",null),e([n({readOnly:!0})],R.prototype,"grid",null),e([n()],R.prototype,"hiddenFields",null),e([n()],R.prototype,"highlightEnabled",null),e([n()],R.prototype,"highlightIds",null),e([n()],R.prototype,"icon",null),e([n()],R.prototype,"isQueryingOrSyncing",null),e([n()],R.prototype,"label",null),e([n()],R.prototype,"layer",null),e([n()],R.prototype,"layerView",null),e([n(),f("esri/widgets/FeatureTable/t9n/FeatureTable")],R.prototype,"messages",null),e([n(),f("esri/t9n/common")],R.prototype,"messagesCommon",null),e([n(),f("esri/widgets/support/t9n/uriUtils")],R.prototype,"messagesURIUtils",null),e([n()],R.prototype,"menuConfig",void 0),e([n()],R.prototype,"multipleSelectionEnabled",null),e([n()],R.prototype,"multiSortEnabled",null),e([n()],R.prototype,"objectIds",null),e([n()],R.prototype,"pageSize",null),e([n()],R.prototype,"relatedRecordsEnabled",null),e([n()],R.prototype,"relatedTable",null),e([n()],R.prototype,"relatedTables",void 0),e([n()],R.prototype,"relationship",null),e([n()],R.prototype,"relationshipColumnConfigs",null),e([n()],R.prototype,"relationshipConfig",null),e([n()],R.prototype,"returnGeometryEnabled",null),e([n()],R.prototype,"rowHighlightIds",null),e([n()],R.prototype,"selectionSource",null),e([n()],R.prototype,"showRelatedTableCallback",null),e([n()],R.prototype,"size",null),e([n({readOnly:!0})],R.prototype,"state",null),e([n({constructOnly:!0})],R.prototype,"tableParent",void 0),e([n()],R.prototype,"tableTemplate",null),e([n()],R.prototype,"tableTemplateOverride",null),e([n()],R.prototype,"title",void 0),e([n()],R.prototype,"timeExtent",null),e([n()],R.prototype,"timeZone",null),e([n()],R.prototype,"view",null),e([n({type:c}),_(["cell-click","cell-pointerover","cell-pointerout","cell-keydown","show-related-table"])],R.prototype,"viewModel",void 0),e([n({type:h,nonNullable:!0})],R.prototype,"visibleElements",void 0),e([n({type:h})],R.prototype,"visibleElementsOverride",void 0),R=S=e([r("esri.widgets.FeatureTable")],R);const j=R;export{j as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import t from"../core/Collection.js";import{watch as i,sync as l,initial as o,on as s}from"../core/reactiveUtils.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import a from"./Widget.js";import d from"./FeatureTable/ColumnMenuVisibleElements.js";import c from"./FeatureTable/FeatureTableViewModel.js";import h from"./FeatureTable/VisibleElements.js";import p from"./FeatureTable/support/FieldColumnTemplate.js";import m from"./FeatureTable/support/TableTemplate.js";import{uniqueColumnNames as u,isIFeatureTableSupportedLayerWithAttachments as g}from"./FeatureTable/support/tableUtils.js";import{loadCalciteComponents as b}from"./support/componentsUtils.js";import{globalCss as w}from"./support/globalCss.js";import{Heading as v}from"./support/Heading.js";import{renderingSanitizer as y}from"./support/widgetUtils.js";import{messageBundle as f}from"./support/decorators/messageBundle.js";import{vmEvent as _}from"./support/decorators/vmEvent.js";import{tsx as M}from"./support/jsxFactory.js";import{substitute as C}from"../intl/substitute.js";var S;const E="esri-feature-table",T=`${E}__prompt`,A={base:E,content:`${E}__content`,menuPopover:`${E}__menu-popover`,tableContainer:`${E}__table-container`,tableNavigation:`${E}__table-navigation`,expanded:`${E}__expanded`,collapsed:`${E}__collapsed`,promptContainer:T,promptHeader:`${T}__header`,promptHeading:`${T}__header__heading`,promptMessage:`${T}__message`,promptDivider:`${T}__divider`,promptActions:`${T}__actions`},I={clearSelection:"clear-selection",delete:"trash",refresh:"refresh",showAll:"selection-x",showSelected:"selection-filter",zoomToSelection:"zoom-to-object"};let R=S=class extends a{constructor(e,i){super(e,i),this._columnVisibilityActions=new Map,this._prompt=null,this._showAllTablesEnabled=!1,this.disabled=!1,this.menuConfig=null,this.relatedTables=new t,this.tableParent=null,this.title=null,this.viewModel=new c,this.visibleElements=new h,this.visibleElementsOverride=null,this._showDeletePrompt=this._showDeletePrompt.bind(this),this._onDeleteSelectionClick=this._onDeleteSelectionClick.bind(this)}initialize(){this.addHandles([i((()=>[this.viewModel.store.querying,this.viewModel.store.syncing,this.editingEnabled]),(()=>this.scheduleRender())),i((()=>({visibleElements:this._effectiveVisibleElements,items:this.columns.length})),(({visibleElements:e})=>{this.columns.forEach((t=>t.visibleElements=e)),this.refreshCellContent()}),l),i((()=>this._effectiveVisibleElements.selectionColumn),(e=>{this.grid&&(this.grid.selectionColumnEnabled=e)}),o),s((()=>this.viewModel),"show-related-table",(e=>this._onShowRelatedTable(e))),i((()=>this.viewModel.state),(e=>{"disabled"===e&&this.relatedTables.length&&this._drainRelatedTables()}))])}loadDependencies(){return b({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel.js"),popover:()=>import("@esri/calcite-components/dist/components/calcite-popover.js"),progress:()=>import("@esri/calcite-components/dist/components/calcite-progress.js"),scrim:()=>import("@esri/calcite-components/dist/components/calcite-scrim.js"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch.js"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip.js"),"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar.js"),dropdown:()=>import("@esri/calcite-components/dist/components/calcite-dropdown.js"),"dropdown-group":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-group.js"),"dropdown-item":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-item.js"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker.js"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker.js"),"input-time-zone":()=>import("@esri/calcite-components/dist/components/calcite-input-time-zone.js")})}destroy(){this._clearPrompt()}get _effectiveTitle(){const{layer:e,messages:t,state:i,highlightIds:l,title:o,viewModel:s}=this;if(o)return y.sanitize("function"==typeof o?o():o);if(!e)return t.noLayer;switch(i){case"disabled":return t.errorLayer;case"ready":return y.sanitize(e.title);case"loading":return t.loading;case"error":return t.errorData}return C(t.header,{title:y.sanitize(e.title),count:s.size,selected:l.length})}get _effectiveVisibleElements(){return this.visibleElementsOverride??this.visibleElements}get _hasCustomMenuItems(){return!!this.menuConfig?.items?.length}get _hasDefaultMenuItems(){return!!(this._showClearSelectionAction||this._showDeleteSelectionAction||this._showRefreshDataAction||this._showZoomToSelectionAction||this._showSelectedRecordsShowSelectedAction||this._showSelectedRecordsShowAllAction||this._showColumnsVisibilityAction)}get _shouldShowMenu(){const{header:e,menu:t}=this._effectiveVisibleElements;return!(!e||!t||!this._hasDefaultMenuItems&&!this._hasCustomMenuItems)}get _showClearSelectionAction(){return!(!this.highlightIds.length||!this._effectiveVisibleElements.menuItems?.clearSelection||this.relatedTables.length)}get _showColumnsVisibilityAction(){const{header:e,menu:t,menuItems:i}=this._effectiveVisibleElements;return!(!(e&&t&&i?.toggleColumns)||this.showRelatedTableCallback||this._showAllTablesEnabled)}get _showDeleteSelectionAction(){return!(!(this.editingEnabled&&this.highlightIds.length&&this._effectiveVisibleElements.menuItems?.deleteSelection&&this.layer?.capabilities?.operations?.supportsDelete)||this.relatedTables.length)}get _showRefreshDataAction(){return!!this._effectiveVisibleElements.menuItems?.refreshData}get _showSelectedRecordsShowSelectedAction(){const e=this.objectIds.length,t=this.highlightIds.length;return!(!t||!this._effectiveVisibleElements.menuItems?.selectedRecordsShowSelectedToggle||e&&t===e||this.relatedTables.length)}get _showSelectedRecordsShowAllAction(){return!(!this._effectiveVisibleElements.menuItems?.selectedRecordsShowAllToggle||!this.objectIds.length||this.relatedTables.length)}get _showZoomToSelectionAction(){return!!(this.view&&this.highlightIds.length&&this._effectiveVisibleElements.menuItems?.zoomToSelection)}get actionColumnConfig(){return this.viewModel.actionColumnConfig}set actionColumnConfig(e){this.viewModel.actionColumnConfig=e}get activeFilters(){return this.viewModel.activeFilters}get activeSortOrders(){return this.viewModel.activeSortOrders}get attachmentsEnabled(){return this.viewModel.attachmentsEnabled}set attachmentsEnabled(e){this.viewModel.attachmentsEnabled=e}get autoRefreshEnabled(){return this.viewModel.autoRefreshEnabled}set autoRefreshEnabled(e){this.viewModel.autoRefreshEnabled=e}get columnPerformanceModeEnabled(){return this.viewModel.columnPerformanceModeEnabled}set columnPerformanceModeEnabled(e){this.viewModel.columnPerformanceModeEnabled=e}get columnReorderingEnabled(){return this.viewModel.columnReorderingEnabled}set columnReorderingEnabled(e){this.viewModel.columnReorderingEnabled=e}get columns(){return this.viewModel.columns}get editingEnabled(){return this.viewModel.editingEnabled}set editingEnabled(e){this.viewModel.editingEnabled=e}get filterGeometry(){return this.viewModel.filterGeometry}set filterGeometry(e){this.viewModel.filterGeometry=e}get filterBySelectionEnabled(){return this.viewModel.filterBySelectionEnabled}set filterBySelectionEnabled(e){this.viewModel.filterBySelectionEnabled=e}get grid(){return this.viewModel.grid}get hiddenFields(){return this.viewModel.hiddenFields}set hiddenFields(e){this.viewModel.hiddenFields=e}get highlightEnabled(){return this.viewModel.highlightEnabled}set highlightEnabled(e){this.viewModel.highlightEnabled=e}get highlightIds(){return this.viewModel.highlightIds}set highlightIds(e){this.viewModel.highlightIds=e}get icon(){return"table"}set icon(e){this._overrideIfSome("icon",e)}get isQueryingOrSyncing(){return this.viewModel.isQueryingOrSyncing||this.relatedTables.some((e=>!!e.isQueryingOrSyncing))}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get layerView(){return this.viewModel.layerView}get messages(){return this.viewModel.messages}set messages(e){this.viewModel.messages=e}get messagesCommon(){return this.viewModel.messagesCommon}set messagesCommon(e){this.viewModel.messagesCommon=e}get messagesURIUtils(){return this.viewModel.messagesURIUtils}set messagesURIUtils(e){this.viewModel.messagesURIUtils=e}get multipleSelectionEnabled(){return this.viewModel.multipleSelectionEnabled}set multipleSelectionEnabled(e){this.viewModel.multipleSelectionEnabled=e}get multiSortEnabled(){return this.viewModel.multiSortEnabled}set multiSortEnabled(e){this.viewModel.multiSortEnabled=e}get objectIds(){return this.viewModel.objectIds}set objectIds(e){this.viewModel.objectIds=e}get pageSize(){return this.viewModel.pageSize}set pageSize(e){this.viewModel.pageSize=e}get relatedRecordsEnabled(){return this.viewModel.relatedRecordsEnabled}set relatedRecordsEnabled(e){this.viewModel.relatedRecordsEnabled=e}get relatedTable(){return this.relatedTables.at(-1)}get relationship(){return this.viewModel.relationship}get relationshipColumnConfigs(){return this.viewModel.relationshipColumnConfigs}set relationshipColumnConfigs(e){this.viewModel.relationshipColumnConfigs=e}get relationshipConfig(){return this.viewModel.relationshipConfig}set relationshipConfig(e){this.viewModel.relationshipConfig=e}get returnGeometryEnabled(){return this.viewModel.returnGeometryEnabled}set returnGeometryEnabled(e){this.viewModel.returnGeometryEnabled=e}get rowHighlightIds(){return this.viewModel.rowHighlightIds}set rowHighlightIds(e){this.viewModel.rowHighlightIds=e}get selectionSource(){return this.viewModel.selectionSource}set selectionSource(e){this.viewModel.selectionSource=e}get showRelatedTableCallback(){return this.viewModel.showRelatedTableCallback}set showRelatedTableCallback(e){this.viewModel.showRelatedTableCallback=e}get size(){return this.viewModel.size}get state(){return this.viewModel.state}get tableTemplate(){return this.viewModel.tableTemplate}set tableTemplate(e){this.viewModel.tableTemplate=e}get tableTemplateOverride(){return this.viewModel.tableTemplateOverride}set tableTemplateOverride(e){this.viewModel.tableTemplateOverride=e}get timeExtent(){return this.viewModel.timeExtent}set timeExtent(e){this.viewModel.timeExtent=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}clearSelectionFilter(){this.viewModel.clearSelectionFilter()}deleteSelection(e){return this.highlightIds.length?e?(this._showDeletePrompt(),this.scheduleRender(),Promise.resolve()):this.viewModel.deleteSelection():Promise.resolve()}filterBySelection(){this.viewModel.filterBySelection()}findColumn(e){return this.viewModel.findColumn(e)}hideColumn(e){this.grid?.hideColumn(e)}async refresh(){this.relatedTables.forEach((async e=>await e.refresh())),await this.viewModel.refresh()}refreshCellContent(){this.viewModel.refreshCellContent()}showAllColumns(){this.viewModel.showAllColumns()}showColumn(e){this.grid?.showColumn(e)}sortColumn(e,t){this.viewModel.sortColumn(e,t)}scrollToIndex(e){this.viewModel.scrollToIndex(e)}toggleColumnVisibility(e){this.viewModel.toggleColumnVisibility(e)}zoomToSelection(){this.viewModel.zoomToSelection()}render(){const{_prompt:e,_effectiveVisibleElements:t,isQueryingOrSyncing:i,menuConfig:l,state:o}=this;return M("div",{bind:this,class:this.classes(A.base,w.widget)},M("calcite-panel",{bind:this,class:A.content,closable:t.close,disabled:this.disabled||"disabled"===o,heading:t.header?this._effectiveTitle:void 0,loading:"loading"===o,menuOpen:!!l?.open,overlayPositioning:"fixed",onCalcitePanelClose:e=>{e.target.closed=!1,this.emit("close")}},t.progress?M("calcite-progress",{type:i?"indeterminate":"determinate"}):null,this._renderColumnVisibilityAction(),this._renderHeaderMenuActions(),this._renderRelatedTableNavigationBar(),M("div",{class:A.tableContainer},this._renderTables())),e?M("calcite-scrim",null,this._renderPrompt(e)):null)}_renderTables(){const{_showAllTablesEnabled:e,grid:t,relatedTables:i}=this;if(i.length){const l=i.toArray(),o=1===l.length,s=this.classes(A.base,e?A.expanded:A.collapsed),n=e||o,r=e?l:o?[l[0]]:l.slice(-2);return M("calcite-panel",null,M("div",null,[n?M("div",{class:s},t?.render()):void 0,...r.map((e=>{const t=i.indexOf(e);return M("div",{class:s,key:`related-${t}`},e.render())})),,]))}return t?.render()}_clearPrompt(){this._prompt=null}_renderPrompt({title:e,message:t,context:i,actions:l}){const o=M("calcite-button",{appearance:"solid",key:"prompt-primary-button",kind:"danger"===i?"danger":"brand",onclick:l.primary.action,width:l.secondary?"half":"full"},l.primary.label),s=l.secondary?M("calcite-button",{appearance:"outline",key:"prompt-secondary-button",kind:"danger"===i?"danger":"brand",onclick:l.secondary.action,width:"half"},l.secondary.label):null;return M("div",{class:`${A.promptContainer}--${i}`},M("div",{class:A.promptHeader},M("calcite-icon",{icon:"exclamation-mark-triangle"}),M(v,{class:A.promptHeading,level:2},e)),M("div",{class:A.promptMessage},t),M("div",{class:A.promptDivider}),M("div",{class:A.promptActions},s,o))}_showDeletePrompt(){const{messages:e,messagesCommon:t}=this,i=C(e.deleteSelectionCount,{count:this.highlightIds.length});this._prompt={title:i,message:e.deleteRecordsRemoved,context:"danger",actions:{primary:{label:t.delete,action:this._onDeleteSelectionClick},secondary:{label:e.keepRecords,action:()=>this._clearPrompt()}}}}async _onDeleteSelectionClick(){try{await this.viewModel.deleteSelection()}finally{this._clearPrompt()}}_renderHeaderMenuAction(e){const{disabled:t,hidden:i,icon:l,text:o,clickFunction:s}=e;if(!i)return M("calcite-action",{disabled:t??this.menuConfig?.disabled,icon:l??void 0,key:o,onclick:()=>s(),slot:"header-menu-actions",text:o,textEnabled:!0,title:o})}_renderHeaderMenuActions(){return this._shouldShowMenu?[this._renderDefaultHeaderMenuActions(),this._renderCustomHeaderMenuActions()]:[]}_renderDefaultHeaderMenuActions(){if(!this._hasDefaultMenuItems)return[];const{messages:e}=this,t=[];return this._showRefreshDataAction&&t.push(this._renderHeaderMenuAction({icon:I.refresh,text:e.refreshData,clickFunction:()=>this.refresh()})),this._showDeleteSelectionAction&&t.push(this._renderHeaderMenuAction({icon:I.delete,text:e.deleteSelection,clickFunction:()=>this.deleteSelection(!0)})),this._showClearSelectionAction&&t.push(this._renderHeaderMenuAction({icon:I.clearSelection,text:e.clearSelection,clickFunction:()=>this.highlightIds?.removeAll()})),this._showZoomToSelectionAction&&t.push(this._renderHeaderMenuAction({icon:I.zoomToSelection,text:e.zoomToSelection,clickFunction:()=>this.zoomToSelection()})),this._showSelectedRecordsShowSelectedAction&&t.push(this._renderHeaderMenuAction({icon:I.showSelected,text:e.showSelected,clickFunction:()=>{const{objectIds:e}=this;e.removeAll(),e.addMany(this.highlightIds.toArray())}})),this._showSelectedRecordsShowAllAction&&t.push(this._renderHeaderMenuAction({icon:I.showAll,text:e.showAllRecords,clickFunction:()=>this.objectIds.removeAll()})),t}_renderCustomHeaderMenuActions(){return this.menuConfig?.items?.map((({disabled:e,hidden:t,icon:i,label:l,clickFunction:o})=>this._renderHeaderMenuAction({hidden:"function"==typeof t?t():t,icon:i,text:l,disabled:e,clickFunction:e=>o(e)})))??[]}_renderColumnVisibilityAction(){if(!this._showColumnsVisibilityAction)return[];const{_columnVisibilityActions:e,_effectiveVisibleElements:t,id:i,messages:l}=this,o=this.relatedTables.at(-1)||this,s=o.columns.toArray(),n=l?.toggleColumns,r=`${i}__toggle-columns-action`,a=[M("calcite-action",{afterCreate:t=>e.set(i,t),afterRemoved:()=>e.delete(i),appearance:"transparent",bind:this,disabled:o.menuConfig?.disabled,icon:"show-column",id:r,slot:"header-actions-end",text:n},t.tooltips?M("calcite-tooltip",{closeOnClick:!0,overlayPositioning:"fixed",placement:"bottom-end",slot:"tooltip"},n):null)];return o.menuConfig?.disabled||a.push(M("calcite-popover",{autoClose:!0,class:A.menuPopover,label:n,overlayPositioning:"fixed",placement:"top-end",pointerDisabled:!0,referenceElement:e.get(i)},M("calcite-list",{filterEnabled:!0,selectionMode:"multiple"},...s.map((({effectiveLabel:e,fieldName:t,hidden:i})=>M("calcite-list-item",{key:`toggle-columns__item-${t}`,label:e,selected:!i,value:t,onCalciteListItemSelect:({target:e})=>o.toggleColumnVisibility(e.value)})))))),a}_onShowRelatedTable(e){if(this.showRelatedTableCallback)return;const{relatedTables:t}=this,{length:i}=t,l=i?t.getItemAt(i-1):this;this._collapseRelatedTable(l,e),this._createRelatedTable(e)}_renderRelatedTableNavigationBar(){const e=this.messages.exitRelatedRecords;if(this.relatedTables.length&&!this.showRelatedTableCallback)return M("div",{class:A.tableNavigation,key:"table-nav"},M("calcite-action",{icon:"move-up",key:e,onclick:()=>this._drainRelatedTables(),text:e,title:e}),this.relatedTables.toArray().map(((e,t)=>this._renderRelatedTableNavigationAction(e,t))),M("div",null,M("calcite-label",{layout:"inline"},"Show all tables",M("calcite-switch",{checked:this._showAllTablesEnabled,onCalciteSwitchChange:e=>{const{relatedTables:t}=this,i=!!e.target.checked,l=t.at(-1);this._showAllTablesEnabled=i,l&&(i?this._enterShowAllView(l):this._exitShowAllView(l))}}))))}_renderRelatedTableNavigationAction(e,t){const i=this._getLabelForRelatedTableNavigationAction(e);return M("calcite-action",{icon:"chevron-right",key:t,onclick:()=>this._drainRelatedTablesAboveIndex(t),text:i,textEnabled:!0,title:e.layer?.title||""})}_getLabelForRelatedTableNavigationAction(e){const t=e.layer?.title;if(!t)return"";const{relatedTables:i}=this;if(i.length<=1)return t;return i.indexOf(e)!==i.length-1&&t.length>20?`${t.slice(0,20)}...`:t}_drainRelatedTables(){this.relatedTables.drain((e=>!e.destroyed&&e.destroy())),this.set({_showAllTablesEnabled:!1,multipleSelectionEnabled:!0,tableTemplateOverride:null,relationshipColumnConfigs:null,visibleElementsOverride:null}),this.hiddenFields.removeMany([u.action,u.attachments])}_drainRelatedTablesAboveIndex(e){const t=this.relatedTables,i=t.filter(((t,i)=>i>e));i.forEach((e=>!e.destroyed&&e.destroy())),t.removeMany(i);const l=t.at(-1);if(!l?.layer||!l?.relationship)return;const{layer:o,relationship:s}=l;this._showAllTablesEnabled?this._enterShowAllView(l):l.set({multipleSelectionEnabled:!0,tableTemplateOverride:null,relationshipColumnConfigs:this._getRelationshipIdsToShow(o,s.id),visibleElementsOverride:null}),l.hiddenFields.removeMany([u.action,u.attachments])}_getRelatedTableMenuItemConfig(e,t,i){return t.fields.map((({alias:l,name:o})=>({selected:o===i,label:l||o,clickFunction:i=>{i.stopPropagation(),e.tableTemplateOverride=new m({columnTemplates:[this._createRelatedFieldColumnTemplate(e,t,o)]})}})))}_createRelatedFieldColumnTemplate(e,t,i){return new p({fieldName:i,editable:!1,menuConfig:{selectionMode:"single",icon:"chevron-down",items:this._getRelatedTableMenuItemConfig(e,t,i)},resizable:!1})}_enterShowAllView(e){const t=e.layer;if(!t)return;const i=e===this,{visibleElements:l}=e,o=t.displayField||t.objectIdField;e.set({relationshipColumnConfigs:[],tableTemplateOverride:new m({columnTemplates:[this._createRelatedFieldColumnTemplate(e,t,o)]}),visibleElementsOverride:new h({header:i&&l.header,progress:i&&l.progress,columnMenus:l.columnMenus,close:l.close,tooltips:l.tooltips,selectionColumn:!1,columnMenuItems:new d({sortAscending:!1,sortDescending:!1})})}),e.hiddenFields.addMany([u.action,u.attachments])}_exitShowAllView(e){const{layer:t,relationship:i}=e;t&&null!=i?.id&&(e.set({relationshipColumnConfigs:this._getRelationshipIdsToShow(t,i.id),tableTemplateOverride:null,visibleElementsOverride:null}),e.hiddenFields.removeMany([u.action,u.attachments]))}_collapseRelatedTable(e,i){const{relatedLayer:l,feature:o,relationshipId:s}=i,n=l.relationships?.find((({id:e})=>e===s)),{objectIdField:r}=l,a=l.displayField||n?.keyField||r,c=o.getObjectId()??o.attributes[r],p=e===this,{visibleElements:g}=e;e.set({highlightIds:new t([c]),multipleSelectionEnabled:!1,relationshipColumnConfigs:[{relationshipId:s,collapsed:!0}],tableTemplateOverride:new m({columnTemplates:[this._createRelatedFieldColumnTemplate(e,l,a)]}),visibleElementsOverride:new h({header:p&&g.header,progress:p&&g.progress,columnMenus:g.columnMenus,close:g.close,tooltips:g.tooltips,selectionColumn:!1,columnMenuItems:new d({sortAscending:!1,sortDescending:!1})})}),e.hiddenFields.addMany([u.action,u.attachments])}_getRelationshipIdsToShow(e,t){return(e.relationships??[]).filter((e=>!(e.id===t&&"one-to-one"===e.cardinality))).map((({id:e})=>({relationshipId:e})))}async _createRelatedTable(e){const{editingEnabled:t,relatedTables:i,view:l,viewModel:o}=this,{layer:n,feature:r,relatedLayer:a,relationshipId:d}=e,c=r.getObjectId()??r.attributes[a.objectIdField],p=i.length,m=p?i.getItemAt(p-1):this;await n.load();const u=this.attachmentsEnabled&&g(n),b=new S({layer:n,attachmentsEnabled:u,editingEnabled:t,relatedRecordsEnabled:!0,relationshipConfig:{objectId:c,relatedLayer:a,relationshipId:d},relationshipColumnConfigs:this._getRelationshipIdsToShow(n,d),tableParent:m,view:l,visibleElements:new h({header:!1,progress:!1}),showRelatedTableCallback:({feature:e,layer:t,relatedLayer:i,relationshipId:l})=>{null!=(e.getObjectId()??e.attributes[i.objectIdField])&&o.emit("show-related-table",{feature:e,layer:t,relatedLayer:i,relationshipId:l})}});b.addHandles([s((()=>m.highlightIds),"change",(({added:e})=>{const t=e[0];null!=t&&(b.highlightIds.removeAll(),b.relationshipConfig={objectId:t,relatedLayer:a,relationshipId:d})})),s((()=>m),"cell-click",(e=>{const{feature:t}=e;if(t){const e=t.getObjectId()??t.attributes[a.objectIdField];null!=e&&m.highlightIds.add(e)}}))]),this.relatedTables.add(b),this.scheduleRender()}};e([n()],R.prototype,"_columnVisibilityActions",void 0),e([n()],R.prototype,"_effectiveTitle",null),e([n()],R.prototype,"_effectiveVisibleElements",null),e([n()],R.prototype,"_hasCustomMenuItems",null),e([n()],R.prototype,"_hasDefaultMenuItems",null),e([n()],R.prototype,"_prompt",void 0),e([n()],R.prototype,"_shouldShowMenu",null),e([n()],R.prototype,"_showAllTablesEnabled",void 0),e([n()],R.prototype,"_showClearSelectionAction",null),e([n()],R.prototype,"_showColumnsVisibilityAction",null),e([n()],R.prototype,"_showDeleteSelectionAction",null),e([n()],R.prototype,"_showRefreshDataAction",null),e([n()],R.prototype,"_showSelectedRecordsShowSelectedAction",null),e([n()],R.prototype,"_showSelectedRecordsShowAllAction",null),e([n()],R.prototype,"_showZoomToSelectionAction",null),e([n()],R.prototype,"actionColumnConfig",null),e([n({readOnly:!0})],R.prototype,"activeFilters",null),e([n({readOnly:!0})],R.prototype,"activeSortOrders",null),e([n()],R.prototype,"attachmentsEnabled",null),e([n()],R.prototype,"autoRefreshEnabled",null),e([n()],R.prototype,"columnPerformanceModeEnabled",null),e([n()],R.prototype,"columnReorderingEnabled",null),e([n({readOnly:!0})],R.prototype,"columns",null),e([n()],R.prototype,"disabled",void 0),e([n()],R.prototype,"editingEnabled",null),e([n()],R.prototype,"filterGeometry",null),e([n()],R.prototype,"filterBySelectionEnabled",null),e([n({readOnly:!0})],R.prototype,"grid",null),e([n()],R.prototype,"hiddenFields",null),e([n()],R.prototype,"highlightEnabled",null),e([n()],R.prototype,"highlightIds",null),e([n()],R.prototype,"icon",null),e([n()],R.prototype,"isQueryingOrSyncing",null),e([n()],R.prototype,"label",null),e([n()],R.prototype,"layer",null),e([n()],R.prototype,"layerView",null),e([n(),f("esri/widgets/FeatureTable/t9n/FeatureTable")],R.prototype,"messages",null),e([n(),f("esri/t9n/common")],R.prototype,"messagesCommon",null),e([n(),f("esri/widgets/support/t9n/uriUtils")],R.prototype,"messagesURIUtils",null),e([n()],R.prototype,"menuConfig",void 0),e([n()],R.prototype,"multipleSelectionEnabled",null),e([n()],R.prototype,"multiSortEnabled",null),e([n()],R.prototype,"objectIds",null),e([n()],R.prototype,"pageSize",null),e([n()],R.prototype,"relatedRecordsEnabled",null),e([n()],R.prototype,"relatedTable",null),e([n()],R.prototype,"relatedTables",void 0),e([n()],R.prototype,"relationship",null),e([n()],R.prototype,"relationshipColumnConfigs",null),e([n()],R.prototype,"relationshipConfig",null),e([n()],R.prototype,"returnGeometryEnabled",null),e([n()],R.prototype,"rowHighlightIds",null),e([n()],R.prototype,"selectionSource",null),e([n()],R.prototype,"showRelatedTableCallback",null),e([n()],R.prototype,"size",null),e([n({readOnly:!0})],R.prototype,"state",null),e([n({constructOnly:!0})],R.prototype,"tableParent",void 0),e([n()],R.prototype,"tableTemplate",null),e([n()],R.prototype,"tableTemplateOverride",null),e([n()],R.prototype,"title",void 0),e([n()],R.prototype,"timeExtent",null),e([n()],R.prototype,"timeZone",null),e([n()],R.prototype,"view",null),e([n({type:c}),_(["cell-click","cell-pointerover","cell-pointerout","cell-keydown","show-related-table"])],R.prototype,"viewModel",void 0),e([n({type:h,nonNullable:!0})],R.prototype,"visibleElements",void 0),e([n({type:h})],R.prototype,"visibleElementsOverride",void 0),R=S=e([r("esri.widgets.FeatureTable")],R);const j=R;export{j as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import{property as t}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import s from"../Widget.js";import{css as i}from"./css.js";import{loadCalciteComponents as r}from"../support/componentsUtils.js";import"../support/widgetUtils.js";import{messageBundle as l}from"../support/decorators/messageBundle.js";import{tsx as c,tsxFragment as a}from"../support/jsxFactory.js";let n=class extends s{constructor(e,t){super(e,t),this.messages=null,this.closed=!1,this.closable=!0,this._handleOpenRelatedFeature=e=>{this.emit("open-related-feature",{feature:e})}}loadDependencies(){return r({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item.js")})}render(){const{flowItems:e}=this,t=e?.toArray();return c(a,null,t?.map((e=>this._renderRelatedRecordsFlowItem(e))))}_handleCloseClick(){this.emit("close")}_handleExitClick(){this.emit("exit")}_handleRelatedRecordsBackClick(){const e=this.flowItems?.pop();e&&("showAllEnabled"in e.viewModel&&(e.viewModel.showAllEnabled=!1),e&&(e.viewModel=null,e.destroy()))}_renderRelatedRecordsFlowItem(e){const{messages:t,closable:o,closed:s}=this,r="graphic"in e&&!e.isTable,l=t.exitRelatedRecords,a=t.selectFeature;return c("calcite-flow-item",{bind:this,closable:o,closed:s,description:this._getRelatedRecordsFlowItemDescription(e),heading:e.title??"",key:`flow-item-${e.viewModel.uid}`,onCalciteFlowItemBack:e=>{e.preventDefault(),this._handleRelatedRecordsBackClick()},onCalciteFlowItemClose:this._handleCloseClick},c("calcite-action",{appearance:"transparent",bind:this,class:i.actionExit,icon:"move-up",key:"exit-related-records-action",onclick:this._handleExitClick,slot:"header-actions-start",text:l,title:l}),r?c("calcite-action",{appearance:"transparent",bind:this,icon:"zoom-to-object",key:"open-related-feature-action",onclick:()=>this._handleOpenRelatedFeature(e),slot:"header-actions-end",text:a,title:a}):null,c("div",{class:i.container},e.render()))}_getRelatedRecordsFlowItemDescription(e){return"featureCountDescription"in e?e.featureCountDescription:e.viewModel.description??""}};e([t()],n.prototype,"flowItems",void 0),e([t(),l("esri/widgets/Features/t9n/Features")],n.prototype,"messages",void 0),e([t()],n.prototype,"closed",void 0),e([t()],n.prototype,"closable",void 0),n=e([o("esri.widgets.Features.FeaturesRelatedRecords")],n);const d=n;export{d as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import{property as t}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import s from"../Widget.js";import{css as i}from"./css.js";import{loadCalciteComponents as r}from"../support/componentsUtils.js";import"../support/widgetUtils.js";import{messageBundle as l}from"../support/decorators/messageBundle.js";import{tsx as c,tsxFragment as a}from"../support/jsxFactory.js";let n=class extends s{constructor(e,t){super(e,t),this.messages=null,this.closed=!1,this.closable=!0,this._handleOpenRelatedFeature=e=>{this.emit("open-related-feature",{feature:e})}}loadDependencies(){return r({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item.js")})}render(){const{flowItems:e}=this,t=e?.toArray();return c(a,null,t?.map((e=>this._renderRelatedRecordsFlowItem(e))))}_handleCloseClick(){this.emit("close")}_handleExitClick(){this.emit("exit")}_handleRelatedRecordsBackClick(){const e=this.flowItems?.pop();e&&("showAllEnabled"in e.viewModel&&(e.viewModel.showAllEnabled=!1),e&&(e.viewModel=null,e.destroy()))}_renderRelatedRecordsFlowItem(e){const{messages:t,closable:o,closed:s}=this,r="graphic"in e&&!e.isTable&&e.graphic?.geometry,l=t.exitRelatedRecords,a=t.selectFeature;return c("calcite-flow-item",{bind:this,closable:o,closed:s,description:this._getRelatedRecordsFlowItemDescription(e),heading:e.title??"",key:`flow-item-${e.viewModel.uid}`,onCalciteFlowItemBack:e=>{e.preventDefault(),this._handleRelatedRecordsBackClick()},onCalciteFlowItemClose:this._handleCloseClick},c("calcite-action",{appearance:"transparent",bind:this,class:i.actionExit,icon:"move-up",key:"exit-related-records-action",onclick:this._handleExitClick,slot:"header-actions-start",text:l,title:l}),r?c("calcite-action",{appearance:"transparent",bind:this,icon:"zoom-to-object",key:"open-related-feature-action",onclick:()=>this._handleOpenRelatedFeature(e),slot:"header-actions-end",text:a,title:a}):null,c("div",{class:i.container},e.render()))}_getRelatedRecordsFlowItemDescription(e){return"featureCountDescription"in e?e.featureCountDescription:e.viewModel.description??""}};e([t()],n.prototype,"flowItems",void 0),e([t(),l("esri/widgets/Features/t9n/Features")],n.prototype,"messages",void 0),e([t()],n.prototype,"closed",void 0),e([t()],n.prototype,"closable",void 0),n=e([o("esri.widgets.Features.FeaturesRelatedRecords")],n);const d=n;export{d as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- const i={hide:"hide",hideChildren:"hide-children"},e=10,n=2;function t({exclusive:i,visible:e,visibilityAppearance:n}){const t="checkbox"===n;return e?i?"circle-f":t?"check-square-f":"view-visible":i?"circle":t?"square":"view-hide"}function r({connectionStatus:i,publishing:e}){return i?"connected"===i?"beacon":"offline":e?"square":"bullet-point"}function l(e){return e?.listMode===i.hideChildren}function u(i){return i?.listMode??void 0}function s(i){if(!i)return"inherited";const e=h(b(i)?i.layer:i);return null!=e?e?"independent":"inherited":"visibilityMode"in i&&null!=i.visibilityMode?i.visibilityMode:"independent"}function a(i){if(i&&(!("type"in i)||"wmts"!==i.type))return"sublayers"in i?"sublayers":"layers"in i?"layers":void 0}function o(i){const e=(i?.layer&&b(i.layer)?i.layer.layer:void 0)??i?.layer;return!!e&&(v(e)??!0)}function c(e){return u(e)!==i.hide}function y(i,e){i?.sort(((i,n)=>{const t="uid"in i?e.indexOf(i.uid):-1,r="uid"in n?e.indexOf(n.uid):-1;return t>r?-1:t<r?1:0}))}function d(i,e){const n=i?.layer;if(!n)return;const t=a(n);if(!t)return;let r;"layers"===t&&"layers"in n?r=n.layers:"sublayers"===t&&"sublayers"in n&&(r=n.sublayers),y(r,e)}function p(i){const e=i?.layer;return e&&"layers"in e?e.layers:null}function f(i){const e=b(i)?i:null,n=i?.parent,t=null!=n&&"type"in n&&"map-image"===n.type?e?.source:null,r="";return t&&n?{layer:n,title:r,sublayerIds:[t.mapLayerId]}:{layer:i,title:r}}function b(i){return null!=i&&"layer"in i&&null!=i.layer}function h(i){const e=m(i);return null!=e&&"supportsSublayerVisibility"in e?e.supportsSublayerVisibility:void 0}function v(i){const e=m(i);return null!=e&&"supportsDynamicLayers"in e?e.supportsDynamicLayers:void 0}function m(i){return i&&"capabilities"in i&&null!=i.capabilities&&"exportMap"in i.capabilities?i.capabilities.exportMap:void 0}function x(i){return i?.["data-item"]}function M(i){return i?.getAttribute("data-layer-type")}function g({children:i,error:e,incompatible:n}){return!!i?.filter((i=>!i.hidden)).length&&!e&&!n}export{l as areChildrenHidden,c as canDisplayLayer,o as canSortSublayers,u as findLayerListMode,s as findLayerVisibilityMode,x as getItem,p as getItemLayers,M as getLayerType,f as getLegendLayerInfo,a as getNormalizedChildLayerProperty,r as getStatusIcon,t as getVisibilityIcon,b as isSublayer,g as listItemHasChildren,n as minDragEnabledItems,e as minFilterItems,d as sortChildLayersToIds,y as sortLayersToIds};
5
+ const i={hide:"hide",hideChildren:"hide-children"},e=10,n=2;function t({exclusive:i,visible:e,visibilityAppearance:n}){const t="checkbox"===n;return e?i?"circle-f":t?"check-square-f":"view-visible":i?"circle":t?"square":"view-hide"}function r({connectionStatus:i,publishing:e}){return i?"connected"===i?"beacon":"offline":e?"square":"bullet-point"}function l(e){return e?.listMode===i.hideChildren}function u(i){return i?.listMode??void 0}function s(i){if(!i)return"inherited";const e=h(b(i)?i.layer:i);return null!=e?e?"independent":"inherited":"visibilityMode"in i&&null!=i.visibilityMode?i.visibilityMode:"independent"}function a(i){if(i&&(!("type"in i)||"wmts"!==i.type))return"sublayers"in i?"sublayers":"layers"in i?"layers":void 0}function o(i){const e=(i?.layer&&b(i.layer)?i.layer.layer:void 0)??i?.layer;return!!e&&("catalog"!==e.type&&(v(e)??!0))}function c(e){return u(e)!==i.hide}function y(i,e){i?.sort(((i,n)=>{const t="uid"in i?e.indexOf(i.uid):-1,r="uid"in n?e.indexOf(n.uid):-1;return t>r?-1:t<r?1:0}))}function d(i,e){const n=i?.layer;if(!n)return;const t=a(n);if(!t)return;let r;"layers"===t&&"layers"in n?r=n.layers:"sublayers"===t&&"sublayers"in n&&(r=n.sublayers),y(r,e)}function p(i){const e=i?.layer;return e&&"layers"in e?e.layers:null}function f(i){const e=b(i)?i:null,n=i?.parent,t=null!=n&&"type"in n&&"map-image"===n.type?e?.source:null,r="";return t&&n?{layer:n,title:r,sublayerIds:[t.mapLayerId]}:{layer:i,title:r}}function b(i){return null!=i&&"layer"in i&&null!=i.layer}function h(i){const e=m(i);return null!=e&&"supportsSublayerVisibility"in e?e.supportsSublayerVisibility:void 0}function v(i){const e=m(i);return null!=e&&"supportsDynamicLayers"in e?e.supportsDynamicLayers:void 0}function m(i){return i&&"capabilities"in i&&null!=i.capabilities&&"exportMap"in i.capabilities?i.capabilities.exportMap:void 0}function x(i){return i?.["data-item"]}function M(i){return i?.getAttribute("data-layer-type")}function g({children:i,error:e,incompatible:n}){return!!i?.filter((i=>!i.hidden)).length&&!e&&!n}export{l as areChildrenHidden,c as canDisplayLayer,o as canSortSublayers,u as findLayerListMode,s as findLayerVisibilityMode,x as getItem,p as getItemLayers,M as getLayerType,f as getLegendLayerInfo,a as getNormalizedChildLayerProperty,r as getStatusIcon,t as getVisibilityIcon,b as isSublayer,g as listItemHasChildren,n as minDragEnabledItems,e as minFilterItems,d as sortChildLayersToIds,y as sortLayersToIds};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import t from"../core/Collection.js";import{deprecatedProperty as i}from"../core/deprecate.js";import{IdentifiableMixin as o}from"../core/Identifiable.js";import l from"../core/Logger.js";import s from"../core/ReactiveMap.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as a}from"../core/accessorSupport/decorators/subclass.js";import{getActionIcon as r,getActionStyles as c}from"../support/actions/actionUtils.js";import d from"./Widget.js";import{css as m}from"./LayerList/css.js";import p from"./LayerList/LayerListViewModel.js";import h from"./LayerList/LayerListVisibleElements.js";import g from"./LayerList/ListItem.js";import{minDragEnabledItems as u,minFilterItems as y,getItem as _,getLayerType as f,listItemHasChildren as v,areChildrenHidden as I,canSortSublayers as b,getStatusIcon as w,sortLayersToIds as L,sortChildLayersToIds as F,getVisibilityIcon as C}from"./LayerList/support/layerListUtils.js";import{loadCalciteComponents as E}from"./support/componentsUtils.js";import{globalCss as k}from"./support/globalCss.js";import"./support/widgetUtils.js";import{messageBundle as A}from"./support/decorators/messageBundle.js";import{vmEvent as M}from"./support/decorators/vmEvent.js";import{tsx as T}from"./support/jsxFactory.js";const G=t.ofType(g);let j=class extends(o(d)){constructor(e,t){super(e,t),this._activeItem=null,this._tooltipReferenceMap=new s,this._focusRootFlowItem=!1,this._focusPanelFlowItem=!1,this._focusKnowledgeGraphFlowItem=!1,this._focusCatalogFlowItem=!1,this._knowledgeGraphFlowItem=null,this._catalogFlowItem=null,this._lastDragDetail=null,this._selectedDragItemLayerUid=null,this._rootGroupUid=`operational-${this.uid}`,this.catalogLayerList=null,this.catalogOptions=null,this.collapsed=!1,this.dragEnabled=!1,this.filterPlaceholder="",this.filterText="",this.headingLevel=2,this.knowledgeGraphTableList=null,this.knowledgeGraphOptions=null,this.listItemCanGiveFunction=null,this.listItemCanReceiveFunction=null,this.messages=null,this.messagesCommon=null,this.minDragEnabledItems=u,this.minFilterItems=y,this.selectedItems=new G,this.selectionMode="none",this.viewModel=new p,this.visibilityAppearance="default",this.visibleElements=new h,this._canMove=({dragEl:e,fromEl:t,toEl:i},o)=>{const l="pull"===o?this.listItemCanGiveFunction:this.listItemCanReceiveFunction,s=_(e);if(!s?.sortable)return!1;const n=_(t),a=f(t),r=_(i),c=f(i),d=!!a&&!!c&&a===c,m={selected:s,from:n,to:r},p=t.group,h=i.group,g=n?.layer?.type,u=r?.layer?.type,y=new Set(["map-image","catalog","knowledge-graph"]),v="sublayer";return p&&h&&"function"==typeof l?l.call(null,m):d&&!!g&&!!u&&!y.has(g)&&!y.has(u)&&s?.layer?.type!==v},this._clearActiveItem=()=>{this._activeItem=null},this._setActiveItem=e=>{if("default"!==this.visibilityAppearance)return;const t=Array.from(e.composedPath()).find((e=>e.classList?.contains(m.item)));this._activeItem=_(t)},this._onCalciteListOrderChange=e=>{const{_lastDragDetail:t}=this,{toEl:i,fromEl:o,dragEl:l,newIndex:s}=e;if(o&&i&&!(t?.newIndex===s&&t?.dragEl===l&&t?.toEl===i&&t?.fromEl===o))if(this._lastDragDetail=e,o!==i)this._moveLayerFromChildList({toEl:i,fromEl:o,dragEl:l,newIndex:s});else{const e=Array.from(o.children).filter((e=>e?.matches("calcite-list-item"))).map((e=>e.value));this._sortLayers(o,e)}}}loadDependencies(){return E({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group.js"),"action-menu":()=>import("@esri/calcite-components/dist/components/calcite-action-menu.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow.js"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip.js")})}destroy(){this._destroyKnowledgeGraph(),this._tooltipReferenceMap.clear()}get _dragEnabled(){return this.viewModel.totalItems>=this.minDragEnabledItems&&this.dragEnabled}get _filterEnabled(){return this.viewModel.totalItems>=this.minFilterItems&&this.visibleElements.filter}get icon(){return"layers"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get listItemCreatedFunction(){return this.viewModel.listItemCreatedFunction}set listItemCreatedFunction(e){this.viewModel.listItemCreatedFunction=e}get multipleSelectionEnabled(){return i(l.getLogger(this),"multipleSelectionEnabled",{replacement:"selectionMode",version:"4.29",warnOnce:!0}),"multiple"===this.selectionMode}set multipleSelectionEnabled(e){i(l.getLogger(this),"multipleSelectionEnabled",{replacement:"selectionMode",version:"4.29",warnOnce:!0}),this.selectionMode=e?"multiple":this.selectionEnabled?"single":"none"}get operationalItems(){return this.viewModel.operationalItems}set operationalItems(e){this.viewModel.operationalItems=e}get selectionEnabled(){return i(l.getLogger(this),"selectionEnabled",{replacement:"selectionMode, dragEnabled",version:"4.29",warnOnce:!0}),"none"!==this.selectionMode&&this.dragEnabled}set selectionEnabled(e){i(l.getLogger(this),"selectionEnabled",{replacement:"selectionMode, dragEnabled",version:"4.29",warnOnce:!0}),this.dragEnabled=e,this.selectionMode=e?this.multipleSelectionEnabled?"multiple":"single":"none"}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}triggerAction(e,t){return this.viewModel.triggerAction(e,t)}render(){const e=this.viewModel?.state,t={[k.hidden]:"loading"===e,[k.disabled]:"disabled"===e},i=this.operationalItems?.filter((e=>!e.hidden&&(this.visibleElements.errors||!e.error)));return T("div",{class:this.classes(m.base,k.widget,k.panel,t)},i?.length?[this._renderItemTooltips(i),this._renderItems(i)]:this._renderNoItems())}_renderItemTooltip(e){const{_tooltipReferenceMap:t,messages:i}=this;return e?T("calcite-tooltip",{key:`tooltip-${e.layer.uid}`,referenceElement:t.get(e.layer.uid)},i.layerIncompatibleTooltip):null}_renderItemTooltipNodes(e){return e.incompatible?this._renderItemTooltip(e):e.children?.filter((e=>!e.hidden)).toArray().map((e=>this._renderItemTooltipNodes(e)))}_renderItemTooltips(e){return e?.toArray().map((e=>this._renderItemTooltipNodes(e)))}_renderNoItemsMessage(){return T("div",{slot:"message"},this.messages.noItemsToDisplay)}_renderNoItems(){return T("div",{class:m.itemMessage,key:"esri-layer-list__no-items"},T("calcite-notice",{icon:"information",kind:"info",open:!0,width:"full"},this._renderNoItemsMessage()))}_destroyCatalog(){this._catalogFlowItem=null,this._focusRootFlowItem=!0,this.catalogLayerList?.destroy(),this._set("catalogLayerList",null)}_destroyKnowledgeGraph(){this._knowledgeGraphFlowItem=null,this._focusRootFlowItem=!0,this.knowledgeGraphTableList?.destroy(),this._set("knowledgeGraphTableList",null)}async _createCatalog(){const{default:e}=await import("./CatalogLayerList.js"),{headingLevel:t,catalogOptions:i,view:o,filterPlaceholder:l,listItemCreatedFunction:s,minFilterItems:n,selectionMode:a,visibilityAppearance:r}=this,c=this._catalogFlowItem?.layer;this._set("catalogLayerList",new e({headingLevel:t,view:o,filterPlaceholder:l,listItemCreatedFunction:s,minFilterItems:n,selectionMode:a,visibilityAppearance:r,...i,catalogLayer:c}))}async _createKnowledgeGraph(){const{default:e}=await import("./TableList.js"),t=this._knowledgeGraphFlowItem?.layer;if("knowledge-graph"!==t?.type||!t.tables.length)return;const{headingLevel:i,knowledgeGraphOptions:o,selectionMode:l,dragEnabled:s}=this;this._set("knowledgeGraphTableList",new e({headingLevel:i,selectionMode:l,dragEnabled:s,...o,tables:t.tables}))}_renderCatalogFlowItem(){const{_catalogFlowItem:e,messages:t}=this;if(!e)return null;const i=this._getLayerTitle(e);return T("calcite-flow-item",{afterCreate:this._focusCatalogFlowItemNode,afterUpdate:this._focusCatalogFlowItemNode,bind:this,description:i,heading:t.catalogLayers,headingLevel:this.headingLevel,key:`flow-catalog-${e.uid}`,onCalciteFlowItemBack:e=>{e.preventDefault(),this._destroyCatalog()}},this.catalogLayerList?.render())}_renderKnowledgeGraphFlowItem(){const{_knowledgeGraphFlowItem:e,messages:t}=this;if(!e)return null;const i=this._getLayerTitle(e);return T("calcite-flow-item",{afterCreate:this._focusKnowledgeGraphFlowItemNode,afterUpdate:this._focusKnowledgeGraphFlowItemNode,bind:this,description:i,heading:t.tables,headingLevel:this.headingLevel,key:`flow-knowledge-graph-${e.uid}`,onCalciteFlowItemBack:e=>{e.preventDefault(),this._destroyKnowledgeGraph()}},this.knowledgeGraphTableList?.render())}_renderPanelFlowItems(e){return e?e.flatten((e=>e.children)).filter((({hidden:e,panel:t})=>!e&&t?.open&&!t.disabled&&t.flowEnabled)).toArray().map((({title:e,panel:t})=>{const i=()=>this._handlePanelFlowItemBack(t);return T("calcite-flow-item",{afterCreate:this._focusPanelFlowItemNode,afterUpdate:this._focusPanelFlowItemNode,bind:this,description:e,heading:t.title,headingLevel:this.headingLevel,key:`flow-panel-${t.uid}`,onCalciteFlowItemBack:e=>{e.preventDefault(),i()}},t.render(),T("calcite-button",{appearance:"transparent",onclick:i,slot:"footer-actions",width:"full"},this.messagesCommon.back))})):[]}_handlePanelFlowItemBack(e){e.open=!1,this._focusRootFlowItem=!0}_focusRootFlowItemNode(e){this._focusRootFlowItem&&(this._focusRootFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_focusCatalogFlowItemNode(e){this._focusCatalogFlowItem&&(this._focusCatalogFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_focusKnowledgeGraphFlowItemNode(e){this._focusKnowledgeGraphFlowItem&&(this._focusKnowledgeGraphFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_focusPanelFlowItemNode(e){this._focusPanelFlowItem&&(this._focusPanelFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_renderItems(e){const{visible:t,collapsed:i,_filterEnabled:o,_rootGroupUid:l,visibleElements:{closeButton:s,collapseButton:n,heading:a,flow:r},_dragEnabled:c,selectionMode:d,filterText:p,filterPlaceholder:h,messages:g}=this,u=[T("calcite-flow-item",{afterCreate:this._focusRootFlowItemNode,afterUpdate:this._focusRootFlowItemNode,bind:this,closable:s,closed:!t,collapsed:i,collapsible:n,heading:a?g.widgetLabel:void 0,headingLevel:this.headingLevel,key:"root-flow-item",onCalciteFlowItemClose:()=>this.visible=!1},T("calcite-list",{afterCreate:e=>{e.addEventListener("focusin",this._setActiveItem),e.addEventListener("focusout",this._clearActiveItem)},afterRemoved:e=>{e.removeEventListener("focusin",this._setActiveItem),e.removeEventListener("focusout",this._clearActiveItem)},canPull:e=>this._canMove(e,"pull"),canPut:e=>this._canMove(e,"put"),"data-layer-type":l,dragEnabled:c,filterEnabled:o,filterPlaceholder:h,filterText:o?p:"",group:l,key:"root-list",label:g.widgetLabel,onmouseleave:this._clearActiveItem,onmouseover:this._setActiveItem,selectionAppearance:"border",selectionMode:d,onCalciteListChange:e=>this._handleCalciteListChange(e),onCalciteListDragEnd:e=>this._handleCalciteListDragEnd(e.detail),onCalciteListFilter:e=>this.filterText=e.target?.filterText??"",onCalciteListOrderChange:e=>this._onCalciteListOrderChange(e.detail)},e?.toArray().map((e=>this._renderItem(e))),e?.length&&o?T("div",{class:m.filterNoResults,slot:"filter-no-results"},T("calcite-notice",{kind:"info",open:!0,width:"full"},this._renderNoItemsMessage())):null)),this._renderPanelFlowItems(e),this._renderKnowledgeGraphFlowItem(),this._renderCatalogFlowItem()];return t?r?T("calcite-flow",{key:"root-flow"},u):u:null}_renderChildList(e,t=[]){const{_dragEnabled:i,_rootGroupUid:o,viewModel:{listModeDisabled:l},messages:s,selectionMode:n}=this,{children:a}=e,r="catalog-dynamic-group"!==e.layer?.type&&v(e),c=!(!l&&I(e.layer))&&!r&&i&&"group"===e.layer?.type;return r||c?T("calcite-list",{canPull:e=>this._canMove(e,"pull"),canPut:e=>this._canMove(e,"put"),"data-item":e,"data-layer-type":o,dragEnabled:!!i&&(e.childrenSortable&&b(e)),group:`${o}-${e.layer.uid}`,key:`child-list-${e.layer.uid}`,selectionAppearance:"border",selectionMode:n},a?.filter((e=>!e.hidden)).toArray().map((i=>this._renderItem(i,e,[...t,e.title]))),"knowledge-graph"===e.layer?.type&&e.layer.tables?.length?T("calcite-list-item",{class:m.item,"data-layer-id":e.layer.id,dragDisabled:!0,key:`list-item-knowledge-graph-tables-${e.layer.uid}`,title:s.tables,onCalciteListItemSelect:()=>{this._knowledgeGraphFlowItem=e,this._focusKnowledgeGraphFlowItem=!0,this._createKnowledgeGraph()}},T("div",{class:m.itemContent,slot:"content"},s.tables),T("calcite-icon",{class:m.itemTableIcon,icon:"table",scale:"s",slot:"content-start"}),T("calcite-icon",{flipRtl:!0,icon:"chevron-right",scale:"s",slot:"content-end"})):null):null}_renderItemMessage(e){return e.error?T("div",{class:m.itemMessage,key:"esri-layer-list__error",slot:"content-bottom"},T("calcite-notice",{icon:"exclamation-mark-triangle",kind:"warning",open:!0,scale:"s",width:"full"},T("div",{slot:"message"},this.messages.layerError))):e.incompatible?T("div",{class:m.itemMessage,key:"esri-layer-list__incompatible",slot:"content-bottom"},T("calcite-notice",{afterCreate:t=>this._setTooltipReference(t,e),afterRemoved:()=>this._removeTooltipReference(e),bind:this,icon:"exclamation-mark-triangle",kind:"warning",open:!0,scale:"s",tabIndex:0,width:"full"},T("div",{slot:"message"},this.messages.layerIncompatible))):null}_getLayerTitle(e){return e.title||this.messages.untitledLayer}_renderItem(e,t,i){const{_activeItem:o,_selectedDragItemLayerUid:l,selectionMode:s,selectedItems:n,messages:a,visibleElements:r}=this,c=this._getLayerTitle(e),d=e.visibleAtCurrentTimeExtent?e.visibleAtCurrentScale?c:`${c} (${a.layerInvisibleAtScale})`:`${c} (${a.layerInvisibleAtTime})`,p=this._filterActions(e.actionsSections),h=this._countActions(p),g="catalog"===e.parent?.layer?.type,u="catalog-footprint"===e.layer?.type,y="catalog-dynamic-group"===e.layer?.type,_=u?T("calcite-icon",{class:m.itemCatalogIcon,icon:"footprint",key:"footprint",scale:"s",slot:"content-start"}):null,f=y?T("calcite-icon",{class:m.itemCatalogIcon,icon:"catalog-dataset",key:"catalog-dataset",scale:"s",slot:"content-start"}):null,v=r.catalogLayerList&&y?T("calcite-action",{appearance:"transparent",disabled:!e.layer.visible,icon:"chevron-right",iconFlipRtl:!0,onclick:()=>{this._catalogFlowItem=t,this._focusCatalogFlowItem=!0,this._createCatalog()},scale:"s",slot:"actions-end",text:c}):null;return T("calcite-list-item",{afterCreate:t=>this._focusSelectedDragEl(t,e),afterUpdate:t=>this._focusSelectedDragEl(t,e),class:this.classes(m.item,{[m.itemActive]:o===e}),"data-item":e,"data-layer-id":e.layer.id,dragDisabled:!e.sortable||g,dragSelected:e.layer.uid===l,id:e.layer.uid,key:`list-item-${e.layer.uid}`,label:c,metadata:{parentTitles:i,title:c},open:e.open,selected:"none"!==s&&n.includes(e),title:d,value:e.layer.uid,onCalciteListItemDragHandleChange:t=>this._handleCalciteListItemDragHandleChange(t,e),onCalciteListItemSelect:i=>this._handleCalciteListItemSelect(i,e,t),onCalciteListItemToggle:t=>this._handleCalciteListItemToggle(t,e)},_,f,T("div",{class:this.classes({[m.itemContent]:!0,[m.itemInvisible]:!e.visibleAtCurrentScale||!e.visibleAtCurrentTimeExtent}),slot:"content"},c),this._renderItemStatus(e,t),this._renderItemToggle(e,t),v,this._renderItemTemporaryIcon(e),this._renderChildList(e,i),this._renderItemMessage(e),this._renderPanel(e.panel),this._renderPanelAction(e.panel),h>1?this._renderActionsSections(e,p):1===h?this._renderAction({item:e,action:this._getSingleAction(p),textEnabled:!1}):null)}_renderItemStatus(e,t){const{visibleElements:i}=this;if(!i.statusIndicators)return null;const{connectionStatus:o,publishing:l,updating:s}=e,n=s&&!t,a=!!o;return T("calcite-icon",{class:this.classes({[m.statusIndicator]:!0,[m.publishing]:l,[m.updating]:n,[m.connectionStatus]:a,[m.connectionStatusConnected]:a&&"connected"===o}),icon:w({connectionStatus:o,publishing:l}),key:"layer-item-status",scale:"s",slot:"actions-end"})}_renderItemTemporaryIcon(e){return this.visibleElements.temporaryLayerIndicators&&"persistenceEnabled"in e.layer&&!e.layer.persistenceEnabled?T("calcite-icon",{class:m.itemTemporaryIcon,icon:"temporary",key:"temporary-icon",scale:"s",slot:"actions-start",title:this.messages.temporary}):null}_renderItemToggle(e,t){const{messages:i,visibilityAppearance:o}=this,{visible:l}=e,s=t?.visibilityMode;if("inherited"===s)return null;const n=C({visible:l,exclusive:"exclusive"===s,visibilityAppearance:o}),a="checkbox"===o,r=i.layerVisibility;return T("calcite-action",{appearance:"transparent",class:m.visibleToggle,icon:a?n:void 0,key:"visibility-toggle",onclick:()=>this._toggleVisibility(e,t),scale:"s",slot:a?"actions-start":"actions-end",text:r,title:r},a?null:T("calcite-icon",{class:this.classes({[m.visibleIcon]:"exclusive"!==s&&l}),icon:n,scale:"s"}))}_renderPanel(e){return!e?.open||e.disabled||e.flowEnabled?null:T("div",{class:m.itemContentBottom,key:`content-panel-${e.uid}`,slot:"content-bottom"},e.render())}_renderPanelAction(e){if(!e?.visible)return null;const{open:t,title:i,disabled:o}=e;return T("calcite-action",{active:t,appearance:"transparent",disabled:o,icon:r(e),key:`action-${e.uid}`,onclick:()=>this._togglePanel(e),scale:"s",slot:"actions-end",text:i??"",title:i??void 0},this._renderFallbackIcon(e))}_renderActionsSections(e,t){const i=this.messagesCommon.options;return T("calcite-action-menu",{appearance:"transparent",key:"item-action-menu",label:this.messagesCommon.menu,open:e.actionsOpen,overlayPositioning:"fixed",placement:"bottom-end",scale:"s",slot:"actions-end",onCalciteActionMenuOpen:t=>e.actionsOpen=t.target.open},T("calcite-action",{appearance:"transparent",icon:"ellipsis",scale:"s",slot:"trigger",text:i,title:i}),t.toArray().map(((t,i)=>this._renderActionSection(e,t,i))))}_renderActionSection(e,t,i){return T("calcite-action-group",{key:`action-section-${i}`},t.toArray().map((t=>this._renderAction({item:e,action:t,textEnabled:!0}))))}_renderFallbackIcon(e){const{className:t,icon:i}=e;if(i)return null;const o="image"in e?e.image:void 0,l={[m.itemActionIcon]:!!t,[m.itemActionImage]:!!o};return t&&(l[t]=!0),o||t?T("span",{"aria-hidden":"true",class:this.classes(m.itemActionIcon,l),key:"icon",styles:c(o)}):null}_renderAction(e){const{item:t,action:i,textEnabled:o}=e;if(!i)return null;const{active:l,disabled:s,title:n,type:a,indicator:c}=i;return T("calcite-action",{active:"toggle"===a&&i.value,appearance:"transparent",disabled:s,icon:r(i),indicator:c,key:`action-${i.uid}`,loading:l,onclick:()=>this._triggerAction(t,i),scale:"s",slot:o?void 0:"actions-end",text:n??"",textEnabled:o,title:n??void 0},this._renderFallbackIcon(i))}_setTooltipReference(e,t){this._tooltipReferenceMap.set(t.layer.uid,e)}_removeTooltipReference(e){this._tooltipReferenceMap.delete(e.layer.uid)}_moveLayerFromChildList({toEl:e,fromEl:t,dragEl:i,newIndex:o}){const l=_(i),s=_(e),n=_(t);this.viewModel.moveListItem(l,n,s,o)}_handleCalciteListDragEnd(e){const{fromEl:t,dragEl:i,oldIndex:o}=e;t.insertBefore(i,t.children[o])}_sortLayers(e,t){if(e)if(e.group===this._rootGroupUid)L(this.view?.map?.layers,t);else{const i=_(e);if(!i)return;F(i,t)}}_getSingleAction(e){return e.reduce((e=>e)).find((e=>e&&("button"===e.type||"toggle"===e.type)))}_filterActions(e){return e.map((e=>e.filter((e=>e.visible))))}_countActions(e){return e.reduce(((e,t)=>e+t.length),0)}_triggerAction(e,t){t&&e&&("toggle"===t.type&&(t.value=!t.value),this.triggerAction(t,e))}_handleCalciteListChange(e){const{selectionMode:t,selectedItems:i}=this;if("none"===t)return;const o=e.target.selectedItems.map((e=>_(e))).filter(Boolean);i.removeAll(),i.addMany(o)}_handleCalciteListItemToggle(e,t){e.stopPropagation(),t.open=e.target.open}_focusSelectedDragEl(e,t){this._selectedDragItemLayerUid===t.layer.uid&&requestAnimationFrame((()=>e?.setFocus()))}_handleCalciteListItemDragHandleChange(e,t){e.stopPropagation();const i=e.target.dragSelected;this._selectedDragItemLayerUid=i?t.layer.uid:null}_handleCalciteListItemSelect(e,t,i){_(e.target)===t&&"none"===this.selectionMode&&"inherited"!==i?.visibilityMode&&this._toggleVisibility(t,i)}_togglePanel(e){e.open=!e.open,e.open&&(this._focusPanelFlowItem=!0)}_toggleVisibility(e,t){if(!e)return;const i=t?.visibilityMode;"exclusive"===i&&e.visible||(e.visible=!e.visible)}};e([n()],j.prototype,"_activeItem",void 0),e([n()],j.prototype,"_tooltipReferenceMap",void 0),e([n()],j.prototype,"_focusRootFlowItem",void 0),e([n()],j.prototype,"_focusPanelFlowItem",void 0),e([n()],j.prototype,"_focusKnowledgeGraphFlowItem",void 0),e([n()],j.prototype,"_focusCatalogFlowItem",void 0),e([n()],j.prototype,"_dragEnabled",null),e([n()],j.prototype,"_filterEnabled",null),e([n()],j.prototype,"_knowledgeGraphFlowItem",void 0),e([n()],j.prototype,"_catalogFlowItem",void 0),e([n({readOnly:!0})],j.prototype,"catalogLayerList",void 0),e([n()],j.prototype,"catalogOptions",void 0),e([n()],j.prototype,"collapsed",void 0),e([n()],j.prototype,"dragEnabled",void 0),e([n()],j.prototype,"filterPlaceholder",void 0),e([n()],j.prototype,"filterText",void 0),e([n()],j.prototype,"headingLevel",void 0),e([n()],j.prototype,"icon",null),e([n({readOnly:!0})],j.prototype,"knowledgeGraphTableList",void 0),e([n()],j.prototype,"knowledgeGraphOptions",void 0),e([n()],j.prototype,"label",null),e([n()],j.prototype,"listItemCanGiveFunction",void 0),e([n()],j.prototype,"listItemCanReceiveFunction",void 0),e([n()],j.prototype,"listItemCreatedFunction",null),e([n(),A("esri/widgets/LayerList/t9n/LayerList")],j.prototype,"messages",void 0),e([n(),A("esri/t9n/common")],j.prototype,"messagesCommon",void 0),e([n()],j.prototype,"minDragEnabledItems",void 0),e([n()],j.prototype,"minFilterItems",void 0),e([n()],j.prototype,"multipleSelectionEnabled",null),e([n()],j.prototype,"operationalItems",null),e([n()],j.prototype,"selectionEnabled",null),e([n()],j.prototype,"selectedItems",void 0),e([n()],j.prototype,"selectionMode",void 0),e([n()],j.prototype,"view",null),e([M("trigger-action"),n({type:p})],j.prototype,"viewModel",void 0),e([n()],j.prototype,"visibilityAppearance",void 0),e([n({type:h,nonNullable:!0})],j.prototype,"visibleElements",void 0),j=e([a("esri.widgets.LayerList")],j);const S=j;export{S as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import t from"../core/Collection.js";import{deprecatedProperty as i}from"../core/deprecate.js";import{IdentifiableMixin as o}from"../core/Identifiable.js";import l from"../core/Logger.js";import s from"../core/ReactiveMap.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as a}from"../core/accessorSupport/decorators/subclass.js";import{getActionIcon as r,getActionStyles as c}from"../support/actions/actionUtils.js";import d from"./Widget.js";import{css as m}from"./LayerList/css.js";import p from"./LayerList/LayerListViewModel.js";import h from"./LayerList/LayerListVisibleElements.js";import g from"./LayerList/ListItem.js";import{minDragEnabledItems as u,minFilterItems as y,getItem as _,getLayerType as f,listItemHasChildren as v,areChildrenHidden as I,canSortSublayers as b,getStatusIcon as w,sortLayersToIds as L,sortChildLayersToIds as F,getVisibilityIcon as C}from"./LayerList/support/layerListUtils.js";import{loadCalciteComponents as E}from"./support/componentsUtils.js";import{globalCss as k}from"./support/globalCss.js";import"./support/widgetUtils.js";import{messageBundle as A}from"./support/decorators/messageBundle.js";import{vmEvent as M}from"./support/decorators/vmEvent.js";import{tsx as T}from"./support/jsxFactory.js";const G=t.ofType(g);let j=class extends(o(d)){constructor(e,t){super(e,t),this._activeItem=null,this._tooltipReferenceMap=new s,this._focusRootFlowItem=!1,this._focusPanelFlowItem=!1,this._focusKnowledgeGraphFlowItem=!1,this._focusCatalogFlowItem=!1,this._knowledgeGraphFlowItem=null,this._catalogFlowItem=null,this._lastDragDetail=null,this._selectedDragItemLayerUid=null,this._rootGroupUid=`operational-${this.uid}`,this.catalogLayerList=null,this.catalogOptions=null,this.collapsed=!1,this.dragEnabled=!1,this.filterPlaceholder="",this.filterText="",this.headingLevel=2,this.knowledgeGraphTableList=null,this.knowledgeGraphOptions=null,this.listItemCanGiveFunction=null,this.listItemCanReceiveFunction=null,this.messages=null,this.messagesCommon=null,this.minDragEnabledItems=u,this.minFilterItems=y,this.selectedItems=new G,this.selectionMode="none",this.viewModel=new p,this.visibilityAppearance="default",this.visibleElements=new h,this._canMove=({dragEl:e,fromEl:t,toEl:i},o)=>{const l="pull"===o?this.listItemCanGiveFunction:this.listItemCanReceiveFunction,s=_(e);if(!s?.sortable)return!1;const n=_(t),a=f(t),r=_(i),c=f(i),d=!!a&&!!c&&a===c,m={selected:s,from:n,to:r},p=t.group,h=i.group,g=n?.layer?.type??"",u=r?.layer?.type??"",y=new Set(["map-image","catalog","knowledge-graph"]),v="sublayer";return p&&h&&"function"==typeof l?l.call(null,m):d&&!y.has(g)&&!y.has(u)&&s?.layer?.type!==v},this._clearActiveItem=()=>{this._activeItem=null},this._setActiveItem=e=>{if("default"!==this.visibilityAppearance)return;const t=Array.from(e.composedPath()).find((e=>e.classList?.contains(m.item)));this._activeItem=_(t)},this._onCalciteListOrderChange=e=>{const{_lastDragDetail:t}=this,{toEl:i,fromEl:o,dragEl:l,newIndex:s}=e;if(o&&i&&!(t?.newIndex===s&&t?.dragEl===l&&t?.toEl===i&&t?.fromEl===o))if(this._lastDragDetail=e,o!==i)this._moveLayerFromChildList({toEl:i,fromEl:o,dragEl:l,newIndex:s});else{const e=Array.from(o.children).filter((e=>e?.matches("calcite-list-item"))).map((e=>e.value));this._sortLayers(o,e)}}}loadDependencies(){return E({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group.js"),"action-menu":()=>import("@esri/calcite-components/dist/components/calcite-action-menu.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow.js"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip.js")})}destroy(){this._destroyKnowledgeGraph(),this._tooltipReferenceMap.clear()}get _dragEnabled(){return this.viewModel.totalItems>=this.minDragEnabledItems&&this.dragEnabled}get _filterEnabled(){return this.viewModel.totalItems>=this.minFilterItems&&this.visibleElements.filter}get icon(){return"layers"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get listItemCreatedFunction(){return this.viewModel.listItemCreatedFunction}set listItemCreatedFunction(e){this.viewModel.listItemCreatedFunction=e}get multipleSelectionEnabled(){return i(l.getLogger(this),"multipleSelectionEnabled",{replacement:"selectionMode",version:"4.29",warnOnce:!0}),"multiple"===this.selectionMode}set multipleSelectionEnabled(e){i(l.getLogger(this),"multipleSelectionEnabled",{replacement:"selectionMode",version:"4.29",warnOnce:!0}),this.selectionMode=e?"multiple":this.selectionEnabled?"single":"none"}get operationalItems(){return this.viewModel.operationalItems}set operationalItems(e){this.viewModel.operationalItems=e}get selectionEnabled(){return i(l.getLogger(this),"selectionEnabled",{replacement:"selectionMode, dragEnabled",version:"4.29",warnOnce:!0}),"none"!==this.selectionMode&&this.dragEnabled}set selectionEnabled(e){i(l.getLogger(this),"selectionEnabled",{replacement:"selectionMode, dragEnabled",version:"4.29",warnOnce:!0}),this.dragEnabled=e,this.selectionMode=e?this.multipleSelectionEnabled?"multiple":"single":"none"}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}triggerAction(e,t){return this.viewModel.triggerAction(e,t)}render(){const e=this.viewModel?.state,t={[k.hidden]:"loading"===e,[k.disabled]:"disabled"===e},i=this.operationalItems?.filter((e=>!e.hidden&&(this.visibleElements.errors||!e.error)));return T("div",{class:this.classes(m.base,k.widget,k.panel,t)},i?.length?[this._renderItemTooltips(i),this._renderItems(i)]:this._renderNoItems())}_renderItemTooltip(e){const{_tooltipReferenceMap:t,messages:i}=this;return e?T("calcite-tooltip",{key:`tooltip-${e.layer.uid}`,referenceElement:t.get(e.layer.uid)},i.layerIncompatibleTooltip):null}_renderItemTooltipNodes(e){return e.incompatible?this._renderItemTooltip(e):e.children?.filter((e=>!e.hidden)).toArray().map((e=>this._renderItemTooltipNodes(e)))}_renderItemTooltips(e){return e?.toArray().map((e=>this._renderItemTooltipNodes(e)))}_renderNoItemsMessage(){return T("div",{slot:"message"},this.messages.noItemsToDisplay)}_renderNoItems(){return T("div",{class:m.itemMessage,key:"esri-layer-list__no-items"},T("calcite-notice",{icon:"information",kind:"info",open:!0,width:"full"},this._renderNoItemsMessage()))}_destroyCatalog(){this._catalogFlowItem=null,this._focusRootFlowItem=!0,this.catalogLayerList?.destroy(),this._set("catalogLayerList",null)}_destroyKnowledgeGraph(){this._knowledgeGraphFlowItem=null,this._focusRootFlowItem=!0,this.knowledgeGraphTableList?.destroy(),this._set("knowledgeGraphTableList",null)}async _createCatalog(){const{default:e}=await import("./CatalogLayerList.js"),{headingLevel:t,catalogOptions:i,view:o,filterPlaceholder:l,listItemCreatedFunction:s,minFilterItems:n,selectionMode:a,visibilityAppearance:r}=this,c=this._catalogFlowItem?.layer;this._set("catalogLayerList",new e({headingLevel:t,view:o,filterPlaceholder:l,listItemCreatedFunction:s,minFilterItems:n,selectionMode:a,visibilityAppearance:r,...i,catalogLayer:c}))}async _createKnowledgeGraph(){const{default:e}=await import("./TableList.js"),t=this._knowledgeGraphFlowItem?.layer;if("knowledge-graph"!==t?.type||!t.tables.length)return;const{headingLevel:i,knowledgeGraphOptions:o,selectionMode:l,dragEnabled:s}=this;this._set("knowledgeGraphTableList",new e({headingLevel:i,selectionMode:l,dragEnabled:s,...o,tables:t.tables}))}_renderCatalogFlowItem(){const{_catalogFlowItem:e,messages:t}=this;if(!e)return null;const i=this._getLayerTitle(e);return T("calcite-flow-item",{afterCreate:this._focusCatalogFlowItemNode,afterUpdate:this._focusCatalogFlowItemNode,bind:this,description:i,heading:t.catalogLayers,headingLevel:this.headingLevel,key:`flow-catalog-${e.uid}`,onCalciteFlowItemBack:e=>{e.preventDefault(),this._destroyCatalog()}},this.catalogLayerList?.render())}_renderKnowledgeGraphFlowItem(){const{_knowledgeGraphFlowItem:e,messages:t}=this;if(!e)return null;const i=this._getLayerTitle(e);return T("calcite-flow-item",{afterCreate:this._focusKnowledgeGraphFlowItemNode,afterUpdate:this._focusKnowledgeGraphFlowItemNode,bind:this,description:i,heading:t.tables,headingLevel:this.headingLevel,key:`flow-knowledge-graph-${e.uid}`,onCalciteFlowItemBack:e=>{e.preventDefault(),this._destroyKnowledgeGraph()}},this.knowledgeGraphTableList?.render())}_renderPanelFlowItems(e){return e?e.flatten((e=>e.children)).filter((({hidden:e,panel:t})=>!e&&t?.open&&!t.disabled&&t.flowEnabled)).toArray().map((({title:e,panel:t})=>{const i=()=>this._handlePanelFlowItemBack(t);return T("calcite-flow-item",{afterCreate:this._focusPanelFlowItemNode,afterUpdate:this._focusPanelFlowItemNode,bind:this,description:e,heading:t.title,headingLevel:this.headingLevel,key:`flow-panel-${t.uid}`,onCalciteFlowItemBack:e=>{e.preventDefault(),i()}},t.render(),T("calcite-button",{appearance:"transparent",onclick:i,slot:"footer-actions",width:"full"},this.messagesCommon.back))})):[]}_handlePanelFlowItemBack(e){e.open=!1,this._focusRootFlowItem=!0}_focusRootFlowItemNode(e){this._focusRootFlowItem&&(this._focusRootFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_focusCatalogFlowItemNode(e){this._focusCatalogFlowItem&&(this._focusCatalogFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_focusKnowledgeGraphFlowItemNode(e){this._focusKnowledgeGraphFlowItem&&(this._focusKnowledgeGraphFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_focusPanelFlowItemNode(e){this._focusPanelFlowItem&&(this._focusPanelFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_renderItems(e){const{visible:t,collapsed:i,_filterEnabled:o,_rootGroupUid:l,visibleElements:{closeButton:s,collapseButton:n,heading:a,flow:r},_dragEnabled:c,selectionMode:d,filterText:p,filterPlaceholder:h,messages:g}=this,u=[T("calcite-flow-item",{afterCreate:this._focusRootFlowItemNode,afterUpdate:this._focusRootFlowItemNode,bind:this,closable:s,closed:!t,collapsed:i,collapsible:n,heading:a?g.widgetLabel:void 0,headingLevel:this.headingLevel,key:"root-flow-item",onCalciteFlowItemClose:()=>this.visible=!1},T("calcite-list",{afterCreate:e=>{e.addEventListener("focusin",this._setActiveItem),e.addEventListener("focusout",this._clearActiveItem)},afterRemoved:e=>{e.removeEventListener("focusin",this._setActiveItem),e.removeEventListener("focusout",this._clearActiveItem)},canPull:e=>this._canMove(e,"pull"),canPut:e=>this._canMove(e,"put"),"data-layer-type":l,dragEnabled:c,filterEnabled:o,filterPlaceholder:h,filterText:o?p:"",group:l,key:"root-list",label:g.widgetLabel,onmouseleave:this._clearActiveItem,onmouseover:this._setActiveItem,selectionAppearance:"border",selectionMode:d,onCalciteListChange:e=>this._handleCalciteListChange(e),onCalciteListDragEnd:e=>this._handleCalciteListDragEnd(e.detail),onCalciteListFilter:e=>this.filterText=e.target?.filterText??"",onCalciteListOrderChange:e=>this._onCalciteListOrderChange(e.detail)},e?.toArray().map((e=>this._renderItem(e))),e?.length&&o?T("div",{class:m.filterNoResults,slot:"filter-no-results"},T("calcite-notice",{kind:"info",open:!0,width:"full"},this._renderNoItemsMessage())):null)),this._renderPanelFlowItems(e),this._renderKnowledgeGraphFlowItem(),this._renderCatalogFlowItem()];return t?r?T("calcite-flow",{key:"root-flow"},u):u:null}_renderChildList(e,t=[]){const{_dragEnabled:i,_rootGroupUid:o,viewModel:{listModeDisabled:l},messages:s,selectionMode:n}=this,{children:a}=e,r="catalog-dynamic-group"!==e.layer?.type&&v(e),c=!(!l&&I(e.layer))&&!r&&i&&"group"===e.layer?.type;return r||c?T("calcite-list",{canPull:e=>this._canMove(e,"pull"),canPut:e=>this._canMove(e,"put"),"data-item":e,"data-layer-type":o,dragEnabled:!!i&&(e.childrenSortable&&b(e)),group:`${o}-${e.layer.uid}`,key:`child-list-${e.layer.uid}`,selectionAppearance:"border",selectionMode:n},a?.filter((e=>!e.hidden)).toArray().map((i=>this._renderItem(i,e,[...t,e.title]))),"knowledge-graph"===e.layer?.type&&e.layer.tables?.length?T("calcite-list-item",{class:m.item,"data-layer-id":e.layer.id,dragDisabled:!0,key:`list-item-knowledge-graph-tables-${e.layer.uid}`,title:s.tables,onCalciteListItemSelect:()=>{this._knowledgeGraphFlowItem=e,this._focusKnowledgeGraphFlowItem=!0,this._createKnowledgeGraph()}},T("div",{class:m.itemContent,slot:"content"},s.tables),T("calcite-icon",{class:m.itemTableIcon,icon:"table",scale:"s",slot:"content-start"}),T("calcite-icon",{flipRtl:!0,icon:"chevron-right",scale:"s",slot:"content-end"})):null):null}_renderItemMessage(e){return e.error?T("div",{class:m.itemMessage,key:"esri-layer-list__error",slot:"content-bottom"},T("calcite-notice",{icon:"exclamation-mark-triangle",kind:"warning",open:!0,scale:"s",width:"full"},T("div",{slot:"message"},this.messages.layerError))):e.incompatible?T("div",{class:m.itemMessage,key:"esri-layer-list__incompatible",slot:"content-bottom"},T("calcite-notice",{afterCreate:t=>this._setTooltipReference(t,e),afterRemoved:()=>this._removeTooltipReference(e),bind:this,icon:"exclamation-mark-triangle",kind:"warning",open:!0,scale:"s",tabIndex:0,width:"full"},T("div",{slot:"message"},this.messages.layerIncompatible))):null}_getLayerTitle(e){return e.title||this.messages.untitledLayer}_renderItem(e,t,i){const{_activeItem:o,_selectedDragItemLayerUid:l,selectionMode:s,selectedItems:n,messages:a,visibleElements:r}=this,c=this._getLayerTitle(e),d=e.visibleAtCurrentTimeExtent?e.visibleAtCurrentScale?c:`${c} (${a.layerInvisibleAtScale})`:`${c} (${a.layerInvisibleAtTime})`,p=this._filterActions(e.actionsSections),h=this._countActions(p),g="catalog"===e.parent?.layer?.type,u="catalog-footprint"===e.layer?.type,y="catalog-dynamic-group"===e.layer?.type,_=u?T("calcite-icon",{class:m.itemCatalogIcon,icon:"footprint",key:"footprint",scale:"s",slot:"content-start"}):null,f=y?T("calcite-icon",{class:m.itemCatalogIcon,icon:"catalog-dataset",key:"catalog-dataset",scale:"s",slot:"content-start"}):null,v=r.catalogLayerList&&y?T("calcite-action",{appearance:"transparent",disabled:!e.layer.visible,icon:"chevron-right",iconFlipRtl:!0,onclick:()=>{this._catalogFlowItem=t,this._focusCatalogFlowItem=!0,this._createCatalog()},scale:"s",slot:"actions-end",text:c}):null;return T("calcite-list-item",{afterCreate:t=>this._focusSelectedDragEl(t,e),afterUpdate:t=>this._focusSelectedDragEl(t,e),class:this.classes(m.item,{[m.itemActive]:o===e}),"data-item":e,"data-layer-id":e.layer.id,dragDisabled:!e.sortable||g,dragSelected:e.layer.uid===l,id:e.layer.uid,key:`list-item-${e.layer.uid}`,label:c,metadata:{parentTitles:i,title:c},open:e.open,selected:"none"!==s&&n.includes(e),title:d,value:e.layer.uid,onCalciteListItemDragHandleChange:t=>this._handleCalciteListItemDragHandleChange(t,e),onCalciteListItemSelect:i=>this._handleCalciteListItemSelect(i,e,t),onCalciteListItemToggle:t=>this._handleCalciteListItemToggle(t,e)},_,f,T("div",{class:this.classes({[m.itemContent]:!0,[m.itemInvisible]:!e.visibleAtCurrentScale||!e.visibleAtCurrentTimeExtent}),slot:"content"},c),this._renderItemStatus(e,t),this._renderItemToggle(e,t),v,this._renderItemTemporaryIcon(e),this._renderChildList(e,i),this._renderItemMessage(e),this._renderPanel(e.panel),this._renderPanelAction(e.panel),h>1?this._renderActionsSections(e,p):1===h?this._renderAction({item:e,action:this._getSingleAction(p),textEnabled:!1}):null)}_renderItemStatus(e,t){const{visibleElements:i}=this;if(!i.statusIndicators)return null;const{connectionStatus:o,publishing:l,updating:s}=e,n=s&&!t,a=!!o;return T("calcite-icon",{class:this.classes({[m.statusIndicator]:!0,[m.publishing]:l,[m.updating]:n,[m.connectionStatus]:a,[m.connectionStatusConnected]:a&&"connected"===o}),icon:w({connectionStatus:o,publishing:l}),key:"layer-item-status",scale:"s",slot:"actions-end"})}_renderItemTemporaryIcon(e){return this.visibleElements.temporaryLayerIndicators&&"persistenceEnabled"in e.layer&&!e.layer.persistenceEnabled?T("calcite-icon",{class:m.itemTemporaryIcon,icon:"temporary",key:"temporary-icon",scale:"s",slot:"actions-start",title:this.messages.temporary}):null}_renderItemToggle(e,t){const{messages:i,visibilityAppearance:o}=this,{visible:l}=e,s=t?.visibilityMode;if("inherited"===s)return null;const n=C({visible:l,exclusive:"exclusive"===s,visibilityAppearance:o}),a="checkbox"===o,r=i.layerVisibility;return T("calcite-action",{appearance:"transparent",class:m.visibleToggle,icon:a?n:void 0,key:"visibility-toggle",onclick:()=>this._toggleVisibility(e,t),scale:"s",slot:a?"actions-start":"actions-end",text:r,title:r},a?null:T("calcite-icon",{class:this.classes({[m.visibleIcon]:"exclusive"!==s&&l}),icon:n,scale:"s"}))}_renderPanel(e){return!e?.open||e.disabled||e.flowEnabled?null:T("div",{class:m.itemContentBottom,key:`content-panel-${e.uid}`,slot:"content-bottom"},e.render())}_renderPanelAction(e){if(!e?.visible)return null;const{open:t,title:i,disabled:o}=e;return T("calcite-action",{active:t,appearance:"transparent",disabled:o,icon:r(e),key:`action-${e.uid}`,onclick:()=>this._togglePanel(e),scale:"s",slot:"actions-end",text:i??"",title:i??void 0},this._renderFallbackIcon(e))}_renderActionsSections(e,t){const i=this.messagesCommon.options;return T("calcite-action-menu",{appearance:"transparent",key:"item-action-menu",label:this.messagesCommon.menu,open:e.actionsOpen,overlayPositioning:"fixed",placement:"bottom-end",scale:"s",slot:"actions-end",onCalciteActionMenuOpen:t=>e.actionsOpen=t.target.open},T("calcite-action",{appearance:"transparent",icon:"ellipsis",scale:"s",slot:"trigger",text:i,title:i}),t.toArray().map(((t,i)=>this._renderActionSection(e,t,i))))}_renderActionSection(e,t,i){return T("calcite-action-group",{key:`action-section-${i}`},t.toArray().map((t=>this._renderAction({item:e,action:t,textEnabled:!0}))))}_renderFallbackIcon(e){const{className:t,icon:i}=e;if(i)return null;const o="image"in e?e.image:void 0,l={[m.itemActionIcon]:!!t,[m.itemActionImage]:!!o};return t&&(l[t]=!0),o||t?T("span",{"aria-hidden":"true",class:this.classes(m.itemActionIcon,l),key:"icon",styles:c(o)}):null}_renderAction(e){const{item:t,action:i,textEnabled:o}=e;if(!i)return null;const{active:l,disabled:s,title:n,type:a,indicator:c}=i;return T("calcite-action",{active:"toggle"===a&&i.value,appearance:"transparent",disabled:s,icon:r(i),indicator:c,key:`action-${i.uid}`,loading:l,onclick:()=>this._triggerAction(t,i),scale:"s",slot:o?void 0:"actions-end",text:n??"",textEnabled:o,title:n??void 0},this._renderFallbackIcon(i))}_setTooltipReference(e,t){this._tooltipReferenceMap.set(t.layer.uid,e)}_removeTooltipReference(e){this._tooltipReferenceMap.delete(e.layer.uid)}_moveLayerFromChildList({toEl:e,fromEl:t,dragEl:i,newIndex:o}){const l=_(i),s=_(e),n=_(t);this.viewModel.moveListItem(l,n,s,o)}_handleCalciteListDragEnd(e){const{fromEl:t,dragEl:i,oldIndex:o}=e;t.insertBefore(i,t.children[o])}_sortLayers(e,t){if(e)if(e.group===this._rootGroupUid)L(this.view?.map?.layers,t);else{const i=_(e);if(!i)return;F(i,t)}}_getSingleAction(e){return e.reduce((e=>e)).find((e=>e&&("button"===e.type||"toggle"===e.type)))}_filterActions(e){return e.map((e=>e.filter((e=>e.visible))))}_countActions(e){return e.reduce(((e,t)=>e+t.length),0)}_triggerAction(e,t){t&&e&&("toggle"===t.type&&(t.value=!t.value),this.triggerAction(t,e))}_handleCalciteListChange(e){const{selectionMode:t,selectedItems:i}=this;if("none"===t)return;const o=e.target.selectedItems.map((e=>_(e))).filter(Boolean);i.removeAll(),i.addMany(o)}_handleCalciteListItemToggle(e,t){e.stopPropagation(),t.open=e.target.open}_focusSelectedDragEl(e,t){this._selectedDragItemLayerUid===t.layer.uid&&requestAnimationFrame((()=>e?.setFocus()))}_handleCalciteListItemDragHandleChange(e,t){e.stopPropagation();const i=e.target.dragSelected;this._selectedDragItemLayerUid=i?t.layer.uid:null}_handleCalciteListItemSelect(e,t,i){_(e.target)===t&&"none"===this.selectionMode&&"inherited"!==i?.visibilityMode&&this._toggleVisibility(t,i)}_togglePanel(e){e.open=!e.open,e.open&&(this._focusPanelFlowItem=!0)}_toggleVisibility(e,t){if(!e)return;const i=t?.visibilityMode;"exclusive"===i&&e.visible||(e.visible=!e.visible)}};e([n()],j.prototype,"_activeItem",void 0),e([n()],j.prototype,"_tooltipReferenceMap",void 0),e([n()],j.prototype,"_focusRootFlowItem",void 0),e([n()],j.prototype,"_focusPanelFlowItem",void 0),e([n()],j.prototype,"_focusKnowledgeGraphFlowItem",void 0),e([n()],j.prototype,"_focusCatalogFlowItem",void 0),e([n()],j.prototype,"_dragEnabled",null),e([n()],j.prototype,"_filterEnabled",null),e([n()],j.prototype,"_knowledgeGraphFlowItem",void 0),e([n()],j.prototype,"_catalogFlowItem",void 0),e([n({readOnly:!0})],j.prototype,"catalogLayerList",void 0),e([n()],j.prototype,"catalogOptions",void 0),e([n()],j.prototype,"collapsed",void 0),e([n()],j.prototype,"dragEnabled",void 0),e([n()],j.prototype,"filterPlaceholder",void 0),e([n()],j.prototype,"filterText",void 0),e([n()],j.prototype,"headingLevel",void 0),e([n()],j.prototype,"icon",null),e([n({readOnly:!0})],j.prototype,"knowledgeGraphTableList",void 0),e([n()],j.prototype,"knowledgeGraphOptions",void 0),e([n()],j.prototype,"label",null),e([n()],j.prototype,"listItemCanGiveFunction",void 0),e([n()],j.prototype,"listItemCanReceiveFunction",void 0),e([n()],j.prototype,"listItemCreatedFunction",null),e([n(),A("esri/widgets/LayerList/t9n/LayerList")],j.prototype,"messages",void 0),e([n(),A("esri/t9n/common")],j.prototype,"messagesCommon",void 0),e([n()],j.prototype,"minDragEnabledItems",void 0),e([n()],j.prototype,"minFilterItems",void 0),e([n()],j.prototype,"multipleSelectionEnabled",null),e([n()],j.prototype,"operationalItems",null),e([n()],j.prototype,"selectionEnabled",null),e([n()],j.prototype,"selectedItems",void 0),e([n()],j.prototype,"selectionMode",void 0),e([n()],j.prototype,"view",null),e([M("trigger-action"),n({type:p})],j.prototype,"viewModel",void 0),e([n()],j.prototype,"visibilityAppearance",void 0),e([n({type:h,nonNullable:!0})],j.prototype,"visibleElements",void 0),j=e([a("esri.widgets.LayerList")],j);const S=j;export{S as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import"../../geometry.js";import{id as e}from"../../kernel.js";import i from"../../request.js";import{isSome as r}from"../../core/arrayUtils.js";import o from"../../core/Collection.js";import s from"../../core/Error.js";import{JSONMap as a}from"../../core/jsonMap.js";import{clone as l}from"../../core/lang.js";import n from"../../core/Loadable.js";import{isAbortError as p}from"../../core/promiseUtils.js";import{watch as m,initial as u}from"../../core/reactiveUtils.js";import{createScreenPoint as h}from"../../core/screenUtils.js";import{convertUnit as c,getMetersPerUnitForSR as d,inchesPerMeter as y}from"../../core/unitUtils.js";import{property as f}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as v}from"../../core/accessorSupport/decorators/subclass.js";import{formatDate as w,convertDateFormatToIntlOptions as _}from"../../intl/date.js";import{getLanguage as g}from"../../intl/locale.js";import T from"../../portal/Portal.js";import I from"../../portal/PortalQueryParams.js";import{execute as O}from"../../rest/geoprocessor/execute.js";import{submitJob as b}from"../../rest/geoprocessor/submitJob.js";import{execute as x,getTasks as P,getMode as L}from"../../rest/print.js";import{fromJSON as S}from"../../rest/support/fileFormat.js";import{fromJSON as j}from"../../rest/support/layoutTemplate.js";import E from"../../rest/support/PrintParameters.js";import U from"../../rest/support/PrintTemplate.js";import{getExtent as C}from"../../views/2d/viewpointUtils.js";import{ViewEventPriorities as H}from"../../views/input/InputManager.js";import D from"../../views/overlay/BoxOverlayItem.js";import F from"./CustomTemplate.js";import k from"./TemplateOptions.js";import M from"../../geometry/Extent.js";const N=new a({inch:"inches",foot:"feet",yard:"yards",mile:"miles","nautical-mile":"nautical-miles",millimeter:"millimeters",centimeter:"centimeters",decimeter:"decimeters",meter:"meters",kilometer:"kilometers"}),W=o.ofType(F);function A(t){t.layoutOptions??={},t.layoutOptions.customTextElements??=[];const e="date";if(!t.layoutOptions.customTextElements.find((t=>e in t))){const{customTextElements:e}=t.layoutOptions;let i=w(Date.now(),_("short-date"));"ar"===g()&&(i="‏"+i),e.push({date:i})}}let z=class extends n{constructor(t){super(t),this._serviceTemplateCustomTextElements=null,this._templateToLayoutInfo=new Map,this._isFreeHand=!1,this._freeHandWidth=0,this._freehandHeight=0,this.allowedFormats="all",this.allowedLayouts="all",this.browseTemplates=new W,this.defaultTemplates=new W,this.error=null,this.extraParameters=null,this.includeDefaultTemplates=!0,this.portal=T.getDefault(),this.printPreviewEnabled=!1,this.printServiceUrl=null,this.printTimeout=12e4,this.templatesInfo=null,this.updateDelay=1e3,this.view=null,this.templateCustomTextElements=null,this.templateOptions=new k}initialize(){this.addHandles(m((()=>this.printPreviewEnabled),(t=>{t?this._enablePrintPreview():(this.removeHandles("overlay-handler"),this.view?.overlay?.removeItem(this._getOverlayItem()))})))}destroy(){this.removeHandles("overlay-handler"),this.view&&(this._overlayItem&&(this.view.overlay?.removeItem(this._overlayItem),this._overlayItem.destroy(),this._overlayItem=null),this.view=null)}get effectivePrintServiceUrl(){return this.printServiceUrl??null}get effectiveTemplateCustomTextElements(){if(!this._serviceTemplateCustomTextElements)return{};const t=l(this._serviceTemplateCustomTextElements);return this.templateCustomTextElements&&Object.keys(this.templateCustomTextElements).forEach((e=>{const i=t[e];if(i){const t=this.templateCustomTextElements?.[e];i.forEach((e=>{const[i]=Object.entries(e)[0];t?.forEach((t=>{const[r,o]=Object.entries(t)[0];i===r&&(e[i]=o)}))}))}})),Object.freeze(t)}get layoutTemplateInfo(){return this._templateToLayoutInfo.get(this.templateOptions.layoutItem?.id??this.templateOptions.layout)}get state(){return"loading"===this.loadStatus?"initializing":"failed"===this.loadStatus||this.error?"error":"loaded"===this.loadStatus&&this.view?.ready?"ready":"disabled"}get layoutTemplateNorthArrowInfo(){return this.layoutTemplateInfo?.layoutOptions?.mapSurroundInfos?this.layoutTemplateInfo.layoutOptions.mapSurroundInfos.find((t=>"CIMMarkerNorthArrow"===t.type)):null}async load(t){return this.addResolvingPromise(this._loadResources(t).catch((t=>this.error=t))),this}async print(t){const{view:e,extraParameters:i,updateDelay:r}=this;if(!e)throw new s("print:view-required","view is not set");A(t);const o=this._getOverlayItem(),a=t.scalePreserved||!this.printPreviewEnabled?void 0:C(new M,e.viewpoint,"MAP_ONLY"===t.layout?[t.exportOptions.width,t.exportOptions.height]:[o.boxWidth,o.boxHeight]),l=new E({view:e,template:t,extent:a,extraParameters:i,updateDelay:r});try{return await x(this.effectivePrintServiceUrl,l,{timeout:this.printTimeout})}catch(n){throw new s("print:export-error","An error occurred while exporting the web map.",{error:n})}}toPrintTemplate({attributionEnabled:t,author:e,copyright:i,customTextElements:r,dpi:o,forceFeatureAttributes:s,format:a,height:l,includeTables:n,layout:p,layoutItem:m,legendEnabled:u,northArrowEnabled:h,scale:c,scaleEnabled:d,title:y,width:f}){const v=new U({attributionVisible:t,forceFeatureAttributes:s,format:a,includeTables:n,layout:p,layoutItem:m,layoutOptions:{authorText:e||"",copyrightText:i||"",customTextElements:r,titleText:y||""},outScale:c??0,scalePreserved:d});f&&(v.exportOptions.width=f),l&&(v.exportOptions.height=l),o&&(v.exportOptions.dpi=o),!u&&v.layoutOptions&&(v.layoutOptions.legendLayers=[]);const w=this.layoutTemplateNorthArrowInfo;if(w){!(w.visible===h)&&v.layoutOptions&&(v.layoutOptions.elementOverrides={[w.name]:{visible:h}})}return v}async fetchLayoutTemplateInfo(t,e){if(!t.layoutItem?.id)return;const i=await this._fetchPortalLayoutTemplateInfo(t.layoutItem,e);this._templateToLayoutInfo.set(t.layoutItem.id,i),t.layoutTemplateInfo=i;const{hasLegend:r,mapSurroundInfos:o}=i.layoutOptions,s=o.some((({type:t,visible:e})=>"CIMMarkerNorthArrow"===t&&e));t.layoutOptions={legend:r,northArrow:s}}getPageSizeLabel(t){if(!t)return;const e=this._templateToLayoutInfo.get(t);return e?`${e.pageSize.join(" x ")} ${N.fromJSON(e.pageUnits.toLowerCase())}`:void 0}async addPortalTemplate(t){const e=new F({label:t.title,layoutItem:t});this.browseTemplates.add(e)}removePortalTemplate(t){t.layoutItem?.id&&this.templateOptions.layoutItem?.id===t.layoutItem.id&&(this.templateOptions.layout=this.templatesInfo?.layout?.defaultValue??"letter-ansi-a-landscape",this.templateOptions.layoutItem=null),this._templateToLayoutInfo.delete(t.layoutItem.id),this.browseTemplates.remove(t)}async _loadResources(t){let e=[];if(!this.printServiceUrl){if(this.destroyed)return;try{await this.portal.load(t)}catch(l){throw new s("print:could-not-load-portal","Cannot load print resource information from portal",{error:l,url:this.effectivePrintServiceUrl})}const i=this.portal.helperServices?.printTask;i&&(this._set("effectivePrintServiceUrl",i.url),e=i.templates?.map((t=>F.fromJSON(t)))??[])}this.defaultTemplates.addMany(e);const i=this.effectivePrintServiceUrl?.toLowerCase().split("/");if(!i?.includes("gpserver"))throw new s("print:invalid-print-service-url","Can't fetch print templates information from provided URL",{url:this.effectivePrintServiceUrl});const[r,o,a]=await Promise.all([this._getPrintServiceLayouts(t),this._getPrintServiceTemplates(t),this._getPortalCustomTemplates(t)]);this._processPrintServiceLayouts(r),this._processPrintServiceTemplates(o),this._processPortalTemplates(a)}async _getPortalCustomTemplates(t){if(this.printServiceUrl)return[];const{layoutGroupQuery:e}=this.portal;if(!e)return[];const i=new I({query:e,disableExtraQuery:!0}),r=await this.portal.queryGroups(i,t);if(!r.total)return[];const o=r.results[0],s=new I({num:100,query:"type:Layout"}),a=(await o.queryItems(s,t)).results;return a.length?a.map((t=>new F({label:t.title,layoutItem:t}))):[]}async _fetchPortalLayoutTemplateInfo(t,i){const{id:r}=t;"public"!==t.access&&e&&await e.getCredential(this._printServiceLayoutsUrl);const o={Layout_Item_ID:JSON.stringify({id:r})},{results:s}=await O(this._printServiceLayoutsUrl,o,null,i);return s[0].value[0]}_processPortalTemplates(t){this.defaultTemplates.addMany(t)}_processPrintServiceTemplates(t){this._set("templatesInfo",t)}async _getPrintServiceLayouts(t){let e=[];const i=async e=>{const i=await L(this.effectivePrintServiceUrl);if(this._printServiceLayoutsUrl=this.effectivePrintServiceUrl.replace(/(\/GPServer\/).+/i,`$1${encodeURI(e)}`),"async"===i){const e=await b(this._printServiceLayoutsUrl,void 0,void 0,t||void 0);await e.waitForJobCompletion({interval:1e3});return(await e.fetchResultData("Output_JSON")).value}return(await O(this._printServiceLayoutsUrl,null,null,t)).results[0].value},r=(await P(this.effectivePrintServiceUrl,t)).find((t=>t.includes("Get Layout Templates Info")));if(r)try{e=await i(r)}catch{}return e}_processPrintServiceLayouts(t){const e={};for(const i of t){const{layoutTemplate:t,layoutOptions:r}=i,o=j(t);this._templateToLayoutInfo.set(o,i),e[o]=r.customTextElements}this._serviceTemplateCustomTextElements=Object.freeze(e)}async _getPrintServiceTemplates(t){let e;try{({data:e}=await i(this.effectivePrintServiceUrl,{...t,query:{f:"json"},timeout:this.printTimeout}))}catch(l){throw p(l)?l:new s("print:unavailable-service-info","Can't fetch templates info from service",{error:l})}const{parameters:r}=e,o=r.find((({name:t})=>"Format"===t)),a=r.find((({name:t})=>"Layout_Template"===t));return{format:this._getFormat(o),layout:this._getLayout(a)}}_getFormat(t){const e="all"===this.allowedFormats?t.choiceList:t.choiceList.filter((t=>this.allowedFormats.includes(S(t)))),i=(e.length?e:t.choiceList).map(S).filter(r),o=S(t.defaultValue),s=i.includes(o)?o:i[0];return{choiceList:i,defaultValue:s}}_getLayout(t){const e=t.choiceList.filter((t=>"map_only"!==t.toLowerCase())),i="all"===this.allowedLayouts?e:e.filter((t=>this.allowedLayouts.includes(j(t)))),o=(i.length?i:e).map(j).filter(r),s=j(t.defaultValue),a=o.includes(s)?s:o.find((t=>/(?=.*letter)(?=.*landscape)/i.test(t)))??o.find((t=>/(?=.*a4)(?=.*landscape)/i.test(t)))??o[0];return{choiceList:o,defaultValue:a}}_getOverlayItem(){return this._overlayItem||(this._overlayItem=new D({strokeDash:[5],strokeWidth:2,strokeColor:[30,144,255,255]})),this._overlayItem}_enablePrintPreview(){if(!this.view?.overlay)return;const t=this.templateOptions,e=this._getOverlayItem();this.addHandles([m((()=>[t.width,t.height,t.scaleEnabled,t.scale,t.layout,t.layoutItem,this.view?.scale,this.view?.size,this.view?.state.paddedViewState.size,this.view?.state.padding]),(()=>this._updateOverLayItem()),u),this.view?.on("drag",["Shift"],(t=>this._handleDrag(t)),H.WIDGET),this.view?.on("key-down",["Escape"],(()=>this._resetDrag()),H.WIDGET)],"overlay-handler"),this.view.overlay.addItem(e)}_updateOverLayItem(){if(!this.view)return;const t=this.templateOptions,e=this._getOverlayItem(),i=t.layoutItem?.id??t.layout,r=this.view,o=r.spatialReference,[s,a]=r.state.paddedViewState.size,l=r.state.padding;let n=0,p=0;if("MAP_ONLY"===i)null!=t.width&&null!=t.height&&(n=t.width,p=t.height);else{const{webMapFrameSize:e,pageUnits:r}=this._templateToLayoutInfo.get(i)??{};if(e&&r)if(this._isFreeHand){const t=e[0]/e[1];n=this._freeHandWidth,p=this._freehandHeight,n>p?p=n/t:n=p*t}else{const t=N.fromJSON(r.toLowerCase()),i=o.unit;n=c(e[0],t,i),p=c(e[1],t,i)}if(!this._isFreeHand)if(t.scaleEnabled&&t.scale){const e=d(o)*y*t.dpi;n*=e,p*=e}else if(0===n||0===p)n=s,p=a;else{const t=(s-.1*s)/n,e=(a-.1*a)/p,i=Math.min(t,e);n*=i,p*=i}}const{scaleEnabled:m,scale:u}=t,h=m&&u?u/this.view.scale:1;e.boxWidth=n*h,e.boxHeight=p*h,l&&(e.padding=l),e.backgroundWidth=s??0,e.backgroundHeight=a??0}_resetDrag(){this._isFreeHand=!1,this._updateOverLayItem()}_handleDrag(t){switch(t.action){case"start":this._start();break;case"update":this._update(t);break;case"end":this._end()}t.stopPropagation()}_start(){this._isFreeHand=!0}_update(t){const e=this._getOverlayItem(),{x:i,y:r}=t,{x:o,y:s}=t.origin;i>o?(e.x=o,e.boxWidth=i-o):(e.x=i,e.boxWidth=o-i),r>s?(e.y=s,e.boxHeight=r-s):(e.y=r,e.boxHeight=s-r)}_end(){const t=this._getOverlayItem();if(!this.view||null==t.x||null==t.y)return;const e=this.view,i=e.toMap(h(t.x+.5*t.boxWidth,t.y+.5*t.boxHeight));t.x=null,t.y=null,e.goTo({center:i}),this._freeHandWidth=t.boxWidth,this._freehandHeight=t.boxHeight,"MAP_ONLY"===this.templateOptions.layout&&(this.templateOptions.width=this._freeHandWidth,this.templateOptions.height=this._freehandHeight),this.templateOptions.scale=this.view.scale,this._updateOverLayItem()}};t([f()],z.prototype,"_serviceTemplateCustomTextElements",void 0),t([f()],z.prototype,"_templateToLayoutInfo",void 0),t([f()],z.prototype,"allowedFormats",void 0),t([f()],z.prototype,"allowedLayouts",void 0),t([f({type:W})],z.prototype,"browseTemplates",void 0),t([f({type:W})],z.prototype,"defaultTemplates",void 0),t([f()],z.prototype,"error",void 0),t([f()],z.prototype,"extraParameters",void 0),t([f()],z.prototype,"includeDefaultTemplates",void 0),t([f({readOnly:!0})],z.prototype,"effectivePrintServiceUrl",null),t([f()],z.prototype,"effectiveTemplateCustomTextElements",null),t([f()],z.prototype,"layoutTemplateInfo",null),t([f({type:T})],z.prototype,"portal",void 0),t([f()],z.prototype,"printPreviewEnabled",void 0),t([f()],z.prototype,"printServiceUrl",void 0),t([f()],z.prototype,"printTimeout",void 0),t([f({readOnly:!0})],z.prototype,"state",null),t([f({readOnly:!0})],z.prototype,"templatesInfo",void 0),t([f()],z.prototype,"updateDelay",void 0),t([f()],z.prototype,"view",void 0),t([f()],z.prototype,"templateCustomTextElements",void 0),t([f({type:k})],z.prototype,"templateOptions",void 0),t([f()],z.prototype,"layoutTemplateNorthArrowInfo",null),z=t([v("esri.widgets.Print.PrintViewModel")],z);const V=z;export{V as default};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import"../../geometry.js";import{id as e}from"../../kernel.js";import i from"../../request.js";import{isSome as o}from"../../core/arrayUtils.js";import r from"../../core/Collection.js";import s from"../../core/Error.js";import{JSONMap as a}from"../../core/jsonMap.js";import{clone as l}from"../../core/lang.js";import n from"../../core/Loadable.js";import{isAbortError as p}from"../../core/promiseUtils.js";import{watch as m,initial as u}from"../../core/reactiveUtils.js";import{createScreenPoint as h}from"../../core/screenUtils.js";import{convertUnit as c,getMetersPerUnitForSR as d,inchesPerMeter as y}from"../../core/unitUtils.js";import{property as f}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as v}from"../../core/accessorSupport/decorators/subclass.js";import{formatDate as w,convertDateFormatToIntlOptions as T}from"../../intl/date.js";import{getLanguage as _}from"../../intl/locale.js";import I from"../../portal/Portal.js";import g from"../../portal/PortalQueryParams.js";import{execute as b}from"../../rest/geoprocessor/execute.js";import{submitJob as O}from"../../rest/geoprocessor/submitJob.js";import{execute as P,getTasks as x,getMode as L}from"../../rest/print.js";import{fromJSON as S}from"../../rest/support/fileFormat.js";import{fromJSON as j}from"../../rest/support/layoutTemplate.js";import U from"../../rest/support/PrintParameters.js";import E from"../../rest/support/PrintTemplate.js";import{getExtent as k}from"../../views/2d/viewpointUtils.js";import{ViewEventPriorities as C}from"../../views/input/InputManager.js";import H from"../../views/overlay/BoxOverlayItem.js";import D from"./CustomTemplate.js";import F from"./TemplateOptions.js";import M from"../../geometry/Extent.js";const N=/(\/GPServer\/).+/i,W=new a({inch:"inches",foot:"feet",yard:"yards",mile:"miles","nautical-mile":"nautical-miles",millimeter:"millimeters",centimeter:"centimeters",decimeter:"decimeters",meter:"meters",kilometer:"kilometers"}),A=r.ofType(D);function z(t){t.layoutOptions??={},t.layoutOptions.customTextElements??=[];const e="date";if(!t.layoutOptions.customTextElements.find((t=>e in t))){const{customTextElements:e}=t.layoutOptions;let i=w(Date.now(),T("short-date"));"ar"===_()&&(i="‏"+i),e.push({date:i})}}let V=class extends n{constructor(t){super(t),this._serviceTemplateCustomTextElements=null,this._templateToLayoutInfo=new Map,this._isFreeHand=!1,this._freeHandWidth=0,this._freehandHeight=0,this._asyncPrintTaskUrl=null,this._layoutInfoTaskUrl=null,this.allowedFormats="all",this.allowedLayouts="all",this.browseTemplates=new A,this.defaultTemplates=new A,this.error=null,this.extraParameters=null,this.includeDefaultTemplates=!0,this.portal=I.getDefault(),this.portalTemplateIds=[],this.printPreviewEnabled=!1,this.printServiceUrl=null,this.printTimeout=12e4,this.templatesInfo=null,this.updateDelay=1e3,this.view=null,this.templateCustomTextElements=null,this.templateOptions=new F}initialize(){this.addHandles(m((()=>this.printPreviewEnabled),(t=>{t?this._enablePrintPreview():(this.removeHandles("overlay-handler"),this.view?.overlay?.removeItem(this._getOverlayItem()))})))}destroy(){this.removeHandles("overlay-handler"),this.view&&(this._overlayItem&&(this.view.overlay?.removeItem(this._overlayItem),this._overlayItem.destroy(),this._overlayItem=null),this.view=null)}get effectivePrintServiceUrl(){return this.printServiceUrl??null}get effectiveTemplateCustomTextElements(){if(!this._serviceTemplateCustomTextElements)return{};const t=l(this._serviceTemplateCustomTextElements);return this.templateCustomTextElements&&Object.keys(this.templateCustomTextElements).forEach((e=>{const i=t[e];if(i){const t=this.templateCustomTextElements?.[e];i.forEach((e=>{const[i]=Object.entries(e)[0];t?.forEach((t=>{const[o,r]=Object.entries(t)[0];i===o&&(e[i]=r)}))}))}})),Object.freeze(t)}get layoutTemplateInfo(){const t=this.templateOptions.layoutItem?.id??this.templateOptions.layout;return t?this._templateToLayoutInfo.get(t):null}get state(){return"loading"===this.loadStatus?"initializing":"failed"===this.loadStatus||this.error?"error":"loaded"===this.loadStatus&&this.view?.ready?"ready":"disabled"}get layoutTemplateNorthArrowInfo(){return this.layoutTemplateInfo?.layoutOptions?.mapSurroundInfos?this.layoutTemplateInfo.layoutOptions.mapSurroundInfos.find((t=>"CIMMarkerNorthArrow"===t.type)):null}async load(t){return this.addResolvingPromise(this._loadResources(t).catch((t=>this.error=t))),this}async print(t){const{view:e,extraParameters:i,updateDelay:o}=this;if(!e)throw new s("print:view-required","view is not set");z(t);const r=this._getOverlayItem(),a=t.scalePreserved||!this.printPreviewEnabled?void 0:k(new M,e.viewpoint,"MAP_ONLY"===t.layout?[t.exportOptions.width,t.exportOptions.height]:[r.boxWidth,r.boxHeight]),l=new U({view:e,template:t,extent:a,extraParameters:i,updateDelay:o});try{const e=!!t.layoutItem?.id&&(this.portalTemplateIds.includes(t.layoutItem.id)||this.browseTemplates.some((e=>e.layoutItem?.id===t.layoutItem?.id)));return await P(e&&this._asyncPrintTaskUrl?this._asyncPrintTaskUrl:this.effectivePrintServiceUrl,l,{timeout:this.printTimeout})}catch(n){throw new s("print:export-error","An error occurred while exporting the web map.",{error:n})}}toPrintTemplate({attributionEnabled:t,author:e,copyright:i,customTextElements:o,dpi:r,forceFeatureAttributes:a,format:l,height:n,includeTables:p,layout:m,layoutItem:u,legendEnabled:h,northArrowEnabled:c,scale:d,scaleEnabled:y,title:f,width:v}){if(!m)throw new s("print:layout-required","layout is not set");const w=new E({attributionVisible:t,forceFeatureAttributes:a,format:l,includeTables:p,layout:m,layoutItem:u,layoutOptions:{authorText:e||"",copyrightText:i||"",customTextElements:o,titleText:f||""},outScale:d??0,scalePreserved:y});v&&(w.exportOptions.width=v),n&&(w.exportOptions.height=n),r&&(w.exportOptions.dpi=r),!h&&w.layoutOptions&&(w.layoutOptions.legendLayers=[]);const T=this.layoutTemplateNorthArrowInfo;if(T){!(T.visible===c)&&w.layoutOptions&&(w.layoutOptions.elementOverrides={[T.name]:{visible:c}})}return w}async fetchLayoutTemplateInfo(t,e){if(!t.layoutItem?.id)return;const i=await this._fetchPortalLayoutTemplateInfo(t.layoutItem,e);this._templateToLayoutInfo.set(t.layoutItem.id,i),t.layoutTemplateInfo=i;const{hasLegend:o,mapSurroundInfos:r}=i.layoutOptions,s=r.some((({type:t,visible:e})=>"CIMMarkerNorthArrow"===t&&e));t.layoutOptions={legend:o,northArrow:s}}getPageSizeLabel(t){if(!t)return;const e=this._templateToLayoutInfo.get(t);return e?`${e.pageSize.join(" x ")} ${W.fromJSON(e.pageUnits.toLowerCase())}`:void 0}async addPortalTemplate(t){const e=new D({label:t.title,layoutItem:t});this.browseTemplates.add(e)}removePortalTemplate(t){t.layoutItem?.id&&this.templateOptions.layoutItem?.id===t.layoutItem.id&&(this.templateOptions.layout=this.defaultTemplates.length||this.browseTemplates.length?null:this.templatesInfo?.layout?.defaultValue,this.templateOptions.layoutItem=null),this._templateToLayoutInfo.delete(t.layoutItem.id),this.browseTemplates.remove(t)}async _loadResources(t){let e=[];if(!this.printServiceUrl){if(this.destroyed)return;try{await this.portal.load(t)}catch(l){throw new s("print:could-not-load-portal","Cannot load print resource information from portal",{error:l,url:this.effectivePrintServiceUrl})}if(this.portal.helperServices){const{asyncPrintTask:i,layoutInfoTask:o,printTask:r}=this.portal.helperServices;if(r&&(this._set("effectivePrintServiceUrl",r.url),e=r.templates?.map((t=>D.fromJSON(t)))??[]),this._asyncPrintTaskUrl=i?.url,o?.url){const e=(await x(o.url,t)).find((t=>t.includes("Get Layout Templates Info")));e&&(this._layoutInfoTaskUrl=o.url.replace(N,`$1${encodeURI(e)}`))}}}this.defaultTemplates.addMany(e);const i=this.effectivePrintServiceUrl?.toLowerCase().split("/");if(!i?.includes("gpserver"))throw new s("print:invalid-print-service-url","Can't fetch print templates information from provided URL",{url:this.effectivePrintServiceUrl});const[o,r,a]=await Promise.all([this._getPrintServiceLayouts(t),this._getPrintServiceTemplates(t),this._getPortalCustomTemplates(t)]);this._processPrintServiceLayouts(o),this._processPrintServiceTemplates(r),this._processPortalTemplates(a)}async _getPortalCustomTemplates(t){if(this.printServiceUrl)return[];const{layoutGroupQuery:e}=this.portal;if(!e)return[];const i=new g({query:e,disableExtraQuery:!0}),o=await this.portal.queryGroups(i,t);if(!o.total)return[];const r=o.results[0],s=new g({num:100,query:"type:Layout"}),a=(await r.queryItems(s,t)).results;return a.length?a.map((t=>new D({label:t.title,layoutItem:t}))):[]}async _fetchPortalLayoutTemplateInfo(t,i){const{id:o}=t;if(!this._layoutInfoTaskUrl)throw new s("print:invalid-layout-info-task-url","Can't fetch layout template info",{url:this._layoutInfoTaskUrl});"public"!==t.access&&e&&await e.getCredential(this._layoutInfoTaskUrl);const r={Layout_Item_ID:JSON.stringify({id:o})},{results:a}=await b(this._layoutInfoTaskUrl,r,null,i);return a[0].value[0]}_processPortalTemplates(t){this.defaultTemplates.addMany(t);for(const e of t)e.layoutItem?.id&&this.portalTemplateIds.push(e.layoutItem.id)}_processPrintServiceTemplates(t){this._set("templatesInfo",t)}async _getPrintServiceLayouts(t){let e=[];const i=async e=>{const i=await L(this.effectivePrintServiceUrl);if(this._printServiceLayoutsUrl=this.effectivePrintServiceUrl.replace(N,`$1${encodeURI(e)}`),"async"===i){const e=await O(this._printServiceLayoutsUrl,void 0,void 0,t||void 0);await e.waitForJobCompletion({interval:1e3});return(await e.fetchResultData("Output_JSON")).value}return(await b(this._printServiceLayoutsUrl,null,null,t)).results[0].value},o=(await x(this.effectivePrintServiceUrl,t)).find((t=>t.includes("Get Layout Templates Info")));if(o)try{e=await i(o)}catch{}return e}_processPrintServiceLayouts(t){const e={};for(const i of t){const{layoutTemplate:t,layoutOptions:o}=i,r=j(t);this._templateToLayoutInfo.set(r,i),e[r]=o.customTextElements}this._serviceTemplateCustomTextElements=Object.freeze(e)}async _getPrintServiceTemplates(t){let e;try{({data:e}=await i(this.effectivePrintServiceUrl,{...t,query:{f:"json"},timeout:this.printTimeout}))}catch(l){throw p(l)?l:new s("print:unavailable-service-info","Can't fetch templates info from service",{error:l})}const{parameters:o}=e,r=o.find((({name:t})=>"Format"===t)),a=o.find((({name:t})=>"Layout_Template"===t));return{format:this._getFormat(r),layout:this._getLayout(a)}}_getFormat(t){const e="all"===this.allowedFormats?t.choiceList:t.choiceList.filter((t=>this.allowedFormats.includes(S(t)))),i=(e.length?e:t.choiceList).map(S).filter(o),r=S(t.defaultValue),s=i.includes(r)?r:i[0];return{choiceList:i,defaultValue:s}}_getLayout(t){const e=t.choiceList.filter((t=>"map_only"!==t.toLowerCase())),i="all"===this.allowedLayouts?e:e.filter((t=>this.allowedLayouts.includes(j(t)))),r=(i.length?i:e).map(j).filter(o),s=j(t.defaultValue),a=r.includes(s)?s:r.find((t=>/(?=.*letter)(?=.*landscape)/i.test(t)))??r.find((t=>/(?=.*a4)(?=.*landscape)/i.test(t)))??r[0];return{choiceList:r,defaultValue:a}}_getOverlayItem(){return this._overlayItem||(this._overlayItem=new H({strokeDash:[5],strokeWidth:2,strokeColor:[30,144,255,255]})),this._overlayItem}_enablePrintPreview(){if(!this.view?.overlay)return;const t=this.templateOptions,e=this._getOverlayItem();this.addHandles([m((()=>[t.width,t.height,t.scaleEnabled,t.scale,t.layout,t.layoutItem,this.view?.scale,this.view?.size,this.view?.state.paddedViewState.size,this.view?.state.padding]),(()=>this._updateOverLayItem()),u),this.view?.on("drag",["Shift"],(t=>this._handleDrag(t)),C.WIDGET),this.view?.on("key-down",["Escape"],(()=>this._resetDrag()),C.WIDGET)],"overlay-handler"),this.view.overlay.addItem(e)}_updateOverLayItem(){if(!this.view)return;const t=this.templateOptions,e=this._getOverlayItem(),i=t.layoutItem?.id??t.layout,o=this.view,r=o.spatialReference,[s,a]=o.state.paddedViewState.size,l=o.state.padding;let n=0,p=0;if("MAP_ONLY"===i)null!=t.width&&null!=t.height&&(n=t.width,p=t.height);else if(i){const{webMapFrameSize:e,pageUnits:o}=this._templateToLayoutInfo.get(i)??{};if(e&&o)if(this._isFreeHand){const t=e[0]/e[1];n=this._freeHandWidth,p=this._freehandHeight,n>p?p=n/t:n=p*t}else{const t=W.fromJSON(o.toLowerCase()),i=r.unit;n=c(e[0],t,i),p=c(e[1],t,i)}if(!this._isFreeHand)if(t.scaleEnabled&&t.scale){const e=d(r)*y*t.dpi;n*=e,p*=e}else if(0===n||0===p)n=s,p=a;else{const t=(s-.1*s)/n,e=(a-.1*a)/p,i=Math.min(t,e);n*=i,p*=i}}const{scaleEnabled:m,scale:u}=t,h=m&&u?u/this.view.scale:1;e.boxWidth=n*h,e.boxHeight=p*h,l&&(e.padding=l),e.backgroundWidth=s??0,e.backgroundHeight=a??0}_resetDrag(){this._isFreeHand=!1,this._updateOverLayItem()}_handleDrag(t){switch(t.action){case"start":this._start();break;case"update":this._update(t);break;case"end":this._end()}t.stopPropagation()}_start(){this._isFreeHand=!0}_update(t){const e=this._getOverlayItem(),{x:i,y:o}=t,{x:r,y:s}=t.origin;i>r?(e.x=r,e.boxWidth=i-r):(e.x=i,e.boxWidth=r-i),o>s?(e.y=s,e.boxHeight=o-s):(e.y=o,e.boxHeight=s-o)}_end(){const t=this._getOverlayItem();if(!this.view||null==t.x||null==t.y)return;const e=this.view,i=e.toMap(h(t.x+.5*t.boxWidth,t.y+.5*t.boxHeight));t.x=null,t.y=null,e.goTo({center:i}),this._freeHandWidth=t.boxWidth,this._freehandHeight=t.boxHeight,"MAP_ONLY"===this.templateOptions.layout&&(this.templateOptions.width=this._freeHandWidth,this.templateOptions.height=this._freehandHeight),this.templateOptions.scale=this.view.scale,this._updateOverLayItem()}};t([f()],V.prototype,"_serviceTemplateCustomTextElements",void 0),t([f()],V.prototype,"_templateToLayoutInfo",void 0),t([f()],V.prototype,"allowedFormats",void 0),t([f()],V.prototype,"allowedLayouts",void 0),t([f({type:A})],V.prototype,"browseTemplates",void 0),t([f({type:A})],V.prototype,"defaultTemplates",void 0),t([f()],V.prototype,"error",void 0),t([f()],V.prototype,"extraParameters",void 0),t([f()],V.prototype,"includeDefaultTemplates",void 0),t([f({readOnly:!0})],V.prototype,"effectivePrintServiceUrl",null),t([f()],V.prototype,"effectiveTemplateCustomTextElements",null),t([f()],V.prototype,"layoutTemplateInfo",null),t([f({type:I})],V.prototype,"portal",void 0),t([f()],V.prototype,"portalTemplateIds",void 0),t([f()],V.prototype,"printPreviewEnabled",void 0),t([f()],V.prototype,"printServiceUrl",void 0),t([f()],V.prototype,"printTimeout",void 0),t([f({readOnly:!0})],V.prototype,"state",null),t([f({readOnly:!0})],V.prototype,"templatesInfo",void 0),t([f()],V.prototype,"updateDelay",void 0),t([f()],V.prototype,"view",void 0),t([f()],V.prototype,"templateCustomTextElements",void 0),t([f({type:F})],V.prototype,"templateOptions",void 0),t([f()],V.prototype,"layoutTemplateNorthArrowInfo",null),V=t([v("esri.widgets.Print.PrintViewModel")],V);const q=V;export{q as default};
package/widgets/Print.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import t from"../core/Collection.js";import{clone as i}from"../core/lang.js";import{watch as a}from"../core/reactiveUtils.js";import{addProxy as l,hasSameOrigin as o}from"../core/urlUtils.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import{subclass as s}from"../core/accessorSupport/decorators/subclass.js";import{getToken as r}from"../rest/utils.js";import{toJSON as c}from"../rest/support/fileFormat.js";import p from"./Widget.js";import d from"./Print/FileLink.js";import u from"./Print/PrintViewModel.js";import{loadCalciteComponents as h}from"./support/componentsUtils.js";import{globalCss as m}from"./support/globalCss.js";import{Heading as b}from"./support/Heading.js";import{legacyIcon as _}from"./support/legacyIcon.js";import{isActivationKey as y}from"./support/widgetUtils.js";import{messageBundle as f}from"./support/decorators/messageBundle.js";import{tsx as g}from"./support/jsxFactory.js";const v=t.ofType(d),w="MAP_ONLY";var T;!function(e){e.layout="layoutTab",e.mapOnly="mapOnlyTab",e.export="exportTab"}(T||(T={}));const x="esri-print",C=`${x}__advanced-options-button`,O={base:x,headerTitle:`${x}__header-title`,inputText:`${x}__input-text`,layoutTabList:`${x}__layout-tab-list`,layoutTab:`${x}__layout-tab`,layoutSection:`${x}__layout-section`,mapOnlySection:`${x}__map-only-section`,scaleInput:`${x}__scale-input`,panelItemsCentered:`${x}__panel-items--centered`,loader:`${x}__loader`,advancedOptionsButton:C,advancedOptionsButtonContainer:`${C}-container`,advancedOptionsButtonTitle:`${C}-title`,advancedOptionsButtonIconOpened:`${C}-icon--opened`,advancedOptionsButtonIconClosed:`${C}-icon--closed`,advancedOptionsButtonIconClosed_RTL:`${C}-icon--closed-rtl`,refreshButton:`${x}__refresh-button`,swapButton:`${x}__swap-button`,printButton:`${x}__export-button`,templateSelectContainer:`${x}__template-select-container`,templateSelectBlock:`${x}__template-select-block`,templateSelectIcon:`${x}__template-select-icon`,formSectionContainer:`${x}__form-section-container`,formInputLabel:`${x}__form-input-label`,formCheckboxLabel:`${x}__form-checkbox-label`,advancedOptionsSection:`${x}__advanced-options-section`,advancedOptionsContainer:`${x}__advanced-options-container`,authorInfoContainer:`${x}__author-info-container`,browseTemplateButtonContainer:`${x}__browse-template-button-container`,copyrightInfoContainer:`${x}__copyright-info-container`,exportedFilesContainer:`${x}__export-panel-container`,exportedFilesTitle:`${x}__export-title`,exportedFile:`${x}__exported-file`,exportedFileLink:`${x}__exported-file-link`,exportedFileLinkTitle:`${x}__exported-file-link-title`,exportedFilesEmpty:`${x}__exported-files-empty`,legendInfoContainer:`${x}__legend-info-container`,printWidgetContainer:`${x}__container`,content:`${x}__content`,panelContainer:`${x}__panel-container`,scaleInfoContainer:`${x}__scale-info-container`,scaleInputContainer:`${x}__scale-input-container`,sizeContainer:`${x}__size-container`,panelError:`${x}__panel--error`,exportedFileError:`${x}__exported-file--error`,exportSection:`${x}__export-section`,exportSectionCentered:`${x}__export-section--centered`,templateButtonContainer:`${x}__template-button-container`,templateDoneButton:`${x}__template-done-button`};function I(e,t,i,a){const l=i/t,o=a/t;return{width:Math.round(e*l),height:Math.round(e*o)}}function k(e){return!isNaN(e)&&e>0}function $(e){return e?.toUpperCase()===w}function L(e){const{state:t,extension:i}=e;switch(t){case"pending":return"spinner";case"error":return"exclamation-mark-circle";default:return i?.toLowerCase()?.includes("pdf")?"file-pdf":"file"}}let M=class extends p{constructor(e,t){super(e,t),this._activeTabFocusRequested=!1,this._awaitingServerResponse=!1,this._exportedFileNameMap={},this._selectedTab=T.layout,this._pendingExportScroll=!1,this._rootNode=null,this._showTemplates=!1,this._selectedLayout=null,this._abortController=null,this.browseTemplateButtonOnClick=null,this.exportedLinks=new v,this.headingLevel=3,this.viewModel=new u,this._onInput=e=>{this._selectedTab===T.layout?this.templateOptions.title=e.target.value:this._selectedTab===T.mapOnly&&(this.templateOptions.fileName=e.target.value)},this._removeLink=e=>{const t=e.currentTarget["data-item"];t&&"error"===t.state&&this.exportedLinks.remove(t)},this._handleLinkClick=e=>{const t=e.currentTarget,{href:i}=t,a=r(this.viewModel.effectivePrintServiceUrl);if(!a)return;if(!e.isTrusted)return void e.stopPropagation();e.preventDefault();const l=new URL(i);l.searchParams.set("token",a),t.href=l.href,t.click(),t.href=i},this._focusOnTabChange=this._focusOnTabChange.bind(this)}initialize(){this.addHandles([a((()=>[this.templateOptions.format,this.viewModel.templatesInfo?.format.defaultValue]),(([e,t])=>{if(t&&!e)return void(this.templateOptions.format=t);if(!e||!t||!this.viewModel.templatesInfo)return;if(this.viewModel.templatesInfo.format.choiceList.includes(e))return;const i=this.viewModel.templatesInfo.format.choiceList.find((t=>t.toUpperCase().includes(`(${e.toUpperCase()})`)));this.templateOptions.format=i??t})),a((()=>[this.templateOptions.layout,this.viewModel.templatesInfo?.layout.defaultValue]),(([e,t])=>{if(t&&!e)return void(this.templateOptions.layout=t);if(!e||!t||!this.viewModel.templatesInfo)return;if(this._selectedTab=$(e)?T.mapOnly:T.layout,this._selectedTab!==T.layout)return;this._selectedLayout=e;const a=this.viewModel.effectiveTemplateCustomTextElements[this.templateOptions.layout];this.templateOptions.customTextElements=a?i(a):null})),a((()=>this.templateOptions.dpi),(e=>{e<=0&&(this.templateOptions.dpi=1)})),a((()=>this.viewModel.view?.scale),(e=>{!e||this.templateOptions.scaleEnabled&&this.templateOptions.scale||(this.templateOptions.scale=e)}))]);const{height:e,width:t}=this.templateOptions;this.templateOptions.width=t||800,this.templateOptions.height=e||1100;const l=setTimeout((()=>{this._awaitingServerResponse=!0,this.scheduleRender()}),500);this.viewModel.load().then((()=>{clearTimeout(l),this._awaitingServerResponse=!1}))}loadDependencies(){return h({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),block:()=>import("@esri/calcite-components/dist/components/calcite-block.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),checkbox:()=>import("@esri/calcite-components/dist/components/calcite-checkbox.js"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox.js"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item.js"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow.js"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),input:()=>import("@esri/calcite-components/dist/components/calcite-input.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),"list-item-group":()=>import("@esri/calcite-components/dist/components/calcite-list-item-group.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch.js")})}destroy(){this.viewModel.destroy()}get allowedFormats(){return this.viewModel.allowedFormats}set allowedFormats(e){this.viewModel.allowedFormats=e}get allowedLayouts(){return this.viewModel.allowedLayouts}set allowedLayouts(e){this.viewModel.allowedLayouts=e}get error(){return this.viewModel.error}get extraParameters(){return this.viewModel.extraParameters}set extraParameters(e){this.viewModel.extraParameters=e}get icon(){return"print"}set icon(e){this._overrideIfSome("icon",e)}get includeDefaultTemplates(){return this.viewModel.includeDefaultTemplates}set includeDefaultTemplates(e){this.viewModel.includeDefaultTemplates=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get portal(){return this.viewModel.portal}set portal(e){this.viewModel.portal=e}get printServiceUrl(){return this.viewModel.printServiceUrl}set printServiceUrl(e){this.viewModel.printServiceUrl=e}get templateCustomTextElements(){return this.viewModel.templateCustomTextElements}set templateCustomTextElements(e){this.viewModel.templateCustomTextElements=e}get templateOptions(){return this.viewModel.templateOptions}set templateOptions(e){this.viewModel.templateOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}render(){const{messages:e,templateOptions:t,viewModel:i,view:a}=this,{attributionEnabled:l,author:o,copyright:n,dpi:s,format:r,height:p,layout:d,legendEnabled:u,northArrowEnabled:h,scaleEnabled:y,scale:f,width:v}=t,w="ready"!==i.state||this._awaitingServerResponse,x=this._renderTitleOrFileNameSection(),C=g("div",{class:O.formSectionContainer},g("calcite-label",null,e.fileFormatTitle,g("calcite-combobox",{clearDisabled:!0,label:e.formatDefaultOption,maxItems:6,placeholder:e.formatDefaultOption,selectionMode:"single-persist",onCalciteComboboxChange:({target:e})=>{this.templateOptions.format=e.selectedItems[0].value}},i.templatesInfo?.format?.choiceList.sort().map(((e,t)=>g("calcite-combobox-item",{key:`file-format-${t}`,selected:e===this.templateOptions.format,textLabel:c(e),value:e})))))),I=g("div",{class:O.formSectionContainer},g("calcite-label",null,e.template,g("div",{class:O.templateSelectContainer,onclick:()=>{this._showTemplates=!0}},g("calcite-block",{class:O.templateSelectBlock,description:this.viewModel.getPageSizeLabel(d),heading:this._getTemplateLabel()}),g("calcite-icon",{class:O.templateSelectIcon,icon:"chevron-right",scale:"s"})))),k=g("div",{class:O.formSectionContainer},g("label",{class:O.formInputLabel},e.dpi,g("input",{bind:this,class:this.classes(O.inputText,m.input),"data-input-name":"dpi",min:"1",onchange:this._handleDPIChange,tabIndex:0,type:"number",value:`${s}`}))),$=g("div",{class:this.classes(O.scaleInfoContainer,O.formSectionContainer)},g("calcite-label",{layout:"inline"},g("calcite-checkbox",{bind:this,checked:y,"data-option-name":"scaleEnabled",tabIndex:0,onCalciteCheckboxChange:this._toggleInputValue}),e.scale),g("div",{class:O.scaleInputContainer},g("input",{"aria-label":e.scaleLabel,"aria-valuenow":`${f}`,bind:this,class:this.classes(O.inputText,m.input,O.scaleInput),"data-input-name":"scale",disabled:!y,onchange:this._updateInputValue,role:"spinbutton",tabIndex:0,type:"number",value:`${f}`}),g("button",{"aria-label":e.reset,bind:this,class:this.classes(m.widgetButton,O.refreshButton,_.refresh),onclick:this._resetToCurrentScale,tabIndex:0,type:"button"}))),L=g("div",{"aria-labelledby":`${this.id}__advancedOptionsForLayout`,class:O.advancedOptionsContainer},$,this.viewModel.layoutTemplateInfo?.layoutOptions?.hasAuthorText??1?g("div",{class:this.classes(O.authorInfoContainer,O.formSectionContainer)},g("label",{class:O.formInputLabel},e.author,g("input",{bind:this,class:this.classes(O.inputText,m.input),"data-input-name":"author",onchange:this._updateInputValue,tabIndex:0,type:"text",value:o??""}))):null,this.viewModel.layoutTemplateInfo?.layoutOptions?.hasCopyrightText??1?g("div",{class:this.classes(O.copyrightInfoContainer,O.formSectionContainer),key:d},g("label",{class:O.formInputLabel},e.copyright,g("input",{bind:this,class:this.classes(O.inputText,m.input),"data-input-name":"copyright",onchange:this._updateInputValue,tabIndex:0,type:"text",value:n??""}))):null,k,this.viewModel.layoutTemplateInfo?.layoutOptions?.hasLegend??1?g("div",{class:this.classes(O.legendInfoContainer,O.formSectionContainer)},g("calcite-label",{layout:"inline"},g("calcite-checkbox",{bind:this,checked:u,"data-option-name":"legendEnabled",tabIndex:0,onCalciteCheckboxChange:this._toggleInputValue}),e.legend)):null,this.viewModel.layoutTemplateNorthArrowInfo?g("div",{class:this.classes(O.legendInfoContainer,O.formSectionContainer),key:"north-arrow"},g("calcite-label",{layout:"inline"},g("calcite-checkbox",{bind:this,checked:h,"data-option-name":"northArrowEnabled",tabIndex:0,onCalciteCheckboxChange:this._toggleInputValue}),e.northArrow)):null,this._renderCustomTextElementSection()),M=g("div",{"aria-labelledby":`${this.id}__advancedOptionsForMapOnly`,class:O.advancedOptionsContainer},$,k,g("div",{class:O.formSectionContainer},g("calcite-label",{layout:"inline"},g("calcite-checkbox",{bind:this,checked:l,"data-option-name":"attributionEnabled",tabIndex:0,onCalciteCheckboxChange:this._toggleInputValue}),e.attribution)),this._renderCustomTextElementSection()),S=g("calcite-label",{layout:"inline-space-between"},e.printPreview,g("calcite-switch",{checked:this.viewModel.printPreviewEnabled,onCalciteSwitchChange:e=>{this.viewModel.printPreviewEnabled=!!e.target.checked}})),E=this.exportedLinks.toArray(),F=this._renderExportedLink(E),j={[O.exportSectionCentered]:!E.length},P=this._selectedTab===T.layout?g("section",{"aria-labelledby":`${this.id}__layoutTab`,class:O.layoutSection,id:`${this.id}__layoutContent`,key:"esri-print__layoutContent",role:"tabpanel"},g("div",{class:O.panelContainer},this.viewModel.layoutTemplateInfo?.layoutOptions?.hasTitleText??1?x:null,I,this._selectedTab===T.layout?C:null,S),g("calcite-block",{"aria-label":e.advancedOptions,class:this.classes(O.panelContainer,O.advancedOptionsSection),collapsible:!0,heading:e.advancedOptions,id:"advancedOptionsForLayout"},L)):this._selectedTab===T.mapOnly?g("section",{"aria-labelledby":`${this.id}__mapOnlyTab`,class:O.mapOnlySection,id:`${this.id}__mapOnlyContent`,key:"esri-print__mapOnlyContent",role:"tabpanel"},g("div",{class:O.panelContainer},x,C,g("div",{class:this.classes(O.sizeContainer,O.formSectionContainer)},g("label",{class:O.formInputLabel},e.width,g("input",{bind:this,class:this.classes(O.inputText,m.input),"data-input-name":"width",onchange:this._updateInputValue,tabIndex:0,type:"number",value:`${v}`})),g("label",{class:O.formInputLabel},e.height,g("input",{bind:this,class:this.classes(O.inputText,m.input),"data-input-name":"height",onchange:this._updateInputValue,tabIndex:0,type:"number",value:`${p}`})),g("button",{"aria-label":e.swap,bind:this,class:this.classes(m.widgetButton,O.swapButton,_.swap),onclick:this._switchInput,tabIndex:0,type:"button"})),S,g("calcite-block",{"aria-label":e.advancedOptions,class:this.classes(O.panelContainer,O.advancedOptionsSection),collapsible:!0,heading:e.advancedOptions,id:"advancedOptionsForMapOnly"},M))):g("section",{"aria-labelledby":`${this.id}__exportTab`,class:this.classes(O.exportSection,j),id:`${this.id}__exportContent`,key:"esri-print__exportContent",role:"tabpanel"},g("div",{class:O.panelContainer},g("div",{afterUpdate:this._scrollExportIntoView,bind:this,class:O.exportedFilesContainer},0===E.length?g("div",{class:O.exportedFilesEmpty},g("calcite-icon",{icon:"file",scale:"l"}),g("div",null,g(b,{class:O.exportedFilesTitle,level:this.headingLevel},e.noExportedFiles),g("div",null,e.exportHint))):F))),A={[m.buttonDisabled]:w||!d&&!r},B=!a||"2d"!==a.type,D=g("div",{class:O.panelError},B?e.sceneViewError:e.serviceError),N=E.some((({state:e})=>"pending"===e)),V=g("div",{class:O.content},g("ul",{bind:this,class:O.layoutTabList,onclick:this._toggleLayoutPanel,onkeydown:this._handleLayoutPanelKeyDown,role:"tablist"},g("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${this._selectedTab===T.layout}`,class:O.layoutTab,"data-tab-id":T.layout,id:`${this.id}__layoutTab`,role:"tab",tabIndex:0},e.layoutTab),g("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${this._selectedTab===T.mapOnly}`,class:O.layoutTab,"data-tab-id":T.mapOnly,id:`${this.id}__mapOnlyTab`,role:"tab",tabIndex:0},e.mapOnlyTab),g("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${this._selectedTab===T.export}`,class:O.layoutTab,"data-tab-id":T.export,id:`${this.id}__exportedFilesTab`,role:"tab",tabIndex:0},N?g("calcite-loader",{inline:!0,label:"loading",scale:"s"}):null,e.exportsTab)),P,this._selectedTab!==T.export?g("button",{"aria-label":e.exportDescription,bind:this,class:this.classes(O.printButton,m.button,A),disabled:w,onclick:this._handlePrintMap,tabIndex:0,type:"button"},e.export):null),U=g("calcite-flow",{key:"root-flow"},g("calcite-flow-item",{bind:this,closable:!1,key:"root-flow-item"},g("div",{class:O.printWidgetContainer},g("header",{class:O.headerTitle},e.export),this.error||B||!a?D:V)),this._renderChooseTemplateFlowItem()),R="initializing"===i.state,z=R?this._renderLoader():U,H={[O.panelItemsCentered]:R};return g("div",{bind:this,class:this.classes(O.base,m.widget,m.panel,H)},z)}_getTemplateLabel(){const{messages:e,includeDefaultTemplates:t,templateOptions:i,viewModel:a}=this,{layout:l}=i,o=(t?a.defaultTemplates.find((({layoutItem:e})=>l===e?.id)):null)??a.browseTemplates.find((({layoutItem:e})=>l===e?.id));return o?.label?.replaceAll("_"," ")??e[l]??l.replaceAll("_"," ")??e.selectTemplate}_renderChooseTemplateFlowItem(){if(!this._showTemplates)return null;const{includeDefaultTemplates:e,messages:t,viewModel:i}=this,{defaultTemplates:a,templatesInfo:l,browseTemplates:o}=i,n=o.length?o.toArray().sort(((e,t)=>(e.label??"")>(t.label??"")?1:-1)).map(((e,a)=>{const l=e.layoutItem?.id??e.layout,o=i.getPageSizeLabel(l),n=l===this.templateOptions.layout;return g("calcite-list-item",{description:o,key:`browse-template-${a}`,label:e?.label?.replaceAll("_"," ")??t.untitled,selected:n,title:e.description??"",value:l},!o&&n&&e.layoutItem?.id?g("calcite-loader",{inline:!0,label:"loading",scale:"s",slot:"content-end"}):null,g("calcite-action",{icon:"trash",onclick:()=>i.removePortalTemplate(e),slot:"actions-end",text:"delete"}))})):null,s=a.length&&e?a.toArray().filter((({label:e})=>!$(e))).sort(((e,t)=>(e.label??"")>(t.label??"")?1:-1)).map(((e,a)=>{const l=e.layoutItem?.id??e.layout,o=i.getPageSizeLabel(l),n=l===this.templateOptions.layout;return g("calcite-list-item",{description:o,key:`default-template-${a}`,label:e?.label?.replaceAll("_"," ")??t.untitled,selected:n,title:e.description??"",value:l},!o&&n&&e.layoutItem?.id?g("calcite-loader",{inline:!0,label:"loading",scale:"s",slot:"content-end"}):null)})):null,r=!l?.layout?.choiceList.length||e&&a.length?null:l.layout.choiceList.map((e=>({label:t[e]??e.replaceAll("_"," "),value:e}))).sort(((e,t)=>e.label>t.label?1:0)).map((({label:e,value:t},a)=>g("calcite-list-item",{description:i.getPageSizeLabel(t),key:`service-template-${a}`,label:e,selected:t===this.templateOptions.layout,value:t}))),c=(n?.length||0)+(s?.length||0)+(r?.length||0)>15;return g("calcite-flow-item",{bind:this,closable:!1,heading:t.chooseTemplate,key:"template-flow-item",onCalciteFlowItemBack:()=>{this._showTemplates=!1}},this.browseTemplateButtonOnClick?g("calcite-button",{appearance:"outline",class:O.browseTemplateButtonContainer,onclick:this.browseTemplateButtonOnClick},"Browse Templates"):null,g("calcite-list",{filterEnabled:c,selectionMode:"single-persist",onCalciteListChange:({target:e})=>this._applyTemplate(e.selectedItems[0].value)},n?.length?g("calcite-list-item-group",{heading:t.organizationTemplates,key:"org-templates"},n):null,n?.length?s?.length?g("calcite-list-item-group",{heading:t.defaultTemplates,key:"default-templates"},s):null:s,n?.length?r?.length?g("calcite-list-item-group",{heading:t.defaultTemplates,key:"service-templates"},r):null:r),g("div",{class:O.templateButtonContainer},g("calcite-button",{class:O.templateDoneButton,onclick:()=>this._showTemplates=!1},"Done")))}_renderCustomTextElementSection(){const{customTextElements:e}=this.templateOptions;return e?g("div",{class:O.formSectionContainer,key:"custom-text-elements"},e.map((e=>{const[t,i]=Object.entries(e)[0];return"date"===t?null:g("label",{key:t},t,g("input",{bind:this,class:this.classes(O.inputText,m.input),"data-input-custom":!0,"data-input-name":t,onchange:this._updateInputValue,type:"text",value:i}))}))):null}async _applyTemplate(e){if(this._abortController&&(this._abortController.abort(),this._abortController=null),!e)return;const t=this.viewModel.defaultTemplates.find((({layoutItem:t})=>e===t?.id))??this.viewModel.browseTemplates.find((({layoutItem:t})=>e===t?.id));if(!t)return this.templateOptions.layout=e,void(this.templateOptions.layoutItem=null);const{format:i,layoutItem:a}=t,l=a?.id??t.layout??this.templateOptions.layout;if(this.templateOptions.layout=l,!t.layoutOptions)try{this._abortController=new AbortController,await this.viewModel.fetchLayoutTemplateInfo(t,{signal:this._abortController.signal})}catch(s){return}finally{this._abortController=null}const o=t.layoutOptions?.legend??this.templateOptions.legendEnabled,n=t.layoutOptions?.northArrow??this.templateOptions.northArrowEnabled;this.templateOptions.set({format:i,layout:l,layoutItem:a,legendEnabled:o,northArrowEnabled:n})}_renderTitleOrFileNameSection(){const{title:e,fileName:t,titlePlaceHolder:i,fileNamePlaceHolder:a}=this.messages,l=this._selectedTab===T.layout?e:t,o=this._selectedTab===T.layout?i:a,n=this._selectedTab===T.layout?this.templateOptions.title:this.templateOptions.fileName;return g("div",{class:O.formSectionContainer,key:l},g("calcite-label",null,l,g("calcite-input",{placeholder:o,value:n??"",onCalciteInputInput:this._onInput})))}_focusOnTabChange(e){if(!this._activeTabFocusRequested)return;const t=e.getAttribute("data-tab-id");("layoutTab"===t&&this._selectedTab===T.layout||"mapOnlyTab"===t&&this._selectedTab===T.mapOnly||"exportTab"===t&&this._selectedTab===T.export)&&(e.focus(),this._activeTabFocusRequested=!1)}_renderLoader(){const e={[O.loader]:this._awaitingServerResponse};return g("div",{class:this.classes(e),key:"loader"})}_createFileLink(e,t){const i=t||this.messages.untitled,a=e.format.toLowerCase(),l=a.includes("png")?"png":a,o=i+l;return void 0!==this._exportedFileNameMap[o]?this._exportedFileNameMap[o]++:this._exportedFileNameMap[o]=0,new d({name:i,extension:l,count:this._exportedFileNameMap[o]})}_resetToCurrentScale(){this.templateOptions.scale=this.viewModel.view?.scale}_updateCustomTextElementValue(e,t,i){e.find((e=>{const[i]=Object.entries(e)[0];return i===t}))[t]=i}_updateInputValue(e){const t=e.target,i=t.getAttribute("data-input-name"),a=!!t["data-input-custom"],{templateOptions:l}=this;if(a)return void this._updateCustomTextElementValue(l.customTextElements,i,t.value);let o;if("number"===t.type){if(!k(t.valueAsNumber)){const e=l[i];return void(t.value=`${e}`)}o=t.valueAsNumber}else o=t.value;l[i]=o}_handleDPIChange(e){const{templateOptions:t}=this,i=t.dpi;this._updateInputValue(e);const a=e.currentTarget.valueAsNumber,{height:l,width:o}=I(a,i,t.width,t.height);t.height=l,t.width=o}_handlePrintMap(){this._pendingExportScroll=!0;const{templateOptions:e}=this,t=this.viewModel.toPrintTemplate(e),i=this._selectedTab===T.layout?t.layoutOptions?.titleText:e.fileName,a=this._createFileLink(t,i);this.exportedLinks.add(a),this.emit("submit",{link:a}),this._selectedTab=T.export,this.viewModel.print(t).then((e=>{a.set({url:e&&e.url,state:"ready"})})).catch((e=>{a.set({error:e,state:"error"})})).then((()=>{this.emit("complete",{link:a}),this.scheduleRender()}))}_switchInput(){[this.templateOptions.width,this.templateOptions.height]=[this.templateOptions.height,this.templateOptions.width]}_scrollExportIntoView(){if(!this._pendingExportScroll)return;this._pendingExportScroll=!1;const e=this._rootNode;if(!e)return;const{clientHeight:t,scrollHeight:i}=e,a=i-t;a>0&&(e.scrollTop=a)}_toggleInputValue(e){const t=e.target,i=t.getAttribute("data-option-name");this.templateOptions[i]=t.checked,"scaleEnabled"===i&&(this.templateOptions[i]||this._resetToCurrentScale())}_renderExportedLink(e){const t=this.messages,i=e.map((e=>{const{error:i,url:a,state:n}=e,s=e.formattedName??"",r="error"===n,c="pending"===n,p="ready"===n;let d=a||null;d&&(d=l(d));const u=o(a,location.href);let h;h=c?t.pending:p?t.ready:t.errorMessage;const b=r?"print-task:cim-symbol-unsupported"===i?.name?t.exportWebMapCIMError:t.exportWebMapError:"";return g("calcite-list-item",{"aria-label":h,class:O.exportedFile,"data-item":e,description:c?t.generatingExport:b||t.linkReady,key:s,label:s,onclick:this._removeLink,title:b},g("calcite-icon",{class:c?m.rotating:"",icon:L(e),scale:"s",slot:"content-start"}),p?g("a",{"aria-label":`${s}. ${t.linkReady}`,download:s,href:d??"",onclick:this._handleLinkClick,rel:"noreferrer",slot:"content-end",tabIndex:0,target:"_blank"},g("calcite-action",{"aria-label":`${s}. ${t.linkReady}`,icon:u?"download-to":"launch",onclick:this._handleLinkClick,text:s})):null)}));return g("calcite-list",{filterEnabled:e?.length>10},i)}_toggleLayoutPanel(e){const t=e.target;this._toggleTab(t.getAttribute("data-tab-id"))}_toggleTab(e,t=!0){this._selectedTab=e,this._selectedTab!==T.export&&(this.templateOptions.layout=this._selectedTab===T.layout?this._selectedLayout??this.viewModel.templatesInfo?.layout?.defaultValue??"letter-ansi-a-landscape":w,this.templateOptions.layoutItem=null),t&&(this._activeTabFocusRequested=!0)}_handleLayoutPanelKeyDown(e){const{key:t}=e,i=e.target.getAttribute("data-tab-id");if(y(t))return this._toggleTab(i),e.preventDefault(),void e.stopPropagation();if("ArrowLeft"===t||"ArrowRight"===t){switch(i){case T.layout:this._toggleTab("ArrowLeft"===t?T.export:T.mapOnly);break;case T.mapOnly:this._toggleTab("ArrowLeft"===t?T.layout:T.export);break;case T.export:this._toggleTab("ArrowLeft"===t?T.mapOnly:T.layout)}e.preventDefault(),e.stopPropagation()}}};e([n()],M.prototype,"allowedFormats",null),e([n()],M.prototype,"allowedLayouts",null),e([n()],M.prototype,"browseTemplateButtonOnClick",void 0),e([n()],M.prototype,"error",null),e([n({type:v})],M.prototype,"exportedLinks",void 0),e([n()],M.prototype,"extraParameters",null),e([n()],M.prototype,"headingLevel",void 0),e([n()],M.prototype,"icon",null),e([n()],M.prototype,"includeDefaultTemplates",null),e([n()],M.prototype,"label",null),e([n(),f("esri/widgets/Print/t9n/Print")],M.prototype,"messages",void 0),e([n()],M.prototype,"portal",null),e([n()],M.prototype,"printServiceUrl",null),e([n()],M.prototype,"templateCustomTextElements",null),e([n()],M.prototype,"templateOptions",null),e([n()],M.prototype,"view",null),e([n({type:u})],M.prototype,"viewModel",void 0),M=e([s("esri.widgets.Print")],M);const S=M;export{S as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import t from"../core/Collection.js";import{clone as l}from"../core/lang.js";import{watch as i}from"../core/reactiveUtils.js";import{addProxy as a,hasSameOrigin as o}from"../core/urlUtils.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import{subclass as s}from"../core/accessorSupport/decorators/subclass.js";import{getToken as r}from"../rest/utils.js";import{toJSON as c}from"../rest/support/fileFormat.js";import p from"./Widget.js";import d from"./Print/FileLink.js";import u from"./Print/PrintViewModel.js";import{loadCalciteComponents as h}from"./support/componentsUtils.js";import{globalCss as m}from"./support/globalCss.js";import{Heading as b}from"./support/Heading.js";import{legacyIcon as _}from"./support/legacyIcon.js";import{isActivationKey as y}from"./support/widgetUtils.js";import{messageBundle as g}from"./support/decorators/messageBundle.js";import{tsx as f}from"./support/jsxFactory.js";const v=t.ofType(d),w="MAP_ONLY";var T;!function(e){e.layout="layoutTab",e.mapOnly="mapOnlyTab",e.export="exportTab"}(T||(T={}));const x="esri-print",C=`${x}__advanced-options-button`,O={base:x,headerTitle:`${x}__header-title`,inputText:`${x}__input-text`,layoutTabList:`${x}__layout-tab-list`,layoutTab:`${x}__layout-tab`,layoutSection:`${x}__layout-section`,mapOnlySection:`${x}__map-only-section`,scaleInput:`${x}__scale-input`,panelItemsCentered:`${x}__panel-items--centered`,loader:`${x}__loader`,advancedOptionsButton:C,advancedOptionsButtonContainer:`${C}-container`,advancedOptionsButtonTitle:`${C}-title`,advancedOptionsButtonIconOpened:`${C}-icon--opened`,advancedOptionsButtonIconClosed:`${C}-icon--closed`,advancedOptionsButtonIconClosed_RTL:`${C}-icon--closed-rtl`,refreshButton:`${x}__refresh-button`,swapButton:`${x}__swap-button`,printButton:`${x}__export-button`,templateSelectContainer:`${x}__template-select-container`,templateSelectBlock:`${x}__template-select-block`,templateSelectIcon:`${x}__template-select-icon`,formSectionContainer:`${x}__form-section-container`,formInputLabel:`${x}__form-input-label`,formCheckboxLabel:`${x}__form-checkbox-label`,advancedOptionsSection:`${x}__advanced-options-section`,advancedOptionsContainer:`${x}__advanced-options-container`,authorInfoContainer:`${x}__author-info-container`,browseTemplateButtonContainer:`${x}__browse-template-button-container`,copyrightInfoContainer:`${x}__copyright-info-container`,exportedFilesContainer:`${x}__export-panel-container`,exportedFilesTitle:`${x}__export-title`,exportedFile:`${x}__exported-file`,exportedFileLink:`${x}__exported-file-link`,exportedFileLinkTitle:`${x}__exported-file-link-title`,exportedFilesEmpty:`${x}__exported-files-empty`,legendInfoContainer:`${x}__legend-info-container`,printWidgetContainer:`${x}__container`,content:`${x}__content`,panelContainer:`${x}__panel-container`,scaleInfoContainer:`${x}__scale-info-container`,scaleInputContainer:`${x}__scale-input-container`,sizeContainer:`${x}__size-container`,panelError:`${x}__panel--error`,exportedFileError:`${x}__exported-file--error`,exportSection:`${x}__export-section`,exportSectionCentered:`${x}__export-section--centered`,templateButtonContainer:`${x}__template-button-container`,templateDoneButton:`${x}__template-done-button`};function I(e,t,l,i){const a=l/t,o=i/t;return{width:Math.round(e*a),height:Math.round(e*o)}}function k(e){return!isNaN(e)&&e>0}function $(e){return e?.toUpperCase()===w}function L(e){const{state:t,extension:l}=e;switch(t){case"pending":return"spinner";case"error":return"exclamation-mark-circle";default:return l?.toLowerCase()?.includes("pdf")?"file-pdf":"file"}}function M(e,t){return!!t&&e.some((e=>e.layoutItem?.id===t||e.layout===t))}let S=class extends p{constructor(e,t){super(e,t),this._activeTabFocusRequested=!1,this._awaitingServerResponse=!1,this._exportedFileNameMap={},this._selectedTab=T.layout,this._pendingExportScroll=!1,this._rootNode=null,this._selectedLayout=null,this._abortController=null,this._showTemplates=!1,this.browseTemplateButtonOnClick=null,this.exportedLinks=new v,this.headingLevel=3,this.viewModel=new u,this._onInput=e=>{this._selectedTab===T.layout?this.templateOptions.title=e.target.value:this._selectedTab===T.mapOnly&&(this.templateOptions.fileName=e.target.value)},this._removeLink=e=>{const t=e.currentTarget["data-item"];t&&"error"===t.state&&this.exportedLinks.remove(t)},this._handleLinkClick=e=>{const t=e.currentTarget,{href:l}=t,i=r(this.viewModel.effectivePrintServiceUrl);if(!i)return;if(!e.isTrusted)return void e.stopPropagation();e.preventDefault();const a=new URL(l);a.searchParams.set("token",i),t.href=a.href,t.click(),t.href=l},this._focusOnTabChange=this._focusOnTabChange.bind(this)}initialize(){this.addHandles([i((()=>[this.templateOptions.format,this.viewModel.templatesInfo?.format.defaultValue]),(([e,t])=>{if(t&&!e)return void(this.templateOptions.format=t);if(!e||!t||!this.viewModel.templatesInfo)return;if(this.viewModel.templatesInfo.format.choiceList.includes(e))return;const l=this.viewModel.templatesInfo.format.choiceList.find((t=>t.toUpperCase().includes(`(${e.toUpperCase()})`)));this.templateOptions.format=l??t})),i((()=>[this.templateOptions.layout,this.viewModel.templatesInfo?.layout.defaultValue]),(([e,t])=>{if(this._selectedTab=$(e)?T.mapOnly:T.layout,this._selectedTab!==T.layout)return;const{includeDefaultTemplates:i,viewModel:a,_selectedLayout:o}=this,{portalTemplateIds:n,browseTemplates:s,templatesInfo:r}=a,c=a.defaultTemplates.filter((({layoutItem:e})=>n.includes(e?.id))),p=a.defaultTemplates.filter((({layoutItem:e})=>!n.includes(e?.id))),d=i&&p.length;if(e){(d?M(p,e):r?.layout.choiceList.includes(e))||M(c,e)||M(s,e)||(this.templateOptions.layout=null)}else{const e=o&&((d?M(p,o):r?.layout.choiceList.includes(o))||M(c,o)||M(s,o));this.templateOptions.layout=e?o:null,this.templateOptions.layout||d||!t||(this.templateOptions.layout=t)}this._selectedLayout=this.templateOptions.layout,this._selectedLayout||(this.viewModel.printPreviewEnabled=!1);const u=!!this.templateOptions.layout&&this.viewModel.effectiveTemplateCustomTextElements[this.templateOptions.layout];this.templateOptions.customTextElements=u?l(u):null})),i((()=>this.templateOptions.dpi),(e=>{e<=0&&(this.templateOptions.dpi=1)})),i((()=>this.viewModel.view?.scale),(e=>{!e||this.templateOptions.scaleEnabled&&this.templateOptions.scale||(this.templateOptions.scale=e)}))]);const{height:e,width:t}=this.templateOptions;this.templateOptions.width=t||800,this.templateOptions.height=e||1100;const a=setTimeout((()=>{this._awaitingServerResponse=!0,this.scheduleRender()}),500);this.viewModel.load().then((()=>{clearTimeout(a),this._awaitingServerResponse=!1}))}loadDependencies(){return h({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),block:()=>import("@esri/calcite-components/dist/components/calcite-block.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),checkbox:()=>import("@esri/calcite-components/dist/components/calcite-checkbox.js"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox.js"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item.js"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow.js"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),input:()=>import("@esri/calcite-components/dist/components/calcite-input.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),"list-item-group":()=>import("@esri/calcite-components/dist/components/calcite-list-item-group.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch.js")})}destroy(){this.viewModel.destroy()}get allowedFormats(){return this.viewModel.allowedFormats}set allowedFormats(e){this.viewModel.allowedFormats=e}get allowedLayouts(){return this.viewModel.allowedLayouts}set allowedLayouts(e){this.viewModel.allowedLayouts=e}get error(){return this.viewModel.error}get extraParameters(){return this.viewModel.extraParameters}set extraParameters(e){this.viewModel.extraParameters=e}get icon(){return"print"}set icon(e){this._overrideIfSome("icon",e)}get includeDefaultTemplates(){return this.viewModel.includeDefaultTemplates}set includeDefaultTemplates(e){this.viewModel.includeDefaultTemplates=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get portal(){return this.viewModel.portal}set portal(e){this.viewModel.portal=e}get printServiceUrl(){return this.viewModel.printServiceUrl}set printServiceUrl(e){this.viewModel.printServiceUrl=e}get templateCustomTextElements(){return this.viewModel.templateCustomTextElements}set templateCustomTextElements(e){this.viewModel.templateCustomTextElements=e}get templateOptions(){return this.viewModel.templateOptions}set templateOptions(e){this.viewModel.templateOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}render(){const{messages:e,templateOptions:t,viewModel:l,view:i}=this,{attributionEnabled:a,author:o,copyright:n,dpi:s,format:r,height:p,layout:d,legendEnabled:u,northArrowEnabled:h,scaleEnabled:y,scale:g,width:v}=t,w="ready"!==l.state||this._awaitingServerResponse||!d,x=this._renderTitleOrFileNameSection(),C=f("div",{class:O.formSectionContainer},f("calcite-label",null,e.fileFormatTitle,f("calcite-combobox",{clearDisabled:!0,label:e.formatDefaultOption,maxItems:6,placeholder:e.formatDefaultOption,selectionMode:"single-persist",onCalciteComboboxChange:({target:e})=>{this.templateOptions.format=e.selectedItems[0].value}},l.templatesInfo?.format?.choiceList.sort().map(((e,t)=>f("calcite-combobox-item",{key:`file-format-${t}`,selected:e===this.templateOptions.format,textLabel:c(e),value:e})))))),I=f("div",{class:O.formSectionContainer},f("calcite-label",null,e.template,f("div",{class:O.templateSelectContainer,onclick:()=>{this._showTemplates=!0}},f("calcite-block",{class:O.templateSelectBlock,description:this.viewModel.getPageSizeLabel(d),heading:this._getTemplateLabel()}),f("calcite-icon",{class:O.templateSelectIcon,icon:"chevron-right",scale:"s"})))),k=f("div",{class:O.formSectionContainer},f("label",{class:O.formInputLabel},e.dpi,f("input",{bind:this,class:this.classes(O.inputText,m.input),"data-input-name":"dpi",min:"1",onchange:this._handleDPIChange,tabIndex:0,type:"number",value:`${s}`}))),$=f("div",{class:this.classes(O.scaleInfoContainer,O.formSectionContainer)},f("calcite-label",{layout:"inline"},f("calcite-checkbox",{bind:this,checked:y,"data-option-name":"scaleEnabled",tabIndex:0,onCalciteCheckboxChange:this._toggleInputValue}),e.scale),f("div",{class:O.scaleInputContainer},f("input",{"aria-label":e.scaleLabel,"aria-valuenow":`${g}`,bind:this,class:this.classes(O.inputText,m.input,O.scaleInput),"data-input-name":"scale",disabled:!y,onchange:this._updateInputValue,role:"spinbutton",tabIndex:0,type:"number",value:`${g}`}),f("button",{"aria-label":e.reset,bind:this,class:this.classes(m.widgetButton,O.refreshButton,_.refresh),onclick:this._resetToCurrentScale,tabIndex:0,type:"button"}))),L=f("div",{"aria-labelledby":`${this.id}__advancedOptionsForLayout`,class:O.advancedOptionsContainer},$,this.viewModel.layoutTemplateInfo?.layoutOptions?.hasAuthorText??1?f("div",{class:this.classes(O.authorInfoContainer,O.formSectionContainer)},f("label",{class:O.formInputLabel},e.author,f("input",{bind:this,class:this.classes(O.inputText,m.input),"data-input-name":"author",onchange:this._updateInputValue,tabIndex:0,type:"text",value:o??""}))):null,this.viewModel.layoutTemplateInfo?.layoutOptions?.hasCopyrightText??1?f("div",{class:this.classes(O.copyrightInfoContainer,O.formSectionContainer),key:"copyright-text"},f("label",{class:O.formInputLabel},e.copyright,f("input",{bind:this,class:this.classes(O.inputText,m.input),"data-input-name":"copyright",onchange:this._updateInputValue,tabIndex:0,type:"text",value:n??""}))):null,k,this.viewModel.layoutTemplateInfo?.layoutOptions?.hasLegend??1?f("div",{class:this.classes(O.legendInfoContainer,O.formSectionContainer)},f("calcite-label",{layout:"inline"},f("calcite-checkbox",{bind:this,checked:u,"data-option-name":"legendEnabled",tabIndex:0,onCalciteCheckboxChange:this._toggleInputValue}),e.legend)):null,this.viewModel.layoutTemplateNorthArrowInfo??1?f("div",{class:this.classes(O.legendInfoContainer,O.formSectionContainer),key:"north-arrow"},f("calcite-label",{layout:"inline"},f("calcite-checkbox",{bind:this,checked:h,"data-option-name":"northArrowEnabled",tabIndex:0,onCalciteCheckboxChange:this._toggleInputValue}),e.northArrow)):null,this._renderCustomTextElementSection()),M=f("div",{"aria-labelledby":`${this.id}__advancedOptionsForMapOnly`,class:O.advancedOptionsContainer},$,k,f("div",{class:O.formSectionContainer},f("calcite-label",{layout:"inline"},f("calcite-checkbox",{bind:this,checked:a,"data-option-name":"attributionEnabled",tabIndex:0,onCalciteCheckboxChange:this._toggleInputValue}),e.attribution)),this._renderCustomTextElementSection()),S=f("calcite-label",{layout:"inline-space-between"},e.printPreview,f("calcite-switch",{checked:this.viewModel.printPreviewEnabled,disabled:!d,onCalciteSwitchChange:e=>{this.viewModel.printPreviewEnabled=!!e.target.checked}})),E=this.exportedLinks.toArray(),F=this._renderExportedLink(E),j={[O.exportSectionCentered]:!E.length},P=this._selectedTab===T.layout?f("section",{"aria-labelledby":`${this.id}__layoutTab`,class:O.layoutSection,id:`${this.id}__layoutContent`,key:"esri-print__layoutContent",role:"tabpanel"},f("div",{class:O.panelContainer},this.viewModel.layoutTemplateInfo?.layoutOptions?.hasTitleText??1?x:null,I,this._selectedTab===T.layout?C:null,S),f("calcite-block",{"aria-label":e.advancedOptions,class:this.classes(O.panelContainer,O.advancedOptionsSection),collapsible:!0,disabled:!d,heading:e.advancedOptions,id:"advancedOptionsForLayout"},L)):this._selectedTab===T.mapOnly?f("section",{"aria-labelledby":`${this.id}__mapOnlyTab`,class:O.mapOnlySection,id:`${this.id}__mapOnlyContent`,key:"esri-print__mapOnlyContent",role:"tabpanel"},f("div",{class:O.panelContainer},x,C,f("div",{class:this.classes(O.sizeContainer,O.formSectionContainer)},f("label",{class:O.formInputLabel},e.width,f("input",{bind:this,class:this.classes(O.inputText,m.input),"data-input-name":"width",onchange:this._updateInputValue,tabIndex:0,type:"number",value:`${v}`})),f("label",{class:O.formInputLabel},e.height,f("input",{bind:this,class:this.classes(O.inputText,m.input),"data-input-name":"height",onchange:this._updateInputValue,tabIndex:0,type:"number",value:`${p}`})),f("button",{"aria-label":e.swap,bind:this,class:this.classes(m.widgetButton,O.swapButton,_.swap),onclick:this._switchInput,tabIndex:0,type:"button"})),S,f("calcite-block",{"aria-label":e.advancedOptions,class:this.classes(O.panelContainer,O.advancedOptionsSection),collapsible:!0,heading:e.advancedOptions,id:"advancedOptionsForMapOnly"},M))):f("section",{"aria-labelledby":`${this.id}__exportTab`,class:this.classes(O.exportSection,j),id:`${this.id}__exportContent`,key:"esri-print__exportContent",role:"tabpanel"},f("div",{class:O.panelContainer},f("div",{afterUpdate:this._scrollExportIntoView,bind:this,class:O.exportedFilesContainer},0===E.length?f("div",{class:O.exportedFilesEmpty},f("calcite-icon",{icon:"file",scale:"l"}),f("div",null,f(b,{class:O.exportedFilesTitle,level:this.headingLevel},e.noExportedFiles),f("div",null,e.exportHint))):F))),A={[m.buttonDisabled]:w||!d&&!r},B=!i||"2d"!==i.type,D=f("div",{class:O.panelError},B?e.sceneViewError:e.serviceError),N=E.some((({state:e})=>"pending"===e)),V=f("div",{class:O.content},f("ul",{bind:this,class:O.layoutTabList,onclick:this._toggleLayoutPanel,onkeydown:this._handleLayoutPanelKeyDown,role:"tablist"},f("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${this._selectedTab===T.layout}`,class:O.layoutTab,"data-tab-id":T.layout,id:`${this.id}__layoutTab`,role:"tab",tabIndex:0},e.layoutTab),f("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${this._selectedTab===T.mapOnly}`,class:O.layoutTab,"data-tab-id":T.mapOnly,id:`${this.id}__mapOnlyTab`,role:"tab",tabIndex:0},e.mapOnlyTab),f("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${this._selectedTab===T.export}`,class:O.layoutTab,"data-tab-id":T.export,id:`${this.id}__exportedFilesTab`,role:"tab",tabIndex:0},N?f("calcite-loader",{inline:!0,label:"loading",scale:"s"}):null,e.exportsTab)),P,this._selectedTab!==T.export?f("button",{"aria-label":e.exportDescription,bind:this,class:this.classes(O.printButton,m.button,A),disabled:w,onclick:this._handlePrintMap,tabIndex:0,type:"button"},e.export):null),U=f("calcite-flow",{key:"root-flow"},f("calcite-flow-item",{bind:this,closable:!1,key:"root-flow-item"},f("div",{class:O.printWidgetContainer},f("header",{class:O.headerTitle},e.export),this.error||B||!i?D:V)),this._renderChooseTemplateFlowItem()),R="initializing"===l.state,z=R?this._renderLoader():U,H={[O.panelItemsCentered]:R};return f("div",{bind:this,class:this.classes(O.base,m.widget,m.panel,H)},z)}_getTemplateLabel(){const{messages:e,includeDefaultTemplates:t,templateOptions:l,viewModel:i}=this,{layout:a}=l,o=(t?i.defaultTemplates.find((({layoutItem:e})=>a===e?.id)):null)??i.browseTemplates.find((({layoutItem:e})=>a===e?.id));return o?.label?.replaceAll("_"," ")??e[a]??a?.replaceAll("_"," ")??e.selectTemplate}_renderChooseTemplateFlowItem(){if(!this._showTemplates)return null;const{includeDefaultTemplates:e,messages:t,viewModel:l}=this,{defaultTemplates:i,templatesInfo:a,browseTemplates:o,portalTemplateIds:n}=l,s=o.length?o.toArray().sort(((e,t)=>(e.label??"")>(t.label??"")?1:-1)).map(((e,i)=>{const a=e.layoutItem?.id??e.layout,o=l.getPageSizeLabel(a),n=a===this.templateOptions.layout;return f("calcite-list-item",{description:o,key:`browse-template-${i}`,label:e?.label?.replaceAll("_"," ")??t.untitled,selected:n,title:e.description??"",value:a},!o&&n&&e.layoutItem?.id?f("calcite-loader",{inline:!0,label:"loading",scale:"s",slot:"content-end"}):null,f("calcite-action",{icon:"trash",onclick:()=>l.removePortalTemplate(e),slot:"actions-end",text:"delete"}))})):null,r=i.length&&e?i.toArray().filter((({label:e,layoutItem:t})=>!$(e)&&n.includes(t?.id))).sort(((e,t)=>(e.label??"")>(t.label??"")?1:-1)).map(((e,i)=>{const a=e.layoutItem?.id??e.layout,o=l.getPageSizeLabel(a),n=a===this.templateOptions.layout;return f("calcite-list-item",{description:o,key:`default-template-${i}`,label:e?.label?.replaceAll("_"," ")??t.untitled,selected:n,title:e.description??"",value:a},!o&&n&&e.layoutItem?.id?f("calcite-loader",{inline:!0,label:"loading",scale:"s",slot:"content-end"}):null)})):null,c=i.length&&e?i.toArray().filter((({label:e,layoutItem:t})=>!$(e)&&!n.includes(t?.id))).sort(((e,t)=>(e.label??"")>(t.label??"")?1:-1)).map(((e,i)=>{const a=e.layoutItem?.id??e.layout,o=l.getPageSizeLabel(a),n=a===this.templateOptions.layout;return f("calcite-list-item",{description:o,key:`default-template-${i}`,label:e?.label?.replaceAll("_"," ")??t.untitled,selected:n,title:e.description??"",value:a},!o&&n&&e.layoutItem?.id?f("calcite-loader",{inline:!0,label:"loading",scale:"s",slot:"content-end"}):null)})):null,p=!a?.layout?.choiceList.length||e&&c?.length?null:a.layout.choiceList.map((e=>({label:t[e]??e.replaceAll("_"," "),value:e}))).sort(((e,t)=>e.label>t.label?1:0)).map((({label:e,value:t},i)=>f("calcite-list-item",{description:l.getPageSizeLabel(t),key:`service-template-${i}`,label:e,selected:t===this.templateOptions.layout,value:t}))),d=(s?.length??0)+(r?.length??0)+(c?.length??0)+(p?.length??0)>15;return f("calcite-flow-item",{bind:this,closable:!1,heading:t.chooseTemplate,key:"template-flow-item",onCalciteFlowItemBack:()=>{this._showTemplates=!1}},this.browseTemplateButtonOnClick?f("calcite-button",{appearance:"outline",class:O.browseTemplateButtonContainer,onclick:this.browseTemplateButtonOnClick},"Browse Templates"):null,f("calcite-list",{filterEnabled:d,selectionMode:"single-persist",onCalciteListChange:({target:e})=>this._applyTemplate(e.selectedItems[0].value)},s?.length?f("calcite-list-item-group",{heading:t.myTemplates,key:"my-templates"},s):null,r?.length?f("calcite-list-item-group",{heading:t.organizationTemplates,key:"org-templates"},r):null,s?.length||r?.length?c?.length?f("calcite-list-item-group",{heading:t.defaultTemplates,key:"default-templates"},c):null:c,s?.length||r?.length?p?.length?f("calcite-list-item-group",{heading:t.defaultTemplates,key:"service-templates"},p):null:p),f("div",{class:O.templateButtonContainer},f("calcite-button",{class:O.templateDoneButton,onclick:()=>this._showTemplates=!1},"Done")))}_renderCustomTextElementSection(){const{customTextElements:e}=this.templateOptions;return e?f("div",{class:O.formSectionContainer,key:"custom-text-elements"},e.map((e=>{const[t,l]=Object.entries(e)[0];return"date"===t?null:f("label",{key:t},t,f("input",{bind:this,class:this.classes(O.inputText,m.input),"data-input-custom":!0,"data-input-name":t,onchange:this._updateInputValue,type:"text",value:l}))}))):null}async _applyTemplate(e){if(this._abortController&&(this._abortController.abort(),this._abortController=null),!e)return;const t=this.viewModel.defaultTemplates.find((({layoutItem:t})=>e===t?.id))??this.viewModel.browseTemplates.find((({layoutItem:t})=>e===t?.id));if(!t)return this.templateOptions.layout=e,void(this.templateOptions.layoutItem=null);const{format:l,layoutItem:i}=t,a=i?.id??t.layout??this.templateOptions.layout;if(this.templateOptions.layout=a,!t.layoutOptions)try{this._abortController=new AbortController,await this.viewModel.fetchLayoutTemplateInfo(t,{signal:this._abortController.signal})}catch(s){return}finally{this._abortController=null}const o=t.layoutOptions?.legend??this.templateOptions.legendEnabled,n=t.layoutOptions?.northArrow??this.templateOptions.northArrowEnabled;this.templateOptions.set({format:l,layout:a,layoutItem:i,legendEnabled:o,northArrowEnabled:n})}_renderTitleOrFileNameSection(){const{title:e,fileName:t,titlePlaceHolder:l,fileNamePlaceHolder:i}=this.messages,a=this._selectedTab===T.layout?e:t,o=this._selectedTab===T.layout?l:i,n=this._selectedTab===T.layout?this.templateOptions.title:this.templateOptions.fileName;return f("div",{class:O.formSectionContainer,key:a},f("calcite-label",null,a,f("calcite-input",{placeholder:o,value:n??"",onCalciteInputInput:this._onInput})))}_focusOnTabChange(e){if(!this._activeTabFocusRequested)return;const t=e.getAttribute("data-tab-id");("layoutTab"===t&&this._selectedTab===T.layout||"mapOnlyTab"===t&&this._selectedTab===T.mapOnly||"exportTab"===t&&this._selectedTab===T.export)&&(e.focus(),this._activeTabFocusRequested=!1)}_renderLoader(){const e={[O.loader]:this._awaitingServerResponse};return f("div",{class:this.classes(e),key:"loader"})}_createFileLink(e,t){const l=t||this.messages.untitled,i=e.format.toLowerCase(),a=i.includes("png")?"png":i,o=l+a;return void 0!==this._exportedFileNameMap[o]?this._exportedFileNameMap[o]++:this._exportedFileNameMap[o]=0,new d({name:l,extension:a,count:this._exportedFileNameMap[o]})}_resetToCurrentScale(){this.templateOptions.scale=this.viewModel.view?.scale}_updateCustomTextElementValue(e,t,l){e.find((e=>{const[l]=Object.entries(e)[0];return l===t}))[t]=l}_updateInputValue(e){const t=e.target,l=t.getAttribute("data-input-name"),i=!!t["data-input-custom"],{templateOptions:a}=this;if(i)return void this._updateCustomTextElementValue(a.customTextElements,l,t.value);let o;if("number"===t.type){if(!k(t.valueAsNumber)){const e=a[l];return void(t.value=`${e}`)}o=t.valueAsNumber}else o=t.value;a[l]=o}_handleDPIChange(e){const{templateOptions:t}=this,l=t.dpi;this._updateInputValue(e);const i=e.currentTarget.valueAsNumber,{height:a,width:o}=I(i,l,t.width,t.height);t.height=a,t.width=o}_handlePrintMap(){this._pendingExportScroll=!0;const{templateOptions:e}=this,t=this.viewModel.toPrintTemplate(e),l=this._selectedTab===T.layout?t.layoutOptions?.titleText:e.fileName,i=this._createFileLink(t,l);this.exportedLinks.add(i),this.emit("submit",{link:i}),this._selectedTab=T.export,this.viewModel.print(t).then((e=>{i.set({url:e&&e.url,state:"ready"})})).catch((e=>{i.set({error:e,state:"error"})})).then((()=>{this.emit("complete",{link:i}),this.scheduleRender()}))}_switchInput(){[this.templateOptions.width,this.templateOptions.height]=[this.templateOptions.height,this.templateOptions.width]}_scrollExportIntoView(){if(!this._pendingExportScroll)return;this._pendingExportScroll=!1;const e=this._rootNode;if(!e)return;const{clientHeight:t,scrollHeight:l}=e,i=l-t;i>0&&(e.scrollTop=i)}_toggleInputValue(e){const t=e.target,l=t.getAttribute("data-option-name");this.templateOptions[l]=t.checked,"scaleEnabled"===l&&(this.templateOptions[l]||this._resetToCurrentScale())}_renderExportedLink(e){const t=this.messages,l=e.map((e=>{const{error:l,url:i,state:n}=e,s=e.formattedName??"",r="error"===n,c="pending"===n,p="ready"===n;let d=i||null;d&&(d=a(d));const u=o(i,location.href);let h;h=c?t.pending:p?t.ready:t.errorMessage;const b=r?"print-task:cim-symbol-unsupported"===l?.name?t.exportWebMapCIMError:t.exportWebMapError:"";return f("calcite-list-item",{"aria-label":h,class:O.exportedFile,"data-item":e,description:c?t.generatingExport:b||t.linkReady,key:s,label:s,onclick:this._removeLink,title:b},f("calcite-icon",{class:c?m.rotating:"",icon:L(e),scale:"s",slot:"content-start"}),p?f("a",{"aria-label":`${s}. ${t.linkReady}`,download:s,href:d??"",onclick:this._handleLinkClick,rel:"noreferrer",slot:"content-end",tabIndex:0,target:"_blank"},f("calcite-action",{"aria-label":`${s}. ${t.linkReady}`,icon:u?"download-to":"launch",onclick:this._handleLinkClick,text:s})):null)}));return f("calcite-list",{filterEnabled:e?.length>10},l)}_toggleLayoutPanel(e){const t=e.target;this._toggleTab(t.getAttribute("data-tab-id"))}_toggleTab(e,t=!0){this._selectedTab=e,this._selectedTab!==T.export&&(this.templateOptions.layout=this._selectedTab===T.layout?this._selectedLayout??(this.includeDefaultTemplates&&this.viewModel.defaultTemplates.length)?null:this.viewModel.templatesInfo?.layout?.defaultValue:w,this.templateOptions.layoutItem=null),t&&(this._activeTabFocusRequested=!0)}_handleLayoutPanelKeyDown(e){const{key:t}=e,l=e.target.getAttribute("data-tab-id");if(y(t))return this._toggleTab(l),e.preventDefault(),void e.stopPropagation();if("ArrowLeft"===t||"ArrowRight"===t){switch(l){case T.layout:this._toggleTab("ArrowLeft"===t?T.export:T.mapOnly);break;case T.mapOnly:this._toggleTab("ArrowLeft"===t?T.layout:T.export);break;case T.export:this._toggleTab("ArrowLeft"===t?T.mapOnly:T.layout)}e.preventDefault(),e.stopPropagation()}}};e([n()],S.prototype,"_showTemplates",void 0),e([n()],S.prototype,"allowedFormats",null),e([n()],S.prototype,"allowedLayouts",null),e([n()],S.prototype,"browseTemplateButtonOnClick",void 0),e([n()],S.prototype,"error",null),e([n({type:v})],S.prototype,"exportedLinks",void 0),e([n()],S.prototype,"extraParameters",null),e([n()],S.prototype,"headingLevel",void 0),e([n()],S.prototype,"icon",null),e([n()],S.prototype,"includeDefaultTemplates",null),e([n()],S.prototype,"label",null),e([n(),g("esri/widgets/Print/t9n/Print")],S.prototype,"messages",void 0),e([n()],S.prototype,"portal",null),e([n()],S.prototype,"printServiceUrl",null),e([n()],S.prototype,"templateCustomTextElements",null),e([n()],S.prototype,"templateOptions",null),e([n()],S.prototype,"view",null),e([n({type:u})],S.prototype,"viewModel",void 0),S=e([s("esri.widgets.Print")],S);const E=S;export{E as default};