@arcgis/core 4.30.0-next.20240605 → 4.30.0-next.20240607
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/README.md +1 -1
- package/arcade/functions/centroid.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/0062b5fc83fc67d813e0.js +1 -0
- package/assets/esri/core/workers/chunks/{288fdc4a4746d6b81687.js → 4468c2c3b489782faa5c.js} +1 -1
- package/assets/esri/core/workers/chunks/6ad7b5817a9594689716.js +1 -0
- package/assets/esri/core/workers/chunks/733a117cb420316751b9.js +1 -0
- package/assets/esri/core/workers/chunks/888ad3cf5eaa472731be.js +1 -0
- package/assets/esri/core/workers/chunks/{342426c8a8c9f5f84811.js → b62e942e675d5770ea24.js} +1 -1
- package/assets/esri/core/workers/chunks/{4faf7055457c04dc9fc1.js → cd03ad7dc45fbbeb1a2f.js} +1 -1
- package/assets/esri/rest/knowledgeGraph/wasmInterface/arcgis-knowledge-client-core-simd.wasm +0 -0
- package/assets/esri/rest/knowledgeGraph/wasmInterface/arcgis-knowledge-client-core.wasm +0 -0
- package/assets/esri/themes/base/widgets/_BasemapLayerList.scss +8 -0
- package/assets/esri/themes/base/widgets/_CatalogLayerList.scss +8 -0
- package/assets/esri/themes/base/widgets/_LayerList.scss +8 -0
- package/assets/esri/themes/base/widgets/_Print.scss +12 -0
- package/assets/esri/themes/base/widgets/_TableList.scss +8 -0
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/interfaces.d.ts +140 -28
- package/layers/CatalogLayer.js +1 -1
- package/layers/knowledgeGraph/KnowledgeGraphSublayer.js +1 -1
- package/layers/support/Sublayer.js +1 -1
- package/layers/support/arcgisLayers.js +1 -1
- package/package.json +1 -1
- package/smartMapping/renderers/size.js +1 -1
- package/support/elevationInfoUtils.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/support/styleUtils.js +1 -1
- package/views/3d/analysis/Viewshed/FieldOfViewManipulation.js +1 -1
- package/views/3d/analysis/Viewshed/ScaleOrientManipulation.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedSubTool.js +1 -1
- package/views/3d/interactive/editingTools/manipulatorUtils.js +1 -1
- package/views/3d/interactive/editingTools/originGeometryVisualElementUtils.js +1 -1
- package/views/3d/layers/BuildingSceneLayerView3D.js +1 -1
- package/views/3d/layers/TiledLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
- package/views/3d/layers/support/FeatureTileVisibility3D.js +1 -1
- package/views/3d/state/NearFarHeuristic.js +1 -1
- package/views/3d/terrain/OverlayRenderer.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ElevationAgnosticBVH.js +1 -1
- package/views/3d/webgl-engine/effects/RenderPluginManager.js +1 -1
- package/views/3d/webgl-engine/lib/SortedRenderGeometryRenderer.js +1 -1
- package/webdoc/support/webdocSaveUtils.js +1 -1
- package/widgets/BasemapLayerList/css.js +1 -1
- package/widgets/BasemapLayerList.js +1 -1
- package/widgets/CatalogLayerList/css.js +1 -1
- package/widgets/CatalogLayerList.js +1 -1
- package/widgets/Feature/support/featureUtils.js +1 -1
- package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
- package/widgets/FeatureTable/FieldColumn.js +1 -1
- package/widgets/FeatureTable/Grid/Column.js +1 -1
- package/widgets/FeatureTable/Grid/GridViewModel.js +1 -1
- package/widgets/FeatureTable/RelationshipColumn.js +1 -1
- package/widgets/FeatureTable/support/FeatureStore.js +1 -1
- package/widgets/FeatureTable/support/tableUtils.js +1 -1
- package/widgets/FeatureTable.js +1 -1
- package/widgets/Features/FeaturesViewModel.js +1 -1
- package/widgets/LayerList/css.js +1 -1
- package/widgets/LayerList.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/PanoramicViewer/PanoramicViewerViewModel.js +1 -1
- package/widgets/Print/PrintViewModel.js +1 -1
- package/widgets/Print.js +1 -1
- package/widgets/TableList/css.js +1 -1
- package/widgets/TableList.js +1 -1
- package/widgets/support/legacyIcon.js +1 -1
- package/assets/esri/core/workers/chunks/9f2d8940da48c864b2ca.js +0 -1
- package/assets/esri/core/workers/chunks/d03ada1212b13e76bff4.js +0 -1
- package/assets/esri/core/workers/chunks/de4f0da054e8a798dfbf.js +0 -1
- package/assets/esri/core/workers/chunks/e21d72debf45c5a33520.js +0 -1
package/widgets/LayerList.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.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import t from"../core/Collection.js";import{deprecatedProperty as i}from"../core/deprecate.js";import{IdentifiableMixin as o}from"../core/Identifiable.js";import l from"../core/Logger.js";import s from"../core/ReactiveMap.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as a}from"../core/accessorSupport/decorators/subclass.js";import{getActionIcon as r,getActionStyles as c}from"../support/actions/actionUtils.js";import d from"./Widget.js";import{css as m}from"./LayerList/css.js";import p from"./LayerList/LayerListViewModel.js";import h from"./LayerList/LayerListVisibleElements.js";import g from"./LayerList/ListItem.js";import{minDragEnabledItems as u,minFilterItems as y,getItem as _,getLayerType as f,listItemHasChildren as v,areChildrenHidden as I,canSortSublayers as b,getStatusIcon as w,sortLayersToIds as L,sortChildLayersToIds as F,getVisibilityIcon as C}from"./LayerList/support/layerListUtils.js";import{loadCalciteComponents as E}from"./support/componentsUtils.js";import{globalCss as k}from"./support/globalCss.js";import"./support/widgetUtils.js";import{messageBundle as A}from"./support/decorators/messageBundle.js";import{vmEvent as M}from"./support/decorators/vmEvent.js";import{tsx as T}from"./support/jsxFactory.js";const G=t.ofType(g);let j=class extends(o(d)){constructor(e,t){super(e,t),this._activeItem=null,this._tooltipReferenceMap=new s,this._focusRootFlowItem=!1,this._focusPanelFlowItem=!1,this._focusKnowledgeGraphFlowItem=!1,this._focusCatalogFlowItem=!1,this._knowledgeGraphFlowItem=null,this._catalogFlowItem=null,this._lastDragDetail=null,this._selectedDragItemLayerUid=null,this._rootGroupUid=`operational-${this.uid}`,this.catalogLayerList=null,this.catalogOptions=null,this.collapsed=!1,this.dragEnabled=!1,this.filterPlaceholder="",this.filterText="",this.headingLevel=2,this.knowledgeGraphTableList=null,this.knowledgeGraphOptions=null,this.listItemCanGiveFunction=null,this.listItemCanReceiveFunction=null,this.messages=null,this.messagesCommon=null,this.minDragEnabledItems=u,this.minFilterItems=y,this.selectedItems=new G,this.selectionMode="none",this.viewModel=new p,this.visibilityAppearance="default",this.visibleElements=new h,this._canMove=({dragEl:e,fromEl:t,toEl:i},o)=>{const l="pull"===o?this.listItemCanGiveFunction:this.listItemCanReceiveFunction,s=_(e);if(!s?.sortable)return!1;const n=_(t),a=f(t),r=_(i),c=f(i),d=!!a&&!!c&&a===c,m={selected:s,from:n,to:r},p=t.group,h=i.group,g=n?.layer?.type??"",u=r?.layer?.type??"",y=new Set(["map-image","catalog","knowledge-graph"]),v="sublayer";return p&&h&&"function"==typeof l?l.call(null,m):d&&!y.has(g)&&!y.has(u)&&s?.layer?.type!==v},this._clearActiveItem=()=>{this._activeItem=null},this._setActiveItem=e=>{if("default"!==this.visibilityAppearance)return;const t=Array.from(e.composedPath()).find((e=>e.classList?.contains(m.item)));this._activeItem=_(t)},this._onCalciteListOrderChange=e=>{const{_lastDragDetail:t}=this,{toEl:i,fromEl:o,dragEl:l,newIndex:s}=e;if(o&&i&&!(t?.newIndex===s&&t?.dragEl===l&&t?.toEl===i&&t?.fromEl===o))if(this._lastDragDetail=e,o!==i)this._moveLayerFromChildList({toEl:i,fromEl:o,dragEl:l,newIndex:s});else{const e=Array.from(o.children).filter((e=>e?.matches("calcite-list-item"))).map((e=>e.value));this._sortLayers(o,e)}}}loadDependencies(){return E({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group.js"),"action-menu":()=>import("@esri/calcite-components/dist/components/calcite-action-menu.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow.js"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip.js")})}destroy(){this._destroyKnowledgeGraph(),this._tooltipReferenceMap.clear()}get _dragEnabled(){return this.viewModel.totalItems>=this.minDragEnabledItems&&this.dragEnabled}get _filterEnabled(){return this.viewModel.totalItems>=this.minFilterItems&&this.visibleElements.filter}get icon(){return"layers"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get listItemCreatedFunction(){return this.viewModel.listItemCreatedFunction}set listItemCreatedFunction(e){this.viewModel.listItemCreatedFunction=e}get multipleSelectionEnabled(){return i(l.getLogger(this),"multipleSelectionEnabled",{replacement:"selectionMode",version:"4.29",warnOnce:!0}),"multiple"===this.selectionMode}set multipleSelectionEnabled(e){i(l.getLogger(this),"multipleSelectionEnabled",{replacement:"selectionMode",version:"4.29",warnOnce:!0}),this.selectionMode=e?"multiple":this.selectionEnabled?"single":"none"}get operationalItems(){return this.viewModel.operationalItems}set operationalItems(e){this.viewModel.operationalItems=e}get selectionEnabled(){return i(l.getLogger(this),"selectionEnabled",{replacement:"selectionMode, dragEnabled",version:"4.29",warnOnce:!0}),"none"!==this.selectionMode&&this.dragEnabled}set selectionEnabled(e){i(l.getLogger(this),"selectionEnabled",{replacement:"selectionMode, dragEnabled",version:"4.29",warnOnce:!0}),this.dragEnabled=e,this.selectionMode=e?this.multipleSelectionEnabled?"multiple":"single":"none"}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}triggerAction(e,t){return this.viewModel.triggerAction(e,t)}render(){const e=this.viewModel?.state,t={[k.hidden]:"loading"===e,[k.disabled]:"disabled"===e},i=this.operationalItems?.filter((e=>!e.hidden&&(this.visibleElements.errors||!e.error)));return T("div",{class:this.classes(m.base,k.widget,k.panel,t)},i?.length?[this._renderItemTooltips(i),this._renderItems(i)]:this._renderNoItems())}_renderItemTooltip(e){const{_tooltipReferenceMap:t,messages:i}=this;return e?T("calcite-tooltip",{key:`tooltip-${e.layer.uid}`,referenceElement:t.get(e.layer.uid)},i.layerIncompatibleTooltip):null}_renderItemTooltipNodes(e){return e.incompatible?this._renderItemTooltip(e):e.children?.filter((e=>!e.hidden)).toArray().map((e=>this._renderItemTooltipNodes(e)))}_renderItemTooltips(e){return e?.toArray().map((e=>this._renderItemTooltipNodes(e)))}_renderNoItemsMessage(){return T("div",{slot:"message"},this.messages.noItemsToDisplay)}_renderNoItems(){return T("div",{class:m.itemMessage,key:"esri-layer-list__no-items"},T("calcite-notice",{icon:"information",kind:"info",open:!0,width:"full"},this._renderNoItemsMessage()))}_destroyCatalog(){this._catalogFlowItem=null,this._focusRootFlowItem=!0,this.catalogLayerList?.destroy(),this._set("catalogLayerList",null)}_destroyKnowledgeGraph(){this._knowledgeGraphFlowItem=null,this._focusRootFlowItem=!0,this.knowledgeGraphTableList?.destroy(),this._set("knowledgeGraphTableList",null)}async _createCatalog(){const{default:e}=await import("./CatalogLayerList.js"),{headingLevel:t,catalogOptions:i,view:o,filterPlaceholder:l,listItemCreatedFunction:s,minFilterItems:n,selectionMode:a,visibilityAppearance:r}=this,c=this._catalogFlowItem?.layer;this._set("catalogLayerList",new e({headingLevel:t,view:o,filterPlaceholder:l,listItemCreatedFunction:s,minFilterItems:n,selectionMode:a,visibilityAppearance:r,...i,catalogLayer:c}))}async _createKnowledgeGraph(){const{default:e}=await import("./TableList.js"),t=this._knowledgeGraphFlowItem?.layer;if("knowledge-graph"!==t?.type||!t.tables.length)return;const{headingLevel:i,knowledgeGraphOptions:o,selectionMode:l,dragEnabled:s}=this;this._set("knowledgeGraphTableList",new e({headingLevel:i,selectionMode:l,dragEnabled:s,...o,tables:t.tables}))}_renderCatalogFlowItem(){const{_catalogFlowItem:e,messages:t}=this;if(!e)return null;const i=this._getLayerTitle(e);return T("calcite-flow-item",{afterCreate:this._focusCatalogFlowItemNode,afterUpdate:this._focusCatalogFlowItemNode,bind:this,description:i,heading:t.catalogLayers,headingLevel:this.headingLevel,key:`flow-catalog-${e.uid}`,onCalciteFlowItemBack:e=>{e.preventDefault(),this._destroyCatalog()}},this.catalogLayerList?.render())}_renderKnowledgeGraphFlowItem(){const{_knowledgeGraphFlowItem:e,messages:t}=this;if(!e)return null;const i=this._getLayerTitle(e);return T("calcite-flow-item",{afterCreate:this._focusKnowledgeGraphFlowItemNode,afterUpdate:this._focusKnowledgeGraphFlowItemNode,bind:this,description:i,heading:t.tables,headingLevel:this.headingLevel,key:`flow-knowledge-graph-${e.uid}`,onCalciteFlowItemBack:e=>{e.preventDefault(),this._destroyKnowledgeGraph()}},this.knowledgeGraphTableList?.render())}_renderPanelFlowItems(e){return e?e.flatten((e=>e.children)).filter((({hidden:e,panel:t})=>!e&&t?.open&&!t.disabled&&t.flowEnabled)).toArray().map((({title:e,panel:t})=>{const i=()=>this._handlePanelFlowItemBack(t);return T("calcite-flow-item",{afterCreate:this._focusPanelFlowItemNode,afterUpdate:this._focusPanelFlowItemNode,bind:this,description:e,heading:t.title,headingLevel:this.headingLevel,key:`flow-panel-${t.uid}`,onCalciteFlowItemBack:e=>{e.preventDefault(),i()}},t.render(),T("calcite-button",{appearance:"transparent",onclick:i,slot:"footer-actions",width:"full"},this.messagesCommon.back))})):[]}_handlePanelFlowItemBack(e){e.open=!1,this._focusRootFlowItem=!0}_focusRootFlowItemNode(e){this._focusRootFlowItem&&(this._focusRootFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_focusCatalogFlowItemNode(e){this._focusCatalogFlowItem&&(this._focusCatalogFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_focusKnowledgeGraphFlowItemNode(e){this._focusKnowledgeGraphFlowItem&&(this._focusKnowledgeGraphFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_focusPanelFlowItemNode(e){this._focusPanelFlowItem&&(this._focusPanelFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_renderItems(e){const{visible:t,collapsed:i,_filterEnabled:o,_rootGroupUid:l,visibleElements:{closeButton:s,collapseButton:n,heading:a,flow:r},_dragEnabled:c,selectionMode:d,filterText:p,filterPlaceholder:h,messages:g}=this,u=[T("calcite-flow-item",{afterCreate:this._focusRootFlowItemNode,afterUpdate:this._focusRootFlowItemNode,bind:this,closable:s,closed:!t,collapsed:i,collapsible:n,heading:a?g.widgetLabel:void 0,headingLevel:this.headingLevel,key:"root-flow-item",onCalciteFlowItemClose:()=>this.visible=!1},T("calcite-list",{afterCreate:e=>{e.addEventListener("focusin",this._setActiveItem),e.addEventListener("focusout",this._clearActiveItem)},afterRemoved:e=>{e.removeEventListener("focusin",this._setActiveItem),e.removeEventListener("focusout",this._clearActiveItem)},canPull:e=>this._canMove(e,"pull"),canPut:e=>this._canMove(e,"put"),"data-layer-type":l,dragEnabled:c,filterEnabled:o,filterPlaceholder:h,filterText:o?p:"",group:l,key:"root-list",label:g.widgetLabel,onmouseleave:this._clearActiveItem,onmouseover:this._setActiveItem,selectionAppearance:"border",selectionMode:d,onCalciteListChange:e=>this._handleCalciteListChange(e),onCalciteListDragEnd:e=>this._handleCalciteListDragEnd(e.detail),onCalciteListFilter:e=>this.filterText=e.target?.filterText??"",onCalciteListOrderChange:e=>this._onCalciteListOrderChange(e.detail)},e?.toArray().map((e=>this._renderItem(e))),e?.length&&o?T("div",{class:m.filterNoResults,slot:"filter-no-results"},T("calcite-notice",{kind:"info",open:!0,width:"full"},this._renderNoItemsMessage())):null)),this._renderPanelFlowItems(e),this._renderKnowledgeGraphFlowItem(),this._renderCatalogFlowItem()];return t?r?T("calcite-flow",{key:"root-flow"},u):u:null}_renderChildList(e,t=[]){const{_dragEnabled:i,_rootGroupUid:o,viewModel:{listModeDisabled:l},messages:s,selectionMode:n}=this,{children:a}=e,r="catalog-dynamic-group"!==e.layer?.type&&v(e),c=!(!l&&I(e.layer))&&!r&&i&&"group"===e.layer?.type;return r||c?T("calcite-list",{canPull:e=>this._canMove(e,"pull"),canPut:e=>this._canMove(e,"put"),"data-item":e,"data-layer-type":o,dragEnabled:!!i&&(e.childrenSortable&&b(e)),group:`${o}-${e.layer.uid}`,key:`child-list-${e.layer.uid}`,selectionAppearance:"border",selectionMode:n},a?.filter((e=>!e.hidden)).toArray().map((i=>this._renderItem(i,e,[...t,e.title]))),"knowledge-graph"===e.layer?.type&&e.layer.tables?.length?T("calcite-list-item",{class:m.item,"data-layer-id":e.layer.id,dragDisabled:!0,key:`list-item-knowledge-graph-tables-${e.layer.uid}`,title:s.tables,onCalciteListItemSelect:()=>{this._knowledgeGraphFlowItem=e,this._focusKnowledgeGraphFlowItem=!0,this._createKnowledgeGraph()}},T("div",{class:m.itemContent,slot:"content"},s.tables),T("calcite-icon",{class:m.itemTableIcon,icon:"table",scale:"s",slot:"content-start"}),T("calcite-icon",{flipRtl:!0,icon:"chevron-right",scale:"s",slot:"content-end"})):null):null}_renderItemMessage(e){return e.error?T("div",{class:m.itemMessage,key:"esri-layer-list__error",slot:"content-bottom"},T("calcite-notice",{icon:"exclamation-mark-triangle",kind:"warning",open:!0,scale:"s",width:"full"},T("div",{slot:"message"},this.messages.layerError))):e.incompatible?T("div",{class:m.itemMessage,key:"esri-layer-list__incompatible",slot:"content-bottom"},T("calcite-notice",{afterCreate:t=>this._setTooltipReference(t,e),afterRemoved:()=>this._removeTooltipReference(e),bind:this,icon:"exclamation-mark-triangle",kind:"warning",open:!0,scale:"s",tabIndex:0,width:"full"},T("div",{slot:"message"},this.messages.layerIncompatible))):null}_getLayerTitle(e){return e.title||this.messages.untitledLayer}_renderItem(e,t,i){const{_activeItem:o,_selectedDragItemLayerUid:l,selectionMode:s,selectedItems:n,messages:a,visibleElements:r}=this,c=this._getLayerTitle(e),d=e.visibleAtCurrentTimeExtent?e.visibleAtCurrentScale?c:`${c} (${a.layerInvisibleAtScale})`:`${c} (${a.layerInvisibleAtTime})`,p=this._filterActions(e.actionsSections),h=this._countActions(p),g="catalog"===e.parent?.layer?.type,u="catalog-footprint"===e.layer?.type,y="catalog-dynamic-group"===e.layer?.type,_=u?T("calcite-icon",{class:m.itemCatalogIcon,icon:"footprint",key:"footprint",scale:"s",slot:"content-start"}):null,f=y?T("calcite-icon",{class:m.itemCatalogIcon,icon:"catalog-dataset",key:"catalog-dataset",scale:"s",slot:"content-start"}):null,v=r.catalogLayerList&&y?T("calcite-action",{appearance:"transparent",disabled:!e.layer.visible,icon:"chevron-right",iconFlipRtl:!0,onclick:()=>{this._catalogFlowItem=t,this._focusCatalogFlowItem=!0,this._createCatalog()},scale:"s",slot:"actions-end",text:c}):null;return T("calcite-list-item",{afterCreate:t=>this._focusSelectedDragEl(t,e),afterUpdate:t=>this._focusSelectedDragEl(t,e),class:this.classes(m.item,{[m.itemActive]:o===e}),"data-item":e,"data-layer-id":e.layer.id,dragDisabled:!e.sortable||g,dragSelected:e.layer.uid===l,id:e.layer.uid,key:`list-item-${e.layer.uid}`,label:c,metadata:{parentTitles:i,title:c},open:e.open,selected:"none"!==s&&n.includes(e),title:d,value:e.layer.uid,onCalciteListItemDragHandleChange:t=>this._handleCalciteListItemDragHandleChange(t,e),onCalciteListItemSelect:i=>this._handleCalciteListItemSelect(i,e,t),onCalciteListItemToggle:t=>this._handleCalciteListItemToggle(t,e)},_,f,T("div",{class:this.classes({[m.itemContent]:!0,[m.itemInvisible]:!e.visibleAtCurrentScale||!e.visibleAtCurrentTimeExtent}),slot:"content"},c),this._renderItemStatus(e,t),this._renderItemToggle(e,t),v,this._renderItemTemporaryIcon(e),this._renderChildList(e,i),this._renderItemMessage(e),this._renderPanel(e.panel),this._renderPanelAction(e.panel),h>1?this._renderActionsSections(e,p):1===h?this._renderAction({item:e,action:this._getSingleAction(p),textEnabled:!1}):null)}_renderItemStatus(e,t){const{visibleElements:i}=this;if(!i.statusIndicators)return null;const{connectionStatus:o,publishing:l,updating:s}=e,n=s&&!t,a=!!o;return T("calcite-icon",{class:this.classes({[m.statusIndicator]:!0,[m.publishing]:l,[m.updating]:n,[m.connectionStatus]:a,[m.connectionStatusConnected]:a&&"connected"===o}),icon:w({connectionStatus:o,publishing:l}),key:"layer-item-status",scale:"s",slot:"actions-end"})}_renderItemTemporaryIcon(e){return this.visibleElements.temporaryLayerIndicators&&"persistenceEnabled"in e.layer&&!e.layer.persistenceEnabled?T("calcite-icon",{class:m.itemTemporaryIcon,icon:"temporary",key:"temporary-icon",scale:"s",slot:"actions-start",title:this.messages.temporary}):null}_renderItemToggle(e,t){const{messages:i,visibilityAppearance:o}=this,{visible:l}=e,s=t?.visibilityMode;if("inherited"===s)return null;const n=C({visible:l,exclusive:"exclusive"===s,visibilityAppearance:o}),a="checkbox"===o,r=i.layerVisibility;return T("calcite-action",{appearance:"transparent",class:m.visibleToggle,icon:a?n:void 0,key:"visibility-toggle",onclick:()=>this._toggleVisibility(e,t),scale:"s",slot:a?"actions-start":"actions-end",text:r,title:r},a?null:T("calcite-icon",{class:this.classes({[m.visibleIcon]:"exclusive"!==s&&l}),icon:n,scale:"s"}))}_renderPanel(e){return!e?.open||e.disabled||e.flowEnabled?null:T("div",{class:m.itemContentBottom,key:`content-panel-${e.uid}`,slot:"content-bottom"},e.render())}_renderPanelAction(e){if(!e?.visible)return null;const{open:t,title:i,disabled:o}=e;return T("calcite-action",{active:t,appearance:"transparent",disabled:o,icon:r(e),key:`action-${e.uid}`,onclick:()=>this._togglePanel(e),scale:"s",slot:"actions-end",text:i??"",title:i??void 0},this._renderFallbackIcon(e))}_renderActionsSections(e,t){const i=this.messagesCommon.options;return T("calcite-action-menu",{appearance:"transparent",key:"item-action-menu",label:this.messagesCommon.menu,open:e.actionsOpen,overlayPositioning:"fixed",placement:"bottom-end",scale:"s",slot:"actions-end",onCalciteActionMenuOpen:t=>e.actionsOpen=t.target.open},T("calcite-action",{appearance:"transparent",icon:"ellipsis",scale:"s",slot:"trigger",text:i,title:i}),t.toArray().map(((t,i)=>this._renderActionSection(e,t,i))))}_renderActionSection(e,t,i){return T("calcite-action-group",{key:`action-section-${i}`},t.toArray().map((t=>this._renderAction({item:e,action:t,textEnabled:!0}))))}_renderFallbackIcon(e){const{className:t,icon:i}=e;if(i)return null;const o="image"in e?e.image:void 0,l={[m.itemActionIcon]:!!t,[m.itemActionImage]:!!o};return t&&(l[t]=!0),o||t?T("span",{"aria-hidden":"true",class:this.classes(m.itemActionIcon,l),key:"icon",styles:c(o)}):null}_renderAction(e){const{item:t,action:i,textEnabled:o}=e;if(!i)return null;const{active:l,disabled:s,title:n,type:a,indicator:c}=i;return T("calcite-action",{active:"toggle"===a&&i.value,appearance:"transparent",disabled:s,icon:r(i),indicator:c,key:`action-${i.uid}`,loading:l,onclick:()=>this._triggerAction(t,i),scale:"s",slot:o?void 0:"actions-end",text:n??"",textEnabled:o,title:n??void 0},this._renderFallbackIcon(i))}_setTooltipReference(e,t){this._tooltipReferenceMap.set(t.layer.uid,e)}_removeTooltipReference(e){this._tooltipReferenceMap.delete(e.layer.uid)}_moveLayerFromChildList({toEl:e,fromEl:t,dragEl:i,newIndex:o}){const l=_(i),s=_(e),n=_(t);this.viewModel.moveListItem(l,n,s,o)}_handleCalciteListDragEnd(e){const{fromEl:t,dragEl:i,oldIndex:o}=e;t.insertBefore(i,t.children[o])}_sortLayers(e,t){if(e)if(e.group===this._rootGroupUid)L(this.view?.map?.layers,t);else{const i=_(e);if(!i)return;F(i,t)}}_getSingleAction(e){return e.reduce((e=>e)).find((e=>e&&("button"===e.type||"toggle"===e.type)))}_filterActions(e){return e.map((e=>e.filter((e=>e.visible))))}_countActions(e){return e.reduce(((e,t)=>e+t.length),0)}_triggerAction(e,t){t&&e&&("toggle"===t.type&&(t.value=!t.value),this.triggerAction(t,e))}_handleCalciteListChange(e){const{selectionMode:t,selectedItems:i}=this;if("none"===t)return;const o=e.target.selectedItems.map((e=>_(e))).filter(Boolean);i.removeAll(),i.addMany(o)}_handleCalciteListItemToggle(e,t){e.stopPropagation(),t.open=e.target.open}_focusSelectedDragEl(e,t){this._selectedDragItemLayerUid===t.layer.uid&&requestAnimationFrame((()=>e?.setFocus()))}_handleCalciteListItemDragHandleChange(e,t){e.stopPropagation();const i=e.target.dragSelected;this._selectedDragItemLayerUid=i?t.layer.uid:null}_handleCalciteListItemSelect(e,t,i){_(e.target)===t&&"none"===this.selectionMode&&"inherited"!==i?.visibilityMode&&this._toggleVisibility(t,i)}_togglePanel(e){e.open=!e.open,e.open&&(this._focusPanelFlowItem=!0)}_toggleVisibility(e,t){if(!e)return;const i=t?.visibilityMode;"exclusive"===i&&e.visible||(e.visible=!e.visible)}};e([n()],j.prototype,"_activeItem",void 0),e([n()],j.prototype,"_tooltipReferenceMap",void 0),e([n()],j.prototype,"_focusRootFlowItem",void 0),e([n()],j.prototype,"_focusPanelFlowItem",void 0),e([n()],j.prototype,"_focusKnowledgeGraphFlowItem",void 0),e([n()],j.prototype,"_focusCatalogFlowItem",void 0),e([n()],j.prototype,"_dragEnabled",null),e([n()],j.prototype,"_filterEnabled",null),e([n()],j.prototype,"_knowledgeGraphFlowItem",void 0),e([n()],j.prototype,"_catalogFlowItem",void 0),e([n({readOnly:!0})],j.prototype,"catalogLayerList",void 0),e([n()],j.prototype,"catalogOptions",void 0),e([n()],j.prototype,"collapsed",void 0),e([n()],j.prototype,"dragEnabled",void 0),e([n()],j.prototype,"filterPlaceholder",void 0),e([n()],j.prototype,"filterText",void 0),e([n()],j.prototype,"headingLevel",void 0),e([n()],j.prototype,"icon",null),e([n({readOnly:!0})],j.prototype,"knowledgeGraphTableList",void 0),e([n()],j.prototype,"knowledgeGraphOptions",void 0),e([n()],j.prototype,"label",null),e([n()],j.prototype,"listItemCanGiveFunction",void 0),e([n()],j.prototype,"listItemCanReceiveFunction",void 0),e([n()],j.prototype,"listItemCreatedFunction",null),e([n(),A("esri/widgets/LayerList/t9n/LayerList")],j.prototype,"messages",void 0),e([n(),A("esri/t9n/common")],j.prototype,"messagesCommon",void 0),e([n()],j.prototype,"minDragEnabledItems",void 0),e([n()],j.prototype,"minFilterItems",void 0),e([n()],j.prototype,"multipleSelectionEnabled",null),e([n()],j.prototype,"operationalItems",null),e([n()],j.prototype,"selectionEnabled",null),e([n()],j.prototype,"selectedItems",void 0),e([n()],j.prototype,"selectionMode",void 0),e([n()],j.prototype,"view",null),e([M("trigger-action"),n({type:p})],j.prototype,"viewModel",void 0),e([n()],j.prototype,"visibilityAppearance",void 0),e([n({type:h,nonNullable:!0})],j.prototype,"visibleElements",void 0),j=e([a("esri.widgets.LayerList")],j);const S=j;export{S as default};
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import t from"../core/Collection.js";import{deprecatedProperty as i}from"../core/deprecate.js";import{IdentifiableMixin as o}from"../core/Identifiable.js";import s from"../core/Logger.js";import l from"../core/ReactiveMap.js";import{watch as a}from"../core/reactiveUtils.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import{getActionIcon as c,getActionStyles as d}from"../support/actions/actionUtils.js";import m from"./Widget.js";import{css as p}from"./LayerList/css.js";import h from"./LayerList/LayerListViewModel.js";import u from"./LayerList/LayerListVisibleElements.js";import g from"./LayerList/ListItem.js";import{minDragEnabledItems as y,minFilterItems as _,getItem as b,getLayerType as f,listItemHasChildren as v,areChildrenHidden as I,canSortSublayers as L,getStatusIcon as w,sortLayersToIds as C,sortChildLayersToIds as E,getVisibilityIcon as F}from"./LayerList/support/layerListUtils.js";import{loadCalciteComponents as T}from"./support/componentsUtils.js";import{globalCss as A}from"./support/globalCss.js";import"./support/widgetUtils.js";import{messageBundle as M}from"./support/decorators/messageBundle.js";import{vmEvent as k}from"./support/decorators/vmEvent.js";import{tsx as j}from"./support/jsxFactory.js";const S=t.ofType(g);let P=class extends(o(m)){constructor(e,t){super(e,t),this._activeItem=null,this._tooltipReferenceMap=new l,this._focusRootFlowItem=!1,this._focusPanelFlowItem=!1,this._focusTableListFlowItem=!1,this._focusCatalogFlowItem=!1,this._lastDragDetail=null,this._selectedDragItemLayerUid=null,this._rootGroupUid=`operational-${this.uid}`,this.catalogLayerList=null,this.catalogOptions=null,this.collapsed=!1,this.dragEnabled=!1,this.filterPlaceholder="",this.filterText="",this.headingLevel=2,this.tableList=null,this.knowledgeGraphOptions=null,this.listItemCanGiveFunction=null,this.listItemCanReceiveFunction=null,this.messages=null,this.messagesCommon=null,this.minDragEnabledItems=y,this.minFilterItems=_,this.openCatalogItem=null,this.openTableListItem=null,this.selectedItems=new S,this.selectionMode="none",this.viewModel=new h,this.visibilityAppearance="default",this.visibleElements=new u,this._canMove=({dragEl:e,fromEl:t,toEl:i},o)=>{const s="pull"===o?this.listItemCanGiveFunction:this.listItemCanReceiveFunction,l=b(e);if(!l?.sortable)return!1;const a=b(t),n=f(t),r=b(i),c=f(i),d=!!n&&!!c&&n===c,m={selected:l,from:a,to:r},p=t.group,h=i.group,u=a?.layer?.type??"",g=r?.layer?.type??"",y=new Set(["map-image","catalog","knowledge-graph"]),_="sublayer";return p&&h&&"function"==typeof s?s.call(null,m):d&&!y.has(u)&&!y.has(g)&&l?.layer?.type!==_},this._clearActiveItem=()=>{this._activeItem=null},this._setActiveItem=e=>{if("default"!==this.visibilityAppearance)return;const t=Array.from(e.composedPath()).find((e=>e.classList?.contains(p.item)));this._activeItem=b(t)},this._onCalciteListOrderChange=e=>{const{_lastDragDetail:t}=this,{toEl:i,fromEl:o,dragEl:s,newIndex:l}=e;if(o&&i&&!(t?.newIndex===l&&t?.dragEl===s&&t?.toEl===i&&t?.fromEl===o))if(this._lastDragDetail=e,o!==i)this._moveLayerFromChildList({toEl:i,fromEl:o,dragEl:s,newIndex:l});else{const e=Array.from(o.children).filter((e=>e?.matches("calcite-list-item"))).map((e=>e.value));this._sortLayers(o,e)}}}initialize(){this.addHandles([a((()=>this.openCatalogItem),(e=>e?this._createCatalog():this._destroyCatalog())),a((()=>this.openTableListItem),(e=>e?this._createTableList():this._destroyTableList()))])}loadDependencies(){return T({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group.js"),"action-menu":()=>import("@esri/calcite-components/dist/components/calcite-action-menu.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow.js"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip.js")})}destroy(){this._destroyTableList(),this._tooltipReferenceMap.clear()}get _totalItems(){return this.viewModel.operationalItems.flatten((e=>e.children.filter((e=>"catalog-dynamic-group"!==e.layer.type)))).length}get _dragEnabled(){return this._totalItems>=this.minDragEnabledItems&&this.dragEnabled}get _filterEnabled(){return this._totalItems>=this.minFilterItems&&this.visibleElements.filter}get icon(){return"layers"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get listItemCreatedFunction(){return this.viewModel.listItemCreatedFunction}set listItemCreatedFunction(e){this.viewModel.listItemCreatedFunction=e}get multipleSelectionEnabled(){return i(s.getLogger(this),"multipleSelectionEnabled",{replacement:"selectionMode",version:"4.29",warnOnce:!0}),"multiple"===this.selectionMode}set multipleSelectionEnabled(e){i(s.getLogger(this),"multipleSelectionEnabled",{replacement:"selectionMode",version:"4.29",warnOnce:!0}),this.selectionMode=e?"multiple":this.selectionEnabled?"single":"none"}get operationalItems(){return this.viewModel.operationalItems}set operationalItems(e){this.viewModel.operationalItems=e}get selectionEnabled(){return i(s.getLogger(this),"selectionEnabled",{replacement:"selectionMode, dragEnabled",version:"4.29",warnOnce:!0}),"none"!==this.selectionMode&&this.dragEnabled}set selectionEnabled(e){i(s.getLogger(this),"selectionEnabled",{replacement:"selectionMode, dragEnabled",version:"4.29",warnOnce:!0}),this.dragEnabled=e,this.selectionMode=e?this.multipleSelectionEnabled?"multiple":"single":"none"}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}triggerAction(e,t){return this.viewModel.triggerAction(e,t)}render(){const e=this.viewModel?.state,t={[A.hidden]:"loading"===e,[A.disabled]:"disabled"===e},i=this.operationalItems?.filter((e=>!e.hidden&&(this.visibleElements.errors||!e.error)));return j("div",{class:this.classes(p.base,A.widget,A.panel,t)},i?.length?[this._renderItemTooltips(i),this._renderItems(i)]:this._renderNoItems())}_renderItemTooltip(e){const{_tooltipReferenceMap:t,messages:i}=this;return e?j("calcite-tooltip",{key:`tooltip-${e.layer.uid}`,referenceElement:t.get(e.layer.uid)},i.layerIncompatibleTooltip):null}_renderItemTooltipNodes(e){return e.incompatible?this._renderItemTooltip(e):e.children?.filter((e=>!e.hidden)).toArray().map((e=>this._renderItemTooltipNodes(e)))}_renderItemTooltips(e){return e?.toArray().map((e=>this._renderItemTooltipNodes(e)))}_renderNoItemsMessage(){return j("div",{slot:"message"},this.messages.noItemsToDisplay)}_renderNoItems(){return j("div",{class:p.itemMessage,key:"esri-layer-list__no-items"},j("calcite-notice",{icon:"information",kind:"info",open:!0,width:"full"},this._renderNoItemsMessage()))}_destroyCatalog(){this.catalogLayerList?.destroy(),this._set("catalogLayerList",null)}_destroyTableList(){this.tableList?.destroy(),this._set("tableList",null)}async _createCatalog(){this._destroyCatalog();const{default:e}=await import("./CatalogLayerList.js"),{headingLevel:t,catalogOptions:i,view:o,filterPlaceholder:s,listItemCreatedFunction:l,minFilterItems:a,selectionMode:n,visibilityAppearance:r}=this,c=this.openCatalogItem?.layer;this._set("catalogLayerList",new e({headingLevel:t,view:o,filterPlaceholder:s,listItemCreatedFunction:l,minFilterItems:a,selectionMode:n,visibilityAppearance:r,...i,catalogLayer:c}))}_getTableListParams(e){const t=e?.layer;return"knowledge-graph"===t?.type?{...this.knowledgeGraphOptions,tables:t?.tables}:null}async _createTableList(){this._destroyTableList();const{default:e}=await import("./TableList.js"),t=this._getTableListParams(this.openTableListItem);if(!t?.tables?.length)return;const{headingLevel:i,selectionMode:o,dragEnabled:s}=this;this._set("tableList",new e({headingLevel:i,selectionMode:o,dragEnabled:s,...t}))}_renderCatalogFlowItem(){const{openCatalogItem:e,messages:t}=this;if(!e)return null;const i=this._getLayerTitle(e);return j("calcite-flow-item",{afterCreate:this._focusCatalogFlowItemNode,afterUpdate:this._focusCatalogFlowItemNode,bind:this,description:i,heading:t.catalogLayers,headingLevel:this.headingLevel,key:`flow-catalog-${e.uid}`,onCalciteFlowItemBack:e=>{e.preventDefault(),this.openCatalogItem=null,this._focusRootFlowItem=!0}},this.catalogLayerList?.render())}_renderTableListFlowItem(){const{openTableListItem:e,messages:t}=this;if(!e)return null;const i=this._getLayerTitle(e);return j("calcite-flow-item",{afterCreate:this._focusTableListFlowItemNode,afterUpdate:this._focusTableListFlowItemNode,bind:this,description:i,heading:t.tables,headingLevel:this.headingLevel,key:`flow-table-list-${e.uid}`,onCalciteFlowItemBack:e=>{e.preventDefault(),this.openTableListItem=null,this._focusRootFlowItem=!0}},this.tableList?.render())}_renderPanelFlowItems(e){return e?e.flatten((e=>e.children)).filter((({hidden:e,panel:t})=>!e&&t?.open&&!t.disabled&&t.flowEnabled)).toArray().map((({title:e,panel:t})=>{const i=()=>this._handlePanelFlowItemBack(t);return j("calcite-flow-item",{afterCreate:this._focusPanelFlowItemNode,afterUpdate:this._focusPanelFlowItemNode,bind:this,description:e,heading:t.title,headingLevel:this.headingLevel,key:`flow-panel-${t.uid}`,onCalciteFlowItemBack:e=>{e.preventDefault(),i()}},t.render(),j("calcite-button",{appearance:"transparent",onclick:i,slot:"footer-actions",width:"full"},this.messagesCommon.back))})):[]}_handlePanelFlowItemBack(e){e.open=!1,this._focusRootFlowItem=!0}_focusRootFlowItemNode(e){this._focusRootFlowItem&&(this._focusRootFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_focusCatalogFlowItemNode(e){this._focusCatalogFlowItem&&(this._focusCatalogFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_focusTableListFlowItemNode(e){this._focusTableListFlowItem&&(this._focusTableListFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_focusPanelFlowItemNode(e){this._focusPanelFlowItem&&(this._focusPanelFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_renderItems(e){const{visible:t,collapsed:i,_filterEnabled:o,_rootGroupUid:s,visibleElements:{closeButton:l,collapseButton:a,heading:n,flow:r},_dragEnabled:c,selectionMode:d,filterText:m,filterPlaceholder:h,messages:u}=this,g=[j("calcite-flow-item",{afterCreate:this._focusRootFlowItemNode,afterUpdate:this._focusRootFlowItemNode,bind:this,closable:l,closed:!t,collapsed:i,collapsible:a,heading:n?u.widgetLabel:void 0,headingLevel:this.headingLevel,key:"root-flow-item",onCalciteFlowItemClose:()=>this.visible=!1},j("calcite-list",{afterCreate:e=>{e.addEventListener("focusin",this._setActiveItem),e.addEventListener("focusout",this._clearActiveItem)},afterRemoved:e=>{e.removeEventListener("focusin",this._setActiveItem),e.removeEventListener("focusout",this._clearActiveItem)},canPull:e=>this._canMove(e,"pull"),canPut:e=>this._canMove(e,"put"),"data-layer-type":s,dragEnabled:c,filterEnabled:o,filterPlaceholder:h,filterText:o?m:"",group:s,key:"root-list",label:u.widgetLabel,onmouseleave:this._clearActiveItem,onmouseover:this._setActiveItem,selectionAppearance:"border",selectionMode:d,onCalciteListChange:e=>this._handleCalciteListChange(e),onCalciteListDragEnd:e=>this._handleCalciteListDragEnd(e.detail),onCalciteListFilter:e=>this.filterText=e.target?.filterText??"",onCalciteListOrderChange:e=>this._onCalciteListOrderChange(e.detail)},e?.toArray().map((e=>this._renderItem(e))),e?.length&&o?j("div",{class:p.filterNoResults,slot:"filter-no-results"},j("calcite-notice",{kind:"info",open:!0,width:"full"},this._renderNoItemsMessage())):null)),this._renderPanelFlowItems(e),this._renderTableListFlowItem(),this._renderCatalogFlowItem()];return t?r?j("calcite-flow",{key:"root-flow"},g):g:null}_renderChildList(e,t=[]){const{_dragEnabled:i,_rootGroupUid:o,viewModel:{listModeDisabled:s},messages:l,selectionMode:a}=this,{children:n}=e,r="catalog-dynamic-group"!==e.layer?.type&&v(e),c=!(!s&&I(e.layer))&&!r&&i&&"group"===e.layer?.type;return r||c?j("calcite-list",{canPull:e=>this._canMove(e,"pull"),canPut:e=>this._canMove(e,"put"),"data-item":e,"data-layer-type":o,dragEnabled:!!i&&(e.childrenSortable&&L(e)),group:`${o}-${e.layer.uid}`,key:`child-list-${e.layer.uid}`,selectionAppearance:"border",selectionMode:a},n?.filter((e=>!e.hidden)).toArray().map((i=>this._renderItem(i,e,[...t,e.title]))),this._getTableListParams(e)?.tables?.length?j("calcite-list-item",{class:p.item,"data-layer-id":e.layer.id,dragDisabled:!0,key:`list-item-table-list-tables-${e.layer.uid}`,title:l.tables,onCalciteListItemSelect:()=>{this.openTableListItem=e,this._focusTableListFlowItem=!0}},j("div",{class:p.itemContent,slot:"content"},l.tables),j("calcite-icon",{class:p.itemTableIcon,icon:"table",scale:"s",slot:"content-start"}),j("calcite-icon",{flipRtl:!0,icon:"chevron-right",scale:"s",slot:"content-end"})):null):null}_renderItemMessage(e){return e.error?j("div",{class:p.itemMessage,key:"esri-layer-list__error",slot:"content-bottom"},j("calcite-notice",{icon:"exclamation-mark-triangle",kind:"warning",open:!0,scale:"s",width:"full"},j("div",{slot:"message"},this.messages.layerError))):e.incompatible?j("div",{class:p.itemMessage,key:"esri-layer-list__incompatible",slot:"content-bottom"},j("calcite-notice",{afterCreate:t=>this._setTooltipReference(t,e),afterRemoved:()=>this._removeTooltipReference(e),bind:this,icon:"exclamation-mark-triangle",kind:"warning",open:!0,scale:"s",tabIndex:0,width:"full"},j("div",{slot:"message"},this.messages.layerIncompatible))):null}_getLayerTitle(e){return e.title||this.messages.untitledLayer}_renderItem(e,t,i){const{_activeItem:o,_selectedDragItemLayerUid:s,selectionMode:l,selectedItems:a,messages:n,visibleElements:r}=this,c=this._getLayerTitle(e),d=e.visibleAtCurrentTimeExtent?e.visibleAtCurrentScale?c:`${c} (${n.layerInvisibleAtScale})`:`${c} (${n.layerInvisibleAtTime})`,m=this._filterActions(e.actionsSections),h=this._countActions(m),u="catalog"===e.parent?.layer?.type,g="catalog-footprint"===e.layer?.type,y="catalog-dynamic-group"===e.layer?.type,_=g?j("calcite-icon",{class:p.itemCatalogIcon,icon:"footprint",key:"footprint",scale:"s",slot:"content-start"}):null,b=y?j("calcite-icon",{class:p.itemCatalogIcon,icon:"catalog-dataset",key:"catalog-dataset",scale:"s",slot:"content-start"}):null,f=r.catalogLayerList&&y?j("calcite-action",{appearance:"transparent",disabled:!e.layer.visible,icon:"chevron-right",iconFlipRtl:!0,onclick:()=>{this.openCatalogItem=t,this._focusCatalogFlowItem=!0},scale:"s",slot:"actions-end",text:c}):null;return j("calcite-list-item",{afterCreate:t=>this._focusSelectedDragEl(t,e),afterUpdate:t=>this._focusSelectedDragEl(t,e),class:this.classes(p.item,{[p.itemActive]:o===e}),"data-item":e,"data-layer-id":e.layer.id,dragDisabled:!e.sortable||u,dragSelected:e.layer.uid===s,id:e.layer.uid,key:`list-item-${e.layer.uid}`,label:c,metadata:{parentTitles:i,title:c},open:e.open,selected:"none"!==l&&a.includes(e),title:d,value:e.layer.uid,onCalciteListItemDragHandleChange:t=>this._handleCalciteListItemDragHandleChange(t,e),onCalciteListItemSelect:i=>this._handleCalciteListItemSelect(i,e,t),onCalciteListItemToggle:t=>this._handleCalciteListItemToggle(t,e)},_,b,j("div",{class:this.classes({[p.itemContent]:!0,[p.itemInvisible]:!e.visibleAtCurrentScale||!e.visibleAtCurrentTimeExtent}),slot:"content"},c),this._renderItemStatus(e,t),this._renderItemToggle(e,t),f,this._renderItemTemporaryIcon(e),this._renderChildList(e,i),this._renderItemMessage(e),this._renderPanel(e.panel),this._renderPanelAction(e.panel),h>1?this._renderActionsSections(e,m):1===h?this._renderAction({item:e,action:this._getSingleAction(m),textEnabled:!1}):null)}_renderItemStatus(e,t){const{visibleElements:i}=this;if(!i.statusIndicators)return null;const{connectionStatus:o,publishing:s,updating:l}=e,a=l&&!t,n=!!o;return j("calcite-icon",{class:this.classes({[p.statusIndicator]:!0,[p.publishing]:s,[p.updating]:a,[p.connectionStatus]:n,[p.connectionStatusConnected]:n&&"connected"===o}),icon:w({connectionStatus:o,publishing:s}),key:"layer-item-status",scale:"s",slot:"actions-end"})}_renderItemTemporaryIcon(e){return this.visibleElements.temporaryLayerIndicators&&"persistenceEnabled"in e.layer&&!e.layer.persistenceEnabled?j("calcite-icon",{class:p.itemTemporaryIcon,icon:"temporary",key:"temporary-icon",scale:"s",slot:"actions-start",title:this.messages.temporary}):null}_renderItemToggle(e,t){const{messages:i,visibilityAppearance:o}=this,{visible:s}=e,l=t?.visibilityMode;if("inherited"===l)return null;const a=F({visible:s,exclusive:"exclusive"===l,visibilityAppearance:o}),n="checkbox"===o,r=i.layerVisibility;return j("calcite-action",{appearance:"transparent",class:p.visibleToggle,icon:n?a:void 0,key:"visibility-toggle",onclick:()=>this._toggleVisibility(e,t),scale:"s",slot:n?"actions-start":"actions-end",text:r,title:r},n?null:j("calcite-icon",{class:this.classes({[p.visibleIcon]:"exclusive"!==l&&s}),icon:a,scale:"s"}))}_renderPanel(e){return!e?.open||e.disabled||e.flowEnabled?null:j("div",{class:p.itemContentBottom,key:`content-panel-${e.uid}`,slot:"content-bottom"},e.render())}_renderPanelAction(e){if(!e?.visible)return null;const{open:t,title:i,disabled:o}=e;return j("calcite-action",{active:t,appearance:"transparent",disabled:o,icon:c(e),key:`action-${e.uid}`,onclick:()=>this._togglePanel(e),scale:"s",slot:"actions-end",text:i??"",title:i??void 0},this._renderFallbackIcon(e))}_renderActionsSections(e,t){const i=this.messagesCommon.options;return j("calcite-action-menu",{appearance:"transparent",class:p.actionMenu,key:"item-action-menu",label:this.messagesCommon.menu,open:e.actionsOpen,overlayPositioning:"fixed",placement:"bottom-end",scale:"s",slot:"actions-end",onCalciteActionMenuOpen:t=>e.actionsOpen=t.target.open},j("calcite-action",{appearance:"transparent",icon:"ellipsis",scale:"s",slot:"trigger",text:i,title:i}),t.toArray().map(((t,i)=>this._renderActionSection(e,t,i))))}_renderActionSection(e,t,i){return j("calcite-action-group",{class:p.actionGroup,key:`action-section-${i}`},t.toArray().map((t=>this._renderAction({item:e,action:t,textEnabled:!0}))))}_renderFallbackIcon(e){const{className:t,icon:i}=e;if(i)return null;const o="image"in e?e.image:void 0,s={[p.itemActionIcon]:!!t,[p.itemActionImage]:!!o};return t&&(s[t]=!0),o||t?j("span",{"aria-hidden":"true",class:this.classes(p.itemActionIcon,s),key:"icon",styles:d(o)}):null}_renderAction(e){const{item:t,action:i,textEnabled:o}=e;if(!i)return null;const{active:s,disabled:l,title:a,type:n,indicator:r}=i;return j("calcite-action",{active:"toggle"===n&&i.value,appearance:"transparent",disabled:l,icon:c(i),indicator:r,key:`action-${i.uid}`,loading:s,onclick:()=>this._triggerAction(t,i),scale:"s",slot:o?void 0:"actions-end",text:a??"",textEnabled:o,title:a??void 0},this._renderFallbackIcon(i))}_setTooltipReference(e,t){this._tooltipReferenceMap.set(t.layer.uid,e)}_removeTooltipReference(e){this._tooltipReferenceMap.delete(e.layer.uid)}_moveLayerFromChildList({toEl:e,fromEl:t,dragEl:i,newIndex:o}){const s=b(i),l=b(e),a=b(t);this.viewModel.moveListItem(s,a,l,o)}_handleCalciteListDragEnd(e){const{fromEl:t,dragEl:i,oldIndex:o}=e;t.insertBefore(i,t.children[o])}_sortLayers(e,t){if(e)if(e.group===this._rootGroupUid)C(this.view?.map?.layers,t);else{const i=b(e);if(!i)return;E(i,t)}}_getSingleAction(e){return e.reduce((e=>e)).find((e=>e&&("button"===e.type||"toggle"===e.type)))}_filterActions(e){return e.map((e=>e.filter((e=>e.visible))))}_countActions(e){return e.reduce(((e,t)=>e+t.length),0)}_triggerAction(e,t){t&&e&&("toggle"===t.type&&(t.value=!t.value),this.triggerAction(t,e))}_handleCalciteListChange(e){const{selectionMode:t,selectedItems:i}=this;if("none"===t)return;const o=e.target.selectedItems.map((e=>b(e))).filter(Boolean);i.removeAll(),i.addMany(o)}_handleCalciteListItemToggle(e,t){e.stopPropagation(),t.open=e.target.open}_focusSelectedDragEl(e,t){this._selectedDragItemLayerUid===t.layer.uid&&requestAnimationFrame((()=>e?.setFocus()))}_handleCalciteListItemDragHandleChange(e,t){e.stopPropagation();const i=e.target.dragSelected;this._selectedDragItemLayerUid=i?t.layer.uid:null}_handleCalciteListItemSelect(e,t,i){b(e.target)===t&&"none"===this.selectionMode&&"inherited"!==i?.visibilityMode&&this._toggleVisibility(t,i)}_togglePanel(e){e.open=!e.open,e.open&&(this._focusPanelFlowItem=!0)}_toggleVisibility(e,t){if(!e)return;const i=t?.visibilityMode;"exclusive"===i&&e.visible||(e.visible=!e.visible)}};e([n()],P.prototype,"_activeItem",void 0),e([n()],P.prototype,"_tooltipReferenceMap",void 0),e([n()],P.prototype,"_focusRootFlowItem",void 0),e([n()],P.prototype,"_focusPanelFlowItem",void 0),e([n()],P.prototype,"_focusTableListFlowItem",void 0),e([n()],P.prototype,"_focusCatalogFlowItem",void 0),e([n()],P.prototype,"_totalItems",null),e([n()],P.prototype,"_dragEnabled",null),e([n()],P.prototype,"_filterEnabled",null),e([n({readOnly:!0})],P.prototype,"catalogLayerList",void 0),e([n()],P.prototype,"catalogOptions",void 0),e([n()],P.prototype,"collapsed",void 0),e([n()],P.prototype,"dragEnabled",void 0),e([n()],P.prototype,"filterPlaceholder",void 0),e([n()],P.prototype,"filterText",void 0),e([n()],P.prototype,"headingLevel",void 0),e([n()],P.prototype,"icon",null),e([n({readOnly:!0})],P.prototype,"tableList",void 0),e([n()],P.prototype,"knowledgeGraphOptions",void 0),e([n()],P.prototype,"label",null),e([n()],P.prototype,"listItemCanGiveFunction",void 0),e([n()],P.prototype,"listItemCanReceiveFunction",void 0),e([n()],P.prototype,"listItemCreatedFunction",null),e([n(),M("esri/widgets/LayerList/t9n/LayerList")],P.prototype,"messages",void 0),e([n(),M("esri/t9n/common")],P.prototype,"messagesCommon",void 0),e([n()],P.prototype,"minDragEnabledItems",void 0),e([n()],P.prototype,"minFilterItems",void 0),e([n()],P.prototype,"multipleSelectionEnabled",null),e([n()],P.prototype,"openCatalogItem",void 0),e([n()],P.prototype,"openTableListItem",void 0),e([n()],P.prototype,"operationalItems",null),e([n()],P.prototype,"selectionEnabled",null),e([n()],P.prototype,"selectedItems",void 0),e([n()],P.prototype,"selectionMode",void 0),e([n()],P.prototype,"view",null),e([k("trigger-action"),n({type:h})],P.prototype,"viewModel",void 0),e([n()],P.prototype,"visibilityAppearance",void 0),e([n({type:u,nonNullable:!0})],P.prototype,"visibleElements",void 0),P=e([r("esri.widgets.LayerList")],P);const x=P;export{x 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.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import t from"../../Graphic.js";import{isSome as i,equals as r}from"../../core/arrayUtils.js";import{createTask as o}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import{deprecatedProperty as a}from"../../core/deprecate.js";import n from"../../core/Error.js";import l from"../../core/Evented.js";import{isSerializable as h}from"../../core/JSONSupport.js";import{equalsShallow as c}from"../../core/lang.js";import u from"../../core/Logger.js";import{clamp as p}from"../../core/mathUtils.js";import{abortMaybe as d,destroyMaybe as m}from"../../core/maybe.js";import{isAbortError as g,throwIfAborted as y,waitTick as f}from"../../core/promiseUtils.js";import{watch as F,syncAndInitial as v,initial as w}from"../../core/reactiveUtils.js";import{property as _}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as b}from"../../core/accessorSupport/decorators/subclass.js";import{isPolygon as P}from"../../geometry/support/jsonUtils.js";import{geographicToWebMercator as I}from"../../geometry/support/webMercatorUtils.js";import C from"../../layers/GraphicsLayer.js";import{searchImages as V}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as S}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as O,computePolygonForInspection as j,resizePolygon as A,checkIfPolygonContainsSelectedPoint as B}from"../../layers/orientedImagery/core/coverageUtils.js";import{updateElevation as k,transformPoints as L}from"../../layers/orientedImagery/transformations/groundToImageUtils.js";import{transformPoints as G}from"../../layers/orientedImagery/transformations/imageToGroundUtils.js";import{getInitialAngle as M,convertPixelToHeadingPitch as E,convertHeadingPitchToSphereVertex as R}from"../../layers/orientedImagery/transformations/utils.js";import x from"../../rest/support/AttachmentQuery.js";import{ViewEventPriorities as T}from"../../views/input/InputManager.js";import D from"../PanoramicViewer.js";import{sectorsInOrder as H,sectorsRadii as U}from"./constants.js";import{crossSymbol as N,crossSymbol3D as z,diamondSymbol as W,diamondSymbol3D as J,activeSourcePointSymbol as $,sourcePointSymbol as q}from"./symbols.js";import{getContentType as K,isNoAttachmentError as Q,isTifOrMrf as X,isSceneView as Y,isGraphic as Z,calculateSegment as ee,calculateDirection as te}from"./utils.js";import ie from"./components/ImageViewer.js";import re from"../../geometry/Point.js";import oe from"../../geometry/SpatialReference.js";const se={click:"view-click",imageClick:"image-click",interactionHandles:"interaction-handles",footprintHandles:"footprint-handles"},ae=new Set(["JPG","JPEG"]),ne=/\.(\w+)$/,le=e=>"FA"===e;let he=class extends l.EventedAccessor{constructor(e){super(e),this.additionalFeatures=new s,this.bestFeatureAngle=0,this.coverageFrustums=new s,this.coveragePolygons=new s,this.currentBestFeature=null,this.currentCoverageVisible=!0,this.determineWorkflowForFeature=()=>{d(this._featureChangedTask),this._featureChangedTask=o((async e=>{const{currentBestFeature:t,selectedPoint:i}=this;if(t&&i){this._initialCurrentCoverageUpdate=!0;try{await this._updatePointsAndPolygons({signal:e}),await this._loadImage({signal:e})}catch(r){g(r)||(this.loadImageError(r),u.getLogger(this).error("#loadIImage()","error occured while loading image",r))}}}))},this.disabled=!1,this.displayMessage={key:"onLoadMessage",type:"info"},this.drawFootprint=()=>{this.bestFeatureFootprint&&this.updateCurrentCoveragePolygon(this.bestFeatureFootprint)},this.features=new s,this.isAdditionalCoverageVisible=!1,this.isAdditionalPointSourcesVisible=!1,this.layer=null,this.localPort=null,this.mapImageConversionToolState=!1,this.navigatorCurrentBestFeature=null,this.pointSources=new s,this.previousFeatureAngle=0,this.selectedPoint=null,this.shouldShowSelectedImage=!1,this.updateFootprint=async(e,t)=>{"image-loaded"===this.state&&await(this._adapter?.updateFootprint(e,t))},this.updateFootprintPanorama=async(e,t)=>{await(this._adapter?.updateFootprintPanorama(e,t))},this._adapter=null,this.additionalFootprints=new s,this.additionalCameraLocations=new s,this.bestFeatureCurrentFootprint=null,this._fetchFeaturesController=null,this._highlightedFeatureHandle=null,this._imageViewer=new ie,this.bestFeatureFootprint=null,this._initialCurrentCoverageUpdate=!0,this._loading=!1,this._overlays=new C({listMode:"hide",internal:!0,elevationInfo:{mode:"absolute-height"}}),this._panoramicViewer=new D,this._referencePointOnGround=null,this._referencePointOnImage=null,this._sectorData=null,this._crossSymbol=null,this.footprintExtent=null,this._featureChangedTask=null,this._openPopupTask=null,this._suitabilities=null,this._transformController=new AbortController,this._updateFootprintTask=null,this.highlight=e=>{if(!this._overlaysView)return;this.removeHighlight();const t=this.additionalFootprints.find((({attributes:{imageID:t}})=>t===Number(e)));this._highlightedFeatureHandle=t?this._overlaysView?.highlight(t):null},this.loadImageFromSource=async(e,t)=>{const{mode:i,imageRotation:r,options:o}=t,s="string"==typeof e,a=s?e:e.url;let n=s?e.match(ne)?.[1]??"":e.datasetFormat;if(!n){const e=await K(a,{...t.options});e&&(n=e.split("/")[1]),n??="UNKNOWN FORMAT"}switch(i){case"default":{this._imageViewer.imageSource={datasetFormat:n.toUpperCase(),url:a};const e=new URL(a);this._imageViewer.customParameters=Object.fromEntries(e.searchParams),this._imageViewer.imageRotation=r??0,await this._imageViewer.loadImage(o);break}case"panoramic":if(ae.has(n.toUpperCase())){const{selectedPoint:e}=this,{pitch:i,yaw:r,cameraLocation:s,viewAngle:n}=t;this._panoramicViewer.imageSource=a;let l=r??0;"number"==typeof n?l=n-l:s&&e&&(l=await M(s,e)-l),this._panoramicViewer.pitch=i??0,this._panoramicViewer.yaw=l,await this._panoramicViewer.loadImage(o)}else this.setMessage("unsupportedPanoramicImageryError","error",void 0,{datasetFormat:n});break}},this.loadImageViewer=e=>{this._imageViewer.container=e},this.loadPanoramicViewer=e=>{this._panoramicViewer.container=e},this.removeHighlight=()=>this._highlightedFeatureHandle?.remove(),this.toggleImageAttributes=()=>{d(this._openPopupTask),this._openPopupTask=o((async e=>{const{currentBestFeature:i,popupEnabled:r,layer:o,view:s}=this;if(s?.closePopup(),!(s&&i&&r&&o))return;const{attributes:a,geometry:n}=i,l=new t({geometry:n,attributes:a.toJSON(),popupTemplate:o.popupTemplate});y(e),await s.openPopup({features:[l],location:a.location.clone()})}))},this._getImageSourceFromAttachment=async(e,t,i)=>{const r=new x({objectIds:[t]}),o=await e.queryAttachments(r,i),s=o[`${t}`]?.[0],a=s?.url;if(!a)throw new n("NoAttachmentError","no attachments found",{[e.objectIdField]:t,layer:e});return{datasetFormat:s.contentType.split("/")[1].toUpperCase(),url:a}},this._loadImage=async e=>{const{currentBestFeature:t,layer:i,mode:r}=this;if(this.clearGraphics(),!i||!t||"none"===r)return;const{attributes:o}=t,{imagePath:s,imageRotation:a,cameraHeading:n,cameraRoll:l,cameraPitch:h,objectId:c,cameraOrientation:p,location:d}=o,m=(l??0)+(a??0),f=d.spatialReference.isWGS84&&4!==p?.type?I(d):new re(d);let F=s;if(le(s))try{F=await this._getImageSourceFromAttachment(i,c,e)}catch(v){if(g(v))return;return Q(v)?(u.getLogger(this).error(v),void this.setMessage("noAttachment","error",`${i.objectIdField}: ${c}`)):(u.getLogger(this).error(v,{[i.objectIdField]:c,layer:i}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${i.objectIdField} ${c}`))}try{await this.loadImageFromSource(F,{imageRotation:m,options:e,pitch:h,yaw:n,mode:r,cameraLocation:f}),y(e),await this.transformAndPlotSelectedLocation(e)}catch(v){g(v)||this.loadImageError(v)}},this._mapImageConversionToolViewClickHandler=e=>{e.stopPropagation(),e.preventDefault(),e.mapPoint&&this.plotMapPoint(e.mapPoint)},this._viewClickHandler=e=>{"mouse"===e.pointerType&&0!==e.button||(e.stopPropagation(),e.preventDefault(),e.mapPoint&&this.loadBestImage(e.mapPoint))},this.plotSelectedPointOnImage=async(e,i)=>{if(await f(i),!e)return;const r=new re({...h(e)?e.toJSON():e,spatialReference:oe.WebMercator});if("default"===this.mode)r.x-=.5,r.y=.5-r.y,this._crossSymbol=new t({geometry:r,symbol:N}),this._imageViewer.addGraphic(this._crossSymbol,0);else if("panoramic"===this.mode){const{imageSize:i}=this._panoramicViewer;if(!i)return;const[r,o]=i,{heading:s,pitch:a}=E(e,r,o),n=R(s,a);this._crossSymbol=new t({geometry:new re(n,oe.WebMercator),symbol:z}),this._panoramicViewer.addGraphic(this._crossSymbol,0)}},this.handleSectorClick=this.handleSectorClick.bind(this),this.searchBestImage=this.searchBestImage.bind(this),this.transformAndPlotReferencePointOnImage=this.transformAndPlotReferencePointOnImage.bind(this),this.updateSuitabilities=this.updateSuitabilities.bind(this),this.determineWorkflowForFeature=this.determineWorkflowForFeature.bind(this),this.selectBestFeature=this.selectBestFeature.bind(this),this.drawFootprint=this.drawFootprint.bind(this)}initialize(){this.addHandles([F((()=>this.view),(async e=>{if(e){switch(this._loading=!0,e.type){case"2d":{const{default:e}=await import("./adapters/OrientedImageryViewerViewModelAdapter2D.js");this._adapter=new e(this);break}case"3d":{const{default:e}=await import("./adapters/OrientedImageryViewerViewModelAdapter3D.js");this._adapter=new e(this);break}}this._loading=!1}else this._adapter=null}),v),F((()=>this.view?.map),((e,t)=>{t?.layers.remove(this._overlays),e?.layers.add(this._overlays)}),w),F((()=>this.view?.map?.allLayers?.length),(e=>{e&&this.view?.map?.layers.reorder(this._overlays,e-1)}),w),F((()=>[this.state,this.mapImageConversionToolState,this.view]),(()=>{if(this.removeHandles(se.click),"disabled"===this.state||null==this.view)return;const e=this.mapImageConversionToolState&&"image-loaded"===this.state?this._mapImageConversionToolViewClickHandler:this._viewClickHandler;this.addHandles(this.view.on("click",e,T.WIDGET),se.click),this.removeHandles(se.imageClick);const{mapImageConversionToolState:t,mode:i}=this;if(t&&"none"!==i)switch(i){case"default":this._imageViewer.clickAction="pixel-location",this.addHandles(this._imageViewer.on("pixel-location",(async e=>{this.plotReferencePointOnImage(e);const t=this.currentBestFeature;if(t){const i=(await G([e.toJSON()],{feature:t,imageProperties:{width:this._imageViewer.imageSize[0],height:this._imageViewer.imageSize[1]},options:{signal:this._transformController?.signal},footprintExtent:this.footprintExtent}))[0];i&&this.plotReferencePointOnGround(i)}})),se.imageClick);break;case"panoramic":this._panoramicViewer.clickAction="pixel-location",this.addHandles(this._panoramicViewer.on("pixel-location",(async e=>{this.plotReferencePointOnImage(e);const t=this.currentBestFeature,{imageSize:i}=this._panoramicViewer;if(t&&e&&i){const r=(await G([e],{feature:t,imageProperties:{width:i[0],height:i[1]},options:{signal:this._transformController?.signal},footprintExtent:this.footprintExtent}))[0];r&&this.plotReferencePointOnGround(r)}})),se.imageClick)}}),v),F((()=>this.bestFeatureAngle),((e,t)=>{this.previousFeatureAngle=t??0}),v),F((()=>this.currentBestFeature),((e,t)=>{this.determineWorkflowForFeature(e,t)}),{sync:!0}),F((()=>this.mode),(e=>{switch(this.removeHandles(se.interactionHandles),e){case"default":this.addHandles(F((()=>this._imageViewer.imagePointsInView),(e=>{e&&(d(this._updateFootprintTask),this._updateFootprintTask=o((async t=>{await this.updateFootprint(e,{signal:t})})))}),{...v,equals:(e,t)=>r(e,t,c)}),se.interactionHandles);break;case"panoramic":this.addHandles(F((()=>{const{imageSize:e,fov:t,imageRenderer:{size:i},pitch:r,yaw:o}=this._panoramicViewer,s=i[0]/i[1];return e?{imageSize:e,verticalFieldOfView:t/s,horizontalFieldOfView:t,yaw:o,pitch:r}:null}),(e=>{e&&(d(this._updateFootprintTask),this._updateFootprintTask=o((async t=>{await this.updateFootprintPanorama(e,{signal:t})})))}),v),se.interactionHandles)}}),v),F((()=>[this.brightness,this.contrast,this.sharpness]),(()=>{const{_imageViewer:e,brightness:t,contrast:i,mode:r,sharpness:o}=this;"default"===r&&(e.brightness=t,e.contrast=i,e.sharpness=o)}),v)])}destroy(){this._updateFootprintTask=d(this._updateFootprintTask),this._cancelFetchingFeatures(),this.coverageFrustums.destroy(),this.coveragePolygons.destroy(),this.pointSources.destroy(),this.additionalFootprints.destroy(),this.additionalCameraLocations.destroy(),this.bestFeatureFootprint=m(this.bestFeatureFootprint),this.bestFeatureCurrentFootprint=m(this.bestFeatureCurrentFootprint),this._crossSymbol=m(this._crossSymbol),this._referencePointOnGround=m(this._referencePointOnGround),this._referencePointOnImage=m(this._referencePointOnImage),this._overlays&&this.view?.map?.remove(this._overlays),this._overlays.destroy()}get activeLayer(){return a(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){a(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get activeViewer(){const{_imageViewer:e,_panoramicViewer:t,mode:i}=this;switch(i){case"default":return e;case"panoramic":return t;default:return null}}get brightness(){return this._get("brightness")??0}set brightness(e){this._set("brightness",e>10?10:e<-10?-10:e)}get contrast(){return this._get("contrast")??0}set contrast(e){this._set("contrast",p(e,-10,10))}get featureCount(){return this.features?.length??0}get imageGalleryEnabled(){return X(this.currentBestFeature?.attributes.imagePath.trim())}get imageLoaded(){return a(u.getLogger(this),"imageLoaded",{replacement:'Use OrientedImageryViewer.state === "image-loaded"',version:"4.29",warnOnce:!0}),"image-loaded"===this.state}get imagePointsInView(){const{mode:e,_imageViewer:t}=this;return"default"===e?t.imagePointsInView:null}get mode(){const e=this.currentBestFeature?.attributes;if(!e)return"none";const{horizontalFieldOfView:t,isSpherical:i}=e;return 360===t||i?"panoramic":"default"}get popupEnabled(){return null!==this.layer&&this.layer.popupEnabled}get referencePoint(){return this._referencePointOnGround?.geometry}get sectorData(){const{_sectorData:e}=this;return e?H.map((t=>e[t])):null}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",p(e,0,1))}get state(){const{mode:e,disabled:t}=this;if(t)return"disabled";if(this._loading)return"image-loading";switch(e){case"default":return this._imageViewer.state;case"panoramic":return this._panoramicViewer.state}return"ready"}get thumbnails(){const{features:e}=this;return e?new s(e.map((({attributes:{imagePath:e,objectId:t,cameraRoll:i,imageRotation:r}})=>{const o=e.trim();return X(o)?{url:o,objectId:t,rotation:(i??0)+(r??0)}:null})).filter(i)):null}set view(e){this._set("view",e)}get _overlaysView(){return this.view?.layerViews.find((({layer:e})=>e===this._overlays))}filterByFootprints(e,t){const i=[],r=[],o=[];return e.forEach((e=>{const{layer:{coveragePercent:s},attributes:a}=e;let n;const{polygon:l,frustum:h}=O(a);if(n=l.clone(),a.isInspection&&(n=j(a)),s&&(n=A(n,s)),B(n,t)){o.push(e);const{cameraHeading:t,geometry:s,objectId:n,cameraHeight:c}=a,u=s.clone();u.z=c,u.imageID=n,this.pointSources.push(u),t>0&&(i.push(l),h&&r.push(h))}})),{features:o,polygons:i,frustums:r}}getCurrentCoveragePolygon(){return this.bestFeatureCurrentFootprint}getCurrentBestFeaturePolygon(){return this.bestFeatureFootprint}handleSectorClick(e){if(isNaN(e))return;const t=this._sectorData?.[H[e]];t?.length&&this._updateCurrentBestFeature(t.at(0))}handleFeatureClick(e){const{sector:t,featureIndexInSector:i}=e;if(isNaN(i))return;const r=this._sectorData?.[t];r?.length&&this._updateCurrentBestFeature(r.at(i))}async loadBestImage(e){this._loading=!0,this.view?.closePopup(),this.displayMessage=null,this.selectedPoint=e.spatialReference.isGeographic?I(e):e.clone(),this.features.removeAll(),this.currentBestFeature=null,this.additionalFeatures.removeAll(),this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint=m(this.bestFeatureCurrentFootprint),this._overlays?.removeAll(),await this._fetchFeaturesWithController(e)}loadImageError(e){u.getLogger(this).error("oriented-imagery-viewer:load-image",e),this.setMessage("imageLoadError","error",e.message)}async plotMapPoint(e){return this.plotReferencePoint(e),this.transformAndPlotReferencePointOnImage({feature:this.currentBestFeature,selectedLocation:e,options:{signal:this._transformController?.signal}})}plotReferencePointOnGround(e){this._referencePointOnGround&&(this._overlays?.remove(this._referencePointOnGround),this._referencePointOnGround.destroy()),null!=e&&(this._referencePointOnGround=new t({geometry:new re({...e.toJSON()}),symbol:W}),this.view?this._overlays?.add(this._referencePointOnGround):this.emit("plot-ground-point",{data:{point:this._referencePointOnGround?.geometry}}))}plotReferencePointOnImage(e){if("image-loaded"===this.state)switch(this._referencePointOnImage&&(this._imageViewer.removeGraphic(this._referencePointOnImage),this._panoramicViewer.removeGraphic(this._referencePointOnImage),this._referencePointOnImage.destroy()),this.mode){case"default":{const i=h(e)?e.toJSON():e;i.x-=.5,i.y=.5-i.y,this._referencePointOnImage=new t({geometry:new re({spatialReference:this._imageViewer.imageRenderer.spatialReference,...i}),symbol:W}),this._imageViewer.addGraphic(this._referencePointOnImage,0);break}case"panoramic":{const{imageSize:i}=this._panoramicViewer;if(!i)return;const[r,o]=i,{heading:s,pitch:a}=E(e,r,o),n=R(s,a);this._referencePointOnImage=new t({geometry:new re(n,oe.WebMercator),symbol:J}),this._panoramicViewer.addGraphic(this._referencePointOnImage,0);break}}}resetImage(){switch(this.setMessage("onLoadMessage","info"),this.mode){case"default":this._imageViewer.clearImage(),this._imageViewer.clearGraphics();break;case"panoramic":this._panoramicViewer.clearGraphics()}this._cancelFetchingFeatures()}async searchBestImage(e,t){try{const i=await V(e,t);i&&await this._processFeatureResponse(i,e.point,{signal:t?.signal})}catch(i){g(i)||(this.setMessage("imageLoadError","error",i.message),u.getLogger(this).error("error occurred while finding best image",i))}}selectBestFeature(e){this.currentBestFeature=this.features?.find((({attributes:t})=>t.objectId===Number(e)))}setAdditionalCameraLocationsVisibility(e){this.additionalCameraLocations.forEach((t=>{t.visible=e}))}setAdditionalCoverageVisibility(e){this.additionalFootprints.forEach((t=>{t.visible=e}))}setCurrentCoverageVisibility(e){this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.visible=e),this.currentBestFeatureLocation&&(this.currentBestFeatureLocation.visible=e)}setMapImageConversionToolState(e){this.mapImageConversionToolState=e}async transformAndPlotReferencePointOnImage(e){const{selectedLocation:t,options:i}=e,r=this.bestFeatureFootprint?.geometry,o=P(r)&&r.contains(t),s="mesh"===r?.type&&r?.extent.contains(t);if(!o&&!s)return;const a=await this.transformPoint(t,i);return a?(this.plotReferencePointOnImage(a),{x:a.x,y:a.y}):void 0}updateSuitabilities(e){this._suitabilities=e.sort(((e,t)=>e.suitability-t.suitability));const t=this._suitabilities.map((e=>e.feature));this._updateFeatures(t),this._groupFeaturesBySectors(),this._initialCurrentCoverageUpdate=!0}_cancelFetchingFeatures(e){const t=this._fetchFeaturesController;t&&t.abort(e),this._fetchFeaturesController=null}async _fetchFeatures(e,t){if(!this.view)return;const i=this.layer;if(i){const r={include:i},o=this.view.toScreen(e);if(!o)return;const s=await this.view.hitTest(o,r);this._processHitTestResults(i,s,t)}}async _fetchFeaturesWithController(e){this._cancelFetchingFeatures();const t=new AbortController,{signal:i}=t;this._fetchFeaturesController=t;try{await this._fetchFeatures(e,{signal:i}).finally((()=>{this._fetchFeaturesController=null}))}catch(r){this.setMessage("imageLoadError","error"),u.getLogger(this).error("error occurred while fetching features",r)}}_groupFeaturesBySectors(){const{_suitabilities:e,additionalFeatures:t,currentBestFeature:i,features:r}=this;if(!(e&&t&&i&&r))return void(this._sectorData=null);this._sectorData={};for(const l of H)this._sectorData[l]=new s;const o=e.map(((e,t)=>({...e,featureIndex:t})));o.sort(((e,t)=>e.trueSuitability-t.trueSuitability));const a=o.map((({distance:e})=>e)),n=Math.max(...a);o.forEach((e=>{const{distance:t,angle:i,featureIndex:o}=e,s=t/n*U[2],a=ee(t,n),l=te(i);if(!this._sectorData)return;const h=U[3]+s*Math.sin(i*Math.PI/180),c=U[3]+s*Math.cos(i*Math.PI/180);let u;const p=r.at(o),d=p===this.currentBestFeature,m=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;if(d&&m)u=-90;else{const e=h-U[3],t=c-U[3],i=t/Math.sqrt(e**2+t**2);let r=180*Math.acos(i)/Math.PI;(e<0&&t<0||e<0&&t>0)&&(r*=-1),u=r}const g=""===a?l:`${a}_${l}`;d&&(u===this.bestFeatureAngle?this.previousFeatureAngle=u:this.bestFeatureAngle=u,this.navigatorCurrentBestFeature=m?null:{x:h,y:c,direction:l});const y=this._sectorData[g];y.add({angle:i,featureIndex:o,x:h,y:c,objectID:p.attributes.objectId,sector:g,featureIndexInSector:y.length})}))}async _processFeatureResponse(e,t,i){const{features:r}=e;if(!r?.length)return this.setMessage("noImageError","error"),void(this.currentBestFeature=null);this.coveragePolygons.removeAll(),this.coverageFrustums.removeAll(),this.pointSources.removeAll();const{features:o,polygons:s,frustums:a}=this.filterByFootprints(r,t);if(!o.length)return this.setMessage("noImageError","error"),void(this.currentBestFeature=null);this.coveragePolygons.addMany(s),this.coverageFrustums.addMany(a);const n=s.find((e=>e.imageID===o[0].attributes.objectId)).clone();n&&!n.contains(o[0].geometry)&&n.addRing([o[0].geometry]);const l=n.extent;let h;if(this.footprintExtent=l,this.view?.supportsGround)try{h=await this.view.map.ground.createElevationSampler(l,i)}catch(p){g(p)||u.getLogger(this).error(p)}if(o[0].elevationSample=h,(h||o[0].attributes.elevationSource)&&l){const e=await k([t],{feature:o[0],footprintExtent:l,options:i});if(e[0]){const i=e[0];t.elevation=i.z}}o[0].elevationSample&&o.forEach((e=>{e.elevationSample=o[0].elevationSample})),this._suitabilities=S({features:o,selectedPoint:t,camera:Y(this.view)?this.view.camera:null,currentImage:this.currentBestFeature}),this.updateSuitabilities(this._suitabilities);const c=this._suitabilities.map((e=>e.feature));this.currentBestFeature=c[0],this._loading=!1}async _processHitTestResults(e,t,i){const{screenPoint:r,results:[o]}=t,s="graphic"===o?.type&&this.shouldShowSelectedImage,a=o?.mapPoint??this.view?.toMap(r);if(!a)return;const n={layerInstanceOrURL:e,point:a,queryParams:{maximumDistance:e.maximumDistance,objectIds:s?[o.graphic.getAttribute(e.objectIdField)]:void 0}};await this.searchBestImage(n,i)}_updateFeatures(e){if(!e.length)return this.currentBestFeature=null,void this.additionalFeatures.removeAll();this.features.removeAll(),this.features.addMany(e),this.currentBestFeature=e[0],e.length>1?this.additionalFeatures.addMany(e.slice(1)):this.additionalFeatures.removeAll()}async _updatePointsAndPolygons(e){const{pointSources:i,currentBestFeature:r,currentCoverageVisible:o,isAdditionalPointSourcesVisible:s}=this;if(r){this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.destroy(),this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null),await(this._adapter?.createFootprints(e)),y(e);for(const e of i)e.imageID===r.attributes.objectId?this.currentBestFeatureLocation=new t({attributes:{imageID:e.imageID},geometry:e,symbol:$,visible:o}):this.additionalCameraLocations.push(new t({attributes:{imageID:e.imageID},geometry:e,symbol:q,visible:s}))}}_updateCurrentBestFeature(e){if(!e)return;this.currentBestFeature=this.features?.at(e.featureIndex);const t=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;let i;if(t)i=-90;else{const t=e.x-U[3],r=e.y-U[3],o=r/Math.sqrt(t**2+r**2);let s=180*Math.acos(o)/Math.PI;(t<0&&r<0||t<0&&r>0)&&(s*=-1),i=s}i===this.bestFeatureAngle?this.previousFeatureAngle=i:this.bestFeatureAngle=i,this.navigatorCurrentBestFeature=t?null:{x:e.x,y:e.y,direction:e.sector.includes("_")?e.sector.split("_")[1]:e.sector}}clearGraphics(){this._imageViewer.clearGraphics(),this._panoramicViewer.clearGraphics()}plotReferencePoint(e){"mapPoint"in e?this.plotReferencePointOnGround(e.mapPoint):this.plotReferencePointOnGround(e)}setMessage(e,t,i,r){this._loading=!1,this.displayMessage={key:e,type:t,data:i,map:r}}async transformAndPlotSelectedLocation(e){const{currentBestFeature:t,selectedPoint:i,state:r}=this;if(this._crossSymbol&&(this._panoramicViewer.removeGraphic(this._crossSymbol),this._imageViewer.removeGraphic(this._crossSymbol),this._crossSymbol=m(this._crossSymbol)),!i||!t||"image-loaded"!==r)return;let o;try{o=await this.transformPoint(i,e),y(e),await this.plotSelectedPointOnImage(o,e)}catch(s){g(s)||u.getLogger(this).error("failed to transform map point to pixel, cross symbol will not be plotted on image",{error:s,selectedPoint:i,feature:t})}}async transformPoint(e,t){if("none"===this.mode)return;const i=this.currentBestFeature,r=await L([e],{feature:i,imageProperties:"default"===this.mode?this._imageViewer.viewModel.image.serviceRasterInfo:{width:this._panoramicViewer.imageSize?.[0],height:this._panoramicViewer.imageSize?.[1]},options:t},"3d"===this.view?.type);if(!r.length)return;return r[0]}updateCurrentCoveragePolygon(e){const{additionalFootprints:i,additionalCameraLocations:r,currentBestFeature:o,currentBestFeatureLocation:s,currentCoverageVisible:a,selectedPoint:n,view:l,_adapter:h}=this,{attributes:{objectId:c},elevationSample:u}=o;if(this._initialCurrentCoverageUpdate){if(this._overlays?.removeAll(),this._initialCurrentCoverageUpdate=!1,this.bestFeatureCurrentFootprint=m(this.bestFeatureCurrentFootprint),e&&(e.visible=a,this.bestFeatureCurrentFootprint=e),l){const e=[...i,...r,this.bestFeatureCurrentFootprint,s].filter(Z);l.supportsGround&&u&&h?.updateGroundElevation&&h.updateGroundElevation(e,u),n&&e.push(new t({geometry:n.clone(),symbol:N.clone(),attributes:{imageID:c}})),this._overlays.graphics.addMany(e)}}else if(l){const t=this.bestFeatureCurrentFootprint&&this._overlays?this._overlays.graphics.indexOf(this.bestFeatureCurrentFootprint):-1;e&&(this.bestFeatureCurrentFootprint&&(this._overlays?.remove(this.bestFeatureCurrentFootprint),this.bestFeatureCurrentFootprint.destroy()),this.bestFeatureCurrentFootprint=e,l?.supportsGround&&u&&h?.updateGroundElevation&&h.updateGroundElevation([e],u),e.visible=this.currentCoverageVisible,this._overlays?.graphics.add(this.bestFeatureCurrentFootprint,t>=0?t:void 0))}}};e([_()],he.prototype,"activeLayer",null),e([_({readOnly:!0})],he.prototype,"activeViewer",null),e([_()],he.prototype,"additionalFeatures",void 0),e([_()],he.prototype,"bestFeatureAngle",void 0),e([_({type:Number})],he.prototype,"brightness",null),e([_({type:Number})],he.prototype,"contrast",null),e([_()],he.prototype,"coverageFrustums",void 0),e([_()],he.prototype,"coveragePolygons",void 0),e([_()],he.prototype,"currentBestFeature",void 0),e([_()],he.prototype,"currentCoverageVisible",void 0),e([_({json:{write:!1}})],he.prototype,"determineWorkflowForFeature",void 0),e([_()],he.prototype,"disabled",void 0),e([_()],he.prototype,"displayMessage",void 0),e([_()],he.prototype,"drawFootprint",void 0),e([_({readOnly:!0})],he.prototype,"featureCount",null),e([_()],he.prototype,"features",void 0),e([_({readOnly:!0})],he.prototype,"imageGalleryEnabled",null),e([_({readOnly:!0})],he.prototype,"imageLoaded",null),e([_()],he.prototype,"imagePointsInView",null),e([_()],he.prototype,"isAdditionalCoverageVisible",void 0),e([_()],he.prototype,"isAdditionalPointSourcesVisible",void 0),e([_()],he.prototype,"layer",void 0),e([_({type:Number})],he.prototype,"localPort",void 0),e([_()],he.prototype,"mapImageConversionToolState",void 0),e([_({readOnly:!0,value:"none"})],he.prototype,"mode",null),e([_()],he.prototype,"navigatorCurrentBestFeature",void 0),e([_()],he.prototype,"pointSources",void 0),e([_({readOnly:!0})],he.prototype,"popupEnabled",null),e([_()],he.prototype,"previousFeatureAngle",void 0),e([_()],he.prototype,"referencePoint",null),e([_({readOnly:!0})],he.prototype,"sectorData",null),e([_()],he.prototype,"selectedPoint",void 0),e([_({type:Number})],he.prototype,"sharpness",null),e([_()],he.prototype,"shouldShowSelectedImage",void 0),e([_({readOnly:!0})],he.prototype,"state",null),e([_({readOnly:!0})],he.prototype,"thumbnails",null),e([_()],he.prototype,"updateFootprint",void 0),e([_()],he.prototype,"updateFootprintPanorama",void 0),e([_({value:null})],he.prototype,"view",null),e([_()],he.prototype,"_adapter",void 0),e([_({type:s.ofType(t)})],he.prototype,"additionalFootprints",void 0),e([_({type:s.ofType(t)})],he.prototype,"additionalCameraLocations",void 0),e([_()],he.prototype,"bestFeatureCurrentFootprint",void 0),e([_()],he.prototype,"_fetchFeaturesController",void 0),e([_()],he.prototype,"_highlightedFeatureHandle",void 0),e([_()],he.prototype,"_imageViewer",void 0),e([_({type:t})],he.prototype,"bestFeatureFootprint",void 0),e([_()],he.prototype,"_initialCurrentCoverageUpdate",void 0),e([_()],he.prototype,"_loading",void 0),e([_()],he.prototype,"_overlays",void 0),e([_({readOnly:!0})],he.prototype,"_overlaysView",null),e([_()],he.prototype,"_panoramicViewer",void 0),e([_()],he.prototype,"_referencePointOnGround",void 0),e([_()],he.prototype,"_referencePointOnImage",void 0),e([_()],he.prototype,"currentBestFeatureLocation",void 0),e([_()],he.prototype,"_sectorData",void 0),e([_()],he.prototype,"footprintExtent",void 0),he=e([b("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],he);const ce=he;export{ce as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import t from"../../Graphic.js";import{isSome as i,equals as r}from"../../core/arrayUtils.js";import{createTask as o}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import{deprecatedProperty as a}from"../../core/deprecate.js";import n from"../../core/Error.js";import l from"../../core/Evented.js";import{isSerializable as h}from"../../core/JSONSupport.js";import{equalsShallow as c}from"../../core/lang.js";import u from"../../core/Logger.js";import{clamp as p}from"../../core/mathUtils.js";import{abortMaybe as d,destroyMaybe as m}from"../../core/maybe.js";import{isAbortError as g,throwIfAborted as y,waitTick as f}from"../../core/promiseUtils.js";import{watch as F,syncAndInitial as v,initial as w}from"../../core/reactiveUtils.js";import{property as _}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as b}from"../../core/accessorSupport/decorators/subclass.js";import{isPolygon as P}from"../../geometry/support/jsonUtils.js";import{geographicToWebMercator as I}from"../../geometry/support/webMercatorUtils.js";import C from"../../layers/GraphicsLayer.js";import{searchImages as V}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as S}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as O,computePolygonForInspection as j,resizePolygon as A,checkIfPolygonContainsSelectedPoint as B}from"../../layers/orientedImagery/core/coverageUtils.js";import{updateElevation as k,transformPoints as L}from"../../layers/orientedImagery/transformations/groundToImageUtils.js";import{transformPoints as G}from"../../layers/orientedImagery/transformations/imageToGroundUtils.js";import{getInitialAngle as M,convertPixelToHeadingPitch as E,convertHeadingPitchToSphereVertex as R}from"../../layers/orientedImagery/transformations/utils.js";import x from"../../rest/support/AttachmentQuery.js";import{ViewEventPriorities as T}from"../../views/input/InputManager.js";import D from"../PanoramicViewer.js";import{sectorsInOrder as H,sectorsRadii as U}from"./constants.js";import{crossSymbol as N,crossSymbol3D as z,diamondSymbol as W,diamondSymbol3D as q,activeSourcePointSymbol as J,sourcePointSymbol as $}from"./symbols.js";import{getContentType as K,isNoAttachmentError as Q,isTifOrMrf as X,isSceneView as Y,isGraphic as Z,calculateSegment as ee,calculateDirection as te}from"./utils.js";import ie from"./components/ImageViewer.js";import re from"../../geometry/Point.js";import oe from"../../geometry/SpatialReference.js";const se={click:"view-click",imageClick:"image-click",interactionHandles:"interaction-handles",footprintHandles:"footprint-handles"},ae=new Set(["JPG","JPEG"]),ne=/\.(\w+)$/,le=e=>"FA"===e;let he=class extends l.EventedAccessor{constructor(e){super(e),this.additionalFeatures=new s,this.bestFeatureAngle=0,this.coverageFrustums=new s,this.coveragePolygons=new s,this.currentBestFeature=null,this.currentCoverageVisible=!0,this.determineWorkflowForFeature=()=>{d(this._featureChangedTask),this._featureChangedTask=o((async e=>{const{currentBestFeature:t,selectedPoint:i}=this;if(t&&i){this._initialCurrentCoverageUpdate=!0;try{await this._updatePointsAndPolygons({signal:e}),await this._loadImage({signal:e})}catch(r){g(r)||(this.loadImageError(r),u.getLogger(this).error("#loadIImage()","error occured while loading image",r))}}}))},this.disabled=!1,this.displayMessage={key:"onLoadMessage",type:"info"},this.drawFootprint=()=>{this.bestFeatureFootprint&&this.updateCurrentCoveragePolygon(this.bestFeatureFootprint)},this.features=new s,this.isAdditionalCoverageVisible=!1,this.isAdditionalPointSourcesVisible=!1,this.layer=null,this.localPort=null,this.mapImageConversionToolState=!1,this.navigatorCurrentBestFeature=null,this.pointSources=new s,this.previousFeatureAngle=0,this.selectedPoint=null,this.shouldShowSelectedImage=!1,this.updateFootprint=async(e,t)=>{"image-loaded"===this.state&&await(this._adapter?.updateFootprint(e,t))},this.updateFootprintPanorama=async(e,t)=>{await(this._adapter?.updateFootprintPanorama(e,t))},this._adapter=null,this.additionalFootprints=new s,this.additionalCameraLocations=new s,this.bestFeatureCurrentFootprint=null,this._fetchFeaturesController=null,this._highlightedFeatureHandle=null,this._imageViewer=new ie,this.bestFeatureFootprint=null,this._initialCurrentCoverageUpdate=!0,this._loading=!1,this._overlays=new C({listMode:"hide",internal:!0,elevationInfo:{mode:"absolute-height"}}),this._panoramicViewer=new D,this._referencePointOnGround=null,this._referencePointOnImage=null,this._sectorData=null,this._crossSymbol=null,this.footprintExtent=null,this._featureChangedTask=null,this._openPopupTask=null,this._suitabilities=null,this._transformController=new AbortController,this._updateFootprintTask=null,this.highlight=e=>{if(!this._overlaysView)return;this.removeHighlight();const t=this.additionalFootprints.find((({attributes:{imageID:t}})=>t===Number(e)));this._highlightedFeatureHandle=t?this._overlaysView?.highlight(t):null},this.loadImageFromSource=async(e,t)=>{const{mode:i,imageRotation:r,options:o}=t,s="string"==typeof e,a=s?e:e.url;let n=s?e.match(ne)?.[1]??"":e.datasetFormat;if(!n){const e=await K(a,{...t.options});e&&(n=e.split("/")[1]),n??="UNKNOWN FORMAT"}switch(i){case"default":{this._imageViewer.imageSource={datasetFormat:n.toUpperCase(),url:a};const e=new URL(a);this._imageViewer.customParameters=Object.fromEntries(e.searchParams),this._imageViewer.imageRotation=r??0,await this._imageViewer.loadImage(o);break}case"panoramic":if(ae.has(n.toUpperCase())){const{selectedPoint:e}=this,{pitch:i,yaw:r,cameraLocation:s,viewAngle:n}=t;this._panoramicViewer.imageSource=a;let l=r??0;"number"==typeof n?l=n-l:s&&e&&(l=await M(s,e)-l),this._panoramicViewer.pitch=i??0,this._panoramicViewer.yaw=l,await this._panoramicViewer.loadImage(o)}else this.setMessage("unsupportedPanoramicImageryError","error",void 0,{datasetFormat:n});break}},this.loadImageViewer=e=>{this._imageViewer.container=e},this.loadPanoramicViewer=e=>{this._panoramicViewer.container=e},this.removeHighlight=()=>this._highlightedFeatureHandle?.remove(),this.toggleImageAttributes=()=>{d(this._openPopupTask),this._openPopupTask=o((async e=>{const{currentBestFeature:i,popupEnabled:r,layer:o,view:s}=this;if(s?.closePopup(),!(s&&i&&r&&o))return;const{attributes:a,geometry:n}=i,l=new t({geometry:n,attributes:a.toJSON(),popupTemplate:o.popupTemplate});y(e),await s.openPopup({features:[l],location:a.location.clone()})}))},this._getImageSourceFromAttachment=async(e,t,i)=>{const r=new x({objectIds:[t]}),o=await e.queryAttachments(r,i),s=o[`${t}`]?.[0],a=s?.url;if(!a)throw new n("NoAttachmentError","no attachments found",{[e.objectIdField]:t,layer:e});return{datasetFormat:s.contentType.split("/")[1].toUpperCase(),url:a}},this._loadImage=async e=>{const{currentBestFeature:t,layer:i,mode:r}=this;if(this.clearGraphics(),!i||!t||"none"===r)return;const{attributes:o}=t,{imagePath:s,imageRotation:a,cameraHeading:n,cameraRoll:l,cameraPitch:h,objectId:c,cameraOrientation:p,location:d}=o,m=(l??0)+(a??0),f=d.spatialReference.isWGS84&&4!==p?.type?I(d):new re(d);let F=s;if(le(s))try{F=await this._getImageSourceFromAttachment(i,c,e)}catch(v){if(g(v))return;return Q(v)?(u.getLogger(this).error(v),void this.setMessage("noAttachment","error",`${i.objectIdField}: ${c}`)):(u.getLogger(this).error(v,{[i.objectIdField]:c,layer:i}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${i.objectIdField} ${c}`))}try{await this.loadImageFromSource(F,{imageRotation:m,options:e,pitch:h,yaw:n,mode:r,cameraLocation:f}),y(e),await this.transformAndPlotSelectedLocation(e)}catch(v){g(v)||this.loadImageError(v)}},this._mapImageConversionToolViewClickHandler=e=>{e.stopPropagation(),e.preventDefault(),e.mapPoint&&this.plotMapPoint(e.mapPoint)},this._viewClickHandler=e=>{"mouse"===e.pointerType&&0!==e.button||(e.stopPropagation(),e.preventDefault(),e.mapPoint&&this.loadBestImage(e.mapPoint))},this.plotSelectedPointOnImage=async(e,i)=>{if(await f(i),!e)return;const r=new re({...h(e)?e.toJSON():e,spatialReference:oe.WebMercator});if("default"===this.mode)r.x-=.5,r.y=.5-r.y,this._crossSymbol=new t({geometry:r,symbol:N}),this._imageViewer.addGraphic(this._crossSymbol,0);else if("panoramic"===this.mode){const{imageSize:i}=this._panoramicViewer;if(!i)return;const[r,o]=i,{heading:s,pitch:a}=E(e,r,o),n=R(s,a);this._crossSymbol=new t({geometry:new re(n,oe.WebMercator),symbol:z}),this._panoramicViewer.addGraphic(this._crossSymbol,0)}},this.handleSectorClick=this.handleSectorClick.bind(this),this.searchBestImage=this.searchBestImage.bind(this),this.transformAndPlotReferencePointOnImage=this.transformAndPlotReferencePointOnImage.bind(this),this.updateSuitabilities=this.updateSuitabilities.bind(this),this.determineWorkflowForFeature=this.determineWorkflowForFeature.bind(this),this.selectBestFeature=this.selectBestFeature.bind(this),this.drawFootprint=this.drawFootprint.bind(this)}initialize(){this.addHandles([F((()=>this.view),(async e=>{if(e){switch(this._loading=!0,e.type){case"2d":{const{default:e}=await import("./adapters/OrientedImageryViewerViewModelAdapter2D.js");this._adapter=new e(this);break}case"3d":{const{default:e}=await import("./adapters/OrientedImageryViewerViewModelAdapter3D.js");this._adapter=new e(this);break}}this._loading=!1}else this._adapter=null}),v),F((()=>this.view?.map),((e,t)=>{t?.layers.remove(this._overlays),e?.layers.add(this._overlays)}),w),F((()=>this.view?.map?.allLayers?.length),(e=>{e&&this.view?.map?.layers.reorder(this._overlays,e-1)}),w),F((()=>[this.state,this.mapImageConversionToolState,this.view]),(()=>{if(this.removeHandles(se.click),"disabled"===this.state||null==this.view)return;const e=this.mapImageConversionToolState&&"image-loaded"===this.state?this._mapImageConversionToolViewClickHandler:this._viewClickHandler;this.addHandles(this.view.on("click",e,T.WIDGET),se.click),this.removeHandles(se.imageClick);const{mapImageConversionToolState:t,mode:i}=this;if(t&&"none"!==i)switch(i){case"default":this._imageViewer.clickAction="pixel-location",this.addHandles(this._imageViewer.on("pixel-location",(async e=>{this.plotReferencePointOnImage(e);const t=this.currentBestFeature;if(t){const i=(await G([e.toJSON()],{feature:t,imageProperties:{width:this._imageViewer.imageSize[0],height:this._imageViewer.imageSize[1]},options:{signal:this._transformController?.signal},footprintExtent:this.footprintExtent}))[0];i&&this.plotReferencePointOnGround(i)}})),se.imageClick);break;case"panoramic":this._panoramicViewer.clickAction="pixel-location",this.addHandles(this._panoramicViewer.on("pixel-location",(async e=>{this.plotReferencePointOnImage(e);const t=this.currentBestFeature,{imageSize:i}=this._panoramicViewer;if(t&&e&&i){const r=(await G([e],{feature:t,imageProperties:{width:i[0],height:i[1]},options:{signal:this._transformController?.signal},footprintExtent:this.footprintExtent}))[0];r&&this.plotReferencePointOnGround(r)}})),se.imageClick)}}),v),F((()=>this.bestFeatureAngle),((e,t)=>{this.previousFeatureAngle=t??0}),v),F((()=>this.currentBestFeature),((e,t)=>{this.determineWorkflowForFeature(e,t)}),{sync:!0}),F((()=>this.mode),(e=>{switch(this.removeHandles(se.interactionHandles),e){case"default":this.addHandles(F((()=>this._imageViewer.imagePointsInView),(e=>{e&&(d(this._updateFootprintTask),this._updateFootprintTask=o((async t=>{await this.updateFootprint(e,{signal:t})})))}),{...v,equals:(e,t)=>r(e,t,c)}),se.interactionHandles);break;case"panoramic":this.addHandles(F((()=>{const{currentBestFeature:e}=this,{imageSize:t,fov:i,imageRenderer:{size:r},pitch:o,yaw:s}=this._panoramicViewer;if(!e||!t)return null;return[i/(r[0]/r[1]),i,s,o]}),(e=>{if(!e||"image-loading"===this.state)return;const[t,i,r,s]=e;d(this._updateFootprintTask),this._updateFootprintTask=o((async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:i,yaw:r,pitch:s},{signal:e})}))}),{...v,equals:(e,t)=>r(e,t,c)}),se.interactionHandles)}}),v),F((()=>[this.brightness,this.contrast,this.sharpness]),(()=>{const{_imageViewer:e,brightness:t,contrast:i,mode:r,sharpness:o}=this;"default"===r&&(e.brightness=t,e.contrast=i,e.sharpness=o)}),v)])}destroy(){this._updateFootprintTask=d(this._updateFootprintTask),this._cancelFetchingFeatures(),this.coverageFrustums.destroy(),this.coveragePolygons.destroy(),this.pointSources.destroy(),this.additionalFootprints.destroy(),this.additionalCameraLocations.destroy(),this.bestFeatureFootprint=m(this.bestFeatureFootprint),this.bestFeatureCurrentFootprint=m(this.bestFeatureCurrentFootprint),this._crossSymbol=m(this._crossSymbol),this._referencePointOnGround=m(this._referencePointOnGround),this._referencePointOnImage=m(this._referencePointOnImage),this._overlays&&this.view?.map?.remove(this._overlays),this._overlays.destroy()}get activeLayer(){return a(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){a(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get activeViewer(){const{_imageViewer:e,_panoramicViewer:t,mode:i}=this;switch(i){case"default":return e;case"panoramic":return t;default:return null}}get brightness(){return this._get("brightness")??0}set brightness(e){this._set("brightness",e>10?10:e<-10?-10:e)}get contrast(){return this._get("contrast")??0}set contrast(e){this._set("contrast",p(e,-10,10))}get featureCount(){return this.features?.length??0}get imageGalleryEnabled(){return X(this.currentBestFeature?.attributes.imagePath.trim())}get imageLoaded(){return a(u.getLogger(this),"imageLoaded",{replacement:'Use OrientedImageryViewer.state === "image-loaded"',version:"4.29",warnOnce:!0}),"image-loaded"===this.state}get imagePointsInView(){const{mode:e,_imageViewer:t}=this;return"default"===e?t.imagePointsInView:null}get mode(){const e=this.currentBestFeature?.attributes;if(!e)return"none";const{horizontalFieldOfView:t,isSpherical:i}=e;return 360===t||i?"panoramic":"default"}get popupEnabled(){return null!==this.layer&&this.layer.popupEnabled}get referencePoint(){return this._referencePointOnGround?.geometry}get sectorData(){const{_sectorData:e}=this;return e?H.map((t=>e[t])):null}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",p(e,0,1))}get state(){const{mode:e,disabled:t}=this;if(t)return"disabled";if(this._loading)return"image-loading";switch(e){case"default":return this._imageViewer.state;case"panoramic":return this._panoramicViewer.state}return"ready"}get thumbnails(){const{features:e}=this;return e?new s(e.map((({attributes:{imagePath:e,objectId:t,cameraRoll:i,imageRotation:r}})=>{const o=e.trim();return X(o)?{url:o,objectId:t,rotation:(i??0)+(r??0)}:null})).filter(i)):null}set view(e){this._set("view",e)}get _overlaysView(){return this.view?.layerViews.find((({layer:e})=>e===this._overlays))}filterByFootprints(e,t){const i=[],r=[],o=[];return e.forEach((e=>{const{layer:{coveragePercent:s},attributes:a}=e;let n;const{polygon:l,frustum:h}=O(a);if(n=l.clone(),a.isInspection&&(n=j(a)),s&&(n=A(n,s)),B(n,t)){o.push(e);const{cameraHeading:t,geometry:s,objectId:n,cameraHeight:c}=a,u=s.clone();u.z=c,u.imageID=n,this.pointSources.push(u),t>0&&(i.push(l),h&&r.push(h))}})),{features:o,polygons:i,frustums:r}}getCurrentCoveragePolygon(){return this.bestFeatureCurrentFootprint}getCurrentBestFeaturePolygon(){return this.bestFeatureFootprint}handleSectorClick(e){if(isNaN(e))return;const t=this._sectorData?.[H[e]];t?.length&&this._updateCurrentBestFeature(t.at(0))}handleFeatureClick(e){const{sector:t,featureIndexInSector:i}=e;if(isNaN(i))return;const r=this._sectorData?.[t];r?.length&&this._updateCurrentBestFeature(r.at(i))}async loadBestImage(e){this._loading=!0,this.view?.closePopup(),this.displayMessage=null,this.selectedPoint=e.spatialReference.isGeographic?I(e):e.clone(),this.features.removeAll(),this.currentBestFeature=null,this.additionalFeatures.removeAll(),this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint=m(this.bestFeatureCurrentFootprint),this._overlays?.removeAll(),await this._fetchFeaturesWithController(e)}loadImageError(e){u.getLogger(this).error("oriented-imagery-viewer:load-image",e),this.setMessage("imageLoadError","error",e.message)}async plotMapPoint(e){return this.plotReferencePoint(e),this.transformAndPlotReferencePointOnImage({feature:this.currentBestFeature,selectedLocation:e,options:{signal:this._transformController?.signal}})}plotReferencePointOnGround(e){this._referencePointOnGround&&(this._overlays?.remove(this._referencePointOnGround),this._referencePointOnGround.destroy()),null!=e&&(this._referencePointOnGround=new t({geometry:new re({...e.toJSON()}),symbol:W}),this.view?this._overlays?.add(this._referencePointOnGround):this.emit("plot-ground-point",{data:{point:this._referencePointOnGround?.geometry}}))}plotReferencePointOnImage(e){if("image-loaded"===this.state)switch(this._referencePointOnImage&&(this._imageViewer.removeGraphic(this._referencePointOnImage),this._panoramicViewer.removeGraphic(this._referencePointOnImage),this._referencePointOnImage.destroy()),this.mode){case"default":{const i=h(e)?e.toJSON():e;i.x-=.5,i.y=.5-i.y,this._referencePointOnImage=new t({geometry:new re({spatialReference:this._imageViewer.imageRenderer.spatialReference,...i}),symbol:W}),this._imageViewer.addGraphic(this._referencePointOnImage,0);break}case"panoramic":{const{imageSize:i}=this._panoramicViewer;if(!i)return;const[r,o]=i,{heading:s,pitch:a}=E(e,r,o),n=R(s,a);this._referencePointOnImage=new t({geometry:new re(n,oe.WebMercator),symbol:q}),this._panoramicViewer.addGraphic(this._referencePointOnImage,0);break}}}resetImage(){switch(this.setMessage("onLoadMessage","info"),this.mode){case"default":this._imageViewer.clearImage(),this._imageViewer.clearGraphics();break;case"panoramic":this._panoramicViewer.clearGraphics()}this._cancelFetchingFeatures()}async searchBestImage(e,t){try{const i=await V(e,t);i&&await this._processFeatureResponse(i,e.point,{signal:t?.signal})}catch(i){g(i)||(this.setMessage("imageLoadError","error",i.message),u.getLogger(this).error("error occurred while finding best image",i))}}selectBestFeature(e){this.currentBestFeature=this.features?.find((({attributes:t})=>t.objectId===Number(e)))}setAdditionalCameraLocationsVisibility(e){this.additionalCameraLocations.forEach((t=>{t.visible=e}))}setAdditionalCoverageVisibility(e){this.additionalFootprints.forEach((t=>{t.visible=e}))}setCurrentCoverageVisibility(e){this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.visible=e),this.currentBestFeatureLocation&&(this.currentBestFeatureLocation.visible=e)}setMapImageConversionToolState(e){this.mapImageConversionToolState=e}async transformAndPlotReferencePointOnImage(e){const{selectedLocation:t,options:i}=e,r=this.bestFeatureFootprint?.geometry,o=P(r)&&r.contains(t),s="mesh"===r?.type&&r?.extent.contains(t);if(!o&&!s)return;const a=await this.transformPoint(t,i);return a?(this.plotReferencePointOnImage(a),{x:a.x,y:a.y}):void 0}updateSuitabilities(e){this._suitabilities=e.sort(((e,t)=>e.suitability-t.suitability));const t=this._suitabilities.map((e=>e.feature));this._updateFeatures(t),this._groupFeaturesBySectors(),this._initialCurrentCoverageUpdate=!0}_cancelFetchingFeatures(e){const t=this._fetchFeaturesController;t&&t.abort(e),this._fetchFeaturesController=null}async _fetchFeatures(e,t){if(!this.view)return;const i=this.layer;if(i){const r={include:i},o=this.view.toScreen(e);if(!o)return;const s=await this.view.hitTest(o,r);this._processHitTestResults(i,s,t)}}async _fetchFeaturesWithController(e){this._cancelFetchingFeatures();const t=new AbortController,{signal:i}=t;this._fetchFeaturesController=t;try{await this._fetchFeatures(e,{signal:i}).finally((()=>{this._fetchFeaturesController=null}))}catch(r){this.setMessage("imageLoadError","error"),u.getLogger(this).error("error occurred while fetching features",r)}}_groupFeaturesBySectors(){const{_suitabilities:e,additionalFeatures:t,currentBestFeature:i,features:r}=this;if(!(e&&t&&i&&r))return void(this._sectorData=null);this._sectorData={};for(const l of H)this._sectorData[l]=new s;const o=e.map(((e,t)=>({...e,featureIndex:t})));o.sort(((e,t)=>e.trueSuitability-t.trueSuitability));const a=o.map((({distance:e})=>e)),n=Math.max(...a);o.forEach((e=>{const{distance:t,angle:i,featureIndex:o}=e,s=t/n*U[2],a=ee(t,n),l=te(i);if(!this._sectorData)return;const h=U[3]+s*Math.sin(i*Math.PI/180),c=U[3]+s*Math.cos(i*Math.PI/180);let u;const p=r.at(o),d=p===this.currentBestFeature,m=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;if(d&&m)u=-90;else{const e=h-U[3],t=c-U[3],i=t/Math.sqrt(e**2+t**2);let r=180*Math.acos(i)/Math.PI;(e<0&&t<0||e<0&&t>0)&&(r*=-1),u=r}const g=""===a?l:`${a}_${l}`;d&&(u===this.bestFeatureAngle?this.previousFeatureAngle=u:this.bestFeatureAngle=u,this.navigatorCurrentBestFeature=m?null:{x:h,y:c,direction:l});const y=this._sectorData[g];y.add({angle:i,featureIndex:o,x:h,y:c,objectID:p.attributes.objectId,sector:g,featureIndexInSector:y.length})}))}async _processFeatureResponse(e,t,i){const{features:r}=e;if(!r?.length)return this.setMessage("noImageError","error"),void(this.currentBestFeature=null);this.coveragePolygons.removeAll(),this.coverageFrustums.removeAll(),this.pointSources.removeAll();const{features:o,polygons:s,frustums:a}=this.filterByFootprints(r,t);if(!o.length)return this.setMessage("noImageError","error"),void(this.currentBestFeature=null);this.coveragePolygons.addMany(s),this.coverageFrustums.addMany(a);const n=s.find((e=>e.imageID===o[0].attributes.objectId)).clone();n&&!n.contains(o[0].geometry)&&n.addRing([o[0].geometry]);const l=n.extent;let h;if(this.footprintExtent=l,this.view?.supportsGround)try{h=await this.view.map.ground.createElevationSampler(l,i)}catch(p){g(p)||u.getLogger(this).error(p)}if(o[0].elevationSample=h,(h||o[0].attributes.elevationSource)&&l){const e=await k([t],{feature:o[0],footprintExtent:l,options:i});if(e[0]){const i=e[0];t.elevation=i.z}}o[0].elevationSample&&o.forEach((e=>{e.elevationSample=o[0].elevationSample})),this._suitabilities=S({features:o,selectedPoint:t,camera:Y(this.view)?this.view.camera:null,currentImage:this.currentBestFeature}),this.updateSuitabilities(this._suitabilities);const c=this._suitabilities.map((e=>e.feature));this.currentBestFeature=c[0],this._loading=!1}async _processHitTestResults(e,t,i){const{screenPoint:r,results:[o]}=t,s="graphic"===o?.type&&this.shouldShowSelectedImage,a=o?.mapPoint??this.view?.toMap(r);if(!a)return;const n={layerInstanceOrURL:e,point:a,queryParams:{maximumDistance:e.maximumDistance,objectIds:s?[o.graphic.getAttribute(e.objectIdField)]:void 0}};await this.searchBestImage(n,i)}_updateFeatures(e){if(!e.length)return this.currentBestFeature=null,void this.additionalFeatures.removeAll();this.features.removeAll(),this.features.addMany(e),this.currentBestFeature=e[0],e.length>1?this.additionalFeatures.addMany(e.slice(1)):this.additionalFeatures.removeAll()}async _updatePointsAndPolygons(e){const{pointSources:i,currentBestFeature:r,currentCoverageVisible:o,isAdditionalPointSourcesVisible:s}=this;if(r){this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.destroy(),this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null),await(this._adapter?.createFootprints(e)),y(e);for(const e of i)e.imageID===r.attributes.objectId?this.currentBestFeatureLocation=new t({attributes:{imageID:e.imageID},geometry:e,symbol:J,visible:o}):this.additionalCameraLocations.push(new t({attributes:{imageID:e.imageID},geometry:e,symbol:$,visible:s}))}}_updateCurrentBestFeature(e){if(!e)return;this.currentBestFeature=this.features?.at(e.featureIndex);const t=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;let i;if(t)i=-90;else{const t=e.x-U[3],r=e.y-U[3],o=r/Math.sqrt(t**2+r**2);let s=180*Math.acos(o)/Math.PI;(t<0&&r<0||t<0&&r>0)&&(s*=-1),i=s}i===this.bestFeatureAngle?this.previousFeatureAngle=i:this.bestFeatureAngle=i,this.navigatorCurrentBestFeature=t?null:{x:e.x,y:e.y,direction:e.sector.includes("_")?e.sector.split("_")[1]:e.sector}}clearGraphics(){this._imageViewer.clearGraphics(),this._panoramicViewer.clearGraphics()}plotReferencePoint(e){"mapPoint"in e?this.plotReferencePointOnGround(e.mapPoint):this.plotReferencePointOnGround(e)}setMessage(e,t,i,r){this._loading=!1,this.displayMessage={key:e,type:t,data:i,map:r}}async transformAndPlotSelectedLocation(e){const{currentBestFeature:t,selectedPoint:i,state:r}=this;if(this._crossSymbol&&(this._panoramicViewer.removeGraphic(this._crossSymbol),this._imageViewer.removeGraphic(this._crossSymbol),this._crossSymbol=m(this._crossSymbol)),!i||!t||"image-loaded"!==r)return;let o;try{o=await this.transformPoint(i,e),y(e),await this.plotSelectedPointOnImage(o,e)}catch(s){g(s)||u.getLogger(this).error("failed to transform map point to pixel, cross symbol will not be plotted on image",{error:s,selectedPoint:i,feature:t})}}async transformPoint(e,t){if("none"===this.mode)return;const i=this.currentBestFeature,r=await L([e],{feature:i,imageProperties:"default"===this.mode?this._imageViewer.viewModel.image.serviceRasterInfo:{width:this._panoramicViewer.imageSize?.[0],height:this._panoramicViewer.imageSize?.[1]},options:t},"3d"===this.view?.type);if(!r.length)return;return r[0]}updateCurrentCoveragePolygon(e){const{additionalFootprints:i,additionalCameraLocations:r,currentBestFeature:o,currentBestFeatureLocation:s,currentCoverageVisible:a,selectedPoint:n,view:l,_adapter:h}=this,{attributes:{objectId:c},elevationSample:u}=o;if(this._initialCurrentCoverageUpdate){if(this._overlays?.removeAll(),this._initialCurrentCoverageUpdate=!1,this.bestFeatureCurrentFootprint=m(this.bestFeatureCurrentFootprint),e&&(e.visible=a,this.bestFeatureCurrentFootprint=e),l){const e=[...i,...r,this.bestFeatureCurrentFootprint,s].filter(Z);l.supportsGround&&u&&h?.updateGroundElevation&&h.updateGroundElevation(e,u),n&&e.push(new t({geometry:n.clone(),symbol:N.clone(),attributes:{imageID:c}})),this._overlays.graphics.addMany(e)}}else if(l){const t=this.bestFeatureCurrentFootprint&&this._overlays?this._overlays.graphics.indexOf(this.bestFeatureCurrentFootprint):-1;e&&(this.bestFeatureCurrentFootprint&&(this._overlays?.remove(this.bestFeatureCurrentFootprint),this.bestFeatureCurrentFootprint.destroy()),this.bestFeatureCurrentFootprint=e,l?.supportsGround&&u&&h?.updateGroundElevation&&h.updateGroundElevation([e],u),e.visible=this.currentCoverageVisible,this._overlays?.graphics.add(this.bestFeatureCurrentFootprint,t>=0?t:void 0))}}};e([_()],he.prototype,"activeLayer",null),e([_({readOnly:!0})],he.prototype,"activeViewer",null),e([_()],he.prototype,"additionalFeatures",void 0),e([_()],he.prototype,"bestFeatureAngle",void 0),e([_({type:Number})],he.prototype,"brightness",null),e([_({type:Number})],he.prototype,"contrast",null),e([_()],he.prototype,"coverageFrustums",void 0),e([_()],he.prototype,"coveragePolygons",void 0),e([_()],he.prototype,"currentBestFeature",void 0),e([_()],he.prototype,"currentCoverageVisible",void 0),e([_({json:{write:!1}})],he.prototype,"determineWorkflowForFeature",void 0),e([_()],he.prototype,"disabled",void 0),e([_()],he.prototype,"displayMessage",void 0),e([_()],he.prototype,"drawFootprint",void 0),e([_({readOnly:!0})],he.prototype,"featureCount",null),e([_()],he.prototype,"features",void 0),e([_({readOnly:!0})],he.prototype,"imageGalleryEnabled",null),e([_({readOnly:!0})],he.prototype,"imageLoaded",null),e([_()],he.prototype,"imagePointsInView",null),e([_()],he.prototype,"isAdditionalCoverageVisible",void 0),e([_()],he.prototype,"isAdditionalPointSourcesVisible",void 0),e([_()],he.prototype,"layer",void 0),e([_({type:Number})],he.prototype,"localPort",void 0),e([_()],he.prototype,"mapImageConversionToolState",void 0),e([_({readOnly:!0,value:"none"})],he.prototype,"mode",null),e([_()],he.prototype,"navigatorCurrentBestFeature",void 0),e([_()],he.prototype,"pointSources",void 0),e([_({readOnly:!0})],he.prototype,"popupEnabled",null),e([_()],he.prototype,"previousFeatureAngle",void 0),e([_()],he.prototype,"referencePoint",null),e([_({readOnly:!0})],he.prototype,"sectorData",null),e([_()],he.prototype,"selectedPoint",void 0),e([_({type:Number})],he.prototype,"sharpness",null),e([_()],he.prototype,"shouldShowSelectedImage",void 0),e([_({readOnly:!0})],he.prototype,"state",null),e([_({readOnly:!0})],he.prototype,"thumbnails",null),e([_()],he.prototype,"updateFootprint",void 0),e([_()],he.prototype,"updateFootprintPanorama",void 0),e([_({value:null})],he.prototype,"view",null),e([_()],he.prototype,"_adapter",void 0),e([_({type:s.ofType(t)})],he.prototype,"additionalFootprints",void 0),e([_({type:s.ofType(t)})],he.prototype,"additionalCameraLocations",void 0),e([_()],he.prototype,"bestFeatureCurrentFootprint",void 0),e([_()],he.prototype,"_fetchFeaturesController",void 0),e([_()],he.prototype,"_highlightedFeatureHandle",void 0),e([_()],he.prototype,"_imageViewer",void 0),e([_({type:t})],he.prototype,"bestFeatureFootprint",void 0),e([_()],he.prototype,"_initialCurrentCoverageUpdate",void 0),e([_()],he.prototype,"_loading",void 0),e([_()],he.prototype,"_overlays",void 0),e([_({readOnly:!0})],he.prototype,"_overlaysView",null),e([_()],he.prototype,"_panoramicViewer",void 0),e([_()],he.prototype,"_referencePointOnGround",void 0),e([_()],he.prototype,"_referencePointOnImage",void 0),e([_()],he.prototype,"currentBestFeatureLocation",void 0),e([_()],he.prototype,"_sectorData",void 0),e([_()],he.prototype,"footprintExtent",void 0),he=e([b("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],he);const ce=he;export{ce 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.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import i from"../../Camera.js";import"../../geometry.js";import t from"../../Ground.js";import o from"../../Map.js";import a from"../../request.js";import r from"../../core/Collection.js";import s from"../../core/Error.js";import n from"../../core/Evented.js";import{JSONMap as h}from"../../core/jsonMap.js";import{destroyMaybe as m}from"../../core/maybe.js";import{isAbortError as l,waitTick as d}from"../../core/promiseUtils.js";import{watch as c,when as p,syncAndInitial as g}from"../../core/reactiveUtils.js";import{property as _}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{enumeration as u}from"../../core/accessorSupport/decorators/enumeration.js";import{subclass as y}from"../../core/accessorSupport/decorators/subclass.js";import v from"../../layers/GraphicsLayer.js";import{convertSphereVertexToPixelLocation as f}from"../../layers/orientedImagery/transformations/utils.js";import w from"../../views/SceneView.js";import V from"../Zoom.js";import{logAndThrow as C,getMissingPropertyErrorName as j,getMissingPropertyErrorMessage as P}from"../OrientedImageryViewer/utils.js";import{defaultImageSphereCenter as z}from"./constants.js";import R from"./PanoramicZoomConditions.js";import H from"./PanoramicZoomViewModel.js";import{meshToGraphic as b,createImageSphere as S}from"./utils.js";import M from"../../geometry/SpatialReference.js";const x={autoLoad:"auto-load",default:"default",navigation:"navigation",fovConstraint:"fov-constraint",clickAction:"image-click-action"};let O=class extends n.EventedAccessor{constructor(e){super(e),this._startPosition=null,this._targetPosition=null,this._graphics=new v({elevationInfo:{mode:"relative-to-ground"}}),this._imageGraphic=null,this._loadController=null,this._map=new o({ground:new t({opacity:0,navigationConstraint:null}),layers:new r([this._graphics])}),this._zoomViewModel=null,this.autoLoad=!1,this.clickAction="none",this.maxHFOV=120,this.minHFOV=50,this.imageSize=null,this.imageSource=null,this.pitch=90,this.state="ready",this.yaw=0,this._addNavigationHandles=()=>{this.imageRenderer.basemapTerrain.suspended=!0,this.imageRenderer.constraints.tilt.max=180,this.removeHandles(x.navigation),this.addHandles([this.imageRenderer.on("mouse-wheel",this._handleWheel),this.imageRenderer.on("double-click",this._handleDoubleClick),this.imageRenderer.on("drag",this._handleDrag),this.imageRenderer.on("key-down",(e=>{const i=["+","-","Shift","_","=","ArrowUp","ArrowDown","ArrowRight","ArrowLeft"],t=e.key;i.includes(t)&&e.stopPropagation()}))],x.navigation)},this._addHFOVHandles=()=>{this.removeHandles(x.fovConstraint),this.addHandles(c((()=>[this.maxHFOV,this.minHFOV]),(()=>{this._zoomViewModel&&(this._zoomViewModel.panoramicZoomConditions=new R({view:this.imageRenderer,maxFOV:this.maxHFOV,minFOV:this.minHFOV}))}),g),x.fovConstraint)},this._addZoomHandles=()=>{this._zoomViewModel=new H({view:this.imageRenderer,panoramicZoomConditions:new R({maxFOV:this.maxHFOV,minFOV:this.minHFOV})});const e=new V({viewModel:this._zoomViewModel});this.imageRenderer.ui.add(e,"top-left"),this._addHFOVHandles()},this._cancelLoadWithController=()=>{this._loadController?.abort(),this._loadController=null},this._handleDoubleClick=e=>{e.stopPropagation(),e.native.ctrlKey?this._zoomOut():this._zoomIn()},this._handleDrag=e=>{e.stopPropagation();const{action:i,x:t,y:o}=e;switch(i){case"start":this._startPosition=this._targetPosition={x:t,y:o};break;case"update":this._targetPosition={x:t,y:o},this._updateCameraHeadingAndTilt()}},this._handleImageClick=e=>{if("image-loaded"===this.state&&this.imageRenderer.ready)switch(this.clickAction){case"emit":e.stopPropagation(),this.emit("click",e);break;case"hittest":e.stopPropagation(),e.async((async()=>{const i=await this.imageRenderer.hitTest(e.screenPoint,{include:this._graphics});this.emit("hittest-response",i)}));break;case"pixel-location":{if(e.stopPropagation(),!this.imageSize||!e.mapPoint)return void this.emit("pixel-location",null);const i=f(e.mapPoint,this.imageSize[0],this.imageSize[1]);this.emit("pixel-location",{...i,spatialReference:M.WebMercator,meshVertex:e.mapPoint});break}}},this._handleWheel=e=>{const i=e.deltaX??e.native.deltaX;e.stopPropagation(),i>0||e.deltaY>0?this._zoomOut():this._zoomIn()},this._loadWithController=()=>{this._cancelLoadWithController(),this._loadController=new AbortController,this.loadImage(this._loadController)},this._zoomIn=()=>this._zoomViewModel?.zoomIn(),this._zoomOut=()=>this._zoomViewModel?.zoomOut(),this.addGraphic=(e,i)=>"image-loaded"===this.state&&!this._graphics.graphics.includes(e)&&(this._graphics.graphics.add(e,i),!0),this.addManyGraphics=e=>{if("image-loaded"!==this.state)return!1;const i=e.filter((e=>!this._graphics.graphics.includes(e)));return this._graphics.graphics.addMany(i),!0},this.clearGraphics=()=>{this._graphics.graphics.removeAll()},this.clearImage=()=>{this.imageSize=null,this._removeImageSphere()},this.removeGraphic=e=>!("image-loaded"!==this.state||!this._graphics.graphics.includes(e))&&(this._graphics.remove(e),!0),this.removeManyGraphics=e=>{if("image-loaded"!==this.state)return!1;const i=e.filter((e=>this._graphics.graphics.includes(e)));return this._graphics.removeMany(i),!0},this._imageRenderer=new w({map:this._map,viewingMode:"local",camera:{position:z},environment:{atmosphereEnabled:!1,starsEnabled:!1,lighting:{type:"virtual"}},popupEnabled:!1,spatialReference:M.WebMercator,ui:{components:["attribution"]}})}initialize(){this.addHandles([c((()=>this.imageSource),(()=>{this.
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import i from"../../Camera.js";import"../../geometry.js";import t from"../../Ground.js";import o from"../../Map.js";import a from"../../request.js";import r from"../../core/Collection.js";import s from"../../core/Error.js";import n from"../../core/Evented.js";import{JSONMap as h}from"../../core/jsonMap.js";import{destroyMaybe as m}from"../../core/maybe.js";import{isAbortError as l,waitTick as d}from"../../core/promiseUtils.js";import{watch as c,when as p,syncAndInitial as g}from"../../core/reactiveUtils.js";import{property as _}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{enumeration as u}from"../../core/accessorSupport/decorators/enumeration.js";import{subclass as y}from"../../core/accessorSupport/decorators/subclass.js";import v from"../../layers/GraphicsLayer.js";import{convertSphereVertexToPixelLocation as f}from"../../layers/orientedImagery/transformations/utils.js";import w from"../../views/SceneView.js";import V from"../Zoom.js";import{logAndThrow as C,getMissingPropertyErrorName as j,getMissingPropertyErrorMessage as P}from"../OrientedImageryViewer/utils.js";import{defaultImageSphereCenter as z}from"./constants.js";import R from"./PanoramicZoomConditions.js";import H from"./PanoramicZoomViewModel.js";import{meshToGraphic as b,createImageSphere as S}from"./utils.js";import M from"../../geometry/SpatialReference.js";const x={autoLoad:"auto-load",default:"default",navigation:"navigation",fovConstraint:"fov-constraint",clickAction:"image-click-action"};let O=class extends n.EventedAccessor{constructor(e){super(e),this._startPosition=null,this._targetPosition=null,this._graphics=new v({elevationInfo:{mode:"relative-to-ground"}}),this._imageGraphic=null,this._loadController=null,this._map=new o({ground:new t({opacity:0,navigationConstraint:null}),layers:new r([this._graphics])}),this._zoomViewModel=null,this.autoLoad=!1,this.clickAction="none",this.maxHFOV=120,this.minHFOV=50,this.imageSize=null,this.imageSource=null,this.pitch=90,this.state="ready",this.yaw=0,this._addNavigationHandles=()=>{this.imageRenderer.basemapTerrain.suspended=!0,this.imageRenderer.constraints.tilt.max=180,this.removeHandles(x.navigation),this.addHandles([this.imageRenderer.on("mouse-wheel",this._handleWheel),this.imageRenderer.on("double-click",this._handleDoubleClick),this.imageRenderer.on("drag",this._handleDrag),this.imageRenderer.on("key-down",(e=>{const i=["+","-","Shift","_","=","ArrowUp","ArrowDown","ArrowRight","ArrowLeft"],t=e.key;i.includes(t)&&e.stopPropagation()}))],x.navigation)},this._addHFOVHandles=()=>{this.removeHandles(x.fovConstraint),this.addHandles(c((()=>[this.maxHFOV,this.minHFOV]),(()=>{this._zoomViewModel&&(this._zoomViewModel.panoramicZoomConditions=new R({view:this.imageRenderer,maxFOV:this.maxHFOV,minFOV:this.minHFOV}))}),g),x.fovConstraint)},this._addZoomHandles=()=>{this._zoomViewModel=new H({view:this.imageRenderer,panoramicZoomConditions:new R({maxFOV:this.maxHFOV,minFOV:this.minHFOV})});const e=new V({viewModel:this._zoomViewModel});this.imageRenderer.ui.add(e,"top-left"),this._addHFOVHandles()},this._cancelLoadWithController=()=>{this._loadController?.abort(),this._loadController=null},this._handleDoubleClick=e=>{e.stopPropagation(),e.native.ctrlKey?this._zoomOut():this._zoomIn()},this._handleDrag=e=>{e.stopPropagation();const{action:i,x:t,y:o}=e;switch(i){case"start":this._startPosition=this._targetPosition={x:t,y:o};break;case"update":this._targetPosition={x:t,y:o},this._updateCameraHeadingAndTilt()}},this._handleImageClick=e=>{if("image-loaded"===this.state&&this.imageRenderer.ready)switch(this.clickAction){case"emit":e.stopPropagation(),this.emit("click",e);break;case"hittest":e.stopPropagation(),e.async((async()=>{const i=await this.imageRenderer.hitTest(e.screenPoint,{include:this._graphics});this.emit("hittest-response",i)}));break;case"pixel-location":{if(e.stopPropagation(),!this.imageSize||!e.mapPoint)return void this.emit("pixel-location",null);const i=f(e.mapPoint,this.imageSize[0],this.imageSize[1]);this.emit("pixel-location",{...i,spatialReference:M.WebMercator,meshVertex:e.mapPoint});break}}},this._handleWheel=e=>{const i=e.deltaX??e.native.deltaX;e.stopPropagation(),i>0||e.deltaY>0?this._zoomOut():this._zoomIn()},this._loadWithController=()=>{this._cancelLoadWithController(),this._loadController=new AbortController,this.loadImage(this._loadController)},this._zoomIn=()=>this._zoomViewModel?.zoomIn(),this._zoomOut=()=>this._zoomViewModel?.zoomOut(),this.addGraphic=(e,i)=>"image-loaded"===this.state&&!this._graphics.graphics.includes(e)&&(this._graphics.graphics.add(e,i),!0),this.addManyGraphics=e=>{if("image-loaded"!==this.state)return!1;const i=e.filter((e=>!this._graphics.graphics.includes(e)));return this._graphics.graphics.addMany(i),!0},this.clearGraphics=()=>{this._graphics.graphics.removeAll()},this.clearImage=()=>{this.imageSize=null,this._removeImageSphere()},this.removeGraphic=e=>!("image-loaded"!==this.state||!this._graphics.graphics.includes(e))&&(this._graphics.remove(e),!0),this.removeManyGraphics=e=>{if("image-loaded"!==this.state)return!1;const i=e.filter((e=>this._graphics.graphics.includes(e)));return this._graphics.removeMany(i),!0},this._imageRenderer=new w({map:this._map,viewingMode:"local",camera:{position:z},environment:{atmosphereEnabled:!1,starsEnabled:!1,lighting:{type:"virtual"}},popupEnabled:!1,spatialReference:M.WebMercator,ui:{components:["attribution"]}})}initialize(){this.state="initialized",this.addHandles([c((()=>this.imageSource),(()=>{this.imageSource&&this.autoLoad&&this._loadWithController()}),g),c((()=>this.fov),(()=>{this._reloadCamera()}),g),c((()=>this.yaw),(e=>{this.camera.heading=e,this._reloadCamera()}),g),c((()=>this.pitch),(e=>{this.camera.tilt=e,this._reloadCamera()}),g),p((()=>this.imageRenderer.ready),(()=>{this._addNavigationHandles(),this._addZoomHandles()}),g),c((()=>this.clickAction),(e=>{this.removeHandles(x.clickAction),"none"!==e&&this.addHandles(this.imageRenderer.on("click",this._handleImageClick))}),g)],x.default)}get camera(){return this.imageRenderer.camera}set camera(e){e&&(this.imageRenderer.camera=e.clone())}get fov(){return this.camera.fov}set fov(e){Number.isFinite(e)&&this._zoomViewModel?.zoomTo(e)}get imageRenderer(){return this._imageRenderer}async _loadImageInternal(e,i){let t;this.state="image-loading";try{t=(await a(e,{responseType:"image",...i})).data}catch(o){throw l(o)?this.state="image-load-aborted":this.state="image-load-error",o}return this._updateImageSphere(t,i)}_reloadCamera(){this.camera=this.camera.clone()}_removeImageSphere(){this._imageGraphic&&(this._graphics.remove(this._imageGraphic),this._imageGraphic=m(this._imageGraphic)),this.state="ready",this.imageSize=null}_updateCameraHeadingAndTilt(){if(!this._startPosition||!this._targetPosition)return;const e=this.camera.heading+(this._startPosition.x-this._targetPosition.x)/this.imageRenderer.width*this.camera.fov;this.yaw=(e+360)%360;const i=this.camera.tilt-(this._startPosition.y-this._targetPosition.y)/this.imageRenderer.height*this.imageRenderer.camera.fov;this.pitch=Math.min(179.5,Math.max(.5,i)),this._startPosition=this._targetPosition}async _updateImageSphere(e,i){return await d(i),this._imageGraphic=b(S(e)),this._graphics.add(this._imageGraphic),this.state="image-loaded",this.imageSize=[e.width,e.height],this._imageGraphic.geometry}async loadImage(e){return this._removeImageSphere(),this.imageSource?this._loadImageInternal(this.imageSource,e):C(this.declaredClass,new s(j("panoramic-viewer"),P("PanoramicViewerViewModel","imageSource")))}};e([_()],O.prototype,"_graphics",void 0),e([_()],O.prototype,"_imageGraphic",void 0),e([_()],O.prototype,"_imageRenderer",void 0),e([_()],O.prototype,"_loadController",void 0),e([_()],O.prototype,"_map",void 0),e([_()],O.prototype,"_zoomViewModel",void 0),e([_({type:Boolean})],O.prototype,"autoLoad",void 0),e([_({type:i})],O.prototype,"camera",null),e([u(new h({emit:"emit",hittest:"hittest",none:"none","pixel-location":"pixel-location"}))],O.prototype,"clickAction",void 0),e([_({type:Number})],O.prototype,"fov",null),e([_({type:Number})],O.prototype,"maxHFOV",void 0),e([_({type:Number})],O.prototype,"minHFOV",void 0),e([_()],O.prototype,"imageSize",void 0),e([_()],O.prototype,"imageSource",void 0),e([_({type:Number})],O.prototype,"pitch",void 0),e([_({readOnly:!0})],O.prototype,"imageRenderer",null),e([_()],O.prototype,"state",void 0),e([_({type:Number})],O.prototype,"yaw",void 0),O=e([y("esri.widgets.PanoramicViewer.PanoramicViewerViewModel")],O);const k=O;export{k 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.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../chunks/tslib.es6.js";import"../../geometry.js";import{id as e}from"../../kernel.js";import o from"../../request.js";import{isSome as i}from"../../core/arrayUtils.js";import r from"../../core/Collection.js";import s from"../../core/Error.js";import{JSONMap as a}from"../../core/jsonMap.js";import{clone as l}from"../../core/lang.js";import n from"../../core/Loadable.js";import{isAbortError as p}from"../../core/promiseUtils.js";import{watch as m,initial as u}from"../../core/reactiveUtils.js";import{createScreenPoint as h}from"../../core/screenUtils.js";import{convertUnit as c,getMetersPerUnitForSR as d,inchesPerMeter as y}from"../../core/unitUtils.js";import{property as f}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as v}from"../../core/accessorSupport/decorators/subclass.js";import{formatDate as w,convertDateFormatToIntlOptions as T}from"../../intl/date.js";import{getLanguage as _}from"../../intl/locale.js";import I from"../../portal/Portal.js";import g from"../../portal/PortalQueryParams.js";import{execute as b}from"../../rest/geoprocessor/execute.js";import{submitJob as O}from"../../rest/geoprocessor/submitJob.js";import{execute as P,getTasks as x,getMode as L}from"../../rest/print.js";import{fromJSON as S}from"../../rest/support/fileFormat.js";import{fromJSON as j}from"../../rest/support/layoutTemplate.js";import E from"../../rest/support/PrintParameters.js";import U from"../../rest/support/PrintTemplate.js";import{getExtent as C}from"../../views/2d/viewpointUtils.js";import{ViewEventPriorities as k}from"../../views/input/InputManager.js";import H from"../../views/overlay/BoxOverlayItem.js";import D from"./CustomTemplate.js";import F from"./TemplateOptions.js";import M from"../../geometry/Extent.js";const N=/.+\.arcgis\.com$/i,W=/(\/GPServer\/).+/i,A=new a({inch:"inches",foot:"feet",yard:"yards",mile:"miles","nautical-mile":"nautical-miles",millimeter:"millimeters",centimeter:"centimeters",decimeter:"decimeters",meter:"meters",kilometer:"kilometers"}),z=r.ofType(D);function V(t){t.layoutOptions??={},t.layoutOptions.customTextElements??=[];const e="date";if(!t.layoutOptions.customTextElements.find((t=>e in t))){const{customTextElements:e}=t.layoutOptions;let o=w(Date.now(),T("short-date"));"ar"===_()&&(o=""+o),e.push({date:o})}}let q=class extends n{constructor(t){super(t),this._serviceTemplateCustomTextElements=null,this._templateToLayoutInfo=new Map,this._isFreeHand=!1,this._freeHandWidth=0,this._freehandHeight=0,this._asyncPrintTaskUrl=null,this._layoutInfoTaskUrl=null,this.allowedFormats="all",this.allowedLayouts="all",this.browseTemplates=new z,this.defaultTemplates=new z,this.error=null,this.extraParameters=null,this.includeDefaultTemplates=!0,this.portal=I.getDefault(),this.portalTemplateIds=[],this.printPreviewEnabled=!1,this.printServiceUrl=null,this.printTimeout=12e4,this.templatesInfo=null,this.updateDelay=1e3,this.view=null,this.templateCustomTextElements=null,this.templateOptions=new F}initialize(){this.addHandles(m((()=>this.printPreviewEnabled),(t=>{t?this._enablePrintPreview():(this.removeHandles("overlay-handler"),this.view?.overlay?.removeItem(this._getOverlayItem()))})))}destroy(){this.removeHandles("overlay-handler"),this.view&&(this._overlayItem&&(this.view.overlay?.removeItem(this._overlayItem),this._overlayItem.destroy(),this._overlayItem=null),this.view=null)}get effectivePrintServiceUrl(){return this.printServiceUrl??null}get effectiveTemplateCustomTextElements(){if(!this._serviceTemplateCustomTextElements)return{};const t=l(this._serviceTemplateCustomTextElements);return this.templateCustomTextElements&&Object.keys(this.templateCustomTextElements).forEach((e=>{const o=t[e];if(o){const t=this.templateCustomTextElements?.[e];o.forEach((e=>{const[o]=Object.entries(e)[0];t?.forEach((t=>{const[i,r]=Object.entries(t)[0];o===i&&(e[o]=r)}))}))}})),Object.freeze(t)}get layoutTemplateInfo(){const t=this.templateOptions.layoutItem?.id??this.templateOptions.layout;return t?this._templateToLayoutInfo.get(t):null}get state(){return"loading"===this.loadStatus?"initializing":"failed"===this.loadStatus||this.error?"error":"loaded"===this.loadStatus&&this.view?.ready?"ready":"disabled"}get layoutTemplateNorthArrowInfo(){return this.layoutTemplateInfo?.layoutOptions?.mapSurroundInfos?this.layoutTemplateInfo.layoutOptions.mapSurroundInfos.find((t=>"CIMMarkerNorthArrow"===t.type)):null}async load(t){return this.addResolvingPromise(this._loadResources(t).catch((t=>this.error=t))),this}async print(t){const{view:e,extraParameters:o,updateDelay:i}=this;if(!e)throw new s("print:view-required","view is not set");V(t);const r=this._getOverlayItem(),a=t.scalePreserved||!this.printPreviewEnabled?void 0:C(new M,e.viewpoint,"MAP_ONLY"===t.layout?[t.exportOptions.width,t.exportOptions.height]:[r.boxWidth,r.boxHeight]),l=new E({view:e,template:t,extent:a,extraParameters:o,updateDelay:i});try{const e=!!t.layoutItem?.id&&(this.portalTemplateIds.includes(t.layoutItem.id)||this.browseTemplates.some((e=>e.layoutItem?.id===t.layoutItem?.id)));return await P(e&&this._asyncPrintTaskUrl?this._asyncPrintTaskUrl:this.effectivePrintServiceUrl,l,{timeout:this.printTimeout})}catch(n){throw new s("print:export-error","An error occurred while exporting the web map.",{error:n})}}toPrintTemplate({attributionEnabled:t,author:e,copyright:o,customTextElements:i,dpi:r,forceFeatureAttributes:a,format:l,height:n,includeTables:p,layout:m,layoutItem:u,legendEnabled:h,northArrowEnabled:c,scale:d,scaleEnabled:y,title:f,width:v}){if(!m)throw new s("print:layout-required","layout is not set");const w=new U({attributionVisible:t,forceFeatureAttributes:a,format:l,includeTables:p,layout:m,layoutItem:u,layoutOptions:{authorText:e||"",copyrightText:o||"",customTextElements:i,titleText:f||""},outScale:d??0,scalePreserved:y});v&&(w.exportOptions.width=v),n&&(w.exportOptions.height=n),r&&(w.exportOptions.dpi=r),!h&&w.layoutOptions&&(w.layoutOptions.legendLayers=[]);const T=this.layoutTemplateNorthArrowInfo;if(T){!(T.visible===c)&&w.layoutOptions&&(w.layoutOptions.elementOverrides={[T.name]:{visible:c}})}return w}async fetchLayoutTemplateInfo(t,e){if(!t.layoutItem?.id)return;const o=await this._fetchPortalLayoutTemplateInfo(t.layoutItem,e);this._templateToLayoutInfo.set(t.layoutItem.id,o),t.layoutTemplateInfo=o;const{hasLegend:i,mapSurroundInfos:r}=o.layoutOptions,s=r.some((({type:t,visible:e})=>"CIMMarkerNorthArrow"===t&&e));t.layoutOptions={legend:i,northArrow:s}}getPageSizeLabel(t){if(!t)return;const e=this._templateToLayoutInfo.get(t);return e?`${e.pageSize.join(" x ")} ${A.fromJSON(e.pageUnits.toLowerCase())}`:void 0}async addPortalTemplate(t){const e=new D({label:t.title,layoutItem:t});this.browseTemplates.add(e)}removePortalTemplate(t){t.layoutItem?.id&&this.templateOptions.layoutItem?.id===t.layoutItem.id&&(this.templateOptions.layout=this.defaultTemplates.length||this.browseTemplates.length?null:this.templatesInfo?.layout?.defaultValue,this.templateOptions.layoutItem=null),this._templateToLayoutInfo.delete(t.layoutItem.id),this.browseTemplates.remove(t)}async _loadResources(t){let e=[];if(!this.printServiceUrl){if(this.destroyed)return;try{await this.portal.load(t)}catch(n){throw new s("print:could-not-load-portal","Cannot load print resource information from portal",{error:n,url:this.effectivePrintServiceUrl})}if(this.portal.helperServices){const{asyncPrintTask:o,layoutInfoTask:i,printTask:r}=this.portal.helperServices;r&&(this._set("effectivePrintServiceUrl",r.url),e=r.templates?.map((t=>D.fromJSON(t)))??[]),this._asyncPrintTaskUrl=o?.url;const s=i?.url||this.effectivePrintServiceUrl;if(s){const e=(await x(s,t)).find((t=>t.includes("Get Layout Templates Info")));e&&(this._layoutInfoTaskUrl=s.replace(W,`$1${encodeURI(e)}`))}}}this.defaultTemplates.addMany(e);const o=this.effectivePrintServiceUrl?.toLowerCase().split("/");if(!o?.includes("gpserver"))throw new s("print:invalid-print-service-url","Can't fetch print templates information from provided URL",{url:this.effectivePrintServiceUrl});const i=!N.test(this.portal.url)||this.portal.user&&"anonymous"!==this.portal.authMode,[r,a,l]=await Promise.all([this._getPrintServiceLayouts(t),this._getPrintServiceTemplates(t),i?this._getPortalCustomTemplates(t):null]);this._processPrintServiceLayouts(r),this._processPrintServiceTemplates(a),this._processPortalTemplates(l),this._updateOverLayItem()}async _getPortalCustomTemplates(t){if(this.printServiceUrl)return[];const{layoutGroupQuery:e}=this.portal;if(!e)return[];const o=new g({query:e,disableExtraQuery:!0}),i=await this.portal.queryGroups(o,t);if(!i.total)return[];const r=i.results[0],s=new g({num:100,query:"type:Layout"}),a=(await r.queryItems(s,t)).results;return a.length?a.map((t=>new D({label:t.title,layoutItem:t}))):[]}async _fetchPortalLayoutTemplateInfo(t,o){const{id:i}=t,r=this._layoutInfoTaskUrl;if(!r)throw new s("print:invalid-layout-info-task-url","Can't fetch layout template info",{url:r});"public"!==t.access&&e&&await e.getCredential(r);const a={Layout_Item_ID:JSON.stringify({id:i})};return(await this._fetchLayoutTemplateInfos(a,o))[0]}async _fetchLayoutTemplateInfos(t,e){const o=this._layoutInfoTaskUrl;if(!o)throw new s("print:invalid-layout-info-task-url","Can't fetch layout template info",{url:o});if("async"===await L(o)){const i=await O(o,t,void 0,e||void 0);await i.waitForJobCompletion({interval:1e3});return(await i.fetchResultData("Output_JSON")).value}return(await b(o,t,null,e)).results[0].value}_processPortalTemplates(t){if(t){this.defaultTemplates.addMany(t);for(const e of t)e.layoutItem?.id&&this.portalTemplateIds.push(e.layoutItem.id)}}_processPrintServiceTemplates(t){this._set("templatesInfo",t)}async _getPrintServiceLayouts(t){let e=[];try{e=await this._fetchLayoutTemplateInfos(void 0,t)}catch{}return e}_processPrintServiceLayouts(t){const e={};for(const o of t){const{layoutTemplate:t,layoutOptions:i}=o,r=j(t);this._templateToLayoutInfo.set(r,o),e[r]=i.customTextElements}this._serviceTemplateCustomTextElements=Object.freeze(e)}async _getPrintServiceTemplates(t){let e;try{({data:e}=await o(this.effectivePrintServiceUrl,{...t,query:{f:"json"},timeout:this.printTimeout}))}catch(l){throw p(l)?l:new s("print:unavailable-service-info","Can't fetch templates info from service",{error:l})}const{parameters:i}=e,r=i.find((({name:t})=>"Format"===t)),a=i.find((({name:t})=>"Layout_Template"===t));return{format:this._getFormat(r),layout:this._getLayout(a)}}_getFormat(t){const e="all"===this.allowedFormats?t.choiceList:t.choiceList.filter((t=>this.allowedFormats.includes(S(t)))),o=(e.length?e:t.choiceList).map(S).filter(i),r=S(t.defaultValue),s=o.includes(r)?r:o[0];return{choiceList:o,defaultValue:s}}_getLayout(t){const e=t.choiceList.filter((t=>"map_only"!==t.toLowerCase())),o="all"===this.allowedLayouts?e:e.filter((t=>this.allowedLayouts.includes(j(t)))),r=(o.length?o:e).map(j).filter(i),s=j(t.defaultValue),a=r.includes(s)?s:r.find((t=>/(?=.*letter)(?=.*landscape)/i.test(t)))??r.find((t=>/(?=.*a4)(?=.*landscape)/i.test(t)))??r[0];return{choiceList:r,defaultValue:a}}_getOverlayItem(){return this._overlayItem||(this._overlayItem=new H({strokeDash:[5],strokeWidth:2,strokeColor:[30,144,255,255]})),this._overlayItem}_enablePrintPreview(){if(!this.view?.overlay)return;const t=this.templateOptions,e=this._getOverlayItem();this.addHandles([m((()=>[t.width,t.height,t.scaleEnabled,t.scale,t.layout,t.layoutItem,this.view?.scale,this.view?.size,this.view?.state.paddedViewState.size,this.view?.state.padding]),(()=>this._updateOverLayItem()),u),this.view?.on("drag",["Shift"],(t=>this._handleDrag(t)),k.WIDGET),this.view?.on("key-down",["Escape"],(()=>this._resetDrag()),k.WIDGET)],"overlay-handler"),this.view.overlay.addItem(e)}_updateOverLayItem(){if(!this.view)return;const t=this.templateOptions,e=this._getOverlayItem(),o=t.layoutItem?.id??t.layout,i=this.view,r=i.spatialReference,[s,a]=i.state.paddedViewState.size,l=i.state.padding;let n=0,p=0;if("MAP_ONLY"===o)null!=t.width&&null!=t.height&&(n=t.width,p=t.height);else if(o){const{webMapFrameSize:e,pageUnits:i}=this._templateToLayoutInfo.get(o)??{};if(e&&i)if(this._isFreeHand){const t=e[0]/e[1];n=this._freeHandWidth,p=this._freehandHeight,n>p?p=n/t:n=p*t}else{const t=A.fromJSON(i.toLowerCase()),o=r.unit;n=c(e[0],t,o),p=c(e[1],t,o)}if(!this._isFreeHand)if(t.scaleEnabled&&t.scale){const e=d(r)*y*t.dpi;n*=e,p*=e}else if(0===n||0===p)n=s,p=a;else{const t=(s-.1*s)/n,e=(a-.1*a)/p,o=Math.min(t,e);n*=o,p*=o}}const{scaleEnabled:m,scale:u}=t,h=m&&u?u/this.view.scale:1;e.boxWidth=n*h,e.boxHeight=p*h,l&&(e.padding=l),e.backgroundWidth=s??0,e.backgroundHeight=a??0}_resetDrag(){this._isFreeHand=!1,this._updateOverLayItem()}_handleDrag(t){switch(t.action){case"start":this._start();break;case"update":this._update(t);break;case"end":this._end()}t.stopPropagation()}_start(){this._isFreeHand=!0}_update(t){const e=this._getOverlayItem(),{x:o,y:i}=t,{x:r,y:s}=t.origin;o>r?(e.x=r,e.boxWidth=o-r):(e.x=o,e.boxWidth=r-o),i>s?(e.y=s,e.boxHeight=i-s):(e.y=i,e.boxHeight=s-i)}_end(){const t=this._getOverlayItem();if(!this.view||null==t.x||null==t.y)return;const e=this.view,o=e.toMap(h(t.x+.5*t.boxWidth,t.y+.5*t.boxHeight));t.x=null,t.y=null,e.goTo({center:o}),this._freeHandWidth=t.boxWidth,this._freehandHeight=t.boxHeight,"MAP_ONLY"===this.templateOptions.layout&&(this.templateOptions.width=this._freeHandWidth,this.templateOptions.height=this._freehandHeight),this.templateOptions.scale=this.view.scale,this._updateOverLayItem()}};t([f()],q.prototype,"_serviceTemplateCustomTextElements",void 0),t([f()],q.prototype,"_templateToLayoutInfo",void 0),t([f()],q.prototype,"allowedFormats",void 0),t([f()],q.prototype,"allowedLayouts",void 0),t([f({type:z})],q.prototype,"browseTemplates",void 0),t([f({type:z})],q.prototype,"defaultTemplates",void 0),t([f()],q.prototype,"error",void 0),t([f()],q.prototype,"extraParameters",void 0),t([f()],q.prototype,"includeDefaultTemplates",void 0),t([f({readOnly:!0})],q.prototype,"effectivePrintServiceUrl",null),t([f()],q.prototype,"effectiveTemplateCustomTextElements",null),t([f()],q.prototype,"layoutTemplateInfo",null),t([f({type:I})],q.prototype,"portal",void 0),t([f()],q.prototype,"portalTemplateIds",void 0),t([f()],q.prototype,"printPreviewEnabled",void 0),t([f()],q.prototype,"printServiceUrl",void 0),t([f()],q.prototype,"printTimeout",void 0),t([f({readOnly:!0})],q.prototype,"state",null),t([f({readOnly:!0})],q.prototype,"templatesInfo",void 0),t([f()],q.prototype,"updateDelay",void 0),t([f()],q.prototype,"view",void 0),t([f()],q.prototype,"templateCustomTextElements",void 0),t([f({type:F})],q.prototype,"templateOptions",void 0),t([f()],q.prototype,"layoutTemplateNorthArrowInfo",null),q=t([v("esri.widgets.Print.PrintViewModel")],q);const J=q;export{J as default};
|
|
5
|
+
import{_ as t}from"../../chunks/tslib.es6.js";import"../../geometry.js";import{id as e}from"../../kernel.js";import i from"../../request.js";import{isSome as o}from"../../core/arrayUtils.js";import r from"../../core/Collection.js";import s from"../../core/Error.js";import{JSONMap as a}from"../../core/jsonMap.js";import{clone as l}from"../../core/lang.js";import n from"../../core/Loadable.js";import{isAbortError as p}from"../../core/promiseUtils.js";import{watch as m,initial as u}from"../../core/reactiveUtils.js";import{createScreenPoint as h}from"../../core/screenUtils.js";import{convertUnit as c,getMetersPerUnitForSR as d,inchesPerMeter as y}from"../../core/unitUtils.js";import{property as f}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as v}from"../../core/accessorSupport/decorators/subclass.js";import{formatDate as w,convertDateFormatToIntlOptions as T}from"../../intl/date.js";import{getLanguage as I}from"../../intl/locale.js";import _ from"../../portal/Portal.js";import g from"../../portal/PortalQueryParams.js";import{execute as O}from"../../rest/geoprocessor/execute.js";import{submitJob as b}from"../../rest/geoprocessor/submitJob.js";import{execute as P,getTasks as x,getMode as L}from"../../rest/print.js";import{fromJSON as S}from"../../rest/support/fileFormat.js";import{fromJSON as j}from"../../rest/support/layoutTemplate.js";import E from"../../rest/support/PrintParameters.js";import U from"../../rest/support/PrintTemplate.js";import{getExtent as k}from"../../views/2d/viewpointUtils.js";import{ViewEventPriorities as C}from"../../views/input/InputManager.js";import H from"../../views/overlay/BoxOverlayItem.js";import A from"./CustomTemplate.js";import D from"./TemplateOptions.js";import F from"../../geometry/Extent.js";const M=/.+\.arcgis\.com$/i,W=/(\/GPServer\/).+/i,N=new a({inch:"inches",foot:"feet",yard:"yards",mile:"miles","nautical-mile":"nautical-miles",millimeter:"millimeters",centimeter:"centimeters",decimeter:"decimeters",meter:"meters",kilometer:"kilometers"}),V=r.ofType(A);function q(t){t.layoutOptions??={},t.layoutOptions.customTextElements??=[];const e="date";if(!t.layoutOptions.customTextElements.find((t=>e in t))){const{customTextElements:e}=t.layoutOptions;let i=w(Date.now(),T("short-date"));"ar"===I()&&(i=""+i),e.push({date:i})}}let z=class extends n{constructor(t){super(t),this._serviceTemplateCustomTextElements=null,this._layoutToTemplateInfo=new Map,this._isFreeHand=!1,this._freeHandWidth=0,this._freehandHeight=0,this._asyncPrintTaskUrl=null,this._layoutInfoTaskUrl=null,this.allowedFormats="all",this.allowedLayouts="all",this.browseTemplates=new V,this.defaultTemplates=new V,this.error=null,this.extraParameters=null,this.includeDefaultTemplates=!0,this.portal=_.getDefault(),this.portalTemplateIds=[],this.showPrintAreaEnabled=!1,this.printServiceUrl=null,this.printTimeout=12e4,this.templatesInfo=null,this.updateDelay=1e3,this.view=null,this.templateCustomTextElements=null,this.templateOptions=new D}initialize(){this.addHandles(m((()=>this.showPrintAreaEnabled),(t=>{t?this._enablePrintPreview():(this.removeHandles("overlay-handler"),this.view?.overlay?.removeItem(this._getOverlayItem()))})))}destroy(){this.removeHandles("overlay-handler"),this.view&&(this._overlayItem&&(this.view.overlay?.removeItem(this._overlayItem),this._overlayItem.destroy(),this._overlayItem=null),this.view=null)}get effectivePrintServiceUrl(){return this.printServiceUrl??null}get effectiveTemplateCustomTextElements(){if(!this._serviceTemplateCustomTextElements)return{};const t=l(this._serviceTemplateCustomTextElements);return this.templateCustomTextElements&&Object.keys(this.templateCustomTextElements).forEach((e=>{const i=t[e];if(i){const t=this.templateCustomTextElements?.[e];i.forEach((e=>{const[i]=Object.entries(e)[0];t?.forEach((t=>{const[o,r]=Object.entries(t)[0];i===o&&(e[i]=r)}))}))}})),Object.freeze(t)}get layoutTemplateInfo(){const t=this.templateOptions.layoutItem?.id??this.templateOptions.layout;return t?this._layoutToTemplateInfo.get(t):null}get state(){return"loading"===this.loadStatus?"initializing":"failed"===this.loadStatus||this.error?"error":"loaded"===this.loadStatus&&this.view?.ready?"ready":"disabled"}get layoutTemplateNorthArrowInfo(){return this.layoutTemplateInfo?.layoutOptions?.mapSurroundInfos?this.layoutTemplateInfo.layoutOptions.mapSurroundInfos.find((t=>"CIMMarkerNorthArrow"===t.type)):null}async load(t){return this.addResolvingPromise(this._loadResources(t).catch((t=>this.error=t))),this}async print(t){const{view:e,extraParameters:i,updateDelay:o}=this;if(!e)throw new s("print:view-required","view is not set");q(t);const r=this._getOverlayItem(),a=t.scalePreserved||!this.showPrintAreaEnabled?void 0:k(new F,e.viewpoint,"MAP_ONLY"===t.layout?[t.exportOptions.width,t.exportOptions.height]:[r.boxWidth,r.boxHeight]),l=new E({view:e,template:t,extent:a,extraParameters:i,updateDelay:o});try{const e=!!t.layoutItem?.id&&(this.portalTemplateIds.includes(t.layoutItem.id)||this.browseTemplates.some((e=>e.layoutItem?.id===t.layoutItem?.id)));return await P(e&&this._asyncPrintTaskUrl?this._asyncPrintTaskUrl:this.effectivePrintServiceUrl,l,{timeout:this.printTimeout})}catch(n){throw new s("print:export-error","An error occurred while exporting the web map.",{error:n})}}toPrintTemplate({attributionEnabled:t,author:e,copyright:i,customTextElements:o,dpi:r,forceFeatureAttributes:a,format:l,height:n,includeTables:p,layout:m,layoutItem:u,legendEnabled:h,northArrowEnabled:c,scale:d,scaleEnabled:y,title:f,width:v}){if(!m)throw new s("print:layout-required","layout is not set");const w=new U({attributionVisible:t,forceFeatureAttributes:a,format:l,includeTables:p,layout:m,layoutItem:u,layoutOptions:{authorText:e||"",copyrightText:i||"",customTextElements:o,titleText:f||""},outScale:d??0,scalePreserved:y});v&&(w.exportOptions.width=v),n&&(w.exportOptions.height=n),r&&(w.exportOptions.dpi=r),!h&&w.layoutOptions&&(w.layoutOptions.legendLayers=[]);const T=this.layoutTemplateNorthArrowInfo;if(T){!(T.visible===c)&&w.layoutOptions&&(w.layoutOptions.elementOverrides={[T.name]:{visible:c}})}return w}async fetchLayoutTemplateInfo(t,e){if(!t.layoutItem?.id)return;const i=await this._fetchPortalLayoutTemplateInfo(t.layoutItem,e);this._layoutToTemplateInfo.set(t.layoutItem.id,i),t.layoutTemplateInfo=i;const{hasLegend:o,mapSurroundInfos:r}=i.layoutOptions,s=r.some((({type:t,visible:e})=>"CIMMarkerNorthArrow"===t&&e));t.layoutOptions={legend:o,northArrow:s}}getLayoutTemplateInfo(t){return this._layoutToTemplateInfo.get(t)}async addPortalTemplate(t){const e=new A({label:t.title,layoutItem:t});this.browseTemplates.add(e)}removePortalTemplate(t){t.layoutItem?.id&&this.templateOptions.layoutItem?.id===t.layoutItem.id&&(this.templateOptions.layout=this.defaultTemplates.length||this.browseTemplates.length?null:this.templatesInfo?.layout?.defaultValue,this.templateOptions.layoutItem=null),this._layoutToTemplateInfo.delete(t.layoutItem.id),this.browseTemplates.remove(t)}async _loadResources(t){let e=[];if(this.printServiceUrl)this._set("effectivePrintServiceUrl",this.printServiceUrl),await this._updateLayoutInfoTaskUrl(this.effectivePrintServiceUrl);else{if(this.destroyed)return;try{await this.portal.load(t)}catch(n){throw new s("print:could-not-load-portal","Cannot load print resource information from portal",{error:n,url:this.effectivePrintServiceUrl})}if(this.portal.helperServices){const{asyncPrintTask:t,layoutInfoTask:i,printTask:o}=this.portal.helperServices;o&&(this._set("effectivePrintServiceUrl",o.url),e=o.templates?.map((t=>A.fromJSON(t)))??[]),this._asyncPrintTaskUrl=t?.url,await this._updateLayoutInfoTaskUrl(i?.url||this.effectivePrintServiceUrl)}}this.defaultTemplates.addMany(e);const i=this.effectivePrintServiceUrl?.toLowerCase().split("/");if(!i?.includes("gpserver"))throw new s("print:invalid-print-service-url","Can't fetch print templates information from provided URL",{url:this.effectivePrintServiceUrl});const o=!M.test(this.portal.url)||this.portal.user&&"anonymous"!==this.portal.authMode,[r,a,l]=await Promise.all([this._getPrintServiceLayouts(t),this._getPrintServiceTemplates(t),o?this._getPortalCustomTemplates(t):null]);if(this._processPrintServiceLayouts(r),this._processPrintServiceTemplates(a),this._processPortalTemplates(l),this.templateOptions.layoutItem?.id){const e=this.templateOptions.layoutItem.id;let i=this.defaultTemplates.find((t=>t.layoutItem?.id===e));i||(i=new A({label:this.templateOptions.layoutItem.title,layoutItem:this.templateOptions.layoutItem})),await this.fetchLayoutTemplateInfo(i,t),this.templateOptions.layout=e}this._updateOverLayItem()}async _updateLayoutInfoTaskUrl(t,e){if(!t)return;const i=(await x(t,e)).find((t=>t.includes("Get Layout Templates Info")));i&&(this._layoutInfoTaskUrl=t.replace(W,`$1${encodeURI(i)}`))}async _getPortalCustomTemplates(t){if(this.printServiceUrl)return[];const{layoutGroupQuery:e}=this.portal;if(!e)return[];const i=new g({query:e,disableExtraQuery:!0}),o=await this.portal.queryGroups(i,t);if(!o.total)return[];const r=o.results[0],s=new g({num:100,query:"type:Layout"}),a=(await r.queryItems(s,t)).results;return a.length?a.map((t=>new A({label:t.title,layoutItem:t}))):[]}async _fetchPortalLayoutTemplateInfo(t,i){const{id:o}=t,r=this._layoutInfoTaskUrl;if(!r)throw new s("print:invalid-layout-info-task-url","Can't fetch layout template info",{url:r});"public"!==t.access&&e&&await e.getCredential(r);const a={Layout_Item_ID:JSON.stringify({id:o})};return(await this._fetchLayoutTemplateInfos(a,i))[0]}async _fetchLayoutTemplateInfos(t,e){const i=this._layoutInfoTaskUrl;if(!i)throw new s("print:invalid-layout-info-task-url","Can't fetch layout template info",{url:i});if("async"===await L(i)){const o=await b(i,t,void 0,e||void 0);await o.waitForJobCompletion({interval:1e3});return(await o.fetchResultData("Output_JSON")).value}return(await O(i,t,null,e)).results[0].value}_processPortalTemplates(t){if(t){this.defaultTemplates.addMany(t);for(const e of t)e.layoutItem?.id&&this.portalTemplateIds.push(e.layoutItem.id)}}_processPrintServiceTemplates(t){this._set("templatesInfo",t)}async _getPrintServiceLayouts(t){let e=[];try{e=await this._fetchLayoutTemplateInfos(void 0,t)}catch{}return e}_processPrintServiceLayouts(t){const e={};for(const i of t){const{layoutTemplate:t,layoutOptions:o}=i,r=j(t);this._layoutToTemplateInfo.set(r,i),e[r]=o.customTextElements}this._serviceTemplateCustomTextElements=Object.freeze(e)}async _getPrintServiceTemplates(t){let e;try{({data:e}=await i(this.effectivePrintServiceUrl,{...t,query:{f:"json"},timeout:this.printTimeout}))}catch(l){throw p(l)?l:new s("print:unavailable-service-info","Can't fetch templates info from service",{error:l})}const{parameters:o}=e,r=o.find((({name:t})=>"Format"===t)),a=o.find((({name:t})=>"Layout_Template"===t));return{format:this._getFormat(r),layout:this._getLayout(a)}}_getFormat(t){const e="all"===this.allowedFormats?t.choiceList:t.choiceList.filter((t=>this.allowedFormats.includes(S(t)))),i=(e.length?e:t.choiceList).map(S).filter(o),r=S(t.defaultValue),s=i.includes(r)?r:i[0];return{choiceList:i,defaultValue:s}}_getLayout(t){const e=t.choiceList.filter((t=>"map_only"!==t.toLowerCase())),i="all"===this.allowedLayouts?e:e.filter((t=>this.allowedLayouts.includes(j(t)))),r=(i.length?i:e).map(j).filter(o),s=j(t.defaultValue),a=r.includes(s)?s:r.find((t=>/(?=.*letter)(?=.*landscape)/i.test(t)))??r.find((t=>/(?=.*a4)(?=.*landscape)/i.test(t)))??r[0];return{choiceList:r,defaultValue:a}}_getOverlayItem(){return this._overlayItem||(this._overlayItem=new H({strokeDash:[5],strokeWidth:2,strokeColor:[30,144,255,255]})),this._overlayItem}_enablePrintPreview(){if(!this.view?.overlay)return;const t=this.templateOptions,e=this._getOverlayItem();this.addHandles([m((()=>[t.width,t.height,t.scaleEnabled,t.scale,t.layout,t.layoutItem,this.view?.scale,this.view?.size,this.view?.state.paddedViewState.size,this.view?.state.padding]),(()=>this._updateOverLayItem()),u),this.view?.on("drag",["Shift"],(t=>this._handleDrag(t)),C.WIDGET),this.view?.on("key-down",["Escape"],(()=>this._resetDrag()),C.WIDGET)],"overlay-handler"),this.view.overlay.addItem(e)}_updateOverLayItem(){if(!this.view)return;const t=this.templateOptions,e=this._getOverlayItem(),i=t.layoutItem?.id??t.layout,o=this.view,r=o.spatialReference,[s,a]=o.state.paddedViewState.size,l=o.state.padding;let n=0,p=0;if("MAP_ONLY"===i)null!=t.width&&null!=t.height&&(n=t.width,p=t.height);else if(i){const{webMapFrameSize:e,pageUnits:o}=this._layoutToTemplateInfo.get(i)??{};if(e&&o)if(this._isFreeHand){const t=e[0]/e[1];n=this._freeHandWidth,p=this._freehandHeight,n>p?p=n/t:n=p*t}else{const t=N.fromJSON(o.toLowerCase()),i=r.unit;n=c(e[0],t,i),p=c(e[1],t,i)}if(!this._isFreeHand)if(t.scaleEnabled&&t.scale){const e=d(r)*y*t.dpi;n*=e,p*=e}else if(0===n||0===p)n=s,p=a;else{const t=(s-.1*s)/n,e=(a-.1*a)/p,i=Math.min(t,e);n*=i,p*=i}}const{scaleEnabled:m,scale:u}=t,h=m&&u?u/this.view.scale:1;e.boxWidth=n*h||s,e.boxHeight=p*h||a,l&&(e.padding=l),e.backgroundWidth=s??0,e.backgroundHeight=a??0}_resetDrag(){this._isFreeHand=!1,this._updateOverLayItem()}_handleDrag(t){switch(t.action){case"start":this._start();break;case"update":this._update(t);break;case"end":this._end()}t.stopPropagation()}_start(){this._isFreeHand=!0}_update(t){const e=this._getOverlayItem(),{x:i,y:o}=t,{x:r,y:s}=t.origin;i>r?(e.x=r,e.boxWidth=i-r):(e.x=i,e.boxWidth=r-i),o>s?(e.y=s,e.boxHeight=o-s):(e.y=o,e.boxHeight=s-o)}_end(){const t=this._getOverlayItem();if(!this.view||null==t.x||null==t.y)return;const e=this.view,i=e.toMap(h(t.x+.5*t.boxWidth,t.y+.5*t.boxHeight));t.x=null,t.y=null,e.goTo({center:i}),this._freeHandWidth=t.boxWidth,this._freehandHeight=t.boxHeight,"MAP_ONLY"===this.templateOptions.layout&&(this.templateOptions.width=this._freeHandWidth,this.templateOptions.height=this._freehandHeight),this.templateOptions.scale=this.view.scale,this._updateOverLayItem()}};t([f()],z.prototype,"_serviceTemplateCustomTextElements",void 0),t([f()],z.prototype,"_layoutToTemplateInfo",void 0),t([f()],z.prototype,"allowedFormats",void 0),t([f()],z.prototype,"allowedLayouts",void 0),t([f({type:V})],z.prototype,"browseTemplates",void 0),t([f({type:V})],z.prototype,"defaultTemplates",void 0),t([f()],z.prototype,"error",void 0),t([f()],z.prototype,"extraParameters",void 0),t([f()],z.prototype,"includeDefaultTemplates",void 0),t([f({readOnly:!0})],z.prototype,"effectivePrintServiceUrl",null),t([f()],z.prototype,"effectiveTemplateCustomTextElements",null),t([f()],z.prototype,"layoutTemplateInfo",null),t([f({type:_})],z.prototype,"portal",void 0),t([f()],z.prototype,"portalTemplateIds",void 0),t([f()],z.prototype,"showPrintAreaEnabled",void 0),t([f()],z.prototype,"printServiceUrl",void 0),t([f()],z.prototype,"printTimeout",void 0),t([f({readOnly:!0})],z.prototype,"state",null),t([f({readOnly:!0})],z.prototype,"templatesInfo",void 0),t([f()],z.prototype,"updateDelay",void 0),t([f()],z.prototype,"view",void 0),t([f()],z.prototype,"templateCustomTextElements",void 0),t([f({type:D})],z.prototype,"templateOptions",void 0),t([f()],z.prototype,"layoutTemplateNorthArrowInfo",null),z=t([v("esri.widgets.Print.PrintViewModel")],z);const J=z;export{J 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.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import t from"../core/Collection.js";import{clone as l}from"../core/lang.js";import{watch as a}from"../core/reactiveUtils.js";import{addProxy as i,hasSameOrigin as o}from"../core/urlUtils.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import{subclass as s}from"../core/accessorSupport/decorators/subclass.js";import{getToken as r}from"../rest/utils.js";import{toJSON as c}from"../rest/support/fileFormat.js";import p from"./Widget.js";import d from"./Print/FileLink.js";import u from"./Print/PrintViewModel.js";import{loadCalciteComponents as m}from"./support/componentsUtils.js";import{globalCss as h}from"./support/globalCss.js";import{Heading as b}from"./support/Heading.js";import{legacyIcon as y}from"./support/legacyIcon.js";import{isRTL as _,isActivationKey as f}from"./support/widgetUtils.js";import{messageBundle as g}from"./support/decorators/messageBundle.js";import{tsx as v}from"./support/jsxFactory.js";const w=t.ofType(d),T="MAP_ONLY";var x;!function(e){e.layout="layoutTab",e.mapOnly="mapOnlyTab",e.export="exportTab"}(x||(x={}));const C="esri-print",O=`${C}__advanced-options-button`,I={base:C,headerTitle:`${C}__header-title`,inputText:`${C}__input-text`,layoutTabList:`${C}__layout-tab-list`,layoutTab:`${C}__layout-tab`,layoutSection:`${C}__layout-section`,mapOnlySection:`${C}__map-only-section`,scaleInput:`${C}__scale-input`,panelItemsCentered:`${C}__panel-items--centered`,loader:`${C}__loader`,advancedOptionsButton:O,advancedOptionsButtonContainer:`${O}-container`,advancedOptionsButtonTitle:`${O}-title`,advancedOptionsButtonIconOpened:`${O}-icon--opened`,advancedOptionsButtonIconClosed:`${O}-icon--closed`,advancedOptionsButtonIconClosed_RTL:`${O}-icon--closed-rtl`,refreshButton:`${C}__refresh-button`,swapButton:`${C}__swap-button`,printButton:`${C}__export-button`,templateSelectContainer:`${C}__template-select-container`,templateSelectBlock:`${C}__template-select-block`,templateSelectIcon:`${C}__template-select-icon`,formSectionContainer:`${C}__form-section-container`,formInputLabel:`${C}__form-input-label`,formCheckboxLabel:`${C}__form-checkbox-label`,advancedOptionsSection:`${C}__advanced-options-section`,advancedOptionsContainer:`${C}__advanced-options-container`,authorInfoContainer:`${C}__author-info-container`,browseTemplateButtonContainer:`${C}__browse-template-button-container`,copyrightInfoContainer:`${C}__copyright-info-container`,exportedFilesContainer:`${C}__export-panel-container`,exportedFilesTitle:`${C}__export-title`,exportedFile:`${C}__exported-file`,exportedFileLink:`${C}__exported-file-link`,exportedFileLinkTitle:`${C}__exported-file-link-title`,exportedFilesEmpty:`${C}__exported-files-empty`,legendInfoContainer:`${C}__legend-info-container`,printWidgetContainer:`${C}__container`,content:`${C}__content`,panelContainer:`${C}__panel-container`,scaleInfoContainer:`${C}__scale-info-container`,scaleInputContainer:`${C}__scale-input-container`,sizeContainer:`${C}__size-container`,panelError:`${C}__panel--error`,exportedFileError:`${C}__exported-file--error`,exportedFileLoader:`${C}__exported-file--loader`,exportSection:`${C}__export-section`,exportSectionCentered:`${C}__export-section--centered`,templateButtonContainer:`${C}__template-button-container`,templateDoneButton:`${C}__template-done-button`,templateSelectFlowItemContainer:`${C}__template-select-flow-item-container`,templateSelectFlowItemContent:`${C}__template-select-flow-item-content`};function k(e,t,l,a){const i=l/t,o=a/t;return{width:Math.round(e*i),height:Math.round(e*o)}}function $(e){return!isNaN(e)&&e>0}function L(e){return e?.toUpperCase()===T}function M(e){const{state:t,extension:l}=e;switch(t){case"pending":return"spinner";case"error":return"exclamation-mark-circle";default:return l?.toLowerCase()?.includes("pdf")?"file-pdf":"file"}}function S(e,t){return!!t&&e.some((e=>e.layoutItem?.id===t||e.layout===t))}let E=class extends p{constructor(e,t){super(e,t),this._activeTabFocusRequested=!1,this._awaitingServerResponse=!1,this._exportedFileNameMap={},this._selectedTab=x.layout,this._pendingExportScroll=!1,this._rootNode=null,this._selectedLayout=null,this._abortController=null,this._showTemplates=!1,this.browseTemplateButtonOnClick=null,this.exportedLinks=new w,this.headingLevel=3,this.messagesCommon=null,this.viewModel=new u,this._onInput=e=>{this._selectedTab===x.layout?this.templateOptions.title=e.target.value:this._selectedTab===x.mapOnly&&(this.templateOptions.fileName=e.target.value)},this._removeLink=e=>{const t=e.currentTarget["data-item"];t&&this.exportedLinks.remove(t)},this._handleLinkClick=e=>{const t=e.currentTarget["data-item"];if(!t||"ready"!==t.state||!t.url)return;const l=r(this.viewModel.effectivePrintServiceUrl),a=t.url,i=document.createElement("a");if(i.target="_blank",i.href=a,i.rel="noreferrer",i.download=t.formattedName??"",!l)return i.click(),void e.stopPropagation();if(!e.isTrusted)return void e.stopPropagation();e.preventDefault();const o=new URL(a);o.searchParams.set("token",l),i.href=o.href,i.click(),i.href=a},this._focusOnTabChange=this._focusOnTabChange.bind(this)}initialize(){this.addHandles([a((()=>[this.templateOptions.format,this.viewModel.templatesInfo?.format.defaultValue]),(([e,t])=>{if(t&&!e)return void(this.templateOptions.format=t);if(!e||!t||!this.viewModel.templatesInfo)return;if(this.viewModel.templatesInfo.format.choiceList.includes(e))return;const l=this.viewModel.templatesInfo.format.choiceList.find((t=>t.toUpperCase().includes(`(${e.toUpperCase()})`)));this.templateOptions.format=l??t})),a((()=>[this.templateOptions.layout,this.viewModel.templatesInfo?.layout.defaultValue]),(async([e,t])=>{if(this._selectedTab=L(e)?x.mapOnly:x.layout,this._selectedTab!==x.layout)return;const{includeDefaultTemplates:a,viewModel:i,_selectedLayout:o}=this,{portalTemplateIds:n,browseTemplates:s,templatesInfo:r}=i,c=i.defaultTemplates.filter((({layoutItem:e})=>n.includes(e?.id))),p=i.defaultTemplates.filter((({layoutItem:e})=>!n.includes(e?.id))),d=a&&p.length;if(e){(d?S(p,e):r?.layout.choiceList.includes(e))||S(c,e)||S(s,e)||(this.templateOptions.layout=null,this.templateOptions.layoutItem=null)}else{o&&((d?S(p,o):r?.layout.choiceList.includes(o))||S(c,o)||S(s,o))?await this._applyTemplate(o):(this.templateOptions.layout=null,this.templateOptions.layoutItem=null),this.templateOptions.layout||d||!t||await this._applyTemplate(t)}this._selectedLayout=this.templateOptions.layout,this._selectedLayout||(this.printPreviewEnabled=!1);const u=!!this.templateOptions.layout&&this.viewModel.effectiveTemplateCustomTextElements[this.templateOptions.layout];this.templateOptions.customTextElements=u?l(u):null})),a((()=>this.templateOptions.dpi),(e=>{e<=0&&(this.templateOptions.dpi=1)})),a((()=>this.viewModel.view?.scale),(e=>{!e||this.templateOptions.scaleEnabled&&this.templateOptions.scale||(this.templateOptions.scale=e)}))]);const{height:e,width:t}=this.templateOptions;this.templateOptions.width=t||800,this.templateOptions.height=e||1100;const i=setTimeout((()=>{this._awaitingServerResponse=!0,this.scheduleRender()}),500);this.viewModel.load().then((()=>{clearTimeout(i),this._awaitingServerResponse=!1}))}loadDependencies(){return m({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),block:()=>import("@esri/calcite-components/dist/components/calcite-block.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),checkbox:()=>import("@esri/calcite-components/dist/components/calcite-checkbox.js"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox.js"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item.js"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow.js"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),input:()=>import("@esri/calcite-components/dist/components/calcite-input.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),"list-item-group":()=>import("@esri/calcite-components/dist/components/calcite-list-item-group.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch.js")})}destroy(){this.viewModel.destroy()}get allowedFormats(){return this.viewModel.allowedFormats}set allowedFormats(e){this.viewModel.allowedFormats=e}get allowedLayouts(){return this.viewModel.allowedLayouts}set allowedLayouts(e){this.viewModel.allowedLayouts=e}get error(){return this.viewModel.error}get extraParameters(){return this.viewModel.extraParameters}set extraParameters(e){this.viewModel.extraParameters=e}get icon(){return"print"}set icon(e){this._overrideIfSome("icon",e)}get includeDefaultTemplates(){return this.viewModel.includeDefaultTemplates}set includeDefaultTemplates(e){this.viewModel.includeDefaultTemplates=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get portal(){return this.viewModel.portal}set portal(e){this.viewModel.portal=e}get printPreviewEnabled(){return this.viewModel.printPreviewEnabled}set printPreviewEnabled(e){this.viewModel.printPreviewEnabled=e}get printServiceUrl(){return this.viewModel.printServiceUrl}set printServiceUrl(e){this.viewModel.printServiceUrl=e}get templateCustomTextElements(){return this.viewModel.templateCustomTextElements}set templateCustomTextElements(e){this.viewModel.templateCustomTextElements=e}get templateOptions(){return this.viewModel.templateOptions}set templateOptions(e){this.viewModel.templateOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}render(){const{messages:e,templateOptions:t,viewModel:l,view:a}=this,{attributionEnabled:i,author:o,copyright:n,dpi:s,format:r,height:p,layout:d,legendEnabled:u,northArrowEnabled:m,scaleEnabled:f,scale:g,width:w}=t,T="ready"!==l.state||this._awaitingServerResponse||!d,C=this._renderTitleOrFileNameSection(),O=v("div",{class:I.formSectionContainer},v("calcite-label",null,e.fileFormatTitle,v("calcite-combobox",{clearDisabled:!0,label:e.formatDefaultOption,maxItems:6,placeholder:e.formatDefaultOption,selectionMode:"single-persist",onCalciteComboboxChange:({target:e})=>{this.templateOptions.format=e.selectedItems[0].value}},l.templatesInfo?.format?.choiceList.sort().map(((e,t)=>v("calcite-combobox-item",{key:`file-format-${t}`,selected:e===this.templateOptions.format,textLabel:c(e),value:e})))))),k=v("calcite-label",{layout:"inline"},v("calcite-switch",{checked:this.printPreviewEnabled,disabled:!d,onCalciteSwitchChange:e=>{this.printPreviewEnabled=!!e.target.checked}}),e.printPreview),$=v("div",null,v("div",{class:I.formSectionContainer},v("calcite-label",null,e.template,v("div",{class:I.templateSelectContainer,onclick:()=>{this._showTemplates=!0}},v("calcite-block",{class:I.templateSelectBlock,description:this.viewModel.getPageSizeLabel(d),heading:this._getTemplateLabel()}),v("calcite-icon",{class:I.templateSelectIcon,icon:_()?"chevron-left":"chevron-right",scale:"s"})))),k),L=v("div",{class:I.formSectionContainer},v("label",{class:I.formInputLabel},e.dpi,v("input",{bind:this,class:this.classes(I.inputText,h.input),"data-input-name":"dpi",min:"1",onchange:this._handleDPIChange,tabIndex:0,type:"number",value:`${s}`}))),M=v("div",{class:this.classes(I.scaleInfoContainer,I.formSectionContainer)},v("calcite-label",{layout:"inline"},v("calcite-checkbox",{bind:this,checked:f,"data-option-name":"scaleEnabled",tabIndex:0,onCalciteCheckboxChange:this._toggleInputValue}),e.scale),v("div",{class:I.scaleInputContainer},v("input",{"aria-label":e.scaleLabel,"aria-valuenow":`${g}`,bind:this,class:this.classes(I.inputText,h.input,I.scaleInput),"data-input-name":"scale",disabled:!f,onchange:this._updateInputValue,role:"spinbutton",tabIndex:0,type:"number",value:`${g}`}),v("button",{"aria-label":e.reset,bind:this,class:this.classes(h.widgetButton,I.refreshButton,y.refresh),onclick:this._resetToCurrentScale,tabIndex:0,type:"button"}))),S=v("div",{"aria-labelledby":`${this.id}__advancedOptionsForLayout`,class:I.advancedOptionsContainer,key:"advanced-section-for-layout"},M,this.viewModel.layoutTemplateInfo?.layoutOptions?.hasAuthorText??1?v("div",{class:this.classes(I.authorInfoContainer,I.formSectionContainer),key:"author-info"},v("label",{class:I.formInputLabel},e.author,v("input",{bind:this,class:this.classes(I.inputText,h.input),"data-input-name":"author",onchange:this._updateInputValue,tabIndex:0,type:"text",value:o??""}))):null,this.viewModel.layoutTemplateInfo?.layoutOptions?.hasCopyrightText??1?v("div",{class:this.classes(I.copyrightInfoContainer,I.formSectionContainer),key:"copyright-text"},v("label",{class:I.formInputLabel},e.copyright,v("input",{bind:this,class:this.classes(I.inputText,h.input),"data-input-name":"copyright",onchange:this._updateInputValue,tabIndex:0,type:"text",value:n??""}))):null,L,this.viewModel.layoutTemplateInfo?.layoutOptions?.hasLegend??1?v("div",{class:this.classes(I.legendInfoContainer,I.formSectionContainer),key:"legend-info"},v("calcite-label",{layout:"inline"},v("calcite-checkbox",{bind:this,checked:u,"data-option-name":"legendEnabled",tabIndex:0,onCalciteCheckboxChange:this._toggleInputValue}),e.legend)):null,this.viewModel.layoutTemplateNorthArrowInfo??1?v("div",{class:this.classes(I.legendInfoContainer,I.formSectionContainer),key:"north-arrow"},v("calcite-label",{layout:"inline"},v("calcite-checkbox",{bind:this,checked:m,"data-option-name":"northArrowEnabled",tabIndex:0,onCalciteCheckboxChange:this._toggleInputValue}),e.northArrow)):null,this._renderCustomTextElementSection()),E=v("div",{"aria-labelledby":`${this.id}__advancedOptionsForMapOnly`,class:I.advancedOptionsContainer},M,L,v("div",{class:I.formSectionContainer},v("calcite-label",{layout:"inline"},v("calcite-checkbox",{bind:this,checked:i,"data-option-name":"attributionEnabled",tabIndex:0,onCalciteCheckboxChange:this._toggleInputValue}),e.attribution)),this._renderCustomTextElementSection()),F=this.exportedLinks.toArray(),P=this._renderExportedLink(F),j={[I.exportSectionCentered]:!F.length},A=this._selectedTab===x.layout?v("section",{"aria-labelledby":`${this.id}__layoutTab`,class:I.layoutSection,id:`${this.id}__layoutContent`,key:"esri-print__layoutContent",role:"tabpanel"},v("div",{class:I.panelContainer},this.viewModel.layoutTemplateInfo?.layoutOptions?.hasTitleText??1?C:null,$,this._selectedTab===x.layout?O:null,v("calcite-block",{"aria-label":e.advancedOptions,class:this.classes(I.panelContainer,I.advancedOptionsSection),collapsible:!0,disabled:!d,heading:e.advancedOptions,id:"advancedOptionsForLayout",key:"advanced-options-for-layout"},S))):this._selectedTab===x.mapOnly?v("section",{"aria-labelledby":`${this.id}__mapOnlyTab`,class:I.mapOnlySection,id:`${this.id}__mapOnlyContent`,key:"esri-print__mapOnlyContent",role:"tabpanel"},v("div",{class:I.panelContainer},C,O,v("div",null,v("div",{class:this.classes(I.sizeContainer,I.formSectionContainer)},v("label",{class:I.formInputLabel},e.width,v("input",{bind:this,class:this.classes(I.inputText,h.input),"data-input-name":"width",onchange:this._updateInputValue,tabIndex:0,type:"number",value:`${w}`})),v("label",{class:I.formInputLabel},e.height,v("input",{bind:this,class:this.classes(I.inputText,h.input),"data-input-name":"height",onchange:this._updateInputValue,tabIndex:0,type:"number",value:`${p}`})),v("button",{"aria-label":e.swap,bind:this,class:this.classes(h.widgetButton,I.swapButton,y.swap),onclick:this._switchInput,tabIndex:0,type:"button"})),k),v("calcite-block",{"aria-label":e.advancedOptions,class:this.classes(I.panelContainer,I.advancedOptionsSection),collapsible:!0,heading:e.advancedOptions,id:"advancedOptionsForMapOnly",key:"advanced-options-for-map-only"},E))):v("section",{"aria-labelledby":`${this.id}__exportTab`,class:this.classes(I.exportSection,j),id:`${this.id}__exportContent`,key:"esri-print__exportContent",role:"tabpanel"},v("div",{class:I.panelContainer},v("div",{afterUpdate:this._scrollExportIntoView,bind:this,class:I.exportedFilesContainer},0===F.length?v("div",{class:I.exportedFilesEmpty},v("calcite-icon",{icon:"file",scale:"l"}),v("div",null,v(b,{class:I.exportedFilesTitle,level:this.headingLevel},e.noExportedFiles),v("div",null,e.exportHint))):P))),B={[h.buttonDisabled]:T||!d&&!r},D=!a||"2d"!==a.type,N=v("div",{class:I.panelError},D?e.sceneViewError:e.serviceError),V=F.some((({state:e})=>"pending"===e)),U=v("div",{class:I.content,key:"panel"},v("div",null,v("ul",{bind:this,class:I.layoutTabList,onclick:this._toggleLayoutPanel,onkeydown:this._handleLayoutPanelKeyDown,role:"tablist"},v("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${this._selectedTab===x.layout}`,class:I.layoutTab,"data-tab-id":x.layout,id:`${this.id}__layoutTab`,role:"tab",tabIndex:0},e.layoutTab),v("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${this._selectedTab===x.mapOnly}`,class:I.layoutTab,"data-tab-id":x.mapOnly,id:`${this.id}__mapOnlyTab`,role:"tab",tabIndex:0},e.mapOnlyTab),v("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${this._selectedTab===x.export}`,class:I.layoutTab,"data-tab-id":x.export,id:`${this.id}__exportedFilesTab`,role:"tab",tabIndex:0},V?v("calcite-loader",{inline:!0,label:"loading",scale:"s"}):null,e.exportsTab)),A),this._selectedTab!==x.export?v("button",{"aria-label":e.exportDescription,bind:this,class:this.classes(I.printButton,h.button,B),disabled:T,onclick:this._handlePrintMap,tabIndex:0,type:"button"},e.export):null),R=v("calcite-flow",{key:"root-flow"},v("calcite-flow-item",{bind:this,key:"root-flow-item"},v("div",{class:I.printWidgetContainer},v("header",{class:I.headerTitle},e.export),this.error||D||!a?N:U)),this._renderChooseTemplateFlowItem()),z="initializing"===l.state,H=z?this._renderLoader():R,W={[I.panelItemsCentered]:z};return v("div",{bind:this,class:this.classes(I.base,h.widget,h.panel,W)},H)}_getTemplateLabel(){const{messages:e,includeDefaultTemplates:t,templateOptions:l,viewModel:a}=this,{layout:i}=l,o=(t?a.defaultTemplates.find((({layoutItem:e,layout:t})=>i===e?.id||i===t)):null)??a.browseTemplates.find((({layoutItem:e})=>i===e?.id));return o?.label?.replaceAll("_"," ")??e[i]??i?.replaceAll("_"," ")??e.selectTemplate}_renderChooseTemplateFlowItem(){if(!this._showTemplates)return null;const{includeDefaultTemplates:e,messages:t,viewModel:l}=this,{defaultTemplates:a,templatesInfo:i,browseTemplates:o,portalTemplateIds:n}=l,s=o.length?o.toArray().sort(((e,t)=>(e.label??"")>(t.label??"")?1:-1)).map(((e,a)=>{const i=e.layoutItem?.id??e.layout,o=l.getPageSizeLabel(i),n=i===this.templateOptions.layout;return v("calcite-list-item",{description:o,key:`browse-template-${a}`,label:e?.label?.replaceAll("_"," ")??t.untitled,selected:n,title:e.description??"",value:i},!o&&n&&e.layoutItem?.id?v("calcite-loader",{inline:!0,key:`browse-template-loader-${a}`,label:"loading",scale:"s",slot:"content-end"}):null,v("calcite-action",{icon:"trash",onclick:()=>l.removePortalTemplate(e),slot:"actions-end",text:"delete"}))})):null,r=a.length&&e?a.toArray().filter((({label:e,layoutItem:t})=>!L(e)&&n.includes(t?.id))).sort(((e,t)=>(e.label??"")>(t.label??"")?1:-1)).map(((e,a)=>{const i=e.layoutItem?.id??e.layout,o=l.getPageSizeLabel(i),n=i===this.templateOptions.layout;return v("calcite-list-item",{description:o,key:`portal-template-${i}-${n}`,label:e?.label?.replaceAll("_"," ")??t.untitled,selected:n,title:e.description??"",value:i},!o&&n&&e.layoutItem?.id?v("calcite-loader",{inline:!0,key:`portal-template-loader-${a}`,label:"loading",scale:"s",slot:"content-end"}):null)})):null,c=a.length&&e?a.toArray().filter((({label:e,layoutItem:t})=>!L(e)&&!n.includes(t?.id))).sort(((e,t)=>(e.label??"")>(t.label??"")?1:-1)).map(((e,a)=>{const i=e.layoutItem?.id??e.layout,o=l.getPageSizeLabel(i),n=i===this.templateOptions.layout;return v("calcite-list-item",{description:o,key:`default-template-${a}`,label:e?.label?.replaceAll("_"," ")??t.untitled,selected:n,title:e.description??"",value:i},!o&&n&&e.layoutItem?.id?v("calcite-loader",{inline:!0,key:`default-template-loader-${a}`,label:"loading",scale:"s",slot:"content-end"}):null)})):null,p=!i?.layout?.choiceList.length||e&&c?.length?null:i.layout.choiceList.map((e=>({label:t[e]??e.replaceAll("_"," "),value:e}))).sort(((e,t)=>e.label>t.label?1:0)).map((({label:e,value:t},a)=>v("calcite-list-item",{description:l.getPageSizeLabel(t),key:`service-template-${a}`,label:e,selected:t===this.templateOptions.layout,value:t}))),d=(s?.length??0)+(r?.length??0)+(c?.length??0)+(p?.length??0)>15;return v("calcite-flow-item",{bind:this,closable:!1,heading:t.chooseTemplate,key:"template-flow-item",onCalciteFlowItemBack:e=>{e.preventDefault(),this._showTemplates=!1}},v("div",{class:I.templateSelectFlowItemContainer},v("div",{class:I.templateSelectFlowItemContent},this.browseTemplateButtonOnClick?v("calcite-button",{appearance:"outline",class:I.browseTemplateButtonContainer,key:"browse-template-button",onclick:this.browseTemplateButtonOnClick},"Browse Templates"):null,v("calcite-list",{filterEnabled:d,key:"template-list",selectionMode:"single-persist",onCalciteListChange:({target:e})=>this._applyTemplate(e.selectedItems[0].value)},s?.length?v("calcite-list-item-group",{heading:t.myTemplates,key:"my-templates"},s):null,r?.length?v("calcite-list-item-group",{heading:`${t.organizationTemplates} (${t.beta})`,key:"org-templates"},r):null,s?.length||r?.length?c?.length?v("calcite-list-item-group",{heading:t.defaultTemplates,key:"default-templates"},c):null:c,s?.length||r?.length?p?.length?v("calcite-list-item-group",{heading:t.defaultTemplates,key:"service-templates"},p):null:p)),v("div",{class:I.templateButtonContainer},v("calcite-button",{class:I.templateDoneButton,onclick:()=>this._showTemplates=!1},this.messagesCommon.done))))}_renderCustomTextElementSection(){const{customTextElements:e}=this.templateOptions;return e?v("div",{class:I.formSectionContainer,key:"custom-text-elements"},e.map((e=>{const[t,l]=Object.entries(e)[0];return"date"===t?null:v("label",{key:t},t,v("input",{bind:this,class:this.classes(I.inputText,h.input),"data-input-custom":!0,"data-input-name":t,onchange:this._updateInputValue,type:"text",value:l}))}))):null}async _applyTemplate(e){if(this._abortController&&(this._abortController.abort(),this._abortController=null),!e)return;const t=this.viewModel.defaultTemplates.find((({layoutItem:t})=>e===t?.id))??this.viewModel.browseTemplates.find((({layoutItem:t})=>e===t?.id));if(!t)return this.templateOptions.layout=e,void(this.templateOptions.layoutItem=null);const{format:l,layoutItem:a}=t,i=a?.id??t.layout??this.templateOptions.layout;if(this.templateOptions.layout=i,!t.layoutOptions)try{this._abortController=new AbortController,await this.viewModel.fetchLayoutTemplateInfo(t,{signal:this._abortController.signal})}catch(s){return}finally{this._abortController=null}const o=t.layoutOptions?.legend??this.templateOptions.legendEnabled,n=t.layoutOptions?.northArrow??this.templateOptions.northArrowEnabled;this.templateOptions.set({format:l,layout:i,layoutItem:a,legendEnabled:o,northArrowEnabled:n})}_renderTitleOrFileNameSection(){const{title:e,fileName:t,titlePlaceHolder:l,fileNamePlaceHolder:a}=this.messages,i=this._selectedTab===x.layout?e:t,o=this._selectedTab===x.layout?l:a,n=this._selectedTab===x.layout?this.templateOptions.title:this.templateOptions.fileName;return v("div",{class:I.formSectionContainer,key:i},v("calcite-label",null,i,v("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===x.layout||"mapOnlyTab"===t&&this._selectedTab===x.mapOnly||"exportTab"===t&&this._selectedTab===x.export)&&(e.focus(),this._activeTabFocusRequested=!1)}_renderLoader(){const e={[I.loader]:this._awaitingServerResponse};return v("div",{class:this.classes(e),key:"loader"})}_createFileLink(e,t){const l=t||this.messages.untitled,a=e.format.toLowerCase(),i=a.includes("png")?"png":a,o=l+i;return void 0!==this._exportedFileNameMap[o]?this._exportedFileNameMap[o]++:this._exportedFileNameMap[o]=0,new d({name:l,extension:i,count:this._exportedFileNameMap[o]})}_resetToCurrentScale(){this.templateOptions.scale=this.viewModel.view?.scale}_updateCustomTextElementValue(e,t,l){e.find((e=>{const[l]=Object.entries(e)[0];return l===t}))[t]=l}_updateInputValue(e){const t=e.target,l=t.getAttribute("data-input-name"),a=!!t["data-input-custom"],{templateOptions:i}=this;if(a)return void this._updateCustomTextElementValue(i.customTextElements,l,t.value);let o;if("number"===t.type){if(!$(t.valueAsNumber)){const e=i[l];return void(t.value=`${e}`)}o=t.valueAsNumber}else o=t.value;i[l]=o}_handleDPIChange(e){const{templateOptions:t}=this,l=t.dpi;this._updateInputValue(e);const a=e.currentTarget.valueAsNumber,{height:i,width:o}=k(a,l,t.width,t.height);t.height=i,t.width=o}_handlePrintMap(){this._pendingExportScroll=!0;const{templateOptions:e}=this,t=this.viewModel.toPrintTemplate(e),l=this._selectedTab===x.layout?t.layoutOptions?.titleText:e.fileName,a=this._createFileLink(t,l);this.exportedLinks.add(a),this.emit("submit",{link:a}),this._selectedTab=x.export,this.viewModel.print(t).then((e=>{a.set({url:e&&e.url,state:"ready"})})).catch((e=>{a.set({error:e,state:"error"})})).then((()=>{this.emit("complete",{link:a}),this.scheduleRender()}))}_switchInput(){[this.templateOptions.width,this.templateOptions.height]=[this.templateOptions.height,this.templateOptions.width]}_scrollExportIntoView(){if(!this._pendingExportScroll)return;this._pendingExportScroll=!1;const e=this._rootNode;if(!e)return;const{clientHeight:t,scrollHeight:l}=e,a=l-t;a>0&&(e.scrollTop=a)}_toggleInputValue(e){const t=e.target,l=t.getAttribute("data-option-name");this.templateOptions[l]=t.checked,"scaleEnabled"===l&&this._resetToCurrentScale()}_renderExportedLink(e){const t=this.messages,l=e.map((e=>{const{error:l,url:a,state:n}=e,s=e.formattedName??"",r="error"===n,c="pending"===n,p="ready"===n;let d=a||null;d&&(d=i(d));const u=o(a,location.href);let m;m=c?t.pending:p?t.ready:t.errorMessage;const h=r?"print-task:cim-symbol-unsupported"===l?.name?t.exportWebMapCIMError:t.exportWebMapError:"";return v("calcite-list-item",{"aria-label":m,class:I.exportedFile,"data-item":e,description:c?t.generatingExport:h||(u?t.ready:t.linkReady),key:s,label:s,title:h,onCalciteListItemSelect:this._handleLinkClick},c?v("calcite-loader",{class:I.exportedFileLoader,inline:!0,key:`${s}-loader`,label:t.generatingExport,scale:"m",slot:"content-start"}):v("calcite-icon",{icon:M(e),key:`${s}-start-icon`,scale:"s",slot:"content-start"}),p?v("calcite-icon",{"aria-label":`${s}. ${t.linkReady}`,icon:u?"download-to":"launch",key:`${s}-end-icon`,scale:"s",slot:"content-end"}):null,c?null:v("calcite-action",{"aria-label":`${h}`,"data-item":e,icon:"x",key:`${s}-action`,onclick:this._removeLink,slot:"actions-end",text:`${h}`}))}));return v("calcite-list",{filterEnabled:e?.length>10},l)}_toggleLayoutPanel(e){const t=e.target;this._toggleTab(t.getAttribute("data-tab-id"))}_toggleTab(e,t=!0){if(this._selectedTab=e,this._selectedTab===x.mapOnly)this.templateOptions.layout=T,this.templateOptions.layoutItem=null;else if(this._selectedTab===x.layout){const e=this._selectedLayout??(this.includeDefaultTemplates&&this.viewModel.defaultTemplates.length?null:this.viewModel.templatesInfo?.layout?.defaultValue);e&&this._applyTemplate(e)}t&&(this._activeTabFocusRequested=!0)}_handleLayoutPanelKeyDown(e){const{key:t}=e,l=e.target.getAttribute("data-tab-id");if(f(t))return this._toggleTab(l),e.preventDefault(),void e.stopPropagation();if("ArrowLeft"===t||"ArrowRight"===t){switch(l){case x.layout:this._toggleTab("ArrowLeft"===t?x.export:x.mapOnly);break;case x.mapOnly:this._toggleTab("ArrowLeft"===t?x.layout:x.export);break;case x.export:this._toggleTab("ArrowLeft"===t?x.mapOnly:x.layout)}e.preventDefault(),e.stopPropagation()}}};e([n()],E.prototype,"_showTemplates",void 0),e([n()],E.prototype,"allowedFormats",null),e([n()],E.prototype,"allowedLayouts",null),e([n()],E.prototype,"browseTemplateButtonOnClick",void 0),e([n()],E.prototype,"error",null),e([n({type:w})],E.prototype,"exportedLinks",void 0),e([n()],E.prototype,"extraParameters",null),e([n()],E.prototype,"headingLevel",void 0),e([n()],E.prototype,"icon",null),e([n()],E.prototype,"includeDefaultTemplates",null),e([n()],E.prototype,"label",null),e([n(),g("esri/widgets/Print/t9n/Print")],E.prototype,"messages",void 0),e([n(),g("esri/t9n/common")],E.prototype,"messagesCommon",void 0),e([n()],E.prototype,"portal",null),e([n()],E.prototype,"printPreviewEnabled",null),e([n()],E.prototype,"printServiceUrl",null),e([n()],E.prototype,"templateCustomTextElements",null),e([n()],E.prototype,"templateOptions",null),e([n()],E.prototype,"view",null),e([n({type:u})],E.prototype,"viewModel",void 0),E=e([s("esri.widgets.Print")],E);const F=E;export{F as default};
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import t from"../core/Collection.js";import{JSONMap as l}from"../core/jsonMap.js";import{clone as a}from"../core/lang.js";import{watch as i}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"../core/has.js";import"../core/Logger.js";import{subclass as c}from"../core/accessorSupport/decorators/subclass.js";import{getToken as p}from"../rest/utils.js";import{toJSON as d}from"../rest/support/fileFormat.js";import u from"./Widget.js";import m from"./Print/FileLink.js";import h from"./Print/PrintViewModel.js";import{loadCalciteComponents as b}from"./support/componentsUtils.js";import{globalCss as y}from"./support/globalCss.js";import{Heading as _}from"./support/Heading.js";import{legacyIcon as f}from"./support/legacyIcon.js";import{isRTL as g,isActivationKey as v}from"./support/widgetUtils.js";import{messageBundle as w}from"./support/decorators/messageBundle.js";import{tsx as T}from"./support/jsxFactory.js";import{formatNumber as x}from"../intl/number.js";const C=t.ofType(m),O="MAP_ONLY";var I;!function(e){e.layout="layoutTab",e.mapOnly="mapOnlyTab",e.export="exportTab"}(I||(I={}));const k="esri-print",$=`${k}__advanced-options-button`,L={base:k,headerTitle:`${k}__header-title`,inputText:`${k}__input-text`,layoutTabList:`${k}__layout-tab-list`,layoutTab:`${k}__layout-tab`,layoutSection:`${k}__layout-section`,mapOnlySection:`${k}__map-only-section`,scaleInput:`${k}__scale-input`,panelItemsCentered:`${k}__panel-items--centered`,loader:`${k}__loader`,advancedOptionsButton:$,advancedOptionsButtonContainer:`${$}-container`,advancedOptionsButtonTitle:`${$}-title`,advancedOptionsButtonIconOpened:`${$}-icon--opened`,advancedOptionsButtonIconClosed:`${$}-icon--closed`,advancedOptionsButtonIconClosed_RTL:`${$}-icon--closed-rtl`,refreshButton:`${k}__refresh-button`,swapButton:`${k}__swap-button`,printButton:`${k}__export-button`,templateSelectContainer:`${k}__template-select-container`,templateSelectBlock:`${k}__template-select-block`,templateSelectIcon:`${k}__template-select-icon`,formSectionContainer:`${k}__form-section-container`,formInputLabel:`${k}__form-input-label`,formCheckboxLabel:`${k}__form-checkbox-label`,advancedOptionsSection:`${k}__advanced-options-section`,advancedOptionsContainer:`${k}__advanced-options-container`,authorInfoContainer:`${k}__author-info-container`,browseTemplateButtonContainer:`${k}__browse-template-button-container`,copyrightInfoContainer:`${k}__copyright-info-container`,exportedFilesContainer:`${k}__export-panel-container`,exportedFilesTitle:`${k}__export-title`,exportedFile:`${k}__exported-file`,exportedFileLink:`${k}__exported-file-link`,exportedFileLinkTitle:`${k}__exported-file-link-title`,exportedFilesEmpty:`${k}__exported-files-empty`,legendInfoContainer:`${k}__legend-info-container`,printWidgetContainer:`${k}__container`,content:`${k}__content`,panelContainer:`${k}__panel-container`,scaleInfoContainer:`${k}__scale-info-container`,scaleInputContainer:`${k}__scale-input-container`,sizeContainer:`${k}__size-container`,panelError:`${k}__panel--error`,exportedFileError:`${k}__exported-file--error`,exportedFileLoader:`${k}__exported-file--loader`,exportSection:`${k}__export-section`,exportSectionCentered:`${k}__export-section--centered`,templateButtonContainer:`${k}__template-button-container`,templateDoneButton:`${k}__template-done-button`,templateSelectFlowItemContainer:`${k}__template-select-flow-item-container`,templateSelectFlowItemContent:`${k}__template-select-flow-item-content`,templateSelectFlowItemListHeading:`${k}__template-select-flow-item-list-heading`};function S(e,t,l,a){const i=l/t,o=a/t;return{width:Math.round(e*i),height:Math.round(e*o)}}function M(e){return!isNaN(e)&&e>0}function E(e){return e?.toUpperCase()===O}function F(e){const{state:t,extension:l}=e;switch(t){case"pending":return"spinner";case"error":return"exclamation-mark-circle";default:return l?.toLowerCase()?.includes("pdf")?"file-pdf":"file"}}function j(e,t){return!!t&&e.some((e=>e.layoutItem?.id===t||e.layout===t))}const P=new l({inch:"inches",foot:"feet",yard:"yards",mile:"miles","nautical-mile":"nautical-miles",millimeter:"millimeters",centimeter:"centimeters",decimeter:"decimeters",meter:"meters",kilometer:"kilometers"});let A=class extends u{constructor(e,t){super(e,t),this._activeTabFocusRequested=!1,this._awaitingServerResponse=!1,this._exportedFileNameMap={},this._selectedTab=I.layout,this._pendingExportScroll=!1,this._rootNode=null,this._selectedLayout=null,this._abortController=null,this._showTemplates=!1,this.browseTemplateButtonOnClick=null,this.exportedLinks=new C,this.headingLevel=3,this.messagesCommon=null,this.messagesUnits=null,this.viewModel=new h,this._onInput=e=>{this._selectedTab===I.layout?this.templateOptions.title=e.target.value:this._selectedTab===I.mapOnly&&(this.templateOptions.fileName=e.target.value)},this._removeLink=e=>{const t=e.currentTarget["data-item"];t&&this.exportedLinks.remove(t)},this._handleLinkClick=e=>{const t=e.currentTarget["data-item"];if(!t||"ready"!==t.state||!t.url)return;const l=p(this.viewModel.effectivePrintServiceUrl),a=t.url,i=document.createElement("a");if(i.target="_blank",i.href=a,i.rel="noreferrer",i.download=t.formattedName??"",!l)return i.click(),void e.stopPropagation();if(!e.isTrusted)return void e.stopPropagation();e.preventDefault();const o=new URL(a);o.searchParams.set("token",l),i.href=o.href,i.click(),i.href=a},this._focusOnTabChange=this._focusOnTabChange.bind(this)}initialize(){this.addHandles([i((()=>[this.templateOptions.format,this.viewModel.templatesInfo?.format.defaultValue]),(([e,t])=>{if(t&&!e)return void(this.templateOptions.format=t);if(!e||!t||!this.viewModel.templatesInfo)return;if(this.viewModel.templatesInfo.format.choiceList.includes(e))return;const l=this.viewModel.templatesInfo.format.choiceList.find((t=>t.toUpperCase().includes(`(${e.toUpperCase()})`)));this.templateOptions.format=l??t})),i((()=>[this.templateOptions.layout,this.viewModel.templatesInfo?.layout.defaultValue]),(async([e,t])=>{if(this._selectedTab=E(e)?I.mapOnly:I.layout,this._selectedTab!==I.layout)return;const{includeDefaultTemplates:l,viewModel:i,_selectedLayout:o}=this,{portalTemplateIds:n,browseTemplates:s,templatesInfo:r}=i,c=i.defaultTemplates.filter((({layoutItem:e})=>n.includes(e?.id))),p=i.defaultTemplates.filter((({layoutItem:e})=>!n.includes(e?.id))),d=l&&p.length;if(e){(d?j(p,e):r?.layout.choiceList.includes(e))||j(c,e)||j(s,e)||(this.templateOptions.layout=null,this.templateOptions.layoutItem=null)}else{o&&((d?j(p,o):r?.layout.choiceList.includes(o))||j(c,o)||j(s,o))?await this._applyTemplate(o):(this.templateOptions.layout=null,this.templateOptions.layoutItem=null),this.templateOptions.layout||d||!t||await this._applyTemplate(t)}this._selectedLayout=this.templateOptions.layout;const u=!!this.templateOptions.layout&&this.viewModel.effectiveTemplateCustomTextElements[this.templateOptions.layout];this.templateOptions.customTextElements=u?a(u):null})),i((()=>this.templateOptions.dpi),(e=>{e<=0&&(this.templateOptions.dpi=1)})),i((()=>this.viewModel.view?.scale),(e=>{!e||this.templateOptions.scaleEnabled&&this.templateOptions.scale||(this.templateOptions.scale=e)}))]);const{height:e,width:t}=this.templateOptions;this.templateOptions.width=t||800,this.templateOptions.height=e||1100;const l=setTimeout((()=>{this._awaitingServerResponse=!0,this.scheduleRender()}),500);this.viewModel.load().then((()=>{clearTimeout(l),this._awaitingServerResponse=!1}))}loadDependencies(){return b({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),block:()=>import("@esri/calcite-components/dist/components/calcite-block.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),checkbox:()=>import("@esri/calcite-components/dist/components/calcite-checkbox.js"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox.js"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item.js"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow.js"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),input:()=>import("@esri/calcite-components/dist/components/calcite-input.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),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")})}destroy(){this.viewModel.destroy()}get allowedFormats(){return this.viewModel.allowedFormats}set allowedFormats(e){this.viewModel.allowedFormats=e}get allowedLayouts(){return this.viewModel.allowedLayouts}set allowedLayouts(e){this.viewModel.allowedLayouts=e}get error(){return this.viewModel.error}get extraParameters(){return this.viewModel.extraParameters}set extraParameters(e){this.viewModel.extraParameters=e}get icon(){return"print"}set icon(e){this._overrideIfSome("icon",e)}get includeDefaultTemplates(){return this.viewModel.includeDefaultTemplates}set includeDefaultTemplates(e){this.viewModel.includeDefaultTemplates=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get portal(){return this.viewModel.portal}set portal(e){this.viewModel.portal=e}get 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:l,view:a}=this,{attributionEnabled:i,author:o,copyright:n,dpi:s,format:r,height:c,layout:p,legendEnabled:u,northArrowEnabled:m,scaleEnabled:h,scale:b,width:v}=t,w="ready"!==l.state||this._awaitingServerResponse||!p,x=this._renderTitleOrFileNameSection(),C=T("div",{class:L.formSectionContainer},T("calcite-label",null,e.fileFormatTitle,T("calcite-combobox",{clearDisabled:!0,label:e.formatDefaultOption,maxItems:6,placeholder:e.formatDefaultOption,selectionMode:"single-persist",onCalciteComboboxChange:({target:e})=>{this.templateOptions.format=e.selectedItems[0].value}},l.templatesInfo?.format?.choiceList.sort().map(((e,t)=>T("calcite-combobox-item",{key:`file-format-${t}`,selected:e===this.templateOptions.format,textLabel:d(e),value:e})))))),O=T("calcite-label",{layout:"inline"},T("calcite-switch",{checked:this.showPrintAreaEnabled,onCalciteSwitchChange:e=>{this.showPrintAreaEnabled=!!e.target.checked}}),e.printPreview),k=T("div",null,T("div",{class:L.formSectionContainer},T("calcite-label",null,e.template,T("div",{class:L.templateSelectContainer,onclick:()=>{this._showTemplates=!0}},T("calcite-block",{class:L.templateSelectBlock,description:this._getPageSizeLabel(p),heading:this._getTemplateLabel()}),T("calcite-icon",{class:L.templateSelectIcon,icon:g()?"chevron-left":"chevron-right",scale:"s"})))),O),$=T("div",{class:L.formSectionContainer},T("label",{class:L.formInputLabel},e.dpi,T("input",{bind:this,class:this.classes(L.inputText,y.input),"data-input-name":"dpi",min:"1",onchange:this._handleDPIChange,tabIndex:0,type:"number",value:`${s}`}))),S=T("div",{class:this.classes(L.scaleInfoContainer,L.formSectionContainer)},T("calcite-label",{layout:"inline"},T("calcite-checkbox",{bind:this,checked:h,"data-option-name":"scaleEnabled",tabIndex:0,onCalciteCheckboxChange:this._toggleInputValue}),e.scale),T("div",{class:L.scaleInputContainer},T("input",{"aria-label":e.scaleLabel,"aria-valuenow":`${b}`,bind:this,class:this.classes(L.inputText,y.input,L.scaleInput),"data-input-name":"scale",disabled:!h,onchange:this._updateInputValue,role:"spinbutton",tabIndex:0,type:"number",value:`${b}`}),T("button",{"aria-label":e.reset,bind:this,class:this.classes(y.widgetButton,L.refreshButton,f.refresh),onclick:this._resetToCurrentScale,tabIndex:0,type:"button"}))),M=T("div",{"aria-labelledby":`${this.id}__advancedOptionsForLayout`,class:L.advancedOptionsContainer,key:"advanced-section-for-layout"},S,this.viewModel.layoutTemplateInfo?.layoutOptions?.hasAuthorText??1?T("div",{class:this.classes(L.authorInfoContainer,L.formSectionContainer),key:"author-info"},T("label",{class:L.formInputLabel},e.author,T("input",{bind:this,class:this.classes(L.inputText,y.input),"data-input-name":"author",onchange:this._updateInputValue,tabIndex:0,type:"text",value:o??""}))):null,this.viewModel.layoutTemplateInfo?.layoutOptions?.hasCopyrightText??1?T("div",{class:this.classes(L.copyrightInfoContainer,L.formSectionContainer),key:"copyright-text"},T("label",{class:L.formInputLabel},e.copyright,T("input",{bind:this,class:this.classes(L.inputText,y.input),"data-input-name":"copyright",onchange:this._updateInputValue,tabIndex:0,type:"text",value:n??""}))):null,$,this.viewModel.layoutTemplateInfo?.layoutOptions?.hasLegend??1?T("div",{class:this.classes(L.legendInfoContainer,L.formSectionContainer),key:"legend-info"},T("calcite-label",{layout:"inline"},T("calcite-checkbox",{bind:this,checked:u,"data-option-name":"legendEnabled",tabIndex:0,onCalciteCheckboxChange:this._toggleInputValue}),e.legend)):null,this.viewModel.layoutTemplateNorthArrowInfo??1?T("div",{class:this.classes(L.legendInfoContainer,L.formSectionContainer),key:"north-arrow"},T("calcite-label",{layout:"inline"},T("calcite-checkbox",{bind:this,checked:m,"data-option-name":"northArrowEnabled",tabIndex:0,onCalciteCheckboxChange:this._toggleInputValue}),e.northArrow)):null,this._renderCustomTextElementSection()),E=T("div",{"aria-labelledby":`${this.id}__advancedOptionsForMapOnly`,class:L.advancedOptionsContainer},S,$,T("div",{class:L.formSectionContainer},T("calcite-label",{layout:"inline"},T("calcite-checkbox",{bind:this,checked:i,"data-option-name":"attributionEnabled",tabIndex:0,onCalciteCheckboxChange:this._toggleInputValue}),e.attribution)),this._renderCustomTextElementSection()),F=this.exportedLinks.toArray(),j=this._renderExportedLink(F),P={[L.exportSectionCentered]:!F.length},A=this._selectedTab===I.layout?T("section",{"aria-labelledby":`${this.id}__layoutTab`,class:L.layoutSection,id:`${this.id}__layoutContent`,key:"esri-print__layoutContent",role:"tabpanel"},T("div",{class:L.panelContainer},this.viewModel.layoutTemplateInfo?.layoutOptions?.hasTitleText??1?x:null,k,this._selectedTab===I.layout?C:null,T("calcite-block",{"aria-label":e.advancedOptions,class:this.classes(L.panelContainer,L.advancedOptionsSection),collapsible:!0,disabled:!p,heading:e.advancedOptions,id:"advancedOptionsForLayout",key:"advanced-options-for-layout"},M))):this._selectedTab===I.mapOnly?T("section",{"aria-labelledby":`${this.id}__mapOnlyTab`,class:L.mapOnlySection,id:`${this.id}__mapOnlyContent`,key:"esri-print__mapOnlyContent",role:"tabpanel"},T("div",{class:L.panelContainer},x,C,T("div",null,T("div",{class:this.classes(L.sizeContainer,L.formSectionContainer)},T("label",{class:L.formInputLabel},e.width,T("input",{bind:this,class:this.classes(L.inputText,y.input),"data-input-name":"width",onchange:this._updateInputValue,tabIndex:0,type:"number",value:`${v}`})),T("label",{class:L.formInputLabel},e.height,T("input",{bind:this,class:this.classes(L.inputText,y.input),"data-input-name":"height",onchange:this._updateInputValue,tabIndex:0,type:"number",value:`${c}`})),T("button",{"aria-label":e.swap,bind:this,class:this.classes(y.widgetButton,L.swapButton,f.swap),onclick:this._switchInput,tabIndex:0,type:"button"})),O),T("calcite-block",{"aria-label":e.advancedOptions,class:this.classes(L.panelContainer,L.advancedOptionsSection),collapsible:!0,heading:e.advancedOptions,id:"advancedOptionsForMapOnly",key:"advanced-options-for-map-only"},E))):T("section",{"aria-labelledby":`${this.id}__exportTab`,class:this.classes(L.exportSection,P),id:`${this.id}__exportContent`,key:"esri-print__exportContent",role:"tabpanel"},T("div",{class:L.panelContainer},T("div",{afterUpdate:this._scrollExportIntoView,bind:this,class:L.exportedFilesContainer},0===F.length?T("div",{class:L.exportedFilesEmpty},T("calcite-icon",{icon:"file",scale:"l"}),T("div",null,T(_,{class:L.exportedFilesTitle,level:this.headingLevel},e.noExportedFiles),T("div",null,e.exportHint))):j))),B={[y.buttonDisabled]:w||!p&&!r},D=!a||"2d"!==a.type,N=T("div",{class:L.panelError},D?e.sceneViewError:e.serviceError),U=F.some((({state:e})=>"pending"===e)),V=T("div",{class:L.content,key:"panel"},T("div",null,T("ul",{bind:this,class:L.layoutTabList,onclick:this._toggleLayoutPanel,onkeydown:this._handleLayoutPanelKeyDown,role:"tablist"},T("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${this._selectedTab===I.layout}`,class:L.layoutTab,"data-tab-id":I.layout,id:`${this.id}__layoutTab`,role:"tab",tabIndex:0},e.layoutTab),T("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${this._selectedTab===I.mapOnly}`,class:L.layoutTab,"data-tab-id":I.mapOnly,id:`${this.id}__mapOnlyTab`,role:"tab",tabIndex:0},e.mapOnlyTab),T("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${this._selectedTab===I.export}`,class:L.layoutTab,"data-tab-id":I.export,id:`${this.id}__exportedFilesTab`,role:"tab",tabIndex:0},U?T("calcite-loader",{inline:!0,label:"loading",scale:"s"}):null,e.exportsTab)),A),this._selectedTab!==I.export?T("button",{"aria-label":e.exportDescription,bind:this,class:this.classes(L.printButton,y.button,B),disabled:w,onclick:this._handlePrintMap,tabIndex:0,type:"button"},e.export):null),R=T("calcite-flow",{key:"root-flow"},T("calcite-flow-item",{bind:this,key:"root-flow-item"},T("div",{class:L.printWidgetContainer},T("header",{class:L.headerTitle},e.export),this.error||D||!a?N:V)),this._renderChooseTemplateFlowItem()),z="initializing"===l.state,H=z?this._renderLoader():R,W={[L.panelItemsCentered]:z};return T("div",{bind:this,class:this.classes(L.base,y.widget,y.panel,W)},H)}_getPageSizeLabel(e){if(!e)return;const t=this.viewModel.getLayoutTemplateInfo(e);if(!t)return;const l=P.fromJSON(t.pageUnits.toLowerCase());return`${x(t.pageSize[0])} x ${x(t.pageSize[1])} ${o(this.messagesUnits,l,"abbr")}`}_getTemplateLabel(){const{messages:e,includeDefaultTemplates:t,templateOptions:l,viewModel:a}=this,{layout:i}=l,o=i?(t?a.defaultTemplates.find((({layoutItem:e,layout:t})=>i===e?.id||i===t)):null)??a.browseTemplates.find((({layoutItem:e})=>i===e?.id)):null;return o?.label?.replaceAll("_"," ")??e[i]??i?.replaceAll("_"," ")??e.selectTemplate}_renderChooseTemplateFlowItem(){if(!this._showTemplates)return null;const{includeDefaultTemplates:e,messages:t,viewModel:l}=this,{defaultTemplates:a,templatesInfo:i,browseTemplates:o,portalTemplateIds:n}=l,s=o.length?o.toArray().sort(((e,t)=>(e.label??"")>(t.label??"")?1:-1)).map(((e,a)=>{const i=e.layoutItem?.id??e.layout,o=this._getPageSizeLabel(i),n=i===this.templateOptions.layout;return T("calcite-list-item",{description:o,key:`browse-template-${a}`,label:e?.label?.replaceAll("_"," ")??t.untitled,selected:n,title:e.description??"",value:i},!o&&n&&e.layoutItem?.id?T("calcite-loader",{inline:!0,key:`browse-template-loader-${a}`,label:"loading",scale:"s",slot:"content-end"}):null,T("calcite-action",{icon:"trash",onclick:()=>l.removePortalTemplate(e),slot:"actions-end",text:"delete"}))})):null,r=a.length&&e?a.toArray().filter((({label:e,layoutItem:t})=>!E(e)&&n.includes(t?.id))).sort(((e,t)=>(e.label??"")>(t.label??"")?1:-1)).map(((e,l)=>{const a=e.layoutItem?.id??e.layout,i=this._getPageSizeLabel(a),o=a===this.templateOptions.layout;return T("calcite-list-item",{description:i,key:`portal-template-${a}-${o}`,label:e?.label?.replaceAll("_"," ")??t.untitled,selected:o,title:e.description??"",value:a},!i&&o&&e.layoutItem?.id?T("calcite-loader",{inline:!0,key:`portal-template-loader-${l}`,label:"loading",scale:"s",slot:"content-end"}):null)})):null,c=a.length&&e?a.toArray().filter((({label:e,layoutItem:t})=>!E(e)&&!n.includes(t?.id))).sort(((e,t)=>(e.label??"")>(t.label??"")?1:-1)).map(((e,l)=>{const a=e.layoutItem?.id??e.layout,i=this._getPageSizeLabel(a),o=a===this.templateOptions.layout;return T("calcite-list-item",{description:i,key:`default-template-${l}`,label:e?.label?.replaceAll("_"," ")??t.untitled,selected:o,title:e.description??"",value:a},!i&&o&&e.layoutItem?.id?T("calcite-loader",{inline:!0,key:`default-template-loader-${l}`,label:"loading",scale:"s",slot:"content-end"}):null)})):null,p=!i?.layout?.choiceList.length||e&&c?.length?null:i.layout.choiceList.map((e=>({label:t[e]??e.replaceAll("_"," "),value:e}))).sort(((e,t)=>e.label>t.label?1:0)).map((({label:e,value:t},l)=>T("calcite-list-item",{description:this._getPageSizeLabel(t),key:`service-template-${l}`,label:e,selected:t===this.templateOptions.layout,value:t}))),d=(s?.length??0)+(r?.length??0)+(c?.length??0)+(p?.length??0)>15;return T("calcite-flow-item",{bind:this,closable:!1,heading:t.chooseTemplate,key:"template-flow-item",onCalciteFlowItemBack:e=>{e.preventDefault(),this._showTemplates=!1}},T("div",{class:L.templateSelectFlowItemContainer},T("div",{class:L.templateSelectFlowItemContent},this.browseTemplateButtonOnClick?T("calcite-button",{appearance:"outline",class:L.browseTemplateButtonContainer,key:"browse-template-button",onclick:this.browseTemplateButtonOnClick},"Browse Templates"):null,T("calcite-list",{filterEnabled:d,key:"template-list",selectionMode:"single-persist",onCalciteListChange:({target:e})=>this._applyTemplate(e.selectedItems[0].value)},s?.length?T("div",{key:"my-templates"},T("div",{class:L.templateSelectFlowItemListHeading},t.myTemplates,T("calcite-chip",{appearance:"outline",kind:"neutral",scale:"s",value:t.beta},t.beta)),s):null,r?.length?T("div",{key:"org-templates"},T("div",{class:L.templateSelectFlowItemListHeading},t.organizationTemplates,T("calcite-chip",{appearance:"outline",kind:"neutral",scale:"s",value:t.beta},t.beta)),r):null,s?.length||r?.length?c?.length?T("div",{key:"default-templates"},T("div",{class:L.templateSelectFlowItemListHeading},t.defaultTemplates),c):null:c,s?.length||r?.length?p?.length?T("div",{key:"service-templates"},T("div",{class:L.templateSelectFlowItemListHeading},t.defaultTemplates),p):null:p)),T("div",{class:L.templateButtonContainer},T("calcite-button",{class:L.templateDoneButton,onclick:()=>this._showTemplates=!1},this.messagesCommon.done))))}_renderCustomTextElementSection(){const{customTextElements:e}=this.templateOptions;return e?T("div",{class:L.formSectionContainer,key:"custom-text-elements"},e.map((e=>{const[t,l]=Object.entries(e)[0];return"date"===t?null:T("label",{key:t},t,T("input",{bind:this,class:this.classes(L.inputText,y.input),"data-input-custom":!0,"data-input-name":t,onchange:this._updateInputValue,type:"text",value:l}))}))):null}async _applyTemplate(e){if(this._abortController&&(this._abortController.abort(),this._abortController=null),!e)return;const t=this.viewModel.defaultTemplates.find((({layoutItem:t})=>e===t?.id))??this.viewModel.browseTemplates.find((({layoutItem:t})=>e===t?.id));if(!t)return this.templateOptions.layout=e,void(this.templateOptions.layoutItem=null);const{format:l,layoutItem:a}=t,i=a?.id??t.layout??this.templateOptions.layout;if(this.templateOptions.layout=i,!t.layoutOptions)try{this._abortController=new AbortController,await this.viewModel.fetchLayoutTemplateInfo(t,{signal:this._abortController.signal})}catch(s){return}finally{this._abortController=null}const o=t.layoutOptions?.legend??this.templateOptions.legendEnabled,n=t.layoutOptions?.northArrow??this.templateOptions.northArrowEnabled;this.templateOptions.set({format:l,layout:i,layoutItem:a,legendEnabled:o,northArrowEnabled:n})}_renderTitleOrFileNameSection(){const{title:e,fileName:t,titlePlaceHolder:l,fileNamePlaceHolder:a}=this.messages,i=this._selectedTab===I.layout?e:t,o=this._selectedTab===I.layout?l:a,n=this._selectedTab===I.layout?this.templateOptions.title:this.templateOptions.fileName;return T("div",{class:L.formSectionContainer,key:i},T("calcite-label",null,i,T("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===I.layout||"mapOnlyTab"===t&&this._selectedTab===I.mapOnly||"exportTab"===t&&this._selectedTab===I.export)&&(e.focus(),this._activeTabFocusRequested=!1)}_renderLoader(){const e={[L.loader]:this._awaitingServerResponse};return T("div",{class:this.classes(e),key:"loader"})}_createFileLink(e,t){const l=t||this.messages.untitled,a=e.format.toLowerCase(),i=a.includes("png")?"png":a,o=l+i;return void 0!==this._exportedFileNameMap[o]?this._exportedFileNameMap[o]++:this._exportedFileNameMap[o]=0,new m({name:l,extension:i,count:this._exportedFileNameMap[o]})}_resetToCurrentScale(){this.templateOptions.scale=this.viewModel.view?.scale}_updateCustomTextElementValue(e,t,l){e.find((e=>{const[l]=Object.entries(e)[0];return l===t}))[t]=l}_updateInputValue(e){const t=e.target,l=t.getAttribute("data-input-name"),a=!!t["data-input-custom"],{templateOptions:i}=this;if(a)return void this._updateCustomTextElementValue(i.customTextElements,l,t.value);let o;if("number"===t.type){if(!M(t.valueAsNumber)){const e=i[l];return void(t.value=`${e}`)}o=t.valueAsNumber}else o=t.value;i[l]=o}_handleDPIChange(e){const{templateOptions:t}=this,l=t.dpi;this._updateInputValue(e);const a=e.currentTarget.valueAsNumber,{height:i,width:o}=S(a,l,t.width,t.height);t.height=i,t.width=o}_handlePrintMap(){this._pendingExportScroll=!0;const{templateOptions:e}=this,t=this.viewModel.toPrintTemplate(e),l=this._selectedTab===I.layout?t.layoutOptions?.titleText:e.fileName,a=this._createFileLink(t,l);this.exportedLinks.add(a),this.emit("submit",{link:a}),this._selectedTab=I.export,this.viewModel.print(t).then((e=>{a.set({url:e&&e.url,state:"ready"})})).catch((e=>{a.set({error:e,state:"error"})})).then((()=>{this.emit("complete",{link:a}),this.scheduleRender()}))}_switchInput(){[this.templateOptions.width,this.templateOptions.height]=[this.templateOptions.height,this.templateOptions.width]}_scrollExportIntoView(){if(!this._pendingExportScroll)return;this._pendingExportScroll=!1;const e=this._rootNode;if(!e)return;const{clientHeight:t,scrollHeight:l}=e,a=l-t;a>0&&(e.scrollTop=a)}_toggleInputValue(e){const t=e.target,l=t.getAttribute("data-option-name");this.templateOptions[l]=t.checked,"scaleEnabled"===l&&this._resetToCurrentScale()}_renderExportedLink(e){const t=this.messages,l=e.map((e=>{const{error:l,url:a,state:i}=e,o=e.formattedName??"",r="error"===i,c="pending"===i,p="ready"===i;let d=a||null;d&&(d=n(d));const u=s(a,location.href);let m;m=c?t.pending:p?t.ready:t.errorMessage;const h=r?"print-task:cim-symbol-unsupported"===l?.name?t.exportWebMapCIMError:t.exportWebMapError:"";return T("calcite-list-item",{"aria-label":m,class:L.exportedFile,"data-item":e,description:c?t.generatingExport:h||(u?t.ready:t.linkReady),key:o,label:o,title:h,onCalciteListItemSelect:this._handleLinkClick},c?T("calcite-loader",{class:L.exportedFileLoader,inline:!0,key:`${o}-loader`,label:t.generatingExport,scale:"m",slot:"content-start"}):T("calcite-icon",{icon:F(e),key:`${o}-start-icon`,scale:"s",slot:"content-start"}),p?T("calcite-icon",{"aria-label":`${o}. ${t.linkReady}`,icon:u?"download-to":"launch",key:`${o}-end-icon`,scale:"s",slot:"content-end"}):null,c?null:T("calcite-action",{"aria-label":`${h}`,"data-item":e,icon:"x",key:`${o}-action`,onclick:this._removeLink,slot:"actions-end",text:`${h}`}))}));return T("calcite-list",{filterEnabled:e?.length>10},l)}_toggleLayoutPanel(e){const t=e.target;this._toggleTab(t.getAttribute("data-tab-id"))}_toggleTab(e,t=!0){if(this._selectedTab=e,this._selectedTab===I.mapOnly)this.templateOptions.layout=O,this.templateOptions.layoutItem=null;else if(this._selectedTab===I.layout){const e=this._selectedLayout??(this.includeDefaultTemplates&&this.viewModel.defaultTemplates.length?null:this.viewModel.templatesInfo?.layout?.defaultValue);e?this._applyTemplate(e):(this.templateOptions.layout=null,this.templateOptions.layoutItem=null)}t&&(this._activeTabFocusRequested=!0)}_handleLayoutPanelKeyDown(e){const{key:t}=e,l=e.target.getAttribute("data-tab-id");if(v(t))return this._toggleTab(l),e.preventDefault(),void e.stopPropagation();if("ArrowLeft"===t||"ArrowRight"===t){switch(l){case I.layout:this._toggleTab("ArrowLeft"===t?I.export:I.mapOnly);break;case I.mapOnly:this._toggleTab("ArrowLeft"===t?I.layout:I.export);break;case I.export:this._toggleTab("ArrowLeft"===t?I.mapOnly:I.layout)}e.preventDefault(),e.stopPropagation()}}};e([r()],A.prototype,"_showTemplates",void 0),e([r()],A.prototype,"allowedFormats",null),e([r()],A.prototype,"allowedLayouts",null),e([r()],A.prototype,"browseTemplateButtonOnClick",void 0),e([r()],A.prototype,"error",null),e([r({type:C})],A.prototype,"exportedLinks",void 0),e([r()],A.prototype,"extraParameters",null),e([r()],A.prototype,"headingLevel",void 0),e([r()],A.prototype,"icon",null),e([r()],A.prototype,"includeDefaultTemplates",null),e([r()],A.prototype,"label",null),e([r(),w("esri/widgets/Print/t9n/Print")],A.prototype,"messages",void 0),e([r(),w("esri/t9n/common")],A.prototype,"messagesCommon",void 0),e([r(),w("esri/core/t9n/Units")],A.prototype,"messagesUnits",void 0),e([r()],A.prototype,"portal",null),e([r()],A.prototype,"showPrintAreaEnabled",null),e([r()],A.prototype,"printServiceUrl",null),e([r()],A.prototype,"templateCustomTextElements",null),e([r()],A.prototype,"templateOptions",null),e([r()],A.prototype,"view",null),e([r({type:h})],A.prototype,"viewModel",void 0),A=e([c("esri.widgets.Print")],A);const B=A;export{B as default};
|