1import{eU as X,s as Z,ia as D,aS as U,bi as ee,M as V,b5 as te,eZ as G,e$ as L,e_ as O,h$ as ae,P as re}from"./index-tMz818nX.js";import{r as M}from"./arcadeEnvironment-CdtMQ6X4.js";import{t as ne}from"./ImmutableArray-BPVd6ESQ.js";let b=null;function oe(e,n,r,c={}){const a=n.elementType,i="value",p=a.type==="array"?[{name:i,type:a.type,elementType:a.elementType}]:a.type==="dictionary"?[{name:i,type:a.type,properties:a.properties}]:[{name:i,type:a.type}];return new ne(e.map(o=>{const t={};return j(t,p,{[i]:o},r,c),t[i]}))}function ce(e,n,r={}){const c=e instanceof ae?new re({source:e.features,geometryType:e.geometryType,fields:e.fields,spatialReference:e.spatialReference}):e;return n.constructFeatureSet(c,r.spatialReference,null,!0,r.lruCache,r.interceptor)}function ie(e,n,r={}){const{spatialReference:c,interceptor:a,lruCache:i}=r;return typeof e=="string"?n.createFeatureSetCollectionFromService(e,c,i,a):n.createFeatureSetCollectionFromMap(e,c,i,a)}function se(e,n,r,c={}){const a=Object.create(null);return j(a,n.properties,e,r,c),new b.Dictionary(a)}function j(e,n,r,c,a={}){const i={};for(const p of Object.keys(r))i[p.toLowerCase()]=r[p];for(const p of n){const o=p.name.toLowerCase();if(a.variablesPreProcessed)e[o]=i[o];else switch(p.type){case"array":{const t=i[o];e[o]=t==null?null:oe(t,p,c,a);break}case"feature":{const t=i[o];e[o]=t==null?null:b.Feature.createFromGraphic(t,a?.timeZone);break}case"featureSet":{const t=i[o];e[o]=t==null?null:c?ce(t,c,a):null;break}case"featureSetCollection":{const t=i[o];e[o]=t==null?null:c?ie(t,c,a):null;break}case"dictionary":{const t=i[o];e[o]=t==null?null:se(t,p,c,a);break}case"date":{const t=i[o];e[o]=t?t instanceof O?t:a?.timeZone?O.dateJSAndZoneToArcadeDate(t,a?.timeZone):O.dateJSToArcadeDate(t):null;break}case"dateOnly":{const t=i[o];e[o]=t?t instanceof L?t:L.fromReader(t):null;break}case"time":{const t=i[o];e[o]=t?t instanceof G?t:G.fromReader(t):null;break}case"knowledgeGraph":case"geometry":case"boolean":case"text":case"number":e[o]=i[o];break;case"voxel":{const t=i[o];e[o]=t==null?null:new b.Voxel(t,a?.timeZone);break}case"pixel":{const t=i[o];e[o]=t==null?null:b.Pixel.fromImageryGraphic(t,a?.timeZone);break}}}}function Y(e,n){for(const r of e)n.push(r),r.type==="dictionary"&&Y(r.properties,n);return n}function P(e,n,r,c,a){const{spatialReference:i,interceptor:p,lruCache:o,console:t,abortSignal:x,timeZone:C,services:v={portal:V.getDefault()},track:u}=r,g={vars:{},spatialReference:i,interceptor:p,timeZone:C,lrucache:o,useAsync:a,services:v,console:t,abortSignal:x,track:u};return n&&j(g.vars,e.variables,n,c,r),g}function w(e,n){switch(n.getArcadeType(e)){case"number":case"text":case"boolean":case"point":case"polygon":case"polyline":case"multipoint":case"extent":return e;case"date":return e.toJSDate();case"time":case"dateOnly":return e.toString();case"feature":{const r=(e.type,e),c="geometry"in r?r.geometry():null,a="readAttributes"in r?r.readAttributes():r.attributes;return new te({geometry:c,attributes:a})}case"dictionary":{const r=e,c=r.attributes,a={};for(const i of Object.keys(c))a[i]=w(r.field(i),n);return a}case"array":return("toArray"in e?e.toArray():e).map(r=>w(r,n))}return e}const B={variables:[{name:"$feature",type:"feature"},{name:"$layer",type:"featureSet"},{name:"$datastore",type:"featureSetCollection"},{name:"$map",type:"featureSetCollection"},{name:"$userInput",type:"geometry"},{name:"$graph",type:"knowledgeGraph"},{name:"$view",type:"dictionary",properties:[{name:"scale",type:"number"},{name:"timeProperties",type:"dictionary",properties:[{name:"currentStart",type:"date"},{name:"currentEnd",type:"date"},{name:"startIncluded",type:"boolean"},{name:"endIncluded",type:"boolean"}]}]}]},J={variables:[{name:"$feature",type:"feature"},{name:"$aggregatedFeatures",type:"featureSet"},{name:"$view",type:"dictionary",properties:[{name:"scale",type:"number"},{name:"timeProperties",type:"dictionary",properties:[{name:"currentStart",type:"date"},{name:"currentEnd",type:"date"},{name:"startIncluded",type:"boolean"},{name:"endIncluded",type:"boolean"}]}]}]},z={variables:[{name:"$voxel",type:"voxel"}]},_={variables:[{name:"$pixel",type:"pixel"},{name:"$imageCollectionItem",type:"feature"}]},N=new Map([["aggregate-field",{variables:[{name:"$feature",type:"feature"}]}],["form-constraint",{variables:[{name:"$feature",type:"feature"}]}],["feature-z",{variables:[{name:"$feature",type:"feature"}]}],["field-calculation",{variables:[{name:"$feature",type:"feature"},{name:"$datastore",type:"featureSetCollection"}]}],["form-calculation",{variables:[{name:"$feature",type:"feature"},{name:"$originalFeature",type:"feature"},{name:"$layer",type:"featureSet"},{name:"$featureSet",type:"featureSet"},{name:"$datastore",type:"featureSetCollection"},{name:"$map",type:"featureSetCollection"},{name:"$editContext",type:"dictionary",properties:[{name:"editType",type:"text"}]}]}],["labeling",{variables:[{name:"$feature",type:"feature"},{name:"$view",type:"dictionary",properties:[{name:"scale",type:"number"},{name:"timeProperties",type:"dictionary",properties:[{name:"currentStart",type:"date"},{name:"currentEnd",type:"date"},{name:"startIncluded",type:"boolean"},{name:"endIncluded",type:"boolean"}]}]}]}],["popup",B],["popup-element",B],["popup-feature-reduction",J],["popup-element-feature-reduction",J],["visualization",{variables:[{name:"$feature",type:"feature"},{name:"$view",type:"dictionary",properties:[{name:"scale",type:"number"},{name:"timeProperties",type:"dictionary",properties:[{name:"currentStart",type:"date"},{name:"currentEnd",type:"date"},{name:"startIncluded",type:"boolean"},{name:"endIncluded",type:"boolean"}]}]}]}],["popup-voxel",z],["popup-element-voxel",z],["popup-imagery",_],["popup-element-imagery",_]]);function de(e){e==="feature-reduction-popup"?(D(U.getLogger("esri.arcade"),'profile name: "feature-reduction-popup"',{replacement:'"popup-feature-reduction"',version:"4.32",warnOnce:!0}),e="popup-feature-reduction"):e==="feature-reduction-popup-element"&&(D(U.getLogger("esri.arcade"),'profile name: "feature-reduction-popup-element"',{replacement:'"popup-element-feature-reduction"',version:"4.32",warnOnce:!0}),e="popup-element-feature-reduction");const n=N.get(e);if(!n){const r=Array.from(N.keys()).map(c=>`'${c}'`).join(", ");throw new Z("createArcadeProfile:invalid-profile-name",`Invalid profile name '${e}'. You must specify one of the following values: ${r}`)}return ee(n)}async function be(e,n,r={}){b||(b=await X());const{arcade:c,arcadeUtils:a,batchExec:{createBatchExecutor:i},aiServices:{BatchTranslationServiceFactory:p,PortalTranslationService:o}}=b,{loadScriptDependencies:t,referencesMember:x,scriptIsAsync:C}=c,v=Y(n.variables,[]).filter(s=>s.type==="featureSet"||s.type==="featureSetCollection").map(s=>M(s.name)),u=c.parseScript(e,v);
1if(!u)throw new Z("arcade:invalid-script","Unable to create SyntaxTree");const g=a.extractFieldNames(u),q=c.scriptTouchesGeometry(u),E=n.variables.map(s=>M(s.name)).filter(s=>x(u,s)),f=C(u,v);await t(u,f,v);const k=c.compileScript(u,{vars:Object.fromEntries(E.map(s=>[s,!0])),useAsync:f}),{lruCache:A,services:I}=r,T=c.featureSetUtils();return{execute:(s,m={})=>{if(f)throw new Z("arcade:invalid-execution-mode","Cannot execute the script in synchronous mode");const l={...I,...m.services},d={lruCache:A,...m,services:l},y=k(P(n,s,d,T,f));return m.rawOutput?y:w(y,a)},executeAsync:async(s,m={})=>{const l={...I,...m.services},d={lruCache:A,...m,services:l},y=await k(P(n,s,d,T,f));return m.rawOutput?y:w(y,a)},executeAsyncBatch:async(s,m,l={})=>{const d=[],y=i(s,async($,S)=>{const K=m($);try{const h={...F,translation:H.create(S)},Q={lruCache:A,...l,services:h},R=await k(P(n,K,Q,T,f)),W=l.rawOutput?R:w(R,a);d.push({id:S.id,result:{status:"fulfilled",value:W}})}catch(h){throw d.push({id:S.id,result:{status:"rejected",reason:h}}),h}},l.maxConcurrency??64,l.abortSignal),F={...I,...l.services},H=new p(y,F.translation??new o(F.portal??V.getDefault(),l.console));return await y.run(),d.sort(({id:$},{id:S})=>$-S).map(({result:$})=>$)},isAsync:f,variablesUsed:E,fieldsUsed:g,geometryUsed:q,syntaxTree:u}}export{be as createArcadeExecutor,de as createArcadeProfile};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.