holostaff-widget 3.0.14 → 3.0.16

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.
Files changed (24) hide show
  1. package/dist/{CanvasRenderer-CGmwXsA3.js → CanvasRenderer-CprGagIN.js} +5 -5
  2. package/dist/{CanvasRenderer-CGmwXsA3.js.map → CanvasRenderer-CprGagIN.js.map} +1 -1
  3. package/dist/{Filter-Cv9YaQJe.js → Filter-qbkxNVeE.js} +2 -2
  4. package/dist/{Filter-Cv9YaQJe.js.map → Filter-qbkxNVeE.js.map} +1 -1
  5. package/dist/{GpuStencilModesToPixi-D0RHrt7V.js → GpuStencilModesToPixi-BnseRxoy.js} +3 -3
  6. package/dist/{GpuStencilModesToPixi-D0RHrt7V.js.map → GpuStencilModesToPixi-BnseRxoy.js.map} +1 -1
  7. package/dist/{RenderTargetSystem-zWkrwY4k.js → RenderTargetSystem-BwX2InSy.js} +3 -3
  8. package/dist/{RenderTargetSystem-zWkrwY4k.js.map → RenderTargetSystem-BwX2InSy.js.map} +1 -1
  9. package/dist/{WebGLRenderer-B3OAer7k.js → WebGLRenderer-tpK2CgkV.js} +5 -5
  10. package/dist/{WebGLRenderer-B3OAer7k.js.map → WebGLRenderer-tpK2CgkV.js.map} +1 -1
  11. package/dist/{WebGPURenderer-D89NVi14.js → WebGPURenderer-BMDNxlA-.js} +6 -6
  12. package/dist/{WebGPURenderer-D89NVi14.js.map → WebGPURenderer-BMDNxlA-.js.map} +1 -1
  13. package/dist/{browserAll-Be_SS_qE.js → browserAll-Q4oQr3Sq.js} +3 -3
  14. package/dist/{browserAll-Be_SS_qE.js.map → browserAll-Q4oQr3Sq.js.map} +1 -1
  15. package/dist/{getTextureBatchBindGroup-BLI6QX4Z.js → getTextureBatchBindGroup-CiblA9bl.js} +3 -3
  16. package/dist/{getTextureBatchBindGroup-BLI6QX4Z.js.map → getTextureBatchBindGroup-CiblA9bl.js.map} +1 -1
  17. package/dist/hs-widget.es.js +1 -1
  18. package/dist/hs-widget.umd.js +1 -1
  19. package/dist/hs-widget.umd.js.map +1 -1
  20. package/dist/{index-CidWtnTb.js → index-Cr9XsSBX.js} +18 -21
  21. package/dist/{index-CidWtnTb.js.map → index-Cr9XsSBX.js.map} +1 -1
  22. package/dist/{webworkerAll-a6prFa0E.js → webworkerAll-LYuPX-gz.js} +3 -3
  23. package/dist/{webworkerAll-a6prFa0E.js.map → webworkerAll-LYuPX-gz.js.map} +1 -1
  24. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
- import { B as p } from "./Filter-Cv9YaQJe.js";
2
- import { T as a } from "./index-CidWtnTb.js";
1
+ import { B as p } from "./Filter-qbkxNVeE.js";
2
+ import { T as a } from "./index-Cr9XsSBX.js";
3
3
  const d = {};
