obi-sdk 0.19.57-beta.4 → 0.19.57-beta.5

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.js CHANGED
@@ -130,4 +130,4 @@ ${t}</tr>
130
130
  `}tablecell(t){let e=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>
131
131
  `}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${Ea(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:n}){let i=this.parser.parseInline(n),r=v3(t);if(r===null)return i;t=r;let a='<a href="'+t+'"';return e&&(a+=' title="'+Ea(e)+'"'),a+=">"+i+"</a>",a}image({href:t,title:e,text:n,tokens:i}){i&&(n=this.parser.parseInline(i,this.parser.textRenderer));let r=v3(t);if(r===null)return Ea(n);t=r;let a=`<img src="${t}" alt="${n}"`;return e&&(a+=` title="${Ea(e)}"`),a+=">",a}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:Ea(t.text)}},Gb=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}checkbox({raw:t}){return t}},xr=class ry{constructor(e){vt(this,"options"),vt(this,"renderer"),vt(this,"textRenderer"),this.options=e||xs,this.options.renderer=this.options.renderer||new vp,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Gb}static parse(e,n){return new ry(n).parse(e)}static parseInline(e,n){return new ry(n).parseInline(e)}parse(e){var i,r;let n="";for(let a=0;a<e.length;a++){let o=e[a];if((r=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&r[o.type]){let l=o,c=this.options.extensions.renderers[l.type].call({parser:this},l);if(c!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(l.type)){n+=c||"";continue}}let s=o;switch(s.type){case"space":{n+=this.renderer.space(s);break}case"hr":{n+=this.renderer.hr(s);break}case"heading":{n+=this.renderer.heading(s);break}case"code":{n+=this.renderer.code(s);break}case"table":{n+=this.renderer.table(s);break}case"blockquote":{n+=this.renderer.blockquote(s);break}case"list":{n+=this.renderer.list(s);break}case"checkbox":{n+=this.renderer.checkbox(s);break}case"html":{n+=this.renderer.html(s);break}case"def":{n+=this.renderer.def(s);break}case"paragraph":{n+=this.renderer.paragraph(s);break}case"text":{n+=this.renderer.text(s);break}default:{let l='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return n}parseInline(e,n=this.renderer){var r,a;let i="";for(let o=0;o<e.length;o++){let s=e[o];if((a=(r=this.options.extensions)==null?void 0:r.renderers)!=null&&a[s.type]){let c=this.options.extensions.renderers[s.type].call({parser:this},s);if(c!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type)){i+=c||"";continue}}let l=s;switch(l.type){case"escape":{i+=n.text(l);break}case"html":{i+=n.html(l);break}case"link":{i+=n.link(l);break}case"image":{i+=n.image(l);break}case"checkbox":{i+=n.checkbox(l);break}case"strong":{i+=n.strong(l);break}case"em":{i+=n.em(l);break}case"codespan":{i+=n.codespan(l);break}case"br":{i+=n.br(l);break}case"del":{i+=n.del(l);break}case"text":{i+=n.text(l);break}default:{let c='Token with "'+l.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return i}},bp,zu=(bp=class{constructor(t){vt(this,"options"),vt(this,"block"),this.options=t||xs}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(){return this.block?_r.lex:_r.lexInline}provideParser(){return this.block?xr.parse:xr.parseInline}},vt(bp,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),vt(bp,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),bp),Jz=class{constructor(...t){vt(this,"defaults",Ib()),vt(this,"options",this.setOptions),vt(this,"parse",this.parseMarkdown(!0)),vt(this,"parseInline",this.parseMarkdown(!1)),vt(this,"Parser",xr),vt(this,"Renderer",vp),vt(this,"TextRenderer",Gb),vt(this,"Lexer",_r),vt(this,"Tokenizer",gp),vt(this,"Hooks",zu),this.use(...t)}walkTokens(t,e){var i,r;let n=[];for(let a of t)switch(n=n.concat(e.call(this,a)),a.type){case"table":{let o=a;for(let s of o.header)n=n.concat(this.walkTokens(s.tokens,e));for(let s of o.rows)for(let l of s)n=n.concat(this.walkTokens(l.tokens,e));break}case"list":{let o=a;n=n.concat(this.walkTokens(o.items,e));break}default:{let o=a;(r=(i=this.defaults.extensions)==null?void 0:i.childTokens)!=null&&r[o.type]?this.defaults.extensions.childTokens[o.type].forEach(s=>{let l=o[s].flat(1/0);n=n.concat(this.walkTokens(l,e))}):o.tokens&&(n=n.concat(this.walkTokens(o.tokens,e)))}}return n}use(...t){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(n=>{let i={...n};if(i.async=this.defaults.async||i.async||!1,n.extensions&&(n.extensions.forEach(r=>{if(!r.name)throw new Error("extension name required");if("renderer"in r){let a=e.renderers[r.name];a?e.renderers[r.name]=function(...o){let s=r.renderer.apply(this,o);return s===!1&&(s=a.apply(this,o)),s}:e.renderers[r.name]=r.renderer}if("tokenizer"in r){if(!r.level||r.level!=="block"&&r.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let a=e[r.level];a?a.unshift(r.tokenizer):e[r.level]=[r.tokenizer],r.start&&(r.level==="block"?e.startBlock?e.startBlock.push(r.start):e.startBlock=[r.start]:r.level==="inline"&&(e.startInline?e.startInline.push(r.start):e.startInline=[r.start]))}"childTokens"in r&&r.childTokens&&(e.childTokens[r.name]=r.childTokens)}),i.extensions=e),n.renderer){let r=this.defaults.renderer||new vp(this.defaults);for(let a in n.renderer){if(!(a in r))throw new Error(`renderer '${a}' does not exist`);if(["options","parser"].includes(a))continue;let o=a,s=n.renderer[o],l=r[o];r[o]=(...c)=>{let u=s.apply(r,c);return u===!1&&(u=l.apply(r,c)),u||""}}i.renderer=r}if(n.tokenizer){let r=this.defaults.tokenizer||new gp(this.defaults);for(let a in n.tokenizer){if(!(a in r))throw new Error(`tokenizer '${a}' does not exist`);if(["options","rules","lexer"].includes(a))continue;let o=a,s=n.tokenizer[o],l=r[o];r[o]=(...c)=>{let u=s.apply(r,c);return u===!1&&(u=l.apply(r,c)),u}}i.tokenizer=r}if(n.hooks){let r=this.defaults.hooks||new zu;for(let a in n.hooks){if(!(a in r))throw new Error(`hook '${a}' does not exist`);if(["options","block"].includes(a))continue;let o=a,s=n.hooks[o],l=r[o];zu.passThroughHooks.has(a)?r[o]=c=>{if(this.defaults.async&&zu.passThroughHooksRespectAsync.has(a))return(async()=>{let d=await s.call(r,c);return l.call(r,d)})();let u=s.call(r,c);return l.call(r,u)}:r[o]=(...c)=>{if(this.defaults.async)return(async()=>{let d=await s.apply(r,c);return d===!1&&(d=await l.apply(r,c)),d})();let u=s.apply(r,c);return u===!1&&(u=l.apply(r,c)),u}}i.hooks=r}if(n.walkTokens){let r=this.defaults.walkTokens,a=n.walkTokens;i.walkTokens=function(o){let s=[];return s.push(a.call(this,o)),r&&(s=s.concat(r.call(this,o))),s}}this.defaults={...this.defaults,...i}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return _r.lex(t,e??this.defaults)}parser(t,e){return xr.parse(t,e??this.defaults)}parseMarkdown(t){return(e,n)=>{let i={...n},r={...this.defaults,...i},a=this.onError(!!r.silent,!!r.async);if(this.defaults.async===!0&&i.async===!1)return a(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return a(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return a(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(r.hooks&&(r.hooks.options=r,r.hooks.block=t),r.async)return(async()=>{let o=r.hooks?await r.hooks.preprocess(e):e,s=await(r.hooks?await r.hooks.provideLexer():t?_r.lex:_r.lexInline)(o,r),l=r.hooks?await r.hooks.processAllTokens(s):s;r.walkTokens&&await Promise.all(this.walkTokens(l,r.walkTokens));let c=await(r.hooks?await r.hooks.provideParser():t?xr.parse:xr.parseInline)(l,r);return r.hooks?await r.hooks.postprocess(c):c})().catch(a);try{r.hooks&&(e=r.hooks.preprocess(e));let o=(r.hooks?r.hooks.provideLexer():t?_r.lex:_r.lexInline)(e,r);r.hooks&&(o=r.hooks.processAllTokens(o)),r.walkTokens&&this.walkTokens(o,r.walkTokens);let s=(r.hooks?r.hooks.provideParser():t?xr.parse:xr.parseInline)(o,r);return r.hooks&&(s=r.hooks.postprocess(s)),s}catch(o){return a(o)}}}onError(t,e){return n=>{if(n.message+=`
132
132
  Please report this to https://github.com/markedjs/marked.`,t){let i="<p>An error occurred:</p><pre>"+Ea(n.message+"",!0)+"</pre>";return e?Promise.resolve(i):i}if(e)return Promise.reject(n);throw n}}},Ss=new Jz;function at(t,e){return Ss.parse(t,e)}at.options=at.setOptions=function(t){return Ss.setOptions(t),at.defaults=Ss.defaults,i3(at.defaults),at},at.getDefaults=Ib,at.defaults=xs,at.use=function(...t){return Ss.use(...t),at.defaults=Ss.defaults,i3(at.defaults),at},at.walkTokens=function(t,e){return Ss.walkTokens(t,e)},at.parseInline=Ss.parseInline,at.Parser=xr,at.parser=xr.parse,at.Renderer=vp,at.TextRenderer=Gb,at.Lexer=_r,at.lexer=_r.lex,at.Tokenizer=gp,at.Hooks=zu,at.parse=at,at.options,at.setOptions,at.use,at.walkTokens,at.parseInline,xr.parse,_r.lex;const Qz="_base_1ne03_1",Zz={base:Qz},eF=["p","br","strong","em","u","a","ul","ol","li","h1","h2","h3","h4","h5","h6","code","pre","blockquote","hr"],tF=["href","title","target","rel"];at.setOptions({breaks:!0,gfm:!0});function nF(t){const{content:e,className:n,...i}=t,r=w.useMemo(()=>{if(!e)return"";const a=at.parse(e,{async:!1});return pz.sanitize(a,{ALLOWED_TAGS:[...eF],ALLOWED_ATTR:[...tF],ALLOW_DATA_ATTR:!1})},[e]);return r?f.jsx("div",{className:se(Zz.base,n),dangerouslySetInnerHTML:{__html:r},...i}):null}const iF="_controlBar_6shmw_1",rF="_popoverAnchor_6shmw_11",aF="_confirmationPopover_6shmw_15",oF="_confirmationPopoverAlignRight_6shmw_30",sF="_confirmationPopoverAlignCenter_6shmw_33",lF="_confirmationMessage_6shmw_53",cF="_confirmationActions_6shmw_60",uF="_confirmationButton_6shmw_65",dF="_confirmationButtonCancel_6shmw_83",hF="_confirmationButtonNeutral_6shmw_91",fF="_confirmationButtonDanger_6shmw_99",pF="_controlButton_6shmw_108",mF="_controlButtonIconOnly_6shmw_130",gF="_controlButtonDisabled_6shmw_135",vF="_controlButtonDanger_6shmw_162",bF="_controlButtonContent_6shmw_178",yF="_controlButtonIcon_6shmw_130",_F="_controlButtonLabel_6shmw_194",xF="_controlButtonChevron_6shmw_201",SF="_controlButtonNotificationDot_6shmw_210",kF="_deviceSplitButton_6shmw_222",TF="_deviceSplitButtonEnabled_6shmw_226",wF="_dualButtonContent_6shmw_307",CF="_dualButtonIcon_6shmw_317",EF="_dualButtonLabel_6shmw_326",RF="_screenShareButton_6shmw_340",AF="_screenShareButtonCompact_6shmw_351",Ge={controlBar:iF,popoverAnchor:rF,confirmationPopover:aF,confirmationPopoverAlignRight:oF,confirmationPopoverAlignCenter:sF,confirmationMessage:lF,confirmationActions:cF,confirmationButton:uF,confirmationButtonCancel:dF,confirmationButtonNeutral:hF,confirmationButtonDanger:fF,controlButton:pF,controlButtonIconOnly:mF,controlButtonDisabled:gF,controlButtonDanger:vF,controlButtonContent:bF,controlButtonIcon:yF,controlButtonLabel:_F,controlButtonChevron:xF,controlButtonNotificationDot:SF,deviceSplitButton:kF,deviceSplitButtonEnabled:TF,dualButtonContent:wF,dualButtonIcon:CF,dualButtonLabel:EF,screenShareButton:RF,screenShareButtonCompact:AF},NF="_inline_1gpyx_1",OF="_vertical_1gpyx_6",MF="_divider_1gpyx_10",DF="_dividerVertical_1gpyx_16",PF="_customDivider_1gpyx_21",Fu={inline:NF,vertical:OF,divider:MF,dividerVertical:DF,customDivider:PF},_3={none:"0px",xxs:"var(--space-xxs)",xs:"var(--space-xs)",sm:"var(--space-sm)",md:"var(--space-md)",lg:"var(--space-lg)",xl:"var(--space-xl)","2xl":"var(--space-2xl)","3xl":"var(--space-3xl)","4xl":"var(--space-4xl)","5xl":"var(--space-5xl)"};function Sr(t){if(t!==void 0){if(typeof t=="number")return`${t}px`;if(t in _3)return _3[t];if(typeof t=="string"&&t.trim().length>0)return t}}function LF(t,e){const{as:n,direction:i="horizontal",gap:r,align:a="center",justify:o,wrap:s=!1,divider:l,className:c,style:u,children:d,...h}=t,p=n??"div",b={display:"flex",flexDirection:i==="horizontal"?"row":"column",flexWrap:s?"wrap":"nowrap",alignItems:a,...o?{justifyContent:o}:{},...u};if(r!==void 0){const y=Sr(r);y&&(b.gap=y)}const m=hi.Children.toArray(d).filter(y=>y!=null&&typeof y!="boolean"),S=y=>!l||y===0?null:l===!0||l==="line"?f.jsx("span",{"aria-hidden":"true",className:se(Fu.divider,i==="vertical"&&Fu.dividerVertical)},`inline-divider-${y}`):f.jsx("span",{"aria-hidden":"true",className:Fu.customDivider,children:l},`inline-divider-${y}`),g=[];return m.forEach((y,x)=>{if(x>0){const v=S(x);v&&g.push(v)}g.push(y)}),f.jsx(p,{ref:e,className:se(Fu.inline,i==="vertical"&&Fu.vertical,c),style:b,...h,children:g})}const Wb=hi.forwardRef(LF);Wb.displayName="Inline";function IF(){const[t,e]=w.useState(()=>typeof window>"u"?!1:window.innerWidth<768);return w.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const n=window.matchMedia("(max-width: 767px)"),i=()=>{e(n.matches)};return i(),typeof n.addEventListener=="function"?(n.addEventListener("change",i),()=>n.removeEventListener("change",i)):(n.addListener(i),()=>n.removeListener(i))},[]),t}function Yb(t){const{icon:e,label:n,showChevron:i=!1,variant:r="default",disabled:a,className:o="",size:s="md",iconOnly:l=!1,showNotificationDot:c=!1,isOn:u,"aria-label":d,...h}=t,p=se(Ge.controlButton,a&&Ge.controlButtonDisabled,l&&Ge.controlButtonIconOnly,r==="danger"&&Ge.controlButtonDanger,o),b=Number.parseInt(Tb[s],10),m=r==="danger"?"outline":"primary",S=r==="danger"?"danger":"default",g=f.jsxs(f.Fragment,{children:[f.jsxs("span",{className:Ge.controlButtonContent,children:[e?f.jsx("span",{className:Ge.controlButtonIcon,children:hi.isValidElement(e)&&e.props.size===void 0?hi.cloneElement(e,{size:b}):e}):null,l?null:f.jsx("span",{className:Ge.controlButtonLabel,children:n}),l||!i?null:f.jsx("span",{className:Ge.controlButtonChevron,"aria-hidden":"true",children:f.jsx(wb,{size:16})})]}),c?f.jsx("span",{className:Ge.controlButtonNotificationDot,"aria-hidden":"true"}):null]});return typeof u=="boolean"?f.jsx(sp,{...h,type:"button",disabled:a,variant:m,color:S,isOn:u,"aria-label":d||n,className:p,"data-has-notification":c?"true":void 0,children:g}):f.jsx(_s,{...h,type:"button",disabled:a,variant:m,color:S,"aria-label":d||n,className:p,"data-has-notification":c?"true":void 0,children:g})}function jF(t){const{audioDevices:e,currentMicrophoneId:n,isMicrophoneEnabled:i,isScreenShareActive:r,widgetState:a,canPublishData:o,browserSupportsScreenSharing:s,screenShareButtonVariant:l="default",onMicDeviceSelect:c,onMicToggle:u,onChatToggle:d,onLeave:h,onScreenShareToggle:p,showChatNotification:b=!1,isLanguageSelectorEnabled:m=!0,languages:S=[],selectedLanguage:g=null,defaultLanguageCode:y=null,isMultilingual:x=!1,onLanguageChange:v,isChatOpen:k=a==="chat"}=t,T=S.length,C=!m||T===0,R=IF(),A=R?"xs":"sm",N=R,[O,B]=w.useState(!1),[W,L]=w.useState(!1),K=w.useRef(null),P=w.useRef(null);w.useEffect(()=>{const U=me=>{const Rt=me.composedPath();O&&K.current&&!Rt.includes(K.current)&&B(!1),W&&P.current&&!Rt.includes(P.current)&&L(!1)},fe=me=>{me.key==="Escape"&&(O&&B(!1),W&&L(!1))};if(O||W)return document.addEventListener("mousedown",U),document.addEventListener("keydown",fe),()=>{document.removeEventListener("mousedown",U),document.removeEventListener("keydown",fe)}},[O,W]),w.useEffect(()=>{r||B(!1)},[r]);const V=w.useMemo(()=>e.map(U=>({label:U.label||`Microphone ${U.deviceId.slice(0,8)}`,value:U.deviceId})),[e]),X=w.useMemo(()=>n?V.find(U=>U.value===n)??null:null,[n,V]),te=w.useCallback(U=>{U.value,c(U.value)},[c]),$={microphone:!0,screenShare:s,chat:o},z=w.useCallback(()=>{if(r){B(!0);return}p()},[r,p]),Z=w.useCallback(()=>{B(!1),p()},[p]),Q=w.useCallback(()=>{B(!1)},[]),ce=w.useCallback(()=>{L(!0)},[]),j=w.useCallback(()=>{L(!1),h()},[h]),ge=w.useCallback(()=>{L(!1)},[]);return f.jsx("div",{className:Ge.controlBar,"data-testid":"control-bar","data-controls":JSON.stringify($),"data-language-option-count":T>0?String(T):void 0,"data-default-language-code":y??void 0,children:f.jsxs(Wb,{gap:A,align:"center",justify:"center",wrap:N,children:[f.jsx(k7,{onClick:u,buttonAriaLabel:i?"Mute microphone":"Unmute microphone",options:V,value:X,onChange:te,variant:"primary",menuPlacement:"top",menuDisabled:V.length===0,menuAriaLabel:"Select microphone device",listboxAriaLabel:"Microphone devices",ariaPressed:i,className:se(Ge.deviceSplitButton,i&&Ge.deviceSplitButtonEnabled),children:f.jsxs("span",{className:Ge.dualButtonContent,children:[f.jsx("span",{className:Ge.dualButtonIcon,children:i?f.jsx(NE,{}):f.jsx(OE,{})}),f.jsx("span",{className:Ge.dualButtonLabel,children:"Microphone"})]})}),o?f.jsx(Yb,{icon:f.jsx(CE,{}),label:"Chat",onClick:d,isOn:k,"aria-label":"Toggle chat",showNotificationDot:b}):null,s?f.jsxs("div",{ref:K,className:Ge.popoverAnchor,children:[f.jsx(Yb,{icon:f.jsx(ME,{}),label:r?"Share screen off":"Share screen",className:l==="compact"?Ge.screenShareButtonCompact:Ge.screenShareButton,iconOnly:l==="compact",onClick:z,isOn:r,"aria-label":r?"Stop screen sharing":"Start screen sharing"}),O?f.jsxs("div",{className:se(Ge.confirmationPopover,Ge.confirmationPopoverAlignCenter),role:"dialog","aria-label":"Stop screen sharing confirmation","data-testid":"confirm-stop-share",children:[f.jsx("p",{className:Ge.confirmationMessage,children:"Stop screen sharing?"}),f.jsxs("div",{className:Ge.confirmationActions,children:[f.jsx("button",{type:"button",className:se(Ge.confirmationButton,Ge.confirmationButtonCancel),onClick:Q,children:"Cancel"}),f.jsx("button",{type:"button",className:se(Ge.confirmationButton,Ge.confirmationButtonNeutral),onClick:Z,children:"Stop"})]})]}):null]}):null,f.jsx(zE,{languages:S,value:g,onChange:v,defaultLanguageCode:y,variant:"control-bar",disabled:C}),f.jsxs("div",{ref:P,className:Ge.popoverAnchor,children:[f.jsx(Yb,{icon:f.jsx(AE,{}),label:"Leave",variant:"danger",onClick:ce,"aria-label":"Leave meeting"}),W?f.jsxs("div",{className:se(Ge.confirmationPopover,Ge.confirmationPopoverAlignRight),role:"dialog","aria-label":"Leave meeting confirmation","data-testid":"confirm-leave",children:[f.jsx("p",{className:Ge.confirmationMessage,children:"Would you like to end the call?"}),f.jsxs("div",{className:Ge.confirmationActions,children:[f.jsx("button",{type:"button",className:se(Ge.confirmationButton,Ge.confirmationButtonCancel),onClick:ge,children:"Cancel"}),f.jsx("button",{type:"button",className:se(Ge.confirmationButton,Ge.confirmationButtonDanger),onClick:j,children:"Leave"})]})]}):null]})]})})}function BF(t){return f.jsx(jF,{...t})}const UF="_controlBar_1n8jn_1",zF="_controlButton_1n8jn_12",FF="_controlButtonDisabled_1n8jn_35",qF="_controlButtonDanger_1n8jn_62",HF="_controlButtonIconOnly_1n8jn_78",VF="_screenShareButton_1n8jn_83",GF="_controlButtonContent_1n8jn_88",WF="_controlButtonIcon_1n8jn_78",YF="_controlButtonLabel_1n8jn_103",KF="_controlButtonNotificationDot_1n8jn_108",XF="_popoverAnchor_1n8jn_198",$F="_confirmationPopover_1n8jn_202",JF="_confirmationMessage_1n8jn_216",QF="_confirmationActions_1n8jn_223",ZF="_confirmationButton_1n8jn_228",eq="_confirmationButtonCancel_1n8jn_246",tq="_confirmationButtonDanger_1n8jn_254",vn={controlBar:UF,controlButton:zF,controlButtonDisabled:FF,controlButtonDanger:qF,controlButtonIconOnly:HF,screenShareButton:VF,controlButtonContent:GF,controlButtonIcon:WF,controlButtonLabel:YF,controlButtonNotificationDot:KF,popoverAnchor:XF,confirmationPopover:$F,confirmationMessage:JF,confirmationActions:QF,confirmationButton:ZF,confirmationButtonCancel:eq,confirmationButtonDanger:tq};function yp(t){const{icon:e,label:n,variant:i="default",disabled:r,className:a="",iconOnly:o=!1,showNotificationDot:s=!1,isOn:l,"aria-label":c,...u}=t,d=se(vn.controlButton,r&&vn.controlButtonDisabled,o&&vn.controlButtonIconOnly,i==="danger"&&vn.controlButtonDanger,a),h=i==="danger"?"outline":"primary",p=i==="danger"?"danger":"default",b=f.jsxs(f.Fragment,{children:[f.jsxs("span",{className:vn.controlButtonContent,children:[e?f.jsx("span",{className:vn.controlButtonIcon,children:hi.isValidElement(e)&&e.props.size===void 0?hi.cloneElement(e,{size:20}):e}):null,o?null:f.jsx("span",{className:vn.controlButtonLabel,children:n})]}),s?f.jsx("span",{className:vn.controlButtonNotificationDot,"aria-hidden":"true"}):null]});return typeof l=="boolean"?f.jsx(sp,{...u,type:"button",disabled:r,variant:h,color:p,size:"xs",isOn:l,"aria-label":c||n,className:d,"data-has-notification":s?"true":void 0,children:b}):f.jsx(_s,{...u,type:"button",disabled:r,variant:h,color:p,size:"xs","aria-label":c||n,className:d,"data-has-notification":s?"true":void 0,children:b})}function nq(t){const{isMicrophoneEnabled:e,isChatOpen:n,isScreenShareActive:i,showChatNotification:r=!1,onMicToggle:a,onChatToggle:o,onScreenShareToggle:s,onLeave:l,languages:c=[],selectedLanguage:u=null,defaultLanguageCode:d=null,isMultilingual:h=!1,onLanguageChange:p,isLanguageSelectorEnabled:b=!0,className:m,testId:S,...g}=t,y=!b||c.length===0,[x,v]=w.useState(!1),k=w.useRef(null);w.useEffect(()=>{const O=W=>{const L=W.composedPath();x&&k.current&&!L.includes(k.current)&&v(!1)},B=W=>{W.key==="Escape"&&x&&v(!1)};if(x)return document.addEventListener("mousedown",O),document.addEventListener("keydown",B),()=>{document.removeEventListener("mousedown",O),document.removeEventListener("keydown",B)}},[x]);const T=w.useCallback(()=>{a()},[a]),C=w.useCallback(()=>{s()},[s]),R=w.useCallback(()=>{v(!0)},[]),A=w.useCallback(()=>{v(!1),l()},[l]),N=w.useCallback(()=>{v(!1)},[]);return f.jsx("div",{...g,className:se(vn.controlBar,m),"data-testid":S,children:f.jsxs(Wb,{gap:"xs",align:"center",justify:"center",wrap:!1,children:[f.jsx(yp,{icon:e?f.jsx(NE,{size:18}):f.jsx(OE,{size:18}),label:"Microphone",iconOnly:!0,isOn:e,onClick:T,"aria-label":e?"Mute microphone":"Unmute microphone"}),f.jsx(yp,{icon:f.jsx(CE,{}),label:"Chat",iconOnly:!0,isOn:n,onClick:o,"aria-label":"Toggle chat",showNotificationDot:r}),f.jsx(yp,{icon:f.jsx(ME,{}),label:"Screen share",iconOnly:!0,className:vn.screenShareButton,isOn:i,onClick:C,"aria-label":i?"Stop screen sharing":"Start screen sharing"}),f.jsx(zE,{languages:c,value:u,onChange:p,defaultLanguageCode:d,variant:"pip",disabled:y}),f.jsxs("div",{ref:k,className:vn.popoverAnchor,children:[f.jsx(yp,{icon:f.jsx(AE,{size:16}),label:"Hang up",iconOnly:!0,variant:"danger",onClick:R,"aria-label":"Hang up"}),x?f.jsxs("div",{className:vn.confirmationPopover,role:"dialog","aria-label":"Hang up confirmation","data-testid":"confirm-leave",children:[f.jsx("p",{className:vn.confirmationMessage,children:"Would you like to end the call?"}),f.jsxs("div",{className:vn.confirmationActions,children:[f.jsx("button",{type:"button",className:se(vn.confirmationButton,vn.confirmationButtonCancel),onClick:N,children:"Cancel"}),f.jsx("button",{type:"button",className:se(vn.confirmationButton,vn.confirmationButtonDanger),onClick:A,children:"Leave"})]})]}):null]})]})})}function iq(t){return f.jsx(nq,{...t})}const rq="_container_zht0b_1",aq="_containerGradient_zht0b_14",oq="_containerFlat_zht0b_24",sq="_halo_zht0b_28",lq="_outerRing_zht0b_38",cq="_circle_zht0b_42",uq="_image_zht0b_72",dq="_captionContainer_zht0b_88",hq="_captionRegion_zht0b_99",Ra={container:rq,containerGradient:aq,containerFlat:oq,halo:sq,outerRing:lq,circle:cq,image:uq,captionContainer:dq,captionRegion:hq},fq="_statusText_1dkze_6",pq={statusText:fq},mq={idle:null,thinking:"Thinking...",searching:"Searching..."};function gq(t){const{status:e,size:n="md"}=t,i=e?mq[e]:null,r=i!==null;return f.jsx("div",{className:pq.statusText,"data-visible":r,"data-size":n,"aria-live":"polite",children:i})}const vq="https://obi-static.s3.ap-southeast-2.amazonaws.com/images/obi-avatar.png",bq={sm:{haloSize:"4.5rem",maxBorderWidth:5,outerRingScalePower:.55,glowSize:"20px"},md:{haloSize:"8rem",maxBorderWidth:8,outerRingScalePower:.7,glowSize:"35px"},lg:{haloSize:"10rem",maxBorderWidth:10,outerRingScalePower:.75,glowSize:"42px"}};function x3(t){const{audioPower:e,size:n="md",background:i="gradient",imageSrc:r=vq,accentColor:a,ariaLabel:o="Avatar placeholder",status:s,captionsText:l,className:c,style:u,...d}=t,h=bq[n],p=Math.min(1,Math.max(0,e)),b=p>.01,m=b?Math.min(1,p/.5):0,S=b?Math.max(1,m*h.maxBorderWidth):0,g=1.02,y=b?g+p*h.outerRingScalePower:g,x=b?.2+p*.35:0,v={...u??{},...a?{"--avatar-fallback-accent":a}:{}},k={"--avatar-fallback-halo-size":h.haloSize,"--avatar-fallback-border-width":`${S}px`,"--avatar-fallback-secondary-border-scale":y.toString(),"--avatar-fallback-secondary-border-opacity":x.toString(),"--avatar-fallback-glow-size":h.glowSize},T=l!=null&&l!=="";return f.jsxs("div",{...d,className:se(Ra.container,i==="gradient"?Ra.containerGradient:Ra.containerFlat,c),style:v,"data-testid":"avatar-fallback","aria-label":o,role:"img",children:[f.jsxs("div",{className:Ra.halo,style:k,children:[f.jsx("div",{className:Ra.outerRing,"aria-hidden":"true"}),f.jsx("div",{className:Ra.circle,children:f.jsx("img",{className:Ra.image,src:r,alt:"","aria-hidden":"true"})}),f.jsx(gq,{status:s,size:n})]}),T&&f.jsx("div",{className:Ra.captionContainer,children:f.jsx("div",{className:Ra.captionRegion,"data-size":n,role:"status","aria-live":"polite","aria-atomic":"true",children:l})})]})}const yq="_container_1k3qg_11",_q="_screenshot_1k3qg_20",xq="_flash_1k3qg_30",Kb={container:yq,screenshot:_q,flash:xq};function Sq(t){const{isActive:e,imageUrl:n,onComplete:i,duration:r=2e3}=t,[a,o]=w.useState(!1),s=w.useRef(null),l=w.useRef(i);return w.useEffect(()=>{l.current=i},[i]),w.useEffect(()=>{if(!e){o(!1),s.current&&(clearTimeout(s.current),s.current=null);return}if(!s.current)return o(!0),s.current=setTimeout(()=>{var c;o(!1),s.current=null,(c=l.current)==null||c.call(l)},r),()=>{s.current&&(clearTimeout(s.current),s.current=null)}},[e,r]),a?f.jsxs("div",{className:Kb.container,"aria-live":"polite","aria-label":"Screenshot captured",children:[n&&f.jsx("img",{src:n,alt:"Captured screenshot",className:Kb.screenshot}),f.jsx("div",{className:Kb.flash})]}):null}const kq="_container_13ukq_1",Tq="_dragging_13ukq_5",wq="_placeholder_13ukq_9",Cq="_handleButton_13ukq_15",Eq="_customHandle_13ukq_105",ql={container:kq,dragging:Tq,placeholder:wq,handleButton:Cq,"handle-top":"_handle-top_13ukq_65","handle-bottom":"_handle-bottom_13ukq_75","handle-left":"_handle-left_13ukq_85","handle-right":"_handle-right_13ukq_95",customHandle:Eq};function Rq(t){const{disabled:e,lingerMs:n,isDragging:i}=t,[r,a]=w.useState(!1),o=w.useRef(null),s=w.useCallback(()=>{o.current!==null&&(window.clearTimeout(o.current),o.current=null)},[]),l=w.useCallback(()=>{e||(s(),a(!0))},[s,e]),c=w.useCallback(()=>{e||i||(s(),o.current=window.setTimeout(()=>{a(!1),o.current=null},n))},[s,e,i,n]);return w.useEffect(()=>{i&&l()},[i,l]),w.useEffect(()=>s,[s]),{isHandleVisible:r,showHandle:l,scheduleHideHandle:c}}function Aq(t){const{initialPosition:e,preserveSpace:n,onPositionChange:i}=t,r=w.useRef(null),[a,o]=w.useState(!!e),[s,l]=w.useState(!1),[c,u]=w.useState(null),[d,h]=w.useState(()=>e??{x:0,y:0}),p=w.useRef(d);s||(p.current=d);const b=w.useRef(null),m=w.useRef(!1),S=w.useRef(!1);w.useEffect(()=>{e&&(S.current||(o(!0),h(e),p.current=e))},[e==null?void 0:e.x,e==null?void 0:e.y]),w.useEffect(()=>{if(e||m.current)return;const v=r.current;if(!v)return;const k=v.getBoundingClientRect(),T={x:k.left,y:k.top};m.current=!0,o(!0),h(T),p.current=T,u(n?{width:k.width,height:k.height}:null)},[e,n]);const g=w.useCallback(v=>{const k=b.current;if(!(!k||v.pointerId!==k.pointerId)){b.current=null,S.current=!0,h(p.current),l(!1);try{v.currentTarget.releasePointerCapture(k.pointerId)}catch{}}},[]),y=w.useCallback(v=>{v.button===0&&(v.preventDefault(),v.currentTarget.setPointerCapture(v.pointerId),b.current={pointerId:v.pointerId,startClientX:v.clientX,startClientY:v.clientY,startX:p.current.x,startY:p.current.y},l(!0))},[]),x=w.useCallback(v=>{const k=b.current;if(!k||v.pointerId!==k.pointerId)return;const T={x:k.startX+(v.clientX-k.startClientX),y:k.startY+(v.clientY-k.startClientY)};p.current=T,r.current&&(r.current.style.transform=`translate3d(${T.x}px, ${T.y}px, 0)`),i==null||i(T)},[i]);return{containerRef:r,isFixed:a,isDragging:s,position:d,placeholderSize:c,onPointerDown:y,onPointerMove:x,endDrag:g}}function Nq(t){const{children:e,className:n,handle:i="top",initialPosition:r,disabled:a=!1,preserveSpace:o=!0,zIndex:s=1e3,onPositionChange:l,handleAriaLabel:c="Drag",handleLingerMs:u=350,style:d,...h}=t,{containerRef:p,isFixed:b,isDragging:m,position:S,placeholderSize:g,onPointerDown:y,onPointerMove:x,endDrag:v}=Aq({initialPosition:r,preserveSpace:o,onPositionChange:l}),{isHandleVisible:k,showHandle:T,scheduleHideHandle:C}=Rq({disabled:a,lingerMs:u,isDragging:m}),R=typeof e=="function",A=w.useMemo(()=>{const O=B=>f.jsx("div",{className:se(ql.customHandle,B.className),onPointerDown:y,onPointerMove:x,onPointerUp:v,onPointerCancel:v,children:B.children});return O.displayName="Draggable.Handle",O},[y,x,v]),N={...d,position:b?"fixed":"relative",top:b?0:d==null?void 0:d.top,left:b?0:d==null?void 0:d.left,transform:b?`translate3d(${S.x}px, ${S.y}px, 0)`:d==null?void 0:d.transform,zIndex:b?s:d==null?void 0:d.zIndex};return f.jsxs(f.Fragment,{children:[o&&b&&g?f.jsx("div",{className:ql.placeholder,style:{width:g.width,height:g.height}}):null,f.jsxs("div",{ref:p,className:se(ql.container,m?ql.dragging:null,n),"data-handle-visible":R?void 0:a?"false":k||m?"true":"false",style:N,onMouseEnter:R?void 0:T,onMouseLeave:R?void 0:C,...h,children:[!R&&!a?f.jsx("button",{type:"button",className:se(ql.handleButton,ql[`handle-${i}`]),"aria-label":c,onMouseEnter:T,onMouseLeave:C,onPointerDown:O=>{T(),y(O)},onPointerMove:x,onPointerUp:v,onPointerCancel:v}):null,R?e({Handle:A}):e]})]})}const Oq="_container_gzwdo_1",Mq="_captionRegion_gzwdo_14",Dq="_status_gzwdo_22",Pq="_captionText_gzwdo_29",_p={container:Oq,captionRegion:Mq,status:Dq,captionText:Pq},Lq={idle:null,thinking:"Thinking...",searching:"Searching..."};function Iq(t){const{text:e,status:n,className:i,...r}=t,a=n?Lq[n]:null;return f.jsx("div",{...r,className:se(_p.container,i),"data-testid":"pip-captions-panel",children:f.jsxs("div",{className:_p.captionRegion,role:"status","aria-live":"polite","aria-atomic":"true",children:[a?f.jsx("div",{className:_p.status,children:a}):null,f.jsx("div",{className:_p.captionText,children:e})]})})}const jq="_panel_1laxg_1",Bq="_row_1laxg_22",Uq="_stepContent_1laxg_29",zq="_stepLabel_1laxg_37",Fq="_currentStep_1laxg_44",qq="_nextStep_1laxg_51",Hq="_skipButtonContainer_1laxg_65",Vq="_circleButton_1laxg_73",Gq="_arrowPlaceholder_1laxg_100",Wq="_skipButton_1laxg_65",nr={panel:jq,row:Bq,stepContent:Uq,stepLabel:zq,currentStep:Fq,nextStep:qq,skipButtonContainer:Hq,circleButton:Vq,arrowPlaceholder:Gq,skipButton:Wq},Yq="_truncatedText_1u580_1",Kq={truncatedText:Yq};function S3(t){const{children:e,maxLines:n=2,className:i,"data-testid":r}=t;return f.jsx("div",{className:`${Kq.truncatedText} ${i||""}`,style:{WebkitLineClamp:n},"data-testid":r,children:e})}function Xq(t,e,n){var c;const i=t.length,r=n&&i>0&&((c=t[i-1])==null?void 0:c.title)==="Conclusion",a=r?t.slice(0,-1):t.slice(),o=a.length;if(o===0)return{visibleSteps:a,currentIndex:null};const s=typeof e=="number"&&Number.isFinite(e)?e:1;if(r&&s===i)return{visibleSteps:a,currentIndex:null};const l=Math.min(Math.max(s,1),o)-1;return{visibleSteps:a,currentIndex:l}}function Xb(t,e){return e<=0||typeof t!="number"||!Number.isFinite(t)?0:Math.min(Math.max(Math.trunc(t),1),e)-1}function $q(t){var C;const{steps:e,currentStep:n,onStepClick:i,hideTrailingConclusionStep:r=!0,className:a,testId:o,...s}=t,{visibleSteps:l,currentIndex:c}=w.useMemo(()=>Xq(e,n,r),[n,r,e]),[u,d]=w.useState(()=>Xb(n,l.length)),h=w.useRef(!1);w.useEffect(()=>{if(!h.current)d(Xb(n,l.length));else{const R=Xb(n,l.length);u===R&&(h.current=!1)}},[n,l,u]);const p=l.length,b=l[u],m=u>0,S=u<p-1,g=S?(C=l[u+1])==null?void 0:C.title:void 0,y=p===0?0:u+1,x=c!==null&&b&&u!==c,v=()=>{m&&(h.current=!0,d(R=>Math.max(R-1,0)))},k=()=>{S&&(h.current=!0,d(R=>Math.min(R+1,p-1)))},T=()=>{!x||!b||!i||(h.current=!1,i(u,b))};return f.jsxs("div",{...s,className:se(nr.panel,a),"data-testid":o,role:"group","aria-label":"Course progress",children:[f.jsxs("div",{className:nr.row,children:[m?f.jsx("button",{type:"button",className:nr.circleButton,"aria-label":"Previous step",onClick:v,children:f.jsx(EE,{size:14})}):f.jsx("span",{className:nr.arrowPlaceholder,"aria-hidden":"true"}),f.jsxs("div",{className:nr.stepContent,children:[f.jsxs(xi,{className:nr.stepLabel,"aria-live":"polite",children:["Step ",y,"/",p]}),f.jsx(S3,{maxLines:2,children:f.jsx(xi,{className:nr.currentStep,"data-testid":"pip-outline-current-step",children:(b==null?void 0:b.title)??"No steps available"})}),g?f.jsx(S3,{maxLines:2,children:f.jsxs(xi,{variant:"muted",className:nr.nextStep,children:["Next: ",g]})}):null]}),S?f.jsx("button",{type:"button",className:nr.circleButton,"aria-label":"Next step",onClick:k,children:f.jsx(VB,{size:14})}):f.jsx("span",{className:nr.arrowPlaceholder,"aria-hidden":"true"})]}),x?f.jsx("div",{className:nr.skipButtonContainer,children:f.jsx("button",{type:"button",className:nr.skipButton,"aria-label":"Skip to this step",onClick:T,children:f.jsx(XB,{size:14})})}):null]})}const Jq="_window_zm5au_1",Qq="_exitButton_zm5au_14",Zq="_content_zm5au_47",eH="_contentTopOverlay_zm5au_58",tH="_dragHandle_zm5au_68",nH="_contentBottomOverlay_zm5au_78",iH="_controls_zm5au_87",rH="_messagesPanelWrapper_zm5au_95",Eo={window:Jq,exitButton:Qq,content:Zq,contentTopOverlay:eH,dragHandle:tH,contentBottomOverlay:nH,controls:iH,messagesPanelWrapper:rH};function aH(t){return t==null?!1:typeof t=="string"?t.trim().length>0:!0}function oH(t){const{onExit:e,controlBarProps:n,isCourseOutlineSelected:i,onCourseOutlineToggle:r,isCaptionsEnabled:a=!1,onCaptionsToggle:o,courseOutline:s,messagesPanel:l,avatarFallbackProps:c,contentTopOverlaySlot:u,screenshotUrl:d,cameraShotTrigger:h,className:p,testId:b,...m}=t,S=i,g=n.isChatOpen&&!S&&l,y=c==null?void 0:c.captionsText,x=a&&aH(y),[v,k]=w.useState(!1),T=w.useRef(h),C=w.useCallback(()=>{k(!1)},[]);w.useEffect(()=>{h&&h>0&&h!==T.current&&k(!0),T.current=h},[h]);const R=w.useCallback(()=>f.jsx(x3,{audioPower:(c==null?void 0:c.audioPower)??0,size:"sm",background:"flat",imageSrc:c==null?void 0:c.imageSrc,ariaLabel:c==null?void 0:c.ariaLabel,status:c==null?void 0:c.status}),[c]),A=S?s?f.jsx($q,{steps:s.steps,currentStep:s.currentStep,onStepClick:s.onStepClick,hideTrailingConclusionStep:s.hideTrailingConclusionStep}):R():g?f.jsx("div",{className:Eo.messagesPanelWrapper,children:l}):x?f.jsx(Iq,{text:y}):R();return f.jsxs("div",{...m,className:se(Eo.window,p),"data-testid":b,role:"group","aria-label":"Picture-in-Picture",children:[f.jsxs("div",{className:Eo.content,children:[f.jsx("div",{className:Eo.contentTopOverlay,children:u}),f.jsx("button",{type:"button",className:Eo.exitButton,onClick:e,"aria-label":"Exit PiP",children:f.jsx(WB,{size:14})}),A,!g&&f.jsxs("div",{className:Eo.contentBottomOverlay,children:[f.jsx(sp,{isOn:i,onClick:r,variant:"primary",size:"xs","aria-label":"Toggle course outline",children:f.jsx($B,{size:18})}),f.jsx(sp,{isOn:a,onClick:o,variant:"primary",size:"xs","aria-label":"Toggle captions",children:f.jsx(HB,{size:18})})]}),f.jsx(Sq,{isActive:v,imageUrl:d??null,onComplete:C})]}),f.jsx("div",{className:Eo.controls,children:f.jsx(iq,{...n})})]})}function sH(t){const{initialPosition:e,onPositionChange:n,zIndex:i=1e3,...r}=t;return f.jsx(Nq,{initialPosition:e,onPositionChange:n,zIndex:i,preserveSpace:!1,children:({Handle:a})=>f.jsx(oH,{...r,contentTopOverlaySlot:f.jsx(a,{className:Eo.dragHandle})})})}const lH="_root_ygi3o_1",cH="_overlay_ygi3o_7",uH="_caption_ygi3o_17",$b={root:lH,overlay:cH,caption:uH};function dH(t){return t==null?!1:typeof t=="string"?t.trim().length>0:!0}function hH(t){const{children:e,className:n,text:i}=t,r=dH(i);return f.jsxs("div",{className:se($b.root,n),children:[e,r?f.jsx("div",{className:$b.overlay,role:"status","aria-live":"polite","aria-atomic":"true",children:f.jsx("div",{className:$b.caption,children:i})}):null]})}const fH="_box_dc9yv_1",pH={box:fH},k3={none:"0px",panel:"var(--radius-panel)",card:"var(--radius-card)"},T3={surface:"var(--color-surface)",surfaceMuted:"var(--color-surface-muted)",surfaceAlt:"var(--color-surface-alt)",primarySoft:"var(--color-primary-soft)",primarySofter:"var(--color-primary-softer)",dangerSurface:"var(--color-danger-surface)"};function mH(t){if(t!==void 0){if(typeof t=="number")return`${t}px`;if(t in k3)return k3[t];if(typeof t=="string"&&t.trim().length>0)return t}}function gH(t){if(t!==void 0){if(t in T3)return T3[t];if(typeof t=="string"&&t.trim().length>0)return t}}function vH(t,e){const{as:n,className:i,padding:r,paddingX:a,paddingY:o,paddingTop:s,paddingBottom:l,paddingLeft:c,paddingRight:u,paddingSm:d,paddingMd:h,paddingLg:p,paddingXl:b,margin:m,marginX:S,marginY:g,marginTop:y,marginBottom:x,marginLeft:v,marginRight:k,radius:T,radiusTop:C,radiusBottom:R,radiusLeft:A,radiusRight:N,radiusTopLeft:O,radiusTopRight:B,radiusBottomLeft:W,radiusBottomRight:L,background:K,gap:P,style:V,...X}=t,te=n??"div",$={...V},z=$,Z={},Q=(U,fe)=>{if(fe===void 0)return;const me=Sr(fe);me&&($[U]=me)},ce=(U,fe)=>{if(fe===void 0)return;const me=Sr(fe);me&&($[U]=me)},j=(U,fe)=>{if(fe===void 0)return;const me=mH(fe);me&&($[U]=me)},ge={sm:d,md:h,lg:p,xl:b};if(r!==void 0){const U=Sr(r);U&&(z["--box-padding"]=U)}for(const[U,fe]of Object.entries(ge)){if(fe===void 0)continue;const me=Sr(fe);me&&(z[`--box-padding-${U}`]=me,Z[`data-padding-${U}`]="")}if(a!==void 0){const U=Sr(a);U&&($.paddingLeft=U,$.paddingRight=U)}if(o!==void 0){const U=Sr(o);U&&($.paddingTop=U,$.paddingBottom=U)}if(Q("paddingTop",s),Q("paddingBottom",l),Q("paddingLeft",c),Q("paddingRight",u),m!==void 0){const U=Sr(m);U&&($.margin=U)}if(S!==void 0){const U=Sr(S);U&&($.marginLeft=U,$.marginRight=U)}if(g!==void 0){const U=Sr(g);U&&($.marginTop=U,$.marginBottom=U)}if(ce("marginTop",y),ce("marginBottom",x),ce("marginLeft",v),ce("marginRight",k),P!==void 0){const U=Sr(P);U&&($.gap=U)}if(j("borderRadius",T),C!==void 0&&(j("borderTopLeftRadius",C),j("borderTopRightRadius",C)),R!==void 0&&(j("borderBottomLeftRadius",R),j("borderBottomRightRadius",R)),A!==void 0&&(j("borderTopLeftRadius",A),j("borderBottomLeftRadius",A)),N!==void 0&&(j("borderTopRightRadius",N),j("borderBottomRightRadius",N)),j("borderTopLeftRadius",O),j("borderTopRightRadius",B),j("borderBottomLeftRadius",W),j("borderBottomRightRadius",L),K!==void 0){const U=gH(K);U&&($.background=U)}return f.jsx(te,{ref:e,className:se(pH.box,i),style:$,...Z,...X})}const xp=hi.forwardRef(vH);xp.displayName="Box";const bH="_panel_eawk4_1",yH="_selected_eawk4_10",w3={panel:bH,selected:yH};function qu(t){const{children:e,className:n,selected:i,...r}=t;return f.jsx("div",{className:se(w3.panel,i?w3.selected:null,n),...r,children:e})}const _H="_root_yccm8_1",xH="_header_yccm8_8",SH="_icon_yccm8_15",kH="_text_yccm8_26",TH="_heading_yccm8_33",wH="_description_yccm8_41",CH="_body_yccm8_47",EH="_footer_yccm8_54",Ro={root:_H,header:xH,icon:SH,text:kH,heading:TH,description:wH,body:CH,footer:EH};function C3(t){const{className:e,...n}=t;return f.jsx("div",{className:se(Ro.icon,e),...n})}function E3(t){const{className:e,...n}=t;return f.jsx("h3",{className:se(Ro.heading,e),...n})}function R3(t){const{className:e,...n}=t;return f.jsx("p",{className:se(Ro.description,e),...n})}function A3(t){const{className:e,...n}=t;return f.jsx("div",{className:se(Ro.footer,e),...n})}function RH(t){const e=w.Children.toArray(t),n=[];let i,r,a,o;for(const s of e){if(w.isValidElement(s)&&s.type===C3&&i===void 0){i=s;continue}if(w.isValidElement(s)&&s.type===E3&&r===void 0){r=s;continue}if(w.isValidElement(s)&&s.type===R3&&a===void 0){a=s;continue}if(w.isValidElement(s)&&s.type===A3&&o===void 0){o=s;continue}n.push(s)}return{icon:i,heading:r,description:a,footer:o,body:n}}function AH(t){const{children:e,className:n,...i}=t,r=RH(e),a=r.icon||r.heading||r.description;return f.jsxs(qu,{className:se(Ro.root,n),...i,children:[a?f.jsxs("div",{className:Ro.header,children:[r.icon,r.heading||r.description?f.jsxs("div",{className:Ro.text,children:[r.heading,r.description]}):null]}):null,r.body.length?f.jsx("div",{className:Ro.body,children:r.body}):null,r.footer]})}const Jb=Object.assign(AH,{Icon:C3,Heading:E3,Description:R3,Footer:A3}),NH="_panel_f4a69_1",OH="_header_f4a69_10",MH="_title_f4a69_19",DH="_scrollArea_f4a69_29",PH="_scrollable_f4a69_34",LH="_list_f4a69_39",IH="_courseButton_f4a69_45",jH="_courseCard_f4a69_61",BH="_loading_f4a69_65",UH="_spinnerWrapper_f4a69_69",zH="_spinner_f4a69_69",FH="_contentHidden_f4a69_92",qH="_courseHeading_f4a69_101",HH="_courseDescription_f4a69_107",VH="_empty_f4a69_116",Ln={panel:NH,header:OH,title:MH,scrollArea:DH,scrollable:PH,list:LH,courseButton:IH,courseCard:jH,loading:BH,spinnerWrapper:UH,spinner:zH,contentHidden:FH,courseHeading:qH,courseDescription:HH,empty:VH};function GH(t){const{selectionMode:e,selectedCourseIds:n,defaultSelectedCourseIds:i,onSelectedCourseIdsChange:r}=t,a=n!==void 0,[o,s]=w.useState(()=>i??[]),l=a?n:o,c=w.useCallback(d=>{a||s(d),r==null||r(d)},[a,r]),u=w.useCallback(d=>{const h=l.includes(d);if(e==="single"){c(h?[]:[d]);return}if(h){c(l.filter(p=>p!==d));return}c([...l,d])},[l,e,c]);return{selectedCourseIds:l,toggleCourseId:u}}function WH(t){const{title:e="Courses",ariaLabel:n,className:i,courses:r,selectionMode:a="multiple",selectedCourseIds:o,onCourseToggle:s,loadingCourseId:l,emptyMessage:c="No courses available",testId:u,...d}=t;return f.jsxs(qu,{...d,className:se(Ln.panel,i),role:"region","aria-label":n??e,"data-testid":u,children:[f.jsx("div",{className:Ln.header,children:f.jsx(xi,{as:"h2",className:Ln.title,children:e})}),f.jsx("div",{className:Ln.scrollArea,children:f.jsx(zl,{className:Ln.scrollable,children:r.length===0?f.jsx(xi,{variant:"muted",className:Ln.empty,"data-testid":"course-panel-empty",children:c}):f.jsx("div",{className:Ln.list,"data-testid":"course-panel-list",children:r.map(h=>{const p=o.includes(h.id),b=l!=null&&h.id===l,m=h.disabled===!0||l!=null,S=se(Ln.courseButton,b&&Ln.loading);return f.jsxs("button",{type:"button",className:S,"aria-pressed":p,"aria-disabled":m,"aria-busy":b||void 0,disabled:m,onClick:()=>s==null?void 0:s(h.id,h),"data-testid":`course-panel-item-${h.id}`,children:[b?f.jsx("span",{className:Ln.spinnerWrapper,"aria-hidden":"true","data-testid":`course-panel-item-spinner-${h.id}`,children:f.jsx("span",{className:Ln.spinner})}):null,f.jsxs(Jb,{selected:p,className:Ln.courseCard,children:[f.jsx(Jb.Heading,{className:se(Ln.courseHeading,b&&Ln.contentHidden),children:h.title}),h.description?f.jsx(Jb.Description,{className:se(Ln.courseDescription,b&&Ln.contentHidden),children:h.description}):null]})]},h.id)})})})})]})}function YH(t){const{selectionMode:e="multiple",selectedCourseIds:n,defaultSelectedCourseIds:i,onSelectedCourseIdsChange:r,onCourseToggle:a,...o}=t,{selectedCourseIds:s,toggleCourseId:l}=GH({selectionMode:e,selectedCourseIds:n,defaultSelectedCourseIds:i,onSelectedCourseIdsChange:r}),c=w.useCallback((u,d)=>{l(u),a==null||a(u,d)},[a,l]);return f.jsx(WH,{...o,selectionMode:e,selectedCourseIds:s,onCourseToggle:c})}const KH="_panel_1je0q_1",XH="_header_1je0q_10",$H="_headerActions_1je0q_19",JH="_popoverAnchor_1je0q_27",QH="_backButton_1je0q_31",ZH="_divider_1je0q_38",eV="_title_1je0q_44",tV="_scrollArea_1je0q_54",nV="_scrollable_1je0q_59",iV="_list_1je0q_64",rV="_section_1je0q_70",aV="_sectionHeader_1je0q_76",oV="_sectionTitle_1je0q_80",sV="_sectionTitleCompact_1je0q_88",lV="_item_1je0q_92",cV="_itemClickable_1je0q_106",uV="_itemCompleted_1je0q_110",dV="_itemCurrent_1je0q_114",hV="_itemFuture_1je0q_118",fV="_itemDisabled_1je0q_123",pV="_row_1je0q_137",mV="_stepHeader_1je0q_144",gV="_stepNumber_1je0q_153",vV="_stepTitle_1je0q_159",bV="_checkIcon_1je0q_171",yV="_empty_1je0q_175",_V="_confirmationPopover_1je0q_180",xV="_confirmationMessage_1je0q_204",SV="_confirmationActions_1je0q_211",kV="_confirmationButton_1je0q_216",TV="_confirmationButtonCancel_1je0q_234",wV="_confirmationButtonNeutral_1je0q_242",Re={panel:KH,header:XH,headerActions:$H,popoverAnchor:JH,backButton:QH,divider:ZH,title:eV,scrollArea:tV,scrollable:nV,list:iV,section:rV,sectionHeader:aV,sectionTitle:oV,sectionTitleCompact:sV,item:lV,itemClickable:cV,itemCompleted:uV,itemCurrent:dV,itemFuture:hV,itemDisabled:fV,row:pV,stepHeader:mV,stepNumber:gV,stepTitle:vV,checkIcon:bV,empty:yV,confirmationPopover:_V,confirmationMessage:xV,confirmationActions:SV,confirmationButton:kV,confirmationButtonCancel:TV,confirmationButtonNeutral:wV};function CV(t){var p;const{steps:e,currentStep:n,hideTrailingConclusionStep:i}=t,r=e.length,a=i&&r>0&&((p=e[r-1])==null?void 0:p.title)==="Conclusion",o=a?e.slice(0,-1):e.slice(),s=o.length,l=typeof n=="number"&&isFinite(n)?n:1;if(s===0)return{visibleSteps:o,completedIndices:[],currentIndex:null,futureIndices:[]};if(a&&l===r)return{visibleSteps:o,completedIndices:Array.from({length:s},(b,m)=>m),currentIndex:null,futureIndices:[]};const c=Math.min(Math.max(l,1),s)-1,u=Array.from({length:Math.max(0,c)},(b,m)=>m),d=Math.min(c,s-1),h=Array.from({length:Math.max(0,s-(d+1))},(b,m)=>d+1+m);return{visibleSteps:o,completedIndices:u,currentIndex:d,futureIndices:h}}function EV(t){const{title:e="Course Outline",ariaLabel:n,className:i,steps:r,currentStep:a,onStepClick:o,hideTrailingConclusionStep:s=!0,emptyMessage:l="No steps available",density:c="default",testId:u,onBackToCoursesConfirm:d,backToCoursesDisabled:h=!1,backToCoursesLabel:p="Back to courses",backToCoursesConfirmMessage:b="Going back will end this course. You can start another course from the list.",backToCoursesConfirmLabel:m="Back",backToCoursesCancelLabel:S="Cancel",showBackToCourses:g=!0,...y}=t,[x,v]=w.useState(!1),k=w.useRef(null),T=h||!d,C=w.useCallback(V=>(V+1).toString().padStart(2,"0"),[]),{visibleSteps:R,completedIndices:A,currentIndex:N,futureIndices:O}=w.useMemo(()=>CV({steps:r,currentStep:a,hideTrailingConclusionStep:s}),[a,s,r]),B=c==="compact"?"md":"lg",W=w.useCallback(()=>{T||v(V=>!V)},[T]),L=w.useCallback(()=>{v(!1)},[]),K=w.useCallback(()=>{v(!1),d&&d()},[d]);w.useEffect(()=>{if(!x)return;const V=te=>{const $=te.composedPath();k.current&&!$.includes(k.current)&&v(!1)},X=te=>{te.key==="Escape"&&v(!1)};return document.addEventListener("mousedown",V),document.addEventListener("keydown",X),()=>{document.removeEventListener("mousedown",V),document.removeEventListener("keydown",X)}},[x]),w.useEffect(()=>{T&&x&&v(!1)},[T,x]);const P=w.useCallback((V,X)=>{const te=R[V];if(!te)return null;const $=typeof o=="function",z=$&&te.disabled===!0,Z=$&&!z,Q=se(Re.item,{[Re.itemClickable]:Z,[Re.itemCompleted]:X==="completed",[Re.itemCurrent]:X==="current",[Re.itemFuture]:X==="future",[Re.itemDisabled]:z}),ce=f.jsxs("div",{className:Re.row,children:[f.jsxs("div",{className:Re.stepHeader,children:[f.jsx("span",{className:Re.stepNumber,children:C(V)}),f.jsx("span",{className:Re.stepTitle,children:te.title})]}),X==="completed"?f.jsx(ap,{size:20,className:Re.checkIcon}):null]});return $?f.jsx(xp,{as:"button",type:"button",className:Q,onClick:()=>{Z&&o(V,te)},disabled:z,"aria-current":X==="current"?"step":void 0,"aria-label":`Step ${C(V)}: ${te.title}`,"data-testid":`course-outline-item-${te.id}`,padding:B,radius:"panel",gap:"sm",children:ce},te.id):f.jsx(xp,{className:Q,"aria-current":X==="current"?"step":void 0,"aria-label":`Step ${C(V)}: ${te.title}`,"data-testid":`course-outline-item-${te.id}`,padding:B,radius:"panel",gap:"sm",children:ce},te.id)},[C,B,o,R]);return f.jsxs(qu,{...y,className:se(Re.panel,i),role:"region","aria-label":n??e,"data-testid":u,children:[f.jsxs("div",{className:Re.header,children:[f.jsx(xi,{as:"h2",className:Re.title,children:e}),g?f.jsx("div",{className:Re.headerActions,children:f.jsxs("div",{ref:k,className:Re.popoverAnchor,children:[f.jsxs(_s,{type:"button",variant:"secondary",color:"default",size:"sm",className:Re.backButton,onClick:W,disabled:T,"aria-label":p,"data-testid":"course-outline-back-button",children:[f.jsx(EE,{size:16,"aria-hidden":"true"}),f.jsx("span",{children:p})]}),x?f.jsxs("div",{className:Re.confirmationPopover,role:"dialog","aria-label":"Back to courses confirmation","data-testid":"course-outline-back-confirm",children:[f.jsx("p",{className:Re.confirmationMessage,children:b}),f.jsxs("div",{className:Re.confirmationActions,children:[f.jsx("button",{type:"button",className:se(Re.confirmationButton,Re.confirmationButtonCancel),onClick:L,"data-testid":"course-outline-back-cancel",children:S}),f.jsx("button",{type:"button",className:se(Re.confirmationButton,Re.confirmationButtonNeutral),onClick:K,"data-testid":"course-outline-back-confirm-action",children:m})]})]}):null]})}):null]}),f.jsx("div",{className:Re.divider,"aria-hidden":"true"}),f.jsx("div",{className:Re.scrollArea,children:f.jsx(zl,{className:Re.scrollable,children:R.length===0?f.jsx(xi,{variant:"muted",className:Re.empty,"data-testid":"course-outline-empty",children:l}):f.jsxs("div",{className:Re.list,"data-testid":"course-outline-list",children:[A.length>0?f.jsxs("div",{className:Re.section,"data-testid":"course-outline-section-completed",children:[f.jsx("div",{className:Re.sectionHeader,children:f.jsx("span",{className:se(Re.sectionTitle,c==="compact"?Re.sectionTitleCompact:null),children:"Completed"})}),A.map(V=>P(V,"completed"))]}):null,N!==null?f.jsxs("div",{className:Re.section,"data-testid":"course-outline-section-current",children:[f.jsx("div",{className:Re.sectionHeader,children:f.jsx("span",{className:se(Re.sectionTitle,c==="compact"?Re.sectionTitleCompact:null),children:"Current"})}),P(N,"current")]}):null,O.length>0?f.jsxs("div",{className:Re.section,"data-testid":"course-outline-section-upcoming",children:[f.jsx("div",{className:Re.sectionHeader,children:f.jsx("span",{className:se(Re.sectionTitle,c==="compact"?Re.sectionTitleCompact:null),children:"Upcoming"})}),O.map(V=>P(V,"future"))]}):null]})})})]})}function RV(t){return f.jsx(EV,{...t})}const AV="_panel_h7cuf_1",NV="_messagesArea_h7cuf_20",OV="_messagesList_h7cuf_46",MV="_messageItem_h7cuf_53",DV="_messageMetadata_h7cuf_59",PV="_senderName_h7cuf_67",LV="_timestamp_h7cuf_71",IV="_messageBubble_h7cuf_75",jV="_agentMessage_h7cuf_85",BV="_agentActions_h7cuf_89",UV="_copyButton_h7cuf_95",zV="_copyButtonCopied_h7cuf_129",FV="_empty_h7cuf_133",qV="_composer_h7cuf_140",HV="_composerDisabled_h7cuf_160",VV="_composerInput_h7cuf_165",GV="_sendButton_h7cuf_180",Mn={panel:AV,messagesArea:NV,messagesList:OV,messageItem:MV,messageMetadata:DV,senderName:PV,timestamp:LV,messageBubble:IV,agentMessage:jV,agentActions:BV,copyButton:UV,copyButtonCopied:zV,empty:FV,composer:qV,composerDisabled:HV,composerInput:VV,sendButton:GV};function WV(t){const e=new Date(t),n=e.getHours(),i=e.getMinutes(),r=n>=12?"PM":"AM",a=n%12||12,o=i.toString().padStart(2,"0");return`${a}:${o}${r}`}function YV(t,e){var i,r;if(typeof t.isAgent=="boolean")return t.isAgent;const n=((i=t.from)==null?void 0:i.identity)??void 0;return n&&e&&n===e?!1:((r=t.attributes)==null?void 0:r.source)==="agent-rpc"?!0:n?n==="agent-avatar"||n.startsWith("agent-"):!1}function KV(t,e){var i,r,a;const n=(i=t.from)==null?void 0:i.identity;return n&&e&&n===e?"You":((r=t.from)==null?void 0:r.name)??((a=t.attributes)==null?void 0:a.senderName)??n??"Unknown"}async function XV(t){var n;if(typeof navigator<"u"&&((n=navigator.clipboard)!=null&&n.writeText)){await navigator.clipboard.writeText(t);return}if(typeof document>"u")throw new Error("Clipboard unavailable");const e=document.createElement("textarea");e.value=t,e.style.position="fixed",e.style.left="-9999px",e.style.top="0",e.setAttribute("readonly","true"),document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e)}function $V(t){const{messages:e,localIdentity:n,onSend:i,isSending:r=!1,inputPlaceholder:a="Type a message...",className:o,testId:s,...l}=t,[c,u]=w.useState(""),[d,h]=w.useState(null),p=w.useRef(null),b=w.useRef(null),m=w.useMemo(()=>{const v=e[e.length-1];return v?v.id??`${v.timestamp}-${e.length-1}`:null},[e]);w.useEffect(()=>{var v,k;(k=(v=p.current)==null?void 0:v.scrollIntoView)==null||k.call(v,{behavior:"smooth"})},[m]),w.useEffect(()=>()=>{b.current&&(window.clearTimeout(b.current),b.current=null)},[]);const S=w.useCallback(async()=>{const v=c.trim();v.length!==0&&(await i(v),u(""))},[c,i]),g=w.useCallback(v=>{v.key==="Enter"&&(v.preventDefault(),S())},[S]),y=w.useCallback(async(v,k)=>{try{await XV(v.message??""),h(k),b.current&&window.clearTimeout(b.current),b.current=window.setTimeout(()=>{h(null),b.current=null},2e3)}catch(T){console.warn("[PiPChatPanel] Failed to copy message",T)}},[]),x=c.trim().length>0&&!r;return f.jsxs("div",{...l,className:se(Mn.panel,o),"data-testid":s,role:"region","aria-label":"Chat",children:[f.jsx("div",{className:Mn.messagesArea,children:e.length===0?f.jsx("div",{className:Mn.empty,"data-testid":"pip-chat-panel-empty",children:"No messages yet"}):f.jsxs("div",{className:Mn.messagesList,"data-testid":"pip-chat-panel-list",children:[e.map((v,k)=>{const T=v.id??`${v.timestamp}-${k}`,C=YV(v,n),R=d===T;return f.jsxs("div",{className:se(Mn.messageItem,C&&Mn.agentMessage),"data-testid":`pip-chat-panel-message-${T}`,children:[f.jsxs("div",{className:Mn.messageMetadata,children:[f.jsx("span",{className:Mn.senderName,children:KV(v,n)}),f.jsx("span",{className:Mn.timestamp,children:WV(v.timestamp)})]}),f.jsx("div",{className:Mn.messageBubble,children:v.message}),C?f.jsx("div",{className:Mn.agentActions,children:f.jsx("button",{type:"button",className:se(Mn.copyButton,R&&Mn.copyButtonCopied),onClick:()=>void y(v,T),"aria-label":R?"Copied":"Copy message",title:R?"Copied":"Copy message","data-testid":"pip-copy-agent-message","data-copied":R?"true":"false",children:f.jsx(RE,{size:14})})}):null]},T)}),f.jsx("div",{ref:p})]})}),f.jsxs("div",{className:se(Mn.composer,r&&Mn.composerDisabled),children:[f.jsx("input",{type:"text",className:Mn.composerInput,value:c,onChange:v=>u(v.target.value),onKeyDown:g,placeholder:a,disabled:r,"aria-label":"Message"}),f.jsx("button",{type:"button",className:Mn.sendButton,onClick:()=>void S(),disabled:!x,"aria-label":"Send message",children:f.jsx(DE,{size:16})})]})]})}const JV="_panel_k5ick_1",QV="_header_k5ick_11",ZV="_title_k5ick_19",eG="_titleCompact_k5ick_29",tG="_headerActions_k5ick_33",nG="_closeButton_k5ick_39",iG="_divider_k5ick_67",rG="_body_k5ick_73",aG="_messagesArea_k5ick_81",oG="_scrollable_k5ick_86",sG="_messagesList_k5ick_90",lG="_messageItem_k5ick_98",cG="_messageMetadata_k5ick_104",uG="_senderName_k5ick_112",dG="_timestamp_k5ick_116",hG="_messageBubble_k5ick_120",fG="_messageText_k5ick_124",pG="_agentMessage_k5ick_130",mG="_agentActions_k5ick_134",gG="_copyButton_k5ick_140",vG="_copyButtonCopied_k5ick_174",bG="_inputRow_k5ick_178",yG="_empty_k5ick_182",_G="_composer_k5ick_188",xG="_composerDefault_k5ick_203",SG="_composerCompact_k5ick_208",kG="_composerDisabled_k5ick_218",TG="_composerInputWrapper_k5ick_223",wG="_composerInput_k5ick_223",CG="_sendButton_k5ick_240",EG="_sendButtonCompact_k5ick_257",nt={panel:JV,header:QV,title:ZV,titleCompact:eG,headerActions:tG,closeButton:nG,divider:iG,body:rG,messagesArea:aG,scrollable:oG,messagesList:sG,messageItem:lG,messageMetadata:cG,senderName:uG,timestamp:dG,messageBubble:hG,messageText:fG,agentMessage:pG,agentActions:mG,copyButton:gG,copyButtonCopied:vG,inputRow:bG,empty:yG,composer:_G,composerDefault:xG,composerCompact:SG,composerDisabled:kG,composerInputWrapper:TG,composerInput:wG,sendButton:CG,sendButtonCompact:EG};function RG(t){const e=new Date(t),n=e.getHours(),i=e.getMinutes(),r=n>=12?"PM":"AM",a=n%12||12,o=i.toString().padStart(2,"0");return`${a}:${o}${r}`}function AG(t,e){var i,r;if(typeof t.isAgent=="boolean")return t.isAgent;const n=((i=t.from)==null?void 0:i.identity)??void 0;return n&&e&&n===e?!1:((r=t.attributes)==null?void 0:r.source)==="agent-rpc"?!0:n?n==="agent-avatar"||n.startsWith("agent-"):!1}function NG(t,e){var i,r,a;const n=(i=t.from)==null?void 0:i.identity;return n&&e&&n===e?"You":((r=t.from)==null?void 0:r.name)??((a=t.attributes)==null?void 0:a.senderName)??n??"Unknown"}async function OG(t){var n;if(typeof navigator<"u"&&((n=navigator.clipboard)!=null&&n.writeText)){await navigator.clipboard.writeText(t);return}if(typeof document>"u")throw new Error("Clipboard unavailable");const e=document.createElement("textarea");e.value=t,e.style.position="fixed",e.style.left="-9999px",e.style.top="0",e.setAttribute("readonly","true"),document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e)}function MG(t){const{disabled:e,placeholder:n,size:i="md",autoFocus:r,onSend:a}=t,[o,s]=w.useState(""),l=w.useCallback(async()=>{const p=o.trim();p.length!==0&&(await a(p),s(""))},[a,o]),c=w.useCallback(p=>{p.key==="Enter"&&(p.preventDefault(),l())},[l]),u=i==="sm"||i==="xs",d=u?18:24,h=o.trim().length>0&&e!==!0;return f.jsxs("div",{className:se(nt.composer,u?nt.composerCompact:nt.composerDefault,e?nt.composerDisabled:null),children:[f.jsx("div",{className:nt.composerInputWrapper,children:f.jsx(LE,{value:o,onChange:s,onKeyDown:c,className:nt.composerInput,placeholder:n??"Send a message ...",disabled:e,size:i,autoFocus:r,"aria-label":"Message"})}),f.jsx("button",{type:"button",className:se(nt.sendButton,u?nt.sendButtonCompact:null),onClick:()=>void l(),disabled:!h,"aria-label":"Send message",children:f.jsx(DE,{size:d})})]})}function N3(t){const{title:e="Messages",ariaLabel:n,className:i,messages:r,isSending:a=!1,localIdentity:o,onSend:s,onClose:l,showCloseButton:c=!0,emptyMessage:u="No messages yet",density:d="default",testId:h,formatTimestamp:p=RG,getSenderName:b,isAgentMessage:m,copyResetDelayMs:S=2e3,showAgentCopyButton:g=!0,inputPlaceholder:y,inputAutoFocus:x,...v}=t,k=w.useRef(null),[T,C]=w.useState(null),R=w.useRef(null),A=w.useCallback(K=>b?b(K):NG(K,o),[b,o]),N=w.useCallback(K=>m?m(K,o):AG(K,o),[m,o]),O=w.useMemo(()=>{const K=r[r.length-1];return K?K.id??`${K.timestamp}-${r.length-1}`:null},[r]);w.useEffect(()=>{var K,P;(P=(K=k.current)==null?void 0:K.scrollIntoView)==null||P.call(K,{behavior:"smooth"})},[O]),w.useEffect(()=>()=>{R.current&&(window.clearTimeout(R.current),R.current=null)},[]);const B=w.useCallback(K=>{C(K),R.current&&window.clearTimeout(R.current),R.current=window.setTimeout(()=>{C(null),R.current=null},S)},[S]),W=w.useCallback(async(K,P)=>{try{await OG(K.message??""),B(P)}catch(V){console.warn("[ChatPanel] Failed to copy message",V)}},[B]),L=d==="compact"?"sm":"md";return f.jsxs(qu,{...v,className:se(nt.panel,i),role:"region","aria-label":n??e,"data-testid":h,children:[f.jsxs("div",{className:nt.header,children:[f.jsx(xi,{as:"h2",className:se(nt.title,d==="compact"?nt.titleCompact:null),children:e}),l&&c?f.jsx("div",{className:nt.headerActions,children:f.jsx("button",{type:"button",className:nt.closeButton,onClick:l,"aria-label":`Close ${e}`,children:f.jsx(op,{size:d==="compact"?18:20})})}):null]}),f.jsx("div",{className:nt.divider,"aria-hidden":"true"}),f.jsxs("div",{className:nt.body,children:[f.jsx("div",{className:nt.messagesArea,children:f.jsx(zl,{className:nt.scrollable,children:r.length===0?f.jsx(xi,{variant:"muted",className:nt.empty,"data-testid":"chat-panel-empty",children:u}):f.jsxs("div",{className:nt.messagesList,"data-testid":"chat-panel-list",children:[r.map((K,P)=>{const V=K.id??`${K.timestamp}-${P}`,X=N(K),te=T===V;return f.jsxs("div",{className:se(nt.messageItem,X?nt.agentMessage:null),"data-testid":`chat-panel-message-${V}`,children:[f.jsxs("div",{className:nt.messageMetadata,children:[f.jsx("span",{className:nt.senderName,children:A(K)}),f.jsx("span",{className:nt.timestamp,children:p(K.timestamp)})]}),f.jsx(xp,{className:nt.messageBubble,padding:"md",radius:"panel",background:X?"surfaceMuted":"surface",children:f.jsx("div",{className:nt.messageText,children:K.message})}),X&&g?f.jsx("div",{className:nt.agentActions,children:f.jsx("button",{type:"button",className:se(nt.copyButton,te?nt.copyButtonCopied:null),onClick:()=>void W(K,V),"aria-label":te?"Copied":"Copy agent message",title:te?"Copied":"Copy agent message","data-testid":"copy-agent-message","data-copied":te?"true":"false",children:f.jsx(RE,{size:18})})}):null]},V)}),f.jsx("div",{ref:k})]})})}),f.jsx("div",{className:nt.inputRow,children:f.jsx(MG,{onSend:s,disabled:a,placeholder:y,size:L,autoFocus:x})})]})]})}const DG="_responsive_14d0j_2",Hu={responsive:DG,"showAboveWidth-sm":"_showAboveWidth-sm_14d0j_15","showAboveWidth-md":"_showAboveWidth-md_14d0j_24","showAboveWidth-lg":"_showAboveWidth-lg_14d0j_33","showAboveWidth-xl":"_showAboveWidth-xl_14d0j_42","hideAboveWidth-sm":"_hideAboveWidth-sm_14d0j_53","hideAboveWidth-md":"_hideAboveWidth-md_14d0j_59","hideAboveWidth-lg":"_hideAboveWidth-lg_14d0j_65","hideAboveWidth-xl":"_hideAboveWidth-xl_14d0j_71","showAboveHeight-short":"_showAboveHeight-short_14d0j_84","showAboveHeight-medium":"_showAboveHeight-medium_14d0j_93","hideAboveHeight-short":"_hideAboveHeight-short_14d0j_104","hideAboveHeight-medium":"_hideAboveHeight-medium_14d0j_110"};function PG(t){const{as:e,children:n,showAboveWidth:i,hideAboveWidth:r,showAboveHeight:a,hideAboveHeight:o,className:s,...l}=t,c=[Hu.responsive];return i&&c.push(Hu[`showAboveWidth-${i}`]),r&&c.push(Hu[`hideAboveWidth-${r}`]),a&&c.push(Hu[`showAboveHeight-${a}`]),o&&c.push(Hu[`hideAboveHeight-${o}`]),f.jsx(e??"div",{...l,className:se(c,s),children:n})}w.createContext("vertical");const LG="_container_1v6ko_1",IG="_video_1v6ko_7",jG="_chip_1v6ko_16",BG="_logo_1v6ko_34",Sp={container:LG,video:IG,chip:jG,logo:BG},UG="https://obi-static.s3.ap-southeast-2.amazonaws.com/videos/greeting.mp4";function zG(t){const{agentName:e="Obi",greetingVideoSrc:n,className:i,...r}=t,a=w.useRef(null),o=()=>{var s;try{(s=a.current)==null||s.pause()}catch{}};return f.jsxs("div",{className:se(Sp.container,i),...r,children:[f.jsx("video",{ref:a,className:Sp.video,src:n??UG,autoPlay:!0,muted:!0,playsInline:!0,onEnded:o}),f.jsxs("div",{className:Sp.chip,children:[f.jsx(YB,{size:12,className:Sp.logo}),f.jsx("span",{children:e})]})]})}typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;const O3=50,Hl="?",M3=/\(error: (.*)\)/,D3=/captureMessage|captureException/;function FG(...t){const e=t.sort((n,i)=>n[0]-i[0]).map(n=>n[1]);return(n,i=0,r=0)=>{const a=[],o=n.split(`
133
- `);for(let s=i;s<o.length;s++){const l=o[s];if(l.length>1024)continue;const c=M3.test(l)?l.replace(M3,"$1"):l;if(!c.match(/\S*Error: /)){for(const u of e){const d=u(c);if(d){a.push(d);break}}if(a.length>=O3+r)break}}return qG(a.slice(r))}}function qG(t){if(!t.length)return[];const e=Array.from(t);return/sentryWrapped/.test(kp(e).function||"")&&e.pop(),e.reverse(),D3.test(kp(e).function||"")&&(e.pop(),D3.test(kp(e).function||"")&&e.pop()),e.slice(0,O3).map(n=>({...n,filename:n.filename||kp(e).filename,function:n.function||Hl}))}function kp(t){return t[t.length-1]||{}}typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;const HG=30,VG=50;function Qb(t,e,n,i){const r={filename:t,function:e==="<anonymous>"?Hl:e,in_app:!0};return n!==void 0&&(r.lineno=n),i!==void 0&&(r.colno=i),r}const GG=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,WG=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,YG=/\((\S*)(?::(\d+))(?::(\d+))\)/,KG=t=>{const e=GG.exec(t);if(e){const[,i,r,a]=e;return Qb(i,Hl,+r,+a)}const n=WG.exec(t);if(n){if(n[2]&&n[2].indexOf("eval")===0){const a=YG.exec(n[2]);a&&(n[2]=a[1],n[3]=a[2],n[4]=a[3])}const[i,r]=P3(n[1]||Hl,n[2]);return Qb(r,i,n[3]?+n[3]:void 0,n[4]?+n[4]:void 0)}},XG=[HG,KG],$G=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,JG=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i;FG(...[XG,[VG,t=>{const e=$G.exec(t);if(e){if(e[3]&&e[3].indexOf(" > eval")>-1){const r=JG.exec(e[3]);r&&(e[1]=e[1]||"eval",e[3]=r[1],e[4]=r[2],e[5]="")}let n=e[3],i=e[1]||Hl;return[i,n]=P3(i,n),Qb(n,i,e[4]?+e[4]:void 0,e[5]?+e[5]:void 0)}}]]);const P3=(t,e)=>{const n=t.indexOf("safari-extension")!==-1,i=t.indexOf("safari-web-extension")!==-1;return n||i?[t.indexOf("@")!==-1?t.split("@")[0]:Hl,n?`safari-extension:${e}`:`safari-web-extension:${e}`]:[t,e]};typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;const ir={shell:"_shell_8bsnr_1",layout:"_layout_8bsnr_11",layoutThree:"_layoutThree_8bsnr_23",leftPanel:"_leftPanel_8bsnr_27",middlePanel:"_middlePanel_8bsnr_36",rightPanel:"_rightPanel_8bsnr_37",videoFrame:"_videoFrame_8bsnr_41",captions:"_captions_8bsnr_52",controls:"_controls_8bsnr_58",coursePanel:"_coursePanel_8bsnr_71",returnToPiPOverlay:"_returnToPiPOverlay_8bsnr_82",returnToPiPButton:"_returnToPiPButton_8bsnr_94"};function Zb(...t){return t.filter(Boolean).join(" ")}function QG(t){const{captionsText:e,avatarAudioPower:n=0,avatarImageSrc:i,avatarAriaLabel:r,avatarStatus:a,controlBarProps:o,courses:s,coursePanelProps:l,middlePanel:c,rightPanel:u,isCourseOutlineOpen:d,onReturnToPiP:h,className:p}=t;return f.jsx("div",{className:Zb(ir.shell,p),"data-testid":"course-dialog-content",children:f.jsxs("div",{className:Zb(ir.layout,u?ir.layoutThree:null),children:[f.jsxs("div",{className:ir.leftPanel,children:[f.jsxs("div",{className:ir.videoFrame,children:[d&&h&&f.jsx("div",{className:ir.returnToPiPOverlay,children:f.jsx("button",{type:"button",className:ir.returnToPiPButton,onClick:h,"aria-label":"Return to PiP","data-testid":"course-return-to-pip",children:f.jsx(GB,{size:14})})}),f.jsx(hH,{className:ir.captions,text:e,children:f.jsx(x3,{audioPower:n,size:"lg",background:"flat",imageSrc:i,ariaLabel:r??"Agent avatar placeholder",status:a})})]}),f.jsx("div",{className:ir.controls,children:f.jsx(BF,{...o})})]}),u?f.jsx("div",{className:ir.rightPanel,"data-testid":"course-dialog-right-panel",children:u}):null,f.jsx("div",{className:ir.middlePanel,"data-testid":"course-dialog-middle-panel",children:c??f.jsx(YH,{...l,courses:s,className:Zb(ir.coursePanel,l==null?void 0:l.className)})})]})})}function L3(t){const{open:e,onClose:n,dialogProps:i,...r}=t;return f.jsx(HE,{open:e,onClose:n,variant:"ghost",...i,children:f.jsx(QG,{...r})})}const ZG=80,eW=500,tW=1e3;function nW(t,e){const{delayMs:n=0}=e??{},r=t.filter(m=>{var g;const S=(g=m.participantInfo)==null?void 0:g.identity;return(S==null?void 0:S.startsWith("agent-"))??!1}).map(m=>m.text??"").join(" ").trim(),[a,o]=w.useState(""),[s,l]=w.useState(!1),c=w.useRef(""),u=w.useRef(null),d=w.useRef(null),h=w.useRef(null),p=m=>{h.current&&(clearTimeout(h.current),h.current=null),n>0?h.current=setTimeout(()=>{o(m)},n):o(m)},b=(m,S)=>m.startsWith(S)?m.slice(S.length).trim():m.trim();return w.useEffect(()=>{if(d.current&&(clearTimeout(d.current),d.current=null),s)return;const m=b(r,c.current);p(m),m.length>ZG?(l(!0),u.current=setTimeout(()=>{l(!1),c.current=r},eW+n)):m.length>0&&(d.current=setTimeout(()=>{c.current=r,p("")},tW+n))},[r,s,n]),w.useEffect(()=>()=>{u.current&&clearTimeout(u.current),d.current&&clearTimeout(d.current),h.current&&clearTimeout(h.current)},[]),{caption:a,hasCaption:a.length>0}}const kr={layout:"_layout_k1q6c_1",left:"_left_k1q6c_10",copy:"_copy_k1q6c_17",description:"_description_k1q6c_25",descriptionScroller:"_descriptionScroller_k1q6c_31",cta:"_cta_k1q6c_36",disclaimer:"_disclaimer_k1q6c_43",right:"_right_k1q6c_47",mediaPanel:"_mediaPanel_k1q6c_56",agentStill:"_agentStill_k1q6c_63",dialogWithSmallClose:"_dialogWithSmallClose_k1q6c_88"};function iW(t){const{open:e,onClose:n,onStart:i,agentName:r,agentSubtitle:a,description:o,startLabel:s="Start Now",disclaimer:l="Sessions are securely recorded for quality improvement purposes.",showCloseButton:c=!1,isStarting:u=!1,greetingVideoSrc:d}=t;return f.jsx(HE,{open:e,onClose:n,size:"large",showCloseButton:c,className:kr.dialogWithSmallClose,children:f.jsxs("div",{className:kr.layout,children:[f.jsxs("div",{className:kr.left,children:[f.jsxs("div",{className:kr.copy,children:[f.jsx(xi,{variant:"heading",children:r}),f.jsx(xi,{variant:"subheading",children:a}),f.jsx(xi,{variant:"muted",as:"div",className:kr.description,children:f.jsx(zl,{className:kr.descriptionScroller,children:f.jsx(nF,{content:o})})})]}),f.jsxs("div",{className:kr.cta,children:[f.jsx(_s,{type:"button",size:"lg",fullWidth:!0,onClick:i,isLoading:u,children:s}),f.jsx(xi,{variant:"subscript",as:"p",className:kr.disclaimer,children:l})]})]}),f.jsx(PG,{showAboveWidth:"md",children:f.jsx("div",{className:kr.right,children:f.jsx(qu,{className:kr.mediaPanel,children:f.jsx(zG,{agentName:r,greetingVideoSrc:d,className:kr.agentStill})})})})]})})}const rW={launcherPill:"_launcherPill_1fhyr_1"};function aW(t){const{label:e,onClick:n}=t;return f.jsx("button",{type:"button",className:rW.launcherPill,onClick:n,"data-testid":"ai-coach-pill",children:e})}const I3="__ama_course__",oW="ama_course",sW=3e4;function lW(t){var No,Oo,Wl,_n,xn,Mo,Do,Kr,Po,Ut,Lo,Io,jo,Bo,Yl,_,I,M,pe,Le,ve,zt,_t,xt,Xr,Ie,Uo,Kl,K3;const{sdk:e,shadowHost:n}=t,i=!!e.passivePlanUuid,r=i?((No=e.client)==null?void 0:No.selectedPlanUuid)??null:null,a=((Oo=e.client)==null?void 0:Oo.session)??null,o=!!a&&(i&&!!r||!!((Wl=e.client)!=null&&Wl.selectedPlanUuid)),[s,l]=w.useState(()=>a),[c,u]=w.useState(()=>a!=null&&a.sessionUuid?uW(a.sessionUuid):null),d=(()=>{var Y;return a?((Y=a.roomId)==null?void 0:Y.startsWith("obs-"))&&!c?"course-selection":"pip":r?"start-session":"hidden"})(),[h,p]=w.useState(()=>d),b=w.useRef(d),[m,S]=w.useState(!1),[g,y]=w.useState(!1),[x,v]=w.useState(!1),[k,T]=w.useState([]),[C,R]=w.useState(null),[A,N]=w.useState(null),[O,B]=w.useState(0),[W,L]=w.useState(!1),[K,P]=w.useState(!1),[V,X]=w.useState(0),[te,$]=w.useState(null),[z,Z]=w.useState([]),[Q,ce]=w.useState(!1),[j,ge]=w.useState(!1),[U,fe]=w.useState(()=>o),me=w.useRef(o),Rt=w.useRef(null),en=w.useRef(null),be=w.useRef(!1),qe=()=>{p(Y=>{const ne=Y==="course-selection",Te=Y==="course-outline"&&be.current;return ne||Te?(be.current=!1,L(!1),"pip"):Y})};w.useEffect(()=>{b.current=h},[h]),w.useEffect(()=>()=>{Rt.current&&clearTimeout(Rt.current)},[]);const bt=()=>{Rt.current&&(clearTimeout(Rt.current),Rt.current=null)},Je=()=>{bt(),en.current=null,N(Y=>Y===null?Y:null)},cn=Y=>{bt(),en.current=Y,N(Y),Rt.current=setTimeout(()=>{const ne=en.current===Y,Te=b.current==="course-selection";ne&&Te&&(en.current=null,N(null)),Rt.current=null},sW)},tn=dW((xn=(_n=e.client)==null?void 0:_n.product)==null?void 0:xn.widget_url_blacklist),Mt=hW(s),{audioDevices:bn}=fW();w.useEffect(()=>{s!=null&&s.sessionUuid&&j3(s.sessionUuid,c)},[c,s==null?void 0:s.sessionUuid]);const{caption:yn}=nW(z,{delayMs:0}),In=typeof navigator<"u"&&!!((Mo=navigator.mediaDevices)!=null&&Mo.getDisplayMedia),Si=((Kr=(Do=s==null?void 0:s.room)==null?void 0:Do.localParticipant)==null?void 0:Kr.isScreenShareEnabled)??!1,de=Y=>{var Ae;const ne=((Ae=e.client)==null?void 0:Ae.identity)??Y.identity,Te=typeof(ne==null?void 0:ne.first_name)=="string"?ne.first_name.trim():"",st=typeof(ne==null?void 0:ne.last_name)=="string"?ne.last_name.trim():"",xe=typeof(ne==null?void 0:ne.email)=="string"&&ne.email.trim().length>0?ne.email.trim():"";return{firstName:Te,lastName:st,email:xe}},We=Y=>{const{firstName:ne,lastName:Te,email:st}=de(Y),xe=[ne,Te,st].map(pt=>pt.trim());return xe.some(pt=>pt.length>0)?xe.join(":"):""},Ce=Y=>{const{firstName:ne,lastName:Te,email:st}=de(Y),xe=[ne,Te].filter(Boolean).join(" ").trim();return{name:xe.length>0?xe:void 0,email:st.length>0?st:void 0,screenShareSupported:In}},Qe=(()=>{if(s!=null&&s.speakingState){if(s.speakingState==="thinking")return"thinking";if(s.speakingState==="busy")return"searching"}})(),ot=((Ut=(Po=e.client)==null?void 0:Po.product)==null?void 0:Ut.avatar_image_url)||((Io=(Lo=e.client)==null?void 0:Lo.product)==null?void 0:Io.logo_url)||void 0,ki=((Bo=(jo=e.client)==null?void 0:jo.product)==null?void 0:Bo.greeting_video_url)||void 0,Ii=cW({sdk:e,session:s,isBlacklisted:tn}),Wr=!i&&Ii,q=!!(s??((Yl=e.client)==null?void 0:Yl.session)??null),ae=(s==null?void 0:s.clientType)==="meet"?We(s):"",he=(I=(_=e.client)==null?void 0:_.product)==null?void 0:I.assistant_subtitle,Pe=typeof he=="string"&&he.trim().length>0?he:"Onboarding Assistant",it=()=>B(Y=>Y+1),jn=async()=>{var ne,Te;if(!s)return;const Y=((Te=(ne=s.room)==null?void 0:ne.localParticipant)==null?void 0:Te.isScreenShareEnabled)??!1;try{Y?await s.setScreenShareEnabled(!1):await s.shareScreen()}catch(st){console.error("[obi-sdk] failed to toggle screen share",st)}finally{it()}},Ti=w.useRef(null),Bn=w.useRef(null),Un=w.useRef(!1),Wt=w.useRef({session:null,sessionUuid:null,started:!1}),ai=w.useRef(null),zn=w.useRef(new WeakMap),Vl=(Y,ne)=>{if(!ne)return;let Te=zn.current.get(Y);Te||(Te=new Set,zn.current.set(Y,Te)),Te.add(ne)},ks=Y=>{if(!Y||Ti.current===Y)return;Bn.current&&(Bn.current(),Bn.current=null);const ne=()=>it(),Te=ie=>{u(ie),Je(),Y!=null&&Y.sessionUuid&&j3(Y.sessionUuid,ie),p(Ne=>Ne==="pip"||Ne==="course-outline"?Ne:Ne==="course-selection"?(be.current=!0,"course-outline"):Ne)},st=ie=>{Je(),T(ie.courses),p("course-selection"),be.current=!1,u(null),Y!=null&&Y.sessionUuid&&B3(Y.sessionUuid),R(null),P(!1)},xe=(ie,Ne)=>{},Ae=ie=>{ie.isAgent},pt=ie=>{$(ie),X(Date.now())},nn=ie=>{if(!ie){$(null);return}$(ie),X(Date.now())};Y.on("stateChanged",ne),Y.on("speakingStateChanged",ne),Y.on("paused",ne),Y.on("unpaused",ne),Y.on("chatMessagesChanged",ne),Y.on("chatMessageReceived",Ae),Y.on("courseProgress",Te),Y.on("courseSelection",st),Y.on("transcript",xe),Y.on("screenCaptured",pt),Y.on("screenCaptureNotification",nn),Y.on("captions",Z),Y.on("introductionComplete",qe),Ti.current=Y,Bn.current=()=>{Y.off("stateChanged",ne),Y.off("speakingStateChanged",ne),Y.off("paused",ne),Y.off("unpaused",ne),Y.off("chatMessagesChanged",ne),Y.off("chatMessageReceived",Ae),Y.off("courseProgress",Te),Y.off("courseSelection",st),Y.off("transcript",xe),Y.off("screenCaptured",pt),Y.off("screenCaptureNotification",nn),Y.off("captions",Z),Y.off("introductionComplete",qe)}},Se=Y=>{var Te;return Y?((Te=Y.roomId)==null?void 0:Te.startsWith("obs-"))&&!c?"course-selection":"pip":"hidden"};w.useEffect(()=>{const Y=()=>{ai.current&&(ai.current(),ai.current=null)},ne=xe=>{if(xe.clientType!=="meet")return;if(Wt.current.session&&Wt.current.session===xe||!!Wt.current.sessionUuid&&!!xe.sessionUuid&&Wt.current.sessionUuid===xe.sessionUuid){if(Wt.current.started||ai.current)return}else Wt.current={session:xe,sessionUuid:xe.sessionUuid??null,started:!1},Y();const pt=async()=>{Wt.current={session:xe,sessionUuid:xe.sessionUuid??null,started:!0};const Ne=We(xe);Ne&&Vl(xe,Ne);try{await xe.sendHumanJoined(Ce(xe))}catch(Yt){console.error("[obi-sdk] failed to send human_joined handshake",Yt)}},nn=(Ne,Yt)=>{Ne==="connecting"||Ne==="error"||(Y(),pt())},ie=xe.state;if(ie&&ie!=="connecting"&&ie!=="error"){pt();return}xe.on("stateChanged",nn),ai.current=()=>{xe.off("stateChanged",nn)}},Te=xe=>{var Ae,pt,nn,ie;if(xe)if((Ae=e.client)!=null&&Ae.session)p(Se(((nn=e.client)==null?void 0:nn.session)??null));else{const Yt=!!e.passivePlanUuid,qn=Yt&&!!((pt=e.client)!=null&&pt.selectedPlanUuid);if(Yt&&!qn)return;p("start-session")}else(ie=e.client)!=null&&ie.session||p("hidden")},st=()=>it();if(e.on("showMenu",Te),e.on("configUpdated",st),e.client){e.client.session&&(l(e.client.session),ks(e.client.session),p(Se(e.client.session))),e.client.on("sessionStarted",Ae=>{l(Ae),ks(Ae),Un.current=!1,S(!1),y(!1),v(!1),P(!1);const pt=me.current;me.current=!1,pt?(be.current=!0,p("course-outline")):(be.current=!1,p(Se(Ae))),sa().track("session-started",{planId:Ae.planId}),ne(Ae)}),e.client.on("sessionResumed",Ae=>{l(Ae),ks(Ae),Un.current=!1,S(!1),y(!1),v(!1),P(!1),be.current=!1,p(Se(Ae)),ne(Ae)});const xe=()=>{var nn;const Ae=(nn=e.client)==null?void 0:nn.session;Ae!=null&&Ae.sessionUuid&&B3(Ae.sessionUuid);const pt=Ti.current;Bn.current&&(Bn.current(),Bn.current=null),l(null),Ti.current=null,S(!1),y(!1),v(!1),P(!1),fe(!1),me.current=!1,Je(),be.current=!1,Y(),Wt.current={session:null,sessionUuid:null,started:!1},pt&&zn.current.delete(pt),Un.current||p("hidden")};e.client.on("sessionStopped",xe),e.client.on("sessionShutdown",xe),e.client.on("stateChanged",it)}return()=>{e.off("showMenu",Te),e.off("configUpdated",st),Bn.current&&Bn.current(),Y()}},[e]),w.useEffect(()=>{const Y=s;if(!Y||Y.clientType!=="meet")return;const ne=Y.state;if(!ne||ne==="connecting"||ne==="error"||!ae)return;const Te=zn.current.get(Y);Te!=null&&Te.has(ae)||(Vl(Y,ae),Y.sendHumanJoined(Ce(Y)).catch(st=>console.error("[obi-sdk] failed to send human_joined update",st)))},[In,ae,s,s==null?void 0:s.state]),w.useLayoutEffect(()=>{var Y,ne;(ne=(Y=e.client)==null?void 0:Y.product)!=null&&ne.primary_color&&n.style.setProperty("--obi-color-primary",e.client.product.primary_color)},[(pe=(M=e.client)==null?void 0:M.product)==null?void 0:pe.primary_color,n]),w.useEffect(()=>{if(i&&!tn&&!q){if(!r){p("hidden");return}p("start-session")}},[q,i,tn,r]),w.useEffect(()=>{var nn,ie;ge(!1);const Y=(nn=e.client)==null?void 0:nn.api,ne=(ie=e.client)==null?void 0:ie.product;if(!Y||!ne)return;const Te=(ne==null?void 0:ne.uuid)??(ne==null?void 0:ne.product_uuid),st=(ne==null?void 0:ne.slug)??(ne==null?void 0:ne.product_slug),xe=(ne==null?void 0:ne.id)??(ne==null?void 0:ne.product_id),Ae={};if(Te?Ae.product_uuid=Te:st?Ae.product_slug=st:xe!=null&&(Ae.product_id=String(xe)),Object.keys(Ae).length===0)return;let pt=!1;return Y.getFeatureFlags(Ae).then(Ne=>{if(pt)return;const qn=((Ne==null?void 0:Ne.data)??[]).find(ny=>(ny==null?void 0:ny.slug)===oW);if(!qn)return;const{user_enabled:oi,product_enabled:Hn,global_enabled:Tr}=qn;let ty=!!Tr;Hn!=null&&(ty=!!Hn),oi!=null&&(ty=!!oi),ge(ty)}).catch(Ne=>{console.error("[obi-sdk] failed to load AMA feature flag",Ne)}),()=>{pt=!0}},[(Le=e.client)==null?void 0:Le.api,(ve=e.client)==null?void 0:ve.product]);const Fn=(c==null?void 0:c.stepNames.map((Y,ne)=>({id:`step-${ne+1}`,title:Y})))??[],Gl=(c==null?void 0:c.currentStep)??null,Ao=!0,Yr=(Y,ne)=>{s==null||s.say(`Can we jump to the section about ${ne.title}?`)};if(tn||i&&!r&&!q)return null;if(h==="hidden")return Wr?f.jsx(aW,{label:Pe,onClick:()=>{e.updateShowMenu(!0)}}):null;if(h==="start-session"){const Y=(zt=e.client)==null?void 0:zt.product,ne=(_t=e.client)==null?void 0:_t.selectedPlan,Te=i&&!!r,st=i&&!!r||!!((xt=e.client)!=null&&xt.selectedPlanUuid),xe=(Y==null?void 0:Y.agent_name)||"Obi",Ae=(Y==null?void 0:Y.assistant_subtitle)||"AI Assistant",pt=Te&&(ne==null?void 0:ne.description)||(Y==null?void 0:Y.assistant_description)||"";return f.jsx(iW,{open:!0,onClose:()=>{S(!1),p("hidden")},onStart:()=>{me.current=st,fe(st),S(!0),e.startSession({withMicrophone:!0})},agentName:xe,agentSubtitle:Ae,description:pt,showCloseButton:!1,startLabel:"Start Session",isStarting:m,greetingVideoSrc:ki})}if(h==="course-selection"){const Y=(Xr=s==null?void 0:s.roomId)==null?void 0:Xr.startsWith("obs-"),ne=((Ie=e.client)==null?void 0:Ie.plans)||[],Te=Y&&k.length>0,st=Te?k.slice().sort((ie,Ne)=>ie.order!==void 0&&Ne.order!==void 0?ie.order-Ne.order:ie.order!==void 0?-1:Ne.order!==void 0?1:ie.name.localeCompare(Ne.name)).map(ie=>({id:ie.uuid,title:ie.name,description:ie.description||ie.overview||"",status:ie.completed?"completed":"available",duration:typeof ie.duration=="number"?`${ie.duration} min`:ie.duration})):ne.map(ie=>{var Ne,Yt;return{id:ie.uuid,title:ie.name,description:ie.description,status:(Yt=(Ne=e.client)==null?void 0:Ne.planIsCompleted)!=null&&Yt[ne.indexOf(ie)]?"completed":"available",duration:ie.estimated_duration?`${ie.estimated_duration} min`:void 0}});Te&&j&&st.push({id:I3,title:"Ask me anything",description:"Ask questions before choosing a course.",status:"available"});const xe=(s==null?void 0:s.languageCodes)||[],Ae=(s==null?void 0:s.selectedLanguage)||(s==null?void 0:s.defaultLanguageCode)||null,pt={audioDevices:bn,currentMicrophoneId:(s==null?void 0:s.preferredMicrophoneDeviceId)||null,isMicrophoneEnabled:!g&&((s==null?void 0:s.isMicShared)??!1),isScreenShareActive:Si,widgetState:x?"chat":null,canPublishData:!0,browserSupportsScreenSharing:In,onMicDeviceSelect:async ie=>{e.client&&(e.client.preferredMicrophoneDeviceId=ie),s&&ie&&await s.switchMicrophoneDevice(ie),it()},onMicToggle:async()=>{s!=null&&s.isMicShared?g?(await s.unmuteMicrophone(),y(!1)):(await s.muteMicrophone(),y(!0)):await(s==null?void 0:s.shareMicrophone())},onChatToggle:()=>{v(!x)},onLeave:()=>{s==null||s.stop()},onScreenShareToggle:jn,languages:xe,selectedLanguage:Ae,defaultLanguageCode:s==null?void 0:s.defaultLanguageCode,isMultilingual:(s==null?void 0:s.isMultilingual)??!1,onLanguageChange:ie=>{s==null||s.setLanguage(ie)},isLanguageSelectorEnabled:!0,...x?{screenShareButtonVariant:"compact"}:{}},nn=x?f.jsx(N3,{messages:(s==null?void 0:s.chatMessages)??[],localIdentity:((Uo=s==null?void 0:s.room)==null?void 0:Uo.localParticipant.identity)??(typeof(s==null?void 0:s.identity)=="string"?s.identity:null),onSend:async ie=>{var Ne,Yt,qn,oi;if(s){const Hn=Date.now();s.appendChatMessage({timestamp:Hn,message:ie,from:{identity:((Yt=(Ne=s.room)==null?void 0:Ne.localParticipant)==null?void 0:Yt.identity)??null,name:((oi=(qn=s.room)==null?void 0:qn.localParticipant)==null?void 0:oi.name)??null},isAgent:!1}),await s.say(ie)}},onClose:()=>v(!1)}):void 0;return f.jsx(L3,{open:!0,onClose:()=>s==null?void 0:s.stop(),courses:st,controlBarProps:pt,coursePanelProps:{selectedCourseIds:C?[C]:void 0,loadingCourseId:A,onCourseToggle:async ie=>{var Ne,Yt,qn,oi;if(!en.current)if(Te){if(ie===I3){cn(ie),R(ie);try{await((Ne=s==null?void 0:s.say)==null?void 0:Ne.call(s,"Please start an AMA session."))}catch(Tr){console.error("[obi-sdk] failed to start AMA course",Tr),Je(),R(null)}return}const Hn=k.find(Tr=>Tr.uuid===ie);if(Hn){cn(ie),R(ie);try{await((Yt=s==null?void 0:s.say)==null?void 0:Yt.call(s,`I'd like to take the ${Hn.name} course.`))}catch(Tr){console.error("[obi-sdk] failed to send course selection",Tr),Je(),R(null)}}}else{const Hn=ne.find(Tr=>Tr.uuid===ie);if(Hn){cn(ie),(qn=e.client)==null||qn.selectPlan(Hn),p("pip");try{await((oi=s==null?void 0:s.say)==null?void 0:oi.call(s,`I'd like to take the ${Hn.name} course.`))}catch(Tr){console.error("[obi-sdk] failed to send course selection",Tr),p("course-selection"),Je()}}}}},rightPanel:nn,avatarImageSrc:ot,avatarAudioPower:Mt,avatarStatus:Qe,captionsText:yn})}if(h==="course-outline"){const Y=(s==null?void 0:s.languageCodes)||[],ne=(s==null?void 0:s.selectedLanguage)||(s==null?void 0:s.defaultLanguageCode)||null,Te={audioDevices:bn,currentMicrophoneId:(s==null?void 0:s.preferredMicrophoneDeviceId)||null,isMicrophoneEnabled:!g&&((s==null?void 0:s.isMicShared)??!1),isScreenShareActive:Si,widgetState:x?"chat":null,canPublishData:!0,browserSupportsScreenSharing:In,onMicDeviceSelect:async ie=>{e.client&&(e.client.preferredMicrophoneDeviceId=ie),s&&ie&&await s.switchMicrophoneDevice(ie),it()},onMicToggle:async()=>{s!=null&&s.isMicShared?g?(await s.unmuteMicrophone(),y(!1)):(await s.muteMicrophone(),y(!0)):await(s==null?void 0:s.shareMicrophone())},onChatToggle:()=>{v(!x)},onLeave:()=>{s==null||s.stop()},onScreenShareToggle:jn,languages:Y,selectedLanguage:ne,defaultLanguageCode:s==null?void 0:s.defaultLanguageCode,isMultilingual:(s==null?void 0:s.isMultilingual)??!1,onLanguageChange:ie=>{s==null||s.setLanguage(ie)},isLanguageSelectorEnabled:!0,...x?{screenShareButtonVariant:"compact"}:{}},st=x?f.jsx(N3,{messages:(s==null?void 0:s.chatMessages)??[],localIdentity:((Kl=s==null?void 0:s.room)==null?void 0:Kl.localParticipant.identity)??(typeof(s==null?void 0:s.identity)=="string"?s.identity:null),onSend:async ie=>{var Ne,Yt,qn,oi;if(s){const Hn=Date.now();s.appendChatMessage({timestamp:Hn,message:ie,from:{identity:((Yt=(Ne=s.room)==null?void 0:Ne.localParticipant)==null?void 0:Yt.identity)??null,name:((oi=(qn=s.room)==null?void 0:qn.localParticipant)==null?void 0:oi.name)??null},isAgent:!1}),await s.say(ie)}},onClose:()=>v(!1)}):void 0,xe=!!c,Ae=!U,pt=async()=>{if(!(!(s!=null&&s.endCourse)||K)){P(!0);try{await s.endCourse("back_to_courses")}catch(ie){console.error("[obi-sdk] failed to end course",ie),P(!1)}}},nn=f.jsx(RV,{steps:Fn,currentStep:Gl,hideTrailingConclusionStep:Ao,onStepClick:Yr,showBackToCourses:Ae,...Ae?{onBackToCoursesConfirm:pt,backToCoursesDisabled:K}:{}});return f.jsx(L3,{open:!0,onClose:()=>s==null?void 0:s.stop(),courses:[],controlBarProps:Te,middlePanel:nn,rightPanel:st,isCourseOutlineOpen:xe,onReturnToPiP:xe?()=>p("pip"):void 0,avatarImageSrc:ot,avatarAudioPower:Mt,avatarStatus:Qe,captionsText:yn})}if(h==="pip"){const Y=(s==null?void 0:s.languageCodes)||[],ne=(s==null?void 0:s.selectedLanguage)||(s==null?void 0:s.defaultLanguageCode)||null,Te=280,st=250,xe=16,Ae={x:window.innerWidth-Te-xe,y:window.innerHeight-st-xe},pt={isMicrophoneEnabled:!g&&((s==null?void 0:s.isMicShared)??!1),isChatOpen:x,isScreenShareActive:Si,onMicToggle:async()=>{s!=null&&s.isMicShared?g?(await s.unmuteMicrophone(),y(!1)):(await s.muteMicrophone(),y(!0)):await(s==null?void 0:s.shareMicrophone())},onChatToggle:()=>v(ie=>!ie),onScreenShareToggle:jn,onLeave:()=>{s==null||s.stop()},languages:Y,selectedLanguage:ne,defaultLanguageCode:s==null?void 0:s.defaultLanguageCode,isMultilingual:(s==null?void 0:s.isMultilingual)??!1,onLanguageChange:ie=>{s==null||s.setLanguage(ie)},isLanguageSelectorEnabled:!0},nn=x?f.jsx($V,{messages:(s==null?void 0:s.chatMessages)??[],localIdentity:((K3=s==null?void 0:s.room)==null?void 0:K3.localParticipant.identity)??(typeof(s==null?void 0:s.identity)=="string"?s.identity:null),onSend:async ie=>{var Ne,Yt,qn,oi;if(s){const Hn=Date.now();s.appendChatMessage({timestamp:Hn,message:ie,from:{identity:((Yt=(Ne=s.room)==null?void 0:Ne.localParticipant)==null?void 0:Yt.identity)??null,name:((oi=(qn=s.room)==null?void 0:qn.localParticipant)==null?void 0:oi.name)??null},isAgent:!1}),await s.say(ie)}},testId:"pip-chat-panel"}):void 0;return f.jsx(sH,{initialPosition:Ae,onExit:()=>{be.current=!1,p("course-outline")},controlBarProps:pt,isCourseOutlineSelected:W&&!!c,onCourseOutlineToggle:c?()=>{L(ie=>!ie)}:void 0,isCaptionsEnabled:Q,onCaptionsToggle:()=>ce(ie=>!ie),courseOutline:c?{steps:Fn,currentStep:Gl,onStepClick:Yr,hideTrailingConclusionStep:Ao}:void 0,messagesPanel:nn,avatarFallbackProps:{audioPower:Mt,imageSrc:ot,status:Qe,captionsText:yn},screenshotUrl:te,cameraShotTrigger:V})}return null}function cW(t){var l,c;const{sdk:e,session:n,isBlacklisted:i}=t;if(i)return!1;const r=e.client;if(!r||r.state!=="ready"||(n??r.session??null))return!1;let o=e.isActive;return((l=r.product)==null?void 0:l.name)==="Canibuild"&&(o=!0),!(!o||(e.widgetDisplay??((c=r.product)==null?void 0:c.widget_display))==="invisible")}function j3(t,e){if(!t)return;const n=`obi-widget-course-progress-${t}`;if(e===null){localStorage.removeItem(n);return}try{const i={...e,timestamp:Date.now()};localStorage.setItem(n,JSON.stringify(i))}catch(i){console.error("[obi-sdk] failed to save course progress",i)}}function uW(t){if(!t)return null;const e=`obi-widget-course-progress-${t}`;try{const n=localStorage.getItem(e);if(!n)return null;const i=JSON.parse(n);if(typeof i.currentStep!="number"||typeof i.totalSteps!="number"||!Array.isArray(i.stepNames))return console.warn("[obi-sdk] invalid course progress data, clearing",i),localStorage.removeItem(e),null;const r=24*60*60*1e3;return i.timestamp&&Date.now()-i.timestamp>r?(localStorage.removeItem(e),null):{currentStep:i.currentStep,totalSteps:i.totalSteps,stepNames:i.stepNames}}catch(n){return console.error("[obi-sdk] failed to load course progress",n),localStorage.removeItem(e),null}}function B3(t){if(!t)return;const e=`obi-widget-course-progress-${t}`;try{localStorage.removeItem(e)}catch(n){console.error("[obi-sdk] failed to clear course progress",n)}}function dW(t){const[e,n]=w.useState(()=>ys(t));return w.useEffect(()=>{n(ys(t))},[t]),w.useEffect(()=>{const i=()=>{n(ys(t))};return window.addEventListener("popstate",i),window.addEventListener("hashchange",i),()=>{window.removeEventListener("popstate",i),window.removeEventListener("hashchange",i)}},[t]),e}function hW(t){const[e,n]=w.useState(0),i=w.useRef(null),r=w.useRef(0),a=w.useRef(0);return w.useEffect(()=>{if(!t){n(0),r.current=0,a.current=0;return}const o=()=>{const s=t.audioSpectrum();let l=0;if(s&&s.length>0){let b=0;for(let m=0;m<s.length;m++)b+=s[m];l=Math.min(1,Math.max(0,b/s.length))}const c=r.current,d=l>=c?.7:.15,h=c*d+l*(1-d);r.current=h;const p=h<.05?0:Math.min(1,h);Math.abs(p-a.current)>.01&&(a.current=p,n(p)),i.current=requestAnimationFrame(o)};return i.current=requestAnimationFrame(o),()=>{i.current&&cancelAnimationFrame(i.current)}},[t]),e}function fW(){const[t,e]=w.useState({audioDevices:[]});return w.useEffect(()=>{var i;if(typeof navigator>"u"||!((i=navigator.mediaDevices)!=null&&i.enumerateDevices))return;const n=()=>{navigator.mediaDevices.enumerateDevices().then(r=>{e({audioDevices:r.filter(a=>a.kind==="audioinput")})})};return n(),navigator.mediaDevices.addEventListener("devicechange",n),()=>navigator.mediaDevices.removeEventListener("devicechange",n)},[]),t}function U3(){const t=window.location.hostname;return t.endsWith(".clinic1.com")||t==="getcor.ai"||t==="getcor.io"||t==="localhost"||t==="127.0.0.1"||t==="::1"}const z3=U3();function pW(t){if(document.querySelector("#obi-host")||document.querySelector("obi-widget"))return;mW();const e=document.createElement("div");e.id="obi-host",e.style.position="fixed",e.style.zIndex="9999",document.body.appendChild(e);const n=e.attachShadow({mode:"open"}),i=document.createElement("div");i.id="obi-container",n.appendChild(i);const r=new CSSStyleSheet;r.replaceSync(MB);const a=[r];if(z3){const s=new CSSStyleSheet;s.replaceSync(AB),a.push(s);const l=new CSSStyleSheet;l.replaceSync(OB),a.push(l)}else{const s=new CSSStyleSheet;s.replaceSync(NB),a.push(s)}n.adoptedStyleSheets=a;const o=RB.createRoot(i);z3?o.render(f.jsx(lW,{sdk:t,shadowHost:e})):o.render(f.jsx(LB,{sdk:t,shadowHost:e})),console.log("[obi-sdk] widget mounted")}function mW(){F3("https://fonts.cdnfonts.com/css/satoshi"),F3("https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap")}function F3(t){const e=document.createElement("link");e.href=t,e.rel="stylesheet",document.head.appendChild(e)}const q3="49206C6F7665204F6269_session",H3="obi-url-params",ey="obi-client-heartbeat",gW=5e3,V3=4e4,G3=15e3;function vW(){return U3()?"meet":"sdk"}class bW extends Ep{constructor(e){super(),this.client=null,this.isActive=!1,this.primaryColour="#9500FF",this.passivePlanUuid=null,this.commandLog=[],this.commandQueue=[],this._resumed=!1,this.heartbeatInterval=null,this.dispatchCommand=(n,i)=>{var r,a,o,s,l;switch(this.commandLog.push({commandType:n,args:i}),n){case"update":this.updateConfig(i);break;case"startSession":{if(i!=null&&i.planUuid){const c=(((r=this.client)==null?void 0:r.plans)||[]).find(u=>u.uuid===i.planUuid)||null;if(!c){console.warn("[obi] startSession command requires a valid planUuid",i);return}(o=(a=this.client)==null?void 0:a.selectPlan)==null||o.call(a,c)}this.updateActive(!0);break}case"stopSession":(l=(s=this.client)==null?void 0:s.stopSession)==null||l.call(s);break;case"say":this.say(i);break;default:console.warn("[obi] unknown command",{commandType:n,args:i})}},e&&this.createClient(e),this.parsePassiveParams()}async createClient(e){if(this.client){this.client.appToken!==e&&console.warn("[obi] client already exists with different app token");return}let n=null;const i=vW(),r=this.load();if(r)try{const a=this.parsePersistedSessionMetadata(r),o=a&&this.isPersistedSessionStale(a);o!=null&&o.stale&&a?(this.trackStaleSessionDiscard(a.sessionUuid,o.ageMs,o.reason),this.clearCachedClient()):(n=wh.deserialise(r,e,i,{apiBaseUrl:"https://staging.coragents.ai",captureScreen:this.captureScreen.bind(this)}),n?this._resumed=!0:this.clearCachedClient())}catch(a){console.error("[obi] error loading cached client",a),this.clearCachedClient()}n||(n=new wh(e,i,{apiBaseUrl:"https://staging.coragents.ai",captureScreen:this.captureScreen.bind(this)})),this.client=n,this.client.session&&this.startHeartbeat(this.client.session.sessionUuid),this.client.on("stateChanged",a=>{var o,s,l,c,u,d,h,p,b,m;a==="ready"&&this.updateConfig({isActive:((o=window==null?void 0:window.obiWidgetConfig)==null?void 0:o.isActive)??((s=this.client)==null?void 0:s.showWidget),primaryColour:((c=(l=this.client)==null?void 0:l.product)==null?void 0:c.primary_color)||"#9500FF",widgetDisplay:((u=window==null?void 0:window.obiWidgetConfig)==null?void 0:u.widgetDisplay)||((h=(d=this.client)==null?void 0:d.product)==null?void 0:h.widget_display)||"regular",completedWidgetDisplay:((p=window==null?void 0:window.obiWidgetConfig)==null?void 0:p.completedWidgetDisplay)||((m=(b=this.client)==null?void 0:b.product)==null?void 0:m.completed_widget_display)||"regular"})}),this.client.on("sessionStarted",()=>{var a,o;this.save(),this.startHeartbeat(((o=(a=this.client)==null?void 0:a.session)==null?void 0:o.sessionUuid)||null),this.passivePlanUuid=null}),this.client.on("sessionStopped",()=>{this.clearCachedClient(),this.passivePlanUuid=null}),this.client.on("sessionShutdown",()=>{this.clearCachedClient()}),this.client.on("trackEvent",(a,o)=>{}),this.client.session&&(this.client.session.isPaused,this.client.resumeSession(a=>{a.on("stateChanged",o=>{o!=="disconnecting"&&o!=="disconnected"&&o!=="error"&&o!=="connecting"&&this.save()}),a.on("paused",()=>{this.save()}),a.on("unpaused",()=>{this.save()})}))}_maybeActOnServerEngagement(){var s;const e=this.client;if(!e||e.state!=="ready")return;const n=e.product,i=(s=e.engagement)==null?void 0:s.style;if(!i||n&&ys(n.widget_url_blacklist||[])||!e.showWidget)return;const r=e.plans||[],a=e.planIsCompleted||[],o=r.length>0&&a.filter(Boolean).length===r.length;if(!(r.length===0||o)){if(i==="modal"){const l=a.findIndex(u=>!u),c=l>=0?r[l]:null;c&&e.selectPlan(c)}else i==="popover"&&setTimeout(()=>{this.showMessage("Don't forget to complete your onboarding",{autoCloseMs:1e4})},1e3);try{sa().track("engagement-prompt-shown",{style:i})}catch{}}}async initialise(e={}){var n;this.commandQueue=e.queuedCommands||[],this._resumed?(this._resumed=!1,this.dispatchCommandQueue()):this.client?this.client.initialise({planUuid:this.passivePlanUuid||void 0,identity:((n=window==null?void 0:window.obiWidgetConfig)==null?void 0:n.user)||void 0}).then(()=>{this.emit("initialised");try{this._maybeActOnServerEngagement()}catch{}this.dispatchCommandQueue()}).catch(i=>{console.error("[obi] error initialising client",i),this.emit("error",i)}):this.dispatchCommandQueue()}async updateConfig(e){e.apiKey!==void 0&&await this.updateAppToken(e.apiKey),this.updateActive(e.isActive),this.updatePrimaryColour(e.primaryColour),this.updateWidgetDisplay(e.widgetDisplay),this.updateCompletedWidgetDisplay(e.completedWidgetDisplay),this.updateWidgetPosition(e.widgetPosition),e.user!==void 0&&await this.updateIdentity(e.user),this.updateShowMenu(e.showMenu),this.emit("configUpdated")}async updateAppToken(e){var n;e===void 0||e==((n=this.client)==null?void 0:n.appToken)||(this.passivePlanUuid,await this.createClient(e),this.client&&await this.client.initialise({planUuid:this.passivePlanUuid||void 0}).then(()=>{this.emit("initialised");try{this._maybeActOnServerEngagement()}catch{}}).catch(i=>{console.error("[obi] error initialising client",i),this.emit("error",i)}))}updateActive(e){e===void 0||e==this.isActive||(this.isActive=e)}updatePrimaryColour(e){e===void 0||e==this.primaryColour||(this.primaryColour=e)}updateWidgetDisplay(e){e===void 0||e==this.widgetDisplay||(this.widgetDisplay=e)}updateCompletedWidgetDisplay(e){e===void 0||e==this.completedWidgetDisplay||(this.completedWidgetDisplay=e)}updateWidgetPosition(e){e===void 0||e==this.widgetPosition||(this.widgetPosition=e)}async updateIdentity(e){var i,r;if(e===void 0||e==((i=this.client)==null?void 0:i.identity))return;(r=this.client)==null||r.identity;let n=e?{...e,extra:{...e,...(e==null?void 0:e.extra)||{}}}:void 0;await this.client.initialise({identity:n,planUuid:this.passivePlanUuid||void 0}).then(()=>{this.emit("initialised");try{this._maybeActOnServerEngagement()}catch{}}).catch(a=>{console.error("[obi] error initialising client",a),this.emit("error",a)}),e!=null&&e.email&&sa().identify((e==null?void 0:e.email)||"",n)}updateShowMenu(e){e!==void 0&&this.emit("showMenu",e)}async say(e){var n,i,r;await((r=(i=(n=this.client)==null?void 0:n.session)==null?void 0:i.say)==null?void 0:r.call(i,e))}async startSession(e){await this.client.startSession(this.client.selectedPlanUuid||null,n=>{n.on("stateChanged",i=>{i!=="disconnecting"&&i!=="disconnected"&&i!=="error"&&i!=="connecting"&&this.save()}),n.on("paused",()=>{this.save()}),n.on("unpaused",()=>{this.save()})},e)}dispatchCommandQueue(){const e=this.commandQueue;this.commandQueue=[],e.forEach(n=>{try{this.dispatchCommand(n[0],n[1]||[])}catch(i){console.error("[obi] error dispatching command",i)}})}parsePassiveParams(){if(this.passivePlanUuid){this.passivePlanUuid;return}let e={};e=JSON.parse(localStorage.getItem(H3)||"{}"),Object.keys(e).length===0&&new URLSearchParams(window.location.search).forEach((a,o)=>{e[o]=a});const n=e[q3];if(!n)return null;const i=new URL(window.location.href);i.searchParams.delete(q3),window.history.replaceState({},"",i.toString()),i.toString(),localStorage.removeItem(H3),this.passivePlanUuid=n}mountWidget(){pW(this)}showMessage(e,n){try{this.emit("showMessage",{text:e,autoCloseMs:n==null?void 0:n.autoCloseMs})}catch{}}async captureScreen(){try{await xO(async()=>(this.graphemes||(this.graphemes=await this.client.api.getGraphemes()),this.graphemes.data.text_segmentation)),await mR(async()=>(this.graphemes||(this.graphemes=await this.client.api.getGraphemes()),this.graphemes.data.css_line_breaks))}catch(e){throw console.error("[obi] error initialising unicode trie",e),e}try{return(await ZN(document.documentElement,{useCORS:!0,allowTaint:!0,foreignObjectRendering:!0})).toDataURL("image/png")}catch(e){throw console.error("[obi] error capturing screen",e),e}}save(){var n;const e=((n=this.client)==null?void 0:n.serialise())||"";localStorage.setItem("obi-client",e)}load(){return localStorage.getItem("obi-client")}parsePersistedSessionMetadata(e){const n=JSON.parse(e),i=this.parseTimestampMs(n.serialisedAt);if(!n.session)return null;let r=null;if(typeof n.session=="string")try{r=JSON.parse(n.session)}catch{return null}else typeof n.session=="object"&&(r=n.session);return r?{sessionUuid:typeof r.sessionUuid=="string"?r.sessionUuid:null,startedAtMs:this.parseTimestampMs(r.startedAt),serialisedAtMs:i}:null}isPersistedSessionStale(e){const n=Date.now(),i=this.readHeartbeat();if(i&&i.sessionUuid&&e.sessionUuid&&i.sessionUuid===e.sessionUuid){const s=Math.max(0,n-i.updatedAtMs);return{stale:s>V3,reason:s>V3?"heartbeat-stale":"heartbeat-fresh",ageMs:s}}const r=[e.serialisedAtMs,e.startedAtMs].filter(s=>typeof s=="number"&&Number.isFinite(s));if(r.length===0)return{stale:!0,reason:"fallback-missing-timestamps",ageMs:null};const a=Math.max(...r),o=Math.max(0,n-a);return{stale:o>G3,reason:o>G3?"fallback-too-old":"fallback-recent",ageMs:o}}parseTimestampMs(e){if(typeof e=="number")return e;if(typeof e=="string"){const n=Number(e);if(!Number.isNaN(n))return n;const i=Date.parse(e);return Number.isFinite(i)?i:null}return null}readHeartbeat(){const e=localStorage.getItem(ey);if(!e)return null;try{return JSON.parse(e)}catch{return null}}trackStaleSessionDiscard(e,n,i){try{sa().track("stale-session-discarded",{sessionUuid:e||void 0,ageMs:n??void 0,reason:i})}catch{}}startHeartbeat(e){if(!e){this.clearHeartbeat();return}this.stopHeartbeat(),this.writeHeartbeat(e),this.heartbeatInterval=setInterval(()=>{this.writeHeartbeat(e)},gW)}stopHeartbeat(){this.heartbeatInterval&&(clearInterval(this.heartbeatInterval),this.heartbeatInterval=null)}writeHeartbeat(e){const n={sessionUuid:e,updatedAtMs:Date.now()};localStorage.setItem(ey,JSON.stringify(n))}clearHeartbeat(){this.stopHeartbeat(),localStorage.removeItem(ey)}clearCachedClient(){this.clearHeartbeat(),localStorage.removeItem("obi-client")}}async function W3(t,e){let n;try{n=window}catch{console.warn("[obi] no window object found"),n={}}return yW({appToken:t,window:n,init:e})}async function yW({appToken:t,window:e,init:n}){var a,o;if(e.obi){console.warn("[obi] obi object already found on window, skipping");return}n&&n(),t||(t=(a=e==null?void 0:e.obiWidgetConfig)==null?void 0:a.apiKey);let i;try{i=((o=e.ObiSDK)==null?void 0:o.q)||[]}catch{i=[]}const r=new bW(t);return e.ObiSDK=r.dispatchCommand,await r.initialise({queuedCommands:i}),e.obi=r,r.mountWidget(),r}function Y3(){}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{W3(void 0,Y3)}):W3(void 0,Y3)})();
133
+ `);for(let s=i;s<o.length;s++){const l=o[s];if(l.length>1024)continue;const c=M3.test(l)?l.replace(M3,"$1"):l;if(!c.match(/\S*Error: /)){for(const u of e){const d=u(c);if(d){a.push(d);break}}if(a.length>=O3+r)break}}return qG(a.slice(r))}}function qG(t){if(!t.length)return[];const e=Array.from(t);return/sentryWrapped/.test(kp(e).function||"")&&e.pop(),e.reverse(),D3.test(kp(e).function||"")&&(e.pop(),D3.test(kp(e).function||"")&&e.pop()),e.slice(0,O3).map(n=>({...n,filename:n.filename||kp(e).filename,function:n.function||Hl}))}function kp(t){return t[t.length-1]||{}}typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;const HG=30,VG=50;function Qb(t,e,n,i){const r={filename:t,function:e==="<anonymous>"?Hl:e,in_app:!0};return n!==void 0&&(r.lineno=n),i!==void 0&&(r.colno=i),r}const GG=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,WG=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,YG=/\((\S*)(?::(\d+))(?::(\d+))\)/,KG=t=>{const e=GG.exec(t);if(e){const[,i,r,a]=e;return Qb(i,Hl,+r,+a)}const n=WG.exec(t);if(n){if(n[2]&&n[2].indexOf("eval")===0){const a=YG.exec(n[2]);a&&(n[2]=a[1],n[3]=a[2],n[4]=a[3])}const[i,r]=P3(n[1]||Hl,n[2]);return Qb(r,i,n[3]?+n[3]:void 0,n[4]?+n[4]:void 0)}},XG=[HG,KG],$G=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,JG=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i;FG(...[XG,[VG,t=>{const e=$G.exec(t);if(e){if(e[3]&&e[3].indexOf(" > eval")>-1){const r=JG.exec(e[3]);r&&(e[1]=e[1]||"eval",e[3]=r[1],e[4]=r[2],e[5]="")}let n=e[3],i=e[1]||Hl;return[i,n]=P3(i,n),Qb(n,i,e[4]?+e[4]:void 0,e[5]?+e[5]:void 0)}}]]);const P3=(t,e)=>{const n=t.indexOf("safari-extension")!==-1,i=t.indexOf("safari-web-extension")!==-1;return n||i?[t.indexOf("@")!==-1?t.split("@")[0]:Hl,n?`safari-extension:${e}`:`safari-web-extension:${e}`]:[t,e]};typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;const ir={shell:"_shell_8bsnr_1",layout:"_layout_8bsnr_11",layoutThree:"_layoutThree_8bsnr_23",leftPanel:"_leftPanel_8bsnr_27",middlePanel:"_middlePanel_8bsnr_36",rightPanel:"_rightPanel_8bsnr_37",videoFrame:"_videoFrame_8bsnr_41",captions:"_captions_8bsnr_52",controls:"_controls_8bsnr_58",coursePanel:"_coursePanel_8bsnr_71",returnToPiPOverlay:"_returnToPiPOverlay_8bsnr_82",returnToPiPButton:"_returnToPiPButton_8bsnr_94"};function Zb(...t){return t.filter(Boolean).join(" ")}function QG(t){const{captionsText:e,avatarAudioPower:n=0,avatarImageSrc:i,avatarAriaLabel:r,avatarStatus:a,controlBarProps:o,courses:s,coursePanelProps:l,middlePanel:c,rightPanel:u,isCourseOutlineOpen:d,onReturnToPiP:h,className:p}=t;return f.jsx("div",{className:Zb(ir.shell,p),"data-testid":"course-dialog-content",children:f.jsxs("div",{className:Zb(ir.layout,u?ir.layoutThree:null),children:[f.jsxs("div",{className:ir.leftPanel,children:[f.jsxs("div",{className:ir.videoFrame,children:[d&&h&&f.jsx("div",{className:ir.returnToPiPOverlay,children:f.jsx("button",{type:"button",className:ir.returnToPiPButton,onClick:h,"aria-label":"Return to PiP","data-testid":"course-return-to-pip",children:f.jsx(GB,{size:14})})}),f.jsx(hH,{className:ir.captions,text:e,children:f.jsx(x3,{audioPower:n,size:"lg",background:"flat",imageSrc:i,ariaLabel:r??"Agent avatar placeholder",status:a})})]}),f.jsx("div",{className:ir.controls,children:f.jsx(BF,{...o})})]}),u?f.jsx("div",{className:ir.rightPanel,"data-testid":"course-dialog-right-panel",children:u}):null,f.jsx("div",{className:ir.middlePanel,"data-testid":"course-dialog-middle-panel",children:c??f.jsx(YH,{...l,courses:s,className:Zb(ir.coursePanel,l==null?void 0:l.className)})})]})})}function L3(t){const{open:e,onClose:n,dialogProps:i,...r}=t;return f.jsx(HE,{open:e,onClose:n,variant:"ghost",...i,children:f.jsx(QG,{...r})})}const ZG=80,eW=500,tW=1e3;function nW(t,e){const{delayMs:n=0}=e??{},r=t.filter(m=>{var g;const S=(g=m.participantInfo)==null?void 0:g.identity;return(S==null?void 0:S.startsWith("agent-"))??!1}).map(m=>m.text??"").join(" ").trim(),[a,o]=w.useState(""),[s,l]=w.useState(!1),c=w.useRef(""),u=w.useRef(null),d=w.useRef(null),h=w.useRef(null),p=m=>{h.current&&(clearTimeout(h.current),h.current=null),n>0?h.current=setTimeout(()=>{o(m)},n):o(m)},b=(m,S)=>m.startsWith(S)?m.slice(S.length).trim():m.trim();return w.useEffect(()=>{if(d.current&&(clearTimeout(d.current),d.current=null),s)return;const m=b(r,c.current);p(m),m.length>ZG?(l(!0),u.current=setTimeout(()=>{l(!1),c.current=r},eW+n)):m.length>0&&(d.current=setTimeout(()=>{c.current=r,p("")},tW+n))},[r,s,n]),w.useEffect(()=>()=>{u.current&&clearTimeout(u.current),d.current&&clearTimeout(d.current),h.current&&clearTimeout(h.current)},[]),{caption:a,hasCaption:a.length>0}}const kr={layout:"_layout_k1q6c_1",left:"_left_k1q6c_10",copy:"_copy_k1q6c_17",description:"_description_k1q6c_25",descriptionScroller:"_descriptionScroller_k1q6c_31",cta:"_cta_k1q6c_36",disclaimer:"_disclaimer_k1q6c_43",right:"_right_k1q6c_47",mediaPanel:"_mediaPanel_k1q6c_56",agentStill:"_agentStill_k1q6c_63",dialogWithSmallClose:"_dialogWithSmallClose_k1q6c_88"};function iW(t){const{open:e,onClose:n,onStart:i,agentName:r,agentSubtitle:a,description:o,startLabel:s="Start Now",disclaimer:l="Sessions are securely recorded for quality improvement purposes.",showCloseButton:c=!1,isStarting:u=!1,greetingVideoSrc:d}=t;return f.jsx(HE,{open:e,onClose:n,size:"large",showCloseButton:c,className:kr.dialogWithSmallClose,children:f.jsxs("div",{className:kr.layout,children:[f.jsxs("div",{className:kr.left,children:[f.jsxs("div",{className:kr.copy,children:[f.jsx(xi,{variant:"heading",children:r}),f.jsx(xi,{variant:"subheading",children:a}),f.jsx(xi,{variant:"muted",as:"div",className:kr.description,children:f.jsx(zl,{className:kr.descriptionScroller,children:f.jsx(nF,{content:o})})})]}),f.jsxs("div",{className:kr.cta,children:[f.jsx(_s,{type:"button",size:"lg",fullWidth:!0,onClick:i,isLoading:u,children:s}),f.jsx(xi,{variant:"subscript",as:"p",className:kr.disclaimer,children:l})]})]}),f.jsx(PG,{showAboveWidth:"md",children:f.jsx("div",{className:kr.right,children:f.jsx(qu,{className:kr.mediaPanel,children:f.jsx(zG,{agentName:r,greetingVideoSrc:d,className:kr.agentStill})})})})]})})}const rW={launcherPill:"_launcherPill_1fhyr_1"};function aW(t){const{label:e,onClick:n}=t;return f.jsx("button",{type:"button",className:rW.launcherPill,onClick:n,"data-testid":"ai-coach-pill",children:e})}const I3="__ama_course__",oW="ama_course",sW=3e4;function lW(t){var No,Oo,Wl,_n,xn,Mo,Do,Kr,Po,Ut,Lo,Io,jo,Bo,Yl,_,I,M,pe,Le,ve,zt,_t,xt,Xr,Ie,Uo,Kl,K3;const{sdk:e,shadowHost:n}=t,i=!!e.passivePlanUuid,r=i?((No=e.client)==null?void 0:No.selectedPlanUuid)??null:null,a=((Oo=e.client)==null?void 0:Oo.session)??null,o=!!a&&(i&&!!r||!!((Wl=e.client)!=null&&Wl.selectedPlanUuid)),[s,l]=w.useState(()=>a),[c,u]=w.useState(()=>a!=null&&a.sessionUuid?uW(a.sessionUuid):null),d=(()=>{var Y;return a?((Y=a.roomId)==null?void 0:Y.startsWith("obs-"))&&!c?"course-selection":"pip":r?"start-session":"hidden"})(),[h,p]=w.useState(()=>d),b=w.useRef(d),[m,S]=w.useState(!1),[g,y]=w.useState(!1),[x,v]=w.useState(!1),[k,T]=w.useState([]),[C,R]=w.useState(null),[A,N]=w.useState(null),[O,B]=w.useState(0),[W,L]=w.useState(!1),[K,P]=w.useState(!1),[V,X]=w.useState(0),[te,$]=w.useState(null),[z,Z]=w.useState([]),[Q,ce]=w.useState(!1),[j,ge]=w.useState(!1),[U,fe]=w.useState(()=>o),me=w.useRef(o),Rt=w.useRef(null),en=w.useRef(null),be=w.useRef(!1),qe=()=>{p(Y=>{const ne=Y==="course-selection",Te=Y==="course-outline"&&be.current;return ne||Te?(be.current=!1,L(!1),"pip"):Y})};w.useEffect(()=>{b.current=h},[h]),w.useEffect(()=>()=>{Rt.current&&clearTimeout(Rt.current)},[]);const bt=()=>{Rt.current&&(clearTimeout(Rt.current),Rt.current=null)},Je=()=>{bt(),en.current=null,N(Y=>Y===null?Y:null)},cn=Y=>{bt(),en.current=Y,N(Y),Rt.current=setTimeout(()=>{const ne=en.current===Y,Te=b.current==="course-selection";ne&&Te&&(en.current=null,N(null)),Rt.current=null},sW)},tn=dW((xn=(_n=e.client)==null?void 0:_n.product)==null?void 0:xn.widget_url_blacklist),Mt=hW(s),{audioDevices:bn}=fW();w.useEffect(()=>{s!=null&&s.sessionUuid&&j3(s.sessionUuid,c)},[c,s==null?void 0:s.sessionUuid]);const{caption:yn}=nW(z,{delayMs:0}),In=typeof navigator<"u"&&!!((Mo=navigator.mediaDevices)!=null&&Mo.getDisplayMedia),Si=((Kr=(Do=s==null?void 0:s.room)==null?void 0:Do.localParticipant)==null?void 0:Kr.isScreenShareEnabled)??!1,de=Y=>{var Ae;const ne=((Ae=e.client)==null?void 0:Ae.identity)??Y.identity,Te=typeof(ne==null?void 0:ne.first_name)=="string"?ne.first_name.trim():"",st=typeof(ne==null?void 0:ne.last_name)=="string"?ne.last_name.trim():"",xe=typeof(ne==null?void 0:ne.email)=="string"&&ne.email.trim().length>0?ne.email.trim():"";return{firstName:Te,lastName:st,email:xe}},We=Y=>{const{firstName:ne,lastName:Te,email:st}=de(Y),xe=[ne,Te,st].map(pt=>pt.trim());return xe.some(pt=>pt.length>0)?xe.join(":"):""},Ce=Y=>{const{firstName:ne,lastName:Te,email:st}=de(Y),xe=[ne,Te].filter(Boolean).join(" ").trim();return{name:xe.length>0?xe:void 0,email:st.length>0?st:void 0,screenShareSupported:In}},Qe=(()=>{if(s!=null&&s.speakingState){if(s.speakingState==="thinking")return"thinking";if(s.speakingState==="busy")return"searching"}})(),ot=((Ut=(Po=e.client)==null?void 0:Po.product)==null?void 0:Ut.avatar_image_url)||((Io=(Lo=e.client)==null?void 0:Lo.product)==null?void 0:Io.logo_url)||void 0,ki=((Bo=(jo=e.client)==null?void 0:jo.product)==null?void 0:Bo.greeting_video_url)||void 0,Ii=cW({sdk:e,session:s,isBlacklisted:tn}),Wr=!i&&Ii,q=!!(s??((Yl=e.client)==null?void 0:Yl.session)??null),ae=(s==null?void 0:s.clientType)==="meet"?We(s):"",he=(I=(_=e.client)==null?void 0:_.product)==null?void 0:I.assistant_subtitle,Pe=typeof he=="string"&&he.trim().length>0?he:"Onboarding Assistant",it=()=>B(Y=>Y+1),jn=async()=>{var ne,Te;if(!s)return;const Y=((Te=(ne=s.room)==null?void 0:ne.localParticipant)==null?void 0:Te.isScreenShareEnabled)??!1;try{Y?await s.setScreenShareEnabled(!1):await s.shareScreen()}catch(st){console.error("[obi-sdk] failed to toggle screen share",st)}finally{it()}},Ti=w.useRef(null),Bn=w.useRef(null),Un=w.useRef(!1),Wt=w.useRef({session:null,sessionUuid:null,started:!1}),ai=w.useRef(null),zn=w.useRef(new WeakMap),Vl=(Y,ne)=>{if(!ne)return;let Te=zn.current.get(Y);Te||(Te=new Set,zn.current.set(Y,Te)),Te.add(ne)},ks=Y=>{if(!Y||Ti.current===Y)return;Bn.current&&(Bn.current(),Bn.current=null);const ne=()=>it(),Te=ie=>{u(ie),Je(),Y!=null&&Y.sessionUuid&&j3(Y.sessionUuid,ie),p(Ne=>Ne==="pip"||Ne==="course-outline"?Ne:Ne==="course-selection"?(be.current=!0,"course-outline"):Ne)},st=ie=>{Je(),T(ie.courses),p("course-selection"),be.current=!1,u(null),Y!=null&&Y.sessionUuid&&B3(Y.sessionUuid),R(null),P(!1)},xe=(ie,Ne)=>{},Ae=ie=>{ie.isAgent},pt=ie=>{$(ie),X(Date.now())},nn=ie=>{if(!ie){$(null);return}$(ie),X(Date.now())};Y.on("stateChanged",ne),Y.on("speakingStateChanged",ne),Y.on("paused",ne),Y.on("unpaused",ne),Y.on("chatMessagesChanged",ne),Y.on("chatMessageReceived",Ae),Y.on("courseProgress",Te),Y.on("courseSelection",st),Y.on("transcript",xe),Y.on("screenCaptured",pt),Y.on("screenCaptureNotification",nn),Y.on("captions",Z),Y.on("introductionComplete",qe),Ti.current=Y,Bn.current=()=>{Y.off("stateChanged",ne),Y.off("speakingStateChanged",ne),Y.off("paused",ne),Y.off("unpaused",ne),Y.off("chatMessagesChanged",ne),Y.off("chatMessageReceived",Ae),Y.off("courseProgress",Te),Y.off("courseSelection",st),Y.off("transcript",xe),Y.off("screenCaptured",pt),Y.off("screenCaptureNotification",nn),Y.off("captions",Z),Y.off("introductionComplete",qe)}},Se=Y=>{var Te;return Y?((Te=Y.roomId)==null?void 0:Te.startsWith("obs-"))&&!c?"course-selection":"pip":"hidden"};w.useEffect(()=>{const Y=()=>{ai.current&&(ai.current(),ai.current=null)},ne=xe=>{if(xe.clientType!=="meet")return;if(Wt.current.session&&Wt.current.session===xe||!!Wt.current.sessionUuid&&!!xe.sessionUuid&&Wt.current.sessionUuid===xe.sessionUuid){if(Wt.current.started||ai.current)return}else Wt.current={session:xe,sessionUuid:xe.sessionUuid??null,started:!1},Y();const pt=async()=>{Wt.current={session:xe,sessionUuid:xe.sessionUuid??null,started:!0};const Ne=We(xe);Ne&&Vl(xe,Ne);try{await xe.sendHumanJoined(Ce(xe))}catch(Yt){console.error("[obi-sdk] failed to send human_joined handshake",Yt)}},nn=(Ne,Yt)=>{Ne==="connecting"||Ne==="error"||(Y(),pt())},ie=xe.state;if(ie&&ie!=="connecting"&&ie!=="error"){pt();return}xe.on("stateChanged",nn),ai.current=()=>{xe.off("stateChanged",nn)}},Te=xe=>{var Ae,pt,nn,ie;if(xe)if((Ae=e.client)!=null&&Ae.session)p(Se(((nn=e.client)==null?void 0:nn.session)??null));else{const Yt=!!e.passivePlanUuid,qn=Yt&&!!((pt=e.client)!=null&&pt.selectedPlanUuid);if(Yt&&!qn)return;p("start-session")}else(ie=e.client)!=null&&ie.session||p("hidden")},st=()=>it();if(e.on("showMenu",Te),e.on("configUpdated",st),e.client){e.client.session&&(l(e.client.session),ks(e.client.session),p(Se(e.client.session))),e.client.on("sessionStarted",Ae=>{l(Ae),ks(Ae),Un.current=!1,S(!1),y(!1),v(!1),P(!1);const pt=me.current;me.current=!1,pt?(be.current=!0,p("course-outline")):(be.current=!1,p(Se(Ae))),sa().track("session-started",{planId:Ae.planId}),ne(Ae)}),e.client.on("sessionResumed",Ae=>{l(Ae),ks(Ae),Un.current=!1,S(!1),y(!1),v(!1),P(!1),be.current=!1,p(Se(Ae)),ne(Ae)});const xe=()=>{var nn;const Ae=(nn=e.client)==null?void 0:nn.session;Ae!=null&&Ae.sessionUuid&&B3(Ae.sessionUuid);const pt=Ti.current;Bn.current&&(Bn.current(),Bn.current=null),l(null),Ti.current=null,S(!1),y(!1),v(!1),P(!1),fe(!1),me.current=!1,Je(),be.current=!1,Y(),Wt.current={session:null,sessionUuid:null,started:!1},pt&&zn.current.delete(pt),Un.current||p("hidden")};e.client.on("sessionStopped",xe),e.client.on("sessionShutdown",xe),e.client.on("stateChanged",it)}return()=>{e.off("showMenu",Te),e.off("configUpdated",st),Bn.current&&Bn.current(),Y()}},[e]),w.useEffect(()=>{const Y=s;if(!Y||Y.clientType!=="meet")return;const ne=Y.state;if(!ne||ne==="connecting"||ne==="error"||!ae)return;const Te=zn.current.get(Y);Te!=null&&Te.has(ae)||(Vl(Y,ae),Y.sendHumanJoined(Ce(Y)).catch(st=>console.error("[obi-sdk] failed to send human_joined update",st)))},[In,ae,s,s==null?void 0:s.state]),w.useLayoutEffect(()=>{var Y,ne;(ne=(Y=e.client)==null?void 0:Y.product)!=null&&ne.primary_color&&n.style.setProperty("--obi-color-primary",e.client.product.primary_color)},[(pe=(M=e.client)==null?void 0:M.product)==null?void 0:pe.primary_color,n]),w.useEffect(()=>{if(i&&!tn&&!q){if(!r){p("hidden");return}p("start-session")}},[q,i,tn,r]),w.useEffect(()=>{var nn,ie;ge(!1);const Y=(nn=e.client)==null?void 0:nn.api,ne=(ie=e.client)==null?void 0:ie.product;if(!Y||!ne)return;const Te=(ne==null?void 0:ne.uuid)??(ne==null?void 0:ne.product_uuid),st=(ne==null?void 0:ne.slug)??(ne==null?void 0:ne.product_slug),xe=(ne==null?void 0:ne.id)??(ne==null?void 0:ne.product_id),Ae={};if(Te?Ae.product_uuid=Te:st?Ae.product_slug=st:xe!=null&&(Ae.product_id=String(xe)),Object.keys(Ae).length===0)return;let pt=!1;return Y.getFeatureFlags(Ae).then(Ne=>{if(pt)return;const qn=((Ne==null?void 0:Ne.data)??[]).find(ny=>(ny==null?void 0:ny.slug)===oW);if(!qn)return;const{user_enabled:oi,product_enabled:Hn,global_enabled:Tr}=qn;let ty=!!Tr;Hn!=null&&(ty=!!Hn),oi!=null&&(ty=!!oi),ge(ty)}).catch(Ne=>{console.error("[obi-sdk] failed to load AMA feature flag",Ne)}),()=>{pt=!0}},[(Le=e.client)==null?void 0:Le.api,(ve=e.client)==null?void 0:ve.product]);const Fn=(c==null?void 0:c.stepNames.map((Y,ne)=>({id:`step-${ne+1}`,title:Y})))??[],Gl=(c==null?void 0:c.currentStep)??null,Ao=!0,Yr=(Y,ne)=>{s==null||s.say(`Can we jump to the section about ${ne.title}?`)};if(tn||i&&!r&&!q)return null;if(h==="hidden")return Wr?f.jsx(aW,{label:Pe,onClick:()=>{e.updateShowMenu(!0)}}):null;if(h==="start-session"){const Y=(zt=e.client)==null?void 0:zt.product,ne=(_t=e.client)==null?void 0:_t.selectedPlan,Te=i&&!!r,st=i&&!!r||!!((xt=e.client)!=null&&xt.selectedPlanUuid),xe=(Y==null?void 0:Y.agent_name)||"Obi",Ae=(Y==null?void 0:Y.assistant_subtitle)||"AI Assistant",pt=Te&&(ne==null?void 0:ne.description)||(Y==null?void 0:Y.assistant_description)||"";return f.jsx(iW,{open:!0,onClose:()=>{S(!1),p("hidden")},onStart:()=>{me.current=st,fe(st),S(!0),e.startSession({withMicrophone:!0})},agentName:xe,agentSubtitle:Ae,description:pt,showCloseButton:!1,startLabel:"Start Session",isStarting:m,greetingVideoSrc:ki})}if(h==="course-selection"){const Y=(Xr=s==null?void 0:s.roomId)==null?void 0:Xr.startsWith("obs-"),ne=((Ie=e.client)==null?void 0:Ie.plans)||[],Te=Y&&k.length>0,st=Te?k.slice().sort((ie,Ne)=>ie.order!==void 0&&Ne.order!==void 0?ie.order-Ne.order:ie.order!==void 0?-1:Ne.order!==void 0?1:ie.name.localeCompare(Ne.name)).map(ie=>({id:ie.uuid,title:ie.name,description:ie.description||ie.overview||"",status:ie.completed?"completed":"available",duration:typeof ie.duration=="number"?`${ie.duration} min`:ie.duration})):ne.map(ie=>{var Ne,Yt;return{id:ie.uuid,title:ie.name,description:ie.description,status:(Yt=(Ne=e.client)==null?void 0:Ne.planIsCompleted)!=null&&Yt[ne.indexOf(ie)]?"completed":"available",duration:ie.estimated_duration?`${ie.estimated_duration} min`:void 0}});Te&&j&&st.push({id:I3,title:"Ask me anything",description:"Ask questions before choosing a course.",status:"available"});const xe=(s==null?void 0:s.languageCodes)||[],Ae=(s==null?void 0:s.selectedLanguage)||(s==null?void 0:s.defaultLanguageCode)||null,pt={audioDevices:bn,currentMicrophoneId:(s==null?void 0:s.preferredMicrophoneDeviceId)||null,isMicrophoneEnabled:!g&&((s==null?void 0:s.isMicShared)??!1),isScreenShareActive:Si,widgetState:x?"chat":null,canPublishData:!0,browserSupportsScreenSharing:In,onMicDeviceSelect:async ie=>{e.client&&(e.client.preferredMicrophoneDeviceId=ie),s&&ie&&await s.switchMicrophoneDevice(ie),it()},onMicToggle:async()=>{s!=null&&s.isMicShared?g?(await s.unmuteMicrophone(),y(!1)):(await s.muteMicrophone(),y(!0)):await(s==null?void 0:s.shareMicrophone())},onChatToggle:()=>{v(!x)},onLeave:()=>{s==null||s.stop()},onScreenShareToggle:jn,languages:xe,selectedLanguage:Ae,defaultLanguageCode:s==null?void 0:s.defaultLanguageCode,isMultilingual:(s==null?void 0:s.isMultilingual)??!1,onLanguageChange:ie=>{s==null||s.setLanguage(ie)},isLanguageSelectorEnabled:!0,...x?{screenShareButtonVariant:"compact"}:{}},nn=x?f.jsx(N3,{messages:(s==null?void 0:s.chatMessages)??[],localIdentity:((Uo=s==null?void 0:s.room)==null?void 0:Uo.localParticipant.identity)??(typeof(s==null?void 0:s.identity)=="string"?s.identity:null),onSend:async ie=>{var Ne,Yt,qn,oi;if(s){const Hn=Date.now();s.appendChatMessage({timestamp:Hn,message:ie,from:{identity:((Yt=(Ne=s.room)==null?void 0:Ne.localParticipant)==null?void 0:Yt.identity)??null,name:((oi=(qn=s.room)==null?void 0:qn.localParticipant)==null?void 0:oi.name)??null},isAgent:!1}),await s.say(ie)}},onClose:()=>v(!1)}):void 0;return f.jsx(L3,{open:!0,onClose:()=>s==null?void 0:s.stop(),courses:st,controlBarProps:pt,coursePanelProps:{selectedCourseIds:C?[C]:void 0,loadingCourseId:A,onCourseToggle:async ie=>{var Ne,Yt,qn,oi;if(!en.current)if(Te){if(ie===I3){cn(ie),R(ie);try{await((Ne=s==null?void 0:s.say)==null?void 0:Ne.call(s,"Please start an AMA session."))}catch(Tr){console.error("[obi-sdk] failed to start AMA course",Tr),Je(),R(null)}return}const Hn=k.find(Tr=>Tr.uuid===ie);if(Hn){cn(ie),R(ie);try{await((Yt=s==null?void 0:s.say)==null?void 0:Yt.call(s,`I'd like to take the ${Hn.name} course.`))}catch(Tr){console.error("[obi-sdk] failed to send course selection",Tr),Je(),R(null)}}}else{const Hn=ne.find(Tr=>Tr.uuid===ie);if(Hn){cn(ie),(qn=e.client)==null||qn.selectPlan(Hn),p("pip");try{await((oi=s==null?void 0:s.say)==null?void 0:oi.call(s,`I'd like to take the ${Hn.name} course.`))}catch(Tr){console.error("[obi-sdk] failed to send course selection",Tr),p("course-selection"),Je()}}}}},rightPanel:nn,avatarImageSrc:ot,avatarAudioPower:Mt,avatarStatus:Qe,captionsText:yn})}if(h==="course-outline"){const Y=(s==null?void 0:s.languageCodes)||[],ne=(s==null?void 0:s.selectedLanguage)||(s==null?void 0:s.defaultLanguageCode)||null,Te={audioDevices:bn,currentMicrophoneId:(s==null?void 0:s.preferredMicrophoneDeviceId)||null,isMicrophoneEnabled:!g&&((s==null?void 0:s.isMicShared)??!1),isScreenShareActive:Si,widgetState:x?"chat":null,canPublishData:!0,browserSupportsScreenSharing:In,onMicDeviceSelect:async ie=>{e.client&&(e.client.preferredMicrophoneDeviceId=ie),s&&ie&&await s.switchMicrophoneDevice(ie),it()},onMicToggle:async()=>{s!=null&&s.isMicShared?g?(await s.unmuteMicrophone(),y(!1)):(await s.muteMicrophone(),y(!0)):await(s==null?void 0:s.shareMicrophone())},onChatToggle:()=>{v(!x)},onLeave:()=>{s==null||s.stop()},onScreenShareToggle:jn,languages:Y,selectedLanguage:ne,defaultLanguageCode:s==null?void 0:s.defaultLanguageCode,isMultilingual:(s==null?void 0:s.isMultilingual)??!1,onLanguageChange:ie=>{s==null||s.setLanguage(ie)},isLanguageSelectorEnabled:!0,...x?{screenShareButtonVariant:"compact"}:{}},st=x?f.jsx(N3,{messages:(s==null?void 0:s.chatMessages)??[],localIdentity:((Kl=s==null?void 0:s.room)==null?void 0:Kl.localParticipant.identity)??(typeof(s==null?void 0:s.identity)=="string"?s.identity:null),onSend:async ie=>{var Ne,Yt,qn,oi;if(s){const Hn=Date.now();s.appendChatMessage({timestamp:Hn,message:ie,from:{identity:((Yt=(Ne=s.room)==null?void 0:Ne.localParticipant)==null?void 0:Yt.identity)??null,name:((oi=(qn=s.room)==null?void 0:qn.localParticipant)==null?void 0:oi.name)??null},isAgent:!1}),await s.say(ie)}},onClose:()=>v(!1)}):void 0,xe=!!c,Ae=!U,pt=async()=>{if(!(!(s!=null&&s.endCourse)||K)){P(!0);try{await s.endCourse("back_to_courses")}catch(ie){console.error("[obi-sdk] failed to end course",ie),P(!1)}}},nn=f.jsx(RV,{steps:Fn,currentStep:Gl,hideTrailingConclusionStep:Ao,onStepClick:Yr,showBackToCourses:Ae,...Ae?{onBackToCoursesConfirm:pt,backToCoursesDisabled:K}:{}});return f.jsx(L3,{open:!0,onClose:()=>s==null?void 0:s.stop(),courses:[],controlBarProps:Te,middlePanel:nn,rightPanel:st,isCourseOutlineOpen:xe,onReturnToPiP:xe?()=>p("pip"):void 0,avatarImageSrc:ot,avatarAudioPower:Mt,avatarStatus:Qe,captionsText:yn})}if(h==="pip"){const Y=(s==null?void 0:s.languageCodes)||[],ne=(s==null?void 0:s.selectedLanguage)||(s==null?void 0:s.defaultLanguageCode)||null,Te=280,st=250,xe=16,Ae={x:window.innerWidth-Te-xe,y:window.innerHeight-st-xe},pt={isMicrophoneEnabled:!g&&((s==null?void 0:s.isMicShared)??!1),isChatOpen:x,isScreenShareActive:Si,onMicToggle:async()=>{s!=null&&s.isMicShared?g?(await s.unmuteMicrophone(),y(!1)):(await s.muteMicrophone(),y(!0)):await(s==null?void 0:s.shareMicrophone())},onChatToggle:()=>v(ie=>!ie),onScreenShareToggle:jn,onLeave:()=>{s==null||s.stop()},languages:Y,selectedLanguage:ne,defaultLanguageCode:s==null?void 0:s.defaultLanguageCode,isMultilingual:(s==null?void 0:s.isMultilingual)??!1,onLanguageChange:ie=>{s==null||s.setLanguage(ie)},isLanguageSelectorEnabled:!0},nn=x?f.jsx($V,{messages:(s==null?void 0:s.chatMessages)??[],localIdentity:((K3=s==null?void 0:s.room)==null?void 0:K3.localParticipant.identity)??(typeof(s==null?void 0:s.identity)=="string"?s.identity:null),onSend:async ie=>{var Ne,Yt,qn,oi;if(s){const Hn=Date.now();s.appendChatMessage({timestamp:Hn,message:ie,from:{identity:((Yt=(Ne=s.room)==null?void 0:Ne.localParticipant)==null?void 0:Yt.identity)??null,name:((oi=(qn=s.room)==null?void 0:qn.localParticipant)==null?void 0:oi.name)??null},isAgent:!1}),await s.say(ie)}},testId:"pip-chat-panel"}):void 0;return f.jsx(sH,{initialPosition:Ae,onExit:()=>{be.current=!1,p("course-outline")},controlBarProps:pt,isCourseOutlineSelected:W&&!!c,onCourseOutlineToggle:c?()=>{L(ie=>!ie)}:void 0,isCaptionsEnabled:Q,onCaptionsToggle:()=>ce(ie=>!ie),courseOutline:c?{steps:Fn,currentStep:Gl,onStepClick:Yr,hideTrailingConclusionStep:Ao}:void 0,messagesPanel:nn,avatarFallbackProps:{audioPower:Mt,imageSrc:ot,status:Qe,captionsText:yn},screenshotUrl:te,cameraShotTrigger:V})}return null}function cW(t){var l,c;const{sdk:e,session:n,isBlacklisted:i}=t;if(i)return!1;const r=e.client;if(!r||r.state!=="ready"||(n??r.session??null))return!1;let o=e.isActive;return((l=r.product)==null?void 0:l.name)==="Canibuild"&&(o=!0),!(!o||(e.widgetDisplay??((c=r.product)==null?void 0:c.widget_display))==="invisible")}function j3(t,e){if(!t)return;const n=`obi-widget-course-progress-${t}`;if(e===null){localStorage.removeItem(n);return}try{const i={...e,timestamp:Date.now()};localStorage.setItem(n,JSON.stringify(i))}catch(i){console.error("[obi-sdk] failed to save course progress",i)}}function uW(t){if(!t)return null;const e=`obi-widget-course-progress-${t}`;try{const n=localStorage.getItem(e);if(!n)return null;const i=JSON.parse(n);if(typeof i.currentStep!="number"||typeof i.totalSteps!="number"||!Array.isArray(i.stepNames))return console.warn("[obi-sdk] invalid course progress data, clearing",i),localStorage.removeItem(e),null;const r=24*60*60*1e3;return i.timestamp&&Date.now()-i.timestamp>r?(localStorage.removeItem(e),null):{currentStep:i.currentStep,totalSteps:i.totalSteps,stepNames:i.stepNames}}catch(n){return console.error("[obi-sdk] failed to load course progress",n),localStorage.removeItem(e),null}}function B3(t){if(!t)return;const e=`obi-widget-course-progress-${t}`;try{localStorage.removeItem(e)}catch(n){console.error("[obi-sdk] failed to clear course progress",n)}}function dW(t){const[e,n]=w.useState(()=>ys(t));return w.useEffect(()=>{n(ys(t))},[t]),w.useEffect(()=>{const i=()=>{n(ys(t))};return window.addEventListener("popstate",i),window.addEventListener("hashchange",i),()=>{window.removeEventListener("popstate",i),window.removeEventListener("hashchange",i)}},[t]),e}function hW(t){const[e,n]=w.useState(0),i=w.useRef(null),r=w.useRef(0),a=w.useRef(0);return w.useEffect(()=>{if(!t){n(0),r.current=0,a.current=0;return}const o=()=>{const s=t.audioSpectrum();let l=0;if(s&&s.length>0){let b=0;for(let m=0;m<s.length;m++)b+=s[m];l=Math.min(1,Math.max(0,b/s.length))}const c=r.current,d=l>=c?.7:.15,h=c*d+l*(1-d);r.current=h;const p=h<.05?0:Math.min(1,h);Math.abs(p-a.current)>.01&&(a.current=p,n(p)),i.current=requestAnimationFrame(o)};return i.current=requestAnimationFrame(o),()=>{i.current&&cancelAnimationFrame(i.current)}},[t]),e}function fW(){const[t,e]=w.useState({audioDevices:[]});return w.useEffect(()=>{var i;if(typeof navigator>"u"||!((i=navigator.mediaDevices)!=null&&i.enumerateDevices))return;const n=()=>{navigator.mediaDevices.enumerateDevices().then(r=>{e({audioDevices:r.filter(a=>a.kind==="audioinput")})})};return n(),navigator.mediaDevices.addEventListener("devicechange",n),()=>navigator.mediaDevices.removeEventListener("devicechange",n)},[]),t}function U3(){const t=window.location.hostname;return t.endsWith(".getcor.ai")||t.endsWith(".getcor.io")||t.endsWith(".clinic1.com")||t===".onuptick.com"||t==="getcor.ai"||t==="getcor.io"||t==="localhost"||t==="127.0.0.1"||t==="::1"}const z3=U3();function pW(t){if(document.querySelector("#obi-host")||document.querySelector("obi-widget"))return;mW();const e=document.createElement("div");e.id="obi-host",e.style.position="fixed",e.style.zIndex="9999",document.body.appendChild(e);const n=e.attachShadow({mode:"open"}),i=document.createElement("div");i.id="obi-container",n.appendChild(i);const r=new CSSStyleSheet;r.replaceSync(MB);const a=[r];if(z3){const s=new CSSStyleSheet;s.replaceSync(AB),a.push(s);const l=new CSSStyleSheet;l.replaceSync(OB),a.push(l)}else{const s=new CSSStyleSheet;s.replaceSync(NB),a.push(s)}n.adoptedStyleSheets=a;const o=RB.createRoot(i);z3?o.render(f.jsx(lW,{sdk:t,shadowHost:e})):o.render(f.jsx(LB,{sdk:t,shadowHost:e})),console.log("[obi-sdk] widget mounted")}function mW(){F3("https://fonts.cdnfonts.com/css/satoshi"),F3("https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap")}function F3(t){const e=document.createElement("link");e.href=t,e.rel="stylesheet",document.head.appendChild(e)}const q3="49206C6F7665204F6269_session",H3="obi-url-params",ey="obi-client-heartbeat",gW=5e3,V3=4e4,G3=15e3;function vW(){return U3()?"meet":"sdk"}class bW extends Ep{constructor(e){super(),this.client=null,this.isActive=!1,this.primaryColour="#9500FF",this.passivePlanUuid=null,this.commandLog=[],this.commandQueue=[],this._resumed=!1,this.heartbeatInterval=null,this.dispatchCommand=(n,i)=>{var r,a,o,s,l;switch(this.commandLog.push({commandType:n,args:i}),n){case"update":this.updateConfig(i);break;case"startSession":{if(i!=null&&i.planUuid){const c=(((r=this.client)==null?void 0:r.plans)||[]).find(u=>u.uuid===i.planUuid)||null;if(!c){console.warn("[obi] startSession command requires a valid planUuid",i);return}(o=(a=this.client)==null?void 0:a.selectPlan)==null||o.call(a,c)}this.updateActive(!0);break}case"stopSession":(l=(s=this.client)==null?void 0:s.stopSession)==null||l.call(s);break;case"say":this.say(i);break;default:console.warn("[obi] unknown command",{commandType:n,args:i})}},e&&this.createClient(e),this.parsePassiveParams()}async createClient(e){if(this.client){this.client.appToken!==e&&console.warn("[obi] client already exists with different app token");return}let n=null;const i=vW(),r=this.load();if(r)try{const a=this.parsePersistedSessionMetadata(r),o=a&&this.isPersistedSessionStale(a);o!=null&&o.stale&&a?(this.trackStaleSessionDiscard(a.sessionUuid,o.ageMs,o.reason),this.clearCachedClient()):(n=wh.deserialise(r,e,i,{apiBaseUrl:"https://staging.coragents.ai",captureScreen:this.captureScreen.bind(this)}),n?this._resumed=!0:this.clearCachedClient())}catch(a){console.error("[obi] error loading cached client",a),this.clearCachedClient()}n||(n=new wh(e,i,{apiBaseUrl:"https://staging.coragents.ai",captureScreen:this.captureScreen.bind(this)})),this.client=n,this.client.session&&this.startHeartbeat(this.client.session.sessionUuid),this.client.on("stateChanged",a=>{var o,s,l,c,u,d,h,p,b,m;a==="ready"&&this.updateConfig({isActive:((o=window==null?void 0:window.obiWidgetConfig)==null?void 0:o.isActive)??((s=this.client)==null?void 0:s.showWidget),primaryColour:((c=(l=this.client)==null?void 0:l.product)==null?void 0:c.primary_color)||"#9500FF",widgetDisplay:((u=window==null?void 0:window.obiWidgetConfig)==null?void 0:u.widgetDisplay)||((h=(d=this.client)==null?void 0:d.product)==null?void 0:h.widget_display)||"regular",completedWidgetDisplay:((p=window==null?void 0:window.obiWidgetConfig)==null?void 0:p.completedWidgetDisplay)||((m=(b=this.client)==null?void 0:b.product)==null?void 0:m.completed_widget_display)||"regular"})}),this.client.on("sessionStarted",()=>{var a,o;this.save(),this.startHeartbeat(((o=(a=this.client)==null?void 0:a.session)==null?void 0:o.sessionUuid)||null),this.passivePlanUuid=null}),this.client.on("sessionStopped",()=>{this.clearCachedClient(),this.passivePlanUuid=null}),this.client.on("sessionShutdown",()=>{this.clearCachedClient()}),this.client.on("trackEvent",(a,o)=>{}),this.client.session&&(this.client.session.isPaused,this.client.resumeSession(a=>{a.on("stateChanged",o=>{o!=="disconnecting"&&o!=="disconnected"&&o!=="error"&&o!=="connecting"&&this.save()}),a.on("paused",()=>{this.save()}),a.on("unpaused",()=>{this.save()})}))}_maybeActOnServerEngagement(){var s;const e=this.client;if(!e||e.state!=="ready")return;const n=e.product,i=(s=e.engagement)==null?void 0:s.style;if(!i||n&&ys(n.widget_url_blacklist||[])||!e.showWidget)return;const r=e.plans||[],a=e.planIsCompleted||[],o=r.length>0&&a.filter(Boolean).length===r.length;if(!(r.length===0||o)){if(i==="modal"){const l=a.findIndex(u=>!u),c=l>=0?r[l]:null;c&&e.selectPlan(c)}else i==="popover"&&setTimeout(()=>{this.showMessage("Don't forget to complete your onboarding",{autoCloseMs:1e4})},1e3);try{sa().track("engagement-prompt-shown",{style:i})}catch{}}}async initialise(e={}){var n;this.commandQueue=e.queuedCommands||[],this._resumed?(this._resumed=!1,this.dispatchCommandQueue()):this.client?this.client.initialise({planUuid:this.passivePlanUuid||void 0,identity:((n=window==null?void 0:window.obiWidgetConfig)==null?void 0:n.user)||void 0}).then(()=>{this.emit("initialised");try{this._maybeActOnServerEngagement()}catch{}this.dispatchCommandQueue()}).catch(i=>{console.error("[obi] error initialising client",i),this.emit("error",i)}):this.dispatchCommandQueue()}async updateConfig(e){e.apiKey!==void 0&&await this.updateAppToken(e.apiKey),this.updateActive(e.isActive),this.updatePrimaryColour(e.primaryColour),this.updateWidgetDisplay(e.widgetDisplay),this.updateCompletedWidgetDisplay(e.completedWidgetDisplay),this.updateWidgetPosition(e.widgetPosition),e.user!==void 0&&await this.updateIdentity(e.user),this.updateShowMenu(e.showMenu),this.emit("configUpdated")}async updateAppToken(e){var n;e===void 0||e==((n=this.client)==null?void 0:n.appToken)||(this.passivePlanUuid,await this.createClient(e),this.client&&await this.client.initialise({planUuid:this.passivePlanUuid||void 0}).then(()=>{this.emit("initialised");try{this._maybeActOnServerEngagement()}catch{}}).catch(i=>{console.error("[obi] error initialising client",i),this.emit("error",i)}))}updateActive(e){e===void 0||e==this.isActive||(this.isActive=e)}updatePrimaryColour(e){e===void 0||e==this.primaryColour||(this.primaryColour=e)}updateWidgetDisplay(e){e===void 0||e==this.widgetDisplay||(this.widgetDisplay=e)}updateCompletedWidgetDisplay(e){e===void 0||e==this.completedWidgetDisplay||(this.completedWidgetDisplay=e)}updateWidgetPosition(e){e===void 0||e==this.widgetPosition||(this.widgetPosition=e)}async updateIdentity(e){var i,r;if(e===void 0||e==((i=this.client)==null?void 0:i.identity))return;(r=this.client)==null||r.identity;let n=e?{...e,extra:{...e,...(e==null?void 0:e.extra)||{}}}:void 0;await this.client.initialise({identity:n,planUuid:this.passivePlanUuid||void 0}).then(()=>{this.emit("initialised");try{this._maybeActOnServerEngagement()}catch{}}).catch(a=>{console.error("[obi] error initialising client",a),this.emit("error",a)}),e!=null&&e.email&&sa().identify((e==null?void 0:e.email)||"",n)}updateShowMenu(e){e!==void 0&&this.emit("showMenu",e)}async say(e){var n,i,r;await((r=(i=(n=this.client)==null?void 0:n.session)==null?void 0:i.say)==null?void 0:r.call(i,e))}async startSession(e){await this.client.startSession(this.client.selectedPlanUuid||null,n=>{n.on("stateChanged",i=>{i!=="disconnecting"&&i!=="disconnected"&&i!=="error"&&i!=="connecting"&&this.save()}),n.on("paused",()=>{this.save()}),n.on("unpaused",()=>{this.save()})},e)}dispatchCommandQueue(){const e=this.commandQueue;this.commandQueue=[],e.forEach(n=>{try{this.dispatchCommand(n[0],n[1]||[])}catch(i){console.error("[obi] error dispatching command",i)}})}parsePassiveParams(){if(this.passivePlanUuid){this.passivePlanUuid;return}let e={};e=JSON.parse(localStorage.getItem(H3)||"{}"),Object.keys(e).length===0&&new URLSearchParams(window.location.search).forEach((a,o)=>{e[o]=a});const n=e[q3];if(!n)return null;const i=new URL(window.location.href);i.searchParams.delete(q3),window.history.replaceState({},"",i.toString()),i.toString(),localStorage.removeItem(H3),this.passivePlanUuid=n}mountWidget(){pW(this)}showMessage(e,n){try{this.emit("showMessage",{text:e,autoCloseMs:n==null?void 0:n.autoCloseMs})}catch{}}async captureScreen(){try{await xO(async()=>(this.graphemes||(this.graphemes=await this.client.api.getGraphemes()),this.graphemes.data.text_segmentation)),await mR(async()=>(this.graphemes||(this.graphemes=await this.client.api.getGraphemes()),this.graphemes.data.css_line_breaks))}catch(e){throw console.error("[obi] error initialising unicode trie",e),e}try{return(await ZN(document.documentElement,{useCORS:!0,allowTaint:!0,foreignObjectRendering:!0})).toDataURL("image/png")}catch(e){throw console.error("[obi] error capturing screen",e),e}}save(){var n;const e=((n=this.client)==null?void 0:n.serialise())||"";localStorage.setItem("obi-client",e)}load(){return localStorage.getItem("obi-client")}parsePersistedSessionMetadata(e){const n=JSON.parse(e),i=this.parseTimestampMs(n.serialisedAt);if(!n.session)return null;let r=null;if(typeof n.session=="string")try{r=JSON.parse(n.session)}catch{return null}else typeof n.session=="object"&&(r=n.session);return r?{sessionUuid:typeof r.sessionUuid=="string"?r.sessionUuid:null,startedAtMs:this.parseTimestampMs(r.startedAt),serialisedAtMs:i}:null}isPersistedSessionStale(e){const n=Date.now(),i=this.readHeartbeat();if(i&&i.sessionUuid&&e.sessionUuid&&i.sessionUuid===e.sessionUuid){const s=Math.max(0,n-i.updatedAtMs);return{stale:s>V3,reason:s>V3?"heartbeat-stale":"heartbeat-fresh",ageMs:s}}const r=[e.serialisedAtMs,e.startedAtMs].filter(s=>typeof s=="number"&&Number.isFinite(s));if(r.length===0)return{stale:!0,reason:"fallback-missing-timestamps",ageMs:null};const a=Math.max(...r),o=Math.max(0,n-a);return{stale:o>G3,reason:o>G3?"fallback-too-old":"fallback-recent",ageMs:o}}parseTimestampMs(e){if(typeof e=="number")return e;if(typeof e=="string"){const n=Number(e);if(!Number.isNaN(n))return n;const i=Date.parse(e);return Number.isFinite(i)?i:null}return null}readHeartbeat(){const e=localStorage.getItem(ey);if(!e)return null;try{return JSON.parse(e)}catch{return null}}trackStaleSessionDiscard(e,n,i){try{sa().track("stale-session-discarded",{sessionUuid:e||void 0,ageMs:n??void 0,reason:i})}catch{}}startHeartbeat(e){if(!e){this.clearHeartbeat();return}this.stopHeartbeat(),this.writeHeartbeat(e),this.heartbeatInterval=setInterval(()=>{this.writeHeartbeat(e)},gW)}stopHeartbeat(){this.heartbeatInterval&&(clearInterval(this.heartbeatInterval),this.heartbeatInterval=null)}writeHeartbeat(e){const n={sessionUuid:e,updatedAtMs:Date.now()};localStorage.setItem(ey,JSON.stringify(n))}clearHeartbeat(){this.stopHeartbeat(),localStorage.removeItem(ey)}clearCachedClient(){this.clearHeartbeat(),localStorage.removeItem("obi-client")}}async function W3(t,e){let n;try{n=window}catch{console.warn("[obi] no window object found"),n={}}return yW({appToken:t,window:n,init:e})}async function yW({appToken:t,window:e,init:n}){var a,o;if(e.obi){console.warn("[obi] obi object already found on window, skipping");return}n&&n(),t||(t=(a=e==null?void 0:e.obiWidgetConfig)==null?void 0:a.apiKey);let i;try{i=((o=e.ObiSDK)==null?void 0:o.q)||[]}catch{i=[]}const r=new bW(t);return e.ObiSDK=r.dispatchCommand,await r.initialise({queuedCommands:i}),e.obi=r,r.mountWidget(),r}function Y3(){}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{W3(void 0,Y3)}):W3(void 0,Y3)})();
@@ -130,4 +130,4 @@ ${t}</tr>
130
130
  `}tablecell(t){let e=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>
131
131
  `}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${Ea(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:n}){let i=this.parser.parseInline(n),r=v3(t);if(r===null)return i;t=r;let a='<a href="'+t+'"';return e&&(a+=' title="'+Ea(e)+'"'),a+=">"+i+"</a>",a}image({href:t,title:e,text:n,tokens:i}){i&&(n=this.parser.parseInline(i,this.parser.textRenderer));let r=v3(t);if(r===null)return Ea(n);t=r;let a=`<img src="${t}" alt="${n}"`;return e&&(a+=` title="${Ea(e)}"`),a+=">",a}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:Ea(t.text)}},Gb=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}checkbox({raw:t}){return t}},xr=class ry{constructor(e){vt(this,"options"),vt(this,"renderer"),vt(this,"textRenderer"),this.options=e||xs,this.options.renderer=this.options.renderer||new vp,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Gb}static parse(e,n){return new ry(n).parse(e)}static parseInline(e,n){return new ry(n).parseInline(e)}parse(e){var i,r;let n="";for(let a=0;a<e.length;a++){let o=e[a];if((r=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&r[o.type]){let l=o,c=this.options.extensions.renderers[l.type].call({parser:this},l);if(c!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(l.type)){n+=c||"";continue}}let s=o;switch(s.type){case"space":{n+=this.renderer.space(s);break}case"hr":{n+=this.renderer.hr(s);break}case"heading":{n+=this.renderer.heading(s);break}case"code":{n+=this.renderer.code(s);break}case"table":{n+=this.renderer.table(s);break}case"blockquote":{n+=this.renderer.blockquote(s);break}case"list":{n+=this.renderer.list(s);break}case"checkbox":{n+=this.renderer.checkbox(s);break}case"html":{n+=this.renderer.html(s);break}case"def":{n+=this.renderer.def(s);break}case"paragraph":{n+=this.renderer.paragraph(s);break}case"text":{n+=this.renderer.text(s);break}default:{let l='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return n}parseInline(e,n=this.renderer){var r,a;let i="";for(let o=0;o<e.length;o++){let s=e[o];if((a=(r=this.options.extensions)==null?void 0:r.renderers)!=null&&a[s.type]){let c=this.options.extensions.renderers[s.type].call({parser:this},s);if(c!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type)){i+=c||"";continue}}let l=s;switch(l.type){case"escape":{i+=n.text(l);break}case"html":{i+=n.html(l);break}case"link":{i+=n.link(l);break}case"image":{i+=n.image(l);break}case"checkbox":{i+=n.checkbox(l);break}case"strong":{i+=n.strong(l);break}case"em":{i+=n.em(l);break}case"codespan":{i+=n.codespan(l);break}case"br":{i+=n.br(l);break}case"del":{i+=n.del(l);break}case"text":{i+=n.text(l);break}default:{let c='Token with "'+l.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return i}},bp,zu=(bp=class{constructor(t){vt(this,"options"),vt(this,"block"),this.options=t||xs}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(){return this.block?_r.lex:_r.lexInline}provideParser(){return this.block?xr.parse:xr.parseInline}},vt(bp,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),vt(bp,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),bp),Jz=class{constructor(...t){vt(this,"defaults",Ib()),vt(this,"options",this.setOptions),vt(this,"parse",this.parseMarkdown(!0)),vt(this,"parseInline",this.parseMarkdown(!1)),vt(this,"Parser",xr),vt(this,"Renderer",vp),vt(this,"TextRenderer",Gb),vt(this,"Lexer",_r),vt(this,"Tokenizer",gp),vt(this,"Hooks",zu),this.use(...t)}walkTokens(t,e){var i,r;let n=[];for(let a of t)switch(n=n.concat(e.call(this,a)),a.type){case"table":{let o=a;for(let s of o.header)n=n.concat(this.walkTokens(s.tokens,e));for(let s of o.rows)for(let l of s)n=n.concat(this.walkTokens(l.tokens,e));break}case"list":{let o=a;n=n.concat(this.walkTokens(o.items,e));break}default:{let o=a;(r=(i=this.defaults.extensions)==null?void 0:i.childTokens)!=null&&r[o.type]?this.defaults.extensions.childTokens[o.type].forEach(s=>{let l=o[s].flat(1/0);n=n.concat(this.walkTokens(l,e))}):o.tokens&&(n=n.concat(this.walkTokens(o.tokens,e)))}}return n}use(...t){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(n=>{let i={...n};if(i.async=this.defaults.async||i.async||!1,n.extensions&&(n.extensions.forEach(r=>{if(!r.name)throw new Error("extension name required");if("renderer"in r){let a=e.renderers[r.name];a?e.renderers[r.name]=function(...o){let s=r.renderer.apply(this,o);return s===!1&&(s=a.apply(this,o)),s}:e.renderers[r.name]=r.renderer}if("tokenizer"in r){if(!r.level||r.level!=="block"&&r.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let a=e[r.level];a?a.unshift(r.tokenizer):e[r.level]=[r.tokenizer],r.start&&(r.level==="block"?e.startBlock?e.startBlock.push(r.start):e.startBlock=[r.start]:r.level==="inline"&&(e.startInline?e.startInline.push(r.start):e.startInline=[r.start]))}"childTokens"in r&&r.childTokens&&(e.childTokens[r.name]=r.childTokens)}),i.extensions=e),n.renderer){let r=this.defaults.renderer||new vp(this.defaults);for(let a in n.renderer){if(!(a in r))throw new Error(`renderer '${a}' does not exist`);if(["options","parser"].includes(a))continue;let o=a,s=n.renderer[o],l=r[o];r[o]=(...c)=>{let u=s.apply(r,c);return u===!1&&(u=l.apply(r,c)),u||""}}i.renderer=r}if(n.tokenizer){let r=this.defaults.tokenizer||new gp(this.defaults);for(let a in n.tokenizer){if(!(a in r))throw new Error(`tokenizer '${a}' does not exist`);if(["options","rules","lexer"].includes(a))continue;let o=a,s=n.tokenizer[o],l=r[o];r[o]=(...c)=>{let u=s.apply(r,c);return u===!1&&(u=l.apply(r,c)),u}}i.tokenizer=r}if(n.hooks){let r=this.defaults.hooks||new zu;for(let a in n.hooks){if(!(a in r))throw new Error(`hook '${a}' does not exist`);if(["options","block"].includes(a))continue;let o=a,s=n.hooks[o],l=r[o];zu.passThroughHooks.has(a)?r[o]=c=>{if(this.defaults.async&&zu.passThroughHooksRespectAsync.has(a))return(async()=>{let d=await s.call(r,c);return l.call(r,d)})();let u=s.call(r,c);return l.call(r,u)}:r[o]=(...c)=>{if(this.defaults.async)return(async()=>{let d=await s.apply(r,c);return d===!1&&(d=await l.apply(r,c)),d})();let u=s.apply(r,c);return u===!1&&(u=l.apply(r,c)),u}}i.hooks=r}if(n.walkTokens){let r=this.defaults.walkTokens,a=n.walkTokens;i.walkTokens=function(o){let s=[];return s.push(a.call(this,o)),r&&(s=s.concat(r.call(this,o))),s}}this.defaults={...this.defaults,...i}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return _r.lex(t,e??this.defaults)}parser(t,e){return xr.parse(t,e??this.defaults)}parseMarkdown(t){return(e,n)=>{let i={...n},r={...this.defaults,...i},a=this.onError(!!r.silent,!!r.async);if(this.defaults.async===!0&&i.async===!1)return a(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return a(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return a(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(r.hooks&&(r.hooks.options=r,r.hooks.block=t),r.async)return(async()=>{let o=r.hooks?await r.hooks.preprocess(e):e,s=await(r.hooks?await r.hooks.provideLexer():t?_r.lex:_r.lexInline)(o,r),l=r.hooks?await r.hooks.processAllTokens(s):s;r.walkTokens&&await Promise.all(this.walkTokens(l,r.walkTokens));let c=await(r.hooks?await r.hooks.provideParser():t?xr.parse:xr.parseInline)(l,r);return r.hooks?await r.hooks.postprocess(c):c})().catch(a);try{r.hooks&&(e=r.hooks.preprocess(e));let o=(r.hooks?r.hooks.provideLexer():t?_r.lex:_r.lexInline)(e,r);r.hooks&&(o=r.hooks.processAllTokens(o)),r.walkTokens&&this.walkTokens(o,r.walkTokens);let s=(r.hooks?r.hooks.provideParser():t?xr.parse:xr.parseInline)(o,r);return r.hooks&&(s=r.hooks.postprocess(s)),s}catch(o){return a(o)}}}onError(t,e){return n=>{if(n.message+=`
132
132
  Please report this to https://github.com/markedjs/marked.`,t){let i="<p>An error occurred:</p><pre>"+Ea(n.message+"",!0)+"</pre>";return e?Promise.resolve(i):i}if(e)return Promise.reject(n);throw n}}},Ss=new Jz;function at(t,e){return Ss.parse(t,e)}at.options=at.setOptions=function(t){return Ss.setOptions(t),at.defaults=Ss.defaults,i3(at.defaults),at},at.getDefaults=Ib,at.defaults=xs,at.use=function(...t){return Ss.use(...t),at.defaults=Ss.defaults,i3(at.defaults),at},at.walkTokens=function(t,e){return Ss.walkTokens(t,e)},at.parseInline=Ss.parseInline,at.Parser=xr,at.parser=xr.parse,at.Renderer=vp,at.TextRenderer=Gb,at.Lexer=_r,at.lexer=_r.lex,at.Tokenizer=gp,at.Hooks=zu,at.parse=at,at.options,at.setOptions,at.use,at.walkTokens,at.parseInline,xr.parse,_r.lex;const Qz="_base_1ne03_1",Zz={base:Qz},eF=["p","br","strong","em","u","a","ul","ol","li","h1","h2","h3","h4","h5","h6","code","pre","blockquote","hr"],tF=["href","title","target","rel"];at.setOptions({breaks:!0,gfm:!0});function nF(t){const{content:e,className:n,...i}=t,r=w.useMemo(()=>{if(!e)return"";const a=at.parse(e,{async:!1});return pz.sanitize(a,{ALLOWED_TAGS:[...eF],ALLOWED_ATTR:[...tF],ALLOW_DATA_ATTR:!1})},[e]);return r?f.jsx("div",{className:se(Zz.base,n),dangerouslySetInnerHTML:{__html:r},...i}):null}const iF="_controlBar_6shmw_1",rF="_popoverAnchor_6shmw_11",aF="_confirmationPopover_6shmw_15",oF="_confirmationPopoverAlignRight_6shmw_30",sF="_confirmationPopoverAlignCenter_6shmw_33",lF="_confirmationMessage_6shmw_53",cF="_confirmationActions_6shmw_60",uF="_confirmationButton_6shmw_65",dF="_confirmationButtonCancel_6shmw_83",hF="_confirmationButtonNeutral_6shmw_91",fF="_confirmationButtonDanger_6shmw_99",pF="_controlButton_6shmw_108",mF="_controlButtonIconOnly_6shmw_130",gF="_controlButtonDisabled_6shmw_135",vF="_controlButtonDanger_6shmw_162",bF="_controlButtonContent_6shmw_178",yF="_controlButtonIcon_6shmw_130",_F="_controlButtonLabel_6shmw_194",xF="_controlButtonChevron_6shmw_201",SF="_controlButtonNotificationDot_6shmw_210",kF="_deviceSplitButton_6shmw_222",TF="_deviceSplitButtonEnabled_6shmw_226",wF="_dualButtonContent_6shmw_307",CF="_dualButtonIcon_6shmw_317",EF="_dualButtonLabel_6shmw_326",RF="_screenShareButton_6shmw_340",AF="_screenShareButtonCompact_6shmw_351",Ge={controlBar:iF,popoverAnchor:rF,confirmationPopover:aF,confirmationPopoverAlignRight:oF,confirmationPopoverAlignCenter:sF,confirmationMessage:lF,confirmationActions:cF,confirmationButton:uF,confirmationButtonCancel:dF,confirmationButtonNeutral:hF,confirmationButtonDanger:fF,controlButton:pF,controlButtonIconOnly:mF,controlButtonDisabled:gF,controlButtonDanger:vF,controlButtonContent:bF,controlButtonIcon:yF,controlButtonLabel:_F,controlButtonChevron:xF,controlButtonNotificationDot:SF,deviceSplitButton:kF,deviceSplitButtonEnabled:TF,dualButtonContent:wF,dualButtonIcon:CF,dualButtonLabel:EF,screenShareButton:RF,screenShareButtonCompact:AF},NF="_inline_1gpyx_1",OF="_vertical_1gpyx_6",MF="_divider_1gpyx_10",DF="_dividerVertical_1gpyx_16",PF="_customDivider_1gpyx_21",Fu={inline:NF,vertical:OF,divider:MF,dividerVertical:DF,customDivider:PF},_3={none:"0px",xxs:"var(--space-xxs)",xs:"var(--space-xs)",sm:"var(--space-sm)",md:"var(--space-md)",lg:"var(--space-lg)",xl:"var(--space-xl)","2xl":"var(--space-2xl)","3xl":"var(--space-3xl)","4xl":"var(--space-4xl)","5xl":"var(--space-5xl)"};function Sr(t){if(t!==void 0){if(typeof t=="number")return`${t}px`;if(t in _3)return _3[t];if(typeof t=="string"&&t.trim().length>0)return t}}function LF(t,e){const{as:n,direction:i="horizontal",gap:r,align:a="center",justify:o,wrap:s=!1,divider:l,className:c,style:u,children:d,...h}=t,p=n??"div",b={display:"flex",flexDirection:i==="horizontal"?"row":"column",flexWrap:s?"wrap":"nowrap",alignItems:a,...o?{justifyContent:o}:{},...u};if(r!==void 0){const y=Sr(r);y&&(b.gap=y)}const m=hi.Children.toArray(d).filter(y=>y!=null&&typeof y!="boolean"),S=y=>!l||y===0?null:l===!0||l==="line"?f.jsx("span",{"aria-hidden":"true",className:se(Fu.divider,i==="vertical"&&Fu.dividerVertical)},`inline-divider-${y}`):f.jsx("span",{"aria-hidden":"true",className:Fu.customDivider,children:l},`inline-divider-${y}`),g=[];return m.forEach((y,x)=>{if(x>0){const v=S(x);v&&g.push(v)}g.push(y)}),f.jsx(p,{ref:e,className:se(Fu.inline,i==="vertical"&&Fu.vertical,c),style:b,...h,children:g})}const Wb=hi.forwardRef(LF);Wb.displayName="Inline";function IF(){const[t,e]=w.useState(()=>typeof window>"u"?!1:window.innerWidth<768);return w.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const n=window.matchMedia("(max-width: 767px)"),i=()=>{e(n.matches)};return i(),typeof n.addEventListener=="function"?(n.addEventListener("change",i),()=>n.removeEventListener("change",i)):(n.addListener(i),()=>n.removeListener(i))},[]),t}function Yb(t){const{icon:e,label:n,showChevron:i=!1,variant:r="default",disabled:a,className:o="",size:s="md",iconOnly:l=!1,showNotificationDot:c=!1,isOn:u,"aria-label":d,...h}=t,p=se(Ge.controlButton,a&&Ge.controlButtonDisabled,l&&Ge.controlButtonIconOnly,r==="danger"&&Ge.controlButtonDanger,o),b=Number.parseInt(Tb[s],10),m=r==="danger"?"outline":"primary",S=r==="danger"?"danger":"default",g=f.jsxs(f.Fragment,{children:[f.jsxs("span",{className:Ge.controlButtonContent,children:[e?f.jsx("span",{className:Ge.controlButtonIcon,children:hi.isValidElement(e)&&e.props.size===void 0?hi.cloneElement(e,{size:b}):e}):null,l?null:f.jsx("span",{className:Ge.controlButtonLabel,children:n}),l||!i?null:f.jsx("span",{className:Ge.controlButtonChevron,"aria-hidden":"true",children:f.jsx(wb,{size:16})})]}),c?f.jsx("span",{className:Ge.controlButtonNotificationDot,"aria-hidden":"true"}):null]});return typeof u=="boolean"?f.jsx(sp,{...h,type:"button",disabled:a,variant:m,color:S,isOn:u,"aria-label":d||n,className:p,"data-has-notification":c?"true":void 0,children:g}):f.jsx(_s,{...h,type:"button",disabled:a,variant:m,color:S,"aria-label":d||n,className:p,"data-has-notification":c?"true":void 0,children:g})}function jF(t){const{audioDevices:e,currentMicrophoneId:n,isMicrophoneEnabled:i,isScreenShareActive:r,widgetState:a,canPublishData:o,browserSupportsScreenSharing:s,screenShareButtonVariant:l="default",onMicDeviceSelect:c,onMicToggle:u,onChatToggle:d,onLeave:h,onScreenShareToggle:p,showChatNotification:b=!1,isLanguageSelectorEnabled:m=!0,languages:S=[],selectedLanguage:g=null,defaultLanguageCode:y=null,isMultilingual:x=!1,onLanguageChange:v,isChatOpen:k=a==="chat"}=t,T=S.length,C=!m||T===0,R=IF(),A=R?"xs":"sm",N=R,[O,B]=w.useState(!1),[W,L]=w.useState(!1),K=w.useRef(null),P=w.useRef(null);w.useEffect(()=>{const U=me=>{const Rt=me.composedPath();O&&K.current&&!Rt.includes(K.current)&&B(!1),W&&P.current&&!Rt.includes(P.current)&&L(!1)},fe=me=>{me.key==="Escape"&&(O&&B(!1),W&&L(!1))};if(O||W)return document.addEventListener("mousedown",U),document.addEventListener("keydown",fe),()=>{document.removeEventListener("mousedown",U),document.removeEventListener("keydown",fe)}},[O,W]),w.useEffect(()=>{r||B(!1)},[r]);const V=w.useMemo(()=>e.map(U=>({label:U.label||`Microphone ${U.deviceId.slice(0,8)}`,value:U.deviceId})),[e]),X=w.useMemo(()=>n?V.find(U=>U.value===n)??null:null,[n,V]),te=w.useCallback(U=>{U.value,c(U.value)},[c]),$={microphone:!0,screenShare:s,chat:o},z=w.useCallback(()=>{if(r){B(!0);return}p()},[r,p]),Z=w.useCallback(()=>{B(!1),p()},[p]),Q=w.useCallback(()=>{B(!1)},[]),ce=w.useCallback(()=>{L(!0)},[]),j=w.useCallback(()=>{L(!1),h()},[h]),ge=w.useCallback(()=>{L(!1)},[]);return f.jsx("div",{className:Ge.controlBar,"data-testid":"control-bar","data-controls":JSON.stringify($),"data-language-option-count":T>0?String(T):void 0,"data-default-language-code":y??void 0,children:f.jsxs(Wb,{gap:A,align:"center",justify:"center",wrap:N,children:[f.jsx(k7,{onClick:u,buttonAriaLabel:i?"Mute microphone":"Unmute microphone",options:V,value:X,onChange:te,variant:"primary",menuPlacement:"top",menuDisabled:V.length===0,menuAriaLabel:"Select microphone device",listboxAriaLabel:"Microphone devices",ariaPressed:i,className:se(Ge.deviceSplitButton,i&&Ge.deviceSplitButtonEnabled),children:f.jsxs("span",{className:Ge.dualButtonContent,children:[f.jsx("span",{className:Ge.dualButtonIcon,children:i?f.jsx(NE,{}):f.jsx(OE,{})}),f.jsx("span",{className:Ge.dualButtonLabel,children:"Microphone"})]})}),o?f.jsx(Yb,{icon:f.jsx(CE,{}),label:"Chat",onClick:d,isOn:k,"aria-label":"Toggle chat",showNotificationDot:b}):null,s?f.jsxs("div",{ref:K,className:Ge.popoverAnchor,children:[f.jsx(Yb,{icon:f.jsx(ME,{}),label:r?"Share screen off":"Share screen",className:l==="compact"?Ge.screenShareButtonCompact:Ge.screenShareButton,iconOnly:l==="compact",onClick:z,isOn:r,"aria-label":r?"Stop screen sharing":"Start screen sharing"}),O?f.jsxs("div",{className:se(Ge.confirmationPopover,Ge.confirmationPopoverAlignCenter),role:"dialog","aria-label":"Stop screen sharing confirmation","data-testid":"confirm-stop-share",children:[f.jsx("p",{className:Ge.confirmationMessage,children:"Stop screen sharing?"}),f.jsxs("div",{className:Ge.confirmationActions,children:[f.jsx("button",{type:"button",className:se(Ge.confirmationButton,Ge.confirmationButtonCancel),onClick:Q,children:"Cancel"}),f.jsx("button",{type:"button",className:se(Ge.confirmationButton,Ge.confirmationButtonNeutral),onClick:Z,children:"Stop"})]})]}):null]}):null,f.jsx(zE,{languages:S,value:g,onChange:v,defaultLanguageCode:y,variant:"control-bar",disabled:C}),f.jsxs("div",{ref:P,className:Ge.popoverAnchor,children:[f.jsx(Yb,{icon:f.jsx(AE,{}),label:"Leave",variant:"danger",onClick:ce,"aria-label":"Leave meeting"}),W?f.jsxs("div",{className:se(Ge.confirmationPopover,Ge.confirmationPopoverAlignRight),role:"dialog","aria-label":"Leave meeting confirmation","data-testid":"confirm-leave",children:[f.jsx("p",{className:Ge.confirmationMessage,children:"Would you like to end the call?"}),f.jsxs("div",{className:Ge.confirmationActions,children:[f.jsx("button",{type:"button",className:se(Ge.confirmationButton,Ge.confirmationButtonCancel),onClick:ge,children:"Cancel"}),f.jsx("button",{type:"button",className:se(Ge.confirmationButton,Ge.confirmationButtonDanger),onClick:j,children:"Leave"})]})]}):null]})]})})}function BF(t){return f.jsx(jF,{...t})}const UF="_controlBar_1n8jn_1",zF="_controlButton_1n8jn_12",FF="_controlButtonDisabled_1n8jn_35",qF="_controlButtonDanger_1n8jn_62",HF="_controlButtonIconOnly_1n8jn_78",VF="_screenShareButton_1n8jn_83",GF="_controlButtonContent_1n8jn_88",WF="_controlButtonIcon_1n8jn_78",YF="_controlButtonLabel_1n8jn_103",KF="_controlButtonNotificationDot_1n8jn_108",XF="_popoverAnchor_1n8jn_198",$F="_confirmationPopover_1n8jn_202",JF="_confirmationMessage_1n8jn_216",QF="_confirmationActions_1n8jn_223",ZF="_confirmationButton_1n8jn_228",eq="_confirmationButtonCancel_1n8jn_246",tq="_confirmationButtonDanger_1n8jn_254",vn={controlBar:UF,controlButton:zF,controlButtonDisabled:FF,controlButtonDanger:qF,controlButtonIconOnly:HF,screenShareButton:VF,controlButtonContent:GF,controlButtonIcon:WF,controlButtonLabel:YF,controlButtonNotificationDot:KF,popoverAnchor:XF,confirmationPopover:$F,confirmationMessage:JF,confirmationActions:QF,confirmationButton:ZF,confirmationButtonCancel:eq,confirmationButtonDanger:tq};function yp(t){const{icon:e,label:n,variant:i="default",disabled:r,className:a="",iconOnly:o=!1,showNotificationDot:s=!1,isOn:l,"aria-label":c,...u}=t,d=se(vn.controlButton,r&&vn.controlButtonDisabled,o&&vn.controlButtonIconOnly,i==="danger"&&vn.controlButtonDanger,a),h=i==="danger"?"outline":"primary",p=i==="danger"?"danger":"default",b=f.jsxs(f.Fragment,{children:[f.jsxs("span",{className:vn.controlButtonContent,children:[e?f.jsx("span",{className:vn.controlButtonIcon,children:hi.isValidElement(e)&&e.props.size===void 0?hi.cloneElement(e,{size:20}):e}):null,o?null:f.jsx("span",{className:vn.controlButtonLabel,children:n})]}),s?f.jsx("span",{className:vn.controlButtonNotificationDot,"aria-hidden":"true"}):null]});return typeof l=="boolean"?f.jsx(sp,{...u,type:"button",disabled:r,variant:h,color:p,size:"xs",isOn:l,"aria-label":c||n,className:d,"data-has-notification":s?"true":void 0,children:b}):f.jsx(_s,{...u,type:"button",disabled:r,variant:h,color:p,size:"xs","aria-label":c||n,className:d,"data-has-notification":s?"true":void 0,children:b})}function nq(t){const{isMicrophoneEnabled:e,isChatOpen:n,isScreenShareActive:i,showChatNotification:r=!1,onMicToggle:a,onChatToggle:o,onScreenShareToggle:s,onLeave:l,languages:c=[],selectedLanguage:u=null,defaultLanguageCode:d=null,isMultilingual:h=!1,onLanguageChange:p,isLanguageSelectorEnabled:b=!0,className:m,testId:S,...g}=t,y=!b||c.length===0,[x,v]=w.useState(!1),k=w.useRef(null);w.useEffect(()=>{const O=W=>{const L=W.composedPath();x&&k.current&&!L.includes(k.current)&&v(!1)},B=W=>{W.key==="Escape"&&x&&v(!1)};if(x)return document.addEventListener("mousedown",O),document.addEventListener("keydown",B),()=>{document.removeEventListener("mousedown",O),document.removeEventListener("keydown",B)}},[x]);const T=w.useCallback(()=>{a()},[a]),C=w.useCallback(()=>{s()},[s]),R=w.useCallback(()=>{v(!0)},[]),A=w.useCallback(()=>{v(!1),l()},[l]),N=w.useCallback(()=>{v(!1)},[]);return f.jsx("div",{...g,className:se(vn.controlBar,m),"data-testid":S,children:f.jsxs(Wb,{gap:"xs",align:"center",justify:"center",wrap:!1,children:[f.jsx(yp,{icon:e?f.jsx(NE,{size:18}):f.jsx(OE,{size:18}),label:"Microphone",iconOnly:!0,isOn:e,onClick:T,"aria-label":e?"Mute microphone":"Unmute microphone"}),f.jsx(yp,{icon:f.jsx(CE,{}),label:"Chat",iconOnly:!0,isOn:n,onClick:o,"aria-label":"Toggle chat",showNotificationDot:r}),f.jsx(yp,{icon:f.jsx(ME,{}),label:"Screen share",iconOnly:!0,className:vn.screenShareButton,isOn:i,onClick:C,"aria-label":i?"Stop screen sharing":"Start screen sharing"}),f.jsx(zE,{languages:c,value:u,onChange:p,defaultLanguageCode:d,variant:"pip",disabled:y}),f.jsxs("div",{ref:k,className:vn.popoverAnchor,children:[f.jsx(yp,{icon:f.jsx(AE,{size:16}),label:"Hang up",iconOnly:!0,variant:"danger",onClick:R,"aria-label":"Hang up"}),x?f.jsxs("div",{className:vn.confirmationPopover,role:"dialog","aria-label":"Hang up confirmation","data-testid":"confirm-leave",children:[f.jsx("p",{className:vn.confirmationMessage,children:"Would you like to end the call?"}),f.jsxs("div",{className:vn.confirmationActions,children:[f.jsx("button",{type:"button",className:se(vn.confirmationButton,vn.confirmationButtonCancel),onClick:N,children:"Cancel"}),f.jsx("button",{type:"button",className:se(vn.confirmationButton,vn.confirmationButtonDanger),onClick:A,children:"Leave"})]})]}):null]})]})})}function iq(t){return f.jsx(nq,{...t})}const rq="_container_zht0b_1",aq="_containerGradient_zht0b_14",oq="_containerFlat_zht0b_24",sq="_halo_zht0b_28",lq="_outerRing_zht0b_38",cq="_circle_zht0b_42",uq="_image_zht0b_72",dq="_captionContainer_zht0b_88",hq="_captionRegion_zht0b_99",Ra={container:rq,containerGradient:aq,containerFlat:oq,halo:sq,outerRing:lq,circle:cq,image:uq,captionContainer:dq,captionRegion:hq},fq="_statusText_1dkze_6",pq={statusText:fq},mq={idle:null,thinking:"Thinking...",searching:"Searching..."};function gq(t){const{status:e,size:n="md"}=t,i=e?mq[e]:null,r=i!==null;return f.jsx("div",{className:pq.statusText,"data-visible":r,"data-size":n,"aria-live":"polite",children:i})}const vq="https://obi-static.s3.ap-southeast-2.amazonaws.com/images/obi-avatar.png",bq={sm:{haloSize:"4.5rem",maxBorderWidth:5,outerRingScalePower:.55,glowSize:"20px"},md:{haloSize:"8rem",maxBorderWidth:8,outerRingScalePower:.7,glowSize:"35px"},lg:{haloSize:"10rem",maxBorderWidth:10,outerRingScalePower:.75,glowSize:"42px"}};function x3(t){const{audioPower:e,size:n="md",background:i="gradient",imageSrc:r=vq,accentColor:a,ariaLabel:o="Avatar placeholder",status:s,captionsText:l,className:c,style:u,...d}=t,h=bq[n],p=Math.min(1,Math.max(0,e)),b=p>.01,m=b?Math.min(1,p/.5):0,S=b?Math.max(1,m*h.maxBorderWidth):0,g=1.02,y=b?g+p*h.outerRingScalePower:g,x=b?.2+p*.35:0,v={...u??{},...a?{"--avatar-fallback-accent":a}:{}},k={"--avatar-fallback-halo-size":h.haloSize,"--avatar-fallback-border-width":`${S}px`,"--avatar-fallback-secondary-border-scale":y.toString(),"--avatar-fallback-secondary-border-opacity":x.toString(),"--avatar-fallback-glow-size":h.glowSize},T=l!=null&&l!=="";return f.jsxs("div",{...d,className:se(Ra.container,i==="gradient"?Ra.containerGradient:Ra.containerFlat,c),style:v,"data-testid":"avatar-fallback","aria-label":o,role:"img",children:[f.jsxs("div",{className:Ra.halo,style:k,children:[f.jsx("div",{className:Ra.outerRing,"aria-hidden":"true"}),f.jsx("div",{className:Ra.circle,children:f.jsx("img",{className:Ra.image,src:r,alt:"","aria-hidden":"true"})}),f.jsx(gq,{status:s,size:n})]}),T&&f.jsx("div",{className:Ra.captionContainer,children:f.jsx("div",{className:Ra.captionRegion,"data-size":n,role:"status","aria-live":"polite","aria-atomic":"true",children:l})})]})}const yq="_container_1k3qg_11",_q="_screenshot_1k3qg_20",xq="_flash_1k3qg_30",Kb={container:yq,screenshot:_q,flash:xq};function Sq(t){const{isActive:e,imageUrl:n,onComplete:i,duration:r=2e3}=t,[a,o]=w.useState(!1),s=w.useRef(null),l=w.useRef(i);return w.useEffect(()=>{l.current=i},[i]),w.useEffect(()=>{if(!e){o(!1),s.current&&(clearTimeout(s.current),s.current=null);return}if(!s.current)return o(!0),s.current=setTimeout(()=>{var c;o(!1),s.current=null,(c=l.current)==null||c.call(l)},r),()=>{s.current&&(clearTimeout(s.current),s.current=null)}},[e,r]),a?f.jsxs("div",{className:Kb.container,"aria-live":"polite","aria-label":"Screenshot captured",children:[n&&f.jsx("img",{src:n,alt:"Captured screenshot",className:Kb.screenshot}),f.jsx("div",{className:Kb.flash})]}):null}const kq="_container_13ukq_1",Tq="_dragging_13ukq_5",wq="_placeholder_13ukq_9",Cq="_handleButton_13ukq_15",Eq="_customHandle_13ukq_105",ql={container:kq,dragging:Tq,placeholder:wq,handleButton:Cq,"handle-top":"_handle-top_13ukq_65","handle-bottom":"_handle-bottom_13ukq_75","handle-left":"_handle-left_13ukq_85","handle-right":"_handle-right_13ukq_95",customHandle:Eq};function Rq(t){const{disabled:e,lingerMs:n,isDragging:i}=t,[r,a]=w.useState(!1),o=w.useRef(null),s=w.useCallback(()=>{o.current!==null&&(window.clearTimeout(o.current),o.current=null)},[]),l=w.useCallback(()=>{e||(s(),a(!0))},[s,e]),c=w.useCallback(()=>{e||i||(s(),o.current=window.setTimeout(()=>{a(!1),o.current=null},n))},[s,e,i,n]);return w.useEffect(()=>{i&&l()},[i,l]),w.useEffect(()=>s,[s]),{isHandleVisible:r,showHandle:l,scheduleHideHandle:c}}function Aq(t){const{initialPosition:e,preserveSpace:n,onPositionChange:i}=t,r=w.useRef(null),[a,o]=w.useState(!!e),[s,l]=w.useState(!1),[c,u]=w.useState(null),[d,h]=w.useState(()=>e??{x:0,y:0}),p=w.useRef(d);s||(p.current=d);const b=w.useRef(null),m=w.useRef(!1),S=w.useRef(!1);w.useEffect(()=>{e&&(S.current||(o(!0),h(e),p.current=e))},[e==null?void 0:e.x,e==null?void 0:e.y]),w.useEffect(()=>{if(e||m.current)return;const v=r.current;if(!v)return;const k=v.getBoundingClientRect(),T={x:k.left,y:k.top};m.current=!0,o(!0),h(T),p.current=T,u(n?{width:k.width,height:k.height}:null)},[e,n]);const g=w.useCallback(v=>{const k=b.current;if(!(!k||v.pointerId!==k.pointerId)){b.current=null,S.current=!0,h(p.current),l(!1);try{v.currentTarget.releasePointerCapture(k.pointerId)}catch{}}},[]),y=w.useCallback(v=>{v.button===0&&(v.preventDefault(),v.currentTarget.setPointerCapture(v.pointerId),b.current={pointerId:v.pointerId,startClientX:v.clientX,startClientY:v.clientY,startX:p.current.x,startY:p.current.y},l(!0))},[]),x=w.useCallback(v=>{const k=b.current;if(!k||v.pointerId!==k.pointerId)return;const T={x:k.startX+(v.clientX-k.startClientX),y:k.startY+(v.clientY-k.startClientY)};p.current=T,r.current&&(r.current.style.transform=`translate3d(${T.x}px, ${T.y}px, 0)`),i==null||i(T)},[i]);return{containerRef:r,isFixed:a,isDragging:s,position:d,placeholderSize:c,onPointerDown:y,onPointerMove:x,endDrag:g}}function Nq(t){const{children:e,className:n,handle:i="top",initialPosition:r,disabled:a=!1,preserveSpace:o=!0,zIndex:s=1e3,onPositionChange:l,handleAriaLabel:c="Drag",handleLingerMs:u=350,style:d,...h}=t,{containerRef:p,isFixed:b,isDragging:m,position:S,placeholderSize:g,onPointerDown:y,onPointerMove:x,endDrag:v}=Aq({initialPosition:r,preserveSpace:o,onPositionChange:l}),{isHandleVisible:k,showHandle:T,scheduleHideHandle:C}=Rq({disabled:a,lingerMs:u,isDragging:m}),R=typeof e=="function",A=w.useMemo(()=>{const O=B=>f.jsx("div",{className:se(ql.customHandle,B.className),onPointerDown:y,onPointerMove:x,onPointerUp:v,onPointerCancel:v,children:B.children});return O.displayName="Draggable.Handle",O},[y,x,v]),N={...d,position:b?"fixed":"relative",top:b?0:d==null?void 0:d.top,left:b?0:d==null?void 0:d.left,transform:b?`translate3d(${S.x}px, ${S.y}px, 0)`:d==null?void 0:d.transform,zIndex:b?s:d==null?void 0:d.zIndex};return f.jsxs(f.Fragment,{children:[o&&b&&g?f.jsx("div",{className:ql.placeholder,style:{width:g.width,height:g.height}}):null,f.jsxs("div",{ref:p,className:se(ql.container,m?ql.dragging:null,n),"data-handle-visible":R?void 0:a?"false":k||m?"true":"false",style:N,onMouseEnter:R?void 0:T,onMouseLeave:R?void 0:C,...h,children:[!R&&!a?f.jsx("button",{type:"button",className:se(ql.handleButton,ql[`handle-${i}`]),"aria-label":c,onMouseEnter:T,onMouseLeave:C,onPointerDown:O=>{T(),y(O)},onPointerMove:x,onPointerUp:v,onPointerCancel:v}):null,R?e({Handle:A}):e]})]})}const Oq="_container_gzwdo_1",Mq="_captionRegion_gzwdo_14",Dq="_status_gzwdo_22",Pq="_captionText_gzwdo_29",_p={container:Oq,captionRegion:Mq,status:Dq,captionText:Pq},Lq={idle:null,thinking:"Thinking...",searching:"Searching..."};function Iq(t){const{text:e,status:n,className:i,...r}=t,a=n?Lq[n]:null;return f.jsx("div",{...r,className:se(_p.container,i),"data-testid":"pip-captions-panel",children:f.jsxs("div",{className:_p.captionRegion,role:"status","aria-live":"polite","aria-atomic":"true",children:[a?f.jsx("div",{className:_p.status,children:a}):null,f.jsx("div",{className:_p.captionText,children:e})]})})}const jq="_panel_1laxg_1",Bq="_row_1laxg_22",Uq="_stepContent_1laxg_29",zq="_stepLabel_1laxg_37",Fq="_currentStep_1laxg_44",qq="_nextStep_1laxg_51",Hq="_skipButtonContainer_1laxg_65",Vq="_circleButton_1laxg_73",Gq="_arrowPlaceholder_1laxg_100",Wq="_skipButton_1laxg_65",nr={panel:jq,row:Bq,stepContent:Uq,stepLabel:zq,currentStep:Fq,nextStep:qq,skipButtonContainer:Hq,circleButton:Vq,arrowPlaceholder:Gq,skipButton:Wq},Yq="_truncatedText_1u580_1",Kq={truncatedText:Yq};function S3(t){const{children:e,maxLines:n=2,className:i,"data-testid":r}=t;return f.jsx("div",{className:`${Kq.truncatedText} ${i||""}`,style:{WebkitLineClamp:n},"data-testid":r,children:e})}function Xq(t,e,n){var c;const i=t.length,r=n&&i>0&&((c=t[i-1])==null?void 0:c.title)==="Conclusion",a=r?t.slice(0,-1):t.slice(),o=a.length;if(o===0)return{visibleSteps:a,currentIndex:null};const s=typeof e=="number"&&Number.isFinite(e)?e:1;if(r&&s===i)return{visibleSteps:a,currentIndex:null};const l=Math.min(Math.max(s,1),o)-1;return{visibleSteps:a,currentIndex:l}}function Xb(t,e){return e<=0||typeof t!="number"||!Number.isFinite(t)?0:Math.min(Math.max(Math.trunc(t),1),e)-1}function $q(t){var C;const{steps:e,currentStep:n,onStepClick:i,hideTrailingConclusionStep:r=!0,className:a,testId:o,...s}=t,{visibleSteps:l,currentIndex:c}=w.useMemo(()=>Xq(e,n,r),[n,r,e]),[u,d]=w.useState(()=>Xb(n,l.length)),h=w.useRef(!1);w.useEffect(()=>{if(!h.current)d(Xb(n,l.length));else{const R=Xb(n,l.length);u===R&&(h.current=!1)}},[n,l,u]);const p=l.length,b=l[u],m=u>0,S=u<p-1,g=S?(C=l[u+1])==null?void 0:C.title:void 0,y=p===0?0:u+1,x=c!==null&&b&&u!==c,v=()=>{m&&(h.current=!0,d(R=>Math.max(R-1,0)))},k=()=>{S&&(h.current=!0,d(R=>Math.min(R+1,p-1)))},T=()=>{!x||!b||!i||(h.current=!1,i(u,b))};return f.jsxs("div",{...s,className:se(nr.panel,a),"data-testid":o,role:"group","aria-label":"Course progress",children:[f.jsxs("div",{className:nr.row,children:[m?f.jsx("button",{type:"button",className:nr.circleButton,"aria-label":"Previous step",onClick:v,children:f.jsx(EE,{size:14})}):f.jsx("span",{className:nr.arrowPlaceholder,"aria-hidden":"true"}),f.jsxs("div",{className:nr.stepContent,children:[f.jsxs(xi,{className:nr.stepLabel,"aria-live":"polite",children:["Step ",y,"/",p]}),f.jsx(S3,{maxLines:2,children:f.jsx(xi,{className:nr.currentStep,"data-testid":"pip-outline-current-step",children:(b==null?void 0:b.title)??"No steps available"})}),g?f.jsx(S3,{maxLines:2,children:f.jsxs(xi,{variant:"muted",className:nr.nextStep,children:["Next: ",g]})}):null]}),S?f.jsx("button",{type:"button",className:nr.circleButton,"aria-label":"Next step",onClick:k,children:f.jsx(VB,{size:14})}):f.jsx("span",{className:nr.arrowPlaceholder,"aria-hidden":"true"})]}),x?f.jsx("div",{className:nr.skipButtonContainer,children:f.jsx("button",{type:"button",className:nr.skipButton,"aria-label":"Skip to this step",onClick:T,children:f.jsx(XB,{size:14})})}):null]})}const Jq="_window_zm5au_1",Qq="_exitButton_zm5au_14",Zq="_content_zm5au_47",eH="_contentTopOverlay_zm5au_58",tH="_dragHandle_zm5au_68",nH="_contentBottomOverlay_zm5au_78",iH="_controls_zm5au_87",rH="_messagesPanelWrapper_zm5au_95",Eo={window:Jq,exitButton:Qq,content:Zq,contentTopOverlay:eH,dragHandle:tH,contentBottomOverlay:nH,controls:iH,messagesPanelWrapper:rH};function aH(t){return t==null?!1:typeof t=="string"?t.trim().length>0:!0}function oH(t){const{onExit:e,controlBarProps:n,isCourseOutlineSelected:i,onCourseOutlineToggle:r,isCaptionsEnabled:a=!1,onCaptionsToggle:o,courseOutline:s,messagesPanel:l,avatarFallbackProps:c,contentTopOverlaySlot:u,screenshotUrl:d,cameraShotTrigger:h,className:p,testId:b,...m}=t,S=i,g=n.isChatOpen&&!S&&l,y=c==null?void 0:c.captionsText,x=a&&aH(y),[v,k]=w.useState(!1),T=w.useRef(h),C=w.useCallback(()=>{k(!1)},[]);w.useEffect(()=>{h&&h>0&&h!==T.current&&k(!0),T.current=h},[h]);const R=w.useCallback(()=>f.jsx(x3,{audioPower:(c==null?void 0:c.audioPower)??0,size:"sm",background:"flat",imageSrc:c==null?void 0:c.imageSrc,ariaLabel:c==null?void 0:c.ariaLabel,status:c==null?void 0:c.status}),[c]),A=S?s?f.jsx($q,{steps:s.steps,currentStep:s.currentStep,onStepClick:s.onStepClick,hideTrailingConclusionStep:s.hideTrailingConclusionStep}):R():g?f.jsx("div",{className:Eo.messagesPanelWrapper,children:l}):x?f.jsx(Iq,{text:y}):R();return f.jsxs("div",{...m,className:se(Eo.window,p),"data-testid":b,role:"group","aria-label":"Picture-in-Picture",children:[f.jsxs("div",{className:Eo.content,children:[f.jsx("div",{className:Eo.contentTopOverlay,children:u}),f.jsx("button",{type:"button",className:Eo.exitButton,onClick:e,"aria-label":"Exit PiP",children:f.jsx(WB,{size:14})}),A,!g&&f.jsxs("div",{className:Eo.contentBottomOverlay,children:[f.jsx(sp,{isOn:i,onClick:r,variant:"primary",size:"xs","aria-label":"Toggle course outline",children:f.jsx($B,{size:18})}),f.jsx(sp,{isOn:a,onClick:o,variant:"primary",size:"xs","aria-label":"Toggle captions",children:f.jsx(HB,{size:18})})]}),f.jsx(Sq,{isActive:v,imageUrl:d??null,onComplete:C})]}),f.jsx("div",{className:Eo.controls,children:f.jsx(iq,{...n})})]})}function sH(t){const{initialPosition:e,onPositionChange:n,zIndex:i=1e3,...r}=t;return f.jsx(Nq,{initialPosition:e,onPositionChange:n,zIndex:i,preserveSpace:!1,children:({Handle:a})=>f.jsx(oH,{...r,contentTopOverlaySlot:f.jsx(a,{className:Eo.dragHandle})})})}const lH="_root_ygi3o_1",cH="_overlay_ygi3o_7",uH="_caption_ygi3o_17",$b={root:lH,overlay:cH,caption:uH};function dH(t){return t==null?!1:typeof t=="string"?t.trim().length>0:!0}function hH(t){const{children:e,className:n,text:i}=t,r=dH(i);return f.jsxs("div",{className:se($b.root,n),children:[e,r?f.jsx("div",{className:$b.overlay,role:"status","aria-live":"polite","aria-atomic":"true",children:f.jsx("div",{className:$b.caption,children:i})}):null]})}const fH="_box_dc9yv_1",pH={box:fH},k3={none:"0px",panel:"var(--radius-panel)",card:"var(--radius-card)"},T3={surface:"var(--color-surface)",surfaceMuted:"var(--color-surface-muted)",surfaceAlt:"var(--color-surface-alt)",primarySoft:"var(--color-primary-soft)",primarySofter:"var(--color-primary-softer)",dangerSurface:"var(--color-danger-surface)"};function mH(t){if(t!==void 0){if(typeof t=="number")return`${t}px`;if(t in k3)return k3[t];if(typeof t=="string"&&t.trim().length>0)return t}}function gH(t){if(t!==void 0){if(t in T3)return T3[t];if(typeof t=="string"&&t.trim().length>0)return t}}function vH(t,e){const{as:n,className:i,padding:r,paddingX:a,paddingY:o,paddingTop:s,paddingBottom:l,paddingLeft:c,paddingRight:u,paddingSm:d,paddingMd:h,paddingLg:p,paddingXl:b,margin:m,marginX:S,marginY:g,marginTop:y,marginBottom:x,marginLeft:v,marginRight:k,radius:T,radiusTop:C,radiusBottom:R,radiusLeft:A,radiusRight:N,radiusTopLeft:O,radiusTopRight:B,radiusBottomLeft:W,radiusBottomRight:L,background:K,gap:P,style:V,...X}=t,te=n??"div",$={...V},z=$,Z={},Q=(U,fe)=>{if(fe===void 0)return;const me=Sr(fe);me&&($[U]=me)},ce=(U,fe)=>{if(fe===void 0)return;const me=Sr(fe);me&&($[U]=me)},j=(U,fe)=>{if(fe===void 0)return;const me=mH(fe);me&&($[U]=me)},ge={sm:d,md:h,lg:p,xl:b};if(r!==void 0){const U=Sr(r);U&&(z["--box-padding"]=U)}for(const[U,fe]of Object.entries(ge)){if(fe===void 0)continue;const me=Sr(fe);me&&(z[`--box-padding-${U}`]=me,Z[`data-padding-${U}`]="")}if(a!==void 0){const U=Sr(a);U&&($.paddingLeft=U,$.paddingRight=U)}if(o!==void 0){const U=Sr(o);U&&($.paddingTop=U,$.paddingBottom=U)}if(Q("paddingTop",s),Q("paddingBottom",l),Q("paddingLeft",c),Q("paddingRight",u),m!==void 0){const U=Sr(m);U&&($.margin=U)}if(S!==void 0){const U=Sr(S);U&&($.marginLeft=U,$.marginRight=U)}if(g!==void 0){const U=Sr(g);U&&($.marginTop=U,$.marginBottom=U)}if(ce("marginTop",y),ce("marginBottom",x),ce("marginLeft",v),ce("marginRight",k),P!==void 0){const U=Sr(P);U&&($.gap=U)}if(j("borderRadius",T),C!==void 0&&(j("borderTopLeftRadius",C),j("borderTopRightRadius",C)),R!==void 0&&(j("borderBottomLeftRadius",R),j("borderBottomRightRadius",R)),A!==void 0&&(j("borderTopLeftRadius",A),j("borderBottomLeftRadius",A)),N!==void 0&&(j("borderTopRightRadius",N),j("borderBottomRightRadius",N)),j("borderTopLeftRadius",O),j("borderTopRightRadius",B),j("borderBottomLeftRadius",W),j("borderBottomRightRadius",L),K!==void 0){const U=gH(K);U&&($.background=U)}return f.jsx(te,{ref:e,className:se(pH.box,i),style:$,...Z,...X})}const xp=hi.forwardRef(vH);xp.displayName="Box";const bH="_panel_eawk4_1",yH="_selected_eawk4_10",w3={panel:bH,selected:yH};function qu(t){const{children:e,className:n,selected:i,...r}=t;return f.jsx("div",{className:se(w3.panel,i?w3.selected:null,n),...r,children:e})}const _H="_root_yccm8_1",xH="_header_yccm8_8",SH="_icon_yccm8_15",kH="_text_yccm8_26",TH="_heading_yccm8_33",wH="_description_yccm8_41",CH="_body_yccm8_47",EH="_footer_yccm8_54",Ro={root:_H,header:xH,icon:SH,text:kH,heading:TH,description:wH,body:CH,footer:EH};function C3(t){const{className:e,...n}=t;return f.jsx("div",{className:se(Ro.icon,e),...n})}function E3(t){const{className:e,...n}=t;return f.jsx("h3",{className:se(Ro.heading,e),...n})}function R3(t){const{className:e,...n}=t;return f.jsx("p",{className:se(Ro.description,e),...n})}function A3(t){const{className:e,...n}=t;return f.jsx("div",{className:se(Ro.footer,e),...n})}function RH(t){const e=w.Children.toArray(t),n=[];let i,r,a,o;for(const s of e){if(w.isValidElement(s)&&s.type===C3&&i===void 0){i=s;continue}if(w.isValidElement(s)&&s.type===E3&&r===void 0){r=s;continue}if(w.isValidElement(s)&&s.type===R3&&a===void 0){a=s;continue}if(w.isValidElement(s)&&s.type===A3&&o===void 0){o=s;continue}n.push(s)}return{icon:i,heading:r,description:a,footer:o,body:n}}function AH(t){const{children:e,className:n,...i}=t,r=RH(e),a=r.icon||r.heading||r.description;return f.jsxs(qu,{className:se(Ro.root,n),...i,children:[a?f.jsxs("div",{className:Ro.header,children:[r.icon,r.heading||r.description?f.jsxs("div",{className:Ro.text,children:[r.heading,r.description]}):null]}):null,r.body.length?f.jsx("div",{className:Ro.body,children:r.body}):null,r.footer]})}const Jb=Object.assign(AH,{Icon:C3,Heading:E3,Description:R3,Footer:A3}),NH="_panel_f4a69_1",OH="_header_f4a69_10",MH="_title_f4a69_19",DH="_scrollArea_f4a69_29",PH="_scrollable_f4a69_34",LH="_list_f4a69_39",IH="_courseButton_f4a69_45",jH="_courseCard_f4a69_61",BH="_loading_f4a69_65",UH="_spinnerWrapper_f4a69_69",zH="_spinner_f4a69_69",FH="_contentHidden_f4a69_92",qH="_courseHeading_f4a69_101",HH="_courseDescription_f4a69_107",VH="_empty_f4a69_116",Ln={panel:NH,header:OH,title:MH,scrollArea:DH,scrollable:PH,list:LH,courseButton:IH,courseCard:jH,loading:BH,spinnerWrapper:UH,spinner:zH,contentHidden:FH,courseHeading:qH,courseDescription:HH,empty:VH};function GH(t){const{selectionMode:e,selectedCourseIds:n,defaultSelectedCourseIds:i,onSelectedCourseIdsChange:r}=t,a=n!==void 0,[o,s]=w.useState(()=>i??[]),l=a?n:o,c=w.useCallback(d=>{a||s(d),r==null||r(d)},[a,r]),u=w.useCallback(d=>{const h=l.includes(d);if(e==="single"){c(h?[]:[d]);return}if(h){c(l.filter(p=>p!==d));return}c([...l,d])},[l,e,c]);return{selectedCourseIds:l,toggleCourseId:u}}function WH(t){const{title:e="Courses",ariaLabel:n,className:i,courses:r,selectionMode:a="multiple",selectedCourseIds:o,onCourseToggle:s,loadingCourseId:l,emptyMessage:c="No courses available",testId:u,...d}=t;return f.jsxs(qu,{...d,className:se(Ln.panel,i),role:"region","aria-label":n??e,"data-testid":u,children:[f.jsx("div",{className:Ln.header,children:f.jsx(xi,{as:"h2",className:Ln.title,children:e})}),f.jsx("div",{className:Ln.scrollArea,children:f.jsx(zl,{className:Ln.scrollable,children:r.length===0?f.jsx(xi,{variant:"muted",className:Ln.empty,"data-testid":"course-panel-empty",children:c}):f.jsx("div",{className:Ln.list,"data-testid":"course-panel-list",children:r.map(h=>{const p=o.includes(h.id),b=l!=null&&h.id===l,m=h.disabled===!0||l!=null,S=se(Ln.courseButton,b&&Ln.loading);return f.jsxs("button",{type:"button",className:S,"aria-pressed":p,"aria-disabled":m,"aria-busy":b||void 0,disabled:m,onClick:()=>s==null?void 0:s(h.id,h),"data-testid":`course-panel-item-${h.id}`,children:[b?f.jsx("span",{className:Ln.spinnerWrapper,"aria-hidden":"true","data-testid":`course-panel-item-spinner-${h.id}`,children:f.jsx("span",{className:Ln.spinner})}):null,f.jsxs(Jb,{selected:p,className:Ln.courseCard,children:[f.jsx(Jb.Heading,{className:se(Ln.courseHeading,b&&Ln.contentHidden),children:h.title}),h.description?f.jsx(Jb.Description,{className:se(Ln.courseDescription,b&&Ln.contentHidden),children:h.description}):null]})]},h.id)})})})})]})}function YH(t){const{selectionMode:e="multiple",selectedCourseIds:n,defaultSelectedCourseIds:i,onSelectedCourseIdsChange:r,onCourseToggle:a,...o}=t,{selectedCourseIds:s,toggleCourseId:l}=GH({selectionMode:e,selectedCourseIds:n,defaultSelectedCourseIds:i,onSelectedCourseIdsChange:r}),c=w.useCallback((u,d)=>{l(u),a==null||a(u,d)},[a,l]);return f.jsx(WH,{...o,selectionMode:e,selectedCourseIds:s,onCourseToggle:c})}const KH="_panel_1je0q_1",XH="_header_1je0q_10",$H="_headerActions_1je0q_19",JH="_popoverAnchor_1je0q_27",QH="_backButton_1je0q_31",ZH="_divider_1je0q_38",eV="_title_1je0q_44",tV="_scrollArea_1je0q_54",nV="_scrollable_1je0q_59",iV="_list_1je0q_64",rV="_section_1je0q_70",aV="_sectionHeader_1je0q_76",oV="_sectionTitle_1je0q_80",sV="_sectionTitleCompact_1je0q_88",lV="_item_1je0q_92",cV="_itemClickable_1je0q_106",uV="_itemCompleted_1je0q_110",dV="_itemCurrent_1je0q_114",hV="_itemFuture_1je0q_118",fV="_itemDisabled_1je0q_123",pV="_row_1je0q_137",mV="_stepHeader_1je0q_144",gV="_stepNumber_1je0q_153",vV="_stepTitle_1je0q_159",bV="_checkIcon_1je0q_171",yV="_empty_1je0q_175",_V="_confirmationPopover_1je0q_180",xV="_confirmationMessage_1je0q_204",SV="_confirmationActions_1je0q_211",kV="_confirmationButton_1je0q_216",TV="_confirmationButtonCancel_1je0q_234",wV="_confirmationButtonNeutral_1je0q_242",Re={panel:KH,header:XH,headerActions:$H,popoverAnchor:JH,backButton:QH,divider:ZH,title:eV,scrollArea:tV,scrollable:nV,list:iV,section:rV,sectionHeader:aV,sectionTitle:oV,sectionTitleCompact:sV,item:lV,itemClickable:cV,itemCompleted:uV,itemCurrent:dV,itemFuture:hV,itemDisabled:fV,row:pV,stepHeader:mV,stepNumber:gV,stepTitle:vV,checkIcon:bV,empty:yV,confirmationPopover:_V,confirmationMessage:xV,confirmationActions:SV,confirmationButton:kV,confirmationButtonCancel:TV,confirmationButtonNeutral:wV};function CV(t){var p;const{steps:e,currentStep:n,hideTrailingConclusionStep:i}=t,r=e.length,a=i&&r>0&&((p=e[r-1])==null?void 0:p.title)==="Conclusion",o=a?e.slice(0,-1):e.slice(),s=o.length,l=typeof n=="number"&&isFinite(n)?n:1;if(s===0)return{visibleSteps:o,completedIndices:[],currentIndex:null,futureIndices:[]};if(a&&l===r)return{visibleSteps:o,completedIndices:Array.from({length:s},(b,m)=>m),currentIndex:null,futureIndices:[]};const c=Math.min(Math.max(l,1),s)-1,u=Array.from({length:Math.max(0,c)},(b,m)=>m),d=Math.min(c,s-1),h=Array.from({length:Math.max(0,s-(d+1))},(b,m)=>d+1+m);return{visibleSteps:o,completedIndices:u,currentIndex:d,futureIndices:h}}function EV(t){const{title:e="Course Outline",ariaLabel:n,className:i,steps:r,currentStep:a,onStepClick:o,hideTrailingConclusionStep:s=!0,emptyMessage:l="No steps available",density:c="default",testId:u,onBackToCoursesConfirm:d,backToCoursesDisabled:h=!1,backToCoursesLabel:p="Back to courses",backToCoursesConfirmMessage:b="Going back will end this course. You can start another course from the list.",backToCoursesConfirmLabel:m="Back",backToCoursesCancelLabel:S="Cancel",showBackToCourses:g=!0,...y}=t,[x,v]=w.useState(!1),k=w.useRef(null),T=h||!d,C=w.useCallback(V=>(V+1).toString().padStart(2,"0"),[]),{visibleSteps:R,completedIndices:A,currentIndex:N,futureIndices:O}=w.useMemo(()=>CV({steps:r,currentStep:a,hideTrailingConclusionStep:s}),[a,s,r]),B=c==="compact"?"md":"lg",W=w.useCallback(()=>{T||v(V=>!V)},[T]),L=w.useCallback(()=>{v(!1)},[]),K=w.useCallback(()=>{v(!1),d&&d()},[d]);w.useEffect(()=>{if(!x)return;const V=te=>{const $=te.composedPath();k.current&&!$.includes(k.current)&&v(!1)},X=te=>{te.key==="Escape"&&v(!1)};return document.addEventListener("mousedown",V),document.addEventListener("keydown",X),()=>{document.removeEventListener("mousedown",V),document.removeEventListener("keydown",X)}},[x]),w.useEffect(()=>{T&&x&&v(!1)},[T,x]);const P=w.useCallback((V,X)=>{const te=R[V];if(!te)return null;const $=typeof o=="function",z=$&&te.disabled===!0,Z=$&&!z,Q=se(Re.item,{[Re.itemClickable]:Z,[Re.itemCompleted]:X==="completed",[Re.itemCurrent]:X==="current",[Re.itemFuture]:X==="future",[Re.itemDisabled]:z}),ce=f.jsxs("div",{className:Re.row,children:[f.jsxs("div",{className:Re.stepHeader,children:[f.jsx("span",{className:Re.stepNumber,children:C(V)}),f.jsx("span",{className:Re.stepTitle,children:te.title})]}),X==="completed"?f.jsx(ap,{size:20,className:Re.checkIcon}):null]});return $?f.jsx(xp,{as:"button",type:"button",className:Q,onClick:()=>{Z&&o(V,te)},disabled:z,"aria-current":X==="current"?"step":void 0,"aria-label":`Step ${C(V)}: ${te.title}`,"data-testid":`course-outline-item-${te.id}`,padding:B,radius:"panel",gap:"sm",children:ce},te.id):f.jsx(xp,{className:Q,"aria-current":X==="current"?"step":void 0,"aria-label":`Step ${C(V)}: ${te.title}`,"data-testid":`course-outline-item-${te.id}`,padding:B,radius:"panel",gap:"sm",children:ce},te.id)},[C,B,o,R]);return f.jsxs(qu,{...y,className:se(Re.panel,i),role:"region","aria-label":n??e,"data-testid":u,children:[f.jsxs("div",{className:Re.header,children:[f.jsx(xi,{as:"h2",className:Re.title,children:e}),g?f.jsx("div",{className:Re.headerActions,children:f.jsxs("div",{ref:k,className:Re.popoverAnchor,children:[f.jsxs(_s,{type:"button",variant:"secondary",color:"default",size:"sm",className:Re.backButton,onClick:W,disabled:T,"aria-label":p,"data-testid":"course-outline-back-button",children:[f.jsx(EE,{size:16,"aria-hidden":"true"}),f.jsx("span",{children:p})]}),x?f.jsxs("div",{className:Re.confirmationPopover,role:"dialog","aria-label":"Back to courses confirmation","data-testid":"course-outline-back-confirm",children:[f.jsx("p",{className:Re.confirmationMessage,children:b}),f.jsxs("div",{className:Re.confirmationActions,children:[f.jsx("button",{type:"button",className:se(Re.confirmationButton,Re.confirmationButtonCancel),onClick:L,"data-testid":"course-outline-back-cancel",children:S}),f.jsx("button",{type:"button",className:se(Re.confirmationButton,Re.confirmationButtonNeutral),onClick:K,"data-testid":"course-outline-back-confirm-action",children:m})]})]}):null]})}):null]}),f.jsx("div",{className:Re.divider,"aria-hidden":"true"}),f.jsx("div",{className:Re.scrollArea,children:f.jsx(zl,{className:Re.scrollable,children:R.length===0?f.jsx(xi,{variant:"muted",className:Re.empty,"data-testid":"course-outline-empty",children:l}):f.jsxs("div",{className:Re.list,"data-testid":"course-outline-list",children:[A.length>0?f.jsxs("div",{className:Re.section,"data-testid":"course-outline-section-completed",children:[f.jsx("div",{className:Re.sectionHeader,children:f.jsx("span",{className:se(Re.sectionTitle,c==="compact"?Re.sectionTitleCompact:null),children:"Completed"})}),A.map(V=>P(V,"completed"))]}):null,N!==null?f.jsxs("div",{className:Re.section,"data-testid":"course-outline-section-current",children:[f.jsx("div",{className:Re.sectionHeader,children:f.jsx("span",{className:se(Re.sectionTitle,c==="compact"?Re.sectionTitleCompact:null),children:"Current"})}),P(N,"current")]}):null,O.length>0?f.jsxs("div",{className:Re.section,"data-testid":"course-outline-section-upcoming",children:[f.jsx("div",{className:Re.sectionHeader,children:f.jsx("span",{className:se(Re.sectionTitle,c==="compact"?Re.sectionTitleCompact:null),children:"Upcoming"})}),O.map(V=>P(V,"future"))]}):null]})})})]})}function RV(t){return f.jsx(EV,{...t})}const AV="_panel_h7cuf_1",NV="_messagesArea_h7cuf_20",OV="_messagesList_h7cuf_46",MV="_messageItem_h7cuf_53",DV="_messageMetadata_h7cuf_59",PV="_senderName_h7cuf_67",LV="_timestamp_h7cuf_71",IV="_messageBubble_h7cuf_75",jV="_agentMessage_h7cuf_85",BV="_agentActions_h7cuf_89",UV="_copyButton_h7cuf_95",zV="_copyButtonCopied_h7cuf_129",FV="_empty_h7cuf_133",qV="_composer_h7cuf_140",HV="_composerDisabled_h7cuf_160",VV="_composerInput_h7cuf_165",GV="_sendButton_h7cuf_180",Mn={panel:AV,messagesArea:NV,messagesList:OV,messageItem:MV,messageMetadata:DV,senderName:PV,timestamp:LV,messageBubble:IV,agentMessage:jV,agentActions:BV,copyButton:UV,copyButtonCopied:zV,empty:FV,composer:qV,composerDisabled:HV,composerInput:VV,sendButton:GV};function WV(t){const e=new Date(t),n=e.getHours(),i=e.getMinutes(),r=n>=12?"PM":"AM",a=n%12||12,o=i.toString().padStart(2,"0");return`${a}:${o}${r}`}function YV(t,e){var i,r;if(typeof t.isAgent=="boolean")return t.isAgent;const n=((i=t.from)==null?void 0:i.identity)??void 0;return n&&e&&n===e?!1:((r=t.attributes)==null?void 0:r.source)==="agent-rpc"?!0:n?n==="agent-avatar"||n.startsWith("agent-"):!1}function KV(t,e){var i,r,a;const n=(i=t.from)==null?void 0:i.identity;return n&&e&&n===e?"You":((r=t.from)==null?void 0:r.name)??((a=t.attributes)==null?void 0:a.senderName)??n??"Unknown"}async function XV(t){var n;if(typeof navigator<"u"&&((n=navigator.clipboard)!=null&&n.writeText)){await navigator.clipboard.writeText(t);return}if(typeof document>"u")throw new Error("Clipboard unavailable");const e=document.createElement("textarea");e.value=t,e.style.position="fixed",e.style.left="-9999px",e.style.top="0",e.setAttribute("readonly","true"),document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e)}function $V(t){const{messages:e,localIdentity:n,onSend:i,isSending:r=!1,inputPlaceholder:a="Type a message...",className:o,testId:s,...l}=t,[c,u]=w.useState(""),[d,h]=w.useState(null),p=w.useRef(null),b=w.useRef(null),m=w.useMemo(()=>{const v=e[e.length-1];return v?v.id??`${v.timestamp}-${e.length-1}`:null},[e]);w.useEffect(()=>{var v,k;(k=(v=p.current)==null?void 0:v.scrollIntoView)==null||k.call(v,{behavior:"smooth"})},[m]),w.useEffect(()=>()=>{b.current&&(window.clearTimeout(b.current),b.current=null)},[]);const S=w.useCallback(async()=>{const v=c.trim();v.length!==0&&(await i(v),u(""))},[c,i]),g=w.useCallback(v=>{v.key==="Enter"&&(v.preventDefault(),S())},[S]),y=w.useCallback(async(v,k)=>{try{await XV(v.message??""),h(k),b.current&&window.clearTimeout(b.current),b.current=window.setTimeout(()=>{h(null),b.current=null},2e3)}catch(T){console.warn("[PiPChatPanel] Failed to copy message",T)}},[]),x=c.trim().length>0&&!r;return f.jsxs("div",{...l,className:se(Mn.panel,o),"data-testid":s,role:"region","aria-label":"Chat",children:[f.jsx("div",{className:Mn.messagesArea,children:e.length===0?f.jsx("div",{className:Mn.empty,"data-testid":"pip-chat-panel-empty",children:"No messages yet"}):f.jsxs("div",{className:Mn.messagesList,"data-testid":"pip-chat-panel-list",children:[e.map((v,k)=>{const T=v.id??`${v.timestamp}-${k}`,C=YV(v,n),R=d===T;return f.jsxs("div",{className:se(Mn.messageItem,C&&Mn.agentMessage),"data-testid":`pip-chat-panel-message-${T}`,children:[f.jsxs("div",{className:Mn.messageMetadata,children:[f.jsx("span",{className:Mn.senderName,children:KV(v,n)}),f.jsx("span",{className:Mn.timestamp,children:WV(v.timestamp)})]}),f.jsx("div",{className:Mn.messageBubble,children:v.message}),C?f.jsx("div",{className:Mn.agentActions,children:f.jsx("button",{type:"button",className:se(Mn.copyButton,R&&Mn.copyButtonCopied),onClick:()=>void y(v,T),"aria-label":R?"Copied":"Copy message",title:R?"Copied":"Copy message","data-testid":"pip-copy-agent-message","data-copied":R?"true":"false",children:f.jsx(RE,{size:14})})}):null]},T)}),f.jsx("div",{ref:p})]})}),f.jsxs("div",{className:se(Mn.composer,r&&Mn.composerDisabled),children:[f.jsx("input",{type:"text",className:Mn.composerInput,value:c,onChange:v=>u(v.target.value),onKeyDown:g,placeholder:a,disabled:r,"aria-label":"Message"}),f.jsx("button",{type:"button",className:Mn.sendButton,onClick:()=>void S(),disabled:!x,"aria-label":"Send message",children:f.jsx(DE,{size:16})})]})]})}const JV="_panel_k5ick_1",QV="_header_k5ick_11",ZV="_title_k5ick_19",eG="_titleCompact_k5ick_29",tG="_headerActions_k5ick_33",nG="_closeButton_k5ick_39",iG="_divider_k5ick_67",rG="_body_k5ick_73",aG="_messagesArea_k5ick_81",oG="_scrollable_k5ick_86",sG="_messagesList_k5ick_90",lG="_messageItem_k5ick_98",cG="_messageMetadata_k5ick_104",uG="_senderName_k5ick_112",dG="_timestamp_k5ick_116",hG="_messageBubble_k5ick_120",fG="_messageText_k5ick_124",pG="_agentMessage_k5ick_130",mG="_agentActions_k5ick_134",gG="_copyButton_k5ick_140",vG="_copyButtonCopied_k5ick_174",bG="_inputRow_k5ick_178",yG="_empty_k5ick_182",_G="_composer_k5ick_188",xG="_composerDefault_k5ick_203",SG="_composerCompact_k5ick_208",kG="_composerDisabled_k5ick_218",TG="_composerInputWrapper_k5ick_223",wG="_composerInput_k5ick_223",CG="_sendButton_k5ick_240",EG="_sendButtonCompact_k5ick_257",nt={panel:JV,header:QV,title:ZV,titleCompact:eG,headerActions:tG,closeButton:nG,divider:iG,body:rG,messagesArea:aG,scrollable:oG,messagesList:sG,messageItem:lG,messageMetadata:cG,senderName:uG,timestamp:dG,messageBubble:hG,messageText:fG,agentMessage:pG,agentActions:mG,copyButton:gG,copyButtonCopied:vG,inputRow:bG,empty:yG,composer:_G,composerDefault:xG,composerCompact:SG,composerDisabled:kG,composerInputWrapper:TG,composerInput:wG,sendButton:CG,sendButtonCompact:EG};function RG(t){const e=new Date(t),n=e.getHours(),i=e.getMinutes(),r=n>=12?"PM":"AM",a=n%12||12,o=i.toString().padStart(2,"0");return`${a}:${o}${r}`}function AG(t,e){var i,r;if(typeof t.isAgent=="boolean")return t.isAgent;const n=((i=t.from)==null?void 0:i.identity)??void 0;return n&&e&&n===e?!1:((r=t.attributes)==null?void 0:r.source)==="agent-rpc"?!0:n?n==="agent-avatar"||n.startsWith("agent-"):!1}function NG(t,e){var i,r,a;const n=(i=t.from)==null?void 0:i.identity;return n&&e&&n===e?"You":((r=t.from)==null?void 0:r.name)??((a=t.attributes)==null?void 0:a.senderName)??n??"Unknown"}async function OG(t){var n;if(typeof navigator<"u"&&((n=navigator.clipboard)!=null&&n.writeText)){await navigator.clipboard.writeText(t);return}if(typeof document>"u")throw new Error("Clipboard unavailable");const e=document.createElement("textarea");e.value=t,e.style.position="fixed",e.style.left="-9999px",e.style.top="0",e.setAttribute("readonly","true"),document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e)}function MG(t){const{disabled:e,placeholder:n,size:i="md",autoFocus:r,onSend:a}=t,[o,s]=w.useState(""),l=w.useCallback(async()=>{const p=o.trim();p.length!==0&&(await a(p),s(""))},[a,o]),c=w.useCallback(p=>{p.key==="Enter"&&(p.preventDefault(),l())},[l]),u=i==="sm"||i==="xs",d=u?18:24,h=o.trim().length>0&&e!==!0;return f.jsxs("div",{className:se(nt.composer,u?nt.composerCompact:nt.composerDefault,e?nt.composerDisabled:null),children:[f.jsx("div",{className:nt.composerInputWrapper,children:f.jsx(LE,{value:o,onChange:s,onKeyDown:c,className:nt.composerInput,placeholder:n??"Send a message ...",disabled:e,size:i,autoFocus:r,"aria-label":"Message"})}),f.jsx("button",{type:"button",className:se(nt.sendButton,u?nt.sendButtonCompact:null),onClick:()=>void l(),disabled:!h,"aria-label":"Send message",children:f.jsx(DE,{size:d})})]})}function N3(t){const{title:e="Messages",ariaLabel:n,className:i,messages:r,isSending:a=!1,localIdentity:o,onSend:s,onClose:l,showCloseButton:c=!0,emptyMessage:u="No messages yet",density:d="default",testId:h,formatTimestamp:p=RG,getSenderName:b,isAgentMessage:m,copyResetDelayMs:S=2e3,showAgentCopyButton:g=!0,inputPlaceholder:y,inputAutoFocus:x,...v}=t,k=w.useRef(null),[T,C]=w.useState(null),R=w.useRef(null),A=w.useCallback(K=>b?b(K):NG(K,o),[b,o]),N=w.useCallback(K=>m?m(K,o):AG(K,o),[m,o]),O=w.useMemo(()=>{const K=r[r.length-1];return K?K.id??`${K.timestamp}-${r.length-1}`:null},[r]);w.useEffect(()=>{var K,P;(P=(K=k.current)==null?void 0:K.scrollIntoView)==null||P.call(K,{behavior:"smooth"})},[O]),w.useEffect(()=>()=>{R.current&&(window.clearTimeout(R.current),R.current=null)},[]);const B=w.useCallback(K=>{C(K),R.current&&window.clearTimeout(R.current),R.current=window.setTimeout(()=>{C(null),R.current=null},S)},[S]),W=w.useCallback(async(K,P)=>{try{await OG(K.message??""),B(P)}catch(V){console.warn("[ChatPanel] Failed to copy message",V)}},[B]),L=d==="compact"?"sm":"md";return f.jsxs(qu,{...v,className:se(nt.panel,i),role:"region","aria-label":n??e,"data-testid":h,children:[f.jsxs("div",{className:nt.header,children:[f.jsx(xi,{as:"h2",className:se(nt.title,d==="compact"?nt.titleCompact:null),children:e}),l&&c?f.jsx("div",{className:nt.headerActions,children:f.jsx("button",{type:"button",className:nt.closeButton,onClick:l,"aria-label":`Close ${e}`,children:f.jsx(op,{size:d==="compact"?18:20})})}):null]}),f.jsx("div",{className:nt.divider,"aria-hidden":"true"}),f.jsxs("div",{className:nt.body,children:[f.jsx("div",{className:nt.messagesArea,children:f.jsx(zl,{className:nt.scrollable,children:r.length===0?f.jsx(xi,{variant:"muted",className:nt.empty,"data-testid":"chat-panel-empty",children:u}):f.jsxs("div",{className:nt.messagesList,"data-testid":"chat-panel-list",children:[r.map((K,P)=>{const V=K.id??`${K.timestamp}-${P}`,X=N(K),te=T===V;return f.jsxs("div",{className:se(nt.messageItem,X?nt.agentMessage:null),"data-testid":`chat-panel-message-${V}`,children:[f.jsxs("div",{className:nt.messageMetadata,children:[f.jsx("span",{className:nt.senderName,children:A(K)}),f.jsx("span",{className:nt.timestamp,children:p(K.timestamp)})]}),f.jsx(xp,{className:nt.messageBubble,padding:"md",radius:"panel",background:X?"surfaceMuted":"surface",children:f.jsx("div",{className:nt.messageText,children:K.message})}),X&&g?f.jsx("div",{className:nt.agentActions,children:f.jsx("button",{type:"button",className:se(nt.copyButton,te?nt.copyButtonCopied:null),onClick:()=>void W(K,V),"aria-label":te?"Copied":"Copy agent message",title:te?"Copied":"Copy agent message","data-testid":"copy-agent-message","data-copied":te?"true":"false",children:f.jsx(RE,{size:18})})}):null]},V)}),f.jsx("div",{ref:k})]})})}),f.jsx("div",{className:nt.inputRow,children:f.jsx(MG,{onSend:s,disabled:a,placeholder:y,size:L,autoFocus:x})})]})]})}const DG="_responsive_14d0j_2",Hu={responsive:DG,"showAboveWidth-sm":"_showAboveWidth-sm_14d0j_15","showAboveWidth-md":"_showAboveWidth-md_14d0j_24","showAboveWidth-lg":"_showAboveWidth-lg_14d0j_33","showAboveWidth-xl":"_showAboveWidth-xl_14d0j_42","hideAboveWidth-sm":"_hideAboveWidth-sm_14d0j_53","hideAboveWidth-md":"_hideAboveWidth-md_14d0j_59","hideAboveWidth-lg":"_hideAboveWidth-lg_14d0j_65","hideAboveWidth-xl":"_hideAboveWidth-xl_14d0j_71","showAboveHeight-short":"_showAboveHeight-short_14d0j_84","showAboveHeight-medium":"_showAboveHeight-medium_14d0j_93","hideAboveHeight-short":"_hideAboveHeight-short_14d0j_104","hideAboveHeight-medium":"_hideAboveHeight-medium_14d0j_110"};function PG(t){const{as:e,children:n,showAboveWidth:i,hideAboveWidth:r,showAboveHeight:a,hideAboveHeight:o,className:s,...l}=t,c=[Hu.responsive];return i&&c.push(Hu[`showAboveWidth-${i}`]),r&&c.push(Hu[`hideAboveWidth-${r}`]),a&&c.push(Hu[`showAboveHeight-${a}`]),o&&c.push(Hu[`hideAboveHeight-${o}`]),f.jsx(e??"div",{...l,className:se(c,s),children:n})}w.createContext("vertical");const LG="_container_1v6ko_1",IG="_video_1v6ko_7",jG="_chip_1v6ko_16",BG="_logo_1v6ko_34",Sp={container:LG,video:IG,chip:jG,logo:BG},UG="https://obi-static.s3.ap-southeast-2.amazonaws.com/videos/greeting.mp4";function zG(t){const{agentName:e="Obi",greetingVideoSrc:n,className:i,...r}=t,a=w.useRef(null),o=()=>{var s;try{(s=a.current)==null||s.pause()}catch{}};return f.jsxs("div",{className:se(Sp.container,i),...r,children:[f.jsx("video",{ref:a,className:Sp.video,src:n??UG,autoPlay:!0,muted:!0,playsInline:!0,onEnded:o}),f.jsxs("div",{className:Sp.chip,children:[f.jsx(YB,{size:12,className:Sp.logo}),f.jsx("span",{children:e})]})]})}typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;const O3=50,Hl="?",M3=/\(error: (.*)\)/,D3=/captureMessage|captureException/;function FG(...t){const e=t.sort((n,i)=>n[0]-i[0]).map(n=>n[1]);return(n,i=0,r=0)=>{const a=[],o=n.split(`
133
- `);for(let s=i;s<o.length;s++){const l=o[s];if(l.length>1024)continue;const c=M3.test(l)?l.replace(M3,"$1"):l;if(!c.match(/\S*Error: /)){for(const u of e){const d=u(c);if(d){a.push(d);break}}if(a.length>=O3+r)break}}return qG(a.slice(r))}}function qG(t){if(!t.length)return[];const e=Array.from(t);return/sentryWrapped/.test(kp(e).function||"")&&e.pop(),e.reverse(),D3.test(kp(e).function||"")&&(e.pop(),D3.test(kp(e).function||"")&&e.pop()),e.slice(0,O3).map(n=>({...n,filename:n.filename||kp(e).filename,function:n.function||Hl}))}function kp(t){return t[t.length-1]||{}}typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;const HG=30,VG=50;function Qb(t,e,n,i){const r={filename:t,function:e==="<anonymous>"?Hl:e,in_app:!0};return n!==void 0&&(r.lineno=n),i!==void 0&&(r.colno=i),r}const GG=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,WG=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,YG=/\((\S*)(?::(\d+))(?::(\d+))\)/,KG=t=>{const e=GG.exec(t);if(e){const[,i,r,a]=e;return Qb(i,Hl,+r,+a)}const n=WG.exec(t);if(n){if(n[2]&&n[2].indexOf("eval")===0){const a=YG.exec(n[2]);a&&(n[2]=a[1],n[3]=a[2],n[4]=a[3])}const[i,r]=P3(n[1]||Hl,n[2]);return Qb(r,i,n[3]?+n[3]:void 0,n[4]?+n[4]:void 0)}},XG=[HG,KG],$G=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,JG=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i;FG(...[XG,[VG,t=>{const e=$G.exec(t);if(e){if(e[3]&&e[3].indexOf(" > eval")>-1){const r=JG.exec(e[3]);r&&(e[1]=e[1]||"eval",e[3]=r[1],e[4]=r[2],e[5]="")}let n=e[3],i=e[1]||Hl;return[i,n]=P3(i,n),Qb(n,i,e[4]?+e[4]:void 0,e[5]?+e[5]:void 0)}}]]);const P3=(t,e)=>{const n=t.indexOf("safari-extension")!==-1,i=t.indexOf("safari-web-extension")!==-1;return n||i?[t.indexOf("@")!==-1?t.split("@")[0]:Hl,n?`safari-extension:${e}`:`safari-web-extension:${e}`]:[t,e]};typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;const ir={shell:"_shell_8bsnr_1",layout:"_layout_8bsnr_11",layoutThree:"_layoutThree_8bsnr_23",leftPanel:"_leftPanel_8bsnr_27",middlePanel:"_middlePanel_8bsnr_36",rightPanel:"_rightPanel_8bsnr_37",videoFrame:"_videoFrame_8bsnr_41",captions:"_captions_8bsnr_52",controls:"_controls_8bsnr_58",coursePanel:"_coursePanel_8bsnr_71",returnToPiPOverlay:"_returnToPiPOverlay_8bsnr_82",returnToPiPButton:"_returnToPiPButton_8bsnr_94"};function Zb(...t){return t.filter(Boolean).join(" ")}function QG(t){const{captionsText:e,avatarAudioPower:n=0,avatarImageSrc:i,avatarAriaLabel:r,avatarStatus:a,controlBarProps:o,courses:s,coursePanelProps:l,middlePanel:c,rightPanel:u,isCourseOutlineOpen:d,onReturnToPiP:h,className:p}=t;return f.jsx("div",{className:Zb(ir.shell,p),"data-testid":"course-dialog-content",children:f.jsxs("div",{className:Zb(ir.layout,u?ir.layoutThree:null),children:[f.jsxs("div",{className:ir.leftPanel,children:[f.jsxs("div",{className:ir.videoFrame,children:[d&&h&&f.jsx("div",{className:ir.returnToPiPOverlay,children:f.jsx("button",{type:"button",className:ir.returnToPiPButton,onClick:h,"aria-label":"Return to PiP","data-testid":"course-return-to-pip",children:f.jsx(GB,{size:14})})}),f.jsx(hH,{className:ir.captions,text:e,children:f.jsx(x3,{audioPower:n,size:"lg",background:"flat",imageSrc:i,ariaLabel:r??"Agent avatar placeholder",status:a})})]}),f.jsx("div",{className:ir.controls,children:f.jsx(BF,{...o})})]}),u?f.jsx("div",{className:ir.rightPanel,"data-testid":"course-dialog-right-panel",children:u}):null,f.jsx("div",{className:ir.middlePanel,"data-testid":"course-dialog-middle-panel",children:c??f.jsx(YH,{...l,courses:s,className:Zb(ir.coursePanel,l==null?void 0:l.className)})})]})})}function L3(t){const{open:e,onClose:n,dialogProps:i,...r}=t;return f.jsx(HE,{open:e,onClose:n,variant:"ghost",...i,children:f.jsx(QG,{...r})})}const ZG=80,eW=500,tW=1e3;function nW(t,e){const{delayMs:n=0}=e??{},r=t.filter(m=>{var g;const S=(g=m.participantInfo)==null?void 0:g.identity;return(S==null?void 0:S.startsWith("agent-"))??!1}).map(m=>m.text??"").join(" ").trim(),[a,o]=w.useState(""),[s,l]=w.useState(!1),c=w.useRef(""),u=w.useRef(null),d=w.useRef(null),h=w.useRef(null),p=m=>{h.current&&(clearTimeout(h.current),h.current=null),n>0?h.current=setTimeout(()=>{o(m)},n):o(m)},b=(m,S)=>m.startsWith(S)?m.slice(S.length).trim():m.trim();return w.useEffect(()=>{if(d.current&&(clearTimeout(d.current),d.current=null),s)return;const m=b(r,c.current);p(m),m.length>ZG?(l(!0),u.current=setTimeout(()=>{l(!1),c.current=r},eW+n)):m.length>0&&(d.current=setTimeout(()=>{c.current=r,p("")},tW+n))},[r,s,n]),w.useEffect(()=>()=>{u.current&&clearTimeout(u.current),d.current&&clearTimeout(d.current),h.current&&clearTimeout(h.current)},[]),{caption:a,hasCaption:a.length>0}}const kr={layout:"_layout_k1q6c_1",left:"_left_k1q6c_10",copy:"_copy_k1q6c_17",description:"_description_k1q6c_25",descriptionScroller:"_descriptionScroller_k1q6c_31",cta:"_cta_k1q6c_36",disclaimer:"_disclaimer_k1q6c_43",right:"_right_k1q6c_47",mediaPanel:"_mediaPanel_k1q6c_56",agentStill:"_agentStill_k1q6c_63",dialogWithSmallClose:"_dialogWithSmallClose_k1q6c_88"};function iW(t){const{open:e,onClose:n,onStart:i,agentName:r,agentSubtitle:a,description:o,startLabel:s="Start Now",disclaimer:l="Sessions are securely recorded for quality improvement purposes.",showCloseButton:c=!1,isStarting:u=!1,greetingVideoSrc:d}=t;return f.jsx(HE,{open:e,onClose:n,size:"large",showCloseButton:c,className:kr.dialogWithSmallClose,children:f.jsxs("div",{className:kr.layout,children:[f.jsxs("div",{className:kr.left,children:[f.jsxs("div",{className:kr.copy,children:[f.jsx(xi,{variant:"heading",children:r}),f.jsx(xi,{variant:"subheading",children:a}),f.jsx(xi,{variant:"muted",as:"div",className:kr.description,children:f.jsx(zl,{className:kr.descriptionScroller,children:f.jsx(nF,{content:o})})})]}),f.jsxs("div",{className:kr.cta,children:[f.jsx(_s,{type:"button",size:"lg",fullWidth:!0,onClick:i,isLoading:u,children:s}),f.jsx(xi,{variant:"subscript",as:"p",className:kr.disclaimer,children:l})]})]}),f.jsx(PG,{showAboveWidth:"md",children:f.jsx("div",{className:kr.right,children:f.jsx(qu,{className:kr.mediaPanel,children:f.jsx(zG,{agentName:r,greetingVideoSrc:d,className:kr.agentStill})})})})]})})}const rW={launcherPill:"_launcherPill_1fhyr_1"};function aW(t){const{label:e,onClick:n}=t;return f.jsx("button",{type:"button",className:rW.launcherPill,onClick:n,"data-testid":"ai-coach-pill",children:e})}const I3="__ama_course__",oW="ama_course",sW=3e4;function lW(t){var No,Oo,Wl,_n,xn,Mo,Do,Kr,Po,Ut,Lo,Io,jo,Bo,Yl,_,I,M,pe,Le,ve,zt,_t,xt,Xr,Ie,Uo,Kl,K3;const{sdk:e,shadowHost:n}=t,i=!!e.passivePlanUuid,r=i?((No=e.client)==null?void 0:No.selectedPlanUuid)??null:null,a=((Oo=e.client)==null?void 0:Oo.session)??null,o=!!a&&(i&&!!r||!!((Wl=e.client)!=null&&Wl.selectedPlanUuid)),[s,l]=w.useState(()=>a),[c,u]=w.useState(()=>a!=null&&a.sessionUuid?uW(a.sessionUuid):null),d=(()=>{var Y;return a?((Y=a.roomId)==null?void 0:Y.startsWith("obs-"))&&!c?"course-selection":"pip":r?"start-session":"hidden"})(),[h,p]=w.useState(()=>d),b=w.useRef(d),[m,S]=w.useState(!1),[g,y]=w.useState(!1),[x,v]=w.useState(!1),[k,T]=w.useState([]),[C,R]=w.useState(null),[A,N]=w.useState(null),[O,B]=w.useState(0),[W,L]=w.useState(!1),[K,P]=w.useState(!1),[V,X]=w.useState(0),[te,$]=w.useState(null),[z,Z]=w.useState([]),[Q,ce]=w.useState(!1),[j,ge]=w.useState(!1),[U,fe]=w.useState(()=>o),me=w.useRef(o),Rt=w.useRef(null),en=w.useRef(null),be=w.useRef(!1),qe=()=>{p(Y=>{const ne=Y==="course-selection",Te=Y==="course-outline"&&be.current;return ne||Te?(be.current=!1,L(!1),"pip"):Y})};w.useEffect(()=>{b.current=h},[h]),w.useEffect(()=>()=>{Rt.current&&clearTimeout(Rt.current)},[]);const bt=()=>{Rt.current&&(clearTimeout(Rt.current),Rt.current=null)},Je=()=>{bt(),en.current=null,N(Y=>Y===null?Y:null)},cn=Y=>{bt(),en.current=Y,N(Y),Rt.current=setTimeout(()=>{const ne=en.current===Y,Te=b.current==="course-selection";ne&&Te&&(en.current=null,N(null)),Rt.current=null},sW)},tn=dW((xn=(_n=e.client)==null?void 0:_n.product)==null?void 0:xn.widget_url_blacklist),Mt=hW(s),{audioDevices:bn}=fW();w.useEffect(()=>{s!=null&&s.sessionUuid&&j3(s.sessionUuid,c)},[c,s==null?void 0:s.sessionUuid]);const{caption:yn}=nW(z,{delayMs:0}),In=typeof navigator<"u"&&!!((Mo=navigator.mediaDevices)!=null&&Mo.getDisplayMedia),Si=((Kr=(Do=s==null?void 0:s.room)==null?void 0:Do.localParticipant)==null?void 0:Kr.isScreenShareEnabled)??!1,de=Y=>{var Ae;const ne=((Ae=e.client)==null?void 0:Ae.identity)??Y.identity,Te=typeof(ne==null?void 0:ne.first_name)=="string"?ne.first_name.trim():"",st=typeof(ne==null?void 0:ne.last_name)=="string"?ne.last_name.trim():"",xe=typeof(ne==null?void 0:ne.email)=="string"&&ne.email.trim().length>0?ne.email.trim():"";return{firstName:Te,lastName:st,email:xe}},We=Y=>{const{firstName:ne,lastName:Te,email:st}=de(Y),xe=[ne,Te,st].map(pt=>pt.trim());return xe.some(pt=>pt.length>0)?xe.join(":"):""},Ce=Y=>{const{firstName:ne,lastName:Te,email:st}=de(Y),xe=[ne,Te].filter(Boolean).join(" ").trim();return{name:xe.length>0?xe:void 0,email:st.length>0?st:void 0,screenShareSupported:In}},Qe=(()=>{if(s!=null&&s.speakingState){if(s.speakingState==="thinking")return"thinking";if(s.speakingState==="busy")return"searching"}})(),ot=((Ut=(Po=e.client)==null?void 0:Po.product)==null?void 0:Ut.avatar_image_url)||((Io=(Lo=e.client)==null?void 0:Lo.product)==null?void 0:Io.logo_url)||void 0,ki=((Bo=(jo=e.client)==null?void 0:jo.product)==null?void 0:Bo.greeting_video_url)||void 0,Ii=cW({sdk:e,session:s,isBlacklisted:tn}),Wr=!i&&Ii,q=!!(s??((Yl=e.client)==null?void 0:Yl.session)??null),ae=(s==null?void 0:s.clientType)==="meet"?We(s):"",he=(I=(_=e.client)==null?void 0:_.product)==null?void 0:I.assistant_subtitle,Pe=typeof he=="string"&&he.trim().length>0?he:"Onboarding Assistant",it=()=>B(Y=>Y+1),jn=async()=>{var ne,Te;if(!s)return;const Y=((Te=(ne=s.room)==null?void 0:ne.localParticipant)==null?void 0:Te.isScreenShareEnabled)??!1;try{Y?await s.setScreenShareEnabled(!1):await s.shareScreen()}catch(st){console.error("[obi-sdk] failed to toggle screen share",st)}finally{it()}},Ti=w.useRef(null),Bn=w.useRef(null),Un=w.useRef(!1),Wt=w.useRef({session:null,sessionUuid:null,started:!1}),ai=w.useRef(null),zn=w.useRef(new WeakMap),Vl=(Y,ne)=>{if(!ne)return;let Te=zn.current.get(Y);Te||(Te=new Set,zn.current.set(Y,Te)),Te.add(ne)},ks=Y=>{if(!Y||Ti.current===Y)return;Bn.current&&(Bn.current(),Bn.current=null);const ne=()=>it(),Te=ie=>{u(ie),Je(),Y!=null&&Y.sessionUuid&&j3(Y.sessionUuid,ie),p(Ne=>Ne==="pip"||Ne==="course-outline"?Ne:Ne==="course-selection"?(be.current=!0,"course-outline"):Ne)},st=ie=>{Je(),T(ie.courses),p("course-selection"),be.current=!1,u(null),Y!=null&&Y.sessionUuid&&B3(Y.sessionUuid),R(null),P(!1)},xe=(ie,Ne)=>{},Ae=ie=>{ie.isAgent},pt=ie=>{$(ie),X(Date.now())},nn=ie=>{if(!ie){$(null);return}$(ie),X(Date.now())};Y.on("stateChanged",ne),Y.on("speakingStateChanged",ne),Y.on("paused",ne),Y.on("unpaused",ne),Y.on("chatMessagesChanged",ne),Y.on("chatMessageReceived",Ae),Y.on("courseProgress",Te),Y.on("courseSelection",st),Y.on("transcript",xe),Y.on("screenCaptured",pt),Y.on("screenCaptureNotification",nn),Y.on("captions",Z),Y.on("introductionComplete",qe),Ti.current=Y,Bn.current=()=>{Y.off("stateChanged",ne),Y.off("speakingStateChanged",ne),Y.off("paused",ne),Y.off("unpaused",ne),Y.off("chatMessagesChanged",ne),Y.off("chatMessageReceived",Ae),Y.off("courseProgress",Te),Y.off("courseSelection",st),Y.off("transcript",xe),Y.off("screenCaptured",pt),Y.off("screenCaptureNotification",nn),Y.off("captions",Z),Y.off("introductionComplete",qe)}},Se=Y=>{var Te;return Y?((Te=Y.roomId)==null?void 0:Te.startsWith("obs-"))&&!c?"course-selection":"pip":"hidden"};w.useEffect(()=>{const Y=()=>{ai.current&&(ai.current(),ai.current=null)},ne=xe=>{if(xe.clientType!=="meet")return;if(Wt.current.session&&Wt.current.session===xe||!!Wt.current.sessionUuid&&!!xe.sessionUuid&&Wt.current.sessionUuid===xe.sessionUuid){if(Wt.current.started||ai.current)return}else Wt.current={session:xe,sessionUuid:xe.sessionUuid??null,started:!1},Y();const pt=async()=>{Wt.current={session:xe,sessionUuid:xe.sessionUuid??null,started:!0};const Ne=We(xe);Ne&&Vl(xe,Ne);try{await xe.sendHumanJoined(Ce(xe))}catch(Yt){console.error("[obi-sdk] failed to send human_joined handshake",Yt)}},nn=(Ne,Yt)=>{Ne==="connecting"||Ne==="error"||(Y(),pt())},ie=xe.state;if(ie&&ie!=="connecting"&&ie!=="error"){pt();return}xe.on("stateChanged",nn),ai.current=()=>{xe.off("stateChanged",nn)}},Te=xe=>{var Ae,pt,nn,ie;if(xe)if((Ae=e.client)!=null&&Ae.session)p(Se(((nn=e.client)==null?void 0:nn.session)??null));else{const Yt=!!e.passivePlanUuid,qn=Yt&&!!((pt=e.client)!=null&&pt.selectedPlanUuid);if(Yt&&!qn)return;p("start-session")}else(ie=e.client)!=null&&ie.session||p("hidden")},st=()=>it();if(e.on("showMenu",Te),e.on("configUpdated",st),e.client){e.client.session&&(l(e.client.session),ks(e.client.session),p(Se(e.client.session))),e.client.on("sessionStarted",Ae=>{l(Ae),ks(Ae),Un.current=!1,S(!1),y(!1),v(!1),P(!1);const pt=me.current;me.current=!1,pt?(be.current=!0,p("course-outline")):(be.current=!1,p(Se(Ae))),sa().track("session-started",{planId:Ae.planId}),ne(Ae)}),e.client.on("sessionResumed",Ae=>{l(Ae),ks(Ae),Un.current=!1,S(!1),y(!1),v(!1),P(!1),be.current=!1,p(Se(Ae)),ne(Ae)});const xe=()=>{var nn;const Ae=(nn=e.client)==null?void 0:nn.session;Ae!=null&&Ae.sessionUuid&&B3(Ae.sessionUuid);const pt=Ti.current;Bn.current&&(Bn.current(),Bn.current=null),l(null),Ti.current=null,S(!1),y(!1),v(!1),P(!1),fe(!1),me.current=!1,Je(),be.current=!1,Y(),Wt.current={session:null,sessionUuid:null,started:!1},pt&&zn.current.delete(pt),Un.current||p("hidden")};e.client.on("sessionStopped",xe),e.client.on("sessionShutdown",xe),e.client.on("stateChanged",it)}return()=>{e.off("showMenu",Te),e.off("configUpdated",st),Bn.current&&Bn.current(),Y()}},[e]),w.useEffect(()=>{const Y=s;if(!Y||Y.clientType!=="meet")return;const ne=Y.state;if(!ne||ne==="connecting"||ne==="error"||!ae)return;const Te=zn.current.get(Y);Te!=null&&Te.has(ae)||(Vl(Y,ae),Y.sendHumanJoined(Ce(Y)).catch(st=>console.error("[obi-sdk] failed to send human_joined update",st)))},[In,ae,s,s==null?void 0:s.state]),w.useLayoutEffect(()=>{var Y,ne;(ne=(Y=e.client)==null?void 0:Y.product)!=null&&ne.primary_color&&n.style.setProperty("--obi-color-primary",e.client.product.primary_color)},[(pe=(M=e.client)==null?void 0:M.product)==null?void 0:pe.primary_color,n]),w.useEffect(()=>{if(i&&!tn&&!q){if(!r){p("hidden");return}p("start-session")}},[q,i,tn,r]),w.useEffect(()=>{var nn,ie;ge(!1);const Y=(nn=e.client)==null?void 0:nn.api,ne=(ie=e.client)==null?void 0:ie.product;if(!Y||!ne)return;const Te=(ne==null?void 0:ne.uuid)??(ne==null?void 0:ne.product_uuid),st=(ne==null?void 0:ne.slug)??(ne==null?void 0:ne.product_slug),xe=(ne==null?void 0:ne.id)??(ne==null?void 0:ne.product_id),Ae={};if(Te?Ae.product_uuid=Te:st?Ae.product_slug=st:xe!=null&&(Ae.product_id=String(xe)),Object.keys(Ae).length===0)return;let pt=!1;return Y.getFeatureFlags(Ae).then(Ne=>{if(pt)return;const qn=((Ne==null?void 0:Ne.data)??[]).find(ny=>(ny==null?void 0:ny.slug)===oW);if(!qn)return;const{user_enabled:oi,product_enabled:Hn,global_enabled:Tr}=qn;let ty=!!Tr;Hn!=null&&(ty=!!Hn),oi!=null&&(ty=!!oi),ge(ty)}).catch(Ne=>{console.error("[obi-sdk] failed to load AMA feature flag",Ne)}),()=>{pt=!0}},[(Le=e.client)==null?void 0:Le.api,(ve=e.client)==null?void 0:ve.product]);const Fn=(c==null?void 0:c.stepNames.map((Y,ne)=>({id:`step-${ne+1}`,title:Y})))??[],Gl=(c==null?void 0:c.currentStep)??null,Ao=!0,Yr=(Y,ne)=>{s==null||s.say(`Can we jump to the section about ${ne.title}?`)};if(tn||i&&!r&&!q)return null;if(h==="hidden")return Wr?f.jsx(aW,{label:Pe,onClick:()=>{e.updateShowMenu(!0)}}):null;if(h==="start-session"){const Y=(zt=e.client)==null?void 0:zt.product,ne=(_t=e.client)==null?void 0:_t.selectedPlan,Te=i&&!!r,st=i&&!!r||!!((xt=e.client)!=null&&xt.selectedPlanUuid),xe=(Y==null?void 0:Y.agent_name)||"Obi",Ae=(Y==null?void 0:Y.assistant_subtitle)||"AI Assistant",pt=Te&&(ne==null?void 0:ne.description)||(Y==null?void 0:Y.assistant_description)||"";return f.jsx(iW,{open:!0,onClose:()=>{S(!1),p("hidden")},onStart:()=>{me.current=st,fe(st),S(!0),e.startSession({withMicrophone:!0})},agentName:xe,agentSubtitle:Ae,description:pt,showCloseButton:!1,startLabel:"Start Session",isStarting:m,greetingVideoSrc:ki})}if(h==="course-selection"){const Y=(Xr=s==null?void 0:s.roomId)==null?void 0:Xr.startsWith("obs-"),ne=((Ie=e.client)==null?void 0:Ie.plans)||[],Te=Y&&k.length>0,st=Te?k.slice().sort((ie,Ne)=>ie.order!==void 0&&Ne.order!==void 0?ie.order-Ne.order:ie.order!==void 0?-1:Ne.order!==void 0?1:ie.name.localeCompare(Ne.name)).map(ie=>({id:ie.uuid,title:ie.name,description:ie.description||ie.overview||"",status:ie.completed?"completed":"available",duration:typeof ie.duration=="number"?`${ie.duration} min`:ie.duration})):ne.map(ie=>{var Ne,Yt;return{id:ie.uuid,title:ie.name,description:ie.description,status:(Yt=(Ne=e.client)==null?void 0:Ne.planIsCompleted)!=null&&Yt[ne.indexOf(ie)]?"completed":"available",duration:ie.estimated_duration?`${ie.estimated_duration} min`:void 0}});Te&&j&&st.push({id:I3,title:"Ask me anything",description:"Ask questions before choosing a course.",status:"available"});const xe=(s==null?void 0:s.languageCodes)||[],Ae=(s==null?void 0:s.selectedLanguage)||(s==null?void 0:s.defaultLanguageCode)||null,pt={audioDevices:bn,currentMicrophoneId:(s==null?void 0:s.preferredMicrophoneDeviceId)||null,isMicrophoneEnabled:!g&&((s==null?void 0:s.isMicShared)??!1),isScreenShareActive:Si,widgetState:x?"chat":null,canPublishData:!0,browserSupportsScreenSharing:In,onMicDeviceSelect:async ie=>{e.client&&(e.client.preferredMicrophoneDeviceId=ie),s&&ie&&await s.switchMicrophoneDevice(ie),it()},onMicToggle:async()=>{s!=null&&s.isMicShared?g?(await s.unmuteMicrophone(),y(!1)):(await s.muteMicrophone(),y(!0)):await(s==null?void 0:s.shareMicrophone())},onChatToggle:()=>{v(!x)},onLeave:()=>{s==null||s.stop()},onScreenShareToggle:jn,languages:xe,selectedLanguage:Ae,defaultLanguageCode:s==null?void 0:s.defaultLanguageCode,isMultilingual:(s==null?void 0:s.isMultilingual)??!1,onLanguageChange:ie=>{s==null||s.setLanguage(ie)},isLanguageSelectorEnabled:!0,...x?{screenShareButtonVariant:"compact"}:{}},nn=x?f.jsx(N3,{messages:(s==null?void 0:s.chatMessages)??[],localIdentity:((Uo=s==null?void 0:s.room)==null?void 0:Uo.localParticipant.identity)??(typeof(s==null?void 0:s.identity)=="string"?s.identity:null),onSend:async ie=>{var Ne,Yt,qn,oi;if(s){const Hn=Date.now();s.appendChatMessage({timestamp:Hn,message:ie,from:{identity:((Yt=(Ne=s.room)==null?void 0:Ne.localParticipant)==null?void 0:Yt.identity)??null,name:((oi=(qn=s.room)==null?void 0:qn.localParticipant)==null?void 0:oi.name)??null},isAgent:!1}),await s.say(ie)}},onClose:()=>v(!1)}):void 0;return f.jsx(L3,{open:!0,onClose:()=>s==null?void 0:s.stop(),courses:st,controlBarProps:pt,coursePanelProps:{selectedCourseIds:C?[C]:void 0,loadingCourseId:A,onCourseToggle:async ie=>{var Ne,Yt,qn,oi;if(!en.current)if(Te){if(ie===I3){cn(ie),R(ie);try{await((Ne=s==null?void 0:s.say)==null?void 0:Ne.call(s,"Please start an AMA session."))}catch(Tr){console.error("[obi-sdk] failed to start AMA course",Tr),Je(),R(null)}return}const Hn=k.find(Tr=>Tr.uuid===ie);if(Hn){cn(ie),R(ie);try{await((Yt=s==null?void 0:s.say)==null?void 0:Yt.call(s,`I'd like to take the ${Hn.name} course.`))}catch(Tr){console.error("[obi-sdk] failed to send course selection",Tr),Je(),R(null)}}}else{const Hn=ne.find(Tr=>Tr.uuid===ie);if(Hn){cn(ie),(qn=e.client)==null||qn.selectPlan(Hn),p("pip");try{await((oi=s==null?void 0:s.say)==null?void 0:oi.call(s,`I'd like to take the ${Hn.name} course.`))}catch(Tr){console.error("[obi-sdk] failed to send course selection",Tr),p("course-selection"),Je()}}}}},rightPanel:nn,avatarImageSrc:ot,avatarAudioPower:Mt,avatarStatus:Qe,captionsText:yn})}if(h==="course-outline"){const Y=(s==null?void 0:s.languageCodes)||[],ne=(s==null?void 0:s.selectedLanguage)||(s==null?void 0:s.defaultLanguageCode)||null,Te={audioDevices:bn,currentMicrophoneId:(s==null?void 0:s.preferredMicrophoneDeviceId)||null,isMicrophoneEnabled:!g&&((s==null?void 0:s.isMicShared)??!1),isScreenShareActive:Si,widgetState:x?"chat":null,canPublishData:!0,browserSupportsScreenSharing:In,onMicDeviceSelect:async ie=>{e.client&&(e.client.preferredMicrophoneDeviceId=ie),s&&ie&&await s.switchMicrophoneDevice(ie),it()},onMicToggle:async()=>{s!=null&&s.isMicShared?g?(await s.unmuteMicrophone(),y(!1)):(await s.muteMicrophone(),y(!0)):await(s==null?void 0:s.shareMicrophone())},onChatToggle:()=>{v(!x)},onLeave:()=>{s==null||s.stop()},onScreenShareToggle:jn,languages:Y,selectedLanguage:ne,defaultLanguageCode:s==null?void 0:s.defaultLanguageCode,isMultilingual:(s==null?void 0:s.isMultilingual)??!1,onLanguageChange:ie=>{s==null||s.setLanguage(ie)},isLanguageSelectorEnabled:!0,...x?{screenShareButtonVariant:"compact"}:{}},st=x?f.jsx(N3,{messages:(s==null?void 0:s.chatMessages)??[],localIdentity:((Kl=s==null?void 0:s.room)==null?void 0:Kl.localParticipant.identity)??(typeof(s==null?void 0:s.identity)=="string"?s.identity:null),onSend:async ie=>{var Ne,Yt,qn,oi;if(s){const Hn=Date.now();s.appendChatMessage({timestamp:Hn,message:ie,from:{identity:((Yt=(Ne=s.room)==null?void 0:Ne.localParticipant)==null?void 0:Yt.identity)??null,name:((oi=(qn=s.room)==null?void 0:qn.localParticipant)==null?void 0:oi.name)??null},isAgent:!1}),await s.say(ie)}},onClose:()=>v(!1)}):void 0,xe=!!c,Ae=!U,pt=async()=>{if(!(!(s!=null&&s.endCourse)||K)){P(!0);try{await s.endCourse("back_to_courses")}catch(ie){console.error("[obi-sdk] failed to end course",ie),P(!1)}}},nn=f.jsx(RV,{steps:Fn,currentStep:Gl,hideTrailingConclusionStep:Ao,onStepClick:Yr,showBackToCourses:Ae,...Ae?{onBackToCoursesConfirm:pt,backToCoursesDisabled:K}:{}});return f.jsx(L3,{open:!0,onClose:()=>s==null?void 0:s.stop(),courses:[],controlBarProps:Te,middlePanel:nn,rightPanel:st,isCourseOutlineOpen:xe,onReturnToPiP:xe?()=>p("pip"):void 0,avatarImageSrc:ot,avatarAudioPower:Mt,avatarStatus:Qe,captionsText:yn})}if(h==="pip"){const Y=(s==null?void 0:s.languageCodes)||[],ne=(s==null?void 0:s.selectedLanguage)||(s==null?void 0:s.defaultLanguageCode)||null,Te=280,st=250,xe=16,Ae={x:window.innerWidth-Te-xe,y:window.innerHeight-st-xe},pt={isMicrophoneEnabled:!g&&((s==null?void 0:s.isMicShared)??!1),isChatOpen:x,isScreenShareActive:Si,onMicToggle:async()=>{s!=null&&s.isMicShared?g?(await s.unmuteMicrophone(),y(!1)):(await s.muteMicrophone(),y(!0)):await(s==null?void 0:s.shareMicrophone())},onChatToggle:()=>v(ie=>!ie),onScreenShareToggle:jn,onLeave:()=>{s==null||s.stop()},languages:Y,selectedLanguage:ne,defaultLanguageCode:s==null?void 0:s.defaultLanguageCode,isMultilingual:(s==null?void 0:s.isMultilingual)??!1,onLanguageChange:ie=>{s==null||s.setLanguage(ie)},isLanguageSelectorEnabled:!0},nn=x?f.jsx($V,{messages:(s==null?void 0:s.chatMessages)??[],localIdentity:((K3=s==null?void 0:s.room)==null?void 0:K3.localParticipant.identity)??(typeof(s==null?void 0:s.identity)=="string"?s.identity:null),onSend:async ie=>{var Ne,Yt,qn,oi;if(s){const Hn=Date.now();s.appendChatMessage({timestamp:Hn,message:ie,from:{identity:((Yt=(Ne=s.room)==null?void 0:Ne.localParticipant)==null?void 0:Yt.identity)??null,name:((oi=(qn=s.room)==null?void 0:qn.localParticipant)==null?void 0:oi.name)??null},isAgent:!1}),await s.say(ie)}},testId:"pip-chat-panel"}):void 0;return f.jsx(sH,{initialPosition:Ae,onExit:()=>{be.current=!1,p("course-outline")},controlBarProps:pt,isCourseOutlineSelected:W&&!!c,onCourseOutlineToggle:c?()=>{L(ie=>!ie)}:void 0,isCaptionsEnabled:Q,onCaptionsToggle:()=>ce(ie=>!ie),courseOutline:c?{steps:Fn,currentStep:Gl,onStepClick:Yr,hideTrailingConclusionStep:Ao}:void 0,messagesPanel:nn,avatarFallbackProps:{audioPower:Mt,imageSrc:ot,status:Qe,captionsText:yn},screenshotUrl:te,cameraShotTrigger:V})}return null}function cW(t){var l,c;const{sdk:e,session:n,isBlacklisted:i}=t;if(i)return!1;const r=e.client;if(!r||r.state!=="ready"||(n??r.session??null))return!1;let o=e.isActive;return((l=r.product)==null?void 0:l.name)==="Canibuild"&&(o=!0),!(!o||(e.widgetDisplay??((c=r.product)==null?void 0:c.widget_display))==="invisible")}function j3(t,e){if(!t)return;const n=`obi-widget-course-progress-${t}`;if(e===null){localStorage.removeItem(n);return}try{const i={...e,timestamp:Date.now()};localStorage.setItem(n,JSON.stringify(i))}catch(i){console.error("[obi-sdk] failed to save course progress",i)}}function uW(t){if(!t)return null;const e=`obi-widget-course-progress-${t}`;try{const n=localStorage.getItem(e);if(!n)return null;const i=JSON.parse(n);if(typeof i.currentStep!="number"||typeof i.totalSteps!="number"||!Array.isArray(i.stepNames))return console.warn("[obi-sdk] invalid course progress data, clearing",i),localStorage.removeItem(e),null;const r=24*60*60*1e3;return i.timestamp&&Date.now()-i.timestamp>r?(localStorage.removeItem(e),null):{currentStep:i.currentStep,totalSteps:i.totalSteps,stepNames:i.stepNames}}catch(n){return console.error("[obi-sdk] failed to load course progress",n),localStorage.removeItem(e),null}}function B3(t){if(!t)return;const e=`obi-widget-course-progress-${t}`;try{localStorage.removeItem(e)}catch(n){console.error("[obi-sdk] failed to clear course progress",n)}}function dW(t){const[e,n]=w.useState(()=>ys(t));return w.useEffect(()=>{n(ys(t))},[t]),w.useEffect(()=>{const i=()=>{n(ys(t))};return window.addEventListener("popstate",i),window.addEventListener("hashchange",i),()=>{window.removeEventListener("popstate",i),window.removeEventListener("hashchange",i)}},[t]),e}function hW(t){const[e,n]=w.useState(0),i=w.useRef(null),r=w.useRef(0),a=w.useRef(0);return w.useEffect(()=>{if(!t){n(0),r.current=0,a.current=0;return}const o=()=>{const s=t.audioSpectrum();let l=0;if(s&&s.length>0){let b=0;for(let m=0;m<s.length;m++)b+=s[m];l=Math.min(1,Math.max(0,b/s.length))}const c=r.current,d=l>=c?.7:.15,h=c*d+l*(1-d);r.current=h;const p=h<.05?0:Math.min(1,h);Math.abs(p-a.current)>.01&&(a.current=p,n(p)),i.current=requestAnimationFrame(o)};return i.current=requestAnimationFrame(o),()=>{i.current&&cancelAnimationFrame(i.current)}},[t]),e}function fW(){const[t,e]=w.useState({audioDevices:[]});return w.useEffect(()=>{var i;if(typeof navigator>"u"||!((i=navigator.mediaDevices)!=null&&i.enumerateDevices))return;const n=()=>{navigator.mediaDevices.enumerateDevices().then(r=>{e({audioDevices:r.filter(a=>a.kind==="audioinput")})})};return n(),navigator.mediaDevices.addEventListener("devicechange",n),()=>navigator.mediaDevices.removeEventListener("devicechange",n)},[]),t}function U3(){const t=window.location.hostname;return t.endsWith(".clinic1.com")||t==="getcor.ai"||t==="getcor.io"||t==="localhost"||t==="127.0.0.1"||t==="::1"}const z3=U3();function pW(t){if(document.querySelector("#obi-host")||document.querySelector("obi-widget"))return;mW();const e=document.createElement("div");e.id="obi-host",e.style.position="fixed",e.style.zIndex="9999",document.body.appendChild(e);const n=e.attachShadow({mode:"open"}),i=document.createElement("div");i.id="obi-container",n.appendChild(i);const r=new CSSStyleSheet;r.replaceSync(MB);const a=[r];if(z3){const s=new CSSStyleSheet;s.replaceSync(AB),a.push(s);const l=new CSSStyleSheet;l.replaceSync(OB),a.push(l)}else{const s=new CSSStyleSheet;s.replaceSync(NB),a.push(s)}n.adoptedStyleSheets=a;const o=RB.createRoot(i);z3?o.render(f.jsx(lW,{sdk:t,shadowHost:e})):o.render(f.jsx(LB,{sdk:t,shadowHost:e})),console.log("[obi-sdk] widget mounted")}function mW(){F3("https://fonts.cdnfonts.com/css/satoshi"),F3("https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap")}function F3(t){const e=document.createElement("link");e.href=t,e.rel="stylesheet",document.head.appendChild(e)}const q3="49206C6F7665204F6269_session",H3="obi-url-params",ey="obi-client-heartbeat",gW=5e3,V3=4e4,G3=15e3;function vW(){return U3()?"meet":"sdk"}class bW extends Ep{constructor(e){super(),this.client=null,this.isActive=!1,this.primaryColour="#9500FF",this.passivePlanUuid=null,this.commandLog=[],this.commandQueue=[],this._resumed=!1,this.heartbeatInterval=null,this.dispatchCommand=(n,i)=>{var r,a,o,s,l;switch(this.commandLog.push({commandType:n,args:i}),n){case"update":this.updateConfig(i);break;case"startSession":{if(i!=null&&i.planUuid){const c=(((r=this.client)==null?void 0:r.plans)||[]).find(u=>u.uuid===i.planUuid)||null;if(!c){console.warn("[obi] startSession command requires a valid planUuid",i);return}(o=(a=this.client)==null?void 0:a.selectPlan)==null||o.call(a,c)}this.updateActive(!0);break}case"stopSession":(l=(s=this.client)==null?void 0:s.stopSession)==null||l.call(s);break;case"say":this.say(i);break;default:console.warn("[obi] unknown command",{commandType:n,args:i})}},e&&this.createClient(e),this.parsePassiveParams()}async createClient(e){if(this.client){this.client.appToken!==e&&console.warn("[obi] client already exists with different app token");return}let n=null;const i=vW(),r=this.load();if(r)try{const a=this.parsePersistedSessionMetadata(r),o=a&&this.isPersistedSessionStale(a);o!=null&&o.stale&&a?(this.trackStaleSessionDiscard(a.sessionUuid,o.ageMs,o.reason),this.clearCachedClient()):(n=wh.deserialise(r,e,i,{apiBaseUrl:"https://staging.coragents.ai",captureScreen:this.captureScreen.bind(this)}),n?this._resumed=!0:this.clearCachedClient())}catch(a){console.error("[obi] error loading cached client",a),this.clearCachedClient()}n||(n=new wh(e,i,{apiBaseUrl:"https://staging.coragents.ai",captureScreen:this.captureScreen.bind(this)})),this.client=n,this.client.session&&this.startHeartbeat(this.client.session.sessionUuid),this.client.on("stateChanged",a=>{var o,s,l,c,u,d,h,p,b,m;a==="ready"&&this.updateConfig({isActive:((o=window==null?void 0:window.obiWidgetConfig)==null?void 0:o.isActive)??((s=this.client)==null?void 0:s.showWidget),primaryColour:((c=(l=this.client)==null?void 0:l.product)==null?void 0:c.primary_color)||"#9500FF",widgetDisplay:((u=window==null?void 0:window.obiWidgetConfig)==null?void 0:u.widgetDisplay)||((h=(d=this.client)==null?void 0:d.product)==null?void 0:h.widget_display)||"regular",completedWidgetDisplay:((p=window==null?void 0:window.obiWidgetConfig)==null?void 0:p.completedWidgetDisplay)||((m=(b=this.client)==null?void 0:b.product)==null?void 0:m.completed_widget_display)||"regular"})}),this.client.on("sessionStarted",()=>{var a,o;this.save(),this.startHeartbeat(((o=(a=this.client)==null?void 0:a.session)==null?void 0:o.sessionUuid)||null),this.passivePlanUuid=null}),this.client.on("sessionStopped",()=>{this.clearCachedClient(),this.passivePlanUuid=null}),this.client.on("sessionShutdown",()=>{this.clearCachedClient()}),this.client.on("trackEvent",(a,o)=>{}),this.client.session&&(this.client.session.isPaused,this.client.resumeSession(a=>{a.on("stateChanged",o=>{o!=="disconnecting"&&o!=="disconnected"&&o!=="error"&&o!=="connecting"&&this.save()}),a.on("paused",()=>{this.save()}),a.on("unpaused",()=>{this.save()})}))}_maybeActOnServerEngagement(){var s;const e=this.client;if(!e||e.state!=="ready")return;const n=e.product,i=(s=e.engagement)==null?void 0:s.style;if(!i||n&&ys(n.widget_url_blacklist||[])||!e.showWidget)return;const r=e.plans||[],a=e.planIsCompleted||[],o=r.length>0&&a.filter(Boolean).length===r.length;if(!(r.length===0||o)){if(i==="modal"){const l=a.findIndex(u=>!u),c=l>=0?r[l]:null;c&&e.selectPlan(c)}else i==="popover"&&setTimeout(()=>{this.showMessage("Don't forget to complete your onboarding",{autoCloseMs:1e4})},1e3);try{sa().track("engagement-prompt-shown",{style:i})}catch{}}}async initialise(e={}){var n;this.commandQueue=e.queuedCommands||[],this._resumed?(this._resumed=!1,this.dispatchCommandQueue()):this.client?this.client.initialise({planUuid:this.passivePlanUuid||void 0,identity:((n=window==null?void 0:window.obiWidgetConfig)==null?void 0:n.user)||void 0}).then(()=>{this.emit("initialised");try{this._maybeActOnServerEngagement()}catch{}this.dispatchCommandQueue()}).catch(i=>{console.error("[obi] error initialising client",i),this.emit("error",i)}):this.dispatchCommandQueue()}async updateConfig(e){e.apiKey!==void 0&&await this.updateAppToken(e.apiKey),this.updateActive(e.isActive),this.updatePrimaryColour(e.primaryColour),this.updateWidgetDisplay(e.widgetDisplay),this.updateCompletedWidgetDisplay(e.completedWidgetDisplay),this.updateWidgetPosition(e.widgetPosition),e.user!==void 0&&await this.updateIdentity(e.user),this.updateShowMenu(e.showMenu),this.emit("configUpdated")}async updateAppToken(e){var n;e===void 0||e==((n=this.client)==null?void 0:n.appToken)||(this.passivePlanUuid,await this.createClient(e),this.client&&await this.client.initialise({planUuid:this.passivePlanUuid||void 0}).then(()=>{this.emit("initialised");try{this._maybeActOnServerEngagement()}catch{}}).catch(i=>{console.error("[obi] error initialising client",i),this.emit("error",i)}))}updateActive(e){e===void 0||e==this.isActive||(this.isActive=e)}updatePrimaryColour(e){e===void 0||e==this.primaryColour||(this.primaryColour=e)}updateWidgetDisplay(e){e===void 0||e==this.widgetDisplay||(this.widgetDisplay=e)}updateCompletedWidgetDisplay(e){e===void 0||e==this.completedWidgetDisplay||(this.completedWidgetDisplay=e)}updateWidgetPosition(e){e===void 0||e==this.widgetPosition||(this.widgetPosition=e)}async updateIdentity(e){var i,r;if(e===void 0||e==((i=this.client)==null?void 0:i.identity))return;(r=this.client)==null||r.identity;let n=e?{...e,extra:{...e,...(e==null?void 0:e.extra)||{}}}:void 0;await this.client.initialise({identity:n,planUuid:this.passivePlanUuid||void 0}).then(()=>{this.emit("initialised");try{this._maybeActOnServerEngagement()}catch{}}).catch(a=>{console.error("[obi] error initialising client",a),this.emit("error",a)}),e!=null&&e.email&&sa().identify((e==null?void 0:e.email)||"",n)}updateShowMenu(e){e!==void 0&&this.emit("showMenu",e)}async say(e){var n,i,r;await((r=(i=(n=this.client)==null?void 0:n.session)==null?void 0:i.say)==null?void 0:r.call(i,e))}async startSession(e){await this.client.startSession(this.client.selectedPlanUuid||null,n=>{n.on("stateChanged",i=>{i!=="disconnecting"&&i!=="disconnected"&&i!=="error"&&i!=="connecting"&&this.save()}),n.on("paused",()=>{this.save()}),n.on("unpaused",()=>{this.save()})},e)}dispatchCommandQueue(){const e=this.commandQueue;this.commandQueue=[],e.forEach(n=>{try{this.dispatchCommand(n[0],n[1]||[])}catch(i){console.error("[obi] error dispatching command",i)}})}parsePassiveParams(){if(this.passivePlanUuid){this.passivePlanUuid;return}let e={};e=JSON.parse(localStorage.getItem(H3)||"{}"),Object.keys(e).length===0&&new URLSearchParams(window.location.search).forEach((a,o)=>{e[o]=a});const n=e[q3];if(!n)return null;const i=new URL(window.location.href);i.searchParams.delete(q3),window.history.replaceState({},"",i.toString()),i.toString(),localStorage.removeItem(H3),this.passivePlanUuid=n}mountWidget(){pW(this)}showMessage(e,n){try{this.emit("showMessage",{text:e,autoCloseMs:n==null?void 0:n.autoCloseMs})}catch{}}async captureScreen(){try{await xO(async()=>(this.graphemes||(this.graphemes=await this.client.api.getGraphemes()),this.graphemes.data.text_segmentation)),await mR(async()=>(this.graphemes||(this.graphemes=await this.client.api.getGraphemes()),this.graphemes.data.css_line_breaks))}catch(e){throw console.error("[obi] error initialising unicode trie",e),e}try{return(await ZN(document.documentElement,{useCORS:!0,allowTaint:!0,foreignObjectRendering:!0})).toDataURL("image/png")}catch(e){throw console.error("[obi] error capturing screen",e),e}}save(){var n;const e=((n=this.client)==null?void 0:n.serialise())||"";localStorage.setItem("obi-client",e)}load(){return localStorage.getItem("obi-client")}parsePersistedSessionMetadata(e){const n=JSON.parse(e),i=this.parseTimestampMs(n.serialisedAt);if(!n.session)return null;let r=null;if(typeof n.session=="string")try{r=JSON.parse(n.session)}catch{return null}else typeof n.session=="object"&&(r=n.session);return r?{sessionUuid:typeof r.sessionUuid=="string"?r.sessionUuid:null,startedAtMs:this.parseTimestampMs(r.startedAt),serialisedAtMs:i}:null}isPersistedSessionStale(e){const n=Date.now(),i=this.readHeartbeat();if(i&&i.sessionUuid&&e.sessionUuid&&i.sessionUuid===e.sessionUuid){const s=Math.max(0,n-i.updatedAtMs);return{stale:s>V3,reason:s>V3?"heartbeat-stale":"heartbeat-fresh",ageMs:s}}const r=[e.serialisedAtMs,e.startedAtMs].filter(s=>typeof s=="number"&&Number.isFinite(s));if(r.length===0)return{stale:!0,reason:"fallback-missing-timestamps",ageMs:null};const a=Math.max(...r),o=Math.max(0,n-a);return{stale:o>G3,reason:o>G3?"fallback-too-old":"fallback-recent",ageMs:o}}parseTimestampMs(e){if(typeof e=="number")return e;if(typeof e=="string"){const n=Number(e);if(!Number.isNaN(n))return n;const i=Date.parse(e);return Number.isFinite(i)?i:null}return null}readHeartbeat(){const e=localStorage.getItem(ey);if(!e)return null;try{return JSON.parse(e)}catch{return null}}trackStaleSessionDiscard(e,n,i){try{sa().track("stale-session-discarded",{sessionUuid:e||void 0,ageMs:n??void 0,reason:i})}catch{}}startHeartbeat(e){if(!e){this.clearHeartbeat();return}this.stopHeartbeat(),this.writeHeartbeat(e),this.heartbeatInterval=setInterval(()=>{this.writeHeartbeat(e)},gW)}stopHeartbeat(){this.heartbeatInterval&&(clearInterval(this.heartbeatInterval),this.heartbeatInterval=null)}writeHeartbeat(e){const n={sessionUuid:e,updatedAtMs:Date.now()};localStorage.setItem(ey,JSON.stringify(n))}clearHeartbeat(){this.stopHeartbeat(),localStorage.removeItem(ey)}clearCachedClient(){this.clearHeartbeat(),localStorage.removeItem("obi-client")}}async function W3(t,e){let n;try{n=window}catch{console.warn("[obi] no window object found"),n={}}return yW({appToken:t,window:n,init:e})}async function yW({appToken:t,window:e,init:n}){var a,o;if(e.obi){console.warn("[obi] obi object already found on window, skipping");return}n&&n(),t||(t=(a=e==null?void 0:e.obiWidgetConfig)==null?void 0:a.apiKey);let i;try{i=((o=e.ObiSDK)==null?void 0:o.q)||[]}catch{i=[]}const r=new bW(t);return e.ObiSDK=r.dispatchCommand,await r.initialise({queuedCommands:i}),e.obi=r,r.mountWidget(),r}function Y3(){}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{W3(void 0,Y3)}):W3(void 0,Y3)})();
133
+ `);for(let s=i;s<o.length;s++){const l=o[s];if(l.length>1024)continue;const c=M3.test(l)?l.replace(M3,"$1"):l;if(!c.match(/\S*Error: /)){for(const u of e){const d=u(c);if(d){a.push(d);break}}if(a.length>=O3+r)break}}return qG(a.slice(r))}}function qG(t){if(!t.length)return[];const e=Array.from(t);return/sentryWrapped/.test(kp(e).function||"")&&e.pop(),e.reverse(),D3.test(kp(e).function||"")&&(e.pop(),D3.test(kp(e).function||"")&&e.pop()),e.slice(0,O3).map(n=>({...n,filename:n.filename||kp(e).filename,function:n.function||Hl}))}function kp(t){return t[t.length-1]||{}}typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;const HG=30,VG=50;function Qb(t,e,n,i){const r={filename:t,function:e==="<anonymous>"?Hl:e,in_app:!0};return n!==void 0&&(r.lineno=n),i!==void 0&&(r.colno=i),r}const GG=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,WG=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,YG=/\((\S*)(?::(\d+))(?::(\d+))\)/,KG=t=>{const e=GG.exec(t);if(e){const[,i,r,a]=e;return Qb(i,Hl,+r,+a)}const n=WG.exec(t);if(n){if(n[2]&&n[2].indexOf("eval")===0){const a=YG.exec(n[2]);a&&(n[2]=a[1],n[3]=a[2],n[4]=a[3])}const[i,r]=P3(n[1]||Hl,n[2]);return Qb(r,i,n[3]?+n[3]:void 0,n[4]?+n[4]:void 0)}},XG=[HG,KG],$G=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,JG=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i;FG(...[XG,[VG,t=>{const e=$G.exec(t);if(e){if(e[3]&&e[3].indexOf(" > eval")>-1){const r=JG.exec(e[3]);r&&(e[1]=e[1]||"eval",e[3]=r[1],e[4]=r[2],e[5]="")}let n=e[3],i=e[1]||Hl;return[i,n]=P3(i,n),Qb(n,i,e[4]?+e[4]:void 0,e[5]?+e[5]:void 0)}}]]);const P3=(t,e)=>{const n=t.indexOf("safari-extension")!==-1,i=t.indexOf("safari-web-extension")!==-1;return n||i?[t.indexOf("@")!==-1?t.split("@")[0]:Hl,n?`safari-extension:${e}`:`safari-web-extension:${e}`]:[t,e]};typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;const ir={shell:"_shell_8bsnr_1",layout:"_layout_8bsnr_11",layoutThree:"_layoutThree_8bsnr_23",leftPanel:"_leftPanel_8bsnr_27",middlePanel:"_middlePanel_8bsnr_36",rightPanel:"_rightPanel_8bsnr_37",videoFrame:"_videoFrame_8bsnr_41",captions:"_captions_8bsnr_52",controls:"_controls_8bsnr_58",coursePanel:"_coursePanel_8bsnr_71",returnToPiPOverlay:"_returnToPiPOverlay_8bsnr_82",returnToPiPButton:"_returnToPiPButton_8bsnr_94"};function Zb(...t){return t.filter(Boolean).join(" ")}function QG(t){const{captionsText:e,avatarAudioPower:n=0,avatarImageSrc:i,avatarAriaLabel:r,avatarStatus:a,controlBarProps:o,courses:s,coursePanelProps:l,middlePanel:c,rightPanel:u,isCourseOutlineOpen:d,onReturnToPiP:h,className:p}=t;return f.jsx("div",{className:Zb(ir.shell,p),"data-testid":"course-dialog-content",children:f.jsxs("div",{className:Zb(ir.layout,u?ir.layoutThree:null),children:[f.jsxs("div",{className:ir.leftPanel,children:[f.jsxs("div",{className:ir.videoFrame,children:[d&&h&&f.jsx("div",{className:ir.returnToPiPOverlay,children:f.jsx("button",{type:"button",className:ir.returnToPiPButton,onClick:h,"aria-label":"Return to PiP","data-testid":"course-return-to-pip",children:f.jsx(GB,{size:14})})}),f.jsx(hH,{className:ir.captions,text:e,children:f.jsx(x3,{audioPower:n,size:"lg",background:"flat",imageSrc:i,ariaLabel:r??"Agent avatar placeholder",status:a})})]}),f.jsx("div",{className:ir.controls,children:f.jsx(BF,{...o})})]}),u?f.jsx("div",{className:ir.rightPanel,"data-testid":"course-dialog-right-panel",children:u}):null,f.jsx("div",{className:ir.middlePanel,"data-testid":"course-dialog-middle-panel",children:c??f.jsx(YH,{...l,courses:s,className:Zb(ir.coursePanel,l==null?void 0:l.className)})})]})})}function L3(t){const{open:e,onClose:n,dialogProps:i,...r}=t;return f.jsx(HE,{open:e,onClose:n,variant:"ghost",...i,children:f.jsx(QG,{...r})})}const ZG=80,eW=500,tW=1e3;function nW(t,e){const{delayMs:n=0}=e??{},r=t.filter(m=>{var g;const S=(g=m.participantInfo)==null?void 0:g.identity;return(S==null?void 0:S.startsWith("agent-"))??!1}).map(m=>m.text??"").join(" ").trim(),[a,o]=w.useState(""),[s,l]=w.useState(!1),c=w.useRef(""),u=w.useRef(null),d=w.useRef(null),h=w.useRef(null),p=m=>{h.current&&(clearTimeout(h.current),h.current=null),n>0?h.current=setTimeout(()=>{o(m)},n):o(m)},b=(m,S)=>m.startsWith(S)?m.slice(S.length).trim():m.trim();return w.useEffect(()=>{if(d.current&&(clearTimeout(d.current),d.current=null),s)return;const m=b(r,c.current);p(m),m.length>ZG?(l(!0),u.current=setTimeout(()=>{l(!1),c.current=r},eW+n)):m.length>0&&(d.current=setTimeout(()=>{c.current=r,p("")},tW+n))},[r,s,n]),w.useEffect(()=>()=>{u.current&&clearTimeout(u.current),d.current&&clearTimeout(d.current),h.current&&clearTimeout(h.current)},[]),{caption:a,hasCaption:a.length>0}}const kr={layout:"_layout_k1q6c_1",left:"_left_k1q6c_10",copy:"_copy_k1q6c_17",description:"_description_k1q6c_25",descriptionScroller:"_descriptionScroller_k1q6c_31",cta:"_cta_k1q6c_36",disclaimer:"_disclaimer_k1q6c_43",right:"_right_k1q6c_47",mediaPanel:"_mediaPanel_k1q6c_56",agentStill:"_agentStill_k1q6c_63",dialogWithSmallClose:"_dialogWithSmallClose_k1q6c_88"};function iW(t){const{open:e,onClose:n,onStart:i,agentName:r,agentSubtitle:a,description:o,startLabel:s="Start Now",disclaimer:l="Sessions are securely recorded for quality improvement purposes.",showCloseButton:c=!1,isStarting:u=!1,greetingVideoSrc:d}=t;return f.jsx(HE,{open:e,onClose:n,size:"large",showCloseButton:c,className:kr.dialogWithSmallClose,children:f.jsxs("div",{className:kr.layout,children:[f.jsxs("div",{className:kr.left,children:[f.jsxs("div",{className:kr.copy,children:[f.jsx(xi,{variant:"heading",children:r}),f.jsx(xi,{variant:"subheading",children:a}),f.jsx(xi,{variant:"muted",as:"div",className:kr.description,children:f.jsx(zl,{className:kr.descriptionScroller,children:f.jsx(nF,{content:o})})})]}),f.jsxs("div",{className:kr.cta,children:[f.jsx(_s,{type:"button",size:"lg",fullWidth:!0,onClick:i,isLoading:u,children:s}),f.jsx(xi,{variant:"subscript",as:"p",className:kr.disclaimer,children:l})]})]}),f.jsx(PG,{showAboveWidth:"md",children:f.jsx("div",{className:kr.right,children:f.jsx(qu,{className:kr.mediaPanel,children:f.jsx(zG,{agentName:r,greetingVideoSrc:d,className:kr.agentStill})})})})]})})}const rW={launcherPill:"_launcherPill_1fhyr_1"};function aW(t){const{label:e,onClick:n}=t;return f.jsx("button",{type:"button",className:rW.launcherPill,onClick:n,"data-testid":"ai-coach-pill",children:e})}const I3="__ama_course__",oW="ama_course",sW=3e4;function lW(t){var No,Oo,Wl,_n,xn,Mo,Do,Kr,Po,Ut,Lo,Io,jo,Bo,Yl,_,I,M,pe,Le,ve,zt,_t,xt,Xr,Ie,Uo,Kl,K3;const{sdk:e,shadowHost:n}=t,i=!!e.passivePlanUuid,r=i?((No=e.client)==null?void 0:No.selectedPlanUuid)??null:null,a=((Oo=e.client)==null?void 0:Oo.session)??null,o=!!a&&(i&&!!r||!!((Wl=e.client)!=null&&Wl.selectedPlanUuid)),[s,l]=w.useState(()=>a),[c,u]=w.useState(()=>a!=null&&a.sessionUuid?uW(a.sessionUuid):null),d=(()=>{var Y;return a?((Y=a.roomId)==null?void 0:Y.startsWith("obs-"))&&!c?"course-selection":"pip":r?"start-session":"hidden"})(),[h,p]=w.useState(()=>d),b=w.useRef(d),[m,S]=w.useState(!1),[g,y]=w.useState(!1),[x,v]=w.useState(!1),[k,T]=w.useState([]),[C,R]=w.useState(null),[A,N]=w.useState(null),[O,B]=w.useState(0),[W,L]=w.useState(!1),[K,P]=w.useState(!1),[V,X]=w.useState(0),[te,$]=w.useState(null),[z,Z]=w.useState([]),[Q,ce]=w.useState(!1),[j,ge]=w.useState(!1),[U,fe]=w.useState(()=>o),me=w.useRef(o),Rt=w.useRef(null),en=w.useRef(null),be=w.useRef(!1),qe=()=>{p(Y=>{const ne=Y==="course-selection",Te=Y==="course-outline"&&be.current;return ne||Te?(be.current=!1,L(!1),"pip"):Y})};w.useEffect(()=>{b.current=h},[h]),w.useEffect(()=>()=>{Rt.current&&clearTimeout(Rt.current)},[]);const bt=()=>{Rt.current&&(clearTimeout(Rt.current),Rt.current=null)},Je=()=>{bt(),en.current=null,N(Y=>Y===null?Y:null)},cn=Y=>{bt(),en.current=Y,N(Y),Rt.current=setTimeout(()=>{const ne=en.current===Y,Te=b.current==="course-selection";ne&&Te&&(en.current=null,N(null)),Rt.current=null},sW)},tn=dW((xn=(_n=e.client)==null?void 0:_n.product)==null?void 0:xn.widget_url_blacklist),Mt=hW(s),{audioDevices:bn}=fW();w.useEffect(()=>{s!=null&&s.sessionUuid&&j3(s.sessionUuid,c)},[c,s==null?void 0:s.sessionUuid]);const{caption:yn}=nW(z,{delayMs:0}),In=typeof navigator<"u"&&!!((Mo=navigator.mediaDevices)!=null&&Mo.getDisplayMedia),Si=((Kr=(Do=s==null?void 0:s.room)==null?void 0:Do.localParticipant)==null?void 0:Kr.isScreenShareEnabled)??!1,de=Y=>{var Ae;const ne=((Ae=e.client)==null?void 0:Ae.identity)??Y.identity,Te=typeof(ne==null?void 0:ne.first_name)=="string"?ne.first_name.trim():"",st=typeof(ne==null?void 0:ne.last_name)=="string"?ne.last_name.trim():"",xe=typeof(ne==null?void 0:ne.email)=="string"&&ne.email.trim().length>0?ne.email.trim():"";return{firstName:Te,lastName:st,email:xe}},We=Y=>{const{firstName:ne,lastName:Te,email:st}=de(Y),xe=[ne,Te,st].map(pt=>pt.trim());return xe.some(pt=>pt.length>0)?xe.join(":"):""},Ce=Y=>{const{firstName:ne,lastName:Te,email:st}=de(Y),xe=[ne,Te].filter(Boolean).join(" ").trim();return{name:xe.length>0?xe:void 0,email:st.length>0?st:void 0,screenShareSupported:In}},Qe=(()=>{if(s!=null&&s.speakingState){if(s.speakingState==="thinking")return"thinking";if(s.speakingState==="busy")return"searching"}})(),ot=((Ut=(Po=e.client)==null?void 0:Po.product)==null?void 0:Ut.avatar_image_url)||((Io=(Lo=e.client)==null?void 0:Lo.product)==null?void 0:Io.logo_url)||void 0,ki=((Bo=(jo=e.client)==null?void 0:jo.product)==null?void 0:Bo.greeting_video_url)||void 0,Ii=cW({sdk:e,session:s,isBlacklisted:tn}),Wr=!i&&Ii,q=!!(s??((Yl=e.client)==null?void 0:Yl.session)??null),ae=(s==null?void 0:s.clientType)==="meet"?We(s):"",he=(I=(_=e.client)==null?void 0:_.product)==null?void 0:I.assistant_subtitle,Pe=typeof he=="string"&&he.trim().length>0?he:"Onboarding Assistant",it=()=>B(Y=>Y+1),jn=async()=>{var ne,Te;if(!s)return;const Y=((Te=(ne=s.room)==null?void 0:ne.localParticipant)==null?void 0:Te.isScreenShareEnabled)??!1;try{Y?await s.setScreenShareEnabled(!1):await s.shareScreen()}catch(st){console.error("[obi-sdk] failed to toggle screen share",st)}finally{it()}},Ti=w.useRef(null),Bn=w.useRef(null),Un=w.useRef(!1),Wt=w.useRef({session:null,sessionUuid:null,started:!1}),ai=w.useRef(null),zn=w.useRef(new WeakMap),Vl=(Y,ne)=>{if(!ne)return;let Te=zn.current.get(Y);Te||(Te=new Set,zn.current.set(Y,Te)),Te.add(ne)},ks=Y=>{if(!Y||Ti.current===Y)return;Bn.current&&(Bn.current(),Bn.current=null);const ne=()=>it(),Te=ie=>{u(ie),Je(),Y!=null&&Y.sessionUuid&&j3(Y.sessionUuid,ie),p(Ne=>Ne==="pip"||Ne==="course-outline"?Ne:Ne==="course-selection"?(be.current=!0,"course-outline"):Ne)},st=ie=>{Je(),T(ie.courses),p("course-selection"),be.current=!1,u(null),Y!=null&&Y.sessionUuid&&B3(Y.sessionUuid),R(null),P(!1)},xe=(ie,Ne)=>{},Ae=ie=>{ie.isAgent},pt=ie=>{$(ie),X(Date.now())},nn=ie=>{if(!ie){$(null);return}$(ie),X(Date.now())};Y.on("stateChanged",ne),Y.on("speakingStateChanged",ne),Y.on("paused",ne),Y.on("unpaused",ne),Y.on("chatMessagesChanged",ne),Y.on("chatMessageReceived",Ae),Y.on("courseProgress",Te),Y.on("courseSelection",st),Y.on("transcript",xe),Y.on("screenCaptured",pt),Y.on("screenCaptureNotification",nn),Y.on("captions",Z),Y.on("introductionComplete",qe),Ti.current=Y,Bn.current=()=>{Y.off("stateChanged",ne),Y.off("speakingStateChanged",ne),Y.off("paused",ne),Y.off("unpaused",ne),Y.off("chatMessagesChanged",ne),Y.off("chatMessageReceived",Ae),Y.off("courseProgress",Te),Y.off("courseSelection",st),Y.off("transcript",xe),Y.off("screenCaptured",pt),Y.off("screenCaptureNotification",nn),Y.off("captions",Z),Y.off("introductionComplete",qe)}},Se=Y=>{var Te;return Y?((Te=Y.roomId)==null?void 0:Te.startsWith("obs-"))&&!c?"course-selection":"pip":"hidden"};w.useEffect(()=>{const Y=()=>{ai.current&&(ai.current(),ai.current=null)},ne=xe=>{if(xe.clientType!=="meet")return;if(Wt.current.session&&Wt.current.session===xe||!!Wt.current.sessionUuid&&!!xe.sessionUuid&&Wt.current.sessionUuid===xe.sessionUuid){if(Wt.current.started||ai.current)return}else Wt.current={session:xe,sessionUuid:xe.sessionUuid??null,started:!1},Y();const pt=async()=>{Wt.current={session:xe,sessionUuid:xe.sessionUuid??null,started:!0};const Ne=We(xe);Ne&&Vl(xe,Ne);try{await xe.sendHumanJoined(Ce(xe))}catch(Yt){console.error("[obi-sdk] failed to send human_joined handshake",Yt)}},nn=(Ne,Yt)=>{Ne==="connecting"||Ne==="error"||(Y(),pt())},ie=xe.state;if(ie&&ie!=="connecting"&&ie!=="error"){pt();return}xe.on("stateChanged",nn),ai.current=()=>{xe.off("stateChanged",nn)}},Te=xe=>{var Ae,pt,nn,ie;if(xe)if((Ae=e.client)!=null&&Ae.session)p(Se(((nn=e.client)==null?void 0:nn.session)??null));else{const Yt=!!e.passivePlanUuid,qn=Yt&&!!((pt=e.client)!=null&&pt.selectedPlanUuid);if(Yt&&!qn)return;p("start-session")}else(ie=e.client)!=null&&ie.session||p("hidden")},st=()=>it();if(e.on("showMenu",Te),e.on("configUpdated",st),e.client){e.client.session&&(l(e.client.session),ks(e.client.session),p(Se(e.client.session))),e.client.on("sessionStarted",Ae=>{l(Ae),ks(Ae),Un.current=!1,S(!1),y(!1),v(!1),P(!1);const pt=me.current;me.current=!1,pt?(be.current=!0,p("course-outline")):(be.current=!1,p(Se(Ae))),sa().track("session-started",{planId:Ae.planId}),ne(Ae)}),e.client.on("sessionResumed",Ae=>{l(Ae),ks(Ae),Un.current=!1,S(!1),y(!1),v(!1),P(!1),be.current=!1,p(Se(Ae)),ne(Ae)});const xe=()=>{var nn;const Ae=(nn=e.client)==null?void 0:nn.session;Ae!=null&&Ae.sessionUuid&&B3(Ae.sessionUuid);const pt=Ti.current;Bn.current&&(Bn.current(),Bn.current=null),l(null),Ti.current=null,S(!1),y(!1),v(!1),P(!1),fe(!1),me.current=!1,Je(),be.current=!1,Y(),Wt.current={session:null,sessionUuid:null,started:!1},pt&&zn.current.delete(pt),Un.current||p("hidden")};e.client.on("sessionStopped",xe),e.client.on("sessionShutdown",xe),e.client.on("stateChanged",it)}return()=>{e.off("showMenu",Te),e.off("configUpdated",st),Bn.current&&Bn.current(),Y()}},[e]),w.useEffect(()=>{const Y=s;if(!Y||Y.clientType!=="meet")return;const ne=Y.state;if(!ne||ne==="connecting"||ne==="error"||!ae)return;const Te=zn.current.get(Y);Te!=null&&Te.has(ae)||(Vl(Y,ae),Y.sendHumanJoined(Ce(Y)).catch(st=>console.error("[obi-sdk] failed to send human_joined update",st)))},[In,ae,s,s==null?void 0:s.state]),w.useLayoutEffect(()=>{var Y,ne;(ne=(Y=e.client)==null?void 0:Y.product)!=null&&ne.primary_color&&n.style.setProperty("--obi-color-primary",e.client.product.primary_color)},[(pe=(M=e.client)==null?void 0:M.product)==null?void 0:pe.primary_color,n]),w.useEffect(()=>{if(i&&!tn&&!q){if(!r){p("hidden");return}p("start-session")}},[q,i,tn,r]),w.useEffect(()=>{var nn,ie;ge(!1);const Y=(nn=e.client)==null?void 0:nn.api,ne=(ie=e.client)==null?void 0:ie.product;if(!Y||!ne)return;const Te=(ne==null?void 0:ne.uuid)??(ne==null?void 0:ne.product_uuid),st=(ne==null?void 0:ne.slug)??(ne==null?void 0:ne.product_slug),xe=(ne==null?void 0:ne.id)??(ne==null?void 0:ne.product_id),Ae={};if(Te?Ae.product_uuid=Te:st?Ae.product_slug=st:xe!=null&&(Ae.product_id=String(xe)),Object.keys(Ae).length===0)return;let pt=!1;return Y.getFeatureFlags(Ae).then(Ne=>{if(pt)return;const qn=((Ne==null?void 0:Ne.data)??[]).find(ny=>(ny==null?void 0:ny.slug)===oW);if(!qn)return;const{user_enabled:oi,product_enabled:Hn,global_enabled:Tr}=qn;let ty=!!Tr;Hn!=null&&(ty=!!Hn),oi!=null&&(ty=!!oi),ge(ty)}).catch(Ne=>{console.error("[obi-sdk] failed to load AMA feature flag",Ne)}),()=>{pt=!0}},[(Le=e.client)==null?void 0:Le.api,(ve=e.client)==null?void 0:ve.product]);const Fn=(c==null?void 0:c.stepNames.map((Y,ne)=>({id:`step-${ne+1}`,title:Y})))??[],Gl=(c==null?void 0:c.currentStep)??null,Ao=!0,Yr=(Y,ne)=>{s==null||s.say(`Can we jump to the section about ${ne.title}?`)};if(tn||i&&!r&&!q)return null;if(h==="hidden")return Wr?f.jsx(aW,{label:Pe,onClick:()=>{e.updateShowMenu(!0)}}):null;if(h==="start-session"){const Y=(zt=e.client)==null?void 0:zt.product,ne=(_t=e.client)==null?void 0:_t.selectedPlan,Te=i&&!!r,st=i&&!!r||!!((xt=e.client)!=null&&xt.selectedPlanUuid),xe=(Y==null?void 0:Y.agent_name)||"Obi",Ae=(Y==null?void 0:Y.assistant_subtitle)||"AI Assistant",pt=Te&&(ne==null?void 0:ne.description)||(Y==null?void 0:Y.assistant_description)||"";return f.jsx(iW,{open:!0,onClose:()=>{S(!1),p("hidden")},onStart:()=>{me.current=st,fe(st),S(!0),e.startSession({withMicrophone:!0})},agentName:xe,agentSubtitle:Ae,description:pt,showCloseButton:!1,startLabel:"Start Session",isStarting:m,greetingVideoSrc:ki})}if(h==="course-selection"){const Y=(Xr=s==null?void 0:s.roomId)==null?void 0:Xr.startsWith("obs-"),ne=((Ie=e.client)==null?void 0:Ie.plans)||[],Te=Y&&k.length>0,st=Te?k.slice().sort((ie,Ne)=>ie.order!==void 0&&Ne.order!==void 0?ie.order-Ne.order:ie.order!==void 0?-1:Ne.order!==void 0?1:ie.name.localeCompare(Ne.name)).map(ie=>({id:ie.uuid,title:ie.name,description:ie.description||ie.overview||"",status:ie.completed?"completed":"available",duration:typeof ie.duration=="number"?`${ie.duration} min`:ie.duration})):ne.map(ie=>{var Ne,Yt;return{id:ie.uuid,title:ie.name,description:ie.description,status:(Yt=(Ne=e.client)==null?void 0:Ne.planIsCompleted)!=null&&Yt[ne.indexOf(ie)]?"completed":"available",duration:ie.estimated_duration?`${ie.estimated_duration} min`:void 0}});Te&&j&&st.push({id:I3,title:"Ask me anything",description:"Ask questions before choosing a course.",status:"available"});const xe=(s==null?void 0:s.languageCodes)||[],Ae=(s==null?void 0:s.selectedLanguage)||(s==null?void 0:s.defaultLanguageCode)||null,pt={audioDevices:bn,currentMicrophoneId:(s==null?void 0:s.preferredMicrophoneDeviceId)||null,isMicrophoneEnabled:!g&&((s==null?void 0:s.isMicShared)??!1),isScreenShareActive:Si,widgetState:x?"chat":null,canPublishData:!0,browserSupportsScreenSharing:In,onMicDeviceSelect:async ie=>{e.client&&(e.client.preferredMicrophoneDeviceId=ie),s&&ie&&await s.switchMicrophoneDevice(ie),it()},onMicToggle:async()=>{s!=null&&s.isMicShared?g?(await s.unmuteMicrophone(),y(!1)):(await s.muteMicrophone(),y(!0)):await(s==null?void 0:s.shareMicrophone())},onChatToggle:()=>{v(!x)},onLeave:()=>{s==null||s.stop()},onScreenShareToggle:jn,languages:xe,selectedLanguage:Ae,defaultLanguageCode:s==null?void 0:s.defaultLanguageCode,isMultilingual:(s==null?void 0:s.isMultilingual)??!1,onLanguageChange:ie=>{s==null||s.setLanguage(ie)},isLanguageSelectorEnabled:!0,...x?{screenShareButtonVariant:"compact"}:{}},nn=x?f.jsx(N3,{messages:(s==null?void 0:s.chatMessages)??[],localIdentity:((Uo=s==null?void 0:s.room)==null?void 0:Uo.localParticipant.identity)??(typeof(s==null?void 0:s.identity)=="string"?s.identity:null),onSend:async ie=>{var Ne,Yt,qn,oi;if(s){const Hn=Date.now();s.appendChatMessage({timestamp:Hn,message:ie,from:{identity:((Yt=(Ne=s.room)==null?void 0:Ne.localParticipant)==null?void 0:Yt.identity)??null,name:((oi=(qn=s.room)==null?void 0:qn.localParticipant)==null?void 0:oi.name)??null},isAgent:!1}),await s.say(ie)}},onClose:()=>v(!1)}):void 0;return f.jsx(L3,{open:!0,onClose:()=>s==null?void 0:s.stop(),courses:st,controlBarProps:pt,coursePanelProps:{selectedCourseIds:C?[C]:void 0,loadingCourseId:A,onCourseToggle:async ie=>{var Ne,Yt,qn,oi;if(!en.current)if(Te){if(ie===I3){cn(ie),R(ie);try{await((Ne=s==null?void 0:s.say)==null?void 0:Ne.call(s,"Please start an AMA session."))}catch(Tr){console.error("[obi-sdk] failed to start AMA course",Tr),Je(),R(null)}return}const Hn=k.find(Tr=>Tr.uuid===ie);if(Hn){cn(ie),R(ie);try{await((Yt=s==null?void 0:s.say)==null?void 0:Yt.call(s,`I'd like to take the ${Hn.name} course.`))}catch(Tr){console.error("[obi-sdk] failed to send course selection",Tr),Je(),R(null)}}}else{const Hn=ne.find(Tr=>Tr.uuid===ie);if(Hn){cn(ie),(qn=e.client)==null||qn.selectPlan(Hn),p("pip");try{await((oi=s==null?void 0:s.say)==null?void 0:oi.call(s,`I'd like to take the ${Hn.name} course.`))}catch(Tr){console.error("[obi-sdk] failed to send course selection",Tr),p("course-selection"),Je()}}}}},rightPanel:nn,avatarImageSrc:ot,avatarAudioPower:Mt,avatarStatus:Qe,captionsText:yn})}if(h==="course-outline"){const Y=(s==null?void 0:s.languageCodes)||[],ne=(s==null?void 0:s.selectedLanguage)||(s==null?void 0:s.defaultLanguageCode)||null,Te={audioDevices:bn,currentMicrophoneId:(s==null?void 0:s.preferredMicrophoneDeviceId)||null,isMicrophoneEnabled:!g&&((s==null?void 0:s.isMicShared)??!1),isScreenShareActive:Si,widgetState:x?"chat":null,canPublishData:!0,browserSupportsScreenSharing:In,onMicDeviceSelect:async ie=>{e.client&&(e.client.preferredMicrophoneDeviceId=ie),s&&ie&&await s.switchMicrophoneDevice(ie),it()},onMicToggle:async()=>{s!=null&&s.isMicShared?g?(await s.unmuteMicrophone(),y(!1)):(await s.muteMicrophone(),y(!0)):await(s==null?void 0:s.shareMicrophone())},onChatToggle:()=>{v(!x)},onLeave:()=>{s==null||s.stop()},onScreenShareToggle:jn,languages:Y,selectedLanguage:ne,defaultLanguageCode:s==null?void 0:s.defaultLanguageCode,isMultilingual:(s==null?void 0:s.isMultilingual)??!1,onLanguageChange:ie=>{s==null||s.setLanguage(ie)},isLanguageSelectorEnabled:!0,...x?{screenShareButtonVariant:"compact"}:{}},st=x?f.jsx(N3,{messages:(s==null?void 0:s.chatMessages)??[],localIdentity:((Kl=s==null?void 0:s.room)==null?void 0:Kl.localParticipant.identity)??(typeof(s==null?void 0:s.identity)=="string"?s.identity:null),onSend:async ie=>{var Ne,Yt,qn,oi;if(s){const Hn=Date.now();s.appendChatMessage({timestamp:Hn,message:ie,from:{identity:((Yt=(Ne=s.room)==null?void 0:Ne.localParticipant)==null?void 0:Yt.identity)??null,name:((oi=(qn=s.room)==null?void 0:qn.localParticipant)==null?void 0:oi.name)??null},isAgent:!1}),await s.say(ie)}},onClose:()=>v(!1)}):void 0,xe=!!c,Ae=!U,pt=async()=>{if(!(!(s!=null&&s.endCourse)||K)){P(!0);try{await s.endCourse("back_to_courses")}catch(ie){console.error("[obi-sdk] failed to end course",ie),P(!1)}}},nn=f.jsx(RV,{steps:Fn,currentStep:Gl,hideTrailingConclusionStep:Ao,onStepClick:Yr,showBackToCourses:Ae,...Ae?{onBackToCoursesConfirm:pt,backToCoursesDisabled:K}:{}});return f.jsx(L3,{open:!0,onClose:()=>s==null?void 0:s.stop(),courses:[],controlBarProps:Te,middlePanel:nn,rightPanel:st,isCourseOutlineOpen:xe,onReturnToPiP:xe?()=>p("pip"):void 0,avatarImageSrc:ot,avatarAudioPower:Mt,avatarStatus:Qe,captionsText:yn})}if(h==="pip"){const Y=(s==null?void 0:s.languageCodes)||[],ne=(s==null?void 0:s.selectedLanguage)||(s==null?void 0:s.defaultLanguageCode)||null,Te=280,st=250,xe=16,Ae={x:window.innerWidth-Te-xe,y:window.innerHeight-st-xe},pt={isMicrophoneEnabled:!g&&((s==null?void 0:s.isMicShared)??!1),isChatOpen:x,isScreenShareActive:Si,onMicToggle:async()=>{s!=null&&s.isMicShared?g?(await s.unmuteMicrophone(),y(!1)):(await s.muteMicrophone(),y(!0)):await(s==null?void 0:s.shareMicrophone())},onChatToggle:()=>v(ie=>!ie),onScreenShareToggle:jn,onLeave:()=>{s==null||s.stop()},languages:Y,selectedLanguage:ne,defaultLanguageCode:s==null?void 0:s.defaultLanguageCode,isMultilingual:(s==null?void 0:s.isMultilingual)??!1,onLanguageChange:ie=>{s==null||s.setLanguage(ie)},isLanguageSelectorEnabled:!0},nn=x?f.jsx($V,{messages:(s==null?void 0:s.chatMessages)??[],localIdentity:((K3=s==null?void 0:s.room)==null?void 0:K3.localParticipant.identity)??(typeof(s==null?void 0:s.identity)=="string"?s.identity:null),onSend:async ie=>{var Ne,Yt,qn,oi;if(s){const Hn=Date.now();s.appendChatMessage({timestamp:Hn,message:ie,from:{identity:((Yt=(Ne=s.room)==null?void 0:Ne.localParticipant)==null?void 0:Yt.identity)??null,name:((oi=(qn=s.room)==null?void 0:qn.localParticipant)==null?void 0:oi.name)??null},isAgent:!1}),await s.say(ie)}},testId:"pip-chat-panel"}):void 0;return f.jsx(sH,{initialPosition:Ae,onExit:()=>{be.current=!1,p("course-outline")},controlBarProps:pt,isCourseOutlineSelected:W&&!!c,onCourseOutlineToggle:c?()=>{L(ie=>!ie)}:void 0,isCaptionsEnabled:Q,onCaptionsToggle:()=>ce(ie=>!ie),courseOutline:c?{steps:Fn,currentStep:Gl,onStepClick:Yr,hideTrailingConclusionStep:Ao}:void 0,messagesPanel:nn,avatarFallbackProps:{audioPower:Mt,imageSrc:ot,status:Qe,captionsText:yn},screenshotUrl:te,cameraShotTrigger:V})}return null}function cW(t){var l,c;const{sdk:e,session:n,isBlacklisted:i}=t;if(i)return!1;const r=e.client;if(!r||r.state!=="ready"||(n??r.session??null))return!1;let o=e.isActive;return((l=r.product)==null?void 0:l.name)==="Canibuild"&&(o=!0),!(!o||(e.widgetDisplay??((c=r.product)==null?void 0:c.widget_display))==="invisible")}function j3(t,e){if(!t)return;const n=`obi-widget-course-progress-${t}`;if(e===null){localStorage.removeItem(n);return}try{const i={...e,timestamp:Date.now()};localStorage.setItem(n,JSON.stringify(i))}catch(i){console.error("[obi-sdk] failed to save course progress",i)}}function uW(t){if(!t)return null;const e=`obi-widget-course-progress-${t}`;try{const n=localStorage.getItem(e);if(!n)return null;const i=JSON.parse(n);if(typeof i.currentStep!="number"||typeof i.totalSteps!="number"||!Array.isArray(i.stepNames))return console.warn("[obi-sdk] invalid course progress data, clearing",i),localStorage.removeItem(e),null;const r=24*60*60*1e3;return i.timestamp&&Date.now()-i.timestamp>r?(localStorage.removeItem(e),null):{currentStep:i.currentStep,totalSteps:i.totalSteps,stepNames:i.stepNames}}catch(n){return console.error("[obi-sdk] failed to load course progress",n),localStorage.removeItem(e),null}}function B3(t){if(!t)return;const e=`obi-widget-course-progress-${t}`;try{localStorage.removeItem(e)}catch(n){console.error("[obi-sdk] failed to clear course progress",n)}}function dW(t){const[e,n]=w.useState(()=>ys(t));return w.useEffect(()=>{n(ys(t))},[t]),w.useEffect(()=>{const i=()=>{n(ys(t))};return window.addEventListener("popstate",i),window.addEventListener("hashchange",i),()=>{window.removeEventListener("popstate",i),window.removeEventListener("hashchange",i)}},[t]),e}function hW(t){const[e,n]=w.useState(0),i=w.useRef(null),r=w.useRef(0),a=w.useRef(0);return w.useEffect(()=>{if(!t){n(0),r.current=0,a.current=0;return}const o=()=>{const s=t.audioSpectrum();let l=0;if(s&&s.length>0){let b=0;for(let m=0;m<s.length;m++)b+=s[m];l=Math.min(1,Math.max(0,b/s.length))}const c=r.current,d=l>=c?.7:.15,h=c*d+l*(1-d);r.current=h;const p=h<.05?0:Math.min(1,h);Math.abs(p-a.current)>.01&&(a.current=p,n(p)),i.current=requestAnimationFrame(o)};return i.current=requestAnimationFrame(o),()=>{i.current&&cancelAnimationFrame(i.current)}},[t]),e}function fW(){const[t,e]=w.useState({audioDevices:[]});return w.useEffect(()=>{var i;if(typeof navigator>"u"||!((i=navigator.mediaDevices)!=null&&i.enumerateDevices))return;const n=()=>{navigator.mediaDevices.enumerateDevices().then(r=>{e({audioDevices:r.filter(a=>a.kind==="audioinput")})})};return n(),navigator.mediaDevices.addEventListener("devicechange",n),()=>navigator.mediaDevices.removeEventListener("devicechange",n)},[]),t}function U3(){const t=window.location.hostname;return t.endsWith(".getcor.ai")||t.endsWith(".getcor.io")||t.endsWith(".clinic1.com")||t===".onuptick.com"||t==="getcor.ai"||t==="getcor.io"||t==="localhost"||t==="127.0.0.1"||t==="::1"}const z3=U3();function pW(t){if(document.querySelector("#obi-host")||document.querySelector("obi-widget"))return;mW();const e=document.createElement("div");e.id="obi-host",e.style.position="fixed",e.style.zIndex="9999",document.body.appendChild(e);const n=e.attachShadow({mode:"open"}),i=document.createElement("div");i.id="obi-container",n.appendChild(i);const r=new CSSStyleSheet;r.replaceSync(MB);const a=[r];if(z3){const s=new CSSStyleSheet;s.replaceSync(AB),a.push(s);const l=new CSSStyleSheet;l.replaceSync(OB),a.push(l)}else{const s=new CSSStyleSheet;s.replaceSync(NB),a.push(s)}n.adoptedStyleSheets=a;const o=RB.createRoot(i);z3?o.render(f.jsx(lW,{sdk:t,shadowHost:e})):o.render(f.jsx(LB,{sdk:t,shadowHost:e})),console.log("[obi-sdk] widget mounted")}function mW(){F3("https://fonts.cdnfonts.com/css/satoshi"),F3("https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap")}function F3(t){const e=document.createElement("link");e.href=t,e.rel="stylesheet",document.head.appendChild(e)}const q3="49206C6F7665204F6269_session",H3="obi-url-params",ey="obi-client-heartbeat",gW=5e3,V3=4e4,G3=15e3;function vW(){return U3()?"meet":"sdk"}class bW extends Ep{constructor(e){super(),this.client=null,this.isActive=!1,this.primaryColour="#9500FF",this.passivePlanUuid=null,this.commandLog=[],this.commandQueue=[],this._resumed=!1,this.heartbeatInterval=null,this.dispatchCommand=(n,i)=>{var r,a,o,s,l;switch(this.commandLog.push({commandType:n,args:i}),n){case"update":this.updateConfig(i);break;case"startSession":{if(i!=null&&i.planUuid){const c=(((r=this.client)==null?void 0:r.plans)||[]).find(u=>u.uuid===i.planUuid)||null;if(!c){console.warn("[obi] startSession command requires a valid planUuid",i);return}(o=(a=this.client)==null?void 0:a.selectPlan)==null||o.call(a,c)}this.updateActive(!0);break}case"stopSession":(l=(s=this.client)==null?void 0:s.stopSession)==null||l.call(s);break;case"say":this.say(i);break;default:console.warn("[obi] unknown command",{commandType:n,args:i})}},e&&this.createClient(e),this.parsePassiveParams()}async createClient(e){if(this.client){this.client.appToken!==e&&console.warn("[obi] client already exists with different app token");return}let n=null;const i=vW(),r=this.load();if(r)try{const a=this.parsePersistedSessionMetadata(r),o=a&&this.isPersistedSessionStale(a);o!=null&&o.stale&&a?(this.trackStaleSessionDiscard(a.sessionUuid,o.ageMs,o.reason),this.clearCachedClient()):(n=wh.deserialise(r,e,i,{apiBaseUrl:"https://staging.coragents.ai",captureScreen:this.captureScreen.bind(this)}),n?this._resumed=!0:this.clearCachedClient())}catch(a){console.error("[obi] error loading cached client",a),this.clearCachedClient()}n||(n=new wh(e,i,{apiBaseUrl:"https://staging.coragents.ai",captureScreen:this.captureScreen.bind(this)})),this.client=n,this.client.session&&this.startHeartbeat(this.client.session.sessionUuid),this.client.on("stateChanged",a=>{var o,s,l,c,u,d,h,p,b,m;a==="ready"&&this.updateConfig({isActive:((o=window==null?void 0:window.obiWidgetConfig)==null?void 0:o.isActive)??((s=this.client)==null?void 0:s.showWidget),primaryColour:((c=(l=this.client)==null?void 0:l.product)==null?void 0:c.primary_color)||"#9500FF",widgetDisplay:((u=window==null?void 0:window.obiWidgetConfig)==null?void 0:u.widgetDisplay)||((h=(d=this.client)==null?void 0:d.product)==null?void 0:h.widget_display)||"regular",completedWidgetDisplay:((p=window==null?void 0:window.obiWidgetConfig)==null?void 0:p.completedWidgetDisplay)||((m=(b=this.client)==null?void 0:b.product)==null?void 0:m.completed_widget_display)||"regular"})}),this.client.on("sessionStarted",()=>{var a,o;this.save(),this.startHeartbeat(((o=(a=this.client)==null?void 0:a.session)==null?void 0:o.sessionUuid)||null),this.passivePlanUuid=null}),this.client.on("sessionStopped",()=>{this.clearCachedClient(),this.passivePlanUuid=null}),this.client.on("sessionShutdown",()=>{this.clearCachedClient()}),this.client.on("trackEvent",(a,o)=>{}),this.client.session&&(this.client.session.isPaused,this.client.resumeSession(a=>{a.on("stateChanged",o=>{o!=="disconnecting"&&o!=="disconnected"&&o!=="error"&&o!=="connecting"&&this.save()}),a.on("paused",()=>{this.save()}),a.on("unpaused",()=>{this.save()})}))}_maybeActOnServerEngagement(){var s;const e=this.client;if(!e||e.state!=="ready")return;const n=e.product,i=(s=e.engagement)==null?void 0:s.style;if(!i||n&&ys(n.widget_url_blacklist||[])||!e.showWidget)return;const r=e.plans||[],a=e.planIsCompleted||[],o=r.length>0&&a.filter(Boolean).length===r.length;if(!(r.length===0||o)){if(i==="modal"){const l=a.findIndex(u=>!u),c=l>=0?r[l]:null;c&&e.selectPlan(c)}else i==="popover"&&setTimeout(()=>{this.showMessage("Don't forget to complete your onboarding",{autoCloseMs:1e4})},1e3);try{sa().track("engagement-prompt-shown",{style:i})}catch{}}}async initialise(e={}){var n;this.commandQueue=e.queuedCommands||[],this._resumed?(this._resumed=!1,this.dispatchCommandQueue()):this.client?this.client.initialise({planUuid:this.passivePlanUuid||void 0,identity:((n=window==null?void 0:window.obiWidgetConfig)==null?void 0:n.user)||void 0}).then(()=>{this.emit("initialised");try{this._maybeActOnServerEngagement()}catch{}this.dispatchCommandQueue()}).catch(i=>{console.error("[obi] error initialising client",i),this.emit("error",i)}):this.dispatchCommandQueue()}async updateConfig(e){e.apiKey!==void 0&&await this.updateAppToken(e.apiKey),this.updateActive(e.isActive),this.updatePrimaryColour(e.primaryColour),this.updateWidgetDisplay(e.widgetDisplay),this.updateCompletedWidgetDisplay(e.completedWidgetDisplay),this.updateWidgetPosition(e.widgetPosition),e.user!==void 0&&await this.updateIdentity(e.user),this.updateShowMenu(e.showMenu),this.emit("configUpdated")}async updateAppToken(e){var n;e===void 0||e==((n=this.client)==null?void 0:n.appToken)||(this.passivePlanUuid,await this.createClient(e),this.client&&await this.client.initialise({planUuid:this.passivePlanUuid||void 0}).then(()=>{this.emit("initialised");try{this._maybeActOnServerEngagement()}catch{}}).catch(i=>{console.error("[obi] error initialising client",i),this.emit("error",i)}))}updateActive(e){e===void 0||e==this.isActive||(this.isActive=e)}updatePrimaryColour(e){e===void 0||e==this.primaryColour||(this.primaryColour=e)}updateWidgetDisplay(e){e===void 0||e==this.widgetDisplay||(this.widgetDisplay=e)}updateCompletedWidgetDisplay(e){e===void 0||e==this.completedWidgetDisplay||(this.completedWidgetDisplay=e)}updateWidgetPosition(e){e===void 0||e==this.widgetPosition||(this.widgetPosition=e)}async updateIdentity(e){var i,r;if(e===void 0||e==((i=this.client)==null?void 0:i.identity))return;(r=this.client)==null||r.identity;let n=e?{...e,extra:{...e,...(e==null?void 0:e.extra)||{}}}:void 0;await this.client.initialise({identity:n,planUuid:this.passivePlanUuid||void 0}).then(()=>{this.emit("initialised");try{this._maybeActOnServerEngagement()}catch{}}).catch(a=>{console.error("[obi] error initialising client",a),this.emit("error",a)}),e!=null&&e.email&&sa().identify((e==null?void 0:e.email)||"",n)}updateShowMenu(e){e!==void 0&&this.emit("showMenu",e)}async say(e){var n,i,r;await((r=(i=(n=this.client)==null?void 0:n.session)==null?void 0:i.say)==null?void 0:r.call(i,e))}async startSession(e){await this.client.startSession(this.client.selectedPlanUuid||null,n=>{n.on("stateChanged",i=>{i!=="disconnecting"&&i!=="disconnected"&&i!=="error"&&i!=="connecting"&&this.save()}),n.on("paused",()=>{this.save()}),n.on("unpaused",()=>{this.save()})},e)}dispatchCommandQueue(){const e=this.commandQueue;this.commandQueue=[],e.forEach(n=>{try{this.dispatchCommand(n[0],n[1]||[])}catch(i){console.error("[obi] error dispatching command",i)}})}parsePassiveParams(){if(this.passivePlanUuid){this.passivePlanUuid;return}let e={};e=JSON.parse(localStorage.getItem(H3)||"{}"),Object.keys(e).length===0&&new URLSearchParams(window.location.search).forEach((a,o)=>{e[o]=a});const n=e[q3];if(!n)return null;const i=new URL(window.location.href);i.searchParams.delete(q3),window.history.replaceState({},"",i.toString()),i.toString(),localStorage.removeItem(H3),this.passivePlanUuid=n}mountWidget(){pW(this)}showMessage(e,n){try{this.emit("showMessage",{text:e,autoCloseMs:n==null?void 0:n.autoCloseMs})}catch{}}async captureScreen(){try{await xO(async()=>(this.graphemes||(this.graphemes=await this.client.api.getGraphemes()),this.graphemes.data.text_segmentation)),await mR(async()=>(this.graphemes||(this.graphemes=await this.client.api.getGraphemes()),this.graphemes.data.css_line_breaks))}catch(e){throw console.error("[obi] error initialising unicode trie",e),e}try{return(await ZN(document.documentElement,{useCORS:!0,allowTaint:!0,foreignObjectRendering:!0})).toDataURL("image/png")}catch(e){throw console.error("[obi] error capturing screen",e),e}}save(){var n;const e=((n=this.client)==null?void 0:n.serialise())||"";localStorage.setItem("obi-client",e)}load(){return localStorage.getItem("obi-client")}parsePersistedSessionMetadata(e){const n=JSON.parse(e),i=this.parseTimestampMs(n.serialisedAt);if(!n.session)return null;let r=null;if(typeof n.session=="string")try{r=JSON.parse(n.session)}catch{return null}else typeof n.session=="object"&&(r=n.session);return r?{sessionUuid:typeof r.sessionUuid=="string"?r.sessionUuid:null,startedAtMs:this.parseTimestampMs(r.startedAt),serialisedAtMs:i}:null}isPersistedSessionStale(e){const n=Date.now(),i=this.readHeartbeat();if(i&&i.sessionUuid&&e.sessionUuid&&i.sessionUuid===e.sessionUuid){const s=Math.max(0,n-i.updatedAtMs);return{stale:s>V3,reason:s>V3?"heartbeat-stale":"heartbeat-fresh",ageMs:s}}const r=[e.serialisedAtMs,e.startedAtMs].filter(s=>typeof s=="number"&&Number.isFinite(s));if(r.length===0)return{stale:!0,reason:"fallback-missing-timestamps",ageMs:null};const a=Math.max(...r),o=Math.max(0,n-a);return{stale:o>G3,reason:o>G3?"fallback-too-old":"fallback-recent",ageMs:o}}parseTimestampMs(e){if(typeof e=="number")return e;if(typeof e=="string"){const n=Number(e);if(!Number.isNaN(n))return n;const i=Date.parse(e);return Number.isFinite(i)?i:null}return null}readHeartbeat(){const e=localStorage.getItem(ey);if(!e)return null;try{return JSON.parse(e)}catch{return null}}trackStaleSessionDiscard(e,n,i){try{sa().track("stale-session-discarded",{sessionUuid:e||void 0,ageMs:n??void 0,reason:i})}catch{}}startHeartbeat(e){if(!e){this.clearHeartbeat();return}this.stopHeartbeat(),this.writeHeartbeat(e),this.heartbeatInterval=setInterval(()=>{this.writeHeartbeat(e)},gW)}stopHeartbeat(){this.heartbeatInterval&&(clearInterval(this.heartbeatInterval),this.heartbeatInterval=null)}writeHeartbeat(e){const n={sessionUuid:e,updatedAtMs:Date.now()};localStorage.setItem(ey,JSON.stringify(n))}clearHeartbeat(){this.stopHeartbeat(),localStorage.removeItem(ey)}clearCachedClient(){this.clearHeartbeat(),localStorage.removeItem("obi-client")}}async function W3(t,e){let n;try{n=window}catch{console.warn("[obi] no window object found"),n={}}return yW({appToken:t,window:n,init:e})}async function yW({appToken:t,window:e,init:n}){var a,o;if(e.obi){console.warn("[obi] obi object already found on window, skipping");return}n&&n(),t||(t=(a=e==null?void 0:e.obiWidgetConfig)==null?void 0:a.apiKey);let i;try{i=((o=e.ObiSDK)==null?void 0:o.q)||[]}catch{i=[]}const r=new bW(t);return e.ObiSDK=r.dispatchCommand,await r.initialise({queuedCommands:i}),e.obi=r,r.mountWidget(),r}function Y3(){}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{W3(void 0,Y3)}):W3(void 0,Y3)})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "obi-sdk",
3
- "version": "0.19.57-beta.4",
3
+ "version": "0.19.57-beta.5",
4
4
  "description": "JavaScript SDK for Obi",
5
5
  "type": "module",
6
6
  "main": "dist/obi-sdk.umd.js",