@arcgis/ai-components 5.1.0-next.68 → 5.1.0-next.69
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/{3CZQHWJP.js → ABNCEYLL.js} +1 -1
- package/dist/cdn/{7UFEWDRP.js → BDNPOFE3.js} +1 -1
- package/dist/cdn/{TLUSRT4T.js → EUFX6NVB.js} +1 -1
- package/dist/cdn/{TXYUMBUK.js → GDZJLYX3.js} +1 -1
- package/dist/cdn/{RLCQB27O.js → H3PQFXNE.js} +1 -1
- package/dist/cdn/{OWX4S2UP.js → HXFRR6EC.js} +1 -1
- package/dist/cdn/{6PXPMO7V.js → IRWH2Z5B.js} +1 -1
- package/dist/cdn/{OFBHZ4Y7.js → NDR3JRNG.js} +1 -1
- package/dist/cdn/{H3WHZNX6.js → NPL674O3.js} +23 -18
- package/dist/cdn/{4DSA6DQE.js → OCRLLTMY.js} +1 -1
- package/dist/cdn/{ZM6OIY4L.js → PXWXEVZS.js} +1 -1
- package/dist/cdn/{FIHB3MAG.js → PZNHMI2L.js} +1 -1
- package/dist/cdn/{E5AFTZBM.js → WEBEIOLW.js} +1 -1
- package/dist/cdn/{PX5BFWEH.js → Z6HX4HRX.js} +1 -1
- package/dist/cdn/{RIJ423YM.js → ZIGYCHMU.js} +1 -1
- package/dist/cdn/index.js +1 -1
- package/dist/components/arcgis-assistant/customElement.js +3 -1
- package/dist/components/arcgis-assistant-chat-entry/customElement.js +3 -1
- package/dist/components/arcgis-assistant-chat-entry-speech-input/customElement.js +3 -1
- 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 +7 -7
- /package/dist/cdn/{ECU7VUF3.js → 6TDOQJ45.js} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{a as o,b as l}from"./
|
|
2
|
+
import{a as o,b as l}from"./NPL674O3.js";import{g as i,h as t,v as c,w as a,z as r}from"./6TDOQJ45.js";import"./CFDTXKJ6.js";var d=i`.assistant-chat-card-content__skeleton-block{display:flex;flex-direction:column;gap:var(--calcite-spacing-sm);width:100%}.assistant-chat-card-content__skeleton-text{display:block;height:.95em;border-radius:var(--calcite-border-radius);background:linear-gradient(90deg,color-mix(in srgb,var(--calcite-color-foreground-2) 65%,transparent),color-mix(in srgb,var(--calcite-color-foreground-3) 85%,transparent),color-mix(in srgb,var(--calcite-color-foreground-2) 65%,transparent));background-size:200% 100%;animation:assistant-chat-card-content-shimmer 1.2s ease-in-out infinite;width:85%}.assistant-chat-card-content__skeleton-text:last-child{width:70%}@keyframes assistant-chat-card-content-shimmer{0%{background-position:-150% 0}to{background-position:150% 0}}@media(prefers-reduced-motion){.assistant-chat-card-content__skeleton-text{animation:none}}.assistant-chat-card-content__text-container{padding:0 var(--calcite-spacing-sm);display:flex;flex-direction:column;gap:var(--calcite-spacing-sm);color:var(--calcite-color-text-1)}.assistant-chat-card-content__text-container pre{background-color:var(--calcite-color-foreground-1);padding:var(--calcite-spacing-sm);border-radius:var(--calcite-border-radius);color:var(--calcite-color-text-1);direction:ltr;max-width:100%;overflow:auto}.assistant-chat-card-content__text-container pre code{display:block;white-space:pre;font-family:var(--calcite-code-family)}.assistant-chat-card-content__loading-container{display:flex;flex-direction:column;gap:var(--calcite-spacing-sm)}.assistant-chat-card-content__loading{display:flex;align-items:center;gap:var(--calcite-spacing-sm)}.assistant-chat-card-content__text-loading{font-style:italic;word-wrap:break-word;word-break:break-all;overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-line-clamp:1;line-clamp:1;-webkit-box-orient:vertical}.assistant-chat-card-content__error-notice{padding:var(--calcite-spacing-sm)}`,n="assistant-chat-card-content",e={textLoading:`${n}__text-loading`,skeletonBlock:`${n}__skeleton-block`,skeletonText:`${n}__skeleton-text`},s=class extends c{constructor(){super(...arguments),this.loading=!1,this.type="text"}static{this.properties={loading:5,type:1,content:1,loadingMessage:1}}static{this.styles=d}_renderText(){return t`<div class="assistant-chat-card-content__text-container">${this.loading?t`<div class="assistant-chat-card-content__loading-container"><div class="assistant-chat-card-content__loading"><calcite-loader label=loading inline></calcite-loader><div class=${a(e.textLoading)}>${this.loadingMessage}</div></div><div class=${a(e.skeletonBlock)}><span class=${a(e.skeletonText)}></span><span class=${a(e.skeletonText)}></span></div></div>`:t`<div>${o(l(this.content))}</div>`}</div>`}_renderError(){return t`<calcite-notice class="assistant-chat-card-content__error-notice" open icon kind=warning width=auto><div slot=message>${this.content}</div></calcite-notice>`}render(){switch(this.type){case"text":return this._renderText();case"error":return this._renderError();default:return t`<p>Unsupported content type</p>`}}};r("arcgis-assistant-chat-card-content",s);export{s as ArcgisAssistantChatCardContent};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import a from"./L7YTPHKQ.js";import{a as k}from"./
|
|
2
|
+
import a from"./L7YTPHKQ.js";import{a as k}from"./H3PQFXNE.js";import{a as C}from"./KVH3PDVW.js";import"./YGW7TUNX.js";import{g as _,h,l as v,n as o,t as u,u as m,v as f,z as E}from"./6TDOQJ45.js";import"./CFDTXKJ6.js";export default $arcgis.t(([I,{whenOnce:S,watch:L,when:P},O,A,{property:p,subclass:M},{x:w}])=>{var x=_`:host{display:block;width:var(--arcgis-internal-panel-width, 100%);height:var(--arcgis-internal-expand-max-height, 100%)}`,R=Object.defineProperty,z=Object.getOwnPropertyDescriptor,l=(c,t,e,i)=>{for(var s=i>1?void 0:i?z(t,e):t,r=c.length-1,n;r>=0;r--)(n=c[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&R(t,e,s),s},a=class extends A{constructor(c){super(c),this.view=null,this.loading=!1,this.processing=!1,this.processingStep=""}async load(){this._set("loading",!0);try{await this._initialize()}finally{this._set("loading",!1)}}destroy(){this.orchestrator?.dispose(),super.destroy()}async _initialize(){this.removeHandles(),await Promise.all([this.portal.load(),this.view?.when()]),this.view&&await S(()=>!this.view.updating),this._set("orchestrator",await w.init({agents:[...this.agents],view:this.view??void 0})),this.addHandles([L(()=>[this.view,this.agents],()=>{this._initialize()})])}clearChatHistory(){this.orchestrator?.newConversation()}async*ask(c,t){if(!this.orchestrator)throw new Error("Orchestrator not initialized yet.");this._set("processing",!0),this._set("processingStep","");let e=[];try{let i=this.orchestrator.ask(c);for await(let s of i){let r=s.runId;if(t?.aborted){yield{type:"cancelled",runId:r};break}switch(s.type){case"trace":{this._set("processingStep",s.data.text),e.push(s.data.text);break}case"completed":{if(!s.result.content.length){yield{type:"completed",error:"Could not process the request.",log:e,runId:r};return}let n=s.result.content;this._set("processingStep",""),yield{type:"completed",response:n,log:e,runId:r};return}case"interrupt":{let{kind:n,message:d,metadata:b}=s.interrupt,g=Array.isArray(b)?[...b]:[],$=(()=>{switch(n){case"booleanChoice":return{type:"boolean-choice",message:d,options:g};case"singleSelection":return{type:"single-select",message:d,options:g};case"multipleSelection":return{type:"multi-select",message:d,options:g};case"textInput":return{type:"text-input",message:d};default:return{type:n,message:d,options:g}}})();this._set("processingStep","Waiting for user input..."),yield{type:"interrupt",payload:$,runId:r};break}case"cancelled":{yield{type:"cancelled",runId:r};return}case"error":{yield{type:"completed",error:s.error.message,log:e,runId:r};return}default:{console.warn("Unknown event type:",s);break}}}}catch(i){console.warn("Error during message processing:",i),yield{type:"completed",error:"An error occurred during message processing.",log:e,runId:"error"};return}finally{this._set("processing",!1)}}};l([p({readOnly:!0})],a.prototype,"orchestrator",2);l([p()],a.prototype,"agents",2);l([p()],a.prototype,"portal",2);l([p()],a.prototype,"view",2);l([p({readOnly:!0})],a.prototype,"loading",2);l([p({readOnly:!0})],a.prototype,"processing",2);l([p({readOnly:!0})],a.prototype,"processingStep",2);a=l([M("OrchestratorController")],a);var H="Embeddings resource 'embeddings-v01.json' not found in the webmap portal item.",j="Embeddings not found for this web map.",F="https://developers.arcgis.com/javascript/latest/agentic-apps/ai-webmap-setup/#embeddings",y=class extends f{constructor(){super(...arguments),this._messages=k({blocking:!0}),this.#t=u(),this.#e=u(),this.#s=null,this.#o=new Map,this.#r=O.getDefault(),this.#i=t=>{t.stopPropagation(),this.arcgisInterruptCancel.emit(),this.orchestrator?.cancelInterrupt(),this._interrupt=null},this.#a=t=>{t.stopPropagation();let e=t.detail;this.arcgisInterruptSubmit.emit(e),this.orchestrator?.resumeInterrupt(e),this._interrupt=null},this.#n=t=>{t.stopPropagation(),this.keepSuggestedPrompts||(this.suggestedPrompts=[]);let e=t.detail;this.arcgisSubmit.emit(e),this.submitMessage(e)},this.#l=t=>{if(t.stopPropagation(),this.arcgisCancel.emit(),this._interrupt){this.orchestrator?.cancelInterrupt(),this._interrupt=null;return}this.#s?.abort()},this.#c=t=>{t.stopPropagation();let e=t.detail;this.arcgisFeedback.emit(e)},this._orchestratorController=null,this._interrupt=null,this._error=null,this.messages=new I([]),this.referenceElement=null,this.suggestedPrompts=[],this.feedbackEnabled=!1,this.keepSuggestedPrompts=!1,this.logEnabled=!1,this.copyEnabled=!1,this.voiceInputEnabled=!1,this.readAloudEnabled=!1,this.arcgisCancel=o(),this.arcgisError=o(),this.arcgisFeedback=o(),this.arcgisInterrupt=o(),this.arcgisInterruptCancel=o(),this.arcgisInterruptSubmit=o(),this.arcgisReady=o(),this.arcgisSubmit=o()}static{this.properties={_orchestratorController:16,_interrupt:16,_error:16,_user:16,messages:0,orchestrator:32,entryMessage:1,heading:1,description:1,referenceElement:1,suggestedPrompts:0,feedbackEnabled:5,keepSuggestedPrompts:5,logEnabled:5,copyEnabled:5,voiceInputEnabled:5,readAloudEnabled:5}}static{this.styles=x}#t;#e;#s;#o;#r;#i;#a;#n;#l;#c;async#h(){try{let t=C(this.el,this.referenceElement);await t?.componentOnReady();let e=[...this.#o.values()];return e.length?(this._orchestratorController=new a({agents:e,portal:this.#r,view:t?.view}),await this._orchestratorController.load(),!0):(this._error="No agents found.",!1)}catch(t){return this._error=t?.message??"Error initializing orchestrator.",v(this)(t),!1}}get _user(){return this.#r?.user?.fullName||this.#r?.user?.username}get orchestrator(){return this._orchestratorController?.orchestrator}async clearChatHistory(){this._reset(),this._orchestratorController?.clearChatHistory()}register(t){this.#o.set(t.agent.id,t)}async submitMessage(t){let e=t.trim();if(!e||(this.messages.push({id:Date.now().toString(),role:"user",content:e}),!this._orchestratorController))return;let i=this._orchestratorController.ask(e,this.#s?.signal);for await(let s of i){let r=s.runId;switch(s.type){case"completed":this.messages.push({role:"assistant",content:s.response,log:s.log,error:s.error,id:r});break;case"interrupt":this._interrupt={...s.payload,id:r};break;case"cancelled":this.messages.push({role:"assistant",error:"Request cancelled.",id:r});break}}}load(){this.manager.onLifecycle(this._reset.bind(this))}loaded(){this.manager.onLifecycle(()=>{this.#t.value?.addEventListener("arcgisSubmit",this.#n),this.#t.value?.addEventListener("arcgisCancel",this.#l),this.#t.value?.addEventListener("arcgisFeedback",this.#c);let t=P(()=>!!this._interrupt&&!!this.#e.value,()=>{let e=this.#e.value;e.removeEventListener("arcgisSubmit",this.#a),e.removeEventListener("arcgisCancel",this.#i),e.addEventListener("arcgisSubmit",this.#a,{once:!0}),e.addEventListener("arcgisCancel",this.#i,{once:!0}),this._interrupt&&this.arcgisInterrupt.emit(this._interrupt)});return queueMicrotask(()=>{this.#h().then(e=>{e?this.arcgisReady.emit():this._error&&this.arcgisError.emit(new Error(this._error))})}),()=>{t.remove(),this.#e.value?.removeEventListener("arcgisSubmit",this.#a),this.#e.value?.removeEventListener("arcgisCancel",this.#i),this.#t.value?.removeEventListener("arcgisSubmit",this.#n),this.#t.value?.removeEventListener("arcgisCancel",this.#l),this.#t.value?.removeEventListener("arcgisFeedback",this.#c),this._orchestratorController?.destroy(),this._orchestratorController=null}})}_reset(){this.#s?.abort(),this._interrupt=null,this.messages.removeAll(),this._error=null}_renderErrorNotice(){return this._error?h`<calcite-notice closable slot=entry-message open kind=danger icon width=full>${this._error===H?h`<div slot=message>${j}</div><calcite-link slot=link .href=${F} target=_blank title="Learn about web map embeddings">Read more</calcite-link>`:h`<div slot=message>${this._error}</div>`}</calcite-notice>`:null}render(){return h`<arcgis-assistant-shell .loading=${!this._orchestratorController&&!this._error||this._orchestratorController?.loading} .heading=${this.heading??this._messages.assistantLabel} .description=${this.description} .entryMessage=${this.entryMessage} .entryMessageClosed=${this.messages.length>0} .awaitingResponse=${this._orchestratorController?.processing} .suggestedPrompts=${this.suggestedPrompts} .messages=${this.messages} .voiceInputEnabled=${this.voiceInputEnabled} ${m(this.#t)}>${this._renderErrorNotice()}${this._interrupt?h`<arcgis-assistant-interrupt slot=entry-message .type=${this._interrupt.type} .message=${this._interrupt.message} .options=${this._interrupt.options} ${m(this.#e)}></arcgis-assistant-interrupt>`:null}<arcgis-assistant-chat .loading=${this._orchestratorController?.processing} .loadingMessage=${this._orchestratorController?.processingStep||""} .messages=${this.messages} .user=${this._user} .feedbackEnabled=${this.feedbackEnabled} .logEnabled=${this.logEnabled} .copyEnabled=${this.copyEnabled} .readAloudEnabled=${this.readAloudEnabled}><slot></slot></arcgis-assistant-chat><slot name=header-actions-end slot=header-actions-end></slot>${this.entryMessage?null:h`<slot name=entry-message slot=entry-message></slot>`}<slot name=entry-actions-start slot=entry-actions-start></slot><slot name=footer-content slot=footer-content></slot></arcgis-assistant-shell>`}};E("arcgis-assistant",y);return y},"core/Collection","core/reactiveUtils","portal/Portal","core/Accessor","core/accessorSupport/decorators",a)
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{a as o}from"./
|
|
2
|
+
import{a as o}from"./H3PQFXNE.js";import"./YGW7TUNX.js";import{g as a,h as s,n as e,v as n,z as l}from"./6TDOQJ45.js";import"./CFDTXKJ6.js";export default $arcgis.t(([r])=>{var c=a`.assistant-shell__footer-container{display:flex;flex-direction:column;flex:1 1 0;gap:var(--calcite-spacing-md)}.assistant-shell__content-container{display:flex;flex-direction:column;flex:1 1 0;min-height:0;position:relative;overflow:auto}.assistant-shell__suggested-prompts-container{display:flex;justify-content:center;width:100%}.assistant-shell__suggested-prompts{padding:var(--calcite-spacing-md);max-width:100%;box-sizing:border-box}calcite-chip{max-width:100%}.assistant-shell__suggested-prompt{max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-style:normal;cursor:pointer}`,i=class extends n{constructor(){super(...arguments),this._messages=o({blocking:!0}),this.description="",this.loading=!1,this.entryMessageClosed=!1,this.awaitingResponse=!1,this.suggestedPrompts=[],this.inputValue="",this.messages=new r([]),this.voiceInputEnabled=!1,this.arcgisCancel=e(),this.arcgisSubmit=e()}static{this.properties={heading:1,description:1,loading:5,entryMessage:1,entryMessageClosed:5,awaitingResponse:5,suggestedPrompts:0,inputValue:1,status:1,messages:0,voiceInputEnabled:5}}static{this.styles=c}_renderSuggestedPrompts(){return this.suggestedPrompts?.length?s`<div class="assistant-shell__suggested-prompts-container"><calcite-chip-group class="assistant-shell__suggested-prompts" .label=${this._messages.suggestedPromptsLabel??"suggested prompts"}>${this.suggestedPrompts.map(t=>s`<calcite-chip .value=${t} .label=${t} appearance=outline-fill kind=brand @calciteChipSelect=${()=>this.inputValue=t}><div class="assistant-shell__suggested-prompt">${t}</div></calcite-chip>`)}</calcite-chip-group></div>`:null}render(){return s`<calcite-panel .loading=${this.loading} .heading=${this.heading??this._messages.shellHeading} .description=${this.description}><slot slot=header-actions-end name=header-actions-end></slot><div class="assistant-shell__content-container"><slot></slot></div>${this._renderSuggestedPrompts()}<div class="assistant-shell__footer-container" slot=footer><slot name=entry-message>${this.entryMessageClosed?null:s`<calcite-notice slot=entry-message .open=${!this.entryMessageClosed} kind=info closable icon width=full><div slot=message>${this.entryMessage??this._messages.shellEntryMessage}</div></calcite-notice>`}</slot><arcgis-assistant-chat-entry .awaitingResponse=${this.awaitingResponse} .arcgisSubmit=${this.arcgisSubmit} .arcgisCancel=${this.arcgisCancel} .inputValue=${this.inputValue} .status=${this.status} .messages=${this.messages} .voiceInputEnabled=${this.voiceInputEnabled}><slot name=entry-actions-start slot=entry-actions-start></slot></arcgis-assistant-chat-entry><slot name=footer-content></slot></div></calcite-panel>`}};l("arcgis-assistant-shell",i);return i},"core/Collection")
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{a as _}from"./
|
|
2
|
+
import{a as _}from"./H3PQFXNE.js";import"./YGW7TUNX.js";import{g as d,h as c,n as o,t as v,u as g,v as f,x as y,z as m}from"./6TDOQJ45.js";import"./CFDTXKJ6.js";export default $arcgis.t(([{watch:b},w])=>{var V=d`.assistant-chat-entry__input-container{display:flex;flex-direction:column}.assistant-chat-entry__footer-start{display:flex;gap:var(--calcite-spacing-md);flex-wrap:wrap;align-items:center}.assistant-chat-entry__footer-end{display:flex;gap:var(--calcite-spacing-md);align-items:center}.assistant-chat-entry__status-indicator{width:9px;height:9px;border-radius:100%;background-color:var(--calcite-color-status-success)}.assistant-chat-entry__status-indicator[data-status=working]{background-color:var(--calcite-color-status-warning)}.assistant-chat-entry__status-indicator[data-status=error]{background-color:var(--calcite-color-status-danger)}.assistant-chat-entry__status-text{text-transform:capitalize}`;function l(u){let{baseValue:t,transcript:s}=u;if(!s)return t;let e=t.trim();return e?`${e} ${s}`:s}var h=class extends f{constructor(){super(...arguments),this.#t=v(),this.#s=-1,this.#a="",this.#e=null,this.#i=t=>{let s=t.detail;this._applyVoiceInputTranscript(s?.transcript)},this.#n=()=>{this._startVoiceInputSession()},this.#r=()=>{this._finishVoiceInputSession()},this.#c=t=>{let s=t.detail;this._applyVoiceInputTranscript(s?.transcript,{final:!0})},this.#o=t=>{},this._messages=_({blocking:!0}),this.keyboardShortcutsDisabled=!1,this.awaitingResponse=!1,this.inputValue="",this.voiceInputEnabled=!1,this.messages=new w([]),this.arcgisCancel=o(),this.arcgisSubmit=o()}static{this.properties={_userMessages:16,keyboardShortcutsDisabled:5,entryPlaceholder:1,awaitingResponse:5,inputValue:1,status:1,voiceInputEnabled:5,messages:0}}static{this.styles=V}#t;#s;#a;#e;#i;#n;#r;#c;#o;get _userMessages(){return this.messages.toArray().filter(t=>t.role==="user").map(({content:t})=>t)}loaded(){this.manager.onLifecycle(()=>{let t=[{eventType:"arcgisVoiceInputInterimTranscription",callback:this.#i},{eventType:"arcgisVoiceInputStart",callback:this.#n},{eventType:"arcgisVoiceInputStop",callback:this.#r},{eventType:"arcgisVoiceInputTranscription",callback:this.#c},{eventType:"arcgisVoiceInputTranscriptionStreamChunk",callback:this.#o}];for(let{eventType:s,callback:e}of t)this.el.addEventListener(s,e);return[b(()=>this.inputValue,s=>{this.#t.value&&(this.#t.value.value=s)},{initial:!0}),{remove:()=>{for(let{eventType:s,callback:e}of t)this.el.removeEventListener(s,e)}}]})}async _submitMessage(){if(this.awaitingResponse){this.arcgisCancel.emit();return}let t=this.#t.value?.value.trim();t&&(this.arcgisSubmit.emit(t),this.#s=-1,this.#a="",this._clearVoiceInputSession(),this.#t.value&&(this.#t.value.value="",await this.#t.value.setFocus()))}async _navigateHistory(t,s){let e=this.#t.value;if(!e)return;let a=this._userMessages;if(a.length===0)return;let i=e.value??"",r=e.shadowRoot?.querySelector("textarea"),n=r?.selectionStart,p=r?.selectionEnd;if(!(n==null||p==null)&&!(n!==p||t==="up"&&n!==0||t==="down"&&n!==i.length)){if(t==="up"){this.#s===-1?(this.#a=i,this.#s=a.length-1):this.#s=Math.max(0,this.#s-1),e.value=a[this.#s]??"",s.preventDefault();return}this.#s!==-1&&(this.#s<a.length-1?(this.#s+=1,e.value=a[this.#s]??""):(this.#s=-1,e.value=this.#a),s.preventDefault())}}_startVoiceInputSession(){this.#e={baseValue:this.#t.value?.value?.trim()??"",phase:"listening",transcript:""}}_finishVoiceInputSession(){let t=this.#t.value,s=this.#e;if(!t){this._clearVoiceInputSession();return}if(!s){this._setDraftValue(t.value?.trim()??"");return}let e={...s,phase:"stopped"},a=l(e);this.#e=e,this._setDraftValue(a)}async _applyVoiceInputTranscript(t,s){let e=this.#t.value,a=this.#e;if(!e||!t||!a)return;if(a.phase==="stopped"){let n=l(a);if((e.value?.trim()??"")!==n){this._clearVoiceInputSession();return}}let i={...a,transcript:t},r=l(i);this.#e=i,this._setDraftValue(r),s?.final&&i.phase==="stopped"&&await e.setFocus()}_setDraftValue(t){this.#t.value&&(this.#t.value.value=t),this.#s=-1,this.#a=t}_clearVoiceInputSession(){this.#e=null}render(){return c`<div class="assistant-chat-entry__input-container"><calcite-text-area .value=${this.#t.value?.value} .placeholder=${this.entryPlaceholder??this._messages.entryPlaceholder} resize=vertical @keydown=${async t=>{t.altKey||t.ctrlKey||t.metaKey||t.shiftKey||this.keyboardShortcutsDisabled||(t.key==="Enter"?(t.preventDefault(),await this._submitMessage()):t.key==="ArrowUp"?await this._navigateHistory("up",t):t.key==="ArrowDown"&&await this._navigateHistory("down",t))}} ${g(this.#t)}><div slot=footer-start class="assistant-chat-entry__footer-start"><slot name=entry-actions-start></slot></div><div slot=footer-end class="assistant-chat-entry__footer-end">${this.status?c`<div id=tooltip-status class="assistant-chat-entry__status-indicator" data-status=${this.status??y}></div><calcite-tooltip reference-element=tooltip-status offset-distance=12><span class="assistant-chat-entry__status-text">${this.status}</span></calcite-tooltip>`:null}${this.voiceInputEnabled?c`<arcgis-assistant-chat-entry-speech-input .awaitingResponse=${this.awaitingResponse}></arcgis-assistant-chat-entry-speech-input>`:null}<calcite-button .iconStart=${this.awaitingResponse?"circle-stop":"send"} slot=footer-end round @click=${()=>{this._submitMessage()}}>${this.awaitingResponse?this._messages.stopButtonLabel:this._messages.askButtonLabel}</calcite-button></div></calcite-text-area></div>`}};m("arcgis-assistant-chat-entry",h);return h},"core/reactiveUtils","core/Collection")
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{a as $,c as k}from"./YGW7TUNX.js";import{A as N,a as C,b as L,c as m,d as f,e as P,f as O,k as g,m as v,o as w}from"./
|
|
2
|
+
import{a as $,c as k}from"./YGW7TUNX.js";import{A as N,a as C,b as L,c as m,d as f,e as P,f as O,k as g,m as v,o as w}from"./6TDOQJ45.js";var _=t=>(...s)=>{let o=f(),e=new t(...s),r=e.exports;m(o.at(-1));let n=e.component.manager;n.W(e,r),e.watchExports(n.W.bind(n,e)),P(e);let a=[e.component,...o].reverse();return v(a,i=>i===void 0?void 0:j(e,i,r),r)},j=(t,{host:s,key:o,isReactive:e},r)=>{let n=s,a=n[o]!==t.exports,i=n[o]!==r,c=r!==t.exports;if(a&&!i&&c&&(n[o]=t.exports),s===t.component){if(e){let l=t.component.manager;i&&l.W(t,n[o]),t.onUpdate(u=>{if(u.has(o)){let x=n[o];x!==t.exports&&l.W(t,x)}})}t.O=e?void 0:o}let d=t.component.constructor.elementProperties.get(o)?.readOnly;t.watchExports(()=>{n[o]!==t.exports&&(d?O(()=>{n[o]=t.exports}):n[o]=t.exports)})};var z="ar,bg,bs,ca,cs,da,de,el,en,es,et,fi,fr,he,hr,hu,id,it,ja,ko,lt,lv,nl,nb,no,pl,pt-BR,pt-PT,ro,ru,sk,sl,sr,sv,th,tr,uk,vi,zh-CN,zh-HK,zh-TW".split(","),M=new Set(z),h="en",U={pt:"pt-BR",nb:"no",nn:"no",zh:"zh-CN"},F=async(t,s,o="")=>{let e=`${s}/${o}`,r=`${e}${t}.json`;return b[r]??(b[r]=A(t,e)),await b[r]},b={},A=async(t,s)=>{let o=`${s}${t}.json`;try{let e=await fetch(o);if(e.ok)return await e.json()}catch(e){return g("error","intl",`An unknown error occurred while fetching localization strings at ${o}`,{detail:{error:e}}),{}}return t===h?{}:await A(h,s)},y=t=>{let s=k(t,"lang",globalThis.navigator?.language||h);return{lang:s,t9nLocale:D(s)}},D=t=>{let[s,o]=t.split("-"),e=s.toLowerCase(),r=e;return o&&(r=`${e}-${o.toUpperCase()}`),r=U[r]??r,M.has(r)?r:o?D(e):h},T=(t,s,o,e)=>{let r,n=()=>K(t,s(),e).then(a=>{(r?.lang!==a.lang||r.t9nLocale!==a.t9nLocale||r.t9nStrings!==a.t9nStrings)&&o(a),r=a}).catch(a=>{g("error","intl","Error updating component locale state",{detail:{error:a}})});return queueMicrotask(n),$(t,["lang"],n)},K=async(t,s,o=t.localName.split("-").slice(1).join("-"))=>{let{lang:e,t9nLocale:r}=y(t),n=`${s}/${o}/t9n`,i=o===null?{}:await F(r,n,"messages.");return{lang:e,t9nLocale:r,t9nStrings:i}};var W=t=>I(void 0,t);var E=class extends w{constructor(s,o){super(s);let e=this.exports;try{L(this.component);let r=o(this.component,this),n=this.exports!==e;if(C(r)){n||this.setProvisionalExports(r);let a=r.then(i=>{this.exports=i,super.catchUpLifecycle()}).catch(i=>{this.P.reject(i)});this.onLoad(async()=>await a)}else(!n||r!==void 0)&&(this.exports=r),queueMicrotask(()=>super.catchUpLifecycle())}catch(r){this.P.reject(r)}}catchUpLifecycle(){}},I=_(E);var S=t=>(s={})=>W((o,e)=>{let r=y(o.el),n={_lang:r.lang,_t9nLocale:r.t9nLocale,_loading:!0},a=o;e.onLifecycle(()=>T(o.el,()=>t("./assets"),({t9nLocale:c,t9nStrings:p,lang:d})=>{let l={...p,_lang:d,_t9nLocale:c,_loading:!1};e.exports=l;let u=p.componentLabel;typeof u=="string"&&"label"in o&&o.label==null&&(o.label??=u),i(a.messageOverrides)},s.name));let i=c=>{let p=e.exports,d=p._original??p,l=V(d,c);c&&(l._original=d),e.exports=l};return"messageOverrides"in a&&e.onUpdate(c=>{c.has("messageOverrides")&&i(a.messageOverrides)}),s.blocking?(e.setProvisionalExports(n,!1),e.ready):n}),V=(t,s)=>{if(!s)return t;let o={...t};return Object.entries(s).forEach(([e,r])=>{t[e]!==void 0&&(typeof r=="object"?o[e]=V(t[e],r):o[e]=r??t[e])}),o};var ct=S(N);export{ct as a};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{g as C,h as S,n as l,v as f,x as m,z as y}from"./ECU7VUF3.js";import"./CFDTXKJ6.js";export default $arcgis.t(([{when:w,watch:u},k,{property:d,subclass:v}])=>{var T=C`.assistant-chat-entry-speech-input__button{--calcite-button-background-color: var(--calcite-color-transparent);--calcite-button-border-color: transparent;--calcite-button-icon-color: var(--calcite-color-text-3);--calcite-button-text-color: var(--calcite-color-text-3);flex:0 0 auto;position:relative}.assistant-chat-entry-speech-input__button[data-state=disabled]{--calcite-button-icon-color: var(--calcite-color-text-3);opacity:var(--calcite-opacity-disabled)}.assistant-chat-entry-speech-input__button[data-state=listening]{--calcite-button-background-color: color-mix( in srgb, var(--calcite-color-brand) 14%, var(--calcite-color-foreground-1) );--calcite-button-border-color: color-mix(in srgb, var(--calcite-color-brand) 24%, transparent);--calcite-button-icon-color: var(--calcite-color-brand);--calcite-button-text-color: var(--calcite-color-brand);box-shadow:var(--calcite-shadow-sm)}.assistant-chat-entry-speech-input__button[data-state=listening]:hover{--calcite-button-background-color: color-mix( in srgb, var(--calcite-color-brand-hover, var(--calcite-color-brand)) 18%, var(--calcite-color-foreground-1) )}.assistant-chat-entry-speech-input__button[data-state=listening]:active{--calcite-button-background-color: color-mix( in srgb, var(--calcite-color-brand) 24%, var(--calcite-color-foreground-1) )}.assistant-chat-entry-speech-input__button[data-state=processing]{--calcite-button-background-color: color-mix( in srgb, var(--calcite-color-brand) 10%, var(--calcite-color-foreground-1) );--calcite-button-border-color: color-mix(in srgb, var(--calcite-color-brand) 20%, transparent);--calcite-button-icon-color: var(--calcite-color-brand);--calcite-button-text-color: var(--calcite-color-brand)}.assistant-chat-entry-speech-input__button[data-state=error]{--calcite-button-background-color: color-mix( in srgb, var(--calcite-color-status-danger) 12%, var(--calcite-color-foreground-1) );--calcite-button-border-color: color-mix(in srgb, var(--calcite-color-status-danger) 24%, transparent);--calcite-button-icon-color: var(--calcite-color-status-danger);--calcite-button-text-color: var(--calcite-color-status-danger)}.assistant-chat-entry-speech-input__button[data-state=listening]:after{content:"";position:absolute;inset:-4px;border:1px solid color-mix(in srgb,var(--calcite-color-brand) 40%,transparent);border-radius:inherit;opacity:0;pointer-events:none;transform:scale(.92);animation:assistant-chat-entry-speech-input-recording-pulse 1.8s ease-out infinite}@keyframes assistant-chat-entry-speech-input-recording-pulse{0%{opacity:.65;transform:scale(.92)}70%{opacity:0;transform:scale(1.16)}to{opacity:0;transform:scale(1.16)}}@media(prefers-reduced-motion){.assistant-chat-entry-speech-input__button[data-state=listening]:after{animation:none;opacity:1;transform:none}}`,I=Object.defineProperty,x=Object.getOwnPropertyDescriptor,p=(t,e,s,r)=>{for(var i=r>1?void 0:r?x(e,s):e,n=t.length-1,o;n>=0;n--)(o=t[n])&&(i=(r?o(e,s,i):o(i))||i);return r&&i&&I(e,s,i),i},a=class extends k{constructor(t){super(t),this.state="idle",this.liveTranscript="",this.transcript="",this.errorCode=void 0}static isSupported(){return!1}};p([d()],a.prototype,"language",2);p([d({readOnly:!0})],a.prototype,"state",2);p([d({readOnly:!0})],a.prototype,"liveTranscript",2);p([d({readOnly:!0})],a.prototype,"transcript",2);p([d({readOnly:!0})],a.prototype,"errorCode",2);a=p([v("SpeechController")],a);var O=["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/ogg;codecs=opus","audio/ogg"];function h(t){return t.replace(/\s+/gu," ").trim()}var M=Object.defineProperty,E=Object.getOwnPropertyDescriptor,g=(t,e,s,r)=>{for(var i=r>1?void 0:r?E(e,s):e,n=t.length-1,o;n>=0;n--)(o=t[n])&&(i=(r?o(e,s,i):o(i))||i);return r&&i&&M(e,s,i),i},c=class extends a{constructor(t){super(t),this._activeSessionId=null,this._mediaRecorder=null,this._mediaRecorderChunkIndex=0,this._mediaRecorderStopReason=null,this._mediaStream=null,this._pendingChunkOperations=new Set,this._recordedChunks=[],this.handleRecording=null,this.chunkTimeSlice=3e3}get _mimeType(){return typeof window>"u"||typeof window.MediaRecorder?.isTypeSupported!="function"?"":O.find(t=>window.MediaRecorder.isTypeSupported(t))??""}initialize(){c.isSupported()&&this.addHandles(w(()=>!!this.errorCode,()=>{this._set("state","error")}))}destroy(){this._mediaRecorder&&(this._mediaRecorder.onstart=null,this._mediaRecorder.ondataavailable=null,this._mediaRecorder.onerror=null,this._mediaRecorder.onstop=null),this.cancel(),this._mediaRecorder=null}_queuePendingChunkOperation(t){this._pendingChunkOperations.add(t),t.finally(()=>{this._pendingChunkOperations.delete(t)})}async _awaitPendingChunkOperations(){this._pendingChunkOperations.size&&await Promise.allSettled(Array.from(this._pendingChunkOperations))}_onDataAvailable(t){let e=this._activeSessionId;e!=null&&this._queuePendingChunkOperation(this._processDataAvailable(t,e))}async _processDataAvailable(t,e){let s=t.data;if(!s.size||e!==this._activeSessionId)return;this._recordedChunks.push(s);let r=s.type||this._mediaRecorder?.mimeType||this._mimeType,i=this._mediaRecorderStopReason==="toggle"&&this._mediaRecorder?.state==="inactive";try{if(!this.handleRecording)return;let n=h(await this.handleRecording(s,r,this._mediaRecorderChunkIndex,i)??"");if(e!==this._activeSessionId)return;n&&this._set("liveTranscript",h(`${this.liveTranscript} ${n}`))}catch(n){if(e!==this._activeSessionId)return;this._failSession(n instanceof Error&&n.message==="transcription-unavailable"?"transcription-unavailable":"transcription-failed");return}!i&&e===this._activeSessionId&&(this._mediaRecorderChunkIndex+=1)}_failSession(t){let e=this._mediaRecorder;if(e){e.onstart=null,e.ondataavailable=null,e.onerror=null,e.onstop=null;try{e.state!=="inactive"&&e.stop()}catch{}}this._activeSessionId=null,this._mediaRecorder=null,this._mediaRecorderChunkIndex=0,this._mediaRecorderStopReason=null,this._pendingChunkOperations.clear(),this._recordedChunks=[],this._releaseMediaStream(),this._set("liveTranscript",""),this._set("transcript",""),this._set("errorCode",t)}_onError(){this._failSession("recording-failed")}_onStart(){this._set("state","listening")}_onStop(){this._handleStop()}_releaseMediaStream(){this._mediaStream?.getTracks().forEach(t=>t.stop()),this._mediaStream=null}async _handleStop(){let t=this._mediaRecorder,e=this._activeSessionId,s=this._mediaRecorderStopReason,r=t?.mimeType||this._recordedChunks.find(n=>!!n.type)?.type||"",i=[...this._recordedChunks];if(this._mediaRecorder=null,this._mediaRecorderChunkIndex=0,this._releaseMediaStream(),s==="cancel"){this._activeSessionId===e&&(this._activeSessionId=null),this._mediaRecorderStopReason=null,this._pendingChunkOperations.clear(),this._recordedChunks=[],this._set("liveTranscript",""),this._set("transcript",""),this._set("state","idle"),this._set("errorCode",void 0);return}if(e==null){this._mediaRecorderStopReason=null,this._pendingChunkOperations.clear(),this._recordedChunks=[],this._set("state","idle"),this._set("errorCode",void 0);return}if(await this._awaitPendingChunkOperations(),e===this._activeSessionId){if(!(r?new Blob(i,{type:r}):new Blob(i)).size){this._activeSessionId===e&&(this._activeSessionId=null),this._mediaRecorderStopReason=null,this._recordedChunks=[],this._set("errorCode","recording-failed");return}this._set("state","processing"),this._set("transcript",h(`${this.transcript} ${this.liveTranscript}`)),this._set("liveTranscript",""),this._activeSessionId===e&&(this._activeSessionId=null),this._set("state","idle"),this._set("errorCode",void 0),this._mediaRecorderStopReason=null,this._recordedChunks=[]}}start(){if(!c.isSupported()){this._set("errorCode","not-supported");return}let t=Date.now();this._activeSessionId=t,this._mediaRecorderChunkIndex=0,this._mediaRecorderStopReason=null,this._pendingChunkOperations.clear(),this._recordedChunks=[],this._set("liveTranscript",""),this._set("transcript",""),this._set("errorCode",void 0),navigator.mediaDevices.getUserMedia({audio:!0}).then(e=>{if(t!==this._activeSessionId){e.getTracks().forEach(i=>i.stop());return}let s=this._mimeType,r=s?new window.MediaRecorder(e,{mimeType:s}):new window.MediaRecorder(e);this._mediaStream=e,this._mediaRecorder=r,this._mediaRecorderChunkIndex=0,this._mediaRecorderStopReason=null,this._recordedChunks=[],r.ondataavailable=this._onDataAvailable.bind(this),r.onerror=this._onError.bind(this),r.onstart=this._onStart.bind(this),r.onstop=this._onStop.bind(this),this._mediaRecorder.start(this.chunkTimeSlice)}).catch(e=>{t===this._activeSessionId&&(this._activeSessionId=null,this._mediaRecorder=null,this._mediaRecorderChunkIndex=0,this._mediaRecorderStopReason=null,this._pendingChunkOperations.clear(),this._recordedChunks=[],this._releaseMediaStream(),e instanceof DOMException&&e.name==="NotAllowedError"?this._set("errorCode","not-allowed"):this._set("errorCode","recording-failed"))})}stop(){if(this._mediaRecorder){this._mediaRecorderStopReason="toggle";try{this._mediaRecorder.state!=="inactive"?this._mediaRecorder.stop():this._handleStop()}catch{}}}cancel(){let t=this._mediaRecorder;if(this._activeSessionId=null,this._mediaRecorderStopReason="cancel",this._mediaRecorderChunkIndex=0,this._pendingChunkOperations.clear(),this._recordedChunks=[],this._set("liveTranscript",""),this._set("transcript",""),this._set("state","idle"),this._set("errorCode",void 0),!t){this._releaseMediaStream();return}try{if(t.state!=="inactive"){t.stop();return}}catch{}this._mediaRecorder=null,this._releaseMediaStream()}static isSupported(){return typeof window<"u"&&!!(window.MediaRecorder&&navigator.mediaDevices?.getUserMedia)}};g([d()],c.prototype,"_mimeType",1);g([d()],c.prototype,"handleRecording",2);g([d()],c.prototype,"chunkTimeSlice",2);c=g([v("MediaRecorderController")],c);var $=Object.getOwnPropertyDescriptor,D=(t,e,s,r)=>{for(var i=r>1?void 0:r?$(e,s):e,n=t.length-1,o;n>=0;n--)(o=t[n])&&(i=o(i)||i);return i};function R(){if(typeof window>"u")return null;let t=window;return t.SpeechRecognition??t.webkitSpeechRecognition??null}var _=class extends a{constructor(t){super(t),this._isCancelled=!1,this._recognition=null}initialize(){let t=R();if(!t)return;let e=new t;e.continuous=!0,e.interimResults=!0,this.language&&(e.lang=this.language),e.onstart=this._onStart.bind(this),e.onresult=this._onResult.bind(this),e.onerror=this._onError.bind(this),e.onend=this._onEnd.bind(this),e.onspeechend=this._onSpeechEnd.bind(this),this._recognition=e,this.addHandles(w(()=>!!this.errorCode,()=>{this._set("state","error")}))}destroy(){this._recognition&&(this._recognition.onstart=null,this._recognition.onresult=null,this._recognition.onerror=null,this._recognition.onend=null,this._recognition.onspeechend=null,this.cancel(),this._recognition=null)}_onStart(){this._isCancelled=!1,this._set("state","listening")}_onResult(t){let{finalTranscript:e,liveTranscript:s}=Array.from(t.results).reduce((r,i)=>(i.isFinal?r.finalTranscript+=i[0].transcript:r.liveTranscript+=i[0].transcript,r),{finalTranscript:"",liveTranscript:""});this._set("transcript",h(e)),this._set("liveTranscript",h(s))}_onError(t){if(t.error==="aborted"&&this._isCancelled){this._set("state","idle");return}let e="unhandled";switch(t.error){case"no-speech":e="no-speech";break;case"service-not-allowed":case"not-allowed":e="not-allowed";break;default:e="unhandled"}this._set("errorCode",e)}_onEnd(){let t=h(`${this.transcript} ${this.liveTranscript}`);if(this._set("liveTranscript",""),this._isCancelled){this._set("transcript",""),this._set("state","idle"),this._set("errorCode",void 0);return}this.errorCode?this._set("transcript",""):(this._set("transcript",t),this._set("state","idle")),this._set("errorCode",void 0)}_onSpeechEnd(){this._set("state","processing")}_reset(t=!1){this._isCancelled=t,this._set("liveTranscript",""),this._set("transcript",""),this._set("errorCode",void 0),this._set("state","idle")}start(){if(!this._recognition){this._set("errorCode","not-supported");return}this._reset(!1);try{this._recognition.start()}catch{this._set("errorCode","unhandled")}}stop(){if(this._recognition){this._set("state","processing");try{this._recognition.stop()}catch{}}}cancel(){if(this._recognition){this._reset(!0);try{this._recognition.abort()}catch{}}}static isSupported(){return!!R()}};_=D([v("WebSpeechController")],_);var b=class extends f{constructor(){super(...arguments),this._resolvedMode="disabled",this.awaitingResponse=!1,this.mode="web-speech",this.arcgisVoiceInputError=l(),this.arcgisVoiceInputStart=l(),this.arcgisVoiceInputStop=l(),this.arcgisVoiceInputInterimTranscription=l(),this.arcgisVoiceInputTranscription=l(),this.arcgisVoiceInputTranscriptionStreamChunk=l()}static{this.properties={_resolvedMode:16,_state:16,_errorCode:16,_liveTranscript:16,_transcript:16,_isButtonDisabled:16,_buttonLabel:16,awaitingResponse:5,language:1,mode:1}}static{this.styles=T}get _state(){return this._speechController?.state??"idle"}get _errorCode(){return this._speechController?.errorCode??null}get _liveTranscript(){return this._speechController?.liveTranscript??""}get _transcript(){return this._speechController?.transcript??""}get _isButtonDisabled(){return this._resolvedMode==="disabled"||this.awaitingResponse||this._state==="processing"}get _buttonLabel(){if(this.awaitingResponse)return"Voice input unavailable while assistant is responding";if(this._resolvedMode==="disabled")return"Voice input unavailable";switch(this._state){case"error":return this._errorCode==="not-allowed"?"Microphone permission denied. Retry voice input":"Retry voice input";case"listening":return"Stop voice input";case"processing":return"Processing voice input";default:return"Start voice input"}}loaded(){this.manager.onLifecycle(()=>[u(()=>[this.mode,this.language],()=>{this._configureController()},{initial:!0}),u(()=>this.awaitingResponse,e=>{e&&this._cancelActiveSession()},{initial:!0}),u(()=>this._liveTranscript,e=>{if(e){let s=h(`${this._transcript} ${e}`);this.arcgisVoiceInputInterimTranscription.emit({transcript:s})}}),u(()=>this._transcript,e=>{e&&this.arcgisVoiceInputTranscription.emit({transcript:e})}),u(()=>this._state,e=>{e==="error"&&this._errorCode&&this.arcgisVoiceInputError.emit({errorCode:this._errorCode})})])}disconnectedCallback(){super.disconnectedCallback(),this._destroySpeechController()}_configureController(){let e=this._resolveMode();this._destroySpeechController(),this._resolvedMode=e,e!=="disabled"&&(this._speechController=e==="web-speech"?new _({language:this.language}):new c({language:this.language,handleRecording:this._handleRecording.bind(this)}))}_destroySpeechController(){this._speechController?.cancel(),this._speechController?.destroy(),this._speechController=void 0}async _handleToggle(){if(!(this._isButtonDisabled||!this._speechController)){if(this._state==="listening"){this._speechController.stop(),this.arcgisVoiceInputStop.emit();return}this._speechController.start(),this.arcgisVoiceInputStart.emit()}}async _handleRecording(e,s,r,i){let n;return this.arcgisVoiceInputTranscriptionStreamChunk.emit({blob:e,chunkIndex:r,isFinal:i,mimeType:s,respondWithTranscript:o=>{n=o}}),n}_resolveMode(){return this.mode==="disabled"?"disabled":this.mode==="web-speech"&&_.isSupported()?"web-speech":c.isSupported()?"media-recorder":"disabled"}async _cancelActiveSession(){this._speechController&&this._resolvedMode!=="disabled"&&this._speechController.cancel()}render(){return S`<calcite-button appearance=transparent class="assistant-chat-entry-speech-input__button" data-mode=${this._resolvedMode??m} data-state=${(this._resolvedMode==="disabled"?"disabled":this._state)??m} .disabled=${this._isButtonDisabled} icon-start=microphone kind=neutral .label=${this._buttonLabel} .loading=${this._state==="processing"} round scale=m @click=${()=>{this._handleToggle()}}></calcite-button>`}};y("arcgis-assistant-chat-entry-speech-input",b);return b},"core/reactiveUtils","core/Accessor","core/accessorSupport/decorators")
|
|
2
|
+
import{g as C,h as S,n as l,v as f,x as m,z as y}from"./6TDOQJ45.js";import"./CFDTXKJ6.js";export default $arcgis.t(([{when:w,watch:u},k,{property:d,subclass:v}])=>{var T=C`.assistant-chat-entry-speech-input__button{--calcite-button-background-color: var(--calcite-color-transparent);--calcite-button-border-color: transparent;--calcite-button-icon-color: var(--calcite-color-text-3);--calcite-button-text-color: var(--calcite-color-text-3);flex:0 0 auto;position:relative}.assistant-chat-entry-speech-input__button[data-state=disabled]{--calcite-button-icon-color: var(--calcite-color-text-3);opacity:var(--calcite-opacity-disabled)}.assistant-chat-entry-speech-input__button[data-state=listening]{--calcite-button-background-color: color-mix( in srgb, var(--calcite-color-brand) 14%, var(--calcite-color-foreground-1) );--calcite-button-border-color: color-mix(in srgb, var(--calcite-color-brand) 24%, transparent);--calcite-button-icon-color: var(--calcite-color-brand);--calcite-button-text-color: var(--calcite-color-brand);box-shadow:var(--calcite-shadow-sm)}.assistant-chat-entry-speech-input__button[data-state=listening]:hover{--calcite-button-background-color: color-mix( in srgb, var(--calcite-color-brand-hover, var(--calcite-color-brand)) 18%, var(--calcite-color-foreground-1) )}.assistant-chat-entry-speech-input__button[data-state=listening]:active{--calcite-button-background-color: color-mix( in srgb, var(--calcite-color-brand) 24%, var(--calcite-color-foreground-1) )}.assistant-chat-entry-speech-input__button[data-state=processing]{--calcite-button-background-color: color-mix( in srgb, var(--calcite-color-brand) 10%, var(--calcite-color-foreground-1) );--calcite-button-border-color: color-mix(in srgb, var(--calcite-color-brand) 20%, transparent);--calcite-button-icon-color: var(--calcite-color-brand);--calcite-button-text-color: var(--calcite-color-brand)}.assistant-chat-entry-speech-input__button[data-state=error]{--calcite-button-background-color: color-mix( in srgb, var(--calcite-color-status-danger) 12%, var(--calcite-color-foreground-1) );--calcite-button-border-color: color-mix(in srgb, var(--calcite-color-status-danger) 24%, transparent);--calcite-button-icon-color: var(--calcite-color-status-danger);--calcite-button-text-color: var(--calcite-color-status-danger)}.assistant-chat-entry-speech-input__button[data-state=listening]:after{content:"";position:absolute;inset:-4px;border:1px solid color-mix(in srgb,var(--calcite-color-brand) 40%,transparent);border-radius:inherit;opacity:0;pointer-events:none;transform:scale(.92);animation:assistant-chat-entry-speech-input-recording-pulse 1.8s ease-out infinite}@keyframes assistant-chat-entry-speech-input-recording-pulse{0%{opacity:.65;transform:scale(.92)}70%{opacity:0;transform:scale(1.16)}to{opacity:0;transform:scale(1.16)}}@media(prefers-reduced-motion){.assistant-chat-entry-speech-input__button[data-state=listening]:after{animation:none;opacity:1;transform:none}}`,I=Object.defineProperty,x=Object.getOwnPropertyDescriptor,p=(t,e,s,r)=>{for(var i=r>1?void 0:r?x(e,s):e,n=t.length-1,o;n>=0;n--)(o=t[n])&&(i=(r?o(e,s,i):o(i))||i);return r&&i&&I(e,s,i),i},a=class extends k{constructor(t){super(t),this.state="idle",this.liveTranscript="",this.transcript="",this.errorCode=void 0}static isSupported(){return!1}};p([d()],a.prototype,"language",2);p([d({readOnly:!0})],a.prototype,"state",2);p([d({readOnly:!0})],a.prototype,"liveTranscript",2);p([d({readOnly:!0})],a.prototype,"transcript",2);p([d({readOnly:!0})],a.prototype,"errorCode",2);a=p([v("SpeechController")],a);var O=["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/ogg;codecs=opus","audio/ogg"];function h(t){return t.replace(/\s+/gu," ").trim()}var M=Object.defineProperty,E=Object.getOwnPropertyDescriptor,g=(t,e,s,r)=>{for(var i=r>1?void 0:r?E(e,s):e,n=t.length-1,o;n>=0;n--)(o=t[n])&&(i=(r?o(e,s,i):o(i))||i);return r&&i&&M(e,s,i),i},c=class extends a{constructor(t){super(t),this._activeSessionId=null,this._mediaRecorder=null,this._mediaRecorderChunkIndex=0,this._mediaRecorderStopReason=null,this._mediaStream=null,this._pendingChunkOperations=new Set,this._recordedChunks=[],this.handleRecording=null,this.chunkTimeSlice=3e3}get _mimeType(){return typeof window>"u"||typeof window.MediaRecorder?.isTypeSupported!="function"?"":O.find(t=>window.MediaRecorder.isTypeSupported(t))??""}initialize(){c.isSupported()&&this.addHandles(w(()=>!!this.errorCode,()=>{this._set("state","error")}))}destroy(){this._mediaRecorder&&(this._mediaRecorder.onstart=null,this._mediaRecorder.ondataavailable=null,this._mediaRecorder.onerror=null,this._mediaRecorder.onstop=null),this.cancel(),this._mediaRecorder=null}_queuePendingChunkOperation(t){this._pendingChunkOperations.add(t),t.finally(()=>{this._pendingChunkOperations.delete(t)})}async _awaitPendingChunkOperations(){this._pendingChunkOperations.size&&await Promise.allSettled(Array.from(this._pendingChunkOperations))}_onDataAvailable(t){let e=this._activeSessionId;e!=null&&this._queuePendingChunkOperation(this._processDataAvailable(t,e))}async _processDataAvailable(t,e){let s=t.data;if(!s.size||e!==this._activeSessionId)return;this._recordedChunks.push(s);let r=s.type||this._mediaRecorder?.mimeType||this._mimeType,i=this._mediaRecorderStopReason==="toggle"&&this._mediaRecorder?.state==="inactive";try{if(!this.handleRecording)return;let n=h(await this.handleRecording(s,r,this._mediaRecorderChunkIndex,i)??"");if(e!==this._activeSessionId)return;n&&this._set("liveTranscript",h(`${this.liveTranscript} ${n}`))}catch(n){if(e!==this._activeSessionId)return;this._failSession(n instanceof Error&&n.message==="transcription-unavailable"?"transcription-unavailable":"transcription-failed");return}!i&&e===this._activeSessionId&&(this._mediaRecorderChunkIndex+=1)}_failSession(t){let e=this._mediaRecorder;if(e){e.onstart=null,e.ondataavailable=null,e.onerror=null,e.onstop=null;try{e.state!=="inactive"&&e.stop()}catch{}}this._activeSessionId=null,this._mediaRecorder=null,this._mediaRecorderChunkIndex=0,this._mediaRecorderStopReason=null,this._pendingChunkOperations.clear(),this._recordedChunks=[],this._releaseMediaStream(),this._set("liveTranscript",""),this._set("transcript",""),this._set("errorCode",t)}_onError(){this._failSession("recording-failed")}_onStart(){this._set("state","listening")}_onStop(){this._handleStop()}_releaseMediaStream(){this._mediaStream?.getTracks().forEach(t=>t.stop()),this._mediaStream=null}async _handleStop(){let t=this._mediaRecorder,e=this._activeSessionId,s=this._mediaRecorderStopReason,r=t?.mimeType||this._recordedChunks.find(n=>!!n.type)?.type||"",i=[...this._recordedChunks];if(this._mediaRecorder=null,this._mediaRecorderChunkIndex=0,this._releaseMediaStream(),s==="cancel"){this._activeSessionId===e&&(this._activeSessionId=null),this._mediaRecorderStopReason=null,this._pendingChunkOperations.clear(),this._recordedChunks=[],this._set("liveTranscript",""),this._set("transcript",""),this._set("state","idle"),this._set("errorCode",void 0);return}if(e==null){this._mediaRecorderStopReason=null,this._pendingChunkOperations.clear(),this._recordedChunks=[],this._set("state","idle"),this._set("errorCode",void 0);return}if(await this._awaitPendingChunkOperations(),e===this._activeSessionId){if(!(r?new Blob(i,{type:r}):new Blob(i)).size){this._activeSessionId===e&&(this._activeSessionId=null),this._mediaRecorderStopReason=null,this._recordedChunks=[],this._set("errorCode","recording-failed");return}this._set("state","processing"),this._set("transcript",h(`${this.transcript} ${this.liveTranscript}`)),this._set("liveTranscript",""),this._activeSessionId===e&&(this._activeSessionId=null),this._set("state","idle"),this._set("errorCode",void 0),this._mediaRecorderStopReason=null,this._recordedChunks=[]}}start(){if(!c.isSupported()){this._set("errorCode","not-supported");return}let t=Date.now();this._activeSessionId=t,this._mediaRecorderChunkIndex=0,this._mediaRecorderStopReason=null,this._pendingChunkOperations.clear(),this._recordedChunks=[],this._set("liveTranscript",""),this._set("transcript",""),this._set("errorCode",void 0),navigator.mediaDevices.getUserMedia({audio:!0}).then(e=>{if(t!==this._activeSessionId){e.getTracks().forEach(i=>i.stop());return}let s=this._mimeType,r=s?new window.MediaRecorder(e,{mimeType:s}):new window.MediaRecorder(e);this._mediaStream=e,this._mediaRecorder=r,this._mediaRecorderChunkIndex=0,this._mediaRecorderStopReason=null,this._recordedChunks=[],r.ondataavailable=this._onDataAvailable.bind(this),r.onerror=this._onError.bind(this),r.onstart=this._onStart.bind(this),r.onstop=this._onStop.bind(this),this._mediaRecorder.start(this.chunkTimeSlice)}).catch(e=>{t===this._activeSessionId&&(this._activeSessionId=null,this._mediaRecorder=null,this._mediaRecorderChunkIndex=0,this._mediaRecorderStopReason=null,this._pendingChunkOperations.clear(),this._recordedChunks=[],this._releaseMediaStream(),e instanceof DOMException&&e.name==="NotAllowedError"?this._set("errorCode","not-allowed"):this._set("errorCode","recording-failed"))})}stop(){if(this._mediaRecorder){this._mediaRecorderStopReason="toggle";try{this._mediaRecorder.state!=="inactive"?this._mediaRecorder.stop():this._handleStop()}catch{}}}cancel(){let t=this._mediaRecorder;if(this._activeSessionId=null,this._mediaRecorderStopReason="cancel",this._mediaRecorderChunkIndex=0,this._pendingChunkOperations.clear(),this._recordedChunks=[],this._set("liveTranscript",""),this._set("transcript",""),this._set("state","idle"),this._set("errorCode",void 0),!t){this._releaseMediaStream();return}try{if(t.state!=="inactive"){t.stop();return}}catch{}this._mediaRecorder=null,this._releaseMediaStream()}static isSupported(){return typeof window<"u"&&!!(window.MediaRecorder&&navigator.mediaDevices?.getUserMedia)}};g([d()],c.prototype,"_mimeType",1);g([d()],c.prototype,"handleRecording",2);g([d()],c.prototype,"chunkTimeSlice",2);c=g([v("MediaRecorderController")],c);var $=Object.getOwnPropertyDescriptor,D=(t,e,s,r)=>{for(var i=r>1?void 0:r?$(e,s):e,n=t.length-1,o;n>=0;n--)(o=t[n])&&(i=o(i)||i);return i};function R(){if(typeof window>"u")return null;let t=window;return t.SpeechRecognition??t.webkitSpeechRecognition??null}var _=class extends a{constructor(t){super(t),this._isCancelled=!1,this._recognition=null}initialize(){let t=R();if(!t)return;let e=new t;e.continuous=!0,e.interimResults=!0,this.language&&(e.lang=this.language),e.onstart=this._onStart.bind(this),e.onresult=this._onResult.bind(this),e.onerror=this._onError.bind(this),e.onend=this._onEnd.bind(this),e.onspeechend=this._onSpeechEnd.bind(this),this._recognition=e,this.addHandles(w(()=>!!this.errorCode,()=>{this._set("state","error")}))}destroy(){this._recognition&&(this._recognition.onstart=null,this._recognition.onresult=null,this._recognition.onerror=null,this._recognition.onend=null,this._recognition.onspeechend=null,this.cancel(),this._recognition=null)}_onStart(){this._isCancelled=!1,this._set("state","listening")}_onResult(t){let{finalTranscript:e,liveTranscript:s}=Array.from(t.results).reduce((r,i)=>(i.isFinal?r.finalTranscript+=i[0].transcript:r.liveTranscript+=i[0].transcript,r),{finalTranscript:"",liveTranscript:""});this._set("transcript",h(e)),this._set("liveTranscript",h(s))}_onError(t){if(t.error==="aborted"&&this._isCancelled){this._set("state","idle");return}let e="unhandled";switch(t.error){case"no-speech":e="no-speech";break;case"service-not-allowed":case"not-allowed":e="not-allowed";break;default:e="unhandled"}this._set("errorCode",e)}_onEnd(){let t=h(`${this.transcript} ${this.liveTranscript}`);if(this._set("liveTranscript",""),this._isCancelled){this._set("transcript",""),this._set("state","idle"),this._set("errorCode",void 0);return}this.errorCode?this._set("transcript",""):(this._set("transcript",t),this._set("state","idle")),this._set("errorCode",void 0)}_onSpeechEnd(){this._set("state","processing")}_reset(t=!1){this._isCancelled=t,this._set("liveTranscript",""),this._set("transcript",""),this._set("errorCode",void 0),this._set("state","idle")}start(){if(!this._recognition){this._set("errorCode","not-supported");return}this._reset(!1);try{this._recognition.start()}catch{this._set("errorCode","unhandled")}}stop(){if(this._recognition){this._set("state","processing");try{this._recognition.stop()}catch{}}}cancel(){if(this._recognition){this._reset(!0);try{this._recognition.abort()}catch{}}}static isSupported(){return!!R()}};_=D([v("WebSpeechController")],_);var b=class extends f{constructor(){super(...arguments),this._resolvedMode="disabled",this.awaitingResponse=!1,this.mode="web-speech",this.arcgisVoiceInputError=l(),this.arcgisVoiceInputStart=l(),this.arcgisVoiceInputStop=l(),this.arcgisVoiceInputInterimTranscription=l(),this.arcgisVoiceInputTranscription=l(),this.arcgisVoiceInputTranscriptionStreamChunk=l()}static{this.properties={_resolvedMode:16,_state:16,_errorCode:16,_liveTranscript:16,_transcript:16,_isButtonDisabled:16,_buttonLabel:16,awaitingResponse:5,language:1,mode:1}}static{this.styles=T}get _state(){return this._speechController?.state??"idle"}get _errorCode(){return this._speechController?.errorCode??null}get _liveTranscript(){return this._speechController?.liveTranscript??""}get _transcript(){return this._speechController?.transcript??""}get _isButtonDisabled(){return this._resolvedMode==="disabled"||this.awaitingResponse||this._state==="processing"}get _buttonLabel(){if(this.awaitingResponse)return"Voice input unavailable while assistant is responding";if(this._resolvedMode==="disabled")return"Voice input unavailable";switch(this._state){case"error":return this._errorCode==="not-allowed"?"Microphone permission denied. Retry voice input":"Retry voice input";case"listening":return"Stop voice input";case"processing":return"Processing voice input";default:return"Start voice input"}}loaded(){this.manager.onLifecycle(()=>[u(()=>[this.mode,this.language],()=>{this._configureController()},{initial:!0}),u(()=>this.awaitingResponse,e=>{e&&this._cancelActiveSession()},{initial:!0}),u(()=>this._liveTranscript,e=>{if(e){let s=h(`${this._transcript} ${e}`);this.arcgisVoiceInputInterimTranscription.emit({transcript:s})}}),u(()=>this._transcript,e=>{e&&this.arcgisVoiceInputTranscription.emit({transcript:e})}),u(()=>this._state,e=>{e==="error"&&this._errorCode&&this.arcgisVoiceInputError.emit({errorCode:this._errorCode})})])}disconnectedCallback(){super.disconnectedCallback(),this._destroySpeechController()}_configureController(){let e=this._resolveMode();this._destroySpeechController(),this._resolvedMode=e,e!=="disabled"&&(this._speechController=e==="web-speech"?new _({language:this.language}):new c({language:this.language,handleRecording:this._handleRecording.bind(this)}))}_destroySpeechController(){this._speechController?.cancel(),this._speechController?.destroy(),this._speechController=void 0}async _handleToggle(){if(!(this._isButtonDisabled||!this._speechController)){if(this._state==="listening"){this._speechController.stop(),this.arcgisVoiceInputStop.emit();return}this._speechController.start(),this.arcgisVoiceInputStart.emit()}}async _handleRecording(e,s,r,i){let n;return this.arcgisVoiceInputTranscriptionStreamChunk.emit({blob:e,chunkIndex:r,isFinal:i,mimeType:s,respondWithTranscript:o=>{n=o}}),n}_resolveMode(){return this.mode==="disabled"?"disabled":this.mode==="web-speech"&&_.isSupported()?"web-speech":c.isSupported()?"media-recorder":"disabled"}async _cancelActiveSession(){this._speechController&&this._resolvedMode!=="disabled"&&this._speechController.cancel()}render(){return S`<calcite-button appearance=transparent class="assistant-chat-entry-speech-input__button" data-mode=${this._resolvedMode??m} data-state=${(this._resolvedMode==="disabled"?"disabled":this._state)??m} .disabled=${this._isButtonDisabled} icon-start=microphone kind=neutral .label=${this._buttonLabel} .loading=${this._state==="processing"} round scale=m @click=${()=>{this._handleToggle()}}></calcite-button>`}};y("arcgis-assistant-chat-entry-speech-input",b);return b},"core/reactiveUtils","core/Accessor","core/accessorSupport/decorators")
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import c from"./Y4RSINW4.js";import b from"./L7YTPHKQ.js";import{a as e,c as a}from"./B4DEC7PH.js";import"./KVH3PDVW.js";import"./YGW7TUNX.js";import{v as s,z as r}from"./
|
|
2
|
+
import c from"./Y4RSINW4.js";import b from"./L7YTPHKQ.js";import{a as e,c as a}from"./B4DEC7PH.js";import"./KVH3PDVW.js";import"./YGW7TUNX.js";import{v as s,z as r}from"./6TDOQJ45.js";import"./CFDTXKJ6.js";export default $arcgis.t(([,{c:i}])=>{var t=class extends s{constructor(){super(...arguments),this.agent=i}static{this.properties={referenceElement:1}}#t;getContext(){if(!this.#t)throw new Error("arcgis-assistant-layer-styling-agent requires a mapView");return{mapView:this.#t}}load(){this.#t=e(this,"arcgis-assistant-layer-styling-agent"),a(this)}};r("arcgis-assistant-layer-styling-agent",t);return t},b,c)
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{b as e,c as i}from"./B4DEC7PH.js";import"./KVH3PDVW.js";import"./YGW7TUNX.js";import{v as s,z as a}from"./
|
|
2
|
+
import{b as e,c as i}from"./B4DEC7PH.js";import"./KVH3PDVW.js";import"./YGW7TUNX.js";import{v as s,z as a}from"./6TDOQJ45.js";import"./CFDTXKJ6.js";var t=class extends s{static{this.properties={agent:0,context:0}}async getContext(){return e(this.context)?await this.context():this.context}load(){i(this)}};a("arcgis-assistant-agent",t);export{t as ArcgisAssistantAgent};
|