ai-chatbot-widget 0.0.12 → 0.0.13

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.
@@ -13881,13 +13881,14 @@ function Pb({ theme: c = "boring", notificationBadge: u = !0, greeting: s, pageC
13881
13881
  }, Ze = async (te) => {
13882
13882
  te.key === "Enter" && !te.shiftKey && (te.preventDefault(), await pe());
13883
13883
  };
13884
- return /* @__PURE__ */ J.jsxs("div", { className: "fixed bottom-6 right-6 z-50", children: [
13884
+ return /* @__PURE__ */ J.jsxs("div", { className: "fixed bottom-6 right-6 z-50 ai-chatbot", children: [
13885
13885
  /* @__PURE__ */ J.jsx(
13886
13886
  "div",
13887
13887
  {
13888
13888
  className: `
13889
13889
  absolute bottom-16 right-0 w-96 h-[550px]
13890
13890
  transform transition-all duration-300 ease-in-out origin-bottom-right
13891
+ ai-chatbot-window
13891
13892
  ${v ? "scale-100 opacity-100" : "scale-0 opacity-0 pointer-events-none"}
13892
13893
  `,
13893
13894
  children: /* @__PURE__ */ J.jsxs("div", { className: `${rt(c, "mainBackground")} rounded-4xl shadow-2xl backdrop-blur-xl h-full flex flex-col overflow-hidden`, children: [
@@ -160,8 +160,9 @@ Please report this to https://github.com/markedjs/marked.`,r){const c="<p>An err
160
160
  `)}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,...s){const c=new this(i);return s.forEach(o=>c.set(o)),c}static accessor(i){const c=(this[Ao]=this[Ao]={accessors:{}}).accessors,o=this.prototype;function d(g){const m=ln(g);c[m]||(Jg(o,g),c[m]=!0)}return _.isArray(i)?i.forEach(d):d(i),this}};ie.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),_.reduceDescriptors(ie.prototype,({value:r},i)=>{let s=i[0].toUpperCase()+i.slice(1);return{get:()=>r,set(c){this[s]=c}}}),_.freezeMethods(ie);function ur(r,i){const s=this||en,c=i||s,o=ie.from(c.headers);let d=c.data;return _.forEach(r,function(m){d=m.call(s,d,o.normalize(),i?i.status:void 0)}),o.normalize(),d}function Ro(r){return!!(r&&r.__CANCEL__)}function ua(r,i,s){P.call(this,r??"canceled",P.ERR_CANCELED,i,s),this.name="CanceledError"}_.inherits(ua,P,{__CANCEL__:!0});function _o(r,i,s){const c=s.config.validateStatus;!s.status||!c||c(s.status)?r(s):i(new P("Request failed with status code "+s.status,[P.ERR_BAD_REQUEST,P.ERR_BAD_RESPONSE][Math.floor(s.status/100)-4],s.config,s.request,s))}function $g(r){const i=/^([-+\w]{1,25})(:?\/\/|:)/.exec(r);return i&&i[1]||""}function Wg(r,i){r=r||10;const s=new Array(r),c=new Array(r);let o=0,d=0,g;return i=i!==void 0?i:1e3,function(v){const p=Date.now(),y=c[d];g||(g=p),s[o]=v,c[o]=p;let k=d,D=0;for(;k!==o;)D+=s[k++],k=k%r;if(o=(o+1)%r,o===d&&(d=(d+1)%r),p-g<i)return;const Q=y&&p-y;return Q?Math.round(D*1e3/Q):void 0}}function Fg(r,i){let s=0,c=1e3/i,o,d;const g=(p,y=Date.now())=>{s=y,o=null,d&&(clearTimeout(d),d=null),r.apply(null,p)};return[(...p)=>{const y=Date.now(),k=y-s;k>=c?g(p,y):(o=p,d||(d=setTimeout(()=>{d=null,g(o)},c-k)))},()=>o&&g(o)]}const gi=(r,i,s=3)=>{let c=0;const o=Wg(50,250);return Fg(d=>{const g=d.loaded,m=d.lengthComputable?d.total:void 0,v=g-c,p=o(v),y=g<=m;c=g;const k={loaded:g,total:m,progress:m?g/m:void 0,bytes:v,rate:p||void 0,estimated:p&&m&&y?(m-g)/p:void 0,event:d,lengthComputable:m!=null,[i?"download":"upload"]:!0};r(k)},s)},ko=(r,i)=>{const s=r!=null;return[c=>i[0]({lengthComputable:s,total:r,loaded:c}),i[1]]},zo=r=>(...i)=>_.asap(()=>r(...i)),Pg=Ft.hasStandardBrowserEnv?((r,i)=>s=>(s=new URL(s,Ft.origin),r.protocol===s.protocol&&r.host===s.host&&(i||r.port===s.port)))(new URL(Ft.origin),Ft.navigator&&/(msie|trident)/i.test(Ft.navigator.userAgent)):()=>!0,Ig=Ft.hasStandardBrowserEnv?{write(r,i,s,c,o,d){const g=[r+"="+encodeURIComponent(i)];_.isNumber(s)&&g.push("expires="+new Date(s).toGMTString()),_.isString(c)&&g.push("path="+c),_.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 tm(r){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(r)}function em(r,i){return i?r.replace(/\/?\/$/,"")+"/"+i.replace(/^\/+/,""):r}function Oo(r,i,s){let c=!tm(i);return r&&(c||s==!1)?em(r,i):i}const Do=r=>r instanceof ie?{...r}:r;function Hl(r,i){i=i||{};const s={};function c(p,y,k,D){return _.isPlainObject(p)&&_.isPlainObject(y)?_.merge.call({caseless:D},p,y):_.isPlainObject(y)?_.merge({},y):_.isArray(y)?y.slice():y}function o(p,y,k,D){if(_.isUndefined(y)){if(!_.isUndefined(p))return c(void 0,p,k,D)}else return c(p,y,k,D)}function d(p,y){if(!_.isUndefined(y))return c(void 0,y)}function g(p,y){if(_.isUndefined(y)){if(!_.isUndefined(p))return c(void 0,p)}else return c(void 0,y)}function m(p,y,k){if(k in i)return c(p,y);if(k in r)return c(void 0,p)}const v={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,y,k)=>o(Do(p),Do(y),k,!0)};return _.forEach(Object.keys(Object.assign({},r,i)),function(y){const k=v[y]||o,D=k(r[y],i[y],y);_.isUndefined(D)&&k!==m||(s[y]=D)}),s}const Mo=r=>{const i=Hl({},r);let{data:s,withXSRFToken:c,xsrfHeaderName:o,xsrfCookieName:d,headers:g,auth:m}=i;i.headers=g=ie.from(g),i.url=So(Oo(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 v;if(_.isFormData(s)){if(Ft.hasStandardBrowserEnv||Ft.hasStandardBrowserWebWorkerEnv)g.setContentType(void 0);else if((v=g.getContentType())!==!1){const[p,...y]=v?v.split(";").map(k=>k.trim()).filter(Boolean):[];g.setContentType([p||"multipart/form-data",...y].join("; "))}}if(Ft.hasStandardBrowserEnv&&(c&&_.isFunction(c)&&(c=c(i)),c||c!==!1&&Pg(i.url))){const p=o&&d&&Ig.read(d);p&&g.set(o,p)}return i},lm=typeof XMLHttpRequest<"u"&&function(r){return new Promise(function(s,c){const o=Mo(r);let d=o.data;const g=ie.from(o.headers).normalize();let{responseType:m,onUploadProgress:v,onDownloadProgress:p}=o,y,k,D,Q,N;function H(){Q&&Q(),N&&N(),o.cancelToken&&o.cancelToken.unsubscribe(y),o.signal&&o.signal.removeEventListener("abort",y)}let L=new XMLHttpRequest;L.open(o.method.toUpperCase(),o.url,!0),L.timeout=o.timeout;function I(){if(!L)return;const ut=ie.from("getAllResponseHeaders"in L&&L.getAllResponseHeaders()),pt={data:!m||m==="text"||m==="json"?L.responseText:L.response,status:L.status,statusText:L.statusText,headers:ut,config:r,request:L};_o(function(gt){s(gt),H()},function(gt){c(gt),H()},pt),L=null}"onloadend"in L?L.onloadend=I:L.onreadystatechange=function(){!L||L.readyState!==4||L.status===0&&!(L.responseURL&&L.responseURL.indexOf("file:")===0)||setTimeout(I)},L.onabort=function(){L&&(c(new P("Request aborted",P.ECONNABORTED,r,L)),L=null)},L.onerror=function(){c(new P("Network Error",P.ERR_NETWORK,r,L)),L=null},L.ontimeout=function(){let ct=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const pt=o.transitional||Eo;o.timeoutErrorMessage&&(ct=o.timeoutErrorMessage),c(new P(ct,pt.clarifyTimeoutError?P.ETIMEDOUT:P.ECONNABORTED,r,L)),L=null},d===void 0&&g.setContentType(null),"setRequestHeader"in L&&_.forEach(g.toJSON(),function(ct,pt){L.setRequestHeader(pt,ct)}),_.isUndefined(o.withCredentials)||(L.withCredentials=!!o.withCredentials),m&&m!=="json"&&(L.responseType=o.responseType),p&&([D,N]=gi(p,!0),L.addEventListener("progress",D)),v&&L.upload&&([k,Q]=gi(v),L.upload.addEventListener("progress",k),L.upload.addEventListener("loadend",Q)),(o.cancelToken||o.signal)&&(y=ut=>{L&&(c(!ut||ut.type?new ua(null,r,L):ut),L.abort(),L=null)},o.cancelToken&&o.cancelToken.subscribe(y),o.signal&&(o.signal.aborted?y():o.signal.addEventListener("abort",y)));const st=$g(o.url);if(st&&Ft.protocols.indexOf(st)===-1){c(new P("Unsupported protocol "+st+":",P.ERR_BAD_REQUEST,r));return}L.send(d||null)})},am=(r,i)=>{const{length:s}=r=r?r.filter(Boolean):[];if(i||s){let c=new AbortController,o;const d=function(p){if(!o){o=!0,m();const y=p instanceof Error?p:this.reason;c.abort(y instanceof P?y:new ua(y instanceof Error?y.message:y))}};let g=i&&setTimeout(()=>{g=null,d(new P(`timeout ${i} of ms exceeded`,P.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:v}=c;return v.unsubscribe=()=>_.asap(m),v}},nm=function*(r,i){let s=r.byteLength;if(s<i){yield r;return}let c=0,o;for(;c<s;)o=c+i,yield r.slice(c,o),c=o},im=async function*(r,i){for await(const s of um(r))yield*nm(s,i)},um=async function*(r){if(r[Symbol.asyncIterator]){yield*r;return}const i=r.getReader();try{for(;;){const{done:s,value:c}=await i.read();if(s)break;yield c}}finally{await i.cancel()}},No=(r,i,s,c)=>{const o=im(r,i);let d=0,g,m=v=>{g||(g=!0,c&&c(v))};return new ReadableStream({async pull(v){try{const{done:p,value:y}=await o.next();if(p){m(),v.close();return}let k=y.byteLength;if(s){let D=d+=k;s(D)}v.enqueue(new Uint8Array(y))}catch(p){throw m(p),p}},cancel(v){return m(v),o.return()}},{highWaterMark:2})},mi=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",Uo=mi&&typeof ReadableStream=="function",rm=mi&&(typeof TextEncoder=="function"?(r=>i=>r.encode(i))(new TextEncoder):async r=>new Uint8Array(await new Response(r).arrayBuffer())),Bo=(r,...i)=>{try{return!!r(...i)}catch{return!1}},sm=Uo&&Bo(()=>{let r=!1;const i=new Request(Ft.origin,{body:new ReadableStream,method:"POST",get duplex(){return r=!0,"half"}}).headers.has("Content-Type");return r&&!i}),Co=64*1024,rr=Uo&&Bo(()=>_.isReadableStream(new Response("").body)),bi={stream:rr&&(r=>r.body)};mi&&(r=>{["text","arrayBuffer","blob","formData","stream"].forEach(i=>{!bi[i]&&(bi[i]=_.isFunction(r[i])?s=>s[i]():(s,c)=>{throw new P(`Response type '${i}' is not supported`,P.ERR_NOT_SUPPORT,c)})})})(new Response);const cm=async r=>{if(r==null)return 0;if(_.isBlob(r))return r.size;if(_.isSpecCompliantForm(r))return(await new Request(Ft.origin,{method:"POST",body:r}).arrayBuffer()).byteLength;if(_.isArrayBufferView(r)||_.isArrayBuffer(r))return r.byteLength;if(_.isURLSearchParams(r)&&(r=r+""),_.isString(r))return(await rm(r)).byteLength},om=async(r,i)=>{const s=_.toFiniteNumber(r.getContentLength());return s??cm(i)},sr={http:Dg,xhr:lm,fetch:mi&&(async r=>{let{url:i,method:s,data:c,signal:o,cancelToken:d,timeout:g,onDownloadProgress:m,onUploadProgress:v,responseType:p,headers:y,withCredentials:k="same-origin",fetchOptions:D}=Mo(r);p=p?(p+"").toLowerCase():"text";let Q=am([o,d&&d.toAbortSignal()],g),N;const H=Q&&Q.unsubscribe&&(()=>{Q.unsubscribe()});let L;try{if(v&&sm&&s!=="get"&&s!=="head"&&(L=await om(y,c))!==0){let pt=new Request(i,{method:"POST",body:c,duplex:"half"}),V;if(_.isFormData(c)&&(V=pt.headers.get("content-type"))&&y.setContentType(V),pt.body){const[gt,Zt]=ko(L,gi(zo(v)));c=No(pt.body,Co,gt,Zt)}}_.isString(k)||(k=k?"include":"omit");const I="credentials"in Request.prototype;N=new Request(i,{...D,signal:Q,method:s.toUpperCase(),headers:y.normalize().toJSON(),body:c,duplex:"half",credentials:I?k:void 0});let st=await fetch(N,D);const ut=rr&&(p==="stream"||p==="response");if(rr&&(m||ut&&H)){const pt={};["status","statusText","headers"].forEach(et=>{pt[et]=st[et]});const V=_.toFiniteNumber(st.headers.get("content-length")),[gt,Zt]=m&&ko(V,gi(zo(m),!0))||[];st=new Response(No(st.body,Co,gt,()=>{Zt&&Zt(),H&&H()}),pt)}p=p||"text";let ct=await bi[_.findKey(bi,p)||"text"](st,r);return!ut&&H&&H(),await new Promise((pt,V)=>{_o(pt,V,{data:ct,headers:ie.from(st.headers),status:st.status,statusText:st.statusText,config:r,request:N})})}catch(I){throw H&&H(),I&&I.name==="TypeError"&&/Load failed|fetch/i.test(I.message)?Object.assign(new P("Network Error",P.ERR_NETWORK,r,N),{cause:I.cause||I}):P.from(I,I&&I.code,r,N)}})};_.forEach(sr,(r,i)=>{if(r){try{Object.defineProperty(r,"name",{value:i})}catch{}Object.defineProperty(r,"adapterName",{value:i})}});const qo=r=>`- ${r}`,fm=r=>_.isFunction(r)||r===null||r===!1,Ho={getAdapter:r=>{r=_.isArray(r)?r:[r];const{length:i}=r;let s,c;const o={};for(let d=0;d<i;d++){s=r[d];let g;if(c=s,!fm(s)&&(c=sr[(g=String(s)).toLowerCase()],c===void 0))throw new P(`Unknown adapter '${g}'`);if(c)break;o[g||"#"+d]=c}if(!c){const d=Object.entries(o).map(([m,v])=>`adapter ${m} `+(v===!1?"is not supported by the environment":"is not available in the build"));let g=i?d.length>1?`since :
161
161
  `+d.map(qo).join(`
162
162
  `):" "+qo(d[0]):"as no adapter specified";throw new P("There is no suitable adapter to dispatch the request "+g,"ERR_NOT_SUPPORT")}return c},adapters:sr};function cr(r){if(r.cancelToken&&r.cancelToken.throwIfRequested(),r.signal&&r.signal.aborted)throw new ua(null,r)}function jo(r){return cr(r),r.headers=ie.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),Ho.getAdapter(r.adapter||en.adapter)(r).then(function(c){return cr(r),c.data=ur.call(r,r.transformResponse,c),c.headers=ie.from(c.headers),c},function(c){return Ro(c)||(cr(r),c&&c.response&&(c.response.data=ur.call(r,r.transformResponse,c.response),c.response.headers=ie.from(c.response.headers))),Promise.reject(c)})}const Lo="1.10.0",yi={};["object","boolean","number","function","string","symbol"].forEach((r,i)=>{yi[r]=function(c){return typeof c===r||"a"+(i<1?"n ":" ")+r}});const Yo={};yi.transitional=function(i,s,c){function o(d,g){return"[Axios v"+Lo+"] Transitional option '"+d+"'"+g+(c?". "+c:"")}return(d,g,m)=>{if(i===!1)throw new P(o(g," has been removed"+(s?" in "+s:"")),P.ERR_DEPRECATED);return s&&!Yo[g]&&(Yo[g]=!0,console.warn(o(g," has been deprecated since v"+s+" and will be removed in the near future"))),i?i(d,g,m):!0}},yi.spelling=function(i){return(s,c)=>(console.warn(`${c} is likely a misspelling of ${i}`),!0)};function dm(r,i,s){if(typeof r!="object")throw new P("options must be an object",P.ERR_BAD_OPTION_VALUE);const c=Object.keys(r);let o=c.length;for(;o-- >0;){const d=c[o],g=i[d];if(g){const m=r[d],v=m===void 0||g(m,d,r);if(v!==!0)throw new P("option "+d+" must be "+v,P.ERR_BAD_OPTION_VALUE);continue}if(s!==!0)throw new P("Unknown option "+d,P.ERR_BAD_OPTION)}}const vi={assertOptions:dm,validators:yi},qe=vi.validators;let jl=class{constructor(i){this.defaults=i||{},this.interceptors={request:new xo,response:new xo}}async request(i,s){try{return await this._request(i,s)}catch(c){if(c instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const d=o.stack?o.stack.replace(/^.+\n/,""):"";try{c.stack?d&&!String(c.stack).endsWith(d.replace(/^.+\n.+\n/,""))&&(c.stack+=`
163
- `+d):c.stack=d}catch{}}throw c}}_request(i,s){typeof i=="string"?(s=s||{},s.url=i):s=i||{},s=Hl(this.defaults,s);const{transitional:c,paramsSerializer:o,headers:d}=s;c!==void 0&&vi.assertOptions(c,{silentJSONParsing:qe.transitional(qe.boolean),forcedJSONParsing:qe.transitional(qe.boolean),clarifyTimeoutError:qe.transitional(qe.boolean)},!1),o!=null&&(_.isFunction(o)?s.paramsSerializer={serialize:o}:vi.assertOptions(o,{encode:qe.function,serialize:qe.function},!0)),s.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?s.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:s.allowAbsoluteUrls=!0),vi.assertOptions(s,{baseUrl:qe.spelling("baseURL"),withXsrfToken:qe.spelling("withXSRFToken")},!0),s.method=(s.method||this.defaults.method||"get").toLowerCase();let g=d&&_.merge(d.common,d[s.method]);d&&_.forEach(["delete","get","head","post","put","patch","common"],N=>{delete d[N]}),s.headers=ie.concat(g,d);const m=[];let v=!0;this.interceptors.request.forEach(function(H){typeof H.runWhen=="function"&&H.runWhen(s)===!1||(v=v&&H.synchronous,m.unshift(H.fulfilled,H.rejected))});const p=[];this.interceptors.response.forEach(function(H){p.push(H.fulfilled,H.rejected)});let y,k=0,D;if(!v){const N=[jo.bind(this),void 0];for(N.unshift.apply(N,m),N.push.apply(N,p),D=N.length,y=Promise.resolve(s);k<D;)y=y.then(N[k++],N[k++]);return y}D=m.length;let Q=s;for(k=0;k<D;){const N=m[k++],H=m[k++];try{Q=N(Q)}catch(L){H.call(this,L);break}}try{y=jo.call(this,Q)}catch(N){return Promise.reject(N)}for(k=0,D=p.length;k<D;)y=y.then(p[k++],p[k++]);return y}getUri(i){i=Hl(this.defaults,i);const s=Oo(i.baseURL,i.url,i.allowAbsoluteUrls);return So(s,i.params,i.paramsSerializer)}};_.forEach(["delete","get","head","options"],function(i){jl.prototype[i]=function(s,c){return this.request(Hl(c||{},{method:i,url:s,data:(c||{}).data}))}}),_.forEach(["post","put","patch"],function(i){function s(c){return function(d,g,m){return this.request(Hl(m||{},{method:i,headers:c?{"Content-Type":"multipart/form-data"}:{},url:d,data:g}))}}jl.prototype[i]=s(),jl.prototype[i+"Form"]=s(!0)});let hm=class Cp{constructor(i){if(typeof i!="function")throw new TypeError("executor must be a function.");let s;this.promise=new Promise(function(d){s=d});const c=this;this.promise.then(o=>{if(!c._listeners)return;let d=c._listeners.length;for(;d-- >0;)c._listeners[d](o);c._listeners=null}),this.promise.then=o=>{let d;const g=new Promise(m=>{c.subscribe(m),d=m}).then(o);return g.cancel=function(){c.unsubscribe(d)},g},i(function(d,g,m){c.reason||(c.reason=new ua(d,g,m),s(c.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 s=this._listeners.indexOf(i);s!==-1&&this._listeners.splice(s,1)}toAbortSignal(){const i=new AbortController,s=c=>{i.abort(c)};return this.subscribe(s),i.signal.unsubscribe=()=>this.unsubscribe(s),i.signal}static source(){let i;return{token:new Cp(function(o){i=o}),cancel:i}}};function pm(r){return function(s){return r.apply(null,s)}}function gm(r){return _.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 Go(r){const i=new jl(r),s=no(jl.prototype.request,i);return _.extend(s,jl.prototype,i,{allOwnKeys:!0}),_.extend(s,i,null,{allOwnKeys:!0}),s.create=function(o){return Go(Hl(r,o))},s}const Dt=Go(en);Dt.Axios=jl,Dt.CanceledError=ua,Dt.CancelToken=hm,Dt.isCancel=Ro,Dt.VERSION=Lo,Dt.toFormData=hi,Dt.AxiosError=P,Dt.Cancel=Dt.CanceledError,Dt.all=function(i){return Promise.all(i)},Dt.spread=pm,Dt.isAxiosError=gm,Dt.mergeConfig=Hl,Dt.AxiosHeaders=ie,Dt.formToJSON=r=>To(_.isHTMLForm(r)?new FormData(r):r),Dt.getAdapter=Ho.getAdapter,Dt.HttpStatusCode=or,Dt.default=Dt;const{Axios:lv,AxiosError:av,CanceledError:nv,isCancel:iv,CancelToken:uv,VERSION:rv,all:sv,Cancel:cv,isAxiosError:ov,spread:fv,toFormData:dv,AxiosHeaders:hv,HttpStatusCode:pv,formToJSON:gv,getAdapter:mv,mergeConfig:bv}=Dt,mm=async(r,i)=>{var o;const s=(o=window.location.search.replace("?","").split("&").find(d=>d.includes("utm")))==null?void 0:o.split("=")[1];return(await Dt.post(i,{message:r},{headers:{utm:s}})).data.output},bm=async r=>{const i=await Dt.get(r),s=[];for(const c of i.data.propertyName){const o=JSON.parse(c);s.push(o)}return s.reverse()};function ym({theme:r="boring",notificationBadge:i=!0,greeting:s,pageContext:c,chatPrompts:o=[],chatbotUrl:d,dialogeBaseUrl:g}){const m=s?[{content:s,sender:"bot"}]:[],[v,p]=Wt.useState(!1),[y,k]=Wt.useState(s?m:[]),[D,Q]=Wt.useState(""),[N,H]=Wt.useState(!1),[L,I]=Wt.useState(!0),st=Wt.useRef(null),[ut,ct]=Wt.useState(o),pt=()=>{var et;(et=st.current)==null||et.scrollIntoView({behavior:"smooth"})};Wt.useEffect(()=>{y.filter(Rt=>Rt.sender==="user").length>0?I(!1):I(!0),pt()},[y]),Wt.useEffect(()=>{y.length<=1&&bm(g).then(et=>{const Rt=et.map(ue=>({content:ue.data.content,sender:ue.type==="human"?"user":"bot"}));k([...m,...Rt])})},[g]),Wt.useEffect(()=>{const et=window.location.pathname;if(c){for(const[Rt,{exec:ue,timer:Lt}]of Object.entries(c))if(Rt===et){V(Lt,ue);break}}},[c]);const V=async(et,Rt)=>{await Z0(et),Rt({open:{isOpen:v,setIsOpen:p},messageOptions:{messages:y,setMessages:k},input:{inputValue:D,setInputValue:Q},promptsOptions:{prompts:ut,setPrompts:ct},scrollToBottom:pt})},gt=async et=>{const Rt=et||D.trim();if(!Rt)return;const ue={content:Rt,sender:"user"};k(Lt=>[...Lt,ue]),Q(""),H(!0);try{const Pt={content:await mm(Rt,d),sender:"bot"};k(He=>[...He,Pt])}catch{const Pt={content:"Unfortunately, an error occurred while processing your request.",sender:"bot"};k(He=>[...He,Pt])}finally{H(!1)}},Zt=async et=>{et.key==="Enter"&&!et.shiftKey&&(et.preventDefault(),await gt())};return J.jsxs("div",{className:"fixed bottom-6 right-6 z-50",children:[J.jsx("div",{className:`
163
+ `+d):c.stack=d}catch{}}throw c}}_request(i,s){typeof i=="string"?(s=s||{},s.url=i):s=i||{},s=Hl(this.defaults,s);const{transitional:c,paramsSerializer:o,headers:d}=s;c!==void 0&&vi.assertOptions(c,{silentJSONParsing:qe.transitional(qe.boolean),forcedJSONParsing:qe.transitional(qe.boolean),clarifyTimeoutError:qe.transitional(qe.boolean)},!1),o!=null&&(_.isFunction(o)?s.paramsSerializer={serialize:o}:vi.assertOptions(o,{encode:qe.function,serialize:qe.function},!0)),s.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?s.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:s.allowAbsoluteUrls=!0),vi.assertOptions(s,{baseUrl:qe.spelling("baseURL"),withXsrfToken:qe.spelling("withXSRFToken")},!0),s.method=(s.method||this.defaults.method||"get").toLowerCase();let g=d&&_.merge(d.common,d[s.method]);d&&_.forEach(["delete","get","head","post","put","patch","common"],N=>{delete d[N]}),s.headers=ie.concat(g,d);const m=[];let v=!0;this.interceptors.request.forEach(function(H){typeof H.runWhen=="function"&&H.runWhen(s)===!1||(v=v&&H.synchronous,m.unshift(H.fulfilled,H.rejected))});const p=[];this.interceptors.response.forEach(function(H){p.push(H.fulfilled,H.rejected)});let y,k=0,D;if(!v){const N=[jo.bind(this),void 0];for(N.unshift.apply(N,m),N.push.apply(N,p),D=N.length,y=Promise.resolve(s);k<D;)y=y.then(N[k++],N[k++]);return y}D=m.length;let Q=s;for(k=0;k<D;){const N=m[k++],H=m[k++];try{Q=N(Q)}catch(L){H.call(this,L);break}}try{y=jo.call(this,Q)}catch(N){return Promise.reject(N)}for(k=0,D=p.length;k<D;)y=y.then(p[k++],p[k++]);return y}getUri(i){i=Hl(this.defaults,i);const s=Oo(i.baseURL,i.url,i.allowAbsoluteUrls);return So(s,i.params,i.paramsSerializer)}};_.forEach(["delete","get","head","options"],function(i){jl.prototype[i]=function(s,c){return this.request(Hl(c||{},{method:i,url:s,data:(c||{}).data}))}}),_.forEach(["post","put","patch"],function(i){function s(c){return function(d,g,m){return this.request(Hl(m||{},{method:i,headers:c?{"Content-Type":"multipart/form-data"}:{},url:d,data:g}))}}jl.prototype[i]=s(),jl.prototype[i+"Form"]=s(!0)});let hm=class Cp{constructor(i){if(typeof i!="function")throw new TypeError("executor must be a function.");let s;this.promise=new Promise(function(d){s=d});const c=this;this.promise.then(o=>{if(!c._listeners)return;let d=c._listeners.length;for(;d-- >0;)c._listeners[d](o);c._listeners=null}),this.promise.then=o=>{let d;const g=new Promise(m=>{c.subscribe(m),d=m}).then(o);return g.cancel=function(){c.unsubscribe(d)},g},i(function(d,g,m){c.reason||(c.reason=new ua(d,g,m),s(c.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 s=this._listeners.indexOf(i);s!==-1&&this._listeners.splice(s,1)}toAbortSignal(){const i=new AbortController,s=c=>{i.abort(c)};return this.subscribe(s),i.signal.unsubscribe=()=>this.unsubscribe(s),i.signal}static source(){let i;return{token:new Cp(function(o){i=o}),cancel:i}}};function pm(r){return function(s){return r.apply(null,s)}}function gm(r){return _.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 Go(r){const i=new jl(r),s=no(jl.prototype.request,i);return _.extend(s,jl.prototype,i,{allOwnKeys:!0}),_.extend(s,i,null,{allOwnKeys:!0}),s.create=function(o){return Go(Hl(r,o))},s}const Dt=Go(en);Dt.Axios=jl,Dt.CanceledError=ua,Dt.CancelToken=hm,Dt.isCancel=Ro,Dt.VERSION=Lo,Dt.toFormData=hi,Dt.AxiosError=P,Dt.Cancel=Dt.CanceledError,Dt.all=function(i){return Promise.all(i)},Dt.spread=pm,Dt.isAxiosError=gm,Dt.mergeConfig=Hl,Dt.AxiosHeaders=ie,Dt.formToJSON=r=>To(_.isHTMLForm(r)?new FormData(r):r),Dt.getAdapter=Ho.getAdapter,Dt.HttpStatusCode=or,Dt.default=Dt;const{Axios:lv,AxiosError:av,CanceledError:nv,isCancel:iv,CancelToken:uv,VERSION:rv,all:sv,Cancel:cv,isAxiosError:ov,spread:fv,toFormData:dv,AxiosHeaders:hv,HttpStatusCode:pv,formToJSON:gv,getAdapter:mv,mergeConfig:bv}=Dt,mm=async(r,i)=>{var o;const s=(o=window.location.search.replace("?","").split("&").find(d=>d.includes("utm")))==null?void 0:o.split("=")[1];return(await Dt.post(i,{message:r},{headers:{utm:s}})).data.output},bm=async r=>{const i=await Dt.get(r),s=[];for(const c of i.data.propertyName){const o=JSON.parse(c);s.push(o)}return s.reverse()};function ym({theme:r="boring",notificationBadge:i=!0,greeting:s,pageContext:c,chatPrompts:o=[],chatbotUrl:d,dialogeBaseUrl:g}){const m=s?[{content:s,sender:"bot"}]:[],[v,p]=Wt.useState(!1),[y,k]=Wt.useState(s?m:[]),[D,Q]=Wt.useState(""),[N,H]=Wt.useState(!1),[L,I]=Wt.useState(!0),st=Wt.useRef(null),[ut,ct]=Wt.useState(o),pt=()=>{var et;(et=st.current)==null||et.scrollIntoView({behavior:"smooth"})};Wt.useEffect(()=>{y.filter(Rt=>Rt.sender==="user").length>0?I(!1):I(!0),pt()},[y]),Wt.useEffect(()=>{y.length<=1&&bm(g).then(et=>{const Rt=et.map(ue=>({content:ue.data.content,sender:ue.type==="human"?"user":"bot"}));k([...m,...Rt])})},[g]),Wt.useEffect(()=>{const et=window.location.pathname;if(c){for(const[Rt,{exec:ue,timer:Lt}]of Object.entries(c))if(Rt===et){V(Lt,ue);break}}},[c]);const V=async(et,Rt)=>{await Z0(et),Rt({open:{isOpen:v,setIsOpen:p},messageOptions:{messages:y,setMessages:k},input:{inputValue:D,setInputValue:Q},promptsOptions:{prompts:ut,setPrompts:ct},scrollToBottom:pt})},gt=async et=>{const Rt=et||D.trim();if(!Rt)return;const ue={content:Rt,sender:"user"};k(Lt=>[...Lt,ue]),Q(""),H(!0);try{const Pt={content:await mm(Rt,d),sender:"bot"};k(He=>[...He,Pt])}catch{const Pt={content:"Unfortunately, an error occurred while processing your request.",sender:"bot"};k(He=>[...He,Pt])}finally{H(!1)}},Zt=async et=>{et.key==="Enter"&&!et.shiftKey&&(et.preventDefault(),await gt())};return J.jsxs("div",{className:"fixed bottom-6 right-6 z-50 ai-chatbot",children:[J.jsx("div",{className:`
164
164
  absolute bottom-16 right-0 w-96 h-[550px]
165
165
  transform transition-all duration-300 ease-in-out origin-bottom-right
166
+ ai-chatbot-window
166
167
  ${v?"scale-100 opacity-100":"scale-0 opacity-0 pointer-events-none"}
167
168
  `,children:J.jsxs("div",{className:`${ae(r,"mainBackground")} rounded-4xl shadow-2xl backdrop-blur-xl h-full flex flex-col overflow-hidden`,children:[J.jsx(a0,{setIsOpen:p,theme:r}),J.jsxs("div",{className:"flex-1 flex flex-col h-full justify-between overflow-y-auto p-4 space-y-4 scrollbar-thin scrollbar-thumb-purple-500/50 scrollbar-track-transparent",children:[J.jsxs("div",{className:"space-y-4 ",children:[y.map((et,Rt)=>J.jsx(L0,{message:et,index:Rt,theme:r},et.content)),N&&J.jsx(Y0,{}),J.jsx("div",{ref:st})]}),L&&J.jsx("div",{className:"flex gap-2 flex-wrap",children:ut.map(et=>J.jsx(V0,{prompt:et,handleSendMessage:gt,theme:r},et))})]}),J.jsx(X0,{handleKeyPress:Zt,inputValue:D,setInputValue:Q,handleSendMessage:()=>gt(),theme:r})]})}),J.jsx(Q0,{isOpen:v,setIsOpen:p,theme:r}),!v&&i&&J.jsx(G0,{})]})}function vm(r,i={}){const s=typeof r=="string"?document.querySelector(r):r;Kp.createRoot(s).render(J.jsx(ym,{...i}))}return Ze.mountChatbotWidget=vm,Object.defineProperty(Ze,Symbol.toStringTag,{value:"Module"}),Ze}({});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-chatbot-widget",
3
- "version": "0.0.12",
3
+ "version": "0.0.13",
4
4
  "type": "module",
5
5
  "main": "dist/chatbot-widget.iife.js",
6
6
  "module": "dist/chatbot-widget.es.js",