react-aichatbot-widget 2.0.8 → 2.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.js +4 -4
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(s=>r.set(s)),r}static accessor(t){const r=(this[De]=this[De]={accessors:{}}).accessors,s=this.prototype;function i(o){const l=Q(o);r[l]||(Dn(s,o),r[l]=!0)}return a.isArray(t)?t.forEach(i):i(t),this}};P.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);a.reduceDescriptors(P.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}});a.freezeMethods(P);function be(e,t){const n=this||te,r=t||n,s=P.from(r.headers);let i=r.data;return a.forEach(e,function(l){i=l.call(n,i,s.normalize(),t?t.status:void 0)}),s.normalize(),i}function ut(e){return!!(e&&e.__CANCEL__)}function X(e,t,n){g.call(this,e??"canceled",g.ERR_CANCELED,t,n),this.name="CanceledError"}a.inherits(X,g,{__CANCEL__:!0});function dt(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new g("Request failed with status code "+n.status,[g.ERR_BAD_REQUEST,g.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function Bn(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function vn(e,t){e=e||10;const n=new Array(e),r=new Array(e);let s=0,i=0,o;return t=t!==void 0?t:1e3,function(f){const d=Date.now(),u=r[i];o||(o=d),n[s]=f,r[s]=d;let h=i,x=0;for(;h!==s;)x+=n[h++],h=h%e;if(s=(s+1)%e,s===i&&(i=(i+1)%e),d-o<t)return;const S=u&&d-u;return S?Math.round(x*1e3/S):void 0}}function $n(e,t){let n=0,r=1e3/t,s,i;const o=(d,u=Date.now())=>{n=u,s=null,i&&(clearTimeout(i),i=null),e(...d)};return[(...d)=>{const u=Date.now(),h=u-n;h>=r?o(d,u):(s=d,i||(i=setTimeout(()=>{i=null,o(s)},r-h)))},()=>s&&o(s)]}const le=(e,t,n=3)=>{let r=0;const s=vn(50,250);return $n(i=>{const o=i.loaded,l=i.lengthComputable?i.total:void 0,f=o-r,d=s(f),u=o<=l;r=o;const h={loaded:o,total:l,progress:l?o/l:void 0,bytes:f,rate:d||void 0,estimated:d&&l&&u?(l-o)/d:void 0,event:i,lengthComputable:l!=null,[t?"download":"upload"]:!0};e(h)},n)},Be=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},ve=e=>(...t)=>a.asap(()=>e(...t)),Hn=j.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,j.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(j.origin),j.navigator&&/(msie|trident)/i.test(j.navigator.userAgent)):()=>!0,qn=j.hasStandardBrowserEnv?{write(e,t,n,r,s,i,o){if(typeof document>"u")return;const l=[`${e}=${encodeURIComponent(t)}`];a.isNumber(n)&&l.push(`expires=${new Date(n).toUTCString()}`),a.isString(r)&&l.push(`path=${r}`),a.isString(s)&&l.push(`domain=${s}`),i===!0&&l.push("secure"),a.isString(o)&&l.push(`SameSite=${o}`),document.cookie=l.join("; ")},read(e){if(typeof document>"u")return null;const t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function Mn(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function zn(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function ft(e,t,n){let r=!Mn(t);return e&&(r||n==!1)?zn(e,t):t}const $e=e=>e instanceof P?{...e}:e;function z(e,t){t=t||{};const n={};function r(d,u,h,x){return a.isPlainObject(d)&&a.isPlainObject(u)?a.merge.call({caseless:x},d,u):a.isPlainObject(u)?a.merge({},u):a.isArray(u)?u.slice():u}function s(d,u,h,x){if(a.isUndefined(u)){if(!a.isUndefined(d))return r(void 0,d,h,x)}else return r(d,u,h,x)}function i(d,u){if(!a.isUndefined(u))return r(void 0,u)}function o(d,u){if(a.isUndefined(u)){if(!a.isUndefined(d))return r(void 0,d)}else return r(void 0,u)}function l(d,u,h){if(h in t)return r(d,u);if(h in e)return r(void 0,d)}const f={url:i,method:i,data:i,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:l,headers:(d,u,h)=>s($e(d),$e(u),h,!0)};return a.forEach(Object.keys({...e,...t}),function(u){const h=f[u]||s,x=h(e[u],t[u],u);a.isUndefined(x)&&h!==l||(n[u]=x)}),n}const pt=e=>{const t=z({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:s,xsrfCookieName:i,headers:o,auth:l}=t;if(t.headers=o=P.from(o),t.url=at(ft(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),l&&o.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):""))),a.isFormData(n)){if(j.hasStandardBrowserEnv||j.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(a.isFunction(n.getHeaders)){const f=n.getHeaders(),d=["content-type","content-length"];Object.entries(f).forEach(([u,h])=>{d.includes(u.toLowerCase())&&o.set(u,h)})}}if(j.hasStandardBrowserEnv&&(r&&a.isFunction(r)&&(r=r(t)),r||r!==!1&&Hn(t.url))){const f=s&&i&&qn.read(i);f&&o.set(s,f)}return t},Wn=typeof XMLHttpRequest<"u",Jn=Wn&&function(e){return new Promise(function(n,r){const s=pt(e);let i=s.data;const o=P.from(s.headers).normalize();let{responseType:l,onUploadProgress:f,onDownloadProgress:d}=s,u,h,x,S,c;function m(){S&&S(),c&&c(),s.cancelToken&&s.cancelToken.unsubscribe(u),s.signal&&s.signal.removeEventListener("abort",u)}let p=new XMLHttpRequest;p.open(s.method.toUpperCase(),s.url,!0),p.timeout=s.timeout;function w(){if(!p)return;const E=P.from("getAllResponseHeaders"in p&&p.getAllResponseHeaders()),O={data:!l||l==="text"||l==="json"?p.responseText:p.response,status:p.status,statusText:p.statusText,headers:E,config:e,request:p};dt(function(b){n(b),m()},function(b){r(b),m()},O),p=null}"onloadend"in p?p.onloadend=w:p.onreadystatechange=function(){!p||p.readyState!==4||p.status===0&&!(p.responseURL&&p.responseURL.indexOf("file:")===0)||setTimeout(w)},p.onabort=function(){p&&(r(new g("Request aborted",g.ECONNABORTED,e,p)),p=null)},p.onerror=function(C){const O=C&&C.message?C.message:"Network Error",U=new g(O,g.ERR_NETWORK,e,p);U.event=C||null,r(U),p=null},p.ontimeout=function(){let C=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded";const O=s.transitional||lt;s.timeoutErrorMessage&&(C=s.timeoutErrorMessage),r(new g(C,O.clarifyTimeoutError?g.ETIMEDOUT:g.ECONNABORTED,e,p)),p=null},i===void 0&&o.setContentType(null),"setRequestHeader"in p&&a.forEach(o.toJSON(),function(C,O){p.setRequestHeader(O,C)}),a.isUndefined(s.withCredentials)||(p.withCredentials=!!s.withCredentials),l&&l!=="json"&&(p.responseType=s.responseType),d&&([x,c]=le(d,!0),p.addEventListener("progress",x)),f&&p.upload&&([h,S]=le(f),p.upload.addEventListener("progress",h),p.upload.addEventListener("loadend",S)),(s.cancelToken||s.signal)&&(u=E=>{p&&(r(!E||E.type?new X(null,e,p):E),p.abort(),p=null)},s.cancelToken&&s.cancelToken.subscribe(u),s.signal&&(s.signal.aborted?u():s.signal.addEventListener("abort",u)));const T=Bn(s.url);if(T&&j.protocols.indexOf(T)===-1){r(new g("Unsupported protocol "+T+":",g.ERR_BAD_REQUEST,e));return}p.send(i||null)})},Vn=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,s;const i=function(d){if(!s){s=!0,l();const u=d instanceof Error?d:this.reason;r.abort(u instanceof g?u:new X(u instanceof Error?u.message:u))}};let o=t&&setTimeout(()=>{o=null,i(new g(`timeout ${t} of ms exceeded`,g.ETIMEDOUT))},t);const l=()=>{e&&(o&&clearTimeout(o),o=null,e.forEach(d=>{d.unsubscribe?d.unsubscribe(i):d.removeEventListener("abort",i)}),e=null)};e.forEach(d=>d.addEventListener("abort",i));const{signal:f}=r;return f.unsubscribe=()=>a.asap(l),f}},Kn=function*(e,t){let n=e.byteLength;if(n<t){yield e;return}let r=0,s;for(;r<n;)s=r+t,yield e.slice(r,s),r=s},Xn=async function*(e,t){for await(const n of Gn(e))yield*Kn(n,t)},Gn=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:r}=await t.read();if(n)break;yield r}}finally{await t.cancel()}},He=(e,t,n,r)=>{const s=Xn(e,t);let i=0,o,l=f=>{o||(o=!0,r&&r(f))};return new ReadableStream({async pull(f){try{const{done:d,value:u}=await s.next();if(d){l(),f.close();return}let h=u.byteLength;if(n){let x=i+=h;n(x)}f.enqueue(new Uint8Array(u))}catch(d){throw l(d),d}},cancel(f){return l(f),s.return()}},{highWaterMark:2})},qe=64*1024,{isFunction:se}=a,Qn=(({Request:e,Response:t})=>({Request:e,Response:t}))(a.global),{ReadableStream:Me,TextEncoder:ze}=a.global,We=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Yn=e=>{e=a.merge.call({skipUndefined:!0},Qn,e);const{fetch:t,Request:n,Response:r}=e,s=t?se(t):typeof fetch=="function",i=se(n),o=se(r);if(!s)return!1;const l=s&&se(Me),f=s&&(typeof ze=="function"?(c=>m=>c.encode(m))(new ze):async c=>new Uint8Array(await new n(c).arrayBuffer())),d=i&&l&&We(()=>{let c=!1;const m=new n(j.origin,{body:new Me,method:"POST",get duplex(){return c=!0,"half"}}).headers.has("Content-Type");return c&&!m}),u=o&&l&&We(()=>a.isReadableStream(new r("").body)),h={stream:u&&(c=>c.body)};s&&["text","arrayBuffer","blob","formData","stream"].forEach(c=>{!h[c]&&(h[c]=(m,p)=>{let w=m&&m[c];if(w)return w.call(m);throw new g(`Response type '${c}' is not supported`,g.ERR_NOT_SUPPORT,p)})});const x=async c=>{if(c==null)return 0;if(a.isBlob(c))return c.size;if(a.isSpecCompliantForm(c))return(await new n(j.origin,{method:"POST",body:c}).arrayBuffer()).byteLength;if(a.isArrayBufferView(c)||a.isArrayBuffer(c))return c.byteLength;if(a.isURLSearchParams(c)&&(c=c+""),a.isString(c))return(await f(c)).byteLength},S=async(c,m)=>{const p=a.toFiniteNumber(c.getContentLength());return p??x(m)};return async c=>{let{url:m,method:p,data:w,signal:T,cancelToken:E,timeout:C,onDownloadProgress:O,onUploadProgress:U,responseType:b,headers:k,withCredentials:_="same-origin",fetchOptions:W}=pt(c),Ae=t||fetch;b=b?(b+"").toLowerCase():"text";let ne=Vn([T,E&&E.toAbortSignal()],C),G=null;const H=ne&&ne.unsubscribe&&(()=>{ne.unsubscribe()});let je;try{if(U&&d&&p!=="get"&&p!=="head"&&(je=await S(k,w))!==0){let v=new n(m,{method:"POST",body:w,duplex:"half"}),J;if(a.isFormData(w)&&(J=v.headers.get("content-type"))&&k.setContentType(J),v.body){const[he,re]=Be(je,le(ve(U)));w=He(v.body,qe,he,re)}}a.isString(_)||(_=_?"include":"omit");const L=i&&"credentials"in n.prototype,ke={...W,signal:ne,method:p.toUpperCase(),headers:k.normalize().toJSON(),body:w,duplex:"half",credentials:L?_:void 0};G=i&&new n(m,ke);let B=await(i?Ae(G,W):Ae(m,ke));const Ne=u&&(b==="stream"||b==="response");if(u&&(O||Ne&&H)){const v={};["status","statusText","headers"].forEach(Fe=>{v[Fe]=B[Fe]});const J=a.toFiniteNumber(B.headers.get("content-length")),[he,re]=O&&Be(J,le(ve(O),!0))||[];B=new r(He(B.body,qe,he,()=>{re&&re(),H&&H()}),v)}b=b||"text";let xt=await h[a.findKey(h,b)||"text"](B,c);return!Ne&&H&&H(),await new Promise((v,J)=>{dt(v,J,{data:xt,headers:P.from(B.headers),status:B.status,statusText:B.statusText,config:c,request:G})})}catch(L){throw H&&H(),L&&L.name==="TypeError"&&/Load failed|fetch/i.test(L.message)?Object.assign(new g("Network Error",g.ERR_NETWORK,c,G),{cause:L.cause||L}):g.from(L,L&&L.code,c,G)}}},Zn=new Map,ht=e=>{let t=e&&e.env||{};const{fetch:n,Request:r,Response:s}=t,i=[r,s,n];let o=i.length,l=o,f,d,u=Zn;for(;l--;)f=i[l],d=u.get(f),d===void 0&&u.set(f,d=l?new Map:Yn(t)),u=d;return d};ht();const Te={http:yn,xhr:Jn,fetch:{get:ht}};a.forEach(Te,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Je=e=>`- ${e}`,er=e=>a.isFunction(e)||e===null||e===!1;function tr(e,t){e=a.isArray(e)?e:[e];const{length:n}=e;let r,s;const i={};for(let o=0;o<n;o++){r=e[o];let l;if(s=r,!er(r)&&(s=Te[(l=String(r)).toLowerCase()],s===void 0))throw new g(`Unknown adapter '${l}'`);if(s&&(a.isFunction(s)||(s=s.get(t))))break;i[l||"#"+o]=s}if(!s){const o=Object.entries(i).map(([f,d])=>`adapter ${f} `+(d===!1?"is not supported by the environment":"is not available in the build"));let l=n?o.length>1?`since :
|
|
4
4
|
`+o.map(Je).join(`
|
|
5
5
|
`):" "+Je(o[0]):"as no adapter specified";throw new g("There is no suitable adapter to dispatch the request "+l,"ERR_NOT_SUPPORT")}return s}const mt={getAdapter:tr,adapters:Te};function ge(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new X(null,e)}function Ve(e){return ge(e),e.headers=P.from(e.headers),e.data=be.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),mt.getAdapter(e.adapter||te.adapter,e)(e).then(function(r){return ge(e),r.data=be.call(e,e.transformResponse,r),r.headers=P.from(r.headers),r},function(r){return ut(r)||(ge(e),r&&r.response&&(r.response.data=be.call(e,e.transformResponse,r.response),r.response.headers=P.from(r.response.headers))),Promise.reject(r)})}const yt="1.13.2",pe={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{pe[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Ke={};pe.transitional=function(t,n,r){function s(i,o){return"[Axios v"+yt+"] Transitional option '"+i+"'"+o+(r?". "+r:"")}return(i,o,l)=>{if(t===!1)throw new g(s(o," has been removed"+(n?" in "+n:"")),g.ERR_DEPRECATED);return n&&!Ke[o]&&(Ke[o]=!0,console.warn(s(o," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(i,o,l):!0}};pe.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function nr(e,t,n){if(typeof e!="object")throw new g("options must be an object",g.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let s=r.length;for(;s-- >0;){const i=r[s],o=t[i];if(o){const l=e[i],f=l===void 0||o(l,i,e);if(f!==!0)throw new g("option "+i+" must be "+f,g.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new g("Unknown option "+i,g.ERR_BAD_OPTION)}}const ae={assertOptions:nr,validators:pe},D=ae.validators;let M=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Le,response:new Le}}async request(t,n){try{return await this._request(t,n)}catch(r){if(r instanceof Error){let s={};Error.captureStackTrace?Error.captureStackTrace(s):s=new Error;const i=s.stack?s.stack.replace(/^.+\n/,""):"";try{r.stack?i&&!String(r.stack).endsWith(i.replace(/^.+\n.+\n/,""))&&(r.stack+=`
|
|
6
|
-
`+i):r.stack=i}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=z(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:i}=n;r!==void 0&&ae.assertOptions(r,{silentJSONParsing:D.transitional(D.boolean),forcedJSONParsing:D.transitional(D.boolean),clarifyTimeoutError:D.transitional(D.boolean)},!1),s!=null&&(a.isFunction(s)?n.paramsSerializer={serialize:s}:ae.assertOptions(s,{encode:D.function,serialize:D.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),ae.assertOptions(n,{baseUrl:D.spelling("baseURL"),withXsrfToken:D.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let o=i&&a.merge(i.common,i[n.method]);i&&a.forEach(["delete","get","head","post","put","patch","common"],c=>{delete i[c]}),n.headers=P.concat(o,i);const l=[];let f=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(n)===!1||(f=f&&m.synchronous,l.unshift(m.fulfilled,m.rejected))});const d=[];this.interceptors.response.forEach(function(m){d.push(m.fulfilled,m.rejected)});let u,h=0,x;if(!f){const c=[Ve.bind(this),void 0];for(c.unshift(...l),c.push(...d),x=c.length,u=Promise.resolve(n);h<x;)u=u.then(c[h++],c[h++]);return u}x=l.length;let S=n;for(;h<x;){const c=l[h++],m=l[h++];try{S=c(S)}catch(p){m.call(this,p);break}}try{u=Ve.call(this,S)}catch(c){return Promise.reject(c)}for(h=0,x=d.length;h<x;)u=u.then(d[h++],d[h++]);return u}getUri(t){t=z(this.defaults,t);const n=ft(t.baseURL,t.url,t.allowAbsoluteUrls);return at(n,t.params,t.paramsSerializer)}};a.forEach(["delete","get","head","options"],function(t){M.prototype[t]=function(n,r){return this.request(z(r||{},{method:t,url:n,data:(r||{}).data}))}});a.forEach(["post","put","patch"],function(t){function n(r){return function(i,o,l){return this.request(z(l||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:i,data:o}))}}M.prototype[t]=n(),M.prototype[t+"Form"]=n(!0)});let rr=class bt{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(i){n=i});const r=this;this.promise.then(s=>{if(!r._listeners)return;let i=r._listeners.length;for(;i-- >0;)r._listeners[i](s);r._listeners=null}),this.promise.then=s=>{let i;const o=new Promise(l=>{r.subscribe(l),i=l}).then(s);return o.cancel=function(){r.unsubscribe(i)},o},t(function(i,o,l){r.reason||(r.reason=new X(i,o,l),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new bt(function(s){t=s}),cancel:t}}};function sr(e){return function(n){return e.apply(null,n)}}function or(e){return a.isObject(e)&&e.isAxiosError===!0}const Ee={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,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Ee).forEach(([e,t])=>{Ee[t]=e});function gt(e){const t=new M(e),n=Xe(M.prototype.request,t);return a.extend(n,M.prototype,t,{allOwnKeys:!0}),a.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return gt(z(e,s))},n}const R=gt(te);R.Axios=M;R.CanceledError=X;R.CancelToken=rr;R.isCancel=ut;R.VERSION=yt;R.toFormData=fe;R.AxiosError=g;R.Cancel=R.CanceledError;R.all=function(t){return Promise.all(t)};R.spread=sr;R.isAxiosError=or;R.mergeConfig=z;R.AxiosHeaders=P;R.formToJSON=e=>ct(a.isHTMLForm(e)?new FormData(e):e);R.getAdapter=mt.getAdapter;R.HttpStatusCode=Ee;R.default=R;const{Axios:fr,AxiosError:pr,CanceledError:hr,isCancel:mr,CancelToken:yr,VERSION:br,all:gr,Cancel:xr,isAxiosError:Sr,spread:wr,toFormData:Er,AxiosHeaders:Rr,HttpStatusCode:Cr,formToJSON:Or,getAdapter:Tr,mergeConfig:Ar}=R,ir=async e=>{try{await R.get(`https://n8n.clone67.com/webhook/end-chat-session?sessionId=${e}`)}catch{throw new Error}},ar=({chatBotData:e,theme:t,onlineStatus:n,isExpand:r,endSession:s})=>{const[i,o]=N.useState(null),[l,f]=N.useState(""),[d,u]=N.useState("Connecting to server..."),[h,x]=N.useState(""),[S,c]=N.useState(!1);N.useEffect(()=>{var b=localStorage.getItem("clone67ChatSessionId");b===null&&(b=Tt(),localStorage.setItem("clone67ChatSessionId",b));const{socket:k}=kt(b,e.pineconeNamespace);o(k),k.onopen=()=>{u("Server connected"),setTimeout(()=>{u("")},2e3),n("online")},k.onmessage=async _=>{try{const W=await _.data;x(W),c(!1)}catch(W){console.error("Error handling server message:",W)}},k.onerror=_=>{u("Server error occurred"),console.error("WebSocket error:",_),n("offline")},k.onclose=()=>{u("Server disconnected"),n("offline")}},[]),N.useEffect(()=>{(async()=>{if(!s)return;const k=localStorage.getItem("clone67ChatSessionId");if(console.log("messagese are:",h),i&&i.readyState===WebSocket.OPEN)try{h&&await ir(k),i.send(JSON.stringify({type:"end_session"})),i.close(),localStorage.removeItem("clone67ChatSessionId")}catch(_){console.log("Error while saving messages",_)}})()},[s]);const m=async b=>{if(b.preventDefault(),i&&i.readyState===WebSocket.OPEN){const _={type:"chat",userInput:l};i.send(JSON.stringify(_))}c(!0);const k={created_at:Date.now(),sender_type:"user",message:l};x(JSON.stringify(k)),f("")},p=b=>{b.key==="Enter"&&!b.shiftKey&&(b.preventDefault(),m(b))},w={flex:1,padding:"12px 16px",background:`${S?`${t.primaryColor}33`:t.backgroundColor}`,color:t.fontColor,border:`1px solid ${t.primaryColor}`,borderRadius:"12px",fontSize:"14px",outline:"none",transition:"all 0.2s ease",boxShadow:"none",cursor:S?"not-allowed":"auto"},T={padding:"12px 20px",borderRadius:"12px",background:S?`${t.primaryColor}33`:`linear-gradient(135deg, ${t.primaryColor}, ${t.secondaryColor})`,color:t.fontColor,border:"none",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",fontWeight:"600",fontSize:"14px",transition:"all 0.2s ease",minWidth:"48px",cursor:S?"not-allowed":"pointer"},E={padding:"10px",borderColor:t.fontColor,background:t.backgroundColor,flexShrink:0},C={display:"flex",gap:"12px",alignItems:"center"},O={textAlign:"center",padding:"2px",backgroundColor:d==="Server connected"||d==="online"?"#09BA00":d==="Connecting to server..."?"#DED000":"#FF3408",color:"#ffffff",fontSize:"10px"},U={padding:"8px",animation:"fadeIn 0.3s ease-in-out, pulse 1.5s ease-in-out infinite",animationDelay:"0s, 0.3s",fontSize:"10px",color:t.fontColor};return y.jsxs(y.Fragment,{children:[d&&y.jsx("p",{style:O,children:d}),s?y.jsx(jt,{theme:t}):y.jsxs(y.Fragment,{children:[y.jsx(At,{messages:h,chatBotData:e,theme:t,isExpand:r}),S&&y.jsx("div",{style:U,children:`${e.name} is typing...`}),y.jsx("div",{style:E,children:y.jsxs("form",{onSubmit:m,style:C,children:[y.jsx("input",{type:"text",placeholder:"Type a message...",value:l,onChange:b=>f(b.target.value),disabled:S,onKeyDown:p,style:w,onFocus:b=>{b.target.style.boxShadow=`0 0 0 1px ${t.primaryColor}`,b.target.style.borderColor=t.primaryColor},onBlur:b=>{b.target.style.boxShadow="none",b.target.style.borderColor=t.primaryColor}}),y.jsx("button",{onClick:m,style:T,disabled:S,"aria-label":"Send message",children:y.jsx($.Send,{size:18})})]})})]})]})},lr=({theme:e,chatBotData:t,onClose:n})=>{const[r,s]=N.useState(!1),[i,o]=N.useState(!1),[l,f]=N.useState(!1),u={position:"fixed",bottom:"112px",[t.position==="left"?"left":"right"]:"32px",zIndex:50,width:r?"684px":"384px",height:r?"620px":"520px",background:`${e.backgroundColor}cc`,backdropFilter:"blur(16px)",WebkitBackdropFilter:"blur(16px)",borderRadius:"16px",border:"1px solid rgba(255, 255, 255, 0.3)",display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"system-ui, -apple-system, sans-serif",boxShadow:"0 10px 25px -3px rgba(0,0,0,0.1)"},h={padding:"16px 20px",background:`linear-gradient(135deg, ${e.primaryColor}, ${e.secondaryColor})`,color:e.fontColor,borderRadius:"16px 16px 0 0",display:"flex",alignItems:"center",justifyContent:"space-between",boxShadow:"0 4px 6px -1px rgba(0,0,0,0.1)"},x={position:"relative"},S={width:"44px",height:"44px",borderRadius:"50%",background:"rgba(255,255,255,0.2)",display:"flex",alignItems:"center",justifyContent:"center"},c={position:"absolute",bottom:0,right:0,width:"14px",height:"14px",backgroundColor:i?"#00BF49":"#F54927",borderRadius:"50%",border:"3px solid white"},m={fontSize:"18px",fontWeight:"600",margin:0,lineHeight:"1.2"},p={fontSize:"12px",opacity:.9,margin:0,lineHeight:"1.3"},w={padding:"8px",borderRadius:"50%",background:"transparent",border:"none",cursor:"pointer",transition:"background 0.2s"},T={padding:"10px",borderTop:"1px solid rgba(255,255,255,0.2)",background:e.backgroundColor,textAlign:"center"},E={fontSize:"11px",color:e.fontColor,letterSpacing:"0.5px"},C={fontWeight:"600"},O=(b,k)=>{b.currentTarget.style.background=k?"rgba(255,255,255,0.2)":"transparent"},U=b=>{o(b==="online")};return y.jsxs("div",{style:u,children:[y.jsxs("div",{style:h,children:[y.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[y.jsxs("div",{style:x,children:[y.jsx("div",{style:S,children:y.jsx($.MessageCircle,{size:22})}),y.jsx("span",{style:c})]}),y.jsxs("div",{children:[y.jsx("h3",{style:m,children:t.name}),y.jsx("p",{style:p,children:t.subTitle})]})]}),y.jsxs("div",{style:{display:"flex",alignItems:"left"},children:[y.jsx("button",{onClick:()=>s(b=>!b),"aria-label":"expand chat",style:w,onMouseEnter:b=>O(b,!0),onMouseLeave:b=>O(b,!1),children:r?y.jsx($.Minimize2,{size:20}):y.jsx($.Maximize2,{size:20})}),y.jsx("button",{onClick:()=>{f(!0),setTimeout(()=>{n()},2e3)},style:w,onMouseEnter:b=>O(b,!0),onMouseLeave:b=>O(b,!1),children:y.jsx($.X,{size:20})})]})]}),y.jsx(ar,{chatBotData:t,theme:e,onlineStatus:U,isExpand:r,endSession:l}),y.jsx("div",{style:T,children:y.jsxs("p",{style:E,children:["powered by ",y.jsx("span",{style:C,children:"clone67.com"})]})})]})},cr=({pineconeNamespace:e,primaryColor:t="#3b82f6",secondaryColor:n="#8b5cf6",backgroundColor:r="#ffffff",fontColor:s="#1f2937",placeholderColor:i="#9ca3af",position:o="right",name:l="AI Assistant",subTitle:f="AI powered assistant",welcomeText:d="Hi! How can I help you today?",aiInitialMessage:u=""})=>{const[h,x]=N.useState(!1),S=()=>x(O=>!O),c=()=>{x(!1)},m={primaryColor:t,secondaryColor:n,backgroundColor:r,fontColor:s,placeholderColor:i,inputBackgroundColor:r},p={name:l,subTitle:f,welcomeText:d,pineconeNamespace:e,position:o,aiInitialMessage:u};u===""&&(p.aiInitialMessage=`Hello! I'm ${p.name}, your AI assistant. How can I help you today?`);const w=o==="left",T="32px",E={position:"fixed",bottom:"104px",[w?"left":"right"]:T,zIndex:9999,pointerEvents:"auto"},C={position:"fixed",bottom:"32px",[w?"left":"right"]:T,zIndex:1e4,pointerEvents:"auto"};return y.jsxs(y.Fragment,{children:[h&&y.jsx("div",{style:E,children:y.jsx(lr,{onClose:c,theme:m,chatBotData:p})}),y.jsx("div",{style:C,children:y.jsx(St,{onMinimise:S,isOpen:h,theme:m,chatBotData:p})})]})};module.exports=cr;
|
|
6
|
+
`+i):r.stack=i}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=z(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:i}=n;r!==void 0&&ae.assertOptions(r,{silentJSONParsing:D.transitional(D.boolean),forcedJSONParsing:D.transitional(D.boolean),clarifyTimeoutError:D.transitional(D.boolean)},!1),s!=null&&(a.isFunction(s)?n.paramsSerializer={serialize:s}:ae.assertOptions(s,{encode:D.function,serialize:D.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),ae.assertOptions(n,{baseUrl:D.spelling("baseURL"),withXsrfToken:D.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let o=i&&a.merge(i.common,i[n.method]);i&&a.forEach(["delete","get","head","post","put","patch","common"],c=>{delete i[c]}),n.headers=P.concat(o,i);const l=[];let f=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(n)===!1||(f=f&&m.synchronous,l.unshift(m.fulfilled,m.rejected))});const d=[];this.interceptors.response.forEach(function(m){d.push(m.fulfilled,m.rejected)});let u,h=0,x;if(!f){const c=[Ve.bind(this),void 0];for(c.unshift(...l),c.push(...d),x=c.length,u=Promise.resolve(n);h<x;)u=u.then(c[h++],c[h++]);return u}x=l.length;let S=n;for(;h<x;){const c=l[h++],m=l[h++];try{S=c(S)}catch(p){m.call(this,p);break}}try{u=Ve.call(this,S)}catch(c){return Promise.reject(c)}for(h=0,x=d.length;h<x;)u=u.then(d[h++],d[h++]);return u}getUri(t){t=z(this.defaults,t);const n=ft(t.baseURL,t.url,t.allowAbsoluteUrls);return at(n,t.params,t.paramsSerializer)}};a.forEach(["delete","get","head","options"],function(t){M.prototype[t]=function(n,r){return this.request(z(r||{},{method:t,url:n,data:(r||{}).data}))}});a.forEach(["post","put","patch"],function(t){function n(r){return function(i,o,l){return this.request(z(l||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:i,data:o}))}}M.prototype[t]=n(),M.prototype[t+"Form"]=n(!0)});let rr=class bt{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(i){n=i});const r=this;this.promise.then(s=>{if(!r._listeners)return;let i=r._listeners.length;for(;i-- >0;)r._listeners[i](s);r._listeners=null}),this.promise.then=s=>{let i;const o=new Promise(l=>{r.subscribe(l),i=l}).then(s);return o.cancel=function(){r.unsubscribe(i)},o},t(function(i,o,l){r.reason||(r.reason=new X(i,o,l),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new bt(function(s){t=s}),cancel:t}}};function sr(e){return function(n){return e.apply(null,n)}}function or(e){return a.isObject(e)&&e.isAxiosError===!0}const Ee={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,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Ee).forEach(([e,t])=>{Ee[t]=e});function gt(e){const t=new M(e),n=Xe(M.prototype.request,t);return a.extend(n,M.prototype,t,{allOwnKeys:!0}),a.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return gt(z(e,s))},n}const R=gt(te);R.Axios=M;R.CanceledError=X;R.CancelToken=rr;R.isCancel=ut;R.VERSION=yt;R.toFormData=fe;R.AxiosError=g;R.Cancel=R.CanceledError;R.all=function(t){return Promise.all(t)};R.spread=sr;R.isAxiosError=or;R.mergeConfig=z;R.AxiosHeaders=P;R.formToJSON=e=>ct(a.isHTMLForm(e)?new FormData(e):e);R.getAdapter=mt.getAdapter;R.HttpStatusCode=Ee;R.default=R;const{Axios:fr,AxiosError:pr,CanceledError:hr,isCancel:mr,CancelToken:yr,VERSION:br,all:gr,Cancel:xr,isAxiosError:Sr,spread:wr,toFormData:Er,AxiosHeaders:Rr,HttpStatusCode:Cr,formToJSON:Or,getAdapter:Tr,mergeConfig:Ar}=R,ir=async(e,t)=>{try{await R.get(`https://n8n.clone67.com/webhook/end-chat-session?chatbotNamespace=${t}&sessionId=${e}`)}catch{throw new Error}},ar=({chatBotData:e,theme:t,onlineStatus:n,isExpand:r,endSession:s})=>{const[i,o]=N.useState(null),[l,f]=N.useState(""),[d,u]=N.useState("Connecting to server..."),[h,x]=N.useState(""),[S,c]=N.useState(!1);N.useEffect(()=>{var b=localStorage.getItem("clone67ChatSessionId");b===null&&(b=Tt(),localStorage.setItem("clone67ChatSessionId",b));const{socket:k}=kt(b,e.pineconeNamespace);o(k),k.onopen=()=>{u("Server connected"),setTimeout(()=>{u("")},2e3),n("online")},k.onmessage=async _=>{try{const W=await _.data;x(W),c(!1)}catch(W){console.error("Error handling server message:",W)}},k.onerror=_=>{u("Server error occurred"),console.error("WebSocket error:",_),n("offline")},k.onclose=()=>{u("Server disconnected"),n("offline")}},[]),N.useEffect(()=>{(async()=>{if(!s)return;const k=localStorage.getItem("clone67ChatSessionId");if(i&&i.readyState===WebSocket.OPEN)try{h&&await ir(k,e.pineconeNamespace),i.send(JSON.stringify({type:"end_session"})),i.close(),localStorage.removeItem("clone67ChatSessionId")}catch(_){console.log("Error while saving messages",_)}})()},[s]);const m=async b=>{if(b.preventDefault(),i&&i.readyState===WebSocket.OPEN){const _={type:"chat",userInput:l};i.send(JSON.stringify(_))}c(!0);const k={created_at:Date.now(),sender_type:"user",message:l};x(JSON.stringify(k)),f("")},p=b=>{b.key==="Enter"&&!b.shiftKey&&(b.preventDefault(),m(b))},w={flex:1,padding:"12px 16px",background:`${S?`${t.primaryColor}33`:t.backgroundColor}`,color:t.fontColor,border:`1px solid ${t.primaryColor}`,borderRadius:"12px",fontSize:"14px",outline:"none",transition:"all 0.2s ease",boxShadow:"none",cursor:S?"not-allowed":"auto"},T={padding:"12px 20px",borderRadius:"12px",background:S?`${t.primaryColor}33`:`linear-gradient(135deg, ${t.primaryColor}, ${t.secondaryColor})`,color:t.fontColor,border:"none",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",fontWeight:"600",fontSize:"14px",transition:"all 0.2s ease",minWidth:"48px",cursor:S?"not-allowed":"pointer"},E={padding:"10px",borderColor:t.fontColor,background:t.backgroundColor,flexShrink:0},C={display:"flex",gap:"12px",alignItems:"center"},O={textAlign:"center",padding:"2px",backgroundColor:d==="Server connected"||d==="online"?"#09BA00":d==="Connecting to server..."?"#DED000":"#FF3408",color:"#ffffff",fontSize:"10px"},U={padding:"8px",animation:"fadeIn 0.3s ease-in-out, pulse 1.5s ease-in-out infinite",animationDelay:"0s, 0.3s",fontSize:"10px",color:t.fontColor};return y.jsxs(y.Fragment,{children:[d&&y.jsx("p",{style:O,children:d}),s?y.jsx(jt,{theme:t}):y.jsxs(y.Fragment,{children:[y.jsx(At,{messages:h,chatBotData:e,theme:t,isExpand:r}),S&&y.jsx("div",{style:U,children:`${e.name} is typing...`}),y.jsx("div",{style:E,children:y.jsxs("form",{onSubmit:m,style:C,children:[y.jsx("input",{type:"text",placeholder:"Type a message...",value:l,onChange:b=>f(b.target.value),disabled:S,onKeyDown:p,style:w,onFocus:b=>{b.target.style.boxShadow=`0 0 0 1px ${t.primaryColor}`,b.target.style.borderColor=t.primaryColor},onBlur:b=>{b.target.style.boxShadow="none",b.target.style.borderColor=t.primaryColor}}),y.jsx("button",{onClick:m,style:T,disabled:S,"aria-label":"Send message",children:y.jsx($.Send,{size:18})})]})})]})]})},lr=({theme:e,chatBotData:t,onClose:n})=>{const[r,s]=N.useState(!1),[i,o]=N.useState(!1),[l,f]=N.useState(!1),u={position:"fixed",bottom:"112px",[t.position==="left"?"left":"right"]:"32px",zIndex:50,width:r?"684px":"384px",height:r?"620px":"520px",background:`${e.backgroundColor}cc`,backdropFilter:"blur(16px)",WebkitBackdropFilter:"blur(16px)",borderRadius:"16px",border:"1px solid rgba(255, 255, 255, 0.3)",display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"system-ui, -apple-system, sans-serif",boxShadow:"0 10px 25px -3px rgba(0,0,0,0.1)"},h={padding:"16px 20px",background:`linear-gradient(135deg, ${e.primaryColor}, ${e.secondaryColor})`,color:e.fontColor,borderRadius:"16px 16px 0 0",display:"flex",alignItems:"center",justifyContent:"space-between",boxShadow:"0 4px 6px -1px rgba(0,0,0,0.1)"},x={position:"relative"},S={width:"44px",height:"44px",borderRadius:"50%",background:"rgba(255,255,255,0.2)",display:"flex",alignItems:"center",justifyContent:"center"},c={position:"absolute",bottom:0,right:0,width:"14px",height:"14px",backgroundColor:i?"#00BF49":"#F54927",borderRadius:"50%",border:"3px solid white"},m={fontSize:"18px",fontWeight:"600",margin:0,lineHeight:"1.2"},p={fontSize:"12px",opacity:.9,margin:0,lineHeight:"1.3"},w={padding:"8px",borderRadius:"50%",background:"transparent",border:"none",cursor:"pointer",transition:"background 0.2s"},T={padding:"10px",borderTop:"1px solid rgba(255,255,255,0.2)",background:e.backgroundColor,textAlign:"center"},E={fontSize:"11px",color:e.fontColor,letterSpacing:"0.5px"},C={fontWeight:"600"},O=(b,k)=>{b.currentTarget.style.background=k?"rgba(255,255,255,0.2)":"transparent"},U=b=>{o(b==="online")};return y.jsxs("div",{style:u,children:[y.jsxs("div",{style:h,children:[y.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[y.jsxs("div",{style:x,children:[y.jsx("div",{style:S,children:y.jsx($.MessageCircle,{size:22})}),y.jsx("span",{style:c})]}),y.jsxs("div",{children:[y.jsx("h3",{style:m,children:t.name}),y.jsx("p",{style:p,children:t.subTitle})]})]}),y.jsxs("div",{style:{display:"flex",alignItems:"left"},children:[y.jsx("button",{onClick:()=>s(b=>!b),"aria-label":"expand chat",style:w,onMouseEnter:b=>O(b,!0),onMouseLeave:b=>O(b,!1),children:r?y.jsx($.Minimize2,{size:20}):y.jsx($.Maximize2,{size:20})}),y.jsx("button",{onClick:()=>{f(!0),setTimeout(()=>{n()},2e3)},style:w,onMouseEnter:b=>O(b,!0),onMouseLeave:b=>O(b,!1),children:y.jsx($.X,{size:20})})]})]}),y.jsx(ar,{chatBotData:t,theme:e,onlineStatus:U,isExpand:r,endSession:l}),y.jsx("div",{style:T,children:y.jsxs("p",{style:E,children:["powered by ",y.jsx("span",{style:C,children:"clone67.com"})]})})]})},cr=({pineconeNamespace:e,primaryColor:t="#3b82f6",secondaryColor:n="#8b5cf6",backgroundColor:r="#ffffff",fontColor:s="#1f2937",placeholderColor:i="#9ca3af",position:o="right",name:l="AI Assistant",subTitle:f="AI powered assistant",welcomeText:d="Hi! How can I help you today?",aiInitialMessage:u=""})=>{const[h,x]=N.useState(!1),S=()=>x(O=>!O),c=()=>{x(!1)},m={primaryColor:t,secondaryColor:n,backgroundColor:r,fontColor:s,placeholderColor:i,inputBackgroundColor:r},p={name:l,subTitle:f,welcomeText:d,pineconeNamespace:e,position:o,aiInitialMessage:u};u===""&&(p.aiInitialMessage=`Hello! I'm ${p.name}, your AI assistant. How can I help you today?`);const w=o==="left",T="32px",E={position:"fixed",bottom:"104px",[w?"left":"right"]:T,zIndex:9999,pointerEvents:"auto"},C={position:"fixed",bottom:"32px",[w?"left":"right"]:T,zIndex:1e4,pointerEvents:"auto"};return y.jsxs(y.Fragment,{children:[h&&y.jsx("div",{style:E,children:y.jsx(lr,{onClose:c,theme:m,chatBotData:p})}),y.jsx("div",{style:C,children:y.jsx(St,{onMinimise:S,isOpen:h,theme:m,chatBotData:p})})]})};module.exports=cr;
|
package/dist/index.js
CHANGED
|
@@ -1932,9 +1932,9 @@ const {
|
|
|
1932
1932
|
formToJSON: Br,
|
|
1933
1933
|
getAdapter: jr,
|
|
1934
1934
|
mergeConfig: vr
|
|
1935
|
-
} = R, yr = async (e) => {
|
|
1935
|
+
} = R, yr = async (e, t) => {
|
|
1936
1936
|
try {
|
|
1937
|
-
await R.get(`https://n8n.clone67.com/webhook/end-chat-session?sessionId=${e}`);
|
|
1937
|
+
await R.get(`https://n8n.clone67.com/webhook/end-chat-session?chatbotNamespace=${t}&sessionId=${e}`);
|
|
1938
1938
|
} catch {
|
|
1939
1939
|
throw new Error();
|
|
1940
1940
|
}
|
|
@@ -1964,9 +1964,9 @@ const {
|
|
|
1964
1964
|
(async () => {
|
|
1965
1965
|
if (!o) return;
|
|
1966
1966
|
const F = localStorage.getItem("clone67ChatSessionId");
|
|
1967
|
-
if (
|
|
1967
|
+
if (i && i.readyState === WebSocket.OPEN)
|
|
1968
1968
|
try {
|
|
1969
|
-
h && await yr(F), i.send(JSON.stringify({ type: "end_session" })), i.close(), localStorage.removeItem("clone67ChatSessionId");
|
|
1969
|
+
h && await yr(F, e.pineconeNamespace), i.send(JSON.stringify({ type: "end_session" })), i.close(), localStorage.removeItem("clone67ChatSessionId");
|
|
1970
1970
|
} catch (U) {
|
|
1971
1971
|
console.log("Error while saving messages", U);
|
|
1972
1972
|
}
|