@arcgis/core 4.31.1 → 4.31.3

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/widgets/Print.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import"../geometry.js";import"../intl.js";import t from"../core/Collection.js";import{JSONMap as i}from"../core/jsonMap.js";import{watch as a,whenOnce as l}from"../core/reactiveUtils.js";import{unitName as o}from"../core/unitFormatUtils.js";import{addProxy as n,hasSameOrigin as s}from"../core/urlUtils.js";import{property as r}from"../core/accessorSupport/decorators/property.js";import{ensureInteger as c}from"../core/accessorSupport/ensureType.js";import"../core/RandomLCG.js";import"../core/has.js";import{subclass as p}from"../core/accessorSupport/decorators/subclass.js";import{isValid as d}from"../geometry/support/spatialReferenceUtils.js";import{reArcGISOnlineDomain as m}from"../portal/support/urlUtils.js";import{getToken as u}from"../rest/utils.js";import{formatJsonMap as h}from"../rest/support/fileFormat.js";import b from"./Widget.js";import _ from"./Print/FileLink.js";import v from"./Print/PrintViewModel.js";import{loadCalciteComponents as g}from"./support/componentsUtils.js";import{globalCss as f}from"./support/globalCss.js";import{Heading as y}from"./support/Heading.js";import{legacyIcon as w}from"./support/legacyIcon.js";import{isRTL as T,isActivationKey as x}from"./support/widgetUtils.js";import{messageBundle as k}from"./support/decorators/messageBundle.js";import{tsx as C}from"./support/jsxFactory.js";import S from"../geometry/SpatialReference.js";import{formatNumber as O}from"../intl/number.js";const $=t.ofType(_),I="map-only";var E;!function(e){e.layout="layoutTab",e.mapOnly="mapOnlyTab",e.export="exportTab"}(E||(E={}));const L="esri-print",F=`${L}__advanced-options-button`,M={base:L,headerTitle:`${L}__header-title`,layoutTabList:`${L}__layout-tab-list`,layoutTab:`${L}__layout-tab`,layoutSection:`${L}__layout-section`,mapOnlySection:`${L}__map-only-section`,panelItemsCentered:`${L}__panel-items--centered`,loader:`${L}__loader`,advancedOptionsButton:F,advancedOptionsButtonContainer:`${F}-container`,advancedOptionsButtonTitle:`${F}-title`,advancedOptionsButtonIconOpened:`${F}-icon--opened`,advancedOptionsButtonIconClosed:`${F}-icon--closed`,advancedOptionsButtonIconClosed_RTL:`${F}-icon--closed-rtl`,swapButton:`${L}__swap-button`,printButton:`${L}__export-button`,printButtonSection:`${L}__export-button-section`,printButtonSectionDivider:`${L}__export-button-section--divider`,templateSelectContainer:`${L}__template-select-container`,templateSelectBlock:`${L}__template-select-block`,templateSelectIcon:`${L}__template-select-icon`,templateSelectError:`${L}__template-select-error`,templateSelectArrow:`${L}__template-select-arrow`,formSectionContainer:`${L}__form-section-container`,formCheckboxLabel:`${L}__form-checkbox-label`,advancedOptionsSection:`${L}__advanced-options-section`,advancedOptionsContainer:`${L}__advanced-options-container`,browseTemplateButtonContainer:`${L}__browse-template-button-container`,browseTemplateButtonContainerFilter:`${L}__browse-template-button-container-filter`,exportedFilesContainer:`${L}__export-panel-container`,exportedFilesTitle:`${L}__export-title`,exportedFile:`${L}__exported-file`,exportedFileLink:`${L}__exported-file-link`,exportedFileLinkTitle:`${L}__exported-file-link-title`,exportedFileLinkDescription:`${L}__exported-file-link-description`,exportedFilesEmpty:`${L}__exported-files-empty`,printWidgetContainer:`${L}__container`,content:`${L}__content`,panelContainer:`${L}__panel-container`,scaleInfoContainer:`${L}__scale-info-container`,scaleInputContainer:`${L}__scale-input-container`,scaleInput:`${L}__scale-input`,sizeContainer:`${L}__size-container`,panelError:`${L}__panel--error`,exportedFileError:`${L}__exported-file--error`,exportedFileLoader:`${L}__exported-file--loader`,exportSection:`${L}__export-section`,exportSectionCentered:`${L}__export-section--centered`,templateButtonContainer:`${L}__template-button-container`,templateDoneButton:`${L}__template-done-button`,templateSelectFlowItemContainer:`${L}__template-select-flow-item-container`,templateSelectFlowItemContent:`${L}__template-select-flow-item-content`,templateSelectFlowItemListHeading:`${L}__template-select-flow-item-list-heading`,srLabel:`${L}__sr-label`,invalidWkidText:`${L}__invalid-wkid-text`};function j(e,t,i,a){const l=i/t,o=a/t;return{width:Math.round(e*l),height:Math.round(e*o)}}function P(e){return!isNaN(e)&&e>0}function B(e){return e?.toLowerCase()===I}function A(e){const{state:t,extension:i}=e;switch(t){case"pending":return"spinner";case"error":return"exclamation-mark-circle";default:return i?.toLowerCase()?.includes("pdf")?"file-pdf":"file"}}const R=new i({inch:"inches",foot:"feet",yard:"yards",mile:"miles","nautical-mile":"nautical-miles",millimeter:"millimeters",centimeter:"centimeters",decimeter:"decimeters",meter:"meters",kilometer:"kilometers"}),N=new Map([["a3-landscape","a3-landscape"],["a3-portrait","a3-portrait"],["a4-landscape","a4-landscape"],["a4-portrait","a4-portrait"],["letter-ansi-a-landscape","ansi-a-landscape"],["letter-ansi-a-portrait","ansi-a-portrait"],["tabloid-ansi-b-landscape","ansi-b-landscape"],["tabloid-ansi-b-portrait","ansi-b-portrait"]]);let D=class extends b{constructor(e,t){super(e,t),this._activeTabFocusRequested=!1,this._awaitingServerResponse=!1,this._exportedFileNameMap={},this._selectedTab=E.layout,this._pendingExportScroll=!1,this._rootNode=null,this._selectedTemplate=null,this._formats=[],this._showTemplates=!1,this._isValidSpatialReference=!0,this.allowedFormatsForSaving=null,this.browseTemplateButtonOnClick=null,this.exportedLinks=new $,this.headerVisible=!0,this.headingLevel=3,this.messagesCommon=null,this.messagesUnits=null,this.saveExportEnabled=!1,this.saveExportHidden=!0,this.saveAsButtonCallback=null,this.viewModel=new v,this._onInput=e=>{this._selectedTab===E.layout?this.templateOptions.title=e.target.value:this._selectedTab===E.mapOnly&&(this.templateOptions.fileName=e.target.value)},this._handleLinkClick=e=>{const t=e.currentTarget["data-item"];if(!t||"ready"!==t.state||!t.url)return;const i=u(this.viewModel.effectivePrintServiceUrl),a=t.url,l=document.createElement("a");if(l.target="_blank",l.href=a,l.rel="noreferrer",l.download=t.formattedName??"",!i)return l.click(),void e.stopPropagation();e.preventDefault();const o=new URL(a);o.searchParams.set("token",i),l.href=o.href,l.click(),l.href=a},this._focusOnTabChange=this._focusOnTabChange.bind(this)}initialize(){this.addHandles([a((()=>[this.templateOptions.format,this.viewModel.templatesInfo?.format]),(()=>{const{templatesInfo:e}=this.viewModel;if(e){if(this._formats.length!==e.format.choiceList.length){const t=h.apiValues;this._formats=e.format.choiceList.map((e=>{const i=t.find((t=>new RegExp(`\\b${t}\\b`,"i").test(e)))??e;return{value:i,label:e===i?e.toUpperCase():e}})).sort(((e,t)=>e.label.localeCompare(t.label)))}if(!e.format.defaultValue||this.templateOptions.format);else{const t=this._formats.find((({value:t})=>new RegExp(`\\b${t}\\b`,"i").test(e.format.defaultValue)))?.value;t&&(this.templateOptions.format=t)}}})),a((()=>[this.templateOptions.id,this.viewModel.loaded]),(async()=>{const{layout:e}=this.templateOptions;this._selectedTab=B(e)?E.mapOnly:E.layout,this._selectedTab===E.layout&&this.viewModel.loaded&&(this._selectedTemplate=this.viewModel.getLayoutTemplateById(this.templateOptions.id))})),a((()=>this.templateOptions.dpi),(e=>{e<=0&&(this.templateOptions.dpi=1)})),a((()=>this.viewModel.view?.scale),(e=>{!e||this.templateOptions.scaleEnabled&&this.templateOptions.scale||(this.templateOptions.scale=e)}))]);for(const{name:a,extension:l}of this.exportedLinks)a&&l&&this._updateExportedFileNameMap(`${a}${l}`);const{height:e,width:t}=this.templateOptions;this.templateOptions.width=t||800,this.templateOptions.height=e||1100;const i=setTimeout((()=>{this._awaitingServerResponse=!0,this.scheduleRender()}),500);this.viewModel.load().then((()=>{clearTimeout(i),this._awaitingServerResponse=!1}))}loadDependencies(){return g({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),block:()=>import("@esri/calcite-components/dist/components/calcite-block.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),checkbox:()=>import("@esri/calcite-components/dist/components/calcite-checkbox.js"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox.js"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item.js"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow.js"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),input:()=>import("@esri/calcite-components/dist/components/calcite-input.js"),"input-number":()=>import("@esri/calcite-components/dist/components/calcite-input-number.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch.js"),chip:()=>import("@esri/calcite-components/dist/components/calcite-chip.js"),popover:()=>import("@esri/calcite-components/dist/components/calcite-popover.js"),link:()=>import("@esri/calcite-components/dist/components/calcite-link.js")})}destroy(){this.viewModel.destroy()}get allowedFormats(){return this.viewModel.allowedFormats}set allowedFormats(e){this.viewModel.allowedFormats=e}get allowedLayouts(){return this.viewModel.allowedLayouts}set allowedLayouts(e){this.viewModel.allowedLayouts=e}get error(){return this.viewModel.error}get extraParameters(){return this.viewModel.extraParameters}set extraParameters(e){this.viewModel.extraParameters=e}get icon(){return"print"}set icon(e){this._overrideIfSome("icon",e)}get includeDefaultTemplates(){return this.viewModel.includeDefaultTemplates}set includeDefaultTemplates(e){this.viewModel.includeDefaultTemplates=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get outSpatialReference(){return this.viewModel.outSpatialReference}set outSpatialReference(e){this.viewModel.outSpatialReference=e}get portal(){return this.viewModel.portal}set portal(e){this.viewModel.portal=e}get showPrintAreaEnabled(){return this.viewModel.showPrintAreaEnabled}set showPrintAreaEnabled(e){this.viewModel.showPrintAreaEnabled=e}get printServiceUrl(){return this.viewModel.printServiceUrl}set printServiceUrl(e){this.viewModel.printServiceUrl=e}get templateCustomTextElements(){return this.viewModel.templateCustomTextElements}set templateCustomTextElements(e){this.viewModel.templateCustomTextElements=e}get templateOptions(){return this.viewModel.templateOptions}set templateOptions(e){this.viewModel.templateOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}render(){const{messages:e,templateOptions:t,viewModel:i,view:a}=this,{attributionEnabled:l,author:o,copyright:n,dpi:s,format:r,height:p,layout:m,layoutItem:u,legendEnabled:h,northArrowEnabled:b,scaleBarEnabled:_,scaleEnabled:v,scale:g,width:x}=t,k="ready"!==i.state||this._awaitingServerResponse||!(m||u),O=this._renderTitleOrFileNameSection(),$=C("div",{class:M.formSectionContainer},C("calcite-label",null,e.fileFormatTitle,C("calcite-combobox",{clearDisabled:!0,label:e.formatDefaultOption,maxItems:6,placeholder:e.formatDefaultOption,selectionMode:"single-persist",onCalciteComboboxChange:({target:e})=>{this.templateOptions.format=e.selectedItems[0]?.value??"pdf"}},this._formats.map((({value:e,label:t},i)=>C("calcite-combobox-item",{key:`file-format-${i}`,selected:e===this.templateOptions.format,textLabel:t,value:e})))))),I=C("calcite-label",{layout:"inline"},C("calcite-switch",{checked:this.showPrintAreaEnabled,onCalciteSwitchChange:e=>{this.showPrintAreaEnabled=!!e.target.checked}}),e.printPreview),L=C("div",null,C("div",{class:M.formSectionContainer},C("calcite-label",null,e.template,C("calcite-block",{class:M.templateSelectContainer,collapsible:!1,description:this._getPageSizeLabel(this._selectedTemplate),heading:this._getTemplateLabel(this._selectedTemplate,!0),key:"template-select-block",loading:"loading"===this._selectedTemplate?.state,onclick:()=>{this._showTemplates=!0}},C("calcite-icon",{class:M.templateSelectIcon,icon:(this._selectedTemplate?.layout?N.get(this._selectedTemplate.layout):null)||"custom-print",key:"template-select-icon",scale:"l",slot:"content-start"}),"error"===this._selectedTemplate?.state?C("calcite-icon",{class:M.templateSelectError,icon:"exclamation-mark-circle",key:"template-select-error",scale:"s",slot:"actions-end"}):null,C("calcite-icon",{class:M.templateSelectArrow,icon:T()?"chevron-left":"chevron-right",key:"template-select-arrow",scale:"s",slot:"actions-end"})))),I),F=C("div",{class:M.formSectionContainer},C("calcite-label",null,e.dpi,C("calcite-input-number",{bind:this,"data-input-name":"dpi",min:1,value:`${s}`,onCalciteInputNumberInput:this._handleDPIChange}))),j=C("div",{class:M.formSectionContainer},C("calcite-label",null,C("div",{class:M.srLabel},e.outSpatialReference,C("calcite-link",{href:"https://developers.arcgis.com/rest/services-reference/enterprise/using-spatial-references/",target:"_blank"},"(WKID)")),C("calcite-input-number",{bind:this,"data-input-name":"outSpatialReference",integer:!0,numberButtonType:"none",value:i.outSpatialReference?.wkid?.toString()??"",onCalciteInputNumberInput:({target:e})=>{const t=c(e.value);i.outSpatialReference=Number.isNaN(t)||null==t?null:new S({wkid:t}),this._isValidSpatialReference=!i.outSpatialReference||d(i.outSpatialReference)}}),this._isValidSpatialReference?null:C("div",{class:M.invalidWkidText,key:`out-sr-${i.outSpatialReference?.wkid}`},e.invalidWkid))),P=C("div",{class:this.classes(M.scaleInfoContainer,M.formSectionContainer)},C("calcite-label",{layout:"inline"},C("calcite-checkbox",{bind:this,checked:v,"data-option-name":"scaleEnabled",onCalciteCheckboxChange:this._toggleInputValue}),e.scale),C("div",{class:M.scaleInputContainer},C("calcite-input-number",{"aria-label":e.scaleLabel,"aria-valuenow":`${g}`,bind:this,class:M.scaleInput,"data-input-name":"scale",disabled:!v,value:`${g}`,onCalciteInputNumberInput:this._updateNumberInputValue}),C("calcite-button",{appearance:"outline","aria-label":e.reset,bind:this,disabled:!v,iconStart:"refresh",kind:"neutral",onclick:this._resetToCurrentScale}))),B=C("div",{"aria-labelledby":`${this.id}__advancedOptionsForLayout`,class:M.advancedOptionsContainer,key:"advanced-section-for-layout"},P,this._selectedTemplate?.layoutTemplateInfo?.layoutOptions?.hasAuthorText??1?C("div",{class:M.formSectionContainer,key:"author-info"},C("calcite-label",null,e.author,C("calcite-input",{bind:this,"data-input-name":"author",value:o??"",onCalciteInputInput:this._updateInputValue}))):null,this._selectedTemplate?.layoutTemplateInfo?.layoutOptions?.hasCopyrightText??1?C("div",{class:M.formSectionContainer,key:"copyright-text"},C("calcite-label",null,e.copyright,C("calcite-input",{bind:this,"data-input-name":"copyright",value:n??"",onCalciteInputInput:this._updateInputValue}))):null,F,j,this._renderCustomTextElementSection(),this._selectedTemplate?.layoutTemplateInfo?.layoutOptions?.hasLegend??1?C("div",{class:M.formSectionContainer,key:"legend-info"},C("calcite-label",{layout:"inline"},C("calcite-checkbox",{bind:this,checked:h,"data-option-name":"legendEnabled",onCalciteCheckboxChange:this._toggleInputValue}),e.legend)):null,this._selectedTemplate?.mapSurroundInfoOptions?.northArrow.length?C("div",{class:M.formSectionContainer,key:"north-arrow"},C("calcite-label",{layout:"inline"},C("calcite-checkbox",{bind:this,checked:b,"data-option-name":"northArrowEnabled",onCalciteCheckboxChange:this._toggleInputValue}),e.northArrow)):null,this._selectedTemplate?.mapSurroundInfoOptions?.scaleBar.length?C("div",{class:M.formSectionContainer,key:"scale-bar"},C("calcite-label",{layout:"inline"},C("calcite-checkbox",{bind:this,checked:_,"data-option-name":"scaleBarEnabled",onCalciteCheckboxChange:this._toggleInputValue}),e.scaleBar)):null),A=C("div",{"aria-labelledby":`${this.id}__advancedOptionsForMapOnly`,class:M.advancedOptionsContainer},P,F,j,C("div",{class:M.formSectionContainer},C("calcite-label",{layout:"inline"},C("calcite-checkbox",{bind:this,checked:l,"data-option-name":"attributionEnabled",onCalciteCheckboxChange:this._toggleInputValue}),e.attribution)),this._renderCustomTextElementSection()),R=this.exportedLinks.toArray(),D=this._renderExportedLink(R),V={[M.exportSectionCentered]:!R.length},U=this._selectedTab===E.layout?C("section",{"aria-labelledby":`${this.id}__layoutTab`,class:M.layoutSection,id:`${this.id}__layoutContent`,key:"esri-print__layoutContent",role:"tabpanel"},C("div",{class:M.panelContainer},this._selectedTemplate?.layoutTemplateInfo?.layoutOptions?.hasTitleText??1?O:null,L,this._selectedTab===E.layout?$:null,C("calcite-block",{"aria-label":e.advancedOptions,class:this.classes(M.panelContainer,M.advancedOptionsSection),collapsible:!0,disabled:!(m||u?.id),heading:e.advancedOptions,id:"advancedOptionsForLayout",key:"advanced-options-for-layout"},B))):this._selectedTab===E.mapOnly?C("section",{"aria-labelledby":`${this.id}__mapOnlyTab`,class:M.mapOnlySection,id:`${this.id}__mapOnlyContent`,key:"esri-print__mapOnlyContent",role:"tabpanel"},C("div",{class:M.panelContainer},O,$,C("div",null,C("div",{class:this.classes(M.sizeContainer,M.formSectionContainer)},C("calcite-label",null,e.width,C("calcite-input-number",{bind:this,"data-input-name":"width",value:`${x}`,onCalciteInputNumberInput:this._updateNumberInputValue})),C("calcite-label",null,e.height,C("calcite-input-number",{bind:this,"data-input-name":"height",value:`${p}`,onCalciteInputNumberInput:this._updateNumberInputValue})),C("button",{"aria-label":e.swap,bind:this,class:this.classes(f.widgetButton,M.swapButton,w.swap),onclick:this._switchInput,type:"button"})),I),C("calcite-block",{"aria-label":e.advancedOptions,class:this.classes(M.panelContainer,M.advancedOptionsSection),collapsible:!0,heading:e.advancedOptions,id:"advancedOptionsForMapOnly",key:"advanced-options-for-map-only"},A))):C("section",{"aria-labelledby":`${this.id}__exportTab`,class:this.classes(M.exportSection,V),id:`${this.id}__exportContent`,key:"esri-print__exportContent",role:"tabpanel"},C("div",{class:M.panelContainer},C("div",{afterUpdate:this._scrollExportIntoView,bind:this,class:M.exportedFilesContainer},0===R.length?C("div",{class:M.exportedFilesEmpty},C("calcite-icon",{icon:"file",scale:"l"}),C("div",null,C(y,{class:M.exportedFilesTitle,level:this.headingLevel},e.noExportedFiles),C("div",null,e.exportHint))):D))),H="2d"!==a?.type,z=C("div",{class:M.panelError},a?H?e.sceneViewError:e.serviceError:e.noViewError),W=R.some((({state:e})=>"pending"===e)),q=C("div",{class:M.content,key:"panel"},C("div",null,C("ul",{bind:this,class:M.layoutTabList,onclick:this._toggleLayoutPanel,onkeydown:this._handleLayoutPanelKeyDown,role:"tablist"},C("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${this._selectedTab===E.layout}`,class:M.layoutTab,"data-tab-id":E.layout,id:`${this.id}__layoutTab`,role:"tab",tabIndex:0},e.layoutTab),C("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${this._selectedTab===E.mapOnly}`,class:M.layoutTab,"data-tab-id":E.mapOnly,id:`${this.id}__mapOnlyTab`,role:"tab",tabIndex:0},e.mapOnlyTab),C("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${this._selectedTab===E.export}`,class:M.layoutTab,"data-tab-id":E.export,id:`${this.id}__exportedFilesTab`,role:"tab",tabIndex:0},W?C("calcite-loader",{inline:!0,label:"loading",scale:"s"}):null,e.exportsTab)),U),this._selectedTab!==E.export?C("div",{class:this.classes(M.printButtonSection,!this.saveExportHidden&&this.portal?M.printButtonSectionDivider:null),key:"export-button-section"},!this.saveExportHidden&&this.portal?C("calcite-label",{layout:"inline"},C("calcite-checkbox",{bind:this,checked:this.saveExportEnabled,onCalciteCheckboxChange:e=>{this.saveExportEnabled=!!e.target.checked}}),e.saveExportToMyContent):null,C("calcite-button",{"aria-label":e.exportDescription,bind:this,class:this.classes(M.printButton),disabled:k||!(m||u?.id)&&!r,onclick:this._handlePrintMap,scale:"l",width:"full"},e.export)):null),K=C("calcite-flow",{key:"root-flow"},C("calcite-flow-item",{bind:this,key:"root-flow-item"},C("div",{class:M.printWidgetContainer},this.headerVisible?C("header",{class:M.headerTitle},e.export):null,this.error||H||!a?z:q)),this._renderChooseTemplateFlowItem()),G="initializing"===i.state,J=G?this._renderLoader():K,Q={[M.panelItemsCentered]:G};return C("div",{bind:this,class:this.classes(M.base,f.widget,f.panel,Q)},J)}_getPageSizeLabel(e){if(!e)return;const t=e.layoutTemplateInfo;if(!t)return;const i=R.fromJSON(t.pageUnits.toLowerCase());return`${O(t.pageSize[0])} x ${O(t.pageSize[1])} ${o(this.messagesUnits,i,"abbr")}`}_getTemplateLabel(e,t=!1){if(!e)return t?this.messages.selectTemplate:this.messages.untitled;const{label:i,layout:a,layoutItem:l,type:o}=e;if("print-service-template"===o)return this.messages[a];const n=i??a??l?.id;return n?.replaceAll("_"," ")??this.messages.untitled}_getPortalTemplates(){const{portalTemplateIds:e}=this.viewModel;return this.includeDefaultTemplates?this.viewModel.defaultTemplates.toArray().filter((({layout:t,layoutItem:i})=>!B(t)&&!!i?.id&&e.includes(i.id))):[]}_getDefaultTemplates(){const{portalTemplateIds:e}=this.viewModel;return this.includeDefaultTemplates?this.viewModel.defaultTemplates.toArray().filter((({layout:t,layoutItem:i})=>!(B(t)||i?.id&&e.includes(i.id)))):[]}_getPrintServiceTemplates(){return this.includeDefaultTemplates&&this._getDefaultTemplates().length?[]:this.viewModel.printServiceTemplates.toArray().filter((({layout:e})=>!B(e)))}_renderLayoutTemplates(e,t=!1,i=!1){return t&&e.sort(((e,t)=>(e.label??"")>(t.label??"")?1:-1)),e.map((e=>C("calcite-list-item",{description:this._getPageSizeLabel(e),key:`template-${e.id}-${e.id===this.templateOptions.id}`,label:this._getTemplateLabel(e),selected:e.id===this.templateOptions.id,title:e.description??"",value:e},C("calcite-icon",{icon:(e.layout?N.get(e.layout):null)||"custom-print",slot:"content-start"}),"loading"===e.state?C("calcite-loader",{inline:!0,key:`template-loader-${e.id}`,label:"loading",scale:"s",slot:"content-end"}):null,"error"===e?.state?C("calcite-icon",{class:M.templateSelectError,icon:"exclamation-mark-circle",key:`template-error-${e.id}`,scale:"s",slot:"content-end"}):null,i?C("calcite-action",{icon:"trash",onclick:()=>this.viewModel.removePortalTemplate(e),slot:"actions-end",text:"delete"}):null)))}_renderChooseTemplateFlowItem(){if(!this._showTemplates)return null;const{messages:e}=this,t=m.test(this.portal?.url),i=this.viewModel.browseTemplates.toArray(),a=this._getPortalTemplates(),l=this._getDefaultTemplates(),o=this._getPrintServiceTemplates(),n=i.length+a.length+l.length+o.length>15,s=this.browseTemplateButtonOnClick?C("calcite-button",{appearance:"outline",class:n?M.browseTemplateButtonContainerFilter:M.browseTemplateButtonContainer,iconStart:"folder",key:"browse-template-button",onclick:this.browseTemplateButtonOnClick,slot:n?"filter-actions-end":"default"},n?null:e.browseTemplates):null;return C("calcite-flow-item",{bind:this,closable:!1,heading:e.chooseTemplate,key:"template-flow-item",onCalciteFlowItemBack:e=>{e.preventDefault(),this._showTemplates=!1}},C("div",{class:M.templateSelectFlowItemContainer},C("div",{class:M.templateSelectFlowItemContent},n?null:s,C("calcite-list",{filterEnabled:n,filterProps:["label"],key:"template-list",selectionMode:"single-persist",onCalciteListChange:({target:e})=>this.viewModel.applyTemplate(e.selectedItems[0]?.value)},n?s:null,i.length?C("div",{key:"my-templates"},C("div",{class:M.templateSelectFlowItemListHeading},e.myTemplates,C("calcite-chip",{appearance:"outline",kind:"neutral",scale:"s",value:e.beta},e.beta)),this._renderLayoutTemplates(i,!0,!0)):null,a.length?C("div",{key:"org-templates"},C("div",{class:M.templateSelectFlowItemListHeading},e.organizationTemplates,t?C("calcite-chip",{appearance:"outline",kind:"neutral",scale:"s",value:e.beta},e.beta):null),this._renderLayoutTemplates(a)):null,i.length||a.length?l.length?C("div",{key:"default-templates"},C("div",{class:M.templateSelectFlowItemListHeading},e.defaultTemplates),this._renderLayoutTemplates(l,!0)):null:this._renderLayoutTemplates(l,!0),i.length||a.length?o.length?C("div",{key:"service-templates"},C("div",{class:M.templateSelectFlowItemListHeading},e.defaultTemplates),this._renderLayoutTemplates(o)):null:this._renderLayoutTemplates(o))),C("div",{class:M.templateButtonContainer},C("calcite-button",{class:M.templateDoneButton,onclick:()=>this._showTemplates=!1},this.messagesCommon.done))))}_renderCustomTextElementSection(){const{customTextElements:e}=this.templateOptions;return e?C("div",{class:M.formSectionContainer,key:"custom-text-elements"},e.map(((e,t)=>{const[i,a]=Object.entries(e)[0];return"date"===i?null:C("calcite-label",{key:`custom-text-elements-${i}-${t}`},i,C("calcite-input",{bind:this,"data-input-custom":!0,"data-input-name":i,value:a??"",onCalciteInputInput:this._updateInputValue}))}))):null}_renderTitleOrFileNameSection(){const{title:e,fileName:t,titlePlaceHolder:i,fileNamePlaceHolder:a}=this.messages,l=this._selectedTab===E.layout?e:t,o=this._selectedTab===E.layout?i:a,n=this._selectedTab===E.layout?this.templateOptions.title:this.templateOptions.fileName;return C("div",{class:M.formSectionContainer,key:l},C("calcite-label",null,l,C("calcite-input",{placeholder:o,value:n??"",onCalciteInputInput:this._onInput})))}_focusOnTabChange(e){if(!this._activeTabFocusRequested)return;const t=e.getAttribute("data-tab-id");("layoutTab"===t&&this._selectedTab===E.layout||"mapOnlyTab"===t&&this._selectedTab===E.mapOnly||"exportTab"===t&&this._selectedTab===E.export)&&(e.focus(),this._activeTabFocusRequested=!1)}_renderLoader(){const e={[M.loader]:this._awaitingServerResponse};return C("div",{class:this.classes(e),key:"loader"})}_updateExportedFileNameMap(e){void 0!==this._exportedFileNameMap[e]?this._exportedFileNameMap[e]++:this._exportedFileNameMap[e]=0}_createFileLink(e,t){const i=t||this.messages.untitled,a=e.format.toLowerCase(),l=a.includes("png")?"png":a,o=i+l;return this._updateExportedFileNameMap(o),new _({name:i,extension:l,count:this._exportedFileNameMap[o]})}_resetToCurrentScale(){this.templateOptions.scale=this.viewModel.view?.scale}_updateCustomTextElementValue(e,t,i){e.find((e=>{const[i]=Object.entries(e)[0];return i===t}))[t]=i}_updateInputValue(e){const t=e.target,i=t.getAttribute("data-input-name"),a=!!t["data-input-custom"],{templateOptions:l}=this;a?this._updateCustomTextElementValue(l.customTextElements,i,t.value):l[i]=t.value}_updateNumberInputValue(e){const t=e.target,i=t.getAttribute("data-input-name"),{templateOptions:a}=this,l=Number(t.value);if(P(l))a[i]=l;else{const e=a[i];t.value=`${e}`}}_handleDPIChange(e){const{templateOptions:t}=this,i=t.dpi;this._updateNumberInputValue(e);const a=t.dpi,{height:l,width:o}=j(a,i,t.width,t.height);t.height=l,t.width=o}_handlePrintMap(){this._pendingExportScroll=!0;const{templateOptions:e,saveExportEnabled:t}=this,i=this.viewModel.toPrintTemplate(e),a=this._selectedTab===E.layout?i.layoutOptions?.titleText:e.fileName,l=this._createFileLink(i,a);this.exportedLinks.add(l),this.emit("submit",{link:l,saveExportEnabled:t}),this._selectedTab=E.export,this.viewModel.print(i).then((e=>{l.set({url:e&&e.url,state:"ready"})})).catch((e=>{l.set({error:e,state:"error"})})).then((()=>{this.emit("complete",{link:l,saveExportEnabled:t}),this.scheduleRender()}))}_switchInput(){[this.templateOptions.width,this.templateOptions.height]=[this.templateOptions.height,this.templateOptions.width]}_scrollExportIntoView(){if(!this._pendingExportScroll)return;this._pendingExportScroll=!1;const e=this._rootNode;if(!e)return;const{clientHeight:t,scrollHeight:i}=e,a=i-t;a>0&&(e.scrollTop=a)}_toggleInputValue(e){const t=e.target,i=t.getAttribute("data-option-name");this.templateOptions[i]=t.checked,"scaleEnabled"===i&&this._resetToCurrentScale()}_renderExportedLink(e){const t=this.messages,i=e.map((e=>{const{error:i,url:a,state:o}=e,r=e.formattedName??"",c="error"===o,p="pending"===o,d="ready"===o;let m=a||null;m&&(m=n(m));const u=s(a,location.href);let h;h=p?t.pending:d?t.ready:t.errorMessage;const b=c?"print-task:cim-symbol-unsupported"===i?.name?t.exportWebMapCIMError:t.exportWebMapError:"";return C("calcite-list-item",{"aria-label":h,key:r,title:b},C("div",{class:M.exportedFile,"data-item":e,onclick:this._handleLinkClick,slot:"content"},C("div",null,C("div",{class:M.exportedFileLinkTitle},r),C("div",{class:M.exportedFileLinkDescription},p?t.generatingExport:b||(u?t.ready:t.linkReady))),d?C("calcite-icon",{"aria-label":`${r}. ${t.linkReady}`,icon:u?"download-to":"launch",key:`${r}-end-icon`,scale:"s",slot:"content-end"}):null),p?C("calcite-loader",{class:M.exportedFileLoader,inline:!0,key:`${r}-loader`,label:t.generatingExport,scale:"m",slot:"content-start"}):C("calcite-icon",{icon:A(e),key:`${r}-start-icon`,scale:"s",slot:"content-start"}),p?null:this.saveAsButtonCallback&&!c&&this._isFormatAllowedForSaving(e.extension)?C("calcite-action",{"aria-label":`${b}`,icon:"ellipsis",id:`${r}-popover-button`,key:`${r}-action`,slot:"actions-end",text:`${b}`},C("calcite-popover",{autoClose:!0,key:`${r}-popover`,label:"Popover",offsetDistance:1,overlayPositioning:"fixed",pointerDisabled:!0,referenceElement:`${r}-popover-button`,scale:"s"},C("calcite-list",null,e.portalItem?C("calcite-list-item",{label:t.openItem,onCalciteListItemSelect:()=>{const t=e.portalItem;if(!t||!t.itemPageUrl)return;const i=document.createElement("a");i.target="_blank",i.href=t.itemPageUrl,i.rel="noreferrer",i.click()}},C("calcite-icon",{icon:"launch2",key:`${r}-launch-icon`,scale:"s",slot:"content-start"})):C("calcite-list-item",{label:t.saveAs,onCalciteListItemSelect:async()=>{this.saveAsButtonCallback&&(l((()=>e.portalItem)).then((e=>{e.itemPageUrl&&this.scheduleRender()})),await this.saveAsButtonCallback(e))}},C("calcite-icon",{icon:"save",key:`${r}-save-icon`,scale:"s",slot:"content-start"})),C("calcite-list-item",{label:this.messagesCommon.delete,onCalciteListItemSelect:()=>this.exportedLinks.remove(e)},C("calcite-icon",{icon:"trash",key:`${r}-delete-icon`,scale:"s",slot:"content-start"}))))):C("calcite-action",{"aria-label":`${b}`,icon:"x",key:`${r}-action`,onclick:()=>{this.exportedLinks.remove(e)},slot:"actions-end",text:`${b}`}))}));return C("calcite-list",{filterEnabled:e?.length>10},i)}_isFormatAllowedForSaving(e){return!this.allowedFormatsForSaving||"all"===this.allowedFormatsForSaving||!(!e||!this.allowedFormatsForSaving.includes(e))}_toggleLayoutPanel(e){const t=e.target;this._toggleTab(t.getAttribute("data-tab-id"))}_toggleTab(e,t=!0){if(this._selectedTab=e,this._selectedTab===E.mapOnly)this.templateOptions.reset(),this.templateOptions.layout=I;else if(this._selectedTab===E.layout){const e=this._selectedTemplate??this.viewModel.defaultTemplate;e?this.viewModel.applyTemplate(e):this.templateOptions.reset()}t&&(this._activeTabFocusRequested=!0)}_handleLayoutPanelKeyDown(e){const{key:t}=e,i=e.target.getAttribute("data-tab-id");if(x(t))return this._toggleTab(i),e.preventDefault(),void e.stopPropagation();if("ArrowLeft"===t||"ArrowRight"===t){switch(i){case E.layout:this._toggleTab("ArrowLeft"===t?E.export:E.mapOnly);break;case E.mapOnly:this._toggleTab("ArrowLeft"===t?E.layout:E.export);break;case E.export:this._toggleTab("ArrowLeft"===t?E.mapOnly:E.layout)}e.preventDefault(),e.stopPropagation()}}};e([r()],D.prototype,"_showTemplates",void 0),e([r()],D.prototype,"_isValidSpatialReference",void 0),e([r()],D.prototype,"allowedFormats",null),e([r()],D.prototype,"allowedFormatsForSaving",void 0),e([r()],D.prototype,"allowedLayouts",null),e([r()],D.prototype,"browseTemplateButtonOnClick",void 0),e([r()],D.prototype,"error",null),e([r({type:$})],D.prototype,"exportedLinks",void 0),e([r()],D.prototype,"extraParameters",null),e([r()],D.prototype,"headerVisible",void 0),e([r()],D.prototype,"headingLevel",void 0),e([r()],D.prototype,"icon",null),e([r()],D.prototype,"includeDefaultTemplates",null),e([r()],D.prototype,"label",null),e([r(),k("esri/widgets/Print/t9n/Print")],D.prototype,"messages",void 0),e([r(),k("esri/t9n/common")],D.prototype,"messagesCommon",void 0),e([r(),k("esri/core/t9n/Units")],D.prototype,"messagesUnits",void 0),e([r({type:S})],D.prototype,"outSpatialReference",null),e([r()],D.prototype,"portal",null),e([r()],D.prototype,"saveExportEnabled",void 0),e([r()],D.prototype,"saveExportHidden",void 0),e([r()],D.prototype,"showPrintAreaEnabled",null),e([r()],D.prototype,"printServiceUrl",null),e([r()],D.prototype,"saveAsButtonCallback",void 0),e([r()],D.prototype,"templateCustomTextElements",null),e([r()],D.prototype,"templateOptions",null),e([r()],D.prototype,"view",null),e([r({type:v})],D.prototype,"viewModel",void 0),D=e([p("esri.widgets.Print")],D);const V=D;export{V as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import"../geometry.js";import"../intl.js";import t from"../core/Collection.js";import{JSONMap as i}from"../core/jsonMap.js";import{watch as a,whenOnce as l}from"../core/reactiveUtils.js";import{unitName as o}from"../core/unitFormatUtils.js";import{addProxy as n,hasSameOrigin as s}from"../core/urlUtils.js";import{property as r}from"../core/accessorSupport/decorators/property.js";import{ensureInteger as c}from"../core/accessorSupport/ensureType.js";import"../core/RandomLCG.js";import"../core/has.js";import{subclass as p}from"../core/accessorSupport/decorators/subclass.js";import{isValid as d}from"../geometry/support/spatialReferenceUtils.js";import{reArcGISOnlineDomain as m}from"../portal/support/urlUtils.js";import{getToken as u}from"../rest/utils.js";import{formatJsonMap as h}from"../rest/support/fileFormat.js";import b from"./Widget.js";import _ from"./Print/FileLink.js";import v from"./Print/PrintViewModel.js";import{loadCalciteComponents as g}from"./support/componentsUtils.js";import{globalCss as f}from"./support/globalCss.js";import{Heading as y}from"./support/Heading.js";import{legacyIcon as w}from"./support/legacyIcon.js";import{isRTL as T,isActivationKey as x}from"./support/widgetUtils.js";import{messageBundle as k}from"./support/decorators/messageBundle.js";import{tsx as C}from"./support/jsxFactory.js";import S from"../geometry/SpatialReference.js";import{formatNumber as O}from"../intl/number.js";const $=t.ofType(_),I="map-only";var E;!function(e){e.layout="layoutTab",e.mapOnly="mapOnlyTab",e.export="exportTab"}(E||(E={}));const L="esri-print",F=`${L}__advanced-options-button`,M={base:L,headerTitle:`${L}__header-title`,layoutTabList:`${L}__layout-tab-list`,layoutTab:`${L}__layout-tab`,layoutSection:`${L}__layout-section`,mapOnlySection:`${L}__map-only-section`,panelItemsCentered:`${L}__panel-items--centered`,loader:`${L}__loader`,advancedOptionsButton:F,advancedOptionsButtonContainer:`${F}-container`,advancedOptionsButtonTitle:`${F}-title`,advancedOptionsButtonIconOpened:`${F}-icon--opened`,advancedOptionsButtonIconClosed:`${F}-icon--closed`,advancedOptionsButtonIconClosed_RTL:`${F}-icon--closed-rtl`,swapButton:`${L}__swap-button`,printButton:`${L}__export-button`,printButtonSection:`${L}__export-button-section`,printButtonSectionDivider:`${L}__export-button-section--divider`,templateSelectContainer:`${L}__template-select-container`,templateSelectBlock:`${L}__template-select-block`,templateSelectIcon:`${L}__template-select-icon`,templateSelectError:`${L}__template-select-error`,templateSelectArrow:`${L}__template-select-arrow`,formSectionContainer:`${L}__form-section-container`,formCheckboxLabel:`${L}__form-checkbox-label`,advancedOptionsSection:`${L}__advanced-options-section`,advancedOptionsContainer:`${L}__advanced-options-container`,browseTemplateButtonContainer:`${L}__browse-template-button-container`,browseTemplateButtonContainerFilter:`${L}__browse-template-button-container-filter`,exportedFilesContainer:`${L}__export-panel-container`,exportedFilesTitle:`${L}__export-title`,exportedFile:`${L}__exported-file`,exportedFileLink:`${L}__exported-file-link`,exportedFileLinkTitle:`${L}__exported-file-link-title`,exportedFileLinkDescription:`${L}__exported-file-link-description`,exportedFilesEmpty:`${L}__exported-files-empty`,printWidgetContainer:`${L}__container`,content:`${L}__content`,panelContainer:`${L}__panel-container`,scaleInfoContainer:`${L}__scale-info-container`,scaleInputContainer:`${L}__scale-input-container`,scaleInput:`${L}__scale-input`,sizeContainer:`${L}__size-container`,panelError:`${L}__panel--error`,exportedFileError:`${L}__exported-file--error`,exportedFileLoader:`${L}__exported-file--loader`,exportSection:`${L}__export-section`,exportSectionCentered:`${L}__export-section--centered`,templateButtonContainer:`${L}__template-button-container`,templateDoneButton:`${L}__template-done-button`,templateSelectFlowItemContainer:`${L}__template-select-flow-item-container`,templateSelectFlowItemContent:`${L}__template-select-flow-item-content`,templateSelectFlowItemListHeading:`${L}__template-select-flow-item-list-heading`,srLabel:`${L}__sr-label`,invalidWkidText:`${L}__invalid-wkid-text`};function j(e,t,i,a){const l=i/t,o=a/t;return{width:Math.round(e*l),height:Math.round(e*o)}}function P(e){return!isNaN(e)&&e>0}function B(e){return e?.toLowerCase()===I}function A(e){const{state:t,extension:i}=e;switch(t){case"pending":return"spinner";case"error":return"exclamation-mark-circle";default:return i?.toLowerCase()?.includes("pdf")?"file-pdf":"file"}}const R=new i({inch:"inches",foot:"feet",yard:"yards",mile:"miles","nautical-mile":"nautical-miles",millimeter:"millimeters",centimeter:"centimeters",decimeter:"decimeters",meter:"meters",kilometer:"kilometers"}),N=new Map([["a3-landscape","a3-landscape"],["a3-portrait","a3-portrait"],["a4-landscape","a4-landscape"],["a4-portrait","a4-portrait"],["letter-ansi-a-landscape","ansi-a-landscape"],["letter-ansi-a-portrait","ansi-a-portrait"],["tabloid-ansi-b-landscape","ansi-b-landscape"],["tabloid-ansi-b-portrait","ansi-b-portrait"]]);let D=class extends b{constructor(e,t){super(e,t),this._activeTabFocusRequested=!1,this._awaitingServerResponse=!1,this._exportedFileNameMap={},this._selectedTab=E.layout,this._pendingExportScroll=!1,this._rootNode=null,this._selectedTemplate=null,this._formats=[],this._showTemplates=!1,this._isValidSpatialReference=!0,this.allowedFormatsForSaving=null,this.browseTemplateButtonOnClick=null,this.exportedLinks=new $,this.headerVisible=!0,this.headingLevel=3,this.messagesCommon=null,this.messagesUnits=null,this.saveExportEnabled=!1,this.saveExportHidden=!0,this.saveAsButtonCallback=null,this.viewModel=new v,this._onInput=e=>{this._selectedTab===E.layout?this.templateOptions.title=e.target.value:this._selectedTab===E.mapOnly&&(this.templateOptions.fileName=e.target.value)},this._handleLinkClick=e=>{const t=e.currentTarget["data-item"];if(!t||"ready"!==t.state||!t.url)return;const i=u(this.viewModel.effectivePrintServiceUrl),a=t.url,l=document.createElement("a");if(l.target="_blank",l.href=a,l.rel="noreferrer",l.download=t.formattedName??"",!i)return l.click(),void e.stopPropagation();e.preventDefault();const o=new URL(a);o.searchParams.set("token",i),l.href=o.href,l.click(),l.href=a},this._focusOnTabChange=this._focusOnTabChange.bind(this)}initialize(){this.addHandles([a((()=>[this.templateOptions.format,this.viewModel.templatesInfo?.format]),(()=>{const{templatesInfo:e}=this.viewModel;if(!e)return;if(this._formats.length!==e.format.choiceList.length){const t=h.apiValues;this._formats=e.format.choiceList.map((e=>{const i=t.find((t=>new RegExp(`\\b${t}\\b`,"i").test(e)))??e;return{value:i,label:e===i?e.toUpperCase():e}})).sort(((e,t)=>e.label.localeCompare(t.label)))}const t=this._formats.some((({value:e})=>new RegExp(`\\b${e}\\b`,"i").test(this.templateOptions.format)));if(!e.format.defaultValue||t);else{const t=this._formats.find((({value:t})=>new RegExp(`\\b${t}\\b`,"i").test(e.format.defaultValue)))?.value;t&&(this.templateOptions.format=t)}})),a((()=>[this.templateOptions.id,this.viewModel.loaded]),(async()=>{const{layout:e}=this.templateOptions;this._selectedTab=B(e)?E.mapOnly:E.layout,this._selectedTab===E.layout&&this.viewModel.loaded&&(this._selectedTemplate=this.viewModel.getLayoutTemplateById(this.templateOptions.id))})),a((()=>this.templateOptions.dpi),(e=>{e<=0&&(this.templateOptions.dpi=1)})),a((()=>this.viewModel.view?.scale),(e=>{!e||this.templateOptions.scaleEnabled&&this.templateOptions.scale||(this.templateOptions.scale=e)}))]);for(const{name:a,extension:l}of this.exportedLinks)a&&l&&this._updateExportedFileNameMap(`${a}${l}`);const{height:e,width:t}=this.templateOptions;this.templateOptions.width=t||800,this.templateOptions.height=e||1100;const i=setTimeout((()=>{this._awaitingServerResponse=!0,this.scheduleRender()}),500);this.viewModel.load().then((()=>{clearTimeout(i),this._awaitingServerResponse=!1}))}loadDependencies(){return g({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),block:()=>import("@esri/calcite-components/dist/components/calcite-block.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),checkbox:()=>import("@esri/calcite-components/dist/components/calcite-checkbox.js"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox.js"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item.js"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow.js"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),input:()=>import("@esri/calcite-components/dist/components/calcite-input.js"),"input-number":()=>import("@esri/calcite-components/dist/components/calcite-input-number.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch.js"),chip:()=>import("@esri/calcite-components/dist/components/calcite-chip.js"),popover:()=>import("@esri/calcite-components/dist/components/calcite-popover.js"),link:()=>import("@esri/calcite-components/dist/components/calcite-link.js")})}destroy(){this.viewModel.destroy()}get allowedFormats(){return this.viewModel.allowedFormats}set allowedFormats(e){this.viewModel.allowedFormats=e}get allowedLayouts(){return this.viewModel.allowedLayouts}set allowedLayouts(e){this.viewModel.allowedLayouts=e}get error(){return this.viewModel.error}get extraParameters(){return this.viewModel.extraParameters}set extraParameters(e){this.viewModel.extraParameters=e}get icon(){return"print"}set icon(e){this._overrideIfSome("icon",e)}get includeDefaultTemplates(){return this.viewModel.includeDefaultTemplates}set includeDefaultTemplates(e){this.viewModel.includeDefaultTemplates=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get outSpatialReference(){return this.viewModel.outSpatialReference}set outSpatialReference(e){this.viewModel.outSpatialReference=e}get portal(){return this.viewModel.portal}set portal(e){this.viewModel.portal=e}get showPrintAreaEnabled(){return this.viewModel.showPrintAreaEnabled}set showPrintAreaEnabled(e){this.viewModel.showPrintAreaEnabled=e}get printServiceUrl(){return this.viewModel.printServiceUrl}set printServiceUrl(e){this.viewModel.printServiceUrl=e}get templateCustomTextElements(){return this.viewModel.templateCustomTextElements}set templateCustomTextElements(e){this.viewModel.templateCustomTextElements=e}get templateOptions(){return this.viewModel.templateOptions}set templateOptions(e){this.viewModel.templateOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}render(){const{messages:e,templateOptions:t,viewModel:i,view:a}=this,{attributionEnabled:l,author:o,copyright:n,dpi:s,format:r,height:p,layout:m,layoutItem:u,legendEnabled:h,northArrowEnabled:b,scaleBarEnabled:_,scaleEnabled:v,scale:g,width:x}=t,k="ready"!==i.state||this._awaitingServerResponse||!(m||u),O=this._renderTitleOrFileNameSection(),$=C("div",{class:M.formSectionContainer},C("calcite-label",null,e.fileFormatTitle,C("calcite-combobox",{clearDisabled:!0,label:e.formatDefaultOption,maxItems:6,placeholder:e.formatDefaultOption,selectionMode:"single-persist",onCalciteComboboxChange:({target:e})=>{this.templateOptions.format=e.selectedItems[0]?.value??"pdf"}},this._formats.map((({value:e,label:t},i)=>C("calcite-combobox-item",{key:`file-format-${i}`,selected:e===this.templateOptions.format,textLabel:t,value:e})))))),I=C("calcite-label",{layout:"inline"},C("calcite-switch",{checked:this.showPrintAreaEnabled,onCalciteSwitchChange:e=>{this.showPrintAreaEnabled=!!e.target.checked}}),e.printPreview),L=C("div",null,C("div",{class:M.formSectionContainer},C("calcite-label",null,e.template,C("calcite-block",{class:M.templateSelectContainer,collapsible:!1,description:this._getPageSizeLabel(this._selectedTemplate),heading:this._getTemplateLabel(this._selectedTemplate,!0),key:"template-select-block",loading:"loading"===this._selectedTemplate?.state,onclick:()=>{this._showTemplates=!0}},C("calcite-icon",{class:M.templateSelectIcon,icon:(this._selectedTemplate?.layout?N.get(this._selectedTemplate.layout):null)||"custom-print",key:"template-select-icon",scale:"l",slot:"content-start"}),"error"===this._selectedTemplate?.state?C("calcite-icon",{class:M.templateSelectError,icon:"exclamation-mark-circle",key:"template-select-error",scale:"s",slot:"actions-end"}):null,C("calcite-icon",{class:M.templateSelectArrow,icon:T()?"chevron-left":"chevron-right",key:"template-select-arrow",scale:"s",slot:"actions-end"})))),I),F=C("div",{class:M.formSectionContainer},C("calcite-label",null,e.dpi,C("calcite-input-number",{bind:this,"data-input-name":"dpi",min:1,value:`${s}`,onCalciteInputNumberInput:this._handleDPIChange}))),j=C("div",{class:M.formSectionContainer},C("calcite-label",null,C("div",{class:M.srLabel},e.outSpatialReference,C("calcite-link",{href:"https://developers.arcgis.com/rest/services-reference/enterprise/using-spatial-references/",target:"_blank"},"(WKID)")),C("calcite-input-number",{bind:this,"data-input-name":"outSpatialReference",integer:!0,numberButtonType:"none",value:i.outSpatialReference?.wkid?.toString()??"",onCalciteInputNumberInput:({target:e})=>{const t=c(e.value);i.outSpatialReference=Number.isNaN(t)||null==t?null:new S({wkid:t}),this._isValidSpatialReference=!i.outSpatialReference||d(i.outSpatialReference)}}),this._isValidSpatialReference?null:C("div",{class:M.invalidWkidText,key:`out-sr-${i.outSpatialReference?.wkid}`},e.invalidWkid))),P=C("div",{class:this.classes(M.scaleInfoContainer,M.formSectionContainer)},C("calcite-label",{layout:"inline"},C("calcite-checkbox",{bind:this,checked:v,"data-option-name":"scaleEnabled",onCalciteCheckboxChange:this._toggleInputValue}),e.scale),C("div",{class:M.scaleInputContainer},C("calcite-input-number",{"aria-label":e.scaleLabel,"aria-valuenow":`${g}`,bind:this,class:M.scaleInput,"data-input-name":"scale",disabled:!v,value:`${g}`,onCalciteInputNumberInput:this._updateNumberInputValue}),C("calcite-button",{appearance:"outline","aria-label":e.reset,bind:this,disabled:!v,iconStart:"refresh",kind:"neutral",onclick:this._resetToCurrentScale}))),B=C("div",{"aria-labelledby":`${this.id}__advancedOptionsForLayout`,class:M.advancedOptionsContainer,key:"advanced-section-for-layout"},P,this._selectedTemplate?.layoutTemplateInfo?.layoutOptions?.hasAuthorText??1?C("div",{class:M.formSectionContainer,key:"author-info"},C("calcite-label",null,e.author,C("calcite-input",{bind:this,"data-input-name":"author",value:o??"",onCalciteInputInput:this._updateInputValue}))):null,this._selectedTemplate?.layoutTemplateInfo?.layoutOptions?.hasCopyrightText??1?C("div",{class:M.formSectionContainer,key:"copyright-text"},C("calcite-label",null,e.copyright,C("calcite-input",{bind:this,"data-input-name":"copyright",value:n??"",onCalciteInputInput:this._updateInputValue}))):null,F,j,this._renderCustomTextElementSection(),this._selectedTemplate?.layoutTemplateInfo?.layoutOptions?.hasLegend??1?C("div",{class:M.formSectionContainer,key:"legend-info"},C("calcite-label",{layout:"inline"},C("calcite-checkbox",{bind:this,checked:h,"data-option-name":"legendEnabled",onCalciteCheckboxChange:this._toggleInputValue}),e.legend)):null,this._selectedTemplate?.mapSurroundInfoOptions?.northArrow.length?C("div",{class:M.formSectionContainer,key:"north-arrow"},C("calcite-label",{layout:"inline"},C("calcite-checkbox",{bind:this,checked:b,"data-option-name":"northArrowEnabled",onCalciteCheckboxChange:this._toggleInputValue}),e.northArrow)):null,this._selectedTemplate?.mapSurroundInfoOptions?.scaleBar.length?C("div",{class:M.formSectionContainer,key:"scale-bar"},C("calcite-label",{layout:"inline"},C("calcite-checkbox",{bind:this,checked:_,"data-option-name":"scaleBarEnabled",onCalciteCheckboxChange:this._toggleInputValue}),e.scaleBar)):null),A=C("div",{"aria-labelledby":`${this.id}__advancedOptionsForMapOnly`,class:M.advancedOptionsContainer},P,F,j,C("div",{class:M.formSectionContainer},C("calcite-label",{layout:"inline"},C("calcite-checkbox",{bind:this,checked:l,"data-option-name":"attributionEnabled",onCalciteCheckboxChange:this._toggleInputValue}),e.attribution)),this._renderCustomTextElementSection()),R=this.exportedLinks.toArray(),D=this._renderExportedLink(R),V={[M.exportSectionCentered]:!R.length},U=this._selectedTab===E.layout?C("section",{"aria-labelledby":`${this.id}__layoutTab`,class:M.layoutSection,id:`${this.id}__layoutContent`,key:"esri-print__layoutContent",role:"tabpanel"},C("div",{class:M.panelContainer},this._selectedTemplate?.layoutTemplateInfo?.layoutOptions?.hasTitleText??1?O:null,L,this._selectedTab===E.layout?$:null,C("calcite-block",{"aria-label":e.advancedOptions,class:this.classes(M.panelContainer,M.advancedOptionsSection),collapsible:!0,disabled:!(m||u?.id),heading:e.advancedOptions,id:"advancedOptionsForLayout",key:"advanced-options-for-layout"},B))):this._selectedTab===E.mapOnly?C("section",{"aria-labelledby":`${this.id}__mapOnlyTab`,class:M.mapOnlySection,id:`${this.id}__mapOnlyContent`,key:"esri-print__mapOnlyContent",role:"tabpanel"},C("div",{class:M.panelContainer},O,$,C("div",null,C("div",{class:this.classes(M.sizeContainer,M.formSectionContainer)},C("calcite-label",null,e.width,C("calcite-input-number",{bind:this,"data-input-name":"width",value:`${x}`,onCalciteInputNumberInput:this._updateNumberInputValue})),C("calcite-label",null,e.height,C("calcite-input-number",{bind:this,"data-input-name":"height",value:`${p}`,onCalciteInputNumberInput:this._updateNumberInputValue})),C("button",{"aria-label":e.swap,bind:this,class:this.classes(f.widgetButton,M.swapButton,w.swap),onclick:this._switchInput,type:"button"})),I),C("calcite-block",{"aria-label":e.advancedOptions,class:this.classes(M.panelContainer,M.advancedOptionsSection),collapsible:!0,heading:e.advancedOptions,id:"advancedOptionsForMapOnly",key:"advanced-options-for-map-only"},A))):C("section",{"aria-labelledby":`${this.id}__exportTab`,class:this.classes(M.exportSection,V),id:`${this.id}__exportContent`,key:"esri-print__exportContent",role:"tabpanel"},C("div",{class:M.panelContainer},C("div",{afterUpdate:this._scrollExportIntoView,bind:this,class:M.exportedFilesContainer},0===R.length?C("div",{class:M.exportedFilesEmpty},C("calcite-icon",{icon:"file",scale:"l"}),C("div",null,C(y,{class:M.exportedFilesTitle,level:this.headingLevel},e.noExportedFiles),C("div",null,e.exportHint))):D))),H="2d"!==a?.type,z=C("div",{class:M.panelError},a?H?e.sceneViewError:e.serviceError:e.noViewError),W=R.some((({state:e})=>"pending"===e)),q=C("div",{class:M.content,key:"panel"},C("div",null,C("ul",{bind:this,class:M.layoutTabList,onclick:this._toggleLayoutPanel,onkeydown:this._handleLayoutPanelKeyDown,role:"tablist"},C("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${this._selectedTab===E.layout}`,class:M.layoutTab,"data-tab-id":E.layout,id:`${this.id}__layoutTab`,role:"tab",tabIndex:0},e.layoutTab),C("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${this._selectedTab===E.mapOnly}`,class:M.layoutTab,"data-tab-id":E.mapOnly,id:`${this.id}__mapOnlyTab`,role:"tab",tabIndex:0},e.mapOnlyTab),C("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${this._selectedTab===E.export}`,class:M.layoutTab,"data-tab-id":E.export,id:`${this.id}__exportedFilesTab`,role:"tab",tabIndex:0},W?C("calcite-loader",{inline:!0,label:"loading",scale:"s"}):null,e.exportsTab)),U),this._selectedTab!==E.export?C("div",{class:this.classes(M.printButtonSection,!this.saveExportHidden&&this.portal?M.printButtonSectionDivider:null),key:"export-button-section"},!this.saveExportHidden&&this.portal?C("calcite-label",{layout:"inline"},C("calcite-checkbox",{bind:this,checked:this.saveExportEnabled,onCalciteCheckboxChange:e=>{this.saveExportEnabled=!!e.target.checked}}),e.saveExportToMyContent):null,C("calcite-button",{"aria-label":e.exportDescription,bind:this,class:this.classes(M.printButton),disabled:k||!(m||u?.id)&&!r,onclick:this._handlePrintMap,scale:"l",width:"full"},e.export)):null),K=C("calcite-flow",{key:"root-flow"},C("calcite-flow-item",{bind:this,key:"root-flow-item"},C("div",{class:M.printWidgetContainer},this.headerVisible?C("header",{class:M.headerTitle},e.export):null,this.error||H||!a?z:q)),this._renderChooseTemplateFlowItem()),G="initializing"===i.state,J=G?this._renderLoader():K,Q={[M.panelItemsCentered]:G};return C("div",{bind:this,class:this.classes(M.base,f.widget,f.panel,Q)},J)}_getPageSizeLabel(e){if(!e)return;const t=e.layoutTemplateInfo;if(!t)return;const i=R.fromJSON(t.pageUnits.toLowerCase());return`${O(t.pageSize[0])} x ${O(t.pageSize[1])} ${o(this.messagesUnits,i,"abbr")}`}_getTemplateLabel(e,t=!1){if(!e)return t?this.messages.selectTemplate:this.messages.untitled;const{label:i,layout:a,layoutItem:l,type:o}=e;if("print-service-template"===o)return this.messages[a];const n=i??a??l?.id;return n?.replaceAll("_"," ")??this.messages.untitled}_getPortalTemplates(){const{portalTemplateIds:e}=this.viewModel;return this.includeDefaultTemplates?this.viewModel.defaultTemplates.toArray().filter((({layout:t,layoutItem:i})=>!B(t)&&!!i?.id&&e.includes(i.id))):[]}_getDefaultTemplates(){const{portalTemplateIds:e}=this.viewModel;return this.includeDefaultTemplates?this.viewModel.defaultTemplates.toArray().filter((({layout:t,layoutItem:i})=>!(B(t)||i?.id&&e.includes(i.id)))):[]}_getPrintServiceTemplates(){return this.includeDefaultTemplates&&this._getDefaultTemplates().length?[]:this.viewModel.printServiceTemplates.toArray().filter((({layout:e})=>!B(e)))}_renderLayoutTemplates(e,t=!1,i=!1){return t&&e.sort(((e,t)=>(e.label??"")>(t.label??"")?1:-1)),e.map((e=>C("calcite-list-item",{description:this._getPageSizeLabel(e),key:`template-${e.id}-${e.id===this.templateOptions.id}`,label:this._getTemplateLabel(e),selected:e.id===this.templateOptions.id,title:e.description??"",value:e},C("calcite-icon",{icon:(e.layout?N.get(e.layout):null)||"custom-print",slot:"content-start"}),"loading"===e.state?C("calcite-loader",{inline:!0,key:`template-loader-${e.id}`,label:"loading",scale:"s",slot:"content-end"}):null,"error"===e?.state?C("calcite-icon",{class:M.templateSelectError,icon:"exclamation-mark-circle",key:`template-error-${e.id}`,scale:"s",slot:"content-end"}):null,i?C("calcite-action",{icon:"trash",onclick:()=>this.viewModel.removePortalTemplate(e),slot:"actions-end",text:"delete"}):null)))}_renderChooseTemplateFlowItem(){if(!this._showTemplates)return null;const{messages:e}=this,t=m.test(this.portal?.url),i=this.viewModel.browseTemplates.toArray(),a=this._getPortalTemplates(),l=this._getDefaultTemplates(),o=this._getPrintServiceTemplates(),n=i.length+a.length+l.length+o.length>15,s=this.browseTemplateButtonOnClick?C("calcite-button",{appearance:"outline",class:n?M.browseTemplateButtonContainerFilter:M.browseTemplateButtonContainer,iconStart:"folder",key:"browse-template-button",onclick:this.browseTemplateButtonOnClick,slot:n?"filter-actions-end":"default"},n?null:e.browseTemplates):null;return C("calcite-flow-item",{bind:this,closable:!1,heading:e.chooseTemplate,key:"template-flow-item",onCalciteFlowItemBack:e=>{e.preventDefault(),this._showTemplates=!1}},C("div",{class:M.templateSelectFlowItemContainer},C("div",{class:M.templateSelectFlowItemContent},n?null:s,C("calcite-list",{filterEnabled:n,filterProps:["label"],key:"template-list",selectionMode:"single-persist",onCalciteListChange:({target:e})=>this.viewModel.applyTemplate(e.selectedItems[0]?.value)},n?s:null,i.length?C("div",{key:"my-templates"},C("div",{class:M.templateSelectFlowItemListHeading},e.myTemplates,C("calcite-chip",{appearance:"outline",kind:"neutral",scale:"s",value:e.beta},e.beta)),this._renderLayoutTemplates(i,!0,!0)):null,a.length?C("div",{key:"org-templates"},C("div",{class:M.templateSelectFlowItemListHeading},e.organizationTemplates,t?C("calcite-chip",{appearance:"outline",kind:"neutral",scale:"s",value:e.beta},e.beta):null),this._renderLayoutTemplates(a)):null,i.length||a.length?l.length?C("div",{key:"default-templates"},C("div",{class:M.templateSelectFlowItemListHeading},e.defaultTemplates),this._renderLayoutTemplates(l,!0)):null:this._renderLayoutTemplates(l,!0),i.length||a.length?o.length?C("div",{key:"service-templates"},C("div",{class:M.templateSelectFlowItemListHeading},e.defaultTemplates),this._renderLayoutTemplates(o)):null:this._renderLayoutTemplates(o))),C("div",{class:M.templateButtonContainer},C("calcite-button",{class:M.templateDoneButton,onclick:()=>this._showTemplates=!1},this.messagesCommon.done))))}_renderCustomTextElementSection(){const{customTextElements:e}=this.templateOptions;return e?C("div",{class:M.formSectionContainer,key:"custom-text-elements"},e.map(((e,t)=>{const[i,a]=Object.entries(e)[0];return"date"===i?null:C("calcite-label",{key:`custom-text-elements-${i}-${t}`},i,C("calcite-input",{bind:this,"data-input-custom":!0,"data-input-name":i,value:a??"",onCalciteInputInput:this._updateInputValue}))}))):null}_renderTitleOrFileNameSection(){const{title:e,fileName:t,titlePlaceHolder:i,fileNamePlaceHolder:a}=this.messages,l=this._selectedTab===E.layout?e:t,o=this._selectedTab===E.layout?i:a,n=this._selectedTab===E.layout?this.templateOptions.title:this.templateOptions.fileName;return C("div",{class:M.formSectionContainer,key:l},C("calcite-label",null,l,C("calcite-input",{placeholder:o,value:n??"",onCalciteInputInput:this._onInput})))}_focusOnTabChange(e){if(!this._activeTabFocusRequested)return;const t=e.getAttribute("data-tab-id");("layoutTab"===t&&this._selectedTab===E.layout||"mapOnlyTab"===t&&this._selectedTab===E.mapOnly||"exportTab"===t&&this._selectedTab===E.export)&&(e.focus(),this._activeTabFocusRequested=!1)}_renderLoader(){const e={[M.loader]:this._awaitingServerResponse};return C("div",{class:this.classes(e),key:"loader"})}_updateExportedFileNameMap(e){void 0!==this._exportedFileNameMap[e]?this._exportedFileNameMap[e]++:this._exportedFileNameMap[e]=0}_createFileLink(e,t){const i=t||this.messages.untitled,a=e.format.toLowerCase(),l=a.includes("png")?"png":a,o=i+l;return this._updateExportedFileNameMap(o),new _({name:i,extension:l,count:this._exportedFileNameMap[o]})}_resetToCurrentScale(){this.templateOptions.scale=this.viewModel.view?.scale}_updateCustomTextElementValue(e,t,i){e.find((e=>{const[i]=Object.entries(e)[0];return i===t}))[t]=i}_updateInputValue(e){const t=e.target,i=t.getAttribute("data-input-name"),a=!!t["data-input-custom"],{templateOptions:l}=this;a?this._updateCustomTextElementValue(l.customTextElements,i,t.value):l[i]=t.value}_updateNumberInputValue(e){const t=e.target,i=t.getAttribute("data-input-name"),{templateOptions:a}=this,l=Number(t.value);if(P(l))a[i]=l;else{const e=a[i];t.value=`${e}`}}_handleDPIChange(e){const{templateOptions:t}=this,i=t.dpi;this._updateNumberInputValue(e);const a=t.dpi,{height:l,width:o}=j(a,i,t.width,t.height);t.height=l,t.width=o}_handlePrintMap(){this._pendingExportScroll=!0;const{templateOptions:e,saveExportEnabled:t}=this,i=this.viewModel.toPrintTemplate(e),a=this._selectedTab===E.layout?i.layoutOptions?.titleText:e.fileName,l=this._createFileLink(i,a);this.exportedLinks.add(l),this.emit("submit",{link:l,saveExportEnabled:t}),this._selectedTab=E.export,this.viewModel.print(i).then((e=>{l.set({url:e&&e.url,state:"ready"})})).catch((e=>{l.set({error:e,state:"error"})})).then((()=>{this.emit("complete",{link:l,saveExportEnabled:t}),this.scheduleRender()}))}_switchInput(){[this.templateOptions.width,this.templateOptions.height]=[this.templateOptions.height,this.templateOptions.width]}_scrollExportIntoView(){if(!this._pendingExportScroll)return;this._pendingExportScroll=!1;const e=this._rootNode;if(!e)return;const{clientHeight:t,scrollHeight:i}=e,a=i-t;a>0&&(e.scrollTop=a)}_toggleInputValue(e){const t=e.target,i=t.getAttribute("data-option-name");this.templateOptions[i]=t.checked,"scaleEnabled"===i&&this._resetToCurrentScale()}_renderExportedLink(e){const t=this.messages,i=e.map((e=>{const{error:i,url:a,state:o}=e,r=e.formattedName??"",c="error"===o,p="pending"===o,d="ready"===o;let m=a||null;m&&(m=n(m));const u=s(a,location.href);let h;h=p?t.pending:d?t.ready:t.errorMessage;const b=c?"print-task:cim-symbol-unsupported"===i?.name?t.exportWebMapCIMError:t.exportWebMapError:"";return C("calcite-list-item",{"aria-label":h,key:r,title:b},C("div",{class:M.exportedFile,"data-item":e,onclick:this._handleLinkClick,slot:"content"},C("div",null,C("div",{class:M.exportedFileLinkTitle},r),C("div",{class:M.exportedFileLinkDescription},p?t.generatingExport:b||(u?t.ready:t.linkReady))),d?C("calcite-icon",{"aria-label":`${r}. ${t.linkReady}`,icon:u?"download-to":"launch",key:`${r}-end-icon`,scale:"s",slot:"content-end"}):null),p?C("calcite-loader",{class:M.exportedFileLoader,inline:!0,key:`${r}-loader`,label:t.generatingExport,scale:"m",slot:"content-start"}):C("calcite-icon",{icon:A(e),key:`${r}-start-icon`,scale:"s",slot:"content-start"}),p?null:this.saveAsButtonCallback&&!c&&this._isFormatAllowedForSaving(e.extension)?C("calcite-action",{"aria-label":`${b}`,icon:"ellipsis",id:`${r}-popover-button`,key:`${r}-action`,slot:"actions-end",text:`${b}`},C("calcite-popover",{autoClose:!0,key:`${r}-popover`,label:"Popover",offsetDistance:1,overlayPositioning:"fixed",pointerDisabled:!0,referenceElement:`${r}-popover-button`,scale:"s"},C("calcite-list",null,e.portalItem?C("calcite-list-item",{label:t.openItem,onCalciteListItemSelect:()=>{const t=e.portalItem;if(!t||!t.itemPageUrl)return;const i=document.createElement("a");i.target="_blank",i.href=t.itemPageUrl,i.rel="noreferrer",i.click()}},C("calcite-icon",{icon:"launch2",key:`${r}-launch-icon`,scale:"s",slot:"content-start"})):C("calcite-list-item",{label:t.saveAs,onCalciteListItemSelect:async()=>{this.saveAsButtonCallback&&(l((()=>e.portalItem)).then((e=>{e.itemPageUrl&&this.scheduleRender()})),await this.saveAsButtonCallback(e))}},C("calcite-icon",{icon:"save",key:`${r}-save-icon`,scale:"s",slot:"content-start"})),C("calcite-list-item",{label:this.messagesCommon.delete,onCalciteListItemSelect:()=>this.exportedLinks.remove(e)},C("calcite-icon",{icon:"trash",key:`${r}-delete-icon`,scale:"s",slot:"content-start"}))))):C("calcite-action",{"aria-label":`${b}`,icon:"x",key:`${r}-action`,onclick:()=>{this.exportedLinks.remove(e)},slot:"actions-end",text:`${b}`}))}));return C("calcite-list",{filterEnabled:e?.length>10},i)}_isFormatAllowedForSaving(e){return!this.allowedFormatsForSaving||"all"===this.allowedFormatsForSaving||!(!e||!this.allowedFormatsForSaving.includes(e))}_toggleLayoutPanel(e){const t=e.target;this._toggleTab(t.getAttribute("data-tab-id"))}_toggleTab(e,t=!0){if(this._selectedTab=e,this._selectedTab===E.mapOnly)this.templateOptions.reset(),this.templateOptions.layout=I;else if(this._selectedTab===E.layout){const e=this._selectedTemplate??this.viewModel.defaultTemplate;e?this.viewModel.applyTemplate(e):this.templateOptions.reset()}t&&(this._activeTabFocusRequested=!0)}_handleLayoutPanelKeyDown(e){const{key:t}=e,i=e.target.getAttribute("data-tab-id");if(x(t))return this._toggleTab(i),e.preventDefault(),void e.stopPropagation();if("ArrowLeft"===t||"ArrowRight"===t){switch(i){case E.layout:this._toggleTab("ArrowLeft"===t?E.export:E.mapOnly);break;case E.mapOnly:this._toggleTab("ArrowLeft"===t?E.layout:E.export);break;case E.export:this._toggleTab("ArrowLeft"===t?E.mapOnly:E.layout)}e.preventDefault(),e.stopPropagation()}}};e([r()],D.prototype,"_showTemplates",void 0),e([r()],D.prototype,"_isValidSpatialReference",void 0),e([r()],D.prototype,"allowedFormats",null),e([r()],D.prototype,"allowedFormatsForSaving",void 0),e([r()],D.prototype,"allowedLayouts",null),e([r()],D.prototype,"browseTemplateButtonOnClick",void 0),e([r()],D.prototype,"error",null),e([r({type:$})],D.prototype,"exportedLinks",void 0),e([r()],D.prototype,"extraParameters",null),e([r()],D.prototype,"headerVisible",void 0),e([r()],D.prototype,"headingLevel",void 0),e([r()],D.prototype,"icon",null),e([r()],D.prototype,"includeDefaultTemplates",null),e([r()],D.prototype,"label",null),e([r(),k("esri/widgets/Print/t9n/Print")],D.prototype,"messages",void 0),e([r(),k("esri/t9n/common")],D.prototype,"messagesCommon",void 0),e([r(),k("esri/core/t9n/Units")],D.prototype,"messagesUnits",void 0),e([r({type:S})],D.prototype,"outSpatialReference",null),e([r()],D.prototype,"portal",null),e([r()],D.prototype,"saveExportEnabled",void 0),e([r()],D.prototype,"saveExportHidden",void 0),e([r()],D.prototype,"showPrintAreaEnabled",null),e([r()],D.prototype,"printServiceUrl",null),e([r()],D.prototype,"saveAsButtonCallback",void 0),e([r()],D.prototype,"templateCustomTextElements",null),e([r()],D.prototype,"templateOptions",null),e([r()],D.prototype,"view",null),e([r({type:v})],D.prototype,"viewModel",void 0),D=e([p("esri.widgets.Print")],D);const V=D;export{V as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../../chunks/tslib.es6.js";import e from"../../../Color.js";import"../../../geometry.js";import"../../../symbols.js";import i from"../../../core/Evented.js";import r from"../../../core/Logger.js";import{rad2deg as s}from"../../../core/mathUtils.js";import{destroyMaybe as o}from"../../../core/maybe.js";import{when as n,watch as a}from"../../../core/reactiveUtils.js";import{convertUnit as l}from"../../../core/unitUtils.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as h}from"../../../core/accessorSupport/decorators/subclass.js";import{isLoadedOrLoadFor as p,project as d}from"../../../geometry/projection.js";import{getResolutionForScale as m}from"../../../geometry/support/scaleUtils.js";import{MeasuredGrid as g}from"../../../grids/MeasuredGrid.js";import{makeDehydratedPoint as u}from"../../../layers/graphics/dehydratedPoint.js";import{defaultUnitPropertyMetadata as v}from"../../../properties/defaultUnit.js";import{minimumPixelsPerStrideForDisplayWhenScalingOff as y}from"../../../views/2d/grid/constants.js";import{getScaleFactor as _,shouldUsePlanar as w,measureMetersPerUnitAtReferencePoint as f}from"../../../views/2d/grid/gridUtils.js";import{DrawGraphicTool2D as S}from"../../../views/2d/interactive/editingTools/draw/DrawGraphicTool2D.js";import"../../../views/2d/interactive/editingTools/ControlPointsTransformTool.js";import"../../../views/2d/interactive/editingTools/TransformTool.js";import"../../../views/2d/interactive/editingTools/MediaTransformToolsWrapper.js";import{gridPlacementGraphicSymbol as b}from"../../../views/interactive/snapping/snappingUtils.js";import P from"../../../views/overlay/CrosshairOverlayItem.js";import T from"../../../views/overlay/TextOverlayItem.js";import{degreeSymbol as j}from"../../CoordinateConversion/support/formatUtils.js";import{applyColorToGrid as C,gridRotationToDegrees as x}from"./gridUtils.js";import G from"../../../geometry/Point.js";import O from"../../../symbols/SimpleLineSymbol.js";import R from"../../../symbols/SimpleMarkerSymbol.js";const I=Symbol("grid-interactivity");let L=class extends i.EventedAccessor{constructor(t){super(t),this._drawGraphicTool=null,this._crosshairLabel=null,this._crosshairItem=null,this.snappingManager=null,this.snappingOptions=null,this.view=null,this.placementDisabled=!1,this._mostRecentlyShownGrid=null,this._sketchedVertexCount=0}initialize(){this.addHandles([n((()=>!this.displayEnabled),(()=>{this.interactivePlacementState=null})),a((()=>this.view?.viewpoint),(()=>{this._renderOverlays()})),a((()=>this.snappingOptions?.gridEnabled&&this.snappingOptions.enabled),(t=>{null!=t&&(this.trySetDisplayEnabled(t),!0===this.snappingOptions?.enabled&&(this.snappingEnabled=t))})),a((()=>this.view?.grid),((t,e)=>{this._mostRecentlyShownGrid=!t&&e?e:null}))])}destroy(){this._resetGridPlacementState(),this._crosshairItem&&(this.view?.overlay?.removeItem(this._crosshairItem),this._crosshairItem=o(this._crosshairItem)),this._crosshairLabel&&(this.view?.overlay?.removeItem(this._crosshairLabel),this._crosshairLabel=o(this._crosshairLabel))}get displayEnabled(){return!!this.view?.grid}get dynamicScaling(){return this.grid?.dynamicScaling??!1}set dynamicScaling(t){this.grid&&(this.grid.dynamicScaling=t)}get grid(){return this.view?.grid??this._mostRecentlyShownGrid}set gridColor(t){this._set("gridColor",t);const[e,i,r,s]=t.toArray();C(this.grid,[e,i,r,s/255])}get gridControlsEnabled(){return this.displayEnabled&&!this.interactivePlacementState}set interactivePlacementState(t){this._set("interactivePlacementState",t),this._resetGridPlacementState(),t&&this._startGridManipulation(t)}get majorLineInterval(){return this.grid?.majorLineInterval??10}set majorLineInterval(t){this.grid&&(this.grid.majorLineInterval=t<1?1:t>15?15:t)}get rotateWithMap(){return this.grid?.rotateWithMap??!1}set rotateWithMap(t){this.grid&&(this.grid.rotateWithMap=t)}get rotation(){return this.grid?.rotation??-180}set rotation(t){this.grid&&(this.grid.rotation=t)}get snappingEnabled(){return(this.grid&&this.snappingOptions?.gridEnabled)??!1}set snappingEnabled(t){const{snappingOptions:e}=this;e&&(e.gridEnabled=t)}get spacing(){return this.grid?.spacing??1}set spacing(t){this.grid&&t>0&&(this.grid.spacing=t)}get unit(){return this.grid?.units}set unit(t){this.grid&&(this.grid.units=t)}get gridOutOfScale(){return!this.dynamicScaling&&null!=this._pixelsPerStride&&this._pixelsPerStride<y}get effectiveSpacingAfterDynamicScaling(){return this.majorLineInterval<1||!this.dynamicScaling||!this.view||null==this._pixelsPerStride||!this.grid?.spacing?null:this.grid.spacing*_(this.majorLineInterval,this._pixelsPerStride,this.dynamicScaling)}get numericSpacingInputShouldBeVisible(){return!!this.view?.spatialReference&&w(this.view.spatialReference)}get _metersPerSRUnit(){if(!(this.view&&this.displayEnabled&&this.grid&&p(this.grid.center.spatialReference,this.view.spatialReference)))return null;const t=d(this.grid.center,this.view.spatialReference);return f(t)}get _pixelsPerStride(){if(!this.view?.scale||!this.displayEnabled||!this.grid||null==this._metersPerSRUnit)return null;const t=this.grid,{scale:e,spatialReference:i}=this.view;return l(t.spacing,t.units,"meters")/(this._metersPerSRUnit*m(e,i))}get _isPlacing(){if(!this._drawGraphicTool)return!1;const t=this.interactivePlacementState;return"place"===t||"interactive"===t&&0===this._sketchedVertexCount}get _isRotating(){if(!this._drawGraphicTool)return!1;const t=this.interactivePlacementState;return"rotate"===t||"interactive"===t&&1===this._sketchedVertexCount}get _isScaling(){if(!this._drawGraphicTool)return!1;return"interactive"===this.interactivePlacementState&&1===this._sketchedVertexCount}togglePlacementState(t){this.interactivePlacementState=this.interactivePlacementState===t?null:t}trySetDisplayEnabled(t){const{view:e}=this;if(e?.ready)if(!e.grid&&t)if(this._mostRecentlyShownGrid)e.grid=this._mostRecentlyShownGrid;else{const t="imperial"===this.defaultUnit?"feet":"meters";e.grid=new g({units:t,center:e.center??new G,rotateWithMap:!0}),C(this.grid,[115,115,115])}else t||(e.grid=null);else r.getLogger(this).warn("Attempting to enable grid display while view is not ready")}startPlacement(t){const{view:e,snappingManager:i}=this;if(!e)return;this._set("interactivePlacementState",t),this._sketchedVertexCount=0;const r=new S({view:e,graphicProperties:{attributes:{[b]:b}},sketchOptions:{tooltips:{enabled:!0,visibleElements:{direction:!1,rotation:!1,totalLength:!1,elevation:!1,distance:!1,area:!1}}},geometryType:"polyline",mode:"click",snapToScene:!1,snappingManager:i,forceUniformSize:!0,centered:!1,cursor:"interactive"===this.interactivePlacementState||"place"===this.interactivePlacementState?"none":null,regularVerticesSymbol:void 0,activeVertexSymbol:E,activeLineSymbol:k,graphicSymbol:k});this._drawGraphicTool=r,e.addAndActivateTool(r),this._renderOverlays(),this.addHandles([r.on("cursor-update",(t=>this._onCursorUpdate(t))),r.on("complete",(()=>this._onDrawComplete())),r.on("vertex-add",(e=>this._onVertexAdd(e,t)))],I)}async _startGridManipulation(t){const{view:e}=this;if(!e)return void(this.interactivePlacementState=null);const i=new CustomEvent("before-placement",{cancelable:!0});this.emit("before-placement",i),i.defaultPrevented||this.startPlacement(t)}_onCursorUpdate(t){try{if(this._isPlacing){const e=t.vertices[0].coordinates;return void this._handlePlace(e)}if(this._drawGraphicTool.cursor=null,this._isRotating&&this._handleRotate(t.vertices[0].coordinates),this._isScaling){const t=this._drawGraphicTool?.drawOperation.cursorVertex;this._handleScale(t)}}finally{this._renderOverlays()}}_onDrawComplete(){this._drawGraphicTool.cursor=null,this.interactivePlacementState=null}_onVertexAdd(t,e){const i=t.vertices[0].coordinates;this._isPlacing&&this._handlePlace(i),this._isRotating&&this._sketchedVertexCount>0&&this._handleRotate(i),this._isScaling&&this._sketchedVertexCount>0&&this._handleScale(u(i[0],i[1],void 0,this.view.spatialReference)),this._sketchedVertexCount++,this._drawGraphicTool.cursor=null,2!==this._sketchedVertexCount&&"interactive"===e||(this.interactivePlacementState=null),this._renderOverlays()}_handlePlace(t){const{grid:e,view:i}=this;e&&i&&(e.center=new G({x:t[0],y:t[1],spatialReference:i.spatialReference}))}_handleRotate(t){const{grid:e,view:i}=this;if(!e||!i)return;this._drawGraphicTool?.sketchOptions.tooltips.set("enabled",!1);const{x:r,y:o}=e.center,[n,a]=t,l=i.toScreen(e.center,{pickClosestTarget:!0}),c=l&&i.toMap(l),h=i.toScreen(u(n,a,void 0,i.spatialReference),{pickClosestTarget:!0}),p=h&&i.toMap(h),d=c?c.x:r,m=c?c.y:o,g=d-(p?p.x:n),v=m-(p?p.y:a);if(0===g&&0===v)return;const y=Math.atan2(v,g),_=s(y),w=e.rotateWithMap,f=i.viewpoint.rotation??0,S=w?_:_-f;e.rotation=Math.fround(S)%360}_handleScale(t){const{view:e,grid:i,_drawGraphicTool:r,interactivePlacementState:s,_metersPerSRUnit:o}=this;if(!(t&&e&&i&&r&&o))return;r.sketchOptions.tooltips.enabled=!1;const n="interactive"===s?i.center:r.drawOperation.firstVertex;if(!n||!t)return;const a=e?.toScreen(n),c=a&&e.toMap(a),h=e?.toScreen(t),p=c??n,d=(h&&e.toMap(h))??t,m=Math.sqrt((p.x-d.x)**2+(p.y-d.y)**2),g=l(m*o,"meters",i.units);this.spacing=g}_renderOverlays(){this._renderCrosshairOverlay(),this._renderTextOverlay()}_renderTextOverlay(){const{grid:t,view:e,_drawGraphicTool:i}=this,r=this._getCrosshairLabel();if(!(t&&e?.overlay&&i&&r))return;const s=e.toScreen(t.center,{pickClosestTarget:!0});s&&(r.position=[s.x+12,s.y+12]),this._isRotating?(r.text=`${x(t.rotation)}${j}`,r.visible=!0):r.visible=!1}_renderCrosshairOverlay(){const{grid:t,view:e,_drawGraphicTool:i}=this;if(!t||!e?.overlay||!i)return;const r=this._getCrosshair();if(!r)return;const s=e.toScreen(t.center);s&&(r.x=s.x,r.y=s.y,r.rotation=t.rotateWithMap?e.viewpoint.rotation-t.rotation:-t.rotation,r.visible=!!i)}_getCrosshairLabel(){if(this._crosshairLabel)return this._crosshairLabel;const{grid:t,view:i,_drawGraphicTool:r}=this;if(!t||!i?.overlay||!r)return null;const s=new T({anchor:"top-left",fontSize:10,textColor:new e([21,21,21]),backgroundColor:new e([248,248,248]),padding:8,borderRadius:20});return i.overlay.addItem(s),this._crosshairLabel=s,s}_getCrosshair(){const{_crosshairItem:t,view:e}=this;return e?.overlay?t&&e.overlay.items.includes(t)?t:(this._crosshairItem=new P({color:e.effectiveTheme.accentColor,thickness:4,length:36,visible:!0}),e.overlay?.addItem(this._crosshairItem),this._crosshairItem):null}_resetGridPlacementState(){this.removeHandles(I),this._crosshairItem&&(this._crosshairItem.visible=!1),this._crosshairLabel&&(this._crosshairLabel.visible=!1),this._drawGraphicTool&&(this.view?.activeTool===this._drawGraphicTool&&(this.view.activeTool=null),this.view?.tools.remove(this._drawGraphicTool)),this._drawGraphicTool=o(this._drawGraphicTool)}};t([c(v)],L.prototype,"defaultUnit",void 0),t([c({readOnly:!0})],L.prototype,"displayEnabled",null),t([c()],L.prototype,"dynamicScaling",null),t([c()],L.prototype,"grid",null),t([c()],L.prototype,"gridColor",null),t([c({readOnly:!0})],L.prototype,"gridControlsEnabled",null),t([c()],L.prototype,"interactivePlacementState",null),t([c()],L.prototype,"majorLineInterval",null),t([c()],L.prototype,"rotateWithMap",null),t([c()],L.prototype,"rotation",null),t([c()],L.prototype,"snappingEnabled",null),t([c()],L.prototype,"snappingManager",void 0),t([c()],L.prototype,"snappingOptions",void 0),t([c()],L.prototype,"spacing",null),t([c()],L.prototype,"unit",null),t([c()],L.prototype,"view",void 0),t([c({readOnly:!0})],L.prototype,"gridOutOfScale",null),t([c({readOnly:!0})],L.prototype,"effectiveSpacingAfterDynamicScaling",null),t([c({readOnly:!0})],L.prototype,"numericSpacingInputShouldBeVisible",null),t([c()],L.prototype,"placementDisabled",void 0),t([c()],L.prototype,"_metersPerSRUnit",null),t([c()],L.prototype,"_pixelsPerStride",null),t([c()],L.prototype,"_isPlacing",null),t([c()],L.prototype,"_isRotating",null),t([c()],L.prototype,"_isScaling",null),t([c()],L.prototype,"_mostRecentlyShownGrid",void 0),t([c()],L.prototype,"_sketchedVertexCount",void 0),L=t([h("esri.widgets.support.GridControls.GridControlsViewModel")],L);const M=L,k=new O({width:0}),E=new R({color:e.fromArray([0,0,0,0]),outline:new O({color:e.fromArray([0,0,0,0])})});export{M as default};
5
+ import{_ as t}from"../../../chunks/tslib.es6.js";import e from"../../../Color.js";import"../../../geometry.js";import"../../../symbols.js";import i from"../../../core/Evented.js";import r from"../../../core/Logger.js";import{rad2deg as s}from"../../../core/mathUtils.js";import{destroyMaybe as o}from"../../../core/maybe.js";import{when as n,watch as a}from"../../../core/reactiveUtils.js";import{convertUnit as l}from"../../../core/unitUtils.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as h}from"../../../core/accessorSupport/decorators/subclass.js";import{isLoadedOrLoadFor as d,project as p}from"../../../geometry/projection.js";import{getResolutionForScale as m}from"../../../geometry/support/scaleUtils.js";import{MeasuredGrid as g}from"../../../grids/MeasuredGrid.js";import{makeDehydratedPoint as u}from"../../../layers/graphics/dehydratedPoint.js";import{defaultUnitPropertyMetadata as v}from"../../../properties/defaultUnit.js";import{minimumPixelsPerStrideForDisplayWhenScalingOff as y}from"../../../views/2d/grid/constants.js";import{getScaleFactor as _,shouldUsePlanar as w,measureMetersPerUnitAtReferencePoint as f}from"../../../views/2d/grid/gridUtils.js";import{DrawGraphicTool2D as S}from"../../../views/2d/interactive/editingTools/draw/DrawGraphicTool2D.js";import"../../../views/2d/interactive/editingTools/ControlPointsTransformTool.js";import"../../../views/2d/interactive/editingTools/TransformTool.js";import"../../../views/2d/interactive/editingTools/MediaTransformToolsWrapper.js";import{gridPlacementGraphicSymbol as b}from"../../../views/interactive/snapping/snappingUtils.js";import P from"../../../views/overlay/CrosshairOverlayItem.js";import T from"../../../views/overlay/TextOverlayItem.js";import{degreeSymbol as j}from"../../CoordinateConversion/support/formatUtils.js";import{applyColorToGrid as C,gridRotationToDegrees as x}from"./gridUtils.js";import G from"../../../geometry/Point.js";import R from"../../../symbols/SimpleLineSymbol.js";import O from"../../../symbols/SimpleMarkerSymbol.js";const I=Symbol("grid-interactivity");let L=class extends i.EventedAccessor{constructor(t){super(t),this._drawGraphicTool=null,this._crosshairLabel=null,this._crosshairItem=null,this.snappingManager=null,this.snappingOptions=null,this.view=null,this.placementDisabled=!1,this._mostRecentlyShownGrid=null,this._sketchedVertexCount=0}initialize(){this.addHandles([n((()=>!this.displayEnabled),(()=>{this.interactivePlacementState=null})),a((()=>this.view?.viewpoint),(()=>{this._renderOverlays()})),a((()=>this.snappingOptions?.gridEnabled),(t=>{null!=t&&this.trySetDisplayEnabled(t)})),a((()=>this.view?.grid),((t,e)=>{this._mostRecentlyShownGrid=!t&&e?e:null}))])}destroy(){this._resetGridPlacementState(),this._crosshairItem&&(this.view?.overlay?.removeItem(this._crosshairItem),this._crosshairItem=o(this._crosshairItem)),this._crosshairLabel&&(this.view?.overlay?.removeItem(this._crosshairLabel),this._crosshairLabel=o(this._crosshairLabel))}get displayEnabled(){return!!this.view?.grid}get dynamicScaling(){return this.grid?.dynamicScaling??!1}set dynamicScaling(t){this.grid&&(this.grid.dynamicScaling=t)}get grid(){return this.view?.grid??this._mostRecentlyShownGrid}set gridColor(t){this._set("gridColor",t);const[e,i,r,s]=t.toArray();C(this.grid,[e,i,r,s/255])}get gridControlsEnabled(){return this.displayEnabled&&!this.interactivePlacementState}set interactivePlacementState(t){this._set("interactivePlacementState",t),this._resetGridPlacementState(),t&&this._startGridManipulation(t)}get majorLineInterval(){return this.grid?.majorLineInterval??10}set majorLineInterval(t){this.grid&&(this.grid.majorLineInterval=t<1?1:t>15?15:t)}get rotateWithMap(){return this.grid?.rotateWithMap??!1}set rotateWithMap(t){this.grid&&(this.grid.rotateWithMap=t)}get rotation(){return this.grid?.rotation??-180}set rotation(t){this.grid&&(this.grid.rotation=t)}get snappingEnabled(){return(this.grid&&this.snappingOptions?.gridEnabled)??!1}set snappingEnabled(t){const{snappingOptions:e}=this;e&&(e.gridEnabled=t)}get spacing(){return this.grid?.spacing??1}set spacing(t){this.grid&&t>0&&(this.grid.spacing=t)}get unit(){return this.grid?.units}set unit(t){this.grid&&(this.grid.units=t)}get gridOutOfScale(){return!this.dynamicScaling&&null!=this._pixelsPerStride&&this._pixelsPerStride<y}get effectiveSpacingAfterDynamicScaling(){return this.majorLineInterval<1||!this.dynamicScaling||!this.view||null==this._pixelsPerStride||!this.grid?.spacing?null:this.grid.spacing*_(this.majorLineInterval,this._pixelsPerStride,this.dynamicScaling)}get numericSpacingInputShouldBeVisible(){return!!this.view?.spatialReference&&w(this.view.spatialReference)}get _metersPerSRUnit(){if(!(this.view&&this.displayEnabled&&this.grid&&d(this.grid.center.spatialReference,this.view.spatialReference)))return null;const t=p(this.grid.center,this.view.spatialReference);return f(t)}get _pixelsPerStride(){if(!this.view?.scale||!this.displayEnabled||!this.grid||null==this._metersPerSRUnit)return null;const t=this.grid,{scale:e,spatialReference:i}=this.view;return l(t.spacing,t.units,"meters")/(this._metersPerSRUnit*m(e,i))}get _isPlacing(){if(!this._drawGraphicTool)return!1;const t=this.interactivePlacementState;return"place"===t||"interactive"===t&&0===this._sketchedVertexCount}get _isRotating(){if(!this._drawGraphicTool)return!1;const t=this.interactivePlacementState;return"rotate"===t||"interactive"===t&&1===this._sketchedVertexCount}get _isScaling(){if(!this._drawGraphicTool)return!1;return"interactive"===this.interactivePlacementState&&1===this._sketchedVertexCount}togglePlacementState(t){this.interactivePlacementState=this.interactivePlacementState===t?null:t}trySetDisplayEnabled(t){const{view:e}=this;if(e?.ready)if(!e.grid&&t)if(this._mostRecentlyShownGrid)e.grid=this._mostRecentlyShownGrid;else{const t="imperial"===this.defaultUnit?"feet":"meters";e.grid=new g({units:t,center:e.center??new G,rotateWithMap:!0}),C(this.grid,[115,115,115])}else t||(e.grid=null);else r.getLogger(this).warn("Attempting to enable grid display while view is not ready")}startPlacement(t){const{view:e,snappingManager:i}=this;if(!e)return;this._set("interactivePlacementState",t),this._sketchedVertexCount=0;const r=new S({view:e,graphicProperties:{attributes:{[b]:b}},sketchOptions:{tooltips:{enabled:!0,visibleElements:{direction:!1,rotation:!1,totalLength:!1,elevation:!1,distance:!1,area:!1}}},geometryType:"polyline",mode:"click",snapToScene:!1,snappingManager:i,forceUniformSize:!0,centered:!1,cursor:"interactive"===this.interactivePlacementState||"place"===this.interactivePlacementState?"none":null,regularVerticesSymbol:void 0,activeVertexSymbol:E,activeLineSymbol:k,graphicSymbol:k});this._drawGraphicTool=r,e.addAndActivateTool(r),this._renderOverlays(),this.addHandles([r.on("cursor-update",(t=>this._onCursorUpdate(t))),r.on("complete",(()=>this._onDrawComplete())),r.on("vertex-add",(e=>this._onVertexAdd(e,t)))],I)}async _startGridManipulation(t){const{view:e}=this;if(!e)return void(this.interactivePlacementState=null);const i=new CustomEvent("before-placement",{cancelable:!0});this.emit("before-placement",i),i.defaultPrevented||this.startPlacement(t)}_onCursorUpdate(t){try{if(this._isPlacing){const e=t.vertices[0].coordinates;return void this._handlePlace(e)}if(this._drawGraphicTool.cursor=null,this._isRotating&&this._handleRotate(t.vertices[0].coordinates),this._isScaling){const t=this._drawGraphicTool?.drawOperation.cursorVertex;this._handleScale(t)}}finally{this._renderOverlays()}}_onDrawComplete(){this._drawGraphicTool.cursor=null,this.interactivePlacementState=null}_onVertexAdd(t,e){const i=t.vertices[0].coordinates;this._isPlacing&&this._handlePlace(i),this._isRotating&&this._sketchedVertexCount>0&&this._handleRotate(i),this._isScaling&&this._sketchedVertexCount>0&&this._handleScale(u(i[0],i[1],void 0,this.view.spatialReference)),this._sketchedVertexCount++,this._drawGraphicTool.cursor=null,2!==this._sketchedVertexCount&&"interactive"===e||(this.interactivePlacementState=null),this._renderOverlays()}_handlePlace(t){const{grid:e,view:i}=this;e&&i&&(e.center=new G({x:t[0],y:t[1],spatialReference:i.spatialReference}))}_handleRotate(t){const{grid:e,view:i}=this;if(!e||!i)return;this._drawGraphicTool?.sketchOptions.tooltips.set("enabled",!1);const{x:r,y:o}=e.center,[n,a]=t,l=i.toScreen(e.center,{pickClosestTarget:!0}),c=l&&i.toMap(l),h=i.toScreen(u(n,a,void 0,i.spatialReference),{pickClosestTarget:!0}),d=h&&i.toMap(h),p=c?c.x:r,m=c?c.y:o,g=p-(d?d.x:n),v=m-(d?d.y:a);if(0===g&&0===v)return;const y=Math.atan2(v,g),_=s(y),w=e.rotateWithMap,f=i.viewpoint.rotation??0,S=w?_:_-f;e.rotation=Math.fround(S)%360}_handleScale(t){const{view:e,grid:i,_drawGraphicTool:r,interactivePlacementState:s,_metersPerSRUnit:o}=this;if(!(t&&e&&i&&r&&o))return;r.sketchOptions.tooltips.enabled=!1;const n="interactive"===s?i.center:r.drawOperation.firstVertex;if(!n||!t)return;const a=e?.toScreen(n),c=a&&e.toMap(a),h=e?.toScreen(t),d=c??n,p=(h&&e.toMap(h))??t,m=Math.sqrt((d.x-p.x)**2+(d.y-p.y)**2),g=l(m*o,"meters",i.units);this.spacing=g}_renderOverlays(){this._renderCrosshairOverlay(),this._renderTextOverlay()}_renderTextOverlay(){const{grid:t,view:e,_drawGraphicTool:i}=this,r=this._getCrosshairLabel();if(!(t&&e?.overlay&&i&&r))return;const s=e.toScreen(t.center,{pickClosestTarget:!0});s&&(r.position=[s.x+12,s.y+12]),this._isRotating?(r.text=`${x(t.rotation)}${j}`,r.visible=!0):r.visible=!1}_renderCrosshairOverlay(){const{grid:t,view:e,_drawGraphicTool:i}=this;if(!t||!e?.overlay||!i)return;const r=this._getCrosshair();if(!r)return;const s=e.toScreen(t.center);s&&(r.x=s.x,r.y=s.y,r.rotation=t.rotateWithMap?e.viewpoint.rotation-t.rotation:-t.rotation,r.visible=!!i)}_getCrosshairLabel(){if(this._crosshairLabel)return this._crosshairLabel;const{grid:t,view:i,_drawGraphicTool:r}=this;if(!t||!i?.overlay||!r)return null;const s=new T({anchor:"top-left",fontSize:10,textColor:new e([21,21,21]),backgroundColor:new e([248,248,248]),padding:8,borderRadius:20});return i.overlay.addItem(s),this._crosshairLabel=s,s}_getCrosshair(){const{_crosshairItem:t,view:e}=this;return e?.overlay?t&&e.overlay.items.includes(t)?t:(this._crosshairItem=new P({color:e.effectiveTheme.accentColor,thickness:4,length:36,visible:!0}),e.overlay?.addItem(this._crosshairItem),this._crosshairItem):null}_resetGridPlacementState(){this.removeHandles(I),this._crosshairItem&&(this._crosshairItem.visible=!1),this._crosshairLabel&&(this._crosshairLabel.visible=!1),this._drawGraphicTool&&(this.view?.activeTool===this._drawGraphicTool&&(this.view.activeTool=null),this.view?.tools.remove(this._drawGraphicTool)),this._drawGraphicTool=o(this._drawGraphicTool)}};t([c(v)],L.prototype,"defaultUnit",void 0),t([c({readOnly:!0})],L.prototype,"displayEnabled",null),t([c()],L.prototype,"dynamicScaling",null),t([c()],L.prototype,"grid",null),t([c()],L.prototype,"gridColor",null),t([c({readOnly:!0})],L.prototype,"gridControlsEnabled",null),t([c()],L.prototype,"interactivePlacementState",null),t([c()],L.prototype,"majorLineInterval",null),t([c()],L.prototype,"rotateWithMap",null),t([c()],L.prototype,"rotation",null),t([c()],L.prototype,"snappingEnabled",null),t([c()],L.prototype,"snappingManager",void 0),t([c()],L.prototype,"snappingOptions",void 0),t([c()],L.prototype,"spacing",null),t([c()],L.prototype,"unit",null),t([c()],L.prototype,"view",void 0),t([c({readOnly:!0})],L.prototype,"gridOutOfScale",null),t([c({readOnly:!0})],L.prototype,"effectiveSpacingAfterDynamicScaling",null),t([c({readOnly:!0})],L.prototype,"numericSpacingInputShouldBeVisible",null),t([c()],L.prototype,"placementDisabled",void 0),t([c()],L.prototype,"_metersPerSRUnit",null),t([c()],L.prototype,"_pixelsPerStride",null),t([c()],L.prototype,"_isPlacing",null),t([c()],L.prototype,"_isRotating",null),t([c()],L.prototype,"_isScaling",null),t([c()],L.prototype,"_mostRecentlyShownGrid",void 0),t([c()],L.prototype,"_sketchedVertexCount",void 0),L=t([h("esri.widgets.support.GridControls.GridControlsViewModel")],L);const M=L,k=new R({width:0}),E=new O({color:e.fromArray([0,0,0,0]),outline:new R({color:e.fromArray([0,0,0,0])})});export{M as default};
@@ -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{isSome as t}from"../../core/arrayUtils.js";import{createTask as i}from"../../core/asyncUtils.js";import{destroyMaybe as s}from"../../core/maybe.js";import{generateUID as l}from"../../core/uid.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import a from"../Widget.js";import{loadCalciteComponents as r}from"./componentsUtils.js";import{globalCss as d}from"./globalCss.js";import{loadLabeledSwitchComponents as p,LabeledSwitch as c}from"./LabeledSwitch.js";import{setFocus as g}from"./widgetUtils.js";import{messageBundle as h}from"./decorators/messageBundle.js";import{tsx as m}from"./jsxFactory.js";import b from"./SnappingControls/SnappingControlsViewModel.js";import{itemTitleMatchesFilter as u}from"./SnappingControls/snappingLayerListUtils.js";import y from"./SnappingControls/VisibleElements.js";const _="esri-snapping-controls",L={base:_,container:`${_}__container`,item:`${_}__item`,toggleBlock:`${_}__toggle-block`,layerListBlock:`${_}__layer-list-block`,layerList:`${_}__layer-list`,layerListFilter:`${_}__layer-list__filter`,layerListButton:`${_}__layer-list__button`,layerListItem:`${_}__layer-list__item`,layerListGroup:`${_}__layer-list__group`,nestedContainer:`${_}__nested-container`};let w=class extends a{constructor(e,t){super(e,t),this._defaultViewModel=null,this._layerListFilter=null,this._gridLoadTask=null,this.layerListOpen=!0,this.gridOptionsOpen=!1,this.messages=null,this.messagesCommon=null,this.snappingManager=null,this.visibleElements=new y,this._enableSnappingSwitchChange=e=>{this.snappingOptions.enabled=e},this._featureEnabledSwitchChange=e=>{this.snappingOptions.featureEnabled=e},this._gridEnabledSwitchChange=e=>{this.snappingOptions.gridEnabled=e,e&&this._startLoadGrid()},this._selfEnabledSwitchChange=e=>{this.snappingOptions.selfEnabled=e},this._onToggleLayersButtonClick=e=>{this.viewModel.toggleSnappingForAllLayers(!this.viewModel.allLayersEnabled),g(e.target)};const{snappingOptions:i,view:s,viewModel:l}=e;this.viewModel=l??(this._defaultViewModel=new b({snappingOptions:i,view:s}))}normalizeCtorArgs(e){const{snappingOptions:t,view:i,viewModel:s,...l}=e;return l}destroy(){this.viewModel!==this._defaultViewModel&&(this._defaultViewModel=s(this._defaultViewModel))}loadDependencies(){return Promise.all([r({block:()=>import("@esri/calcite-components/dist/components/calcite-block.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),input:()=>import("@esri/calcite-components/dist/components/calcite-input.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),checkbox:()=>import("@esri/calcite-components/dist/components/calcite-checkbox.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js")}),p()])}get _openAndReady(){return this.gridOptionsOpen&&this.snappingOptions.gridEnabled&&this.snappingOptions.enabled}get icon(){return"snap-to-point"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get snappingOptions(){return this.viewModel.snappingOptions}set snappingOptions(e){this.viewModel.snappingOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}set viewModel(e){e!==this._get("viewModel")&&(null!=this._defaultViewModel&&this._defaultViewModel===e||(this._defaultViewModel=s(this._defaultViewModel)),this._set("viewModel",e))}render(){const{label:e}=this;return m("div",{"aria-label":e,class:this.classes(L.base,d.widget)},m("div",{class:L.container},this._renderContent()))}_renderContent(){return[this._renderToggles(),this._renderLayerList(),"2d"===this.view?.type&&this.visibleElements.gridControls?this._renderGridOptions():null]}_renderToggles(){const{visibleElements:e,view:i}=this,s=[e.selfEnabledToggle?this._renderSelfEnabledToggle():null,e.featureEnabledToggle?this._renderFeatureEnabledToggle():null,e.gridEnabledToggle&&"2d"===i?.type?this._renderGridEnabledToggle():null].filter(t),l=[e.enabledToggle?this._renderEnabledToggle():null,s.length>0?m("div",{class:L.nestedContainer},s):null].filter(t);return 0===l.length?null:m("calcite-block",{class:L.toggleBlock,heading:e.header?this.label:"",key:"toggle-block",open:!0},l)}_renderEnabledToggle(){return m(c,{checked:this.viewModel.snappingOptions.enabled,disabled:this._enabledToggleDisabled,key:`${this.id}__enabled-toggle`,label:this.messages.enableSnapping,onChange:this._enableSnappingSwitchChange})}_renderSelfEnabledToggle(){return m(c,{checked:this.viewModel.snappingOptions.selfEnabled,disabled:this._secondaryElementsDisabled,key:`${this.id}__self-enabled-toggle`,label:this.messages.geometryGuides,onChange:this._selfEnabledSwitchChange})}_renderFeatureEnabledToggle(){return m(c,{checked:this.viewModel.snappingOptions.featureEnabled,disabled:this._secondaryElementsDisabled,key:`${this.id}__feature-enabled-toggle`,label:this.messages.featureToFeature,onChange:this._featureEnabledSwitchChange})}_renderGridEnabledToggle(){return m(c,{checked:this.viewModel.snappingOptions.gridEnabled,disabled:this._secondaryElementsDisabled,key:`${this.id}__grid-enabled-toggle`,label:this.messages.grid,onChange:this._gridEnabledSwitchChange})}_renderLayerList(){if(!this.visibleElements.layerList)return null;const{messages:e,viewModel:t}=this,i=({target:{value:e}})=>{this._layerListFilter=""===e?null:new RegExp(e,"i")},s=t.layerListViewModel.operationalItems.length>9?m("calcite-input",{class:L.layerListFilter,clearable:!0,placeholder:e?.searchLayers,onCalciteInputInput:i}):null,l=this._secondaryElementsDisabled,n=this.layerListOpen&&!l;return m("calcite-block",{class:L.layerListBlock,collapsible:!0,disabled:this._secondaryElementsDisabled,heading:e.snappingLayers,key:"list-block",open:n,onCalciteBlockToggle:e=>this.layerListOpen=e.target.open},s,this._renderToggleLayersButton(),m("calcite-list",{class:L.layerList,selectionMode:"none"},this._renderLayerListItemCollection(t.layerListViewModel.operationalItems)))}_renderGridOptions(){const{view:e,visibleElements:t,snappingManager:i,snappingOptions:s,_openAndReady:l}=this,{gridEnabled:n,enabled:o}=s;l&&this._startLoadGrid();const a=this._gridLoadTask?.value,r=a&&"2d"===e?.type&&m(a,{snappingManager:i,snappingOptions:s,view:e,visibleElements:t.gridControlsElements});return m("calcite-block",{class:L.layerListBlock,collapsible:!0,disabled:!n||!o,heading:this.messages.gridOptionsHeading,key:"grid-block",open:l,onCalciteBlockClose:()=>this.gridOptionsOpen=!1,onCalciteBlockOpen:()=>this.gridOptionsOpen=!0},r??m("calcite-loader",{label:this.messagesCommon.loading,scale:"s",text:this.messagesCommon.loading}))}async _startLoadGrid(){!this._gridLoadTask&&this.visibleElements.gridControls&&"2d"===this.view?.type&&(this._gridLoadTask=i((async()=>(await import("./GridControls.js")).default)))}_renderLayerListItemCollection(e){const i=this._layerListFilter;return e.map((e=>{switch(i?u(e,i):null){case"children":{const t=e.children.filter((e=>!1!==u(e,i)));return this._renderLayerListItemGroup(e,t)}case"self":case null:return this._renderLayerListItemOrGroup(e);case!1:return"self"===u(e.parent,i)?this._renderLayerListItemOrGroup(e):null}})).toArray().filter(t)}_renderToggleLayersButton(){if(!this.visibleElements.layerListToggleLayersButton)return null;const{viewModel:{allLayersEnabled:e},messages:t}=this,i=e?t.disableAllLayers:t.enableAllLayers;return m("calcite-button",{appearance:"transparent",class:L.layerListButton,label:i,name:"layer-toggle",onclick:this._onToggleLayersButtonClick},i)}_renderLayerListItemOrGroup(e){if(e.children.length)return this._renderLayerListItemGroup(e);const{messages:{untitledLayer:t}}=this,i=e.title||t,s=()=>{this.viewModel.toggleSnappingForLayers([e.layer.id],"enabled"!==e.enabled)};return m("calcite-list-item",{class:L.layerListItem,key:`${this.id}-list-item-${e.uid}`,label:i,onCalciteListItemSelect:e=>{e.stopPropagation(),s()}},m("calcite-checkbox",{checked:"enabled"===e.enabled,slot:"actions-start",onCalciteCheckboxChange:s}))}_renderLayerListItemGroup(e,t){const{children:i,title:s}=e,n=s||this.messages.untitledLayer,o=s&&""!==s?s:l(),a=!!t?.length,r=t??i,d=()=>{this.viewModel.toggleSnappingForLayers(e.childLayerIds,"enabled"!==e.enabled)};return m("calcite-list-item",{class:L.layerListGroup,key:o,label:n,open:a,onCalciteListItemSelect:e=>{e.stopPropagation(),d()}},m("calcite-checkbox",{checked:"enabled"===e.enabled,indeterminate:"indeterminate"===e.enabled,slot:"actions-start",onCalciteCheckboxChange:d}),m("calcite-list",null,this._renderLayerListItemCollection(r)))}get _enabledToggleDisabled(){const e=this.snappingOptions;return e.enabledToggled||e.forceDisabled}get _secondaryElementsDisabled(){return this._enabledToggleDisabled||!this.snappingOptions.enabled}};e([n()],w.prototype,"_defaultViewModel",void 0),e([n()],w.prototype,"_layerListFilter",void 0),e([n()],w.prototype,"_gridLoadTask",void 0),e([n()],w.prototype,"_openAndReady",null),e([n()],w.prototype,"label",null),e([n({type:Boolean,nonNullable:!0})],w.prototype,"layerListOpen",void 0),e([n({type:Boolean,nonNullable:!0})],w.prototype,"gridOptionsOpen",void 0),e([n(),h("esri/widgets/support/SnappingControls/t9n/SnappingControls")],w.prototype,"messages",void 0),e([n(),h("esri/t9n/common")],w.prototype,"messagesCommon",void 0),e([n()],w.prototype,"snappingOptions",null),e([n()],w.prototype,"snappingManager",void 0),e([n()],w.prototype,"view",null),e([n()],w.prototype,"viewModel",null),e([n({type:y,nonNullable:!0})],w.prototype,"visibleElements",void 0),e([n()],w.prototype,"_enabledToggleDisabled",null),e([n()],w.prototype,"_secondaryElementsDisabled",null),w=e([o("esri.widgets.support.SnappingControls")],w);const v=w;export{v as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import{isSome as t}from"../../core/arrayUtils.js";import{createTask as i}from"../../core/asyncUtils.js";import{destroyMaybe as s}from"../../core/maybe.js";import{watch as l}from"../../core/reactiveUtils.js";import{generateUID as n}from"../../core/uid.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import r from"../Widget.js";import{loadCalciteComponents as d}from"./componentsUtils.js";import{globalCss as p}from"./globalCss.js";import{loadLabeledSwitchComponents as c,LabeledSwitch as g}from"./LabeledSwitch.js";import{setFocus as h}from"./widgetUtils.js";import{messageBundle as m}from"./decorators/messageBundle.js";import{tsx as b}from"./jsxFactory.js";import u from"./SnappingControls/SnappingControlsViewModel.js";import{itemTitleMatchesFilter as y}from"./SnappingControls/snappingLayerListUtils.js";import _ from"./SnappingControls/VisibleElements.js";const L="esri-snapping-controls",w={base:L,container:`${L}__container`,item:`${L}__item`,toggleBlock:`${L}__toggle-block`,layerListBlock:`${L}__layer-list-block`,layerList:`${L}__layer-list`,layerListFilter:`${L}__layer-list__filter`,layerListButton:`${L}__layer-list__button`,layerListItem:`${L}__layer-list__item`,layerListGroup:`${L}__layer-list__group`,nestedContainer:`${L}__nested-container`};let v=class extends r{constructor(e,t){super(e,t),this._defaultViewModel=null,this._layerListFilter=null,this._gridLoadTask=null,this.layerListOpen=!0,this.gridOptionsOpen=!1,this.messages=null,this.messagesCommon=null,this.snappingManager=null,this.visibleElements=new _,this._enableSnappingSwitchChange=e=>{this.snappingOptions.enabled=e},this._featureEnabledSwitchChange=e=>{this.snappingOptions.featureEnabled=e},this._gridEnabledSwitchChange=e=>{this.snappingOptions.gridEnabled=e,e&&this._startLoadGrid()},this._selfEnabledSwitchChange=e=>{this.snappingOptions.selfEnabled=e},this._onToggleLayersButtonClick=e=>{this.viewModel.toggleSnappingForAllLayers(!this.viewModel.allLayersEnabled),h(e.target)};const{snappingOptions:i,view:s,viewModel:l}=e;this.viewModel=l??(this._defaultViewModel=new u({snappingOptions:i,view:s}))}normalizeCtorArgs(e){const{snappingOptions:t,view:i,viewModel:s,...l}=e;return l}destroy(){this.viewModel!==this._defaultViewModel&&(this._defaultViewModel=s(this._defaultViewModel))}loadDependencies(){return Promise.all([d({block:()=>import("@esri/calcite-components/dist/components/calcite-block.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),input:()=>import("@esri/calcite-components/dist/components/calcite-input.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),checkbox:()=>import("@esri/calcite-components/dist/components/calcite-checkbox.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js")}),c()])}initialize(){this.addHandles(l((()=>"2d"===this.view?.type&&!!this.view.grid),(e=>{this.visibleElements.gridControls&&(this.snappingOptions.gridEnabled=e)})))}get _openAndReady(){return this.gridOptionsOpen&&this.snappingOptions.gridEnabled&&this.snappingOptions.enabled}get icon(){return"snap-to-point"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get snappingOptions(){return this.viewModel.snappingOptions}set snappingOptions(e){this.viewModel.snappingOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}set viewModel(e){e!==this._get("viewModel")&&(null!=this._defaultViewModel&&this._defaultViewModel===e||(this._defaultViewModel=s(this._defaultViewModel)),this._set("viewModel",e))}render(){const{label:e}=this;return b("div",{"aria-label":e,class:this.classes(w.base,p.widget)},b("div",{class:w.container},this._renderContent()))}_renderContent(){return[this._renderToggles(),this._renderLayerList(),"2d"===this.view?.type&&this.visibleElements.gridControls?this._renderGridOptions():null]}_renderToggles(){const{visibleElements:e,view:i}=this,s=[e.selfEnabledToggle?this._renderSelfEnabledToggle():null,e.featureEnabledToggle?this._renderFeatureEnabledToggle():null,e.gridEnabledToggle&&"2d"===i?.type?this._renderGridEnabledToggle():null].filter(t),l=[e.enabledToggle?this._renderEnabledToggle():null,s.length>0?b("div",{class:w.nestedContainer},s):null].filter(t);return 0===l.length?null:b("calcite-block",{class:w.toggleBlock,heading:e.header?this.label:"",key:"toggle-block",open:!0},l)}_renderEnabledToggle(){return b(g,{checked:this.viewModel.snappingOptions.enabled,disabled:this._enabledToggleDisabled,key:`${this.id}__enabled-toggle`,label:this.messages.enableSnapping,onChange:this._enableSnappingSwitchChange})}_renderSelfEnabledToggle(){return b(g,{checked:this.viewModel.snappingOptions.selfEnabled,disabled:this._secondaryElementsDisabled,key:`${this.id}__self-enabled-toggle`,label:this.messages.geometryGuides,onChange:this._selfEnabledSwitchChange})}_renderFeatureEnabledToggle(){return b(g,{checked:this.viewModel.snappingOptions.featureEnabled,disabled:this._secondaryElementsDisabled,key:`${this.id}__feature-enabled-toggle`,label:this.messages.featureToFeature,onChange:this._featureEnabledSwitchChange})}_renderGridEnabledToggle(){return b(g,{checked:this.viewModel.snappingOptions.gridEnabled,disabled:this._secondaryElementsDisabled,key:`${this.id}__grid-enabled-toggle`,label:this.messages.grid,onChange:this._gridEnabledSwitchChange})}_renderLayerList(){if(!this.visibleElements.layerList)return null;const{messages:e,viewModel:t}=this,i=({target:{value:e}})=>{this._layerListFilter=""===e?null:new RegExp(e,"i")},s=t.layerListViewModel.operationalItems.length>9?b("calcite-input",{class:w.layerListFilter,clearable:!0,placeholder:e?.searchLayers,onCalciteInputInput:i}):null,l=this._secondaryElementsDisabled,n=this.layerListOpen&&!l;return b("calcite-block",{class:w.layerListBlock,collapsible:!0,disabled:this._secondaryElementsDisabled,heading:e.snappingLayers,key:"list-block",open:n,onCalciteBlockToggle:e=>this.layerListOpen=e.target.open},s,this._renderToggleLayersButton(),b("calcite-list",{class:w.layerList,selectionMode:"none"},this._renderLayerListItemCollection(t.layerListViewModel.operationalItems)))}_renderGridOptions(){const{view:e,visibleElements:t,snappingManager:i,snappingOptions:s,_openAndReady:l}=this,{gridEnabled:n,enabled:o}=s;(l||"2d"===e?.type&&e.grid)&&this._startLoadGrid();const a=this._gridLoadTask?.value,r=a&&"2d"===e?.type&&b(a,{snappingManager:i,snappingOptions:s,view:e,visibleElements:t.gridControlsElements});return b("calcite-block",{class:w.layerListBlock,collapsible:!0,disabled:!n||!o,heading:this.messages.gridOptionsHeading,key:"grid-block",open:l,onCalciteBlockClose:()=>this.gridOptionsOpen=!1,onCalciteBlockOpen:()=>this.gridOptionsOpen=!0},r??b("calcite-loader",{label:this.messagesCommon.loading,scale:"s",text:this.messagesCommon.loading}))}async _startLoadGrid(){!this._gridLoadTask&&this.visibleElements.gridControls&&"2d"===this.view?.type&&(this._gridLoadTask=i((async()=>(await import("./GridControls.js")).default)))}_renderLayerListItemCollection(e){const i=this._layerListFilter;return e.map((e=>{switch(i?y(e,i):null){case"children":{const t=e.children.filter((e=>!1!==y(e,i)));return this._renderLayerListItemGroup(e,t)}case"self":case null:return this._renderLayerListItemOrGroup(e);case!1:return"self"===y(e.parent,i)?this._renderLayerListItemOrGroup(e):null}})).toArray().filter(t)}_renderToggleLayersButton(){if(!this.visibleElements.layerListToggleLayersButton)return null;const{viewModel:{allLayersEnabled:e},messages:t}=this,i=e?t.disableAllLayers:t.enableAllLayers;return b("calcite-button",{appearance:"transparent",class:w.layerListButton,label:i,name:"layer-toggle",onclick:this._onToggleLayersButtonClick},i)}_renderLayerListItemOrGroup(e){if(e.children.length)return this._renderLayerListItemGroup(e);const{messages:{untitledLayer:t}}=this,i=e.title||t,s=()=>{this.viewModel.toggleSnappingForLayers([e.layer.id],"enabled"!==e.enabled)};return b("calcite-list-item",{class:w.layerListItem,key:`${this.id}-list-item-${e.uid}`,label:i,onCalciteListItemSelect:e=>{e.stopPropagation(),s()}},b("calcite-checkbox",{checked:"enabled"===e.enabled,slot:"actions-start",onCalciteCheckboxChange:s}))}_renderLayerListItemGroup(e,t){const{children:i,title:s}=e,l=s||this.messages.untitledLayer,o=s&&""!==s?s:n(),a=!!t?.length,r=t??i,d=()=>{this.viewModel.toggleSnappingForLayers(e.childLayerIds,"enabled"!==e.enabled)};return b("calcite-list-item",{class:w.layerListGroup,key:o,label:l,open:a,onCalciteListItemSelect:e=>{e.stopPropagation(),d()}},b("calcite-checkbox",{checked:"enabled"===e.enabled,indeterminate:"indeterminate"===e.enabled,slot:"actions-start",onCalciteCheckboxChange:d}),b("calcite-list",null,this._renderLayerListItemCollection(r)))}get _enabledToggleDisabled(){const e=this.snappingOptions;return e.enabledToggled||e.forceDisabled}get _secondaryElementsDisabled(){return this._enabledToggleDisabled||!this.snappingOptions.enabled}};e([o()],v.prototype,"_defaultViewModel",void 0),e([o()],v.prototype,"_layerListFilter",void 0),e([o()],v.prototype,"_gridLoadTask",void 0),e([o()],v.prototype,"_openAndReady",null),e([o()],v.prototype,"label",null),e([o({type:Boolean,nonNullable:!0})],v.prototype,"layerListOpen",void 0),e([o({type:Boolean,nonNullable:!0})],v.prototype,"gridOptionsOpen",void 0),e([o(),m("esri/widgets/support/SnappingControls/t9n/SnappingControls")],v.prototype,"messages",void 0),e([o(),m("esri/t9n/common")],v.prototype,"messagesCommon",void 0),e([o()],v.prototype,"snappingOptions",null),e([o()],v.prototype,"snappingManager",void 0),e([o()],v.prototype,"view",null),e([o()],v.prototype,"viewModel",null),e([o({type:_,nonNullable:!0})],v.prototype,"visibleElements",void 0),e([o()],v.prototype,"_enabledToggleDisabled",null),e([o()],v.prototype,"_secondaryElementsDisabled",null),v=e([a("esri.widgets.support.SnappingControls")],v);const f=v;export{f as default};
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[4796],{81457:(e,t,r)=>{r.d(t,{A:()=>P});var n,o=r(90237),i=r(61147),s=(r(44208),r(66552)),a=r(25482),l=r(4718),u=r(90629),c=r(10107),p=(r(53966),r(36005)),d=r(40608),y=r(43937),h=(r(87811),r(32730));let f=n=class extends a.oY{constructor(){super(...arguments),this.expression=null,this.title=null,this.value=null}readExpression(e,t){return t.value?(0,h.mX)(t.value):e}writeExpression(e,t,r){null!=this.value&&(e=(0,h.mX)(this.value)),null!=e&&(t[r]=e)}clone(){return new n({expression:this.expression,title:this.title,value:this.value})}};(0,o._)([(0,c.MZ)({type:String,json:{write:{writerEnsuresNonNull:!0}}})],f.prototype,"expression",void 0),(0,o._)([(0,p.w)("expression",["expression","value"])],f.prototype,"readExpression",null),(0,o._)([(0,y.K)("expression")],f.prototype,"writeExpression",null),(0,o._)([(0,c.MZ)({type:String,json:{write:!0,origins:{"web-scene":{write:!1}}}})],f.prototype,"title",void 0),(0,o._)([(0,c.MZ)({json:{read:!1,write:!1}})],f.prototype,"value",void 0),f=n=(0,o._)([(0,d.$)("esri.layers.support.LabelExpressionInfo")],f);const m=f;var b,w=r(83531),g=r(59868),v=r(73838);const x=new s.J({esriServerPointLabelPlacementAboveCenter:"above-center",esriServerPointLabelPlacementAboveLeft:"above-left",esriServerPointLabelPlacementAboveRight:"above-right",esriServerPointLabelPlacementBelowCenter:"below-center",esriServerPointLabelPlacementBelowLeft:"below-left",esriServerPointLabelPlacementBelowRight:"below-right",esriServerPointLabelPlacementCenterCenter:"center-center",esriServerPointLabelPlacementCenterLeft:"center-left",esriServerPointLabelPlacementCenterRight:"center-right",esriServerLinePlacementAboveAfter:"above-after",esriServerLinePlacementAboveAlong:"above-along",esriServerLinePlacementAboveBefore:"above-before",esriServerLinePlacementAboveStart:"above-start",esriServerLinePlacementAboveEnd:"above-end",esriServerLinePlacementBelowAfter:"below-after",esriServerLinePlacementBelowAlong:"below-along",esriServerLinePlacementBelowBefore:"below-before",esriServerLinePlacementBelowStart:"below-start",esriServerLinePlacementBelowEnd:"below-end",esriServerLinePlacementCenterAfter:"center-after",esriServerLinePlacementCenterAlong:"center-along",esriServerLinePlacementCenterBefore:"center-before",esriServerLinePlacementCenterStart:"center-start",esriServerLinePlacementCenterEnd:"center-end",esriServerPolygonPlacementAlwaysHorizontal:"always-horizontal"},{ignoreUnknown:!0});function S(e,t,r){return{enabled:!(0,w.TU)(r?.layer)}}function A(e){return!e||"service"!==e.origin&&!("map-image"===e.layer?.type)}function M(e){return!!function(e){return"map-image"===e?.type}(e)&&!!e.capabilities?.exportMap?.supportsArcadeExpressionForLabeling}let I=b=class extends a.oY{static evaluateWhere(e,t){const r=(e,t,r)=>{switch(t){case"=":return e==r;case"<>":return e!=r;case">":return e>r;case">=":return e>=r;case"<":return e<r;case"<=":return e<=r}return!1};try{if(null==e)return!0;const n=e.split(" ");if(3===n.length)return r(t[n[0]],n[1],n[2]);if(7===n.length){const e=r(t[n[0]],n[1],n[2]),o=n[3],i=r(t[n[4]],n[5],n[6]);switch(o){case"AND":return e&&i;case"OR":return e||i}}return!1}catch(e){}}constructor(e){super(e),this.type="label",this.name=null,this.allowOverrun=!1,this.deconflictionStrategy="static",this.labelExpression=null,this.labelExpressionInfo=null,this.labelPlacement=null,this.labelPosition="curved",this.maxScale=0,this.minScale=0,this.repeatLabel=!0,this.repeatLabelDistance=null,this.symbol=g.Hk,this.useCodedValues=void 0,this.where=null}readLabelExpression(e,t){const r=t.labelExpressionInfo;if(!r||!r.value&&!r.expression)return e}writeLabelExpression(e,t,r){if(this.labelExpressionInfo)if(null!=this.labelExpressionInfo.value)e=(0,h.D3)(this.labelExpressionInfo.value);else if(null!=this.labelExpressionInfo.expression){const t=(0,h.tH)(this.labelExpressionInfo.expression);t&&(e="["+t+"]")}null!=e&&(t[r]=e)}writeLabelExpressionInfo(e,t,r,n){if(null==e&&null!=this.labelExpression&&A(n))e=new m({expression:this.getLabelExpressionArcade()});else if(!e)return;const o=e.toJSON(n);o.expression&&(t[r]=o)}writeMaxScale(e,t){(e||this.minScale)&&(t.maxScale=e)}writeMinScale(e,t){(e||this.maxScale)&&(t.minScale=e)}getLabelExpression(){return(0,h.XJ)(this)}getLabelExpressionArcade(){return(0,h.BI)(this)}getLabelExpressionSingleField(){return(0,h.rU)(this)}hash(){return JSON.stringify(this)}clone(){return new b({allowOverrun:this.allowOverrun,deconflictionStrategy:this.deconflictionStrategy,labelExpression:this.labelExpression,labelExpressionInfo:(0,l.o8)(this.labelExpressionInfo),labelPosition:this.labelPosition,labelPlacement:this.labelPlacement,maxScale:this.maxScale,minScale:this.minScale,name:this.name,repeatLabel:this.repeatLabel,repeatLabelDistance:this.repeatLabelDistance,symbol:(0,l.o8)(this.symbol),where:this.where,useCodedValues:this.useCodedValues})}};(0,o._)([(0,c.MZ)({type:String,json:{write:!0}})],I.prototype,"name",void 0),(0,o._)([(0,c.MZ)({type:Boolean,json:{write:!0,default:!1,origins:{"web-scene":{write:!1},"portal-item":{default:!1,write:{overridePolicy:S}}}}})],I.prototype,"allowOverrun",void 0),(0,o._)([(0,c.MZ)({type:String,json:{write:!0,default:"static",origins:{"web-scene":{write:!1},"portal-item":{default:"static",write:{overridePolicy:S}}}}})],I.prototype,"deconflictionStrategy",void 0),(0,o._)([(0,c.MZ)({type:String,json:{write:{overridePolicy(e,t,r){return this.labelExpressionInfo&&"service"===r?.origin&&M(r.layer)?{enabled:!1}:{allowNull:!0}}}}})],I.prototype,"labelExpression",void 0),(0,o._)([(0,p.w)("labelExpression")],I.prototype,"readLabelExpression",null),(0,o._)([(0,y.K)("labelExpression")],I.prototype,"writeLabelExpression",null),(0,o._)([(0,c.MZ)({type:m,json:{write:{overridePolicy:(e,t,r)=>function(e){return A(e)||M(e?.layer)}(r)?{allowNull:!0}:{enabled:!1}}}})],I.prototype,"labelExpressionInfo",void 0),(0,o._)([(0,y.K)("labelExpressionInfo")],I.prototype,"writeLabelExpressionInfo",null),(0,o._)([(0,c.MZ)({type:x.apiValues,json:{type:x.jsonValues,read:x.read,write:x.write}})],I.prototype,"labelPlacement",void 0),(0,o._)([(0,c.MZ)({type:["curved","parallel"],json:{write:!0,origins:{"web-map":{write:!1},"web-scene":{write:!1},"portal-item":{write:!1}}}})],I.prototype,"labelPosition",void 0),(0,o._)([(0,c.MZ)({type:Number})],I.prototype,"maxScale",void 0),(0,o._)([(0,y.K)("maxScale")],I.prototype,"writeMaxScale",null),(0,o._)([(0,c.MZ)({type:Number})],I.prototype,"minScale",void 0),(0,o._)([(0,y.K)("minScale")],I.prototype,"writeMinScale",null),(0,o._)([(0,c.MZ)({type:Boolean,json:{write:!0,origins:{"web-scene":{write:!1},"portal-item":{write:{overridePolicy:S}}}}})],I.prototype,"repeatLabel",void 0),(0,o._)([(0,c.MZ)({type:Number,cast:u.cr,json:{write:!0,origins:{"web-scene":{write:!1},"portal-item":{write:{overridePolicy:S}}}}})],I.prototype,"repeatLabelDistance",void 0),(0,o._)([(0,c.MZ)({types:i.em,json:{origins:{"web-scene":{types:i.Rv,write:v.oO,default:null}},write:v.oO,default:null}})],I.prototype,"symbol",void 0),(0,o._)([(0,c.MZ)({type:Boolean,json:{write:!0}})],I.prototype,"useCodedValues",void 0),(0,o._)([(0,c.MZ)({type:String,json:{write:!0}})],I.prototype,"where",void 0),I=b=(0,o._)([(0,d.$)("esri.layers.support.LabelClass")],I);const P=I},15426:(e,t,r)=>{r.d(t,{Xl:()=>S,ct:()=>I,pc:()=>T,hx:()=>V,C$:()=>k,PD:()=>z,VZ:()=>D,mm:()=>L,VA:()=>H,WP:()=>j,iX:()=>x,Nv:()=>G,xd:()=>Q,GA:()=>U,jp:()=>R,tG:()=>K,lV:()=>E,B5:()=>Z,Ye:()=>F,sg:()=>_,hM:()=>C,S2:()=>O,jD:()=>N,Zm:()=>q,$4:()=>B,Pt:()=>X,bt:()=>M,rn:()=>P,ZJ:()=>W});var n=r(70333),o=r(61147),i=r(60999),s=r(49186),a=r(66552),l=r(39516),u=r(13069),c=r(90360),p=r(39357),d=r(53177),y=r(61956);async function h(e,t,r){t=t.clone(),e.capabilities.query.supportsMaxRecordCountFactor&&(t.maxRecordCountFactor=f(e));const n=function(e){return f(e)*function(e){return e.capabilities.query.maxRecordCount||2e3}(e)}(e),o=e.capabilities.query.supportsPagination;t.start=0,t.num=n;let i=null;for(;;){const s=await e.source.queryFeaturesJSON(t,r);if(null==i?i=s:i.features=i.features.concat(s.features),i.exceededTransferLimit=s.exceededTransferLimit,!o||!s.exceededTransferLimit)break;t.start+=n}return i}function f(e){return e.capabilities.query.supportsMaxRecordCountFactor?y.A.MAX_MAX_RECORD_COUNT_FACTOR:1}var m=r(83531),b=r(96576),w=r(93618),g=r(54546),v=r(26591);const x=new a.J({esriGeometryPoint:"point",esriGeometryMultipoint:"multipoint",esriGeometryPolyline:"polyline",esriGeometryPolygon:"polygon",esriGeometryMultiPatch:"multipatch"});async function S(e,t,r,n){const o=await $(e);if(await A(e,t,n),!o.addAttachment)throw new s.A(n,"Layer source does not support addAttachment capability");return o.addAttachment(t,r)}function A(e,t,r){const{attributes:n}=t,{objectIdField:o}=e;return e.capabilities?.data?.supportsAttachment?t?n?o&&n[o]?Promise.resolve():Promise.reject(new s.A(r,`feature is missing the identifying attribute ${o}`)):Promise.reject(new s.A(r,"'attributes' are required on a feature to query attachments")):Promise.reject(new s.A(r,"A feature is required to add/delete/update attachments")):Promise.reject(new s.A(r,"this layer doesn't support attachments"))}async function M(e,t,r,n,o){const i=await $(e);if(await A(e,t,o),!i.updateAttachment)throw new s.A(o,"Layer source does not support updateAttachment capability");return i.updateAttachment(t,r,n)}async function I(e,t,n){const{applyEdits:o}=await r.e(8628).then(r.bind(r,78628)),i=await e.load();let s=n;return"feature"===i.type&&i.infoFor3D&&null!=t.deleteFeatures&&null!=i.globalIdField&&(s={...s,globalIdToObjectId:await U(i,t.deleteFeatures,i.globalIdField)}),o(i,i.source,t,n)}async function P(e,t,n){const{uploadAssets:o}=await r.e(8628).then(r.bind(r,78628)),i=await e.load();return o(i,i.source,t,n)}async function L(e,t,r,n){const o=await $(e);if(await A(e,t,n),!o.deleteAttachments)throw new s.A(n,"Layer source does not support deleteAttachments capability");return o.deleteAttachments(t,r)}async function j(e,t,r){const n=(await e.load({signal:t?.signal})).source;if(!n.fetchRecomputedExtents)throw new s.A(r,"Layer source does not support fetchUpdates capability");return n.fetchRecomputedExtents(t)}async function E(e,t,r,n){t=g.A.from(t),await e.load();const o=e.source,i=e.capabilities;if(!i?.data?.supportsAttachment)throw new s.A(n,"this layer doesn't support attachments");const{attachmentTypes:a,objectIds:l,globalIds:u,num:c,size:p,start:d,where:y}=t;if(!i?.operations?.supportsQueryAttachments&&(a?.length>0||u?.length>0||p?.length>0||c||d||y))throw new s.A(n,"when 'capabilities.operations.supportsQueryAttachments' is false, only objectIds is supported",t);if(!(l?.length||u?.length||y))throw new s.A(n,"'objectIds', 'globalIds', or 'where' are required to perform attachment query",t);if(!o.queryAttachments)throw new s.A(n,"Layer source does not support queryAttachments capability",t);return o.queryAttachments(t)}async function _(e,t,r,n){const o=await $(e);if(!o.queryObjectIds)throw new s.A(n,"Layer source does not support queryObjectIds capability");return o.queryObjectIds(y.A.from(t)??e.createQuery(),r)}async function F(e,t,r,n){const o=await $(e);if(!o.queryFeatureCount)throw new s.A(n,"Layer source does not support queryFeatureCount capability");return o.queryFeatureCount(y.A.from(t)??e.createQuery(),r)}async function Z(e,t,r,n){const o=await $(e);if(!o.queryExtent)throw new s.A(n,"Layer source does not support queryExtent capability");return o.queryExtent(y.A.from(t)??e.createQuery(),r)}async function C(e,t,r,n){const o=await $(e);if(!o.queryRelatedFeatures)throw new s.A(n,"Layer source does not support queryRelatedFeatures capability");return o.queryRelatedFeatures(v.default.from(t),r)}async function O(e,t,r,n){const o=await $(e);if(!o.queryRelatedFeaturesCount)throw new s.A(n,"Layer source does not support queryRelatedFeaturesCount capability");return o.queryRelatedFeaturesCount(v.default.from(t),r)}async function R(e){const t=e.source;if(t?.refresh)try{const{dataChanged:r,updates:n}=await t.refresh();if(null!=n&&(e.sourceJSON={...e.sourceJSON,...n},e.read(n,{origin:"service",url:e.parsedUrl})),r)return!0}catch{}if(e.definitionExpression)try{return(await(0,l.G)(e.definitionExpression,e.fieldsIndex)).hasDateFunctions}catch{}return!1}function D(e){const t=new y.A,r=e.capabilities?.data,n=e.capabilities?.query;t.historicMoment=e.historicMoment,t.gdbVersion=e.gdbVersion,t.returnGeometry=!0,n&&(t.compactGeometryEnabled=n.supportsCompactGeometry,t.defaultSpatialReferenceEnabled=n.supportsDefaultSpatialReference),r&&(r.supportsZ&&null!=e.returnZ&&(t.returnZ=e.returnZ),r.supportsM&&null!=e.returnM&&(t.returnM=e.returnM)),t.outFields=["*"];const{timeOffset:o,timeExtent:i}=e;return t.timeExtent=null!=o&&null!=i?i.offset(-o.value,o.unit):i||null,t.multipatchOption="multipatch"===e.geometryType?"xyFootprint":null,t}function N(e){const{globalIdField:t,fields:r}=e;if(t)return t;if(r)for(const e of r)if("esriFieldTypeGlobalID"===e.type)return e.name}function q(e){const{objectIdField:t,fields:r}=e;if(t)return t;if(r)for(const e of r)if("esriFieldTypeOID"===e.type)return e.name}function B(e){return e.currentVersion?e.currentVersion:e.hasOwnProperty("capabilities")||e.hasOwnProperty("drawingInfo")||e.hasOwnProperty("hasAttachments")||e.hasOwnProperty("htmlPopupType")||e.hasOwnProperty("relationships")||e.hasOwnProperty("timeInfo")||e.hasOwnProperty("typeIdField")||e.hasOwnProperty("types")?10:9.3}function G(e,t){const{subtypes:r,subtypeField:n}=e;if(!t?.attributes||!r?.length||!n)return null;const o=t.attributes[n];return null==o?null:r.find((e=>e.code===o))}function T(e,t){const{fieldsIndex:r,subtypeField:n}=e,{name:o}=r.get(t)??{};if(!o)return null;if((n&&r.get(n)?.name)===o&&e.subtypes?.length){const t=e.subtypes.map((e=>new p.H({code:e.code,name:e.name})));if(t?.length)return new d.A({codedValues:t})}return null}function V(e,t){const{fieldsIndex:r}=e,{name:n}=r.get(t)??{};if(!n)return null;if(("typeIdField"in e?r.get(e.typeIdField)?.name:null)===n&&"types"in e&&e.types?.length){const t=e.types.map((e=>new p.H({code:e.id,name:e.name})));return new d.A({codedValues:t})}return null}async function $(e){return(await e.load()).source}async function H(e,t,r){const o=e.parsedUrl?.path;o&&e.authenticationTriggerEvent===t&&await async function(e,t){if(!n.id)return;if(n.id.findCredential(e))return;let r;try{const o=await(0,m.wI)(e,t);o&&(r=await n.id.checkSignInStatus(`${o}/sharing`))}catch(e){}if(r)try{const r=null!=t?t.signal:null;await n.id.getCredential(e,{signal:r})}catch(e){}}(o,r)}function k(e){return!X(e)&&(e.userHasUpdateItemPrivileges||e.editingEnabled)}const J=(0,c.C)({types:o.xK});function z(e,t){if(e.defaultSymbol)return e.types?.length?new w.A({defaultSymbol:J(e.defaultSymbol,e,t),field:e.typeIdField,uniqueValueInfos:e.types.map((e=>({id:e.id,symbol:J(e.symbol,e,t)})))}):new b.A({symbol:J(e.defaultSymbol,e,t)})}function K(e){let t=e.sourceJSON?.cacheMaxAge;if(!t)return!1;const r=e.editingInfo?.lastEditDate?.getTime();return null==r||(t*=1e3,Date.now()-r<t)}async function U(e,t,r){if(null==t)return null;const n=[],{objectIdField:o}=e;if(t.forEach((e=>{let t=null;if("attributes"in e){const{attributes:n}=e;t={globalId:n[r],objectId:null!=n[o]&&-1!==n[o]?n[o]:null}}else t={globalId:e.globalId,objectId:null!=e.objectId&&-1!==e.objectId?e.objectId:null};null!=t.globalId&&(null!=t.objectId&&-1!==t.objectId||n.push(t.globalId))})),0===n.length)return null;const s=e.createQuery();s.where=n.map((e=>`${r}='${e}'`)).join(" OR "),s.returnGeometry=!1,s.outFields=[o,r],s.cacheHint=!1;const a=await(0,i.DZ)(h(e,s));if(!a.ok)return null;const l=new Map,c=a.value.features;for(const e of c){const t=e.attributes[r],n=e.attributes[o];null!=t&&null!=n&&-1!==n&&l.set((0,u.AG)(t),n)}return l}function Q(e,t,r){if(!t||!r||!e)return null;const n=r.getAttribute(t);return null==n?null:e.find((e=>{const{id:t}=e;return null!=t&&t.toString()===n.toString()}))??null}function X(e){return e.sourceJSON?.isMultiServicesView||function(e){return!!e.sourceJSON?.capabilities?.toLowerCase().split(",").map((e=>e.trim())).includes("map")}(e)}function W(e,t,r){const n=t?.queryBins;if(!n)throw new s.A(r,"Layer source does not support binning");switch(e.binParameters.type){case"auto-interval":if(!n.supportsAutoInterval)throw new s.A(r,"Layer source does not support auto-interval binning");break;case"date":if(!n.supportsDate)throw new s.A(r,"Layer source does not support date binning");break;case"fixed-boundaries":if(!n.supportsFixedBoundaries)throw new s.A(r,"Layer source does not support fixed-boundaries binning");break;case"fixed-interval":if(!n.supportsFixedInterval)throw new s.A(r,"Layer source does not support fixed-interval binning")}const o=n?.supportedStatistics;if(e.outStatistics&&o){const t=new Map([["count","count"],["sum","sum"],["min","min"],["max","max"],["avg","avg"],["stddev","stddev"],["var","var"],["percentile-continuous","percentileContinuous"],["percentile-discrete","percentileDiscrete"],["centroid-aggregate","centroid"],["convex-hull-aggregate","convexHull"],["envelope-aggregate","envelope"]]);for(const{statisticType:n}of e.outStatistics){const e=t.get(n);if(e&&!o[e])throw new s.A(r,`Layer source does not support ${n} statistic type`)}}}},39383:(e,t,r)=>{r.d(t,{w:()=>l,z:()=>c});var n=r(49186),o=r(53966),i=r(81457);const s=()=>o.A.getLogger("esri.layers.support.labelingInfo"),a=/\[([^[\]]+)\]/gi;function l(e,t,r){return e?e.map((e=>{const n=new i.A;if(n.read(e,r),n.labelExpression){const e=t.fields||t.layerDefinition?.fields||this.fields;n.labelExpression=n.labelExpression.replaceAll(a,((t,r)=>`[${function(e,t){if(!t)return e;const r=e.toLowerCase();for(let e=0;e<t.length;e++){const n=t[e].name;if(n.toLowerCase()===r)return n}return e}(r,e)}]`))}return n})):null}const u={esriGeometryPoint:["above-right","above-center","above-left","center-center","center-left","center-right","below-center","below-left","below-right"],esriGeometryMultiPatch:["always-horizontal"],esriGeometryPolygon:["always-horizontal"],esriGeometryPolyline:["center-along","above-along","below-along"],esriGeometryMultipoint:null,esriGeometryEnvelope:null};function c(e,t){const r=[];for(const o of e){const e=o.labelPlacement,i=u[t];if(!o.symbol)return s().warn("No ILabelClass symbol specified."),[];if(!i)return s().error(new n.A("labeling:unsupported-geometry-type",`Unable to create labels for layer, geometry type '${t}' is not supported`)),[];if(i.includes(e))r.push(o);else{const n=i[0];e&&s().warn(`Found invalid label placement type ${e} for ${t}. Defaulting to ${n}`);const a=o.clone();a.labelPlacement=n,r.push(a)}}return r}},54546:(e,t,r)=>{r.d(t,{A:()=>d});var n,o=r(90237),i=r(25482),s=r(4718),a=r(10107),l=r(56507),u=r(40608),c=r(43937);let p=n=class extends i.oY{constructor(e){super(e),this.attachmentTypes=null,this.attachmentsWhere=null,this.cacheHint=void 0,this.keywords=null,this.globalIds=null,this.name=null,this.num=null,this.objectIds=null,this.returnMetadata=!1,this.size=null,this.start=null,this.where=null}writeStart(e,t){t.resultOffset=this.start,t.resultRecordCount=this.num||10}clone(){return new n((0,s.o8)({attachmentTypes:this.attachmentTypes,attachmentsWhere:this.attachmentsWhere,cacheHint:this.cacheHint,keywords:this.keywords,where:this.where,globalIds:this.globalIds,name:this.name,num:this.num,objectIds:this.objectIds,returnMetadata:this.returnMetadata,size:this.size,start:this.start}))}};(0,o._)([(0,a.MZ)({type:[String],json:{write:!0}})],p.prototype,"attachmentTypes",void 0),(0,o._)([(0,a.MZ)({type:String,json:{read:{source:"attachmentsDefinitionExpression"},write:{target:"attachmentsDefinitionExpression"}}})],p.prototype,"attachmentsWhere",void 0),(0,o._)([(0,a.MZ)({type:Boolean,json:{write:!0}})],p.prototype,"cacheHint",void 0),(0,o._)([(0,a.MZ)({type:[String],json:{write:!0}})],p.prototype,"keywords",void 0),(0,o._)([(0,a.MZ)({type:[String],json:{write:!0}})],p.prototype,"globalIds",void 0),(0,o._)([(0,a.MZ)({json:{write:!0}})],p.prototype,"name",void 0),(0,o._)([(0,a.MZ)({type:Number,json:{read:{source:"resultRecordCount"}}})],p.prototype,"num",void 0),(0,o._)([(0,a.MZ)({type:[Number],json:{write:!0}})],p.prototype,"objectIds",void 0),(0,o._)([(0,a.MZ)({type:Boolean,json:{default:!1,write:!0}})],p.prototype,"returnMetadata",void 0),(0,o._)([(0,a.MZ)({type:[Number],json:{write:!0}})],p.prototype,"size",void 0),(0,o._)([(0,a.MZ)({type:Number,json:{read:{source:"resultOffset"}}})],p.prototype,"start",void 0),(0,o._)([(0,c.K)("start"),(0,c.K)("num")],p.prototype,"writeStart",null),(0,o._)([(0,a.MZ)({type:String,json:{read:{source:"definitionExpression"},write:{target:"definitionExpression"}}})],p.prototype,"where",void 0),p=n=(0,o._)([(0,u.$)("esri.rest.support.AttachmentQuery")],p),p.from=(0,l.dp)(p);const d=p},26591:(e,t,r)=>{r.r(t),r.d(t,{default:()=>h});var n,o=r(90237),i=(r(59456),r(25482)),s=r(4718),a=r(10107),l=r(56507),u=r(40608),c=r(43937),p=r(27733),d=r(16930);let y=n=class extends i.oY{constructor(e){super(e),this.cacheHint=void 0,this.dynamicDataSource=void 0,this.gdbVersion=null,this.geometryPrecision=void 0,this.historicMoment=null,this.maxAllowableOffset=void 0,this.objectIds=null,this.orderByFields=null,this.outFields=null,this.outSpatialReference=null,this.relationshipId=void 0,this.start=void 0,this.num=void 0,this.returnGeometry=!1,this.returnM=void 0,this.returnZ=void 0,this.where=null}_writeHistoricMoment(e,t){t.historicMoment=e&&e.getTime()}writeStart(e,t){t.resultOffset=this.start,t.resultRecordCount=this.num||10,this.start>0&&null==this.where&&(t.definitionExpression="1=1")}clone(){return new n((0,s.o8)({cacheHint:this.cacheHint,dynamicDataSource:this.dynamicDataSource,gdbVersion:this.gdbVersion,geometryPrecision:this.geometryPrecision,historicMoment:this.historicMoment&&new Date(this.historicMoment.getTime()),maxAllowableOffset:this.maxAllowableOffset,objectIds:this.objectIds,orderByFields:this.orderByFields,outFields:this.outFields,outSpatialReference:this.outSpatialReference,relationshipId:this.relationshipId,start:this.start,num:this.num,returnGeometry:this.returnGeometry,where:this.where,returnZ:this.returnZ,returnM:this.returnM}))}};(0,o._)([(0,a.MZ)({type:Boolean,json:{write:!0}})],y.prototype,"cacheHint",void 0),(0,o._)([(0,a.MZ)({type:p.L,json:{write:!0}})],y.prototype,"dynamicDataSource",void 0),(0,o._)([(0,a.MZ)({type:String,json:{write:!0}})],y.prototype,"gdbVersion",void 0),(0,o._)([(0,a.MZ)({type:Number,json:{write:!0}})],y.prototype,"geometryPrecision",void 0),(0,o._)([(0,a.MZ)({type:Date})],y.prototype,"historicMoment",void 0),(0,o._)([(0,c.K)("historicMoment")],y.prototype,"_writeHistoricMoment",null),(0,o._)([(0,a.MZ)({type:Number,json:{write:!0}})],y.prototype,"maxAllowableOffset",void 0),(0,o._)([(0,a.MZ)({json:{write:!0}})],y.prototype,"objectIds",void 0),(0,o._)([(0,a.MZ)({type:[String],json:{write:!0}})],y.prototype,"orderByFields",void 0),(0,o._)([(0,a.MZ)({type:[String],json:{write:!0}})],y.prototype,"outFields",void 0),(0,o._)([(0,a.MZ)({type:d.A,json:{read:{source:"outSR"},write:{target:"outSR"}}})],y.prototype,"outSpatialReference",void 0),(0,o._)([(0,a.MZ)({json:{write:!0}})],y.prototype,"relationshipId",void 0),(0,o._)([(0,a.MZ)({type:Number,json:{read:{source:"resultOffset"}}})],y.prototype,"start",void 0),(0,o._)([(0,c.K)("start"),(0,c.K)("num")],y.prototype,"writeStart",null),(0,o._)([(0,a.MZ)({type:Number,json:{read:{source:"resultRecordCount"}}})],y.prototype,"num",void 0),(0,o._)([(0,a.MZ)({json:{write:!0}})],y.prototype,"returnGeometry",void 0),(0,o._)([(0,a.MZ)({type:Boolean,json:{write:{overridePolicy:e=>({enabled:e})}}})],y.prototype,"returnM",void 0),(0,o._)([(0,a.MZ)({type:Boolean,json:{write:{overridePolicy:e=>({enabled:e})}}})],y.prototype,"returnZ",void 0),(0,o._)([(0,a.MZ)({type:String,json:{read:{source:"definitionExpression"},write:{target:"definitionExpression"}}})],y.prototype,"where",void 0),y=n=(0,o._)([(0,u.$)("esri.rest.support.RelationshipQuery")],y),y.from=(0,l.dp)(y);const h=y},30291:(e,t,r)=>{r.d(t,{tn:()=>u});var n=r(13874),o=r(30524),i=r(28122),s=(r(84424),r(80737),r(96808),r(66159)),a=(r(67336),r(92094),r(23721),r(70696),r(41227)),l=r(68780);function u({displayField:e,editFieldsInfo:t,fields:r,objectIdField:l,title:u},y){if(!r)return null;const f=function(e,t){const r=t?.visibleFieldNames;return function({fields:e,ignoreFieldTypes:t,sortDisabled:r}){const n=e;return t&&(e=e.filter((e=>!t.includes(e.type)))),e===n&&(e=e.slice()),!0!==r&&e.sort(p),e}({fields:e.fields??[],ignoreFieldTypes:t?.ignoreFieldTypes||h,sortDisabled:t?.sortDisabled}).map((t=>new a.A({fieldName:t.name,isEditable:(0,o.R$)(t,e),label:t.alias,format:d(t),visible:c(t,{...e,visibleFieldNames:r})})))}({editFieldsInfo:t,fields:r,objectIdField:l},y);if(!f.length)return null;const m=function(e){const t=(0,o.mB)(e),{titleBase:r}=e;return t?`${r}: {${t.trim()}}`:r??""}({titleBase:u,fields:r,displayField:e}),b=[new s.A,new i.A];return new n.A({title:m,content:b,fieldInfos:f})}const c=(e,t)=>t.visibleFieldNames?t.visibleFieldNames.has(e.name):(0,o.Bz)(e,t);function p(e,t){return"oid"===e.type?-1:"oid"===t.type?1:y(e)?-1:y(t)?1:(e.alias||e.name).toLocaleLowerCase().localeCompare((t.alias||t.name).toLocaleLowerCase())}function d(e){switch(e.type){case"small-integer":case"integer":case"single":return new l.A({digitSeparator:!0,places:0});case"double":return new l.A({digitSeparator:!0,places:2});case"string":return(0,o.JL)(e.name)?new l.A({digitSeparator:!0,places:0}):void 0;default:return}}function y(e){if("name"===(e.name&&e.name.toLowerCase()))return!0;const t=e.alias?.toLowerCase();return"name"===t}const h=["geometry","blob","raster","guid","xml"]}}]);