@arcgis/core 4.31.0-next.20240607 → 4.31.0-next.20240608
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/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{fa5e171c8ce844363b6c.js → 465c718f0b9f7ba0f1ea.js} +1 -1
- package/assets/esri/core/workers/chunks/4e2943968517e385bd12.js +1 -0
- package/assets/esri/core/workers/chunks/5f3600a6d7159228731d.js +1 -0
- package/assets/esri/core/workers/chunks/ace3297f0f314c3724da.js +1 -0
- package/assets/esri/core/workers/chunks/{342426c8a8c9f5f84811.js → b62e942e675d5770ea24.js} +1 -1
- package/assets/esri/core/workers/chunks/c660649465058ef82045.js +1 -0
- package/assets/esri/core/workers/chunks/{4faf7055457c04dc9fc1.js → cd03ad7dc45fbbeb1a2f.js} +1 -1
- package/assets/esri/core/workers/chunks/{6a943f384fcd0af5888b.js → e66ebcfffd081f847efe.js} +1 -1
- package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
- package/assets/esri/libs/lyr3d/lyr3DWorker.wasm +0 -0
- 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/chunks/Terrain.glsl.js +3 -1
- package/chunks/lyr3DWorker.js +1 -1
- package/interfaces.d.ts +152 -32
- package/layers/CatalogLayer.js +1 -1
- package/layers/MapImageLayer.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/effects/RenderPluginManager.js +1 -1
- package/views/3d/webgl-engine/effects/debug/RenderNodeVisualizerNode.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/Fullscreen.js +1 -1
- package/widgets/LayerList/css.js +1 -1
- package/widgets/LayerList.js +1 -1
- package/widgets/Locate.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/Track.js +1 -1
- package/assets/esri/core/workers/chunks/441f3eaef3b703dd1026.js +0 -1
- package/assets/esri/core/workers/chunks/ba988cd3a49987a0fb83.js +0 -1
- package/assets/esri/core/workers/chunks/c70683b7183458b338f8.js +0 -1
- package/assets/esri/core/workers/chunks/d03ada1212b13e76bff4.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.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import t from"../core/Collection.js";import{deprecatedProperty as i}from"../core/deprecate.js";import{IdentifiableMixin as o}from"../core/Identifiable.js";import l from"../core/Logger.js";import s from"../core/ReactiveMap.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as a}from"../core/accessorSupport/decorators/subclass.js";import{getActionIcon as r,getActionStyles as c}from"../support/actions/actionUtils.js";import d from"./Widget.js";import{css as m}from"./LayerList/css.js";import p from"./LayerList/LayerListViewModel.js";import h from"./LayerList/LayerListVisibleElements.js";import g from"./LayerList/ListItem.js";import{minDragEnabledItems as u,minFilterItems as y,getItem as _,getLayerType as f,listItemHasChildren as v,areChildrenHidden as I,canSortSublayers as b,getStatusIcon as w,sortLayersToIds as L,sortChildLayersToIds as F,getVisibilityIcon as C}from"./LayerList/support/layerListUtils.js";import{loadCalciteComponents as E}from"./support/componentsUtils.js";import{globalCss as k}from"./support/globalCss.js";import"./support/widgetUtils.js";import{messageBundle as A}from"./support/decorators/messageBundle.js";import{vmEvent as M}from"./support/decorators/vmEvent.js";import{tsx as T}from"./support/jsxFactory.js";const G=t.ofType(g);let j=class extends(o(d)){constructor(e,t){super(e,t),this._activeItem=null,this._tooltipReferenceMap=new s,this._focusRootFlowItem=!1,this._focusPanelFlowItem=!1,this._focusKnowledgeGraphFlowItem=!1,this._focusCatalogFlowItem=!1,this._knowledgeGraphFlowItem=null,this._catalogFlowItem=null,this._lastDragDetail=null,this._selectedDragItemLayerUid=null,this._rootGroupUid=`operational-${this.uid}`,this.catalogLayerList=null,this.catalogOptions=null,this.collapsed=!1,this.dragEnabled=!1,this.filterPlaceholder="",this.filterText="",this.headingLevel=2,this.knowledgeGraphTableList=null,this.knowledgeGraphOptions=null,this.listItemCanGiveFunction=null,this.listItemCanReceiveFunction=null,this.messages=null,this.messagesCommon=null,this.minDragEnabledItems=u,this.minFilterItems=y,this.selectedItems=new G,this.selectionMode="none",this.viewModel=new p,this.visibilityAppearance="default",this.visibleElements=new h,this._canMove=({dragEl:e,fromEl:t,toEl:i},o)=>{const l="pull"===o?this.listItemCanGiveFunction:this.listItemCanReceiveFunction,s=_(e);if(!s?.sortable)return!1;const n=_(t),a=f(t),r=_(i),c=f(i),d=!!a&&!!c&&a===c,m={selected:s,from:n,to:r},p=t.group,h=i.group,g=n?.layer?.type??"",u=r?.layer?.type??"",y=new Set(["map-image","catalog","knowledge-graph"]),v="sublayer";return p&&h&&"function"==typeof l?l.call(null,m):d&&!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};
|
package/widgets/Locate.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import{deprecatedProperty as o}from"../core/deprecate.js";import t from"../core/Logger.js";import{property as i}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as s}from"../core/accessorSupport/decorators/subclass.js";import r from"./Widget.js";import l from"./Locate/LocateViewModel.js";import{loadCalciteComponents as n}from"./support/componentsUtils.js";import{globalCss as a}from"./support/globalCss.js";import
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import{deprecatedProperty as o}from"../core/deprecate.js";import t from"../core/Logger.js";import{property as i}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as s}from"../core/accessorSupport/decorators/subclass.js";import r from"./Widget.js";import l from"./Locate/LocateViewModel.js";import{loadCalciteComponents as n}from"./support/componentsUtils.js";import{globalCss as a}from"./support/globalCss.js";import"./support/widgetUtils.js";import{messageBundle as c}from"./support/decorators/messageBundle.js";import{vmEvent as p}from"./support/decorators/vmEvent.js";import{tsx as d}from"./support/jsxFactory.js";const m={base:"esri-locate"};let g=class extends r{constructor(e,o){super(e,o),this.messages=null,this.messagesCommon=null,this.viewModel=new l,this._locate=()=>{const{viewModel:e}=this;"locating"===e.state?e.cancelLocate():e.locate().catch((()=>{}))}}loadDependencies(){return n({button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip.js")})}get geolocationOptions(){return this.viewModel.geolocationOptions}set geolocationOptions(e){this.viewModel.geolocationOptions=e}get goToLocationEnabled(){return this.viewModel.goToLocationEnabled}set goToLocationEnabled(e){this.viewModel.goToLocationEnabled=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get graphic(){return this.viewModel.graphic}set graphic(e){this.viewModel.graphic=e}get icon(){return"gps-off"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get popupEnabled(){return this.viewModel.popupEnabled}set popupEnabled(e){this.viewModel.popupEnabled=e}get rotationEnabled(){return o(t.getLogger(this),"rotationEnabled",{replacement:"use Track widget",version:"4.29",warnOnce:!0}),this.viewModel.rotationEnabled}set rotationEnabled(e){o(t.getLogger(this),"rotationEnabled",{replacement:"use Track widget",version:"4.29",warnOnce:!0}),this.viewModel.rotationEnabled=e}get scale(){return this.viewModel.scale}set scale(e){this.viewModel.scale=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}cancelLocate(){this.viewModel.cancelLocate()}locate(){return this.viewModel.locate()}render(){const{viewModel:e,icon:o}=this,{state:t}=e,i="locating"===t,s=i?this.messagesCommon.cancel:this.messages.title,r="feature-unsupported"===t,l=this._localizeError(this.viewModel?.error);return d("div",{class:this.classes(m.base,a.widget)},!r&&d("calcite-button",{class:a.widgetButton,disabled:"disabled"===t,iconStart:i?void 0:o,kind:"neutral",label:s,onclick:this._locate,title:s},i?d("calcite-loader",{inline:!0,label:""}):null),l?d("calcite-tooltip",{open:!0,overlayPositioning:"fixed",referenceElement:this.container},l):null)}_localizeError(e){return e instanceof GeolocationPositionError?e.code===GeolocationPositionError.PERMISSION_DENIED?this.messages?.permissionError:e.code===GeolocationPositionError.TIMEOUT?this.messages?.timeoutError:this.messages?.positionUnavailable:e instanceof Error?e.message:void 0}};e([i()],g.prototype,"geolocationOptions",null),e([i()],g.prototype,"goToLocationEnabled",null),e([i()],g.prototype,"goToOverride",null),e([i()],g.prototype,"graphic",null),e([i()],g.prototype,"icon",null),e([i()],g.prototype,"label",null),e([i(),c("esri/widgets/Locate/t9n/Locate")],g.prototype,"messages",void 0),e([i(),c("esri/t9n/common")],g.prototype,"messagesCommon",void 0),e([i()],g.prototype,"popupEnabled",null),e([i()],g.prototype,"rotationEnabled",null),e([i()],g.prototype,"scale",null),e([i()],g.prototype,"view",null),e([i({type:l}),p(["locate","locate-error"])],g.prototype,"viewModel",void 0),g=e([s("esri.widgets.Locate")],g);const u=g;export{u as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import 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.31/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.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../chunks/tslib.es6.js";import"../../geometry.js";import{id as e}from"../../kernel.js";import 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};
|