@convai/web-widget 0.1.3 → 0.1.4
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/README.md +5 -5
- package/package.json +1 -1
- package/runtime.js +11341 -6506
- package/v1.js +2 -2
package/v1.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(){var
|
|
1
|
+
(function(){var H=c=>{throw TypeError(c)};var O=(c,u,o)=>u.has(c)||H("Cannot "+o);var r=(c,u,o)=>(O(c,u,"read from private field"),o?o.call(c):u.get(c)),m=(c,u,o)=>u.has(c)?H("Cannot add the same private member more than once"):u instanceof WeakSet?u.add(c):u.set(c,o),s=(c,u,o,E)=>(O(c,u,"write to private field"),E?E.call(c,o):u.set(c,o),o),f=(c,u,o)=>(O(c,u,"access private method"),o);(function(){"use strict";var C,g,x,b,y,S,A,k,$,d,Z,D,J,N,M;const c=["bottom-right","bottom-left","top-right","top-left","inline"],u=["none","hover","idle"],o="https://docs.convai.com/embed",E=(e,i)=>e.hasAttribute(i),h=(e,i)=>{var t;return(t=e.getAttribute(i))!=null?t:void 0};function R(e,i,t){return i.includes(e)?e:t}function K(e){const i=h(e,"publication-id"),t=h(e,"character-id"),n=h(e,"token-endpoint"),a=h(e,"connect-endpoint"),p=h(e,"api-key"),l=h(e,"publication-api-url"),v=h(e,"core-url");if(i){if(t)return{ok:!1,message:`<convai-widget> cannot take both publication-id and character-id. A published integration names only the publication. See ${o}`};if(n||a||p)return{ok:!1,message:`<convai-widget> cannot take publication-id together with token-endpoint, connect-endpoint or api-key: a published session mints its own launch grant. See ${o}`}}else{if(!t)return{ok:!1,message:`<convai-widget> requires a character-id, or a publication-id. See ${o}`};if(!n&&!a&&!p)return{ok:!1,message:`<convai-widget> requires one of token-endpoint (recommended), connect-endpoint, or api-key (development only). See ${o}`}}let j;const z=h(e,"end-user-metadata");if(z!==void 0)try{const w=JSON.parse(z);if(w===null||typeof w!="object"||Array.isArray(w))return{ok:!1,message:"end-user-metadata must be a JSON object"};j=w}catch{return{ok:!1,message:"end-user-metadata is not valid JSON"}}for(const[w,F]of[["publication-api-url",l],["core-url",v]]){if(F===void 0)continue;let U;try{U=new URL(F)}catch{return{ok:!1,message:`${w} must be an absolute URL. See ${o}`}}if(U.protocol!=="https:"&&U.protocol!=="http:")return{ok:!1,message:`${w} must use HTTP or HTTPS. See ${o}`};if(U.username||U.password)return{ok:!1,message:`${w} must not include credentials. See ${o}`}}return{ok:!0,config:{characterId:t,publicationId:i,publicationApiUrl:l,coreUrl:v,tokenEndpoint:n,connectEndpoint:a,apiKey:p,endUserId:h(e,"end-user-id"),endUserMetadata:j,placement:R(h(e,"placement"),c,"bottom-right"),preload:R(h(e,"preload"),u,"none"),startOpen:E(e,"start-open"),startWithAudio:i?!1:E(e,"start-with-audio"),accent:h(e,"accent"),greeting:h(e,"greeting"),launcherLabel:h(e,"launcher-label"),avatarSrc:h(e,"avatar-src"),disabled:E(e,"disabled"),debug:E(e,"debug")}}}const q=`
|
|
2
2
|
:host { all: initial; }
|
|
3
3
|
.convai-launcher {
|
|
4
4
|
position: fixed;
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
border-radius: inherit;
|
|
41
41
|
object-fit: cover;
|
|
42
42
|
}
|
|
43
|
-
`,Z={"bottom-right":"bottom: 24px; right: 24px;","bottom-left":"bottom: 24px; left: 24px;","top-right":"top: 24px; right: 24px;","top-left":"top: 24px; left: 24px;"},D=[["M0 0 C.7-.01 1.4-.01 2.12-.02 C4.44-.04 6.75-.05 9.07-.06 C9.86-.07 10.65-.07 11.47-.07 C15.67-.09 19.86-.11 24.06-.12 C28.38-.13 32.71-.16 37.03-.2 C40.36-.23 43.7-.24 47.03-.24 C48.63-.25 50.22-.26 51.81-.28 C69.27-.47 69.27-.47 75.59 5.62 C80.22 10.86 81.34 14.49 81.36 21.42 C81.36 22.14 81.37 22.87 81.38 23.61 C81.39 25.99 81.39 28.38 81.39 30.76 C81.39 32.42 81.39 34.09 81.4 35.75 C81.41 39.23 81.41 42.71 81.4 46.19 C81.4 50.65 81.41 55.1 81.44 59.56 C81.45 62.99 81.45 66.42 81.45 69.85 C81.45 71.49 81.45 73.13 81.46 74.78 C81.48 77.08 81.47 79.37 81.46 81.67 C81.46 82.98 81.46 84.29 81.46 85.64 C80.84 91.47 78.53 95.26 74.09 98.99 C73.4 99.57 72.72 100.16 72.02 100.76 C68.47 103.36 65.36 103.31 61.1 103.32 C59.87 103.33 58.64 103.33 57.37 103.34 C56.71 103.34 56.05 103.34 55.38 103.35 C53.31 103.35 51.24 103.37 49.17 103.39 C43.28 103.44 37.4 103.49 31.52 103.5 C27.91 103.51 24.31 103.54 20.71 103.58 C19.34 103.6 17.98 103.6 16.61 103.6 C8.73 103.59 1.87 103.81-4.91 108.18 C-7.72 111.13-9.15 114.52-10.91 118.18 C-11.29 118.93-11.66 119.69-12.04 120.47 C-16.08 130.42-15.44 140.76-15.37 151.33 C-15.35 154.9-15.35 158.47-15.36 162.05 C-15.38 170.92-15.37 179.79-15.34 188.66 C-15.32 196.18-15.32 203.69-15.34 211.21 C-15.35 214.72-15.32 218.22-15.3 221.73 C-15.3 223.9-15.31 226.06-15.32 228.23 C-15.3 229.19-15.29 230.16-15.27 231.15 C-15.35 238.01-16.95 243.5-20.91 249.18 C-26.05 253.49-30.94 255.29-37.62 255.33 C-38.56 255.34-39.5 255.35-40.47 255.36 C-41.5 255.36-42.53 255.37-43.58 255.37 C-44.67 255.38-45.76 255.39-46.88 255.39 C-50.48 255.42-54.07 255.44-57.67 255.45 C-58.9 255.46-60.13 255.46-61.4 255.47 C-67.24 255.49-73.09 255.51-78.93 255.52 C-84.99 255.54-91.04 255.56-97.1 255.61 C-103.61 255.66-110.12 255.68-116.63 255.69 C-119.1 255.7-121.58 255.71-124.05 255.74 C-127.53 255.77-131 255.77-134.47 255.76 C-135.48 255.78-136.5 255.79-137.54 255.81 C-144.59 255.75-150.06 254.19-155.91 250.18 C-160.12 245.77-162.03 241.44-162.07 235.39 C-162.08 233.91-162.08 233.91-162.09 232.4 C-162.1 231.32-162.1 230.24-162.11 229.13 C-162.12 227.99-162.12 226.85-162.13 225.68 C-162.16 221.91-162.17 218.13-162.19 214.35 C-162.19 213.06-162.2 211.77-162.2 210.45 C-162.23 205.03-162.24 199.61-162.26 194.19 C-162.27 186.44-162.31 178.68-162.36 170.93 C-162.41 164.81-162.42 158.69-162.43 152.58 C-162.43 149.98-162.45 147.38-162.47 144.78 C-162.51 141.15-162.51 137.51-162.5 133.87 C-162.51 132.8-162.53 131.73-162.55 130.63 C-162.49 123.86-161.3 119.41-156.91 114.18 C-150.7 108.27-145.09 107.89-136.9 107.94 C-135.89 107.94-134.89 107.93-133.85 107.93 C-131.67 107.93-129.49 107.93-127.31 107.93 C-123.85 107.94-120.39 107.93-116.92 107.92 C-107.09 107.88-97.25 107.86-87.41 107.87 C-81.38 107.88-75.36 107.86-69.34 107.83 C-67.05 107.82-64.76 107.82-62.48 107.83 C-43.45 108.09-43.45 108.09-26.79 99.74 C-23.11 94.71-22.67 89.88-22.68 83.77 C-22.67 83.05-22.67 82.34-22.67 81.6 C-22.67 80.05-22.67 78.51-22.67 76.96 C-22.68 74.5-22.67 72.05-22.65 69.59 C-22.62 62.61-22.6 55.63-22.61 48.65 C-22.62 44.37-22.6 40.09-22.56 35.81 C-22.56 34.18-22.56 32.56-22.57 30.94 C-22.62 21.93-22.61 13.7-16.91 6.18 C-11.69 1.25-7.03 .05 0 0 Z","#1EB453","translate(275.91,92.82)"],["M0 0 C.71-.01 1.42-.01 2.15-.02 C4.49-.04 6.83-.05 9.18-.06 C9.98-.07 10.78-.07 11.61-.07 C15.86-.09 20.11-.11 24.36-.12 C28.73-.13 33.11-.16 37.48-.2 C40.86-.23 44.24-.24 47.62-.24 C49.23-.25 50.84-.26 52.45-.28 C61.88-.38 69.23-.41 76.9 5.82 C77.35 6.35 77.8 6.88 78.25 7.43 C78.95 8.21 78.95 8.21 79.65 9.01 C84.03 16.75 83.19 25.92 83.18 34.52 C83.18 36.01 83.19 37.5 83.19 38.99 C83.2 42.11 83.2 45.22 83.2 48.34 C83.19 52.31 83.21 56.28 83.23 60.25 C83.24 63.33 83.25 66.41 83.24 69.49 C83.24 70.95 83.25 72.41 83.26 73.88 C83.37 93 83.37 93 77.13 100.05 C76.68 100.59 76.23 101.12 75.77 101.67 C70.72 105.7 65.71 106.55 59.39 106.56 C58.67 106.57 57.96 106.57 57.23 106.58 C55.69 106.59 54.15 106.59 52.62 106.59 C50.18 106.58 47.75 106.6 45.32 106.62 C39.27 106.66 33.23 106.67 27.19 106.68 C22.07 106.69 16.95 106.72 11.84 106.76 C9.45 106.77 7.05 106.77 4.66 106.76 C3.19 106.77 1.72 106.78 .24 106.79 C-1.04 106.79-2.32 106.8-3.64 106.8 C-7.42 107.21-9.82 108.35-13.12 110.18 C-13.78 110.18-14.44 110.18-15.12 110.18 C-17.52 115.84-17.42 121.16-17.43 127.2 C-17.45 129.38-17.48 131.55-17.5 133.73 C-17.53 137.14-17.56 140.56-17.58 143.97 C-17.6 147.27-17.64 150.58-17.68 153.89 C-17.68 154.9-17.68 155.91-17.68 156.95 C-17.78 164.52-19.03 169.99-23.25 176.43 C-29.46 182.37-36.31 183.79-44.69 183.67 C-46 183.68-46 183.68-47.35 183.68 C-49.19 183.68-51.03 183.66-52.88 183.64 C-55.68 183.61-58.48 183.62-61.28 183.64 C-63.08 183.63-64.89 183.62-66.69 183.61 C-67.51 183.61-68.34 183.62-69.19 183.62 C-75.59 183.52-81.4 182.53-86.4 178.2 C-86.95 177.51-87.49 176.83-88.06 176.11 C-88.62 175.42-89.19 174.73-89.77 174.02 C-91.96 171.04-92.26 169.23-92.31 165.58 C-92.33 164.62-92.35 163.67-92.36 162.68 C-92.41 158.3-92.45 153.92-92.47 149.53 C-92.49 147.22-92.51 144.91-92.55 142.61 C-92.61 139.27-92.63 135.94-92.64 132.61 C-92.67 131.58-92.69 130.56-92.71 129.5 C-92.69 122.84-91.55 118.27-87.12 113.18 C-82.86 109.85-79.42 108.07-74.02 108.02 C-73.2 108.01-72.38 108-71.53 107.99 C-70.65 107.98-69.76 107.97-68.85 107.97 C-66.97 107.94-65.1 107.91-63.22 107.88 C-60.26 107.84-57.31 107.8-54.35 107.78 C-51.5 107.75-48.64 107.7-45.79 107.65 C-44.47 107.65-44.47 107.65-43.13 107.64 C-38.07 107.54-34.48 107.02-30.12 104.18 C-28.39 101.62-28.39 101.62-27.31 98.68 C-26.91 97.72-26.51 96.76-26.1 95.77 C-24.41 91.31-24 87.99-23.99 83.2 C-23.99 82.5-23.99 81.79-23.99 81.06 C-23.98 79.53-23.98 77.99-23.98 76.46 C-23.98 73.19-23.96 69.92-23.94 66.65 C-23.9 60.56-23.87 54.47-23.87 48.38 C-23.87 44.15-23.85 39.91-23.81 35.67 C-23.8 34.06-23.8 32.45-23.8 30.85 C-23.84 21.86-23.77 13.7-18.12 6.18 C-12.5 .77-7.53 .06 0 0 Z","#1EB453","translate(92.12,53.82)"],["M0 0 C.66 .33 1.32 .66 2 1 C.9 2.3-.2 3.59-1.31 4.88 C-1.93 5.59-2.54 6.31-3.18 7.05 C-5 9-5 9-8 11 C-6.6 6.56-4.4 4.13-1 1 C-.67 .67-.34 .34 0 0 Z","currentColor","translate(264,95)"],["M0 0 C.66 .33 1.32 .66 2 1 C-.64 3.64-3.28 6.28-6 9 C-6 6-6 6-3.56 3.38 C-2.72 2.59-1.87 1.81-1 1 C-.67 .67-.34 .34 0 0 Z","currentColor","translate(79,56)"]],q="http://www.w3.org/2000/svg";function J(){const n=document.createElementNS(q,"svg");n.setAttribute("width","32px"),n.setAttribute("height","32px"),n.setAttribute("viewBox","0 0 384 384"),n.setAttribute("fill","currentColor"),n.setAttribute("style","color: var(--convai-accent, #1EB453)"),n.setAttribute("aria-hidden","true");for(const[r,t,e]of D){const a=document.createElementNS(q,"path");a.setAttribute("d",r),a.setAttribute("fill",t),a.setAttribute("transform",e),n.appendChild(a)}return n}function H(n){if("adoptedStyleSheets"in n&&typeof CSSStyleSheet!="undefined")try{const t=new CSSStyleSheet;t.replaceSync(I),n.adoptedStyleSheets=[...n.adoptedStyleSheets,t];return}catch{}const r=document.createElement("style");r.textContent=I,n.appendChild(r)}function K(n,r,t){var C;H(n);const e=document.createElement("div");e.className="convai-launcher",e.dataset.placement=r.placement,e.setAttribute("part","launcher"),r.placement!=="inline"&&(e.style.cssText=Z[r.placement]),r.accent&&e.style.setProperty("--convai-accent",r.accent);const a=document.createElement("button");if(a.className="convai-launcher__button",a.type="button",a.setAttribute("aria-label",(C=r.launcherLabel)!=null?C:"Open chat"),r.avatarSrc){const c=document.createElement("img");c.className="convai-launcher__avatar",c.src=r.avatarSrc,c.alt="",a.appendChild(c)}else a.appendChild(J());if(a.addEventListener("click",t),r.launcherLabel){const c=document.createElement("span");c.className="convai-launcher__label",c.textContent=r.launcherLabel;const m=r.placement.endsWith("right");m&&e.appendChild(c),e.appendChild(a),m||e.appendChild(c)}else e.appendChild(a);return n.appendChild(e),{element:e,remove:()=>e.remove()}}const $=new WeakMap,B=64,N=new Set(["","none","auto","normal"]);function G(n){var r;for(let t=n.parentElement;t;t=t.parentElement){const e=getComputedStyle(t),a=e.willChange;if(!N.has(e.transform)||!N.has(e.filter)||!N.has(e.perspective)||!N.has((r=e.backdropFilter)!=null?r:"")||!N.has(e.contain)||/transform|perspective|filter/.test(a))return t}return null}const M=class M extends HTMLElement{constructor(){super(...arguments);f(this,l);f(this,u,null);f(this,b,null);f(this,x,!1);f(this,v,null);f(this,y,[]);f(this,S,null);f(this,k,!1);f(this,E,!1);f(this,A,!1)}connectedCallback(){try{g(this,l,R).call(this)}catch(t){try{this.emitError("runtime",`widget failed to start: ${String(t)}`)}catch{}}}disconnectedCallback(){s(this,k,!1),this.destroy()}async load(){return i(this,S)?i(this,S):(s(this,S,g(this,l,F).call(this)),i(this,S))}get ready(){return i(this,x)}get client(){var t,e;return(e=(t=i(this,b))==null?void 0:t.client)!=null?e:null}get characterId(){return this.getAttribute("character-id")}get placement(){var t;return(t=this.getAttribute("placement"))!=null?t:"bottom-right"}get preload(){var t;return(t=this.getAttribute("preload"))!=null?t:"none"}markReady(t){s(this,b,t),s(this,x,!0);const e=i(this,y);s(this,y,[]),s(this,E,!1);for(const a of e)try{a(t)}catch(C){try{this.emitError("runtime",`queued call failed: ${String(C)}`)}catch{}}this.emit("convai-ready")}get config(){return i(this,u)}open(){g(this,l,U).call(this),g(this,l,L).call(this,t=>t.open())}close(){g(this,l,L).call(this,t=>t.close())}toggle(){g(this,l,U).call(this),g(this,l,L).call(this,t=>t.toggle())}sendMessage(t){g(this,l,U).call(this),g(this,l,L).call(this,e=>e.sendMessage(t))}destroy(){var t,e;s(this,y,[]),s(this,E,!1);try{(t=i(this,b))==null||t.destroy()}catch{}s(this,b,null),s(this,x,!1),(e=i(this,v))==null||e.remove(),s(this,v,null)}emit(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e,bubbles:!0,composed:!0}))}emitError(t,e){try{console.error(`[convai-widget] ${e}`)}catch{}this.emit("convai-error",{code:t,message:e})}};u=new WeakMap,b=new WeakMap,x=new WeakMap,v=new WeakMap,y=new WeakMap,S=new WeakMap,k=new WeakMap,E=new WeakMap,A=new WeakMap,l=new WeakSet,R=function(){var a;let t=$.get(this);if(t){if(i(this,k))return;t.replaceChildren(),t.adoptedStyleSheets=[],s(this,S,null),s(this,u,null),s(this,A,!1)}else t=this.attachShadow({mode:"closed"}),$.set(this,t);s(this,k,!0);const e=P(this);if(!e.ok){this.emitError("config",e.message),this.hasAttribute("debug")&&t.appendChild(document.createTextNode(`convai-widget: ${e.message}`));return}s(this,u,e.config),!i(this,u).disabled&&(s(this,v,K(t,i(this,u),()=>this.open())),i(this,u).preload==="idle"?((a=window.requestIdleCallback)!=null?a:(c=>window.setTimeout(c,2e3)))(()=>void this.load()):i(this,u).preload==="hover"&&i(this,v).element.addEventListener("pointerenter",()=>void this.load(),{once:!0}),i(this,u).startOpen&&this.open(),i(this,u).debug&&i(this,u).placement!=="inline"&&g(this,l,z).call(this))},z=function(){try{const t=G(this);if(!t)return;console.warn(`[convai-widget] <${t.tagName.toLowerCase()}> establishes a containing block (transform / filter / backdrop-filter / perspective / contain / will-change), so the launcher's \`position: fixed\` resolves against it instead of the viewport and may be clipped. Place <convai-widget> as a direct child of <body>, or use placement="inline".`)}catch{}},F=async function(){const t=$.get(this);if(!t||!i(this,u)||!i(this,v))return;const e=M.runtimeUrl;if(!e){this.emitError("runtime","could not resolve the runtime URL");return}let a;try{a=await import(e)}catch{try{a=await import(`${e}?retry=1`)}catch(C){this.emitError("runtime",`failed to load the widget runtime: ${String(C)}`);return}}try{const C=await a.mount({root:t,config:i(this,u),host:this,launcher:i(this,v),emit:(c,m)=>this.emit(c,m),emitError:(c,m)=>this.emitError(c,m),engaged:i(this,A)});this.markReady(C)}catch(C){this.emitError("runtime",`widget failed to start: ${String(C)}`)}},L=function(t){if(i(this,b)){t(i(this,b));return}if(i(this,y).length>=B){i(this,E)||(s(this,E,!0),this.emitError("runtime",`more than ${B} calls were queued before the runtime mounted; further calls are being dropped. The runtime may have failed to load, or destroy() may already have run.`));return}i(this,y).push(t)},U=function(){this.isConnected&&(s(this,A,!0),this.load())},M.runtimeUrl=null;let _=M;function Q(n){if(!n)return null;const r=n.getAttribute("data-runtime-url");return r||(n.src?n.src.replace(/\/v1(\.\w+)?\.js(\?.*)?$/,"/runtime.js"):null)}const V=Q(document.currentScript);_.runtimeUrl=V,customElements.get("convai-widget")||customElements.define("convai-widget",_)})();
|
|
43
|
+
`,G={"bottom-right":"bottom: 24px; right: 24px;","bottom-left":"bottom: 24px; left: 24px;","top-right":"top: 24px; right: 24px;","top-left":"top: 24px; left: 24px;"},Q=[["M0 0 C.7-.01 1.4-.01 2.12-.02 C4.44-.04 6.75-.05 9.07-.06 C9.86-.07 10.65-.07 11.47-.07 C15.67-.09 19.86-.11 24.06-.12 C28.38-.13 32.71-.16 37.03-.2 C40.36-.23 43.7-.24 47.03-.24 C48.63-.25 50.22-.26 51.81-.28 C69.27-.47 69.27-.47 75.59 5.62 C80.22 10.86 81.34 14.49 81.36 21.42 C81.36 22.14 81.37 22.87 81.38 23.61 C81.39 25.99 81.39 28.38 81.39 30.76 C81.39 32.42 81.39 34.09 81.4 35.75 C81.41 39.23 81.41 42.71 81.4 46.19 C81.4 50.65 81.41 55.1 81.44 59.56 C81.45 62.99 81.45 66.42 81.45 69.85 C81.45 71.49 81.45 73.13 81.46 74.78 C81.48 77.08 81.47 79.37 81.46 81.67 C81.46 82.98 81.46 84.29 81.46 85.64 C80.84 91.47 78.53 95.26 74.09 98.99 C73.4 99.57 72.72 100.16 72.02 100.76 C68.47 103.36 65.36 103.31 61.1 103.32 C59.87 103.33 58.64 103.33 57.37 103.34 C56.71 103.34 56.05 103.34 55.38 103.35 C53.31 103.35 51.24 103.37 49.17 103.39 C43.28 103.44 37.4 103.49 31.52 103.5 C27.91 103.51 24.31 103.54 20.71 103.58 C19.34 103.6 17.98 103.6 16.61 103.6 C8.73 103.59 1.87 103.81-4.91 108.18 C-7.72 111.13-9.15 114.52-10.91 118.18 C-11.29 118.93-11.66 119.69-12.04 120.47 C-16.08 130.42-15.44 140.76-15.37 151.33 C-15.35 154.9-15.35 158.47-15.36 162.05 C-15.38 170.92-15.37 179.79-15.34 188.66 C-15.32 196.18-15.32 203.69-15.34 211.21 C-15.35 214.72-15.32 218.22-15.3 221.73 C-15.3 223.9-15.31 226.06-15.32 228.23 C-15.3 229.19-15.29 230.16-15.27 231.15 C-15.35 238.01-16.95 243.5-20.91 249.18 C-26.05 253.49-30.94 255.29-37.62 255.33 C-38.56 255.34-39.5 255.35-40.47 255.36 C-41.5 255.36-42.53 255.37-43.58 255.37 C-44.67 255.38-45.76 255.39-46.88 255.39 C-50.48 255.42-54.07 255.44-57.67 255.45 C-58.9 255.46-60.13 255.46-61.4 255.47 C-67.24 255.49-73.09 255.51-78.93 255.52 C-84.99 255.54-91.04 255.56-97.1 255.61 C-103.61 255.66-110.12 255.68-116.63 255.69 C-119.1 255.7-121.58 255.71-124.05 255.74 C-127.53 255.77-131 255.77-134.47 255.76 C-135.48 255.78-136.5 255.79-137.54 255.81 C-144.59 255.75-150.06 254.19-155.91 250.18 C-160.12 245.77-162.03 241.44-162.07 235.39 C-162.08 233.91-162.08 233.91-162.09 232.4 C-162.1 231.32-162.1 230.24-162.11 229.13 C-162.12 227.99-162.12 226.85-162.13 225.68 C-162.16 221.91-162.17 218.13-162.19 214.35 C-162.19 213.06-162.2 211.77-162.2 210.45 C-162.23 205.03-162.24 199.61-162.26 194.19 C-162.27 186.44-162.31 178.68-162.36 170.93 C-162.41 164.81-162.42 158.69-162.43 152.58 C-162.43 149.98-162.45 147.38-162.47 144.78 C-162.51 141.15-162.51 137.51-162.5 133.87 C-162.51 132.8-162.53 131.73-162.55 130.63 C-162.49 123.86-161.3 119.41-156.91 114.18 C-150.7 108.27-145.09 107.89-136.9 107.94 C-135.89 107.94-134.89 107.93-133.85 107.93 C-131.67 107.93-129.49 107.93-127.31 107.93 C-123.85 107.94-120.39 107.93-116.92 107.92 C-107.09 107.88-97.25 107.86-87.41 107.87 C-81.38 107.88-75.36 107.86-69.34 107.83 C-67.05 107.82-64.76 107.82-62.48 107.83 C-43.45 108.09-43.45 108.09-26.79 99.74 C-23.11 94.71-22.67 89.88-22.68 83.77 C-22.67 83.05-22.67 82.34-22.67 81.6 C-22.67 80.05-22.67 78.51-22.67 76.96 C-22.68 74.5-22.67 72.05-22.65 69.59 C-22.62 62.61-22.6 55.63-22.61 48.65 C-22.62 44.37-22.6 40.09-22.56 35.81 C-22.56 34.18-22.56 32.56-22.57 30.94 C-22.62 21.93-22.61 13.7-16.91 6.18 C-11.69 1.25-7.03 .05 0 0 Z","#1EB453","translate(275.91,92.82)"],["M0 0 C.71-.01 1.42-.01 2.15-.02 C4.49-.04 6.83-.05 9.18-.06 C9.98-.07 10.78-.07 11.61-.07 C15.86-.09 20.11-.11 24.36-.12 C28.73-.13 33.11-.16 37.48-.2 C40.86-.23 44.24-.24 47.62-.24 C49.23-.25 50.84-.26 52.45-.28 C61.88-.38 69.23-.41 76.9 5.82 C77.35 6.35 77.8 6.88 78.25 7.43 C78.95 8.21 78.95 8.21 79.65 9.01 C84.03 16.75 83.19 25.92 83.18 34.52 C83.18 36.01 83.19 37.5 83.19 38.99 C83.2 42.11 83.2 45.22 83.2 48.34 C83.19 52.31 83.21 56.28 83.23 60.25 C83.24 63.33 83.25 66.41 83.24 69.49 C83.24 70.95 83.25 72.41 83.26 73.88 C83.37 93 83.37 93 77.13 100.05 C76.68 100.59 76.23 101.12 75.77 101.67 C70.72 105.7 65.71 106.55 59.39 106.56 C58.67 106.57 57.96 106.57 57.23 106.58 C55.69 106.59 54.15 106.59 52.62 106.59 C50.18 106.58 47.75 106.6 45.32 106.62 C39.27 106.66 33.23 106.67 27.19 106.68 C22.07 106.69 16.95 106.72 11.84 106.76 C9.45 106.77 7.05 106.77 4.66 106.76 C3.19 106.77 1.72 106.78 .24 106.79 C-1.04 106.79-2.32 106.8-3.64 106.8 C-7.42 107.21-9.82 108.35-13.12 110.18 C-13.78 110.18-14.44 110.18-15.12 110.18 C-17.52 115.84-17.42 121.16-17.43 127.2 C-17.45 129.38-17.48 131.55-17.5 133.73 C-17.53 137.14-17.56 140.56-17.58 143.97 C-17.6 147.27-17.64 150.58-17.68 153.89 C-17.68 154.9-17.68 155.91-17.68 156.95 C-17.78 164.52-19.03 169.99-23.25 176.43 C-29.46 182.37-36.31 183.79-44.69 183.67 C-46 183.68-46 183.68-47.35 183.68 C-49.19 183.68-51.03 183.66-52.88 183.64 C-55.68 183.61-58.48 183.62-61.28 183.64 C-63.08 183.63-64.89 183.62-66.69 183.61 C-67.51 183.61-68.34 183.62-69.19 183.62 C-75.59 183.52-81.4 182.53-86.4 178.2 C-86.95 177.51-87.49 176.83-88.06 176.11 C-88.62 175.42-89.19 174.73-89.77 174.02 C-91.96 171.04-92.26 169.23-92.31 165.58 C-92.33 164.62-92.35 163.67-92.36 162.68 C-92.41 158.3-92.45 153.92-92.47 149.53 C-92.49 147.22-92.51 144.91-92.55 142.61 C-92.61 139.27-92.63 135.94-92.64 132.61 C-92.67 131.58-92.69 130.56-92.71 129.5 C-92.69 122.84-91.55 118.27-87.12 113.18 C-82.86 109.85-79.42 108.07-74.02 108.02 C-73.2 108.01-72.38 108-71.53 107.99 C-70.65 107.98-69.76 107.97-68.85 107.97 C-66.97 107.94-65.1 107.91-63.22 107.88 C-60.26 107.84-57.31 107.8-54.35 107.78 C-51.5 107.75-48.64 107.7-45.79 107.65 C-44.47 107.65-44.47 107.65-43.13 107.64 C-38.07 107.54-34.48 107.02-30.12 104.18 C-28.39 101.62-28.39 101.62-27.31 98.68 C-26.91 97.72-26.51 96.76-26.1 95.77 C-24.41 91.31-24 87.99-23.99 83.2 C-23.99 82.5-23.99 81.79-23.99 81.06 C-23.98 79.53-23.98 77.99-23.98 76.46 C-23.98 73.19-23.96 69.92-23.94 66.65 C-23.9 60.56-23.87 54.47-23.87 48.38 C-23.87 44.15-23.85 39.91-23.81 35.67 C-23.8 34.06-23.8 32.45-23.8 30.85 C-23.84 21.86-23.77 13.7-18.12 6.18 C-12.5 .77-7.53 .06 0 0 Z","#1EB453","translate(92.12,53.82)"],["M0 0 C.66 .33 1.32 .66 2 1 C.9 2.3-.2 3.59-1.31 4.88 C-1.93 5.59-2.54 6.31-3.18 7.05 C-5 9-5 9-8 11 C-6.6 6.56-4.4 4.13-1 1 C-.67 .67-.34 .34 0 0 Z","currentColor","translate(264,95)"],["M0 0 C.66 .33 1.32 .66 2 1 C-.64 3.64-3.28 6.28-6 9 C-6 6-6 6-3.56 3.38 C-2.72 2.59-1.87 1.81-1 1 C-.67 .67-.34 .34 0 0 Z","currentColor","translate(79,56)"]],B="http://www.w3.org/2000/svg";function V(){const e=document.createElementNS(B,"svg");e.setAttribute("width","32px"),e.setAttribute("height","32px"),e.setAttribute("viewBox","0 0 384 384"),e.setAttribute("fill","currentColor"),e.setAttribute("style","color: var(--convai-accent, #1EB453)"),e.setAttribute("aria-hidden","true");for(const[i,t,n]of Q){const a=document.createElementNS(B,"path");a.setAttribute("d",i),a.setAttribute("fill",t),a.setAttribute("transform",n),e.appendChild(a)}return e}function W(e){if("adoptedStyleSheets"in e&&typeof CSSStyleSheet!="undefined")try{const t=new CSSStyleSheet;t.replaceSync(q),e.adoptedStyleSheets=[...e.adoptedStyleSheets,t];return}catch{}const i=document.createElement("style");i.textContent=q,e.appendChild(i)}function X(e,i,t){var p;W(e);const n=document.createElement("div");n.className="convai-launcher",n.dataset.placement=i.placement,n.setAttribute("part","launcher"),i.placement!=="inline"&&(n.style.cssText=G[i.placement]),i.accent&&n.style.setProperty("--convai-accent",i.accent);const a=document.createElement("button");if(a.className="convai-launcher__button",a.type="button",a.setAttribute("aria-label",(p=i.launcherLabel)!=null?p:"Open chat"),i.avatarSrc){const l=document.createElement("img");l.className="convai-launcher__avatar",l.src=i.avatarSrc,l.alt="",a.appendChild(l)}else a.appendChild(V());if(a.addEventListener("click",t),i.launcherLabel){const l=document.createElement("span");l.className="convai-launcher__label",l.textContent=i.launcherLabel;const v=i.placement.endsWith("right");v&&n.appendChild(l),n.appendChild(a),v||n.appendChild(l)}else n.appendChild(a);return e.appendChild(n),{element:n,remove:()=>n.remove()}}const I=new WeakMap,P=64,L=new Set(["","none","auto","normal"]);function Y(e){var i;for(let t=e.parentElement;t;t=t.parentElement){const n=getComputedStyle(t),a=n.willChange;if(!L.has(n.transform)||!L.has(n.filter)||!L.has(n.perspective)||!L.has((i=n.backdropFilter)!=null?i:"")||!L.has(n.contain)||/transform|perspective|filter/.test(a))return t}return null}const _=class _ extends HTMLElement{constructor(){super(...arguments);m(this,d);m(this,C,null);m(this,g,null);m(this,x,!1);m(this,b,null);m(this,y,[]);m(this,S,null);m(this,A,!1);m(this,k,!1);m(this,$,!1)}connectedCallback(){try{f(this,d,Z).call(this)}catch(t){try{this.emitError("runtime",`widget failed to start: ${String(t)}`)}catch{}}}disconnectedCallback(){s(this,A,!1),this.destroy()}async load(){return r(this,S)?r(this,S):(s(this,S,f(this,d,J).call(this)),r(this,S))}get ready(){return r(this,x)}get client(){var t,n;return(n=(t=r(this,g))==null?void 0:t.client)!=null?n:null}get characterId(){return this.getAttribute("character-id")}get placement(){var t;return(t=this.getAttribute("placement"))!=null?t:"bottom-right"}get preload(){var t;return(t=this.getAttribute("preload"))!=null?t:"none"}markReady(t){s(this,g,t),s(this,x,!0);const n=r(this,y);s(this,y,[]),s(this,k,!1);for(const a of n)try{a(t)}catch(p){try{this.emitError("runtime",`queued call failed: ${String(p)}`)}catch{}}this.emit("convai-ready")}get config(){return r(this,C)}open(){f(this,d,M).call(this),f(this,d,N).call(this,t=>t.open())}close(){f(this,d,N).call(this,t=>t.close())}toggle(){f(this,d,M).call(this),f(this,d,N).call(this,t=>t.toggle())}sendMessage(t){f(this,d,M).call(this),f(this,d,N).call(this,n=>n.sendMessage(t))}destroy(){var t,n;s(this,y,[]),s(this,k,!1);try{(t=r(this,g))==null||t.destroy()}catch{}s(this,g,null),s(this,x,!1),(n=r(this,b))==null||n.remove(),s(this,b,null)}emit(t,n){this.dispatchEvent(new CustomEvent(t,{detail:n,bubbles:!0,composed:!0}))}emitError(t,n){try{console.error(`[convai-widget] ${n}`)}catch{}this.emit("convai-error",{code:t,message:n})}};C=new WeakMap,g=new WeakMap,x=new WeakMap,b=new WeakMap,y=new WeakMap,S=new WeakMap,A=new WeakMap,k=new WeakMap,$=new WeakMap,d=new WeakSet,Z=function(){var a;let t=I.get(this);if(t){if(r(this,A))return;t.replaceChildren(),t.adoptedStyleSheets=[],s(this,S,null),s(this,C,null),s(this,$,!1)}else t=this.attachShadow({mode:"closed"}),I.set(this,t);s(this,A,!0);const n=K(this);if(!n.ok){this.emitError("config",n.message),this.hasAttribute("debug")&&t.appendChild(document.createTextNode(`convai-widget: ${n.message}`));return}s(this,C,n.config),!r(this,C).disabled&&(s(this,b,X(t,r(this,C),()=>this.open())),r(this,C).preload==="idle"?((a=window.requestIdleCallback)!=null?a:(l=>window.setTimeout(l,2e3)))(()=>void this.load()):r(this,C).preload==="hover"&&r(this,b).element.addEventListener("pointerenter",()=>void this.load(),{once:!0}),r(this,C).startOpen&&this.open(),r(this,C).debug&&r(this,C).placement!=="inline"&&f(this,d,D).call(this))},D=function(){try{const t=Y(this);if(!t)return;console.warn(`[convai-widget] <${t.tagName.toLowerCase()}> establishes a containing block (transform / filter / backdrop-filter / perspective / contain / will-change), so the launcher's \`position: fixed\` resolves against it instead of the viewport and may be clipped. Place <convai-widget> as a direct child of <body>, or use placement="inline".`)}catch{}},J=async function(){const t=I.get(this);if(!t||!r(this,C)||!r(this,b))return;const n=_.runtimeUrl;if(!n){this.emitError("runtime","could not resolve the runtime URL");return}let a;try{a=await import(n)}catch{try{a=await import(`${n}?retry=1`)}catch(p){this.emitError("runtime",`failed to load the widget runtime: ${String(p)}`);return}}try{const p=await a.mount({root:t,config:r(this,C),host:this,launcher:r(this,b),emit:(l,v)=>this.emit(l,v),emitError:(l,v)=>this.emitError(l,v),engaged:r(this,$)});this.markReady(p)}catch(p){this.emitError("runtime",`widget failed to start: ${String(p)}`)}},N=function(t){if(r(this,g)){t(r(this,g));return}if(r(this,y).length>=P){r(this,k)||(s(this,k,!0),this.emitError("runtime",`more than ${P} calls were queued before the runtime mounted; further calls are being dropped. The runtime may have failed to load, or destroy() may already have run.`));return}r(this,y).push(t)},M=function(){this.isConnected&&(s(this,$,!0),this.load())},_.runtimeUrl=null;let T=_;function tt(e){if(!e)return null;const i=e.getAttribute("data-runtime-url");return i||(e.src?e.src.replace(/\/v1(\.\w+)?\.js(\?.*)?$/,"/runtime.js"):null)}const et=tt(document.currentScript);T.runtimeUrl=et,customElements.get("convai-widget")||customElements.define("convai-widget",T)})();
|
|
44
44
|
})();
|