@arcgis/core 5.2.4 → 5.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/core",
3
- "version": "5.2.4",
3
+ "version": "5.2.6",
4
4
  "description": "ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API",
5
5
  "keywords": [
6
6
  "ArcGIS",
@@ -20,7 +20,7 @@
20
20
  "license": "SEE LICENSE IN LICENSE.md",
21
21
  "dependencies": {
22
22
  "@amcharts/amcharts5": "~5.20.8",
23
- "@arcgis/toolkit": "5.2.4",
23
+ "@arcgis/toolkit": "5.2.6",
24
24
  "@esri/arcgis-html-sanitizer": "~4.2.0",
25
25
  "@esri/calcite-components": "^5.2.1",
26
26
  "@vaadin/grid": "~25.3.2",
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{CanvasDrawHelper as e,Transformation as t}from"./CIMSymbolDrawHelper.js";import{CIMSymbolHelper as n,CIMSymbolInflatedSizeHelper as r}from"./CIMSymbolHelper.js";import{normalizeDashTemplate as i}from"./dashUtils.js";import{createPointSymbolHaloSilhouette as a}from"./pointSymbolHaloUtils.js";import{rasterizeFillStyle as o,rasterizeDash1D as s,rasterizeGradient as c,createHaloImage as l,createAlphaMaskRings as u,applyAlphaMask as d,createHaloSDF as f}from"./rasterizingUtils.js";import p from"./Rect.js";import{getSDFInfo as m,buildSDF as h}from"./SDFHelper.js";import{resampleHermite as g}from"./utils.js";import{rasterizedVectorMarkerMinSize as _,patternFillRasterizationScale as v}from"../../views/2d/engine/webgl/definitions.js";class y{constructor(e){this._resourceManager=e,this._cachedRasterizationCanvas=null}dispose(){this._cachedRasterizationCanvas=null}get _canvas(){return this._cachedRasterizationCanvas||=document.createElement(`canvas`),this._cachedRasterizationCanvas}rasterizeJSONResource(e){switch(e.type){case`dash`:{let t=i(e.dashTemplate),[n,r,a]=s(t);return{size:[r,a],image:new Uint32Array(n.buffer),sdf:!0,simplePattern:!0,anchorX:0,anchorY:0}}case`fill-style`:{let[t,n,r,i]=o(this._canvas,e,v);return{size:[n,r],image:new Uint32Array(t.buffer),sdf:!1,simplePattern:!0,anchorX:0,anchorY:0,rasterizationScale:i}}case`sdf`:return x(e);case`CIMGradientFill`:case`CIMGradientStroke`:case`CIMHatchFill`:case`CIMPictureMarker`:case`CIMVectorMarker`:return this._rasterizeCIMJSONResource(e);case`cim-point-symbol-halo`:return this._rasterizeCIMPointSymbolHalo(e)}}_rasterizeCIMJSONResource(e){switch(e.type){case`CIMGradientFill`:case`CIMGradientStroke`:{let[t,n,r]=c(this._canvas,e);return{size:[n,r],image:new Uint32Array(t.buffer),sdf:!1,simplePattern:!1,anchorX:0,anchorY:0,samplingMode:e.gradientType===`Discrete`||e.colorRamp.type===`CIMFixedColorRamp`?`Nearest`:`Linear`}}case`CIMHatchFill`:{let t=n.fromCIMHatchFill(e,v);return this._rasterizeCIMVectorMarker(t)}case`CIMPictureMarker`:{let t=n.fromCIMInsidePolygon(e);return this._rasterizeCIMVectorMarker(t)}case`CIMVectorMarker`:{if(e.markerPlacement?.type===`CIMMarkerPlacementInsidePolygon`){let t=n.fromCIMInsidePolygon(e);return this._rasterizeCIMVectorMarker(t)}let t=m(e);return t&&!e.avoidSDFRasterization?x(t):this._rasterizeCIMVectorMarker(e,!1,_)}}}_rasterizeCIMVectorMarker(e,t=!0,r){let i=t?p.fromExtent(e.frame):null,[a,o,s,c,l]=n.rasterize(this._canvas,e,i,this._resourceManager,!0,r);return a?{size:[o,s],image:new Uint32Array(a.buffer),sdf:!1,simplePattern:!1,anchorX:c,anchorY:l}:null}_rasterizeCIMPointSymbolHalo(i){let{symbol:o}=i,s=o.haloSize??0;if(s<=0)return null;let c=a({...o,haloSize:0,haloSymbol:void 0}),p=r.getPointSymbolHaloPadding(o,this._resourceManager),[m,h,g,v,y,x]=n.rasterize(this._canvas,c,null,this._resourceManager,!1,_,p);if(!m)return null;let S=s*x,C=o.haloSymbol?.symbolLayers?.filter(e=>e.enable!==!1)??[],w=C.length===1&&C[0].type===`CIMSolidFill`;if(!i.sdf&&w)return{size:[h,g],image:new Uint32Array(l(m,h,g,S).buffer),sdf:!1,simplePattern:!1,anchorX:v,anchorY:y};if(!i.sdf){let n=l(m,h,g,S),r=u(n,h,g);if(r.length===0||!o.haloSymbol)return null;let i=-v*h,a=-y*g,s=t.createScale(x,-x);s.translate(h*.5-i,g*.5+a);let c=s.invert(),f={type:`polygon`,rings:r.map(e=>e.map(e=>c.transform(e)))},p=this._canvas.getContext(`2d`,{willReadFrequently:!0});p.clearRect(0,0,h,g),new e(p,this._resourceManager,s,!0).drawSymbol(o.haloSymbol,f);let _=p.getImageData(0,0,h,g).data,C=b(o.haloSymbol)?_:d(_,n);return{size:[h,g],image:new Uint32Array(C.buffer),sdf:!1,simplePattern:!1,anchorX:v,anchorY:y}}let{image:T,encodingRadius:E}=f(m,h,g,S);return{size:[h,g],image:new Uint32Array(T.buffer),sdf:!0,simplePattern:!1,anchorX:v,anchorY:y,sdfPaddingRatio:0,sdfDecodeCoeff:2*E/g}}rasterizeImageResource(e,t,n,r){this._canvas.width=e,this._canvas.height=t;let i=this._canvas.getContext(`2d`,{willReadFrequently:!0});n instanceof ImageData?i.putImageData(n,0,0):(n.setAttribute(`width`,`${e}px`),n.setAttribute(`height`,`${t}px`),i.drawImage(n,0,0,e,t));let a=i.getImageData(0,0,e,t),o=new Uint8Array(a.data);if(r){for(let e of r)if(e&&e.oldColor&&e.oldColor.length===4&&e.newColor&&e.newColor.length===4){let[t,n,r,i]=e.oldColor,[a,s,c,l]=e.newColor;if(t===a&&n===s&&r===c&&i===l)continue;for(let e=0;e<o.length;e+=4)t===o[e]&&n===o[e+1]&&r===o[e+2]&&i===o[e+3]&&(o[e]=a,o[e+1]=s,o[e+2]=c,o[e+3]=l)}}let s;for(let e=0;e<o.length;e+=4)s=o[e+3]/255,o[e]=o[e]*s,o[e+1]=o[e+1]*s,o[e+2]=o[e+2]*s;let c=o,l=e,u=t;if(l>=512||u>=512){let n=l/u;n>1?(l=512,u=Math.round(512/n)):(u=512,l=Math.round(512*n)),c=new Uint8Array(4*l*u);let r=new Uint8ClampedArray(c.buffer);g(o,e,t,r,l,u,!1)}return{size:[l,u],image:new Uint32Array(c.buffer),sdf:!1,simplePattern:!1,anchorX:0,anchorY:0}}}function b(e){return e.symbolLayers?.some(e=>{if(e.enable===!1||e.type!==`CIMCharacterMarker`&&e.type!==`CIMPictureMarker`&&e.type!==`CIMVectorMarker`)return!1;let t=e.markerPlacement;return t?.type!==`CIMMarkerPlacementInsidePolygon`&&!(t?.type===`CIMMarkerPlacementPolygonCenter`&&t.clipAtBoundary)})??!1}function x(e){if(!e)return null;let{data:t,width:n,height:r,sdfPaddingRatio:i,sdfDecodeCoeff:a}=h(e);return t?{size:[n,r],image:new Uint32Array(t.buffer),sdf:!0,simplePattern:!0,sdfPaddingRatio:i,sdfDecodeCoeff:a,anchorX:0,anchorY:0}:null}export{y as default};
2
+ import{CanvasDrawHelper as e,Transformation as t}from"./CIMSymbolDrawHelper.js";import{CIMSymbolHelper as n,CIMSymbolInflatedSizeHelper as r}from"./CIMSymbolHelper.js";import{normalizeDashTemplate as i}from"./dashUtils.js";import{createPointSymbolHaloSilhouette as a}from"./pointSymbolHaloUtils.js";import{rasterizeFillStyle as o,rasterizeDash1D as s,rasterizeGradient as c,createHaloImage as l,createAlphaMaskRings as u,applyAlphaMask as d,createHaloSDF as f}from"./rasterizingUtils.js";import p from"./Rect.js";import{getSDFInfo as m,buildSDF as h}from"./SDFHelper.js";import{resampleHermite as g}from"./utils.js";import{rasterizedVectorMarkerMinSize as _,patternFillRasterizationScale as v}from"../../views/2d/engine/webgl/definitions.js";class y{constructor(e){this._resourceManager=e,this._cachedRasterizationCanvas=null}dispose(){this._cachedRasterizationCanvas=null}get _canvas(){return this._cachedRasterizationCanvas||=document.createElement(`canvas`),this._cachedRasterizationCanvas}rasterizeJSONResource(e){switch(e.type){case`dash`:{let t=i(e.dashTemplate),[n,r,a]=s(t);return{size:[r,a],image:new Uint32Array(n.buffer),sdf:!0,simplePattern:!0,anchorX:0,anchorY:0}}case`fill-style`:{let[t,n,r,i]=o(this._canvas,e,v);return{size:[n,r],image:new Uint32Array(t.buffer),sdf:!1,simplePattern:!0,anchorX:0,anchorY:0,rasterizationScale:i}}case`sdf`:return x(e);case`CIMGradientFill`:case`CIMGradientStroke`:case`CIMHatchFill`:case`CIMPictureMarker`:case`CIMVectorMarker`:return this._rasterizeCIMJSONResource(e);case`cim-point-symbol-halo`:return this._rasterizeCIMPointSymbolHalo(e)}}_rasterizeCIMJSONResource(e){switch(e.type){case`CIMGradientFill`:case`CIMGradientStroke`:{let[t,n,r]=c(this._canvas,e);return{size:[n,r],image:new Uint32Array(t.buffer),sdf:!1,simplePattern:!1,anchorX:0,anchorY:0,samplingMode:e.gradientType===`Discrete`||e.colorRamp.type===`CIMFixedColorRamp`?`Nearest`:`Linear`}}case`CIMHatchFill`:{let t=n.fromCIMHatchFill(e,v);return this._rasterizeCIMVectorMarker(t)}case`CIMPictureMarker`:{let t=n.fromCIMInsidePolygon(e);return this._rasterizeCIMVectorMarker(t)}case`CIMVectorMarker`:{if(e.markerPlacement?.type===`CIMMarkerPlacementInsidePolygon`){let t=n.fromCIMInsidePolygon(e);return this._rasterizeCIMVectorMarker(t)}let t=m(e);return t&&!e.avoidSDFRasterization?x(t):this._rasterizeCIMVectorMarker(e,!1,_)}}}_rasterizeCIMVectorMarker(e,t=!0,r){let i=t?p.fromExtent(e.frame):null,[a,o,s,c,l]=n.rasterize(this._canvas,e,i,this._resourceManager,!0,r);return a?{size:[o,s],image:new Uint32Array(a.buffer),sdf:!1,simplePattern:!1,anchorX:c,anchorY:l}:null}_rasterizeCIMPointSymbolHalo(i){let{symbol:o}=i,s=o.haloSize??0;if(s<=0)return null;let c=a({...o,haloSize:0,haloSymbol:void 0}),p=r.getPointSymbolHaloPadding(o,this._resourceManager),[m,h,g,v,y,x]=n.rasterize(this._canvas,c,null,this._resourceManager,!1,_,p);if(!m)return null;let S=s*x,C=o.haloSymbol?.symbolLayers?.filter(e=>e.enable!==!1)??[],w=C.length===1&&C[0].type===`CIMSolidFill`;if(!i.sdf&&w)return{size:[h,g],image:new Uint32Array(l(m,h,g,S).buffer),sdf:!1,simplePattern:!1,anchorX:v,anchorY:y};if(!i.sdf){let n=l(m,h,g,S),r=u(n,h,g);if(r.length===0||!o.haloSymbol)return null;let i=-v*h,a=-y*g,s=t.createScale(x,-x);s.translate(h*.5-i,g*.5+a);let c=s.invert(),f={type:`polygon`,rings:r.map(e=>e.map(e=>c.transform(e)))},p=this._canvas.getContext(`2d`,{willReadFrequently:!0});p.clearRect(0,0,h,g),new e(p,this._resourceManager,s,!0).drawSymbol(o.haloSymbol,f);let _=p.getImageData(0,0,h,g).data,C=b(o.haloSymbol)?_:d(_,n);return{size:[h,g],image:new Uint32Array(C.buffer),sdf:!1,simplePattern:!1,anchorX:v,anchorY:y}}let{image:T,encodingRadius:E}=f(m,h,g,S);return{size:[h,g],image:new Uint32Array(T.buffer),sdf:!0,simplePattern:!1,anchorX:v,anchorY:y,sdfPaddingRatio:0,sdfDecodeCoeff:2*E/g}}rasterizeImageResource(e,t,n,r,i){i??=512,this._canvas.width=e,this._canvas.height=t;let a=this._canvas.getContext(`2d`,{willReadFrequently:!0});n instanceof ImageData?a.putImageData(n,0,0):(n.setAttribute(`width`,`${e}px`),n.setAttribute(`height`,`${t}px`),a.drawImage(n,0,0,e,t));let o=a.getImageData(0,0,e,t),s=new Uint8Array(o.data);if(r){for(let e of r)if(e&&e.oldColor&&e.oldColor.length===4&&e.newColor&&e.newColor.length===4){let[t,n,r,i]=e.oldColor,[a,o,c,l]=e.newColor;if(t===a&&n===o&&r===c&&i===l)continue;for(let e=0;e<s.length;e+=4)t===s[e]&&n===s[e+1]&&r===s[e+2]&&i===s[e+3]&&(s[e]=a,s[e+1]=o,s[e+2]=c,s[e+3]=l)}}let c;for(let e=0;e<s.length;e+=4)c=s[e+3]/255,s[e]=s[e]*c,s[e+1]=s[e+1]*c,s[e+2]=s[e+2]*c;let l=s,u=e,d=t;if(u>=i||d>=i){let n=u/d;n>1?(u=i,d=Math.round(i/n)):(d=i,u=Math.round(i*n)),l=new Uint8Array(4*u*d);let r=new Uint8ClampedArray(l.buffer);g(s,e,t,r,u,d,!1)}return{size:[u,d],image:new Uint32Array(l.buffer),sdf:!1,simplePattern:!1,anchorX:0,anchorY:0}}}function b(e){return e.symbolLayers?.some(e=>{if(e.enable===!1||e.type!==`CIMCharacterMarker`&&e.type!==`CIMPictureMarker`&&e.type!==`CIMVectorMarker`)return!1;let t=e.markerPlacement;return t?.type!==`CIMMarkerPlacementInsidePolygon`&&!(t?.type===`CIMMarkerPlacementPolygonCenter`&&t.clipAtBoundary)})??!1}function x(e){if(!e)return null;let{data:t,width:n,height:r,sdfPaddingRatio:i,sdfDecodeCoeff:a}=h(e);return t?{size:[n,r],image:new Uint32Array(t.buffer),sdf:!0,simplePattern:!0,sdfPaddingRatio:i,sdfDecodeCoeff:a,anchorX:0,anchorY:0}:null}export{y as default};
@@ -1,3 +1,3 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
2
  import{defaultCIMValues as e,defaultCIMColor as t}from"./defaultCIMValues.js";function n(e){return typeof e==`function`}function r(e,t,r,i){return n(e)?e(t,r,i):e}function i(e){return[e.r,e.g,e.b,e.a]}function a(e){let t=e.length;for(;t--;)if(!` /-,
3
- `.includes(e.charAt(t)))return!1;return!0}function o(e,t){let n=[],r=0,i=-1;do if(i=e.indexOf(`[`,r),i>=r){if(i>r){let t=e.slice(r,i);n.push([t,null,a(t)])}if(r=i+1,i=e.indexOf(`]`,r),i>=r){if(i>r){let a=t[e.slice(r,i)];a&&n.push([null,a,!1])}r=i+1}}while(i!==-1);if(r<e.length){let t=e.slice(r);n.push([t,null,a(t)])}return n}function s(e,t,n){let r=``,i=null;for(let n of t){let[t,a,o]=n;if(t!=null&&t!==``)o?i=t:(i!=null&&(r+=i,i=null),r+=t);else{let t=e.readAttribute(a);t!=null&&t!==``&&(i!==null&&(r+=i,i=null),r+=t)}}return l(r,n)}function c(e,t,n,r){let i=``,a=null;for(let r of t){let[t,o,s]=r;if(t!=null&&t!==``)s?a=t:(a!=null&&(i+=a,a=null),i+=t);else{let t=o;n!=null&&(t=B(o,n));let r=e.attributes[t];r!=null&&r!==``&&(a!=null&&(i+=a,a=null),i+=r)}}return l(i,r)}function l(e,t){switch(typeof e!=`string`&&(e=String(e)),t){case`LowerCase`:return e.toLowerCase();case`Allcaps`:return e.toUpperCase();default:return e}}function u(e,t,n,r,i,a,o=!0){let s=t/i,c=n/a,l=Math.ceil(s/2),u=Math.ceil(c/2);for(let n=0;n<a;n++)for(let d=0;d<i;d++){let f=(d+(o?a-n-1:n)*i)*4,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=(n+.5)*c;for(let r=Math.floor(n*c);r<(n+1)*c;r++){let n=Math.abs(b-(r+.5))/u,i=(d+.5)*s,a=n*n;for(let n=Math.floor(d*s);n<(d+1)*s;n++){let o=Math.abs(i-(n+.5))/l,s=Math.sqrt(a+o*o);s>=-1&&s<=1&&(p=2*s*s*s-3*s*s+1,p>0&&(o=4*(n+r*t),y+=p*e[o+3],h+=p,e[o+3]<255&&(p=p*e[o+3]/250),g+=p*e[o],_+=p*e[o+1],v+=p*e[o+2],m+=p))}}r[f]=g/m,r[f+1]=_/m,r[f+2]=v/m,r[f+3]=y/h}}function d(e){return e?[e[0],e[1],e[2],e[3]/255]:[0,0,0,0]}function f(e){return e.data?.symbol??null}function p(e){return e.type===`CIMVectorMarker`||e.type===`CIMPictureMarker`||e.type===`CIMBarChartMarker`||e.type===`CIMCharacterMarker`||e.type===`CIMPieChartMarker`||e.type===`CIMStackedBarChartMarker`}function m(e){return e.type===`CIMGradientStroke`||e.type===`CIMPictureStroke`||e.type===`CIMSolidStroke`}function h(e){return e!=null&&(e.type===`CIMGradientFill`||e.type===`CIMHatchFill`||e.type===`CIMPictureFill`||e.type===`CIMSolidFill`||e.type===`CIMWaterFill`)}function g(e){return e!=null&&(e.type===`CIMMarkerPlacementAlongLineRandomSize`||e.type===`CIMMarkerPlacementAlongLineSameSize`||e.type===`CIMMarkerPlacementAlongLineVariableSize`||e.type===`CIMMarkerPlacementAtExtremities`||e.type===`CIMMarkerPlacementAtMeasuredUnits`||e.type===`CIMMarkerPlacementAtRatioPositions`||e.type===`CIMMarkerPlacementOnLine`||e.type===`CIMMarkerPlacementOnVertices`)}const _=(e,t=0)=>e==null||isNaN(e)?t:e,v=(e,t)=>e??t,y=(e,t)=>e??t,b=e=>e.tintColor?d(e.tintColor):[255,255,255,1];function x(e){if(!e)return`normal`;switch(e.toLowerCase()){case`italic`:return`italic`;case`oblique`:return`oblique`;default:return`normal`}}function S(e){if(!e)return`normal`;switch(e.toLowerCase()){case`bold`:return`bold`;case`bolder`:return`bolder`;case`lighter`:return`lighter`;default:return`normal`}}function C(e){return e.underline?`underline`:e.strikethrough?`line-through`:`none`}function w(e){if(!e)return null;switch(e.type){case`CIMPolygonSymbol`:if(e.symbolLayers)for(let t of e.symbolLayers){let e=w(t);if(e!=null)return e}break;case`CIMTextSymbol`:return w(e.symbol);case`CIMSolidFill`:return e.color}return null}function T(e){if(e)switch(e.type){case`CIMPolygonSymbol`:case`CIMLineSymbol`:{let t=e.symbolLayers;if(t)for(let e of t){let t=T(e);if(t!=null)return t}break}case`CIMTextSymbol`:return T(e.symbol);case`CIMSolidStroke`:return e.color}}function E(e){for(let t of e)if(t.enable)switch(t.type){case`CIMSolidStroke`:case`CIMGradientStroke`:case`CIMPictureStroke`:return!0}return!1}function D(e){if(e)switch(e.type){case`CIMPolygonSymbol`:case`CIMLineSymbol`:if(e.symbolLayers)for(let t of e.symbolLayers){let e=D(t);if(e!==void 0)return e}break;case`CIMTextSymbol`:return D(e.symbol);case`CIMSolidStroke`:case`CIMGradientStroke`:case`CIMPictureStroke`:return e.width}}function O(t){let n=0;for(let r of t??[])r.enable!==!1&&m(r)&&(n=Math.max(n,_(r.width,e[r.type].width)));return n}function k(e){switch(e){case`Left`:default:return`left`;case`Right`:return`right`;case`Center`:return`center`;case`Justify`:return`justify`}}function A(e){switch(e){default:return`bottom`;case`Top`:return`top`;case`Center`:return`middle`;case`Baseline`:return`baseline`;case`Bottom`:return`bottom`}}function j(e){return(e?Object.keys(e):[]).map(t=>({name:t,alias:t,type:typeof e[t]==`string`?`esriFieldTypeString`:`esriFieldTypeDouble`}))}const M=e=>e.includes(`data:image/svg+xml`);function N(e){if(!e)return null;switch(e.type){case`CIMPointSymbol`:return`esriGeometryPoint`;case`CIMTextSymbol`:return`esriGeometryPoint`;case`CIMLineSymbol`:return`esriGeometryPolyline`;case`CIMPolygonSymbol`:return`esriGeometryPolygon`;default:return null}}function P(e){return e&&e.charAt(0).toLowerCase()+e.slice(1)}function F(e,t,n,r,i,a,o=!0){let{infos:s}=a,c=1,l=0,u=0,d=0,f=1;for(let{absoluteAnchorPoint:e,offsetX:t,offsetY:n,rotation:r,size:i,frameHeight:a,rotateClockWise:p,scaleSymbolsProportionally:m}of s){f=e?1:c;let s=K(t,n,l,f,u),h=G(t,n,l,f,d);u=s,d=h,a&&(m||o)&&(c*=i/a),l=q(r,p,l)}let p=K(r,i,l,f,u),m=G(r,i,l,f,d);return{size:e*c,rotation:q(t,n,l),offsetX:p,offsetY:m}}function I(e){if(e==null)return!1;if(Array.isArray(e))return e.every(e=>I(e));switch(typeof e){case`string`:return!!e;case`number`:return!isNaN(e)}}function L(n,r){if(r===`color`||r===`outlinecolor`||r===`backgroundcolor`||r===`borderlinecolor`||r===`tintcolor`)return[...t[r]];let i=e[n];if(!i)throw Error(`InternalError: default value for type ${n}.`);return i[r]}function R(e){if(e==null)return`Normal`;switch(e.type){case`CIMTextSymbol`:return e.textCase??`Normal`;case`CIMPointSymbol`:case`CIMLineSymbol`:case`CIMPolygonSymbol`:{let t=e.symbolLayers;if(!t)return`Normal`;for(let e of t)if(e.type===`CIMVectorMarker`)return R(e)}break;case`CIMVectorMarker`:{let t=e.markerGraphics;if(!t)return`Normal`;for(let e of t)if(e.symbol)return R(e.symbol)}}return`Normal`}function z(t){if(t)switch(t.type){case`CIMTextSymbol`:return t.height;case`CIMPointSymbol`:{let n=0;if(t.symbolLayers){for(let r of t.symbolLayers)if(r)switch(r.type){case`CIMCharacterMarker`:case`CIMPictureMarker`:case`CIMVectorMarker`:case`CIMObjectMarker3D`:case`CIMglTFMarker3D`:{let t=r.size??e.CIMVectorMarker.size;t>n&&(n=t);break}}}return n}case`CIMLineSymbol`:case`CIMPolygonSymbol`:{let n=0;if(t.symbolLayers){for(let r of t.symbolLayers)if(r)switch(r.type){case`CIMSolidStroke`:case`CIMPictureStroke`:case`CIMGradientStroke`:{let e=r.width;e!=null&&e>n&&(n=e);break}case`CIMCharacterMarker`:case`CIMPictureMarker`:case`CIMVectorMarker`:case`CIMObjectMarker3D`:case`CIMglTFMarker3D`:if(r.markerPlacement&&g(r.markerPlacement)){let t=r.size??e.CIMVectorMarker.size;t>n&&(n=t)}break;case`CIMPictureFill`:{let e=r.height;e!=null&&e>n&&(n=e)}}}return n}}}function B(e,t){if(t!==null){let n=t.get(e);return n?n.name:e}return e}function V(e){return e.map(e=>({...e,propertyName:P(e.propertyName)}))}function H(e){let t={};for(let n in e){let r=e[n];t[P(n)]=r}return t}function U(e){if(!e)return 0;let t=0;for(let n of e)t+=W(n);return t}function W(e){if(!e)return 0;if(Z(e))return e.inflateSize??256;if(Q(e))return Math.abs(e.inflateSize);switch(e.type){case`CIMGeometricEffectArrow`:return Math.abs(e.width*.5);case`CIMGeometricEffectBuffer`:return Math.abs(e.size);case`CIMGeometricEffectCircularSector`:return Math.abs(e.radius??25);case`CIMGeometricEffectControlMeasureLine`:return 500;case`CIMGeometricEffectExtension`:return Math.abs(e.length);case`CIMGeometricEffectJog`:return Math.abs(e.length*.5);case`CIMGeometricEffectMove`:return Math.max(Math.abs(_(e.offsetX)),Math.abs(_(e.offsetY)));case`CIMGeometricEffectOffset`:return Math.abs(e.offset);case`CIMGeometricEffectOffsetTangent`:return Math.abs(e.offset);case`CIMGeometricEffectRadial`:return Math.abs(e.length??5);case`CIMGeometricEffectRegularPolygon`:return Math.abs(e.radius);case`CIMGeometricEffectRotate`:return 0;case`CIMGeometricEffectScale`:return 0;case`CIMGeometricEffectTaperedPolygon`:return Math.max(Math.abs(e.fromWidth),Math.abs(e.toWidth))*.5;case`CIMGeometricEffectWave`:return Math.abs(e.amplitude);case`CIMGeometricEffectDonut`:return Math.abs(e.width);default:return 0}}function G(e,t,n,r,i){let a=n*Math.PI/180;if(a){let n=Math.cos(a);return(Math.sin(a)*e+n*t)*r+i}return t*r+i}function K(e,t,n,r,i){let a=n*Math.PI/180;if(a){let n=Math.cos(a),o=Math.sin(a);return(n*e-o*t)*r+i}return e*r+i}function q(e,t,n){return t?n-e:n+e}function J(e,t,n){let r=n===`Color`||n===`TintColor`||n===`ToColor`,i=n===`Rotation`||n===`Angle`||n===`ToRotation`,a=t[P(n)];if(a!=null&&(r?a=[a[0]/255,a[1]/255,a[2]/255,a[3]/255]:i&&(a*=Math.PI/180)),a??(a=L(t.type,n.toLowerCase()),a!=null&&(r?a=[a[0]/255,a[1]/255,a[2]/255,a[3]]:i&&(a*=Math.PI/180))),t.primitiveName!=null){let o=e[t.primitiveName];if(o!=null){let e=o[n];e==null||(typeof e==`string`||typeof e==`number`||Array.isArray(e)?(a=e,a!=null&&(r?a=[a[0]/255,a[1]/255,a[2]/255,a[3]/255]:i&&(a*=Math.PI/180))):(a={valueExpressionInfo:e,defaultValue:a},a!=null&&(r?a={type:`Process`,op:`ArcadeColor`,value:a}:i&&(a={type:`Process`,op:`Divide`,left:a,right:180/Math.PI}))))}}if(a==null)throw Error(`Failed to derive a value or an expression for "${n}".`);return a}function Y(e,t,n){if(t[P(n)]!=null)return!0;if(t.primitiveName!=null){let r=e[t.primitiveName];if(r!=null&&r[n]!=null)return!0}return!1}function X(e,t){return Math.max(Math.min((e??t)/100,1),0)}function Z(e){return e.type.startsWith(`Private`)}function Q(e){return e.type===`CIMSimpleLineCallout`||e.type===`CIMBackgroundCallout`||e.type===`CIMBalloonCallout`||e.type===`CIMPointSymbolCallout`}function $(e){return e!=null&&ee(e)?e:void 0}function ee(e){return`setControlPoint`in e&&`getControlPoint`in e&&`setControlPointAt`in e&&`getControlPointAt`in e}export{l as adjustTextCase,o as analyzeTextParts,F as applyParentTransform,$ as asCIMGeometryCursor,c as assignTextValuesFromFeature,j as attributesToFields,i as colorToArray,r as evaluateValueOrFunction,C as fromCIMFontDecoration,k as fromCIMHorizontalAlignment,A as fromCIMVerticalAlignment,L as getDefaultCIMValue,U as getEffectsInflateSize,y as getEnum,B as getFieldName,w as getFillColor,x as getFontStyle,S as getFontWeight,O as getMaxStrokeWidth,_ as getNumericValue,J as getProcessParam,X as getRelativeGradientSize,z as getSize,T as getStrokeColor,D as getStrokeWidth,R as getTextCasing,s as getTextValuesFromFeatureHandle,b as getTintColor,v as getValue,Y as hasProcessParam,E as hasStrokeLayer,h as isCIMFill,p as isCIMMarker,g as isCIMMarkerStrokePlacement,m as isCIMStroke,n as isFeatureValueFn,Z as isPrivateGeometricEffect,M as isSVGImage,I as isValidCIMValue,N as mapCIMSymbolToGeometryType,d as normalizeAlpha,V as normalizePrimitiveOverrideProps,u as resampleHermite,f as toCIMSymbolJSON,H as toLowerCaseProps,P as uncapitalize};
3
+ `.includes(e.charAt(t)))return!1;return!0}function o(e,t){let n=[],r=0,i=-1;do if(i=e.indexOf(`[`,r),i>=r){if(i>r){let t=e.slice(r,i);n.push([t,null,a(t)])}if(r=i+1,i=e.indexOf(`]`,r),i>=r){if(i>r){let a=t[e.slice(r,i)];a&&n.push([null,a,!1])}r=i+1}}while(i!==-1);if(r<e.length){let t=e.slice(r);n.push([t,null,a(t)])}return n}function s(e,t,n){let r=``,i=null;for(let n of t){let[t,a,o]=n;if(t!=null&&t!==``)o?i=t:(i!=null&&(r+=i,i=null),r+=t);else{let t=e.readAttribute(a);t!=null&&t!==``&&(i!==null&&(r+=i,i=null),r+=t)}}return l(r,n)}function c(e,t,n,r){let i=``,a=null;for(let r of t){let[t,o,s]=r;if(t!=null&&t!==``)s?a=t:(a!=null&&(i+=a,a=null),i+=t);else{let t=o;n!=null&&(t=B(o,n));let r=e.attributes[t];r!=null&&r!==``&&(a!=null&&(i+=a,a=null),i+=r)}}return l(i,r)}function l(e,t){switch(typeof e!=`string`&&(e=String(e)),t){case`LowerCase`:return e.toLowerCase();case`Allcaps`:return e.toUpperCase();default:return e}}function u(e,t,n,r,i,a,o=!0){let s=t/i,c=n/a,l=Math.ceil(s/2),u=Math.ceil(c/2);for(let n=0;n<a;n++)for(let d=0;d<i;d++){let f=(d+(o?a-n-1:n)*i)*4,p=0,m=0,h=0,g=0,_=0,v=0,y=(n+.5)*c;for(let r=Math.floor(n*c);r<(n+1)*c;r++){let n=Math.abs(y-(r+.5))/u,i=(d+.5)*s,a=n*n;for(let n=Math.floor(d*s);n<(d+1)*s;n++){let o=Math.abs(i-(n+.5))/l,s=Math.sqrt(a+o*o);s>=-1&&s<=1&&(p=2*s*s*s-3*s*s+1,p>0&&(o=4*(n+r*t),h+=p*e[o],g+=p*e[o+1],_+=p*e[o+2],v+=p*e[o+3],m+=p))}}r[f]=h/m,r[f+1]=g/m,r[f+2]=_/m,r[f+3]=v/m}}function d(e){return e?[e[0],e[1],e[2],e[3]/255]:[0,0,0,0]}function f(e){return e.data?.symbol??null}function p(e){return e.type===`CIMVectorMarker`||e.type===`CIMPictureMarker`||e.type===`CIMBarChartMarker`||e.type===`CIMCharacterMarker`||e.type===`CIMPieChartMarker`||e.type===`CIMStackedBarChartMarker`}function m(e){return e.type===`CIMGradientStroke`||e.type===`CIMPictureStroke`||e.type===`CIMSolidStroke`}function h(e){return e!=null&&(e.type===`CIMGradientFill`||e.type===`CIMHatchFill`||e.type===`CIMPictureFill`||e.type===`CIMSolidFill`||e.type===`CIMWaterFill`)}function g(e){return e!=null&&(e.type===`CIMMarkerPlacementAlongLineRandomSize`||e.type===`CIMMarkerPlacementAlongLineSameSize`||e.type===`CIMMarkerPlacementAlongLineVariableSize`||e.type===`CIMMarkerPlacementAtExtremities`||e.type===`CIMMarkerPlacementAtMeasuredUnits`||e.type===`CIMMarkerPlacementAtRatioPositions`||e.type===`CIMMarkerPlacementOnLine`||e.type===`CIMMarkerPlacementOnVertices`)}const _=(e,t=0)=>e==null||isNaN(e)?t:e,v=(e,t)=>e??t,y=(e,t)=>e??t,b=e=>e.tintColor?d(e.tintColor):[255,255,255,1];function x(e){if(!e)return`normal`;switch(e.toLowerCase()){case`italic`:return`italic`;case`oblique`:return`oblique`;default:return`normal`}}function S(e){if(!e)return`normal`;switch(e.toLowerCase()){case`bold`:return`bold`;case`bolder`:return`bolder`;case`lighter`:return`lighter`;default:return`normal`}}function C(e){return e.underline?`underline`:e.strikethrough?`line-through`:`none`}function w(e){if(!e)return null;switch(e.type){case`CIMPolygonSymbol`:if(e.symbolLayers)for(let t of e.symbolLayers){let e=w(t);if(e!=null)return e}break;case`CIMTextSymbol`:return w(e.symbol);case`CIMSolidFill`:return e.color}return null}function T(e){if(e)switch(e.type){case`CIMPolygonSymbol`:case`CIMLineSymbol`:{let t=e.symbolLayers;if(t)for(let e of t){let t=T(e);if(t!=null)return t}break}case`CIMTextSymbol`:return T(e.symbol);case`CIMSolidStroke`:return e.color}}function E(e){for(let t of e)if(t.enable)switch(t.type){case`CIMSolidStroke`:case`CIMGradientStroke`:case`CIMPictureStroke`:return!0}return!1}function D(e){if(e)switch(e.type){case`CIMPolygonSymbol`:case`CIMLineSymbol`:if(e.symbolLayers)for(let t of e.symbolLayers){let e=D(t);if(e!==void 0)return e}break;case`CIMTextSymbol`:return D(e.symbol);case`CIMSolidStroke`:case`CIMGradientStroke`:case`CIMPictureStroke`:return e.width}}function O(t){let n=0;for(let r of t??[])r.enable!==!1&&m(r)&&(n=Math.max(n,_(r.width,e[r.type].width)));return n}function k(e){switch(e){case`Left`:default:return`left`;case`Right`:return`right`;case`Center`:return`center`;case`Justify`:return`justify`}}function A(e){switch(e){default:return`bottom`;case`Top`:return`top`;case`Center`:return`middle`;case`Baseline`:return`baseline`;case`Bottom`:return`bottom`}}function j(e){return(e?Object.keys(e):[]).map(t=>({name:t,alias:t,type:typeof e[t]==`string`?`esriFieldTypeString`:`esriFieldTypeDouble`}))}const M=e=>e.includes(`data:image/svg+xml`);function N(e){if(!e)return null;switch(e.type){case`CIMPointSymbol`:return`esriGeometryPoint`;case`CIMTextSymbol`:return`esriGeometryPoint`;case`CIMLineSymbol`:return`esriGeometryPolyline`;case`CIMPolygonSymbol`:return`esriGeometryPolygon`;default:return null}}function P(e){return e&&e.charAt(0).toLowerCase()+e.slice(1)}function F(e,t,n,r,i,a,o=!0){let{infos:s}=a,c=1,l=0,u=0,d=0,f=1;for(let{absoluteAnchorPoint:e,offsetX:t,offsetY:n,rotation:r,size:i,frameHeight:a,rotateClockWise:p,scaleSymbolsProportionally:m}of s){f=e?1:c;let s=K(t,n,l,f,u),h=G(t,n,l,f,d);u=s,d=h,a&&(m||o)&&(c*=i/a),l=q(r,p,l)}let p=K(r,i,l,f,u),m=G(r,i,l,f,d);return{size:e*c,rotation:q(t,n,l),offsetX:p,offsetY:m}}function I(e){if(e==null)return!1;if(Array.isArray(e))return e.every(e=>I(e));switch(typeof e){case`string`:return!!e;case`number`:return!isNaN(e)}}function L(n,r){if(r===`color`||r===`outlinecolor`||r===`backgroundcolor`||r===`borderlinecolor`||r===`tintcolor`)return[...t[r]];let i=e[n];if(!i)throw Error(`InternalError: default value for type ${n}.`);return i[r]}function R(e){if(e==null)return`Normal`;switch(e.type){case`CIMTextSymbol`:return e.textCase??`Normal`;case`CIMPointSymbol`:case`CIMLineSymbol`:case`CIMPolygonSymbol`:{let t=e.symbolLayers;if(!t)return`Normal`;for(let e of t)if(e.type===`CIMVectorMarker`)return R(e)}break;case`CIMVectorMarker`:{let t=e.markerGraphics;if(!t)return`Normal`;for(let e of t)if(e.symbol)return R(e.symbol)}}return`Normal`}function z(t){if(t)switch(t.type){case`CIMTextSymbol`:return t.height;case`CIMPointSymbol`:{let n=0;if(t.symbolLayers){for(let r of t.symbolLayers)if(r)switch(r.type){case`CIMCharacterMarker`:case`CIMPictureMarker`:case`CIMVectorMarker`:case`CIMObjectMarker3D`:case`CIMglTFMarker3D`:{let t=r.size??e.CIMVectorMarker.size;t>n&&(n=t);break}}}return n}case`CIMLineSymbol`:case`CIMPolygonSymbol`:{let n=0;if(t.symbolLayers){for(let r of t.symbolLayers)if(r)switch(r.type){case`CIMSolidStroke`:case`CIMPictureStroke`:case`CIMGradientStroke`:{let e=r.width;e!=null&&e>n&&(n=e);break}case`CIMCharacterMarker`:case`CIMPictureMarker`:case`CIMVectorMarker`:case`CIMObjectMarker3D`:case`CIMglTFMarker3D`:if(r.markerPlacement&&g(r.markerPlacement)){let t=r.size??e.CIMVectorMarker.size;t>n&&(n=t)}break;case`CIMPictureFill`:{let e=r.height;e!=null&&e>n&&(n=e)}}}return n}}}function B(e,t){if(t!==null){let n=t.get(e);return n?n.name:e}return e}function V(e){return e.map(e=>({...e,propertyName:P(e.propertyName)}))}function H(e){let t={};for(let n in e){let r=e[n];t[P(n)]=r}return t}function U(e){if(!e)return 0;let t=0;for(let n of e)t+=W(n);return t}function W(e){if(!e)return 0;if(Z(e))return e.inflateSize??256;if(Q(e))return Math.abs(e.inflateSize);switch(e.type){case`CIMGeometricEffectArrow`:return Math.abs(e.width*.5);case`CIMGeometricEffectBuffer`:return Math.abs(e.size);case`CIMGeometricEffectCircularSector`:return Math.abs(e.radius??25);case`CIMGeometricEffectControlMeasureLine`:return 500;case`CIMGeometricEffectExtension`:return Math.abs(e.length);case`CIMGeometricEffectJog`:return Math.abs(e.length*.5);case`CIMGeometricEffectMove`:return Math.max(Math.abs(_(e.offsetX)),Math.abs(_(e.offsetY)));case`CIMGeometricEffectOffset`:return Math.abs(e.offset);case`CIMGeometricEffectOffsetTangent`:return Math.abs(e.offset);case`CIMGeometricEffectRadial`:return Math.abs(e.length??5);case`CIMGeometricEffectRegularPolygon`:return Math.abs(e.radius);case`CIMGeometricEffectRotate`:return 0;case`CIMGeometricEffectScale`:return 0;case`CIMGeometricEffectTaperedPolygon`:return Math.max(Math.abs(e.fromWidth),Math.abs(e.toWidth))*.5;case`CIMGeometricEffectWave`:return Math.abs(e.amplitude);case`CIMGeometricEffectDonut`:return Math.abs(e.width);default:return 0}}function G(e,t,n,r,i){let a=n*Math.PI/180;if(a){let n=Math.cos(a);return(Math.sin(a)*e+n*t)*r+i}return t*r+i}function K(e,t,n,r,i){let a=n*Math.PI/180;if(a){let n=Math.cos(a),o=Math.sin(a);return(n*e-o*t)*r+i}return e*r+i}function q(e,t,n){return t?n-e:n+e}function J(e,t,n){let r=n===`Color`||n===`TintColor`||n===`ToColor`,i=n===`Rotation`||n===`Angle`||n===`ToRotation`,a=t[P(n)];if(a!=null&&(r?a=[a[0]/255,a[1]/255,a[2]/255,a[3]/255]:i&&(a*=Math.PI/180)),a??(a=L(t.type,n.toLowerCase()),a!=null&&(r?a=[a[0]/255,a[1]/255,a[2]/255,a[3]]:i&&(a*=Math.PI/180))),t.primitiveName!=null){let o=e[t.primitiveName];if(o!=null){let e=o[n];e==null||(typeof e==`string`||typeof e==`number`||Array.isArray(e)?(a=e,a!=null&&(r?a=[a[0]/255,a[1]/255,a[2]/255,a[3]/255]:i&&(a*=Math.PI/180))):(a={valueExpressionInfo:e,defaultValue:a},a!=null&&(r?a={type:`Process`,op:`ArcadeColor`,value:a}:i&&(a={type:`Process`,op:`Divide`,left:a,right:180/Math.PI}))))}}if(a==null)throw Error(`Failed to derive a value or an expression for "${n}".`);return a}function Y(e,t,n){if(t[P(n)]!=null)return!0;if(t.primitiveName!=null){let r=e[t.primitiveName];if(r!=null&&r[n]!=null)return!0}return!1}function X(e,t){return Math.max(Math.min((e??t)/100,1),0)}function Z(e){return e.type.startsWith(`Private`)}function Q(e){return e.type===`CIMSimpleLineCallout`||e.type===`CIMBackgroundCallout`||e.type===`CIMBalloonCallout`||e.type===`CIMPointSymbolCallout`}function $(e){return e!=null&&ee(e)?e:void 0}function ee(e){return`setControlPoint`in e&&`getControlPoint`in e&&`setControlPointAt`in e&&`getControlPointAt`in e}export{l as adjustTextCase,o as analyzeTextParts,F as applyParentTransform,$ as asCIMGeometryCursor,c as assignTextValuesFromFeature,j as attributesToFields,i as colorToArray,r as evaluateValueOrFunction,C as fromCIMFontDecoration,k as fromCIMHorizontalAlignment,A as fromCIMVerticalAlignment,L as getDefaultCIMValue,U as getEffectsInflateSize,y as getEnum,B as getFieldName,w as getFillColor,x as getFontStyle,S as getFontWeight,O as getMaxStrokeWidth,_ as getNumericValue,J as getProcessParam,X as getRelativeGradientSize,z as getSize,T as getStrokeColor,D as getStrokeWidth,R as getTextCasing,s as getTextValuesFromFeatureHandle,b as getTintColor,v as getValue,Y as hasProcessParam,E as hasStrokeLayer,h as isCIMFill,p as isCIMMarker,g as isCIMMarkerStrokePlacement,m as isCIMStroke,n as isFeatureValueFn,Z as isPrivateGeometricEffect,M as isSVGImage,I as isValidCIMValue,N as mapCIMSymbolToGeometryType,d as normalizeAlpha,V as normalizePrimitiveOverrideProps,u as resampleHermite,f as toCIMSymbolJSON,H as toLowerCaseProps,P as uncapitalize};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import e from"../../../../config.js";import t from"../../../../request.js";import n from"../../../../core/Error.js";import r from"../../../../core/Logger.js";import{throwIfAborted as i,isAbortError as a}from"../../../../core/promiseUtils.js";import{QueueProcessor as o}from"../../../../core/QueueProcessor.js";import{pt2px as s}from"../../../../core/screenUtils.js";import{numericHash as c}from"../../../../core/string.js";import l from"../../../../symbols/cim/CIMResourceManager.js";import{CIMSymbolHelper as u}from"../../../../symbols/cim/CIMSymbolHelper.js";import{normalizeDashTemplate as d}from"../../../../symbols/cim/dashUtils.js";import f from"../../../../symbols/cim/Rasterizer.js";import{svgSdfTextureInnerSize as p,textureBindingGlyphAtlas as m,textureBindingSpriteAtlas as h}from"./definitions.js";import{GlyphMosaic as g}from"./GlyphMosaic.js";import{hashMosaic as _}from"./hashMosaic.js";import v from"./Rect.js";import y from"./SDFConverter.js";import b from"./SpriteMosaic.js";import{discardUrlIfHasUrlHash as x}from"./urlUtils.js";import{AnimatableTextureResource as S}from"./animatedFormats/AnimatableTextureResource.js";import{AnimationStore as C}from"./animations/store/AnimationStore.js";const w=()=>r.getLogger(`esri.views.MapView`),T=(e,t,r)=>w().error(new n(e,t,r));class E{static fromMosaic(e,t){return new E(e,t.page,t.sdf,t.samplingMode)}constructor(e,t,n,r){this.mosaicType=e,this.page=t,this.sdf=n,this.samplingMode=r}}class D{constructor(r){this._requestRender=r,this._resourceManager=new l,this._sdfConverter=new y(p),this._hashToBindingInfo=new Map,this._ongoingRasterizations=new Map,this._imageRequestQueue=new o({concurrency:10,process:async(e,r)=>{i(r);try{return await t(e,{responseType:`image`,signal:r})}catch(t){throw a(t)?t:new n(`mapview-invalid-resource`,`Could not fetch requested resource at ${e}`,t)}}}),this.animationStore=new C,this._spriteMosaic=new b(2048,2048,500),this._glyphMosaic=new g(1024,1024,!1,e=>this._setTextureBinding(1,e)),this._rasterizer=new f(this.resourceManager),this._baseUrl=`${e.fontsUrl}/{fontstack}/{range}.pbf`}dispose(){this._spriteMosaic.dispose(),this._glyphMosaic.dispose(),this._rasterizer.dispose(),this._sdfConverter.dispose(),this._spriteMosaic=null,this._glyphMosaic=null,this._sdfConverter=null,this._hashToBindingInfo.clear(),this._hashToBindingInfo=null,this._ongoingRasterizations.clear(),this._ongoingRasterizations=null,this._imageRequestQueue.clear(),this._imageRequestQueue=null,this._resourceManager.destroy(),this.animationStore.destroy()}get sprites(){return this._spriteMosaic}get glyphs(){return this._glyphMosaic}get resourceManager(){return this._resourceManager}openMessagePorts(){return this._glyphMosaic.openMessagePorts()}async rasterizeItem(e,t){if(e==null)return T(`mapview-null-resource`,`Unable to rasterize null resource`),null;if(e.type===`animation-info`){let{resource:t}=e,{location:n}=this.animationStore.add(t);return{rect:new v(n.column,n.row,t.length,1),page:n.page,textureBinding:1,type:`sprite`,width:t.length,height:1,rasterizationScale:1,sdfPaddingRatio:.5,samplingMode:`Linear`,sdfDecodeCoeff:1,simplePattern:!1}}if(e.type!==`cim-rasterization-info`)return T(`mapview-unexpected-resource`,`Unable to rasterize resource`),null;let{resource:n}=e;if(n.type===`text`){let e=await this._rasterizeText(n,t);return this._forEachGlyphItem(e,e=>this._setTextureBinding(1,e.mosaicItem)),e}let r=await this._rasterizeSprite(n,t);return r&&this._setTextureBinding(0,r),r}getBindingInfo(e,t,n){let{context:r}=e,i=this._hashToBindingInfo.get(t);if(!i)return T(`mapview-texture-manager`,`Could not find binding info for textureKey ${t}!`),{mosaicInfo:{size:[0,0]},mosaicTexture:null};let a=i.page,o=i.samplingMode===`Nearest`?9728:n?9987:9729,s,c,l;if(i.mosaicType===0)c=this._spriteMosaic.getTexture(e,a),l=h,s=this._spriteMosaic.getSize(a);else if(i.mosaicType===1)c=this._glyphMosaic.getTexture(r,a),l=m,s=[this.glyphs.width,this.glyphs.height],this._glyphMosaic.bind(r,o,a,m);else return T(`mapview-texture-manager`,`Cannot handle unknown type ${i.mosaicType}`),{mosaicInfo:{size:[0,0]},mosaicTexture:null};return c.setSamplingMode(o),{mosaicInfo:{size:s},mosaicTexture:{texture:c,unit:l}}}_setTextureBinding(e,t){let{sdf:n,samplingMode:r,page:i}=t,a=_(e,i,!!n,r);if(!this._hashToBindingInfo.has(a)){let n=E.fromMosaic(e,t);this._hashToBindingInfo.set(a,n)}return t.textureBinding=a,a}async _rasterizeText(e,t){return this._glyphMosaic.rasterizeText(this._baseUrl,e,t)}_forEachGlyphItem(e,t){if(e){if(e.type===`glyphs`){e.glyphs.forEach(t);return}for(let n of e.runs)n.glyphs.glyphs.forEach(t)}}_hashSpriteResource(e){switch(e.type){case`path`:return`path:${e.path}.${+!!e.asFill}`;case`CIMPictureMarker`:return`${e.type}:${e.url}:${e.size}:${k(e.markerPlacement)}`;case`CIMPictureFill`:return`${e.type}:${e.url}:${e.height}`;case`CIMPictureStroke`:return`${e.type}:${e.url}:${e.width}`;case`dash`:return`dash:${e.capStyle}.${d(e.dashTemplate).join(``)}`;case`sdf`:return`sdf:${JSON.stringify(e.geometry)}.${e.sdfTextureSize}.${+!!e.asFill}`;case`fill-style`:return`fill_style:${e.style}`;case`animated`:return JSON.stringify(x(e));case`CIMGradientFill`:case`CIMGradientStroke`:return`gradient:${JSON.stringify(e.colorRamp)}.${e.gradientType}.${e.interval}`;case`CIMHatchFill`:case`CIMVectorMarker`:case`cim-point-symbol-halo`:return JSON.stringify(e)}}async _rasterizeSprite(e,t){if(!e)return null;let n=c(this._hashSpriteResource(e));if(this._spriteMosaic.has(n))return this._spriteMosaic.getSpriteItem(n);if(`url`in e&&e.url&&e.type!==`animated`||e.type===`CIMPictureFill`||e.type===`CIMPictureStroke`||e.type===`CIMPictureMarker`||e.type===`CIMVectorMarker`||e.type===`cim-point-symbol-halo`){let t=e.type===`cim-point-symbol-halo`?e.symbol:{type:`CIMPointSymbol`,symbolLayers:[e]};await u.normalizeSymbolAndFetchResources(t,this._resourceManager)}switch(e.type){case`CIMPictureMarker`:return e.markerPlacement?.type===`CIMMarkerPlacementInsidePolygon`?this._rasterizeJSONResource(n,e):this._handleAsyncResource(n,e,t);case`animated`:return this._handleAsyncResource(n,e,t);case`CIMPictureFill`:case`CIMPictureStroke`:case`path`:return this._handleAsyncResource(n,e,t);case`CIMGradientFill`:case`CIMGradientStroke`:case`CIMHatchFill`:case`CIMVectorMarker`:case`cim-point-symbol-halo`:case`dash`:case`fill-style`:case`sdf`:return this._rasterizeJSONResource(n,e)}}_rasterizeJSONResource(e,t){let n=this._rasterizer.rasterizeJSONResource(t);if(n){let{size:r,image:i,sdf:a,simplePattern:o,rasterizationScale:s,samplingMode:c,sdfPaddingRatio:l,sdfDecodeCoeff:u}=n;return this._addItemToMosaic(e,r,{type:`static`,data:i},A(t),a,o,s,c,l,u)}return null}async _handleAsyncResource(e,t,n){if(this._ongoingRasterizations.has(e))return this._ongoingRasterizations.get(e);let r;return r=t.type===`path`?this._handleSVG(t,e,n):this._handleImage(t,e,n),this._ongoingRasterizations.set(e,r),r.finally(()=>this._ongoingRasterizations.delete(e)),r}async _handleSVG(e,t,n){let r=[p,p],{asFill:i}=e,a=await this._sdfConverter.draw(e.path,i,n);return this._addItemToMosaic(t,r,{type:`static`,data:new Uint32Array(a.buffer)},!1,!0,!0)}_handleGIFOrPNG(e,t,n){let r=e.url,i=this.resourceManager.getResource(r);if(i==null)return null;let{width:a,height:o}=i;if(i instanceof HTMLImageElement){if(e.type===`animated`)return T(`mapview-unexpected-resource`,`Attempt to configure animations for a non-animated image.`),null;let n=`colorSubstitutions`in e?e.colorSubstitutions:void 0,{size:r,sdf:s,image:c}=this._rasterizer.rasterizeImageResource(a,o,i,n);return this._addItemToMosaic(t,r,{type:`static`,data:c},A(e),s,!1)}let s,c,l;e.type===`animated`?(s=!1,c={type:`CIMAnimatedSymbolProperties`,playAnimation:e.playAnimation,reverseAnimation:e.reverseAnimation,randomizeStartTime:e.randomizeStartTime,randomizeStartSeed:e.randomizeStartSeed,startTimeOffset:e.startTimeOffset,duration:e.duration,repeatType:e.repeatType,repeatDelay:e.repeatDelay},l=e.startGroup||0):(s=A(e),c={type:`CIMAnimatedSymbolProperties`,playAnimation:!0},l=0);let u=new S(i,this._requestRender,c,l);return this._addItemToMosaic(t,[u.width,u.height],{type:`animated`,data:u},s,!1,!1)}async _handleImage(e,t,r){let i=e.url;if(M(i)||P(i))return this._handleGIFOrPNG(e,t,r);if(e.type===`animated`)return T(`mapview-unexpected-resource`,`Attempt to configure animations for a non-animated image.`),null;try{let n,a=this.resourceManager.getResource(i);if(a!=null&&a instanceof HTMLImageElement)n=a;else{let{data:e}=await this._imageRequestQueue.push(i,{...r});n=e}if(O(i)){if(`width`in e&&`height`in e)n.width=s(e.width),n.height=s(e.height);else if(`cim`in e){let t=e;n.width=s(t.width??t.scaleX*t.size),n.height=s(t.size)}}if(!n.width||!n.height)return null;let o=n.width,c=n.height,l=`colorSubstitutions`in e?e.colorSubstitutions:void 0,{size:u,sdf:d,image:f}=this._rasterizer.rasterizeImageResource(o,c,n,l);return this._addItemToMosaic(t,u,{type:`static`,data:f},A(e),d,!1)}catch(e){throw a(e)?e:new n(`mapview-invalid-resource`,`Could not fetch requested resource at ${i}. ${e.message}`)}}_addItemToMosaic(e,t,n,r,i,a,o,s,c,l){return this._spriteMosaic.addSpriteItem(e,t,n,r,i,a,o,s,c,l)}}function O(e){return e.includes(`data:image/svg+xml`)}function k(e){if(e==null)return``;let{type:t}=e;switch(t){case`CIMMarkerPlacementAlongLineRandomSize`:return`${t}-${e.seed}-${e.randomization}`;case`CIMMarkerPlacementAlongLineVariableSize`:return`${t}-${e.maxRandomOffset}-${e.numberOfSizes}-${e.seed}-${e.variationMethod}`;case`CIMMarkerPlacementAtExtremities`:return`${t}-${e.extremityPlacement}-${e.offsetAlongLine}`;case`CIMMarkerPlacementAtRatioPositions`:return`${t}-${e.beginPosition}-${e.endPosition}-${e.flipFirst}-${JSON.stringify(e.positionArray)}`;case`CIMMarkerPlacementAtMeasuredUnits`:return`${t}-${e.interval}-${e.skipMarkerRate}-${e.placeAtExtremities}`;case`CIMMarkerPlacementInsidePolygon`:return`${t}-${e.stepX}-${e.stepY}-${e.randomness}-${e.gridType}-${e.seed}-${e.shiftOddRows}`;case`CIMMarkerPlacementOnLine`:return`${t}-${e.relativeTo}-${e.startPointOffset}`;case`CIMMarkerPlacementOnVertices`:return`${t}-${e.placeOnControlPoints}-${e.placeOnEndPoints}-${e.placeOnRegularVertices}`;case`CIMMarkerPlacementPolygonCenter`:return`${t}-${e.method}`;default:return`${t}`}}function A(e){switch(e.type){case`CIMVectorMarker`:case`CIMPictureMarker`:return F(e);case`cim-point-symbol-halo`:return!1;default:return!0}}const j=e=>e!=null&&e.startsWith(`data:image/gif`),M=e=>e&&(e.includes(`.gif`)||j(e)),N=e=>e!=null&&e.startsWith(`data:image/png`),P=e=>e&&(e.includes(`.png`)||N(e)),F=e=>e&&`markerPlacement`in e&&e.markerPlacement&&e.markerPlacement.type===`CIMMarkerPlacementInsidePolygon`;export{D as TextureManager};
2
+ import e from"../../../../config.js";import t from"../../../../request.js";import n from"../../../../core/Error.js";import r from"../../../../core/Logger.js";import{throwIfAborted as i,isAbortError as a}from"../../../../core/promiseUtils.js";import{QueueProcessor as o}from"../../../../core/QueueProcessor.js";import{pt2px as s}from"../../../../core/screenUtils.js";import{numericHash as c}from"../../../../core/string.js";import l from"../../../../symbols/cim/CIMResourceManager.js";import{CIMSymbolHelper as u}from"../../../../symbols/cim/CIMSymbolHelper.js";import{normalizeDashTemplate as d}from"../../../../symbols/cim/dashUtils.js";import f from"../../../../symbols/cim/Rasterizer.js";import{svgSdfTextureInnerSize as p,textureBindingGlyphAtlas as m,textureBindingSpriteAtlas as h}from"./definitions.js";import{GlyphMosaic as g}from"./GlyphMosaic.js";import{hashMosaic as _}from"./hashMosaic.js";import v from"./Rect.js";import y from"./SDFConverter.js";import b from"./SpriteMosaic.js";import{discardUrlIfHasUrlHash as x}from"./urlUtils.js";import{AnimatableTextureResource as S}from"./animatedFormats/AnimatableTextureResource.js";import{AnimationStore as C}from"./animations/store/AnimationStore.js";const w=()=>r.getLogger(`esri.views.MapView`),T=(e,t,r)=>w().error(new n(e,t,r));class E{static fromMosaic(e,t){return new E(e,t.page,t.sdf,t.samplingMode)}constructor(e,t,n,r){this.mosaicType=e,this.page=t,this.sdf=n,this.samplingMode=r}}class D{constructor(r){this._requestRender=r,this._resourceManager=new l,this._sdfConverter=new y(p),this._hashToBindingInfo=new Map,this._ongoingRasterizations=new Map,this._imageRequestQueue=new o({concurrency:10,process:async(e,r)=>{i(r);try{return await t(e,{responseType:`image`,signal:r})}catch(t){throw a(t)?t:new n(`mapview-invalid-resource`,`Could not fetch requested resource at ${e}`,t)}}}),this.animationStore=new C,this._spriteMosaic=new b(2048,2048,500),this._glyphMosaic=new g(1024,1024,!1,e=>this._setTextureBinding(1,e)),this._rasterizer=new f(this.resourceManager),this._baseUrl=`${e.fontsUrl}/{fontstack}/{range}.pbf`}dispose(){this._spriteMosaic.dispose(),this._glyphMosaic.dispose(),this._rasterizer.dispose(),this._sdfConverter.dispose(),this._spriteMosaic=null,this._glyphMosaic=null,this._sdfConverter=null,this._hashToBindingInfo.clear(),this._hashToBindingInfo=null,this._ongoingRasterizations.clear(),this._ongoingRasterizations=null,this._imageRequestQueue.clear(),this._imageRequestQueue=null,this._resourceManager.destroy(),this.animationStore.destroy()}get sprites(){return this._spriteMosaic}get glyphs(){return this._glyphMosaic}get resourceManager(){return this._resourceManager}openMessagePorts(){return this._glyphMosaic.openMessagePorts()}async rasterizeItem(e,t){if(e==null)return T(`mapview-null-resource`,`Unable to rasterize null resource`),null;if(e.type===`animation-info`){let{resource:t}=e,{location:n}=this.animationStore.add(t);return{rect:new v(n.column,n.row,t.length,1),page:n.page,textureBinding:1,type:`sprite`,width:t.length,height:1,rasterizationScale:1,sdfPaddingRatio:.5,samplingMode:`Linear`,sdfDecodeCoeff:1,simplePattern:!1}}if(e.type!==`cim-rasterization-info`)return T(`mapview-unexpected-resource`,`Unable to rasterize resource`),null;let{resource:n}=e;if(n.type===`text`){let e=await this._rasterizeText(n,t);return this._forEachGlyphItem(e,e=>this._setTextureBinding(1,e.mosaicItem)),e}let r=await this._rasterizeSprite(n,t);return r&&this._setTextureBinding(0,r),r}getBindingInfo(e,t,n){let{context:r}=e,i=this._hashToBindingInfo.get(t);if(!i)return T(`mapview-texture-manager`,`Could not find binding info for textureKey ${t}!`),{mosaicInfo:{size:[0,0]},mosaicTexture:null};let a=i.page,o=i.samplingMode===`Nearest`?9728:n?9987:9729,s,c,l;if(i.mosaicType===0)c=this._spriteMosaic.getTexture(e,a),l=h,s=this._spriteMosaic.getSize(a);else if(i.mosaicType===1)c=this._glyphMosaic.getTexture(r,a),l=m,s=[this.glyphs.width,this.glyphs.height],this._glyphMosaic.bind(r,o,a,m);else return T(`mapview-texture-manager`,`Cannot handle unknown type ${i.mosaicType}`),{mosaicInfo:{size:[0,0]},mosaicTexture:null};return c.setSamplingMode(o),{mosaicInfo:{size:s},mosaicTexture:{texture:c,unit:l}}}_setTextureBinding(e,t){let{sdf:n,samplingMode:r,page:i}=t,a=_(e,i,!!n,r);if(!this._hashToBindingInfo.has(a)){let n=E.fromMosaic(e,t);this._hashToBindingInfo.set(a,n)}return t.textureBinding=a,a}async _rasterizeText(e,t){return this._glyphMosaic.rasterizeText(this._baseUrl,e,t)}_forEachGlyphItem(e,t){if(e){if(e.type===`glyphs`){e.glyphs.forEach(t);return}for(let n of e.runs)n.glyphs.glyphs.forEach(t)}}_hashSpriteResource(e){switch(e.type){case`path`:return`path:${e.path}.${+!!e.asFill}`;case`CIMPictureMarker`:return`${e.type}:${e.url}:${e.size}:${k(e.markerPlacement)}`;case`CIMPictureFill`:return`${e.type}:${e.url}:${e.height}`;case`CIMPictureStroke`:return`${e.type}:${e.url}:${e.width}`;case`dash`:return`dash:${e.capStyle}.${d(e.dashTemplate).join(``)}`;case`sdf`:return`sdf:${JSON.stringify(e.geometry)}.${e.sdfTextureSize}.${+!!e.asFill}`;case`fill-style`:return`fill_style:${e.style}`;case`animated`:return JSON.stringify(x(e));case`CIMGradientFill`:case`CIMGradientStroke`:return`gradient:${JSON.stringify(e.colorRamp)}.${e.gradientType}.${e.interval}`;case`CIMHatchFill`:case`CIMVectorMarker`:case`cim-point-symbol-halo`:return JSON.stringify(e)}}async _rasterizeSprite(e,t){if(!e)return null;let n=c(this._hashSpriteResource(e));if(this._spriteMosaic.has(n))return this._spriteMosaic.getSpriteItem(n);if(`url`in e&&e.url&&e.type!==`animated`||e.type===`CIMPictureFill`||e.type===`CIMPictureStroke`||e.type===`CIMPictureMarker`||e.type===`CIMVectorMarker`||e.type===`cim-point-symbol-halo`){let t=e.type===`cim-point-symbol-halo`?e.symbol:{type:`CIMPointSymbol`,symbolLayers:[e]};await u.normalizeSymbolAndFetchResources(t,this._resourceManager)}switch(e.type){case`CIMPictureMarker`:return e.markerPlacement?.type===`CIMMarkerPlacementInsidePolygon`?this._rasterizeJSONResource(n,e):this._handleAsyncResource(n,e,t);case`animated`:return this._handleAsyncResource(n,e,t);case`CIMPictureFill`:case`CIMPictureStroke`:case`path`:return this._handleAsyncResource(n,e,t);case`CIMGradientFill`:case`CIMGradientStroke`:case`CIMHatchFill`:case`CIMVectorMarker`:case`cim-point-symbol-halo`:case`dash`:case`fill-style`:case`sdf`:return this._rasterizeJSONResource(n,e)}}_rasterizeJSONResource(e,t){let n=this._rasterizer.rasterizeJSONResource(t);if(n){let{size:r,image:i,sdf:a,simplePattern:o,rasterizationScale:s,samplingMode:c,sdfPaddingRatio:l,sdfDecodeCoeff:u}=n;return this._addItemToMosaic(e,r,{type:`static`,data:i},A(t),a,o,s,c,l,u)}return null}async _handleAsyncResource(e,t,n){if(this._ongoingRasterizations.has(e))return this._ongoingRasterizations.get(e);let r;return r=t.type===`path`?this._handleSVG(t,e,n):this._handleImage(t,e,n),this._ongoingRasterizations.set(e,r),r.finally(()=>this._ongoingRasterizations.delete(e)),r}async _handleSVG(e,t,n){let r=[p,p],{asFill:i}=e,a=await this._sdfConverter.draw(e.path,i,n);return this._addItemToMosaic(t,r,{type:`static`,data:new Uint32Array(a.buffer)},!1,!0,!0)}_handleGIFOrPNG(e,t,n){let r=e.url,i=this.resourceManager.getResource(r);if(i==null)return null;let{width:a,height:o}=i;if(i instanceof HTMLImageElement){if(e.type===`animated`)return T(`mapview-unexpected-resource`,`Attempt to configure animations for a non-animated image.`),null;let n=`colorSubstitutions`in e?e.colorSubstitutions:void 0,{size:r,sdf:s,image:c}=this._rasterizer.rasterizeImageResource(a,o,i,n,e.type===`CIMPictureMarker`?128:void 0);return this._addItemToMosaic(t,r,{type:`static`,data:c},A(e),s,!1)}let s,c,l;e.type===`animated`?(s=!1,c={type:`CIMAnimatedSymbolProperties`,playAnimation:e.playAnimation,reverseAnimation:e.reverseAnimation,randomizeStartTime:e.randomizeStartTime,randomizeStartSeed:e.randomizeStartSeed,startTimeOffset:e.startTimeOffset,duration:e.duration,repeatType:e.repeatType,repeatDelay:e.repeatDelay},l=e.startGroup||0):(s=A(e),c={type:`CIMAnimatedSymbolProperties`,playAnimation:!0},l=0);let u=new S(i,this._requestRender,c,l);return this._addItemToMosaic(t,[u.width,u.height],{type:`animated`,data:u},s,!1,!1)}async _handleImage(e,t,r){let i=e.url;if(M(i)||P(i))return this._handleGIFOrPNG(e,t,r);if(e.type===`animated`)return T(`mapview-unexpected-resource`,`Attempt to configure animations for a non-animated image.`),null;try{let n,a=this.resourceManager.getResource(i);if(a!=null&&a instanceof HTMLImageElement)n=a;else{let{data:e}=await this._imageRequestQueue.push(i,{...r});n=e}if(O(i)){if(`width`in e&&`height`in e)n.width=s(e.width),n.height=s(e.height);else if(`cim`in e){let t=e;n.width=s(t.width??t.scaleX*t.size),n.height=s(t.size)}}if(!n.width||!n.height)return null;let o=n.width,c=n.height,l=`colorSubstitutions`in e?e.colorSubstitutions:void 0,{size:u,sdf:d,image:f}=this._rasterizer.rasterizeImageResource(o,c,n,l,e.type===`CIMPictureMarker`?128:void 0);return this._addItemToMosaic(t,u,{type:`static`,data:f},A(e),d,!1)}catch(e){throw a(e)?e:new n(`mapview-invalid-resource`,`Could not fetch requested resource at ${i}. ${e.message}`)}}_addItemToMosaic(e,t,n,r,i,a,o,s,c,l){return this._spriteMosaic.addSpriteItem(e,t,n,r,i,a,o,s,c,l)}}function O(e){return e.includes(`data:image/svg+xml`)}function k(e){if(e==null)return``;let{type:t}=e;switch(t){case`CIMMarkerPlacementAlongLineRandomSize`:return`${t}-${e.seed}-${e.randomization}`;case`CIMMarkerPlacementAlongLineVariableSize`:return`${t}-${e.maxRandomOffset}-${e.numberOfSizes}-${e.seed}-${e.variationMethod}`;case`CIMMarkerPlacementAtExtremities`:return`${t}-${e.extremityPlacement}-${e.offsetAlongLine}`;case`CIMMarkerPlacementAtRatioPositions`:return`${t}-${e.beginPosition}-${e.endPosition}-${e.flipFirst}-${JSON.stringify(e.positionArray)}`;case`CIMMarkerPlacementAtMeasuredUnits`:return`${t}-${e.interval}-${e.skipMarkerRate}-${e.placeAtExtremities}`;case`CIMMarkerPlacementInsidePolygon`:return`${t}-${e.stepX}-${e.stepY}-${e.randomness}-${e.gridType}-${e.seed}-${e.shiftOddRows}`;case`CIMMarkerPlacementOnLine`:return`${t}-${e.relativeTo}-${e.startPointOffset}`;case`CIMMarkerPlacementOnVertices`:return`${t}-${e.placeOnControlPoints}-${e.placeOnEndPoints}-${e.placeOnRegularVertices}`;case`CIMMarkerPlacementPolygonCenter`:return`${t}-${e.method}`;default:return`${t}`}}function A(e){switch(e.type){case`CIMVectorMarker`:case`CIMPictureMarker`:return F(e);case`cim-point-symbol-halo`:return!1;default:return!0}}const j=e=>e!=null&&e.startsWith(`data:image/gif`),M=e=>e&&(e.includes(`.gif`)||j(e)),N=e=>e!=null&&e.startsWith(`data:image/png`),P=e=>e&&(e.includes(`.png`)||N(e)),F=e=>e&&`markerPlacement`in e&&e.markerPlacement&&e.markerPlacement.type===`CIMMarkerPlacementInsidePolygon`;export{D as TextureManager};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{destroyMaybe as n}from"../../../../core/maybe.js";import{watch as r,sync as i}from"../../../../core/reactiveUtils.js";import{property as a,subclass as o}from"../../../../core/accessorSupport/decorators.js";import s from"../../../../geometry/Extent.js";import{fallbackObjectIDAttribute as c}from"../../../../layers/LayerConstants.js";import{QueryEngine as l}from"../../../../layers/graphics/data/QueryEngine.js";import u from"../../../../layers/support/FieldsIndex.js";import d from"../../../../rest/support/FeatureSet.js";import f from"../../../../rest/support/Query.js";const p=l;let m=class extends t{constructor(e){super(e)}initialize(){this.addHandles(this.layerView.on(`visible-geometry-changed`,()=>this.spatialIndex.events.emit(`changed`))),this.addHandles(r(()=>this.layerView.availableFields,()=>this._dataQueryEngineInstance=n(this._dataQueryEngineInstance),i))}destroy(){this._dataQueryEngineInstance=n(this._dataQueryEngineInstance),this._set(`layerView`,null)}get spatialReference(){return this.layerView.view.spatialReference}get layer(){return this.layerView.layer}get defaultQueryJSON(){return new f({outSpatialReference:this.spatialReference}).toJSON()}get _dataQueryEngine(){return this._ensureDataQueryEngine()}async executeQueryForCount(e,t){return this._dataQueryEngine.executeQueryForCount(this._ensureQueryJSON(e),t)}async executeQueryForExtent(e,t){let{count:n,extent:r}=await this._dataQueryEngine.executeQueryForExtent(this._ensureQueryJSON(e),t);return{count:n,extent:s.fromJSON(r)}}async executeQueryForIds(e,t){return this._dataQueryEngine.executeQueryForIds(this._ensureQueryJSON(e),t)}async executeQuery(e,t){let n=this._ensureQueryJSON(e),r=await this._dataQueryEngine.executeQuery(n,t);if(e?.returnGeometry){let{processQueryGeometries:e}=await import(`./I3SQueryResultGeometry.js`);return e(this.layerView,r)}return d.fromJSON(r)}_ensureQueryJSON(e){return e==null?this.defaultQueryJSON:e.toJSON()}_ensureDataQueryEngine(){if(this._dataQueryEngineInstance)return this._dataQueryEngineInstance;let e=this.layer.objectIdField||c,t=this.layer.fieldsIndex?.toJSON()||new u([]),n=this.layerView.view.resourceController.scheduler,r=this.spatialReference.toJSON(),i=this.priority,a=this.spatialIndex,o=this.layerView.availableFields??[];return this._dataQueryEngineInstance=new p({hasZ:!0,hasM:!1,geometryType:`esriGeometryPolygon`,fieldsIndex:t,timeInfo:null,spatialReference:r,featureIdInfo:{type:`object-id`,fieldName:e},featureStore:a,scheduler:n,priority:i,availableFields:o}),this._dataQueryEngineInstance}};e([a({constructOnly:!0})],m.prototype,`layerView`,void 0),e([a({constructOnly:!0})],m.prototype,`priority`,void 0),e([a({constructOnly:!0})],m.prototype,`spatialIndex`,void 0),e([a()],m.prototype,`spatialReference`,null),e([a()],m.prototype,`layer`,null),e([a()],m.prototype,`defaultQueryJSON`,null),m=e([o(`esri.views.3d.layers.i3s.I3SQueryEngine`)],m);export{m as I3SQueryEngine};
2
+ import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{destroyMaybe as n}from"../../../../core/maybe.js";import{watch as r,sync as i}from"../../../../core/reactiveUtils.js";import{property as a,subclass as o}from"../../../../core/accessorSupport/decorators.js";import s from"../../../../geometry/Extent.js";import{fallbackObjectIDAttribute as c}from"../../../../layers/LayerConstants.js";import{QueryEngine as l}from"../../../../layers/graphics/data/QueryEngine.js";import u from"../../../../layers/support/FieldsIndex.js";import d from"../../../../rest/support/FeatureSet.js";import f from"../../../../rest/support/Query.js";const p=l;let m=class extends t{constructor(e){super(e)}initialize(){this.addHandles(this.layerView.on(`visible-geometry-changed`,()=>this.spatialIndex.events.emit(`changed`))),this.addHandles(r(()=>[this.layerView.availableFields,this.layer.timeInfo?.toJSON()],()=>this._dataQueryEngineInstance=n(this._dataQueryEngineInstance),i))}destroy(){this._dataQueryEngineInstance=n(this._dataQueryEngineInstance),this._set(`layerView`,null)}get spatialReference(){return this.layerView.view.spatialReference}get layer(){return this.layerView.layer}get defaultQueryJSON(){return new f({outSpatialReference:this.spatialReference}).toJSON()}get _dataQueryEngine(){return this._ensureDataQueryEngine()}async executeQueryForCount(e,t){return this._dataQueryEngine.executeQueryForCount(this._ensureQueryJSON(e),t)}async executeQueryForExtent(e,t){let{count:n,extent:r}=await this._dataQueryEngine.executeQueryForExtent(this._ensureQueryJSON(e),t);return{count:n,extent:s.fromJSON(r)}}async executeQueryForIds(e,t){return this._dataQueryEngine.executeQueryForIds(this._ensureQueryJSON(e),t)}async executeQuery(e,t){let n=this._ensureQueryJSON(e),r=await this._dataQueryEngine.executeQuery(n,t);if(e?.returnGeometry){let{processQueryGeometries:e}=await import(`./I3SQueryResultGeometry.js`);return e(this.layerView,r)}return d.fromJSON(r)}_ensureQueryJSON(e){return e==null?this.defaultQueryJSON:e.toJSON()}_ensureDataQueryEngine(){if(this._dataQueryEngineInstance)return this._dataQueryEngineInstance;let e=this.layer.objectIdField||c,t=this.layer.fieldsIndex?.toJSON()||new u([]),n=this.layerView.view.resourceController.scheduler,r=this.spatialReference.toJSON(),i=this.priority,a=this.spatialIndex,o=this.layerView.availableFields??[];return this._dataQueryEngineInstance=new p({hasZ:!0,hasM:!1,geometryType:`esriGeometryPolygon`,fieldsIndex:t,timeInfo:this.layer.timeInfo?.toJSON(),spatialReference:r,featureIdInfo:{type:`object-id`,fieldName:e},featureStore:a,scheduler:n,priority:i,availableFields:o}),this._dataQueryEngineInstance}};e([a({constructOnly:!0})],m.prototype,`layerView`,void 0),e([a({constructOnly:!0})],m.prototype,`priority`,void 0),e([a({constructOnly:!0})],m.prototype,`spatialIndex`,void 0),e([a()],m.prototype,`spatialReference`,null),e([a()],m.prototype,`layer`,null),e([a()],m.prototype,`defaultQueryJSON`,null),m=e([o(`esri.views.3d.layers.i3s.I3SQueryEngine`)],m);export{m as I3SQueryEngine};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import e from"../core/Version.js";const t=new e(1,40,`webscene`);export{t as webSceneVersion};
2
+ import e from"../core/Version.js";const t=new e(1,41,`webscene`);export{t as webSceneVersion};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{substitute as t}from"../intl.js";import{deprecateWidget as n}from"../core/deprecate.js";import r from"../core/Logger.js";import{getOrCreateMapValue as i}from"../core/MapUtils.js";import{destroyMaybe as a}from"../core/maybe.js";import o from"../core/ReactiveMap.js";import{watch as s,when as c,on as l,sync as u}from"../core/reactiveUtils.js";import{formatFileSize as d}from"../core/unitFormatUtils.js";import{property as f,subclass as p}from"../core/accessorSupport/decorators.js";import{formatDate as m}from"../intl/date.js";import{isIntegerField as h}from"../layers/support/fieldUtils.js";import{isString as g}from"../support/guards.js";import ee from"./Widget.js";import{getAttachmentTypeCategory as te,getCalciteIconForAttachment as _}from"./Attachments/support/attachmentUtils.js";import{getAttachmentKey as v,isImageAttachment as y,getAttachmentFilenameParts as b}from"./BatchAttributeForm/attachmentUtils.js";import{getHiddenFieldsValidationErrorMessage as ne,getMessageString as x,isElementTemplateWithInputType as S,subtypeChangeShouldPrompt as re,flattenInputs as ie}from"./BatchAttributeForm/batchAttributeFormUtils.js";import C from"./BatchAttributeForm/BatchAttributeFormViewModel.js";import{css as w}from"./BatchAttributeForm/css.js";import{makeViewingEditedAttachmentFooterButtons as ae,makeViewingAttachmentFooterButtons as oe,makeCancelFooterButton as T,makeDefaultFooterButtons as E}from"./BatchAttributeForm/interfaceUtils.js";import D from"./BatchAttributeForm/VisibleElements.js";import{isDynamicChoiceController as O,isMultipleChoiceController as k}from"./BatchAttributeForm/inputs/support/controllerUtils.js";import{isGroupInput as A,isFieldInput as j,isTextElementInput as se,isRelationshipElementInput as ce,isAttachmentElementInput as le,isUtilityNetworkAssociationsElementInput as ue,differentValuesString as M,getNormalizedFieldName as N,isGroupedInput as P}from"./BatchAttributeForm/inputs/support/inputUtils.js";import{clearMultipleChoiceOtherChoiceStateForViewModel as F,otherChoiceCheckedPlaceholderValue as I,canRestoreMultipleChoiceOtherChoiceDraftValue as L}from"./BatchAttributeForm/inputs/support/multipleChoiceInputUtils.js";import{loadRelationshipDetailsComponents as R,RelationshipDetails as z}from"./BatchAttributeForm/rendered-content/RelationshipDetails.js";import{Prompt as B}from"./Editor/components/Prompt.js";import{downloadAttachmentInfo as V}from"./FeatureTable/support/exportUtils.js";import{loadCalciteComponents as H}from"./support/componentsUtils.js";import{getLabelForDateFieldValue as de,getIntlOptionsForField as fe,prepareISOFieldValueForDateComponents as U,prepareUnixFieldValueForDateComponents as W,normalizeTimeOnlyString as G,getISOFieldValueFromDateComponents as pe,getUnixFieldValueFromDateComponents as me}from"./support/dateUtils.js";import{globalCss as K}from"./support/globalCss.js";import{Heading as he}from"./support/Heading.js";import{calciteListFilterProps as ge}from"./support/listUtils.js";import{messageBundle as q,vmEvent as _e,tsx as J}from"./support/widget.js";import{setFocus as ve}from"./support/widgetUtils.js";import{isEmptyValue as Y,ContingentValuesValidationError as X}from"./support/forms/formUtils.js";const Z=`data-element-id`,Q=`data-field-name`;let $=class extends ee{constructor(e,t){super(e,t),this.headingLevel=2,this.messagesCommon=null,this.messages=null,this.featureFormMessages=null,this.featureTableMessages=null,this.messagesUnits=null,this.viewModel=new C,this.visibleElements=new D,this.groupDisplay=`all`,this._associationsList=null,this._associationsWidgetsMap=new o,this._attemptFocusOnNextRender=!1,this._dateComponentMap=new Map,this._touchedInputs=new Set,this._dynamicChoiceItemSelections=new WeakSet,this._focusedFieldInput=null,this._pendingSubtypeChoice=null,this._batchSwitchInputInitialValues=new Map,this._listObserverNode=null,this._listObserver=new IntersectionObserver(e=>{e.length&&e[0].isIntersecting&&this.viewModel.activeRelationshipInput?.incrementPage()},{root:window.document}),this._attachmentDialogInfo=null,this._attachmentListFilterText=``,this._attachmentFileInputMap=new Map,this._prompt=null,this._selectedAttachmentReplaceFileInput=null,this._afterListObserverCreated=e=>{this.viewModel.activeRelationshipInput&&(this._listObserverNode=e)},this._afterListObserverRemoved=()=>{this._listObserverNode=null},this._maximizeSelectedAttachment=()=>{this._attachmentDialogInfo=this.selectedAttachmentDetails},this._enterAttachmentReplaceView=()=>{let e=this.selectedAttachmentDetails;this._canReplaceSelectedAttachment()&&e&&(e.input.clearValidationCriteriaState(),this.viewModel.setShowingSelectedAttachmentReplacePage(!0))},this._setSelectedAttachmentReplaceFileInput=e=>{this._selectedAttachmentReplaceFileInput=e},this._openSelectedAttachmentReplaceFilePicker=()=>{this._canReplaceSelectedAttachment()&&this._selectedAttachmentReplaceFileInput?.click()},this._resetSelectedAttachmentName=()=>{let e=this.selectedAttachmentDetails;if(!e?.attachment)return;let t=e.input.getAttachmentEditState(e.attachment).initialName;if(t==null)return;let n=e.input.template.elementId,r=v(e.attachment);this.viewModel.stageRenameAttachment(n,r,t)},this._closeAttachmentDialog=()=>{this.hideAttachmentDialog()},this._saveInputFromElement=this._saveInputFromElement.bind(this),this._onFormSubmit=this._onFormSubmit.bind(this),this._onComponentFocus=this._onComponentFocus.bind(this),this._onComponentBlur=this._onComponentBlur.bind(this),this._afterComponentCreateOrUpdate=this._afterComponentCreateOrUpdate.bind(this),this._afterDateComponentCreateOrUpdate=this._afterDateComponentCreateOrUpdate.bind(this),this._afterRadioGroupCreateOrUpdate=this._afterRadioGroupCreateOrUpdate.bind(this),e?.suppressDeprecationWarning||(this.announceDeprecation=()=>{n(r.getLogger(this),`Editor`,`arcgis-editor`,{version:`5.0`})})}normalizeCtorArgs(e={}){let{suppressDeprecationWarning:t,...n}=e;return n}initialize(){this.addHandles([s(()=>this.features.toArray(),()=>{this._dateComponentMap.clear(),F(this.viewModel,{includeDraftValues:!0})}),s(()=>this.viewModel.activeForm,()=>{this._batchSwitchInputInitialValues.clear(),this._resetTransientFormState(),F(this.viewModel),this._setFocusableInput()}),s(()=>this.viewModel.selectedAttachmentAddElementId,()=>{this.hideAttachmentDialog()}),c(()=>!this.selectedAttachmentDetails,()=>this.hideAttachmentDialog()),s(()=>this.viewModel.selectedAttachmentListElementId,()=>{this._attachmentListFilterText=``}),s(()=>[this.viewModel.activeRelationshipInput,this._listObserverNode],()=>this._onObserverChange()),l(()=>this.viewModel,`submit`,()=>{this.valid||this.goToFirstError()}),s(()=>[this._associationsEnabled,this.viewModel.activeForm.allUtilityNetworkAssociationsElementInputs],()=>this._setUpAssociationsWidgets(),u),s(()=>this.viewModel.activeAssociationsInput,e=>this._onActiveAssociationsInputChange(e)),s(()=>this.groupDisplay,()=>this._syncGroupInputStates())])}loadDependencies(){return Promise.all([H({action:()=>import(`@esri/calcite-components/dist/components/calcite-action`),autocomplete:()=>import(`@esri/calcite-components/dist/components/calcite-autocomplete`),"autocomplete-item":()=>import(`@esri/calcite-components/dist/components/calcite-autocomplete-item`),block:()=>import(`@esri/calcite-components/dist/components/calcite-block`),button:()=>import(`@esri/calcite-components/dist/components/calcite-button`),checkbox:()=>import(`@esri/calcite-components/dist/components/calcite-checkbox`),chip:()=>import(`@esri/calcite-components/dist/components/calcite-chip`),combobox:()=>import(`@esri/calcite-components/dist/components/calcite-combobox`),"combobox-item":()=>import(`@esri/calcite-components/dist/components/calcite-combobox-item`),"combobox-item-group":()=>import(`@esri/calcite-components/dist/components/calcite-combobox-item-group`),dialog:()=>import(`@esri/calcite-components/dist/components/calcite-dialog`),dropdown:()=>import(`@esri/calcite-components/dist/components/calcite-dropdown`),"dropdown-group":()=>import(`@esri/calcite-components/dist/components/calcite-dropdown-group`),"dropdown-item":()=>import(`@esri/calcite-components/dist/components/calcite-dropdown-item`),icon:()=>import(`@esri/calcite-components/dist/components/calcite-icon`),input:()=>import(`@esri/calcite-components/dist/components/calcite-input`),"input-date-picker":()=>import(`@esri/calcite-components/dist/components/calcite-input-date-picker`),"input-message":()=>import(`@esri/calcite-components/dist/components/calcite-input-message`),"input-number":()=>import(`@esri/calcite-components/dist/components/calcite-input-number`),"input-time-picker":()=>import(`@esri/calcite-components/dist/components/calcite-input-time-picker`),"input-time-zone":()=>import(`@esri/calcite-components/dist/components/calcite-input-time-zone`),label:()=>import(`@esri/calcite-components/dist/components/calcite-label`),list:()=>import(`@esri/calcite-components/dist/components/calcite-list`),"list-item":()=>import(`@esri/calcite-components/dist/components/calcite-list-item`),loader:()=>import(`@esri/calcite-components/dist/components/calcite-loader`),notice:()=>import(`@esri/calcite-components/dist/components/calcite-notice`),switch:()=>import(`@esri/calcite-components/dist/components/calcite-switch`),"text-area":()=>import(`@esri/calcite-components/dist/components/calcite-text-area`),"radio-button":()=>import(`@esri/calcite-components/dist/components/calcite-radio-button`),"radio-button-group":()=>import(`@esri/calcite-components/dist/components/calcite-radio-button-group`)}),R()])}destroy(){this._destroyAssociationsWidgets(),this._associationsList=a(this._associationsList),this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode)}get activeFeatureIndex(){return this.viewModel.activeFeatureIndex}set activeFeatureIndex(e){this.viewModel.activeFeatureIndex=e}get attachmentsEnabled(){return this.viewModel.attachmentsEnabled}set attachmentsEnabled(e){this.viewModel.attachmentsEnabled=e}get callbacks(){return this.viewModel.callbacks}set callbacks(e){this.viewModel.callbacks=e}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get effectiveTitle(){let{features:e,messages:t,page:n}=this;return t?n===`replacing-attachment`?t.titles.replaceAttachment:n===`viewing-attachment-details`?t.titles.editAttachment:n===`adding-attachments`?t.titles.addAttachments:n===`viewing-attachments`?t.titles.attachments:e.length===1||this.activeFeatureIndex>-1?t.titles.editFeature:e.length>1?t.titles.editFeatures:``:``}get effectiveDisabled(){return this.disabledOrReadOnly||this.viewModel.updating}get disabledOrReadOnly(){return this.disabled||this.readOnly}get features(){return this.viewModel.features}set features(e){this.viewModel.features=e}get footerButtonInfos(){if(!this.features.length||!this.messages||!this.messagesCommon)return[];let{messages:e,messagesCommon:t,page:n}=this,r=this.effectiveDisabled;if(n===`adding-attachments`||n===`replacing-attachment`)return[];if(n===`viewing-attachment-details`){let t=this.selectedAttachmentDetails,n=t?.input?.getAttachmentEditState(t.attachment);return!t?.input||!n?[]:n.isRenamed||n.isReplaced?ae({doneOnclick:()=>this._setSelectedAttachment(null),messages:e.footerButtons,resetOnclick:()=>this._resetSelectedAttachmentChanges(),resetDisabled:this._disableAttachmentModification(t.input)}):oe({deleteDisabled:this._disableAttachmentModification(t.input),deleteOnclick:()=>this._deleteSelectedAttachment(),doneOnclick:()=>this._setSelectedAttachment(null),messages:e.footerButtons})}return n===`viewing-associated-features`?T({messages:t,purpose:`cancel-viewing-associated-features`,onclick:()=>this.goBack()}):n===`viewing-associated-layers`?T({messages:t,purpose:`cancel-viewing-associated-layers`,onclick:()=>this.goBack()}):n===`viewing-attachments`||n===`viewing-related-records`?[]:E({disabled:r||!this.valid,formId:this._formId,messages:e,callback:()=>this.submit()})}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get maximumFeatureCount(){return this.viewModel.maximumFeatureCount}set maximumFeatureCount(e){this.viewModel.maximumFeatureCount=e}get maximumFeatureCountWithComplexForms(){return this.viewModel.maximumFeatureCountWithComplexForms}set maximumFeatureCountWithComplexForms(e){this.viewModel.maximumFeatureCountWithComplexForms=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get layerInfos(){return this.viewModel.layerInfos}set layerInfos(e){this.viewModel.layerInfos=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get icon(){return`edit-attributes`}set icon(e){this._overrideIfSome(`icon`,e)}get page(){return this.viewModel.page}get readOnly(){return this.viewModel.readOnly}set readOnly(e){this.viewModel.readOnly=e}get showPrompt(){return e=>{this._prompt?.cancel?.(),this._prompt=e}}set showPrompt(e){this._overrideIfSome(`showPrompt`,e)}get clearPrompt(){return()=>this._prompt=null}set clearPrompt(e){this._overrideIfSome(`clearPrompt`,e)}get selectedAttachment(){return this.viewModel.selectedAttachment}get selectedAttachmentDetails(){return this.viewModel.selectedAttachmentDetails}get valid(){return this.viewModel.valid}get _formHeaderVisible(){return this.viewModel.mode===`batch`||!this.viewModel.activeFeature?!1:!!(this.viewModel.formDescription||this.viewModel.formTitle)}get _associationsEnabled(){let{callbacks:e}=this;return!!(e?.addAssociation||e?.editAssociatedFeature)}get _formId(){return`${this.id}-form`}get _relatedRecordsEnabled(){let{callbacks:e}=this;return!!(e&&(e.addRelatedRecord||e.editRelatedRecord))}async goBack(){return this.viewModel.goBack()}async goHome(){return this.viewModel.goHome()}goToFirstError(){let e=this.viewModel.getFirstVisibleInvalidFieldInput();if(!e)return;let{groupInput:t}=e;t&&(t.open||=!0),this._setFocusableInput(e.input),this.scheduleRender()}render(){return J(`div`,{class:this.classes(w.base,K.widget,K.panel),ondragover:this._handleDragAndDrop,ondrop:this._handleDragAndDrop},this._renderContent(),this._renderAttachmentDialog(),this._prompt?J(B,{...this._prompt,headingLevel:this.headingLevel}):void 0)}setActiveAssociationsInput(e){this.viewModel.setActiveAssociationsInput(e)}setActiveAssociationsLayer(e){this.viewModel.setActiveAssociationsLayer(e)}setActiveAssociationType(e){this.viewModel.setActiveAssociationType(e)}submit(){return this.viewModel.submit()}get test(){return{saveInput:this._saveInput.bind(this),pendingSubtypeChoice:this._pendingSubtypeChoice,touchedInputs:this._touchedInputs}}_setDateTimeTimeZoneMap(e){let{datePart:t,elementId:n}=e.dataset,r=i(this._dateComponentMap,`${n}`,()=>({}));switch(t){case`date`:r.date=e;break;case`time`:r.time=e;break;case`timeZone`:r.timeZone=e}}_renderContent(){let{messages:e,viewModel:n}=this,{status:r}=n;if(r===`failed`)return n.hasTooManyComplexFeatures?this._renderErrorNotice(t(e.formFailedToLoadTooManyComplexFeatures,{num:n.maximumFeatureCountWithComplexForms})):n.hasTooManyFeatures?this._renderErrorNotice(t(e.formFailedToLoadTooManyFeatures,{num:n.maximumFeatureCount})):e.formFailedToLoad;if(n.hasLayersWithContingentValues&&this.viewModel.features.length>1)return this._renderErrorNotice(e.unsupportedContingentValues);if(r===`loading`&&this.visibleElements.loadingIndicator)return J(`calcite-loader`,{key:`loader`,label:this.messagesCommon?.loading});if(this.features.length!==0)return this._renderForm()}_renderErrorNotice(e,t=`warning`){return J(`calcite-notice`,{class:w.noticeError,icon:!0,kind:t,open:!0},J(`div`,{slot:`message`},e))}_renderForm(){return J(`form`,{class:w.form,id:this._formId,inert:!!this._prompt,onsubmit:this._onFormSubmit},this.viewModel.expressionEvaluationFailed&&this.visibleElements.expressionsErrorNotice&&this._renderErrorNotice(this.messages.expressionEvaluationFailed),this._renderInvisibleFieldsError(),this._renderPage())}_renderPage(){switch(this.page){case`adding-attachments`:return this._renderAttachmentAddPage();case`viewing-attachment-details`:case`replacing-attachment`:return this._renderAttachmentDetailPage();case`viewing-attachments`:return this._renderAttachmentListPage();case`viewing-associated-layers`:case`viewing-associated-features`:return this._renderViewingAssociationsPage();case`viewing-related-categories`:case`viewing-related-records`:return this._renderRelationshipListPage();default:return this._renderDefaultPage()}}_renderInvisibleFieldsError(){let{viewModel:e}=this,{hasNonActiveInvalidFeatures:t,activeForm:n}=e,r;if(!e.submitHasBeenAttempted)return null;if(n.invalidHiddenInputs.length>0){if(r=ne(n,e.mode,this.messages),this.viewModel.mode===`batch`){let e=n.invalidHiddenInputs.filter(e=>e.effectiveVisibilityCode===`hidden:group-visibility-expression:all-features`||e.visibilityCode===`hidden:visibility-expression:all-features`);e.length>0?r+=` (${e.map(e=>e.label).join(`, `)})`:r=null}else r=null}else if(t)return null;return r?this._renderErrorNotice(r,`danger`):null}_renderDefaultPage(){return[this._renderReadOnlyNotice(),this._renderFormHeader(),this._renderFormContent()]}_renderReadOnlyNotice(){if((this.disabled||this.readOnly)&&this.visibleElements.readOnlyNotice)return J(`calcite-notice`,{class:w.disabledNotice,"data-testid":`read-only-notice`,icon:`read-only-non-editable`,kind:`brand`,open:!0,scale:`s`,width:`full`},J(`div`,{slot:`message`},this.featureFormMessages.disabledForm))}_renderFormHeader(){let{formTitle:e,formDescription:t}=this.viewModel;if(!this._formHeaderVisible)return;let n=e?J(he,{key:`title`,level:this.headingLevel},e):void 0,r=t?J(`p`,{class:w.description,key:`description`},t):void 0;return J(`div`,{class:w.formHeader},n,r)}_renderFormContent(){return this.viewModel.hasVisibleInputs?this.viewModel.activeForm.inputs.filter(e=>e.visible).map(e=>this._renderInput(e)):this._renderErrorNotice(this.messages.noVisibleFields[this.viewModel.noVisibleElementsReason])}_renderInput(e){if(A(e))return this._renderGroupInput(e);if(j(e))return this._renderLabeledField(e);if(se(e))return this._renderTextComponent(e);if(ce(e))return this._renderRelationshipElementInput(e);if(le(e))return this._renderAttachmentElementInput(e);if(ue(e))return this._renderUtilityNetworkAssociationsElementInput(e)}_renderGroupInput(e){let{inputs:t,template:n,open:r}=e,i=t.filter(e=>e.visible),a=e.label??``,o=this._focusedFieldInput?.group===e,s=this.groupDisplay===`sequential`;return J(`calcite-block`,{class:this.classes(w.group,s?w.groupSequential:null,o?w.groupActive:null,this.disabled?w.inputDisabled:null),description:e.description??void 0,expandable:!0,expanded:r,heading:a,headingLevel:this.headingLevel,key:`{${n.elementId}-key}`,label:a,onCalciteBlockCollapse:({currentTarget:t})=>{e.open=!1,this._onGroupToggle(t,e)},onCalciteBlockExpand:({currentTarget:t})=>{e.open=!0,this._onGroupToggle(t,e)}},i.map(e=>this._renderInput(e)))}_renderLabeledField(e){let{elementId:n}=e.template,{label:r,required:i,dataType:a}=e,o=i?t(this.messages.requiredFieldLabel,{name:r}):r;return J(`calcite-label`,{"aria-label":o,class:w.label,key:`field--${n}`},J(`div`,{class:w.labelTextContent,key:`labelTextContainer`},r,i?J(`span`,{"aria-hidden":`true`,title:this.messagesCommon.required},`*`):void 0),a===`unsupported`?this._renderReadOnlyComponent(e):this._renderFieldInput(e),this._renderAuxiliaryText(e))}_renderFieldInput(e){let t=this.getCommonInputProps(e),{dataType:n}=e;return O(e.inputController)?this._renderDynamicChoiceComponent({input:e,props:t,controller:e.inputController}):e.domain?.type===`coded-value`?this._renderCodedInputs({input:e,props:t}):k(e.inputController)?this._renderMultipleChoiceComponent({input:e,props:t}):n===`date`?this._renderDateComponents(e,t):(t.disabled=this.disabled,t.readOnly=t.readOnly||this.viewModel.updating,n===`number`?this._renderNumberComponent(e,t):this._renderStringComponent(e,t))}_renderAuxiliaryText(e){let{description:t}=e,n=this._getErrorToDisplay(e),r=n?x(e,n,this.messages):null;return r?J(`calcite-input-message`,{icon:!0,status:`invalid`},r):e.valueIsOutOfDomain&&(this._touchedInputs.has(e.template.elementId)||this.viewModel.submitHasBeenAttempted)?J(`calcite-input-message`,{icon:!0,status:`idle`},this.messages.subtypes.fieldOutOfSubtypeDomainWarning):t?J(`calcite-input-message`,{class:w.description,icon:!1,status:`idle`},t):null}_renderCodedInputs({input:e,props:t}){let n=e.input?.type??null,r=e.codedValueOptions;switch(n){case`switch`:return this._renderSwitchField({input:e,props:t});case`radio-buttons`:return this._renderRadioButtonGroupComponent({input:e,options:r,props:t});default:return this._renderComboBoxComponent({options:r,props:t,input:e})}}_renderDynamicChoiceComponent({input:e,props:t,controller:n}){let r=n.filteredChoices,i=t.readOnly||t.disabled,a=e.showNoValueLabel||this.messages.empty,o=n.evaluated&&!n.evaluating&&!n.choices.length&&J(`calcite-notice`,{appearance:`transparent`,kind:`neutral`,open:!0,scale:`s`,slot:`content-bottom`,width:`full`},J(`div`,{slot:`message`},e.showNoValueOptionEnabled?this.messages.noDynamicChoicesWithNoValue:this.messages.noDynamicChoices)),s=t=>{this._saveInput(e,t)},l=(e,t)=>{this._dynamicChoiceItemSelections.delete(n);let r=e.closest(`calcite-autocomplete`);if(r){let e=t==null?``:n.getLabel(t);n.filterValue=``,r.inputValue=e}s(t)},u=({currentTarget:t})=>{let r=t.inputValue??``;n.filterValue=r,!r&&e.value!=null&&s(null)},d=e.showNoValueOptionEnabled?J(`calcite-autocomplete-item`,{disabled:i,heading:a,key:`dynamic-choice-empty`,selected:e.value==null,value:``,onCalciteAutocompleteItemSelect:({currentTarget:e})=>l(e,null),onpointerdown:()=>{this._dynamicChoiceItemSelections.add(n)}}):null,f=t=>{this.addHandles(c(()=>!n.initialEvaluationInProgress,()=>{t.inputValue=e.value===M?this.messages.differentValuesPlaceholder:e.value==null?``:n.inputValue},{once:!0,initial:!0}))};return J(`calcite-autocomplete`,{...t,afterCreate:f,disabled:i&&!n.interactionActive,loading:n.initialEvaluationInProgress,placeholder:e.value==null?a:t.placeholder,value:t.value===M?this.messages.differentValuesPlaceholder:String(t.value),onblur:e=>this._onDynamicChoiceBlur(e,n),onCalciteAutocompleteBeforeOpen:()=>n.beginInteraction(),onCalciteAutocompleteTextInput:u},n.evaluating?J(`calcite-loader`,{key:`dynamic-choice-loader`,label:this.messagesCommon.loading,scale:`s`,slot:`content-top`}):[o,d,...r.map(t=>J(`calcite-autocomplete-item`,{disabled:i,heading:t.name,key:`dynamic-choice-${t.code}`,selected:t.code===e.value,value:String(t.code),onCalciteAutocompleteItemSelect:({currentTarget:e})=>l(e,t.code),onpointerdown:()=>{this._dynamicChoiceItemSelections.add(n)}}))])}_renderMultipleChoiceComponent({input:e,props:t}){let{messages:n}=this,r=this._getMultipleChoiceController(e);if(!r)return null;let{input:i}=r,a=i.includeSelectAllChoices===!0,{checkboxStatesByValue:o,selectAllState:s}=r.selectionState,c=s.checked?n.deselectAllLabel:n.selectAllLabel,l=r.otherChoiceRenderState;return J(`div`,{class:w.multipleChoiceInput,key:`${t.key}-multiple-choice-group`},a?this._renderMultipleChoiceSelectAllCheckbox({props:t,selectAllState:s,selectAllLabel:c,handleSelectAllCheckboxChange:t=>{this._saveValueFromMultipleChoiceCheckbox({input:e,checkbox:t,isSelectAllCheckbox:!0})}}):null,this._renderMultipleChoiceChoiceCheckboxes({input:e,props:t,checkboxStatesByValue:o,handleChoiceCheckboxChange:t=>{this._saveValueFromMultipleChoiceCheckbox({input:e,checkbox:t})}}),l.shouldShow?this._renderMultipleChoiceOtherChoice({props:t,includeSelectAllChoices:a,otherChoiceRenderState:l,handleOtherChoiceCheckboxChange:t=>{let{fieldName:n}=l;n&&this._saveOtherChoiceCheckboxValue({input:e,isChecked:t.checked,otherChoiceFieldName:n})},handleOtherChoiceInputChange:t=>{this._saveValueFromMultipleChoiceTextInput({input:e,textInput:t,otherChoiceFieldName:l.fieldName??void 0})},differentValuesPlaceholder:n.differentValuesPlaceholder}):null)}_renderMultipleChoiceSelectAllCheckbox({props:e,selectAllState:t,selectAllLabel:n,handleSelectAllCheckboxChange:r}){return J(`calcite-checkbox`,{afterCreate:e.afterCreate,afterUpdate:e.afterUpdate,"aria-invalid":e[`aria-invalid`],checked:t.checked,class:w.multipleChoiceSelectAll,"data-element-id":e[Z],disabled:e.readOnly||e.disabled,indeterminate:t.indeterminate,key:`${e.key}-select-all`,label:n,labelText:n,value:`esri_BatchAttributeForm_select_all`,onblur:e.onblur,onCalciteCheckboxChange:({currentTarget:e})=>r(e),onfocus:e.onfocus})}_renderMultipleChoiceChoiceCheckboxes({input:e,props:t,checkboxStatesByValue:n,handleChoiceCheckboxChange:r}){let i=this._getMultipleChoiceController(e);if(!i)return[];let{choices:a}=i;return a.map(e=>{let i=n.get(e.value)??{checked:!1,indeterminate:!1};return J(`calcite-checkbox`,{afterCreate:t.afterCreate,afterUpdate:t.afterUpdate,"aria-invalid":t[`aria-invalid`],checked:i.checked,class:t.class,"data-element-id":t[Z],disabled:t.readOnly||t.disabled,indeterminate:i.indeterminate,key:`${t.key}-${e.value}`,label:e.label,labelText:e.label,value:e.value,onblur:t.onblur,onCalciteCheckboxChange:({currentTarget:e})=>r(e),onfocus:t.onfocus})})}_renderMultipleChoiceOtherChoice({props:e,includeSelectAllChoices:t,otherChoiceRenderState:n,handleOtherChoiceCheckboxChange:r,handleOtherChoiceInputChange:i,differentValuesPlaceholder:a}){let o=n.label??this.messages.otherOptionLabel;return J(`div`,{class:this.classes(w.multipleChoiceOtherChoice,t?w.multipleChoiceOtherChoiceWithSelectAll:null),key:`${e.key}-other-choice`},J(`calcite-checkbox`,{afterCreate:e.afterCreate,afterUpdate:e.afterUpdate,"aria-invalid":e[`aria-invalid`],checked:n.checkboxState.checked,class:e.class,"data-element-id":e[Z],disabled:e.readOnly||e.disabled,indeterminate:n.checkboxState.indeterminate,key:`${e.key}-other-choice-checkbox`,label:o,labelText:o,value:`esri_BatchAttributeForm_other_choice`,onblur:e.onblur,onCalciteCheckboxChange:({currentTarget:e})=>r(e),onfocus:e.onfocus}),n.checkboxState.checked?J(`calcite-input`,{afterCreate:e.afterCreate,afterUpdate:e.afterUpdate,"aria-invalid":e[`aria-invalid`],"aria-label":o,class:w.textElementInput,"data-element-id":e[Z],disabled:e.readOnly||e.disabled,key:`${e.key}-other-choice-input`,maxLength:n.maxLength,placeholder:n.value===M?a:n.hint,status:n.status,type:`text`,value:n.normalizedValue===M?``:n.normalizedValue?String(n.normalizedValue):``,onblur:e.onblur,onCalciteInputInput:({currentTarget:e})=>i(e),onfocus:e.onfocus}):null)}async _saveValueFromMultipleChoiceCheckbox({input:e,checkbox:t,isSelectAllCheckbox:n=!1}){this._markInputTouched(e);let r=this._getMultipleChoiceController(e);if(!r)return;if(r.input&&!n&&this.viewModel.mode===`batch`){await this._saveMultipleChoiceCheckboxValueByFeature({input:e,checkbox:t});return}let i=e.value,a=this._parseValue(t,e,n);a!==i&&await this.viewModel.setValue(e.template.elementId,a)}async _saveValueFromMultipleChoiceTextInput({input:e,textInput:t,otherChoiceFieldName:n}){if(!n)return;let r=t.value,i=r==null||r===``?null:r,a=this._getMultipleChoiceController(e);if(!a)return;a.initializeExplicitOtherChoiceCheckedState(),a.stashOtherChoiceDraftValueForFeatures(e.features,i);let o=N(e,n);o&&await this.viewModel.setValueForFieldName(o,i,Array.from(e.features,e=>e.source))}async _saveOtherChoiceCheckboxValue({input:e,isChecked:t,otherChoiceFieldName:n}){let r=this._getMultipleChoiceController(e);if(!r)return;r.setExplicitOtherChoiceCheckedState(t),this._markInputTouched(e),t||r.setOtherChoiceDraftValuesFromFeatures(e.features.toArray());let i=N(e,n);if(!i)return;let a=new Map;for(let i of e.features){let e=i.getAttribute(n);if(t){if(!Y(e))continue;let t=r.getOtherChoiceDraftValue(i),n=L(t)?t:I;a.set(i,n);continue}e!=null&&a.set(i,null)}a.size!==0&&await this.viewModel.setValuePerFeatureForFieldName(i,new Map(Array.from(a,([e,t])=>[e.source,t])))}async _saveMultipleChoiceCheckboxValueByFeature({input:e,checkbox:t}){let n=this._getMultipleChoiceController(e);if(!n)return;let r=new Map(e.features.map(r=>[r,n.getUpdatedValueForFeature({choiceValue:t.value,currentValue:r.getAttribute(e.fieldName),isChecked:t.checked})]));r.size!==0&&await this.viewModel.setFieldInputValuePerFeature(e,r)}_renderSwitchField({input:e,props:t}){if((this._batchSwitchInputInitialValues.get(e)===M||e.value===M)&&this.viewModel.mode===`batch`){let n={dropdown:{afterCreate:this._afterComponentCreateOrUpdate,afterUpdate:this._afterComponentCreateOrUpdate,disabled:t.readOnly,open:!1,onblur:t.onblur,onfocus:t.onfocus,[Z]:t[Z]},trigger:{appearance:`transparent`,iconEnd:`chevron-down`,kind:`neutral`,slot:`trigger`,label:t.label},group:{mode:`single`}};return this._renderDropdownComponent({buttonValue:e.value,dropdownProps:n,options:[{name:this.messages.differentValuesPlaceholder,value:M,disabled:!0},...e.codedValueDomainOptions]})}return this._renderSwitchComponent({input:e,props:t})}_renderSwitchComponent({input:e,props:t}){return J(`calcite-switch`,{...t,checked:S(e.template,`switch`)?e.value===e.template.input.onValue:!1,class:w.inputSwitch,disabled:t.readOnly||t.disabled,onCalciteSwitchChange:({currentTarget:e})=>this._saveInputFromElement(e)})}_renderDropdownComponent({buttonValue:e,options:t,dropdownProps:n}){let{trigger:r,dropdown:i,group:a}=n;return J(`calcite-dropdown`,{...i,topLayerDisabled:this.topLayerDisabled,onCalciteDropdownSelect:({currentTarget:e})=>this._saveInputFromElement(e)},J(`calcite-button`,{...r},e===M?this.messages.differentValuesPlaceholder:e),J(`calcite-dropdown-group`,{selectionMode:a.mode},t.map(t=>J(`calcite-dropdown-item`,{disabled:t.disabled,label:String(t.name),selected:e===t.value},t.name))))}_renderComboBoxComponent({input:e,options:t,props:n}){let r=this.viewModel.editType===`INSERT`,i=this._touchedInputs.has(e?.template.elementId),a=r&&e.showNoValueOptionEnabled&&!i?()=>{}:n.onblur,o={...n,onblur:a};return J(`calcite-combobox`,{...o,clearDisabled:e.isSubtypeField,selectionMode:`single`,topLayerDisabled:this.topLayerDisabled,value:n.placeholder===this.messages.differentValuesPlaceholder?M:String(n.value),onCalciteComboboxChange:({currentTarget:t})=>{t.value!==M&&(e.isSubtypeField&&t.selectedItems.length===0?t.value=`${e.value}`:this._saveInputFromElement(t))}},this.renderComboboxOptionsList({input:e,options:t,props:n}))}renderComboboxOptionsList({input:e,options:t,props:n}){let r=e=>e.map(e=>{let{value:t}=e,r=Y(e.value)?this.messages.empty:e.name;return J(`calcite-combobox-item`,{heading:r,key:`#${t}`,selected:n.value===t,value:`${t}`})}),i=[],{messages:a}=this;t.other.length>0&&i.push(J(`calcite-combobox-item-group`,{key:`other`,label:a.other},r(t.other))),t.unsupported.length>0&&i.push(J(`calcite-combobox-item-group`,{key:`unsupported`,label:a.unsupported},r(t.unsupported)));let o=r(t.recommended);i.length>0?i.unshift(J(`calcite-combobox-item-group`,{key:`recommended`,label:a.recommended},o)):i=o;let s=n.placeholder===this.messages.differentValuesPlaceholder,c=!s&&Y(n.value);return e.showNoValueOptionEnabled&&!t.containsEmptyOption&&i.unshift(J(`calcite-combobox-item`,{heading:e.showNoValueLabel||this.messages.empty,key:`empty-option`,selected:c,value:``})),s&&i.unshift(J(`calcite-combobox-item`,{heading:this.messages.differentValuesPlaceholder,key:M,selected:!0,value:M})),i}_renderRadioButtonGroupComponent({input:e,options:t,props:n}){let r=[...t.recommended,...t.other,...t.unsupported].map(({name:t,value:r})=>this._renderRadioButtons({label:t,value:r,selected:r===e.value,props:n}));if(e.showNoValueOptionEnabled&&!t.containsEmptyOption){let t=e.showNoValueLabel||this.messages.empty,i=Y(e.value);r.unshift(this._renderRadioButtons({label:t,value:``,selected:i,props:n}))}return J(`calcite-radio-button-group`,{afterCreate:this._afterRadioGroupCreateOrUpdate,afterUpdate:this._afterRadioGroupCreateOrUpdate,class:w.inputRadioGroup,"data-field-name":n[Q],disabled:n.readOnly||n.disabled,key:`${n.key}-radio-group`,layout:`vertical`,name:`${n.name}-${this.id}`,required:n.required},r,n.placeholder===this.messages.differentValuesPlaceholder?J(`calcite-label`,{class:w.placeholderRadio,key:n.label,layout:`inline`},J(`calcite-radio-button`,{checked:!0,class:w.inputRadio,disabled:!0,value:n.placeholder}),n.placeholder):null)}_renderRadioButtons({value:e,selected:t,label:n,props:r}){return J(`calcite-label`,{class:w.inputRadioLabel,key:r.label,layout:`inline`},J(`calcite-radio-button`,{...r,afterCreate:void 0,afterUpdate:void 0,checked:t,class:w.inputRadio,disabled:r.readOnly||r.disabled,name:void 0,value:e,onCalciteRadioButtonChange:({currentTarget:e})=>{e.checked&&this._saveInputFromElement(e)}}),n)}_renderStringComponent(e,t){let{template:n}=e;return!n.field.editable||this.readOnly?this._renderReadOnlyComponent(e):n.input?.type===`text-area`?J(`calcite-text-area`,{...t,class:this.classes(w.individualElement),resize:`vertical`,value:t.value?String(t.value):``,onblur:n=>{t.onblur(n),e.userHasChangedValue&&this._saveInputFromElement(n.currentTarget)},onCalciteTextAreaInput:t=>{e.userHasChangedValue=!0,t.currentTarget.value===``&&this._saveInputFromElement(t.currentTarget)}}):J(`calcite-input`,{...t,class:this.classes(w.individualElement),type:`text`,value:t.value?String(t.value):``,onblur:n=>{t.onblur(n),e.userHasChangedValue&&this._saveInputFromElement(n.currentTarget)},onCalciteInputInput:t=>{e.userHasChangedValue=!0,t.currentTarget.value===``&&this._saveInputFromElement(t.currentTarget)}})}_renderNumberComponent(e,t){let n=h(e.field);return J(`calcite-input-number`,{...t,integer:n,step:n?1:`any`,type:`number`,value:n&&t.value!==``?Math.round(parseFloat(String(t.value))).toString():String(t.value),onblur:n=>{t.onblur(n),e.userHasChangedValue&&this._saveInputFromElement(n.currentTarget)},onCalciteInputNumberInput:t=>{e.userHasChangedValue=!0,t.currentTarget.value===``&&this._saveInputFromElement(t.currentTarget)}})}_renderReadOnlyComponent(e,t){let n=this.getCommonInputProps(e);return J(`calcite-input`,{...n,class:this.classes(w.fieldInput,w.inputDisabled,w.individualElement),readOnly:!0,type:`text`,value:String(t??n.value??``)})}_renderDateComponents(e,t){let{field:n}=e,r;switch(n.type){case`date`:r=this._renderDateFieldComponents(e,t);break;case`date-only`:r=this._renderDateOnlyFieldComponent(e,t);break;case`time-only`:r=this._renderTimeOnlyFieldComponent(e,t);break;case`timestamp-offset`:r=this._renderTimestampOffsetFieldComponents(e,t);break;default:r=this._renderReadOnlyComponent(e,de(n,t.value,{timeZone:e.effectiveTimeZone,...fe(e.template.field)}))}return e.value===M?[r,J(`calcite-input-message`,{icon:`information`,key:`diff-values-message`,status:`idle`},this.messages.differentValues)]:r}_renderDateOnlyFieldComponent(e,t){let{class:n,disabled:r,key:i,readOnly:a}=t,{rawMax:o,rawMin:s}=e.range;return J(`calcite-input-date-picker`,{afterCreate:this._afterDateComponentCreateOrUpdate,afterUpdate:this._afterDateComponentCreateOrUpdate,class:n,"data-date-part":`date`,"data-element-id":t[Z],"data-field-name":t[Q],disabled:r,key:`${i}-date-input`,max:g(o)?o:void 0,min:g(s)?s:void 0,overlayPositioning:`fixed`,readOnly:a,topLayerDisabled:this.topLayerDisabled,value:e.value===M?``:e.value?String(e.value):``,onblur:t.onblur,onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.currentTarget),onfocus:t.onfocus})}_renderTimeOnlyFieldComponent(e,t){let{class:n,disabled:r,key:i,readOnly:a}=t;return J(`calcite-input-time-picker`,{afterCreate:this._afterDateComponentCreateOrUpdate,afterUpdate:this._afterDateComponentCreateOrUpdate,class:n,"data-date-part":`time`,"data-element-id":t[Z],"data-field-name":t[Q],disabled:r,key:`${i}-time-input`,overlayPositioning:`fixed`,readOnly:a,step:e.timeStep,value:e.value===M?``:e.value?String(e.value):``,onblur:t.onblur,onCalciteInputTimePickerChange:t=>this._saveValueFromDateComponent(e,t.currentTarget),onfocus:t.onfocus})}_renderTimestampOffsetFieldComponents(e,t){let{class:n,disabled:r,key:i,readOnly:a,onblur:o,onfocus:s}=t,{rawMax:c,rawMin:l}=e.range,u=e.effectiveTimeZone,d=U(c,u),f=U(l,u),p=U(e.value===M?``:e.value,u),m=e.includeTimeOffset,h={afterCreate:this._afterDateComponentCreateOrUpdate,afterUpdate:this._afterDateComponentCreateOrUpdate,disabled:r,[Z]:t[Z],[Q]:t[Q],onblur:o,onfocus:s,overlayPositioning:`fixed`,readOnly:a};return J(`div`,{class:w.dateInputContainer,key:`${i}-date-time-container`},J(`calcite-input-date-picker`,{...h,class:n,"data-date-part":`date`,key:`${i}-date-input`,max:d?.date??void 0,min:f?.date??void 0,topLayerDisabled:this.topLayerDisabled,value:p.date??``,onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),J(`calcite-input-time-picker`,{...h,class:n,"data-date-part":`time`,key:`${i}-time-input`,step:e.timeStep,value:p.time??``,onCalciteInputTimePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),m?J(`calcite-input-time-zone`,{...h,class:n,clearable:e.value===M||e.value==null,"data-date-part":`timeZone`,key:`${i}-timezone-input`,value:p.timeZoneOffset||``,onCalciteInputTimeZoneChange:t=>this._saveValueFromDateComponent(e,t.target)}):null)}_renderDateFieldComponents(e,t){let{class:n,disabled:r,key:i,readOnly:a,min:o,max:s}=t,c=e.effectiveTimeZone,l=W(e.value===M?``:e.value,c),u=W(s,c),d=W(o,c),f=e.includeTime,p={afterCreate:this._afterDateComponentCreateOrUpdate,afterUpdate:this._afterDateComponentCreateOrUpdate,disabled:r,[Z]:t[Z],[Q]:t[Q],onblur:t.onblur,onfocus:t.onfocus,overlayPositioning:`fixed`,readOnly:a};return J(`div`,{class:w.dateInputContainer,key:`${i}-date-time-container`},J(`calcite-input-date-picker`,{...p,class:n,"data-date-part":`date`,key:`${i}-date-input`,max:u?.date??void 0,min:d?.date??void 0,topLayerDisabled:this.topLayerDisabled,value:l.date??``,onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),f?J(`calcite-input-time-picker`,{...p,"data-date-part":`time`,key:`${i}-time-input`,step:1,value:l.time??``,onCalciteInputTimePickerChange:t=>{this._saveValueFromDateComponent(e,t.target)}}):null)}_renderRelationshipElementInput(e){return this._relatedRecordsEnabled?J(z,{afterObserverCreated:this._afterListObserverCreated,afterObserverRemoved:this._afterListObserverRemoved,input:e,messages:this.messages,messagesCommon:this.messagesCommon,viewModel:this.viewModel}):null}_renderRelationshipListPage(){let{activeRelationshipInput:e}=this.viewModel;if(e)return this._renderRelationshipElementInput(e)}_renderAttachmentElementInput(e){if(!this.attachmentsEnabled)return;let{allAttachmentsVisibleOnDefaultPage:t,attachments:n,defaultPageAttachments:r,template:{description:i,elementId:a,label:o}}=e,s=t?n:r;return J(`div`,{class:w.attachmentElementInput,"data-testid":`attachment-element-${a}`,key:`attachment-element-${a}`},o?J(`div`,{class:w.attachmentElementLabel,key:`attachment-element-label-${a}`},o):null,i?J(`div`,{class:w.description,key:`attachment-element-description-${a}`},i):null,n.length?this._renderAttachmentList(e,s,{label:o||this.messagesCommon.details,viewAllCount:t?null:n.length}):J(`div`,{class:w.attachmentElementEmptyState,key:`attachment-element-empty-state-${a}`},this.messages.attachments.noAttachments),this._renderAttachmentAddAction(e))}_renderAttachmentListPage(){let e=this.viewModel.selectedAttachmentListInput;if(e)return J(`div`,{class:w.attachmentElementAllPanel,key:`attachment-element-all-panel-${e.template.elementId}`},this._renderAttachmentList(e,e.attachments,{filterEnabled:!0,label:this.messages.titles.attachments}))}_renderAttachmentList(e,t,n){let{filterEnabled:r,label:i,viewAllCount:a}=n;return J(`calcite-list`,{class:w.attachmentElementList,filterEnabled:r,filterPlaceholder:r?this.messages.attachments.searchAttachments:void 0,filterProps:r?ge:void 0,filterText:r?this._attachmentListFilterText:void 0,label:i,selectionAppearance:`border`,selectionMode:`none`,onCalciteListFilter:r?e=>{this._attachmentListFilterText=e.currentTarget.filterText??``}:void 0},this._renderAttachmentListItems(e,t),a==null?null:this._renderViewAllAttachmentsItem(e,a))}_renderAttachmentListItems(e,t){let{elementId:n}=e.template;return t.map((t,r)=>{let i=this._formatAttachmentSize(t.size),a=this._getAttachmentLabel(t,r,i,e.displayFilename),o=a===i?void 0:i,s=v(t),c=e.isStagedAttachmentAddition(t),l=e.getAttachmentEditState(t),u=l.isDeleted,d=!u&&(c||l.isRenamed||l.isReplaced);return J(`calcite-list-item`,{class:w.attachmentElementListItem,description:o,key:`attachment-item-${s}`,label:a,onCalciteListItemSelect:c||u?void 0:()=>this._setSelectedAttachment({attachmentKey:s,elementId:n})},J(`div`,{class:w.attachmentElementListItemStart,slot:`content-start`},this._renderAttachmentPreviewThumbnail(t,a,e)),d?J(`span`,{class:w.attachmentElementListItemStagedIndicator,slot:`content-end`}):null,c?[J(`calcite-action`,{disabled:this._disableAttachmentModification(e),icon:`x`,scale:`s`,slot:`actions-end`,text:this.messagesCommon.delete,title:this.messagesCommon.delete,onclick:()=>this.viewModel.stageDeleteAttachment(n,v(t))})]:u?J(`calcite-chip`,{label:this.messages.attachments.deleted,scale:`s`,slot:`content-end`},this.messages.attachments.deleted):J(`calcite-icon`,{flipRtl:!0,icon:`chevron-right`,scale:`s`,slot:`content-end`}))})}_renderViewAllAttachmentsItem(e,n){let{elementId:r}=e.template,{viewAll:i}=this.messages.attachments;return J(`calcite-list-item`,{class:w.attachmentElementListItem,description:t(this.messages.attachments.count,{count:n}),key:`attachment-item-view-all-${r}`,label:i,onCalciteListItemSelect:()=>this._setAttachmentListElementId(r)},J(`calcite-icon`,{flipRtl:!0,icon:`chevron-right`,scale:`s`,slot:`content-end`}))}_renderAttachmentAddAction(e){let{elementId:t}=e.template,n=this.effectiveDisabled||e.addDisabled,r=this._renderAttachmentCountLimitsLabel(e),i=this._getAttachmentNoticeMessage(e),a=e.hasMinimumAttachmentCountNotMet||e.hasExceededAttachmentLimit?`danger`:`info`,o=e.canUploadFiles,s=e.isCaptureOnly&&!this.effectiveDisabled&&!i;return J(`div`,{class:w.attachmentElementAddActions,key:`attachment-element-add-actions-${t}`},o?J(`calcite-button`,{appearance:`outline`,disabled:n,iconStart:`attachment`,kind:`neutral`,round:!0,scale:`s`,onclick:()=>this._setAttachmentAddElementId(t)},this.messages.attachments.attach):null,this._renderAttachmentCaptureButton(e),s?this._renderAttachmentCaptureDisabledNotice(t):null,r?J(`div`,{class:w.attachmentElementEmptyActionHint},r):null,!this.effectiveDisabled&&i?J(`calcite-notice`,{closable:!1,icon:a===`danger`?`exclamation-mark-circle`:`lightbulb`,kind:a,open:!0,scale:`s`,width:`full`},J(`div`,{slot:`message`},i)):null)}_renderAttachmentCaptureButton(e){if(!e.hasCaptureInputs)return null;let t=e.captureMediaType;return J(`calcite-button`,{appearance:`outline`,disabled:!0,iconStart:ye(t),kind:`neutral`,round:!0,scale:`s`},this._getCaptureButtonLabel(t))}_getAttachmentNoticeMessage(e){let t=this.messages.attachments;return e.hasUnsupportedFileTypeValidationError?this._getUnsupportedFileTypeMessage():e.hasMinimumAttachmentCountNotMet&&this._shouldShowMinimumAttachmentNotice(e)?t.minimumNotMet:e.hasExceededAttachmentLimit?t.attachmentLimitExceeded:e.hasReachedAttachmentLimit?t.attachmentLimitReached:null}_shouldShowMinimumAttachmentNotice(e){return e.hasAttachmentChanges||this.viewModel.submitHasBeenAttempted||this._touchedInputs.has(e.template.elementId)}_getCaptureButtonLabel(e){let{capture:t,recordAudio:n,takePhoto:r,takeVideo:i}=this.messages.attachments;switch(e){case`image`:return r||t;case`video`:return i||t;case`audio`:return n||t;default:return t}}_renderAttachmentAddPage(){let e=this.viewModel.selectedAttachmentAddInput;return e?this._renderAttachmentAddPanel(e):null}_renderAttachmentAddPanel(e){let{maxAttachmentCount:t}=e,{elementId:n}=e.template;if(e.isCaptureOnly)return this._renderAttachmentCaptureDisabledNotice(n);let r=t==null||t-e.attachments.length>1,i=this.effectiveDisabled||e.addDisabled,a=this.messages.attachments,o=a.dragAndDropFile,s=e=>{this._attachmentFileInputMap.set(n,e)};return J(`div`,{class:w.attachmentElementAddPanel,key:`attachment-element-add-panel-${n}`},J(`input`,{accept:e.accept,afterCreate:s,afterRemoved:()=>{this._attachmentFileInputMap.delete(n)},afterUpdate:s,class:w.attachmentElementFileInput,"data-element-id":n,disabled:i,multiple:r,type:`file`,onchange:e=>{let t=e.currentTarget,r=t.files?Array.from(t.files):[];this._stageAttachmentFiles(n,r),t.value=``}}),J(`div`,{class:w.attachmentElementAddDropzone,"data-disabled":i?`true`:`false`,ondragover:e=>{e.stopPropagation(),e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`copy`)},ondrop:e=>{if(e.preventDefault(),e.stopPropagation(),i)return;let t=e.dataTransfer?.files?Array.from(e.dataTransfer.files):[];this._stageAttachmentFiles(n,t)}},J(`calcite-icon`,{class:w.attachmentElementAddDropzoneIcon,icon:`upload`,scale:`l`}),J(`div`,{class:w.attachmentElementAddDropzoneHeading},a.addFile),J(`div`,{class:w.attachmentElementAddDropzoneDetail,title:o},o),J(`calcite-button`,{appearance:`transparent`,disabled:i,iconStart:`folder-open`,kind:`brand`,scale:`s`,type:`button`,onclick:e=>{e.stopPropagation(),this._openAttachmentFilePicker(n,i)}},a.selectFile)),this._renderAttachmentValidationCriteria(e,{includeCountCriteria:!0}))}_renderAttachmentCaptureDisabledNotice(e){return J(`calcite-notice`,{class:w.attachmentElementCaptureNotice,icon:!0,key:`attachment-element-capture-disabled-notice-${e}`,kind:`warning`,open:!0,scale:`s`},J(`div`,{slot:`message`},this.messages.attachments.captureMethodNotSupported))}async _stageAttachmentFiles(e,t){if(t.length===0)return;let n=this.viewModel.selectedAttachmentAddInput,r=!0;try{r=(await this.viewModel.stageAddAttachments(e,t)).length>0&&!n?.hasInvalidValidationCriteria&&!n?.hasUnsupportedFileTypeValidationError}finally{r&&this.viewModel.setSelectedAttachmentAddElementId(null)}}_openAttachmentFilePicker(e,t){t||this._attachmentFileInputMap.get(e)?.click()}_renderAttachmentDetailPage(){let e=this.selectedAttachmentDetails;if(!e)return;if(this.page===`replacing-attachment`)return this._renderAttachmentReplacePanel(e);let{attachment:t,input:n}=e,r=v(t),i=!!n.getAttachmentPreviewUrl(t),a=!this._disableAttachmentModification(n)&&n.canUploadFiles,o=n.getAttachmentEditState(t);return J(`div`,{class:w.attachmentElementDetail,key:`attachment-detail-panel-${n.template.elementId}-${r}`},J(`div`,{class:w.attachmentElementDetailPreview},this._renderAttachmentPreviewImageForInput(t,n)),J(`div`,{class:w.attachmentElementDetailActions},y(t)?J(`calcite-button`,{appearance:`outline`,disabled:!i,iconStart:`expand`,kind:`neutral`,label:this.messages.attachments.maximize,scale:`m`,title:this.messages.attachments.maximize,onclick:this._maximizeSelectedAttachment}):null,J(`calcite-button`,{appearance:`outline`,disabled:!i||o.isReplaced,iconStart:`download`,kind:`neutral`,label:this.messages.attachments.download,scale:`m`,title:this.messages.attachments.download,onclick:()=>{this._downloadAttachment(t)}}),J(`calcite-button`,{appearance:`outline`,disabled:!a,iconStart:`upload-to`,kind:`neutral`,label:this.messages.attachments.replace,scale:`m`,title:this.messages.attachments.replace,onclick:this._enterAttachmentReplaceView})),J(`div`,{class:w.attachmentElementDetailMetadata},J(`div`,{class:w.attachmentElementDetailMetadataGroup},J(`span`,{class:w.attachmentElementDetailMetadataLabel},this.messages.attachments.fileName),this._renderFileNameContent(t,n)),J(`div`,{class:w.attachmentElementDetailMetadataGroup},J(`span`,{class:w.attachmentElementDetailMetadataLabel},this.messages.attachments.size),J(`span`,{class:w.attachmentElementDetailMetadataValue},this._formatAttachmentSize(t.size))),J(`div`,{class:w.attachmentElementDetailMetadataGroup},J(`span`,{class:w.attachmentElementDetailMetadataLabel},this.messages.attachments.type),J(`span`,{class:w.attachmentElementDetailMetadataValue},this._getLabelForAttachmentType(t)))))}_renderFileNameContent(e,t){if(!t.allowUserRename)return J(`span`,{class:w.attachmentElementDetailMetadataValue},e.name);let n=t.getAttachmentEditState(e),{baseName:r,extension:i}=b(e.name),a=this._disableAttachmentModification(t),o=!a&&e.name.trim().length===0;return[J(`div`,{class:w.attachmentElementDetailFileNameRow,key:`file-name-row`},J(`calcite-input`,{class:w.attachmentElementDetailFileNameInput,disabled:a,scale:`m`,status:o?`invalid`:`idle`,suffixText:i,value:r,onCalciteInputInput:({currentTarget:e})=>this._renameSelectedAttachment(e.value)}),J(`calcite-button`,{appearance:`transparent`,disabled:a||n.initialName==null||!n.isRenamed,iconStart:`reset`,kind:`neutral`,label:this.messages.footerButtons.reset,scale:`m`,title:this.messages.footerButtons.reset,onclick:this._resetSelectedAttachmentName})),o?J(`calcite-input-message`,{icon:!0,key:`file-name-message`,status:`invalid`},this.messages.validationErrors.cannotBeNull):null]}_renderAttachmentReplacePanel(e){let{attachment:t,input:n}=e,r=this._disableAttachmentModification(n)||!n.canUploadFiles,i=n.template.elementId;return J(`div`,{class:w.attachmentElementAddPanel,key:`attachment-replace-panel-${i}-${v(t)}`},J(`input`,{accept:n.accept,afterCreate:this._setSelectedAttachmentReplaceFileInput,afterRemoved:()=>{this._selectedAttachmentReplaceFileInput=null},afterUpdate:this._setSelectedAttachmentReplaceFileInput,class:w.attachmentElementFileInput,disabled:r,type:`file`,onchange:e=>{let t=e.currentTarget,n=t.files?.[0];n&&this._stageSelectedAttachmentReplacement(n),t.value=``}}),J(`div`,{class:w.attachmentElementAddDropzone,"data-disabled":r?`true`:`false`,ondragover:e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer&&(e.dataTransfer.dropEffect=`copy`)},ondrop:e=>{if(e.preventDefault(),e.stopPropagation(),r)return;let t=e.dataTransfer?.files?.[0];t&&this._stageSelectedAttachmentReplacement(t)}},J(`calcite-icon`,{class:w.attachmentElementAddDropzoneIcon,icon:`refresh`,scale:`l`}),J(`div`,{class:w.attachmentElementAddDropzoneHeading},this.messages.attachments.replace),J(`div`,{class:w.attachmentElementAddDropzoneDetail,title:this.messages.attachments.dragAndDropFile},this.messages.attachments.dragAndDropFile),J(`calcite-button`,{appearance:`transparent`,disabled:r,iconStart:`folder-open`,kind:`brand`,scale:`s`,onclick:e=>{e.stopPropagation(),this._openSelectedAttachmentReplaceFilePicker()}},this.messages.attachments.selectFile)),this._renderAttachmentValidationCriteria(n,{includeCountCriteria:!1}),J(`div`,{class:w.attachmentElementDetailMetadata},J(`div`,{class:w.attachmentElementDetailMetadataGroup},J(`span`,{class:w.attachmentElementDetailMetadataLabel},this.messages.attachments.fileToBeReplaced),J(`span`,{class:w.attachmentElementDetailMetadataValue},t.name))))}_renderAttachmentDialog(){let e=this._attachmentDialogInfo;if(!e)return null;let{attachment:t,input:n}=e;return J(`calcite-dialog`,{heading:t.name||this.messagesCommon.details,key:`attachment-preview-dialog`,modal:!0,open:!0,placement:`cover`,width:`l`,onCalciteDialogClose:this._closeAttachmentDialog},J(`div`,{class:w.attachmentElementDialogPreview},this._renderAttachmentPreviewImageForInput(t,n)))}_setSelectedAttachment(e,t){this._markInputTouched(t),this.viewModel.setSelectedAttachment(e),e||this.hideAttachmentDialog()}_setAttachmentAddElementId(e){let{viewModel:t}=this;t.setSelectedAttachmentAddElementId(e),this._markInputTouched(t.selectedAttachmentAddInput),t.selectedAttachmentAddInput?.clearValidationCriteriaState(),this.hideAttachmentDialog()}_setAttachmentListElementId(e){let{viewModel:t}=this;t.setSelectedAttachmentListElementId(e),this._markInputTouched(t.selectedAttachmentListInput),this.hideAttachmentDialog()}_getAttachmentLabel(e,n,r,i){return i!==!1&&g(e.name)&&e.name.length>0?e.name:r===this.messagesCommon.notApplicable?t(this.messages.attachments.attachmentNumberedLabel,{index:n+1}):r}_renderAttachmentCountLimitsLabel(e){let t=this.messages.attachments,n=e.minAttachmentCount!=null&&e.minAttachmentCount>0?this._renderAttachmentCountLimitLabel(t.minAttachmentsShort,e.minAttachmentCount,`min`):null,r=e.maxAttachmentCount==null?null:this._renderAttachmentCountLimitLabel(t.maxAttachmentsShort,e.maxAttachmentCount,`max`);return!n&&!r?null:[n,n&&r?J(`span`,{key:`attachment-count-limits-separator`},`, `):null,r]}_renderAttachmentCountLimitLabel(e,n,r){let i=`__count__`,[a,o]=t(e,{count:i}).split(i);return J(`span`,{key:r},a,J(`span`,{class:w.attachmentElementEmptyActionHintValue},n),o)}_renderAttachmentValidationCriteria(e,{includeCountCriteria:t}){let n=this._getAttachmentValidationCriteria(e,{includeCountCriteria:t}),r=`attachment-validation-criteria-${e.template.elementId}`;return n.length===0?null:J(`div`,{class:w.attachmentElementValidationCriteria,key:r},n.map(({key:e,message:t,state:n})=>J(`calcite-notice`,{appearance:n===`danger`?`outline-fill`:`transparent`,closable:!1,icon:!0,key:e,kind:n,open:!0,scale:`s`,width:`full`},J(`div`,{slot:`message`},t))))}_getAttachmentValidationCriteria(e,{includeCountCriteria:n}){let r=[],i=e.validationCriterionStates,a=this.messages.attachments,o=this._getNestableAttachmentInputs(e.input);e.hasUnsupportedFileTypeValidationError&&r.push({key:`unsupported-file-type`,message:this._getUnsupportedFileTypeMessage(),state:`danger`});for(let e of o)e.type===`document`&&e.maxFileSize!=null&&r.push({key:`maximum-file-size`,message:t(a.maximumFileSize,{maxSize:this._formatAttachmentSizeLimitInMegabytes(e.maxFileSize)}),state:i.get(`maximum-file-size`)??`info`}),e.type===`audio`&&e.maxDuration!=null&&r.push({key:`maximum-audio-length`,message:t(a.maximumAudioLength,{maxDuration:this._formatAttachmentDurationLimit(e.maxDuration)}),state:i.get(`maximum-audio-length`)??`info`}),e.type===`video`&&e.maxDuration!=null&&r.push({key:`maximum-video-length`,message:t(a.maximumVideoLength,{maxDuration:this._formatAttachmentDurationLimit(e.maxDuration)}),state:i.get(`maximum-video-length`)??`info`}),e.type===`image`&&e.maxImageSize!=null&&r.push({key:`maximum-image-size`,message:t(a.attachmentMustBeSmallerThan,{maxSize:`${e.maxImageSize}px`}),state:i.get(`maximum-image-size`)??`info`});return n&&e.minAttachmentCount!=null&&e.minAttachmentCount>0&&r.push({key:`minimum-number-of-files`,message:t(a.minimumNumberOfFiles,{count:e.minAttachmentCount}),state:i.get(`minimum-number-of-files`)??`info`}),n&&e.maxAttachmentCount!=null&&r.push({key:`maximum-number-of-files`,message:t(a.maximumNumberOfFiles,{count:e.maxAttachmentCount}),state:i.get(`maximum-number-of-files`)??`info`}),r}_getNestableAttachmentInputs(e){return e==null?[]:e.type===`attachment`?e.inputTypes?.slice()??[]:[e]}_getUnsupportedFileTypeMessage(){return this.featureTableMessages.errorFileUnsupported}_formatAttachmentSize(e){return e==null||Number.isNaN(e)?this.messagesCommon.notApplicable:d(this.messagesUnits,e)}_formatAttachmentSizeLimitInMegabytes(e){return d(this.messagesUnits,e*1048576)}_formatAttachmentDurationLimit(e){return m(Math.round(e)*1e3,{...e>=3600?{hour:`2-digit`,hourCycle:`h23`}:{},minute:`2-digit`,second:`2-digit`,timeZone:`UTC`})}_getLabelForAttachmentType({contentType:e}){if(!e)return this.messagesCommon.notApplicable;let t=this.messages.attachments.attachmentTypes,n=te(e);return t?.[n]||e}_renderAttachmentPreviewThumbnail(e,t,n){let r=n.getAttachmentPreviewUrl(e,64);return r&&y(e)?J(`img`,{alt:t,class:w.attachmentElementListItemThumb,src:r}):J(`calcite-icon`,{class:w.attachmentElementListItemIcon,icon:_(e.contentType),scale:`s`})}_renderAttachmentPreviewImageForInput(e,t){let n=t.getAttachmentPreviewUrl(e),r=e.name||this.messagesCommon.details;return n&&y(e)?J(`img`,{alt:r,class:w.attachmentElementDetailPreviewImage,src:n,title:r}):[J(`calcite-icon`,{class:w.attachmentElementDetailPreviewIcon,icon:_(e.contentType),scale:`l`,textLabel:r,title:r}),this.messages.attachments.noPreviewAvailable]}async _downloadAttachment(e){await V(e)}_canReplaceSelectedAttachment(){return!this.effectiveDisabled&&!!this.selectedAttachmentDetails?.input.canUploadFiles}_exitAttachmentReplaceView(){this.viewModel.setShowingSelectedAttachmentReplacePage(!1),this._selectedAttachmentReplaceFileInput=null}async _stageSelectedAttachmentReplacement(e){let t=this.selectedAttachmentDetails;if(!t?.attachment)return;let n=t.input.template.elementId,r=v(t.attachment),i=!1;try{i=await this.viewModel.stageReplaceAttachment(n,r,e)}finally{i&&this._exitAttachmentReplaceView()}}_renameSelectedAttachment(e){let t=this.selectedAttachmentDetails;if(!t?.attachment)return;let n=t.input.template.elementId,r=v(t.attachment);this.viewModel.stageRenameAttachment(n,r,e)}_resetSelectedAttachmentChanges(){let e=this.selectedAttachmentDetails;e?.attachment&&this.viewModel.resetAttachmentChanges(e.input.template.elementId,v(e.attachment))}_deleteSelectedAttachment(){let e=this.selectedAttachmentDetails;if(!e?.attachment||this._disableAttachmentModification(e.input))return;let t=e.input.template.elementId,n=v(e.attachment);this.viewModel.stageDeleteAttachment(t,n),this._setSelectedAttachment(null)}_disableAttachmentModification(e){return this.disabledOrReadOnly||!e.editable}hideAttachmentDialog(){this._attachmentDialogInfo=null}_renderTextComponent(e){let{elementId:t}=e.template;return J(`div`,{class:w.textElementInput,"data-testid":`text-element-${t}`,innerHTML:e.text,key:`text-element-${t}`})}_renderUtilityNetworkAssociationsElementInput(e){if(!this._associationsEnabled)return;let{elementId:t}=e.template;return J(`div`,{class:w.utilityNetworkAssociationsElementInput,"data-testid":t,key:t},this._associationsWidgetsMap.get(e)?.render())}getCommonInputProps(e){let{template:t,valid:n,value:r,minLength:i,maxLength:a,required:o,fieldName:s,editable:c,range:{max:l,min:u}}=e,d=!c||this.readOnly,f=this.disabled||this.viewModel.updating,p=this._getErrorToDisplay(e)?`invalid`:`idle`,m=t.hint??void 0,h=!1;return r===M&&(m=this.messages.differentValuesPlaceholder,h=!0),{afterCreate:this._afterComponentCreateOrUpdate,afterUpdate:this._afterComponentCreateOrUpdate,"aria-invalid":n?`false`:`true`,class:this.classes(w.fieldInput,d?w.inputDisabled:null),status:p,maxLength:a&&a>-1?a:void 0,minLength:i&&i>-1?i:void 0,key:t.elementId,label:s,name:s,max:l??void 0,min:u??void 0,disabled:f,readOnly:d,onblur:this._onComponentBlur,required:o,placeholder:m,value:h?``:r??``,[Z]:t.elementId,[Q]:s,onfocus:this._onComponentFocus}}_onObserverChange(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode);let e=this.viewModel.activeRelationshipInput;e&&this._listObserverNode&&e.showAllEnabled&&this._listObserver.observe(this._listObserverNode)}_onFormSubmit(e){e.preventDefault()}_handleDragAndDrop(e){e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`none`)}_getFieldInputFromHTMLElement(e){return this.viewModel.findFieldInput(e.getAttribute(Z))}_afterRadioGroupCreateOrUpdate(e){let t=e.selectedItem,n=e.querySelector(`calcite-radio-button`),r=t||n;r&&this._afterComponentCreateOrUpdate(r)}_onComponentFocus(e){let t=e.target,n=this._getFieldInputFromHTMLElement(t);this._focusedFieldInput=n}_markInputTouched(e){e&&this._touchedInputs.add(e.template.elementId)}_isMultipleChoiceCheckbox(e,t){let n=this._getMultipleChoiceController(t);return e.tagName===`CALCITE-CHECKBOX`&&n?.input!=null}_afterComponentCreateOrUpdate(e){let t=this._getFieldInputFromHTMLElement(e),n=this._focusedFieldInput;this._attemptFocusOnNextRender&&n===t&&(this._attemptFocusOnNextRender=!1,ve(e))}_onComponentBlur(e){let t=e.target,n=this._getFieldInputFromHTMLElement(t);this._isMultipleChoiceCheckbox(t,n)||this._markInputTouched(n),this._focusedFieldInput=null}_onDynamicChoiceBlur(e,t){let n=e.currentTarget;if(this._dynamicChoiceItemSelections.delete(t))return;let r=e.relatedTarget;r instanceof Node&&n.contains(r)||(t.endInteraction(),n.inputValue=t.fieldInput.value===M?this.messages.differentValuesPlaceholder:t.inputValue,this._onComponentBlur(e))}_resetTransientFormState(){this._attemptFocusOnNextRender=!1,this._focusedFieldInput=null,this._attachmentDialogInfo=null,this._selectedAttachmentReplaceFileInput=null,this._attachmentListFilterText=``,this._attachmentFileInputMap.clear()}_parseValue(e,t,n=!1){let r=this._getMultipleChoiceController(t);if(r){let{input:t,values:i}=r;if(t&&i){let t=e;return r.getValueFromCheckboxChange({choiceValue:t.value,isChecked:t.checked,isSelectAllCheckbox:n})}}if(S(t.template,`switch`)){if(e.localName===`calcite-dropdown`&&t.domain){for(let n of t.domain.codedValues)if(n.name===e.selectedItems[0].textContent)return n.code}return e.checked?t.template.input.onValue:t.template.input.offValue}let i=e.value;return i==null||i===``?null:t.dataType===`number`?i===`-0`||i===`-0.`||i===`-0,`?i:parseFloat(i):t.field.type===`date`?parseFloat(i):i}_getMultipleChoiceController(e){return k(e.inputController)?e.inputController:null}_saveInputFromElement(e){let t=this._getFieldInputFromHTMLElement(e);if(!t)return;let n=this._parseValue(e,t);this._saveInput(t,n)}_saveInput(e,t){let{elementId:n}=e.template,r=e?.value,{viewModel:a}=this;if(S(e.template,`switch`)&&a.mode!==`single`){let t=i(this._batchSwitchInputInitialValues,e,()=>e.value);this._batchSwitchInputInitialValues.set(e,t===null?r:t)}t!==r&&(this._markInputTouched(e),!e.isSubtypeField||a.mode===`batch`||!re(a.activeLayer,r,t)?a.setValue(n,t):this._pendingSubtypeChoice||=this._handleSubtypeChoice(e,t))}async _handleSubtypeChoice(e,n){let{value:r,template:i}=e,{elementId:a}=i,{messages:o,viewModel:s,messagesCommon:c}=this,{subtypes:l,activeFeatureIndex:u}=s;if(await s.setValue(a,n),!l?.length)return;let d=l.find(e=>e.code===n),f=l.find(e=>e.code===r)?.name??`${r}`;if(!d)return;let p=Promise.withResolvers();s.pendingSubtypeChoice=p;let m=`update-fields`,h=[{label:o.subtypes.useDefaultValuesOption,value:`update-fields`},{label:o.subtypes.keepCurrentValuesOption,value:`keep-existing`}],g={context:`info`,title:o.subtypes.changeWarningTitle,message:t(o.subtypes.changeWarning,{originalType:f,newType:d.name}),radios:h,defaultRadioSelection:`update-fields`,onRadioSelection:e=>{m=e},actions:{primary:{label:c.apply,action:()=>p.resolve(m),type:`positive`},secondary:{label:c.cancel,type:`neutral`,action:()=>p.resolve(`undo`)}},cancel:()=>p.reject()};try{switch(this.showPrompt(g),await p.promise){case`update-fields`:await s.applySubtypeDefaults(d),await s.handleSubtypeChanged(u);break;case`keep-existing`:await s.handleSubtypeChanged(u);break;case`undo`:await this.viewModel.setValue(a,r)}}finally{s.pendingSubtypeChoice=null,this.clearPrompt(),this._pendingSubtypeChoice=null}}_afterDateComponentCreateOrUpdate(e){this._setDateTimeTimeZoneMap(e),this._afterComponentCreateOrUpdate(e)}_saveValueFromDateComponent(e,t){let{elementId:n}=e.template,r=e.field.type,i=this._dateComponentMap.get(`${n}`);if(!i)return;let a=e.effectiveTimeZone,o=e.value===M?void 0:e.value,s=null;r===`date-only`?s=Array.isArray(t.value)?t.value[0]:t.value:r===`time-only`?(o=G(o),s=G(t.value)):s=r===`timestamp-offset`?t.value==null?null:pe({dateComponent:i.date,timeComponent:i.time,oldValue:o,timeZoneComponent:i.timeZone,defaultTimeZone:a}):t.value==null?null:me({oldValue:o,dateComponent:i.date,timeZone:a,timeComponent:i.time?.value===M?void 0:i.time}),o!==s&&(this._markInputTouched(e),s===null||!t.value?this.viewModel.setValue(n,null):this.viewModel.setValue(n,s))}_getErrorToDisplay(e){let t=e.compositeError;return e.valid||!t?null:t===X.CONTINGENCY_VIOLATION_ERROR||t===X.CONTINGENCY_VIOLATION_WARNING?t:!this._touchedInputs.has(e.template.elementId)&&!this.viewModel.submitHasBeenAttempted?null:t}_renderViewingAssociationsPage(){return this._associationsList?.render()}_onActiveAssociationsInputChange(e){let t=this._associationsList;t&&(e?(t.associationInput=e,t.viewModel=e.viewModel):t.associationInput=null)}async _setUpAssociationsWidgets(){let e=this.viewModel.activeForm.allUtilityNetworkAssociationsElementInputs;if(this._associationsEnabled&&e.length!==0){await this._setUpUtilityNetworkAssociationList();for(let t of e)this._associationsWidgetsMap.set(t,await this._createAssociationsWidget(t))}}async _setUpUtilityNetworkAssociationList(){if(this._associationsList)return;let e=(await import(`./FeatureForm/FeatureFormUtilityNetworkAssociations/FeatureFormUtilityNetworkAssociationList.js`)).default;this._associationsList=new e({onSelectLayer:this._onSelectAssociatedLayer.bind(this),onSelectFeature:this._onEditAssociatedFeature.bind(this),onAddAssociation:this._onAddAssociation.bind(this)});let t=this.viewModel.activeAssociationsInput;t&&(this._associationsList.associationInput=t,this._associationsList.viewModel=t.viewModel)}async _createAssociationsWidget(e){let t=(await import(`./Feature/FeatureUtilityNetworkAssociations.js`)).default;return new t({viewModel:e.viewModel,onSelectAssociationType:t=>this._onSelectAssociationType(e,t)})}_destroyAssociationsWidgets(){this._associationsWidgetsMap.forEach(e=>a(e)),this._associationsWidgetsMap.clear()}_onSelectAssociationType(e,{listType:t}){this.setActiveAssociationsInput(e),this.setActiveAssociationType(t)}_onSelectAssociatedLayer({layer:e}){this.setActiveAssociationsLayer(e)}async _onEditAssociatedFeature(e){let t=this.callbacks?.editAssociatedFeature,n=this.viewModel.activeAssociationsInput;if(!t||!n?.feature)return;let{association:r,feature:i}=e;await t({parentFeature:n.feature.plainGraphic,association:r,feature:i})}_onAddAssociation(e){let t=this.callbacks?.addAssociation,n=this.viewModel.activeAssociationsInput;if(!t||!n?.feature)return;let{associationType:r,utilityNetwork:i}=e;t({feature:n.feature.plainGraphic,associationType:r,utilityNetwork:i})}_setFocusableInput(e){let t=e&&j(e)?e:this._findFocusableInput(e);this._syncGroupInputStates(),this._focusedFieldInput=t,this._attemptFocusOnNextRender=!0}_findFocusableInput(e){let t=this.viewModel.activeForm.inputs;if(!t.length)return;let n=ie(t),r;if(!e)r=0;else if(A(e)){let t=e.inputs.find(e=>e.visible);r=t?n.indexOf(t):0}else{let i;i=P(e)&&!e.group.open?e.group.inputs.filter(j)[t.length-1]:e,r=n.indexOf(i)+1}for(let e=r;e<n.length;e++){let t=n[e];if(t.visible&&j(t)){if(this.disabledOrReadOnly&&(t?.inputType===`switch`||t?.inputType===`radio-buttons`))continue;return t}}return null}_onGroupToggle(e,t){e.expanded?(t.open=!0,this._setFocusableInput(t),this.groupDisplay===`sequential`&&this.viewModel.activeForm.allGroupInputs.forEach(e=>{e!==t&&(e.open=!1)})):t.open=!1,this.scheduleRender()}_syncGroupInputStates(){if(this.groupDisplay!==`sequential`)return;let e=this.viewModel.activeForm?.allGroupInputs;if(!e.length)return;let t=e.filter(e=>e.open);t.length===0?e[0].open=!0:t.length>1&&t.slice(1).forEach(e=>e.open=!1)}};e([f()],$.prototype,`activeFeatureIndex`,null),e([f()],$.prototype,`attachmentsEnabled`,null),e([f()],$.prototype,`callbacks`,null),e([f()],$.prototype,`disabled`,null),e([f()],$.prototype,`effectiveTitle`,null),e([f()],$.prototype,`effectiveDisabled`,null),e([f()],$.prototype,`disabledOrReadOnly`,null),e([f()],$.prototype,`features`,null),e([f()],$.prototype,`footerButtonInfos`,null),e([f()],$.prototype,`map`,null),e([f()],$.prototype,`maximumFeatureCount`,null),e([f()],$.prototype,`maximumFeatureCountWithComplexForms`,null),e([f()],$.prototype,`spatialReference`,null),e([f()],$.prototype,`layerInfos`,null),e([f()],$.prototype,`timeZone`,null),e([f()],$.prototype,`headingLevel`,void 0),e([f()],$.prototype,`icon`,null),e([f(),q(`esri/t9n/common`)],$.prototype,`messagesCommon`,void 0),e([f(),q(`esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm`)],$.prototype,`messages`,void 0),e([f(),q(`esri/widgets/FeatureForm/t9n/FeatureForm`)],$.prototype,`featureFormMessages`,void 0),e([f(),q(`esri/widgets/FeatureTable/t9n/FeatureTable`)],$.prototype,`featureTableMessages`,void 0),e([f(),q(`esri/core/t9n/Units`)],$.prototype,`messagesUnits`,void 0),e([f()],$.prototype,`page`,null),e([f()],$.prototype,`readOnly`,null),e([f()],$.prototype,`showPrompt`,null),e([f()],$.prototype,`clearPrompt`,null),e([f()],$.prototype,`selectedAttachment`,null),e([f()],$.prototype,`selectedAttachmentDetails`,null),e([f()],$.prototype,`valid`,null),e([f({type:C}),_e([`attachments-change`,`value-change`,`values-change`,`submit`])],$.prototype,`viewModel`,void 0),e([f({type:D,nonNullable:!0})],$.prototype,`visibleElements`,void 0),e([f()],$.prototype,`groupDisplay`,void 0),e([f()],$.prototype,`_formHeaderVisible`,null),e([f()],$.prototype,`_associationsEnabled`,null),e([f()],$.prototype,`_associationsList`,void 0),e([f()],$.prototype,`_attemptFocusOnNextRender`,void 0),e([f()],$.prototype,`_formId`,null),e([f()],$.prototype,`_focusedFieldInput`,void 0),e([f()],$.prototype,`_pendingSubtypeChoice`,void 0),e([f()],$.prototype,`_relatedRecordsEnabled`,null),e([f()],$.prototype,`_listObserverNode`,void 0),e([f()],$.prototype,`_attachmentDialogInfo`,void 0),e([f()],$.prototype,`_attachmentListFilterText`,void 0),e([f()],$.prototype,`_prompt`,void 0),e([f()],$.prototype,`test`,null),$=e([p(`esri.widgets.BatchAttributeForm`)],$);function ye(e){switch(e){case`audio`:return _(`audio/mpeg`);case`video`:return _(`video/mp4`);case`image`:return _(`image/png`);default:return`camera`}}const be=$;export{be as default};
2
+ import{__decorate as e}from"tslib";import{substitute as t}from"../intl.js";import{deprecateWidget as n}from"../core/deprecate.js";import r from"../core/Logger.js";import{getOrCreateMapValue as i}from"../core/MapUtils.js";import{destroyMaybe as a}from"../core/maybe.js";import o from"../core/ReactiveMap.js";import{watch as s,when as c,on as l,sync as u}from"../core/reactiveUtils.js";import{formatFileSize as d}from"../core/unitFormatUtils.js";import{property as f,subclass as p}from"../core/accessorSupport/decorators.js";import{formatDate as m}from"../intl/date.js";import{isIntegerField as h}from"../layers/support/fieldUtils.js";import{isString as g}from"../support/guards.js";import ee from"./Widget.js";import{getAttachmentTypeCategory as te,getCalciteIconForAttachment as _}from"./Attachments/support/attachmentUtils.js";import{getAttachmentKey as v,isImageAttachment as y,getAttachmentFilenameParts as b}from"./BatchAttributeForm/attachmentUtils.js";import{getHiddenFieldsValidationErrorMessage as x,getMessageString as ne,isElementTemplateWithInputType as S,subtypeChangeShouldPrompt as re,flattenInputs as ie}from"./BatchAttributeForm/batchAttributeFormUtils.js";import C from"./BatchAttributeForm/BatchAttributeFormViewModel.js";import{css as w}from"./BatchAttributeForm/css.js";import{makeViewingEditedAttachmentFooterButtons as ae,makeViewingAttachmentFooterButtons as oe,makeCancelFooterButton as T,makeDefaultFooterButtons as E}from"./BatchAttributeForm/interfaceUtils.js";import D from"./BatchAttributeForm/VisibleElements.js";import{isDynamicChoiceController as O,isMultipleChoiceController as k}from"./BatchAttributeForm/inputs/support/controllerUtils.js";import{isGroupInput as A,isFieldInput as j,isTextElementInput as se,isRelationshipElementInput as ce,isAttachmentElementInput as le,isUtilityNetworkAssociationsElementInput as ue,differentValuesString as M,getNormalizedFieldName as N,isGroupedInput as P}from"./BatchAttributeForm/inputs/support/inputUtils.js";import{clearMultipleChoiceOtherChoiceStateForViewModel as F,otherChoiceCheckedPlaceholderValue as I,canRestoreMultipleChoiceOtherChoiceDraftValue as L}from"./BatchAttributeForm/inputs/support/multipleChoiceInputUtils.js";import{loadRelationshipDetailsComponents as R,RelationshipDetails as z}from"./BatchAttributeForm/rendered-content/RelationshipDetails.js";import{Prompt as B}from"./Editor/components/Prompt.js";import{downloadAttachmentInfo as V}from"./FeatureTable/support/exportUtils.js";import{loadCalciteComponents as H}from"./support/componentsUtils.js";import{getLabelForDateFieldValue as de,getIntlOptionsForField as fe,prepareISOFieldValueForDateComponents as U,prepareUnixFieldValueForDateComponents as W,normalizeTimeOnlyString as G,getISOFieldValueFromDateComponents as pe,getUnixFieldValueFromDateComponents as me}from"./support/dateUtils.js";import{globalCss as K}from"./support/globalCss.js";import{Heading as he}from"./support/Heading.js";import{calciteListFilterProps as ge}from"./support/listUtils.js";import{messageBundle as q,vmEvent as _e,tsx as J}from"./support/widget.js";import{setFocus as ve}from"./support/widgetUtils.js";import{isEmptyValue as Y,ContingentValuesValidationError as X}from"./support/forms/formUtils.js";const Z=`data-element-id`,Q=`data-field-name`;let $=class extends ee{constructor(e,t){super(e,t),this.headingLevel=2,this.messagesCommon=null,this.messages=null,this.featureFormMessages=null,this.featureTableMessages=null,this.messagesUnits=null,this.viewModel=new C,this.visibleElements=new D,this.groupDisplay=`all`,this._associationsList=null,this._associationsWidgetsMap=new o,this._attemptFocusOnNextRender=!1,this._dateComponentMap=new Map,this._touchedInputs=new Set,this._dynamicChoiceItemSelections=new WeakSet,this._focusedFieldInput=null,this._pendingSubtypeChoice=null,this._batchSwitchInputInitialValues=new Map,this._listObserverNode=null,this._listObserver=new IntersectionObserver(e=>{e.length&&e[0].isIntersecting&&this.viewModel.activeRelationshipInput?.incrementPage()},{root:window.document}),this._attachmentDialogInfo=null,this._attachmentListFilterText=``,this._attachmentFileInputMap=new Map,this._prompt=null,this._selectedAttachmentReplaceFileInput=null,this._afterListObserverCreated=e=>{this.viewModel.activeRelationshipInput&&(this._listObserverNode=e)},this._afterListObserverRemoved=()=>{this._listObserverNode=null},this._maximizeSelectedAttachment=()=>{this._attachmentDialogInfo=this.selectedAttachmentDetails},this._enterAttachmentReplaceView=()=>{let e=this.selectedAttachmentDetails;this._canReplaceSelectedAttachment()&&e&&(e.input.clearValidationCriteriaState(),this.viewModel.setShowingSelectedAttachmentReplacePage(!0))},this._setSelectedAttachmentReplaceFileInput=e=>{this._selectedAttachmentReplaceFileInput=e},this._openSelectedAttachmentReplaceFilePicker=()=>{this._canReplaceSelectedAttachment()&&this._selectedAttachmentReplaceFileInput?.click()},this._resetSelectedAttachmentName=()=>{let e=this.selectedAttachmentDetails;if(!e?.attachment)return;let t=e.input.getAttachmentEditState(e.attachment).initialName;if(t==null)return;let n=e.input.template.elementId,r=v(e.attachment);this.viewModel.stageRenameAttachment(n,r,t)},this._closeAttachmentDialog=()=>{this.hideAttachmentDialog()},this._saveInputFromElement=this._saveInputFromElement.bind(this),this._onFormSubmit=this._onFormSubmit.bind(this),this._onComponentFocus=this._onComponentFocus.bind(this),this._onComponentBlur=this._onComponentBlur.bind(this),this._afterComponentCreateOrUpdate=this._afterComponentCreateOrUpdate.bind(this),this._afterDateComponentCreateOrUpdate=this._afterDateComponentCreateOrUpdate.bind(this),this._afterRadioGroupCreateOrUpdate=this._afterRadioGroupCreateOrUpdate.bind(this),e?.suppressDeprecationWarning||(this.announceDeprecation=()=>{n(r.getLogger(this),`Editor`,`arcgis-editor`,{version:`5.0`})})}normalizeCtorArgs(e={}){let{suppressDeprecationWarning:t,...n}=e;return n}initialize(){this.addHandles([s(()=>this.features.toArray(),()=>{this._dateComponentMap.clear(),F(this.viewModel,{includeDraftValues:!0})}),s(()=>this.viewModel.activeForm,()=>{this._batchSwitchInputInitialValues.clear(),this._resetTransientFormState(),F(this.viewModel),this._syncGroupInputInitialStates(),this._setFocusableInput()}),s(()=>this.viewModel.selectedAttachmentAddElementId,()=>{this.hideAttachmentDialog()}),c(()=>!this.selectedAttachmentDetails,()=>this.hideAttachmentDialog()),s(()=>this.viewModel.selectedAttachmentListElementId,()=>{this._attachmentListFilterText=``}),s(()=>[this.viewModel.activeRelationshipInput,this._listObserverNode],()=>this._onObserverChange()),l(()=>this.viewModel,`submit`,()=>{this.valid||this.goToFirstError()}),s(()=>[this._associationsEnabled,this.viewModel.activeForm.allUtilityNetworkAssociationsElementInputs],()=>this._setUpAssociationsWidgets(),u),s(()=>this.viewModel.activeAssociationsInput,e=>this._onActiveAssociationsInputChange(e)),s(()=>this.groupDisplay,()=>this._syncGroupInputInitialStates())])}loadDependencies(){return Promise.all([H({action:()=>import(`@esri/calcite-components/dist/components/calcite-action`),autocomplete:()=>import(`@esri/calcite-components/dist/components/calcite-autocomplete`),"autocomplete-item":()=>import(`@esri/calcite-components/dist/components/calcite-autocomplete-item`),block:()=>import(`@esri/calcite-components/dist/components/calcite-block`),button:()=>import(`@esri/calcite-components/dist/components/calcite-button`),checkbox:()=>import(`@esri/calcite-components/dist/components/calcite-checkbox`),chip:()=>import(`@esri/calcite-components/dist/components/calcite-chip`),combobox:()=>import(`@esri/calcite-components/dist/components/calcite-combobox`),"combobox-item":()=>import(`@esri/calcite-components/dist/components/calcite-combobox-item`),"combobox-item-group":()=>import(`@esri/calcite-components/dist/components/calcite-combobox-item-group`),dialog:()=>import(`@esri/calcite-components/dist/components/calcite-dialog`),dropdown:()=>import(`@esri/calcite-components/dist/components/calcite-dropdown`),"dropdown-group":()=>import(`@esri/calcite-components/dist/components/calcite-dropdown-group`),"dropdown-item":()=>import(`@esri/calcite-components/dist/components/calcite-dropdown-item`),icon:()=>import(`@esri/calcite-components/dist/components/calcite-icon`),input:()=>import(`@esri/calcite-components/dist/components/calcite-input`),"input-date-picker":()=>import(`@esri/calcite-components/dist/components/calcite-input-date-picker`),"input-message":()=>import(`@esri/calcite-components/dist/components/calcite-input-message`),"input-number":()=>import(`@esri/calcite-components/dist/components/calcite-input-number`),"input-time-picker":()=>import(`@esri/calcite-components/dist/components/calcite-input-time-picker`),"input-time-zone":()=>import(`@esri/calcite-components/dist/components/calcite-input-time-zone`),label:()=>import(`@esri/calcite-components/dist/components/calcite-label`),list:()=>import(`@esri/calcite-components/dist/components/calcite-list`),"list-item":()=>import(`@esri/calcite-components/dist/components/calcite-list-item`),loader:()=>import(`@esri/calcite-components/dist/components/calcite-loader`),notice:()=>import(`@esri/calcite-components/dist/components/calcite-notice`),switch:()=>import(`@esri/calcite-components/dist/components/calcite-switch`),"text-area":()=>import(`@esri/calcite-components/dist/components/calcite-text-area`),"radio-button":()=>import(`@esri/calcite-components/dist/components/calcite-radio-button`),"radio-button-group":()=>import(`@esri/calcite-components/dist/components/calcite-radio-button-group`)}),R()])}destroy(){this._destroyAssociationsWidgets(),this._associationsList=a(this._associationsList),this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode)}get activeFeatureIndex(){return this.viewModel.activeFeatureIndex}set activeFeatureIndex(e){this.viewModel.activeFeatureIndex=e}get attachmentsEnabled(){return this.viewModel.attachmentsEnabled}set attachmentsEnabled(e){this.viewModel.attachmentsEnabled=e}get callbacks(){return this.viewModel.callbacks}set callbacks(e){this.viewModel.callbacks=e}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get effectiveTitle(){let{features:e,messages:t,page:n}=this;return t?n===`replacing-attachment`?t.titles.replaceAttachment:n===`viewing-attachment-details`?t.titles.editAttachment:n===`adding-attachments`?t.titles.addAttachments:n===`viewing-attachments`?t.titles.attachments:e.length===1||this.activeFeatureIndex>-1?t.titles.editFeature:e.length>1?t.titles.editFeatures:``:``}get effectiveDisabled(){return this.disabledOrReadOnly||this.viewModel.updating}get disabledOrReadOnly(){return this.disabled||this.readOnly}get features(){return this.viewModel.features}set features(e){this.viewModel.features=e}get footerButtonInfos(){if(!this.features.length||!this.messages||!this.messagesCommon)return[];let{messages:e,messagesCommon:t,page:n}=this,r=this.effectiveDisabled;if(n===`adding-attachments`||n===`replacing-attachment`)return[];if(n===`viewing-attachment-details`){let t=this.selectedAttachmentDetails,n=t?.input?.getAttachmentEditState(t.attachment);return!t?.input||!n?[]:n.isRenamed||n.isReplaced?ae({doneOnclick:()=>this._setSelectedAttachment(null),messages:e.footerButtons,resetOnclick:()=>this._resetSelectedAttachmentChanges(),resetDisabled:this._disableAttachmentModification(t.input)}):oe({deleteDisabled:this._disableAttachmentModification(t.input),deleteOnclick:()=>this._deleteSelectedAttachment(),doneOnclick:()=>this._setSelectedAttachment(null),messages:e.footerButtons})}return n===`viewing-associated-features`?T({messages:t,purpose:`cancel-viewing-associated-features`,onclick:()=>this.goBack()}):n===`viewing-associated-layers`?T({messages:t,purpose:`cancel-viewing-associated-layers`,onclick:()=>this.goBack()}):n===`viewing-attachments`||n===`viewing-related-records`?[]:E({disabled:r||!this.valid,formId:this._formId,messages:e,callback:()=>this.submit()})}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get maximumFeatureCount(){return this.viewModel.maximumFeatureCount}set maximumFeatureCount(e){this.viewModel.maximumFeatureCount=e}get maximumFeatureCountWithComplexForms(){return this.viewModel.maximumFeatureCountWithComplexForms}set maximumFeatureCountWithComplexForms(e){this.viewModel.maximumFeatureCountWithComplexForms=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get layerInfos(){return this.viewModel.layerInfos}set layerInfos(e){this.viewModel.layerInfos=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get icon(){return`edit-attributes`}set icon(e){this._overrideIfSome(`icon`,e)}get page(){return this.viewModel.page}get readOnly(){return this.viewModel.readOnly}set readOnly(e){this.viewModel.readOnly=e}get showPrompt(){return e=>{this._prompt?.cancel?.(),this._prompt=e}}set showPrompt(e){this._overrideIfSome(`showPrompt`,e)}get clearPrompt(){return()=>this._prompt=null}set clearPrompt(e){this._overrideIfSome(`clearPrompt`,e)}get selectedAttachment(){return this.viewModel.selectedAttachment}get selectedAttachmentDetails(){return this.viewModel.selectedAttachmentDetails}get valid(){return this.viewModel.valid}get _formHeaderVisible(){return this.viewModel.mode===`batch`||!this.viewModel.activeFeature?!1:!!(this.viewModel.formDescription||this.viewModel.formTitle)}get _associationsEnabled(){let{callbacks:e}=this;return!!(e?.addAssociation||e?.editAssociatedFeature)}get _formId(){return`${this.id}-form`}get _relatedRecordsEnabled(){let{callbacks:e}=this;return!!(e&&(e.addRelatedRecord||e.editRelatedRecord))}async goBack(){return this.viewModel.goBack()}async goHome(){return this.viewModel.goHome()}goToFirstError(){let e=this.viewModel.getFirstVisibleInvalidFieldInput();if(!e)return;let{groupInput:t}=e;t&&(t.open||=!0),this._setFocusableInput(e.input),this.scheduleRender()}render(){return J(`div`,{class:this.classes(w.base,K.widget,K.panel),ondragover:this._handleDragAndDrop,ondrop:this._handleDragAndDrop},this._renderContent(),this._renderAttachmentDialog(),this._prompt?J(B,{...this._prompt,headingLevel:this.headingLevel}):void 0)}setActiveAssociationsInput(e){this.viewModel.setActiveAssociationsInput(e)}setActiveAssociationsLayer(e){this.viewModel.setActiveAssociationsLayer(e)}setActiveAssociationType(e){this.viewModel.setActiveAssociationType(e)}submit(){return this.viewModel.submit()}get test(){return{saveInput:this._saveInput.bind(this),pendingSubtypeChoice:this._pendingSubtypeChoice,touchedInputs:this._touchedInputs}}_setDateTimeTimeZoneMap(e){let{datePart:t,elementId:n}=e.dataset,r=i(this._dateComponentMap,`${n}`,()=>({}));switch(t){case`date`:r.date=e;break;case`time`:r.time=e;break;case`timeZone`:r.timeZone=e}}_renderContent(){let{messages:e,viewModel:n}=this,{status:r}=n;if(r===`failed`)return n.hasTooManyComplexFeatures?this._renderErrorNotice(t(e.formFailedToLoadTooManyComplexFeatures,{num:n.maximumFeatureCountWithComplexForms})):n.hasTooManyFeatures?this._renderErrorNotice(t(e.formFailedToLoadTooManyFeatures,{num:n.maximumFeatureCount})):e.formFailedToLoad;if(n.hasLayersWithContingentValues&&this.viewModel.features.length>1)return this._renderErrorNotice(e.unsupportedContingentValues);if(r===`loading`&&this.visibleElements.loadingIndicator)return J(`calcite-loader`,{key:`loader`,label:this.messagesCommon?.loading});if(this.features.length!==0)return this._renderForm()}_renderErrorNotice(e,t=`warning`){return J(`calcite-notice`,{class:w.noticeError,icon:!0,kind:t,open:!0},J(`div`,{slot:`message`},e))}_renderForm(){return J(`form`,{class:w.form,id:this._formId,inert:!!this._prompt,onsubmit:this._onFormSubmit},this.viewModel.expressionEvaluationFailed&&this.visibleElements.expressionsErrorNotice&&this._renderErrorNotice(this.messages.expressionEvaluationFailed),this._renderInvisibleFieldsError(),this._renderPage())}_renderPage(){switch(this.page){case`adding-attachments`:return this._renderAttachmentAddPage();case`viewing-attachment-details`:case`replacing-attachment`:return this._renderAttachmentDetailPage();case`viewing-attachments`:return this._renderAttachmentListPage();case`viewing-associated-layers`:case`viewing-associated-features`:return this._renderViewingAssociationsPage();case`viewing-related-categories`:case`viewing-related-records`:return this._renderRelationshipListPage();default:return this._renderDefaultPage()}}_renderInvisibleFieldsError(){let{viewModel:e}=this,{hasNonActiveInvalidFeatures:t,activeForm:n}=e,r;if(!e.submitHasBeenAttempted)return null;if(n.invalidHiddenInputs.length>0){if(r=x(n,e.mode,this.messages),this.viewModel.mode===`batch`){let e=n.invalidHiddenInputs.filter(e=>e.effectiveVisibilityCode===`hidden:group-visibility-expression:all-features`||e.visibilityCode===`hidden:visibility-expression:all-features`);e.length>0?r+=` (${e.map(e=>e.label).join(`, `)})`:r=null}else r=null}else if(t)return null;return r?this._renderErrorNotice(r,`danger`):null}_renderDefaultPage(){return[this._renderReadOnlyNotice(),this._renderFormHeader(),this._renderFormContent()]}_renderReadOnlyNotice(){if((this.disabled||this.readOnly)&&this.visibleElements.readOnlyNotice)return J(`calcite-notice`,{class:w.disabledNotice,"data-testid":`read-only-notice`,icon:`read-only-non-editable`,kind:`brand`,open:!0,scale:`s`,width:`full`},J(`div`,{slot:`message`},this.featureFormMessages.disabledForm))}_renderFormHeader(){let{formTitle:e,formDescription:t}=this.viewModel;if(!this._formHeaderVisible)return;let n=e?J(he,{key:`title`,level:this.headingLevel},e):void 0,r=t?J(`p`,{class:w.description,key:`description`},t):void 0;return J(`div`,{class:w.formHeader},n,r)}_renderFormContent(){return this.viewModel.hasVisibleInputs?this.viewModel.activeForm.inputs.filter(e=>e.visible).map(e=>this._renderInput(e)):this._renderErrorNotice(this.messages.noVisibleFields[this.viewModel.noVisibleElementsReason])}_renderInput(e){if(A(e))return this._renderGroupInput(e);if(j(e))return this._renderLabeledField(e);if(se(e))return this._renderTextComponent(e);if(ce(e))return this._renderRelationshipElementInput(e);if(le(e))return this._renderAttachmentElementInput(e);if(ue(e))return this._renderUtilityNetworkAssociationsElementInput(e)}_renderGroupInput(e){let{inputs:t,template:n,open:r}=e,i=t.filter(e=>e.visible),a=e.label??``,o=this._focusedFieldInput?.group===e,s=this.groupDisplay===`sequential`;return J(`calcite-block`,{class:this.classes(w.group,s?w.groupSequential:null,o?w.groupActive:null,this.disabled?w.inputDisabled:null),description:e.description??void 0,expandable:!0,expanded:r,heading:a,headingLevel:this.headingLevel,key:`{${n.elementId}-key}`,label:a,onCalciteBlockCollapse:()=>{e.open=!1},onCalciteBlockExpand:()=>{this._onGroupExpand(e)}},i.map(e=>this._renderInput(e)))}_renderLabeledField(e){let{elementId:n}=e.template,{label:r,required:i,dataType:a}=e,o=i?t(this.messages.requiredFieldLabel,{name:r}):r;return J(`calcite-label`,{"aria-label":o,class:w.label,key:`field--${n}`},J(`div`,{class:w.labelTextContent,key:`labelTextContainer`},r,i?J(`span`,{"aria-hidden":`true`,title:this.messagesCommon.required},`*`):void 0),a===`unsupported`?this._renderReadOnlyComponent(e):this._renderFieldInput(e),this._renderAuxiliaryText(e))}_renderFieldInput(e){let t=this.getCommonInputProps(e),{dataType:n}=e;return O(e.inputController)?this._renderDynamicChoiceComponent({input:e,props:t,controller:e.inputController}):e.domain?.type===`coded-value`?this._renderCodedInputs({input:e,props:t}):k(e.inputController)?this._renderMultipleChoiceComponent({input:e,props:t}):n===`date`?this._renderDateComponents(e,t):(t.disabled=this.disabled,t.readOnly=t.readOnly||this.viewModel.updating,n===`number`?this._renderNumberComponent(e,t):this._renderStringComponent(e,t))}_renderAuxiliaryText(e){let{description:t}=e,n=this._getErrorToDisplay(e),r=n?ne(e,n,this.messages):null;return r?J(`calcite-input-message`,{icon:!0,status:`invalid`},r):e.valueIsOutOfDomain&&(this._touchedInputs.has(e.template.elementId)||this.viewModel.submitHasBeenAttempted)?J(`calcite-input-message`,{icon:!0,status:`idle`},this.messages.subtypes.fieldOutOfSubtypeDomainWarning):t?J(`calcite-input-message`,{class:w.description,icon:!1,status:`idle`},t):null}_renderCodedInputs({input:e,props:t}){let n=e.input?.type??null,r=e.codedValueOptions;switch(n){case`switch`:return this._renderSwitchField({input:e,props:t});case`radio-buttons`:return this._renderRadioButtonGroupComponent({input:e,options:r,props:t});default:return this._renderComboBoxComponent({options:r,props:t,input:e})}}_renderDynamicChoiceComponent({input:e,props:t,controller:n}){let r=n.filteredChoices,i=t.readOnly||t.disabled,a=e.showNoValueLabel||this.messages.empty,o=n.evaluated&&!n.evaluating&&!n.choices.length&&J(`calcite-notice`,{appearance:`transparent`,kind:`neutral`,open:!0,scale:`s`,slot:`content-bottom`,width:`full`},J(`div`,{slot:`message`},e.showNoValueOptionEnabled?this.messages.noDynamicChoicesWithNoValue:this.messages.noDynamicChoices)),s=t=>{this._saveInput(e,t)},l=(e,t)=>{this._dynamicChoiceItemSelections.delete(n);let r=e.closest(`calcite-autocomplete`);if(r){let e=t==null?``:n.getLabel(t);n.filterValue=``,r.inputValue=e}s(t)},u=({currentTarget:t})=>{let r=t.inputValue??``;n.filterValue=r,!r&&e.value!=null&&s(null)},d=e.showNoValueOptionEnabled?J(`calcite-autocomplete-item`,{disabled:i,heading:a,key:`dynamic-choice-empty`,selected:e.value==null,value:``,onCalciteAutocompleteItemSelect:({currentTarget:e})=>l(e,null),onpointerdown:()=>{this._dynamicChoiceItemSelections.add(n)}}):null,f=t=>{this.addHandles(c(()=>!n.initialEvaluationInProgress,()=>{t.inputValue=e.value===M?this.messages.differentValuesPlaceholder:e.value==null?``:n.inputValue},{once:!0,initial:!0}))};return J(`calcite-autocomplete`,{...t,afterCreate:f,disabled:i&&!n.interactionActive,loading:n.initialEvaluationInProgress,placeholder:e.value==null?a:t.placeholder,value:t.value===M?this.messages.differentValuesPlaceholder:String(t.value),onblur:e=>this._onDynamicChoiceBlur(e,n),onCalciteAutocompleteBeforeOpen:()=>n.beginInteraction(),onCalciteAutocompleteTextInput:u},n.evaluating?J(`calcite-loader`,{key:`dynamic-choice-loader`,label:this.messagesCommon.loading,scale:`s`,slot:`content-top`}):[o,d,...r.map(t=>J(`calcite-autocomplete-item`,{disabled:i,heading:t.name,key:`dynamic-choice-${t.code}`,selected:t.code===e.value,value:String(t.code),onCalciteAutocompleteItemSelect:({currentTarget:e})=>l(e,t.code),onpointerdown:()=>{this._dynamicChoiceItemSelections.add(n)}}))])}_renderMultipleChoiceComponent({input:e,props:t}){let{messages:n}=this,r=this._getMultipleChoiceController(e);if(!r)return null;let{input:i}=r,a=i.includeSelectAllChoices===!0,{checkboxStatesByValue:o,selectAllState:s}=r.selectionState,c=s.checked?n.deselectAllLabel:n.selectAllLabel,l=r.otherChoiceRenderState;return J(`div`,{class:w.multipleChoiceInput,key:`${t.key}-multiple-choice-group`},a?this._renderMultipleChoiceSelectAllCheckbox({props:t,selectAllState:s,selectAllLabel:c,handleSelectAllCheckboxChange:t=>{this._saveValueFromMultipleChoiceCheckbox({input:e,checkbox:t,isSelectAllCheckbox:!0})}}):null,this._renderMultipleChoiceChoiceCheckboxes({input:e,props:t,checkboxStatesByValue:o,handleChoiceCheckboxChange:t=>{this._saveValueFromMultipleChoiceCheckbox({input:e,checkbox:t})}}),l.shouldShow?this._renderMultipleChoiceOtherChoice({props:t,includeSelectAllChoices:a,otherChoiceRenderState:l,handleOtherChoiceCheckboxChange:t=>{let{fieldName:n}=l;n&&this._saveOtherChoiceCheckboxValue({input:e,isChecked:t.checked,otherChoiceFieldName:n})},handleOtherChoiceInputChange:t=>{this._saveValueFromMultipleChoiceTextInput({input:e,textInput:t,otherChoiceFieldName:l.fieldName??void 0})},differentValuesPlaceholder:n.differentValuesPlaceholder}):null)}_renderMultipleChoiceSelectAllCheckbox({props:e,selectAllState:t,selectAllLabel:n,handleSelectAllCheckboxChange:r}){return J(`calcite-checkbox`,{afterCreate:e.afterCreate,afterUpdate:e.afterUpdate,"aria-invalid":e[`aria-invalid`],checked:t.checked,class:w.multipleChoiceSelectAll,"data-element-id":e[Z],disabled:e.readOnly||e.disabled,indeterminate:t.indeterminate,key:`${e.key}-select-all`,label:n,labelText:n,value:`esri_BatchAttributeForm_select_all`,onblur:e.onblur,onCalciteCheckboxChange:({currentTarget:e})=>r(e),onfocus:e.onfocus})}_renderMultipleChoiceChoiceCheckboxes({input:e,props:t,checkboxStatesByValue:n,handleChoiceCheckboxChange:r}){let i=this._getMultipleChoiceController(e);if(!i)return[];let{choices:a}=i;return a.map(e=>{let i=n.get(e.value)??{checked:!1,indeterminate:!1};return J(`calcite-checkbox`,{afterCreate:t.afterCreate,afterUpdate:t.afterUpdate,"aria-invalid":t[`aria-invalid`],checked:i.checked,class:t.class,"data-element-id":t[Z],disabled:t.readOnly||t.disabled,indeterminate:i.indeterminate,key:`${t.key}-${e.value}`,label:e.label,labelText:e.label,value:e.value,onblur:t.onblur,onCalciteCheckboxChange:({currentTarget:e})=>r(e),onfocus:t.onfocus})})}_renderMultipleChoiceOtherChoice({props:e,includeSelectAllChoices:t,otherChoiceRenderState:n,handleOtherChoiceCheckboxChange:r,handleOtherChoiceInputChange:i,differentValuesPlaceholder:a}){let o=n.label??this.messages.otherOptionLabel;return J(`div`,{class:this.classes(w.multipleChoiceOtherChoice,t?w.multipleChoiceOtherChoiceWithSelectAll:null),key:`${e.key}-other-choice`},J(`calcite-checkbox`,{afterCreate:e.afterCreate,afterUpdate:e.afterUpdate,"aria-invalid":e[`aria-invalid`],checked:n.checkboxState.checked,class:e.class,"data-element-id":e[Z],disabled:e.readOnly||e.disabled,indeterminate:n.checkboxState.indeterminate,key:`${e.key}-other-choice-checkbox`,label:o,labelText:o,value:`esri_BatchAttributeForm_other_choice`,onblur:e.onblur,onCalciteCheckboxChange:({currentTarget:e})=>r(e),onfocus:e.onfocus}),n.checkboxState.checked?J(`calcite-input`,{afterCreate:e.afterCreate,afterUpdate:e.afterUpdate,"aria-invalid":e[`aria-invalid`],"aria-label":o,class:w.textElementInput,"data-element-id":e[Z],disabled:e.readOnly||e.disabled,key:`${e.key}-other-choice-input`,maxLength:n.maxLength,placeholder:n.value===M?a:n.hint,status:n.status,type:`text`,value:n.normalizedValue===M?``:n.normalizedValue?String(n.normalizedValue):``,onblur:e.onblur,onCalciteInputInput:({currentTarget:e})=>i(e),onfocus:e.onfocus}):null)}async _saveValueFromMultipleChoiceCheckbox({input:e,checkbox:t,isSelectAllCheckbox:n=!1}){this._markInputTouched(e);let r=this._getMultipleChoiceController(e);if(!r)return;if(r.input&&!n&&this.viewModel.mode===`batch`){await this._saveMultipleChoiceCheckboxValueByFeature({input:e,checkbox:t});return}let i=e.value,a=this._parseValue(t,e,n);a!==i&&await this.viewModel.setValue(e.template.elementId,a)}async _saveValueFromMultipleChoiceTextInput({input:e,textInput:t,otherChoiceFieldName:n}){if(!n)return;let r=t.value,i=r==null||r===``?null:r,a=this._getMultipleChoiceController(e);if(!a)return;a.initializeExplicitOtherChoiceCheckedState(),a.stashOtherChoiceDraftValueForFeatures(e.features,i);let o=N(e,n);o&&await this.viewModel.setValueForFieldName(o,i,Array.from(e.features,e=>e.source))}async _saveOtherChoiceCheckboxValue({input:e,isChecked:t,otherChoiceFieldName:n}){let r=this._getMultipleChoiceController(e);if(!r)return;r.setExplicitOtherChoiceCheckedState(t),this._markInputTouched(e),t||r.setOtherChoiceDraftValuesFromFeatures(e.features.toArray());let i=N(e,n);if(!i)return;let a=new Map;for(let i of e.features){let e=i.getAttribute(n);if(t){if(!Y(e))continue;let t=r.getOtherChoiceDraftValue(i),n=L(t)?t:I;a.set(i,n);continue}e!=null&&a.set(i,null)}a.size!==0&&await this.viewModel.setValuePerFeatureForFieldName(i,new Map(Array.from(a,([e,t])=>[e.source,t])))}async _saveMultipleChoiceCheckboxValueByFeature({input:e,checkbox:t}){let n=this._getMultipleChoiceController(e);if(!n)return;let r=new Map(e.features.map(r=>[r,n.getUpdatedValueForFeature({choiceValue:t.value,currentValue:r.getAttribute(e.fieldName),isChecked:t.checked})]));r.size!==0&&await this.viewModel.setFieldInputValuePerFeature(e,r)}_renderSwitchField({input:e,props:t}){if((this._batchSwitchInputInitialValues.get(e)===M||e.value===M)&&this.viewModel.mode===`batch`){let n={dropdown:{afterCreate:this._afterComponentCreateOrUpdate,afterUpdate:this._afterComponentCreateOrUpdate,disabled:t.readOnly,open:!1,onblur:t.onblur,onfocus:t.onfocus,[Z]:t[Z]},trigger:{appearance:`transparent`,iconEnd:`chevron-down`,kind:`neutral`,slot:`trigger`,label:t.label},group:{mode:`single`}};return this._renderDropdownComponent({buttonValue:e.value,dropdownProps:n,options:[{name:this.messages.differentValuesPlaceholder,value:M,disabled:!0},...e.codedValueDomainOptions]})}return this._renderSwitchComponent({input:e,props:t})}_renderSwitchComponent({input:e,props:t}){return J(`calcite-switch`,{...t,checked:S(e.template,`switch`)?e.value===e.template.input.onValue:!1,class:w.inputSwitch,disabled:t.readOnly||t.disabled,onCalciteSwitchChange:({currentTarget:e})=>this._saveInputFromElement(e)})}_renderDropdownComponent({buttonValue:e,options:t,dropdownProps:n}){let{trigger:r,dropdown:i,group:a}=n;return J(`calcite-dropdown`,{...i,topLayerDisabled:this.topLayerDisabled,onCalciteDropdownSelect:({currentTarget:e})=>this._saveInputFromElement(e)},J(`calcite-button`,{...r},e===M?this.messages.differentValuesPlaceholder:e),J(`calcite-dropdown-group`,{selectionMode:a.mode},t.map(t=>J(`calcite-dropdown-item`,{disabled:t.disabled,label:String(t.name),selected:e===t.value},t.name))))}_renderComboBoxComponent({input:e,options:t,props:n}){let r=this.viewModel.editType===`INSERT`,i=this._touchedInputs.has(e?.template.elementId),a=r&&e.showNoValueOptionEnabled&&!i?()=>{}:n.onblur,o={...n,onblur:a};return J(`calcite-combobox`,{...o,clearDisabled:e.isSubtypeField,selectionMode:`single`,topLayerDisabled:this.topLayerDisabled,value:n.placeholder===this.messages.differentValuesPlaceholder?M:String(n.value),onCalciteComboboxChange:({currentTarget:t})=>{t.value!==M&&(e.isSubtypeField&&t.selectedItems.length===0?t.value=`${e.value}`:this._saveInputFromElement(t))}},this.renderComboboxOptionsList({input:e,options:t,props:n}))}renderComboboxOptionsList({input:e,options:t,props:n}){let r=e=>e.map(e=>{let{value:t}=e,r=Y(e.value)?this.messages.empty:e.name;return J(`calcite-combobox-item`,{heading:r,key:`#${t}`,selected:n.value===t,value:`${t}`})}),i=[],{messages:a}=this;t.other.length>0&&i.push(J(`calcite-combobox-item-group`,{key:`other`,label:a.other},r(t.other))),t.unsupported.length>0&&i.push(J(`calcite-combobox-item-group`,{key:`unsupported`,label:a.unsupported},r(t.unsupported)));let o=r(t.recommended);i.length>0?i.unshift(J(`calcite-combobox-item-group`,{key:`recommended`,label:a.recommended},o)):i=o;let s=n.placeholder===this.messages.differentValuesPlaceholder,c=!s&&Y(n.value);return e.showNoValueOptionEnabled&&!t.containsEmptyOption&&i.unshift(J(`calcite-combobox-item`,{heading:e.showNoValueLabel||this.messages.empty,key:`empty-option`,selected:c,value:``})),s&&i.unshift(J(`calcite-combobox-item`,{heading:this.messages.differentValuesPlaceholder,key:M,selected:!0,value:M})),i}_renderRadioButtonGroupComponent({input:e,options:t,props:n}){let r=[...t.recommended,...t.other,...t.unsupported].map(({name:t,value:r})=>this._renderRadioButtons({label:t,value:r,selected:r===e.value,props:n}));if(e.showNoValueOptionEnabled&&!t.containsEmptyOption){let t=e.showNoValueLabel||this.messages.empty,i=Y(e.value);r.unshift(this._renderRadioButtons({label:t,value:``,selected:i,props:n}))}return J(`calcite-radio-button-group`,{afterCreate:this._afterRadioGroupCreateOrUpdate,afterUpdate:this._afterRadioGroupCreateOrUpdate,class:w.inputRadioGroup,"data-field-name":n[Q],disabled:n.readOnly||n.disabled,key:`${n.key}-radio-group`,layout:`vertical`,name:`${n.name}-${this.id}`,required:n.required},r,n.placeholder===this.messages.differentValuesPlaceholder?J(`calcite-label`,{class:w.placeholderRadio,key:n.label,layout:`inline`},J(`calcite-radio-button`,{checked:!0,class:w.inputRadio,disabled:!0,value:n.placeholder}),n.placeholder):null)}_renderRadioButtons({value:e,selected:t,label:n,props:r}){return J(`calcite-label`,{class:w.inputRadioLabel,key:r.label,layout:`inline`},J(`calcite-radio-button`,{...r,afterCreate:void 0,afterUpdate:void 0,checked:t,class:w.inputRadio,disabled:r.readOnly||r.disabled,name:void 0,value:e,onCalciteRadioButtonChange:({currentTarget:e})=>{e.checked&&this._saveInputFromElement(e)}}),n)}_renderStringComponent(e,t){let{template:n}=e;return!n.field.editable||this.readOnly?this._renderReadOnlyComponent(e):n.input?.type===`text-area`?J(`calcite-text-area`,{...t,class:this.classes(w.individualElement),resize:`vertical`,value:t.value?String(t.value):``,onblur:n=>{t.onblur(n),e.userHasChangedValue&&this._saveInputFromElement(n.currentTarget)},onCalciteTextAreaInput:t=>{e.userHasChangedValue=!0,t.currentTarget.value===``&&this._saveInputFromElement(t.currentTarget)}}):J(`calcite-input`,{...t,class:this.classes(w.individualElement),type:`text`,value:t.value?String(t.value):``,onblur:n=>{t.onblur(n),e.userHasChangedValue&&this._saveInputFromElement(n.currentTarget)},onCalciteInputInput:t=>{e.userHasChangedValue=!0,t.currentTarget.value===``&&this._saveInputFromElement(t.currentTarget)}})}_renderNumberComponent(e,t){let n=h(e.field);return J(`calcite-input-number`,{...t,integer:n,step:n?1:`any`,type:`number`,value:n&&t.value!==``?Math.round(parseFloat(String(t.value))).toString():String(t.value),onblur:n=>{t.onblur(n),e.userHasChangedValue&&this._saveInputFromElement(n.currentTarget)},onCalciteInputNumberInput:t=>{e.userHasChangedValue=!0,t.currentTarget.value===``&&this._saveInputFromElement(t.currentTarget)}})}_renderReadOnlyComponent(e,t){let n=this.getCommonInputProps(e);return J(`calcite-input`,{...n,class:this.classes(w.fieldInput,w.inputDisabled,w.individualElement),readOnly:!0,type:`text`,value:String(t??n.value??``)})}_renderDateComponents(e,t){let{field:n}=e,r;switch(n.type){case`date`:r=this._renderDateFieldComponents(e,t);break;case`date-only`:r=this._renderDateOnlyFieldComponent(e,t);break;case`time-only`:r=this._renderTimeOnlyFieldComponent(e,t);break;case`timestamp-offset`:r=this._renderTimestampOffsetFieldComponents(e,t);break;default:r=this._renderReadOnlyComponent(e,de(n,t.value,{timeZone:e.effectiveTimeZone,...fe(e.template.field)}))}return e.value===M?[r,J(`calcite-input-message`,{icon:`information`,key:`diff-values-message`,status:`idle`},this.messages.differentValues)]:r}_renderDateOnlyFieldComponent(e,t){let{class:n,disabled:r,key:i,readOnly:a}=t,{rawMax:o,rawMin:s}=e.range;return J(`calcite-input-date-picker`,{afterCreate:this._afterDateComponentCreateOrUpdate,afterUpdate:this._afterDateComponentCreateOrUpdate,class:n,"data-date-part":`date`,"data-element-id":t[Z],"data-field-name":t[Q],disabled:r,key:`${i}-date-input`,max:g(o)?o:void 0,min:g(s)?s:void 0,overlayPositioning:`fixed`,readOnly:a,topLayerDisabled:this.topLayerDisabled,value:e.value===M?``:e.value?String(e.value):``,onblur:t.onblur,onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.currentTarget),onfocus:t.onfocus})}_renderTimeOnlyFieldComponent(e,t){let{class:n,disabled:r,key:i,readOnly:a}=t;return J(`calcite-input-time-picker`,{afterCreate:this._afterDateComponentCreateOrUpdate,afterUpdate:this._afterDateComponentCreateOrUpdate,class:n,"data-date-part":`time`,"data-element-id":t[Z],"data-field-name":t[Q],disabled:r,key:`${i}-time-input`,overlayPositioning:`fixed`,readOnly:a,step:e.timeStep,value:e.value===M?``:e.value?String(e.value):``,onblur:t.onblur,onCalciteInputTimePickerChange:t=>this._saveValueFromDateComponent(e,t.currentTarget),onfocus:t.onfocus})}_renderTimestampOffsetFieldComponents(e,t){let{class:n,disabled:r,key:i,readOnly:a,onblur:o,onfocus:s}=t,{rawMax:c,rawMin:l}=e.range,u=e.effectiveTimeZone,d=U(c,u),f=U(l,u),p=U(e.value===M?``:e.value,u),m=e.includeTimeOffset,h={afterCreate:this._afterDateComponentCreateOrUpdate,afterUpdate:this._afterDateComponentCreateOrUpdate,disabled:r,[Z]:t[Z],[Q]:t[Q],onblur:o,onfocus:s,overlayPositioning:`fixed`,readOnly:a};return J(`div`,{class:w.dateInputContainer,key:`${i}-date-time-container`},J(`calcite-input-date-picker`,{...h,class:n,"data-date-part":`date`,key:`${i}-date-input`,max:d?.date??void 0,min:f?.date??void 0,topLayerDisabled:this.topLayerDisabled,value:p.date??``,onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),J(`calcite-input-time-picker`,{...h,class:n,"data-date-part":`time`,key:`${i}-time-input`,step:e.timeStep,value:p.time??``,onCalciteInputTimePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),m?J(`calcite-input-time-zone`,{...h,class:n,clearable:e.value===M||e.value==null,"data-date-part":`timeZone`,key:`${i}-timezone-input`,value:p.timeZoneOffset||``,onCalciteInputTimeZoneChange:t=>this._saveValueFromDateComponent(e,t.target)}):null)}_renderDateFieldComponents(e,t){let{class:n,disabled:r,key:i,readOnly:a,min:o,max:s}=t,c=e.effectiveTimeZone,l=W(e.value===M?``:e.value,c),u=W(s,c),d=W(o,c),f=e.includeTime,p={afterCreate:this._afterDateComponentCreateOrUpdate,afterUpdate:this._afterDateComponentCreateOrUpdate,disabled:r,[Z]:t[Z],[Q]:t[Q],onblur:t.onblur,onfocus:t.onfocus,overlayPositioning:`fixed`,readOnly:a};return J(`div`,{class:w.dateInputContainer,key:`${i}-date-time-container`},J(`calcite-input-date-picker`,{...p,class:n,"data-date-part":`date`,key:`${i}-date-input`,max:u?.date??void 0,min:d?.date??void 0,topLayerDisabled:this.topLayerDisabled,value:l.date??``,onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),f?J(`calcite-input-time-picker`,{...p,"data-date-part":`time`,key:`${i}-time-input`,step:1,value:l.time??``,onCalciteInputTimePickerChange:t=>{this._saveValueFromDateComponent(e,t.target)}}):null)}_renderRelationshipElementInput(e){return this._relatedRecordsEnabled?J(z,{afterObserverCreated:this._afterListObserverCreated,afterObserverRemoved:this._afterListObserverRemoved,input:e,messages:this.messages,messagesCommon:this.messagesCommon,viewModel:this.viewModel}):null}_renderRelationshipListPage(){let{activeRelationshipInput:e}=this.viewModel;if(e)return this._renderRelationshipElementInput(e)}_renderAttachmentElementInput(e){if(!this.attachmentsEnabled)return;let{allAttachmentsVisibleOnDefaultPage:t,attachments:n,defaultPageAttachments:r,template:{description:i,elementId:a,label:o}}=e,s=t?n:r;return J(`div`,{class:w.attachmentElementInput,"data-testid":`attachment-element-${a}`,key:`attachment-element-${a}`},o?J(`div`,{class:w.attachmentElementLabel,key:`attachment-element-label-${a}`},o):null,i?J(`div`,{class:w.description,key:`attachment-element-description-${a}`},i):null,n.length?this._renderAttachmentList(e,s,{label:o||this.messagesCommon.details,viewAllCount:t?null:n.length}):J(`div`,{class:w.attachmentElementEmptyState,key:`attachment-element-empty-state-${a}`},this.messages.attachments.noAttachments),this._renderAttachmentAddAction(e))}_renderAttachmentListPage(){let e=this.viewModel.selectedAttachmentListInput;if(e)return J(`div`,{class:w.attachmentElementAllPanel,key:`attachment-element-all-panel-${e.template.elementId}`},this._renderAttachmentList(e,e.attachments,{filterEnabled:!0,label:this.messages.titles.attachments}))}_renderAttachmentList(e,t,n){let{filterEnabled:r,label:i,viewAllCount:a}=n;return J(`calcite-list`,{class:w.attachmentElementList,filterEnabled:r,filterPlaceholder:r?this.messages.attachments.searchAttachments:void 0,filterProps:r?ge:void 0,filterText:r?this._attachmentListFilterText:void 0,label:i,selectionAppearance:`border`,selectionMode:`none`,onCalciteListFilter:r?e=>{this._attachmentListFilterText=e.currentTarget.filterText??``}:void 0},this._renderAttachmentListItems(e,t),a==null?null:this._renderViewAllAttachmentsItem(e,a))}_renderAttachmentListItems(e,t){let{elementId:n}=e.template;return t.map((t,r)=>{let i=this._formatAttachmentSize(t.size),a=this._getAttachmentLabel(t,r,i,e.displayFilename),o=a===i?void 0:i,s=v(t),c=e.isStagedAttachmentAddition(t),l=e.getAttachmentEditState(t),u=l.isDeleted,d=!u&&(c||l.isRenamed||l.isReplaced);return J(`calcite-list-item`,{class:w.attachmentElementListItem,description:o,key:`attachment-item-${s}`,label:a,onCalciteListItemSelect:c||u?void 0:()=>this._setSelectedAttachment({attachmentKey:s,elementId:n})},J(`div`,{class:w.attachmentElementListItemStart,slot:`content-start`},this._renderAttachmentPreviewThumbnail(t,a,e)),d?J(`span`,{class:w.attachmentElementListItemStagedIndicator,slot:`content-end`}):null,c?[J(`calcite-action`,{disabled:this._disableAttachmentModification(e),icon:`x`,scale:`s`,slot:`actions-end`,text:this.messagesCommon.delete,title:this.messagesCommon.delete,onclick:()=>this.viewModel.stageDeleteAttachment(n,v(t))})]:u?J(`calcite-chip`,{label:this.messages.attachments.deleted,scale:`s`,slot:`content-end`},this.messages.attachments.deleted):J(`calcite-icon`,{flipRtl:!0,icon:`chevron-right`,scale:`s`,slot:`content-end`}))})}_renderViewAllAttachmentsItem(e,n){let{elementId:r}=e.template,{viewAll:i}=this.messages.attachments;return J(`calcite-list-item`,{class:w.attachmentElementListItem,description:t(this.messages.attachments.count,{count:n}),key:`attachment-item-view-all-${r}`,label:i,onCalciteListItemSelect:()=>this._setAttachmentListElementId(r)},J(`calcite-icon`,{flipRtl:!0,icon:`chevron-right`,scale:`s`,slot:`content-end`}))}_renderAttachmentAddAction(e){let{elementId:t}=e.template,n=this.effectiveDisabled||e.addDisabled,r=this._renderAttachmentCountLimitsLabel(e),i=this._getAttachmentNoticeMessage(e),a=e.hasMinimumAttachmentCountNotMet||e.hasExceededAttachmentLimit?`danger`:`info`,o=e.canUploadFiles,s=e.isCaptureOnly&&!this.effectiveDisabled&&!i;return J(`div`,{class:w.attachmentElementAddActions,key:`attachment-element-add-actions-${t}`},o?J(`calcite-button`,{appearance:`outline`,disabled:n,iconStart:`attachment`,kind:`neutral`,round:!0,scale:`s`,onclick:()=>this._setAttachmentAddElementId(t)},this.messages.attachments.attach):null,this._renderAttachmentCaptureButton(e),s?this._renderAttachmentCaptureDisabledNotice(t):null,r?J(`div`,{class:w.attachmentElementEmptyActionHint},r):null,!this.effectiveDisabled&&i?J(`calcite-notice`,{closable:!1,icon:a===`danger`?`exclamation-mark-circle`:`lightbulb`,kind:a,open:!0,scale:`s`,width:`full`},J(`div`,{slot:`message`},i)):null)}_renderAttachmentCaptureButton(e){if(!e.hasCaptureInputs)return null;let t=e.captureMediaType;return J(`calcite-button`,{appearance:`outline`,disabled:!0,iconStart:ye(t),kind:`neutral`,round:!0,scale:`s`},this._getCaptureButtonLabel(t))}_getAttachmentNoticeMessage(e){let t=this.messages.attachments;return e.hasUnsupportedFileTypeValidationError?this._getUnsupportedFileTypeMessage():e.hasMinimumAttachmentCountNotMet&&this._shouldShowMinimumAttachmentNotice(e)?t.minimumNotMet:e.hasExceededAttachmentLimit?t.attachmentLimitExceeded:e.hasReachedAttachmentLimit?t.attachmentLimitReached:null}_shouldShowMinimumAttachmentNotice(e){return e.hasAttachmentChanges||this.viewModel.submitHasBeenAttempted||this._touchedInputs.has(e.template.elementId)}_getCaptureButtonLabel(e){let{capture:t,recordAudio:n,takePhoto:r,takeVideo:i}=this.messages.attachments;switch(e){case`image`:return r||t;case`video`:return i||t;case`audio`:return n||t;default:return t}}_renderAttachmentAddPage(){let e=this.viewModel.selectedAttachmentAddInput;return e?this._renderAttachmentAddPanel(e):null}_renderAttachmentAddPanel(e){let{maxAttachmentCount:t}=e,{elementId:n}=e.template;if(e.isCaptureOnly)return this._renderAttachmentCaptureDisabledNotice(n);let r=t==null||t-e.attachments.length>1,i=this.effectiveDisabled||e.addDisabled,a=this.messages.attachments,o=a.dragAndDropFile,s=e=>{this._attachmentFileInputMap.set(n,e)};return J(`div`,{class:w.attachmentElementAddPanel,key:`attachment-element-add-panel-${n}`},J(`input`,{accept:e.accept,afterCreate:s,afterRemoved:()=>{this._attachmentFileInputMap.delete(n)},afterUpdate:s,class:w.attachmentElementFileInput,"data-element-id":n,disabled:i,multiple:r,type:`file`,onchange:e=>{let t=e.currentTarget,r=t.files?Array.from(t.files):[];this._stageAttachmentFiles(n,r),t.value=``}}),J(`div`,{class:w.attachmentElementAddDropzone,"data-disabled":i?`true`:`false`,ondragover:e=>{e.stopPropagation(),e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`copy`)},ondrop:e=>{if(e.preventDefault(),e.stopPropagation(),i)return;let t=e.dataTransfer?.files?Array.from(e.dataTransfer.files):[];this._stageAttachmentFiles(n,t)}},J(`calcite-icon`,{class:w.attachmentElementAddDropzoneIcon,icon:`upload`,scale:`l`}),J(`div`,{class:w.attachmentElementAddDropzoneHeading},a.addFile),J(`div`,{class:w.attachmentElementAddDropzoneDetail,title:o},o),J(`calcite-button`,{appearance:`transparent`,disabled:i,iconStart:`folder-open`,kind:`brand`,scale:`s`,type:`button`,onclick:e=>{e.stopPropagation(),this._openAttachmentFilePicker(n,i)}},a.selectFile)),this._renderAttachmentValidationCriteria(e,{includeCountCriteria:!0}))}_renderAttachmentCaptureDisabledNotice(e){return J(`calcite-notice`,{class:w.attachmentElementCaptureNotice,icon:!0,key:`attachment-element-capture-disabled-notice-${e}`,kind:`warning`,open:!0,scale:`s`},J(`div`,{slot:`message`},this.messages.attachments.captureMethodNotSupported))}async _stageAttachmentFiles(e,t){if(t.length===0)return;let n=this.viewModel.selectedAttachmentAddInput,r=!0;try{r=(await this.viewModel.stageAddAttachments(e,t)).length>0&&!n?.hasInvalidValidationCriteria&&!n?.hasUnsupportedFileTypeValidationError}finally{r&&this.viewModel.setSelectedAttachmentAddElementId(null)}}_openAttachmentFilePicker(e,t){t||this._attachmentFileInputMap.get(e)?.click()}_renderAttachmentDetailPage(){let e=this.selectedAttachmentDetails;if(!e)return;if(this.page===`replacing-attachment`)return this._renderAttachmentReplacePanel(e);let{attachment:t,input:n}=e,r=v(t),i=!!n.getAttachmentPreviewUrl(t),a=!this._disableAttachmentModification(n)&&n.canUploadFiles,o=n.getAttachmentEditState(t);return J(`div`,{class:w.attachmentElementDetail,key:`attachment-detail-panel-${n.template.elementId}-${r}`},J(`div`,{class:w.attachmentElementDetailPreview},this._renderAttachmentPreviewImageForInput(t,n)),J(`div`,{class:w.attachmentElementDetailActions},y(t)?J(`calcite-button`,{appearance:`outline`,disabled:!i,iconStart:`expand`,kind:`neutral`,label:this.messages.attachments.maximize,scale:`m`,title:this.messages.attachments.maximize,onclick:this._maximizeSelectedAttachment}):null,J(`calcite-button`,{appearance:`outline`,disabled:!i||o.isReplaced,iconStart:`download`,kind:`neutral`,label:this.messages.attachments.download,scale:`m`,title:this.messages.attachments.download,onclick:()=>{this._downloadAttachment(t)}}),J(`calcite-button`,{appearance:`outline`,disabled:!a,iconStart:`upload-to`,kind:`neutral`,label:this.messages.attachments.replace,scale:`m`,title:this.messages.attachments.replace,onclick:this._enterAttachmentReplaceView})),J(`div`,{class:w.attachmentElementDetailMetadata},J(`div`,{class:w.attachmentElementDetailMetadataGroup},J(`span`,{class:w.attachmentElementDetailMetadataLabel},this.messages.attachments.fileName),this._renderFileNameContent(t,n)),J(`div`,{class:w.attachmentElementDetailMetadataGroup},J(`span`,{class:w.attachmentElementDetailMetadataLabel},this.messages.attachments.size),J(`span`,{class:w.attachmentElementDetailMetadataValue},this._formatAttachmentSize(t.size))),J(`div`,{class:w.attachmentElementDetailMetadataGroup},J(`span`,{class:w.attachmentElementDetailMetadataLabel},this.messages.attachments.type),J(`span`,{class:w.attachmentElementDetailMetadataValue},this._getLabelForAttachmentType(t)))))}_renderFileNameContent(e,t){if(!t.allowUserRename)return J(`span`,{class:w.attachmentElementDetailMetadataValue},e.name);let n=t.getAttachmentEditState(e),{baseName:r,extension:i}=b(e.name),a=this._disableAttachmentModification(t),o=!a&&e.name.trim().length===0;return[J(`div`,{class:w.attachmentElementDetailFileNameRow,key:`file-name-row`},J(`calcite-input`,{class:w.attachmentElementDetailFileNameInput,disabled:a,scale:`m`,status:o?`invalid`:`idle`,suffixText:i,value:r,onCalciteInputInput:({currentTarget:e})=>this._renameSelectedAttachment(e.value)}),J(`calcite-button`,{appearance:`transparent`,disabled:a||n.initialName==null||!n.isRenamed,iconStart:`reset`,kind:`neutral`,label:this.messages.footerButtons.reset,scale:`m`,title:this.messages.footerButtons.reset,onclick:this._resetSelectedAttachmentName})),o?J(`calcite-input-message`,{icon:!0,key:`file-name-message`,status:`invalid`},this.messages.validationErrors.cannotBeNull):null]}_renderAttachmentReplacePanel(e){let{attachment:t,input:n}=e,r=this._disableAttachmentModification(n)||!n.canUploadFiles,i=n.template.elementId;return J(`div`,{class:w.attachmentElementAddPanel,key:`attachment-replace-panel-${i}-${v(t)}`},J(`input`,{accept:n.accept,afterCreate:this._setSelectedAttachmentReplaceFileInput,afterRemoved:()=>{this._selectedAttachmentReplaceFileInput=null},afterUpdate:this._setSelectedAttachmentReplaceFileInput,class:w.attachmentElementFileInput,disabled:r,type:`file`,onchange:e=>{let t=e.currentTarget,n=t.files?.[0];n&&this._stageSelectedAttachmentReplacement(n),t.value=``}}),J(`div`,{class:w.attachmentElementAddDropzone,"data-disabled":r?`true`:`false`,ondragover:e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer&&(e.dataTransfer.dropEffect=`copy`)},ondrop:e=>{if(e.preventDefault(),e.stopPropagation(),r)return;let t=e.dataTransfer?.files?.[0];t&&this._stageSelectedAttachmentReplacement(t)}},J(`calcite-icon`,{class:w.attachmentElementAddDropzoneIcon,icon:`refresh`,scale:`l`}),J(`div`,{class:w.attachmentElementAddDropzoneHeading},this.messages.attachments.replace),J(`div`,{class:w.attachmentElementAddDropzoneDetail,title:this.messages.attachments.dragAndDropFile},this.messages.attachments.dragAndDropFile),J(`calcite-button`,{appearance:`transparent`,disabled:r,iconStart:`folder-open`,kind:`brand`,scale:`s`,onclick:e=>{e.stopPropagation(),this._openSelectedAttachmentReplaceFilePicker()}},this.messages.attachments.selectFile)),this._renderAttachmentValidationCriteria(n,{includeCountCriteria:!1}),J(`div`,{class:w.attachmentElementDetailMetadata},J(`div`,{class:w.attachmentElementDetailMetadataGroup},J(`span`,{class:w.attachmentElementDetailMetadataLabel},this.messages.attachments.fileToBeReplaced),J(`span`,{class:w.attachmentElementDetailMetadataValue},t.name))))}_renderAttachmentDialog(){let e=this._attachmentDialogInfo;if(!e)return null;let{attachment:t,input:n}=e;return J(`calcite-dialog`,{heading:t.name||this.messagesCommon.details,key:`attachment-preview-dialog`,modal:!0,open:!0,placement:`cover`,width:`l`,onCalciteDialogClose:this._closeAttachmentDialog},J(`div`,{class:w.attachmentElementDialogPreview},this._renderAttachmentPreviewImageForInput(t,n)))}_setSelectedAttachment(e,t){this._markInputTouched(t),this.viewModel.setSelectedAttachment(e),e||this.hideAttachmentDialog()}_setAttachmentAddElementId(e){let{viewModel:t}=this;t.setSelectedAttachmentAddElementId(e),this._markInputTouched(t.selectedAttachmentAddInput),t.selectedAttachmentAddInput?.clearValidationCriteriaState(),this.hideAttachmentDialog()}_setAttachmentListElementId(e){let{viewModel:t}=this;t.setSelectedAttachmentListElementId(e),this._markInputTouched(t.selectedAttachmentListInput),this.hideAttachmentDialog()}_getAttachmentLabel(e,n,r,i){return i!==!1&&g(e.name)&&e.name.length>0?e.name:r===this.messagesCommon.notApplicable?t(this.messages.attachments.attachmentNumberedLabel,{index:n+1}):r}_renderAttachmentCountLimitsLabel(e){let t=this.messages.attachments,n=e.minAttachmentCount!=null&&e.minAttachmentCount>0?this._renderAttachmentCountLimitLabel(t.minAttachmentsShort,e.minAttachmentCount,`min`):null,r=e.maxAttachmentCount==null?null:this._renderAttachmentCountLimitLabel(t.maxAttachmentsShort,e.maxAttachmentCount,`max`);return!n&&!r?null:[n,n&&r?J(`span`,{key:`attachment-count-limits-separator`},`, `):null,r]}_renderAttachmentCountLimitLabel(e,n,r){let i=`__count__`,[a,o]=t(e,{count:i}).split(i);return J(`span`,{key:r},a,J(`span`,{class:w.attachmentElementEmptyActionHintValue},n),o)}_renderAttachmentValidationCriteria(e,{includeCountCriteria:t}){let n=this._getAttachmentValidationCriteria(e,{includeCountCriteria:t}),r=`attachment-validation-criteria-${e.template.elementId}`;return n.length===0?null:J(`div`,{class:w.attachmentElementValidationCriteria,key:r},n.map(({key:e,message:t,state:n})=>J(`calcite-notice`,{appearance:n===`danger`?`outline-fill`:`transparent`,closable:!1,icon:!0,key:e,kind:n,open:!0,scale:`s`,width:`full`},J(`div`,{slot:`message`},t))))}_getAttachmentValidationCriteria(e,{includeCountCriteria:n}){let r=[],i=e.validationCriterionStates,a=this.messages.attachments,o=this._getNestableAttachmentInputs(e.input);e.hasUnsupportedFileTypeValidationError&&r.push({key:`unsupported-file-type`,message:this._getUnsupportedFileTypeMessage(),state:`danger`});for(let e of o)e.type===`document`&&e.maxFileSize!=null&&r.push({key:`maximum-file-size`,message:t(a.maximumFileSize,{maxSize:this._formatAttachmentSizeLimitInMegabytes(e.maxFileSize)}),state:i.get(`maximum-file-size`)??`info`}),e.type===`audio`&&e.maxDuration!=null&&r.push({key:`maximum-audio-length`,message:t(a.maximumAudioLength,{maxDuration:this._formatAttachmentDurationLimit(e.maxDuration)}),state:i.get(`maximum-audio-length`)??`info`}),e.type===`video`&&e.maxDuration!=null&&r.push({key:`maximum-video-length`,message:t(a.maximumVideoLength,{maxDuration:this._formatAttachmentDurationLimit(e.maxDuration)}),state:i.get(`maximum-video-length`)??`info`}),e.type===`image`&&e.maxImageSize!=null&&r.push({key:`maximum-image-size`,message:t(a.attachmentMustBeSmallerThan,{maxSize:`${e.maxImageSize}px`}),state:i.get(`maximum-image-size`)??`info`});return n&&e.minAttachmentCount!=null&&e.minAttachmentCount>0&&r.push({key:`minimum-number-of-files`,message:t(a.minimumNumberOfFiles,{count:e.minAttachmentCount}),state:i.get(`minimum-number-of-files`)??`info`}),n&&e.maxAttachmentCount!=null&&r.push({key:`maximum-number-of-files`,message:t(a.maximumNumberOfFiles,{count:e.maxAttachmentCount}),state:i.get(`maximum-number-of-files`)??`info`}),r}_getNestableAttachmentInputs(e){return e==null?[]:e.type===`attachment`?e.inputTypes?.slice()??[]:[e]}_getUnsupportedFileTypeMessage(){return this.featureTableMessages.errorFileUnsupported}_formatAttachmentSize(e){return e==null||Number.isNaN(e)?this.messagesCommon.notApplicable:d(this.messagesUnits,e)}_formatAttachmentSizeLimitInMegabytes(e){return d(this.messagesUnits,e*1048576)}_formatAttachmentDurationLimit(e){return m(Math.round(e)*1e3,{...e>=3600?{hour:`2-digit`,hourCycle:`h23`}:{},minute:`2-digit`,second:`2-digit`,timeZone:`UTC`})}_getLabelForAttachmentType({contentType:e}){if(!e)return this.messagesCommon.notApplicable;let t=this.messages.attachments.attachmentTypes,n=te(e);return t?.[n]||e}_renderAttachmentPreviewThumbnail(e,t,n){let r=n.getAttachmentPreviewUrl(e,64);return r&&y(e)?J(`img`,{alt:t,class:w.attachmentElementListItemThumb,src:r}):J(`calcite-icon`,{class:w.attachmentElementListItemIcon,icon:_(e.contentType),scale:`s`})}_renderAttachmentPreviewImageForInput(e,t){let n=t.getAttachmentPreviewUrl(e),r=e.name||this.messagesCommon.details;return n&&y(e)?J(`img`,{alt:r,class:w.attachmentElementDetailPreviewImage,src:n,title:r}):[J(`calcite-icon`,{class:w.attachmentElementDetailPreviewIcon,icon:_(e.contentType),scale:`l`,textLabel:r,title:r}),this.messages.attachments.noPreviewAvailable]}async _downloadAttachment(e){await V(e)}_canReplaceSelectedAttachment(){return!this.effectiveDisabled&&!!this.selectedAttachmentDetails?.input.canUploadFiles}_exitAttachmentReplaceView(){this.viewModel.setShowingSelectedAttachmentReplacePage(!1),this._selectedAttachmentReplaceFileInput=null}async _stageSelectedAttachmentReplacement(e){let t=this.selectedAttachmentDetails;if(!t?.attachment)return;let n=t.input.template.elementId,r=v(t.attachment),i=!1;try{i=await this.viewModel.stageReplaceAttachment(n,r,e)}finally{i&&this._exitAttachmentReplaceView()}}_renameSelectedAttachment(e){let t=this.selectedAttachmentDetails;if(!t?.attachment)return;let n=t.input.template.elementId,r=v(t.attachment);this.viewModel.stageRenameAttachment(n,r,e)}_resetSelectedAttachmentChanges(){let e=this.selectedAttachmentDetails;e?.attachment&&this.viewModel.resetAttachmentChanges(e.input.template.elementId,v(e.attachment))}_deleteSelectedAttachment(){let e=this.selectedAttachmentDetails;if(!e?.attachment||this._disableAttachmentModification(e.input))return;let t=e.input.template.elementId,n=v(e.attachment);this.viewModel.stageDeleteAttachment(t,n),this._setSelectedAttachment(null)}_disableAttachmentModification(e){return this.disabledOrReadOnly||!e.editable}hideAttachmentDialog(){this._attachmentDialogInfo=null}_renderTextComponent(e){let{elementId:t}=e.template;return J(`div`,{class:w.textElementInput,"data-testid":`text-element-${t}`,innerHTML:e.text,key:`text-element-${t}`})}_renderUtilityNetworkAssociationsElementInput(e){if(!this._associationsEnabled)return;let{elementId:t}=e.template;return J(`div`,{class:w.utilityNetworkAssociationsElementInput,"data-testid":t,key:t},this._associationsWidgetsMap.get(e)?.render())}getCommonInputProps(e){let{template:t,valid:n,value:r,minLength:i,maxLength:a,required:o,fieldName:s,editable:c,range:{max:l,min:u}}=e,d=!c||this.readOnly,f=this.disabled||this.viewModel.updating,p=this._getErrorToDisplay(e)?`invalid`:`idle`,m=t.hint??void 0,h=!1;return r===M&&(m=this.messages.differentValuesPlaceholder,h=!0),{afterCreate:this._afterComponentCreateOrUpdate,afterUpdate:this._afterComponentCreateOrUpdate,"aria-invalid":n?`false`:`true`,class:this.classes(w.fieldInput,d?w.inputDisabled:null),status:p,maxLength:a&&a>-1?a:void 0,minLength:i&&i>-1?i:void 0,key:t.elementId,label:s,name:s,max:l??void 0,min:u??void 0,disabled:f,readOnly:d,onblur:this._onComponentBlur,required:o,placeholder:m,value:h?``:r??``,[Z]:t.elementId,[Q]:s,onfocus:this._onComponentFocus}}_onObserverChange(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode);let e=this.viewModel.activeRelationshipInput;e&&this._listObserverNode&&e.showAllEnabled&&this._listObserver.observe(this._listObserverNode)}_onFormSubmit(e){e.preventDefault()}_handleDragAndDrop(e){e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`none`)}_getFieldInputFromHTMLElement(e){return this.viewModel.findFieldInput(e.getAttribute(Z))}_afterRadioGroupCreateOrUpdate(e){let t=e.selectedItem,n=e.querySelector(`calcite-radio-button`),r=t||n;r&&this._afterComponentCreateOrUpdate(r)}_onComponentFocus(e){let t=e.target,n=this._getFieldInputFromHTMLElement(t);this._focusedFieldInput=n}_markInputTouched(e){e&&this._touchedInputs.add(e.template.elementId)}_isMultipleChoiceCheckbox(e,t){let n=this._getMultipleChoiceController(t);return e.tagName===`CALCITE-CHECKBOX`&&n?.input!=null}_afterComponentCreateOrUpdate(e){let t=this._getFieldInputFromHTMLElement(e),n=this._focusedFieldInput;this._attemptFocusOnNextRender&&n===t&&(this._attemptFocusOnNextRender=!1,ve(e))}_onComponentBlur(e){let t=e.target,n=this._getFieldInputFromHTMLElement(t);this._isMultipleChoiceCheckbox(t,n)||this._markInputTouched(n),this._focusedFieldInput=null}_onDynamicChoiceBlur(e,t){let n=e.currentTarget;if(this._dynamicChoiceItemSelections.delete(t))return;let r=e.relatedTarget;r instanceof Node&&n.contains(r)||(t.endInteraction(),n.inputValue=t.fieldInput.value===M?this.messages.differentValuesPlaceholder:t.inputValue,this._onComponentBlur(e))}_resetTransientFormState(){this._attemptFocusOnNextRender=!1,this._focusedFieldInput=null,this._attachmentDialogInfo=null,this._selectedAttachmentReplaceFileInput=null,this._attachmentListFilterText=``,this._attachmentFileInputMap.clear()}_parseValue(e,t,n=!1){let r=this._getMultipleChoiceController(t);if(r){let{input:t,values:i}=r;if(t&&i){let t=e;return r.getValueFromCheckboxChange({choiceValue:t.value,isChecked:t.checked,isSelectAllCheckbox:n})}}if(S(t.template,`switch`)){if(e.localName===`calcite-dropdown`&&t.domain){for(let n of t.domain.codedValues)if(n.name===e.selectedItems[0].textContent)return n.code}return e.checked?t.template.input.onValue:t.template.input.offValue}let i=e.value;return i==null||i===``?null:t.dataType===`number`?i===`-0`||i===`-0.`||i===`-0,`?i:parseFloat(i):t.field.type===`date`?parseFloat(i):i}_getMultipleChoiceController(e){return k(e.inputController)?e.inputController:null}_saveInputFromElement(e){let t=this._getFieldInputFromHTMLElement(e);if(!t)return;let n=this._parseValue(e,t);this._saveInput(t,n)}_saveInput(e,t){let{elementId:n}=e.template,r=e?.value,{viewModel:a}=this;if(S(e.template,`switch`)&&a.mode!==`single`){let t=i(this._batchSwitchInputInitialValues,e,()=>e.value);this._batchSwitchInputInitialValues.set(e,t===null?r:t)}t!==r&&(this._markInputTouched(e),!e.isSubtypeField||a.mode===`batch`||!re(a.activeLayer,r,t)?a.setValue(n,t):this._pendingSubtypeChoice||=this._handleSubtypeChoice(e,t))}async _handleSubtypeChoice(e,n){let{value:r,template:i}=e,{elementId:a}=i,{messages:o,viewModel:s,messagesCommon:c}=this,{subtypes:l,activeFeatureIndex:u}=s;if(await s.setValue(a,n),!l?.length)return;let d=l.find(e=>e.code===n),f=l.find(e=>e.code===r)?.name??`${r}`;if(!d)return;let p=Promise.withResolvers();s.pendingSubtypeChoice=p;let m=`update-fields`,h=[{label:o.subtypes.useDefaultValuesOption,value:`update-fields`},{label:o.subtypes.keepCurrentValuesOption,value:`keep-existing`}],g={context:`info`,title:o.subtypes.changeWarningTitle,message:t(o.subtypes.changeWarning,{originalType:f,newType:d.name}),radios:h,defaultRadioSelection:`update-fields`,onRadioSelection:e=>{m=e},actions:{primary:{label:c.apply,action:()=>p.resolve(m),type:`positive`},secondary:{label:c.cancel,type:`neutral`,action:()=>p.resolve(`undo`)}},cancel:()=>p.reject()};try{switch(this.showPrompt(g),await p.promise){case`update-fields`:await s.applySubtypeDefaults(d),await s.handleSubtypeChanged(u);break;case`keep-existing`:await s.handleSubtypeChanged(u);break;case`undo`:await this.viewModel.setValue(a,r)}}finally{s.pendingSubtypeChoice=null,this.clearPrompt(),this._pendingSubtypeChoice=null}}_afterDateComponentCreateOrUpdate(e){this._setDateTimeTimeZoneMap(e),this._afterComponentCreateOrUpdate(e)}_saveValueFromDateComponent(e,t){let{elementId:n}=e.template,r=e.field.type,i=this._dateComponentMap.get(`${n}`);if(!i)return;let a=e.effectiveTimeZone,o=e.value===M?void 0:e.value,s=null;r===`date-only`?s=Array.isArray(t.value)?t.value[0]:t.value:r===`time-only`?(o=G(o),s=G(t.value)):s=r===`timestamp-offset`?t.value==null?null:pe({dateComponent:i.date,timeComponent:i.time,oldValue:o,timeZoneComponent:i.timeZone,defaultTimeZone:a}):t.value==null?null:me({oldValue:o,dateComponent:i.date,timeZone:a,timeComponent:i.time?.value===M?void 0:i.time}),o!==s&&(this._markInputTouched(e),s===null||!t.value?this.viewModel.setValue(n,null):this.viewModel.setValue(n,s))}_getErrorToDisplay(e){let t=e.compositeError;return e.valid||!t?null:t===X.CONTINGENCY_VIOLATION_ERROR||t===X.CONTINGENCY_VIOLATION_WARNING?t:!this._touchedInputs.has(e.template.elementId)&&!this.viewModel.submitHasBeenAttempted?null:t}_renderViewingAssociationsPage(){return this._associationsList?.render()}_onActiveAssociationsInputChange(e){let t=this._associationsList;t&&(e?(t.associationInput=e,t.viewModel=e.viewModel):t.associationInput=null)}async _setUpAssociationsWidgets(){let e=this.viewModel.activeForm.allUtilityNetworkAssociationsElementInputs;if(this._associationsEnabled&&e.length!==0){await this._setUpUtilityNetworkAssociationList();for(let t of e)this._associationsWidgetsMap.set(t,await this._createAssociationsWidget(t))}}async _setUpUtilityNetworkAssociationList(){if(this._associationsList)return;let e=(await import(`./FeatureForm/FeatureFormUtilityNetworkAssociations/FeatureFormUtilityNetworkAssociationList.js`)).default;this._associationsList=new e({onSelectLayer:this._onSelectAssociatedLayer.bind(this),onSelectFeature:this._onEditAssociatedFeature.bind(this),onAddAssociation:this._onAddAssociation.bind(this)});let t=this.viewModel.activeAssociationsInput;t&&(this._associationsList.associationInput=t,this._associationsList.viewModel=t.viewModel)}async _createAssociationsWidget(e){let t=(await import(`./Feature/FeatureUtilityNetworkAssociations.js`)).default;return new t({viewModel:e.viewModel,onSelectAssociationType:t=>this._onSelectAssociationType(e,t)})}_destroyAssociationsWidgets(){this._associationsWidgetsMap.forEach(e=>a(e)),this._associationsWidgetsMap.clear()}_onSelectAssociationType(e,{listType:t}){this.setActiveAssociationsInput(e),this.setActiveAssociationType(t)}_onSelectAssociatedLayer({layer:e}){this.setActiveAssociationsLayer(e)}async _onEditAssociatedFeature(e){let t=this.callbacks?.editAssociatedFeature,n=this.viewModel.activeAssociationsInput;if(!t||!n?.feature)return;let{association:r,feature:i}=e;await t({parentFeature:n.feature.plainGraphic,association:r,feature:i})}_onAddAssociation(e){let t=this.callbacks?.addAssociation,n=this.viewModel.activeAssociationsInput;if(!t||!n?.feature)return;let{associationType:r,utilityNetwork:i}=e;t({feature:n.feature.plainGraphic,associationType:r,utilityNetwork:i})}_setFocusableInput(e){let t=e&&j(e)?e:this._findFocusableInput(e);this._focusedFieldInput=t,this._attemptFocusOnNextRender=!0}_findFocusableInput(e){let t=this.viewModel.activeForm.inputs;if(!t.length)return;let n=ie(t),r;if(!e)r=0;else if(A(e)){let t=e.inputs.find(e=>e.visible);r=t?n.indexOf(t):0}else{let i;i=P(e)&&!e.group.open?e.group.inputs.filter(j)[t.length-1]:e,r=n.indexOf(i)+1}for(let e=r;e<n.length;e++){let t=n[e],r=P(t)&&!t.group.open;if(t.visible&&j(t)&&!r){if(this.disabledOrReadOnly&&(t?.inputType===`switch`||t?.inputType===`radio-buttons`))continue;return t}}return null}_onGroupExpand(e){e.open=!0,this.groupDisplay===`sequential`&&this.viewModel.activeForm.allGroupInputs.forEach(t=>{t!==e&&(t.open=!1)}),this._focusedFieldInput?.group!==e&&this._setFocusableInput(e)}_syncGroupInputInitialStates(){if(this.groupDisplay!==`sequential`)return;let e=this.viewModel.activeForm?.allGroupInputs;if(!e.length)return;let t=e.filter(e=>e.open);t.length===0?e[0].open=!0:t.length>1&&t.slice(1).forEach(e=>e.open=!1)}};e([f()],$.prototype,`activeFeatureIndex`,null),e([f()],$.prototype,`attachmentsEnabled`,null),e([f()],$.prototype,`callbacks`,null),e([f()],$.prototype,`disabled`,null),e([f()],$.prototype,`effectiveTitle`,null),e([f()],$.prototype,`effectiveDisabled`,null),e([f()],$.prototype,`disabledOrReadOnly`,null),e([f()],$.prototype,`features`,null),e([f()],$.prototype,`footerButtonInfos`,null),e([f()],$.prototype,`map`,null),e([f()],$.prototype,`maximumFeatureCount`,null),e([f()],$.prototype,`maximumFeatureCountWithComplexForms`,null),e([f()],$.prototype,`spatialReference`,null),e([f()],$.prototype,`layerInfos`,null),e([f()],$.prototype,`timeZone`,null),e([f()],$.prototype,`headingLevel`,void 0),e([f()],$.prototype,`icon`,null),e([f(),q(`esri/t9n/common`)],$.prototype,`messagesCommon`,void 0),e([f(),q(`esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm`)],$.prototype,`messages`,void 0),e([f(),q(`esri/widgets/FeatureForm/t9n/FeatureForm`)],$.prototype,`featureFormMessages`,void 0),e([f(),q(`esri/widgets/FeatureTable/t9n/FeatureTable`)],$.prototype,`featureTableMessages`,void 0),e([f(),q(`esri/core/t9n/Units`)],$.prototype,`messagesUnits`,void 0),e([f()],$.prototype,`page`,null),e([f()],$.prototype,`readOnly`,null),e([f()],$.prototype,`showPrompt`,null),e([f()],$.prototype,`clearPrompt`,null),e([f()],$.prototype,`selectedAttachment`,null),e([f()],$.prototype,`selectedAttachmentDetails`,null),e([f()],$.prototype,`valid`,null),e([f({type:C}),_e([`attachments-change`,`value-change`,`values-change`,`submit`])],$.prototype,`viewModel`,void 0),e([f({type:D,nonNullable:!0})],$.prototype,`visibleElements`,void 0),e([f()],$.prototype,`groupDisplay`,void 0),e([f()],$.prototype,`_formHeaderVisible`,null),e([f()],$.prototype,`_associationsEnabled`,null),e([f()],$.prototype,`_associationsList`,void 0),e([f()],$.prototype,`_attemptFocusOnNextRender`,void 0),e([f()],$.prototype,`_formId`,null),e([f()],$.prototype,`_focusedFieldInput`,void 0),e([f()],$.prototype,`_pendingSubtypeChoice`,void 0),e([f()],$.prototype,`_relatedRecordsEnabled`,null),e([f()],$.prototype,`_listObserverNode`,void 0),e([f()],$.prototype,`_attachmentDialogInfo`,void 0),e([f()],$.prototype,`_attachmentListFilterText`,void 0),e([f()],$.prototype,`_prompt`,void 0),e([f()],$.prototype,`test`,null),$=e([p(`esri.widgets.BatchAttributeForm`)],$);function ye(e){switch(e){case`audio`:return _(`audio/mpeg`);case`video`:return _(`video/mp4`);case`image`:return _(`image/png`);default:return`camera`}}const be=$;export{be as default};