/*! All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
v4.33.0-next.164 */
import a from"./B2I4LZUP.js";import{b as f,c,d as p}from"./LDNGK54P.js";import{D as u}from"./OOJBBMWC.js";import{i as h,j as x}from"./PZMW2IU4.js";export default $arcgis.t(([{b:g,c:T,d:v,e:y,f:M,g:F,h:A}])=>{async function I(e){let{apiVersion:i,bundles:t,hiddenApiItems:a}=e.toEditorProfileDefinition(),n=await P(e.dictionaryVariables);return{apiVersion:i,bundles:t,variables:n,hiddenApiItems:a?.map(r=>r.toLowerCase())}}async function P(e,i=f.Variable){return await Promise.all(e.map(async t=>{switch(t.type){case"dictionary":return await C(t,i);case"feature":return await L(t,i);default:return V(t,i)}}))}function V(e,i){let{name:t,type:a}=e,n=e.getDescription();return{name:t,description:n,type:a,completion:{label:t,detail:t,insertText:t,insertTextMode:p.asIs,insertTextFormat:c.PlainText,kind:i,documentation:{kind:"markdown",value:n}}}}async function L(e,i){let t=await e.loadSource(),{name:a}=e,n=e.getDescription(),r={label:a,detail:a,insertText:a,insertTextMode:p.asIs,insertTextFormat:c.PlainText,kind:i},s={name:a,description:n,type:"dictionary",properties:[],completion:r};if(!t)return s;let[o,l]=M(t.fields,n,!0);return s.properties=o,r.documentation={kind:"markdown",value:l},s}async function C(e,i){let{name:t,dictionaryVariables:a}=e,n=e.getDescription(),r=a.reduce((s,o)=>{s!==""&&(s+=`  
  
`),s+=`**${o.name}**  
${o.type}`;let l=o.getDescription();return l&&(s+=`  
${l}`),s},n);return{name:t,description:n,type:"dictionary",properties:await P(a,f.Field),completion:{label:t,detail:t,insertText:t,insertTextMode:p.asIs,insertTextFormat:c.PlainText,kind:i,documentation:{kind:"markdown",value:r}}}}async function m(e="en"){let i=k.get(e);if(i)return i;if(!h.has(e))return await m("en");try{let t=await fetch(u(`./assets/arcade-language/profiles/arcade-profiles.t9n.${e}.json`));return t.ok?D(e,await t.json()):e==="en"?null:await m("en")}catch{return null}}var k=new Map;function D(e,i){let t=new Map;return i.forEach(a=>{t.set(a.id,a)}),k.set(e,t),t}async function E(e,i="en"){return(await m(i))?.get(e)??null}function $(e){return!!e&&typeof e=="object"&&"additionalVariables"in e&&Array.isArray(e.additionalVariables)}function S(e){return e?.map(b)}function b(e){switch(e.type){case"dictionary":return{...e,type:e.type,properties:S(e.properties)};case"array":return{...e,type:e.type,elementType:{type:"number",name:"number"}};default:return{...e,type:e.type}}}async function j(e,i="en"){if(!y(e))return;let t=await E(e.id,i);if(!t)return;let a={bundles:[...t.bundles],variables:[],hiddenApiItems:e.hiddenApiItems?.map(n=>n.toLowerCase())};return t.variables.forEach(n=>{if(e.disabledVariables?.includes(n.name))return;let r=e.definitions[n.name];switch(n.type){case"dictionary":return a.variables.push(b({...n,type:n.type,properties:Array.isArray(r)?[...r]:n.properties}));case"feature":case"voxel":return g(r)?a.variables.push({...n,type:"feature",definition:r}):void 0;case"featureSet":return T(r)?a.variables.push({...n,type:n.type,definition:r}):void 0;case"featureSetCollection":return v(r)?a.variables.push({...n,type:n.type,definition:r}):void 0;default:return a.variables.push(b(n))}}),$(e)&&a.variables.push(...e.additionalVariables??[]),a}var w=class extends A{constructor(){super("arcade",{apiPath:"./assets/arcade-language/api",apiPrefix:"arcade-api.t9n."})}async setProfileForModel(i,t,a={locale:"en"}){y(t)&&(t=await j(t,a.locale));let n=await x(a.locale,u("./assets/editor-profile/t9n"),"messages.");if(!n)throw new Error(`Failed to load the language bundle for ${a.locale}`);this.disposeForModel(i);let r=this._getApiKey(i),s=new F(t,n);this._modelToProfileMap.set(r,s);let o=await I(s);this.updateApiContextForModel(i,{locale:a.locale,profile:o,snippets:a.snippets})}},d=new w,z={setProfileForModel:d.setProfileForModel.bind(d),getApiLibraryForModel:d.getApiLibraryForModel.bind(d)};return d},a)