@arcgis/ai-components 5.1.0-next.6 → 5.1.0-next.8

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 (77) hide show
  1. package/dist/cdn/2S4DQWU7.js +2 -0
  2. package/dist/cdn/46Q4W2ZL.js +2 -0
  3. package/dist/cdn/{4Y73V2HU.js → AGZUEMOX.js} +1 -1
  4. package/dist/cdn/{UY4FI7AP.js → D6OOXTNF.js} +1 -1
  5. package/dist/cdn/I4LOCAOT.js +2 -0
  6. package/dist/cdn/JJPTDO6D.js +2 -0
  7. package/dist/cdn/JVR66VPL.js +3 -0
  8. package/dist/cdn/KDL663TG.js +2 -0
  9. package/dist/cdn/{2PLHSU7P.js → MN4FA32I.js} +65 -65
  10. package/dist/cdn/MYKSIL6I.js +2 -0
  11. package/dist/cdn/NSM3CLQ7.js +2 -0
  12. package/dist/cdn/OJUEJ4RT.js +2 -0
  13. package/dist/cdn/PQHYDFCL.js +2 -0
  14. package/dist/cdn/TISLVKGP.js +2 -0
  15. package/dist/cdn/TNI4DRHG.js +2 -0
  16. package/dist/cdn/{AIAY4NON.js → TTJBCQZA.js} +77 -68
  17. package/dist/cdn/{26V7SXDR.js → VG7GKLZR.js} +1 -1
  18. package/dist/cdn/{NKNUZCLA.js → W2A22QZU.js} +15 -0
  19. package/dist/cdn/WAO4LVNK.js +67 -0
  20. package/dist/cdn/WFEBJPQ4.js +2 -0
  21. package/dist/cdn/WTK5H7Z6.js +2 -0
  22. package/dist/cdn/ZGRFMSA2.js +2 -0
  23. package/dist/cdn/index.js +1 -1
  24. package/dist/cdn/main.css +1 -1
  25. package/dist/chunks/converterUtils.js +117 -0
  26. package/dist/chunks/utils.js +12 -14
  27. package/dist/chunks/utils2.js +3 -2
  28. package/dist/components/arcgis-assistant/customElement.d.ts +29 -11
  29. package/dist/components/arcgis-assistant/customElement.js +143 -125
  30. package/dist/components/arcgis-assistant/types.d.ts +29 -0
  31. package/dist/components/arcgis-assistant-chat/customElement.d.ts +8 -6
  32. package/dist/components/arcgis-assistant-chat/customElement.js +12 -12
  33. package/dist/components/arcgis-assistant-chat-card/customElement.d.ts +12 -5
  34. package/dist/components/arcgis-assistant-chat-card/customElement.js +59 -25
  35. package/dist/components/arcgis-assistant-chat-card/index.js +2 -0
  36. package/dist/components/arcgis-assistant-chat-card-content/customElement.js +14 -12
  37. package/dist/components/arcgis-assistant-chat-card-content/index.js +1 -0
  38. package/dist/components/arcgis-assistant-chat-entry/customElement.d.ts +5 -2
  39. package/dist/components/arcgis-assistant-chat-entry/customElement.js +42 -20
  40. package/dist/components/arcgis-assistant-data-exploration-agent/customElement.js +5 -5
  41. package/dist/components/arcgis-assistant-help-agent/customElement.d.ts +33 -0
  42. package/dist/components/arcgis-assistant-help-agent/customElement.js +26 -0
  43. package/dist/components/arcgis-assistant-help-agent/index.d.ts +1 -0
  44. package/dist/components/arcgis-assistant-help-agent/index.js +1 -0
  45. package/dist/components/arcgis-assistant-interrupt/customElement.d.ts +1 -1
  46. package/dist/components/arcgis-assistant-interrupt/customElement.js +8 -8
  47. package/dist/components/arcgis-assistant-layer-filter-agent/customElement.js +2 -2
  48. package/dist/components/arcgis-assistant-layer-query-agent/customElement.js +11 -11
  49. package/dist/components/arcgis-assistant-layer-styling-agent/customElement.js +6 -6
  50. package/dist/components/arcgis-assistant-navigation-agent/customElement.js +5 -5
  51. package/dist/components/arcgis-assistant-shell/customElement.d.ts +3 -0
  52. package/dist/components/arcgis-assistant-shell/customElement.js +12 -11
  53. package/dist/docs/api.json +1 -1
  54. package/dist/docs/docs.json +1 -1
  55. package/dist/docs/vscode.html-custom-data.json +1 -1
  56. package/dist/docs/web-types.json +1 -1
  57. package/dist/index.d.ts +16 -0
  58. package/dist/loader.js +8 -7
  59. package/dist/types/lumina.d.ts +19 -5
  60. package/dist/types/preact.d.ts +20 -5
  61. package/dist/types/react.d.ts +21 -5
  62. package/dist/types/stencil.d.ts +19 -5
  63. package/package.json +8 -6
  64. package/dist/cdn/GCFT45CD.js +0 -2
  65. package/dist/cdn/GN2HYJJX.js +0 -4
  66. package/dist/cdn/I22GHLAO.js +0 -2
  67. package/dist/cdn/IFSNQY7L.js +0 -2
  68. package/dist/cdn/IFWK7P7O.js +0 -2
  69. package/dist/cdn/J35M7O4J.js +0 -2
  70. package/dist/cdn/JABDBJPC.js +0 -2
  71. package/dist/cdn/KJZARHAM.js +0 -2
  72. package/dist/cdn/M672SFG6.js +0 -2
  73. package/dist/cdn/Q674OE2M.js +0 -2
  74. package/dist/cdn/VUHDKXFM.js +0 -2
  75. package/dist/cdn/XGVAPO3I.js +0 -2
  76. package/dist/cdn/XVUE27HC.js +0 -2
  77. package/dist/cdn/Y7UZYXEV.js +0 -2
