@arcgis/core 4.23.1 → 4.23.2

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/config.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- import"./core/has.js";import{deepMerge as e}from"./core/object.js";var r;const s={apiKey:void 0,applicationUrl:null==(r=globalThis.location)?void 0:r.href,assetsPath:"",fontsUrl:"https://static.arcgis.com/fonts",geometryServiceUrl:"https://utility.arcgisonline.com/arcgis/rest/services/Geometry/GeometryServer",geoRSSServiceUrl:"https://utility.arcgis.com/sharing/rss",kmlServiceUrl:"https://utility.arcgis.com/sharing/kml",portalUrl:"https://www.arcgis.com",routeServiceUrl:"https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World",workers:{loaderConfig:{has:{},paths:{},map:{},packages:[]}},request:{httpsDomains:["arcgis.com","arcgisonline.com","esrikr.com","premiumservices.blackbridge.com","esripremium.accuweather.com","gbm.digitalglobe.com","firstlook.digitalglobe.com","msi.digitalglobe.com"],interceptors:[],maxUrlLength:2e3,proxyRules:[],proxyUrl:null,timeout:6e4,trustedServers:[],useIdentity:!0},log:{interceptors:[],level:null}};if(globalThis.esriConfig&&(e(s,globalThis.esriConfig,!0),delete s.has),!s.assetsPath){const e="4.23.1";s.assetsPath=`https://js.arcgis.com/${e.slice(0,-2)}/@arcgis/core/assets`}s.baseUrl&&console.warn("[esri.config]","baseUrl has been replaced by assetsPath"),Object.defineProperty(s,"baseUrl",{set(){console.warn("[esri.config]","baseUrl has been replaced by assetsPath")}}),s.request.corsEnabledServers=[],s.request.corsEnabledServers.push=function(){return console.warn("[esri.config]","request.corsEnabledServers is not supported and will be removed in a future release. See http://esriurl.com/cors8664"),0};export{s as default};
5
+ import"./core/has.js";import{deepMerge as e}from"./core/object.js";var r;const s={apiKey:void 0,applicationUrl:null==(r=globalThis.location)?void 0:r.href,assetsPath:"",fontsUrl:"https://static.arcgis.com/fonts",geometryServiceUrl:"https://utility.arcgisonline.com/arcgis/rest/services/Geometry/GeometryServer",geoRSSServiceUrl:"https://utility.arcgis.com/sharing/rss",kmlServiceUrl:"https://utility.arcgis.com/sharing/kml",portalUrl:"https://www.arcgis.com",routeServiceUrl:"https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World",workers:{loaderConfig:{has:{},paths:{},map:{},packages:[]}},request:{httpsDomains:["arcgis.com","arcgisonline.com","esrikr.com","premiumservices.blackbridge.com","esripremium.accuweather.com","gbm.digitalglobe.com","firstlook.digitalglobe.com","msi.digitalglobe.com"],interceptors:[],maxUrlLength:2e3,proxyRules:[],proxyUrl:null,timeout:6e4,trustedServers:[],useIdentity:!0},log:{interceptors:[],level:null}};if(globalThis.esriConfig&&(e(s,globalThis.esriConfig,!0),delete s.has),!s.assetsPath){const e="4.23.2";s.assetsPath=`https://js.arcgis.com/${e.slice(0,-2)}/@arcgis/core/assets`}s.baseUrl&&console.warn("[esri.config]","baseUrl has been replaced by assetsPath"),Object.defineProperty(s,"baseUrl",{set(){console.warn("[esri.config]","baseUrl has been replaced by assetsPath")}}),s.request.corsEnabledServers=[],s.request.corsEnabledServers.push=function(){return console.warn("[esri.config]","request.corsEnabledServers is not supported and will be removed in a future release. See http://esriurl.com/cors8664"),0};export{s as default};
package/interfaces.d.ts CHANGED
@@ -28231,7 +28231,7 @@ declare namespace __esri {
28231
28231
  /**
28232
28232
  * A helper function that returns an instance of the portal's [ClosestFacilityTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-ClosestFacilityTask.html) [helper service](https://enterprise.arcgis.com/en/portal/latest/administer/windows/about-utility-services.htm).
28233
28233
  *
28234
- * @deprecated since version 4.21.
28234
+ * @deprecated since version 4.21. Use {@link module:esri/rest/closestFacility} with [helperServices](#helperServices) instead.
28235
28235
  *
28236
28236
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#createClosestFacilityTask)
28237
28237
  */
@@ -28245,7 +28245,7 @@ declare namespace __esri {
28245
28245
  /**
28246
28246
  * A helper function that returns an instance of the portal's [GeometryService](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-GeometryService.html) [helper service](https://enterprise.arcgis.com/en/portal/latest/administer/windows/about-utility-services.htm).
28247
28247
  *
28248
- * @deprecated since version 4.21.
28248
+ * @deprecated since version 4.21. Use {@link module:esri/rest/geometryService} with [helperServices](#helperServices) instead.
28249
28249
  *
28250
28250
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#createGeometryService)
28251
28251
  */
@@ -28253,7 +28253,7 @@ declare namespace __esri {
28253
28253
  /**
28254
28254
  * A helper function that returns an instance of the portal's [PrintTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-PrintTask.html) [helper service](https://enterprise.arcgis.com/en/portal/latest/administer/windows/about-utility-services.htm).
28255
28255
  *
28256
- * @deprecated since version 4.21.
28256
+ * @deprecated since version 4.21. Use {@link module:esri/rest/print} with [helperServices](#helperServices) instead.
28257
28257
  *
28258
28258
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#createPrintTask)
28259
28259
  */
@@ -28261,7 +28261,7 @@ declare namespace __esri {
28261
28261
  /**
28262
28262
  * A helper function that returns an instance of the portal's [RouteTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-RouteTask.html) [helper service](https://enterprise.arcgis.com/en/portal/latest/administer/windows/about-utility-services.htm).
28263
28263
  *
28264
- * @deprecated since version 4.21.
28264
+ * @deprecated since version 4.21. Use {@link module:esri/rest/route} with [helperServices](#helperServices) instead.
28265
28265
  *
28266
28266
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#createRouteTask)
28267
28267
  */
@@ -28269,7 +28269,7 @@ declare namespace __esri {
28269
28269
  /**
28270
28270
  * A helper function that returns an instance of the portal's [ServiceAreaTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-ServiceAreaTask.html) [helper service](https://enterprise.arcgis.com/en/portal/latest/administer/windows/about-utility-services.htm).
28271
28271
  *
28272
- * @deprecated since version 4.21.
28272
+ * @deprecated since version 4.21. Use {@link module:esri/rest/serviceArea} with [helperServices](#helperServices) instead.
28273
28273
  *
28274
28274
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#createServiceAreaTask)
28275
28275
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/core",
3
- "version": "4.23.1",
3
+ "version": "4.23.2",
4
4
  "homepage": "https://js.arcgis.com",
5
5
  "description": "ArcGIS API for JavaScript: A complete 2D and 3D mapping and data visualization API",
6
6
  "keywords": [
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- const c="20220324",e="9cf26ea170966c3de028527befb4b12c79e5cd94";export{c as buildDate,e as commitHash};
5
+ const c="20220325",d="bd365f30c3ec9889ec50c6d6f51a1c6ac3877d35";export{c as buildDate,d as commitHash};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- import{bidiText as t}from"../../core/BidiText.js";import e from"../../core/Logger.js";import{isNone as s,isSome as i}from"../../core/maybe.js";import r from"../../core/ObjectPool.js";import{pt2px as n}from"../../core/screenUtils.js";import{create as o,fromValues as a}from"../../geometry/support/aaBoundingRect.js";import{getBoundsXY as h}from"../../geometry/support/boundsUtils.js";import{isPoint as l,isPolygon as c,isPolyline as m,isExtent as f,isMultipoint as u}from"../../geometry/support/jsonUtils.js";import{SimpleGeometryCursor as _}from"./CIMEffects.js";import{getEffectOperator as d,getPlacementOperator as p}from"./CIMOperators.js";import{Placement as y}from"./CIMPlacements.js";import g from"./CIMResourceManager.js";import{LineCapStyle as x,LineJoinStyle as P}from"./enums.js";import w from"./Rect.js";import{TextRasterizer as M}from"./TextRasterizer.js";import{HAlign as b,VAlign as S}from"../../views/2d/engine/webgl/alignmentUtils.js";import{GLYPH_SIZE as k,MAGIC_LABEL_LINE_HEIGHT as C}from"../../views/2d/engine/webgl/definitions.js";import{shapeGlyphs as R}from"../../views/2d/engine/webgl/mesh/templates/shapingUtils.js";const T=Math.PI/180,I=10,v=e.getLogger("esri.symbols.cim.CIMSymbolDrawHelper");class L{constructor(t){this._t=t}static createIdentity(){return new L([1,0,0,0,1,0])}clone(){const t=this._t;return new L(t.slice())}transform(t){const e=this._t;return[e[0]*t[0]+e[1]*t[1]+e[2],e[3]*t[0]+e[4]*t[1]+e[5]]}static createScale(t,e){return new L([t,0,0,0,e,0])}scale(t,e){const s=this._t;return s[0]*=t,s[1]*=t,s[2]*=t,s[3]*=e,s[4]*=e,s[5]*=e,this}scaleRatio(){return Math.sqrt(this._t[0]*this._t[0]+this._t[1]*this._t[1])}static createTranslate(t,e){return new L([0,0,t,0,0,e])}translate(t,e){const s=this._t;return s[2]+=t,s[5]+=e,this}static createRotate(t){const e=Math.cos(t),s=Math.sin(t);return new L([e,-s,0,s,e,0])}rotate(t){return L.multiply(this,L.createRotate(t),this)}static multiply(t,e,s){const i=t._t,r=e._t,n=i[0]*r[0]+i[3]*r[1],o=i[1]*r[0]+i[4]*r[1],a=i[2]*r[0]+i[5]*r[1]+r[2],h=i[0]*r[3]+i[3]*r[4],l=i[1]*r[3]+i[4]*r[4],c=i[2]*r[3]+i[5]*r[4]+r[5],m=s._t;return m[0]=n,m[1]=o,m[2]=a,m[3]=h,m[4]=l,m[5]=c,s}invert(){const t=this._t;let e=t[0]*t[4]-t[1]*t[3];if(0===e)return new L([0,0,0,0,0,0]);e=1/e;const s=(t[1]*t[5]-t[2]*t[4])*e,i=(t[2]*t[3]-t[0]*t[5])*e,r=t[4]*e,n=-t[1]*e,o=-t[3]*e,a=t[0]*e;return new L([r,n,s,o,a,i])}}class z{constructor(t,e){this._transfos=[],this._sizeTransfos=[],this._geomUnitsPerPoint=1,this._placementPool=new r(y,null,null,100),this._earlyReturn=!1,this._mapRotation=0,this._resourceManager=t||new g,this._transfos.push(e||L.createIdentity()),this._sizeTransfos.push(e?e.scaleRatio():1)}setTransform(t,e){this._transfos=[t||L.createIdentity()],this._sizeTransfos=[e||(t?t.scaleRatio():1)]}setGeomUnitsPerPoint(t){this._geomUnitsPerPoint=t}transformPt(t){return this._transfos[this._transfos.length-1].transform(t)}transformSize(t){return t*this._sizeTransfos[this._sizeTransfos.length-1]}reverseTransformPt(t){return this._transfos[this._transfos.length-1].invert().transform(t)}reverseTransformSize(t){return t/this._sizeTransfos[this._sizeTransfos.length-1]}geomUnitsPerPoint(){return this.isEmbedded()?1:this._geomUnitsPerPoint}isEmbedded(){return this._transfos.length>1}back(){return this._transfos[this._transfos.length-1]}push(t,e){const s=e?t.scaleRatio():1;L.multiply(t,this.back(),t),this._transfos.push(t),this._sizeTransfos.push(this._sizeTransfos[this._sizeTransfos.length-1]*s)}pop(){this._transfos.splice(-1,1),this._sizeTransfos.splice(-1,1)}drawSymbol(t,e){if(t)switch(t.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":this.drawMultiLayerSymbol(t,e);break;case"CIMTextSymbol":this.drawTextSymbol(t,e)}}drawMultiLayerSymbol(t,e){if(!t)return;const s=t.symbolLayers;if(!s)return;const i=t.effects;if(i&&i.length>0){const t=this.executeEffects(i,e);if(t){let e=t.next();for(;e;)this.drawSymbolLayers(s,e),e=t.next()}}else this.drawSymbolLayers(s,e)}executeEffects(t,e){const s=this._resourceManager.geometryEngine;let i=new _(e);for(const r of t){const t=d(r);t&&(i=t.execute(i,r,this.geomUnitsPerPoint(),s))}return i}drawSymbolLayers(t,e){let s=t.length;for(;s--;){const i=t[s];if(!i||!1===i.enable)continue;const r=i.effects;if(r&&r.length>0){const t=this.executeEffects(r,e);if(t){let e=null;for(;(e=t.next())&&(this.drawSymbolLayer(i,e),!this._earlyReturn););}}else this.drawSymbolLayer(i,e);if(this._earlyReturn)return}}drawSymbolLayer(t,e){switch(t.type){case"CIMSolidFill":this.drawSolidFill(e,t.color);break;case"CIMHatchFill":this.drawHatchFill(e,t);break;case"CIMPictureFill":this.drawPictureFill(e,t);break;case"CIMGradientFill":this.drawGradientFill(e,t);break;case"CIMSolidStroke":this.drawSolidStroke(e,t.color,t.width,t.capStyle,t.joinStyle,t.miterLimit);break;case"CIMPictureStroke":this.drawPictureStroke(e,t);break;case"CIMGradientStroke":this.drawGradientStroke(e,t);break;case"CIMCharacterMarker":case"CIMPictureMarker":case"CIMVectorMarker":this.drawMarkerLayer(t,e)}}drawHatchFill(t,e){const s=this._buildHatchPolyline(e,t,this.geomUnitsPerPoint());s&&(this.pushClipPath(t),this.drawMultiLayerSymbol(e.lineSymbol,s),this.popClipPath())}drawPictureFill(t,e){}drawGradientFill(t,e){}drawPictureStroke(t,e){}drawGradientStroke(t,e){}drawMarkerLayer(t,e){const s=t.markerPlacement;if(s){const i=p(s);if(i){const r="CIMMarkerPlacementInsidePolygon"===s.type;r&&this.pushClipPath(e);const n=i.execute(e,s,this.geomUnitsPerPoint(),this._resourceManager.geometryEngine);if(n){let e=null;for(;(e=n.next())&&(this.drawMarker(t,e),!this._earlyReturn););}r&&this.popClipPath()}}else{const s=this._placementPool.acquire();if(l(e))s.tx=e.x,s.ty=e.y,this.drawMarker(t,s);else for(const i of e.points)if(s.tx=i[0],s.ty=i[1],this.drawMarker(t,s),this._earlyReturn)break;this._placementPool.release(s)}}drawMarker(t,e){switch(t.type){case"CIMCharacterMarker":case"CIMPictureMarker":this.drawPictureMarker(t,e);break;case"CIMVectorMarker":this.drawVectorMarker(t,e)}}drawPictureMarker(t,e){var i,r,n,o,a;if(!t)return;const h=this._resourceManager.getResource(t.url),l=null!=(i=t.size)?i:10;if(s(h)||l<=0)return;const c=h.width,m=h.height;if(!c||!m)return;const f=c/m,u=null!=(r=t.scaleX)?r:1,_=L.createIdentity(),d=t.anchorPoint;if(d){let e=d.x,s=d.y;"Absolute"!==t.anchorPointUnits&&(e*=l*f*u,s*=l),_.translate(-e,-s)}let p=null!=(n=t.rotation)?n:0;t.rotateClockwise&&(p=-p),this._mapRotation&&(p+=this._mapRotation),p&&_.rotate(p*T);let y=null!=(o=t.offsetX)?o:0,g=null!=(a=t.offsetY)?a:0;if(y||g){if(this._mapRotation){const t=T*this._mapRotation,e=Math.cos(t),s=Math.sin(t),i=y*s+g*e;y=y*e-g*s,g=i}_.translate(y,g)}const x=this.geomUnitsPerPoint();1!==x&&_.scale(x,x);const P=e.getAngle();P&&_.rotate(P),_.translate(e.tx,e.ty),this.push(_,!1),this.drawImage(t.url,l,t.scaleX),this.pop()}drawVectorMarker(t,e){var s,i,r,n;if(!t)return;const o=t.markerGraphics;if(!o)return;const a=null!=(s=t.size)?s:10,h=t.frame,l=h?h.ymax-h.ymin:0,c=a&&l?a/l:1,m=L.createIdentity();h&&m.translate(.5*-(h.xmax+h.xmin),.5*-(h.ymax+h.ymin));const f=t.anchorPoint;if(f){let e=f.x,s=f.y;"Absolute"!==t.anchorPointUnits?h&&(e*=h.xmax-h.xmin,s*=h.ymax-h.ymin):(e/=c,s/=c),m.translate(-e,-s)}1!==c&&m.scale(c,c);let u=null!=(i=t.rotation)?i:0;t.rotateClockwise&&(u=-u),this._mapRotation&&(u+=this._mapRotation),u&&m.rotate(u*T);let _=null!=(r=t.offsetX)?r:0,d=null!=(n=t.offsetY)?n:0;if(_||d){if(this._mapRotation){const t=T*this._mapRotation,e=Math.cos(t),s=Math.sin(t),i=_*s+d*e;_=_*e-d*s,d=i}m.translate(_,d)}const p=this.geomUnitsPerPoint();1!==p&&m.scale(p,p);const y=e.getAngle();y&&m.rotate(y),m.translate(e.tx,e.ty),this.push(m,t.scaleSymbolsProportionally);for(const g of o)if(g&&g.symbol&&g.geometry||v.error("Invalid marker graphic",g),this.drawSymbol(g.symbol,g.geometry),this._earlyReturn)break;this.pop()}drawTextSymbol(t,e){var s,i,r,n;if(!t)return;if(!l(e))return;if((null!=(s=t.height)?s:10)<=0)return;const o=L.createIdentity();let a=null!=(i=t.angle)?i:0;a=-a,a&&o.rotate(a*T);const h=null!=(r=t.offsetX)?r:0,c=null!=(n=t.offsetY)?n:0;(h||c)&&o.translate(h,c);const m=this.geomUnitsPerPoint();1!==m&&o.scale(m,m),o.translate(e.x,e.y),this.push(o,!1),this.drawText(t),this.pop()}_buildHatchPolyline(t,e,s){let i=(void 0!==t.separation?t.separation:4)*s,r=void 0!==t.rotation?t.rotation:0;if(0===i)return null;i<0&&(i=-i);let n=0;const a=.5*i;for(;n>a;)n-=i;for(;n<-a;)n+=i;const l=o();h(l,e),l[0]-=a,l[1]-=a,l[2]+=a,l[3]+=a;const c=[[l[0],l[1]],[l[0],l[3]],[l[2],l[3]],[l[2],l[1]]];for(;r>180;)r-=180;for(;r<0;)r+=180;const m=Math.cos(r*T),f=Math.sin(r*T),u=-i*f,_=i*m;let d,p,y,g;n=(void 0!==t.offsetX?t.offsetX*s:0)*f-(void 0!==t.offsetY?t.offsetY*s:0)*m,d=y=Number.MAX_VALUE,p=g=-Number.MAX_VALUE;for(const o of c){const t=o[0],e=o[1],s=m*t+f*e,i=-f*t+m*e;d=Math.min(d,s),y=Math.min(y,i),p=Math.max(p,s),g=Math.max(g,i)}y=Math.floor(y/i)*i;let x=m*d-f*y-u*n/i,P=f*d+m*y-_*n/i,w=m*p-f*y-u*n/i,M=f*p+m*y-_*n/i;const b=1+Math.round((g-y)/i),S=[];for(let o=0;o<b;o++)x+=u,P+=_,w+=u,M+=_,S.push([[x,P],[w,M]]);return{paths:S}}}class U extends z{constructor(t,e){super(t,e),this.reset()}reset(){this._xmin=this._ymin=1/0,this._xmax=this._ymax=-1/0,this._clipCount=0}envelope(){return new w(this._xmin,this._ymin,this._xmax-this._xmin,this._ymax-this._ymin)}bounds(){return a(this._xmin,this._ymin,this._xmax,this._ymax)}drawSolidFill(t){if(t&&!(this._clipCount>0))if(c(t))this._processPath(t.rings,0);else if(m(t))this._processPath(t.paths,0);else if(f(t)){const e=A(t);e&&this._processPath(e.rings,0)}else console.error("drawSolidFill Unexpected geometry type!")}drawSolidStroke(t,e,s){if(!t||this._clipCount>0)return;const i=.5*this.transformSize(s);if(c(t))this._processPath(t.rings,i);else if(m(t))this._processPath(t.paths,i);else if(f(t)){const e=A(t);e&&this._processPath(e.rings,i)}else console.error("drawSolidStroke unexpected geometry type!")}pushClipPath(t){this.drawSolidFill(t),++this._clipCount}popClipPath(){--this._clipCount}drawImage(t,e,s){let r=s*e,n=e;const o=this._resourceManager.getResource(t);!e&&i(o)&&(r=s*o.width,n=o.height),this._merge(this.transformPt([-r/2,-n/2]),0),this._merge(this.transformPt([-r/2,n/2]),0),this._merge(this.transformPt([r/2,-n/2]),0),this._merge(this.transformPt([r/2,n/2]),0)}drawText(t){this._textRasterizer||(this._textRasterizer=new M)}_processPath(t,e){if(t)for(const s of t){const t=s?s.length:0;if(t>1){this._merge(this.transformPt(s[0]),e);for(let i=1;i<t;++i)this._merge(this.transformPt(s[i]),e)}}}_merge(t,e){t[0]-e<this._xmin&&(this._xmin=t[0]-e),t[0]+e>this._xmax&&(this._xmax=t[0]+e),t[1]-e<this._ymin&&(this._ymin=t[1]-e),t[1]+e>this._ymax&&(this._ymax=t[1]+e)}}class F extends z{constructor(){super(...arguments),this._searchPoint=[0,0],this._searchDistPoint=0}hitTest(t,e,s,i,r,o){const a=o*n(1);this.setTransform(),this.setGeomUnitsPerPoint(a),this._searchPoint=[(t[0]+t[2])/2,(t[1]+t[3])/2],this._searchDistPoint=(t[2]-t[0])/2/a,this._textInfo=i;const h=e&&("CIMPointSymbol"===e.type&&"Map"!==e.angleAlignment||"CIMTextSymbol"===e.type);return this._mapRotation=h?r:0,this._earlyReturn=!1,this.drawSymbol(e,s),this._earlyReturn}drawSolidFill(t,e){this._hitTestFill(t)}drawHatchFill(t,e){this._hitTestFill(t)}drawPictureFill(t,e){this._hitTestFill(t)}drawGradientFill(t,e){this._hitTestFill(t)}drawSolidStroke(t,e,s,i,r,n){this._hitTestStroke(t,s)}drawPictureStroke(t,e){this._hitTestStroke(t,e.width)}drawGradientStroke(t,e){this._hitTestStroke(t,e.width)}pushClipPath(t){}popClipPath(){}drawImage(t,e,i){const r=this._resourceManager.getResource(t);if(s(r)||0===r.height||0===e)return;const n=e*this.geomUnitsPerPoint(),o=n*i*(r.width/r.height),a=this.reverseTransformPt(this._searchPoint),h=this._searchDistPoint;Math.abs(a[0])<o/2+h&&Math.abs(a[1])<n/2+h&&(this._earlyReturn=!0)}drawText(e){var s,i;const r=this._textInfo;if(!r)return;const n=r.get(e);if(!n)return;const{text:o,mosaicItem:a}=n;if(!a||0===a.glyphMosaicItems.length)return;const h=null!=(s=e.height)?s:I,l=B(e.lineGapType,null!=(i=e.lineGap)?i:0,h),c=t(o)[1],m=a.glyphMosaicItems,f=R(m,c,{scale:h/k,angle:0,xOffset:0,yOffset:0,hAlign:G(e.horizontalAlignment),vAlign:E(e.verticalAlignment),maxLineWidth:512,lineHeight:C*Math.max(.25,Math.min(l||1,4)),decoration:e.font.decoration||"none",isCIM:!0}),u=this.reverseTransformPt(this._searchPoint),_=u[0],d=u[1];for(const t of f.glyphs)if(_>t.xTopLeft&&_<t.xBottomRight&&d>-t.yBottomRight&&d<-t.yTopLeft){this._earlyReturn=!0;break}}_hitTestFill(t){let e=null;if(f(t)){const s=t;e=[[[s.xmin,s.ymin],[s.xmin,s.ymax],[s.xmax,s.ymax],[s.xmax,s.ymin],[s.xmin,s.ymin]]]}else if(c(t))e=t.rings;else{if(!m(t))return;e=t.paths}const s=this.reverseTransformPt(this._searchPoint);this._pointInPolygon(s,e)&&(this._earlyReturn=!0);const i=this.reverseTransformSize(this._searchDistPoint)*this.geomUnitsPerPoint();this._nearLine(s,e,i)&&(this._earlyReturn=!0)}_hitTestStroke(t,e){let s=null;if(f(t)){const e=t;s=[[[e.xmin,e.ymin],[e.xmin,e.ymax],[e.xmax,e.ymax],[e.xmax,e.ymin],[e.xmin,e.ymin]]]}else if(c(t))s=t.rings;else{if(!m(t))return;s=t.paths}const i=this.reverseTransformPt(this._searchPoint),r=e*this.geomUnitsPerPoint(),n=this.reverseTransformSize(this._searchDistPoint)*this.geomUnitsPerPoint();this._nearLine(i,s,r/2+n)&&(this._earlyReturn=!0)}_pointInPolygon(t,e){let s=0;for(const i of e){const e=i.length;for(let r=1;r<e;++r){const e=i[r-1],n=i[r];if(e[1]>t[1]==n[1]>t[1])continue;(n[0]-e[0])*(t[1]-e[1])-(n[1]-e[1])*(t[0]-e[0])>0?s++:s--}}return 0!==s}_nearLine(t,e,s){for(const i of e){const e=i.length;for(let r=1;r<e;++r){const e=i[r-1],n=i[r];let o=(n[0]-e[0])*(n[0]-e[0])+(n[1]-e[1])*(n[1]-e[1]);if(0===o)continue;o=Math.sqrt(o);const a=((n[0]-e[0])*(t[1]-e[1])-(n[1]-e[1])*(t[0]-e[0]))/o;if(Math.abs(a)<s){const i=((n[0]-e[0])*(t[0]-e[0])+(n[1]-e[1])*(t[1]-e[1]))/o;if(i>-s&&i<o+s)return!0}}}return!1}}class j extends z{constructor(t,e,s){super(e,s),this._ctx=t}drawSolidFill(t,e){if(!t)return;if(c(t))this._buildPath(t.rings,!0);else if(m(t))this._buildPath(t.paths,!0);else if(f(t))this._buildPath(A(t).rings,!0);else{if(!u(t))return;console.log("CanvasDrawHelper.drawSolidFill - No implementation!")}const s=this._ctx;s.fillStyle="string"==typeof e?e:"rgba("+Math.round(e[0])+","+Math.round(e[1])+","+Math.round(e[2])+","+e[3]/255+")",s.fill("evenodd")}drawSolidStroke(t,e,s,i,r,n){if(!t||!e||0===s)return;if(c(t))this._buildPath(t.rings,!0);else if(m(t))this._buildPath(t.paths,!1);else{if(!f(t))return void console.log("CanvasDrawHelper.drawSolidStroke isn't implemented!");this._buildPath(A(t).rings,!0)}const o=this._ctx;o.strokeStyle="string"==typeof e?e:"rgba("+Math.round(e[0])+","+Math.round(e[1])+","+Math.round(e[2])+","+e[3]/255+")",o.lineWidth=this.transformSize(s)+.5,this._setCapStyle(i),this._setJoinStyle(r),o.miterLimit=n,o.stroke()}pushClipPath(t){if(this._ctx.save(),c(t))this._buildPath(t.rings,!0);else if(m(t))this._buildPath(t.paths,!0);else{if(!f(t))return;this._buildPath(A(t).rings,!0)}this._ctx.clip("evenodd")}popClipPath(){this._ctx.restore()}drawImage(t,e,i){const r=this._resourceManager.getResource(t);if(s(r))return;const n=this._ctx,o=n.canvas.width,a=n.canvas.height;let h=e*i*(r.width/r.height),l=i*e;e||(h=i*r.width,l=i*r.height),this._ctx.drawImage(r,0,0,r.width,r.height,0,0,Math.min(this.transformSize(h),o),Math.min(this.transformSize(l),a))}drawText(t){this._textRasterizer||(this._textRasterizer=new M)}_buildPath(t,e){const s=this._ctx;if(s.beginPath(),t)for(const i of t){const t=i?i.length:0;if(t>1){let r=this.transformPt(i[0]);s.moveTo(r[0],r[1]);for(let e=1;e<t;++e)r=this.transformPt(i[e]),s.lineTo(r[0],r[1]);e&&s.closePath()}}}_setCapStyle(t){switch(t){case x.Butt:this._ctx.lineCap="butt";break;case x.Round:this._ctx.lineCap="round";break;case x.Square:this._ctx.lineCap="square"}}_setJoinStyle(t){switch(t){case P.Bevel:this._ctx.lineJoin="bevel";break;case P.Round:this._ctx.lineJoin="round";break;case P.Miter:this._ctx.lineJoin="miter"}}}const A=t=>t?{spatialReference:t.spatialReference,rings:[[[t.xmin,t.ymin],[t.xmin,t.ymax],[t.xmax,t.ymax],[t.xmax,t.ymin],[t.xmin,t.ymin]]]}:null,G=t=>{switch(t){case"Left":return b.Left;case"Right":return b.Right;case"Center":case"Justify":return b.Center}},E=t=>{switch(t){case"Top":return S.Top;case"Center":return S.Center;case"Bottom":return S.Bottom;case"Baseline":return S.Baseline}},B=(t,e,s)=>{switch(t){case"ExtraLeading":return 1+e/s;case"Multiple":return e;case"Exact":return e/s}};export{z as CIMSymbolDrawHelper,T as C_DEG_TO_RAD,j as CanvasDrawHelper,U as EnvDrawHelper,F as HittestDrawHelper,L as Transformation,G as horizontalAlignment2HAlign,B as lineGapType2LineHeight,E as verticalAlignment2VAlign};
5
+ import{bidiText as t}from"../../core/BidiText.js";import e from"../../core/Logger.js";import{isNone as s,isSome as i}from"../../core/maybe.js";import r from"../../core/ObjectPool.js";import{pt2px as n}from"../../core/screenUtils.js";import{create as o,fromValues as a}from"../../geometry/support/aaBoundingRect.js";import{getBoundsXY as h}from"../../geometry/support/boundsUtils.js";import{polygonCentroid as l}from"../../geometry/support/centroid.js";import{isPoint as c,isPolygon as m,isPolyline as f,isExtent as u,isMultipoint as _}from"../../geometry/support/jsonUtils.js";import{SimpleGeometryCursor as d}from"./CIMEffects.js";import{getEffectOperator as p,getPlacementOperator as y}from"./CIMOperators.js";import{Placement as g}from"./CIMPlacements.js";import x from"./CIMResourceManager.js";import{LineCapStyle as P,LineJoinStyle as w}from"./enums.js";import M from"./Rect.js";import{TextRasterizer as b}from"./TextRasterizer.js";import{HAlign as S,VAlign as k}from"../../views/2d/engine/webgl/alignmentUtils.js";import{GLYPH_SIZE as C,MAGIC_LABEL_LINE_HEIGHT as R}from"../../views/2d/engine/webgl/definitions.js";import{shapeGlyphs as T}from"../../views/2d/engine/webgl/mesh/templates/shapingUtils.js";const I=Math.PI/180,v=10,L=e.getLogger("esri.symbols.cim.CIMSymbolDrawHelper");class z{constructor(t){this._t=t}static createIdentity(){return new z([1,0,0,0,1,0])}clone(){const t=this._t;return new z(t.slice())}transform(t){const e=this._t;return[e[0]*t[0]+e[1]*t[1]+e[2],e[3]*t[0]+e[4]*t[1]+e[5]]}static createScale(t,e){return new z([t,0,0,0,e,0])}scale(t,e){const s=this._t;return s[0]*=t,s[1]*=t,s[2]*=t,s[3]*=e,s[4]*=e,s[5]*=e,this}scaleRatio(){return Math.sqrt(this._t[0]*this._t[0]+this._t[1]*this._t[1])}static createTranslate(t,e){return new z([0,0,t,0,0,e])}translate(t,e){const s=this._t;return s[2]+=t,s[5]+=e,this}static createRotate(t){const e=Math.cos(t),s=Math.sin(t);return new z([e,-s,0,s,e,0])}rotate(t){return z.multiply(this,z.createRotate(t),this)}static multiply(t,e,s){const i=t._t,r=e._t,n=i[0]*r[0]+i[3]*r[1],o=i[1]*r[0]+i[4]*r[1],a=i[2]*r[0]+i[5]*r[1]+r[2],h=i[0]*r[3]+i[3]*r[4],l=i[1]*r[3]+i[4]*r[4],c=i[2]*r[3]+i[5]*r[4]+r[5],m=s._t;return m[0]=n,m[1]=o,m[2]=a,m[3]=h,m[4]=l,m[5]=c,s}invert(){const t=this._t;let e=t[0]*t[4]-t[1]*t[3];if(0===e)return new z([0,0,0,0,0,0]);e=1/e;const s=(t[1]*t[5]-t[2]*t[4])*e,i=(t[2]*t[3]-t[0]*t[5])*e,r=t[4]*e,n=-t[1]*e,o=-t[3]*e,a=t[0]*e;return new z([r,n,s,o,a,i])}}class U{constructor(t,e){this._transfos=[],this._sizeTransfos=[],this._geomUnitsPerPoint=1,this._placementPool=new r(g,null,null,100),this._earlyReturn=!1,this._mapRotation=0,this._resourceManager=t||new x,this._transfos.push(e||z.createIdentity()),this._sizeTransfos.push(e?e.scaleRatio():1)}setTransform(t,e){this._transfos=[t||z.createIdentity()],this._sizeTransfos=[e||(t?t.scaleRatio():1)]}setGeomUnitsPerPoint(t){this._geomUnitsPerPoint=t}transformPt(t){return this._transfos[this._transfos.length-1].transform(t)}transformSize(t){return t*this._sizeTransfos[this._sizeTransfos.length-1]}reverseTransformPt(t){return this._transfos[this._transfos.length-1].invert().transform(t)}reverseTransformSize(t){return t/this._sizeTransfos[this._sizeTransfos.length-1]}geomUnitsPerPoint(){return this.isEmbedded()?1:this._geomUnitsPerPoint}isEmbedded(){return this._transfos.length>1}back(){return this._transfos[this._transfos.length-1]}push(t,e){const s=e?t.scaleRatio():1;z.multiply(t,this.back(),t),this._transfos.push(t),this._sizeTransfos.push(this._sizeTransfos[this._sizeTransfos.length-1]*s)}pop(){this._transfos.splice(-1,1),this._sizeTransfos.splice(-1,1)}drawSymbol(t,e){if(t)switch(t.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":this.drawMultiLayerSymbol(t,e);break;case"CIMTextSymbol":this.drawTextSymbol(t,e)}}drawMultiLayerSymbol(t,e){if(!t)return;const s=t.symbolLayers;if(!s)return;const i=t.effects;if(i&&i.length>0){const t=this.executeEffects(i,e);if(t){let e=t.next();for(;e;)this.drawSymbolLayers(s,e),e=t.next()}}else this.drawSymbolLayers(s,e)}executeEffects(t,e){const s=this._resourceManager.geometryEngine;let i=new d(e);for(const r of t){const t=p(r);t&&(i=t.execute(i,r,this.geomUnitsPerPoint(),s))}return i}drawSymbolLayers(t,e){let s=t.length;for(;s--;){const i=t[s];if(!i||!1===i.enable)continue;const r=i.effects;if(r&&r.length>0){const t=this.executeEffects(r,e);if(t){let e=null;for(;(e=t.next())&&(this.drawSymbolLayer(i,e),!this._earlyReturn););}}else this.drawSymbolLayer(i,e);if(this._earlyReturn)return}}drawSymbolLayer(t,e){switch(t.type){case"CIMSolidFill":this.drawSolidFill(e,t.color);break;case"CIMHatchFill":this.drawHatchFill(e,t);break;case"CIMPictureFill":this.drawPictureFill(e,t);break;case"CIMGradientFill":this.drawGradientFill(e,t);break;case"CIMSolidStroke":this.drawSolidStroke(e,t.color,t.width,t.capStyle,t.joinStyle,t.miterLimit);break;case"CIMPictureStroke":this.drawPictureStroke(e,t);break;case"CIMGradientStroke":this.drawGradientStroke(e,t);break;case"CIMCharacterMarker":case"CIMPictureMarker":case"CIMVectorMarker":this.drawMarkerLayer(t,e)}}drawHatchFill(t,e){const s=this._buildHatchPolyline(e,t,this.geomUnitsPerPoint());s&&(this.pushClipPath(t),this.drawMultiLayerSymbol(e.lineSymbol,s),this.popClipPath())}drawPictureFill(t,e){}drawGradientFill(t,e){}drawPictureStroke(t,e){}drawGradientStroke(t,e){}drawMarkerLayer(t,e){const s=t.markerPlacement;if(s){const i=y(s);if(i){const r="CIMMarkerPlacementInsidePolygon"===s.type;r&&this.pushClipPath(e);const n=i.execute(e,s,this.geomUnitsPerPoint(),this._resourceManager.geometryEngine);if(n){let e=null;for(;(e=n.next())&&(this.drawMarker(t,e),!this._earlyReturn););}r&&this.popClipPath()}}else{const s=this._placementPool.acquire();if(c(e))s.tx=e.x,s.ty=e.y,this.drawMarker(t,s);else if(m(e))[s.tx,s.ty]=l(e),this.drawMarker(t,s);else for(const i of e.points)if(s.tx=i[0],s.ty=i[1],this.drawMarker(t,s),this._earlyReturn)break;this._placementPool.release(s)}}drawMarker(t,e){switch(t.type){case"CIMCharacterMarker":case"CIMPictureMarker":this.drawPictureMarker(t,e);break;case"CIMVectorMarker":this.drawVectorMarker(t,e)}}drawPictureMarker(t,e){var i,r,n,o,a;if(!t)return;const h=this._resourceManager.getResource(t.url),l=null!=(i=t.size)?i:10;if(s(h)||l<=0)return;const c=h.width,m=h.height;if(!c||!m)return;const f=c/m,u=null!=(r=t.scaleX)?r:1,_=z.createIdentity(),d=t.anchorPoint;if(d){let e=d.x,s=d.y;"Absolute"!==t.anchorPointUnits&&(e*=l*f*u,s*=l),_.translate(-e,-s)}let p=null!=(n=t.rotation)?n:0;t.rotateClockwise&&(p=-p),this._mapRotation&&(p+=this._mapRotation),p&&_.rotate(p*I);let y=null!=(o=t.offsetX)?o:0,g=null!=(a=t.offsetY)?a:0;if(y||g){if(this._mapRotation){const t=I*this._mapRotation,e=Math.cos(t),s=Math.sin(t),i=y*s+g*e;y=y*e-g*s,g=i}_.translate(y,g)}const x=this.geomUnitsPerPoint();1!==x&&_.scale(x,x);const P=e.getAngle();P&&_.rotate(P),_.translate(e.tx,e.ty),this.push(_,!1),this.drawImage(t.url,l,t.scaleX),this.pop()}drawVectorMarker(t,e){var s,i,r,n;if(!t)return;const o=t.markerGraphics;if(!o)return;const a=null!=(s=t.size)?s:10,h=t.frame,l=h?h.ymax-h.ymin:0,c=a&&l?a/l:1,m=z.createIdentity();h&&m.translate(.5*-(h.xmax+h.xmin),.5*-(h.ymax+h.ymin));const f=t.anchorPoint;if(f){let e=f.x,s=f.y;"Absolute"!==t.anchorPointUnits?h&&(e*=h.xmax-h.xmin,s*=h.ymax-h.ymin):(e/=c,s/=c),m.translate(-e,-s)}1!==c&&m.scale(c,c);let u=null!=(i=t.rotation)?i:0;t.rotateClockwise&&(u=-u),this._mapRotation&&(u+=this._mapRotation),u&&m.rotate(u*I);let _=null!=(r=t.offsetX)?r:0,d=null!=(n=t.offsetY)?n:0;if(_||d){if(this._mapRotation){const t=I*this._mapRotation,e=Math.cos(t),s=Math.sin(t),i=_*s+d*e;_=_*e-d*s,d=i}m.translate(_,d)}const p=this.geomUnitsPerPoint();1!==p&&m.scale(p,p);const y=e.getAngle();y&&m.rotate(y),m.translate(e.tx,e.ty),this.push(m,t.scaleSymbolsProportionally);for(const g of o)if(g&&g.symbol&&g.geometry||L.error("Invalid marker graphic",g),this.drawSymbol(g.symbol,g.geometry),this._earlyReturn)break;this.pop()}drawTextSymbol(t,e){var s,i,r,n;if(!t)return;if(!c(e))return;if((null!=(s=t.height)?s:10)<=0)return;const o=z.createIdentity();let a=null!=(i=t.angle)?i:0;a=-a,a&&o.rotate(a*I);const h=null!=(r=t.offsetX)?r:0,l=null!=(n=t.offsetY)?n:0;(h||l)&&o.translate(h,l);const m=this.geomUnitsPerPoint();1!==m&&o.scale(m,m),o.translate(e.x,e.y),this.push(o,!1),this.drawText(t),this.pop()}_buildHatchPolyline(t,e,s){let i=(void 0!==t.separation?t.separation:4)*s,r=void 0!==t.rotation?t.rotation:0;if(0===i)return null;i<0&&(i=-i);let n=0;const a=.5*i;for(;n>a;)n-=i;for(;n<-a;)n+=i;const l=o();h(l,e),l[0]-=a,l[1]-=a,l[2]+=a,l[3]+=a;const c=[[l[0],l[1]],[l[0],l[3]],[l[2],l[3]],[l[2],l[1]]];for(;r>180;)r-=180;for(;r<0;)r+=180;const m=Math.cos(r*I),f=Math.sin(r*I),u=-i*f,_=i*m;let d,p,y,g;n=(void 0!==t.offsetX?t.offsetX*s:0)*f-(void 0!==t.offsetY?t.offsetY*s:0)*m,d=y=Number.MAX_VALUE,p=g=-Number.MAX_VALUE;for(const o of c){const t=o[0],e=o[1],s=m*t+f*e,i=-f*t+m*e;d=Math.min(d,s),y=Math.min(y,i),p=Math.max(p,s),g=Math.max(g,i)}y=Math.floor(y/i)*i;let x=m*d-f*y-u*n/i,P=f*d+m*y-_*n/i,w=m*p-f*y-u*n/i,M=f*p+m*y-_*n/i;const b=1+Math.round((g-y)/i),S=[];for(let o=0;o<b;o++)x+=u,P+=_,w+=u,M+=_,S.push([[x,P],[w,M]]);return{paths:S}}}class F extends U{constructor(t,e){super(t,e),this.reset()}reset(){this._xmin=this._ymin=1/0,this._xmax=this._ymax=-1/0,this._clipCount=0}envelope(){return new M(this._xmin,this._ymin,this._xmax-this._xmin,this._ymax-this._ymin)}bounds(){return a(this._xmin,this._ymin,this._xmax,this._ymax)}drawSolidFill(t){if(t&&!(this._clipCount>0))if(m(t))this._processPath(t.rings,0);else if(f(t))this._processPath(t.paths,0);else if(u(t)){const e=G(t);e&&this._processPath(e.rings,0)}else console.error("drawSolidFill Unexpected geometry type!")}drawSolidStroke(t,e,s){if(!t||this._clipCount>0)return;const i=.5*this.transformSize(s);if(m(t))this._processPath(t.rings,i);else if(f(t))this._processPath(t.paths,i);else if(u(t)){const e=G(t);e&&this._processPath(e.rings,i)}else console.error("drawSolidStroke unexpected geometry type!")}pushClipPath(t){this.drawSolidFill(t),++this._clipCount}popClipPath(){--this._clipCount}drawImage(t,e,s){let r=s*e,n=e;const o=this._resourceManager.getResource(t);!e&&i(o)&&(r=s*o.width,n=o.height),this._merge(this.transformPt([-r/2,-n/2]),0),this._merge(this.transformPt([-r/2,n/2]),0),this._merge(this.transformPt([r/2,-n/2]),0),this._merge(this.transformPt([r/2,n/2]),0)}drawText(t){this._textRasterizer||(this._textRasterizer=new b)}_processPath(t,e){if(t)for(const s of t){const t=s?s.length:0;if(t>1){this._merge(this.transformPt(s[0]),e);for(let i=1;i<t;++i)this._merge(this.transformPt(s[i]),e)}}}_merge(t,e){t[0]-e<this._xmin&&(this._xmin=t[0]-e),t[0]+e>this._xmax&&(this._xmax=t[0]+e),t[1]-e<this._ymin&&(this._ymin=t[1]-e),t[1]+e>this._ymax&&(this._ymax=t[1]+e)}}class j extends U{constructor(){super(...arguments),this._searchPoint=[0,0],this._searchDistPoint=0}hitTest(t,e,s,i,r,o){const a=o*n(1);this.setTransform(),this.setGeomUnitsPerPoint(a),this._searchPoint=[(t[0]+t[2])/2,(t[1]+t[3])/2],this._searchDistPoint=(t[2]-t[0])/2/a,this._textInfo=i;const h=e&&("CIMPointSymbol"===e.type&&"Map"!==e.angleAlignment||"CIMTextSymbol"===e.type);return this._mapRotation=h?r:0,this._earlyReturn=!1,this.drawSymbol(e,s),this._earlyReturn}drawSolidFill(t,e){this._hitTestFill(t)}drawHatchFill(t,e){this._hitTestFill(t)}drawPictureFill(t,e){this._hitTestFill(t)}drawGradientFill(t,e){this._hitTestFill(t)}drawSolidStroke(t,e,s,i,r,n){this._hitTestStroke(t,s)}drawPictureStroke(t,e){this._hitTestStroke(t,e.width)}drawGradientStroke(t,e){this._hitTestStroke(t,e.width)}pushClipPath(t){}popClipPath(){}drawImage(t,e,i){const r=this._resourceManager.getResource(t);if(s(r)||0===r.height||0===e)return;const n=e*this.geomUnitsPerPoint(),o=n*i*(r.width/r.height),a=this.reverseTransformPt(this._searchPoint),h=this._searchDistPoint;Math.abs(a[0])<o/2+h&&Math.abs(a[1])<n/2+h&&(this._earlyReturn=!0)}drawText(e){var s,i;const r=this._textInfo;if(!r)return;const n=r.get(e);if(!n)return;const{text:o,mosaicItem:a}=n;if(!a||0===a.glyphMosaicItems.length)return;const h=null!=(s=e.height)?s:v,l=H(e.lineGapType,null!=(i=e.lineGap)?i:0,h),c=t(o)[1],m=a.glyphMosaicItems,f=T(m,c,{scale:h/C,angle:0,xOffset:0,yOffset:0,hAlign:E(e.horizontalAlignment),vAlign:B(e.verticalAlignment),maxLineWidth:512,lineHeight:R*Math.max(.25,Math.min(l||1,4)),decoration:e.font.decoration||"none",isCIM:!0}),u=this.reverseTransformPt(this._searchPoint),_=u[0],d=u[1];for(const t of f.glyphs)if(_>t.xTopLeft&&_<t.xBottomRight&&d>-t.yBottomRight&&d<-t.yTopLeft){this._earlyReturn=!0;break}}_hitTestFill(t){let e=null;if(u(t)){const s=t;e=[[[s.xmin,s.ymin],[s.xmin,s.ymax],[s.xmax,s.ymax],[s.xmax,s.ymin],[s.xmin,s.ymin]]]}else if(m(t))e=t.rings;else{if(!f(t))return;e=t.paths}const s=this.reverseTransformPt(this._searchPoint);this._pointInPolygon(s,e)&&(this._earlyReturn=!0);const i=this.reverseTransformSize(this._searchDistPoint)*this.geomUnitsPerPoint();this._nearLine(s,e,i)&&(this._earlyReturn=!0)}_hitTestStroke(t,e){let s=null;if(u(t)){const e=t;s=[[[e.xmin,e.ymin],[e.xmin,e.ymax],[e.xmax,e.ymax],[e.xmax,e.ymin],[e.xmin,e.ymin]]]}else if(m(t))s=t.rings;else{if(!f(t))return;s=t.paths}const i=this.reverseTransformPt(this._searchPoint),r=e*this.geomUnitsPerPoint(),n=this.reverseTransformSize(this._searchDistPoint)*this.geomUnitsPerPoint();this._nearLine(i,s,r/2+n)&&(this._earlyReturn=!0)}_pointInPolygon(t,e){let s=0;for(const i of e){const e=i.length;for(let r=1;r<e;++r){const e=i[r-1],n=i[r];if(e[1]>t[1]==n[1]>t[1])continue;(n[0]-e[0])*(t[1]-e[1])-(n[1]-e[1])*(t[0]-e[0])>0?s++:s--}}return 0!==s}_nearLine(t,e,s){for(const i of e){const e=i.length;for(let r=1;r<e;++r){const e=i[r-1],n=i[r];let o=(n[0]-e[0])*(n[0]-e[0])+(n[1]-e[1])*(n[1]-e[1]);if(0===o)continue;o=Math.sqrt(o);const a=((n[0]-e[0])*(t[1]-e[1])-(n[1]-e[1])*(t[0]-e[0]))/o;if(Math.abs(a)<s){const i=((n[0]-e[0])*(t[0]-e[0])+(n[1]-e[1])*(t[1]-e[1]))/o;if(i>-s&&i<o+s)return!0}}}return!1}}class A extends U{constructor(t,e,s){super(e,s),this._ctx=t}drawSolidFill(t,e){if(!t)return;if(m(t))this._buildPath(t.rings,!0);else if(f(t))this._buildPath(t.paths,!0);else if(u(t))this._buildPath(G(t).rings,!0);else{if(!_(t))return;console.log("CanvasDrawHelper.drawSolidFill - No implementation!")}const s=this._ctx;s.fillStyle="string"==typeof e?e:"rgba("+Math.round(e[0])+","+Math.round(e[1])+","+Math.round(e[2])+","+e[3]/255+")",s.fill("evenodd")}drawSolidStroke(t,e,s,i,r,n){if(!t||!e||0===s)return;if(m(t))this._buildPath(t.rings,!0);else if(f(t))this._buildPath(t.paths,!1);else{if(!u(t))return void console.log("CanvasDrawHelper.drawSolidStroke isn't implemented!");this._buildPath(G(t).rings,!0)}const o=this._ctx;o.strokeStyle="string"==typeof e?e:"rgba("+Math.round(e[0])+","+Math.round(e[1])+","+Math.round(e[2])+","+e[3]/255+")",o.lineWidth=this.transformSize(s)+.5,this._setCapStyle(i),this._setJoinStyle(r),o.miterLimit=n,o.stroke()}pushClipPath(t){if(this._ctx.save(),m(t))this._buildPath(t.rings,!0);else if(f(t))this._buildPath(t.paths,!0);else{if(!u(t))return;this._buildPath(G(t).rings,!0)}this._ctx.clip("evenodd")}popClipPath(){this._ctx.restore()}drawImage(t,e,i){const r=this._resourceManager.getResource(t);if(s(r))return;const n=this._ctx,o=n.canvas.width,a=n.canvas.height;let h=e*i*(r.width/r.height),l=i*e;e||(h=i*r.width,l=i*r.height),this._ctx.drawImage(r,0,0,r.width,r.height,0,0,Math.min(this.transformSize(h),o),Math.min(this.transformSize(l),a))}drawText(t){this._textRasterizer||(this._textRasterizer=new b)}_buildPath(t,e){const s=this._ctx;if(s.beginPath(),t)for(const i of t){const t=i?i.length:0;if(t>1){let r=this.transformPt(i[0]);s.moveTo(r[0],r[1]);for(let e=1;e<t;++e)r=this.transformPt(i[e]),s.lineTo(r[0],r[1]);e&&s.closePath()}}}_setCapStyle(t){switch(t){case P.Butt:this._ctx.lineCap="butt";break;case P.Round:this._ctx.lineCap="round";break;case P.Square:this._ctx.lineCap="square"}}_setJoinStyle(t){switch(t){case w.Bevel:this._ctx.lineJoin="bevel";break;case w.Round:this._ctx.lineJoin="round";break;case w.Miter:this._ctx.lineJoin="miter"}}}const G=t=>t?{spatialReference:t.spatialReference,rings:[[[t.xmin,t.ymin],[t.xmin,t.ymax],[t.xmax,t.ymax],[t.xmax,t.ymin],[t.xmin,t.ymin]]]}:null,E=t=>{switch(t){case"Left":return S.Left;case"Right":return S.Right;case"Center":case"Justify":return S.Center}},B=t=>{switch(t){case"Top":return k.Top;case"Center":return k.Center;case"Bottom":return k.Bottom;case"Baseline":return k.Baseline}},H=(t,e,s)=>{switch(t){case"ExtraLeading":return 1+e/s;case"Multiple":return e;case"Exact":return e/s}};export{U as CIMSymbolDrawHelper,I as C_DEG_TO_RAD,A as CanvasDrawHelper,F as EnvDrawHelper,j as HittestDrawHelper,z as Transformation,E as horizontalAlignment2HAlign,H as lineGapType2LineHeight,B as verticalAlignment2VAlign};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- import{isNone as t,isSome as e}from"../../../../../core/maybe.js";import{MIN_MAX_ZOOM_PRECISION_FACTOR as i,TEXTURE_BINDING_ATTRIBUTE_DATA_0 as s,TEXTURE_BINDING_ATTRIBUTE_DATA_1 as o,TEXTURE_BINDING_ATTRIBUTE_DATA_2 as a,TEXTURE_BINDING_ATTRIBUTE_DATA_3 as r}from"../definitions.js";import n from"./WGLBrush.js";import{BlendFactor as v,CompareFunction as u,DataType as f}from"../../../../webgl/enums.js";class m extends n{constructor(){super(...arguments),this._computeDesc=null}prepareState({context:t},e,i){const s=i&&-1!==i.indexOf("hittest");t.setBlendingEnabled(!s),t.setBlendFunctionSeparate(v.ONE,v.ONE_MINUS_SRC_ALPHA,v.ONE,v.ONE_MINUS_SRC_ALPHA),t.setColorMask(!0,!0,!0,!0),t.setStencilWriteMask(0),t.setStencilTestEnabled(!0),t.setStencilFunction(u.EQUAL,e.stencilRef,255)}draw(e,i,s){const o=this.getGeometryType();i.commit(e);const a=i.getGeometry(o);t(a)||(e.timeline.begin(this.name),e.attributeView.bindTextures(e.context),a.forEachCommand((t=>this.drawGeometry(e,i,t,s))))}_setSharedUniforms(t,n,v){const{displayLevel:u,pixelRatio:f,state:m,passOptions:l}=n;e(l)&&"hittest"===l.type&&(t.setUniform2fv("u_hittestPos",l.position),t.setUniform1f("u_hittestDist",l.distance)),t.setUniform1f("u_pixelRatio",f),t.setUniformMatrix3fv("u_tileMat3",v.transforms.tileMat3),t.setUniformMatrix3fv("u_viewMat3",m.viewMat3),t.setUniformMatrix3fv("u_dvsMat3",v.transforms.dvs),t.setUniformMatrix3fv("u_displayViewMat3",m.displayViewMat3),t.setUniform1f("u_currentZoom",Math.round(u*i)),t.setUniform1i("u_attributeTextureSize",n.attributeView.size),t.setUniform1i("u_attributeData0",s),t.setUniform1i("u_attributeData1",o),t.setUniform1i("u_attributeData2",a),t.setUniform1i("u_attributeData3",r)}_setSizeVVUniforms(t,e,i,s){if(t.vvSizeMinMaxValue&&e.setUniform4fv("u_vvSizeMinMaxValue",i.vvSizeMinMaxValue),t.vvSizeScaleStops&&e.setUniform1f("u_vvSizeScaleStopsValue",i.vvSizeScaleStopsValue),t.vvSizeFieldStops){const t=i.getSizeVVFieldStops(s.key.level);e.setUniform1fv("u_vvSizeFieldStopsValues",t.values),e.setUniform1fv("u_vvSizeFieldStopsSizes",t.sizes)}t.vvSizeUnitValue&&e.setUniform1f("u_vvSizeUnitValueWorldToPixelsRatio",i.vvSizeUnitValueToPixelsRatio)}_setColorAndOpacityVVUniforms(t,e,i){t.vvColor&&(e.setUniform1fv("u_vvColorValues",i.vvColorValues),e.setUniform4fv("u_vvColors",i.vvColors)),t.vvOpacity&&(e.setUniform1fv("u_vvOpacityValues",i.vvOpacityValues),e.setUniform1fv("u_vvOpacities",i.vvOpacities))}_setRotationVVUniforms(t,e,i){t.vvRotation&&e.setUniform1f("u_vvRotationType","geographic"===i.vvMaterialParameters.vvRotationType?0:1)}_getTriangleDesc(t){if(!this._computeDesc){const e=t.strides,i=t.strides.geometry,s=new Map(t.attributes),o=t.bufferLayouts.geometry.map((t=>({...t}))),a=Math.max(...t.attributes.values()),r={geometry:o};r.geometry.push({count:2,name:"a_pos1",divisor:0,normalized:!1,offset:i,stride:i,type:f.SHORT}),r.geometry.push({count:2,name:"a_pos2",divisor:0,normalized:!1,offset:2*i,stride:i,type:f.SHORT}),s.set("a_pos1",a+1),s.set("a_pos2",a+2),this._computeDesc={bufferLayouts:r,attributes:s,strides:e}}return this._computeDesc}}export{m as default};
5
+ import{isNone as t,isSome as e}from"../../../../../core/maybe.js";import{MIN_MAX_ZOOM_PRECISION_FACTOR as i,TEXTURE_BINDING_ATTRIBUTE_DATA_0 as s,TEXTURE_BINDING_ATTRIBUTE_DATA_1 as o,TEXTURE_BINDING_ATTRIBUTE_DATA_2 as a,TEXTURE_BINDING_ATTRIBUTE_DATA_3 as r}from"../definitions.js";import n from"./WGLBrush.js";import{BlendFactor as v,CompareFunction as u,DataType as f}from"../../../../webgl/enums.js";class m extends n{constructor(){super(...arguments),this._computeDesc=new Map}prepareState({context:t},e,i){const s=i&&-1!==i.indexOf("hittest");t.setBlendingEnabled(!s),t.setBlendFunctionSeparate(v.ONE,v.ONE_MINUS_SRC_ALPHA,v.ONE,v.ONE_MINUS_SRC_ALPHA),t.setColorMask(!0,!0,!0,!0),t.setStencilWriteMask(0),t.setStencilTestEnabled(!0),t.setStencilFunction(u.EQUAL,e.stencilRef,255)}draw(e,i,s){const o=this.getGeometryType();i.commit(e);const a=i.getGeometry(o);t(a)||(e.timeline.begin(this.name),e.attributeView.bindTextures(e.context),a.forEachCommand((t=>this.drawGeometry(e,i,t,s))))}_setSharedUniforms(t,n,v){const{displayLevel:u,pixelRatio:f,state:m,passOptions:l}=n;e(l)&&"hittest"===l.type&&(t.setUniform2fv("u_hittestPos",l.position),t.setUniform1f("u_hittestDist",l.distance)),t.setUniform1f("u_pixelRatio",f),t.setUniformMatrix3fv("u_tileMat3",v.transforms.tileMat3),t.setUniformMatrix3fv("u_viewMat3",m.viewMat3),t.setUniformMatrix3fv("u_dvsMat3",v.transforms.dvs),t.setUniformMatrix3fv("u_displayViewMat3",m.displayViewMat3),t.setUniform1f("u_currentZoom",Math.round(u*i)),t.setUniform1i("u_attributeTextureSize",n.attributeView.size),t.setUniform1i("u_attributeData0",s),t.setUniform1i("u_attributeData1",o),t.setUniform1i("u_attributeData2",a),t.setUniform1i("u_attributeData3",r)}_setSizeVVUniforms(t,e,i,s){if(t.vvSizeMinMaxValue&&e.setUniform4fv("u_vvSizeMinMaxValue",i.vvSizeMinMaxValue),t.vvSizeScaleStops&&e.setUniform1f("u_vvSizeScaleStopsValue",i.vvSizeScaleStopsValue),t.vvSizeFieldStops){const t=i.getSizeVVFieldStops(s.key.level);e.setUniform1fv("u_vvSizeFieldStopsValues",t.values),e.setUniform1fv("u_vvSizeFieldStopsSizes",t.sizes)}t.vvSizeUnitValue&&e.setUniform1f("u_vvSizeUnitValueWorldToPixelsRatio",i.vvSizeUnitValueToPixelsRatio)}_setColorAndOpacityVVUniforms(t,e,i){t.vvColor&&(e.setUniform1fv("u_vvColorValues",i.vvColorValues),e.setUniform4fv("u_vvColors",i.vvColors)),t.vvOpacity&&(e.setUniform1fv("u_vvOpacityValues",i.vvOpacityValues),e.setUniform1fv("u_vvOpacities",i.vvOpacities))}_setRotationVVUniforms(t,e,i){t.vvRotation&&e.setUniform1f("u_vvRotationType","geographic"===i.vvMaterialParameters.vvRotationType?0:1)}_getTriangleDesc(t,e){let i=this._computeDesc.get(t);if(!i){const s=e.strides,o=e.strides.geometry,a=new Map(e.attributes),r=e.bufferLayouts.geometry.map((t=>({...t}))),n=Math.max(...e.attributes.values()),v={geometry:r};v.geometry.push({count:2,name:"a_pos1",divisor:0,normalized:!1,offset:o,stride:o,type:f.SHORT}),v.geometry.push({count:2,name:"a_pos2",divisor:0,normalized:!1,offset:2*o,stride:o,type:f.SHORT}),a.set("a_pos1",n+1),a.set("a_pos2",n+2),i={bufferLayouts:v,attributes:a,strides:s},this._computeDesc.set(t,i)}return i}}export{m as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- import{disposeMaybe as t,isSome as e,isNone as o}from"../../../../../core/maybe.js";import r from"../../../../../core/RandomLCG.js";import{TEXTURE_BINDING_RENDERER_0 as i,TEXTURE_BINDING_RENDERER_1 as s,TILE_SIZE as n}from"../definitions.js";import{WGLGeometryType as a}from"../enums.js";import{createProgramDescriptor as d}from"../Utils.js";import l from"./WGLGeometryBrush.js";import{FillMaterialKey as m}from"../materialKey/MaterialKey.js";import{BufferObject as _}from"../../../../webgl/BufferObject.js";import{PrimitiveType as u,DataType as c,TextureType as f,PixelFormat as h,PixelType as T,TextureSamplingMode as p,TextureWrapMode as x,TargetType as y,DepthStencilTargetType as D,RenderbufferFormat as g,Usage as E}from"../../../../webgl/enums.js";import{FramebufferObject as S}from"../../../../webgl/FramebufferObject.js";import{Renderbuffer as w}from"../../../../webgl/Renderbuffer.js";import{Texture as U}from"../../../../webgl/Texture.js";import{VertexArrayObject as O}from"../../../../webgl/VertexArrayObject.js";const b=t=>{const e={geometry:[{location:0,name:"a_pos",count:2,type:c.SHORT},{location:1,name:"a_id",count:3,type:c.UNSIGNED_BYTE},{location:2,name:"a_bitset",count:1,type:c.UNSIGNED_BYTE}]};return t.dotDensity?(e.geometry.push({location:3,name:"a_inverseArea",count:1,type:c.FLOAT}),d(t.data,e)):(e.geometry.push({location:3,name:"a_color",count:4,type:c.UNSIGNED_BYTE,normalized:!0}),t.simple||e.geometry.push({location:4,name:"a_aux1",count:4,type:c.UNSIGNED_SHORT}),e.geometry.push({location:5,name:"a_aux2",count:4,type:c.UNSIGNED_BYTE},{location:6,name:"a_aux3",count:4,type:c.UNSIGNED_BYTE}),t.simple||e.geometry.push({location:7,name:"a_zoomRange",count:2,type:c.UNSIGNED_SHORT}),d(t.data,e))};class N extends l{constructor(){super(...arguments),this._dotTextureSize=0,this._dotTextures=null,this._dotSamplers=new Int32Array([i,s]),this._dotVAO=null,this._dotDesc={vsPath:"dot/dot",fsPath:"dot/dot",attributes:new Map([["a_pos",0]])}}dispose(){this._disposeTextures(),this._dotFBO=t(this._dotFBO),this._dotVAO=t(this._dotVAO)}getGeometryType(){return a.FILL}drawGeometry(t,o,r,i){const{context:s,painter:n,rendererInfo:a,requiredLevel:d,passOptions:l}=t,_=m.load(r.materialKey),f=n.materialManager;let h=u.TRIANGLES,T=b(_);e(l)&&"hittest"===l.type&&(T=this._getTriangleDesc(T),h=u.POINTS);const{attributes:p,bufferLayouts:x}=T,y=f.getMaterialProgram(t,_,"materials/fill",p,i);if(s.useProgram(y),this._setSharedUniforms(y,t,o),y.setUniform2f("u_tileOffset",512*o.key.col,512*o.key.row),_.textureBinding){n.textureManager.bindTextures(s,y,_);const e=1/2**(d-o.key.level)/t.pixelRatio;y.setUniform1f("u_zoomFactor",e)}const D=1/t.pixelRatio;y.setUniform1f("u_blur",D),y.setUniform1f("u_antialiasing",D),this._setSizeVVUniforms(_,y,a,o),this._setColorAndOpacityVVUniforms(_,y,a);const g=e(l)&&"hittest"===l.type,E=r.target.getVAO(s,x,p,g);let S=r.indexCount,w=r.indexFrom*Uint32Array.BYTES_PER_ELEMENT;if(g&&(S/=3,w/=3),s.bindVAO(E),!_.dotDensity||g)s.drawElements(h,S,c.UNSIGNED_INT,w);else{const e=this._drawDotLocations(t,o,y,S,w);this._drawDotDensity(t,o,e)}}_drawDotDensity(t,e,o){const{context:r,painter:i,rendererInfo:s}=t,n=i.materialManager.getProgram(t,this._dotDesc),a=this._createDotDensityMesh(r,this._dotDesc.attributes,{geometry:[{name:"a_pos",count:2,type:c.SHORT,divisor:0,normalized:!1,offset:0,stride:4}]});r.setStencilTestEnabled(!0),r.useProgram(n),n.setUniform1f("u_tileZoomFactor",1),n.setUniform1i("u_texture",this._dotSamplers[0]),n.setUniform1f("u_dotSize",Math.max(s.ddDotSize,1)),n.setUniform1f("u_pixelRatio",window.devicePixelRatio),this._setSharedUniforms(n,t,e),r.bindTexture(o,this._dotSamplers[0]),r.bindVAO(a),r.drawArrays(u.POINTS,0,262144)}_drawDotLocations(t,e,o,r,i){const{context:s,rendererInfo:a,requiredLevel:d}=t,l=s.getViewport();s.setViewport(0,0,512,512);const m=s.getBoundFramebufferObject(),_=this._createFBO(s);s.bindFramebuffer(_),s.setClearColor(0,0,0,0),s.clear(s.gl.COLOR_BUFFER_BIT|s.gl.STENCIL_BUFFER_BIT),s.setStencilTestEnabled(!1);const f=1/2**(d-e.key.level),h=n,T=h*window.devicePixelRatio*h*window.devicePixelRatio,p=1/f*(1/f),x=a.ddDotScale?t.state.scale/a.ddDotScale:1;return o.setUniform1f("u_tileZoomFactor",f),o.setUniform1f("u_tileDotsOverArea",T/(n*window.devicePixelRatio*n*window.devicePixelRatio)),o.setUniformMatrix4fv("u_dotColors",a.ddColors),o.setUniform4fv("u_isActive",a.ddActiveDots),o.setUniform4fv("u_dotBackgroundColor",a.ddBackgroundColor),o.setUniform1f("u_dotValue",Math.max(1,a.ddDotValue*x*p)),this._bindDotDensityTextures(s,o,a,h),s.drawElements(u.TRIANGLES,r,c.UNSIGNED_INT,i),s.setViewport(l.x,l.y,l.width,l.height),s.bindFramebuffer(m),_.colorTexture}_createFBO(t){if(o(this._dotFBO)){const e=512,o=512,r={target:f.TEXTURE_2D,pixelFormat:h.RGBA,dataType:T.UNSIGNED_BYTE,samplingMode:p.NEAREST,wrapMode:x.CLAMP_TO_EDGE,width:e,height:o},i={colorTarget:y.TEXTURE,depthStencilTarget:D.DEPTH_STENCIL_RENDER_BUFFER},s=new w(t,{width:e,height:o,internalFormat:g.DEPTH_STENCIL});this._dotFBO=new S(t,i,r,s)}return this._dotFBO}_disposeTextures(){if(this._dotTextures){for(let t=0;t<this._dotTextures.length;t++)this._dotTextures[t].dispose();this._dotTextures=null}}_bindDotDensityTextures(t,e,o,r){const i=this._createDotDensityTextures(t,r,o.ddSeed);e.setUniform1iv("u_dotTextures",this._dotSamplers);for(let s=0;s<i.length;s++)t.bindTexture(i[s],this._dotSamplers[s])}_createDotDensityMesh(t,e,r){if(o(this._dotVAO)){const o=2,i=new Int16Array(262144*o);for(let t=0;t<512;t++)for(let e=0;e<512;e++)i[o*(e+512*t)]=e,i[o*(e+512*t)+1]=t;const s=_.createVertex(t,E.STATIC_DRAW,i);this._dotVAO=new O(t,e,r,{geometry:s},null)}return this._dotVAO}_createDotDensityTextures(t,e,o){if(this._dotTextureSize===e&&this._seed===o||(this._disposeTextures(),this._dotTextureSize=e,this._seed=o),null===this._dotTextures){const i=new r(o);this._dotTextures=[this._allocDotDensityTexture(t,e,i),this._allocDotDensityTexture(t,e,i)]}return this._dotTextures}_allocDotDensityTexture(t,e,o){const r=new Float32Array(e*e*4);for(let i=0;i<r.length;i++)r[i]=o.getFloat();return new U(t,{wrapMode:x.REPEAT,pixelFormat:h.RGBA,dataType:T.FLOAT,samplingMode:p.NEAREST,width:e,height:e},r)}}export{N as default};
5
+ import{disposeMaybe as t,isSome as e,isNone as o}from"../../../../../core/maybe.js";import r from"../../../../../core/RandomLCG.js";import{TEXTURE_BINDING_RENDERER_0 as i,TEXTURE_BINDING_RENDERER_1 as s,TILE_SIZE as a}from"../definitions.js";import{WGLGeometryType as n}from"../enums.js";import{createProgramDescriptor as d}from"../Utils.js";import l from"./WGLGeometryBrush.js";import{FillMaterialKey as m}from"../materialKey/MaterialKey.js";import{BufferObject as _}from"../../../../webgl/BufferObject.js";import{PrimitiveType as u,DataType as c,TextureType as f,PixelFormat as h,PixelType as T,TextureSamplingMode as p,TextureWrapMode as y,TargetType as x,DepthStencilTargetType as D,RenderbufferFormat as g,Usage as E}from"../../../../webgl/enums.js";import{FramebufferObject as S}from"../../../../webgl/FramebufferObject.js";import{Renderbuffer as w}from"../../../../webgl/Renderbuffer.js";import{Texture as U}from"../../../../webgl/Texture.js";import{VertexArrayObject as O}from"../../../../webgl/VertexArrayObject.js";const b=t=>{const e={geometry:[{location:0,name:"a_pos",count:2,type:c.SHORT},{location:1,name:"a_id",count:3,type:c.UNSIGNED_BYTE},{location:2,name:"a_bitset",count:1,type:c.UNSIGNED_BYTE}]};return t.dotDensity?(e.geometry.push({location:3,name:"a_inverseArea",count:1,type:c.FLOAT}),d(t.data,e)):(e.geometry.push({location:3,name:"a_color",count:4,type:c.UNSIGNED_BYTE,normalized:!0}),t.simple||e.geometry.push({location:4,name:"a_aux1",count:4,type:c.UNSIGNED_SHORT}),e.geometry.push({location:5,name:"a_aux2",count:4,type:c.UNSIGNED_BYTE},{location:6,name:"a_aux3",count:4,type:c.UNSIGNED_BYTE}),t.simple||e.geometry.push({location:7,name:"a_zoomRange",count:2,type:c.UNSIGNED_SHORT}),d(t.data,e))};class N extends l{constructor(){super(...arguments),this._dotTextureSize=0,this._dotTextures=null,this._dotSamplers=new Int32Array([i,s]),this._dotVAO=null,this._dotDesc={vsPath:"dot/dot",fsPath:"dot/dot",attributes:new Map([["a_pos",0]])}}dispose(){this._disposeTextures(),this._dotFBO=t(this._dotFBO),this._dotVAO=t(this._dotVAO)}getGeometryType(){return n.FILL}drawGeometry(t,o,r,i){const{context:s,painter:a,rendererInfo:n,requiredLevel:d,passOptions:l}=t,_=m.load(r.materialKey),f=a.materialManager;let h=u.TRIANGLES,T=b(_);e(l)&&"hittest"===l.type&&(T=this._getTriangleDesc(r.materialKey,T),h=u.POINTS);const{attributes:p,bufferLayouts:y}=T,x=f.getMaterialProgram(t,_,"materials/fill",p,i);if(s.useProgram(x),this._setSharedUniforms(x,t,o),x.setUniform2f("u_tileOffset",512*o.key.col,512*o.key.row),_.textureBinding){a.textureManager.bindTextures(s,x,_);const e=1/2**(d-o.key.level)/t.pixelRatio;x.setUniform1f("u_zoomFactor",e)}const D=1/t.pixelRatio;x.setUniform1f("u_blur",D),x.setUniform1f("u_antialiasing",D),this._setSizeVVUniforms(_,x,n,o),this._setColorAndOpacityVVUniforms(_,x,n);const g=e(l)&&"hittest"===l.type,E=r.target.getVAO(s,y,p,g);let S=r.indexCount,w=r.indexFrom*Uint32Array.BYTES_PER_ELEMENT;if(g&&(S/=3,w/=3),s.bindVAO(E),!_.dotDensity||g)s.drawElements(h,S,c.UNSIGNED_INT,w);else{const e=this._drawDotLocations(t,o,x,S,w);this._drawDotDensity(t,o,e)}}_drawDotDensity(t,e,o){const{context:r,painter:i,rendererInfo:s}=t,a=i.materialManager.getProgram(t,this._dotDesc),n=this._createDotDensityMesh(r,this._dotDesc.attributes,{geometry:[{name:"a_pos",count:2,type:c.SHORT,divisor:0,normalized:!1,offset:0,stride:4}]});r.setStencilTestEnabled(!0),r.useProgram(a),a.setUniform1f("u_tileZoomFactor",1),a.setUniform1i("u_texture",this._dotSamplers[0]),a.setUniform1f("u_dotSize",Math.max(s.ddDotSize,1)),a.setUniform1f("u_pixelRatio",window.devicePixelRatio),this._setSharedUniforms(a,t,e),r.bindTexture(o,this._dotSamplers[0]),r.bindVAO(n),r.drawArrays(u.POINTS,0,262144)}_drawDotLocations(t,e,o,r,i){const{context:s,rendererInfo:n,requiredLevel:d}=t,l=s.getViewport();s.setViewport(0,0,512,512);const m=s.getBoundFramebufferObject(),_=this._createFBO(s);s.bindFramebuffer(_),s.setClearColor(0,0,0,0),s.clear(s.gl.COLOR_BUFFER_BIT|s.gl.STENCIL_BUFFER_BIT),s.setStencilTestEnabled(!1);const f=1/2**(d-e.key.level),h=a,T=h*window.devicePixelRatio*h*window.devicePixelRatio,p=1/f*(1/f),y=n.ddDotScale?t.state.scale/n.ddDotScale:1;return o.setUniform1f("u_tileZoomFactor",f),o.setUniform1f("u_tileDotsOverArea",T/(a*window.devicePixelRatio*a*window.devicePixelRatio)),o.setUniformMatrix4fv("u_dotColors",n.ddColors),o.setUniform4fv("u_isActive",n.ddActiveDots),o.setUniform4fv("u_dotBackgroundColor",n.ddBackgroundColor),o.setUniform1f("u_dotValue",Math.max(1,n.ddDotValue*y*p)),this._bindDotDensityTextures(s,o,n,h),s.drawElements(u.TRIANGLES,r,c.UNSIGNED_INT,i),s.setViewport(l.x,l.y,l.width,l.height),s.bindFramebuffer(m),_.colorTexture}_createFBO(t){if(o(this._dotFBO)){const e=512,o=512,r={target:f.TEXTURE_2D,pixelFormat:h.RGBA,dataType:T.UNSIGNED_BYTE,samplingMode:p.NEAREST,wrapMode:y.CLAMP_TO_EDGE,width:e,height:o},i={colorTarget:x.TEXTURE,depthStencilTarget:D.DEPTH_STENCIL_RENDER_BUFFER},s=new w(t,{width:e,height:o,internalFormat:g.DEPTH_STENCIL});this._dotFBO=new S(t,i,r,s)}return this._dotFBO}_disposeTextures(){if(this._dotTextures){for(let t=0;t<this._dotTextures.length;t++)this._dotTextures[t].dispose();this._dotTextures=null}}_bindDotDensityTextures(t,e,o,r){const i=this._createDotDensityTextures(t,r,o.ddSeed);e.setUniform1iv("u_dotTextures",this._dotSamplers);for(let s=0;s<i.length;s++)t.bindTexture(i[s],this._dotSamplers[s])}_createDotDensityMesh(t,e,r){if(o(this._dotVAO)){const o=2,i=new Int16Array(262144*o);for(let t=0;t<512;t++)for(let e=0;e<512;e++)i[o*(e+512*t)]=e,i[o*(e+512*t)+1]=t;const s=_.createVertex(t,E.STATIC_DRAW,i);this._dotVAO=new O(t,e,r,{geometry:s},null)}return this._dotVAO}_createDotDensityTextures(t,e,o){if(this._dotTextureSize===e&&this._seed===o||(this._disposeTextures(),this._dotTextureSize=e,this._seed=o),null===this._dotTextures){const i=new r(o);this._dotTextures=[this._allocDotDensityTexture(t,e,i),this._allocDotDensityTexture(t,e,i)]}return this._dotTextures}_allocDotDensityTexture(t,e,o){const r=new Float32Array(e*e*4);for(let i=0;i<r.length;i++)r[i]=o.getFloat();return new U(t,{wrapMode:y.REPEAT,pixelFormat:h.RGBA,dataType:T.FLOAT,samplingMode:p.NEAREST,width:e,height:e},r)}}export{N as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- import{isSome as t}from"../../../../../core/maybe.js";import{WGLGeometryType as e}from"../enums.js";import{createProgramDescriptor as o}from"../Utils.js";import a from"./WGLGeometryBrush.js";import{LineMaterialKey as n}from"../materialKey/MaterialKey.js";import{DataType as i,PrimitiveType as r}from"../../../../webgl/enums.js";const s=t=>o(t.data,{geometry:[{location:0,name:"a_pos",count:2,type:i.SHORT},{location:1,name:"a_id",count:4,type:i.UNSIGNED_BYTE},{location:2,name:"a_color",count:4,type:i.UNSIGNED_BYTE,normalized:!0},{location:3,name:"a_offsetAndNormal",count:4,type:i.BYTE},{location:4,name:"a_accumulatedDistanceAndHalfWidth",count:2,type:i.UNSIGNED_SHORT},{location:5,name:"a_tlbr",count:4,type:i.UNSIGNED_SHORT},{location:6,name:"a_segmentDirection",count:4,type:i.BYTE},{location:7,name:"a_aux",count:2,type:i.UNSIGNED_SHORT},{location:8,name:"a_zoomRange",count:2,type:i.UNSIGNED_SHORT}]});class m extends a{dispose(){}getGeometryType(){return e.LINE}drawGeometry(e,o,a,m){const{context:l,painter:c,rendererInfo:u,displayLevel:p,passOptions:y}=e,_=n.load(a.materialKey);let d=s(_),f=r.TRIANGLES;t(y)&&"hittest"===y.type&&(d=this._getTriangleDesc(d),f=r.POINTS);const{attributes:E,bufferLayouts:N}=d,g=c.materialManager.getMaterialProgram(e,_,"materials/line",E,m),S=1/e.pixelRatio,T=0;l.useProgram(g),this._setSharedUniforms(g,e,o),_.textureBinding&&c.textureManager.bindTextures(l,g,_);const U=2**(p-o.key.level)/e.pixelRatio;g.setUniform1f("u_zoomFactor",U),g.setUniform1f("u_blur",T+S),g.setUniform1f("u_antialiasing",S),this._setSizeVVUniforms(_,g,u,o),this._setColorAndOpacityVVUniforms(_,g,u),l.setFaceCullingEnabled(!1);const G=t(y)&&"hittest"===y.type,I=a.target.getVAO(l,N,E,G);let x=a.indexCount,D=a.indexFrom*Uint32Array.BYTES_PER_ELEMENT;G&&(x/=3,D/=3),l.bindVAO(I),l.drawElements(f,x,i.UNSIGNED_INT,D)}}export{m as default};
5
+ import{isSome as t}from"../../../../../core/maybe.js";import{WGLGeometryType as e}from"../enums.js";import{createProgramDescriptor as a}from"../Utils.js";import o from"./WGLGeometryBrush.js";import{LineMaterialKey as n}from"../materialKey/MaterialKey.js";import{DataType as i,PrimitiveType as r}from"../../../../webgl/enums.js";const s=t=>a(t.data,{geometry:[{location:0,name:"a_pos",count:2,type:i.SHORT},{location:1,name:"a_id",count:4,type:i.UNSIGNED_BYTE},{location:2,name:"a_color",count:4,type:i.UNSIGNED_BYTE,normalized:!0},{location:3,name:"a_offsetAndNormal",count:4,type:i.BYTE},{location:4,name:"a_accumulatedDistanceAndHalfWidth",count:2,type:i.UNSIGNED_SHORT},{location:5,name:"a_tlbr",count:4,type:i.UNSIGNED_SHORT},{location:6,name:"a_segmentDirection",count:4,type:i.BYTE},{location:7,name:"a_aux",count:2,type:i.UNSIGNED_SHORT},{location:8,name:"a_zoomRange",count:2,type:i.UNSIGNED_SHORT}]});class m extends o{dispose(){}getGeometryType(){return e.LINE}drawGeometry(e,a,o,m){const{context:l,painter:c,rendererInfo:u,displayLevel:p,passOptions:y}=e,_=n.load(o.materialKey);let d=s(_),f=r.TRIANGLES;t(y)&&"hittest"===y.type&&(d=this._getTriangleDesc(o.materialKey,d),f=r.POINTS);const{attributes:E,bufferLayouts:N}=d,g=c.materialManager.getMaterialProgram(e,_,"materials/line",E,m),S=1/e.pixelRatio,T=0;l.useProgram(g),this._setSharedUniforms(g,e,a),_.textureBinding&&c.textureManager.bindTextures(l,g,_);const U=2**(p-a.key.level)/e.pixelRatio;g.setUniform1f("u_zoomFactor",U),g.setUniform1f("u_blur",T+S),g.setUniform1f("u_antialiasing",S),this._setSizeVVUniforms(_,g,u,a),this._setColorAndOpacityVVUniforms(_,g,u),l.setFaceCullingEnabled(!1);const G=t(y)&&"hittest"===y.type,I=o.target.getVAO(l,N,E,G);let x=o.indexCount,D=o.indexFrom*Uint32Array.BYTES_PER_ELEMENT;G&&(x/=3,D/=3),l.bindVAO(I),l.drawElements(f,x,i.UNSIGNED_INT,D)}}export{m as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import t from"../../core/Accessor.js";import{HandleOwnerMixin as i}from"../../core/HandleOwner.js";import{isSome as l,isNone as r,get as n}from"../../core/maybe.js";import{watch as o}from"../../core/reactiveUtils.js";import{generateUID as s}from"../../core/uid.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as u}from"../../core/accessorSupport/decorators/subclass.js";import d from"../../layers/support/CodedValueDomain.js";import"../../layers/support/Domain.js";import"../../layers/support/InheritedDomain.js";import"../../layers/support/RangeDomain.js";import{validateDomainValue as p,DomainValidationError as c,getDomainRange as h}from"../../layers/support/domainUtils.js";import{isNumericField as m,isStringField as y,isDateField as v,TypeValidationError as f,validateFieldValue as g,getFeatureEditFields as E,getFeatureGeometryFields as b,NumericRangeValidationError as _,getFieldRange as x}from"../../layers/support/fieldUtils.js";import{substitute as F}from"../../intl/substitute.js";var V,O;!function(e){e.Text="text",e.Number="number",e.Date="date",e.Unsupported="unsupported"}(V||(V={})),function(e){e.TOO_SHORT="length-validation-error::too-short"}(O||(O={}));const U={type:"number"},T={type:"number",intlOptions:{notation:"scientific"}},j={type:"date",intlOptions:{day:"2-digit",month:"2-digit",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}};let A=class extends(i(t)){constructor(e){super(e),this._storedValue=null,this.arcade=null,this.editableFunction=null,this.id=s().toString(),this.requiredFunction=null,this.valueFunction=null,this.visibilityFunction=null,this.feature=null,this.field=null,this.fieldElement=null,this.layer=null,this.description=null,this.inputType=null,this.error=null,this.group=null,this.hint=null,this.messages=null,this.name=null}initialize(){this.handles.add(o((()=>this.value),((e,t)=>{if(e!==t){const{feature:e,name:t,value:i}=this;e.setAttribute(t,i)}})))}get _configAllowsEdits(){var e,t,i;const{fieldElement:r,layer:n,name:o}=this;if(l(r))return!1!==r.editable;const s="subtype-group"!==(null==n?void 0:n.type)?null==n||null==(e=n.popupTemplate)||null==(t=e.fieldInfos)?void 0:t.find((({fieldName:e})=>e===o)):null;return null==(i=null==s?void 0:s.isEditable)||i}get _layerFieldAllowsEdits(){const{field:e,layer:t}=this;return(null==t?void 0:t.capabilities.operations.supportsEditing)&&(null==e?void 0:e.editable)}get isUsingValueExpression(){return this._shouldUseValueExpression()}get evaluatedEditableExpression(){const{editableFunction:e}=this;if(r(e))return null;const{arcade:t}=this;return t.arcadeUtils.executeFunction(e,t.arcadeUtils.createExecContext(this.feature))}get evaluatedRequiredExpression(){const{requiredFunction:e}=this;if(r(e))return null;const{arcade:t}=this;return t.arcadeUtils.executeFunction(e,t.arcadeUtils.createExecContext(this.feature))}get evaluatedVisibilityExpression(){const{visibilityFunction:e}=this;if(r(e))return null;const{arcade:t}=this;return t.arcadeUtils.executeFunction(e,t.arcadeUtils.createExecContext(this.feature))}get evaluatedValueExpression(){const{valueFunction:e}=this;if(r(e))return null;const{arcade:t}=this;return t.arcadeUtils.executeFunction(e,t.arcadeUtils.createExecContext(this.feature))}set initialFeature(e){this._set("initialFeature",e),this.notifyChange("valid")}get domain(){var e;const{typeIdField:t}=this.layer,i=t===this.name,r=null==(e=this.field)?void 0:e.domain;if(i&&!r){const{layer:e}=this,t="subtype-group"===e.type?e.sublayers.map((({subtypeCode:e,title:t})=>({id:e,name:t}))):e.types.map((({id:e,name:t})=>({code:e,name:t})));return new d({name:"__internal-type-based-coded-value-domain__",codedValues:t})}const{feature:o}=this,s=t&&this.layer.getFieldDomain(this.name,{feature:o})||r,a=n(this.fieldElement,"domain");return l(a)&&this._isDomainCompatible(a)?a:s}get editable(){var e;return!!this._layerFieldAllowsEdits&&(null!=(e=this.evaluatedEditableExpression)?e:this._configAllowsEdits)}get errorMessage(){return this._toErrorMessage()}get includeTime(){var e;const{fieldElement:t}=this,i=l(t)&&"datetime-picker"===(null==(e=t.input)?void 0:e.type)?t.input.includeTime:void 0;return void 0===i||i}get label(){return l(this.fieldElement)&&this.fieldElement.label||this.field.alias||this.field.name}get maxLength(){const e=-1;if(this.type===V.Date)return e;const{field:t,fieldElement:i}=this,r=null==t?void 0:t.length,n=l(i)&&D(i.input)?i.input.maxLength:NaN;return!isNaN(n)&&n>=e&&(r===e||n<=r)?n:r}get minLength(){const e=-1;if(this.type===V.Date)return e;const{field:t,fieldElement:i}=this,r=null==t?void 0:t.length,n=l(i)&&D(i.input)?i.input.minLength:NaN;return!isNaN(n)&&n>=e&&(r===e||n<=r)?n:e}get required(){var e,t;return!!this.editable&&(!1===(null==(e=this.field)?void 0:e.nullable)||null!=(t=this.evaluatedRequiredExpression)&&t)}get submittable(){return!!this.valid||this.initialFeature.getAttribute(this.field.name)===this.value}get type(){const{field:e}=this;return m(e)?V.Number:y(e)?V.Text:v(e)?V.Date:V.Unsupported}get valid(){const e=this._validate();return this._set("error",e),null===e}get value(){return this._shouldUseValueExpression()?this.evaluatedValueExpression:this.get("_storedValue")}set value(e){this.notifyChange("evaluatedVisibilityExpression"),this.set("_storedValue",e)}get visible(){return!this._isEditorField()&&(l(this.fieldElement)?null==(e=this.evaluatedVisibilityExpression)||e:this._isVisibleByDefault());var e}_isDomainCompatible(e){const{field:t}=this;if("coded-value"===(null==e?void 0:e.type)){const i=typeof e.codedValues[0].code;if("string"===i&&y(t)||"number"===i&&m(t))return!0}return!!("range"===(null==e?void 0:e.type)&&m(t)||v(t))}_validate(){const{domain:e,field:t,initialFeature:i,minLength:l,required:r,type:n,valid:o,value:s}=this,a=r&&null===s,u=void 0!==o;return!a&&i.getAttribute(t.name)===s&&u?null:"text"===n&&l>-1&&"string"==typeof s&&s.length<l?O.TOO_SHORT:e?null!==s||r?p(e,s):null:a?f.INVALID_TYPE:g(t,s)}_isVisibleByDefault(){var e;const t=null==(e=this.field)?void 0:e.type;return"oid"!==t&&"global-id"!==t&&!this._isGeometryField()}_isEditorField(){return E(this.layer).indexOf(this.name)>-1}_isGeometryField(){return b(this.layer).indexOf(this.name)>-1}_shouldUseValueExpression(){return this._layerFieldAllowsEdits&&!this._configAllowsEdits&&l(this.valueFunction)}_toErrorMessage(){const{domain:e,field:t,messages:i,minLength:l,value:r,required:n,type:o}=this,s=this.error;if(n&&null===r)return i.validationErrors.cannotBeNull;if(s===c.VALUE_OUT_OF_RANGE||s===_.OUT_OF_RANGE){const l=h(e)||x(t);return F(i.validationErrors.outsideRange,l,{format:{max:"date"===o?j:l.isInteger?U:T,min:"date"===o?j:l.isInteger?U:T}})}return s===c.INVALID_CODED_VALUE?i.validationErrors.invalidCodedValue:s===f.INVALID_TYPE?i.validationErrors.invalidType:s===O.TOO_SHORT?F(i.validationErrors.tooShort,{min:l}):null}};function D(e){return!!e&&"maxLength"in e}e([a()],A.prototype,"_storedValue",void 0),e([a()],A.prototype,"_configAllowsEdits",null),e([a()],A.prototype,"_layerFieldAllowsEdits",null),e([a()],A.prototype,"arcade",void 0),e([a()],A.prototype,"editableFunction",void 0),e([a()],A.prototype,"requiredFunction",void 0),e([a()],A.prototype,"valueFunction",void 0),e([a()],A.prototype,"isUsingValueExpression",null),e([a()],A.prototype,"visibilityFunction",void 0),e([a()],A.prototype,"evaluatedEditableExpression",null),e([a()],A.prototype,"evaluatedRequiredExpression",null),e([a()],A.prototype,"evaluatedVisibilityExpression",null),e([a()],A.prototype,"evaluatedValueExpression",null),e([a()],A.prototype,"feature",void 0),e([a()],A.prototype,"field",void 0),e([a()],A.prototype,"fieldElement",void 0),e([a()],A.prototype,"initialFeature",null),e([a()],A.prototype,"layer",void 0),e([a({aliasOf:"fieldElement.description"})],A.prototype,"description",void 0),e([a()],A.prototype,"domain",null),e([a()],A.prototype,"editable",null),e([a({aliasOf:"fieldElement.input.type"})],A.prototype,"inputType",void 0),e([a({readOnly:!0})],A.prototype,"error",void 0),e([a({dependsOn:["error","messages","value"]})],A.prototype,"errorMessage",null),e([a()],A.prototype,"group",void 0),e([a({aliasOf:"fieldElement.hint"})],A.prototype,"hint",void 0),e([a()],A.prototype,"includeTime",null),e([a()],A.prototype,"label",null),e([a()],A.prototype,"maxLength",null),e([a()],A.prototype,"minLength",null),e([a()],A.prototype,"messages",void 0),e([a({aliasOf:"field.name"})],A.prototype,"name",void 0),e([a()],A.prototype,"required",null),e([a()],A.prototype,"submittable",null),e([a()],A.prototype,"type",null),e([a()],A.prototype,"valid",null),e([a({value:null})],A.prototype,"value",null),e([a()],A.prototype,"visible",null),A=e([u("esri.widgets.FeatureForm.InputField")],A);const N=A;export{N as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import t from"../../core/Accessor.js";import{HandleOwnerMixin as i}from"../../core/HandleOwner.js";import{isSome as l,isNone as r,get as n}from"../../core/maybe.js";import{watch as o}from"../../core/reactiveUtils.js";import{generateUID as s}from"../../core/uid.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as u}from"../../core/accessorSupport/decorators/subclass.js";import d from"../../layers/support/CodedValueDomain.js";import"../../layers/support/Domain.js";import"../../layers/support/InheritedDomain.js";import"../../layers/support/RangeDomain.js";import{validateDomainValue as p,DomainValidationError as c,getDomainRange as m}from"../../layers/support/domainUtils.js";import{isNumericField as h,isStringField as y,isDateField as f,TypeValidationError as v,validateFieldValue as g,getFeatureEditFields as E,getFeatureGeometryFields as b,NumericRangeValidationError as _,getFieldRange as x}from"../../layers/support/fieldUtils.js";import{substitute as F}from"../../intl/substitute.js";var V,O;!function(e){e.Text="text",e.Number="number",e.Date="date",e.Unsupported="unsupported"}(V||(V={})),function(e){e.TOO_SHORT="length-validation-error::too-short"}(O||(O={}));const U={type:"number"},T={type:"number",intlOptions:{notation:"scientific"}},j={type:"date",intlOptions:{day:"2-digit",month:"2-digit",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}};function A(e){return e>=1e7||e<=-1e7}let D=class extends(i(t)){constructor(e){super(e),this._storedValue=null,this.arcade=null,this.editableFunction=null,this.id=s().toString(),this.requiredFunction=null,this.valueFunction=null,this.visibilityFunction=null,this.feature=null,this.field=null,this.fieldElement=null,this.layer=null,this.description=null,this.inputType=null,this.error=null,this.group=null,this.hint=null,this.messages=null,this.name=null}initialize(){this.handles.add(o((()=>this.value),((e,t)=>{if(e!==t){const{feature:e,name:t,value:i}=this;e.setAttribute(t,i)}})))}get _configAllowsEdits(){var e,t,i;const{fieldElement:r,layer:n,name:o}=this;if(l(r))return!1!==r.editable;const s="subtype-group"!==(null==n?void 0:n.type)?null==n||null==(e=n.popupTemplate)||null==(t=e.fieldInfos)?void 0:t.find((({fieldName:e})=>e===o)):null;return null==(i=null==s?void 0:s.isEditable)||i}get _layerFieldAllowsEdits(){const{field:e,layer:t}=this;return(null==t?void 0:t.capabilities.operations.supportsEditing)&&(null==e?void 0:e.editable)}get isUsingValueExpression(){return this._shouldUseValueExpression()}get evaluatedEditableExpression(){const{editableFunction:e}=this;if(r(e))return null;const{arcade:t}=this;return t.arcadeUtils.executeFunction(e,t.arcadeUtils.createExecContext(this.feature))}get evaluatedRequiredExpression(){const{requiredFunction:e}=this;if(r(e))return null;const{arcade:t}=this;return t.arcadeUtils.executeFunction(e,t.arcadeUtils.createExecContext(this.feature))}get evaluatedVisibilityExpression(){const{visibilityFunction:e}=this;if(r(e))return null;const{arcade:t}=this;return t.arcadeUtils.executeFunction(e,t.arcadeUtils.createExecContext(this.feature))}get evaluatedValueExpression(){const{valueFunction:e}=this;if(r(e))return null;const{arcade:t}=this;return t.arcadeUtils.executeFunction(e,t.arcadeUtils.createExecContext(this.feature))}set initialFeature(e){this._set("initialFeature",e),this.notifyChange("valid")}get domain(){var e;const{typeIdField:t}=this.layer,i=t===this.name,r=null==(e=this.field)?void 0:e.domain;if(i&&!r){const{layer:e}=this,t="subtype-group"===e.type?e.sublayers.map((({subtypeCode:e,title:t})=>({id:e,name:t}))):e.types.map((({id:e,name:t})=>({code:e,name:t})));return new d({name:"__internal-type-based-coded-value-domain__",codedValues:t})}const{feature:o}=this,s=t&&this.layer.getFieldDomain(this.name,{feature:o})||r,a=n(this.fieldElement,"domain");return l(a)&&this._isDomainCompatible(a)?a:s}get editable(){var e;return!!this._layerFieldAllowsEdits&&(null!=(e=this.evaluatedEditableExpression)?e:this._configAllowsEdits)}get errorMessage(){return this._toErrorMessage()}get includeTime(){var e;const{fieldElement:t}=this,i=l(t)&&"datetime-picker"===(null==(e=t.input)?void 0:e.type)?t.input.includeTime:void 0;return void 0===i||i}get label(){return l(this.fieldElement)&&this.fieldElement.label||this.field.alias||this.field.name}get maxLength(){const e=-1;if(this.type===V.Date)return e;const{field:t,fieldElement:i}=this,r=null==t?void 0:t.length,n=l(i)&&N(i.input)?i.input.maxLength:NaN;return!isNaN(n)&&n>=e&&(r===e||n<=r)?n:r}get minLength(){const e=-1;if(this.type===V.Date)return e;const{field:t,fieldElement:i}=this,r=null==t?void 0:t.length,n=l(i)&&N(i.input)?i.input.minLength:NaN;return!isNaN(n)&&n>=e&&(r===e||n<=r)?n:e}get required(){var e,t;return!!this.editable&&(!1===(null==(e=this.field)?void 0:e.nullable)||null!=(t=this.evaluatedRequiredExpression)&&t)}get submittable(){return!!this.valid||this.initialFeature.getAttribute(this.field.name)===this.value}get type(){const{field:e}=this;return h(e)?V.Number:y(e)?V.Text:f(e)?V.Date:V.Unsupported}get valid(){const e=this._validate();return this._set("error",e),null===e}get value(){return this._shouldUseValueExpression()?this.evaluatedValueExpression:this.get("_storedValue")}set value(e){this.notifyChange("evaluatedVisibilityExpression"),this.set("_storedValue",e)}get visible(){return!this._isEditorField()&&(l(this.fieldElement)?null==(e=this.evaluatedVisibilityExpression)||e:this._isVisibleByDefault());var e}_isDomainCompatible(e){const{field:t}=this;if("coded-value"===(null==e?void 0:e.type)){const i=typeof e.codedValues[0].code;if("string"===i&&y(t)||"number"===i&&h(t))return!0}return!!("range"===(null==e?void 0:e.type)&&h(t)||f(t))}_validate(){const{domain:e,field:t,initialFeature:i,minLength:l,required:r,type:n,valid:o,value:s}=this,a=r&&null===s,u=void 0!==o;return!a&&i.getAttribute(t.name)===s&&u?null:"text"===n&&l>-1&&"string"==typeof s&&s.length<l?O.TOO_SHORT:e?null!==s||r?p(e,s):null:a?v.INVALID_TYPE:g(t,s)}_isVisibleByDefault(){var e;const t=null==(e=this.field)?void 0:e.type;return"oid"!==t&&"global-id"!==t&&!this._isGeometryField()}_isEditorField(){return E(this.layer).indexOf(this.name)>-1}_isGeometryField(){return b(this.layer).indexOf(this.name)>-1}_shouldUseValueExpression(){return this._layerFieldAllowsEdits&&!this._configAllowsEdits&&l(this.valueFunction)}_toErrorMessage(){const{domain:e,field:t,messages:i,minLength:l,value:r,required:n,type:o}=this,s=this.error;if(n&&null===r)return i.validationErrors.cannotBeNull;if(s===c.VALUE_OUT_OF_RANGE||s===_.OUT_OF_RANGE){const l=m(e)||x(t);return F(i.validationErrors.outsideRange,l,{format:{max:"date"===o?j:A(l.max)?T:U,min:"date"===o?j:A(l.min)?T:U}})}return s===c.INVALID_CODED_VALUE?i.validationErrors.invalidCodedValue:s===v.INVALID_TYPE?i.validationErrors.invalidType:s===O.TOO_SHORT?F(i.validationErrors.tooShort,{min:l}):null}};function N(e){return!!e&&"maxLength"in e}e([a()],D.prototype,"_storedValue",void 0),e([a()],D.prototype,"_configAllowsEdits",null),e([a()],D.prototype,"_layerFieldAllowsEdits",null),e([a()],D.prototype,"arcade",void 0),e([a()],D.prototype,"editableFunction",void 0),e([a()],D.prototype,"requiredFunction",void 0),e([a()],D.prototype,"valueFunction",void 0),e([a()],D.prototype,"isUsingValueExpression",null),e([a()],D.prototype,"visibilityFunction",void 0),e([a()],D.prototype,"evaluatedEditableExpression",null),e([a()],D.prototype,"evaluatedRequiredExpression",null),e([a()],D.prototype,"evaluatedVisibilityExpression",null),e([a()],D.prototype,"evaluatedValueExpression",null),e([a()],D.prototype,"feature",void 0),e([a()],D.prototype,"field",void 0),e([a()],D.prototype,"fieldElement",void 0),e([a()],D.prototype,"initialFeature",null),e([a()],D.prototype,"layer",void 0),e([a({aliasOf:"fieldElement.description"})],D.prototype,"description",void 0),e([a()],D.prototype,"domain",null),e([a()],D.prototype,"editable",null),e([a({aliasOf:"fieldElement.input.type"})],D.prototype,"inputType",void 0),e([a({readOnly:!0})],D.prototype,"error",void 0),e([a({dependsOn:["error","messages","value"]})],D.prototype,"errorMessage",null),e([a()],D.prototype,"group",void 0),e([a({aliasOf:"fieldElement.hint"})],D.prototype,"hint",void 0),e([a()],D.prototype,"includeTime",null),e([a()],D.prototype,"label",null),e([a()],D.prototype,"maxLength",null),e([a()],D.prototype,"minLength",null),e([a()],D.prototype,"messages",void 0),e([a({aliasOf:"field.name"})],D.prototype,"name",void 0),e([a()],D.prototype,"required",null),e([a()],D.prototype,"submittable",null),e([a()],D.prototype,"type",null),e([a()],D.prototype,"valid",null),e([a({value:null})],D.prototype,"value",null),e([a()],D.prototype,"visible",null),D=e([u("esri.widgets.FeatureForm.InputField")],D);const L=D;export{L as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{neverReached as t}from"../core/compilerUtils.js";import{isNone as i,isSome as a}from"../core/maybe.js";import{aliasOf as n}from"../core/accessorSupport/decorators/aliasOf.js";import"../core/arrayUtils.js";import"../core/has.js";import"../core/accessorSupport/ensureType.js";import{property as l}from"../core/accessorSupport/decorators/property.js";import{subclass as s}from"../core/accessorSupport/decorators/subclass.js";import{getDomainRange as r}from"../layers/support/domainUtils.js";import{getFieldRange as o}from"../layers/support/fieldUtils.js";import u from"./Widget.js";import d from"./FeatureForm/FeatureFormViewModel.js";import{Heading as p,incrementHeadingLevel as c}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as m}from"./support/decorators/messageBundle.js";import"../core/Logger.js";import{vmEvent as h}from"./support/decorators/vmEvent.js";import{tsx as f}from"./support/jsxFactory.js";import{DateTime as _}from"luxon";import{getLocale as v}from"../intl/locale.js";const g={base:"esri-feature-form",form:"esri-feature-form__form",formHeader:"esri-feature-form__form-header",label:"esri-feature-form__label",inputField:"esri-feature-form__input",inputDate:"esri-feature-form__input--date",inputTime:"esri-feature-form__input--time",inputRadioGroup:"esri-feature-form__input--radio-group",inputRadio:"esri-feature-form__input--radio",inputRadioLabel:"esri-feature-form__input--radio-label",inputDisabled:"esri-feature-form__input--disabled",inputSwitch:"esri-feature-form__input--switch",inputInvalid:"esri-feature-form__input--invalid",inputIconInvalid:"esri-feature-form__input-icon--invalid",errorMessage:"esri-feature-form__field-error-message",description:"esri-feature-form__description-text",dateInputPart:"esri-feature-form__date-input-part",loneDateInputPart:"esri-feature-form__date-input-part--lone",dateInputContainer:"esri-feature-form__date-input-container",dateFormatHint:"esri-feature-form__date-format-hint",group:"esri-feature-form__group",groupLabel:"esri-feature-form__group-label",groupHeader:"esri-feature-form__group-header",groupHeading:"esri-feature-form__group-header",groupTitle:"esri-feature-form__group-title",groupDescription:"esri-feature-form__group-description",groupToggleIcon:"esri-feature-form__group-toggle-icon",groupCollapsed:"esri-feature-form__group--collapsed",groupSequential:"esri-feature-form__group--sequential",groupActive:"esri-feature-form__group--active",collapseIcon:"esri-icon-up",errorIcon:"esri-icon-notice-triangle",expandIcon:"esri-icon-down",widget:"esri-widget",panel:"esri-widget--panel",input:"esri-input",select:"esri-select"},b={datePattern:"D",timePattern:"tt"};function y(e){return e&&e.inputFields}let I=class extends u{constructor(e,t){super(e,t),this._activeDateFieldEdit=null,this._activeInputName=null,this._fieldFocusNeeded=!1,this._fieldToInitialIncompatibleDomainValue=new Map,this._switchFieldsWithInitialIncompatibleValue=new Set,this._userUpdatedInputFieldNames=new Set,this.description=null,this.feature=null,this.fieldConfig=null,this.formTemplate=null,this.groupDisplay="all",this.headingLevel=2,this.label=void 0,this.layer=null,this.messages=null,this.messagesTemplates=null,this.strict=null,this.title=null,this.viewModel=new d,this._handleSwitchClick=e=>{e.target===e.currentTarget&&e.stopImmediatePropagation()},this._handleRadioInputChange=e=>{this._commitInputValue(e.target)},this._handleInputInput=e=>{this._commitInputValue(e.currentTarget,!0)},this._handleFormKeyDown=this._handleFormKeyDown.bind(this),this._handleInputBlur=this._handleInputBlur.bind(this),this._handleInputFocus=this._handleInputFocus.bind(this),this._handleNumberInputMouseDown=this._handleNumberInputMouseDown.bind(this),this._handleInputKeyDown=this._handleInputKeyDown.bind(this),this._handleOptionChange=this._handleOptionChange.bind(this),this._handleGroupClick=this._handleGroupClick.bind(this),this._handleSubmit=this._handleSubmit.bind(this),this._afterInputCreateOrUpdate=this._afterInputCreateOrUpdate.bind(this)}initialize(){this.own(this.watch("feature",(()=>{const e=this._getFocusableInput("forward");this._activeInputName=e&&e.name,this._userUpdatedInputFieldNames.clear(),this._fieldToInitialIncompatibleDomainValue.clear(),this._switchFieldsWithInitialIncompatibleValue.clear(),this._fieldFocusNeeded=!0})),this.on("submit",(e=>{if(e.invalid.length>0){const[t]=e.invalid;e.invalid.forEach((e=>this._userUpdatedInputFieldNames.add(e))),this._activeInputName=t,this._fieldFocusNeeded=!0,this.scheduleRender()}})))}loadDependencies(){return Promise.all([import("@esri/calcite-components/dist/components/calcite-combobox.js"),import("@esri/calcite-components/dist/components/calcite-combobox-item.js"),import("@esri/calcite-components/dist/components/calcite-combobox-item-group.js"),import("@esri/calcite-components/dist/components/calcite-input-message.js"),import("@esri/calcite-components/dist/components/calcite-switch.js")])}destroy(){this._userUpdatedInputFieldNames.clear(),this._userUpdatedInputFieldNames=null}getValues(){return null}submit(){return null}render(){const{state:e}=this.viewModel;return f("div",{class:this.classes(g.base,g.widget,g.panel)},"ready"===e?this.renderForm():null)}renderForm(){const e=this.title?f(p,{key:"title",level:this.headingLevel},this.title):null,t=this.description?f("p",{class:g.description,key:"description"},this.description):null,i=e||t?f("div",{class:g.formHeader},e,t):null;return f("form",{class:g.form,novalidate:!0,onsubmit:this._handleSubmit,onkeydown:this._handleFormKeyDown},i,this.renderFields())}renderFields(){const{viewModel:{inputFields:e}}=this;return e.map(((e,t)=>y(e)?this.renderGroup(e,t):this.renderLabeledField(e)))}renderGroup(e,t){const{description:i,inputFields:a,label:n,state:l}=e,s=this.viewModel.findField(this._activeInputName),r=!(!s||s.group!==e),o=`${this.id}_group_${t}`,u=`${this.id}_group-label_${t}`,d=`${this.id}_group-description_${t}`,m=i?f("p",{class:this.classes(g.groupDescription,g.description),id:d},i):null,h="sequential"===this.groupDisplay,_=h?r:"expanded"===l,v=_?g.collapseIcon:g.expandIcon;return f("fieldset",{"aria-expanded":_.toString(),"aria-labelledby":u,"aria-describedby":i?d:"",class:this.classes(g.group,h?g.groupSequential:null,_?null:g.groupCollapsed,r?g.groupActive:null),"data-group":e,id:o,key:t,onclick:this._handleGroupClick},f("button",{role:h?"presentation":void 0,class:g.groupHeader,type:"button",tabIndex:h?-1:0},f("div",{class:g.groupTitle},f(p,{class:g.groupLabel,id:u,level:this.title?c(this.headingLevel):this.headingLevel},n),m),h?null:f("span",{class:this.classes(v,g.groupToggleIcon)})),a.map((e=>this.renderLabeledField(e))))}_getFocusableInput(e,t){const i=this.viewModel.allInputFields,a="forward"===e?i:i.slice().reverse();let n;if(t)if(y(t))n=a.indexOf(t.inputFields[0]);else{let i;if(this._isInputFieldInGroup(t)&&"collapsed"===t.group.state){const{inputFields:a}=t.group;i="forward"===e?a[a.length-1]:a[0]}else i=t;n=a.indexOf(i)+1}else n=0;for(let l=n;l<a.length;l++){const e=a[l];if(e.visible)return e}return null}renderLabeledField(e){const{label:t,layer:i,type:a}=e;return f("label",{key:`${i.id}-${e.name}`,class:g.label},[t,"unsupported"!==a?this.renderInputField(e):this.renderUnsupportedField(e),this.renderAuxiliaryText(e)])}renderInputField(e){const{domain:t,name:i,type:a,value:n}=e,l=this.getCommonInputProps(e);if("coded-value"===(null==t?void 0:t.type)){if(this._inputFieldHasInputType(e,"switch")){const{fieldElement:t}=e;if(!(this._switchFieldsWithInitialIncompatibleValue.has(i)||null==n||t.input.onValue!==n&&t.input.offValue!==n))return this.renderSwitchInputField(n,l);this._switchFieldsWithInitialIncompatibleValue.add(i)}return"radio-buttons"===e.inputType?this.renderRadioButtonsInputField(n,t.codedValues.map((({code:e,name:t})=>({value:e,name:t}))),l):this.renderSelectInputField(n,this._getFieldValueOptions(i,t),l)}return"text"===a&&"text-area"===e.inputType?f("textarea",{...l}):"datetime-picker"===e.inputType||"date"===a?this.renderDateInputField(n,l):f("input",{type:"text"===a?"text":"number",...l})}_parseDateTime(e,t,i){if(i){var a;let n=_.fromJSDate(this._parseDate(e,i));const l=_.fromMillis(null!=(a=t.value)?a:Date.now());return n="date"===i?n.set({hour:l.hour,minute:l.minute,second:l.second}):n.set({day:l.day,month:l.month,year:l.year}),n.isValid?n.toMillis():null}const n=_.fromJSDate(this._parseDate(e));return n.isValid?n.toMillis():null}renderDateInputField(e,t){const{date:i,time:a}=this._formatDate(0),n=`${this.id}-${t.key}`,l=`${n}-date`,s=`${n}-time`,r=t["data-field"],{includeTime:o}=r,{_activeDateFieldEdit:u}=this;let{date:d,time:p}=this._formatDate(e);var c,m,h,_;(null==u?void 0:u.fieldName)===r.name&&(d=null!=(c=null==(m=u.date.input)?void 0:m.value)?c:d,p=null!=(h=null==(_=u.time.input)?void 0:_.value)?h:p);return f("div",{key:`${t.key}-date`,class:g.dateInputContainer},f("div",{class:this.classes(g.dateInputPart,o?null:g.loneDateInputPart)},f("input",{"aria-label":r.label,"aria-describedby":l,type:"text",...t,"data-date-part":"date",class:this.classes(t.class,g.inputDate),value:d}),f("div",{class:g.dateFormatHint,id:l},i)),o?f("div",{class:g.dateInputPart,key:"time-input"},f("input",{"aria-describedby":s,"aria-label":r.label,type:"text",...t,"data-date-part":"time",class:this.classes(t.class,g.inputTime),value:p}),f("div",{class:g.dateFormatHint,id:s},a)):null)}renderUnsupportedField(e){const t=this.getCommonInputProps(e);return f("input",{afterCreate:t.afterCreate,afterUpdate:t.afterUpdate,class:this.classes(g.input,g.inputField,g.inputDisabled),"data-field":t["data-field"],onfocus:t.onfocus,readOnly:!0,tabIndex:t.tabIndex,type:"text",value:t.value})}renderSelectInputField(e,t,a){const{messages:n,messagesTemplates:l}=this,s=t.map((t=>t.map((t=>f("calcite-combobox-item",{value:t.value,"text-label":t.name,key:t.value,selected:e===t.value}))))),r=a["data-field"],[o,u]=s;this._registerIncompatibleValue(e,t.flat(),r,(e=>{u.unshift(f("calcite-combobox-item",{value:`${e}`,"text-label":`${e}`,key:"incompatible-option",readOnly:!0}))}));const d=u.length>0?[f("calcite-combobox-item-group",{key:"recommended",label:n.recommended},o),f("calcite-combobox-item-group",{key:"other",label:l.other},u)]:o,p=i(r.fieldElement)||this._inputFieldHasInputType(r,"combo-box")&&r.fieldElement.input.showNoValueOption;if(!r.required&&p){const e="",t=this._inputFieldHasInputType(r,"combo-box")&&r.fieldElement.input.noValueOptionLabel||this.messages.empty;d.unshift(f("calcite-combobox-item",{value:e,"text-label":this.messages.empty,key:"empty-option"},t))}return f("calcite-combobox",{...a,"selection-mode":"single",disabled:a.readOnly,allowCustomValues:!1,onCalciteComboboxChange:e=>this._handleOptionChange(e.target)},d)}_registerIncompatibleValue(e,t,i,a){const n=this._fieldToInitialIncompatibleDomainValue,l=n.has(i.name);(l||null!=e&&""!==e&&!t.find((t=>t.value===e))||l)&&(l||n.set(i.name,e),null==a||a(n.get(i.name)))}renderRadioButtonsInputField(e,t,a){const n=a["data-field"],l=t.map((t=>this.renderRadioButton({key:t.name,label:t.name,name:n.name,value:t.value,selected:t.value===e,props:a})));this._registerIncompatibleValue(e,t,n);const s=i(n.fieldElement)||this._inputFieldHasInputType(n,"radio-buttons")&&n.fieldElement.input.showNoValueOption;if(!n.required&&s){const t="",i=this._inputFieldHasInputType(n,"radio-buttons")&&n.fieldElement.input.noValueOptionLabel||this.messages.empty,s=e===t||null===e;l.unshift(this.renderRadioButton({key:"empty-option",label:i,name:n.name,value:t,selected:s,props:a}))}return f("div",{key:`${a.key}-radio`,class:g.inputRadioGroup},l)}renderSwitchInputField(e,t){const i=t["data-field"],a=!!this._inputFieldHasInputType(i,"switch")&&e===i.fieldElement.input.onValue;return f("calcite-switch",{...t,class:g.inputSwitch,onclick:this._handleSwitchClick,checked:a,disabled:t.readOnly})}renderRadioButton({key:e,name:t,value:i,selected:a,label:n,props:l}){return f("label",{key:e,class:g.inputRadioLabel},f("input",{...l,class:g.inputRadio,name:t,type:"radio",value:i,checked:a,onchange:this._handleRadioInputChange}),n)}renderAuxiliaryText(e){const t=this._userUpdatedInputFieldNames.has(e.name)&&!e.valid?e.errorMessage:a(this.viewModel.contingencyConstraintViolations.get(e.name))?this.messages.validationErrors.valuesIncompatible:null;return a(t)?f("calcite-input-message",{status:"invalid",icon:!0,active:!0},t):e.description?f("div",{key:"description",class:g.description},e.description):void 0}getCommonInputProps(e){const{groupDisplay:t}=this,{editable:i,group:n,hint:l,maxLength:s,minLength:r,name:o,required:u,type:d,valid:p,value:c}=e,m=this._userUpdatedInputFieldNames.has(o),h=!i,f="all"===t&&a(n)&&"collapsed"===n.state;return{afterCreate:this._afterInputCreateOrUpdate,afterUpdate:this._afterInputCreateOrUpdate,"aria-invalid":p?"false":"true",class:this.classes(g.input,g.inputField,h?g.inputDisabled:null,m&&!p?g.inputInvalid:null),key:o,label:o,minlength:r>-1?`${r}`:"",maxlength:s>-1?`${s}`:"",...this._getNumberFieldConstraints(e),readOnly:h,value:null==c?"":`${c}`,"data-field":e,onfocus:this._handleInputFocus,oninput:this._handleInputInput,onblur:this._handleInputBlur,onkeydown:this._handleInputKeyDown,onmousedown:"number"===d?this._handleNumberInputMouseDown:null,placeholder:"number"===d||"text"===d?l:"",required:u,tabIndex:f?-1:0}}_isInputFieldInGroup(e){return!y(e)&&a(e.group)}_handleNumberInputMouseDown({target:e}){e.focus(),this.scheduleRender()}_getFieldValueOptions(e,t){const i=t.codedValues.map((({code:e,name:t})=>({value:e,name:t}))),a=this.viewModel.fieldsWithContingentValues.has(e)?this._getContingentValueOptions(e):[];if(a.length>0){const e=new Set(a.map((e=>e.value)));return[a,i.filter((t=>!e.has(t.value)))]}return[i,[]]}_getContingentValueOptions(e){const t={};for(const l of this.viewModel.allInputFields){const{name:a,value:n}=l;!i(n)&&a!==e&&this.viewModel.fieldsWithContingentValues.has(a)&&(t[a]=n)}const a=this.viewModel.joinedContingentValues.slice(),n=new Map;for(const l of a){const a=l.values[e];if(i(a)||"code"!==a.objectType&&"null"!==a.objectType)continue;const{code:s,name:r}="null"===a.objectType?{code:"",name:this.messages.empty}:a.codedValue;if(n.has(s))continue;Object.entries(t).every((([e,t])=>!l.values.hasOwnProperty(e)||this._valueIsValidContingentValue(t,l.values[e])))&&n.set(s,{name:r,value:s})}return[...n.values()]}_getNumberFieldConstraints(e){const t=r(e.domain)||o(e.field);return t&&t.max!==Number.MAX_VALUE&&t.min!==Number.MIN_VALUE?t:{min:null,max:null}}_afterInputCreateOrUpdate(e){const t=e["data-field"],i=this.viewModel.findField(this._activeInputName),a=this._fieldToInitialIncompatibleDomainValue.get(t.name)===t.value;this._fieldFocusNeeded&&i===t&&("radio-buttons"!==t.inputType||a||e.checked)&&(this._fieldFocusNeeded=!1,e.focus())}_handleInputFocus(e){const t=e.target,i=t["data-field"];this._activeInputName=i.name,"date"===i.type&&this._syncDateFieldEdits(t)}_handleInputBlur(e){const t=e.target,i=t["data-field"];if("date"===i.type){const n=e.relatedTarget,l=n&&n["data-field"];if(l&&"date"===i.type&&"date"===l.type&&i.field===l.field){if(""!==t.value&&""===n.value){var a;const l=n.getAttribute("data-date-part");n.value=this._formatDate(null!=(a=i.value)?a:Date.now())[l],this._parseDate(t.value,t.getAttribute("data-date-part"))&&this._commitInputValue(e.target,!0,!1)}return}}this._commitInputValue(t),this.scheduleRender()}_commitInputValue(e,t=!1,i=!0){const a=e["data-field"];if(this._activeDateFieldEdit){const{date:o,time:u}=this._activeDateFieldEdit,d=this._parseDateTime(e.value,a,o.active?"date":"time"),p=null!==this.viewModel.getValue(a.name),c=o.input&&(u.input||!a.includeTime),m=null===d;if(t){if(m)return;(c||!i||p)&&this._updateDateFieldValue(a,d)}else{var n,l;if(""===(null==(n=o.input)?void 0:n.value)||""===(null==(l=u.input)?void 0:l.value))this._updateDateFieldValue(a,null);else if(c){var s,r;const e=`${o.input.value} ${null!=(s=null==(r=u.input)?void 0:r.value)?s:""}`,t=this._parseDateTime(e,a);!(null!==t)&&p||this._updateDateFieldValue(a,t)}this._activeDateFieldEdit=null}}else this._updateFieldValue(e)}_handleInputKeyDown(e){const{key:t,altKey:i,ctrlKey:a,metaKey:n}=e,l=e.target["data-field"];if("Enter"===t)this._isInputFieldInGroup(l)&&"collapsed"===l.group.state&&(l.group.state="expanded");else{const{type:s}=l.field,r="single"===s||"double"===s,o=!i&&!a&&!n;if(("integer"===s||"small-integer"===s||r)&&o&&1===t.length){const i=Number(t),a=["-","+"],n=["e","."],l=r?[...a,...n]:a;isNaN(i)&&-1===l.indexOf(t)&&e.preventDefault()}}}_syncDateFieldEdits(e){var t,i;const a=e["data-field"];if("date"!==a.type)return;const n=e.getAttribute("data-date-part"),l="date"===n?{value:e.value,input:e,active:!0}:{...null==(t=this._activeDateFieldEdit)?void 0:t.date,active:!1},s="time"===n?{value:e.value,input:e,active:!0}:{...null==(i=this._activeDateFieldEdit)?void 0:i.time,active:!1};this._activeDateFieldEdit={fieldName:a.name,date:l,time:s}}_updateFieldValue(e){const t=e["data-field"],{name:i}=t;if(this.viewModel.setValue(i,this._parseValue(e)),this._userUpdatedInputFieldNames.add(i),this.viewModel.fieldsWithContingentValues.has(i)){const e=Object.fromEntries(Object.entries(this.getValues()).filter((([e,t])=>a(t))));this.viewModel.validateContingencyConstraints(e)}}_updateDateFieldValue(e,t){this.viewModel.setValue(e.name,t),this._userUpdatedInputFieldNames.add(e.name)}_parseValue(e){const t=e["data-field"],i=e.value;if(this._inputFieldHasInputType(t,"switch")&&!(e instanceof HTMLCalciteComboboxElement))return e.checked?t.fieldElement.input.onValue:t.fieldElement.input.offValue;if("radio-buttons"===t.inputType&&"radio"===e.type&&!e.checked)return t.value;const{type:a}=t;if("number"===a)return i?parseFloat(i):null;if("date"===a){if(!i)return null;const a=Number(i);if(!isNaN(a))return a;const n=e.getAttribute("data-date-part"),l=this._parseDate(i,n);if(!l)return null;let s=_.fromJSDate(l);const r=t.domain,o=_.now();let u=o;if(r&&"range"===r.type){const e=_.fromMillis(r.maxValue);o<e&&(u=e)}const d=this.viewModel.getValue(t.name),p=null!=d?_.fromMillis(d):u;return s="date"===n?s.set({hour:p.hour,minute:p.minute,second:p.second}):s.set({day:p.day,month:p.month,year:p.year}),s.toMillis()}return i}_handleOptionChange(e){this._commitInputValue(e),this.scheduleRender()}_handleGroupClick(e){var t;const i=e.currentTarget["data-group"],a="expanded"===i.state,n="sequential"===this.groupDisplay,l=`.${g.groupHeader}`;if(!(a&&!e.target.closest(l))){if(this._activeInputName=null==(t=this._getFocusableInput("forward",i))?void 0:t.name,n){const t=e.target.closest(l);if(a&&!t)return;this.viewModel.inputFields.forEach((e=>{y(e)&&e!==i&&(e.state="collapsed")}))}i.state=a?"collapsed":"expanded",this._fieldFocusNeeded=n,this.scheduleRender()}}_handleSubmit(e){e.preventDefault()}_handleFormKeyDown(e){"Enter"===e.key&&this.viewModel.submit()}_formatDate(e){if(null==e)return{date:"",time:""};const t=_.fromMillis(e,{locale:v(),numberingSystem:"latn"});return{date:t.toLocaleString({year:"numeric",month:"2-digit",day:"2-digit"}),time:t.toFormat(b.timePattern)}}_parseDate(e,t){if(null==e||""===e)return null;const{timePattern:i,datePattern:a}=b,n=t?"date"===t?a:i:`${a} ${i}`,l=_.fromFormat(e,n,{locale:v(),numberingSystem:"latn"});return l.isValid?l.toJSDate():null}_inputFieldHasInputType(e,t){var i;return a(e.fieldElement)&&(null==(i=e.fieldElement.input)?void 0:i.type)===t}_valueIsValidContingentValue(e,i){var a;switch(i.objectType){case"any":return!0;case"null":return null==e;case"code":return e===(null==(a=i.codedValue)?void 0:a.code);case"range":return e>=i.minValue&&e<=i.maxValue;default:return t(i.objectType),!1}}};e([n("viewModel.description")],I.prototype,"description",void 0),e([n("viewModel.feature")],I.prototype,"feature",void 0),e([n("viewModel.fieldConfig")],I.prototype,"fieldConfig",void 0),e([n("viewModel.formTemplate")],I.prototype,"formTemplate",void 0),e([l()],I.prototype,"groupDisplay",void 0),e([l()],I.prototype,"headingLevel",void 0),e([l({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],I.prototype,"label",void 0),e([n("viewModel.layer")],I.prototype,"layer",void 0),e([l(),m("esri/widgets/FeatureForm/t9n/FeatureForm")],I.prototype,"messages",void 0),e([l(),m("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],I.prototype,"messagesTemplates",void 0),e([n("viewModel.strict")],I.prototype,"strict",void 0),e([n("viewModel.title")],I.prototype,"title",void 0),e([l(),h(["value-change","submit"])],I.prototype,"viewModel",void 0),e([n("viewModel.getValues")],I.prototype,"getValues",null),e([n("viewModel.submit")],I.prototype,"submit",null),I=e([s("esri.widgets.FeatureForm")],I);const F=I;export{F as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{neverReached as t}from"../core/compilerUtils.js";import{isNone as i,isSome as a}from"../core/maybe.js";import{aliasOf as n}from"../core/accessorSupport/decorators/aliasOf.js";import"../core/arrayUtils.js";import"../core/has.js";import"../core/accessorSupport/ensureType.js";import{property as l}from"../core/accessorSupport/decorators/property.js";import{subclass as s}from"../core/accessorSupport/decorators/subclass.js";import{getDomainRange as r}from"../layers/support/domainUtils.js";import{getFieldRange as o}from"../layers/support/fieldUtils.js";import u from"./Widget.js";import d from"./FeatureForm/FeatureFormViewModel.js";import{Heading as p,incrementHeadingLevel as c}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as m}from"./support/decorators/messageBundle.js";import"../core/Logger.js";import{vmEvent as h}from"./support/decorators/vmEvent.js";import{tsx as f}from"./support/jsxFactory.js";import{DateTime as _}from"luxon";import{getLocale as v}from"../intl/locale.js";const g={base:"esri-feature-form",form:"esri-feature-form__form",formHeader:"esri-feature-form__form-header",label:"esri-feature-form__label",inputField:"esri-feature-form__input",inputDate:"esri-feature-form__input--date",inputTime:"esri-feature-form__input--time",inputRadioGroup:"esri-feature-form__input--radio-group",inputRadio:"esri-feature-form__input--radio",inputRadioLabel:"esri-feature-form__input--radio-label",inputDisabled:"esri-feature-form__input--disabled",inputSwitch:"esri-feature-form__input--switch",inputInvalid:"esri-feature-form__input--invalid",inputIconInvalid:"esri-feature-form__input-icon--invalid",errorMessage:"esri-feature-form__field-error-message",description:"esri-feature-form__description-text",dateInputPart:"esri-feature-form__date-input-part",loneDateInputPart:"esri-feature-form__date-input-part--lone",dateInputContainer:"esri-feature-form__date-input-container",dateFormatHint:"esri-feature-form__date-format-hint",group:"esri-feature-form__group",groupLabel:"esri-feature-form__group-label",groupHeader:"esri-feature-form__group-header",groupHeading:"esri-feature-form__group-header",groupTitle:"esri-feature-form__group-title",groupDescription:"esri-feature-form__group-description",groupToggleIcon:"esri-feature-form__group-toggle-icon",groupCollapsed:"esri-feature-form__group--collapsed",groupSequential:"esri-feature-form__group--sequential",groupActive:"esri-feature-form__group--active",collapseIcon:"esri-icon-up",errorIcon:"esri-icon-notice-triangle",expandIcon:"esri-icon-down",widget:"esri-widget",panel:"esri-widget--panel",input:"esri-input",select:"esri-select"},b={datePattern:"D",timePattern:"tt"};function y(e){return e&&e.inputFields}let I=class extends u{constructor(e,t){super(e,t),this._activeDateFieldEdit=null,this._activeInputName=null,this._fieldFocusNeeded=!1,this._fieldToInitialIncompatibleDomainValue=new Map,this._switchFieldsWithInitialIncompatibleValue=new Set,this._userUpdatedInputFieldNames=new Set,this.description=null,this.feature=null,this.fieldConfig=null,this.formTemplate=null,this.groupDisplay="all",this.headingLevel=2,this.label=void 0,this.layer=null,this.messages=null,this.messagesTemplates=null,this.strict=null,this.title=null,this.viewModel=new d,this._handleSwitchClick=e=>{e.target===e.currentTarget&&e.stopImmediatePropagation()},this._handleRadioInputChange=e=>{this._commitInputValue(e.target)},this._handleInputInput=e=>{this._commitInputValue(e.currentTarget,!0)},this._handleFormKeyDown=this._handleFormKeyDown.bind(this),this._handleInputBlur=this._handleInputBlur.bind(this),this._handleInputFocus=this._handleInputFocus.bind(this),this._handleNumberInputMouseDown=this._handleNumberInputMouseDown.bind(this),this._handleInputKeyDown=this._handleInputKeyDown.bind(this),this._handleOptionChange=this._handleOptionChange.bind(this),this._handleGroupClick=this._handleGroupClick.bind(this),this._handleSubmit=this._handleSubmit.bind(this),this._afterInputCreateOrUpdate=this._afterInputCreateOrUpdate.bind(this)}initialize(){this.own(this.watch("feature",(()=>{const e=this._getFocusableInput("forward");this._activeInputName=e&&e.name,this._userUpdatedInputFieldNames.clear(),this._fieldToInitialIncompatibleDomainValue.clear(),this._switchFieldsWithInitialIncompatibleValue.clear(),this._fieldFocusNeeded=!0})),this.on("submit",(e=>{if(e.invalid.length>0){const[t]=e.invalid;e.invalid.forEach((e=>this._userUpdatedInputFieldNames.add(e))),this._activeInputName=t,this._fieldFocusNeeded=!0,this.scheduleRender()}})))}loadDependencies(){return Promise.all([import("@esri/calcite-components/dist/components/calcite-combobox.js"),import("@esri/calcite-components/dist/components/calcite-combobox-item.js"),import("@esri/calcite-components/dist/components/calcite-combobox-item-group.js"),import("@esri/calcite-components/dist/components/calcite-input-message.js"),import("@esri/calcite-components/dist/components/calcite-switch.js")])}destroy(){this._userUpdatedInputFieldNames.clear(),this._userUpdatedInputFieldNames=null}getValues(){return null}submit(){return null}render(){const{state:e}=this.viewModel;return f("div",{class:this.classes(g.base,g.widget,g.panel)},"ready"===e?this.renderForm():null)}renderForm(){const e=this.title?f(p,{key:"title",level:this.headingLevel},this.title):null,t=this.description?f("p",{class:g.description,key:"description"},this.description):null,i=e||t?f("div",{class:g.formHeader},e,t):null;return f("form",{class:g.form,novalidate:!0,onsubmit:this._handleSubmit,onkeydown:this._handleFormKeyDown},i,this.renderFields())}renderFields(){const{viewModel:{inputFields:e}}=this;return e.map(((e,t)=>y(e)?this.renderGroup(e,t):this.renderLabeledField(e)))}renderGroup(e,t){const{description:i,inputFields:a,label:n,state:l}=e,s=this.viewModel.findField(this._activeInputName),r=!(!s||s.group!==e),o=`${this.id}_group_${t}`,u=`${this.id}_group-label_${t}`,d=`${this.id}_group-description_${t}`,m=i?f("p",{class:this.classes(g.groupDescription,g.description),id:d},i):null,h="sequential"===this.groupDisplay,_=h?r:"expanded"===l,v=_?g.collapseIcon:g.expandIcon;return f("fieldset",{"aria-expanded":_.toString(),"aria-labelledby":u,"aria-describedby":i?d:"",class:this.classes(g.group,h?g.groupSequential:null,_?null:g.groupCollapsed,r?g.groupActive:null),"data-group":e,id:o,key:t,onclick:this._handleGroupClick},f("button",{role:h?"presentation":void 0,class:g.groupHeader,type:"button",tabIndex:h?-1:0},f("div",{class:g.groupTitle},f(p,{class:g.groupLabel,id:u,level:this.title?c(this.headingLevel):this.headingLevel},n),m),h?null:f("span",{class:this.classes(v,g.groupToggleIcon)})),a.map((e=>this.renderLabeledField(e))))}_getFocusableInput(e,t){const i=this.viewModel.allInputFields,a="forward"===e?i:i.slice().reverse();let n;if(t)if(y(t))n=a.indexOf(t.inputFields[0]);else{let i;if(this._isInputFieldInGroup(t)&&"collapsed"===t.group.state){const{inputFields:a}=t.group;i="forward"===e?a[a.length-1]:a[0]}else i=t;n=a.indexOf(i)+1}else n=0;for(let l=n;l<a.length;l++){const e=a[l];if(e.visible)return e}return null}renderLabeledField(e){const{label:t,layer:i,type:a}=e;return f("label",{key:`${i.id}-${e.name}`,class:g.label},[t,"unsupported"!==a?this.renderInputField(e):this.renderUnsupportedField(e),this.renderAuxiliaryText(e)])}renderInputField(e){const{domain:t,name:i,type:a,value:n}=e,l=this.getCommonInputProps(e);if("coded-value"===(null==t?void 0:t.type)){if(this._inputFieldHasInputType(e,"switch")){const{fieldElement:t}=e;if(!(this._switchFieldsWithInitialIncompatibleValue.has(i)||null==n||t.input.onValue!==n&&t.input.offValue!==n))return this.renderSwitchInputField(n,l);this._switchFieldsWithInitialIncompatibleValue.add(i)}return"radio-buttons"===e.inputType?this.renderRadioButtonsInputField(n,t.codedValues.map((({code:e,name:t})=>({value:e,name:t}))),l):this.renderSelectInputField(n,this._getFieldValueOptions(i,t),l)}return"text"===a&&"text-area"===e.inputType?f("textarea",{...l}):"datetime-picker"===e.inputType||"date"===a?this.renderDateInputField(n,l):f("input",{type:"text"===a?"text":"number",...l})}_parseDateTime(e,t,i){if(i){var a;let n=_.fromJSDate(this._parseDate(e,i));const l=_.fromMillis(null!=(a=t.value)?a:Date.now());return n="date"===i?n.set({hour:l.hour,minute:l.minute,second:l.second}):n.set({day:l.day,month:l.month,year:l.year}),n.isValid?n.toMillis():null}const n=_.fromJSDate(this._parseDate(e));return n.isValid?n.toMillis():null}renderDateInputField(e,t){const{date:i,time:a}=this._formatDate(0),n=`${this.id}-${t.key}`,l=`${n}-date`,s=`${n}-time`,r=t["data-field"],{includeTime:o}=r,{_activeDateFieldEdit:u}=this;let{date:d,time:p}=this._formatDate(e);var c,m,h,_;(null==u?void 0:u.fieldName)===r.name&&(d=null!=(c=null==(m=u.date.input)?void 0:m.value)?c:d,p=null!=(h=null==(_=u.time.input)?void 0:_.value)?h:p);return f("div",{key:`${t.key}-date`,class:g.dateInputContainer},f("div",{class:this.classes(g.dateInputPart,o?null:g.loneDateInputPart)},f("input",{"aria-label":r.label,"aria-describedby":l,type:"text",...t,"data-date-part":"date",class:this.classes(t.class,g.inputDate),value:d}),f("div",{class:g.dateFormatHint,id:l},i)),o?f("div",{class:g.dateInputPart,key:"time-input"},f("input",{"aria-describedby":s,"aria-label":r.label,type:"text",...t,"data-date-part":"time",class:this.classes(t.class,g.inputTime),value:p}),f("div",{class:g.dateFormatHint,id:s},a)):null)}renderUnsupportedField(e){const t=this.getCommonInputProps(e);return f("input",{afterCreate:t.afterCreate,afterUpdate:t.afterUpdate,class:this.classes(g.input,g.inputField,g.inputDisabled),"data-field":t["data-field"],onfocus:t.onfocus,readOnly:!0,tabIndex:t.tabIndex,type:"text",value:t.value})}renderSelectInputField(e,t,a){const{messages:n,messagesTemplates:l}=this,s=t.map((t=>t.map((t=>f("calcite-combobox-item",{value:t.value,"text-label":t.name,key:t.value,selected:e===t.value}))))),r=a["data-field"],[o,u]=s;this._registerIncompatibleValue(e,t.flat(),r,(e=>{u.unshift(f("calcite-combobox-item",{value:`${e}`,"text-label":`${e}`,key:"incompatible-option",readOnly:!0}))}));const d=u.length>0?[f("calcite-combobox-item-group",{key:"recommended",label:n.recommended},o),f("calcite-combobox-item-group",{key:"other",label:l.other},u)]:o,p=i(r.fieldElement)||this._inputFieldHasInputType(r,"combo-box")&&r.fieldElement.input.showNoValueOption;if(!r.required&&p){const e="",t=this._inputFieldHasInputType(r,"combo-box")&&r.fieldElement.input.noValueOptionLabel||this.messages.empty;d.unshift(f("calcite-combobox-item",{value:e,"text-label":this.messages.empty,key:"empty-option"},t))}return f("calcite-combobox",{...a,"selection-mode":"single",disabled:a.readOnly,allowCustomValues:!1,onCalciteComboboxChange:e=>this._handleOptionChange(e.target)},d)}_registerIncompatibleValue(e,t,i,a){const n=this._fieldToInitialIncompatibleDomainValue,l=n.has(i.name);(l||null!=e&&""!==e&&!t.find((t=>t.value===e))||l)&&(l||n.set(i.name,e),null==a||a(n.get(i.name)))}renderRadioButtonsInputField(e,t,a){const n=a["data-field"],l=t.map((t=>this.renderRadioButton({key:t.name,label:t.name,name:n.name,value:t.value,selected:t.value===e,props:a})));this._registerIncompatibleValue(e,t,n);const s=i(n.fieldElement)||this._inputFieldHasInputType(n,"radio-buttons")&&n.fieldElement.input.showNoValueOption;if(!n.required&&s){const t="",i=this._inputFieldHasInputType(n,"radio-buttons")&&n.fieldElement.input.noValueOptionLabel||this.messages.empty,s=e===t||null===e;l.unshift(this.renderRadioButton({key:"empty-option",label:i,name:n.name,value:t,selected:s,props:a}))}return f("div",{key:`${a.key}-radio`,class:g.inputRadioGroup},l)}renderSwitchInputField(e,t){const i=t["data-field"],a=!!this._inputFieldHasInputType(i,"switch")&&e===i.fieldElement.input.onValue;return f("calcite-switch",{...t,class:g.inputSwitch,onclick:this._handleSwitchClick,checked:a,disabled:t.readOnly})}renderRadioButton({key:e,name:t,value:i,selected:a,label:n,props:l}){return f("label",{key:e,class:g.inputRadioLabel},f("input",{...l,class:g.inputRadio,name:t,type:"radio",value:i,checked:a,onchange:this._handleRadioInputChange}),n)}renderAuxiliaryText(e){const t=this._userUpdatedInputFieldNames.has(e.name)&&!e.valid?e.errorMessage:a(this.viewModel.contingencyConstraintViolations.get(e.name))?this.messages.validationErrors.valuesIncompatible:null;return a(t)?f("calcite-input-message",{status:"invalid",icon:!0,active:!0},t):e.description?f("div",{key:"description",class:g.description},e.description):void 0}getCommonInputProps(e){const{groupDisplay:t}=this,{editable:i,group:n,hint:l,maxLength:s,minLength:r,name:o,required:u,type:d,valid:p,value:c}=e,m=this._userUpdatedInputFieldNames.has(o),h=!i,f="all"===t&&a(n)&&"collapsed"===n.state;return{afterCreate:this._afterInputCreateOrUpdate,afterUpdate:this._afterInputCreateOrUpdate,"aria-invalid":p?"false":"true",class:this.classes(g.input,g.inputField,h?g.inputDisabled:null,m&&!p?g.inputInvalid:null),key:o,label:o,minlength:r>-1?`${r}`:"",maxlength:s>-1?`${s}`:"",...this._getNumberFieldConstraints(e),readOnly:h,value:null==c?"":`${c}`,"data-field":e,onfocus:this._handleInputFocus,oninput:this._handleInputInput,onblur:this._handleInputBlur,onkeydown:this._handleInputKeyDown,onmousedown:"number"===d?this._handleNumberInputMouseDown:null,placeholder:"number"===d||"text"===d?l:"",required:u,tabIndex:f?-1:0}}_isInputFieldInGroup(e){return!y(e)&&a(e.group)}_handleNumberInputMouseDown({target:e}){e.focus(),this.scheduleRender()}_getFieldValueOptions(e,t){const i=t.codedValues.map((({code:e,name:t})=>({value:e,name:t}))),a=this.viewModel.fieldsWithContingentValues.has(e)?this._getContingentValueOptions(e):[];if(a.length>0){const e=new Set(a.map((e=>e.value)));return[a,i.filter((t=>!e.has(t.value)))]}return[i,[]]}_getContingentValueOptions(e){const t={};for(const l of this.viewModel.allInputFields){const{name:a,value:n}=l;!i(n)&&a!==e&&this.viewModel.fieldsWithContingentValues.has(a)&&(t[a]=n)}const a=this.viewModel.joinedContingentValues.slice(),n=new Map;for(const l of a){const a=l.values[e];if(i(a)||"code"!==a.objectType&&"null"!==a.objectType)continue;const{code:s,name:r}="null"===a.objectType?{code:"",name:this.messages.empty}:a.codedValue;if(n.has(s))continue;Object.entries(t).every((([e,t])=>!l.values.hasOwnProperty(e)||this._valueIsValidContingentValue(t,l.values[e])))&&n.set(s,{name:r,value:s})}return[...n.values()]}_getNumberFieldConstraints(e){const t=r(e.domain)||o(e.field);return t&&t.max!==Number.MAX_VALUE&&t.min!==Number.MIN_VALUE?t:{min:null,max:null}}_afterInputCreateOrUpdate(e){const t=e["data-field"],i=this.viewModel.findField(this._activeInputName),a=this._fieldToInitialIncompatibleDomainValue.get(t.name)===t.value;this._fieldFocusNeeded&&i===t&&("radio-buttons"!==t.inputType||a||e.checked)&&(this._fieldFocusNeeded=!1,e.focus())}_handleInputFocus(e){const t=e.target,i=t["data-field"];this._activeInputName=i.name,"date"===i.type&&this._syncDateFieldEdits(t)}_handleInputBlur(e){const t=e.target,i=t["data-field"];if("date"===i.type){const n=e.relatedTarget,l=n&&n["data-field"];if(l&&"date"===i.type&&"date"===l.type&&i.field===l.field){if(""!==t.value&&""===n.value){var a;const l=n.getAttribute("data-date-part");n.value=this._formatDate(null!=(a=i.value)?a:Date.now())[l],this._parseDate(t.value,t.getAttribute("data-date-part"))&&this._commitInputValue(e.target,!0,!1)}return}}this._commitInputValue(t),this.scheduleRender()}_commitInputValue(e,t=!1,i=!0){const a=e["data-field"];if(this._activeDateFieldEdit){const{date:o,time:u}=this._activeDateFieldEdit,d=this._parseDateTime(e.value,a,o.active?"date":"time"),p=null!==this.viewModel.getValue(a.name),c=o.input&&(u.input||!a.includeTime),m=null===d;if(t){if(m)return;(c||!i||p)&&this._updateDateFieldValue(a,d)}else{var n,l;if(""===(null==(n=o.input)?void 0:n.value)||""===(null==(l=u.input)?void 0:l.value))this._updateDateFieldValue(a,null);else if(c){var s,r;const e=`${o.input.value} ${null!=(s=null==(r=u.input)?void 0:r.value)?s:""}`,t=this._parseDateTime(e,a);!(null!==t)&&p||this._updateDateFieldValue(a,t)}this._activeDateFieldEdit=null}}else this._updateFieldValue(e)}_handleInputKeyDown(e){const{key:t,altKey:i,ctrlKey:a,metaKey:n}=e,l=e.target["data-field"];if("Enter"===t)this._isInputFieldInGroup(l)&&"collapsed"===l.group.state&&(l.group.state="expanded");else{const{type:s}=l.field,r="single"===s||"double"===s,o=!i&&!a&&!n;if(("integer"===s||"small-integer"===s||r)&&o&&1===t.length){const i=Number(t),a=["-","+"],n=["e","."],l=r?[...a,...n]:a;isNaN(i)&&-1===l.indexOf(t)&&e.preventDefault()}}}_syncDateFieldEdits(e){var t,i;const a=e["data-field"];if("date"!==a.type)return;const n=e.getAttribute("data-date-part"),l="date"===n?{value:e.value,input:e,active:!0}:{...null==(t=this._activeDateFieldEdit)?void 0:t.date,active:!1},s="time"===n?{value:e.value,input:e,active:!0}:{...null==(i=this._activeDateFieldEdit)?void 0:i.time,active:!1};this._activeDateFieldEdit={fieldName:a.name,date:l,time:s}}_updateFieldValue(e){const t=e["data-field"],{name:i}=t;if(this.viewModel.setValue(i,this._parseValue(e)),this._userUpdatedInputFieldNames.add(i),this.viewModel.fieldsWithContingentValues.has(i)){const e=Object.fromEntries(Object.entries(this.getValues()).filter((([e,t])=>a(t))));this.viewModel.validateContingencyConstraints(e)}}_updateDateFieldValue(e,t){this.viewModel.setValue(e.name,t),this._userUpdatedInputFieldNames.add(e.name)}_parseValue(e){const t=e["data-field"],i=e.value;if(this._inputFieldHasInputType(t,"switch")&&"CALCITE-COMBOBOX"!==e.tagName)return e.checked?t.fieldElement.input.onValue:t.fieldElement.input.offValue;if("radio-buttons"===t.inputType&&"radio"===e.type&&!e.checked)return t.value;const{type:a}=t;if("number"===a)return i?parseFloat(i):null;if("date"===a){if(!i)return null;const a=Number(i);if(!isNaN(a))return a;const n=e.getAttribute("data-date-part"),l=this._parseDate(i,n);if(!l)return null;let s=_.fromJSDate(l);const r=t.domain,o=_.now();let u=o;if(r&&"range"===r.type){const e=_.fromMillis(r.maxValue);o<e&&(u=e)}const d=this.viewModel.getValue(t.name),p=null!=d?_.fromMillis(d):u;return s="date"===n?s.set({hour:p.hour,minute:p.minute,second:p.second}):s.set({day:p.day,month:p.month,year:p.year}),s.toMillis()}return i}_handleOptionChange(e){this._commitInputValue(e),this.scheduleRender()}_handleGroupClick(e){var t;const i=e.currentTarget["data-group"],a="expanded"===i.state,n="sequential"===this.groupDisplay,l=`.${g.groupHeader}`;if(!(a&&!e.target.closest(l))){if(this._activeInputName=null==(t=this._getFocusableInput("forward",i))?void 0:t.name,n){const t=e.target.closest(l);if(a&&!t)return;this.viewModel.inputFields.forEach((e=>{y(e)&&e!==i&&(e.state="collapsed")}))}i.state=a?"collapsed":"expanded",this._fieldFocusNeeded=n,this.scheduleRender()}}_handleSubmit(e){e.preventDefault()}_handleFormKeyDown(e){"Enter"===e.key&&this.viewModel.submit()}_formatDate(e){if(null==e)return{date:"",time:""};const t=_.fromMillis(e,{locale:v(),numberingSystem:"latn"});return{date:t.toLocaleString({year:"numeric",month:"2-digit",day:"2-digit"}),time:t.toFormat(b.timePattern)}}_parseDate(e,t){if(null==e||""===e)return null;const{timePattern:i,datePattern:a}=b,n=t?"date"===t?a:i:`${a} ${i}`,l=_.fromFormat(e,n,{locale:v(),numberingSystem:"latn"});return l.isValid?l.toJSDate():null}_inputFieldHasInputType(e,t){var i;return a(e.fieldElement)&&(null==(i=e.fieldElement.input)?void 0:i.type)===t}_valueIsValidContingentValue(e,i){var a;switch(i.objectType){case"any":return!0;case"null":return null==e;case"code":return e===(null==(a=i.codedValue)?void 0:a.code);case"range":return e>=i.minValue&&e<=i.maxValue;default:return t(i.objectType),!1}}};e([n("viewModel.description")],I.prototype,"description",void 0),e([n("viewModel.feature")],I.prototype,"feature",void 0),e([n("viewModel.fieldConfig")],I.prototype,"fieldConfig",void 0),e([n("viewModel.formTemplate")],I.prototype,"formTemplate",void 0),e([l()],I.prototype,"groupDisplay",void 0),e([l()],I.prototype,"headingLevel",void 0),e([l({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],I.prototype,"label",void 0),e([n("viewModel.layer")],I.prototype,"layer",void 0),e([l(),m("esri/widgets/FeatureForm/t9n/FeatureForm")],I.prototype,"messages",void 0),e([l(),m("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],I.prototype,"messagesTemplates",void 0),e([n("viewModel.strict")],I.prototype,"strict",void 0),e([n("viewModel.title")],I.prototype,"title",void 0),e([l(),h(["value-change","submit"])],I.prototype,"viewModel",void 0),e([n("viewModel.getValues")],I.prototype,"getValues",null),e([n("viewModel.submit")],I.prototype,"submit",null),I=e([s("esri.widgets.FeatureForm")],I);const F=I;export{F as default};