obi-sdk 0.19.50-beta.10 → 0.19.50-beta.11

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
@@ -117,5 +117,5 @@ ${this.parser.parse(t)}</blockquote>
117
117
  ${t}</tr>
118
118
  `}tablecell(t){let e=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>
119
119
  `}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>${aa(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=ME(t);if(r===null)return i;t=r;let a='<a href="'+t+'"';return e&&(a+=' title="'+aa(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=ME(t);if(r===null)return aa(n);t=r;let a=`<img src="${t}" alt="${n}"`;return e&&(a+=` title="${aa(e)}"`),a+=">",a}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:aa(t.text)}},mb=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}},$i=class Rb{constructor(e){rt(this,"options"),rt(this,"renderer"),rt(this,"textRenderer"),this.options=e||qo,this.options.renderer=this.options.renderer||new zf,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new mb}static parse(e,n){return new Rb(n).parse(e)}static parseInline(e,n){return new Rb(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}},qf,nu=(qf=class{constructor(t){rt(this,"options"),rt(this,"block"),this.options=t||qo}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(){return this.block?Zi.lex:Zi.lexInline}provideParser(){return this.block?$i.parse:$i.parseInline}},rt(qf,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),rt(qf,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),qf),hj=class{constructor(...t){rt(this,"defaults",ob()),rt(this,"options",this.setOptions),rt(this,"parse",this.parseMarkdown(!0)),rt(this,"parseInline",this.parseMarkdown(!1)),rt(this,"Parser",$i),rt(this,"Renderer",zf),rt(this,"TextRenderer",mb),rt(this,"Lexer",Zi),rt(this,"Tokenizer",jf),rt(this,"Hooks",nu),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 zf(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 jf(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 nu;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];nu.passThroughHooks.has(a)?r[o]=c=>{if(this.defaults.async&&nu.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 Zi.lex(t,e??this.defaults)}parser(t,e){return $i.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?Zi.lex:Zi.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?$i.parse:$i.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?Zi.lex:Zi.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?$i.parse:$i.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+=`
120
- Please report this to https://github.com/markedjs/marked.`,t){let i="<p>An error occurred:</p><pre>"+aa(n.message+"",!0)+"</pre>";return e?Promise.resolve(i):i}if(e)return Promise.reject(n);throw n}}},Fo=new hj;function Ke(t,e){return Fo.parse(t,e)}Ke.options=Ke.setOptions=function(t){return Fo.setOptions(t),Ke.defaults=Fo.defaults,bE(Ke.defaults),Ke},Ke.getDefaults=ob,Ke.defaults=qo,Ke.use=function(...t){return Fo.use(...t),Ke.defaults=Fo.defaults,bE(Ke.defaults),Ke},Ke.walkTokens=function(t,e){return Fo.walkTokens(t,e)},Ke.parseInline=Fo.parseInline,Ke.Parser=$i,Ke.parser=$i.parse,Ke.Renderer=zf,Ke.TextRenderer=mb,Ke.Lexer=Zi,Ke.lexer=Zi.lex,Ke.Tokenizer=jf,Ke.Hooks=nu,Ke.parse=Ke,Ke.options,Ke.setOptions,Ke.use,Ke.walkTokens,Ke.parseInline,$i.parse,Zi.lex;const fj="_base_1ne03_1",pj={base:fj},mj=["p","br","strong","em","u","a","ul","ol","li","h1","h2","h3","h4","h5","h6","code","pre","blockquote","hr"],gj=["href","title","target","rel"];Ke.setOptions({breaks:!0,gfm:!0});function vj(t){const{content:e,className:n,...i}=t,r=A.useMemo(()=>{if(!e)return"";const a=Ke.parse(e,{async:!1});return A7.sanitize(a,{ALLOWED_TAGS:[...mj],ALLOWED_ATTR:[...gj],ALLOW_DATA_ATTR:!1})},[e]);return r?x.jsx("div",{className:re(pj.base,n),dangerouslySetInnerHTML:{__html:r},...i}):null}const bj="_controlBar_14416_1",yj="_popoverAnchor_14416_11",_j="_confirmationPopover_14416_15",xj="_confirmationPopoverAlignRight_14416_30",Sj="_confirmationPopoverAlignCenter_14416_33",Tj="_confirmationMessage_14416_53",kj="_confirmationActions_14416_60",wj="_confirmationButton_14416_65",Cj="_confirmationButtonCancel_14416_83",Ej="_confirmationButtonNeutral_14416_91",Rj="_confirmationButtonDanger_14416_99",Aj="_controlButton_14416_108",Oj="_controlButtonIconOnly_14416_130",Nj="_controlButtonDisabled_14416_135",Mj="_controlButtonDanger_14416_162",Dj="_controlButtonContent_14416_178",Lj="_controlButtonIcon_14416_130",Pj="_controlButtonLabel_14416_194",Ij="_controlButtonChevron_14416_201",Bj="_controlButtonNotificationDot_14416_210",Uj="_deviceSplitButton_14416_222",jj="_deviceSplitButtonEnabled_14416_226",zj="_dualButtonContent_14416_307",qj="_dualButtonIcon_14416_317",Fj="_dualButtonLabel_14416_326",Hj="_screenShareButton_14416_340",Vj="_screenShareButtonCompact_14416_351",Le={controlBar:bj,popoverAnchor:yj,confirmationPopover:_j,confirmationPopoverAlignRight:xj,confirmationPopoverAlignCenter:Sj,confirmationMessage:Tj,confirmationActions:kj,confirmationButton:wj,confirmationButtonCancel:Cj,confirmationButtonNeutral:Ej,confirmationButtonDanger:Rj,controlButton:Aj,controlButtonIconOnly:Oj,controlButtonDisabled:Nj,controlButtonDanger:Mj,controlButtonContent:Dj,controlButtonIcon:Lj,controlButtonLabel:Pj,controlButtonChevron:Ij,controlButtonNotificationDot:Bj,deviceSplitButton:Uj,deviceSplitButtonEnabled:jj,dualButtonContent:zj,dualButtonIcon:qj,dualButtonLabel:Fj,screenShareButton:Hj,screenShareButtonCompact:Vj},Gj="_inline_1gpyx_1",Yj="_vertical_1gpyx_6",Wj="_divider_1gpyx_10",Kj="_dividerVertical_1gpyx_16",Xj="_customDivider_1gpyx_21",iu={inline:Gj,vertical:Yj,divider:Wj,dividerVertical:Kj,customDivider:Xj},PE={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 er(t){if(t!==void 0){if(typeof t=="number")return`${t}px`;if(t in PE)return PE[t];if(typeof t=="string"&&t.trim().length>0)return t}}function Qj(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,f=n??"div",y={display:"flex",flexDirection:i==="horizontal"?"row":"column",flexWrap:s?"wrap":"nowrap",alignItems:a,...o?{justifyContent:o}:{},...u};if(r!==void 0){const g=er(r);g&&(y.gap=g)}const v=Vn.Children.toArray(d).filter(g=>g!=null&&typeof g!="boolean"),T=g=>!l||g===0?null:l===!0||l==="line"?x.jsx("span",{"aria-hidden":"true",className:re(iu.divider,i==="vertical"&&iu.dividerVertical)},`inline-divider-${g}`):x.jsx("span",{"aria-hidden":"true",className:iu.customDivider,children:l},`inline-divider-${g}`),m=[];return v.forEach((g,_)=>{if(_>0){const p=T(_);p&&m.push(p)}m.push(g)}),x.jsx(f,{ref:e,className:re(iu.inline,i==="vertical"&&iu.vertical,c),style:y,...h,children:m})}const gb=Vn.forwardRef(Qj);gb.displayName="Inline";function Jj(){const[t,e]=A.useState(()=>typeof window>"u"?!1:window.innerWidth<768);return A.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 vb(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,f=re(Le.controlButton,a&&Le.controlButtonDisabled,l&&Le.controlButtonIconOnly,r==="danger"&&Le.controlButtonDanger,o),y=Number.parseInt(Kv[s],10),v=r==="danger"?"outline":"primary",T=r==="danger"?"danger":"default",m=x.jsxs(x.Fragment,{children:[x.jsxs("span",{className:Le.controlButtonContent,children:[e?x.jsx("span",{className:Le.controlButtonIcon,children:Vn.isValidElement(e)&&e.props.size===void 0?Vn.cloneElement(e,{size:y}):e}):null,l?null:x.jsx("span",{className:Le.controlButtonLabel,children:n}),l||!i?null:x.jsx("span",{className:Le.controlButtonChevron,"aria-hidden":"true",children:x.jsx(Xv,{size:16})})]}),c?x.jsx("span",{className:Le.controlButtonNotificationDot,"aria-hidden":"true"}):null]});return typeof u=="boolean"?x.jsx(Of,{...h,type:"button",disabled:a,variant:v,color:T,isOn:u,"aria-label":d||n,className:f,"data-has-notification":c?"true":void 0,children:m}):x.jsx(ol,{...h,type:"button",disabled:a,variant:v,color:T,"aria-label":d||n,className:f,"data-has-notification":c?"true":void 0,children:m})}function Zj(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:f,showChatNotification:y=!1,isLanguageSelectorEnabled:v=!0,languages:T=[],selectedLanguage:m=null,defaultLanguageCode:g=null,isMultilingual:_=!1,onLanguageChange:p,isChatOpen:S=a==="chat"}=t,k=T.length,w=v&&_&&k>0,E=Jj(),R=E?"xs":"sm",O=E,[D,q]=A.useState(!1),[Y,se]=A.useState(!1),H=A.useRef(null),P=A.useRef(null);A.useEffect(()=>{const B=me=>{const yn=me.composedPath();D&&H.current&&!yn.includes(H.current)&&q(!1),Y&&P.current&&!yn.includes(P.current)&&se(!1)},le=me=>{me.key==="Escape"&&(D&&q(!1),Y&&se(!1))};if(D||Y)return document.addEventListener("mousedown",B),document.addEventListener("keydown",le),()=>{document.removeEventListener("mousedown",B),document.removeEventListener("keydown",le)}},[D,Y]),A.useEffect(()=>{r||q(!1)},[r]);const W=A.useMemo(()=>e.map(B=>({label:B.label||`Microphone ${B.deviceId.slice(0,8)}`,value:B.deviceId})),[e]),X=A.useMemo(()=>n?W.find(B=>B.value===n)??null:null,[n,W]),ne=A.useCallback(B=>{B.value,c(B.value)},[c]),K={microphone:!0,screenShare:s,chat:o},ee=A.useCallback(()=>{if(r){q(!0);return}f()},[r,f]),J=A.useCallback(()=>{q(!1),f()},[f]),V=A.useCallback(()=>{q(!1)},[]),ae=A.useCallback(()=>{se(!0)},[]),j=A.useCallback(()=>{se(!1),h()},[h]),ve=A.useCallback(()=>{se(!1)},[]);return x.jsx("div",{className:Le.controlBar,"data-testid":"control-bar","data-controls":JSON.stringify(K),"data-language-option-count":k>0?String(k):void 0,"data-default-language-code":g??void 0,children:x.jsxs(gb,{gap:R,align:"center",justify:"center",wrap:O,children:[x.jsx(UU,{onClick:u,buttonAriaLabel:i?"Mute microphone":"Unmute microphone",options:W,value:X,onChange:ne,variant:"primary",menuPlacement:"top",menuDisabled:W.length===0,menuAriaLabel:"Select microphone device",listboxAriaLabel:"Microphone devices",ariaPressed:i,className:re(Le.deviceSplitButton,i&&Le.deviceSplitButtonEnabled),children:x.jsxs("span",{className:Le.dualButtonContent,children:[x.jsx("span",{className:Le.dualButtonIcon,children:i?x.jsx(G2,{}):x.jsx(Y2,{})}),x.jsx("span",{className:Le.dualButtonLabel,children:"Microphone"})]})}),o?x.jsx(vb,{icon:x.jsx(F2,{}),label:"Chat",onClick:d,isOn:S,"aria-label":"Toggle chat",showNotificationDot:y}):null,s?x.jsxs("div",{ref:H,className:Le.popoverAnchor,children:[x.jsx(vb,{icon:x.jsx(W2,{}),label:r?"Share screen off":"Share screen",className:l==="compact"?Le.screenShareButtonCompact:Le.screenShareButton,iconOnly:l==="compact",onClick:ee,isOn:r,"aria-label":r?"Stop screen sharing":"Start screen sharing"}),D?x.jsxs("div",{className:re(Le.confirmationPopover,Le.confirmationPopoverAlignCenter),role:"dialog","aria-label":"Stop screen sharing confirmation","data-testid":"confirm-stop-share",children:[x.jsx("p",{className:Le.confirmationMessage,children:"Stop screen sharing?"}),x.jsxs("div",{className:Le.confirmationActions,children:[x.jsx("button",{type:"button",className:re(Le.confirmationButton,Le.confirmationButtonCancel),onClick:V,children:"Cancel"}),x.jsx("button",{type:"button",className:re(Le.confirmationButton,Le.confirmationButtonNeutral),onClick:J,children:"Stop"})]})]}):null]}):null,w?x.jsx(tE,{languages:T,value:m,onChange:p,defaultLanguageCode:g,variant:"control-bar"}):null,x.jsxs("div",{ref:P,className:Le.popoverAnchor,children:[x.jsx(vb,{icon:x.jsx(V2,{}),label:"Leave",variant:"danger",onClick:ae,"aria-label":"Leave meeting"}),Y?x.jsxs("div",{className:re(Le.confirmationPopover,Le.confirmationPopoverAlignRight),role:"dialog","aria-label":"Leave meeting confirmation","data-testid":"confirm-leave",children:[x.jsx("p",{className:Le.confirmationMessage,children:"Would you like to end the call?"}),x.jsxs("div",{className:Le.confirmationActions,children:[x.jsx("button",{type:"button",className:re(Le.confirmationButton,Le.confirmationButtonCancel),onClick:ve,children:"Cancel"}),x.jsx("button",{type:"button",className:re(Le.confirmationButton,Le.confirmationButtonDanger),onClick:j,children:"Leave"})]})]}):null]})]})})}function $j(t){return x.jsx(Zj,{...t})}const ez="_controlBar_75i8h_1",tz="_controlButton_75i8h_12",nz="_controlButtonDisabled_75i8h_35",iz="_controlButtonDanger_75i8h_62",rz="_controlButtonIconOnly_75i8h_78",az="_screenShareButton_75i8h_83",oz="_controlButtonContent_75i8h_88",sz="_controlButtonIcon_75i8h_78",lz="_controlButtonLabel_75i8h_103",cz="_controlButtonNotificationDot_75i8h_108",uz="_popoverAnchor_75i8h_198",dz="_confirmationPopover_75i8h_202",hz="_confirmationMessage_75i8h_216",fz="_confirmationActions_75i8h_223",pz="_confirmationButton_75i8h_228",mz="_confirmationButtonCancel_75i8h_246",gz="_confirmationButtonDanger_75i8h_254",nn={controlBar:ez,controlButton:tz,controlButtonDisabled:nz,controlButtonDanger:iz,controlButtonIconOnly:rz,screenShareButton:az,controlButtonContent:oz,controlButtonIcon:sz,controlButtonLabel:lz,controlButtonNotificationDot:cz,popoverAnchor:uz,confirmationPopover:dz,confirmationMessage:hz,confirmationActions:fz,confirmationButton:pz,confirmationButtonCancel:mz,confirmationButtonDanger:gz};function Ff(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=re(nn.controlButton,r&&nn.controlButtonDisabled,o&&nn.controlButtonIconOnly,i==="danger"&&nn.controlButtonDanger,a),h=i==="danger"?"outline":"primary",f=i==="danger"?"danger":"default",y=x.jsxs(x.Fragment,{children:[x.jsxs("span",{className:nn.controlButtonContent,children:[e?x.jsx("span",{className:nn.controlButtonIcon,children:Vn.isValidElement(e)&&e.props.size===void 0?Vn.cloneElement(e,{size:20}):e}):null,o?null:x.jsx("span",{className:nn.controlButtonLabel,children:n})]}),s?x.jsx("span",{className:nn.controlButtonNotificationDot,"aria-hidden":"true"}):null]});return typeof l=="boolean"?x.jsx(Of,{...u,type:"button",disabled:r,variant:h,color:f,size:"xs",isOn:l,"aria-label":c||n,className:d,"data-has-notification":s?"true":void 0,children:y}):x.jsx(ol,{...u,type:"button",disabled:r,variant:h,color:f,size:"xs","aria-label":c||n,className:d,"data-has-notification":s?"true":void 0,children:y})}function vz(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,onLanguageChange:f,isLanguageSelectorEnabled:y=!0,className:v,testId:T,...m}=t,g=!y||!h||c.length===0,[_,p]=A.useState(!1),S=A.useRef(null);A.useEffect(()=>{const D=Y=>{const se=Y.composedPath();_&&S.current&&!se.includes(S.current)&&p(!1)},q=Y=>{Y.key==="Escape"&&_&&p(!1)};if(_)return document.addEventListener("mousedown",D),document.addEventListener("keydown",q),()=>{document.removeEventListener("mousedown",D),document.removeEventListener("keydown",q)}},[_]);const k=A.useCallback(()=>{a()},[a]),w=A.useCallback(()=>{s()},[s]),E=A.useCallback(()=>{p(!0)},[]),R=A.useCallback(()=>{p(!1),l()},[l]),O=A.useCallback(()=>{p(!1)},[]);return x.jsx("div",{...m,className:re(nn.controlBar,v),"data-testid":T,children:x.jsxs(gb,{gap:"xs",align:"center",justify:"center",wrap:!1,children:[x.jsx(Ff,{icon:e?x.jsx(G2,{}):x.jsx(Y2,{}),label:"Microphone",iconOnly:!0,isOn:e,onClick:k,"aria-label":e?"Mute microphone":"Unmute microphone"}),x.jsx(Ff,{icon:x.jsx(F2,{}),label:"Chat",iconOnly:!0,isOn:n,onClick:o,"aria-label":"Toggle chat",showNotificationDot:r}),x.jsx(Ff,{icon:x.jsx(W2,{}),label:"Screen share",iconOnly:!0,className:nn.screenShareButton,isOn:i,onClick:w,"aria-label":i?"Stop screen sharing":"Start screen sharing"}),x.jsx(tE,{languages:c,value:u,onChange:f,defaultLanguageCode:d,variant:"pip",disabled:g}),x.jsxs("div",{ref:S,className:nn.popoverAnchor,children:[x.jsx(Ff,{icon:x.jsx(V2,{}),label:"Hang up",iconOnly:!0,variant:"danger",onClick:E,"aria-label":"Hang up"}),_?x.jsxs("div",{className:nn.confirmationPopover,role:"dialog","aria-label":"Hang up confirmation","data-testid":"confirm-leave",children:[x.jsx("p",{className:nn.confirmationMessage,children:"Would you like to end the call?"}),x.jsxs("div",{className:nn.confirmationActions,children:[x.jsx("button",{type:"button",className:re(nn.confirmationButton,nn.confirmationButtonCancel),onClick:O,children:"Cancel"}),x.jsx("button",{type:"button",className:re(nn.confirmationButton,nn.confirmationButtonDanger),onClick:R,children:"Leave"})]})]}):null]})]})})}function bz(t){return x.jsx(vz,{...t})}const yz="_container_zht0b_1",_z="_containerGradient_zht0b_14",xz="_containerFlat_zht0b_24",Sz="_halo_zht0b_28",Tz="_outerRing_zht0b_38",kz="_circle_zht0b_42",wz="_image_zht0b_72",Cz="_captionContainer_zht0b_88",Ez="_captionRegion_zht0b_99",oa={container:yz,containerGradient:_z,containerFlat:xz,halo:Sz,outerRing:Tz,circle:kz,image:wz,captionContainer:Cz,captionRegion:Ez},Rz="_statusText_1dkze_6",Az={statusText:Rz},Oz={idle:null,thinking:"Thinking...",searching:"Searching..."};function Nz(t){const{status:e,size:n="md"}=t,i=e?Oz[e]:null,r=i!==null;return x.jsx("div",{className:Az.statusText,"data-visible":r,"data-size":n,"aria-live":"polite",children:i})}const Mz="https://obi-static.s3.ap-southeast-2.amazonaws.com/images/obi-avatar.png",Dz={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 IE(t){const{audioPower:e,size:n="md",background:i="gradient",imageSrc:r=Mz,accentColor:a,ariaLabel:o="Avatar placeholder",status:s,captionsText:l,className:c,style:u,...d}=t,h=Dz[n],f=Math.min(1,Math.max(0,e)),y=f>.01,v=y?Math.min(1,f/.5):0,T=y?Math.max(1,v*h.maxBorderWidth):0,m=1.02,g=y?m+f*h.outerRingScalePower:m,_=y?.2+f*.35:0,p={...u??{},...a?{"--avatar-fallback-accent":a}:{}},S={"--avatar-fallback-halo-size":h.haloSize,"--avatar-fallback-border-width":`${T}px`,"--avatar-fallback-secondary-border-scale":g.toString(),"--avatar-fallback-secondary-border-opacity":_.toString(),"--avatar-fallback-glow-size":h.glowSize},k=l!=null&&l!=="";return x.jsxs("div",{...d,className:re(oa.container,i==="gradient"?oa.containerGradient:oa.containerFlat,c),style:p,"data-testid":"avatar-fallback","aria-label":o,role:"img",children:[x.jsxs("div",{className:oa.halo,style:S,children:[x.jsx("div",{className:oa.outerRing,"aria-hidden":"true"}),x.jsx("div",{className:oa.circle,children:x.jsx("img",{className:oa.image,src:r,alt:"","aria-hidden":"true"})}),x.jsx(Nz,{status:s,size:n})]}),k&&x.jsx("div",{className:oa.captionContainer,children:x.jsx("div",{className:oa.captionRegion,"data-size":n,role:"status","aria-live":"polite","aria-atomic":"true",children:l})})]})}const Lz="_container_1k3qg_11",Pz="_screenshot_1k3qg_20",Iz="_flash_1k3qg_30",bb={container:Lz,screenshot:Pz,flash:Iz};function Bz(t){const{isActive:e,imageUrl:n,onComplete:i,duration:r=2e3}=t,[a,o]=A.useState(!1),s=A.useRef(null);return A.useEffect(()=>{if(!e){o(!1),s.current&&(clearTimeout(s.current),s.current=null);return}if(!s.current)return o(!0),s.current=setTimeout(()=>{o(!1),s.current=null,i==null||i()},r),()=>{s.current&&(clearTimeout(s.current),s.current=null)}},[e,r,i]),a?x.jsxs("div",{className:bb.container,"aria-live":"polite","aria-label":"Screenshot captured",children:[n&&x.jsx("img",{src:n,alt:"Captured screenshot",className:bb.screenshot}),x.jsx("div",{className:bb.flash})]}):null}const Uz="_container_13ukq_1",jz="_dragging_13ukq_5",zz="_placeholder_13ukq_9",qz="_handleButton_13ukq_15",Fz="_customHandle_13ukq_105",cl={container:Uz,dragging:jz,placeholder:zz,handleButton:qz,"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:Fz};function Hz(t){const{disabled:e,lingerMs:n,isDragging:i}=t,[r,a]=A.useState(!1),o=A.useRef(null),s=A.useCallback(()=>{o.current!==null&&(window.clearTimeout(o.current),o.current=null)},[]),l=A.useCallback(()=>{e||(s(),a(!0))},[s,e]),c=A.useCallback(()=>{e||i||(s(),o.current=window.setTimeout(()=>{a(!1),o.current=null},n))},[s,e,i,n]);return A.useEffect(()=>{i&&l()},[i,l]),A.useEffect(()=>s,[s]),{isHandleVisible:r,showHandle:l,scheduleHideHandle:c}}function Vz(t){const{initialPosition:e,preserveSpace:n,onPositionChange:i}=t,r=A.useRef(null),[a,o]=A.useState(!!e),[s,l]=A.useState(!1),[c,u]=A.useState(null),[d,h]=A.useState(()=>e??{x:0,y:0}),f=A.useRef(d);s||(f.current=d);const y=A.useRef(null),v=A.useRef(!1),T=A.useRef(!1);A.useEffect(()=>{e&&(T.current||(o(!0),h(e),f.current=e))},[e==null?void 0:e.x,e==null?void 0:e.y]),A.useEffect(()=>{if(e||v.current)return;const p=r.current;if(!p)return;const S=p.getBoundingClientRect(),k={x:S.left,y:S.top};v.current=!0,o(!0),h(k),f.current=k,u(n?{width:S.width,height:S.height}:null)},[e,n]);const m=A.useCallback(p=>{const S=y.current;if(!(!S||p.pointerId!==S.pointerId)){y.current=null,T.current=!0,h(f.current),l(!1);try{p.currentTarget.releasePointerCapture(S.pointerId)}catch{}}},[]),g=A.useCallback(p=>{p.button===0&&(p.preventDefault(),p.currentTarget.setPointerCapture(p.pointerId),y.current={pointerId:p.pointerId,startClientX:p.clientX,startClientY:p.clientY,startX:f.current.x,startY:f.current.y},l(!0))},[]),_=A.useCallback(p=>{const S=y.current;if(!S||p.pointerId!==S.pointerId)return;const k={x:S.startX+(p.clientX-S.startClientX),y:S.startY+(p.clientY-S.startClientY)};f.current=k,r.current&&(r.current.style.transform=`translate3d(${k.x}px, ${k.y}px, 0)`),i==null||i(k)},[i]);return{containerRef:r,isFixed:a,isDragging:s,position:d,placeholderSize:c,onPointerDown:g,onPointerMove:_,endDrag:m}}function Gz(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:f,isFixed:y,isDragging:v,position:T,placeholderSize:m,onPointerDown:g,onPointerMove:_,endDrag:p}=Vz({initialPosition:r,preserveSpace:o,onPositionChange:l}),{isHandleVisible:S,showHandle:k,scheduleHideHandle:w}=Hz({disabled:a,lingerMs:u,isDragging:v}),E=typeof e=="function",R=A.useMemo(()=>{const D=q=>x.jsx("div",{className:re(cl.customHandle,q.className),onPointerDown:g,onPointerMove:_,onPointerUp:p,onPointerCancel:p,children:q.children});return D.displayName="Draggable.Handle",D},[g,_,p]),O={...d,position:y?"fixed":"relative",top:y?0:d==null?void 0:d.top,left:y?0:d==null?void 0:d.left,transform:y?`translate3d(${T.x}px, ${T.y}px, 0)`:d==null?void 0:d.transform,zIndex:y?s:d==null?void 0:d.zIndex};return x.jsxs(x.Fragment,{children:[o&&y&&m?x.jsx("div",{className:cl.placeholder,style:{width:m.width,height:m.height}}):null,x.jsxs("div",{ref:f,className:re(cl.container,v?cl.dragging:null,n),"data-handle-visible":E?void 0:a?"false":S||v?"true":"false",style:O,onMouseEnter:E?void 0:k,onMouseLeave:E?void 0:w,...h,children:[!E&&!a?x.jsx("button",{type:"button",className:re(cl.handleButton,cl[`handle-${i}`]),"aria-label":c,onMouseEnter:k,onMouseLeave:w,onPointerDown:D=>{k(),g(D)},onPointerMove:_,onPointerUp:p,onPointerCancel:p}):null,E?e({Handle:R}):e]})]})}const Yz="_container_1u25n_1",Wz="_captionRegion_1u25n_14",Kz="_status_1u25n_22",Xz="_captionText_1u25n_29",Hf={container:Yz,captionRegion:Wz,status:Kz,captionText:Xz},Qz={idle:null,thinking:"Thinking...",searching:"Searching..."};function Jz(t){const{text:e,status:n,className:i,...r}=t,a=n?Qz[n]:null;return x.jsx("div",{...r,className:re(Hf.container,i),"data-testid":"pip-captions-panel",children:x.jsxs("div",{className:Hf.captionRegion,role:"status","aria-live":"polite","aria-atomic":"true",children:[a?x.jsx("div",{className:Hf.status,children:a}):null,x.jsx("div",{className:Hf.captionText,children:e})]})})}const Zz="_panel_1npcg_1",$z="_row_1npcg_20",eq="_stepContent_1npcg_26",tq="_stepLabel_1npcg_35",nq="_currentStep_1npcg_42",iq="_nextStep_1npcg_49",rq="_skipRow_1npcg_63",aq="_circleButton_1npcg_68",oq="_arrowPlaceholder_1npcg_93",sq="_skipButton_1npcg_99",Mi={panel:Zz,row:$z,stepContent:eq,stepLabel:tq,currentStep:nq,nextStep:iq,skipRow:rq,circleButton:aq,arrowPlaceholder:oq,skipButton:sq};function lq(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 BE(t,e){return e<=0||typeof t!="number"||!Number.isFinite(t)?0:Math.min(Math.max(Math.trunc(t),1),e)-1}function cq(t){var k;const{steps:e,currentStep:n,onStepClick:i,hideTrailingConclusionStep:r=!0,className:a,testId:o,...s}=t,{visibleSteps:l,currentIndex:c}=A.useMemo(()=>lq(e,n,r),[n,r,e]),[u,d]=A.useState(()=>BE(n,l.length));A.useEffect(()=>{d(BE(n,l.length))},[n,l]);const h=l.length,f=l[u],y=u>0,v=u<h-1,T=v?(k=l[u+1])==null?void 0:k.title:void 0,m=h===0?0:u+1,g=c!==null&&f&&u!==c,_=()=>{y&&d(w=>Math.max(w-1,0))},p=()=>{v&&d(w=>Math.min(w+1,h-1))},S=()=>{!g||!f||!i||i(u,f)};return x.jsxs("div",{...s,className:re(Mi.panel,a),"data-testid":o,role:"group","aria-label":"Course progress",children:[x.jsxs("div",{className:Mi.row,children:[y?x.jsx("button",{type:"button",className:Mi.circleButton,"aria-label":"Previous step",onClick:_,children:x.jsx(aB,{size:14})}):x.jsx("span",{className:Mi.arrowPlaceholder,"aria-hidden":"true"}),x.jsxs("div",{className:Mi.stepContent,children:[x.jsxs(Zn,{className:Mi.stepLabel,"aria-live":"polite",children:["Step ",m,"/",h]}),x.jsx(Zn,{className:Mi.currentStep,"data-testid":"pip-outline-current-step",children:(f==null?void 0:f.title)??"No steps available"}),T?x.jsxs(Zn,{variant:"muted",className:Mi.nextStep,children:["Next: ",T]}):null]}),v?x.jsx("button",{type:"button",className:Mi.circleButton,"aria-label":"Next step",onClick:p,children:x.jsx(oB,{size:14})}):x.jsx("span",{className:Mi.arrowPlaceholder,"aria-hidden":"true"})]}),g?x.jsx("div",{className:Mi.skipRow,children:x.jsx("button",{type:"button",className:Mi.skipButton,"aria-label":"Skip to this step",onClick:S,children:x.jsx(uB,{size:14})})}):null]})}const uq="_window_1q008_1",dq="_exitButton_1q008_13",hq="_content_1q008_43",fq="_contentTopOverlay_1q008_53",pq="_contentTopOverlaySlot_1q008_67",mq="_dragHandle_1q008_77",gq="_contentBottomOverlay_1q008_82",vq="_controls_1q008_91",ro={window:uq,exitButton:dq,content:hq,contentTopOverlay:fq,contentTopOverlaySlot:pq,dragHandle:mq,contentBottomOverlay:gq,controls:vq};function bq(t){return t==null?!1:typeof t=="string"?t.trim().length>0:!0}function yq(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:f,testId:y,...v}=t,T=i,m=n.isChatOpen&&!T&&l,g=c==null?void 0:c.captionsText,_=a&&bq(g),[p,S]=A.useState(!1);A.useEffect(()=>{h&&h>0&&S(!0)},[h]);const k=A.useCallback(()=>x.jsx(IE,{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]),w=T?s?x.jsx(cq,{steps:s.steps,currentStep:s.currentStep,onStepClick:s.onStepClick,hideTrailingConclusionStep:s.hideTrailingConclusionStep}):k():m?l:_?x.jsx(Jz,{text:g,status:c==null?void 0:c.status}):k();return x.jsxs("div",{...v,className:re(ro.window,f),"data-testid":y,role:"group","aria-label":"Picture-in-Picture",children:[x.jsxs("div",{className:ro.content,children:[x.jsxs("div",{className:ro.contentTopOverlay,children:[u?x.jsx("div",{className:ro.contentTopOverlaySlot,children:u}):null,x.jsx("button",{type:"button",className:ro.exitButton,onClick:e,"aria-label":"Exit PiP",children:x.jsx(sB,{size:14})})]}),w,!m&&x.jsxs("div",{className:ro.contentBottomOverlay,children:[x.jsx(Of,{isOn:i,onClick:r,variant:"primary",size:"xs","aria-label":"Toggle course outline",children:x.jsx(dB,{size:18})}),x.jsx(Of,{isOn:a,onClick:o,variant:"primary",size:"xs","aria-label":"Toggle captions",children:x.jsx(rB,{size:18})})]}),x.jsx(Bz,{isActive:p,imageUrl:d??null,onComplete:()=>S(!1)})]}),x.jsx("div",{className:ro.controls,children:x.jsx(bz,{...n})})]})}function _q(t){const{initialPosition:e,onPositionChange:n,zIndex:i=1e3,...r}=t;return x.jsx(Gz,{initialPosition:e,onPositionChange:n,zIndex:i,preserveSpace:!1,children:({Handle:a})=>x.jsx(yq,{...r,contentTopOverlaySlot:x.jsx(a,{className:ro.dragHandle})})})}const xq="_root_ygi3o_1",Sq="_overlay_ygi3o_7",Tq="_caption_ygi3o_17",yb={root:xq,overlay:Sq,caption:Tq};function kq(t){return t==null?!1:typeof t=="string"?t.trim().length>0:!0}function wq(t){const{children:e,className:n,text:i}=t,r=kq(i);return x.jsxs("div",{className:re(yb.root,n),children:[e,r?x.jsx("div",{className:yb.overlay,role:"status","aria-live":"polite","aria-atomic":"true",children:x.jsx("div",{className:yb.caption,children:i})}):null]})}const Cq="_box_1r6by_1",Eq={box:Cq},UE={none:"0px",panel:"var(--radius-panel)",card:"var(--radius-card)"},jE={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 Rq(t){if(t!==void 0){if(typeof t=="number")return`${t}px`;if(t in UE)return UE[t];if(typeof t=="string"&&t.trim().length>0)return t}}function Aq(t){if(t!==void 0){if(t in jE)return jE[t];if(typeof t=="string"&&t.trim().length>0)return t}}function Oq(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:f,paddingXl:y,margin:v,marginX:T,marginY:m,marginTop:g,marginBottom:_,marginLeft:p,marginRight:S,radius:k,radiusTop:w,radiusBottom:E,radiusLeft:R,radiusRight:O,radiusTopLeft:D,radiusTopRight:q,radiusBottomLeft:Y,radiusBottomRight:se,background:H,gap:P,style:W,...X}=t,ne=n??"div",K={...W},ee=K,J={},V=(B,le)=>{if(le===void 0)return;const me=er(le);me&&(K[B]=me)},ae=(B,le)=>{if(le===void 0)return;const me=er(le);me&&(K[B]=me)},j=(B,le)=>{if(le===void 0)return;const me=Rq(le);me&&(K[B]=me)},ve={sm:d,md:h,lg:f,xl:y};if(r!==void 0){const B=er(r);B&&(ee["--box-padding"]=B)}for(const[B,le]of Object.entries(ve)){if(le===void 0)continue;const me=er(le);me&&(ee[`--box-padding-${B}`]=me,J[`data-padding-${B}`]="")}if(a!==void 0){const B=er(a);B&&(K.paddingLeft=B,K.paddingRight=B)}if(o!==void 0){const B=er(o);B&&(K.paddingTop=B,K.paddingBottom=B)}if(V("paddingTop",s),V("paddingBottom",l),V("paddingLeft",c),V("paddingRight",u),v!==void 0){const B=er(v);B&&(K.margin=B)}if(T!==void 0){const B=er(T);B&&(K.marginLeft=B,K.marginRight=B)}if(m!==void 0){const B=er(m);B&&(K.marginTop=B,K.marginBottom=B)}if(ae("marginTop",g),ae("marginBottom",_),ae("marginLeft",p),ae("marginRight",S),P!==void 0){const B=er(P);B&&(K.gap=B)}if(j("borderRadius",k),w!==void 0&&(j("borderTopLeftRadius",w),j("borderTopRightRadius",w)),E!==void 0&&(j("borderBottomLeftRadius",E),j("borderBottomRightRadius",E)),R!==void 0&&(j("borderTopLeftRadius",R),j("borderBottomLeftRadius",R)),O!==void 0&&(j("borderTopRightRadius",O),j("borderBottomRightRadius",O)),j("borderTopLeftRadius",D),j("borderTopRightRadius",q),j("borderBottomLeftRadius",Y),j("borderBottomRightRadius",se),H!==void 0){const B=Aq(H);B&&(K.background=B)}return x.jsx(ne,{ref:e,className:re(Eq.box,i),style:K,...J,...X})}const Vf=Vn.forwardRef(Oq);Vf.displayName="Box";const Nq="_panel_eawk4_1",Mq="_selected_eawk4_10",zE={panel:Nq,selected:Mq};function ru(t){const{children:e,className:n,selected:i,...r}=t;return x.jsx("div",{className:re(zE.panel,i?zE.selected:null,n),...r,children:e})}const Dq="_root_yccm8_1",Lq="_header_yccm8_8",Pq="_icon_yccm8_15",Iq="_text_yccm8_26",Bq="_heading_yccm8_33",Uq="_description_yccm8_41",jq="_body_yccm8_47",zq="_footer_yccm8_54",ao={root:Dq,header:Lq,icon:Pq,text:Iq,heading:Bq,description:Uq,body:jq,footer:zq};function qE(t){const{className:e,...n}=t;return x.jsx("div",{className:re(ao.icon,e),...n})}function FE(t){const{className:e,...n}=t;return x.jsx("h3",{className:re(ao.heading,e),...n})}function HE(t){const{className:e,...n}=t;return x.jsx("p",{className:re(ao.description,e),...n})}function VE(t){const{className:e,...n}=t;return x.jsx("div",{className:re(ao.footer,e),...n})}function qq(t){const e=A.Children.toArray(t),n=[];let i,r,a,o;for(const s of e){if(A.isValidElement(s)&&s.type===qE&&i===void 0){i=s;continue}if(A.isValidElement(s)&&s.type===FE&&r===void 0){r=s;continue}if(A.isValidElement(s)&&s.type===HE&&a===void 0){a=s;continue}if(A.isValidElement(s)&&s.type===VE&&o===void 0){o=s;continue}n.push(s)}return{icon:i,heading:r,description:a,footer:o,body:n}}function Fq(t){const{children:e,className:n,...i}=t,r=qq(e),a=r.icon||r.heading||r.description;return x.jsxs(ru,{className:re(ao.root,n),...i,children:[a?x.jsxs("div",{className:ao.header,children:[r.icon,r.heading||r.description?x.jsxs("div",{className:ao.text,children:[r.heading,r.description]}):null]}):null,r.body.length?x.jsx("div",{className:ao.body,children:r.body}):null,r.footer]})}const _b=Object.assign(Fq,{Icon:qE,Heading:FE,Description:HE,Footer:VE}),Hq="_panel_1uwhd_1",Vq="_header_1uwhd_11",Gq="_title_1uwhd_19",Yq="_scrollArea_1uwhd_29",Wq="_scrollable_1uwhd_34",Kq="_list_1uwhd_38",Xq="_courseButton_1uwhd_44",Qq="_courseCard_1uwhd_55",Jq="_courseHeading_1uwhd_64",Zq="_courseDescription_1uwhd_70",$q="_empty_1uwhd_79",tr={panel:Hq,header:Vq,title:Gq,scrollArea:Yq,scrollable:Wq,list:Kq,courseButton:Xq,courseCard:Qq,courseHeading:Jq,courseDescription:Zq,empty:$q};function eF(t){const{selectionMode:e,selectedCourseIds:n,defaultSelectedCourseIds:i,onSelectedCourseIdsChange:r}=t,a=n!==void 0,[o,s]=A.useState(()=>i??[]),l=a?n:o,c=A.useCallback(d=>{a||s(d),r==null||r(d)},[a,r]),u=A.useCallback(d=>{const h=l.includes(d);if(e==="single"){c(h?[]:[d]);return}if(h){c(l.filter(f=>f!==d));return}c([...l,d])},[l,e,c]);return{selectedCourseIds:l,toggleCourseId:u}}function tF(t){const{title:e="Courses",ariaLabel:n,className:i,courses:r,selectionMode:a="multiple",selectedCourseIds:o,onCourseToggle:s,emptyMessage:l="No courses available",testId:c,...u}=t;return x.jsxs(ru,{...u,className:re(tr.panel,i),role:"region","aria-label":n??e,"data-testid":c,children:[x.jsx("div",{className:tr.header,children:x.jsx(Zn,{as:"h2",className:tr.title,children:e})}),x.jsx("div",{className:tr.scrollArea,children:x.jsx(sl,{className:tr.scrollable,children:r.length===0?x.jsx(Zn,{variant:"muted",className:tr.empty,"data-testid":"course-panel-empty",children:l}):x.jsx("div",{className:tr.list,"data-testid":"course-panel-list",children:r.map(d=>{const h=o.includes(d.id),f=d.disabled===!0;return x.jsx("button",{type:"button",className:tr.courseButton,"aria-pressed":h,"aria-disabled":f,disabled:f,onClick:()=>s==null?void 0:s(d.id,d),"data-testid":`course-panel-item-${d.id}`,children:x.jsxs(_b,{selected:h,className:tr.courseCard,children:[x.jsx(_b.Heading,{className:tr.courseHeading,children:d.title}),d.description?x.jsx(_b.Description,{className:tr.courseDescription,children:d.description}):null]})},d.id)})})})})]})}function nF(t){const{selectionMode:e="multiple",selectedCourseIds:n,defaultSelectedCourseIds:i,onSelectedCourseIdsChange:r,onCourseToggle:a,...o}=t,{selectedCourseIds:s,toggleCourseId:l}=eF({selectionMode:e,selectedCourseIds:n,defaultSelectedCourseIds:i,onSelectedCourseIdsChange:r}),c=A.useCallback((u,d)=>{l(u),a==null||a(u,d)},[a,l]);return x.jsx(tF,{...o,selectionMode:e,selectedCourseIds:s,onCourseToggle:c})}const iF="_panel_1on05_1",rF="_header_1on05_11",aF="_divider_1on05_19",oF="_title_1on05_25",sF="_scrollArea_1on05_35",lF="_scrollable_1on05_40",cF="_list_1on05_44",uF="_section_1on05_50",dF="_sectionHeader_1on05_56",hF="_sectionTitle_1on05_60",fF="_sectionTitleCompact_1on05_68",pF="_item_1on05_72",mF="_itemClickable_1on05_86",gF="_itemCompleted_1on05_90",vF="_itemCurrent_1on05_94",bF="_itemFuture_1on05_98",yF="_itemDisabled_1on05_103",_F="_row_1on05_117",xF="_stepHeader_1on05_124",SF="_stepNumber_1on05_133",TF="_stepTitle_1on05_139",kF="_checkIcon_1on05_151",wF="_empty_1on05_155",He={panel:iF,header:rF,divider:aF,title:oF,scrollArea:sF,scrollable:lF,list:cF,section:uF,sectionHeader:dF,sectionTitle:hF,sectionTitleCompact:fF,item:pF,itemClickable:mF,itemCompleted:gF,itemCurrent:vF,itemFuture:bF,itemDisabled:yF,row:_F,stepHeader:xF,stepNumber:SF,stepTitle:TF,checkIcon:kF,empty:wF};function CF(t){var f;const{steps:e,currentStep:n,hideTrailingConclusionStep:i}=t,r=e.length,a=i&&r>0&&((f=e[r-1])==null?void 0:f.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},(y,v)=>v),currentIndex:null,futureIndices:[]};const c=Math.min(Math.max(l,1),s)-1,u=Array.from({length:Math.max(0,c)},(y,v)=>v),d=Math.min(c,s-1),h=Array.from({length:Math.max(0,s-(d+1))},(y,v)=>d+1+v);return{visibleSteps:o,completedIndices:u,currentIndex:d,futureIndices:h}}function EF(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,...d}=t,h=A.useCallback(_=>(_+1).toString().padStart(2,"0"),[]),{visibleSteps:f,completedIndices:y,currentIndex:v,futureIndices:T}=A.useMemo(()=>CF({steps:r,currentStep:a,hideTrailingConclusionStep:s}),[a,s,r]),m=c==="compact"?"md":"lg",g=A.useCallback((_,p)=>{const S=f[_];if(!S)return null;const k=typeof o=="function",w=k&&S.disabled===!0,E=k&&!w,R=re(He.item,{[He.itemClickable]:E,[He.itemCompleted]:p==="completed",[He.itemCurrent]:p==="current",[He.itemFuture]:p==="future",[He.itemDisabled]:w}),O=x.jsxs("div",{className:He.row,children:[x.jsxs("div",{className:He.stepHeader,children:[x.jsx("span",{className:He.stepNumber,children:h(_)}),x.jsx("span",{className:He.stepTitle,children:S.title})]}),p==="completed"?x.jsx(Rf,{size:20,className:He.checkIcon}):null]});return k?x.jsx(Vf,{as:"button",type:"button",className:R,onClick:()=>{E&&o(_,S)},disabled:w,"aria-current":p==="current"?"step":void 0,"aria-label":`Step ${h(_)}: ${S.title}`,"data-testid":`course-outline-item-${S.id}`,padding:m,radius:"panel",gap:"sm",children:O},S.id):x.jsx(Vf,{className:R,"aria-current":p==="current"?"step":void 0,"aria-label":`Step ${h(_)}: ${S.title}`,"data-testid":`course-outline-item-${S.id}`,padding:m,radius:"panel",gap:"sm",children:O},S.id)},[h,m,o,f]);return x.jsxs(ru,{...d,className:re(He.panel,i),role:"region","aria-label":n??e,"data-testid":u,children:[x.jsx("div",{className:He.header,children:x.jsx(Zn,{as:"h2",className:He.title,children:e})}),x.jsx("div",{className:He.divider,"aria-hidden":"true"}),x.jsx("div",{className:He.scrollArea,children:x.jsx(sl,{className:He.scrollable,children:f.length===0?x.jsx(Zn,{variant:"muted",className:He.empty,"data-testid":"course-outline-empty",children:l}):x.jsxs("div",{className:He.list,"data-testid":"course-outline-list",children:[y.length>0?x.jsxs("div",{className:He.section,"data-testid":"course-outline-section-completed",children:[x.jsx("div",{className:He.sectionHeader,children:x.jsx("span",{className:re(He.sectionTitle,c==="compact"?He.sectionTitleCompact:null),children:"Completed"})}),y.map(_=>g(_,"completed"))]}):null,v!==null?x.jsxs("div",{className:He.section,"data-testid":"course-outline-section-current",children:[x.jsx("div",{className:He.sectionHeader,children:x.jsx("span",{className:re(He.sectionTitle,c==="compact"?He.sectionTitleCompact:null),children:"Current"})}),g(v,"current")]}):null,T.length>0?x.jsxs("div",{className:He.section,"data-testid":"course-outline-section-upcoming",children:[x.jsx("div",{className:He.sectionHeader,children:x.jsx("span",{className:re(He.sectionTitle,c==="compact"?He.sectionTitleCompact:null),children:"Upcoming"})}),T.map(_=>g(_,"future"))]}):null]})})})]})}function RF(t){return x.jsx(EF,{...t})}const AF="_panel_8h64k_1",OF="_messagesArea_8h64k_20",NF="_messagesList_8h64k_46",MF="_messageItem_8h64k_53",DF="_messageMetadata_8h64k_59",LF="_senderName_8h64k_67",PF="_timestamp_8h64k_71",IF="_messageBubble_8h64k_75",BF="_agentMessage_8h64k_85",UF="_agentActions_8h64k_89",jF="_copyButton_8h64k_95",zF="_copyButtonCopied_8h64k_129",qF="_empty_8h64k_133",FF="_composer_8h64k_140",HF="_composerDisabled_8h64k_160",VF="_composerInput_8h64k_165",GF="_sendButton_8h64k_180",mn={panel:AF,messagesArea:OF,messagesList:NF,messageItem:MF,messageMetadata:DF,senderName:LF,timestamp:PF,messageBubble:IF,agentMessage:BF,agentActions:UF,copyButton:jF,copyButtonCopied:zF,empty:qF,composer:FF,composerDisabled:HF,composerInput:VF,sendButton:GF};function YF(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 WF(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 KF(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 XF(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 QF(t){const{messages:e,localIdentity:n,onSend:i,isSending:r=!1,inputPlaceholder:a="Type a message...",className:o,testId:s,...l}=t,[c,u]=A.useState(""),[d,h]=A.useState(null),f=A.useRef(null),y=A.useRef(null),v=A.useMemo(()=>{const p=e[e.length-1];return p?p.id??`${p.timestamp}-${e.length-1}`:null},[e]);A.useEffect(()=>{var p,S;(S=(p=f.current)==null?void 0:p.scrollIntoView)==null||S.call(p,{behavior:"smooth"})},[v]),A.useEffect(()=>()=>{y.current&&(window.clearTimeout(y.current),y.current=null)},[]);const T=A.useCallback(async()=>{const p=c.trim();p.length!==0&&(await i(p),u(""))},[c,i]),m=A.useCallback(p=>{p.key==="Enter"&&(p.preventDefault(),T())},[T]),g=A.useCallback(async(p,S)=>{try{await XF(p.message??""),h(S),y.current&&window.clearTimeout(y.current),y.current=window.setTimeout(()=>{h(null),y.current=null},2e3)}catch(k){console.warn("[PiPChatPanel] Failed to copy message",k)}},[]),_=c.trim().length>0&&!r;return x.jsxs("div",{...l,className:re(mn.panel,o),"data-testid":s,role:"region","aria-label":"Chat",children:[x.jsx("div",{className:mn.messagesArea,children:e.length===0?x.jsx("div",{className:mn.empty,"data-testid":"pip-chat-panel-empty",children:"No messages yet"}):x.jsxs("div",{className:mn.messagesList,"data-testid":"pip-chat-panel-list",children:[e.map((p,S)=>{const k=p.id??`${p.timestamp}-${S}`,w=WF(p,n),E=d===k;return x.jsxs("div",{className:re(mn.messageItem,w&&mn.agentMessage),"data-testid":`pip-chat-panel-message-${k}`,children:[x.jsxs("div",{className:mn.messageMetadata,children:[x.jsx("span",{className:mn.senderName,children:KF(p,n)}),x.jsx("span",{className:mn.timestamp,children:YF(p.timestamp)})]}),x.jsx("div",{className:mn.messageBubble,children:p.message}),w?x.jsx("div",{className:mn.agentActions,children:x.jsx("button",{type:"button",className:re(mn.copyButton,E&&mn.copyButtonCopied),onClick:()=>void g(p,k),"aria-label":E?"Copied":"Copy message",title:E?"Copied":"Copy message","data-testid":"pip-copy-agent-message","data-copied":E?"true":"false",children:x.jsx(H2,{size:14})})}):null]},k)}),x.jsx("div",{ref:f})]})}),x.jsxs("div",{className:re(mn.composer,r&&mn.composerDisabled),children:[x.jsx("input",{type:"text",className:mn.composerInput,value:c,onChange:p=>u(p.target.value),onKeyDown:m,placeholder:a,disabled:r,"aria-label":"Message"}),x.jsx("button",{type:"button",className:mn.sendButton,onClick:()=>void T(),disabled:!_,"aria-label":"Send message",children:x.jsx(K2,{size:16})})]})]})}const JF="_panel_q8m25_1",ZF="_header_q8m25_11",$F="_title_q8m25_19",eH="_titleCompact_q8m25_29",tH="_headerActions_q8m25_33",nH="_closeButton_q8m25_39",iH="_divider_q8m25_67",rH="_body_q8m25_73",aH="_messagesArea_q8m25_81",oH="_scrollable_q8m25_86",sH="_messagesList_q8m25_90",lH="_messageItem_q8m25_98",cH="_messageMetadata_q8m25_104",uH="_senderName_q8m25_112",dH="_timestamp_q8m25_116",hH="_messageBubble_q8m25_120",fH="_messageText_q8m25_124",pH="_agentMessage_q8m25_130",mH="_agentActions_q8m25_134",gH="_copyButton_q8m25_140",vH="_copyButtonCopied_q8m25_174",bH="_inputRow_q8m25_178",yH="_empty_q8m25_182",_H="_composer_q8m25_188",xH="_composerDefault_q8m25_203",SH="_composerCompact_q8m25_208",TH="_composerDisabled_q8m25_218",kH="_composerInputWrapper_q8m25_223",wH="_composerInput_q8m25_223",CH="_sendButton_q8m25_240",EH="_sendButtonCompact_q8m25_257",Ve={panel:JF,header:ZF,title:$F,titleCompact:eH,headerActions:tH,closeButton:nH,divider:iH,body:rH,messagesArea:aH,scrollable:oH,messagesList:sH,messageItem:lH,messageMetadata:cH,senderName:uH,timestamp:dH,messageBubble:hH,messageText:fH,agentMessage:pH,agentActions:mH,copyButton:gH,copyButtonCopied:vH,inputRow:bH,empty:yH,composer:_H,composerDefault:xH,composerCompact:SH,composerDisabled:TH,composerInputWrapper:kH,composerInput:wH,sendButton:CH,sendButtonCompact:EH};function RH(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 AH(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 OH(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 NH(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 MH(t){const{disabled:e,placeholder:n,size:i="md",autoFocus:r,onSend:a}=t,[o,s]=A.useState(""),l=A.useCallback(async()=>{const f=o.trim();f.length!==0&&(await a(f),s(""))},[a,o]),c=A.useCallback(f=>{f.key==="Enter"&&(f.preventDefault(),l())},[l]),u=i==="sm"||i==="xs",d=u?18:24,h=o.trim().length>0&&e!==!0;return x.jsxs("div",{className:re(Ve.composer,u?Ve.composerCompact:Ve.composerDefault,e?Ve.composerDisabled:null),children:[x.jsx("div",{className:Ve.composerInputWrapper,children:x.jsx(Q2,{value:o,onChange:s,onKeyDown:c,className:Ve.composerInput,placeholder:n??"Send a message ...",disabled:e,size:i,autoFocus:r,"aria-label":"Message"})}),x.jsx("button",{type:"button",className:re(Ve.sendButton,u?Ve.sendButtonCompact:null),onClick:()=>void l(),disabled:!h,"aria-label":"Send message",children:x.jsx(K2,{size:d})})]})}function GE(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:f=RH,getSenderName:y,isAgentMessage:v,copyResetDelayMs:T=2e3,showAgentCopyButton:m=!0,inputPlaceholder:g,inputAutoFocus:_,...p}=t,S=A.useRef(null),[k,w]=A.useState(null),E=A.useRef(null),R=A.useCallback(H=>y?y(H):OH(H,o),[y,o]),O=A.useCallback(H=>v?v(H,o):AH(H,o),[v,o]),D=A.useMemo(()=>{const H=r[r.length-1];return H?H.id??`${H.timestamp}-${r.length-1}`:null},[r]);A.useEffect(()=>{var H,P;(P=(H=S.current)==null?void 0:H.scrollIntoView)==null||P.call(H,{behavior:"smooth"})},[D]),A.useEffect(()=>()=>{E.current&&(window.clearTimeout(E.current),E.current=null)},[]);const q=A.useCallback(H=>{w(H),E.current&&window.clearTimeout(E.current),E.current=window.setTimeout(()=>{w(null),E.current=null},T)},[T]),Y=A.useCallback(async(H,P)=>{try{await NH(H.message??""),q(P)}catch(W){console.warn("[ChatPanel] Failed to copy message",W)}},[q]),se=d==="compact"?"sm":"md";return x.jsxs(ru,{...p,className:re(Ve.panel,i),role:"region","aria-label":n??e,"data-testid":h,children:[x.jsxs("div",{className:Ve.header,children:[x.jsx(Zn,{as:"h2",className:re(Ve.title,d==="compact"?Ve.titleCompact:null),children:e}),l&&c?x.jsx("div",{className:Ve.headerActions,children:x.jsx("button",{type:"button",className:Ve.closeButton,onClick:l,"aria-label":`Close ${e}`,children:x.jsx(Af,{size:d==="compact"?18:20})})}):null]}),x.jsx("div",{className:Ve.divider,"aria-hidden":"true"}),x.jsxs("div",{className:Ve.body,children:[x.jsx("div",{className:Ve.messagesArea,children:x.jsx(sl,{className:Ve.scrollable,children:r.length===0?x.jsx(Zn,{variant:"muted",className:Ve.empty,"data-testid":"chat-panel-empty",children:u}):x.jsxs("div",{className:Ve.messagesList,"data-testid":"chat-panel-list",children:[r.map((H,P)=>{const W=H.id??`${H.timestamp}-${P}`,X=O(H),ne=k===W;return x.jsxs("div",{className:re(Ve.messageItem,X?Ve.agentMessage:null),"data-testid":`chat-panel-message-${W}`,children:[x.jsxs("div",{className:Ve.messageMetadata,children:[x.jsx("span",{className:Ve.senderName,children:R(H)}),x.jsx("span",{className:Ve.timestamp,children:f(H.timestamp)})]}),x.jsx(Vf,{className:Ve.messageBubble,padding:"md",radius:"panel",background:X?"surfaceMuted":"surface",children:x.jsx("div",{className:Ve.messageText,children:H.message})}),X&&m?x.jsx("div",{className:Ve.agentActions,children:x.jsx("button",{type:"button",className:re(Ve.copyButton,ne?Ve.copyButtonCopied:null),onClick:()=>void Y(H,W),"aria-label":ne?"Copied":"Copy agent message",title:ne?"Copied":"Copy agent message","data-testid":"copy-agent-message","data-copied":ne?"true":"false",children:x.jsx(H2,{size:18})})}):null]},W)}),x.jsx("div",{ref:S})]})})}),x.jsx("div",{className:Ve.inputRow,children:x.jsx(MH,{onSend:s,disabled:a,placeholder:g,size:se,autoFocus:_})})]})]})}A.createContext("vertical");const DH="_container_1a1i6_1",LH="_video_1a1i6_7",PH="_chip_1a1i6_16",IH="_logo_1a1i6_34",Gf={container:DH,video:LH,chip:PH,logo:IH},BH="https://obi-static.s3.ap-southeast-2.amazonaws.com/videos/greeting.mp4";function UH(t){const{agentName:e="Obi",className:n,...i}=t,r=A.useRef(null),a=()=>{var o;try{(o=r.current)==null||o.pause()}catch{}};return x.jsxs("div",{className:re(Gf.container,n),...i,children:[x.jsx("video",{ref:r,className:Gf.video,src:BH,autoPlay:!0,muted:!0,playsInline:!0,onEnded:a}),x.jsxs("div",{className:Gf.chip,children:[x.jsx(lB,{size:14,className:Gf.logo}),x.jsx("span",{children:e})]})]})}typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;const YE=50,ul="?",WE=/\(error: (.*)\)/,KE=/captureMessage|captureException/;function jH(...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(`
121
- `);for(let s=i;s<o.length;s++){const l=o[s];if(l.length>1024)continue;const c=WE.test(l)?l.replace(WE,"$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>=YE+r)break}}return zH(a.slice(r))}}function zH(t){if(!t.length)return[];const e=Array.from(t);return/sentryWrapped/.test(Yf(e).function||"")&&e.pop(),e.reverse(),KE.test(Yf(e).function||"")&&(e.pop(),KE.test(Yf(e).function||"")&&e.pop()),e.slice(0,YE).map(n=>({...n,filename:n.filename||Yf(e).filename,function:n.function||ul}))}function Yf(t){return t[t.length-1]||{}}typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;const qH=30,FH=50;function xb(t,e,n,i){const r={filename:t,function:e==="<anonymous>"?ul:e,in_app:!0};return n!==void 0&&(r.lineno=n),i!==void 0&&(r.colno=i),r}const HH=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,VH=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,GH=/\((\S*)(?::(\d+))(?::(\d+))\)/,YH=t=>{const e=HH.exec(t);if(e){const[,i,r,a]=e;return xb(i,ul,+r,+a)}const n=VH.exec(t);if(n){if(n[2]&&n[2].indexOf("eval")===0){const a=GH.exec(n[2]);a&&(n[2]=a[1],n[3]=a[2],n[4]=a[3])}const[i,r]=XE(n[1]||ul,n[2]);return xb(r,i,n[3]?+n[3]:void 0,n[4]?+n[4]:void 0)}},WH=[qH,YH],KH=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,XH=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i;jH(...[WH,[FH,t=>{const e=KH.exec(t);if(e){if(e[3]&&e[3].indexOf(" > eval")>-1){const r=XH.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]||ul;return[i,n]=XE(i,n),xb(n,i,e[4]?+e[4]:void 0,e[5]?+e[5]:void 0)}}]]);const XE=(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]:ul,n?`safari-extension:${e}`:`safari-web-extension:${e}`]:[t,e]};typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;const Er={shell:"_shell_3h8q7_1",layout:"_layout_3h8q7_11",layoutThree:"_layoutThree_3h8q7_23",leftPanel:"_leftPanel_3h8q7_27",middlePanel:"_middlePanel_3h8q7_36",rightPanel:"_rightPanel_3h8q7_37",videoFrame:"_videoFrame_3h8q7_41",captions:"_captions_3h8q7_51",controls:"_controls_3h8q7_57",coursePanel:"_coursePanel_3h8q7_70"};function Sb(...t){return t.filter(Boolean).join(" ")}function QH(t){const{captionsText:e,avatarAudioPower:n=0,avatarImageSrc:i,avatarAriaLabel:r,avatarStatus:a,controlBarProps:o,courses:s,coursePanelProps:l,middlePanel:c,rightPanel:u,className:d}=t;return x.jsx("div",{className:Sb(Er.shell,d),"data-testid":"course-dialog-content",children:x.jsxs("div",{className:Sb(Er.layout,u?Er.layoutThree:null),children:[x.jsxs("div",{className:Er.leftPanel,children:[x.jsx("div",{className:Er.videoFrame,children:x.jsx(wq,{className:Er.captions,text:e,children:x.jsx(IE,{audioPower:n,size:"lg",background:"flat",imageSrc:i,ariaLabel:r??"Agent avatar placeholder",status:a})})}),x.jsx("div",{className:Er.controls,children:x.jsx($j,{...o})})]}),x.jsx("div",{className:Er.middlePanel,"data-testid":"course-dialog-middle-panel",children:c??x.jsx(nF,{...l,courses:s,className:Sb(Er.coursePanel,l==null?void 0:l.className)})}),u?x.jsx("div",{className:Er.rightPanel,"data-testid":"course-dialog-right-panel",children:u}):null]})})}function QE(t){const{open:e,onClose:n,dialogProps:i,...r}=t;return x.jsx(rE,{open:e,onClose:n,variant:"ghost",...i,children:x.jsx(QH,{...r})})}const JH=80,ZH=500,$H=1e3;function eV(t,e){const{delayMs:n=0}=e??{},r=t.filter(v=>{var m;const T=(m=v.participantInfo)==null?void 0:m.identity;return(T==null?void 0:T.startsWith("agent-"))??!1}).map(v=>v.text??"").join(" ").trim(),[a,o]=A.useState(""),[s,l]=A.useState(!1),c=A.useRef(""),u=A.useRef(null),d=A.useRef(null),h=A.useRef(null),f=v=>{h.current&&(clearTimeout(h.current),h.current=null),n>0?h.current=setTimeout(()=>{o(v)},n):o(v)},y=(v,T)=>v.startsWith(T)?v.slice(T.length).trim():v.trim();return A.useEffect(()=>{if(d.current&&(clearTimeout(d.current),d.current=null),s)return;const v=y(r,c.current);f(v),v.length>JH?(l(!0),u.current=setTimeout(()=>{l(!1),c.current=r},ZH+n)):v.length>0&&(d.current=setTimeout(()=>{c.current=r,f("")},$H+n))},[r,s,n]),A.useEffect(()=>()=>{u.current&&clearTimeout(u.current),d.current&&clearTimeout(d.current),h.current&&clearTimeout(h.current)},[]),{caption:a,hasCaption:a.length>0}}const nr={layout:"_layout_17ztq_1",left:"_left_17ztq_10",copy:"_copy_17ztq_17",description:"_description_17ztq_25",descriptionScroller:"_descriptionScroller_17ztq_31",cta:"_cta_17ztq_36",disclaimer:"_disclaimer_17ztq_43",right:"_right_17ztq_47",mediaPanel:"_mediaPanel_17ztq_56",agentStill:"_agentStill_17ztq_63",dialogWithSmallClose:"_dialogWithSmallClose_17ztq_87"};function tV(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=!0,isStarting:u=!1}=t;return x.jsx(rE,{open:e,onClose:n,size:"large",showCloseButton:c,className:nr.dialogWithSmallClose,children:x.jsxs("div",{className:nr.layout,children:[x.jsxs("div",{className:nr.left,children:[x.jsxs("div",{className:nr.copy,children:[x.jsx(Zn,{variant:"heading",children:r}),x.jsx(Zn,{variant:"subheading",children:a}),x.jsx(Zn,{variant:"muted",as:"div",className:nr.description,children:x.jsx(sl,{className:nr.descriptionScroller,children:x.jsx(vj,{content:o})})})]}),x.jsxs("div",{className:nr.cta,children:[x.jsx(ol,{type:"button",size:"lg",fullWidth:!0,onClick:i,isLoading:u,children:s}),x.jsx(Zn,{variant:"subscript",as:"p",className:nr.disclaimer,children:l})]})]}),x.jsx("div",{className:nr.right,children:x.jsx(ru,{className:nr.mediaPanel,children:x.jsx(UH,{agentName:r,className:nr.agentStill})})})]})})}function nV(t){let e=t.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*/g,"__DOUBLE_STAR__").replace(/\*/g,"[^/]*").replace(/__DOUBLE_STAR__/g,".*").replace(/\?/g,"[^/]");return new RegExp(`^${e}$`,"i")}function iV(t,e){if(!e||e.length===0)return!1;const n=t.replace(/^https?:\/\//,"").replace(/\/$/,"");return e.some(i=>{try{const r=nV(i);return r.test(n)||r.test(t)}catch(r){return console.warn(`Invalid URL pattern: ${i}`,r),!1}})}function Wf(t){if(!t||t.length===0)return!1;const e=window.location.origin+window.location.pathname;return iV(e,t)}function rV(t){var gn,Mt,Di,hi,rn,Pn,$n,rr,Rr,oe,Ge,xe,Ze,st,Li,ar,oo,Ar,so,Pi;const{sdk:e,shadowHost:n}=t,[i,r]=A.useState("hidden"),[a,o]=A.useState(()=>{var Z;return((Z=e.client)==null?void 0:Z.session)||null}),[s,l]=A.useState(!1),[c,u]=A.useState(!1),[d,h]=A.useState(!1),[f,y]=A.useState(()=>{var ce;const Z=(ce=e.client)==null?void 0:ce.session;return Z!=null&&Z.sessionUuid?aV(Z.sessionUuid):null}),[v,T]=A.useState([]),[m,g]=A.useState(null),[_,p]=A.useState(0),[S,k]=A.useState(!1),[w,E]=A.useState(0),[R,O]=A.useState(null),[D,q]=A.useState([]),[Y,se]=A.useState(!0),H=oV((Mt=(gn=e.client)==null?void 0:gn.product)==null?void 0:Mt.widget_url_blacklist),P=sV(a),{audioDevices:W}=lV();A.useEffect(()=>{a!=null&&a.sessionUuid&&JE(a.sessionUuid,f)},[f,a==null?void 0:a.sessionUuid]);const{caption:X}=eV(D,{delayMs:0}),ne=Y?X:"",K=typeof navigator<"u"&&!!((Di=navigator.mediaDevices)!=null&&Di.getDisplayMedia),ee=((rn=(hi=a==null?void 0:a.room)==null?void 0:hi.localParticipant)==null?void 0:rn.isScreenShareEnabled)??!1,J=(()=>{if(a!=null&&a.speakingState){if(a.speakingState==="thinking")return"thinking";if(a.speakingState==="busy")return"searching"}})(),V=()=>p(Z=>Z+1),ae=async()=>{var ce,Ne;if(!a)return;const Z=((Ne=(ce=a.room)==null?void 0:ce.localParticipant)==null?void 0:Ne.isScreenShareEnabled)??!1;try{Z?await a.setScreenShareEnabled(!1):await a.shareScreen()}catch(Ae){console.error("[obi-sdk] failed to toggle screen share",Ae)}finally{V()}},j=A.useRef(null),ve=A.useRef(null),B=A.useRef(!1),le=Z=>{if(!Z||j.current===Z)return;ve.current&&(ve.current(),ve.current=null);const ce=()=>V(),Ne=at=>{y(at),Z!=null&&Z.sessionUuid&&JE(Z.sessionUuid,at),r(de=>de==="course-selection"?(k(!1),"pip"):de)},Ae=at=>{T(at.courses),r("course-selection"),y(null),Z!=null&&Z.sessionUuid&&ZE(Z.sessionUuid),g(null)},pt=(at,de)=>{},Ct=at=>{O(at),E(Date.now())},Yt=at=>{at&&O(at),E(Date.now())};Z.on("stateChanged",ce),Z.on("speakingStateChanged",ce),Z.on("paused",ce),Z.on("unpaused",ce),Z.on("chatMessagesChanged",ce),Z.on("courseProgress",Ne),Z.on("courseSelection",Ae),Z.on("transcript",pt),Z.on("screenCaptured",Ct),Z.on("screenCaptureNotification",Yt),Z.on("captions",q),j.current=Z,ve.current=()=>{Z.off("stateChanged",ce),Z.off("speakingStateChanged",ce),Z.off("paused",ce),Z.off("unpaused",ce),Z.off("chatMessagesChanged",ce),Z.off("courseProgress",Ne),Z.off("courseSelection",Ae),Z.off("transcript",pt),Z.off("screenCaptured",Ct),Z.off("screenCaptureNotification",Yt),Z.off("captions",q)}},me=Z=>{var Ne;return Z?((Ne=Z.roomId)==null?void 0:Ne.startsWith("obs-"))&&!f?"course-selection":"pip":"hidden"};A.useEffect(()=>{const Z=Ne=>{var Ae,pt,Ct;Ne?(Ae=e.client)!=null&&Ae.session?r(me(((pt=e.client)==null?void 0:pt.session)??null)):r("start-session"):(Ct=e.client)!=null&&Ct.session||r("hidden")},ce=()=>V();if(e.on("showMenu",Z),e.on("configUpdated",ce),e.client){e.client.session&&(o(e.client.session),le(e.client.session),r(me(e.client.session))),e.client.on("sessionStarted",Ae=>{o(Ae),le(Ae),B.current=!1,l(!1),u(!1),h(!1),r(me(Ae)),vg().track("session-started",{planId:Ae.planId})}),e.client.on("sessionResumed",Ae=>{o(Ae),le(Ae),B.current=!1,l(!1),u(!1),h(!1),r(me(Ae))});const Ne=()=>{var pt;const Ae=(pt=e.client)==null?void 0:pt.session;Ae!=null&&Ae.sessionUuid&&ZE(Ae.sessionUuid),ve.current&&(ve.current(),ve.current=null),o(null),j.current=null,l(!1),u(!1),h(!1),B.current||r("hidden")};e.client.on("sessionStopped",Ne),e.client.on("sessionShutdown",Ne),e.client.on("stateChanged",V)}return()=>{e.off("showMenu",Z),e.off("configUpdated",ce),ve.current&&ve.current()}},[e]),A.useLayoutEffect(()=>{var Z,ce;(ce=(Z=e.client)==null?void 0:Z.product)!=null&&ce.primary_color&&n.style.setProperty("--obi-color-primary",e.client.product.primary_color)},[($n=(Pn=e.client)==null?void 0:Pn.product)==null?void 0:$n.primary_color,n]);const yn=(f==null?void 0:f.stepNames.map((Z,ce)=>({id:`step-${ce+1}`,title:Z})))??[],di=(f==null?void 0:f.currentStep)??null,ir=!0,Gt=(Z,ce)=>{a==null||a.say(`Can we jump to the section about ${ce.title}?`)};if(H||i==="hidden")return null;if(i==="start-session"){const Z=(rr=e.client)==null?void 0:rr.product,ce=(Rr=e.client)==null?void 0:Rr.selectedPlan,Ne=(Z==null?void 0:Z.agent_name)||"Obi",Ae="AI Assistant",pt=(ce==null?void 0:ce.description)||(Z==null?void 0:Z.description)||"I'm here to help you.";return x.jsx(tV,{open:!0,onClose:()=>{l(!1),r("hidden")},onStart:()=>{l(!0),e.startSession({withMicrophone:!0})},agentName:Ne,agentSubtitle:Ae,description:pt,showCloseButton:!1,startLabel:"Start Session",isStarting:s})}if(i==="course-selection"){const Z=(oe=a==null?void 0:a.roomId)==null?void 0:oe.startsWith("obs-"),ce=((Ge=e.client)==null?void 0:Ge.plans)||[],Ne=Z&&v.length>0,Ae=Ne?v.slice().sort((de,Ye)=>de.order!==void 0&&Ye.order!==void 0?de.order-Ye.order:de.order!==void 0?-1:Ye.order!==void 0?1:de.name.localeCompare(Ye.name)).map(de=>({id:de.uuid,title:de.name,description:de.description||de.overview||"",status:de.completed?"completed":"available",duration:typeof de.duration=="number"?`${de.duration} min`:de.duration})):ce.map(de=>{var Ye,In;return{id:de.uuid,title:de.name,description:de.description,status:(In=(Ye=e.client)==null?void 0:Ye.planIsCompleted)!=null&&In[ce.indexOf(de)]?"completed":"available",duration:de.estimated_duration?`${de.estimated_duration} min`:void 0}}),pt=(a==null?void 0:a.languageCodes)||[],Ct=(a==null?void 0:a.selectedLanguage)||(a==null?void 0:a.defaultLanguageCode)||null,Yt={audioDevices:W,currentMicrophoneId:(a==null?void 0:a.preferredMicrophoneDeviceId)||null,isMicrophoneEnabled:!c&&((a==null?void 0:a.isMicShared)??!1),isScreenShareActive:ee,widgetState:d?"chat":null,canPublishData:!0,browserSupportsScreenSharing:K,onMicDeviceSelect:async de=>{e.client&&(e.client.preferredMicrophoneDeviceId=de),a&&de&&await a.switchMicrophoneDevice(de),V()},onMicToggle:async()=>{a!=null&&a.isMicShared?c?(a.unmuteMicrophone(),u(!1)):(a.muteMicrophone(),u(!0)):await(a==null?void 0:a.shareMicrophone())},onChatToggle:()=>{h(!d)},onLeave:()=>{a==null||a.stop()},onScreenShareToggle:ae,languages:pt,selectedLanguage:Ct,defaultLanguageCode:a==null?void 0:a.defaultLanguageCode,isMultilingual:(a==null?void 0:a.isMultilingual)??!1,onLanguageChange:de=>{a==null||a.setLanguage(de)},isLanguageSelectorEnabled:!0,...d?{screenShareButtonVariant:"compact"}:{}},at=d?x.jsx(GE,{messages:(a==null?void 0:a.chatMessages)??[],localIdentity:((xe=a==null?void 0:a.room)==null?void 0:xe.localParticipant.identity)??(typeof(a==null?void 0:a.identity)=="string"?a.identity:null),onSend:async de=>{var Ye,In,Ii,he;a&&(a.appendChatMessage({timestamp:Date.now(),message:de,from:{identity:((In=(Ye=a.room)==null?void 0:Ye.localParticipant)==null?void 0:In.identity)??null,name:((he=(Ii=a.room)==null?void 0:Ii.localParticipant)==null?void 0:he.name)??null},isAgent:!1}),await a.say(de))},onClose:()=>h(!1)}):void 0;return x.jsx(QE,{open:!0,onClose:()=>a==null?void 0:a.stop(),courses:Ae,controlBarProps:Yt,coursePanelProps:{selectedCourseIds:m?[m]:void 0,onCourseToggle:async de=>{var Ye,In,Ii;if(Ne){const he=v.find(Dt=>Dt.uuid===de);if(he){g(de);try{await((Ye=a==null?void 0:a.say)==null?void 0:Ye.call(a,`I'd like to take the ${he.name} course.`))}catch(Dt){console.error("[obi-sdk] failed to send course selection",Dt),g(null)}}}else{const he=ce.find(Dt=>Dt.uuid===de);if(he){(In=e.client)==null||In.selectPlan(he),r("pip");try{await((Ii=a==null?void 0:a.say)==null?void 0:Ii.call(a,`I'd like to take the ${he.name} course.`))}catch(Dt){console.error("[obi-sdk] failed to send course selection",Dt),r("course-selection")}}}}},rightPanel:at,avatarImageSrc:((st=(Ze=e.client)==null?void 0:Ze.product)==null?void 0:st.logo_url)||void 0,avatarAudioPower:P,avatarStatus:J,captionsText:ne})}if(i==="course-outline"){const Z=(a==null?void 0:a.languageCodes)||[],ce=(a==null?void 0:a.selectedLanguage)||(a==null?void 0:a.defaultLanguageCode)||null,Ne={audioDevices:W,currentMicrophoneId:(a==null?void 0:a.preferredMicrophoneDeviceId)||null,isMicrophoneEnabled:!c&&((a==null?void 0:a.isMicShared)??!1),isScreenShareActive:ee,widgetState:d?"chat":null,canPublishData:!0,browserSupportsScreenSharing:K,onMicDeviceSelect:async Ct=>{e.client&&(e.client.preferredMicrophoneDeviceId=Ct),a&&Ct&&await a.switchMicrophoneDevice(Ct),V()},onMicToggle:async()=>{a!=null&&a.isMicShared?c?(a.unmuteMicrophone(),u(!1)):(a.muteMicrophone(),u(!0)):await(a==null?void 0:a.shareMicrophone())},onChatToggle:()=>{h(!d)},onLeave:()=>{a==null||a.stop()},onScreenShareToggle:ae,languages:Z,selectedLanguage:ce,defaultLanguageCode:a==null?void 0:a.defaultLanguageCode,isMultilingual:(a==null?void 0:a.isMultilingual)??!1,onLanguageChange:Ct=>{a==null||a.setLanguage(Ct)},isLanguageSelectorEnabled:!0,...d?{screenShareButtonVariant:"compact"}:{}},Ae=d?x.jsx(GE,{messages:(a==null?void 0:a.chatMessages)??[],localIdentity:((Li=a==null?void 0:a.room)==null?void 0:Li.localParticipant.identity)??(typeof(a==null?void 0:a.identity)=="string"?a.identity:null),onSend:async Ct=>{var Yt,at,de,Ye;a&&(a.appendChatMessage({timestamp:Date.now(),message:Ct,from:{identity:((at=(Yt=a.room)==null?void 0:Yt.localParticipant)==null?void 0:at.identity)??null,name:((Ye=(de=a.room)==null?void 0:de.localParticipant)==null?void 0:Ye.name)??null},isAgent:!1}),await a.say(Ct))},onClose:()=>h(!1)}):void 0,pt=x.jsx(RF,{steps:yn,currentStep:di,hideTrailingConclusionStep:ir,onStepClick:Gt});return x.jsx(QE,{open:!0,onClose:()=>a==null?void 0:a.stop(),courses:[],controlBarProps:Ne,middlePanel:pt,rightPanel:Ae,avatarImageSrc:((oo=(ar=e.client)==null?void 0:ar.product)==null?void 0:oo.logo_url)||void 0,avatarAudioPower:P,avatarStatus:J,captionsText:ne})}if(i==="pip"){const Z=(a==null?void 0:a.languageCodes)||[],ce=(a==null?void 0:a.selectedLanguage)||(a==null?void 0:a.defaultLanguageCode)||null,Ne=280,Ae=250,pt=16,Ct={x:window.innerWidth-Ne-pt,y:window.innerHeight-Ae-pt},Yt={isMicrophoneEnabled:!c&&((a==null?void 0:a.isMicShared)??!1),isChatOpen:d,isScreenShareActive:ee,onMicToggle:async()=>{a!=null&&a.isMicShared?c?(a.unmuteMicrophone(),u(!1)):(a.muteMicrophone(),u(!0)):await(a==null?void 0:a.shareMicrophone())},onChatToggle:()=>h(de=>!de),onScreenShareToggle:ae,onLeave:()=>{a==null||a.stop()},languages:Z,selectedLanguage:ce,defaultLanguageCode:a==null?void 0:a.defaultLanguageCode,isMultilingual:(a==null?void 0:a.isMultilingual)??!1,onLanguageChange:de=>{a==null||a.setLanguage(de)},isLanguageSelectorEnabled:!0},at=d?x.jsx(QF,{messages:(a==null?void 0:a.chatMessages)??[],localIdentity:((Ar=a==null?void 0:a.room)==null?void 0:Ar.localParticipant.identity)??(typeof(a==null?void 0:a.identity)=="string"?a.identity:null),onSend:async de=>{var Ye,In,Ii,he;a&&(a.appendChatMessage({timestamp:Date.now(),message:de,from:{identity:((In=(Ye=a.room)==null?void 0:Ye.localParticipant)==null?void 0:In.identity)??null,name:((he=(Ii=a.room)==null?void 0:Ii.localParticipant)==null?void 0:he.name)??null},isAgent:!1}),await a.say(de))},testId:"pip-chat-panel"}):void 0;return x.jsx(_q,{initialPosition:Ct,onExit:()=>{r("course-outline")},controlBarProps:Yt,isCourseOutlineSelected:S&&!!f,onCourseOutlineToggle:f?()=>{k(de=>!de)}:void 0,isCaptionsEnabled:Y,onCaptionsToggle:()=>se(de=>!de),courseOutline:f?{steps:yn,currentStep:di,onStepClick:Gt,hideTrailingConclusionStep:ir}:void 0,messagesPanel:at,avatarFallbackProps:{audioPower:P,imageSrc:((Pi=(so=e.client)==null?void 0:so.product)==null?void 0:Pi.logo_url)??void 0,status:J,captionsText:ne},screenshotUrl:R,cameraShotTrigger:w})}return null}function JE(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 aV(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 ZE(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 oV(t){const[e,n]=A.useState(()=>Wf(t));return A.useEffect(()=>{n(Wf(t))},[t]),A.useEffect(()=>{const i=()=>{n(Wf(t))};return window.addEventListener("popstate",i),window.addEventListener("hashchange",i),()=>{window.removeEventListener("popstate",i),window.removeEventListener("hashchange",i)}},[t]),e}function sV(t){const[e,n]=A.useState(0),i=A.useRef(null),r=A.useRef(0),a=A.useRef(0);return A.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 y=0;for(let v=0;v<s.length;v++)y+=s[v];l=Math.min(1,Math.max(0,y/s.length))}const c=r.current,d=l>=c?.7:.15,h=c*d+l*(1-d);r.current=h;const f=h<.05?0:Math.min(1,h);Math.abs(f-a.current)>.01&&(a.current=f,n(f)),i.current=requestAnimationFrame(o)};return i.current=requestAnimationFrame(o),()=>{i.current&&cancelAnimationFrame(i.current)}},[t]),e}function lV(){const[t,e]=A.useState({audioDevices:[]});return A.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 cV(t){if(document.querySelector("#obi-host")||document.querySelector("obi-widget"))return;uV();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(tB);const a=new CSSStyleSheet;a.replaceSync($9);const o=new CSSStyleSheet;o.replaceSync(Z9);const s=new CSSStyleSheet;s.replaceSync(eB),n.adoptedStyleSheets=[r,a,o,s],J9.createRoot(i).render(x.jsx(rV,{sdk:t,shadowHost:e})),console.log("[obi-sdk] widget mounted")}function uV(){$E("https://fonts.cdnfonts.com/css/satoshi"),$E("https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap")}function $E(t){const e=document.createElement("link");e.href=t,e.rel="stylesheet",document.head.appendChild(e)}const e3="49206C6F7665204F6269_session",t3="obi-url-params";class dV extends Jf{constructor(e){super(),this.client=null,this.isActive=!1,this.primaryColour="#9500FF",this.passivePlanUuid=null,this.commandLog=[],this.commandQueue=[],this._resumed=!1,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=this.load();if(i)try{n=Jd.deserialise(i,e,"sdk",{apiBaseUrl:"https://staging.coragents.ai",captureScreen:this.captureScreen.bind(this)}),n?this._resumed=!0:localStorage.removeItem("obi-client")}catch(r){console.error("[obi] error loading cached client",r),localStorage.removeItem("obi-client")}n||(n=new Jd(e,"sdk",{apiBaseUrl:"https://staging.coragents.ai",captureScreen:this.captureScreen.bind(this)})),this.client=n,this.client.on("stateChanged",r=>{var a,o,s,l,c,u,d,h,f,y;r==="ready"&&this.updateConfig({isActive:((a=window==null?void 0:window.obiWidgetConfig)==null?void 0:a.isActive)??((o=this.client)==null?void 0:o.showWidget),primaryColour:((l=(s=this.client)==null?void 0:s.product)==null?void 0:l.primary_color)||"#9500FF",widgetDisplay:((c=window==null?void 0:window.obiWidgetConfig)==null?void 0:c.widgetDisplay)||((d=(u=this.client)==null?void 0:u.product)==null?void 0:d.widget_display)||"regular",completedWidgetDisplay:((h=window==null?void 0:window.obiWidgetConfig)==null?void 0:h.completedWidgetDisplay)||((y=(f=this.client)==null?void 0:f.product)==null?void 0:y.completed_widget_display)||"regular"})}),this.client.on("sessionStarted",()=>{this.save(),this.passivePlanUuid=null}),this.client.on("sessionStopped",()=>{localStorage.removeItem("obi-client"),this.passivePlanUuid=null}),this.client.on("sessionShutdown",()=>{localStorage.removeItem("obi-client")}),this.client.on("trackEvent",(r,a)=>{}),this.client.session&&(this.client.session.isPaused,this.client.resumeSession(r=>{r.on("stateChanged",a=>{a!=="disconnecting"&&a!=="disconnected"&&a!=="error"&&a!=="connecting"&&this.save()}),r.on("paused",()=>{this.save()}),r.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&&Wf(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{vg().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){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),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&&vg().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(t3)||"{}"),Object.keys(e).length===0&&new URLSearchParams(window.location.search).forEach((a,o)=>{e[o]=a});const n=e[e3];if(!n)return null;const i=new URL(window.location.href);i.searchParams.delete(e3),window.history.replaceState({},"",i.toString()),i.toString(),localStorage.removeItem(t3),this.passivePlanUuid=n}mountWidget(){cV(this)}showMessage(e,n){try{this.emit("showMessage",{text:e,autoCloseMs:n==null?void 0:n.autoCloseMs})}catch{}}async captureScreen(){try{await OO(async()=>(this.graphemes||(this.graphemes=await this.client.api.getGraphemes()),this.graphemes.data.text_segmentation)),await k3(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 lO(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")}}async function n3(t,e){let n;try{n=window}catch{console.warn("[obi] no window object found"),n={}}return hV({appToken:t,window:n,init:e})}async function hV({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 dV(t);return e.ObiSDK=r.dispatchCommand,await r.initialise({queuedCommands:i}),e.obi=r,r.mountWidget(),r}function i3(){}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{n3(void 0,i3)}):n3(void 0,i3)})();
120
+ Please report this to https://github.com/markedjs/marked.`,t){let i="<p>An error occurred:</p><pre>"+aa(n.message+"",!0)+"</pre>";return e?Promise.resolve(i):i}if(e)return Promise.reject(n);throw n}}},Fo=new hj;function Ke(t,e){return Fo.parse(t,e)}Ke.options=Ke.setOptions=function(t){return Fo.setOptions(t),Ke.defaults=Fo.defaults,bE(Ke.defaults),Ke},Ke.getDefaults=ob,Ke.defaults=qo,Ke.use=function(...t){return Fo.use(...t),Ke.defaults=Fo.defaults,bE(Ke.defaults),Ke},Ke.walkTokens=function(t,e){return Fo.walkTokens(t,e)},Ke.parseInline=Fo.parseInline,Ke.Parser=$i,Ke.parser=$i.parse,Ke.Renderer=zf,Ke.TextRenderer=mb,Ke.Lexer=Zi,Ke.lexer=Zi.lex,Ke.Tokenizer=jf,Ke.Hooks=nu,Ke.parse=Ke,Ke.options,Ke.setOptions,Ke.use,Ke.walkTokens,Ke.parseInline,$i.parse,Zi.lex;const fj="_base_1ne03_1",pj={base:fj},mj=["p","br","strong","em","u","a","ul","ol","li","h1","h2","h3","h4","h5","h6","code","pre","blockquote","hr"],gj=["href","title","target","rel"];Ke.setOptions({breaks:!0,gfm:!0});function vj(t){const{content:e,className:n,...i}=t,r=A.useMemo(()=>{if(!e)return"";const a=Ke.parse(e,{async:!1});return A7.sanitize(a,{ALLOWED_TAGS:[...mj],ALLOWED_ATTR:[...gj],ALLOW_DATA_ATTR:!1})},[e]);return r?x.jsx("div",{className:re(pj.base,n),dangerouslySetInnerHTML:{__html:r},...i}):null}const bj="_controlBar_14416_1",yj="_popoverAnchor_14416_11",_j="_confirmationPopover_14416_15",xj="_confirmationPopoverAlignRight_14416_30",Sj="_confirmationPopoverAlignCenter_14416_33",Tj="_confirmationMessage_14416_53",kj="_confirmationActions_14416_60",wj="_confirmationButton_14416_65",Cj="_confirmationButtonCancel_14416_83",Ej="_confirmationButtonNeutral_14416_91",Rj="_confirmationButtonDanger_14416_99",Aj="_controlButton_14416_108",Oj="_controlButtonIconOnly_14416_130",Nj="_controlButtonDisabled_14416_135",Mj="_controlButtonDanger_14416_162",Dj="_controlButtonContent_14416_178",Lj="_controlButtonIcon_14416_130",Pj="_controlButtonLabel_14416_194",Ij="_controlButtonChevron_14416_201",Bj="_controlButtonNotificationDot_14416_210",Uj="_deviceSplitButton_14416_222",jj="_deviceSplitButtonEnabled_14416_226",zj="_dualButtonContent_14416_307",qj="_dualButtonIcon_14416_317",Fj="_dualButtonLabel_14416_326",Hj="_screenShareButton_14416_340",Vj="_screenShareButtonCompact_14416_351",Le={controlBar:bj,popoverAnchor:yj,confirmationPopover:_j,confirmationPopoverAlignRight:xj,confirmationPopoverAlignCenter:Sj,confirmationMessage:Tj,confirmationActions:kj,confirmationButton:wj,confirmationButtonCancel:Cj,confirmationButtonNeutral:Ej,confirmationButtonDanger:Rj,controlButton:Aj,controlButtonIconOnly:Oj,controlButtonDisabled:Nj,controlButtonDanger:Mj,controlButtonContent:Dj,controlButtonIcon:Lj,controlButtonLabel:Pj,controlButtonChevron:Ij,controlButtonNotificationDot:Bj,deviceSplitButton:Uj,deviceSplitButtonEnabled:jj,dualButtonContent:zj,dualButtonIcon:qj,dualButtonLabel:Fj,screenShareButton:Hj,screenShareButtonCompact:Vj},Gj="_inline_1gpyx_1",Yj="_vertical_1gpyx_6",Wj="_divider_1gpyx_10",Kj="_dividerVertical_1gpyx_16",Xj="_customDivider_1gpyx_21",iu={inline:Gj,vertical:Yj,divider:Wj,dividerVertical:Kj,customDivider:Xj},PE={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 er(t){if(t!==void 0){if(typeof t=="number")return`${t}px`;if(t in PE)return PE[t];if(typeof t=="string"&&t.trim().length>0)return t}}function Qj(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,f=n??"div",y={display:"flex",flexDirection:i==="horizontal"?"row":"column",flexWrap:s?"wrap":"nowrap",alignItems:a,...o?{justifyContent:o}:{},...u};if(r!==void 0){const g=er(r);g&&(y.gap=g)}const v=Vn.Children.toArray(d).filter(g=>g!=null&&typeof g!="boolean"),T=g=>!l||g===0?null:l===!0||l==="line"?x.jsx("span",{"aria-hidden":"true",className:re(iu.divider,i==="vertical"&&iu.dividerVertical)},`inline-divider-${g}`):x.jsx("span",{"aria-hidden":"true",className:iu.customDivider,children:l},`inline-divider-${g}`),m=[];return v.forEach((g,_)=>{if(_>0){const p=T(_);p&&m.push(p)}m.push(g)}),x.jsx(f,{ref:e,className:re(iu.inline,i==="vertical"&&iu.vertical,c),style:y,...h,children:m})}const gb=Vn.forwardRef(Qj);gb.displayName="Inline";function Jj(){const[t,e]=A.useState(()=>typeof window>"u"?!1:window.innerWidth<768);return A.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 vb(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,f=re(Le.controlButton,a&&Le.controlButtonDisabled,l&&Le.controlButtonIconOnly,r==="danger"&&Le.controlButtonDanger,o),y=Number.parseInt(Kv[s],10),v=r==="danger"?"outline":"primary",T=r==="danger"?"danger":"default",m=x.jsxs(x.Fragment,{children:[x.jsxs("span",{className:Le.controlButtonContent,children:[e?x.jsx("span",{className:Le.controlButtonIcon,children:Vn.isValidElement(e)&&e.props.size===void 0?Vn.cloneElement(e,{size:y}):e}):null,l?null:x.jsx("span",{className:Le.controlButtonLabel,children:n}),l||!i?null:x.jsx("span",{className:Le.controlButtonChevron,"aria-hidden":"true",children:x.jsx(Xv,{size:16})})]}),c?x.jsx("span",{className:Le.controlButtonNotificationDot,"aria-hidden":"true"}):null]});return typeof u=="boolean"?x.jsx(Of,{...h,type:"button",disabled:a,variant:v,color:T,isOn:u,"aria-label":d||n,className:f,"data-has-notification":c?"true":void 0,children:m}):x.jsx(ol,{...h,type:"button",disabled:a,variant:v,color:T,"aria-label":d||n,className:f,"data-has-notification":c?"true":void 0,children:m})}function Zj(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:f,showChatNotification:y=!1,isLanguageSelectorEnabled:v=!0,languages:T=[],selectedLanguage:m=null,defaultLanguageCode:g=null,isMultilingual:_=!1,onLanguageChange:p,isChatOpen:S=a==="chat"}=t,k=T.length,w=v&&_&&k>0,E=Jj(),R=E?"xs":"sm",O=E,[D,q]=A.useState(!1),[Y,se]=A.useState(!1),H=A.useRef(null),P=A.useRef(null);A.useEffect(()=>{const B=me=>{const yn=me.composedPath();D&&H.current&&!yn.includes(H.current)&&q(!1),Y&&P.current&&!yn.includes(P.current)&&se(!1)},le=me=>{me.key==="Escape"&&(D&&q(!1),Y&&se(!1))};if(D||Y)return document.addEventListener("mousedown",B),document.addEventListener("keydown",le),()=>{document.removeEventListener("mousedown",B),document.removeEventListener("keydown",le)}},[D,Y]),A.useEffect(()=>{r||q(!1)},[r]);const W=A.useMemo(()=>e.map(B=>({label:B.label||`Microphone ${B.deviceId.slice(0,8)}`,value:B.deviceId})),[e]),X=A.useMemo(()=>n?W.find(B=>B.value===n)??null:null,[n,W]),ne=A.useCallback(B=>{B.value,c(B.value)},[c]),K={microphone:!0,screenShare:s,chat:o},ee=A.useCallback(()=>{if(r){q(!0);return}f()},[r,f]),J=A.useCallback(()=>{q(!1),f()},[f]),V=A.useCallback(()=>{q(!1)},[]),ae=A.useCallback(()=>{se(!0)},[]),j=A.useCallback(()=>{se(!1),h()},[h]),ve=A.useCallback(()=>{se(!1)},[]);return x.jsx("div",{className:Le.controlBar,"data-testid":"control-bar","data-controls":JSON.stringify(K),"data-language-option-count":k>0?String(k):void 0,"data-default-language-code":g??void 0,children:x.jsxs(gb,{gap:R,align:"center",justify:"center",wrap:O,children:[x.jsx(UU,{onClick:u,buttonAriaLabel:i?"Mute microphone":"Unmute microphone",options:W,value:X,onChange:ne,variant:"primary",menuPlacement:"top",menuDisabled:W.length===0,menuAriaLabel:"Select microphone device",listboxAriaLabel:"Microphone devices",ariaPressed:i,className:re(Le.deviceSplitButton,i&&Le.deviceSplitButtonEnabled),children:x.jsxs("span",{className:Le.dualButtonContent,children:[x.jsx("span",{className:Le.dualButtonIcon,children:i?x.jsx(G2,{}):x.jsx(Y2,{})}),x.jsx("span",{className:Le.dualButtonLabel,children:"Microphone"})]})}),o?x.jsx(vb,{icon:x.jsx(F2,{}),label:"Chat",onClick:d,isOn:S,"aria-label":"Toggle chat",showNotificationDot:y}):null,s?x.jsxs("div",{ref:H,className:Le.popoverAnchor,children:[x.jsx(vb,{icon:x.jsx(W2,{}),label:r?"Share screen off":"Share screen",className:l==="compact"?Le.screenShareButtonCompact:Le.screenShareButton,iconOnly:l==="compact",onClick:ee,isOn:r,"aria-label":r?"Stop screen sharing":"Start screen sharing"}),D?x.jsxs("div",{className:re(Le.confirmationPopover,Le.confirmationPopoverAlignCenter),role:"dialog","aria-label":"Stop screen sharing confirmation","data-testid":"confirm-stop-share",children:[x.jsx("p",{className:Le.confirmationMessage,children:"Stop screen sharing?"}),x.jsxs("div",{className:Le.confirmationActions,children:[x.jsx("button",{type:"button",className:re(Le.confirmationButton,Le.confirmationButtonCancel),onClick:V,children:"Cancel"}),x.jsx("button",{type:"button",className:re(Le.confirmationButton,Le.confirmationButtonNeutral),onClick:J,children:"Stop"})]})]}):null]}):null,w?x.jsx(tE,{languages:T,value:m,onChange:p,defaultLanguageCode:g,variant:"control-bar"}):null,x.jsxs("div",{ref:P,className:Le.popoverAnchor,children:[x.jsx(vb,{icon:x.jsx(V2,{}),label:"Leave",variant:"danger",onClick:ae,"aria-label":"Leave meeting"}),Y?x.jsxs("div",{className:re(Le.confirmationPopover,Le.confirmationPopoverAlignRight),role:"dialog","aria-label":"Leave meeting confirmation","data-testid":"confirm-leave",children:[x.jsx("p",{className:Le.confirmationMessage,children:"Would you like to end the call?"}),x.jsxs("div",{className:Le.confirmationActions,children:[x.jsx("button",{type:"button",className:re(Le.confirmationButton,Le.confirmationButtonCancel),onClick:ve,children:"Cancel"}),x.jsx("button",{type:"button",className:re(Le.confirmationButton,Le.confirmationButtonDanger),onClick:j,children:"Leave"})]})]}):null]})]})})}function $j(t){return x.jsx(Zj,{...t})}const ez="_controlBar_75i8h_1",tz="_controlButton_75i8h_12",nz="_controlButtonDisabled_75i8h_35",iz="_controlButtonDanger_75i8h_62",rz="_controlButtonIconOnly_75i8h_78",az="_screenShareButton_75i8h_83",oz="_controlButtonContent_75i8h_88",sz="_controlButtonIcon_75i8h_78",lz="_controlButtonLabel_75i8h_103",cz="_controlButtonNotificationDot_75i8h_108",uz="_popoverAnchor_75i8h_198",dz="_confirmationPopover_75i8h_202",hz="_confirmationMessage_75i8h_216",fz="_confirmationActions_75i8h_223",pz="_confirmationButton_75i8h_228",mz="_confirmationButtonCancel_75i8h_246",gz="_confirmationButtonDanger_75i8h_254",nn={controlBar:ez,controlButton:tz,controlButtonDisabled:nz,controlButtonDanger:iz,controlButtonIconOnly:rz,screenShareButton:az,controlButtonContent:oz,controlButtonIcon:sz,controlButtonLabel:lz,controlButtonNotificationDot:cz,popoverAnchor:uz,confirmationPopover:dz,confirmationMessage:hz,confirmationActions:fz,confirmationButton:pz,confirmationButtonCancel:mz,confirmationButtonDanger:gz};function Ff(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=re(nn.controlButton,r&&nn.controlButtonDisabled,o&&nn.controlButtonIconOnly,i==="danger"&&nn.controlButtonDanger,a),h=i==="danger"?"outline":"primary",f=i==="danger"?"danger":"default",y=x.jsxs(x.Fragment,{children:[x.jsxs("span",{className:nn.controlButtonContent,children:[e?x.jsx("span",{className:nn.controlButtonIcon,children:Vn.isValidElement(e)&&e.props.size===void 0?Vn.cloneElement(e,{size:20}):e}):null,o?null:x.jsx("span",{className:nn.controlButtonLabel,children:n})]}),s?x.jsx("span",{className:nn.controlButtonNotificationDot,"aria-hidden":"true"}):null]});return typeof l=="boolean"?x.jsx(Of,{...u,type:"button",disabled:r,variant:h,color:f,size:"xs",isOn:l,"aria-label":c||n,className:d,"data-has-notification":s?"true":void 0,children:y}):x.jsx(ol,{...u,type:"button",disabled:r,variant:h,color:f,size:"xs","aria-label":c||n,className:d,"data-has-notification":s?"true":void 0,children:y})}function vz(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,onLanguageChange:f,isLanguageSelectorEnabled:y=!0,className:v,testId:T,...m}=t,g=!y||!h||c.length===0,[_,p]=A.useState(!1),S=A.useRef(null);A.useEffect(()=>{const D=Y=>{const se=Y.composedPath();_&&S.current&&!se.includes(S.current)&&p(!1)},q=Y=>{Y.key==="Escape"&&_&&p(!1)};if(_)return document.addEventListener("mousedown",D),document.addEventListener("keydown",q),()=>{document.removeEventListener("mousedown",D),document.removeEventListener("keydown",q)}},[_]);const k=A.useCallback(()=>{a()},[a]),w=A.useCallback(()=>{s()},[s]),E=A.useCallback(()=>{p(!0)},[]),R=A.useCallback(()=>{p(!1),l()},[l]),O=A.useCallback(()=>{p(!1)},[]);return x.jsx("div",{...m,className:re(nn.controlBar,v),"data-testid":T,children:x.jsxs(gb,{gap:"xs",align:"center",justify:"center",wrap:!1,children:[x.jsx(Ff,{icon:e?x.jsx(G2,{}):x.jsx(Y2,{}),label:"Microphone",iconOnly:!0,isOn:e,onClick:k,"aria-label":e?"Mute microphone":"Unmute microphone"}),x.jsx(Ff,{icon:x.jsx(F2,{}),label:"Chat",iconOnly:!0,isOn:n,onClick:o,"aria-label":"Toggle chat",showNotificationDot:r}),x.jsx(Ff,{icon:x.jsx(W2,{}),label:"Screen share",iconOnly:!0,className:nn.screenShareButton,isOn:i,onClick:w,"aria-label":i?"Stop screen sharing":"Start screen sharing"}),x.jsx(tE,{languages:c,value:u,onChange:f,defaultLanguageCode:d,variant:"pip",disabled:g}),x.jsxs("div",{ref:S,className:nn.popoverAnchor,children:[x.jsx(Ff,{icon:x.jsx(V2,{}),label:"Hang up",iconOnly:!0,variant:"danger",onClick:E,"aria-label":"Hang up"}),_?x.jsxs("div",{className:nn.confirmationPopover,role:"dialog","aria-label":"Hang up confirmation","data-testid":"confirm-leave",children:[x.jsx("p",{className:nn.confirmationMessage,children:"Would you like to end the call?"}),x.jsxs("div",{className:nn.confirmationActions,children:[x.jsx("button",{type:"button",className:re(nn.confirmationButton,nn.confirmationButtonCancel),onClick:O,children:"Cancel"}),x.jsx("button",{type:"button",className:re(nn.confirmationButton,nn.confirmationButtonDanger),onClick:R,children:"Leave"})]})]}):null]})]})})}function bz(t){return x.jsx(vz,{...t})}const yz="_container_zht0b_1",_z="_containerGradient_zht0b_14",xz="_containerFlat_zht0b_24",Sz="_halo_zht0b_28",Tz="_outerRing_zht0b_38",kz="_circle_zht0b_42",wz="_image_zht0b_72",Cz="_captionContainer_zht0b_88",Ez="_captionRegion_zht0b_99",oa={container:yz,containerGradient:_z,containerFlat:xz,halo:Sz,outerRing:Tz,circle:kz,image:wz,captionContainer:Cz,captionRegion:Ez},Rz="_statusText_1dkze_6",Az={statusText:Rz},Oz={idle:null,thinking:"Thinking...",searching:"Searching..."};function Nz(t){const{status:e,size:n="md"}=t,i=e?Oz[e]:null,r=i!==null;return x.jsx("div",{className:Az.statusText,"data-visible":r,"data-size":n,"aria-live":"polite",children:i})}const Mz="https://obi-static.s3.ap-southeast-2.amazonaws.com/images/obi-avatar.png",Dz={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 IE(t){const{audioPower:e,size:n="md",background:i="gradient",imageSrc:r=Mz,accentColor:a,ariaLabel:o="Avatar placeholder",status:s,captionsText:l,className:c,style:u,...d}=t,h=Dz[n],f=Math.min(1,Math.max(0,e)),y=f>.01,v=y?Math.min(1,f/.5):0,T=y?Math.max(1,v*h.maxBorderWidth):0,m=1.02,g=y?m+f*h.outerRingScalePower:m,_=y?.2+f*.35:0,p={...u??{},...a?{"--avatar-fallback-accent":a}:{}},S={"--avatar-fallback-halo-size":h.haloSize,"--avatar-fallback-border-width":`${T}px`,"--avatar-fallback-secondary-border-scale":g.toString(),"--avatar-fallback-secondary-border-opacity":_.toString(),"--avatar-fallback-glow-size":h.glowSize},k=l!=null&&l!=="";return x.jsxs("div",{...d,className:re(oa.container,i==="gradient"?oa.containerGradient:oa.containerFlat,c),style:p,"data-testid":"avatar-fallback","aria-label":o,role:"img",children:[x.jsxs("div",{className:oa.halo,style:S,children:[x.jsx("div",{className:oa.outerRing,"aria-hidden":"true"}),x.jsx("div",{className:oa.circle,children:x.jsx("img",{className:oa.image,src:r,alt:"","aria-hidden":"true"})}),x.jsx(Nz,{status:s,size:n})]}),k&&x.jsx("div",{className:oa.captionContainer,children:x.jsx("div",{className:oa.captionRegion,"data-size":n,role:"status","aria-live":"polite","aria-atomic":"true",children:l})})]})}const Lz="_container_1k3qg_11",Pz="_screenshot_1k3qg_20",Iz="_flash_1k3qg_30",bb={container:Lz,screenshot:Pz,flash:Iz};function Bz(t){const{isActive:e,imageUrl:n,onComplete:i,duration:r=2e3}=t,[a,o]=A.useState(!1),s=A.useRef(null);return A.useEffect(()=>{if(!e){o(!1),s.current&&(clearTimeout(s.current),s.current=null);return}if(!s.current)return o(!0),s.current=setTimeout(()=>{o(!1),s.current=null,i==null||i()},r),()=>{s.current&&(clearTimeout(s.current),s.current=null)}},[e,r,i]),a?x.jsxs("div",{className:bb.container,"aria-live":"polite","aria-label":"Screenshot captured",children:[n&&x.jsx("img",{src:n,alt:"Captured screenshot",className:bb.screenshot}),x.jsx("div",{className:bb.flash})]}):null}const Uz="_container_13ukq_1",jz="_dragging_13ukq_5",zz="_placeholder_13ukq_9",qz="_handleButton_13ukq_15",Fz="_customHandle_13ukq_105",cl={container:Uz,dragging:jz,placeholder:zz,handleButton:qz,"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:Fz};function Hz(t){const{disabled:e,lingerMs:n,isDragging:i}=t,[r,a]=A.useState(!1),o=A.useRef(null),s=A.useCallback(()=>{o.current!==null&&(window.clearTimeout(o.current),o.current=null)},[]),l=A.useCallback(()=>{e||(s(),a(!0))},[s,e]),c=A.useCallback(()=>{e||i||(s(),o.current=window.setTimeout(()=>{a(!1),o.current=null},n))},[s,e,i,n]);return A.useEffect(()=>{i&&l()},[i,l]),A.useEffect(()=>s,[s]),{isHandleVisible:r,showHandle:l,scheduleHideHandle:c}}function Vz(t){const{initialPosition:e,preserveSpace:n,onPositionChange:i}=t,r=A.useRef(null),[a,o]=A.useState(!!e),[s,l]=A.useState(!1),[c,u]=A.useState(null),[d,h]=A.useState(()=>e??{x:0,y:0}),f=A.useRef(d);s||(f.current=d);const y=A.useRef(null),v=A.useRef(!1),T=A.useRef(!1);A.useEffect(()=>{e&&(T.current||(o(!0),h(e),f.current=e))},[e==null?void 0:e.x,e==null?void 0:e.y]),A.useEffect(()=>{if(e||v.current)return;const p=r.current;if(!p)return;const S=p.getBoundingClientRect(),k={x:S.left,y:S.top};v.current=!0,o(!0),h(k),f.current=k,u(n?{width:S.width,height:S.height}:null)},[e,n]);const m=A.useCallback(p=>{const S=y.current;if(!(!S||p.pointerId!==S.pointerId)){y.current=null,T.current=!0,h(f.current),l(!1);try{p.currentTarget.releasePointerCapture(S.pointerId)}catch{}}},[]),g=A.useCallback(p=>{p.button===0&&(p.preventDefault(),p.currentTarget.setPointerCapture(p.pointerId),y.current={pointerId:p.pointerId,startClientX:p.clientX,startClientY:p.clientY,startX:f.current.x,startY:f.current.y},l(!0))},[]),_=A.useCallback(p=>{const S=y.current;if(!S||p.pointerId!==S.pointerId)return;const k={x:S.startX+(p.clientX-S.startClientX),y:S.startY+(p.clientY-S.startClientY)};f.current=k,r.current&&(r.current.style.transform=`translate3d(${k.x}px, ${k.y}px, 0)`),i==null||i(k)},[i]);return{containerRef:r,isFixed:a,isDragging:s,position:d,placeholderSize:c,onPointerDown:g,onPointerMove:_,endDrag:m}}function Gz(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:f,isFixed:y,isDragging:v,position:T,placeholderSize:m,onPointerDown:g,onPointerMove:_,endDrag:p}=Vz({initialPosition:r,preserveSpace:o,onPositionChange:l}),{isHandleVisible:S,showHandle:k,scheduleHideHandle:w}=Hz({disabled:a,lingerMs:u,isDragging:v}),E=typeof e=="function",R=A.useMemo(()=>{const D=q=>x.jsx("div",{className:re(cl.customHandle,q.className),onPointerDown:g,onPointerMove:_,onPointerUp:p,onPointerCancel:p,children:q.children});return D.displayName="Draggable.Handle",D},[g,_,p]),O={...d,position:y?"fixed":"relative",top:y?0:d==null?void 0:d.top,left:y?0:d==null?void 0:d.left,transform:y?`translate3d(${T.x}px, ${T.y}px, 0)`:d==null?void 0:d.transform,zIndex:y?s:d==null?void 0:d.zIndex};return x.jsxs(x.Fragment,{children:[o&&y&&m?x.jsx("div",{className:cl.placeholder,style:{width:m.width,height:m.height}}):null,x.jsxs("div",{ref:f,className:re(cl.container,v?cl.dragging:null,n),"data-handle-visible":E?void 0:a?"false":S||v?"true":"false",style:O,onMouseEnter:E?void 0:k,onMouseLeave:E?void 0:w,...h,children:[!E&&!a?x.jsx("button",{type:"button",className:re(cl.handleButton,cl[`handle-${i}`]),"aria-label":c,onMouseEnter:k,onMouseLeave:w,onPointerDown:D=>{k(),g(D)},onPointerMove:_,onPointerUp:p,onPointerCancel:p}):null,E?e({Handle:R}):e]})]})}const Yz="_container_1u25n_1",Wz="_captionRegion_1u25n_14",Kz="_status_1u25n_22",Xz="_captionText_1u25n_29",Hf={container:Yz,captionRegion:Wz,status:Kz,captionText:Xz},Qz={idle:null,thinking:"Thinking...",searching:"Searching..."};function Jz(t){const{text:e,status:n,className:i,...r}=t,a=n?Qz[n]:null;return x.jsx("div",{...r,className:re(Hf.container,i),"data-testid":"pip-captions-panel",children:x.jsxs("div",{className:Hf.captionRegion,role:"status","aria-live":"polite","aria-atomic":"true",children:[a?x.jsx("div",{className:Hf.status,children:a}):null,x.jsx("div",{className:Hf.captionText,children:e})]})})}const Zz="_panel_1npcg_1",$z="_row_1npcg_20",eq="_stepContent_1npcg_26",tq="_stepLabel_1npcg_35",nq="_currentStep_1npcg_42",iq="_nextStep_1npcg_49",rq="_skipRow_1npcg_63",aq="_circleButton_1npcg_68",oq="_arrowPlaceholder_1npcg_93",sq="_skipButton_1npcg_99",Mi={panel:Zz,row:$z,stepContent:eq,stepLabel:tq,currentStep:nq,nextStep:iq,skipRow:rq,circleButton:aq,arrowPlaceholder:oq,skipButton:sq};function lq(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 BE(t,e){return e<=0||typeof t!="number"||!Number.isFinite(t)?0:Math.min(Math.max(Math.trunc(t),1),e)-1}function cq(t){var k;const{steps:e,currentStep:n,onStepClick:i,hideTrailingConclusionStep:r=!0,className:a,testId:o,...s}=t,{visibleSteps:l,currentIndex:c}=A.useMemo(()=>lq(e,n,r),[n,r,e]),[u,d]=A.useState(()=>BE(n,l.length));A.useEffect(()=>{d(BE(n,l.length))},[n,l]);const h=l.length,f=l[u],y=u>0,v=u<h-1,T=v?(k=l[u+1])==null?void 0:k.title:void 0,m=h===0?0:u+1,g=c!==null&&f&&u!==c,_=()=>{y&&d(w=>Math.max(w-1,0))},p=()=>{v&&d(w=>Math.min(w+1,h-1))},S=()=>{!g||!f||!i||i(u,f)};return x.jsxs("div",{...s,className:re(Mi.panel,a),"data-testid":o,role:"group","aria-label":"Course progress",children:[x.jsxs("div",{className:Mi.row,children:[y?x.jsx("button",{type:"button",className:Mi.circleButton,"aria-label":"Previous step",onClick:_,children:x.jsx(aB,{size:14})}):x.jsx("span",{className:Mi.arrowPlaceholder,"aria-hidden":"true"}),x.jsxs("div",{className:Mi.stepContent,children:[x.jsxs(Zn,{className:Mi.stepLabel,"aria-live":"polite",children:["Step ",m,"/",h]}),x.jsx(Zn,{className:Mi.currentStep,"data-testid":"pip-outline-current-step",children:(f==null?void 0:f.title)??"No steps available"}),T?x.jsxs(Zn,{variant:"muted",className:Mi.nextStep,children:["Next: ",T]}):null]}),v?x.jsx("button",{type:"button",className:Mi.circleButton,"aria-label":"Next step",onClick:p,children:x.jsx(oB,{size:14})}):x.jsx("span",{className:Mi.arrowPlaceholder,"aria-hidden":"true"})]}),g?x.jsx("div",{className:Mi.skipRow,children:x.jsx("button",{type:"button",className:Mi.skipButton,"aria-label":"Skip to this step",onClick:S,children:x.jsx(uB,{size:14})})}):null]})}const uq="_window_1q008_1",dq="_exitButton_1q008_13",hq="_content_1q008_43",fq="_contentTopOverlay_1q008_53",pq="_contentTopOverlaySlot_1q008_67",mq="_dragHandle_1q008_77",gq="_contentBottomOverlay_1q008_82",vq="_controls_1q008_91",ro={window:uq,exitButton:dq,content:hq,contentTopOverlay:fq,contentTopOverlaySlot:pq,dragHandle:mq,contentBottomOverlay:gq,controls:vq};function bq(t){return t==null?!1:typeof t=="string"?t.trim().length>0:!0}function yq(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:f,testId:y,...v}=t,T=i,m=n.isChatOpen&&!T&&l,g=c==null?void 0:c.captionsText,_=a&&bq(g),[p,S]=A.useState(!1);A.useEffect(()=>{h&&h>0&&S(!0)},[h]);const k=A.useCallback(()=>x.jsx(IE,{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]),w=T?s?x.jsx(cq,{steps:s.steps,currentStep:s.currentStep,onStepClick:s.onStepClick,hideTrailingConclusionStep:s.hideTrailingConclusionStep}):k():m?l:_?x.jsx(Jz,{text:g}):k();return x.jsxs("div",{...v,className:re(ro.window,f),"data-testid":y,role:"group","aria-label":"Picture-in-Picture",children:[x.jsxs("div",{className:ro.content,children:[x.jsxs("div",{className:ro.contentTopOverlay,children:[u?x.jsx("div",{className:ro.contentTopOverlaySlot,children:u}):null,x.jsx("button",{type:"button",className:ro.exitButton,onClick:e,"aria-label":"Exit PiP",children:x.jsx(sB,{size:14})})]}),w,!m&&x.jsxs("div",{className:ro.contentBottomOverlay,children:[x.jsx(Of,{isOn:i,onClick:r,variant:"primary",size:"xs","aria-label":"Toggle course outline",children:x.jsx(dB,{size:18})}),x.jsx(Of,{isOn:a,onClick:o,variant:"primary",size:"xs","aria-label":"Toggle captions",children:x.jsx(rB,{size:18})})]}),x.jsx(Bz,{isActive:p,imageUrl:d??null,onComplete:()=>S(!1)})]}),x.jsx("div",{className:ro.controls,children:x.jsx(bz,{...n})})]})}function _q(t){const{initialPosition:e,onPositionChange:n,zIndex:i=1e3,...r}=t;return x.jsx(Gz,{initialPosition:e,onPositionChange:n,zIndex:i,preserveSpace:!1,children:({Handle:a})=>x.jsx(yq,{...r,contentTopOverlaySlot:x.jsx(a,{className:ro.dragHandle})})})}const xq="_root_ygi3o_1",Sq="_overlay_ygi3o_7",Tq="_caption_ygi3o_17",yb={root:xq,overlay:Sq,caption:Tq};function kq(t){return t==null?!1:typeof t=="string"?t.trim().length>0:!0}function wq(t){const{children:e,className:n,text:i}=t,r=kq(i);return x.jsxs("div",{className:re(yb.root,n),children:[e,r?x.jsx("div",{className:yb.overlay,role:"status","aria-live":"polite","aria-atomic":"true",children:x.jsx("div",{className:yb.caption,children:i})}):null]})}const Cq="_box_1r6by_1",Eq={box:Cq},UE={none:"0px",panel:"var(--radius-panel)",card:"var(--radius-card)"},jE={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 Rq(t){if(t!==void 0){if(typeof t=="number")return`${t}px`;if(t in UE)return UE[t];if(typeof t=="string"&&t.trim().length>0)return t}}function Aq(t){if(t!==void 0){if(t in jE)return jE[t];if(typeof t=="string"&&t.trim().length>0)return t}}function Oq(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:f,paddingXl:y,margin:v,marginX:T,marginY:m,marginTop:g,marginBottom:_,marginLeft:p,marginRight:S,radius:k,radiusTop:w,radiusBottom:E,radiusLeft:R,radiusRight:O,radiusTopLeft:D,radiusTopRight:q,radiusBottomLeft:Y,radiusBottomRight:se,background:H,gap:P,style:W,...X}=t,ne=n??"div",K={...W},ee=K,J={},V=(B,le)=>{if(le===void 0)return;const me=er(le);me&&(K[B]=me)},ae=(B,le)=>{if(le===void 0)return;const me=er(le);me&&(K[B]=me)},j=(B,le)=>{if(le===void 0)return;const me=Rq(le);me&&(K[B]=me)},ve={sm:d,md:h,lg:f,xl:y};if(r!==void 0){const B=er(r);B&&(ee["--box-padding"]=B)}for(const[B,le]of Object.entries(ve)){if(le===void 0)continue;const me=er(le);me&&(ee[`--box-padding-${B}`]=me,J[`data-padding-${B}`]="")}if(a!==void 0){const B=er(a);B&&(K.paddingLeft=B,K.paddingRight=B)}if(o!==void 0){const B=er(o);B&&(K.paddingTop=B,K.paddingBottom=B)}if(V("paddingTop",s),V("paddingBottom",l),V("paddingLeft",c),V("paddingRight",u),v!==void 0){const B=er(v);B&&(K.margin=B)}if(T!==void 0){const B=er(T);B&&(K.marginLeft=B,K.marginRight=B)}if(m!==void 0){const B=er(m);B&&(K.marginTop=B,K.marginBottom=B)}if(ae("marginTop",g),ae("marginBottom",_),ae("marginLeft",p),ae("marginRight",S),P!==void 0){const B=er(P);B&&(K.gap=B)}if(j("borderRadius",k),w!==void 0&&(j("borderTopLeftRadius",w),j("borderTopRightRadius",w)),E!==void 0&&(j("borderBottomLeftRadius",E),j("borderBottomRightRadius",E)),R!==void 0&&(j("borderTopLeftRadius",R),j("borderBottomLeftRadius",R)),O!==void 0&&(j("borderTopRightRadius",O),j("borderBottomRightRadius",O)),j("borderTopLeftRadius",D),j("borderTopRightRadius",q),j("borderBottomLeftRadius",Y),j("borderBottomRightRadius",se),H!==void 0){const B=Aq(H);B&&(K.background=B)}return x.jsx(ne,{ref:e,className:re(Eq.box,i),style:K,...J,...X})}const Vf=Vn.forwardRef(Oq);Vf.displayName="Box";const Nq="_panel_eawk4_1",Mq="_selected_eawk4_10",zE={panel:Nq,selected:Mq};function ru(t){const{children:e,className:n,selected:i,...r}=t;return x.jsx("div",{className:re(zE.panel,i?zE.selected:null,n),...r,children:e})}const Dq="_root_yccm8_1",Lq="_header_yccm8_8",Pq="_icon_yccm8_15",Iq="_text_yccm8_26",Bq="_heading_yccm8_33",Uq="_description_yccm8_41",jq="_body_yccm8_47",zq="_footer_yccm8_54",ao={root:Dq,header:Lq,icon:Pq,text:Iq,heading:Bq,description:Uq,body:jq,footer:zq};function qE(t){const{className:e,...n}=t;return x.jsx("div",{className:re(ao.icon,e),...n})}function FE(t){const{className:e,...n}=t;return x.jsx("h3",{className:re(ao.heading,e),...n})}function HE(t){const{className:e,...n}=t;return x.jsx("p",{className:re(ao.description,e),...n})}function VE(t){const{className:e,...n}=t;return x.jsx("div",{className:re(ao.footer,e),...n})}function qq(t){const e=A.Children.toArray(t),n=[];let i,r,a,o;for(const s of e){if(A.isValidElement(s)&&s.type===qE&&i===void 0){i=s;continue}if(A.isValidElement(s)&&s.type===FE&&r===void 0){r=s;continue}if(A.isValidElement(s)&&s.type===HE&&a===void 0){a=s;continue}if(A.isValidElement(s)&&s.type===VE&&o===void 0){o=s;continue}n.push(s)}return{icon:i,heading:r,description:a,footer:o,body:n}}function Fq(t){const{children:e,className:n,...i}=t,r=qq(e),a=r.icon||r.heading||r.description;return x.jsxs(ru,{className:re(ao.root,n),...i,children:[a?x.jsxs("div",{className:ao.header,children:[r.icon,r.heading||r.description?x.jsxs("div",{className:ao.text,children:[r.heading,r.description]}):null]}):null,r.body.length?x.jsx("div",{className:ao.body,children:r.body}):null,r.footer]})}const _b=Object.assign(Fq,{Icon:qE,Heading:FE,Description:HE,Footer:VE}),Hq="_panel_1uwhd_1",Vq="_header_1uwhd_11",Gq="_title_1uwhd_19",Yq="_scrollArea_1uwhd_29",Wq="_scrollable_1uwhd_34",Kq="_list_1uwhd_38",Xq="_courseButton_1uwhd_44",Qq="_courseCard_1uwhd_55",Jq="_courseHeading_1uwhd_64",Zq="_courseDescription_1uwhd_70",$q="_empty_1uwhd_79",tr={panel:Hq,header:Vq,title:Gq,scrollArea:Yq,scrollable:Wq,list:Kq,courseButton:Xq,courseCard:Qq,courseHeading:Jq,courseDescription:Zq,empty:$q};function eF(t){const{selectionMode:e,selectedCourseIds:n,defaultSelectedCourseIds:i,onSelectedCourseIdsChange:r}=t,a=n!==void 0,[o,s]=A.useState(()=>i??[]),l=a?n:o,c=A.useCallback(d=>{a||s(d),r==null||r(d)},[a,r]),u=A.useCallback(d=>{const h=l.includes(d);if(e==="single"){c(h?[]:[d]);return}if(h){c(l.filter(f=>f!==d));return}c([...l,d])},[l,e,c]);return{selectedCourseIds:l,toggleCourseId:u}}function tF(t){const{title:e="Courses",ariaLabel:n,className:i,courses:r,selectionMode:a="multiple",selectedCourseIds:o,onCourseToggle:s,emptyMessage:l="No courses available",testId:c,...u}=t;return x.jsxs(ru,{...u,className:re(tr.panel,i),role:"region","aria-label":n??e,"data-testid":c,children:[x.jsx("div",{className:tr.header,children:x.jsx(Zn,{as:"h2",className:tr.title,children:e})}),x.jsx("div",{className:tr.scrollArea,children:x.jsx(sl,{className:tr.scrollable,children:r.length===0?x.jsx(Zn,{variant:"muted",className:tr.empty,"data-testid":"course-panel-empty",children:l}):x.jsx("div",{className:tr.list,"data-testid":"course-panel-list",children:r.map(d=>{const h=o.includes(d.id),f=d.disabled===!0;return x.jsx("button",{type:"button",className:tr.courseButton,"aria-pressed":h,"aria-disabled":f,disabled:f,onClick:()=>s==null?void 0:s(d.id,d),"data-testid":`course-panel-item-${d.id}`,children:x.jsxs(_b,{selected:h,className:tr.courseCard,children:[x.jsx(_b.Heading,{className:tr.courseHeading,children:d.title}),d.description?x.jsx(_b.Description,{className:tr.courseDescription,children:d.description}):null]})},d.id)})})})})]})}function nF(t){const{selectionMode:e="multiple",selectedCourseIds:n,defaultSelectedCourseIds:i,onSelectedCourseIdsChange:r,onCourseToggle:a,...o}=t,{selectedCourseIds:s,toggleCourseId:l}=eF({selectionMode:e,selectedCourseIds:n,defaultSelectedCourseIds:i,onSelectedCourseIdsChange:r}),c=A.useCallback((u,d)=>{l(u),a==null||a(u,d)},[a,l]);return x.jsx(tF,{...o,selectionMode:e,selectedCourseIds:s,onCourseToggle:c})}const iF="_panel_1on05_1",rF="_header_1on05_11",aF="_divider_1on05_19",oF="_title_1on05_25",sF="_scrollArea_1on05_35",lF="_scrollable_1on05_40",cF="_list_1on05_44",uF="_section_1on05_50",dF="_sectionHeader_1on05_56",hF="_sectionTitle_1on05_60",fF="_sectionTitleCompact_1on05_68",pF="_item_1on05_72",mF="_itemClickable_1on05_86",gF="_itemCompleted_1on05_90",vF="_itemCurrent_1on05_94",bF="_itemFuture_1on05_98",yF="_itemDisabled_1on05_103",_F="_row_1on05_117",xF="_stepHeader_1on05_124",SF="_stepNumber_1on05_133",TF="_stepTitle_1on05_139",kF="_checkIcon_1on05_151",wF="_empty_1on05_155",He={panel:iF,header:rF,divider:aF,title:oF,scrollArea:sF,scrollable:lF,list:cF,section:uF,sectionHeader:dF,sectionTitle:hF,sectionTitleCompact:fF,item:pF,itemClickable:mF,itemCompleted:gF,itemCurrent:vF,itemFuture:bF,itemDisabled:yF,row:_F,stepHeader:xF,stepNumber:SF,stepTitle:TF,checkIcon:kF,empty:wF};function CF(t){var f;const{steps:e,currentStep:n,hideTrailingConclusionStep:i}=t,r=e.length,a=i&&r>0&&((f=e[r-1])==null?void 0:f.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},(y,v)=>v),currentIndex:null,futureIndices:[]};const c=Math.min(Math.max(l,1),s)-1,u=Array.from({length:Math.max(0,c)},(y,v)=>v),d=Math.min(c,s-1),h=Array.from({length:Math.max(0,s-(d+1))},(y,v)=>d+1+v);return{visibleSteps:o,completedIndices:u,currentIndex:d,futureIndices:h}}function EF(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,...d}=t,h=A.useCallback(_=>(_+1).toString().padStart(2,"0"),[]),{visibleSteps:f,completedIndices:y,currentIndex:v,futureIndices:T}=A.useMemo(()=>CF({steps:r,currentStep:a,hideTrailingConclusionStep:s}),[a,s,r]),m=c==="compact"?"md":"lg",g=A.useCallback((_,p)=>{const S=f[_];if(!S)return null;const k=typeof o=="function",w=k&&S.disabled===!0,E=k&&!w,R=re(He.item,{[He.itemClickable]:E,[He.itemCompleted]:p==="completed",[He.itemCurrent]:p==="current",[He.itemFuture]:p==="future",[He.itemDisabled]:w}),O=x.jsxs("div",{className:He.row,children:[x.jsxs("div",{className:He.stepHeader,children:[x.jsx("span",{className:He.stepNumber,children:h(_)}),x.jsx("span",{className:He.stepTitle,children:S.title})]}),p==="completed"?x.jsx(Rf,{size:20,className:He.checkIcon}):null]});return k?x.jsx(Vf,{as:"button",type:"button",className:R,onClick:()=>{E&&o(_,S)},disabled:w,"aria-current":p==="current"?"step":void 0,"aria-label":`Step ${h(_)}: ${S.title}`,"data-testid":`course-outline-item-${S.id}`,padding:m,radius:"panel",gap:"sm",children:O},S.id):x.jsx(Vf,{className:R,"aria-current":p==="current"?"step":void 0,"aria-label":`Step ${h(_)}: ${S.title}`,"data-testid":`course-outline-item-${S.id}`,padding:m,radius:"panel",gap:"sm",children:O},S.id)},[h,m,o,f]);return x.jsxs(ru,{...d,className:re(He.panel,i),role:"region","aria-label":n??e,"data-testid":u,children:[x.jsx("div",{className:He.header,children:x.jsx(Zn,{as:"h2",className:He.title,children:e})}),x.jsx("div",{className:He.divider,"aria-hidden":"true"}),x.jsx("div",{className:He.scrollArea,children:x.jsx(sl,{className:He.scrollable,children:f.length===0?x.jsx(Zn,{variant:"muted",className:He.empty,"data-testid":"course-outline-empty",children:l}):x.jsxs("div",{className:He.list,"data-testid":"course-outline-list",children:[y.length>0?x.jsxs("div",{className:He.section,"data-testid":"course-outline-section-completed",children:[x.jsx("div",{className:He.sectionHeader,children:x.jsx("span",{className:re(He.sectionTitle,c==="compact"?He.sectionTitleCompact:null),children:"Completed"})}),y.map(_=>g(_,"completed"))]}):null,v!==null?x.jsxs("div",{className:He.section,"data-testid":"course-outline-section-current",children:[x.jsx("div",{className:He.sectionHeader,children:x.jsx("span",{className:re(He.sectionTitle,c==="compact"?He.sectionTitleCompact:null),children:"Current"})}),g(v,"current")]}):null,T.length>0?x.jsxs("div",{className:He.section,"data-testid":"course-outline-section-upcoming",children:[x.jsx("div",{className:He.sectionHeader,children:x.jsx("span",{className:re(He.sectionTitle,c==="compact"?He.sectionTitleCompact:null),children:"Upcoming"})}),T.map(_=>g(_,"future"))]}):null]})})})]})}function RF(t){return x.jsx(EF,{...t})}const AF="_panel_8h64k_1",OF="_messagesArea_8h64k_20",NF="_messagesList_8h64k_46",MF="_messageItem_8h64k_53",DF="_messageMetadata_8h64k_59",LF="_senderName_8h64k_67",PF="_timestamp_8h64k_71",IF="_messageBubble_8h64k_75",BF="_agentMessage_8h64k_85",UF="_agentActions_8h64k_89",jF="_copyButton_8h64k_95",zF="_copyButtonCopied_8h64k_129",qF="_empty_8h64k_133",FF="_composer_8h64k_140",HF="_composerDisabled_8h64k_160",VF="_composerInput_8h64k_165",GF="_sendButton_8h64k_180",mn={panel:AF,messagesArea:OF,messagesList:NF,messageItem:MF,messageMetadata:DF,senderName:LF,timestamp:PF,messageBubble:IF,agentMessage:BF,agentActions:UF,copyButton:jF,copyButtonCopied:zF,empty:qF,composer:FF,composerDisabled:HF,composerInput:VF,sendButton:GF};function YF(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 WF(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 KF(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 XF(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 QF(t){const{messages:e,localIdentity:n,onSend:i,isSending:r=!1,inputPlaceholder:a="Type a message...",className:o,testId:s,...l}=t,[c,u]=A.useState(""),[d,h]=A.useState(null),f=A.useRef(null),y=A.useRef(null),v=A.useMemo(()=>{const p=e[e.length-1];return p?p.id??`${p.timestamp}-${e.length-1}`:null},[e]);A.useEffect(()=>{var p,S;(S=(p=f.current)==null?void 0:p.scrollIntoView)==null||S.call(p,{behavior:"smooth"})},[v]),A.useEffect(()=>()=>{y.current&&(window.clearTimeout(y.current),y.current=null)},[]);const T=A.useCallback(async()=>{const p=c.trim();p.length!==0&&(await i(p),u(""))},[c,i]),m=A.useCallback(p=>{p.key==="Enter"&&(p.preventDefault(),T())},[T]),g=A.useCallback(async(p,S)=>{try{await XF(p.message??""),h(S),y.current&&window.clearTimeout(y.current),y.current=window.setTimeout(()=>{h(null),y.current=null},2e3)}catch(k){console.warn("[PiPChatPanel] Failed to copy message",k)}},[]),_=c.trim().length>0&&!r;return x.jsxs("div",{...l,className:re(mn.panel,o),"data-testid":s,role:"region","aria-label":"Chat",children:[x.jsx("div",{className:mn.messagesArea,children:e.length===0?x.jsx("div",{className:mn.empty,"data-testid":"pip-chat-panel-empty",children:"No messages yet"}):x.jsxs("div",{className:mn.messagesList,"data-testid":"pip-chat-panel-list",children:[e.map((p,S)=>{const k=p.id??`${p.timestamp}-${S}`,w=WF(p,n),E=d===k;return x.jsxs("div",{className:re(mn.messageItem,w&&mn.agentMessage),"data-testid":`pip-chat-panel-message-${k}`,children:[x.jsxs("div",{className:mn.messageMetadata,children:[x.jsx("span",{className:mn.senderName,children:KF(p,n)}),x.jsx("span",{className:mn.timestamp,children:YF(p.timestamp)})]}),x.jsx("div",{className:mn.messageBubble,children:p.message}),w?x.jsx("div",{className:mn.agentActions,children:x.jsx("button",{type:"button",className:re(mn.copyButton,E&&mn.copyButtonCopied),onClick:()=>void g(p,k),"aria-label":E?"Copied":"Copy message",title:E?"Copied":"Copy message","data-testid":"pip-copy-agent-message","data-copied":E?"true":"false",children:x.jsx(H2,{size:14})})}):null]},k)}),x.jsx("div",{ref:f})]})}),x.jsxs("div",{className:re(mn.composer,r&&mn.composerDisabled),children:[x.jsx("input",{type:"text",className:mn.composerInput,value:c,onChange:p=>u(p.target.value),onKeyDown:m,placeholder:a,disabled:r,"aria-label":"Message"}),x.jsx("button",{type:"button",className:mn.sendButton,onClick:()=>void T(),disabled:!_,"aria-label":"Send message",children:x.jsx(K2,{size:16})})]})]})}const JF="_panel_q8m25_1",ZF="_header_q8m25_11",$F="_title_q8m25_19",eH="_titleCompact_q8m25_29",tH="_headerActions_q8m25_33",nH="_closeButton_q8m25_39",iH="_divider_q8m25_67",rH="_body_q8m25_73",aH="_messagesArea_q8m25_81",oH="_scrollable_q8m25_86",sH="_messagesList_q8m25_90",lH="_messageItem_q8m25_98",cH="_messageMetadata_q8m25_104",uH="_senderName_q8m25_112",dH="_timestamp_q8m25_116",hH="_messageBubble_q8m25_120",fH="_messageText_q8m25_124",pH="_agentMessage_q8m25_130",mH="_agentActions_q8m25_134",gH="_copyButton_q8m25_140",vH="_copyButtonCopied_q8m25_174",bH="_inputRow_q8m25_178",yH="_empty_q8m25_182",_H="_composer_q8m25_188",xH="_composerDefault_q8m25_203",SH="_composerCompact_q8m25_208",TH="_composerDisabled_q8m25_218",kH="_composerInputWrapper_q8m25_223",wH="_composerInput_q8m25_223",CH="_sendButton_q8m25_240",EH="_sendButtonCompact_q8m25_257",Ve={panel:JF,header:ZF,title:$F,titleCompact:eH,headerActions:tH,closeButton:nH,divider:iH,body:rH,messagesArea:aH,scrollable:oH,messagesList:sH,messageItem:lH,messageMetadata:cH,senderName:uH,timestamp:dH,messageBubble:hH,messageText:fH,agentMessage:pH,agentActions:mH,copyButton:gH,copyButtonCopied:vH,inputRow:bH,empty:yH,composer:_H,composerDefault:xH,composerCompact:SH,composerDisabled:TH,composerInputWrapper:kH,composerInput:wH,sendButton:CH,sendButtonCompact:EH};function RH(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 AH(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 OH(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 NH(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 MH(t){const{disabled:e,placeholder:n,size:i="md",autoFocus:r,onSend:a}=t,[o,s]=A.useState(""),l=A.useCallback(async()=>{const f=o.trim();f.length!==0&&(await a(f),s(""))},[a,o]),c=A.useCallback(f=>{f.key==="Enter"&&(f.preventDefault(),l())},[l]),u=i==="sm"||i==="xs",d=u?18:24,h=o.trim().length>0&&e!==!0;return x.jsxs("div",{className:re(Ve.composer,u?Ve.composerCompact:Ve.composerDefault,e?Ve.composerDisabled:null),children:[x.jsx("div",{className:Ve.composerInputWrapper,children:x.jsx(Q2,{value:o,onChange:s,onKeyDown:c,className:Ve.composerInput,placeholder:n??"Send a message ...",disabled:e,size:i,autoFocus:r,"aria-label":"Message"})}),x.jsx("button",{type:"button",className:re(Ve.sendButton,u?Ve.sendButtonCompact:null),onClick:()=>void l(),disabled:!h,"aria-label":"Send message",children:x.jsx(K2,{size:d})})]})}function GE(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:f=RH,getSenderName:y,isAgentMessage:v,copyResetDelayMs:T=2e3,showAgentCopyButton:m=!0,inputPlaceholder:g,inputAutoFocus:_,...p}=t,S=A.useRef(null),[k,w]=A.useState(null),E=A.useRef(null),R=A.useCallback(H=>y?y(H):OH(H,o),[y,o]),O=A.useCallback(H=>v?v(H,o):AH(H,o),[v,o]),D=A.useMemo(()=>{const H=r[r.length-1];return H?H.id??`${H.timestamp}-${r.length-1}`:null},[r]);A.useEffect(()=>{var H,P;(P=(H=S.current)==null?void 0:H.scrollIntoView)==null||P.call(H,{behavior:"smooth"})},[D]),A.useEffect(()=>()=>{E.current&&(window.clearTimeout(E.current),E.current=null)},[]);const q=A.useCallback(H=>{w(H),E.current&&window.clearTimeout(E.current),E.current=window.setTimeout(()=>{w(null),E.current=null},T)},[T]),Y=A.useCallback(async(H,P)=>{try{await NH(H.message??""),q(P)}catch(W){console.warn("[ChatPanel] Failed to copy message",W)}},[q]),se=d==="compact"?"sm":"md";return x.jsxs(ru,{...p,className:re(Ve.panel,i),role:"region","aria-label":n??e,"data-testid":h,children:[x.jsxs("div",{className:Ve.header,children:[x.jsx(Zn,{as:"h2",className:re(Ve.title,d==="compact"?Ve.titleCompact:null),children:e}),l&&c?x.jsx("div",{className:Ve.headerActions,children:x.jsx("button",{type:"button",className:Ve.closeButton,onClick:l,"aria-label":`Close ${e}`,children:x.jsx(Af,{size:d==="compact"?18:20})})}):null]}),x.jsx("div",{className:Ve.divider,"aria-hidden":"true"}),x.jsxs("div",{className:Ve.body,children:[x.jsx("div",{className:Ve.messagesArea,children:x.jsx(sl,{className:Ve.scrollable,children:r.length===0?x.jsx(Zn,{variant:"muted",className:Ve.empty,"data-testid":"chat-panel-empty",children:u}):x.jsxs("div",{className:Ve.messagesList,"data-testid":"chat-panel-list",children:[r.map((H,P)=>{const W=H.id??`${H.timestamp}-${P}`,X=O(H),ne=k===W;return x.jsxs("div",{className:re(Ve.messageItem,X?Ve.agentMessage:null),"data-testid":`chat-panel-message-${W}`,children:[x.jsxs("div",{className:Ve.messageMetadata,children:[x.jsx("span",{className:Ve.senderName,children:R(H)}),x.jsx("span",{className:Ve.timestamp,children:f(H.timestamp)})]}),x.jsx(Vf,{className:Ve.messageBubble,padding:"md",radius:"panel",background:X?"surfaceMuted":"surface",children:x.jsx("div",{className:Ve.messageText,children:H.message})}),X&&m?x.jsx("div",{className:Ve.agentActions,children:x.jsx("button",{type:"button",className:re(Ve.copyButton,ne?Ve.copyButtonCopied:null),onClick:()=>void Y(H,W),"aria-label":ne?"Copied":"Copy agent message",title:ne?"Copied":"Copy agent message","data-testid":"copy-agent-message","data-copied":ne?"true":"false",children:x.jsx(H2,{size:18})})}):null]},W)}),x.jsx("div",{ref:S})]})})}),x.jsx("div",{className:Ve.inputRow,children:x.jsx(MH,{onSend:s,disabled:a,placeholder:g,size:se,autoFocus:_})})]})]})}A.createContext("vertical");const DH="_container_1a1i6_1",LH="_video_1a1i6_7",PH="_chip_1a1i6_16",IH="_logo_1a1i6_34",Gf={container:DH,video:LH,chip:PH,logo:IH},BH="https://obi-static.s3.ap-southeast-2.amazonaws.com/videos/greeting.mp4";function UH(t){const{agentName:e="Obi",className:n,...i}=t,r=A.useRef(null),a=()=>{var o;try{(o=r.current)==null||o.pause()}catch{}};return x.jsxs("div",{className:re(Gf.container,n),...i,children:[x.jsx("video",{ref:r,className:Gf.video,src:BH,autoPlay:!0,muted:!0,playsInline:!0,onEnded:a}),x.jsxs("div",{className:Gf.chip,children:[x.jsx(lB,{size:14,className:Gf.logo}),x.jsx("span",{children:e})]})]})}typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;const YE=50,ul="?",WE=/\(error: (.*)\)/,KE=/captureMessage|captureException/;function jH(...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(`
121
+ `);for(let s=i;s<o.length;s++){const l=o[s];if(l.length>1024)continue;const c=WE.test(l)?l.replace(WE,"$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>=YE+r)break}}return zH(a.slice(r))}}function zH(t){if(!t.length)return[];const e=Array.from(t);return/sentryWrapped/.test(Yf(e).function||"")&&e.pop(),e.reverse(),KE.test(Yf(e).function||"")&&(e.pop(),KE.test(Yf(e).function||"")&&e.pop()),e.slice(0,YE).map(n=>({...n,filename:n.filename||Yf(e).filename,function:n.function||ul}))}function Yf(t){return t[t.length-1]||{}}typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;const qH=30,FH=50;function xb(t,e,n,i){const r={filename:t,function:e==="<anonymous>"?ul:e,in_app:!0};return n!==void 0&&(r.lineno=n),i!==void 0&&(r.colno=i),r}const HH=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,VH=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,GH=/\((\S*)(?::(\d+))(?::(\d+))\)/,YH=t=>{const e=HH.exec(t);if(e){const[,i,r,a]=e;return xb(i,ul,+r,+a)}const n=VH.exec(t);if(n){if(n[2]&&n[2].indexOf("eval")===0){const a=GH.exec(n[2]);a&&(n[2]=a[1],n[3]=a[2],n[4]=a[3])}const[i,r]=XE(n[1]||ul,n[2]);return xb(r,i,n[3]?+n[3]:void 0,n[4]?+n[4]:void 0)}},WH=[qH,YH],KH=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,XH=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i;jH(...[WH,[FH,t=>{const e=KH.exec(t);if(e){if(e[3]&&e[3].indexOf(" > eval")>-1){const r=XH.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]||ul;return[i,n]=XE(i,n),xb(n,i,e[4]?+e[4]:void 0,e[5]?+e[5]:void 0)}}]]);const XE=(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]:ul,n?`safari-extension:${e}`:`safari-web-extension:${e}`]:[t,e]};typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;const Er={shell:"_shell_3h8q7_1",layout:"_layout_3h8q7_11",layoutThree:"_layoutThree_3h8q7_23",leftPanel:"_leftPanel_3h8q7_27",middlePanel:"_middlePanel_3h8q7_36",rightPanel:"_rightPanel_3h8q7_37",videoFrame:"_videoFrame_3h8q7_41",captions:"_captions_3h8q7_51",controls:"_controls_3h8q7_57",coursePanel:"_coursePanel_3h8q7_70"};function Sb(...t){return t.filter(Boolean).join(" ")}function QH(t){const{captionsText:e,avatarAudioPower:n=0,avatarImageSrc:i,avatarAriaLabel:r,avatarStatus:a,controlBarProps:o,courses:s,coursePanelProps:l,middlePanel:c,rightPanel:u,className:d}=t;return x.jsx("div",{className:Sb(Er.shell,d),"data-testid":"course-dialog-content",children:x.jsxs("div",{className:Sb(Er.layout,u?Er.layoutThree:null),children:[x.jsxs("div",{className:Er.leftPanel,children:[x.jsx("div",{className:Er.videoFrame,children:x.jsx(wq,{className:Er.captions,text:e,children:x.jsx(IE,{audioPower:n,size:"lg",background:"flat",imageSrc:i,ariaLabel:r??"Agent avatar placeholder",status:a})})}),x.jsx("div",{className:Er.controls,children:x.jsx($j,{...o})})]}),x.jsx("div",{className:Er.middlePanel,"data-testid":"course-dialog-middle-panel",children:c??x.jsx(nF,{...l,courses:s,className:Sb(Er.coursePanel,l==null?void 0:l.className)})}),u?x.jsx("div",{className:Er.rightPanel,"data-testid":"course-dialog-right-panel",children:u}):null]})})}function QE(t){const{open:e,onClose:n,dialogProps:i,...r}=t;return x.jsx(rE,{open:e,onClose:n,variant:"ghost",...i,children:x.jsx(QH,{...r})})}const JH=80,ZH=500,$H=1e3;function eV(t,e){const{delayMs:n=0}=e??{},r=t.filter(v=>{var m;const T=(m=v.participantInfo)==null?void 0:m.identity;return(T==null?void 0:T.startsWith("agent-"))??!1}).map(v=>v.text??"").join(" ").trim(),[a,o]=A.useState(""),[s,l]=A.useState(!1),c=A.useRef(""),u=A.useRef(null),d=A.useRef(null),h=A.useRef(null),f=v=>{h.current&&(clearTimeout(h.current),h.current=null),n>0?h.current=setTimeout(()=>{o(v)},n):o(v)},y=(v,T)=>v.startsWith(T)?v.slice(T.length).trim():v.trim();return A.useEffect(()=>{if(d.current&&(clearTimeout(d.current),d.current=null),s)return;const v=y(r,c.current);f(v),v.length>JH?(l(!0),u.current=setTimeout(()=>{l(!1),c.current=r},ZH+n)):v.length>0&&(d.current=setTimeout(()=>{c.current=r,f("")},$H+n))},[r,s,n]),A.useEffect(()=>()=>{u.current&&clearTimeout(u.current),d.current&&clearTimeout(d.current),h.current&&clearTimeout(h.current)},[]),{caption:a,hasCaption:a.length>0}}const nr={layout:"_layout_17ztq_1",left:"_left_17ztq_10",copy:"_copy_17ztq_17",description:"_description_17ztq_25",descriptionScroller:"_descriptionScroller_17ztq_31",cta:"_cta_17ztq_36",disclaimer:"_disclaimer_17ztq_43",right:"_right_17ztq_47",mediaPanel:"_mediaPanel_17ztq_56",agentStill:"_agentStill_17ztq_63",dialogWithSmallClose:"_dialogWithSmallClose_17ztq_87"};function tV(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=!0,isStarting:u=!1}=t;return x.jsx(rE,{open:e,onClose:n,size:"large",showCloseButton:c,className:nr.dialogWithSmallClose,children:x.jsxs("div",{className:nr.layout,children:[x.jsxs("div",{className:nr.left,children:[x.jsxs("div",{className:nr.copy,children:[x.jsx(Zn,{variant:"heading",children:r}),x.jsx(Zn,{variant:"subheading",children:a}),x.jsx(Zn,{variant:"muted",as:"div",className:nr.description,children:x.jsx(sl,{className:nr.descriptionScroller,children:x.jsx(vj,{content:o})})})]}),x.jsxs("div",{className:nr.cta,children:[x.jsx(ol,{type:"button",size:"lg",fullWidth:!0,onClick:i,isLoading:u,children:s}),x.jsx(Zn,{variant:"subscript",as:"p",className:nr.disclaimer,children:l})]})]}),x.jsx("div",{className:nr.right,children:x.jsx(ru,{className:nr.mediaPanel,children:x.jsx(UH,{agentName:r,className:nr.agentStill})})})]})})}function nV(t){let e=t.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*/g,"__DOUBLE_STAR__").replace(/\*/g,"[^/]*").replace(/__DOUBLE_STAR__/g,".*").replace(/\?/g,"[^/]");return new RegExp(`^${e}$`,"i")}function iV(t,e){if(!e||e.length===0)return!1;const n=t.replace(/^https?:\/\//,"").replace(/\/$/,"");return e.some(i=>{try{const r=nV(i);return r.test(n)||r.test(t)}catch(r){return console.warn(`Invalid URL pattern: ${i}`,r),!1}})}function Wf(t){if(!t||t.length===0)return!1;const e=window.location.origin+window.location.pathname;return iV(e,t)}function rV(t){var gn,Mt,Di,hi,rn,Pn,$n,rr,Rr,oe,Ge,xe,Ze,st,Li,ar,oo,Ar,so,Pi;const{sdk:e,shadowHost:n}=t,[i,r]=A.useState("hidden"),[a,o]=A.useState(()=>{var Z;return((Z=e.client)==null?void 0:Z.session)||null}),[s,l]=A.useState(!1),[c,u]=A.useState(!1),[d,h]=A.useState(!1),[f,y]=A.useState(()=>{var ce;const Z=(ce=e.client)==null?void 0:ce.session;return Z!=null&&Z.sessionUuid?aV(Z.sessionUuid):null}),[v,T]=A.useState([]),[m,g]=A.useState(null),[_,p]=A.useState(0),[S,k]=A.useState(!1),[w,E]=A.useState(0),[R,O]=A.useState(null),[D,q]=A.useState([]),[Y,se]=A.useState(!0),H=oV((Mt=(gn=e.client)==null?void 0:gn.product)==null?void 0:Mt.widget_url_blacklist),P=sV(a),{audioDevices:W}=lV();A.useEffect(()=>{a!=null&&a.sessionUuid&&JE(a.sessionUuid,f)},[f,a==null?void 0:a.sessionUuid]);const{caption:X}=eV(D,{delayMs:0}),ne=Y?X:"",K=typeof navigator<"u"&&!!((Di=navigator.mediaDevices)!=null&&Di.getDisplayMedia),ee=((rn=(hi=a==null?void 0:a.room)==null?void 0:hi.localParticipant)==null?void 0:rn.isScreenShareEnabled)??!1,J=(()=>{if(a!=null&&a.speakingState){if(a.speakingState==="thinking")return"thinking";if(a.speakingState==="busy")return"searching"}})(),V=()=>p(Z=>Z+1),ae=async()=>{var ce,Ne;if(!a)return;const Z=((Ne=(ce=a.room)==null?void 0:ce.localParticipant)==null?void 0:Ne.isScreenShareEnabled)??!1;try{Z?await a.setScreenShareEnabled(!1):await a.shareScreen()}catch(Ae){console.error("[obi-sdk] failed to toggle screen share",Ae)}finally{V()}},j=A.useRef(null),ve=A.useRef(null),B=A.useRef(!1),le=Z=>{if(!Z||j.current===Z)return;ve.current&&(ve.current(),ve.current=null);const ce=()=>V(),Ne=at=>{y(at),Z!=null&&Z.sessionUuid&&JE(Z.sessionUuid,at),r(de=>de==="course-selection"?(k(!1),"pip"):de)},Ae=at=>{T(at.courses),r("course-selection"),y(null),Z!=null&&Z.sessionUuid&&ZE(Z.sessionUuid),g(null)},pt=(at,de)=>{},Ct=at=>{O(at),E(Date.now())},Yt=at=>{at&&O(at),E(Date.now())};Z.on("stateChanged",ce),Z.on("speakingStateChanged",ce),Z.on("paused",ce),Z.on("unpaused",ce),Z.on("chatMessagesChanged",ce),Z.on("courseProgress",Ne),Z.on("courseSelection",Ae),Z.on("transcript",pt),Z.on("screenCaptured",Ct),Z.on("screenCaptureNotification",Yt),Z.on("captions",q),j.current=Z,ve.current=()=>{Z.off("stateChanged",ce),Z.off("speakingStateChanged",ce),Z.off("paused",ce),Z.off("unpaused",ce),Z.off("chatMessagesChanged",ce),Z.off("courseProgress",Ne),Z.off("courseSelection",Ae),Z.off("transcript",pt),Z.off("screenCaptured",Ct),Z.off("screenCaptureNotification",Yt),Z.off("captions",q)}},me=Z=>{var Ne;return Z?((Ne=Z.roomId)==null?void 0:Ne.startsWith("obs-"))&&!f?"course-selection":"pip":"hidden"};A.useEffect(()=>{const Z=Ne=>{var Ae,pt,Ct;Ne?(Ae=e.client)!=null&&Ae.session?r(me(((pt=e.client)==null?void 0:pt.session)??null)):r("start-session"):(Ct=e.client)!=null&&Ct.session||r("hidden")},ce=()=>V();if(e.on("showMenu",Z),e.on("configUpdated",ce),e.client){e.client.session&&(o(e.client.session),le(e.client.session),r(me(e.client.session))),e.client.on("sessionStarted",Ae=>{o(Ae),le(Ae),B.current=!1,l(!1),u(!1),h(!1),r(me(Ae)),vg().track("session-started",{planId:Ae.planId})}),e.client.on("sessionResumed",Ae=>{o(Ae),le(Ae),B.current=!1,l(!1),u(!1),h(!1),r(me(Ae))});const Ne=()=>{var pt;const Ae=(pt=e.client)==null?void 0:pt.session;Ae!=null&&Ae.sessionUuid&&ZE(Ae.sessionUuid),ve.current&&(ve.current(),ve.current=null),o(null),j.current=null,l(!1),u(!1),h(!1),B.current||r("hidden")};e.client.on("sessionStopped",Ne),e.client.on("sessionShutdown",Ne),e.client.on("stateChanged",V)}return()=>{e.off("showMenu",Z),e.off("configUpdated",ce),ve.current&&ve.current()}},[e]),A.useLayoutEffect(()=>{var Z,ce;(ce=(Z=e.client)==null?void 0:Z.product)!=null&&ce.primary_color&&n.style.setProperty("--obi-color-primary",e.client.product.primary_color)},[($n=(Pn=e.client)==null?void 0:Pn.product)==null?void 0:$n.primary_color,n]);const yn=(f==null?void 0:f.stepNames.map((Z,ce)=>({id:`step-${ce+1}`,title:Z})))??[],di=(f==null?void 0:f.currentStep)??null,ir=!0,Gt=(Z,ce)=>{a==null||a.say(`Can we jump to the section about ${ce.title}?`)};if(H||i==="hidden")return null;if(i==="start-session"){const Z=(rr=e.client)==null?void 0:rr.product,ce=(Rr=e.client)==null?void 0:Rr.selectedPlan,Ne=(Z==null?void 0:Z.agent_name)||"Obi",Ae="AI Assistant",pt=(ce==null?void 0:ce.description)||(Z==null?void 0:Z.description)||"I'm here to help you.";return x.jsx(tV,{open:!0,onClose:()=>{l(!1),r("hidden")},onStart:()=>{l(!0),e.startSession({withMicrophone:!0})},agentName:Ne,agentSubtitle:Ae,description:pt,showCloseButton:!0,startLabel:"Start Session",isStarting:s})}if(i==="course-selection"){const Z=(oe=a==null?void 0:a.roomId)==null?void 0:oe.startsWith("obs-"),ce=((Ge=e.client)==null?void 0:Ge.plans)||[],Ne=Z&&v.length>0,Ae=Ne?v.slice().sort((de,Ye)=>de.order!==void 0&&Ye.order!==void 0?de.order-Ye.order:de.order!==void 0?-1:Ye.order!==void 0?1:de.name.localeCompare(Ye.name)).map(de=>({id:de.uuid,title:de.name,description:de.description||de.overview||"",status:de.completed?"completed":"available",duration:typeof de.duration=="number"?`${de.duration} min`:de.duration})):ce.map(de=>{var Ye,In;return{id:de.uuid,title:de.name,description:de.description,status:(In=(Ye=e.client)==null?void 0:Ye.planIsCompleted)!=null&&In[ce.indexOf(de)]?"completed":"available",duration:de.estimated_duration?`${de.estimated_duration} min`:void 0}}),pt=(a==null?void 0:a.languageCodes)||[],Ct=(a==null?void 0:a.selectedLanguage)||(a==null?void 0:a.defaultLanguageCode)||null,Yt={audioDevices:W,currentMicrophoneId:(a==null?void 0:a.preferredMicrophoneDeviceId)||null,isMicrophoneEnabled:!c&&((a==null?void 0:a.isMicShared)??!1),isScreenShareActive:ee,widgetState:d?"chat":null,canPublishData:!0,browserSupportsScreenSharing:K,onMicDeviceSelect:async de=>{e.client&&(e.client.preferredMicrophoneDeviceId=de),a&&de&&await a.switchMicrophoneDevice(de),V()},onMicToggle:async()=>{a!=null&&a.isMicShared?c?(a.unmuteMicrophone(),u(!1)):(a.muteMicrophone(),u(!0)):await(a==null?void 0:a.shareMicrophone())},onChatToggle:()=>{h(!d)},onLeave:()=>{a==null||a.stop()},onScreenShareToggle:ae,languages:pt,selectedLanguage:Ct,defaultLanguageCode:a==null?void 0:a.defaultLanguageCode,isMultilingual:(a==null?void 0:a.isMultilingual)??!1,onLanguageChange:de=>{a==null||a.setLanguage(de)},isLanguageSelectorEnabled:!0,...d?{screenShareButtonVariant:"compact"}:{}},at=d?x.jsx(GE,{messages:(a==null?void 0:a.chatMessages)??[],localIdentity:((xe=a==null?void 0:a.room)==null?void 0:xe.localParticipant.identity)??(typeof(a==null?void 0:a.identity)=="string"?a.identity:null),onSend:async de=>{var Ye,In,Ii,he;a&&(a.appendChatMessage({timestamp:Date.now(),message:de,from:{identity:((In=(Ye=a.room)==null?void 0:Ye.localParticipant)==null?void 0:In.identity)??null,name:((he=(Ii=a.room)==null?void 0:Ii.localParticipant)==null?void 0:he.name)??null},isAgent:!1}),await a.say(de))},onClose:()=>h(!1)}):void 0;return x.jsx(QE,{open:!0,onClose:()=>a==null?void 0:a.stop(),courses:Ae,controlBarProps:Yt,coursePanelProps:{selectedCourseIds:m?[m]:void 0,onCourseToggle:async de=>{var Ye,In,Ii;if(Ne){const he=v.find(Dt=>Dt.uuid===de);if(he){g(de);try{await((Ye=a==null?void 0:a.say)==null?void 0:Ye.call(a,`I'd like to take the ${he.name} course.`))}catch(Dt){console.error("[obi-sdk] failed to send course selection",Dt),g(null)}}}else{const he=ce.find(Dt=>Dt.uuid===de);if(he){(In=e.client)==null||In.selectPlan(he),r("pip");try{await((Ii=a==null?void 0:a.say)==null?void 0:Ii.call(a,`I'd like to take the ${he.name} course.`))}catch(Dt){console.error("[obi-sdk] failed to send course selection",Dt),r("course-selection")}}}}},rightPanel:at,avatarImageSrc:((st=(Ze=e.client)==null?void 0:Ze.product)==null?void 0:st.logo_url)||void 0,avatarAudioPower:P,avatarStatus:J,captionsText:ne})}if(i==="course-outline"){const Z=(a==null?void 0:a.languageCodes)||[],ce=(a==null?void 0:a.selectedLanguage)||(a==null?void 0:a.defaultLanguageCode)||null,Ne={audioDevices:W,currentMicrophoneId:(a==null?void 0:a.preferredMicrophoneDeviceId)||null,isMicrophoneEnabled:!c&&((a==null?void 0:a.isMicShared)??!1),isScreenShareActive:ee,widgetState:d?"chat":null,canPublishData:!0,browserSupportsScreenSharing:K,onMicDeviceSelect:async Ct=>{e.client&&(e.client.preferredMicrophoneDeviceId=Ct),a&&Ct&&await a.switchMicrophoneDevice(Ct),V()},onMicToggle:async()=>{a!=null&&a.isMicShared?c?(a.unmuteMicrophone(),u(!1)):(a.muteMicrophone(),u(!0)):await(a==null?void 0:a.shareMicrophone())},onChatToggle:()=>{h(!d)},onLeave:()=>{a==null||a.stop()},onScreenShareToggle:ae,languages:Z,selectedLanguage:ce,defaultLanguageCode:a==null?void 0:a.defaultLanguageCode,isMultilingual:(a==null?void 0:a.isMultilingual)??!1,onLanguageChange:Ct=>{a==null||a.setLanguage(Ct)},isLanguageSelectorEnabled:!0,...d?{screenShareButtonVariant:"compact"}:{}},Ae=d?x.jsx(GE,{messages:(a==null?void 0:a.chatMessages)??[],localIdentity:((Li=a==null?void 0:a.room)==null?void 0:Li.localParticipant.identity)??(typeof(a==null?void 0:a.identity)=="string"?a.identity:null),onSend:async Ct=>{var Yt,at,de,Ye;a&&(a.appendChatMessage({timestamp:Date.now(),message:Ct,from:{identity:((at=(Yt=a.room)==null?void 0:Yt.localParticipant)==null?void 0:at.identity)??null,name:((Ye=(de=a.room)==null?void 0:de.localParticipant)==null?void 0:Ye.name)??null},isAgent:!1}),await a.say(Ct))},onClose:()=>h(!1)}):void 0,pt=x.jsx(RF,{steps:yn,currentStep:di,hideTrailingConclusionStep:ir,onStepClick:Gt});return x.jsx(QE,{open:!0,onClose:()=>a==null?void 0:a.stop(),courses:[],controlBarProps:Ne,middlePanel:pt,rightPanel:Ae,avatarImageSrc:((oo=(ar=e.client)==null?void 0:ar.product)==null?void 0:oo.logo_url)||void 0,avatarAudioPower:P,avatarStatus:J,captionsText:ne})}if(i==="pip"){const Z=(a==null?void 0:a.languageCodes)||[],ce=(a==null?void 0:a.selectedLanguage)||(a==null?void 0:a.defaultLanguageCode)||null,Ne=280,Ae=250,pt=16,Ct={x:window.innerWidth-Ne-pt,y:window.innerHeight-Ae-pt},Yt={isMicrophoneEnabled:!c&&((a==null?void 0:a.isMicShared)??!1),isChatOpen:d,isScreenShareActive:ee,onMicToggle:async()=>{a!=null&&a.isMicShared?c?(a.unmuteMicrophone(),u(!1)):(a.muteMicrophone(),u(!0)):await(a==null?void 0:a.shareMicrophone())},onChatToggle:()=>h(de=>!de),onScreenShareToggle:ae,onLeave:()=>{a==null||a.stop()},languages:Z,selectedLanguage:ce,defaultLanguageCode:a==null?void 0:a.defaultLanguageCode,isMultilingual:(a==null?void 0:a.isMultilingual)??!1,onLanguageChange:de=>{a==null||a.setLanguage(de)},isLanguageSelectorEnabled:!0},at=d?x.jsx(QF,{messages:(a==null?void 0:a.chatMessages)??[],localIdentity:((Ar=a==null?void 0:a.room)==null?void 0:Ar.localParticipant.identity)??(typeof(a==null?void 0:a.identity)=="string"?a.identity:null),onSend:async de=>{var Ye,In,Ii,he;a&&(a.appendChatMessage({timestamp:Date.now(),message:de,from:{identity:((In=(Ye=a.room)==null?void 0:Ye.localParticipant)==null?void 0:In.identity)??null,name:((he=(Ii=a.room)==null?void 0:Ii.localParticipant)==null?void 0:he.name)??null},isAgent:!1}),await a.say(de))},testId:"pip-chat-panel"}):void 0;return x.jsx(_q,{initialPosition:Ct,onExit:()=>{r("course-outline")},controlBarProps:Yt,isCourseOutlineSelected:S&&!!f,onCourseOutlineToggle:f?()=>{k(de=>!de)}:void 0,isCaptionsEnabled:Y,onCaptionsToggle:()=>se(de=>!de),courseOutline:f?{steps:yn,currentStep:di,onStepClick:Gt,hideTrailingConclusionStep:ir}:void 0,messagesPanel:at,avatarFallbackProps:{audioPower:P,imageSrc:((Pi=(so=e.client)==null?void 0:so.product)==null?void 0:Pi.logo_url)??void 0,status:J,captionsText:ne},screenshotUrl:R,cameraShotTrigger:w})}return null}function JE(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 aV(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 ZE(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 oV(t){const[e,n]=A.useState(()=>Wf(t));return A.useEffect(()=>{n(Wf(t))},[t]),A.useEffect(()=>{const i=()=>{n(Wf(t))};return window.addEventListener("popstate",i),window.addEventListener("hashchange",i),()=>{window.removeEventListener("popstate",i),window.removeEventListener("hashchange",i)}},[t]),e}function sV(t){const[e,n]=A.useState(0),i=A.useRef(null),r=A.useRef(0),a=A.useRef(0);return A.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 y=0;for(let v=0;v<s.length;v++)y+=s[v];l=Math.min(1,Math.max(0,y/s.length))}const c=r.current,d=l>=c?.7:.15,h=c*d+l*(1-d);r.current=h;const f=h<.05?0:Math.min(1,h);Math.abs(f-a.current)>.01&&(a.current=f,n(f)),i.current=requestAnimationFrame(o)};return i.current=requestAnimationFrame(o),()=>{i.current&&cancelAnimationFrame(i.current)}},[t]),e}function lV(){const[t,e]=A.useState({audioDevices:[]});return A.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 cV(t){if(document.querySelector("#obi-host")||document.querySelector("obi-widget"))return;uV();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(tB);const a=new CSSStyleSheet;a.replaceSync($9);const o=new CSSStyleSheet;o.replaceSync(Z9);const s=new CSSStyleSheet;s.replaceSync(eB),n.adoptedStyleSheets=[r,a,o,s],J9.createRoot(i).render(x.jsx(rV,{sdk:t,shadowHost:e})),console.log("[obi-sdk] widget mounted")}function uV(){$E("https://fonts.cdnfonts.com/css/satoshi"),$E("https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap")}function $E(t){const e=document.createElement("link");e.href=t,e.rel="stylesheet",document.head.appendChild(e)}const e3="49206C6F7665204F6269_session",t3="obi-url-params";class dV extends Jf{constructor(e){super(),this.client=null,this.isActive=!1,this.primaryColour="#9500FF",this.passivePlanUuid=null,this.commandLog=[],this.commandQueue=[],this._resumed=!1,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=this.load();if(i)try{n=Jd.deserialise(i,e,"sdk",{apiBaseUrl:"https://staging.coragents.ai",captureScreen:this.captureScreen.bind(this)}),n?this._resumed=!0:localStorage.removeItem("obi-client")}catch(r){console.error("[obi] error loading cached client",r),localStorage.removeItem("obi-client")}n||(n=new Jd(e,"sdk",{apiBaseUrl:"https://staging.coragents.ai",captureScreen:this.captureScreen.bind(this)})),this.client=n,this.client.on("stateChanged",r=>{var a,o,s,l,c,u,d,h,f,y;r==="ready"&&this.updateConfig({isActive:((a=window==null?void 0:window.obiWidgetConfig)==null?void 0:a.isActive)??((o=this.client)==null?void 0:o.showWidget),primaryColour:((l=(s=this.client)==null?void 0:s.product)==null?void 0:l.primary_color)||"#9500FF",widgetDisplay:((c=window==null?void 0:window.obiWidgetConfig)==null?void 0:c.widgetDisplay)||((d=(u=this.client)==null?void 0:u.product)==null?void 0:d.widget_display)||"regular",completedWidgetDisplay:((h=window==null?void 0:window.obiWidgetConfig)==null?void 0:h.completedWidgetDisplay)||((y=(f=this.client)==null?void 0:f.product)==null?void 0:y.completed_widget_display)||"regular"})}),this.client.on("sessionStarted",()=>{this.save(),this.passivePlanUuid=null}),this.client.on("sessionStopped",()=>{localStorage.removeItem("obi-client"),this.passivePlanUuid=null}),this.client.on("sessionShutdown",()=>{localStorage.removeItem("obi-client")}),this.client.on("trackEvent",(r,a)=>{}),this.client.session&&(this.client.session.isPaused,this.client.resumeSession(r=>{r.on("stateChanged",a=>{a!=="disconnecting"&&a!=="disconnected"&&a!=="error"&&a!=="connecting"&&this.save()}),r.on("paused",()=>{this.save()}),r.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&&Wf(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{vg().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){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),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&&vg().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(t3)||"{}"),Object.keys(e).length===0&&new URLSearchParams(window.location.search).forEach((a,o)=>{e[o]=a});const n=e[e3];if(!n)return null;const i=new URL(window.location.href);i.searchParams.delete(e3),window.history.replaceState({},"",i.toString()),i.toString(),localStorage.removeItem(t3),this.passivePlanUuid=n}mountWidget(){cV(this)}showMessage(e,n){try{this.emit("showMessage",{text:e,autoCloseMs:n==null?void 0:n.autoCloseMs})}catch{}}async captureScreen(){try{await OO(async()=>(this.graphemes||(this.graphemes=await this.client.api.getGraphemes()),this.graphemes.data.text_segmentation)),await k3(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 lO(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")}}async function n3(t,e){let n;try{n=window}catch{console.warn("[obi] no window object found"),n={}}return hV({appToken:t,window:n,init:e})}async function hV({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 dV(t);return e.ObiSDK=r.dispatchCommand,await r.initialise({queuedCommands:i}),e.obi=r,r.mountWidget(),r}function i3(){}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{n3(void 0,i3)}):n3(void 0,i3)})();
@@ -117,5 +117,5 @@ ${this.parser.parse(t)}</blockquote>
117
117
  ${t}</tr>
118
118
  `}tablecell(t){let e=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>
119
119
  `}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>${aa(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=ME(t);if(r===null)return i;t=r;let a='<a href="'+t+'"';return e&&(a+=' title="'+aa(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=ME(t);if(r===null)return aa(n);t=r;let a=`<img src="${t}" alt="${n}"`;return e&&(a+=` title="${aa(e)}"`),a+=">",a}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:aa(t.text)}},mb=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}},$i=class Rb{constructor(e){rt(this,"options"),rt(this,"renderer"),rt(this,"textRenderer"),this.options=e||qo,this.options.renderer=this.options.renderer||new zf,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new mb}static parse(e,n){return new Rb(n).parse(e)}static parseInline(e,n){return new Rb(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}},qf,nu=(qf=class{constructor(t){rt(this,"options"),rt(this,"block"),this.options=t||qo}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(){return this.block?Zi.lex:Zi.lexInline}provideParser(){return this.block?$i.parse:$i.parseInline}},rt(qf,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),rt(qf,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),qf),hj=class{constructor(...t){rt(this,"defaults",ob()),rt(this,"options",this.setOptions),rt(this,"parse",this.parseMarkdown(!0)),rt(this,"parseInline",this.parseMarkdown(!1)),rt(this,"Parser",$i),rt(this,"Renderer",zf),rt(this,"TextRenderer",mb),rt(this,"Lexer",Zi),rt(this,"Tokenizer",jf),rt(this,"Hooks",nu),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 zf(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 jf(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 nu;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];nu.passThroughHooks.has(a)?r[o]=c=>{if(this.defaults.async&&nu.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 Zi.lex(t,e??this.defaults)}parser(t,e){return $i.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?Zi.lex:Zi.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?$i.parse:$i.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?Zi.lex:Zi.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?$i.parse:$i.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+=`
120
- Please report this to https://github.com/markedjs/marked.`,t){let i="<p>An error occurred:</p><pre>"+aa(n.message+"",!0)+"</pre>";return e?Promise.resolve(i):i}if(e)return Promise.reject(n);throw n}}},Fo=new hj;function Ke(t,e){return Fo.parse(t,e)}Ke.options=Ke.setOptions=function(t){return Fo.setOptions(t),Ke.defaults=Fo.defaults,bE(Ke.defaults),Ke},Ke.getDefaults=ob,Ke.defaults=qo,Ke.use=function(...t){return Fo.use(...t),Ke.defaults=Fo.defaults,bE(Ke.defaults),Ke},Ke.walkTokens=function(t,e){return Fo.walkTokens(t,e)},Ke.parseInline=Fo.parseInline,Ke.Parser=$i,Ke.parser=$i.parse,Ke.Renderer=zf,Ke.TextRenderer=mb,Ke.Lexer=Zi,Ke.lexer=Zi.lex,Ke.Tokenizer=jf,Ke.Hooks=nu,Ke.parse=Ke,Ke.options,Ke.setOptions,Ke.use,Ke.walkTokens,Ke.parseInline,$i.parse,Zi.lex;const fj="_base_1ne03_1",pj={base:fj},mj=["p","br","strong","em","u","a","ul","ol","li","h1","h2","h3","h4","h5","h6","code","pre","blockquote","hr"],gj=["href","title","target","rel"];Ke.setOptions({breaks:!0,gfm:!0});function vj(t){const{content:e,className:n,...i}=t,r=A.useMemo(()=>{if(!e)return"";const a=Ke.parse(e,{async:!1});return A7.sanitize(a,{ALLOWED_TAGS:[...mj],ALLOWED_ATTR:[...gj],ALLOW_DATA_ATTR:!1})},[e]);return r?x.jsx("div",{className:re(pj.base,n),dangerouslySetInnerHTML:{__html:r},...i}):null}const bj="_controlBar_14416_1",yj="_popoverAnchor_14416_11",_j="_confirmationPopover_14416_15",xj="_confirmationPopoverAlignRight_14416_30",Sj="_confirmationPopoverAlignCenter_14416_33",Tj="_confirmationMessage_14416_53",kj="_confirmationActions_14416_60",wj="_confirmationButton_14416_65",Cj="_confirmationButtonCancel_14416_83",Ej="_confirmationButtonNeutral_14416_91",Rj="_confirmationButtonDanger_14416_99",Aj="_controlButton_14416_108",Oj="_controlButtonIconOnly_14416_130",Nj="_controlButtonDisabled_14416_135",Mj="_controlButtonDanger_14416_162",Dj="_controlButtonContent_14416_178",Lj="_controlButtonIcon_14416_130",Pj="_controlButtonLabel_14416_194",Ij="_controlButtonChevron_14416_201",Bj="_controlButtonNotificationDot_14416_210",Uj="_deviceSplitButton_14416_222",jj="_deviceSplitButtonEnabled_14416_226",zj="_dualButtonContent_14416_307",qj="_dualButtonIcon_14416_317",Fj="_dualButtonLabel_14416_326",Hj="_screenShareButton_14416_340",Vj="_screenShareButtonCompact_14416_351",Le={controlBar:bj,popoverAnchor:yj,confirmationPopover:_j,confirmationPopoverAlignRight:xj,confirmationPopoverAlignCenter:Sj,confirmationMessage:Tj,confirmationActions:kj,confirmationButton:wj,confirmationButtonCancel:Cj,confirmationButtonNeutral:Ej,confirmationButtonDanger:Rj,controlButton:Aj,controlButtonIconOnly:Oj,controlButtonDisabled:Nj,controlButtonDanger:Mj,controlButtonContent:Dj,controlButtonIcon:Lj,controlButtonLabel:Pj,controlButtonChevron:Ij,controlButtonNotificationDot:Bj,deviceSplitButton:Uj,deviceSplitButtonEnabled:jj,dualButtonContent:zj,dualButtonIcon:qj,dualButtonLabel:Fj,screenShareButton:Hj,screenShareButtonCompact:Vj},Gj="_inline_1gpyx_1",Yj="_vertical_1gpyx_6",Wj="_divider_1gpyx_10",Kj="_dividerVertical_1gpyx_16",Xj="_customDivider_1gpyx_21",iu={inline:Gj,vertical:Yj,divider:Wj,dividerVertical:Kj,customDivider:Xj},PE={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 er(t){if(t!==void 0){if(typeof t=="number")return`${t}px`;if(t in PE)return PE[t];if(typeof t=="string"&&t.trim().length>0)return t}}function Qj(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,f=n??"div",y={display:"flex",flexDirection:i==="horizontal"?"row":"column",flexWrap:s?"wrap":"nowrap",alignItems:a,...o?{justifyContent:o}:{},...u};if(r!==void 0){const g=er(r);g&&(y.gap=g)}const v=Vn.Children.toArray(d).filter(g=>g!=null&&typeof g!="boolean"),T=g=>!l||g===0?null:l===!0||l==="line"?x.jsx("span",{"aria-hidden":"true",className:re(iu.divider,i==="vertical"&&iu.dividerVertical)},`inline-divider-${g}`):x.jsx("span",{"aria-hidden":"true",className:iu.customDivider,children:l},`inline-divider-${g}`),m=[];return v.forEach((g,_)=>{if(_>0){const p=T(_);p&&m.push(p)}m.push(g)}),x.jsx(f,{ref:e,className:re(iu.inline,i==="vertical"&&iu.vertical,c),style:y,...h,children:m})}const gb=Vn.forwardRef(Qj);gb.displayName="Inline";function Jj(){const[t,e]=A.useState(()=>typeof window>"u"?!1:window.innerWidth<768);return A.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 vb(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,f=re(Le.controlButton,a&&Le.controlButtonDisabled,l&&Le.controlButtonIconOnly,r==="danger"&&Le.controlButtonDanger,o),y=Number.parseInt(Kv[s],10),v=r==="danger"?"outline":"primary",T=r==="danger"?"danger":"default",m=x.jsxs(x.Fragment,{children:[x.jsxs("span",{className:Le.controlButtonContent,children:[e?x.jsx("span",{className:Le.controlButtonIcon,children:Vn.isValidElement(e)&&e.props.size===void 0?Vn.cloneElement(e,{size:y}):e}):null,l?null:x.jsx("span",{className:Le.controlButtonLabel,children:n}),l||!i?null:x.jsx("span",{className:Le.controlButtonChevron,"aria-hidden":"true",children:x.jsx(Xv,{size:16})})]}),c?x.jsx("span",{className:Le.controlButtonNotificationDot,"aria-hidden":"true"}):null]});return typeof u=="boolean"?x.jsx(Of,{...h,type:"button",disabled:a,variant:v,color:T,isOn:u,"aria-label":d||n,className:f,"data-has-notification":c?"true":void 0,children:m}):x.jsx(ol,{...h,type:"button",disabled:a,variant:v,color:T,"aria-label":d||n,className:f,"data-has-notification":c?"true":void 0,children:m})}function Zj(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:f,showChatNotification:y=!1,isLanguageSelectorEnabled:v=!0,languages:T=[],selectedLanguage:m=null,defaultLanguageCode:g=null,isMultilingual:_=!1,onLanguageChange:p,isChatOpen:S=a==="chat"}=t,k=T.length,w=v&&_&&k>0,E=Jj(),R=E?"xs":"sm",O=E,[D,q]=A.useState(!1),[Y,se]=A.useState(!1),H=A.useRef(null),P=A.useRef(null);A.useEffect(()=>{const B=me=>{const yn=me.composedPath();D&&H.current&&!yn.includes(H.current)&&q(!1),Y&&P.current&&!yn.includes(P.current)&&se(!1)},le=me=>{me.key==="Escape"&&(D&&q(!1),Y&&se(!1))};if(D||Y)return document.addEventListener("mousedown",B),document.addEventListener("keydown",le),()=>{document.removeEventListener("mousedown",B),document.removeEventListener("keydown",le)}},[D,Y]),A.useEffect(()=>{r||q(!1)},[r]);const W=A.useMemo(()=>e.map(B=>({label:B.label||`Microphone ${B.deviceId.slice(0,8)}`,value:B.deviceId})),[e]),X=A.useMemo(()=>n?W.find(B=>B.value===n)??null:null,[n,W]),ne=A.useCallback(B=>{B.value,c(B.value)},[c]),K={microphone:!0,screenShare:s,chat:o},ee=A.useCallback(()=>{if(r){q(!0);return}f()},[r,f]),J=A.useCallback(()=>{q(!1),f()},[f]),V=A.useCallback(()=>{q(!1)},[]),ae=A.useCallback(()=>{se(!0)},[]),j=A.useCallback(()=>{se(!1),h()},[h]),ve=A.useCallback(()=>{se(!1)},[]);return x.jsx("div",{className:Le.controlBar,"data-testid":"control-bar","data-controls":JSON.stringify(K),"data-language-option-count":k>0?String(k):void 0,"data-default-language-code":g??void 0,children:x.jsxs(gb,{gap:R,align:"center",justify:"center",wrap:O,children:[x.jsx(UU,{onClick:u,buttonAriaLabel:i?"Mute microphone":"Unmute microphone",options:W,value:X,onChange:ne,variant:"primary",menuPlacement:"top",menuDisabled:W.length===0,menuAriaLabel:"Select microphone device",listboxAriaLabel:"Microphone devices",ariaPressed:i,className:re(Le.deviceSplitButton,i&&Le.deviceSplitButtonEnabled),children:x.jsxs("span",{className:Le.dualButtonContent,children:[x.jsx("span",{className:Le.dualButtonIcon,children:i?x.jsx(G2,{}):x.jsx(Y2,{})}),x.jsx("span",{className:Le.dualButtonLabel,children:"Microphone"})]})}),o?x.jsx(vb,{icon:x.jsx(F2,{}),label:"Chat",onClick:d,isOn:S,"aria-label":"Toggle chat",showNotificationDot:y}):null,s?x.jsxs("div",{ref:H,className:Le.popoverAnchor,children:[x.jsx(vb,{icon:x.jsx(W2,{}),label:r?"Share screen off":"Share screen",className:l==="compact"?Le.screenShareButtonCompact:Le.screenShareButton,iconOnly:l==="compact",onClick:ee,isOn:r,"aria-label":r?"Stop screen sharing":"Start screen sharing"}),D?x.jsxs("div",{className:re(Le.confirmationPopover,Le.confirmationPopoverAlignCenter),role:"dialog","aria-label":"Stop screen sharing confirmation","data-testid":"confirm-stop-share",children:[x.jsx("p",{className:Le.confirmationMessage,children:"Stop screen sharing?"}),x.jsxs("div",{className:Le.confirmationActions,children:[x.jsx("button",{type:"button",className:re(Le.confirmationButton,Le.confirmationButtonCancel),onClick:V,children:"Cancel"}),x.jsx("button",{type:"button",className:re(Le.confirmationButton,Le.confirmationButtonNeutral),onClick:J,children:"Stop"})]})]}):null]}):null,w?x.jsx(tE,{languages:T,value:m,onChange:p,defaultLanguageCode:g,variant:"control-bar"}):null,x.jsxs("div",{ref:P,className:Le.popoverAnchor,children:[x.jsx(vb,{icon:x.jsx(V2,{}),label:"Leave",variant:"danger",onClick:ae,"aria-label":"Leave meeting"}),Y?x.jsxs("div",{className:re(Le.confirmationPopover,Le.confirmationPopoverAlignRight),role:"dialog","aria-label":"Leave meeting confirmation","data-testid":"confirm-leave",children:[x.jsx("p",{className:Le.confirmationMessage,children:"Would you like to end the call?"}),x.jsxs("div",{className:Le.confirmationActions,children:[x.jsx("button",{type:"button",className:re(Le.confirmationButton,Le.confirmationButtonCancel),onClick:ve,children:"Cancel"}),x.jsx("button",{type:"button",className:re(Le.confirmationButton,Le.confirmationButtonDanger),onClick:j,children:"Leave"})]})]}):null]})]})})}function $j(t){return x.jsx(Zj,{...t})}const ez="_controlBar_75i8h_1",tz="_controlButton_75i8h_12",nz="_controlButtonDisabled_75i8h_35",iz="_controlButtonDanger_75i8h_62",rz="_controlButtonIconOnly_75i8h_78",az="_screenShareButton_75i8h_83",oz="_controlButtonContent_75i8h_88",sz="_controlButtonIcon_75i8h_78",lz="_controlButtonLabel_75i8h_103",cz="_controlButtonNotificationDot_75i8h_108",uz="_popoverAnchor_75i8h_198",dz="_confirmationPopover_75i8h_202",hz="_confirmationMessage_75i8h_216",fz="_confirmationActions_75i8h_223",pz="_confirmationButton_75i8h_228",mz="_confirmationButtonCancel_75i8h_246",gz="_confirmationButtonDanger_75i8h_254",nn={controlBar:ez,controlButton:tz,controlButtonDisabled:nz,controlButtonDanger:iz,controlButtonIconOnly:rz,screenShareButton:az,controlButtonContent:oz,controlButtonIcon:sz,controlButtonLabel:lz,controlButtonNotificationDot:cz,popoverAnchor:uz,confirmationPopover:dz,confirmationMessage:hz,confirmationActions:fz,confirmationButton:pz,confirmationButtonCancel:mz,confirmationButtonDanger:gz};function Ff(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=re(nn.controlButton,r&&nn.controlButtonDisabled,o&&nn.controlButtonIconOnly,i==="danger"&&nn.controlButtonDanger,a),h=i==="danger"?"outline":"primary",f=i==="danger"?"danger":"default",y=x.jsxs(x.Fragment,{children:[x.jsxs("span",{className:nn.controlButtonContent,children:[e?x.jsx("span",{className:nn.controlButtonIcon,children:Vn.isValidElement(e)&&e.props.size===void 0?Vn.cloneElement(e,{size:20}):e}):null,o?null:x.jsx("span",{className:nn.controlButtonLabel,children:n})]}),s?x.jsx("span",{className:nn.controlButtonNotificationDot,"aria-hidden":"true"}):null]});return typeof l=="boolean"?x.jsx(Of,{...u,type:"button",disabled:r,variant:h,color:f,size:"xs",isOn:l,"aria-label":c||n,className:d,"data-has-notification":s?"true":void 0,children:y}):x.jsx(ol,{...u,type:"button",disabled:r,variant:h,color:f,size:"xs","aria-label":c||n,className:d,"data-has-notification":s?"true":void 0,children:y})}function vz(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,onLanguageChange:f,isLanguageSelectorEnabled:y=!0,className:v,testId:T,...m}=t,g=!y||!h||c.length===0,[_,p]=A.useState(!1),S=A.useRef(null);A.useEffect(()=>{const D=Y=>{const se=Y.composedPath();_&&S.current&&!se.includes(S.current)&&p(!1)},q=Y=>{Y.key==="Escape"&&_&&p(!1)};if(_)return document.addEventListener("mousedown",D),document.addEventListener("keydown",q),()=>{document.removeEventListener("mousedown",D),document.removeEventListener("keydown",q)}},[_]);const k=A.useCallback(()=>{a()},[a]),w=A.useCallback(()=>{s()},[s]),E=A.useCallback(()=>{p(!0)},[]),R=A.useCallback(()=>{p(!1),l()},[l]),O=A.useCallback(()=>{p(!1)},[]);return x.jsx("div",{...m,className:re(nn.controlBar,v),"data-testid":T,children:x.jsxs(gb,{gap:"xs",align:"center",justify:"center",wrap:!1,children:[x.jsx(Ff,{icon:e?x.jsx(G2,{}):x.jsx(Y2,{}),label:"Microphone",iconOnly:!0,isOn:e,onClick:k,"aria-label":e?"Mute microphone":"Unmute microphone"}),x.jsx(Ff,{icon:x.jsx(F2,{}),label:"Chat",iconOnly:!0,isOn:n,onClick:o,"aria-label":"Toggle chat",showNotificationDot:r}),x.jsx(Ff,{icon:x.jsx(W2,{}),label:"Screen share",iconOnly:!0,className:nn.screenShareButton,isOn:i,onClick:w,"aria-label":i?"Stop screen sharing":"Start screen sharing"}),x.jsx(tE,{languages:c,value:u,onChange:f,defaultLanguageCode:d,variant:"pip",disabled:g}),x.jsxs("div",{ref:S,className:nn.popoverAnchor,children:[x.jsx(Ff,{icon:x.jsx(V2,{}),label:"Hang up",iconOnly:!0,variant:"danger",onClick:E,"aria-label":"Hang up"}),_?x.jsxs("div",{className:nn.confirmationPopover,role:"dialog","aria-label":"Hang up confirmation","data-testid":"confirm-leave",children:[x.jsx("p",{className:nn.confirmationMessage,children:"Would you like to end the call?"}),x.jsxs("div",{className:nn.confirmationActions,children:[x.jsx("button",{type:"button",className:re(nn.confirmationButton,nn.confirmationButtonCancel),onClick:O,children:"Cancel"}),x.jsx("button",{type:"button",className:re(nn.confirmationButton,nn.confirmationButtonDanger),onClick:R,children:"Leave"})]})]}):null]})]})})}function bz(t){return x.jsx(vz,{...t})}const yz="_container_zht0b_1",_z="_containerGradient_zht0b_14",xz="_containerFlat_zht0b_24",Sz="_halo_zht0b_28",Tz="_outerRing_zht0b_38",kz="_circle_zht0b_42",wz="_image_zht0b_72",Cz="_captionContainer_zht0b_88",Ez="_captionRegion_zht0b_99",oa={container:yz,containerGradient:_z,containerFlat:xz,halo:Sz,outerRing:Tz,circle:kz,image:wz,captionContainer:Cz,captionRegion:Ez},Rz="_statusText_1dkze_6",Az={statusText:Rz},Oz={idle:null,thinking:"Thinking...",searching:"Searching..."};function Nz(t){const{status:e,size:n="md"}=t,i=e?Oz[e]:null,r=i!==null;return x.jsx("div",{className:Az.statusText,"data-visible":r,"data-size":n,"aria-live":"polite",children:i})}const Mz="https://obi-static.s3.ap-southeast-2.amazonaws.com/images/obi-avatar.png",Dz={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 IE(t){const{audioPower:e,size:n="md",background:i="gradient",imageSrc:r=Mz,accentColor:a,ariaLabel:o="Avatar placeholder",status:s,captionsText:l,className:c,style:u,...d}=t,h=Dz[n],f=Math.min(1,Math.max(0,e)),y=f>.01,v=y?Math.min(1,f/.5):0,T=y?Math.max(1,v*h.maxBorderWidth):0,m=1.02,g=y?m+f*h.outerRingScalePower:m,_=y?.2+f*.35:0,p={...u??{},...a?{"--avatar-fallback-accent":a}:{}},S={"--avatar-fallback-halo-size":h.haloSize,"--avatar-fallback-border-width":`${T}px`,"--avatar-fallback-secondary-border-scale":g.toString(),"--avatar-fallback-secondary-border-opacity":_.toString(),"--avatar-fallback-glow-size":h.glowSize},k=l!=null&&l!=="";return x.jsxs("div",{...d,className:re(oa.container,i==="gradient"?oa.containerGradient:oa.containerFlat,c),style:p,"data-testid":"avatar-fallback","aria-label":o,role:"img",children:[x.jsxs("div",{className:oa.halo,style:S,children:[x.jsx("div",{className:oa.outerRing,"aria-hidden":"true"}),x.jsx("div",{className:oa.circle,children:x.jsx("img",{className:oa.image,src:r,alt:"","aria-hidden":"true"})}),x.jsx(Nz,{status:s,size:n})]}),k&&x.jsx("div",{className:oa.captionContainer,children:x.jsx("div",{className:oa.captionRegion,"data-size":n,role:"status","aria-live":"polite","aria-atomic":"true",children:l})})]})}const Lz="_container_1k3qg_11",Pz="_screenshot_1k3qg_20",Iz="_flash_1k3qg_30",bb={container:Lz,screenshot:Pz,flash:Iz};function Bz(t){const{isActive:e,imageUrl:n,onComplete:i,duration:r=2e3}=t,[a,o]=A.useState(!1),s=A.useRef(null);return A.useEffect(()=>{if(!e){o(!1),s.current&&(clearTimeout(s.current),s.current=null);return}if(!s.current)return o(!0),s.current=setTimeout(()=>{o(!1),s.current=null,i==null||i()},r),()=>{s.current&&(clearTimeout(s.current),s.current=null)}},[e,r,i]),a?x.jsxs("div",{className:bb.container,"aria-live":"polite","aria-label":"Screenshot captured",children:[n&&x.jsx("img",{src:n,alt:"Captured screenshot",className:bb.screenshot}),x.jsx("div",{className:bb.flash})]}):null}const Uz="_container_13ukq_1",jz="_dragging_13ukq_5",zz="_placeholder_13ukq_9",qz="_handleButton_13ukq_15",Fz="_customHandle_13ukq_105",cl={container:Uz,dragging:jz,placeholder:zz,handleButton:qz,"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:Fz};function Hz(t){const{disabled:e,lingerMs:n,isDragging:i}=t,[r,a]=A.useState(!1),o=A.useRef(null),s=A.useCallback(()=>{o.current!==null&&(window.clearTimeout(o.current),o.current=null)},[]),l=A.useCallback(()=>{e||(s(),a(!0))},[s,e]),c=A.useCallback(()=>{e||i||(s(),o.current=window.setTimeout(()=>{a(!1),o.current=null},n))},[s,e,i,n]);return A.useEffect(()=>{i&&l()},[i,l]),A.useEffect(()=>s,[s]),{isHandleVisible:r,showHandle:l,scheduleHideHandle:c}}function Vz(t){const{initialPosition:e,preserveSpace:n,onPositionChange:i}=t,r=A.useRef(null),[a,o]=A.useState(!!e),[s,l]=A.useState(!1),[c,u]=A.useState(null),[d,h]=A.useState(()=>e??{x:0,y:0}),f=A.useRef(d);s||(f.current=d);const y=A.useRef(null),v=A.useRef(!1),T=A.useRef(!1);A.useEffect(()=>{e&&(T.current||(o(!0),h(e),f.current=e))},[e==null?void 0:e.x,e==null?void 0:e.y]),A.useEffect(()=>{if(e||v.current)return;const p=r.current;if(!p)return;const S=p.getBoundingClientRect(),k={x:S.left,y:S.top};v.current=!0,o(!0),h(k),f.current=k,u(n?{width:S.width,height:S.height}:null)},[e,n]);const m=A.useCallback(p=>{const S=y.current;if(!(!S||p.pointerId!==S.pointerId)){y.current=null,T.current=!0,h(f.current),l(!1);try{p.currentTarget.releasePointerCapture(S.pointerId)}catch{}}},[]),g=A.useCallback(p=>{p.button===0&&(p.preventDefault(),p.currentTarget.setPointerCapture(p.pointerId),y.current={pointerId:p.pointerId,startClientX:p.clientX,startClientY:p.clientY,startX:f.current.x,startY:f.current.y},l(!0))},[]),_=A.useCallback(p=>{const S=y.current;if(!S||p.pointerId!==S.pointerId)return;const k={x:S.startX+(p.clientX-S.startClientX),y:S.startY+(p.clientY-S.startClientY)};f.current=k,r.current&&(r.current.style.transform=`translate3d(${k.x}px, ${k.y}px, 0)`),i==null||i(k)},[i]);return{containerRef:r,isFixed:a,isDragging:s,position:d,placeholderSize:c,onPointerDown:g,onPointerMove:_,endDrag:m}}function Gz(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:f,isFixed:y,isDragging:v,position:T,placeholderSize:m,onPointerDown:g,onPointerMove:_,endDrag:p}=Vz({initialPosition:r,preserveSpace:o,onPositionChange:l}),{isHandleVisible:S,showHandle:k,scheduleHideHandle:w}=Hz({disabled:a,lingerMs:u,isDragging:v}),E=typeof e=="function",R=A.useMemo(()=>{const D=q=>x.jsx("div",{className:re(cl.customHandle,q.className),onPointerDown:g,onPointerMove:_,onPointerUp:p,onPointerCancel:p,children:q.children});return D.displayName="Draggable.Handle",D},[g,_,p]),O={...d,position:y?"fixed":"relative",top:y?0:d==null?void 0:d.top,left:y?0:d==null?void 0:d.left,transform:y?`translate3d(${T.x}px, ${T.y}px, 0)`:d==null?void 0:d.transform,zIndex:y?s:d==null?void 0:d.zIndex};return x.jsxs(x.Fragment,{children:[o&&y&&m?x.jsx("div",{className:cl.placeholder,style:{width:m.width,height:m.height}}):null,x.jsxs("div",{ref:f,className:re(cl.container,v?cl.dragging:null,n),"data-handle-visible":E?void 0:a?"false":S||v?"true":"false",style:O,onMouseEnter:E?void 0:k,onMouseLeave:E?void 0:w,...h,children:[!E&&!a?x.jsx("button",{type:"button",className:re(cl.handleButton,cl[`handle-${i}`]),"aria-label":c,onMouseEnter:k,onMouseLeave:w,onPointerDown:D=>{k(),g(D)},onPointerMove:_,onPointerUp:p,onPointerCancel:p}):null,E?e({Handle:R}):e]})]})}const Yz="_container_1u25n_1",Wz="_captionRegion_1u25n_14",Kz="_status_1u25n_22",Xz="_captionText_1u25n_29",Hf={container:Yz,captionRegion:Wz,status:Kz,captionText:Xz},Qz={idle:null,thinking:"Thinking...",searching:"Searching..."};function Jz(t){const{text:e,status:n,className:i,...r}=t,a=n?Qz[n]:null;return x.jsx("div",{...r,className:re(Hf.container,i),"data-testid":"pip-captions-panel",children:x.jsxs("div",{className:Hf.captionRegion,role:"status","aria-live":"polite","aria-atomic":"true",children:[a?x.jsx("div",{className:Hf.status,children:a}):null,x.jsx("div",{className:Hf.captionText,children:e})]})})}const Zz="_panel_1npcg_1",$z="_row_1npcg_20",eq="_stepContent_1npcg_26",tq="_stepLabel_1npcg_35",nq="_currentStep_1npcg_42",iq="_nextStep_1npcg_49",rq="_skipRow_1npcg_63",aq="_circleButton_1npcg_68",oq="_arrowPlaceholder_1npcg_93",sq="_skipButton_1npcg_99",Mi={panel:Zz,row:$z,stepContent:eq,stepLabel:tq,currentStep:nq,nextStep:iq,skipRow:rq,circleButton:aq,arrowPlaceholder:oq,skipButton:sq};function lq(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 BE(t,e){return e<=0||typeof t!="number"||!Number.isFinite(t)?0:Math.min(Math.max(Math.trunc(t),1),e)-1}function cq(t){var k;const{steps:e,currentStep:n,onStepClick:i,hideTrailingConclusionStep:r=!0,className:a,testId:o,...s}=t,{visibleSteps:l,currentIndex:c}=A.useMemo(()=>lq(e,n,r),[n,r,e]),[u,d]=A.useState(()=>BE(n,l.length));A.useEffect(()=>{d(BE(n,l.length))},[n,l]);const h=l.length,f=l[u],y=u>0,v=u<h-1,T=v?(k=l[u+1])==null?void 0:k.title:void 0,m=h===0?0:u+1,g=c!==null&&f&&u!==c,_=()=>{y&&d(w=>Math.max(w-1,0))},p=()=>{v&&d(w=>Math.min(w+1,h-1))},S=()=>{!g||!f||!i||i(u,f)};return x.jsxs("div",{...s,className:re(Mi.panel,a),"data-testid":o,role:"group","aria-label":"Course progress",children:[x.jsxs("div",{className:Mi.row,children:[y?x.jsx("button",{type:"button",className:Mi.circleButton,"aria-label":"Previous step",onClick:_,children:x.jsx(aB,{size:14})}):x.jsx("span",{className:Mi.arrowPlaceholder,"aria-hidden":"true"}),x.jsxs("div",{className:Mi.stepContent,children:[x.jsxs(Zn,{className:Mi.stepLabel,"aria-live":"polite",children:["Step ",m,"/",h]}),x.jsx(Zn,{className:Mi.currentStep,"data-testid":"pip-outline-current-step",children:(f==null?void 0:f.title)??"No steps available"}),T?x.jsxs(Zn,{variant:"muted",className:Mi.nextStep,children:["Next: ",T]}):null]}),v?x.jsx("button",{type:"button",className:Mi.circleButton,"aria-label":"Next step",onClick:p,children:x.jsx(oB,{size:14})}):x.jsx("span",{className:Mi.arrowPlaceholder,"aria-hidden":"true"})]}),g?x.jsx("div",{className:Mi.skipRow,children:x.jsx("button",{type:"button",className:Mi.skipButton,"aria-label":"Skip to this step",onClick:S,children:x.jsx(uB,{size:14})})}):null]})}const uq="_window_1q008_1",dq="_exitButton_1q008_13",hq="_content_1q008_43",fq="_contentTopOverlay_1q008_53",pq="_contentTopOverlaySlot_1q008_67",mq="_dragHandle_1q008_77",gq="_contentBottomOverlay_1q008_82",vq="_controls_1q008_91",ro={window:uq,exitButton:dq,content:hq,contentTopOverlay:fq,contentTopOverlaySlot:pq,dragHandle:mq,contentBottomOverlay:gq,controls:vq};function bq(t){return t==null?!1:typeof t=="string"?t.trim().length>0:!0}function yq(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:f,testId:y,...v}=t,T=i,m=n.isChatOpen&&!T&&l,g=c==null?void 0:c.captionsText,_=a&&bq(g),[p,S]=A.useState(!1);A.useEffect(()=>{h&&h>0&&S(!0)},[h]);const k=A.useCallback(()=>x.jsx(IE,{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]),w=T?s?x.jsx(cq,{steps:s.steps,currentStep:s.currentStep,onStepClick:s.onStepClick,hideTrailingConclusionStep:s.hideTrailingConclusionStep}):k():m?l:_?x.jsx(Jz,{text:g,status:c==null?void 0:c.status}):k();return x.jsxs("div",{...v,className:re(ro.window,f),"data-testid":y,role:"group","aria-label":"Picture-in-Picture",children:[x.jsxs("div",{className:ro.content,children:[x.jsxs("div",{className:ro.contentTopOverlay,children:[u?x.jsx("div",{className:ro.contentTopOverlaySlot,children:u}):null,x.jsx("button",{type:"button",className:ro.exitButton,onClick:e,"aria-label":"Exit PiP",children:x.jsx(sB,{size:14})})]}),w,!m&&x.jsxs("div",{className:ro.contentBottomOverlay,children:[x.jsx(Of,{isOn:i,onClick:r,variant:"primary",size:"xs","aria-label":"Toggle course outline",children:x.jsx(dB,{size:18})}),x.jsx(Of,{isOn:a,onClick:o,variant:"primary",size:"xs","aria-label":"Toggle captions",children:x.jsx(rB,{size:18})})]}),x.jsx(Bz,{isActive:p,imageUrl:d??null,onComplete:()=>S(!1)})]}),x.jsx("div",{className:ro.controls,children:x.jsx(bz,{...n})})]})}function _q(t){const{initialPosition:e,onPositionChange:n,zIndex:i=1e3,...r}=t;return x.jsx(Gz,{initialPosition:e,onPositionChange:n,zIndex:i,preserveSpace:!1,children:({Handle:a})=>x.jsx(yq,{...r,contentTopOverlaySlot:x.jsx(a,{className:ro.dragHandle})})})}const xq="_root_ygi3o_1",Sq="_overlay_ygi3o_7",Tq="_caption_ygi3o_17",yb={root:xq,overlay:Sq,caption:Tq};function kq(t){return t==null?!1:typeof t=="string"?t.trim().length>0:!0}function wq(t){const{children:e,className:n,text:i}=t,r=kq(i);return x.jsxs("div",{className:re(yb.root,n),children:[e,r?x.jsx("div",{className:yb.overlay,role:"status","aria-live":"polite","aria-atomic":"true",children:x.jsx("div",{className:yb.caption,children:i})}):null]})}const Cq="_box_1r6by_1",Eq={box:Cq},UE={none:"0px",panel:"var(--radius-panel)",card:"var(--radius-card)"},jE={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 Rq(t){if(t!==void 0){if(typeof t=="number")return`${t}px`;if(t in UE)return UE[t];if(typeof t=="string"&&t.trim().length>0)return t}}function Aq(t){if(t!==void 0){if(t in jE)return jE[t];if(typeof t=="string"&&t.trim().length>0)return t}}function Oq(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:f,paddingXl:y,margin:v,marginX:T,marginY:m,marginTop:g,marginBottom:_,marginLeft:p,marginRight:S,radius:k,radiusTop:w,radiusBottom:E,radiusLeft:R,radiusRight:O,radiusTopLeft:D,radiusTopRight:q,radiusBottomLeft:Y,radiusBottomRight:se,background:H,gap:P,style:W,...X}=t,ne=n??"div",K={...W},ee=K,J={},V=(B,le)=>{if(le===void 0)return;const me=er(le);me&&(K[B]=me)},ae=(B,le)=>{if(le===void 0)return;const me=er(le);me&&(K[B]=me)},j=(B,le)=>{if(le===void 0)return;const me=Rq(le);me&&(K[B]=me)},ve={sm:d,md:h,lg:f,xl:y};if(r!==void 0){const B=er(r);B&&(ee["--box-padding"]=B)}for(const[B,le]of Object.entries(ve)){if(le===void 0)continue;const me=er(le);me&&(ee[`--box-padding-${B}`]=me,J[`data-padding-${B}`]="")}if(a!==void 0){const B=er(a);B&&(K.paddingLeft=B,K.paddingRight=B)}if(o!==void 0){const B=er(o);B&&(K.paddingTop=B,K.paddingBottom=B)}if(V("paddingTop",s),V("paddingBottom",l),V("paddingLeft",c),V("paddingRight",u),v!==void 0){const B=er(v);B&&(K.margin=B)}if(T!==void 0){const B=er(T);B&&(K.marginLeft=B,K.marginRight=B)}if(m!==void 0){const B=er(m);B&&(K.marginTop=B,K.marginBottom=B)}if(ae("marginTop",g),ae("marginBottom",_),ae("marginLeft",p),ae("marginRight",S),P!==void 0){const B=er(P);B&&(K.gap=B)}if(j("borderRadius",k),w!==void 0&&(j("borderTopLeftRadius",w),j("borderTopRightRadius",w)),E!==void 0&&(j("borderBottomLeftRadius",E),j("borderBottomRightRadius",E)),R!==void 0&&(j("borderTopLeftRadius",R),j("borderBottomLeftRadius",R)),O!==void 0&&(j("borderTopRightRadius",O),j("borderBottomRightRadius",O)),j("borderTopLeftRadius",D),j("borderTopRightRadius",q),j("borderBottomLeftRadius",Y),j("borderBottomRightRadius",se),H!==void 0){const B=Aq(H);B&&(K.background=B)}return x.jsx(ne,{ref:e,className:re(Eq.box,i),style:K,...J,...X})}const Vf=Vn.forwardRef(Oq);Vf.displayName="Box";const Nq="_panel_eawk4_1",Mq="_selected_eawk4_10",zE={panel:Nq,selected:Mq};function ru(t){const{children:e,className:n,selected:i,...r}=t;return x.jsx("div",{className:re(zE.panel,i?zE.selected:null,n),...r,children:e})}const Dq="_root_yccm8_1",Lq="_header_yccm8_8",Pq="_icon_yccm8_15",Iq="_text_yccm8_26",Bq="_heading_yccm8_33",Uq="_description_yccm8_41",jq="_body_yccm8_47",zq="_footer_yccm8_54",ao={root:Dq,header:Lq,icon:Pq,text:Iq,heading:Bq,description:Uq,body:jq,footer:zq};function qE(t){const{className:e,...n}=t;return x.jsx("div",{className:re(ao.icon,e),...n})}function FE(t){const{className:e,...n}=t;return x.jsx("h3",{className:re(ao.heading,e),...n})}function HE(t){const{className:e,...n}=t;return x.jsx("p",{className:re(ao.description,e),...n})}function VE(t){const{className:e,...n}=t;return x.jsx("div",{className:re(ao.footer,e),...n})}function qq(t){const e=A.Children.toArray(t),n=[];let i,r,a,o;for(const s of e){if(A.isValidElement(s)&&s.type===qE&&i===void 0){i=s;continue}if(A.isValidElement(s)&&s.type===FE&&r===void 0){r=s;continue}if(A.isValidElement(s)&&s.type===HE&&a===void 0){a=s;continue}if(A.isValidElement(s)&&s.type===VE&&o===void 0){o=s;continue}n.push(s)}return{icon:i,heading:r,description:a,footer:o,body:n}}function Fq(t){const{children:e,className:n,...i}=t,r=qq(e),a=r.icon||r.heading||r.description;return x.jsxs(ru,{className:re(ao.root,n),...i,children:[a?x.jsxs("div",{className:ao.header,children:[r.icon,r.heading||r.description?x.jsxs("div",{className:ao.text,children:[r.heading,r.description]}):null]}):null,r.body.length?x.jsx("div",{className:ao.body,children:r.body}):null,r.footer]})}const _b=Object.assign(Fq,{Icon:qE,Heading:FE,Description:HE,Footer:VE}),Hq="_panel_1uwhd_1",Vq="_header_1uwhd_11",Gq="_title_1uwhd_19",Yq="_scrollArea_1uwhd_29",Wq="_scrollable_1uwhd_34",Kq="_list_1uwhd_38",Xq="_courseButton_1uwhd_44",Qq="_courseCard_1uwhd_55",Jq="_courseHeading_1uwhd_64",Zq="_courseDescription_1uwhd_70",$q="_empty_1uwhd_79",tr={panel:Hq,header:Vq,title:Gq,scrollArea:Yq,scrollable:Wq,list:Kq,courseButton:Xq,courseCard:Qq,courseHeading:Jq,courseDescription:Zq,empty:$q};function eF(t){const{selectionMode:e,selectedCourseIds:n,defaultSelectedCourseIds:i,onSelectedCourseIdsChange:r}=t,a=n!==void 0,[o,s]=A.useState(()=>i??[]),l=a?n:o,c=A.useCallback(d=>{a||s(d),r==null||r(d)},[a,r]),u=A.useCallback(d=>{const h=l.includes(d);if(e==="single"){c(h?[]:[d]);return}if(h){c(l.filter(f=>f!==d));return}c([...l,d])},[l,e,c]);return{selectedCourseIds:l,toggleCourseId:u}}function tF(t){const{title:e="Courses",ariaLabel:n,className:i,courses:r,selectionMode:a="multiple",selectedCourseIds:o,onCourseToggle:s,emptyMessage:l="No courses available",testId:c,...u}=t;return x.jsxs(ru,{...u,className:re(tr.panel,i),role:"region","aria-label":n??e,"data-testid":c,children:[x.jsx("div",{className:tr.header,children:x.jsx(Zn,{as:"h2",className:tr.title,children:e})}),x.jsx("div",{className:tr.scrollArea,children:x.jsx(sl,{className:tr.scrollable,children:r.length===0?x.jsx(Zn,{variant:"muted",className:tr.empty,"data-testid":"course-panel-empty",children:l}):x.jsx("div",{className:tr.list,"data-testid":"course-panel-list",children:r.map(d=>{const h=o.includes(d.id),f=d.disabled===!0;return x.jsx("button",{type:"button",className:tr.courseButton,"aria-pressed":h,"aria-disabled":f,disabled:f,onClick:()=>s==null?void 0:s(d.id,d),"data-testid":`course-panel-item-${d.id}`,children:x.jsxs(_b,{selected:h,className:tr.courseCard,children:[x.jsx(_b.Heading,{className:tr.courseHeading,children:d.title}),d.description?x.jsx(_b.Description,{className:tr.courseDescription,children:d.description}):null]})},d.id)})})})})]})}function nF(t){const{selectionMode:e="multiple",selectedCourseIds:n,defaultSelectedCourseIds:i,onSelectedCourseIdsChange:r,onCourseToggle:a,...o}=t,{selectedCourseIds:s,toggleCourseId:l}=eF({selectionMode:e,selectedCourseIds:n,defaultSelectedCourseIds:i,onSelectedCourseIdsChange:r}),c=A.useCallback((u,d)=>{l(u),a==null||a(u,d)},[a,l]);return x.jsx(tF,{...o,selectionMode:e,selectedCourseIds:s,onCourseToggle:c})}const iF="_panel_1on05_1",rF="_header_1on05_11",aF="_divider_1on05_19",oF="_title_1on05_25",sF="_scrollArea_1on05_35",lF="_scrollable_1on05_40",cF="_list_1on05_44",uF="_section_1on05_50",dF="_sectionHeader_1on05_56",hF="_sectionTitle_1on05_60",fF="_sectionTitleCompact_1on05_68",pF="_item_1on05_72",mF="_itemClickable_1on05_86",gF="_itemCompleted_1on05_90",vF="_itemCurrent_1on05_94",bF="_itemFuture_1on05_98",yF="_itemDisabled_1on05_103",_F="_row_1on05_117",xF="_stepHeader_1on05_124",SF="_stepNumber_1on05_133",TF="_stepTitle_1on05_139",kF="_checkIcon_1on05_151",wF="_empty_1on05_155",He={panel:iF,header:rF,divider:aF,title:oF,scrollArea:sF,scrollable:lF,list:cF,section:uF,sectionHeader:dF,sectionTitle:hF,sectionTitleCompact:fF,item:pF,itemClickable:mF,itemCompleted:gF,itemCurrent:vF,itemFuture:bF,itemDisabled:yF,row:_F,stepHeader:xF,stepNumber:SF,stepTitle:TF,checkIcon:kF,empty:wF};function CF(t){var f;const{steps:e,currentStep:n,hideTrailingConclusionStep:i}=t,r=e.length,a=i&&r>0&&((f=e[r-1])==null?void 0:f.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},(y,v)=>v),currentIndex:null,futureIndices:[]};const c=Math.min(Math.max(l,1),s)-1,u=Array.from({length:Math.max(0,c)},(y,v)=>v),d=Math.min(c,s-1),h=Array.from({length:Math.max(0,s-(d+1))},(y,v)=>d+1+v);return{visibleSteps:o,completedIndices:u,currentIndex:d,futureIndices:h}}function EF(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,...d}=t,h=A.useCallback(_=>(_+1).toString().padStart(2,"0"),[]),{visibleSteps:f,completedIndices:y,currentIndex:v,futureIndices:T}=A.useMemo(()=>CF({steps:r,currentStep:a,hideTrailingConclusionStep:s}),[a,s,r]),m=c==="compact"?"md":"lg",g=A.useCallback((_,p)=>{const S=f[_];if(!S)return null;const k=typeof o=="function",w=k&&S.disabled===!0,E=k&&!w,R=re(He.item,{[He.itemClickable]:E,[He.itemCompleted]:p==="completed",[He.itemCurrent]:p==="current",[He.itemFuture]:p==="future",[He.itemDisabled]:w}),O=x.jsxs("div",{className:He.row,children:[x.jsxs("div",{className:He.stepHeader,children:[x.jsx("span",{className:He.stepNumber,children:h(_)}),x.jsx("span",{className:He.stepTitle,children:S.title})]}),p==="completed"?x.jsx(Rf,{size:20,className:He.checkIcon}):null]});return k?x.jsx(Vf,{as:"button",type:"button",className:R,onClick:()=>{E&&o(_,S)},disabled:w,"aria-current":p==="current"?"step":void 0,"aria-label":`Step ${h(_)}: ${S.title}`,"data-testid":`course-outline-item-${S.id}`,padding:m,radius:"panel",gap:"sm",children:O},S.id):x.jsx(Vf,{className:R,"aria-current":p==="current"?"step":void 0,"aria-label":`Step ${h(_)}: ${S.title}`,"data-testid":`course-outline-item-${S.id}`,padding:m,radius:"panel",gap:"sm",children:O},S.id)},[h,m,o,f]);return x.jsxs(ru,{...d,className:re(He.panel,i),role:"region","aria-label":n??e,"data-testid":u,children:[x.jsx("div",{className:He.header,children:x.jsx(Zn,{as:"h2",className:He.title,children:e})}),x.jsx("div",{className:He.divider,"aria-hidden":"true"}),x.jsx("div",{className:He.scrollArea,children:x.jsx(sl,{className:He.scrollable,children:f.length===0?x.jsx(Zn,{variant:"muted",className:He.empty,"data-testid":"course-outline-empty",children:l}):x.jsxs("div",{className:He.list,"data-testid":"course-outline-list",children:[y.length>0?x.jsxs("div",{className:He.section,"data-testid":"course-outline-section-completed",children:[x.jsx("div",{className:He.sectionHeader,children:x.jsx("span",{className:re(He.sectionTitle,c==="compact"?He.sectionTitleCompact:null),children:"Completed"})}),y.map(_=>g(_,"completed"))]}):null,v!==null?x.jsxs("div",{className:He.section,"data-testid":"course-outline-section-current",children:[x.jsx("div",{className:He.sectionHeader,children:x.jsx("span",{className:re(He.sectionTitle,c==="compact"?He.sectionTitleCompact:null),children:"Current"})}),g(v,"current")]}):null,T.length>0?x.jsxs("div",{className:He.section,"data-testid":"course-outline-section-upcoming",children:[x.jsx("div",{className:He.sectionHeader,children:x.jsx("span",{className:re(He.sectionTitle,c==="compact"?He.sectionTitleCompact:null),children:"Upcoming"})}),T.map(_=>g(_,"future"))]}):null]})})})]})}function RF(t){return x.jsx(EF,{...t})}const AF="_panel_8h64k_1",OF="_messagesArea_8h64k_20",NF="_messagesList_8h64k_46",MF="_messageItem_8h64k_53",DF="_messageMetadata_8h64k_59",LF="_senderName_8h64k_67",PF="_timestamp_8h64k_71",IF="_messageBubble_8h64k_75",BF="_agentMessage_8h64k_85",UF="_agentActions_8h64k_89",jF="_copyButton_8h64k_95",zF="_copyButtonCopied_8h64k_129",qF="_empty_8h64k_133",FF="_composer_8h64k_140",HF="_composerDisabled_8h64k_160",VF="_composerInput_8h64k_165",GF="_sendButton_8h64k_180",mn={panel:AF,messagesArea:OF,messagesList:NF,messageItem:MF,messageMetadata:DF,senderName:LF,timestamp:PF,messageBubble:IF,agentMessage:BF,agentActions:UF,copyButton:jF,copyButtonCopied:zF,empty:qF,composer:FF,composerDisabled:HF,composerInput:VF,sendButton:GF};function YF(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 WF(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 KF(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 XF(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 QF(t){const{messages:e,localIdentity:n,onSend:i,isSending:r=!1,inputPlaceholder:a="Type a message...",className:o,testId:s,...l}=t,[c,u]=A.useState(""),[d,h]=A.useState(null),f=A.useRef(null),y=A.useRef(null),v=A.useMemo(()=>{const p=e[e.length-1];return p?p.id??`${p.timestamp}-${e.length-1}`:null},[e]);A.useEffect(()=>{var p,S;(S=(p=f.current)==null?void 0:p.scrollIntoView)==null||S.call(p,{behavior:"smooth"})},[v]),A.useEffect(()=>()=>{y.current&&(window.clearTimeout(y.current),y.current=null)},[]);const T=A.useCallback(async()=>{const p=c.trim();p.length!==0&&(await i(p),u(""))},[c,i]),m=A.useCallback(p=>{p.key==="Enter"&&(p.preventDefault(),T())},[T]),g=A.useCallback(async(p,S)=>{try{await XF(p.message??""),h(S),y.current&&window.clearTimeout(y.current),y.current=window.setTimeout(()=>{h(null),y.current=null},2e3)}catch(k){console.warn("[PiPChatPanel] Failed to copy message",k)}},[]),_=c.trim().length>0&&!r;return x.jsxs("div",{...l,className:re(mn.panel,o),"data-testid":s,role:"region","aria-label":"Chat",children:[x.jsx("div",{className:mn.messagesArea,children:e.length===0?x.jsx("div",{className:mn.empty,"data-testid":"pip-chat-panel-empty",children:"No messages yet"}):x.jsxs("div",{className:mn.messagesList,"data-testid":"pip-chat-panel-list",children:[e.map((p,S)=>{const k=p.id??`${p.timestamp}-${S}`,w=WF(p,n),E=d===k;return x.jsxs("div",{className:re(mn.messageItem,w&&mn.agentMessage),"data-testid":`pip-chat-panel-message-${k}`,children:[x.jsxs("div",{className:mn.messageMetadata,children:[x.jsx("span",{className:mn.senderName,children:KF(p,n)}),x.jsx("span",{className:mn.timestamp,children:YF(p.timestamp)})]}),x.jsx("div",{className:mn.messageBubble,children:p.message}),w?x.jsx("div",{className:mn.agentActions,children:x.jsx("button",{type:"button",className:re(mn.copyButton,E&&mn.copyButtonCopied),onClick:()=>void g(p,k),"aria-label":E?"Copied":"Copy message",title:E?"Copied":"Copy message","data-testid":"pip-copy-agent-message","data-copied":E?"true":"false",children:x.jsx(H2,{size:14})})}):null]},k)}),x.jsx("div",{ref:f})]})}),x.jsxs("div",{className:re(mn.composer,r&&mn.composerDisabled),children:[x.jsx("input",{type:"text",className:mn.composerInput,value:c,onChange:p=>u(p.target.value),onKeyDown:m,placeholder:a,disabled:r,"aria-label":"Message"}),x.jsx("button",{type:"button",className:mn.sendButton,onClick:()=>void T(),disabled:!_,"aria-label":"Send message",children:x.jsx(K2,{size:16})})]})]})}const JF="_panel_q8m25_1",ZF="_header_q8m25_11",$F="_title_q8m25_19",eH="_titleCompact_q8m25_29",tH="_headerActions_q8m25_33",nH="_closeButton_q8m25_39",iH="_divider_q8m25_67",rH="_body_q8m25_73",aH="_messagesArea_q8m25_81",oH="_scrollable_q8m25_86",sH="_messagesList_q8m25_90",lH="_messageItem_q8m25_98",cH="_messageMetadata_q8m25_104",uH="_senderName_q8m25_112",dH="_timestamp_q8m25_116",hH="_messageBubble_q8m25_120",fH="_messageText_q8m25_124",pH="_agentMessage_q8m25_130",mH="_agentActions_q8m25_134",gH="_copyButton_q8m25_140",vH="_copyButtonCopied_q8m25_174",bH="_inputRow_q8m25_178",yH="_empty_q8m25_182",_H="_composer_q8m25_188",xH="_composerDefault_q8m25_203",SH="_composerCompact_q8m25_208",TH="_composerDisabled_q8m25_218",kH="_composerInputWrapper_q8m25_223",wH="_composerInput_q8m25_223",CH="_sendButton_q8m25_240",EH="_sendButtonCompact_q8m25_257",Ve={panel:JF,header:ZF,title:$F,titleCompact:eH,headerActions:tH,closeButton:nH,divider:iH,body:rH,messagesArea:aH,scrollable:oH,messagesList:sH,messageItem:lH,messageMetadata:cH,senderName:uH,timestamp:dH,messageBubble:hH,messageText:fH,agentMessage:pH,agentActions:mH,copyButton:gH,copyButtonCopied:vH,inputRow:bH,empty:yH,composer:_H,composerDefault:xH,composerCompact:SH,composerDisabled:TH,composerInputWrapper:kH,composerInput:wH,sendButton:CH,sendButtonCompact:EH};function RH(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 AH(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 OH(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 NH(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 MH(t){const{disabled:e,placeholder:n,size:i="md",autoFocus:r,onSend:a}=t,[o,s]=A.useState(""),l=A.useCallback(async()=>{const f=o.trim();f.length!==0&&(await a(f),s(""))},[a,o]),c=A.useCallback(f=>{f.key==="Enter"&&(f.preventDefault(),l())},[l]),u=i==="sm"||i==="xs",d=u?18:24,h=o.trim().length>0&&e!==!0;return x.jsxs("div",{className:re(Ve.composer,u?Ve.composerCompact:Ve.composerDefault,e?Ve.composerDisabled:null),children:[x.jsx("div",{className:Ve.composerInputWrapper,children:x.jsx(Q2,{value:o,onChange:s,onKeyDown:c,className:Ve.composerInput,placeholder:n??"Send a message ...",disabled:e,size:i,autoFocus:r,"aria-label":"Message"})}),x.jsx("button",{type:"button",className:re(Ve.sendButton,u?Ve.sendButtonCompact:null),onClick:()=>void l(),disabled:!h,"aria-label":"Send message",children:x.jsx(K2,{size:d})})]})}function GE(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:f=RH,getSenderName:y,isAgentMessage:v,copyResetDelayMs:T=2e3,showAgentCopyButton:m=!0,inputPlaceholder:g,inputAutoFocus:_,...p}=t,S=A.useRef(null),[k,w]=A.useState(null),E=A.useRef(null),R=A.useCallback(H=>y?y(H):OH(H,o),[y,o]),O=A.useCallback(H=>v?v(H,o):AH(H,o),[v,o]),D=A.useMemo(()=>{const H=r[r.length-1];return H?H.id??`${H.timestamp}-${r.length-1}`:null},[r]);A.useEffect(()=>{var H,P;(P=(H=S.current)==null?void 0:H.scrollIntoView)==null||P.call(H,{behavior:"smooth"})},[D]),A.useEffect(()=>()=>{E.current&&(window.clearTimeout(E.current),E.current=null)},[]);const q=A.useCallback(H=>{w(H),E.current&&window.clearTimeout(E.current),E.current=window.setTimeout(()=>{w(null),E.current=null},T)},[T]),Y=A.useCallback(async(H,P)=>{try{await NH(H.message??""),q(P)}catch(W){console.warn("[ChatPanel] Failed to copy message",W)}},[q]),se=d==="compact"?"sm":"md";return x.jsxs(ru,{...p,className:re(Ve.panel,i),role:"region","aria-label":n??e,"data-testid":h,children:[x.jsxs("div",{className:Ve.header,children:[x.jsx(Zn,{as:"h2",className:re(Ve.title,d==="compact"?Ve.titleCompact:null),children:e}),l&&c?x.jsx("div",{className:Ve.headerActions,children:x.jsx("button",{type:"button",className:Ve.closeButton,onClick:l,"aria-label":`Close ${e}`,children:x.jsx(Af,{size:d==="compact"?18:20})})}):null]}),x.jsx("div",{className:Ve.divider,"aria-hidden":"true"}),x.jsxs("div",{className:Ve.body,children:[x.jsx("div",{className:Ve.messagesArea,children:x.jsx(sl,{className:Ve.scrollable,children:r.length===0?x.jsx(Zn,{variant:"muted",className:Ve.empty,"data-testid":"chat-panel-empty",children:u}):x.jsxs("div",{className:Ve.messagesList,"data-testid":"chat-panel-list",children:[r.map((H,P)=>{const W=H.id??`${H.timestamp}-${P}`,X=O(H),ne=k===W;return x.jsxs("div",{className:re(Ve.messageItem,X?Ve.agentMessage:null),"data-testid":`chat-panel-message-${W}`,children:[x.jsxs("div",{className:Ve.messageMetadata,children:[x.jsx("span",{className:Ve.senderName,children:R(H)}),x.jsx("span",{className:Ve.timestamp,children:f(H.timestamp)})]}),x.jsx(Vf,{className:Ve.messageBubble,padding:"md",radius:"panel",background:X?"surfaceMuted":"surface",children:x.jsx("div",{className:Ve.messageText,children:H.message})}),X&&m?x.jsx("div",{className:Ve.agentActions,children:x.jsx("button",{type:"button",className:re(Ve.copyButton,ne?Ve.copyButtonCopied:null),onClick:()=>void Y(H,W),"aria-label":ne?"Copied":"Copy agent message",title:ne?"Copied":"Copy agent message","data-testid":"copy-agent-message","data-copied":ne?"true":"false",children:x.jsx(H2,{size:18})})}):null]},W)}),x.jsx("div",{ref:S})]})})}),x.jsx("div",{className:Ve.inputRow,children:x.jsx(MH,{onSend:s,disabled:a,placeholder:g,size:se,autoFocus:_})})]})]})}A.createContext("vertical");const DH="_container_1a1i6_1",LH="_video_1a1i6_7",PH="_chip_1a1i6_16",IH="_logo_1a1i6_34",Gf={container:DH,video:LH,chip:PH,logo:IH},BH="https://obi-static.s3.ap-southeast-2.amazonaws.com/videos/greeting.mp4";function UH(t){const{agentName:e="Obi",className:n,...i}=t,r=A.useRef(null),a=()=>{var o;try{(o=r.current)==null||o.pause()}catch{}};return x.jsxs("div",{className:re(Gf.container,n),...i,children:[x.jsx("video",{ref:r,className:Gf.video,src:BH,autoPlay:!0,muted:!0,playsInline:!0,onEnded:a}),x.jsxs("div",{className:Gf.chip,children:[x.jsx(lB,{size:14,className:Gf.logo}),x.jsx("span",{children:e})]})]})}typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;const YE=50,ul="?",WE=/\(error: (.*)\)/,KE=/captureMessage|captureException/;function jH(...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(`
121
- `);for(let s=i;s<o.length;s++){const l=o[s];if(l.length>1024)continue;const c=WE.test(l)?l.replace(WE,"$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>=YE+r)break}}return zH(a.slice(r))}}function zH(t){if(!t.length)return[];const e=Array.from(t);return/sentryWrapped/.test(Yf(e).function||"")&&e.pop(),e.reverse(),KE.test(Yf(e).function||"")&&(e.pop(),KE.test(Yf(e).function||"")&&e.pop()),e.slice(0,YE).map(n=>({...n,filename:n.filename||Yf(e).filename,function:n.function||ul}))}function Yf(t){return t[t.length-1]||{}}typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;const qH=30,FH=50;function xb(t,e,n,i){const r={filename:t,function:e==="<anonymous>"?ul:e,in_app:!0};return n!==void 0&&(r.lineno=n),i!==void 0&&(r.colno=i),r}const HH=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,VH=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,GH=/\((\S*)(?::(\d+))(?::(\d+))\)/,YH=t=>{const e=HH.exec(t);if(e){const[,i,r,a]=e;return xb(i,ul,+r,+a)}const n=VH.exec(t);if(n){if(n[2]&&n[2].indexOf("eval")===0){const a=GH.exec(n[2]);a&&(n[2]=a[1],n[3]=a[2],n[4]=a[3])}const[i,r]=XE(n[1]||ul,n[2]);return xb(r,i,n[3]?+n[3]:void 0,n[4]?+n[4]:void 0)}},WH=[qH,YH],KH=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,XH=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i;jH(...[WH,[FH,t=>{const e=KH.exec(t);if(e){if(e[3]&&e[3].indexOf(" > eval")>-1){const r=XH.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]||ul;return[i,n]=XE(i,n),xb(n,i,e[4]?+e[4]:void 0,e[5]?+e[5]:void 0)}}]]);const XE=(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]:ul,n?`safari-extension:${e}`:`safari-web-extension:${e}`]:[t,e]};typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;const Er={shell:"_shell_3h8q7_1",layout:"_layout_3h8q7_11",layoutThree:"_layoutThree_3h8q7_23",leftPanel:"_leftPanel_3h8q7_27",middlePanel:"_middlePanel_3h8q7_36",rightPanel:"_rightPanel_3h8q7_37",videoFrame:"_videoFrame_3h8q7_41",captions:"_captions_3h8q7_51",controls:"_controls_3h8q7_57",coursePanel:"_coursePanel_3h8q7_70"};function Sb(...t){return t.filter(Boolean).join(" ")}function QH(t){const{captionsText:e,avatarAudioPower:n=0,avatarImageSrc:i,avatarAriaLabel:r,avatarStatus:a,controlBarProps:o,courses:s,coursePanelProps:l,middlePanel:c,rightPanel:u,className:d}=t;return x.jsx("div",{className:Sb(Er.shell,d),"data-testid":"course-dialog-content",children:x.jsxs("div",{className:Sb(Er.layout,u?Er.layoutThree:null),children:[x.jsxs("div",{className:Er.leftPanel,children:[x.jsx("div",{className:Er.videoFrame,children:x.jsx(wq,{className:Er.captions,text:e,children:x.jsx(IE,{audioPower:n,size:"lg",background:"flat",imageSrc:i,ariaLabel:r??"Agent avatar placeholder",status:a})})}),x.jsx("div",{className:Er.controls,children:x.jsx($j,{...o})})]}),x.jsx("div",{className:Er.middlePanel,"data-testid":"course-dialog-middle-panel",children:c??x.jsx(nF,{...l,courses:s,className:Sb(Er.coursePanel,l==null?void 0:l.className)})}),u?x.jsx("div",{className:Er.rightPanel,"data-testid":"course-dialog-right-panel",children:u}):null]})})}function QE(t){const{open:e,onClose:n,dialogProps:i,...r}=t;return x.jsx(rE,{open:e,onClose:n,variant:"ghost",...i,children:x.jsx(QH,{...r})})}const JH=80,ZH=500,$H=1e3;function eV(t,e){const{delayMs:n=0}=e??{},r=t.filter(v=>{var m;const T=(m=v.participantInfo)==null?void 0:m.identity;return(T==null?void 0:T.startsWith("agent-"))??!1}).map(v=>v.text??"").join(" ").trim(),[a,o]=A.useState(""),[s,l]=A.useState(!1),c=A.useRef(""),u=A.useRef(null),d=A.useRef(null),h=A.useRef(null),f=v=>{h.current&&(clearTimeout(h.current),h.current=null),n>0?h.current=setTimeout(()=>{o(v)},n):o(v)},y=(v,T)=>v.startsWith(T)?v.slice(T.length).trim():v.trim();return A.useEffect(()=>{if(d.current&&(clearTimeout(d.current),d.current=null),s)return;const v=y(r,c.current);f(v),v.length>JH?(l(!0),u.current=setTimeout(()=>{l(!1),c.current=r},ZH+n)):v.length>0&&(d.current=setTimeout(()=>{c.current=r,f("")},$H+n))},[r,s,n]),A.useEffect(()=>()=>{u.current&&clearTimeout(u.current),d.current&&clearTimeout(d.current),h.current&&clearTimeout(h.current)},[]),{caption:a,hasCaption:a.length>0}}const nr={layout:"_layout_17ztq_1",left:"_left_17ztq_10",copy:"_copy_17ztq_17",description:"_description_17ztq_25",descriptionScroller:"_descriptionScroller_17ztq_31",cta:"_cta_17ztq_36",disclaimer:"_disclaimer_17ztq_43",right:"_right_17ztq_47",mediaPanel:"_mediaPanel_17ztq_56",agentStill:"_agentStill_17ztq_63",dialogWithSmallClose:"_dialogWithSmallClose_17ztq_87"};function tV(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=!0,isStarting:u=!1}=t;return x.jsx(rE,{open:e,onClose:n,size:"large",showCloseButton:c,className:nr.dialogWithSmallClose,children:x.jsxs("div",{className:nr.layout,children:[x.jsxs("div",{className:nr.left,children:[x.jsxs("div",{className:nr.copy,children:[x.jsx(Zn,{variant:"heading",children:r}),x.jsx(Zn,{variant:"subheading",children:a}),x.jsx(Zn,{variant:"muted",as:"div",className:nr.description,children:x.jsx(sl,{className:nr.descriptionScroller,children:x.jsx(vj,{content:o})})})]}),x.jsxs("div",{className:nr.cta,children:[x.jsx(ol,{type:"button",size:"lg",fullWidth:!0,onClick:i,isLoading:u,children:s}),x.jsx(Zn,{variant:"subscript",as:"p",className:nr.disclaimer,children:l})]})]}),x.jsx("div",{className:nr.right,children:x.jsx(ru,{className:nr.mediaPanel,children:x.jsx(UH,{agentName:r,className:nr.agentStill})})})]})})}function nV(t){let e=t.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*/g,"__DOUBLE_STAR__").replace(/\*/g,"[^/]*").replace(/__DOUBLE_STAR__/g,".*").replace(/\?/g,"[^/]");return new RegExp(`^${e}$`,"i")}function iV(t,e){if(!e||e.length===0)return!1;const n=t.replace(/^https?:\/\//,"").replace(/\/$/,"");return e.some(i=>{try{const r=nV(i);return r.test(n)||r.test(t)}catch(r){return console.warn(`Invalid URL pattern: ${i}`,r),!1}})}function Wf(t){if(!t||t.length===0)return!1;const e=window.location.origin+window.location.pathname;return iV(e,t)}function rV(t){var gn,Mt,Di,hi,rn,Pn,$n,rr,Rr,oe,Ge,xe,Ze,st,Li,ar,oo,Ar,so,Pi;const{sdk:e,shadowHost:n}=t,[i,r]=A.useState("hidden"),[a,o]=A.useState(()=>{var Z;return((Z=e.client)==null?void 0:Z.session)||null}),[s,l]=A.useState(!1),[c,u]=A.useState(!1),[d,h]=A.useState(!1),[f,y]=A.useState(()=>{var ce;const Z=(ce=e.client)==null?void 0:ce.session;return Z!=null&&Z.sessionUuid?aV(Z.sessionUuid):null}),[v,T]=A.useState([]),[m,g]=A.useState(null),[_,p]=A.useState(0),[S,k]=A.useState(!1),[w,E]=A.useState(0),[R,O]=A.useState(null),[D,q]=A.useState([]),[Y,se]=A.useState(!0),H=oV((Mt=(gn=e.client)==null?void 0:gn.product)==null?void 0:Mt.widget_url_blacklist),P=sV(a),{audioDevices:W}=lV();A.useEffect(()=>{a!=null&&a.sessionUuid&&JE(a.sessionUuid,f)},[f,a==null?void 0:a.sessionUuid]);const{caption:X}=eV(D,{delayMs:0}),ne=Y?X:"",K=typeof navigator<"u"&&!!((Di=navigator.mediaDevices)!=null&&Di.getDisplayMedia),ee=((rn=(hi=a==null?void 0:a.room)==null?void 0:hi.localParticipant)==null?void 0:rn.isScreenShareEnabled)??!1,J=(()=>{if(a!=null&&a.speakingState){if(a.speakingState==="thinking")return"thinking";if(a.speakingState==="busy")return"searching"}})(),V=()=>p(Z=>Z+1),ae=async()=>{var ce,Ne;if(!a)return;const Z=((Ne=(ce=a.room)==null?void 0:ce.localParticipant)==null?void 0:Ne.isScreenShareEnabled)??!1;try{Z?await a.setScreenShareEnabled(!1):await a.shareScreen()}catch(Ae){console.error("[obi-sdk] failed to toggle screen share",Ae)}finally{V()}},j=A.useRef(null),ve=A.useRef(null),B=A.useRef(!1),le=Z=>{if(!Z||j.current===Z)return;ve.current&&(ve.current(),ve.current=null);const ce=()=>V(),Ne=at=>{y(at),Z!=null&&Z.sessionUuid&&JE(Z.sessionUuid,at),r(de=>de==="course-selection"?(k(!1),"pip"):de)},Ae=at=>{T(at.courses),r("course-selection"),y(null),Z!=null&&Z.sessionUuid&&ZE(Z.sessionUuid),g(null)},pt=(at,de)=>{},Ct=at=>{O(at),E(Date.now())},Yt=at=>{at&&O(at),E(Date.now())};Z.on("stateChanged",ce),Z.on("speakingStateChanged",ce),Z.on("paused",ce),Z.on("unpaused",ce),Z.on("chatMessagesChanged",ce),Z.on("courseProgress",Ne),Z.on("courseSelection",Ae),Z.on("transcript",pt),Z.on("screenCaptured",Ct),Z.on("screenCaptureNotification",Yt),Z.on("captions",q),j.current=Z,ve.current=()=>{Z.off("stateChanged",ce),Z.off("speakingStateChanged",ce),Z.off("paused",ce),Z.off("unpaused",ce),Z.off("chatMessagesChanged",ce),Z.off("courseProgress",Ne),Z.off("courseSelection",Ae),Z.off("transcript",pt),Z.off("screenCaptured",Ct),Z.off("screenCaptureNotification",Yt),Z.off("captions",q)}},me=Z=>{var Ne;return Z?((Ne=Z.roomId)==null?void 0:Ne.startsWith("obs-"))&&!f?"course-selection":"pip":"hidden"};A.useEffect(()=>{const Z=Ne=>{var Ae,pt,Ct;Ne?(Ae=e.client)!=null&&Ae.session?r(me(((pt=e.client)==null?void 0:pt.session)??null)):r("start-session"):(Ct=e.client)!=null&&Ct.session||r("hidden")},ce=()=>V();if(e.on("showMenu",Z),e.on("configUpdated",ce),e.client){e.client.session&&(o(e.client.session),le(e.client.session),r(me(e.client.session))),e.client.on("sessionStarted",Ae=>{o(Ae),le(Ae),B.current=!1,l(!1),u(!1),h(!1),r(me(Ae)),vg().track("session-started",{planId:Ae.planId})}),e.client.on("sessionResumed",Ae=>{o(Ae),le(Ae),B.current=!1,l(!1),u(!1),h(!1),r(me(Ae))});const Ne=()=>{var pt;const Ae=(pt=e.client)==null?void 0:pt.session;Ae!=null&&Ae.sessionUuid&&ZE(Ae.sessionUuid),ve.current&&(ve.current(),ve.current=null),o(null),j.current=null,l(!1),u(!1),h(!1),B.current||r("hidden")};e.client.on("sessionStopped",Ne),e.client.on("sessionShutdown",Ne),e.client.on("stateChanged",V)}return()=>{e.off("showMenu",Z),e.off("configUpdated",ce),ve.current&&ve.current()}},[e]),A.useLayoutEffect(()=>{var Z,ce;(ce=(Z=e.client)==null?void 0:Z.product)!=null&&ce.primary_color&&n.style.setProperty("--obi-color-primary",e.client.product.primary_color)},[($n=(Pn=e.client)==null?void 0:Pn.product)==null?void 0:$n.primary_color,n]);const yn=(f==null?void 0:f.stepNames.map((Z,ce)=>({id:`step-${ce+1}`,title:Z})))??[],di=(f==null?void 0:f.currentStep)??null,ir=!0,Gt=(Z,ce)=>{a==null||a.say(`Can we jump to the section about ${ce.title}?`)};if(H||i==="hidden")return null;if(i==="start-session"){const Z=(rr=e.client)==null?void 0:rr.product,ce=(Rr=e.client)==null?void 0:Rr.selectedPlan,Ne=(Z==null?void 0:Z.agent_name)||"Obi",Ae="AI Assistant",pt=(ce==null?void 0:ce.description)||(Z==null?void 0:Z.description)||"I'm here to help you.";return x.jsx(tV,{open:!0,onClose:()=>{l(!1),r("hidden")},onStart:()=>{l(!0),e.startSession({withMicrophone:!0})},agentName:Ne,agentSubtitle:Ae,description:pt,showCloseButton:!1,startLabel:"Start Session",isStarting:s})}if(i==="course-selection"){const Z=(oe=a==null?void 0:a.roomId)==null?void 0:oe.startsWith("obs-"),ce=((Ge=e.client)==null?void 0:Ge.plans)||[],Ne=Z&&v.length>0,Ae=Ne?v.slice().sort((de,Ye)=>de.order!==void 0&&Ye.order!==void 0?de.order-Ye.order:de.order!==void 0?-1:Ye.order!==void 0?1:de.name.localeCompare(Ye.name)).map(de=>({id:de.uuid,title:de.name,description:de.description||de.overview||"",status:de.completed?"completed":"available",duration:typeof de.duration=="number"?`${de.duration} min`:de.duration})):ce.map(de=>{var Ye,In;return{id:de.uuid,title:de.name,description:de.description,status:(In=(Ye=e.client)==null?void 0:Ye.planIsCompleted)!=null&&In[ce.indexOf(de)]?"completed":"available",duration:de.estimated_duration?`${de.estimated_duration} min`:void 0}}),pt=(a==null?void 0:a.languageCodes)||[],Ct=(a==null?void 0:a.selectedLanguage)||(a==null?void 0:a.defaultLanguageCode)||null,Yt={audioDevices:W,currentMicrophoneId:(a==null?void 0:a.preferredMicrophoneDeviceId)||null,isMicrophoneEnabled:!c&&((a==null?void 0:a.isMicShared)??!1),isScreenShareActive:ee,widgetState:d?"chat":null,canPublishData:!0,browserSupportsScreenSharing:K,onMicDeviceSelect:async de=>{e.client&&(e.client.preferredMicrophoneDeviceId=de),a&&de&&await a.switchMicrophoneDevice(de),V()},onMicToggle:async()=>{a!=null&&a.isMicShared?c?(a.unmuteMicrophone(),u(!1)):(a.muteMicrophone(),u(!0)):await(a==null?void 0:a.shareMicrophone())},onChatToggle:()=>{h(!d)},onLeave:()=>{a==null||a.stop()},onScreenShareToggle:ae,languages:pt,selectedLanguage:Ct,defaultLanguageCode:a==null?void 0:a.defaultLanguageCode,isMultilingual:(a==null?void 0:a.isMultilingual)??!1,onLanguageChange:de=>{a==null||a.setLanguage(de)},isLanguageSelectorEnabled:!0,...d?{screenShareButtonVariant:"compact"}:{}},at=d?x.jsx(GE,{messages:(a==null?void 0:a.chatMessages)??[],localIdentity:((xe=a==null?void 0:a.room)==null?void 0:xe.localParticipant.identity)??(typeof(a==null?void 0:a.identity)=="string"?a.identity:null),onSend:async de=>{var Ye,In,Ii,he;a&&(a.appendChatMessage({timestamp:Date.now(),message:de,from:{identity:((In=(Ye=a.room)==null?void 0:Ye.localParticipant)==null?void 0:In.identity)??null,name:((he=(Ii=a.room)==null?void 0:Ii.localParticipant)==null?void 0:he.name)??null},isAgent:!1}),await a.say(de))},onClose:()=>h(!1)}):void 0;return x.jsx(QE,{open:!0,onClose:()=>a==null?void 0:a.stop(),courses:Ae,controlBarProps:Yt,coursePanelProps:{selectedCourseIds:m?[m]:void 0,onCourseToggle:async de=>{var Ye,In,Ii;if(Ne){const he=v.find(Dt=>Dt.uuid===de);if(he){g(de);try{await((Ye=a==null?void 0:a.say)==null?void 0:Ye.call(a,`I'd like to take the ${he.name} course.`))}catch(Dt){console.error("[obi-sdk] failed to send course selection",Dt),g(null)}}}else{const he=ce.find(Dt=>Dt.uuid===de);if(he){(In=e.client)==null||In.selectPlan(he),r("pip");try{await((Ii=a==null?void 0:a.say)==null?void 0:Ii.call(a,`I'd like to take the ${he.name} course.`))}catch(Dt){console.error("[obi-sdk] failed to send course selection",Dt),r("course-selection")}}}}},rightPanel:at,avatarImageSrc:((st=(Ze=e.client)==null?void 0:Ze.product)==null?void 0:st.logo_url)||void 0,avatarAudioPower:P,avatarStatus:J,captionsText:ne})}if(i==="course-outline"){const Z=(a==null?void 0:a.languageCodes)||[],ce=(a==null?void 0:a.selectedLanguage)||(a==null?void 0:a.defaultLanguageCode)||null,Ne={audioDevices:W,currentMicrophoneId:(a==null?void 0:a.preferredMicrophoneDeviceId)||null,isMicrophoneEnabled:!c&&((a==null?void 0:a.isMicShared)??!1),isScreenShareActive:ee,widgetState:d?"chat":null,canPublishData:!0,browserSupportsScreenSharing:K,onMicDeviceSelect:async Ct=>{e.client&&(e.client.preferredMicrophoneDeviceId=Ct),a&&Ct&&await a.switchMicrophoneDevice(Ct),V()},onMicToggle:async()=>{a!=null&&a.isMicShared?c?(a.unmuteMicrophone(),u(!1)):(a.muteMicrophone(),u(!0)):await(a==null?void 0:a.shareMicrophone())},onChatToggle:()=>{h(!d)},onLeave:()=>{a==null||a.stop()},onScreenShareToggle:ae,languages:Z,selectedLanguage:ce,defaultLanguageCode:a==null?void 0:a.defaultLanguageCode,isMultilingual:(a==null?void 0:a.isMultilingual)??!1,onLanguageChange:Ct=>{a==null||a.setLanguage(Ct)},isLanguageSelectorEnabled:!0,...d?{screenShareButtonVariant:"compact"}:{}},Ae=d?x.jsx(GE,{messages:(a==null?void 0:a.chatMessages)??[],localIdentity:((Li=a==null?void 0:a.room)==null?void 0:Li.localParticipant.identity)??(typeof(a==null?void 0:a.identity)=="string"?a.identity:null),onSend:async Ct=>{var Yt,at,de,Ye;a&&(a.appendChatMessage({timestamp:Date.now(),message:Ct,from:{identity:((at=(Yt=a.room)==null?void 0:Yt.localParticipant)==null?void 0:at.identity)??null,name:((Ye=(de=a.room)==null?void 0:de.localParticipant)==null?void 0:Ye.name)??null},isAgent:!1}),await a.say(Ct))},onClose:()=>h(!1)}):void 0,pt=x.jsx(RF,{steps:yn,currentStep:di,hideTrailingConclusionStep:ir,onStepClick:Gt});return x.jsx(QE,{open:!0,onClose:()=>a==null?void 0:a.stop(),courses:[],controlBarProps:Ne,middlePanel:pt,rightPanel:Ae,avatarImageSrc:((oo=(ar=e.client)==null?void 0:ar.product)==null?void 0:oo.logo_url)||void 0,avatarAudioPower:P,avatarStatus:J,captionsText:ne})}if(i==="pip"){const Z=(a==null?void 0:a.languageCodes)||[],ce=(a==null?void 0:a.selectedLanguage)||(a==null?void 0:a.defaultLanguageCode)||null,Ne=280,Ae=250,pt=16,Ct={x:window.innerWidth-Ne-pt,y:window.innerHeight-Ae-pt},Yt={isMicrophoneEnabled:!c&&((a==null?void 0:a.isMicShared)??!1),isChatOpen:d,isScreenShareActive:ee,onMicToggle:async()=>{a!=null&&a.isMicShared?c?(a.unmuteMicrophone(),u(!1)):(a.muteMicrophone(),u(!0)):await(a==null?void 0:a.shareMicrophone())},onChatToggle:()=>h(de=>!de),onScreenShareToggle:ae,onLeave:()=>{a==null||a.stop()},languages:Z,selectedLanguage:ce,defaultLanguageCode:a==null?void 0:a.defaultLanguageCode,isMultilingual:(a==null?void 0:a.isMultilingual)??!1,onLanguageChange:de=>{a==null||a.setLanguage(de)},isLanguageSelectorEnabled:!0},at=d?x.jsx(QF,{messages:(a==null?void 0:a.chatMessages)??[],localIdentity:((Ar=a==null?void 0:a.room)==null?void 0:Ar.localParticipant.identity)??(typeof(a==null?void 0:a.identity)=="string"?a.identity:null),onSend:async de=>{var Ye,In,Ii,he;a&&(a.appendChatMessage({timestamp:Date.now(),message:de,from:{identity:((In=(Ye=a.room)==null?void 0:Ye.localParticipant)==null?void 0:In.identity)??null,name:((he=(Ii=a.room)==null?void 0:Ii.localParticipant)==null?void 0:he.name)??null},isAgent:!1}),await a.say(de))},testId:"pip-chat-panel"}):void 0;return x.jsx(_q,{initialPosition:Ct,onExit:()=>{r("course-outline")},controlBarProps:Yt,isCourseOutlineSelected:S&&!!f,onCourseOutlineToggle:f?()=>{k(de=>!de)}:void 0,isCaptionsEnabled:Y,onCaptionsToggle:()=>se(de=>!de),courseOutline:f?{steps:yn,currentStep:di,onStepClick:Gt,hideTrailingConclusionStep:ir}:void 0,messagesPanel:at,avatarFallbackProps:{audioPower:P,imageSrc:((Pi=(so=e.client)==null?void 0:so.product)==null?void 0:Pi.logo_url)??void 0,status:J,captionsText:ne},screenshotUrl:R,cameraShotTrigger:w})}return null}function JE(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 aV(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 ZE(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 oV(t){const[e,n]=A.useState(()=>Wf(t));return A.useEffect(()=>{n(Wf(t))},[t]),A.useEffect(()=>{const i=()=>{n(Wf(t))};return window.addEventListener("popstate",i),window.addEventListener("hashchange",i),()=>{window.removeEventListener("popstate",i),window.removeEventListener("hashchange",i)}},[t]),e}function sV(t){const[e,n]=A.useState(0),i=A.useRef(null),r=A.useRef(0),a=A.useRef(0);return A.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 y=0;for(let v=0;v<s.length;v++)y+=s[v];l=Math.min(1,Math.max(0,y/s.length))}const c=r.current,d=l>=c?.7:.15,h=c*d+l*(1-d);r.current=h;const f=h<.05?0:Math.min(1,h);Math.abs(f-a.current)>.01&&(a.current=f,n(f)),i.current=requestAnimationFrame(o)};return i.current=requestAnimationFrame(o),()=>{i.current&&cancelAnimationFrame(i.current)}},[t]),e}function lV(){const[t,e]=A.useState({audioDevices:[]});return A.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 cV(t){if(document.querySelector("#obi-host")||document.querySelector("obi-widget"))return;uV();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(tB);const a=new CSSStyleSheet;a.replaceSync($9);const o=new CSSStyleSheet;o.replaceSync(Z9);const s=new CSSStyleSheet;s.replaceSync(eB),n.adoptedStyleSheets=[r,a,o,s],J9.createRoot(i).render(x.jsx(rV,{sdk:t,shadowHost:e})),console.log("[obi-sdk] widget mounted")}function uV(){$E("https://fonts.cdnfonts.com/css/satoshi"),$E("https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap")}function $E(t){const e=document.createElement("link");e.href=t,e.rel="stylesheet",document.head.appendChild(e)}const e3="49206C6F7665204F6269_session",t3="obi-url-params";class dV extends Jf{constructor(e){super(),this.client=null,this.isActive=!1,this.primaryColour="#9500FF",this.passivePlanUuid=null,this.commandLog=[],this.commandQueue=[],this._resumed=!1,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=this.load();if(i)try{n=Jd.deserialise(i,e,"sdk",{apiBaseUrl:"https://staging.coragents.ai",captureScreen:this.captureScreen.bind(this)}),n?this._resumed=!0:localStorage.removeItem("obi-client")}catch(r){console.error("[obi] error loading cached client",r),localStorage.removeItem("obi-client")}n||(n=new Jd(e,"sdk",{apiBaseUrl:"https://staging.coragents.ai",captureScreen:this.captureScreen.bind(this)})),this.client=n,this.client.on("stateChanged",r=>{var a,o,s,l,c,u,d,h,f,y;r==="ready"&&this.updateConfig({isActive:((a=window==null?void 0:window.obiWidgetConfig)==null?void 0:a.isActive)??((o=this.client)==null?void 0:o.showWidget),primaryColour:((l=(s=this.client)==null?void 0:s.product)==null?void 0:l.primary_color)||"#9500FF",widgetDisplay:((c=window==null?void 0:window.obiWidgetConfig)==null?void 0:c.widgetDisplay)||((d=(u=this.client)==null?void 0:u.product)==null?void 0:d.widget_display)||"regular",completedWidgetDisplay:((h=window==null?void 0:window.obiWidgetConfig)==null?void 0:h.completedWidgetDisplay)||((y=(f=this.client)==null?void 0:f.product)==null?void 0:y.completed_widget_display)||"regular"})}),this.client.on("sessionStarted",()=>{this.save(),this.passivePlanUuid=null}),this.client.on("sessionStopped",()=>{localStorage.removeItem("obi-client"),this.passivePlanUuid=null}),this.client.on("sessionShutdown",()=>{localStorage.removeItem("obi-client")}),this.client.on("trackEvent",(r,a)=>{}),this.client.session&&(this.client.session.isPaused,this.client.resumeSession(r=>{r.on("stateChanged",a=>{a!=="disconnecting"&&a!=="disconnected"&&a!=="error"&&a!=="connecting"&&this.save()}),r.on("paused",()=>{this.save()}),r.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&&Wf(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{vg().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){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),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&&vg().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(t3)||"{}"),Object.keys(e).length===0&&new URLSearchParams(window.location.search).forEach((a,o)=>{e[o]=a});const n=e[e3];if(!n)return null;const i=new URL(window.location.href);i.searchParams.delete(e3),window.history.replaceState({},"",i.toString()),i.toString(),localStorage.removeItem(t3),this.passivePlanUuid=n}mountWidget(){cV(this)}showMessage(e,n){try{this.emit("showMessage",{text:e,autoCloseMs:n==null?void 0:n.autoCloseMs})}catch{}}async captureScreen(){try{await OO(async()=>(this.graphemes||(this.graphemes=await this.client.api.getGraphemes()),this.graphemes.data.text_segmentation)),await k3(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 lO(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")}}async function n3(t,e){let n;try{n=window}catch{console.warn("[obi] no window object found"),n={}}return hV({appToken:t,window:n,init:e})}async function hV({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 dV(t);return e.ObiSDK=r.dispatchCommand,await r.initialise({queuedCommands:i}),e.obi=r,r.mountWidget(),r}function i3(){}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{n3(void 0,i3)}):n3(void 0,i3)})();
120
+ Please report this to https://github.com/markedjs/marked.`,t){let i="<p>An error occurred:</p><pre>"+aa(n.message+"",!0)+"</pre>";return e?Promise.resolve(i):i}if(e)return Promise.reject(n);throw n}}},Fo=new hj;function Ke(t,e){return Fo.parse(t,e)}Ke.options=Ke.setOptions=function(t){return Fo.setOptions(t),Ke.defaults=Fo.defaults,bE(Ke.defaults),Ke},Ke.getDefaults=ob,Ke.defaults=qo,Ke.use=function(...t){return Fo.use(...t),Ke.defaults=Fo.defaults,bE(Ke.defaults),Ke},Ke.walkTokens=function(t,e){return Fo.walkTokens(t,e)},Ke.parseInline=Fo.parseInline,Ke.Parser=$i,Ke.parser=$i.parse,Ke.Renderer=zf,Ke.TextRenderer=mb,Ke.Lexer=Zi,Ke.lexer=Zi.lex,Ke.Tokenizer=jf,Ke.Hooks=nu,Ke.parse=Ke,Ke.options,Ke.setOptions,Ke.use,Ke.walkTokens,Ke.parseInline,$i.parse,Zi.lex;const fj="_base_1ne03_1",pj={base:fj},mj=["p","br","strong","em","u","a","ul","ol","li","h1","h2","h3","h4","h5","h6","code","pre","blockquote","hr"],gj=["href","title","target","rel"];Ke.setOptions({breaks:!0,gfm:!0});function vj(t){const{content:e,className:n,...i}=t,r=A.useMemo(()=>{if(!e)return"";const a=Ke.parse(e,{async:!1});return A7.sanitize(a,{ALLOWED_TAGS:[...mj],ALLOWED_ATTR:[...gj],ALLOW_DATA_ATTR:!1})},[e]);return r?x.jsx("div",{className:re(pj.base,n),dangerouslySetInnerHTML:{__html:r},...i}):null}const bj="_controlBar_14416_1",yj="_popoverAnchor_14416_11",_j="_confirmationPopover_14416_15",xj="_confirmationPopoverAlignRight_14416_30",Sj="_confirmationPopoverAlignCenter_14416_33",Tj="_confirmationMessage_14416_53",kj="_confirmationActions_14416_60",wj="_confirmationButton_14416_65",Cj="_confirmationButtonCancel_14416_83",Ej="_confirmationButtonNeutral_14416_91",Rj="_confirmationButtonDanger_14416_99",Aj="_controlButton_14416_108",Oj="_controlButtonIconOnly_14416_130",Nj="_controlButtonDisabled_14416_135",Mj="_controlButtonDanger_14416_162",Dj="_controlButtonContent_14416_178",Lj="_controlButtonIcon_14416_130",Pj="_controlButtonLabel_14416_194",Ij="_controlButtonChevron_14416_201",Bj="_controlButtonNotificationDot_14416_210",Uj="_deviceSplitButton_14416_222",jj="_deviceSplitButtonEnabled_14416_226",zj="_dualButtonContent_14416_307",qj="_dualButtonIcon_14416_317",Fj="_dualButtonLabel_14416_326",Hj="_screenShareButton_14416_340",Vj="_screenShareButtonCompact_14416_351",Le={controlBar:bj,popoverAnchor:yj,confirmationPopover:_j,confirmationPopoverAlignRight:xj,confirmationPopoverAlignCenter:Sj,confirmationMessage:Tj,confirmationActions:kj,confirmationButton:wj,confirmationButtonCancel:Cj,confirmationButtonNeutral:Ej,confirmationButtonDanger:Rj,controlButton:Aj,controlButtonIconOnly:Oj,controlButtonDisabled:Nj,controlButtonDanger:Mj,controlButtonContent:Dj,controlButtonIcon:Lj,controlButtonLabel:Pj,controlButtonChevron:Ij,controlButtonNotificationDot:Bj,deviceSplitButton:Uj,deviceSplitButtonEnabled:jj,dualButtonContent:zj,dualButtonIcon:qj,dualButtonLabel:Fj,screenShareButton:Hj,screenShareButtonCompact:Vj},Gj="_inline_1gpyx_1",Yj="_vertical_1gpyx_6",Wj="_divider_1gpyx_10",Kj="_dividerVertical_1gpyx_16",Xj="_customDivider_1gpyx_21",iu={inline:Gj,vertical:Yj,divider:Wj,dividerVertical:Kj,customDivider:Xj},PE={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 er(t){if(t!==void 0){if(typeof t=="number")return`${t}px`;if(t in PE)return PE[t];if(typeof t=="string"&&t.trim().length>0)return t}}function Qj(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,f=n??"div",y={display:"flex",flexDirection:i==="horizontal"?"row":"column",flexWrap:s?"wrap":"nowrap",alignItems:a,...o?{justifyContent:o}:{},...u};if(r!==void 0){const g=er(r);g&&(y.gap=g)}const v=Vn.Children.toArray(d).filter(g=>g!=null&&typeof g!="boolean"),T=g=>!l||g===0?null:l===!0||l==="line"?x.jsx("span",{"aria-hidden":"true",className:re(iu.divider,i==="vertical"&&iu.dividerVertical)},`inline-divider-${g}`):x.jsx("span",{"aria-hidden":"true",className:iu.customDivider,children:l},`inline-divider-${g}`),m=[];return v.forEach((g,_)=>{if(_>0){const p=T(_);p&&m.push(p)}m.push(g)}),x.jsx(f,{ref:e,className:re(iu.inline,i==="vertical"&&iu.vertical,c),style:y,...h,children:m})}const gb=Vn.forwardRef(Qj);gb.displayName="Inline";function Jj(){const[t,e]=A.useState(()=>typeof window>"u"?!1:window.innerWidth<768);return A.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 vb(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,f=re(Le.controlButton,a&&Le.controlButtonDisabled,l&&Le.controlButtonIconOnly,r==="danger"&&Le.controlButtonDanger,o),y=Number.parseInt(Kv[s],10),v=r==="danger"?"outline":"primary",T=r==="danger"?"danger":"default",m=x.jsxs(x.Fragment,{children:[x.jsxs("span",{className:Le.controlButtonContent,children:[e?x.jsx("span",{className:Le.controlButtonIcon,children:Vn.isValidElement(e)&&e.props.size===void 0?Vn.cloneElement(e,{size:y}):e}):null,l?null:x.jsx("span",{className:Le.controlButtonLabel,children:n}),l||!i?null:x.jsx("span",{className:Le.controlButtonChevron,"aria-hidden":"true",children:x.jsx(Xv,{size:16})})]}),c?x.jsx("span",{className:Le.controlButtonNotificationDot,"aria-hidden":"true"}):null]});return typeof u=="boolean"?x.jsx(Of,{...h,type:"button",disabled:a,variant:v,color:T,isOn:u,"aria-label":d||n,className:f,"data-has-notification":c?"true":void 0,children:m}):x.jsx(ol,{...h,type:"button",disabled:a,variant:v,color:T,"aria-label":d||n,className:f,"data-has-notification":c?"true":void 0,children:m})}function Zj(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:f,showChatNotification:y=!1,isLanguageSelectorEnabled:v=!0,languages:T=[],selectedLanguage:m=null,defaultLanguageCode:g=null,isMultilingual:_=!1,onLanguageChange:p,isChatOpen:S=a==="chat"}=t,k=T.length,w=v&&_&&k>0,E=Jj(),R=E?"xs":"sm",O=E,[D,q]=A.useState(!1),[Y,se]=A.useState(!1),H=A.useRef(null),P=A.useRef(null);A.useEffect(()=>{const B=me=>{const yn=me.composedPath();D&&H.current&&!yn.includes(H.current)&&q(!1),Y&&P.current&&!yn.includes(P.current)&&se(!1)},le=me=>{me.key==="Escape"&&(D&&q(!1),Y&&se(!1))};if(D||Y)return document.addEventListener("mousedown",B),document.addEventListener("keydown",le),()=>{document.removeEventListener("mousedown",B),document.removeEventListener("keydown",le)}},[D,Y]),A.useEffect(()=>{r||q(!1)},[r]);const W=A.useMemo(()=>e.map(B=>({label:B.label||`Microphone ${B.deviceId.slice(0,8)}`,value:B.deviceId})),[e]),X=A.useMemo(()=>n?W.find(B=>B.value===n)??null:null,[n,W]),ne=A.useCallback(B=>{B.value,c(B.value)},[c]),K={microphone:!0,screenShare:s,chat:o},ee=A.useCallback(()=>{if(r){q(!0);return}f()},[r,f]),J=A.useCallback(()=>{q(!1),f()},[f]),V=A.useCallback(()=>{q(!1)},[]),ae=A.useCallback(()=>{se(!0)},[]),j=A.useCallback(()=>{se(!1),h()},[h]),ve=A.useCallback(()=>{se(!1)},[]);return x.jsx("div",{className:Le.controlBar,"data-testid":"control-bar","data-controls":JSON.stringify(K),"data-language-option-count":k>0?String(k):void 0,"data-default-language-code":g??void 0,children:x.jsxs(gb,{gap:R,align:"center",justify:"center",wrap:O,children:[x.jsx(UU,{onClick:u,buttonAriaLabel:i?"Mute microphone":"Unmute microphone",options:W,value:X,onChange:ne,variant:"primary",menuPlacement:"top",menuDisabled:W.length===0,menuAriaLabel:"Select microphone device",listboxAriaLabel:"Microphone devices",ariaPressed:i,className:re(Le.deviceSplitButton,i&&Le.deviceSplitButtonEnabled),children:x.jsxs("span",{className:Le.dualButtonContent,children:[x.jsx("span",{className:Le.dualButtonIcon,children:i?x.jsx(G2,{}):x.jsx(Y2,{})}),x.jsx("span",{className:Le.dualButtonLabel,children:"Microphone"})]})}),o?x.jsx(vb,{icon:x.jsx(F2,{}),label:"Chat",onClick:d,isOn:S,"aria-label":"Toggle chat",showNotificationDot:y}):null,s?x.jsxs("div",{ref:H,className:Le.popoverAnchor,children:[x.jsx(vb,{icon:x.jsx(W2,{}),label:r?"Share screen off":"Share screen",className:l==="compact"?Le.screenShareButtonCompact:Le.screenShareButton,iconOnly:l==="compact",onClick:ee,isOn:r,"aria-label":r?"Stop screen sharing":"Start screen sharing"}),D?x.jsxs("div",{className:re(Le.confirmationPopover,Le.confirmationPopoverAlignCenter),role:"dialog","aria-label":"Stop screen sharing confirmation","data-testid":"confirm-stop-share",children:[x.jsx("p",{className:Le.confirmationMessage,children:"Stop screen sharing?"}),x.jsxs("div",{className:Le.confirmationActions,children:[x.jsx("button",{type:"button",className:re(Le.confirmationButton,Le.confirmationButtonCancel),onClick:V,children:"Cancel"}),x.jsx("button",{type:"button",className:re(Le.confirmationButton,Le.confirmationButtonNeutral),onClick:J,children:"Stop"})]})]}):null]}):null,w?x.jsx(tE,{languages:T,value:m,onChange:p,defaultLanguageCode:g,variant:"control-bar"}):null,x.jsxs("div",{ref:P,className:Le.popoverAnchor,children:[x.jsx(vb,{icon:x.jsx(V2,{}),label:"Leave",variant:"danger",onClick:ae,"aria-label":"Leave meeting"}),Y?x.jsxs("div",{className:re(Le.confirmationPopover,Le.confirmationPopoverAlignRight),role:"dialog","aria-label":"Leave meeting confirmation","data-testid":"confirm-leave",children:[x.jsx("p",{className:Le.confirmationMessage,children:"Would you like to end the call?"}),x.jsxs("div",{className:Le.confirmationActions,children:[x.jsx("button",{type:"button",className:re(Le.confirmationButton,Le.confirmationButtonCancel),onClick:ve,children:"Cancel"}),x.jsx("button",{type:"button",className:re(Le.confirmationButton,Le.confirmationButtonDanger),onClick:j,children:"Leave"})]})]}):null]})]})})}function $j(t){return x.jsx(Zj,{...t})}const ez="_controlBar_75i8h_1",tz="_controlButton_75i8h_12",nz="_controlButtonDisabled_75i8h_35",iz="_controlButtonDanger_75i8h_62",rz="_controlButtonIconOnly_75i8h_78",az="_screenShareButton_75i8h_83",oz="_controlButtonContent_75i8h_88",sz="_controlButtonIcon_75i8h_78",lz="_controlButtonLabel_75i8h_103",cz="_controlButtonNotificationDot_75i8h_108",uz="_popoverAnchor_75i8h_198",dz="_confirmationPopover_75i8h_202",hz="_confirmationMessage_75i8h_216",fz="_confirmationActions_75i8h_223",pz="_confirmationButton_75i8h_228",mz="_confirmationButtonCancel_75i8h_246",gz="_confirmationButtonDanger_75i8h_254",nn={controlBar:ez,controlButton:tz,controlButtonDisabled:nz,controlButtonDanger:iz,controlButtonIconOnly:rz,screenShareButton:az,controlButtonContent:oz,controlButtonIcon:sz,controlButtonLabel:lz,controlButtonNotificationDot:cz,popoverAnchor:uz,confirmationPopover:dz,confirmationMessage:hz,confirmationActions:fz,confirmationButton:pz,confirmationButtonCancel:mz,confirmationButtonDanger:gz};function Ff(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=re(nn.controlButton,r&&nn.controlButtonDisabled,o&&nn.controlButtonIconOnly,i==="danger"&&nn.controlButtonDanger,a),h=i==="danger"?"outline":"primary",f=i==="danger"?"danger":"default",y=x.jsxs(x.Fragment,{children:[x.jsxs("span",{className:nn.controlButtonContent,children:[e?x.jsx("span",{className:nn.controlButtonIcon,children:Vn.isValidElement(e)&&e.props.size===void 0?Vn.cloneElement(e,{size:20}):e}):null,o?null:x.jsx("span",{className:nn.controlButtonLabel,children:n})]}),s?x.jsx("span",{className:nn.controlButtonNotificationDot,"aria-hidden":"true"}):null]});return typeof l=="boolean"?x.jsx(Of,{...u,type:"button",disabled:r,variant:h,color:f,size:"xs",isOn:l,"aria-label":c||n,className:d,"data-has-notification":s?"true":void 0,children:y}):x.jsx(ol,{...u,type:"button",disabled:r,variant:h,color:f,size:"xs","aria-label":c||n,className:d,"data-has-notification":s?"true":void 0,children:y})}function vz(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,onLanguageChange:f,isLanguageSelectorEnabled:y=!0,className:v,testId:T,...m}=t,g=!y||!h||c.length===0,[_,p]=A.useState(!1),S=A.useRef(null);A.useEffect(()=>{const D=Y=>{const se=Y.composedPath();_&&S.current&&!se.includes(S.current)&&p(!1)},q=Y=>{Y.key==="Escape"&&_&&p(!1)};if(_)return document.addEventListener("mousedown",D),document.addEventListener("keydown",q),()=>{document.removeEventListener("mousedown",D),document.removeEventListener("keydown",q)}},[_]);const k=A.useCallback(()=>{a()},[a]),w=A.useCallback(()=>{s()},[s]),E=A.useCallback(()=>{p(!0)},[]),R=A.useCallback(()=>{p(!1),l()},[l]),O=A.useCallback(()=>{p(!1)},[]);return x.jsx("div",{...m,className:re(nn.controlBar,v),"data-testid":T,children:x.jsxs(gb,{gap:"xs",align:"center",justify:"center",wrap:!1,children:[x.jsx(Ff,{icon:e?x.jsx(G2,{}):x.jsx(Y2,{}),label:"Microphone",iconOnly:!0,isOn:e,onClick:k,"aria-label":e?"Mute microphone":"Unmute microphone"}),x.jsx(Ff,{icon:x.jsx(F2,{}),label:"Chat",iconOnly:!0,isOn:n,onClick:o,"aria-label":"Toggle chat",showNotificationDot:r}),x.jsx(Ff,{icon:x.jsx(W2,{}),label:"Screen share",iconOnly:!0,className:nn.screenShareButton,isOn:i,onClick:w,"aria-label":i?"Stop screen sharing":"Start screen sharing"}),x.jsx(tE,{languages:c,value:u,onChange:f,defaultLanguageCode:d,variant:"pip",disabled:g}),x.jsxs("div",{ref:S,className:nn.popoverAnchor,children:[x.jsx(Ff,{icon:x.jsx(V2,{}),label:"Hang up",iconOnly:!0,variant:"danger",onClick:E,"aria-label":"Hang up"}),_?x.jsxs("div",{className:nn.confirmationPopover,role:"dialog","aria-label":"Hang up confirmation","data-testid":"confirm-leave",children:[x.jsx("p",{className:nn.confirmationMessage,children:"Would you like to end the call?"}),x.jsxs("div",{className:nn.confirmationActions,children:[x.jsx("button",{type:"button",className:re(nn.confirmationButton,nn.confirmationButtonCancel),onClick:O,children:"Cancel"}),x.jsx("button",{type:"button",className:re(nn.confirmationButton,nn.confirmationButtonDanger),onClick:R,children:"Leave"})]})]}):null]})]})})}function bz(t){return x.jsx(vz,{...t})}const yz="_container_zht0b_1",_z="_containerGradient_zht0b_14",xz="_containerFlat_zht0b_24",Sz="_halo_zht0b_28",Tz="_outerRing_zht0b_38",kz="_circle_zht0b_42",wz="_image_zht0b_72",Cz="_captionContainer_zht0b_88",Ez="_captionRegion_zht0b_99",oa={container:yz,containerGradient:_z,containerFlat:xz,halo:Sz,outerRing:Tz,circle:kz,image:wz,captionContainer:Cz,captionRegion:Ez},Rz="_statusText_1dkze_6",Az={statusText:Rz},Oz={idle:null,thinking:"Thinking...",searching:"Searching..."};function Nz(t){const{status:e,size:n="md"}=t,i=e?Oz[e]:null,r=i!==null;return x.jsx("div",{className:Az.statusText,"data-visible":r,"data-size":n,"aria-live":"polite",children:i})}const Mz="https://obi-static.s3.ap-southeast-2.amazonaws.com/images/obi-avatar.png",Dz={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 IE(t){const{audioPower:e,size:n="md",background:i="gradient",imageSrc:r=Mz,accentColor:a,ariaLabel:o="Avatar placeholder",status:s,captionsText:l,className:c,style:u,...d}=t,h=Dz[n],f=Math.min(1,Math.max(0,e)),y=f>.01,v=y?Math.min(1,f/.5):0,T=y?Math.max(1,v*h.maxBorderWidth):0,m=1.02,g=y?m+f*h.outerRingScalePower:m,_=y?.2+f*.35:0,p={...u??{},...a?{"--avatar-fallback-accent":a}:{}},S={"--avatar-fallback-halo-size":h.haloSize,"--avatar-fallback-border-width":`${T}px`,"--avatar-fallback-secondary-border-scale":g.toString(),"--avatar-fallback-secondary-border-opacity":_.toString(),"--avatar-fallback-glow-size":h.glowSize},k=l!=null&&l!=="";return x.jsxs("div",{...d,className:re(oa.container,i==="gradient"?oa.containerGradient:oa.containerFlat,c),style:p,"data-testid":"avatar-fallback","aria-label":o,role:"img",children:[x.jsxs("div",{className:oa.halo,style:S,children:[x.jsx("div",{className:oa.outerRing,"aria-hidden":"true"}),x.jsx("div",{className:oa.circle,children:x.jsx("img",{className:oa.image,src:r,alt:"","aria-hidden":"true"})}),x.jsx(Nz,{status:s,size:n})]}),k&&x.jsx("div",{className:oa.captionContainer,children:x.jsx("div",{className:oa.captionRegion,"data-size":n,role:"status","aria-live":"polite","aria-atomic":"true",children:l})})]})}const Lz="_container_1k3qg_11",Pz="_screenshot_1k3qg_20",Iz="_flash_1k3qg_30",bb={container:Lz,screenshot:Pz,flash:Iz};function Bz(t){const{isActive:e,imageUrl:n,onComplete:i,duration:r=2e3}=t,[a,o]=A.useState(!1),s=A.useRef(null);return A.useEffect(()=>{if(!e){o(!1),s.current&&(clearTimeout(s.current),s.current=null);return}if(!s.current)return o(!0),s.current=setTimeout(()=>{o(!1),s.current=null,i==null||i()},r),()=>{s.current&&(clearTimeout(s.current),s.current=null)}},[e,r,i]),a?x.jsxs("div",{className:bb.container,"aria-live":"polite","aria-label":"Screenshot captured",children:[n&&x.jsx("img",{src:n,alt:"Captured screenshot",className:bb.screenshot}),x.jsx("div",{className:bb.flash})]}):null}const Uz="_container_13ukq_1",jz="_dragging_13ukq_5",zz="_placeholder_13ukq_9",qz="_handleButton_13ukq_15",Fz="_customHandle_13ukq_105",cl={container:Uz,dragging:jz,placeholder:zz,handleButton:qz,"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:Fz};function Hz(t){const{disabled:e,lingerMs:n,isDragging:i}=t,[r,a]=A.useState(!1),o=A.useRef(null),s=A.useCallback(()=>{o.current!==null&&(window.clearTimeout(o.current),o.current=null)},[]),l=A.useCallback(()=>{e||(s(),a(!0))},[s,e]),c=A.useCallback(()=>{e||i||(s(),o.current=window.setTimeout(()=>{a(!1),o.current=null},n))},[s,e,i,n]);return A.useEffect(()=>{i&&l()},[i,l]),A.useEffect(()=>s,[s]),{isHandleVisible:r,showHandle:l,scheduleHideHandle:c}}function Vz(t){const{initialPosition:e,preserveSpace:n,onPositionChange:i}=t,r=A.useRef(null),[a,o]=A.useState(!!e),[s,l]=A.useState(!1),[c,u]=A.useState(null),[d,h]=A.useState(()=>e??{x:0,y:0}),f=A.useRef(d);s||(f.current=d);const y=A.useRef(null),v=A.useRef(!1),T=A.useRef(!1);A.useEffect(()=>{e&&(T.current||(o(!0),h(e),f.current=e))},[e==null?void 0:e.x,e==null?void 0:e.y]),A.useEffect(()=>{if(e||v.current)return;const p=r.current;if(!p)return;const S=p.getBoundingClientRect(),k={x:S.left,y:S.top};v.current=!0,o(!0),h(k),f.current=k,u(n?{width:S.width,height:S.height}:null)},[e,n]);const m=A.useCallback(p=>{const S=y.current;if(!(!S||p.pointerId!==S.pointerId)){y.current=null,T.current=!0,h(f.current),l(!1);try{p.currentTarget.releasePointerCapture(S.pointerId)}catch{}}},[]),g=A.useCallback(p=>{p.button===0&&(p.preventDefault(),p.currentTarget.setPointerCapture(p.pointerId),y.current={pointerId:p.pointerId,startClientX:p.clientX,startClientY:p.clientY,startX:f.current.x,startY:f.current.y},l(!0))},[]),_=A.useCallback(p=>{const S=y.current;if(!S||p.pointerId!==S.pointerId)return;const k={x:S.startX+(p.clientX-S.startClientX),y:S.startY+(p.clientY-S.startClientY)};f.current=k,r.current&&(r.current.style.transform=`translate3d(${k.x}px, ${k.y}px, 0)`),i==null||i(k)},[i]);return{containerRef:r,isFixed:a,isDragging:s,position:d,placeholderSize:c,onPointerDown:g,onPointerMove:_,endDrag:m}}function Gz(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:f,isFixed:y,isDragging:v,position:T,placeholderSize:m,onPointerDown:g,onPointerMove:_,endDrag:p}=Vz({initialPosition:r,preserveSpace:o,onPositionChange:l}),{isHandleVisible:S,showHandle:k,scheduleHideHandle:w}=Hz({disabled:a,lingerMs:u,isDragging:v}),E=typeof e=="function",R=A.useMemo(()=>{const D=q=>x.jsx("div",{className:re(cl.customHandle,q.className),onPointerDown:g,onPointerMove:_,onPointerUp:p,onPointerCancel:p,children:q.children});return D.displayName="Draggable.Handle",D},[g,_,p]),O={...d,position:y?"fixed":"relative",top:y?0:d==null?void 0:d.top,left:y?0:d==null?void 0:d.left,transform:y?`translate3d(${T.x}px, ${T.y}px, 0)`:d==null?void 0:d.transform,zIndex:y?s:d==null?void 0:d.zIndex};return x.jsxs(x.Fragment,{children:[o&&y&&m?x.jsx("div",{className:cl.placeholder,style:{width:m.width,height:m.height}}):null,x.jsxs("div",{ref:f,className:re(cl.container,v?cl.dragging:null,n),"data-handle-visible":E?void 0:a?"false":S||v?"true":"false",style:O,onMouseEnter:E?void 0:k,onMouseLeave:E?void 0:w,...h,children:[!E&&!a?x.jsx("button",{type:"button",className:re(cl.handleButton,cl[`handle-${i}`]),"aria-label":c,onMouseEnter:k,onMouseLeave:w,onPointerDown:D=>{k(),g(D)},onPointerMove:_,onPointerUp:p,onPointerCancel:p}):null,E?e({Handle:R}):e]})]})}const Yz="_container_1u25n_1",Wz="_captionRegion_1u25n_14",Kz="_status_1u25n_22",Xz="_captionText_1u25n_29",Hf={container:Yz,captionRegion:Wz,status:Kz,captionText:Xz},Qz={idle:null,thinking:"Thinking...",searching:"Searching..."};function Jz(t){const{text:e,status:n,className:i,...r}=t,a=n?Qz[n]:null;return x.jsx("div",{...r,className:re(Hf.container,i),"data-testid":"pip-captions-panel",children:x.jsxs("div",{className:Hf.captionRegion,role:"status","aria-live":"polite","aria-atomic":"true",children:[a?x.jsx("div",{className:Hf.status,children:a}):null,x.jsx("div",{className:Hf.captionText,children:e})]})})}const Zz="_panel_1npcg_1",$z="_row_1npcg_20",eq="_stepContent_1npcg_26",tq="_stepLabel_1npcg_35",nq="_currentStep_1npcg_42",iq="_nextStep_1npcg_49",rq="_skipRow_1npcg_63",aq="_circleButton_1npcg_68",oq="_arrowPlaceholder_1npcg_93",sq="_skipButton_1npcg_99",Mi={panel:Zz,row:$z,stepContent:eq,stepLabel:tq,currentStep:nq,nextStep:iq,skipRow:rq,circleButton:aq,arrowPlaceholder:oq,skipButton:sq};function lq(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 BE(t,e){return e<=0||typeof t!="number"||!Number.isFinite(t)?0:Math.min(Math.max(Math.trunc(t),1),e)-1}function cq(t){var k;const{steps:e,currentStep:n,onStepClick:i,hideTrailingConclusionStep:r=!0,className:a,testId:o,...s}=t,{visibleSteps:l,currentIndex:c}=A.useMemo(()=>lq(e,n,r),[n,r,e]),[u,d]=A.useState(()=>BE(n,l.length));A.useEffect(()=>{d(BE(n,l.length))},[n,l]);const h=l.length,f=l[u],y=u>0,v=u<h-1,T=v?(k=l[u+1])==null?void 0:k.title:void 0,m=h===0?0:u+1,g=c!==null&&f&&u!==c,_=()=>{y&&d(w=>Math.max(w-1,0))},p=()=>{v&&d(w=>Math.min(w+1,h-1))},S=()=>{!g||!f||!i||i(u,f)};return x.jsxs("div",{...s,className:re(Mi.panel,a),"data-testid":o,role:"group","aria-label":"Course progress",children:[x.jsxs("div",{className:Mi.row,children:[y?x.jsx("button",{type:"button",className:Mi.circleButton,"aria-label":"Previous step",onClick:_,children:x.jsx(aB,{size:14})}):x.jsx("span",{className:Mi.arrowPlaceholder,"aria-hidden":"true"}),x.jsxs("div",{className:Mi.stepContent,children:[x.jsxs(Zn,{className:Mi.stepLabel,"aria-live":"polite",children:["Step ",m,"/",h]}),x.jsx(Zn,{className:Mi.currentStep,"data-testid":"pip-outline-current-step",children:(f==null?void 0:f.title)??"No steps available"}),T?x.jsxs(Zn,{variant:"muted",className:Mi.nextStep,children:["Next: ",T]}):null]}),v?x.jsx("button",{type:"button",className:Mi.circleButton,"aria-label":"Next step",onClick:p,children:x.jsx(oB,{size:14})}):x.jsx("span",{className:Mi.arrowPlaceholder,"aria-hidden":"true"})]}),g?x.jsx("div",{className:Mi.skipRow,children:x.jsx("button",{type:"button",className:Mi.skipButton,"aria-label":"Skip to this step",onClick:S,children:x.jsx(uB,{size:14})})}):null]})}const uq="_window_1q008_1",dq="_exitButton_1q008_13",hq="_content_1q008_43",fq="_contentTopOverlay_1q008_53",pq="_contentTopOverlaySlot_1q008_67",mq="_dragHandle_1q008_77",gq="_contentBottomOverlay_1q008_82",vq="_controls_1q008_91",ro={window:uq,exitButton:dq,content:hq,contentTopOverlay:fq,contentTopOverlaySlot:pq,dragHandle:mq,contentBottomOverlay:gq,controls:vq};function bq(t){return t==null?!1:typeof t=="string"?t.trim().length>0:!0}function yq(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:f,testId:y,...v}=t,T=i,m=n.isChatOpen&&!T&&l,g=c==null?void 0:c.captionsText,_=a&&bq(g),[p,S]=A.useState(!1);A.useEffect(()=>{h&&h>0&&S(!0)},[h]);const k=A.useCallback(()=>x.jsx(IE,{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]),w=T?s?x.jsx(cq,{steps:s.steps,currentStep:s.currentStep,onStepClick:s.onStepClick,hideTrailingConclusionStep:s.hideTrailingConclusionStep}):k():m?l:_?x.jsx(Jz,{text:g}):k();return x.jsxs("div",{...v,className:re(ro.window,f),"data-testid":y,role:"group","aria-label":"Picture-in-Picture",children:[x.jsxs("div",{className:ro.content,children:[x.jsxs("div",{className:ro.contentTopOverlay,children:[u?x.jsx("div",{className:ro.contentTopOverlaySlot,children:u}):null,x.jsx("button",{type:"button",className:ro.exitButton,onClick:e,"aria-label":"Exit PiP",children:x.jsx(sB,{size:14})})]}),w,!m&&x.jsxs("div",{className:ro.contentBottomOverlay,children:[x.jsx(Of,{isOn:i,onClick:r,variant:"primary",size:"xs","aria-label":"Toggle course outline",children:x.jsx(dB,{size:18})}),x.jsx(Of,{isOn:a,onClick:o,variant:"primary",size:"xs","aria-label":"Toggle captions",children:x.jsx(rB,{size:18})})]}),x.jsx(Bz,{isActive:p,imageUrl:d??null,onComplete:()=>S(!1)})]}),x.jsx("div",{className:ro.controls,children:x.jsx(bz,{...n})})]})}function _q(t){const{initialPosition:e,onPositionChange:n,zIndex:i=1e3,...r}=t;return x.jsx(Gz,{initialPosition:e,onPositionChange:n,zIndex:i,preserveSpace:!1,children:({Handle:a})=>x.jsx(yq,{...r,contentTopOverlaySlot:x.jsx(a,{className:ro.dragHandle})})})}const xq="_root_ygi3o_1",Sq="_overlay_ygi3o_7",Tq="_caption_ygi3o_17",yb={root:xq,overlay:Sq,caption:Tq};function kq(t){return t==null?!1:typeof t=="string"?t.trim().length>0:!0}function wq(t){const{children:e,className:n,text:i}=t,r=kq(i);return x.jsxs("div",{className:re(yb.root,n),children:[e,r?x.jsx("div",{className:yb.overlay,role:"status","aria-live":"polite","aria-atomic":"true",children:x.jsx("div",{className:yb.caption,children:i})}):null]})}const Cq="_box_1r6by_1",Eq={box:Cq},UE={none:"0px",panel:"var(--radius-panel)",card:"var(--radius-card)"},jE={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 Rq(t){if(t!==void 0){if(typeof t=="number")return`${t}px`;if(t in UE)return UE[t];if(typeof t=="string"&&t.trim().length>0)return t}}function Aq(t){if(t!==void 0){if(t in jE)return jE[t];if(typeof t=="string"&&t.trim().length>0)return t}}function Oq(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:f,paddingXl:y,margin:v,marginX:T,marginY:m,marginTop:g,marginBottom:_,marginLeft:p,marginRight:S,radius:k,radiusTop:w,radiusBottom:E,radiusLeft:R,radiusRight:O,radiusTopLeft:D,radiusTopRight:q,radiusBottomLeft:Y,radiusBottomRight:se,background:H,gap:P,style:W,...X}=t,ne=n??"div",K={...W},ee=K,J={},V=(B,le)=>{if(le===void 0)return;const me=er(le);me&&(K[B]=me)},ae=(B,le)=>{if(le===void 0)return;const me=er(le);me&&(K[B]=me)},j=(B,le)=>{if(le===void 0)return;const me=Rq(le);me&&(K[B]=me)},ve={sm:d,md:h,lg:f,xl:y};if(r!==void 0){const B=er(r);B&&(ee["--box-padding"]=B)}for(const[B,le]of Object.entries(ve)){if(le===void 0)continue;const me=er(le);me&&(ee[`--box-padding-${B}`]=me,J[`data-padding-${B}`]="")}if(a!==void 0){const B=er(a);B&&(K.paddingLeft=B,K.paddingRight=B)}if(o!==void 0){const B=er(o);B&&(K.paddingTop=B,K.paddingBottom=B)}if(V("paddingTop",s),V("paddingBottom",l),V("paddingLeft",c),V("paddingRight",u),v!==void 0){const B=er(v);B&&(K.margin=B)}if(T!==void 0){const B=er(T);B&&(K.marginLeft=B,K.marginRight=B)}if(m!==void 0){const B=er(m);B&&(K.marginTop=B,K.marginBottom=B)}if(ae("marginTop",g),ae("marginBottom",_),ae("marginLeft",p),ae("marginRight",S),P!==void 0){const B=er(P);B&&(K.gap=B)}if(j("borderRadius",k),w!==void 0&&(j("borderTopLeftRadius",w),j("borderTopRightRadius",w)),E!==void 0&&(j("borderBottomLeftRadius",E),j("borderBottomRightRadius",E)),R!==void 0&&(j("borderTopLeftRadius",R),j("borderBottomLeftRadius",R)),O!==void 0&&(j("borderTopRightRadius",O),j("borderBottomRightRadius",O)),j("borderTopLeftRadius",D),j("borderTopRightRadius",q),j("borderBottomLeftRadius",Y),j("borderBottomRightRadius",se),H!==void 0){const B=Aq(H);B&&(K.background=B)}return x.jsx(ne,{ref:e,className:re(Eq.box,i),style:K,...J,...X})}const Vf=Vn.forwardRef(Oq);Vf.displayName="Box";const Nq="_panel_eawk4_1",Mq="_selected_eawk4_10",zE={panel:Nq,selected:Mq};function ru(t){const{children:e,className:n,selected:i,...r}=t;return x.jsx("div",{className:re(zE.panel,i?zE.selected:null,n),...r,children:e})}const Dq="_root_yccm8_1",Lq="_header_yccm8_8",Pq="_icon_yccm8_15",Iq="_text_yccm8_26",Bq="_heading_yccm8_33",Uq="_description_yccm8_41",jq="_body_yccm8_47",zq="_footer_yccm8_54",ao={root:Dq,header:Lq,icon:Pq,text:Iq,heading:Bq,description:Uq,body:jq,footer:zq};function qE(t){const{className:e,...n}=t;return x.jsx("div",{className:re(ao.icon,e),...n})}function FE(t){const{className:e,...n}=t;return x.jsx("h3",{className:re(ao.heading,e),...n})}function HE(t){const{className:e,...n}=t;return x.jsx("p",{className:re(ao.description,e),...n})}function VE(t){const{className:e,...n}=t;return x.jsx("div",{className:re(ao.footer,e),...n})}function qq(t){const e=A.Children.toArray(t),n=[];let i,r,a,o;for(const s of e){if(A.isValidElement(s)&&s.type===qE&&i===void 0){i=s;continue}if(A.isValidElement(s)&&s.type===FE&&r===void 0){r=s;continue}if(A.isValidElement(s)&&s.type===HE&&a===void 0){a=s;continue}if(A.isValidElement(s)&&s.type===VE&&o===void 0){o=s;continue}n.push(s)}return{icon:i,heading:r,description:a,footer:o,body:n}}function Fq(t){const{children:e,className:n,...i}=t,r=qq(e),a=r.icon||r.heading||r.description;return x.jsxs(ru,{className:re(ao.root,n),...i,children:[a?x.jsxs("div",{className:ao.header,children:[r.icon,r.heading||r.description?x.jsxs("div",{className:ao.text,children:[r.heading,r.description]}):null]}):null,r.body.length?x.jsx("div",{className:ao.body,children:r.body}):null,r.footer]})}const _b=Object.assign(Fq,{Icon:qE,Heading:FE,Description:HE,Footer:VE}),Hq="_panel_1uwhd_1",Vq="_header_1uwhd_11",Gq="_title_1uwhd_19",Yq="_scrollArea_1uwhd_29",Wq="_scrollable_1uwhd_34",Kq="_list_1uwhd_38",Xq="_courseButton_1uwhd_44",Qq="_courseCard_1uwhd_55",Jq="_courseHeading_1uwhd_64",Zq="_courseDescription_1uwhd_70",$q="_empty_1uwhd_79",tr={panel:Hq,header:Vq,title:Gq,scrollArea:Yq,scrollable:Wq,list:Kq,courseButton:Xq,courseCard:Qq,courseHeading:Jq,courseDescription:Zq,empty:$q};function eF(t){const{selectionMode:e,selectedCourseIds:n,defaultSelectedCourseIds:i,onSelectedCourseIdsChange:r}=t,a=n!==void 0,[o,s]=A.useState(()=>i??[]),l=a?n:o,c=A.useCallback(d=>{a||s(d),r==null||r(d)},[a,r]),u=A.useCallback(d=>{const h=l.includes(d);if(e==="single"){c(h?[]:[d]);return}if(h){c(l.filter(f=>f!==d));return}c([...l,d])},[l,e,c]);return{selectedCourseIds:l,toggleCourseId:u}}function tF(t){const{title:e="Courses",ariaLabel:n,className:i,courses:r,selectionMode:a="multiple",selectedCourseIds:o,onCourseToggle:s,emptyMessage:l="No courses available",testId:c,...u}=t;return x.jsxs(ru,{...u,className:re(tr.panel,i),role:"region","aria-label":n??e,"data-testid":c,children:[x.jsx("div",{className:tr.header,children:x.jsx(Zn,{as:"h2",className:tr.title,children:e})}),x.jsx("div",{className:tr.scrollArea,children:x.jsx(sl,{className:tr.scrollable,children:r.length===0?x.jsx(Zn,{variant:"muted",className:tr.empty,"data-testid":"course-panel-empty",children:l}):x.jsx("div",{className:tr.list,"data-testid":"course-panel-list",children:r.map(d=>{const h=o.includes(d.id),f=d.disabled===!0;return x.jsx("button",{type:"button",className:tr.courseButton,"aria-pressed":h,"aria-disabled":f,disabled:f,onClick:()=>s==null?void 0:s(d.id,d),"data-testid":`course-panel-item-${d.id}`,children:x.jsxs(_b,{selected:h,className:tr.courseCard,children:[x.jsx(_b.Heading,{className:tr.courseHeading,children:d.title}),d.description?x.jsx(_b.Description,{className:tr.courseDescription,children:d.description}):null]})},d.id)})})})})]})}function nF(t){const{selectionMode:e="multiple",selectedCourseIds:n,defaultSelectedCourseIds:i,onSelectedCourseIdsChange:r,onCourseToggle:a,...o}=t,{selectedCourseIds:s,toggleCourseId:l}=eF({selectionMode:e,selectedCourseIds:n,defaultSelectedCourseIds:i,onSelectedCourseIdsChange:r}),c=A.useCallback((u,d)=>{l(u),a==null||a(u,d)},[a,l]);return x.jsx(tF,{...o,selectionMode:e,selectedCourseIds:s,onCourseToggle:c})}const iF="_panel_1on05_1",rF="_header_1on05_11",aF="_divider_1on05_19",oF="_title_1on05_25",sF="_scrollArea_1on05_35",lF="_scrollable_1on05_40",cF="_list_1on05_44",uF="_section_1on05_50",dF="_sectionHeader_1on05_56",hF="_sectionTitle_1on05_60",fF="_sectionTitleCompact_1on05_68",pF="_item_1on05_72",mF="_itemClickable_1on05_86",gF="_itemCompleted_1on05_90",vF="_itemCurrent_1on05_94",bF="_itemFuture_1on05_98",yF="_itemDisabled_1on05_103",_F="_row_1on05_117",xF="_stepHeader_1on05_124",SF="_stepNumber_1on05_133",TF="_stepTitle_1on05_139",kF="_checkIcon_1on05_151",wF="_empty_1on05_155",He={panel:iF,header:rF,divider:aF,title:oF,scrollArea:sF,scrollable:lF,list:cF,section:uF,sectionHeader:dF,sectionTitle:hF,sectionTitleCompact:fF,item:pF,itemClickable:mF,itemCompleted:gF,itemCurrent:vF,itemFuture:bF,itemDisabled:yF,row:_F,stepHeader:xF,stepNumber:SF,stepTitle:TF,checkIcon:kF,empty:wF};function CF(t){var f;const{steps:e,currentStep:n,hideTrailingConclusionStep:i}=t,r=e.length,a=i&&r>0&&((f=e[r-1])==null?void 0:f.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},(y,v)=>v),currentIndex:null,futureIndices:[]};const c=Math.min(Math.max(l,1),s)-1,u=Array.from({length:Math.max(0,c)},(y,v)=>v),d=Math.min(c,s-1),h=Array.from({length:Math.max(0,s-(d+1))},(y,v)=>d+1+v);return{visibleSteps:o,completedIndices:u,currentIndex:d,futureIndices:h}}function EF(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,...d}=t,h=A.useCallback(_=>(_+1).toString().padStart(2,"0"),[]),{visibleSteps:f,completedIndices:y,currentIndex:v,futureIndices:T}=A.useMemo(()=>CF({steps:r,currentStep:a,hideTrailingConclusionStep:s}),[a,s,r]),m=c==="compact"?"md":"lg",g=A.useCallback((_,p)=>{const S=f[_];if(!S)return null;const k=typeof o=="function",w=k&&S.disabled===!0,E=k&&!w,R=re(He.item,{[He.itemClickable]:E,[He.itemCompleted]:p==="completed",[He.itemCurrent]:p==="current",[He.itemFuture]:p==="future",[He.itemDisabled]:w}),O=x.jsxs("div",{className:He.row,children:[x.jsxs("div",{className:He.stepHeader,children:[x.jsx("span",{className:He.stepNumber,children:h(_)}),x.jsx("span",{className:He.stepTitle,children:S.title})]}),p==="completed"?x.jsx(Rf,{size:20,className:He.checkIcon}):null]});return k?x.jsx(Vf,{as:"button",type:"button",className:R,onClick:()=>{E&&o(_,S)},disabled:w,"aria-current":p==="current"?"step":void 0,"aria-label":`Step ${h(_)}: ${S.title}`,"data-testid":`course-outline-item-${S.id}`,padding:m,radius:"panel",gap:"sm",children:O},S.id):x.jsx(Vf,{className:R,"aria-current":p==="current"?"step":void 0,"aria-label":`Step ${h(_)}: ${S.title}`,"data-testid":`course-outline-item-${S.id}`,padding:m,radius:"panel",gap:"sm",children:O},S.id)},[h,m,o,f]);return x.jsxs(ru,{...d,className:re(He.panel,i),role:"region","aria-label":n??e,"data-testid":u,children:[x.jsx("div",{className:He.header,children:x.jsx(Zn,{as:"h2",className:He.title,children:e})}),x.jsx("div",{className:He.divider,"aria-hidden":"true"}),x.jsx("div",{className:He.scrollArea,children:x.jsx(sl,{className:He.scrollable,children:f.length===0?x.jsx(Zn,{variant:"muted",className:He.empty,"data-testid":"course-outline-empty",children:l}):x.jsxs("div",{className:He.list,"data-testid":"course-outline-list",children:[y.length>0?x.jsxs("div",{className:He.section,"data-testid":"course-outline-section-completed",children:[x.jsx("div",{className:He.sectionHeader,children:x.jsx("span",{className:re(He.sectionTitle,c==="compact"?He.sectionTitleCompact:null),children:"Completed"})}),y.map(_=>g(_,"completed"))]}):null,v!==null?x.jsxs("div",{className:He.section,"data-testid":"course-outline-section-current",children:[x.jsx("div",{className:He.sectionHeader,children:x.jsx("span",{className:re(He.sectionTitle,c==="compact"?He.sectionTitleCompact:null),children:"Current"})}),g(v,"current")]}):null,T.length>0?x.jsxs("div",{className:He.section,"data-testid":"course-outline-section-upcoming",children:[x.jsx("div",{className:He.sectionHeader,children:x.jsx("span",{className:re(He.sectionTitle,c==="compact"?He.sectionTitleCompact:null),children:"Upcoming"})}),T.map(_=>g(_,"future"))]}):null]})})})]})}function RF(t){return x.jsx(EF,{...t})}const AF="_panel_8h64k_1",OF="_messagesArea_8h64k_20",NF="_messagesList_8h64k_46",MF="_messageItem_8h64k_53",DF="_messageMetadata_8h64k_59",LF="_senderName_8h64k_67",PF="_timestamp_8h64k_71",IF="_messageBubble_8h64k_75",BF="_agentMessage_8h64k_85",UF="_agentActions_8h64k_89",jF="_copyButton_8h64k_95",zF="_copyButtonCopied_8h64k_129",qF="_empty_8h64k_133",FF="_composer_8h64k_140",HF="_composerDisabled_8h64k_160",VF="_composerInput_8h64k_165",GF="_sendButton_8h64k_180",mn={panel:AF,messagesArea:OF,messagesList:NF,messageItem:MF,messageMetadata:DF,senderName:LF,timestamp:PF,messageBubble:IF,agentMessage:BF,agentActions:UF,copyButton:jF,copyButtonCopied:zF,empty:qF,composer:FF,composerDisabled:HF,composerInput:VF,sendButton:GF};function YF(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 WF(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 KF(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 XF(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 QF(t){const{messages:e,localIdentity:n,onSend:i,isSending:r=!1,inputPlaceholder:a="Type a message...",className:o,testId:s,...l}=t,[c,u]=A.useState(""),[d,h]=A.useState(null),f=A.useRef(null),y=A.useRef(null),v=A.useMemo(()=>{const p=e[e.length-1];return p?p.id??`${p.timestamp}-${e.length-1}`:null},[e]);A.useEffect(()=>{var p,S;(S=(p=f.current)==null?void 0:p.scrollIntoView)==null||S.call(p,{behavior:"smooth"})},[v]),A.useEffect(()=>()=>{y.current&&(window.clearTimeout(y.current),y.current=null)},[]);const T=A.useCallback(async()=>{const p=c.trim();p.length!==0&&(await i(p),u(""))},[c,i]),m=A.useCallback(p=>{p.key==="Enter"&&(p.preventDefault(),T())},[T]),g=A.useCallback(async(p,S)=>{try{await XF(p.message??""),h(S),y.current&&window.clearTimeout(y.current),y.current=window.setTimeout(()=>{h(null),y.current=null},2e3)}catch(k){console.warn("[PiPChatPanel] Failed to copy message",k)}},[]),_=c.trim().length>0&&!r;return x.jsxs("div",{...l,className:re(mn.panel,o),"data-testid":s,role:"region","aria-label":"Chat",children:[x.jsx("div",{className:mn.messagesArea,children:e.length===0?x.jsx("div",{className:mn.empty,"data-testid":"pip-chat-panel-empty",children:"No messages yet"}):x.jsxs("div",{className:mn.messagesList,"data-testid":"pip-chat-panel-list",children:[e.map((p,S)=>{const k=p.id??`${p.timestamp}-${S}`,w=WF(p,n),E=d===k;return x.jsxs("div",{className:re(mn.messageItem,w&&mn.agentMessage),"data-testid":`pip-chat-panel-message-${k}`,children:[x.jsxs("div",{className:mn.messageMetadata,children:[x.jsx("span",{className:mn.senderName,children:KF(p,n)}),x.jsx("span",{className:mn.timestamp,children:YF(p.timestamp)})]}),x.jsx("div",{className:mn.messageBubble,children:p.message}),w?x.jsx("div",{className:mn.agentActions,children:x.jsx("button",{type:"button",className:re(mn.copyButton,E&&mn.copyButtonCopied),onClick:()=>void g(p,k),"aria-label":E?"Copied":"Copy message",title:E?"Copied":"Copy message","data-testid":"pip-copy-agent-message","data-copied":E?"true":"false",children:x.jsx(H2,{size:14})})}):null]},k)}),x.jsx("div",{ref:f})]})}),x.jsxs("div",{className:re(mn.composer,r&&mn.composerDisabled),children:[x.jsx("input",{type:"text",className:mn.composerInput,value:c,onChange:p=>u(p.target.value),onKeyDown:m,placeholder:a,disabled:r,"aria-label":"Message"}),x.jsx("button",{type:"button",className:mn.sendButton,onClick:()=>void T(),disabled:!_,"aria-label":"Send message",children:x.jsx(K2,{size:16})})]})]})}const JF="_panel_q8m25_1",ZF="_header_q8m25_11",$F="_title_q8m25_19",eH="_titleCompact_q8m25_29",tH="_headerActions_q8m25_33",nH="_closeButton_q8m25_39",iH="_divider_q8m25_67",rH="_body_q8m25_73",aH="_messagesArea_q8m25_81",oH="_scrollable_q8m25_86",sH="_messagesList_q8m25_90",lH="_messageItem_q8m25_98",cH="_messageMetadata_q8m25_104",uH="_senderName_q8m25_112",dH="_timestamp_q8m25_116",hH="_messageBubble_q8m25_120",fH="_messageText_q8m25_124",pH="_agentMessage_q8m25_130",mH="_agentActions_q8m25_134",gH="_copyButton_q8m25_140",vH="_copyButtonCopied_q8m25_174",bH="_inputRow_q8m25_178",yH="_empty_q8m25_182",_H="_composer_q8m25_188",xH="_composerDefault_q8m25_203",SH="_composerCompact_q8m25_208",TH="_composerDisabled_q8m25_218",kH="_composerInputWrapper_q8m25_223",wH="_composerInput_q8m25_223",CH="_sendButton_q8m25_240",EH="_sendButtonCompact_q8m25_257",Ve={panel:JF,header:ZF,title:$F,titleCompact:eH,headerActions:tH,closeButton:nH,divider:iH,body:rH,messagesArea:aH,scrollable:oH,messagesList:sH,messageItem:lH,messageMetadata:cH,senderName:uH,timestamp:dH,messageBubble:hH,messageText:fH,agentMessage:pH,agentActions:mH,copyButton:gH,copyButtonCopied:vH,inputRow:bH,empty:yH,composer:_H,composerDefault:xH,composerCompact:SH,composerDisabled:TH,composerInputWrapper:kH,composerInput:wH,sendButton:CH,sendButtonCompact:EH};function RH(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 AH(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 OH(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 NH(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 MH(t){const{disabled:e,placeholder:n,size:i="md",autoFocus:r,onSend:a}=t,[o,s]=A.useState(""),l=A.useCallback(async()=>{const f=o.trim();f.length!==0&&(await a(f),s(""))},[a,o]),c=A.useCallback(f=>{f.key==="Enter"&&(f.preventDefault(),l())},[l]),u=i==="sm"||i==="xs",d=u?18:24,h=o.trim().length>0&&e!==!0;return x.jsxs("div",{className:re(Ve.composer,u?Ve.composerCompact:Ve.composerDefault,e?Ve.composerDisabled:null),children:[x.jsx("div",{className:Ve.composerInputWrapper,children:x.jsx(Q2,{value:o,onChange:s,onKeyDown:c,className:Ve.composerInput,placeholder:n??"Send a message ...",disabled:e,size:i,autoFocus:r,"aria-label":"Message"})}),x.jsx("button",{type:"button",className:re(Ve.sendButton,u?Ve.sendButtonCompact:null),onClick:()=>void l(),disabled:!h,"aria-label":"Send message",children:x.jsx(K2,{size:d})})]})}function GE(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:f=RH,getSenderName:y,isAgentMessage:v,copyResetDelayMs:T=2e3,showAgentCopyButton:m=!0,inputPlaceholder:g,inputAutoFocus:_,...p}=t,S=A.useRef(null),[k,w]=A.useState(null),E=A.useRef(null),R=A.useCallback(H=>y?y(H):OH(H,o),[y,o]),O=A.useCallback(H=>v?v(H,o):AH(H,o),[v,o]),D=A.useMemo(()=>{const H=r[r.length-1];return H?H.id??`${H.timestamp}-${r.length-1}`:null},[r]);A.useEffect(()=>{var H,P;(P=(H=S.current)==null?void 0:H.scrollIntoView)==null||P.call(H,{behavior:"smooth"})},[D]),A.useEffect(()=>()=>{E.current&&(window.clearTimeout(E.current),E.current=null)},[]);const q=A.useCallback(H=>{w(H),E.current&&window.clearTimeout(E.current),E.current=window.setTimeout(()=>{w(null),E.current=null},T)},[T]),Y=A.useCallback(async(H,P)=>{try{await NH(H.message??""),q(P)}catch(W){console.warn("[ChatPanel] Failed to copy message",W)}},[q]),se=d==="compact"?"sm":"md";return x.jsxs(ru,{...p,className:re(Ve.panel,i),role:"region","aria-label":n??e,"data-testid":h,children:[x.jsxs("div",{className:Ve.header,children:[x.jsx(Zn,{as:"h2",className:re(Ve.title,d==="compact"?Ve.titleCompact:null),children:e}),l&&c?x.jsx("div",{className:Ve.headerActions,children:x.jsx("button",{type:"button",className:Ve.closeButton,onClick:l,"aria-label":`Close ${e}`,children:x.jsx(Af,{size:d==="compact"?18:20})})}):null]}),x.jsx("div",{className:Ve.divider,"aria-hidden":"true"}),x.jsxs("div",{className:Ve.body,children:[x.jsx("div",{className:Ve.messagesArea,children:x.jsx(sl,{className:Ve.scrollable,children:r.length===0?x.jsx(Zn,{variant:"muted",className:Ve.empty,"data-testid":"chat-panel-empty",children:u}):x.jsxs("div",{className:Ve.messagesList,"data-testid":"chat-panel-list",children:[r.map((H,P)=>{const W=H.id??`${H.timestamp}-${P}`,X=O(H),ne=k===W;return x.jsxs("div",{className:re(Ve.messageItem,X?Ve.agentMessage:null),"data-testid":`chat-panel-message-${W}`,children:[x.jsxs("div",{className:Ve.messageMetadata,children:[x.jsx("span",{className:Ve.senderName,children:R(H)}),x.jsx("span",{className:Ve.timestamp,children:f(H.timestamp)})]}),x.jsx(Vf,{className:Ve.messageBubble,padding:"md",radius:"panel",background:X?"surfaceMuted":"surface",children:x.jsx("div",{className:Ve.messageText,children:H.message})}),X&&m?x.jsx("div",{className:Ve.agentActions,children:x.jsx("button",{type:"button",className:re(Ve.copyButton,ne?Ve.copyButtonCopied:null),onClick:()=>void Y(H,W),"aria-label":ne?"Copied":"Copy agent message",title:ne?"Copied":"Copy agent message","data-testid":"copy-agent-message","data-copied":ne?"true":"false",children:x.jsx(H2,{size:18})})}):null]},W)}),x.jsx("div",{ref:S})]})})}),x.jsx("div",{className:Ve.inputRow,children:x.jsx(MH,{onSend:s,disabled:a,placeholder:g,size:se,autoFocus:_})})]})]})}A.createContext("vertical");const DH="_container_1a1i6_1",LH="_video_1a1i6_7",PH="_chip_1a1i6_16",IH="_logo_1a1i6_34",Gf={container:DH,video:LH,chip:PH,logo:IH},BH="https://obi-static.s3.ap-southeast-2.amazonaws.com/videos/greeting.mp4";function UH(t){const{agentName:e="Obi",className:n,...i}=t,r=A.useRef(null),a=()=>{var o;try{(o=r.current)==null||o.pause()}catch{}};return x.jsxs("div",{className:re(Gf.container,n),...i,children:[x.jsx("video",{ref:r,className:Gf.video,src:BH,autoPlay:!0,muted:!0,playsInline:!0,onEnded:a}),x.jsxs("div",{className:Gf.chip,children:[x.jsx(lB,{size:14,className:Gf.logo}),x.jsx("span",{children:e})]})]})}typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;const YE=50,ul="?",WE=/\(error: (.*)\)/,KE=/captureMessage|captureException/;function jH(...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(`
121
+ `);for(let s=i;s<o.length;s++){const l=o[s];if(l.length>1024)continue;const c=WE.test(l)?l.replace(WE,"$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>=YE+r)break}}return zH(a.slice(r))}}function zH(t){if(!t.length)return[];const e=Array.from(t);return/sentryWrapped/.test(Yf(e).function||"")&&e.pop(),e.reverse(),KE.test(Yf(e).function||"")&&(e.pop(),KE.test(Yf(e).function||"")&&e.pop()),e.slice(0,YE).map(n=>({...n,filename:n.filename||Yf(e).filename,function:n.function||ul}))}function Yf(t){return t[t.length-1]||{}}typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;const qH=30,FH=50;function xb(t,e,n,i){const r={filename:t,function:e==="<anonymous>"?ul:e,in_app:!0};return n!==void 0&&(r.lineno=n),i!==void 0&&(r.colno=i),r}const HH=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,VH=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,GH=/\((\S*)(?::(\d+))(?::(\d+))\)/,YH=t=>{const e=HH.exec(t);if(e){const[,i,r,a]=e;return xb(i,ul,+r,+a)}const n=VH.exec(t);if(n){if(n[2]&&n[2].indexOf("eval")===0){const a=GH.exec(n[2]);a&&(n[2]=a[1],n[3]=a[2],n[4]=a[3])}const[i,r]=XE(n[1]||ul,n[2]);return xb(r,i,n[3]?+n[3]:void 0,n[4]?+n[4]:void 0)}},WH=[qH,YH],KH=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,XH=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i;jH(...[WH,[FH,t=>{const e=KH.exec(t);if(e){if(e[3]&&e[3].indexOf(" > eval")>-1){const r=XH.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]||ul;return[i,n]=XE(i,n),xb(n,i,e[4]?+e[4]:void 0,e[5]?+e[5]:void 0)}}]]);const XE=(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]:ul,n?`safari-extension:${e}`:`safari-web-extension:${e}`]:[t,e]};typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;const Er={shell:"_shell_3h8q7_1",layout:"_layout_3h8q7_11",layoutThree:"_layoutThree_3h8q7_23",leftPanel:"_leftPanel_3h8q7_27",middlePanel:"_middlePanel_3h8q7_36",rightPanel:"_rightPanel_3h8q7_37",videoFrame:"_videoFrame_3h8q7_41",captions:"_captions_3h8q7_51",controls:"_controls_3h8q7_57",coursePanel:"_coursePanel_3h8q7_70"};function Sb(...t){return t.filter(Boolean).join(" ")}function QH(t){const{captionsText:e,avatarAudioPower:n=0,avatarImageSrc:i,avatarAriaLabel:r,avatarStatus:a,controlBarProps:o,courses:s,coursePanelProps:l,middlePanel:c,rightPanel:u,className:d}=t;return x.jsx("div",{className:Sb(Er.shell,d),"data-testid":"course-dialog-content",children:x.jsxs("div",{className:Sb(Er.layout,u?Er.layoutThree:null),children:[x.jsxs("div",{className:Er.leftPanel,children:[x.jsx("div",{className:Er.videoFrame,children:x.jsx(wq,{className:Er.captions,text:e,children:x.jsx(IE,{audioPower:n,size:"lg",background:"flat",imageSrc:i,ariaLabel:r??"Agent avatar placeholder",status:a})})}),x.jsx("div",{className:Er.controls,children:x.jsx($j,{...o})})]}),x.jsx("div",{className:Er.middlePanel,"data-testid":"course-dialog-middle-panel",children:c??x.jsx(nF,{...l,courses:s,className:Sb(Er.coursePanel,l==null?void 0:l.className)})}),u?x.jsx("div",{className:Er.rightPanel,"data-testid":"course-dialog-right-panel",children:u}):null]})})}function QE(t){const{open:e,onClose:n,dialogProps:i,...r}=t;return x.jsx(rE,{open:e,onClose:n,variant:"ghost",...i,children:x.jsx(QH,{...r})})}const JH=80,ZH=500,$H=1e3;function eV(t,e){const{delayMs:n=0}=e??{},r=t.filter(v=>{var m;const T=(m=v.participantInfo)==null?void 0:m.identity;return(T==null?void 0:T.startsWith("agent-"))??!1}).map(v=>v.text??"").join(" ").trim(),[a,o]=A.useState(""),[s,l]=A.useState(!1),c=A.useRef(""),u=A.useRef(null),d=A.useRef(null),h=A.useRef(null),f=v=>{h.current&&(clearTimeout(h.current),h.current=null),n>0?h.current=setTimeout(()=>{o(v)},n):o(v)},y=(v,T)=>v.startsWith(T)?v.slice(T.length).trim():v.trim();return A.useEffect(()=>{if(d.current&&(clearTimeout(d.current),d.current=null),s)return;const v=y(r,c.current);f(v),v.length>JH?(l(!0),u.current=setTimeout(()=>{l(!1),c.current=r},ZH+n)):v.length>0&&(d.current=setTimeout(()=>{c.current=r,f("")},$H+n))},[r,s,n]),A.useEffect(()=>()=>{u.current&&clearTimeout(u.current),d.current&&clearTimeout(d.current),h.current&&clearTimeout(h.current)},[]),{caption:a,hasCaption:a.length>0}}const nr={layout:"_layout_17ztq_1",left:"_left_17ztq_10",copy:"_copy_17ztq_17",description:"_description_17ztq_25",descriptionScroller:"_descriptionScroller_17ztq_31",cta:"_cta_17ztq_36",disclaimer:"_disclaimer_17ztq_43",right:"_right_17ztq_47",mediaPanel:"_mediaPanel_17ztq_56",agentStill:"_agentStill_17ztq_63",dialogWithSmallClose:"_dialogWithSmallClose_17ztq_87"};function tV(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=!0,isStarting:u=!1}=t;return x.jsx(rE,{open:e,onClose:n,size:"large",showCloseButton:c,className:nr.dialogWithSmallClose,children:x.jsxs("div",{className:nr.layout,children:[x.jsxs("div",{className:nr.left,children:[x.jsxs("div",{className:nr.copy,children:[x.jsx(Zn,{variant:"heading",children:r}),x.jsx(Zn,{variant:"subheading",children:a}),x.jsx(Zn,{variant:"muted",as:"div",className:nr.description,children:x.jsx(sl,{className:nr.descriptionScroller,children:x.jsx(vj,{content:o})})})]}),x.jsxs("div",{className:nr.cta,children:[x.jsx(ol,{type:"button",size:"lg",fullWidth:!0,onClick:i,isLoading:u,children:s}),x.jsx(Zn,{variant:"subscript",as:"p",className:nr.disclaimer,children:l})]})]}),x.jsx("div",{className:nr.right,children:x.jsx(ru,{className:nr.mediaPanel,children:x.jsx(UH,{agentName:r,className:nr.agentStill})})})]})})}function nV(t){let e=t.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*/g,"__DOUBLE_STAR__").replace(/\*/g,"[^/]*").replace(/__DOUBLE_STAR__/g,".*").replace(/\?/g,"[^/]");return new RegExp(`^${e}$`,"i")}function iV(t,e){if(!e||e.length===0)return!1;const n=t.replace(/^https?:\/\//,"").replace(/\/$/,"");return e.some(i=>{try{const r=nV(i);return r.test(n)||r.test(t)}catch(r){return console.warn(`Invalid URL pattern: ${i}`,r),!1}})}function Wf(t){if(!t||t.length===0)return!1;const e=window.location.origin+window.location.pathname;return iV(e,t)}function rV(t){var gn,Mt,Di,hi,rn,Pn,$n,rr,Rr,oe,Ge,xe,Ze,st,Li,ar,oo,Ar,so,Pi;const{sdk:e,shadowHost:n}=t,[i,r]=A.useState("hidden"),[a,o]=A.useState(()=>{var Z;return((Z=e.client)==null?void 0:Z.session)||null}),[s,l]=A.useState(!1),[c,u]=A.useState(!1),[d,h]=A.useState(!1),[f,y]=A.useState(()=>{var ce;const Z=(ce=e.client)==null?void 0:ce.session;return Z!=null&&Z.sessionUuid?aV(Z.sessionUuid):null}),[v,T]=A.useState([]),[m,g]=A.useState(null),[_,p]=A.useState(0),[S,k]=A.useState(!1),[w,E]=A.useState(0),[R,O]=A.useState(null),[D,q]=A.useState([]),[Y,se]=A.useState(!0),H=oV((Mt=(gn=e.client)==null?void 0:gn.product)==null?void 0:Mt.widget_url_blacklist),P=sV(a),{audioDevices:W}=lV();A.useEffect(()=>{a!=null&&a.sessionUuid&&JE(a.sessionUuid,f)},[f,a==null?void 0:a.sessionUuid]);const{caption:X}=eV(D,{delayMs:0}),ne=Y?X:"",K=typeof navigator<"u"&&!!((Di=navigator.mediaDevices)!=null&&Di.getDisplayMedia),ee=((rn=(hi=a==null?void 0:a.room)==null?void 0:hi.localParticipant)==null?void 0:rn.isScreenShareEnabled)??!1,J=(()=>{if(a!=null&&a.speakingState){if(a.speakingState==="thinking")return"thinking";if(a.speakingState==="busy")return"searching"}})(),V=()=>p(Z=>Z+1),ae=async()=>{var ce,Ne;if(!a)return;const Z=((Ne=(ce=a.room)==null?void 0:ce.localParticipant)==null?void 0:Ne.isScreenShareEnabled)??!1;try{Z?await a.setScreenShareEnabled(!1):await a.shareScreen()}catch(Ae){console.error("[obi-sdk] failed to toggle screen share",Ae)}finally{V()}},j=A.useRef(null),ve=A.useRef(null),B=A.useRef(!1),le=Z=>{if(!Z||j.current===Z)return;ve.current&&(ve.current(),ve.current=null);const ce=()=>V(),Ne=at=>{y(at),Z!=null&&Z.sessionUuid&&JE(Z.sessionUuid,at),r(de=>de==="course-selection"?(k(!1),"pip"):de)},Ae=at=>{T(at.courses),r("course-selection"),y(null),Z!=null&&Z.sessionUuid&&ZE(Z.sessionUuid),g(null)},pt=(at,de)=>{},Ct=at=>{O(at),E(Date.now())},Yt=at=>{at&&O(at),E(Date.now())};Z.on("stateChanged",ce),Z.on("speakingStateChanged",ce),Z.on("paused",ce),Z.on("unpaused",ce),Z.on("chatMessagesChanged",ce),Z.on("courseProgress",Ne),Z.on("courseSelection",Ae),Z.on("transcript",pt),Z.on("screenCaptured",Ct),Z.on("screenCaptureNotification",Yt),Z.on("captions",q),j.current=Z,ve.current=()=>{Z.off("stateChanged",ce),Z.off("speakingStateChanged",ce),Z.off("paused",ce),Z.off("unpaused",ce),Z.off("chatMessagesChanged",ce),Z.off("courseProgress",Ne),Z.off("courseSelection",Ae),Z.off("transcript",pt),Z.off("screenCaptured",Ct),Z.off("screenCaptureNotification",Yt),Z.off("captions",q)}},me=Z=>{var Ne;return Z?((Ne=Z.roomId)==null?void 0:Ne.startsWith("obs-"))&&!f?"course-selection":"pip":"hidden"};A.useEffect(()=>{const Z=Ne=>{var Ae,pt,Ct;Ne?(Ae=e.client)!=null&&Ae.session?r(me(((pt=e.client)==null?void 0:pt.session)??null)):r("start-session"):(Ct=e.client)!=null&&Ct.session||r("hidden")},ce=()=>V();if(e.on("showMenu",Z),e.on("configUpdated",ce),e.client){e.client.session&&(o(e.client.session),le(e.client.session),r(me(e.client.session))),e.client.on("sessionStarted",Ae=>{o(Ae),le(Ae),B.current=!1,l(!1),u(!1),h(!1),r(me(Ae)),vg().track("session-started",{planId:Ae.planId})}),e.client.on("sessionResumed",Ae=>{o(Ae),le(Ae),B.current=!1,l(!1),u(!1),h(!1),r(me(Ae))});const Ne=()=>{var pt;const Ae=(pt=e.client)==null?void 0:pt.session;Ae!=null&&Ae.sessionUuid&&ZE(Ae.sessionUuid),ve.current&&(ve.current(),ve.current=null),o(null),j.current=null,l(!1),u(!1),h(!1),B.current||r("hidden")};e.client.on("sessionStopped",Ne),e.client.on("sessionShutdown",Ne),e.client.on("stateChanged",V)}return()=>{e.off("showMenu",Z),e.off("configUpdated",ce),ve.current&&ve.current()}},[e]),A.useLayoutEffect(()=>{var Z,ce;(ce=(Z=e.client)==null?void 0:Z.product)!=null&&ce.primary_color&&n.style.setProperty("--obi-color-primary",e.client.product.primary_color)},[($n=(Pn=e.client)==null?void 0:Pn.product)==null?void 0:$n.primary_color,n]);const yn=(f==null?void 0:f.stepNames.map((Z,ce)=>({id:`step-${ce+1}`,title:Z})))??[],di=(f==null?void 0:f.currentStep)??null,ir=!0,Gt=(Z,ce)=>{a==null||a.say(`Can we jump to the section about ${ce.title}?`)};if(H||i==="hidden")return null;if(i==="start-session"){const Z=(rr=e.client)==null?void 0:rr.product,ce=(Rr=e.client)==null?void 0:Rr.selectedPlan,Ne=(Z==null?void 0:Z.agent_name)||"Obi",Ae="AI Assistant",pt=(ce==null?void 0:ce.description)||(Z==null?void 0:Z.description)||"I'm here to help you.";return x.jsx(tV,{open:!0,onClose:()=>{l(!1),r("hidden")},onStart:()=>{l(!0),e.startSession({withMicrophone:!0})},agentName:Ne,agentSubtitle:Ae,description:pt,showCloseButton:!0,startLabel:"Start Session",isStarting:s})}if(i==="course-selection"){const Z=(oe=a==null?void 0:a.roomId)==null?void 0:oe.startsWith("obs-"),ce=((Ge=e.client)==null?void 0:Ge.plans)||[],Ne=Z&&v.length>0,Ae=Ne?v.slice().sort((de,Ye)=>de.order!==void 0&&Ye.order!==void 0?de.order-Ye.order:de.order!==void 0?-1:Ye.order!==void 0?1:de.name.localeCompare(Ye.name)).map(de=>({id:de.uuid,title:de.name,description:de.description||de.overview||"",status:de.completed?"completed":"available",duration:typeof de.duration=="number"?`${de.duration} min`:de.duration})):ce.map(de=>{var Ye,In;return{id:de.uuid,title:de.name,description:de.description,status:(In=(Ye=e.client)==null?void 0:Ye.planIsCompleted)!=null&&In[ce.indexOf(de)]?"completed":"available",duration:de.estimated_duration?`${de.estimated_duration} min`:void 0}}),pt=(a==null?void 0:a.languageCodes)||[],Ct=(a==null?void 0:a.selectedLanguage)||(a==null?void 0:a.defaultLanguageCode)||null,Yt={audioDevices:W,currentMicrophoneId:(a==null?void 0:a.preferredMicrophoneDeviceId)||null,isMicrophoneEnabled:!c&&((a==null?void 0:a.isMicShared)??!1),isScreenShareActive:ee,widgetState:d?"chat":null,canPublishData:!0,browserSupportsScreenSharing:K,onMicDeviceSelect:async de=>{e.client&&(e.client.preferredMicrophoneDeviceId=de),a&&de&&await a.switchMicrophoneDevice(de),V()},onMicToggle:async()=>{a!=null&&a.isMicShared?c?(a.unmuteMicrophone(),u(!1)):(a.muteMicrophone(),u(!0)):await(a==null?void 0:a.shareMicrophone())},onChatToggle:()=>{h(!d)},onLeave:()=>{a==null||a.stop()},onScreenShareToggle:ae,languages:pt,selectedLanguage:Ct,defaultLanguageCode:a==null?void 0:a.defaultLanguageCode,isMultilingual:(a==null?void 0:a.isMultilingual)??!1,onLanguageChange:de=>{a==null||a.setLanguage(de)},isLanguageSelectorEnabled:!0,...d?{screenShareButtonVariant:"compact"}:{}},at=d?x.jsx(GE,{messages:(a==null?void 0:a.chatMessages)??[],localIdentity:((xe=a==null?void 0:a.room)==null?void 0:xe.localParticipant.identity)??(typeof(a==null?void 0:a.identity)=="string"?a.identity:null),onSend:async de=>{var Ye,In,Ii,he;a&&(a.appendChatMessage({timestamp:Date.now(),message:de,from:{identity:((In=(Ye=a.room)==null?void 0:Ye.localParticipant)==null?void 0:In.identity)??null,name:((he=(Ii=a.room)==null?void 0:Ii.localParticipant)==null?void 0:he.name)??null},isAgent:!1}),await a.say(de))},onClose:()=>h(!1)}):void 0;return x.jsx(QE,{open:!0,onClose:()=>a==null?void 0:a.stop(),courses:Ae,controlBarProps:Yt,coursePanelProps:{selectedCourseIds:m?[m]:void 0,onCourseToggle:async de=>{var Ye,In,Ii;if(Ne){const he=v.find(Dt=>Dt.uuid===de);if(he){g(de);try{await((Ye=a==null?void 0:a.say)==null?void 0:Ye.call(a,`I'd like to take the ${he.name} course.`))}catch(Dt){console.error("[obi-sdk] failed to send course selection",Dt),g(null)}}}else{const he=ce.find(Dt=>Dt.uuid===de);if(he){(In=e.client)==null||In.selectPlan(he),r("pip");try{await((Ii=a==null?void 0:a.say)==null?void 0:Ii.call(a,`I'd like to take the ${he.name} course.`))}catch(Dt){console.error("[obi-sdk] failed to send course selection",Dt),r("course-selection")}}}}},rightPanel:at,avatarImageSrc:((st=(Ze=e.client)==null?void 0:Ze.product)==null?void 0:st.logo_url)||void 0,avatarAudioPower:P,avatarStatus:J,captionsText:ne})}if(i==="course-outline"){const Z=(a==null?void 0:a.languageCodes)||[],ce=(a==null?void 0:a.selectedLanguage)||(a==null?void 0:a.defaultLanguageCode)||null,Ne={audioDevices:W,currentMicrophoneId:(a==null?void 0:a.preferredMicrophoneDeviceId)||null,isMicrophoneEnabled:!c&&((a==null?void 0:a.isMicShared)??!1),isScreenShareActive:ee,widgetState:d?"chat":null,canPublishData:!0,browserSupportsScreenSharing:K,onMicDeviceSelect:async Ct=>{e.client&&(e.client.preferredMicrophoneDeviceId=Ct),a&&Ct&&await a.switchMicrophoneDevice(Ct),V()},onMicToggle:async()=>{a!=null&&a.isMicShared?c?(a.unmuteMicrophone(),u(!1)):(a.muteMicrophone(),u(!0)):await(a==null?void 0:a.shareMicrophone())},onChatToggle:()=>{h(!d)},onLeave:()=>{a==null||a.stop()},onScreenShareToggle:ae,languages:Z,selectedLanguage:ce,defaultLanguageCode:a==null?void 0:a.defaultLanguageCode,isMultilingual:(a==null?void 0:a.isMultilingual)??!1,onLanguageChange:Ct=>{a==null||a.setLanguage(Ct)},isLanguageSelectorEnabled:!0,...d?{screenShareButtonVariant:"compact"}:{}},Ae=d?x.jsx(GE,{messages:(a==null?void 0:a.chatMessages)??[],localIdentity:((Li=a==null?void 0:a.room)==null?void 0:Li.localParticipant.identity)??(typeof(a==null?void 0:a.identity)=="string"?a.identity:null),onSend:async Ct=>{var Yt,at,de,Ye;a&&(a.appendChatMessage({timestamp:Date.now(),message:Ct,from:{identity:((at=(Yt=a.room)==null?void 0:Yt.localParticipant)==null?void 0:at.identity)??null,name:((Ye=(de=a.room)==null?void 0:de.localParticipant)==null?void 0:Ye.name)??null},isAgent:!1}),await a.say(Ct))},onClose:()=>h(!1)}):void 0,pt=x.jsx(RF,{steps:yn,currentStep:di,hideTrailingConclusionStep:ir,onStepClick:Gt});return x.jsx(QE,{open:!0,onClose:()=>a==null?void 0:a.stop(),courses:[],controlBarProps:Ne,middlePanel:pt,rightPanel:Ae,avatarImageSrc:((oo=(ar=e.client)==null?void 0:ar.product)==null?void 0:oo.logo_url)||void 0,avatarAudioPower:P,avatarStatus:J,captionsText:ne})}if(i==="pip"){const Z=(a==null?void 0:a.languageCodes)||[],ce=(a==null?void 0:a.selectedLanguage)||(a==null?void 0:a.defaultLanguageCode)||null,Ne=280,Ae=250,pt=16,Ct={x:window.innerWidth-Ne-pt,y:window.innerHeight-Ae-pt},Yt={isMicrophoneEnabled:!c&&((a==null?void 0:a.isMicShared)??!1),isChatOpen:d,isScreenShareActive:ee,onMicToggle:async()=>{a!=null&&a.isMicShared?c?(a.unmuteMicrophone(),u(!1)):(a.muteMicrophone(),u(!0)):await(a==null?void 0:a.shareMicrophone())},onChatToggle:()=>h(de=>!de),onScreenShareToggle:ae,onLeave:()=>{a==null||a.stop()},languages:Z,selectedLanguage:ce,defaultLanguageCode:a==null?void 0:a.defaultLanguageCode,isMultilingual:(a==null?void 0:a.isMultilingual)??!1,onLanguageChange:de=>{a==null||a.setLanguage(de)},isLanguageSelectorEnabled:!0},at=d?x.jsx(QF,{messages:(a==null?void 0:a.chatMessages)??[],localIdentity:((Ar=a==null?void 0:a.room)==null?void 0:Ar.localParticipant.identity)??(typeof(a==null?void 0:a.identity)=="string"?a.identity:null),onSend:async de=>{var Ye,In,Ii,he;a&&(a.appendChatMessage({timestamp:Date.now(),message:de,from:{identity:((In=(Ye=a.room)==null?void 0:Ye.localParticipant)==null?void 0:In.identity)??null,name:((he=(Ii=a.room)==null?void 0:Ii.localParticipant)==null?void 0:he.name)??null},isAgent:!1}),await a.say(de))},testId:"pip-chat-panel"}):void 0;return x.jsx(_q,{initialPosition:Ct,onExit:()=>{r("course-outline")},controlBarProps:Yt,isCourseOutlineSelected:S&&!!f,onCourseOutlineToggle:f?()=>{k(de=>!de)}:void 0,isCaptionsEnabled:Y,onCaptionsToggle:()=>se(de=>!de),courseOutline:f?{steps:yn,currentStep:di,onStepClick:Gt,hideTrailingConclusionStep:ir}:void 0,messagesPanel:at,avatarFallbackProps:{audioPower:P,imageSrc:((Pi=(so=e.client)==null?void 0:so.product)==null?void 0:Pi.logo_url)??void 0,status:J,captionsText:ne},screenshotUrl:R,cameraShotTrigger:w})}return null}function JE(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 aV(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 ZE(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 oV(t){const[e,n]=A.useState(()=>Wf(t));return A.useEffect(()=>{n(Wf(t))},[t]),A.useEffect(()=>{const i=()=>{n(Wf(t))};return window.addEventListener("popstate",i),window.addEventListener("hashchange",i),()=>{window.removeEventListener("popstate",i),window.removeEventListener("hashchange",i)}},[t]),e}function sV(t){const[e,n]=A.useState(0),i=A.useRef(null),r=A.useRef(0),a=A.useRef(0);return A.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 y=0;for(let v=0;v<s.length;v++)y+=s[v];l=Math.min(1,Math.max(0,y/s.length))}const c=r.current,d=l>=c?.7:.15,h=c*d+l*(1-d);r.current=h;const f=h<.05?0:Math.min(1,h);Math.abs(f-a.current)>.01&&(a.current=f,n(f)),i.current=requestAnimationFrame(o)};return i.current=requestAnimationFrame(o),()=>{i.current&&cancelAnimationFrame(i.current)}},[t]),e}function lV(){const[t,e]=A.useState({audioDevices:[]});return A.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 cV(t){if(document.querySelector("#obi-host")||document.querySelector("obi-widget"))return;uV();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(tB);const a=new CSSStyleSheet;a.replaceSync($9);const o=new CSSStyleSheet;o.replaceSync(Z9);const s=new CSSStyleSheet;s.replaceSync(eB),n.adoptedStyleSheets=[r,a,o,s],J9.createRoot(i).render(x.jsx(rV,{sdk:t,shadowHost:e})),console.log("[obi-sdk] widget mounted")}function uV(){$E("https://fonts.cdnfonts.com/css/satoshi"),$E("https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap")}function $E(t){const e=document.createElement("link");e.href=t,e.rel="stylesheet",document.head.appendChild(e)}const e3="49206C6F7665204F6269_session",t3="obi-url-params";class dV extends Jf{constructor(e){super(),this.client=null,this.isActive=!1,this.primaryColour="#9500FF",this.passivePlanUuid=null,this.commandLog=[],this.commandQueue=[],this._resumed=!1,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=this.load();if(i)try{n=Jd.deserialise(i,e,"sdk",{apiBaseUrl:"https://staging.coragents.ai",captureScreen:this.captureScreen.bind(this)}),n?this._resumed=!0:localStorage.removeItem("obi-client")}catch(r){console.error("[obi] error loading cached client",r),localStorage.removeItem("obi-client")}n||(n=new Jd(e,"sdk",{apiBaseUrl:"https://staging.coragents.ai",captureScreen:this.captureScreen.bind(this)})),this.client=n,this.client.on("stateChanged",r=>{var a,o,s,l,c,u,d,h,f,y;r==="ready"&&this.updateConfig({isActive:((a=window==null?void 0:window.obiWidgetConfig)==null?void 0:a.isActive)??((o=this.client)==null?void 0:o.showWidget),primaryColour:((l=(s=this.client)==null?void 0:s.product)==null?void 0:l.primary_color)||"#9500FF",widgetDisplay:((c=window==null?void 0:window.obiWidgetConfig)==null?void 0:c.widgetDisplay)||((d=(u=this.client)==null?void 0:u.product)==null?void 0:d.widget_display)||"regular",completedWidgetDisplay:((h=window==null?void 0:window.obiWidgetConfig)==null?void 0:h.completedWidgetDisplay)||((y=(f=this.client)==null?void 0:f.product)==null?void 0:y.completed_widget_display)||"regular"})}),this.client.on("sessionStarted",()=>{this.save(),this.passivePlanUuid=null}),this.client.on("sessionStopped",()=>{localStorage.removeItem("obi-client"),this.passivePlanUuid=null}),this.client.on("sessionShutdown",()=>{localStorage.removeItem("obi-client")}),this.client.on("trackEvent",(r,a)=>{}),this.client.session&&(this.client.session.isPaused,this.client.resumeSession(r=>{r.on("stateChanged",a=>{a!=="disconnecting"&&a!=="disconnected"&&a!=="error"&&a!=="connecting"&&this.save()}),r.on("paused",()=>{this.save()}),r.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&&Wf(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{vg().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){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),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&&vg().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(t3)||"{}"),Object.keys(e).length===0&&new URLSearchParams(window.location.search).forEach((a,o)=>{e[o]=a});const n=e[e3];if(!n)return null;const i=new URL(window.location.href);i.searchParams.delete(e3),window.history.replaceState({},"",i.toString()),i.toString(),localStorage.removeItem(t3),this.passivePlanUuid=n}mountWidget(){cV(this)}showMessage(e,n){try{this.emit("showMessage",{text:e,autoCloseMs:n==null?void 0:n.autoCloseMs})}catch{}}async captureScreen(){try{await OO(async()=>(this.graphemes||(this.graphemes=await this.client.api.getGraphemes()),this.graphemes.data.text_segmentation)),await k3(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 lO(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")}}async function n3(t,e){let n;try{n=window}catch{console.warn("[obi] no window object found"),n={}}return hV({appToken:t,window:n,init:e})}async function hV({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 dV(t);return e.ObiSDK=r.dispatchCommand,await r.initialise({queuedCommands:i}),e.obi=r,r.mountWidget(),r}function i3(){}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{n3(void 0,i3)}):n3(void 0,i3)})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "obi-sdk",
3
- "version": "0.19.50-beta.10",
3
+ "version": "0.19.50-beta.11",
4
4
  "description": "JavaScript SDK for Obi",
5
5
  "type": "module",
6
6
  "main": "dist/obi-sdk.umd.js",