@arcgis/core 4.33.0-next.20250402 → 4.33.0-next.20250403

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.
Files changed (84) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/0cec53e6f1464c69448d.js +1 -0
  3. package/assets/esri/core/workers/chunks/{322cb1b1871d03b69f0a.js → 5beb525b4adde1d98532.js} +33 -33
  4. package/assets/esri/core/workers/chunks/6b0a6469673417563616.js +1 -0
  5. package/assets/esri/core/workers/chunks/c977a47cabc419610277.js +1 -0
  6. package/assets/esri/core/workers/chunks/{7e00122014d0a55363a8.js → ccb289911e7445b17763.js} +1 -1
  7. package/core/typedArrayUtil.js +1 -1
  8. package/editing/sharedTemplates/SharedTemplateProvider.js +1 -1
  9. package/geometry/Polygon.js +1 -1
  10. package/geometry/support/buffer/BufferView.js +1 -1
  11. package/geometry/support/buffer/internals/Vec2.js +1 -1
  12. package/interfaces.d.ts +23 -21
  13. package/package.json +1 -1
  14. package/support/revision.js +1 -1
  15. package/undoredo/support/Services.js +1 -1
  16. package/views/2d/engine/vectorTiles/decluttering/CollisionJob.js +1 -1
  17. package/views/2d/engine/vectorTiles/decluttering/SymbolDeclutterer.js +1 -1
  18. package/views/2d/engine/vectorTiles/decluttering/SymbolFader.js +1 -1
  19. package/views/2d/layers/StreamLayerView2D.js +1 -1
  20. package/views/3d/environment/ChapmanAtmosphereTechnique.js +1 -1
  21. package/views/3d/environment/NoiseTextureAtlasTechnique.js +1 -1
  22. package/views/3d/environment/PrecipitationTechnique.js +1 -1
  23. package/views/3d/environment/SimpleAtmosphereTechnique.js +1 -1
  24. package/views/3d/layers/DrapedSubView3D.js +1 -1
  25. package/views/3d/support/buffer/InterleavedLayout.js +1 -1
  26. package/views/3d/terrain/PatchGeometry.js +1 -1
  27. package/views/3d/terrain/PatchGeometryFactory.js +1 -1
  28. package/views/3d/terrain/TerrainAttributes.js +1 -1
  29. package/views/3d/webgl-engine/core/shaderLibrary/attributes/PathVertexPosition.glsl.js +3 -3
  30. package/views/3d/webgl-engine/core/shaderTechnique/ShaderTechnique.js +1 -1
  31. package/views/3d/webgl-engine/effects/RenderPlugin.js +1 -1
  32. package/views/3d/webgl-engine/effects/haze/HazeTechnique.js +1 -1
  33. package/views/3d/webgl-engine/effects/highlight/HighlightApplyTechnique.js +1 -1
  34. package/views/3d/webgl-engine/effects/highlight/ShadowHighlightTechnique.js +1 -1
  35. package/views/3d/webgl-engine/effects/magnifier/MagnifierTechnique.js +1 -1
  36. package/views/3d/webgl-engine/effects/stars/StarsTechnique.js +1 -1
  37. package/views/3d/webgl-engine/effects/transparency/OITBlendTechnique.js +1 -1
  38. package/views/3d/webgl-engine/lib/ChangeSet.js +1 -1
  39. package/views/3d/webgl-engine/lib/GLMaterials.js +1 -1
  40. package/views/3d/webgl-engine/lib/ITexture.js +1 -1
  41. package/views/3d/webgl-engine/lib/OrderIndependentTransparency.js +1 -1
  42. package/views/3d/webgl-engine/lib/PathBuilder.js +1 -1
  43. package/views/3d/webgl-engine/lib/PathGeometryData.js +1 -1
  44. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  45. package/views/3d/webgl-engine/lib/SortedRenderGeometryRenderer.js +1 -1
  46. package/views/3d/webgl-engine/lib/Texture.js +1 -1
  47. package/views/3d/webgl-engine/lib/TextureRepository.js +1 -1
  48. package/views/3d/webgl-engine/lib/TextureTechnique.js +1 -1
  49. package/views/3d/webgl-engine/lib/TextureUpdater.js +5 -0
  50. package/views/3d/webgl-engine/lib/rendererUtils.js +1 -1
  51. package/views/3d/webgl-engine/materials/ImageMaterial.js +1 -1
  52. package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
  53. package/views/3d/webgl-engine/materials/PathTechnique.js +1 -1
  54. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  55. package/views/3d/webgl-engine/materials/internal/bufferWriterUtils.js +1 -1
  56. package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
  57. package/views/3d/webgl-engine/shaders/CompositingTechnique.js +1 -1
  58. package/views/3d/webgl-engine/shaders/HUDMaterialTechnique.js +1 -1
  59. package/views/3d/webgl-engine/shaders/HeatmapDensityTechnique.js +1 -1
  60. package/views/3d/webgl-engine/shaders/HeatmapTechnique.js +1 -1
  61. package/views/3d/webgl-engine/shaders/ImageMaterialTechnique.js +1 -1
  62. package/views/3d/webgl-engine/shaders/LineMarkerTechnique.js +1 -1
  63. package/views/3d/webgl-engine/shaders/NativeLineTechnique.js +1 -1
  64. package/views/3d/webgl-engine/shaders/RibbonLineTechnique.js +1 -1
  65. package/views/3d/webgl-engine/shaders/ShadowCastAccumulateTechnique.js +1 -1
  66. package/views/3d/webgl-engine/shaders/ShadowCastVisualizeTechnique.js +1 -1
  67. package/views/3d/webgl-engine/shaders/SlicePlaneMaterialTechnique.js +1 -1
  68. package/views/3d/webgl-engine/shaders/TerrainTechnique.js +1 -1
  69. package/views/3d/webgl-engine/shaders/ViewshedTechnique.js +1 -1
  70. package/views/webgl/renderState.js +1 -1
  71. package/views/webgl/testFloatBufferBlend.js +1 -1
  72. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  73. package/widgets/Editor/UpdateWorkflow.js +1 -1
  74. package/widgets/Editor/workflowUtils.js +1 -1
  75. package/widgets/Editor.js +1 -1
  76. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationItemList.js +1 -1
  77. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationSettings.js +1 -1
  78. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  79. package/widgets/FeatureForm.js +1 -1
  80. package/widgets/support/GridControls/GridControlsViewModel.js +1 -1
  81. package/widgets/support/GridControls.js +1 -1
  82. package/assets/esri/core/workers/chunks/a56da688088404259481.js +0 -1
  83. package/assets/esri/core/workers/chunks/e6469173c65531d6524a.js +0 -1
  84. package/assets/esri/core/workers/chunks/e9e517a2141e504eec64.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../Color.js";import t from"../../Graphic.js";import{isSome as r,addMany as a,equals as o}from"../../core/arrayUtils.js";import{createTask as n}from"../../core/asyncUtils.js";import"../../core/has.js";import i from"../../core/Error.js";import{handlesGroup as s,makeHandle as l,abortHandle as c}from"../../core/handleUtils.js";import{clone as u}from"../../core/lang.js";import p from"../../core/Logger.js";import{getOrCreateMapValue as d}from"../../core/MapUtils.js";import{whenOrAbort as f,throwIfAborted as y,debounce as m,isPromiseLike as h}from"../../core/promiseUtils.js";import{watch as g,on as b,whenOnce as w}from"../../core/reactiveUtils.js";import{px2pt as v}from"../../core/screenUtils.js";import{diff as I}from"../../core/accessorSupport/diffUtils.js";import{isSharedTemplateOrMetadata as T,isSharedGroupTemplate as S,isSharedPresetTemplate as j,isStandardFeatureTemplate as F,isSharedFeatureTemplate as k,isSharedTemplate as A}from"../../editing/templateUtils.js";import V from"../../editing/sharedTemplates/SharedTemplate.js";import{getSharedTemplateProvider as U}from"../../editing/sharedTemplates/SharedTemplateProvider.js";import L from"../../layers/GraphicsLayer.js";import{featureHasFields as M,fixFields as O,getDisplayFieldName as x}from"../../layers/support/fieldUtils.js";import{isSubtypeSublayer as q}from"../../layers/support/layerUtils.js";import{calculateTolerance as P}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as z}from"../../renderers/support/lengthUtils.js";import{getTransformationType as E,TransformationType as C}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import R from"../../symbols/SimpleFillSymbol.js";import D from"../../symbols/SimpleLineSymbol.js";import G from"../../symbols/SimpleMarkerSymbol.js";import{to3D as B}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as N}from"../../symbols/support/symbolUtils.js";import{getServices as Z}from"../../undoredo/support/Services.js";import{GraphicState as Q}from"../../views/3d/layers/graphics/GraphicState.js";import{defaultDrawingMode as W}from"../../views/draw/DrawingMode.js";import{createQueryGeometry as $}from"../../views/support/drapedUtils.js";import{hitTestSelectSimilarDistance as J,filterGraphicHits as H}from"../../views/support/hitTestSelectUtils.js";import{dependencySort as K}from"./support/dependencySort.js";import{isDrawGraphicTool as X}from"../Sketch/support/sketchUtils.js";const Y=()=>p.getLogger("esri.widgets.Editor.workflowUtils");function _(e){return"update"===e.type}function ee(e){const t=e.sourceLayer;if(!t||"feature"!==t.type||!ie(t.renderer))return{rotation:null,size:null};let r=null,a=null;const o=t.renderer.getVisualVariablesForType("rotation").filter((e=>(!e.axis||"heading"===e.axis)&&e.field&&!e.valueExpression));1===o.length&&(r=te(o[0],t));const n=t.renderer.getVisualVariablesForType("size").filter((e=>e.field&&!e.useSymbolValue&&!e.valueExpression&&E(e)===C.RealWorldSize));return 1===n.length&&(a=oe(n[0],t)),{rotation:r,size:a}}function te(e,t){const r="heading"===(e.axis||"heading")&&"arithmetic"===e.rotationType?-1:1,a=e.field,o=t.fields&&t.fields.filter((e=>e.name===a)),n=o&&1===o.length?o[0].type:"double",i={initial:0,current:0};return{field:a,fieldType:n,getDefaultValue:()=>Promise.resolve(0),getValue:e=>(i.current=i.initial-r*e,ne((i.current+360)%360,n)),setInitialValue:e=>{i.initial=e,i.current=0},isUpdatingInteractively:!1,rotationType:e.rotationType??"geographic"}}function re(e,t){switch(t){case"width":return e[0];case"depth":return e[1];case"height":return e[2];default:return e[2]||e[1]||e[0]}}async function ae(e,t,r){if(null==t)return 0;const{symbol:a}=B(t);if(null==a||"web-style"===a.type||"cim"===a.type)return 0;const o=a.symbolLayers.at(0);if(!o)return 0;switch(o.type){case"icon":{const{computeIconLayerResourceSize:e}=await import("../../symbols/support/symbolLayerUtils.js");return Math.min(We.icon,(await e(o,We.icon))[0])||We.icon}case"text":return We.text;case"line":return We.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return re(await t(o,e.scale/We.viewScaleSizeFactor),r)}case"path":case"extrude":return e.scale/We.viewScaleSizeFactor;default:return 0}}function oe(e,t){const r=e.field,a=e.axis,o=t.fields&&t.fields.filter((e=>e.name===r)),n=o&&1===o.length?o[0].type:"double",i={initial:0,current:0},s=z[e.valueUnit]??1;let l;return l="area"===e.valueRepresentation?e=>(e*s/2)**2*Math.PI:"radius"===e.valueRepresentation||"distance"===e.valueRepresentation?e=>e*s/2:e=>e*s,{field:r,fieldType:n,getDefaultValue:async(e,t)=>ne(l(await ae(t,e,a)),n),getValue:(e,t)=>(i.initial||(i.initial=t.pixelSizeAt(t.center)),i.current=i.initial*e,ne(i.current,n)),setInitialValue:e=>{i.initial=e,i.current=0},isUpdatingInteractively:!1,displayUnit:He(e.valueUnit),axis:e.axis}}function ne(e,t){switch(t){case"small-integer":case"integer":case"long":return Math.round(e);case"double":case"single":return e;default:return 0}}function ie(e){switch(e?.type){case"class-breaks":case"simple":case"unique-value":case"dot-density":case"dictionary":case"pie-chart":return!0;default:return!1}}async function se(e,t,r){const a=await N(e,{useSourceLayer:!0,ignoreGraphicSymbol:!0,webStyleCache:t,scale:r});null!=I(e.symbol,a)&&(e.symbol=a)}function le(e,t){if(!e||!t)throw new Error("no geometry type");if("multipatch"===e)return{tool:"mesh",createOptions:{mode:"hybrid"}};const r=new Map;r.set("circle",{mode:"freehand"}),r.set("rectangle",{mode:"freehand"});const a={mode:W,optionsPerTool:r};if(T(t)){const o=t.defaultTool,n=S(t)?t.definition?.inputGeometryType??e:e;switch(o){case"freehand":case"stream-line":return{tool:"polyline"===n?"freehandPolyline":"freehandPolygon",createOptions:a};case"autocomplete-freehand-polygons":case"stream-polygon":return{tool:"freehandPolygon",createOptions:a};case"autocomplete-polygons":case"difference-polygon":case"create-structures":case"polygon":case"trace":return{tool:"polygon"===n?"polygon":"polyline",createOptions:a};case"circle":return r.get("circle").preserveAspectRatio=!0,{tool:"circle",createOptions:a};case"ellipse":return r.get("circle").preserveAspectRatio=!1,{tool:"circle",createOptions:a};case"create-points-along-line":case"multipoint":return{tool:"multipoint",createOptions:a};case"line":case"radial-line":case"right-angle-line":case"split":case"two-point-line":return{tool:"polyline",createOptions:a};case"rectangle":case"regular-polygon":case"right-angle-polygon":return{tool:"rectangle",createOptions:a};case"elevation-point-from-contour":case"elevation-point-from-dem":case"parcel-seed":case"point":case"point-and-rotation":case"point-at-end-of-line":return{tool:"point",createOptions:a}}}else{const o=t.drawingTool;if("circle"===o||"ellipse"===o)return r.get("circle").preserveAspectRatio="circle"===o,{tool:"circle",createOptions:a};if("rectangle"===o)return{tool:"rectangle",createOptions:a};if("freehand"===o)return{tool:"polygon"===e?"freehandPolygon":"freehandPolyline",createOptions:a}}return{tool:e,createOptions:a}}async function ce(e,t,r){const{creationInfo:a,fullTemplate:o}=t;if(!a)throw new i("featureworkflow","No creation info provided.");const n=a.layer,s=Ae(o,a.attributeOverrides),{view:l}=e,c="2d"===l?.type;S(o)||j(o)||await Ve(e,n,s,r,c?l.scale:null);const{capabilities:u}=n;e.layer.elevationInfo=n.elevationInfo;const p=le(n.geometryType,o);e.defaultCreateOptions={graphicProperties:{attributes:s,sourceLayer:n},mode:p.createOptions.mode,optionsPerTool:p.createOptions.optionsPerTool,preserveAspectRatio:p.createOptions.preserveAspectRatio,hasZ:u.data.supportsZ,defaultZ:(c?u.editing.zDefault:null)??e.defaultCreateOptions.defaultZ},null==a.geometryToPlace?await e.create(p.tool):await e.place(a.geometryToPlace,{graphicProperties:{attributes:s,sourceLayer:n}})}async function ue(e){return s([await pe(e),await de(e)])}async function pe({creationAttributes:e,data:t,sketchViewModel:r,view:a,webStyleCache:o}){const{creationInfo:n}=t,{fullTemplate:i}=t;if(!n||"2d"!==a?.type||S(i)||j(i))return null;const s=m((t=>Ve(r,n.layer,e,o,t)));return g((()=>a.scale),(e=>s(e)))}async function de({data:t,sketchViewModel:r,view:a}){const{templateExecutorInfo:o}=t;if(!o)return null;const n=r.activeComponent;if(!a||!X(n))return Y().error(new i("featureworkflow","Failed to set up template feedback.")),null;const c=new L({effect:"saturate(0.6) opacity(0.8)",listMode:"hide",title:"Shared Template Feedback Graphics"});a.map?.add(c);const{executor:u,serviceLayersById:p}=o,d=a.theme?.accentColor??new e([255,165,0,1]);return s([b((()=>n),["cursor-update","vertex-add"],(()=>{c.removeAll();const e=n.graphic?.geometry;if(!e||!fe(e))return;const t=u(e,"digitizing");if(!h(t))for(const r of t.edits){const e=p.get(r.id);if(e&&r.addFeatures&&0!==r.addFeatures.length)for(const t of e)if(!t.isTable)for(const e of r.addFeatures){const t=ye(e,d);t&&c.add(t)}}})),l((()=>{a.map.remove(c),c.destroy()}))])}function fe(e){switch(e.type){case"point":case"multipoint":return!0;case"polyline":return e.paths[0].length>1;case"polygon":{const t=e.rings[0];return o(t.at(0),t.at(-1))?t.length>2:t.length>1}default:return!1}}function ye(e,r){let a=null;switch(e.geometry?.type){case"point":case"multipoint":a=new G({angle:0,color:r,outline:new D({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:1}),path:"undefined",size:8,style:"circle",xoffset:0,yoffset:0});break;case"polygon":a=new R({color:r,outline:new D({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:3}),style:"none"});break;case"polyline":a=new D({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:2});break;default:return null}return new t({geometry:e.geometry,symbol:a,attributes:{...e.attributes}})}async function me(e,t){const r=await Z(t).load(),a=q(e)?e.parent:e;return r.tablesAndLayersLookup.get(a)}async function he(e,t){const r=await me(e,t);if(!r)return new Map;const a=new Map;for(const o of r.layersAndTables)d(a,o.layerId,(()=>[])).push(o);return a}function ge(e){const t=e.objectIdField,r=e.globalIdField??"";return{id:e.layerId,identifierFields:{objectIdField:t,globalIdField:r},addFeatures:[],deleteAttachments:[],addAttachments:[],deleteFeatures:[],updateFeatures:[]}}function be(e){const{edits:t,serviceInfo:a,view:o,findOriginalFeature:n}=e,i=we(a.layersAndTables),s=a.layersAndTables.toArray(),{allEditData:l,editDataByLayerIdMap:c,editDataByIdMap:u}=Ie(t,i,n),p=Te(l,ve(s,c),c);if(Fe(l,p,o),0===p.length)return t;const d=K(p,{continueOnCircularDependency:!0}).map((e=>u.get(e))).filter(r),f=new Map;for(const r of d)f.set(r.uniqueId,r);const y=[];for(const r of l)f.has(r.uniqueId)||y.push(r);const m=[];let h=null;for(const r of d){const{layer:e}=r;switch(null==h?h=ge(e):h.id!==e.layerId&&(m.push(h),h=ge(e)),r.operationType){case"add":case"modify":h.addFeatures.push(r.after);break;case"delete":h.deleteFeatures.push(r.before)}}null!==h&&m.push(h);for(const r of y){const e=r.layer.layerId,t=m.find((t=>t.id===e))??ge(r.layer);switch(m.includes(t)||m.push(t),r.operationType){case"add":t.addFeatures.push(r.after);break;case"modify":t.updateFeatures.push(r.after);break;case"delete":t.deleteFeatures.push(r.before);break;case"deleteAttachment":t.deleteAttachments.push(r.attachmentId);break;case"addAttachment":t.addAttachments.push(r.attachment)}}for(const r of m)void 0!==r.deleteAttachments&&0===r.deleteAttachments.length&&delete r.deleteAttachments,void 0!==r.addAttachments&&0===r.addAttachments.length&&delete r.addAttachments;return m}function we(e){const t=new Map;for(const r of e)t.set(r.layerId,r);return t}function ve(e,t){const r=new Map;for(const a of e)for(const e of a.relationships??[])if(r.set(Se(a,e),""),t.has(e.relatedTableId)){const o=t.get(e.relatedTableId);if(o.length>0)for(const t of o[0].layer.relationships??[])if(t.id===e.id){r.set(Se(a,e),t.keyField);break}}return r}function Ie(e,t,r){const a=new Map,o=[],n=new Map;let s=1;for(const l of e){const e=[],c=t.get(l.id);if(!c)throw new i("featureworkflow",`Failed to prepare applyEdits payload. Layer with id ${l.id} not found.`);for(const t of l.addFeatures??[])e.push({uniqueId:"T"+s++,operationType:"add",layer:c,after:t});for(const t of l.deleteFeatures??[])e.push({uniqueId:"T"+s++,operationType:"delete",before:t,layer:c});for(const t of l.deleteAttachments??[])e.push({uniqueId:"T"+s++,operationType:"deleteAttachment",attachmentId:t,layer:c});for(const t of l.addAttachments??[])e.push({uniqueId:"T"+s++,operationType:"addAttachment",attachment:t,layer:c});for(const t of l.updateFeatures??[])e.push({uniqueId:"T"+s++,operationType:"modify",before:r(t),after:t,layer:c});a.set(c.layerId,e);for(const t of e)o.push(t),n.set(t.uniqueId,t)}return{allEditData:o,editDataByIdMap:n,editDataByLayerIdMap:a}}function Te(e,t,r){const a=[];for(const o of e){const e=o.layer.relationships??[],{uniqueId:n}=o;for(const i of e){const e=i.keyField;if("origin"===i.role){const s=r.get(i.relatedTableId);if(!s||0===s.length)continue;const l=Se(o.layer,i),c=t.get(l);if(void 0===c||""===c)continue;switch(o.operationType){case"add":for(const t of s)t!==o&&("add"!==t.operationType&&"modify"!==t.operationType||t.after.attributes[c]===o.after.attributes[e]&&a.push([n,t.uniqueId]));break;case"modify":if(o.before.attributes[e]!==o.after.attributes[e])for(const t of s){const r=t.uniqueId;t!==o&&("delete"===t.operationType?t.before.attributes[c]===o.before.attributes[e]?a.push([r,n]):t.before.attributes[c]===o.after.attributes[e]&&a.push([n,r]):"add"===t.operationType?t.after.attributes[c]===o.after.attributes[e]?a.push([n,r]):t.after.attributes[c]===o.before.attributes[e]&&a.push([r,n]):"modify"===t.operationType&&(t.before.attributes[c]!==t.after.attributes[c]?t.after.attributes[c]===o.after.attributes[e]?a.push([n,r]):a.push([r,n]):a.push([n,r])))}break;case"delete":for(const t of s)t!==o&&("delete"!==t.operationType&&"modify"!==t.operationType||t.before.attributes[c]===o.before.attributes[e]&&a.push([t.uniqueId,n]))}}}}return a}function Se(e,t){return`${e.layerId}:${t.id}`}function je(e,t){return!!(t?.map&&"utilityNetworks"in t.map&&t.map.utilityNetworks?.length&&t.map.utilityNetworks.some((t=>!(!t.loaded||!e.url?.startsWith(t.featureServiceUrl)||e.layerId!==t.networkSystemLayers.associationsTableId))))}function Fe(e,t,r){const a=[];for(const n of e)je(n.layer,r)&&a.push(n);if(0===a.length)return;let o=[];for(const n of a){const r=n.layer;switch(n.operationType){case"delete":o=[...ke(n.before.attributes[r.fieldsIndex.get("fromglobalid").name],e),...ke(n.before.attributes[r.fieldsIndex.get("toglobalid").name],e)];for(const e of o)t.push([n.uniqueId,e.uniqueId]);break;case"add":o=[...ke(n.after.attributes[r.fieldsIndex.get("fromglobalid").name],e),...ke(n.after.attributes[r.fieldsIndex.get("toglobalid").name],e)];for(const e of o)t.push([e.uniqueId,n.uniqueId])}}}function ke(e,t){const r=[],a=t.filter((({layer:e})=>""!==e.globalIdField&&null!=e.globalIdField));for(const o of a){const t=o.layer.globalIdField;("before"in o&&o.before?.attributes[t]===e||"after"in o&&o.after?.attributes[t]===e)&&r.push(o)}return r}function Ae(e,t={}){return S(e)||j(e)?{}:F(e)?{...e.prototype.attributes,...t}:k(e)?{...e.definition?.defaultValues,...t}:{...t}}async function Ve(e,r,a,o,n){const i=new t({sourceLayer:r,attributes:a}),{rotation:s,size:l}=ee(i);let c=await N(i,{useSourceLayer:!0,webStyleCache:o,scale:n}),u=!1;for(const t of[l,s]){if(null==t)continue;null==a[t.field]&&(a[t.field]=await t.getDefaultValue(c,e.view),u=!0)}switch(u&&(c=await N(i,{useSourceLayer:!0,webStyleCache:o,scale:n})),c?.type){case"simple-fill":case"polygon-3d":e.polygonSymbol=c;break;case"simple-line":case"line-3d":e.polylineSymbol=c;break;case"simple-marker":case"picture-marker":case"point-3d":case"cim":e.pointSymbol=c;break;case"mesh-3d":e.meshSymbol=c}Ue(e.tooltipOptions,l,s)}function Ue(e,t,r){e.visualVariables=null!=t||null!=r?{size:null!=t?{unit:t.displayUnit,axis:t.axis,valueType:t.fieldType}:null,rotation:null!=r?{valueType:r.fieldType,rotationType:r.rotationType??"geographic"}:null}:null}function Le(e,t){return e?.find((e=>e.layer===t))}async function Me(e,t,r,a){switch(t.type){case"3d":return Oe(e,t,r,a);case"2d":return xe(e,t,r,a)}}async function Oe(e,t,r,o){if(0===e.length)return[];const{updatable:n,graphicsByLayer:i}=await r.async((async()=>{const{results:a}=await f(J(t,r),o),n=new Map,i=e=>{const t=e.layer,r=n.get(t);if(!r){const e=new Array;return n.set(t,e),e}return r};H(a).forEach((({graphic:e})=>i(e).push(e)));const s=e.filter((({capabilities:e,layer:t})=>e.update.enabled&&n.has(t)));return 0!==s.length&&r.stopPropagation(),{updatable:s,graphicsByLayer:n}}));return f(Promise.allSettled(n.map((async({layer:e})=>{const t=i.get(e),r=qe(e);if(t.every((e=>M(r,e))))return t;const n=[];for(const o of t){n.push(o.getObjectId());const e=Object.keys(o.attributes);a(r,e)}const s=e.createQuery();return s.returnGeometry=!1,s.objectIds=n,s.outFields=O(e.fieldsIndex,r),e.queryFeatures(s,{signal:o}).then((({features:e})=>e))}))),o)}async function xe(e,t,r,a){if(0===e.length)return[];const{mapPoint:o}=r;if(null==o)return[];let n=null;const i=await r.async((async()=>{const{results:o}=await f(t.hitTest(r),a);if(0===o.length)return[];const i=new Set;n=H(o),n.forEach((({graphic:e})=>e&&i.add(e.layer)));const s=e.filter((e=>i.has(e.layer)&&e.supportsUpdateWorkflow));return s.length>0&&r.stopPropagation(),s}));return f(Promise.allSettled(i.map((async({layer:e})=>{const i=e.createQuery();i.returnGeometry=!0,i.outFields=qe(e);const s="renderer"in e?P({renderer:e.renderer,pointerType:r.pointerType}):0;i.geometry=$(o,s,t),i.outSpatialReference=t.spatialReference;const{features:l}=await e.queryFeatures(i,{signal:a});return n?.forEach((({graphic:t})=>{t.layer!==e||l.some((e=>e.getObjectId()===t.getObjectId()))||l.push(t)})),l}))),a)}function qe(e){return O(e.fieldsIndex,[e.objectIdField,x({displayField:"displayField"in e?e.displayField:null,fields:e.fields})])}async function Pe(e,t,a,o){const n=t.createQuery();n.objectIds=e.map((e=>e.getObjectId())).filter(r),n.outFields=["*"],n.returnM=t.capabilities.data.supportsM,n.returnZ=t.capabilities.data.supportsZ,"scene"===t.type&&null!=t.infoFor3D||(n.outSpatialReference=a);const i=await t.queryFeatures(n,{signal:o});return y(o),i.features}function ze(e){const t=new Map;for(const r of e){const e=r.sourceLayer,a=q(e)?e.parent:e;d(t,a,(()=>[])).push(r)}return t}async function Ee(e){const{graphic:t,sketchViewModel:r,sourceLayer:a,visualVariables:o}=e;await Ce(e);const n={multipleSelectionEnabled:!1};return"point"===a.geometryType&&(n.enableRotation=null!=o.rotation,n.enableScaling=null!=o.size),r.update(t,n)}async function Ce(e){const{graphic:t,sketchViewModel:r,sourceLayer:a,visualVariables:o,webStyleCache:n}=e;let i=!1;const{rotation:s,size:l}=o;for(const c of[s,l]){if(null==c)continue;const e=t.getAttribute(c.field);if(null!=e)c.setInitialValue(e);else{const e=await c.getDefaultValue(t.symbol,r.view);c.setInitialValue(e),t.setAttribute(c.field,e),i=!0}}if(i){const e="2d"===r.view?.type?r.view.scale:null;await se(t,n,e)}Ue(r.tooltipOptions,l,s),r.layer.elevationInfo=a.elevationInfo}function Re(e){return null==e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function De(e){return null==e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}async function Ge(e,t,r,a,o){if(null==t.geometry||"point"!==t.geometry?.type)return;const n=a.rotation,i=Re(r.toolEventInfo);if(null!=n&&null!=i){const{field:r,getValue:a}=n;"rotate-stop"===i.type?(n.isUpdatingInteractively=!1,n.setInitialValue(t.getAttribute(r))):(n.isUpdatingInteractively=!0,t.setAttribute(r,a(i.angle,e)))}const s=a.size,l=De(r.toolEventInfo);if(null!=s&&null!=l){const{field:r,getValue:a}=s;"scale-stop"===l.type?(s.isUpdatingInteractively=!1,s.setInitialValue(t.getAttribute(r))):(s.isUpdatingInteractively=!0,t.setAttribute(r,a(l.xScale,e)))}await se(t,o,"2d"===e.type?e.scale:null)}async function Be({feature:e,featureClone:t,visualVariableAttributes:r,sketchViewModel:a,view:o,onUpdate:n,webStyleCache:i,addUpdatingPromise:u,addHandle:p}){await se(t,i,"2d"===o.type?o.scale:null);let d=null;if("2d"===a?.view?.type){const e=m((e=>se(t,i,e)));d=g((()=>a?.view?.scale),(t=>e(t)))}const f=t.sourceLayer,y=Ye(o,f);await Ee({graphic:t,sketchViewModel:a,sourceLayer:f,visualVariables:r,webStyleCache:i});let h=null;y.then((e=>h=e)).catch((()=>{}));const b=r.size,v=r.rotation,I=g((()=>e.attributes),(async e=>{let r=!1;for(const a in e){const o=e[a];o!==t.getAttribute(a)&&(t.setAttribute(a,o),null==b||b.isUpdatingInteractively||b.field!==a||b.setInitialValue(o),null==v||v.isUpdatingInteractively||v.field!==a||v.setInitialValue(o),(null==h||h.requiredFields.includes(a))&&(r=!0))}r&&await se(t,i,"2d"===o.type?o.scale:null)})),T=a.on("update",(async e=>{const t=e.graphics[0],s={graphic:t,sketchViewModel:a,sourceLayer:f,visualVariables:r,webStyleCache:i};if("complete"===e.state){if(null===o.activeTool)return Ee(s);const e=new AbortController,t=c(e);return p(t),u(w((()=>null===o.activeTool),e.signal).then((()=>(e.abort(),Ee(s)))))}await Ge(o,t,e,r,i),n(et(t),e)})),S=a.on(["undo","redo"],(async e=>{n(et(e.graphics[0]),e)}));return s([S,T,l((()=>a.cancel())),I,d])}async function Ne(e,t,r){const a=e.view;e.layer.add(r);const o=t.sourceLayer,i=t.layer,c=t.getAttribute(i.objectIdField);let u=null;function p(e){u?.abort(),u=n((async t=>{const r=await Ye(a,o);y(t),r.setVisibility?.(c,e)}))}return await Qe(a,r),p(!1),s([Ze(a,r,(e=>p(!e))),l((async()=>{p(!0);try{const e=await Ye(a,o);await w((()=>!e.updating))}finally{e.layer.remove(r)}}))])}function Ze(e,t,r){if("3d"===e.type){const a=new Q({graphic:t});return s([e.trackGraphicState(a),g((()=>a.displaying),r)])}return g((()=>t.visible),r)}async function Qe(e,t){if("3d"===e.type){const r=new Q({graphic:t}),a=e.trackGraphicState(r);await w((()=>r.displaying||r.error)),a.remove()}else await w((()=>t.visible))}const We={icon:v(24),text:v(12),line:v(1),viewScaleSizeFactor:100};function $e(e,t,r){let a=!1;return e.filter((e=>!!a||(a=e===t,a))).map((e=>r[e]()))}function Je(e,t){e.viewModel.syncFeatureTemplates();const r=e.creationInfo;if("awaiting-feature-creation-info"===t[0].id&&r){const a=r.layer,o=e.viewModel.getTemplatesForLayer(a);1===o.length&&"scene"!==a.type&&(r.template=o[0],t.shift())}return t}function He(e){return"unknown"===e?null:e}function Ke(e){e.filesEnabled=!0,e.mode="view",e.capabilities={editing:!0,operations:{add:!0,update:!0,delete:!0}}}const Xe=e=>/-stop/.test(e)||/vertex-/.test(e),Ye=(e,t)=>{const r="subtype-sublayer"===t.type?t.parent:t;return e.whenLayerView(r)};function _e(e){return"createInteractiveEditSession"in e}function et(e){const t=e.geometry;if("mesh"===t?.type){const r=e.cloneShallow();return r.attributes=u(e.attributes),r.geometry=t.cloneShallow(),r.geometry.transform=t.transform?.clone()??null,r}return e.clone()}function tt(e){const t=e.cursor;return e.cursor="progress",l((()=>e.cursor=t))}async function rt(e,t){const{template:r}=e;if(null==r)return null;if(A(r))return r.load();if(T(r)){const e=U(t,{makeSharedTemplateFromJSON:nt}),a=await e.getTemplates({templateIds:[r.templateId],featureService:r.featureService});if(0===a.length)throw new i("editor:failed-to-load-template","Unable to load the provided template");return a[0].load()}return r}function at(e){for(const t of e){const{destinationGraphic:e,destinationField:r,sourceGraphic:a,sourceField:o}=t;e.setAttribute(r,a.getAttribute(o))}}function ot(e){const t=e.templateExecutorInfo?.completionResults;return t?.length?(t.forEach((e=>at(e.relationships))),t.flatMap((e=>e.edits))):null}const nt=e=>V.fromJSON(e);export{Fe as appendAllUtilityNetworkAssociationRelationships,Je as avoidFeatureTemplateSelectionWithOnlyOneItem,_e as canCreateInteractiveEditSession,et as cloneGraphicExceptMesh,we as createLayerIdMap,ve as createRelationshipKeyMap,le as createToolFromGeometryType,$e as createWorkflowSteps,Me as fetchCandidates,Pe as fetchFullFeatures,Te as findAllDependencies,ke as findChangesByGlobalId,Le as findLayerInfo,Se as generateHashForRelationship,Ae as getCreationAttributes,rt as getFullTemplateForCreationInfo,ot as getServiceEditsFromWorkflowData,me as getServiceInfoForLayer,he as getServiceLayersById,ee as getVisualVariableAttributes,ze as groupFeaturesByLayer,Xe as isTerminalUpdateEventType,_ as isUpdateWorkflow,je as isUtilityNetworkAssociationsTable,be as orderEditsByRelationshipDependencies,Ke as prepareAttachmentsForCreateFeaturesWorkflow,at as setRelationshipFields,Be as setUpGeometryUpdate,ue as setUpSketchCreateWatchers,Ce as setVisualVariablesAndElevationInfoForUpdate,tt as showProgressCursor,We as sizeDefaults,He as sizeVariableUnitToLengthUnit,ce as startCreatingNewFeature,Ee as startUpdatingFeatureGeometry,Ne as swapForEditingSession,se as updateGraphicSymbolWhenRequired,Ge as visualVariableInteractiveUpdate,Ye as whenEditorLayerView,Qe as whenGraphicDisplayed};