@@ -1,27 +1,28 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import a from"./2PLHSU7P.js";export default $arcgis.t(([mt,he,De,ft,{addressToLocations:gt},Pe,V,Y,me,fe,Ge,Be,ge,Qe,{createRenderer:yt},{getSchemesByTag:pt,getSchemes:wt},{getBackgroundColorTheme:ke},{createAgeRenderer:bt,createContinuousRenderer:vt},{getSchemesByTag:ye},{createContinuousRenderer:St},{createRenderer:Tt},{getSchemesByTag:Et},{createRenderer:xt},{getSchemesByTag:It},{createRenderer:Lt},{getSchemesByTag:$t},{createRenderer:Ft},{getSchemesByTag:_t},{createAgeRenderer:Nt,createContinuousRenderer:kt},{createRenderer:qt},{getSchemesByTag:At},We,qe,Ae,P,{executeQueryStreaming:Rt},Mt,{a:xe,b:Ie,c:O,d:te,e:re,f:j,g:D,h:N,i:p,j:y,k:k,l:E,m:Le,n:U,o:J,p:$e,q:L,r:q,s:s,t:h,u:x,v:ae,w:Fe,x:z}])=>{var Ne=e=>Array.isArray(e)&&e.every(O),ct=e=>typeof e=="object"&&e!=null&&"messages"in e&&Ne(e.messages),dt=e=>typeof e=="object"&&e!=null&&"lg_tool_call"in e,A=class extends $e{tools;handleToolErrors=!0;trace=!1;constructor(e,r){let{name:t,tags:a,handleToolErrors:o}=r??{};super({name:t,tags:a,func:(i,n)=>this.run(i,n)}),this.tools=e,this.handleToolErrors=o??this.handleToolErrors}async runTool(e,r){let t=this.tools.find(a=>a.name===e.name);try{if(t===void 0)throw new Error(`Tool "${e.name}" not found.`);let a=await t.invoke({...e,type:"tool_call"},r);return O(a)&&a.getType()==="tool"||J(a)?a:new te({status:"success",name:t.name,content:typeof a=="string"?a:JSON.stringify(a),tool_call_id:e.id})}catch(a){if(!this.handleToolErrors||Ie(a))throw a;return new te({status:"error",content:`Error: ${a.message}
3
- Please fix your mistakes.`,name:e.name,tool_call_id:e.id??""})}}async run(e,r){let t;if(dt(e))t=[await this.runTool(e.lg_tool_call,r)];else{let i;if(Ne(e))i=e;else if(ct(e))i=e.messages;else throw new Error("ToolNode only accepts BaseMessage[] or { messages: BaseMessage[] } as input.");let n=new Set(i.filter(c=>c.getType()==="tool").map(c=>c.tool_call_id)),l;for(let c=i.length-1;c>=0;c-=1){let d=i[c];if(D(d)){l=d;break}}if(l==null||!D(l))throw new Error("ToolNode only accepts AIMessages as input.");t=await Promise.all(l.tool_calls?.filter(c=>c.id==null||!n.has(c.id)).map(c=>this.runTool(c,r))??[])}if(!t.some(J))return Array.isArray(e)?t:{messages:t};let a=[],o=null;for(let i of t)J(i)?i.graph===U.PARENT&&Array.isArray(i.goto)&&i.goto.every(n=>Le(n))?o?o.goto.push(...i.goto):o=new U({graph:U.PARENT,goto:i.goto}):a.push(i):a.push(Array.isArray(e)?[i]:{messages:[i]});return o&&a.push(o),a}};var as=y.Root({llmInputMessages:y({reducer:(e,r)=>L([],r),default:()=>[]})});var Ke=y.Root({messages:y({reducer:L,default:()=>[]}),outputMessage:y({reducer:(e="",r)=>{let t=typeof r=="string"?r.trim():"";if(!t)return e;let a=e.trim();if(!a)return t;if(a===t)return e;let o=a.split(`
2
+ import a from"./MN4FA32I.js";export default $arcgis.t(([gt,me,Pe,yt,{addressToLocations:pt},V,ie,Ge,O,Y,fe,ge,Be,Qe,ye,We,{createRenderer:wt},{getSchemesByTag:bt,getSchemes:vt},{getBackgroundColorTheme:qe},{createAgeRenderer:St,createContinuousRenderer:Tt},{getSchemesByTag:pe},{createContinuousRenderer:Et},{createRenderer:xt},{getSchemesByTag:It},{createRenderer:$t},{getSchemesByTag:Lt},{createRenderer:Ft},{getSchemesByTag:_t},{createRenderer:kt},{getSchemesByTag:Nt},{createAgeRenderer:qt,createContinuousRenderer:At},{createRenderer:Rt},{getSchemesByTag:Mt},Ke,Ae,Re,{executeQueryStreaming:zt},Ct,{a:Ie,b:$e,c:P,d:re,e:ae,f:z,g:G,h:A,i:p,j:y,k:F,l:E,m:Le,n:U,o:J,p:Fe,q:_,r:k,s:s,t:h,u:x,v:H,w:_e,x:C}])=>{var Ne=e=>Array.isArray(e)&&e.every(P),ut=e=>typeof e=="object"&&e!=null&&"messages"in e&&Ne(e.messages),ht=e=>typeof e=="object"&&e!=null&&"lg_tool_call"in e,R=class extends Fe{tools;handleToolErrors=!0;trace=!1;constructor(e,r){let{name:t,tags:a,handleToolErrors:o}=r??{};super({name:t,tags:a,func:(i,n)=>this.run(i,n)}),this.tools=e,this.handleToolErrors=o??this.handleToolErrors}async runTool(e,r){let t=this.tools.find(a=>a.name===e.name);try{if(t===void 0)throw new Error(`Tool "${e.name}" not found.`);let a=await t.invoke({...e,type:"tool_call"},r);return P(a)&&a.getType()==="tool"||J(a)?a:new re({status:"success",name:t.name,content:typeof a=="string"?a:JSON.stringify(a),tool_call_id:e.id})}catch(a){if(!this.handleToolErrors||$e(a))throw a;return new re({status:"error",content:`Error: ${a.message}
3
+ Please fix your mistakes.`,name:e.name,tool_call_id:e.id??""})}}async run(e,r){let t;if(ht(e))t=[await this.runTool(e.lg_tool_call,r)];else{let i;if(Ne(e))i=e;else if(ut(e))i=e.messages;else throw new Error("ToolNode only accepts BaseMessage[] or { messages: BaseMessage[] } as input.");let n=new Set(i.filter(d=>d.getType()==="tool").map(d=>d.tool_call_id)),l;for(let d=i.length-1;d>=0;d-=1){let c=i[d];if(G(c)){l=c;break}}if(l==null||!G(l))throw new Error("ToolNode only accepts AIMessages as input.");t=await Promise.all(l.tool_calls?.filter(d=>d.id==null||!n.has(d.id)).map(d=>this.runTool(d,r))??[])}if(!t.some(J))return Array.isArray(e)?t:{messages:t};let a=[],o=null;for(let i of t)J(i)?i.graph===U.PARENT&&Array.isArray(i.goto)&&i.goto.every(n=>Le(n))?o?o.goto.push(...i.goto):o=new U({graph:U.PARENT,goto:i.goto}):a.push(i):a.push(Array.isArray(e)?[i]:{messages:[i]});return o&&a.push(o),a}};var us=y.Root({llmInputMessages:y({reducer:(e,r)=>_([],r),default:()=>[]})});var Ue=y.Root({messages:y({reducer:_,default:()=>[]}),outputMessage:y({reducer:(e="",r)=>{let t=typeof r=="string"?r.trim():"";if(!t)return e;let a=e.trim();if(!a)return t;if(a===t)return e;let o=a.split(`
4
4
 
5
5
  `);return o[o.length-1]?.trim()===t?e:`${e}
6
6
 
7
- ${t}`},default:()=>""}),intent:y({reducer:(e,r)=>r}),vectorSearchLayerResults:y({reducer:(e,r)=>r,default:()=>[]}),vectorSearchFieldResults:y({reducer:(e,r)=>r})});async function zt(e,r){let t="https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer";console.log(`[goToAddress] Geocoding: ${e}`);let a=(await gt(t,{address:{SingleLine:e},outFields:["Match_addr"]}))?.[0];if(!a?.extent)throw new Error(`Could not find location for: ${e}`);let{xmin:o,ymin:i,xmax:n,ymax:l,spatialReference:c}=a.extent,d=new De({xmin:o,ymin:i,xmax:n,ymax:l,spatialReference:c}),u=(o+n)/2,m=(i+l)/2,f=new he({x:u,y:m,spatialReference:c}),g=new ft({style:"circle",color:"red",size:12}),w=new mt({geometry:f,symbol:g});return r.graphics.removeAll(),r.graphics.add(w),await r.goTo(d),`Successfully zoomed to: ${a.address}. Location coordinates: x=${u}, y=${m}, wkid=${c.wkid}`}var Ct=["mapView"];function $(e){let r=e?.configurable?.context;if(!r||typeof r!="object")throw new Error("NavigationAgent context missing");let t=Ct.filter(a=>!(a in r));if(t.length)throw new Error(`NavigationAgent context missing: ${t.join(", ")}`);return r}async function jt({address:e},r){let{mapView:t}=$(r);return await zt(e,t)}var Vt=s.object({address:s.string().describe("The full address or place name to locate.")}),Ot=p(jt,{name:"goToAddress",description:"Geocodes an address using Esri's World Geocoding Service and zooms the map to that location.",schema:Vt});async function Dt(e,r){let t=r.map.bookmarks;if(!t||t.length===0)throw new Error("No bookmarks found in the map.");let a=t.find(i=>i.name===e);if(!a)throw new Error(`Bookmark with name "${e}" not found.`);let o=a.viewpoint;if(!o)throw new Error(`Bookmark with name "${e}" does not have a valid viewpoint.`);return await r.goTo(o),`Navigated to bookmark: ${e}`}async function Pt({bookmarkName:e},r){let{mapView:t}=$(r);return await Promise.resolve(Dt(e,t))}var Gt=N.object({bookmarkName:N.string().describe("The name of the bookmark to navigate to.")}),Bt=p(Pt,{name:"goToBookmark",description:"Go to the extent of the bookmark with the given name.",schema:Gt});async function Qt(e,r,t){let a=t.map?.allLayers.find(i=>i.id===e);if(!a)return`Error: Layer with id ${e} not found`;let o=a.createQuery();o.where=r??"1=1";try{let{extent:i,count:n}=await a.queryExtent(o);if(n===0)return`No features found in ${a.title} matching: ${r}`;if(i)await t.goTo(i);else return`Error: Unable to determine extent for ${a.title}`;return`Successfully zoomed to ${n} feature(s) in ${a.title}`}catch(i){return console.error("Error in goToFeatures:",i),`Error: ${i instanceof Error?i.message:"Unknown error"}`}}async function Wt({layerId:e,where:r},t){let{mapView:a}=$(t);return await Qt(e,r,a)}var Kt=N.object({layerId:N.string().describe("The layerId of the layer to zoom to."),where:N.string().describe("The sql-92 where clause used to query features to zoom to")}),Ut=p(Wt,{name:"goToFeatures",description:"Go to the features that match the given filter related to the given layerId.",schema:Kt});async function Jt(e){let r=new De({xmin:-180,ymin:-90,xmax:180,ymax:90,spatialReference:{wkid:4326}}).expand(.7);return await e.goTo(r),"Successfully zoomed to world extent"}async function Zt(e,r){let{mapView:t}=$(r);return await Jt(t)}var Ht=N.object({}),Yt=p(Zt,{name:"goToFullExtent",description:"Zooms the map to the full world extent using Esri's Geocoding Service.",schema:Ht});async function Xt(e){let r=e.map.initialViewProperties?.viewpoint?.targetGeometry;if(r)await e.goTo(r);else throw new Error("Initial extent is undefined");return"Successfully zoomed to home extent"}async function er(e,r){let{mapView:t}=$(r);return await Xt(t)}var tr=s.object({}),rr=p(er,{name:"goToHomeExtent",description:"Go to the initial web map view extent",schema:tr});async function ar(e,r){await r.when();let t=r.map?.allLayers.find(o=>o.id===e);if(!t)return console.warn(`[goToLayer] No matching FeatureLayer found for: ${e}`),`Could not find layer for: ${e}`;console.log(`[goToLayer] Zooming to layer: ${t.title}`);let a;return(t.type==="link-chart"||t.type==="knowledge-graph-sublayer")&&r.map?.activeLinkChartLayer?a=r.map.diagramNodesExtent:a=t.fullExtent,a?(await r.goTo(a),t.visible=!0,`Successfully zoomed to: ${t.title??""}`):"Layer has no defined extent. Cannot zoom to layer."}async function or({layerId:e},r){let{mapView:t}=$(r);return await ar(e,t)}var ir=N.object({layerId:N.string().describe("The id of the layer to navigate to")}),nr=p(or,{name:"goToLayer",description:"Zooms the map view to the full extent of the top matching layer.",schema:ir});async function sr(e,r){return await r.goTo({scale:e}),`Successfully zoomed to: ${e}`}async function lr({scale:e},r){let{mapView:t}=$(r);return await sr(e,t)}var cr=s.object({scale:s.number().describe("The map scale of the view to go to.")}),dr=p(lr,{name:"goToScale",description:"Go to the specified view scale.",schema:cr});async function ur(e,r,t){let a={target:new he({longitude:e.longitude,latitude:e.latitude,spatialReference:{wkid:4326}})};return t?.zoom!==void 0&&(a.zoom=t.zoom),t?.scale!==void 0&&(a.scale=t.scale),await r.goTo(a),`Successfully navigated to: ${[`(${e.latitude}\xB0, ${e.longitude}\xB0)`,t?.zoom!==void 0?`zoom ${t.zoom}`:"",t?.scale!==void 0?`scale 1:${t.scale}`:""].filter(Boolean).join(", ")}`}async function hr({center:e,zoom:r,scale:t},a){let{mapView:o}=$(a);return await ur(e,o,{zoom:r,scale:t})}var mr=s.object({center:s.object({longitude:s.number().describe("The longitude (x-coordinate) of the point to navigate to."),latitude:s.number().describe("The latitude (y-coordinate) of the point to navigate to.")}),zoom:s.number().optional().describe("The zoom level. Higher values = more zoomed in."),scale:s.number().optional().describe("The map scale. Alternative to zoom. Smaller numbers = more zoomed in.")}),fr=p(hr,{name:"goToViewpoint",description:"Go to the specified viewpoint. This can contain a combination of scale, center, zoom, etc.",schema:mr});async function gr(e,r){return await r.goTo({zoom:e}),`Successfully zoomed to: ${e}`}async function yr({zoom:e},r){let{mapView:t}=$(r);return await gr(e,t)}var pr=s.object({zoom:s.number().min(1).max(20).describe("The zoom level of the view to go to.")}),wr=p(yr,{name:"goToZoom",description:'Go to the specified zoom level. If input is generic (e.g. "zoom in", then only zoom to the next appropriate level - increase level for zooming in and decrease for zooming out.).',schema:pr}),pe=[Ot,Bt,Ut,Yt,rr,nr,dr,fr,wr],Re=Object.assign({"../agents/arcgisKnowledge/prompts/arcgis_knowledge_current_lc_context.md":()=>import("./LSGRWCAO.js").then(e=>e.default),"../agents/arcgisKnowledge/prompts/arcgis_knowledge_intent_prompt.md":()=>import("./KKHKKCYH.js").then(e=>e.default),"../agents/arcgisKnowledge/prompts/arcgis_knowledge_tool_prompt.md":()=>import("./KQ6LEQHH.js").then(e=>e.default),"../agents/dataExploration/prompts/data_explore_filter_prompt.md":()=>import("./M7XUI5KY.js").then(e=>e.default),"../agents/dataExploration/prompts/data_explore_query_prompt.md":()=>import("./ZYQ6U2YH.js").then(e=>e.default),"../agents/dataExploration/prompts/summarize_query_response_prompt.md":()=>import("./SOWNHB7F.js").then(e=>e.default),"../agents/help/prompts/help_prompt.md":()=>import("./62K6RJZZ.js").then(e=>e.default),"../agents/layerFilter/prompts/layer_filter_prompt.md":()=>import("./X7WF7TCS.js").then(e=>e.default),"../agents/layerQuery/prompts/data_query_prompt.md":()=>import("./6T2EIYO4.js").then(e=>e.default),"../agents/layerQuery/prompts/summarize_query_response_prompt.md":()=>import("./HN2HMAMX.js").then(e=>e.default),"../agents/layerStyling/prompts/layer_styling_prompt.md":()=>import("./CFT5BBC6.js").then(e=>e.default),"../agents/navigation/prompts/navigation_intent_prompt.md":()=>import("./NKNUZCLA.js").then(e=>e.default),"../agents/navigation/prompts/navigation_tool_prompt.md":()=>import("./LTBEINKG.js").then(e=>e.default)});async function F(e){let r=Object.entries(Re).find(([t])=>t.endsWith(`/${e}.md`));if(console.log(`entry for prompt "${e}":`,r),!r)throw new Error(`Prompt not found: ${e}
7
+ ${t}`},default:()=>""}),intent:y({reducer:(e,r)=>r}),vectorSearchLayerResults:y({reducer:(e,r)=>r,default:()=>[]}),vectorSearchFieldResults:y({reducer:(e,r)=>r})});async function jt(e,r){let t=V.getDefault().helperServices.geocode.find(q=>q.name==="ArcGIS World Geocoding Service");if(!t)throw new Error("ArcGIS World Geocoding Service not found in helperServices.");let a=t.url,o=`${ie.assetsPath?.endsWith("/")?ie.assetsPath:`${ie.assetsPath}/`}esri/images/search/search-symbol-32.png`;console.log(`[goToAddress] Geocoding: ${e} using ${a}`);let i=(await pt(a,{address:{SingleLine:e},outFields:["Match_addr"]}))?.[0];if(!i?.extent)throw new Error(`Could not find location for: ${e}`);let{xmin:n,ymin:l,xmax:d,ymax:c,spatialReference:u}=i.extent,m=new Pe({xmin:n,ymin:l,xmax:d,ymax:c,spatialReference:u}),f=(n+d)/2,g=(l+c)/2,b=new me({x:f,y:g,spatialReference:u}),v=new yt({url:o,width:24,height:24}),S=new gt({geometry:b,symbol:v});return r.graphics.removeAll(),r.graphics.add(S),await r.goTo(m),`Successfully zoomed to: ${i.address}. Location coordinates: x=${f}, y=${g}, wkid=${u.wkid}`}var Vt=["mapView"];function I(e){let r=e?.configurable?.context;if(!r||typeof r!="object")throw new Error("NavigationAgent context missing");let t=Vt.filter(a=>!(a in r));if(t.length)throw new Error(`NavigationAgent context missing: ${t.join(", ")}`);return r}async function Ot({address:e},r){let{mapView:t}=I(r);return await jt(e,t)}var Dt=s.object({address:s.string().describe("The full address or place name to locate.")}),Pt=p(Ot,{name:"goToAddress",description:"Geocodes an address using Esri's World Geocoding Service and zooms the map to that location.",schema:Dt});async function Gt(e,r){let t=r.map.bookmarks;if(!t||t.length===0)throw new Error("No bookmarks found in the map.");let a=t.find(i=>i.name===e);if(!a)throw new Error(`Bookmark with name "${e}" not found.`);let o=a.viewpoint;if(!o)throw new Error(`Bookmark with name "${e}" does not have a valid viewpoint.`);return await r.goTo(o),`Navigated to bookmark: ${e}`}async function Bt({bookmarkName:e},r){let{mapView:t}=I(r);return await Promise.resolve(Gt(e,t))}var Qt=A.object({bookmarkName:A.string().describe("The name of the bookmark to navigate to.")}),Wt=p(Bt,{name:"goToBookmark",description:"Go to the extent of the bookmark with the given name.",schema:Qt});async function Kt(e,r,t){let a=t.map?.allLayers.find(i=>i.id===e);if(!a)return`Error: Layer with id ${e} not found`;let o=a.createQuery();o.where=r??"1=1";try{let{extent:i,count:n}=await a.queryExtent(o);if(n===0)return`No features found in ${a.title} matching: ${r}`;if(i)await t.goTo(i);else return`Error: Unable to determine extent for ${a.title}`;return`Successfully zoomed to ${n} feature(s) in ${a.title}`}catch(i){return console.error("Error in goToFeatures:",i),`Error: ${i instanceof Error?i.message:"Unknown error"}`}}async function Ut({layerId:e,where:r},t){let{mapView:a}=I(t);return await Kt(e,r,a)}var Jt=A.object({layerId:A.string().describe("The layerId of the layer to zoom to."),where:A.string().describe("The sql-92 where clause used to query features to zoom to")}),Ht=p(Ut,{name:"goToFeatures",description:"Go to the features that match the given filter related to the given layerId.",schema:Jt});async function Zt(e){let r=new Pe({xmin:-180,ymin:-90,xmax:180,ymax:90,spatialReference:{wkid:4326}}).expand(.7);return await e.goTo(r),"Successfully zoomed to world extent"}async function Xt(e,r){let{mapView:t}=I(r);return await Zt(t)}var Yt=A.object({}),er=p(Xt,{name:"goToFullExtent",description:"Zooms the map to the full world extent using Esri's Geocoding Service.",schema:Yt});async function tr(e){let r=e.map.initialViewProperties?.viewpoint?.targetGeometry;if(r)await e.goTo(r);else throw new Error("Initial extent is undefined");return"Successfully zoomed to home extent"}async function rr(e,r){let{mapView:t}=I(r);return await tr(t)}var ar=s.object({}),or=p(rr,{name:"goToHomeExtent",description:"Go to the initial web map view extent",schema:ar});async function ir(e,r){await r.when();let t=r.map?.allLayers.find(o=>o.id===e);if(!t)return console.warn(`[goToLayer] No matching FeatureLayer found for: ${e}`),`Could not find layer for: ${e}`;console.log(`[goToLayer] Zooming to layer: ${t.title}`);let a;return(t.type==="link-chart"||t.type==="knowledge-graph-sublayer")&&r.map?.activeLinkChartLayer?a=r.map.diagramNodesExtent:a=t.fullExtent,a?(await r.goTo(a),t.visible=!0,`Successfully zoomed to: ${t.title??""}`):"Layer has no defined extent. Cannot zoom to layer."}async function nr({layerId:e},r){let{mapView:t}=I(r);return await ir(e,t)}var sr=A.object({layerId:A.string().describe("The id of the layer to navigate to")}),lr=p(nr,{name:"goToLayer",description:"Zooms the map view to the full extent of the top matching layer.",schema:sr});async function cr(e,r){return await r.goTo({scale:e}),`Successfully zoomed to: ${e}`}async function dr({scale:e},r){let{mapView:t}=I(r);return await cr(e,t)}var ur=s.object({scale:s.number().describe("The map scale of the view to go to.")}),hr=p(dr,{name:"goToScale",description:"Go to the specified view scale.",schema:ur});async function mr(e,r,t){let a={target:new me({longitude:e.longitude,latitude:e.latitude,spatialReference:{wkid:4326}})};return t?.zoom!==void 0&&(a.zoom=t.zoom),t?.scale!==void 0&&(a.scale=t.scale),await r.goTo(a),`Successfully navigated to: ${[`(${e.latitude}\xB0, ${e.longitude}\xB0)`,t?.zoom!==void 0?`zoom ${t.zoom}`:"",t?.scale!==void 0?`scale 1:${t.scale}`:""].filter(Boolean).join(", ")}`}async function fr({center:e,zoom:r,scale:t},a){let{mapView:o}=I(a);return await mr(e,o,{zoom:r,scale:t})}var gr=s.object({center:s.object({longitude:s.number().describe("The longitude (x-coordinate) of the point to navigate to."),latitude:s.number().describe("The latitude (y-coordinate) of the point to navigate to.")}),zoom:s.number().optional().describe("The zoom level. Higher values = more zoomed in."),scale:s.number().optional().describe("The map scale. Alternative to zoom. Smaller numbers = more zoomed in.")}),yr=p(fr,{name:"goToViewpoint",description:"Go to the specified viewpoint. This can contain a combination of scale, center, zoom, etc.",schema:gr});async function pr(e,r){return await r.goTo({zoom:e}),`Successfully zoomed to: ${e}`}async function wr({zoom:e},r){let{mapView:t}=I(r);return await pr(e,t)}var br=s.object({zoom:s.number().min(1).max(20).describe("The zoom level of the view to go to.")}),vr=p(wr,{name:"goToZoom",description:'Go to the specified zoom level. If input is generic (e.g. "zoom in", then only zoom to the next appropriate level - increase level for zooming in and decrease for zooming out.).',schema:br}),we=[Pt,Wt,Ht,er,or,lr,hr,yr,vr],Me=Object.assign({"../agents/arcgisKnowledge/prompts/arcgis_knowledge_current_lc_context.md":()=>import("./LSGRWCAO.js").then(e=>e.default),"../agents/arcgisKnowledge/prompts/arcgis_knowledge_intent_prompt.md":()=>import("./KKHKKCYH.js").then(e=>e.default),"../agents/arcgisKnowledge/prompts/arcgis_knowledge_tool_prompt.md":()=>import("./KQ6LEQHH.js").then(e=>e.default),"../agents/dataExploration/prompts/data_explore_filter_prompt.md":()=>import("./M7XUI5KY.js").then(e=>e.default),"../agents/dataExploration/prompts/data_explore_query_prompt.md":()=>import("./ZYQ6U2YH.js").then(e=>e.default),"../agents/dataExploration/prompts/summarize_query_response_prompt.md":()=>import("./SOWNHB7F.js").then(e=>e.default),"../agents/help/prompts/help_prompt.md":()=>import("./62K6RJZZ.js").then(e=>e.default),"../agents/layerFilter/prompts/layer_filter_prompt.md":()=>import("./X7WF7TCS.js").then(e=>e.default),"../agents/layerQuery/prompts/data_query_prompt.md":()=>import("./6T2EIYO4.js").then(e=>e.default),"../agents/layerQuery/prompts/summarize_query_response_prompt.md":()=>import("./HN2HMAMX.js").then(e=>e.default),"../agents/layerStyling/prompts/layer_styling_prompt.md":()=>import("./CFT5BBC6.js").then(e=>e.default),"../agents/navigation/prompts/navigation_intent_prompt.md":()=>import("./W2A22QZU.js").then(e=>e.default),"../agents/navigation/prompts/navigation_tool_prompt.md":()=>import("./LTBEINKG.js").then(e=>e.default)});async function $(e){let r=Object.entries(Me).find(([t])=>t.endsWith(`/${e}.md`));if(console.log(`entry for prompt "${e}":`,r),!r)throw new Error(`Prompt not found: ${e}
8
8
  Available prompts:
9
- ${Object.keys(Re).join(`
10
- `)}`);return await r[1]()}var br=(e,r=3)=>e.filter(t=>t instanceof re).slice(-r),v=(e,r=3)=>{let t=e.map((o,i)=>o instanceof re?i:-1).filter(o=>o!==-1);if(t.length===0)return[];let a=t.length>r?t[t.length-r]:t[0];return e.slice(a)},_=(e,r=" ")=>br(e).map(t=>t.content).join(r).trim();async function vr(e,r){let t=await F("navigation_tool_prompt"),{mapView:a}=$(r),o=a.map,i=e.vectorSearchLayerResults?.length>0?e.vectorSearchLayerResults.map((w,S)=>`${S+1}. layerId=${w.id} | title=${w.title??""} | name=${w.name??""} | score=${w.score.toFixed(2)}`).join(`
9
+ ${Object.keys(Me).join(`
10
+ `)}`);return await r[1]()}var Sr=(e,r=3)=>e.filter(t=>t instanceof ae).slice(-r),T=(e,r=3)=>{let t=e.map((o,i)=>o instanceof ae?i:-1).filter(o=>o!==-1);if(t.length===0)return[];let a=t.length>r?t[t.length-r]:t[0];return e.slice(a)},N=(e,r=" ")=>Sr(e).map(t=>t.content).join(r).trim();async function Tr(e,r){let t=await $("navigation_tool_prompt"),{mapView:a}=I(r),o=a.map,i=e.vectorSearchLayerResults?.length>0?e.vectorSearchLayerResults.map((b,v)=>`${v+1}. layerId=${b.id} | title=${b.title??""} | name=${b.name??""} | score=${b.score.toFixed(2)}`).join(`
11
11
  `):"",n=e.vectorSearchFieldResults?.length>0?JSON.stringify(e.vectorSearchFieldResults,null,2):"",l=e.intent==="goToBookmark"&&o.bookmarks?.length?`Available bookmarks:
12
- ${JSON.stringify(o.bookmarks,null,2)}`:"",c=(e.intent==="goToLayer"||e.intent==="goToFeatures")&&e.vectorSearchLayerResults?.length?`Candidate layers:
13
- ${i}`:"",d=e.intent==="goToFeatures"&&e.vectorSearchFieldResults?.length?`Candidate fields:
14
- ${n}`:"",u={intent:e.intent,bookmarksSection:l,layersSection:c,fieldsSection:d,currentZoom:a.zoom},m=await z({promptText:t,messages:v(e.messages),inputVariables:u,tools:pe}),f=[...e.messages,m],g=(m.tool_calls?.length??0)>0?[...f]:[...f,m];return{...e,messages:g}}async function Sr(e,r){let t=await new A(pe).invoke({messages:v(e.messages)},r),a=t.messages.map(n=>n.text).join(`
12
+ ${JSON.stringify(o.bookmarks,null,2)}`:"",d=(e.intent==="goToLayer"||e.intent==="goToFeatures")&&e.vectorSearchLayerResults?.length?`Candidate layers:
13
+ ${i}`:"",c=e.intent==="goToFeatures"&&e.vectorSearchFieldResults?.length?`Candidate fields:
14
+ ${n}`:"",u={intent:e.intent,bookmarksSection:l,layersSection:d,fieldsSection:c,currentZoom:a.zoom},m=await C({promptText:t,messages:T(e.messages),inputVariables:u,tools:we}),f=[...e.messages,m],g=(m.tool_calls?.length??0)>0?[...f]:[...f,m];return{...e,messages:g}}async function Er(e,r){let t=await new R(we).invoke({messages:T(e.messages)},r),a=t.messages.map(n=>n.text).join(`
15
15
  `);await h({text:`Finished executing navigation tool: ${a}`},r);let o=[...e.messages,...t.messages],i=t.messages.map(n=>n.text).join(`
16
- `);return{...e,messages:o,outputMessage:i}}async function Tr(e){let r=await F("navigation_intent_prompt"),t={tools:pe.map(n=>({name:n.name,description:n.description,schema:n.schema})).map(({name:n,description:l,schema:c})=>`${n}: ${l}, ${JSON.stringify(c)}`).join(`
17
- `)},a=s.object({intent:s.string()}),o=await Fe({promptText:r,modelTier:"fast",messages:v(e.messages),inputVariables:t,schema:a}),i=typeof o.intent=="string"?o.intent.trim().replace(/^"|"$/gu,""):"";return{...e,intent:i||""}}var b=(e,r)=>{let t=e?.configurable?.services?.[r];if(t==null)throw new Error(`${r} missing in config.configurable.services`);return t},Er=.7,xr=async(e,r)=>{try{let t=_(e.messages);await h({text:`Similarity search to find layers: ${t}`},r);let a=b(r,"layerSearch"),o=b(r,"layersAndFieldsRegistry"),i=b(r,"embeddingCache"),n=(await a.searchLayers({text:t,minScore:Er,embeddingCache:i})).map(({id:c,score:d})=>{let u=o.get(c)?.layerItem;return{id:c,title:u?.title,name:u?.name??void 0,score:d}}),l;return n.length>0?l=`Vector search completed. Matching layers:
18
- ${n.map(c=>`- layerId=${c.id} | title=${c.title??""} | name=${c.name??""} | score=${c.score.toFixed(2)}`).join(`
19
- `)}`:l="Vector search completed. No matching layers found.",await h({text:l},r),{...e,vectorSearchLayerResults:n}}catch(t){throw await h({text:`Error during vector search layers: ${t instanceof Error?t.message:String(t)}`},r),t}},Me=.7,Ir=10,Lr=async(e,r)=>{try{let t=_(e.messages);await h({text:"Similarity search to find fields"},r);let a=b(r,"fieldSearch"),o=b(r,"layersAndFieldsRegistry"),i=b(r,"embeddingCache"),n=e.vectorSearchLayerResults?.map(d=>d.id)??[];if(n.length===0)return await h({text:"No candidate layers for field search"},r),e;let l=(await a.searchFields({text:t,layerIds:n,minScore:Me,topResults:Ir,embeddingCache:i})).map(({layerId:d,results:u})=>{let m=o.get(d)?.fieldRegistry;return{layerId:d,layerName:o.get(d)?.layerItem.name,results:u.map(f=>{let g=m?.get(f.name);return{name:f.name,score:f.score,type:g?.type,alias:g?.alias,description:g?.description,statistics:g?.statistics}})}}),c;return l.length>0?c=`Vector search completed. Matching layers and fields:
20
- ${l.map(d=>`${d.layerName??d.layerId}:
21
- ${d.results.map(u=>` - ${u.name} (${u.score.toFixed(2)})`).join(`
16
+ `);return{...e,messages:o,outputMessage:i}}async function xr(e,r){let t=await $("navigation_intent_prompt"),{mapView:a}=I(r),o=we.map(m=>({name:m.name,description:m.description,schema:m.schema})),i=a.map,n=i.bookmarks?.length?`Available bookmarks:
17
+ ${JSON.stringify(i.bookmarks,null,2)}`:"",l={tools:o.map(({name:m,description:f,schema:g})=>`${m}: ${f}, ${JSON.stringify(g)}`).join(`
18
+ `),bookmarks:n},d=s.object({intent:s.string()}),c=await _e({promptText:t,modelTier:"fast",messages:T(e.messages),inputVariables:l,schema:d}),u=typeof c.intent=="string"?c.intent.trim().replace(/^"|"$/gu,""):"";return{...e,intent:u||""}}var w=(e,r)=>{let t=e?.configurable?.services?.[r];if(t==null)throw new Error(`${r} missing in config.configurable.services`);return t},Ir=.7,$r=async(e,r)=>{try{let t=N(e.messages);await h({text:`Similarity search to find layers: ${t}`},r);let a=w(r,"layerSearch"),o=w(r,"layersAndFieldsRegistry"),i=w(r,"embeddingCache"),n=(await a.searchLayers({text:t,minScore:Ir,embeddingCache:i})).map(({id:d,score:c})=>{let u=o.get(d)?.layerItem;return{id:d,title:u?.title,name:u?.name??void 0,score:c}}),l;return n.length>0?l=`Vector search completed. Matching layers:
19
+ ${n.map(d=>`- layerId=${d.id} | title=${d.title??""} | name=${d.name??""} | score=${d.score.toFixed(2)}`).join(`
20
+ `)}`:l="Vector search completed. No matching layers found.",await h({text:l},r),{...e,vectorSearchLayerResults:n}}catch(t){throw await h({text:`Error during vector search layers: ${t instanceof Error?t.message:String(t)}`},r),t}},ze=.7,Lr=10,Fr=async(e,r)=>{try{let t=N(e.messages);await h({text:"Similarity search to find fields"},r);let a=w(r,"fieldSearch"),o=w(r,"layersAndFieldsRegistry"),i=w(r,"embeddingCache"),n=e.vectorSearchLayerResults?.map(c=>c.id)??[];if(n.length===0)return await h({text:"No candidate layers for field search"},r),e;let l=(await a.searchFields({text:t,layerIds:n,minScore:ze,topResults:Lr,embeddingCache:i})).map(({layerId:c,results:u})=>{let m=o.get(c)?.fieldRegistry;return{layerId:c,layerName:o.get(c)?.layerItem.name,results:u.map(f=>{let g=m?.get(f.name);return{name:f.name,score:f.score,type:g?.type,alias:g?.alias,description:g?.description,statistics:g?.statistics}})}}),d;return l.length>0?d=`Vector search completed. Matching layers and fields:
21
+ ${l.map(c=>`${c.layerName??c.layerId}:
22
+ ${c.results.map(u=>` - ${u.name} (${u.score.toFixed(2)})`).join(`
22
23
  `)}`).join(`
23
- `)}`:c=`No vector search field results found for score over ${Me}.`,await h({text:c},r),{...e,vectorSearchFieldResults:l}}catch(t){throw await h({text:`Error during vector search fields: ${t instanceof Error?t.message:String(t)}`},r),t}},B=(e,r)=>(t,a)=>{let o=a?.configurable?.services;for(let i of e)if(!o?.[i])throw new Error(`${r} requires services.${i} to be available.`);return t},$r=(e,r)=>B(["layerSearch","layersAndFieldsRegistry"],"Navigation Agent")(e,r),Fr=()=>new q(Ke).addNode("requireNavigationServices",$r).addNode("intentLLM",Tr).addNode("vectorSearchLayers",xr).addNode("vectorSearchFields",Lr).addNode("agent",vr).addNode("tools",Sr).addEdge(k,"requireNavigationServices").addEdge("requireNavigationServices","intentLLM").addConditionalEdges("intentLLM",e=>e.intent==="goToLayer"||e.intent==="goToFeatures"?"vectorSearchLayers":"agent",{vectorSearchLayers:"vectorSearchLayers",agent:"agent"}).addConditionalEdges("vectorSearchLayers",e=>e.intent==="goToFeatures"?"vectorSearchFields":"agent",{vectorSearchFields:"vectorSearchFields",agent:"agent"}).addEdge("vectorSearchFields","agent").addEdge("agent","tools").addEdge("tools",E),_r=String.raw`- **navigation** — Enables users to interact with the map by navigating to specific locations, layers, features, or extents.
24
- This includes zooming, panning, centering, or geocoding based on user input. The agent is designed to handle explicit map movement requests. NOTE: DO NOT call this agent if the user asks "where is... " or "show me...", that is meant to be handled by another agent.
24
+ `)}`:d=`No vector search field results found for score over ${ze}.`,await h({text:d},r),{...e,vectorSearchFieldResults:l}}catch(t){throw await h({text:`Error during vector search fields: ${t instanceof Error?t.message:String(t)}`},r),t}},D=(e,r)=>(t,a)=>{let o=a?.configurable?.services;for(let i of e)if(!o?.[i])throw new Error(`${r} requires services.${i} to be available.`);return t},_r=(e,r)=>D(["layerSearch","layersAndFieldsRegistry"],"Navigation Agent")(e,r),kr=()=>new k(Ue).addNode("requireNavigationServices",_r).addNode("intentLLM",xr).addNode("vectorSearchLayers",$r).addNode("vectorSearchFields",Fr).addNode("agent",Tr).addNode("tools",Er).addEdge(F,"requireNavigationServices").addEdge("requireNavigationServices","intentLLM").addConditionalEdges("intentLLM",e=>e.intent==="goToLayer"||e.intent==="goToFeatures"?"vectorSearchLayers":"agent",{vectorSearchLayers:"vectorSearchLayers",agent:"agent"}).addConditionalEdges("vectorSearchLayers",e=>e.intent==="goToFeatures"?"vectorSearchFields":"agent",{vectorSearchFields:"vectorSearchFields",agent:"agent"}).addEdge("vectorSearchFields","agent").addEdge("agent","tools").addEdge("tools",E),Nr=String.raw`- **navigation** — Enables users to interact with the map by navigating to specific locations, layers, features, or extents.
25
+ This includes zooming, panning, centering, or geocoding based on user input. The agent is designed to handle explicit map movement requests. NOTE: DO NOT call this agent if the user asks "show me...", that is meant to be handled by another agent. If the query is about where a certain address is, call this agent.
25
26
 
26
27
  Supported actions:
27
28
  - **Zooming**: Adjust the map's zoom level (e.g., "Zoom to level 10", "Zoom in").
@@ -39,19 +40,19 @@ ${d.results.map(u=>` - ${u.name} (${u.score.toFixed(2)})`).join(`
39
40
  _Example: “Center the map on San Francisco at scale 50000”_
40
41
  _Example: “Zoom to the features in the schools layer where city = 'Austin'”_
41
42
  _Example: “Go to the Downtown bookmark”_
42
- _Example: “Zoom to 1600 Pennsylvania Ave”_`,ol={id:"navigation",name:"Navigation Agent",description:_r,createGraph:Fr,workspace:Ke},Ue=y.Root({messages:y({reducer:L,default:()=>[]}),outputMessage:y({reducer:(e="",r)=>{let t=typeof r=="string"?r.trim():"";if(!t)return e;let a=e.trim();if(!a)return t;if(a===t)return e;let o=a.split(`
43
+ _Example: “Where is Mount Rainier?”_`,ml={id:"navigation",name:"Navigation Agent",description:Nr,createGraph:kr,workspace:Ue},Je=y.Root({messages:y({reducer:_,default:()=>[]}),outputMessage:y({reducer:(e="",r)=>{let t=typeof r=="string"?r.trim():"";if(!t)return e;let a=e.trim();if(!a)return t;if(a===t)return e;let o=a.split(`
43
44
 
44
45
  `);return o[o.length-1]?.trim()===t?e:`${e}
45
46
 
46
- ${t}`},default:()=>""}),vectorSearchLayerIds:y(),vectorSearchFieldResults:y(),layerFieldInfo:y(),queryResponse:y()}),Nr=async(e,r)=>(await h({text:"Exiting Data Exploration agent"},r),e),Q=async(e,r)=>{let t=e.tool_calls??[];if(t.length===0){await h({text:`LLM did not request any tool calls: ${String(e?.content)}`},r);return}await Promise.all(t.map(async a=>await h({text:`LLM requested tool call with arguments: ${JSON.stringify(a.args,null,2)}`},r))),console.log("LLM response:",JSON.stringify(e.tool_calls,null,2))};function ne(e){return"point"in e&&e.point!==void 0}function se(e){return"layerId"in e&&e.layerId!==void 0}var W=async(e,r)=>{if(ne(e)){let{point:t}=e;return{geometry:new he({x:t.x,y:t.y,spatialReference:t.spatialReference?{wkid:t.spatialReference.wkid}:r.spatialReference})}}if(se(e)){let t=r.map?.allLayers.find(a=>a.id===e.layerId);if(!t)return{error:`Could not find geometry layer with ID: ${e.layerId}`};try{let a=await t.queryFeatures({where:e.where,returnGeometry:!0,outSpatialReference:r.spatialReference});if(!a.features.length)return{error:`No features found in geometry layer with the specified where clause: ${e.where}`};let o;if(a.features.length===1){let i=a.features[0].geometry;if(!i)return{error:"The geometry of the first feature is undefined or null."};o=i}else{let i=a.features.map(l=>l.geometry),n=Y.executeMany(i);if(!n)return{error:"Failed to create a combined geometry."};o=n}return o.spatialReference||(o.spatialReference=r.spatialReference),{geometry:o}}catch(a){return{error:`Failed to query geometry: ${String(a)}`}}}return{error:"Invalid geometry configuration provided"}},Je=async(e,r,t)=>{let a=e.map?.allLayers.find(i=>i.id===r),o=a.createQuery();o.where=t??"1=1";try{let{extent:i,count:n}=await a.queryExtent(o);return!i||n===0?{success:!1,error:`No features found for where clause: ${t}`}:(await e.goTo(i),{success:!0})}catch(i){return{success:!1,error:i instanceof Error?i.message:String(i)}}},kr=async(e,r,t,a,o)=>{let i=r.map?.allLayers.find(d=>d.id===e.layerId);if(!i)return`Could not find target layer with ID: ${e.layerId}`;let n;if(o){let d=await W(o,r);if("error"in d)return d.error;n=d.geometry}i.featureEffect=null,i.featureEffect=new Pe({filter:new V({where:e.where,geometry:n,spatialRelationship:"intersects",distance:o?.distance,units:o?.units}),includedEffect:t,excludedEffect:a}),i.visible=!0;let l=await Je(r,o?o.layerId:e.layerId,o?o.where:e.where),c=i.title??e.layerId;return l.success?`Applied feature effects to target layer "${i.title??e.layerId}"${o?` using geometry from layer "${o.layerId}"`:""}.`:`Applied filter to "${c}" but no features matched. ${l.error}`},qr=["mapView"];function C(e){let r=e?.configurable?.context;if(!r||typeof r!="object")throw new Error("DataExplorationAgent context missing");let t=qr.filter(a=>!(a in r));if(t.length)throw new Error(`DataExplorationAgent context missing: ${t.join(", ")}`);return r}var Ar=["feet","kilometers","meters","miles","nautical-miles","us-nautical-miles"],R=s.enum(Ar),Rr=async({targetLayer:e,geometryLayer:r,includedEffect:t="drop-shadow(2px, 2px, 2px, gray)",excludedEffect:a="grayscale(100%) opacity(60%) blur(2px)"},o)=>{let{mapView:i}=C(o);return await kr(e,i,t,a,r)},Mr=s.object({targetLayer:s.object({layerId:s.string().describe("The layerId of the layer on which to set a feature effect."),where:s.string().describe("The SQL-92 where clause representing the features to emphasize.")}),geometryLayer:s.object({layerId:s.string().describe("The layerId of the layer containing the geometry by which to filter."),where:s.string().describe("The SQL-92 where clause representing the features from which to filter features from the targetLayer by geometry."),distance:s.number().describe("The distance by which to filter the input geometry."),units:R.describe("The units used to filter by geometry and distance.")}).optional().describe("Optional geometry-based filtering parameters for spatial queries."),includedEffect:s.string().optional().default("drop-shadow(2px, 2px, 2px, gray)").describe("The effect applied to features that meet the filter requirements. Valid effects include: bloom, blur, brightness, contrast, drop-shadow, grayscale, hue-rotate, invert, opacity, saturate, and sepia. Prefer default unless specified."),excludedEffect:s.string().optional().default("grayscale(100%) opacity(60%) blur(2px)").describe("The effect applied to features that do not meet the filter requirements. Valid effects include: bloom, blur, brightness, contrast, drop-shadow, grayscale, hue-rotate, invert, opacity, saturate, and sepia. Prefer default unless specified.")}),zr=p(Rr,{name:"setFeatureEffect",description:"Sets a feature effect on a given layer with given filter parameters and feature effects to emphasize certain features that meet a filter requirement. If no feature effect information is provided, then use the default effect provided.",schema:Mr}),Cr=async(e,r,t)=>{let a=r.map?.allLayers.find(c=>c.id===e.layerId);if(!a)return`Could not find target layer with ID: ${e.layerId}`;let o;if(t){let c=await W(t,r);if("error"in c)return c.error;o=c.geometry}let i=await r.whenLayerView(a);i.filter=null,i.filter=new V({where:e.where,geometry:o,spatialRelationship:"intersects",distance:t?.distance,units:t?.units}),a.visible=!0;let n=await Je(r,t?t.layerId:e.layerId,t?t.where:e.where),l=a.title??e.layerId;return n.success?`Applied feature filter to layer "${a.title??e.layerId}"${t?` using geometry from layer "${t.layerId}"`:""}.`:`Applied filter to "${l}" but no features matched. ${n.error}`},jr=async({targetLayer:e,geometryLayer:r},t)=>{let{mapView:a}=C(t);return await Cr(e,a,r)},Vr=s.object({targetLayer:s.object({layerId:s.string().describe("The layerId of the layer on which to set a filter."),where:s.string().describe("The SQL-92 where clause representing the features to display.")}),geometryLayer:s.object({layerId:s.string().describe("The layerId of the layer containing the geometry by which to filter."),where:s.string().describe("The SQL-92 where clause representing the features from which to filter features from the targetLayer by geometry."),distance:s.number().describe("The distance by which to filter the input geometry."),units:R.describe("The units used to filter by geometry and distance.")}).optional().describe("Optional geometry-based filtering parameters for spatial queries.")}),Or=p(jr,{name:"setFeatureFilter",description:"Sets a client-side filter using a where clause, geometry filter, or both on a target layer. This filters features at the client level in the view.",schema:Vr}),le=(e,r,t)=>{if(e&&typeof e!="function"){let a="getField"in t&&t.getField?.(e),o=a&&"getFieldDomain"in t&&t.getFieldDomain?t.getFieldDomain(a.name):null;if(o?.type==="coded-value"){let i=o.codedValues.find(n=>n.code===r);return i?i.name:null}}return null},Dr=(e,r,t)=>{let a=e.createQuery();return a.outFields=[r],a.where=t||"1=1",a.num=1,a},Pr=async(e,r,t,a)=>{let o=a.map?.allLayers.find(d=>d.id===e),i=Dr(o,r,t.where),n=(await o.queryFeatures(i)).features[0],l=n?n.attributes[r]:null,c=le(r,l,o)||l;return{tool:"getAttribute",layerName:o.title??e,summary:`${r} = ${c}`,details:{fieldName:r,value:c,where:t.where}}};async function Gr({layerId:e,fieldName:r,query:t},a){let{mapView:o}=C(a),i=await Pr(e,r,t,o);return JSON.stringify(i,null,2)}var Br=s.object({layerId:s.string().describe("The layerId of the layer containing the field from which to get a value."),fieldName:s.string().describe("The name of the field/attribute from which to get a field value."),query:s.object({where:s.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value.")})}),Qr=p(Gr,{name:"getAttribute",description:"Returns an attribute value for a given feature.",schema:Br}),we=(e,r)=>r?e.hasAllFeaturesInView:e.hasAllFeatures,Wr=async e=>{let{targetLayer:r,fieldName:t,statisticType:a,mapView:o,layersAndFieldsRegistry:i,geometryLayer:n}=e,l=o.map?.allLayers.find(T=>T.id===r.layerId);if(!l)throw new Error(`Layer '${r.layerId}' not found.`);let c=await o.whenLayerView(l),d=i.get(r.layerId)?.fieldRegistry.get(t);if(!d)throw new Error(`Field '${t}' not found.`);let u,m;if(n){let T=await W(n,o);if("error"in T)throw new Error(T.error);if(!T.geometry)throw new Error(`No features found matching: ${n.where}`);u={geometryLayerId:n.layerId,geometryWhere:n.where,distance:n.distance,units:n.units,applied:!0},m=new V({geometry:T.geometry,distance:n.distance,units:n.units,spatialRelationship:"intersects"})}let f=we(c,!1),g=null,w=null,S=10;if(d.type!=="geometry"&&d.type!=="oid"&&d.type!=="global-id")try{g=await me({layer:l,useFeaturesInView:f,view:f?o:void 0,field:t,sqlWhere:r.where,...m&&{filter:m},outStatisticTypes:{include:[a]}}),["string","small-integer","integer"].includes(d.type)&&(w=(await fe({layer:l,useFeaturesInView:f,view:f?o:void 0,field:t,sqlWhere:r.where,...m&&{filter:m}})).uniqueValueInfos.sort((T,M)=>M.count-T.count).slice(0,S))}catch(T){console.error("Statistics error:",T)}return{tool:"getStatistics",layerName:l.title??r.layerId,summary:`${a} = ${typeof g?.[a]=="number"?g[a]:"N/A"}`,details:{fieldName:t,statisticType:a,statistic:g?.[a]??null,summaryStatistics:g,uniqueValues:w,where:r.where,spatialFilterInfo:u}}};async function Kr({targetLayer:e,fieldName:r,statisticType:t,geometryLayer:a},o){let i=b(o,"layersAndFieldsRegistry"),{mapView:n}=C(o),l=await Wr({targetLayer:e,fieldName:r,statisticType:t,mapView:n,layersAndFieldsRegistry:i,geometryLayer:a});return JSON.stringify(l,null,2)}var Ur=s.object({targetLayer:s.object({layerId:s.string().describe("The layerId of the layer containing the field from which to get a value."),where:s.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value.")}),geometryLayer:s.union([s.object({layerId:s.string().describe("The layerId of the layer containing the geometry by which to filter."),where:s.string().describe("The SQL-92 where clause representing the features from which to filter features from the targetLayer by geometry."),distance:s.number().optional().describe("The distance by which to query from the input geometry."),units:R.optional().describe("The units used to query by geometry and distance.")}),s.object({}).strict()]).optional().describe("Optional geometry-based filtering parameters for spatial queries."),fieldName:s.string().describe("The name of the field for which to get statistics. STRICTLY DO NOT use OBJECTID. Use any other field"),statisticType:s.enum(["avg","max","median","min","stddev","sum","variance","nullcount","count"]).describe("The statistic type to calculate.")}),Jr=p(Kr,{name:"getStatistics",description:'Returns one or more summary statistics for the given field. Statistic types include: count, maximum, minimum, average, median, standard deviation, variance, mode, sum, nullcount (number of features without a value for a given field), unique values. For "most common/frequent" questions: Use statisticType "count" on a categorical field. The response includes uniqueValues sorted by frequency (most common first). Statistics can be returned for number, date, and string fields. Also returns frequency analysis for string fields - unique values sorted by occurrence count (most frequent first). Use this for "most common", "most frequent", or "how many of each" questions. Only call this tool when the question requires filtering (e.g. a WHERE clause or spatial constraint) that cannot be satisfied by precomputed stats.',schema:Ur}),Zr=async(e,r,t,a)=>{let o=t.map?.allLayers.find(u=>u.id===e.layerId),i=await t.whenLayerView(o),n=o.title??e.layerId,l;if(a){let u=await W(a,t);if("error"in u)return{tool:"getTopFeatures",layerName:n,summary:"Geometry lookup failed",details:{error:u.error}};if(!u.geometry)return{tool:"getTopFeatures",layerName:n,summary:"No features found for geometry filter",details:{error:`No features found matching: ${a.where}`}};l=u.geometry}let c=e.outFields.length>2?e.outFields:["*"],d=r.groupByFields&&r.groupByFields.length>0;try{let u;if(d){let f=new Ge({where:e.where||"1=1",outFields:c,orderByFields:e.orderByFields,geometry:l,spatialRelationship:l?"intersects":void 0,distance:a?.distance,units:a?.units,topFilter:new Be({topCount:r.topCount,groupByFields:r.groupByFields,orderByFields:r.orderByFields})});u=await o.queryTopFeatures(f)}else{let f=new ge({where:e.where||"1=1",outFields:c,orderByFields:r.orderByFields,num:r.topCount,geometry:l,spatialRelationship:l?"intersects":void 0,distance:a?.distance,units:a?.units,outSpatialReference:t.spatialReference}),g=we(i,!1);try{u=g?await i.queryFeatures(f):await o.queryFeatures(f)}catch(w){console.warn("Client-side query failed, falling back to server:",w),u=await o.queryFeatures(f)}}let m=u.features.map(f=>f.attributes);return{tool:"getTopFeatures",layerName:n,summary:`Top ${r.topCount} features extracted`,details:{topCount:r.topCount,attributes:m,where:e.where,orderByFields:r.orderByFields,...d&&{groupByFields:r.groupByFields}}}}catch(u){return{tool:"getTopFeatures",layerName:n,summary:"Query failed",details:{error:u instanceof Error?u.message:String(u)}}}},Hr=async({targetLayer:e,topFilter:r,geometryLayer:t},a)=>{let{mapView:o}=C(a),i=await Zr(e,r,o,t);return JSON.stringify(i,null,2)},Yr=s.object({targetLayer:s.object({layerId:s.string().describe("The layerId of the layer containing the field from which to get a value."),where:s.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value."),orderByFields:s.array(s.string().describe("The field(s) and order for which to sort the resulting features.")),outFields:s.array(s.string().describe('The fields to include in the output that will be presented to the user. This should include identifying information about the resulting features, like a name or id, along with the values desired in the output. If unsure, choose all fields ("*").').default("*"))}),geometryLayer:s.object({layerId:s.string().describe("The layerId of the layer containing the geometry by which to filter."),where:s.string().describe("The SQL-92 where clause representing the features from which to filter features from the targetLayer by geometry."),distance:s.number().optional().describe("The distance by which to query from the input geometry."),units:R.describe("The units used to query by geometry and distance.").optional()}).optional().describe("Optional geometry-based filtering parameters for spatial queries."),topFilter:s.object({topCount:s.number().describe("Number of top features to return per group."),orderByFields:s.array(s.string().describe("Field(s) to rank by with ASC/DESC. Must be existing field names, not aggregate functions.")),groupByFields:s.array(s.string().describe("Field(s) to group results by. Returns top N per group."))})}),Xr=p(Hr,{name:"getTopFeatures",description:'Returns top N features ranked by an existing field value. Use for "highest", "lowest", "top N" questions where ranking is based on a field that already exists in the data (e.g., population, value, date, depth). orderByFields must be actual field names with ASC/DESC. Do NOT use aggregate functions like COUNT(), SUM(), AVG() - those require getStatistics.',schema:Yr}),ie=25,ea=async(e,r,t,a)=>{let o=r.map?.allLayers.find(g=>g.id===e.layerId),i=await r.whenLayerView(o),n=o.title??e.layerId,l;if(t){let g=await W(t,r);if("error"in g){let w={error:g.error};return se(t)?(w.geometryLayerId=t.layerId,w.geometryWhere=t.where):ne(t)&&(w.point=t.point),{tool:"queryFeatures",layerName:n,summary:"Geometry lookup failed",details:w}}if(!g.geometry){let w={};return se(t)?(w.error=`No features found matching: ${t.where}`,w.geometryLayerId=t.layerId,w.geometryWhere=t.where):ne(t)&&(w.error="Failed to create point geometry",w.point=t.point),{tool:"queryFeatures",layerName:n,summary:"No features found for geometry filter",details:w}}l=g.geometry}else a&&(l=r.extent.clone());let c=we(i,a??!1),d=new ge({where:e.where||"1=1",outFields:e.outFields.length?e.outFields:["*"],orderByFields:e.orderByFields,...l&&{geometry:l,spatialRelationship:"intersects"},...t?.distance&&{distance:t.distance},...t?.units&&{units:t.units},outSpatialReference:r.spatialReference}),u,m;try{u=c?await i.queryFeatureCount(d):await o.queryFeatureCount(d),u>0&&u<=ie&&(m=c?await i.queryFeatures(d):await o.queryFeatures(d),m&&m.features.forEach(g=>{let w=g.attributes;o.fields.forEach(S=>{let T=w[S.name],M=le(S.name,T,o);M&&(w[S.name]=M)})}))}catch(g){console.warn("Client-side query failed, falling back to server:",g),u=await o.queryFeatureCount(d),u>0&&u<=ie&&(m=await o.queryFeatures(d),m&&m.features.forEach(w=>{o.fields.forEach(S=>{let T=w.attributes[S.name],M=le(S.name,T,o);M&&(w.attributes[S.name]=M)})}))}let f=m?.features.map(g=>g.attributes);return{tool:"queryFeatures",layerName:n,summary:`${u} features found`,details:{totalCount:u,where:e.where,...f&&{attributes:f},...u>ie&&{note:`${u} features found. Too many to list. Use filters to narrow results.`}}}};async function ta({targetLayer:e,geometryFilter:r,useCurrentExtent:t},a){let{mapView:o}=C(a),i=await ea(e,o,r,t);return JSON.stringify(i,null,2)}var ra=s.object({layerId:s.string().describe("The layerId of the layer containing the geometry by which to filter."),where:s.string().describe("The SQL-92 where clause representing the features from which to filter."),distance:s.number().optional().describe("The buffer distance around the geometry."),units:R.optional().describe("The units for the distance buffer.")}),aa=s.object({point:s.object({x:s.number().describe("X coordinate (longitude) from navigation result"),y:s.number().describe("Y coordinate (latitude) from navigation result"),spatialReference:s.object({wkid:s.number().describe("Spatial reference WKID (e.g., 4326 for WGS84)")}).optional().describe("Spatial reference. Defaults to map's spatial reference if not provided.")}).describe("Point coordinates from a previous navigation/geocoding result"),distance:s.number().optional().describe("Optional buffer distance around the point."),units:R.optional().describe("The units for the distance buffer.")}),oa=s.object({targetLayer:s.object({layerId:s.string().describe("The layerId of the layer containing the field from which to get a value."),where:s.string().describe("SQL-92 where clause. IMPORTANT: When using geometryFilter.point for point-in-polygon queries, set this to '1=1' to return all features that intersect the point. Only add attribute filters if the user specifically requests them in addition to the spatial query."),orderByFields:s.array(s.string().describe("The field(s) and order for which to sort the resulting features.")),outFields:s.array(s.string().describe('The fields to include in the output that will be presented to the user. This should include identifying information about the resulting features, like a name or id, along with the values desired in the output. If unsure, choose all fields ("*").').default("*"))}),geometryFilter:s.union([ra,aa]).optional().describe("Geometry filter for spatial queries. Use 'point' option with x/y coordinates from navigation results to find features at that location (point-in-polygon). Use 'layerId/where' option to filter by features from another layer."),useCurrentExtent:s.boolean().optional().describe("Set to true ONLY when user explicitly asks about features 'in my view', 'on my map', 'I am looking at'. Default is false (queries entire layer).")}),ia=p(ta,{name:"queryFeatures",description:"Queries features from a layer. Returns count and attributes (if \u226425 features). Use for listing features, finding features matching conditions, or spatial queries.",schema:oa}),Ze=[Qr,Jr,Xr,ia],He=[zr,Or],X=()=>{let e=new Date().getTimezoneOffset(),r=e<=0?"+":"-",t=Math.floor(Math.abs(e)/60).toString().padStart(2,"0"),a=(Math.abs(e)%60).toString().padStart(2,"0"),o=`${r}${t}:${a}`;return{userTimezone:Intl.DateTimeFormat().resolvedOptions().timeZone,userTimezoneOffset:o}},na=async(e,r)=>{await h({text:"Requesting LLM for layer filter results"},r);let t=await F("data_explore_filter_prompt");if(!r?.configurable)throw new Error("config.configurable is required for layer filter tools");let{userTimezone:a,userTimezoneOffset:o}=X(),i={layerFieldInfo:e.layerFieldInfo,userTimezone:a,userTimezoneOffset:o},n=await z({promptText:t,messages:v(e.messages),inputVariables:i,tools:He}),l=[...e.messages,n],c=(n.tool_calls?.length??0)>0?l:[...l,n],d=n.content.toString();return await Q(n,r),{...e,messages:c,outputMessage:d}},sa=async(e,r)=>{await h({text:"Requesting LLM for layer query results"},r);let t=await F("data_explore_query_prompt");if(!r?.configurable)throw new Error("config.configurable is required for layer query tools");let{userTimezone:a,userTimezoneOffset:o}=X(),i={layerFieldInfo:e.layerFieldInfo,userTimezone:a,userTimezoneOffset:o},n=await z({promptText:t,messages:v(e.messages),inputVariables:i,tools:Ze}),l=[...e.messages,n],c=n.content.toString();return await Q(n,r),{...e,messages:l,outputMessage:c}},la=async(e,r)=>{try{await h({text:"Requesting LLM for summary on query results"},r);let t=await F("summarize_query_response_prompt"),a={queryResponse:e.queryResponse},o=await ae({promptText:t,messages:v(e.messages),inputVariables:a}),i=typeof o=="string"?o:o.content,n=new j(i);return await h({text:`Received response from LLM: ${i}`},r),{...e,outputMessage:i,messages:[...e.messages,n]}}catch(t){throw await h({text:"Error during filter LLM request"},r),new Error(`Error during filter LLM request: ${t instanceof Error?t.message:String(t)}`)}};async function ca(e,r){let t=await new A(He).invoke({messages:v(e.messages)},r),a=[...e.messages,...t.messages],o=t.messages.map(l=>new j({content:l.content,additional_kwargs:l.additional_kwargs}));await h({text:`Finished executing layer filter tool: ${t.messages.map(l=>l.content).join(", ")}`},r);let i=[...a,...o],n=o.map(l=>l.content).join(`
47
+ ${t}`},default:()=>""}),vectorSearchLayerIds:y(),vectorSearchFieldResults:y(),layerFieldInfo:y(),queryResponse:y()}),qr=async(e,r)=>(await h({text:"Exiting Data Exploration agent"},r),e),Q=async(e,r)=>{let t=e.tool_calls??[];if(t.length===0){await h({text:`LLM did not request any tool calls: ${String(e?.content)}`},r);return}await Promise.all(t.map(async a=>await h({text:`LLM requested tool call with arguments: ${JSON.stringify(a.args,null,2)}`},r))),console.log("LLM response:",JSON.stringify(e.tool_calls,null,2))};function se(e){return"point"in e&&e.point!==void 0}function le(e){return"layerId"in e&&e.layerId!==void 0}var W=async(e,r)=>{if(se(e)){let{point:t}=e;return{geometry:new me({x:t.x,y:t.y,spatialReference:t.spatialReference?{wkid:t.spatialReference.wkid}:r.spatialReference})}}if(le(e)){let t=r.map?.allLayers.find(a=>a.id===e.layerId);if(!t)return{error:`Could not find geometry layer with ID: ${e.layerId}`};try{let a=await t.queryFeatures({where:e.where,returnGeometry:!0,outSpatialReference:r.spatialReference});if(!a.features.length)return{error:`No features found in geometry layer with the specified where clause: ${e.where}`};let o;if(a.features.length===1){let i=a.features[0].geometry;if(!i)return{error:"The geometry of the first feature is undefined or null."};o=i}else{let i=a.features.map(l=>l.geometry),n=Y.executeMany(i);if(!n)return{error:"Failed to create a combined geometry."};o=n}return o.spatialReference||(o.spatialReference=r.spatialReference),{geometry:o}}catch(a){return{error:`Failed to query geometry: ${String(a)}`}}}return{error:"Invalid geometry configuration provided"}},He=async(e,r,t)=>{let a=e.map?.allLayers.find(i=>i.id===r),o=a.createQuery();o.where=t??"1=1";try{let{extent:i,count:n}=await a.queryExtent(o);return!i||n===0?{success:!1,error:`No features found for where clause: ${t}`}:(await e.goTo(i),{success:!0})}catch(i){return{success:!1,error:i instanceof Error?i.message:String(i)}}},Ar=async(e,r,t,a,o)=>{let i=r.map?.allLayers.find(c=>c.id===e.layerId);if(!i)return`Could not find target layer with ID: ${e.layerId}`;let n;if(o){let c=await W(o,r);if("error"in c)return c.error;n=c.geometry}i.featureEffect=null,i.featureEffect=new Ge({filter:new O({where:e.where,geometry:n,spatialRelationship:"intersects",distance:o?.distance,units:o?.units}),includedEffect:t,excludedEffect:a}),i.visible=!0;let l=await He(r,o?o.layerId:e.layerId,o?o.where:e.where),d=i.title??e.layerId;return l.success?`Applied feature effects to target layer "${i.title??e.layerId}"${o?` using geometry from layer "${o.layerId}"`:""}.`:`Applied filter to "${d}" but no features matched. ${l.error}`},Rr=["mapView"];function j(e){let r=e?.configurable?.context;if(!r||typeof r!="object")throw new Error("DataExplorationAgent context missing");let t=Rr.filter(a=>!(a in r));if(t.length)throw new Error(`DataExplorationAgent context missing: ${t.join(", ")}`);return r}var Mr=["feet","kilometers","meters","miles","nautical-miles","us-nautical-miles"],M=s.enum(Mr),zr=async({targetLayer:e,geometryLayer:r,includedEffect:t="drop-shadow(2px, 2px, 2px, gray)",excludedEffect:a="grayscale(100%) opacity(60%) blur(2px)"},o)=>{let{mapView:i}=j(o);return await Ar(e,i,t,a,r)},Cr=s.object({targetLayer:s.object({layerId:s.string().describe("The layerId of the layer on which to set a feature effect."),where:s.string().describe("The SQL-92 where clause representing the features to emphasize.")}),geometryLayer:s.object({layerId:s.string().describe("The layerId of the layer containing the geometry by which to filter."),where:s.string().describe("The SQL-92 where clause representing the features from which to filter features from the targetLayer by geometry."),distance:s.number().describe("The distance by which to filter the input geometry."),units:M.describe("The units used to filter by geometry and distance.")}).optional().describe("Optional geometry-based filtering parameters for spatial queries."),includedEffect:s.string().optional().default("drop-shadow(2px, 2px, 2px, gray)").describe("The effect applied to features that meet the filter requirements. Valid effects include: bloom, blur, brightness, contrast, drop-shadow, grayscale, hue-rotate, invert, opacity, saturate, and sepia. Prefer default unless specified."),excludedEffect:s.string().optional().default("grayscale(100%) opacity(60%) blur(2px)").describe("The effect applied to features that do not meet the filter requirements. Valid effects include: bloom, blur, brightness, contrast, drop-shadow, grayscale, hue-rotate, invert, opacity, saturate, and sepia. Prefer default unless specified.")}),jr=p(zr,{name:"setFeatureEffect",description:"Sets a feature effect on a given layer with given filter parameters and feature effects to emphasize certain features that meet a filter requirement. If no feature effect information is provided, then use the default effect provided.",schema:Cr}),Vr=async(e,r,t)=>{let a=r.map?.allLayers.find(d=>d.id===e.layerId);if(!a)return`Could not find target layer with ID: ${e.layerId}`;let o;if(t){let d=await W(t,r);if("error"in d)return d.error;o=d.geometry}let i=await r.whenLayerView(a);i.filter=null,i.filter=new O({where:e.where,geometry:o,spatialRelationship:"intersects",distance:t?.distance,units:t?.units}),a.visible=!0;let n=await He(r,t?t.layerId:e.layerId,t?t.where:e.where),l=a.title??e.layerId;return n.success?`Applied feature filter to layer "${a.title??e.layerId}"${t?` using geometry from layer "${t.layerId}"`:""}.`:`Applied filter to "${l}" but no features matched. ${n.error}`},Or=async({targetLayer:e,geometryLayer:r},t)=>{let{mapView:a}=j(t);return await Vr(e,a,r)},Dr=s.object({targetLayer:s.object({layerId:s.string().describe("The layerId of the layer on which to set a filter."),where:s.string().describe("The SQL-92 where clause representing the features to display.")}),geometryLayer:s.object({layerId:s.string().describe("The layerId of the layer containing the geometry by which to filter."),where:s.string().describe("The SQL-92 where clause representing the features from which to filter features from the targetLayer by geometry."),distance:s.number().describe("The distance by which to filter the input geometry."),units:M.describe("The units used to filter by geometry and distance.")}).optional().describe("Optional geometry-based filtering parameters for spatial queries.")}),Pr=p(Or,{name:"setFeatureFilter",description:"Sets a client-side filter using a where clause, geometry filter, or both on a target layer. This filters features at the client level in the view.",schema:Dr}),ce=(e,r,t)=>{if(e&&typeof e!="function"){let a="getField"in t&&t.getField?.(e),o=a&&"getFieldDomain"in t&&t.getFieldDomain?t.getFieldDomain(a.name):null;if(o?.type==="coded-value"){let i=o.codedValues.find(n=>n.code===r);return i?i.name:null}}return null},Gr=(e,r,t)=>{let a=e.createQuery();return a.outFields=[r],a.where=t||"1=1",a.num=1,a},Br=async(e,r,t,a)=>{let o=a.map?.allLayers.find(c=>c.id===e),i=Gr(o,r,t.where),n=(await o.queryFeatures(i)).features[0],l=n?n.attributes[r]:null,d=ce(r,l,o)||l;return{tool:"getAttribute",layerName:o.title??e,summary:`${r} = ${d}`,details:{fieldName:r,value:d,where:t.where}}};async function Qr({layerId:e,fieldName:r,query:t},a){let{mapView:o}=j(a),i=await Br(e,r,t,o);return JSON.stringify(i,null,2)}var Wr=s.object({layerId:s.string().describe("The layerId of the layer containing the field from which to get a value."),fieldName:s.string().describe("The name of the field/attribute from which to get a field value."),query:s.object({where:s.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value.")})}),Kr=p(Qr,{name:"getAttribute",description:"Returns an attribute value for a given feature.",schema:Wr}),be=(e,r)=>r?e.hasAllFeaturesInView:e.hasAllFeatures,Ur=async e=>{let{targetLayer:r,fieldName:t,statisticType:a,mapView:o,layersAndFieldsRegistry:i,geometryLayer:n}=e,l=o.map?.allLayers.find(S=>S.id===r.layerId);if(!l)throw new Error(`Layer '${r.layerId}' not found.`);let d=await o.whenLayerView(l),c=i.get(r.layerId)?.fieldRegistry.get(t);if(!c)throw new Error(`Field '${t}' not found.`);let u,m;if(n){let S=await W(n,o);if("error"in S)throw new Error(S.error);if(!S.geometry)throw new Error(`No features found matching: ${n.where}`);u={geometryLayerId:n.layerId,geometryWhere:n.where,distance:n.distance,units:n.units,applied:!0},m=new O({geometry:S.geometry,distance:n.distance,units:n.units,spatialRelationship:"intersects"})}let f=be(d,!1),g=null,b=null,v=10;if(c.type!=="geometry"&&c.type!=="oid"&&c.type!=="global-id")try{g=await fe({layer:l,useFeaturesInView:f,view:f?o:void 0,field:t,sqlWhere:r.where,...m&&{filter:m},outStatisticTypes:{include:[a]}}),["string","small-integer","integer"].includes(c.type)&&(b=(await ge({layer:l,useFeaturesInView:f,view:f?o:void 0,field:t,sqlWhere:r.where,...m&&{filter:m}})).uniqueValueInfos.sort((S,q)=>q.count-S.count).slice(0,v))}catch(S){console.error("Statistics error:",S)}return{tool:"getStatistics",layerName:l.title??r.layerId,summary:`${a} = ${typeof g?.[a]=="number"?g[a]:"N/A"}`,details:{fieldName:t,statisticType:a,statistic:g?.[a]??null,summaryStatistics:g,uniqueValues:b,where:r.where,spatialFilterInfo:u}}};async function Jr({targetLayer:e,fieldName:r,statisticType:t,geometryLayer:a},o){let i=w(o,"layersAndFieldsRegistry"),{mapView:n}=j(o),l=await Ur({targetLayer:e,fieldName:r,statisticType:t,mapView:n,layersAndFieldsRegistry:i,geometryLayer:a});return JSON.stringify(l,null,2)}var Hr=s.object({targetLayer:s.object({layerId:s.string().describe("The layerId of the layer containing the field from which to get a value."),where:s.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value.")}),geometryLayer:s.union([s.object({layerId:s.string().describe("The layerId of the layer containing the geometry by which to filter."),where:s.string().describe("The SQL-92 where clause representing the features from which to filter features from the targetLayer by geometry."),distance:s.number().optional().describe("The distance by which to query from the input geometry."),units:M.optional().describe("The units used to query by geometry and distance.")}),s.object({}).strict()]).optional().describe("Optional geometry-based filtering parameters for spatial queries."),fieldName:s.string().describe("The name of the field for which to get statistics. STRICTLY DO NOT use OBJECTID. Use any other field"),statisticType:s.enum(["avg","max","median","min","stddev","sum","variance","nullcount","count"]).describe("The statistic type to calculate.")}),Zr=p(Jr,{name:"getStatistics",description:'Returns one or more summary statistics for the given field. Statistic types include: count, maximum, minimum, average, median, standard deviation, variance, mode, sum, nullcount (number of features without a value for a given field), unique values. For "most common/frequent" questions: Use statisticType "count" on a categorical field. The response includes uniqueValues sorted by frequency (most common first). Statistics can be returned for number, date, and string fields. Also returns frequency analysis for string fields - unique values sorted by occurrence count (most frequent first). Use this for "most common", "most frequent", or "how many of each" questions. Only call this tool when the question requires filtering (e.g. a WHERE clause or spatial constraint) that cannot be satisfied by precomputed stats.',schema:Hr}),Xr=async(e,r,t,a)=>{let o=t.map?.allLayers.find(u=>u.id===e.layerId),i=await t.whenLayerView(o),n=o.title??e.layerId,l;if(a){let u=await W(a,t);if("error"in u)return{tool:"getTopFeatures",layerName:n,summary:"Geometry lookup failed",details:{error:u.error}};if(!u.geometry)return{tool:"getTopFeatures",layerName:n,summary:"No features found for geometry filter",details:{error:`No features found matching: ${a.where}`}};l=u.geometry}let d=e.outFields.length>2?e.outFields:["*"],c=r.groupByFields&&r.groupByFields.length>0;try{let u;if(c){let f=new Be({where:e.where||"1=1",outFields:d,orderByFields:e.orderByFields,geometry:l,spatialRelationship:l?"intersects":void 0,distance:a?.distance,units:a?.units,topFilter:new Qe({topCount:r.topCount,groupByFields:r.groupByFields,orderByFields:r.orderByFields})});u=await o.queryTopFeatures(f)}else{let f=new ye({where:e.where||"1=1",outFields:d,orderByFields:r.orderByFields,num:r.topCount,geometry:l,spatialRelationship:l?"intersects":void 0,distance:a?.distance,units:a?.units,outSpatialReference:t.spatialReference}),g=be(i,!1);try{u=g?await i.queryFeatures(f):await o.queryFeatures(f)}catch(b){console.warn("Client-side query failed, falling back to server:",b),u=await o.queryFeatures(f)}}let m=u.features.map(f=>f.attributes);return{tool:"getTopFeatures",layerName:n,summary:`Top ${r.topCount} features extracted`,details:{topCount:r.topCount,attributes:m,where:e.where,orderByFields:r.orderByFields,...c&&{groupByFields:r.groupByFields}}}}catch(u){return{tool:"getTopFeatures",layerName:n,summary:"Query failed",details:{error:u instanceof Error?u.message:String(u)}}}},Yr=async({targetLayer:e,topFilter:r,geometryLayer:t},a)=>{let{mapView:o}=j(a),i=await Xr(e,r,o,t);return JSON.stringify(i,null,2)},ea=s.object({targetLayer:s.object({layerId:s.string().describe("The layerId of the layer containing the field from which to get a value."),where:s.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value."),orderByFields:s.array(s.string().describe("The field(s) and order for which to sort the resulting features.")),outFields:s.array(s.string().describe('The fields to include in the output that will be presented to the user. This should include identifying information about the resulting features, like a name or id, along with the values desired in the output. If unsure, choose all fields ("*").').default("*"))}),geometryLayer:s.object({layerId:s.string().describe("The layerId of the layer containing the geometry by which to filter."),where:s.string().describe("The SQL-92 where clause representing the features from which to filter features from the targetLayer by geometry."),distance:s.number().optional().describe("The distance by which to query from the input geometry."),units:M.describe("The units used to query by geometry and distance.").optional()}).optional().describe("Optional geometry-based filtering parameters for spatial queries."),topFilter:s.object({topCount:s.number().describe("Number of top features to return per group."),orderByFields:s.array(s.string().describe("Field(s) to rank by with ASC/DESC. Must be existing field names, not aggregate functions.")),groupByFields:s.array(s.string().describe("Field(s) to group results by. Returns top N per group."))})}),ta=p(Yr,{name:"getTopFeatures",description:'Returns top N features ranked by an existing field value. Use for "highest", "lowest", "top N" questions where ranking is based on a field that already exists in the data (e.g., population, value, date, depth). orderByFields must be actual field names with ASC/DESC. Do NOT use aggregate functions like COUNT(), SUM(), AVG() - those require getStatistics.',schema:ea}),ne=25,ra=async(e,r,t,a)=>{let o=r.map?.allLayers.find(g=>g.id===e.layerId),i=await r.whenLayerView(o),n=o.title??e.layerId,l;if(t){let g=await W(t,r);if("error"in g){let b={error:g.error};return le(t)?(b.geometryLayerId=t.layerId,b.geometryWhere=t.where):se(t)&&(b.point=t.point),{tool:"queryFeatures",layerName:n,summary:"Geometry lookup failed",details:b}}if(!g.geometry){let b={};return le(t)?(b.error=`No features found matching: ${t.where}`,b.geometryLayerId=t.layerId,b.geometryWhere=t.where):se(t)&&(b.error="Failed to create point geometry",b.point=t.point),{tool:"queryFeatures",layerName:n,summary:"No features found for geometry filter",details:b}}l=g.geometry}else a&&(l=r.extent.clone());let d=be(i,a??!1),c=new ye({where:e.where||"1=1",outFields:e.outFields.length?e.outFields:["*"],orderByFields:e.orderByFields,...l&&{geometry:l,spatialRelationship:"intersects"},...t?.distance&&{distance:t.distance},...t?.units&&{units:t.units},outSpatialReference:r.spatialReference}),u,m;try{u=d?await i.queryFeatureCount(c):await o.queryFeatureCount(c),u>0&&u<=ne&&(m=d?await i.queryFeatures(c):await o.queryFeatures(c),m&&m.features.forEach(g=>{let b=g.attributes;o.fields.forEach(v=>{let S=b[v.name],q=ce(v.name,S,o);q&&(b[v.name]=q)})}))}catch(g){console.warn("Client-side query failed, falling back to server:",g),u=await o.queryFeatureCount(c),u>0&&u<=ne&&(m=await o.queryFeatures(c),m&&m.features.forEach(b=>{o.fields.forEach(v=>{let S=b.attributes[v.name],q=ce(v.name,S,o);q&&(b.attributes[v.name]=q)})}))}let f=m?.features.map(g=>g.attributes);return{tool:"queryFeatures",layerName:n,summary:`${u} features found`,details:{totalCount:u,where:e.where,...f&&{attributes:f},...u>ne&&{note:`${u} features found. Too many to list. Use filters to narrow results.`}}}};async function aa({targetLayer:e,geometryFilter:r,useCurrentExtent:t},a){let{mapView:o}=j(a),i=await ra(e,o,r,t);return JSON.stringify(i,null,2)}var oa=s.object({layerId:s.string().describe("The layerId of the layer containing the geometry by which to filter."),where:s.string().describe("The SQL-92 where clause representing the features from which to filter."),distance:s.number().optional().describe("The buffer distance around the geometry."),units:M.optional().describe("The units for the distance buffer.")}),ia=s.object({point:s.object({x:s.number().describe("X coordinate (longitude) from navigation result"),y:s.number().describe("Y coordinate (latitude) from navigation result"),spatialReference:s.object({wkid:s.number().describe("Spatial reference WKID (e.g., 4326 for WGS84)")}).optional().describe("Spatial reference. Defaults to map's spatial reference if not provided.")}).describe("Point coordinates from a previous navigation/geocoding result"),distance:s.number().optional().describe("Optional buffer distance around the point."),units:M.optional().describe("The units for the distance buffer.")}),na=s.object({targetLayer:s.object({layerId:s.string().describe("The layerId of the layer containing the field from which to get a value."),where:s.string().describe("SQL-92 where clause. IMPORTANT: When using geometryFilter.point for point-in-polygon queries, set this to '1=1' to return all features that intersect the point. Only add attribute filters if the user specifically requests them in addition to the spatial query."),orderByFields:s.array(s.string().describe("The field(s) and order for which to sort the resulting features.")),outFields:s.array(s.string().describe('The fields to include in the output that will be presented to the user. This should include identifying information about the resulting features, like a name or id, along with the values desired in the output. If unsure, choose all fields ("*").').default("*"))}),geometryFilter:s.union([oa,ia]).optional().describe("Geometry filter for spatial queries. Use 'point' option with x/y coordinates from navigation results to find features at that location (point-in-polygon). Use 'layerId/where' option to filter by features from another layer."),useCurrentExtent:s.boolean().optional().describe("Set to true ONLY when user explicitly asks about features 'in my view', 'on my map', 'I am looking at'. Default is false (queries entire layer).")}),sa=p(aa,{name:"queryFeatures",description:"Queries features from a layer. Returns count and attributes (if \u226425 features). Use for listing features, finding features matching conditions, or spatial queries.",schema:na}),Ze=[Kr,Zr,ta,sa],Xe=[jr,Pr],ee=()=>{let e=new Date().getTimezoneOffset(),r=e<=0?"+":"-",t=Math.floor(Math.abs(e)/60).toString().padStart(2,"0"),a=(Math.abs(e)%60).toString().padStart(2,"0"),o=`${r}${t}:${a}`;return{userTimezone:Intl.DateTimeFormat().resolvedOptions().timeZone,userTimezoneOffset:o}},la=async(e,r)=>{await h({text:"Requesting LLM for layer filter results"},r);let t=await $("data_explore_filter_prompt");if(!r?.configurable)throw new Error("config.configurable is required for layer filter tools");let{userTimezone:a,userTimezoneOffset:o}=ee(),i={layerFieldInfo:e.layerFieldInfo,userTimezone:a,userTimezoneOffset:o},n=await C({promptText:t,messages:T(e.messages),inputVariables:i,tools:Xe}),l=[...e.messages,n],d=(n.tool_calls?.length??0)>0?l:[...l,n],c=n.content.toString();return await Q(n,r),{...e,messages:d,outputMessage:c}},ca=async(e,r)=>{await h({text:"Requesting LLM for layer query results"},r);let t=await $("data_explore_query_prompt");if(!r?.configurable)throw new Error("config.configurable is required for layer query tools");let{userTimezone:a,userTimezoneOffset:o}=ee(),i={layerFieldInfo:e.layerFieldInfo,userTimezone:a,userTimezoneOffset:o},n=await C({promptText:t,messages:T(e.messages),inputVariables:i,tools:Ze}),l=[...e.messages,n],d=n.content.toString();return await Q(n,r),{...e,messages:l,outputMessage:d}},da=async(e,r)=>{try{await h({text:"Requesting LLM for summary on query results"},r);let t=await $("summarize_query_response_prompt"),a={queryResponse:e.queryResponse},o=await H({promptText:t,messages:T(e.messages),inputVariables:a}),i=typeof o=="string"?o:o.content,n=new z(i);return await h({text:`Received response from LLM: ${i}`},r),{...e,outputMessage:i,messages:[...e.messages,n]}}catch(t){throw await h({text:"Error during filter LLM request"},r),new Error(`Error during filter LLM request: ${t instanceof Error?t.message:String(t)}`)}};async function ua(e,r){let t=await new R(Xe).invoke({messages:T(e.messages)},r),a=[...e.messages,...t.messages],o=t.messages.map(l=>new z({content:l.content,additional_kwargs:l.additional_kwargs}));await h({text:`Finished executing layer filter tool: ${t.messages.map(l=>l.content).join(", ")}`},r);let i=[...a,...o],n=o.map(l=>l.content).join(`
47
48
 
48
- `);return{...e,messages:i,outputMessage:n}}var da=new A(Ze);async function ua(e,r){let{messages:t}=await da.invoke({messages:v(e.messages)},r),a=[],o=[];for(let n of t){let l=n.content,c;if(typeof l!="string"){c={tool:n.name??"unknown",layerName:"unknown",summary:"Query failed",details:{error:"Skipping non-string tool output:",raw:l}};continue}try{c=JSON.parse(l)}catch{c={tool:n.name??"unknown",layerName:"unknown",summary:"Query failed",details:{error:l}}}a.push(c),c.details&&typeof c.details=="object"&&"error"in c.details?o.push(`- ${c.tool}: Error - ${String(c.details.error)}`):o.push(`- ${c.layerName}: ${c.summary}`)}let i=[...e.messages,...t];return await h({text:`Finished executing layer query tool: ${o.join(", ")}`},r),{...e,messages:i,queryResponse:a}}var ha=10,ma=async(e,r)=>{let t=null,a=null;try{r.type!=="geometry"&&r.type!=="oid"&&r.type!=="global-id"&&(t=await me({layer:e,field:r.name}),r.type==="string"&&(a=(await fe({layer:e,field:r.name})).uniqueValueInfos.sort((o,i)=>i.count-o.count).slice(0,ha)))}catch(o){console.error(`Error fetching statistics for field ${r.name}:`,o)}return{summaryStatistics:t,uniqueValues:a}};async function be(e,r,t){let a=[],o=[];for(let i of e){let n=function(f){let g=r.get(f)?.layerItem;return g?[g.name&&`Name: ${g.name}`,g.title&&`Title: ${g.title}`,g.description&&`Description: ${g.description}`].filter(Boolean).join(" | "):f},{layerId:l,results:c}=i,d=t.map?.allLayers.find(f=>f.id===l),u=r.get(l)?.fieldRegistry;if(!u)continue;let m=a.find(f=>f.layerId===l);m||(m={layerId:l,layerSummary:n(l),fieldInfos:[]},a.push(m));for(let f of c){let g=u.get(f.name);if(g){if(!g.statistics){let w=ma(d,g).then(S=>{u.set(g.name,{...g,statistics:S}),g.statistics=S});o.push(w)}m.fieldInfos.push(g)}}}return await Promise.all(o),a}var fa=async(e,r)=>{try{await h({text:"Getting statistics for vector search results"},r);let t=b(r,"layersAndFieldsRegistry"),{mapView:a}=C(r),o=await be(e.vectorSearchFieldResults,t,a);return console.log("Field statistics retrieved:",o),await h({text:"Statistics retrieved"},r),{...e,layerFieldInfo:o}}catch(t){throw await h({text:"Error during fetching statistics"},r),new Error(`Error during fetching statistics: ${t instanceof Error?t.message:String(t)}`)}},ze=.7,ga=10,ya=async(e,r)=>{try{let t=_(e.messages);await h({text:"Similarity search to find fields"},r);let a=b(r,"fieldSearch"),o=b(r,"layersAndFieldsRegistry"),i=b(r,"embeddingCache"),n=await a.searchFields({text:t,layerIds:e.vectorSearchLayerIds,minScore:ze,topResults:ga,embeddingCache:i}),l=n.map(({layerId:d,results:u})=>{let m=u.map(f=>` - ${f.name} (${f.score.toFixed(2)})`).join(`
49
- `);return`${o.get(d)?.layerItem.name??d}:
49
+ `);return{...e,messages:i,outputMessage:n}}var ha=new R(Ze);async function ma(e,r){let{messages:t}=await ha.invoke({messages:T(e.messages)},r),a=[],o=[];for(let n of t){let l=n.content,d;if(typeof l!="string"){d={tool:n.name??"unknown",layerName:"unknown",summary:"Query failed",details:{error:"Skipping non-string tool output:",raw:l}};continue}try{d=JSON.parse(l)}catch{d={tool:n.name??"unknown",layerName:"unknown",summary:"Query failed",details:{error:l}}}a.push(d),d.details&&typeof d.details=="object"&&"error"in d.details?o.push(`- ${d.tool}: Error - ${String(d.details.error)}`):o.push(`- ${d.layerName}: ${d.summary}`)}let i=[...e.messages,...t];return await h({text:`Finished executing layer query tool: ${o.join(", ")}`},r),{...e,messages:i,queryResponse:a}}var fa=10,ga=async(e,r)=>{let t=null,a=null;try{r.type!=="geometry"&&r.type!=="oid"&&r.type!=="global-id"&&(t=await fe({layer:e,field:r.name}),r.type==="string"&&(a=(await ge({layer:e,field:r.name})).uniqueValueInfos.sort((o,i)=>i.count-o.count).slice(0,fa)))}catch(o){console.error(`Error fetching statistics for field ${r.name}:`,o)}return{summaryStatistics:t,uniqueValues:a}};async function ve(e,r,t){let a=[],o=[];for(let i of e){let n=function(f){let g=r.get(f)?.layerItem;return g?[g.name&&`Name: ${g.name}`,g.title&&`Title: ${g.title}`,g.description&&`Description: ${g.description}`].filter(Boolean).join(" | "):f},{layerId:l,results:d}=i,c=t.map?.allLayers.find(f=>f.id===l),u=r.get(l)?.fieldRegistry;if(!u)continue;let m=a.find(f=>f.layerId===l);m||(m={layerId:l,layerSummary:n(l),fieldInfos:[]},a.push(m));for(let f of d){let g=u.get(f.name);if(g){if(!g.statistics){let b=ga(c,g).then(v=>{u.set(g.name,{...g,statistics:v}),g.statistics=v});o.push(b)}m.fieldInfos.push(g)}}}return await Promise.all(o),a}var ya=async(e,r)=>{try{await h({text:"Getting statistics for vector search results"},r);let t=w(r,"layersAndFieldsRegistry"),{mapView:a}=j(r),o=await ve(e.vectorSearchFieldResults,t,a);return console.log("Field statistics retrieved:",o),await h({text:"Statistics retrieved"},r),{...e,layerFieldInfo:o}}catch(t){throw await h({text:"Error during fetching statistics"},r),new Error(`Error during fetching statistics: ${t instanceof Error?t.message:String(t)}`)}},Ce=.7,pa=10,wa=async(e,r)=>{try{let t=N(e.messages);await h({text:"Similarity search to find fields"},r);let a=w(r,"fieldSearch"),o=w(r,"layersAndFieldsRegistry"),i=w(r,"embeddingCache"),n=await a.searchFields({text:t,layerIds:e.vectorSearchLayerIds,minScore:Ce,topResults:pa,embeddingCache:i}),l=n.map(({layerId:c,results:u})=>{let m=u.map(f=>` - ${f.name} (${f.score.toFixed(2)})`).join(`
50
+ `);return`${o.get(c)?.layerItem.name??c}:
50
51
  ${m}`}).join(`
51
- `),c;return n.length>0?c=`Vector search completed. Matching layers and fields with scores:
52
- ${l}`:c=`No vector search results found for score over ${ze}.`,await h({text:c},r),{...e,vectorSearchFieldResults:n}}catch(t){throw await h({text:`Error during vector search: ${t instanceof Error?t.message:String(t)}`},r),new Error(`Vector search failed: ${t instanceof Error?t.message:String(t)}`)}},pa=.7,wa=async(e,r)=>{try{let t=_(e.messages);await h({text:`Similarity search to find layers: ${t}`},r);let a=b(r,"layerSearch"),o=b(r,"layersAndFieldsRegistry"),i=b(r,"embeddingCache"),n=await a.searchLayers({text:t,minScore:pa,embeddingCache:i}),l=n.map(u=>u.id),c=n.map(({id:u,score:m})=>`${o.get(u)?.layerItem.name??u} (${m.toFixed(2)})`).join(`
53
- `),d;return l.length>0?d=`Vector search completed. Matching layers with scores:
54
- ${c}`:d="Vector search completed. No matching layers found.",await h({text:d},r),{...e,vectorSearchLayerIds:l}}catch(t){throw await h({text:`Error during vector search: ${t instanceof Error?t.message:String(t)}`},r),new Error(`Vector search failed: ${t instanceof Error?t.message:String(t)}`)}},ba=(e,r)=>B(["layerSearch","fieldSearch","layersAndFieldsRegistry"],"Data Exploration Agent")(e,r),va=()=>new q(Ue).addNode("requireDataExplorationServices",ba).addNode("vectorSearchLayers",wa).addNode("vectorSearchFields",ya).addNode("fieldStatistics",fa).addNode("queryAgent",sa).addNode("queryTools",ua).addNode("summarizeQueryResponseLLM",la).addNode("filterAgent",na).addNode("filterTools",ca).addNode("earlyExit",Nr).addEdge(k,"requireDataExplorationServices").addEdge("requireDataExplorationServices","vectorSearchLayers").addConditionalEdges("vectorSearchLayers",e=>e.vectorSearchLayerIds.length?"vectorSearchFields":"earlyExit").addConditionalEdges("vectorSearchFields",e=>e.vectorSearchFieldResults.length?"fieldStatistics":"earlyExit").addEdge("fieldStatistics","queryAgent").addConditionalEdges("queryAgent",e=>(e.messages[e.messages.length-1]?.tool_calls?.length??0)>0?"queryTools":"filterAgent").addConditionalEdges("queryTools",e=>e.queryResponse.length?"summarizeQueryResponseLLM":"filterAgent").addEdge("summarizeQueryResponseLLM","filterAgent").addEdge("filterAgent","filterTools").addEdge("filterTools",E).addEdge("summarizeQueryResponseLLM",E).addEdge("earlyExit",E),Sa=String.raw`- **data exploration** — User is asking about the feature layer’s data (e.g. counts, summaries, statistics, field values), either for all features, a subset based on a condition, or for a subset based on the current view. And/Or user wants to include or exclude features based on field values, or visually style features differently (e.g., highlight or deemphasize them).
52
+ `),d;return n.length>0?d=`Vector search completed. Matching layers and fields with scores:
53
+ ${l}`:d=`No vector search results found for score over ${Ce}.`,await h({text:d},r),{...e,vectorSearchFieldResults:n}}catch(t){throw await h({text:`Error during vector search: ${t instanceof Error?t.message:String(t)}`},r),new Error(`Vector search failed: ${t instanceof Error?t.message:String(t)}`)}},ba=.7,va=async(e,r)=>{try{let t=N(e.messages);await h({text:`Similarity search to find layers: ${t}`},r);let a=w(r,"layerSearch"),o=w(r,"layersAndFieldsRegistry"),i=w(r,"embeddingCache"),n=await a.searchLayers({text:t,minScore:ba,embeddingCache:i}),l=n.map(u=>u.id),d=n.map(({id:u,score:m})=>`${o.get(u)?.layerItem.name??u} (${m.toFixed(2)})`).join(`
54
+ `),c;return l.length>0?c=`Vector search completed. Matching layers with scores:
55
+ ${d}`:c="Vector search completed. No matching layers found.",await h({text:c},r),{...e,vectorSearchLayerIds:l}}catch(t){throw await h({text:`Error during vector search: ${t instanceof Error?t.message:String(t)}`},r),new Error(`Vector search failed: ${t instanceof Error?t.message:String(t)}`)}},Sa=(e,r)=>D(["layerSearch","fieldSearch","layersAndFieldsRegistry"],"Data Exploration Agent")(e,r),Ta=()=>new k(Je).addNode("requireDataExplorationServices",Sa).addNode("vectorSearchLayers",va).addNode("vectorSearchFields",wa).addNode("fieldStatistics",ya).addNode("queryAgent",ca).addNode("queryTools",ma).addNode("summarizeQueryResponseLLM",da).addNode("filterAgent",la).addNode("filterTools",ua).addNode("earlyExit",qr).addEdge(F,"requireDataExplorationServices").addEdge("requireDataExplorationServices","vectorSearchLayers").addConditionalEdges("vectorSearchLayers",e=>e.vectorSearchLayerIds.length?"vectorSearchFields":"earlyExit").addConditionalEdges("vectorSearchFields",e=>e.vectorSearchFieldResults.length?"fieldStatistics":"earlyExit").addEdge("fieldStatistics","queryAgent").addConditionalEdges("queryAgent",e=>(e.messages[e.messages.length-1]?.tool_calls?.length??0)>0?"queryTools":"filterAgent").addConditionalEdges("queryTools",e=>e.queryResponse.length?"summarizeQueryResponseLLM":"filterAgent").addEdge("summarizeQueryResponseLLM","filterAgent").addEdge("filterAgent","filterTools").addEdge("filterTools",E).addEdge("summarizeQueryResponseLLM",E).addEdge("earlyExit",E),Ea=String.raw`- **data exploration** — User is asking about the feature layer’s data (e.g. counts, summaries, statistics, field values), either for all features, a subset based on a condition, or for a subset based on the current view. And/Or user wants to include or exclude features based on field values, or visually style features differently (e.g., highlight or deemphasize them).
55
56
  The Data Exploration Agent will automatically zoom to the affected features for action taken by this agent. In this case, no need to call navigation tool separately.
56
57
  _Example: “Only show stations where Brand is Shell”_
57
58
  _Example: “Make Shell stations stand out on the map”_
@@ -59,47 +60,47 @@ ${c}`:d="Vector search completed. No matching layers found.",await h({text:d},r)
59
60
  This also includes questions that ask which feature meets a given condition or where a particular feature in the data is located (e.g., “Where is the spring with the highest elevation?”).
60
61
  _Example: “How many features are there?”_
61
62
  _Example: “What’s the average population?”_
62
- _Example: “Which values are in the status field?”_`,il={id:"dataExploration",name:"Data Exploration Agent",description:Sa,createGraph:va,workspace:Ue},Ce=.7,Ta=10,Ea=async(e,r)=>{try{let t=_(e.messages);await h({text:"Similarity search to find fields"},r);let a=b(r,"fieldSearch"),o=b(r,"layersAndFieldsRegistry"),i=b(r,"embeddingCache"),n=await a.searchFields({text:t,layerIds:e.vectorSearchLayerIds,minScore:Ce,topResults:Ta,embeddingCache:i}),l=n.map(({layerId:d,results:u})=>{let m=u.map(f=>` - ${f.name} (${f.score.toFixed(2)})`).join(`
63
- `);return`${o.get(d)?.layerItem.name??d}:
63
+ _Example: “Which values are in the status field?”_`,fl={id:"dataExploration",name:"Data Exploration Agent",description:Ea,createGraph:Ta,workspace:Je},je=.7,xa=10,Ia=async(e,r)=>{try{let t=N(e.messages);await h({text:"Similarity search to find fields"},r);let a=w(r,"fieldSearch"),o=w(r,"layersAndFieldsRegistry"),i=w(r,"embeddingCache"),n=await a.searchFields({text:t,layerIds:e.vectorSearchLayerIds,minScore:je,topResults:xa,embeddingCache:i}),l=n.map(({layerId:c,results:u})=>{let m=u.map(f=>` - ${f.name} (${f.score.toFixed(2)})`).join(`
64
+ `);return`${o.get(c)?.layerItem.name??c}:
64
65
  ${m}`}).join(`
65
- `),c;return n.length>0?c=`Vector search completed. Matching layers and fields with scores:
66
- ${l}`:c=`No vector search results found for score over ${Ce}.`,await h({text:c},r),{...e,vectorSearchFieldResults:n}}catch(t){throw await h({text:`Error during vector search: ${t instanceof Error?t.message:String(t)}`},r),new Error(`Vector search failed: ${t instanceof Error?t.message:String(t)}`)}},xa=.7,Ia=async(e,r)=>{try{let t=_(e.messages);await h({text:`Similarity search to find layers: ${t}`},r);let a=b(r,"layerSearch"),o=b(r,"layersAndFieldsRegistry"),i=await a.searchLayers({text:t,minScore:xa}),n=i.map(d=>d.id),l=i.map(({id:d,score:u})=>`${o.get(d)?.layerItem.name??d} (${u.toFixed(2)})`).join(`
67
- `),c;return n.length>0?c=`Vector search completed. Matching layers with scores:
68
- ${l}`:c="Vector search completed. No matching layers found.",await h({text:c},r),{...e,vectorSearchLayerIds:n}}catch(t){throw await h({text:`Error during vector search: ${t instanceof Error?t.message:String(t)}`},r),new Error(`Vector search failed: ${t instanceof Error?t.message:String(t)}`)}},Ye=["mapView"];function ve(e){let r=e?.configurable?.context;if(!r||typeof r!="object")throw new Error("LayerFilterAgent context missing");let t=Ye.filter(a=>!(a in r));if(t.length)throw new Error(`LayerFilterAgent context missing: ${t.join(", ")}`);return r}var La=async(e,r)=>{try{await h({text:"Getting statistics for vector search results"},r);let t=b(r,"layersAndFieldsRegistry"),{mapView:a}=ve(r),o=await be(e.vectorSearchFieldResults,t,a);return console.log("Field statistics retrieved:",o),await h({text:"Statistics retrieved"},r),{...e,layerFieldInfo:o}}catch(t){throw await h({text:"Error during fetching statistics"},r),new Error(`Error during fetching statistics: ${t instanceof Error?t.message:String(t)}`)}},Xe=async(e,r,t)=>{let a=e.map?.allLayers.find(n=>n.id===r),o=a.createQuery();o.where=t??"1=1";let{features:i}=await a.queryFeatures(o);e.goTo(i)},et=async(e,r)=>{let t=r.map?.allLayers.find(i=>i.id===e.layerId);if(!t)return{error:`Could not find geometry layer with ID: ${e.layerId}`};let a=await t.queryFeatures({where:e.where,returnGeometry:!0});if(!a.features.length)return{error:`No features found in geometry layer with the specified where clause: ${e.where}`};let o;if(a.features.length===1){let i=a.features[0].geometry;if(!i)return{error:"The geometry of the first feature is undefined or null."};o=i}else{let i=a.features.map(l=>l.geometry),n=Y.executeMany(i);if(!n)return{error:"Failed to create a combined geometry."};o=n}return{geometry:o}},$a=async(e,r,t,a,o)=>{let i=r.map?.allLayers.find(l=>l.id===e.layerId);if(!i)return`Could not find target layer with ID: ${e.layerId}`;console.log("Layer type:",i.type),console.log("Layer geometryType:",i.geometryType),console.log("Layer renderer:",i.renderer?.type);let n;if(o){let l=await et(o,r);if("error"in l)return l.error;n=l.geometry}return i.featureEffect=new Pe({filter:new V({where:e.where,geometry:n,spatialRelationship:"intersects",distance:o?.distance,units:o?.units}),includedEffect:t,excludedEffect:a}),i.visible=!0,Xe(r,o?o.layerId:e.layerId,o?o.where:e.where),`Applied feature effects to target layer "${i.title??e.layerId}"${o?` using geometry from layer "${o.layerId}"`:""}.`},Fa=["feet","kilometers","meters","miles","nautical-miles","us-nautical-miles"],tt=s.enum(Fa),_a=async({targetLayer:e,geometryLayer:r,includedEffect:t="drop-shadow(2px, 2px, 2px, gray)",excludedEffect:a="grayscale(100%) opacity(60%) blur(2px)"},o)=>{let{mapView:i}=ve(o);return await $a(e,i,t,a,r)},Na=s.object({targetLayer:s.object({layerId:s.string().describe("The layerId of the layer on which to set a feature effect."),where:s.string().describe("The SQL-92 where clause representing the features to emphasize.")}),geometryLayer:s.object({layerId:s.string().describe("The layerId of the layer containing the geometry by which to filter."),where:s.string().describe("The SQL-92 where clause representing the features from which to filter features from the targetLayer by geometry."),distance:s.number().describe("The distance by which to filter the input geometry."),units:tt.describe("The units used to filter by geometry and distance.")}).optional().describe("Optional geometry-based filtering parameters for spatial queries."),includedEffect:s.string().optional().default("drop-shadow(2px, 2px, 2px, gray)").describe("The effect applied to features that meet the filter requirements. Valid effects include: bloom, blur, brightness, contrast, drop-shadow, grayscale, hue-rotate, invert, opacity, saturate, and sepia. Prefer default unless specified."),excludedEffect:s.string().optional().default("grayscale(100%) opacity(60%) blur(2px)").describe("The effect applied to features that do not meet the filter requirements. Valid effects include: bloom, blur, brightness, contrast, drop-shadow, grayscale, hue-rotate, invert, opacity, saturate, and sepia. Prefer default unless specified.")}),ka=p(_a,{name:"setFeatureEffect",description:"Sets a feature effect on a given layer with given filter parameters and feature effects to emphasize certain features that meet a filter requirement. If no feature effect information is provided, then use the default effect provided.",schema:Na}),qa=async(e,r,t)=>{let a=r.map?.allLayers.find(n=>n.id===e.layerId);if(!a)return`Could not find target layer with ID: ${e.layerId}`;let o;if(t){let n=await et(t,r);if("error"in n)return n.error;o=n.geometry}let i=await r.whenLayerView(a);return i.filter=new V({where:e.where,geometry:o,spatialRelationship:"intersects",distance:t?.distance,units:t?.units}),a.visible=!0,Xe(r,t?t.layerId:e.layerId,t?t.where:e.where),`Applied feature filter to layer "${a.title??e.layerId}"${t?` using geometry from layer "${t.layerId}"`:""}.`},Aa=async({targetLayer:e,geometryLayer:r},t)=>{let{mapView:a}=ve(t);return await qa(e,a,r)},Ra=s.object({targetLayer:s.object({layerId:s.string().describe("The layerId of the layer on which to set a filter."),where:s.string().describe("The SQL-92 where clause representing the features to display.")}),geometryLayer:s.object({layerId:s.string().describe("The layerId of the layer containing the geometry by which to filter."),where:s.string().describe("The SQL-92 where clause representing the features from which to filter features from the targetLayer by geometry."),distance:s.number().describe("The distance by which to filter the input geometry."),units:tt.describe("The units used to filter by geometry and distance.")}).optional().describe("Optional geometry-based filtering parameters for spatial queries.")}),Ma=p(Aa,{name:"setFeatureFilter",description:"Sets a client-side filter using a where clause, geometry filter, or both on a target layer. This filters features at the client level in the view.",schema:Ra}),rt=[ka,Ma],za=async(e,r)=>{await h({text:"Requesting LLM for layer filter results"},r);let t=await F("layer_filter_prompt");if(!r?.configurable)throw new Error("config.configurable is required for layer filter tools");let{userTimezone:a,userTimezoneOffset:o}=X(),i={layerFieldInfo:e.layerFieldInfo,userTimezone:a,userTimezoneOffset:o},n=await z({promptText:t,messages:v(e.messages),inputVariables:i,tools:rt}),l=n.content.toString();return await Q(n,r),{...e,messages:[...e.messages,n],outputMessage:l}};async function Ca(e,r){let t=await new A(rt).invoke({messages:v(e.messages)},r),a=t.messages.map(n=>n.text).join(`
66
+ `),d;return n.length>0?d=`Vector search completed. Matching layers and fields with scores:
67
+ ${l}`:d=`No vector search results found for score over ${je}.`,await h({text:d},r),{...e,vectorSearchFieldResults:n}}catch(t){throw await h({text:`Error during vector search: ${t instanceof Error?t.message:String(t)}`},r),new Error(`Vector search failed: ${t instanceof Error?t.message:String(t)}`)}},$a=.7,La=async(e,r)=>{try{let t=N(e.messages);await h({text:`Similarity search to find layers: ${t}`},r);let a=w(r,"layerSearch"),o=w(r,"layersAndFieldsRegistry"),i=await a.searchLayers({text:t,minScore:$a}),n=i.map(c=>c.id),l=i.map(({id:c,score:u})=>`${o.get(c)?.layerItem.name??c} (${u.toFixed(2)})`).join(`
68
+ `),d;return n.length>0?d=`Vector search completed. Matching layers with scores:
69
+ ${l}`:d="Vector search completed. No matching layers found.",await h({text:d},r),{...e,vectorSearchLayerIds:n}}catch(t){throw await h({text:`Error during vector search: ${t instanceof Error?t.message:String(t)}`},r),new Error(`Vector search failed: ${t instanceof Error?t.message:String(t)}`)}},Ye=["mapView"];function Se(e){let r=e?.configurable?.context;if(!r||typeof r!="object")throw new Error("LayerFilterAgent context missing");let t=Ye.filter(a=>!(a in r));if(t.length)throw new Error(`LayerFilterAgent context missing: ${t.join(", ")}`);return r}var Fa=async(e,r)=>{try{await h({text:"Getting statistics for vector search results"},r);let t=w(r,"layersAndFieldsRegistry"),{mapView:a}=Se(r),o=await ve(e.vectorSearchFieldResults,t,a);return console.log("Field statistics retrieved:",o),await h({text:"Statistics retrieved"},r),{...e,layerFieldInfo:o}}catch(t){throw await h({text:"Error during fetching statistics"},r),new Error(`Error during fetching statistics: ${t instanceof Error?t.message:String(t)}`)}},et=async(e,r,t)=>{let a=e.map?.allLayers.find(n=>n.id===r),o=a.createQuery();o.where=t??"1=1";let{features:i}=await a.queryFeatures(o);e.goTo(i)},tt=async(e,r)=>{let t=r.map?.allLayers.find(i=>i.id===e.layerId);if(!t)return{error:`Could not find geometry layer with ID: ${e.layerId}`};let a=await t.queryFeatures({where:e.where,returnGeometry:!0});if(!a.features.length)return{error:`No features found in geometry layer with the specified where clause: ${e.where}`};let o;if(a.features.length===1){let i=a.features[0].geometry;if(!i)return{error:"The geometry of the first feature is undefined or null."};o=i}else{let i=a.features.map(l=>l.geometry),n=Y.executeMany(i);if(!n)return{error:"Failed to create a combined geometry."};o=n}return{geometry:o}},_a=async(e,r,t,a,o)=>{let i=r.map?.allLayers.find(l=>l.id===e.layerId);if(!i)return`Could not find target layer with ID: ${e.layerId}`;console.log("Layer type:",i.type),console.log("Layer geometryType:",i.geometryType),console.log("Layer renderer:",i.renderer?.type);let n;if(o){let l=await tt(o,r);if("error"in l)return l.error;n=l.geometry}return i.featureEffect=new Ge({filter:new O({where:e.where,geometry:n,spatialRelationship:"intersects",distance:o?.distance,units:o?.units}),includedEffect:t,excludedEffect:a}),i.visible=!0,et(r,o?o.layerId:e.layerId,o?o.where:e.where),`Applied feature effects to target layer "${i.title??e.layerId}"${o?` using geometry from layer "${o.layerId}"`:""}.`},ka=["feet","kilometers","meters","miles","nautical-miles","us-nautical-miles"],rt=s.enum(ka),Na=async({targetLayer:e,geometryLayer:r,includedEffect:t="drop-shadow(2px, 2px, 2px, gray)",excludedEffect:a="grayscale(100%) opacity(60%) blur(2px)"},o)=>{let{mapView:i}=Se(o);return await _a(e,i,t,a,r)},qa=s.object({targetLayer:s.object({layerId:s.string().describe("The layerId of the layer on which to set a feature effect."),where:s.string().describe("The SQL-92 where clause representing the features to emphasize.")}),geometryLayer:s.object({layerId:s.string().describe("The layerId of the layer containing the geometry by which to filter."),where:s.string().describe("The SQL-92 where clause representing the features from which to filter features from the targetLayer by geometry."),distance:s.number().describe("The distance by which to filter the input geometry."),units:rt.describe("The units used to filter by geometry and distance.")}).optional().describe("Optional geometry-based filtering parameters for spatial queries."),includedEffect:s.string().optional().default("drop-shadow(2px, 2px, 2px, gray)").describe("The effect applied to features that meet the filter requirements. Valid effects include: bloom, blur, brightness, contrast, drop-shadow, grayscale, hue-rotate, invert, opacity, saturate, and sepia. Prefer default unless specified."),excludedEffect:s.string().optional().default("grayscale(100%) opacity(60%) blur(2px)").describe("The effect applied to features that do not meet the filter requirements. Valid effects include: bloom, blur, brightness, contrast, drop-shadow, grayscale, hue-rotate, invert, opacity, saturate, and sepia. Prefer default unless specified.")}),Aa=p(Na,{name:"setFeatureEffect",description:"Sets a feature effect on a given layer with given filter parameters and feature effects to emphasize certain features that meet a filter requirement. If no feature effect information is provided, then use the default effect provided.",schema:qa}),Ra=async(e,r,t)=>{let a=r.map?.allLayers.find(n=>n.id===e.layerId);if(!a)return`Could not find target layer with ID: ${e.layerId}`;let o;if(t){let n=await tt(t,r);if("error"in n)return n.error;o=n.geometry}let i=await r.whenLayerView(a);return i.filter=new O({where:e.where,geometry:o,spatialRelationship:"intersects",distance:t?.distance,units:t?.units}),a.visible=!0,et(r,t?t.layerId:e.layerId,t?t.where:e.where),`Applied feature filter to layer "${a.title??e.layerId}"${t?` using geometry from layer "${t.layerId}"`:""}.`},Ma=async({targetLayer:e,geometryLayer:r},t)=>{let{mapView:a}=Se(t);return await Ra(e,a,r)},za=s.object({targetLayer:s.object({layerId:s.string().describe("The layerId of the layer on which to set a filter."),where:s.string().describe("The SQL-92 where clause representing the features to display.")}),geometryLayer:s.object({layerId:s.string().describe("The layerId of the layer containing the geometry by which to filter."),where:s.string().describe("The SQL-92 where clause representing the features from which to filter features from the targetLayer by geometry."),distance:s.number().describe("The distance by which to filter the input geometry."),units:rt.describe("The units used to filter by geometry and distance.")}).optional().describe("Optional geometry-based filtering parameters for spatial queries.")}),Ca=p(Ma,{name:"setFeatureFilter",description:"Sets a client-side filter using a where clause, geometry filter, or both on a target layer. This filters features at the client level in the view.",schema:za}),at=[Aa,Ca],ja=async(e,r)=>{await h({text:"Requesting LLM for layer filter results"},r);let t=await $("layer_filter_prompt");if(!r?.configurable)throw new Error("config.configurable is required for layer filter tools");let{userTimezone:a,userTimezoneOffset:o}=ee(),i={layerFieldInfo:e.layerFieldInfo,userTimezone:a,userTimezoneOffset:o},n=await C({promptText:t,messages:T(e.messages),inputVariables:i,tools:at}),l=n.content.toString();return await Q(n,r),{...e,messages:[...e.messages,n],outputMessage:l}};async function Va(e,r){let t=await new R(at).invoke({messages:T(e.messages)},r),a=t.messages.map(n=>n.text).join(`
69
70
  `);await h({text:`Finished executing layer filter tool: ${a}`},r);let o=[...e.messages,...t.messages],i=t.messages.map(n=>n.text).join(`
70
- `);return{...e,outputMessage:i,messages:o}}var at=y.Root({messages:y({reducer:L,default:()=>[]}),outputMessage:y({reducer:(e="",r)=>{let t=typeof r=="string"?r.trim():"";if(!t)return e;let a=e.trim();if(!a)return t;if(a===t)return e;let o=a.split(`
71
+ `);return{...e,outputMessage:i,messages:o}}var ot=y.Root({messages:y({reducer:_,default:()=>[]}),outputMessage:y({reducer:(e="",r)=>{let t=typeof r=="string"?r.trim():"";if(!t)return e;let a=e.trim();if(!a)return t;if(a===t)return e;let o=a.split(`
71
72
 
72
73
  `);return o[o.length-1]?.trim()===t?e:`${e}
73
74
 
74
- ${t}`},default:()=>""}),vectorSearchLayerIds:y(),vectorSearchFieldResults:y(),layerFieldInfo:y()}),ja=async(e,r)=>(await h({text:"Exiting Layer Filter agent"},r),e),Va=(e,r)=>B(["layerSearch","fieldSearch","layersAndFieldsRegistry"],"Layer Filter Agent")(e,r),Oa=()=>new q(at).addNode("requireLayerFilterServices",Va).addNode("vectorSearchLayers",Ia).addNode("vectorSearchFields",Ea).addNode("fieldStatistics",La).addNode("agent",za).addNode("tools",Ca).addNode("earlyExit",ja).addEdge(k,"requireLayerFilterServices").addEdge("requireLayerFilterServices","vectorSearchLayers").addConditionalEdges("vectorSearchLayers",e=>e.vectorSearchLayerIds.length?"vectorSearchFields":"earlyExit").addConditionalEdges("vectorSearchFields",e=>e.vectorSearchFieldResults.length?"fieldStatistics":"earlyExit").addEdge("fieldStatistics","agent").addConditionalEdges("agent",e=>(e.messages[e.messages.length-1]?.tool_calls?.length??0)>0?"tools":"earlyExit").addEdge("tools","earlyExit").addEdge("earlyExit",E),Da=String.raw`- **layer filter** — User wants to include or exclude features based on field values, or visually style features differently (e.g., highlight or deemphasize them).
75
+ ${t}`},default:()=>""}),vectorSearchLayerIds:y(),vectorSearchFieldResults:y(),layerFieldInfo:y()}),Oa=async(e,r)=>(await h({text:"Exiting Layer Filter agent"},r),e),Da=(e,r)=>D(["layerSearch","fieldSearch","layersAndFieldsRegistry"],"Layer Filter Agent")(e,r),Pa=()=>new k(ot).addNode("requireLayerFilterServices",Da).addNode("vectorSearchLayers",La).addNode("vectorSearchFields",Ia).addNode("fieldStatistics",Fa).addNode("agent",ja).addNode("tools",Va).addNode("earlyExit",Oa).addEdge(F,"requireLayerFilterServices").addEdge("requireLayerFilterServices","vectorSearchLayers").addConditionalEdges("vectorSearchLayers",e=>e.vectorSearchLayerIds.length?"vectorSearchFields":"earlyExit").addConditionalEdges("vectorSearchFields",e=>e.vectorSearchFieldResults.length?"fieldStatistics":"earlyExit").addEdge("fieldStatistics","agent").addConditionalEdges("agent",e=>(e.messages[e.messages.length-1]?.tool_calls?.length??0)>0?"tools":"earlyExit").addEdge("tools","earlyExit").addEdge("earlyExit",E),Ga=String.raw`- **layer filter** — User wants to include or exclude features based on field values, or visually style features differently (e.g., highlight or deemphasize them).
75
76
  The Layer Filter Agent will automatically zoom to the affected features for action taken by this agent. In this case, no need to call navigation tool separately.
76
77
  _Example: “Only show stations where Brand is Shell”_
77
78
  _Example: “Make Shell stations stand out on the map”_
78
- _Example: “Gray out all stations that aren’t Shell”_`,nl={id:"layerFilter",name:"Layer Filter Agent",description:Da,createGraph:Oa,workspace:at},ot=y.Root({messages:y({reducer:L,default:()=>[]}),outputMessage:y({reducer:(e="",r)=>{let t=typeof r=="string"?r.trim():"";if(!t)return e;let a=e.trim();if(!a)return t;if(a===t)return e;let o=a.split(`
79
+ _Example: “Gray out all stations that aren’t Shell”_`,gl={id:"layerFilter",name:"Layer Filter Agent",description:Ga,createGraph:Pa,workspace:ot},it=y.Root({messages:y({reducer:_,default:()=>[]}),outputMessage:y({reducer:(e="",r)=>{let t=typeof r=="string"?r.trim():"";if(!t)return e;let a=e.trim();if(!a)return t;if(a===t)return e;let o=a.split(`
79
80
 
80
81
  `);return o[o.length-1]?.trim()===t?e:`${e}
81
82
 
82
- ${t}`},default:()=>""}),vectorSearchLayerIds:y(),vectorSearchFieldResults:y(),layerFieldInfo:y(),queryResponses:y()}),Pa=async(e,r)=>(await h({text:"Exiting Layer Query agent"},r),e);function K(e){let r=e?.configurable?.context;if(!r||typeof r!="object")throw new Error("LayerQueryAgent context missing");let t=Ye.filter(a=>!(a in r));if(t.length)throw new Error(`LayerQueryAgent context missing: ${t.join(", ")}`);return r}var Ga=async(e,r)=>{try{await h({text:"Getting statistics for vector search results"},r);let t=b(r,"layersAndFieldsRegistry"),{mapView:a}=K(r),o=await be(e.vectorSearchFieldResults,t,a);return console.log("Field statistics retrieved:",o),await h({text:"Statistics retrieved"},r),{...e,layerFieldInfo:o}}catch(t){throw await h({text:"Error during fetching statistics"},r),new Error(`Error during fetching statistics: ${t instanceof Error?t.message:String(t)}`)}},je=.7,Ba=10,Qa=async(e,r)=>{try{let t=_(e.messages);await h({text:"Similarity search to find fields"},r);let a=b(r,"fieldSearch"),o=b(r,"layersAndFieldsRegistry"),i=b(r,"embeddingCache"),n=await a.searchFields({text:t,layerIds:e.vectorSearchLayerIds,minScore:je,topResults:Ba,embeddingCache:i}),l=n.map(({layerId:d,results:u})=>{let m=u.map(f=>` - ${f.name} (${f.score.toFixed(2)})`).join(`
83
- `);return`${o.get(d)?.layerItem.name??d}:
83
+ ${t}`},default:()=>""}),vectorSearchLayerIds:y(),vectorSearchFieldResults:y(),layerFieldInfo:y(),queryResponses:y()}),Ba=async(e,r)=>(await h({text:"Exiting Layer Query agent"},r),e);function K(e){let r=e?.configurable?.context;if(!r||typeof r!="object")throw new Error("LayerQueryAgent context missing");let t=Ye.filter(a=>!(a in r));if(t.length)throw new Error(`LayerQueryAgent context missing: ${t.join(", ")}`);return r}var Qa=async(e,r)=>{try{await h({text:"Getting statistics for vector search results"},r);let t=w(r,"layersAndFieldsRegistry"),{mapView:a}=K(r),o=await ve(e.vectorSearchFieldResults,t,a);return console.log("Field statistics retrieved:",o),await h({text:"Statistics retrieved"},r),{...e,layerFieldInfo:o}}catch(t){throw await h({text:"Error during fetching statistics"},r),new Error(`Error during fetching statistics: ${t instanceof Error?t.message:String(t)}`)}},Ve=.7,Wa=10,Ka=async(e,r)=>{try{let t=N(e.messages);await h({text:"Similarity search to find fields"},r);let a=w(r,"fieldSearch"),o=w(r,"layersAndFieldsRegistry"),i=w(r,"embeddingCache"),n=await a.searchFields({text:t,layerIds:e.vectorSearchLayerIds,minScore:Ve,topResults:Wa,embeddingCache:i}),l=n.map(({layerId:c,results:u})=>{let m=u.map(f=>` - ${f.name} (${f.score.toFixed(2)})`).join(`
84
+ `);return`${o.get(c)?.layerItem.name??c}:
84
85
  ${m}`}).join(`
85
- `),c;return n.length>0?c=`Vector search completed. Matching layers and fields with scores:
86
- ${l}`:c=`No vector search results found for score over ${je}.`,await h({text:c},r),{...e,vectorSearchFieldResults:n}}catch(t){throw await h({text:`Error during vector search: ${t instanceof Error?t.message:String(t)}`},r),new Error(`Vector search failed: ${t instanceof Error?t.message:String(t)}`)}},Wa=.7,Ka=async(e,r)=>{try{let t=_(e.messages);await h({text:`Similarity search to find layers: ${t}`},r);let a=b(r,"layerSearch"),o=b(r,"layersAndFieldsRegistry"),i=await a.searchLayers({text:t,minScore:Wa}),n=i.map(d=>d.id),l=i.map(({id:d,score:u})=>`${o.get(d)?.layerItem.name??d} (${u.toFixed(2)})`).join(`
87
- `),c;return n.length>0?c=`Vector search completed. Matching layers with scores:
88
- ${l}`:c="Vector search completed. No matching layers found.",await h({text:c},r),{...e,vectorSearchLayerIds:n}}catch(t){throw await h({text:`Error during vector search: ${t instanceof Error?t.message:String(t)}`},r),new Error(`Vector search failed: ${t instanceof Error?t.message:String(t)}`)}},Ua=(e,r,t)=>{let a=e.createQuery();return a.outFields=[r],a.where=t||"1=1",a.num=1,a},Ja=async(e,r,t,a)=>{let o=a.map?.allLayers.find(c=>c.id===e),i=Ua(o,r,t.where),n=(await o.queryFeatures(i)).features[0],l=n?n.attributes[r]:null;return{tool:"getAttribute",layerName:o.title??e,summary:`${r} = ${l}`,details:{fieldName:r,value:l,where:t.where}}};async function Za({layerId:e,fieldName:r,query:t},a){let{mapView:o}=K(a),i=await Ja(e,r,t,o);return JSON.stringify(i,null,2)}var Ha=s.object({layerId:s.string().describe("The layerId of the layer containing the field from which to get a value."),fieldName:s.string().describe("The name of the field/attribute from which to get a field value."),query:s.object({where:s.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value.")})}),Ya=p(Za,{name:"getAttribute",description:"Returns an attribute value for a given feature.",schema:Ha}),Se=async(e,r)=>{let t=r.map?.allLayers.find(i=>i.id===e.layerId);if(!t)return{error:`Could not find geometry layer with ID: ${e.layerId}`};let a=await t.queryFeatures({where:e.where,returnGeometry:!0});if(!a.features.length)return{error:`No features found in geometry layer with the specified where clause: ${e.where}`};let o;if(a.features.length===1){let i=a.features[0].geometry;if(!i)return{error:"The geometry of the first feature is undefined or null."};o=i}else{let i=a.features.map(l=>l.geometry),n=Y.executeMany(i);if(!n)return{error:"Failed to create a combined geometry."};o=n}return{geometry:o}},Xa=async e=>{let{targetLayer:r,fieldName:t,statisticType:a,mapView:o,layersAndFieldsRegistry:i,geometryLayer:n}=e,l=o.map?.allLayers.find(g=>g.id===r.layerId);if(!l)throw new Error(`Layer '${r.layerId}' not found.`);let c=i.get(r.layerId)?.fieldRegistry.get(t);if(!c)throw new Error(`Field '${t}' not found.`);let d;if(n){let g=await Se(n,o);if("error"in g)throw new Error(g.error);if(d=g.geometry,n.distance&&n.units){let w=Qe.execute(d,n.distance,{unit:n.units==="us-nautical-miles"?"nautical-miles":n.units});w&&(d=w)}}else d=o.extent.clone();let u=new V({geometry:d,spatialRelationship:"intersects"}),m=null,f=null;try{m=await me({layer:l,field:t,sqlWhere:r.where,filter:u,outStatisticTypes:{include:[a]}}),c.type==="string"&&(f=(await fe({layer:l,field:t,sqlWhere:r.where,filter:u})).uniqueValueInfos)}catch(g){console.error("Statistics error:",g)}return{tool:"getStatistics",layerName:l.title??r.layerId,summary:`${a} = ${typeof m?.[a]=="number"?m[a]:"N/A"}`,details:{fieldName:t,statisticType:a,statistic:m?.[a]??null,summaryStatistics:m,uniqueValues:f,where:r.where}}},eo=["feet","kilometers","meters","miles","nautical-miles","us-nautical-miles"],to=s.enum(eo);async function ro({targetLayer:e,fieldName:r,statisticType:t,geometryLayer:a},o){let i=b(o,"layersAndFieldsRegistry"),{mapView:n}=K(o),l=await Xa({targetLayer:e,fieldName:r,statisticType:t,mapView:n,layersAndFieldsRegistry:i,geometryLayer:a});return console.log(l),JSON.stringify(l,null,2)}var ao=s.object({targetLayer:s.object({layerId:s.string().describe("The layerId of the layer containing the field from which to get a value."),where:s.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value.")}),geometryLayer:s.union([s.object({layerId:s.string().describe("The layerId of the layer containing the geometry by which to filter."),where:s.string().describe("The SQL-92 where clause representing the features from which to filter features from the targetLayer by geometry."),distance:s.number().optional().describe("The distance by which to query from the input geometry."),units:to.optional().describe("The units used to query by geometry and distance.")}),s.object({}).strict()]).optional().describe("Optional geometry-based filtering parameters for spatial queries."),fieldName:s.string().describe("The name of the field for which to get statistics."),statisticType:s.enum(["avg","max","median","min","stddev","sum","variance","nullcount","count"]).describe("The statistic type to calculate.")}),oo=p(ro,{name:"getStatistics",description:"Returns one or more summary statistics for the given field. Statistic types include: count, maximum, minimum, average, median, standard deviation, variance, mode, sum, nullcount (number of features without a value for a given field), unique values. Statistics can be returned for number, date, and string fields. Only call this tool when the question requires filtering (e.g. a WHERE clause or spatial constraint) that cannot be satisfied by precomputed stats.",schema:ao}),io=async(e,r,t,a)=>{let o=t.map?.allLayers.find(d=>d.id===e.layerId),i=a?await Se(a,t):{geometry:void 0},n="geometry"in i?i.geometry:void 0,l=new Ge({where:e.where||"1=1",outFields:e.outFields.length?e.outFields:["*"],orderByFields:e.orderByFields,geometry:n,spatialRelationship:n?"intersects":void 0,distance:a?.distance,units:a?.units,topFilter:new Be({topCount:r.topCount,groupByFields:r.groupByFields,orderByFields:r.orderByFields})}),c=await o.queryTopFeatures(l);return{tool:"getTopFeatures",layerName:o.title??e.layerId,summary:`Top ${r.topCount} features extracted`,details:{topCount:r.topCount,features:c.features,where:e.where}}},no=async({targetLayer:e,topFilter:r,geometryLayer:t},a)=>{let{mapView:o}=K(a),i=await io(e,r,o,t);return JSON.stringify(i,null,2)},so=s.object({targetLayer:s.object({layerId:s.string().describe("The layerId of the layer containing the field from which to get a value."),where:s.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value."),orderByFields:s.array(s.string().describe("The field(s) and order for which to sort the resulting features.")),outFields:s.array(s.string().describe("The fields to include in the output that will be presented to the user. This should include identifying information about the resulting features, like a name or id, along with the values desired in the output."))}),geometryLayer:s.object({layerId:s.string().describe("The layerId of the layer containing the geometry by which to filter."),where:s.string().describe("The SQL-92 where clause representing the features from which to filter features from the targetLayer by geometry."),distance:s.number().describe("The distance by which to query from the input geometry."),units:R.describe("The units used to query by geometry and distance.")}).optional().describe("Optional geometry-based filtering parameters for spatial queries."),topFilter:s.object({topCount:s.number().describe("The SQL-92 where clause representing the feature from which to get an attribute value."),orderByFields:s.array(s.string().describe("The field(s) and order for which to sort the resulting features.")),groupByFields:s.array(s.string().describe("The field(s) for which to group by the top features."))})}),lo=p(no,{name:"getTopFeatures",description:"Returns the top n features from a layer",schema:so}),co=async(e,r,t)=>{let a=r.map?.allLayers.find(c=>c.id===e.layerId),o=t?await Se(t,r):{geometry:void 0},i="geometry"in o?o.geometry:void 0,n=new ge({where:e.where||"1=1",outFields:e.outFields.length?e.outFields:["*"],orderByFields:e.orderByFields,geometry:i,spatialRelationship:i?"intersects":void 0,distance:t?.distance,units:t?.units}),l=await a.queryFeatures(n);return{tool:"queryFeatures",layerName:a.title??e.layerId,summary:`${l.features.length} features found`,details:{totalCount:l.features.length,features:l.features.slice(0,10),where:e.where}}};async function uo({targetLayer:e,geometryLayer:r},t){let{mapView:a}=K(t),o=await co(e,a,r);return JSON.stringify(o,null,2)}var ho=s.object({targetLayer:s.object({layerId:s.string().describe("The layerId of the layer containing the field from which to get a value."),where:s.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value."),orderByFields:s.array(s.string().describe("The field(s) and order for which to sort the resulting features.")),outFields:s.array(s.string().describe("The fields to include in the output that will be presented to the user. This should include identifying information about the resulting features, like a name or id, along with the values desired in the output."))}),geometryLayer:s.object({layerId:s.string().describe("The layerId of the layer containing the geometry by which to filter."),where:s.string().describe("The SQL-92 where clause representing the features from which to filter features from the targetLayer by geometry."),distance:s.number().describe("The distance by which to query from the input geometry."),units:R.describe("The units used to query by geometry and distance.")}).optional().describe("Optional geometry-based filtering parameters for spatial queries.")}),mo=p(uo,{name:"queryFeatures",description:"Queries for one or more features from a given layer.",schema:ho}),it=[mo,oo,Ya,lo],fo=async(e,r)=>{await h({text:"Requesting LLM for layer query results"},r);let t=await F("data_query_prompt");if(!r?.configurable)throw new Error("config.configurable is required for layer query tools");let{userTimezone:a,userTimezoneOffset:o}=X(),i={layerFieldInfo:e.layerFieldInfo,userTimezone:a,userTimezoneOffset:o},n=await z({promptText:t,messages:v(e.messages),inputVariables:i,tools:it});if(!(n.tool_calls&&Array.isArray(n.tool_calls)&&n.tool_calls.length>0))return{...e,messages:[...e.messages,n]};let l=n.content.toString()||"LLM requested tool calls.";return await Q(n,r),{...e,outputMessage:l,messages:[...e.messages,n]}},go=new A(it);async function yo(e,r){let{messages:t}=await go.invoke({messages:v(e.messages)},r),a=[],o=[];for(let l of t){let c=l.content;if(typeof c!="string"){console.warn("Skipping non-string tool output:",c);continue}let d;try{d=JSON.parse(c)}catch{console.warn("Skipping invalid JSON from tool:",c);continue}a.push(d),o.push(`- ${d.layerName}: ${d.summary}`)}if(o.length===0)return{...e,queryResponses:a};let i=new j({content:`Query results:
86
+ `),d;return n.length>0?d=`Vector search completed. Matching layers and fields with scores:
87
+ ${l}`:d=`No vector search results found for score over ${Ve}.`,await h({text:d},r),{...e,vectorSearchFieldResults:n}}catch(t){throw await h({text:`Error during vector search: ${t instanceof Error?t.message:String(t)}`},r),new Error(`Vector search failed: ${t instanceof Error?t.message:String(t)}`)}},Ua=.7,Ja=async(e,r)=>{try{let t=N(e.messages);await h({text:`Similarity search to find layers: ${t}`},r);let a=w(r,"layerSearch"),o=w(r,"layersAndFieldsRegistry"),i=await a.searchLayers({text:t,minScore:Ua}),n=i.map(c=>c.id),l=i.map(({id:c,score:u})=>`${o.get(c)?.layerItem.name??c} (${u.toFixed(2)})`).join(`
88
+ `),d;return n.length>0?d=`Vector search completed. Matching layers with scores:
89
+ ${l}`:d="Vector search completed. No matching layers found.",await h({text:d},r),{...e,vectorSearchLayerIds:n}}catch(t){throw await h({text:`Error during vector search: ${t instanceof Error?t.message:String(t)}`},r),new Error(`Vector search failed: ${t instanceof Error?t.message:String(t)}`)}},Ha=(e,r,t)=>{let a=e.createQuery();return a.outFields=[r],a.where=t||"1=1",a.num=1,a},Za=async(e,r,t,a)=>{let o=a.map?.allLayers.find(d=>d.id===e),i=Ha(o,r,t.where),n=(await o.queryFeatures(i)).features[0],l=n?n.attributes[r]:null;return{tool:"getAttribute",layerName:o.title??e,summary:`${r} = ${l}`,details:{fieldName:r,value:l,where:t.where}}};async function Xa({layerId:e,fieldName:r,query:t},a){let{mapView:o}=K(a),i=await Za(e,r,t,o);return JSON.stringify(i,null,2)}var Ya=s.object({layerId:s.string().describe("The layerId of the layer containing the field from which to get a value."),fieldName:s.string().describe("The name of the field/attribute from which to get a field value."),query:s.object({where:s.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value.")})}),eo=p(Xa,{name:"getAttribute",description:"Returns an attribute value for a given feature.",schema:Ya}),Te=async(e,r)=>{let t=r.map?.allLayers.find(i=>i.id===e.layerId);if(!t)return{error:`Could not find geometry layer with ID: ${e.layerId}`};let a=await t.queryFeatures({where:e.where,returnGeometry:!0});if(!a.features.length)return{error:`No features found in geometry layer with the specified where clause: ${e.where}`};let o;if(a.features.length===1){let i=a.features[0].geometry;if(!i)return{error:"The geometry of the first feature is undefined or null."};o=i}else{let i=a.features.map(l=>l.geometry),n=Y.executeMany(i);if(!n)return{error:"Failed to create a combined geometry."};o=n}return{geometry:o}},to=async e=>{let{targetLayer:r,fieldName:t,statisticType:a,mapView:o,layersAndFieldsRegistry:i,geometryLayer:n}=e,l=o.map?.allLayers.find(g=>g.id===r.layerId);if(!l)throw new Error(`Layer '${r.layerId}' not found.`);let d=i.get(r.layerId)?.fieldRegistry.get(t);if(!d)throw new Error(`Field '${t}' not found.`);let c;if(n){let g=await Te(n,o);if("error"in g)throw new Error(g.error);if(c=g.geometry,n.distance&&n.units){let b=We.execute(c,n.distance,{unit:n.units==="us-nautical-miles"?"nautical-miles":n.units});b&&(c=b)}}else c=o.extent.clone();let u=new O({geometry:c,spatialRelationship:"intersects"}),m=null,f=null;try{m=await fe({layer:l,field:t,sqlWhere:r.where,filter:u,outStatisticTypes:{include:[a]}}),d.type==="string"&&(f=(await ge({layer:l,field:t,sqlWhere:r.where,filter:u})).uniqueValueInfos)}catch(g){console.error("Statistics error:",g)}return{tool:"getStatistics",layerName:l.title??r.layerId,summary:`${a} = ${typeof m?.[a]=="number"?m[a]:"N/A"}`,details:{fieldName:t,statisticType:a,statistic:m?.[a]??null,summaryStatistics:m,uniqueValues:f,where:r.where}}},ro=["feet","kilometers","meters","miles","nautical-miles","us-nautical-miles"],ao=s.enum(ro);async function oo({targetLayer:e,fieldName:r,statisticType:t,geometryLayer:a},o){let i=w(o,"layersAndFieldsRegistry"),{mapView:n}=K(o),l=await to({targetLayer:e,fieldName:r,statisticType:t,mapView:n,layersAndFieldsRegistry:i,geometryLayer:a});return console.log(l),JSON.stringify(l,null,2)}var io=s.object({targetLayer:s.object({layerId:s.string().describe("The layerId of the layer containing the field from which to get a value."),where:s.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value.")}),geometryLayer:s.union([s.object({layerId:s.string().describe("The layerId of the layer containing the geometry by which to filter."),where:s.string().describe("The SQL-92 where clause representing the features from which to filter features from the targetLayer by geometry."),distance:s.number().optional().describe("The distance by which to query from the input geometry."),units:ao.optional().describe("The units used to query by geometry and distance.")}),s.object({}).strict()]).optional().describe("Optional geometry-based filtering parameters for spatial queries."),fieldName:s.string().describe("The name of the field for which to get statistics."),statisticType:s.enum(["avg","max","median","min","stddev","sum","variance","nullcount","count"]).describe("The statistic type to calculate.")}),no=p(oo,{name:"getStatistics",description:"Returns one or more summary statistics for the given field. Statistic types include: count, maximum, minimum, average, median, standard deviation, variance, mode, sum, nullcount (number of features without a value for a given field), unique values. Statistics can be returned for number, date, and string fields. Only call this tool when the question requires filtering (e.g. a WHERE clause or spatial constraint) that cannot be satisfied by precomputed stats.",schema:io}),so=async(e,r,t,a)=>{let o=t.map?.allLayers.find(c=>c.id===e.layerId),i=a?await Te(a,t):{geometry:void 0},n="geometry"in i?i.geometry:void 0,l=new Be({where:e.where||"1=1",outFields:e.outFields.length?e.outFields:["*"],orderByFields:e.orderByFields,geometry:n,spatialRelationship:n?"intersects":void 0,distance:a?.distance,units:a?.units,topFilter:new Qe({topCount:r.topCount,groupByFields:r.groupByFields,orderByFields:r.orderByFields})}),d=await o.queryTopFeatures(l);return{tool:"getTopFeatures",layerName:o.title??e.layerId,summary:`Top ${r.topCount} features extracted`,details:{topCount:r.topCount,features:d.features,where:e.where}}},lo=async({targetLayer:e,topFilter:r,geometryLayer:t},a)=>{let{mapView:o}=K(a),i=await so(e,r,o,t);return JSON.stringify(i,null,2)},co=s.object({targetLayer:s.object({layerId:s.string().describe("The layerId of the layer containing the field from which to get a value."),where:s.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value."),orderByFields:s.array(s.string().describe("The field(s) and order for which to sort the resulting features.")),outFields:s.array(s.string().describe("The fields to include in the output that will be presented to the user. This should include identifying information about the resulting features, like a name or id, along with the values desired in the output."))}),geometryLayer:s.object({layerId:s.string().describe("The layerId of the layer containing the geometry by which to filter."),where:s.string().describe("The SQL-92 where clause representing the features from which to filter features from the targetLayer by geometry."),distance:s.number().describe("The distance by which to query from the input geometry."),units:M.describe("The units used to query by geometry and distance.")}).optional().describe("Optional geometry-based filtering parameters for spatial queries."),topFilter:s.object({topCount:s.number().describe("The SQL-92 where clause representing the feature from which to get an attribute value."),orderByFields:s.array(s.string().describe("The field(s) and order for which to sort the resulting features.")),groupByFields:s.array(s.string().describe("The field(s) for which to group by the top features."))})}),uo=p(lo,{name:"getTopFeatures",description:"Returns the top n features from a layer",schema:co}),ho=async(e,r,t)=>{let a=r.map?.allLayers.find(d=>d.id===e.layerId),o=t?await Te(t,r):{geometry:void 0},i="geometry"in o?o.geometry:void 0,n=new ye({where:e.where||"1=1",outFields:e.outFields.length?e.outFields:["*"],orderByFields:e.orderByFields,geometry:i,spatialRelationship:i?"intersects":void 0,distance:t?.distance,units:t?.units}),l=await a.queryFeatures(n);return{tool:"queryFeatures",layerName:a.title??e.layerId,summary:`${l.features.length} features found`,details:{totalCount:l.features.length,features:l.features.slice(0,10),where:e.where}}};async function mo({targetLayer:e,geometryLayer:r},t){let{mapView:a}=K(t),o=await ho(e,a,r);return JSON.stringify(o,null,2)}var fo=s.object({targetLayer:s.object({layerId:s.string().describe("The layerId of the layer containing the field from which to get a value."),where:s.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value."),orderByFields:s.array(s.string().describe("The field(s) and order for which to sort the resulting features.")),outFields:s.array(s.string().describe("The fields to include in the output that will be presented to the user. This should include identifying information about the resulting features, like a name or id, along with the values desired in the output."))}),geometryLayer:s.object({layerId:s.string().describe("The layerId of the layer containing the geometry by which to filter."),where:s.string().describe("The SQL-92 where clause representing the features from which to filter features from the targetLayer by geometry."),distance:s.number().describe("The distance by which to query from the input geometry."),units:M.describe("The units used to query by geometry and distance.")}).optional().describe("Optional geometry-based filtering parameters for spatial queries.")}),go=p(mo,{name:"queryFeatures",description:"Queries for one or more features from a given layer.",schema:fo}),nt=[go,no,eo,uo],yo=async(e,r)=>{await h({text:"Requesting LLM for layer query results"},r);let t=await $("data_query_prompt");if(!r?.configurable)throw new Error("config.configurable is required for layer query tools");let{userTimezone:a,userTimezoneOffset:o}=ee(),i={layerFieldInfo:e.layerFieldInfo,userTimezone:a,userTimezoneOffset:o},n=await C({promptText:t,messages:T(e.messages),inputVariables:i,tools:nt});if(!(n.tool_calls&&Array.isArray(n.tool_calls)&&n.tool_calls.length>0))return{...e,messages:[...e.messages,n]};let l=n.content.toString()||"LLM requested tool calls.";return await Q(n,r),{...e,outputMessage:l,messages:[...e.messages,n]}},po=new R(nt);async function wo(e,r){let{messages:t}=await po.invoke({messages:T(e.messages)},r),a=[],o=[];for(let l of t){let d=l.content;if(typeof d!="string"){console.warn("Skipping non-string tool output:",d);continue}let c;try{c=JSON.parse(d)}catch{console.warn("Skipping invalid JSON from tool:",d);continue}a.push(c),o.push(`- ${c.layerName}: ${c.summary}`)}if(o.length===0)return{...e,queryResponses:a};let i=new z({content:`Query results:
89
90
  ${o.join(`
90
91
  `)}`}),n=`Query results:
91
92
  ${o.join(`
92
- `)}`;return{...e,outputMessage:n,messages:[...e.messages,...t,i],queryResponses:a}}var po=async(e,r)=>{try{await h({text:"Requesting LLM for summary on query results"},r);let t=await F("summarize_query_response_prompt"),a={queryResponse:e.queryResponses},o=await ae({promptText:t,messages:v(e.messages),inputVariables:a}),i=typeof o=="string"?o:o.content;return e.messages=[...e.messages,new j(i)],e.outputMessage=i,await h({text:`Received response from LLM: ${i}`},r),e}catch(t){throw await h({text:"Error during filter LLM request"},r),new Error(`Error during filter LLM request: ${t instanceof Error?t.message:String(t)}`)}},wo=(e,r)=>B(["layerSearch","fieldSearch","layersAndFieldsRegistry"],"Layer Query Agent")(e,r),bo=()=>new q(ot).addNode("requireLayerQueryServices",wo).addNode("vectorSearchLayers",Ka).addNode("vectorSearchFields",Qa).addNode("fieldStatistics",Ga).addNode("agent",fo).addNode("tools",yo).addNode("summarizeQueryResponseLLM",po).addNode("earlyExit",Pa).addEdge(k,"requireLayerQueryServices").addEdge("requireLayerQueryServices","vectorSearchLayers").addConditionalEdges("vectorSearchLayers",e=>e.vectorSearchLayerIds.length?"vectorSearchFields":"earlyExit").addConditionalEdges("vectorSearchFields",e=>e.vectorSearchFieldResults.length?"fieldStatistics":"earlyExit").addEdge("fieldStatistics","agent").addEdge("agent","tools").addConditionalEdges("tools",e=>e.queryResponses.length?"summarizeQueryResponseLLM":"earlyExit").addEdge("summarizeQueryResponseLLM",E).addEdge("earlyExit",E),vo=String.raw`- **layerQuery** — User is asking about the feature layer’s data (e.g. counts, summaries, statistics, field values), either for all features, a subset based on a condition, or for a subset based on the current view. CRITICAL: Always call the Layer Filter Agent after this agent.
93
+ `)}`;return{...e,outputMessage:n,messages:[...e.messages,...t,i],queryResponses:a}}var bo=async(e,r)=>{try{await h({text:"Requesting LLM for summary on query results"},r);let t=await $("summarize_query_response_prompt"),a={queryResponse:e.queryResponses},o=await H({promptText:t,messages:T(e.messages),inputVariables:a}),i=typeof o=="string"?o:o.content;return e.messages=[...e.messages,new z(i)],e.outputMessage=i,await h({text:`Received response from LLM: ${i}`},r),e}catch(t){throw await h({text:"Error during filter LLM request"},r),new Error(`Error during filter LLM request: ${t instanceof Error?t.message:String(t)}`)}},vo=(e,r)=>D(["layerSearch","fieldSearch","layersAndFieldsRegistry"],"Layer Query Agent")(e,r),So=()=>new k(it).addNode("requireLayerQueryServices",vo).addNode("vectorSearchLayers",Ja).addNode("vectorSearchFields",Ka).addNode("fieldStatistics",Qa).addNode("agent",yo).addNode("tools",wo).addNode("summarizeQueryResponseLLM",bo).addNode("earlyExit",Ba).addEdge(F,"requireLayerQueryServices").addEdge("requireLayerQueryServices","vectorSearchLayers").addConditionalEdges("vectorSearchLayers",e=>e.vectorSearchLayerIds.length?"vectorSearchFields":"earlyExit").addConditionalEdges("vectorSearchFields",e=>e.vectorSearchFieldResults.length?"fieldStatistics":"earlyExit").addEdge("fieldStatistics","agent").addEdge("agent","tools").addConditionalEdges("tools",e=>e.queryResponses.length?"summarizeQueryResponseLLM":"earlyExit").addEdge("summarizeQueryResponseLLM",E).addEdge("earlyExit",E),To=String.raw`- **layerQuery** — User is asking about the feature layer’s data (e.g. counts, summaries, statistics, field values), either for all features, a subset based on a condition, or for a subset based on the current view. CRITICAL: Always call the Layer Filter Agent after this agent.
93
94
  This also includes questions that ask which feature meets a given condition or where a particular feature in the data is located (e.g., “Where is the spring with the highest elevation?”).
94
95
  _Example: “How many features are there?”_
95
96
  _Example: “What’s the average population?”_
96
- _Example: “Which values are in the status field?”_`,sl={id:"layerQuery",name:"Layer Query Agent",description:vo,createGraph:bo,workspace:ot},Ve=.7,So=10,To=async(e,r)=>{try{let t=_(e.messages);await h({text:"Similarity search to find fields"},r);let a=b(r,"fieldSearch"),o=b(r,"layersAndFieldsRegistry"),i=b(r,"embeddingCache"),n=await a.searchFields({text:t,layerIds:e.vectorSearchLayerIds,minScore:Ve,topResults:So,embeddingCache:i}),l=n.map(({layerId:d,results:u})=>{let m=u.map(f=>` - ${f.name} (${f.score.toFixed(2)})`).join(`
97
- `);return`${o.get(d)?.layerItem.name??d}:
97
+ _Example: “Which values are in the status field?”_`,yl={id:"layerQuery",name:"Layer Query Agent",description:To,createGraph:So,workspace:it},Oe=.7,Eo=10,xo=async(e,r)=>{try{let t=N(e.messages);await h({text:"Similarity search to find fields"},r);let a=w(r,"fieldSearch"),o=w(r,"layersAndFieldsRegistry"),i=w(r,"embeddingCache"),n=await a.searchFields({text:t,layerIds:e.vectorSearchLayerIds,minScore:Oe,topResults:Eo,embeddingCache:i}),l=n.map(({layerId:c,results:u})=>{let m=u.map(f=>` - ${f.name} (${f.score.toFixed(2)})`).join(`
98
+ `);return`${o.get(c)?.layerItem.name??c}:
98
99
  ${m}`}).join(`
99
- `),c;return n.length>0?c=`Vector search completed. Matching layers and fields with scores:
100
- ${l}`:c=`No vector search results found for score over ${Ve}.`,await h({text:c},r),{...e,vectorSearchFieldResults:n}}catch(t){throw await h({text:`Error during vector search: ${t instanceof Error?t.message:String(t)}`},r),new Error(`Vector search failed: ${t instanceof Error?t.message:String(t)}`)}},Eo=.7,xo=async(e,r)=>{try{let t=_(e.messages);await h({text:`Similarity search to find layers: ${t}`},r);let a=b(r,"layerSearch"),o=b(r,"layersAndFieldsRegistry"),i=await a.searchLayers({text:t,minScore:Eo}),n=i.map(d=>d.id),l=i.map(({id:d,score:u})=>`${o.get(d)?.layerItem.name??d} (${u.toFixed(2)})`).join(`
101
- `),c;return n.length>0?c=`Vector search completed. Matching layers with scores:
102
- ${l}`:c="Vector search completed. No matching layers found.",await h({text:c},r),{...e,vectorSearchLayerIds:n}}catch(t){throw await h({text:`Error during vector search: ${t instanceof Error?t.message:String(t)}`},r),new Error(`Vector search failed: ${t instanceof Error?t.message:String(t)}`)}};async function Io(e){let{fields:r,layer:t,view:a,styleName:o,colorSchemeTags:i}=e,n;return i?n=pt({basemapTheme:await ke(a),geometryType:t.geometryType,includedTags:i,numColors:Math.min(r.length,8)})[0]:n=wt({basemapTheme:await ke(a),geometryType:t.geometryType,numColors:Math.min(r.length,8)}).primaryScheme,{layer:t,view:a,attributes:r.map(l=>({field:l,label:t.fields.find(c=>c.name===l)?.alias??""})).slice(0,8),outlineOptimizationEnabled:!0,sizeOptimizationEnabled:!0,includeSizeVariable:o.includes("Size"),pieChartScheme:n}}async function Lo(e){return await yt(e)}async function $o({arcgisMap:e,arcgisMapView:r,layerId:t,fields:a,colorSchemes:o,includeSize:i}){let n=r,l=e?.allLayers.find(d=>d.id===t);if(!l)return`Could not find layer for id: ${t}`;let c={styleName:i?"chart-size":"chart",fields:a,layer:l,view:n,colorSchemeTags:o};try{let d=await Io(c),u=await Lo(d);return l.renderer=u.renderer,l.visible=!0,`Chart renderer applied to layer: ${l.title??l.id} using fields ${a.join(", ")}`}catch(d){return`Error applying chart renderer: ${d instanceof Error?d.message:String(d)}`}}var Fo=["mapView"];function I(e){let r=e?.configurable?.context;if(!r||typeof r!="object")throw new Error("LayerStylingAgent context missing");let t=Fo.filter(a=>!(a in r));if(t.length)throw new Error(`LayerStylingAgent context missing: ${t.join(", ")}`);return r}async function _o({layerId:e,fields:r,colorSchemes:t,includeSize:a},o){let{mapView:i}=I(o);return await x({id:"show-legend",description:"Show Legend",payload:{layerIds:[e]}},o),await $o({arcgisMap:i.map,arcgisMapView:i,layerId:e,fields:r,colorSchemes:t,includeSize:a})}var No=s.object({layerId:s.string().describe("The id of the layer to apply the chart renderer to"),fields:s.array(s.string()).describe("The fields to use for the chart renderer (multiple numeric fields)"),colorSchemes:s.array(s.string()).optional().describe("Optional color scheme tags to use"),includeSize:s.boolean().optional().describe("Whether to vary the chart size (chart-size)")}),ko=p(_o,{name:"chart",description:`Label: Charts
100
+ `),d;return n.length>0?d=`Vector search completed. Matching layers and fields with scores:
101
+ ${l}`:d=`No vector search results found for score over ${Oe}.`,await h({text:d},r),{...e,vectorSearchFieldResults:n}}catch(t){throw await h({text:`Error during vector search: ${t instanceof Error?t.message:String(t)}`},r),new Error(`Vector search failed: ${t instanceof Error?t.message:String(t)}`)}},Io=.7,$o=async(e,r)=>{try{let t=N(e.messages);await h({text:`Similarity search to find layers: ${t}`},r);let a=w(r,"layerSearch"),o=w(r,"layersAndFieldsRegistry"),i=await a.searchLayers({text:t,minScore:Io}),n=i.map(c=>c.id),l=i.map(({id:c,score:u})=>`${o.get(c)?.layerItem.name??c} (${u.toFixed(2)})`).join(`
102
+ `),d;return n.length>0?d=`Vector search completed. Matching layers with scores:
103
+ ${l}`:d="Vector search completed. No matching layers found.",await h({text:d},r),{...e,vectorSearchLayerIds:n}}catch(t){throw await h({text:`Error during vector search: ${t instanceof Error?t.message:String(t)}`},r),new Error(`Vector search failed: ${t instanceof Error?t.message:String(t)}`)}};async function Lo(e){let{fields:r,layer:t,view:a,styleName:o,colorSchemeTags:i}=e,n;return i?n=bt({basemapTheme:await qe(a),geometryType:t.geometryType,includedTags:i,numColors:Math.min(r.length,8)})[0]:n=vt({basemapTheme:await qe(a),geometryType:t.geometryType,numColors:Math.min(r.length,8)}).primaryScheme,{layer:t,view:a,attributes:r.map(l=>({field:l,label:t.fields.find(d=>d.name===l)?.alias??""})).slice(0,8),outlineOptimizationEnabled:!0,sizeOptimizationEnabled:!0,includeSizeVariable:o.includes("Size"),pieChartScheme:n}}async function Fo(e){return await wt(e)}async function _o({arcgisMap:e,arcgisMapView:r,layerId:t,fields:a,colorSchemes:o,includeSize:i}){let n=r,l=e?.allLayers.find(c=>c.id===t);if(!l)return`Could not find layer for id: ${t}`;let d={styleName:i?"chart-size":"chart",fields:a,layer:l,view:n,colorSchemeTags:o};try{let c=await Lo(d),u=await Fo(c);return l.renderer=u.renderer,l.visible=!0,`Chart renderer applied to layer: ${l.title??l.id} using fields ${a.join(", ")}`}catch(c){return`Error applying chart renderer: ${c instanceof Error?c.message:String(c)}`}}var ko=["mapView"];function L(e){let r=e?.configurable?.context;if(!r||typeof r!="object")throw new Error("LayerStylingAgent context missing");let t=ko.filter(a=>!(a in r));if(t.length)throw new Error(`LayerStylingAgent context missing: ${t.join(", ")}`);return r}async function No({layerId:e,fields:r,colorSchemes:t,includeSize:a},o){let{mapView:i}=L(o);return await x({id:"show-legend",description:"Show Legend",payload:{layerIds:[e]}},o),await _o({arcgisMap:i.map,arcgisMapView:i,layerId:e,fields:r,colorSchemes:t,includeSize:a})}var qo=s.object({layerId:s.string().describe("The id of the layer to apply the chart renderer to"),fields:s.array(s.string()).describe("The fields to use for the chart renderer (multiple numeric fields)"),colorSchemes:s.array(s.string()).optional().describe("Optional color scheme tags to use"),includeSize:s.boolean().optional().describe("Whether to vary the chart size (chart-size)")}),Ao=p(No,{name:"chart",description:`Label: Charts
103
104
  Description: Show the values of two or more categories as a proportion of the total using a pie chart.
104
105
  Keywords: pie, chart, all categories, breakdown, proportion
105
106
  Example: Show the total number of homes built in each decade using a pie chart for each feature.
@@ -109,19 +110,19 @@ ${l}`:c="Vector search completed. No matching layers found.",await h({text:c},r)
109
110
  Description: Show the values of two or more categories as a proportion of the total using a pie chart and use size to capture the total amount or magnitude.
110
111
  Keywords: pie, chart, all categories, breakdown, proportion, total, amount, how much, sum, graduated size, proportional size
111
112
  Example: Show the total number of homes built in each decade using a pie chart for each feature and vary the size of each chart based on the total of all categories.
112
- Fields: This style requires 2-8 number fields.`,schema:No});function qo(e){let{fields:r,layer:t,view:a,theme:o,colorSchemeTags:i}=e,n=r[0],l;return i&&(l=ye({geometryType:t.geometryType,includedTags:i,theme:o||"high-to-low"})[0]),{layer:t,view:a,startTime:n,endTime:new Date,theme:o,sizeOptimizationEnabled:!0,outlineOptimizationEnabled:!0,colorScheme:l}}async function Ao(e){return await bt(e)}async function Ro({arcgisMap:e,arcgisMapView:r,layerId:t,fields:a,colorSchemes:o,theme:i}){let n=r,l=e?.allLayers.find(d=>d.id===t);if(!l)return`Could not find layer for id: ${t}`;let c={styleName:"color-age",fields:a,layer:l,view:n,colorSchemeTags:o,theme:i};try{let d=qo(c),u=await Ao(d);return l.renderer=u.renderer,l.visible=!0,`Color-age renderer applied to layer: ${l.title??l.id} using fields ${a.join(", ")}`}catch(d){return`Error applying color-age renderer: ${d instanceof Error?d.message:String(d)}`}}async function Mo({layerId:e,fields:r,colorSchemes:t,theme:a},o){let{mapView:i}=I(o);return await x({id:"show-legend",description:"Show Legend",payload:{layerIds:[e]}},o),await Ro({arcgisMap:i.map,arcgisMapView:i,layerId:e,fields:r,colorSchemes:t,theme:a})}var zo=s.object({layerId:s.string().describe("The id of the layer to apply the color-age renderer to"),fields:s.array(s.string()).describe("The field(s) to use for the color-age renderer (temporal/date data)"),colorSchemes:s.array(s.string()).optional().describe("Optional color scheme tags to use"),theme:s.enum(["above-and-below","above","below","centered-on","extremes","high-to-low"]).optional().describe("Optional theme for the color ramp")}),Co=p(Mo,{name:"color-age",description:`Label: Age (color)
113
+ Fields: This style requires 2-8 number fields.`,schema:qo});function Ro(e){let{fields:r,layer:t,view:a,theme:o,colorSchemeTags:i}=e,n=r[0],l;return i&&(l=pe({geometryType:t.geometryType,includedTags:i,theme:o||"high-to-low"})[0]),{layer:t,view:a,startTime:n,endTime:new Date,theme:o,sizeOptimizationEnabled:!0,outlineOptimizationEnabled:!0,colorScheme:l}}async function Mo(e){return await St(e)}async function zo({arcgisMap:e,arcgisMapView:r,layerId:t,fields:a,colorSchemes:o,theme:i}){let n=r,l=e?.allLayers.find(c=>c.id===t);if(!l)return`Could not find layer for id: ${t}`;let d={styleName:"color-age",fields:a,layer:l,view:n,colorSchemeTags:o,theme:i};try{let c=Ro(d),u=await Mo(c);return l.renderer=u.renderer,l.visible=!0,`Color-age renderer applied to layer: ${l.title??l.id} using fields ${a.join(", ")}`}catch(c){return`Error applying color-age renderer: ${c instanceof Error?c.message:String(c)}`}}async function Co({layerId:e,fields:r,colorSchemes:t,theme:a},o){let{mapView:i}=L(o);return await x({id:"show-legend",description:"Show Legend",payload:{layerIds:[e]}},o),await zo({arcgisMap:i.map,arcgisMapView:i,layerId:e,fields:r,colorSchemes:t,theme:a})}var jo=s.object({layerId:s.string().describe("The id of the layer to apply the color-age renderer to"),fields:s.array(s.string()).describe("The field(s) to use for the color-age renderer (temporal/date data)"),colorSchemes:s.array(s.string()).optional().describe("Optional color scheme tags to use"),theme:s.enum(["above-and-below","above","below","centered-on","extremes","high-to-low"]).optional().describe("Optional theme for the color ramp")}),Vo=p(Co,{name:"color-age",description:`Label: Age (color)
113
114
  Description: Use colors along a continuous color ramp to represent the age of features. Age reflects the length of time from a start date to an end date.
114
115
  Keywords: since, age, how old, how long
115
116
  Example: Show the age of each feature based on its reported date.
116
- Fields: This style requires at least one field with a date type.`,schema:zo});function jo(e){let{fields:r,layer:t,view:a,colorSchemeTags:o}=e,{theme:i}=e,n=r[1],l=r[0],c;return o&&(c=ye({geometryType:t.geometryType,includedTags:o,theme:i||"high-to-low"})[0]),{layer:t,view:a,field:l,normalizationField:n,theme:i,sizeOptimizationEnabled:!0,outlineOptimizationEnabled:!0,colorScheme:c}}async function Vo(e){return await vt(e)}async function Oo({arcgisMap:e,arcgisMapView:r,layerId:t,fields:a,colorSchemes:o,theme:i}){let n=r,l=e?.allLayers.find(d=>d.id===t);if(!l)return`Could not find layer for id: ${t}`;let c={styleName:"color",fields:a,layer:l,view:n,colorSchemeTags:o,theme:i};try{let d=jo(c),u=await Vo(d);return l.renderer=u.renderer,l.visible=!0,`Color renderer applied to layer: ${l.title??l.id} using fields ${a.join(", ")}`}catch(d){return`Error applying color renderer: ${d instanceof Error?d.message:String(d)}`}}async function Do({layerId:e,fields:r,colorSchemes:t,theme:a},o){let{mapView:i}=I(o);return await x({id:"show-legend",description:"Show Legend",payload:{layerIds:[e]}},o),await Oo({arcgisMap:i.map,arcgisMapView:i,layerId:e,fields:r,colorSchemes:t,theme:a})}var Po=s.object({layerId:s.string().describe("The id of the layer to apply the color renderer to"),fields:s.array(s.string()).describe("The field(s) to use for the color renderer"),colorSchemes:s.array(s.string()).optional().describe("Optional color scheme tags to use"),theme:s.enum(["above-and-below","above","below","centered-on","extremes","high-to-low"]).optional().describe("Optional theme for the color ramp")}),Go=p(Do,{name:"color",description:`Label: Counts and Amounts (color)
117
+ Fields: This style requires at least one field with a date type.`,schema:jo});function Oo(e){let{fields:r,layer:t,view:a,colorSchemeTags:o}=e,{theme:i}=e,n=r[1],l=r[0],d;return o&&(d=pe({geometryType:t.geometryType,includedTags:o,theme:i||"high-to-low"})[0]),{layer:t,view:a,field:l,normalizationField:n,theme:i,sizeOptimizationEnabled:!0,outlineOptimizationEnabled:!0,colorScheme:d}}async function Do(e){return await Tt(e)}async function Po({arcgisMap:e,arcgisMapView:r,layerId:t,fields:a,colorSchemes:o,theme:i}){let n=r,l=e?.allLayers.find(c=>c.id===t);if(!l)return`Could not find layer for id: ${t}`;let d={styleName:"color",fields:a,layer:l,view:n,colorSchemeTags:o,theme:i};try{let c=Oo(d),u=await Do(c);return l.renderer=u.renderer,l.visible=!0,`Color renderer applied to layer: ${l.title??l.id} using fields ${a.join(", ")}`}catch(c){return`Error applying color renderer: ${c instanceof Error?c.message:String(c)}`}}async function Go({layerId:e,fields:r,colorSchemes:t,theme:a},o){let{mapView:i}=L(o);return await x({id:"show-legend",description:"Show Legend",payload:{layerIds:[e]}},o),await Po({arcgisMap:i.map,arcgisMapView:i,layerId:e,fields:r,colorSchemes:t,theme:a})}var Bo=s.object({layerId:s.string().describe("The id of the layer to apply the color renderer to"),fields:s.array(s.string()).describe("The field(s) to use for the color renderer"),colorSchemes:s.array(s.string()).optional().describe("Optional color scheme tags to use"),theme:s.enum(["above-and-below","above","below","centered-on","extremes","high-to-low"]).optional().describe("Optional theme for the color ramp")}),Qo=p(Go,{name:"color",description:`Label: Counts and Amounts (color)
117
118
  Description: Vary color along a continuous color ramp to represent numeric or ranked data.
118
119
  Keywords: graduated color, choropleth, continuous color, hue, color, gradation, saturation, lightness, percent, rate, ratio, index, how much, increase, decrease
119
120
  Example: Color each feature based on the population density.
120
- Fields: This style requires a single field with a number type. A second number field may be specified for normalizing the value of the first field.`,schema:Po});function Bo(e){let{fields:r,layer:t,view:a,colorSchemeTags:o,theme:i}=e,n,l,c=r[0];return o&&(l=ye({geometryType:t.geometryType,includedTags:o,theme:i||"high-to-low"})[0]),{layer:t,view:a,field:c,normalizationField:n,theme:i,colorOptions:{colorScheme:l}}}async function Qo(e){return await St(e)}async function Wo({arcgisMap:e,arcgisMapView:r,layerId:t,fields:a,colorSchemes:o,theme:i}){let n=r,l=e?.allLayers.find(d=>d.id===t);if(!l)return`Could not find layer for id: ${t}`;let c={styleName:"color-size-univariate",fields:a,layer:l,view:n,colorSchemeTags:o,theme:i};try{let d=Bo(c),u=await Qo(d);return l.renderer=u.renderer,l.visible=!0,`Color-size-univariate renderer applied to layer: ${l.title??l.id} using fields ${a.join(", ")}`}catch(d){return`Error applying color-size-univariate renderer: ${d instanceof Error?d.message:String(d)}`}}async function Ko({layerId:e,fields:r,colorSchemes:t,theme:a},o){let{mapView:i}=I(o);return await x({id:"show-legend",description:"Show Legend",payload:{layerIds:[e]}},o),await Wo({arcgisMap:i.map,arcgisMapView:i,layerId:e,fields:r,colorSchemes:t,theme:a})}var Uo=s.object({layerId:s.string().describe("The id of the layer to apply the color-size univariate renderer to"),fields:s.array(s.string()).describe("The fields to use for the color-size univariate renderer"),colorSchemes:s.array(s.string()).optional().describe("Optional color scheme tags to use"),theme:s.enum(["above-and-below","above","below","centered-on","extremes","high-to-low"]).optional().describe("Optional theme for the color and size ramps")}),Jo=p(Ko,{name:"color-size-univariate",description:`Label: Color and Size (univariate)
121
+ Fields: This style requires a single field with a number type. A second number field may be specified for normalizing the value of the first field.`,schema:Bo});function Wo(e){let{fields:r,layer:t,view:a,colorSchemeTags:o,theme:i}=e,n,l,d=r[0];return o&&(l=pe({geometryType:t.geometryType,includedTags:o,theme:i||"high-to-low"})[0]),{layer:t,view:a,field:d,normalizationField:n,theme:i,colorOptions:{colorScheme:l}}}async function Ko(e){return await Et(e)}async function Uo({arcgisMap:e,arcgisMapView:r,layerId:t,fields:a,colorSchemes:o,theme:i}){let n=r,l=e?.allLayers.find(c=>c.id===t);if(!l)return`Could not find layer for id: ${t}`;let d={styleName:"color-size-univariate",fields:a,layer:l,view:n,colorSchemeTags:o,theme:i};try{let c=Wo(d),u=await Ko(c);return l.renderer=u.renderer,l.visible=!0,`Color-size-univariate renderer applied to layer: ${l.title??l.id} using fields ${a.join(", ")}`}catch(c){return`Error applying color-size-univariate renderer: ${c instanceof Error?c.message:String(c)}`}}async function Jo({layerId:e,fields:r,colorSchemes:t,theme:a},o){let{mapView:i}=L(o);return await x({id:"show-legend",description:"Show Legend",payload:{layerIds:[e]}},o),await Uo({arcgisMap:i.map,arcgisMapView:i,layerId:e,fields:r,colorSchemes:t,theme:a})}var Ho=s.object({layerId:s.string().describe("The id of the layer to apply the color-size univariate renderer to"),fields:s.array(s.string()).describe("The fields to use for the color-size univariate renderer"),colorSchemes:s.array(s.string()).optional().describe("Optional color scheme tags to use"),theme:s.enum(["above-and-below","above","below","centered-on","extremes","high-to-low"]).optional().describe("Optional theme for the color and size ramps")}),Zo=p(Jo,{name:"color-size-univariate",description:`Label: Color and Size (univariate)
121
122
  Description: Vary symbol size and color based on the values of two numeric attributes.
122
123
  Keywords: continuous color, hue, color, size, gradation, saturation, lightness, percent, rate, ratio, index, how much, increase, decrease, amount
123
124
  Example: Color each feature based on the percentage of the population that owns a home and vary the size of each point based on total population.
124
- Fields: This style requires at least two fields: one determining the color of each feature, the other determining the size of each feature. Each field may be normalized by an additional normalization field.`,schema:Uo});function Zo(e){let{fields:r,layer:t,view:a,colorSchemeTags:o}=e,i;return o&&(i=Et({includedTags:o,numColors:Math.min(r.length,8)})[0]),{layer:t,view:a,legendOptions:{unit:"units"},attributes:r.map(n=>({field:n,label:t.fields.find(l=>l.name===n)?.alias??""})).slice(0,8),outlineOptimizationEnabled:!0,dotDensityScheme:i}}async function Ho(e){return await Tt(e)}async function Yo({arcgisMap:e,arcgisMapView:r,layerId:t,fields:a,colorSchemes:o}){let i=r,n=e?.allLayers.find(c=>c.id===t);if(!n)return`Could not find layer for id: ${t}`;let l={styleName:"dot-density",fields:a,layer:n,view:i,colorSchemeTags:o};try{let c=Zo(l),d=await Ho(c);return n.renderer=d.renderer,n.visible=!0,`Dot Density renderer applied to layer: ${n.title??n.id} using fields ${a.join(", ")}`}catch(c){return`Error applying dot density renderer: ${c instanceof Error?c.message:String(c)}`}}async function Xo({layerId:e,fields:r,colorSchemes:t},a){let{mapView:o}=I(a);return await x({id:"show-legend",description:"Show Legend",payload:{layerIds:[e]}},a),await Yo({arcgisMap:o.map,arcgisMapView:o,layerId:e,fields:r,colorSchemes:t})}var ei=s.object({layerId:s.string().describe("The id of the layer to apply the dot density renderer to"),fields:s.array(s.string()).describe("The field(s) to use for the dot density renderer (population or count data)"),colorSchemes:s.array(s.string()).optional().describe("Optional color scheme tags to use")}),ti=p(Xo,{name:"dot-density",description:`Dot Density
125
+ Fields: This style requires at least two fields: one determining the color of each feature, the other determining the size of each feature. Each field may be normalized by an additional normalization field.`,schema:Ho});function Xo(e){let{fields:r,layer:t,view:a,colorSchemeTags:o}=e,i;return o&&(i=It({includedTags:o,numColors:Math.min(r.length,8)})[0]),{layer:t,view:a,legendOptions:{unit:"units"},attributes:r.map(n=>({field:n,label:t.fields.find(l=>l.name===n)?.alias??""})).slice(0,8),outlineOptimizationEnabled:!0,dotDensityScheme:i}}async function Yo(e){return await xt(e)}async function ei({arcgisMap:e,arcgisMapView:r,layerId:t,fields:a,colorSchemes:o}){let i=r,n=e?.allLayers.find(d=>d.id===t);if(!n)return`Could not find layer for id: ${t}`;let l={styleName:"dot-density",fields:a,layer:n,view:i,colorSchemeTags:o};try{let d=Xo(l),c=await Yo(d);return n.renderer=c.renderer,n.visible=!0,`Dot Density renderer applied to layer: ${n.title??n.id} using fields ${a.join(", ")}`}catch(d){return`Error applying dot density renderer: ${d instanceof Error?d.message:String(d)}`}}async function ti({layerId:e,fields:r,colorSchemes:t},a){let{mapView:o}=L(a);return await x({id:"show-legend",description:"Show Legend",payload:{layerIds:[e]}},a),await ei({arcgisMap:o.map,arcgisMapView:o,layerId:e,fields:r,colorSchemes:t})}var ri=s.object({layerId:s.string().describe("The id of the layer to apply the dot density renderer to"),fields:s.array(s.string()).describe("The field(s) to use for the dot density renderer (population or count data)"),colorSchemes:s.array(s.string()).optional().describe("Optional color scheme tags to use")}),ai=p(ti,{name:"dot-density",description:`Dot Density
125
126
  Use dot density to visualize the distribution of one attribute or compare the density of multiple attributes. This is only valid for polygon layers.
126
127
  **Use cases:**
127
128
  - Population distribution visualization
@@ -132,11 +133,11 @@ ${l}`:c="Vector search completed. No matching layers found.",await h({text:c},r)
132
133
  - Visualize distribution of different crops across regions
133
134
  - Display demographic patterns within census tracts
134
135
  **Fields:** Requires 2-8 number fields.
135
- **Keywords:** density, how much, how many, total, number, amount`,schema:ei});function ri(e){let{fields:r,layer:t,view:a,colorSchemeTags:o}=e,i,n=r[0];return o&&(i=It({includedTags:o,basemap:a.map?.basemap||"topo"})[0]),{layer:t,view:a,field:n,heatmapScheme:i}}async function ai(e){return await xt(e)}async function oi({arcgisMap:e,arcgisMapView:r,layerId:t,fields:a,colorSchemes:o}){let i=r,n=e?.allLayers.find(c=>c.id===t);if(!n)return`Could not find layer for id: ${t}`;let l={styleName:"heatmap",fields:a,layer:n,view:i,colorSchemeTags:o};try{let c=ri(l),d=await ai(c);return n.renderer=d.renderer,n.visible=!0,`Heatmap renderer applied to layer: ${n.title??n.id} using fields ${a.join(", ")}`}catch(c){return`Error applying heatmap renderer: ${c instanceof Error?c.message:String(c)}`}}async function ii({layerId:e,fields:r,colorSchemes:t},a){let{mapView:o}=I(a);return await x({id:"show-legend",description:"Show Legend",payload:{layerIds:[e]}},a),await oi({arcgisMap:o.map,arcgisMapView:o,layerId:e,fields:r,colorSchemes:t})}var ni=s.object({layerId:s.string().describe("The id of the layer to apply the heatmap renderer to"),fields:s.array(s.string()).describe("The field(s) to use for the heatmap renderer (typically point density)"),colorSchemes:s.array(s.string()).optional().describe("Optional color scheme tags to use")}),si=p(ii,{name:"heatmap",description:`Label: Heat Map
136
+ **Keywords:** density, how much, how many, total, number, amount`,schema:ri});function oi(e){let{fields:r,layer:t,view:a,colorSchemeTags:o}=e,i,n=r[0];return o&&(i=Lt({includedTags:o,basemap:a.map?.basemap||"topo"})[0]),{layer:t,view:a,field:n,heatmapScheme:i}}async function ii(e){return await $t(e)}async function ni({arcgisMap:e,arcgisMapView:r,layerId:t,fields:a,colorSchemes:o}){let i=r,n=e?.allLayers.find(d=>d.id===t);if(!n)return`Could not find layer for id: ${t}`;let l={styleName:"heatmap",fields:a,layer:n,view:i,colorSchemeTags:o};try{let d=oi(l),c=await ii(d);return n.renderer=c.renderer,n.visible=!0,`Heatmap renderer applied to layer: ${n.title??n.id} using fields ${a.join(", ")}`}catch(d){return`Error applying heatmap renderer: ${d instanceof Error?d.message:String(d)}`}}async function si({layerId:e,fields:r,colorSchemes:t},a){let{mapView:o}=L(a);return await x({id:"show-legend",description:"Show Legend",payload:{layerIds:[e]}},a),await ni({arcgisMap:o.map,arcgisMapView:o,layerId:e,fields:r,colorSchemes:t})}var li=s.object({layerId:s.string().describe("The id of the layer to apply the heatmap renderer to"),fields:s.array(s.string()).describe("The field(s) to use for the heatmap renderer (typically point density)"),colorSchemes:s.array(s.string()).optional().describe("Optional color scheme tags to use")}),ci=p(si,{name:"heatmap",description:`Label: Heat Map
136
137
  Description: Show areas of high density with colors that appear to glow hotter. This is only valid for point layers.
137
138
  Keywords: density, heatmap, hot spots, pattern, cluster
138
139
  Example: Create a heatmap
139
- Fields: This typically requires zero or one field of type number.`,schema:ni});function li(e){let{fields:r,layer:t,view:a,styleName:o,colorSchemeTags:i}=e,n;return i&&(n=$t({geometryType:t.geometryType,includedTags:i,numColors:Math.min(r.length,10)})[0]),{layer:t,view:a,fields:r.map(l=>({name:l})).slice(0,9),outlineOptimizationEnabled:!0,sizeOptimizationEnabled:!0,includeSizeVariable:o.includes("Size"),predominanceScheme:n}}async function ci(e){return await Lt(e)}async function di({arcgisMap:e,arcgisMapView:r,layerId:t,fields:a,colorSchemes:o,includeSize:i}){let n=r,l=e?.allLayers.find(d=>d.id===t);if(!l)return`Could not find layer for id: ${t}`;let c={styleName:i?"predominance-size":"predominance",fields:a,layer:l,view:n,colorSchemeTags:o};try{let d=li(c),u=await ci(d);return l.renderer=u.renderer,l.visible=!0,`Predominance renderer applied to layer: ${l.title??l.id} using fields ${a.join(", ")}`}catch(d){return`Error applying predominance renderer: ${d instanceof Error?d.message:String(d)}`}}async function ui({layerId:e,fields:r,colorSchemes:t,includeSize:a},o){let{mapView:i}=I(o);return await x({id:"show-legend",description:"Show Legend",payload:{layerIds:[e]}},o),await di({arcgisMap:i.map,arcgisMapView:i,layerId:e,fields:r,colorSchemes:t,includeSize:a})}var hi=s.object({layerId:s.string().describe("The id of the layer to apply the predominance renderer to"),fields:s.array(s.string()).describe("The fields to use for the predominance renderer (competing categories)"),colorSchemes:s.array(s.string()).optional().describe("Optional color scheme tags to use"),includeSize:s.boolean().optional().describe("Whether to include size visualization (predominance-size)")}),mi=p(ui,{name:"predominance",description:`Label: Predominant category
140
+ Fields: This typically requires zero or one field of type number.`,schema:li});function di(e){let{fields:r,layer:t,view:a,styleName:o,colorSchemeTags:i}=e,n;return i&&(n=_t({geometryType:t.geometryType,includedTags:i,numColors:Math.min(r.length,10)})[0]),{layer:t,view:a,fields:r.map(l=>({name:l})).slice(0,9),outlineOptimizationEnabled:!0,sizeOptimizationEnabled:!0,includeSizeVariable:o.includes("Size"),predominanceScheme:n}}async function ui(e){return await Ft(e)}async function hi({arcgisMap:e,arcgisMapView:r,layerId:t,fields:a,colorSchemes:o,includeSize:i}){let n=r,l=e?.allLayers.find(c=>c.id===t);if(!l)return`Could not find layer for id: ${t}`;let d={styleName:i?"predominance-size":"predominance",fields:a,layer:l,view:n,colorSchemeTags:o};try{let c=di(d),u=await ui(c);return l.renderer=u.renderer,l.visible=!0,`Predominance renderer applied to layer: ${l.title??l.id} using fields ${a.join(", ")}`}catch(c){return`Error applying predominance renderer: ${c instanceof Error?c.message:String(c)}`}}async function mi({layerId:e,fields:r,colorSchemes:t,includeSize:a},o){let{mapView:i}=L(o);return await x({id:"show-legend",description:"Show Legend",payload:{layerIds:[e]}},o),await hi({arcgisMap:i.map,arcgisMapView:i,layerId:e,fields:r,colorSchemes:t,includeSize:a})}var fi=s.object({layerId:s.string().describe("The id of the layer to apply the predominance renderer to"),fields:s.array(s.string()).describe("The fields to use for the predominance renderer (competing categories)"),colorSchemes:s.array(s.string()).optional().describe("Optional color scheme tags to use"),includeSize:s.boolean().optional().describe("Whether to include size visualization (predominance-size)")}),gi=p(mi,{name:"predominance",description:`Label: Predominant category
140
141
  Description: Compare attributes that share a common subject and unit of measurement to see which has the highest value.
141
142
  Keywords: predominant, winner, won, competing, most, most common, most frequent, dominant, prevalent, top
142
143
  Example: Using fields for Corn Acres, Wheat Acres, and Cotton Acres, show the predominant crop harvested in each area.
@@ -146,15 +147,15 @@ Fields: This typically requires zero or one field of type number.`,schema:ni});f
146
147
  Description: Compare attributes that share a common subject and unit of measurement to see which has the highest value. Also varies the size of each symbol based on the total of all categories.
147
148
  Keywords: predominant, winner, won, competing, most, most common, most frequent, dominant, prevalent, top, amount, total, how much, proportional size, graduated size, sum
148
149
  Example: Show the predominant crop in each area and vary the size of each symbol based on the total of all categories.
149
- Fields: This style relies on 2-10 number fields.`,schema:hi});function fi(e){let{fields:r,layer:t,view:a,colorSchemeTags:o}=e,i,n={field:r[0]},l={field:r[1]};return o&&(i=_t({geometryType:t.geometryType,includedTags:o})[0]),{layer:t,view:a,field1:n,field2:l,outlineOptimizationEnabled:!0,sizeOptimizationEnabled:!0,relationshipScheme:i}}async function gi(e){return await Ft(e)}async function yi({arcgisMap:e,arcgisMapView:r,layerId:t,fields:a,colorSchemes:o}){let i=r,n=e?.allLayers.find(c=>c.id===t);if(!n)return`Could not find layer for id: ${t}`;let l={styleName:"relationship",fields:a,layer:n,view:i,colorSchemeTags:o};try{let c=fi(l),d=await gi(c);return n.renderer=d.renderer,n.visible=!0,`Relationship renderer applied to layer: ${n.title??n.id} using fields ${a.join(", ")}`}catch(c){return`Error applying relationship renderer: ${c instanceof Error?c.message:String(c)}`}}async function pi({layerId:e,fields:r,colorSchemes:t},a){let{mapView:o}=I(a);return await x({id:"show-legend",description:"Show Legend",payload:{layerIds:[e]}},a),await yi({arcgisMap:o.map,arcgisMapView:o,layerId:e,fields:r,colorSchemes:t})}var wi=s.object({layerId:s.string().describe("The id of the layer to apply the relationship renderer to"),fields:s.array(s.string()).describe("The two fields to use for the relationship renderer (bivariate visualization)"),colorSchemes:s.array(s.string()).optional().describe("Optional color scheme tags to use")}),bi=p(pi,{name:"relationship",description:`Label: Relationship
150
+ Fields: This style relies on 2-10 number fields.`,schema:fi});function yi(e){let{fields:r,layer:t,view:a,colorSchemeTags:o}=e,i,n={field:r[0]},l={field:r[1]};return o&&(i=Nt({geometryType:t.geometryType,includedTags:o})[0]),{layer:t,view:a,field1:n,field2:l,outlineOptimizationEnabled:!0,sizeOptimizationEnabled:!0,relationshipScheme:i}}async function pi(e){return await kt(e)}async function wi({arcgisMap:e,arcgisMapView:r,layerId:t,fields:a,colorSchemes:o}){let i=r,n=e?.allLayers.find(d=>d.id===t);if(!n)return`Could not find layer for id: ${t}`;let l={styleName:"relationship",fields:a,layer:n,view:i,colorSchemeTags:o};try{let d=yi(l),c=await pi(d);return n.renderer=c.renderer,n.visible=!0,`Relationship renderer applied to layer: ${n.title??n.id} using fields ${a.join(", ")}`}catch(d){return`Error applying relationship renderer: ${d instanceof Error?d.message:String(d)}`}}async function bi({layerId:e,fields:r,colorSchemes:t},a){let{mapView:o}=L(a);return await x({id:"show-legend",description:"Show Legend",payload:{layerIds:[e]}},a),await wi({arcgisMap:o.map,arcgisMapView:o,layerId:e,fields:r,colorSchemes:t})}var vi=s.object({layerId:s.string().describe("The id of the layer to apply the relationship renderer to"),fields:s.array(s.string()).describe("The two fields to use for the relationship renderer (bivariate visualization)"),colorSchemes:s.array(s.string()).optional().describe("Optional color scheme tags to use")}),Si=p(bi,{name:"relationship",description:`Label: Relationship
150
151
  Description: Overlays two color ramps to represent the relationship between two numeric attributes.
151
152
  Keywords: relationship, correlation, compare, related, bivariate choropleth, bivariate color
152
153
  Example: Show the relationship between tree height and carbon storage
153
- Fields: This style requires two number fields.`,schema:wi});function vi(e){let{fields:r,layer:t,view:a,theme:o}=e,i=r[0];return{layer:t,view:a,startTime:i,endTime:new Date,theme:o,sizeOptimizationEnabled:!0,outlineOptimizationEnabled:!0}}async function Si(e){return await Nt(e)}async function Ti({arcgisMap:e,arcgisMapView:r,layerId:t,fields:a,colorSchemes:o,theme:i}){let n=r,l=e?.allLayers.find(d=>d.id===t);if(!l)return`Could not find layer for id: ${t}`;let c={styleName:"size-age",fields:a,layer:l,view:n,colorSchemeTags:o,theme:i};try{let d=vi(c),u=await Si(d);return l.renderer=u.renderer,l.visible=!0,`Size-age renderer applied to layer: ${l.title??l.id} using fields ${a.join(", ")}`}catch(d){return`Error applying size-age renderer: ${d instanceof Error?d.message:String(d)}`}}async function Ei({layerId:e,fields:r,colorSchemes:t,theme:a},o){let{mapView:i}=I(o);return await x({id:"show-legend",description:"Show Legend",payload:{layerIds:[e]}},o),await Ti({arcgisMap:i.map,arcgisMapView:i,layerId:e,fields:r,colorSchemes:t,theme:a})}var xi=s.object({layerId:s.string().describe("The id of the layer to apply the size-age renderer to"),fields:s.array(s.string()).describe("The field(s) to use for the size-age renderer (temporal data with size)"),colorSchemes:s.array(s.string()).optional().describe("Optional color scheme tags to use"),theme:s.enum(["above-and-below","above","below","centered-on","extremes","high-to-low"]).optional().describe("Optional theme for the size ramp")}),Ii=p(Ei,{name:"size-age",description:`Label: Age (size)
154
+ Fields: This style requires two number fields.`,schema:vi});function Ti(e){let{fields:r,layer:t,view:a,theme:o}=e,i=r[0];return{layer:t,view:a,startTime:i,endTime:new Date,theme:o,sizeOptimizationEnabled:!0,outlineOptimizationEnabled:!0}}async function Ei(e){return await qt(e)}async function xi({arcgisMap:e,arcgisMapView:r,layerId:t,fields:a,colorSchemes:o,theme:i}){let n=r,l=e?.allLayers.find(c=>c.id===t);if(!l)return`Could not find layer for id: ${t}`;let d={styleName:"size-age",fields:a,layer:l,view:n,colorSchemeTags:o,theme:i};try{let c=Ti(d),u=await Ei(c);return l.renderer=u.renderer,l.visible=!0,`Size-age renderer applied to layer: ${l.title??l.id} using fields ${a.join(", ")}`}catch(c){return`Error applying size-age renderer: ${c instanceof Error?c.message:String(c)}`}}async function Ii({layerId:e,fields:r,colorSchemes:t,theme:a},o){let{mapView:i}=L(o);return await x({id:"show-legend",description:"Show Legend",payload:{layerIds:[e]}},o),await xi({arcgisMap:i.map,arcgisMapView:i,layerId:e,fields:r,colorSchemes:t,theme:a})}var $i=s.object({layerId:s.string().describe("The id of the layer to apply the size-age renderer to"),fields:s.array(s.string()).describe("The field(s) to use for the size-age renderer (temporal data with size)"),colorSchemes:s.array(s.string()).optional().describe("Optional color scheme tags to use"),theme:s.enum(["above-and-below","above","below","centered-on","extremes","high-to-low"]).optional().describe("Optional theme for the size ramp")}),Li=p(Ii,{name:"size-age",description:`Label: Age (size)
154
155
  Description: Vary symbol sizes along a continuous ramp to represent the age of features. Age reflects the length of time from a start date to an end date.
155
156
  Keywords: since, age, how old, how long
156
157
  Example: Change the size of features so older features are larger than new features.
157
- Fields: This style requires at least one field with a date type.`,schema:xi});function Li(e){let{fields:r,layer:t,view:a}=e,{theme:o}=e,i=r[1],n=r[0];return{layer:t,view:a,field:n,normalizationField:i,theme:o,sizeOptimizationEnabled:!0,outlineOptimizationEnabled:!0}}async function $i(e){return await kt(e)}async function Fi({arcgisMap:e,arcgisMapView:r,layerId:t,fields:a,colorSchemes:o,theme:i}){let n=r,l=e?.allLayers.find(d=>d.id===t);if(!l)return`Could not find layer for id: ${t}`;let c={styleName:"size",fields:a,layer:l,view:n,colorSchemeTags:o,theme:i};try{let d=Li(c),u=await $i(d);return l.renderer=u.renderer,l.visible=!0,`Size renderer applied to layer: ${l.title??l.id} using fields ${a.join(", ")}`}catch(d){return`Error applying size renderer: ${d instanceof Error?d.message:String(d)}`}}async function _i({layerId:e,fields:r,colorSchemes:t,theme:a},o){let{mapView:i}=I(o);return await x({id:"show-legend",description:"Show Legend",payload:{layerIds:[e]}},o),await Fi({arcgisMap:i.map,arcgisMapView:i,layerId:e,fields:r,colorSchemes:t,theme:a})}var Ni=s.object({layerId:s.string().describe("The id of the layer to apply the size renderer to"),fields:s.array(s.string()).describe("The field(s) to use for the size renderer (numeric data)"),colorSchemes:s.array(s.string()).optional().describe("Optional color scheme tags to use"),theme:s.enum(["above-and-below","above","below","centered-on","extremes","high-to-low"]).optional().describe("Optional theme for the size ramp")}),ki=p(_i,{name:"size",description:`Label: Counts and Amounts (size)
158
+ Fields: This style requires at least one field with a date type.`,schema:$i});function Fi(e){let{fields:r,layer:t,view:a}=e,{theme:o}=e,i=r[1],n=r[0];return{layer:t,view:a,field:n,normalizationField:i,theme:o,sizeOptimizationEnabled:!0,outlineOptimizationEnabled:!0}}async function _i(e){return await At(e)}async function ki({arcgisMap:e,arcgisMapView:r,layerId:t,fields:a,colorSchemes:o,theme:i}){let n=r,l=e?.allLayers.find(c=>c.id===t);if(!l)return`Could not find layer for id: ${t}`;let d={styleName:"size",fields:a,layer:l,view:n,colorSchemeTags:o,theme:i};try{let c=Fi(d),u=await _i(c);return l.renderer=u.renderer,l.visible=!0,`Size renderer applied to layer: ${l.title??l.id} using fields ${a.join(", ")}`}catch(c){return`Error applying size renderer: ${c instanceof Error?c.message:String(c)}`}}async function Ni({layerId:e,fields:r,colorSchemes:t,theme:a},o){let{mapView:i}=L(o);return await x({id:"show-legend",description:"Show Legend",payload:{layerIds:[e]}},o),await ki({arcgisMap:i.map,arcgisMapView:i,layerId:e,fields:r,colorSchemes:t,theme:a})}var qi=s.object({layerId:s.string().describe("The id of the layer to apply the size renderer to"),fields:s.array(s.string()).describe("The field(s) to use for the size renderer (numeric data)"),colorSchemes:s.array(s.string()).optional().describe("Optional color scheme tags to use"),theme:s.enum(["above-and-below","above","below","centered-on","extremes","high-to-low"]).optional().describe("Optional theme for the size ramp")}),Ai=p(Ni,{name:"size",description:`Label: Counts and Amounts (size)
158
159
  Description: Vary symbol sizes along a continuous ramp to represent numeric or ranked data.
159
160
  Keywords: graduated size, proportional size, how much, total, number, amount, size
160
161
  Example: Vary the size of each point based on the total population.
@@ -164,25 +165,33 @@ Fields: This typically requires zero or one field of type number.`,schema:ni});f
164
165
  Description: Vary symbol sizes along a continuous ramp to represent dates.
165
166
  Keywords: graduated size, proportional size, classed size, how much, total, number, when
166
167
  Example: Vary the size of each feature based on the date a ticket was completed.
167
- Fields: This style requires a single field with a date type.`,schema:Ni});function qi(e){let{fields:r,layer:t,view:a,colorSchemeTags:o}=e;console.log("processTypeRendererParams",e);let i=r[0],n=r[1],l=r[2],c;return o&&(c=At({geometryType:t.geometryType,includedTags:o})[0]),{layer:t,view:a,field:i,field2:n,field3:l,outlineOptimizationEnabled:!0,sizeOptimizationEnabled:!0,typeScheme:c}}async function Ai(e){return await qt(e)}async function Ri({arcgisMap:e,arcgisMapView:r,layerId:t,fields:a,colorSchemes:o,theme:i}){let n=r,l=e?.allLayers.find(d=>d.id===t);if(!l)return`Could not find layer for id: ${t}`;let c={styleName:"type",fields:a,layer:l,view:n,colorSchemeTags:o,theme:i};try{let d=qi(c),u=await Ai(d);return l.renderer=u.renderer,l.visible=!0,`Type renderer applied to layer: ${l.title??l.id} using fields ${a.join(", ")}`}catch(d){return`Error applying type renderer: ${d instanceof Error?d.message:String(d)}`}}async function Mi({layerId:e,fields:r,colorSchemes:t,theme:a},o){let{mapView:i}=I(o);return await x({id:"show-legend",description:"Show Legend",payload:{layerIds:[e]}},o),await Ri({arcgisMap:i.map,arcgisMapView:i,layerId:e,fields:r,colorSchemes:t,theme:a})}var zi=s.object({layerId:s.string().describe("The id of the layer to apply the type renderer to"),fields:s.array(s.string()).describe("The field(s) to use for the type renderer (categorical data)"),colorSchemes:s.array(s.string()).optional().describe("Optional color scheme tags to use"),theme:s.enum(["above-and-below","above","below","centered-on","extremes","high-to-low"]).optional().describe("Optional theme for the color scheme")}),Ci=p(Mi,{name:"type",description:`Label: Types (unique symbols)
168
+ Fields: This style requires a single field with a date type.`,schema:qi});function Ri(e){let{fields:r,layer:t,view:a,colorSchemeTags:o}=e;console.log("processTypeRendererParams",e);let i=r[0],n=r[1],l=r[2],d;return o&&(d=Mt({geometryType:t.geometryType,includedTags:o})[0]),{layer:t,view:a,field:i,field2:n,field3:l,outlineOptimizationEnabled:!0,sizeOptimizationEnabled:!0,typeScheme:d}}async function Mi(e){return await Rt(e)}async function zi({arcgisMap:e,arcgisMapView:r,layerId:t,fields:a,colorSchemes:o,theme:i}){let n=r,l=e?.allLayers.find(c=>c.id===t);if(!l)return`Could not find layer for id: ${t}`;let d={styleName:"type",fields:a,layer:l,view:n,colorSchemeTags:o,theme:i};try{let c=Ri(d),u=await Mi(c);return l.renderer=u.renderer,l.visible=!0,`Type renderer applied to layer: ${l.title??l.id} using fields ${a.join(", ")}`}catch(c){return`Error applying type renderer: ${c instanceof Error?c.message:String(c)}`}}async function Ci({layerId:e,fields:r,colorSchemes:t,theme:a},o){let{mapView:i}=L(o);return await x({id:"show-legend",description:"Show Legend",payload:{layerIds:[e]}},o),await zi({arcgisMap:i.map,arcgisMapView:i,layerId:e,fields:r,colorSchemes:t,theme:a})}var ji=s.object({layerId:s.string().describe("The id of the layer to apply the type renderer to"),fields:s.array(s.string()).describe("The field(s) to use for the type renderer (categorical data)"),colorSchemes:s.array(s.string()).optional().describe("Optional color scheme tags to use"),theme:s.enum(["above-and-below","above","below","centered-on","extremes","high-to-low"]).optional().describe("Optional theme for the color scheme")}),Vi=p(Ci,{name:"type",description:`Label: Types (unique symbols)
168
169
  Description: Represent features as categories with different symbol colors or shapes. Examples include type of tree, road class, or province name.
169
170
  Keywords: categorical, category, type, unique, discrete, point of interest, region, group
170
171
  Example: Color each feature based on the region it belongs to
171
- Fields: This style requires a single field which may be a string, number, or date type. It is usually a string.`,schema:zi}),nt=[ko,Co,Go,Jo,ti,si,mi,bi,Ii,ki,Ci],ji=async(e,r)=>{await h({text:"Requesting LLM for layer query results"},r);let t=await F("navigation_intent_prompt");if(!r?.configurable)throw new Error("config.configurable is required for layer query tools");let a={layerFieldInfo:e.layerFieldInfo},o=await z({promptText:t,messages:v(e.messages),inputVariables:a,tools:nt});return await Q(o,r),{...e,messages:[...e.messages,o]}};async function Vi(e,r){let t=await new A(nt).invoke({messages:v(e.messages)},r),a=t.messages.map(i=>i.text).join(`
172
+ Fields: This style requires a single field which may be a string, number, or date type. It is usually a string.`,schema:ji}),st=[Ao,Vo,Qo,Zo,ai,ci,gi,Si,Li,Ai,Vi],Oi=async(e,r)=>{await h({text:"Requesting LLM for layer query results"},r);let t=await $("navigation_intent_prompt");if(!r?.configurable)throw new Error("config.configurable is required for layer query tools");let a={layerFieldInfo:e.layerFieldInfo},o=await C({promptText:t,messages:T(e.messages),inputVariables:a,tools:st});return await Q(o,r),{...e,messages:[...e.messages,o]}};async function Di(e,r){let t=await new R(st).invoke({messages:T(e.messages)},r),a=t.messages.map(i=>i.text).join(`
172
173
  `);await h({text:`Finished executing layer filter tool: ${a}`},r);let o=t.messages.map(i=>i.text).join(`
173
- `);return{...e,outputMessage:o}}var st=y.Root({messages:y({reducer:L,default:()=>[]}),outputMessage:y({reducer:(e="",r)=>{let t=typeof r=="string"?r.trim():"";if(!t)return e;let a=e.trim();if(!a)return t;if(a===t)return e;let o=a.split(`
174
+ `);return{...e,outputMessage:o}}var lt=y.Root({messages:y({reducer:_,default:()=>[]}),outputMessage:y({reducer:(e="",r)=>{let t=typeof r=="string"?r.trim():"";if(!t)return e;let a=e.trim();if(!a)return t;if(a===t)return e;let o=a.split(`
174
175
 
175
176
  `);return o[o.length-1]?.trim()===t?e:`${e}
176
177
 
177
- ${t}`},default:()=>""}),vectorSearchLayerIds:y(),vectorSearchFieldResults:y(),layerFieldInfo:y(),selectedLayerId:y()}),Oi=async(e,r)=>(await h({text:"Exiting Layer Styling agent"},r),e),Di=async(e,r)=>{try{await h({text:"Populating layer and field info"},r);let t=[];for(let a of e.vectorSearchFieldResults){let o=function(u){let m=l.get(u)?.layerItem;return m?[m.name&&`Name: ${m.name}`,m.title&&`Title: ${m.title}`,m.description&&`Description: ${m.description}`].filter(Boolean).join(" | "):u},{layerId:i,results:n}=a,l=b(r,"layersAndFieldsRegistry"),c=l.get(i)?.fieldRegistry;if(!c)continue;let d=t.find(u=>u.layerId===i);d||(d={layerId:i,layerSummary:o(i),fieldInfos:[]},t.push(d));for(let u of n){let m=c.get(u.name);m&&d.fieldInfos.push(m)}}return console.log("Populated layerFieldInfo:",t),await h({text:"Populated layerFieldInfo"},r),{...e,layerFieldInfo:t}}catch(t){throw await h({text:"Error populating layerFieldInfo"},r),new Error(`Error populating layerFieldInfo: ${t instanceof Error?t.message:String(t)}`)}},Pi=(e,r)=>{let t=e.vectorSearchLayerIds??[];if(t.length<=1)return{...e,selectedLayerId:e.vectorSearchLayerIds[0]};let{hitlResponse:a}=r.configurable;if(console.log("hitlResponse:",a),!a||a.agentId!==Oe.id||a.id!=="reviewLayerSelection"){let i={agentId:Oe.id,id:"reviewLayerSelection",kind:"singleSelection",message:"Choose a layer to apply the styles.",metadata:[...t]};throw new xe(i)}let o=null;return Array.isArray(a.payload)&&a.payload.length>0&&(o=a.payload[0]),{...e,selectedLayerId:o??e.vectorSearchLayerIds[0]}},Gi=(e,r)=>B(["layerSearch","fieldSearch","layersAndFieldsRegistry"],"Layer Styling Agent")(e,r),Bi=()=>new q(st).addNode("requireLayerStylingServices",Gi).addNode("vectorSearchLayers",xo).addNode("layerSelectionHITL",Pi).addNode("vectorSearchFields",To).addNode("populateLayerFieldInfo",Di).addNode("agent",ji).addNode("tools",Vi).addNode("earlyExit",Oi).addEdge(k,"requireLayerStylingServices").addEdge("requireLayerStylingServices","vectorSearchLayers").addConditionalEdges("layerSelectionHITL",e=>e.vectorSearchLayerIds.length?"vectorSearchFields":"earlyExit").addConditionalEdges("vectorSearchFields",e=>e.vectorSearchFieldResults.length?"populateLayerFieldInfo":"earlyExit").addEdge("populateLayerFieldInfo","agent").addEdge("agent","tools").addEdge("tools",E).addEdge("earlyExit",E),Qi=String.raw`- **layerStyling** — User wants to change how features are drawn or styled on the map based on their data, such as applying color, size, transparency, symbols, or charts according to field values.
178
+ ${t}`},default:()=>""}),vectorSearchLayerIds:y(),vectorSearchFieldResults:y(),layerFieldInfo:y(),selectedLayerId:y()}),Pi=async(e,r)=>(await h({text:"Exiting Layer Styling agent"},r),e),Gi=async(e,r)=>{try{await h({text:"Populating layer and field info"},r);let t=[];for(let a of e.vectorSearchFieldResults){let o=function(u){let m=l.get(u)?.layerItem;return m?[m.name&&`Name: ${m.name}`,m.title&&`Title: ${m.title}`,m.description&&`Description: ${m.description}`].filter(Boolean).join(" | "):u},{layerId:i,results:n}=a,l=w(r,"layersAndFieldsRegistry"),d=l.get(i)?.fieldRegistry;if(!d)continue;let c=t.find(u=>u.layerId===i);c||(c={layerId:i,layerSummary:o(i),fieldInfos:[]},t.push(c));for(let u of n){let m=d.get(u.name);m&&c.fieldInfos.push(m)}}return console.log("Populated layerFieldInfo:",t),await h({text:"Populated layerFieldInfo"},r),{...e,layerFieldInfo:t}}catch(t){throw await h({text:"Error populating layerFieldInfo"},r),new Error(`Error populating layerFieldInfo: ${t instanceof Error?t.message:String(t)}`)}},Bi=(e,r)=>{let t=e.vectorSearchLayerIds??[];if(t.length<=1)return{...e,selectedLayerId:e.vectorSearchLayerIds[0]};let{hitlResponse:a}=r.configurable;if(console.log("hitlResponse:",a),!a||a.agentId!==De.id||a.id!=="reviewLayerSelection"){let i={agentId:De.id,id:"reviewLayerSelection",kind:"singleSelection",message:"Choose a layer to apply the styles.",metadata:[...t]};throw new Ie(i)}let o=null;return Array.isArray(a.payload)&&a.payload.length>0&&(o=a.payload[0]),{...e,selectedLayerId:o??e.vectorSearchLayerIds[0]}},Qi=(e,r)=>D(["layerSearch","fieldSearch","layersAndFieldsRegistry"],"Layer Styling Agent")(e,r),Wi=()=>new k(lt).addNode("requireLayerStylingServices",Qi).addNode("vectorSearchLayers",$o).addNode("layerSelectionHITL",Bi).addNode("vectorSearchFields",xo).addNode("populateLayerFieldInfo",Gi).addNode("agent",Oi).addNode("tools",Di).addNode("earlyExit",Pi).addEdge(F,"requireLayerStylingServices").addEdge("requireLayerStylingServices","vectorSearchLayers").addConditionalEdges("layerSelectionHITL",e=>e.vectorSearchLayerIds.length?"vectorSearchFields":"earlyExit").addConditionalEdges("vectorSearchFields",e=>e.vectorSearchFieldResults.length?"populateLayerFieldInfo":"earlyExit").addEdge("populateLayerFieldInfo","agent").addEdge("agent","tools").addEdge("tools",E).addEdge("earlyExit",E),Ki=String.raw`- **layerStyling** — User wants to change how features are drawn or styled on the map based on their data, such as applying color, size, transparency, symbols, or charts according to field values.
178
179
  _Example: “Color points by sales amount”_
179
180
  _Example: “Show population density with a color gradient”_
180
181
  _Example: “Create a relationship map between height and depth”_
181
- _Example: “Vary circle sizes according to population”_`,Oe={id:"layerStyling",name:"Layer Styling Agent",description:Qi,createGraph:Bi,workspace:st},ll=y.Root({messages:y({reducer:L,default:()=>[]}),outputMessage:y({reducer:(e="",r)=>{let t=typeof r=="string"?r.trim():"";if(!t)return e;let a=e.trim();if(!a)return t;if(a===t)return e;let o=a.split(`
182
+ _Example: “Vary circle sizes according to population”_`,De={id:"layerStyling",name:"Layer Styling Agent",description:Ki,createGraph:Wi,workspace:lt},ct=y.Root({messages:y({reducer:_,default:()=>[]}),outputMessage:y({reducer:(e="",r)=>{let t=typeof r=="string"?r.trim():"";if(!t)return e;let a=e.trim();if(!a)return t;if(a===t)return e;let o=a.split(`
182
183
 
183
184
  `);return o[o.length-1]?.trim()===t?e:`${e}
184
185
 
185
- ${t}`},default:()=>""})});var cl=String.raw`- **help** Enables users to ask questions about the map, layers, fields, and it's capabilities.
186
+ ${t}`},default:()=>""})}),Ui=e=>{if(!e||e.size===0)return"No layers available in this map.";let r=Array.from(e.values()).map(({layerItem:t,fieldRegistry:a},o)=>{let i=Array.from(a.values()).map(l=>l.name).slice(0,10).join(", "),n=a.size>10?` (and ${a.size-10} more)`:"";return`${o+1}. "${t.title}". Description: ${t.description}
187
+ Fields: ${i}${n}`}).join(`
188
+
189
+ `);return`This map contains ${e.size} layer(s):
190
+
191
+ ${r}`},Ji=e=>{let r=e?.list()??[];return r.length?r.map(t=>`- ${t.agent.name}: ${t.agent.description}`).join(`
192
+ `):"No agents currently available."};async function Hi(e,r){let t=await $("help_prompt"),a=w(r,"layersAndFieldsRegistry"),o=w(r,"agentRegistry"),i={layerSummary:Ui(a),agents:Ji(o)},n=await H({promptText:t,messages:T(e.messages),inputVariables:i}),l=new z(n),d=[...e.messages,l],c=`${e.outputMessage}
193
+
194
+ ${n}`.trim();return{...e,messages:d,outputMessage:c}}var Zi=(e,r)=>D(["agentRegistry"],"Help Agent")(e,r),Xi=()=>new k(ct).addNode("requireHelpServices",Zi).addNode("agent",Hi).addEdge(F,"requireHelpServices").addEdge("requireHelpServices","agent").addEdge("agent",E),Yi=String.raw`- **help** — Enables users to ask questions about the map, layers, fields, and it's capabilities.
186
195
 
187
196
  _Example: “Tell me about this map”_
188
197
  _Example: “List all layers in this map”_
@@ -195,22 +204,22 @@ ${t}`},default:()=>""})});var cl=String.raw`- **help** — Enables users to ask
195
204
 
196
205
  IF the user asks map related queries, but those that are not performed by any of the agents, call this agent so we can respond accordingly.
197
206
  _Example: "Create a chart"_
198
- _Example: "Create a table"_`;var dl=y.Root({messages:y({reducer:L,default:()=>[]}),outputMessage:y({reducer:(e="",r)=>{let t=typeof r=="string"?r.trim():"";if(!t)return e;let a=e.trim();if(!a)return t;if(a===t)return e;let o=a.split(`
207
+ _Example: "Create a table"_`,pl={id:"help",name:"Help Agent",description:Yi,createGraph:Xi,workspace:ct},wl=y.Root({messages:y({reducer:_,default:()=>[]}),outputMessage:y({reducer:(e="",r)=>{let t=typeof r=="string"?r.trim():"";if(!t)return e;let a=e.trim();if(!a)return t;if(a===t)return e;let o=a.split(`
199
208
 
200
209
  `);return o[o.length-1]?.trim()===t?e:`${e}
201
210
 
202
- ${t}`},default:()=>""}),intent:y({reducer:(e,r)=>r})}),Z={conversationId:""},Wi=["linkChartView"],Ki=["knowledgeGraph"];function ee(e){let r=e?.configurable?.context;if(!r||typeof r!="object")throw new Error("ArcgisKnowledgeAgent context missing");let t=Wi.filter(a=>!(a in r));if(t.length)throw new Error(`Link Chart context missing: ${t.join(", ")}`);return r}function Te(e){let r=e?.configurable?.context;if(!r||typeof r!="object")throw new Error("ArcgisKnowledgeAgent context missing");let t=Ki.filter(a=>!(a in r));if(t.length)throw new Error(`Knowledge Graph context missing: ${t.join(", ")}`);return r}var ce=class{constructor(r){this.dataModel=r,this.kind="GraphQueryGenerationRequest",this.explainQuery=!0,this.schemaInformation=de.fromDataModel(r)}},de=class e{constructor(){this.schemaType="ArcgisGraphSchema",this.entityTypes=[],this.relationshipTypes=[],this.identifierInfo={mappingInfo:{identifierMapsTo:"UniformPropertyIdentifier",identifierPropertyName:"globalid"}}}static fromDataModel(r){let t=new e;for(let a of r.entityTypes)t.entityTypes.push(G.fromEntityType(a));for(let a of r.relationshipTypes)t.relationshipTypes.push(ue.fromRelationshipType(a));return t.identifierInfo={mappingInfo:{identifierMapsTo:Ui(r.identifierInfo.identifierMappingInfo.identifierInfoType),identifierPropertyName:r.identifierInfo.identifierMappingInfo.uniformPropertyIdentifier.identifierPropertyName}},t.spatialReference=JSON.parse(JSON.stringify(r.spatialReference)),t}},G=class e{constructor(){this.name="",this.properties=[]}static fromEntityType(r){let t=new e;t.name=r.name,t.alias=r.alias?r.alias:void 0,t.role=Ji(r.role);for(let a of r.properties){let o={name:a.name,alias:a.alias?a.alias:void 0,fieldType:a.fieldType,role:Zi(a.role),geometryDef:a.fieldType==="esriFieldTypeGeometry"?{geometryType:a.geometryType??"esriGeometryAny",hasM:a.hasM?a.hasM:void 0,hasZ:a.hasZ?a.hasZ:void 0}:void 0};t.properties.push(o)}return t}},ue=class extends G{constructor(){super(...arguments),this.observedEndPoints=[]}static fromRelationshipType(r){let t=G.fromEntityType(r);t.observedEndPoints=[];for(let a of r.endPoints)t.observedEndPoints.push({originEntityType:a.originEntityType,destinationEntityType:a.destinationEntityType});return t}},Ui=e=>{switch(e){case"esriIdentifierInfoTypeUNSPECIFIED":return"UNSPECIFIED";case"esriIdentifierInfoTypeDatabaseNative":return"DatabaseNative";case"esriIdentifierInfoTypeUniformProperty":return"UniformPropertyIdentifier";default:return e}},Ji=e=>{switch(e){case"Regular":return"esriGraphNamedObjectRegular";case"Provenance":return"esriGraphNamedObjectProvenance";case"Document":return"esriGraphNamedObjectDocument";default:return e}};function Zi(e){switch(e){case"esriGraphPropertyRegular":return"Regular";case"esriGraphPropertyDocumentName":return"Document_Name";case"esriGraphPropertyDocumentTitle":return"Document_Title";case"esriGraphPropertyDocumentUrl":return"Document_Url";case"esriGraphPropertyDocumentText":return"Document_Text";case"esriGraphPropertyDocumentKeywords":return"Document_Keywords";case"esriGraphPropertyDocumentContentType":return"Document_ContentType";case"esriGraphPropertyDocumentMetadata":return"Document_Metadata";case"esriGraphPropertyDocumentFileExtension":return"Document_FileExtension";case"esriGraphPropertyProvenanceInstanceId":return"Provenance_InstanceId";case"esriGraphPropertyProvenanceSourceType":return"Provenance_SourceType";case"esriGraphPropertyProvenanceSourceName":return"Provenance_SourceName";case"esriGraphPropertyProvenanceSource":return"Provenance_Source";case"esriGraphPropertyProvenanceComment":return"Provenance_Comment";case"esriGraphPropertyProvenanceTypeName":return"Provenance_TypeName";case"esriGraphPropertyProvenancePropertyName":return"Provenance_PropertyName";default:return"Regular"}}async function Hi(e,r,t,a){let{graphQuery:o,explanation:i}=await Ee(e,r,t,a);return`Generated Graph Query:
211
+ ${t}`},default:()=>""}),intent:y({reducer:(e,r)=>r})}),Z={conversationId:""},en=["linkChartView"],tn=["knowledgeGraph"];function te(e){let r=e?.configurable?.context;if(!r||typeof r!="object")throw new Error("ArcgisKnowledgeAgent context missing");let t=en.filter(a=>!(a in r));if(t.length)throw new Error(`Link Chart context missing: ${t.join(", ")}`);return r}function Ee(e){let r=e?.configurable?.context;if(!r||typeof r!="object")throw new Error("ArcgisKnowledgeAgent context missing");let t=tn.filter(a=>!(a in r));if(t.length)throw new Error(`Knowledge Graph context missing: ${t.join(", ")}`);return r}var de=class{constructor(r){this.dataModel=r,this.kind="GraphQueryGenerationRequest",this.explainQuery=!0,this.schemaInformation=ue.fromDataModel(r)}},ue=class e{constructor(){this.schemaType="ArcgisGraphSchema",this.entityTypes=[],this.relationshipTypes=[],this.identifierInfo={mappingInfo:{identifierMapsTo:"UniformPropertyIdentifier",identifierPropertyName:"globalid"}}}static fromDataModel(r){let t=new e;for(let a of r.entityTypes)t.entityTypes.push(B.fromEntityType(a));for(let a of r.relationshipTypes)t.relationshipTypes.push(he.fromRelationshipType(a));return t.identifierInfo={mappingInfo:{identifierMapsTo:rn(r.identifierInfo.identifierMappingInfo.identifierInfoType),identifierPropertyName:r.identifierInfo.identifierMappingInfo.uniformPropertyIdentifier.identifierPropertyName}},t.spatialReference=JSON.parse(JSON.stringify(r.spatialReference)),t}},B=class e{constructor(){this.name="",this.properties=[]}static fromEntityType(r){let t=new e;t.name=r.name,t.alias=r.alias?r.alias:void 0,t.role=an(r.role);for(let a of r.properties){let o={name:a.name,alias:a.alias?a.alias:void 0,fieldType:a.fieldType,role:on(a.role),geometryDef:a.fieldType==="esriFieldTypeGeometry"?{geometryType:a.geometryType??"esriGeometryAny",hasM:a.hasM?a.hasM:void 0,hasZ:a.hasZ?a.hasZ:void 0}:void 0};t.properties.push(o)}return t}},he=class extends B{constructor(){super(...arguments),this.observedEndPoints=[]}static fromRelationshipType(r){let t=B.fromEntityType(r);t.observedEndPoints=[];for(let a of r.endPoints)t.observedEndPoints.push({originEntityType:a.originEntityType,destinationEntityType:a.destinationEntityType});return t}},rn=e=>{switch(e){case"esriIdentifierInfoTypeUNSPECIFIED":return"UNSPECIFIED";case"esriIdentifierInfoTypeDatabaseNative":return"DatabaseNative";case"esriIdentifierInfoTypeUniformProperty":return"UniformPropertyIdentifier";default:return e}},an=e=>{switch(e){case"Regular":return"esriGraphNamedObjectRegular";case"Provenance":return"esriGraphNamedObjectProvenance";case"Document":return"esriGraphNamedObjectDocument";default:return e}};function on(e){switch(e){case"esriGraphPropertyRegular":return"Regular";case"esriGraphPropertyDocumentName":return"Document_Name";case"esriGraphPropertyDocumentTitle":return"Document_Title";case"esriGraphPropertyDocumentUrl":return"Document_Url";case"esriGraphPropertyDocumentText":return"Document_Text";case"esriGraphPropertyDocumentKeywords":return"Document_Keywords";case"esriGraphPropertyDocumentContentType":return"Document_ContentType";case"esriGraphPropertyDocumentMetadata":return"Document_Metadata";case"esriGraphPropertyDocumentFileExtension":return"Document_FileExtension";case"esriGraphPropertyProvenanceInstanceId":return"Provenance_InstanceId";case"esriGraphPropertyProvenanceSourceType":return"Provenance_SourceType";case"esriGraphPropertyProvenanceSourceName":return"Provenance_SourceName";case"esriGraphPropertyProvenanceSource":return"Provenance_Source";case"esriGraphPropertyProvenanceComment":return"Provenance_Comment";case"esriGraphPropertyProvenanceTypeName":return"Provenance_TypeName";case"esriGraphPropertyProvenancePropertyName":return"Provenance_PropertyName";default:return"Regular"}}async function nn(e,r,t,a){let{graphQuery:o,explanation:i}=await xe(e,r,t,a);return`Generated Graph Query:
203
212
  ${o}
204
213
 
205
- Explanation: ${i}`}async function Ee(e,r,t,a){let o={message:e,context:new ce(r)};Z.conversationId&&(o.conversationId=Z.conversationId),await h({text:"Attempting to generate a cypher query from your prompt..."},a);let i=await qe(`${t}/chat`,{method:"post",body:JSON.stringify(o),headers:{"Content-Type":"application/json",token:Ae.findCredential(P.getDefault().url)?.token??""}});if(i.httpStatus!==200)throw new Error(`Graph query service returned an error: ${i.httpStatus}`,{cause:i.data});Z.conversationId||(Z.conversationId=i.data.conversationId);let n=!1,l=Date.now(),c=i.data.sequenceNumber,d="",u="",m=1;for(;!n;){await new Promise(g=>setTimeout(g,1e3)),await h({text:`Periodically requesting status of job from ArcGIS AI Services${"...".substring(0,m)}`},a),m=m%3+1;let f=await qe(`${t}/chat`,{method:"post",body:JSON.stringify({conversationId:i.data.conversationId,inquiryId:i.data.inquiryId,ackSequenceNumber:c}),headers:{"Content-Type":"application/json",token:Ae.findCredential(P.getDefault().url)?.token??""}});if(f.httpStatus!==200)throw new Error(`Graph query service polling returned an error: ${f.httpStatus}`,{cause:f.data});if(f.data.context)d=f.data.context.graphQuery,u=f.data.message||"";else if(!f.data.hasMore)n=!0;else if(Date.now()-l>6e4)throw new Error("Graph query service polling timed out after 1 minute.");c=f.data.sequenceNumber}return{graphQuery:d,explanation:u}}function H(e,r){if(!(!e||typeof e!="object")){if(Xi(e))for(let t of e.path)H(t,r);else if(Yi(e))r.set(`${e.typeName}__${e.id}`,{id:e.id,typeName:e.typeName});else if(Array.isArray(e))for(let t of e)H(t,r);else if(en(e))for(let t of Object.values(e.properties??{}))H(t,r)}}function Yi(e){return!e||typeof e!="object"||Array.isArray(e)?!1:"id"in e&&"typeName"in e}function Xi(e){return!e||typeof e!="object"||Array.isArray(e)?!1:e&&"path"in e&&Array.isArray(e.path)}function en(e){return!e||typeof e!="object"||Array.isArray(e)||"id"in e?!1:"properties"in e&&typeof e.properties=="object"}function tn(e,r){let t=[];for(let a of[...r.dataModel.entityTypes,...r.dataModel.relationshipTypes]){let o=e.getMemberIdsByType(a.name);for(let i of o)t.push({id:i,typeName:a.name})}return t}var rn=async e=>{let r=new Map,t=e.resultRowsStream.getReader();for(;;){let{done:a,value:o}=await t.read();if(a)break;for(let i of o)for(let n of i)H(n,r)}return Array.from(r.values())};async function an(e,r,t,a,o){let{graphQuery:i,explanation:n}=await Ee(e,r.dataModel,t,o);await h({text:`Attempting to execute query: ${i.substring(0,500)}${i.length>500?"...":""}`},o);let l=await Rt(r,new We({openCypherQuery:i}),{signal:o?.signal,timeout:o?.timeout}),c=await rn(l);return await h({text:`Query Results parsed into ${c.length} unique relationships and entities. Atempting to add to link chart...`},o),await a.map.addRecords(c),a.goTo(a.map.diagramNodesExtent),`Link Chart updated successfully. Cypher Query used:
214
+ Explanation: ${i}`}async function xe(e,r,t,a){let o={message:e,context:new de(r)};Z.conversationId&&(o.conversationId=Z.conversationId),await h({text:"Attempting to generate a cypher query from your prompt..."},a);let i=await Ae(`${t}/chat`,{method:"post",body:JSON.stringify(o),headers:{"Content-Type":"application/json",token:Re.findCredential(V.getDefault().url)?.token??""}});if(i.httpStatus!==200)throw new Error(`Graph query service returned an error: ${i.httpStatus}`,{cause:i.data});Z.conversationId||(Z.conversationId=i.data.conversationId);let n=!1,l=Date.now(),d=i.data.sequenceNumber,c="",u="",m=1;for(;!n;){await new Promise(g=>setTimeout(g,1e3)),await h({text:`Periodically requesting status of job from ArcGIS AI Services${"...".substring(0,m)}`},a),m=m%3+1;let f=await Ae(`${t}/chat`,{method:"post",body:JSON.stringify({conversationId:i.data.conversationId,inquiryId:i.data.inquiryId,ackSequenceNumber:d}),headers:{"Content-Type":"application/json",token:Re.findCredential(V.getDefault().url)?.token??""}});if(f.httpStatus!==200)throw new Error(`Graph query service polling returned an error: ${f.httpStatus}`,{cause:f.data});if(f.data.context)c=f.data.context.graphQuery,u=f.data.message||"";else if(!f.data.hasMore)n=!0;else if(Date.now()-l>6e4)throw new Error("Graph query service polling timed out after 1 minute.");d=f.data.sequenceNumber}return{graphQuery:c,explanation:u}}function X(e,r){if(!(!e||typeof e!="object")){if(ln(e))for(let t of e.path)X(t,r);else if(sn(e))r.set(`${e.typeName}__${e.id}`,{id:e.id,typeName:e.typeName});else if(Array.isArray(e))for(let t of e)X(t,r);else if(cn(e))for(let t of Object.values(e.properties??{}))X(t,r)}}function sn(e){return!e||typeof e!="object"||Array.isArray(e)?!1:"id"in e&&"typeName"in e}function ln(e){return!e||typeof e!="object"||Array.isArray(e)?!1:e&&"path"in e&&Array.isArray(e.path)}function cn(e){return!e||typeof e!="object"||Array.isArray(e)||"id"in e?!1:"properties"in e&&typeof e.properties=="object"}function dn(e,r){let t=[];for(let a of[...r.dataModel.entityTypes,...r.dataModel.relationshipTypes]){let o=e.getMemberIdsByType(a.name);for(let i of o)t.push({id:i,typeName:a.name})}return t}var un=async e=>{let r=new Map,t=e.resultRowsStream.getReader();for(;;){let{done:a,value:o}=await t.read();if(a)break;for(let i of o)for(let n of i)X(n,r)}return Array.from(r.values())};async function hn(e,r,t,a,o){let{graphQuery:i,explanation:n}=await xe(e,r.dataModel,t,o);await h({text:`Attempting to execute query: ${i.substring(0,500)}${i.length>500?"...":""}`},o);let l=await zt(r,new Ke({openCypherQuery:i}),{signal:o?.signal,timeout:o?.timeout}),d=await un(l);return await h({text:`Query Results parsed into ${d.length} unique relationships and entities. Atempting to add to link chart...`},o),await a.map.addRecords(d),a.goTo(a.map.diagramNodesExtent),`Link Chart updated successfully. Cypher Query used:
206
215
  ${i}
207
216
 
208
- Explanation: ${n}`}async function on({prompt:e},r){let{knowledgeGraph:t}=Te(r),{linkChartView:a}=ee(r),o=P.getDefault().helperServices,i=await F("arcgis_knowledge_current_lc_context"),n=tn(a.map,t),l=`${e}
217
+ Explanation: ${n}`}async function mn({prompt:e},r){let{knowledgeGraph:t}=Ee(r),{linkChartView:a}=te(r),o=V.getDefault().helperServices,i=await $("arcgis_knowledge_current_lc_context"),n=dn(a.map,t),l=`${e}
209
218
 
210
- ${i}${JSON.stringify(n)}`;return await an(l,t,`${o.aiAssistantServices.url}${o.aiAssistantServices.graphQueryAssistant}`,a,r)}var nn=s.object({prompt:s.string().describe("The user's inquiry into the knowledge graph that needs to be run.")}),ul=p(on,{name:"addRecords",description:"Adds records (entities or relationships) to the current link chart visualization from an inquiry into the knowledge graph data. The inquiry will retrieve data from the graph database that will serve as the basis for the records to be added to the link chart. The user should have explicitly requested to add records to the current link chart from their prompt.",schema:nn});async function sn(e,r){return await r.map.applyLayout(e),`Successfully applied layout: ${e}.`}async function ln({layout:e},r){let{linkChartView:t}=ee(r);return await sn(e,t)}var cn=s.object({layout:s.enum(["organic-standard","organic-community","basic-grid","hierarchical-bottom-to-top","radial-root-centric","tree-left-to-right","geographic-organic-standard","chronological-mono-timeline","chronological-multi-timeline"]).describe("The layout mode to apply to the link chart. The value must be one of the following: organic-standard, organic-community, basic-grid, hierarchical-bottom-to-top, radial-root-centric, tree-left-to-right, geographic-organic-standard, chronological-mono-timeline, chronological-multi-timeline")}),hl=p(ln,{name:"applyLayout",description:"Apply a diagram layout to the link chart",schema:cn});function dn(e,r){return r.map.changeNonspatialDataDisplay(e),`Successfully applied nonspatial visibility setting: ${e}.`}function un({setting:e},r){let{linkChartView:t}=ee(r);return dn(e,t)}var hn=s.object({setting:s.enum(["hidden","visible"]).describe("The setting of nonspatial visibility")}),ml=p(un,{name:"changeNonspatialVisibility",description:"Change whether or not nonspatial data is visible in the link chart. The value must be either 'hidden' or 'visible'.",schema:hn});async function mn(e,r,t,a,o){let{graphQuery:i,explanation:n}=await Ee(e,r.dataModel,t,o);await h({text:`Attempting to create link chart from derived query: ${i}`},o);let l=await Mt.fromCypherQuery(r,new We({openCypherQuery:i}));return await h({text:"Link chart created successfully, loading..."},o),a.map=l,await l.load(),await a.when(),`Link chart created successfully. Cypher Query used to create the link chart:
219
+ ${i}${JSON.stringify(n)}`;return await hn(l,t,`${o.aiAssistantServices.url}${o.aiAssistantServices.graphQueryAssistant}`,a,r)}var fn=s.object({prompt:s.string().describe("The user's inquiry into the knowledge graph that needs to be run.")}),bl=p(mn,{name:"addRecords",description:"Adds records (entities or relationships) to the current link chart visualization from an inquiry into the knowledge graph data. The inquiry will retrieve data from the graph database that will serve as the basis for the records to be added to the link chart. The user should have explicitly requested to add records to the current link chart from their prompt.",schema:fn});async function gn(e,r){return await r.map.applyLayout(e),`Successfully applied layout: ${e}.`}async function yn({layout:e},r){let{linkChartView:t}=te(r);return await gn(e,t)}var pn=s.object({layout:s.enum(["organic-standard","organic-community","basic-grid","hierarchical-bottom-to-top","radial-root-centric","tree-left-to-right","geographic-organic-standard","chronological-mono-timeline","chronological-multi-timeline"]).describe("The layout mode to apply to the link chart. The value must be one of the following: organic-standard, organic-community, basic-grid, hierarchical-bottom-to-top, radial-root-centric, tree-left-to-right, geographic-organic-standard, chronological-mono-timeline, chronological-multi-timeline")}),vl=p(yn,{name:"applyLayout",description:"Apply a diagram layout to the link chart",schema:pn});function wn(e,r){return r.map.changeNonspatialDataDisplay(e),`Successfully applied nonspatial visibility setting: ${e}.`}function bn({setting:e},r){let{linkChartView:t}=te(r);return wn(e,t)}var vn=s.object({setting:s.enum(["hidden","visible"]).describe("The setting of nonspatial visibility")}),Sl=p(bn,{name:"changeNonspatialVisibility",description:"Change whether or not nonspatial data is visible in the link chart. The value must be either 'hidden' or 'visible'.",schema:vn});async function Sn(e,r,t,a,o){let{graphQuery:i,explanation:n}=await xe(e,r.dataModel,t,o);await h({text:`Attempting to create link chart from derived query: ${i}`},o);let l=await Ct.fromCypherQuery(r,new Ke({openCypherQuery:i}));return await h({text:"Link chart created successfully, loading..."},o),a.map=l,await l.load(),await a.when(),`Link chart created successfully. Cypher Query used to create the link chart:
211
220
  ${i}
212
221
 
213
- Explanation: ${n}`}async function fn({prompt:e},r){let{knowledgeGraph:t}=Te(r),{linkChartView:a}=ee(r),o=P.getDefault().helperServices;return await mn(e,t,`${o.aiAssistantServices.url}${o.aiAssistantServices.graphQueryAssistant}`,a,r)}var gn=s.object({prompt:s.string().describe("The user's inquiry into the knowledge graph that needs to be transformed into a link chart visualization.")}),fl=p(fn,{name:"createLinkChart",description:"Creates a new link chart visualization from an inquiry into the knowledge graph data. The inquiry will retrieve data from the graph database that will serve as the basis for the new link chart. The user should have explicitly requested the creation of a new link chart from their prompt.",schema:gn});async function yn({prompt:e},r){let{knowledgeGraph:t}=Te(r),a=P.getDefault().helperServices;return await Hi(e,t.dataModel,`${a.aiAssistantServices.url}${a.aiAssistantServices.graphQueryAssistant}`,r)}var pn=s.object({prompt:s.string().describe("The user's inquiry into the knowledge graph that needs to be translated into a cypher query.")}),gl=p(yn,{name:"generateCypher",description:"Generates an Open Cypher query based on the user's prompt which represents an inquiry into the data of the knowledge service and its graph database, attempting to filter based on certain conditions and traverse specified relationships. The generated query should be syntactically correct and optimized for performance.",schema:pn});var yl=String.raw`The purpose of this agent is to work with Knowledge Graph data, a graph database technology that represents and stores data as interconnected entities (nodes) and relationships (edges).
222
+ Explanation: ${n}`}async function Tn({prompt:e},r){let{knowledgeGraph:t}=Ee(r),{linkChartView:a}=te(r),o=V.getDefault().helperServices;return await Sn(e,t,`${o.aiAssistantServices.url}${o.aiAssistantServices.graphQueryAssistant}`,a,r)}var En=s.object({prompt:s.string().describe("The user's inquiry into the knowledge graph that needs to be transformed into a link chart visualization.")}),Tl=p(Tn,{name:"createLinkChart",description:"Creates a new link chart visualization from an inquiry into the knowledge graph data. The inquiry will retrieve data from the graph database that will serve as the basis for the new link chart. The user should have explicitly requested the creation of a new link chart from their prompt.",schema:En});async function xn({prompt:e},r){let{knowledgeGraph:t}=Ee(r),a=V.getDefault().helperServices;return await nn(e,t.dataModel,`${a.aiAssistantServices.url}${a.aiAssistantServices.graphQueryAssistant}`,r)}var In=s.object({prompt:s.string().describe("The user's inquiry into the knowledge graph that needs to be translated into a cypher query.")}),El=p(xn,{name:"generateCypher",description:"Generates an Open Cypher query based on the user's prompt which represents an inquiry into the data of the knowledge service and its graph database, attempting to filter based on certain conditions and traverse specified relationships. The generated query should be syntactically correct and optimized for performance.",schema:In});var xl=String.raw`The purpose of this agent is to work with Knowledge Graph data, a graph database technology that represents and stores data as interconnected entities (nodes) and relationships (edges).
214
223
  This agent has two categories of skills: those that work with an active link chart visualization of a subset of the data in the knowledge graph, and those that work with the knowledge graph data more generally against the entire dataset in the service and database.
215
224
  For link charts, the agent enables users to interact with a link chart by adding new entities (also called nodes) or relationships (also called edges), removing existing entities or relationships,
216
225
  expanding the graph from particular entities, finding relationships between specified entities on the link chart and adding them to the link chart, finding all relationships
@@ -242,4 +251,4 @@ _example: "Find all the products supplied by Supplier X and add them to my visua
242
251
  _example: "Expand the link chart from 'Entity D' to show its direct connections"_
243
252
  _example: "Find all the cars and then add everything up to two hops away from them on the link chart"_
244
253
  _example: "Connect Emma and Rob on the link chart if there is a relationship between them"
245
- _example: "Discover and add all the relationships originating at 'Entity E' to the link chart"_`;return{a:ol,b:il,c:nl,d:sl,e:Oe}},"Graphic","geometry/Point","geometry/Extent","symbols/SimpleMarkerSymbol","rest/locator","layers/support/FeatureEffect","layers/support/FeatureFilter","geometry/operators/unionOperator","smartMapping/statistics/summaryStatistics","smartMapping/statistics/uniqueValues","rest/support/TopFeaturesQuery","rest/support/TopFilter","rest/support/Query","geometry/operators/bufferOperator","smartMapping/renderers/pieChart","smartMapping/symbology/pieChart","views/support/colorUtils","smartMapping/renderers/color","smartMapping/symbology/color","smartMapping/renderers/univariateColorSize","smartMapping/renderers/dotDensity","smartMapping/symbology/dotDensity","smartMapping/renderers/heatmap","smartMapping/symbology/heatmap","smartMapping/renderers/predominance","smartMapping/symbology/predominance","smartMapping/renderers/relationship","smartMapping/symbology/relationship","smartMapping/renderers/size","smartMapping/renderers/type","smartMapping/symbology/type","rest/knowledgeGraph/GraphQueryStreaming","request","identity/IdentityManager","portal/Portal","rest/knowledgeGraphService","WebLinkChart",a)
254
+ _example: "Discover and add all the relationships originating at 'Entity E' to the link chart"_`;return{a:ml,b:fl,c:gl,d:yl,e:De,f:pl}},"Graphic","geometry/Point","geometry/Extent","symbols/PictureMarkerSymbol","rest/locator","portal/Portal","config","layers/support/FeatureEffect","layers/support/FeatureFilter","geometry/operators/unionOperator","smartMapping/statistics/summaryStatistics","smartMapping/statistics/uniqueValues","rest/support/TopFeaturesQuery","rest/support/TopFilter","rest/support/Query","geometry/operators/bufferOperator","smartMapping/renderers/pieChart","smartMapping/symbology/pieChart","views/support/colorUtils","smartMapping/renderers/color","smartMapping/symbology/color","smartMapping/renderers/univariateColorSize","smartMapping/renderers/dotDensity","smartMapping/symbology/dotDensity","smartMapping/renderers/heatmap","smartMapping/symbology/heatmap","smartMapping/renderers/predominance","smartMapping/symbology/predominance","smartMapping/renderers/relationship","smartMapping/symbology/relationship","smartMapping/renderers/size","smartMapping/renderers/type","smartMapping/symbology/type","rest/knowledgeGraph/GraphQueryStreaming","request","identity/IdentityManager","rest/knowledgeGraphService","WebLinkChart",a)