@avatarfactory/react 0.1.40 → 0.1.41

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/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { U as UseAvatarResult } from './AvatarProvider-BXaeG3PZ.mjs';
2
- export { A as ActionAwaiting, a as ActionCheckResult, b as ActionContext, c as ActionDefinition, d as ActionFlow, e as ActionFlowStage, f as ActionKind, g as ActionParam, h as ActionParamType, i as ActionResult, j as ActionUi, k as ActionUiOp, l as AppEventArgs, m as AppEventPolicy, n as Avatar, o as AvatarConnectingLoader, p as AvatarConnectingLoaderProps, q as AvatarEnvironment, r as AvatarError, s as AvatarErrorCode, t as AvatarErrorSource, u as AvatarEventMap, v as AvatarProvider, w as AvatarPublicProps, x as AvatarWidget, y as AvatarWidgetProps, B as BRIDGE_NAMESPACE, z as BRIDGE_VERSION, C as BridgeActionDeclaration, D as BridgeEnvelope, E as BridgeMessage, F as CaptionPosition, G as ConnectionHealth, H as HealthConcern, I as HealthService, J as HealthState, L as LoaderMessage, P as PaintPhase, R as RuntimeMessage, S as ScreenSharePosition, K as ScreenShareUiConfig, M as SessionPhase, N as StatusBannerConfig, O as StatusBannerPosition, T as ThinkingIndicatorConfig, Q as ThinkingIndicatorPosition, V as TourHighlight, W as TourSide, X as TourState, Y as TourStep, Z as TourTarget, _ as TranscriptConfig, $ as TranscriptEntry, a0 as TranscriptSpeaker, a1 as TranscriptWord, a2 as TurnPhase, a3 as UseAvatarActionFlowResult, a4 as UseAvatarWidgetResult, a5 as WIDGET_DEFAULTS, a6 as WidgetAppearance, a7 as WidgetBehaviour, a8 as WidgetBox, a9 as WidgetConfig, aa as WidgetContextPolicy, ab as WidgetDeploymentProjection, ac as WidgetLauncherStyle, ad as WidgetLimits, ae as WidgetMobileMode, af as WidgetOffset, ag as WidgetPanelSize, ah as WidgetPosition, ai as WidgetStage, aj as WidgetTeaser, ak as WidgetTour, al as buildEnvelope, am as parseBridgeMessage, an as postBridgeMessage, ao as resolveWidgetAppearance, ap as useAvatarAction, aq as useAvatarActionFlow, ar as useAvatarEvent, as as useAvatarWidget } from './AvatarProvider-BXaeG3PZ.mjs';
1
+ import { U as UseAvatarResult } from './AvatarProvider-DqD003D2.mjs';
2
+ export { A as ActionAwaiting, a as ActionCheckResult, b as ActionContext, c as ActionDefinition, d as ActionFlow, e as ActionFlowStage, f as ActionKind, g as ActionParam, h as ActionParamType, i as ActionResult, j as ActionUi, k as ActionUiOp, l as AppEventArgs, m as AppEventPolicy, n as Avatar, o as AvatarConnectingLoader, p as AvatarConnectingLoaderProps, q as AvatarEnvironment, r as AvatarError, s as AvatarErrorCode, t as AvatarErrorSource, u as AvatarEventMap, v as AvatarProvider, w as AvatarPublicProps, x as AvatarWidget, y as AvatarWidgetProps, B as BRIDGE_NAMESPACE, z as BRIDGE_VERSION, C as BridgeActionDeclaration, D as BridgeEnvelope, E as BridgeMessage, F as CaptionPosition, G as ConnectionHealth, H as HealthConcern, I as HealthService, J as HealthState, L as LoaderMessage, P as PaintPhase, R as RuntimeMessage, S as ScreenSharePosition, K as ScreenShareUiConfig, M as SessionPhase, N as StatusBannerConfig, O as StatusBannerPosition, T as ThinkingIndicatorConfig, Q as ThinkingIndicatorPosition, V as TourHighlight, W as TourSide, X as TourState, Y as TourStep, Z as TourTarget, _ as TranscriptConfig, $ as TranscriptEntry, a0 as TranscriptSpeaker, a1 as TranscriptWord, a2 as TurnPhase, a3 as UseAvatarActionFlowResult, a4 as UseAvatarWidgetResult, a5 as WIDGET_DEFAULTS, a6 as WidgetAppearance, a7 as WidgetBehaviour, a8 as WidgetBox, a9 as WidgetConfig, aa as WidgetContextPolicy, ab as WidgetDeploymentProjection, ac as WidgetLauncherStyle, ad as WidgetLimits, ae as WidgetMobileMode, af as WidgetOffset, ag as WidgetPanelSize, ah as WidgetPosition, ai as WidgetStage, aj as WidgetTeaser, ak as WidgetTour, al as buildEnvelope, am as parseBridgeMessage, an as postBridgeMessage, ao as resolveWidgetAppearance, ap as useAvatarAction, aq as useAvatarActionFlow, ar as useAvatarEvent, as as useAvatarWidget } from './AvatarProvider-DqD003D2.mjs';
3
3
  import 'react/jsx-runtime';
4
4
  import './remotePageSurface-ao95kNYE.mjs';
5
5
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { U as UseAvatarResult } from './AvatarProvider-Cll_r1hx.js';
2
- export { A as ActionAwaiting, a as ActionCheckResult, b as ActionContext, c as ActionDefinition, d as ActionFlow, e as ActionFlowStage, f as ActionKind, g as ActionParam, h as ActionParamType, i as ActionResult, j as ActionUi, k as ActionUiOp, l as AppEventArgs, m as AppEventPolicy, n as Avatar, o as AvatarConnectingLoader, p as AvatarConnectingLoaderProps, q as AvatarEnvironment, r as AvatarError, s as AvatarErrorCode, t as AvatarErrorSource, u as AvatarEventMap, v as AvatarProvider, w as AvatarPublicProps, x as AvatarWidget, y as AvatarWidgetProps, B as BRIDGE_NAMESPACE, z as BRIDGE_VERSION, C as BridgeActionDeclaration, D as BridgeEnvelope, E as BridgeMessage, F as CaptionPosition, G as ConnectionHealth, H as HealthConcern, I as HealthService, J as HealthState, L as LoaderMessage, P as PaintPhase, R as RuntimeMessage, S as ScreenSharePosition, K as ScreenShareUiConfig, M as SessionPhase, N as StatusBannerConfig, O as StatusBannerPosition, T as ThinkingIndicatorConfig, Q as ThinkingIndicatorPosition, V as TourHighlight, W as TourSide, X as TourState, Y as TourStep, Z as TourTarget, _ as TranscriptConfig, $ as TranscriptEntry, a0 as TranscriptSpeaker, a1 as TranscriptWord, a2 as TurnPhase, a3 as UseAvatarActionFlowResult, a4 as UseAvatarWidgetResult, a5 as WIDGET_DEFAULTS, a6 as WidgetAppearance, a7 as WidgetBehaviour, a8 as WidgetBox, a9 as WidgetConfig, aa as WidgetContextPolicy, ab as WidgetDeploymentProjection, ac as WidgetLauncherStyle, ad as WidgetLimits, ae as WidgetMobileMode, af as WidgetOffset, ag as WidgetPanelSize, ah as WidgetPosition, ai as WidgetStage, aj as WidgetTeaser, ak as WidgetTour, al as buildEnvelope, am as parseBridgeMessage, an as postBridgeMessage, ao as resolveWidgetAppearance, ap as useAvatarAction, aq as useAvatarActionFlow, ar as useAvatarEvent, as as useAvatarWidget } from './AvatarProvider-Cll_r1hx.js';
1
+ import { U as UseAvatarResult } from './AvatarProvider-CItqTL0v.js';
2
+ export { A as ActionAwaiting, a as ActionCheckResult, b as ActionContext, c as ActionDefinition, d as ActionFlow, e as ActionFlowStage, f as ActionKind, g as ActionParam, h as ActionParamType, i as ActionResult, j as ActionUi, k as ActionUiOp, l as AppEventArgs, m as AppEventPolicy, n as Avatar, o as AvatarConnectingLoader, p as AvatarConnectingLoaderProps, q as AvatarEnvironment, r as AvatarError, s as AvatarErrorCode, t as AvatarErrorSource, u as AvatarEventMap, v as AvatarProvider, w as AvatarPublicProps, x as AvatarWidget, y as AvatarWidgetProps, B as BRIDGE_NAMESPACE, z as BRIDGE_VERSION, C as BridgeActionDeclaration, D as BridgeEnvelope, E as BridgeMessage, F as CaptionPosition, G as ConnectionHealth, H as HealthConcern, I as HealthService, J as HealthState, L as LoaderMessage, P as PaintPhase, R as RuntimeMessage, S as ScreenSharePosition, K as ScreenShareUiConfig, M as SessionPhase, N as StatusBannerConfig, O as StatusBannerPosition, T as ThinkingIndicatorConfig, Q as ThinkingIndicatorPosition, V as TourHighlight, W as TourSide, X as TourState, Y as TourStep, Z as TourTarget, _ as TranscriptConfig, $ as TranscriptEntry, a0 as TranscriptSpeaker, a1 as TranscriptWord, a2 as TurnPhase, a3 as UseAvatarActionFlowResult, a4 as UseAvatarWidgetResult, a5 as WIDGET_DEFAULTS, a6 as WidgetAppearance, a7 as WidgetBehaviour, a8 as WidgetBox, a9 as WidgetConfig, aa as WidgetContextPolicy, ab as WidgetDeploymentProjection, ac as WidgetLauncherStyle, ad as WidgetLimits, ae as WidgetMobileMode, af as WidgetOffset, ag as WidgetPanelSize, ah as WidgetPosition, ai as WidgetStage, aj as WidgetTeaser, ak as WidgetTour, al as buildEnvelope, am as parseBridgeMessage, an as postBridgeMessage, ao as resolveWidgetAppearance, ap as useAvatarAction, aq as useAvatarActionFlow, ar as useAvatarEvent, as as useAvatarWidget } from './AvatarProvider-CItqTL0v.js';
3
3
  import 'react/jsx-runtime';
4
4
  import './remotePageSurface-ao95kNYE.js';
5
5
 
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- 'use strict';var chunkYOMHPKHO_js=require('./chunk-YOMHPKHO.js'),chunkHRSHBEAW_js=require('./chunk-HRSHBEAW.js');Object.defineProperty(exports,"Avatar",{enumerable:true,get:function(){return chunkYOMHPKHO_js.r}});Object.defineProperty(exports,"AvatarConnectingLoader",{enumerable:true,get:function(){return chunkYOMHPKHO_js.j}});Object.defineProperty(exports,"AvatarProvider",{enumerable:true,get:function(){return chunkYOMHPKHO_js.f}});Object.defineProperty(exports,"AvatarWidget",{enumerable:true,get:function(){return chunkYOMHPKHO_js.s}});Object.defineProperty(exports,"BRIDGE_NAMESPACE",{enumerable:true,get:function(){return chunkYOMHPKHO_js.u}});Object.defineProperty(exports,"BRIDGE_VERSION",{enumerable:true,get:function(){return chunkYOMHPKHO_js.v}});Object.defineProperty(exports,"buildEnvelope",{enumerable:true,get:function(){return chunkYOMHPKHO_js.y}});Object.defineProperty(exports,"parseBridgeMessage",{enumerable:true,get:function(){return chunkYOMHPKHO_js.z}});Object.defineProperty(exports,"postBridgeMessage",{enumerable:true,get:function(){return chunkYOMHPKHO_js.A}});Object.defineProperty(exports,"useAvatar",{enumerable:true,get:function(){return chunkYOMHPKHO_js.E}});Object.defineProperty(exports,"useAvatarAction",{enumerable:true,get:function(){return chunkYOMHPKHO_js.C}});Object.defineProperty(exports,"useAvatarActionFlow",{enumerable:true,get:function(){return chunkYOMHPKHO_js.D}});Object.defineProperty(exports,"useAvatarEvent",{enumerable:true,get:function(){return chunkYOMHPKHO_js.B}});Object.defineProperty(exports,"useAvatarWidget",{enumerable:true,get:function(){return chunkYOMHPKHO_js.t}});Object.defineProperty(exports,"PaintPhase",{enumerable:true,get:function(){return chunkHRSHBEAW_js.v}});Object.defineProperty(exports,"SessionPhase",{enumerable:true,get:function(){return chunkHRSHBEAW_js.u}});Object.defineProperty(exports,"TurnPhase",{enumerable:true,get:function(){return chunkHRSHBEAW_js.w}});Object.defineProperty(exports,"WIDGET_DEFAULTS",{enumerable:true,get:function(){return chunkHRSHBEAW_js.B}});Object.defineProperty(exports,"resolveWidgetAppearance",{enumerable:true,get:function(){return chunkHRSHBEAW_js.C}});
1
+ 'use strict';var chunkFDZA3OHI_js=require('./chunk-FDZA3OHI.js'),chunk3SRQGZJ5_js=require('./chunk-3SRQGZJ5.js');Object.defineProperty(exports,"Avatar",{enumerable:true,get:function(){return chunkFDZA3OHI_js.r}});Object.defineProperty(exports,"AvatarConnectingLoader",{enumerable:true,get:function(){return chunkFDZA3OHI_js.j}});Object.defineProperty(exports,"AvatarProvider",{enumerable:true,get:function(){return chunkFDZA3OHI_js.f}});Object.defineProperty(exports,"AvatarWidget",{enumerable:true,get:function(){return chunkFDZA3OHI_js.s}});Object.defineProperty(exports,"BRIDGE_NAMESPACE",{enumerable:true,get:function(){return chunkFDZA3OHI_js.u}});Object.defineProperty(exports,"BRIDGE_VERSION",{enumerable:true,get:function(){return chunkFDZA3OHI_js.v}});Object.defineProperty(exports,"buildEnvelope",{enumerable:true,get:function(){return chunkFDZA3OHI_js.y}});Object.defineProperty(exports,"parseBridgeMessage",{enumerable:true,get:function(){return chunkFDZA3OHI_js.z}});Object.defineProperty(exports,"postBridgeMessage",{enumerable:true,get:function(){return chunkFDZA3OHI_js.A}});Object.defineProperty(exports,"useAvatar",{enumerable:true,get:function(){return chunkFDZA3OHI_js.E}});Object.defineProperty(exports,"useAvatarAction",{enumerable:true,get:function(){return chunkFDZA3OHI_js.C}});Object.defineProperty(exports,"useAvatarActionFlow",{enumerable:true,get:function(){return chunkFDZA3OHI_js.D}});Object.defineProperty(exports,"useAvatarEvent",{enumerable:true,get:function(){return chunkFDZA3OHI_js.B}});Object.defineProperty(exports,"useAvatarWidget",{enumerable:true,get:function(){return chunkFDZA3OHI_js.t}});Object.defineProperty(exports,"PaintPhase",{enumerable:true,get:function(){return chunk3SRQGZJ5_js.v}});Object.defineProperty(exports,"SessionPhase",{enumerable:true,get:function(){return chunk3SRQGZJ5_js.u}});Object.defineProperty(exports,"TurnPhase",{enumerable:true,get:function(){return chunk3SRQGZJ5_js.w}});Object.defineProperty(exports,"WIDGET_DEFAULTS",{enumerable:true,get:function(){return chunk3SRQGZJ5_js.B}});Object.defineProperty(exports,"resolveWidgetAppearance",{enumerable:true,get:function(){return chunk3SRQGZJ5_js.C}});
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- export{r as Avatar,j as AvatarConnectingLoader,f as AvatarProvider,s as AvatarWidget,u as BRIDGE_NAMESPACE,v as BRIDGE_VERSION,y as buildEnvelope,z as parseBridgeMessage,A as postBridgeMessage,E as useAvatar,C as useAvatarAction,D as useAvatarActionFlow,B as useAvatarEvent,t as useAvatarWidget}from'./chunk-OANDIUVQ.mjs';export{v as PaintPhase,u as SessionPhase,w as TurnPhase,B as WIDGET_DEFAULTS,C as resolveWidgetAppearance}from'./chunk-E7HVSIHB.mjs';
1
+ export{r as Avatar,j as AvatarConnectingLoader,f as AvatarProvider,s as AvatarWidget,u as BRIDGE_NAMESPACE,v as BRIDGE_VERSION,y as buildEnvelope,z as parseBridgeMessage,A as postBridgeMessage,E as useAvatar,C as useAvatarAction,D as useAvatarActionFlow,B as useAvatarEvent,t as useAvatarWidget}from'./chunk-6Q2I7WKW.mjs';export{v as PaintPhase,u as SessionPhase,w as TurnPhase,B as WIDGET_DEFAULTS,C as resolveWidgetAppearance}from'./chunk-WOQBPJGB.mjs';
package/dist/page.js CHANGED
@@ -1 +1 @@
1
- 'use strict';var chunkHRSHBEAW_js=require('./chunk-HRSHBEAW.js');function d(u){if(typeof window>"u"||!document.body)return ()=>{};let e=null,t=null,o=0,l=()=>{e=null,t=null,o=Date.now(),u();},n=s=>{let r=Date.now();t??(t=r),e&&clearTimeout(e);let S=Math.max(Math.min(r+s,t+4e3),o+1500);e=setTimeout(l,S-r);},a=()=>n(400),c=new MutationObserver(()=>n(800));return window.addEventListener("scroll",a,{capture:true,passive:true}),c.observe(document.body,{childList:true,subtree:true}),()=>{e&&clearTimeout(e),window.removeEventListener("scroll",a,{capture:true}),c.disconnect();}}Object.defineProperty(exports,"BROWSING_INDEX_PROFILE",{enumerable:true,get:function(){return chunkHRSHBEAW_js.W}});Object.defineProperty(exports,"createWebPageSurface",{enumerable:true,get:function(){return chunkHRSHBEAW_js.Z}});Object.defineProperty(exports,"servePageSurfaceCall",{enumerable:true,get:function(){return chunkHRSHBEAW_js.A}});Object.defineProperty(exports,"watchNavigationEvents",{enumerable:true,get:function(){return chunkHRSHBEAW_js.X}});exports.watchPageSettle=d;
1
+ 'use strict';var chunk3SRQGZJ5_js=require('./chunk-3SRQGZJ5.js');function d(u){if(typeof window>"u"||!document.body)return ()=>{};let e=null,t=null,o=0,l=()=>{e=null,t=null,o=Date.now(),u();},n=s=>{let r=Date.now();t??(t=r),e&&clearTimeout(e);let S=Math.max(Math.min(r+s,t+4e3),o+1500);e=setTimeout(l,S-r);},a=()=>n(400),c=new MutationObserver(()=>n(800));return window.addEventListener("scroll",a,{capture:true,passive:true}),c.observe(document.body,{childList:true,subtree:true}),()=>{e&&clearTimeout(e),window.removeEventListener("scroll",a,{capture:true}),c.disconnect();}}Object.defineProperty(exports,"BROWSING_INDEX_PROFILE",{enumerable:true,get:function(){return chunk3SRQGZJ5_js.W}});Object.defineProperty(exports,"createWebPageSurface",{enumerable:true,get:function(){return chunk3SRQGZJ5_js.Z}});Object.defineProperty(exports,"servePageSurfaceCall",{enumerable:true,get:function(){return chunk3SRQGZJ5_js.A}});Object.defineProperty(exports,"watchNavigationEvents",{enumerable:true,get:function(){return chunk3SRQGZJ5_js.X}});exports.watchPageSettle=d;
package/dist/page.mjs CHANGED
@@ -1 +1 @@
1
- export{W as BROWSING_INDEX_PROFILE,Z as createWebPageSurface,A as servePageSurfaceCall,X as watchNavigationEvents}from'./chunk-E7HVSIHB.mjs';function d(u){if(typeof window>"u"||!document.body)return ()=>{};let e=null,t=null,o=0,l=()=>{e=null,t=null,o=Date.now(),u();},n=s=>{let r=Date.now();t??(t=r),e&&clearTimeout(e);let S=Math.max(Math.min(r+s,t+4e3),o+1500);e=setTimeout(l,S-r);},a=()=>n(400),c=new MutationObserver(()=>n(800));return window.addEventListener("scroll",a,{capture:true,passive:true}),c.observe(document.body,{childList:true,subtree:true}),()=>{e&&clearTimeout(e),window.removeEventListener("scroll",a,{capture:true}),c.disconnect();}}export{d as watchPageSettle};
1
+ export{W as BROWSING_INDEX_PROFILE,Z as createWebPageSurface,A as servePageSurfaceCall,X as watchNavigationEvents}from'./chunk-WOQBPJGB.mjs';function d(u){if(typeof window>"u"||!document.body)return ()=>{};let e=null,t=null,o=0,l=()=>{e=null,t=null,o=Date.now(),u();},n=s=>{let r=Date.now();t??(t=r),e&&clearTimeout(e);let S=Math.max(Math.min(r+s,t+4e3),o+1500);e=setTimeout(l,S-r);},a=()=>n(400),c=new MutationObserver(()=>n(800));return window.addEventListener("scroll",a,{capture:true,passive:true}),c.observe(document.body,{childList:true,subtree:true}),()=>{e&&clearTimeout(e),window.removeEventListener("scroll",a,{capture:true}),c.disconnect();}}export{d as watchPageSettle};
@@ -1,6 +1,6 @@
1
1
  import { RefObject, ReactNode } from 'react';
