UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 40.1 kB
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import t from"../core/Collection.js";import{eventKey as i}from"../core/events.js";import o from"../core/Handles.js";import n from"../core/Logger.js";import{isNone as s,isSome as r}from"../core/maybe.js";import{watch as l,when as a,on as c,whenOnce as d,initial as u}from"../core/reactiveUtils.js";import{throttle as h}from"../core/throttle.js";import{property as p}from"../core/accessorSupport/decorators/property.js";import{cast as g}from"../core/accessorSupport/decorators/cast.js";import"../core/arrayUtils.js";import{subclass as m}from"../core/accessorSupport/decorators/subclass.js";import v from"./Feature.js";import f from"./Spinner.js";import _ from"./Widget.js";import{CSS as w}from"./Feature/resources.js";import{FeatureContentMixin as b}from"./Feature/support/FeatureContentMixin.js";import{getPointFromGeometry as M}from"./Popup/actionUtils.js";import{CSS as y}from"./Popup/css.js";import A from"./Popup/PopupViewModel.js";import{Heading as k}from"./support/Heading.js";import{accessibleHandler as F}from"./support/decorators/accessibleHandler.js";import{messageBundle as C}from"./support/decorators/messageBundle.js";import{vmEvent as I}from"./support/decorators/vmEvent.js";import{tsx as x}from"./support/jsxFactory.js";import{isRTL as O,storeNode as E,cssTransition as N}from"./support/widgetUtils.js";import{isDarkTheme as P}from"../support/themeUtils.js";import{substitute as T}from"../intl/substitute.js";const B="selected-index",D=0,L="popup-spinner",S={buttonEnabled:!0,position:"auto",breakpoint:{width:544}},R="esri-popup";function V(e,t){return void 0===t?`${R}__${e}`:`${R}__${e}-${t}`}const U={closeButton:!0,featureNavigation:!0};let W=class extends(b(_)){constructor(e,i){super(e,i),this._blurClose=!1,this._blurContainer=!1,this._containerNode=null,this._mainContainerNode=null,this._featureMenuNode=null,this._actionsMenuNode=null,this._focusClose=!1,this._focusContainer=!1,this._focusDockButton=!1,this._focusFeatureMenuButton=!1,this._focusActionsMenuButton=!1,this._focusFirstFeature=!1,this._focusFirstAction=!1,this._handles=new o,this._pointerOffsetInPx=16,this._spinner=null,this._feature=null,this._featureMenuIntersectionObserverNode=null,this._featureMenuViewportNode=null,this._rootFlowItemNode=null,this._featureMenuIntersectionObserverCallback=([e])=>{e?.isIntersecting&&null!=this.viewModel.featurePage&&this.viewModel.featurePage++},this._featureMenuIntersectionObserver=new IntersectionObserver(this._featureMenuIntersectionObserverCallback,{root:window.document}),this._displaySpinnerThrottled=h((()=>this._displaySpinner()),D),this._exitRelatedRecordsActions=new WeakMap,this._featureSelectionActions=new WeakMap,this._flowItems=new t,this.alignment="auto",this.collapsed=!1,this.collapseEnabled=!0,this.dockEnabled=!1,this.featureMenuOpen=!1,this.headingLevel=2,this.maxInlineActions=3,this.messages=null,this.messagesCommon=null,this.spinnerEnabled=!0,this.viewModel=new A,this.visibleElements={...U},this._handleOpenRelatedFeature=e=>{this._openRelatedFeature(e)},this._addSelectedFeatureIndexHandle(),this.addHandles([l((()=>this.viewModel?.screenLocation),(()=>this._positionContainer())),l((()=>[this.viewModel?.active,this.dockEnabled]),(()=>this._toggleScreenLocationEnabled())),l((()=>this.viewModel?.screenLocation),((e,t)=>{!!e!=!!t&&this.reposition()})),l((()=>[this.viewModel?.view?.padding,this.viewModel?.view?.size,this.viewModel?.active,this.viewModel?.location,this.alignment]),(()=>this.reposition())),l((()=>this.spinnerEnabled),(e=>this._spinnerEnabledChange(e))),l((()=>this.viewModel?.view?.size),((e,t)=>this._updateDockEnabledForViewSize(e,t))),l((()=>this.viewModel?.view),((e,t)=>this._viewChange(e,t))),l((()=>this.viewModel?.view?.ready),((e,t)=>this._viewReadyChange(e??!1,t??!1))),l((()=>[this.viewModel?.waitingForResult,this.viewModel?.location]),(()=>{this._hideSpinner(),this._displaySpinnerThrottled()})),l((()=>this.selectedFeatureWidget),(()=>this._destroyFlowItemWidgets())),l((()=>[this.selectedFeatureWidget?.viewModel?.title,this.selectedFeatureWidget?.viewModel?.state]),(()=>this._setTitleFromFeatureWidget())),l((()=>[this.selectedFeatureWidget?.viewModel?.content,this.selectedFeatureWidget?.viewModel?.state]),(()=>this._setContentFromFeatureWidget())),a((()=>!this.collapsed),(()=>{"xsmall"===this.viewModel?.view?.widthBreakpoint&&this.viewModel.active&&this.collapseEnabled&&this.viewModel.centerAtLocation()})),c((()=>this.viewModel?.allActions),"change",(()=>this._watchActions())),l((()=>this.viewModel?.allActions),(()=>this._watchActions()),u),l((()=>this.viewModel?.featureViewModels),(()=>this._featureMenuViewportScrollTop())),c((()=>this._flowItems),"change",(()=>{this.notifyChange("_activeFlowItemWidget"),this.scheduleRender()})),l((()=>[this._activeFlowItemWidget?.viewModel?.state,this._activeFlowItemWidget?.viewModel?.title]),(()=>this.scheduleRender()))])}loadDependencies(){return Promise.all([import("@esri/calcite-components/dist/components/calcite-flow.js"),import("@esri/calcite-components/dist/components/calcite-flow-item.js"),import("@esri/calcite-components/dist/components/calcite-action.js"),import("@esri/calcite-components/dist/components/calcite-tooltip.js"),import("@esri/calcite-components/dist/components/calcite-icon.js")])}destroy(){this._destroyFlowItemWidgets(),this._destroySelectedFeatureWidget(),this._destroySpinner(),this._handles?.destroy(),this._unobserveFeatureMenuObserver(),this._featureMenuIntersectionObserver?.disconnect()}get actionsMenuId(){return`${this.id}-actions-menu`}get actionsMenuButtonId(){return`${this.id}-actions-menu-button`}get featureMenuId(){return`${this.id}-feature-menu`}get titleId(){return`${this.id}-popup-title`}get contentId(){return`${this.id}-popup-content`}get hasContent(){const{selectedFeatureWidget:e,viewModel:t}=this;if(!e)return!!t?.content;const i=e.viewModel;if(i?.waitingForContent||"error"===i?.state)return!0;const o=i?.content;return Array.isArray(o)?!!o.length:!!o}get featureNavigationVisible(){return this.viewModel.active&&this.viewModel.featureCount>1&&null!=this.visibleElements.featureNavigation}get collapsible(){return!!(this.collapseEnabled&&this.viewModel.title&&this.hasContent)}get featureMenuVisible(){return this.featureNavigationVisible&&this.featureMenuOpen}get contentCollapsed(){return this.collapsible&&!this.featureMenuVisible&&this.collapsed}get dividedActions(){return this._divideActions()}get _activeFlowItemWidget(){const{_flowItems:e}=this;return e.getItemAt(e.length-1)||null}get actions(){return this.viewModel.actions}set actions(e){this.viewModel.actions=e}set actionsMenuOpen(e){this._set("actionsMenuOpen",!!e)}get actionsMenuOpen(){return!!this.viewModel.active&&this._get("actionsMenuOpen")}get autoCloseEnabled(){return this.viewModel.autoCloseEnabled}set autoCloseEnabled(e){this.viewModel.autoCloseEnabled=e}get autoOpenEnabled(){return this.viewModel.autoOpenEnabled}set autoOpenEnabled(e){this.viewModel.autoOpenEnabled=e}get defaultPopupTemplateEnabled(){return this.viewModel.defaultPopupTemplateEnabled}set defaultPopupTemplateEnabled(e){this.viewModel.defaultPopupTemplateEnabled=e}get content(){return this.viewModel.content}set content(e){this.viewModel.content=e}get currentAlignment(){return this._getCurrentAlignment()}get currentDockPosition(){return this._getCurrentDockPosition()}get dockOptions(){return this._get("dockOptions")||S}set dockOptions(e){const t={...S},i=this.viewModel?.view?.breakpoints,o={};i&&(o.width=i.xsmall,o.height=i.xsmall);const n={...t,...e},s={...t.breakpoint,...o},{breakpoint:r}=n;"object"==typeof r?n.breakpoint={...s,...r}:r&&(n.breakpoint=s),this._set("dockOptions",n),this._setCurrentDockPosition(),this.reposition()}get featureCount(){return this.viewModel.featureCount}get features(){return this.viewModel.features}set features(e){this.viewModel.features=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get highlightEnabled(){return this.viewModel.highlightEnabled}set highlightEnabled(e){this.viewModel.highlightEnabled=e}get location(){return this.viewModel.location}set location(e){this.viewModel.location=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get promises(){return this.viewModel.promises}set promises(e){this.viewModel.promises=e}get selectedFeature(){return this.viewModel.selectedFeature}get selectedFeatureIndex(){return this.viewModel.selectedFeatureIndex}set selectedFeatureIndex(e){this.viewModel.selectedFeatureIndex=e}get selectedFeatureWidget(){const{_feature:e,visibleElements:t,headingLevel:i,_flowItems:o}=this,{selectedFeatureViewModel:n}=this.viewModel,s={...t,title:!1};return n?(e?(e.viewModel=n,e.visibleElements=s):this._feature=new v({flowItems:o,headingLevel:i+1,viewModel:n,visibleElements:s}),this._feature):null}get title(){return this.viewModel.title}set title(e){this.viewModel.title=e}get updateLocationEnabled(){return this.viewModel.updateLocationEnabled}set updateLocationEnabled(e){this.viewModel.updateLocationEnabled=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visible(){return this.viewModel.visible}set visible(e){this.viewModel.visible=e}castVisibleElements(e){return{...U,...e}}blur(){const{active:e}=this.viewModel;e||n.getLogger(this.declaredClass).warn("Popup can only be blurred when currently active."),this.visibleElements.closeButton?this._blurClose=!0:this._blurContainer=!0,this.scheduleRender()}clear(){return this.viewModel.clear()}close(){this.visible=!1}fetchFeatures(e,t){return this.viewModel.fetchFeatures(e,t)}focus(){const{active:e}=this.viewModel;e||n.getLogger(this.declaredClass).warn("Popup can only be focused when currently active."),this.visibleElements.closeButton?this._focusClose=!0:this._focusContainer=!0,this.scheduleRender()}next(){return this.viewModel.next()}open(e){this._handles.remove(B);const t=!!e&&!!e.featureMenuOpen,i=!!e&&!!e.actionsMenuOpen,o={collapsed:!!e&&!!e.collapsed,actionsMenuOpen:i,featureMenuOpen:t};"xsmall"===this.viewModel?.view?.widthBreakpoint&&(o.collapsed=!0),this.set(o),this.viewModel.open(e),this._shouldFocus(e),this._addSelectedFeatureIndexHandle()}previous(){return this.viewModel.previous()}reposition(){this.renderNow(),this._positionContainer(),this._setCurrentAlignment()}triggerAction(e){return this.viewModel.triggerAction(e)}render(){const{actionsMenuOpen:e,dockEnabled:t,featureMenuVisible:i,dividedActions:o,currentAlignment:n,currentDockPosition:s}=this,{active:r}=this.viewModel,{menuActions:l}=o,a=r&&l.length>1&&e,c=r&&t,d=r&&!t,u=this.selectedFeature?.layer?.title,h=this.selectedFeature?.layer?.id,p={[y.alignTopCenter]:"top-center"===n,[y.alignBottomCenter]:"bottom-center"===n,[y.alignTopLeft]:"top-left"===n,[y.alignBottomLeft]:"bottom-left"===n,[y.alignTopRight]:"top-right"===n,[y.alignBottomRight]:"bottom-right"===n,[y.isDocked]:c,[y.shadow]:d,[y.isDockedTopLeft]:"top-left"===s,[y.isDockedTopCenter]:"top-center"===s,[y.isDockedTopRight]:"top-right"===s,[y.isDockedBottomLeft]:"bottom-left"===s,[y.isDockedBottomCenter]:"bottom-center"===s,[y.isDockedBottomRight]:"bottom-right"===s,[y.isFeatureMenuOpen]:i,[y.isActionsMenuOpen]:a};return x("div",{class:this.classes(y.base,p),role:"presentation","data-layer-title":u,"data-layer-id":h,bind:this,afterCreate:this._positionContainer,afterUpdate:this._positionContainer},r?[this.renderMainContainer(),this.renderPointer()]:null)}renderLoadingIcon(){return x("span",{"aria-hidden":"true",class:this.classes(y.icon,y.iconLoading,y.rotating)})}renderNavigationLoading(){const{messagesCommon:e}=this;return this.viewModel.pendingPromisesCount?x("div",{key:V("loading-container"),role:"presentation",class:y.loadingContainer,"aria-label":e.loading,title:e.loading},this.renderLoadingIcon()):null}renderPreviousIcon(){const e=O(this.container),t={[y.iconRightTriangleArrow]:e,[y.paginationPreviousIconRTL]:e,[y.iconLeftTriangleArrow]:!e,[y.paginationPreviousIconLTR]:!e};return x("span",{"aria-hidden":"true",class:this.classes(y.icon,t)})}renderPreviousButton(){const{messages:e}=this;return x("div",{role:"button",tabIndex:0,bind:this,onclick:this._previous,onkeydown:this._previous,class:this.classes(y.button,y.paginationPrevious),"aria-label":e.previous,title:e.previous},this.renderPreviousIcon())}renderNextIcon(){const e=O(this.container),t={[y.iconLeftTriangleArrow]:e,[y.paginationNextIconRTL]:e,[y.iconRightTriangleArrow]:!e,[y.paginationNextIconLTR]:!e};return x("span",{"aria-hidden":"true",class:this.classes(y.icon,t)})}renderNextButton(){const{messages:e}=this;return x("div",{role:"button",tabIndex:0,bind:this,onclick:this._next,onkeydown:this._next,class:this.classes(y.button,y.paginationNext),"aria-label":e.next,title:e.next},this.renderNextIcon())}renderFeatureMenuButton(){const{featureMenuOpen:e,featureMenuId:t,messagesCommon:i}=this,{featureCount:o,selectedFeatureIndex:n}=this.viewModel;return x("div",{role:"button",tabIndex:0,bind:this,onclick:this._toggleFeatureMenu,onkeydown:this._toggleFeatureMenu,afterCreate:this._focusFeatureMenuButtonNode,afterUpdate:this._focusFeatureMenuButtonNode,class:this.classes(y.button,y.featureMenuButton),"aria-haspopup":"true","aria-controls":t,"aria-expanded":e.toString(),"aria-label":i.menu,title:i.menu},this._getPageText(o,n))}renderNavigationButtons(){return this.featureNavigationVisible?[this.renderPreviousButton(),this.renderNavigationLoading()||this.renderFeatureMenuButton(),this.renderNextButton()]:[]}renderDockIcon(){const{dockEnabled:e}=this,t=this._wouldDockTo(),i={[y.iconUndock]:e,[y.iconDock]:!e,[y.iconDockToRight]:!e&&("top-right"===t||"bottom-right"===t),[y.iconDockToLeft]:!e&&("top-left"===t||"bottom-left"===t),[y.iconDockToTop]:!e&&"top-center"===t,[y.iconDockToBottom]:!e&&"bottom-center"===t};return x("span",{"aria-hidden":"true",class:this.classes(i,y.icon)})}renderDockButton(){const{dockEnabled:e,messages:t}=this,i=this.viewModel?.view?.widthBreakpoint,o=e?t.undock:t.dock;return"xsmall"!==i&&this.dockOptions?.buttonEnabled?x("div",{role:"button","aria-label":o,title:o,tabIndex:0,bind:this,onclick:this._toggleDockEnabled,onkeydown:this._toggleDockEnabled,afterCreate:this._focusDockButtonNode,afterUpdate:this._focusDockButtonNode,class:this.classes(y.button,y.buttonDock)},this.renderDockIcon()):null}renderTitle(){const{title:e}=this.viewModel,{titleId:t,collapsible:i,contentCollapsed:o,messagesCommon:n}=this,s={[y.headerContainerButton]:i},r=x(k,{level:this.headingLevel,class:y.headerTitle,innerHTML:e??""}),l=i?x("button",{key:`${e}--collapsible`,id:t,title:o?n.expand:n.collapse,bind:this,enterAnimation:this._createFeatureUpdatedAnimation(),class:this.classes(y.headerContainer,s),"aria-expanded":o?"false":"true",onclick:this._toggleCollapsed,type:"button"},r,x("calcite-icon",{class:y.collapseIcon,key:"collapse-icon",icon:o?"chevron-down":"chevron-up",scale:"m"})):x("div",{key:e??"title",id:t,bind:this,enterAnimation:this._createFeatureUpdatedAnimation(),class:this.classes(y.headerContainer,s)},r);return e?l:null}renderCloseIcon(){return x("span",{"aria-hidden":"true",class:this.classes(y.icon,y.iconClose)})}renderCloseButton(){const{visibleElements:e,messagesCommon:t}=this;return e.closeButton?x("div",{role:"button",tabIndex:0,bind:this,onclick:this._close,onkeydown:this._close,class:y.button,"aria-label":t.close,title:t.close,afterCreate:this._closeButtonNodeUpdated,afterUpdate:this._closeButtonNodeUpdated},this.renderCloseIcon()):null}renderHeader(){return x("header",{class:y.header},this.renderTitle(),x("div",{class:y.headerButtons},this.renderDockButton(),this.renderCloseButton()))}renderContentContainer(){const{contentId:e,hasContent:t,contentCollapsed:i,_flowItems:o}=this,{content:n}=this.viewModel,s=o.toArray(),r={[y.contentHasFlows]:!!s.length};return t&&!i?x("div",{key:n??"content",enterAnimation:this._createFeatureUpdatedAnimation(),id:e,class:this.classes(y.content,r)},x("calcite-flow",{bind:this},x("calcite-flow-item",{bind:this,"data-node-ref":"_rootFlowItemNode",afterCreate:E,key:"root-flow-item",onCalciteFlowItemBack:this._handleBackClick},this.renderContent()),s.map((e=>this.renderFlowItem(e)))),s.map((e=>this.renderFlowItemTooltips(e)))):null}renderFlowItem(e){const{messages:t}=this,i=P(),o="graphic"in e&&!e.isTable;return x("calcite-flow-item",{bind:this,class:this.classes({[y.calciteThemeDark]:!i,[y.calciteThemeLight]:i}),heading:e.title??"",description:this._getFlowItemDescription(e),onCalciteFlowItemBack:this._handleBackClick,key:`flow-item-${e.viewModel.uid}`},x("calcite-action",{class:y.actionExit,icon:"move-up",label:t?.exitRelatedRecords,text:t?.exitRelatedRecords,slot:"header-actions-start",bind:this,afterCreate:t=>this._storeExitRelatedRecordsAction(e,t),onclick:this._destroyFlowItemWidgets}),o?x("calcite-action",{class:y.actionSelectFeature,icon:"zoom-to-object",label:t?.selectFeature,text:t?.selectFeature,slot:"header-actions-end",bind:this,afterCreate:t=>this._storeFeatureSelectionAction(e,t),onclick:()=>this._handleOpenRelatedFeature(e)}):null,x("div",{class:this.classes(y.contentFlowItem,{[y.calciteThemeDark]:i,[y.calciteThemeLight]:!i})},e.render()))}renderFlowItemTooltips(e){const{messages:t,_exitRelatedRecordsActions:i,_featureSelectionActions:o}=this,n=P(),s=o.get(e);return[x("calcite-tooltip",{class:this.classes({[y.calciteThemeDark]:!n,[y.calciteThemeLight]:n}),key:`exit-related-records-tooltip-${e.viewModel.uid}`,label:t?.exitRelatedRecords,overlayPositioning:"fixed",referenceElement:i.get(e),placement:"top"},t?.exitRelatedRecords),s?x("calcite-tooltip",{class:this.classes({[y.calciteThemeDark]:!n,[y.calciteThemeLight]:n}),key:`select-related-record-tooltip-${e.viewModel.uid}`,label:t?.selectFeature,overlayPositioning:"fixed",referenceElement:s,placement:"top"},t?.selectFeature):null]}renderActionsMenuButton(){const{actionsMenuId:e,actionsMenuButtonId:t,actionsMenuOpen:i,dividedActions:o,messagesCommon:n}=this,s=i?n.close:n.open,{menuActions:r}=o;return r.length?x("div",{key:V("actions-menu-button"),class:this.classes(y.button,y.actionsMenuButton),role:"button",id:t,"aria-haspopup":"true","aria-controls":i?e:null,tabIndex:0,bind:this,onclick:this._toggleActionsMenu,onkeydown:this._toggleActionsMenu,afterCreate:this._focusActionsMenuButtonNode,afterUpdate:this._focusActionsMenuButtonNode,"aria-label":s,title:s},x("span",{"aria-hidden":"true",class:y.iconActionsMenu})):null}renderMenuActions(){const{actionsMenuId:e,actionsMenuButtonId:t,actionsMenuOpen:i,dividedActions:o}=this,{menuActions:n}=o;return n.length&&i?x("ul",{id:e,role:"menu","aria-labelledby":t,key:V("actions"),class:y.actions,bind:this,onkeyup:this._handleActionMenuKeyup,afterCreate:this._actionsMenuNodeUpdated,afterUpdate:this._actionsMenuNodeUpdated},n.toArray().map((e=>this.renderAction({action:e,type:"menu-item"})))):null}renderInlineActions(){const{inlineActions:e}=this.dividedActions;return e.length?e.toArray().map((e=>this.renderAction({action:e,type:"inline"}))):[]}renderInlineActionsContainer(){const{inlineActions:e,menuActions:t}=this.dividedActions,i=!!e.length,o=!!t.length;return i||o?x("div",{key:"inline-actions-container","data-inline-actions":i.toString(),"data-menu-actions":o.toString(),class:y.inlineActionsContainer},this.renderInlineActions(),this.renderActionsMenuButton(),this.renderMenuActions()):null}renderNavigation(){return this.featureNavigationVisible?x("section",{key:V("navigation"),class:this.classes(y.navigation)},this.renderNavigationButtons()):null}renderFooter(){const{featureNavigationVisible:e,dividedActions:t}=this,{inlineActions:i,menuActions:o}=t,n=!!i.length,s=!!o.length,r={[y.footerHasPagination]:e,[y.footerHasActions]:n,[y.footerHasActionsMenu]:s};return e||n?x("div",{key:V("feature-buttons"),class:this.classes(y.footer,r)},this.renderInlineActionsContainer(),this.renderNavigation()):null}renderFeatureMenuContainer(){const{messages:e}=this,{featureViewModels:t,isLoadingFeature:i}=this.viewModel,o=T(e.selectedFeatures,{total:t.length});return x("section",{key:V("menu"),class:y.featureMenu},x("strong",{class:y.featureMenuHeader},o),x("nav",{bind:this,class:y.featureMenuViewport,"data-node-ref":"_featureMenuViewportNode",afterCreate:E},this.renderFeatureMenu(),x("div",{class:y.featureMenuObserver,bind:this,afterCreate:this._featureMenuIntersectionObserverCreated}),i?x("div",{class:y.featureMenuLoader},this.renderLoadingIcon()):null))}renderPointer(){return this.dockEnabled?null:x("div",{key:V("pointer"),class:y.pointer,role:"presentation"},x("div",{class:this.classes(y.pointerDirection,y.shadow)}))}renderMainContainer(){const{dockEnabled:e,currentAlignment:t,currentDockPosition:i,titleId:o,contentId:n,collapsible:s,hasContent:r,contentCollapsed:l,visibleElements:a}=this,{title:c}=this.viewModel,d="bottom-left"===t||"bottom-center"===t||"bottom-right"===t||"top-left"===i||"top-center"===i||"top-right"===i,u="top-left"===t||"top-center"===t||"top-right"===t||"bottom-left"===i||"bottom-center"===i||"bottom-right"===i,h={[y.shadow]:e,[y.isCollapsible]:s,[y.isCollapsed]:l};return x("div",{class:this.classes(y.main,y.widget,h),tabIndex:a.closeButton?void 0:-1,role:"dialog","aria-labelledby":c?o:"","aria-describedby":r&&!l?n:"",bind:this,onkeyup:this._handleMainKeyup,afterCreate:this._mainContainerNodeUpdated,afterUpdate:this._mainContainerNodeUpdated},d?this.renderFooter():null,d?this.renderFeatureMenuContainer():null,this.renderHeader(),this.renderContentContainer(),u?this.renderFooter():null,u?this.renderFeatureMenuContainer():null)}renderContent(){const e=this.viewModel?.content;return e?"string"==typeof e?x("div",{class:w.contentNode,key:e,innerHTML:e}):this.renderNodeContent(e):null}renderActionText(e){return x("span",{key:"text",class:y.actionText},e)}renderActionIcon(e){const t=this._getActionClass(e),i=this._getActionImage(e),o={[y.iconLoading]:e.active,[y.rotating]:e.active,[y.icon]:!!t,[y.actionImage]:!e.active&&!!i};return t&&(o[t]=!e.active),x("span",{key:"icon","aria-hidden":"true",class:this.classes(y.icon,o),styles:this._getIconStyles(i)})}renderAction(e){const{action:t,type:i}=e,o=this._getActionTitle(t),n={[y.action]:"toggle"!==t.type,[y.actionToggle]:"toggle"===t.type,[y.actionToggleOn]:"toggle"===t.type&&t.value,[y.buttonDisabled]:t.disabled},s=[this.renderActionIcon(t),this.renderActionText(o)],r="menu-item"===i?x("li",{key:t.uid,role:"menuitem",tabIndex:0,title:o,"aria-label":o,class:this.classes(y.button,n),onkeyup:this._handleActionMenuItemKeyup,bind:this,"data-action-uid":t.uid,onclick:this._triggerAction,onkeydown:this._triggerAction},s):x("div",{key:t.uid,role:"button",tabIndex:0,title:o,"aria-label":o,class:this.classes(y.button,n),onkeyup:this._handleActionMenuItemKeyup,bind:this,"data-action-uid":t.uid,onclick:this._triggerAction,onkeydown:this._triggerAction},s);return t.visible?r:null}renderFeatureMenuItem(e,t){const{messages:i,messagesCommon:o}=this,{selectedFeatureIndex:n,selectedFeatureViewModel:s}=this.viewModel,r=e===s,l={[y.featureMenuSelected]:r},a=r?x("span",{key:V(`feature-menu-selected-feature-${n}`),title:i.selectedFeature,"aria-label":i.selectedFeature,class:y.iconCheckMark}):null,c=x("span",{innerHTML:e.title||o.untitled});return x("li",{role:"menuitem",tabIndex:-1,key:V(`feature-menu-feature-${n}`),class:this.classes(l,y.featureMenuItem),bind:this,"data-feature-index":t,onblur:this._removeActiveFeature,onfocus:this._setActiveFeature,onkeyup:this._handleFeatureMenuItemKeyup,onclick:this._selectFeature,onkeydown:this._selectFeature,onmouseover:this._setActiveFeature,onmouseleave:this._removeActiveFeature},x("span",{class:y.featureMenuTitle},c,a))}renderFeatureMenu(){const{featureMenuId:e}=this,{featureViewModels:t}=this.viewModel;return t.length>1?x("ol",{class:y.featureMenuList,id:e,bind:this,afterCreate:this._featureMenuNodeUpdated,afterUpdate:this._featureMenuNodeUpdated,onkeyup:this._handleFeatureMenuKeyup,role:"menu"},t.filter((e=>!!e.graphic)).map(((e,t)=>this.renderFeatureMenuItem(e,t)))):null}_storeFeatureSelectionAction(e,t){this._featureSelectionActions.set(e,t),this.scheduleRender()}_storeExitRelatedRecordsAction(e,t){this._exitRelatedRecordsActions.set(e,t),this.scheduleRender()}_getFlowItemDescription(e){return"featureCountDescription"in e?e.featureCountDescription:e.viewModel.description??""}async _openRelatedFeature(e){await e.viewModel.updateGeometry();const t=e.graphic,i=t?.geometry;if(s(i)||s(t))return;this._destroyFlowItemWidgets(),await this.viewModel.zoomTo({target:i});const o=M(i);this.open({features:[t],location:r(o)?o:void 0})}_destroyFlowItemWidgets(){this._flowItems.removeAll().forEach((e=>{"showAllEnabled"in e.viewModel&&(e.viewModel.showAllEnabled=!1),e.viewModel=null,e.destroy()}))}_handleBackClick(){const e=this._flowItems.pop();e&&(this._exitRelatedRecordsActions.delete(e),this._featureSelectionActions.delete(e),"showAllEnabled"in e.viewModel&&(e.viewModel.showAllEnabled=!1),e&&(e.viewModel=null,e.destroy()))}_getActionTitle(e){const{messages:t,selectedFeature:i,messagesCommon:o}=this,{id:n}=e,s=i?.attributes,r=e.title??"",l="zoom-to-feature"===n?T(r,{messages:t}):"remove-selected-feature"===n?T(r,{messages:o}):"zoom-to-clustered-features"===n||"browse-clustered-features"===n?T(r,{messages:t}):e.title;return l&&s?T(l,s):l??""}_getActionClass(e){const{selectedFeature:t}=this,i=t?.attributes,{className:o,image:n}=e,s=n||o?o:y.iconDefaultAction;return s&&i?T(s,i):s??""}_getActionImage(e){const{selectedFeature:t}=this,i=t?.attributes,{image:o}=e;return o&&i?T(o,i):o??""}_createFeatureUpdatedAnimation(){return N("enter",y.hasFeatureUpdated)}_getInlineActionCount(){const{maxInlineActions:e,featureNavigationVisible:t}=this;if("number"!=typeof e)return null;const i=Math.round(e);return Math.max(t?i-1:i,0)}_watchActions(){const{allActions:e}=this.viewModel;this.notifyChange("dividedActions");const t="actions";this._handles.remove(t),e&&e.forEach((e=>{this._handles.add(l((()=>[e.uid,e.active,e.className,e.disabled,e.id,e.title,e.image,e.visible]),(()=>this.scheduleRender())),t)}))}_divideActions(){const{allActions:e}=this.viewModel,i=e.filter((e=>e.visible)),o=this._getInlineActionCount(),n=null===o,s=0===o;return{inlineActions:n?i.slice(0):s?new t:i.slice(0,o),menuActions:n?new t:s?i.slice(0):i.slice(o)}}_featureMenuOpenChanged(e){e?this._focusFirstFeature=!0:this._focusFeatureMenuButton=!0}_actionsMenuOpenChanged(e){e?this._focusFirstAction=!0:this._focusActionsMenuButton=!0}_setTitleFromFeatureWidget(){const{selectedFeatureWidget:e,messagesCommon:t}=this;e&&(this.viewModel.title="error"===e.viewModel?.state?t.errorMessage:e.viewModel?.title||"")}_setContentFromFeatureWidget(){const{selectedFeatureWidget:e}=this;e&&(this.viewModel.content=e)}_unobserveFeatureMenuObserver(){this._featureMenuIntersectionObserverNode&&this._featureMenuIntersectionObserver.unobserve(this._featureMenuIntersectionObserverNode)}_featureMenuIntersectionObserverCreated(e){this._unobserveFeatureMenuObserver(),this._featureMenuIntersectionObserver.observe(e),this._featureMenuIntersectionObserverNode=e}_handleFeatureMenuKeyup(e){"Escape"===i(e)&&(e.stopPropagation(),this._focusFeatureMenuButton=!0,this.featureMenuOpen=!1,this.scheduleRender())}_handleActionMenuKeyup(e){"Escape"===i(e)&&(e.stopPropagation(),this._focusActionsMenuButton=!0,this.actionsMenuOpen=!1,this.scheduleRender())}_setActiveFeature(e){const{viewModel:t}=this,i=e.currentTarget["data-feature-index"];t.activeFeature=t.features[i]||null}_removeActiveFeature(){this.viewModel.activeFeature=null}_handleFeatureMenuItemKeyup(e){const t=i(e),{_featureMenuNode:o}=this,n=e.currentTarget["data-feature-index"];if(!o)return;const s=o.querySelectorAll("li"),r=s.length;if("ArrowUp"!==t)if("ArrowDown"!==t)if("Home"!==t)if("End"!==t);else{e.stopPropagation();s[s.length-1].focus()}else{e.stopPropagation();s[0].focus()}else{e.stopPropagation();s[(n+1+r)%r].focus()}else{e.stopPropagation();s[(n-1+r)%r].focus()}}_handleActionMenuItemKeyup(e){const t=i(e),{_actionsMenuNode:o}=this,n=e.currentTarget.dataset.actionUid,{menuActions:s}=this.dividedActions,r=s.findIndex((e=>e.uid===n));if(!o)return;const l=o.querySelectorAll("li"),a=l.length;if("ArrowUp"!==t)if("ArrowDown"!==t)if("Home"!==t)if("End"!==t);else{e.stopPropagation();l[l.length-1].focus()}else{e.stopPropagation();l[0].focus()}else{e.stopPropagation();l[(r+1+a)%a].focus()}else{e.stopPropagation();l[(r-1+a)%a].focus()}}_handleMainKeyup(e){const t=i(e);"ArrowLeft"===t&&(e.stopPropagation(),this.previous()),"ArrowRight"===t&&(e.stopPropagation(),this.next())}_spinnerEnabledChange(e){if(this._destroySpinner(),!e)return;const t=this.get("viewModel.view");this._createSpinner(t)}_hideSpinner(){const{_spinner:e}=this;e&&(e.location=null,e.hide())}_displaySpinner(){const{_spinner:e}=this;if(!e)return;const{location:t,waitingForResult:i}=this.viewModel;i&&t?e.show({location:t}):e.hide()}_getIconStyles(e){return{"background-image":e?`url(${e})`:""}}async _shouldFocus(e){e?.shouldFocus&&(await d((()=>!0===this.viewModel?.active)),this.focus())}_addSelectedFeatureIndexHandle(){const e=l((()=>this.viewModel?.selectedFeatureIndex),((e,t)=>this._selectedFeatureIndexUpdated(e,t)));this._handles.add(e,B)}_selectedFeatureIndexUpdated(e,t){const{featureCount:i}=this;i&&e!==t&&-1!==e&&(this._destroyFlowItemWidgets(),this.actionsMenuOpen=!1,this.featureMenuOpen=!1,this._mainContainerNode&&(this._mainContainerNode.scrollTop=0),this._rootFlowItemNode&&this._rootFlowItemNode.scrollContentTo({top:0}))}_destroySelectedFeatureWidget(){const{_feature:e}=this;e&&(e.viewModel=null,e&&!e.destroyed&&e.destroy()),this._feature=null}_isScreenLocationWithinView(e,t){return e.x>-1&&e.y>-1&&e.x<=t.width&&e.y<=t.height}_isOutsideView(e){const{popupHeight:t,popupWidth:i,screenLocation:o,side:n,view:s}=e;if(isNaN(i)||isNaN(t)||!s||!o)return!1;const r=s.padding;return"right"===n&&o.x+i/2>s.width-r.right||("left"===n&&o.x-i/2<r.left||("top"===n&&o.y-t<r.top||"bottom"===n&&o.y+t>s.height-r.bottom))}_calculateAutoAlignment(e){if("auto"!==e)return e;const{_pointerOffsetInPx:t,_containerNode:i,_mainContainerNode:o,viewModel:n}=this,{screenLocation:r,view:l}=n;if(s(r)||!l||!i)return"top-center";if(!this._isScreenLocationWithinView(r,l))return this._get("currentAlignment")||"top-center";function a(e){return parseInt(e.replace(/[^-\d\.]/g,""),10)}const c=o?window.getComputedStyle(o,null):null,d=c?a(c.getPropertyValue("max-height")):0,u=c?a(c.getPropertyValue("height")):0,{height:h,width:p}=i.getBoundingClientRect(),g=p+t,m=Math.max(h,d,u)+t,v=this._isOutsideView({popupHeight:m,popupWidth:g,screenLocation:r,side:"right",view:l}),f=this._isOutsideView({popupHeight:m,popupWidth:g,screenLocation:r,side:"left",view:l}),_=this._isOutsideView({popupHeight:m,popupWidth:g,screenLocation:r,side:"top",view:l}),w=this._isOutsideView({popupHeight:m,popupWidth:g,screenLocation:r,side:"bottom",view:l});return f?_?"bottom-right":"top-right":v?_?"bottom-left":"top-left":_?w?"top-center":"bottom-center":"top-center"}_callCurrentAlignment(e){return"function"==typeof e?e.call(this):e}_getCurrentAlignment(){const{alignment:e,dockEnabled:t}=this;return t||!this.viewModel.active?null:this._calculatePositionResult(this._calculateAutoAlignment(this._callCurrentAlignment(e)))}_setCurrentAlignment(){this._set("currentAlignment",this._getCurrentAlignment())}_setCurrentDockPosition(){this._set("currentDockPosition",this._getCurrentDockPosition())}_calculatePositionResult(e){const t=["left","right"];return O(this.container)&&t.reverse(),e.replace(/leading/gi,t[0]).replace(/trailing/gi,t[1])}_callDockPosition(e){return"function"==typeof e?e.call(this):e}_getDockPosition(){return this._calculatePositionResult(this._calculateAutoDockPosition(this._callDockPosition(this.dockOptions?.position)))}_getCurrentDockPosition(){return this.dockEnabled&&this.viewModel.active?this._getDockPosition():null}_wouldDockTo(){return this.dockEnabled?null:this._getDockPosition()}_calculateAutoDockPosition(e){if("auto"!==e)return e;const t=this.viewModel?.view,i=O(this.container)?"top-left":"top-right";if(!t)return i;const o=t.padding||{left:0,right:0,top:0,bottom:0},n=t.width-o.left-o.right,{breakpoints:s}=t;return s&&n<=s.xsmall?"bottom-center":i}_positionContainer(e=this._containerNode){if(e&&(this._containerNode=e),!this._containerNode)return;const{screenLocation:t}=this.viewModel,{width:i}=this._containerNode.getBoundingClientRect(),o=this._calculatePositionStyle(t,i);o&&Object.assign(this._containerNode.style,o)}_calculateFullWidth(e){const{currentAlignment:t,_pointerOffsetInPx:i}=this;return"top-left"===t||"bottom-left"===t||"top-right"===t||"bottom-right"===t?e+i:e}_calculateAlignmentPosition(e,t,i,o){const{currentAlignment:n,_pointerOffsetInPx:s}=this;if(!i)return;const{padding:r}=i,l=o/2,a=i.height-t,c=i.width-e;return"bottom-center"===n?{top:t+s-r.top,left:e-l-r.left}:"top-left"===n?{bottom:a+s-r.bottom,right:c+s-r.right}:"bottom-left"===n?{top:t+s-r.top,right:c+s-r.right}:"top-right"===n?{bottom:a+s-r.bottom,left:e+s-r.left}:"bottom-right"===n?{top:t+s-r.top,left:e+s-r.left}:"top-center"===n?{bottom:a+s-r.bottom,left:e-l-r.left}:void 0}_calculatePositionStyle(e,t){const{dockEnabled:i,view:o}=this;if(!o)return;if(i)return{left:"",top:"",right:"",bottom:""};if(s(e)||!t)return;const n=this._calculateFullWidth(t),r=this._calculateAlignmentPosition(e.x,e.y,o,n);return r?{top:void 0!==r.top?`${r.top}px`:"auto",left:void 0!==r.left?`${r.left}px`:"auto",bottom:void 0!==r.bottom?`${r.bottom}px`:"auto",right:void 0!==r.right?`${r.right}px`:"auto"}:void 0}_viewChange(e,t){e&&t&&(this.close(),this.clear())}_viewReadyChange(e,t){if(e){const e=this.get("viewModel.view");this._wireUpView(e)}else t&&(this.close(),this.clear())}_wireUpView(e){if(this._destroySpinner(),!e)return;const{spinnerEnabled:t}=this;t&&this._createSpinner(e),this._setDockEnabledForViewSize(this.dockOptions)}_dockingThresholdCrossed(e,t,i){const[o,n]=e,[s,r]=t,{width:l=0,height:a=0}=i??{};return o<=l&&s>l||o>l&&s<=l||n<=a&&r>a||n>a&&r<=a}_updateDockEnabledForViewSize(e,t){if(!e||!t)return;const i=this.get("viewModel.view.padding")||{left:0,right:0,top:0,bottom:0},o=i.left+i.right,n=i.top+i.bottom,s=[],r=[];s[0]=e[0]-o,s[1]=e[1]-n,r[0]=t[0]-o,r[1]=t[1]-n;const{dockOptions:l}=this,a=l.breakpoint;this._dockingThresholdCrossed(s,r,a)&&this._setDockEnabledForViewSize(l),this._setCurrentDockPosition()}_focusDockButtonNode(e){this._focusDockButton&&(this._focusDockButton=!1,e.focus())}_closeButtonNodeUpdated(e){return this._focusClose?(this._focusClose=!1,void e.focus()):this._blurClose?(this._blurClose=!1,void e.blur()):void 0}_mainContainerNodeUpdated(e){return this._mainContainerNode=e,this._focusContainer?(this._focusContainer=!1,void e.focus()):this._blurContainer?(this._blurContainer=!1,void e.blur()):void 0}_featureMenuNodeUpdated(e){if(this._featureMenuNode=e,!e||!this._focusFirstFeature)return;this._focusFirstFeature=!1;const t=e.querySelectorAll("li");if(t.length){t[0].focus()}}_actionsMenuNodeUpdated(e){if(this._actionsMenuNode=e,!e||!this._focusFirstAction)return;this._focusFirstAction=!1;const t=e.querySelectorAll("li");if(t.length){t[0].focus()}}_focusFeatureMenuButtonNode(e){this._focusFeatureMenuButton&&(this._focusFeatureMenuButton=!1,e.focus())}_focusActionsMenuButtonNode(e){this._focusActionsMenuButton&&(this._focusActionsMenuButton=!1,e.focus())}_featureMenuViewportScrollTop(){this._featureMenuViewportNode&&(this._featureMenuViewportNode.scrollTop=0)}_toggleScreenLocationEnabled(){const{dockEnabled:e,viewModel:t}=this;if(!t)return;const i=t.active&&!e;t.screenLocationEnabled=i}_shouldDockAtCurrentViewSize(e){const t=e.breakpoint,i=this.viewModel?.view?.ui;if(!i)return!1;const{width:o,height:n}=i;if(isNaN(o)||isNaN(n))return!1;if(!t)return!1;const s=t.hasOwnProperty("width")&&o<=(t.width??0),r=t.hasOwnProperty("height")&&n<=(t.height??0);return s||r}_setDockEnabledForViewSize(e){e.breakpoint&&(this.dockEnabled=this._shouldDockAtCurrentViewSize(e))}_getPageText(e,t){return this.featureNavigationVisible?T(this.messages.pageText,{index:t+1,total:e}):null}_destroySpinner(){const{_spinner:e,view:t}=this;e&&(t&&t.ui&&t.ui.remove(e,L),e.destroy(),this._spinner=null)}_createSpinner(e){e&&(this._spinner=new f({view:e}),e.ui.add(this._spinner,{key:L,position:"manual"}))}_toggleCollapsed(){this.collapsed=!this.collapsed}_close(){this.close(),this.view&&this.view.focus()}_toggleDockEnabled(){this.dockEnabled=!this.dockEnabled,this._focusDockButton=!0,this.scheduleRender()}_toggleFeatureMenu(){const e=!this.featureMenuOpen;this._featureMenuOpenChanged(e),this.actionsMenuOpen=!1,this.featureMenuOpen=e}_toggleActionsMenu(){const e=!this.actionsMenuOpen;this._actionsMenuOpenChanged(e),this.featureMenuOpen=!1,this.actionsMenuOpen=e}_triggerAction(e){const t=e.currentTarget.dataset.actionUid,{allActions:i}=this.viewModel,o=i.findIndex((e=>e.uid===t)),n=i.getItemAt(o);n&&"toggle"===n.type&&(n.value=!n.value),this.actionsMenuOpen=!1,this.viewModel.triggerAction(o)}_selectFeature(e){const t=e.currentTarget["data-feature-index"];isNaN(t)||(this.viewModel.selectedFeatureIndex=t),this.featureMenuOpen=!1,this._focusFeatureMenuButton=!0,this.scheduleRender()}_next(){this.next()}_previous(){this.previous()}};e([p({readOnly:!0})],W.prototype,"actionsMenuId",null),e([p({readOnly:!0})],W.prototype,"actionsMenuButtonId",null),e([p({readOnly:!0})],W.prototype,"featureMenuId",null),e([p({readOnly:!0})],W.prototype,"titleId",null),e([p({readOnly:!0})],W.prototype,"contentId",null),e([p({readOnly:!0})],W.prototype,"hasContent",null),e([p({readOnly:!0})],W.prototype,"featureNavigationVisible",null),e([p({readOnly:!0})],W.prototype,"collapsible",null),e([p({readOnly:!0})],W.prototype,"featureMenuVisible",null),e([p({readOnly:!0})],W.prototype,"contentCollapsed",null),e([p({readOnly:!0})],W.prototype,"dividedActions",null),e([p({readOnly:!0,dependsOn:["_flowItems.length"]})],W.prototype,"_activeFlowItemWidget",null),e([p()],W.prototype,"actions",null),e([p()],W.prototype,"actionsMenuOpen",null),e([p()],W.prototype,"alignment",void 0),e([p()],W.prototype,"autoCloseEnabled",null),e([p()],W.prototype,"autoOpenEnabled",null),e([p()],W.prototype,"defaultPopupTemplateEnabled",null),e([p()],W.prototype,"content",null),e([p()],W.prototype,"collapsed",void 0),e([p()],W.prototype,"collapseEnabled",void 0),e([p({readOnly:!0})],W.prototype,"currentAlignment",null),e([p({readOnly:!0})],W.prototype,"currentDockPosition",null),e([p()],W.prototype,"dockOptions",null),e([p()],W.prototype,"dockEnabled",void 0),e([p({readOnly:!0})],W.prototype,"featureCount",null),e([p()],W.prototype,"featureMenuOpen",void 0),e([p()],W.prototype,"features",null),e([p()],W.prototype,"goToOverride",null),e([p()],W.prototype,"headingLevel",void 0),e([p()],W.prototype,"highlightEnabled",null),e([p()],W.prototype,"location",null),e([p()],W.prototype,"label",null),e([p()],W.prototype,"maxInlineActions",void 0),e([p(),C("esri/widgets/Popup/t9n/Popup")],W.prototype,"messages",void 0),e([p(),C("esri/t9n/common")],W.prototype,"messagesCommon",void 0),e([p()],W.prototype,"promises",null),e([p({readOnly:!0})],W.prototype,"selectedFeature",null),e([p()],W.prototype,"selectedFeatureIndex",null),e([p({readOnly:!0})],W.prototype,"selectedFeatureWidget",null),e([p()],W.prototype,"spinnerEnabled",void 0),e([p()],W.prototype,"title",null),e([p()],W.prototype,"updateLocationEnabled",null),e([p()],W.prototype,"view",null),e([p({type:A}),I(["triggerAction","trigger-action"])],W.prototype,"viewModel",void 0),e([p()],W.prototype,"visible",null),e([p()],W.prototype,"visibleElements",void 0),e([g("visibleElements")],W.prototype,"castVisibleElements",null),e([F()],W.prototype,"_close",null),e([F()],W.prototype,"_toggleDockEnabled",null),e([F()],W.prototype,"_toggleFeatureMenu",null),e([F()],W.prototype,"_toggleActionsMenu",null),e([F()],W.prototype,"_triggerAction",null),e([F()],W.prototype,"_selectFeature",null),e([F()],W.prototype,"_next",null),e([F()],W.prototype,"_previous",null),W=e([m("esri.widgets.Popup")],W);const j=W;export{j as default};