ai-chatbot-widget 0.0.25 → 0.0.26
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.
|
@@ -13922,10 +13922,10 @@ function n1({ theme: c = "boring", notificationBadge: u = !0, greeting: s, pageC
|
|
|
13922
13922
|
H((de) => [...de, te]), P(""), ie(!0);
|
|
13923
13923
|
try {
|
|
13924
13924
|
const x = {
|
|
13925
|
-
content: await Pb(C + Mt ? `
|
|
13925
|
+
content: await Pb(C + (Mt ? `
|
|
13926
13926
|
|
|
13927
13927
|
The content of the page I'm on, if necessary:
|
|
13928
|
-
${JSON.stringify(l1())}` : "", h),
|
|
13928
|
+
${JSON.stringify(l1())}` : ""), h),
|
|
13929
13929
|
sender: "bot"
|
|
13930
13930
|
};
|
|
13931
13931
|
H((k) => [...k, x]);
|
|
@@ -13969,7 +13969,7 @@ The content of the page I'm on, if necessary:
|
|
|
13969
13969
|
onClick: () => lt((N) => !N),
|
|
13970
13970
|
children: [
|
|
13971
13971
|
Mt ? /* @__PURE__ */ X.jsx(Ag, { className: "bg-black/80 text-white rounded-full p-0.5", size: 12 }) : /* @__PURE__ */ X.jsx("span", { className: "border border-black/80 size-3 rounded" }),
|
|
13972
|
-
/* @__PURE__ */ X.jsx("
|
|
13972
|
+
/* @__PURE__ */ X.jsx("span", { className: "ai-chatbot__share text-xs select-none text-gray-500 cursor-pointer", children: "Share the page content with the chatbot" })
|
|
13973
13973
|
]
|
|
13974
13974
|
}
|
|
13975
13975
|
)
|
|
@@ -165,12 +165,12 @@ Please report this to https://github.com/markedjs/marked.`,r){const s="<p>An err
|
|
|
165
165
|
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(i){return i instanceof this?i:new this(i)}static concat(i,...c){const s=new this(i);return c.forEach(o=>s.set(o)),s}static accessor(i){const s=(this[Ro]=this[Ro]={accessors:{}}).accessors,o=this.prototype;function d(g){const m=ln(g);s[m]||($g(o,g),s[m]=!0)}return k.isArray(i)?i.forEach(d):d(i),this}};ae.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),k.reduceDescriptors(ae.prototype,({value:r},i)=>{let c=i[0].toUpperCase()+i.slice(1);return{get:()=>r,set(s){this[c]=s}}}),k.freezeMethods(ae);function ur(r,i){const c=this||en,s=i||c,o=ae.from(s.headers);let d=s.data;return k.forEach(r,function(m){d=m.call(c,d,o.normalize(),i?i.status:void 0)}),o.normalize(),d}function ko(r){return!!(r&&r.__CANCEL__)}function ra(r,i,c){I.call(this,r??"canceled",I.ERR_CANCELED,i,c),this.name="CanceledError"}k.inherits(ra,I,{__CANCEL__:!0});function _o(r,i,c){const s=c.config.validateStatus;!c.status||!s||s(c.status)?r(c):i(new I("Request failed with status code "+c.status,[I.ERR_BAD_REQUEST,I.ERR_BAD_RESPONSE][Math.floor(c.status/100)-4],c.config,c.request,c))}function Wg(r){const i=/^([-+\w]{1,25})(:?\/\/|:)/.exec(r);return i&&i[1]||""}function Fg(r,i){r=r||10;const c=new Array(r),s=new Array(r);let o=0,d=0,g;return i=i!==void 0?i:1e3,function(w){const p=Date.now(),v=s[d];g||(g=p),c[o]=w,s[o]=p;let _=d,O=0;for(;_!==o;)O+=c[_++],_=_%r;if(o=(o+1)%r,o===d&&(d=(d+1)%r),p-g<i)return;const Z=v&&p-v;return Z?Math.round(O*1e3/Z):void 0}}function Pg(r,i){let c=0,s=1e3/i,o,d;const g=(p,v=Date.now())=>{c=v,o=null,d&&(clearTimeout(d),d=null),r.apply(null,p)};return[(...p)=>{const v=Date.now(),_=v-c;_>=s?g(p,v):(o=p,d||(d=setTimeout(()=>{d=null,g(o)},s-_)))},()=>o&&g(o)]}const gi=(r,i,c=3)=>{let s=0;const o=Fg(50,250);return Pg(d=>{const g=d.loaded,m=d.lengthComputable?d.total:void 0,w=g-s,p=o(w),v=g<=m;s=g;const _={loaded:g,total:m,progress:m?g/m:void 0,bytes:w,rate:p||void 0,estimated:p&&m&&v?(m-g)/p:void 0,event:d,lengthComputable:m!=null,[i?"download":"upload"]:!0};r(_)},c)},zo=(r,i)=>{const c=r!=null;return[s=>i[0]({lengthComputable:c,total:r,loaded:s}),i[1]]},Oo=r=>(...i)=>k.asap(()=>r(...i)),Ig=$t.hasStandardBrowserEnv?((r,i)=>c=>(c=new URL(c,$t.origin),r.protocol===c.protocol&&r.host===c.host&&(i||r.port===c.port)))(new URL($t.origin),$t.navigator&&/(msie|trident)/i.test($t.navigator.userAgent)):()=>!0,tm=$t.hasStandardBrowserEnv?{write(r,i,c,s,o,d){const g=[r+"="+encodeURIComponent(i)];k.isNumber(c)&&g.push("expires="+new Date(c).toGMTString()),k.isString(s)&&g.push("path="+s),k.isString(o)&&g.push("domain="+o),d===!0&&g.push("secure"),document.cookie=g.join("; ")},read(r){const i=document.cookie.match(new RegExp("(^|;\\s*)("+r+")=([^;]*)"));return i?decodeURIComponent(i[3]):null},remove(r){this.write(r,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function em(r){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(r)}function lm(r,i){return i?r.replace(/\/?\/$/,"")+"/"+i.replace(/^\/+/,""):r}function Do(r,i,c){let s=!em(i);return r&&(s||c==!1)?lm(r,i):i}const Mo=r=>r instanceof ae?{...r}:r;function Hl(r,i){i=i||{};const c={};function s(p,v,_,O){return k.isPlainObject(p)&&k.isPlainObject(v)?k.merge.call({caseless:O},p,v):k.isPlainObject(v)?k.merge({},v):k.isArray(v)?v.slice():v}function o(p,v,_,O){if(k.isUndefined(v)){if(!k.isUndefined(p))return s(void 0,p,_,O)}else return s(p,v,_,O)}function d(p,v){if(!k.isUndefined(v))return s(void 0,v)}function g(p,v){if(k.isUndefined(v)){if(!k.isUndefined(p))return s(void 0,p)}else return s(void 0,v)}function m(p,v,_){if(_ in i)return s(p,v);if(_ in r)return s(void 0,p)}const w={url:d,method:d,data:d,baseURL:g,transformRequest:g,transformResponse:g,paramsSerializer:g,timeout:g,timeoutMessage:g,withCredentials:g,withXSRFToken:g,adapter:g,responseType:g,xsrfCookieName:g,xsrfHeaderName:g,onUploadProgress:g,onDownloadProgress:g,decompress:g,maxContentLength:g,maxBodyLength:g,beforeRedirect:g,transport:g,httpAgent:g,httpsAgent:g,cancelToken:g,socketPath:g,responseEncoding:g,validateStatus:m,headers:(p,v,_)=>o(Mo(p),Mo(v),_,!0)};return k.forEach(Object.keys(Object.assign({},r,i)),function(v){const _=w[v]||o,O=_(r[v],i[v],v);k.isUndefined(O)&&_!==m||(c[v]=O)}),c}const No=r=>{const i=Hl({},r);let{data:c,withXSRFToken:s,xsrfHeaderName:o,xsrfCookieName:d,headers:g,auth:m}=i;i.headers=g=ae.from(g),i.url=So(Do(i.baseURL,i.url,i.allowAbsoluteUrls),r.params,r.paramsSerializer),m&&g.set("Authorization","Basic "+btoa((m.username||"")+":"+(m.password?unescape(encodeURIComponent(m.password)):"")));let w;if(k.isFormData(c)){if($t.hasStandardBrowserEnv||$t.hasStandardBrowserWebWorkerEnv)g.setContentType(void 0);else if((w=g.getContentType())!==!1){const[p,...v]=w?w.split(";").map(_=>_.trim()).filter(Boolean):[];g.setContentType([p||"multipart/form-data",...v].join("; "))}}if($t.hasStandardBrowserEnv&&(s&&k.isFunction(s)&&(s=s(i)),s||s!==!1&&Ig(i.url))){const p=o&&d&&tm.read(d);p&&g.set(o,p)}return i},am=typeof XMLHttpRequest<"u"&&function(r){return new Promise(function(c,s){const o=No(r);let d=o.data;const g=ae.from(o.headers).normalize();let{responseType:m,onUploadProgress:w,onDownloadProgress:p}=o,v,_,O,Z,U;function H(){Z&&Z(),U&&U(),o.cancelToken&&o.cancelToken.unsubscribe(v),o.signal&&o.signal.removeEventListener("abort",v)}let L=new XMLHttpRequest;L.open(o.method.toUpperCase(),o.url,!0),L.timeout=o.timeout;function P(){if(!L)return;const ut=ae.from("getAllResponseHeaders"in L&&L.getAllResponseHeaders()),ht={data:!m||m==="text"||m==="json"?L.responseText:L.response,status:L.status,statusText:L.statusText,headers:ut,config:r,request:L};_o(function(mt){c(mt),H()},function(mt){s(mt),H()},ht),L=null}"onloadend"in L?L.onloadend=P:L.onreadystatechange=function(){!L||L.readyState!==4||L.status===0&&!(L.responseURL&&L.responseURL.indexOf("file:")===0)||setTimeout(P)},L.onabort=function(){L&&(s(new I("Request aborted",I.ECONNABORTED,r,L)),L=null)},L.onerror=function(){s(new I("Network Error",I.ERR_NETWORK,r,L)),L=null},L.ontimeout=function(){let ct=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const ht=o.transitional||To;o.timeoutErrorMessage&&(ct=o.timeoutErrorMessage),s(new I(ct,ht.clarifyTimeoutError?I.ETIMEDOUT:I.ECONNABORTED,r,L)),L=null},d===void 0&&g.setContentType(null),"setRequestHeader"in L&&k.forEach(g.toJSON(),function(ct,ht){L.setRequestHeader(ht,ct)}),k.isUndefined(o.withCredentials)||(L.withCredentials=!!o.withCredentials),m&&m!=="json"&&(L.responseType=o.responseType),p&&([O,U]=gi(p,!0),L.addEventListener("progress",O)),w&&L.upload&&([_,Z]=gi(w),L.upload.addEventListener("progress",_),L.upload.addEventListener("loadend",Z)),(o.cancelToken||o.signal)&&(v=ut=>{L&&(s(!ut||ut.type?new ra(null,r,L):ut),L.abort(),L=null)},o.cancelToken&&o.cancelToken.subscribe(v),o.signal&&(o.signal.aborted?v():o.signal.addEventListener("abort",v)));const st=Wg(o.url);if(st&&$t.protocols.indexOf(st)===-1){s(new I("Unsupported protocol "+st+":",I.ERR_BAD_REQUEST,r));return}L.send(d||null)})},nm=(r,i)=>{const{length:c}=r=r?r.filter(Boolean):[];if(i||c){let s=new AbortController,o;const d=function(p){if(!o){o=!0,m();const v=p instanceof Error?p:this.reason;s.abort(v instanceof I?v:new ra(v instanceof Error?v.message:v))}};let g=i&&setTimeout(()=>{g=null,d(new I(`timeout ${i} of ms exceeded`,I.ETIMEDOUT))},i);const m=()=>{r&&(g&&clearTimeout(g),g=null,r.forEach(p=>{p.unsubscribe?p.unsubscribe(d):p.removeEventListener("abort",d)}),r=null)};r.forEach(p=>p.addEventListener("abort",d));const{signal:w}=s;return w.unsubscribe=()=>k.asap(m),w}},im=function*(r,i){let c=r.byteLength;if(c<i){yield r;return}let s=0,o;for(;s<c;)o=s+i,yield r.slice(s,o),s=o},um=async function*(r,i){for await(const c of rm(r))yield*im(c,i)},rm=async function*(r){if(r[Symbol.asyncIterator]){yield*r;return}const i=r.getReader();try{for(;;){const{done:c,value:s}=await i.read();if(c)break;yield s}}finally{await i.cancel()}},Uo=(r,i,c,s)=>{const o=um(r,i);let d=0,g,m=w=>{g||(g=!0,s&&s(w))};return new ReadableStream({async pull(w){try{const{done:p,value:v}=await o.next();if(p){m(),w.close();return}let _=v.byteLength;if(c){let O=d+=_;c(O)}w.enqueue(new Uint8Array(v))}catch(p){throw m(p),p}},cancel(w){return m(w),o.return()}},{highWaterMark:2})},mi=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",Bo=mi&&typeof ReadableStream=="function",cm=mi&&(typeof TextEncoder=="function"?(r=>i=>r.encode(i))(new TextEncoder):async r=>new Uint8Array(await new Response(r).arrayBuffer())),Co=(r,...i)=>{try{return!!r(...i)}catch{return!1}},sm=Bo&&Co(()=>{let r=!1;const i=new Request($t.origin,{body:new ReadableStream,method:"POST",get duplex(){return r=!0,"half"}}).headers.has("Content-Type");return r&&!i}),qo=64*1024,rr=Bo&&Co(()=>k.isReadableStream(new Response("").body)),bi={stream:rr&&(r=>r.body)};mi&&(r=>{["text","arrayBuffer","blob","formData","stream"].forEach(i=>{!bi[i]&&(bi[i]=k.isFunction(r[i])?c=>c[i]():(c,s)=>{throw new I(`Response type '${i}' is not supported`,I.ERR_NOT_SUPPORT,s)})})})(new Response);const om=async r=>{if(r==null)return 0;if(k.isBlob(r))return r.size;if(k.isSpecCompliantForm(r))return(await new Request($t.origin,{method:"POST",body:r}).arrayBuffer()).byteLength;if(k.isArrayBufferView(r)||k.isArrayBuffer(r))return r.byteLength;if(k.isURLSearchParams(r)&&(r=r+""),k.isString(r))return(await cm(r)).byteLength},fm=async(r,i)=>{const c=k.toFiniteNumber(r.getContentLength());return c??om(i)},cr={http:Mg,xhr:am,fetch:mi&&(async r=>{let{url:i,method:c,data:s,signal:o,cancelToken:d,timeout:g,onDownloadProgress:m,onUploadProgress:w,responseType:p,headers:v,withCredentials:_="same-origin",fetchOptions:O}=No(r);p=p?(p+"").toLowerCase():"text";let Z=nm([o,d&&d.toAbortSignal()],g),U;const H=Z&&Z.unsubscribe&&(()=>{Z.unsubscribe()});let L;try{if(w&&sm&&c!=="get"&&c!=="head"&&(L=await fm(v,s))!==0){let ht=new Request(i,{method:"POST",body:s,duplex:"half"}),V;if(k.isFormData(s)&&(V=ht.headers.get("content-type"))&&v.setContentType(V),ht.body){const[mt,Qt]=zo(L,gi(Oo(w)));s=Uo(ht.body,qo,mt,Qt)}}k.isString(_)||(_=_?"include":"omit");const P="credentials"in Request.prototype;U=new Request(i,{...O,signal:Z,method:c.toUpperCase(),headers:v.normalize().toJSON(),body:s,duplex:"half",credentials:P?_:void 0});let st=await fetch(U,O);const ut=rr&&(p==="stream"||p==="response");if(rr&&(m||ut&&H)){const ht={};["status","statusText","headers"].forEach(Ut=>{ht[Ut]=st[Ut]});const V=k.toFiniteNumber(st.headers.get("content-length")),[mt,Qt]=m&&zo(V,gi(Oo(m),!0))||[];st=new Response(Uo(st.body,qo,mt,()=>{Qt&&Qt(),H&&H()}),ht)}p=p||"text";let ct=await bi[k.findKey(bi,p)||"text"](st,r);return!ut&&H&&H(),await new Promise((ht,V)=>{_o(ht,V,{data:ct,headers:ae.from(st.headers),status:st.status,statusText:st.statusText,config:r,request:U})})}catch(P){throw H&&H(),P&&P.name==="TypeError"&&/Load failed|fetch/i.test(P.message)?Object.assign(new I("Network Error",I.ERR_NETWORK,r,U),{cause:P.cause||P}):I.from(P,P&&P.code,r,U)}})};k.forEach(cr,(r,i)=>{if(r){try{Object.defineProperty(r,"name",{value:i})}catch{}Object.defineProperty(r,"adapterName",{value:i})}});const Ho=r=>`- ${r}`,dm=r=>k.isFunction(r)||r===null||r===!1,jo={getAdapter:r=>{r=k.isArray(r)?r:[r];const{length:i}=r;let c,s;const o={};for(let d=0;d<i;d++){c=r[d];let g;if(s=c,!dm(c)&&(s=cr[(g=String(c)).toLowerCase()],s===void 0))throw new I(`Unknown adapter '${g}'`);if(s)break;o[g||"#"+d]=s}if(!s){const d=Object.entries(o).map(([m,w])=>`adapter ${m} `+(w===!1?"is not supported by the environment":"is not available in the build"));let g=i?d.length>1?`since :
|
|
166
166
|
`+d.map(Ho).join(`
|
|
167
167
|
`):" "+Ho(d[0]):"as no adapter specified";throw new I("There is no suitable adapter to dispatch the request "+g,"ERR_NOT_SUPPORT")}return s},adapters:cr};function sr(r){if(r.cancelToken&&r.cancelToken.throwIfRequested(),r.signal&&r.signal.aborted)throw new ra(null,r)}function Lo(r){return sr(r),r.headers=ae.from(r.headers),r.data=ur.call(r,r.transformRequest),["post","put","patch"].indexOf(r.method)!==-1&&r.headers.setContentType("application/x-www-form-urlencoded",!1),jo.getAdapter(r.adapter||en.adapter)(r).then(function(s){return sr(r),s.data=ur.call(r,r.transformResponse,s),s.headers=ae.from(s.headers),s},function(s){return ko(s)||(sr(r),s&&s.response&&(s.response.data=ur.call(r,r.transformResponse,s.response),s.response.headers=ae.from(s.response.headers))),Promise.reject(s)})}const Yo="1.10.0",vi={};["object","boolean","number","function","string","symbol"].forEach((r,i)=>{vi[r]=function(s){return typeof s===r||"a"+(i<1?"n ":" ")+r}});const Go={};vi.transitional=function(i,c,s){function o(d,g){return"[Axios v"+Yo+"] Transitional option '"+d+"'"+g+(s?". "+s:"")}return(d,g,m)=>{if(i===!1)throw new I(o(g," has been removed"+(c?" in "+c:"")),I.ERR_DEPRECATED);return c&&!Go[g]&&(Go[g]=!0,console.warn(o(g," has been deprecated since v"+c+" and will be removed in the near future"))),i?i(d,g,m):!0}},vi.spelling=function(i){return(c,s)=>(console.warn(`${s} is likely a misspelling of ${i}`),!0)};function hm(r,i,c){if(typeof r!="object")throw new I("options must be an object",I.ERR_BAD_OPTION_VALUE);const s=Object.keys(r);let o=s.length;for(;o-- >0;){const d=s[o],g=i[d];if(g){const m=r[d],w=m===void 0||g(m,d,r);if(w!==!0)throw new I("option "+d+" must be "+w,I.ERR_BAD_OPTION_VALUE);continue}if(c!==!0)throw new I("Unknown option "+d,I.ERR_BAD_OPTION)}}const yi={assertOptions:hm,validators:vi},He=yi.validators;let jl=class{constructor(i){this.defaults=i||{},this.interceptors={request:new Eo,response:new Eo}}async request(i,c){try{return await this._request(i,c)}catch(s){if(s instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const d=o.stack?o.stack.replace(/^.+\n/,""):"";try{s.stack?d&&!String(s.stack).endsWith(d.replace(/^.+\n.+\n/,""))&&(s.stack+=`
|
|
168
|
-
`+d):s.stack=d}catch{}}throw s}}_request(i,c){typeof i=="string"?(c=c||{},c.url=i):c=i||{},c=Hl(this.defaults,c);const{transitional:s,paramsSerializer:o,headers:d}=c;s!==void 0&&yi.assertOptions(s,{silentJSONParsing:He.transitional(He.boolean),forcedJSONParsing:He.transitional(He.boolean),clarifyTimeoutError:He.transitional(He.boolean)},!1),o!=null&&(k.isFunction(o)?c.paramsSerializer={serialize:o}:yi.assertOptions(o,{encode:He.function,serialize:He.function},!0)),c.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?c.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:c.allowAbsoluteUrls=!0),yi.assertOptions(c,{baseUrl:He.spelling("baseURL"),withXsrfToken:He.spelling("withXSRFToken")},!0),c.method=(c.method||this.defaults.method||"get").toLowerCase();let g=d&&k.merge(d.common,d[c.method]);d&&k.forEach(["delete","get","head","post","put","patch","common"],U=>{delete d[U]}),c.headers=ae.concat(g,d);const m=[];let w=!0;this.interceptors.request.forEach(function(H){typeof H.runWhen=="function"&&H.runWhen(c)===!1||(w=w&&H.synchronous,m.unshift(H.fulfilled,H.rejected))});const p=[];this.interceptors.response.forEach(function(H){p.push(H.fulfilled,H.rejected)});let v,_=0,O;if(!w){const U=[Lo.bind(this),void 0];for(U.unshift.apply(U,m),U.push.apply(U,p),O=U.length,v=Promise.resolve(c);_<O;)v=v.then(U[_++],U[_++]);return v}O=m.length;let Z=c;for(_=0;_<O;){const U=m[_++],H=m[_++];try{Z=U(Z)}catch(L){H.call(this,L);break}}try{v=Lo.call(this,Z)}catch(U){return Promise.reject(U)}for(_=0,O=p.length;_<O;)v=v.then(p[_++],p[_++]);return v}getUri(i){i=Hl(this.defaults,i);const c=Do(i.baseURL,i.url,i.allowAbsoluteUrls);return So(c,i.params,i.paramsSerializer)}};k.forEach(["delete","get","head","options"],function(i){jl.prototype[i]=function(c,s){return this.request(Hl(s||{},{method:i,url:c,data:(s||{}).data}))}}),k.forEach(["post","put","patch"],function(i){function c(s){return function(d,g,m){return this.request(Hl(m||{},{method:i,headers:s?{"Content-Type":"multipart/form-data"}:{},url:d,data:g}))}}jl.prototype[i]=c(),jl.prototype[i+"Form"]=c(!0)});let pm=class qp{constructor(i){if(typeof i!="function")throw new TypeError("executor must be a function.");let c;this.promise=new Promise(function(d){c=d});const s=this;this.promise.then(o=>{if(!s._listeners)return;let d=s._listeners.length;for(;d-- >0;)s._listeners[d](o);s._listeners=null}),this.promise.then=o=>{let d;const g=new Promise(m=>{s.subscribe(m),d=m}).then(o);return g.cancel=function(){s.unsubscribe(d)},g},i(function(d,g,m){s.reason||(s.reason=new ra(d,g,m),c(s.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(i){if(this.reason){i(this.reason);return}this._listeners?this._listeners.push(i):this._listeners=[i]}unsubscribe(i){if(!this._listeners)return;const c=this._listeners.indexOf(i);c!==-1&&this._listeners.splice(c,1)}toAbortSignal(){const i=new AbortController,c=s=>{i.abort(s)};return this.subscribe(c),i.signal.unsubscribe=()=>this.unsubscribe(c),i.signal}static source(){let i;return{token:new qp(function(o){i=o}),cancel:i}}};function gm(r){return function(c){return r.apply(null,c)}}function mm(r){return k.isObject(r)&&r.isAxiosError===!0}const or={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(or).forEach(([r,i])=>{or[i]=r});function Xo(r){const i=new jl(r),c=io(jl.prototype.request,i);return k.extend(c,jl.prototype,i,{allOwnKeys:!0}),k.extend(c,i,null,{allOwnKeys:!0}),c.create=function(o){return Xo(Hl(r,o))},c}const zt=Xo(en);zt.Axios=jl,zt.CanceledError=ra,zt.CancelToken=pm,zt.isCancel=ko,zt.VERSION=Yo,zt.toFormData=hi,zt.AxiosError=I,zt.Cancel=zt.CanceledError,zt.all=function(i){return Promise.all(i)},zt.spread=gm,zt.isAxiosError=mm,zt.mergeConfig=Hl,zt.AxiosHeaders=ae,zt.formToJSON=r=>Ao(k.isHTMLForm(r)?new FormData(r):r),zt.getAdapter=jo.getAdapter,zt.HttpStatusCode=or,zt.default=zt;const{Axios:ry,AxiosError:cy,CanceledError:sy,isCancel:oy,CancelToken:fy,VERSION:dy,all:hy,Cancel:py,isAxiosError:gy,spread:my,toFormData:by,AxiosHeaders:vy,HttpStatusCode:yy,formToJSON:wy,getAdapter:xy,mergeConfig:Sy}=zt,bm=async(r,i)=>{var o;const c=(o=window.location.search.replace("?","").split("&").find(d=>d.includes("utm")))==null?void 0:o.split("=")[1];return(await zt.post(i,{message:r},{headers:{utm:c}})).data.output},vm=async r=>{const i=await zt.get(r),c=[];for(const s of i.data.propertyName){const o=JSON.parse(s);c.push(o)}return c.reverse()},ym="script, style, noscript, .ai-chatbot, header, footer, nav, sidebar";function wm(){const r=document.body.cloneNode(!0);return r.querySelectorAll(ym).forEach(i=>i.remove()),r}function xm(){const r={heading:"h1,h2,h3,h4,h5,h6",paragraph:"p","list-item":"li",blockquote:"blockquote",pre:"pre,code",other:"*"},i=wm(),c=[];for(const[s,o]of Object.entries(r))i.querySelectorAll(o).forEach(d=>{const m=(d.textContent??"").replace(/\s+/g," ").trim();m&&c.push({type:s,text:m})});return c}function Sm({theme:r="boring",notificationBadge:i=!0,greeting:c,pageContext:s,chatPrompts:o=[],chatbotUrl:d,dialogeBaseUrl:g,title:m="AI Assistant",imageUrl:w,imageWidth:p,greetingOutside:v=!1}){const _=c?[{content:c,sender:"bot"}]:[],[O,Z]=qt.useState(!1),[U,H]=qt.useState(c?_:[]),[L,P]=qt.useState(""),[st,ut]=qt.useState(!1),[ct,ht]=qt.useState(!0),V=qt.useRef(null),[mt,Qt]=qt.useState(o),[Ut,xe]=qt.useState(i),[Me,ne]=qt.useState(!1),te=()=>{var M;(M=V.current)==null||M.scrollIntoView({behavior:"smooth"})};qt.useEffect(()=>{U.filter(C=>C.sender==="user").length>0?ht(!1):ht(!0),te()},[U]),qt.useEffect(()=>{U.length<=1&&vm(g).then(M=>{const C=M.map(et=>({content:et.data.content,sender:et.type==="human"?"user":"bot"}));H([..._,...C])})},[g]),qt.useEffect(()=>{const M=window.location.pathname;if(s){for(const[C,{exec:et,timer:pt}]of Object.entries(s))if(C===M){sl(pt,et);break}}},[s]),qt.useEffect(()=>{O&&Ut&&xe(!1)},[O]);const sl=async(M,C)=>{await V0(M),C({open:{isOpen:O,setIsOpen:Z},messageOptions:{messages:U,setMessages:H},input:{inputValue:L,setInputValue:P},promptsOptions:{prompts:mt,setPrompts:Qt},scrollToBottom:te})},oe=async M=>{let C=M||L.trim();if(!C)return;const et={content:C,sender:"user"};H(pt=>[...pt,et]),P(""),ut(!0);try{const x={content:await bm(C+Me?`
|
|
168
|
+
`+d):s.stack=d}catch{}}throw s}}_request(i,c){typeof i=="string"?(c=c||{},c.url=i):c=i||{},c=Hl(this.defaults,c);const{transitional:s,paramsSerializer:o,headers:d}=c;s!==void 0&&yi.assertOptions(s,{silentJSONParsing:He.transitional(He.boolean),forcedJSONParsing:He.transitional(He.boolean),clarifyTimeoutError:He.transitional(He.boolean)},!1),o!=null&&(k.isFunction(o)?c.paramsSerializer={serialize:o}:yi.assertOptions(o,{encode:He.function,serialize:He.function},!0)),c.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?c.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:c.allowAbsoluteUrls=!0),yi.assertOptions(c,{baseUrl:He.spelling("baseURL"),withXsrfToken:He.spelling("withXSRFToken")},!0),c.method=(c.method||this.defaults.method||"get").toLowerCase();let g=d&&k.merge(d.common,d[c.method]);d&&k.forEach(["delete","get","head","post","put","patch","common"],U=>{delete d[U]}),c.headers=ae.concat(g,d);const m=[];let w=!0;this.interceptors.request.forEach(function(H){typeof H.runWhen=="function"&&H.runWhen(c)===!1||(w=w&&H.synchronous,m.unshift(H.fulfilled,H.rejected))});const p=[];this.interceptors.response.forEach(function(H){p.push(H.fulfilled,H.rejected)});let v,_=0,O;if(!w){const U=[Lo.bind(this),void 0];for(U.unshift.apply(U,m),U.push.apply(U,p),O=U.length,v=Promise.resolve(c);_<O;)v=v.then(U[_++],U[_++]);return v}O=m.length;let Z=c;for(_=0;_<O;){const U=m[_++],H=m[_++];try{Z=U(Z)}catch(L){H.call(this,L);break}}try{v=Lo.call(this,Z)}catch(U){return Promise.reject(U)}for(_=0,O=p.length;_<O;)v=v.then(p[_++],p[_++]);return v}getUri(i){i=Hl(this.defaults,i);const c=Do(i.baseURL,i.url,i.allowAbsoluteUrls);return So(c,i.params,i.paramsSerializer)}};k.forEach(["delete","get","head","options"],function(i){jl.prototype[i]=function(c,s){return this.request(Hl(s||{},{method:i,url:c,data:(s||{}).data}))}}),k.forEach(["post","put","patch"],function(i){function c(s){return function(d,g,m){return this.request(Hl(m||{},{method:i,headers:s?{"Content-Type":"multipart/form-data"}:{},url:d,data:g}))}}jl.prototype[i]=c(),jl.prototype[i+"Form"]=c(!0)});let pm=class qp{constructor(i){if(typeof i!="function")throw new TypeError("executor must be a function.");let c;this.promise=new Promise(function(d){c=d});const s=this;this.promise.then(o=>{if(!s._listeners)return;let d=s._listeners.length;for(;d-- >0;)s._listeners[d](o);s._listeners=null}),this.promise.then=o=>{let d;const g=new Promise(m=>{s.subscribe(m),d=m}).then(o);return g.cancel=function(){s.unsubscribe(d)},g},i(function(d,g,m){s.reason||(s.reason=new ra(d,g,m),c(s.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(i){if(this.reason){i(this.reason);return}this._listeners?this._listeners.push(i):this._listeners=[i]}unsubscribe(i){if(!this._listeners)return;const c=this._listeners.indexOf(i);c!==-1&&this._listeners.splice(c,1)}toAbortSignal(){const i=new AbortController,c=s=>{i.abort(s)};return this.subscribe(c),i.signal.unsubscribe=()=>this.unsubscribe(c),i.signal}static source(){let i;return{token:new qp(function(o){i=o}),cancel:i}}};function gm(r){return function(c){return r.apply(null,c)}}function mm(r){return k.isObject(r)&&r.isAxiosError===!0}const or={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(or).forEach(([r,i])=>{or[i]=r});function Xo(r){const i=new jl(r),c=io(jl.prototype.request,i);return k.extend(c,jl.prototype,i,{allOwnKeys:!0}),k.extend(c,i,null,{allOwnKeys:!0}),c.create=function(o){return Xo(Hl(r,o))},c}const zt=Xo(en);zt.Axios=jl,zt.CanceledError=ra,zt.CancelToken=pm,zt.isCancel=ko,zt.VERSION=Yo,zt.toFormData=hi,zt.AxiosError=I,zt.Cancel=zt.CanceledError,zt.all=function(i){return Promise.all(i)},zt.spread=gm,zt.isAxiosError=mm,zt.mergeConfig=Hl,zt.AxiosHeaders=ae,zt.formToJSON=r=>Ao(k.isHTMLForm(r)?new FormData(r):r),zt.getAdapter=jo.getAdapter,zt.HttpStatusCode=or,zt.default=zt;const{Axios:ry,AxiosError:cy,CanceledError:sy,isCancel:oy,CancelToken:fy,VERSION:dy,all:hy,Cancel:py,isAxiosError:gy,spread:my,toFormData:by,AxiosHeaders:vy,HttpStatusCode:yy,formToJSON:wy,getAdapter:xy,mergeConfig:Sy}=zt,bm=async(r,i)=>{var o;const c=(o=window.location.search.replace("?","").split("&").find(d=>d.includes("utm")))==null?void 0:o.split("=")[1];return(await zt.post(i,{message:r},{headers:{utm:c}})).data.output},vm=async r=>{const i=await zt.get(r),c=[];for(const s of i.data.propertyName){const o=JSON.parse(s);c.push(o)}return c.reverse()},ym="script, style, noscript, .ai-chatbot, header, footer, nav, sidebar";function wm(){const r=document.body.cloneNode(!0);return r.querySelectorAll(ym).forEach(i=>i.remove()),r}function xm(){const r={heading:"h1,h2,h3,h4,h5,h6",paragraph:"p","list-item":"li",blockquote:"blockquote",pre:"pre,code",other:"*"},i=wm(),c=[];for(const[s,o]of Object.entries(r))i.querySelectorAll(o).forEach(d=>{const m=(d.textContent??"").replace(/\s+/g," ").trim();m&&c.push({type:s,text:m})});return c}function Sm({theme:r="boring",notificationBadge:i=!0,greeting:c,pageContext:s,chatPrompts:o=[],chatbotUrl:d,dialogeBaseUrl:g,title:m="AI Assistant",imageUrl:w,imageWidth:p,greetingOutside:v=!1}){const _=c?[{content:c,sender:"bot"}]:[],[O,Z]=qt.useState(!1),[U,H]=qt.useState(c?_:[]),[L,P]=qt.useState(""),[st,ut]=qt.useState(!1),[ct,ht]=qt.useState(!0),V=qt.useRef(null),[mt,Qt]=qt.useState(o),[Ut,xe]=qt.useState(i),[Me,ne]=qt.useState(!1),te=()=>{var M;(M=V.current)==null||M.scrollIntoView({behavior:"smooth"})};qt.useEffect(()=>{U.filter(C=>C.sender==="user").length>0?ht(!1):ht(!0),te()},[U]),qt.useEffect(()=>{U.length<=1&&vm(g).then(M=>{const C=M.map(et=>({content:et.data.content,sender:et.type==="human"?"user":"bot"}));H([..._,...C])})},[g]),qt.useEffect(()=>{const M=window.location.pathname;if(s){for(const[C,{exec:et,timer:pt}]of Object.entries(s))if(C===M){sl(pt,et);break}}},[s]),qt.useEffect(()=>{O&&Ut&&xe(!1)},[O]);const sl=async(M,C)=>{await V0(M),C({open:{isOpen:O,setIsOpen:Z},messageOptions:{messages:U,setMessages:H},input:{inputValue:L,setInputValue:P},promptsOptions:{prompts:mt,setPrompts:Qt},scrollToBottom:te})},oe=async M=>{let C=M||L.trim();if(!C)return;const et={content:C,sender:"user"};H(pt=>[...pt,et]),P(""),ut(!0);try{const x={content:await bm(C+(Me?`
|
|
169
169
|
|
|
170
170
|
The content of the page I'm on, if necessary:
|
|
171
|
-
${JSON.stringify(xm())}`:"",d),sender:"bot"};H(B=>[...B,x])}catch{const x={content:"Unfortunately, an error occurred while processing your request.",sender:"bot"};H(B=>[...B,x])}finally{ut(!1)}},q=async M=>{M.key==="Enter"&&!M.shiftKey&&(M.preventDefault(),await oe())};return X.jsxs("div",{className:"fixed flex flex-col items-end bottom-1 right-1 md:bottom-6 md:right-6 z-50 ai-chatbot ",children:[X.jsx("div",{className:`
|
|
171
|
+
${JSON.stringify(xm())}`:""),d),sender:"bot"};H(B=>[...B,x])}catch{const x={content:"Unfortunately, an error occurred while processing your request.",sender:"bot"};H(B=>[...B,x])}finally{ut(!1)}},q=async M=>{M.key==="Enter"&&!M.shiftKey&&(M.preventDefault(),await oe())};return X.jsxs("div",{className:"fixed flex flex-col items-end bottom-1 right-1 md:bottom-6 md:right-6 z-50 ai-chatbot ",children:[X.jsx("div",{className:`
|
|
172
172
|
absolute bottom-15 sm:bottom-16 right-0 w-86 sm:w-96 h-[65vh]
|
|
173
173
|
transform transition-all duration-300 ease-in-out origin-bottom-right
|
|
174
174
|
ai-chatbot-window
|
|
175
175
|
${O?"scale-100 opacity-100":"scale-0 opacity-0 pointer-events-none"}
|
|
176
|
-
`,children:X.jsxs("div",{className:`${Pt(r,"mainBackground")} rounded-4xl shadow-2xl backdrop-blur-xl h-full flex flex-col overflow-hidden`,children:[X.jsx(i0,{setIsOpen:Z,theme:r,title:m,imageUrl:w,imageWidth:p}),X.jsxs("div",{className:"flex-1 flex flex-col h-full justify-between overflow-y-auto p-2 lg:p-4 space-y-2 lg:space-y-4 scrollbar-thin scrollbar-thumb-purple-500/50 scrollbar-track-transparent",children:[X.jsxs("div",{className:"space-y-4 ",children:[U.map((M,C)=>X.jsx(no,{message:M,index:C,theme:r},M.content)),st&&X.jsx(G0,{}),X.jsx("div",{ref:V})]}),ct&&X.jsx("div",{className:"flex gap-2 flex-wrap",children:mt.map(M=>X.jsx(K0,{prompt:M,handleSendMessage:oe,theme:r},M))})]}),X.jsx(Q0,{handleKeyPress:q,inputValue:L,setInputValue:P,handleSendMessage:()=>oe(),theme:r}),X.jsxs("div",{className:`px-4 flex items-center py-1 gap-1 cursor-pointer transition-all ${Me?"":"opacity-50"}`,onClick:()=>ne(M=>!M),children:[Me?X.jsx(t0,{className:"bg-black/80 text-white rounded-full p-0.5",size:12}):X.jsx("span",{className:"border border-black/80 size-3 rounded"}),X.jsx("
|
|
176
|
+
`,children:X.jsxs("div",{className:`${Pt(r,"mainBackground")} rounded-4xl shadow-2xl backdrop-blur-xl h-full flex flex-col overflow-hidden`,children:[X.jsx(i0,{setIsOpen:Z,theme:r,title:m,imageUrl:w,imageWidth:p}),X.jsxs("div",{className:"flex-1 flex flex-col h-full justify-between overflow-y-auto p-2 lg:p-4 space-y-2 lg:space-y-4 scrollbar-thin scrollbar-thumb-purple-500/50 scrollbar-track-transparent",children:[X.jsxs("div",{className:"space-y-4 ",children:[U.map((M,C)=>X.jsx(no,{message:M,index:C,theme:r},M.content)),st&&X.jsx(G0,{}),X.jsx("div",{ref:V})]}),ct&&X.jsx("div",{className:"flex gap-2 flex-wrap",children:mt.map(M=>X.jsx(K0,{prompt:M,handleSendMessage:oe,theme:r},M))})]}),X.jsx(Q0,{handleKeyPress:q,inputValue:L,setInputValue:P,handleSendMessage:()=>oe(),theme:r}),X.jsxs("div",{className:`px-4 flex items-center py-1 gap-1 cursor-pointer transition-all ${Me?"":"opacity-50"}`,onClick:()=>ne(M=>!M),children:[Me?X.jsx(t0,{className:"bg-black/80 text-white rounded-full p-0.5",size:12}):X.jsx("span",{className:"border border-black/80 size-3 rounded"}),X.jsx("span",{className:"ai-chatbot__share text-xs select-none text-gray-500 cursor-pointer",children:"Share the page content with the chatbot"})]})]})}),v&&c&&!O&&Ut&&X.jsx("div",{className:"pb-2",children:X.jsx(no,{message:{content:c,sender:"bot"},index:0,theme:r,margin:!1})}),X.jsx(Z0,{isOpen:O,setIsOpen:Z,theme:r}),!O&&Ut&&!v&&X.jsx(X0,{theme:r})]})}function Em(r,i={}){const c=typeof r=="string"?document.querySelector(r):r;Jp.createRoot(c).render(X.jsx(Sm,{...i}))}return Ze.mountChatbotWidget=Em,Object.defineProperty(Ze,Symbol.toStringTag,{value:"Module"}),Ze}({});
|