2
- import { at as LipSyncConfig, au as LipSyncMotionConfig, av as UseAvatarResultWithPlayer, $ as TranscriptEntry, G as ConnectionHealth, d as ActionFlow, k as ActionUiOp, aw as BatchedTtsJob, ax as AvatarModeWithPlayer, ay as AvatarSurface, az as WidgetAction, aA as CommandOutcome, Y as TourStep, aB as AvatarConfigFromServer, S as ScreenSharePosition, F as CaptionPosition, O as StatusBannerPosition, Q as ThinkingIndicatorPosition, q as AvatarEnvironment, r as AvatarError, aC as AvatarConfigWithPlayer, aD as IBrowserHost, aE as PageHost, ab as WidgetDeploymentProjection, aF as AvatarHostProvider } from './AvatarProvider-BXaeG3PZ.mjs';
3
- export { A as ActionAwaiting, a as ActionCheckResult, b as ActionContext, c as ActionDefinition, e as ActionFlowStage, f as ActionKind, g as ActionParam, h as ActionParamType, i as ActionResult, j as ActionUi, l as AppEventArgs, m as AppEventPolicy, n as Avatar, o as AvatarConnectingLoader, p as AvatarConnectingLoaderProps, s as AvatarErrorCode, t as AvatarErrorSource, u as AvatarEventMap, w as AvatarPublicProps, aG as AvatarSpeech, x as AvatarWidget, y as AvatarWidgetProps, B as BRIDGE_NAMESPACE, z as BRIDGE_VERSION, C as BridgeActionDeclaration, D as BridgeEnvelope, E as BridgeMessage, aH as BrowserCommand, aI as BrowserOutcome, H as HealthConcern, I as HealthService, J as HealthState, L as LoaderMessage, P as PaintPhase, R as RuntimeMessage, K as ScreenShareUiConfig, M as SessionPhase, N as StatusBannerConfig, T as ThinkingIndicatorConfig, V as TourHighlight, W as TourSide, X as TourState, Z as TourTarget, _ as TranscriptConfig, a0 as TranscriptSpeaker, a1 as TranscriptWord, a2 as TurnPhase, a3 as UseAvatarActionFlowResult, U as UseAvatarResult, a4 as UseAvatarWidgetResult, a5 as WIDGET_DEFAULTS, a6 as WidgetAppearance, a7 as WidgetBehaviour, a8 as WidgetBox, a9 as WidgetConfig, aa as WidgetContextPolicy, ac as WidgetLauncherStyle, ad as WidgetLimits, ae as WidgetMobileMode, af as WidgetOffset, ag as WidgetPanelSize, ah as WidgetPosition, ai as WidgetStage, aj as WidgetTeaser, ak as WidgetTour, al as buildEnvelope, am as parseBridgeMessage, an as postBridgeMessage, ao as resolveWidgetAppearance, ap as useAvatarAction, aq as useAvatarActionFlow, ar as useAvatarEvent, as as useAvatarWidget } from './AvatarProvider-BXaeG3PZ.mjs';
2
+ import { at as LipSyncConfig, au as LipSyncMotionConfig, av as UseAvatarResultWithPlayer, $ as TranscriptEntry, G as ConnectionHealth, d as ActionFlow, k as ActionUiOp, aw as BatchedTtsJob, ax as AvatarModeWithPlayer, ay as AvatarSurface, az as WidgetAction, aA as CommandOutcome, Y as TourStep, aB as AvatarConfigFromServer, S as ScreenSharePosition, F as CaptionPosition, O as StatusBannerPosition, Q as ThinkingIndicatorPosition, q as AvatarEnvironment, r as AvatarError, aC as AvatarConfigWithPlayer, aD as IBrowserHost, aE as PageHost, ab as WidgetDeploymentProjection, aF as AvatarHostProvider } from './AvatarProvider-DqD003D2.mjs';
3
+ export { A as ActionAwaiting, a as ActionCheckResult, b as ActionContext, c as ActionDefinition, e as ActionFlowStage, f as ActionKind, g as ActionParam, h as ActionParamType, i as ActionResult, j as ActionUi, l as AppEventArgs, m as AppEventPolicy, n as Avatar, o as AvatarConnectingLoader, p as AvatarConnectingLoaderProps, s as AvatarErrorCode, t as AvatarErrorSource, u as AvatarEventMap, w as AvatarPublicProps, aG as AvatarSpeech, x as AvatarWidget, y as AvatarWidgetProps, B as BRIDGE_NAMESPACE, z as BRIDGE_VERSION, C as BridgeActionDeclaration, D as BridgeEnvelope, E as BridgeMessage, aH as BrowserCommand, aI as BrowserOutcome, H as HealthConcern, I as HealthService, J as HealthState, L as LoaderMessage, P as PaintPhase, R as RuntimeMessage, K as ScreenShareUiConfig, M as SessionPhase, N as StatusBannerConfig, T as ThinkingIndicatorConfig, V as TourHighlight, W as TourSide, X as TourState, Z as TourTarget, _ as TranscriptConfig, a0 as TranscriptSpeaker, a1 as TranscriptWord, a2 as TurnPhase, a3 as UseAvatarActionFlowResult, U as UseAvatarResult, a4 as UseAvatarWidgetResult, a5 as WIDGET_DEFAULTS, a6 as WidgetAppearance, a7 as WidgetBehaviour, a8 as WidgetBox, a9 as WidgetConfig, aa as WidgetContextPolicy, ac as WidgetLauncherStyle, ad as WidgetLimits, ae as WidgetMobileMode, af as WidgetOffset, ag as WidgetPanelSize, ah as WidgetPosition, ai as WidgetStage, aj as WidgetTeaser, ak as WidgetTour, al as buildEnvelope, am as parseBridgeMessage, an as postBridgeMessage, ao as resolveWidgetAppearance, ap as useAvatarAction, aq as useAvatarActionFlow, ar as useAvatarEvent, as as useAvatarWidget } from './AvatarProvider-DqD003D2.mjs';
4
4
  import { Rive } from '@rive-app/webgl2';
5
5
  import { P as PageSurfaceCall } from './remotePageSurface-ao95kNYE.mjs';
6
6
  export { I as IPageSurface, a as PageSurfaceTransport, b as PageUnreadable, c as createRemotePageSurface } from './remotePageSurface-ao95kNYE.mjs';
@@ -1,6 +1,6 @@
1
1
  import { RefObject, ReactNode } from 'react';
2
- import { at as LipSyncConfig, au as LipSyncMotionConfig, av as UseAvatarResultWithPlayer, $ as TranscriptEntry, G as ConnectionHealth, d as ActionFlow, k as ActionUiOp, aw as BatchedTtsJob, ax as AvatarModeWithPlayer, ay as AvatarSurface, az as WidgetAction, aA as CommandOutcome, Y as TourStep, aB as AvatarConfigFromServer, S as ScreenSharePosition, F as CaptionPosition, O as StatusBannerPosition, Q as ThinkingIndicatorPosition, q as AvatarEnvironment, r as AvatarError, aC as AvatarConfigWithPlayer, aD as IBrowserHost, aE as PageHost, ab as WidgetDeploymentProjection, aF as AvatarHostProvider } from './AvatarProvider-Cll_r1hx.js';
3
- export { A as ActionAwaiting, a as ActionCheckResult, b as ActionContext, c as ActionDefinition, e as ActionFlowStage, f as ActionKind, g as ActionParam, h as ActionParamType, i as ActionResult, j as ActionUi, l as AppEventArgs, m as AppEventPolicy, n as Avatar, o as AvatarConnectingLoader, p as AvatarConnectingLoaderProps, s as AvatarErrorCode, t as AvatarErrorSource, u as AvatarEventMap, w as AvatarPublicProps, aG as AvatarSpeech, x as AvatarWidget, y as AvatarWidgetProps, B as BRIDGE_NAMESPACE, z as BRIDGE_VERSION, C as BridgeActionDeclaration, D as BridgeEnvelope, E as BridgeMessage, aH as BrowserCommand, aI as BrowserOutcome, H as HealthConcern, I as HealthService, J as HealthState, L as LoaderMessage, P as PaintPhase, R as RuntimeMessage, K as ScreenShareUiConfig, M as SessionPhase, N as StatusBannerConfig, T as ThinkingIndicatorConfig, V as TourHighlight, W as TourSide, X as TourState, Z as TourTarget, _ as TranscriptConfig, a0 as TranscriptSpeaker, a1 as TranscriptWord, a2 as TurnPhase, a3 as UseAvatarActionFlowResult, U as UseAvatarResult, a4 as UseAvatarWidgetResult, a5 as WIDGET_DEFAULTS, a6 as WidgetAppearance, a7 as WidgetBehaviour, a8 as WidgetBox, a9 as WidgetConfig, aa as WidgetContextPolicy, ac as WidgetLauncherStyle, ad as WidgetLimits, ae as WidgetMobileMode, af as WidgetOffset, ag as WidgetPanelSize, ah as WidgetPosition, ai as WidgetStage, aj as WidgetTeaser, ak as WidgetTour, al as buildEnvelope, am as parseBridgeMessage, an as postBridgeMessage, ao as resolveWidgetAppearance, ap as useAvatarAction, aq as useAvatarActionFlow, ar as useAvatarEvent, as as useAvatarWidget } from './AvatarProvider-Cll_r1hx.js';
2
+ import { at as LipSyncConfig, au as LipSyncMotionConfig, av as UseAvatarResultWithPlayer, $ as TranscriptEntry, G as ConnectionHealth, d as ActionFlow, k as ActionUiOp, aw as BatchedTtsJob, ax as AvatarModeWithPlayer, ay as AvatarSurface, az as WidgetAction, aA as CommandOutcome, Y as TourStep, aB as AvatarConfigFromServer, S as ScreenSharePosition, F as CaptionPosition, O as StatusBannerPosition, Q as ThinkingIndicatorPosition, q as AvatarEnvironment, r as AvatarError, aC as AvatarConfigWithPlayer, aD as IBrowserHost, aE as PageHost, ab as WidgetDeploymentProjection, aF as AvatarHostProvider } from './AvatarProvider-CItqTL0v.js';
3
+ export { A as ActionAwaiting, a as ActionCheckResult, b as ActionContext, c as ActionDefinition, e as ActionFlowStage, f as ActionKind, g as ActionParam, h as ActionParamType, i as ActionResult, j as ActionUi, l as AppEventArgs, m as AppEventPolicy, n as Avatar, o as AvatarConnectingLoader, p as AvatarConnectingLoaderProps, s as AvatarErrorCode, t as AvatarErrorSource, u as AvatarEventMap, w as AvatarPublicProps, aG as AvatarSpeech, x as AvatarWidget, y as AvatarWidgetProps, B as BRIDGE_NAMESPACE, z as BRIDGE_VERSION, C as BridgeActionDeclaration, D as BridgeEnvelope, E as BridgeMessage, aH as BrowserCommand, aI as BrowserOutcome, H as HealthConcern, I as HealthService, J as HealthState, L as LoaderMessage, P as PaintPhase, R as RuntimeMessage, K as ScreenShareUiConfig, M as SessionPhase, N as StatusBannerConfig, T as ThinkingIndicatorConfig, V as TourHighlight, W as TourSide, X as TourState, Z as TourTarget, _ as TranscriptConfig, a0 as TranscriptSpeaker, a1 as TranscriptWord, a2 as TurnPhase, a3 as UseAvatarActionFlowResult, U as UseAvatarResult, a4 as UseAvatarWidgetResult, a5 as WIDGET_DEFAULTS, a6 as WidgetAppearance, a7 as WidgetBehaviour, a8 as WidgetBox, a9 as WidgetConfig, aa as WidgetContextPolicy, ac as WidgetLauncherStyle, ad as WidgetLimits, ae as WidgetMobileMode, af as WidgetOffset, ag as WidgetPanelSize, ah as WidgetPosition, ai as WidgetStage, aj as WidgetTeaser, ak as WidgetTour, al as buildEnvelope, am as parseBridgeMessage, an as postBridgeMessage, ao as resolveWidgetAppearance, ap as useAvatarAction, aq as useAvatarActionFlow, ar as useAvatarEvent, as as useAvatarWidget } from './AvatarProvider-CItqTL0v.js';
4
4
  import { Rive } from '@rive-app/webgl2';
5
5
  import { P as PageSurfaceCall } from './remotePageSurface-ao95kNYE.js';
6
6
  export { I as IPageSurface, a as PageSurfaceTransport, b as PageUnreadable, c as createRemotePageSurface } from './remotePageSurface-ao95kNYE.js';
