@arcgis/core 4.31.1 → 4.31.2
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.
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/kernel.js +1 -1
- package/package.json +1 -1
- package/support/revision.js +1 -1
- package/symbols/cim/animationUtils.js +1 -1
- package/symbols/cim/cimAnalyzer.js +1 -1
- package/views/2d/layers/MediaLayerView2D.js +1 -1
- package/views/2d/layers/TileLayerView2D.js +1 -1
- package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
- package/widgets/FeatureTable.js +1 -1
- package/widgets/Print/PrintViewModel.js +1 -1
- package/widgets/Print.js +1 -1
- package/widgets/support/GridControls/GridControlsViewModel.js +1 -1
- package/widgets/support/SnappingControls.js +1 -1
package/widgets/FeatureTable.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"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import{watch as i,sync as l,initial as o,on as n}from"../core/reactiveUtils.js";import{formatFileSize as s}from"../core/unitFormatUtils.js";import{property as a}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import{isLayerFromCatalog as c}from"../layers/catalog/catalogUtils.js";import{isKnowledgeGraphLayer as d,isSubtypeGroupLayer as h}from"../layers/support/layerUtils.js";import m from"../tables/AttributeTableTemplate.js";import p from"./Widget.js";import{isSupportedImage as u,getCalciteIconForAttachment as g}from"./Attachments/support/attachmentUtils.js";import{loadPromptComponents as b,Prompt as w}from"./Editor/components/Prompt.js";import v from"./FeatureTable/ColumnMenuVisibleElements.js";import f from"./FeatureTable/FeatureTableViewModel.js";import y from"./FeatureTable/VisibleElements.js";import{loadFieldColumnComponents as _,isIFeatureTableSupportedLayer as M,isIFeatureTableSupportedLayerWithAttachments as C,getRelationshipIdsToShow as S,isMapImageLayer as T}from"./FeatureTable/support/tableUtils.js";import{loadCalciteComponents as A}from"./support/componentsUtils.js";import{globalCss as E}from"./support/globalCss.js";import{renderingSanitizer as I,storeNode as V,discardNode as R}from"./support/widgetUtils.js";import{messageBundle as k}from"./support/decorators/messageBundle.js";import{vmEvent as x}from"./support/decorators/vmEvent.js";import{tsx as D}from"./support/jsxFactory.js";import{substitute as j}from"../intl/substitute.js";var P;const F="esri-feature-table",L=`${F}__prompt`,O=`${F}__attachments-view`,z={base:F,content:`${F}__content`,menuPopover:`${F}__menu-popover`,layerDropdownMenu:`${F}__layer-switcher-menu`,tableContainer:`${F}__table-container`,tableContainerWithAttachments:`${F}__table-container--attachments`,tableNavigation:`${F}__table-navigation`,attachmentsView:O,attachmentsViewContent:`${O}__content`,attachmentsViewDropArea:`${O}__drop-area`,attachmentsViewIcon:`${O}__icon`,attachmentsViewInformation:`${O}__information`,attachmentsViewList:`${O}__list`,attachmentsViewListFileSize:`${O}__list__filesize`,attachmentsViewListItemDelete:`${O}__list-item--delete`,attachmentsViewListThumbnail:`${O}__list__thumbnail`,expanded:`${F}__expanded`,collapsed:`${F}__collapsed`,promptContainer:L,promptHeader:`${L}__header`,promptHeading:`${L}__header__heading`,promptMessage:`${L}__message`,promptDivider:`${L}__divider`,promptActions:`${L}__actions`},$={attachment:"attachment",chevronDown:"chevron-down",chevronLeft:"chevron-left",chevronRight:"chevron-right",clearSelection:"clear-selection",downloadTo:"download-to",exclamationMarkTriangle:"exclamation-mark-triangle",exportToCSV:"file-csv",folderOpen:"folder-open",delete:"trash",launch:"launch",layers:"layers",moveUp:"move-up",plus:"plus",refresh:"refresh",replaceImage:"replace-image",save:"save",showAll:"selection-x",showColumn:"show-column",showSelected:"selection-filter",upload:"upload",zoomToSelection:"zoom-to-object"};let U=P=class extends p{constructor(e,t){super(e,t),this._attachmentsInput=null,this._columnVisibilityActions=new Map,this.attachmentsList=null,this.description=null,this.disabled=!1,this.layers=null,this.menuConfig=null,this.title=null,this.viewModel=new f,this.visibleElements=new y,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((()=>[this._effectiveVisibleElements,this._effectiveVisibleElements.columnDescriptions,this._effectiveVisibleElements.columnMenus,this._effectiveVisibleElements.columnMenuItems,this.columns.length]),(()=>{this.columns.forEach((e=>e.visibleElements=this._effectiveVisibleElements)),this.refreshCellContent()}),l),i((()=>this._effectiveVisibleElements.selectionColumn),(e=>{this.grid&&(this.grid.selectionColumnEnabled=e)}),o),n((()=>this.viewModel),"show-related-table",(e=>this._onShowRelatedTable(e))),i((()=>this.editingEnabled),(()=>{this.clearPrompt(),this._attachmentsInput&&(this._attachmentsInput.value="")}))])}loadDependencies(){return Promise.all([A({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),alert:()=>import("@esri/calcite-components/dist/components/calcite-alert.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),chip:()=>import("@esri/calcite-components/dist/components/calcite-chip.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"),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"),pagination:()=>import("@esri/calcite-components/dist/components/calcite-pagination.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"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch.js"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip.js")}),b(),_()])}destroy(){this.drainRelatedTables(),this.clearPrompt()}get _effectiveDescription(){const{description:e}=this;return null!=e?I.sanitize("function"==typeof e?e():e):void 0}get _effectiveLayers(){const{layer:e,layers:t}=this,i=t?.length?t.filter(M):[],l=i.length?i:[...this._viewLayers];return e&&!l.includes(e)&&l.push(e),l}get _effectiveTitle(){const{layer:e,messages:t,state:i,highlightIds:l,title:o,size:n}=this;if(o)return I.sanitize("function"==typeof o?o():o);if(!e)return t.noLayer;switch(i){case"disabled":return t.errorLayer;case"ready":case"loading":return t.loading;case"error":return t.errorData}return j(t.header,{title:I.sanitize(e.title),count:n,selected:l.length})}get _effectiveVisibleElements(){return this.visibleElementsOverride??this.visibleElements}get _filteredTables(){const e=this.relatedTables.toArray(),t=1===e.length;return this.allRelatedTablesVisible?e:t?[e[0]]:this._shouldShowAttachmentsView?e.slice(-1):e.slice(-2)}get _hasAttachmentsViewError(){return null!=this.attachmentsViewOptions.error}get _hasCustomMenuItems(){return!!this.menuConfig?.items?.length}get _hasDefaultMenuItems(){return!!(this._showClearSelectionAction||this._showDeleteSelectionAction||this._showExportSelectionToCSVAction||this._showRefreshDataAction||this._showZoomToSelectionAction||this._showSelectedRecordsShowSelectedAction||this._showSelectedRecordsShowAllAction||this._showColumnsVisibilityAction)}get _shouldShowGrid(){return this.allRelatedTablesVisible||1===this.relatedTables.length&&!this._shouldShowAttachmentsView}get _shouldShowMenu(){const{header:e,menu:t}=this._effectiveVisibleElements;return!(!e||!t||!this._hasDefaultMenuItems&&!this._hasCustomMenuItems)}get _shouldShowAttachmentsView(){return!(null==this.attachmentsViewOptions.objectId&&!this.relatedTables.some((e=>null!=e.attachmentsViewOptions.objectId)))}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.allRelatedTablesVisible||this._shouldShowAttachmentsView)}get _showDeleteSelectionAction(){return!(!(this.editingEnabled&&this.highlightIds.length&&this._effectiveVisibleElements.menuItems?.deleteSelection&&this.layer?.capabilities?.operations?.supportsDelete)||this.relatedTables.length)}get _showExportSelectionToCSVAction(){return!(!(this._effectiveVisibleElements.menuItems.exportSelectionToCSV&&this.layer&&this.highlightIds.length)||this.relatedTables.length)}get _showLayerDropdown(){return!(!this._effectiveLayers.length||!this._effectiveVisibleElements.layerDropdown)}get _shouldShowNavigationBar(){const e=!!this.relatedTable||this._shouldShowAttachmentsView;return!this.tableParent&&e}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.effectiveTable.layer?.isTable||!this._effectiveVisibleElements.menuItems?.zoomToSelection)}get _viewLayers(){const e=this.view?.map;if(!e)return[];const t=new Set,i=e=>{!M(e)||h(e)||t.has(e)||t.add(e)},l=e=>{c(e)||"catalog-footprint"===e.type||(d(e)?(e.layers?.forEach(i),e.tables?.forEach(i)):T(e)?(e.sublayers?.forEach(i),e.subtables?.forEach(i)):h(e)?e.sublayers?.forEach(i):i(e))};return e.allLayers.forEach(l),e.allTables.forEach(l),[...t.values()]}get grid(){return this.viewModel.grid}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 allColumns(){return this.viewModel.allColumns}get allRelatedTablesVisible(){return this.viewModel.allRelatedTablesVisible}get attachmentsEnabled(){return this.viewModel.attachmentsEnabled}set attachmentsEnabled(e){this.viewModel.attachmentsEnabled=e}get attachmentsViewOptions(){return this.viewModel.attachmentsViewOptions}set attachmentsViewOptions(e){this.viewModel.attachmentsViewOptions=e}get attributeTableTemplate(){return this.viewModel.attributeTableTemplate}set attributeTableTemplate(e){this.viewModel.attributeTableTemplate=e}get autoRefreshEnabled(){return this.viewModel.autoRefreshEnabled}set autoRefreshEnabled(e){this.viewModel.autoRefreshEnabled=e}get clearPrompt(){return this.viewModel.clearPrompt}set clearPrompt(e){this.viewModel.clearPrompt=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 effectiveSize(){return this.viewModel.effectiveSize}get effectiveTable(){return this.relatedTable||this}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 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 initialSize(){return this.viewModel.initialSize}set initialSize(e){this.viewModel.initialSize=e}get isQueryingOrSyncing(){return this.viewModel.isQueryingOrSyncing}get isSyncingAttachments(){return this.viewModel.isSyncingAttachments}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 maxSize(){return this.viewModel.maxSize}set maxSize(e){this.viewModel.maxSize=e}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 messagesUnits(){return this.viewModel.messagesUnits}set messagesUnits(e){this.viewModel.messagesUnits=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 outFields(){return this.viewModel.outFields}set outFields(e){this.viewModel.outFields=e}get pageCount(){return this.viewModel.pageCount}get pageIndex(){return this.viewModel.pageIndex}set pageIndex(e){this.viewModel.pageIndex=e}get pageSize(){return this.viewModel.pageSize}set pageSize(e){this.viewModel.pageSize=e}get paginationEnabled(){return this.viewModel.paginationEnabled}set paginationEnabled(e){this.viewModel.paginationEnabled=e}get prompt(){return this.viewModel.prompt}set prompt(e){this.viewModel.prompt=e}get relatedRecordsEnabled(){return this.viewModel.relatedRecordsEnabled}set relatedRecordsEnabled(e){this.viewModel.relatedRecordsEnabled=e}get relatedTable(){return this.viewModel.relatedTable}get relatedTables(){return this.viewModel.relatedTables}set relatedTables(e){this.viewModel.relatedTables=e}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 returnMEnabled(){return this.viewModel.returnMEnabled}set returnMEnabled(e){this.viewModel.returnMEnabled=e}get returnZEnabled(){return this.viewModel.returnZEnabled}set returnZEnabled(e){this.viewModel.returnZEnabled=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 showAllRelatedTables(){return this.viewModel.showAllRelatedTables}set showAllRelatedTables(e){this.viewModel.showAllRelatedTables=e}get showPrompt(){return this.viewModel.showPrompt}set showPrompt(e){this.viewModel.showPrompt=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 tableController(){return this.viewModel.tableController}set tableController(e){this.viewModel.tableController=e}get tableParent(){return this.viewModel.tableParent}set tableParent(e){this.viewModel.tableParent=e}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}get visibleElementsOverride(){const{attachmentsViewOptions:e,relatedTable:t,tableController:i,visibleElements:l}=this,{columnDescriptions:o,columnMenus:n,tooltips:s}=l,a=null!=e.objectId;if(t)return new y({columnDescriptions:o,columnMenus:n,tooltips:s,close:l.close,header:l.header,layerDropdown:l.layerDropdown,menu:l.menu,menuItems:l.menuItems,progress:l.progress,selectionColumn:!1,columnMenuItems:new v({sortAscending:!1,sortDescending:!1})});if(i){const e=i.relatedTable===this,t=i.allRelatedTablesVisible,r=e&&l.selectionColumn&&!t&&!a,c=e&&!t&&!a;return new y({columnDescriptions:o,columnMenus:n,tooltips:s,selectionColumn:r,close:!1,header:!1,layerDropdown:!1,menu:!1,progress:!1,columnMenuItems:new v({sortAscending:c,sortDescending:c})})}return a?new y({columnDescriptions:o,columnMenus:n,tooltips:s,close:l.close,header:l.header,layerDropdown:l.layerDropdown,menu:l.menu,menuItems:l.menuItems,progress:l.progress,selectionColumn:!1,columnMenuItems:new v({sortAscending:!1,sortDescending:!1})}):null}clearSelectionFilter(){this.viewModel.clearSelectionFilter()}async deleteAttachments(e,t,i){null!=e&&t?.length&&(i?this._showDeleteAttachmentPrompt(e,t):await this.viewModel.deleteAttachments(e,t))}deleteSelection(e){return this.highlightIds.length?e?(this._showDeletePrompt(),this.scheduleRender(),Promise.resolve()):this.viewModel.deleteSelection():Promise.resolve()}async downloadAttachmentById(e,t){return this.viewModel.downloadAttachmentById(e,t)}drainRelatedTables(){this.viewModel.drainRelatedTables()}exportSelectionToCSV(e){this.viewModel.exportSelectionToCSV(e)}filterBySelection(){this.viewModel.filterBySelection()}findColumn(e){return this.viewModel.findColumn(e)}goToPage(e){this.viewModel.goToPage(e)}hideColumn(e){this.grid?.hideColumn(e)}nextPage(){this.viewModel.nextPage()}previousPage(){this.viewModel.previousPage()}async refresh(){await this.viewModel.refresh()}refreshCellContent(){this.viewModel.refreshCellContent()}async saveAttachmentsViewForm(){await this.viewModel.saveAttachmentsViewForm()}showAllColumns(){this.viewModel.showAllColumns()}showColumn(e){this.grid?.showColumn(e)}sortColumn(e,t){this.viewModel.sortColumn(e,t)}scrollLeft(){this.viewModel.scrollLeft()}scrollToBottom(){this.viewModel.scrollToBottom()}scrollToIndex(e){this.viewModel.scrollToIndex(e)}scrollToRow(e){this.viewModel.scrollToRow(e)}scrollToTop(){this.viewModel.scrollToTop()}toggleColumnVisibility(e){this.viewModel.toggleColumnVisibility(e)}zoomToSelection(){this.effectiveTable.viewModel.zoomToSelection()}render(){const{_effectiveVisibleElements:e,isQueryingOrSyncing:t,menuConfig:i,state:l}=this;return D("div",{bind:this,class:this.classes(z.base,E.widget)},D("calcite-panel",{bind:this,class:z.content,closable:e.close,description:this._effectiveDescription,disabled:this.disabled||"disabled"===l&&!this._effectiveLayers?.length,heading:e.header?this._effectiveTitle:void 0,loading:"loading"===l,menuOpen:!!i?.open,overlayPositioning:"fixed",onCalcitePanelClose:e=>{e.target.closed=!1,this.emit("close")}},e.progress?D("calcite-progress",{type:t?"indeterminate":"determinate"}):null,this._showLayerDropdown?this._renderLayerDropdown():null,this._renderColumnVisibilityAction(),this._renderHeaderMenuActions(),this._renderNavigationBar(),this._renderTables(),this._renderError()),this._renderPrompt())}_renderTables(){const{grid:e,relatedTables:t}=this,i=this.classes(z.tableContainer);if(t.length){const l=this.classes(z.base,this.allRelatedTablesVisible?z.expanded:z.collapsed,this._shouldShowAttachmentsView?z.tableContainerWithAttachments:void 0);return D("div",{class:i},D("calcite-panel",{overlayPositioning:"fixed"},D("div",null,[this._shouldShowGrid?D("div",{class:l},e?.render(),this._renderPagination()):void 0,...this._filteredTables.map((e=>{const i=t.indexOf(e);return D("div",{class:l,key:`related-${i}`},e.render())})),,])))}return null!=this.attachmentsViewOptions.objectId?D("div",{class:i},D("calcite-panel",{overlayPositioning:"fixed"},D("div",null,[D("div",{class:this.classes(z.base,z.collapsed)},e?.render(),this._renderPagination()),this._renderAttachmentsView()]))):[D("div",{class:i},e?.render()),this._renderPagination()]}_renderPagination(){if(this.paginationEnabled)return D("calcite-pagination",{pageSize:1,startItem:this.pageIndex+1,totalItems:this.pageCount,onCalcitePaginationChange:e=>this.goToPage(e.target.startItem-1)})}_renderError(){const{messages:e}=this;return D("calcite-alert",{autoClose:!0,autoCloseDuration:"fast",icon:$.exclamationMarkTriangle,kind:"danger",label:e.errorOccured,open:this._hasAttachmentsViewError,slot:"alerts",onCalciteAlertClose:()=>{this.attachmentsViewOptions.error=null}},D("span",{slot:"message"},e.errorOccured))}_renderPrompt(){return this.prompt?D(w,{...this.prompt,headingLevel:2}):void 0}_showDeletePrompt(){const{messages:e,messagesCommon:t}=this,i=j(e.deleteSelectionCount,{count:this.highlightIds.length});this.showPrompt({title:i,message:e.deleteRecordsRemoved,context:"danger",actions:{primary:{label:t.delete,action:this._onDeleteSelectionClick},secondary:{label:e.keepRecords,action:()=>this.clearPrompt()}}})}_showDeleteAttachmentPrompt(e,t){const{messages:i,messagesCommon:l}=this,o=j(i.deleteAttachmentCount,{count:t.length});this.showPrompt({title:o,message:i.deleteAttachmentConfirmation,context:"danger",actions:{primary:{label:l.delete,action:async()=>{try{await this.deleteAttachments(e,t,!1)}finally{this.clearPrompt()}}},secondary:{label:l.cancel,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:n}=e;if(!i)return D("calcite-action",{disabled:t??this.menuConfig?.disabled,icon:l??void 0,key:o,onclick:()=>n(),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;return[this._showRefreshDataAction&&{icon:$.refresh,text:e.refreshData,clickFunction:()=>this.refresh()},this._showDeleteSelectionAction&&{icon:$.delete,text:e.deleteSelection,clickFunction:()=>this.deleteSelection(!0)},this._showClearSelectionAction&&{icon:$.clearSelection,text:e.clearSelection,clickFunction:()=>this.highlightIds?.removeAll()},this._showZoomToSelectionAction&&{icon:$.zoomToSelection,text:e.zoomToSelection,clickFunction:()=>this.zoomToSelection()},this._showSelectedRecordsShowSelectedAction&&{icon:$.showSelected,text:e.showSelected,clickFunction:()=>{const{objectIds:e}=this;e.removeAll(),e.addMany(this.highlightIds.toArray())}},this._showSelectedRecordsShowAllAction&&{icon:$.showAll,text:e.showAllRecords,clickFunction:()=>this.objectIds.removeAll()},this._showExportSelectionToCSVAction&&{icon:$.exportToCSV,text:e.exportSelectionCSV,clickFunction:()=>this.exportSelectionToCSV()}].filter(t).map((e=>e&&this._renderHeaderMenuAction(e)))}_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,effectiveTable:i,id:l,messages:o}=this,n=i.columns.toArray(),s=o?.toggleColumns,a=`${l}__toggle-columns-action`,r=[D("calcite-action",{afterCreate:t=>e.set(l,t),afterRemoved:()=>e.delete(l),appearance:"transparent",bind:this,disabled:i.menuConfig?.disabled,icon:$.showColumn,id:a,slot:"header-actions-end",text:s},t.tooltips?D("calcite-tooltip",{closeOnClick:!0,overlayPositioning:"fixed",placement:"bottom-end",slot:"tooltip"},s):null)];return i.menuConfig?.disabled||r.push(D("calcite-popover",{autoClose:!0,class:z.menuPopover,label:s,overlayPositioning:"fixed",placement:"top-end",pointerDisabled:!0,referenceElement:e.get(l)},D("calcite-list",{filterEnabled:!0,filterPlaceholder:o.toggleColumns,selectionMode:"multiple"},...n.map((e=>{const t="columns"in e&&e.columns?.length?e.columns.map((e=>this._renderColumnListItem({column:e,table:i,ignoreSelect:!0}))):void 0;return this._renderColumnListItem({column:e,table:i,items:t})}))))),r}_renderColumnListItem(e){const{column:t,table:i,items:l,ignoreSelect:o}=e,{effectiveLabel:n,fieldName:s,hidden:a}=t;return D("calcite-list-item",{key:`toggle-columns__item-${s}`,label:n,open:!(!l?.length||a)||void 0,selected:!a,value:s,onCalciteListItemSelect:e=>{o||i.toggleColumnVisibility(e.target.value)}},l)}_renderLayerDropdown(){const e=this.messages.selectALayer;return D("div",{class:z.layerDropdownMenu,key:`${this.id}-layerDropdown`,slot:"header-actions-start"},D("calcite-dropdown",{bind:this,maxItems:5,overlayPositioning:"fixed",placement:"bottom-start"},D("calcite-action",{icon:$.layers,slot:"trigger",text:e,title:e}),D("calcite-dropdown-group",{selectionMode:"single"},this._effectiveLayers.map(((e,t)=>this._renderLayerDropdownItem(e,t)))??null)))}_renderLayerDropdownItem(e,t){return D("calcite-dropdown-item",{key:`dropdown-item-${t}`,label:e.title??"",selected:e===this.layer,value:e.id,onCalciteDropdownItemSelect:()=>{this.layer=e}},e.title)}_onRelatedNavigationItemClick(e){this.viewModel.drainRelatedTablesAboveIndex(e)}_collapseRelatedTable(e){this.viewModel.collapseRelatedTable(this.effectiveTable,e)}_onShowRelatedTable(e){this.showRelatedTableCallback||(this._collapseRelatedTable(e),this._createRelatedTable(e))}async _createRelatedTable(e){const{editingEnabled:t,effectiveTable:i,paginationEnabled:l,pageSize:o,view:n,viewModel:s}=this,{layer:a,objectId:r,relatedLayer:c,relationshipId:d}=e;await a.load();const h=this.attachmentsEnabled&&C(a),m=new P({layer:a,attachmentsEnabled:h,editingEnabled:t,paginationEnabled:l,pageSize:o,relatedRecordsEnabled:!0,relationshipConfig:{objectId:r,relatedLayer:c,relationshipId:d},relationshipColumnConfigs:S(a,d),tableController:this,tableParent:i,view:n,showRelatedTableCallback:e=>s.emit("show-related-table",e)});this.relatedTables.add(m),this.scheduleRender()}_renderAttachmentsView(){const{attachmentInfos:e,mode:t,objectId:i}=this.attachmentsViewOptions;return"file"!==t&&e.length&&null!=i?this._renderAttachmentsViewList():this._renderAttachmentsViewFilePane()}_renderAttachmentsViewFilePane(){const{attachmentsViewOptions:e,isSyncingAttachments:t,messages:i,messagesUnits:l,viewModel:{supportsAddAttachments:o}}=this,{attachmentId:n,attachmentInfos:a,candidates:r,objectId:c}=e,d=a.find((e=>e.id===n)),h=a.length,m=r?.length,p=d?D("calcite-label",{alignment:"center",key:"replace-file-node",scale:"l"},i.replaceFile):void 0,u=m?void 0:D("calcite-label",{alignment:"center",key:"message-node",scale:"m"},o?null==c?i.noFeature:i.dragAndDropToUpload:i.editingRestricted),g=Array.from(r??[]).pop(),b=g?D("calcite-label",{key:"filename-node"},g.name):void 0,w=o&&null!=c,v=w&&m,f=D("input",{afterCreate:V,afterRemoved:R,afterUpdate:V,bind:this,"data-node-ref":"_attachmentsInput",files:r,hidden:!0,name:"attachment",onchange:e=>this._onAttachmentsViewCandidateChange(e),type:"file"}),y=w?D("calcite-button",{appearance:"outline-fill",bind:this,disabled:t,iconStart:$.folderOpen,key:"select-node",loading:!1,onclick:()=>{this._attachmentsInput?.click()},width:"full"},i.selectFile):void 0,_=v?D("calcite-button",{appearance:"outline-fill",bind:this,disabled:t,iconStart:$.save,key:"save-node",loading:t,onclick:()=>{this.saveAttachmentsViewForm()},width:"full"},d?i.updateAttachment:i.addAttachment):void 0,M=h||m?D("calcite-button",{appearance:"transparent",bind:this,disabled:t,key:"cancel-node",onclick:()=>{this._attachmentsInput&&(this._attachmentsInput.value=""),e.reset(),e.attachmentInfos?.length&&(e.mode="list")},width:"full"},this.messagesCommon.cancel):void 0;return[D("div",{class:z.attachmentsView,key:"attachments-view"},D("div",{class:z.attachmentsViewContent,key:"attachments-view-content"},D("div",{bind:this,class:z.attachmentsViewDropArea,ondragover:e=>e.preventDefault(),ondrop:this._onAttachmentsViewDrop},D("calcite-icon",{class:z.attachmentsViewIcon,icon:$.upload,scale:"l"}),p,u,D("form",{afterCreate:t=>e.form=t,afterRemoved:()=>e.form=null,bind:this,key:"attachments-form"},D("fieldset",null,b,f,y,_,M)))),null!=c&&null!=d?D("div",{class:z.attachmentsViewInformation,key:"information"},this._renderAttachmentsViewThumbnail(d,200),D("label",{key:"file-label"},i.fileName),D("span",{key:"file-span"},d.name),D("label",{key:"size-label"},i.size),D("span",{key:"size-span"},s(l,d.size??0))):void 0)]}_renderAttachmentsViewList(){const{attachmentsViewOptions:e,messages:t,messagesUnits:i,viewModel:{store:{syncingAttachmentEdits:l},supportsDeleteAttachments:o,supportsUpdateAttachments:n}}=this,{attachmentInfos:a,objectId:r}=e;return D("calcite-list",{afterCreate:V,afterRemoved:R,afterUpdate:V,bind:this,class:z.attachmentsViewList,"data-node-ref":"attachmentsList",key:`attachments-list-${r}`,loading:l,ondragover:e=>e.preventDefault(),ondrop:this._onAttachmentsViewDrop,selectionMode:"multiple",onCalciteListChange:()=>this.scheduleRender()},...a?.map((l=>{const{id:a,name:c,size:d,url:h}=l,m=s(i,d??0);return D("calcite-list-item",{afterRemoved:()=>this.scheduleRender(),key:`attachment-${a}`,label:c,value:a},this._renderAttachmentsViewListThumbnail(l),D("span",{class:z.attachmentsViewListFileSize,slot:"actions-end",title:m},m),D("calcite-action",{appearance:"transparent",icon:$.downloadTo,key:`download-attachment-${a}`,label:`${c}`,onclick:e=>{e.preventDefault(),this.downloadAttachmentById(r??-1,a)},slot:"actions-end",text:t.downloadAttachment,title:t.downloadAttachment}),n&&null!=r?D("calcite-action",{appearance:"transparent",disabled:!n,icon:$.replaceImage,key:`replace-attachment-${a}`,label:`${c}`,onclick:()=>{e.mode="file",e.attachmentId=a},slot:"actions-end",text:t.updateAttachment,title:t.updateAttachment}):void 0,D("calcite-action",{appearance:"transparent",icon:$.launch,key:`launch-attachment-${a}`,label:`${c}`,onclick:()=>{h&&window.open(h,"_blank")},slot:"actions-end",text:t.viewAttachment,title:t.viewAttachment}),o&&null!=r?D("calcite-action",{appearance:"transparent",class:z.attachmentsViewListItemDelete,disabled:!o,icon:$.delete,key:`delete-attachment-${a}`,label:`${c}`,onclick:()=>{this.deleteAttachments(r,[a],!0)},slot:"actions-end",text:t.deleteAttachment,title:t.deleteAttachment}):void 0)})))}_renderAttachmentsViewListThumbnail(e){return D("div",{class:z.attachmentsViewListThumbnail,slot:"content-start"},D("a",{href:e.url??"",rel:"noreferrer",target:"_blank"},this._renderAttachmentsViewThumbnail(e)))}_renderAttachmentsViewThumbnail(e,t=64){const{contentType:i,name:l,size:o,url:n}=e,s=`${n}${n?.includes("?")?"&":"?"}w=${t}&s=${o}`;return this.viewModel.supportsResizeAttachments&&u(i)?D("img",{alt:l,key:`thumbnail-image-${l}`,src:s,title:l}):D("calcite-icon",{icon:g(i),key:`thumbnail-icon-${l}`,scale:"l",textLabel:l,title:l})}_onAttachmentsViewCandidateChange({target:e}){this.attachmentsViewOptions.candidates=e?.files}_onAttachmentsViewDrop(e){const{viewModel:t}=this;e.preventDefault(),(t.supportsAddAttachments||t.supportsUpdateAttachments)&&this.attachmentsViewOptions.set({mode:"file",candidates:e.dataTransfer?.files})}_renderNavigationBar(){const{effectiveTable:e,messages:t,messagesCommon:i,relatedTable:l,relatedTables:o}=this;if(!this._shouldShowNavigationBar)return;const{attachmentsList:n,attachmentsViewOptions:s,layer:a,viewModel:{supportsAddAttachments:r,supportsDeleteAttachments:c}}=e;if(!a)return;const{attachmentInfos:d,objectId:h}=s,m=null!=h,p=d.length,u=n?.selectedItems?.length??0,g=`${a.objectIdField}: ${h}`,b=j(t.selectedCount,{count:u}),w=j(t.attachmentsCount,{count:p}),v=m?D("calcite-action",{bind:this,icon:$.chevronRight,iconFlipRtl:!0,key:"navigation-feature",onclick:()=>e.scrollToRow(h),text:g,textEnabled:!0,title:g}):void 0,f=m?D("calcite-action",{icon:$.chevronRight,iconFlipRtl:!0,key:"navigation-attachments-label",label:w,onclick:()=>{p>0&&(s.mode="list")},text:w,textEnabled:!0,title:w}):void 0,y=m?D("calcite-chip",{closable:!0,closed:0===u,key:"navigation-chip",kind:"inverse",label:b,selected:!0,title:b,value:"selected",onCalciteChipClose:()=>n?.selectedItems?.forEach((e=>e.selected=!1))},b):void 0,_=l?D("calcite-label",{layout:"inline"},t.showAllTables,D("calcite-switch",{checked:this.allRelatedTablesVisible,onCalciteSwitchChange:e=>this.showAllRelatedTables=!!e.target.checked})):void 0,M=m&&"list"===s.mode&&null!=h&&u&&c?D("calcite-action",{icon:$.delete,iconFlipRtl:!0,key:"attachments-trash-all",onclick:()=>{e.deleteAttachments(h,n?.selectedItems?.map((e=>e.value))??[],!0)},text:i.delete,textEnabled:!0,title:j(t.deleteAttachmentCount,{count:u})}):void 0,C=m&&"list"===s.mode&&r?D("calcite-action",{bind:this,icon:$.plus,iconFlipRtl:!0,key:"attachments-add",onclick:()=>{s.attachmentId=null,s.mode="file"},text:t.addAttachment,textEnabled:!0,title:t.addAttachment}):void 0;return D("div",{class:z.tableNavigation,key:"table-nav"},D("calcite-action",{icon:$.moveUp,iconFlipRtl:!0,key:"go-back",onclick:()=>{l&&this.drainRelatedTables(),e.attachmentsViewOptions.objectId=null},text:this.layer?.title??"",textEnabled:!1,title:l?t.exitRelatedRecords:t.exitAttachments}),o.toArray().map(((e,t)=>this._renderRelatedTableNavigationAction(e,t))),v,f,D("div",null,y,_,M,C))}_renderRelatedTableNavigationAction(e,t){const i=this._getLabelForRelatedTableNavigationAction(e);return D("calcite-action",{icon:$.chevronRight,iconFlipRtl:!0,key:t,onclick:()=>this._onRelatedNavigationItemClick(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}};e([a()],U.prototype,"_attachmentsInput",void 0),e([a()],U.prototype,"_columnVisibilityActions",void 0),e([a()],U.prototype,"_effectiveDescription",null),e([a()],U.prototype,"_effectiveLayers",null),e([a()],U.prototype,"_effectiveTitle",null),e([a()],U.prototype,"_effectiveVisibleElements",null),e([a()],U.prototype,"_filteredTables",null),e([a()],U.prototype,"_hasAttachmentsViewError",null),e([a()],U.prototype,"_hasCustomMenuItems",null),e([a()],U.prototype,"_hasDefaultMenuItems",null),e([a()],U.prototype,"_shouldShowGrid",null),e([a()],U.prototype,"_shouldShowMenu",null),e([a()],U.prototype,"_shouldShowAttachmentsView",null),e([a()],U.prototype,"_showClearSelectionAction",null),e([a()],U.prototype,"_showColumnsVisibilityAction",null),e([a()],U.prototype,"_showDeleteSelectionAction",null),e([a()],U.prototype,"_showExportSelectionToCSVAction",null),e([a()],U.prototype,"_showLayerDropdown",null),e([a()],U.prototype,"_shouldShowNavigationBar",null),e([a()],U.prototype,"_showRefreshDataAction",null),e([a()],U.prototype,"_showSelectedRecordsShowSelectedAction",null),e([a()],U.prototype,"_showSelectedRecordsShowAllAction",null),e([a()],U.prototype,"_showZoomToSelectionAction",null),e([a()],U.prototype,"_viewLayers",null),e([a()],U.prototype,"attachmentsList",void 0),e([a({readOnly:!0})],U.prototype,"grid",null),e([a()],U.prototype,"actionColumnConfig",null),e([a({readOnly:!0})],U.prototype,"activeFilters",null),e([a({readOnly:!0})],U.prototype,"activeSortOrders",null),e([a()],U.prototype,"allColumns",null),e([a({readOnly:!0})],U.prototype,"allRelatedTablesVisible",null),e([a()],U.prototype,"attachmentsEnabled",null),e([a()],U.prototype,"attachmentsViewOptions",null),e([a({type:m})],U.prototype,"attributeTableTemplate",null),e([a()],U.prototype,"autoRefreshEnabled",null),e([a()],U.prototype,"clearPrompt",null),e([a()],U.prototype,"columnPerformanceModeEnabled",null),e([a()],U.prototype,"columnReorderingEnabled",null),e([a({readOnly:!0})],U.prototype,"columns",null),e([a()],U.prototype,"description",void 0),e([a()],U.prototype,"disabled",void 0),e([a()],U.prototype,"editingEnabled",null),e([a()],U.prototype,"effectiveSize",null),e([a()],U.prototype,"effectiveTable",null),e([a()],U.prototype,"filterGeometry",null),e([a()],U.prototype,"filterBySelectionEnabled",null),e([a()],U.prototype,"hiddenFields",null),e([a()],U.prototype,"highlightEnabled",null),e([a()],U.prototype,"highlightIds",null),e([a()],U.prototype,"icon",null),e([a()],U.prototype,"initialSize",null),e([a()],U.prototype,"isQueryingOrSyncing",null),e([a()],U.prototype,"isSyncingAttachments",null),e([a()],U.prototype,"label",null),e([a()],U.prototype,"layer",null),e([a()],U.prototype,"layers",void 0),e([a()],U.prototype,"layerView",null),e([a()],U.prototype,"maxSize",null),e([a(),k("esri/widgets/FeatureTable/t9n/FeatureTable")],U.prototype,"messages",null),e([a(),k("esri/t9n/common")],U.prototype,"messagesCommon",null),e([a(),k("esri/core/t9n/Units")],U.prototype,"messagesUnits",null),e([a(),k("esri/widgets/support/t9n/uriUtils")],U.prototype,"messagesURIUtils",null),e([a()],U.prototype,"menuConfig",void 0),e([a()],U.prototype,"multipleSelectionEnabled",null),e([a()],U.prototype,"multiSortEnabled",null),e([a()],U.prototype,"objectIds",null),e([a()],U.prototype,"outFields",null),e([a()],U.prototype,"pageCount",null),e([a()],U.prototype,"pageIndex",null),e([a()],U.prototype,"pageSize",null),e([a()],U.prototype,"paginationEnabled",null),e([a()],U.prototype,"prompt",null),e([a()],U.prototype,"relatedRecordsEnabled",null),e([a()],U.prototype,"relatedTable",null),e([a()],U.prototype,"relatedTables",null),e([a()],U.prototype,"relationship",null),e([a()],U.prototype,"relationshipColumnConfigs",null),e([a()],U.prototype,"relationshipConfig",null),e([a()],U.prototype,"returnGeometryEnabled",null),e([a()],U.prototype,"returnMEnabled",null),e([a()],U.prototype,"returnZEnabled",null),e([a()],U.prototype,"rowHighlightIds",null),e([a()],U.prototype,"selectionSource",null),e([a()],U.prototype,"showAllRelatedTables",null),e([a()],U.prototype,"showPrompt",null),e([a()],U.prototype,"showRelatedTableCallback",null),e([a()],U.prototype,"size",null),e([a({readOnly:!0})],U.prototype,"state",null),e([a({constructOnly:!0})],U.prototype,"tableController",null),e([a({constructOnly:!0})],U.prototype,"tableParent",null),e([a()],U.prototype,"tableTemplate",null),e([a()],U.prototype,"tableTemplateOverride",null),e([a()],U.prototype,"title",void 0),e([a()],U.prototype,"timeExtent",null),e([a()],U.prototype,"timeZone",null),e([a()],U.prototype,"view",null),e([a({type:f}),x(["cell-click","cell-dblclick","cell-pointerover","cell-pointerout","cell-keydown","column-reorder","show-related-table"])],U.prototype,"viewModel",void 0),e([a({type:y,nonNullable:!0})],U.prototype,"visibleElements",void 0),e([a({type:y})],U.prototype,"visibleElementsOverride",null),U=P=e([r("esri.widgets.FeatureTable")],U);const B=U;export{B as default};
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import{watch as i,sync as l,initial as o,on as n}from"../core/reactiveUtils.js";import{formatFileSize as s}from"../core/unitFormatUtils.js";import{property as a}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import{isLayerFromCatalog as c}from"../layers/catalog/catalogUtils.js";import{isKnowledgeGraphLayer as d,isSubtypeGroupLayer as h}from"../layers/support/layerUtils.js";import m from"../tables/AttributeTableTemplate.js";import p from"./Widget.js";import{isSupportedImage as u,getCalciteIconForAttachment as g}from"./Attachments/support/attachmentUtils.js";import{loadPromptComponents as b,Prompt as w}from"./Editor/components/Prompt.js";import v from"./FeatureTable/ColumnMenuVisibleElements.js";import f from"./FeatureTable/FeatureTableViewModel.js";import y from"./FeatureTable/VisibleElements.js";import{loadFieldColumnComponents as _,isIFeatureTableSupportedLayer as M,isIFeatureTableSupportedLayerWithAttachments as C,getRelationshipIdsToShow as S,isMapImageLayer as T}from"./FeatureTable/support/tableUtils.js";import{loadCalciteComponents as A}from"./support/componentsUtils.js";import{globalCss as E}from"./support/globalCss.js";import{renderingSanitizer as V,storeNode as I,discardNode as R}from"./support/widgetUtils.js";import{messageBundle as k}from"./support/decorators/messageBundle.js";import{vmEvent as x}from"./support/decorators/vmEvent.js";import{tsx as D}from"./support/jsxFactory.js";import{substitute as j}from"../intl/substitute.js";var P;const F="esri-feature-table",L=`${F}__prompt`,O=`${F}__attachments-view`,z={base:F,content:`${F}__content`,menuPopover:`${F}__menu-popover`,layerDropdownMenu:`${F}__layer-switcher-menu`,tableContainer:`${F}__table-container`,tableContainerWithAttachments:`${F}__table-container--attachments`,tableNavigation:`${F}__table-navigation`,attachmentsView:O,attachmentsViewContent:`${O}__content`,attachmentsViewDropArea:`${O}__drop-area`,attachmentsViewIcon:`${O}__icon`,attachmentsViewInformation:`${O}__information`,attachmentsViewList:`${O}__list`,attachmentsViewListFileSize:`${O}__list__filesize`,attachmentsViewListItemDelete:`${O}__list-item--delete`,attachmentsViewListThumbnail:`${O}__list__thumbnail`,expanded:`${F}__expanded`,collapsed:`${F}__collapsed`,promptContainer:L,promptHeader:`${L}__header`,promptHeading:`${L}__header__heading`,promptMessage:`${L}__message`,promptDivider:`${L}__divider`,promptActions:`${L}__actions`},$={attachment:"attachment",chevronDown:"chevron-down",chevronLeft:"chevron-left",chevronRight:"chevron-right",clearSelection:"clear-selection",downloadTo:"download-to",exclamationMarkTriangle:"exclamation-mark-triangle",exportToCSV:"file-csv",folderOpen:"folder-open",delete:"trash",launch:"launch",layers:"layers",moveUp:"move-up",plus:"plus",refresh:"refresh",replaceImage:"replace-image",save:"save",showAll:"selection-x",showColumn:"show-column",showSelected:"selection-filter",upload:"upload",zoomToSelection:"zoom-to-object"};let U=P=class extends p{constructor(e,t){super(e,t),this._attachmentsInput=null,this._columnVisibilityActions=new Map,this.attachmentsList=null,this.description=null,this.disabled=!1,this.layers=null,this.menuConfig=null,this.title=null,this.viewModel=new f,this.visibleElements=new y,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((()=>[this._effectiveVisibleElements,this._effectiveVisibleElements.columnDescriptions,this._effectiveVisibleElements.columnMenus,this._effectiveVisibleElements.columnMenuItems,this.columns.length]),(()=>{this.columns.forEach((e=>e.visibleElements=this._effectiveVisibleElements)),this.refreshCellContent()}),l),i((()=>this._effectiveVisibleElements.selectionColumn),(e=>{this.grid&&(this.grid.selectionColumnEnabled=e)}),o),n((()=>this.viewModel),"show-related-table",(e=>this._onShowRelatedTable(e))),i((()=>this.editingEnabled),(()=>{const{attachmentsViewOptions:e}=this;this.clearPrompt(),e&&(e.form?.reset(),e.candidates=null)}))])}loadDependencies(){return Promise.all([A({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),alert:()=>import("@esri/calcite-components/dist/components/calcite-alert.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),chip:()=>import("@esri/calcite-components/dist/components/calcite-chip.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"),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"),pagination:()=>import("@esri/calcite-components/dist/components/calcite-pagination.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"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch.js"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip.js")}),b(),_()])}destroy(){this.drainRelatedTables(),this.clearPrompt()}get _effectiveDescription(){const{description:e}=this;return null!=e?V.sanitize("function"==typeof e?e():e):void 0}get _effectiveLayers(){const{layer:e,layers:t}=this,i=t?.length?t.filter(M):[],l=i.length?i:[...this._viewLayers];return e&&!l.includes(e)&&l.push(e),l}get _effectiveTitle(){const{layer:e,messages:t,state:i,highlightIds:l,title:o,size:n}=this;if(o)return V.sanitize("function"==typeof o?o():o);if(!e)return t.noLayer;switch(i){case"disabled":return t.errorLayer;case"ready":case"loading":return t.loading;case"error":return t.errorData}return j(t.header,{title:V.sanitize(e.title),count:n,selected:l.length})}get _effectiveVisibleElements(){return this.visibleElementsOverride??this.visibleElements}get _filteredTables(){const e=this.relatedTables.toArray(),t=1===e.length;return this.allRelatedTablesVisible?e:t?[e[0]]:this._shouldShowAttachmentsView?e.slice(-1):e.slice(-2)}get _hasAttachmentsViewError(){return null!=this.attachmentsViewOptions.error}get _hasCustomMenuItems(){return!!this.menuConfig?.items?.length}get _hasDefaultMenuItems(){return!!(this._showClearSelectionAction||this._showDeleteSelectionAction||this._showExportSelectionToCSVAction||this._showRefreshDataAction||this._showZoomToSelectionAction||this._showSelectedRecordsShowSelectedAction||this._showSelectedRecordsShowAllAction||this._showColumnsVisibilityAction)}get _shouldShowGrid(){return this.allRelatedTablesVisible||1===this.relatedTables.length&&!this._shouldShowAttachmentsView}get _shouldShowMenu(){const{header:e,menu:t}=this._effectiveVisibleElements;return!(!e||!t||!this._hasDefaultMenuItems&&!this._hasCustomMenuItems)}get _shouldShowAttachmentsView(){return!(null==this.attachmentsViewOptions.objectId&&!this.relatedTables.some((e=>null!=e.attachmentsViewOptions.objectId)))}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.allRelatedTablesVisible||this._shouldShowAttachmentsView)}get _showDeleteSelectionAction(){return!(!(this.editingEnabled&&this.highlightIds.length&&this._effectiveVisibleElements.menuItems?.deleteSelection&&this.layer?.capabilities?.operations?.supportsDelete)||this.relatedTables.length)}get _showExportSelectionToCSVAction(){return!(!(this._effectiveVisibleElements.menuItems.exportSelectionToCSV&&this.layer&&this.highlightIds.length)||this.relatedTables.length)}get _showLayerDropdown(){return!(!this._effectiveLayers.length||!this._effectiveVisibleElements.layerDropdown)}get _shouldShowNavigationBar(){const e=!!this.relatedTable||this._shouldShowAttachmentsView;return!this.tableParent&&e}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.effectiveTable.layer?.isTable||!this._effectiveVisibleElements.menuItems?.zoomToSelection)}get _viewLayers(){const e=this.view?.map;if(!e)return[];const t=new Set,i=e=>{!M(e)||h(e)||t.has(e)||t.add(e)},l=e=>{c(e)||"catalog-footprint"===e.type||(d(e)?(e.layers?.forEach(i),e.tables?.forEach(i)):T(e)?(e.sublayers?.forEach(i),e.subtables?.forEach(i)):h(e)?e.sublayers?.forEach(i):i(e))};return e.allLayers.forEach(l),e.allTables.forEach(l),[...t.values()]}get grid(){return this.viewModel.grid}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 allColumns(){return this.viewModel.allColumns}get allRelatedTablesVisible(){return this.viewModel.allRelatedTablesVisible}get attachmentsEnabled(){return this.viewModel.attachmentsEnabled}set attachmentsEnabled(e){this.viewModel.attachmentsEnabled=e}get attachmentsViewOptions(){return this.viewModel.attachmentsViewOptions}set attachmentsViewOptions(e){this.viewModel.attachmentsViewOptions=e}get attributeTableTemplate(){return this.viewModel.attributeTableTemplate}set attributeTableTemplate(e){this.viewModel.attributeTableTemplate=e}get autoRefreshEnabled(){return this.viewModel.autoRefreshEnabled}set autoRefreshEnabled(e){this.viewModel.autoRefreshEnabled=e}get clearPrompt(){return this.viewModel.clearPrompt}set clearPrompt(e){this.viewModel.clearPrompt=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 effectiveSize(){return this.viewModel.effectiveSize}get effectiveTable(){return this.relatedTable||this}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 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 initialSize(){return this.viewModel.initialSize}set initialSize(e){this.viewModel.initialSize=e}get isQueryingOrSyncing(){return this.viewModel.isQueryingOrSyncing}get isSyncingAttachments(){return this.viewModel.isSyncingAttachments}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 maxSize(){return this.viewModel.maxSize}set maxSize(e){this.viewModel.maxSize=e}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 messagesUnits(){return this.viewModel.messagesUnits}set messagesUnits(e){this.viewModel.messagesUnits=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 outFields(){return this.viewModel.outFields}set outFields(e){this.viewModel.outFields=e}get pageCount(){return this.viewModel.pageCount}get pageIndex(){return this.viewModel.pageIndex}set pageIndex(e){this.viewModel.pageIndex=e}get pageSize(){return this.viewModel.pageSize}set pageSize(e){this.viewModel.pageSize=e}get paginationEnabled(){return this.viewModel.paginationEnabled}set paginationEnabled(e){this.viewModel.paginationEnabled=e}get prompt(){return this.viewModel.prompt}set prompt(e){this.viewModel.prompt=e}get relatedRecordsEnabled(){return this.viewModel.relatedRecordsEnabled}set relatedRecordsEnabled(e){this.viewModel.relatedRecordsEnabled=e}get relatedTable(){return this.viewModel.relatedTable}get relatedTables(){return this.viewModel.relatedTables}set relatedTables(e){this.viewModel.relatedTables=e}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 returnMEnabled(){return this.viewModel.returnMEnabled}set returnMEnabled(e){this.viewModel.returnMEnabled=e}get returnZEnabled(){return this.viewModel.returnZEnabled}set returnZEnabled(e){this.viewModel.returnZEnabled=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 showAllRelatedTables(){return this.viewModel.showAllRelatedTables}set showAllRelatedTables(e){this.viewModel.showAllRelatedTables=e}get showPrompt(){return this.viewModel.showPrompt}set showPrompt(e){this.viewModel.showPrompt=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 tableController(){return this.viewModel.tableController}set tableController(e){this.viewModel.tableController=e}get tableParent(){return this.viewModel.tableParent}set tableParent(e){this.viewModel.tableParent=e}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}get visibleElementsOverride(){const{attachmentsViewOptions:e,relatedTable:t,tableController:i,visibleElements:l}=this,{columnDescriptions:o,columnMenus:n,tooltips:s}=l,a=null!=e.objectId;if(t)return new y({columnDescriptions:o,columnMenus:n,tooltips:s,close:l.close,header:l.header,layerDropdown:l.layerDropdown,menu:l.menu,menuItems:l.menuItems,progress:l.progress,selectionColumn:!1,columnMenuItems:new v({sortAscending:!1,sortDescending:!1})});if(i){const e=i.relatedTable===this,t=i.allRelatedTablesVisible,r=e&&l.selectionColumn&&!t&&!a,c=e&&!t&&!a;return new y({columnDescriptions:o,columnMenus:n,tooltips:s,selectionColumn:r,close:!1,header:!1,layerDropdown:!1,menu:!1,progress:!1,columnMenuItems:new v({sortAscending:c,sortDescending:c})})}return a?new y({columnDescriptions:o,columnMenus:n,tooltips:s,close:l.close,header:l.header,layerDropdown:l.layerDropdown,menu:l.menu,menuItems:l.menuItems,progress:l.progress,selectionColumn:!1,columnMenuItems:new v({sortAscending:!1,sortDescending:!1})}):null}clearSelectionFilter(){this.viewModel.clearSelectionFilter()}async deleteAttachments(e,t,i){null!=e&&t?.length&&(i?this._showDeleteAttachmentPrompt(e,t):await this.viewModel.deleteAttachments(e,t))}deleteSelection(e){return this.highlightIds.length?e?(this._showDeletePrompt(),this.scheduleRender(),Promise.resolve()):this.viewModel.deleteSelection():Promise.resolve()}async downloadAttachmentById(e,t){return this.viewModel.downloadAttachmentById(e,t)}drainRelatedTables(){this.viewModel.drainRelatedTables()}exportSelectionToCSV(e){this.viewModel.exportSelectionToCSV(e)}filterBySelection(){this.viewModel.filterBySelection()}findColumn(e){return this.viewModel.findColumn(e)}goToPage(e){this.viewModel.goToPage(e)}hideColumn(e){this.grid?.hideColumn(e)}nextPage(){this.viewModel.nextPage()}previousPage(){this.viewModel.previousPage()}async refresh(){await this.viewModel.refresh()}refreshCellContent(){this.viewModel.refreshCellContent()}async saveAttachmentsViewForm(){await this.viewModel.saveAttachmentsViewForm()}showAllColumns(){this.viewModel.showAllColumns()}showColumn(e){this.grid?.showColumn(e)}sortColumn(e,t){this.viewModel.sortColumn(e,t)}scrollLeft(){this.viewModel.scrollLeft()}scrollToBottom(){this.viewModel.scrollToBottom()}scrollToIndex(e){this.viewModel.scrollToIndex(e)}scrollToRow(e){this.viewModel.scrollToRow(e)}scrollToTop(){this.viewModel.scrollToTop()}toggleColumnVisibility(e){this.viewModel.toggleColumnVisibility(e)}zoomToSelection(){this.effectiveTable.viewModel.zoomToSelection()}render(){const{_effectiveVisibleElements:e,isQueryingOrSyncing:t,menuConfig:i,state:l}=this;return D("div",{bind:this,class:this.classes(z.base,E.widget)},D("calcite-panel",{bind:this,class:z.content,closable:e.close,description:this._effectiveDescription,disabled:this.disabled||"disabled"===l&&!this._effectiveLayers?.length,heading:e.header?this._effectiveTitle:void 0,loading:"loading"===l,menuOpen:!!i?.open,overlayPositioning:"fixed",onCalcitePanelClose:e=>{e.target.closed=!1,this.emit("close")}},e.progress?D("calcite-progress",{type:t?"indeterminate":"determinate"}):null,this._showLayerDropdown?this._renderLayerDropdown():null,this._renderColumnVisibilityAction(),this._renderHeaderMenuActions(),this._renderNavigationBar(),this._renderTables(),this._renderError()),this._renderPrompt())}_renderTables(){const{grid:e,relatedTables:t}=this,i=this.classes(z.tableContainer);if(t.length){const l=this.classes(z.base,this.allRelatedTablesVisible?z.expanded:z.collapsed,this._shouldShowAttachmentsView?z.tableContainerWithAttachments:void 0);return D("div",{class:i},D("calcite-panel",{overlayPositioning:"fixed"},D("div",null,[this._shouldShowGrid?D("div",{class:l},e?.render(),this._renderPagination()):void 0,...this._filteredTables.map((e=>{const i=t.indexOf(e);return D("div",{class:l,key:`related-${i}`},e.render())})),,])))}return null!=this.attachmentsViewOptions.objectId?D("div",{class:i},D("calcite-panel",{overlayPositioning:"fixed"},D("div",null,[D("div",{class:this.classes(z.base,z.collapsed)},e?.render(),this._renderPagination()),this._renderAttachmentsView()]))):[D("div",{class:i},e?.render()),this._renderPagination()]}_renderPagination(){if(this.paginationEnabled)return D("calcite-pagination",{pageSize:1,startItem:this.pageIndex+1,totalItems:this.pageCount,onCalcitePaginationChange:e=>this.goToPage(e.target.startItem-1)})}_renderError(){const{messages:e}=this;return D("calcite-alert",{autoClose:!0,autoCloseDuration:"fast",icon:$.exclamationMarkTriangle,kind:"danger",label:e.errorOccured,open:this._hasAttachmentsViewError,slot:"alerts",onCalciteAlertClose:()=>{this.attachmentsViewOptions.error=null}},D("span",{slot:"message"},e.errorOccured))}_renderPrompt(){return this.prompt?D(w,{...this.prompt,headingLevel:2}):void 0}_showDeletePrompt(){const{messages:e,messagesCommon:t}=this,i=j(e.deleteSelectionCount,{count:this.highlightIds.length});this.showPrompt({title:i,message:e.deleteRecordsRemoved,context:"danger",actions:{primary:{label:t.delete,action:this._onDeleteSelectionClick},secondary:{label:e.keepRecords,action:()=>this.clearPrompt()}}})}_showDeleteAttachmentPrompt(e,t){const{messages:i,messagesCommon:l}=this,o=j(i.deleteAttachmentCount,{count:t.length});this.showPrompt({title:o,message:i.deleteAttachmentConfirmation,context:"danger",actions:{primary:{label:l.delete,action:async()=>{try{await this.deleteAttachments(e,t,!1)}finally{this.clearPrompt()}}},secondary:{label:l.cancel,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:n}=e;if(!i)return D("calcite-action",{disabled:t??this.menuConfig?.disabled,icon:l??void 0,key:o,onclick:()=>n(),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;return[this._showRefreshDataAction&&{icon:$.refresh,text:e.refreshData,clickFunction:()=>this.refresh()},this._showDeleteSelectionAction&&{icon:$.delete,text:e.deleteSelection,clickFunction:()=>this.deleteSelection(!0)},this._showClearSelectionAction&&{icon:$.clearSelection,text:e.clearSelection,clickFunction:()=>this.highlightIds?.removeAll()},this._showZoomToSelectionAction&&{icon:$.zoomToSelection,text:e.zoomToSelection,clickFunction:()=>this.zoomToSelection()},this._showSelectedRecordsShowSelectedAction&&{icon:$.showSelected,text:e.showSelected,clickFunction:()=>{const{objectIds:e}=this;e.removeAll(),e.addMany(this.highlightIds.toArray())}},this._showSelectedRecordsShowAllAction&&{icon:$.showAll,text:e.showAllRecords,clickFunction:()=>this.objectIds.removeAll()},this._showExportSelectionToCSVAction&&{icon:$.exportToCSV,text:e.exportSelectionCSV,clickFunction:()=>this.exportSelectionToCSV()}].filter(t).map((e=>e&&this._renderHeaderMenuAction(e)))}_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,effectiveTable:i,id:l,messages:o}=this,n=i.columns.toArray(),s=o?.toggleColumns,a=`${l}__toggle-columns-action`,r=[D("calcite-action",{afterCreate:t=>e.set(l,t),afterRemoved:()=>e.delete(l),appearance:"transparent",bind:this,disabled:i.menuConfig?.disabled,icon:$.showColumn,id:a,slot:"header-actions-end",text:s},t.tooltips?D("calcite-tooltip",{closeOnClick:!0,overlayPositioning:"fixed",placement:"bottom-end",slot:"tooltip"},s):null)];return i.menuConfig?.disabled||r.push(D("calcite-popover",{autoClose:!0,class:z.menuPopover,label:s,overlayPositioning:"fixed",placement:"top-end",pointerDisabled:!0,referenceElement:e.get(l)},D("calcite-list",{filterEnabled:!0,filterPlaceholder:o.toggleColumns,selectionMode:"multiple"},...n.map((e=>{const t="columns"in e&&e.columns?.length?e.columns.map((e=>this._renderColumnListItem({column:e,table:i,ignoreSelect:!0}))):void 0;return this._renderColumnListItem({column:e,table:i,items:t})}))))),r}_renderColumnListItem(e){const{column:t,table:i,items:l,ignoreSelect:o}=e,{effectiveLabel:n,fieldName:s,hidden:a}=t;return D("calcite-list-item",{key:`toggle-columns__item-${s}`,label:n,open:!(!l?.length||a)||void 0,selected:!a,value:s,onCalciteListItemSelect:e=>{o||i.toggleColumnVisibility(e.target.value)}},l)}_renderLayerDropdown(){const e=this.messages.selectALayer;return D("div",{class:z.layerDropdownMenu,key:`${this.id}-layerDropdown`,slot:"header-actions-start"},D("calcite-dropdown",{bind:this,maxItems:5,overlayPositioning:"fixed",placement:"bottom-start"},D("calcite-action",{icon:$.layers,slot:"trigger",text:e,title:e}),D("calcite-dropdown-group",{selectionMode:"single"},this._effectiveLayers.map(((e,t)=>this._renderLayerDropdownItem(e,t)))??null)))}_renderLayerDropdownItem(e,t){return D("calcite-dropdown-item",{key:`dropdown-item-${t}`,label:e.title??"",selected:e===this.layer,value:e.id,onCalciteDropdownItemSelect:()=>{this.layer=e}},e.title)}_onRelatedNavigationItemClick(e){this.viewModel.drainRelatedTablesAboveIndex(e)}_collapseRelatedTable(e){this.viewModel.collapseRelatedTable(this.effectiveTable,e)}_onShowRelatedTable(e){this.showRelatedTableCallback||(this._collapseRelatedTable(e),this._createRelatedTable(e))}async _createRelatedTable(e){const{editingEnabled:t,effectiveTable:i,paginationEnabled:l,pageSize:o,view:n,viewModel:s}=this,{layer:a,objectId:r,relatedLayer:c,relationshipId:d}=e;await a.load();const h=this.attachmentsEnabled&&C(a),m=new P({layer:a,attachmentsEnabled:h,editingEnabled:t,paginationEnabled:l,pageSize:o,relatedRecordsEnabled:!0,relationshipConfig:{objectId:r,relatedLayer:c,relationshipId:d},relationshipColumnConfigs:S(a,d),tableController:this,tableParent:i,view:n,showRelatedTableCallback:e=>s.emit("show-related-table",e)});this.relatedTables.add(m),this.scheduleRender()}_renderAttachmentsView(){const{attachmentInfos:e,mode:t,objectId:i}=this.attachmentsViewOptions;return"file"!==t&&e.length&&null!=i?this._renderAttachmentsViewList():this._renderAttachmentsViewFilePane()}_renderAttachmentsViewFilePane(){const{attachmentsViewOptions:e,isSyncingAttachments:t,messages:i,messagesUnits:l,viewModel:{supportsAddAttachments:o}}=this,{attachmentId:n,attachmentInfos:a,candidates:r,objectId:c}=e,d=a.find((e=>e.id===n)),h=a.length,m=r?.length,p=d?D("calcite-label",{alignment:"center",key:"replace-file-node",scale:"l"},i.replaceFile):void 0,u=m?void 0:D("calcite-label",{alignment:"center",key:"message-node",scale:"m"},o?null==c?i.noFeature:i.dragAndDropToUpload:i.editingRestricted),g=Array.from(r??[]).pop(),b=g?D("calcite-label",{key:"filename-node"},g.name):void 0,w=o&&null!=c,v=w&&m,f=D("input",{afterCreate:I,afterRemoved:R,afterUpdate:I,bind:this,"data-node-ref":"_attachmentsInput",files:r,hidden:!0,name:"attachment",onchange:e=>this._onAttachmentsViewCandidateChange(e),type:"file"}),y=w?D("calcite-button",{appearance:"outline-fill",bind:this,disabled:t,iconStart:$.folderOpen,key:"select-node",loading:!1,onclick:()=>{this._attachmentsInput?.click()},width:"full"},i.selectFile):void 0,_=v?D("calcite-button",{appearance:"outline-fill",bind:this,disabled:t,iconStart:$.save,key:"save-node",loading:t,onclick:()=>{this.saveAttachmentsViewForm()},width:"full"},d?i.updateAttachment:i.addAttachment):void 0,M=h||m?D("calcite-button",{appearance:"transparent",bind:this,disabled:t,key:"cancel-node",onclick:()=>{this._attachmentsInput&&(this._attachmentsInput.value=""),e.reset(),e.attachmentInfos?.length&&(e.mode="list")},width:"full"},this.messagesCommon.cancel):void 0;return[D("div",{class:z.attachmentsView,key:"attachments-view"},D("div",{class:z.attachmentsViewContent,key:"attachments-view-content"},D("div",{bind:this,class:z.attachmentsViewDropArea,ondragover:e=>e.preventDefault(),ondrop:this._onAttachmentsViewDrop},D("calcite-icon",{class:z.attachmentsViewIcon,icon:$.upload,scale:"l"}),p,u,D("form",{afterCreate:t=>e.form=t,afterRemoved:()=>e.form=null,bind:this,key:"attachments-form"},D("fieldset",null,b,f,y,_,M)))),null!=c&&null!=d?D("div",{class:z.attachmentsViewInformation,key:"information"},this._renderAttachmentsViewThumbnail(d,200),D("label",{key:"file-label"},i.fileName),D("span",{key:"file-span"},d.name),D("label",{key:"size-label"},i.size),D("span",{key:"size-span"},s(l,d.size??0))):void 0)]}_renderAttachmentsViewList(){const{attachmentsViewOptions:e,messages:t,messagesUnits:i,viewModel:{store:{syncingAttachmentEdits:l},supportsDeleteAttachments:o,supportsUpdateAttachments:n}}=this,{attachmentInfos:a,objectId:r}=e;return D("calcite-list",{afterCreate:I,afterRemoved:R,afterUpdate:I,bind:this,class:z.attachmentsViewList,"data-node-ref":"attachmentsList",key:`attachments-list-${r}`,loading:l,ondragover:e=>e.preventDefault(),ondrop:this._onAttachmentsViewDrop,selectionMode:"multiple",onCalciteListChange:()=>this.scheduleRender()},...a?.map((l=>{const{id:a,name:c,size:d,url:h}=l,m=s(i,d??0);return D("calcite-list-item",{afterRemoved:()=>this.scheduleRender(),key:`attachment-${a}`,label:c,value:a},this._renderAttachmentsViewListThumbnail(l),D("span",{class:z.attachmentsViewListFileSize,slot:"actions-end",title:m},m),D("calcite-action",{appearance:"transparent",icon:$.downloadTo,key:`download-attachment-${a}`,label:`${c}`,onclick:e=>{e.preventDefault(),this.downloadAttachmentById(r??-1,a)},slot:"actions-end",text:t.downloadAttachment,title:t.downloadAttachment}),n&&null!=r?D("calcite-action",{appearance:"transparent",disabled:!n,icon:$.replaceImage,key:`replace-attachment-${a}`,label:`${c}`,onclick:()=>{e.mode="file",e.attachmentId=a},slot:"actions-end",text:t.updateAttachment,title:t.updateAttachment}):void 0,D("calcite-action",{appearance:"transparent",icon:$.launch,key:`launch-attachment-${a}`,label:`${c}`,onclick:()=>{h&&window.open(h,"_blank")},slot:"actions-end",text:t.viewAttachment,title:t.viewAttachment}),o&&null!=r?D("calcite-action",{appearance:"transparent",class:z.attachmentsViewListItemDelete,disabled:!o,icon:$.delete,key:`delete-attachment-${a}`,label:`${c}`,onclick:()=>{this.deleteAttachments(r,[a],!0)},slot:"actions-end",text:t.deleteAttachment,title:t.deleteAttachment}):void 0)})))}_renderAttachmentsViewListThumbnail(e){return D("div",{class:z.attachmentsViewListThumbnail,slot:"content-start"},D("a",{href:e.url??"",rel:"noreferrer",target:"_blank"},this._renderAttachmentsViewThumbnail(e)))}_renderAttachmentsViewThumbnail(e,t=64){const{contentType:i,name:l,size:o,url:n}=e,s=`${n}${n?.includes("?")?"&":"?"}w=${t}&s=${o}`;return this.viewModel.supportsResizeAttachments&&u(i)?D("img",{alt:l,key:`thumbnail-image-${l}`,src:s,title:l}):D("calcite-icon",{icon:g(i),key:`thumbnail-icon-${l}`,scale:"l",textLabel:l,title:l})}_onAttachmentsViewCandidateChange({target:e}){this.attachmentsViewOptions.candidates=e?.files}_onAttachmentsViewDrop(e){const{viewModel:t}=this;e.preventDefault(),(t.supportsAddAttachments||t.supportsUpdateAttachments)&&this.attachmentsViewOptions.set({mode:"file",candidates:e.dataTransfer?.files})}_renderNavigationBar(){const{effectiveTable:e,messages:t,messagesCommon:i,relatedTable:l,relatedTables:o}=this;if(!this._shouldShowNavigationBar)return;const{attachmentsList:n,attachmentsViewOptions:s,layer:a,viewModel:{supportsAddAttachments:r,supportsDeleteAttachments:c}}=e;if(!a)return;const{attachmentInfos:d,objectId:h}=s,m=null!=h,p=d.length,u=n?.selectedItems?.length??0,g=`${a.objectIdField}: ${h}`,b=j(t.selectedCount,{count:u}),w=j(t.attachmentsCount,{count:p}),v=m?D("calcite-action",{bind:this,icon:$.chevronRight,iconFlipRtl:!0,key:"navigation-feature",onclick:()=>e.scrollToRow(h),text:g,textEnabled:!0,title:g}):void 0,f=m?D("calcite-action",{icon:$.chevronRight,iconFlipRtl:!0,key:"navigation-attachments-label",label:w,onclick:()=>{p>0&&(s.mode="list")},text:w,textEnabled:!0,title:w}):void 0,y=m?D("calcite-chip",{closable:!0,closed:0===u,key:"navigation-chip",kind:"inverse",label:b,selected:!0,title:b,value:"selected",onCalciteChipClose:()=>n?.selectedItems?.forEach((e=>e.selected=!1))},b):void 0,_=l?D("calcite-label",{layout:"inline"},t.showAllTables,D("calcite-switch",{checked:this.allRelatedTablesVisible,onCalciteSwitchChange:e=>this.showAllRelatedTables=!!e.target.checked})):void 0,M=m&&"list"===s.mode&&null!=h&&u&&c?D("calcite-action",{icon:$.delete,iconFlipRtl:!0,key:"attachments-trash-all",onclick:()=>{e.deleteAttachments(h,n?.selectedItems?.map((e=>e.value))??[],!0)},text:i.delete,textEnabled:!0,title:j(t.deleteAttachmentCount,{count:u})}):void 0,C=m&&"list"===s.mode&&r?D("calcite-action",{bind:this,icon:$.plus,iconFlipRtl:!0,key:"attachments-add",onclick:()=>{s.attachmentId=null,s.mode="file"},text:t.addAttachment,textEnabled:!0,title:t.addAttachment}):void 0;return D("div",{class:z.tableNavigation,key:"table-nav"},D("calcite-action",{icon:$.moveUp,iconFlipRtl:!0,key:"go-back",onclick:()=>{l&&this.drainRelatedTables(),e.attachmentsViewOptions.objectId=null},text:this.layer?.title??"",textEnabled:!1,title:l?t.exitRelatedRecords:t.exitAttachments}),o.toArray().map(((e,t)=>this._renderRelatedTableNavigationAction(e,t))),v,f,D("div",null,y,_,M,C))}_renderRelatedTableNavigationAction(e,t){const i=this._getLabelForRelatedTableNavigationAction(e);return D("calcite-action",{icon:$.chevronRight,iconFlipRtl:!0,key:t,onclick:()=>this._onRelatedNavigationItemClick(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}};e([a()],U.prototype,"_attachmentsInput",void 0),e([a()],U.prototype,"_columnVisibilityActions",void 0),e([a()],U.prototype,"_effectiveDescription",null),e([a()],U.prototype,"_effectiveLayers",null),e([a()],U.prototype,"_effectiveTitle",null),e([a()],U.prototype,"_effectiveVisibleElements",null),e([a()],U.prototype,"_filteredTables",null),e([a()],U.prototype,"_hasAttachmentsViewError",null),e([a()],U.prototype,"_hasCustomMenuItems",null),e([a()],U.prototype,"_hasDefaultMenuItems",null),e([a()],U.prototype,"_shouldShowGrid",null),e([a()],U.prototype,"_shouldShowMenu",null),e([a()],U.prototype,"_shouldShowAttachmentsView",null),e([a()],U.prototype,"_showClearSelectionAction",null),e([a()],U.prototype,"_showColumnsVisibilityAction",null),e([a()],U.prototype,"_showDeleteSelectionAction",null),e([a()],U.prototype,"_showExportSelectionToCSVAction",null),e([a()],U.prototype,"_showLayerDropdown",null),e([a()],U.prototype,"_shouldShowNavigationBar",null),e([a()],U.prototype,"_showRefreshDataAction",null),e([a()],U.prototype,"_showSelectedRecordsShowSelectedAction",null),e([a()],U.prototype,"_showSelectedRecordsShowAllAction",null),e([a()],U.prototype,"_showZoomToSelectionAction",null),e([a()],U.prototype,"_viewLayers",null),e([a()],U.prototype,"attachmentsList",void 0),e([a({readOnly:!0})],U.prototype,"grid",null),e([a()],U.prototype,"actionColumnConfig",null),e([a({readOnly:!0})],U.prototype,"activeFilters",null),e([a({readOnly:!0})],U.prototype,"activeSortOrders",null),e([a()],U.prototype,"allColumns",null),e([a({readOnly:!0})],U.prototype,"allRelatedTablesVisible",null),e([a()],U.prototype,"attachmentsEnabled",null),e([a()],U.prototype,"attachmentsViewOptions",null),e([a({type:m})],U.prototype,"attributeTableTemplate",null),e([a()],U.prototype,"autoRefreshEnabled",null),e([a()],U.prototype,"clearPrompt",null),e([a()],U.prototype,"columnPerformanceModeEnabled",null),e([a()],U.prototype,"columnReorderingEnabled",null),e([a({readOnly:!0})],U.prototype,"columns",null),e([a()],U.prototype,"description",void 0),e([a()],U.prototype,"disabled",void 0),e([a()],U.prototype,"editingEnabled",null),e([a()],U.prototype,"effectiveSize",null),e([a()],U.prototype,"effectiveTable",null),e([a()],U.prototype,"filterGeometry",null),e([a()],U.prototype,"filterBySelectionEnabled",null),e([a()],U.prototype,"hiddenFields",null),e([a()],U.prototype,"highlightEnabled",null),e([a()],U.prototype,"highlightIds",null),e([a()],U.prototype,"icon",null),e([a()],U.prototype,"initialSize",null),e([a()],U.prototype,"isQueryingOrSyncing",null),e([a()],U.prototype,"isSyncingAttachments",null),e([a()],U.prototype,"label",null),e([a()],U.prototype,"layer",null),e([a()],U.prototype,"layers",void 0),e([a()],U.prototype,"layerView",null),e([a()],U.prototype,"maxSize",null),e([a(),k("esri/widgets/FeatureTable/t9n/FeatureTable")],U.prototype,"messages",null),e([a(),k("esri/t9n/common")],U.prototype,"messagesCommon",null),e([a(),k("esri/core/t9n/Units")],U.prototype,"messagesUnits",null),e([a(),k("esri/widgets/support/t9n/uriUtils")],U.prototype,"messagesURIUtils",null),e([a()],U.prototype,"menuConfig",void 0),e([a()],U.prototype,"multipleSelectionEnabled",null),e([a()],U.prototype,"multiSortEnabled",null),e([a()],U.prototype,"objectIds",null),e([a()],U.prototype,"outFields",null),e([a()],U.prototype,"pageCount",null),e([a()],U.prototype,"pageIndex",null),e([a()],U.prototype,"pageSize",null),e([a()],U.prototype,"paginationEnabled",null),e([a()],U.prototype,"prompt",null),e([a()],U.prototype,"relatedRecordsEnabled",null),e([a()],U.prototype,"relatedTable",null),e([a()],U.prototype,"relatedTables",null),e([a()],U.prototype,"relationship",null),e([a()],U.prototype,"relationshipColumnConfigs",null),e([a()],U.prototype,"relationshipConfig",null),e([a()],U.prototype,"returnGeometryEnabled",null),e([a()],U.prototype,"returnMEnabled",null),e([a()],U.prototype,"returnZEnabled",null),e([a()],U.prototype,"rowHighlightIds",null),e([a()],U.prototype,"selectionSource",null),e([a()],U.prototype,"showAllRelatedTables",null),e([a()],U.prototype,"showPrompt",null),e([a()],U.prototype,"showRelatedTableCallback",null),e([a()],U.prototype,"size",null),e([a({readOnly:!0})],U.prototype,"state",null),e([a({constructOnly:!0})],U.prototype,"tableController",null),e([a({constructOnly:!0})],U.prototype,"tableParent",null),e([a()],U.prototype,"tableTemplate",null),e([a()],U.prototype,"tableTemplateOverride",null),e([a()],U.prototype,"title",void 0),e([a()],U.prototype,"timeExtent",null),e([a()],U.prototype,"timeZone",null),e([a()],U.prototype,"view",null),e([a({type:f}),x(["cell-click","cell-dblclick","cell-pointerover","cell-pointerout","cell-keydown","column-reorder","show-related-table"])],U.prototype,"viewModel",void 0),e([a({type:y,nonNullable:!0})],U.prototype,"visibleElements",void 0),e([a({type:y})],U.prototype,"visibleElementsOverride",null),U=P=e([r("esri.widgets.FeatureTable")],U);const B=U;export{B 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 e from"../../request.js";import{isSome as i}from"../../core/arrayUtils.js";import s from"../../core/Collection.js";import o from"../../core/Error.js";import{JSONMap as a}from"../../core/jsonMap.js";import{clone as r}from"../../core/lang.js";import l from"../../core/Loadable.js";import{isAbortError as n}from"../../core/promiseUtils.js";import p from"../../core/ReactiveMap.js";import{watch as m,initial as h}from"../../core/reactiveUtils.js";import{createScreenPoint as u}from"../../core/screenUtils.js";import{unitType as d,convertUnit as c,getMetersPerUnitForSR as y,inchesPerMeter as f}from"../../core/unitUtils.js";import{property as v}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as T}from"../../core/accessorSupport/decorators/subclass.js";import{formatDate as w,convertDateFormatToIntlOptions as _}from"../../intl/date.js";import{getLanguage as I}from"../../intl/locale.js";import g from"../../portal/Portal.js";import O from"../../portal/PortalQueryParams.js";import{reArcGISOnlineDomain as b}from"../../portal/support/urlUtils.js";import{execute as x,getTasks as P}from"../../rest/print.js";import{formatJsonMap as S}from"../../rest/support/fileFormat.js";import{fromJSON as U}from"../../rest/support/layoutTemplate.js";import j from"../../rest/support/PrintParameters.js";import E from"../../rest/support/PrintTemplate.js";import{getExtent as k}from"../../views/2d/viewpointUtils.js";import{ViewEventPriorities as L}from"../../views/input/InputManager.js";import C from"../../views/overlay/BoxOverlayItem.js";import H from"./CustomTemplate.js";import F from"./TemplateOptions.js";import{fetchLayoutTemplateInfos as D}from"./utils.js";import R from"../../geometry/Extent.js";import W from"../../geometry/SpatialReference.js";const A=[30,144,255,255],M=[237,211,23,255],V=[216,48,32,255],q=new Set(["GISProfessionalStdUT","GISProfessionalAdvUT"]),z=/(\/GPServer\/).+/i,G=new a({inch:"inches",foot:"feet",yard:"yards",mile:"miles","nautical-mile":"nautical-miles",millimeter:"millimeters",centimeter:"centimeters",decimeter:"decimeters",meter:"meters",kilometer:"kilometers"}),B=s.ofType(H);function J(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"===I()&&(i=""+i),e.push({date:i})}}function N(t,e,i){if(!e)return;!(e.visible===i)&&t.layoutOptions&&(t.layoutOptions.elementOverrides?t.layoutOptions.elementOverrides[e.name]={visible:i}:t.layoutOptions.elementOverrides={[e.name]:{visible:i}})}let $=class extends l{constructor(t){super(t),this._serviceTemplateCustomTextElements=null,this._templateIdToCustomTemplate=new p,this._isFreeHand=!1,this._freeHandWidth=0,this._freehandHeight=0,this._asyncPrintTaskUrl=null,this._layoutInfoTaskUrl=null,this.allowedFormats="all",this.allowedLayouts="all",this.browseTemplates=new B,this.defaultTemplates=new B,this.error=null,this.extraParameters=null,this.includeDefaultTemplates=!0,this.outSpatialReference=null,this.portal=g.getDefault(),this.portalTemplateIds=[],this.printServiceTemplates=new B,this.defaultTemplate=null,this.showPrintAreaEnabled=!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.showPrintAreaEnabled,this.view]),(()=>{this.showPrintAreaEnabled?this._enablePrintPreview():(this.removeHandles("overlay-handler"),this.view?.overlay?.removeItem(this._getOverlayItem()))})),m((()=>[this.templateOptions.layout,this.templateOptions.layoutItem]),(()=>{this.loaded&&this._processTemplateOptions()}))])}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=r(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[s,o]=Object.entries(t)[0];i===s&&(e[i]=o)}))}))}})),Object.freeze(t)}get state(){return"loading"===this.loadStatus?"initializing":"failed"===this.loadStatus||this.error?"error":"loaded"===this.loadStatus&&this.view?.ready?"ready":"disabled"}async load(t){return this.addResolvingPromise(this._loadResources(t).catch((t=>this.error=t))),this}async print(t){const{view:e,extraParameters:i,updateDelay:s,outSpatialReference:a}=this;if(!e)throw new o("print:view-required","view is not set");J(t);const r=this._getOverlayItem(),l=t.scalePreserved||!this.showPrintAreaEnabled?void 0:k(new R,e.viewpoint,"map-only"===t.layout?[t.exportOptions.width,t.exportOptions.height]:[r.boxWidth,r.boxHeight]),n=new j({view:e,template:t,extent:l,extraParameters:i,updateDelay:s,outSpatialReference:a});try{const e=!!t.layoutItem?.id&&(this.portalTemplateIds.includes(t.layoutItem.id)||this.browseTemplates.some((e=>e.layoutItem?.id===t.layoutItem?.id)));return await x(e&&this._asyncPrintTaskUrl?this._asyncPrintTaskUrl:this.effectivePrintServiceUrl,n,{timeout:this.printTimeout})}catch(p){throw new o("print:export-error","An error occurred while exporting the web map.",{error:p})}}toPrintTemplate({attributionEnabled:t,author:e,copyright:i,customTextElements:s,dpi:a,forceFeatureAttributes:r,format:l,height:n,id:p,includeTables:m,layout:h,layoutItem:u,legendEnabled:d,northArrowEnabled:c,scale:y,scaleEnabled:f,title:v,width:T}){if(!h&&!u)throw new o("print:layout-required","layout is not set");const w=new E({attributionVisible:t,forceFeatureAttributes:r,format:l,includeTables:m,layout:h,layoutItem:u,layoutOptions:{authorText:e||"",copyrightText:i||"",customTextElements:s,titleText:v||""},outScale:y??0,scalePreserved:f});if(T&&(w.exportOptions.width=T),n&&(w.exportOptions.height=n),a&&(w.exportOptions.dpi=a),w.layoutOptions){d||(w.layoutOptions.legendLayers=[]);const t=this.getLayoutTemplateById(p)?.mapSurroundInfoOptions;if(t){N(w,t.northArrow[0],c);const e=t.scaleBar;for(const t of e)N(w,t,f)}}return w}getLayoutTemplateById(t){return t?this._templateIdToCustomTemplate.get(t):null}async addPortalTemplate(t){if(!this.portal||!t?.id)return;try{t.loaded||await t.load()}catch{return void this.applyTemplate(this.defaultTemplate)}const e=new H({type:"browse-template",layoutInfoTaskUrl:this._layoutInfoTaskUrl,label:t.title,layoutItem:t});this._templateIdToCustomTemplate.set(e.id,e),this.browseTemplates.add(e)}removePortalTemplate(t){t.layoutItem&&this.templateOptions.id===t.layoutItem.id&&(this.defaultTemplate?this.applyTemplate(this.defaultTemplate):this.templateOptions.reset()),this.browseTemplates.remove(t),this._templateIdToCustomTemplate.delete(t.id)}async applyTemplate(t){if(!t)return void this.templateOptions.reset();!t.layout||!this.templatesInfo||this.templatesInfo.layout.choiceList.includes(t.layout)||(this.defaultTemplate?t=this.defaultTemplate:this.templateOptions.reset());const e=t.layout?this.effectiveTemplateCustomTextElements[t.layout]:null;await this.templateOptions.applyTemplate(t,e)}async _loadResources(t){if(this.destroyed)return;await this._loadUrls(t);const[e,i]=await Promise.all([this._getLayoutToLayoutTemplateInfos(t),this._getPrintServiceTemplatesInfo(t)]);await this._loadAllTemplates(e,t),this._processPrintServiceTemplatesInfo(i),await this._processTemplateOptions(),this._updateOverLayItem()}async _processTemplateOptions(){const{layout:t,layoutItem:e}=this.templateOptions;if("map-only"!==t&&!this.templateOptions.id)if(e?.id){try{e.loaded||await e.load()}catch{return void this.applyTemplate(this.defaultTemplate)}let t=this._templateIdToCustomTemplate.get(e.id);t||(t=new H({label:e.title,layoutItem:e,layoutInfoTaskUrl:this._layoutInfoTaskUrl}),this._templateIdToCustomTemplate.set(t.id,t)),await this.applyTemplate(t)}else if(t){const t=this.defaultTemplates.find((t=>t.layout===this.templateOptions.layout))??this.printServiceTemplates.find((t=>t.layout===this.templateOptions.layout));await this.applyTemplate(t??this.defaultTemplate)}}async _loadPortal(t){try{await this.portal.load(t)}catch(e){throw new o("print:could-not-load-portal","Cannot load print resource information from portal",{error:e,url:this.effectivePrintServiceUrl})}}async _loadUrls(t){if(this.printServiceUrl)this._set("effectivePrintServiceUrl",this.printServiceUrl),await this._updateLayoutInfoTaskUrl(this.effectivePrintServiceUrl);else{await this._loadPortal(t);const{printTask:e,asyncPrintTask:i,layoutInfoTask:s}=this.portal?.helperServices??{};this._set("effectivePrintServiceUrl",e?.url),this._asyncPrintTaskUrl=i?.url,await this._updateLayoutInfoTaskUrl(s?.url||this.effectivePrintServiceUrl)}const e=this.effectivePrintServiceUrl?.toLowerCase().split("/");if(!e?.includes("gpserver"))throw new o("print:invalid-print-service-url","Can't fetch print templates information from provided URL",{url:this.effectivePrintServiceUrl})}async _updateLayoutInfoTaskUrl(t,e){if(!t)return;const i=(await P(t,e)).find((t=>t.includes("Get Layout Templates Info")));i&&(this._layoutInfoTaskUrl=t.replace(z,`$1${encodeURI(i)}`))}_getPortalDefaultTemplates(t){return this.portal?.helperServices?.printTask?.templates?.filter((t=>"map_only"!==t.layout.toLowerCase()))?.map((e=>{const i=H.fromJSON(e);if(i.type="default-template",i.layoutInfoTaskUrl=this._layoutInfoTaskUrl,i.layout){const e=t.get(i.layout);e&&i.setLayoutTemplateInfo(e)}return i}))??[]}async _getPortalCustomTemplates(t){if(this.printServiceUrl||!this.portal)return[];const{layoutGroupQuery:e,user:i}=this.portal,s=b.test(this.portal.url),o=i?.userLicenseTypeId,a=o&&q.has(o);if(!e||s&&!a)return[];const r=new O({query:e,disableExtraQuery:!0}),l=await this.portal.queryGroups(r,t);if(!l.total)return[];const n=l.results[0],p=new O({num:100,query:"type:Layout",sortField:n.sortField,sortOrder:n.sortOrder??void 0}),m=(await n.queryItems(p,t)).results;if(!m.length)return[];return m.map((t=>(this.portalTemplateIds.push(t.id),new H({type:"default-template",label:t.title,layoutItem:t,layoutInfoTaskUrl:this._layoutInfoTaskUrl}))))}async _loadAllTemplates(t,e){let i=!1;if(this.includeDefaultTemplates&&this.portal&&!this.printServiceUrl){const s=this._getPortalDefaultTemplates(t);i=!!s.length,this.defaultTemplates.addMany(s);const o=await this._getPortalCustomTemplates(e);this.defaultTemplates.addMany(o);for(const t of this.defaultTemplates)this._templateIdToCustomTemplate.set(t.id,t)}i||t.forEach(((t,e)=>{const i=new H({type:"print-service-template",layout:e,layoutInfoTaskUrl:this._layoutInfoTaskUrl});i.setLayoutTemplateInfo(t),this.printServiceTemplates.add(i),this._templateIdToCustomTemplate.set(i.id,i)}))}_processPrintServiceTemplatesInfo(t){this._set("templatesInfo",t);const e=t?.layout?.defaultValue;e&&"map-only"!==e&&this._set("defaultTemplate",this.defaultTemplates.find((t=>t.layout===e))??this.printServiceTemplates.find((t=>t.layout===e)))}async _getLayoutToLayoutTemplateInfos(t){const e=await D(this._layoutInfoTaskUrl,void 0,t),i=new Map,s={};for(const o of e){const t=U(o.layoutTemplate);i.set(t,o),s[t]=o.layoutOptions.customTextElements}return this._serviceTemplateCustomTextElements=Object.freeze(s),i}async _getPrintServiceTemplatesInfo(t){let i;try{({data:i}=await e(this.effectivePrintServiceUrl,{...t,query:{f:"json"},timeout:this.printTimeout}))}catch(l){throw n(l)?l:new o("print:unavailable-service-info","Can't fetch templates info from service",{error:l})}const{parameters:s}=i,a=s.find((({name:t})=>"Format"===t)),r=s.find((({name:t})=>"Layout_Template"===t));return{format:this._getFormat(a),layout:this._getLayout(r)}}_getFormat(t){const e="all"===this.allowedFormats?t.choiceList:t.choiceList.filter((t=>"string"!=typeof this.allowedFormats&&this.allowedFormats.some((e=>new RegExp(`\\b${e}\\b`,"i").test(t))))),s=(e.length?e:t.choiceList).map((t=>S.fromJSON(t))).filter(i),o=S.fromJSON(t.defaultValue),a=s.some((t=>new RegExp(`\\b${o}\\b`,"i").test(t)))?o:s[0];return{choiceList:s,defaultValue:a}}_getLayout(t){const e=t.choiceList.filter((t=>"map_only"!==t.toLowerCase())),s="all"===this.allowedLayouts?e:e.filter((t=>this.allowedLayouts.includes(U(t)))),o=(s.length?s:e).map(U).filter(i),a=U(t.defaultValue),r=o.includes(a)?a:o.find((t=>/(?=.*letter)(?=.*landscape)/i.test(t)))??o.find((t=>/(?=.*a4)(?=.*landscape)/i.test(t)))??o[0];return{choiceList:o,defaultValue:r}}_getOverlayItem(){return this._overlayItem||(this._overlayItem=new C({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,t.id,t.state,this.view?.scale,this.view?.size,this.view?.state.paddedViewState.size,this.view?.state.padding,this.loaded]),(()=>this._updateOverLayItem()),h),this.view?.on("drag",["Shift"],(t=>this._handleDrag(t)),L.WIDGET),this.view?.on("key-down",["Escape"],(()=>this._resetDrag()),L.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,s=this.view,o=s.spatialReference,[a,r]=s.state.paddedViewState.size,l=s.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 e=t.id?this._templateIdToCustomTemplate.get(t.id):null,{webMapFrameSize:i,pageUnits:s}=e?.layoutTemplateInfo??{};let l=!1;if(i&&s)if(this._isFreeHand){const t=i[0]/i[1];n=this._freeHandWidth,p=this._freehandHeight,n>p?p=n/t:n=p*t}else{const t=G.fromJSON(s.toLowerCase()),e=o.unit;d(t)===d(e)?(n=c(i[0],t,e),p=c(i[1],t,e)):(l=!0,n=i[0],p=i[1])}if(!this._isFreeHand)if(t.scaleEnabled&&t.scale){const e=l?Math.min(a/n,r/p):y(o)*f*t.dpi;n*=e,p*=e}else if(0===n||0===p)n=a,p=r;else{const t=(a-.1*a)/n,e=(r-.1*r)/p,i=Math.min(t,e);n*=i,p*=i}}const{scaleEnabled:m,scale:h}=t,u=m&&h?h/this.view.scale:1;if(e.boxWidth=n*u||a,e.boxHeight=p*u||r,l&&(e.padding=l),e.backgroundWidth=a??0,e.backgroundHeight=r??0,"loading"===this.loadStatus)e.strokeColor=M;else if("loaded"===this.loadStatus)switch(this.templateOptions.state){case"pending":e.strokeColor=M;break;case"ready":e.strokeColor=A;break;case"error":e.strokeColor=V}}_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:s}=t,{x:o,y:a}=t.origin;i>o?(e.x=o,e.boxWidth=i-o):(e.x=i,e.boxWidth=o-i),s>a?(e.y=a,e.boxHeight=s-a):(e.y=s,e.boxHeight=a-s)}_end(){const t=this._getOverlayItem();if(!this.view||null==t.x||null==t.y)return;const e=this.view,i=e.toMap(u(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([v()],$.prototype,"_serviceTemplateCustomTextElements",void 0),t([v()],$.prototype,"_templateIdToCustomTemplate",void 0),t([v()],$.prototype,"allowedFormats",void 0),t([v()],$.prototype,"allowedLayouts",void 0),t([v({type:B})],$.prototype,"browseTemplates",void 0),t([v({type:B})],$.prototype,"defaultTemplates",void 0),t([v()],$.prototype,"error",void 0),t([v()],$.prototype,"extraParameters",void 0),t([v()],$.prototype,"includeDefaultTemplates",void 0),t([v({readOnly:!0})],$.prototype,"effectivePrintServiceUrl",null),t([v()],$.prototype,"effectiveTemplateCustomTextElements",null),t([v({type:W})],$.prototype,"outSpatialReference",void 0),t([v({type:g})],$.prototype,"portal",void 0),t([v()],$.prototype,"portalTemplateIds",void 0),t([v({type:B})],$.prototype,"printServiceTemplates",void 0),t([v({readOnly:!0})],$.prototype,"defaultTemplate",void 0),t([v()],$.prototype,"showPrintAreaEnabled",void 0),t([v()],$.prototype,"printServiceUrl",void 0),t([v()],$.prototype,"printTimeout",void 0),t([v({readOnly:!0})],$.prototype,"state",null),t([v({readOnly:!0})],$.prototype,"templatesInfo",void 0),t([v()],$.prototype,"updateDelay",void 0),t([v()],$.prototype,"view",void 0),t([v()],$.prototype,"templateCustomTextElements",void 0),t([v({type:F})],$.prototype,"templateOptions",void 0),$=t([T("esri.widgets.Print.PrintViewModel")],$);const Q=$;export{Q as default};
|
|
5
|
+
import{_ as t}from"../../chunks/tslib.es6.js";import"../../geometry.js";import e from"../../request.js";import{isSome as i}from"../../core/arrayUtils.js";import s from"../../core/Collection.js";import o from"../../core/Error.js";import{JSONMap as a}from"../../core/jsonMap.js";import{clone as r}from"../../core/lang.js";import l from"../../core/Loadable.js";import{isAbortError as n}from"../../core/promiseUtils.js";import p from"../../core/ReactiveMap.js";import{watch as m,initial as h}from"../../core/reactiveUtils.js";import{createScreenPoint as u}from"../../core/screenUtils.js";import{unitType as d,convertUnit as c,getMetersPerUnitForSR as y,inchesPerMeter as f}from"../../core/unitUtils.js";import{property as v}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as T}from"../../core/accessorSupport/decorators/subclass.js";import{formatDate as w,convertDateFormatToIntlOptions as _}from"../../intl/date.js";import{getLanguage as I}from"../../intl/locale.js";import g from"../../portal/Portal.js";import O from"../../portal/PortalQueryParams.js";import{reArcGISOnlineDomain as b}from"../../portal/support/urlUtils.js";import{execute as x,getTasks as P}from"../../rest/print.js";import{formatJsonMap as S}from"../../rest/support/fileFormat.js";import{fromJSON as U}from"../../rest/support/layoutTemplate.js";import j from"../../rest/support/PrintParameters.js";import E from"../../rest/support/PrintTemplate.js";import{getExtent as k}from"../../views/2d/viewpointUtils.js";import{ViewEventPriorities as L}from"../../views/input/InputManager.js";import C from"../../views/overlay/BoxOverlayItem.js";import H from"./CustomTemplate.js";import F from"./TemplateOptions.js";import{fetchLayoutTemplateInfos as D}from"./utils.js";import R from"../../geometry/Extent.js";import W from"../../geometry/SpatialReference.js";const A=[30,144,255,255],M=[237,211,23,255],V=[216,48,32,255],q=new Set(["GISProfessionalStdUT","GISProfessionalAdvUT"]),z=/(\/GPServer\/).+/i,G=new a({inch:"inches",foot:"feet",yard:"yards",mile:"miles","nautical-mile":"nautical-miles",millimeter:"millimeters",centimeter:"centimeters",decimeter:"decimeters",meter:"meters",kilometer:"kilometers"}),B=s.ofType(H);function J(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"===I()&&(i=""+i),e.push({date:i})}}function N(t,e,i){if(!e)return;!(e.visible===i)&&t.layoutOptions&&(t.layoutOptions.elementOverrides?t.layoutOptions.elementOverrides[e.name]={visible:i}:t.layoutOptions.elementOverrides={[e.name]:{visible:i}})}let $=class extends l{constructor(t){super(t),this._serviceTemplateCustomTextElements=null,this._templateIdToCustomTemplate=new p,this._isFreeHand=!1,this._freeHandWidth=0,this._freehandHeight=0,this._asyncPrintTaskUrl=null,this._layoutInfoTaskUrl=null,this.allowedFormats="all",this.allowedLayouts="all",this.browseTemplates=new B,this.defaultTemplates=new B,this.error=null,this.extraParameters=null,this.includeDefaultTemplates=!0,this.outSpatialReference=null,this.portal=g.getDefault(),this.portalTemplateIds=[],this.printServiceTemplates=new B,this.defaultTemplate=null,this.showPrintAreaEnabled=!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.showPrintAreaEnabled,this.view]),(()=>{this.showPrintAreaEnabled?this._enablePrintPreview():(this.removeHandles("overlay-handler"),this.view?.overlay?.removeItem(this._getOverlayItem()))})),m((()=>[this.templateOptions.layout,this.templateOptions.layoutItem]),(()=>{this.loaded&&this._processTemplateOptions()}))])}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=r(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[s,o]=Object.entries(t)[0];i===s&&(e[i]=o)}))}))}})),Object.freeze(t)}get state(){return"loading"===this.loadStatus?"initializing":"failed"===this.loadStatus||this.error?"error":"loaded"===this.loadStatus&&this.view?.ready?"ready":"disabled"}async load(t){return this.addResolvingPromise(this._loadResources(t).catch((t=>this.error=t))),this}async print(t){const{view:e,extraParameters:i,updateDelay:s,outSpatialReference:a}=this;if(!e)throw new o("print:view-required","view is not set");J(t);const r=this._getOverlayItem(),l=t.scalePreserved||!this.showPrintAreaEnabled?void 0:k(new R,e.viewpoint,"map-only"===t.layout?[t.exportOptions.width,t.exportOptions.height]:[r.boxWidth,r.boxHeight]),n=new j({view:e,template:t,extent:l,extraParameters:i,updateDelay:s,outSpatialReference:a});try{const e=!!t.layoutItem?.id&&(this.portalTemplateIds.includes(t.layoutItem.id)||this.browseTemplates.some((e=>e.layoutItem?.id===t.layoutItem?.id)));return await x(e&&this._asyncPrintTaskUrl?this._asyncPrintTaskUrl:this.effectivePrintServiceUrl,n,{timeout:this.printTimeout})}catch(p){throw new o("print:export-error","An error occurred while exporting the web map.",{error:p})}}toPrintTemplate({attributionEnabled:t,author:e,copyright:i,customTextElements:s,dpi:a,forceFeatureAttributes:r,format:l,height:n,id:p,includeTables:m,layout:h,layoutItem:u,legendEnabled:d,northArrowEnabled:c,scale:y,scaleEnabled:f,title:v,width:T}){if(!h&&!u)throw new o("print:layout-required","layout is not set");const w=new E({attributionVisible:t,forceFeatureAttributes:r,format:l,includeTables:m,layout:h,layoutItem:u,layoutOptions:{authorText:e||"",copyrightText:i||"",customTextElements:s,titleText:v||""},outScale:y??0,scalePreserved:f});if(T&&(w.exportOptions.width=T),n&&(w.exportOptions.height=n),a&&(w.exportOptions.dpi=a),w.layoutOptions){d||(w.layoutOptions.legendLayers=[]);const t=this.getLayoutTemplateById(p)?.mapSurroundInfoOptions;if(t){N(w,t.northArrow[0],c);const e=t.scaleBar;for(const t of e)N(w,t,f)}}return w}getLayoutTemplateById(t){return t?this._templateIdToCustomTemplate.get(t):null}async addPortalTemplate(t){if(!this.portal||!t?.id)return;try{t.loaded||await t.load()}catch{return void this.applyTemplate(this.defaultTemplate)}const e=new H({type:"browse-template",layoutInfoTaskUrl:this._layoutInfoTaskUrl,label:t.title,layoutItem:t});this._templateIdToCustomTemplate.set(e.id,e),this.browseTemplates.add(e)}removePortalTemplate(t){t.layoutItem&&this.templateOptions.id===t.layoutItem.id&&(this.defaultTemplate?this.applyTemplate(this.defaultTemplate):this.templateOptions.reset()),this.browseTemplates.remove(t),this._templateIdToCustomTemplate.delete(t.id)}async applyTemplate(t){if(!t)return void this.templateOptions.reset();!t.layout||!this.templatesInfo||this.templatesInfo.layout.choiceList.includes(t.layout)||(this.defaultTemplate?t=this.defaultTemplate:this.templateOptions.reset());const e=t.layout?this.effectiveTemplateCustomTextElements[t.layout]:null;await this.templateOptions.applyTemplate(t,e)}async _loadResources(t){if(this.destroyed)return;await this._loadUrls(t);const[e,i]=await Promise.all([this._getLayoutToLayoutTemplateInfos(t),this._getPrintServiceTemplatesInfo(t)]);await this._loadAllTemplates(e,i,t),this._processPrintServiceTemplatesInfo(i),await this._processTemplateOptions(),this._updateOverLayItem()}async _processTemplateOptions(){const{layout:t,layoutItem:e}=this.templateOptions;if("map-only"!==t&&!this.templateOptions.id)if(e?.id){try{e.loaded||await e.load()}catch{return void this.applyTemplate(this.defaultTemplate)}let t=this._templateIdToCustomTemplate.get(e.id);t||(t=new H({label:e.title,layoutItem:e,layoutInfoTaskUrl:this._layoutInfoTaskUrl}),this._templateIdToCustomTemplate.set(t.id,t)),await this.applyTemplate(t)}else if(t){const t=this.defaultTemplates.find((t=>t.layout===this.templateOptions.layout))??this.printServiceTemplates.find((t=>t.layout===this.templateOptions.layout));await this.applyTemplate(t??this.defaultTemplate)}}async _loadPortal(t){try{await this.portal.load(t)}catch(e){throw new o("print:could-not-load-portal","Cannot load print resource information from portal",{error:e,url:this.effectivePrintServiceUrl})}}async _loadUrls(t){if(this.printServiceUrl)this._set("effectivePrintServiceUrl",this.printServiceUrl),await this._updateLayoutInfoTaskUrl(this.effectivePrintServiceUrl);else{await this._loadPortal(t);const{printTask:e,asyncPrintTask:i,layoutInfoTask:s}=this.portal?.helperServices??{};this._set("effectivePrintServiceUrl",e?.url),this._asyncPrintTaskUrl=i?.url,await this._updateLayoutInfoTaskUrl(s?.url||this.effectivePrintServiceUrl)}const e=this.effectivePrintServiceUrl?.toLowerCase().split("/");if(!e?.includes("gpserver"))throw new o("print:invalid-print-service-url","Can't fetch print templates information from provided URL",{url:this.effectivePrintServiceUrl})}async _updateLayoutInfoTaskUrl(t,e){if(!t)return;const i=(await P(t,e)).find((t=>t.includes("Get Layout Templates Info")));i&&(this._layoutInfoTaskUrl=t.replace(z,`$1${encodeURI(i)}`))}_getPortalDefaultTemplates(t,e){return this.portal?.helperServices?.printTask?.templates?.filter((t=>"map_only"!==t.layout.toLowerCase()&&(!e||e.includes(U(t.layout)))))?.map((e=>{const i=H.fromJSON(e);if(i.type="default-template",i.layoutInfoTaskUrl=this._layoutInfoTaskUrl,i.layout){const e=t.get(i.layout);e&&i.setLayoutTemplateInfo(e)}return i}))??[]}async _getPortalCustomTemplates(t){if(this.printServiceUrl||!this.portal)return[];const{layoutGroupQuery:e,user:i}=this.portal,s=b.test(this.portal.url),o=i?.userLicenseTypeId,a=o&&q.has(o);if(!e||s&&!a)return[];const r=new O({query:e,disableExtraQuery:!0}),l=await this.portal.queryGroups(r,t);if(!l.total)return[];const n=l.results[0],p=new O({num:100,query:"type:Layout",sortField:n.sortField,sortOrder:n.sortOrder??void 0}),m=(await n.queryItems(p,t)).results;if(!m.length)return[];return m.map((t=>(this.portalTemplateIds.push(t.id),new H({type:"default-template",label:t.title,layoutItem:t,layoutInfoTaskUrl:this._layoutInfoTaskUrl}))))}async _loadAllTemplates(t,e,i){let s=!1;const o=e?.layout?.choiceList;if(this.includeDefaultTemplates&&this.portal&&!this.printServiceUrl){const e=this._getPortalDefaultTemplates(t,o);s=!!e.length,this.defaultTemplates.addMany(e);const a=await this._getPortalCustomTemplates(i);this.defaultTemplates.addMany(a);for(const t of this.defaultTemplates)this._templateIdToCustomTemplate.set(t.id,t)}s||t.forEach(((t,e)=>{if(!o||o.includes(e)){const i=new H({type:"print-service-template",layout:e,layoutInfoTaskUrl:this._layoutInfoTaskUrl});i.setLayoutTemplateInfo(t),this.printServiceTemplates.add(i),this._templateIdToCustomTemplate.set(i.id,i)}}))}_processPrintServiceTemplatesInfo(t){this._set("templatesInfo",t);const e=t?.layout?.defaultValue;if(e&&"map-only"!==e){const t=this.defaultTemplates.find((t=>t.layout===e))??this.printServiceTemplates.find((t=>t.layout===e))??this.defaultTemplates.at(0)??this.printServiceTemplates.at(0);this._set("defaultTemplate",t)}}async _getLayoutToLayoutTemplateInfos(t){const e=await D(this._layoutInfoTaskUrl,void 0,t),i=new Map,s={};for(const o of e){const t=U(o.layoutTemplate);i.set(t,o),s[t]=o.layoutOptions.customTextElements}return this._serviceTemplateCustomTextElements=Object.freeze(s),i}async _getPrintServiceTemplatesInfo(t){let i;try{({data:i}=await e(this.effectivePrintServiceUrl,{...t,query:{f:"json"},timeout:this.printTimeout}))}catch(l){throw n(l)?l:new o("print:unavailable-service-info","Can't fetch templates info from service",{error:l})}const{parameters:s}=i,a=s.find((({name:t})=>"Format"===t)),r=s.find((({name:t})=>"Layout_Template"===t));return{format:this._getFormat(a),layout:this._getLayout(r)}}_getFormat(t){const e="all"===this.allowedFormats?t.choiceList:t.choiceList.filter((t=>"string"!=typeof this.allowedFormats&&this.allowedFormats.some((e=>new RegExp(`\\b${e}\\b`,"i").test(t))))),s=(e.length?e:t.choiceList).map((t=>S.fromJSON(t))).filter(i),o=S.fromJSON(t.defaultValue),a=s.some((t=>new RegExp(`\\b${o}\\b`,"i").test(t)))?o:s[0];return{choiceList:s,defaultValue:a}}_getLayout(t){const e=t.choiceList.filter((t=>"map_only"!==t.toLowerCase())),s="all"===this.allowedLayouts?e:e.filter((t=>this.allowedLayouts.includes(U(t)))),o=(s.length?s:e).map(U).filter(i),a=U(t.defaultValue),r=o.includes(a)?a:o.find((t=>/(?=.*letter)(?=.*landscape)/i.test(t)))??o.find((t=>/(?=.*a4)(?=.*landscape)/i.test(t)))??o[0];return{choiceList:o,defaultValue:r}}_getOverlayItem(){return this._overlayItem||(this._overlayItem=new C({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,t.id,t.state,this.view?.scale,this.view?.size,this.view?.state.paddedViewState.size,this.view?.state.padding,this.loaded]),(()=>this._updateOverLayItem()),h),this.view?.on("drag",["Shift"],(t=>this._handleDrag(t)),L.WIDGET),this.view?.on("key-down",["Escape"],(()=>this._resetDrag()),L.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,s=this.view,o=s.spatialReference,[a,r]=s.state.paddedViewState.size,l=s.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 e=t.id?this._templateIdToCustomTemplate.get(t.id):null,{webMapFrameSize:i,pageUnits:s}=e?.layoutTemplateInfo??{};let l=!1;if(i&&s)if(this._isFreeHand){const t=i[0]/i[1];n=this._freeHandWidth,p=this._freehandHeight,n>p?p=n/t:n=p*t}else{const t=G.fromJSON(s.toLowerCase()),e=o.unit;d(t)===d(e)?(n=c(i[0],t,e),p=c(i[1],t,e)):(l=!0,n=i[0],p=i[1])}if(!this._isFreeHand)if(t.scaleEnabled&&t.scale){const e=l?Math.min(a/n,r/p):y(o)*f*t.dpi;n*=e,p*=e}else if(0===n||0===p)n=a,p=r;else{const t=(a-.1*a)/n,e=(r-.1*r)/p,i=Math.min(t,e);n*=i,p*=i}}const{scaleEnabled:m,scale:h}=t,u=m&&h?h/this.view.scale:1;if(e.boxWidth=n*u||a,e.boxHeight=p*u||r,l&&(e.padding=l),e.backgroundWidth=a??0,e.backgroundHeight=r??0,"loading"===this.loadStatus)e.strokeColor=M;else if("loaded"===this.loadStatus)switch(this.templateOptions.state){case"pending":e.strokeColor=M;break;case"ready":e.strokeColor=A;break;case"error":e.strokeColor=V}}_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:s}=t,{x:o,y:a}=t.origin;i>o?(e.x=o,e.boxWidth=i-o):(e.x=i,e.boxWidth=o-i),s>a?(e.y=a,e.boxHeight=s-a):(e.y=s,e.boxHeight=a-s)}_end(){const t=this._getOverlayItem();if(!this.view||null==t.x||null==t.y)return;const e=this.view,i=e.toMap(u(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([v()],$.prototype,"_serviceTemplateCustomTextElements",void 0),t([v()],$.prototype,"_templateIdToCustomTemplate",void 0),t([v()],$.prototype,"allowedFormats",void 0),t([v()],$.prototype,"allowedLayouts",void 0),t([v({type:B})],$.prototype,"browseTemplates",void 0),t([v({type:B})],$.prototype,"defaultTemplates",void 0),t([v()],$.prototype,"error",void 0),t([v()],$.prototype,"extraParameters",void 0),t([v()],$.prototype,"includeDefaultTemplates",void 0),t([v({readOnly:!0})],$.prototype,"effectivePrintServiceUrl",null),t([v()],$.prototype,"effectiveTemplateCustomTextElements",null),t([v({type:W})],$.prototype,"outSpatialReference",void 0),t([v({type:g})],$.prototype,"portal",void 0),t([v()],$.prototype,"portalTemplateIds",void 0),t([v({type:B})],$.prototype,"printServiceTemplates",void 0),t([v({readOnly:!0})],$.prototype,"defaultTemplate",void 0),t([v()],$.prototype,"showPrintAreaEnabled",void 0),t([v()],$.prototype,"printServiceUrl",void 0),t([v()],$.prototype,"printTimeout",void 0),t([v({readOnly:!0})],$.prototype,"state",null),t([v({readOnly:!0})],$.prototype,"templatesInfo",void 0),t([v()],$.prototype,"updateDelay",void 0),t([v()],$.prototype,"view",void 0),t([v()],$.prototype,"templateCustomTextElements",void 0),t([v({type:F})],$.prototype,"templateOptions",void 0),$=t([T("esri.widgets.Print.PrintViewModel")],$);const Q=$;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"../geometry.js";import"../intl.js";import t from"../core/Collection.js";import{JSONMap as i}from"../core/jsonMap.js";import{watch as a,whenOnce as l}from"../core/reactiveUtils.js";import{unitName as o}from"../core/unitFormatUtils.js";import{addProxy as n,hasSameOrigin as s}from"../core/urlUtils.js";import{property as r}from"../core/accessorSupport/decorators/property.js";import{ensureInteger as c}from"../core/accessorSupport/ensureType.js";import"../core/RandomLCG.js";import"../core/has.js";import{subclass as p}from"../core/accessorSupport/decorators/subclass.js";import{isValid as d}from"../geometry/support/spatialReferenceUtils.js";import{reArcGISOnlineDomain as m}from"../portal/support/urlUtils.js";import{getToken as u}from"../rest/utils.js";import{formatJsonMap as h}from"../rest/support/fileFormat.js";import b from"./Widget.js";import _ from"./Print/FileLink.js";import v from"./Print/PrintViewModel.js";import{loadCalciteComponents as g}from"./support/componentsUtils.js";import{globalCss as f}from"./support/globalCss.js";import{Heading as y}from"./support/Heading.js";import{legacyIcon as w}from"./support/legacyIcon.js";import{isRTL as T,isActivationKey as x}from"./support/widgetUtils.js";import{messageBundle as k}from"./support/decorators/messageBundle.js";import{tsx as C}from"./support/jsxFactory.js";import S from"../geometry/SpatialReference.js";import{formatNumber as O}from"../intl/number.js";const $=t.ofType(_),I="map-only";var E;!function(e){e.layout="layoutTab",e.mapOnly="mapOnlyTab",e.export="exportTab"}(E||(E={}));const L="esri-print",F=`${L}__advanced-options-button`,M={base:L,headerTitle:`${L}__header-title`,layoutTabList:`${L}__layout-tab-list`,layoutTab:`${L}__layout-tab`,layoutSection:`${L}__layout-section`,mapOnlySection:`${L}__map-only-section`,panelItemsCentered:`${L}__panel-items--centered`,loader:`${L}__loader`,advancedOptionsButton:F,advancedOptionsButtonContainer:`${F}-container`,advancedOptionsButtonTitle:`${F}-title`,advancedOptionsButtonIconOpened:`${F}-icon--opened`,advancedOptionsButtonIconClosed:`${F}-icon--closed`,advancedOptionsButtonIconClosed_RTL:`${F}-icon--closed-rtl`,swapButton:`${L}__swap-button`,printButton:`${L}__export-button`,printButtonSection:`${L}__export-button-section`,printButtonSectionDivider:`${L}__export-button-section--divider`,templateSelectContainer:`${L}__template-select-container`,templateSelectBlock:`${L}__template-select-block`,templateSelectIcon:`${L}__template-select-icon`,templateSelectError:`${L}__template-select-error`,templateSelectArrow:`${L}__template-select-arrow`,formSectionContainer:`${L}__form-section-container`,formCheckboxLabel:`${L}__form-checkbox-label`,advancedOptionsSection:`${L}__advanced-options-section`,advancedOptionsContainer:`${L}__advanced-options-container`,browseTemplateButtonContainer:`${L}__browse-template-button-container`,browseTemplateButtonContainerFilter:`${L}__browse-template-button-container-filter`,exportedFilesContainer:`${L}__export-panel-container`,exportedFilesTitle:`${L}__export-title`,exportedFile:`${L}__exported-file`,exportedFileLink:`${L}__exported-file-link`,exportedFileLinkTitle:`${L}__exported-file-link-title`,exportedFileLinkDescription:`${L}__exported-file-link-description`,exportedFilesEmpty:`${L}__exported-files-empty`,printWidgetContainer:`${L}__container`,content:`${L}__content`,panelContainer:`${L}__panel-container`,scaleInfoContainer:`${L}__scale-info-container`,scaleInputContainer:`${L}__scale-input-container`,scaleInput:`${L}__scale-input`,sizeContainer:`${L}__size-container`,panelError:`${L}__panel--error`,exportedFileError:`${L}__exported-file--error`,exportedFileLoader:`${L}__exported-file--loader`,exportSection:`${L}__export-section`,exportSectionCentered:`${L}__export-section--centered`,templateButtonContainer:`${L}__template-button-container`,templateDoneButton:`${L}__template-done-button`,templateSelectFlowItemContainer:`${L}__template-select-flow-item-container`,templateSelectFlowItemContent:`${L}__template-select-flow-item-content`,templateSelectFlowItemListHeading:`${L}__template-select-flow-item-list-heading`,srLabel:`${L}__sr-label`,invalidWkidText:`${L}__invalid-wkid-text`};function j(e,t,i,a){const l=i/t,o=a/t;return{width:Math.round(e*l),height:Math.round(e*o)}}function P(e){return!isNaN(e)&&e>0}function B(e){return e?.toLowerCase()===I}function A(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"}}const R=new i({inch:"inches",foot:"feet",yard:"yards",mile:"miles","nautical-mile":"nautical-miles",millimeter:"millimeters",centimeter:"centimeters",decimeter:"decimeters",meter:"meters",kilometer:"kilometers"}),N=new Map([["a3-landscape","a3-landscape"],["a3-portrait","a3-portrait"],["a4-landscape","a4-landscape"],["a4-portrait","a4-portrait"],["letter-ansi-a-landscape","ansi-a-landscape"],["letter-ansi-a-portrait","ansi-a-portrait"],["tabloid-ansi-b-landscape","ansi-b-landscape"],["tabloid-ansi-b-portrait","ansi-b-portrait"]]);let D=class extends b{constructor(e,t){super(e,t),this._activeTabFocusRequested=!1,this._awaitingServerResponse=!1,this._exportedFileNameMap={},this._selectedTab=E.layout,this._pendingExportScroll=!1,this._rootNode=null,this._selectedTemplate=null,this._formats=[],this._showTemplates=!1,this._isValidSpatialReference=!0,this.allowedFormatsForSaving=null,this.browseTemplateButtonOnClick=null,this.exportedLinks=new $,this.headerVisible=!0,this.headingLevel=3,this.messagesCommon=null,this.messagesUnits=null,this.saveExportEnabled=!1,this.saveExportHidden=!0,this.saveAsButtonCallback=null,this.viewModel=new v,this._onInput=e=>{this._selectedTab===E.layout?this.templateOptions.title=e.target.value:this._selectedTab===E.mapOnly&&(this.templateOptions.fileName=e.target.value)},this._handleLinkClick=e=>{const t=e.currentTarget["data-item"];if(!t||"ready"!==t.state||!t.url)return;const i=u(this.viewModel.effectivePrintServiceUrl),a=t.url,l=document.createElement("a");if(l.target="_blank",l.href=a,l.rel="noreferrer",l.download=t.formattedName??"",!i)return l.click(),void e.stopPropagation();e.preventDefault();const o=new URL(a);o.searchParams.set("token",i),l.href=o.href,l.click(),l.href=a},this._focusOnTabChange=this._focusOnTabChange.bind(this)}initialize(){this.addHandles([a((()=>[this.templateOptions.format,this.viewModel.templatesInfo?.format]),(()=>{const{templatesInfo:e}=this.viewModel;if(e){if(this._formats.length!==e.format.choiceList.length){const t=h.apiValues;this._formats=e.format.choiceList.map((e=>{const i=t.find((t=>new RegExp(`\\b${t}\\b`,"i").test(e)))??e;return{value:i,label:e===i?e.toUpperCase():e}})).sort(((e,t)=>e.label.localeCompare(t.label)))}if(!e.format.defaultValue||this.templateOptions.format);else{const t=this._formats.find((({value:t})=>new RegExp(`\\b${t}\\b`,"i").test(e.format.defaultValue)))?.value;t&&(this.templateOptions.format=t)}}})),a((()=>[this.templateOptions.id,this.viewModel.loaded]),(async()=>{const{layout:e}=this.templateOptions;this._selectedTab=B(e)?E.mapOnly:E.layout,this._selectedTab===E.layout&&this.viewModel.loaded&&(this._selectedTemplate=this.viewModel.getLayoutTemplateById(this.templateOptions.id))})),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)}))]);for(const{name:a,extension:l}of this.exportedLinks)a&&l&&this._updateExportedFileNameMap(`${a}${l}`);const{height:e,width:t}=this.templateOptions;this.templateOptions.width=t||800,this.templateOptions.height=e||1100;const i=setTimeout((()=>{this._awaitingServerResponse=!0,this.scheduleRender()}),500);this.viewModel.load().then((()=>{clearTimeout(i),this._awaitingServerResponse=!1}))}loadDependencies(){return g({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"),"input-number":()=>import("@esri/calcite-components/dist/components/calcite-input-number.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"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch.js"),chip:()=>import("@esri/calcite-components/dist/components/calcite-chip.js"),popover:()=>import("@esri/calcite-components/dist/components/calcite-popover.js"),link:()=>import("@esri/calcite-components/dist/components/calcite-link.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 outSpatialReference(){return this.viewModel.outSpatialReference}set outSpatialReference(e){this.viewModel.outSpatialReference=e}get portal(){return this.viewModel.portal}set portal(e){this.viewModel.portal=e}get showPrintAreaEnabled(){return this.viewModel.showPrintAreaEnabled}set showPrintAreaEnabled(e){this.viewModel.showPrintAreaEnabled=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:m,layoutItem:u,legendEnabled:h,northArrowEnabled:b,scaleBarEnabled:_,scaleEnabled:v,scale:g,width:x}=t,k="ready"!==i.state||this._awaitingServerResponse||!(m||u),O=this._renderTitleOrFileNameSection(),$=C("div",{class:M.formSectionContainer},C("calcite-label",null,e.fileFormatTitle,C("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??"pdf"}},this._formats.map((({value:e,label:t},i)=>C("calcite-combobox-item",{key:`file-format-${i}`,selected:e===this.templateOptions.format,textLabel:t,value:e})))))),I=C("calcite-label",{layout:"inline"},C("calcite-switch",{checked:this.showPrintAreaEnabled,onCalciteSwitchChange:e=>{this.showPrintAreaEnabled=!!e.target.checked}}),e.printPreview),L=C("div",null,C("div",{class:M.formSectionContainer},C("calcite-label",null,e.template,C("calcite-block",{class:M.templateSelectContainer,collapsible:!1,description:this._getPageSizeLabel(this._selectedTemplate),heading:this._getTemplateLabel(this._selectedTemplate,!0),key:"template-select-block",loading:"loading"===this._selectedTemplate?.state,onclick:()=>{this._showTemplates=!0}},C("calcite-icon",{class:M.templateSelectIcon,icon:(this._selectedTemplate?.layout?N.get(this._selectedTemplate.layout):null)||"custom-print",key:"template-select-icon",scale:"l",slot:"content-start"}),"error"===this._selectedTemplate?.state?C("calcite-icon",{class:M.templateSelectError,icon:"exclamation-mark-circle",key:"template-select-error",scale:"s",slot:"actions-end"}):null,C("calcite-icon",{class:M.templateSelectArrow,icon:T()?"chevron-left":"chevron-right",key:"template-select-arrow",scale:"s",slot:"actions-end"})))),I),F=C("div",{class:M.formSectionContainer},C("calcite-label",null,e.dpi,C("calcite-input-number",{bind:this,"data-input-name":"dpi",min:1,value:`${s}`,onCalciteInputNumberInput:this._handleDPIChange}))),j=C("div",{class:M.formSectionContainer},C("calcite-label",null,C("div",{class:M.srLabel},e.outSpatialReference,C("calcite-link",{href:"https://developers.arcgis.com/rest/services-reference/enterprise/using-spatial-references/",target:"_blank"},"(WKID)")),C("calcite-input-number",{bind:this,"data-input-name":"outSpatialReference",integer:!0,numberButtonType:"none",value:i.outSpatialReference?.wkid?.toString()??"",onCalciteInputNumberInput:({target:e})=>{const t=c(e.value);i.outSpatialReference=Number.isNaN(t)||null==t?null:new S({wkid:t}),this._isValidSpatialReference=!i.outSpatialReference||d(i.outSpatialReference)}}),this._isValidSpatialReference?null:C("div",{class:M.invalidWkidText,key:`out-sr-${i.outSpatialReference?.wkid}`},e.invalidWkid))),P=C("div",{class:this.classes(M.scaleInfoContainer,M.formSectionContainer)},C("calcite-label",{layout:"inline"},C("calcite-checkbox",{bind:this,checked:v,"data-option-name":"scaleEnabled",onCalciteCheckboxChange:this._toggleInputValue}),e.scale),C("div",{class:M.scaleInputContainer},C("calcite-input-number",{"aria-label":e.scaleLabel,"aria-valuenow":`${g}`,bind:this,class:M.scaleInput,"data-input-name":"scale",disabled:!v,value:`${g}`,onCalciteInputNumberInput:this._updateNumberInputValue}),C("calcite-button",{appearance:"outline","aria-label":e.reset,bind:this,disabled:!v,iconStart:"refresh",kind:"neutral",onclick:this._resetToCurrentScale}))),B=C("div",{"aria-labelledby":`${this.id}__advancedOptionsForLayout`,class:M.advancedOptionsContainer,key:"advanced-section-for-layout"},P,this._selectedTemplate?.layoutTemplateInfo?.layoutOptions?.hasAuthorText??1?C("div",{class:M.formSectionContainer,key:"author-info"},C("calcite-label",null,e.author,C("calcite-input",{bind:this,"data-input-name":"author",value:o??"",onCalciteInputInput:this._updateInputValue}))):null,this._selectedTemplate?.layoutTemplateInfo?.layoutOptions?.hasCopyrightText??1?C("div",{class:M.formSectionContainer,key:"copyright-text"},C("calcite-label",null,e.copyright,C("calcite-input",{bind:this,"data-input-name":"copyright",value:n??"",onCalciteInputInput:this._updateInputValue}))):null,F,j,this._renderCustomTextElementSection(),this._selectedTemplate?.layoutTemplateInfo?.layoutOptions?.hasLegend??1?C("div",{class:M.formSectionContainer,key:"legend-info"},C("calcite-label",{layout:"inline"},C("calcite-checkbox",{bind:this,checked:h,"data-option-name":"legendEnabled",onCalciteCheckboxChange:this._toggleInputValue}),e.legend)):null,this._selectedTemplate?.mapSurroundInfoOptions?.northArrow.length?C("div",{class:M.formSectionContainer,key:"north-arrow"},C("calcite-label",{layout:"inline"},C("calcite-checkbox",{bind:this,checked:b,"data-option-name":"northArrowEnabled",onCalciteCheckboxChange:this._toggleInputValue}),e.northArrow)):null,this._selectedTemplate?.mapSurroundInfoOptions?.scaleBar.length?C("div",{class:M.formSectionContainer,key:"scale-bar"},C("calcite-label",{layout:"inline"},C("calcite-checkbox",{bind:this,checked:_,"data-option-name":"scaleBarEnabled",onCalciteCheckboxChange:this._toggleInputValue}),e.scaleBar)):null),A=C("div",{"aria-labelledby":`${this.id}__advancedOptionsForMapOnly`,class:M.advancedOptionsContainer},P,F,j,C("div",{class:M.formSectionContainer},C("calcite-label",{layout:"inline"},C("calcite-checkbox",{bind:this,checked:l,"data-option-name":"attributionEnabled",onCalciteCheckboxChange:this._toggleInputValue}),e.attribution)),this._renderCustomTextElementSection()),R=this.exportedLinks.toArray(),D=this._renderExportedLink(R),V={[M.exportSectionCentered]:!R.length},U=this._selectedTab===E.layout?C("section",{"aria-labelledby":`${this.id}__layoutTab`,class:M.layoutSection,id:`${this.id}__layoutContent`,key:"esri-print__layoutContent",role:"tabpanel"},C("div",{class:M.panelContainer},this._selectedTemplate?.layoutTemplateInfo?.layoutOptions?.hasTitleText??1?O:null,L,this._selectedTab===E.layout?$:null,C("calcite-block",{"aria-label":e.advancedOptions,class:this.classes(M.panelContainer,M.advancedOptionsSection),collapsible:!0,disabled:!(m||u?.id),heading:e.advancedOptions,id:"advancedOptionsForLayout",key:"advanced-options-for-layout"},B))):this._selectedTab===E.mapOnly?C("section",{"aria-labelledby":`${this.id}__mapOnlyTab`,class:M.mapOnlySection,id:`${this.id}__mapOnlyContent`,key:"esri-print__mapOnlyContent",role:"tabpanel"},C("div",{class:M.panelContainer},O,$,C("div",null,C("div",{class:this.classes(M.sizeContainer,M.formSectionContainer)},C("calcite-label",null,e.width,C("calcite-input-number",{bind:this,"data-input-name":"width",value:`${x}`,onCalciteInputNumberInput:this._updateNumberInputValue})),C("calcite-label",null,e.height,C("calcite-input-number",{bind:this,"data-input-name":"height",value:`${p}`,onCalciteInputNumberInput:this._updateNumberInputValue})),C("button",{"aria-label":e.swap,bind:this,class:this.classes(f.widgetButton,M.swapButton,w.swap),onclick:this._switchInput,type:"button"})),I),C("calcite-block",{"aria-label":e.advancedOptions,class:this.classes(M.panelContainer,M.advancedOptionsSection),collapsible:!0,heading:e.advancedOptions,id:"advancedOptionsForMapOnly",key:"advanced-options-for-map-only"},A))):C("section",{"aria-labelledby":`${this.id}__exportTab`,class:this.classes(M.exportSection,V),id:`${this.id}__exportContent`,key:"esri-print__exportContent",role:"tabpanel"},C("div",{class:M.panelContainer},C("div",{afterUpdate:this._scrollExportIntoView,bind:this,class:M.exportedFilesContainer},0===R.length?C("div",{class:M.exportedFilesEmpty},C("calcite-icon",{icon:"file",scale:"l"}),C("div",null,C(y,{class:M.exportedFilesTitle,level:this.headingLevel},e.noExportedFiles),C("div",null,e.exportHint))):D))),H="2d"!==a?.type,z=C("div",{class:M.panelError},a?H?e.sceneViewError:e.serviceError:e.noViewError),W=R.some((({state:e})=>"pending"===e)),q=C("div",{class:M.content,key:"panel"},C("div",null,C("ul",{bind:this,class:M.layoutTabList,onclick:this._toggleLayoutPanel,onkeydown:this._handleLayoutPanelKeyDown,role:"tablist"},C("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${this._selectedTab===E.layout}`,class:M.layoutTab,"data-tab-id":E.layout,id:`${this.id}__layoutTab`,role:"tab",tabIndex:0},e.layoutTab),C("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${this._selectedTab===E.mapOnly}`,class:M.layoutTab,"data-tab-id":E.mapOnly,id:`${this.id}__mapOnlyTab`,role:"tab",tabIndex:0},e.mapOnlyTab),C("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${this._selectedTab===E.export}`,class:M.layoutTab,"data-tab-id":E.export,id:`${this.id}__exportedFilesTab`,role:"tab",tabIndex:0},W?C("calcite-loader",{inline:!0,label:"loading",scale:"s"}):null,e.exportsTab)),U),this._selectedTab!==E.export?C("div",{class:this.classes(M.printButtonSection,!this.saveExportHidden&&this.portal?M.printButtonSectionDivider:null),key:"export-button-section"},!this.saveExportHidden&&this.portal?C("calcite-label",{layout:"inline"},C("calcite-checkbox",{bind:this,checked:this.saveExportEnabled,onCalciteCheckboxChange:e=>{this.saveExportEnabled=!!e.target.checked}}),e.saveExportToMyContent):null,C("calcite-button",{"aria-label":e.exportDescription,bind:this,class:this.classes(M.printButton),disabled:k||!(m||u?.id)&&!r,onclick:this._handlePrintMap,scale:"l",width:"full"},e.export)):null),K=C("calcite-flow",{key:"root-flow"},C("calcite-flow-item",{bind:this,key:"root-flow-item"},C("div",{class:M.printWidgetContainer},this.headerVisible?C("header",{class:M.headerTitle},e.export):null,this.error||H||!a?z:q)),this._renderChooseTemplateFlowItem()),G="initializing"===i.state,J=G?this._renderLoader():K,Q={[M.panelItemsCentered]:G};return C("div",{bind:this,class:this.classes(M.base,f.widget,f.panel,Q)},J)}_getPageSizeLabel(e){if(!e)return;const t=e.layoutTemplateInfo;if(!t)return;const i=R.fromJSON(t.pageUnits.toLowerCase());return`${O(t.pageSize[0])} x ${O(t.pageSize[1])} ${o(this.messagesUnits,i,"abbr")}`}_getTemplateLabel(e,t=!1){if(!e)return t?this.messages.selectTemplate:this.messages.untitled;const{label:i,layout:a,layoutItem:l,type:o}=e;if("print-service-template"===o)return this.messages[a];const n=i??a??l?.id;return n?.replaceAll("_"," ")??this.messages.untitled}_getPortalTemplates(){const{portalTemplateIds:e}=this.viewModel;return this.includeDefaultTemplates?this.viewModel.defaultTemplates.toArray().filter((({layout:t,layoutItem:i})=>!B(t)&&!!i?.id&&e.includes(i.id))):[]}_getDefaultTemplates(){const{portalTemplateIds:e}=this.viewModel;return this.includeDefaultTemplates?this.viewModel.defaultTemplates.toArray().filter((({layout:t,layoutItem:i})=>!(B(t)||i?.id&&e.includes(i.id)))):[]}_getPrintServiceTemplates(){return this.includeDefaultTemplates&&this._getDefaultTemplates().length?[]:this.viewModel.printServiceTemplates.toArray().filter((({layout:e})=>!B(e)))}_renderLayoutTemplates(e,t=!1,i=!1){return t&&e.sort(((e,t)=>(e.label??"")>(t.label??"")?1:-1)),e.map((e=>C("calcite-list-item",{description:this._getPageSizeLabel(e),key:`template-${e.id}-${e.id===this.templateOptions.id}`,label:this._getTemplateLabel(e),selected:e.id===this.templateOptions.id,title:e.description??"",value:e},C("calcite-icon",{icon:(e.layout?N.get(e.layout):null)||"custom-print",slot:"content-start"}),"loading"===e.state?C("calcite-loader",{inline:!0,key:`template-loader-${e.id}`,label:"loading",scale:"s",slot:"content-end"}):null,"error"===e?.state?C("calcite-icon",{class:M.templateSelectError,icon:"exclamation-mark-circle",key:`template-error-${e.id}`,scale:"s",slot:"content-end"}):null,i?C("calcite-action",{icon:"trash",onclick:()=>this.viewModel.removePortalTemplate(e),slot:"actions-end",text:"delete"}):null)))}_renderChooseTemplateFlowItem(){if(!this._showTemplates)return null;const{messages:e}=this,t=m.test(this.portal?.url),i=this.viewModel.browseTemplates.toArray(),a=this._getPortalTemplates(),l=this._getDefaultTemplates(),o=this._getPrintServiceTemplates(),n=i.length+a.length+l.length+o.length>15,s=this.browseTemplateButtonOnClick?C("calcite-button",{appearance:"outline",class:n?M.browseTemplateButtonContainerFilter:M.browseTemplateButtonContainer,iconStart:"folder",key:"browse-template-button",onclick:this.browseTemplateButtonOnClick,slot:n?"filter-actions-end":"default"},n?null:e.browseTemplates):null;return C("calcite-flow-item",{bind:this,closable:!1,heading:e.chooseTemplate,key:"template-flow-item",onCalciteFlowItemBack:e=>{e.preventDefault(),this._showTemplates=!1}},C("div",{class:M.templateSelectFlowItemContainer},C("div",{class:M.templateSelectFlowItemContent},n?null:s,C("calcite-list",{filterEnabled:n,filterProps:["label"],key:"template-list",selectionMode:"single-persist",onCalciteListChange:({target:e})=>this.viewModel.applyTemplate(e.selectedItems[0]?.value)},n?s:null,i.length?C("div",{key:"my-templates"},C("div",{class:M.templateSelectFlowItemListHeading},e.myTemplates,C("calcite-chip",{appearance:"outline",kind:"neutral",scale:"s",value:e.beta},e.beta)),this._renderLayoutTemplates(i,!0,!0)):null,a.length?C("div",{key:"org-templates"},C("div",{class:M.templateSelectFlowItemListHeading},e.organizationTemplates,t?C("calcite-chip",{appearance:"outline",kind:"neutral",scale:"s",value:e.beta},e.beta):null),this._renderLayoutTemplates(a)):null,i.length||a.length?l.length?C("div",{key:"default-templates"},C("div",{class:M.templateSelectFlowItemListHeading},e.defaultTemplates),this._renderLayoutTemplates(l,!0)):null:this._renderLayoutTemplates(l,!0),i.length||a.length?o.length?C("div",{key:"service-templates"},C("div",{class:M.templateSelectFlowItemListHeading},e.defaultTemplates),this._renderLayoutTemplates(o)):null:this._renderLayoutTemplates(o))),C("div",{class:M.templateButtonContainer},C("calcite-button",{class:M.templateDoneButton,onclick:()=>this._showTemplates=!1},this.messagesCommon.done))))}_renderCustomTextElementSection(){const{customTextElements:e}=this.templateOptions;return e?C("div",{class:M.formSectionContainer,key:"custom-text-elements"},e.map(((e,t)=>{const[i,a]=Object.entries(e)[0];return"date"===i?null:C("calcite-label",{key:`custom-text-elements-${i}-${t}`},i,C("calcite-input",{bind:this,"data-input-custom":!0,"data-input-name":i,value:a??"",onCalciteInputInput:this._updateInputValue}))}))):null}_renderTitleOrFileNameSection(){const{title:e,fileName:t,titlePlaceHolder:i,fileNamePlaceHolder:a}=this.messages,l=this._selectedTab===E.layout?e:t,o=this._selectedTab===E.layout?i:a,n=this._selectedTab===E.layout?this.templateOptions.title:this.templateOptions.fileName;return C("div",{class:M.formSectionContainer,key:l},C("calcite-label",null,l,C("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===E.layout||"mapOnlyTab"===t&&this._selectedTab===E.mapOnly||"exportTab"===t&&this._selectedTab===E.export)&&(e.focus(),this._activeTabFocusRequested=!1)}_renderLoader(){const e={[M.loader]:this._awaitingServerResponse};return C("div",{class:this.classes(e),key:"loader"})}_updateExportedFileNameMap(e){void 0!==this._exportedFileNameMap[e]?this._exportedFileNameMap[e]++:this._exportedFileNameMap[e]=0}_createFileLink(e,t){const i=t||this.messages.untitled,a=e.format.toLowerCase(),l=a.includes("png")?"png":a,o=i+l;return this._updateExportedFileNameMap(o),new _({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;a?this._updateCustomTextElementValue(l.customTextElements,i,t.value):l[i]=t.value}_updateNumberInputValue(e){const t=e.target,i=t.getAttribute("data-input-name"),{templateOptions:a}=this,l=Number(t.value);if(P(l))a[i]=l;else{const e=a[i];t.value=`${e}`}}_handleDPIChange(e){const{templateOptions:t}=this,i=t.dpi;this._updateNumberInputValue(e);const a=t.dpi,{height:l,width:o}=j(a,i,t.width,t.height);t.height=l,t.width=o}_handlePrintMap(){this._pendingExportScroll=!0;const{templateOptions:e,saveExportEnabled:t}=this,i=this.viewModel.toPrintTemplate(e),a=this._selectedTab===E.layout?i.layoutOptions?.titleText:e.fileName,l=this._createFileLink(i,a);this.exportedLinks.add(l),this.emit("submit",{link:l,saveExportEnabled:t}),this._selectedTab=E.export,this.viewModel.print(i).then((e=>{l.set({url:e&&e.url,state:"ready"})})).catch((e=>{l.set({error:e,state:"error"})})).then((()=>{this.emit("complete",{link:l,saveExportEnabled:t}),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._resetToCurrentScale()}_renderExportedLink(e){const t=this.messages,i=e.map((e=>{const{error:i,url:a,state:o}=e,r=e.formattedName??"",c="error"===o,p="pending"===o,d="ready"===o;let m=a||null;m&&(m=n(m));const u=s(a,location.href);let h;h=p?t.pending:d?t.ready:t.errorMessage;const b=c?"print-task:cim-symbol-unsupported"===i?.name?t.exportWebMapCIMError:t.exportWebMapError:"";return C("calcite-list-item",{"aria-label":h,key:r,title:b},C("div",{class:M.exportedFile,"data-item":e,onclick:this._handleLinkClick,slot:"content"},C("div",null,C("div",{class:M.exportedFileLinkTitle},r),C("div",{class:M.exportedFileLinkDescription},p?t.generatingExport:b||(u?t.ready:t.linkReady))),d?C("calcite-icon",{"aria-label":`${r}. ${t.linkReady}`,icon:u?"download-to":"launch",key:`${r}-end-icon`,scale:"s",slot:"content-end"}):null),p?C("calcite-loader",{class:M.exportedFileLoader,inline:!0,key:`${r}-loader`,label:t.generatingExport,scale:"m",slot:"content-start"}):C("calcite-icon",{icon:A(e),key:`${r}-start-icon`,scale:"s",slot:"content-start"}),p?null:this.saveAsButtonCallback&&!c&&this._isFormatAllowedForSaving(e.extension)?C("calcite-action",{"aria-label":`${b}`,icon:"ellipsis",id:`${r}-popover-button`,key:`${r}-action`,slot:"actions-end",text:`${b}`},C("calcite-popover",{autoClose:!0,key:`${r}-popover`,label:"Popover",offsetDistance:1,overlayPositioning:"fixed",pointerDisabled:!0,referenceElement:`${r}-popover-button`,scale:"s"},C("calcite-list",null,e.portalItem?C("calcite-list-item",{label:t.openItem,onCalciteListItemSelect:()=>{const t=e.portalItem;if(!t||!t.itemPageUrl)return;const i=document.createElement("a");i.target="_blank",i.href=t.itemPageUrl,i.rel="noreferrer",i.click()}},C("calcite-icon",{icon:"launch2",key:`${r}-launch-icon`,scale:"s",slot:"content-start"})):C("calcite-list-item",{label:t.saveAs,onCalciteListItemSelect:async()=>{this.saveAsButtonCallback&&(l((()=>e.portalItem)).then((e=>{e.itemPageUrl&&this.scheduleRender()})),await this.saveAsButtonCallback(e))}},C("calcite-icon",{icon:"save",key:`${r}-save-icon`,scale:"s",slot:"content-start"})),C("calcite-list-item",{label:this.messagesCommon.delete,onCalciteListItemSelect:()=>this.exportedLinks.remove(e)},C("calcite-icon",{icon:"trash",key:`${r}-delete-icon`,scale:"s",slot:"content-start"}))))):C("calcite-action",{"aria-label":`${b}`,icon:"x",key:`${r}-action`,onclick:()=>{this.exportedLinks.remove(e)},slot:"actions-end",text:`${b}`}))}));return C("calcite-list",{filterEnabled:e?.length>10},i)}_isFormatAllowedForSaving(e){return!this.allowedFormatsForSaving||"all"===this.allowedFormatsForSaving||!(!e||!this.allowedFormatsForSaving.includes(e))}_toggleLayoutPanel(e){const t=e.target;this._toggleTab(t.getAttribute("data-tab-id"))}_toggleTab(e,t=!0){if(this._selectedTab=e,this._selectedTab===E.mapOnly)this.templateOptions.reset(),this.templateOptions.layout=I;else if(this._selectedTab===E.layout){const e=this._selectedTemplate??this.viewModel.defaultTemplate;e?this.viewModel.applyTemplate(e):this.templateOptions.reset()}t&&(this._activeTabFocusRequested=!0)}_handleLayoutPanelKeyDown(e){const{key:t}=e,i=e.target.getAttribute("data-tab-id");if(x(t))return this._toggleTab(i),e.preventDefault(),void e.stopPropagation();if("ArrowLeft"===t||"ArrowRight"===t){switch(i){case E.layout:this._toggleTab("ArrowLeft"===t?E.export:E.mapOnly);break;case E.mapOnly:this._toggleTab("ArrowLeft"===t?E.layout:E.export);break;case E.export:this._toggleTab("ArrowLeft"===t?E.mapOnly:E.layout)}e.preventDefault(),e.stopPropagation()}}};e([r()],D.prototype,"_showTemplates",void 0),e([r()],D.prototype,"_isValidSpatialReference",void 0),e([r()],D.prototype,"allowedFormats",null),e([r()],D.prototype,"allowedFormatsForSaving",void 0),e([r()],D.prototype,"allowedLayouts",null),e([r()],D.prototype,"browseTemplateButtonOnClick",void 0),e([r()],D.prototype,"error",null),e([r({type:$})],D.prototype,"exportedLinks",void 0),e([r()],D.prototype,"extraParameters",null),e([r()],D.prototype,"headerVisible",void 0),e([r()],D.prototype,"headingLevel",void 0),e([r()],D.prototype,"icon",null),e([r()],D.prototype,"includeDefaultTemplates",null),e([r()],D.prototype,"label",null),e([r(),k("esri/widgets/Print/t9n/Print")],D.prototype,"messages",void 0),e([r(),k("esri/t9n/common")],D.prototype,"messagesCommon",void 0),e([r(),k("esri/core/t9n/Units")],D.prototype,"messagesUnits",void 0),e([r({type:S})],D.prototype,"outSpatialReference",null),e([r()],D.prototype,"portal",null),e([r()],D.prototype,"saveExportEnabled",void 0),e([r()],D.prototype,"saveExportHidden",void 0),e([r()],D.prototype,"showPrintAreaEnabled",null),e([r()],D.prototype,"printServiceUrl",null),e([r()],D.prototype,"saveAsButtonCallback",void 0),e([r()],D.prototype,"templateCustomTextElements",null),e([r()],D.prototype,"templateOptions",null),e([r()],D.prototype,"view",null),e([r({type:v})],D.prototype,"viewModel",void 0),D=e([p("esri.widgets.Print")],D);const V=D;export{V as default};
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import"../geometry.js";import"../intl.js";import t from"../core/Collection.js";import{JSONMap as i}from"../core/jsonMap.js";import{watch as a,whenOnce as l}from"../core/reactiveUtils.js";import{unitName as o}from"../core/unitFormatUtils.js";import{addProxy as n,hasSameOrigin as s}from"../core/urlUtils.js";import{property as r}from"../core/accessorSupport/decorators/property.js";import{ensureInteger as c}from"../core/accessorSupport/ensureType.js";import"../core/RandomLCG.js";import"../core/has.js";import{subclass as p}from"../core/accessorSupport/decorators/subclass.js";import{isValid as d}from"../geometry/support/spatialReferenceUtils.js";import{reArcGISOnlineDomain as m}from"../portal/support/urlUtils.js";import{getToken as u}from"../rest/utils.js";import{formatJsonMap as h}from"../rest/support/fileFormat.js";import b from"./Widget.js";import _ from"./Print/FileLink.js";import v from"./Print/PrintViewModel.js";import{loadCalciteComponents as g}from"./support/componentsUtils.js";import{globalCss as f}from"./support/globalCss.js";import{Heading as y}from"./support/Heading.js";import{legacyIcon as w}from"./support/legacyIcon.js";import{isRTL as T,isActivationKey as x}from"./support/widgetUtils.js";import{messageBundle as k}from"./support/decorators/messageBundle.js";import{tsx as C}from"./support/jsxFactory.js";import S from"../geometry/SpatialReference.js";import{formatNumber as O}from"../intl/number.js";const $=t.ofType(_),I="map-only";var E;!function(e){e.layout="layoutTab",e.mapOnly="mapOnlyTab",e.export="exportTab"}(E||(E={}));const L="esri-print",F=`${L}__advanced-options-button`,M={base:L,headerTitle:`${L}__header-title`,layoutTabList:`${L}__layout-tab-list`,layoutTab:`${L}__layout-tab`,layoutSection:`${L}__layout-section`,mapOnlySection:`${L}__map-only-section`,panelItemsCentered:`${L}__panel-items--centered`,loader:`${L}__loader`,advancedOptionsButton:F,advancedOptionsButtonContainer:`${F}-container`,advancedOptionsButtonTitle:`${F}-title`,advancedOptionsButtonIconOpened:`${F}-icon--opened`,advancedOptionsButtonIconClosed:`${F}-icon--closed`,advancedOptionsButtonIconClosed_RTL:`${F}-icon--closed-rtl`,swapButton:`${L}__swap-button`,printButton:`${L}__export-button`,printButtonSection:`${L}__export-button-section`,printButtonSectionDivider:`${L}__export-button-section--divider`,templateSelectContainer:`${L}__template-select-container`,templateSelectBlock:`${L}__template-select-block`,templateSelectIcon:`${L}__template-select-icon`,templateSelectError:`${L}__template-select-error`,templateSelectArrow:`${L}__template-select-arrow`,formSectionContainer:`${L}__form-section-container`,formCheckboxLabel:`${L}__form-checkbox-label`,advancedOptionsSection:`${L}__advanced-options-section`,advancedOptionsContainer:`${L}__advanced-options-container`,browseTemplateButtonContainer:`${L}__browse-template-button-container`,browseTemplateButtonContainerFilter:`${L}__browse-template-button-container-filter`,exportedFilesContainer:`${L}__export-panel-container`,exportedFilesTitle:`${L}__export-title`,exportedFile:`${L}__exported-file`,exportedFileLink:`${L}__exported-file-link`,exportedFileLinkTitle:`${L}__exported-file-link-title`,exportedFileLinkDescription:`${L}__exported-file-link-description`,exportedFilesEmpty:`${L}__exported-files-empty`,printWidgetContainer:`${L}__container`,content:`${L}__content`,panelContainer:`${L}__panel-container`,scaleInfoContainer:`${L}__scale-info-container`,scaleInputContainer:`${L}__scale-input-container`,scaleInput:`${L}__scale-input`,sizeContainer:`${L}__size-container`,panelError:`${L}__panel--error`,exportedFileError:`${L}__exported-file--error`,exportedFileLoader:`${L}__exported-file--loader`,exportSection:`${L}__export-section`,exportSectionCentered:`${L}__export-section--centered`,templateButtonContainer:`${L}__template-button-container`,templateDoneButton:`${L}__template-done-button`,templateSelectFlowItemContainer:`${L}__template-select-flow-item-container`,templateSelectFlowItemContent:`${L}__template-select-flow-item-content`,templateSelectFlowItemListHeading:`${L}__template-select-flow-item-list-heading`,srLabel:`${L}__sr-label`,invalidWkidText:`${L}__invalid-wkid-text`};function j(e,t,i,a){const l=i/t,o=a/t;return{width:Math.round(e*l),height:Math.round(e*o)}}function P(e){return!isNaN(e)&&e>0}function B(e){return e?.toLowerCase()===I}function A(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"}}const R=new i({inch:"inches",foot:"feet",yard:"yards",mile:"miles","nautical-mile":"nautical-miles",millimeter:"millimeters",centimeter:"centimeters",decimeter:"decimeters",meter:"meters",kilometer:"kilometers"}),N=new Map([["a3-landscape","a3-landscape"],["a3-portrait","a3-portrait"],["a4-landscape","a4-landscape"],["a4-portrait","a4-portrait"],["letter-ansi-a-landscape","ansi-a-landscape"],["letter-ansi-a-portrait","ansi-a-portrait"],["tabloid-ansi-b-landscape","ansi-b-landscape"],["tabloid-ansi-b-portrait","ansi-b-portrait"]]);let D=class extends b{constructor(e,t){super(e,t),this._activeTabFocusRequested=!1,this._awaitingServerResponse=!1,this._exportedFileNameMap={},this._selectedTab=E.layout,this._pendingExportScroll=!1,this._rootNode=null,this._selectedTemplate=null,this._formats=[],this._showTemplates=!1,this._isValidSpatialReference=!0,this.allowedFormatsForSaving=null,this.browseTemplateButtonOnClick=null,this.exportedLinks=new $,this.headerVisible=!0,this.headingLevel=3,this.messagesCommon=null,this.messagesUnits=null,this.saveExportEnabled=!1,this.saveExportHidden=!0,this.saveAsButtonCallback=null,this.viewModel=new v,this._onInput=e=>{this._selectedTab===E.layout?this.templateOptions.title=e.target.value:this._selectedTab===E.mapOnly&&(this.templateOptions.fileName=e.target.value)},this._handleLinkClick=e=>{const t=e.currentTarget["data-item"];if(!t||"ready"!==t.state||!t.url)return;const i=u(this.viewModel.effectivePrintServiceUrl),a=t.url,l=document.createElement("a");if(l.target="_blank",l.href=a,l.rel="noreferrer",l.download=t.formattedName??"",!i)return l.click(),void e.stopPropagation();e.preventDefault();const o=new URL(a);o.searchParams.set("token",i),l.href=o.href,l.click(),l.href=a},this._focusOnTabChange=this._focusOnTabChange.bind(this)}initialize(){this.addHandles([a((()=>[this.templateOptions.format,this.viewModel.templatesInfo?.format]),(()=>{const{templatesInfo:e}=this.viewModel;if(!e)return;if(this._formats.length!==e.format.choiceList.length){const t=h.apiValues;this._formats=e.format.choiceList.map((e=>{const i=t.find((t=>new RegExp(`\\b${t}\\b`,"i").test(e)))??e;return{value:i,label:e===i?e.toUpperCase():e}})).sort(((e,t)=>e.label.localeCompare(t.label)))}const t=this._formats.some((({value:e})=>new RegExp(`\\b${e}\\b`,"i").test(this.templateOptions.format)));if(!e.format.defaultValue||t);else{const t=this._formats.find((({value:t})=>new RegExp(`\\b${t}\\b`,"i").test(e.format.defaultValue)))?.value;t&&(this.templateOptions.format=t)}})),a((()=>[this.templateOptions.id,this.viewModel.loaded]),(async()=>{const{layout:e}=this.templateOptions;this._selectedTab=B(e)?E.mapOnly:E.layout,this._selectedTab===E.layout&&this.viewModel.loaded&&(this._selectedTemplate=this.viewModel.getLayoutTemplateById(this.templateOptions.id))})),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)}))]);for(const{name:a,extension:l}of this.exportedLinks)a&&l&&this._updateExportedFileNameMap(`${a}${l}`);const{height:e,width:t}=this.templateOptions;this.templateOptions.width=t||800,this.templateOptions.height=e||1100;const i=setTimeout((()=>{this._awaitingServerResponse=!0,this.scheduleRender()}),500);this.viewModel.load().then((()=>{clearTimeout(i),this._awaitingServerResponse=!1}))}loadDependencies(){return g({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"),"input-number":()=>import("@esri/calcite-components/dist/components/calcite-input-number.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"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch.js"),chip:()=>import("@esri/calcite-components/dist/components/calcite-chip.js"),popover:()=>import("@esri/calcite-components/dist/components/calcite-popover.js"),link:()=>import("@esri/calcite-components/dist/components/calcite-link.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 outSpatialReference(){return this.viewModel.outSpatialReference}set outSpatialReference(e){this.viewModel.outSpatialReference=e}get portal(){return this.viewModel.portal}set portal(e){this.viewModel.portal=e}get showPrintAreaEnabled(){return this.viewModel.showPrintAreaEnabled}set showPrintAreaEnabled(e){this.viewModel.showPrintAreaEnabled=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:m,layoutItem:u,legendEnabled:h,northArrowEnabled:b,scaleBarEnabled:_,scaleEnabled:v,scale:g,width:x}=t,k="ready"!==i.state||this._awaitingServerResponse||!(m||u),O=this._renderTitleOrFileNameSection(),$=C("div",{class:M.formSectionContainer},C("calcite-label",null,e.fileFormatTitle,C("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??"pdf"}},this._formats.map((({value:e,label:t},i)=>C("calcite-combobox-item",{key:`file-format-${i}`,selected:e===this.templateOptions.format,textLabel:t,value:e})))))),I=C("calcite-label",{layout:"inline"},C("calcite-switch",{checked:this.showPrintAreaEnabled,onCalciteSwitchChange:e=>{this.showPrintAreaEnabled=!!e.target.checked}}),e.printPreview),L=C("div",null,C("div",{class:M.formSectionContainer},C("calcite-label",null,e.template,C("calcite-block",{class:M.templateSelectContainer,collapsible:!1,description:this._getPageSizeLabel(this._selectedTemplate),heading:this._getTemplateLabel(this._selectedTemplate,!0),key:"template-select-block",loading:"loading"===this._selectedTemplate?.state,onclick:()=>{this._showTemplates=!0}},C("calcite-icon",{class:M.templateSelectIcon,icon:(this._selectedTemplate?.layout?N.get(this._selectedTemplate.layout):null)||"custom-print",key:"template-select-icon",scale:"l",slot:"content-start"}),"error"===this._selectedTemplate?.state?C("calcite-icon",{class:M.templateSelectError,icon:"exclamation-mark-circle",key:"template-select-error",scale:"s",slot:"actions-end"}):null,C("calcite-icon",{class:M.templateSelectArrow,icon:T()?"chevron-left":"chevron-right",key:"template-select-arrow",scale:"s",slot:"actions-end"})))),I),F=C("div",{class:M.formSectionContainer},C("calcite-label",null,e.dpi,C("calcite-input-number",{bind:this,"data-input-name":"dpi",min:1,value:`${s}`,onCalciteInputNumberInput:this._handleDPIChange}))),j=C("div",{class:M.formSectionContainer},C("calcite-label",null,C("div",{class:M.srLabel},e.outSpatialReference,C("calcite-link",{href:"https://developers.arcgis.com/rest/services-reference/enterprise/using-spatial-references/",target:"_blank"},"(WKID)")),C("calcite-input-number",{bind:this,"data-input-name":"outSpatialReference",integer:!0,numberButtonType:"none",value:i.outSpatialReference?.wkid?.toString()??"",onCalciteInputNumberInput:({target:e})=>{const t=c(e.value);i.outSpatialReference=Number.isNaN(t)||null==t?null:new S({wkid:t}),this._isValidSpatialReference=!i.outSpatialReference||d(i.outSpatialReference)}}),this._isValidSpatialReference?null:C("div",{class:M.invalidWkidText,key:`out-sr-${i.outSpatialReference?.wkid}`},e.invalidWkid))),P=C("div",{class:this.classes(M.scaleInfoContainer,M.formSectionContainer)},C("calcite-label",{layout:"inline"},C("calcite-checkbox",{bind:this,checked:v,"data-option-name":"scaleEnabled",onCalciteCheckboxChange:this._toggleInputValue}),e.scale),C("div",{class:M.scaleInputContainer},C("calcite-input-number",{"aria-label":e.scaleLabel,"aria-valuenow":`${g}`,bind:this,class:M.scaleInput,"data-input-name":"scale",disabled:!v,value:`${g}`,onCalciteInputNumberInput:this._updateNumberInputValue}),C("calcite-button",{appearance:"outline","aria-label":e.reset,bind:this,disabled:!v,iconStart:"refresh",kind:"neutral",onclick:this._resetToCurrentScale}))),B=C("div",{"aria-labelledby":`${this.id}__advancedOptionsForLayout`,class:M.advancedOptionsContainer,key:"advanced-section-for-layout"},P,this._selectedTemplate?.layoutTemplateInfo?.layoutOptions?.hasAuthorText??1?C("div",{class:M.formSectionContainer,key:"author-info"},C("calcite-label",null,e.author,C("calcite-input",{bind:this,"data-input-name":"author",value:o??"",onCalciteInputInput:this._updateInputValue}))):null,this._selectedTemplate?.layoutTemplateInfo?.layoutOptions?.hasCopyrightText??1?C("div",{class:M.formSectionContainer,key:"copyright-text"},C("calcite-label",null,e.copyright,C("calcite-input",{bind:this,"data-input-name":"copyright",value:n??"",onCalciteInputInput:this._updateInputValue}))):null,F,j,this._renderCustomTextElementSection(),this._selectedTemplate?.layoutTemplateInfo?.layoutOptions?.hasLegend??1?C("div",{class:M.formSectionContainer,key:"legend-info"},C("calcite-label",{layout:"inline"},C("calcite-checkbox",{bind:this,checked:h,"data-option-name":"legendEnabled",onCalciteCheckboxChange:this._toggleInputValue}),e.legend)):null,this._selectedTemplate?.mapSurroundInfoOptions?.northArrow.length?C("div",{class:M.formSectionContainer,key:"north-arrow"},C("calcite-label",{layout:"inline"},C("calcite-checkbox",{bind:this,checked:b,"data-option-name":"northArrowEnabled",onCalciteCheckboxChange:this._toggleInputValue}),e.northArrow)):null,this._selectedTemplate?.mapSurroundInfoOptions?.scaleBar.length?C("div",{class:M.formSectionContainer,key:"scale-bar"},C("calcite-label",{layout:"inline"},C("calcite-checkbox",{bind:this,checked:_,"data-option-name":"scaleBarEnabled",onCalciteCheckboxChange:this._toggleInputValue}),e.scaleBar)):null),A=C("div",{"aria-labelledby":`${this.id}__advancedOptionsForMapOnly`,class:M.advancedOptionsContainer},P,F,j,C("div",{class:M.formSectionContainer},C("calcite-label",{layout:"inline"},C("calcite-checkbox",{bind:this,checked:l,"data-option-name":"attributionEnabled",onCalciteCheckboxChange:this._toggleInputValue}),e.attribution)),this._renderCustomTextElementSection()),R=this.exportedLinks.toArray(),D=this._renderExportedLink(R),V={[M.exportSectionCentered]:!R.length},U=this._selectedTab===E.layout?C("section",{"aria-labelledby":`${this.id}__layoutTab`,class:M.layoutSection,id:`${this.id}__layoutContent`,key:"esri-print__layoutContent",role:"tabpanel"},C("div",{class:M.panelContainer},this._selectedTemplate?.layoutTemplateInfo?.layoutOptions?.hasTitleText??1?O:null,L,this._selectedTab===E.layout?$:null,C("calcite-block",{"aria-label":e.advancedOptions,class:this.classes(M.panelContainer,M.advancedOptionsSection),collapsible:!0,disabled:!(m||u?.id),heading:e.advancedOptions,id:"advancedOptionsForLayout",key:"advanced-options-for-layout"},B))):this._selectedTab===E.mapOnly?C("section",{"aria-labelledby":`${this.id}__mapOnlyTab`,class:M.mapOnlySection,id:`${this.id}__mapOnlyContent`,key:"esri-print__mapOnlyContent",role:"tabpanel"},C("div",{class:M.panelContainer},O,$,C("div",null,C("div",{class:this.classes(M.sizeContainer,M.formSectionContainer)},C("calcite-label",null,e.width,C("calcite-input-number",{bind:this,"data-input-name":"width",value:`${x}`,onCalciteInputNumberInput:this._updateNumberInputValue})),C("calcite-label",null,e.height,C("calcite-input-number",{bind:this,"data-input-name":"height",value:`${p}`,onCalciteInputNumberInput:this._updateNumberInputValue})),C("button",{"aria-label":e.swap,bind:this,class:this.classes(f.widgetButton,M.swapButton,w.swap),onclick:this._switchInput,type:"button"})),I),C("calcite-block",{"aria-label":e.advancedOptions,class:this.classes(M.panelContainer,M.advancedOptionsSection),collapsible:!0,heading:e.advancedOptions,id:"advancedOptionsForMapOnly",key:"advanced-options-for-map-only"},A))):C("section",{"aria-labelledby":`${this.id}__exportTab`,class:this.classes(M.exportSection,V),id:`${this.id}__exportContent`,key:"esri-print__exportContent",role:"tabpanel"},C("div",{class:M.panelContainer},C("div",{afterUpdate:this._scrollExportIntoView,bind:this,class:M.exportedFilesContainer},0===R.length?C("div",{class:M.exportedFilesEmpty},C("calcite-icon",{icon:"file",scale:"l"}),C("div",null,C(y,{class:M.exportedFilesTitle,level:this.headingLevel},e.noExportedFiles),C("div",null,e.exportHint))):D))),H="2d"!==a?.type,z=C("div",{class:M.panelError},a?H?e.sceneViewError:e.serviceError:e.noViewError),W=R.some((({state:e})=>"pending"===e)),q=C("div",{class:M.content,key:"panel"},C("div",null,C("ul",{bind:this,class:M.layoutTabList,onclick:this._toggleLayoutPanel,onkeydown:this._handleLayoutPanelKeyDown,role:"tablist"},C("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${this._selectedTab===E.layout}`,class:M.layoutTab,"data-tab-id":E.layout,id:`${this.id}__layoutTab`,role:"tab",tabIndex:0},e.layoutTab),C("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${this._selectedTab===E.mapOnly}`,class:M.layoutTab,"data-tab-id":E.mapOnly,id:`${this.id}__mapOnlyTab`,role:"tab",tabIndex:0},e.mapOnlyTab),C("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${this._selectedTab===E.export}`,class:M.layoutTab,"data-tab-id":E.export,id:`${this.id}__exportedFilesTab`,role:"tab",tabIndex:0},W?C("calcite-loader",{inline:!0,label:"loading",scale:"s"}):null,e.exportsTab)),U),this._selectedTab!==E.export?C("div",{class:this.classes(M.printButtonSection,!this.saveExportHidden&&this.portal?M.printButtonSectionDivider:null),key:"export-button-section"},!this.saveExportHidden&&this.portal?C("calcite-label",{layout:"inline"},C("calcite-checkbox",{bind:this,checked:this.saveExportEnabled,onCalciteCheckboxChange:e=>{this.saveExportEnabled=!!e.target.checked}}),e.saveExportToMyContent):null,C("calcite-button",{"aria-label":e.exportDescription,bind:this,class:this.classes(M.printButton),disabled:k||!(m||u?.id)&&!r,onclick:this._handlePrintMap,scale:"l",width:"full"},e.export)):null),K=C("calcite-flow",{key:"root-flow"},C("calcite-flow-item",{bind:this,key:"root-flow-item"},C("div",{class:M.printWidgetContainer},this.headerVisible?C("header",{class:M.headerTitle},e.export):null,this.error||H||!a?z:q)),this._renderChooseTemplateFlowItem()),G="initializing"===i.state,J=G?this._renderLoader():K,Q={[M.panelItemsCentered]:G};return C("div",{bind:this,class:this.classes(M.base,f.widget,f.panel,Q)},J)}_getPageSizeLabel(e){if(!e)return;const t=e.layoutTemplateInfo;if(!t)return;const i=R.fromJSON(t.pageUnits.toLowerCase());return`${O(t.pageSize[0])} x ${O(t.pageSize[1])} ${o(this.messagesUnits,i,"abbr")}`}_getTemplateLabel(e,t=!1){if(!e)return t?this.messages.selectTemplate:this.messages.untitled;const{label:i,layout:a,layoutItem:l,type:o}=e;if("print-service-template"===o)return this.messages[a];const n=i??a??l?.id;return n?.replaceAll("_"," ")??this.messages.untitled}_getPortalTemplates(){const{portalTemplateIds:e}=this.viewModel;return this.includeDefaultTemplates?this.viewModel.defaultTemplates.toArray().filter((({layout:t,layoutItem:i})=>!B(t)&&!!i?.id&&e.includes(i.id))):[]}_getDefaultTemplates(){const{portalTemplateIds:e}=this.viewModel;return this.includeDefaultTemplates?this.viewModel.defaultTemplates.toArray().filter((({layout:t,layoutItem:i})=>!(B(t)||i?.id&&e.includes(i.id)))):[]}_getPrintServiceTemplates(){return this.includeDefaultTemplates&&this._getDefaultTemplates().length?[]:this.viewModel.printServiceTemplates.toArray().filter((({layout:e})=>!B(e)))}_renderLayoutTemplates(e,t=!1,i=!1){return t&&e.sort(((e,t)=>(e.label??"")>(t.label??"")?1:-1)),e.map((e=>C("calcite-list-item",{description:this._getPageSizeLabel(e),key:`template-${e.id}-${e.id===this.templateOptions.id}`,label:this._getTemplateLabel(e),selected:e.id===this.templateOptions.id,title:e.description??"",value:e},C("calcite-icon",{icon:(e.layout?N.get(e.layout):null)||"custom-print",slot:"content-start"}),"loading"===e.state?C("calcite-loader",{inline:!0,key:`template-loader-${e.id}`,label:"loading",scale:"s",slot:"content-end"}):null,"error"===e?.state?C("calcite-icon",{class:M.templateSelectError,icon:"exclamation-mark-circle",key:`template-error-${e.id}`,scale:"s",slot:"content-end"}):null,i?C("calcite-action",{icon:"trash",onclick:()=>this.viewModel.removePortalTemplate(e),slot:"actions-end",text:"delete"}):null)))}_renderChooseTemplateFlowItem(){if(!this._showTemplates)return null;const{messages:e}=this,t=m.test(this.portal?.url),i=this.viewModel.browseTemplates.toArray(),a=this._getPortalTemplates(),l=this._getDefaultTemplates(),o=this._getPrintServiceTemplates(),n=i.length+a.length+l.length+o.length>15,s=this.browseTemplateButtonOnClick?C("calcite-button",{appearance:"outline",class:n?M.browseTemplateButtonContainerFilter:M.browseTemplateButtonContainer,iconStart:"folder",key:"browse-template-button",onclick:this.browseTemplateButtonOnClick,slot:n?"filter-actions-end":"default"},n?null:e.browseTemplates):null;return C("calcite-flow-item",{bind:this,closable:!1,heading:e.chooseTemplate,key:"template-flow-item",onCalciteFlowItemBack:e=>{e.preventDefault(),this._showTemplates=!1}},C("div",{class:M.templateSelectFlowItemContainer},C("div",{class:M.templateSelectFlowItemContent},n?null:s,C("calcite-list",{filterEnabled:n,filterProps:["label"],key:"template-list",selectionMode:"single-persist",onCalciteListChange:({target:e})=>this.viewModel.applyTemplate(e.selectedItems[0]?.value)},n?s:null,i.length?C("div",{key:"my-templates"},C("div",{class:M.templateSelectFlowItemListHeading},e.myTemplates,C("calcite-chip",{appearance:"outline",kind:"neutral",scale:"s",value:e.beta},e.beta)),this._renderLayoutTemplates(i,!0,!0)):null,a.length?C("div",{key:"org-templates"},C("div",{class:M.templateSelectFlowItemListHeading},e.organizationTemplates,t?C("calcite-chip",{appearance:"outline",kind:"neutral",scale:"s",value:e.beta},e.beta):null),this._renderLayoutTemplates(a)):null,i.length||a.length?l.length?C("div",{key:"default-templates"},C("div",{class:M.templateSelectFlowItemListHeading},e.defaultTemplates),this._renderLayoutTemplates(l,!0)):null:this._renderLayoutTemplates(l,!0),i.length||a.length?o.length?C("div",{key:"service-templates"},C("div",{class:M.templateSelectFlowItemListHeading},e.defaultTemplates),this._renderLayoutTemplates(o)):null:this._renderLayoutTemplates(o))),C("div",{class:M.templateButtonContainer},C("calcite-button",{class:M.templateDoneButton,onclick:()=>this._showTemplates=!1},this.messagesCommon.done))))}_renderCustomTextElementSection(){const{customTextElements:e}=this.templateOptions;return e?C("div",{class:M.formSectionContainer,key:"custom-text-elements"},e.map(((e,t)=>{const[i,a]=Object.entries(e)[0];return"date"===i?null:C("calcite-label",{key:`custom-text-elements-${i}-${t}`},i,C("calcite-input",{bind:this,"data-input-custom":!0,"data-input-name":i,value:a??"",onCalciteInputInput:this._updateInputValue}))}))):null}_renderTitleOrFileNameSection(){const{title:e,fileName:t,titlePlaceHolder:i,fileNamePlaceHolder:a}=this.messages,l=this._selectedTab===E.layout?e:t,o=this._selectedTab===E.layout?i:a,n=this._selectedTab===E.layout?this.templateOptions.title:this.templateOptions.fileName;return C("div",{class:M.formSectionContainer,key:l},C("calcite-label",null,l,C("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===E.layout||"mapOnlyTab"===t&&this._selectedTab===E.mapOnly||"exportTab"===t&&this._selectedTab===E.export)&&(e.focus(),this._activeTabFocusRequested=!1)}_renderLoader(){const e={[M.loader]:this._awaitingServerResponse};return C("div",{class:this.classes(e),key:"loader"})}_updateExportedFileNameMap(e){void 0!==this._exportedFileNameMap[e]?this._exportedFileNameMap[e]++:this._exportedFileNameMap[e]=0}_createFileLink(e,t){const i=t||this.messages.untitled,a=e.format.toLowerCase(),l=a.includes("png")?"png":a,o=i+l;return this._updateExportedFileNameMap(o),new _({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;a?this._updateCustomTextElementValue(l.customTextElements,i,t.value):l[i]=t.value}_updateNumberInputValue(e){const t=e.target,i=t.getAttribute("data-input-name"),{templateOptions:a}=this,l=Number(t.value);if(P(l))a[i]=l;else{const e=a[i];t.value=`${e}`}}_handleDPIChange(e){const{templateOptions:t}=this,i=t.dpi;this._updateNumberInputValue(e);const a=t.dpi,{height:l,width:o}=j(a,i,t.width,t.height);t.height=l,t.width=o}_handlePrintMap(){this._pendingExportScroll=!0;const{templateOptions:e,saveExportEnabled:t}=this,i=this.viewModel.toPrintTemplate(e),a=this._selectedTab===E.layout?i.layoutOptions?.titleText:e.fileName,l=this._createFileLink(i,a);this.exportedLinks.add(l),this.emit("submit",{link:l,saveExportEnabled:t}),this._selectedTab=E.export,this.viewModel.print(i).then((e=>{l.set({url:e&&e.url,state:"ready"})})).catch((e=>{l.set({error:e,state:"error"})})).then((()=>{this.emit("complete",{link:l,saveExportEnabled:t}),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._resetToCurrentScale()}_renderExportedLink(e){const t=this.messages,i=e.map((e=>{const{error:i,url:a,state:o}=e,r=e.formattedName??"",c="error"===o,p="pending"===o,d="ready"===o;let m=a||null;m&&(m=n(m));const u=s(a,location.href);let h;h=p?t.pending:d?t.ready:t.errorMessage;const b=c?"print-task:cim-symbol-unsupported"===i?.name?t.exportWebMapCIMError:t.exportWebMapError:"";return C("calcite-list-item",{"aria-label":h,key:r,title:b},C("div",{class:M.exportedFile,"data-item":e,onclick:this._handleLinkClick,slot:"content"},C("div",null,C("div",{class:M.exportedFileLinkTitle},r),C("div",{class:M.exportedFileLinkDescription},p?t.generatingExport:b||(u?t.ready:t.linkReady))),d?C("calcite-icon",{"aria-label":`${r}. ${t.linkReady}`,icon:u?"download-to":"launch",key:`${r}-end-icon`,scale:"s",slot:"content-end"}):null),p?C("calcite-loader",{class:M.exportedFileLoader,inline:!0,key:`${r}-loader`,label:t.generatingExport,scale:"m",slot:"content-start"}):C("calcite-icon",{icon:A(e),key:`${r}-start-icon`,scale:"s",slot:"content-start"}),p?null:this.saveAsButtonCallback&&!c&&this._isFormatAllowedForSaving(e.extension)?C("calcite-action",{"aria-label":`${b}`,icon:"ellipsis",id:`${r}-popover-button`,key:`${r}-action`,slot:"actions-end",text:`${b}`},C("calcite-popover",{autoClose:!0,key:`${r}-popover`,label:"Popover",offsetDistance:1,overlayPositioning:"fixed",pointerDisabled:!0,referenceElement:`${r}-popover-button`,scale:"s"},C("calcite-list",null,e.portalItem?C("calcite-list-item",{label:t.openItem,onCalciteListItemSelect:()=>{const t=e.portalItem;if(!t||!t.itemPageUrl)return;const i=document.createElement("a");i.target="_blank",i.href=t.itemPageUrl,i.rel="noreferrer",i.click()}},C("calcite-icon",{icon:"launch2",key:`${r}-launch-icon`,scale:"s",slot:"content-start"})):C("calcite-list-item",{label:t.saveAs,onCalciteListItemSelect:async()=>{this.saveAsButtonCallback&&(l((()=>e.portalItem)).then((e=>{e.itemPageUrl&&this.scheduleRender()})),await this.saveAsButtonCallback(e))}},C("calcite-icon",{icon:"save",key:`${r}-save-icon`,scale:"s",slot:"content-start"})),C("calcite-list-item",{label:this.messagesCommon.delete,onCalciteListItemSelect:()=>this.exportedLinks.remove(e)},C("calcite-icon",{icon:"trash",key:`${r}-delete-icon`,scale:"s",slot:"content-start"}))))):C("calcite-action",{"aria-label":`${b}`,icon:"x",key:`${r}-action`,onclick:()=>{this.exportedLinks.remove(e)},slot:"actions-end",text:`${b}`}))}));return C("calcite-list",{filterEnabled:e?.length>10},i)}_isFormatAllowedForSaving(e){return!this.allowedFormatsForSaving||"all"===this.allowedFormatsForSaving||!(!e||!this.allowedFormatsForSaving.includes(e))}_toggleLayoutPanel(e){const t=e.target;this._toggleTab(t.getAttribute("data-tab-id"))}_toggleTab(e,t=!0){if(this._selectedTab=e,this._selectedTab===E.mapOnly)this.templateOptions.reset(),this.templateOptions.layout=I;else if(this._selectedTab===E.layout){const e=this._selectedTemplate??this.viewModel.defaultTemplate;e?this.viewModel.applyTemplate(e):this.templateOptions.reset()}t&&(this._activeTabFocusRequested=!0)}_handleLayoutPanelKeyDown(e){const{key:t}=e,i=e.target.getAttribute("data-tab-id");if(x(t))return this._toggleTab(i),e.preventDefault(),void e.stopPropagation();if("ArrowLeft"===t||"ArrowRight"===t){switch(i){case E.layout:this._toggleTab("ArrowLeft"===t?E.export:E.mapOnly);break;case E.mapOnly:this._toggleTab("ArrowLeft"===t?E.layout:E.export);break;case E.export:this._toggleTab("ArrowLeft"===t?E.mapOnly:E.layout)}e.preventDefault(),e.stopPropagation()}}};e([r()],D.prototype,"_showTemplates",void 0),e([r()],D.prototype,"_isValidSpatialReference",void 0),e([r()],D.prototype,"allowedFormats",null),e([r()],D.prototype,"allowedFormatsForSaving",void 0),e([r()],D.prototype,"allowedLayouts",null),e([r()],D.prototype,"browseTemplateButtonOnClick",void 0),e([r()],D.prototype,"error",null),e([r({type:$})],D.prototype,"exportedLinks",void 0),e([r()],D.prototype,"extraParameters",null),e([r()],D.prototype,"headerVisible",void 0),e([r()],D.prototype,"headingLevel",void 0),e([r()],D.prototype,"icon",null),e([r()],D.prototype,"includeDefaultTemplates",null),e([r()],D.prototype,"label",null),e([r(),k("esri/widgets/Print/t9n/Print")],D.prototype,"messages",void 0),e([r(),k("esri/t9n/common")],D.prototype,"messagesCommon",void 0),e([r(),k("esri/core/t9n/Units")],D.prototype,"messagesUnits",void 0),e([r({type:S})],D.prototype,"outSpatialReference",null),e([r()],D.prototype,"portal",null),e([r()],D.prototype,"saveExportEnabled",void 0),e([r()],D.prototype,"saveExportHidden",void 0),e([r()],D.prototype,"showPrintAreaEnabled",null),e([r()],D.prototype,"printServiceUrl",null),e([r()],D.prototype,"saveAsButtonCallback",void 0),e([r()],D.prototype,"templateCustomTextElements",null),e([r()],D.prototype,"templateOptions",null),e([r()],D.prototype,"view",null),e([r({type:v})],D.prototype,"viewModel",void 0),D=e([p("esri.widgets.Print")],D);const V=D;export{V 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 e from"../../../Color.js";import"../../../geometry.js";import"../../../symbols.js";import i from"../../../core/Evented.js";import r from"../../../core/Logger.js";import{rad2deg as s}from"../../../core/mathUtils.js";import{destroyMaybe as o}from"../../../core/maybe.js";import{when as n,watch as a}from"../../../core/reactiveUtils.js";import{convertUnit as l}from"../../../core/unitUtils.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as h}from"../../../core/accessorSupport/decorators/subclass.js";import{isLoadedOrLoadFor as p,project as d}from"../../../geometry/projection.js";import{getResolutionForScale as m}from"../../../geometry/support/scaleUtils.js";import{MeasuredGrid as g}from"../../../grids/MeasuredGrid.js";import{makeDehydratedPoint as u}from"../../../layers/graphics/dehydratedPoint.js";import{defaultUnitPropertyMetadata as v}from"../../../properties/defaultUnit.js";import{minimumPixelsPerStrideForDisplayWhenScalingOff as y}from"../../../views/2d/grid/constants.js";import{getScaleFactor as _,shouldUsePlanar as w,measureMetersPerUnitAtReferencePoint as f}from"../../../views/2d/grid/gridUtils.js";import{DrawGraphicTool2D as S}from"../../../views/2d/interactive/editingTools/draw/DrawGraphicTool2D.js";import"../../../views/2d/interactive/editingTools/ControlPointsTransformTool.js";import"../../../views/2d/interactive/editingTools/TransformTool.js";import"../../../views/2d/interactive/editingTools/MediaTransformToolsWrapper.js";import{gridPlacementGraphicSymbol as b}from"../../../views/interactive/snapping/snappingUtils.js";import P from"../../../views/overlay/CrosshairOverlayItem.js";import T from"../../../views/overlay/TextOverlayItem.js";import{degreeSymbol as j}from"../../CoordinateConversion/support/formatUtils.js";import{applyColorToGrid as C,gridRotationToDegrees as x}from"./gridUtils.js";import G from"../../../geometry/Point.js";import O from"../../../symbols/SimpleLineSymbol.js";import R from"../../../symbols/SimpleMarkerSymbol.js";const I=Symbol("grid-interactivity");let L=class extends i.EventedAccessor{constructor(t){super(t),this._drawGraphicTool=null,this._crosshairLabel=null,this._crosshairItem=null,this.snappingManager=null,this.snappingOptions=null,this.view=null,this.placementDisabled=!1,this._mostRecentlyShownGrid=null,this._sketchedVertexCount=0}initialize(){this.addHandles([n((()=>!this.displayEnabled),(()=>{this.interactivePlacementState=null})),a((()=>this.view?.viewpoint),(()=>{this._renderOverlays()})),a((()=>this.snappingOptions?.gridEnabled&&this.snappingOptions.enabled),(t=>{null!=t&&(this.trySetDisplayEnabled(t),!0===this.snappingOptions?.enabled&&(this.snappingEnabled=t))})),a((()=>this.view?.grid),((t,e)=>{this._mostRecentlyShownGrid=!t&&e?e:null}))])}destroy(){this._resetGridPlacementState(),this._crosshairItem&&(this.view?.overlay?.removeItem(this._crosshairItem),this._crosshairItem=o(this._crosshairItem)),this._crosshairLabel&&(this.view?.overlay?.removeItem(this._crosshairLabel),this._crosshairLabel=o(this._crosshairLabel))}get displayEnabled(){return!!this.view?.grid}get dynamicScaling(){return this.grid?.dynamicScaling??!1}set dynamicScaling(t){this.grid&&(this.grid.dynamicScaling=t)}get grid(){return this.view?.grid??this._mostRecentlyShownGrid}set gridColor(t){this._set("gridColor",t);const[e,i,r,s]=t.toArray();C(this.grid,[e,i,r,s/255])}get gridControlsEnabled(){return this.displayEnabled&&!this.interactivePlacementState}set interactivePlacementState(t){this._set("interactivePlacementState",t),this._resetGridPlacementState(),t&&this._startGridManipulation(t)}get majorLineInterval(){return this.grid?.majorLineInterval??10}set majorLineInterval(t){this.grid&&(this.grid.majorLineInterval=t<1?1:t>15?15:t)}get rotateWithMap(){return this.grid?.rotateWithMap??!1}set rotateWithMap(t){this.grid&&(this.grid.rotateWithMap=t)}get rotation(){return this.grid?.rotation??-180}set rotation(t){this.grid&&(this.grid.rotation=t)}get snappingEnabled(){return(this.grid&&this.snappingOptions?.gridEnabled)??!1}set snappingEnabled(t){const{snappingOptions:e}=this;e&&(e.gridEnabled=t)}get spacing(){return this.grid?.spacing??1}set spacing(t){this.grid&&t>0&&(this.grid.spacing=t)}get unit(){return this.grid?.units}set unit(t){this.grid&&(this.grid.units=t)}get gridOutOfScale(){return!this.dynamicScaling&&null!=this._pixelsPerStride&&this._pixelsPerStride<y}get effectiveSpacingAfterDynamicScaling(){return this.majorLineInterval<1||!this.dynamicScaling||!this.view||null==this._pixelsPerStride||!this.grid?.spacing?null:this.grid.spacing*_(this.majorLineInterval,this._pixelsPerStride,this.dynamicScaling)}get numericSpacingInputShouldBeVisible(){return!!this.view?.spatialReference&&w(this.view.spatialReference)}get _metersPerSRUnit(){if(!(this.view&&this.displayEnabled&&this.grid&&p(this.grid.center.spatialReference,this.view.spatialReference)))return null;const t=d(this.grid.center,this.view.spatialReference);return f(t)}get _pixelsPerStride(){if(!this.view?.scale||!this.displayEnabled||!this.grid||null==this._metersPerSRUnit)return null;const t=this.grid,{scale:e,spatialReference:i}=this.view;return l(t.spacing,t.units,"meters")/(this._metersPerSRUnit*m(e,i))}get _isPlacing(){if(!this._drawGraphicTool)return!1;const t=this.interactivePlacementState;return"place"===t||"interactive"===t&&0===this._sketchedVertexCount}get _isRotating(){if(!this._drawGraphicTool)return!1;const t=this.interactivePlacementState;return"rotate"===t||"interactive"===t&&1===this._sketchedVertexCount}get _isScaling(){if(!this._drawGraphicTool)return!1;return"interactive"===this.interactivePlacementState&&1===this._sketchedVertexCount}togglePlacementState(t){this.interactivePlacementState=this.interactivePlacementState===t?null:t}trySetDisplayEnabled(t){const{view:e}=this;if(e?.ready)if(!e.grid&&t)if(this._mostRecentlyShownGrid)e.grid=this._mostRecentlyShownGrid;else{const t="imperial"===this.defaultUnit?"feet":"meters";e.grid=new g({units:t,center:e.center??new G,rotateWithMap:!0}),C(this.grid,[115,115,115])}else t||(e.grid=null);else r.getLogger(this).warn("Attempting to enable grid display while view is not ready")}startPlacement(t){const{view:e,snappingManager:i}=this;if(!e)return;this._set("interactivePlacementState",t),this._sketchedVertexCount=0;const r=new S({view:e,graphicProperties:{attributes:{[b]:b}},sketchOptions:{tooltips:{enabled:!0,visibleElements:{direction:!1,rotation:!1,totalLength:!1,elevation:!1,distance:!1,area:!1}}},geometryType:"polyline",mode:"click",snapToScene:!1,snappingManager:i,forceUniformSize:!0,centered:!1,cursor:"interactive"===this.interactivePlacementState||"place"===this.interactivePlacementState?"none":null,regularVerticesSymbol:void 0,activeVertexSymbol:E,activeLineSymbol:k,graphicSymbol:k});this._drawGraphicTool=r,e.addAndActivateTool(r),this._renderOverlays(),this.addHandles([r.on("cursor-update",(t=>this._onCursorUpdate(t))),r.on("complete",(()=>this._onDrawComplete())),r.on("vertex-add",(e=>this._onVertexAdd(e,t)))],I)}async _startGridManipulation(t){const{view:e}=this;if(!e)return void(this.interactivePlacementState=null);const i=new CustomEvent("before-placement",{cancelable:!0});this.emit("before-placement",i),i.defaultPrevented||this.startPlacement(t)}_onCursorUpdate(t){try{if(this._isPlacing){const e=t.vertices[0].coordinates;return void this._handlePlace(e)}if(this._drawGraphicTool.cursor=null,this._isRotating&&this._handleRotate(t.vertices[0].coordinates),this._isScaling){const t=this._drawGraphicTool?.drawOperation.cursorVertex;this._handleScale(t)}}finally{this._renderOverlays()}}_onDrawComplete(){this._drawGraphicTool.cursor=null,this.interactivePlacementState=null}_onVertexAdd(t,e){const i=t.vertices[0].coordinates;this._isPlacing&&this._handlePlace(i),this._isRotating&&this._sketchedVertexCount>0&&this._handleRotate(i),this._isScaling&&this._sketchedVertexCount>0&&this._handleScale(u(i[0],i[1],void 0,this.view.spatialReference)),this._sketchedVertexCount++,this._drawGraphicTool.cursor=null,2!==this._sketchedVertexCount&&"interactive"===e||(this.interactivePlacementState=null),this._renderOverlays()}_handlePlace(t){const{grid:e,view:i}=this;e&&i&&(e.center=new G({x:t[0],y:t[1],spatialReference:i.spatialReference}))}_handleRotate(t){const{grid:e,view:i}=this;if(!e||!i)return;this._drawGraphicTool?.sketchOptions.tooltips.set("enabled",!1);const{x:r,y:o}=e.center,[n,a]=t,l=i.toScreen(e.center,{pickClosestTarget:!0}),c=l&&i.toMap(l),h=i.toScreen(u(n,a,void 0,i.spatialReference),{pickClosestTarget:!0}),p=h&&i.toMap(h),d=c?c.x:r,m=c?c.y:o,g=d-(p?p.x:n),v=m-(p?p.y:a);if(0===g&&0===v)return;const y=Math.atan2(v,g),_=s(y),w=e.rotateWithMap,f=i.viewpoint.rotation??0,S=w?_:_-f;e.rotation=Math.fround(S)%360}_handleScale(t){const{view:e,grid:i,_drawGraphicTool:r,interactivePlacementState:s,_metersPerSRUnit:o}=this;if(!(t&&e&&i&&r&&o))return;r.sketchOptions.tooltips.enabled=!1;const n="interactive"===s?i.center:r.drawOperation.firstVertex;if(!n||!t)return;const a=e?.toScreen(n),c=a&&e.toMap(a),h=e?.toScreen(t),p=c??n,d=(h&&e.toMap(h))??t,m=Math.sqrt((p.x-d.x)**2+(p.y-d.y)**2),g=l(m*o,"meters",i.units);this.spacing=g}_renderOverlays(){this._renderCrosshairOverlay(),this._renderTextOverlay()}_renderTextOverlay(){const{grid:t,view:e,_drawGraphicTool:i}=this,r=this._getCrosshairLabel();if(!(t&&e?.overlay&&i&&r))return;const s=e.toScreen(t.center,{pickClosestTarget:!0});s&&(r.position=[s.x+12,s.y+12]),this._isRotating?(r.text=`${x(t.rotation)}${j}`,r.visible=!0):r.visible=!1}_renderCrosshairOverlay(){const{grid:t,view:e,_drawGraphicTool:i}=this;if(!t||!e?.overlay||!i)return;const r=this._getCrosshair();if(!r)return;const s=e.toScreen(t.center);s&&(r.x=s.x,r.y=s.y,r.rotation=t.rotateWithMap?e.viewpoint.rotation-t.rotation:-t.rotation,r.visible=!!i)}_getCrosshairLabel(){if(this._crosshairLabel)return this._crosshairLabel;const{grid:t,view:i,_drawGraphicTool:r}=this;if(!t||!i?.overlay||!r)return null;const s=new T({anchor:"top-left",fontSize:10,textColor:new e([21,21,21]),backgroundColor:new e([248,248,248]),padding:8,borderRadius:20});return i.overlay.addItem(s),this._crosshairLabel=s,s}_getCrosshair(){const{_crosshairItem:t,view:e}=this;return e?.overlay?t&&e.overlay.items.includes(t)?t:(this._crosshairItem=new P({color:e.effectiveTheme.accentColor,thickness:4,length:36,visible:!0}),e.overlay?.addItem(this._crosshairItem),this._crosshairItem):null}_resetGridPlacementState(){this.removeHandles(I),this._crosshairItem&&(this._crosshairItem.visible=!1),this._crosshairLabel&&(this._crosshairLabel.visible=!1),this._drawGraphicTool&&(this.view?.activeTool===this._drawGraphicTool&&(this.view.activeTool=null),this.view?.tools.remove(this._drawGraphicTool)),this._drawGraphicTool=o(this._drawGraphicTool)}};t([c(v)],L.prototype,"defaultUnit",void 0),t([c({readOnly:!0})],L.prototype,"displayEnabled",null),t([c()],L.prototype,"dynamicScaling",null),t([c()],L.prototype,"grid",null),t([c()],L.prototype,"gridColor",null),t([c({readOnly:!0})],L.prototype,"gridControlsEnabled",null),t([c()],L.prototype,"interactivePlacementState",null),t([c()],L.prototype,"majorLineInterval",null),t([c()],L.prototype,"rotateWithMap",null),t([c()],L.prototype,"rotation",null),t([c()],L.prototype,"snappingEnabled",null),t([c()],L.prototype,"snappingManager",void 0),t([c()],L.prototype,"snappingOptions",void 0),t([c()],L.prototype,"spacing",null),t([c()],L.prototype,"unit",null),t([c()],L.prototype,"view",void 0),t([c({readOnly:!0})],L.prototype,"gridOutOfScale",null),t([c({readOnly:!0})],L.prototype,"effectiveSpacingAfterDynamicScaling",null),t([c({readOnly:!0})],L.prototype,"numericSpacingInputShouldBeVisible",null),t([c()],L.prototype,"placementDisabled",void 0),t([c()],L.prototype,"_metersPerSRUnit",null),t([c()],L.prototype,"_pixelsPerStride",null),t([c()],L.prototype,"_isPlacing",null),t([c()],L.prototype,"_isRotating",null),t([c()],L.prototype,"_isScaling",null),t([c()],L.prototype,"_mostRecentlyShownGrid",void 0),t([c()],L.prototype,"_sketchedVertexCount",void 0),L=t([h("esri.widgets.support.GridControls.GridControlsViewModel")],L);const M=L,k=new O({width:0}),E=new R({color:e.fromArray([0,0,0,0]),outline:new O({color:e.fromArray([0,0,0,0])})});export{M as default};
|
|
5
|
+
import{_ as t}from"../../../chunks/tslib.es6.js";import e from"../../../Color.js";import"../../../geometry.js";import"../../../symbols.js";import i from"../../../core/Evented.js";import r from"../../../core/Logger.js";import{rad2deg as s}from"../../../core/mathUtils.js";import{destroyMaybe as o}from"../../../core/maybe.js";import{when as n,watch as a}from"../../../core/reactiveUtils.js";import{convertUnit as l}from"../../../core/unitUtils.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as h}from"../../../core/accessorSupport/decorators/subclass.js";import{isLoadedOrLoadFor as d,project as p}from"../../../geometry/projection.js";import{getResolutionForScale as m}from"../../../geometry/support/scaleUtils.js";import{MeasuredGrid as g}from"../../../grids/MeasuredGrid.js";import{makeDehydratedPoint as u}from"../../../layers/graphics/dehydratedPoint.js";import{defaultUnitPropertyMetadata as v}from"../../../properties/defaultUnit.js";import{minimumPixelsPerStrideForDisplayWhenScalingOff as y}from"../../../views/2d/grid/constants.js";import{getScaleFactor as _,shouldUsePlanar as w,measureMetersPerUnitAtReferencePoint as f}from"../../../views/2d/grid/gridUtils.js";import{DrawGraphicTool2D as S}from"../../../views/2d/interactive/editingTools/draw/DrawGraphicTool2D.js";import"../../../views/2d/interactive/editingTools/ControlPointsTransformTool.js";import"../../../views/2d/interactive/editingTools/TransformTool.js";import"../../../views/2d/interactive/editingTools/MediaTransformToolsWrapper.js";import{gridPlacementGraphicSymbol as b}from"../../../views/interactive/snapping/snappingUtils.js";import P from"../../../views/overlay/CrosshairOverlayItem.js";import T from"../../../views/overlay/TextOverlayItem.js";import{degreeSymbol as j}from"../../CoordinateConversion/support/formatUtils.js";import{applyColorToGrid as C,gridRotationToDegrees as x}from"./gridUtils.js";import G from"../../../geometry/Point.js";import R from"../../../symbols/SimpleLineSymbol.js";import O from"../../../symbols/SimpleMarkerSymbol.js";const I=Symbol("grid-interactivity");let L=class extends i.EventedAccessor{constructor(t){super(t),this._drawGraphicTool=null,this._crosshairLabel=null,this._crosshairItem=null,this.snappingManager=null,this.snappingOptions=null,this.view=null,this.placementDisabled=!1,this._mostRecentlyShownGrid=null,this._sketchedVertexCount=0}initialize(){this.addHandles([n((()=>!this.displayEnabled),(()=>{this.interactivePlacementState=null})),a((()=>this.view?.viewpoint),(()=>{this._renderOverlays()})),a((()=>this.snappingOptions?.gridEnabled),(t=>{null!=t&&this.trySetDisplayEnabled(t)})),a((()=>this.view?.grid),((t,e)=>{this._mostRecentlyShownGrid=!t&&e?e:null}))])}destroy(){this._resetGridPlacementState(),this._crosshairItem&&(this.view?.overlay?.removeItem(this._crosshairItem),this._crosshairItem=o(this._crosshairItem)),this._crosshairLabel&&(this.view?.overlay?.removeItem(this._crosshairLabel),this._crosshairLabel=o(this._crosshairLabel))}get displayEnabled(){return!!this.view?.grid}get dynamicScaling(){return this.grid?.dynamicScaling??!1}set dynamicScaling(t){this.grid&&(this.grid.dynamicScaling=t)}get grid(){return this.view?.grid??this._mostRecentlyShownGrid}set gridColor(t){this._set("gridColor",t);const[e,i,r,s]=t.toArray();C(this.grid,[e,i,r,s/255])}get gridControlsEnabled(){return this.displayEnabled&&!this.interactivePlacementState}set interactivePlacementState(t){this._set("interactivePlacementState",t),this._resetGridPlacementState(),t&&this._startGridManipulation(t)}get majorLineInterval(){return this.grid?.majorLineInterval??10}set majorLineInterval(t){this.grid&&(this.grid.majorLineInterval=t<1?1:t>15?15:t)}get rotateWithMap(){return this.grid?.rotateWithMap??!1}set rotateWithMap(t){this.grid&&(this.grid.rotateWithMap=t)}get rotation(){return this.grid?.rotation??-180}set rotation(t){this.grid&&(this.grid.rotation=t)}get snappingEnabled(){return(this.grid&&this.snappingOptions?.gridEnabled)??!1}set snappingEnabled(t){const{snappingOptions:e}=this;e&&(e.gridEnabled=t)}get spacing(){return this.grid?.spacing??1}set spacing(t){this.grid&&t>0&&(this.grid.spacing=t)}get unit(){return this.grid?.units}set unit(t){this.grid&&(this.grid.units=t)}get gridOutOfScale(){return!this.dynamicScaling&&null!=this._pixelsPerStride&&this._pixelsPerStride<y}get effectiveSpacingAfterDynamicScaling(){return this.majorLineInterval<1||!this.dynamicScaling||!this.view||null==this._pixelsPerStride||!this.grid?.spacing?null:this.grid.spacing*_(this.majorLineInterval,this._pixelsPerStride,this.dynamicScaling)}get numericSpacingInputShouldBeVisible(){return!!this.view?.spatialReference&&w(this.view.spatialReference)}get _metersPerSRUnit(){if(!(this.view&&this.displayEnabled&&this.grid&&d(this.grid.center.spatialReference,this.view.spatialReference)))return null;const t=p(this.grid.center,this.view.spatialReference);return f(t)}get _pixelsPerStride(){if(!this.view?.scale||!this.displayEnabled||!this.grid||null==this._metersPerSRUnit)return null;const t=this.grid,{scale:e,spatialReference:i}=this.view;return l(t.spacing,t.units,"meters")/(this._metersPerSRUnit*m(e,i))}get _isPlacing(){if(!this._drawGraphicTool)return!1;const t=this.interactivePlacementState;return"place"===t||"interactive"===t&&0===this._sketchedVertexCount}get _isRotating(){if(!this._drawGraphicTool)return!1;const t=this.interactivePlacementState;return"rotate"===t||"interactive"===t&&1===this._sketchedVertexCount}get _isScaling(){if(!this._drawGraphicTool)return!1;return"interactive"===this.interactivePlacementState&&1===this._sketchedVertexCount}togglePlacementState(t){this.interactivePlacementState=this.interactivePlacementState===t?null:t}trySetDisplayEnabled(t){const{view:e}=this;if(e?.ready)if(!e.grid&&t)if(this._mostRecentlyShownGrid)e.grid=this._mostRecentlyShownGrid;else{const t="imperial"===this.defaultUnit?"feet":"meters";e.grid=new g({units:t,center:e.center??new G,rotateWithMap:!0}),C(this.grid,[115,115,115])}else t||(e.grid=null);else r.getLogger(this).warn("Attempting to enable grid display while view is not ready")}startPlacement(t){const{view:e,snappingManager:i}=this;if(!e)return;this._set("interactivePlacementState",t),this._sketchedVertexCount=0;const r=new S({view:e,graphicProperties:{attributes:{[b]:b}},sketchOptions:{tooltips:{enabled:!0,visibleElements:{direction:!1,rotation:!1,totalLength:!1,elevation:!1,distance:!1,area:!1}}},geometryType:"polyline",mode:"click",snapToScene:!1,snappingManager:i,forceUniformSize:!0,centered:!1,cursor:"interactive"===this.interactivePlacementState||"place"===this.interactivePlacementState?"none":null,regularVerticesSymbol:void 0,activeVertexSymbol:E,activeLineSymbol:k,graphicSymbol:k});this._drawGraphicTool=r,e.addAndActivateTool(r),this._renderOverlays(),this.addHandles([r.on("cursor-update",(t=>this._onCursorUpdate(t))),r.on("complete",(()=>this._onDrawComplete())),r.on("vertex-add",(e=>this._onVertexAdd(e,t)))],I)}async _startGridManipulation(t){const{view:e}=this;if(!e)return void(this.interactivePlacementState=null);const i=new CustomEvent("before-placement",{cancelable:!0});this.emit("before-placement",i),i.defaultPrevented||this.startPlacement(t)}_onCursorUpdate(t){try{if(this._isPlacing){const e=t.vertices[0].coordinates;return void this._handlePlace(e)}if(this._drawGraphicTool.cursor=null,this._isRotating&&this._handleRotate(t.vertices[0].coordinates),this._isScaling){const t=this._drawGraphicTool?.drawOperation.cursorVertex;this._handleScale(t)}}finally{this._renderOverlays()}}_onDrawComplete(){this._drawGraphicTool.cursor=null,this.interactivePlacementState=null}_onVertexAdd(t,e){const i=t.vertices[0].coordinates;this._isPlacing&&this._handlePlace(i),this._isRotating&&this._sketchedVertexCount>0&&this._handleRotate(i),this._isScaling&&this._sketchedVertexCount>0&&this._handleScale(u(i[0],i[1],void 0,this.view.spatialReference)),this._sketchedVertexCount++,this._drawGraphicTool.cursor=null,2!==this._sketchedVertexCount&&"interactive"===e||(this.interactivePlacementState=null),this._renderOverlays()}_handlePlace(t){const{grid:e,view:i}=this;e&&i&&(e.center=new G({x:t[0],y:t[1],spatialReference:i.spatialReference}))}_handleRotate(t){const{grid:e,view:i}=this;if(!e||!i)return;this._drawGraphicTool?.sketchOptions.tooltips.set("enabled",!1);const{x:r,y:o}=e.center,[n,a]=t,l=i.toScreen(e.center,{pickClosestTarget:!0}),c=l&&i.toMap(l),h=i.toScreen(u(n,a,void 0,i.spatialReference),{pickClosestTarget:!0}),d=h&&i.toMap(h),p=c?c.x:r,m=c?c.y:o,g=p-(d?d.x:n),v=m-(d?d.y:a);if(0===g&&0===v)return;const y=Math.atan2(v,g),_=s(y),w=e.rotateWithMap,f=i.viewpoint.rotation??0,S=w?_:_-f;e.rotation=Math.fround(S)%360}_handleScale(t){const{view:e,grid:i,_drawGraphicTool:r,interactivePlacementState:s,_metersPerSRUnit:o}=this;if(!(t&&e&&i&&r&&o))return;r.sketchOptions.tooltips.enabled=!1;const n="interactive"===s?i.center:r.drawOperation.firstVertex;if(!n||!t)return;const a=e?.toScreen(n),c=a&&e.toMap(a),h=e?.toScreen(t),d=c??n,p=(h&&e.toMap(h))??t,m=Math.sqrt((d.x-p.x)**2+(d.y-p.y)**2),g=l(m*o,"meters",i.units);this.spacing=g}_renderOverlays(){this._renderCrosshairOverlay(),this._renderTextOverlay()}_renderTextOverlay(){const{grid:t,view:e,_drawGraphicTool:i}=this,r=this._getCrosshairLabel();if(!(t&&e?.overlay&&i&&r))return;const s=e.toScreen(t.center,{pickClosestTarget:!0});s&&(r.position=[s.x+12,s.y+12]),this._isRotating?(r.text=`${x(t.rotation)}${j}`,r.visible=!0):r.visible=!1}_renderCrosshairOverlay(){const{grid:t,view:e,_drawGraphicTool:i}=this;if(!t||!e?.overlay||!i)return;const r=this._getCrosshair();if(!r)return;const s=e.toScreen(t.center);s&&(r.x=s.x,r.y=s.y,r.rotation=t.rotateWithMap?e.viewpoint.rotation-t.rotation:-t.rotation,r.visible=!!i)}_getCrosshairLabel(){if(this._crosshairLabel)return this._crosshairLabel;const{grid:t,view:i,_drawGraphicTool:r}=this;if(!t||!i?.overlay||!r)return null;const s=new T({anchor:"top-left",fontSize:10,textColor:new e([21,21,21]),backgroundColor:new e([248,248,248]),padding:8,borderRadius:20});return i.overlay.addItem(s),this._crosshairLabel=s,s}_getCrosshair(){const{_crosshairItem:t,view:e}=this;return e?.overlay?t&&e.overlay.items.includes(t)?t:(this._crosshairItem=new P({color:e.effectiveTheme.accentColor,thickness:4,length:36,visible:!0}),e.overlay?.addItem(this._crosshairItem),this._crosshairItem):null}_resetGridPlacementState(){this.removeHandles(I),this._crosshairItem&&(this._crosshairItem.visible=!1),this._crosshairLabel&&(this._crosshairLabel.visible=!1),this._drawGraphicTool&&(this.view?.activeTool===this._drawGraphicTool&&(this.view.activeTool=null),this.view?.tools.remove(this._drawGraphicTool)),this._drawGraphicTool=o(this._drawGraphicTool)}};t([c(v)],L.prototype,"defaultUnit",void 0),t([c({readOnly:!0})],L.prototype,"displayEnabled",null),t([c()],L.prototype,"dynamicScaling",null),t([c()],L.prototype,"grid",null),t([c()],L.prototype,"gridColor",null),t([c({readOnly:!0})],L.prototype,"gridControlsEnabled",null),t([c()],L.prototype,"interactivePlacementState",null),t([c()],L.prototype,"majorLineInterval",null),t([c()],L.prototype,"rotateWithMap",null),t([c()],L.prototype,"rotation",null),t([c()],L.prototype,"snappingEnabled",null),t([c()],L.prototype,"snappingManager",void 0),t([c()],L.prototype,"snappingOptions",void 0),t([c()],L.prototype,"spacing",null),t([c()],L.prototype,"unit",null),t([c()],L.prototype,"view",void 0),t([c({readOnly:!0})],L.prototype,"gridOutOfScale",null),t([c({readOnly:!0})],L.prototype,"effectiveSpacingAfterDynamicScaling",null),t([c({readOnly:!0})],L.prototype,"numericSpacingInputShouldBeVisible",null),t([c()],L.prototype,"placementDisabled",void 0),t([c()],L.prototype,"_metersPerSRUnit",null),t([c()],L.prototype,"_pixelsPerStride",null),t([c()],L.prototype,"_isPlacing",null),t([c()],L.prototype,"_isRotating",null),t([c()],L.prototype,"_isScaling",null),t([c()],L.prototype,"_mostRecentlyShownGrid",void 0),t([c()],L.prototype,"_sketchedVertexCount",void 0),L=t([h("esri.widgets.support.GridControls.GridControlsViewModel")],L);const M=L,k=new R({width:0}),E=new O({color:e.fromArray([0,0,0,0]),outline:new R({color:e.fromArray([0,0,0,0])})});export{M as default};
|