5
+ import e from"../../Color.js";import t from"../../Graphic.js";import{isSome as r,addMany as a,equals as o}from"../../core/arrayUtils.js";import{createTask as n}from"../../core/asyncUtils.js";import"../../core/has.js";import i from"../../core/Error.js";import{handlesGroup as s,makeHandle as l,abortHandle as c}from"../../core/handleUtils.js";import{clone as u}from"../../core/lang.js";import p from"../../core/Logger.js";import{getOrCreateMapValue as d}from"../../core/MapUtils.js";import{whenOrAbort as f,throwIfAborted as y,debounce as m,isPromiseLike as h}from"../../core/promiseUtils.js";import{watch as g,on as b,whenOnce as w}from"../../core/reactiveUtils.js";import{px2pt as v}from"../../core/screenUtils.js";import{diff as I}from"../../core/accessorSupport/diffUtils.js";import{isSharedTemplateOrMetadata as T,isSharedGroupTemplate as S,isSharedPresetTemplate as j,isStandardFeatureTemplate as F,isSharedFeatureTemplate as k,isSharedTemplate as A}from"../../editing/templateUtils.js";import{getSharedTemplateProvider as V}from"../../editing/sharedTemplates/SharedTemplateProvider.js";import U from"../../layers/GraphicsLayer.js";import{featureHasFields as L,fixFields as M,getDisplayFieldName as O}from"../../layers/support/fieldUtils.js";import{isSubtypeSublayer as x}from"../../layers/support/layerUtils.js";import{calculateTolerance as q}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as P}from"../../renderers/support/lengthUtils.js";import{getTransformationType as z,TransformationType as E}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import C from"../../symbols/SimpleFillSymbol.js";import R from"../../symbols/SimpleLineSymbol.js";import D from"../../symbols/SimpleMarkerSymbol.js";import{to3D as G}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as B}from"../../symbols/support/symbolUtils.js";import{getServices as N}from"../../undoredo/support/Services.js";import{GraphicState as Z}from"../../views/3d/layers/graphics/GraphicState.js";import{defaultDrawingMode as Q}from"../../views/draw/DrawingMode.js";import{createQueryGeometry as W}from"../../views/support/drapedUtils.js";import{hitTestSelectSimilarDistance as $,filterGraphicHits as J}from"../../views/support/hitTestSelectUtils.js";import{dependencySort as H}from"./support/dependencySort.js";import{isDrawGraphicTool as K}from"../Sketch/support/sketchUtils.js";const X=()=>p.getLogger("esri.widgets.Editor.workflowUtils");function Y(e){return"update"===e.type}function _(e){const t=e.sourceLayer;if(!t||"feature"!==t.type||!ne(t.renderer))return{rotation:null,size:null};let r=null,a=null;const o=t.renderer.getVisualVariablesForType("rotation").filter((e=>(!e.axis||"heading"===e.axis)&&e.field&&!e.valueExpression));1===o.length&&(r=ee(o[0],t));const n=t.renderer.getVisualVariablesForType("size").filter((e=>e.field&&!e.useSymbolValue&&!e.valueExpression&&z(e)===E.RealWorldSize));return 1===n.length&&(a=ae(n[0],t)),{rotation:r,size:a}}function ee(e,t){const r="heading"===(e.axis||"heading")&&"arithmetic"===e.rotationType?-1:1,a=e.field,o=t.fields&&t.fields.filter((e=>e.name===a)),n=o&&1===o.length?o[0].type:"double",i={initial:0,current:0};return{field:a,fieldType:n,getDefaultValue:()=>Promise.resolve(0),getValue:e=>(i.current=i.initial-r*e,oe((i.current+360)%360,n)),setInitialValue:e=>{i.initial=e,i.current=0},isUpdatingInteractively:!1,rotationType:e.rotationType??"geographic"}}function te(e,t){switch(t){case"width":return e[0];case"depth":return e[1];case"height":return e[2];default:return e[2]||e[1]||e[0]}}async function re(e,t,r){if(null==t)return 0;const{symbol:a}=G(t);if(null==a||"web-style"===a.type||"cim"===a.type)return 0;const o=a.symbolLayers.at(0);if(!o)return 0;switch(o.type){case"icon":{const{computeIconLayerResourceSize:e}=await import("../../symbols/support/symbolLayerUtils.js");return Math.min(Qe.icon,(await e(o,Qe.icon))[0])||Qe.icon}case"text":return Qe.text;case"line":return Qe.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return te(await t(o,e.scale/Qe.viewScaleSizeFactor),r)}case"path":case"extrude":return e.scale/Qe.viewScaleSizeFactor;default:return 0}}function ae(e,t){const r=e.field,a=e.axis,o=t.fields&&t.fields.filter((e=>e.name===r)),n=o&&1===o.length?o[0].type:"double",i={initial:0,current:0},s=P[e.valueUnit]??1;let l;return l="area"===e.valueRepresentation?e=>(e*s/2)**2*Math.PI:"radius"===e.valueRepresentation||"distance"===e.valueRepresentation?e=>e*s/2:e=>e*s,{field:r,fieldType:n,getDefaultValue:async(e,t)=>oe(l(await re(t,e,a)),n),getValue:(e,t)=>(i.initial||(i.initial=t.pixelSizeAt(t.center)),i.current=i.initial*e,oe(i.current,n)),setInitialValue:e=>{i.initial=e,i.current=0},isUpdatingInteractively:!1,displayUnit:Je(e.valueUnit),axis:e.axis}}function oe(e,t){switch(t){case"small-integer":case"integer":case"long":return Math.round(e);case"double":case"single":return e;default:return 0}}function ne(e){switch(e?.type){case"class-breaks":case"simple":case"unique-value":case"dot-density":case"dictionary":case"pie-chart":return!0;default:return!1}}async function ie(e,t,r){const a=await B(e,{useSourceLayer:!0,ignoreGraphicSymbol:!0,webStyleCache:t,scale:r});null!=I(e.symbol,a)&&(e.symbol=a)}function se(e,t){if(!e||!t)throw new Error("no geometry type");if("multipatch"===e)return{tool:"mesh",createOptions:{mode:"hybrid"}};const r=new Map;r.set("circle",{mode:"freehand"}),r.set("rectangle",{mode:"freehand"});const a={mode:Q,optionsPerTool:r};if(T(t)){const o=t.defaultTool,n=S(t)?t.definition?.inputGeometryType??e:e;switch(o){case"freehand":case"stream-line":return{tool:"polyline"===n?"freehandPolyline":"freehandPolygon",createOptions:a};case"autocomplete-freehand-polygons":case"stream-polygon":return{tool:"freehandPolygon",createOptions:a};case"autocomplete-polygons":case"difference-polygon":case"create-structures":case"polygon":case"trace":return{tool:"polygon"===n?"polygon":"polyline",createOptions:a};case"circle":return r.get("circle").preserveAspectRatio=!0,{tool:"circle",createOptions:a};case"ellipse":return r.get("circle").preserveAspectRatio=!1,{tool:"circle",createOptions:a};case"create-points-along-line":case"multipoint":return{tool:"multipoint",createOptions:a};case"line":case"radial-line":case"right-angle-line":case"split":case"two-point-line":return{tool:"polyline",createOptions:a};case"rectangle":case"regular-polygon":case"right-angle-polygon":return{tool:"rectangle",createOptions:a};case"elevation-point-from-contour":case"elevation-point-from-dem":case"parcel-seed":case"point":case"point-and-rotation":case"point-at-end-of-line":return{tool:"point",createOptions:a}}}else{const o=t.drawingTool;if("circle"===o||"ellipse"===o)return r.get("circle").preserveAspectRatio="circle"===o,{tool:"circle",createOptions:a};if("rectangle"===o)return{tool:"rectangle",createOptions:a};if("freehand"===o)return{tool:"polygon"===e?"freehandPolygon":"freehandPolyline",createOptions:a}}return{tool:e,createOptions:a}}async function le(e,t,r){const{creationInfo:a,fullTemplate:o}=t;if(!a)throw new i("featureworkflow","No creation info provided.");const n=a.layer,s=ke(o,a.attributeOverrides),{view:l}=e,c="2d"===l?.type;S(o)||j(o)||await Ae(e,n,s,r,c?l.scale:null);const{capabilities:u}=n;e.layer.elevationInfo=n.elevationInfo;const p=se(n.geometryType,o);e.defaultCreateOptions={graphicProperties:{attributes:s,sourceLayer:n},mode:p.createOptions.mode,optionsPerTool:p.createOptions.optionsPerTool,preserveAspectRatio:p.createOptions.preserveAspectRatio,hasZ:u.data.supportsZ,defaultZ:(c?u.editing.zDefault:null)??e.defaultCreateOptions.defaultZ},null==a.geometryToPlace?await e.create(p.tool):await e.place(a.geometryToPlace,{graphicProperties:{attributes:s,sourceLayer:n}})}async function ce(e){return s([await ue(e),await pe(e)])}async function ue({creationAttributes:e,data:t,sketchViewModel:r,view:a,webStyleCache:o}){const{creationInfo:n}=t,{fullTemplate:i}=t;if(!n||"2d"!==a?.type||S(i)||j(i))return null;const s=m((t=>Ae(r,n.layer,e,o,t)));return g((()=>a.scale),(e=>s(e)))}async function pe({data:t,sketchViewModel:r,view:a}){const{templateExecutorInfo:o}=t;if(!o)return null;const n=r.activeComponent;if(!a||!K(n))return X().error(new i("featureworkflow","Failed to set up template feedback.")),null;const c=new U({effect:"saturate(0.6) opacity(0.8)",listMode:"hide",title:"Shared Template Feedback Graphics"});a.map?.add(c);const{executor:u,serviceLayersById:p}=o,d=a.theme?.accentColor??new e([255,165,0,1]);return s([b((()=>n),["cursor-update","vertex-add"],(()=>{c.removeAll();const e=n.graphic?.geometry;if(!e||!de(e))return;const t=u(e,"digitizing");if(!h(t))for(const r of t.edits){const e=p.get(r.id);if(e&&r.addFeatures&&0!==r.addFeatures.length)for(const t of e)if(!t.isTable)for(const e of r.addFeatures){const t=fe(e,d);t&&c.add(t)}}})),l((()=>{a.map.remove(c),c.destroy()}))])}function de(e){switch(e.type){case"point":case"multipoint":return!0;case"polyline":return e.paths[0].length>1;case"polygon":{const t=e.rings[0];return o(t.at(0),t.at(-1))?t.length>2:t.length>1}default:return!1}}function fe(e,r){let a=null;switch(e.geometry?.type){case"point":case"multipoint":a=new D({angle:0,color:r,outline:new R({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:1}),path:"undefined",size:8,style:"circle",xoffset:0,yoffset:0});break;case"polygon":a=new C({color:r,outline:new R({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:3}),style:"none"});break;case"polyline":a=new R({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:2});break;default:return null}return new t({geometry:e.geometry,symbol:a,attributes:{...e.attributes}})}async function ye(e,t){const r=await N(t).load(),a=x(e)?e.parent:e;return r.tablesAndLayersLookup.get(a)}async function me(e,t){const r=await ye(e,t);if(!r)return new Map;const a=new Map;for(const o of r.layersAndTables)d(a,o.layerId,(()=>[])).push(o);return a}function he(e){const t=e.objectIdField,r=e.globalIdField??"";return{id:e.layerId,identifierFields:{objectIdField:t,globalIdField:r},addFeatures:[],deleteAttachments:[],addAttachments:[],deleteFeatures:[],updateFeatures:[]}}function ge(e){const{edits:t,serviceInfo:a,view:o,findOriginalFeature:n}=e,i=be(a.layersAndTables),s=a.layersAndTables.toArray(),{allEditData:l,editDataByLayerIdMap:c,editDataByIdMap:u}=ve(t,i,n),p=Ie(l,we(s,c),c);if(je(l,p,o),0===p.length)return t;const d=H(p,{continueOnCircularDependency:!0}).map((e=>u.get(e))).filter(r),f=new Map;for(const r of d)f.set(r.uniqueId,r);const y=[];for(const r of l)f.has(r.uniqueId)||y.push(r);const m=[];let h=null;for(const r of d){const{layer:e}=r;switch(null==h?h=he(e):h.id!==e.layerId&&(m.push(h),h=he(e)),r.operationType){case"add":case"modify":h.addFeatures.push(r.after);break;case"delete":h.deleteFeatures.push(r.before)}}null!==h&&m.push(h);for(const r of y){const e=r.layer.layerId,t=m.find((t=>t.id===e))??he(r.layer);switch(m.includes(t)||m.push(t),r.operationType){case"add":t.addFeatures.push(r.after);break;case"modify":t.updateFeatures.push(r.after);break;case"delete":t.deleteFeatures.push(r.before);break;case"deleteAttachment":t.deleteAttachments.push(r.attachmentId);break;case"addAttachment":t.addAttachments.push(r.attachment)}}for(const r of m)void 0!==r.deleteAttachments&&0===r.deleteAttachments.length&&delete r.deleteAttachments,void 0!==r.addAttachments&&0===r.addAttachments.length&&delete r.addAttachments;return m}function be(e){const t=new Map;for(const r of e)t.set(r.layerId,r);return t}function we(e,t){const r=new Map;for(const a of e)for(const e of a.relationships??[])if(r.set(Te(a,e),""),t.has(e.relatedTableId)){const o=t.get(e.relatedTableId);if(o.length>0)for(const t of o[0].layer.relationships??[])if(t.id===e.id){r.set(Te(a,e),t.keyField);break}}return r}function ve(e,t,r){const a=new Map,o=[],n=new Map;let s=1;for(const l of e){const e=[],c=t.get(l.id);if(!c)throw new i("featureworkflow",`Failed to prepare applyEdits payload. Layer with id ${l.id} not found.`);for(const t of l.addFeatures??[])e.push({uniqueId:"T"+s++,operationType:"add",layer:c,after:t});for(const t of l.deleteFeatures??[])e.push({uniqueId:"T"+s++,operationType:"delete",before:t,layer:c});for(const t of l.deleteAttachments??[])e.push({uniqueId:"T"+s++,operationType:"deleteAttachment",attachmentId:t,layer:c});for(const t of l.addAttachments??[])e.push({uniqueId:"T"+s++,operationType:"addAttachment",attachment:t,layer:c});for(const t of l.updateFeatures??[])e.push({uniqueId:"T"+s++,operationType:"modify",before:r(t),after:t,layer:c});a.set(c.layerId,e);for(const t of e)o.push(t),n.set(t.uniqueId,t)}return{allEditData:o,editDataByIdMap:n,editDataByLayerIdMap:a}}function Ie(e,t,r){const a=[];for(const o of e){const e=o.layer.relationships??[],{uniqueId:n}=o;for(const i of e){const e=i.keyField;if("origin"===i.role){const s=r.get(i.relatedTableId);if(!s||0===s.length)continue;const l=Te(o.layer,i),c=t.get(l);if(void 0===c||""===c)continue;switch(o.operationType){case"add":for(const t of s)t!==o&&("add"!==t.operationType&&"modify"!==t.operationType||t.after.attributes[c]===o.after.attributes[e]&&a.push([n,t.uniqueId]));break;case"modify":if(o.before.attributes[e]!==o.after.attributes[e])for(const t of s){const r=t.uniqueId;t!==o&&("delete"===t.operationType?t.before.attributes[c]===o.before.attributes[e]?a.push([r,n]):t.before.attributes[c]===o.after.attributes[e]&&a.push([n,r]):"add"===t.operationType?t.after.attributes[c]===o.after.attributes[e]?a.push([n,r]):t.after.attributes[c]===o.before.attributes[e]&&a.push([r,n]):"modify"===t.operationType&&(t.before.attributes[c]!==t.after.attributes[c]?t.after.attributes[c]===o.after.attributes[e]?a.push([n,r]):a.push([r,n]):a.push([n,r])))}break;case"delete":for(const t of s)t!==o&&("delete"!==t.operationType&&"modify"!==t.operationType||t.before.attributes[c]===o.before.attributes[e]&&a.push([t.uniqueId,n]))}}}}return a}function Te(e,t){return`${e.layerId}:${t.id}`}function Se(e,t){return!!(t?.map&&"utilityNetworks"in t.map&&t.map.utilityNetworks?.length&&t.map.utilityNetworks.some((t=>!(!t.loaded||!e.url?.startsWith(t.featureServiceUrl)||e.layerId!==t.networkSystemLayers.associationsTableId))))}function je(e,t,r){const a=[];for(const n of e)Se(n.layer,r)&&a.push(n);if(0===a.length)return;let o=[];for(const n of a){const r=n.layer;switch(n.operationType){case"delete":o=[...Fe(n.before.attributes[r.fieldsIndex.get("fromglobalid").name],e),...Fe(n.before.attributes[r.fieldsIndex.get("toglobalid").name],e)];for(const e of o)t.push([n.uniqueId,e.uniqueId]);break;case"add":o=[...Fe(n.after.attributes[r.fieldsIndex.get("fromglobalid").name],e),...Fe(n.after.attributes[r.fieldsIndex.get("toglobalid").name],e)];for(const e of o)t.push([e.uniqueId,n.uniqueId])}}}function Fe(e,t){const r=[],a=t.filter((({layer:e})=>""!==e.globalIdField&&null!=e.globalIdField));for(const o of a){const t=o.layer.globalIdField;("before"in o&&o.before?.attributes[t]===e||"after"in o&&o.after?.attributes[t]===e)&&r.push(o)}return r}function ke(e,t={}){return S(e)||j(e)?{}:F(e)?{...e.prototype.attributes,...t}:k(e)?{...e.definition?.defaultValues,...t}:{...t}}async function Ae(e,r,a,o,n){const i=new t({sourceLayer:r,attributes:a}),{rotation:s,size:l}=_(i);let c=await B(i,{useSourceLayer:!0,webStyleCache:o,scale:n}),u=!1;for(const t of[l,s]){if(null==t)continue;null==a[t.field]&&(a[t.field]=await t.getDefaultValue(c,e.view),u=!0)}switch(u&&(c=await B(i,{useSourceLayer:!0,webStyleCache:o,scale:n})),c?.type){case"simple-fill":case"polygon-3d":e.polygonSymbol=c;break;case"simple-line":case"line-3d":e.polylineSymbol=c;break;case"simple-marker":case"picture-marker":case"point-3d":case"cim":e.pointSymbol=c;break;case"mesh-3d":e.meshSymbol=c}Ve(e.tooltipOptions,l,s)}function Ve(e,t,r){e.visualVariables=null!=t||null!=r?{size:null!=t?{unit:t.displayUnit,axis:t.axis,valueType:t.fieldType}:null,rotation:null!=r?{valueType:r.fieldType,rotationType:r.rotationType??"geographic"}:null}:null}function Ue(e,t){return e?.find((e=>e.layer===t))}async function Le(e,t,r,a){switch(t.type){case"3d":return Me(e,t,r,a);case"2d":return Oe(e,t,r,a)}}async function Me(e,t,r,o){if(0===e.length)return[];const{updatable:n,graphicsByLayer:i}=await r.async((async()=>{const{results:a}=await f($(t,r),o),n=new Map,i=e=>{const t=e.layer,r=n.get(t);if(!r){const e=new Array;return n.set(t,e),e}return r};J(a).forEach((({graphic:e})=>i(e).push(e)));const s=e.filter((({capabilities:e,layer:t})=>e.update.enabled&&n.has(t)));return 0!==s.length&&r.stopPropagation(),{updatable:s,graphicsByLayer:n}}));return f(Promise.allSettled(n.map((async({layer:e})=>{const t=i.get(e),r=xe(e);if(t.every((e=>L(r,e))))return t;const n=[];for(const o of t){n.push(o.getObjectId());const e=Object.keys(o.attributes);a(r,e)}const s=e.createQuery();return s.returnGeometry=!1,s.objectIds=n,s.outFields=M(e.fieldsIndex,r),e.queryFeatures(s,{signal:o}).then((({features:e})=>e))}))),o)}async function Oe(e,t,r,a){if(0===e.length)return[];const{mapPoint:o}=r;if(null==o)return[];let n=null;const i=await r.async((async()=>{const{results:o}=await f(t.hitTest(r),a);if(0===o.length)return[];const i=new Set;n=J(o),n.forEach((({graphic:e})=>e&&i.add(e.layer)));const s=e.filter((e=>i.has(e.layer)&&e.supportsUpdateWorkflow));return s.length>0&&r.stopPropagation(),s}));return f(Promise.allSettled(i.map((async({layer:e})=>{const i=e.createQuery();i.returnGeometry=!0,i.outFields=xe(e);const s="renderer"in e?q({renderer:e.renderer,pointerType:r.pointerType}):0;i.geometry=W(o,s,t),i.outSpatialReference=t.spatialReference;const{features:l}=await e.queryFeatures(i,{signal:a});return n?.forEach((({graphic:t})=>{t.layer!==e||l.some((e=>e.getObjectId()===t.getObjectId()))||l.push(t)})),l}))),a)}function xe(e){return M(e.fieldsIndex,[e.objectIdField,O({displayField:"displayField"in e?e.displayField:null,fields:e.fields})])}async function qe(e,t,a,o){const n=t.createQuery();n.objectIds=e.map((e=>e.getObjectId())).filter(r),n.outFields=["*"],n.returnM=t.capabilities.data.supportsM,n.returnZ=t.capabilities.data.supportsZ,"scene"===t.type&&null!=t.infoFor3D||(n.outSpatialReference=a);const i=await t.queryFeatures(n,{signal:o});return y(o),i.features}function Pe(e){const t=new Map;for(const r of e){const e=r.sourceLayer,a=x(e)?e.parent:e;d(t,a,(()=>[])).push(r)}return t}async function ze(e){const{graphic:t,sketchViewModel:r,sourceLayer:a,visualVariables:o}=e;await Ee(e);const n={multipleSelectionEnabled:!1};return"point"===a.geometryType&&(n.enableRotation=null!=o.rotation,n.enableScaling=null!=o.size),r.update(t,n)}async function Ee(e){const{graphic:t,sketchViewModel:r,sourceLayer:a,visualVariables:o,webStyleCache:n}=e;let i=!1;const{rotation:s,size:l}=o;for(const c of[s,l]){if(null==c)continue;const e=t.getAttribute(c.field);if(null!=e)c.setInitialValue(e);else{const e=await c.getDefaultValue(t.symbol,r.view);c.setInitialValue(e),t.setAttribute(c.field,e),i=!0}}if(i){const e="2d"===r.view?.type?r.view.scale:null;await ie(t,n,e)}Ve(r.tooltipOptions,l,s),r.layer.elevationInfo=a.elevationInfo}function Ce(e){return null==e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function Re(e){return null==e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}async function De(e,t,r,a,o){if(null==t.geometry||"point"!==t.geometry?.type)return;const n=a.rotation,i=Ce(r.toolEventInfo);if(null!=n&&null!=i){const{field:r,getValue:a}=n;"rotate-stop"===i.type?(n.isUpdatingInteractively=!1,n.setInitialValue(t.getAttribute(r))):(n.isUpdatingInteractively=!0,t.setAttribute(r,a(i.angle,e)))}const s=a.size,l=Re(r.toolEventInfo);if(null!=s&&null!=l){const{field:r,getValue:a}=s;"scale-stop"===l.type?(s.isUpdatingInteractively=!1,s.setInitialValue(t.getAttribute(r))):(s.isUpdatingInteractively=!0,t.setAttribute(r,a(l.xScale,e)))}await ie(t,o,"2d"===e.type?e.scale:null)}async function Ge({feature:e,featureClone:t,visualVariableAttributes:r,sketchViewModel:a,view:o,onUpdate:n,webStyleCache:i,addUpdatingPromise:u,addHandle:p}){await ie(t,i,"2d"===o.type?o.scale:null);let d=null;if("2d"===a?.view?.type){const e=m((e=>ie(t,i,e)));d=g((()=>a?.view?.scale),(t=>e(t)))}const f=t.sourceLayer,y=Xe(o,f);await ze({graphic:t,sketchViewModel:a,sourceLayer:f,visualVariables:r,webStyleCache:i});let h=null;y.then((e=>h=e)).catch((()=>{}));const b=r.size,v=r.rotation,I=g((()=>e.attributes),(async e=>{let r=!1;for(const a in e){const o=e[a];o!==t.getAttribute(a)&&(t.setAttribute(a,o),null==b||b.isUpdatingInteractively||b.field!==a||b.setInitialValue(o),null==v||v.isUpdatingInteractively||v.field!==a||v.setInitialValue(o),(null==h||h.requiredFields.includes(a))&&(r=!0))}r&&await ie(t,i,"2d"===o.type?o.scale:null)})),T=a.on("update",(async e=>{const t=e.graphics[0],s={graphic:t,sketchViewModel:a,sourceLayer:f,visualVariables:r,webStyleCache:i};if("complete"===e.state){if(null===o.activeTool)return ze(s);const e=new AbortController,t=c(e);return p(t),u(w((()=>null===o.activeTool),e.signal).then((()=>(e.abort(),ze(s)))))}await De(o,t,e,r,i),n(_e(t),e)})),S=a.on(["undo","redo"],(async e=>{n(_e(e.graphics[0]),e)}));return s([S,T,l((()=>a.cancel())),I,d])}async function Be(e,t,r){const a=e.view;e.layer.add(r);const o=t.sourceLayer,i=t.layer,c=t.getAttribute(i.objectIdField);let u=null;function p(e){u?.abort(),u=n((async t=>{const r=await Xe(a,o);y(t),r.setVisibility?.(c,e)}))}return await Ze(a,r),p(!1),s([Ne(a,r,(e=>p(!e))),l((async()=>{p(!0);try{const e=await Xe(a,o);await w((()=>!e.updating))}finally{e.layer.remove(r)}}))])}function Ne(e,t,r){if("3d"===e.type){const a=new Z({graphic:t});return s([e.trackGraphicState(a),g((()=>a.displaying),r)])}return g((()=>t.visible),r)}async function Ze(e,t){if("3d"===e.type){const r=new Z({graphic:t}),a=e.trackGraphicState(r);await w((()=>r.displaying||r.error)),a.remove()}else await w((()=>t.visible))}const Qe={icon:v(24),text:v(12),line:v(1),viewScaleSizeFactor:100};function We(e,t,r){let a=!1;return e.filter((e=>!!a||(a=e===t,a))).map((e=>r[e]()))}function $e(e,t){e.viewModel.syncFeatureTemplates();const r=e.creationInfo;if("awaiting-feature-creation-info"===t[0].id&&r){const a=r.layer,o=e.viewModel.getTemplatesForLayer(a);1===o.length&&"scene"!==a.type&&(r.template=o[0],t.shift())}return t}function Je(e){return"unknown"===e?null:e}function He(e){e.filesEnabled=!0,e.mode="view",e.capabilities={editing:!0,operations:{add:!0,update:!0,delete:!0}}}const Ke=e=>/-stop/.test(e)||/vertex-/.test(e),Xe=(e,t)=>{const r="subtype-sublayer"===t.type?t.parent:t;return e.whenLayerView(r)};function Ye(e){return"createInteractiveEditSession"in e}function _e(e){const t=e.geometry;if("mesh"===t?.type){const r=e.cloneShallow();return r.attributes=u(e.attributes),r.geometry=t.cloneShallow(),r.geometry.transform=t.transform?.clone()??null,r}return e.clone()}function et(e){const t=e.cursor;return e.cursor="progress",l((()=>e.cursor=t))}async function tt(e,t){const{template:r}=e;if(null==r)return null;if(A(r))return r.load();if(T(r)){const e=(await import("../../editing/sharedTemplates/SharedTemplate.js")).default,a=V(t,{makeSharedTemplateFromJSON:t=>e.fromJSON(t)}),o=await a.getTemplates({templateIds:[r.templateId],featureService:r.featureService});if(0===o.length)throw new i("editor:failed-to-load-template","Unable to load the provided template");return o[0].load()}return r}function rt(e){for(const t of e){const{destinationGraphic:e,destinationField:r,sourceGraphic:a,sourceField:o}=t;e.setAttribute(r,a.getAttribute(o))}}function at(e){const t=e.templateExecutorInfo?.completionResults;return t?.length?(t.forEach((e=>rt(e.relationships))),t.flatMap((e=>e.edits))):null}export{je as appendAllUtilityNetworkAssociationRelationships,$e as avoidFeatureTemplateSelectionWithOnlyOneItem,Ye as canCreateInteractiveEditSession,_e as cloneGraphicExceptMesh,be as createLayerIdMap,we as createRelationshipKeyMap,se as createToolFromGeometryType,We as createWorkflowSteps,Le as fetchCandidates,qe as fetchFullFeatures,Ie as findAllDependencies,Fe as findChangesByGlobalId,Ue as findLayerInfo,Te as generateHashForRelationship,ke as getCreationAttributes,tt as getFullTemplateForCreationInfo,at as getServiceEditsFromWorkflowData,ye as getServiceInfoForLayer,me as getServiceLayersById,_ as getVisualVariableAttributes,Pe as groupFeaturesByLayer,Ke as isTerminalUpdateEventType,Y as isUpdateWorkflow,Se as isUtilityNetworkAssociationsTable,ge as orderEditsByRelationshipDependencies,He as prepareAttachmentsForCreateFeaturesWorkflow,rt as setRelationshipFields,Ge as setUpGeometryUpdate,ce as setUpSketchCreateWatchers,Ee as setVisualVariablesAndElevationInfoForUpdate,et as showProgressCursor,Qe as sizeDefaults,Je as sizeVariableUnitToLengthUnit,le as startCreatingNewFeature,ze as startUpdatingFeatureGeometry,Be as swapForEditingSession,ie as updateGraphicSymbolWhenRequired,De as visualVariableInteractiveUpdate,Xe as whenEditorLayerView,Ze as whenGraphicDisplayed};
package/widgets/Editor.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.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{destroyMaybe as t,mappedFind as s,abortMaybe as o}from"../core/maybe.js";import{createResolver as i}from"../core/promiseUtils.js";import{watch as a,initial as r,on as n,when as l}from"../core/reactiveUtils.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as d}from"../core/accessorSupport/decorators/subclass.js";import m from"../views/interactive/sketch/SketchValueOptions.js";import h from"./Attachments.js";import p from"./FeatureForm.js";import u from"./FeatureTemplates.js";import g from"./Spinner.js";import w from"./Widget.js";import{css as _}from"./Editor/css.js";import v from"./Editor/EditorViewModel.js";import{isModelUpload as f}from"./Editor/modelUploadUtils.js";import y from"./Editor/VisibleElements.js";import{loadCreateFeaturesPanelContentComponents as k,CreateFeaturesPanelContent as b}from"./Editor/components/CreateFeaturesPanelContent.js";import{loadFeatureListComponents as A,FeatureList as F}from"./Editor/components/FeatureList.js";import{loadFooterActionsComponents as M,FooterActions as T}from"./Editor/components/FooterActions.js";import{loadNoticesComponents as C,Notice as W}from"./Editor/components/Notices.js";import{loadPanelContentComponents as E,PanelContent as P,PanelContentSection as L,PanelContentMessage as S}from"./Editor/components/PanelContent.js";import{PanelToolbar as I,loadPanelToolbarComponents as j}from"./Editor/components/PanelToolbar.js";import{loadPromptComponents as U,Prompt as D}from"./Editor/components/Prompt.js";import{loadUpdateFeaturePanelContentComponents as V,UpdateFeaturePanelContent as O}from"./Editor/components/UpdateFeaturePanelContent.js";import{loadUploadDetailsComponents as x,UploadDetails as B}from"./Editor/components/UploadDetails.js";import N from"./FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationItemList.js";import z from"./FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationSettings.js";import{VisibleElements as R,CreateToolVisibilityMap as G}from"./Sketch/VisibleElements.js";import{loadCalciteComponents as H}from"./support/componentsUtils.js";import{globalCss as q}from"./support/globalCss.js";import{incrementHeadingLevel as Z,Heading as K}from"./support/Heading.js";import{renderItem as $}from"./support/ItemList.js";import{connectDelayedLoading as J}from"./support/loaderUtils.js";import"./support/widgetUtils.js";import{messageBundle as Q}from"./support/decorators/messageBundle.js";import{vmEvent as X}from"./support/decorators/vmEvent.js";import{tsx as Y}from"./support/jsxFactory.js";import{substitute as ee}from"../intl/substitute.js";const te=Symbol("sketch-setup-handles");let se=class extends w{constructor(e,t){super(e,t),this._featureForm=new p,this._sketchToolbar=null,this._attachments=new h({visibleElements:{addSubmitButton:!1,cancelAddButton:!1,cancelUpdateButton:!1,deleteButton:!1,errorMessage:!1,progressBar:!1,updateButton:!1}}),this._associationItemList=new N,this._associationSettings=new z,this._featureTemplates=new u({enableListScroll:!1,renderItemContentEnd:e=>e.supportsUpload?Y("calcite-icon",{class:_.templateItemContentEnd,icon:"upload-to",key:"upload-icon"}):null,renderItemLabel:e=>e.label,renderCustomGroupContent:e=>this._renderCustomTemplateGroupContent(e)}),this._filterText="",this._prompt=null,this._spinner=new g,this._loading=!1,this.headingLevel=4,this.messages=null,this.messagesCommon=null,this.messagesTemplates=null,this.messagesFeature=null,this.supportingWidgetDefaults=null,this.viewModel=new v,this.visibleElements=new y,this._renderAttachments=()=>this._attachments.render(),this._renderFeatureForm=()=>this._featureForm.render(),this._renderAssociationItemList=()=>this._associationItemList.render(),this._renderAssociationSettings=()=>this._associationSettings.render(),this._renderFeatureTemplates=()=>this._featureTemplates.render(),this._renderSketch=()=>this._sketchToolbar?Y("div",{class:_.sketchContainer,key:"editor-sketch-container"},this._sketchToolbar?.render()):void 0,this._renderSelectIcon=()=>Y("calcite-icon",{icon:"cursor",slot:"content-start"}),this.EditorPanel=({heading:e,key:t,selected:s},...o)=>{const{visibleElements:i}=this;return Y("calcite-flow-item",{closable:!1,heading:e,headingLevel:this.headingLevel,key:t,loading:this._loading,selected:s,onCalciteFlowItemBack:this._onBack},i.zoomToButton&&this.viewModel.canZoomTo?Y("calcite-action",{alignment:"center",appearance:"transparent",icon:"zoom-to-object",key:"zoom-to-button",onclick:()=>this.viewModel.zoomTo(),slot:"header-actions-end",text:this.messages.zoomTo,title:this.messages.zoomTo}):null,i.settingsMenu?Y(I,{editorViewModel:this.viewModel,messagesCommon:this.messagesCommon,visibleElements:i}):null,...o)},this._showDiscardEditsPrompt=()=>{const{messages:e,activeWorkflow:t}=this,s={title:e.cancelEditTitle,message:e.cancelEditWarningMessage,yesLabel:e.discardEdits,noLabel:e.continueEditing};return"create-features"===t?.type&&f(t.data.creationInfo)?this._showPromptAndWait("success"===t.data.upload?.state?e.modelUploads.cancelPlacementPrompt:e.modelUploads.cancelUploadPrompt):"update"===t?.type&&t.activeFeatureFormViewModel?.activeAssociation?this._showPromptAndWait({...s,message:e.cancelAssociationEditWarning}):this._showPromptAndWait(s)},this._showGenericCancelPrompt=()=>{const{messages:e,messagesCommon:t}=this;return this._showPromptAndWait({title:e.cancelRequestTitle,message:e.cancelRequestWarningMessage,yesLabel:t.form.yes,noLabel:t.form.no})},this._showPrompt=e=>{this._prompt?.cancel?.(),this._prompt=e},this._clearPrompt=()=>{this._prompt=null},this._onSave=()=>{this.viewModel.saveWorkflow()},this._onDelete=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({title:e.deleteWarningTitle,message:e.deleteWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.deleteFeatureFromWorkflow(),this._clearPrompt()}},secondary:{label:e.keepFeature,action:this._clearPrompt}}})},this._onDeleteAssociation=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({title:e.deleteAssociationTitle,message:e.deleteAssociationMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.deleteAssociationFromWorkflow(),this._clearPrompt()}},secondary:{label:e.keepAssociation,action:this._clearPrompt}}})},this._onToggleUpdateWorkflow=()=>this.viewModel.toggleUpdateWorkflow(),this._onBack=e=>(e?.stopPropagation(),this.viewModel.back()),this._onAttachmentAdd=()=>{const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type||"update"===e.type&&"create-features"===e.activeWorkflow?.type?(this._attachments.addFile(),e.back()):this._attachments.addAttachment().then((()=>e.back())))},this._onAttachmentUpdate=()=>{const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type?(this._attachments.updateFile(),e.back()):this._attachments.updateAttachment().then((()=>e.back())))},this._onAttachmentDelete=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({title:e.deleteAttachmentWarningTitle,message:e.deleteAttachmentWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:this._onAttachmentDeleteConfirm},secondary:{label:e.keepAttachment,action:this._clearPrompt}}})},this._onAttachmentDeleteConfirm=async()=>{const e=this._attachments,{activeWorkflow:t}=this.viewModel;t&&("create-features"===t.type?e.deleteFile():(await e.deleteAttachment(e.viewModel.activeAttachmentInfo),this._clearPrompt()),await t.back(),this._clearPrompt())},this._onAttachmentsError=e=>{this._showPrompt({title:this.messages.errorWarningTitle,message:e.message,context:"warning",actions:{primary:{label:this.messagesCommon.form.ok,action:this._clearPrompt}}})}}initialize(){this._featureForm.showPrompt=this._showPrompt,this._featureForm.clearPrompt=this._clearPrompt,this.addHandles([a((()=>Z(this.headingLevel)),(e=>{this._featureForm.headingLevel=e,this._featureTemplates.headingLevel=e}),r),n((()=>this.viewModel.activeWorkflow),"cancel-request",(({controller:e})=>{(this.viewModel.hasPendingEdits?this._showDiscardEditsPrompt():this._showGenericCancelPrompt()).then((t=>t?e.allow():e.deny()))})),l((()=>this.viewModel.featureFormViewModel),(e=>{this._featureForm.viewModel=e}),r),l((()=>this.viewModel.utilityNetworkAssociationAddAssociationViewModel),(e=>{this._associationItemList.viewModel=e}),r),l((()=>this.viewModel.utilityNetworkAssociationAddAssociationViewModel?.association),(()=>{this._setUpAssociationSettings()})),a((()=>this.viewModel),(e=>{this._attachments.viewModel=e?.attachmentsViewModel??null,this._featureTemplates.viewModel=e?.featureTemplatesViewModel??null,this._spinner.viewModel=e?.spinnerViewModel??null,e.showDiscardEditsPrompt=this._showDiscardEditsPrompt}),r),a((()=>this.view),((e,t)=>{const s=`editor-${this.id}-spinner`;t?.ui.remove(this._spinner,s),e?.ui.add(this._spinner,{key:s,position:"manual"}),this._associationItemList.view=e}),r),a((()=>[this.supportingWidgetDefaults,this.viewModel.sketchViewModel]),(([e])=>{e&&(this._featureForm.set(e.featureForm),this._attachments.set(e.attachments),this._featureTemplates.set(e.featureTemplates),this.viewModel.sketchViewModel?.set(e.sketch))}),r),l((()=>this._attachments?.error),(e=>this._onAttachmentsError(e))),l((()=>this.viewModel?.failures),(e=>{const{messages:t}=this,[{error:s,retry:o,cancel:i}]=e;this._showPrompt({title:t.errorWarningTitle,message:ee(t.errorWarningMessageTemplate,{errorMessage:s.message}),context:"warning",actions:{primary:{label:t.retry,action:()=>{o(),this._clearPrompt()}},secondary:{label:t.ignore,action:()=>{i(),this._clearPrompt()}}}})})),a((()=>this.viewModel?.state),(e=>{switch(e){case"awaiting-feature-to-update":case"ready":case"disabled":this._filterText="",this._featureTemplates.filterText=""}})),a((()=>this.viewModel.featureFormDisabled),(e=>this._featureForm.disabled=e)),a((()=>this.visibleElements.sketch),(()=>this._setupSketch()),r),J({getLoading:()=>{const{viewModel:e}=this;return e.syncing||e.updating||this._attachments.submitting},setEffectiveLoading:e=>{this._loading=e}})])}destroy(){this._associationItemList.destroy(),this._associationSettings.destroy(),this._attachments.destroy(),this._featureForm.destroy(),this._featureTemplates.destroy(),this._sketchToolbar=t(this._sketchToolbar)}loadDependencies(){return Promise.all([H({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),list:()=>import("@esri/calcite-components/dist/components/calcite-list")}),k(),A(),M(),C(),E(),j(),U(),V(),x()])}get _deleteButtonCommonInfo(){return{appearance:"outline",kind:"danger"}}get activeWorkflow(){return this.viewModel.activeWorkflow}get hideTemplatesForInactiveLayers(){return this.viewModel.hideTemplatesForInactiveLayers}set hideTemplatesForInactiveLayers(e){this.viewModel.hideTemplatesForInactiveLayers=e}get icon(){return"pencil"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get labelOptions(){return this.viewModel.labelOptions}set labelOptions(e){this.viewModel.labelOptions=e}get layerInfos(){return this.viewModel.layerInfos}set layerInfos(e){this.viewModel.layerInfos=e}get snappingOptions(){return this.viewModel.snappingOptions}set snappingOptions(e){this.viewModel.snappingOptions=e}get tooltipOptions(){return this.viewModel.tooltipOptions}set tooltipOptions(e){this.viewModel.tooltipOptions=e}get valueOptions(){return this.viewModel.valueOptions}set valueOptions(e){this.viewModel.valueOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.viewModel.startCreateFeaturesWorkflowAtFeatureTypeSelection()}startCreateFeaturesWorkflowAtFeatureCreation(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureCreation(e)}startCreateFeaturesWorkflowAtFeatureEdit(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureEdit(e)}startUpdateWorkflowAtFeatureSelection(){return this.viewModel.startUpdateWorkflowAtFeatureSelection()}startUpdateWorkflowAtMultipleFeatureSelection(e){return this.viewModel.startUpdateWorkflowAtMultipleFeatureSelection(e)}startUpdateWorkflowAtFeatureEdit(e){return this.viewModel.startUpdateWorkflowAtFeatureEdit(e)}deleteFeatureFromWorkflow(){return this.viewModel.deleteFeatureFromWorkflow()}deleteAssociationFromWorkflow(){return this.viewModel.deleteAssociationFromWorkflow()}cancelWorkflow(e){return this.viewModel.cancelWorkflow(e)}render(){const{visibleElements:e,viewModel:t}=this,s=this.classes(_.base,q.widget,q.panel);if(!t)return Y("div",{class:s,key:"empty"});const{pageStack:o}=t,i=o.length-1,a=o.map(((e,t)=>this._renderPage(e,t===i)));return Y("div",{class:s,key:"base"},e.flow?Y("calcite-flow",{key:"flow"},a):a,this._prompt?Y(D,{...this._prompt,headingLevel:this.headingLevel}):void 0)}_renderPage(e,t){const s={selected:t};switch(e){case"disabled":break;case"ready":return this._renderReady(s);case"awaiting-feature-creation-info":return this._renderAwaitingFeatureCreationInfo(s);case"creating-features-upload-details":return this._renderUploadDetails(s);case"creating-features":return this._renderCreatingFeatures(s);case"editing-existing-feature":case"editing-attributes":return this._renderUpdateFeature(s);case"awaiting-update-feature-candidate":return this._renderFeatureList(s);case"adding-attachment":return this._renderAttachmentAdding(s);case"editing-attachment":return this._renderAttachmentEditing(s);case"viewing-associated-layers":case"viewing-associated-features":return this._renderViewAssociatedLayers(s);case"add-association-select-layer":case"add-association-select-feature":return this._renderSelectFeature(s);case"add-association-create-association":return this._renderAddAssociation(s)}return Y("div",{key:"empty-page"})}_renderAwaitingFeatureCreationInfo(e){const{EditorPanel:t,messages:s}=this;return Y(t,{heading:s.selectTemplate,key:"templates-panel",...e},Y(P,{key:"feature-templates"},Y(L,null,this._renderFeatureTemplates())))}_renderUploadDetails(e){const{EditorPanel:t,activeWorkflow:s,messages:o}=this;if("create-features"!==s?.type)return null;const i=s.data.upload;return i?Y(t,{heading:o.createFeatures,key:"upload-details-panel",...e},Y(B,{helpMessage:this._helpMessage,messages:o,upload:i})):null}_renderCreatingFeatures(e){const{EditorPanel:t,activeWorkflow:s,messages:o,messagesCommon:i,headingLevel:a,viewModel:r}=this;if(!s)return null;const n="create-features"===s.type&&s.numPendingFeatures>0||"update"===s.type&&"create-features"===s?.activeWorkflow?.type&&s.activeWorkflow?.numPendingFeatures>0;return Y(t,{heading:o.createFeatures,key:"create-features-panel",...e},n?Y(O,{editorViewModel:r,headingLevel:a,messages:o,messagesCommon:i,renderAttachments:this._renderAttachments,renderFeatureForm:this._renderFeatureForm,renderSketchToolbar:this._renderSketch,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave}):Y(b,{helpMessage:this._helpMessage,renderSketchToolbar:this._renderSketch}))}_renderUpdateFeature(e){const{EditorPanel:t,messages:s,messagesCommon:o,headingLevel:i,viewModel:a}=this;return Y(t,{heading:s.editFeature,key:"update-feature-panel",...e},Y(O,{editorViewModel:a,headingLevel:i,messages:s,messagesCommon:o,renderAttachments:this._renderAttachments,renderFeatureForm:this._renderFeatureForm,renderSketchToolbar:this._renderSketch,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave}))}_getAssociationTypeTitle(e){const{messages:t}=this;if(!e)return t.editFeature;if(e.title)return e.title;const{messagesFeature:s}=this;switch(e.type){case"attachment":return s.associationsAttachments;case"connectivity":return s.associationsConnectivity;case"structure":return s.associationsStructure;case"content":return s.associationsContents;case"container":return s.associationsContainer}}_getAddAssociationTypeTitle(e){const{messages:t}=this;if(!e)return t.editFeature;const s=t.associations;switch(e.type){case"attachment":return s.addAttachment;case"connectivity":return s.addConnectivity;case"structure":return s.addStructure;case"content":return s.addContent;case"container":return s.addContainer}}_renderViewAssociatedLayers(e){const{EditorPanel:t,messages:s,messagesCommon:o,headingLevel:i,viewModel:a}=this,r=a.featureFormViewModel?.activeAssociationInput?.activeAssociationType,n=this._getAssociationTypeTitle(r);return Y(t,{heading:n,key:"viewing-associated-layers-panel",...e},Y(O,{editorViewModel:a,headingLevel:i,messages:s,messagesCommon:o,renderAttachments:this._renderAttachments,renderFeatureForm:this._renderFeatureForm,renderSketchToolbar:this._renderSketch,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave}))}_renderSelectFeature(e){const{_associationItemList:t,EditorPanel:s,viewModel:o,messagesCommon:i}=this,a=o.utilityNetworkAssociationAddAssociationViewModel,r=this._getAddAssociationTypeTitle(a?.associationType),n="ready"!==a?.state;return Y(s,{heading:r,key:"add-association-select-feature",...e},Y(P,{key:"select-feature"},Y(L,null,this._renderAssociationItemList())),Y(T,{buttons:[t.filterOptionsVisible?{appearance:"solid",label:i.apply,disabled:n,onClick:()=>t.applyFilterOptions(),type:"button"}:void 0,{appearance:"outline",label:i.cancel,disabled:n,onClick:()=>{"update"===o.activeWorkflow?.type&&(t.viewModel.featureSpatialItems.length&&t.highlightHelper?.removeAll(),o.activeWorkflow.cancelActiveWorkflow())},type:"button"}]}))}_setUpAssociationSettings(){const{viewModel:e,_associationSettings:t}=this,s=e.utilityNetworkAssociationAddAssociationViewModel,o="update"===e.activeWorkflow?.type?e.activeWorkflow:null,i=o?o.activeWorkflow:null,a="add-association"===i?.type?i.sourceFeatureItem:null,r=s?.selectedFeature,n=s?.association,l=s?.utilityNetwork;a&&r&&n&&l&&(t.sourceFeature=a,t.targetFeature=r,t.association=n,t.utilityNetwork=l)}_renderAddAssociation(e){const{EditorPanel:t,viewModel:s,messagesCommon:o}=this,i=s.utilityNetworkAssociationAddAssociationViewModel,a=this._getAddAssociationTypeTitle(i?.associationType),r="ready"!==i?.state;return Y(t,{heading:a,key:"add-association",...e},Y(P,{key:"add-association-content"},Y(L,null,this._renderAssociationSettings())),Y(T,{buttons:[{label:o.add,disabled:r||!i.canAddAssociation,onClick:()=>this._onSave(),type:"button"},{appearance:"outline",label:o.cancel,disabled:r,onClick:()=>{"update"===s.activeWorkflow?.type&&s.activeWorkflow.cancelActiveWorkflow()},type:"button"}]}))}_renderCustomTemplateGroupContent(e){const{messages:t,viewModel:o}=this,i=s(e.group.items,(e=>o.itemHasInvalidFormTemplate(e)?t.formFieldCreateError:void 0));return i?Y(W,{kind:"warning",message:i}):null}_renderAttachmentAdding(e){const{EditorPanel:t,_attachments:s,messages:o,messagesCommon:i}=this;return Y(t,{heading:o.addAttachment,key:"attachment-adding-panel",...e},Y(P,{key:"attachments"},this._renderAttachments()),Y(T,{buttons:[{label:s.submitting?i.cancel:i.add,disabled:s.submitting||!s.selectedFile,onClick:this._onAttachmentAdd,type:"button"}]}))}_renderAttachmentEditing(e){const{EditorPanel:t,_attachments:s,activeWorkflow:o,messages:i,messagesCommon:a}=this;return o?Y(t,{heading:i.editAttachment,key:"attachment-editing-panel",...e},Y(P,{key:"attachments"},this._renderAttachments()),o.shouldAllowAttachmentEditing?Y(T,{buttons:[{label:a.update,disabled:s.submitting||!s.selectedFile,onClick:this._onAttachmentUpdate,type:"button"},{...this._deleteButtonCommonInfo,onClick:this._onAttachmentDelete,disabled:s.submitting,label:a.delete,type:"button"}]}):void 0):null}_renderReady(e){const{EditorPanel:t,messages:s,viewModel:o,visibleElements:i}=this,a=this._helpMessage;return Y(t,{heading:s.widgetLabel,key:"landing-panel",...e},Y(P,{key:"landing-content"},o.editorItems.length?[i.editFeaturesSection?Y(L,{key:"edit-actions"},this._renderUpdateActions()):null,i.createFeaturesSection&&o.canCreateVisible?Y(L,{key:"create-actions"},this._renderCreateActions()):null]:Y(S,{key:"no-content"},s.noEditableLayers)),a?Y("div",{class:_.helpMessage,key:"footer-actions",slot:"footer"},a):void 0)}get _helpMessage(){const{activeWorkflow:e,messages:t,view:s}=this,o=e?.helpMessage;return o?t["3d"===s?.type?"helpMessages3d":"helpMessages2d"]?.[o]:void 0}_renderUpdateActions(){const{messages:e,messagesCommon:t,viewModel:s}=this,o={id:"select",label:t.select};return Y("div",{class:_.updateActions,key:"update-actions"},Y(K,{level:Z(this.headingLevel)},e.editFeatures),Y("calcite-list",{class:_.updateActionsList,label:e.editFeaturesList,selectionAppearance:"border",selectionMode:"single"},$({disabled:!s.canUpdateVisible,grouped:!1,item:o,selectedItem:"awaiting-feature-to-update"===s.activeWorkflow?.stepId?o:void 0,renderIcon:this._renderSelectIcon,onItemSelect:this._onToggleUpdateWorkflow})))}_renderCreateActions(){return Y("div",{key:"create-actions"},Y(K,{level:Z(this.headingLevel)},this.messages.createFeatures),Y("div",{class:_.featureTemplatesContainer,key:"templates"},this._renderFeatureTemplates()))}_renderFeatureList(e){const{EditorPanel:t,viewModel:s}=this,{activeWorkflow:o}=s;if("update"!==o?.type)return null;const i=o.data.candidates,a=ee(this.messages.multipleFeaturesTemplate,{total:i.length});return Y(t,{heading:a,key:"feature-list",...e},Y(F,{editorItems:s.editorItems,editorMessages:this.messages,filterText:this._filterText,id:this.id,messagesTemplates:this.messagesTemplates,workflow:o,onFilterTextChange:e=>this._filterText=e,onSelectFeature:(e,t)=>s.selectFeature(e,t),onZoomTo:e=>s.zoomTo(e)}))}_showPromptAndWait({title:e,message:t,yesLabel:s,noLabel:o}){const a=i(),{view:r}=this,n=r?.focused;return this._showPrompt({title:e,message:t,context:"danger",actions:{primary:{label:s,action:()=>a.resolve(!0)},secondary:{label:o,action:()=>a.resolve(!1)}}}),a.promise.finally((()=>{this._clearPrompt(),n&&r?.focus()}))}async _setupSketch(){if(!!!this.visibleElements.sketch)return this._sketchImportAbortController=o(this._sketchImportAbortController),this._sketchToolbar=t(this._sketchToolbar),void this.removeHandles(te);if(this._sketchImportAbortController)return;const e=new AbortController;this._sketchImportAbortController=e;const s=await import("./Sketch.js");if(!e.signal.aborted)try{this._sketchToolbar=new s.default({toolbarKind:"docked",contextualToolLocation:"inline-end",scale:"s",visibleElements:new R({deleteButton:!1,settingsMenu:!1,directionModePicker:!1,selectionCountLabel:!1,duplicateButton:!1,createTools:new G({freehandPolygon:!0,freehandPolyline:!0})})}),this.addHandles([a((()=>this.viewModel.activeLeafWorkflow?.availableCreateTools),(e=>{this._sketchToolbar&&(this._sketchToolbar.availableCreateTools=e)}),r),a((()=>this.visibleElements.undoRedoButtons),(e=>{this._sketchToolbar&&(this._sketchToolbar.visibleElements.undoRedoMenu=e)}),r),l((()=>this.viewModel?.sketchViewModel),(e=>{this._sketchToolbar&&(this._sketchToolbar.viewModel=e)}),r)],te)}finally{this._sketchImportAbortController=null}}get test(){return{sketch:this._sketchToolbar,showPrompt:this._showPromptAndWait.bind(this)}}};e([c()],se.prototype,"_featureForm",void 0),e([c()],se.prototype,"_sketchToolbar",void 0),e([c()],se.prototype,"_attachments",void 0),e([c()],se.prototype,"_associationItemList",void 0),e([c()],se.prototype,"_associationSettings",void 0),e([c()],se.prototype,"_featureTemplates",void 0),e([c()],se.prototype,"_filterText",void 0),e([c()],se.prototype,"_prompt",void 0),e([c()],se.prototype,"_spinner",void 0),e([c()],se.prototype,"_deleteButtonCommonInfo",null),e([c()],se.prototype,"_loading",void 0),e([c({readOnly:!0})],se.prototype,"activeWorkflow",null),e([c()],se.prototype,"headingLevel",void 0),e([c()],se.prototype,"hideTemplatesForInactiveLayers",null),e([c()],se.prototype,"icon",null),e([c()],se.prototype,"label",null),e([c()],se.prototype,"labelOptions",null),e([c()],se.prototype,"layerInfos",null),e([c(),Q("esri/widgets/Editor/t9n/Editor")],se.prototype,"messages",void 0),e([c(),Q("esri/t9n/common")],se.prototype,"messagesCommon",void 0),e([c(),Q("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],se.prototype,"messagesTemplates",void 0),e([c(),Q("esri/widgets/Feature/t9n/Feature")],se.prototype,"messagesFeature",void 0),e([c()],se.prototype,"snappingOptions",null),e([c()],se.prototype,"tooltipOptions",null),e([c()],se.prototype,"supportingWidgetDefaults",void 0),e([c({type:m,nonNullable:!0})],se.prototype,"valueOptions",null),e([c()],se.prototype,"view",null),e([c(),X(["sketch-create","sketch-delete","sketch-update","workflow-cancel","workflow-commit"])],se.prototype,"viewModel",void 0),e([c({type:y,nonNullable:!0})],se.prototype,"visibleElements",void 0),e([c()],se.prototype,"_helpMessage",null),se=e([d("esri.widgets.Editor")],se);const oe=se;export{oe as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{destroyMaybe as t,mappedFind as s,abortMaybe as o}from"../core/maybe.js";import{createResolver as i}from"../core/promiseUtils.js";import{watch as a,initial as r,on as n,when as l}from"../core/reactiveUtils.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as d}from"../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as m}from"../core/support/UpdatingHandles.js";import h from"../views/interactive/sketch/SketchValueOptions.js";import p from"./Attachments.js";import u from"./FeatureForm.js";import g from"./FeatureTemplates.js";import w from"./Spinner.js";import _ from"./Widget.js";import{css as v}from"./Editor/css.js";import f from"./Editor/EditorViewModel.js";import{isModelUpload as y}from"./Editor/modelUploadUtils.js";import k from"./Editor/VisibleElements.js";import{loadCreateFeaturesPanelContentComponents as b,CreateFeaturesPanelContent as A}from"./Editor/components/CreateFeaturesPanelContent.js";import{loadFeatureListComponents as F,FeatureList as M}from"./Editor/components/FeatureList.js";import{loadFooterActionsComponents as T,FooterActions as C}from"./Editor/components/FooterActions.js";import{loadNoticesComponents as W,Notice as E}from"./Editor/components/Notices.js";import{loadPanelContentComponents as P,PanelContent as L,PanelContentSection as S,PanelContentMessage as I}from"./Editor/components/PanelContent.js";import{PanelToolbar as j,loadPanelToolbarComponents as U}from"./Editor/components/PanelToolbar.js";import{loadPromptComponents as D,Prompt as V}from"./Editor/components/Prompt.js";import{loadUpdateFeaturePanelContentComponents as O,UpdateFeaturePanelContent as x}from"./Editor/components/UpdateFeaturePanelContent.js";import{loadUploadDetailsComponents as B,UploadDetails as N}from"./Editor/components/UploadDetails.js";import{VisibleElements as z,CreateToolVisibilityMap as H}from"./Sketch/VisibleElements.js";import{loadCalciteComponents as R}from"./support/componentsUtils.js";import{globalCss as G}from"./support/globalCss.js";import{incrementHeadingLevel as q,Heading as Z}from"./support/Heading.js";import{renderItem as K}from"./support/ItemList.js";import{connectDelayedLoading as $}from"./support/loaderUtils.js";import"./support/widgetUtils.js";import{messageBundle as J}from"./support/decorators/messageBundle.js";import{vmEvent as Q}from"./support/decorators/vmEvent.js";import{tsx as X}from"./support/jsxFactory.js";import{substitute as Y}from"../intl/substitute.js";const ee=Symbol("sketch-setup-handles");let te=class extends _{constructor(e,t){super(e,t),this._featureForm=new u,this._sketchToolbar=null,this._attachments=new p({visibleElements:{addSubmitButton:!1,cancelAddButton:!1,cancelUpdateButton:!1,deleteButton:!1,errorMessage:!1,progressBar:!1,updateButton:!1}}),this._associationItemList=null,this._associationSettings=null,this._featureTemplates=new g({enableListScroll:!1,renderItemContentEnd:e=>e.supportsUpload?X("calcite-icon",{class:v.templateItemContentEnd,icon:"upload-to",key:"upload-icon"}):null,renderItemLabel:e=>e.label,renderCustomGroupContent:e=>this._renderCustomTemplateGroupContent(e)}),this._filterText="",this._prompt=null,this._spinner=new w,this._loading=!1,this._updatingHandles=new m,this.headingLevel=4,this.messages=null,this.messagesCommon=null,this.messagesTemplates=null,this.messagesFeature=null,this.supportingWidgetDefaults=null,this.viewModel=new f,this.visibleElements=new k,this._renderAttachments=()=>this._attachments.render(),this._renderFeatureForm=()=>this._featureForm.render(),this._renderFeatureTemplates=()=>this._featureTemplates.render(),this._renderSketch=()=>this._sketchToolbar?X("div",{class:v.sketchContainer,key:"editor-sketch-container"},this._sketchToolbar?.render()):void 0,this._renderSelectIcon=()=>X("calcite-icon",{icon:"cursor",slot:"content-start"}),this.EditorPanel=({heading:e,key:t,selected:s},...o)=>{const{visibleElements:i}=this;return X("calcite-flow-item",{closable:!1,heading:e,headingLevel:this.headingLevel,key:t,loading:this._loading,selected:s,onCalciteFlowItemBack:this._onBack},i.zoomToButton&&this.viewModel.canZoomTo?X("calcite-action",{alignment:"center",appearance:"transparent",icon:"zoom-to-object",key:"zoom-to-button",onclick:()=>this.viewModel.zoomTo(),slot:"header-actions-end",text:this.messages.zoomTo,title:this.messages.zoomTo}):null,i.settingsMenu?X(j,{editorViewModel:this.viewModel,messagesCommon:this.messagesCommon,visibleElements:i}):null,...o)},this._showDiscardEditsPrompt=()=>{const{messages:e,activeWorkflow:t}=this,s={title:e.cancelEditTitle,message:e.cancelEditWarningMessage,yesLabel:e.discardEdits,noLabel:e.continueEditing};return"create-features"===t?.type&&y(t.data.creationInfo)?this._showPromptAndWait("success"===t.data.upload?.state?e.modelUploads.cancelPlacementPrompt:e.modelUploads.cancelUploadPrompt):"update"===t?.type&&t.activeFeatureFormViewModel?.activeAssociation?this._showPromptAndWait({...s,message:e.cancelAssociationEditWarning}):this._showPromptAndWait(s)},this._showGenericCancelPrompt=()=>{const{messages:e,messagesCommon:t}=this;return this._showPromptAndWait({title:e.cancelRequestTitle,message:e.cancelRequestWarningMessage,yesLabel:t.form.yes,noLabel:t.form.no})},this._showPrompt=e=>{this._prompt?.cancel?.(),this._prompt=e},this._clearPrompt=()=>{this._prompt=null},this._onSave=()=>{this.viewModel.saveWorkflow()},this._onDelete=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({title:e.deleteWarningTitle,message:e.deleteWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.deleteFeatureFromWorkflow(),this._clearPrompt()}},secondary:{label:e.keepFeature,action:this._clearPrompt}}})},this._onDeleteAssociation=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({title:e.deleteAssociationTitle,message:e.deleteAssociationMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.deleteAssociationFromWorkflow(),this._clearPrompt()}},secondary:{label:e.keepAssociation,action:this._clearPrompt}}})},this._onToggleUpdateWorkflow=()=>this.viewModel.toggleUpdateWorkflow(),this._onBack=e=>(e?.stopPropagation(),this.viewModel.back()),this._onAttachmentAdd=()=>{const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type||"update"===e.type&&"create-features"===e.activeWorkflow?.type?(this._attachments.addFile(),e.back()):this._attachments.addAttachment().then((()=>e.back())))},this._onAttachmentUpdate=()=>{const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type?(this._attachments.updateFile(),e.back()):this._attachments.updateAttachment().then((()=>e.back())))},this._onAttachmentDelete=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({title:e.deleteAttachmentWarningTitle,message:e.deleteAttachmentWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:this._onAttachmentDeleteConfirm},secondary:{label:e.keepAttachment,action:this._clearPrompt}}})},this._onAttachmentDeleteConfirm=async()=>{const e=this._attachments,{activeWorkflow:t}=this.viewModel;t&&("create-features"===t.type?e.deleteFile():(await e.deleteAttachment(e.viewModel.activeAttachmentInfo),this._clearPrompt()),await t.back(),this._clearPrompt())},this._onAttachmentsError=e=>{this._showPrompt({title:this.messages.errorWarningTitle,message:e.message,context:"warning",actions:{primary:{label:this.messagesCommon.form.ok,action:this._clearPrompt}}})}}initialize(){this._featureForm.showPrompt=this._showPrompt,this._featureForm.clearPrompt=this._clearPrompt,this.addHandles([a((()=>q(this.headingLevel)),(e=>{this._featureForm.headingLevel=e,this._featureTemplates.headingLevel=e}),r),n((()=>this.viewModel.activeWorkflow),"cancel-request",(({controller:e})=>{(this.viewModel.hasPendingEdits?this._showDiscardEditsPrompt():this._showGenericCancelPrompt()).then((t=>t?e.allow():e.deny()))})),l((()=>this.viewModel.featureFormViewModel),(e=>{this._featureForm.viewModel=e}),r),l((()=>this.viewModel.utilityNetworkAssociationAddAssociationViewModel),(e=>{this._associationItemList?this._associationItemList.viewModel=e:this._updatingHandles.addPromise(this._initializeAssociationItemList(e))}),r),l((()=>this.viewModel.utilityNetworkAssociationAddAssociationViewModel?.association),(()=>{this._setUpAssociationSettings()})),a((()=>this.viewModel),(e=>{this._attachments.viewModel=e?.attachmentsViewModel??null,this._featureTemplates.viewModel=e?.featureTemplatesViewModel??null,this._spinner.viewModel=e?.spinnerViewModel??null,e.showDiscardEditsPrompt=this._showDiscardEditsPrompt}),r),a((()=>this.view),((e,t)=>{const s=`editor-${this.id}-spinner`;t?.ui.remove(this._spinner,s),e?.ui.add(this._spinner,{key:s,position:"manual"}),this._associationItemList&&(this._associationItemList.view=e)}),r),a((()=>[this.supportingWidgetDefaults,this.viewModel.sketchViewModel]),(([e])=>{e&&(this._featureForm.set(e.featureForm),this._attachments.set(e.attachments),this._featureTemplates.set(e.featureTemplates),this.viewModel.sketchViewModel?.set(e.sketch))}),r),l((()=>this._attachments?.error),(e=>this._onAttachmentsError(e))),l((()=>this.viewModel?.failures),(e=>{const{messages:t}=this,[{error:s,retry:o,cancel:i}]=e;this._showPrompt({title:t.errorWarningTitle,message:Y(t.errorWarningMessageTemplate,{errorMessage:s.message}),context:"warning",actions:{primary:{label:t.retry,action:()=>{o(),this._clearPrompt()}},secondary:{label:t.ignore,action:()=>{i(),this._clearPrompt()}}}})})),a((()=>this.viewModel?.state),(e=>{switch(e){case"awaiting-feature-to-update":case"ready":case"disabled":this._filterText="",this._featureTemplates.filterText=""}})),a((()=>this.viewModel.featureFormDisabled),(e=>this._featureForm.disabled=e)),a((()=>this.visibleElements.sketch),(()=>this._setupSketch()),r),$({getLoading:()=>{const{viewModel:e}=this;return e.syncing||e.updating||this._attachments.submitting||this._updatingHandles.updating},setEffectiveLoading:e=>{this._loading=e}})])}destroy(){this._associationItemList?.destroy(),this._associationSettings?.destroy(),this._attachments.destroy(),this._featureForm.destroy(),this._featureTemplates.destroy(),this._sketchToolbar=t(this._sketchToolbar)}loadDependencies(){return Promise.all([R({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),list:()=>import("@esri/calcite-components/dist/components/calcite-list")}),b(),F(),T(),W(),P(),U(),D(),O(),B()])}get _deleteButtonCommonInfo(){return{appearance:"outline",kind:"danger"}}get activeWorkflow(){return this.viewModel.activeWorkflow}get hideTemplatesForInactiveLayers(){return this.viewModel.hideTemplatesForInactiveLayers}set hideTemplatesForInactiveLayers(e){this.viewModel.hideTemplatesForInactiveLayers=e}get icon(){return"pencil"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get labelOptions(){return this.viewModel.labelOptions}set labelOptions(e){this.viewModel.labelOptions=e}get layerInfos(){return this.viewModel.layerInfos}set layerInfos(e){this.viewModel.layerInfos=e}get snappingOptions(){return this.viewModel.snappingOptions}set snappingOptions(e){this.viewModel.snappingOptions=e}get tooltipOptions(){return this.viewModel.tooltipOptions}set tooltipOptions(e){this.viewModel.tooltipOptions=e}get valueOptions(){return this.viewModel.valueOptions}set valueOptions(e){this.viewModel.valueOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.viewModel.startCreateFeaturesWorkflowAtFeatureTypeSelection()}startCreateFeaturesWorkflowAtFeatureCreation(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureCreation(e)}startCreateFeaturesWorkflowAtFeatureEdit(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureEdit(e)}startUpdateWorkflowAtFeatureSelection(){return this.viewModel.startUpdateWorkflowAtFeatureSelection()}startUpdateWorkflowAtMultipleFeatureSelection(e){return this.viewModel.startUpdateWorkflowAtMultipleFeatureSelection(e)}startUpdateWorkflowAtFeatureEdit(e){return this.viewModel.startUpdateWorkflowAtFeatureEdit(e)}deleteFeatureFromWorkflow(){return this.viewModel.deleteFeatureFromWorkflow()}deleteAssociationFromWorkflow(){return this.viewModel.deleteAssociationFromWorkflow()}cancelWorkflow(e){return this.viewModel.cancelWorkflow(e)}render(){const{visibleElements:e,viewModel:t}=this,s=this.classes(v.base,G.widget,G.panel);if(!t)return X("div",{class:s,key:"empty"});const{pageStack:o}=t,i=o.length-1,a=o.map(((e,t)=>this._renderPage(e,t===i)));return X("div",{class:s,key:"base"},e.flow?X("calcite-flow",{inert:!!this._prompt,key:"flow"},a):a,this._prompt?X(V,{...this._prompt,headingLevel:this.headingLevel}):void 0)}_renderPage(e,t){const s={selected:t};switch(e){case"disabled":break;case"ready":return this._renderReady(s);case"awaiting-feature-creation-info":return this._renderAwaitingFeatureCreationInfo(s);case"creating-features-upload-details":return this._renderUploadDetails(s);case"creating-features":return this._renderCreatingFeatures(s);case"editing-existing-feature":case"editing-attributes":return this._renderUpdateFeature(s);case"awaiting-update-feature-candidate":return this._renderFeatureList(s);case"adding-attachment":return this._renderAttachmentAdding(s);case"editing-attachment":return this._renderAttachmentEditing(s);case"viewing-associated-layers":case"viewing-associated-features":return this._renderViewAssociatedLayers(s);case"add-association-select-layer":case"add-association-select-feature":return this._renderSelectFeature(s);case"add-association-create-association":return this._renderAddAssociation(s)}return X("div",{key:"empty-page"})}_renderAwaitingFeatureCreationInfo(e){const{EditorPanel:t,messages:s}=this;return X(t,{heading:s.selectTemplate,key:"templates-panel",...e},X(L,{key:"feature-templates"},X(S,null,this._renderFeatureTemplates())))}_renderUploadDetails(e){const{EditorPanel:t,activeWorkflow:s,messages:o}=this;if("create-features"!==s?.type)return null;const i=s.data.upload;return i?X(t,{heading:o.createFeatures,key:"upload-details-panel",...e},X(N,{helpMessage:this._helpMessage,messages:o,upload:i})):null}_renderCreatingFeatures(e){const{EditorPanel:t,activeWorkflow:s,messages:o,messagesCommon:i,headingLevel:a,viewModel:r}=this;if(!s)return null;const n="create-features"===s.type&&s.numPendingFeatures>0||"update"===s.type&&"create-features"===s?.activeWorkflow?.type&&s.activeWorkflow?.numPendingFeatures>0;return X(t,{heading:o.createFeatures,key:"create-features-panel",...e},n?X(x,{editorViewModel:r,headingLevel:a,messages:o,messagesCommon:i,renderAttachments:this._renderAttachments,renderFeatureForm:this._renderFeatureForm,renderSketchToolbar:this._renderSketch,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave}):X(A,{helpMessage:this._helpMessage,renderSketchToolbar:this._renderSketch}))}_renderUpdateFeature(e){const{EditorPanel:t,messages:s,messagesCommon:o,headingLevel:i,viewModel:a}=this;return X(t,{heading:s.editFeature,key:"update-feature-panel",...e},X(x,{editorViewModel:a,headingLevel:i,messages:s,messagesCommon:o,renderAttachments:this._renderAttachments,renderFeatureForm:this._renderFeatureForm,renderSketchToolbar:this._renderSketch,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave}))}_getAssociationTypeTitle(e){const{messages:t}=this;if(!e)return t.editFeature;if(e.title)return e.title;const{messagesFeature:s}=this;switch(e.type){case"attachment":return s.associationsAttachments;case"connectivity":return s.associationsConnectivity;case"structure":return s.associationsStructure;case"content":return s.associationsContents;case"container":return s.associationsContainer}}_getAddAssociationTypeTitle(e){const{messages:t}=this;if(!e)return t.editFeature;const s=t.associations;switch(e.type){case"attachment":return s.addAttachment;case"connectivity":return s.addConnectivity;case"structure":return s.addStructure;case"content":return s.addContent;case"container":return s.addContainer}}async _initializeAssociationItemList(e){const t=(await import("./FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationItemList.js")).default;this._associationItemList=new t({view:this.view,viewModel:e})}async _initializeAssociationSettings(){const e=new(0,(await import("./FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationSettings.js")).default);return this._associationSettings=e,e}_renderViewAssociatedLayers(e){const{EditorPanel:t,messages:s,messagesCommon:o,headingLevel:i,viewModel:a}=this,r=a.featureFormViewModel?.activeAssociationInput?.activeAssociationType,n=this._getAssociationTypeTitle(r);return X(t,{heading:n,key:"viewing-associated-layers-panel",...e},X(x,{editorViewModel:a,headingLevel:i,messages:s,messagesCommon:o,renderAttachments:this._renderAttachments,renderFeatureForm:this._renderFeatureForm,renderSketchToolbar:this._renderSketch,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave}))}_renderSelectFeature(e){const{_associationItemList:t,EditorPanel:s,viewModel:o,messagesCommon:i}=this,a=o.utilityNetworkAssociationAddAssociationViewModel,r=this._getAddAssociationTypeTitle(a?.associationType),n="ready"!==a?.state;return t?X(s,{heading:r,key:"add-association-select-feature",...e},X(L,{key:"select-feature"},X(S,null,t.render())),X(C,{buttons:[t.filterOptionsVisible?{appearance:"solid",label:i.apply,disabled:n,onClick:()=>t.applyFilterOptions(),type:"button"}:void 0,{appearance:"outline",label:i.cancel,disabled:n,onClick:()=>{"update"===o.activeWorkflow?.type&&(t.viewModel.featureSpatialItems.length&&t.highlightHelper?.removeAll(),o.activeWorkflow.cancelActiveWorkflow())},type:"button"}]})):X(s,{heading:r,key:"add-association-select-feature",...e})}async _setUpAssociationSettings(){const{viewModel:e}=this,t=this._associationSettings??await this._updatingHandles.addPromise(this._initializeAssociationSettings()),s=e.utilityNetworkAssociationAddAssociationViewModel,o="update"===e.activeWorkflow?.type?e.activeWorkflow:null,i=o?o.activeWorkflow:null,a="add-association"===i?.type?i.sourceFeatureItem:null,r=s?.selectedFeature,n=s?.association,l=s?.utilityNetwork;a&&r&&n&&l&&(t.sourceFeature=a,t.targetFeature=r,t.association=n,t.utilityNetwork=l)}_renderAddAssociation(e){const{_associationSettings:t,EditorPanel:s,viewModel:o,messagesCommon:i}=this;if(!t)return null;const a=o.utilityNetworkAssociationAddAssociationViewModel,r=this._getAddAssociationTypeTitle(a?.associationType),n="ready"!==a?.state;return X(s,{heading:r,key:"add-association",...e},X(L,{key:"add-association-content"},X(S,null,t.render())),X(C,{buttons:[{label:i.add,disabled:n||!a.canAddAssociation,onClick:()=>this._onSave(),type:"button"},{appearance:"outline",label:i.cancel,disabled:n,onClick:()=>{"update"===o.activeWorkflow?.type&&o.activeWorkflow.cancelActiveWorkflow()},type:"button"}]}))}_renderCustomTemplateGroupContent(e){const{messages:t,viewModel:o}=this,i=s(e.group.items,(e=>o.itemHasInvalidFormTemplate(e)?t.formFieldCreateError:void 0));return i?X(E,{kind:"warning",message:i}):null}_renderAttachmentAdding(e){const{EditorPanel:t,_attachments:s,messages:o,messagesCommon:i}=this;return X(t,{heading:o.addAttachment,key:"attachment-adding-panel",...e},X(L,{key:"attachments"},this._renderAttachments()),X(C,{buttons:[{label:s.submitting?i.cancel:i.add,disabled:s.submitting||!s.selectedFile,onClick:this._onAttachmentAdd,type:"button"}]}))}_renderAttachmentEditing(e){const{EditorPanel:t,_attachments:s,activeWorkflow:o,messages:i,messagesCommon:a}=this;return o?X(t,{heading:i.editAttachment,key:"attachment-editing-panel",...e},X(L,{key:"attachments"},this._renderAttachments()),o.shouldAllowAttachmentEditing?X(C,{buttons:[{label:a.update,disabled:s.submitting||!s.selectedFile,onClick:this._onAttachmentUpdate,type:"button"},{...this._deleteButtonCommonInfo,onClick:this._onAttachmentDelete,disabled:s.submitting,label:a.delete,type:"button"}]}):void 0):null}_renderReady(e){const{EditorPanel:t,messages:s,viewModel:o,visibleElements:i}=this,a=this._helpMessage;return X(t,{heading:s.widgetLabel,key:"landing-panel",...e},X(L,{key:"landing-content"},o.editorItems.length?[i.editFeaturesSection?X(S,{key:"edit-actions"},this._renderUpdateActions()):null,i.createFeaturesSection&&o.canCreateVisible?X(S,{key:"create-actions"},this._renderCreateActions()):null]:X(I,{key:"no-content"},s.noEditableLayers)),a?X("div",{class:v.helpMessage,key:"footer-actions",slot:"footer"},a):void 0)}get _helpMessage(){const{activeWorkflow:e,messages:t,view:s}=this,o=e?.helpMessage;return o?t["3d"===s?.type?"helpMessages3d":"helpMessages2d"]?.[o]:void 0}_renderUpdateActions(){const{messages:e,messagesCommon:t,viewModel:s}=this,o={id:"select",label:t.select};return X("div",{class:v.updateActions,key:"update-actions"},X(Z,{level:q(this.headingLevel)},e.editFeatures),X("calcite-list",{class:v.updateActionsList,label:e.editFeaturesList,selectionAppearance:"border",selectionMode:"single"},K({disabled:!s.canUpdateVisible,grouped:!1,item:o,selectedItem:"awaiting-feature-to-update"===s.activeWorkflow?.stepId?o:void 0,renderIcon:this._renderSelectIcon,onItemSelect:this._onToggleUpdateWorkflow})))}_renderCreateActions(){return X("div",{key:"create-actions"},X(Z,{level:q(this.headingLevel)},this.messages.createFeatures),X("div",{class:v.featureTemplatesContainer,key:"templates"},this._renderFeatureTemplates()))}_renderFeatureList(e){const{EditorPanel:t,viewModel:s}=this,{activeWorkflow:o}=s;if("update"!==o?.type)return null;const i=o.data.candidates,a=Y(this.messages.multipleFeaturesTemplate,{total:i.length});return X(t,{heading:a,key:"feature-list",...e},X(M,{editorItems:s.editorItems,editorMessages:this.messages,filterText:this._filterText,id:this.id,messagesTemplates:this.messagesTemplates,workflow:o,onFilterTextChange:e=>this._filterText=e,onSelectFeature:(e,t)=>s.selectFeature(e,t),onZoomTo:e=>s.zoomTo(e)}))}_showPromptAndWait({title:e,message:t,yesLabel:s,noLabel:o}){const a=i(),{view:r}=this,n=r?.focused;return this._showPrompt({title:e,message:t,context:"danger",actions:{primary:{label:s,action:()=>a.resolve(!0)},secondary:{label:o,action:()=>a.resolve(!1)}}}),a.promise.finally((()=>{this._clearPrompt(),n&&r?.focus()}))}async _setupSketch(){if(!!!this.visibleElements.sketch)return this._sketchImportAbortController=o(this._sketchImportAbortController),this._sketchToolbar=t(this._sketchToolbar),void this.removeHandles(ee);if(this._sketchImportAbortController)return;const e=new AbortController;this._sketchImportAbortController=e;const s=await import("./Sketch.js");if(!e.signal.aborted)try{this._sketchToolbar=new s.default({toolbarKind:"docked",contextualToolLocation:"inline-end",scale:"s",visibleElements:new z({deleteButton:!1,settingsMenu:!1,directionModePicker:!1,selectionCountLabel:!1,duplicateButton:!1,createTools:new H({freehandPolygon:!0,freehandPolyline:!0})})}),this.addHandles([a((()=>this.viewModel.activeLeafWorkflow?.availableCreateTools),(e=>{this._sketchToolbar&&(this._sketchToolbar.availableCreateTools=e)}),r),a((()=>this.visibleElements.undoRedoButtons),(e=>{this._sketchToolbar&&(this._sketchToolbar.visibleElements.undoRedoMenu=e)}),r),l((()=>this.viewModel?.sketchViewModel),(e=>{this._sketchToolbar&&(this._sketchToolbar.viewModel=e)}),r)],ee)}finally{this._sketchImportAbortController=null}}get test(){return{sketch:this._sketchToolbar,showPrompt:this._showPromptAndWait.bind(this)}}};e([c()],te.prototype,"_featureForm",void 0),e([c()],te.prototype,"_sketchToolbar",void 0),e([c()],te.prototype,"_attachments",void 0),e([c()],te.prototype,"_associationItemList",void 0),e([c()],te.prototype,"_associationSettings",void 0),e([c()],te.prototype,"_featureTemplates",void 0),e([c()],te.prototype,"_filterText",void 0),e([c()],te.prototype,"_prompt",void 0),e([c()],te.prototype,"_spinner",void 0),e([c()],te.prototype,"_deleteButtonCommonInfo",null),e([c()],te.prototype,"_loading",void 0),e([c({readOnly:!0})],te.prototype,"activeWorkflow",null),e([c()],te.prototype,"headingLevel",void 0),e([c()],te.prototype,"hideTemplatesForInactiveLayers",null),e([c()],te.prototype,"icon",null),e([c()],te.prototype,"label",null),e([c()],te.prototype,"labelOptions",null),e([c()],te.prototype,"layerInfos",null),e([c(),J("esri/widgets/Editor/t9n/Editor")],te.prototype,"messages",void 0),e([c(),J("esri/t9n/common")],te.prototype,"messagesCommon",void 0),e([c(),J("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],te.prototype,"messagesTemplates",void 0),e([c(),J("esri/widgets/Feature/t9n/Feature")],te.prototype,"messagesFeature",void 0),e([c()],te.prototype,"snappingOptions",null),e([c()],te.prototype,"tooltipOptions",null),e([c()],te.prototype,"supportingWidgetDefaults",void 0),e([c({type:h,nonNullable:!0})],te.prototype,"valueOptions",null),e([c()],te.prototype,"view",null),e([c(),Q(["sketch-create","sketch-delete","sketch-update","workflow-cancel","workflow-commit"])],te.prototype,"viewModel",void 0),e([c({type:k,nonNullable:!0})],te.prototype,"visibleElements",void 0),e([c()],te.prototype,"_helpMessage",null),te=e([d("esri.widgets.Editor")],te);const se=te;export{se 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.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../intl.js";import{watch as t,on as r}from"../../../core/reactiveUtils.js";import{stripHTML as i}from"../../../core/string.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import l from"../../Widget.js";import a from"../UtilityNetworkAssociationAddAssociationViewModel.js";import{loadCalciteComponents as n}from"../../support/componentsUtils.js";import d from"../../support/FilterBuilder.js";import{globalCss as c}from"../../support/globalCss.js";import{Heading as p}from"../../support/Heading.js";import u from"../../support/SelectionToolbar.js";import"../../support/widgetUtils.js";import{messageBundle as h}from"../../support/decorators/messageBundle.js";import{tsx as m}from"../../support/jsxFactory.js";import{fetchMessageBundle as _}from"../../../intl/messages.js";import{substitute as f}from"../../../intl/substitute.js";const g="esri-feature-form-utility-network-association-layers",v={base:g,header:`${g}__header`,headingContent:`${g}__heading-content`,featureObserver:`${g}__feature-observer`,filterContainer:`${g}__filter-container`,filterOptionsContainer:`${g}__filter-options-container`,filterOptionsHeader:`${g}__filter-options-header`,listContainer:`${g}__list-container`,spatialSelectContainer:`${g}__spatial-select-container`,spatialSelectToolbar:`${g}__spatial-select-toolbar`,stickySpinnerContainer:`${g}__sticky-loading-container`,loadingContainer:`${g}__loading-container`};let y=class extends l{constructor(e,t){super(e,t),this.headingLevel=5,this.messagesCommon=null,this.messagesEditor=null,this.messagesFeature=null,this.messagesFeatureForm=null,this.messagesFilterBuilder=null,this.viewModel=new a,this.view=null,this._filterBuilder=new d,this._featureFilterText="",this._layerFilterText="",this._observer=new IntersectionObserver((([e])=>{e?.isIntersecting&&this._increaseFeaturePage()}),{root:window.document}),this._observerNode=null,this._selectionToolbar=new u({layerViewPreferenceEnabled:!1}),this._handleSelectionComplete=async e=>{const{highlightHelper:t,viewModel:r}=this;await r.handleSelectionComplete(e),t?.removeAll(),this._featureSpatialGraphics.length>0&&t?.add(this._featureSpatialGraphics)}}initialize(){this._setupSelectionToolbar(),this.addHandles([t((()=>this.viewModel),(()=>this.reset())),t((()=>[this.viewModel.state,this._observerNode]),(()=>this._onObserverChange())),t((()=>this.selectedLayer),(e=>{this._filterBuilder.layer=e,e||(this.filterOptionsVisible=!1,this._featureFilterText="")}))])}loadDependencies(){return n({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),input:()=>import("@esri/calcite-components/dist/components/calcite-input"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader")})}destroy(){this._filterBuilder.destroy(),this._selectionToolbar.destroy()}get filterOptionsVisible(){return this.viewModel.filterOptionsVisible}set filterOptionsVisible(e){this.viewModel.filterOptionsVisible=e}get selectedLayer(){return this.viewModel.selectedLayer}set selectedLayer(e){this.viewModel.selectedLayer=e}get selectedFeature(){return this.viewModel.selectedFeature}set selectedFeature(e){this.viewModel.selectedFeature=e}get filterWhereClause(){return this.viewModel.filterWhereClause}set filterWhereClause(e){this.viewModel.filterWhereClause=e,e||this._filterBuilder.reset()}get highlightHelper(){return this.viewModel.highlightHelper}get _featureSpatialGraphics(){return this.viewModel.featureSpatialItems.toArray().map((e=>e.feature))}get _filteredFeatureItems(){const{_featureFilterText:e}=this,{featureItems:t,featureSpatialItems:r}=this.viewModel;return(r.length?r:t).map((e=>({label:e.label,graphic:e.feature,layer:e.feature.sourceLayer}))).filter((t=>t.label?.toLowerCase().includes(e)??!1))}get _filteredFeatureItemsPage(){const{featurePage:e,featuresPerPage:t}=this.viewModel,r=e*t;return this._filteredFeatureItems.toArray().slice(0,r)}render(){return m("div",{class:this.classes(v.base,c.widget)},this._renderContent())}applyFilterOptions(){const{selectedLayer:e}=this;this.filterOptionsVisible=!1,e&&(this.filterWhereClause=this._filterBuilder.whereClause)}reset(){this.filterWhereClause=null,this._featureFilterText="",this._layerFilterText="",this.filterOptionsVisible=!1,this._filterBuilder.reset()}_setupSelectionToolbar(){const{_selectionToolbar:e}=this;e.defaultRectangleToolOptions={...e.defaultRectangleToolOptions,persistSelection:!1},e.defaultLassoToolOptions={...e.defaultLassoToolOptions,persistSelection:!1};const i={createTool:"point",mode:"click",toolName:"",icon:"cursor",toolKey:"point",persistSelection:!1};_("esri/widgets/Editor/t9n/Editor").then((t=>{e.toolConfigs=[{...i,toolName:t.selectFeature}]})),this.addHandles([t((()=>this.view),(e=>{e?this._selectionToolbar.view="2d"===e.type?e:null:this.viewModel.reset()})),t((()=>[this.viewModel,this.viewModel.layerItems.length]),(()=>this._selectionToolbar.sources=this.viewModel.layerItems.toArray())),r((()=>this._selectionToolbar),"complete",this._handleSelectionComplete)])}async _onObserverChange(){this._observerNode&&this._observer.unobserve(this._observerNode);const{state:e}=this.viewModel;this._observerNode&&"ready"===e&&this._observer.observe(this._observerNode)}_increaseFeaturePage(){const{featureCount:e,featurePage:t,featureSpatialItems:r,state:i}=this.viewModel;e||r.length||1===t?"ready"===i&&this.viewModel.featurePage++:this.viewModel.featurePage=1}_renderContent(){const{state:e,filterOptionsVisible:t}=this.viewModel;return"loading"===e?this._renderLoading():t?this._renderFilterOptions():[this._renderSelectionToolbar(),this._renderListContent()]}_renderListContent(){return this.selectedLayer||this.viewModel.featureSpatialItems.length?this._renderFeatures():this._renderLayers()}_renderSelectionToolbar(){const{messagesCommon:e,_selectionToolbar:t}=this,{featureSpatialItems:r,selectedLayer:i}=this.viewModel;if(i||!t.sources?.length)return null;const s=m("div",{class:v.spatialSelectToolbar},t.render()),o=m("calcite-button",{appearance:"transparent",disabled:!r.length,label:e.clear,onclick:()=>this.viewModel.reset()},e.clear);return m("div",{class:v.spatialSelectContainer,key:"spatial-select-toolbar"},s,o)}_renderStickyLoading(){return"querying"===this.viewModel.state?m("div",{class:v.stickySpinnerContainer,key:"sticky-loader"},this._renderLoadingIcon()):null}_renderLoading(){return m("div",{class:v.loadingContainer,key:"loading-container"},this._renderLoadingIcon())}_renderLoadingIcon(){return m("calcite-loader",{inline:!0,label:this.messagesCommon.loading})}_renderFilterOptions(){return m("div",{class:v.filterOptionsContainer},m("div",{class:v.filterOptionsHeader},m("span",null,this.messagesFilterBuilder.widgetLabel),m("calcite-button",{appearance:"transparent",onclick:()=>this._filterBuilder.reset()},this.messagesCommon.clear)),this._filterBuilder.render())}_renderLayers(){const e=this.messagesFeatureForm.associations,t=e.availableLayers,r=e.filterLayers;return m("div",null,this._renderHeader({heading:t,placeholder:r,renderFilterOptions:!1,renderTotal:!1}),m("div",{class:v.listContainer},m("calcite-list",{label:e.associatedFeatures},this._renderLayerItems(),this._renderStickyLoading())))}_renderLayerItems(){const{_layerFilterText:e,viewModel:t,messagesCommon:r}=this,{layerItems:i,tableItems:s}=t;return i.concat(s).map((e=>({label:e.title??r.untitled,layer:e}))).filter((t=>t.label?.toLowerCase().includes(e)??!1)).toArray().map((e=>this._renderLayerItem(e)))}_renderLayerItem(e){const{label:t,layer:r}=e;return m("calcite-list-item",{key:`layer-item-${r.id}`,label:i(t),onCalciteListItemSelect:()=>{this.selectedLayer=r,this._filterBuilder.reset()}},m("calcite-icon",{flipRtl:!0,icon:"chevron-right",scale:"s",slot:"content-end"}))}_renderFeatures(){const{selectedLayer:e,viewModel:t}=this,r=t.featureSpatialItems.length>0,i=this.messagesFeatureForm.associations,s=e?.title??this.messagesCommon.untitled,o=i.filterFeatures;return m("div",null,this._renderHeader({heading:s,placeholder:o,renderFilterOptions:!r,renderTotal:!0}),m("div",{class:v.listContainer},m("calcite-list",{label:i.associatedFeatures},this._renderFeatureItems(),this._renderStickyLoading(),this._renderFeatureObserver())))}_renderFeatureItems(){return this._filteredFeatureItemsPage.map((e=>this._renderFeatureItem(e)))}_renderFeatureItem(e){const{label:t,graphic:r}=e;return m("calcite-list-item",{key:`feature-item-${r.uid}`,label:i(t),onCalciteListItemSelect:()=>{this.selectedFeature={feature:r,label:t}}},m("calcite-icon",{flipRtl:!0,icon:"chevron-right",scale:"s",slot:"content-end"}))}_onObserverCreate(e){this._observerNode=e}_renderFeatureObserver(){return m("div",{afterCreate:this._onObserverCreate,bind:this,class:v.featureObserver,key:"feature-observer"})}_renderHeader(e){return m("div",{class:v.header,key:"filter"},this._renderHeading(e.heading),this._renderFilter(e.placeholder,e.renderFilterOptions),e.renderTotal?this._renderTotal():null)}_renderHeading(e){return e?m(p,{key:"title",level:this.headingLevel},m("div",{class:v.headingContent},m("calcite-icon",{icon:"layer"}),e)):null}_renderFilter(e,t){const r=!this.selectedLayer&&!this.viewModel.featureSpatialItems.length,i=r?this._layerFilterText:this._featureFilterText;return m("div",{class:v.filterContainer,key:"filter"},m("calcite-input",{icon:"search",placeholder:e,type:"search",value:i,onCalciteInputInput:e=>{r?this._layerFilterText=e.currentTarget.value.trim().toLowerCase():this._featureFilterText=e.currentTarget.value.trim().toLowerCase()}},t?this._renderFilterOptionsAction():null))}_renderFilterOptionsAction(){const e=this.messagesFeatureForm.associations.filterOptions;return m("calcite-action",{appearance:"transparent",icon:"sliders",indicator:!!this._filterBuilder.whereClause,onclick:()=>{this.viewModel.filterOptionsVisible=!this.viewModel.filterOptionsVisible},scale:"s",slot:"action",text:e,title:e})}_renderTotal(){const{messagesFeature:e,viewModel:t}=this,{featureCount:r,featureSpatialItems:i}=t,s=f(e.numberRecords,{number:i.length?i.length:r});return m("div",{key:"total"},s)}};e([s()],y.prototype,"filterOptionsVisible",null),e([s()],y.prototype,"headingLevel",void 0),e([s(),h("esri/t9n/common")],y.prototype,"messagesCommon",void 0),e([s(),h("esri/widgets/Editor/t9n/Editor")],y.prototype,"messagesEditor",void 0),e([s(),h("esri/widgets/Feature/t9n/Feature")],y.prototype,"messagesFeature",void 0),e([s(),h("esri/widgets/FeatureForm/t9n/FeatureForm")],y.prototype,"messagesFeatureForm",void 0),e([s(),h("esri/widgets/support/FilterBuilder/t9n/FilterBuilder")],y.prototype,"messagesFilterBuilder",void 0),e([s()],y.prototype,"selectedLayer",null),e([s({type:a})],y.prototype,"viewModel",void 0),e([s()],y.prototype,"selectedFeature",null),e([s()],y.prototype,"filterWhereClause",null),e([s()],y.prototype,"highlightHelper",null),e([s()],y.prototype,"view",void 0),e([s()],y.prototype,"_filterBuilder",void 0),e([s()],y.prototype,"_featureFilterText",void 0),e([s()],y.prototype,"_layerFilterText",void 0),e([s()],y.prototype,"_observer",void 0),e([s()],y.prototype,"_featureSpatialGraphics",null),e([s()],y.prototype,"_filteredFeatureItems",null),e([s()],y.prototype,"_filteredFeatureItemsPage",null),e([s()],y.prototype,"_observerNode",void 0),y=e([o("esri.widgets.FeatureForm.FeatureFormUtilityNetworkAssociations.UtilityNetworkAssociationItemList")],y);const b=y;export{b as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../intl.js";import{watch as t,initial as r,on as i}from"../../../core/reactiveUtils.js";import{stripHTML as s}from"../../../core/string.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import a from"../../Widget.js";import n from"../UtilityNetworkAssociationAddAssociationViewModel.js";import{loadCalciteComponents as d}from"../../support/componentsUtils.js";import c from"../../support/FilterBuilder.js";import{globalCss as p}from"../../support/globalCss.js";import{Heading as u}from"../../support/Heading.js";import h from"../../support/SelectionToolbar.js";import"../../support/widgetUtils.js";import{messageBundle as m}from"../../support/decorators/messageBundle.js";import{tsx as _}from"../../support/jsxFactory.js";import{fetchMessageBundle as f}from"../../../intl/messages.js";import{substitute as g}from"../../../intl/substitute.js";const v="esri-feature-form-utility-network-association-layers",y={base:v,header:`${v}__header`,headingContent:`${v}__heading-content`,featureObserver:`${v}__feature-observer`,filterContainer:`${v}__filter-container`,filterOptionsContainer:`${v}__filter-options-container`,filterOptionsHeader:`${v}__filter-options-header`,listContainer:`${v}__list-container`,spatialSelectContainer:`${v}__spatial-select-container`,spatialSelectToolbar:`${v}__spatial-select-toolbar`,stickySpinnerContainer:`${v}__sticky-loading-container`,loadingContainer:`${v}__loading-container`};let b=class extends a{constructor(e,t){super(e,t),this.headingLevel=5,this.messagesCommon=null,this.messagesEditor=null,this.messagesFeature=null,this.messagesFeatureForm=null,this.messagesFilterBuilder=null,this.viewModel=new n,this.view=null,this._filterBuilder=new c,this._featureFilterText="",this._layerFilterText="",this._observer=new IntersectionObserver((([e])=>{e?.isIntersecting&&this._increaseFeaturePage()}),{root:window.document}),this._observerNode=null,this._selectionToolbar=new h({layerViewPreferenceEnabled:!1}),this._handleSelectionComplete=async e=>{const{highlightHelper:t,viewModel:r}=this;await r.handleSelectionComplete(e),t?.removeAll(),this._featureSpatialGraphics.length>0&&t?.add(this._featureSpatialGraphics)}}initialize(){this._setupSelectionToolbar(),this.addHandles([t((()=>this.viewModel),(()=>this.reset())),t((()=>[this.viewModel.state,this._observerNode]),(()=>this._onObserverChange())),t((()=>this.selectedLayer),(e=>{this._filterBuilder.layer=e,e||(this.filterOptionsVisible=!1,this._featureFilterText="")}))])}loadDependencies(){return d({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),input:()=>import("@esri/calcite-components/dist/components/calcite-input"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader")})}destroy(){this._filterBuilder.destroy(),this._selectionToolbar.destroy()}get filterOptionsVisible(){return this.viewModel.filterOptionsVisible}set filterOptionsVisible(e){this.viewModel.filterOptionsVisible=e}get selectedLayer(){return this.viewModel.selectedLayer}set selectedLayer(e){this.viewModel.selectedLayer=e}get selectedFeature(){return this.viewModel.selectedFeature}set selectedFeature(e){this.viewModel.selectedFeature=e}get filterWhereClause(){return this.viewModel.filterWhereClause}set filterWhereClause(e){this.viewModel.filterWhereClause=e,e||this._filterBuilder.reset()}get highlightHelper(){return this.viewModel.highlightHelper}get _featureSpatialGraphics(){return this.viewModel.featureSpatialItems.toArray().map((e=>e.feature))}get _filteredFeatureItems(){const{_featureFilterText:e}=this,{featureItems:t,featureSpatialItems:r}=this.viewModel;return(r.length?r:t).map((e=>({label:e.label,graphic:e.feature,layer:e.feature.sourceLayer}))).filter((t=>t.label?.toLowerCase().includes(e)??!1))}get _filteredFeatureItemsPage(){const{featurePage:e,featuresPerPage:t}=this.viewModel,r=e*t;return this._filteredFeatureItems.toArray().slice(0,r)}render(){return _("div",{class:this.classes(y.base,p.widget)},this._renderContent())}applyFilterOptions(){const{selectedLayer:e}=this;this.filterOptionsVisible=!1,e&&(this.filterWhereClause=this._filterBuilder.whereClause)}reset(){this.filterWhereClause=null,this._featureFilterText="",this._layerFilterText="",this.filterOptionsVisible=!1,this._filterBuilder.reset()}_setupSelectionToolbar(){const{_selectionToolbar:e}=this;e.defaultRectangleToolOptions={...e.defaultRectangleToolOptions,persistSelection:!1},e.defaultLassoToolOptions={...e.defaultLassoToolOptions,persistSelection:!1};const s={createTool:"point",mode:"click",toolName:"",icon:"cursor",toolKey:"point",persistSelection:!1};f("esri/widgets/Editor/t9n/Editor").then((t=>{e.toolConfigs=[{...s,toolName:t.selectFeature}]})),this.addHandles([t((()=>this.view),(e=>{e?this._selectionToolbar.view="2d"===e.type?e:null:this.viewModel.reset()}),r),t((()=>[this.viewModel,this.viewModel.layerItems.length]),(()=>this._selectionToolbar.sources=this.viewModel.layerItems.toArray())),i((()=>this._selectionToolbar),"complete",this._handleSelectionComplete)])}async _onObserverChange(){this._observerNode&&this._observer.unobserve(this._observerNode);const{state:e}=this.viewModel;this._observerNode&&"ready"===e&&this._observer.observe(this._observerNode)}_increaseFeaturePage(){const{featureCount:e,featurePage:t,featureSpatialItems:r,state:i}=this.viewModel;e||r.length||1===t?"ready"===i&&this.viewModel.featurePage++:this.viewModel.featurePage=1}_renderContent(){const{state:e,filterOptionsVisible:t}=this.viewModel;return"loading"===e?this._renderLoading():t?this._renderFilterOptions():[this._renderSelectionToolbar(),this._renderListContent()]}_renderListContent(){return this.selectedLayer||this.viewModel.featureSpatialItems.length?this._renderFeatures():this._renderLayers()}_renderSelectionToolbar(){const{messagesCommon:e,_selectionToolbar:t}=this,{featureSpatialItems:r,selectedLayer:i}=this.viewModel;if(i||!t.sources?.length)return null;const s=_("div",{class:y.spatialSelectToolbar},t.render()),o=_("calcite-button",{appearance:"transparent",disabled:!r.length,label:e.clear,onclick:()=>this.viewModel.reset()},e.clear);return _("div",{class:y.spatialSelectContainer,key:"spatial-select-toolbar"},s,o)}_renderStickyLoading(){return"querying"===this.viewModel.state?_("div",{class:y.stickySpinnerContainer,key:"sticky-loader"},this._renderLoadingIcon()):null}_renderLoading(){return _("div",{class:y.loadingContainer,key:"loading-container"},this._renderLoadingIcon())}_renderLoadingIcon(){return _("calcite-loader",{inline:!0,label:this.messagesCommon.loading})}_renderFilterOptions(){return _("div",{class:y.filterOptionsContainer},_("div",{class:y.filterOptionsHeader},_("span",null,this.messagesFilterBuilder.widgetLabel),_("calcite-button",{appearance:"transparent",onclick:()=>this._filterBuilder.reset()},this.messagesCommon.clear)),this._filterBuilder.render())}_renderLayers(){const e=this.messagesFeatureForm.associations,t=e.availableLayers,r=e.filterLayers;return _("div",null,this._renderHeader({heading:t,placeholder:r,renderFilterOptions:!1,renderTotal:!1}),_("div",{class:y.listContainer},_("calcite-list",{label:e.associatedFeatures},this._renderLayerItems(),this._renderStickyLoading())))}_renderLayerItems(){const{_layerFilterText:e,viewModel:t,messagesCommon:r}=this,{layerItems:i,tableItems:s}=t;return i.concat(s).map((e=>({label:e.title??r.untitled,layer:e}))).filter((t=>t.label?.toLowerCase().includes(e)??!1)).toArray().map((e=>this._renderLayerItem(e)))}_renderLayerItem(e){const{label:t,layer:r}=e;return _("calcite-list-item",{key:`layer-item-${r.id}`,label:s(t),onCalciteListItemSelect:()=>{this.selectedLayer=r,this._filterBuilder.reset()}},_("calcite-icon",{flipRtl:!0,icon:"chevron-right",scale:"s",slot:"content-end"}))}_renderFeatures(){const{selectedLayer:e,viewModel:t}=this,r=t.featureSpatialItems.length>0,i=this.messagesFeatureForm.associations,s=e?.title??this.messagesCommon.untitled,o=i.filterFeatures;return _("div",null,this._renderHeader({heading:s,placeholder:o,renderFilterOptions:!r,renderTotal:!0}),_("div",{class:y.listContainer},_("calcite-list",{label:i.associatedFeatures},this._renderFeatureItems(),this._renderStickyLoading(),this._renderFeatureObserver())))}_renderFeatureItems(){return this._filteredFeatureItemsPage.map((e=>this._renderFeatureItem(e)))}_renderFeatureItem(e){const{label:t,graphic:r}=e;return _("calcite-list-item",{key:`feature-item-${r.uid}`,label:s(t),onCalciteListItemSelect:()=>{this.selectedFeature={feature:r,label:t}}},_("calcite-icon",{flipRtl:!0,icon:"chevron-right",scale:"s",slot:"content-end"}))}_onObserverCreate(e){this._observerNode=e}_renderFeatureObserver(){return _("div",{afterCreate:this._onObserverCreate,bind:this,class:y.featureObserver,key:"feature-observer"})}_renderHeader(e){return _("div",{class:y.header,key:"filter"},this._renderHeading(e.heading),this._renderFilter(e.placeholder,e.renderFilterOptions),e.renderTotal?this._renderTotal():null)}_renderHeading(e){return e?_(u,{key:"title",level:this.headingLevel},_("div",{class:y.headingContent},_("calcite-icon",{icon:"layer"}),e)):null}_renderFilter(e,t){const r=!this.selectedLayer&&!this.viewModel.featureSpatialItems.length,i=r?this._layerFilterText:this._featureFilterText;return _("div",{class:y.filterContainer,key:"filter"},_("calcite-input",{icon:"search",placeholder:e,type:"search",value:i,onCalciteInputInput:e=>{r?this._layerFilterText=e.currentTarget.value.trim().toLowerCase():this._featureFilterText=e.currentTarget.value.trim().toLowerCase()}},t?this._renderFilterOptionsAction():null))}_renderFilterOptionsAction(){const e=this.messagesFeatureForm.associations.filterOptions;return _("calcite-action",{appearance:"transparent",icon:"sliders",indicator:!!this._filterBuilder.whereClause,onclick:()=>{this.viewModel.filterOptionsVisible=!this.viewModel.filterOptionsVisible},scale:"s",slot:"action",text:e,title:e})}_renderTotal(){const{messagesFeature:e,viewModel:t}=this,{featureCount:r,featureSpatialItems:i}=t,s=g(e.numberRecords,{number:i.length?i.length:r});return _("div",{key:"total"},s)}};e([o()],b.prototype,"filterOptionsVisible",null),e([o()],b.prototype,"headingLevel",void 0),e([o(),m("esri/t9n/common")],b.prototype,"messagesCommon",void 0),e([o(),m("esri/widgets/Editor/t9n/Editor")],b.prototype,"messagesEditor",void 0),e([o(),m("esri/widgets/Feature/t9n/Feature")],b.prototype,"messagesFeature",void 0),e([o(),m("esri/widgets/FeatureForm/t9n/FeatureForm")],b.prototype,"messagesFeatureForm",void 0),e([o(),m("esri/widgets/support/FilterBuilder/t9n/FilterBuilder")],b.prototype,"messagesFilterBuilder",void 0),e([o()],b.prototype,"selectedLayer",null),e([o({type:n})],b.prototype,"viewModel",void 0),e([o()],b.prototype,"selectedFeature",null),e([o()],b.prototype,"filterWhereClause",null),e([o()],b.prototype,"highlightHelper",null),e([o()],b.prototype,"view",void 0),e([o()],b.prototype,"_filterBuilder",void 0),e([o()],b.prototype,"_featureFilterText",void 0),e([o()],b.prototype,"_layerFilterText",void 0),e([o()],b.prototype,"_observer",void 0),e([o()],b.prototype,"_featureSpatialGraphics",null),e([o()],b.prototype,"_filteredFeatureItems",null),e([o()],b.prototype,"_filteredFeatureItemsPage",null),e([o()],b.prototype,"_observerNode",void 0),b=e([l("esri.widgets.FeatureForm.FeatureFormUtilityNetworkAssociations.UtilityNetworkAssociationItemList")],b);const F=b;export{F 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.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import{property as t}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import i from"../../Widget.js";import{loadCalciteComponents as n}from"../../support/componentsUtils.js";import{globalCss as s}from"../../support/globalCss.js";import"../../support/widgetUtils.js";import{messageBundle as r}from"../../support/decorators/messageBundle.js";import{tsx as c}from"../../support/jsxFactory.js";import{getAssociationTitle as a}from"../../support/UtilityNetworkAssociations/utils/getAssociationTitle.js";import{isFromElement as l}from"../../support/UtilityNetworkAssociations/utils/isFromElement.js";const m="esri-feature-form-utility-network-association-settings",d={base:m,infoContainer:`${m}__info-container`};let u=class extends i{constructor(e,t){super(e,t),this.percentAlong=50,this.headingLevel=5,this.messagesFeature=null,this.messagesCommon=null,this.messagesFeatureForm=null,this.readOnly=!1,this.sourceFeature=null,this.targetFeature=null,this.utilityNetwork=null}loadDependencies(){return n({block:()=>import("@esri/calcite-components/dist/components/calcite-block"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item"),"input-number":()=>import("@esri/calcite-components/dist/components/calcite-input-number"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch")})}get association(){return this._get("association")}set association(e){this.percentAlong=e.percentAlong?100*e.percentAlong:50,this._set("association",e)}get associationType(){return this.association.associationType}set associationType(e){this.association.associationType=e,"junction-edge-to-connectivity"!==e&&"junction-edge-from-connectivity"!==e||(this.association.percentAlong=void 0)}render(){return c("div",{class:this.classes(d.base,s.widget)},this._renderFromAssociationEndpoint(),this._renderToAssociationEndpoint(),this._renderAdditionalContent())}_renderFromAssociationEndpoint(){const{associationType:e,association:t,sourceFeature:o,targetFeature:i,messagesFeatureForm:n}=this,s=l(o.feature,t)?o:i,r=s.label,c=a(t,"from",n.associations);switch(e){case"connectivity":case"junction-junction-connectivity":case"junction-edge-midspan-connectivity":case"junction-edge-from-connectivity":case"junction-edge-to-connectivity":return this._renderAssociationEndpoint(r,c,this._renderConnectivityContent(s.feature,t.fromNetworkElement))}return this._renderAssociationEndpoint(r,c)}_renderToAssociationEndpoint(){const{associationType:e,association:t,sourceFeature:o,targetFeature:i,messagesFeatureForm:n}=this,s=l(o.feature,t)?i:o,r=s.label,c=a(t,"to",n.associations);switch(e){case"connectivity":case"junction-junction-connectivity":return this._renderAssociationEndpoint(r,c,this._renderConnectivityContent(s.feature,t.toNetworkElement));case"containment":return this._renderAssociationEndpoint(r,c,this._renderContainmentContent())}return this._renderAssociationEndpoint(r,c)}_renderAssociationEndpoint(e,t,o){return c("calcite-block",{description:t,heading:e,open:!0},o)}_renderContainmentContent(){const{messagesFeatureForm:e,association:t}=this,o=t.isContentVisible??!1;return c("calcite-label",{layout:"inline"},e.associations.visible,c("calcite-switch",{checked:o,onCalciteSwitchChange:({currentTarget:e})=>{t.isContentVisible=e.checked}}))}_renderConnectivityContent(e,t){const{messagesFeatureForm:o,utilityNetwork:i}=this,n=i.getTerminalConfiguration(e),s=n?.terminals.map((e=>this._renderComboboxListItemNumber(e.id,t.terminalId,e.name)))||[];return c("calcite-label",null,o.associations.terminal,c("calcite-combobox",{allowCustomValues:!1,clearDisabled:!0,label:o.associations.terminalComboboxLabel,overlayPositioning:"fixed",selectionMode:"single",onCalciteComboboxChange:({currentTarget:e})=>{t.terminalId=parseInt(e.value,10)}},...s))}_renderAdditionalContent(){const{associationType:e}=this;switch(e){case"connectivity":case"junction-junction-connectivity":case"attachment":case"containment":return}const t="junction-edge-midspan-connectivity"===e?e:"junction-edge-from-connectivity",{messagesFeatureForm:o}=this,i=[this._renderComboboxListItemString("junction-edge-midspan-connectivity",t,o.associations.midspanEdge),this._renderComboboxListItemString("junction-edge-from-connectivity",t,o.associations.endpointEdge)];return c("div",{class:d.infoContainer},c("calcite-label",{key:"additional-content"},o.associations.connectTo,c("calcite-combobox",{allowCustomValues:!1,clearDisabled:!0,label:o.associations.edgeConnectionComboboxLabel,overlayPositioning:"fixed",selectionMode:"single",onCalciteComboboxChange:({currentTarget:e})=>{this.associationType=e.value}},...i)),"junction-edge-midspan-connectivity"===t?this._renderMidspanEdgeContent():this._renderEndpointEdgeContent())}_renderMidspanEdgeContent(){const{messagesFeatureForm:e,percentAlong:t,association:o}=this;return o.percentAlong=t/100,c("calcite-label",{key:"midspan-edge"},e.associations.midspanLocation,c("calcite-input-number",{max:100,min:0,numberButtonType:"vertical",suffixText:"%",value:`${t}`,onCalciteInputNumberInput:({currentTarget:e})=>{this.percentAlong=parseFloat(e.value)}}))}_renderEndpointEdgeContent(){const{associationType:e,messagesFeatureForm:t}=this,o="junction-edge-to-connectivity"===e;return c("calcite-label",{key:"endpoint-edge"},t.associations.edgeSide,c("calcite-label",{layout:"inline"},t.associations.fromSide,c("calcite-switch",{checked:o,onCalciteSwitchChange:({currentTarget:e})=>{const t=e.checked?"junction-edge-to-connectivity":"junction-edge-from-connectivity";this.associationType=t}}),t.associations.toSide))}_renderComboboxListItemNumber(e,t,o){return c("calcite-combobox-item",{heading:o,key:`#${e}`,selected:t===e,value:`${e}`})}_renderComboboxListItemString(e,t,o){return c("calcite-combobox-item",{heading:o,key:`#${e}`,selected:t===e,value:`${e}`})}};e([t()],u.prototype,"association",null),e([t()],u.prototype,"percentAlong",void 0),e([t()],u.prototype,"associationType",null),e([t()],u.prototype,"headingLevel",void 0),e([t(),r("esri/widgets/Feature/t9n/Feature")],u.prototype,"messagesFeature",void 0),e([t(),r("esri/t9n/common")],u.prototype,"messagesCommon",void 0),e([t(),r("esri/widgets/FeatureForm/t9n/FeatureForm")],u.prototype,"messagesFeatureForm",void 0),e([t()],u.prototype,"readOnly",void 0),e([t()],u.prototype,"sourceFeature",void 0),e([t()],u.prototype,"targetFeature",void 0),e([t()],u.prototype,"utilityNetwork",void 0),u=e([o("esri.widgets.FeatureForm.FeatureFormUtilityNetworkAssociations.UtilityNetworkAssociationSettings")],u);const p=u;export{p as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import{property as t}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import i from"../../Widget.js";import{loadCalciteComponents as n}from"../../support/componentsUtils.js";import{globalCss as s}from"../../support/globalCss.js";import"../../support/widgetUtils.js";import{messageBundle as r}from"../../support/decorators/messageBundle.js";import{tsx as c}from"../../support/jsxFactory.js";import{getAssociationTitle as a}from"../../support/UtilityNetworkAssociations/utils/getAssociationTitle.js";import{isFromElement as l}from"../../support/UtilityNetworkAssociations/utils/isFromElement.js";const m="esri-feature-form-utility-network-association-settings",u={base:m,infoContainer:`${m}__info-container`};let d=class extends i{constructor(e,t){super(e,t),this.percentAlong=50,this.headingLevel=5,this.messagesFeature=null,this.messagesCommon=null,this.messagesFeatureForm=null,this.readOnly=!1,this.sourceFeature=null,this.targetFeature=null,this.utilityNetwork=null}loadDependencies(){return n({block:()=>import("@esri/calcite-components/dist/components/calcite-block"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item"),"input-number":()=>import("@esri/calcite-components/dist/components/calcite-input-number"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch")})}get association(){return this._get("association")}set association(e){this.percentAlong=e.percentAlong?100*e.percentAlong:50,this._set("association",e)}get associationType(){return this.association.associationType}set associationType(e){this.association.associationType=e,"junction-edge-to-connectivity"!==e&&"junction-edge-from-connectivity"!==e||(this.association.percentAlong=void 0)}render(){return c("div",{class:this.classes(u.base,s.widget)},this._renderFromAssociationEndpoint(),this._renderToAssociationEndpoint(),this._renderAdditionalContent())}_renderFromAssociationEndpoint(){const{associationType:e,association:t,sourceFeature:o,targetFeature:i,messagesFeatureForm:n}=this,s=l(o.feature,t)?o:i,r=s.label,c=a(t,"from",n.associations);switch(e){case"connectivity":case"junction-junction-connectivity":case"junction-edge-midspan-connectivity":case"junction-edge-from-connectivity":case"junction-edge-to-connectivity":return this._renderAssociationEndpoint(r,c,this._renderConnectivityContent(s.feature,t.fromNetworkElement))}return this._renderAssociationEndpoint(r,c)}_renderToAssociationEndpoint(){const{associationType:e,association:t,sourceFeature:o,targetFeature:i,messagesFeatureForm:n}=this,s=l(o.feature,t)?i:o,r=s.label,c=a(t,"to",n.associations);let m;switch(e){case"connectivity":case"junction-junction-connectivity":m=this._renderConnectivityContent(s.feature,t.toNetworkElement);break;case"containment":m=this._isNonspatial(s.feature)?null:this._renderContainmentContent()}return this._renderAssociationEndpoint(r,c,m)}_renderAssociationEndpoint(e,t,o){return c("calcite-block",{description:t,heading:e,open:!0},o)}_renderContainmentContent(){const{messagesFeatureForm:e,association:t}=this,o=t.isContentVisible??!1;return c("calcite-label",{layout:"inline"},e.associations.visible,c("calcite-switch",{checked:o,onCalciteSwitchChange:({currentTarget:e})=>{t.isContentVisible=e.checked}}))}_renderConnectivityContent(e,t){const{messagesFeatureForm:o,utilityNetwork:i}=this,n=i.getTerminalConfiguration(e),s=n?.terminals.map((e=>this._renderComboboxListItemNumber(e.id,t.terminalId,e.name)))||[];return c("calcite-label",null,o.associations.terminal,c("calcite-combobox",{allowCustomValues:!1,clearDisabled:!0,label:o.associations.terminalComboboxLabel,overlayPositioning:"fixed",selectionMode:"single",onCalciteComboboxChange:({currentTarget:e})=>{t.terminalId=parseInt(e.value,10)}},...s))}_renderAdditionalContent(){const{associationType:e}=this;switch(e){case"connectivity":case"junction-junction-connectivity":case"attachment":case"containment":return}const t="junction-edge-midspan-connectivity"===e?e:"junction-edge-from-connectivity",{messagesFeatureForm:o}=this,i=[this._renderComboboxListItemString("junction-edge-midspan-connectivity",t,o.associations.midspanEdge),this._renderComboboxListItemString("junction-edge-from-connectivity",t,o.associations.endpointEdge)];return c("div",{class:u.infoContainer},c("calcite-label",{key:"additional-content"},o.associations.connectTo,c("calcite-combobox",{allowCustomValues:!1,clearDisabled:!0,label:o.associations.edgeConnectionComboboxLabel,overlayPositioning:"fixed",selectionMode:"single",onCalciteComboboxChange:({currentTarget:e})=>{this.associationType=e.value}},...i)),"junction-edge-midspan-connectivity"===t?this._renderMidspanEdgeContent():this._renderEndpointEdgeContent())}_renderMidspanEdgeContent(){const{messagesFeatureForm:e,percentAlong:t,association:o}=this;return o.percentAlong=t/100,c("calcite-label",{key:"midspan-edge"},e.associations.midspanLocation,c("calcite-input-number",{max:100,min:0,numberButtonType:"vertical",suffixText:"%",value:`${t}`,onCalciteInputNumberInput:({currentTarget:e})=>{this.percentAlong=parseFloat(e.value)}}))}_renderEndpointEdgeContent(){const{associationType:e,messagesFeatureForm:t}=this,o="junction-edge-to-connectivity"===e;return c("calcite-label",{key:"endpoint-edge"},t.associations.edgeSide,c("calcite-label",{layout:"inline"},t.associations.fromSide,c("calcite-switch",{checked:o,onCalciteSwitchChange:({currentTarget:e})=>{const t=e.checked?"junction-edge-to-connectivity":"junction-edge-from-connectivity";this.associationType=t}}),t.associations.toSide))}_renderComboboxListItemNumber(e,t,o){return c("calcite-combobox-item",{heading:o,key:`#${e}`,selected:t===e,value:`${e}`})}_renderComboboxListItemString(e,t,o){return c("calcite-combobox-item",{heading:o,key:`#${e}`,selected:t===e,value:`${e}`})}_isNonspatial(e){const{sourceLayer:t}=e;return null!=t&&"geometryType"in t&&null==t.geometryType}};e([t()],d.prototype,"association",null),e([t()],d.prototype,"percentAlong",void 0),e([t()],d.prototype,"associationType",null),e([t()],d.prototype,"headingLevel",void 0),e([t(),r("esri/widgets/Feature/t9n/Feature")],d.prototype,"messagesFeature",void 0),e([t(),r("esri/t9n/common")],d.prototype,"messagesCommon",void 0),e([t(),r("esri/widgets/FeatureForm/t9n/FeatureForm")],d.prototype,"messagesFeatureForm",void 0),e([t()],d.prototype,"readOnly",void 0),e([t()],d.prototype,"sourceFeature",void 0),e([t()],d.prototype,"targetFeature",void 0),e([t()],d.prototype,"utilityNetwork",void 0),d=e([o("esri.widgets.FeatureForm.FeatureFormUtilityNetworkAssociations.UtilityNetworkAssociationSettings")],d);const p=d;export{p 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.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{neverReached as n}from"../../core/compilerUtils.js";import s from"../../core/Evented.js";import i from"../../core/Logger.js";import{destroyMaybe as o}from"../../core/maybe.js";import r from"../../core/Promise.js";import{debounce as a}from"../../core/promiseUtils.js";import{watch as l,whenOnce as u,on as p,syncAndInitial as c}from"../../core/reactiveUtils.js";import{templateHasKey as h}from"../../core/string.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/RandomLCG.js";import{subclass as f}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as m}from"../../core/support/UpdatingHandles.js";import y from"../../form/FormTemplate.js";import{isUtilityNetworkAssociationsElement as g,isGroupElement as _,isFieldElement as v,isRelationshipElement as I,isTextElement as x}from"../../form/support/formUtils.js";import E from"../../layers/support/ContingentValue.js";import{isEditableLayer as C}from"../../layers/support/editableLayers.js";import F from"../../layers/support/LayerContingentValuesCache.js";import{utc as b,unknown as V,system as w}from"../../time/constants.js";import{flattenAssociationInputs as A,flattenFieldInputs as j,isGroupInput as T,flattenRelationshipInputs as M,parseFormTemplateString as N,isRelationshipInput as k,isFieldInput as L,isTextElementInput as R,getNormalizedFeatureTypeInfo as S,valueIsValidContingentValue as U}from"./featureFormUtils.js";import Z from"./FieldInput.js";import{FormExpressionsManager as H}from"./FormExpressionsManager.js";import P from"./GroupInput.js";import O from"./RelationshipInput.js";import W from"./TextElementInput.js";import G from"./UtilityNetworkAssociationInput.js";import{createFormExpressionArcadeExecutor as $}from"../support/forms/expressions/FormExpressionArcadeExecutor.js";const D=new t({attributes:{}}),z={field:["editableExpression","requiredExpression","valueExpression","visibilityExpression"],group:["visibilityExpression"],relationship:["editableExpression","visibilityExpression"],text:["visibilityExpression"],utilityNetworkAssociations:["editableExpression","visibilityExpression"]},J="#JSAPI_CONTINGENT_VALUE_EMPTY_HASH",B="#JSAPI_CONTINGENT_VALUE_ANY_HASH",K="#JSAPI_CONTINGENT_VALUE_NULL_HASH",Y="esri.widgets.FeatureForm.FeatureFormViewModel",q=()=>i.getLogger(Y);let Q=class extends(r.EsriPromiseMixin(s.EventedAccessor)){constructor(e){super(e),this._expressionExecutorsInUse=new Set,this._expressionExecutorLookup=new Map,this._expressionsManager=null,this._contingentValuesCache=null,this._featureClone=D.clone(),this._initialFeature=D.clone(),this._timeZone=null,this._updatingHandles=new m,this.activeAssociation=null,this.arcadeEditType="NA",this.contingencyConstraintViolations=new Map,this.disabled=!1,this.highlightHelper=null,this.inputs=[],this.map=null,this.callbacks=null,this.strict=!1,this.pendingSubtypeChoice=null,this._updateInputs=a((async()=>{this._stopExpressions();const{_featureClone:e,_initialFeature:t,arcadeEditType:n,formTemplate:s,inputs:i,layer:o,timeZone:r}=this;if(!o)return;const a={arcadeEditType:n,feature:e,initialFeature:t,layer:o,timeZone:r},l=i.slice(),u=s?.elements&&s.elements.length>0?await this._updateInputsUsingFormElements(l,s.elements,a):this._updateInputsUsingLayerFields(l,o?.fields,a);this.inputs=u,await this._startExpressions()}))}initialize(){const e=l((()=>[this.layer,!!this.layer?.loaded,this.formTemplate,this.feature,this.timeZone,this.arcadeEditType]),(([e,t])=>{null!=e&&(t?this._updatingHandles.addPromise(this._updateInputs()):e.load().catch((()=>{})))}),c),t=l((()=>this._arcadeContextInfo),(e=>{null!=this._expressionsManager&&(this._expressionsManager.arcadeContextInfo=e,this._evaluateExpressions((e=>e.evaluateAll())))})),n=l((()=>this.layer),(e=>{const t="subtype-sublayer"===e?.type?e.parent:"feature"===e?.type?e:null;t&&this.addResolvingPromise(F.createLoadedLayerContingentValuesCache(t).then((e=>{this._contingentValuesCache=e,this.notifyChange("fieldsWithContingentValues")})))}),{initial:!0});this.addHandles([e,t,n])}destroy(){this.feature=null,this.layer=null,this._contingentValuesCache=o(this._contingentValuesCache),this.highlightHelper?.removeAll(),this._updatingHandles.destroy()}get _expressionInfosLookup(){return new Map(this.formTemplate?.expressionInfos?.map((e=>[e.name,e])))}get activeAssociationInput(){return this.allAssociationInputs.find((e=>e.uid===this.associationId))}get activeRelationshipInput(){return this.allRelationshipInputs.find((e=>e.relationshipId===this.relationshipId||e.activeCategory||e.showAllEnabled))}get _arcadeContextInfo(){const{_initialFeature:e,arcadeEditType:t,layer:n,map:s,spatialReference:i,timeZone:o}=this;return{layer:C(n)?n:null,originalFeature:e,editType:t,map:s,spatialReference:i,timeZone:o}}get associationId(){return this._get("associationId")}set associationId(e){null==e&&this.activeAssociationInput?.viewModel&&(this.activeAssociationInput.associatedLayer=null,this.activeAssociationInput.viewModel.activeAssociationType=null),this._set("associationId",e)}get associatedLayer(){return this.activeAssociationInput?.associatedLayer}set associatedLayer(e){this.activeAssociationInput&&(this.activeAssociationInput.associatedLayer=e)}get allAssociationInputs(){return A(this.inputs)}get allFieldInputs(){return j(this.inputs)}get allGroupInputs(){return this.inputs.filter(T)}get allRelationshipInputs(){return M(this.inputs)}get _layerFieldsByName(){return new Map(this.layer?.fields.map((e=>[e.name,e])))}get feature(){return this._get("feature")}set feature(e){const t=this._get("feature");this._featureClone=e?e.clone():D.clone(),this._initialFeature=this._featureClone.clone(),this._expressionsManager&&(this._expressionsManager.feature=this._featureClone),e?(this._resetFieldInputValues(this._featureClone),this.allRelationshipInputs.forEach((t=>t.feature=e))):(this.inputs.forEach((e=>e.destroy())),this.inputs.length=0),t!==e&&(this.pendingSubtypeChoice=null),this.contingencyConstraintViolations.clear(),this._set("feature",e)}get fieldsWithContingentValues(){if(null==this._contingentValuesCache)return new Set;const e=this._contingentValuesCache.fieldGroups.flatMap((e=>e.fields));return new Set(e)}get formTemplate(){return this.layer&&"formTemplate"in this.layer?this.layer.formTemplate:null}set formTemplate(e){void 0===e?this._clearOverride("formTemplate"):this._override("formTemplate",e)}get formDescription(){const{formTemplate:e,layer:t}=this;return e?.description&&t?N({label:e.description,attributes:this.getValues(),fieldsIndex:t.fieldsIndex,timeZone:this.timeZone}):null}get formTitle(){const{formTemplate:e,layer:t}=this;return e?.title&&t?N({label:e.title,attributes:this.getValues(),fieldsIndex:t.fieldsIndex,timeZone:this.timeZone}):null}get formHeaderVisible(){const{activeRelationshipInput:e,activeAssociationInput:t,formDescription:n,formTitle:s}=this;return!(e||t||!n&&!s)}get joinedContingentValues(){return this._joinContingentValues()}get layer(){return this.feature?.sourceLayer&&"applyEdits"in this.feature.sourceLayer?this.feature.sourceLayer:null}set layer(e){this._override("layer",e)}get relationshipId(){return this._get("relationshipId")}set relationshipId(e){const t=this.allRelationshipInputs;if(null!=e&&e===this.relationshipId||t.forEach((e=>{e.showAllEnabled=!1,e.activeCategory=null})),null!=e){const n=t.find((t=>t.relationshipId===e));n&&(n.showAllEnabled=!0)}this._set("relationshipId",e)}get spatialReference(){return this.layer?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get state(){return this.layer?.loaded?"ready":"disabled"}get submittable(){return!!this.valid||this.allFieldInputs.filter((e=>!e.valid)).every((({submittable:e})=>e))}get timeZone(){const{layer:e}=this;if(e&&"datesInUnknownTimezone"in e&&e.datesInUnknownTimezone)return b;const t=e&&"preferredTimeZone"in e&&e.preferredTimeZone;return this._timeZone===V?t||b:this._timeZone||w}set timeZone(e){this._timeZone=e}get updating(){return this._updatingHandles.updating}get valid(){const e=this.allFieldInputs;return e.length>0&&e.every((({valid:e})=>e))}findField(e){return this.allFieldInputs.find((t=>t.name===e))}getFieldValueOptionsForField(e,t){const n=this.findField(e);if(!n)return[[],[],[]];const s="coded-value"===n.domain?.type?n.domain.codedValues.map((({name:e,code:t})=>({name:e,value:t}))):[],i=null==n.value||s.some((e=>e.value===n.value))?[]:[{name:`${n.value}`,value:n.value}],o=this.fieldsWithContingentValues.has(e)?this._getContingentValueOptionsForField(e,t):[];if(o.length>0){const e=new Set(o.map((e=>e.value)));return[o,s.filter((t=>!e.has(t.value))),i]}return[s,[],i]}getValue(e){const t=this.layer?.getField(e);if(null!=t)return this._featureClone.getAttribute(t.name)??null}setValue(e,t){const{_featureClone:n,strict:s}=this,i=this.findField(e);t=""===t?null:t,i&&n.getAttribute(e)!==t&&(i.value=t,s&&!i.valid||(this._afterValueChange(i),this._evaluateExpressions((t=>t.evaluateInvalidated([e])))))}getValues(){return{...this._featureClone.attributes}}overrideInitialFeature(e){this._initialFeature=e}submit(){const e=this.allFieldInputs,t=new Set(e.filter((e=>e.valid)).map((({name:e})=>e))),n=e.filter((e=>!e.valid)).map((({name:e})=>e)),s=this.getValues();if(this.validateContingencyConstraints(s,{includeIncompleteViolations:!0}).length>0)for(const[i,o]of this.contingencyConstraintViolations.entries())"error"===o.type&&(t.delete(i),n.push(i));this.notifyChange("submittable"),this.notifyChange("valid"),this.emit("submit",{valid:[...t],invalid:n,values:s})}validateContingencyConstraints(e,t){const{_contingentValuesCache:n}=this,s=new Map;if(this.contingencyConstraintViolations=s,null==n)return[];const{invalid:i,incomplete:o}=n.validateContingencyConstraints(e),r=[...i,...t?.includeIncompleteViolations?o:[]];for(const a of r)for(const e of a.fieldGroup.fields)s.set(e,a);return r}notifyFeatureGeometryChanged(){const{feature:e,_featureClone:t}=this;e&&(t.geometry=e.geometry,this._evaluateExpressions((e=>e.evaluateInvalidatedByGeometry())))}applySubtypeDefaults(e){const{defaultValues:t}=e,{allFieldInputs:n}=this;for(const{name:s}of n){const e=t[s];null!=e&&this.setValue(s,e)}}_emitChangeEvent({name:e,valid:t,value:n}){this.emit("value-change",{layer:this.layer,feature:this.feature,fieldName:e,value:n,valid:t})}async _evaluateExpressions(e){const t=this._expressionsManager;null!=t&&await this._updatingHandles.addPromise(e(t).finally((()=>this._afterExpressionsEvaluated())))}async _updateInputsUsingFormElements(e,t,n){const s=new Map;for(const r of e)if(T(r)){s.set(r.element,r);for(const e of r.inputs)e.element&&s.set(e.element,e)}else r.element&&s.set(r.element,r);const i=new Map,o=await this._updateInputsUsingFormElementsRecursive({existingInputsByElement:s,updatedElements:t.filter(X),sharedInitializationProperties:n,group:null,newExpressionExecutorPromises:i});for(const[r,a]of s.entries())s.delete(r),a.destroy();return await Promise.all(Array.from(i.values())),o}async _updateInputsUsingFormElementsRecursive(e){const{existingInputsByElement:t,updatedElements:n,sharedInitializationProperties:s,group:i,newExpressionExecutorPromises:o}=e,r=[];for(const a of n){const e=t.has(a),n=e?t.get(a):this._makeInputFromElement(a,s,i);if(n){if(r.push(n),await u((()=>!n.updating)),this._assignExpressionExecutors(n,a,o),e)if(t.delete(a),T(n)){const{feature:e,timeZone:t}=s;n.set({feature:e,timeZone:t})}else if(k(n)){const e=this.relationshipId===a.relationshipId;n.set(s),n.set({map:this.map,showAllEnabled:e})}else g(n)?(n.set(s),n.set({map:this.map})):n.set(s);if(_(a)){const e=a.elements.filter((e=>X(e)));n.inputs=await this._updateInputsUsingFormElementsRecursive({existingInputsByElement:t,updatedElements:e,sharedInitializationProperties:s,group:n,newExpressionExecutorPromises:o})}}}return r}_updateInputsUsingLayerFields(e,t,n){if(!Array.isArray(t))return q().warn(this.declaredClass,"No attribute fields found."),[];const s=new Map;for(const o of e)if(T(o)){for(const e of o.inputs)e.destroy();o.inputs.length=0,o.destroy()}else k(o)?o.destroy():L(o)&&(null!==o.element?o.destroy():s.set(o.field,o));const i=[];for(const o of t){const e=n.feature?.getAttribute(o.name)??null,t=s.get(o)??new Z({field:o,preservesValueWhenHidden:this.formTemplate?.preserveFieldValuesWhenHidden});i.push(t.set({...n,value:e})),s.delete(o)}for(const[o,r]of s.entries())s.delete(o),r.destroy();return i}_resetFieldInputValues(e){for(const t of this.allFieldInputs)t.value=e.getAttribute(t.name)}_makeInputFromElement(e,t,s){return _(e)?ee(e,t):v(e)?this._makeFieldInputFromElement(e,t,s):I(e)?this._makeRelationshipInputFromElement(e,t,s):g(e)?this._makeUtilityNetworkAssociationInputFromElement(e,t,s):x(e)?te(e,t):g(e)?this._makeUtilityNetworkAssociationInputFromElement(e,t,s):n()}_makeFieldInputFromElement(e,t,n){const{arcadeEditType:s,feature:i,initialFeature:o,layer:r,timeZone:a}=t,{fieldName:l}=e,u=l&&this._layerFieldsByName.get(l);return u?new Z({arcadeEditType:s,element:e,field:u,value:i?.getAttribute(e.fieldName)??null,feature:i,initialFeature:o,layer:r,group:n,preservesValueWhenHidden:this.formTemplate?.preserveFieldValuesWhenHidden,timeZone:a}):null}_makeRelationshipInputFromElement(e,t,n=null){const{map:s}=this,{feature:i,layer:o,timeZone:r}=t,a=new O({element:e,feature:i,group:n,layer:o,map:s,timeZone:r});return a.addHandles(p((()=>a.relatedLayer),"edits",(()=>this._evaluateExpressions((e=>e.evaluateAsyncExpressions()))))),a}_makeUtilityNetworkAssociationInputFromElement(e,t,n=null){const{map:s}=this,{feature:i,layer:o,timeZone:r}=t;return new G({element:e,feature:i,group:n,layer:o,map:s,timeZone:r})}_assignExpressionExecutors(e,t,n){const s=z[t.type],i=[];for(const o of s){const s=`${o}Executor`;if(e[s]){this._useExecutor(e[s]);continue}const r=t[o];if(null!=r&&""!==r){const t=this._expressionInfosLookup.get(r)?.expression??r;i.push(this._getOrCreateExecutorForExpression(t,n).then((t=>{e[s]=this._useExecutor(t)})))}}return R(e)&&i.push(...this._assignTextElementExpressionExecutors(e,n)),i}_assignTextElementExpressionExecutors(e,t){const{_expressionInfosLookup:n}=this,s=[];for(const o of e.expressionsUsed){const r=n.get(o);null!=r?s.push(this._getOrCreateExecutorForExpression(r.expression,t).then((t=>e.setExpressionExecutor(o,this._useExecutor(t))))):i.getLogger(this).error("feature-form:expression-not-found",`Could not find expressionInfo object with name '${o}'`)}for(const i of e.fieldsUsed){const n=`return $feature['${i}'];`;s.push(this._getOrCreateExecutorForExpression(n,t).then((t=>e.setFieldExecutor(i,this._useExecutor(t)))))}return s}async _getOrCreateExecutorForExpression(e,t){const{_expressionExecutorLookup:n}=this;if(n.has(e))return n.get(e);if(t.has(e))return t.get(e);const s=$(e,this.layer);t.set(e,s);const i=await s;return n.set(e,i),i}_createExpressionsManager(e){const{_arcadeContextInfo:t,_featureClone:n,allFieldInputs:s,formTemplate:i}=this;this._expressionsManager=new H({executors:e,feature:n,arcadeContextInfo:t,fieldInputs:s,preserveFieldValuesWhenHidden:!0===i?.preserveFieldValuesWhenHidden})}async _startExpressions(){if(0===this._expressionExecutorsInUse.size)return;const e=Array.from(this._expressionExecutorsInUse);this._createExpressionsManager(e),this._evaluateExpressions((e=>e.evaluateAll()))}_stopExpressions(){this._expressionsManager=o(this._expressionsManager),this._expressionExecutorsInUse.clear()}_useExecutor(e){return this._expressionExecutorsInUse.add(e),e}_afterValueChange(e){const{name:t,value:n}=e,{_featureClone:s,formTemplate:i,layer:o}=this;if(!o)return;const r=s.getAttribute(t);s.setAttribute(t,n);const{typeFieldName:a,types:l}=S(o);if((e.isSubtypeField||t===a)&&n!==r){if("subtype-sublayer"===o.type){const e=o.parent?.findSublayerForFeature(s);e&&(this.feature&&(this.feature.sourceLayer=e),s.sourceLayer=e)}const e=new Set;for(const t of l)if(t.domains&&"object"==typeof t.domains)for(const n of Object.keys(t.domains))e.add(n);for(const t of e){const e=this.findField(t);e&&e.notifyChange("domain")}this.notifyChange("joinedContingentValues")}if(null!=i){const{description:e,title:n}=i;n&&h(n,t)&&this.notifyChange("formTitle"),e&&h(e,t)&&this.notifyChange("formDescription")}this._emitChangeEvent(e)}_afterExpressionsEvaluated(){const{_featureClone:e}=this;for(const t of this.allFieldInputs)t.value!==e.getAttribute(t.name)&&this._afterValueChange(t)}_joinContingentValues(){const e=this._contingentValuesCache;if(null==e)return[];const{typeFieldName:t}=S(this.layer),n=t?this.getValue(t):null,s=[];for(const r of e.fieldGroups){const{contingencies:e,fields:t,name:i}=r,o=[];for(const s of e)s.isRetired||null!=s.subtype&&s.subtype.code!==n||o.push({values:s.values});o.length>0&&s.push({name:i,fields:t,contingencies:o})}const[i,o]=this._generateJoinPlan(s);return[...i.flatMap((e=>this._joinFieldGroupContingencies(e))),...o.flatMap((e=>e.contingencies))]}_generateJoinPlan(e){const t=new Map,n=[],s=new Set;for(const l of e)for(const e of l.fields)if(t.has(e)){const i=t.get(e),o=l,r=[i.name,o.name].sort().join("|");if(s.has(r))continue;n.push([i,o]),s.add(r),t.set(e,o)}else t.set(e,l);const i=new Set(n.flat()),o=new Set(e);for(const l of i)o.delete(l);const r=new Map,a=new Map;for(const l of new Set(n.flat())){const e=Symbol(l.name);r.set(e,new Set([l])),a.set(l,e)}for(const[l,u]of n){const e=a.get(l),t=a.get(u);if(e===t)continue;const n=r.get(e),s=r.get(t);for(const i of s)n.add(i),a.set(i,e);r.delete(t)}return[[...r.values()].map((e=>[...e])),[...o]]}_joinFieldGroupContingencies(e){const t=e.slice(),n=t.shift();let s=t.shift(),i=this._generateJoinKey(n.fields,s.fields),o=new Set([...n.fields,...s.fields]),r=new Map;for(const l of n.contingencies){const[e]=this._hashContingency(l,i.codedValueFields,!0);r.has(e)?r.get(e)?.push(l):r.set(e,[l])}for(;t.length>0;){const e=new Map,n=t.shift(),a=this._generateJoinKey(o,n.fields);for(const t of s.contingencies){const[n,s]=this._hashContingency(t,i.codedValueFields),o=s?this._findMatchingContingenciesWithAnyHashMask(r,n):r.get(n);if(r.has(B)&&o?.push(...this._findMatchingContingenciesContainingAny(t,r.get(B),i.codedValueFields)),null!=o)for(const r of o){const n=i.rangeFields.length>0?this._joinContingenciesWithRangeDomains(r,t,i.rangeFields):this._joinContingencies(r,t);if(null==n)break;const[s]=this._hashContingency(n,a.codedValueFields,!0);e.has(s)?e.get(s)?.push(n):e.set(s,[n])}}r=e,s=n,i=a,o=new Set([...o,...s.fields])}const a=[];for(const l of s.contingencies){const[e,t]=this._hashContingency(l,i.codedValueFields),n=t?this._findMatchingContingenciesWithAnyHashMask(r,e):r.get(e);if(r.has(B)&&n.push(...this._findMatchingContingenciesContainingAny(l,r.get(B),i.codedValueFields)),null!=n)for(const s of n){const e=i.rangeFields.length>0?this._joinContingenciesWithRangeDomains(s,l,i.rangeFields):this._joinContingencies(s,l);null!=e&&a.push(e)}}return a}_joinContingencies(e,t){const n={values:{...e.values,...t.values}};for(const[s,i]of Object.entries(n.values))"any"===i.objectType&&null!=e.values[s]&&(n.values[s]=e.values[s]);return n}_joinContingenciesWithRangeDomains(e,t,n){const s=this._joinContingencies(e,t);for(const i of n){const n=e.values[i],o=t.values[i],{leftIsNull:r,rightIsNull:a,bothAreNull:l,leftIsAny:u,rightIsAny:p,bothAreAny:c,leftIsRange:h,rightIsRange:d}=this._compareObjectTypes(n.objectType,o.objectType);if(l||c)continue;if(r&&p||a&&u){s.values[i]=new E({objectType:"null"});continue}if(r&&d||a&&h)return null;u?(n.minValue=-1/0,n.maxValue=1/0):p&&(o.minValue=-1/0,o.maxValue=1/0);const f=Math.max(n.minValue,o.minValue),m=Math.min(n.maxValue,o.maxValue);if(f>m)return null;s.values[i]=new E({objectType:"range",minValue:f,maxValue:m})}return s}_findMatchingContingenciesContainingAny(e,t,n){return t.filter((t=>n.every((n=>{const s=t.values[n],i=e.values[n];return"any"===s.objectType||"any"===i.objectType||s.codedValue?.code===i.codedValue?.code}))))}_findMatchingContingenciesWithAnyHashMask(e,t){const n=RegExp(`${t}$`),s=[];for(const[i,o]of e){if(i===B)break;n.test(i)&&s.push(...o)}return s}_generateJoinKey(e,t){const n=Array.isArray(e)?new Set(e):e,s=Array.isArray(t)?new Set(t):t,i=n.size<s.size?n:s,o=i===n?s:n,{feature:r}=this,a=new Set,l=new Set;for(const u of i)if(o.has(u)){const e=this.layer?.getFieldDomain(u,{feature:r??void 0,excludeImpliedDomains:!0});if(null==e)continue;switch(e.type){case"coded-value":a.add(u);break;case"range":l.add(u)}}return{codedValueFields:[...a],rangeFields:[...l]}}_contingencyIsValid(e,t){const n={};for(const{name:s,value:i}of this.allFieldInputs)this.fieldsWithContingentValues.has(s)&&null!=i&&s!==e&&(n[s]=i);return Object.entries(n).every((([e,n])=>!t.values.hasOwnProperty(e)||U(n,t.values[e])))}_getContingentValueOptionsForField(e,t){const n=this.joinedContingentValues.slice(),s=new Map,i={code:"",name:t??"No value"};for(const o of n){const t=o.values[e];if("code"===t?.objectType||"null"===t?.objectType){const{code:n,name:r}=t.codedValue&&"null"!==t.objectType?t.codedValue:i;!s.has(n)&&this._contingencyIsValid(e,o)&&s.set(n,{name:r,value:n})}}return[...s.values()]}_hashContingency(e,t,n=!1){if(t.length<1)return[J,!1];const s=[];let i=!1;for(const o of t){const t=e.values[o];if("any"===t.objectType){if(n)return[B,!0];i=!0,s.push(`${o}:.*`)}else"null"===t.objectType?s.push(`${o}:${K}`):s.push(`${o}:${t.codedValue?.code}`)}return[s.sort().join("&"),i]}_compareObjectTypes(e,t){return{leftIsNull:"null"===e,rightIsNull:"null"===t,bothAreNull:"null"===e&&"null"===t,leftIsAny:"any"===e,rightIsAny:"any"===t,bothAreAny:"any"===e&&"any"===t,leftIsRange:"range"===e,rightIsRange:"range"===t}}get test(){return{featureClone:this._featureClone}}};function X(e){return"field"===e.type||"group"===e.type||"relationship"===e.type||"text"===e.type||"utilityNetworkAssociations"===e.type||(q().warn("form-info::unsupported-element-type","Only element types 'field', 'group' and 'relationship' are supported",`Element ${e.label} has unsupported type '${e.type}'`),!1)}function ee(e,t){const{feature:n,layer:s}=t;return new P({element:e,inputs:[],feature:n,layer:s})}function te(e,t,n=null){const{feature:s,layer:i,timeZone:o}=t;return new W({element:e,feature:s,group:n,layer:i,timeZone:o})}e([d()],Q.prototype,"_expressionInfosLookup",null),e([d()],Q.prototype,"_featureClone",void 0),e([d()],Q.prototype,"_timeZone",void 0),e([d()],Q.prototype,"activeAssociation",void 0),e([d()],Q.prototype,"activeAssociationInput",null),e([d()],Q.prototype,"activeRelationshipInput",null),e([d()],Q.prototype,"_arcadeContextInfo",null),e([d()],Q.prototype,"associationId",null),e([d()],Q.prototype,"associatedLayer",null),e([d()],Q.prototype,"allAssociationInputs",null),e([d()],Q.prototype,"allFieldInputs",null),e([d()],Q.prototype,"allGroupInputs",null),e([d()],Q.prototype,"allRelationshipInputs",null),e([d()],Q.prototype,"_layerFieldsByName",null),e([d()],Q.prototype,"arcadeEditType",void 0),e([d()],Q.prototype,"contingencyConstraintViolations",void 0),e([d()],Q.prototype,"disabled",void 0),e([d()],Q.prototype,"feature",null),e([d()],Q.prototype,"fieldsWithContingentValues",null),e([d({type:y})],Q.prototype,"formTemplate",null),e([d()],Q.prototype,"formDescription",null),e([d()],Q.prototype,"formTitle",null),e([d()],Q.prototype,"formHeaderVisible",null),e([d()],Q.prototype,"highlightHelper",void 0),e([d()],Q.prototype,"inputs",void 0),e([d()],Q.prototype,"joinedContingentValues",null),e([d()],Q.prototype,"layer",null),e([d()],Q.prototype,"map",void 0),e([d()],Q.prototype,"callbacks",void 0),e([d()],Q.prototype,"relationshipId",null),e([d()],Q.prototype,"spatialReference",null),e([d()],Q.prototype,"state",null),e([d()],Q.prototype,"strict",void 0),e([d()],Q.prototype,"submittable",null),e([d()],Q.prototype,"timeZone",null),e([d()],Q.prototype,"updating",null),e([d()],Q.prototype,"valid",null),e([d()],Q.prototype,"pendingSubtypeChoice",void 0),e([d()],Q.prototype,"getValues",null),e([d()],Q.prototype,"submit",null),e([d()],Q.prototype,"test",null),Q=e([f(Y)],Q);const ne=Q;export{ne as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{neverReached as n}from"../../core/compilerUtils.js";import s from"../../core/Evented.js";import i from"../../core/Logger.js";import{destroyMaybe as o}from"../../core/maybe.js";import r from"../../core/Promise.js";import{debounce as a}from"../../core/promiseUtils.js";import{watch as l,whenOnce as u,on as p,syncAndInitial as c}from"../../core/reactiveUtils.js";import{templateHasKey as h}from"../../core/string.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/RandomLCG.js";import{subclass as f}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as m}from"../../core/support/UpdatingHandles.js";import y from"../../form/FormTemplate.js";import{isUtilityNetworkAssociationsElement as g,isGroupElement as _,isFieldElement as v,isRelationshipElement as I,isTextElement as x}from"../../form/support/formUtils.js";import E from"../../layers/support/ContingentValue.js";import{isEditableLayer as C}from"../../layers/support/editableLayers.js";import F from"../../layers/support/LayerContingentValuesCache.js";import{utc as b,unknown as V,system as w}from"../../time/constants.js";import{flattenAssociationInputs as A,flattenFieldInputs as j,isGroupInput as T,flattenRelationshipInputs as M,parseFormTemplateString as k,isRelationshipInput as N,isFieldInput as L,isTextElementInput as R,getNormalizedFeatureTypeInfo as S,valueIsValidContingentValue as U}from"./featureFormUtils.js";import Z from"./FieldInput.js";import{FormExpressionsManager as H}from"./FormExpressionsManager.js";import P from"./GroupInput.js";import O from"./RelationshipInput.js";import W from"./TextElementInput.js";import{createFormExpressionArcadeExecutor as G}from"../support/forms/expressions/FormExpressionArcadeExecutor.js";const $=new t({attributes:{}}),D={field:["editableExpression","requiredExpression","valueExpression","visibilityExpression"],group:["visibilityExpression"],relationship:["editableExpression","visibilityExpression"],text:["visibilityExpression"],utilityNetworkAssociations:["editableExpression","visibilityExpression"]},z="#JSAPI_CONTINGENT_VALUE_EMPTY_HASH",J="#JSAPI_CONTINGENT_VALUE_ANY_HASH",B="#JSAPI_CONTINGENT_VALUE_NULL_HASH",K="esri.widgets.FeatureForm.FeatureFormViewModel",Y=()=>i.getLogger(K);let q=class extends(r.EsriPromiseMixin(s.EventedAccessor)){constructor(e){super(e),this._expressionExecutorsInUse=new Set,this._expressionExecutorLookup=new Map,this._expressionsManager=null,this._contingentValuesCache=null,this._featureClone=$.clone(),this._initialFeature=$.clone(),this._timeZone=null,this._updatingHandles=new m,this.activeAssociation=null,this.arcadeEditType="NA",this.contingencyConstraintViolations=new Map,this.disabled=!1,this.highlightHelper=null,this.inputs=[],this.map=null,this.callbacks=null,this.strict=!1,this.pendingSubtypeChoice=null,this._updateInputs=a((async()=>{this._stopExpressions();const{_featureClone:e,_initialFeature:t,arcadeEditType:n,formTemplate:s,inputs:i,layer:o,timeZone:r}=this;if(!o)return;const a={arcadeEditType:n,feature:e,initialFeature:t,layer:o,timeZone:r},l=i.slice(),u=s?.elements&&s.elements.length>0?await this._updateInputsUsingFormElements(l,s.elements,a):this._updateInputsUsingLayerFields(l,o?.fields,a);this.inputs=u,await this._startExpressions()}))}initialize(){const e=l((()=>[this.layer,!!this.layer?.loaded,this.formTemplate,this.feature,this.timeZone,this.arcadeEditType]),(([e,t])=>{null!=e&&(t?this._updatingHandles.addPromise(this._updateInputs()):e.load().catch((()=>{})))}),c),t=l((()=>this._arcadeContextInfo),(e=>{null!=this._expressionsManager&&(this._expressionsManager.arcadeContextInfo=e,this._evaluateExpressions((e=>e.evaluateAll())))})),n=l((()=>this.layer),(e=>{const t="subtype-sublayer"===e?.type?e.parent:"feature"===e?.type?e:null;t&&this.addResolvingPromise(F.createLoadedLayerContingentValuesCache(t).then((e=>{this._contingentValuesCache=e,this.notifyChange("fieldsWithContingentValues")})))}),{initial:!0});this.addHandles([e,t,n])}destroy(){this.feature=null,this.layer=null,this._contingentValuesCache=o(this._contingentValuesCache),this.highlightHelper?.removeAll(),this._updatingHandles.destroy()}get _expressionInfosLookup(){return new Map(this.formTemplate?.expressionInfos?.map((e=>[e.name,e])))}get activeAssociationInput(){return this.allAssociationInputs.find((e=>e.uid===this.associationId))}get activeRelationshipInput(){return this.allRelationshipInputs.find((e=>e.relationshipId===this.relationshipId||e.activeCategory||e.showAllEnabled))}get _arcadeContextInfo(){const{_initialFeature:e,arcadeEditType:t,layer:n,map:s,spatialReference:i,timeZone:o}=this;return{layer:C(n)?n:null,originalFeature:e,editType:t,map:s,spatialReference:i,timeZone:o}}get associationId(){return this._get("associationId")}set associationId(e){null==e&&this.activeAssociationInput?.viewModel&&(this.activeAssociationInput.associatedLayer=null,this.activeAssociationInput.viewModel.activeAssociationType=null),this._set("associationId",e)}get associatedLayer(){return this.activeAssociationInput?.associatedLayer}set associatedLayer(e){this.activeAssociationInput&&(this.activeAssociationInput.associatedLayer=e)}get allAssociationInputs(){return A(this.inputs)}get allFieldInputs(){return j(this.inputs)}get allGroupInputs(){return this.inputs.filter(T)}get allRelationshipInputs(){return M(this.inputs)}get _layerFieldsByName(){return new Map(this.layer?.fields.map((e=>[e.name,e])))}get feature(){return this._get("feature")}set feature(e){const t=this._get("feature");this._featureClone=e?e.clone():$.clone(),this._initialFeature=this._featureClone.clone(),this._expressionsManager&&(this._expressionsManager.feature=this._featureClone),e?(this._resetFieldInputValues(this._featureClone),this.allRelationshipInputs.forEach((t=>t.feature=e))):(this.inputs.forEach((e=>e.destroy())),this.inputs.length=0),t!==e&&(this.pendingSubtypeChoice=null),this.contingencyConstraintViolations.clear(),this._set("feature",e)}get fieldsWithContingentValues(){if(null==this._contingentValuesCache)return new Set;const e=this._contingentValuesCache.fieldGroups.flatMap((e=>e.fields));return new Set(e)}get formTemplate(){return this.layer&&"formTemplate"in this.layer?this.layer.formTemplate:null}set formTemplate(e){void 0===e?this._clearOverride("formTemplate"):this._override("formTemplate",e)}get formDescription(){const{formTemplate:e,layer:t}=this;return e?.description&&t?k({label:e.description,attributes:this.getValues(),fieldsIndex:t.fieldsIndex,timeZone:this.timeZone}):null}get formTitle(){const{formTemplate:e,layer:t}=this;return e?.title&&t?k({label:e.title,attributes:this.getValues(),fieldsIndex:t.fieldsIndex,timeZone:this.timeZone}):null}get formHeaderVisible(){const{activeRelationshipInput:e,activeAssociationInput:t,formDescription:n,formTitle:s}=this;return!(e||t||!n&&!s)}get joinedContingentValues(){return this._joinContingentValues()}get layer(){return this.feature?.sourceLayer&&"applyEdits"in this.feature.sourceLayer?this.feature.sourceLayer:null}set layer(e){this._override("layer",e)}get relationshipId(){return this._get("relationshipId")}set relationshipId(e){const t=this.allRelationshipInputs;if(null!=e&&e===this.relationshipId||t.forEach((e=>{e.showAllEnabled=!1,e.activeCategory=null})),null!=e){const n=t.find((t=>t.relationshipId===e));n&&(n.showAllEnabled=!0)}this._set("relationshipId",e)}get spatialReference(){return this.layer?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get state(){return this.layer?.loaded?"ready":"disabled"}get submittable(){return!!this.valid||this.allFieldInputs.filter((e=>!e.valid)).every((({submittable:e})=>e))}get timeZone(){const{layer:e}=this;if(e&&"datesInUnknownTimezone"in e&&e.datesInUnknownTimezone)return b;const t=e&&"preferredTimeZone"in e&&e.preferredTimeZone;return this._timeZone===V?t||b:this._timeZone||w}set timeZone(e){this._timeZone=e}get updating(){return this._updatingHandles.updating}get valid(){const e=this.allFieldInputs;return e.length>0&&e.every((({valid:e})=>e))}findField(e){return this.allFieldInputs.find((t=>t.name===e))}getFieldValueOptionsForField(e,t){const n=this.findField(e);if(!n)return[[],[],[]];const s="coded-value"===n.domain?.type?n.domain.codedValues.map((({name:e,code:t})=>({name:e,value:t}))):[],i=null==n.value||s.some((e=>e.value===n.value))?[]:[{name:`${n.value}`,value:n.value}],o=this.fieldsWithContingentValues.has(e)?this._getContingentValueOptionsForField(e,t):[];if(o.length>0){const e=new Set(o.map((e=>e.value)));return[o,s.filter((t=>!e.has(t.value))),i]}return[s,[],i]}getValue(e){const t=this.layer?.getField(e);if(null!=t)return this._featureClone.getAttribute(t.name)??null}setValue(e,t){const{_featureClone:n,strict:s}=this,i=this.findField(e);t=""===t?null:t,i&&n.getAttribute(e)!==t&&(i.value=t,s&&!i.valid||(this._afterValueChange(i),this._evaluateExpressions((t=>t.evaluateInvalidated([e])))))}getValues(){return{...this._featureClone.attributes}}overrideInitialFeature(e){this._initialFeature=e}submit(){const e=this.allFieldInputs,t=new Set(e.filter((e=>e.valid)).map((({name:e})=>e))),n=e.filter((e=>!e.valid)).map((({name:e})=>e)),s=this.getValues();if(this.validateContingencyConstraints(s,{includeIncompleteViolations:!0}).length>0)for(const[i,o]of this.contingencyConstraintViolations.entries())"error"===o.type&&(t.delete(i),n.push(i));this.notifyChange("submittable"),this.notifyChange("valid"),this.emit("submit",{valid:[...t],invalid:n,values:s})}validateContingencyConstraints(e,t){const{_contingentValuesCache:n}=this,s=new Map;if(this.contingencyConstraintViolations=s,null==n)return[];const{invalid:i,incomplete:o}=n.validateContingencyConstraints(e),r=[...i,...t?.includeIncompleteViolations?o:[]];for(const a of r)for(const e of a.fieldGroup.fields)s.set(e,a);return r}notifyFeatureGeometryChanged(){const{feature:e,_featureClone:t}=this;e&&(t.geometry=e.geometry,this._evaluateExpressions((e=>e.evaluateInvalidatedByGeometry())))}applySubtypeDefaults(e){const{defaultValues:t}=e,{allFieldInputs:n}=this;for(const{name:s}of n){const e=t[s];null!=e&&this.setValue(s,e)}}_emitChangeEvent({name:e,valid:t,value:n}){this.emit("value-change",{layer:this.layer,feature:this.feature,fieldName:e,value:n,valid:t})}async _evaluateExpressions(e){const t=this._expressionsManager;null!=t&&await this._updatingHandles.addPromise(e(t).finally((()=>this._afterExpressionsEvaluated())))}async _updateInputsUsingFormElements(e,t,n){const s=new Map;for(const r of e)if(T(r)){s.set(r.element,r);for(const e of r.inputs)e.element&&s.set(e.element,e)}else r.element&&s.set(r.element,r);const i=new Map,o=await this._updateInputsUsingFormElementsRecursive({existingInputsByElement:s,updatedElements:t.filter(Q),sharedInitializationProperties:n,group:null,newExpressionExecutorPromises:i});for(const[r,a]of s.entries())s.delete(r),a.destroy();return await Promise.all(Array.from(i.values())),o}async _updateInputsUsingFormElementsRecursive(e){const{existingInputsByElement:t,updatedElements:n,sharedInitializationProperties:s,group:i,newExpressionExecutorPromises:o}=e,r=[];for(const a of n){const e=t.has(a),n=e?t.get(a):g(a)?await this._makeUtilityNetworkAssociationInputFromElement(a,s,i):this._makeInputFromElement(a,s,i);if(n){if(r.push(n),await u((()=>!n.updating)),this._assignExpressionExecutors(n,a,o),e)if(t.delete(a),T(n)){const{feature:e,timeZone:t}=s;n.set({feature:e,timeZone:t})}else if(N(n)){const e=this.relationshipId===a.relationshipId;n.set(s),n.set({map:this.map,showAllEnabled:e})}else g(n)?(n.set(s),n.set({map:this.map})):n.set(s);if(_(a)){const e=a.elements.filter((e=>Q(e)));n.inputs=await this._updateInputsUsingFormElementsRecursive({existingInputsByElement:t,updatedElements:e,sharedInitializationProperties:s,group:n,newExpressionExecutorPromises:o})}}}return r}_updateInputsUsingLayerFields(e,t,n){if(!Array.isArray(t))return Y().warn(this.declaredClass,"No attribute fields found."),[];const s=new Map;for(const o of e)if(T(o)){for(const e of o.inputs)e.destroy();o.inputs.length=0,o.destroy()}else N(o)?o.destroy():L(o)&&(null!==o.element?o.destroy():s.set(o.field,o));const i=[];for(const o of t){const e=n.feature?.getAttribute(o.name)??null,t=s.get(o)??new Z({field:o,preservesValueWhenHidden:this.formTemplate?.preserveFieldValuesWhenHidden});i.push(t.set({...n,value:e})),s.delete(o)}for(const[o,r]of s.entries())s.delete(o),r.destroy();return i}_resetFieldInputValues(e){for(const t of this.allFieldInputs)t.value=e.getAttribute(t.name)}_makeInputFromElement(e,t,s){return _(e)?X(e,t):v(e)?this._makeFieldInputFromElement(e,t,s):I(e)?this._makeRelationshipInputFromElement(e,t,s):g(e)?this._makeUtilityNetworkAssociationInputFromElement(e,t,s):x(e)?ee(e,t):g(e)?this._makeUtilityNetworkAssociationInputFromElement(e,t,s):n()}_makeFieldInputFromElement(e,t,n){const{arcadeEditType:s,feature:i,initialFeature:o,layer:r,timeZone:a}=t,{fieldName:l}=e,u=l&&this._layerFieldsByName.get(l);return u?new Z({arcadeEditType:s,element:e,field:u,value:i?.getAttribute(e.fieldName)??null,feature:i,initialFeature:o,layer:r,group:n,preservesValueWhenHidden:this.formTemplate?.preserveFieldValuesWhenHidden,timeZone:a}):null}_makeRelationshipInputFromElement(e,t,n=null){const{map:s}=this,{feature:i,layer:o,timeZone:r}=t,a=new O({element:e,feature:i,group:n,layer:o,map:s,timeZone:r});return a.addHandles(p((()=>a.relatedLayer),"edits",(()=>this._evaluateExpressions((e=>e.evaluateAsyncExpressions()))))),a}async _makeUtilityNetworkAssociationInputFromElement(e,t,n=null){const{map:s}=this,{feature:i,layer:o,timeZone:r}=t;return new(0,(await import("./UtilityNetworkAssociationInput.js")).default)({element:e,feature:i,group:n,layer:o,map:s,timeZone:r})}_assignExpressionExecutors(e,t,n){const s=D[t.type],i=[];for(const o of s){const s=`${o}Executor`;if(e[s]){this._useExecutor(e[s]);continue}const r=t[o];if(null!=r&&""!==r){const t=this._expressionInfosLookup.get(r)?.expression??r;i.push(this._getOrCreateExecutorForExpression(t,n).then((t=>{e[s]=this._useExecutor(t)})))}}return R(e)&&i.push(...this._assignTextElementExpressionExecutors(e,n)),i}_assignTextElementExpressionExecutors(e,t){const{_expressionInfosLookup:n}=this,s=[];for(const o of e.expressionsUsed){const r=n.get(o);null!=r?s.push(this._getOrCreateExecutorForExpression(r.expression,t).then((t=>e.setExpressionExecutor(o,this._useExecutor(t))))):i.getLogger(this).error("feature-form:expression-not-found",`Could not find expressionInfo object with name '${o}'`)}for(const i of e.fieldsUsed){const n=`return $feature['${i}'];`;s.push(this._getOrCreateExecutorForExpression(n,t).then((t=>e.setFieldExecutor(i,this._useExecutor(t)))))}return s}async _getOrCreateExecutorForExpression(e,t){const{_expressionExecutorLookup:n}=this;if(n.has(e))return n.get(e);if(t.has(e))return t.get(e);const s=G(e,this.layer);t.set(e,s);const i=await s;return n.set(e,i),i}_createExpressionsManager(e){const{_arcadeContextInfo:t,_featureClone:n,allFieldInputs:s,formTemplate:i}=this;this._expressionsManager=new H({executors:e,feature:n,arcadeContextInfo:t,fieldInputs:s,preserveFieldValuesWhenHidden:!0===i?.preserveFieldValuesWhenHidden})}async _startExpressions(){if(0===this._expressionExecutorsInUse.size)return;const e=Array.from(this._expressionExecutorsInUse);this._createExpressionsManager(e),this._evaluateExpressions((e=>e.evaluateAll()))}_stopExpressions(){this._expressionsManager=o(this._expressionsManager),this._expressionExecutorsInUse.clear()}_useExecutor(e){return this._expressionExecutorsInUse.add(e),e}_afterValueChange(e){const{name:t,value:n}=e,{_featureClone:s,formTemplate:i,layer:o}=this;if(!o)return;const r=s.getAttribute(t);s.setAttribute(t,n);const{typeFieldName:a,types:l}=S(o);if((e.isSubtypeField||t===a)&&n!==r){if("subtype-sublayer"===o.type){const e=o.parent?.findSublayerForFeature(s);e&&(this.feature&&(this.feature.sourceLayer=e),s.sourceLayer=e)}const e=new Set;for(const t of l)if(t.domains&&"object"==typeof t.domains)for(const n of Object.keys(t.domains))e.add(n);for(const t of e){const e=this.findField(t);e&&e.notifyChange("domain")}this.notifyChange("joinedContingentValues")}if(null!=i){const{description:e,title:n}=i;n&&h(n,t)&&this.notifyChange("formTitle"),e&&h(e,t)&&this.notifyChange("formDescription")}this._emitChangeEvent(e)}_afterExpressionsEvaluated(){const{_featureClone:e}=this;for(const t of this.allFieldInputs)t.value!==e.getAttribute(t.name)&&this._afterValueChange(t)}_joinContingentValues(){const e=this._contingentValuesCache;if(null==e)return[];const{typeFieldName:t}=S(this.layer),n=t?this.getValue(t):null,s=[];for(const r of e.fieldGroups){const{contingencies:e,fields:t,name:i}=r,o=[];for(const s of e)s.isRetired||null!=s.subtype&&s.subtype.code!==n||o.push({values:s.values});o.length>0&&s.push({name:i,fields:t,contingencies:o})}const[i,o]=this._generateJoinPlan(s);return[...i.flatMap((e=>this._joinFieldGroupContingencies(e))),...o.flatMap((e=>e.contingencies))]}_generateJoinPlan(e){const t=new Map,n=[],s=new Set;for(const l of e)for(const e of l.fields)if(t.has(e)){const i=t.get(e),o=l,r=[i.name,o.name].sort().join("|");if(s.has(r))continue;n.push([i,o]),s.add(r),t.set(e,o)}else t.set(e,l);const i=new Set(n.flat()),o=new Set(e);for(const l of i)o.delete(l);const r=new Map,a=new Map;for(const l of new Set(n.flat())){const e=Symbol(l.name);r.set(e,new Set([l])),a.set(l,e)}for(const[l,u]of n){const e=a.get(l),t=a.get(u);if(e===t)continue;const n=r.get(e),s=r.get(t);for(const i of s)n.add(i),a.set(i,e);r.delete(t)}return[[...r.values()].map((e=>[...e])),[...o]]}_joinFieldGroupContingencies(e){const t=e.slice(),n=t.shift();let s=t.shift(),i=this._generateJoinKey(n.fields,s.fields),o=new Set([...n.fields,...s.fields]),r=new Map;for(const l of n.contingencies){const[e]=this._hashContingency(l,i.codedValueFields,!0);r.has(e)?r.get(e)?.push(l):r.set(e,[l])}for(;t.length>0;){const e=new Map,n=t.shift(),a=this._generateJoinKey(o,n.fields);for(const t of s.contingencies){const[n,s]=this._hashContingency(t,i.codedValueFields),o=s?this._findMatchingContingenciesWithAnyHashMask(r,n):r.get(n);if(r.has(J)&&o?.push(...this._findMatchingContingenciesContainingAny(t,r.get(J),i.codedValueFields)),null!=o)for(const r of o){const n=i.rangeFields.length>0?this._joinContingenciesWithRangeDomains(r,t,i.rangeFields):this._joinContingencies(r,t);if(null==n)break;const[s]=this._hashContingency(n,a.codedValueFields,!0);e.has(s)?e.get(s)?.push(n):e.set(s,[n])}}r=e,s=n,i=a,o=new Set([...o,...s.fields])}const a=[];for(const l of s.contingencies){const[e,t]=this._hashContingency(l,i.codedValueFields),n=t?this._findMatchingContingenciesWithAnyHashMask(r,e):r.get(e);if(r.has(J)&&n.push(...this._findMatchingContingenciesContainingAny(l,r.get(J),i.codedValueFields)),null!=n)for(const s of n){const e=i.rangeFields.length>0?this._joinContingenciesWithRangeDomains(s,l,i.rangeFields):this._joinContingencies(s,l);null!=e&&a.push(e)}}return a}_joinContingencies(e,t){const n={values:{...e.values,...t.values}};for(const[s,i]of Object.entries(n.values))"any"===i.objectType&&null!=e.values[s]&&(n.values[s]=e.values[s]);return n}_joinContingenciesWithRangeDomains(e,t,n){const s=this._joinContingencies(e,t);for(const i of n){const n=e.values[i],o=t.values[i],{leftIsNull:r,rightIsNull:a,bothAreNull:l,leftIsAny:u,rightIsAny:p,bothAreAny:c,leftIsRange:h,rightIsRange:d}=this._compareObjectTypes(n.objectType,o.objectType);if(l||c)continue;if(r&&p||a&&u){s.values[i]=new E({objectType:"null"});continue}if(r&&d||a&&h)return null;u?(n.minValue=-1/0,n.maxValue=1/0):p&&(o.minValue=-1/0,o.maxValue=1/0);const f=Math.max(n.minValue,o.minValue),m=Math.min(n.maxValue,o.maxValue);if(f>m)return null;s.values[i]=new E({objectType:"range",minValue:f,maxValue:m})}return s}_findMatchingContingenciesContainingAny(e,t,n){return t.filter((t=>n.every((n=>{const s=t.values[n],i=e.values[n];return"any"===s.objectType||"any"===i.objectType||s.codedValue?.code===i.codedValue?.code}))))}_findMatchingContingenciesWithAnyHashMask(e,t){const n=RegExp(`${t}$`),s=[];for(const[i,o]of e){if(i===J)break;n.test(i)&&s.push(...o)}return s}_generateJoinKey(e,t){const n=Array.isArray(e)?new Set(e):e,s=Array.isArray(t)?new Set(t):t,i=n.size<s.size?n:s,o=i===n?s:n,{feature:r}=this,a=new Set,l=new Set;for(const u of i)if(o.has(u)){const e=this.layer?.getFieldDomain(u,{feature:r??void 0,excludeImpliedDomains:!0});if(null==e)continue;switch(e.type){case"coded-value":a.add(u);break;case"range":l.add(u)}}return{codedValueFields:[...a],rangeFields:[...l]}}_contingencyIsValid(e,t){const n={};for(const{name:s,value:i}of this.allFieldInputs)this.fieldsWithContingentValues.has(s)&&null!=i&&s!==e&&(n[s]=i);return Object.entries(n).every((([e,n])=>!t.values.hasOwnProperty(e)||U(n,t.values[e])))}_getContingentValueOptionsForField(e,t){const n=this.joinedContingentValues.slice(),s=new Map,i={code:"",name:t??"No value"};for(const o of n){const t=o.values[e];if("code"===t?.objectType||"null"===t?.objectType){const{code:n,name:r}=t.codedValue&&"null"!==t.objectType?t.codedValue:i;!s.has(n)&&this._contingencyIsValid(e,o)&&s.set(n,{name:r,value:n})}}return[...s.values()]}_hashContingency(e,t,n=!1){if(t.length<1)return[z,!1];const s=[];let i=!1;for(const o of t){const t=e.values[o];if("any"===t.objectType){if(n)return[J,!0];i=!0,s.push(`${o}:.*`)}else"null"===t.objectType?s.push(`${o}:${B}`):s.push(`${o}:${t.codedValue?.code}`)}return[s.sort().join("&"),i]}_compareObjectTypes(e,t){return{leftIsNull:"null"===e,rightIsNull:"null"===t,bothAreNull:"null"===e&&"null"===t,leftIsAny:"any"===e,rightIsAny:"any"===t,bothAreAny:"any"===e&&"any"===t,leftIsRange:"range"===e,rightIsRange:"range"===t}}get test(){return{featureClone:this._featureClone}}};function Q(e){return"field"===e.type||"group"===e.type||"relationship"===e.type||"text"===e.type||"utilityNetworkAssociations"===e.type||(Y().warn("form-info::unsupported-element-type","Only element types 'field', 'group' and 'relationship' are supported",`Element ${e.label} has unsupported type '${e.type}'`),!1)}function X(e,t){const{feature:n,layer:s}=t;return new P({element:e,inputs:[],feature:n,layer:s})}function ee(e,t,n=null){const{feature:s,layer:i,timeZone:o}=t;return new W({element:e,feature:s,group:n,layer:i,timeZone:o})}e([d()],q.prototype,"_expressionInfosLookup",null),e([d()],q.prototype,"_featureClone",void 0),e([d()],q.prototype,"_timeZone",void 0),e([d()],q.prototype,"activeAssociation",void 0),e([d()],q.prototype,"activeAssociationInput",null),e([d()],q.prototype,"activeRelationshipInput",null),e([d()],q.prototype,"_arcadeContextInfo",null),e([d()],q.prototype,"associationId",null),e([d()],q.prototype,"associatedLayer",null),e([d()],q.prototype,"allAssociationInputs",null),e([d()],q.prototype,"allFieldInputs",null),e([d()],q.prototype,"allGroupInputs",null),e([d()],q.prototype,"allRelationshipInputs",null),e([d()],q.prototype,"_layerFieldsByName",null),e([d()],q.prototype,"arcadeEditType",void 0),e([d()],q.prototype,"contingencyConstraintViolations",void 0),e([d()],q.prototype,"disabled",void 0),e([d()],q.prototype,"feature",null),e([d()],q.prototype,"fieldsWithContingentValues",null),e([d({type:y})],q.prototype,"formTemplate",null),e([d()],q.prototype,"formDescription",null),e([d()],q.prototype,"formTitle",null),e([d()],q.prototype,"formHeaderVisible",null),e([d()],q.prototype,"highlightHelper",void 0),e([d()],q.prototype,"inputs",void 0),e([d()],q.prototype,"joinedContingentValues",null),e([d()],q.prototype,"layer",null),e([d()],q.prototype,"map",void 0),e([d()],q.prototype,"callbacks",void 0),e([d()],q.prototype,"relationshipId",null),e([d()],q.prototype,"spatialReference",null),e([d()],q.prototype,"state",null),e([d()],q.prototype,"strict",void 0),e([d()],q.prototype,"submittable",null),e([d()],q.prototype,"timeZone",null),e([d()],q.prototype,"updating",null),e([d()],q.prototype,"valid",null),e([d()],q.prototype,"pendingSubtypeChoice",void 0),e([d()],q.prototype,"getValues",null),e([d()],q.prototype,"submit",null),e([d()],q.prototype,"test",null),q=e([f(K)],q);const te=q;export{te as default};