4
4
  function G(t, o, u) {
5
5
  let e = 2166136261;
@@ -20,4 +20,4 @@ function f(t, o, u, e) {
20
20
  export {
21
21
  G as g
22
22
  };
23
- //# sourceMappingURL=getTextureBatchBindGroup-BLI6QX4Z.js.map
23
+ //# sourceMappingURL=getTextureBatchBindGroup-CiblA9bl.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getTextureBatchBindGroup-BLI6QX4Z.js","sources":["../node_modules/pixi.js/lib/rendering/batcher/gpu/getTextureBatchBindGroup.mjs"],"sourcesContent":["import { BindGroup } from '../../renderers/gpu/shader/BindGroup.mjs';\nimport { Texture } from '../../renderers/shared/texture/Texture.mjs';\n\n\"use strict\";\nconst cachedGroups = {};\nfunction getTextureBatchBindGroup(textures, size, maxTextures) {\n let uid = 2166136261;\n for (let i = 0; i < size; i++) {\n uid ^= textures[i].uid;\n uid = Math.imul(uid, 16777619);\n uid >>>= 0;\n }\n return cachedGroups[uid] || generateTextureBatchBindGroup(textures, size, uid, maxTextures);\n}\nfunction generateTextureBatchBindGroup(textures, size, key, maxTextures) {\n const bindGroupResources = {};\n let bindIndex = 0;\n for (let i = 0; i < maxTextures; i++) {\n const texture = i < size ? textures[i] : Texture.EMPTY.source;\n bindGroupResources[bindIndex++] = texture.source;\n bindGroupResources[bindIndex++] = texture.style;\n }\n const bindGroup = new BindGroup(bindGroupResources);\n cachedGroups[key] = bindGroup;\n return bindGroup;\n}\n\nexport { getTextureBatchBindGroup };\n//# sourceMappingURL=getTextureBatchBindGroup.mjs.map\n"],"names":["cachedGroups","getTextureBatchBindGroup","textures","size","maxTextures","uid","i","generateTextureBatchBindGroup","key","bindGroupResources","bindIndex","texture","Texture","bindGroup","BindGroup"],"mappings":";;AAIA,MAAMA,IAAe,CAAA;AACrB,SAASC,EAAyBC,GAAUC,GAAMC,GAAa;AAC7D,MAAIC,IAAM;AACV,WAASC,IAAI,GAAGA,IAAIH,GAAMG;AACxB,IAAAD,KAAOH,EAASI,CAAC,EAAE,KACnBD,IAAM,KAAK,KAAKA,GAAK,QAAQ,GAC7BA,OAAS;AAEX,SAAOL,EAAaK,CAAG,KAAKE,EAA8BL,GAAUC,GAAME,GAAKD,CAAW;AAC5F;AACA,SAASG,EAA8BL,GAAUC,GAAMK,GAAKJ,GAAa;AACvE,QAAMK,IAAqB,CAAA;AAC3B,MAAIC,IAAY;AAChB,WAASJ,IAAI,GAAGA,IAAIF,GAAaE,KAAK;AACpC,UAAMK,IAAUL,IAAIH,IAAOD,EAASI,CAAC,IAAIM,EAAQ,MAAM;AACvD,IAAAH,EAAmBC,GAAW,IAAIC,EAAQ,QAC1CF,EAAmBC,GAAW,IAAIC,EAAQ;AAAA,EAC5C;AACA,QAAME,IAAY,IAAIC,EAAUL,CAAkB;AAClD,SAAAT,EAAaQ,CAAG,IAAIK,GACbA;AACT;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"getTextureBatchBindGroup-CiblA9bl.js","sources":["../node_modules/pixi.js/lib/rendering/batcher/gpu/getTextureBatchBindGroup.mjs"],"sourcesContent":["import { BindGroup } from '../../renderers/gpu/shader/BindGroup.mjs';\nimport { Texture } from '../../renderers/shared/texture/Texture.mjs';\n\n\"use strict\";\nconst cachedGroups = {};\nfunction getTextureBatchBindGroup(textures, size, maxTextures) {\n let uid = 2166136261;\n for (let i = 0; i < size; i++) {\n uid ^= textures[i].uid;\n uid = Math.imul(uid, 16777619);\n uid >>>= 0;\n }\n return cachedGroups[uid] || generateTextureBatchBindGroup(textures, size, uid, maxTextures);\n}\nfunction generateTextureBatchBindGroup(textures, size, key, maxTextures) {\n const bindGroupResources = {};\n let bindIndex = 0;\n for (let i = 0; i < maxTextures; i++) {\n const texture = i < size ? textures[i] : Texture.EMPTY.source;\n bindGroupResources[bindIndex++] = texture.source;\n bindGroupResources[bindIndex++] = texture.style;\n }\n const bindGroup = new BindGroup(bindGroupResources);\n cachedGroups[key] = bindGroup;\n return bindGroup;\n}\n\nexport { getTextureBatchBindGroup };\n//# sourceMappingURL=getTextureBatchBindGroup.mjs.map\n"],"names":["cachedGroups","getTextureBatchBindGroup","textures","size","maxTextures","uid","i","generateTextureBatchBindGroup","key","bindGroupResources","bindIndex","texture","Texture","bindGroup","BindGroup"],"mappings":";;AAIA,MAAMA,IAAe,CAAA;AACrB,SAASC,EAAyBC,GAAUC,GAAMC,GAAa;AAC7D,MAAIC,IAAM;AACV,WAASC,IAAI,GAAGA,IAAIH,GAAMG;AACxB,IAAAD,KAAOH,EAASI,CAAC,EAAE,KACnBD,IAAM,KAAK,KAAKA,GAAK,QAAQ,GAC7BA,OAAS;AAEX,SAAOL,EAAaK,CAAG,KAAKE,EAA8BL,GAAUC,GAAME,GAAKD,CAAW;AAC5F;AACA,SAASG,EAA8BL,GAAUC,GAAMK,GAAKJ,GAAa;AACvE,QAAMK,IAAqB,CAAA;AAC3B,MAAIC,IAAY;AAChB,WAASJ,IAAI,GAAGA,IAAIF,GAAaE,KAAK;AACpC,UAAMK,IAAUL,IAAIH,IAAOD,EAASI,CAAC,IAAIM,EAAQ,MAAM;AACvD,IAAAH,EAAmBC,GAAW,IAAIC,EAAQ,QAC1CF,EAAmBC,GAAW,IAAIC,EAAQ;AAAA,EAC5C;AACA,QAAME,IAAY,IAAIC,EAAUL,CAAkB;AAClD,SAAAT,EAAaQ,CAAG,IAAIK,GACbA;AACT;","x_google_ignoreList":[0]}
@@ -1,4 +1,4 @@
1
- import { a7 as f } from "./index-CidWtnTb.js";
1
+ import { a7 as f } from "./index-Cr9XsSBX.js";
2
2
  export {
3
3
  f as HolostaffWidget
4
4
  };
@@ -1061,7 +1061,7 @@ Continue the conversation naturally from this context.`,i=e.actionId;this.cleanu
1061
1061
  0%, 100% { box-shadow: 0 0 8px var(--hs-accent-glow), inset 0 0 4px var(--hs-accent-glow); }
1062
1062
  50% { box-shadow: 0 0 20px var(--hs-accent-glow), inset 0 0 8px var(--hs-accent-glow); }
1063
1063
  }
1064
- `;let af=!1;class qC{constructor(){this.highlights=[]}highlight(e,t=3e3){St(),this.injectPulseStyle();const i=document.createElement("div");i.className="hs-highlight-overlay",i.setAttribute("data-hs-theme","dark");const r=()=>{const l=e.getBoundingClientRect();Object.assign(i.style,{position:"fixed",top:`${l.top-3}px`,left:`${l.left-3}px`,width:`${l.width+6}px`,height:`${l.height+6}px`,border:"2px solid var(--hs-accent)",borderRadius:"var(--hs-radius-sm)",animation:"hs-highlight-glow 1.5s ease-in-out infinite",pointerEvents:"none",zIndex:W.zOverlay,boxSizing:"border-box"})};r(),document.body.appendChild(i);const n=()=>r();window.addEventListener("scroll",n,{passive:!0});const o=setTimeout(()=>this.removeHighlight(a),t),a={overlay:i,timer:o,scrollHandler:n,anim:null};this.highlights.push(a)}clearAll(){this.highlights.forEach(e=>this.removeHighlight(e)),this.highlights=[]}removeHighlight(e){clearTimeout(e.timer),window.removeEventListener("scroll",e.scrollHandler),e.anim=TC(e.overlay,1,0,"smooth",()=>{e.overlay.remove()});const t=this.highlights.indexOf(e);t>=0&&this.highlights.splice(t,1)}injectPulseStyle(){if(af)return;af=!0;const e=document.createElement("style");e.textContent=YC,document.head.appendChild(e)}}const KC=800,ZC=600*1e3,JC=540*1e3,lf=60*1e3,QC=90*1e3,eS=[{type:"function",name:"page_action",description:"Interact with the webpage the visitor is viewing. You can scroll to elements, highlight elements, click buttons/links, fill form fields, or read the page content. Describe what you want to do in natural language. Call this to understand the page, guide the visitor, or take actions on their behalf.",parameters:{type:"object",properties:{instruction:{type:"string",description:"What to do on the page, e.g. 'scroll to pricing section', 'highlight the sign-up button', 'fill the email field with test@example.com', 'read the page to understand what it contains'"}},required:["instruction"]}},{type:"function",name:"show_text_card",description:"Display a floating text card overlay near the avatar with additional information for the visitor. Use for key points, explanations, or summaries that benefit from visual display.",parameters:{type:"object",properties:{title:{type:"string",description:"Card title"},body:{type:"string",description:"Card body text"}},required:["title","body"]}},{type:"function",name:"show_image_card",description:"Display a floating image card overlay with an optional caption.",parameters:{type:"object",properties:{image_url:{type:"string",description:"URL of the image to display"},caption:{type:"string",description:"Optional caption below the image"}},required:["image_url"]}},{type:"function",name:"show_bullet_list",description:"Display a styled list of key points as a floating overlay card.",parameters:{type:"object",properties:{title:{type:"string",description:"List title"},items:{type:"array",items:{type:"string"},description:"List items"}},required:["title","items"]}},{type:"function",name:"dismiss_overlays",description:"Dismiss all currently visible overlay cards.",parameters:{type:"object",properties:{},required:[]}},{type:"function",name:"get_skill_instructions",description:'Retrieve the full playbook for one of your configured skills. Call this when you determine a skill is relevant to the current conversation — it returns detailed guidance on what to say, tone, and what to avoid. Use the skill name exactly as listed in the "Your Skills" section of your instructions.',parameters:{type:"object",properties:{skill_name:{type:"string",description:'The exact skill name as listed in Your Skills (e.g. "Convert Visitor", "Get Started").'}},required:["skill_name"]}},{type:"function",name:"end_conversation",description:"Gracefully end the current conversation. Call this after two failed attempts to steer an off-topic visitor back to the platform's purpose. Before calling, deliver your exit message naturally in speech — do not include it as a parameter. Set flag=true to mark this visitor as non-serious so they are not interrupted by the agent on future visits.",parameters:{type:"object",properties:{flag:{type:"boolean",description:"If true, flag this visitor as non-serious. The widget will be fully suppressed on their future visits."},reason:{type:"string",description:'Short reason for logging. E.g. "visitor not interested in platform".'}},required:["flag"]}}];class cf{constructor(e,t,i){this.stage=null,this.avatar=null,this.state="idle",this.avatarState="idle",this.scrollHandler=null,this.idleVideoUrl=null,this.idleImageUrl=null,this.bubbleTimer=null,this.realtimeSession=null,this.audioForwarder=null,this.anamSession=null,this.sessionResponse=null,this.domAnalyzer=null,this.toolHandler=null,this.maxDurationTimer=null,this.maxDurationWarnTimer=null,this.inactivityTimer=null,this.inactivityCloseTimer=null,this.sessionStartTime=0,this.logger=null,this.rrwebRecorder=null,this.visionWs=null,this.externalObserver=!1,this.actionExecutor=null,this.visionContext=null,this.staffDisplayName="Assistant",this.staffAvatarUrl=null,this.hasHadConversation=!1,this.pendingEndAfterResponse=null,this.avatarFrame=null,this.bubble=null,this.chatPill=null,this.overlayRenderer=null,this.controls=null,this.confirmationPrompt=null,this.highlightRenderer=null,this.stageBackdrop=null,this.stageEl=null,this.homePlaceholder=null,this.homeObserver=null,this.homeVisible=!0,this.homeEverSeen=!1,this.pillProtected=!1,this.paused=!1,this.config=e,this.widgetPrompts=t??null,this.evalMode=i??!1,this.visitorId=this.getOrCreateVisitorId()}get isInline(){return this.config.mode==="inline"&&!!this.config.container}get activeContainer(){return this.config.container}async init(){St(),this.stage=new dx,await this.stage.init(this.config.mode,this.config.container),this.avatar=new px(this.stage.stageWidth,this.stage.stageHeight),this.stage.app.stage.addChild(this.avatar.container),await this.loadIdleAsset(),this.avatarFrame=new BC,this.stage.rootElement&&$i(this.stage.rootElement),this.bubble=new UC(this.widgetPrompts??void 0),this.bubble.onClick=()=>this.onAvatarClick(),this.stage.rootElement&&(this.stage.rootElement.style.position="relative",this.stage.rootElement.appendChild(this.bubble.el)),this.avatar.setInteractive(()=>this.onAvatarClick()),this.chatPill=new of,this.chatPill.init(this.staffAvatarUrl,this.idleVideoUrl,this.staffDisplayName),this.chatPill.onClick=()=>this.onAvatarClick(),this.isInline?(setTimeout(()=>{var t;(this.state==="idle"||this.state==="teasing")&&!this.homeVisible&&((t=this.chatPill)==null?void 0:t.state)==="hidden"&&this.chatPill.showNamed()},5e3),this.startHomeObserver()):this.homeVisible=!1,this.setupTrigger(),this.startVisionLoop(),window.addEventListener("beforeunload",()=>{var e;(this.state==="active"||this.state==="connecting")&&((e=this.logger)==null||e.flush())}),console.log("[HolostaffWidget] Initialized",{staffId:this.config.staffId,trigger:this.config.trigger,visionEnabled:!!this.config.visionWsUrl})}async loadIdleAsset(){if(!(!this.avatar||!this.stage)){if(this.idleVideoUrl)try{if(this.isInline&&this.stage.inlineTarget){const e=this.stage.inlineTarget;e.style.position="relative";const t=document.createElement("div");t.className="hs-inline-card",t.setAttribute("data-hs-theme","dark"),Object.assign(t.style,{position:"absolute",inset:"0",display:"flex",flexDirection:"column",borderRadius:"var(--hs-radius-lg)",overflow:"hidden",background:"var(--hs-glass-bg)",backdropFilter:"blur(var(--hs-glass-blur)) saturate(var(--hs-glass-saturate))",WebkitBackdropFilter:"blur(var(--hs-glass-blur)) saturate(var(--hs-glass-saturate))",border:"1px solid var(--hs-glass-border)",boxShadow:"var(--hs-glass-shadow)",cursor:"pointer",padding:"var(--hs-space-3)",boxSizing:"border-box"});const i=document.createElement("div");Object.assign(i.style,{flex:"1",overflow:"hidden",position:"relative",borderRadius:"var(--hs-radius-md)",border:"1px solid var(--hs-glass-border)"});const r=document.createElement("video");r.src=this.idleVideoUrl,r.autoplay=!0,r.loop=!0,r.muted=!0,r.playsInline=!0,r.setAttribute("playsinline",""),Object.assign(r.style,{width:"100%",height:"100%",objectFit:"cover",display:"block"}),i.appendChild(r),t.appendChild(i);const n=document.createElement("div");Object.assign(n.style,{padding:"var(--hs-space-3) var(--hs-space-4)",textAlign:"center"});const o=document.createElement("div");Object.assign(o.style,{color:"var(--hs-text-primary)",fontSize:"var(--hs-text-base)",fontWeight:"var(--hs-weight-semibold)",fontFamily:"var(--hs-font)",lineHeight:"var(--hs-line-height)"}),o.textContent=`${this.staffDisplayName}, your AI copilot`,n.appendChild(o);const a=document.createElement("div");Object.assign(a.style,{color:"var(--hs-text-tertiary)",fontSize:"var(--hs-text-xs)",fontFamily:"var(--hs-font)",marginTop:"2px"}),a.textContent="Powered by Holostaff",n.appendChild(a),t.appendChild(n),t.addEventListener("click",()=>this.onAvatarClick()),e.appendChild(t),this.stage.rootElement&&(this.stage.rootElement.style.display="none")}else{const e=this.stage.rootElement;if(!e)throw new Error("Widget root not available");await this.avatar.loadIdleVideo(this.idleVideoUrl,e)}return}catch{console.warn("[HolostaffWidget] Failed to load idle video, trying image fallback")}this.idleImageUrl?await this.avatar.loadIdleImage(this.idleImageUrl):console.warn("[HolostaffWidget] No idle video or image configured")}}setIdleVideo(e){this.idleVideoUrl=e}setIdleImage(e){this.idleImageUrl=e}setObserver(e,t){this.rrwebRecorder=e,this.visionWs=t,this.externalObserver=!0}setStaffInfo(e,t){this.staffDisplayName=e,this.staffAvatarUrl=t}updateEvalState(e){if(!this.evalMode)return;const t=window.__HS_EVAL_STATE__;t&&Object.assign(t,e)}setupTrigger(){if(this.isInline){this.showAvatarOnly();return}if(this.config.visionWsUrl){this.showAvatarOnly();return}switch(this.config.trigger){case"scroll":this.setupScrollTrigger();break;case"delay":setTimeout(()=>this.showTeaser(),this.config.delayMs);break;case"immediate":this.showTeaser();break}}setupScrollTrigger(){this.scrollHandler=()=>{const e=window.scrollY,t=document.documentElement.scrollHeight-window.innerHeight,i=t>0?e/t:0;i>=this.config.scrollThreshold&&this.state==="idle"?this.showTeaser():i<this.config.scrollThreshold*.5&&this.state==="teasing"&&this.hideTeaser()},window.addEventListener("scroll",this.scrollHandler,{passive:!0})}showAvatarOnly(){this.state!=="idle"||!this.avatar||!this.stage||(this.state="teasing",this.avatar.slideIn(this.stage.app.ticker))}showTeaser(){this.state!=="idle"||!this.avatar||!this.stage||(this.state="teasing",this.avatar.slideIn(this.stage.app.ticker),this.bubbleTimer=setTimeout(()=>{var e;return(e=this.bubble)==null?void 0:e.start()},KC))}hideTeaser(){var e;this.state!=="teasing"||!this.avatar||!this.stage||(this.state="idle",this.bubbleTimer&&(clearTimeout(this.bubbleTimer),this.bubbleTimer=null),(e=this.bubble)==null||e.stop(),this.avatar.slideOut(this.stage.app.ticker))}async onAvatarClick(){var e,t,i,r,n,o,a,l,c,h,u,f;if(!(this.state!=="teasing"&&this.state!=="idle")){if(this.state="connecting",(e=this.bubble)==null||e.stop(),(t=this.bubble)==null||t.hideStatic(),(i=this.actionExecutor)==null||i.destroy(),this.actionExecutor=null,this.isInline){(r=this.chatPill)==null||r.showConnecting();const d=(o=(n=this.stage)==null?void 0:n.inlineTarget)==null?void 0:o.querySelector(".hs-inline-card video");d&&d.pause()}else{(a=this.stage)!=null&&a.rootElement&&(this.stage.rootElement.style.display="");const d=document.querySelector("#holostaff-widget-root video");d&&d.pause(),(l=this.bubble)==null||l.showStatic("Connecting...")}console.log("[HolostaffWidget] Starting conversation...");try{this.sessionResponse=await Bf(this.config.staffId,this.config.backendUrl,this.visitorId),console.log("[HolostaffWidget] Session tokens received"),this.logger=new dv({staffId:this.config.staffId,staffName:this.sessionResponse.staff.name,backendUrl:this.config.backendUrl}),await this.connectAnam(),await this.connectRealtimeApi(),this.state="active",this.setAvatarState("listening"),this.sessionStartTime=Date.now(),(c=this.bubble)==null||c.hideStatic(),this.updateEvalState({conversationStarted:!0}),this.showControls(),this.startSessionTimers(),(h=this.visionWs)==null||h.sendConversationStarted(),(u=this.rrwebRecorder)==null||u.pause(),console.log("[HolostaffWidget] Conversation active")}catch(d){console.error("[HolostaffWidget] Failed to start conversation:",d),this.updateEvalState({conversationError:(d==null?void 0:d.message)??String(d),conversationErrorAt:new Date().toISOString()}),(f=this.bubble)==null||f.hideStatic(),this.endConversation()}}}moveToStage(){var t;if(!this.isInline||!((t=this.stage)!=null&&t.inlineTarget))return;const e=this.stage.inlineTarget.querySelector(".hs-inline-card");e&&(e.style.display="none"),this.stage.inlineTarget.querySelectorAll("video").forEach(i=>{i instanceof HTMLVideoElement&&i.pause()}),this.homePlaceholder=document.createElement("div"),this.homePlaceholder.setAttribute("data-hs-theme","dark"),Object.assign(this.homePlaceholder.style,{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",color:"var(--hs-text-secondary)",fontSize:"var(--hs-text-sm)",fontFamily:"var(--hs-font)",textAlign:"center",padding:"var(--hs-space-4)",boxSizing:"border-box"}),this.homePlaceholder.innerHTML="Agent is active below&nbsp;&darr;",this.stage.inlineTarget.appendChild(this.homePlaceholder),this.stageBackdrop=new XC,this.stageEl=this.stageBackdrop.el,this.stageBackdrop.show(),console.log("[HolostaffWidget] Moved to glass stage (bottom-center)")}returnToHome(){var t,i,r;if((t=this.stageBackdrop)==null||t.destroy(),this.stageBackdrop=null,this.stageEl=null,(i=this.homePlaceholder)==null||i.remove(),this.homePlaceholder=null,!((r=this.stage)!=null&&r.inlineTarget))return;const e=this.stage.inlineTarget.querySelector(".hs-inline-card");e&&(e.style.display=""),this.stage.inlineTarget.querySelectorAll(".hs-inline-card video").forEach(n=>{n.style.display="",n instanceof HTMLVideoElement&&n.play()}),console.log("[HolostaffWidget] Returned to home (inline container)")}startHomeObserver(){var i;this.stopHomeObserver();const e=(i=this.stage)==null?void 0:i.inlineTarget;if(!e)return;const t=e.getBoundingClientRect();this.homeVisible=t.top<window.innerHeight&&t.bottom>0,this.homeObserver=new IntersectionObserver(([r])=>{const n=this.homeVisible;if(this.homeVisible=r.isIntersecting,this.homeVisible&&!this.homeEverSeen&&(this.homeEverSeen=!0),(this.state==="idle"||this.state==="teasing")&&this.chatPill)if(this.homeVisible){if(this.pillProtected){this.pillProtected=!1;return}this.chatPill.hide()}else!this.homeVisible&&n&&this.homeEverSeen?this.chatPill.showNamed():!this.homeVisible&&!this.homeEverSeen&&this.chatPill.state==="hidden"&&this.chatPill.showNamed()},{threshold:.1}),this.homeObserver.observe(e)}stopHomeObserver(){var e;(e=this.homeObserver)==null||e.disconnect(),this.homeObserver=null}async connectAnam(){this.sessionResponse&&(this.anamSession=new tv({sessionToken:this.sessionResponse.anamSessionToken,inlineMode:this.isInline&&!!this.stageBackdrop}),this.anamSession.onConnected=()=>{console.log("[HolostaffWidget] Anam connected")},this.anamSession.onVideoReady=e=>{var t,i,r;console.log("[HolostaffWidget] Anam avatar video ready"),(t=this.bubble)==null||t.hideStatic(),(i=this.chatPill)==null||i.hide(),this.isInline?(this.moveToStage(),(r=this.stageBackdrop)==null||r.appendContent(e)):this.avatar&&this.stage&&this.avatar.setLiveVideo(e,this.stage.app.ticker)},this.anamSession.onTalkStreamInterrupted=()=>{console.log("[HolostaffWidget] Anam talk stream interrupted")},this.anamSession.onDisconnected=e=>{console.log("[HolostaffWidget] Anam disconnected:",e),this.endConversation()},this.anamSession.onError=e=>{console.error("[HolostaffWidget] Anam error:",e.message)},await this.anamSession.connect(),console.log("[HolostaffWidget] Anam session ready"))}async connectRealtimeApi(){var o;if(!this.sessionResponse)return;const e=document.title||"",t=location.href,i=((o=document.querySelector('meta[name="description"]'))==null?void 0:o.getAttribute("content"))||"",r=Array.from(document.querySelectorAll("h1, h2, h3")).slice(0,10).map(a=>{var l;return(l=a.textContent)==null?void 0:l.trim()}).filter(Boolean).join(" | ");let n=(this.sessionResponse.staff.instructions??"")+`
1064
+ `;let af=!1;class qC{constructor(){this.highlights=[]}highlight(e,t=3e3){St(),this.injectPulseStyle();const i=document.createElement("div");i.className="hs-highlight-overlay",i.setAttribute("data-hs-theme","dark");const r=()=>{const l=e.getBoundingClientRect();Object.assign(i.style,{position:"fixed",top:`${l.top-3}px`,left:`${l.left-3}px`,width:`${l.width+6}px`,height:`${l.height+6}px`,border:"2px solid var(--hs-accent)",borderRadius:"var(--hs-radius-sm)",animation:"hs-highlight-glow 1.5s ease-in-out infinite",pointerEvents:"none",zIndex:W.zOverlay,boxSizing:"border-box"})};r(),document.body.appendChild(i);const n=()=>r();window.addEventListener("scroll",n,{passive:!0});const o=setTimeout(()=>this.removeHighlight(a),t),a={overlay:i,timer:o,scrollHandler:n,anim:null};this.highlights.push(a)}clearAll(){this.highlights.forEach(e=>this.removeHighlight(e)),this.highlights=[]}removeHighlight(e){clearTimeout(e.timer),window.removeEventListener("scroll",e.scrollHandler),e.anim=TC(e.overlay,1,0,"smooth",()=>{e.overlay.remove()});const t=this.highlights.indexOf(e);t>=0&&this.highlights.splice(t,1)}injectPulseStyle(){if(af)return;af=!0;const e=document.createElement("style");e.textContent=YC,document.head.appendChild(e)}}const KC=800,ZC=600*1e3,JC=540*1e3,lf=60*1e3,QC=90*1e3,eS=[{type:"function",name:"page_action",description:"Interact with the webpage the visitor is viewing. You can scroll to elements, highlight elements, click buttons/links, fill form fields, or read the page content. Describe what you want to do in natural language. Call this to understand the page, guide the visitor, or take actions on their behalf.",parameters:{type:"object",properties:{instruction:{type:"string",description:"What to do on the page, e.g. 'scroll to pricing section', 'highlight the sign-up button', 'fill the email field with test@example.com', 'read the page to understand what it contains'"}},required:["instruction"]}},{type:"function",name:"show_text_card",description:"Display a floating text card overlay near the avatar with additional information for the visitor. Use for key points, explanations, or summaries that benefit from visual display.",parameters:{type:"object",properties:{title:{type:"string",description:"Card title"},body:{type:"string",description:"Card body text"}},required:["title","body"]}},{type:"function",name:"show_image_card",description:"Display a floating image card overlay with an optional caption.",parameters:{type:"object",properties:{image_url:{type:"string",description:"URL of the image to display"},caption:{type:"string",description:"Optional caption below the image"}},required:["image_url"]}},{type:"function",name:"show_bullet_list",description:"Display a styled list of key points as a floating overlay card.",parameters:{type:"object",properties:{title:{type:"string",description:"List title"},items:{type:"array",items:{type:"string"},description:"List items"}},required:["title","items"]}},{type:"function",name:"dismiss_overlays",description:"Dismiss all currently visible overlay cards.",parameters:{type:"object",properties:{},required:[]}},{type:"function",name:"get_skill_instructions",description:'Retrieve the full playbook for one of your configured skills. Call this when you determine a skill is relevant to the current conversation — it returns detailed guidance on what to say, tone, and what to avoid. Use the skill name exactly as listed in the "Your Skills" section of your instructions.',parameters:{type:"object",properties:{skill_name:{type:"string",description:'The exact skill name as listed in Your Skills (e.g. "Convert Visitor", "Get Started").'}},required:["skill_name"]}},{type:"function",name:"end_conversation",description:"Gracefully end the current conversation. Call this after two failed attempts to steer an off-topic visitor back to the platform's purpose. Before calling, deliver your exit message naturally in speech — do not include it as a parameter. Set flag=true to mark this visitor as non-serious so they are not interrupted by the agent on future visits.",parameters:{type:"object",properties:{flag:{type:"boolean",description:"If true, flag this visitor as non-serious. The widget will be fully suppressed on their future visits."},reason:{type:"string",description:'Short reason for logging. E.g. "visitor not interested in platform".'}},required:["flag"]}}];class cf{constructor(e,t,i){this.stage=null,this.avatar=null,this.state="idle",this.avatarState="idle",this.scrollHandler=null,this.idleVideoUrl=null,this.idleImageUrl=null,this.bubbleTimer=null,this.realtimeSession=null,this.audioForwarder=null,this.anamSession=null,this.sessionResponse=null,this.domAnalyzer=null,this.toolHandler=null,this.maxDurationTimer=null,this.maxDurationWarnTimer=null,this.inactivityTimer=null,this.inactivityCloseTimer=null,this.sessionStartTime=0,this.logger=null,this.rrwebRecorder=null,this.visionWs=null,this.externalObserver=!1,this.actionExecutor=null,this.visionContext=null,this.staffDisplayName="Assistant",this.staffAvatarUrl=null,this.hasHadConversation=!1,this.pendingEndAfterResponse=null,this.avatarFrame=null,this.bubble=null,this.chatPill=null,this.overlayRenderer=null,this.controls=null,this.confirmationPrompt=null,this.highlightRenderer=null,this.stageBackdrop=null,this.stageEl=null,this.homePlaceholder=null,this.homeObserver=null,this.homeVisible=!0,this.homeEverSeen=!1,this.pillProtected=!1,this.paused=!1,this.config=e,this.widgetPrompts=t??null,this.evalMode=i??!1,this.visitorId=this.getOrCreateVisitorId()}get isInline(){return this.config.mode==="inline"&&!!this.config.container}get activeContainer(){return this.config.container}async init(){St(),this.stage=new dx,await this.stage.init(this.config.mode,this.config.container),this.avatar=new px(this.stage.stageWidth,this.stage.stageHeight),this.stage.app.stage.addChild(this.avatar.container),await this.loadIdleAsset(),this.avatarFrame=new BC,this.stage.rootElement&&$i(this.stage.rootElement),this.bubble=new UC(this.widgetPrompts??void 0),this.bubble.onClick=()=>this.onAvatarClick(),this.stage.rootElement&&(this.stage.rootElement.style.position="relative",this.stage.rootElement.appendChild(this.bubble.el)),this.avatar.setInteractive(()=>this.onAvatarClick()),this.chatPill=new of,this.chatPill.init(this.staffAvatarUrl,this.idleVideoUrl,this.staffDisplayName),this.chatPill.onClick=()=>this.onAvatarClick(),this.isInline?(setTimeout(()=>{var t;(this.state==="idle"||this.state==="teasing")&&!this.homeVisible&&((t=this.chatPill)==null?void 0:t.state)==="hidden"&&this.chatPill.showNamed()},5e3),this.startHomeObserver()):this.homeVisible=!1,this.setupTrigger(),this.startVisionLoop(),window.addEventListener("beforeunload",()=>{var e;(this.state==="active"||this.state==="connecting")&&((e=this.logger)==null||e.flush())}),console.log("[HolostaffWidget] Initialized",{staffId:this.config.staffId,trigger:this.config.trigger,visionEnabled:!!this.config.visionWsUrl})}async loadIdleAsset(){if(!(!this.avatar||!this.stage)){if(this.idleVideoUrl)try{if(this.isInline&&this.stage.inlineTarget){const e=this.stage.inlineTarget;e.style.position="relative";const t=document.createElement("div");t.className="hs-inline-card",t.setAttribute("data-hs-theme","dark"),Object.assign(t.style,{position:"absolute",inset:"0",display:"flex",flexDirection:"column",borderRadius:"var(--hs-radius-lg)",overflow:"hidden",background:"var(--hs-glass-bg)",backdropFilter:"blur(var(--hs-glass-blur)) saturate(var(--hs-glass-saturate))",WebkitBackdropFilter:"blur(var(--hs-glass-blur)) saturate(var(--hs-glass-saturate))",border:"1px solid var(--hs-glass-border)",boxShadow:"var(--hs-glass-shadow)",cursor:"pointer",padding:"var(--hs-space-3)",boxSizing:"border-box"});const i=document.createElement("div");Object.assign(i.style,{flex:"1",overflow:"hidden",position:"relative",borderRadius:"var(--hs-radius-md)",border:"1px solid var(--hs-glass-border)"});const r=document.createElement("video");r.src=this.idleVideoUrl,r.autoplay=!0,r.loop=!0,r.muted=!0,r.playsInline=!0,r.setAttribute("playsinline",""),Object.assign(r.style,{width:"100%",height:"100%",objectFit:"cover",display:"block"}),i.appendChild(r),t.appendChild(i);const n=document.createElement("div");Object.assign(n.style,{padding:"var(--hs-space-3) var(--hs-space-4)",textAlign:"center"});const o=document.createElement("div");Object.assign(o.style,{color:"var(--hs-text-primary)",fontSize:"var(--hs-text-base)",fontWeight:"var(--hs-weight-semibold)",fontFamily:"var(--hs-font)",lineHeight:"var(--hs-line-height)"}),o.textContent=`${this.staffDisplayName}, your AI copilot`,n.appendChild(o);const a=document.createElement("div");Object.assign(a.style,{color:"var(--hs-text-tertiary)",fontSize:"var(--hs-text-xs)",fontFamily:"var(--hs-font)",marginTop:"2px"}),a.textContent="Powered by Holostaff",n.appendChild(a),t.appendChild(n),t.addEventListener("click",()=>this.onAvatarClick()),e.appendChild(t),this.stage.rootElement&&(this.stage.rootElement.style.display="none")}else{const e=this.stage.rootElement;if(!e)throw new Error("Widget root not available");await this.avatar.loadIdleVideo(this.idleVideoUrl,e)}return}catch{console.warn("[HolostaffWidget] Failed to load idle video, trying image fallback")}this.idleImageUrl?await this.avatar.loadIdleImage(this.idleImageUrl):console.warn("[HolostaffWidget] No idle video or image configured")}}setIdleVideo(e){this.idleVideoUrl=e}setIdleImage(e){this.idleImageUrl=e}setObserver(e,t){this.rrwebRecorder=e,this.visionWs=t,this.externalObserver=!0}setStaffInfo(e,t){this.staffDisplayName=e,this.staffAvatarUrl=t}updateEvalState(e){if(!this.evalMode)return;const t=window.__HS_EVAL_STATE__;t&&Object.assign(t,e)}setupTrigger(){if(this.isInline){this.showAvatarOnly();return}if(!this.config.visionWsUrl)switch(this.config.trigger){case"scroll":this.setupScrollTrigger();break;case"delay":setTimeout(()=>this.showTeaser(),this.config.delayMs);break;case"immediate":this.showTeaser();break}}setupScrollTrigger(){this.scrollHandler=()=>{const e=window.scrollY,t=document.documentElement.scrollHeight-window.innerHeight,i=t>0?e/t:0;i>=this.config.scrollThreshold&&this.state==="idle"?this.showTeaser():i<this.config.scrollThreshold*.5&&this.state==="teasing"&&this.hideTeaser()},window.addEventListener("scroll",this.scrollHandler,{passive:!0})}showAvatarOnly(){this.state!=="idle"||!this.avatar||!this.stage||(this.state="teasing",this.avatar.slideIn(this.stage.app.ticker))}showTeaser(){this.state!=="idle"||!this.avatar||!this.stage||(this.state="teasing",this.avatar.slideIn(this.stage.app.ticker),this.bubbleTimer=setTimeout(()=>{var e;return(e=this.bubble)==null?void 0:e.start()},KC))}hideTeaser(){var e;this.state!=="teasing"||!this.avatar||!this.stage||(this.state="idle",this.bubbleTimer&&(clearTimeout(this.bubbleTimer),this.bubbleTimer=null),(e=this.bubble)==null||e.stop(),this.avatar.slideOut(this.stage.app.ticker))}async onAvatarClick(){var e,t,i,r,n,o,a,l,c,h,u,f;if(!(this.state!=="teasing"&&this.state!=="idle")){if(this.state="connecting",(e=this.bubble)==null||e.stop(),(t=this.bubble)==null||t.hideStatic(),(i=this.actionExecutor)==null||i.destroy(),this.actionExecutor=null,this.isInline){(r=this.chatPill)==null||r.showConnecting();const d=(o=(n=this.stage)==null?void 0:n.inlineTarget)==null?void 0:o.querySelector(".hs-inline-card video");d&&d.pause()}else{(a=this.stage)!=null&&a.rootElement&&(this.stage.rootElement.style.display="");const d=document.querySelector("#holostaff-widget-root video");d&&d.pause(),(l=this.bubble)==null||l.showStatic("Connecting...")}console.log("[HolostaffWidget] Starting conversation...");try{this.sessionResponse=await Bf(this.config.staffId,this.config.backendUrl,this.visitorId),console.log("[HolostaffWidget] Session tokens received"),this.logger=new dv({staffId:this.config.staffId,staffName:this.sessionResponse.staff.name,backendUrl:this.config.backendUrl}),await this.connectAnam(),await this.connectRealtimeApi(),this.state="active",this.setAvatarState("listening"),this.sessionStartTime=Date.now(),(c=this.bubble)==null||c.hideStatic(),this.updateEvalState({conversationStarted:!0}),this.showControls(),this.startSessionTimers(),(h=this.visionWs)==null||h.sendConversationStarted(),(u=this.rrwebRecorder)==null||u.pause(),console.log("[HolostaffWidget] Conversation active")}catch(d){console.error("[HolostaffWidget] Failed to start conversation:",d),this.updateEvalState({conversationError:(d==null?void 0:d.message)??String(d),conversationErrorAt:new Date().toISOString()}),(f=this.bubble)==null||f.hideStatic(),this.endConversation()}}}moveToStage(){var t;if(!this.isInline||!((t=this.stage)!=null&&t.inlineTarget))return;const e=this.stage.inlineTarget.querySelector(".hs-inline-card");e&&(e.style.display="none"),this.stage.inlineTarget.querySelectorAll("video").forEach(i=>{i instanceof HTMLVideoElement&&i.pause()}),this.homePlaceholder=document.createElement("div"),this.homePlaceholder.setAttribute("data-hs-theme","dark"),Object.assign(this.homePlaceholder.style,{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",color:"var(--hs-text-secondary)",fontSize:"var(--hs-text-sm)",fontFamily:"var(--hs-font)",textAlign:"center",padding:"var(--hs-space-4)",boxSizing:"border-box"}),this.homePlaceholder.innerHTML="Agent is active below&nbsp;&darr;",this.stage.inlineTarget.appendChild(this.homePlaceholder),this.stageBackdrop=new XC,this.stageEl=this.stageBackdrop.el,this.stageBackdrop.show(),console.log("[HolostaffWidget] Moved to glass stage (bottom-center)")}returnToHome(){var t,i,r;if((t=this.stageBackdrop)==null||t.destroy(),this.stageBackdrop=null,this.stageEl=null,(i=this.homePlaceholder)==null||i.remove(),this.homePlaceholder=null,!((r=this.stage)!=null&&r.inlineTarget))return;const e=this.stage.inlineTarget.querySelector(".hs-inline-card");e&&(e.style.display=""),this.stage.inlineTarget.querySelectorAll(".hs-inline-card video").forEach(n=>{n.style.display="",n instanceof HTMLVideoElement&&n.play()}),console.log("[HolostaffWidget] Returned to home (inline container)")}startHomeObserver(){var i;this.stopHomeObserver();const e=(i=this.stage)==null?void 0:i.inlineTarget;if(!e)return;const t=e.getBoundingClientRect();this.homeVisible=t.top<window.innerHeight&&t.bottom>0,this.homeObserver=new IntersectionObserver(([r])=>{const n=this.homeVisible;if(this.homeVisible=r.isIntersecting,this.homeVisible&&!this.homeEverSeen&&(this.homeEverSeen=!0),(this.state==="idle"||this.state==="teasing")&&this.chatPill)if(this.homeVisible){if(this.pillProtected){this.pillProtected=!1;return}this.chatPill.hide()}else!this.homeVisible&&n&&this.homeEverSeen?this.chatPill.showNamed():!this.homeVisible&&!this.homeEverSeen&&this.chatPill.state==="hidden"&&this.chatPill.showNamed()},{threshold:.1}),this.homeObserver.observe(e)}stopHomeObserver(){var e;(e=this.homeObserver)==null||e.disconnect(),this.homeObserver=null}async connectAnam(){this.sessionResponse&&(this.anamSession=new tv({sessionToken:this.sessionResponse.anamSessionToken,inlineMode:this.isInline&&!!this.stageBackdrop}),this.anamSession.onConnected=()=>{console.log("[HolostaffWidget] Anam connected")},this.anamSession.onVideoReady=e=>{var t,i,r;console.log("[HolostaffWidget] Anam avatar video ready"),(t=this.bubble)==null||t.hideStatic(),(i=this.chatPill)==null||i.hide(),this.isInline?(this.moveToStage(),(r=this.stageBackdrop)==null||r.appendContent(e)):this.avatar&&this.stage&&this.avatar.setLiveVideo(e,this.stage.app.ticker)},this.anamSession.onTalkStreamInterrupted=()=>{console.log("[HolostaffWidget] Anam talk stream interrupted")},this.anamSession.onDisconnected=e=>{console.log("[HolostaffWidget] Anam disconnected:",e),this.endConversation()},this.anamSession.onError=e=>{console.error("[HolostaffWidget] Anam error:",e.message)},await this.anamSession.connect(),console.log("[HolostaffWidget] Anam session ready"))}async connectRealtimeApi(){var o;if(!this.sessionResponse)return;const e=document.title||"",t=location.href,i=((o=document.querySelector('meta[name="description"]'))==null?void 0:o.getAttribute("content"))||"",r=Array.from(document.querySelectorAll("h1, h2, h3")).slice(0,10).map(a=>{var l;return(l=a.textContent)==null?void 0:l.trim()}).filter(Boolean).join(" | ");let n=(this.sessionResponse.staff.instructions??"")+`
1065
1065
 
1066
1066
  ## Current Page
1067
1067
  Title: ${e}