@arcgis/core 4.30.1 → 4.30.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.
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import"../../geometry.js";import{id as e}from"../../kernel.js";import o from"../../request.js";import{isSome as i}from"../../core/arrayUtils.js";import r from"../../core/Collection.js";import s from"../../core/Error.js";import{JSONMap as a}from"../../core/jsonMap.js";import{clone as l}from"../../core/lang.js";import n from"../../core/Loadable.js";import{isAbortError as p}from"../../core/promiseUtils.js";import{watch as m,initial as u}from"../../core/reactiveUtils.js";import{createScreenPoint as h}from"../../core/screenUtils.js";import{unitType as c,convertUnit as d,getMetersPerUnitForSR as y,inchesPerMeter as f}from"../../core/unitUtils.js";import{property as v}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as w}from"../../core/accessorSupport/decorators/subclass.js";import{formatDate as T,convertDateFormatToIntlOptions as I}from"../../intl/date.js";import{getLanguage as _}from"../../intl/locale.js";import g from"../../portal/Portal.js";import O from"../../portal/PortalQueryParams.js";import{reArcGISOnlineDomain as b}from"../../portal/support/urlUtils.js";import{execute as P}from"../../rest/geoprocessor/execute.js";import{submitJob as x}from"../../rest/geoprocessor/submitJob.js";import{execute as S,getTasks as L,getMode as j}from"../../rest/print.js";import{fromJSON as E}from"../../rest/support/fileFormat.js";import{fromJSON as U}from"../../rest/support/layoutTemplate.js";import k from"../../rest/support/PrintParameters.js";import C from"../../rest/support/PrintTemplate.js";import{getExtent as H}from"../../views/2d/viewpointUtils.js";import{ViewEventPriorities as F}from"../../views/input/InputManager.js";import A from"../../views/overlay/BoxOverlayItem.js";import D from"./CustomTemplate.js";import M from"./TemplateOptions.js";import W from"../../geometry/Extent.js";const N=new Set(["GISProfessionalStdUT","GISProfessionalAdvUT"]),z=/(\/GPServer\/).+/i,V=new a({inch:"inches",foot:"feet",yard:"yards",mile:"miles","nautical-mile":"nautical-miles",millimeter:"millimeters",centimeter:"centimeters",decimeter:"decimeters",meter:"meters",kilometer:"kilometers"}),q=r.ofType(D);function G(t){t.layoutOptions??={},t.layoutOptions.customTextElements??=[];const e="date";if(!t.layoutOptions.customTextElements.find((t=>e in t))){const{customTextElements:e}=t.layoutOptions;let o=T(Date.now(),I("short-date"));"ar"===_()&&(o="‏"+o),e.push({date:o})}}let J=class extends n{constructor(t){super(t),this._serviceTemplateCustomTextElements=null,this._layoutToTemplateInfo=new Map,this._isFreeHand=!1,this._freeHandWidth=0,this._freehandHeight=0,this._asyncPrintTaskUrl=null,this._layoutInfoTaskUrl=null,this.allowedFormats="all",this.allowedLayouts="all",this.browseTemplates=new q,this.defaultTemplates=new q,this.error=null,this.extraParameters=null,this.includeDefaultTemplates=!0,this.portal=g.getDefault(),this.portalTemplateIds=[],this.showPrintAreaEnabled=!1,this.printServiceUrl=null,this.printTimeout=12e4,this.templatesInfo=null,this.updateDelay=1e3,this.view=null,this.templateCustomTextElements=null,this.templateOptions=new M}initialize(){this.addHandles(m((()=>this.showPrintAreaEnabled),(t=>{t?this._enablePrintPreview():(this.removeHandles("overlay-handler"),this.view?.overlay?.removeItem(this._getOverlayItem()))})))}destroy(){this.removeHandles("overlay-handler"),this.view&&(this._overlayItem&&(this.view.overlay?.removeItem(this._overlayItem),this._overlayItem.destroy(),this._overlayItem=null),this.view=null)}get effectivePrintServiceUrl(){return this.printServiceUrl??null}get effectiveTemplateCustomTextElements(){if(!this._serviceTemplateCustomTextElements)return{};const t=l(this._serviceTemplateCustomTextElements);return this.templateCustomTextElements&&Object.keys(this.templateCustomTextElements).forEach((e=>{const o=t[e];if(o){const t=this.templateCustomTextElements?.[e];o.forEach((e=>{const[o]=Object.entries(e)[0];t?.forEach((t=>{const[i,r]=Object.entries(t)[0];o===i&&(e[o]=r)}))}))}})),Object.freeze(t)}get layoutTemplateInfo(){const t=this.templateOptions.layoutItem?.id??this.templateOptions.layout;return t?this._layoutToTemplateInfo.get(t):null}get state(){return"loading"===this.loadStatus?"initializing":"failed"===this.loadStatus||this.error?"error":"loaded"===this.loadStatus&&this.view?.ready?"ready":"disabled"}get layoutTemplateNorthArrowInfo(){return this.layoutTemplateInfo?.layoutOptions?.mapSurroundInfos?this.layoutTemplateInfo.layoutOptions.mapSurroundInfos.find((t=>"CIMMarkerNorthArrow"===t.type)):null}async load(t){return this.addResolvingPromise(this._loadResources(t).catch((t=>this.error=t))),this}async print(t){const{view:e,extraParameters:o,updateDelay:i}=this;if(!e)throw new s("print:view-required","view is not set");G(t);const r=this._getOverlayItem(),a=t.scalePreserved||!this.showPrintAreaEnabled?void 0:H(new W,e.viewpoint,"MAP_ONLY"===t.layout?[t.exportOptions.width,t.exportOptions.height]:[r.boxWidth,r.boxHeight]),l=new k({view:e,template:t,extent:a,extraParameters:o,updateDelay:i});try{const e=!!t.layoutItem?.id&&(this.portalTemplateIds.includes(t.layoutItem.id)||this.browseTemplates.some((e=>e.layoutItem?.id===t.layoutItem?.id)));return await S(e&&this._asyncPrintTaskUrl?this._asyncPrintTaskUrl:this.effectivePrintServiceUrl,l,{timeout:this.printTimeout})}catch(n){throw new s("print:export-error","An error occurred while exporting the web map.",{error:n})}}toPrintTemplate({attributionEnabled:t,author:e,copyright:o,customTextElements:i,dpi:r,forceFeatureAttributes:a,format:l,height:n,includeTables:p,layout:m,layoutItem:u,legendEnabled:h,northArrowEnabled:c,scale:d,scaleEnabled:y,title:f,width:v}){if(!m)throw new s("print:layout-required","layout is not set");const w=new C({attributionVisible:t,forceFeatureAttributes:a,format:l,includeTables:p,layout:m,layoutItem:u,layoutOptions:{authorText:e||"",copyrightText:o||"",customTextElements:i,titleText:f||""},outScale:d??0,scalePreserved:y});v&&(w.exportOptions.width=v),n&&(w.exportOptions.height=n),r&&(w.exportOptions.dpi=r),!h&&w.layoutOptions&&(w.layoutOptions.legendLayers=[]);const T=this.layoutTemplateNorthArrowInfo;if(T){!(T.visible===c)&&w.layoutOptions&&(w.layoutOptions.elementOverrides={[T.name]:{visible:c}})}return w}async fetchLayoutTemplateInfo(t,e){if(!t.layoutItem?.id)return;const o=await this._fetchPortalLayoutTemplateInfo(t.layoutItem,e);this._layoutToTemplateInfo.set(t.layoutItem.id,o),t.layoutTemplateInfo=o;const{hasLegend:i,mapSurroundInfos:r,customTextElements:s}=o.layoutOptions,a=r.some((({type:t,visible:e})=>"CIMMarkerNorthArrow"===t&&e));t.layoutOptions={legend:i,northArrow:a};const n=l(this._serviceTemplateCustomTextElements)??{};n[t.layoutItem.id]=s,this._serviceTemplateCustomTextElements=Object.freeze(n)}getLayoutTemplateInfo(t){return this._layoutToTemplateInfo.get(t)}async addPortalTemplate(t){const e=new D({label:t.title,layoutItem:t});this.browseTemplates.add(e)}removePortalTemplate(t){t.layoutItem?.id&&this.templateOptions.layoutItem?.id===t.layoutItem.id&&(this.templateOptions.layout=this.defaultTemplates.length||this.browseTemplates.length?null:this.templatesInfo?.layout?.defaultValue,this.templateOptions.layoutItem=null),this._layoutToTemplateInfo.delete(t.layoutItem.id),this.browseTemplates.remove(t)}async _loadResources(t){let e=[];if(this.printServiceUrl)this._set("effectivePrintServiceUrl",this.printServiceUrl),await this._updateLayoutInfoTaskUrl(this.effectivePrintServiceUrl);else{if(this.destroyed)return;try{await this.portal.load(t)}catch(l){throw new s("print:could-not-load-portal","Cannot load print resource information from portal",{error:l,url:this.effectivePrintServiceUrl})}if(this.portal.helperServices){const{asyncPrintTask:t,layoutInfoTask:o,printTask:i}=this.portal.helperServices;i&&(this._set("effectivePrintServiceUrl",i.url),e=i.templates?.map((t=>D.fromJSON(t)))??[]),this._asyncPrintTaskUrl=t?.url,await this._updateLayoutInfoTaskUrl(o?.url||this.effectivePrintServiceUrl)}}this.defaultTemplates.addMany(e);const o=this.effectivePrintServiceUrl?.toLowerCase().split("/");if(!o?.includes("gpserver"))throw new s("print:invalid-print-service-url","Can't fetch print templates information from provided URL",{url:this.effectivePrintServiceUrl});const[i,r,a]=await Promise.all([this._getPrintServiceLayouts(t),this._getPrintServiceTemplates(t),this._getPortalCustomTemplates(t)]);if(this._processPrintServiceLayouts(i),this._processPrintServiceTemplates(r),this._processPortalTemplates(a),this.templateOptions.layoutItem?.id){const e=this.templateOptions.layoutItem.id;let o=this.defaultTemplates.find((t=>t.layoutItem?.id===e));o||(o=new D({label:this.templateOptions.layoutItem.title,layoutItem:this.templateOptions.layoutItem})),await this.fetchLayoutTemplateInfo(o,t),this.templateOptions.layout=e}this._updateOverLayItem()}async _updateLayoutInfoTaskUrl(t,e){if(!t)return;const o=(await L(t,e)).find((t=>t.includes("Get Layout Templates Info")));o&&(this._layoutInfoTaskUrl=t.replace(z,`$1${encodeURI(o)}`))}async _getPortalCustomTemplates(t){if(this.printServiceUrl||!this.portal)return[];const{layoutGroupQuery:e,user:o}=this.portal,i=b.test(this.portal.url),r=o?.userLicenseTypeId,s=r&&N.has(r);if(!e||i&&!s)return[];const a=new O({query:e,disableExtraQuery:!0}),l=await this.portal.queryGroups(a,t);if(!l.total)return[];const n=l.results[0],p=new O({num:100,query:"type:Layout",sortField:n.sortField,sortOrder:n.sortOrder??void 0}),m=(await n.queryItems(p,t)).results;return m.length?m.map((t=>new D({label:t.title,layoutItem:t}))):[]}async _fetchPortalLayoutTemplateInfo(t,o){const{id:i}=t,r=this._layoutInfoTaskUrl;if(!r)throw new s("print:invalid-layout-info-task-url","Can't fetch layout template info",{url:r});"public"!==t.access&&e&&await e.getCredential(r);const a={Layout_Item_ID:JSON.stringify({id:i})};return(await this._fetchLayoutTemplateInfos(a,o))[0]}async _fetchLayoutTemplateInfos(t,e){const o=this._layoutInfoTaskUrl;if(!o)throw new s("print:invalid-layout-info-task-url","Can't fetch layout template info",{url:o});if("async"===await j(o)){const i=await x(o,t,void 0,e||void 0);await i.waitForJobCompletion({interval:1e3});return(await i.fetchResultData("Output_JSON")).value}return(await P(o,t,null,e)).results[0].value}_processPortalTemplates(t){if(t){this.defaultTemplates.addMany(t);for(const e of t)e.layoutItem?.id&&this.portalTemplateIds.push(e.layoutItem.id)}}_processPrintServiceTemplates(t){this._set("templatesInfo",t)}async _getPrintServiceLayouts(t){let e=[];try{e=await this._fetchLayoutTemplateInfos(void 0,t)}catch{}return e}_processPrintServiceLayouts(t){const e={};for(const o of t){const{layoutTemplate:t,layoutOptions:i}=o,r=U(t);this._layoutToTemplateInfo.set(r,o),e[r]=i.customTextElements}this._serviceTemplateCustomTextElements=Object.freeze(e)}async _getPrintServiceTemplates(t){let e;try{({data:e}=await o(this.effectivePrintServiceUrl,{...t,query:{f:"json"},timeout:this.printTimeout}))}catch(l){throw p(l)?l:new s("print:unavailable-service-info","Can't fetch templates info from service",{error:l})}const{parameters:i}=e,r=i.find((({name:t})=>"Format"===t)),a=i.find((({name:t})=>"Layout_Template"===t));return{format:this._getFormat(r),layout:this._getLayout(a)}}_getFormat(t){const e="all"===this.allowedFormats?t.choiceList:t.choiceList.filter((t=>this.allowedFormats.includes(E(t)))),o=(e.length?e:t.choiceList).map(E).filter(i),r=E(t.defaultValue),s=o.includes(r)?r:o[0];return{choiceList:o,defaultValue:s}}_getLayout(t){const e=t.choiceList.filter((t=>"map_only"!==t.toLowerCase())),o="all"===this.allowedLayouts?e:e.filter((t=>this.allowedLayouts.includes(U(t)))),r=(o.length?o:e).map(U).filter(i),s=U(t.defaultValue),a=r.includes(s)?s:r.find((t=>/(?=.*letter)(?=.*landscape)/i.test(t)))??r.find((t=>/(?=.*a4)(?=.*landscape)/i.test(t)))??r[0];return{choiceList:r,defaultValue:a}}_getOverlayItem(){return this._overlayItem||(this._overlayItem=new A({strokeDash:[5],strokeWidth:2,strokeColor:[30,144,255,255]})),this._overlayItem}_enablePrintPreview(){if(!this.view?.overlay)return;const t=this.templateOptions,e=this._getOverlayItem();this.addHandles([m((()=>[t.width,t.height,t.scaleEnabled,t.scale,t.layout,t.layoutItem,this.view?.scale,this.view?.size,this.view?.state.paddedViewState.size,this.view?.state.padding]),(()=>this._updateOverLayItem()),u),this.view?.on("drag",["Shift"],(t=>this._handleDrag(t)),F.WIDGET),this.view?.on("key-down",["Escape"],(()=>this._resetDrag()),F.WIDGET)],"overlay-handler"),this.view.overlay.addItem(e)}_updateOverLayItem(){if(!this.view)return;const t=this.templateOptions,e=this._getOverlayItem(),o=t.layoutItem?.id??t.layout,i=this.view,r=i.spatialReference,[s,a]=i.state.paddedViewState.size,l=i.state.padding;let n=0,p=0;if("MAP_ONLY"===o)null!=t.width&&null!=t.height&&(n=t.width,p=t.height);else if(o){const{webMapFrameSize:e,pageUnits:i}=this._layoutToTemplateInfo.get(o)??{};let l=!1;if(e&&i)if(this._isFreeHand){const t=e[0]/e[1];n=this._freeHandWidth,p=this._freehandHeight,n>p?p=n/t:n=p*t}else{const t=V.fromJSON(i.toLowerCase()),o=r.unit;c(t)===c(o)?(n=d(e[0],t,o),p=d(e[1],t,o)):(l=!0,n=e[0],p=e[1])}if(!this._isFreeHand)if(t.scaleEnabled&&t.scale){const e=l?Math.min(s/n,a/p):y(r)*f*t.dpi;n*=e,p*=e}else if(0===n||0===p)n=s,p=a;else{const t=(s-.1*s)/n,e=(a-.1*a)/p,o=Math.min(t,e);n*=o,p*=o}}const{scaleEnabled:m,scale:u}=t,h=m&&u?u/this.view.scale:1;e.boxWidth=n*h||s,e.boxHeight=p*h||a,l&&(e.padding=l),e.backgroundWidth=s??0,e.backgroundHeight=a??0}_resetDrag(){this._isFreeHand=!1,this._updateOverLayItem()}_handleDrag(t){switch(t.action){case"start":this._start();break;case"update":this._update(t);break;case"end":this._end()}t.stopPropagation()}_start(){this._isFreeHand=!0}_update(t){const e=this._getOverlayItem(),{x:o,y:i}=t,{x:r,y:s}=t.origin;o>r?(e.x=r,e.boxWidth=o-r):(e.x=o,e.boxWidth=r-o),i>s?(e.y=s,e.boxHeight=i-s):(e.y=i,e.boxHeight=s-i)}_end(){const t=this._getOverlayItem();if(!this.view||null==t.x||null==t.y)return;const e=this.view,o=e.toMap(h(t.x+.5*t.boxWidth,t.y+.5*t.boxHeight));t.x=null,t.y=null,e.goTo({center:o}),this._freeHandWidth=t.boxWidth,this._freehandHeight=t.boxHeight,"MAP_ONLY"===this.templateOptions.layout&&(this.templateOptions.width=this._freeHandWidth,this.templateOptions.height=this._freehandHeight),this.templateOptions.scale=this.view.scale,this._updateOverLayItem()}};t([v()],J.prototype,"_serviceTemplateCustomTextElements",void 0),t([v()],J.prototype,"_layoutToTemplateInfo",void 0),t([v()],J.prototype,"allowedFormats",void 0),t([v()],J.prototype,"allowedLayouts",void 0),t([v({type:q})],J.prototype,"browseTemplates",void 0),t([v({type:q})],J.prototype,"defaultTemplates",void 0),t([v()],J.prototype,"error",void 0),t([v()],J.prototype,"extraParameters",void 0),t([v()],J.prototype,"includeDefaultTemplates",void 0),t([v({readOnly:!0})],J.prototype,"effectivePrintServiceUrl",null),t([v()],J.prototype,"effectiveTemplateCustomTextElements",null),t([v()],J.prototype,"layoutTemplateInfo",null),t([v({type:g})],J.prototype,"portal",void 0),t([v()],J.prototype,"portalTemplateIds",void 0),t([v()],J.prototype,"showPrintAreaEnabled",void 0),t([v()],J.prototype,"printServiceUrl",void 0),t([v()],J.prototype,"printTimeout",void 0),t([v({readOnly:!0})],J.prototype,"state",null),t([v({readOnly:!0})],J.prototype,"templatesInfo",void 0),t([v()],J.prototype,"updateDelay",void 0),t([v()],J.prototype,"view",void 0),t([v()],J.prototype,"templateCustomTextElements",void 0),t([v({type:M})],J.prototype,"templateOptions",void 0),t([v()],J.prototype,"layoutTemplateNorthArrowInfo",null),J=t([w("esri.widgets.Print.PrintViewModel")],J);const R=J;export{R as default};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import"../../geometry.js";import{id as e}from"../../kernel.js";import o from"../../request.js";import{isSome as i}from"../../core/arrayUtils.js";import r from"../../core/Collection.js";import s from"../../core/Error.js";import{JSONMap as a}from"../../core/jsonMap.js";import{clone as l}from"../../core/lang.js";import n from"../../core/Loadable.js";import{isAbortError as p}from"../../core/promiseUtils.js";import m from"../../core/ReactiveMap.js";import{watch as u,initial as h}from"../../core/reactiveUtils.js";import{createScreenPoint as c}from"../../core/screenUtils.js";import{unitType as d,convertUnit as y,getMetersPerUnitForSR as f,inchesPerMeter as v}from"../../core/unitUtils.js";import{property as w}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as T}from"../../core/accessorSupport/decorators/subclass.js";import{formatDate as I,convertDateFormatToIntlOptions as _}from"../../intl/date.js";import{getLanguage as g}from"../../intl/locale.js";import O from"../../portal/Portal.js";import b from"../../portal/PortalQueryParams.js";import{reArcGISOnlineDomain as P}from"../../portal/support/urlUtils.js";import{execute as x}from"../../rest/geoprocessor/execute.js";import{submitJob as S}from"../../rest/geoprocessor/submitJob.js";import{execute as L,getTasks as j,getMode as E}from"../../rest/print.js";import{fromJSON as U}from"../../rest/support/fileFormat.js";import{fromJSON as k}from"../../rest/support/layoutTemplate.js";import C from"../../rest/support/PrintParameters.js";import H from"../../rest/support/PrintTemplate.js";import{getExtent as F}from"../../views/2d/viewpointUtils.js";import{ViewEventPriorities as A}from"../../views/input/InputManager.js";import D from"../../views/overlay/BoxOverlayItem.js";import M from"./CustomTemplate.js";import W from"./TemplateOptions.js";import N from"../../geometry/Extent.js";const z=new Set(["GISProfessionalStdUT","GISProfessionalAdvUT"]),V=/(\/GPServer\/).+/i,q=new a({inch:"inches",foot:"feet",yard:"yards",mile:"miles","nautical-mile":"nautical-miles",millimeter:"millimeters",centimeter:"centimeters",decimeter:"decimeters",meter:"meters",kilometer:"kilometers"}),G=r.ofType(M);function R(t){t.layoutOptions??={},t.layoutOptions.customTextElements??=[];const e="date";if(!t.layoutOptions.customTextElements.find((t=>e in t))){const{customTextElements:e}=t.layoutOptions;let o=I(Date.now(),_("short-date"));"ar"===g()&&(o="‏"+o),e.push({date:o})}}let J=class extends n{constructor(t){super(t),this._serviceTemplateCustomTextElements=null,this._layoutToTemplateInfo=new m,this._isFreeHand=!1,this._freeHandWidth=0,this._freehandHeight=0,this._asyncPrintTaskUrl=null,this._layoutInfoTaskUrl=null,this.allowedFormats="all",this.allowedLayouts="all",this.browseTemplates=new G,this.defaultTemplates=new G,this.error=null,this.extraParameters=null,this.includeDefaultTemplates=!0,this.portal=O.getDefault(),this.portalTemplateIds=[],this.showPrintAreaEnabled=!1,this.printServiceUrl=null,this.printTimeout=12e4,this.templatesInfo=null,this.updateDelay=1e3,this.view=null,this.templateCustomTextElements=null,this.templateOptions=new W}initialize(){this.addHandles(u((()=>this.showPrintAreaEnabled),(t=>{t?this._enablePrintPreview():(this.removeHandles("overlay-handler"),this.view?.overlay?.removeItem(this._getOverlayItem()))})))}destroy(){this.removeHandles("overlay-handler"),this.view&&(this._overlayItem&&(this.view.overlay?.removeItem(this._overlayItem),this._overlayItem.destroy(),this._overlayItem=null),this.view=null)}get effectivePrintServiceUrl(){return this.printServiceUrl??null}get effectiveTemplateCustomTextElements(){if(!this._serviceTemplateCustomTextElements)return{};const t=l(this._serviceTemplateCustomTextElements);return this.templateCustomTextElements&&Object.keys(this.templateCustomTextElements).forEach((e=>{const o=t[e];if(o){const t=this.templateCustomTextElements?.[e];o.forEach((e=>{const[o]=Object.entries(e)[0];t?.forEach((t=>{const[i,r]=Object.entries(t)[0];o===i&&(e[o]=r)}))}))}})),Object.freeze(t)}get layoutTemplateInfo(){const t=this.templateOptions.layoutItem?.id??this.templateOptions.layout;return t?this._layoutToTemplateInfo.get(t):null}get state(){return"loading"===this.loadStatus?"initializing":"failed"===this.loadStatus||this.error?"error":"loaded"===this.loadStatus&&this.view?.ready?"ready":"disabled"}get layoutTemplateNorthArrowInfo(){return this.layoutTemplateInfo?.layoutOptions?.mapSurroundInfos?this.layoutTemplateInfo.layoutOptions.mapSurroundInfos.find((t=>"CIMMarkerNorthArrow"===t.type)):null}async load(t){return this.addResolvingPromise(this._loadResources(t).catch((t=>this.error=t))),this}async print(t){const{view:e,extraParameters:o,updateDelay:i}=this;if(!e)throw new s("print:view-required","view is not set");R(t);const r=this._getOverlayItem(),a=t.scalePreserved||!this.showPrintAreaEnabled?void 0:F(new N,e.viewpoint,"MAP_ONLY"===t.layout?[t.exportOptions.width,t.exportOptions.height]:[r.boxWidth,r.boxHeight]),l=new C({view:e,template:t,extent:a,extraParameters:o,updateDelay:i});try{const e=!!t.layoutItem?.id&&(this.portalTemplateIds.includes(t.layoutItem.id)||this.browseTemplates.some((e=>e.layoutItem?.id===t.layoutItem?.id)));return await L(e&&this._asyncPrintTaskUrl?this._asyncPrintTaskUrl:this.effectivePrintServiceUrl,l,{timeout:this.printTimeout})}catch(n){throw new s("print:export-error","An error occurred while exporting the web map.",{error:n})}}toPrintTemplate({attributionEnabled:t,author:e,copyright:o,customTextElements:i,dpi:r,forceFeatureAttributes:a,format:l,height:n,includeTables:p,layout:m,layoutItem:u,legendEnabled:h,northArrowEnabled:c,scale:d,scaleEnabled:y,title:f,width:v}){if(!m)throw new s("print:layout-required","layout is not set");const w=new H({attributionVisible:t,forceFeatureAttributes:a,format:l,includeTables:p,layout:m,layoutItem:u,layoutOptions:{authorText:e||"",copyrightText:o||"",customTextElements:i,titleText:f||""},outScale:d??0,scalePreserved:y});v&&(w.exportOptions.width=v),n&&(w.exportOptions.height=n),r&&(w.exportOptions.dpi=r),!h&&w.layoutOptions&&(w.layoutOptions.legendLayers=[]);const T=this.layoutTemplateNorthArrowInfo;if(T){!(T.visible===c)&&w.layoutOptions&&(w.layoutOptions.elementOverrides={[T.name]:{visible:c}})}return w}async fetchLayoutTemplateInfo(t,e){if(!t.layoutItem?.id)return;const o=await this._fetchPortalLayoutTemplateInfo(t.layoutItem,e);this._layoutToTemplateInfo.set(t.layoutItem.id,o),t.layoutTemplateInfo=o;const{hasLegend:i,mapSurroundInfos:r,customTextElements:s}=o.layoutOptions,a=r.some((({type:t,visible:e})=>"CIMMarkerNorthArrow"===t&&e));t.layoutOptions={legend:i,northArrow:a};const n=l(this._serviceTemplateCustomTextElements)??{};n[t.layoutItem.id]=s,this._serviceTemplateCustomTextElements=Object.freeze(n)}getLayoutTemplateInfo(t){return this._layoutToTemplateInfo.get(t)}async addPortalTemplate(t){const e=new M({label:t.title,layoutItem:t});this.browseTemplates.add(e)}removePortalTemplate(t){t.layoutItem?.id&&this.templateOptions.layoutItem?.id===t.layoutItem.id&&(this.templateOptions.layout=this.defaultTemplates.length||this.browseTemplates.length?null:this.templatesInfo?.layout?.defaultValue,this.templateOptions.layoutItem=null),this._layoutToTemplateInfo.delete(t.layoutItem.id),this.browseTemplates.remove(t)}async _loadResources(t){let e=[];if(this.printServiceUrl)this._set("effectivePrintServiceUrl",this.printServiceUrl),await this._updateLayoutInfoTaskUrl(this.effectivePrintServiceUrl);else{if(this.destroyed)return;try{await this.portal.load(t)}catch(l){throw new s("print:could-not-load-portal","Cannot load print resource information from portal",{error:l,url:this.effectivePrintServiceUrl})}if(this.portal.helperServices){const{asyncPrintTask:t,layoutInfoTask:o,printTask:i}=this.portal.helperServices;i&&(this._set("effectivePrintServiceUrl",i.url),e=i.templates?.map((t=>M.fromJSON(t)))??[]),this._asyncPrintTaskUrl=t?.url,await this._updateLayoutInfoTaskUrl(o?.url||this.effectivePrintServiceUrl)}}this.defaultTemplates.addMany(e);const o=this.effectivePrintServiceUrl?.toLowerCase().split("/");if(!o?.includes("gpserver"))throw new s("print:invalid-print-service-url","Can't fetch print templates information from provided URL",{url:this.effectivePrintServiceUrl});const[i,r,a]=await Promise.all([this._getPrintServiceLayouts(t),this._getPrintServiceTemplates(t),this._getPortalCustomTemplates(t)]);if(this._processPrintServiceLayouts(i),this._processPrintServiceTemplates(r),this._processPortalTemplates(a),this.templateOptions.layoutItem?.id){const e=this.templateOptions.layoutItem.id;let o=this.defaultTemplates.find((t=>t.layoutItem?.id===e));o||(o=new M({label:this.templateOptions.layoutItem.title,layoutItem:this.templateOptions.layoutItem})),await this.fetchLayoutTemplateInfo(o,t),this.templateOptions.layout=e}this._updateOverLayItem()}async _updateLayoutInfoTaskUrl(t,e){if(!t)return;const o=(await j(t,e)).find((t=>t.includes("Get Layout Templates Info")));o&&(this._layoutInfoTaskUrl=t.replace(V,`$1${encodeURI(o)}`))}async _getPortalCustomTemplates(t){if(this.printServiceUrl||!this.portal)return[];const{layoutGroupQuery:e,user:o}=this.portal,i=P.test(this.portal.url),r=o?.userLicenseTypeId,s=r&&z.has(r);if(!e||i&&!s)return[];const a=new b({query:e,disableExtraQuery:!0}),l=await this.portal.queryGroups(a,t);if(!l.total)return[];const n=l.results[0],p=new b({num:100,query:"type:Layout",sortField:n.sortField,sortOrder:n.sortOrder??void 0}),m=(await n.queryItems(p,t)).results;return m.length?m.map((t=>new M({label:t.title,layoutItem:t}))):[]}async _fetchPortalLayoutTemplateInfo(t,o){const{id:i}=t,r=this._layoutInfoTaskUrl;if(!r)throw new s("print:invalid-layout-info-task-url","Can't fetch layout template info",{url:r});"public"!==t.access&&e&&await e.getCredential(r);const a={Layout_Item_ID:JSON.stringify({id:i})};return(await this._fetchLayoutTemplateInfos(a,o))[0]}async _fetchLayoutTemplateInfos(t,e){const o=this._layoutInfoTaskUrl;if(!o)throw new s("print:invalid-layout-info-task-url","Can't fetch layout template info",{url:o});if("async"===await E(o)){const i=await S(o,t,void 0,e||void 0);await i.waitForJobCompletion({interval:1e3});return(await i.fetchResultData("Output_JSON")).value}return(await x(o,t,null,e)).results[0].value}_processPortalTemplates(t){if(t){this.defaultTemplates.addMany(t);for(const e of t)e.layoutItem?.id&&this.portalTemplateIds.push(e.layoutItem.id)}}_processPrintServiceTemplates(t){this._set("templatesInfo",t)}async _getPrintServiceLayouts(t){let e=[];try{e=await this._fetchLayoutTemplateInfos(void 0,t)}catch{}return e}_processPrintServiceLayouts(t){const e={};for(const o of t){const{layoutTemplate:t,layoutOptions:i}=o,r=k(t);this._layoutToTemplateInfo.set(r,o),e[r]=i.customTextElements}this._serviceTemplateCustomTextElements=Object.freeze(e)}async _getPrintServiceTemplates(t){let e;try{({data:e}=await o(this.effectivePrintServiceUrl,{...t,query:{f:"json"},timeout:this.printTimeout}))}catch(l){throw p(l)?l:new s("print:unavailable-service-info","Can't fetch templates info from service",{error:l})}const{parameters:i}=e,r=i.find((({name:t})=>"Format"===t)),a=i.find((({name:t})=>"Layout_Template"===t));return{format:this._getFormat(r),layout:this._getLayout(a)}}_getFormat(t){const e="all"===this.allowedFormats?t.choiceList:t.choiceList.filter((t=>this.allowedFormats.includes(U(t)))),o=(e.length?e:t.choiceList).map(U).filter(i),r=U(t.defaultValue),s=o.includes(r)?r:o[0];return{choiceList:o,defaultValue:s}}_getLayout(t){const e=t.choiceList.filter((t=>"map_only"!==t.toLowerCase())),o="all"===this.allowedLayouts?e:e.filter((t=>this.allowedLayouts.includes(k(t)))),r=(o.length?o:e).map(k).filter(i),s=k(t.defaultValue),a=r.includes(s)?s:r.find((t=>/(?=.*letter)(?=.*landscape)/i.test(t)))??r.find((t=>/(?=.*a4)(?=.*landscape)/i.test(t)))??r[0];return{choiceList:r,defaultValue:a}}_getOverlayItem(){return this._overlayItem||(this._overlayItem=new D({strokeDash:[5],strokeWidth:2,strokeColor:[30,144,255,255]})),this._overlayItem}_enablePrintPreview(){if(!this.view?.overlay)return;const t=this.templateOptions,e=this._getOverlayItem();this.addHandles([u((()=>[t.width,t.height,t.scaleEnabled,t.scale,t.layout,t.layoutItem,this.view?.scale,this.view?.size,this.view?.state.paddedViewState.size,this.view?.state.padding]),(()=>this._updateOverLayItem()),h),this.view?.on("drag",["Shift"],(t=>this._handleDrag(t)),A.WIDGET),this.view?.on("key-down",["Escape"],(()=>this._resetDrag()),A.WIDGET)],"overlay-handler"),this.view.overlay.addItem(e)}_updateOverLayItem(){if(!this.view)return;const t=this.templateOptions,e=this._getOverlayItem(),o=t.layoutItem?.id??t.layout,i=this.view,r=i.spatialReference,[s,a]=i.state.paddedViewState.size,l=i.state.padding;let n=0,p=0;if("MAP_ONLY"===o)null!=t.width&&null!=t.height&&(n=t.width,p=t.height);else if(o){const{webMapFrameSize:e,pageUnits:i}=this._layoutToTemplateInfo.get(o)??{};let l=!1;if(e&&i)if(this._isFreeHand){const t=e[0]/e[1];n=this._freeHandWidth,p=this._freehandHeight,n>p?p=n/t:n=p*t}else{const t=q.fromJSON(i.toLowerCase()),o=r.unit;d(t)===d(o)?(n=y(e[0],t,o),p=y(e[1],t,o)):(l=!0,n=e[0],p=e[1])}if(!this._isFreeHand)if(t.scaleEnabled&&t.scale){const e=l?Math.min(s/n,a/p):f(r)*v*t.dpi;n*=e,p*=e}else if(0===n||0===p)n=s,p=a;else{const t=(s-.1*s)/n,e=(a-.1*a)/p,o=Math.min(t,e);n*=o,p*=o}}const{scaleEnabled:m,scale:u}=t,h=m&&u?u/this.view.scale:1;e.boxWidth=n*h||s,e.boxHeight=p*h||a,l&&(e.padding=l),e.backgroundWidth=s??0,e.backgroundHeight=a??0}_resetDrag(){this._isFreeHand=!1,this._updateOverLayItem()}_handleDrag(t){switch(t.action){case"start":this._start();break;case"update":this._update(t);break;case"end":this._end()}t.stopPropagation()}_start(){this._isFreeHand=!0}_update(t){const e=this._getOverlayItem(),{x:o,y:i}=t,{x:r,y:s}=t.origin;o>r?(e.x=r,e.boxWidth=o-r):(e.x=o,e.boxWidth=r-o),i>s?(e.y=s,e.boxHeight=i-s):(e.y=i,e.boxHeight=s-i)}_end(){const t=this._getOverlayItem();if(!this.view||null==t.x||null==t.y)return;const e=this.view,o=e.toMap(c(t.x+.5*t.boxWidth,t.y+.5*t.boxHeight));t.x=null,t.y=null,e.goTo({center:o}),this._freeHandWidth=t.boxWidth,this._freehandHeight=t.boxHeight,"MAP_ONLY"===this.templateOptions.layout&&(this.templateOptions.width=this._freeHandWidth,this.templateOptions.height=this._freehandHeight),this.templateOptions.scale=this.view.scale,this._updateOverLayItem()}};t([w()],J.prototype,"_serviceTemplateCustomTextElements",void 0),t([w()],J.prototype,"_layoutToTemplateInfo",void 0),t([w()],J.prototype,"allowedFormats",void 0),t([w()],J.prototype,"allowedLayouts",void 0),t([w({type:G})],J.prototype,"browseTemplates",void 0),t([w({type:G})],J.prototype,"defaultTemplates",void 0),t([w()],J.prototype,"error",void 0),t([w()],J.prototype,"extraParameters",void 0),t([w()],J.prototype,"includeDefaultTemplates",void 0),t([w({readOnly:!0})],J.prototype,"effectivePrintServiceUrl",null),t([w()],J.prototype,"effectiveTemplateCustomTextElements",null),t([w()],J.prototype,"layoutTemplateInfo",null),t([w({type:O})],J.prototype,"portal",void 0),t([w()],J.prototype,"portalTemplateIds",void 0),t([w()],J.prototype,"showPrintAreaEnabled",void 0),t([w()],J.prototype,"printServiceUrl",void 0),t([w()],J.prototype,"printTimeout",void 0),t([w({readOnly:!0})],J.prototype,"state",null),t([w({readOnly:!0})],J.prototype,"templatesInfo",void 0),t([w()],J.prototype,"updateDelay",void 0),t([w()],J.prototype,"view",void 0),t([w()],J.prototype,"templateCustomTextElements",void 0),t([w({type:W})],J.prototype,"templateOptions",void 0),t([w()],J.prototype,"layoutTemplateNorthArrowInfo",null),J=t([T("esri.widgets.Print.PrintViewModel")],J);const Q=J;export{Q as default};
package/widgets/Print.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import t from"../core/Collection.js";import{JSONMap as l}from"../core/jsonMap.js";import{clone as i}from"../core/lang.js";import{watch as a}from"../core/reactiveUtils.js";import{unitName as o}from"../core/unitFormatUtils.js";import{addProxy as n,hasSameOrigin as s}from"../core/urlUtils.js";import{property as r}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import{subclass as c}from"../core/accessorSupport/decorators/subclass.js";import{reArcGISOnlineDomain as p}from"../portal/support/urlUtils.js";import{getToken as d}from"../rest/utils.js";import{toJSON as u}from"../rest/support/fileFormat.js";import m from"./Widget.js";import h from"./Print/FileLink.js";import b from"./Print/PrintViewModel.js";import{loadCalciteComponents as y}from"./support/componentsUtils.js";import{globalCss as _}from"./support/globalCss.js";import{Heading as f}from"./support/Heading.js";import{legacyIcon as g}from"./support/legacyIcon.js";import{isRTL as v,isActivationKey as w}from"./support/widgetUtils.js";import{messageBundle as T}from"./support/decorators/messageBundle.js";import{tsx as x}from"./support/jsxFactory.js";import{formatNumber as C}from"../intl/number.js";const O=t.ofType(h),I="MAP_ONLY";var k;!function(e){e.layout="layoutTab",e.mapOnly="mapOnlyTab",e.export="exportTab"}(k||(k={}));const $="esri-print",L=`${$}__advanced-options-button`,S={base:$,headerTitle:`${$}__header-title`,layoutTabList:`${$}__layout-tab-list`,layoutTab:`${$}__layout-tab`,layoutSection:`${$}__layout-section`,mapOnlySection:`${$}__map-only-section`,panelItemsCentered:`${$}__panel-items--centered`,loader:`${$}__loader`,advancedOptionsButton:L,advancedOptionsButtonContainer:`${L}-container`,advancedOptionsButtonTitle:`${L}-title`,advancedOptionsButtonIconOpened:`${L}-icon--opened`,advancedOptionsButtonIconClosed:`${L}-icon--closed`,advancedOptionsButtonIconClosed_RTL:`${L}-icon--closed-rtl`,swapButton:`${$}__swap-button`,printButton:`${$}__export-button`,templateSelectContainer:`${$}__template-select-container`,templateSelectBlock:`${$}__template-select-block`,templateSelectIcon:`${$}__template-select-icon`,formSectionContainer:`${$}__form-section-container`,formCheckboxLabel:`${$}__form-checkbox-label`,advancedOptionsSection:`${$}__advanced-options-section`,advancedOptionsContainer:`${$}__advanced-options-container`,browseTemplateButtonContainer:`${$}__browse-template-button-container`,exportedFilesContainer:`${$}__export-panel-container`,exportedFilesTitle:`${$}__export-title`,exportedFile:`${$}__exported-file`,exportedFileLink:`${$}__exported-file-link`,exportedFileLinkTitle:`${$}__exported-file-link-title`,exportedFilesEmpty:`${$}__exported-files-empty`,printWidgetContainer:`${$}__container`,content:`${$}__content`,panelContainer:`${$}__panel-container`,scaleInfoContainer:`${$}__scale-info-container`,scaleInputContainer:`${$}__scale-input-container`,scaleInput:`${$}__scale-input`,sizeContainer:`${$}__size-container`,panelError:`${$}__panel--error`,exportedFileError:`${$}__exported-file--error`,exportedFileLoader:`${$}__exported-file--loader`,exportSection:`${$}__export-section`,exportSectionCentered:`${$}__export-section--centered`,templateButtonContainer:`${$}__template-button-container`,templateDoneButton:`${$}__template-done-button`,templateSelectFlowItemContainer:`${$}__template-select-flow-item-container`,templateSelectFlowItemContent:`${$}__template-select-flow-item-content`,templateSelectFlowItemListHeading:`${$}__template-select-flow-item-list-heading`};function M(e,t,l,i){const a=l/t,o=i/t;return{width:Math.round(e*a),height:Math.round(e*o)}}function E(e){return!isNaN(e)&&e>0}function F(e){return e?.toUpperCase()===I}function j(e){const{state:t,extension:l}=e;switch(t){case"pending":return"spinner";case"error":return"exclamation-mark-circle";default:return l?.toLowerCase()?.includes("pdf")?"file-pdf":"file"}}function P(e,t){return!!t&&e.some((e=>e.layoutItem?.id===t||e.layout===t))}const A=new l({inch:"inches",foot:"feet",yard:"yards",mile:"miles","nautical-mile":"nautical-miles",millimeter:"millimeters",centimeter:"centimeters",decimeter:"decimeters",meter:"meters",kilometer:"kilometers"});let B=class extends m{constructor(e,t){super(e,t),this._activeTabFocusRequested=!1,this._awaitingServerResponse=!1,this._exportedFileNameMap={},this._selectedTab=k.layout,this._pendingExportScroll=!1,this._rootNode=null,this._selectedLayout=null,this._abortController=null,this._showTemplates=!1,this.browseTemplateButtonOnClick=null,this.exportedLinks=new O,this.headingLevel=3,this.messagesCommon=null,this.messagesUnits=null,this.viewModel=new b,this._onInput=e=>{this._selectedTab===k.layout?this.templateOptions.title=e.target.value:this._selectedTab===k.mapOnly&&(this.templateOptions.fileName=e.target.value)},this._removeLink=e=>{const t=e.currentTarget["data-item"];t&&this.exportedLinks.remove(t)},this._handleLinkClick=e=>{const t=e.currentTarget["data-item"];if(!t||"ready"!==t.state||!t.url)return;const l=d(this.viewModel.effectivePrintServiceUrl),i=t.url,a=document.createElement("a");if(a.target="_blank",a.href=i,a.rel="noreferrer",a.download=t.formattedName??"",!l)return a.click(),void e.stopPropagation();e.preventDefault();const o=new URL(i);o.searchParams.set("token",l),a.href=o.href,a.click(),a.href=i},this._focusOnTabChange=this._focusOnTabChange.bind(this)}initialize(){this.addHandles([a((()=>[this.templateOptions.format,this.viewModel.templatesInfo?.format.defaultValue]),(([e,t])=>{if(t&&!e)return void(this.templateOptions.format=t);if(!e||!t||!this.viewModel.templatesInfo)return;if(this.viewModel.templatesInfo.format.choiceList.includes(e))return;const l=this.viewModel.templatesInfo.format.choiceList.find((t=>t.toUpperCase().includes(`(${e.toUpperCase()})`)));this.templateOptions.format=l??t})),a((()=>[this.templateOptions.layout,this.viewModel.templatesInfo?.layout.defaultValue]),(async([e,t])=>{if(this._selectedTab=F(e)?k.mapOnly:k.layout,this._selectedTab!==k.layout)return;const{includeDefaultTemplates:l,viewModel:a,_selectedLayout:o}=this,{portalTemplateIds:n,browseTemplates:s,templatesInfo:r}=a,c=a.defaultTemplates.filter((({layoutItem:e})=>n.includes(e?.id))),p=a.defaultTemplates.filter((({layoutItem:e})=>!n.includes(e?.id))),d=l&&p.length;if(e){(d?P(p,e):r?.layout.choiceList.includes(e))||P(c,e)||P(s,e)||(this.templateOptions.layout=null,this.templateOptions.layoutItem=null)}else{o&&((d?P(p,o):r?.layout.choiceList.includes(o))||P(c,o)||P(s,o))?await this._applyTemplate(o):(this.templateOptions.layout=null,this.templateOptions.layoutItem=null),this.templateOptions.layout||d||!t||await this._applyTemplate(t)}this._selectedLayout=this.templateOptions.layout;const u=!!this.templateOptions.layout&&this.viewModel.effectiveTemplateCustomTextElements[this.templateOptions.layout];this.templateOptions.customTextElements=u?i(u):null})),a((()=>this.templateOptions.dpi),(e=>{e<=0&&(this.templateOptions.dpi=1)})),a((()=>this.viewModel.view?.scale),(e=>{!e||this.templateOptions.scaleEnabled&&this.templateOptions.scale||(this.templateOptions.scale=e)}))]);const{height:e,width:t}=this.templateOptions;this.templateOptions.width=t||800,this.templateOptions.height=e||1100;const l=setTimeout((()=>{this._awaitingServerResponse=!0,this.scheduleRender()}),500);this.viewModel.load().then((()=>{clearTimeout(l),this._awaitingServerResponse=!1}))}loadDependencies(){return y({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),block:()=>import("@esri/calcite-components/dist/components/calcite-block.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),checkbox:()=>import("@esri/calcite-components/dist/components/calcite-checkbox.js"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox.js"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item.js"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow.js"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),input:()=>import("@esri/calcite-components/dist/components/calcite-input.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch.js"),chip:()=>import("@esri/calcite-components/dist/components/calcite-chip.js")})}destroy(){this.viewModel.destroy()}get allowedFormats(){return this.viewModel.allowedFormats}set allowedFormats(e){this.viewModel.allowedFormats=e}get allowedLayouts(){return this.viewModel.allowedLayouts}set allowedLayouts(e){this.viewModel.allowedLayouts=e}get error(){return this.viewModel.error}get extraParameters(){return this.viewModel.extraParameters}set extraParameters(e){this.viewModel.extraParameters=e}get icon(){return"print"}set icon(e){this._overrideIfSome("icon",e)}get includeDefaultTemplates(){return this.viewModel.includeDefaultTemplates}set includeDefaultTemplates(e){this.viewModel.includeDefaultTemplates=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get portal(){return this.viewModel.portal}set portal(e){this.viewModel.portal=e}get showPrintAreaEnabled(){return this.viewModel.showPrintAreaEnabled}set showPrintAreaEnabled(e){this.viewModel.showPrintAreaEnabled=e}get printServiceUrl(){return this.viewModel.printServiceUrl}set printServiceUrl(e){this.viewModel.printServiceUrl=e}get templateCustomTextElements(){return this.viewModel.templateCustomTextElements}set templateCustomTextElements(e){this.viewModel.templateCustomTextElements=e}get templateOptions(){return this.viewModel.templateOptions}set templateOptions(e){this.viewModel.templateOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}render(){const{messages:e,templateOptions:t,viewModel:l,view:i}=this,{attributionEnabled:a,author:o,copyright:n,dpi:s,format:r,height:c,layout:p,legendEnabled:d,northArrowEnabled:m,scaleEnabled:h,scale:b,width:y}=t,w="ready"!==l.state||this._awaitingServerResponse||!p,T=this._renderTitleOrFileNameSection(),C=x("div",{class:S.formSectionContainer},x("calcite-label",null,e.fileFormatTitle,x("calcite-combobox",{clearDisabled:!0,label:e.formatDefaultOption,maxItems:6,placeholder:e.formatDefaultOption,selectionMode:"single-persist",onCalciteComboboxChange:({target:e})=>{this.templateOptions.format=e.selectedItems[0].value}},l.templatesInfo?.format?.choiceList.sort().map(((e,t)=>x("calcite-combobox-item",{key:`file-format-${t}`,selected:e===this.templateOptions.format,textLabel:u(e),value:e})))))),O=x("calcite-label",{layout:"inline"},x("calcite-switch",{checked:this.showPrintAreaEnabled,onCalciteSwitchChange:e=>{this.showPrintAreaEnabled=!!e.target.checked}}),e.printPreview),I=x("div",null,x("div",{class:S.formSectionContainer},x("calcite-label",null,e.template,x("div",{class:S.templateSelectContainer,onclick:()=>{this._showTemplates=!0}},x("calcite-block",{class:S.templateSelectBlock,description:this._getPageSizeLabel(p),heading:this._getTemplateLabel()}),x("calcite-icon",{class:S.templateSelectIcon,icon:v()?"chevron-left":"chevron-right",scale:"s"})))),O),$=x("div",{class:S.formSectionContainer},x("calcite-label",null,e.dpi,x("calcite-input",{bind:this,"data-input-name":"dpi",min:1,tabIndex:0,type:"number",value:`${s}`,onCalciteInputInput:this._handleDPIChange}))),L=x("div",{class:this.classes(S.scaleInfoContainer,S.formSectionContainer)},x("calcite-label",{layout:"inline"},x("calcite-checkbox",{bind:this,checked:h,"data-option-name":"scaleEnabled",tabIndex:0,onCalciteCheckboxChange:this._toggleInputValue}),e.scale),x("div",{class:S.scaleInputContainer},x("calcite-input",{"aria-label":e.scaleLabel,"aria-valuenow":`${b}`,bind:this,class:S.scaleInput,"data-input-name":"scale",disabled:!h,tabIndex:0,type:"number",value:`${b}`,onCalciteInputInput:this._updateInputValue}),x("calcite-button",{appearance:"outline","aria-label":e.reset,bind:this,disabled:!h,iconStart:"refresh",kind:"neutral",onclick:this._resetToCurrentScale,tabIndex:0}))),M=x("div",{"aria-labelledby":`${this.id}__advancedOptionsForLayout`,class:S.advancedOptionsContainer,key:"advanced-section-for-layout"},L,this.viewModel.layoutTemplateInfo?.layoutOptions?.hasAuthorText??1?x("div",{class:S.formSectionContainer,key:"author-info"},x("calcite-label",null,e.author,x("calcite-input",{bind:this,"data-input-name":"author",tabIndex:0,value:o??"",onCalciteInputInput:this._updateInputValue}))):null,this.viewModel.layoutTemplateInfo?.layoutOptions?.hasCopyrightText??1?x("div",{class:S.formSectionContainer,key:"copyright-text"},x("calcite-label",null,e.copyright,x("calcite-input",{bind:this,"data-input-name":"copyright",tabIndex:0,value:n??"",onCalciteInputInput:this._updateInputValue}))):null,$,this._renderCustomTextElementSection(),this.viewModel.layoutTemplateInfo?.layoutOptions?.hasLegend??1?x("div",{class:S.formSectionContainer,key:"legend-info"},x("calcite-label",{layout:"inline"},x("calcite-checkbox",{bind:this,checked:d,"data-option-name":"legendEnabled",tabIndex:0,onCalciteCheckboxChange:this._toggleInputValue}),e.legend)):null,this.viewModel.layoutTemplateNorthArrowInfo??1?x("div",{class:S.formSectionContainer,key:"north-arrow"},x("calcite-label",{layout:"inline"},x("calcite-checkbox",{bind:this,checked:m,"data-option-name":"northArrowEnabled",tabIndex:0,onCalciteCheckboxChange:this._toggleInputValue}),e.northArrow)):null),E=x("div",{"aria-labelledby":`${this.id}__advancedOptionsForMapOnly`,class:S.advancedOptionsContainer},L,$,x("div",{class:S.formSectionContainer},x("calcite-label",{layout:"inline"},x("calcite-checkbox",{bind:this,checked:a,"data-option-name":"attributionEnabled",tabIndex:0,onCalciteCheckboxChange:this._toggleInputValue}),e.attribution)),this._renderCustomTextElementSection()),F=this.exportedLinks.toArray(),j=this._renderExportedLink(F),P={[S.exportSectionCentered]:!F.length},A=this._selectedTab===k.layout?x("section",{"aria-labelledby":`${this.id}__layoutTab`,class:S.layoutSection,id:`${this.id}__layoutContent`,key:"esri-print__layoutContent",role:"tabpanel"},x("div",{class:S.panelContainer},this.viewModel.layoutTemplateInfo?.layoutOptions?.hasTitleText??1?T:null,I,this._selectedTab===k.layout?C:null,x("calcite-block",{"aria-label":e.advancedOptions,class:this.classes(S.panelContainer,S.advancedOptionsSection),collapsible:!0,disabled:!p,heading:e.advancedOptions,id:"advancedOptionsForLayout",key:"advanced-options-for-layout"},M))):this._selectedTab===k.mapOnly?x("section",{"aria-labelledby":`${this.id}__mapOnlyTab`,class:S.mapOnlySection,id:`${this.id}__mapOnlyContent`,key:"esri-print__mapOnlyContent",role:"tabpanel"},x("div",{class:S.panelContainer},T,C,x("div",null,x("div",{class:this.classes(S.sizeContainer,S.formSectionContainer)},x("calcite-label",null,e.width,x("calcite-input",{bind:this,"data-input-name":"width",tabIndex:0,type:"number",value:`${y}`,onCalciteInputInput:this._updateInputValue})),x("calcite-label",null,e.height,x("calcite-input",{bind:this,"data-input-name":"height",tabIndex:0,type:"number",value:`${c}`,onCalciteInputInput:this._updateInputValue})),x("button",{"aria-label":e.swap,bind:this,class:this.classes(_.widgetButton,S.swapButton,g.swap),onclick:this._switchInput,tabIndex:0,type:"button"})),O),x("calcite-block",{"aria-label":e.advancedOptions,class:this.classes(S.panelContainer,S.advancedOptionsSection),collapsible:!0,heading:e.advancedOptions,id:"advancedOptionsForMapOnly",key:"advanced-options-for-map-only"},E))):x("section",{"aria-labelledby":`${this.id}__exportTab`,class:this.classes(S.exportSection,P),id:`${this.id}__exportContent`,key:"esri-print__exportContent",role:"tabpanel"},x("div",{class:S.panelContainer},x("div",{afterUpdate:this._scrollExportIntoView,bind:this,class:S.exportedFilesContainer},0===F.length?x("div",{class:S.exportedFilesEmpty},x("calcite-icon",{icon:"file",scale:"l"}),x("div",null,x(f,{class:S.exportedFilesTitle,level:this.headingLevel},e.noExportedFiles),x("div",null,e.exportHint))):j))),B={[_.buttonDisabled]:w||!p&&!r},D=!i||"2d"!==i.type,U=x("div",{class:S.panelError},D?e.sceneViewError:e.serviceError),N=F.some((({state:e})=>"pending"===e)),V=x("div",{class:S.content,key:"panel"},x("div",null,x("ul",{bind:this,class:S.layoutTabList,onclick:this._toggleLayoutPanel,onkeydown:this._handleLayoutPanelKeyDown,role:"tablist"},x("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${this._selectedTab===k.layout}`,class:S.layoutTab,"data-tab-id":k.layout,id:`${this.id}__layoutTab`,role:"tab",tabIndex:0},e.layoutTab),x("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${this._selectedTab===k.mapOnly}`,class:S.layoutTab,"data-tab-id":k.mapOnly,id:`${this.id}__mapOnlyTab`,role:"tab",tabIndex:0},e.mapOnlyTab),x("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${this._selectedTab===k.export}`,class:S.layoutTab,"data-tab-id":k.export,id:`${this.id}__exportedFilesTab`,role:"tab",tabIndex:0},N?x("calcite-loader",{inline:!0,label:"loading",scale:"s"}):null,e.exportsTab)),A),this._selectedTab!==k.export?x("button",{"aria-label":e.exportDescription,bind:this,class:this.classes(S.printButton,_.button,B),disabled:w,onclick:this._handlePrintMap,tabIndex:0,type:"button"},e.export):null),R=x("calcite-flow",{key:"root-flow"},x("calcite-flow-item",{bind:this,key:"root-flow-item"},x("div",{class:S.printWidgetContainer},x("header",{class:S.headerTitle},e.export),this.error||D||!i?U:V)),this._renderChooseTemplateFlowItem()),z="initializing"===l.state,H=z?this._renderLoader():R,W={[S.panelItemsCentered]:z};return x("div",{bind:this,class:this.classes(S.base,_.widget,_.panel,W)},H)}_getPageSizeLabel(e){if(!e)return;const t=this.viewModel.getLayoutTemplateInfo(e);if(!t)return;const l=A.fromJSON(t.pageUnits.toLowerCase());return`${C(t.pageSize[0])} x ${C(t.pageSize[1])} ${o(this.messagesUnits,l,"abbr")}`}_getTemplateLabel(){const{messages:e,includeDefaultTemplates:t,templateOptions:l,viewModel:i}=this,{layout:a}=l,o=a?(t?i.defaultTemplates.find((({layoutItem:e,layout:t})=>a===e?.id||a===t)):null)??i.browseTemplates.find((({layoutItem:e})=>a===e?.id)):null;return o?.label?.replaceAll("_"," ")??e[a]??a?.replaceAll("_"," ")??e.selectTemplate}_renderChooseTemplateFlowItem(){if(!this._showTemplates)return null;const{includeDefaultTemplates:e,messages:t,viewModel:l}=this,{defaultTemplates:i,templatesInfo:a,browseTemplates:o,portalTemplateIds:n}=l,s=p.test(this.portal?.url),r=o.length?o.toArray().sort(((e,t)=>(e.label??"")>(t.label??"")?1:-1)).map(((e,i)=>{const a=e.layoutItem?.id??e.layout,o=this._getPageSizeLabel(a),n=a===this.templateOptions.layout;return x("calcite-list-item",{description:o,key:`browse-template-${i}`,label:e?.label?.replaceAll("_"," ")??t.untitled,selected:n,title:e.description??"",value:a},!o&&n&&e.layoutItem?.id?x("calcite-loader",{inline:!0,key:`browse-template-loader-${i}`,label:"loading",scale:"s",slot:"content-end"}):null,x("calcite-action",{icon:"trash",onclick:()=>l.removePortalTemplate(e),slot:"actions-end",text:"delete"}))})):null,c=i.length&&e?i.toArray().filter((({label:e,layoutItem:t})=>!F(e)&&n.includes(t?.id))).map(((e,l)=>{const i=e.layoutItem?.id??e.layout,a=this._getPageSizeLabel(i),o=i===this.templateOptions.layout;return x("calcite-list-item",{description:a,key:`portal-template-${i}-${o}`,label:e?.label?.replaceAll("_"," ")??t.untitled,selected:o,title:e.description??"",value:i},!a&&o&&e.layoutItem?.id?x("calcite-loader",{inline:!0,key:`portal-template-loader-${l}`,label:"loading",scale:"s",slot:"content-end"}):null)})):null,d=i.length&&e?i.toArray().filter((({label:e,layoutItem:t})=>!F(e)&&!n.includes(t?.id))).sort(((e,t)=>(e.label??"")>(t.label??"")?1:-1)).map(((e,l)=>{const i=e.layoutItem?.id??e.layout,a=this._getPageSizeLabel(i),o=i===this.templateOptions.layout;return x("calcite-list-item",{description:a,key:`default-template-${l}`,label:e?.label?.replaceAll("_"," ")??t.untitled,selected:o,title:e.description??"",value:i},!a&&o&&e.layoutItem?.id?x("calcite-loader",{inline:!0,key:`default-template-loader-${l}`,label:"loading",scale:"s",slot:"content-end"}):null)})):null,u=!a?.layout?.choiceList.length||e&&d?.length?null:a.layout.choiceList.map((e=>({label:t[e]??e.replaceAll("_"," "),value:e}))).sort(((e,t)=>e.label>t.label?1:0)).map((({label:e,value:t},l)=>x("calcite-list-item",{description:this._getPageSizeLabel(t),key:`service-template-${l}`,label:e,selected:t===this.templateOptions.layout,value:t}))),m=(r?.length??0)+(c?.length??0)+(d?.length??0)+(u?.length??0)>15;return x("calcite-flow-item",{bind:this,closable:!1,heading:t.chooseTemplate,key:"template-flow-item",onCalciteFlowItemBack:e=>{e.preventDefault(),this._showTemplates=!1}},x("div",{class:S.templateSelectFlowItemContainer},x("div",{class:S.templateSelectFlowItemContent},this.browseTemplateButtonOnClick?x("calcite-button",{appearance:"outline",class:S.browseTemplateButtonContainer,key:"browse-template-button",onclick:this.browseTemplateButtonOnClick},"Browse Templates"):null,x("calcite-list",{filterEnabled:m,key:"template-list",selectionMode:"single-persist",onCalciteListChange:({target:e})=>this._applyTemplate(e.selectedItems[0].value)},r?.length?x("div",{key:"my-templates"},x("div",{class:S.templateSelectFlowItemListHeading},t.myTemplates,x("calcite-chip",{appearance:"outline",kind:"neutral",scale:"s",value:t.beta},t.beta)),r):null,c?.length?x("div",{key:"org-templates"},x("div",{class:S.templateSelectFlowItemListHeading},t.organizationTemplates,s?x("calcite-chip",{appearance:"outline",kind:"neutral",scale:"s",value:t.beta},t.beta):null),c):null,r?.length||c?.length?d?.length?x("div",{key:"default-templates"},x("div",{class:S.templateSelectFlowItemListHeading},t.defaultTemplates),d):null:d,r?.length||c?.length?u?.length?x("div",{key:"service-templates"},x("div",{class:S.templateSelectFlowItemListHeading},t.defaultTemplates),u):null:u)),x("div",{class:S.templateButtonContainer},x("calcite-button",{class:S.templateDoneButton,onclick:()=>this._showTemplates=!1},this.messagesCommon.done))))}_renderCustomTextElementSection(){const{customTextElements:e}=this.templateOptions;return e?x("div",{class:S.formSectionContainer,key:"custom-text-elements"},e.map(((e,t)=>{const[l,i]=Object.entries(e)[0];return"date"===l?null:x("calcite-label",{key:`custom-text-elements-${l}-${t}`},l,x("calcite-input",{bind:this,"data-input-custom":!0,"data-input-name":l,value:i??"",onCalciteInputInput:this._updateInputValue}))}))):null}async _applyTemplate(e){if(this._abortController&&(this._abortController.abort(),this._abortController=null),!e)return;const t=this.viewModel.defaultTemplates.find((({layoutItem:t})=>e===t?.id))??this.viewModel.browseTemplates.find((({layoutItem:t})=>e===t?.id));if(!t)return this.templateOptions.layout=e,void(this.templateOptions.layoutItem=null);const{format:l,layoutItem:a}=t,o=a?.id??t.layout??this.templateOptions.layout;if(this.templateOptions.layout=o,!t.layoutOptions)try{this._abortController=new AbortController,await this.viewModel.fetchLayoutTemplateInfo(t,{signal:this._abortController.signal})}catch(p){return}finally{this._abortController=null}const n=t.layoutOptions?.legend??this.templateOptions.legendEnabled,s=t.layoutOptions?.northArrow??this.templateOptions.northArrowEnabled,r=o?this.viewModel.effectiveTemplateCustomTextElements[o]:null,c=r?i(r):null;this.templateOptions.set({customTextElements:c,format:l,layout:o,layoutItem:a,legendEnabled:n,northArrowEnabled:s})}_renderTitleOrFileNameSection(){const{title:e,fileName:t,titlePlaceHolder:l,fileNamePlaceHolder:i}=this.messages,a=this._selectedTab===k.layout?e:t,o=this._selectedTab===k.layout?l:i,n=this._selectedTab===k.layout?this.templateOptions.title:this.templateOptions.fileName;return x("div",{class:S.formSectionContainer,key:a},x("calcite-label",null,a,x("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===k.layout||"mapOnlyTab"===t&&this._selectedTab===k.mapOnly||"exportTab"===t&&this._selectedTab===k.export)&&(e.focus(),this._activeTabFocusRequested=!1)}_renderLoader(){const e={[S.loader]:this._awaitingServerResponse};return x("div",{class:this.classes(e),key:"loader"})}_createFileLink(e,t){const l=t||this.messages.untitled,i=e.format.toLowerCase(),a=i.includes("png")?"png":i,o=l+a;return void 0!==this._exportedFileNameMap[o]?this._exportedFileNameMap[o]++:this._exportedFileNameMap[o]=0,new h({name:l,extension:a,count:this._exportedFileNameMap[o]})}_resetToCurrentScale(){this.templateOptions.scale=this.viewModel.view?.scale}_updateCustomTextElementValue(e,t,l){e.find((e=>{const[l]=Object.entries(e)[0];return l===t}))[t]=l}_updateInputValue(e){const t=e.target,l=t.getAttribute("data-input-name"),i=!!t["data-input-custom"],{templateOptions:a}=this;if(i)return void this._updateCustomTextElementValue(a.customTextElements,l,t.value);let o;if("number"===t.type){const e=Number(t.value);if(!E(e)){const e=a[l];return void(t.value=`${e}`)}o=e}else o=t.value;a[l]=o}_handleDPIChange(e){const{templateOptions:t}=this,l=t.dpi;this._updateInputValue(e);const i=t.dpi,{height:a,width:o}=M(i,l,t.width,t.height);t.height=a,t.width=o}_handlePrintMap(){this._pendingExportScroll=!0;const{templateOptions:e}=this,t=this.viewModel.toPrintTemplate(e),l=this._selectedTab===k.layout?t.layoutOptions?.titleText:e.fileName,i=this._createFileLink(t,l);this.exportedLinks.add(i),this.emit("submit",{link:i}),this._selectedTab=k.export,this.viewModel.print(t).then((e=>{i.set({url:e&&e.url,state:"ready"})})).catch((e=>{i.set({error:e,state:"error"})})).then((()=>{this.emit("complete",{link:i}),this.scheduleRender()}))}_switchInput(){[this.templateOptions.width,this.templateOptions.height]=[this.templateOptions.height,this.templateOptions.width]}_scrollExportIntoView(){if(!this._pendingExportScroll)return;this._pendingExportScroll=!1;const e=this._rootNode;if(!e)return;const{clientHeight:t,scrollHeight:l}=e,i=l-t;i>0&&(e.scrollTop=i)}_toggleInputValue(e){const t=e.target,l=t.getAttribute("data-option-name");this.templateOptions[l]=t.checked,"scaleEnabled"===l&&this._resetToCurrentScale()}_renderExportedLink(e){const t=this.messages,l=e.map((e=>{const{error:l,url:i,state:a}=e,o=e.formattedName??"",r="error"===a,c="pending"===a,p="ready"===a;let d=i||null;d&&(d=n(d));const u=s(i,location.href);let m;m=c?t.pending:p?t.ready:t.errorMessage;const h=r?"print-task:cim-symbol-unsupported"===l?.name?t.exportWebMapCIMError:t.exportWebMapError:"";return x("calcite-list-item",{"aria-label":m,class:S.exportedFile,"data-item":e,description:c?t.generatingExport:h||(u?t.ready:t.linkReady),key:o,label:o,title:h,onCalciteListItemSelect:this._handleLinkClick},c?x("calcite-loader",{class:S.exportedFileLoader,inline:!0,key:`${o}-loader`,label:t.generatingExport,scale:"m",slot:"content-start"}):x("calcite-icon",{icon:j(e),key:`${o}-start-icon`,scale:"s",slot:"content-start"}),p?x("calcite-icon",{"aria-label":`${o}. ${t.linkReady}`,icon:u?"download-to":"launch",key:`${o}-end-icon`,scale:"s",slot:"content-end"}):null,c?null:x("calcite-action",{"aria-label":`${h}`,"data-item":e,icon:"x",key:`${o}-action`,onclick:this._removeLink,slot:"actions-end",text:`${h}`}))}));return x("calcite-list",{filterEnabled:e?.length>10},l)}_toggleLayoutPanel(e){const t=e.target;this._toggleTab(t.getAttribute("data-tab-id"))}_toggleTab(e,t=!0){if(this._selectedTab=e,this._selectedTab===k.mapOnly)this.templateOptions.layout=I,this.templateOptions.layoutItem=null,this.templateOptions.customTextElements=null;else if(this._selectedTab===k.layout){const e=this._selectedLayout??(this.includeDefaultTemplates&&this.viewModel.defaultTemplates.length?null:this.viewModel.templatesInfo?.layout?.defaultValue);e?this._applyTemplate(e):(this.templateOptions.layout=null,this.templateOptions.layoutItem=null,this.templateOptions.customTextElements=null)}t&&(this._activeTabFocusRequested=!0)}_handleLayoutPanelKeyDown(e){const{key:t}=e,l=e.target.getAttribute("data-tab-id");if(w(t))return this._toggleTab(l),e.preventDefault(),void e.stopPropagation();if("ArrowLeft"===t||"ArrowRight"===t){switch(l){case k.layout:this._toggleTab("ArrowLeft"===t?k.export:k.mapOnly);break;case k.mapOnly:this._toggleTab("ArrowLeft"===t?k.layout:k.export);break;case k.export:this._toggleTab("ArrowLeft"===t?k.mapOnly:k.layout)}e.preventDefault(),e.stopPropagation()}}};e([r()],B.prototype,"_showTemplates",void 0),e([r()],B.prototype,"allowedFormats",null),e([r()],B.prototype,"allowedLayouts",null),e([r()],B.prototype,"browseTemplateButtonOnClick",void 0),e([r()],B.prototype,"error",null),e([r({type:O})],B.prototype,"exportedLinks",void 0),e([r()],B.prototype,"extraParameters",null),e([r()],B.prototype,"headingLevel",void 0),e([r()],B.prototype,"icon",null),e([r()],B.prototype,"includeDefaultTemplates",null),e([r()],B.prototype,"label",null),e([r(),T("esri/widgets/Print/t9n/Print")],B.prototype,"messages",void 0),e([r(),T("esri/t9n/common")],B.prototype,"messagesCommon",void 0),e([r(),T("esri/core/t9n/Units")],B.prototype,"messagesUnits",void 0),e([r()],B.prototype,"portal",null),e([r()],B.prototype,"showPrintAreaEnabled",null),e([r()],B.prototype,"printServiceUrl",null),e([r()],B.prototype,"templateCustomTextElements",null),e([r()],B.prototype,"templateOptions",null),e([r()],B.prototype,"view",null),e([r({type:b})],B.prototype,"viewModel",void 0),B=e([c("esri.widgets.Print")],B);const D=B;export{D as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import t from"../core/Collection.js";import{JSONMap as l}from"../core/jsonMap.js";import{clone as i}from"../core/lang.js";import{watch as a}from"../core/reactiveUtils.js";import{unitName as o}from"../core/unitFormatUtils.js";import{addProxy as n,hasSameOrigin as s}from"../core/urlUtils.js";import{property as r}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import{subclass as c}from"../core/accessorSupport/decorators/subclass.js";import{reArcGISOnlineDomain as p}from"../portal/support/urlUtils.js";import{getToken as d}from"../rest/utils.js";import{toJSON as u}from"../rest/support/fileFormat.js";import m from"./Widget.js";import h from"./Print/FileLink.js";import b from"./Print/PrintViewModel.js";import{loadCalciteComponents as y}from"./support/componentsUtils.js";import{globalCss as _}from"./support/globalCss.js";import{Heading as f}from"./support/Heading.js";import{legacyIcon as g}from"./support/legacyIcon.js";import{isRTL as v,isActivationKey as w}from"./support/widgetUtils.js";import{messageBundle as T}from"./support/decorators/messageBundle.js";import{tsx as x}from"./support/jsxFactory.js";import{formatNumber as C}from"../intl/number.js";const O=t.ofType(h),I="MAP_ONLY";var k;!function(e){e.layout="layoutTab",e.mapOnly="mapOnlyTab",e.export="exportTab"}(k||(k={}));const $="esri-print",L=`${$}__advanced-options-button`,S={base:$,headerTitle:`${$}__header-title`,layoutTabList:`${$}__layout-tab-list`,layoutTab:`${$}__layout-tab`,layoutSection:`${$}__layout-section`,mapOnlySection:`${$}__map-only-section`,panelItemsCentered:`${$}__panel-items--centered`,loader:`${$}__loader`,advancedOptionsButton:L,advancedOptionsButtonContainer:`${L}-container`,advancedOptionsButtonTitle:`${L}-title`,advancedOptionsButtonIconOpened:`${L}-icon--opened`,advancedOptionsButtonIconClosed:`${L}-icon--closed`,advancedOptionsButtonIconClosed_RTL:`${L}-icon--closed-rtl`,swapButton:`${$}__swap-button`,printButton:`${$}__export-button`,templateSelectContainer:`${$}__template-select-container`,templateSelectBlock:`${$}__template-select-block`,templateSelectIcon:`${$}__template-select-icon`,formSectionContainer:`${$}__form-section-container`,formCheckboxLabel:`${$}__form-checkbox-label`,advancedOptionsSection:`${$}__advanced-options-section`,advancedOptionsContainer:`${$}__advanced-options-container`,browseTemplateButtonContainer:`${$}__browse-template-button-container`,exportedFilesContainer:`${$}__export-panel-container`,exportedFilesTitle:`${$}__export-title`,exportedFile:`${$}__exported-file`,exportedFileLink:`${$}__exported-file-link`,exportedFileLinkTitle:`${$}__exported-file-link-title`,exportedFilesEmpty:`${$}__exported-files-empty`,printWidgetContainer:`${$}__container`,content:`${$}__content`,panelContainer:`${$}__panel-container`,scaleInfoContainer:`${$}__scale-info-container`,scaleInputContainer:`${$}__scale-input-container`,scaleInput:`${$}__scale-input`,sizeContainer:`${$}__size-container`,panelError:`${$}__panel--error`,exportedFileError:`${$}__exported-file--error`,exportedFileLoader:`${$}__exported-file--loader`,exportSection:`${$}__export-section`,exportSectionCentered:`${$}__export-section--centered`,templateButtonContainer:`${$}__template-button-container`,templateDoneButton:`${$}__template-done-button`,templateSelectFlowItemContainer:`${$}__template-select-flow-item-container`,templateSelectFlowItemContent:`${$}__template-select-flow-item-content`,templateSelectFlowItemListHeading:`${$}__template-select-flow-item-list-heading`};function M(e,t,l,i){const a=l/t,o=i/t;return{width:Math.round(e*a),height:Math.round(e*o)}}function E(e){return!isNaN(e)&&e>0}function F(e){return e?.toUpperCase()===I}function j(e){const{state:t,extension:l}=e;switch(t){case"pending":return"spinner";case"error":return"exclamation-mark-circle";default:return l?.toLowerCase()?.includes("pdf")?"file-pdf":"file"}}function P(e,t){return!!t&&e.some((e=>e.layoutItem?.id===t||e.layout===t))}const A=new l({inch:"inches",foot:"feet",yard:"yards",mile:"miles","nautical-mile":"nautical-miles",millimeter:"millimeters",centimeter:"centimeters",decimeter:"decimeters",meter:"meters",kilometer:"kilometers"});let B=class extends m{constructor(e,t){super(e,t),this._activeTabFocusRequested=!1,this._awaitingServerResponse=!1,this._exportedFileNameMap={},this._selectedTab=k.layout,this._pendingExportScroll=!1,this._rootNode=null,this._selectedLayout=null,this._abortController=null,this._showTemplates=!1,this.browseTemplateButtonOnClick=null,this.exportedLinks=new O,this.headingLevel=3,this.messagesCommon=null,this.messagesUnits=null,this.viewModel=new b,this._onInput=e=>{this._selectedTab===k.layout?this.templateOptions.title=e.target.value:this._selectedTab===k.mapOnly&&(this.templateOptions.fileName=e.target.value)},this._removeLink=e=>{const t=e.currentTarget["data-item"];t&&this.exportedLinks.remove(t)},this._handleLinkClick=e=>{const t=e.currentTarget["data-item"];if(!t||"ready"!==t.state||!t.url)return;const l=d(this.viewModel.effectivePrintServiceUrl),i=t.url,a=document.createElement("a");if(a.target="_blank",a.href=i,a.rel="noreferrer",a.download=t.formattedName??"",!l)return a.click(),void e.stopPropagation();e.preventDefault();const o=new URL(i);o.searchParams.set("token",l),a.href=o.href,a.click(),a.href=i},this._focusOnTabChange=this._focusOnTabChange.bind(this)}initialize(){this.addHandles([a((()=>[this.templateOptions.format,this.viewModel.templatesInfo?.format.defaultValue]),(([e,t])=>{if(t&&!e)return void(this.templateOptions.format=t);if(!e||!t||!this.viewModel.templatesInfo)return;if(this.viewModel.templatesInfo.format.choiceList.includes(e))return;const l=this.viewModel.templatesInfo.format.choiceList.find((t=>t.toUpperCase().includes(`(${e.toUpperCase()})`)));this.templateOptions.format=l??t})),a((()=>[this.templateOptions.layout,this.viewModel.templatesInfo?.layout.defaultValue]),(async([e,t])=>{if(this._selectedTab=F(e)?k.mapOnly:k.layout,this._selectedTab!==k.layout)return;const{includeDefaultTemplates:l,viewModel:a,_selectedLayout:o}=this,{portalTemplateIds:n,browseTemplates:s,templatesInfo:r}=a,c=a.defaultTemplates.filter((({layoutItem:e})=>n.includes(e?.id))),p=a.defaultTemplates.filter((({layoutItem:e})=>!n.includes(e?.id))),d=l&&p.length;if(e){(d?P(p,e):r?.layout.choiceList.includes(e))||P(c,e)||P(s,e)||(this.templateOptions.layout=null,this.templateOptions.layoutItem=null)}else{o&&((d?P(p,o):r?.layout.choiceList.includes(o))||P(c,o)||P(s,o))?await this._applyTemplate(o):(this.templateOptions.layout=null,this.templateOptions.layoutItem=null),this.templateOptions.layout||d||!t||await this._applyTemplate(t)}this._selectedLayout=this.templateOptions.layout;const u=!!this.templateOptions.layout&&this.viewModel.effectiveTemplateCustomTextElements[this.templateOptions.layout];this.templateOptions.customTextElements=u?i(u):null})),a((()=>this.templateOptions.dpi),(e=>{e<=0&&(this.templateOptions.dpi=1)})),a((()=>this.viewModel.view?.scale),(e=>{!e||this.templateOptions.scaleEnabled&&this.templateOptions.scale||(this.templateOptions.scale=e)}))]);const{height:e,width:t}=this.templateOptions;this.templateOptions.width=t||800,this.templateOptions.height=e||1100;const l=setTimeout((()=>{this._awaitingServerResponse=!0,this.scheduleRender()}),500);this.viewModel.load().then((()=>{clearTimeout(l),this._awaitingServerResponse=!1}))}loadDependencies(){return y({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),block:()=>import("@esri/calcite-components/dist/components/calcite-block.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),checkbox:()=>import("@esri/calcite-components/dist/components/calcite-checkbox.js"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox.js"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item.js"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow.js"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),input:()=>import("@esri/calcite-components/dist/components/calcite-input.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch.js"),chip:()=>import("@esri/calcite-components/dist/components/calcite-chip.js")})}destroy(){this.viewModel.destroy()}get allowedFormats(){return this.viewModel.allowedFormats}set allowedFormats(e){this.viewModel.allowedFormats=e}get allowedLayouts(){return this.viewModel.allowedLayouts}set allowedLayouts(e){this.viewModel.allowedLayouts=e}get error(){return this.viewModel.error}get extraParameters(){return this.viewModel.extraParameters}set extraParameters(e){this.viewModel.extraParameters=e}get icon(){return"print"}set icon(e){this._overrideIfSome("icon",e)}get includeDefaultTemplates(){return this.viewModel.includeDefaultTemplates}set includeDefaultTemplates(e){this.viewModel.includeDefaultTemplates=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get portal(){return this.viewModel.portal}set portal(e){this.viewModel.portal=e}get showPrintAreaEnabled(){return this.viewModel.showPrintAreaEnabled}set showPrintAreaEnabled(e){this.viewModel.showPrintAreaEnabled=e}get printServiceUrl(){return this.viewModel.printServiceUrl}set printServiceUrl(e){this.viewModel.printServiceUrl=e}get templateCustomTextElements(){return this.viewModel.templateCustomTextElements}set templateCustomTextElements(e){this.viewModel.templateCustomTextElements=e}get templateOptions(){return this.viewModel.templateOptions}set templateOptions(e){this.viewModel.templateOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}render(){const{messages:e,templateOptions:t,viewModel:l,view:i}=this,{attributionEnabled:a,author:o,copyright:n,dpi:s,format:r,height:c,layout:p,legendEnabled:d,northArrowEnabled:m,scaleEnabled:h,scale:b,width:y}=t,w="ready"!==l.state||this._awaitingServerResponse||!p,T=this._renderTitleOrFileNameSection(),C=x("div",{class:S.formSectionContainer},x("calcite-label",null,e.fileFormatTitle,x("calcite-combobox",{clearDisabled:!0,label:e.formatDefaultOption,maxItems:6,placeholder:e.formatDefaultOption,selectionMode:"single-persist",onCalciteComboboxChange:({target:e})=>{this.templateOptions.format=e.selectedItems[0].value}},l.templatesInfo?.format?.choiceList.sort().map(((e,t)=>x("calcite-combobox-item",{key:`file-format-${t}`,selected:e===this.templateOptions.format,textLabel:u(e),value:e})))))),O=x("calcite-label",{layout:"inline"},x("calcite-switch",{checked:this.showPrintAreaEnabled,onCalciteSwitchChange:e=>{this.showPrintAreaEnabled=!!e.target.checked}}),e.printPreview),I=x("div",null,x("div",{class:S.formSectionContainer},x("calcite-label",null,e.template,x("div",{class:S.templateSelectContainer,onclick:()=>{this._showTemplates=!0}},x("calcite-block",{class:S.templateSelectBlock,description:this._getPageSizeLabel(p),heading:this._getTemplateLabel()}),x("calcite-icon",{class:S.templateSelectIcon,icon:v()?"chevron-left":"chevron-right",scale:"s"})))),O),$=x("div",{class:S.formSectionContainer},x("calcite-label",null,e.dpi,x("calcite-input",{bind:this,"data-input-name":"dpi",min:1,tabIndex:0,type:"number",value:`${s}`,onCalciteInputInput:this._handleDPIChange}))),L=x("div",{class:this.classes(S.scaleInfoContainer,S.formSectionContainer)},x("calcite-label",{layout:"inline"},x("calcite-checkbox",{bind:this,checked:h,"data-option-name":"scaleEnabled",tabIndex:0,onCalciteCheckboxChange:this._toggleInputValue}),e.scale),x("div",{class:S.scaleInputContainer},x("calcite-input",{"aria-label":e.scaleLabel,"aria-valuenow":`${b}`,bind:this,class:S.scaleInput,"data-input-name":"scale",disabled:!h,tabIndex:0,type:"number",value:`${b}`,onCalciteInputInput:this._updateInputValue}),x("calcite-button",{appearance:"outline","aria-label":e.reset,bind:this,disabled:!h,iconStart:"refresh",kind:"neutral",onclick:this._resetToCurrentScale,tabIndex:0}))),M=x("div",{"aria-labelledby":`${this.id}__advancedOptionsForLayout`,class:S.advancedOptionsContainer,key:"advanced-section-for-layout"},L,this.viewModel.layoutTemplateInfo?.layoutOptions?.hasAuthorText??1?x("div",{class:S.formSectionContainer,key:"author-info"},x("calcite-label",null,e.author,x("calcite-input",{bind:this,"data-input-name":"author",tabIndex:0,value:o??"",onCalciteInputInput:this._updateInputValue}))):null,this.viewModel.layoutTemplateInfo?.layoutOptions?.hasCopyrightText??1?x("div",{class:S.formSectionContainer,key:"copyright-text"},x("calcite-label",null,e.copyright,x("calcite-input",{bind:this,"data-input-name":"copyright",tabIndex:0,value:n??"",onCalciteInputInput:this._updateInputValue}))):null,$,this._renderCustomTextElementSection(),this.viewModel.layoutTemplateInfo?.layoutOptions?.hasLegend??1?x("div",{class:S.formSectionContainer,key:"legend-info"},x("calcite-label",{layout:"inline"},x("calcite-checkbox",{bind:this,checked:d,"data-option-name":"legendEnabled",tabIndex:0,onCalciteCheckboxChange:this._toggleInputValue}),e.legend)):null,this.viewModel.layoutTemplateNorthArrowInfo??1?x("div",{class:S.formSectionContainer,key:"north-arrow"},x("calcite-label",{layout:"inline"},x("calcite-checkbox",{bind:this,checked:m,"data-option-name":"northArrowEnabled",tabIndex:0,onCalciteCheckboxChange:this._toggleInputValue}),e.northArrow)):null),E=x("div",{"aria-labelledby":`${this.id}__advancedOptionsForMapOnly`,class:S.advancedOptionsContainer},L,$,x("div",{class:S.formSectionContainer},x("calcite-label",{layout:"inline"},x("calcite-checkbox",{bind:this,checked:a,"data-option-name":"attributionEnabled",tabIndex:0,onCalciteCheckboxChange:this._toggleInputValue}),e.attribution)),this._renderCustomTextElementSection()),F=this.exportedLinks.toArray(),j=this._renderExportedLink(F),P={[S.exportSectionCentered]:!F.length},A=this._selectedTab===k.layout?x("section",{"aria-labelledby":`${this.id}__layoutTab`,class:S.layoutSection,id:`${this.id}__layoutContent`,key:"esri-print__layoutContent",role:"tabpanel"},x("div",{class:S.panelContainer},this.viewModel.layoutTemplateInfo?.layoutOptions?.hasTitleText??1?T:null,I,this._selectedTab===k.layout?C:null,x("calcite-block",{"aria-label":e.advancedOptions,class:this.classes(S.panelContainer,S.advancedOptionsSection),collapsible:!0,disabled:!p,heading:e.advancedOptions,id:"advancedOptionsForLayout",key:"advanced-options-for-layout"},M))):this._selectedTab===k.mapOnly?x("section",{"aria-labelledby":`${this.id}__mapOnlyTab`,class:S.mapOnlySection,id:`${this.id}__mapOnlyContent`,key:"esri-print__mapOnlyContent",role:"tabpanel"},x("div",{class:S.panelContainer},T,C,x("div",null,x("div",{class:this.classes(S.sizeContainer,S.formSectionContainer)},x("calcite-label",null,e.width,x("calcite-input",{bind:this,"data-input-name":"width",tabIndex:0,type:"number",value:`${y}`,onCalciteInputInput:this._updateInputValue})),x("calcite-label",null,e.height,x("calcite-input",{bind:this,"data-input-name":"height",tabIndex:0,type:"number",value:`${c}`,onCalciteInputInput:this._updateInputValue})),x("button",{"aria-label":e.swap,bind:this,class:this.classes(_.widgetButton,S.swapButton,g.swap),onclick:this._switchInput,tabIndex:0,type:"button"})),O),x("calcite-block",{"aria-label":e.advancedOptions,class:this.classes(S.panelContainer,S.advancedOptionsSection),collapsible:!0,heading:e.advancedOptions,id:"advancedOptionsForMapOnly",key:"advanced-options-for-map-only"},E))):x("section",{"aria-labelledby":`${this.id}__exportTab`,class:this.classes(S.exportSection,P),id:`${this.id}__exportContent`,key:"esri-print__exportContent",role:"tabpanel"},x("div",{class:S.panelContainer},x("div",{afterUpdate:this._scrollExportIntoView,bind:this,class:S.exportedFilesContainer},0===F.length?x("div",{class:S.exportedFilesEmpty},x("calcite-icon",{icon:"file",scale:"l"}),x("div",null,x(f,{class:S.exportedFilesTitle,level:this.headingLevel},e.noExportedFiles),x("div",null,e.exportHint))):j))),B={[_.buttonDisabled]:w||!p&&!r},D=!i||"2d"!==i.type,U=x("div",{class:S.panelError},D?e.sceneViewError:e.serviceError),N=F.some((({state:e})=>"pending"===e)),V=x("div",{class:S.content,key:"panel"},x("div",null,x("ul",{bind:this,class:S.layoutTabList,onclick:this._toggleLayoutPanel,onkeydown:this._handleLayoutPanelKeyDown,role:"tablist"},x("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${this._selectedTab===k.layout}`,class:S.layoutTab,"data-tab-id":k.layout,id:`${this.id}__layoutTab`,role:"tab",tabIndex:0},e.layoutTab),x("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${this._selectedTab===k.mapOnly}`,class:S.layoutTab,"data-tab-id":k.mapOnly,id:`${this.id}__mapOnlyTab`,role:"tab",tabIndex:0},e.mapOnlyTab),x("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${this._selectedTab===k.export}`,class:S.layoutTab,"data-tab-id":k.export,id:`${this.id}__exportedFilesTab`,role:"tab",tabIndex:0},N?x("calcite-loader",{inline:!0,label:"loading",scale:"s"}):null,e.exportsTab)),A),this._selectedTab!==k.export?x("button",{"aria-label":e.exportDescription,bind:this,class:this.classes(S.printButton,_.button,B),disabled:w,onclick:this._handlePrintMap,tabIndex:0,type:"button"},e.export):null),R=x("calcite-flow",{key:"root-flow"},x("calcite-flow-item",{bind:this,key:"root-flow-item"},x("div",{class:S.printWidgetContainer},x("header",{class:S.headerTitle},e.export),this.error||D||!i?U:V)),this._renderChooseTemplateFlowItem()),z="initializing"===l.state,H=z?this._renderLoader():R,W={[S.panelItemsCentered]:z};return x("div",{bind:this,class:this.classes(S.base,_.widget,_.panel,W)},H)}_getPageSizeLabel(e){if(!e)return;const t=this.viewModel.getLayoutTemplateInfo(e);if(!t)return;const l=A.fromJSON(t.pageUnits.toLowerCase());return`${C(t.pageSize[0])} x ${C(t.pageSize[1])} ${o(this.messagesUnits,l,"abbr")}`}_getTemplateLabel(){const{messages:e,includeDefaultTemplates:t,templateOptions:l,viewModel:i}=this,{layout:a}=l,o=a?(t?i.defaultTemplates.find((({layoutItem:e,layout:t})=>a===e?.id||a===t)):null)??i.browseTemplates.find((({layoutItem:e})=>a===e?.id)):null;return o?.label?.replaceAll("_"," ")??e[a]??a?.replaceAll("_"," ")??e.selectTemplate}_renderChooseTemplateFlowItem(){if(!this._showTemplates)return null;const{includeDefaultTemplates:e,messages:t,viewModel:l}=this,{defaultTemplates:i,templatesInfo:a,browseTemplates:o,portalTemplateIds:n}=l,s=p.test(this.portal?.url),r=o.length?o.toArray().sort(((e,t)=>(e.label??"")>(t.label??"")?1:-1)).map(((e,i)=>{const a=e.layoutItem?.id??e.layout,o=this._getPageSizeLabel(a),n=a===this.templateOptions.layout;return x("calcite-list-item",{description:o,key:`browse-template-${i}`,label:e?.label?.replaceAll("_"," ")??t.untitled,selected:n,title:e.description??"",value:a},!o&&n&&e.layoutItem?.id?x("calcite-loader",{inline:!0,key:`browse-template-loader-${i}`,label:"loading",scale:"s",slot:"content-end"}):null,x("calcite-action",{icon:"trash",onclick:()=>l.removePortalTemplate(e),slot:"actions-end",text:"delete"}))})):null,c=i.length&&e?i.toArray().filter((({label:e,layoutItem:t})=>!F(e)&&n.includes(t?.id))).map(((e,l)=>{const i=e.layoutItem?.id??e.layout,a=this._getPageSizeLabel(i),o=i===this.templateOptions.layout;return x("calcite-list-item",{description:a,key:`portal-template-${i}-${o}`,label:e?.label?.replaceAll("_"," ")??t.untitled,selected:o,title:e.description??"",value:i},!a&&o&&e.layoutItem?.id?x("calcite-loader",{inline:!0,key:`portal-template-loader-${l}`,label:"loading",scale:"s",slot:"content-end"}):null)})):null,d=i.length&&e?i.toArray().filter((({label:e,layoutItem:t})=>!F(e)&&!n.includes(t?.id))).sort(((e,t)=>(e.label??"")>(t.label??"")?1:-1)).map(((e,l)=>{const i=e.layoutItem?.id??e.layout,a=this._getPageSizeLabel(i),o=i===this.templateOptions.layout;return x("calcite-list-item",{description:a,key:`default-template-${l}`,label:e?.label?.replaceAll("_"," ")??t.untitled,selected:o,title:e.description??"",value:i},!a&&o&&e.layoutItem?.id?x("calcite-loader",{inline:!0,key:`default-template-loader-${l}`,label:"loading",scale:"s",slot:"content-end"}):null)})):null,u=!a?.layout?.choiceList.length||e&&d?.length?null:a.layout.choiceList.map((e=>({label:t[e]??e.replaceAll("_"," "),value:e}))).sort(((e,t)=>e.label>t.label?1:0)).map((({label:e,value:t},l)=>x("calcite-list-item",{description:this._getPageSizeLabel(t),key:`service-template-${l}`,label:e,selected:t===this.templateOptions.layout,value:t}))),m=(r?.length??0)+(c?.length??0)+(d?.length??0)+(u?.length??0)>15;return x("calcite-flow-item",{bind:this,closable:!1,heading:t.chooseTemplate,key:"template-flow-item",onCalciteFlowItemBack:e=>{e.preventDefault(),this._showTemplates=!1}},x("div",{class:S.templateSelectFlowItemContainer},x("div",{class:S.templateSelectFlowItemContent},this.browseTemplateButtonOnClick?x("calcite-button",{appearance:"outline",class:S.browseTemplateButtonContainer,key:"browse-template-button",onclick:this.browseTemplateButtonOnClick},"Browse Templates"):null,x("calcite-list",{filterEnabled:m,key:"template-list",selectionMode:"single-persist",onCalciteListChange:({target:e})=>this._applyTemplate(e.selectedItems[0].value)},r?.length?x("div",{key:"my-templates"},x("div",{class:S.templateSelectFlowItemListHeading},t.myTemplates,x("calcite-chip",{appearance:"outline",kind:"neutral",scale:"s",value:t.beta},t.beta)),r):null,c?.length?x("div",{key:"org-templates"},x("div",{class:S.templateSelectFlowItemListHeading},t.organizationTemplates,s?x("calcite-chip",{appearance:"outline",kind:"neutral",scale:"s",value:t.beta},t.beta):null),c):null,r?.length||c?.length?d?.length?x("div",{key:"default-templates"},x("div",{class:S.templateSelectFlowItemListHeading},t.defaultTemplates),d):null:d,r?.length||c?.length?u?.length?x("div",{key:"service-templates"},x("div",{class:S.templateSelectFlowItemListHeading},t.defaultTemplates),u):null:u)),x("div",{class:S.templateButtonContainer},x("calcite-button",{class:S.templateDoneButton,onclick:()=>this._showTemplates=!1},this.messagesCommon.done))))}_renderCustomTextElementSection(){const{customTextElements:e}=this.templateOptions;return e?x("div",{class:S.formSectionContainer,key:"custom-text-elements"},e.map(((e,t)=>{const[l,i]=Object.entries(e)[0];return"date"===l?null:x("calcite-label",{key:`custom-text-elements-${l}-${t}`},l,x("calcite-input",{bind:this,"data-input-custom":!0,"data-input-name":l,value:i??"",onCalciteInputInput:this._updateInputValue}))}))):null}async _applyTemplate(e){if(this._abortController&&(this._abortController.abort(),this._abortController=null),!e)return;const t=this.viewModel.defaultTemplates.find((({layoutItem:t})=>e===t?.id))??this.viewModel.browseTemplates.find((({layoutItem:t})=>e===t?.id));if(!t)return this.templateOptions.layout=e,void(this.templateOptions.layoutItem=null);const{layoutItem:l}=t,a=t.format??this.templateOptions.format,o=l?.id??t.layout??this.templateOptions.layout;if(this.templateOptions.layout=o,!t.layoutOptions)try{this._abortController=new AbortController,await this.viewModel.fetchLayoutTemplateInfo(t,{signal:this._abortController.signal})}catch(p){return}finally{this._abortController=null}const n=t.layoutOptions?.legend??this.templateOptions.legendEnabled,s=t.layoutOptions?.northArrow??this.templateOptions.northArrowEnabled,r=o?this.viewModel.effectiveTemplateCustomTextElements[o]:null,c=r?i(r):null;this.templateOptions.set({customTextElements:c,format:a,layout:o,layoutItem:l,legendEnabled:n,northArrowEnabled:s})}_renderTitleOrFileNameSection(){const{title:e,fileName:t,titlePlaceHolder:l,fileNamePlaceHolder:i}=this.messages,a=this._selectedTab===k.layout?e:t,o=this._selectedTab===k.layout?l:i,n=this._selectedTab===k.layout?this.templateOptions.title:this.templateOptions.fileName;return x("div",{class:S.formSectionContainer,key:a},x("calcite-label",null,a,x("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===k.layout||"mapOnlyTab"===t&&this._selectedTab===k.mapOnly||"exportTab"===t&&this._selectedTab===k.export)&&(e.focus(),this._activeTabFocusRequested=!1)}_renderLoader(){const e={[S.loader]:this._awaitingServerResponse};return x("div",{class:this.classes(e),key:"loader"})}_createFileLink(e,t){const l=t||this.messages.untitled,i=e.format.toLowerCase(),a=i.includes("png")?"png":i,o=l+a;return void 0!==this._exportedFileNameMap[o]?this._exportedFileNameMap[o]++:this._exportedFileNameMap[o]=0,new h({name:l,extension:a,count:this._exportedFileNameMap[o]})}_resetToCurrentScale(){this.templateOptions.scale=this.viewModel.view?.scale}_updateCustomTextElementValue(e,t,l){e.find((e=>{const[l]=Object.entries(e)[0];return l===t}))[t]=l}_updateInputValue(e){const t=e.target,l=t.getAttribute("data-input-name"),i=!!t["data-input-custom"],{templateOptions:a}=this;if(i)return void this._updateCustomTextElementValue(a.customTextElements,l,t.value);let o;if("number"===t.type){const e=Number(t.value);if(!E(e)){const e=a[l];return void(t.value=`${e}`)}o=e}else o=t.value;a[l]=o}_handleDPIChange(e){const{templateOptions:t}=this,l=t.dpi;this._updateInputValue(e);const i=t.dpi,{height:a,width:o}=M(i,l,t.width,t.height);t.height=a,t.width=o}_handlePrintMap(){this._pendingExportScroll=!0;const{templateOptions:e}=this,t=this.viewModel.toPrintTemplate(e),l=this._selectedTab===k.layout?t.layoutOptions?.titleText:e.fileName,i=this._createFileLink(t,l);this.exportedLinks.add(i),this.emit("submit",{link:i}),this._selectedTab=k.export,this.viewModel.print(t).then((e=>{i.set({url:e&&e.url,state:"ready"})})).catch((e=>{i.set({error:e,state:"error"})})).then((()=>{this.emit("complete",{link:i}),this.scheduleRender()}))}_switchInput(){[this.templateOptions.width,this.templateOptions.height]=[this.templateOptions.height,this.templateOptions.width]}_scrollExportIntoView(){if(!this._pendingExportScroll)return;this._pendingExportScroll=!1;const e=this._rootNode;if(!e)return;const{clientHeight:t,scrollHeight:l}=e,i=l-t;i>0&&(e.scrollTop=i)}_toggleInputValue(e){const t=e.target,l=t.getAttribute("data-option-name");this.templateOptions[l]=t.checked,"scaleEnabled"===l&&this._resetToCurrentScale()}_renderExportedLink(e){const t=this.messages,l=e.map((e=>{const{error:l,url:i,state:a}=e,o=e.formattedName??"",r="error"===a,c="pending"===a,p="ready"===a;let d=i||null;d&&(d=n(d));const u=s(i,location.href);let m;m=c?t.pending:p?t.ready:t.errorMessage;const h=r?"print-task:cim-symbol-unsupported"===l?.name?t.exportWebMapCIMError:t.exportWebMapError:"";return x("calcite-list-item",{"aria-label":m,class:S.exportedFile,"data-item":e,description:c?t.generatingExport:h||(u?t.ready:t.linkReady),key:o,label:o,title:h,onCalciteListItemSelect:this._handleLinkClick},c?x("calcite-loader",{class:S.exportedFileLoader,inline:!0,key:`${o}-loader`,label:t.generatingExport,scale:"m",slot:"content-start"}):x("calcite-icon",{icon:j(e),key:`${o}-start-icon`,scale:"s",slot:"content-start"}),p?x("calcite-icon",{"aria-label":`${o}. ${t.linkReady}`,icon:u?"download-to":"launch",key:`${o}-end-icon`,scale:"s",slot:"content-end"}):null,c?null:x("calcite-action",{"aria-label":`${h}`,"data-item":e,icon:"x",key:`${o}-action`,onclick:this._removeLink,slot:"actions-end",text:`${h}`}))}));return x("calcite-list",{filterEnabled:e?.length>10},l)}_toggleLayoutPanel(e){const t=e.target;this._toggleTab(t.getAttribute("data-tab-id"))}_toggleTab(e,t=!0){if(this._selectedTab=e,this._selectedTab===k.mapOnly)this.templateOptions.layout=I,this.templateOptions.layoutItem=null,this.templateOptions.customTextElements=null;else if(this._selectedTab===k.layout){const e=this._selectedLayout??(this.includeDefaultTemplates&&this.viewModel.defaultTemplates.length?null:this.viewModel.templatesInfo?.layout?.defaultValue);e?this._applyTemplate(e):(this.templateOptions.layout=null,this.templateOptions.layoutItem=null,this.templateOptions.customTextElements=null)}t&&(this._activeTabFocusRequested=!0)}_handleLayoutPanelKeyDown(e){const{key:t}=e,l=e.target.getAttribute("data-tab-id");if(w(t))return this._toggleTab(l),e.preventDefault(),void e.stopPropagation();if("ArrowLeft"===t||"ArrowRight"===t){switch(l){case k.layout:this._toggleTab("ArrowLeft"===t?k.export:k.mapOnly);break;case k.mapOnly:this._toggleTab("ArrowLeft"===t?k.layout:k.export);break;case k.export:this._toggleTab("ArrowLeft"===t?k.mapOnly:k.layout)}e.preventDefault(),e.stopPropagation()}}};e([r()],B.prototype,"_showTemplates",void 0),e([r()],B.prototype,"allowedFormats",null),e([r()],B.prototype,"allowedLayouts",null),e([r()],B.prototype,"browseTemplateButtonOnClick",void 0),e([r()],B.prototype,"error",null),e([r({type:O})],B.prototype,"exportedLinks",void 0),e([r()],B.prototype,"extraParameters",null),e([r()],B.prototype,"headingLevel",void 0),e([r()],B.prototype,"icon",null),e([r()],B.prototype,"includeDefaultTemplates",null),e([r()],B.prototype,"label",null),e([r(),T("esri/widgets/Print/t9n/Print")],B.prototype,"messages",void 0),e([r(),T("esri/t9n/common")],B.prototype,"messagesCommon",void 0),e([r(),T("esri/core/t9n/Units")],B.prototype,"messagesUnits",void 0),e([r()],B.prototype,"portal",null),e([r()],B.prototype,"showPrintAreaEnabled",null),e([r()],B.prototype,"printServiceUrl",null),e([r()],B.prototype,"templateCustomTextElements",null),e([r()],B.prototype,"templateOptions",null),e([r()],B.prototype,"view",null),e([r({type:b})],B.prototype,"viewModel",void 0),B=e([c("esri.widgets.Print")],B);const D=B;export{D as default};
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[6107,9377,3069,9062],{70668:(e,t,r)=>{r.d(t,{A:()=>y});var i=r(90237),n=r(69540),o=r(25482),s=r(88930),l=r(10107),a=(r(44208),r(53966),r(87811),r(93223)),d=r(40608),u=r(73133);let p=class extends((0,n.O)(o.oY)){constructor(e){super(e),this.unit="milliseconds",this.value=0}toMilliseconds(){return(0,s.t)(this.value,this.unit,"milliseconds")}};(0,i._)([(0,a.e)(u.j,{nonNullable:!0})],p.prototype,"unit",void 0),(0,i._)([(0,l.MZ)({type:Number,json:{write:!0},nonNullable:!0})],p.prototype,"value",void 0),p=(0,i._)([(0,d.$)("esri.TimeInterval")],p);const y=p},32587:(e,t,r)=>{r.d(t,{A:()=>o});var i=r(62788),n=r(95488);class o{constructor(e){this._observable=new n.I,this._map=new Map(e)}get size(){return(0,i.gc)(this._observable),this._map.size}clear(){this._map.size>0&&(this._map.clear(),this._observable.notify())}delete(e){const t=this._map.delete(e);return t&&this._observable.notify(),t}entries(){return(0,i.gc)(this._observable),this._map.entries()}forEach(e,t){(0,i.gc)(this._observable),this._map.forEach(((r,i)=>e.call(t,r,i,this)),t)}get(e){return(0,i.gc)(this._observable),this._map.get(e)}has(e){return(0,i.gc)(this._observable),this._map.has(e)}keys(){return(0,i.gc)(this._observable),this._map.keys()}set(e,t){return this._map.set(e,t),this._observable.notify(),this}values(){return(0,i.gc)(this._observable),this._map.values()}[Symbol.iterator](){return(0,i.gc)(this._observable),this._map[Symbol.iterator]()}get[Symbol.toStringTag](){return this._map[Symbol.toStringTag]}}},44794:(e,t,r)=>{r.d(t,{v:()=>l});var i=r(4718),n=r(62788),o=r(95488);class s{constructor(e,t){this._observable=new o.I,this._value=e,this._equalityFunction=t}get value(){return(0,n.gc)(this._observable),this._value}set value(e){this._equalityFunction(e,this._value)||(this._value=e,this._observable.notify())}mutate(e){e(this._value),this._observable.notify()}}function l(e,t=i.gh){return new s(e,t)}},39516:(e,t,r)=>{async function i(e,t){const{WhereClause:i}=await Promise.all([r.e(835),r.e(4800)]).then(r.bind(r,50835));return i.create(e,t)}function n(e,t){return"1=1"===e?t??e:"1=1"===t?e??t:null!=e&&""!==e?null!=t&&""!==t?`(${e}) AND (${t})`:e:t}r.d(t,{G:()=>i,m:()=>n})},3330:(e,t,r)=>{r.d(t,{GB:()=>n,Qo:()=>s,Y4:()=>o});var i=r(96285);class n{}function o(e){return e instanceof i.bo?e===n.instance:"unknown"===e?.toString().toLowerCase()}function s(e){return o(e)?n.instance:e}n.instance=new i.oh("Etc/UTC")},13069:(e,t,r)=>{r.d(t,{lk:()=>n,vD:()=>s,yS:()=>o});const i="randomUUID"in crypto;function n(){if(i)return crypto.randomUUID();const e=crypto.getRandomValues(new Uint16Array(8));e[3]=4095&e[3]|16384,e[4]=16383&e[4]|32768;const t=t=>e[t].toString(16).padStart(4,"0");return t(0)+t(1)+"-"+t(2)+"-"+t(3)+"-"+t(4)+"-"+t(5)+t(6)+t(7)}function o(){return`{${n().toUpperCase()}}`}function s(){return`{${n()}}`}},70328:(e,t,r)=>{r.d(t,{BI:()=>f,Ej:()=>u,Hq:()=>d,Ie:()=>h,Jt:()=>m,Ne:()=>p,RF:()=>l,aI:()=>_,fA:()=>o,hZ:()=>c,iT:()=>a,is:()=>g,qv:()=>v,vI:()=>y,v_:()=>w,vt:()=>n,w1:()=>s});var i=r(5443);function n(e=w){return[e[0],e[1],e[2],e[3],e[4],e[5]]}function o(e,t,r,i,o,s,l=n()){return l[0]=e,l[1]=t,l[2]=r,l[3]=i,l[4]=o,l[5]=s,l}function s(e,t){const r=isFinite(e[2])||isFinite(e[5]);return new i.A(r?{xmin:e[0],xmax:e[3],ymin:e[1],ymax:e[4],zmin:e[2],zmax:e[5],spatialReference:t}:{xmin:e[0],xmax:e[3],ymin:e[1],ymax:e[4],spatialReference:t})}function l(e,t){e[0]=Math.min(e[0],t[0]),e[1]=Math.min(e[1],t[1]),e[2]=Math.min(e[2],t[2]),e[3]=Math.max(e[3],t[3]),e[4]=Math.max(e[4],t[4]),e[5]=Math.max(e[5],t[5])}function a(e,t){e[0]=Math.min(e[0],t[0]),e[1]=Math.min(e[1],t[1]),e[2]=Math.min(e[2],t[2]),e[3]=Math.max(e[3],t[0]),e[4]=Math.max(e[4],t[1]),e[5]=Math.max(e[5],t[2])}function d(e,t,r=0,i=t.length/3){let n=e[0],o=e[1],s=e[2],l=e[3],a=e[4],d=e[5];for(let e=0;e<i;e++)n=Math.min(n,t[r+3*e]),o=Math.min(o,t[r+3*e+1]),s=Math.min(s,t[r+3*e+2]),l=Math.max(l,t[r+3*e]),a=Math.max(a,t[r+3*e+1]),d=Math.max(d,t[r+3*e+2]);e[0]=n,e[1]=o,e[2]=s,e[3]=l,e[4]=a,e[5]=d}function u(e,t=[0,0,0]){return t[0]=function(e){return e[0]>=e[3]?0:e[3]-e[0]}(e),t[1]=function(e){return e[1]>=e[4]?0:e[4]-e[1]}(e),t[2]=function(e){return e[2]>=e[5]?0:e[5]-e[2]}(e),t}function p(e,t,r=e){return r[0]=t[0],r[1]=t[1],r[2]=t[2],r!==e&&(r[3]=e[3],r[4]=e[4],r[5]=e[5]),r}function y(e,t,r=e){return r[3]=t[0],r[4]=t[1],r[5]=t[2],r!==e&&(r[0]=e[0],r[1]=e[1],r[2]=e[2]),e}function c(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e}function h(e){return e?c(e,v):n(v)}function m(e,t){return e[0]=t[0],e[1]=t[1],e[2]=Number.NEGATIVE_INFINITY,e[3]=t[2],e[4]=t[3],e[5]=Number.POSITIVE_INFINITY,e}function f(e,t,r,i,n){return e[0]=t,e[1]=r,e[2]=Number.NEGATIVE_INFINITY,e[3]=i,e[4]=n,e[5]=Number.POSITIVE_INFINITY,e}function g(e){return 6===e.length}function _(e,t,r){if(null==e||null==t)return e===t;if(!g(e)||!g(t))return!1;if(r){for(let i=0;i<e.length;i++)if(!r(e[i],t[i]))return!1}else for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}r(19419);const v=[1/0,1/0,1/0,-1/0,-1/0,-1/0],w=[0,0,0,0,0,0];n()},79003:(e,t,r)=>{r.r(t),r.d(t,{default:()=>pe});var i=r(90237),n=r(78888),o=r(5503),s=r(49186),l=r(91869),a=r(92071),d=r(74887),u=r(84952),p=r(10107),y=(r(44208),r(53966),r(87811),r(40608)),c=r(4146),h=r(36563),m=r(55359),f=r(32587),g=r(36708),_=r(44794),v=r(56507),w=r(63074),b=r(25036),M=r(10873),F=r(91880),x=r(1873);let Z=class extends((0,b.j)((0,w.dM)((0,a.P)(c.A)))){constructor(e){super(e),this._layerCache=new m.q(20,(e=>e.destroy())),this._oidToReference=new f.A,this._layerToReference=new Map,this.layers=new o.A,this.maximumVisibleSublayers=10,this.opacity=1,this.parent=null,this.persistenceEnabled=!0,this.title="Layers in view",this.type="catalog-dynamic-group",this.visible=!0}initialize(){this.addHandles([this.layers.on("after-add",(({item:e})=>{e.parent=this})),this.layers.on("after-remove",(({item:e})=>{e.parent=null})),(0,g.wB)((()=>this._orderBy),(()=>{this._updateLayerSortValues(),this._sortAllLayers()}))])}load(e){return this.addResolvingPromise(this.parent.load()),Promise.resolve(this)}destroy(){this._layerCache.destroy(),this._oidToReference.clear(),this._layerToReference.clear()}get _orderBy(){return this.parent?this.parent.orderBy?.find((e=>!e.valueExpression&&e.field))??new F.A({field:this.parent.objectIdField}):null}get _referenceComparator(){const e=this._orderBy;if(!this.parent||!e)return()=>0;const t=this.parent.fieldsIndex.get(e.field),r=(0,x.FM)(t?.toJSON().type,"descending"===e.order),i=(0,x.FM)("esriFieldTypeOID","descending"===e.order);return(e,t)=>r(t.sortValue,e.sortValue)||i(t.objectId,e.objectId)}get fullExtent(){return this.parent?.fullExtent??null}get updating(){return(0,l.Bs)(this._oidToReference,(e=>null!=e.pending))}acquireLayer(e){if(this.destroyed)return(0,h.hA)();const t=this._getLayerReference(e);return t.count++,(0,h.hA)((()=>{t.count--,t.count||this._destroyLayerReference(t)}))}_getLayerReference(e){const t=e.getObjectId();return(0,l.tE)(this._oidToReference,t,(()=>{const t=e.getObjectId(),r=`${t}`,i=e.getAttribute(this.parent.itemSourceField),n=new T(e,t,i),o=this._layerCache.pop(r);return o?(this._addLayer(n,o),n):(n.pending=this.parent.createLayerFromFootprint(e).then((e=>{n.count?this._addLayer(n,e):(this.destroyed||this._layerCache.get(r)||this._layerCache.put(r,e),n.layer=null)})).catch((()=>{})).finally((()=>{n.pending=null})),n)}))}_destroyLayerReference(e){e.layer&&(this._layerToReference.delete(e.layer),this.layers.remove(e.layer),this.destroyed?e.layer.destroy():this._layerCache.put(`${e.objectId}`,e.layer),e.layer=null),this._oidToReference.delete(e.objectId)}_addLayer(e,t){e.layer=t,t.persistenceEnabled=!1,this._layerToReference.set(t,e),this._updateLayerSortValue(e),this.layers.add(t),this._sortAllLayers()}_updateLayerSortValues(){for(const e of this._layerToReference.values())this._updateLayerSortValue(e)}_updateLayerSortValue(e){this._orderBy&&(e.sortValue=e.footprint.getAttribute(this._orderBy.field))}_sortAllLayers(){this.layers.sort(((e,t)=>this._referenceComparator(this._layerToReference.get(e),this._layerToReference.get(t))))}};(0,i._)([(0,p.MZ)()],Z.prototype,"_orderBy",null),(0,i._)([(0,p.MZ)({readOnly:!0})],Z.prototype,"_referenceComparator",null),(0,i._)([(0,p.MZ)({type:["show","hide","hide-children"],json:{write:!0}})],Z.prototype,"listMode",void 0),(0,i._)([(0,p.MZ)({readOnly:!0})],Z.prototype,"fullExtent",null),(0,i._)([(0,p.MZ)({type:String,json:{origins:{service:{read:!1},"portal-item":{read:!1}},write:{ignoreOrigin:!0}}})],Z.prototype,"id",void 0),(0,i._)([(0,p.MZ)({readOnly:!0})],Z.prototype,"layers",void 0),(0,i._)([(0,p.MZ)({type:v.jz,range:{min:0,max:50},json:{write:!0,default:10}})],Z.prototype,"maximumVisibleSublayers",void 0),(0,i._)([(0,p.MZ)(M.ke)],Z.prototype,"opacity",void 0),(0,i._)([(0,p.MZ)({clonable:!1})],Z.prototype,"parent",void 0),(0,i._)([(0,p.MZ)({type:String,nonNullable:!0,json:{write:{ignoreOrigin:!0,isRequired:!0}}})],Z.prototype,"title",void 0),(0,i._)([(0,p.MZ)({json:{read:!1}})],Z.prototype,"type",void 0),(0,i._)([(0,p.MZ)({readOnly:!0})],Z.prototype,"updating",null),(0,i._)([(0,p.MZ)({type:Boolean,json:{name:"visibility",write:!0}})],Z.prototype,"visible",void 0),Z=(0,i._)([(0,y.$)("esri.layers.catalog.CatalogDynamicGroupLayer")],Z);const I=Z;class T{constructor(e,t,r){this.footprint=e,this.objectId=t,this.itemSource=r,this.count=0,this.layer=null,this.sortValue=void 0,this._pending=(0,_.v)(null)}get pending(){return this._pending.value}set pending(e){this._pending.value=e}}var S=r(13874),O=(r(86162),r(94409),r(65345),r(42980),r(39290),r(92438),r(96576)),j=(r(93618),r(65494),r(15036)),E=r(4718),A=r(35666),R=r(4206),N=r(87718),L=r(30524),V=r(81457),D=r(39383),B=r(30291),P=r(94985);let q=class extends((0,b.j)((0,N.F)((0,w.dM)((0,a.P)(c.A))))){constructor(e){super(e),this.charts=null,this.editingEnabled=!0,this.elevationInfo=null,this.formTemplate=null,this.labelingInfo=null,this.labelsVisible=!0,this.legendEnabled=!0,this.maxScale=0,this.minScale=0,this.opacity=1,this.parent=null,this.persistenceEnabled=!0,this.popupEnabled=!0,this.popupTemplate=null,this.title="Footprints",this.type="catalog-footprint",this.visible=!0}load(e){return this.addResolvingPromise(this._doLoad(e)),Promise.resolve(this)}async _doLoad(e){await this.parent.load(e),(0,L.yp)(this.renderer,this.fieldsIndex),this.addHandles([this.parent.on("apply-edits",(e=>this.emit("apply-edits",e))),this.parent.on("edits",(e=>this.emit("edits",e))),this.parent.on("refresh",(e=>this.emit("refresh",e)))])}get apiKey(){return this.parent?.apiKey}get capabilities(){return this.parent?.capabilities}get customParameters(){return this.parent?.customParameters}get dateFieldsTimeZone(){return this.parent?.dateFieldsTimeZone??null}get datesInUnknownTimezone(){return this.parent?.datesInUnknownTimezone??!1}get definitionExpression(){return this.parent?.definitionExpression}get editingInfo(){return this.parent?.editingInfo}get effectiveCapabilities(){return this.parent?.effectiveCapabilities}get createQueryVersion(){return this.parent?.createQueryVersion}get defaultPopupTemplate(){return this.createPopupTemplate()}get displayField(){return this.parent?.displayField}get effectiveEditingEnabled(){return!1}get fields(){return this.parent?.fields}get fieldsIndex(){return this.parent?.fieldsIndex}get fullExtent(){return this.parent?.fullExtent}get geometryFieldsInfo(){return this.parent?.geometryFieldsInfo}get geometryType(){return this.parent?.geometryType}get globalIdField(){return this.parent?.globalIdField}get hasM(){return this.parent?.hasM??!1}get hasZ(){return this.parent?.hasZ??!1}get objectIdField(){return this.parent?.objectIdField}get orderBy(){return this.parent?.orderBy??null}get outFields(){return this.parent?.outFields}get parsedUrl(){return this.parent?.parsedUrl??null}get preferredTimeZone(){return this.parent?.preferredTimeZone??null}set renderer(e){(0,L.yp)(e,this.fieldsIndex),this._set("renderer",e)}get renderer(){return this._isOverridden("renderer")?this._get("renderer"):function(){const e=new P.A({style:"solid",color:[0,0,0,0],outline:{style:"solid",color:[96,96,96,.75],width:.75}});return new O.A({symbol:e})}()}get returnM(){return this.parent?.returnM}get returnZ(){return this.parent?.returnZ}get source(){return this.parent?.source}get timeExtent(){return this.parent?.timeExtent}get timeInfo(){return this.parent?.timeInfo}get timeOffset(){return this.parent?.timeOffset}get typeIdField(){return this.parent?.typeIdField}get types(){return this.parent?.types}get useViewTime(){return this.parent?.useViewTime??!0}get version(){return this.parent?.version}async applyEdits(e,t){return await this.load(),this.parent.applyEdits(e,t)}createPopupTemplate(e){const t={fields:this.fields,objectIdField:this.objectIdField,title:this.title};return(0,B.tn)(t,e)}createQuery(){return this.parent?.createQuery()}getField(e){return this.parent?.getField(e)}getFieldDomain(e,t){return this.parent?.getFieldDomain(e,t)}async queryExtent(e,t){return await this.load(),this.parent.queryExtent(e,t)}async queryFeatures(e,t){return await this.load(),this.parent.queryFeatures(e,t)}async queryFeatureCount(e,t){return await this.load(),this.parent.queryFeatureCount(e,t)}async queryObjectIds(e,t){return await this.load(),this.parent.queryObjectIds(e,t)}};(0,i._)([(0,p.MZ)({readOnly:!0})],q.prototype,"apiKey",null),(0,i._)([(0,p.MZ)({readOnly:!0})],q.prototype,"capabilities",null),(0,i._)([(0,p.MZ)({readOnly:!0})],q.prototype,"customParameters",null),(0,i._)([(0,p.MZ)()],q.prototype,"dateFieldsTimeZone",null),(0,i._)([(0,p.MZ)({readOnly:!0})],q.prototype,"datesInUnknownTimezone",null),(0,i._)([(0,p.MZ)({readOnly:!0})],q.prototype,"definitionExpression",null),(0,i._)([(0,p.MZ)({readOnly:!0})],q.prototype,"editingInfo",null),(0,i._)([(0,p.MZ)({readOnly:!0})],q.prototype,"effectiveCapabilities",null),(0,i._)([(0,p.MZ)({json:{origins:{"web-scene":{write:!1}},write:!0}})],q.prototype,"charts",void 0),(0,i._)([(0,p.MZ)({readOnly:!0})],q.prototype,"createQueryVersion",null),(0,i._)([(0,p.MZ)({readOnly:!0})],q.prototype,"defaultPopupTemplate",null),(0,i._)([(0,p.MZ)()],q.prototype,"displayField",null),(0,i._)([(0,p.MZ)({type:Boolean,nonNullable:!0,json:{name:"enableEditing",write:!0,origins:{"web-scene":{read:!1,write:!1}}}})],q.prototype,"editingEnabled",void 0),(0,i._)([(0,p.MZ)({readOnly:!0})],q.prototype,"effectiveEditingEnabled",null),(0,i._)([(0,p.MZ)((()=>{const e=(0,E.o8)(M.Yj);return e.json.origins["web-map"]={read:!1,write:!1},e})())],q.prototype,"elevationInfo",void 0),(0,i._)([(0,p.MZ)({readOnly:!0})],q.prototype,"fields",null),(0,i._)([(0,p.MZ)({readOnly:!0})],q.prototype,"fieldsIndex",null),(0,i._)([(0,p.MZ)({type:R.A,json:{name:"formInfo",write:!0,origins:{"web-scene":{read:!1,write:!1}}}})],q.prototype,"formTemplate",void 0),(0,i._)([(0,p.MZ)({readOnly:!0})],q.prototype,"fullExtent",null),(0,i._)([(0,p.MZ)({readOnly:!0})],q.prototype,"geometryFieldsInfo",null),(0,i._)([(0,p.MZ)({readOnly:!0})],q.prototype,"geometryType",null),(0,i._)([(0,p.MZ)({readOnly:!0})],q.prototype,"globalIdField",null),(0,i._)([(0,p.MZ)({readOnly:!0})],q.prototype,"hasM",null),(0,i._)([(0,p.MZ)({readOnly:!0})],q.prototype,"hasZ",null),(0,i._)([(0,p.MZ)({type:String,json:{origins:{service:{read:!1},"portal-item":{read:!1}},write:{ignoreOrigin:!0}}})],q.prototype,"id",void 0),(0,i._)([(0,p.MZ)({type:[V.A],json:{name:"layerDefinition.drawingInfo.labelingInfo",read:D.w,write:!0}})],q.prototype,"labelingInfo",void 0),(0,i._)([(0,p.MZ)(M.kF)],q.prototype,"labelsVisible",void 0),(0,i._)([(0,p.MZ)(M.fV)],q.prototype,"legendEnabled",void 0),(0,i._)([(0,p.MZ)({type:["show","hide"],json:{write:!0}})],q.prototype,"listMode",void 0),(0,i._)([(0,p.MZ)((()=>{const e=(0,E.o8)(M.hG);return e.json.origins.service.read=!1,e})())],q.prototype,"maxScale",void 0),(0,i._)([(0,p.MZ)((()=>{const e=(0,E.o8)(M.hn);return e.json.origins.service.read=!1,e})())],q.prototype,"minScale",void 0),(0,i._)([(0,p.MZ)({readOnly:!0})],q.prototype,"objectIdField",null),(0,i._)([(0,p.MZ)(M.ke)],q.prototype,"opacity",void 0),(0,i._)([(0,p.MZ)({readOnly:!0})],q.prototype,"orderBy",null),(0,i._)([(0,p.MZ)({readOnly:!0})],q.prototype,"outFields",null),(0,i._)([(0,p.MZ)({clonable:!1})],q.prototype,"parent",void 0),(0,i._)([(0,p.MZ)({readOnly:!0})],q.prototype,"parsedUrl",null),(0,i._)([(0,p.MZ)(M.M6)],q.prototype,"popupEnabled",void 0),(0,i._)([(0,p.MZ)({type:S.A,json:{name:"popupInfo",write:!0}})],q.prototype,"popupTemplate",void 0),(0,i._)([(0,p.MZ)({readOnly:!0})],q.prototype,"preferredTimeZone",null),(0,i._)([(0,p.MZ)({types:j.H,json:{origins:{"web-scene":{types:j.X}},name:"layerDefinition.drawingInfo.renderer",write:{overridePolicy(e,t){return{ignoreOrigin:this.originIdOf(t)<A.Gr.PORTAL_ITEM}}}}})],q.prototype,"renderer",null),(0,i._)([(0,p.MZ)({readOnly:!0})],q.prototype,"returnM",null),(0,i._)([(0,p.MZ)({readOnly:!0})],q.prototype,"returnZ",null),(0,i._)([(0,p.MZ)({readOnly:!0})],q.prototype,"source",null),(0,i._)([(0,p.MZ)({readOnly:!0})],q.prototype,"timeExtent",null),(0,i._)([(0,p.MZ)({readOnly:!0})],q.prototype,"timeInfo",null),(0,i._)([(0,p.MZ)({readOnly:!0})],q.prototype,"timeOffset",null),(0,i._)([(0,p.MZ)({type:String,nonNullable:!0,json:{write:{ignoreOrigin:!0,isRequired:!0}}})],q.prototype,"title",void 0),(0,i._)([(0,p.MZ)({json:{read:!1}})],q.prototype,"type",void 0),(0,i._)([(0,p.MZ)({readOnly:!0})],q.prototype,"typeIdField",null),(0,i._)([(0,p.MZ)({readOnly:!0})],q.prototype,"types",null),(0,i._)([(0,p.MZ)({readOnly:!0})],q.prototype,"useViewTime",null),(0,i._)([(0,p.MZ)({type:Boolean,json:{name:"visibility",write:!0}})],q.prototype,"visible",void 0),q=(0,i._)([(0,y.$)("esri.layers.catalog.CatalogFootprintLayer")],q);const $=q;var U=r(72593),C=r(52136),G=r(18768),J=r(69208),z=r(47685),k=r(87796),Q=r(16131),Y=r(32756),K=r(8303),H=r(54310),X=r(82935),W=r(15426),ee=r(33143),te=r(17036),re=r(4513),ie=r(91908),ne=r(20655),oe=r(80812),se=r(39131),le=r(61956);const ae=(0,te.p)();function de(e,t,r,i){const n=e.write({},i);(function(e){if(null==e)return!0;const t=Object.keys(e);return!t.length||1===t.length&&"id"===t[0]})(n)||(t[r]=n)}let ue=class extends((0,k.j)((0,z.w6)((0,w.dM)((0,Y.f)((0,X.e)((0,b.j)((0,H.J)((0,G.b)((0,Q.q)((0,K.A)((0,a.P)((0,J.d)((0,C.p)(c.A)))))))))))))){constructor(e){super(e),this._portals=new Map,this._layerToFootprint=new WeakMap,this.drawOrderField="cd_draworder",this.dynamicGroupLayer=new I({parent:this}),this.elevationInfo=null,this.fields=null,this.fieldsIndex=null,this.floorInfo=null,this.footprintLayer=new $({parent:this}),this.itemNameField="cd_itemname",this.itemSourceField="cd_itemsource",this.itemTypeField="cd_itemtype",this.layers=new o.A([this.dynamicGroupLayer,this.footprintLayer]),this.maxScaleField="cd_maxscale",this.minScaleField="cd_minscale",this.orderBy=null,this.outFields=null,this.supportedSourceTypes=new Set(["Catalog Layer"]),this.source=new U.default({layer:this,supportedSourceTypes:this.supportedSourceTypes}),this.type="catalog",this.typeIdField=null,this.types=null}load(e){const t=null!=e?e.signal:null,r=this.loadFromPortal({supportedTypes:["Feature Service"]},e).catch(d.QP).then((async()=>{const{url:e,source:r,portalItem:i}=this;if(!e)throw new s.A("catalog-layer:missing-url","Catalog layer must be created with a url");if(null==this.layerId){const r=await this._fetchFirstValidLayerId(t);if(null==r)throw new s.A("catalog-layer:missing-layerId","There is no Catalog Layer in the service",{service:e});this.layerId=r}await r.load({signal:t});const{sourceJSON:n}=r;n&&(this.sourceJSON=n,this.read(n,{origin:"service",portalItem:i,portal:i?.portal,url:this.parsedUrl}))})).then((()=>{const e=[this.itemNameField,this.itemSourceField,this.itemTypeField,this.minScaleField,this.maxScaleField],t=e.filter((e=>!this.fieldsIndex.has(e)));if(t.length)throw new s.A("catalog-layer:missing-fields","There are missing fields to operate properly",{requiredFields:e,missingFields:t})})).then((()=>(0,W.VA)(this,"load",e)));return this.addResolvingPromise(r),Promise.resolve(this)}destroy(){this.footprintLayer.destroy(),this.dynamicGroupLayer.destroy();for(const e of this._portals.values())e.destroy();this._portals.clear()}get createQueryVersion(){return this.commitProperty("definitionExpression"),this.commitProperty("timeExtent"),this.commitProperty("timeOffset"),this.commitProperty("geometryType"),this.commitProperty("capabilities"),(this._get("createQueryVersion")??0)+1}get editingEnabled(){return this.loaded&&null!=this.capabilities&&this.capabilities.operations.supportsEditing&&this.userHasEditingPrivileges}get effectiveEditingEnabled(){return!1}get parsedUrl(){const e=(0,u.An)(this.url);return null!=e&&null!=this.layerId&&(e.path=(0,u.fj)(e.path,this.layerId.toString())),e}async applyEdits(e,t){return(0,W.ct)(this,e,t)}on(e,t){return super.on(e,t)}async createLayerFromFootprint(e){const t=await this._createLayer(e);return this._configureLayer(t,e),this._layerToFootprint.set(t,e),t}createFootprintFromLayer(e){return this._layerToFootprint.get(e)?.clone()}createQuery(){const e=new le.A,t=this.capabilities?.query;e.returnGeometry=!0,t&&(e.compactGeometryEnabled=t.supportsCompactGeometry,e.defaultSpatialReferenceEnabled=t.supportsDefaultSpatialReference),e.outFields=["*"];const{timeOffset:r,timeExtent:i}=this;return e.timeExtent=null!=r&&null!=i?i.offset(-r.value,r.unit):i||null,e.where=this.definitionExpression||"1=1",e}getFeatureType(e){return(0,W.xd)(this.types,this.typeIdField,e)}getField(e){return this.fieldsIndex.get(e)}getFieldDomain(e,t){const r=t?.feature,i=this.getFeatureType(r);if(i){const t=i.domains&&i.domains[e];if(t&&"inherited"!==t.type)return t}return this.getField(e)?.domain}async hasDataChanged(){return(0,W.jp)(this)}async queryFeatures(e,t){const r=await this.load(),i=await r.source.queryFeatures(le.A.from(e)??r.createQuery(),t);if(i?.features)for(const e of i.features)e.layer=e.sourceLayer=r.footprintLayer;return i}async queryObjectIds(e,t){return(await this.load()).source.queryObjectIds(le.A.from(e)??this.createQuery(),t)}async queryFeatureCount(e,t){return(await this.load()).source.queryFeatureCount(le.A.from(e)??this.createQuery(),t)}async queryExtent(e,t){return(await this.load()).source.queryExtent(le.A.from(e)??this.createQuery(),t)}serviceSupportsSpatialReference(e){return this.loaded&&(0,ie.D)(this,e)}read(e,t){if(super.read(e,t),e){const{footprintLayer:r,dynamicGroupLayer:i}=e;r&&this.footprintLayer.read(r,t),i&&this.dynamicGroupLayer.read(i,t)}}async _fetchFirstValidLayerId(e){const{data:t}=await(0,n.A)(this.url,{query:{f:"json",...this.customParameters,token:this.apiKey},responseType:"json",signal:e});if(Array.isArray(t?.layers))return t.layers.find((({type:e})=>this.supportedSourceTypes.has(e)))?.id}async _createLayer(e){const t=e.getAttribute(this.itemSourceField);if(!t)throw new s.A("catalog-layer:item-source-missing",`The footprint is missing the "${this.itemSourceField}" attribute`);const r=JSON.parse(t);if(function(e){return"object"==typeof e&&null!=e&&"itemId"in e&&"portalUrl"in e}(r)){const{itemId:e,portalUrl:t}=r,i=(0,se.qG)(t),n=this.portalItem?.portal,o=ne.A.getDefault();let s,a=!0;n&&(0,u.ut)(t,n.url)?s=n:(0,u.ut)(t,o.url)?s=o:(s=(0,l.tE)(this._portals,i,(()=>new ne.A({url:i}))),a=!1);const d=await c.A.fromPortalItem(new oe.default({id:e,portal:s}));if(!a){try{await d.load()}catch{}d.portalItem=null}return d}return function(e){return"object"==typeof e&&null!=e&&"url"in e}(r)?c.A.fromArcGISServerUrl({url:r.url}):new(await re.S.UnsupportedLayer())}_configureLayer(e,t){const r=t.getAttribute(this.itemNameField);r&&(e.title=r);const i=t.getAttribute(this.maxScaleField);null!=i&&"maxScale"in e&&(e.maxScale=i);const n=t.getAttribute(this.minScaleField);null!=n&&"minScale"in e&&(e.minScale=n)}};(0,i._)([(0,p.MZ)({readOnly:!0})],ue.prototype,"createQueryVersion",null),(0,i._)([(0,p.MZ)({readOnly:!0})],ue.prototype,"drawOrderField",void 0),(0,i._)([(0,p.MZ)({type:I,readOnly:!0,json:{read:!1,write:{ignoreOrigin:!0,writer:de}}})],ue.prototype,"dynamicGroupLayer",void 0),(0,i._)([(0,p.MZ)({readOnly:!0})],ue.prototype,"editingEnabled",null),(0,i._)([(0,p.MZ)({readOnly:!0})],ue.prototype,"effectiveEditingEnabled",null),(0,i._)([(0,p.MZ)({json:{origins:{"web-scene":{name:"layerDefinition.elevationInfo",read:!1,write:!1}}}})],ue.prototype,"elevationInfo",void 0),(0,i._)([(0,p.MZ)({...ae.fields,readOnly:!0,json:{origins:{service:{read:!0}},read:!1}})],ue.prototype,"fields",void 0),(0,i._)([(0,p.MZ)(ae.fieldsIndex)],ue.prototype,"fieldsIndex",void 0),(0,i._)([(0,p.MZ)({json:{origins:{"web-scene":{name:"layerDefinition.floorInfo",read:!1,write:!1}}}})],ue.prototype,"floorInfo",void 0),(0,i._)([(0,p.MZ)({type:$,readOnly:!0,json:{read:!1,write:{ignoreOrigin:!0,writer:de}}})],ue.prototype,"footprintLayer",void 0),(0,i._)([(0,p.MZ)(M.id)],ue.prototype,"id",void 0),(0,i._)([(0,p.MZ)({readOnly:!0})],ue.prototype,"itemNameField",void 0),(0,i._)([(0,p.MZ)({readOnly:!0})],ue.prototype,"itemSourceField",void 0),(0,i._)([(0,p.MZ)({readOnly:!0})],ue.prototype,"itemTypeField",void 0),(0,i._)([(0,p.MZ)({readOnly:!0})],ue.prototype,"layers",void 0),(0,i._)([(0,p.MZ)({type:["show","hide","hide-children"]})],ue.prototype,"listMode",void 0),(0,i._)([(0,p.MZ)({readOnly:!0})],ue.prototype,"maxScaleField",void 0),(0,i._)([(0,p.MZ)({readOnly:!0})],ue.prototype,"minScaleField",void 0),(0,i._)([(0,p.MZ)({value:"CatalogLayer",type:["CatalogLayer"]})],ue.prototype,"operationalLayerType",void 0),(0,i._)([(0,p.MZ)({json:{origins:{"web-scene":{name:"layerDefinition.orderBy",write:!0,read:!0}}}})],ue.prototype,"orderBy",void 0),(0,i._)([(0,p.MZ)(ae.outFields)],ue.prototype,"outFields",void 0),(0,i._)([(0,p.MZ)({readOnly:!0})],ue.prototype,"parsedUrl",null),(0,i._)([(0,p.MZ)({readOnly:!0})],ue.prototype,"source",void 0),(0,i._)([(0,p.MZ)({json:{read:!1}})],ue.prototype,"type",void 0),(0,i._)([(0,p.MZ)({type:String})],ue.prototype,"typeIdField",void 0),(0,i._)([(0,p.MZ)({type:[ee.A]})],ue.prototype,"types",void 0),ue=(0,i._)([(0,y.$)("esri.layers.CatalogLayer")],ue);const pe=ue},87718:(e,t,r)=>{r.d(t,{F:()=>T,Y:()=>I});var i,n=r(90237),o=r(10107),s=(r(44208),r(53966),r(87811),r(40608)),l=r(49186),a=r(25482),d=r(93637),u=r(76369),p=r(59456),y=r(60945),c=r(66552),h=r(4718),m=r(61956);const f=new c.J({esriSpatialRelIntersects:"intersects",esriSpatialRelContains:"contains",esriSpatialRelCrosses:"crosses",esriSpatialRelDisjoint:"disjoint",esriSpatialRelEnvelopeIntersects:"envelope-intersects",esriSpatialRelIndexIntersects:"index-intersects",esriSpatialRelOverlaps:"overlaps",esriSpatialRelTouches:"touches",esriSpatialRelWithin:"within",esriSpatialRelRelation:"relation"}),g=new c.J({esriSRUnit_Meter:"meters",esriSRUnit_Kilometer:"kilometers",esriSRUnit_Foot:"feet",esriSRUnit_StatuteMile:"miles",esriSRUnit_NauticalMile:"nautical-miles",esriSRUnit_USNauticalMile:"us-nautical-miles"});let _=i=class extends a.oY{constructor(e){super(e),this.where=null,this.geometry=null,this.spatialRelationship="intersects",this.distance=void 0,this.objectIds=null,this.units=null,this.timeExtent=null}createQuery(e={}){const{where:t,geometry:r,spatialRelationship:i,timeExtent:n,objectIds:o,units:s,distance:l}=this;return new m.A({geometry:(0,h.o8)(r),objectIds:(0,h.o8)(o),spatialRelationship:i,timeExtent:(0,h.o8)(n),where:t,units:s,distance:l,...e})}clone(){const{where:e,geometry:t,spatialRelationship:r,timeExtent:n,objectIds:o,units:s,distance:l}=this;return new i({geometry:(0,h.o8)(t),objectIds:(0,h.o8)(o),spatialRelationship:r,timeExtent:(0,h.o8)(n),where:e,units:s,distance:l})}};(0,n._)([(0,o.MZ)({type:String,json:{write:!0}})],_.prototype,"where",void 0),(0,n._)([(0,o.MZ)({types:p.yR,json:{write:!0}})],_.prototype,"geometry",void 0),(0,n._)([(0,o.MZ)({type:f.apiValues,json:{name:"spatialRel",read:{reader:f.read},write:{allowNull:!1,writer:f.write,overridePolicy(){return{enabled:null!=this.geometry}}}}})],_.prototype,"spatialRelationship",void 0),(0,n._)([(0,o.MZ)({type:Number,json:{write:{overridePolicy(e){return{enabled:null!=e&&null!=this.geometry}}}}})],_.prototype,"distance",void 0),(0,n._)([(0,o.MZ)({type:[Number],json:{write:!0}})],_.prototype,"objectIds",void 0),(0,n._)([(0,o.MZ)({type:g.apiValues,json:{read:g.read,write:{writer:g.write,overridePolicy(e){return{enabled:null!=e&&null!=this.geometry}}}}})],_.prototype,"units",void 0),(0,n._)([(0,o.MZ)({type:y.A,json:{write:!0}})],_.prototype,"timeExtent",void 0),_=i=(0,n._)([(0,s.$)("esri.layers.support.FeatureFilter")],_);const v=_;var w;const b={read:{reader:u.LF},write:{writer:u.M9,overridePolicy(){return{allowNull:null!=this.excludedEffect,isRequired:null==this.excludedEffect}}}},M={read:{reader:u.LF},write:{writer:u.M9,overridePolicy(){return{allowNull:null!=this.includedEffect,isRequired:null==this.includedEffect}}}},F={name:"showExcludedLabels",default:!0};let x=w=class extends a.oY{constructor(e){super(e),this.filter=null,this.includedEffect=null,this.excludedEffect=null,this.excludedLabelsVisible=!1}write(e,t){const r=super.write(e,t);if(t?.origin){if(r.filter){const e=Object.keys(r.filter);if(e.length>1||"where"!==e[0])return t.messages?.push(new l.A("web-document-write:unsupported-feature-effect","Invalid feature effect 'filter'. A filter can only contain a 'where' property",{layer:t.layer,effect:this})),null}if("showExcludedLabels"in r)return t.messages?.push(new l.A("web-document-write:unsupported-feature-effect","Invalid value for property 'excludedLabelsVisible' which should always be 'true'",{layer:t.layer,effect:this})),null}return r}clone(){return new w({filter:null!=this.filter?this.filter.clone():null,includedEffect:this.includedEffect,excludedEffect:this.excludedEffect,excludedLabelsVisible:this.excludedLabelsVisible})}};(0,n._)([(0,o.MZ)({type:v,json:{write:{allowNull:!0,writer(e,t,r,i){const n=e?.write({},i);n&&0!==Object.keys(n).length?(0,d.sM)(r,n,t):(0,d.sM)(r,null,t)}}}})],x.prototype,"filter",void 0),(0,n._)([(0,o.MZ)({json:{read:u.LF,write:{writer:u.M9,allowNull:!0},origins:{"web-map":b,"portal-item":b}}})],x.prototype,"includedEffect",void 0),(0,n._)([(0,o.MZ)({json:{read:u.LF,write:{writer:u.M9,allowNull:!0},origins:{"web-map":M,"portal-item":M}}})],x.prototype,"excludedEffect",void 0),(0,n._)([(0,o.MZ)({type:Boolean,json:{write:!0,name:"showExcludedLabels",origins:{"web-map":F,"portal-item":F}}})],x.prototype,"excludedLabelsVisible",void 0),x=w=(0,n._)([(0,s.$)("esri.layers.support.FeatureEffect")],x);const Z={write:{allowNull:!0}},I={type:x,json:{origins:{"web-map":Z,"portal-item":Z}}},T=e=>{let t=class extends e{constructor(){super(...arguments),this.featureEffect=null}};return(0,n._)([(0,o.MZ)(I)],t.prototype,"featureEffect",void 0),t=(0,n._)([(0,s.$)("esri.layers.mixins.FeatureEffectLayer")],t),t}},32756:(e,t,r)=>{r.d(t,{f:()=>d,n:()=>a});var i=r(90237),n=r(93637),o=r(10107),s=(r(44208),r(53966),r(87811),r(40608)),l=r(91880);const a={type:[l.A],json:{origins:{"web-scene":{write:!1,read:!1}},name:"layerDefinition.orderBy",read:{reader:function(e,t,r){if(!e)return null;const i=e.find((e=>!!e.field));if(!i)return null;const n=new l.A;return n.read(i,r),[n]}},write:{writer:function(e,t,r,i){const o=e.find((e=>!!e.field));o&&(0,n.sM)(r,[o.toJSON()],t)}}}},d=e=>{let t=class extends e{constructor(){super(...arguments),this.orderBy=null}};return(0,i._)([(0,o.MZ)(a)],t.prototype,"orderBy",void 0),t=(0,i._)([(0,s.$)("esri.layers.mixins.OrderedLayer")],t),t}},82935:(e,t,r)=>{r.d(t,{B:()=>c,e:()=>h});var i=r(90237),n=r(60945),o=r(70668),s=r(10107),l=(r(44208),r(53966),r(87811),r(36005)),a=r(40608),d=r(89317),u=r(30524),p=r(96184),y=r(73133);const c={type:Boolean,json:{read:{source:"timeAnimation"},write:{target:"timeAnimation",layerContainerTypes:d.K}}},h=e=>{let t=class extends e{constructor(){super(...arguments),this.timeExtent=null,this.timeOffset=null,this.useViewTime=!0}readOffset(e,t){const r=t.timeInfo.exportOptions;if(!r)return null;const i=r.timeOffset,n=y.j.fromJSON(r.timeOffsetUnits);return i&&n?new o.A({value:i,unit:n}):null}set timeInfo(e){(0,u.sv)(e,this.fieldsIndex),this._set("timeInfo",e)}};return(0,i._)([(0,s.MZ)({type:n.A,json:{write:!1}})],t.prototype,"timeExtent",void 0),(0,i._)([(0,s.MZ)({type:o.A})],t.prototype,"timeOffset",void 0),(0,i._)([(0,l.w)("service","timeOffset",["timeInfo.exportOptions"])],t.prototype,"readOffset",null),(0,i._)([(0,s.MZ)({value:null,type:p.A,json:{write:!0,origins:{"web-document":{read:!1,write:!1},"portal-item":{read:!1,write:!1}}}})],t.prototype,"timeInfo",null),(0,i._)([(0,s.MZ)(c)],t.prototype,"useViewTime",void 0),t=(0,i._)([(0,a.$)("esri.layers.mixins.TemporalLayer")],t),t}},33143:(e,t,r)=>{r.d(t,{A:()=>c});var i=r(90237),n=r(69540),o=r(25482),s=r(10107),l=(r(44208),r(53966),r(87811),r(36005)),a=r(40608),d=r(43937),u=r(72088),p=r(29005);let y=class extends((0,n.O)(o.oY)){constructor(e){super(e),this.id=null,this.name=null,this.domains=null,this.templates=null}readDomains(e){const t={};for(const r of Object.keys(e))t[r]=(0,u.rS)(e[r]);return t}writeDomains(e,t){const r={};for(const t of Object.keys(e))e[t]&&(r[t]=e[t]?.toJSON());t.domains=r}};(0,i._)([(0,s.MZ)({json:{write:!0}})],y.prototype,"id",void 0),(0,i._)([(0,s.MZ)({json:{write:!0}})],y.prototype,"name",void 0),(0,i._)([(0,s.MZ)({json:{write:!0}})],y.prototype,"domains",void 0),(0,i._)([(0,l.w)("domains")],y.prototype,"readDomains",null),(0,i._)([(0,d.K)("domains")],y.prototype,"writeDomains",null),(0,i._)([(0,s.MZ)({type:[p.A],json:{write:!0}})],y.prototype,"templates",void 0),y=(0,i._)([(0,a.$)("esri.layers.support.FeatureType")],y);const c=y},20437:(e,t,r)=>{r.d(t,{A:()=>f});var i,n=r(90237),o=r(66552),s=r(25482),l=r(10107),a=r(56507),d=(r(87811),r(44208),r(93223)),u=r(36005),p=r(40608),y=r(72088),c=r(98453);const h=new o.J({binary:"binary",coordinate:"coordinate",countOrAmount:"count-or-amount",dateAndTime:"date-and-time",description:"description",locationOrPlaceName:"location-or-place-name",measurement:"measurement",nameOrTitle:"name-or-title",none:"none",orderedOrRanked:"ordered-or-ranked",percentageOrRatio:"percentage-or-ratio",typeOrCategory:"type-or-category",uniqueIdentifier:"unique-identifier"});let m=i=class extends s.oY{constructor(e){super(e),this.alias=null,this.defaultValue=void 0,this.description=null,this.domain=null,this.editable=!0,this.length=void 0,this.name=null,this.nullable=!0,this.type=null,this.valueType=null,this.visible=!0}readDescription(e,{description:t}){let r=null;try{r=t?JSON.parse(t):null}catch(e){}return r?.value??null}readValueType(e,{description:t}){let r=null;try{r=t?JSON.parse(t):null}catch(e){}return r?h.fromJSON(r.fieldValueType):null}clone(){return new i({alias:this.alias,defaultValue:this.defaultValue,description:this.description,domain:this.domain?.clone()??null,editable:this.editable,length:this.length,name:this.name,nullable:this.nullable,type:this.type,valueType:this.valueType,visible:this.visible})}};(0,n._)([(0,l.MZ)({type:String,json:{write:!0}})],m.prototype,"alias",void 0),(0,n._)([(0,l.MZ)({type:[String,Number],json:{write:{allowNull:!0}}})],m.prototype,"defaultValue",void 0),(0,n._)([(0,l.MZ)()],m.prototype,"description",void 0),(0,n._)([(0,u.w)("description")],m.prototype,"readDescription",null),(0,n._)([(0,l.MZ)({types:y.gK,json:{read:{reader:y.rS},write:!0}})],m.prototype,"domain",void 0),(0,n._)([(0,l.MZ)({type:Boolean,json:{write:!0}})],m.prototype,"editable",void 0),(0,n._)([(0,l.MZ)({type:a.jz,json:{write:{overridePolicy:e=>({enabled:Number.isFinite(e)})}}})],m.prototype,"length",void 0),(0,n._)([(0,l.MZ)({type:String,json:{write:!0}})],m.prototype,"name",void 0),(0,n._)([(0,l.MZ)({type:Boolean,json:{write:!0}})],m.prototype,"nullable",void 0),(0,n._)([(0,d.e)(c.m)],m.prototype,"type",void 0),(0,n._)([(0,l.MZ)()],m.prototype,"valueType",void 0),(0,n._)([(0,u.w)("valueType",["description"])],m.prototype,"readValueType",null),(0,n._)([(0,l.MZ)({type:Boolean,json:{read:!1}})],m.prototype,"visible",void 0),m=i=(0,n._)([(0,p.$)("esri.layers.support.Field")],m);const f=m},95466:(e,t,r)=>{r.d(t,{A:()=>y});var i=r(49186),n=r(25482),o=r(53966),s=r(91869),l=r(3330),a=r(30524),d=r(56400),u=r(96285);const p=new Map;class y{static fromJSON(e){return new y(e.fields,e.timeZoneByFieldName)}static fromLayer(e){return new y(e.fields??[],f(e))}static fromLayerJSON(e){return new y(e.fields??[],f(e))}constructor(e=[],t){this._fieldsMap=new Map,this._normalizedFieldsMap=new Map,this._dateFieldsSet=new Set,this._numericFieldsSet=new Set,this._requiredFields=null,this.dateFields=[],this.numericFields=[],this.fields=e||[],this._timeZoneByFieldName=t?new Map(t):null;const r=[];for(const e of this.fields){const t=e?.name,i=h(t);if(t&&i){const n=c(t);this._fieldsMap.set(t,e),this._fieldsMap.set(n,e),this._normalizedFieldsMap.set(i,e),r.push(`${n}:${e.type}:${this._timeZoneByFieldName?.get(t)}`),(0,a.vE)(e)?(this.dateFields.push(e),this._dateFieldsSet.add(e)):(0,a.WA)(e)&&(this._numericFieldsSet.add(e),this.numericFields.push(e)),(0,a.te)(e)||(0,a.Xz)(e)||(e.editable=null==e.editable||!!e.editable,e.nullable=null==e.nullable||!!e.nullable)}}r.sort(),this.uid=r.join()}get requiredFields(){if(!this._requiredFields){this._requiredFields=[];for(const e of this.fields)(0,a.te)(e)||(0,a.Xz)(e)||e.nullable||void 0!==(0,a.lD)(e)||this._requiredFields.push(e)}return this._requiredFields}equals(e){return this.uid===e?.uid}has(e){return null!=this.get(e)}get(e){if(!e)return;let t=this._fieldsMap.get(e);return t||(t=this._fieldsMap.get(c(e))??this._normalizedFieldsMap.get(h(e)),t&&this._fieldsMap.set(e,t),t)}getTimeZone(e){const t=this.get(e&&"string"!=typeof e?e.name:e);return t?this._timeZoneByFieldName?this._timeZoneByFieldName.get(t.name):"date"===t.type||"esriFieldTypeDate"===t.type?(o.A.getLogger("esri.layers.support.FieldsIndex").error(new i.A("getTimeZone:no-timezone-information",`no time zone information for field '${t.name}'`)),d.n$):m.has(t.type)?d.L5:null:null}getLuxonTimeZone(e){const t=this.getTimeZone(e);return t?t===d.L5?l.GB.instance:t===d.n$?u.mQ.utcInstance:(0,s.tE)(p,t,(()=>u.oh.create(t))):null}isDateField(e){return this._dateFieldsSet.has(this.get(e))}isTimeOnlyField(e){return(0,a.OH)(this.get(e))}isNumericField(e){return this._numericFieldsSet.has(this.get(e))}normalizeFieldName(e){return this.get(e)?.name??void 0}toJSON(){return{fields:this.fields.map((e=>(0,n.Wj)(e)?e.toJSON():e)),timeZoneByFieldName:this._timeZoneByFieldName?Array.from(this._timeZoneByFieldName.entries()):null}}}function c(e){return e.trim().toLowerCase()}function h(e){return(0,a.rS)(e)?.toLowerCase()??""}const m=new Set(["time-only","date-only","timestamp-offset","esriFieldTypeDateOnly","esriFieldTypeTimeOnly","esriFieldTypeTimestampOffset"]);function f(e){const t=new Map;if(!e.fields)return t;const r=!0===e.datesInUnknownTimezone,{timeInfo:i,editFieldsInfo:n}=e,o=(i?"startField"in i?i.startField:i.startTimeField:"")??"",s=(i?"endField"in i?i.endField:i.endTimeField:"")??"",l=function(e){return"dateFieldsTimeZone"in e}(e)?e.dateFieldsTimeZone??null:e.dateFieldsTimeReference?(0,d.ZS)(e.dateFieldsTimeReference):null,a=n?function(e){return"timeZone"in e}(n)?n.timeZone??l:n.dateFieldsTimeReference?(0,d.ZS)(n.dateFieldsTimeReference):l??d.n$:null,u=i?function(e){return"timeZone"in e}(i)?i.timeZone??l:i.timeReference?(0,d.ZS)(i.timeReference):l:null,p=new Map([[c(n?.creationDateField??""),a],[c(n?.editDateField??""),a],[c(o),u],[c(s),u]]);for(const{name:i,type:n}of e.fields)if(m.has(n))t.set(i,d.L5);else if("date"!==n&&"esriFieldTypeDate"!==n)t.set(i,null);else if(r)t.set(i,d.L5);else{const e=p.get(c(i??""))??l;t.set(i,e)}return t}},91880:(e,t,r)=>{r.d(t,{A:()=>p});var i,n=r(90237),o=r(66552),s=r(25482),l=r(10107),a=(r(44208),r(53966),r(87811),r(40608));const d=new o.J({asc:"ascending",desc:"descending"});let u=i=class extends s.oY{constructor(e){super(e),this.field=null,this.valueExpression=null,this.order="ascending"}clone(){return new i({field:this.field,valueExpression:this.valueExpression,order:this.order})}};(0,n._)([(0,l.MZ)({type:String,json:{write:!0}})],u.prototype,"field",void 0),(0,n._)([(0,l.MZ)({type:String,json:{write:!0,origins:{"web-scene":{read:!1,write:!1}}}})],u.prototype,"valueExpression",void 0),(0,n._)([(0,l.MZ)({type:d.apiValues,json:{type:d.jsonValues,read:d.read,write:d.write}})],u.prototype,"order",void 0),u=i=(0,n._)([(0,a.$)("esri.layers.support.OrderByInfo")],u);const p=u},96184:(e,t,r)=>{r.d(t,{A:()=>m});var i=r(90237),n=r(60945),o=r(70668),s=r(69540),l=r(25482),a=r(10107),d=(r(44208),r(53966),r(87811),r(36005)),u=r(40608),p=r(43937),y=r(56400);function c(e,t){return o.A.fromJSON({value:e,unit:t})}let h=class extends((0,s.O)(l.oY)){constructor(e){super(e),this.cumulative=!1,this.endField=null,this.fullTimeExtent=null,this.hasLiveData=!1,this.interval=null,this.startField=null,this.timeZone=null,this.trackIdField=null,this.useTime=!0,this.stops=null}readFullTimeExtent(e,t){return t.timeExtent&&Array.isArray(t.timeExtent)&&2===t.timeExtent.length?n.A.fromArray(t.timeExtent):null}writeFullTimeExtent(e,t){null!=e?.start&&null!=e.end?t.timeExtent=e.toArray():t.timeExtent=null}readInterval(e,t){return t.timeInterval&&t.timeIntervalUnits?c(t.timeInterval,t.timeIntervalUnits):t.defaultTimeInterval&&t.defaultTimeIntervalUnits?c(t.defaultTimeInterval,t.defaultTimeIntervalUnits):null}writeInterval(e,t){t.timeInterval=e?.toJSON().value??null,t.timeIntervalUnits=e?.toJSON().unit??null}};(0,i._)([(0,a.MZ)({type:Boolean,json:{name:"exportOptions.timeDataCumulative",write:!0}})],h.prototype,"cumulative",void 0),(0,i._)([(0,a.MZ)({type:String,json:{name:"endTimeField",write:{enabled:!0,allowNull:!0}}})],h.prototype,"endField",void 0),(0,i._)([(0,a.MZ)({type:n.A,json:{write:{enabled:!0,allowNull:!0}}})],h.prototype,"fullTimeExtent",void 0),(0,i._)([(0,d.w)("fullTimeExtent",["timeExtent"])],h.prototype,"readFullTimeExtent",null),(0,i._)([(0,p.K)("fullTimeExtent")],h.prototype,"writeFullTimeExtent",null),(0,i._)([(0,a.MZ)({type:Boolean,json:{write:!0}})],h.prototype,"hasLiveData",void 0),(0,i._)([(0,a.MZ)({type:o.A,json:{write:{enabled:!0,allowNull:!0}}})],h.prototype,"interval",void 0),(0,i._)([(0,d.w)("interval",["timeInterval","timeIntervalUnits","defaultTimeInterval","defaultTimeIntervalUnits"])],h.prototype,"readInterval",null),(0,i._)([(0,p.K)("interval")],h.prototype,"writeInterval",null),(0,i._)([(0,a.MZ)({type:String,json:{name:"startTimeField",write:{enabled:!0,allowNull:!0}}})],h.prototype,"startField",void 0),(0,i._)([(0,a.MZ)((0,y.P6)("timeReference",!0))],h.prototype,"timeZone",void 0),(0,i._)([(0,a.MZ)({type:String,json:{write:{enabled:!0,allowNull:!0}}})],h.prototype,"trackIdField",void 0),(0,i._)([(0,a.MZ)({type:Boolean,json:{name:"exportOptions.useTime",write:!0}})],h.prototype,"useTime",void 0),(0,i._)([(0,a.MZ)({type:[Date],json:{read:!1}})],h.prototype,"stops",void 0),h=(0,i._)([(0,u.$)("esri.layers.support.TimeInfo")],h);const m=h},72088:(e,t,r)=>{r.d(t,{rS:()=>x,gK:()=>F}),r(44208);var i,n=r(90237),o=r(4718),s=r(10107),l=(r(53966),r(93223)),a=r(40608),d=r(25482);r(87811);let u=i=class extends d.oY{constructor(e){super(e),this.name=null,this.code=null}clone(){return new i({name:this.name,code:this.code})}};(0,n._)([(0,s.MZ)({type:String,json:{write:!0}})],u.prototype,"name",void 0),(0,n._)([(0,s.MZ)({type:[String,Number],json:{write:!0}})],u.prototype,"code",void 0),u=i=(0,n._)([(0,a.$)("esri.layers.support.CodedValue")],u);const p=new(r(66552).J)({inherited:"inherited",codedValue:"coded-value",range:"range"});let y=class extends d.oY{constructor(e){super(e),this.name=null,this.type=null}};(0,n._)([(0,s.MZ)({type:String,json:{write:!0}})],y.prototype,"name",void 0),(0,n._)([(0,l.e)(p)],y.prototype,"type",void 0),y=(0,n._)([(0,a.$)("esri.layers.support.Domain")],y);const c=y;var h;let m=h=class extends c{constructor(e){super(e),this.codedValues=null,this.type="coded-value"}getName(e){let t=null;if(this.codedValues){const r=String(e);this.codedValues.some((e=>(String(e.code)===r&&(t=e.name),!!t)))}return t}clone(){return new h({codedValues:(0,o.o8)(this.codedValues),name:this.name})}};(0,n._)([(0,s.MZ)({type:[u],json:{write:!0}})],m.prototype,"codedValues",void 0),(0,n._)([(0,l.e)({codedValue:"coded-value"})],m.prototype,"type",void 0),m=h=(0,n._)([(0,a.$)("esri.layers.support.CodedValueDomain")],m);const f=m;var g;r(49186);let _=g=class extends c{constructor(e){super(e),this.type="inherited"}clone(){return new g}};(0,n._)([(0,l.e)({inherited:"inherited"})],_.prototype,"type",void 0),_=g=(0,n._)([(0,a.$)("esri.layers.support.InheritedDomain")],_);const v=_;var w;let b=w=class extends c{constructor(e){super(e),this.maxValue=null,this.minValue=null,this.type="range"}clone(){return new w({maxValue:this.maxValue,minValue:this.minValue,name:this.name})}};(0,n._)([(0,s.MZ)({json:{type:[Number],read:{source:"range",reader:(e,t)=>t.range?.[1]},write:{enabled:!1,overridePolicy(){return{enabled:null!=this.maxValue&&null==this.minValue}},target:"range",writer(e,t,r){t[r]=[this.minValue||0,e]}}}})],b.prototype,"maxValue",void 0),(0,n._)([(0,s.MZ)({json:{type:[Number],read:{source:"range",reader:(e,t)=>t.range?.[0]},write:{target:"range",writer(e,t,r){t[r]=[e,this.maxValue||0]}}}})],b.prototype,"minValue",void 0),(0,n._)([(0,l.e)({range:"range"})],b.prototype,"type",void 0),b=w=(0,n._)([(0,a.$)("esri.layers.support.RangeDomain")],b);const M=b,F={key:"type",base:c,typeMap:{range:b,"coded-value":f,inherited:v}};function x(e){if(!e?.type)return null;switch(e.type){case"range":return M.fromJSON(e);case"codedValue":return f.fromJSON(e);case"inherited":return v.fromJSON(e)}return null}},17036:(e,t,r)=>{r.d(t,{p:()=>a});var i=r(44208),n=r(53966),o=r(20437),s=r(95466),l=r(30524);function a(){return{fields:{type:[o.A],value:null,set:function(e){if(e&&(0,i.A)("big-integer-warning-enabled")){const t=e.filter((e=>"big-integer"===e.type||"oid"===e.type&&(e.length||0)>=8));if(t.length){const e=t.map((e=>`'${e.name}'`)).join(", ");n.A.getLogger(this).warn("#fields",`Layer (title: '${this.title??"no title"}', id: '${this.id??"no id"}') references big-integer field(s): ${e}, support for which is experimental. Only integers less than ${Number.MAX_SAFE_INTEGER} (Number.MAX_SAFE_INTEGER) are supported.`)}}this._set("fields",e)}},fieldsIndex:{readOnly:!0,get(){return s.A.fromLayer(this)}},outFields:{type:[String],json:{read:!1},set:function(e){this._userOutFields=e,this.notifyChange("outFields")},get:function(){const e=this._userOutFields;if(!e?.length)return null;if(e.includes("*"))return["*"];if(!this.fields)return e;for(const t of e){const r=this.fieldsIndex?.has(t);r||n.A.getLogger("esri.layers.support.fieldProperties").error("field-attributes-layer:invalid-field",`Invalid field ${t} found in outFields`,{layer:this,outFields:e})}return(0,l.DB)(this.fieldsIndex,e)}}}}},98453:(e,t,r)=>{r.d(t,{m:()=>i});const i=new(r(66552).J)({esriFieldTypeSmallInteger:"small-integer",esriFieldTypeInteger:"integer",esriFieldTypeSingle:"single",esriFieldTypeDouble:"double",esriFieldTypeLong:"long",esriFieldTypeString:"string",esriFieldTypeDate:"date",esriFieldTypeOID:"oid",esriFieldTypeGeometry:"geometry",esriFieldTypeBlob:"blob",esriFieldTypeRaster:"raster",esriFieldTypeGUID:"guid",esriFieldTypeGlobalID:"global-id",esriFieldTypeXML:"xml",esriFieldTypeBigInteger:"big-integer",esriFieldTypeDateOnly:"date-only",esriFieldTypeTimeOnly:"time-only",esriFieldTypeTimestampOffset:"timestamp-offset"})},32730:(e,t,r)=>{r.d(t,{BI:()=>f,D3:()=>h,XJ:()=>m,lc:()=>c,mX:()=>_,rU:()=>g,tH:()=>F});var i=r(799);const n="__begin__",o="__end__",s=new RegExp(n,"ig"),l=new RegExp(o,"ig"),a=new RegExp("^"+n,"i"),d=new RegExp(o+"$","i"),u='"',p=u+" + ",y=" + "+u;function c(e){return e.replaceAll(new RegExp("\\[","g"),"{").replaceAll(new RegExp("\\]","g"),"}")}function h(e){return e.replaceAll(new RegExp("\\{","g"),"[").replaceAll(new RegExp("\\}","g"),"]")}function m(e){const t={expression:"",type:"none"};return e.labelExpressionInfo?e.labelExpressionInfo.value?(t.expression=e.labelExpressionInfo.value,t.type="conventional"):e.labelExpressionInfo.expression&&(t.expression=e.labelExpressionInfo.expression,t.type="arcade"):null!=e.labelExpression&&(t.expression=c(e.labelExpression),t.type="conventional"),t}function f(e){const t=m(e);if(!t)return null;switch(t.type){case"conventional":return _(t.expression);case"arcade":return t.expression}return null}function g(e){const t=m(e);if(!t)return null;switch(t.type){case"conventional":return function(e){const t=e?.match(v);return t?.[1].trim()||null}(t.expression);case"arcade":return F(t.expression)}return null}function _(e){let t;return e?(t=(0,i.HC)(e,(e=>n+'$feature["'+e+'"]'+o)),t=a.test(t)?t.replace(a,""):u+t,t=d.test(t)?t.replace(d,""):t+u,t=t.replaceAll(s,p).replaceAll(l,y)):t='""',t}const v=/^\s*\{([^}]+)\}\s*$/i,w=/^\s*(?:(?:\$feature\.(\w+))|(?:\$feature\[(["'])(.+)(\2)\]));?\s*$/i,b=/^\s*(?:(?:\$feature\.(\w+))|(?:\$feature\[(["'])(.+)(\2)\]));?\s*(?:DomainName\(\s*\$feature\s*,\s*(["'])(\1|\3)(\5)\s*\));?\s*$/i,M=/^\s*(?:DomainName\(\s*\$feature\s*,\s*(["'])(.+)(\1)\s*\));?\s*$/i;function F(e){if(!e)return null;let t=w.exec(e)||b.exec(e);return t?t[1]||t[3]:(t=M.exec(e),t?t[2]:null)}},73133:(e,t,r)=>{r.d(t,{j:()=>i});const i=(0,r(66552).O)()({esriTimeUnitsMilliseconds:"milliseconds",esriTimeUnitsSeconds:"seconds",esriTimeUnitsMinutes:"minutes",esriTimeUnitsHours:"hours",esriTimeUnitsDays:"days",esriTimeUnitsWeeks:"weeks",esriTimeUnitsMonths:"months",esriTimeUnitsYears:"years",esriTimeUnitsDecades:"decades",esriTimeUnitsCenturies:"centuries",esriTimeUnitsUnknown:void 0})},96520:(e,t,r)=>{r.d(t,{u:()=>s});var i=r(83047),n=r(21325);function o(e,t,r){if(null==e.hasM||e.hasZ)for(const e of t)for(const t of e)t.length>2&&(t[2]*=r)}function s(e,t,r){if(!e&&!t||!r)return;const n=(0,i.G9)(r);l(e,r,n),l(t,r,n)}function l(e,t,r){if(e)for(const i of e)a(i.geometry,t,r)}function a(e,t,r){if(!e?.spatialReference||(0,n.aI)(e.spatialReference,t))return;const s=(0,i.G9)(e.spatialReference)/r;if(1!==s)if("x"in e)null!=e.z&&(e.z*=s);else if("rings"in e)o(e,e.rings,s);else if("paths"in e)o(e,e.paths,s);else if("points"in e&&(null==e.hasM||e.hasZ))for(const t of e.points)t.length>2&&(t[2]*=s)}},58501:(e,t,r)=>{r.d(t,{q:()=>n});var i=r(62815);function n(e,t,r){if(!r?.features||!r.hasZ)return;const n=(0,i.N)(r.geometryType,t,e.outSpatialReference);if(null!=n)for(const e of r.features)n(e.geometry)}},22671:(e,t,r)=>{r.d(t,{A:()=>v});var i,n=r(90237),o=r(59456),s=r(52106),l=r(66552),a=r(25482),d=r(4718),u=r(10107),p=(r(44208),r(53966),r(36005)),y=r(40608),c=r(43937),h=r(16930),m=r(65864),f=r(20437);const g=new l.J({esriGeometryPoint:"point",esriGeometryMultipoint:"multipoint",esriGeometryPolyline:"polyline",esriGeometryPolygon:"polygon",esriGeometryEnvelope:"extent",mesh:"mesh","":null});let _=i=class extends a.oY{constructor(e){super(e),this.displayFieldName=null,this.exceededTransferLimit=!1,this.features=[],this.fields=null,this.geometryType=null,this.hasM=!1,this.hasZ=!1,this.queryGeometry=null,this.spatialReference=null}readFeatures(e,t){const r=h.A.fromJSON(t.spatialReference),i=[];for(let t=0;t<e.length;t++){const n=e[t],o=s.A.fromJSON(n),l=n.geometry?.spatialReference;null==o.geometry||l||(o.geometry.spatialReference=r);const a=n.aggregateGeometries,d=o.aggregateGeometries;if(a&&null!=d)for(const e in d){const t=d[e],i=a[e],n=i?.spatialReference;null==t||n||(t.spatialReference=r)}i.push(o)}return i}writeGeometryType(e,t,r,i){if(e)return void g.write(e,t,r,i);const{features:n}=this;if(n)for(const e of n)if(null!=e?.geometry)return void g.write(e.geometry.type,t,r,i)}readQueryGeometry(e,t){if(!e)return null;const r=!!e.spatialReference,i=(0,m.rS)(e);return i&&!r&&t.spatialReference&&(i.spatialReference=h.A.fromJSON(t.spatialReference)),i}writeSpatialReference(e,t){if(e)return void(t.spatialReference=e.toJSON());const{features:r}=this;if(r)for(const e of r)if(e&&null!=e.geometry&&e.geometry.spatialReference)return void(t.spatialReference=e.geometry.spatialReference.toJSON())}clone(){return new i(this.cloneProperties())}cloneProperties(){return(0,d.o8)({displayFieldName:this.displayFieldName,exceededTransferLimit:this.exceededTransferLimit,features:this.features,fields:this.fields,geometryType:this.geometryType,hasM:this.hasM,hasZ:this.hasZ,queryGeometry:this.queryGeometry,spatialReference:this.spatialReference,transform:this.transform})}toJSON(e){const t=this.write();if(t.features&&Array.isArray(e)&&e.length>0)for(let r=0;r<t.features.length;r++){const i=t.features[r];if(i.geometry){const t=e?.[r];i.geometry=t?.toJSON()||i.geometry}}return t}quantize(e){const{scale:[t,r],translate:[i,n]}=e,o=this.features,s=this._getQuantizationFunction(this.geometryType,(e=>Math.round((e-i)/t)),(e=>Math.round((n-e)/r)));for(let e=0,t=o.length;e<t;e++)s?.(o[e].geometry)||(o.splice(e,1),e--,t--);return this.transform=e,this}unquantize(){const{geometryType:e,features:t,transform:r}=this;if(!r)return this;const{translate:[i,n],scale:[o,s]}=r;let l=null,a=null;if(this.hasZ&&null!=r?.scale?.[2]){const{translate:[,,e],scale:[,,t]}=r;l=r=>r*t+e}if(this.hasM&&null!=r?.scale?.[3]){const{translate:[,,,e],scale:[,,,t]}=r;a=r=>null==r?r:r*t+e}const d=this._getHydrationFunction(e,(e=>e*o+i),(e=>n-e*s),l,a);for(const{geometry:e}of t)null!=e&&d&&d(e);return this.transform=null,this}_quantizePoints(e,t,r){let i,n;const o=[];for(let s=0,l=e.length;s<l;s++){const l=e[s];if(s>0){const e=t(l[0]),s=r(l[1]);e===i&&s===n||(o.push([e-i,s-n]),i=e,n=s)}else i=t(l[0]),n=r(l[1]),o.push([i,n])}return o.length>0?o:null}_getQuantizationFunction(e,t,r){return"point"===e?e=>(e.x=t(e.x),e.y=r(e.y),e):"polyline"===e||"polygon"===e?e=>{const i=(0,m.Bi)(e)?e.rings:e.paths,n=[];for(let e=0,o=i.length;e<o;e++){const o=i[e],s=this._quantizePoints(o,t,r);s&&n.push(s)}return n.length>0?((0,m.Bi)(e)?e.rings=n:e.paths=n,e):null}:"multipoint"===e?e=>{const i=this._quantizePoints(e.points,t,r);return i&&i.length>0?(e.points=i,e):null}:"extent"===e?e=>e:null}_getHydrationFunction(e,t,r,i,n){return"point"===e?e=>{e.x=t(e.x),e.y=r(e.y),i&&(e.z=i(e.z))}:"polyline"===e||"polygon"===e?e=>{const o=(0,m.Bi)(e)?e.rings:e.paths;let s,l;for(let e=0,i=o.length;e<i;e++){const i=o[e];for(let e=0,n=i.length;e<n;e++){const n=i[e];e>0?(s+=n[0],l+=n[1]):(s=n[0],l=n[1]),n[0]=t(s),n[1]=r(l)}}if(i&&n)for(let e=0,t=o.length;e<t;e++){const t=o[e];for(let e=0,r=t.length;e<r;e++){const r=t[e];r[2]=i(r[2]),r[3]=n(r[3])}}else if(i)for(let e=0,t=o.length;e<t;e++){const t=o[e];for(let e=0,r=t.length;e<r;e++){const r=t[e];r[2]=i(r[2])}}else if(n)for(let e=0,t=o.length;e<t;e++){const t=o[e];for(let e=0,r=t.length;e<r;e++){const r=t[e];r[2]=n(r[2])}}}:"extent"===e?e=>{e.xmin=t(e.xmin),e.ymin=r(e.ymin),e.xmax=t(e.xmax),e.ymax=r(e.ymax),i&&null!=e.zmax&&null!=e.zmin&&(e.zmax=i(e.zmax),e.zmin=i(e.zmin)),n&&null!=e.mmax&&null!=e.mmin&&(e.mmax=n(e.mmax),e.mmin=n(e.mmin))}:"multipoint"===e?e=>{const o=e.points;let s,l;for(let e=0,i=o.length;e<i;e++){const i=o[e];e>0?(s+=i[0],l+=i[1]):(s=i[0],l=i[1]),i[0]=t(s),i[1]=r(l)}if(i&&n)for(let e=0,t=o.length;e<t;e++){const t=o[e];t[2]=i(t[2]),t[3]=n(t[3])}else if(i)for(let e=0,t=o.length;e<t;e++){const t=o[e];t[2]=i(t[2])}else if(n)for(let e=0,t=o.length;e<t;e++){const t=o[e];t[2]=n(t[2])}}:null}};(0,n._)([(0,u.MZ)({type:String,json:{write:!0}})],_.prototype,"displayFieldName",void 0),(0,n._)([(0,u.MZ)({type:Boolean,json:{write:{overridePolicy:e=>({enabled:e})}}})],_.prototype,"exceededTransferLimit",void 0),(0,n._)([(0,u.MZ)({type:[s.A],json:{write:!0}})],_.prototype,"features",void 0),(0,n._)([(0,p.w)("features")],_.prototype,"readFeatures",null),(0,n._)([(0,u.MZ)({type:[f.A],json:{write:!0}})],_.prototype,"fields",void 0),(0,n._)([(0,u.MZ)({type:["point","multipoint","polyline","polygon","extent","mesh"],json:{read:{reader:g.read}}})],_.prototype,"geometryType",void 0),(0,n._)([(0,c.K)("geometryType")],_.prototype,"writeGeometryType",null),(0,n._)([(0,u.MZ)({type:Boolean,json:{write:{overridePolicy:e=>({enabled:e})}}})],_.prototype,"hasM",void 0),(0,n._)([(0,u.MZ)({type:Boolean,json:{write:{overridePolicy:e=>({enabled:e})}}})],_.prototype,"hasZ",void 0),(0,n._)([(0,u.MZ)({types:o.yR,json:{write:!0}})],_.prototype,"queryGeometry",void 0),(0,n._)([(0,p.w)("queryGeometry")],_.prototype,"readQueryGeometry",null),(0,n._)([(0,u.MZ)({type:h.A,json:{write:!0}})],_.prototype,"spatialReference",void 0),(0,n._)([(0,c.K)("spatialReference")],_.prototype,"writeSpatialReference",null),(0,n._)([(0,u.MZ)({json:{write:!0}})],_.prototype,"transform",void 0),_=i=(0,n._)([(0,y.$)("esri.rest.support.FeatureSet")],_),_.prototype.toJSON.isDefaultToJSON=!0;const v=_}}]);