obi-sdk 0.11.0 → 0.11.1
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/modular/chunks/index-45f4d445.js +6 -0
- package/dist/modular/chunks/index-45f4d445.js.map +1 -0
- package/dist/modular/chunks/{obi-widget-585f773a.js → obi-widget-00df4624.js} +25 -8
- package/dist/modular/chunks/{obi-widget-585f773a.js.map → obi-widget-00df4624.js.map} +1 -1
- package/dist/modular/index.js +1 -1
- package/dist/modular/ui.js +10 -10
- package/dist/obi-sdk.standalone.iife.js +2 -2
- package/dist/obi-sdk.standalone.iife.js.map +1 -1
- package/dist/react.es.js +5 -5
- package/dist/react.es.js.map +1 -1
- package/dist/react.umd.js +2 -2
- package/dist/react.umd.js.map +1 -1
- package/dist/ui/components/obi-widget/obi-widget.d.ts +1 -1
- package/package.json +1 -1
- package/dist/modular/chunks/index-4be516d9.js +0 -6
- package/dist/modular/chunks/index-4be516d9.js.map +0 -1
package/dist/modular/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { O as ObiWidget, s as setGlobalContext, t as trackEvent, c as captureException, w as withSentryAsyncHandler, a as withSentryHandler } from "./chunks/obi-widget-
|
|
1
|
+
import { O as ObiWidget, s as setGlobalContext, t as trackEvent, c as captureException, w as withSentryAsyncHandler, a as withSentryHandler } from "./chunks/obi-widget-00df4624.js";
|
|
2
2
|
import "./chunks/types-e0297e7b.js";
|
|
3
3
|
if (!customElements.get("obi-widget")) {
|
|
4
4
|
customElements.define("obi-widget", ObiWidget);
|
package/dist/modular/ui.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { S as SDKState } from "./chunks/types-e0297e7b.js";
|
|
2
|
-
import { i, n, b as i$1, x } from "./chunks/obi-widget-
|
|
3
|
-
import { A, C, e, f, D, N, d, O, S } from "./chunks/obi-widget-
|
|
2
|
+
import { i, n, b as i$1, x } from "./chunks/obi-widget-00df4624.js";
|
|
3
|
+
import { A, C, e, f, D, N, d, O, S } from "./chunks/obi-widget-00df4624.js";
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
6
|
var __decorateClass = (decorators, target, key, kind) => {
|
|
@@ -85,14 +85,14 @@ if (!customElements.get("obi-status-widget")) {
|
|
|
85
85
|
const statusWidget = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, ObiStatusWidget }, Symbol.toStringTag, { value: "Module" }));
|
|
86
86
|
function defineCustomElements() {
|
|
87
87
|
Promise.resolve().then(() => statusWidget);
|
|
88
|
-
import("./chunks/index-
|
|
89
|
-
import("./chunks/obi-widget-
|
|
90
|
-
import("./chunks/obi-widget-
|
|
91
|
-
import("./chunks/obi-widget-
|
|
92
|
-
import("./chunks/obi-widget-
|
|
93
|
-
import("./chunks/obi-widget-
|
|
94
|
-
import("./chunks/obi-widget-
|
|
95
|
-
import("./chunks/obi-widget-
|
|
88
|
+
import("./chunks/index-45f4d445.js");
|
|
89
|
+
import("./chunks/obi-widget-00df4624.js").then((n2) => n2.l);
|
|
90
|
+
import("./chunks/obi-widget-00df4624.js").then((n2) => n2.m);
|
|
91
|
+
import("./chunks/obi-widget-00df4624.js").then((n2) => n2.g);
|
|
92
|
+
import("./chunks/obi-widget-00df4624.js").then((n2) => n2.h);
|
|
93
|
+
import("./chunks/obi-widget-00df4624.js").then((n2) => n2.o);
|
|
94
|
+
import("./chunks/obi-widget-00df4624.js").then((n2) => n2.j);
|
|
95
|
+
import("./chunks/obi-widget-00df4624.js").then((n2) => n2.k);
|
|
96
96
|
}
|
|
97
97
|
export {
|
|
98
98
|
A as AudioEqualizer,
|
|
@@ -908,7 +908,7 @@
|
|
|
908
908
|
opacity: 0.5;
|
|
909
909
|
cursor: not-allowed;
|
|
910
910
|
}
|
|
911
|
-
`,gU([np({type:Object})],pU.prototype,"session",2),gU([np({type:Function})],pU.prototype,"onStart",2),gU([np({type:Function})],pU.prototype,"onClose",2),gU([sp()],pU.prototype,"isLoading",2),gU([sp()],pU.prototype,"error",2),gU([sp()],pU.prototype,"startAttempts",2),customElements.get("obi-session-start-modal")||customElements.define("obi-session-start-modal",pU);var vU=Object.defineProperty,mU=Object.getOwnPropertyDescriptor,QU=(A,t,e,i)=>{for(var n,s=i>1?void 0:i?mU(t,e):t,r=A.length-1;r>=0;r--)(n=A[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&vU(t,e,s),s};class CU extends Ap{constructor(){super(),this.apiKey="",this.isActive=!0,this.linkOnlyAccess=!1,this.urlBlacklist=[],this.position="bottom-right",this.user=null,this.state=Ra.READY,this.storedActiveState=void 0,this.showCourseModal=!1,this.showSessionStartModal=!1,this.selectedCourse=null,this.isHovering=!1,this.navVisible=!1,this.activeSession=null,this.volume={speaker:"ASSISTANT",volume:0,spectrum:[]},this.databaseConfig=null,this.configLoaded=!1,this.configInCode=!1,this.sessionToken=null,this.roomToken=null,this.roomUrl=null,this.boundSaveSessionData=null,this.obiClient=null,this.closeNavTimeoutRef=null,this.researchingTimeoutRef=null,this.urlCheckInterval=null,this.currentUrl="",this.connectObi=mC((async A=>{if(this.activeSession)return pC("connection_already_exists",{sessionToken:A},"ObiWidget"),void console.log("Connection already exists");pC("session_connection_started",{sessionToken:A},"ObiWidget"),vC({sessionId:A});try{const t=this.createSession(A);if(!t)return void this.handleSessionCreationFailure((()=>this.removeSessionUrlParams()));this.setupSessionEventListeners(t,(()=>this.removeSessionUrlParams())),t.on("screenCaptureRequested",mC((async()=>{pC("screen_capture_requested",{},"ObiWidget");try{const A=(await(t=document.documentElement,e={useCORS:!0,allowTaint:!0,foreignObjectRendering:!0},void 0===e&&(e={}),(function(A,t){return Za(void 0,void 0,void 0,(function(){var e,i,n,s,r,o,a,c,u,h,l,d,B,f,w,g,p,v,m,Q,C,U,F,y,b,E,I,k,H,S,T,O,K,D,M,L,x,_;return za(this,(function(N){switch(N.label){case 0:if(!A||"object"!=typeof A)return[2,Promise.reject("Invalid element provided as first argument")];if(!(e=A.ownerDocument))throw new Error("Element is not attached to a Document");if(!(i=e.defaultView))throw new Error("Document is not attached to a Window");return n={allowTaint:null!==(U=t.allowTaint)&&void 0!==U&&U,imageTimeout:null!==(F=t.imageTimeout)&&void 0!==F?F:15e3,proxy:t.proxy,useCORS:null!==(y=t.useCORS)&&void 0!==y&&y,customIsSameOrigin:t.customIsSameOrigin},s=qa({logging:null===(b=t.logging)||void 0===b||b,cache:t.cache},n),r={windowWidth:null!==(E=t.windowWidth)&&void 0!==E?E:i.innerWidth,windowHeight:null!==(I=t.windowHeight)&&void 0!==I?I:i.innerHeight,scrollX:null!==(k=t.scrollX)&&void 0!==k?k:i.pageXOffset,scrollY:null!==(H=t.scrollY)&&void 0!==H?H:i.pageYOffset},o=new tc(r.scrollX,r.scrollY,r.windowWidth,r.windowHeight),a=new Xw(s,o),c=null!==(S=t.foreignObjectRendering)&&void 0!==S&&S,u={allowTaint:null!==(T=t.allowTaint)&&void 0!==T&&T,onclone:t.onclone,ignoreElements:t.ignoreElements,inlineImages:c,copyStyles:c},a.logger.debug("Starting document clone with size ".concat(o.width,"x").concat(o.height," scrolled to ").concat(-o.left,",").concat(-o.top)),h=new Of(a,A,u),(l=h.clonedReferenceElement)?[4,h.toIFrame(e,o)]:[2,Promise.reject("Unable to find element in cloned iframe")];case 1:return d=N.sent(),B=of(l)||"HTML"===l.tagName?(function(A){var t=A.body,e=A.documentElement;if(!t||!e)throw new Error("Unable to get document size");var i=Math.max(Math.max(t.scrollWidth,e.scrollWidth),Math.max(t.offsetWidth,e.offsetWidth),Math.max(t.clientWidth,e.clientWidth)),n=Math.max(Math.max(t.scrollHeight,e.scrollHeight),Math.max(t.offsetHeight,e.offsetHeight),Math.max(t.clientHeight,e.clientHeight));return new tc(0,0,i,n)})(l.ownerDocument):ec(a,l),f=B.width,w=B.height,g=B.left,p=B.top,v=(function(A,t,e){var i=t.ownerDocument,n=i.documentElement?Yh(A,getComputedStyle(i.documentElement).backgroundColor):Wh.TRANSPARENT,s=i.body?Yh(A,getComputedStyle(i.body).backgroundColor):Wh.TRANSPARENT,r="string"==typeof e?Yh(A,e):null===e?Wh.TRANSPARENT:4294967295;return t===i.documentElement?dh(n)?dh(s)?r:s:n:r})(a,l,t.backgroundColor),m={canvas:t.canvas,backgroundColor:v,scale:null!==(K=null!==(O=t.scale)&&void 0!==O?O:i.devicePixelRatio)&&void 0!==K?K:1,x:(null!==(D=t.x)&&void 0!==D?D:0)+g,y:(null!==(M=t.y)&&void 0!==M?M:0)+p,width:null!==(L=t.width)&&void 0!==L?L:Math.ceil(f),height:null!==(x=t.height)&&void 0!==x?x:Math.ceil(w)},c?(a.logger.debug("Document cloned, using foreign object rendering"),[4,new Pw(a,m).render(l)]):[3,3];case 2:return Q=N.sent(),[3,5];case 3:return a.logger.debug("Document cloned, element located at ".concat(g,",").concat(p," with size ").concat(f,"x").concat(w," using computed rendering")),a.logger.debug("Starting DOM parsing"),C=YB(a,l),v===C.styles.backgroundColor&&(C.styles.backgroundColor=Wh.TRANSPARENT),a.logger.debug("Starting renderer for element at ".concat(m.x,",").concat(m.y," with size ").concat(m.width,"x").concat(m.height)),[4,new xw(a,m).render(C)];case 4:Q=N.sent(),N.label=5;case 5:return(null===(_=t.removeContainer)||void 0===_||_)&&(Of.destroy(d)||a.logger.error("Cannot detach cloned iframe as it is not in the DOM anymore")),a.logger.debug("Finished rendering"),[2,Q]}}))}))})(t,e))).toDataURL("image/png");this.activeSession.emit("screenCaptureComplete",A),pC("screen_capture_completed",{},"ObiWidget")}catch(i){gC(i,{componentName:"ObiWidget",handlerName:"screenCaptureRequested",sessionToken:A}),console.error("[obi] error capturing screen:",i),this.activeSession.emit("screenCaptureComplete","error"),pC("screen_capture_failed",{error:i instanceof Error?i.message:String(i)},"ObiWidget")}var t,e}),"screenCaptureRequested","ObiWidget"));const e=await t.connect();e&&(this.sessionToken=A,this.roomToken=e.token,this.roomUrl=e.url,vC({sessionId:A,widgetState:this.state.toString()}),this.removeSessionUrlParams(),pC("session_connection_established",{sessionToken:A,hasRoomToken:!!e.token},"ObiWidget")),this.activeSession=t}catch(t){console.error("Failed to start session:",t),gC(t,{componentName:"ObiWidget",handlerName:"connectObi",sessionToken:A}),this.handleSessionCreationFailure((()=>this.removeSessionUrlParams()))}}),"connectObi","ObiWidget"),this.handleCloseModals=()=>{this.state=Ra.READY,this.showCourseModal=!1,this.showSessionStartModal=!1},this.handleCourseSelectEvent=A=>{const t=A;this.selectedCourse=t.detail,this.showCourseModal=!1,this.showSessionStartModal=!0},this.handleUrlSessionEvent=mC((async A=>{pC("url_session_event",{sessionToken:A},"ObiWidget");try{if(!this.obiClient)return gC(new Error("ObiClient not initialized"),{componentName:"ObiWidget",handlerName:"handleUrlSessionEvent",sessionToken:A}),void console.error("ObiClient not initialized");const t=await this.obiClient.startSession(A,this.apiKey);if(t.data){const{session:e}=t.data;if(console.log("[obi-sdk] session:",e),pC("session_started",{sessionId:e?.id,sessionToken:A},"ObiWidget"),e){const t=e;this.selectedCourse={id:A,name:t.onboarding_plan?.name||"",description:t.onboarding_plan?.description||""},this.state=Ra.LOADING,this.showSessionStartModal=!0,pC("matching_session_found",{sessionToken:A,hasOnboardingPlan:!!t.onboarding_plan},"ObiWidget")}else console.log("[obi-sdk] no session found with token:",A),pC("no_matching_session",{sessionToken:A},"ObiWidget")}}catch(t){console.error("Failed to fetch session details:",t),gC(t,{componentName:"ObiWidget",handlerName:"handleUrlSessionEvent",sessionToken:A})}}),"handleUrlSessionEvent","ObiWidget"),this.handleSessionStart=mC((async A=>{pC("session_start_requested",{sessionToken:A},"ObiWidget"),this.activeSession&&(pC("session_start_blocked",{sessionToken:A},"ObiWidget"),gC(new Error("Session start blocked"),{componentName:"ObiWidget",handlerName:"handleSessionStart",sessionToken:A}),this.activeSession.disconnect(),this.activeSession=null),this.showSessionStartModal=!1,this.state=Ra.LOADING,vC({widgetState:this.state.toString()}),await this.connectObi(A)}),"handleSessionStart","ObiWidget"),this.checkExistingSession=mC((async()=>{pC("checking_existing_session",{},"ObiWidget");try{const A=JSON.parse(FC.getItem(UC)||"{}"),{sessionToken:t,roomToken:e,roomUrl:i,sessionExpiry:n,obiState:s}=A;if(!t||!e||!i)return void pC("no_existing_session_data",{},"ObiWidget");if(console.log("[obi-sdk] using existing session"),pC("existing_session_data_found",{sessionToken:t,hasExpiry:!!n,obiState:s},"ObiWidget"),n&&new Date(n)<new Date)return this.clearSessionStorage(),void pC("session_expired",{sessionToken:t},"ObiWidget");this.state=Ra.LOADING,vC({sessionId:t,widgetState:this.state.toString()});const r=this.createSession(t);if(!r)return void this.handleSessionCreationFailure((()=>this.clearSessionStorage()));this.setupSessionEventListeners(r,(()=>this.clearSessionStorage())),await r.reconnect(i,e,s)?(this.activeSession=r,this.sessionToken=t,this.roomToken=e,this.roomUrl=i,this.state=s,this.storedActiveState=s,pC("session_reconnected",{sessionToken:t,obiState:s},"ObiWidget")):(this.clearSessionStorage(),pC("session_reconnection_failed",{sessionToken:t},"ObiWidget"))}catch(A){console.error("Error reconnecting to session:",A),gC(A,{componentName:"ObiWidget",handlerName:"checkExistingSession"}),this.handleSessionCreationFailure((()=>this.clearSessionStorage()))}}),"checkExistingSession","ObiWidget");try{CC("ObiWidget").setContext(),this.obiClient=new u({baseUrl:t}),this.currentUrl=window.location.href;const A=()=>{try{this.activeSession&&this.sessionToken&&this.roomToken&&this.roomUrl&&this.saveSessionData()}catch(A){gC(A,{componentName:"ObiWidget",handlerName:"handleUnload"})}};window.addEventListener("beforeunload",A),window.addEventListener("pagehide",A),pC("ObiWidget_constructor_completed",{},"ObiWidget")}catch(A){throw gC(A,{componentName:"ObiWidget",lifecycle:"constructor"}),A}}updateFromConfig(){if(window.obiWidgetConfig){this.apiKey=window.obiWidgetConfig.apiKey||this.apiKey;const A=void 0!==window.obiWidgetConfig.position,t=void 0!==window.obiWidgetConfig.primaryColor,e=void 0!==window.obiWidgetConfig.linkOnlyAccess,i=void 0!==window.obiWidgetConfig.urlBlacklist;this.configInCode=A&&t&&e&&i,this.configInCode?(this.configLoaded=!0,this.applyFinalConfiguration()):this.configLoaded||this.fetchDatabaseConfig(),!0===window.obiWidgetConfig.showMenu&&(this.state=Ra.LOADING,this.showCourseModal=!0,window.obiWidgetConfig.showMenu=!1)}else this.configLoaded||this.fetchDatabaseConfig()}generateColorVariables(A){try{const t=Xa(A,"#c4b5fd"),e=Xa(A,"#c76cff"),i=(function(A){try{const t={h:Va(A).h,s:100,l:96};return Ja(t.h,t.s,t.l)}catch(t){return console.warn("Failed to transform to light tint, using fallback:",t),A}})(A),n=Xa(A,"#A06DF9");this.style.setProperty("--obi-secondary",t),this.style.setProperty("--obi-course-selected",e),this.style.setProperty("--obi-course-selected-bg",i),this.style.setProperty("--obi-paused-pulse",n)}catch(t){console.warn("Failed to generate color variables:",t),this.style.setProperty("--obi-secondary","#c4b5fd"),this.style.setProperty("--obi-course-selected","#c76cff"),this.style.setProperty("--obi-course-selected-bg","#fbf3ff"),this.style.setProperty("--obi-paused-pulse","#A06DF9")}}removeSessionUrlParams(){const A=new URL(window.location.href);A.searchParams.delete($a),window.history.replaceState({},"",A.toString()),localStorage.removeItem("obi-url-params")}createSession(A){try{return new Ga({sessionId:A,apiBaseUrl:t})||(console.error("Failed to create session"),null)}catch(e){return console.error("Error creating session:",e),null}}setupSessionEventListeners(A,t){A.on("stateChanged",(t=>{if(t===Ra.RESEARCHING)return this.researchingTimeoutRef&&window.clearTimeout(this.researchingTimeoutRef),this.state=t,this.researchingTimeoutRef=window.setTimeout((()=>{this.researchingTimeoutRef=null;const t=A.getCurrentState();this.state=t,t!==Ra.READY&&(this.storedActiveState=t)}),1500),void(this.storedActiveState=t);null===this.researchingTimeoutRef&&(this.state=t,t!==Ra.READY&&(this.storedActiveState=t))})),A.on("volume",(({speaker:A,spectrum:t,volume:e})=>{this.volume={speaker:A,spectrum:t,volume:e}})),A.on("error",(A=>{console.error("Session error:",A),this.state=Ra.ERROR,this.activeSession=null,t&&t()}))}handleSessionCreationFailure(A){this.state=Ra.ERROR,this.activeSession=null,A&&A()}clearSessionStorage(){FC.removeItem(UC)}handleUrlChange(){this.requestUpdate(),yC(this.urlBlacklist)&&this.activeSession&&this.terminateSession()}saveSessionData(){if(this.activeSession&&this.sessionToken&&this.roomToken&&this.roomUrl){const A=new Date;A.setMinutes(A.getMinutes()+5);const t={sessionToken:this.sessionToken,roomToken:this.roomToken,roomUrl:this.roomUrl,obiState:this.storedActiveState??this.state,sessionExpiry:A.toISOString()};FC.setItem(UC,JSON.stringify(t))}}async sessionConnectionCheck(){const A=(function(){let A={};return A=JSON.parse(localStorage.getItem("obi-url-params")||"{}"),0===Object.keys(A).length&&new URLSearchParams(window.location.search).forEach(((t,e)=>{A[e]=t})),localStorage.removeItem("obi-url-params"),A[$a]})();A?(console.log("[obi-sdk] using magic link"),this.apiKey?await this.handleUrlSessionEvent(A):(console.log("[obi-sdk] API key not ready, retrying..."),setTimeout((()=>{this.apiKey&&this.handleUrlSessionEvent(A)}),100))):await this.checkExistingSession()}connectedCallback(){super.connectedCallback(),this.updateFromConfig(),this.addEventListener("obi-config-updated",this.handleConfigUpdate.bind(this)),this.setAttribute("position",this.position),this.boundSaveSessionData=this.saveSessionData.bind(this),window.addEventListener("beforeunload",this.boundSaveSessionData),window.addEventListener("pagehide",this.boundSaveSessionData),this.isActive&&(this.urlCheckInterval=window.setInterval((()=>{this.currentUrl!==window.location.href&&(this.currentUrl=window.location.href,this.handleUrlChange())}),1e3)),this.addEventListener("course-select",this.handleCourseSelectEvent)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("obi-config-updated",this.handleConfigUpdate.bind(this)),null!==this.closeNavTimeoutRef&&window.clearTimeout(this.closeNavTimeoutRef),null!==this.researchingTimeoutRef&&(window.clearTimeout(this.researchingTimeoutRef),this.researchingTimeoutRef=null),this.boundSaveSessionData&&(window.removeEventListener("beforeunload",this.boundSaveSessionData),window.removeEventListener("pagehide",this.boundSaveSessionData)),null!==this.urlCheckInterval&&(clearInterval(this.urlCheckInterval),this.urlCheckInterval=null),this.removeSessionUrlParams()}handleConfigUpdate(A){const t=A.detail.isActive&&!this.isActive;this.updateFromConfig(),this.position&&this.setAttribute("position",this.position),t&&!yC(this.urlBlacklist)&&this.sessionConnectionCheck(),this.requestUpdate()}handleMouseEnter(){this.isHovering=!0,this.navVisible=!0}handleMouseLeave(){this.isHovering=!1,null!==this.closeNavTimeoutRef&&window.clearTimeout(this.closeNavTimeoutRef),this.closeNavTimeoutRef=window.setTimeout((()=>{this.isHovering||(this.navVisible=!1),this.closeNavTimeoutRef=null}),300)}terminateSession(){this.clearSessionStorage(),this.sessionToken=null,this.roomToken=null,this.roomUrl=null,null!==this.researchingTimeoutRef&&(window.clearTimeout(this.researchingTimeoutRef),this.researchingTimeoutRef=null),this.activeSession&&(this.activeSession.disconnect(),this.activeSession=null),this.state=Ra.READY}handleItemSelect(A,t){"experiences"!==A?xa([A,t]).with(["pause",!0],(()=>{this.activeSession?.pauseRecording()})).with(["pause",!1],(()=>{this.activeSession?.resumeRecording()})).with(["activate",!1],(()=>{this.terminateSession()})).otherwise((()=>{})):this.showCourseModal=!0}async fetchDatabaseConfig(){if(!this.apiKey)return this.configLoaded=!0,void this.applyFinalConfiguration();try{const A=`obi-widget-config-${this.apiKey}`,t=localStorage.getItem(A),e=localStorage.getItem(`${A}-timestamp`);if(t&&e&&Date.now()-parseInt(e,10)<6e5){const A=JSON.parse(t);return this.databaseConfig=A,this.configLoaded=!0,void this.applyFinalConfiguration()}const i=new AbortController,n=setTimeout((()=>i.abort()),3e3),s=await this.obiClient.getOnboardeeWidgetConfig(this.apiKey,i.signal);if(clearTimeout(n),s.error){if(404===s.response?.status)return localStorage.removeItem(A),localStorage.removeItem(`${A}-timestamp`),this.databaseConfig=null,this.configLoaded=!0,void this.applyFinalConfiguration();throw new Error(`HTTP ${s.response?.status||"Unknown error"}`)}const r=s.data;localStorage.setItem(A,JSON.stringify(r)),localStorage.setItem(`${A}-timestamp`,Date.now().toString()),this.databaseConfig=r,this.configLoaded=!0,this.applyFinalConfiguration()}catch(A){A instanceof Error&&"AbortError"===A.name?console.warn("Widget config fetch timed out, using defaults"):console.warn("Failed to fetch widget config from database:",A),this.databaseConfig=null,this.configLoaded=!0,this.applyFinalConfiguration()}}applyFinalConfiguration(){const A=window.obiWidgetConfig,t=this.databaseConfig;this.user=A?.user||this.user,this.position=A?.position||t?.position||this.position,this.setAttribute("position",this.position),void 0!==A?.isActive&&(this.isActive=A.isActive),void 0!==A?.linkOnlyAccess?this.linkOnlyAccess=A.linkOnlyAccess:void 0!==t?.linkOnlyAccess&&(this.linkOnlyAccess=t.linkOnlyAccess);const e=A?.urlBlacklist||[],i=t?.urlBlacklist||[];if(e.length>0||i.length>0){const A=[...e,...i];this.urlBlacklist=[...new Set(A)]}const n=A?.primaryColor||t?.primaryColor||Pa;this.style.setProperty("--obi-primary",n),this.generateColorVariables(n),this.isActive&&!yC(this.urlBlacklist)&&this.sessionConnectionCheck()}render(){if(!this.configLoaded)return _g;if(!this.isActive)return _g;if(this.linkOnlyAccess&&this.state===Ra.READY)return _g;if(yC(this.urlBlacklist))return _g;const A=xa(this.state).with(Ra.LOADING,(()=>Mg`<obi-dot-loader></obi-dot-loader>`)).with(Ra.RESEARCHING,(()=>Mg`<obi-searching-loader></obi-searching-loader>`)).with(Da.union(Ra.USER_SPEAKING,Ra.AGENT_SPEAKING),(()=>Mg`<obi-audio-equalizer .volume=${this.volume}></obi-audio-equalizer>`)).with(Ra.THINKING,(()=>Mg`<obi-dot-loader></obi-dot-loader>`)).with(Ra.PAUSED,(()=>MC)).otherwise((()=>MC)),t=this.state===Ra.USER_SPEAKING||this.state===Ra.AGENT_SPEAKING,e=this.state===Ra.PAUSED,i=this.state===Ra.RESEARCHING,n=this.state===Ra.USER_SPEAKING,s=this.state!==Ra.READY||this.navVisible,r=this.state!==Ra.READY||this.navVisible,o=this.position.includes("top")?"down":"up",a=["widget-container",s?"rotated":"",t?"pulse":"",e?"paused-pulse":"",i?"researching":"",n?"user-speaking":""].filter(Boolean).join(" ");return Mg`
|
|
911
|
+
`,gU([np({type:Object})],pU.prototype,"session",2),gU([np({type:Function})],pU.prototype,"onStart",2),gU([np({type:Function})],pU.prototype,"onClose",2),gU([sp()],pU.prototype,"isLoading",2),gU([sp()],pU.prototype,"error",2),gU([sp()],pU.prototype,"startAttempts",2),customElements.get("obi-session-start-modal")||customElements.define("obi-session-start-modal",pU);var vU=Object.defineProperty,mU=Object.getOwnPropertyDescriptor,QU=(A,t,e,i)=>{for(var n,s=i>1?void 0:i?mU(t,e):t,r=A.length-1;r>=0;r--)(n=A[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&vU(t,e,s),s};class CU extends Ap{constructor(){super(),this.apiKey="",this.isActive=!0,this.linkOnlyAccess=!1,this.urlBlacklist=[],this.position="bottom-right",this.user=null,this.state=Ra.READY,this.storedActiveState=void 0,this.showCourseModal=!1,this.showSessionStartModal=!1,this.selectedCourse=null,this.isHovering=!1,this.navVisible=!1,this.activeSession=null,this.volume={speaker:"ASSISTANT",volume:0,spectrum:[]},this.databaseConfig=null,this.configLoaded=!1,this.configAllInCode=!1,this.sessionToken=null,this.roomToken=null,this.roomUrl=null,this.boundSaveSessionData=null,this.obiClient=null,this.closeNavTimeoutRef=null,this.researchingTimeoutRef=null,this.urlCheckInterval=null,this.currentUrl="",this.connectObi=mC((async A=>{if(this.activeSession)return pC("connection_already_exists",{sessionToken:A},"ObiWidget"),void console.log("Connection already exists");pC("session_connection_started",{sessionToken:A},"ObiWidget"),vC({sessionId:A});try{const t=this.createSession(A);if(!t)return void this.handleSessionCreationFailure((()=>this.removeSessionUrlParams()));this.setupSessionEventListeners(t,(()=>this.removeSessionUrlParams())),t.on("screenCaptureRequested",mC((async()=>{pC("screen_capture_requested",{},"ObiWidget");try{const A=(await(t=document.documentElement,e={useCORS:!0,allowTaint:!0,foreignObjectRendering:!0},void 0===e&&(e={}),(function(A,t){return Za(void 0,void 0,void 0,(function(){var e,i,n,s,r,o,a,c,u,h,l,d,B,f,w,g,p,v,m,Q,C,U,F,y,b,E,I,k,H,S,T,O,K,D,M,L,x,_;return za(this,(function(N){switch(N.label){case 0:if(!A||"object"!=typeof A)return[2,Promise.reject("Invalid element provided as first argument")];if(!(e=A.ownerDocument))throw new Error("Element is not attached to a Document");if(!(i=e.defaultView))throw new Error("Document is not attached to a Window");return n={allowTaint:null!==(U=t.allowTaint)&&void 0!==U&&U,imageTimeout:null!==(F=t.imageTimeout)&&void 0!==F?F:15e3,proxy:t.proxy,useCORS:null!==(y=t.useCORS)&&void 0!==y&&y,customIsSameOrigin:t.customIsSameOrigin},s=qa({logging:null===(b=t.logging)||void 0===b||b,cache:t.cache},n),r={windowWidth:null!==(E=t.windowWidth)&&void 0!==E?E:i.innerWidth,windowHeight:null!==(I=t.windowHeight)&&void 0!==I?I:i.innerHeight,scrollX:null!==(k=t.scrollX)&&void 0!==k?k:i.pageXOffset,scrollY:null!==(H=t.scrollY)&&void 0!==H?H:i.pageYOffset},o=new tc(r.scrollX,r.scrollY,r.windowWidth,r.windowHeight),a=new Xw(s,o),c=null!==(S=t.foreignObjectRendering)&&void 0!==S&&S,u={allowTaint:null!==(T=t.allowTaint)&&void 0!==T&&T,onclone:t.onclone,ignoreElements:t.ignoreElements,inlineImages:c,copyStyles:c},a.logger.debug("Starting document clone with size ".concat(o.width,"x").concat(o.height," scrolled to ").concat(-o.left,",").concat(-o.top)),h=new Of(a,A,u),(l=h.clonedReferenceElement)?[4,h.toIFrame(e,o)]:[2,Promise.reject("Unable to find element in cloned iframe")];case 1:return d=N.sent(),B=of(l)||"HTML"===l.tagName?(function(A){var t=A.body,e=A.documentElement;if(!t||!e)throw new Error("Unable to get document size");var i=Math.max(Math.max(t.scrollWidth,e.scrollWidth),Math.max(t.offsetWidth,e.offsetWidth),Math.max(t.clientWidth,e.clientWidth)),n=Math.max(Math.max(t.scrollHeight,e.scrollHeight),Math.max(t.offsetHeight,e.offsetHeight),Math.max(t.clientHeight,e.clientHeight));return new tc(0,0,i,n)})(l.ownerDocument):ec(a,l),f=B.width,w=B.height,g=B.left,p=B.top,v=(function(A,t,e){var i=t.ownerDocument,n=i.documentElement?Yh(A,getComputedStyle(i.documentElement).backgroundColor):Wh.TRANSPARENT,s=i.body?Yh(A,getComputedStyle(i.body).backgroundColor):Wh.TRANSPARENT,r="string"==typeof e?Yh(A,e):null===e?Wh.TRANSPARENT:4294967295;return t===i.documentElement?dh(n)?dh(s)?r:s:n:r})(a,l,t.backgroundColor),m={canvas:t.canvas,backgroundColor:v,scale:null!==(K=null!==(O=t.scale)&&void 0!==O?O:i.devicePixelRatio)&&void 0!==K?K:1,x:(null!==(D=t.x)&&void 0!==D?D:0)+g,y:(null!==(M=t.y)&&void 0!==M?M:0)+p,width:null!==(L=t.width)&&void 0!==L?L:Math.ceil(f),height:null!==(x=t.height)&&void 0!==x?x:Math.ceil(w)},c?(a.logger.debug("Document cloned, using foreign object rendering"),[4,new Pw(a,m).render(l)]):[3,3];case 2:return Q=N.sent(),[3,5];case 3:return a.logger.debug("Document cloned, element located at ".concat(g,",").concat(p," with size ").concat(f,"x").concat(w," using computed rendering")),a.logger.debug("Starting DOM parsing"),C=YB(a,l),v===C.styles.backgroundColor&&(C.styles.backgroundColor=Wh.TRANSPARENT),a.logger.debug("Starting renderer for element at ".concat(m.x,",").concat(m.y," with size ").concat(m.width,"x").concat(m.height)),[4,new xw(a,m).render(C)];case 4:Q=N.sent(),N.label=5;case 5:return(null===(_=t.removeContainer)||void 0===_||_)&&(Of.destroy(d)||a.logger.error("Cannot detach cloned iframe as it is not in the DOM anymore")),a.logger.debug("Finished rendering"),[2,Q]}}))}))})(t,e))).toDataURL("image/png");this.activeSession.emit("screenCaptureComplete",A),pC("screen_capture_completed",{},"ObiWidget")}catch(i){gC(i,{componentName:"ObiWidget",handlerName:"screenCaptureRequested",sessionToken:A}),console.error("[obi] error capturing screen:",i),this.activeSession.emit("screenCaptureComplete","error"),pC("screen_capture_failed",{error:i instanceof Error?i.message:String(i)},"ObiWidget")}var t,e}),"screenCaptureRequested","ObiWidget"));const e=await t.connect();e&&(this.sessionToken=A,this.roomToken=e.token,this.roomUrl=e.url,vC({sessionId:A,widgetState:this.state.toString()}),this.removeSessionUrlParams(),pC("session_connection_established",{sessionToken:A,hasRoomToken:!!e.token},"ObiWidget")),this.activeSession=t}catch(t){console.error("Failed to start session:",t),gC(t,{componentName:"ObiWidget",handlerName:"connectObi",sessionToken:A}),this.handleSessionCreationFailure((()=>this.removeSessionUrlParams()))}}),"connectObi","ObiWidget"),this.handleCloseModals=()=>{this.state=Ra.READY,this.showCourseModal=!1,this.showSessionStartModal=!1},this.handleCourseSelectEvent=A=>{const t=A;this.selectedCourse=t.detail,this.showCourseModal=!1,this.showSessionStartModal=!0},this.handleUrlSessionEvent=mC((async A=>{pC("url_session_event",{sessionToken:A},"ObiWidget");try{if(!this.obiClient)return gC(new Error("ObiClient not initialized"),{componentName:"ObiWidget",handlerName:"handleUrlSessionEvent",sessionToken:A}),void console.error("ObiClient not initialized");const t=await this.obiClient.startSession(A,this.apiKey);if(t.data){const{session:e}=t.data;if(console.log("[obi-sdk] session:",e),pC("session_started",{sessionId:e?.id,sessionToken:A},"ObiWidget"),e){const t=e;this.selectedCourse={id:A,name:t.onboarding_plan?.name||"",description:t.onboarding_plan?.description||""},this.state=Ra.LOADING,this.showSessionStartModal=!0,pC("matching_session_found",{sessionToken:A,hasOnboardingPlan:!!t.onboarding_plan},"ObiWidget")}else console.log("[obi-sdk] no session found with token:",A),pC("no_matching_session",{sessionToken:A},"ObiWidget")}}catch(t){console.error("Failed to fetch session details:",t),gC(t,{componentName:"ObiWidget",handlerName:"handleUrlSessionEvent",sessionToken:A})}}),"handleUrlSessionEvent","ObiWidget"),this.handleSessionStart=mC((async A=>{pC("session_start_requested",{sessionToken:A},"ObiWidget"),this.activeSession&&(pC("session_start_blocked",{sessionToken:A},"ObiWidget"),gC(new Error("Session start blocked"),{componentName:"ObiWidget",handlerName:"handleSessionStart",sessionToken:A}),this.activeSession.disconnect(),this.activeSession=null),this.showSessionStartModal=!1,this.state=Ra.LOADING,vC({widgetState:this.state.toString()}),await this.connectObi(A)}),"handleSessionStart","ObiWidget"),this.checkExistingSession=mC((async()=>{pC("checking_existing_session",{},"ObiWidget");try{const A=JSON.parse(FC.getItem(UC)||"{}"),{sessionToken:t,roomToken:e,roomUrl:i,sessionExpiry:n,obiState:s}=A;if(!t||!e||!i)return void pC("no_existing_session_data",{},"ObiWidget");if(console.log("[obi-sdk] using existing session"),pC("existing_session_data_found",{sessionToken:t,hasExpiry:!!n,obiState:s},"ObiWidget"),n&&new Date(n)<new Date)return this.clearSessionStorage(),void pC("session_expired",{sessionToken:t},"ObiWidget");this.state=Ra.LOADING,vC({sessionId:t,widgetState:this.state.toString()});const r=this.createSession(t);if(!r)return void this.handleSessionCreationFailure((()=>this.clearSessionStorage()));this.setupSessionEventListeners(r,(()=>this.clearSessionStorage())),await r.reconnect(i,e,s)?(this.activeSession=r,this.sessionToken=t,this.roomToken=e,this.roomUrl=i,this.state=s,this.storedActiveState=s,pC("session_reconnected",{sessionToken:t,obiState:s},"ObiWidget")):(this.clearSessionStorage(),pC("session_reconnection_failed",{sessionToken:t},"ObiWidget"))}catch(A){console.error("Error reconnecting to session:",A),gC(A,{componentName:"ObiWidget",handlerName:"checkExistingSession"}),this.handleSessionCreationFailure((()=>this.clearSessionStorage()))}}),"checkExistingSession","ObiWidget");try{CC("ObiWidget").setContext(),this.obiClient=new u({baseUrl:t}),this.currentUrl=window.location.href;const A=()=>{try{this.activeSession&&this.sessionToken&&this.roomToken&&this.roomUrl&&this.saveSessionData()}catch(A){gC(A,{componentName:"ObiWidget",handlerName:"handleUnload"})}};window.addEventListener("beforeunload",A),window.addEventListener("pagehide",A),pC("ObiWidget_constructor_completed",{},"ObiWidget")}catch(A){throw gC(A,{componentName:"ObiWidget",lifecycle:"constructor"}),A}}updateFromConfig(){if(window.obiWidgetConfig){this.apiKey=window.obiWidgetConfig.apiKey||this.apiKey,void 0!==window.obiWidgetConfig.position&&(this.position=window.obiWidgetConfig.position,this.setAttribute("position",this.position)),void 0!==window.obiWidgetConfig.primaryColor&&(this.style.setProperty("--obi-primary",window.obiWidgetConfig.primaryColor),this.generateColorVariables(window.obiWidgetConfig.primaryColor)),void 0!==window.obiWidgetConfig.user&&(this.user=window.obiWidgetConfig.user),void 0!==window.obiWidgetConfig.isActive&&(this.isActive=window.obiWidgetConfig.isActive),void 0!==window.obiWidgetConfig.linkOnlyAccess&&(this.linkOnlyAccess=window.obiWidgetConfig.linkOnlyAccess),void 0!==window.obiWidgetConfig.urlBlacklist&&(this.urlBlacklist=window.obiWidgetConfig.urlBlacklist);const A=void 0!==window.obiWidgetConfig.position,t=void 0!==window.obiWidgetConfig.primaryColor,e=void 0!==window.obiWidgetConfig.linkOnlyAccess,i=void 0!==window.obiWidgetConfig.urlBlacklist;this.configAllInCode=A&&t&&e&&i,this.configAllInCode?(this.configLoaded=!0,this.applyFinalConfiguration()):this.configLoaded||this.fetchDatabaseConfig(),!0===window.obiWidgetConfig.showMenu&&(this.state=Ra.LOADING,this.showCourseModal=!0,window.obiWidgetConfig.showMenu=!1)}else this.configLoaded||this.fetchDatabaseConfig()}generateColorVariables(A){try{const t=Xa(A,"#c4b5fd"),e=Xa(A,"#c76cff"),i=(function(A){try{const t={h:Va(A).h,s:100,l:96};return Ja(t.h,t.s,t.l)}catch(t){return console.warn("Failed to transform to light tint, using fallback:",t),A}})(A),n=Xa(A,"#A06DF9");this.style.setProperty("--obi-secondary",t),this.style.setProperty("--obi-course-selected",e),this.style.setProperty("--obi-course-selected-bg",i),this.style.setProperty("--obi-paused-pulse",n)}catch(t){console.warn("Failed to generate color variables:",t),this.style.setProperty("--obi-secondary","#c4b5fd"),this.style.setProperty("--obi-course-selected","#c76cff"),this.style.setProperty("--obi-course-selected-bg","#fbf3ff"),this.style.setProperty("--obi-paused-pulse","#A06DF9")}}removeSessionUrlParams(){const A=new URL(window.location.href);A.searchParams.delete($a),window.history.replaceState({},"",A.toString()),localStorage.removeItem("obi-url-params")}createSession(A){try{return new Ga({sessionId:A,apiBaseUrl:t})||(console.error("Failed to create session"),null)}catch(e){return console.error("Error creating session:",e),null}}setupSessionEventListeners(A,t){A.on("stateChanged",(t=>{if(t===Ra.RESEARCHING)return this.researchingTimeoutRef&&window.clearTimeout(this.researchingTimeoutRef),this.state=t,this.researchingTimeoutRef=window.setTimeout((()=>{this.researchingTimeoutRef=null;const t=A.getCurrentState();this.state=t,t!==Ra.READY&&(this.storedActiveState=t)}),1500),void(this.storedActiveState=t);null===this.researchingTimeoutRef&&(this.state=t,t!==Ra.READY&&(this.storedActiveState=t))})),A.on("volume",(({speaker:A,spectrum:t,volume:e})=>{this.volume={speaker:A,spectrum:t,volume:e}})),A.on("error",(A=>{console.error("Session error:",A),this.state=Ra.ERROR,this.activeSession=null,t&&t()}))}handleSessionCreationFailure(A){this.state=Ra.ERROR,this.activeSession=null,A&&A()}clearSessionStorage(){FC.removeItem(UC)}handleUrlChange(){this.requestUpdate(),yC(this.urlBlacklist)&&this.activeSession&&this.terminateSession()}saveSessionData(){if(this.activeSession&&this.sessionToken&&this.roomToken&&this.roomUrl){const A=new Date;A.setMinutes(A.getMinutes()+5);const t={sessionToken:this.sessionToken,roomToken:this.roomToken,roomUrl:this.roomUrl,obiState:this.storedActiveState??this.state,sessionExpiry:A.toISOString()};FC.setItem(UC,JSON.stringify(t))}}async sessionConnectionCheck(){const A=(function(){let A={};return A=JSON.parse(localStorage.getItem("obi-url-params")||"{}"),0===Object.keys(A).length&&new URLSearchParams(window.location.search).forEach(((t,e)=>{A[e]=t})),localStorage.removeItem("obi-url-params"),A[$a]})();A?(console.log("[obi-sdk] using magic link"),this.apiKey?await this.handleUrlSessionEvent(A):(console.log("[obi-sdk] API key not ready, retrying..."),setTimeout((()=>{this.apiKey&&this.handleUrlSessionEvent(A)}),100))):await this.checkExistingSession()}connectedCallback(){super.connectedCallback(),this.updateFromConfig(),this.addEventListener("obi-config-updated",this.handleConfigUpdate.bind(this)),this.setAttribute("position",this.position),this.boundSaveSessionData=this.saveSessionData.bind(this),window.addEventListener("beforeunload",this.boundSaveSessionData),window.addEventListener("pagehide",this.boundSaveSessionData),this.isActive&&(this.urlCheckInterval=window.setInterval((()=>{this.currentUrl!==window.location.href&&(this.currentUrl=window.location.href,this.handleUrlChange())}),1e3)),this.addEventListener("course-select",this.handleCourseSelectEvent)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("obi-config-updated",this.handleConfigUpdate.bind(this)),null!==this.closeNavTimeoutRef&&window.clearTimeout(this.closeNavTimeoutRef),null!==this.researchingTimeoutRef&&(window.clearTimeout(this.researchingTimeoutRef),this.researchingTimeoutRef=null),this.boundSaveSessionData&&(window.removeEventListener("beforeunload",this.boundSaveSessionData),window.removeEventListener("pagehide",this.boundSaveSessionData)),null!==this.urlCheckInterval&&(clearInterval(this.urlCheckInterval),this.urlCheckInterval=null),this.removeSessionUrlParams()}handleConfigUpdate(A){const t=A.detail.isActive&&!this.isActive;this.updateFromConfig(),t&&!yC(this.urlBlacklist)&&this.sessionConnectionCheck(),this.requestUpdate()}handleMouseEnter(){this.isHovering=!0,this.navVisible=!0}handleMouseLeave(){this.isHovering=!1,null!==this.closeNavTimeoutRef&&window.clearTimeout(this.closeNavTimeoutRef),this.closeNavTimeoutRef=window.setTimeout((()=>{this.isHovering||(this.navVisible=!1),this.closeNavTimeoutRef=null}),300)}terminateSession(){this.clearSessionStorage(),this.sessionToken=null,this.roomToken=null,this.roomUrl=null,null!==this.researchingTimeoutRef&&(window.clearTimeout(this.researchingTimeoutRef),this.researchingTimeoutRef=null),this.activeSession&&(this.activeSession.disconnect(),this.activeSession=null),this.state=Ra.READY}handleItemSelect(A,t){"experiences"!==A?xa([A,t]).with(["pause",!0],(()=>{this.activeSession?.pauseRecording()})).with(["pause",!1],(()=>{this.activeSession?.resumeRecording()})).with(["activate",!1],(()=>{this.terminateSession()})).otherwise((()=>{})):this.showCourseModal=!0}async fetchDatabaseConfig(){if(!this.apiKey)return this.configLoaded=!0,void this.applyFinalConfiguration();try{const A=`obi-widget-config-${this.apiKey}`,t=localStorage.getItem(A),e=localStorage.getItem(`${A}-timestamp`);if(t&&e&&Date.now()-parseInt(e,10)<6e5){const A=JSON.parse(t);return this.databaseConfig=A,this.configLoaded=!0,void this.applyFinalConfiguration()}const i=new AbortController,n=setTimeout((()=>i.abort()),3e3),s=await this.obiClient.getOnboardeeWidgetConfig(this.apiKey,i.signal);if(clearTimeout(n),s.error){if(404===s.response?.status)return localStorage.removeItem(A),localStorage.removeItem(`${A}-timestamp`),this.databaseConfig=null,this.configLoaded=!0,void this.applyFinalConfiguration();throw new Error(`HTTP ${s.response?.status||"Unknown error"}`)}const r=s.data;localStorage.setItem(A,JSON.stringify(r)),localStorage.setItem(`${A}-timestamp`,Date.now().toString()),this.databaseConfig=r,this.configLoaded=!0,this.applyFinalConfiguration()}catch(A){A instanceof Error&&"AbortError"===A.name?console.warn("Widget config fetch timed out, using defaults"):console.warn("Failed to fetch widget config from database:",A),this.databaseConfig=null,this.configLoaded=!0,this.applyFinalConfiguration()}}applyFinalConfiguration(){const A=window.obiWidgetConfig,t=this.databaseConfig;this.user=A?.user||this.user,this.position=A?.position||t?.position||this.position,this.setAttribute("position",this.position),void 0!==A?.isActive&&(this.isActive=A.isActive),void 0!==A?.linkOnlyAccess?this.linkOnlyAccess=A.linkOnlyAccess:void 0!==t?.linkOnlyAccess&&(this.linkOnlyAccess=t.linkOnlyAccess);const e=A?.urlBlacklist||[],i=t?.urlBlacklist||[];if(e.length>0||i.length>0){const A=[...e,...i];this.urlBlacklist=[...new Set(A)]}const n=A?.primaryColor||t?.primaryColor||Pa;this.style.setProperty("--obi-primary",n),this.generateColorVariables(n),this.isActive&&!yC(this.urlBlacklist)&&this.sessionConnectionCheck()}render(){if(!this.configLoaded)return _g;if(!this.isActive)return _g;if(this.linkOnlyAccess&&this.state===Ra.READY)return _g;if(yC(this.urlBlacklist))return _g;const A=xa(this.state).with(Ra.LOADING,(()=>Mg`<obi-dot-loader></obi-dot-loader>`)).with(Ra.RESEARCHING,(()=>Mg`<obi-searching-loader></obi-searching-loader>`)).with(Da.union(Ra.USER_SPEAKING,Ra.AGENT_SPEAKING),(()=>Mg`<obi-audio-equalizer .volume=${this.volume}></obi-audio-equalizer>`)).with(Ra.THINKING,(()=>Mg`<obi-dot-loader></obi-dot-loader>`)).with(Ra.PAUSED,(()=>MC)).otherwise((()=>MC)),t=this.state===Ra.USER_SPEAKING||this.state===Ra.AGENT_SPEAKING,e=this.state===Ra.PAUSED,i=this.state===Ra.RESEARCHING,n=this.state===Ra.USER_SPEAKING,s=this.state!==Ra.READY||this.navVisible,r=this.state!==Ra.READY||this.navVisible,o=this.position.includes("top")?"down":"up",a=["widget-container",s?"rotated":"",t?"pulse":"",e?"paused-pulse":"",i?"researching":"",n?"user-speaking":""].filter(Boolean).join(" ");return Mg`
|
|
912
912
|
<div
|
|
913
913
|
class="${a}"
|
|
914
914
|
@mouseenter=${this.handleMouseEnter}
|
|
@@ -1084,4 +1084,4 @@
|
|
|
1084
1084
|
box-shadow: 0px 0px 18px 6px
|
|
1085
1085
|
color-mix(in srgb, var(--obi-paused-pulse, #a06df9) 75%, transparent);
|
|
1086
1086
|
}
|
|
1087
|
-
`,QU([sp()],CU.prototype,"apiKey",2),QU([sp()],CU.prototype,"isActive",2),QU([sp()],CU.prototype,"linkOnlyAccess",2),QU([sp()],CU.prototype,"urlBlacklist",2),QU([sp()],CU.prototype,"position",2),QU([sp()],CU.prototype,"user",2),QU([sp()],CU.prototype,"state",2),QU([sp()],CU.prototype,"storedActiveState",2),QU([sp()],CU.prototype,"showCourseModal",2),QU([sp()],CU.prototype,"showSessionStartModal",2),QU([sp()],CU.prototype,"selectedCourse",2),QU([sp()],CU.prototype,"isHovering",2),QU([sp()],CU.prototype,"navVisible",2),QU([sp()],CU.prototype,"activeSession",2),QU([sp()],CU.prototype,"volume",2),QU([sp()],CU.prototype,"databaseConfig",2),QU([sp()],CU.prototype,"configLoaded",2),QU([sp()],CU.prototype,"
|
|
1087
|
+
`,QU([sp()],CU.prototype,"apiKey",2),QU([sp()],CU.prototype,"isActive",2),QU([sp()],CU.prototype,"linkOnlyAccess",2),QU([sp()],CU.prototype,"urlBlacklist",2),QU([sp()],CU.prototype,"position",2),QU([sp()],CU.prototype,"user",2),QU([sp()],CU.prototype,"state",2),QU([sp()],CU.prototype,"storedActiveState",2),QU([sp()],CU.prototype,"showCourseModal",2),QU([sp()],CU.prototype,"showSessionStartModal",2),QU([sp()],CU.prototype,"selectedCourse",2),QU([sp()],CU.prototype,"isHovering",2),QU([sp()],CU.prototype,"navVisible",2),QU([sp()],CU.prototype,"activeSession",2),QU([sp()],CU.prototype,"volume",2),QU([sp()],CU.prototype,"databaseConfig",2),QU([sp()],CU.prototype,"configLoaded",2),QU([sp()],CU.prototype,"configAllInCode",2),customElements.get("obi-widget")||customElements.define("obi-widget",CU),customElements.get("obi-widget")||customElements.define("obi-widget",CU);const bU=QC((function(){const A=window;let t=[];"function"!=typeof A.ObiSDK&&"object"!=typeof A.ObiSDK||(t=A.ObiSDK.q||[]),A.obiWidgetConfig&&vC({apiKey:A.obiWidgetConfig.apiKey,userId:A.obiWidgetConfig.user?.id,userEmail:A.obiWidgetConfig.user?.email,userMetadata:A.obiWidgetConfig.user?.metadata}),A.ObiSDK=function(t,e){try{"update"===t&&e&&(A.obiWidgetConfig={...A.obiWidgetConfig,...e},e.user&&vC({userId:e.user.id,userEmail:e.user.email,userMetadata:e.user.metadata}),document.querySelectorAll("obi-widget").forEach((A=>{A.dispatchEvent(new CustomEvent("obi-config-updated",{detail:e,bubbles:!0,composed:!0}))})),pC("SDK_config_updated",{hasUser:!!e.user,configKeys:Object.keys(e)},"init"))}catch(i){throw gC(i,{componentName:"init",handlerName:"ObiSDK.update",command:t}),i}},A.ObiSDK.q=t}),"mountSDK","init"),EU=mC((async function(){return yU((async()=>{if(document.querySelector("obi-widget"))return void pC("widget_already_exists",{},"init");if(!document.body)throw new Error("document.body not available");const A=document.createElement("obi-widget");document.body.appendChild(A),console.log("[obi-sdk] widget mounted"),pC("widget_mounted",{},"init")}),"widget mounting")}),"mountWidget","init"),IU=QC((function(){const A=window;if(A.ObiSDK&&Array.isArray(A.ObiSDK.q)){const t=A.ObiSDK.q.length;pC("queue_processing",{queueLength:t},"init"),(A.ObiSDK.q||[]).forEach((t=>{A.ObiSDK(...t)})),A.ObiSDK.q=[],t>0&&pC("queue_processed",{queueLength:t},"init")}}),"processQueue","init"),kU=mC((async function(){await HU("https://fonts.cdnfonts.com/css/satoshi"),await HU("https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap")}),"loadFonts","init"),HU=mC((async function(A){return yU((async()=>{if(!document.head)throw new Error("document.head not available");const t=document.createElement("link");t.href=A,t.rel="stylesheet",document.head.appendChild(t),pC("font_loaded",{fontUrl:A},"init")}),"font loading")}),"loadFont","init"),SU=mC((async function(){pC("SDK_initialization_started",{},"init"),await new Promise((A=>setTimeout(A,500))),bU(),await kU(),await EU(),IU(),pC("SDK_initialization_completed",{},"init")}),"safeInitialize","init"),TU=mC((async function(){"loading"===document.readyState?(pC("DOM_not_ready",{},"init"),document.addEventListener("DOMContentLoaded",(async()=>{try{await SU()}catch(A){gC(A,{componentName:"init",handlerName:"DOMContentLoaded"}),console.error("[obi-sdk] initialization failed:",A)}}))):(pC("DOM_ready",{},"init"),await SU())}),"initializeObiWidget","init");try{vC({componentName:"init"}),pC("SDK_script_loaded",{},"init"),TU().catch((A=>{gC(A,{componentName:"init",handlerName:"initializeObiWidget"}),console.error("[obi-sdk] initialization failed:",A)}))}catch(OU){gC(OU,{componentName:"init",handlerName:"top-level"}),console.error("[obi-sdk] initialization failed:",OU)}A.ObiWidget=CU,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})})({});//# sourceMappingURL=obi-sdk.standalone.iife.js.map
|