package/dist/unstable.js CHANGED
@@ -1 +1 @@
1
- 'use strict';var chunkYOMHPKHO_js=require('./chunk-YOMHPKHO.js'),chunkHRSHBEAW_js=require('./chunk-HRSHBEAW.js'),react=require('react'),jsxRuntime=require('react/jsx-runtime');var Q=()=>performance.timeOrigin+performance.now();var $e=500,Ye="1",Z=class{constructor(e){this.deps=e;this.player=null;this.epoch=null;this.jobId=null;this.nextChunk=0;this.muted=false;this.job=null;this.refreshTimer=null;this.controls={pause:()=>this.player?.pause(),resume:()=>this.player?.resume(),getOutputLevel:()=>this.player?.getOutputLevel()??0,hasPendingAudio:()=>this.player?.hasPendingAudio()??false,reset:()=>this.reset()};}speak(e){e.sessionId!==this.epoch&&(this.dropPlayer(),this.epoch=e.sessionId,this.jobId=null),e.jobId!==this.jobId&&(this.jobId=e.jobId,this.nextChunk=0,this.job=null);let n={...e,audioChunks:e.audioChunks.map(i=>i?Ye:"")};this.job=ce(this.job,n),this.deps.emit({t:"speech",job:n});let r=this.player??this.makePlayer(),o=Math.max(0,this.nextChunk-e.chunkOffset);for(let i=o;i<e.audioChunks.length;i++){this.nextChunk=e.chunkOffset+i+1;let p=e.audioChunks[i];if(!p)continue;let k=e.alignments[i];k?r.enqueueChunk(p,k.character_start_times_seconds[0]??0):r.enqueueSequentialChunk(p);}}reset(){this.dropPlayer(),this.nextChunk=0,this.jobId=null,this.job=null,this.deps.emit({t:"speech.reset"});}resetSession(){this.reset(),this.epoch=null;}setMuted(e){this.muted=e,this.player?.setMuted(e);}anchor(){let e=this.player;return {epoch:this.epoch,alignmentSec:e?e.getAlignmentTime():chunkHRSHBEAW_js.e,playableSec:e?.getPlayableAlignmentTime()??0,at:Q(),paused:e?.isPaused()??false,scheduled:e?.isPlaybackScheduled()??false,active:e?.isAudioActive()??false,pending:e?.hasPendingAudio()??false}}snapshot(){return [...this.job?[{t:"speech",job:this.job}]:[],{t:"anchor",anchor:this.anchor()}]}destroy(){this.dropPlayer();}makePlayer(){let e=this.epoch,n=new chunkYOMHPKHO_js.i(()=>{this.deps.onEnded(),this.deps.emit({t:"speech.ended",epoch:e});},this.deps.getAudioContext());return n.setMuted(this.muted),n.onTimeline=()=>this.emitAnchor(),this.player=n,this.deps.publishClock(()=>n.isPlaybackScheduled()?n.getAlignmentTime():null),this.refreshTimer=setInterval(()=>{n.isPlaybackScheduled()&&this.emitAnchor();},$e),n}emitAnchor(){this.deps.emit({t:"anchor",anchor:this.anchor()});}dropPlayer(){this.refreshTimer&&clearInterval(this.refreshTimer),this.refreshTimer=null;let e=this.player;e&&(this.player=null,e.onTimeline=void 0,e.destroy(),this.deps.publishClock(null));}},ce=(t,e)=>{if(!t)return {...e};let n={...t,audioChunks:[...t.audioChunks],alignments:[...t.alignments],...t.displayAlignments&&{displayAlignments:[...t.displayAlignments]},...(t.visemes||e.visemes)&&{visemes:[...t.visemes??t.alignments.map(()=>null)]}};return e.audioChunks.forEach((r,o)=>{e.chunkOffset+o===t.chunkOffset+n.audioChunks.length&&(n.audioChunks.push(r),n.alignments.push(e.alignments[o]??null),n.displayAlignments?.push(e.displayAlignments?.[o]??null),n.visemes?.push(e.visemes?.[o]??null));}),n};var le=class{constructor(e,n){this.link=e;this.visible=new Map;this.front=null;this.nextCallId=0;this.pending=new Map;this.pageListeners=new Set;this.pageHost={browser:n,surface:chunkHRSHBEAW_js.z(r=>this.callFront(r)),watch:r=>(this.pageListeners.add(r),()=>this.pageListeners.delete(r)),pageBeforeLive:true};}handle(e,n){switch(n.t){case "visible":return n.visible?this.visible.set(e,Date.now()):this.visible.delete(e),this.pickFront(n.visible?e:null),true;case "page.reply":{let r=this.pending.get(n.id);return !r||r.viewId!==e||(this.pending.delete(n.id),n.ok?r.resolve(n.value):r.reject(new Error(n.error??"the page call failed"))),true}case "page.changed":return e===this.front&&this.pageChanged(),true;default:return false}}leave(e){this.visible.delete(e);for(let[n,r]of this.pending)r.viewId===e&&(this.pending.delete(n),r.reject(new Error("the page closed")));this.front===e&&this.pickFront(null);}pickFront(e){let n=e;if(!n||!this.visible.has(n)){n=null;let r=-1;for(let[o,i]of this.visible)i>r&&([n,r]=[o,i]);}n!==this.front&&(this.front=n,chunkHRSHBEAW_js.b.debug("EngineHost","front view changed",{front:n}),this.pageChanged());}pageChanged(){for(let e of this.pageListeners)e();}callFront(e){let n=this.front;if(!n)return Promise.reject(new Error("no page is in front"));let r=++this.nextCallId;return new Promise((o,i)=>{this.pending.set(r,{resolve:o,reject:i,viewId:n}),this.link.send(n,{t:"page.call",id:r,call:e});})}},Qe=t=>{let{error:e}=t;return {isReady:t.isReady,isLoading:t.isLoading,isConnecting:t.isConnecting,isSpeaking:t.isSpeaking,isListening:t.isListening,isThinking:t.isThinking,isResponseSlow:t.isResponseSlow,isIdle:t.isIdle,isFailed:t.isFailed,isConnected:t.isConnected,isMicMuted:t.isMicMuted,isSpeakerMuted:t.isSpeakerMuted,isPushToTalk:t.isPushToTalk,isTalking:t.isTalking,availableActions:t.availableActions,notice:t.notice,avatarId:t.avatarId,mode:t.mode,error:e?{code:e.code,message:e.message,source:e.source,fatal:e.fatal,retryable:e.retryable}:null,resetToken:t._resetToken,riveKey:t._riveKey,avatarConfig:t._avatarConfig,shouldArmTalking:t._shouldArmTalking,userActivity:t._userActivity,thinkingSignal:t._thinkingSignal,visualState:t._visualState,tuning:{...t._lipSyncTuning}}};function Ze({link:t,views:e}){let n=chunkYOMHPKHO_js.g(),r=react.useRef(n);r.current=n;let o=react.useMemo(()=>new Z({getAudioContext:()=>r.current._getAudioContext(),onEnded:()=>r.current._onPlaybackEnd(),publishClock:s=>r.current._registerSpeechClock(s),emit:s=>t.broadcast(s)}),[t]);react.useEffect(()=>()=>o.destroy(),[o]),react.useEffect(()=>{r.current._registerPlaybackControls(o.controls);let s=r.current._onSpeechJob(d=>o.speak(d));return ()=>{s(),r.current._registerPlaybackControls(null);}},[o]);let i=react.useRef(n._resetToken);react.useEffect(()=>{n._resetToken!==i.current&&(i.current=n._resetToken,o.resetSession());},[n._resetToken,o]),react.useEffect(()=>o.setMuted(n._speakerMuted),[n._speakerMuted,o]),react.useEffect(()=>{n._avatarConfig&&r.current._onRiveReady?.();},[n._avatarConfig,n._riveKey]);let p=Qe(n),k=JSON.stringify(p),T=react.useRef(p);return T.current=p,react.useEffect(()=>{t.broadcast({t:"state",state:T.current});},[t,k]),react.useEffect(()=>n._transcriptStore.subscribe(()=>t.broadcast({t:"transcript",entries:r.current._transcriptStore.getSnapshot().slice(-200)})),[n._transcriptStore,t]),react.useEffect(()=>n._healthStore.subscribe(()=>t.broadcast({t:"health",health:r.current._healthStore.getSnapshot()})),[n._healthStore,t]),react.useEffect(()=>{let s=r.current._gestureQueue.current;s.length!==0&&t.broadcast({t:"gestures",gestures:s.splice(0,s.length)});},[n._gestureSignal,t]),react.useEffect(()=>t.onMessage((s,d)=>{if(e.handle(s,d))return;let h=r.current;switch(d.t){case "join":{let a=[{t:"state",state:T.current},{t:"transcript",entries:h._transcriptStore.getSnapshot().slice(-200)},{t:"health",health:h._healthStore.getSnapshot()},...o.snapshot()];for(let m of a)t.send(s,m);return}case "cmd":d.cmd==="start"?h.start():d.cmd==="stop"?h.stop():d.cmd==="interrupt"?h.interrupt():d.cmd==="stopSpeaking"?h.stopSpeaking():d.cmd==="startTalking"?h.startTalking():d.cmd==="stopTalking"?h.stopTalking():d.cmd==="skipNextGreeting"&&h._skipNextGreeting();return;case "mic":h.setMicMuted(d.muted);return;case "speaker":h.setSpeakerMuted(d.muted);return;case "trigger":h.triggerAction?.(d.name);return;case "avatarClick":h._avatarClicked?.();return;case "surface":h._setMountSurface(d.surface);return;case "rive.ready":return}}),[t,e,o]),react.useEffect(()=>t.onLeave(s=>e.leave(s)),[t,e]),null}function et({config:t,link:e,browser:n}){let r=react.useRef(n),o=react.useMemo(()=>new le(e,r.current),[e]);return jsxRuntime.jsx(chunkYOMHPKHO_js.e,{config:t,pageHost:o.pageHost,children:jsxRuntime.jsx(Ze,{link:e,views:o})})}var te=class{constructor(){this.anchor=null;this.epoch=null;this.players=new Set;this.createPlayer=e=>{let n=new pe(this,e,()=>this.players.delete(n));return this.players.add(n),n};}setEpoch(e){this.epoch=e;}setAnchor(e){this.anchor=e;}ended(e){if(!(e!==null&&e!==this.epoch))for(let n of [...this.players])n.end();}current(){let e=this.anchor;return e&&e.epoch===this.epoch?e:null}},pe=class{constructor(e,n,r){this.speech=e;this.onEnded=n;this.release=r;}enqueueChunk(){}enqueueSequentialChunk(){}pause(){}resume(){}setMuted(){}playBeep(){}getAlignmentTime(){let e=this.speech.current();return !e||e.alignmentSec===chunkHRSHBEAW_js.e?chunkHRSHBEAW_js.e:e.paused?e.alignmentSec:e.alignmentSec+(Q()-e.at)/1e3}getPlayableAlignmentTime(){return this.speech.current()?.playableSec??0}isPlaybackScheduled(){return this.speech.current()?.scheduled??false}isAudioActive(){return this.speech.current()?.active??false}hasPendingAudio(){return this.speech.current()?.pending??false}getOutputLevel(){return 0}end(){this.onEnded();}destroy(){this.release();}};var nt={services:{ingest:"ok",stt:"ok",llm:"ok",tts:"ok",downlink:"ok"},concern:null},b=()=>{},rt=(t,e,n)=>{let[r,o]=react.useState(null),[i,p]=react.useState(null),[k,T]=react.useState(0),s=react.useMemo(()=>new te,[]),d=react.useMemo(()=>new chunkHRSHBEAW_js.p,[]),h=react.useMemo(()=>new chunkYOMHPKHO_js.b,[]),a=react.useMemo(()=>chunkHRSHBEAW_js.N([]),[]),m=react.useMemo(()=>chunkHRSHBEAW_js.N(nt),[]),u=react.useMemo(()=>chunkHRSHBEAW_js.N(null),[]),f=react.useRef([]),P=react.useRef(null),V=react.useRef(null),M=react.useRef(n);react.useEffect(()=>{let c=e.onMessage(w=>{switch(w.t){case "state":Object.assign(d,w.state.tuning),o(w.state);return;case "speech":s.setEpoch(w.job.sessionId),p(C=>C&&C.sessionId===w.job.sessionId&&C.jobId===w.job.jobId?ce(C,w.job):{...w.job});return;case "anchor":s.setAnchor(w.anchor);return;case "speech.ended":s.ended(w.epoch);return;case "speech.reset":P.current?.reset(),p(null);return;case "gestures":f.current.push(...w.gestures),T(C=>C+1);return;case "transcript":a.set(w.entries);return;case "health":m.set(w.health);return;case "page.call":{let C=M.current?.surface,{id:I,call:oe}=w;if(!C){e.send({t:"page.reply",id:I,ok:false,error:"no page here"});return}Promise.resolve().then(()=>chunkHRSHBEAW_js.A(C,oe)).then(y=>e.send({t:"page.reply",id:I,ok:true,value:y}),y=>e.send({t:"page.reply",id:I,ok:false,error:String(y)}));return}}});return e.send({t:"join",protocol:1}),c},[e,s,d,a,m]),react.useEffect(()=>{let c=()=>e.send({t:"visible",visible:document.visibilityState==="visible"});return c(),document.addEventListener("visibilitychange",c),()=>document.removeEventListener("visibilitychange",c)},[e]),react.useEffect(()=>M.current?.watch(()=>e.send({t:"page.changed"})),[e]);let x=react.useCallback(c=>e.send({t:"cmd",cmd:c}),[e]),N=t.transcript;return {isReady:r?.isReady??false,isLoading:r?.isLoading??true,isConnecting:r?.isConnecting??false,isSpeaking:r?.isSpeaking??false,isListening:r?.isListening??false,isThinking:r?.isThinking??false,isResponseSlow:r?.isResponseSlow??false,isIdle:r?.isIdle??true,isFailed:r?.isFailed??false,isConnected:r?.isConnected??false,isMicMuted:r?.isMicMuted??false,isSpeakerMuted:r?.isSpeakerMuted??false,isPushToTalk:r?.isPushToTalk??false,isTalking:r?.isTalking??false,availableActions:r?.availableActions??[],notice:r?.notice??null,avatarId:r?.avatarId??t.avatar?.avatarId,error:r?.error??null,controls:{enabled:t.controls?.enabled||false,stopSpeaking:t.controls?.stopSpeaking||false},mode:t.mode||"call",setMicMuted:c=>e.send({t:"mic",muted:c}),setSpeakerMuted:c=>e.send({t:"speaker",muted:c}),isMoodDetectionAvailable:false,isMoodDetectionOn:false,setMoodDetection:b,startTalking:()=>x("startTalking"),stopTalking:()=>x("stopTalking"),start:async()=>x("start"),stop:()=>x("stop"),interrupt:()=>x("interrupt"),stopSpeaking:()=>x("stopSpeaking"),triggerAction:c=>e.send({t:"trigger",name:c}),on:b,off:b,speakText:b,speakAudio:b,play:b,addLiveContext:b,notify:b,readPage:async()=>null,registerAction:()=>b,setLipSyncTuning:b,_healthStore:m,_transcriptStore:a,_actionFlowStore:u,_sendActionUi:()=>false,_currentJob:i,_onPlaybackEnd:b,_onRiveReady:()=>e.send({t:"rive.ready"}),_onRiveError:c=>chunkHRSHBEAW_js.b.warn("RemoteAvatar","rig failed to load",{error:String(c)}),_resetToken:r?.resetToken??0,_mode:t.mode||"call",_setMountSurface:c=>e.send({t:"surface",surface:c}),_onWidgetCommand:()=>b,_reportWidgetStatus:b,_onSpeechJob:()=>b,_requestTour:async()=>null,_skipNextGreeting:()=>x("skipNextGreeting"),_riveKey:r?.riveKey??"",_avatarConfig:r?.avatarConfig??null,_shouldArmTalking:r?.shouldArmTalking??false,_userActivity:r?.userActivity??0,_thinkingSignal:r?.thinkingSignal??0,_speakerMuted:r?.isSpeakerMuted??false,_gestureQueue:f,_gestureSignal:k,_avatarClicked:()=>e.send({t:"avatarClick"}),_lipSyncTuning:d,_rigActivity:h,_visualState:r?.visualState??"normal",_camera:ot,_screen:st,_screenSharePosition:t.screenShare?.position??"top-center",_captionsEnabled:!!N?.enabled&&N.captions!==false,_captionPosition:N?.position??"bottom-center",_statusBannerEnabled:t.statusBanner?.enabled!==false,_statusBannerPosition:t.statusBanner?.position??"bottom-left",_thinkingIndicatorEnabled:t.thinkingIndicator?.enabled!==false,_thinkingIndicatorPosition:t.thinkingIndicator?.position??"top-left",_speechClockRef:V,_registerSpeechClock:c=>{V.current=c;},_registerPlaybackControls:c=>{P.current=c;},_getAudioContext:()=>null,_createSpeechPlayer:s.createPlayer,_spacebarToTalk:t.turnTaking?.spacebar!==false}},ot={stream:null,facing:"user",sessionOpen:false,toggleVideo:b,flip:b,mood:null},st={phase:"idle",share:b,dismiss:b,stop:b};function it({config:t,link:e,pageHost:n,children:r}){let o=rt(t,e,n);return jsxRuntime.jsx(chunkYOMHPKHO_js.d.Provider,{value:o,children:jsxRuntime.jsx(chunkYOMHPKHO_js.c,{children:r})})}var at=2600,ct=t=>!!t&&typeof t=="object"&&["left","top","width","height"].every(e=>Number.isFinite(t[e])),Oe=(t,e)=>{let n=new Map,r=new Map,o=new Set,i=0,p=a=>{window.parent!==window&&chunkYOMHPKHO_js.A(window.parent,t,e,a);},k=a=>{let m=chunkYOMHPKHO_js.z(a,{origin:t,deployId:e,direction:"from-loader",source:window.parent});if(m)switch(m.type){case "page.result":{let{callId:u,ok:f,value:P,error:V}=m.payload,M=n.get(u);n.delete(u),f?M?.resolve(P):M?.reject(new Error(V??"the page refused"));return}case "page.changed":o.forEach(u=>u());return;case "tour.result":{let{seq:u,found:f,rect:P}=m.payload;r.get(u)?.({found:f===true,rect:ct(P)?P:void 0}),r.delete(u);return}}};window.addEventListener("message",k);let T={surface:chunkHRSHBEAW_js.z(a=>new Promise((m,u)=>{let f=`p${++i}`;n.set(f,{resolve:m,reject:u}),setTimeout(()=>n.delete(f),chunkHRSHBEAW_js.y),p({type:"page.call",payload:{callId:f,call:a}});})),watch:a=>(o.add(a),()=>o.delete(a)),pageBeforeLive:true},s=a=>new Promise(m=>{let u=++i,f=setTimeout(()=>{r.delete(u),m({found:false});},at);r.set(u,P=>{clearTimeout(f),m(P);}),p({type:"tour.do",payload:{seq:u,...a}});});return {pageHost:T,tourPage:(a,m)=>({seenKey:a,scroll:async u=>(await s({op:"scroll",target:u})).rect??null,mark:async(u,f)=>(await s({op:"mark",target:u,strong:f,color:m})).found,clear:()=>{s({op:"clear"});},scrollTop:()=>{s({op:"top"});}}),dispose:()=>window.removeEventListener("message",k)}};var lt=new Set(["bottom-right","bottom-left","top-right","top-left"]),pt=new Set(["sheet","corner"]),Be={min:0,max:200},ut={min:40,max:160},dt={min:280,max:640},gt={min:360,max:900},ht=/^(#[0-9a-f]{3,8}|rgba?\(\s*[\d.]+%?\s*,\s*[\d.]+%?\s*,\s*[\d.]+%?\s*(,\s*[\d.]+%?\s*)?\))$/i,z=(t,e)=>typeof t=="number"&&Number.isFinite(t)?Math.min(e.max,Math.max(e.min,Math.round(t))):void 0,mt=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),Ve=t=>{let e=t&&typeof t=="object"?t:{},n=e.appearance&&typeof e.appearance=="object"?e.appearance:{},r=n.offset,o=n.panel,i=z(r?.x,Be),p=z(r?.y,Be),k=z(o?.w,dt),T=z(o?.h,gt),s=e.tour;return {layout:e.layout==="inline"?"inline":"widget",appearance:mt({position:typeof n.position=="string"&&lt.has(n.position)?n.position:void 0,offset:i!==void 0&&p!==void 0?{x:i,y:p}:void 0,bubbleSize:z(n.bubbleSize,ut),panel:k!==void 0&&T!==void 0?{w:k,h:T}:void 0,accent:typeof n.accent=="string"&&ht.test(n.accent.trim())?n.accent.trim():void 0,draggable:typeof n.draggable=="boolean"?n.draggable:void 0,mobile:typeof n.mobile=="string"&&pt.has(n.mobile)?n.mobile:void 0}),tour:s&&typeof s=="object"?{once:s.once==="session"?"session":"visitor"}:void 0,pageAccess:e.pageAccess===true}};var vt=()=>new URLSearchParams(window.location.search).get("page")==="1",bt=()=>{let t=new URLSearchParams(window.location.hash.slice(1)),e=t.get(chunkYOMHPKHO_js.x);if(e)return window.history.replaceState(null,"",window.location.pathname+window.location.search),{token:e,led:t.get("led")==="1"}},St=({projection:t,hostOrigin:e})=>{let{behaviour:n}=t,[r]=react.useState(()=>Oe(e,t.deployId));react.useEffect(()=>r.dispose,[r]);let[o]=react.useState(()=>vt()?r.pageHost:void 0),[i]=react.useState(()=>({kept:bt(),onState:k=>chunkYOMHPKHO_js.A(window.parent,e,t.deployId,{type:"event",payload:{name:chunkYOMHPKHO_js.w,detail:{token:k}}})})),p=react.useMemo(()=>({deployId:t.deployId,mode:t.mode,avatar:{avatarId:t.avatarId,greeting:n?.greeting},connectTone:n?.connectTone,transcript:n?.transcript}),[t.deployId,t.mode,t.avatarId,n]);return At(),jsxRuntime.jsx(chunkYOMHPKHO_js.e,{config:p,embedHostOrigin:e,pageHost:o,embedResume:i,children:jsxRuntime.jsx(kt,{projection:t,hostOrigin:e,channel:r,carriesOn:!!i.kept})})},kt=({projection:t,hostOrigin:e,channel:n,carriesOn:r})=>{let o=chunkYOMHPKHO_js.h(),{_sendActionUi:i}=chunkYOMHPKHO_js.g(),p=chunkYOMHPKHO_js.t(),{flow:k}=chunkYOMHPKHO_js.D(),[T,s]=react.useState(null),[d,h]=react.useState(0),[a,m]=react.useState(null),u=react.useRef(new Map),f=react.useRef(new Map),P=react.useRef([]),V=react.useRef(0),{deployId:M,configVersion:x,mode:N}=t,c=react.useMemo(()=>({...t.appearance,...a?.config.appearance}),[t.appearance,a]),w=react.useMemo(()=>chunkHRSHBEAW_js.C(c),[c]),C=react.useMemo(()=>chunkHRSHBEAW_js.C(t.appearance).position,[t.appearance]),I=react.useMemo(()=>a?.config.tour?{...t.tour,generate:true,once:a.config.tour.once}:t.tour,[t.tour,a]),oe=react.useMemo(()=>a&&I?n.tourPage(`af-tour:site:${e}`,I.highlightColor):void 0,[n,a,I]),y=react.useCallback(l=>{window.parent!==window&&chunkYOMHPKHO_js.A(window.parent,e,M,l);},[e,M]),se=d>=2,Ne=react.useMemo(()=>se?{...c,draggable:c.draggable??true,teaser:void 0}:{...c,offset:{x:0,y:0},draggable:false,teaser:void 0},[c,se]),ge=react.useCallback(l=>{P.current.forEach(R=>R()),P.current=l.flatMap(R=>{let v=Object.values(R.params??{}).some(A=>A.check),E=o.registerAction?.({...R,handler:(A,{callId:g,signal:S})=>new Promise(O=>{u.current.set(g,O),S.addEventListener("abort",()=>u.current.delete(g)),y({type:"action.run",payload:{callId:g,name:R.name,args:A}});}),...v&&{check:(A,g,S)=>new Promise(O=>{let q=`check-${++V.current}`;f.current.set(q,O),setTimeout(()=>f.current.delete(q),chunkHRSHBEAW_js.s),y({type:"action.check",payload:{checkId:q,name:R.name,param:A,value:g,args:S}});})}});return E?[E]:[]});},[o,y]);react.useEffect(()=>{let l=R=>{let v=chunkYOMHPKHO_js.z(R,{origin:e,deployId:M,direction:"from-loader",source:window.parent});if(v)switch(v.type){case "host.info":{let{w:E,h:A}=v.payload.viewport;s(S=>S&&S.w===E&&S.h===A?S:{w:E,h:A}),h(v.payload.frameLayout??0);let g={config:Ve(v.payload.config)};m(S=>S&&JSON.stringify(S)===JSON.stringify(g)?S:g);return}case "context.set":o.addLiveContext?.({context:v.payload.context});return;case "context.event":o.addLiveContext?.({context:`${v.payload.name}: ${v.payload.context}`,update:true});return;case "cmd.open":p.open();return;case "cmd.close":p.close();return;case "cmd.start":o.start?.();return;case "cmd.stop":case "cmd.destroy":o.stop?.();return;case "action.set":ge(v.payload.actions);return;case "action.result":{let{callId:E,ok:A,result:g,error:S}=v.payload,O=u.current.get(E);u.current.delete(E),O?.(A?{ok:true,result:g}:{ok:false,error:S??"failed"});return}case "action.check_result":{let{checkId:E,ok:A,reason:g,suggestions:S,param:O,value:q}=v.payload,Ue=f.current.get(E);f.current.delete(E),Ue?.(A?{ok:true,value:q}:{ok:false,reason:g,suggestions:S,param:O});return}case "action.ui":i(v.payload.op,v.payload.args,v.payload.name);return}};return window.addEventListener("message",l),()=>window.removeEventListener("message",l)},[e,M,o,p,ge,i]),react.useEffect(()=>()=>P.current.forEach(l=>l()),[]),react.useEffect(()=>{y({type:"ready",payload:{configVersion:x,mode:N,position:C}});},[y,x,N,C]),react.useEffect(()=>{let l=(g,S)=>y({type:"event",payload:{name:g,detail:S}}),R=()=>l("start"),v=()=>l("stop"),E=g=>l("notice",{kind:g.kind,action:g.action}),A=g=>l("error",{code:g.code,fatal:g.fatal,cause:chunkHRSHBEAW_js.t(g)});return o.on?.("start",R),o.on?.("stop",v),o.on?.("notice",E),o.on?.("error",A),()=>{o.off?.("start",R),o.off?.("stop",v),o.off?.("notice",E),o.off?.("error",A);}},[o.on,o.off,y]);let he=react.useRef(false);react.useEffect(()=>{!r||he.current||(he.current=true,p.open(),o.start?.());},[r,p,o]),react.useEffect(()=>{y({type:"event",payload:{name:"speaking",detail:{speaking:o.isSpeaking}}});},[o.isSpeaking,y]),react.useEffect(()=>{y({type:"action.flow",payload:{flow:k}});},[k,y]);let We=react.useCallback(l=>y({type:"resize",payload:{w:l.w,h:l.h,position:l.position,sheet:l.sheet,offset:w.offset,left:l.left,top:l.top,gutter:l.gutter}}),[y,w.offset]),me=react.useRef(null),Fe=react.useCallback(l=>{l!==me.current&&(me.current=l,y({type:"state",payload:{stage:l}}));},[y]);return !T||!a?null:a.config.layout==="inline"?jsxRuntime.jsx(wt,{}):jsxRuntime.jsx(chunkYOMHPKHO_js.s,{appearance:Ne,hostViewport:T,framed:se,tour:I,tourPage:oe,onResize:We,onStageChange:Fe})},wt=()=>(chunkYOMHPKHO_js.g()._setMountSurface("inline"),jsxRuntime.jsx("div",{style:{width:"100vw",height:"100vh"},children:jsxRuntime.jsx(chunkYOMHPKHO_js.r,{style:{width:"100%",height:"100%"}})})),At=()=>{react.useEffect(()=>{for(let t of [document.documentElement,document.body])Object.assign(t.style,{background:"transparent",margin:"0",overflow:"hidden",colorScheme:"normal",fontFamily:"system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif"});},[]);};var En=chunkYOMHPKHO_js.e,Tn=()=>chunkYOMHPKHO_js.g()._skipNextGreeting,Pn=()=>chunkYOMHPKHO_js.g()._rigActivity.subscribe;Object.defineProperty(exports,"Avatar",{enumerable:true,get:function(){return chunkYOMHPKHO_js.r}});Object.defineProperty(exports,"AvatarConnectingLoader",{enumerable:true,get:function(){return chunkYOMHPKHO_js.j}});Object.defineProperty(exports,"AvatarWidget",{enumerable:true,get:function(){return chunkYOMHPKHO_js.s}});Object.defineProperty(exports,"BRIDGE_NAMESPACE",{enumerable:true,get:function(){return chunkYOMHPKHO_js.u}});Object.defineProperty(exports,"BRIDGE_VERSION",{enumerable:true,get:function(){return chunkYOMHPKHO_js.v}});Object.defineProperty(exports,"buildEnvelope",{enumerable:true,get:function(){return chunkYOMHPKHO_js.y}});Object.defineProperty(exports,"getRiveRendererStatus",{enumerable:true,get:function(){return chunkYOMHPKHO_js.l}});Object.defineProperty(exports,"onRiveRendererEvent",{enumerable:true,get:function(){return chunkYOMHPKHO_js.m}});Object.defineProperty(exports,"parseBridgeMessage",{enumerable:true,get:function(){return chunkYOMHPKHO_js.z}});Object.defineProperty(exports,"postBridgeMessage",{enumerable:true,get:function(){return chunkYOMHPKHO_js.A}});Object.defineProperty(exports,"setScriptUrls",{enumerable:true,get:function(){return chunkYOMHPKHO_js.a}});Object.defineProperty(exports,"simulateRiveContextLoss",{enumerable:true,get:function(){return chunkYOMHPKHO_js.n}});Object.defineProperty(exports,"useAvatar",{enumerable:true,get:function(){return chunkYOMHPKHO_js.h}});Object.defineProperty(exports,"useAvatarAction",{enumerable:true,get:function(){return chunkYOMHPKHO_js.C}});Object.defineProperty(exports,"useAvatarActionFlow",{enumerable:true,get:function(){return chunkYOMHPKHO_js.D}});Object.defineProperty(exports,"useAvatarEvent",{enumerable:true,get:function(){return chunkYOMHPKHO_js.B}});Object.defineProperty(exports,"useAvatarWidget",{enumerable:true,get:function(){return chunkYOMHPKHO_js.t}});Object.defineProperty(exports,"useRiveFrameHold",{enumerable:true,get:function(){return chunkYOMHPKHO_js.q}});Object.defineProperty(exports,"useRiveRenderGeneration",{enumerable:true,get:function(){return chunkYOMHPKHO_js.o}});Object.defineProperty(exports,"useRiveRendererStatus",{enumerable:true,get:function(){return chunkYOMHPKHO_js.p}});Object.defineProperty(exports,"watchRiveRenderer",{enumerable:true,get:function(){return chunkYOMHPKHO_js.k}});Object.defineProperty(exports,"PaintPhase",{enumerable:true,get:function(){return chunkHRSHBEAW_js.v}});Object.defineProperty(exports,"SessionPhase",{enumerable:true,get:function(){return chunkHRSHBEAW_js.u}});Object.defineProperty(exports,"TurnPhase",{enumerable:true,get:function(){return chunkHRSHBEAW_js.w}});Object.defineProperty(exports,"WIDGET_DEFAULTS",{enumerable:true,get:function(){return chunkHRSHBEAW_js.B}});Object.defineProperty(exports,"createRemotePageSurface",{enumerable:true,get:function(){return chunkHRSHBEAW_js.z}});Object.defineProperty(exports,"resolveWidgetAppearance",{enumerable:true,get:function(){return chunkHRSHBEAW_js.C}});exports.AvatarEngineHost=et;exports.AvatarProvider=En;exports.EmbedRuntime=St;exports.RemoteAvatarProvider=it;exports.useRigActivity=Pn;exports.useSkipNextGreeting=Tn;
1
+ 'use strict';var chunkFDZA3OHI_js=require('./chunk-FDZA3OHI.js'),chunk3SRQGZJ5_js=require('./chunk-3SRQGZJ5.js'),react=require('react'),jsxRuntime=require('react/jsx-runtime');var Q=()=>performance.timeOrigin+performance.now();var $e=500,Ye="1",Z=class{constructor(e){this.deps=e;this.player=null;this.epoch=null;this.jobId=null;this.nextChunk=0;this.muted=false;this.job=null;this.refreshTimer=null;this.controls={pause:()=>this.player?.pause(),resume:()=>this.player?.resume(),getOutputLevel:()=>this.player?.getOutputLevel()??0,hasPendingAudio:()=>this.player?.hasPendingAudio()??false,reset:()=>this.reset()};}speak(e){e.sessionId!==this.epoch&&(this.dropPlayer(),this.epoch=e.sessionId,this.jobId=null),e.jobId!==this.jobId&&(this.jobId=e.jobId,this.nextChunk=0,this.job=null);let n={...e,audioChunks:e.audioChunks.map(i=>i?Ye:"")};this.job=ce(this.job,n),this.deps.emit({t:"speech",job:n});let r=this.player??this.makePlayer(),o=Math.max(0,this.nextChunk-e.chunkOffset);for(let i=o;i<e.audioChunks.length;i++){this.nextChunk=e.chunkOffset+i+1;let p=e.audioChunks[i];if(!p)continue;let k=e.alignments[i];k?r.enqueueChunk(p,k.character_start_times_seconds[0]??0):r.enqueueSequentialChunk(p);}}reset(){this.dropPlayer(),this.nextChunk=0,this.jobId=null,this.job=null,this.deps.emit({t:"speech.reset"});}resetSession(){this.reset(),this.epoch=null;}setMuted(e){this.muted=e,this.player?.setMuted(e);}anchor(){let e=this.player;return {epoch:this.epoch,alignmentSec:e?e.getAlignmentTime():chunk3SRQGZJ5_js.e,playableSec:e?.getPlayableAlignmentTime()??0,at:Q(),paused:e?.isPaused()??false,scheduled:e?.isPlaybackScheduled()??false,active:e?.isAudioActive()??false,pending:e?.hasPendingAudio()??false}}snapshot(){return [...this.job?[{t:"speech",job:this.job}]:[],{t:"anchor",anchor:this.anchor()}]}destroy(){this.dropPlayer();}makePlayer(){let e=this.epoch,n=new chunkFDZA3OHI_js.i(()=>{this.deps.onEnded(),this.deps.emit({t:"speech.ended",epoch:e});},this.deps.getAudioContext());return n.setMuted(this.muted),n.onTimeline=()=>this.emitAnchor(),this.player=n,this.deps.publishClock(()=>n.isPlaybackScheduled()?n.getAlignmentTime():null),this.refreshTimer=setInterval(()=>{n.isPlaybackScheduled()&&this.emitAnchor();},$e),n}emitAnchor(){this.deps.emit({t:"anchor",anchor:this.anchor()});}dropPlayer(){this.refreshTimer&&clearInterval(this.refreshTimer),this.refreshTimer=null;let e=this.player;e&&(this.player=null,e.onTimeline=void 0,e.destroy(),this.deps.publishClock(null));}},ce=(t,e)=>{if(!t)return {...e};let n={...t,audioChunks:[...t.audioChunks],alignments:[...t.alignments],...t.displayAlignments&&{displayAlignments:[...t.displayAlignments]},...(t.visemes||e.visemes)&&{visemes:[...t.visemes??t.alignments.map(()=>null)]}};return e.audioChunks.forEach((r,o)=>{e.chunkOffset+o===t.chunkOffset+n.audioChunks.length&&(n.audioChunks.push(r),n.alignments.push(e.alignments[o]??null),n.displayAlignments?.push(e.displayAlignments?.[o]??null),n.visemes?.push(e.visemes?.[o]??null));}),n};var le=class{constructor(e,n){this.link=e;this.visible=new Map;this.front=null;this.nextCallId=0;this.pending=new Map;this.pageListeners=new Set;this.pageHost={browser:n,surface:chunk3SRQGZJ5_js.z(r=>this.callFront(r)),watch:r=>(this.pageListeners.add(r),()=>this.pageListeners.delete(r)),pageBeforeLive:true};}handle(e,n){switch(n.t){case "visible":return n.visible?this.visible.set(e,Date.now()):this.visible.delete(e),this.pickFront(n.visible?e:null),true;case "page.reply":{let r=this.pending.get(n.id);return !r||r.viewId!==e||(this.pending.delete(n.id),n.ok?r.resolve(n.value):r.reject(new Error(n.error??"the page call failed"))),true}case "page.changed":return e===this.front&&this.pageChanged(),true;default:return false}}leave(e){this.visible.delete(e);for(let[n,r]of this.pending)r.viewId===e&&(this.pending.delete(n),r.reject(new Error("the page closed")));this.front===e&&this.pickFront(null);}pickFront(e){let n=e;if(!n||!this.visible.has(n)){n=null;let r=-1;for(let[o,i]of this.visible)i>r&&([n,r]=[o,i]);}n!==this.front&&(this.front=n,chunk3SRQGZJ5_js.b.debug("EngineHost","front view changed",{front:n}),this.pageChanged());}pageChanged(){for(let e of this.pageListeners)e();}callFront(e){let n=this.front;if(!n)return Promise.reject(new Error("no page is in front"));let r=++this.nextCallId;return new Promise((o,i)=>{this.pending.set(r,{resolve:o,reject:i,viewId:n}),this.link.send(n,{t:"page.call",id:r,call:e});})}},Qe=t=>{let{error:e}=t;return {isReady:t.isReady,isLoading:t.isLoading,isConnecting:t.isConnecting,isSpeaking:t.isSpeaking,isListening:t.isListening,isThinking:t.isThinking,isResponseSlow:t.isResponseSlow,isIdle:t.isIdle,isFailed:t.isFailed,isConnected:t.isConnected,isMicMuted:t.isMicMuted,isSpeakerMuted:t.isSpeakerMuted,isPushToTalk:t.isPushToTalk,isTalking:t.isTalking,availableActions:t.availableActions,notice:t.notice,avatarId:t.avatarId,mode:t.mode,error:e?{code:e.code,message:e.message,source:e.source,fatal:e.fatal,retryable:e.retryable}:null,resetToken:t._resetToken,riveKey:t._riveKey,avatarConfig:t._avatarConfig,shouldArmTalking:t._shouldArmTalking,userActivity:t._userActivity,thinkingSignal:t._thinkingSignal,visualState:t._visualState,tuning:{...t._lipSyncTuning}}};function Ze({link:t,views:e}){let n=chunkFDZA3OHI_js.g(),r=react.useRef(n);r.current=n;let o=react.useMemo(()=>new Z({getAudioContext:()=>r.current._getAudioContext(),onEnded:()=>r.current._onPlaybackEnd(),publishClock:s=>r.current._registerSpeechClock(s),emit:s=>t.broadcast(s)}),[t]);react.useEffect(()=>()=>o.destroy(),[o]),react.useEffect(()=>{r.current._registerPlaybackControls(o.controls);let s=r.current._onSpeechJob(d=>o.speak(d));return ()=>{s(),r.current._registerPlaybackControls(null);}},[o]);let i=react.useRef(n._resetToken);react.useEffect(()=>{n._resetToken!==i.current&&(i.current=n._resetToken,o.resetSession());},[n._resetToken,o]),react.useEffect(()=>o.setMuted(n._speakerMuted),[n._speakerMuted,o]),react.useEffect(()=>{n._avatarConfig&&r.current._onRiveReady?.();},[n._avatarConfig,n._riveKey]);let p=Qe(n),k=JSON.stringify(p),T=react.useRef(p);return T.current=p,react.useEffect(()=>{t.broadcast({t:"state",state:T.current});},[t,k]),react.useEffect(()=>n._transcriptStore.subscribe(()=>t.broadcast({t:"transcript",entries:r.current._transcriptStore.getSnapshot().slice(-200)})),[n._transcriptStore,t]),react.useEffect(()=>n._healthStore.subscribe(()=>t.broadcast({t:"health",health:r.current._healthStore.getSnapshot()})),[n._healthStore,t]),react.useEffect(()=>{let s=r.current._gestureQueue.current;s.length!==0&&t.broadcast({t:"gestures",gestures:s.splice(0,s.length)});},[n._gestureSignal,t]),react.useEffect(()=>t.onMessage((s,d)=>{if(e.handle(s,d))return;let h=r.current;switch(d.t){case "join":{let a=[{t:"state",state:T.current},{t:"transcript",entries:h._transcriptStore.getSnapshot().slice(-200)},{t:"health",health:h._healthStore.getSnapshot()},...o.snapshot()];for(let m of a)t.send(s,m);return}case "cmd":d.cmd==="start"?h.start():d.cmd==="stop"?h.stop():d.cmd==="interrupt"?h.interrupt():d.cmd==="stopSpeaking"?h.stopSpeaking():d.cmd==="startTalking"?h.startTalking():d.cmd==="stopTalking"?h.stopTalking():d.cmd==="skipNextGreeting"&&h._skipNextGreeting();return;case "mic":h.setMicMuted(d.muted);return;case "speaker":h.setSpeakerMuted(d.muted);return;case "trigger":h.triggerAction?.(d.name);return;case "avatarClick":h._avatarClicked?.();return;case "surface":h._setMountSurface(d.surface);return;case "rive.ready":return}}),[t,e,o]),react.useEffect(()=>t.onLeave(s=>e.leave(s)),[t,e]),null}function et({config:t,link:e,browser:n}){let r=react.useRef(n),o=react.useMemo(()=>new le(e,r.current),[e]);return jsxRuntime.jsx(chunkFDZA3OHI_js.e,{config:t,pageHost:o.pageHost,children:jsxRuntime.jsx(Ze,{link:e,views:o})})}var te=class{constructor(){this.anchor=null;this.epoch=null;this.players=new Set;this.createPlayer=e=>{let n=new pe(this,e,()=>this.players.delete(n));return this.players.add(n),n};}setEpoch(e){this.epoch=e;}setAnchor(e){this.anchor=e;}ended(e){if(!(e!==null&&e!==this.epoch))for(let n of [...this.players])n.end();}current(){let e=this.anchor;return e&&e.epoch===this.epoch?e:null}},pe=class{constructor(e,n,r){this.speech=e;this.onEnded=n;this.release=r;}enqueueChunk(){}enqueueSequentialChunk(){}pause(){}resume(){}setMuted(){}playBeep(){}getAlignmentTime(){let e=this.speech.current();return !e||e.alignmentSec===chunk3SRQGZJ5_js.e?chunk3SRQGZJ5_js.e:e.paused?e.alignmentSec:e.alignmentSec+(Q()-e.at)/1e3}getPlayableAlignmentTime(){return this.speech.current()?.playableSec??0}isPlaybackScheduled(){return this.speech.current()?.scheduled??false}isAudioActive(){return this.speech.current()?.active??false}hasPendingAudio(){return this.speech.current()?.pending??false}getOutputLevel(){return 0}end(){this.onEnded();}destroy(){this.release();}};var nt={services:{ingest:"ok",stt:"ok",llm:"ok",tts:"ok",downlink:"ok"},concern:null},b=()=>{},rt=(t,e,n)=>{let[r,o]=react.useState(null),[i,p]=react.useState(null),[k,T]=react.useState(0),s=react.useMemo(()=>new te,[]),d=react.useMemo(()=>new chunk3SRQGZJ5_js.p,[]),h=react.useMemo(()=>new chunkFDZA3OHI_js.b,[]),a=react.useMemo(()=>chunk3SRQGZJ5_js.N([]),[]),m=react.useMemo(()=>chunk3SRQGZJ5_js.N(nt),[]),u=react.useMemo(()=>chunk3SRQGZJ5_js.N(null),[]),f=react.useRef([]),P=react.useRef(null),V=react.useRef(null),M=react.useRef(n);react.useEffect(()=>{let c=e.onMessage(w=>{switch(w.t){case "state":Object.assign(d,w.state.tuning),o(w.state);return;case "speech":s.setEpoch(w.job.sessionId),p(C=>C&&C.sessionId===w.job.sessionId&&C.jobId===w.job.jobId?ce(C,w.job):{...w.job});return;case "anchor":s.setAnchor(w.anchor);return;case "speech.ended":s.ended(w.epoch);return;case "speech.reset":P.current?.reset(),p(null);return;case "gestures":f.current.push(...w.gestures),T(C=>C+1);return;case "transcript":a.set(w.entries);return;case "health":m.set(w.health);return;case "page.call":{let C=M.current?.surface,{id:I,call:oe}=w;if(!C){e.send({t:"page.reply",id:I,ok:false,error:"no page here"});return}Promise.resolve().then(()=>chunk3SRQGZJ5_js.A(C,oe)).then(y=>e.send({t:"page.reply",id:I,ok:true,value:y}),y=>e.send({t:"page.reply",id:I,ok:false,error:String(y)}));return}}});return e.send({t:"join",protocol:1}),c},[e,s,d,a,m]),react.useEffect(()=>{let c=()=>e.send({t:"visible",visible:document.visibilityState==="visible"});return c(),document.addEventListener("visibilitychange",c),()=>document.removeEventListener("visibilitychange",c)},[e]),react.useEffect(()=>M.current?.watch(()=>e.send({t:"page.changed"})),[e]);let x=react.useCallback(c=>e.send({t:"cmd",cmd:c}),[e]),N=t.transcript;return {isReady:r?.isReady??false,isLoading:r?.isLoading??true,isConnecting:r?.isConnecting??false,isSpeaking:r?.isSpeaking??false,isListening:r?.isListening??false,isThinking:r?.isThinking??false,isResponseSlow:r?.isResponseSlow??false,isIdle:r?.isIdle??true,isFailed:r?.isFailed??false,isConnected:r?.isConnected??false,isMicMuted:r?.isMicMuted??false,isSpeakerMuted:r?.isSpeakerMuted??false,isPushToTalk:r?.isPushToTalk??false,isTalking:r?.isTalking??false,availableActions:r?.availableActions??[],notice:r?.notice??null,avatarId:r?.avatarId??t.avatar?.avatarId,error:r?.error??null,controls:{enabled:t.controls?.enabled||false,stopSpeaking:t.controls?.stopSpeaking||false},mode:t.mode||"call",setMicMuted:c=>e.send({t:"mic",muted:c}),setSpeakerMuted:c=>e.send({t:"speaker",muted:c}),isMoodDetectionAvailable:false,isMoodDetectionOn:false,setMoodDetection:b,startTalking:()=>x("startTalking"),stopTalking:()=>x("stopTalking"),start:async()=>x("start"),stop:()=>x("stop"),interrupt:()=>x("interrupt"),stopSpeaking:()=>x("stopSpeaking"),triggerAction:c=>e.send({t:"trigger",name:c}),on:b,off:b,speakText:b,speakAudio:b,play:b,addLiveContext:b,notify:b,readPage:async()=>null,registerAction:()=>b,setLipSyncTuning:b,_healthStore:m,_transcriptStore:a,_actionFlowStore:u,_sendActionUi:()=>false,_currentJob:i,_onPlaybackEnd:b,_onRiveReady:()=>e.send({t:"rive.ready"}),_onRiveError:c=>chunk3SRQGZJ5_js.b.warn("RemoteAvatar","rig failed to load",{error:String(c)}),_resetToken:r?.resetToken??0,_mode:t.mode||"call",_setMountSurface:c=>e.send({t:"surface",surface:c}),_onWidgetCommand:()=>b,_reportWidgetStatus:b,_onSpeechJob:()=>b,_requestTour:async()=>null,_skipNextGreeting:()=>x("skipNextGreeting"),_riveKey:r?.riveKey??"",_avatarConfig:r?.avatarConfig??null,_shouldArmTalking:r?.shouldArmTalking??false,_userActivity:r?.userActivity??0,_thinkingSignal:r?.thinkingSignal??0,_speakerMuted:r?.isSpeakerMuted??false,_gestureQueue:f,_gestureSignal:k,_avatarClicked:()=>e.send({t:"avatarClick"}),_lipSyncTuning:d,_rigActivity:h,_visualState:r?.visualState??"normal",_camera:ot,_screen:st,_screenSharePosition:t.screenShare?.position??"top-center",_captionsEnabled:!!N?.enabled&&N.captions!==false,_captionPosition:N?.position??"bottom-center",_statusBannerEnabled:t.statusBanner?.enabled!==false,_statusBannerPosition:t.statusBanner?.position??"bottom-left",_thinkingIndicatorEnabled:t.thinkingIndicator?.enabled!==false,_thinkingIndicatorPosition:t.thinkingIndicator?.position??"top-left",_speechClockRef:V,_registerSpeechClock:c=>{V.current=c;},_registerPlaybackControls:c=>{P.current=c;},_getAudioContext:()=>null,_createSpeechPlayer:s.createPlayer,_spacebarToTalk:t.turnTaking?.spacebar!==false}},ot={stream:null,facing:"user",sessionOpen:false,toggleVideo:b,flip:b,mood:null},st={phase:"idle",share:b,dismiss:b,stop:b};function it({config:t,link:e,pageHost:n,children:r}){let o=rt(t,e,n);return jsxRuntime.jsx(chunkFDZA3OHI_js.d.Provider,{value:o,children:jsxRuntime.jsx(chunkFDZA3OHI_js.c,{children:r})})}var at=2600,ct=t=>!!t&&typeof t=="object"&&["left","top","width","height"].every(e=>Number.isFinite(t[e])),Oe=(t,e)=>{let n=new Map,r=new Map,o=new Set,i=0,p=a=>{window.parent!==window&&chunkFDZA3OHI_js.A(window.parent,t,e,a);},k=a=>{let m=chunkFDZA3OHI_js.z(a,{origin:t,deployId:e,direction:"from-loader",source:window.parent});if(m)switch(m.type){case "page.result":{let{callId:u,ok:f,value:P,error:V}=m.payload,M=n.get(u);n.delete(u),f?M?.resolve(P):M?.reject(new Error(V??"the page refused"));return}case "page.changed":o.forEach(u=>u());return;case "tour.result":{let{seq:u,found:f,rect:P}=m.payload;r.get(u)?.({found:f===true,rect:ct(P)?P:void 0}),r.delete(u);return}}};window.addEventListener("message",k);let T={surface:chunk3SRQGZJ5_js.z(a=>new Promise((m,u)=>{let f=`p${++i}`;n.set(f,{resolve:m,reject:u}),setTimeout(()=>n.delete(f),chunk3SRQGZJ5_js.y),p({type:"page.call",payload:{callId:f,call:a}});})),watch:a=>(o.add(a),()=>o.delete(a)),pageBeforeLive:true},s=a=>new Promise(m=>{let u=++i,f=setTimeout(()=>{r.delete(u),m({found:false});},at);r.set(u,P=>{clearTimeout(f),m(P);}),p({type:"tour.do",payload:{seq:u,...a}});});return {pageHost:T,tourPage:(a,m)=>({seenKey:a,scroll:async u=>(await s({op:"scroll",target:u})).rect??null,mark:async(u,f)=>(await s({op:"mark",target:u,strong:f,color:m})).found,clear:()=>{s({op:"clear"});},scrollTop:()=>{s({op:"top"});}}),dispose:()=>window.removeEventListener("message",k)}};var lt=new Set(["bottom-right","bottom-left","top-right","top-left"]),pt=new Set(["sheet","corner"]),Be={min:0,max:200},ut={min:40,max:160},dt={min:280,max:640},gt={min:360,max:900},ht=/^(#[0-9a-f]{3,8}|rgba?\(\s*[\d.]+%?\s*,\s*[\d.]+%?\s*,\s*[\d.]+%?\s*(,\s*[\d.]+%?\s*)?\))$/i,z=(t,e)=>typeof t=="number"&&Number.isFinite(t)?Math.min(e.max,Math.max(e.min,Math.round(t))):void 0,mt=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),Ve=t=>{let e=t&&typeof t=="object"?t:{},n=e.appearance&&typeof e.appearance=="object"?e.appearance:{},r=n.offset,o=n.panel,i=z(r?.x,Be),p=z(r?.y,Be),k=z(o?.w,dt),T=z(o?.h,gt),s=e.tour;return {layout:e.layout==="inline"?"inline":"widget",appearance:mt({position:typeof n.position=="string"&&lt.has(n.position)?n.position:void 0,offset:i!==void 0&&p!==void 0?{x:i,y:p}:void 0,bubbleSize:z(n.bubbleSize,ut),panel:k!==void 0&&T!==void 0?{w:k,h:T}:void 0,accent:typeof n.accent=="string"&&ht.test(n.accent.trim())?n.accent.trim():void 0,draggable:typeof n.draggable=="boolean"?n.draggable:void 0,mobile:typeof n.mobile=="string"&&pt.has(n.mobile)?n.mobile:void 0}),tour:s&&typeof s=="object"?{once:s.once==="session"?"session":"visitor"}:void 0,pageAccess:e.pageAccess===true}};var vt=()=>new URLSearchParams(window.location.search).get("page")==="1",bt=()=>{let t=new URLSearchParams(window.location.hash.slice(1)),e=t.get(chunkFDZA3OHI_js.x);if(e)return window.history.replaceState(null,"",window.location.pathname+window.location.search),{token:e,led:t.get("led")==="1"}},St=({projection:t,hostOrigin:e})=>{let{behaviour:n}=t,[r]=react.useState(()=>Oe(e,t.deployId));react.useEffect(()=>r.dispose,[r]);let[o]=react.useState(()=>vt()?r.pageHost:void 0),[i]=react.useState(()=>({kept:bt(),onState:k=>chunkFDZA3OHI_js.A(window.parent,e,t.deployId,{type:"event",payload:{name:chunkFDZA3OHI_js.w,detail:{token:k}}})})),p=react.useMemo(()=>({deployId:t.deployId,mode:t.mode,avatar:{avatarId:t.avatarId,greeting:n?.greeting},connectTone:n?.connectTone,transcript:n?.transcript}),[t.deployId,t.mode,t.avatarId,n]);return At(),jsxRuntime.jsx(chunkFDZA3OHI_js.e,{config:p,embedHostOrigin:e,pageHost:o,embedResume:i,children:jsxRuntime.jsx(kt,{projection:t,hostOrigin:e,channel:r,carriesOn:!!i.kept})})},kt=({projection:t,hostOrigin:e,channel:n,carriesOn:r})=>{let o=chunkFDZA3OHI_js.h(),{_sendActionUi:i}=chunkFDZA3OHI_js.g(),p=chunkFDZA3OHI_js.t(),{flow:k}=chunkFDZA3OHI_js.D(),[T,s]=react.useState(null),[d,h]=react.useState(0),[a,m]=react.useState(null),u=react.useRef(new Map),f=react.useRef(new Map),P=react.useRef([]),V=react.useRef(0),{deployId:M,configVersion:x,mode:N}=t,c=react.useMemo(()=>({...t.appearance,...a?.config.appearance}),[t.appearance,a]),w=react.useMemo(()=>chunk3SRQGZJ5_js.C(c),[c]),C=react.useMemo(()=>chunk3SRQGZJ5_js.C(t.appearance).position,[t.appearance]),I=react.useMemo(()=>a?.config.tour?{...t.tour,generate:true,once:a.config.tour.once}:t.tour,[t.tour,a]),oe=react.useMemo(()=>a&&I?n.tourPage(`af-tour:site:${e}`,I.highlightColor):void 0,[n,a,I]),y=react.useCallback(l=>{window.parent!==window&&chunkFDZA3OHI_js.A(window.parent,e,M,l);},[e,M]),se=d>=2,Ne=react.useMemo(()=>se?{...c,draggable:c.draggable??true,teaser:void 0}:{...c,offset:{x:0,y:0},draggable:false,teaser:void 0},[c,se]),ge=react.useCallback(l=>{P.current.forEach(R=>R()),P.current=l.flatMap(R=>{let v=Object.values(R.params??{}).some(A=>A.check),E=o.registerAction?.({...R,handler:(A,{callId:g,signal:S})=>new Promise(O=>{u.current.set(g,O),S.addEventListener("abort",()=>u.current.delete(g)),y({type:"action.run",payload:{callId:g,name:R.name,args:A}});}),...v&&{check:(A,g,S)=>new Promise(O=>{let q=`check-${++V.current}`;f.current.set(q,O),setTimeout(()=>f.current.delete(q),chunk3SRQGZJ5_js.s),y({type:"action.check",payload:{checkId:q,name:R.name,param:A,value:g,args:S}});})}});return E?[E]:[]});},[o,y]);react.useEffect(()=>{let l=R=>{let v=chunkFDZA3OHI_js.z(R,{origin:e,deployId:M,direction:"from-loader",source:window.parent});if(v)switch(v.type){case "host.info":{let{w:E,h:A}=v.payload.viewport;s(S=>S&&S.w===E&&S.h===A?S:{w:E,h:A}),h(v.payload.frameLayout??0);let g={config:Ve(v.payload.config)};m(S=>S&&JSON.stringify(S)===JSON.stringify(g)?S:g);return}case "context.set":o.addLiveContext?.({context:v.payload.context});return;case "context.event":o.addLiveContext?.({context:`${v.payload.name}: ${v.payload.context}`,update:true});return;case "cmd.open":p.open();return;case "cmd.close":p.close();return;case "cmd.start":o.start?.();return;case "cmd.stop":case "cmd.destroy":o.stop?.();return;case "action.set":ge(v.payload.actions);return;case "action.result":{let{callId:E,ok:A,result:g,error:S}=v.payload,O=u.current.get(E);u.current.delete(E),O?.(A?{ok:true,result:g}:{ok:false,error:S??"failed"});return}case "action.check_result":{let{checkId:E,ok:A,reason:g,suggestions:S,param:O,value:q}=v.payload,Ue=f.current.get(E);f.current.delete(E),Ue?.(A?{ok:true,value:q}:{ok:false,reason:g,suggestions:S,param:O});return}case "action.ui":i(v.payload.op,v.payload.args,v.payload.name);return}};return window.addEventListener("message",l),()=>window.removeEventListener("message",l)},[e,M,o,p,ge,i]),react.useEffect(()=>()=>P.current.forEach(l=>l()),[]),react.useEffect(()=>{y({type:"ready",payload:{configVersion:x,mode:N,position:C}});},[y,x,N,C]),react.useEffect(()=>{let l=(g,S)=>y({type:"event",payload:{name:g,detail:S}}),R=()=>l("start"),v=()=>l("stop"),E=g=>l("notice",{kind:g.kind,action:g.action}),A=g=>l("error",{code:g.code,fatal:g.fatal,cause:chunk3SRQGZJ5_js.t(g)});return o.on?.("start",R),o.on?.("stop",v),o.on?.("notice",E),o.on?.("error",A),()=>{o.off?.("start",R),o.off?.("stop",v),o.off?.("notice",E),o.off?.("error",A);}},[o.on,o.off,y]);let he=react.useRef(false);react.useEffect(()=>{!r||he.current||(he.current=true,p.open(),o.start?.());},[r,p,o]),react.useEffect(()=>{y({type:"event",payload:{name:"speaking",detail:{speaking:o.isSpeaking}}});},[o.isSpeaking,y]),react.useEffect(()=>{y({type:"action.flow",payload:{flow:k}});},[k,y]);let We=react.useCallback(l=>y({type:"resize",payload:{w:l.w,h:l.h,position:l.position,sheet:l.sheet,offset:w.offset,left:l.left,top:l.top,gutter:l.gutter}}),[y,w.offset]),me=react.useRef(null),Fe=react.useCallback(l=>{l!==me.current&&(me.current=l,y({type:"state",payload:{stage:l}}));},[y]);return !T||!a?null:a.config.layout==="inline"?jsxRuntime.jsx(wt,{}):jsxRuntime.jsx(chunkFDZA3OHI_js.s,{appearance:Ne,hostViewport:T,framed:se,tour:I,tourPage:oe,onResize:We,onStageChange:Fe})},wt=()=>(chunkFDZA3OHI_js.g()._setMountSurface("inline"),jsxRuntime.jsx("div",{style:{width:"100vw",height:"100vh"},children:jsxRuntime.jsx(chunkFDZA3OHI_js.r,{style:{width:"100%",height:"100%"}})})),At=()=>{react.useEffect(()=>{for(let t of [document.documentElement,document.body])Object.assign(t.style,{background:"transparent",margin:"0",overflow:"hidden",colorScheme:"normal",fontFamily:"system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif"});},[]);};var En=chunkFDZA3OHI_js.e,Tn=()=>chunkFDZA3OHI_js.g()._skipNextGreeting,Pn=()=>chunkFDZA3OHI_js.g()._rigActivity.subscribe;Object.defineProperty(exports,"Avatar",{enumerable:true,get:function(){return chunkFDZA3OHI_js.r}});Object.defineProperty(exports,"AvatarConnectingLoader",{enumerable:true,get:function(){return chunkFDZA3OHI_js.j}});Object.defineProperty(exports,"AvatarWidget",{enumerable:true,get:function(){return chunkFDZA3OHI_js.s}});Object.defineProperty(exports,"BRIDGE_NAMESPACE",{enumerable:true,get:function(){return chunkFDZA3OHI_js.u}});Object.defineProperty(exports,"BRIDGE_VERSION",{enumerable:true,get:function(){return chunkFDZA3OHI_js.v}});Object.defineProperty(exports,"buildEnvelope",{enumerable:true,get:function(){return chunkFDZA3OHI_js.y}});Object.defineProperty(exports,"getRiveRendererStatus",{enumerable:true,get:function(){return chunkFDZA3OHI_js.l}});Object.defineProperty(exports,"onRiveRendererEvent",{enumerable:true,get:function(){return chunkFDZA3OHI_js.m}});Object.defineProperty(exports,"parseBridgeMessage",{enumerable:true,get:function(){return chunkFDZA3OHI_js.z}});Object.defineProperty(exports,"postBridgeMessage",{enumerable:true,get:function(){return chunkFDZA3OHI_js.A}});Object.defineProperty(exports,"setScriptUrls",{enumerable:true,get:function(){return chunkFDZA3OHI_js.a}});Object.defineProperty(exports,"simulateRiveContextLoss",{enumerable:true,get:function(){return chunkFDZA3OHI_js.n}});Object.defineProperty(exports,"useAvatar",{enumerable:true,get:function(){return chunkFDZA3OHI_js.h}});Object.defineProperty(exports,"useAvatarAction",{enumerable:true,get:function(){return chunkFDZA3OHI_js.C}});Object.defineProperty(exports,"useAvatarActionFlow",{enumerable:true,get:function(){return chunkFDZA3OHI_js.D}});Object.defineProperty(exports,"useAvatarEvent",{enumerable:true,get:function(){return chunkFDZA3OHI_js.B}});Object.defineProperty(exports,"useAvatarWidget",{enumerable:true,get:function(){return chunkFDZA3OHI_js.t}});Object.defineProperty(exports,"useRiveFrameHold",{enumerable:true,get:function(){return chunkFDZA3OHI_js.q}});Object.defineProperty(exports,"useRiveRenderGeneration",{enumerable:true,get:function(){return chunkFDZA3OHI_js.o}});Object.defineProperty(exports,"useRiveRendererStatus",{enumerable:true,get:function(){return chunkFDZA3OHI_js.p}});Object.defineProperty(exports,"watchRiveRenderer",{enumerable:true,get:function(){return chunkFDZA3OHI_js.k}});Object.defineProperty(exports,"PaintPhase",{enumerable:true,get:function(){return chunk3SRQGZJ5_js.v}});Object.defineProperty(exports,"SessionPhase",{enumerable:true,get:function(){return chunk3SRQGZJ5_js.u}});Object.defineProperty(exports,"TurnPhase",{enumerable:true,get:function(){return chunk3SRQGZJ5_js.w}});Object.defineProperty(exports,"WIDGET_DEFAULTS",{enumerable:true,get:function(){return chunk3SRQGZJ5_js.B}});Object.defineProperty(exports,"createRemotePageSurface",{enumerable:true,get:function(){return chunk3SRQGZJ5_js.z}});Object.defineProperty(exports,"resolveWidgetAppearance",{enumerable:true,get:function(){return chunk3SRQGZJ5_js.C}});exports.AvatarEngineHost=et;exports.AvatarProvider=En;exports.EmbedRuntime=St;exports.RemoteAvatarProvider=it;exports.useRigActivity=Pn;exports.useSkipNextGreeting=Tn;
package/dist/unstable.mjs CHANGED
@@ -1 +1 @@
1
- import {e,d,c,A,w,h,g,t,D,s as s$1,r,b as b$2,x,z as z$2,i}from'./chunk-OANDIUVQ.mjs';export{r as Avatar,j as AvatarConnectingLoader,s as AvatarWidget,u as BRIDGE_NAMESPACE,v as BRIDGE_VERSION,y as buildEnvelope,l as getRiveRendererStatus,m as onRiveRendererEvent,z as parseBridgeMessage,A as postBridgeMessage,a as setScriptUrls,n as simulateRiveContextLoss,h as useAvatar,C as useAvatarAction,D as useAvatarActionFlow,B as useAvatarEvent,t as useAvatarWidget,q as useRiveFrameHold,o as useRiveRenderGeneration,p as useRiveRendererStatus,k as watchRiveRenderer}from'./chunk-OANDIUVQ.mjs';import {C,s,z as z$1,b as b$1,p,N,A as A$1,y,t as t$1,e as e$1}from'./chunk-E7HVSIHB.mjs';export{v as PaintPhase,u as SessionPhase,w as TurnPhase,B as WIDGET_DEFAULTS,z as createRemotePageSurface,C as resolveWidgetAppearance}from'./chunk-E7HVSIHB.mjs';import {useRef,useMemo,useState,useEffect,useCallback}from'react';import {jsx}from'react/jsx-runtime';var Q=()=>performance.timeOrigin+performance.now();var $e=500,Ye="1",Z=class{constructor(e){this.deps=e;this.player=null;this.epoch=null;this.jobId=null;this.nextChunk=0;this.muted=false;this.job=null;this.refreshTimer=null;this.controls={pause:()=>this.player?.pause(),resume:()=>this.player?.resume(),getOutputLevel:()=>this.player?.getOutputLevel()??0,hasPendingAudio:()=>this.player?.hasPendingAudio()??false,reset:()=>this.reset()};}speak(e){e.sessionId!==this.epoch&&(this.dropPlayer(),this.epoch=e.sessionId,this.jobId=null),e.jobId!==this.jobId&&(this.jobId=e.jobId,this.nextChunk=0,this.job=null);let n={...e,audioChunks:e.audioChunks.map(i=>i?Ye:"")};this.job=ce(this.job,n),this.deps.emit({t:"speech",job:n});let r=this.player??this.makePlayer(),o=Math.max(0,this.nextChunk-e.chunkOffset);for(let i=o;i<e.audioChunks.length;i++){this.nextChunk=e.chunkOffset+i+1;let p=e.audioChunks[i];if(!p)continue;let k=e.alignments[i];k?r.enqueueChunk(p,k.character_start_times_seconds[0]??0):r.enqueueSequentialChunk(p);}}reset(){this.dropPlayer(),this.nextChunk=0,this.jobId=null,this.job=null,this.deps.emit({t:"speech.reset"});}resetSession(){this.reset(),this.epoch=null;}setMuted(e){this.muted=e,this.player?.setMuted(e);}anchor(){let e=this.player;return {epoch:this.epoch,alignmentSec:e?e.getAlignmentTime():e$1,playableSec:e?.getPlayableAlignmentTime()??0,at:Q(),paused:e?.isPaused()??false,scheduled:e?.isPlaybackScheduled()??false,active:e?.isAudioActive()??false,pending:e?.hasPendingAudio()??false}}snapshot(){return [...this.job?[{t:"speech",job:this.job}]:[],{t:"anchor",anchor:this.anchor()}]}destroy(){this.dropPlayer();}makePlayer(){let e=this.epoch,n=new i(()=>{this.deps.onEnded(),this.deps.emit({t:"speech.ended",epoch:e});},this.deps.getAudioContext());return n.setMuted(this.muted),n.onTimeline=()=>this.emitAnchor(),this.player=n,this.deps.publishClock(()=>n.isPlaybackScheduled()?n.getAlignmentTime():null),this.refreshTimer=setInterval(()=>{n.isPlaybackScheduled()&&this.emitAnchor();},$e),n}emitAnchor(){this.deps.emit({t:"anchor",anchor:this.anchor()});}dropPlayer(){this.refreshTimer&&clearInterval(this.refreshTimer),this.refreshTimer=null;let e=this.player;e&&(this.player=null,e.onTimeline=void 0,e.destroy(),this.deps.publishClock(null));}},ce=(t,e)=>{if(!t)return {...e};let n={...t,audioChunks:[...t.audioChunks],alignments:[...t.alignments],...t.displayAlignments&&{displayAlignments:[...t.displayAlignments]},...(t.visemes||e.visemes)&&{visemes:[...t.visemes??t.alignments.map(()=>null)]}};return e.audioChunks.forEach((r,o)=>{e.chunkOffset+o===t.chunkOffset+n.audioChunks.length&&(n.audioChunks.push(r),n.alignments.push(e.alignments[o]??null),n.displayAlignments?.push(e.displayAlignments?.[o]??null),n.visemes?.push(e.visemes?.[o]??null));}),n};var le=class{constructor(e,n){this.link=e;this.visible=new Map;this.front=null;this.nextCallId=0;this.pending=new Map;this.pageListeners=new Set;this.pageHost={browser:n,surface:z$1(r=>this.callFront(r)),watch:r=>(this.pageListeners.add(r),()=>this.pageListeners.delete(r)),pageBeforeLive:true};}handle(e,n){switch(n.t){case "visible":return n.visible?this.visible.set(e,Date.now()):this.visible.delete(e),this.pickFront(n.visible?e:null),true;case "page.reply":{let r=this.pending.get(n.id);return !r||r.viewId!==e||(this.pending.delete(n.id),n.ok?r.resolve(n.value):r.reject(new Error(n.error??"the page call failed"))),true}case "page.changed":return e===this.front&&this.pageChanged(),true;default:return false}}leave(e){this.visible.delete(e);for(let[n,r]of this.pending)r.viewId===e&&(this.pending.delete(n),r.reject(new Error("the page closed")));this.front===e&&this.pickFront(null);}pickFront(e){let n=e;if(!n||!this.visible.has(n)){n=null;let r=-1;for(let[o,i]of this.visible)i>r&&([n,r]=[o,i]);}n!==this.front&&(this.front=n,b$1.debug("EngineHost","front view changed",{front:n}),this.pageChanged());}pageChanged(){for(let e of this.pageListeners)e();}callFront(e){let n=this.front;if(!n)return Promise.reject(new Error("no page is in front"));let r=++this.nextCallId;return new Promise((o,i)=>{this.pending.set(r,{resolve:o,reject:i,viewId:n}),this.link.send(n,{t:"page.call",id:r,call:e});})}},Qe=t=>{let{error:e}=t;return {isReady:t.isReady,isLoading:t.isLoading,isConnecting:t.isConnecting,isSpeaking:t.isSpeaking,isListening:t.isListening,isThinking:t.isThinking,isResponseSlow:t.isResponseSlow,isIdle:t.isIdle,isFailed:t.isFailed,isConnected:t.isConnected,isMicMuted:t.isMicMuted,isSpeakerMuted:t.isSpeakerMuted,isPushToTalk:t.isPushToTalk,isTalking:t.isTalking,availableActions:t.availableActions,notice:t.notice,avatarId:t.avatarId,mode:t.mode,error:e?{code:e.code,message:e.message,source:e.source,fatal:e.fatal,retryable:e.retryable}:null,resetToken:t._resetToken,riveKey:t._riveKey,avatarConfig:t._avatarConfig,shouldArmTalking:t._shouldArmTalking,userActivity:t._userActivity,thinkingSignal:t._thinkingSignal,visualState:t._visualState,tuning:{...t._lipSyncTuning}}};function Ze({link:t,views:e}){let n=g(),r=useRef(n);r.current=n;let o=useMemo(()=>new Z({getAudioContext:()=>r.current._getAudioContext(),onEnded:()=>r.current._onPlaybackEnd(),publishClock:s=>r.current._registerSpeechClock(s),emit:s=>t.broadcast(s)}),[t]);useEffect(()=>()=>o.destroy(),[o]),useEffect(()=>{r.current._registerPlaybackControls(o.controls);let s=r.current._onSpeechJob(d=>o.speak(d));return ()=>{s(),r.current._registerPlaybackControls(null);}},[o]);let i=useRef(n._resetToken);useEffect(()=>{n._resetToken!==i.current&&(i.current=n._resetToken,o.resetSession());},[n._resetToken,o]),useEffect(()=>o.setMuted(n._speakerMuted),[n._speakerMuted,o]),useEffect(()=>{n._avatarConfig&&r.current._onRiveReady?.();},[n._avatarConfig,n._riveKey]);let p=Qe(n),k=JSON.stringify(p),T=useRef(p);return T.current=p,useEffect(()=>{t.broadcast({t:"state",state:T.current});},[t,k]),useEffect(()=>n._transcriptStore.subscribe(()=>t.broadcast({t:"transcript",entries:r.current._transcriptStore.getSnapshot().slice(-200)})),[n._transcriptStore,t]),useEffect(()=>n._healthStore.subscribe(()=>t.broadcast({t:"health",health:r.current._healthStore.getSnapshot()})),[n._healthStore,t]),useEffect(()=>{let s=r.current._gestureQueue.current;s.length!==0&&t.broadcast({t:"gestures",gestures:s.splice(0,s.length)});},[n._gestureSignal,t]),useEffect(()=>t.onMessage((s,d)=>{if(e.handle(s,d))return;let h=r.current;switch(d.t){case "join":{let a=[{t:"state",state:T.current},{t:"transcript",entries:h._transcriptStore.getSnapshot().slice(-200)},{t:"health",health:h._healthStore.getSnapshot()},...o.snapshot()];for(let m of a)t.send(s,m);return}case "cmd":d.cmd==="start"?h.start():d.cmd==="stop"?h.stop():d.cmd==="interrupt"?h.interrupt():d.cmd==="stopSpeaking"?h.stopSpeaking():d.cmd==="startTalking"?h.startTalking():d.cmd==="stopTalking"?h.stopTalking():d.cmd==="skipNextGreeting"&&h._skipNextGreeting();return;case "mic":h.setMicMuted(d.muted);return;case "speaker":h.setSpeakerMuted(d.muted);return;case "trigger":h.triggerAction?.(d.name);return;case "avatarClick":h._avatarClicked?.();return;case "surface":h._setMountSurface(d.surface);return;case "rive.ready":return}}),[t,e,o]),useEffect(()=>t.onLeave(s=>e.leave(s)),[t,e]),null}function et({config:t,link:e$1,browser:n}){let r=useRef(n),o=useMemo(()=>new le(e$1,r.current),[e$1]);return jsx(e,{config:t,pageHost:o.pageHost,children:jsx(Ze,{link:e$1,views:o})})}var te=class{constructor(){this.anchor=null;this.epoch=null;this.players=new Set;this.createPlayer=e=>{let n=new pe(this,e,()=>this.players.delete(n));return this.players.add(n),n};}setEpoch(e){this.epoch=e;}setAnchor(e){this.anchor=e;}ended(e){if(!(e!==null&&e!==this.epoch))for(let n of [...this.players])n.end();}current(){let e=this.anchor;return e&&e.epoch===this.epoch?e:null}},pe=class{constructor(e,n,r){this.speech=e;this.onEnded=n;this.release=r;}enqueueChunk(){}enqueueSequentialChunk(){}pause(){}resume(){}setMuted(){}playBeep(){}getAlignmentTime(){let e=this.speech.current();return !e||e.alignmentSec===e$1?e$1:e.paused?e.alignmentSec:e.alignmentSec+(Q()-e.at)/1e3}getPlayableAlignmentTime(){return this.speech.current()?.playableSec??0}isPlaybackScheduled(){return this.speech.current()?.scheduled??false}isAudioActive(){return this.speech.current()?.active??false}hasPendingAudio(){return this.speech.current()?.pending??false}getOutputLevel(){return 0}end(){this.onEnded();}destroy(){this.release();}};var nt={services:{ingest:"ok",stt:"ok",llm:"ok",tts:"ok",downlink:"ok"},concern:null},b=()=>{},rt=(t,e,n)=>{let[r,o]=useState(null),[i,p$1]=useState(null),[k,T]=useState(0),s=useMemo(()=>new te,[]),d=useMemo(()=>new p,[]),h=useMemo(()=>new b$2,[]),a=useMemo(()=>N([]),[]),m=useMemo(()=>N(nt),[]),u=useMemo(()=>N(null),[]),f=useRef([]),P=useRef(null),V=useRef(null),M=useRef(n);useEffect(()=>{let c=e.onMessage(w=>{switch(w.t){case "state":Object.assign(d,w.state.tuning),o(w.state);return;case "speech":s.setEpoch(w.job.sessionId),p$1(C=>C&&C.sessionId===w.job.sessionId&&C.jobId===w.job.jobId?ce(C,w.job):{...w.job});return;case "anchor":s.setAnchor(w.anchor);return;case "speech.ended":s.ended(w.epoch);return;case "speech.reset":P.current?.reset(),p$1(null);return;case "gestures":f.current.push(...w.gestures),T(C=>C+1);return;case "transcript":a.set(w.entries);return;case "health":m.set(w.health);return;case "page.call":{let C=M.current?.surface,{id:I,call:oe}=w;if(!C){e.send({t:"page.reply",id:I,ok:false,error:"no page here"});return}Promise.resolve().then(()=>A$1(C,oe)).then(y=>e.send({t:"page.reply",id:I,ok:true,value:y}),y=>e.send({t:"page.reply",id:I,ok:false,error:String(y)}));return}}});return e.send({t:"join",protocol:1}),c},[e,s,d,a,m]),useEffect(()=>{let c=()=>e.send({t:"visible",visible:document.visibilityState==="visible"});return c(),document.addEventListener("visibilitychange",c),()=>document.removeEventListener("visibilitychange",c)},[e]),useEffect(()=>M.current?.watch(()=>e.send({t:"page.changed"})),[e]);let x=useCallback(c=>e.send({t:"cmd",cmd:c}),[e]),N$1=t.transcript;return {isReady:r?.isReady??false,isLoading:r?.isLoading??true,isConnecting:r?.isConnecting??false,isSpeaking:r?.isSpeaking??false,isListening:r?.isListening??false,isThinking:r?.isThinking??false,isResponseSlow:r?.isResponseSlow??false,isIdle:r?.isIdle??true,isFailed:r?.isFailed??false,isConnected:r?.isConnected??false,isMicMuted:r?.isMicMuted??false,isSpeakerMuted:r?.isSpeakerMuted??false,isPushToTalk:r?.isPushToTalk??false,isTalking:r?.isTalking??false,availableActions:r?.availableActions??[],notice:r?.notice??null,avatarId:r?.avatarId??t.avatar?.avatarId,error:r?.error??null,controls:{enabled:t.controls?.enabled||false,stopSpeaking:t.controls?.stopSpeaking||false},mode:t.mode||"call",setMicMuted:c=>e.send({t:"mic",muted:c}),setSpeakerMuted:c=>e.send({t:"speaker",muted:c}),isMoodDetectionAvailable:false,isMoodDetectionOn:false,setMoodDetection:b,startTalking:()=>x("startTalking"),stopTalking:()=>x("stopTalking"),start:async()=>x("start"),stop:()=>x("stop"),interrupt:()=>x("interrupt"),stopSpeaking:()=>x("stopSpeaking"),triggerAction:c=>e.send({t:"trigger",name:c}),on:b,off:b,speakText:b,speakAudio:b,play:b,addLiveContext:b,notify:b,readPage:async()=>null,registerAction:()=>b,setLipSyncTuning:b,_healthStore:m,_transcriptStore:a,_actionFlowStore:u,_sendActionUi:()=>false,_currentJob:i,_onPlaybackEnd:b,_onRiveReady:()=>e.send({t:"rive.ready"}),_onRiveError:c=>b$1.warn("RemoteAvatar","rig failed to load",{error:String(c)}),_resetToken:r?.resetToken??0,_mode:t.mode||"call",_setMountSurface:c=>e.send({t:"surface",surface:c}),_onWidgetCommand:()=>b,_reportWidgetStatus:b,_onSpeechJob:()=>b,_requestTour:async()=>null,_skipNextGreeting:()=>x("skipNextGreeting"),_riveKey:r?.riveKey??"",_avatarConfig:r?.avatarConfig??null,_shouldArmTalking:r?.shouldArmTalking??false,_userActivity:r?.userActivity??0,_thinkingSignal:r?.thinkingSignal??0,_speakerMuted:r?.isSpeakerMuted??false,_gestureQueue:f,_gestureSignal:k,_avatarClicked:()=>e.send({t:"avatarClick"}),_lipSyncTuning:d,_rigActivity:h,_visualState:r?.visualState??"normal",_camera:ot,_screen:st,_screenSharePosition:t.screenShare?.position??"top-center",_captionsEnabled:!!N$1?.enabled&&N$1.captions!==false,_captionPosition:N$1?.position??"bottom-center",_statusBannerEnabled:t.statusBanner?.enabled!==false,_statusBannerPosition:t.statusBanner?.position??"bottom-left",_thinkingIndicatorEnabled:t.thinkingIndicator?.enabled!==false,_thinkingIndicatorPosition:t.thinkingIndicator?.position??"top-left",_speechClockRef:V,_registerSpeechClock:c=>{V.current=c;},_registerPlaybackControls:c=>{P.current=c;},_getAudioContext:()=>null,_createSpeechPlayer:s.createPlayer,_spacebarToTalk:t.turnTaking?.spacebar!==false}},ot={stream:null,facing:"user",sessionOpen:false,toggleVideo:b,flip:b,mood:null},st={phase:"idle",share:b,dismiss:b,stop:b};function it({config:t,link:e,pageHost:n,children:r}){let o=rt(t,e,n);return jsx(d.Provider,{value:o,children:jsx(c,{children:r})})}var at=2600,ct=t=>!!t&&typeof t=="object"&&["left","top","width","height"].every(e=>Number.isFinite(t[e])),Oe=(t,e)=>{let n=new Map,r=new Map,o=new Set,i=0,p=a=>{window.parent!==window&&A(window.parent,t,e,a);},k=a=>{let m=z$2(a,{origin:t,deployId:e,direction:"from-loader",source:window.parent});if(m)switch(m.type){case "page.result":{let{callId:u,ok:f,value:P,error:V}=m.payload,M=n.get(u);n.delete(u),f?M?.resolve(P):M?.reject(new Error(V??"the page refused"));return}case "page.changed":o.forEach(u=>u());return;case "tour.result":{let{seq:u,found:f,rect:P}=m.payload;r.get(u)?.({found:f===true,rect:ct(P)?P:void 0}),r.delete(u);return}}};window.addEventListener("message",k);let T={surface:z$1(a=>new Promise((m,u)=>{let f=`p${++i}`;n.set(f,{resolve:m,reject:u}),setTimeout(()=>n.delete(f),y),p({type:"page.call",payload:{callId:f,call:a}});})),watch:a=>(o.add(a),()=>o.delete(a)),pageBeforeLive:true},s=a=>new Promise(m=>{let u=++i,f=setTimeout(()=>{r.delete(u),m({found:false});},at);r.set(u,P=>{clearTimeout(f),m(P);}),p({type:"tour.do",payload:{seq:u,...a}});});return {pageHost:T,tourPage:(a,m)=>({seenKey:a,scroll:async u=>(await s({op:"scroll",target:u})).rect??null,mark:async(u,f)=>(await s({op:"mark",target:u,strong:f,color:m})).found,clear:()=>{s({op:"clear"});},scrollTop:()=>{s({op:"top"});}}),dispose:()=>window.removeEventListener("message",k)}};var lt=new Set(["bottom-right","bottom-left","top-right","top-left"]),pt=new Set(["sheet","corner"]),Be={min:0,max:200},ut={min:40,max:160},dt={min:280,max:640},gt={min:360,max:900},ht=/^(#[0-9a-f]{3,8}|rgba?\(\s*[\d.]+%?\s*,\s*[\d.]+%?\s*,\s*[\d.]+%?\s*(,\s*[\d.]+%?\s*)?\))$/i,z=(t,e)=>typeof t=="number"&&Number.isFinite(t)?Math.min(e.max,Math.max(e.min,Math.round(t))):void 0,mt=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),Ve=t=>{let e=t&&typeof t=="object"?t:{},n=e.appearance&&typeof e.appearance=="object"?e.appearance:{},r=n.offset,o=n.panel,i=z(r?.x,Be),p=z(r?.y,Be),k=z(o?.w,dt),T=z(o?.h,gt),s=e.tour;return {layout:e.layout==="inline"?"inline":"widget",appearance:mt({position:typeof n.position=="string"&&lt.has(n.position)?n.position:void 0,offset:i!==void 0&&p!==void 0?{x:i,y:p}:void 0,bubbleSize:z(n.bubbleSize,ut),panel:k!==void 0&&T!==void 0?{w:k,h:T}:void 0,accent:typeof n.accent=="string"&&ht.test(n.accent.trim())?n.accent.trim():void 0,draggable:typeof n.draggable=="boolean"?n.draggable:void 0,mobile:typeof n.mobile=="string"&&pt.has(n.mobile)?n.mobile:void 0}),tour:s&&typeof s=="object"?{once:s.once==="session"?"session":"visitor"}:void 0,pageAccess:e.pageAccess===true}};var vt=()=>new URLSearchParams(window.location.search).get("page")==="1",bt=()=>{let t=new URLSearchParams(window.location.hash.slice(1)),e=t.get(x);if(e)return window.history.replaceState(null,"",window.location.pathname+window.location.search),{token:e,led:t.get("led")==="1"}},St=({projection:t,hostOrigin:e$1})=>{let{behaviour:n}=t,[r]=useState(()=>Oe(e$1,t.deployId));useEffect(()=>r.dispose,[r]);let[o]=useState(()=>vt()?r.pageHost:void 0),[i]=useState(()=>({kept:bt(),onState:k=>A(window.parent,e$1,t.deployId,{type:"event",payload:{name:w,detail:{token:k}}})})),p=useMemo(()=>({deployId:t.deployId,mode:t.mode,avatar:{avatarId:t.avatarId,greeting:n?.greeting},connectTone:n?.connectTone,transcript:n?.transcript}),[t.deployId,t.mode,t.avatarId,n]);return At(),jsx(e,{config:p,embedHostOrigin:e$1,pageHost:o,embedResume:i,children:jsx(kt,{projection:t,hostOrigin:e$1,channel:r,carriesOn:!!i.kept})})},kt=({projection:t$2,hostOrigin:e,channel:n,carriesOn:r})=>{let o=h(),{_sendActionUi:i}=g(),p=t(),{flow:k}=D(),[T,s$2]=useState(null),[d,h$1]=useState(0),[a,m]=useState(null),u=useRef(new Map),f=useRef(new Map),P=useRef([]),V=useRef(0),{deployId:M,configVersion:x,mode:N}=t$2,c=useMemo(()=>({...t$2.appearance,...a?.config.appearance}),[t$2.appearance,a]),w=useMemo(()=>C(c),[c]),C$1=useMemo(()=>C(t$2.appearance).position,[t$2.appearance]),I=useMemo(()=>a?.config.tour?{...t$2.tour,generate:true,once:a.config.tour.once}:t$2.tour,[t$2.tour,a]),oe=useMemo(()=>a&&I?n.tourPage(`af-tour:site:${e}`,I.highlightColor):void 0,[n,a,I]),y=useCallback(l=>{window.parent!==window&&A(window.parent,e,M,l);},[e,M]),se=d>=2,Ne=useMemo(()=>se?{...c,draggable:c.draggable??true,teaser:void 0}:{...c,offset:{x:0,y:0},draggable:false,teaser:void 0},[c,se]),ge=useCallback(l=>{P.current.forEach(R=>R()),P.current=l.flatMap(R=>{let v=Object.values(R.params??{}).some(A=>A.check),E=o.registerAction?.({...R,handler:(A,{callId:g,signal:S})=>new Promise(O=>{u.current.set(g,O),S.addEventListener("abort",()=>u.current.delete(g)),y({type:"action.run",payload:{callId:g,name:R.name,args:A}});}),...v&&{check:(A,g,S)=>new Promise(O=>{let q=`check-${++V.current}`;f.current.set(q,O),setTimeout(()=>f.current.delete(q),s),y({type:"action.check",payload:{checkId:q,name:R.name,param:A,value:g,args:S}});})}});return E?[E]:[]});},[o,y]);useEffect(()=>{let l=R=>{let v=z$2(R,{origin:e,deployId:M,direction:"from-loader",source:window.parent});if(v)switch(v.type){case "host.info":{let{w:E,h:A}=v.payload.viewport;s$2(S=>S&&S.w===E&&S.h===A?S:{w:E,h:A}),h$1(v.payload.frameLayout??0);let g={config:Ve(v.payload.config)};m(S=>S&&JSON.stringify(S)===JSON.stringify(g)?S:g);return}case "context.set":o.addLiveContext?.({context:v.payload.context});return;case "context.event":o.addLiveContext?.({context:`${v.payload.name}: ${v.payload.context}`,update:true});return;case "cmd.open":p.open();return;case "cmd.close":p.close();return;case "cmd.start":o.start?.();return;case "cmd.stop":case "cmd.destroy":o.stop?.();return;case "action.set":ge(v.payload.actions);return;case "action.result":{let{callId:E,ok:A,result:g,error:S}=v.payload,O=u.current.get(E);u.current.delete(E),O?.(A?{ok:true,result:g}:{ok:false,error:S??"failed"});return}case "action.check_result":{let{checkId:E,ok:A,reason:g,suggestions:S,param:O,value:q}=v.payload,Ue=f.current.get(E);f.current.delete(E),Ue?.(A?{ok:true,value:q}:{ok:false,reason:g,suggestions:S,param:O});return}case "action.ui":i(v.payload.op,v.payload.args,v.payload.name);return}};return window.addEventListener("message",l),()=>window.removeEventListener("message",l)},[e,M,o,p,ge,i]),useEffect(()=>()=>P.current.forEach(l=>l()),[]),useEffect(()=>{y({type:"ready",payload:{configVersion:x,mode:N,position:C$1}});},[y,x,N,C$1]),useEffect(()=>{let l=(g,S)=>y({type:"event",payload:{name:g,detail:S}}),R=()=>l("start"),v=()=>l("stop"),E=g=>l("notice",{kind:g.kind,action:g.action}),A=g=>l("error",{code:g.code,fatal:g.fatal,cause:t$1(g)});return o.on?.("start",R),o.on?.("stop",v),o.on?.("notice",E),o.on?.("error",A),()=>{o.off?.("start",R),o.off?.("stop",v),o.off?.("notice",E),o.off?.("error",A);}},[o.on,o.off,y]);let he=useRef(false);useEffect(()=>{!r||he.current||(he.current=true,p.open(),o.start?.());},[r,p,o]),useEffect(()=>{y({type:"event",payload:{name:"speaking",detail:{speaking:o.isSpeaking}}});},[o.isSpeaking,y]),useEffect(()=>{y({type:"action.flow",payload:{flow:k}});},[k,y]);let We=useCallback(l=>y({type:"resize",payload:{w:l.w,h:l.h,position:l.position,sheet:l.sheet,offset:w.offset,left:l.left,top:l.top,gutter:l.gutter}}),[y,w.offset]),me=useRef(null),Fe=useCallback(l=>{l!==me.current&&(me.current=l,y({type:"state",payload:{stage:l}}));},[y]);return !T||!a?null:a.config.layout==="inline"?jsx(wt,{}):jsx(s$1,{appearance:Ne,hostViewport:T,framed:se,tour:I,tourPage:oe,onResize:We,onStageChange:Fe})},wt=()=>(g()._setMountSurface("inline"),jsx("div",{style:{width:"100vw",height:"100vh"},children:jsx(r,{style:{width:"100%",height:"100%"}})})),At=()=>{useEffect(()=>{for(let t of [document.documentElement,document.body])Object.assign(t.style,{background:"transparent",margin:"0",overflow:"hidden",colorScheme:"normal",fontFamily:"system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif"});},[]);};var En=e,Tn=()=>g()._skipNextGreeting,Pn=()=>g()._rigActivity.subscribe;export{et as AvatarEngineHost,En as AvatarProvider,St as EmbedRuntime,it as RemoteAvatarProvider,Pn as useRigActivity,Tn as useSkipNextGreeting};
1
+ import {e,d,c,A,w,h,g,t,D,s as s$1,r,b as b$2,x,z as z$2,i}from'./chunk-6Q2I7WKW.mjs';export{r as Avatar,j as AvatarConnectingLoader,s as AvatarWidget,u as BRIDGE_NAMESPACE,v as BRIDGE_VERSION,y as buildEnvelope,l as getRiveRendererStatus,m as onRiveRendererEvent,z as parseBridgeMessage,A as postBridgeMessage,a as setScriptUrls,n as simulateRiveContextLoss,h as useAvatar,C as useAvatarAction,D as useAvatarActionFlow,B as useAvatarEvent,t as useAvatarWidget,q as useRiveFrameHold,o as useRiveRenderGeneration,p as useRiveRendererStatus,k as watchRiveRenderer}from'./chunk-6Q2I7WKW.mjs';import {C,s,z as z$1,b as b$1,p,N,A as A$1,y,t as t$1,e as e$1}from'./chunk-WOQBPJGB.mjs';export{v as PaintPhase,u as SessionPhase,w as TurnPhase,B as WIDGET_DEFAULTS,z as createRemotePageSurface,C as resolveWidgetAppearance}from'./chunk-WOQBPJGB.mjs';import {useRef,useMemo,useState,useEffect,useCallback}from'react';import {jsx}from'react/jsx-runtime';var Q=()=>performance.timeOrigin+performance.now();var $e=500,Ye="1",Z=class{constructor(e){this.deps=e;this.player=null;this.epoch=null;this.jobId=null;this.nextChunk=0;this.muted=false;this.job=null;this.refreshTimer=null;this.controls={pause:()=>this.player?.pause(),resume:()=>this.player?.resume(),getOutputLevel:()=>this.player?.getOutputLevel()??0,hasPendingAudio:()=>this.player?.hasPendingAudio()??false,reset:()=>this.reset()};}speak(e){e.sessionId!==this.epoch&&(this.dropPlayer(),this.epoch=e.sessionId,this.jobId=null),e.jobId!==this.jobId&&(this.jobId=e.jobId,this.nextChunk=0,this.job=null);let n={...e,audioChunks:e.audioChunks.map(i=>i?Ye:"")};this.job=ce(this.job,n),this.deps.emit({t:"speech",job:n});let r=this.player??this.makePlayer(),o=Math.max(0,this.nextChunk-e.chunkOffset);for(let i=o;i<e.audioChunks.length;i++){this.nextChunk=e.chunkOffset+i+1;let p=e.audioChunks[i];if(!p)continue;let k=e.alignments[i];k?r.enqueueChunk(p,k.character_start_times_seconds[0]??0):r.enqueueSequentialChunk(p);}}reset(){this.dropPlayer(),this.nextChunk=0,this.jobId=null,this.job=null,this.deps.emit({t:"speech.reset"});}resetSession(){this.reset(),this.epoch=null;}setMuted(e){this.muted=e,this.player?.setMuted(e);}anchor(){let e=this.player;return {epoch:this.epoch,alignmentSec:e?e.getAlignmentTime():e$1,playableSec:e?.getPlayableAlignmentTime()??0,at:Q(),paused:e?.isPaused()??false,scheduled:e?.isPlaybackScheduled()??false,active:e?.isAudioActive()??false,pending:e?.hasPendingAudio()??false}}snapshot(){return [...this.job?[{t:"speech",job:this.job}]:[],{t:"anchor",anchor:this.anchor()}]}destroy(){this.dropPlayer();}makePlayer(){let e=this.epoch,n=new i(()=>{this.deps.onEnded(),this.deps.emit({t:"speech.ended",epoch:e});},this.deps.getAudioContext());return n.setMuted(this.muted),n.onTimeline=()=>this.emitAnchor(),this.player=n,this.deps.publishClock(()=>n.isPlaybackScheduled()?n.getAlignmentTime():null),this.refreshTimer=setInterval(()=>{n.isPlaybackScheduled()&&this.emitAnchor();},$e),n}emitAnchor(){this.deps.emit({t:"anchor",anchor:this.anchor()});}dropPlayer(){this.refreshTimer&&clearInterval(this.refreshTimer),this.refreshTimer=null;let e=this.player;e&&(this.player=null,e.onTimeline=void 0,e.destroy(),this.deps.publishClock(null));}},ce=(t,e)=>{if(!t)return {...e};let n={...t,audioChunks:[...t.audioChunks],alignments:[...t.alignments],...t.displayAlignments&&{displayAlignments:[...t.displayAlignments]},...(t.visemes||e.visemes)&&{visemes:[...t.visemes??t.alignments.map(()=>null)]}};return e.audioChunks.forEach((r,o)=>{e.chunkOffset+o===t.chunkOffset+n.audioChunks.length&&(n.audioChunks.push(r),n.alignments.push(e.alignments[o]??null),n.displayAlignments?.push(e.displayAlignments?.[o]??null),n.visemes?.push(e.visemes?.[o]??null));}),n};var le=class{constructor(e,n){this.link=e;this.visible=new Map;this.front=null;this.nextCallId=0;this.pending=new Map;this.pageListeners=new Set;this.pageHost={browser:n,surface:z$1(r=>this.callFront(r)),watch:r=>(this.pageListeners.add(r),()=>this.pageListeners.delete(r)),pageBeforeLive:true};}handle(e,n){switch(n.t){case "visible":return n.visible?this.visible.set(e,Date.now()):this.visible.delete(e),this.pickFront(n.visible?e:null),true;case "page.reply":{let r=this.pending.get(n.id);return !r||r.viewId!==e||(this.pending.delete(n.id),n.ok?r.resolve(n.value):r.reject(new Error(n.error??"the page call failed"))),true}case "page.changed":return e===this.front&&this.pageChanged(),true;default:return false}}leave(e){this.visible.delete(e);for(let[n,r]of this.pending)r.viewId===e&&(this.pending.delete(n),r.reject(new Error("the page closed")));this.front===e&&this.pickFront(null);}pickFront(e){let n=e;if(!n||!this.visible.has(n)){n=null;let r=-1;for(let[o,i]of this.visible)i>r&&([n,r]=[o,i]);}n!==this.front&&(this.front=n,b$1.debug("EngineHost","front view changed",{front:n}),this.pageChanged());}pageChanged(){for(let e of this.pageListeners)e();}callFront(e){let n=this.front;if(!n)return Promise.reject(new Error("no page is in front"));let r=++this.nextCallId;return new Promise((o,i)=>{this.pending.set(r,{resolve:o,reject:i,viewId:n}),this.link.send(n,{t:"page.call",id:r,call:e});})}},Qe=t=>{let{error:e}=t;return {isReady:t.isReady,isLoading:t.isLoading,isConnecting:t.isConnecting,isSpeaking:t.isSpeaking,isListening:t.isListening,isThinking:t.isThinking,isResponseSlow:t.isResponseSlow,isIdle:t.isIdle,isFailed:t.isFailed,isConnected:t.isConnected,isMicMuted:t.isMicMuted,isSpeakerMuted:t.isSpeakerMuted,isPushToTalk:t.isPushToTalk,isTalking:t.isTalking,availableActions:t.availableActions,notice:t.notice,avatarId:t.avatarId,mode:t.mode,error:e?{code:e.code,message:e.message,source:e.source,fatal:e.fatal,retryable:e.retryable}:null,resetToken:t._resetToken,riveKey:t._riveKey,avatarConfig:t._avatarConfig,shouldArmTalking:t._shouldArmTalking,userActivity:t._userActivity,thinkingSignal:t._thinkingSignal,visualState:t._visualState,tuning:{...t._lipSyncTuning}}};function Ze({link:t,views:e}){let n=g(),r=useRef(n);r.current=n;let o=useMemo(()=>new Z({getAudioContext:()=>r.current._getAudioContext(),onEnded:()=>r.current._onPlaybackEnd(),publishClock:s=>r.current._registerSpeechClock(s),emit:s=>t.broadcast(s)}),[t]);useEffect(()=>()=>o.destroy(),[o]),useEffect(()=>{r.current._registerPlaybackControls(o.controls);let s=r.current._onSpeechJob(d=>o.speak(d));return ()=>{s(),r.current._registerPlaybackControls(null);}},[o]);let i=useRef(n._resetToken);useEffect(()=>{n._resetToken!==i.current&&(i.current=n._resetToken,o.resetSession());},[n._resetToken,o]),useEffect(()=>o.setMuted(n._speakerMuted),[n._speakerMuted,o]),useEffect(()=>{n._avatarConfig&&r.current._onRiveReady?.();},[n._avatarConfig,n._riveKey]);let p=Qe(n),k=JSON.stringify(p),T=useRef(p);return T.current=p,useEffect(()=>{t.broadcast({t:"state",state:T.current});},[t,k]),useEffect(()=>n._transcriptStore.subscribe(()=>t.broadcast({t:"transcript",entries:r.current._transcriptStore.getSnapshot().slice(-200)})),[n._transcriptStore,t]),useEffect(()=>n._healthStore.subscribe(()=>t.broadcast({t:"health",health:r.current._healthStore.getSnapshot()})),[n._healthStore,t]),useEffect(()=>{let s=r.current._gestureQueue.current;s.length!==0&&t.broadcast({t:"gestures",gestures:s.splice(0,s.length)});},[n._gestureSignal,t]),useEffect(()=>t.onMessage((s,d)=>{if(e.handle(s,d))return;let h=r.current;switch(d.t){case "join":{let a=[{t:"state",state:T.current},{t:"transcript",entries:h._transcriptStore.getSnapshot().slice(-200)},{t:"health",health:h._healthStore.getSnapshot()},...o.snapshot()];for(let m of a)t.send(s,m);return}case "cmd":d.cmd==="start"?h.start():d.cmd==="stop"?h.stop():d.cmd==="interrupt"?h.interrupt():d.cmd==="stopSpeaking"?h.stopSpeaking():d.cmd==="startTalking"?h.startTalking():d.cmd==="stopTalking"?h.stopTalking():d.cmd==="skipNextGreeting"&&h._skipNextGreeting();return;case "mic":h.setMicMuted(d.muted);return;case "speaker":h.setSpeakerMuted(d.muted);return;case "trigger":h.triggerAction?.(d.name);return;case "avatarClick":h._avatarClicked?.();return;case "surface":h._setMountSurface(d.surface);return;case "rive.ready":return}}),[t,e,o]),useEffect(()=>t.onLeave(s=>e.leave(s)),[t,e]),null}function et({config:t,link:e$1,browser:n}){let r=useRef(n),o=useMemo(()=>new le(e$1,r.current),[e$1]);return jsx(e,{config:t,pageHost:o.pageHost,children:jsx(Ze,{link:e$1,views:o})})}var te=class{constructor(){this.anchor=null;this.epoch=null;this.players=new Set;this.createPlayer=e=>{let n=new pe(this,e,()=>this.players.delete(n));return this.players.add(n),n};}setEpoch(e){this.epoch=e;}setAnchor(e){this.anchor=e;}ended(e){if(!(e!==null&&e!==this.epoch))for(let n of [...this.players])n.end();}current(){let e=this.anchor;return e&&e.epoch===this.epoch?e:null}},pe=class{constructor(e,n,r){this.speech=e;this.onEnded=n;this.release=r;}enqueueChunk(){}enqueueSequentialChunk(){}pause(){}resume(){}setMuted(){}playBeep(){}getAlignmentTime(){let e=this.speech.current();return !e||e.alignmentSec===e$1?e$1:e.paused?e.alignmentSec:e.alignmentSec+(Q()-e.at)/1e3}getPlayableAlignmentTime(){return this.speech.current()?.playableSec??0}isPlaybackScheduled(){return this.speech.current()?.scheduled??false}isAudioActive(){return this.speech.current()?.active??false}hasPendingAudio(){return this.speech.current()?.pending??false}getOutputLevel(){return 0}end(){this.onEnded();}destroy(){this.release();}};var nt={services:{ingest:"ok",stt:"ok",llm:"ok",tts:"ok",downlink:"ok"},concern:null},b=()=>{},rt=(t,e,n)=>{let[r,o]=useState(null),[i,p$1]=useState(null),[k,T]=useState(0),s=useMemo(()=>new te,[]),d=useMemo(()=>new p,[]),h=useMemo(()=>new b$2,[]),a=useMemo(()=>N([]),[]),m=useMemo(()=>N(nt),[]),u=useMemo(()=>N(null),[]),f=useRef([]),P=useRef(null),V=useRef(null),M=useRef(n);useEffect(()=>{let c=e.onMessage(w=>{switch(w.t){case "state":Object.assign(d,w.state.tuning),o(w.state);return;case "speech":s.setEpoch(w.job.sessionId),p$1(C=>C&&C.sessionId===w.job.sessionId&&C.jobId===w.job.jobId?ce(C,w.job):{...w.job});return;case "anchor":s.setAnchor(w.anchor);return;case "speech.ended":s.ended(w.epoch);return;case "speech.reset":P.current?.reset(),p$1(null);return;case "gestures":f.current.push(...w.gestures),T(C=>C+1);return;case "transcript":a.set(w.entries);return;case "health":m.set(w.health);return;case "page.call":{let C=M.current?.surface,{id:I,call:oe}=w;if(!C){e.send({t:"page.reply",id:I,ok:false,error:"no page here"});return}Promise.resolve().then(()=>A$1(C,oe)).then(y=>e.send({t:"page.reply",id:I,ok:true,value:y}),y=>e.send({t:"page.reply",id:I,ok:false,error:String(y)}));return}}});return e.send({t:"join",protocol:1}),c},[e,s,d,a,m]),useEffect(()=>{let c=()=>e.send({t:"visible",visible:document.visibilityState==="visible"});return c(),document.addEventListener("visibilitychange",c),()=>document.removeEventListener("visibilitychange",c)},[e]),useEffect(()=>M.current?.watch(()=>e.send({t:"page.changed"})),[e]);let x=useCallback(c=>e.send({t:"cmd",cmd:c}),[e]),N$1=t.transcript;return {isReady:r?.isReady??false,isLoading:r?.isLoading??true,isConnecting:r?.isConnecting??false,isSpeaking:r?.isSpeaking??false,isListening:r?.isListening??false,isThinking:r?.isThinking??false,isResponseSlow:r?.isResponseSlow??false,isIdle:r?.isIdle??true,isFailed:r?.isFailed??false,isConnected:r?.isConnected??false,isMicMuted:r?.isMicMuted??false,isSpeakerMuted:r?.isSpeakerMuted??false,isPushToTalk:r?.isPushToTalk??false,isTalking:r?.isTalking??false,availableActions:r?.availableActions??[],notice:r?.notice??null,avatarId:r?.avatarId??t.avatar?.avatarId,error:r?.error??null,controls:{enabled:t.controls?.enabled||false,stopSpeaking:t.controls?.stopSpeaking||false},mode:t.mode||"call",setMicMuted:c=>e.send({t:"mic",muted:c}),setSpeakerMuted:c=>e.send({t:"speaker",muted:c}),isMoodDetectionAvailable:false,isMoodDetectionOn:false,setMoodDetection:b,startTalking:()=>x("startTalking"),stopTalking:()=>x("stopTalking"),start:async()=>x("start"),stop:()=>x("stop"),interrupt:()=>x("interrupt"),stopSpeaking:()=>x("stopSpeaking"),triggerAction:c=>e.send({t:"trigger",name:c}),on:b,off:b,speakText:b,speakAudio:b,play:b,addLiveContext:b,notify:b,readPage:async()=>null,registerAction:()=>b,setLipSyncTuning:b,_healthStore:m,_transcriptStore:a,_actionFlowStore:u,_sendActionUi:()=>false,_currentJob:i,_onPlaybackEnd:b,_onRiveReady:()=>e.send({t:"rive.ready"}),_onRiveError:c=>b$1.warn("RemoteAvatar","rig failed to load",{error:String(c)}),_resetToken:r?.resetToken??0,_mode:t.mode||"call",_setMountSurface:c=>e.send({t:"surface",surface:c}),_onWidgetCommand:()=>b,_reportWidgetStatus:b,_onSpeechJob:()=>b,_requestTour:async()=>null,_skipNextGreeting:()=>x("skipNextGreeting"),_riveKey:r?.riveKey??"",_avatarConfig:r?.avatarConfig??null,_shouldArmTalking:r?.shouldArmTalking??false,_userActivity:r?.userActivity??0,_thinkingSignal:r?.thinkingSignal??0,_speakerMuted:r?.isSpeakerMuted??false,_gestureQueue:f,_gestureSignal:k,_avatarClicked:()=>e.send({t:"avatarClick"}),_lipSyncTuning:d,_rigActivity:h,_visualState:r?.visualState??"normal",_camera:ot,_screen:st,_screenSharePosition:t.screenShare?.position??"top-center",_captionsEnabled:!!N$1?.enabled&&N$1.captions!==false,_captionPosition:N$1?.position??"bottom-center",_statusBannerEnabled:t.statusBanner?.enabled!==false,_statusBannerPosition:t.statusBanner?.position??"bottom-left",_thinkingIndicatorEnabled:t.thinkingIndicator?.enabled!==false,_thinkingIndicatorPosition:t.thinkingIndicator?.position??"top-left",_speechClockRef:V,_registerSpeechClock:c=>{V.current=c;},_registerPlaybackControls:c=>{P.current=c;},_getAudioContext:()=>null,_createSpeechPlayer:s.createPlayer,_spacebarToTalk:t.turnTaking?.spacebar!==false}},ot={stream:null,facing:"user",sessionOpen:false,toggleVideo:b,flip:b,mood:null},st={phase:"idle",share:b,dismiss:b,stop:b};function it({config:t,link:e,pageHost:n,children:r}){let o=rt(t,e,n);return jsx(d.Provider,{value:o,children:jsx(c,{children:r})})}var at=2600,ct=t=>!!t&&typeof t=="object"&&["left","top","width","height"].every(e=>Number.isFinite(t[e])),Oe=(t,e)=>{let n=new Map,r=new Map,o=new Set,i=0,p=a=>{window.parent!==window&&A(window.parent,t,e,a);},k=a=>{let m=z$2(a,{origin:t,deployId:e,direction:"from-loader",source:window.parent});if(m)switch(m.type){case "page.result":{let{callId:u,ok:f,value:P,error:V}=m.payload,M=n.get(u);n.delete(u),f?M?.resolve(P):M?.reject(new Error(V??"the page refused"));return}case "page.changed":o.forEach(u=>u());return;case "tour.result":{let{seq:u,found:f,rect:P}=m.payload;r.get(u)?.({found:f===true,rect:ct(P)?P:void 0}),r.delete(u);return}}};window.addEventListener("message",k);let T={surface:z$1(a=>new Promise((m,u)=>{let f=`p${++i}`;n.set(f,{resolve:m,reject:u}),setTimeout(()=>n.delete(f),y),p({type:"page.call",payload:{callId:f,call:a}});})),watch:a=>(o.add(a),()=>o.delete(a)),pageBeforeLive:true},s=a=>new Promise(m=>{let u=++i,f=setTimeout(()=>{r.delete(u),m({found:false});},at);r.set(u,P=>{clearTimeout(f),m(P);}),p({type:"tour.do",payload:{seq:u,...a}});});return {pageHost:T,tourPage:(a,m)=>({seenKey:a,scroll:async u=>(await s({op:"scroll",target:u})).rect??null,mark:async(u,f)=>(await s({op:"mark",target:u,strong:f,color:m})).found,clear:()=>{s({op:"clear"});},scrollTop:()=>{s({op:"top"});}}),dispose:()=>window.removeEventListener("message",k)}};var lt=new Set(["bottom-right","bottom-left","top-right","top-left"]),pt=new Set(["sheet","corner"]),Be={min:0,max:200},ut={min:40,max:160},dt={min:280,max:640},gt={min:360,max:900},ht=/^(#[0-9a-f]{3,8}|rgba?\(\s*[\d.]+%?\s*,\s*[\d.]+%?\s*,\s*[\d.]+%?\s*(,\s*[\d.]+%?\s*)?\))$/i,z=(t,e)=>typeof t=="number"&&Number.isFinite(t)?Math.min(e.max,Math.max(e.min,Math.round(t))):void 0,mt=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),Ve=t=>{let e=t&&typeof t=="object"?t:{},n=e.appearance&&typeof e.appearance=="object"?e.appearance:{},r=n.offset,o=n.panel,i=z(r?.x,Be),p=z(r?.y,Be),k=z(o?.w,dt),T=z(o?.h,gt),s=e.tour;return {layout:e.layout==="inline"?"inline":"widget",appearance:mt({position:typeof n.position=="string"&&lt.has(n.position)?n.position:void 0,offset:i!==void 0&&p!==void 0?{x:i,y:p}:void 0,bubbleSize:z(n.bubbleSize,ut),panel:k!==void 0&&T!==void 0?{w:k,h:T}:void 0,accent:typeof n.accent=="string"&&ht.test(n.accent.trim())?n.accent.trim():void 0,draggable:typeof n.draggable=="boolean"?n.draggable:void 0,mobile:typeof n.mobile=="string"&&pt.has(n.mobile)?n.mobile:void 0}),tour:s&&typeof s=="object"?{once:s.once==="session"?"session":"visitor"}:void 0,pageAccess:e.pageAccess===true}};var vt=()=>new URLSearchParams(window.location.search).get("page")==="1",bt=()=>{let t=new URLSearchParams(window.location.hash.slice(1)),e=t.get(x);if(e)return window.history.replaceState(null,"",window.location.pathname+window.location.search),{token:e,led:t.get("led")==="1"}},St=({projection:t,hostOrigin:e$1})=>{let{behaviour:n}=t,[r]=useState(()=>Oe(e$1,t.deployId));useEffect(()=>r.dispose,[r]);let[o]=useState(()=>vt()?r.pageHost:void 0),[i]=useState(()=>({kept:bt(),onState:k=>A(window.parent,e$1,t.deployId,{type:"event",payload:{name:w,detail:{token:k}}})})),p=useMemo(()=>({deployId:t.deployId,mode:t.mode,avatar:{avatarId:t.avatarId,greeting:n?.greeting},connectTone:n?.connectTone,transcript:n?.transcript}),[t.deployId,t.mode,t.avatarId,n]);return At(),jsx(e,{config:p,embedHostOrigin:e$1,pageHost:o,embedResume:i,children:jsx(kt,{projection:t,hostOrigin:e$1,channel:r,carriesOn:!!i.kept})})},kt=({projection:t$2,hostOrigin:e,channel:n,carriesOn:r})=>{let o=h(),{_sendActionUi:i}=g(),p=t(),{flow:k}=D(),[T,s$2]=useState(null),[d,h$1]=useState(0),[a,m]=useState(null),u=useRef(new Map),f=useRef(new Map),P=useRef([]),V=useRef(0),{deployId:M,configVersion:x,mode:N}=t$2,c=useMemo(()=>({...t$2.appearance,...a?.config.appearance}),[t$2.appearance,a]),w=useMemo(()=>C(c),[c]),C$1=useMemo(()=>C(t$2.appearance).position,[t$2.appearance]),I=useMemo(()=>a?.config.tour?{...t$2.tour,generate:true,once:a.config.tour.once}:t$2.tour,[t$2.tour,a]),oe=useMemo(()=>a&&I?n.tourPage(`af-tour:site:${e}`,I.highlightColor):void 0,[n,a,I]),y=useCallback(l=>{window.parent!==window&&A(window.parent,e,M,l);},[e,M]),se=d>=2,Ne=useMemo(()=>se?{...c,draggable:c.draggable??true,teaser:void 0}:{...c,offset:{x:0,y:0},draggable:false,teaser:void 0},[c,se]),ge=useCallback(l=>{P.current.forEach(R=>R()),P.current=l.flatMap(R=>{let v=Object.values(R.params??{}).some(A=>A.check),E=o.registerAction?.({...R,handler:(A,{callId:g,signal:S})=>new Promise(O=>{u.current.set(g,O),S.addEventListener("abort",()=>u.current.delete(g)),y({type:"action.run",payload:{callId:g,name:R.name,args:A}});}),...v&&{check:(A,g,S)=>new Promise(O=>{let q=`check-${++V.current}`;f.current.set(q,O),setTimeout(()=>f.current.delete(q),s),y({type:"action.check",payload:{checkId:q,name:R.name,param:A,value:g,args:S}});})}});return E?[E]:[]});},[o,y]);useEffect(()=>{let l=R=>{let v=z$2(R,{origin:e,deployId:M,direction:"from-loader",source:window.parent});if(v)switch(v.type){case "host.info":{let{w:E,h:A}=v.payload.viewport;s$2(S=>S&&S.w===E&&S.h===A?S:{w:E,h:A}),h$1(v.payload.frameLayout??0);let g={config:Ve(v.payload.config)};m(S=>S&&JSON.stringify(S)===JSON.stringify(g)?S:g);return}case "context.set":o.addLiveContext?.({context:v.payload.context});return;case "context.event":o.addLiveContext?.({context:`${v.payload.name}: ${v.payload.context}`,update:true});return;case "cmd.open":p.open();return;case "cmd.close":p.close();return;case "cmd.start":o.start?.();return;case "cmd.stop":case "cmd.destroy":o.stop?.();return;case "action.set":ge(v.payload.actions);return;case "action.result":{let{callId:E,ok:A,result:g,error:S}=v.payload,O=u.current.get(E);u.current.delete(E),O?.(A?{ok:true,result:g}:{ok:false,error:S??"failed"});return}case "action.check_result":{let{checkId:E,ok:A,reason:g,suggestions:S,param:O,value:q}=v.payload,Ue=f.current.get(E);f.current.delete(E),Ue?.(A?{ok:true,value:q}:{ok:false,reason:g,suggestions:S,param:O});return}case "action.ui":i(v.payload.op,v.payload.args,v.payload.name);return}};return window.addEventListener("message",l),()=>window.removeEventListener("message",l)},[e,M,o,p,ge,i]),useEffect(()=>()=>P.current.forEach(l=>l()),[]),useEffect(()=>{y({type:"ready",payload:{configVersion:x,mode:N,position:C$1}});},[y,x,N,C$1]),useEffect(()=>{let l=(g,S)=>y({type:"event",payload:{name:g,detail:S}}),R=()=>l("start"),v=()=>l("stop"),E=g=>l("notice",{kind:g.kind,action:g.action}),A=g=>l("error",{code:g.code,fatal:g.fatal,cause:t$1(g)});return o.on?.("start",R),o.on?.("stop",v),o.on?.("notice",E),o.on?.("error",A),()=>{o.off?.("start",R),o.off?.("stop",v),o.off?.("notice",E),o.off?.("error",A);}},[o.on,o.off,y]);let he=useRef(false);useEffect(()=>{!r||he.current||(he.current=true,p.open(),o.start?.());},[r,p,o]),useEffect(()=>{y({type:"event",payload:{name:"speaking",detail:{speaking:o.isSpeaking}}});},[o.isSpeaking,y]),useEffect(()=>{y({type:"action.flow",payload:{flow:k}});},[k,y]);let We=useCallback(l=>y({type:"resize",payload:{w:l.w,h:l.h,position:l.position,sheet:l.sheet,offset:w.offset,left:l.left,top:l.top,gutter:l.gutter}}),[y,w.offset]),me=useRef(null),Fe=useCallback(l=>{l!==me.current&&(me.current=l,y({type:"state",payload:{stage:l}}));},[y]);return !T||!a?null:a.config.layout==="inline"?jsx(wt,{}):jsx(s$1,{appearance:Ne,hostViewport:T,framed:se,tour:I,tourPage:oe,onResize:We,onStageChange:Fe})},wt=()=>(g()._setMountSurface("inline"),jsx("div",{style:{width:"100vw",height:"100vh"},children:jsx(r,{style:{width:"100%",height:"100%"}})})),At=()=>{useEffect(()=>{for(let t of [document.documentElement,document.body])Object.assign(t.style,{background:"transparent",margin:"0",overflow:"hidden",colorScheme:"normal",fontFamily:"system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif"});},[]);};var En=e,Tn=()=>g()._skipNextGreeting,Pn=()=>g()._rigActivity.subscribe;export{et as AvatarEngineHost,En as AvatarProvider,St as EmbedRuntime,it as RemoteAvatarProvider,Pn as useRigActivity,Tn as useSkipNextGreeting};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@avatarfactory/react",
3
- "version": "0.1.40",
3
+ "version": "0.1.41",
4
4
  "description": "A React SDK for embedding real-time talking avatars with voice, lip-sync, and live conversations.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -29,7 +29,6 @@
29
29
  },
30
30
  "files": [
31
31
  "dist",
32
- "!dist/framer",
33
32
  "THIRD_PARTY_LICENSES.md"
34
33
  ],
35
34
  "sideEffects": [
@@ -63,6 +62,9 @@
63
62
  "typescript-plugin-css-modules": "^5.2.0",
64
63
  "vitest": "^2.1.9"
65
64
  },
66
- "homepage": "https://avatarfactory-ui-demo.vercel.app/docs",
67
- "license": "SEE LICENSE IN LICENSE"
65
+ "homepage": "https://www.avatarfactory.in/docs",
66
+ "license": "SEE LICENSE IN LICENSE",
67
+ "publishConfig": {
68
+ "access": "public"
69
+ }
68
70
  }