@arcgis/coding-components 5.1.0-next.7 → 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.
- package/dist/cdn/2KBW6YWT.js +2 -0
- package/dist/cdn/{YUYP77Z2.js → LYTYTEMO.js} +1 -1
- package/dist/cdn/{D2RP5367.js → ZGBZ6BXY.js} +1 -1
- package/dist/cdn/assets/code-editor/sql-expr.worker.js +1 -1
- package/dist/cdn/index.js +1 -1
- package/dist/components/arcgis-arcade-coding-assistant/customElement.js +1 -1
- package/dist/components/arcgis-arcade-editor/customElement.js +41 -37
- package/dist/components/arcgis-arcade-results/customElement.js +13 -13
- package/dist/docs/api.json +1 -1
- package/dist/docs/docs.json +1 -1
- package/dist/docs/web-types.json +1 -1
- package/package.json +5 -5
- package/dist/cdn/2LBCAP4J.js +0 -2
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
+
import d from"./4Y64BGY2.js";import c from"./TAGUYTAK.js";import{a as M}from"./ZYS253RG.js";import b from"./MKAM2LVE.js";import"./P5D2YYFD.js";import a from"./X2LBWSH3.js";import"./IFNCCZ7O.js";import"./QWLPT7LO.js";import"./NKCYMRE4.js";import"./BQLG62QR.js";import"./WMLTLTIE.js";import"./UYBZWFE5.js";import{D as C,E as D,F as I,G as r,J as B,K as k,h as w,j as s,l as $,n as S,s as y}from"./EMMNZESW.js";import{a as R,b as o}from"./BCUUVBXH.js";import"./YLN7EMJC.js";import"./GHSEU7VA.js";import"./4OSKRQ5X.js";import{Rk as L}from"./NG7S6FUK.js";import"./3TTFCHAA.js";export default $arcgis.t(([O,,l,{a:U,b:F},{a:T,h:b}])=>{var z=w`:host{height:100%}calcite-tooltip:not([calcite-hydrated])>*{display:none}.main-action-bar{calcite-action-group{padding-inline-end:var(--calcite-spacing-sm)}calcite-action-group calcite-action{padding-inline-end:var(--calcite-spacing-sm)}calcite-action-group calcite-action:not(:first-child){padding-inline-start:var(--calcite-spacing-sm)}calcite-action-group:last-child{border-inline-end-width:0px}calcite-action-group:not(:first-child){padding-inline-start:var(--calcite-spacing-sm)}}`,N="https://services6.arcgis.com/HXHga6CfMLMBOlBX/ArcGIS/rest/services/survey123_6e349a50b4504ca6b6107216d568db5f_form/FeatureServer/0",a=(i,e)=>R(i,"Arcade Assistant",e),H=i=>{let{aiAssistantsEnabled:e}=i;return e===void 0?(a("warn","`areAiAssistantsEnabled` is not defined in the organizations settings."),!1):e},V=i=>!(!i||!("id"in i)),G=async i=>(await O.getCredential(i,{oAuthPopupConfirmation:!1})).token,q=async i=>{try{return!!await O.checkSignInStatus(i)}catch{return a("warn","User is not signed in."),!1}};async function X({portalUrl:i,profile:e}){if(!V(e))return a("warn","Addon initialization failed. Reason: unsupported profile."),{shouldRender:!1};let t=i.replace(/\/sharing\/rest(\/.*)?$/iu,"").replace(/\/$/u,"");if(!await q(t))return{shouldRender:!1};let n=await G(i),c=`${t}/sharing/rest/portals/self?f=json&token=${n}`,h=`${t}/sharing/rest/portals/self/settings?f=json&token=${n}`,p=`${t}/sharing/rest/portals/self/signinSettings?f=json&token=${n}`,u=await Promise.allSettled([fetch(c,{credentials:"include"}).then(d=>d.json()),fetch(h,{credentials:"include"}).then(d=>d.json()),fetch(p,{credentials:"include"}).then(d=>d.json())]),[g,_,m]=u,f=g.status==="fulfilled"?g.value:(a("warn",`Failed to fetch selfUrl. Reason: ${g.reason}.`),{}),v=_.status==="fulfilled"?_.value:(a("warn",`Failed to fetch settingsUrl. Reason: ${_.reason}.`),{}),j=m.status==="fulfilled"?m.value:(a("warn",`Failed to fetch signinSettingsUrl. Reason: ${m.reason}.`),{}),x=f.helpBase||"";if(!v)return a("warn","Settings response is not available."),{shouldRender:!1};let A=H(v);j.blockBetaApps===!0&&(a("warn","Arcade Assistant is blocked by the organization settings. To enable it, do not block beta apps in the organization settings."),A=!1),f?.user?.privileges?.includes("portal:user:useAIAssistants")||(a("warn","User does not have the required privileges to use AI Assistants."),A=!1);let E=f?.helperServices?.aiAssistantServices?.url;return E?{shouldRender:!0,serviceUrl:E,helpBase:x,assistantsEnabled:A,feedbackServiceUrl:N}:{shouldRender:!0,assistantsEnabled:!1,helpBase:x,feedbackServiceUrl:N}}var P=class extends I{constructor(){super(...arguments),this._codeEditorElt=C(),this._componentReadyDefer=Promise.withResolvers(),this._disposables=[],this._editorProfilePromise=Promise.resolve(void 0),this.messages=M(),this._modelId=y(),this._openArcadeHelp=()=>void window.open(T,"Arcade Help"),this._toggleSidePanel=e=>{if(!e.target)return;let t=e.target?.dataset.panelName??"none";this.openedSidePanel=t===this.openedSidePanel?"none":t,this.openedSidePanel==="none"&&this._codeEditorElt.value?.setFocus().catch(o(this))},this._consoleLogs=[],this._executingScript=!1,this._preparingArcade=!1,this._resultPanel="output",this._showExecutionPanel=!1,this._arcadeAssistantRemoteState={shouldRender:!1},this.hideDocumentationActions=!1,this.hideSideBar=!1,this.openedSidePanel="none",this.script="",this.sideActionBarExpanded=!1,this.arcgisDiagnosticsChange=S({bubbles:!1}),this.arcgisScriptChange=S({bubbles:!1})}static{this.properties={_apiLibrary:16,_consoleLogs:16,_editorProfile:16,_executingScript:16,_executionResult:16,_preparingArcade:16,_resultPanel:16,_showExecutionPanel:16,_arcadeAssistantRemoteState:16,editorInstance:32,editorOptions:0,hideDocumentationActions:5,hideSideBar:5,openedSidePanel:3,profile:0,script:1,sideActionBarExpanded:7,snippets:0,suggestions:0,testData:0,customPanels:0,arcadeAssistant:0}}static{this.styles=[z]}get editorInstance(){return this._codeEditorElt.value?.editorInstance}async getTestResult(){if(!this.testData)return{type:"error",value:"Missing test data",error:null};let e=await this._editorProfilePromise;if(!e)return{type:"error",value:"Missing editor profile",error:null};await this._componentReadyDefer.promise;let t=this._codeEditorElt.value?.value;return await b(e.definition,t,this.testData)}async setFocus(){await this._componentReadyDefer.promise,await this._codeEditorElt.value?.setFocus()}async load(){let e=k("./assets");U(e),await this._updateDataModelDeps(),await this._updateArcadeAssistantRemoteState()}willUpdate(e){(e.has("messages")||e.has("profile"))&&this.hasUpdated&&this._updateDataModelDeps(),e.has("testData")&&this._testDataChanged(),e.has("snippets")&&l.updateApiContextForModel(this._modelId,{snippets:this.snippets}),e.has("arcadeAssistant")&&this._updateArcadeAssistantRemoteState()}async loaded(){this._componentReadyDefer.resolve(),await this._updateApiLibrary();let e=await F();this._disposables.push(e.onDiagnosticsChange(t=>!this._preparingArcade&&this.arcgisDiagnosticsChange.emit(t.diagnostics))),this.testData&&this._addExecuteScriptAction()}disconnectedCallback(){for(super.disconnectedCallback();this._disposables.length;)this._disposables.pop()?.dispose()}async _updateDataModelDeps(){await this._updateEditorProfile(),await this._updateApiLibrary()}_testDataChanged(){!this.testData&&this._executeScriptAction&&(this._disposeSafely(this._executeScriptAction),this._executeScriptAction=void 0),this.testData&&!this._executeScriptAction&&this._addExecuteScriptAction(),this._showExecutionPanel&&this._executeScript().catch(o(this))}async _updateEditorProfile(){this._preparingArcade=!0;try{await l.setProfileForModel(this._modelId,this.profile,{locale:this.messages._t9nLocale,snippets:this.snippets}),this._editorProfile=l.getEditorProfileForModel(this._modelId)}catch{this._editorProfile=void 0}finally{this._editorProfilePromise=Promise.resolve(this._editorProfile),this._preparingArcade=!1}}async _updateApiLibrary(){this._apiLibrary=await l.getApiLibraryForModel(this._modelId)}async _executeScript(){let e=this.testData;if(!this._codeEditorElt.value||!e)return;let t=await this._editorProfilePromise;if(!t){this._executionResult={type:"error",value:"Missing editor profile",error:null};return}this._showExecutionPanel=!0,this._executingScript=!0,this._consoleLogs=[],setTimeout(()=>void(async()=>{let n=this._codeEditorElt.value?.value;this._executionResult=await b(t.definition,n,e,c=>setTimeout(()=>this._consoleLogs=[...this._consoleLogs,c],0)),this._executingScript=!1})(),0)}_toggleShowExecutionPanel(){this._showExecutionPanel=!this._showExecutionPanel}_toggleSideActionBarExpanded(){this.sideActionBarExpanded=!this.sideActionBarExpanded}_onCodeEditorValueChange(e){e.stopPropagation(),this.script=e.detail,this.arcgisScriptChange.emit(e.detail)}_insertAsSnippet(e){this._codeEditorElt.value?.insertSnippet(e.detail).catch(o(this))}_insertAsText(e){this._insertText(e.detail)}_insertText(e){this._codeEditorElt.value?.insertText(e).catch(o(this))}_onResultPanelChange(e){let t=e.currentTarget;this._resultPanel=t.openedResultPanel}_onExecutionPanelClose(){this._showExecutionPanel=!1}_addExecuteScriptAction(){let e=this.editorInstance?.addAction({id:"run-script",label:"Run Arcade Expression",keybindings:[L.F5],contextMenuGroupId:"code",contextMenuOrder:1,run:()=>{this.testData&&this._executeScript().catch(o(this))}});e&&(this._executeScriptAction=e,this._disposables.push(e))}_disposeSafely(e){let t=this._disposables.indexOf(e);t!==-1&&this._disposables.splice(t,1),e.dispose()}async _updateArcadeAssistantRemoteState(){this.arcadeAssistant&&(this._arcadeAssistantRemoteState=await X({...this.arcadeAssistant,profile:this.profile}))}renderMainActionBar(){return this.testData?s`<calcite-action-bar class="main-action-bar" layout=horizontal scale=s expanded expand-disabled slot=top-action-bar><calcite-action-group scale=s><calcite-action .text=${this.messages.run??""} text-enabled icon=play scale=s .loading=${this._preparingArcade} @click=${()=>void this._executeScript().catch(o(this))}></calcite-action>${this._executionResult?s`<calcite-action .text=${this.messages.lastresults??""} .active=${this._showExecutionPanel} text-enabled icon=access-string-results icon-flip-rtl scale=s @click=${this._toggleShowExecutionPanel}></calcite-action>`:null}</calcite-action-group></calcite-action-bar>`:null}renderMainPanel(){return s`<arcgis-code-editor slot=editor .editorOptions=${this.editorOptions} .language=${l.languageId} .value=${this.script??""} .modelId=${this._modelId} @arcgisValueChange=${this._onCodeEditorValueChange} ${D(this._codeEditorElt)}></arcgis-code-editor>`}renderAction({id:e,label:t,icon:n,active:c,panelName:h,iconFlipRtl:p=!1,onClick:u=this._toggleSidePanel}){return s`<calcite-action id=${e??$} .text=${t} .textEnabled=${this.sideActionBarExpanded} .icon=${n} .active=${c} @click=${u} data-panel-name=${h??$} .iconFlipRtl=${p}></calcite-action>${!this.sideActionBarExpanded&&s`<calcite-tooltip .referenceElement=${e}><span>${t}</span></calcite-tooltip>`||""}`}renderSideActionBar(){return this.hideSideBar?null:s`<calcite-action-bar slot=side-action-bar class="side-action-bar" .expanded=${this.sideActionBarExpanded} position=end @calciteActionBarToggle=${this._toggleSideActionBarExpanded}><calcite-action-group>${this.renderAction({id:"profile-variables-action",label:this.messages.profilevariables??"",icon:"profile-variables",active:this.openedSidePanel==="variables",panelName:"variables"})}${this.renderAction({id:"function-action",label:this.messages.constantsandfunctions??"",icon:"function",active:this.openedSidePanel==="api",panelName:"api"})}${this.suggestions?.length?this.renderAction({id:"suggestions-action",label:this.messages.suggestions??"",icon:"lightbulb",active:this.openedSidePanel==="suggestions",panelName:"suggestions"}):null}${this._arcadeAssistantRemoteState.shouldRender&&this.renderAction({id:"arcade-assistant-action",label:this.messages.arcadeassistant??"Arcade assistant",icon:"effects",active:this.openedSidePanel==="arcade-assistant",panelName:"arcade-assistant"})||""}${this.customPanels?.map(e=>e.enabled===!1?null:this.renderAction({id:e.id,label:e.name,icon:e.icon,active:this.openedSidePanel===e.id,panelName:e.id}))}${this.hideDocumentationActions?null:this.renderAction({id:"developer-website-action",label:this.messages.help??"",icon:"question",active:!1,panelName:"none",iconFlipRtl:this.messages._lang==="ar",onClick:this._openArcadeHelp})}</calcite-action-group></calcite-action-bar>`}renderSidePanel(){if(this.hideSideBar)return null;let{openedSidePanel:e}=this;return s`<arcgis-language-api-panel slot=side-panel class=${r(e==="api"?"":"hidden")} .loading=${this._preparingArcade} .apiLibrary=${this._apiLibrary} .hideDocumentationActions=${this.hideDocumentationActions} @arcgisInternalItemSelected=${this._insertAsSnippet} @arcgisInternalClosePanel=${this._toggleSidePanel} data-panel-name=none .closed=${e!=="api"}></arcgis-language-api-panel><arcgis-editor-variables slot=side-panel class=${r(e==="variables"?"":"hidden")} .loading=${this._preparingArcade} .modelId=${this._modelId} @arcgisInternalItemSelected=${this._insertAsText} @arcgisInternalClosePanel=${this._toggleSidePanel} data-panel-name=none .variable=${this._editorProfile} .closed=${e!=="variables"}></arcgis-editor-variables>${this.suggestions?.length&&s`<arcgis-arcade-suggestions slot=side-panel class=${r(e==="suggestions"?"":"hidden")} .closed=${e!=="suggestions"} .suggestions=${this.suggestions} @arcgisInternalItemSelected=${this._insertAsText} @arcgisInternalClosePanel=${this._toggleSidePanel} data-panel-name=none></arcgis-arcade-suggestions>`||""}${this.arcadeAssistant&&this._arcadeAssistantRemoteState.shouldRender&&s`<arcgis-arcade-coding-assistant slot=side-panel class=${r(e==="arcade-assistant"?"":"hidden")} .closed=${e!=="arcade-assistant"} .insertText=${this._insertText.bind(this)} .closePanel=${this._toggleSidePanel} .portalUrl=${this.arcadeAssistant.portalUrl} .serviceUrl=${"serviceUrl"in this._arcadeAssistantRemoteState?this._arcadeAssistantRemoteState.serviceUrl:void 0} .helpBase=${this._arcadeAssistantRemoteState.helpBase} .assistantsEnabled=${this._arcadeAssistantRemoteState.assistantsEnabled} .feedbackServiceUrl=${this._arcadeAssistantRemoteState.feedbackServiceUrl} .editorRef=${this.el} .appVersion=${this.arcadeAssistant.appVersion}></arcgis-arcade-coding-assistant>`||""}${this.customPanels?.map(t=>s`<calcite-flow slot=side-panel class=${r(e===t.id?"":"hidden")}>${t?.useFlows?t.renderer?.({closePanel:this._toggleSidePanel,insertText:this._insertText.bind(this),closed:e!==t.id,editorRef:this.el}):s`<calcite-flow-item .heading=${t.name} heading-level=2 closable .closed=${e!==t.id} @calciteFlowItemClose=${this._toggleSidePanel} .description=${t.description}>${t.renderer?.({closePanel:this._toggleSidePanel,insertText:this._insertText.bind(this),closed:e!==t.id,editorRef:this.el})}</calcite-flow-item>`}</calcite-flow>`)}`}renderResultsPanel(){return this._showExecutionPanel?s`<arcgis-arcade-results slot=results-panel .openedResultPanel=${this._resultPanel} .loading=${this._executingScript} .result=${this._executionResult} .consoleLogs=${this._consoleLogs} @arcgisInternalOpenedResultPanelChange=${this._onResultPanelChange} @arcgisInternalClosePanel=${this._onExecutionPanelClose}></arcgis-arcade-results>`:null}render(){return s`<arcgis-code-editor-shell>${this.renderMainActionBar()}${this.renderMainPanel()}${this.renderResultsPanel()}${this.renderSidePanel()}${this.renderSideActionBar()}</arcgis-code-editor-shell>`}};B("arcgis-arcade-editor",P);return P},"identity/IdentityManager",a,b,c,d)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
2
|
import{a as oe}from"./ZYS253RG.js";import"./MP6Z45SA.js";import b from"./MKAM2LVE.js";import"./P5D2YYFD.js";import a from"./X2LBWSH3.js";import{d as ce}from"./IFNCCZ7O.js";import{c as ne,d as re}from"./QWLPT7LO.js";import"./NKCYMRE4.js";import"./BQLG62QR.js";import"./WMLTLTIE.js";import"./UYBZWFE5.js";import{A as X,B as Z,C as U,D as ee,E as te,F as ie,G as ae,H as O,J as se,h as W,j as p,k as P,l as _,s as K,v as N,w as q,x as D,y as I,z as k}from"./EMMNZESW.js";import{a as T}from"./BCUUVBXH.js";import"./YLN7EMJC.js";import"./GHSEU7VA.js";import"./4OSKRQ5X.js";import"./NG7S6FUK.js";import"./3TTFCHAA.js";export default $arcgis.t(([Se,pe,Te,Ae,Ce,{getDeclaredVoxelMembers:Ie,getDeclaredPixelMembers:Me},Ee,{property:w,subclass:Re},{g:le,h:F},z])=>{var de=(t,e,i)=>{let a=new Map;for(let s=e;s<=i;s++)a.set(t[s],s);return a},L=q(class extends D{constructor(t){if(super(t),t.type!==N.CHILD)throw Error("repeat() can only be used in text expressions")}dt(t,e,i){let a;i===void 0?i=e:e!==void 0&&(a=e);let s=[],n=[],l=0;for(let d of t)s[l]=a?a(d,l):l,n[l]=i(d,l),l++;return{values:n,keys:s}}render(t,e,i){return this.dt(t,e,i).values}update(t,[e,i,a]){let s=Z(t),{values:n,keys:l}=this.dt(e,i,a);if(!Array.isArray(s))return this.ut=l,n;let d=this.ut??=[],c=[],o,g,r=0,u=s.length-1,m=0,h=n.length-1;for(;r<=u&&m<=h;)if(s[r]===null)r++;else if(s[u]===null)u--;else if(d[r]===l[m])c[m]=k(s[r],n[m]),r++,m++;else if(d[u]===l[h])c[h]=k(s[u],n[h]),u--,h--;else if(d[r]===l[h])c[h]=k(s[r],n[h]),I(t,c[h+1],s[r]),r++,h--;else if(d[u]===l[m])c[m]=k(s[u],n[m]),I(t,s[r],s[u]),u--,m++;else if(o===void 0&&(o=de(l,m,h),g=de(d,r,u)),o.has(d[r]))if(o.has(d[u])){let f=g.get(l[m]),S=f!==void 0?s[f]:null;if(S===null){let v=I(t,s[r]);k(v,n[m]),c[m]=v}else c[m]=k(S,n[m]),I(t,s[r],S),s[f]=null;m++}else U(s[u]),u--;else U(s[r]),r++;for(;m<=h;){let f=I(t,c[h+1]);k(f,n[m]),c[m++]=f}for(;r<=u;){let f=s[r++];f!==null&&U(f)}return this.ut=l,X(t,c),P}});var R=class extends D{constructor(e){if(super(e),this.it=_,e.type!==N.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===_||e==null)return this._t=void 0,this.it=e;if(e===P)return e;if(typeof e!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this._t;this.it=e;let i=[e];return i.raw=i,this._t={_$litType$:this.constructor.resultType,strings:i,values:[]}}};R.directiveName="unsafeHTML",R.resultType=1;var V=q(R);var Ve=W`:host(:not([closed])){container-type:size;--calcite-block-border-color: var(--calcite-color-transparent);box-sizing:border-box;.submission-actions-wrapper{display:flex;flex-direction:column;width:100%;gap:.75rem}.submission-actions{display:flex;flex-direction:row;gap:.5rem;justify-content:space-between}@container (max-width: 380px){.hidden-below-380{display:none}}@container (min-width: 380px){.hidden-above-380{display:none}}.gaps{display:flex;gap:.25rem}.align-inline-end{margin-inline-start:auto}.context-popover p{padding:0 .5rem;font-size:var(--calcite-font-size-sm)}.feedback-content{padding:var(--calcite-spacing-sm);display:flex;flex-direction:column;max-height:75cqb;overflow-y:auto;>*{margin-block-end:.5rem}>*:last-child,.terms-label{margin-block-end:0}calcite-text-area{--calcite-text-area-min-height: 4rem}calcite-notice{margin-block-start:0}}.feedback-sheet{--calcite-sheet-height: auto;--calcite-sheet-max-height: 100%;--calcite-sheet-min-height: auto}.feedback-footer{display:flex;justify-content:flex-end;gap:.5rem;width:100%}calcite-chip[slot=header-actions-end]{align-self:center;margin-inline-end:.5rem}calcite-flow-item calcite-shell{background:transparent}calcite-block{width:100%;max-width:100%;align-self:flex-end;background-color:transparent;margin-block:0}calcite-sheet{--calcite-sheet-scrim-background: rgba(200, 200, 200, .5)}calcite-list-item calcite-button{margin-inline-end:.25rem}calcite-flow-item calcite-shell calcite-notice{margin-block:1rem}calcite-block[open]:last-of-type{border-block-end:0}.text-area-wrapper{display:flex;border-radius:var(--calcite-corner-radius-round);margin:.75rem;overflow:hidden;--calcite-color-border-input: transparent;position:sticky;box-shadow:var(--calcite-shadow-sm);flex:none;flex-direction:column}calcite-text-area{height:auto;overflow:hidden;--calcite-font-weight-normal: 500;font-weight:500;line-height:1.2}calcite-flow{height:100%}calcite-popover calcite-list{--calcite-list-background-color: transparent;--calcite-input-border-color: transparent}calcite-popover calcite-list calcite-filter{--calcite-spacing-sm: 0}.contained-popover-or-tooltip{--calcite-popover-max-size-x: 100%;--calcite-tooltip-max-size-x: 100%}.info-heading{font-size:var(--calcite-font-size-0);color:var(--calcite-color-text-1);margin:0}.info-heading-row{display:flex;align-items:center;gap:var(--calcite-spacing-sm);flex-wrap:wrap}.unstyled-h3{margin:unset;font-size:var(--calcite-font-size-md)}.unstyled-shell{position:unset;inset:unset;display:unset;block-size:unset;inline-size:unset}.suggestion-button{font-weight:var(--calcite-font-weight-medium)}.suggestions{display:flex;flex-direction:row;gap:var(--calcite-spacing-xs);flex-wrap:wrap}.info-block{max-width:450px}#result-block{calcite-card-group{--calcite-card-group-gap: 1.25rem}calcite-card{--calcite-card-corner-radius: var(--calcite-corner-radius-round);--calcite-card-border-color: transparent;width:100%}.positioned-code-content{display:flex;flex-direction:row;gap:.5rem;padding:.5rem}calcite-card [slot=heading] calcite-chip{margin-block-start:.25rem}.code-response-wrapper{position:relative;background:var(--calcite-color-foreground-2);border-radius:var(--calcite-corner-radius-round);margin-top:-1.5rem}.prior-prompt{display:flex;flex-direction:row;padding:0;overflow-y:hidden;overflow-x:auto;margin:.25rem 0 .75rem;align-items:center;max-width:100%;span{overflow-x:auto;overflow-y:hidden}}.copy-feedback{display:none}.copy-prompt-button{align-self:flex-start;margin-inline-start:auto}.response-secondary-action-button[data-copied]+.copy-feedback,.copy-prompt-button[data-copied]+.copy-feedback{display:block;span{padding:.75rem 1rem;font-size:var(--calcite-font-size--2);line-height:1.375;color:var(--calcite-color-text--2);font-weight:var(--calcite-font-weight-medium)}}.copy-prompt-button[data-copied]~.copy-tooltip,.response-secondary-action-button[data-copied]~.copy-tooltip{display:none}code{white-space:pre;font-size:12px;margin:0;overflow-x:auto;font-family:Fira Mono,Consolas,Menlo,monospace;display:block;max-height:12rem;position:relative;padding:.5rem}.response-secondary-action-button{margin-left:.5rem}.add-to-editor-button{--calcite-internal-button-border-color: unset}}.collapsible-code{padding:.5rem}.collapsible-code summary{cursor:pointer;font-weight:500;color:var(--calcite-color-brand);outline:none;padding:.25rem 0}.collapsible-code[open] summary{color:var(--calcite-color-text-2)}.response-error-container{padding:.5rem;background:color-mix(in srgb,var(--calcite-color-status-warning) 10%,transparent);border-radius:var(--calcite-corner-radius-round);margin:1rem 0;font-size:var(--calcite-font-size--2);--calcite-input-message-icon-color: var(--calcite-color-status-warning)}.response-error-chip{--calcite-internal-chip-background-color: var(--calcite-color-status-warning);--calcite-chip-icon-color: var(--calcite-color-foreground-1);--calcite-chip-border-color: var(--calcite-color-transparent)}.feedback-actions{gap:unset}.contained{max-width:100%;max-height:100%;max-width:100cqi;max-height:75cqb;overflow-y:auto}.submission-notice{--calcite-notice-border-color: transparent;margin-block:0;width:100%;--calcite-font-size-relative-base: var(--calcite-font-size--2)}.border-block-end{border-block-end:1px solid var(--calcite-color-border-3)}.round-top{border-radius:var(--calcite-corner-radius-round) var(--calcite-corner-radius-round) 0 0}}:host([closed]){display:none}`,A=class extends Error{constructor({message:e,code:i,subCode:a,details:s,source:n}){super(e),this.name="ArcadeAssistantError",this.code=i,this.subCode=a,this.details=s,this.source=n}};function ue(t){if(!t)return;let e=t.indexOf('{"error":');if(e!==-1)try{let i=t.slice(e),a=JSON.parse(i);if(a&&typeof a=="object"&&a.error)return a.error}catch{return}}async function Pe(t){let{baseUrl:e,skillId:i,message:a,authToken:s,previousConversationId:n,context:l}=t,d=i?`${e}/skills/${i}/chat`:`${e}/chat`,c=[],o={message:a,context:l};n&&(o.conversation_id=n);let g;try{g=await pe(d,{method:"post",headers:{"Content-Type":"application/json",token:s},body:JSON.stringify(o),responseType:"json"})}catch(v){let $=v,C=$.details?.rawResponse||$.message||String(v),M=ue(C);throw M?new A(M):v}let r=g.data;c.push(r);let u=r.conversationId,m=r.inquiryId,h=r.sequenceNumber;async function f(){let v=0,$=100;for(;v<$;){await new Promise(E=>setTimeout(E,1e3));let C=Ne(u,h,m),M;try{M=await pe(d,{method:"post",headers:{"Content-Type":"application/json",token:s},body:JSON.stringify(C),responseType:"json"})}catch(E){let J=E,ke=J.details?.rawResponse||J.message||String(E),Y=ue(ke);throw Y?new A(Y):E}let x=M.data;if(x.context?.kind==="ArcgisErrorAsContext"&&x.context.error)throw new A({message:x.context.error.message||"ArcGIS Assistant error",code:x.context.error.code,subCode:x.context.error.subCode,details:x.context.error.details,source:"polling-response"});if(c.push(x),h=x.sequenceNumber,v++,!x.hasMore)break}if(v===$)throw new A({message:"Request timed out",code:"TIMEOUT",source:"polling"})}let S=120*1e3;return await Promise.race([f(),new Promise((v,$)=>setTimeout(()=>$(new A({message:"Request timed out",code:"TIMEOUT",source:"hard-timeout"})),S))]),c}function Ne(t,e,i){return{conversationId:t,inquiryId:i,ackSequenceNumber:e}}function qe(t){return t.message.match(/Error in prompt shield/u)?"I'm having trouble with this request. Try again by rephrasing the question.":t.code==="TIMEOUT"?"Request timed out. Try again by re-asking the same question or rephrasing it.":t.message}var De=({notices:t})=>t.length?p`<div class="border-block-end">${L(t,e=>e.id??e.title,e=>p`<calcite-notice class="submission-notice" .icon=${e.icon} .kind=${e.kind} scale=s open .closable=${e.closable} @calciteNoticeClose=${()=>e.onClose?.()}><div slot=title>${e.title}</div>${e.message&&p`<div slot=message>${e.message}</div>`||""}${e.actionLinkMessage&&e.onAction&&p`<calcite-link slot=link @click=${()=>e.onAction?.()}>${e.actionLinkMessage}</calcite-link>`||""}</calcite-notice>`)}</div>`:null,Ue=t=>{let e=t.value.length,i=72,a=180,s=t.offsetWidth,n=Math.max(1,Math.floor(s/8)),l=Math.ceil(e/n),d=i+(l-2)*24;t.style.setProperty("--calcite-text-area-min-height",`${Math.min(d,a)}px`)},Oe=({promptValidationMessage:t,errorMessage:e,contextTooBig:i,contextReducedNoticeDismissed:a,setContextReducedNoticeDismissed:s,setErrorMessage:n,messages:l})=>{let d=[];if(t&&d.push({id:"prompt-validation",kind:"danger",icon:"exclamation-mark-triangle",title:t,closable:!0}),e&&d.push({id:"assistant-error",kind:"danger",icon:"exclamation-mark-triangle",title:e,closable:!0,onClose:()=>n(void 0)}),i&&!a){let c=l.contextreduced??"Context reduced",o=l.contextreducedmessage??"The editor profile is too large for the assistant. It has been reduced in the assistant in order to ensure a successful request.";d.push({id:"context-reduced",kind:"warning",icon:"exclamation-mark-triangle",title:c,message:o,closable:!0,onClose:()=>s(!0)})}return d};function _e({messages:t}){return p`<calcite-chip slot=header-actions-end scale=s appearance=outline-fill .label=${t.beta??"Beta"}>${t.beta??"Beta"}</calcite-chip>`}function Fe({popoverContent:t,messages:e}){return p`<calcite-action icon=information slot=header-actions-end id=legal-disclaimer text></calcite-action><calcite-popover reference-element=legal-disclaimer .label=${e.legaldisclaimer??"Legal disclaimer"} placement=bottom auto-close focus-trap-disabled><div class="contained">${t}</div></calcite-popover>`}function ze({errorMessage:t,slot:e}){return p`<div class="error-display"><calcite-input-message id=error-message status=invalid icon=exclamation-mark-triangle scale=m slot=${e??O}>${t}</calcite-input-message></div>`}function Le({active:t,setActive:e,messages:i}){return p`<calcite-alert slot=alerts .open=${t} placement=bottom kind=success icon=check-circle-f auto-close @calciteAlertClose=${()=>e(!1)} .label=${i.expressionapplied??"Expression applied"}><div slot=message>${i.expressionapplied??"Expression applied to editor."}</div></calcite-alert>`}function Be({context:t,messages:e}){return t?p`<div class="gaps">${t.profileId&&p`<calcite-popover auto-close placement=top .label=${(e.profilecontextlabel??"Profile context: {profileId}").replace("{profileId}",t.profileId)} reference-element=profile-context-button class="context-popover contained-popover-or-tooltip"><p>${(e.profilecontextlabel??"Profile context: {profileId}").replace("{profileId}",t.profileId)}</p></calcite-popover><calcite-button round kind=neutral icon-start=map-information id=profile-context-button scale=s></calcite-button>`||""}</div>`:null}function je({isDisabled:t,isReadOnly:e,setQuestion:i,setIsViewingResult:a,textAreaRef:s,question:n,errorMessage:l,setErrorMessage:d,promptValidationMessage:c,setPromptValidationMessage:o,submitQuestion:g,messages:r,mode:u,assistantRef:m,context:h,contextReducedNoticeDismissed:f,setContextReducedNoticeDismissed:S}){let v=h?.contextTooLarge??!1,$=Oe({promptValidationMessage:c,errorMessage:l,contextTooBig:v,contextReducedNoticeDismissed:f,setContextReducedNoticeDismissed:S,setErrorMessage:d,messages:r});return p`<div class="text-area-wrapper">${De({notices:$})}<calcite-text-area scale=s resize=vertical .readOnly=${t||e} class=${ae($.length?"submission-text-area":"submission-text-area round-top")} .placeholder=${r.askaquestion??`Specify the calculation or logic you need in an Arcade expression. (e.g., 'Return "Yes" if value > 10')`} .value=${n} @calciteTextAreaInput=${C=>{Ue(C.target),i(C.target.value)}} ${te(s)}><div class="submission-actions-wrapper" slot=footer-start><div class="submission-actions">${h&&Be({context:h,messages:r})||""}<div class="align-inline-end gaps"><calcite-button round kind=neutral .hidden=${u!=="refine"} icon-start=arrow-left icon-flip-rtl=both appearance=solid scale=s .disabled=${t} @click=${async()=>{a(!1),i("")}} .label=${r.startover??"Start Over"} class="hidden-above-380" id=small-start-over-button></calcite-button><calcite-tooltip reference-element=small-start-over-button placement=top-start class="hidden-above-380">${r.startover??"Start Over"}</calcite-tooltip><calcite-button round kind=neutral .hidden=${u!=="refine"} icon-start=arrow-left icon-flip-rtl=both appearance=solid .disabled=${t} @click=${async()=>{a(!1),i("")}} class="hidden-below-380" scale=s>${r.startover??"Start Over"}</calcite-button><calcite-button round scale=s icon-end=effects appearance=solid .loading=${t} .disabled=${t} @click=${async()=>{if(d(""),!n){o(r.enteraprompt??"Please enter a prompt");return}o(void 0),await g()}} class="hidden-below-380">${u==="prompt"?r.ask??"Generate":r.refine??"Refine"}</calcite-button><calcite-button round scale=s icon-end=effects appearance=solid .loading=${t} .disabled=${t} id=small-submit-button @click=${async()=>{if(d(""),!n){o(r.enteraprompt??"Please enter a prompt");return}o(void 0),await g()}} class="hidden-above-380" .label=${u==="prompt"?r.ask??"Generate":r.refine??"Refine"}></calcite-button><calcite-tooltip reference-element=small-submit-button placement=top-start class="hidden-above-380">${u==="prompt"?r.ask??"Generate":r.refine??"Refine"}</calcite-tooltip></div></div></div></calcite-text-area></div>`}var He="https://www.esri.com/en-us/privacy/privacy-statements/privacy-supplement",Qe="https://www.esri.com/en-us/privacy/privacy-statements";function Ge({setOpen:t,messages:e,feedback:i,learnMoreUrl:a,setFeedback:s,onSubmit:n}){return i.active?p`<calcite-sheet class="feedback-sheet" .label=${e.feedback??"Feedback"} slot=sheets display-mode=float position=block-end .open=${i.active} @calciteSheetClose=${()=>t(!1)}><calcite-panel .heading=${e.submitfeedback??"Submit feedback to Esri"} scale=s><div class="feedback-content"><calcite-text-area scale=s resize=vertical .value=${i.text} @calciteTextAreaInput=${l=>s({...i,text:l.target.value})} .disabled=${i.submitting} .placeholder=${e.donotincludepersonalinfo??"Do not include personal or sensitive information"} rows=3></calcite-text-area><calcite-label layout=inline scale=s class="terms-label"><calcite-checkbox scale=l .checked=${i.termsAccepted} @calciteCheckboxChange=${l=>{s({...i,termsAccepted:l.target.checked})}} .disabled=${i.submitting}></calcite-checkbox><span>${V((e.agreement??"I agree to the {EsriPrivacyStatement} (and {Supplement}).").replace("{EsriPrivacyStatement}",`<calcite-link href=${Qe} target="_blank">${e.esriprivacystatement??"Esri Privacy Statement"}</calcite-link>`).replace("{Supplement}",`<calcite-link href=${He} target="_blank">${e.supplement??"Supplement"}</calcite-link>`))}</span></calcite-label><calcite-notice scale=s open closable><span slot=message>${V((e.feedbackhelps??"Your feedback will be used to improve Esri products and services. {LearnMore} about how this data is used.").replace("{LearnMore}",`<calcite-link href=${a} target="_blank">${e.learnmore??"Learn more"}</calcite-link>`))}</span></calcite-notice></div><div slot=footer class="feedback-footer"><calcite-button kind=neutral appearance=outline @click=${()=>t(!1)} .disabled=${i.submitting}>${e.cancel??"Cancel"}</calcite-button><calcite-button @click=${n} .disabled=${!i.termsAccepted||i.submitting} .loading=${i.submitting} data-testid=submit-feedback-button>${e.submit??"Submit"}</calcite-button></div></calcite-panel></calcite-sheet>`:null}function me({assistantsEnabled:t,messages:e,slot:i,helpTopicUrl:a}){return p`<calcite-block .label=${e.assistantinformation??"Assistant information"} slot=${i??O} expanded class="info-block" scale=s><div class="info-heading-row"><h1 class="info-heading">${e.introducing??"Introducing Arcade Assistant (beta)"}</h1><calcite-chip .label=${e.new??"New"} kind=brand scale=s>${e.new??"New"}</calcite-chip></div>${t?p`<p>${e.capabilities??"The assistant uses artificial intelligence to generate Arcade expressions."}</p><p>${e.keepinmind??"Keep in mind the following:"}<ul><li>${e.beconsise??"Be concise, but also clear in your request"}</li><li>${e.avoidambiguity??"Avoid ambiguity and vagueness"}</li><li>${e.moredetails??"you do not need to use exact field names in your instructions, but more detail is generally better"}</li></ul>${V((e.seedocumentation??"Please see the {documentation} for more information, including limitations and additional resources.").replace("{documentation}",`<calcite-link href=${a} target="_blank">${e.documentation??"documentation"}</calcite-link>`))}</p>`:p`<p>${e.useofassistant??"The assistant uses artificial intelligence to generate Arcade expressions. To enable Arcade Assistant (beta), the following must be true:"}</p><ul><li>${e.enabledinorg??"AI assistants are enabled in the organization settings"}</li><li>${e.enabledbetaapps??"Beta apps and capabilities are not blocked"}</li><li>${e.enabledroleprivilege??"Your role privilege allows you to use AI assistants"}</li></ul>`}</calcite-block>`}function Je({messages:t,onProceed:e,onExit:i,helpTopicUrl:a}){return p`<calcite-dialog close-disabled placement=top .heading=${t.welcome??"Welcome to the new assistant experience"} slot=dialogs open width-scale=m id=welcome-dialog><h3 class="unstyled-h3">${t.beforeyougetstarted??"Before you get started be aware:"}</h3><ul><li>${t.maybeincorrect??"AI generated code may occasionally be incorrect or biased. Review carefully."}</li><li>${V((t.pleasereadhelp??"Read the Arcade Assistant (beta) {helpTopic} to get started and learn details on security, privacy and limitations.").replace("{helpTopic}",`<calcite-link href=${a} target="_blank">${t.helptopic??"help topic"}</calcite-link>`))}</li></ul><calcite-button id=welcome-proceed slot=footer-end @click=${e}>${t.proceed??"Proceed"}</calcite-button><calcite-button id=welcome-decline slot=footer-start @click=${i} kind=neutral>${t.exit??"Exit"}</calcite-button></calcite-dialog>`}function Ye({messages:t,suggestions:e,onSuggestionClick:i}){return p`<calcite-block .heading=${t.promptsuggestions} expanded collapsible id=suggestion-block scale=s><div class="suggestions">${e.map(a=>p`<calcite-button round scale=s appearance=outline-fill kind=neutral .label=${t.promptsuggestion} class="suggestion-button" @click=${()=>i?.(a)}>${a}</calcite-button>`)}</div></calcite-block>`}var he=200;function ge({hidden:t=!1,expanded:e=!1,messages:i,cards:a,heading:s,collapsible:n=!1,showEffectsIcon:l=!1,onCopyCode:d,standalone:c}){return p`<calcite-block .hidden=${t} id=result-block .heading=${s??i.besteffort??"Here is the assistant's best effort"} .expanded=${e} .collapsible=${n}>${l&&p`<calcite-chip .label=${i.assistantresponses??"Assistant responses"} slot=content-start icon=effects scale=m class="suggestion-chips"></calcite-chip>`||""}<calcite-card-group .label=${i.assistantresponses??"Assistant responses"}>${L(a,o=>o.conversationId,o=>p`<calcite-card><div slot=heading><div class="prior-prompt"><span>${o.priorPrompt.length>he?`${o.priorPrompt.slice(0,he)}...`:o.priorPrompt}</span><calcite-action icon=duplicate scale=s slot=actions-end class="copy-prompt-button" text .id=${`copy-prompt-${o.conversationId}-${c?"standalone":"list"}`} @click=${g=>{let r=g.currentTarget;navigator.clipboard.writeText(o.priorPrompt).then(()=>{r.setAttribute("data-copied","true"),setTimeout(()=>r.removeAttribute("data-copied"),1500)})}}></calcite-action><calcite-popover .referenceElement=${`copy-prompt-${o.conversationId}-${c?"standalone":"list"}`} placement=top-start class="copy-feedback" .label=${i.copiedsuccessfully??"copied successfully"} open trigger-disabled><span>${i.copiedsuccessfully??"copied successfully"}</span></calcite-popover><calcite-tooltip .referenceElement=${`copy-prompt-${o.conversationId}-${c?"standalone":"list"}`} placement=top-start class="copy-tooltip">${i.copyprompttoclipboard??"Copy prompt to clipboard"}</calcite-tooltip></div>${o.message&&c&&p`<div class="response-error-container">${ze({errorMessage:o.message})}</div>`||""}</div><div><div class="code-response-wrapper"><div class="positioned-code-content"><calcite-chip-group .label=${i.responsecontext??"Response Context"} scale=s>${o.message&&!c&&p`<calcite-tooltip .referenceElement=${`response-chip-${o.conversationId}-error`} placement=top-start>${o.message}</calcite-tooltip><calcite-chip .id=${`response-chip-${o.conversationId}-error`} .label=${i.error??"Error"} scale=s appearance=outline icon=exclamation-mark-triangle-f class="response-error-chip"></calcite-chip>`||""}${We({card:o,messages:i})}</calcite-chip-group></div><details class="collapsible-code" open><summary>Code response</summary><arcgis-code-viewer language=arcade round>${o.code}</arcgis-code-viewer></details></div></div><div slot=footer-start class="feedback-actions"><calcite-button class="add-to-editor-button hidden-above-380" @click=${()=>o.onAddToEditor("add")} scale=s icon-start=plus round .label=${i.addtoeditor??"Add to editor"} .id=${`add-to-editor-button-${o.conversationId}-${c?"standalone":"list"}`}></calcite-button><calcite-tooltip class="hidden-above-380" .referenceElement=${`add-to-editor-button-${o.conversationId}-${c?"standalone":"list"}`} placement=top-start>${i.addtoeditor??"Add to editor"}</calcite-tooltip><calcite-button class="add-to-editor-button hidden-below-380" @click=${()=>o.onAddToEditor("add")} scale=s icon-start=plus round>${i.addtoeditor??"Add to editor"}</calcite-button><calcite-button round icon-start=file-code kind=neutral scale=s @click=${()=>o.onAddToEditor("replace")} class="response-secondary-action-button" .id=${`replace-${o.conversationId}-${c?"standalone":"list"}`}></calcite-button><calcite-tooltip .referenceElement=${`replace-${o.conversationId}-${c?"standalone":"list"}`} placement=top-start><span>${i.replaceineditor??"Replace all code in editor"}</span></calcite-tooltip><calcite-button round icon-start=copy-to-clipboard kind=neutral scale=s @click=${g=>{let r=g.currentTarget;d(o.code).then(()=>{r.setAttribute("data-copied","true"),setTimeout(()=>r.removeAttribute("data-copied"),1500)})}} class="response-secondary-action-button" .id=${`copy-response-${o.conversationId}-${c?"standalone":"list"}`}></calcite-button><calcite-popover .referenceElement=${`copy-response-${o.conversationId}-${c?"standalone":"list"}`} placement=top-start class="copy-feedback" .label=${i.copiedsuccessfully??"copied successfully"} open trigger-disabled><span>${i.copiedsuccessfully??"copied successfully"}</span></calcite-popover><calcite-tooltip .referenceElement=${`copy-response-${o.conversationId}-${c?"standalone":"list"}`} placement=top-start class="copy-tooltip">${i.copytoclipboard??"Copy code to clipboard"}</calcite-tooltip></div><div slot=footer-end class="feedback-actions"><calcite-action .text=${i.thumbsup??"Thumbs up"} scale=s icon=thumbs-up @click=${o.onThumbsUp} .id=${`thumbs-up-${o.conversationId}-${c?"standalone":"list"}`}></calcite-action><calcite-tooltip .referenceElement=${`thumbs-up-${o.conversationId}-${c?"standalone":"list"}`} placement=top-start><span>${i.helpful??"Helpful"}</span></calcite-tooltip><calcite-action .text=${i.thumbsdown??"Thumbs down"} scale=s icon=thumbs-down @click=${o.onThumbsDown} .id=${`thumbs-down-${o.conversationId}-${c?"standalone":"list"}`}></calcite-action><calcite-tooltip .referenceElement=${`thumbs-down-${o.conversationId}-${c?"standalone":"list"}`} placement=top-start><span>${i.unhelpful??"Unhelpful"}</span></calcite-tooltip></div></calcite-card>`)}</calcite-card-group></calcite-block>`}var We=({card:t,messages:e})=>{let i=K(),a=`response-chip-profile-${t.conversationId}-${i}`,s=(e.profilecontextlabel??"Profile context: {profileId}").replace("{profileId}",t.profileId);return p`<calcite-tooltip .referenceElement=${a} placement=top-start class="contained-popover-or-tooltip">${s}</calcite-tooltip><calcite-chip .label=${t.profileId} scale=s appearance=outline icon=map-information id=${a??O}>${t.profileId}</calcite-chip>`},be=t=>t.type==="featureSet",B=t=>{if(!le(t))return[];let e=[];return t.relationships?.forEach(i=>{e.push(i.toJSON())}),e},j=t=>t.length>0?{relationships:t}:{},Ke=t=>ce(t).map(e=>({alias:e.alias,name:e.name,type:e.type,...e.domain?{domain:e.domain}:{}})),H=t=>t?{fields:Ke(t)}:{fields:[]};async function fe(t){let e=await t.loadSource(),i=F(e)&&e.isTable,a=B(e);return{name:t.name,type:"featureSet",isTable:i,...H(e?.fields),...j(a)}}async function xe(t){switch(t.type){case"feature":{let e=await t.loadSource(),i=B(e);return{name:t.name,type:t.type,...H(e?.fields),...j(i)}}case"featureSet":{let e=await t.loadSource(),i=F(e)&&e.isTable;return{name:t.name,type:"featureSet",...i?{isTable:i}:{},...H(e?.fields),...j(B(e))}}case"featureSetCollection":{let e=await t.loadSource(),i=e?.layers.filter(be)??[],a=e?.tables.filter(be)??[],s=await Promise.all(i.map(fe)),n=await Promise.all(a.map(fe));return{name:t.name,type:"featureSetCollection",layers:s,tables:n}}case"dictionary":{let e=await Promise.all(t.dictionaryVariables.map(xe));return{name:t.name,type:"dictionary",attributes:e}}case"pixel":{let e=await t.loadSource();if(!e)return{name:t.name,type:"pixel"};let i=await Me(e);return{name:t.name,type:"pixel",members:i.map(ve)}}case"voxel":{let e=await t.loadSource();if(!e)return{name:t.name,type:"voxel"};let i=await Ie(e);return{name:t.name,type:"voxel",members:i.map(ve)}}case"array":return{name:t.name,type:"array",elementType:t.elementType.type};case"number":case"text":case"boolean":case"date":case"knowledgeGraph":case"dateOnly":case"geometry":case"time":return{name:t.name,type:t.type}}}function ve(t){return t.type==="array"?{name:t.name,type:"array",elementType:t.elementType.type}:{name:t.name,type:t.type}}async function Xe(t){return{variables:await Promise.all(t.variables.map(xe))}}var Ze=1e5;function et(t){let e=new TextEncoder().encode(t).length;return Math.ceil(e/3.5)}function Q(t){return et(JSON.stringify(t))}function tt(t){let e=a=>({name:a.name,type:a.type,...a.isTable?{isTable:a.isTable}:{},...a.relationships?{relationships:a.relationships}:{}}),i=a=>{switch(a.type){case"feature":case"featureSet":case"knowledgeGraph":return{name:a.name,type:a.type,..."isTable"in a&&a.isTable?{isTable:a.isTable}:{},..."relationships"in a?{relationships:a.relationships}:{}};case"featureSetCollection":return{name:a.name,type:"featureSetCollection",layers:a.layers.map(e),tables:a.tables.map(e)};case"dictionary":return{name:a.name,type:"dictionary",attributes:a.attributes.map(i)};case"pixel":case"voxel":return{name:a.name,type:a.type};case"array":return{name:a.name,type:"array",...a.elementType?{elementType:a.elementType}:{}};default:return a}};return{variables:t.variables.map(i)}}function it(t){let e=t.variables,i=e.length,a=e.find(n=>n.name==="$feature")??e.find(n=>n.type==="feature")??e[0],s=a?[a]:[];return{context:{variables:s},wasReduced:i!==s.length,reducedToVariableName:a?.name}}function at(t){return Q(t)>Ze}var st=Object.defineProperty,ot=Object.getOwnPropertyDescriptor,y=(t,e,i,a)=>{for(var s=a>1?void 0:a?ot(e,i):e,n=t.length-1,l;n>=0;n--)(l=t[n])&&(s=(a?l(e,i,s):l(s))||s);return a&&s&&st(e,i,s),s},b=class extends Ee{constructor(t){super(t),this.viewMode="prompt",this.confirmationActive=!1,this.contextReducedNoticeDismissed=!1,this.splashActive=!0,this.isSubmitting=!1,this.question="",this.history=[],this.feedback={active:!1}}};y([w()],b.prototype,"viewMode",2);y([w()],b.prototype,"confirmationActive",2);y([w()],b.prototype,"contextReducedNoticeDismissed",2);y([w()],b.prototype,"splashActive",2);y([w()],b.prototype,"isSubmitting",2);y([w()],b.prototype,"errorMessage",2);y([w()],b.prototype,"promptValidationMessage",2);y([w()],b.prototype,"question",2);y([w()],b.prototype,"history",2);y([w()],b.prototype,"feedback",2);y([w()],b.prototype,"context",2);b=y([Re("ArcadeAssistantViewState")],b);var nt="arcade_generation",rt="ArcadeCodeRequest",ye="visualization",ct="ArcadeAssistant",lt=["your_comments","user_evaluation","question","answer","useragent","_source","version","context","extras"],we=[],$e=!0,G=class extends ie{constructor(){super(...arguments),this.textAreaRef=ee(),this.messages=oe(),this._feedbackService=void 0,this.viewState=new b,this.handleFeedbackButton=(e,i)=>{this.updateViewState({feedback:{active:!0,value:e,item:i,termsAccepted:!1,text:"",submitting:!1}})},this.handleFeedbackSheetClose=()=>{this.updateViewState({feedback:{active:!1}})},this.handleFeedbackSubmit=async()=>{if(!this.viewState.feedback.active)return;this.updateViewState({feedback:{...this.viewState.feedback,submitting:!0}});let e=await this.ensureFeedbackService();if(!e){this.handleFeedbackSheetClose();return}let i=this.viewState.feedback.item.contextSnapshot,a=Ae.applicationName;!a&&!this.appVersion&&T("warn",this,"esriConfig.applicationName is not set. Consider setting it to help identify the application version in feedback.");let{value:s,text:n,termsAccepted:l,item:{question:d,formattedScript:c,conversationId:o}}=this.viewState.feedback,g={user_evaluation:s,your_comments:n||void 0,question:d??"",answer:encodeURIComponent(c??""),useragent:navigator.userAgent,_source:ct,version:this.appVersion||a||"NOT_SET",context:i?JSON.stringify(i):"",extras:i?.profileId??"",conversation_id:o??"",privacy_statement:l?"I_agree":""};try{await e.applyEdits({addFeatures:[new Ce({attributes:g})]})}catch(r){T("error",this,"Error submitting feedback.",{detail:{error:r}})}this.handleFeedbackSheetClose()},this.handleClose=e=>{this.closed=!0,this.closePanel?.(e)},this.setQuestionState=e=>{this.updateViewState({question:e,promptValidationMessage:void 0})},this.setFeedbackState=e=>{this.updateViewState({feedback:e})},this.onSuggestionClick=e=>{this.textAreaRef.value&&(this.textAreaRef.value.value=e,this.textAreaRef.value.setFocus(),this.setQuestionState(e))},this.helpBase="",this.assistantsEnabled=!1,this.closed=!1}static{this.properties={closePanel:0,insertText:0,helpBase:1,assistantsEnabled:5,portalUrl:1,serviceUrl:1,closed:7,editorRef:0,feedbackServiceUrl:1,appVersion:1}}static{this.styles=Ve}get disclaimerComment(){return`// ${this.messages.disclaimercomment}
|
|
3
|
-
// ${this.messages.disclaimerpt2??"AI-generated content may be inaccurate. Review before using."}`}get assistantOverviewDocUrl(){return`${this.helpBase??"https://doc.arcgis.com/en/arcgis-online/"}create-maps/understand-arcade-assistant.htm`}get usingTheAssitantDocUrl(){return`${this.helpBase??"https://doc.arcgis.com/en/arcgis-online/"}create-maps/use-arcade-assistant.htm`}async destroy(){}connectedCallback(){super.connectedCallback(),this.updateViewState({history:we,splashActive:$e})}load(){let e=async()=>{let i=this.getModel();if(!i){this.updateViewState({context:void 0});return}let a=await this.getProfileAndMetadata(i.uri);this.updateViewState({context:a,contextReducedNoticeDismissed:a.contextTooLarge?!1:this.viewState.contextReducedNoticeDismissed})};e().catch(i=>{T("error",this,"Error setting initial context.",{detail:{error:i}})}),this.manager.onLifecycle(()=>{let i=z.onModelContextDidChange(async()=>{e().catch(a=>{T("error",this,"Error setting context.",{detail:{error:a}})})});return{remove:()=>{i.dispose()}}})}disconnectedCallback(){super.disconnectedCallback(),we=this.viewState.history,$e=this.viewState.splashActive,this.copySuccessTimer&&(clearTimeout(this.copySuccessTimer),this.copySuccessTimer=void 0)}createFeedbackContextSnapshot(e){let i=tt(e.metadata);return{...e,metadata:i,estimatedTokens:Q(i)}}updateViewState(e){this.viewState.set(e)}getHistoryCards(){return this.viewState.history.reduce((e,i)=>(!i.script||(e.push({priorPrompt:i.question,code:i.formattedScript||i.error||"",profileId:i.profile??ye,onAddToEditor:a=>{ne(this.editorRef.editorInstance,i.formattedScript??"",a,this.disclaimerComment)},onThumbsUp:()=>this.handleFeedbackButton("good",i),onThumbsDown:()=>this.handleFeedbackButton("bad",i),conversationId:i.conversationId??"",message:i.message}),this.viewState.viewMode),e),[])}async ensureFeedbackService(){if(this._feedbackService)return this._feedbackService;if(!this.feedbackServiceUrl)return;let e=new Te({url:this.feedbackServiceUrl});await e.load();let i=lt.filter(a=>!e.fields.some(s=>s.name===a));if(i.length>0){T("error",this,`Missing the following fields in feedback service: ${i.join(", ")}. Feedback will not be logged.`);return}return this._feedbackService=e,e}getModel(){return this.editorRef.editorInstance?.getModel()}async submitQuestion(){if(this.viewState.question){this.updateViewState({isSubmitting:!0,errorMessage:void 0});try{let e=await this.getToken(),i=this.getModel();if(!i)return;let a=this.viewState.context??await this.getProfileAndMetadata(i.uri),s=(await Pe({baseUrl:this.serviceUrl,skillId:nt,message:this.viewState.question,authToken:e,context:{kind:rt,context:{profile_id:a.profileId,metadata:[a.metadata]}}})).find(n=>n.context?.kind==="ArcadeCodeResponse");if(!s)return;if(s.context?.kind==="ArcadeCodeResponse"){let n=this.createFeedbackContextSnapshot(a);this.updateViewState({history:[{script:s?.context?.arcadeCode?.code,formattedScript:re(s?.context?.arcadeCode?.code??""),error:void 0,question:this.viewState.question,profile:a.profileId,conversationId:s.conversationId,contextSnapshot:n,...s.message?{message:s.message}:{}},...this.viewState.history],viewMode:"result",errorMessage:void 0})}}catch(e){e instanceof Error&&e.name==="ArcadeAssistantError"?this.updateViewState({errorMessage:qe(e)||this.messages.erroroccurred||"An error occurred."}):this.updateViewState({errorMessage:this.messages.erroroccurred||"An error occurred."}),T("error",this,"Error submitting question",{detail:{error:e}})}finally{this.updateViewState({isSubmitting:!1})}}}async getToken(){let{token:e}=await Se.getCredential(this.portalUrl);return e}async getProfileAndMetadata(e){let i=ye,a=z.getEditorProfileForModel(e);a?.loaded||await a?.loadSource();let s=this.editorRef.profile;s&&"id"in s&&(i=s.id);let n=a?await Xe(a):{variables:[]},l=at(n),d=l?it(n):void 0,c=d?d.context:n,o=Q(c);return{profileId:i,metadata:c,contextTooLarge:l,reducedToVariableName:d?.reducedToVariableName,estimatedTokens:o}}onCopyCode(e){let i=e?`${this.disclaimerComment}
|
|
3
|
+
// ${this.messages.disclaimerpt2??"AI-generated content may be inaccurate. Review before using."}`}get assistantOverviewDocUrl(){return`${this.helpBase??"https://doc.arcgis.com/en/arcgis-online/"}create-maps/understand-arcade-assistant.htm`}get usingTheAssitantDocUrl(){return`${this.helpBase??"https://doc.arcgis.com/en/arcgis-online/"}create-maps/use-arcade-assistant.htm`}async destroy(){}connectedCallback(){super.connectedCallback(),this.updateViewState({history:we,splashActive:$e})}load(){let e=async()=>{let i=this.getModel();if(!i){this.updateViewState({context:void 0});return}let a=await this.getProfileAndMetadata(i.uri);this.updateViewState({context:a,contextReducedNoticeDismissed:a.contextTooLarge?!1:this.viewState.contextReducedNoticeDismissed})};e().catch(i=>{T("error",this,"Error setting initial context.",{detail:{error:i}})}),this.manager.onLifecycle(()=>{let i=z.onModelContextDidChange(async()=>{e().catch(a=>{T("error",this,"Error setting context.",{detail:{error:a}})})});return{remove:()=>{i.dispose()}}})}disconnectedCallback(){super.disconnectedCallback(),we=this.viewState.history,$e=this.viewState.splashActive,this.copySuccessTimer&&(clearTimeout(this.copySuccessTimer),this.copySuccessTimer=void 0)}createFeedbackContextSnapshot(e){let i=tt(e.metadata);return{...e,metadata:i,estimatedTokens:Q(i)}}updateViewState(e){this.viewState.set(e)}getHistoryCards(){return this.viewState.history.reduce((e,i)=>(!i.script||(e.push({priorPrompt:i.question,code:i.formattedScript||i.error||"",profileId:i.profile??ye,onAddToEditor:a=>{ne(this.editorRef.editorInstance,i.formattedScript??"",a,this.disclaimerComment)},onThumbsUp:()=>this.handleFeedbackButton("good",i),onThumbsDown:()=>this.handleFeedbackButton("bad",i),conversationId:i.conversationId??"",message:i.message}),this.viewState.viewMode),e),[])}async ensureFeedbackService(){if(this._feedbackService)return this._feedbackService;if(!this.feedbackServiceUrl)return;let e=new Te({url:this.feedbackServiceUrl});await e.load();let i=lt.filter(a=>!e.fields.some(s=>s.name===a));if(i.length>0){T("error",this,`Missing the following fields in feedback service: ${i.join(", ")}. Feedback will not be logged.`);return}return this._feedbackService=e,e}getModel(){return this.editorRef.editorInstance?.getModel()}async submitQuestion(){if(this.viewState.question){this.updateViewState({isSubmitting:!0,errorMessage:void 0});try{let e=await this.getToken(),i=this.getModel();if(!i||!this.serviceUrl)return;let a=this.viewState.context??await this.getProfileAndMetadata(i.uri),s=(await Pe({baseUrl:this.serviceUrl,skillId:nt,message:this.viewState.question,authToken:e,context:{kind:rt,context:{profile_id:a.profileId,metadata:[a.metadata]}}})).find(n=>n.context?.kind==="ArcadeCodeResponse");if(!s)return;if(s.context?.kind==="ArcadeCodeResponse"){let n=this.createFeedbackContextSnapshot(a);this.updateViewState({history:[{script:s?.context?.arcadeCode?.code,formattedScript:re(s?.context?.arcadeCode?.code??""),error:void 0,question:this.viewState.question,profile:a.profileId,conversationId:s.conversationId,contextSnapshot:n,...s.message?{message:s.message}:{}},...this.viewState.history],viewMode:"result",errorMessage:void 0})}}catch(e){e instanceof Error&&e.name==="ArcadeAssistantError"?this.updateViewState({errorMessage:qe(e)||this.messages.erroroccurred||"An error occurred."}):this.updateViewState({errorMessage:this.messages.erroroccurred||"An error occurred."}),T("error",this,"Error submitting question",{detail:{error:e}})}finally{this.updateViewState({isSubmitting:!1})}}}async getToken(){let{token:e}=await Se.getCredential(this.portalUrl);return e}async getProfileAndMetadata(e){let i=ye,a=z.getEditorProfileForModel(e);a?.loaded||await a?.loadSource();let s=this.editorRef.profile;s&&"id"in s&&(i=s.id);let n=a?await Xe(a):{variables:[]},l=at(n),d=l?it(n):void 0,c=d?d.context:n,o=Q(c);return{profileId:i,metadata:c,contextTooLarge:l,reducedToVariableName:d?.reducedToVariableName,estimatedTokens:o}}onCopyCode(e){let i=e?`${this.disclaimerComment}
|
|
4
4
|
${e}`:"";return navigator.clipboard.writeText(i)}render(){if(this.closed)return null;let e=this.viewState.viewMode==="result",i=this.getHistoryCards();return this.assistantsEnabled?p`<calcite-flow><calcite-flow-item closable heading-level=2 .heading=${this.messages.arcadeassistant??"Arcade assistant"} @calciteFlowItemClose=${this.handleClose}>${this.viewState.splashActive&&p`<calcite-scrim></calcite-scrim>`||""}${_e({messages:this.messages})}${Fe({messages:this.messages,popoverContent:me({assistantsEnabled:this.assistantsEnabled,messages:this.messages,helpTopicUrl:this.usingTheAssitantDocUrl})})}<calcite-shell class="unstyled-shell">${this.viewState.splashActive&&Je({messages:this.messages,onProceed:()=>{this.updateViewState({splashActive:!1})},helpTopicUrl:this.assistantOverviewDocUrl,onExit:a=>this.closePanel?.(a)})||""}${Le({active:this.viewState.confirmationActive,setActive:a=>this.updateViewState({confirmationActive:a}),messages:this.messages})}${je({isDisabled:this.viewState.isSubmitting,isReadOnly:!1,setQuestion:this.setQuestionState,setIsViewingResult:a=>this.updateViewState({viewMode:a?"result":"prompt"}),mode:e?"refine":"prompt",textAreaRef:this.textAreaRef,question:this.viewState.question,errorMessage:this.viewState.errorMessage,setErrorMessage:a=>this.updateViewState({errorMessage:a}),promptValidationMessage:this.viewState.promptValidationMessage,setPromptValidationMessage:a=>this.updateViewState({promptValidationMessage:a}),submitQuestion:this.submitQuestion.bind(this),assistantRef:this.el,messages:this.messages,context:this.viewState.context,contextReducedNoticeDismissed:this.viewState.contextReducedNoticeDismissed,setContextReducedNoticeDismissed:a=>this.updateViewState({contextReducedNoticeDismissed:a})})}<calcite-block-group .label=${this.messages.interactiveblocks??"interactive blocks"}>${!e&&!this.viewState.isSubmitting&&Ye({messages:this.messages,suggestions:[this.messages.prompsuggestion1??"",this.messages.prompsuggestion2??""],onSuggestionClick:this.onSuggestionClick})||""}<calcite-block .hidden=${!this.viewState.isSubmitting} .heading=${this.messages.generatingresponse??"Generating response..."}></calcite-block>${ge({expanded:e,messages:this.messages,collapsible:!0,showEffectsIcon:!0,cards:i.length?[i[0]]:[],heading:this.messages.besteffort??"Here's the assistant's best effort",hidden:this.viewState.isSubmitting||!e,onCopyCode:this.onCopyCode.bind(this),standalone:!0})}${ge({expanded:!e,messages:this.messages,collapsible:!0,cards:e?i.slice(1):i,heading:this.messages.recentprompts??"Recent prompts",hidden:this.viewState.isSubmitting||this.viewState.history.length===0,onCopyCode:this.onCopyCode.bind(this)})}</calcite-block-group>${this.viewState.feedback.active?Ge({setOpen:this.handleFeedbackSheetClose,messages:this.messages,onSubmit:this.handleFeedbackSubmit,feedback:this.viewState.feedback,setFeedback:this.setFeedbackState,learnMoreUrl:this.assistantOverviewDocUrl}):null}</calcite-shell></calcite-flow-item></calcite-flow>`:p`<calcite-flow><calcite-flow-item .selected=${!e} closable heading-level=2 .heading=${this.messages.arcadeassistant??"Arcade assistant"} @calciteFlowItemClose=${this.handleClose}>${me({slot:"content-top",messages:this.messages,assistantsEnabled:this.assistantsEnabled,helpTopicUrl:this.usingTheAssitantDocUrl})}</calcite-flow-item></calcite-flow>`}};se("arcgis-arcade-coding-assistant",G);return G},"identity/IdentityManager","request","layers/FeatureLayer","config","Graphic","applications/Components/arcadeEditorUtils","core/Accessor","core/accessorSupport/decorators",a,b)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import a from"./4Y64BGY2.js";import{a as S}from"./HPZZVB4X.js";import{a as O}from"./ZYS253RG.js";import"./MP6Z45SA.js";import"./P5D2YYFD.js";import{d as F}from"./IFNCCZ7O.js";import{b as C,c as L}from"./WMLTLTIE.js";import{D as m,E as p,F as T,G as g,H as y,J as M,g as P,h as b,j as t,n as x,p as
|
|
2
|
+
import a from"./4Y64BGY2.js";import{a as S}from"./HPZZVB4X.js";import{a as O}from"./ZYS253RG.js";import"./MP6Z45SA.js";import"./P5D2YYFD.js";import{d as F}from"./IFNCCZ7O.js";import{b as C,c as L}from"./WMLTLTIE.js";import{D as m,E as p,F as T,G as g,H as y,J as M,g as P,h as b,j as t,n as x,p as u,t as r}from"./EMMNZESW.js";import"./BCUUVBXH.js";import"./3TTFCHAA.js";export default $arcgis.t(([{b:o,c:R,d:h,e:I,f:_,g:j}])=>{var J=b`:host{display:flex;flex-direction:column;width:100%;background-color:var(--calcite-color-foreground-1);color:var(--calcite-color-text-2);.flex-adjustable{flex:1 1 auto;overflow:hidden}.flex-row{display:flex;flex-direction:row;overflow:hidden}.flex-column{display:flex;flex-direction:column;overflow:hidden;min-height:0}.y-scrollable-container{overflow-y:auto;block-size:100%;background-color:var(--calcite-color-foreground-1)}header{border-bottom:1px solid var(--calcite-color-border-3);flex:0 0 auto}.ltr-container{direction:ltr}calcite-action-bar{calcite-action-group{padding-inline-end:var(--calcite-spacing-sm);calcite-action{padding-inline-end:var(--calcite-spacing-sm)}calcite-action:not(:first-child){padding-inline-start:var(--calcite-spacing-sm)}}calcite-action-group:last-child{border-inline-end-width:0px}calcite-action-group:not(:first-child){padding-inline-start:var(--calcite-spacing-sm)}}.notice-container{margin:var(--calcite-spacing-xxs);padding:var(--calcite-spacing-sm);background-color:var(--calcite-color-foreground-1)}.color-info{color:var(--calcite-color-status-info)}.color-error{color:var(--calcite-color-status-danger)}.color-success{color:var(--calcite-color-status-success)}[class*=result-value-]{font-size:var(--calcite-font-size--2);line-height:1.25rem;background-color:var(--calcite-color-foreground-1);margin:var(--calcite-spacing-md)}.console-logs-container{background-color:var(--calcite-color-foreground-1);padding:0 var(--calcite-spacing-md);font-family:var(--calcite-code-family);font-size:var(--calcite-font-size--2);font-weight:var(--calcite-font-weight-normal)}.result-value-table{display:flex;flex-direction:column;min-height:0;.table-scroll{overflow:auto;flex:1 1 auto;min-height:0;max-width:100%;background-color:var(--calcite-color-foreground-1)}table{min-width:max-content;border-spacing:0;border-collapse:collapse;text-align:start;white-space:nowrap;thead{background-color:var(--calcite-color-foreground-2)}tr{border-top:1px solid var(--calcite-color-border-3);border-bottom:1px solid var(--calcite-color-border-3)}th,td{border-inline-start:1px solid var(--calcite-color-border-3);border-inline-end:1px solid var(--calcite-color-border-3);text-align:start;padding:var(--calcite-spacing-xxs);.string-value{white-space:pre}}th{font-weight:var(--calcite-font-weight-medium)}}}.tree-item-label,.number-value,.string-value,.boolean-value{font-family:var(--calcite-code-family)}.tree-item-label,.value-type{color:var(--calcite-color-text-2);font-weight:var(--calcite-font-weight-normal)}.dictionary-property{color:var(--arcgis-editor-identifier)}.number-value{color:var(--arcgis-editor-number)}.string-value{color:var(--arcgis-editor-string);white-space:pre-wrap}.constant-value{color:var(--arcgis-editor-constant)}.date-value{color:var(--arcgis-editor-date)}}`,l={lines:!0,selectionMode:"none",scale:"s",oncalciteTreeSelect:e=>e.currentTarget.selectedItems.forEach(a=>a.selected=!1)},v={onClick:e=>{let a=e.currentTarget;a.expanded=!a.expanded}},n=({name:e})=>t`<span class="dictionary-property">${e}</span><span>: </span>`,D=({value:e,subtree:a=!1})=>t`<calcite-tree slot=${(a?"children":void 0)??y} .lines=${l.lines} .selectionMode=${l.selectionMode} .scale=${l.scale} @calciteTreeSelect=${l.oncalciteTreeSelect}><calcite-tree-item class="string-value">${JSON.stringify(e.castAsJson(),void 0,2)}</calcite-tree-item></calcite-tree>`,z=({value:e,subtree:a=!1})=>t`<calcite-tree slot=${(a?"children":void 0)??y} .lines=${l.lines} .selectionMode=${l.selectionMode} .scale=${l.scale} @calciteTreeSelect=${l.oncalciteTreeSelect}><calcite-tree-item><div class="tree-item-label">${n({name:"type"})}${e.type}</div></calcite-tree-item><calcite-tree-item><div class="tree-item-label">${n({name:"value"})}<span class="string-value">${JSON.stringify(e,void 0,2)}</span></div></calcite-tree-item></calcite-tree>`,f=({arcadeResult:e})=>{switch(e.type){case"unknown":case"null":return t`<span class="constant-value">${e.type}</span>`;case"text":return t`<span class="string-value">${u(e.value)}</span>`;case"number":return t`<span class="number-value">${e.value.toString()}</span>`;case"boolean":return t`<span class="constant-value">${e.value.toString()}</span>`;case"date":return t`<span class="date-value">${I(e)}</span>`;case"dateOnly":return t`<span class="string-value">${u(_(e))}</span>`;case"time":return t`<span class="string-value">${u(j(e))}</span>`;default:return null}},N=({arcadeResult:e,t9nStrings:a})=>{let s=e.value??[],i=Math.max(s.length-o,0);return t`<span>${`${e.type}(${s.length??0})`}</span>${i>0?t`<span> ${r(a.showingfirstitemsformat,{count:o.toString()})}</span>`:null}`},E=({value:e,subtree:a,t9nStrings:s})=>{let i=e.geometry?.();return t`<calcite-tree slot=${"children"} .lines=${l.lines} .selectionMode=${l.selectionMode} .scale=${l.scale} @calciteTreeSelect=${l.oncalciteTreeSelect}>${e.keys().map(c=>{let d=h(e.field(c));return e.arcadeDeclaredClass==="esri.arcade.Feature"&&d.type==="geometry"?null:k({arcadeResult:d,name:c,t9nStrings:s})})}${i?k({arcadeResult:{type:"geometry",value:i},name:"geometry",t9nStrings:s}):null}</calcite-tree>`},G=({arcadeResult:e,t9nStrings:a})=>t`<div class="value-type"><span>${e.type}:</span>${e.features.length>=R?t`<span> ${r(a.showingfirstitemsformat,{count:R.toString()})}</span>`:null}</div>`,A=({items:e,subtree:a,t9nStrings:s})=>t`<calcite-tree slot=${"children"} .lines=${l.lines} .selectionMode=${l.selectionMode} .scale=${l.scale} @calciteTreeSelect=${l.oncalciteTreeSelect}>${e.map((i,c)=>{let d=h(i);return k({arcadeResult:d,name:c,expanded:!a,t9nStrings:s})})}</calcite-tree>`,k=({arcadeResult:e,name:a,expanded:s,t9nStrings:i})=>{switch(e.type){case"null":case"unknown":case"text":case"number":case"date":case"dateOnly":case"time":case"boolean":return t`<calcite-tree-item><div class="tree-item-label">${n({name:a})}${f({arcadeResult:e})}</div></calcite-tree-item>`;case"array":{let c=(e.value??[]).slice(0,o);return t`<calcite-tree-item .expanded=${s} @click=${v.onClick}><div class="tree-item-label">${n({name:a})}${N({arcadeResult:e,t9nStrings:i})}</div>${A({items:c,subtree:!0,t9nStrings:i})}</calcite-tree-item>`}case"geometry":return t`<calcite-tree-item .expanded=${s} @click=${v.onClick}><div class="tree-item-label">${n({name:a})}<span>${e.type}</span></div>${z({value:e.value,subtree:!0})}</calcite-tree-item>`;case"attachment":return t`<calcite-tree-item .expanded=${s} @click=${v.onClick}><div class="tree-item-label">${n({name:a})}<span>${e.type}</span></div>${D({value:e.value,subtree:!0})}</calcite-tree-item>`;case"feature":case"dictionary":case"portal":return t`<calcite-tree-item .expanded=${s} @click=${v.onClick}><div class="tree-item-label">${n({name:a})}<span>${e.type}</span></div>${E({value:e.value,subtree:!0,t9nStrings:i})}</calcite-tree-item>`;default:return null}},V=({arcadeResult:e})=>{let a=F(e.value.fields);return t`<div class="table-scroll"><table><thead><tr>${a.map(s=>t`<th>${s.name}</th>`)}</tr></thead><tbody>${e.features.map(s=>t`<tr>${a.map(i=>{try{let c=h(s.field(i.name));return t`<td>${f({arcadeResult:c})}</td>`}catch{return t`<td></td>`}})}</tr>`)}</tbody></table></div>`};function q(){let e=`:host {
|
|
3
3
|
`,a=S["light-theme"];Object.entries(a).forEach(([i,c])=>{e+=` --arcgis-editor-${i}: ${c};
|
|
4
4
|
`}),e+=`}
|
|
5
5
|
`,e+=`:host([calcite-mode-dark]) {
|
|
@@ -18238,7 +18238,7 @@ function se(t, e, r, n) {
|
|
|
18238
18238
|
const fr = { apiKey: void 0, apiKeys: { scopes: [] }, applicationName: "", applicationUrl: globalThis.location?.href, assetsPath: "", fontsUrl: "https://static.arcgis.com/fonts", geometryServiceUrl: "https://utility.arcgisonline.com/arcgis/rest/services/Geometry/GeometryServer", geoRSSServiceUrl: "https://utility.arcgis.com/sharing/rss", kmlServiceUrl: "https://utility.arcgis.com/sharing/kml", userPrivilegesApplied: !0, portalUrl: "https://www.arcgis.com", respectPrefersReducedMotion: !0, routeServiceUrl: "https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World", workers: { loaderConfig: { has: {}, paths: {}, map: {}, packages: [] } }, request: { crossOriginNoCorsDomains: null, httpsDomains: ["arcgis.com", "arcgisonline.com", "esrikr.com", "premiumservices.blackbridge.com", "esripremium.accuweather.com", "gbm.digitalglobe.com", "firstlook.digitalglobe.com", "msi.digitalglobe.com"], interceptors: [], internalInterceptors: [], maxUrlLength: 2e3, priority: "high", proxyRules: [], proxyUrl: null, timeout: 62e3, trustedServers: [], useIdentity: !0 }, log: { interceptors: [], level: null } };
|
|
18239
18239
|
if (globalThis.esriConfig && (q4(fr, globalThis.esriConfig, !0), delete fr.has), !fr.assetsPath) {
|
|
18240
18240
|
{
|
|
18241
|
-
const t = "5.0.0-next.
|
|
18241
|
+
const t = "5.0.0-next.116";
|
|
18242
18242
|
fr.assetsPath = `https://cdn.jsdelivr.net/npm/@arcgis/core@${t}/assets`;
|
|
18243
18243
|
}
|
|
18244
18244
|
fr.defaultAssetsPath = fr.assetsPath;
|
package/dist/cdn/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{I as s,u as e}from"./EMMNZESW.js";import"./BCUUVBXH.js";import"./3TTFCHAA.js";var i=e(s,{"arcgis-arcade-coding-assistant":[()=>import("./
|
|
2
|
+
import{I as s,u as e}from"./EMMNZESW.js";import"./BCUUVBXH.js";import"./3TTFCHAA.js";var i=e(s,{"arcgis-arcade-coding-assistant":[()=>import("./LYTYTEMO.js"),"appVersion,assistantsEnabled,closed,closePanel:,editorRef:,feedbackServiceUrl,helpBase,insertText:,portalUrl,serviceUrl;destroy"],"arcgis-arcade-editor":[()=>import("./2KBW6YWT.js"),"arcadeAssistant:,customPanels:,editorInstance:,editorOptions:,hideDocumentationActions,hideSideBar,messages:,openedSidePanel,profile:,script,sideActionBarExpanded,snippets:,suggestions:,testData:;getTestResult,setFocus"],"arcgis-arcade-results":[()=>import("./ZGBZ6BXY.js"),"calciteModeDark,consoleLogs:,loading,openedResultPanel,result:"],"arcgis-arcade-suggestions":[()=>import("./44MLHT3A.js"),"closed,suggestions:"],"arcgis-code-editor":[()=>import("./3FUUECYI.js"),"editorInstance:,editorOptions:,language,modelId,value;insertSnippet,insertText,setFocus"],"arcgis-code-editor-shell":[()=>import("./3C7TCPV5.js")],"arcgis-code-viewer":[()=>import("./6U5PWF5V.js"),"language,round"],"arcgis-editor-variables":[()=>import("./DTZPALJA.js"),"closed,loading,modelId,variable:"],"arcgis-language-api-panel":[()=>import("./H75CMJQP.js"),"apiLibrary:,closed,hideDocumentationActions,languageId,loading"],"arcgis-sql-expression-editor":[()=>import("./Q7MXMDGS.js"),"hideSideBar,messages:,profile:,script;setFocus"]});i({resourcesUrl:import.meta.url});var t=new CSSStyleSheet;t.replaceSync("@layer{:not([hydrated]):is(arcgis-arcade-editor,arcgis-code-editor,arcgis-code-editor-shell,arcgis-code-viewer,arcgis-sql-expression-editor){visibility:hidden}}");document.adoptedStyleSheets=[...document.adoptedStyleSheets,t];window.$arcgis||Object.defineProperty(window,"$arcgis",{configurable:!1,enumerable:!0,writable:!1,value:{}}),((a,r)=>{a.t=(c,...x)=>Promise.all(x.map(x=>x.then?x:(!a?.forceESM&&a?.import||(x=>import(x+".js").then(m=>m.default??m)))("@arcgis/core/"+x))).then(c);r.p=a.t(([m])=>{r.t=m.trackAccess;r.o=m.createObservable;r.c=m.createTrackingTarget;r.r=m.runTracked},"applications/Components/reactiveUtils")})($arcgis,s)
|
|
@@ -650,7 +650,7 @@ class Ke extends ie {
|
|
|
650
650
|
this.updateViewState({ isSubmitting: !0, errorMessage: void 0 });
|
|
651
651
|
try {
|
|
652
652
|
const e = await this.getToken(), i = this.getModel();
|
|
653
|
-
if (!i)
|
|
653
|
+
if (!i || !this.serviceUrl)
|
|
654
654
|
return;
|
|
655
655
|
const o = this.viewState.context ?? await this.getProfileAndMetadata(i.uri), n = (await we({
|
|
656
656
|
baseUrl: this.serviceUrl,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import { g as
|
|
3
|
-
import { css as
|
|
4
|
-
import { KeyCode as
|
|
2
|
+
import { g as I, c as D } from "../../chunks/runtime.js";
|
|
3
|
+
import { css as C, html as s, nothing as b } from "lit";
|
|
4
|
+
import { KeyCode as B } from "monaco-editor";
|
|
5
5
|
import "monaco-editor/esm/vs/editor/standalone/browser/standaloneServices.js";
|
|
6
6
|
import "monaco-editor/esm/vs/editor/standalone/common/standaloneTheme.js";
|
|
7
7
|
import "monaco-editor/esm/vs/platform/hover/browser/hover.js";
|
|
@@ -9,21 +9,21 @@ import "monaco-editor/esm/vs/editor/common/languages/supports/tokenization.js";
|
|
|
9
9
|
import "monaco-editor/esm/vs/base/browser/dom.js";
|
|
10
10
|
import "monaco-editor/esm/vs/editor/browser/editorDom.js";
|
|
11
11
|
import "monaco-editor/esm/vs/editor/browser/controller/mouseTarget.js";
|
|
12
|
-
import { LitElement as
|
|
13
|
-
import { generateGuid as
|
|
14
|
-
import { D as
|
|
15
|
-
import { s as
|
|
12
|
+
import { LitElement as k, createEvent as v, safeClassMap as l } from "@arcgis/lumina";
|
|
13
|
+
import { generateGuid as M } from "@arcgis/toolkit/string";
|
|
14
|
+
import { D as T, e as x } from "../../chunks/arcade-executor.js";
|
|
15
|
+
import { s as U, g as L } from "../../chunks/arcade-service-accessors.js";
|
|
16
16
|
import { b as c } from "../../chunks/arcade-defaults.js";
|
|
17
|
-
import { u as
|
|
18
|
-
import { createRef as
|
|
19
|
-
import
|
|
20
|
-
import { log as
|
|
21
|
-
const
|
|
17
|
+
import { u as F } from "../../chunks/useT9n.js";
|
|
18
|
+
import { createRef as N, ref as H } from "lit/directives/ref.js";
|
|
19
|
+
import R from "@arcgis/core/identity/IdentityManager.js";
|
|
20
|
+
import { log as O, rethrowError as o } from "@arcgis/toolkit/log";
|
|
21
|
+
const j = C`:host{height:100%}calcite-tooltip:not([calcite-hydrated])>*{display:none}.main-action-bar{calcite-action-group{padding-inline-end:var(--calcite-spacing-sm)}calcite-action-group calcite-action{padding-inline-end:var(--calcite-spacing-sm)}calcite-action-group calcite-action:not(:first-child){padding-inline-start:var(--calcite-spacing-sm)}calcite-action-group:last-child{border-inline-end-width:0px}calcite-action-group:not(:first-child){padding-inline-start:var(--calcite-spacing-sm)}}`, E = "https://services6.arcgis.com/HXHga6CfMLMBOlBX/ArcGIS/rest/services/survey123_6e349a50b4504ca6b6107216d568db5f_form/FeatureServer/0", a = (i, e) => O(i, "Arcade Assistant", e), z = (i) => {
|
|
22
22
|
const { aiAssistantsEnabled: e } = i;
|
|
23
23
|
return e === void 0 ? (a("warn", "`areAiAssistantsEnabled` is not defined in the organizations settings."), !1) : e;
|
|
24
|
-
}, V = (i) => !(!i || !("id" in i)), G = async (i) => (await
|
|
24
|
+
}, V = (i) => !(!i || !("id" in i)), G = async (i) => (await R.getCredential(i, { oAuthPopupConfirmation: !1 })).token, q = async (i) => {
|
|
25
25
|
try {
|
|
26
|
-
return !!await
|
|
26
|
+
return !!await R.checkSignInStatus(i);
|
|
27
27
|
} catch {
|
|
28
28
|
return a("warn", "User is not signed in."), !1;
|
|
29
29
|
}
|
|
@@ -37,42 +37,46 @@ async function X({
|
|
|
37
37
|
const t = i.replace(/\/sharing\/rest(\/.*)?$/iu, "").replace(/\/$/u, "");
|
|
38
38
|
if (!await q(t))
|
|
39
39
|
return { shouldRender: !1 };
|
|
40
|
-
const n = await G(i), h = `${t}/sharing/rest/portals/self?f=json&token=${n}`, p = `${t}/sharing/rest/portals/self/settings?f=json&token=${n}`, u = `${t}/sharing/rest/portals/self/signinSettings?f=json&token=${n}`,
|
|
40
|
+
const n = await G(i), h = `${t}/sharing/rest/portals/self?f=json&token=${n}`, p = `${t}/sharing/rest/portals/self/settings?f=json&token=${n}`, u = `${t}/sharing/rest/portals/self/signinSettings?f=json&token=${n}`, w = await Promise.allSettled([
|
|
41
41
|
fetch(h, { credentials: "include" }).then((r) => r.json()),
|
|
42
42
|
fetch(p, { credentials: "include" }).then((r) => r.json()),
|
|
43
43
|
fetch(u, { credentials: "include" }).then((r) => r.json())
|
|
44
|
-
]), [g, f, _] =
|
|
45
|
-
if (!$)
|
|
46
|
-
return a("warn", "Service URL is not available in the portal self response."), { shouldRender: !1 };
|
|
47
|
-
const w = m.helpBase || "";
|
|
44
|
+
]), [g, f, _] = w, m = g.status === "fulfilled" ? g.value : (a("warn", `Failed to fetch selfUrl. Reason: ${g.reason}.`), {}), S = f.status === "fulfilled" ? f.value : (a("warn", `Failed to fetch settingsUrl. Reason: ${f.reason}.`), {}), y = _.status === "fulfilled" ? _.value : (a("warn", `Failed to fetch signinSettingsUrl. Reason: ${_.reason}.`), {}), $ = m.helpBase || "";
|
|
48
45
|
if (!S)
|
|
49
46
|
return a("warn", "Settings response is not available."), { shouldRender: !1 };
|
|
50
47
|
let A = z(S);
|
|
51
|
-
|
|
48
|
+
y.blockBetaApps === !0 && (a(
|
|
52
49
|
"warn",
|
|
53
50
|
"Arcade Assistant is blocked by the organization settings. To enable it, do not block beta apps in the organization settings."
|
|
54
|
-
), A = !1), m?.user?.privileges?.includes("portal:user:useAIAssistants") || (a("warn", "User does not have the required privileges to use AI Assistants."), A = !1)
|
|
51
|
+
), A = !1), m?.user?.privileges?.includes("portal:user:useAIAssistants") || (a("warn", "User does not have the required privileges to use AI Assistants."), A = !1);
|
|
52
|
+
const P = m?.helperServices?.aiAssistantServices?.url;
|
|
53
|
+
return P ? {
|
|
55
54
|
shouldRender: !0,
|
|
56
|
-
serviceUrl:
|
|
57
|
-
helpBase:
|
|
55
|
+
serviceUrl: P,
|
|
56
|
+
helpBase: $,
|
|
58
57
|
assistantsEnabled: A,
|
|
59
|
-
feedbackServiceUrl:
|
|
58
|
+
feedbackServiceUrl: E
|
|
59
|
+
} : {
|
|
60
|
+
shouldRender: !0,
|
|
61
|
+
assistantsEnabled: !1,
|
|
62
|
+
helpBase: $,
|
|
63
|
+
feedbackServiceUrl: E
|
|
60
64
|
};
|
|
61
65
|
}
|
|
62
|
-
class K extends
|
|
66
|
+
class K extends k {
|
|
63
67
|
constructor() {
|
|
64
|
-
super(...arguments), this._codeEditorElt =
|
|
68
|
+
super(...arguments), this._codeEditorElt = N(), this._componentReadyDefer = Promise.withResolvers(), this._disposables = [], this._editorProfilePromise = Promise.resolve(void 0), this.messages = F(), this._modelId = M(), this._openArcadeHelp = () => void window.open(T, "Arcade Help"), this._toggleSidePanel = (e) => {
|
|
65
69
|
if (!e.target)
|
|
66
70
|
return;
|
|
67
71
|
const t = e.target?.dataset.panelName ?? "none";
|
|
68
72
|
this.openedSidePanel = t === this.openedSidePanel ? "none" : t, this.openedSidePanel === "none" && this._codeEditorElt.value?.setFocus().catch(o(this));
|
|
69
|
-
}, this._consoleLogs = [], this._executingScript = !1, this._preparingArcade = !1, this._resultPanel = "output", this._showExecutionPanel = !1, this._arcadeAssistantRemoteState = { shouldRender: !1 }, this.hideDocumentationActions = !1, this.hideSideBar = !1, this.openedSidePanel = "none", this.script = "", this.sideActionBarExpanded = !1, this.arcgisDiagnosticsChange =
|
|
73
|
+
}, this._consoleLogs = [], this._executingScript = !1, this._preparingArcade = !1, this._resultPanel = "output", this._showExecutionPanel = !1, this._arcadeAssistantRemoteState = { shouldRender: !1 }, this.hideDocumentationActions = !1, this.hideSideBar = !1, this.openedSidePanel = "none", this.script = "", this.sideActionBarExpanded = !1, this.arcgisDiagnosticsChange = v({ bubbles: !1 }), this.arcgisScriptChange = v({ bubbles: !1 });
|
|
70
74
|
}
|
|
71
75
|
static {
|
|
72
76
|
this.properties = { _apiLibrary: 16, _consoleLogs: 16, _editorProfile: 16, _executingScript: 16, _executionResult: 16, _preparingArcade: 16, _resultPanel: 16, _showExecutionPanel: 16, _arcadeAssistantRemoteState: 16, editorInstance: 32, editorOptions: 0, hideDocumentationActions: 5, hideSideBar: 5, openedSidePanel: 3, profile: 0, script: 1, sideActionBarExpanded: 7, snippets: 0, suggestions: 0, testData: 0, customPanels: 0, arcadeAssistant: 0 };
|
|
73
77
|
}
|
|
74
78
|
static {
|
|
75
|
-
this.styles = [
|
|
79
|
+
this.styles = [j];
|
|
76
80
|
}
|
|
77
81
|
get editorInstance() {
|
|
78
82
|
return this._codeEditorElt.value?.editorInstance;
|
|
@@ -85,14 +89,14 @@ class K extends B {
|
|
|
85
89
|
return { type: "error", value: "Missing editor profile", error: null };
|
|
86
90
|
await this._componentReadyDefer.promise;
|
|
87
91
|
const t = this._codeEditorElt.value?.value;
|
|
88
|
-
return await
|
|
92
|
+
return await x(e.definition, t, this.testData);
|
|
89
93
|
}
|
|
90
94
|
async setFocus() {
|
|
91
95
|
await this._componentReadyDefer.promise, await this._codeEditorElt.value?.setFocus();
|
|
92
96
|
}
|
|
93
97
|
async load() {
|
|
94
|
-
const e =
|
|
95
|
-
|
|
98
|
+
const e = I("./assets");
|
|
99
|
+
U(e), await this._updateDataModelDeps(), await this._updateArcadeAssistantRemoteState();
|
|
96
100
|
}
|
|
97
101
|
willUpdate(e) {
|
|
98
102
|
(e.has("messages") || e.has("profile")) && this.hasUpdated && this._updateDataModelDeps(), e.has("testData") && this._testDataChanged(), e.has("snippets") && c.updateApiContextForModel(this._modelId, {
|
|
@@ -141,7 +145,7 @@ class K extends B {
|
|
|
141
145
|
}
|
|
142
146
|
this._showExecutionPanel = !0, this._executingScript = !0, this._consoleLogs = [], setTimeout(() => void (async () => {
|
|
143
147
|
const d = this._codeEditorElt.value?.value;
|
|
144
|
-
this._executionResult = await
|
|
148
|
+
this._executionResult = await x(t.definition, d, e, (n) => setTimeout(() => this._consoleLogs = [...this._consoleLogs, n], 0)), this._executingScript = !1;
|
|
145
149
|
})(), 0);
|
|
146
150
|
}
|
|
147
151
|
_toggleShowExecutionPanel() {
|
|
@@ -174,7 +178,7 @@ class K extends B {
|
|
|
174
178
|
// An unique identifier for the action.
|
|
175
179
|
id: "run-script",
|
|
176
180
|
label: "Run Arcade Expression",
|
|
177
|
-
keybindings: [
|
|
181
|
+
keybindings: [B.F5],
|
|
178
182
|
contextMenuGroupId: "code",
|
|
179
183
|
contextMenuOrder: 1,
|
|
180
184
|
run: () => {
|
|
@@ -197,10 +201,10 @@ class K extends B {
|
|
|
197
201
|
return this.testData ? s`<calcite-action-bar class="main-action-bar" layout=horizontal scale=s expanded expand-disabled slot=top-action-bar><calcite-action-group scale=s><calcite-action .text=${this.messages.run ?? ""} text-enabled icon=play scale=s .loading=${this._preparingArcade} @click=${() => void this._executeScript().catch(o(this))}></calcite-action>${this._executionResult ? s`<calcite-action .text=${this.messages.lastresults ?? ""} .active=${this._showExecutionPanel} text-enabled icon=access-string-results icon-flip-rtl scale=s @click=${this._toggleShowExecutionPanel}></calcite-action>` : null}</calcite-action-group></calcite-action-bar>` : null;
|
|
198
202
|
}
|
|
199
203
|
renderMainPanel() {
|
|
200
|
-
return s`<arcgis-code-editor slot=editor .editorOptions=${this.editorOptions} .language=${c.languageId} .value=${this.script ?? ""} .modelId=${this._modelId} @arcgisValueChange=${this._onCodeEditorValueChange} ${
|
|
204
|
+
return s`<arcgis-code-editor slot=editor .editorOptions=${this.editorOptions} .language=${c.languageId} .value=${this.script ?? ""} .modelId=${this._modelId} @arcgisValueChange=${this._onCodeEditorValueChange} ${H(this._codeEditorElt)}></arcgis-code-editor>`;
|
|
201
205
|
}
|
|
202
206
|
renderAction({ id: e, label: t, icon: d, active: n, panelName: h, iconFlipRtl: p = !1, onClick: u = this._toggleSidePanel }) {
|
|
203
|
-
return s`<calcite-action id=${e ??
|
|
207
|
+
return s`<calcite-action id=${e ?? b} .text=${t} .textEnabled=${this.sideActionBarExpanded} .icon=${d} .active=${n} @click=${u} data-panel-name=${h ?? b} .iconFlipRtl=${p}></calcite-action>${!this.sideActionBarExpanded && s`<calcite-tooltip .referenceElement=${e}><span>${t}</span></calcite-tooltip>` || ""}`;
|
|
204
208
|
}
|
|
205
209
|
renderSideActionBar() {
|
|
206
210
|
return this.hideSideBar ? null : s`<calcite-action-bar slot=side-action-bar class="side-action-bar" .expanded=${this.sideActionBarExpanded} position=end @calciteActionBarToggle=${this._toggleSideActionBarExpanded}><calcite-action-group>${this.renderAction({
|
|
@@ -247,7 +251,7 @@ class K extends B {
|
|
|
247
251
|
if (this.hideSideBar)
|
|
248
252
|
return null;
|
|
249
253
|
const { openedSidePanel: e } = this;
|
|
250
|
-
return s`<arcgis-language-api-panel slot=side-panel class=${l(e === "api" ? "" : "hidden")} .loading=${this._preparingArcade} .apiLibrary=${this._apiLibrary} .hideDocumentationActions=${this.hideDocumentationActions} @arcgisInternalItemSelected=${this._insertAsSnippet} @arcgisInternalClosePanel=${this._toggleSidePanel} data-panel-name=none .closed=${e !== "api"}></arcgis-language-api-panel><arcgis-editor-variables slot=side-panel class=${l(e === "variables" ? "" : "hidden")} .loading=${this._preparingArcade} .modelId=${this._modelId} @arcgisInternalItemSelected=${this._insertAsText} @arcgisInternalClosePanel=${this._toggleSidePanel} data-panel-name=none .variable=${this._editorProfile} .closed=${e !== "variables"}></arcgis-editor-variables>${this.suggestions?.length && s`<arcgis-arcade-suggestions slot=side-panel class=${l(e === "suggestions" ? "" : "hidden")} .closed=${e !== "suggestions"} .suggestions=${this.suggestions} @arcgisInternalItemSelected=${this._insertAsText} @arcgisInternalClosePanel=${this._toggleSidePanel} data-panel-name=none></arcgis-arcade-suggestions>` || ""}${this.arcadeAssistant && this._arcadeAssistantRemoteState.shouldRender && s`<arcgis-arcade-coding-assistant slot=side-panel class=${l(e === "arcade-assistant" ? "" : "hidden")} .closed=${e !== "arcade-assistant"} .insertText=${this._insertText.bind(this)} .closePanel=${this._toggleSidePanel} .portalUrl=${this.arcadeAssistant.portalUrl} .serviceUrl=${this._arcadeAssistantRemoteState.serviceUrl} .helpBase=${this._arcadeAssistantRemoteState.helpBase} .assistantsEnabled=${this._arcadeAssistantRemoteState.assistantsEnabled} .feedbackServiceUrl=${this._arcadeAssistantRemoteState.feedbackServiceUrl} .editorRef=${this.el} .appVersion=${this.arcadeAssistant.appVersion}></arcgis-arcade-coding-assistant>` || ""}${this.customPanels?.map((t) => s`<calcite-flow slot=side-panel class=${l(e === t.id ? "" : "hidden")}>${t?.useFlows ? t.renderer?.({
|
|
254
|
+
return s`<arcgis-language-api-panel slot=side-panel class=${l(e === "api" ? "" : "hidden")} .loading=${this._preparingArcade} .apiLibrary=${this._apiLibrary} .hideDocumentationActions=${this.hideDocumentationActions} @arcgisInternalItemSelected=${this._insertAsSnippet} @arcgisInternalClosePanel=${this._toggleSidePanel} data-panel-name=none .closed=${e !== "api"}></arcgis-language-api-panel><arcgis-editor-variables slot=side-panel class=${l(e === "variables" ? "" : "hidden")} .loading=${this._preparingArcade} .modelId=${this._modelId} @arcgisInternalItemSelected=${this._insertAsText} @arcgisInternalClosePanel=${this._toggleSidePanel} data-panel-name=none .variable=${this._editorProfile} .closed=${e !== "variables"}></arcgis-editor-variables>${this.suggestions?.length && s`<arcgis-arcade-suggestions slot=side-panel class=${l(e === "suggestions" ? "" : "hidden")} .closed=${e !== "suggestions"} .suggestions=${this.suggestions} @arcgisInternalItemSelected=${this._insertAsText} @arcgisInternalClosePanel=${this._toggleSidePanel} data-panel-name=none></arcgis-arcade-suggestions>` || ""}${this.arcadeAssistant && this._arcadeAssistantRemoteState.shouldRender && s`<arcgis-arcade-coding-assistant slot=side-panel class=${l(e === "arcade-assistant" ? "" : "hidden")} .closed=${e !== "arcade-assistant"} .insertText=${this._insertText.bind(this)} .closePanel=${this._toggleSidePanel} .portalUrl=${this.arcadeAssistant.portalUrl} .serviceUrl=${"serviceUrl" in this._arcadeAssistantRemoteState ? this._arcadeAssistantRemoteState.serviceUrl : void 0} .helpBase=${this._arcadeAssistantRemoteState.helpBase} .assistantsEnabled=${this._arcadeAssistantRemoteState.assistantsEnabled} .feedbackServiceUrl=${this._arcadeAssistantRemoteState.feedbackServiceUrl} .editorRef=${this.el} .appVersion=${this.arcadeAssistant.appVersion}></arcgis-arcade-coding-assistant>` || ""}${this.customPanels?.map((t) => s`<calcite-flow slot=side-panel class=${l(e === t.id ? "" : "hidden")}>${t?.useFlows ? t.renderer?.({
|
|
251
255
|
closePanel: this._toggleSidePanel,
|
|
252
256
|
insertText: this._insertText.bind(this),
|
|
253
257
|
closed: e !== t.id,
|
|
@@ -268,7 +272,7 @@ class K extends B {
|
|
|
268
272
|
return s`<arcgis-code-editor-shell>${this.renderMainActionBar()}${this.renderMainPanel()}${this.renderResultsPanel()}${this.renderSidePanel()}${this.renderSideActionBar()}</arcgis-code-editor-shell>`;
|
|
269
273
|
}
|
|
270
274
|
}
|
|
271
|
-
|
|
275
|
+
D("arcgis-arcade-editor", K);
|
|
272
276
|
export {
|
|
273
277
|
K as ArcgisArcadeEditor
|
|
274
278
|
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
2
|
import { c as I } from "../../chunks/runtime.js";
|
|
3
|
-
import { css as
|
|
4
|
-
import { nothing as
|
|
3
|
+
import { css as w, html as t, unsafeCSS as D } from "lit";
|
|
4
|
+
import { nothing as T, LitElement as O, createEvent as y, safeClassMap as h } from "@arcgis/lumina";
|
|
5
5
|
import { setValuesInString as o, quoteString as g } from "@arcgis/toolkit/string";
|
|
6
6
|
import { B as x, v as b, M as m, f as L, a as A, b as F } from "../../chunks/arcade-executor.js";
|
|
7
7
|
import { u as _ } from "../../chunks/useT9n.js";
|
|
8
8
|
import { s as j } from "../../chunks/fields.js";
|
|
9
9
|
import "@arcgis/toolkit/function";
|
|
10
|
-
import { createRef as v, ref as
|
|
10
|
+
import { createRef as v, ref as f } from "lit/directives/ref.js";
|
|
11
11
|
import { t as k } from "../../chunks/monaco-theme.js";
|
|
12
12
|
import { observeAncestorsMutation as z, unsafeGetCalciteModeName as N } from "@arcgis/toolkit/dom";
|
|
13
|
-
const E =
|
|
13
|
+
const E = w`:host{display:flex;flex-direction:column;width:100%;background-color:var(--calcite-color-foreground-1);color:var(--calcite-color-text-2);.flex-adjustable{flex:1 1 auto;overflow:hidden}.flex-row{display:flex;flex-direction:row;overflow:hidden}.flex-column{display:flex;flex-direction:column;overflow:hidden;min-height:0}.y-scrollable-container{overflow-y:auto;block-size:100%;background-color:var(--calcite-color-foreground-1)}header{border-bottom:1px solid var(--calcite-color-border-3);flex:0 0 auto}.ltr-container{direction:ltr}calcite-action-bar{calcite-action-group{padding-inline-end:var(--calcite-spacing-sm);calcite-action{padding-inline-end:var(--calcite-spacing-sm)}calcite-action:not(:first-child){padding-inline-start:var(--calcite-spacing-sm)}}calcite-action-group:last-child{border-inline-end-width:0px}calcite-action-group:not(:first-child){padding-inline-start:var(--calcite-spacing-sm)}}.notice-container{margin:var(--calcite-spacing-xxs);padding:var(--calcite-spacing-sm);background-color:var(--calcite-color-foreground-1)}.color-info{color:var(--calcite-color-status-info)}.color-error{color:var(--calcite-color-status-danger)}.color-success{color:var(--calcite-color-status-success)}[class*=result-value-]{font-size:var(--calcite-font-size--2);line-height:1.25rem;background-color:var(--calcite-color-foreground-1);margin:var(--calcite-spacing-md)}.console-logs-container{background-color:var(--calcite-color-foreground-1);padding:0 var(--calcite-spacing-md);font-family:var(--calcite-code-family);font-size:var(--calcite-font-size--2);font-weight:var(--calcite-font-weight-normal)}.result-value-table{display:flex;flex-direction:column;min-height:0;.table-scroll{overflow:auto;flex:1 1 auto;min-height:0;max-width:100%;background-color:var(--calcite-color-foreground-1)}table{min-width:max-content;border-spacing:0;border-collapse:collapse;text-align:start;white-space:nowrap;thead{background-color:var(--calcite-color-foreground-2)}tr{border-top:1px solid var(--calcite-color-border-3);border-bottom:1px solid var(--calcite-color-border-3)}th,td{border-inline-start:1px solid var(--calcite-color-border-3);border-inline-end:1px solid var(--calcite-color-border-3);text-align:start;padding:var(--calcite-spacing-xxs);.string-value{white-space:pre}}th{font-weight:var(--calcite-font-weight-medium)}}}.tree-item-label,.number-value,.string-value,.boolean-value{font-family:var(--calcite-code-family)}.tree-item-label,.value-type{color:var(--calcite-color-text-2);font-weight:var(--calcite-font-weight-normal)}.dictionary-property{color:var(--arcgis-editor-identifier)}.number-value{color:var(--arcgis-editor-number)}.string-value{color:var(--arcgis-editor-string);white-space:pre-wrap}.constant-value{color:var(--arcgis-editor-constant)}.date-value{color:var(--arcgis-editor-date)}}`, l = {
|
|
14
14
|
lines: !0,
|
|
15
15
|
selectionMode: "none",
|
|
16
16
|
scale: "s",
|
|
@@ -20,7 +20,7 @@ const E = T`:host{display:flex;flex-direction:column;width:100%;background-color
|
|
|
20
20
|
const a = e.currentTarget;
|
|
21
21
|
a.expanded = !a.expanded;
|
|
22
22
|
}
|
|
23
|
-
}, r = ({ name: e }) => t`<span class="dictionary-property">${e}</span><span>: </span>`, S = ({ value: e, subtree: a = !1 }) => t`<calcite-tree slot=${(a ? "children" : void 0) ??
|
|
23
|
+
}, r = ({ name: e }) => t`<span class="dictionary-property">${e}</span><span>: </span>`, S = ({ value: e, subtree: a = !1 }) => t`<calcite-tree slot=${(a ? "children" : void 0) ?? T} .lines=${l.lines} .selectionMode=${l.selectionMode} .scale=${l.scale} @calciteTreeSelect=${l.oncalciteTreeSelect}><calcite-tree-item class="string-value">${JSON.stringify(e.castAsJson(), void 0, 2)}</calcite-tree-item></calcite-tree>`, P = ({ value: e, subtree: a = !1 }) => t`<calcite-tree slot=${(a ? "children" : void 0) ?? T} .lines=${l.lines} .selectionMode=${l.selectionMode} .scale=${l.scale} @calciteTreeSelect=${l.oncalciteTreeSelect}><calcite-tree-item><div class="tree-item-label">${r({ name: "type" })}${e.type}</div></calcite-tree-item><calcite-tree-item><div class="tree-item-label">${r({ name: "value" })}<span class="string-value">${JSON.stringify(e, void 0, 2)}</span></div></calcite-tree-item></calcite-tree>`, p = ({ arcadeResult: e }) => {
|
|
24
24
|
switch (e.type) {
|
|
25
25
|
case "unknown":
|
|
26
26
|
case "null":
|
|
@@ -49,14 +49,14 @@ const E = T`:host{display:flex;flex-direction:column;width:100%;background-color
|
|
|
49
49
|
const i = e.geometry?.();
|
|
50
50
|
return t`<calcite-tree slot=${"children"} .lines=${l.lines} .selectionMode=${l.selectionMode} .scale=${l.scale} @calciteTreeSelect=${l.oncalciteTreeSelect}>${e.keys().map((c) => {
|
|
51
51
|
const n = b(e.field(c));
|
|
52
|
-
return e.arcadeDeclaredClass === "esri.arcade.Feature" && n.type === "geometry" ? null :
|
|
53
|
-
})}${i ?
|
|
52
|
+
return e.arcadeDeclaredClass === "esri.arcade.Feature" && n.type === "geometry" ? null : $({ arcadeResult: n, name: c, t9nStrings: s });
|
|
53
|
+
})}${i ? $({ arcadeResult: { type: "geometry", value: i }, name: "geometry", t9nStrings: s }) : null}</calcite-tree>`;
|
|
54
54
|
}, V = ({ arcadeResult: e, t9nStrings: a }) => t`<div class="value-type"><span>${e.type}:</span>${e.features.length >= x ? t`<span> ${o(a.showingfirstitemsformat, {
|
|
55
55
|
count: x.toString()
|
|
56
56
|
})}</span>` : null}</div>`, M = ({ items: e, subtree: a, t9nStrings: s }) => t`<calcite-tree slot=${"children"} .lines=${l.lines} .selectionMode=${l.selectionMode} .scale=${l.scale} @calciteTreeSelect=${l.oncalciteTreeSelect}>${e.map((i, c) => {
|
|
57
57
|
const n = b(i);
|
|
58
|
-
return
|
|
59
|
-
})}</calcite-tree>`,
|
|
58
|
+
return $({ arcadeResult: n, name: c, expanded: !a, t9nStrings: s });
|
|
59
|
+
})}</calcite-tree>`, $ = ({ arcadeResult: e, name: a, expanded: s, t9nStrings: i }) => {
|
|
60
60
|
switch (e.type) {
|
|
61
61
|
case "null":
|
|
62
62
|
case "unknown":
|
|
@@ -84,14 +84,14 @@ const E = T`:host{display:flex;flex-direction:column;width:100%;background-color
|
|
|
84
84
|
}
|
|
85
85
|
}, J = ({ arcadeResult: e }) => {
|
|
86
86
|
const a = j(e.value.fields);
|
|
87
|
-
return t`<table><thead><tr>${a.map((s) => t`<th>${s.name}</th>`)}</tr></thead><tbody>${e.features.map((s) => t`<tr>${a.map((i) => {
|
|
87
|
+
return t`<div class="table-scroll"><table><thead><tr>${a.map((s) => t`<th>${s.name}</th>`)}</tr></thead><tbody>${e.features.map((s) => t`<tr>${a.map((i) => {
|
|
88
88
|
try {
|
|
89
89
|
const c = b(s.field(i.name));
|
|
90
90
|
return t`<td>${p({ arcadeResult: c })}</td>`;
|
|
91
91
|
} catch {
|
|
92
92
|
return t`<td></td>`;
|
|
93
93
|
}
|
|
94
|
-
})}</tr>`)}</tbody></table>`;
|
|
94
|
+
})}</tr>`)}</tbody></table></div>`;
|
|
95
95
|
};
|
|
96
96
|
function G() {
|
|
97
97
|
let e = `:host {
|
|
@@ -109,7 +109,7 @@ function G() {
|
|
|
109
109
|
--arcgis-editor-${i}: ${c};`;
|
|
110
110
|
}), e += `
|
|
111
111
|
}
|
|
112
|
-
`,
|
|
112
|
+
`, w`
|
|
113
113
|
${D(e)}
|
|
114
114
|
`;
|
|
115
115
|
}
|
|
@@ -219,7 +219,7 @@ class B extends O {
|
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
221
|
render() {
|
|
222
|
-
return t`<header class="flex-row"><calcite-action-bar class="flex-adjustable" layout=horizontal scale=s expanded expand-disabled><calcite-action-group scale=s><calcite-action .active=${this.openedResultPanel === "output"} .text=${this.messages.output ?? ""} text-enabled scale=s icon=list-show-all icon-flip-rtl @click=${this._switchResultPanel} data-panel-name=output ${
|
|
222
|
+
return t`<header class="flex-row"><calcite-action-bar class="flex-adjustable" layout=horizontal scale=s expanded expand-disabled><calcite-action-group scale=s><calcite-action .active=${this.openedResultPanel === "output"} .text=${this.messages.output ?? ""} text-enabled scale=s icon=list-show-all icon-flip-rtl @click=${this._switchResultPanel} data-panel-name=output ${f(this.outputRef)}></calcite-action><calcite-action .active=${this.openedResultPanel === "console"} .text=${this.messages.console ?? ""} text-enabled scale=s icon=console icon-flip-rtl @click=${this._switchResultPanel} data-panel-name=console ${f(this.consoleRef)}></calcite-action><calcite-action .active=${this.openedResultPanel === "log"} .text=${this.messages.log ?? ""} text-enabled scale=s icon=list icon-flip-rtl @click=${this._switchResultPanel} data-panel-name=log ${f(this.logRef)}></calcite-action></calcite-action-group></calcite-action-bar><calcite-action scale=s icon=x .text=${this.messages.close ?? ""} @click=${this._emitClose}></calcite-action></header><article class="flex-adjustable">${this.loading ? t`<calcite-loader scale=s type=indeterminate .label=${this.messages.loading ?? "Loading"}></calcite-loader>` : t`<div class="flex-column y-scrollable-container">${this.renderOutputPanel()}${this.renderConsolePanel()}${this.renderLogPanel()}</div>`}</article>`;
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
225
|
I("arcgis-arcade-results", B);
|