@chatwoot/agent-react-components 4.2.0-dev.0b56add844 → 4.2.0-dev.76e1643ccf

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.
Files changed (4) hide show
  1. package/index.cjs +1 -1
  2. package/index.js +14 -12
  3. package/package.json +1 -1
  4. package/README.md +0 -69
package/index.cjs CHANGED
@@ -189,7 +189,7 @@ Here are the main features of the integration:
189
189
  `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...r){const a=new this(e);return r.forEach(o=>a.set(o)),a}static accessor(e){const a=(this[zk]=this[zk]={accessors:{}}).accessors,o=this.prototype;function i(n){const s=l1(n);a[s]||(VZe(o,n),a[s]=!0)}return ne.isArray(e)?e.forEach(i):i(e),this}};xa.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);ne.reduceDescriptors(xa.prototype,({value:t},e)=>{let r=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(a){this[r]=a}}});ne.freezeMethods(xa);function V3(t,e){const r=this||Wc,a=e||r,o=xa.from(a.headers);let i=a.data;return ne.forEach(t,function(s){i=s.call(r,i,o.normalize(),e?e.status:void 0)}),o.normalize(),i}function CM(t){return!!(t&&t.__CANCEL__)}function F0(t,e,r){He.call(this,t??"canceled",He.ERR_CANCELED,e,r),this.name="CanceledError"}ne.inherits(F0,He,{__CANCEL__:!0});function AM(t,e,r){const a=r.config.validateStatus;!r.status||!a||a(r.status)?t(r):e(new He("Request failed with status code "+r.status,[He.ERR_BAD_REQUEST,He.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function BZe(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}function PZe(t,e){t=t||10;const r=new Array(t),a=new Array(t);let o=0,i=0,n;return e=e!==void 0?e:1e3,function(l){const c=Date.now(),u=a[i];n||(n=c),r[o]=l,a[o]=c;let d=i,g=0;for(;d!==o;)g+=r[d++],d=d%t;if(o=(o+1)%t,o===i&&(i=(i+1)%t),c-n<e)return;const h=u&&c-u;return h?Math.round(g*1e3/h):void 0}}function FZe(t,e){let r=0,a=1e3/e,o,i;const n=(c,u=Date.now())=>{r=u,o=null,i&&(clearTimeout(i),i=null),t.apply(null,c)};return[(...c)=>{const u=Date.now(),d=u-r;d>=a?n(c,u):(o=c,i||(i=setTimeout(()=>{i=null,n(o)},a-d)))},()=>o&&n(o)]}const bd=(t,e,r=3)=>{let a=0;const o=PZe(50,250);return FZe(i=>{const n=i.loaded,s=i.lengthComputable?i.total:void 0,l=n-a,c=o(l),u=n<=s;a=n;const d={loaded:n,total:s,progress:s?n/s:void 0,bytes:l,rate:c||void 0,estimated:c&&s&&u?(s-n)/c:void 0,event:i,lengthComputable:s!=null,[e?"download":"upload"]:!0};t(d)},r)},qk=(t,e)=>{const r=t!=null;return[a=>e[0]({lengthComputable:r,total:t,loaded:a}),e[1]]},Gk=t=>(...e)=>ne.asap(()=>t(...e)),UZe=Ur.hasStandardBrowserEnv?((t,e)=>r=>(r=new URL(r,Ur.origin),t.protocol===r.protocol&&t.host===r.host&&(e||t.port===r.port)))(new URL(Ur.origin),Ur.navigator&&/(msie|trident)/i.test(Ur.navigator.userAgent)):()=>!0,jZe=Ur.hasStandardBrowserEnv?{write(t,e,r,a,o,i){const n=[t+"="+encodeURIComponent(e)];ne.isNumber(r)&&n.push("expires="+new Date(r).toGMTString()),ne.isString(a)&&n.push("path="+a),ne.isString(o)&&n.push("domain="+o),i===!0&&n.push("secure"),document.cookie=n.join("; ")},read(t){const e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove(t){this.write(t,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function zZe(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function qZe(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}function xM(t,e,r){let a=!zZe(e);return t&&a||r==!1?qZe(t,e):e}const Hk=t=>t instanceof xa?{...t}:t;function qs(t,e){e=e||{};const r={};function a(c,u,d,g){return ne.isPlainObject(c)&&ne.isPlainObject(u)?ne.merge.call({caseless:g},c,u):ne.isPlainObject(u)?ne.merge({},u):ne.isArray(u)?u.slice():u}function o(c,u,d,g){if(ne.isUndefined(u)){if(!ne.isUndefined(c))return a(void 0,c,d,g)}else return a(c,u,d,g)}function i(c,u){if(!ne.isUndefined(u))return a(void 0,u)}function n(c,u){if(ne.isUndefined(u)){if(!ne.isUndefined(c))return a(void 0,c)}else return a(void 0,u)}function s(c,u,d){if(d in e)return a(c,u);if(d in t)return a(void 0,c)}const l={url:i,method:i,data:i,baseURL:n,transformRequest:n,transformResponse:n,paramsSerializer:n,timeout:n,timeoutMessage:n,withCredentials:n,withXSRFToken:n,adapter:n,responseType:n,xsrfCookieName:n,xsrfHeaderName:n,onUploadProgress:n,onDownloadProgress:n,decompress:n,maxContentLength:n,maxBodyLength:n,beforeRedirect:n,transport:n,httpAgent:n,httpsAgent:n,cancelToken:n,socketPath:n,responseEncoding:n,validateStatus:s,headers:(c,u,d)=>o(Hk(c),Hk(u),d,!0)};return ne.forEach(Object.keys(Object.assign({},t,e)),function(u){const d=l[u]||o,g=d(t[u],e[u],u);ne.isUndefined(g)&&d!==s||(r[u]=g)}),r}const yM=t=>{const e=qs({},t);let{data:r,withXSRFToken:a,xsrfHeaderName:o,xsrfCookieName:i,headers:n,auth:s}=e;e.headers=n=xa.from(n),e.url=bM(xM(e.baseURL,e.url),t.params,t.paramsSerializer),s&&n.set("Authorization","Basic "+btoa((s.username||"")+":"+(s.password?unescape(encodeURIComponent(s.password)):"")));let l;if(ne.isFormData(r)){if(Ur.hasStandardBrowserEnv||Ur.hasStandardBrowserWebWorkerEnv)n.setContentType(void 0);else if((l=n.getContentType())!==!1){const[c,...u]=l?l.split(";").map(d=>d.trim()).filter(Boolean):[];n.setContentType([c||"multipart/form-data",...u].join("; "))}}if(Ur.hasStandardBrowserEnv&&(a&&ne.isFunction(a)&&(a=a(e)),a||a!==!1&&UZe(e.url))){const c=o&&i&&jZe.read(i);c&&n.set(o,c)}return e},GZe=typeof XMLHttpRequest<"u",HZe=GZe&&function(t){return new Promise(function(r,a){const o=yM(t);let i=o.data;const n=xa.from(o.headers).normalize();let{responseType:s,onUploadProgress:l,onDownloadProgress:c}=o,u,d,g,h,m;function f(){h&&h(),m&&m(),o.cancelToken&&o.cancelToken.unsubscribe(u),o.signal&&o.signal.removeEventListener("abort",u)}let b=new XMLHttpRequest;b.open(o.method.toUpperCase(),o.url,!0),b.timeout=o.timeout;function k(){if(!b)return;const w=xa.from("getAllResponseHeaders"in b&&b.getAllResponseHeaders()),A={data:!s||s==="text"||s==="json"?b.responseText:b.response,status:b.status,statusText:b.statusText,headers:w,config:t,request:b};AM(function(M){r(M),f()},function(M){a(M),f()},A),b=null}"onloadend"in b?b.onloadend=k:b.onreadystatechange=function(){!b||b.readyState!==4||b.status===0&&!(b.responseURL&&b.responseURL.indexOf("file:")===0)||setTimeout(k)},b.onabort=function(){b&&(a(new He("Request aborted",He.ECONNABORTED,t,b)),b=null)},b.onerror=function(){a(new He("Network Error",He.ERR_NETWORK,t,b)),b=null},b.ontimeout=function(){let v=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const A=o.transitional||EM;o.timeoutErrorMessage&&(v=o.timeoutErrorMessage),a(new He(v,A.clarifyTimeoutError?He.ETIMEDOUT:He.ECONNABORTED,t,b)),b=null},i===void 0&&n.setContentType(null),"setRequestHeader"in b&&ne.forEach(n.toJSON(),function(v,A){b.setRequestHeader(A,v)}),ne.isUndefined(o.withCredentials)||(b.withCredentials=!!o.withCredentials),s&&s!=="json"&&(b.responseType=o.responseType),c&&([g,m]=bd(c,!0),b.addEventListener("progress",g)),l&&b.upload&&([d,h]=bd(l),b.upload.addEventListener("progress",d),b.upload.addEventListener("loadend",h)),(o.cancelToken||o.signal)&&(u=w=>{b&&(a(!w||w.type?new F0(null,t,b):w),b.abort(),b=null)},o.cancelToken&&o.cancelToken.subscribe(u),o.signal&&(o.signal.aborted?u():o.signal.addEventListener("abort",u)));const C=BZe(o.url);if(C&&Ur.protocols.indexOf(C)===-1){a(new He("Unsupported protocol "+C+":",He.ERR_BAD_REQUEST,t));return}b.send(i||null)})},KZe=(t,e)=>{const{length:r}=t=t?t.filter(Boolean):[];if(e||r){let a=new AbortController,o;const i=function(c){if(!o){o=!0,s();const u=c instanceof Error?c:this.reason;a.abort(u instanceof He?u:new F0(u instanceof Error?u.message:u))}};let n=e&&setTimeout(()=>{n=null,i(new He(`timeout ${e} of ms exceeded`,He.ETIMEDOUT))},e);const s=()=>{t&&(n&&clearTimeout(n),n=null,t.forEach(c=>{c.unsubscribe?c.unsubscribe(i):c.removeEventListener("abort",i)}),t=null)};t.forEach(c=>c.addEventListener("abort",i));const{signal:l}=a;return l.unsubscribe=()=>ne.asap(s),l}},WZe=function*(t,e){let r=t.byteLength;if(r<e){yield t;return}let a=0,o;for(;a<r;)o=a+e,yield t.slice(a,o),a=o},ZZe=async function*(t,e){for await(const r of JZe(t))yield*WZe(r,e)},JZe=async function*(t){if(t[Symbol.asyncIterator]){yield*t;return}const e=t.getReader();try{for(;;){const{done:r,value:a}=await e.read();if(r)break;yield a}}finally{await e.cancel()}},Kk=(t,e,r,a)=>{const o=ZZe(t,e);let i=0,n,s=l=>{n||(n=!0,a&&a(l))};return new ReadableStream({async pull(l){try{const{done:c,value:u}=await o.next();if(c){s(),l.close();return}let d=u.byteLength;if(r){let g=i+=d;r(g)}l.enqueue(new Uint8Array(u))}catch(c){throw s(c),c}},cancel(l){return s(l),o.return()}},{highWaterMark:2})},Zg=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",TM=Zg&&typeof ReadableStream=="function",QZe=Zg&&(typeof TextEncoder=="function"?(t=>e=>t.encode(e))(new TextEncoder):async t=>new Uint8Array(await new Response(t).arrayBuffer())),SM=(t,...e)=>{try{return!!t(...e)}catch{return!1}},XZe=TM&&SM(()=>{let t=!1;const e=new Request(Ur.origin,{body:new ReadableStream,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type");return t&&!e}),Wk=64*1024,qp=TM&&SM(()=>ne.isReadableStream(new Response("").body)),Ed={stream:qp&&(t=>t.body)};Zg&&(t=>{["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!Ed[e]&&(Ed[e]=ne.isFunction(t[e])?r=>r[e]():(r,a)=>{throw new He(`Response type '${e}' is not supported`,He.ERR_NOT_SUPPORT,a)})})})(new Response);const YZe=async t=>{if(t==null)return 0;if(ne.isBlob(t))return t.size;if(ne.isSpecCompliantForm(t))return(await new Request(Ur.origin,{method:"POST",body:t}).arrayBuffer()).byteLength;if(ne.isArrayBufferView(t)||ne.isArrayBuffer(t))return t.byteLength;if(ne.isURLSearchParams(t)&&(t=t+""),ne.isString(t))return(await QZe(t)).byteLength},_Ze=async(t,e)=>{const r=ne.toFiniteNumber(t.getContentLength());return r??YZe(e)},$Ze=Zg&&(async t=>{let{url:e,method:r,data:a,signal:o,cancelToken:i,timeout:n,onDownloadProgress:s,onUploadProgress:l,responseType:c,headers:u,withCredentials:d="same-origin",fetchOptions:g}=yM(t);c=c?(c+"").toLowerCase():"text";let h=KZe([o,i&&i.toAbortSignal()],n),m;const f=h&&h.unsubscribe&&(()=>{h.unsubscribe()});let b;try{if(l&&XZe&&r!=="get"&&r!=="head"&&(b=await _Ze(u,a))!==0){let A=new Request(e,{method:"POST",body:a,duplex:"half"}),E;if(ne.isFormData(a)&&(E=A.headers.get("content-type"))&&u.setContentType(E),A.body){const[M,P]=qk(b,bd(Gk(l)));a=Kk(A.body,Wk,M,P)}}ne.isString(d)||(d=d?"include":"omit");const k="credentials"in Request.prototype;m=new Request(e,{...g,signal:h,method:r.toUpperCase(),headers:u.normalize().toJSON(),body:a,duplex:"half",credentials:k?d:void 0});let C=await fetch(m);const w=qp&&(c==="stream"||c==="response");if(qp&&(s||w&&f)){const A={};["status","statusText","headers"].forEach(S=>{A[S]=C[S]});const E=ne.toFiniteNumber(C.headers.get("content-length")),[M,P]=s&&qk(E,bd(Gk(s),!0))||[];C=new Response(Kk(C.body,Wk,M,()=>{P&&P(),f&&f()}),A)}c=c||"text";let v=await Ed[ne.findKey(Ed,c)||"text"](C,t);return!w&&f&&f(),await new Promise((A,E)=>{AM(A,E,{data:v,headers:xa.from(C.headers),status:C.status,statusText:C.statusText,config:t,request:m})})}catch(k){throw f&&f(),k&&k.name==="TypeError"&&/fetch/i.test(k.message)?Object.assign(new He("Network Error",He.ERR_NETWORK,t,m),{cause:k.cause||k}):He.from(k,k&&k.code,t,m)}}),Gp={http:mZe,xhr:HZe,fetch:$Ze};ne.forEach(Gp,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch{}Object.defineProperty(t,"adapterName",{value:e})}});const Zk=t=>`- ${t}`,eJe=t=>ne.isFunction(t)||t===null||t===!1,IM={getAdapter:t=>{t=ne.isArray(t)?t:[t];const{length:e}=t;let r,a;const o={};for(let i=0;i<e;i++){r=t[i];let n;if(a=r,!eJe(r)&&(a=Gp[(n=String(r)).toLowerCase()],a===void 0))throw new He(`Unknown adapter '${n}'`);if(a)break;o[n||"#"+i]=a}if(!a){const i=Object.entries(o).map(([s,l])=>`adapter ${s} `+(l===!1?"is not supported by the environment":"is not available in the build"));let n=e?i.length>1?`since :
190
190
  `+i.map(Zk).join(`
191
191
  `):" "+Zk(i[0]):"as no adapter specified";throw new He("There is no suitable adapter to dispatch the request "+n,"ERR_NOT_SUPPORT")}return a},adapters:Gp};function B3(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new F0(null,t)}function Jk(t){return B3(t),t.headers=xa.from(t.headers),t.data=V3.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),IM.getAdapter(t.adapter||Wc.adapter)(t).then(function(a){return B3(t),a.data=V3.call(t,t.transformResponse,a),a.headers=xa.from(a.headers),a},function(a){return CM(a)||(B3(t),a&&a.response&&(a.response.data=V3.call(t,t.transformResponse,a.response),a.response.headers=xa.from(a.response.headers))),Promise.reject(a)})}const MM="1.8.2",Jg={};["object","boolean","number","function","string","symbol"].forEach((t,e)=>{Jg[t]=function(a){return typeof a===t||"a"+(e<1?"n ":" ")+t}});const Qk={};Jg.transitional=function(e,r,a){function o(i,n){return"[Axios v"+MM+"] Transitional option '"+i+"'"+n+(a?". "+a:"")}return(i,n,s)=>{if(e===!1)throw new He(o(n," has been removed"+(r?" in "+r:"")),He.ERR_DEPRECATED);return r&&!Qk[n]&&(Qk[n]=!0,console.warn(o(n," has been deprecated since v"+r+" and will be removed in the near future"))),e?e(i,n,s):!0}};Jg.spelling=function(e){return(r,a)=>(console.warn(`${a} is likely a misspelling of ${e}`),!0)};function tJe(t,e,r){if(typeof t!="object")throw new He("options must be an object",He.ERR_BAD_OPTION_VALUE);const a=Object.keys(t);let o=a.length;for(;o-- >0;){const i=a[o],n=e[i];if(n){const s=t[i],l=s===void 0||n(s,i,t);if(l!==!0)throw new He("option "+i+" must be "+l,He.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new He("Unknown option "+i,He.ERR_BAD_OPTION)}}const hu={assertOptions:tJe,validators:Jg},Po=hu.validators;let Ls=class{constructor(e){this.defaults=e,this.interceptors={request:new jk,response:new jk}}async request(e,r){try{return await this._request(e,r)}catch(a){if(a instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const i=o.stack?o.stack.replace(/^.+\n/,""):"";try{a.stack?i&&!String(a.stack).endsWith(i.replace(/^.+\n.+\n/,""))&&(a.stack+=`
192
- `+i):a.stack=i}catch{}}throw a}}_request(e,r){typeof e=="string"?(r=r||{},r.url=e):r=e||{},r=qs(this.defaults,r);const{transitional:a,paramsSerializer:o,headers:i}=r;a!==void 0&&hu.assertOptions(a,{silentJSONParsing:Po.transitional(Po.boolean),forcedJSONParsing:Po.transitional(Po.boolean),clarifyTimeoutError:Po.transitional(Po.boolean)},!1),o!=null&&(ne.isFunction(o)?r.paramsSerializer={serialize:o}:hu.assertOptions(o,{encode:Po.function,serialize:Po.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),hu.assertOptions(r,{baseUrl:Po.spelling("baseURL"),withXsrfToken:Po.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let n=i&&ne.merge(i.common,i[r.method]);i&&ne.forEach(["delete","get","head","post","put","patch","common"],m=>{delete i[m]}),r.headers=xa.concat(n,i);const s=[];let l=!0;this.interceptors.request.forEach(function(f){typeof f.runWhen=="function"&&f.runWhen(r)===!1||(l=l&&f.synchronous,s.unshift(f.fulfilled,f.rejected))});const c=[];this.interceptors.response.forEach(function(f){c.push(f.fulfilled,f.rejected)});let u,d=0,g;if(!l){const m=[Jk.bind(this),void 0];for(m.unshift.apply(m,s),m.push.apply(m,c),g=m.length,u=Promise.resolve(r);d<g;)u=u.then(m[d++],m[d++]);return u}g=s.length;let h=r;for(d=0;d<g;){const m=s[d++],f=s[d++];try{h=m(h)}catch(b){f.call(this,b);break}}try{u=Jk.call(this,h)}catch(m){return Promise.reject(m)}for(d=0,g=c.length;d<g;)u=u.then(c[d++],c[d++]);return u}getUri(e){e=qs(this.defaults,e);const r=xM(e.baseURL,e.url,e.allowAbsoluteUrls);return bM(r,e.params,e.paramsSerializer)}};ne.forEach(["delete","get","head","options"],function(e){Ls.prototype[e]=function(r,a){return this.request(qs(a||{},{method:e,url:r,data:(a||{}).data}))}});ne.forEach(["post","put","patch"],function(e){function r(a){return function(i,n,s){return this.request(qs(s||{},{method:e,headers:a?{"Content-Type":"multipart/form-data"}:{},url:i,data:n}))}}Ls.prototype[e]=r(),Ls.prototype[e+"Form"]=r(!0)});let rJe=class OM{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(i){r=i});const a=this;this.promise.then(o=>{if(!a._listeners)return;let i=a._listeners.length;for(;i-- >0;)a._listeners[i](o);a._listeners=null}),this.promise.then=o=>{let i;const n=new Promise(s=>{a.subscribe(s),i=s}).then(o);return n.cancel=function(){a.unsubscribe(i)},n},e(function(i,n,s){a.reason||(a.reason=new F0(i,n,s),r(a.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const r=this._listeners.indexOf(e);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const e=new AbortController,r=a=>{e.abort(a)};return this.subscribe(r),e.signal.unsubscribe=()=>this.unsubscribe(r),e.signal}static source(){let e;return{token:new OM(function(o){e=o}),cancel:e}}};function aJe(t){return function(r){return t.apply(null,r)}}function oJe(t){return ne.isObject(t)&&t.isAxiosError===!0}const Hp={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(Hp).forEach(([t,e])=>{Hp[e]=t});function LM(t){const e=new Ls(t),r=lM(Ls.prototype.request,e);return ne.extend(r,Ls.prototype,e,{allOwnKeys:!0}),ne.extend(r,e,null,{allOwnKeys:!0}),r.create=function(o){return LM(qs(t,o))},r}const _t=LM(Wc);_t.Axios=Ls;_t.CanceledError=F0;_t.CancelToken=rJe;_t.isCancel=CM;_t.VERSION=MM;_t.toFormData=Wg;_t.AxiosError=He;_t.Cancel=_t.CanceledError;_t.all=function(e){return Promise.all(e)};_t.spread=aJe;_t.isAxiosError=oJe;_t.mergeConfig=qs;_t.AxiosHeaders=xa;_t.formToJSON=t=>kM(ne.isHTMLForm(t)?new FormData(t):t);_t.getAdapter=IM.getAdapter;_t.HttpStatusCode=Hp;_t.default=_t;const{Axios:ket,AxiosError:Cet,CanceledError:Aet,isCancel:xet,CancelToken:yet,VERSION:Tet,all:Iet,Cancel:Met,isAxiosError:Oet,spread:Let,toFormData:Ret,AxiosHeaders:Net,HttpStatusCode:Det,formToJSON:Vet,getAdapter:Bet,mergeConfig:Pet}=_t,iJe=t=>Promise.reject(t),nJe=t=>{const e=window.__WOOT_API_HOST__,r=window.__WOOT_ACCESS_TOKEN__,a=t.create({baseURL:`${e}/`});return Object.assign(a.defaults.headers.common,{api_access_token:r}),a.interceptors.response.use(o=>o,o=>iJe(o)),a};var Kp={exports:{}};(function(t,e){(function(r,a){a(e)})(ct,function(r){var a={logger:self.console,WebSocket:self.WebSocket},o={log:function(){if(this.enabled){for(var N,q=arguments.length,j=Array(q),J=0;J<q;J++)j[J]=arguments[J];j.push(Date.now()),(N=a.logger).log.apply(N,["[ActionCable]"].concat(j))}}},i=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(S){return typeof S}:function(S){return S&&typeof Symbol=="function"&&S.constructor===Symbol&&S!==Symbol.prototype?"symbol":typeof S},n=function(S,N){if(!(S instanceof N))throw new TypeError("Cannot call a class as a function")},s=function(){function S(N,q){for(var j=0;j<q.length;j++){var J=q[j];J.enumerable=J.enumerable||!1,J.configurable=!0,"value"in J&&(J.writable=!0),Object.defineProperty(N,J.key,J)}}return function(N,q,j){return q&&S(N.prototype,q),j&&S(N,j),N}}(),l=function(){return new Date().getTime()},c=function(N){return(l()-N)/1e3},u=function(N,q,j){return Math.max(q,Math.min(j,N))},d=function(){function S(N){n(this,S),this.visibilityDidChange=this.visibilityDidChange.bind(this),this.connection=N,this.reconnectAttempts=0}return S.prototype.start=function(){this.isRunning()||(this.startedAt=l(),delete this.stoppedAt,this.startPolling(),addEventListener("visibilitychange",this.visibilityDidChange),o.log("ConnectionMonitor started. pollInterval = "+this.getPollInterval()+" ms"))},S.prototype.stop=function(){this.isRunning()&&(this.stoppedAt=l(),this.stopPolling(),removeEventListener("visibilitychange",this.visibilityDidChange),o.log("ConnectionMonitor stopped"))},S.prototype.isRunning=function(){return this.startedAt&&!this.stoppedAt},S.prototype.recordPing=function(){this.pingedAt=l()},S.prototype.recordConnect=function(){this.reconnectAttempts=0,this.recordPing(),delete this.disconnectedAt,o.log("ConnectionMonitor recorded connect")},S.prototype.recordDisconnect=function(){this.disconnectedAt=l(),o.log("ConnectionMonitor recorded disconnect")},S.prototype.startPolling=function(){this.stopPolling(),this.poll()},S.prototype.stopPolling=function(){clearTimeout(this.pollTimeout)},S.prototype.poll=function(){var q=this;this.pollTimeout=setTimeout(function(){q.reconnectIfStale(),q.poll()},this.getPollInterval())},S.prototype.getPollInterval=function(){var q=this.constructor.pollInterval,j=q.min,J=q.max,_=q.multiplier,B=_*Math.log(this.reconnectAttempts+1);return Math.round(u(B,j,J)*1e3)},S.prototype.reconnectIfStale=function(){this.connectionIsStale()&&(o.log("ConnectionMonitor detected stale connection. reconnectAttempts = "+this.reconnectAttempts+", pollInterval = "+this.getPollInterval()+" ms, time disconnected = "+c(this.disconnectedAt)+" s, stale threshold = "+this.constructor.staleThreshold+" s"),this.reconnectAttempts++,this.disconnectedRecently()?o.log("ConnectionMonitor skipping reopening recent disconnect"):(o.log("ConnectionMonitor reopening"),this.connection.reopen()))},S.prototype.connectionIsStale=function(){return c(this.pingedAt?this.pingedAt:this.startedAt)>this.constructor.staleThreshold},S.prototype.disconnectedRecently=function(){return this.disconnectedAt&&c(this.disconnectedAt)<this.constructor.staleThreshold},S.prototype.visibilityDidChange=function(){var q=this;document.visibilityState==="visible"&&setTimeout(function(){(q.connectionIsStale()||!q.connection.isOpen())&&(o.log("ConnectionMonitor reopening stale connection on visibilitychange. visibilityState = "+document.visibilityState),q.connection.reopen())},200)},S}();d.pollInterval={min:3,max:30,multiplier:5},d.staleThreshold=6;var g={message_types:{welcome:"welcome",disconnect:"disconnect",ping:"ping",confirmation:"confirm_subscription",rejection:"reject_subscription"},disconnect_reasons:{unauthorized:"unauthorized",invalid_request:"invalid_request",server_restart:"server_restart"},default_mount_path:"/cable",protocols:["actioncable-v1-json","actioncable-unsupported"]},h=g.message_types,m=g.protocols,f=m.slice(0,m.length-1),b=[].indexOf,k=function(){function S(N){n(this,S),this.open=this.open.bind(this),this.consumer=N,this.subscriptions=this.consumer.subscriptions,this.monitor=new d(this),this.disconnected=!0}return S.prototype.send=function(q){return this.isOpen()?(this.webSocket.send(JSON.stringify(q)),!0):!1},S.prototype.open=function(){return this.isActive()?(o.log("Attempted to open WebSocket, but existing socket is "+this.getState()),!1):(o.log("Opening WebSocket, current state is "+this.getState()+", subprotocols: "+m),this.webSocket&&this.uninstallEventHandlers(),this.webSocket=new a.WebSocket(this.consumer.url,m),this.installEventHandlers(),this.monitor.start(),!0)},S.prototype.close=function(){var q=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{allowReconnect:!0},j=q.allowReconnect;if(j||this.monitor.stop(),this.isActive())return this.webSocket.close()},S.prototype.reopen=function(){if(o.log("Reopening WebSocket, current state is "+this.getState()),this.isActive())try{return this.close()}catch(q){o.log("Failed to reopen WebSocket",q)}finally{o.log("Reopening WebSocket in "+this.constructor.reopenDelay+"ms"),setTimeout(this.open,this.constructor.reopenDelay)}else return this.open()},S.prototype.getProtocol=function(){if(this.webSocket)return this.webSocket.protocol},S.prototype.isOpen=function(){return this.isState("open")},S.prototype.isActive=function(){return this.isState("open","connecting")},S.prototype.isProtocolSupported=function(){return b.call(f,this.getProtocol())>=0},S.prototype.isState=function(){for(var q=arguments.length,j=Array(q),J=0;J<q;J++)j[J]=arguments[J];return b.call(j,this.getState())>=0},S.prototype.getState=function(){if(this.webSocket){for(var q in a.WebSocket)if(a.WebSocket[q]===this.webSocket.readyState)return q.toLowerCase()}return null},S.prototype.installEventHandlers=function(){for(var q in this.events){var j=this.events[q].bind(this);this.webSocket["on"+q]=j}},S.prototype.uninstallEventHandlers=function(){for(var q in this.events)this.webSocket["on"+q]=function(){}},S}();k.reopenDelay=500,k.prototype.events={message:function(N){if(this.isProtocolSupported()){var q=JSON.parse(N.data),j=q.identifier,J=q.message,_=q.reason,B=q.reconnect,T=q.type;switch(T){case h.welcome:return this.monitor.recordConnect(),this.subscriptions.reload();case h.disconnect:return o.log("Disconnecting. Reason: "+_),this.close({allowReconnect:B});case h.ping:return this.monitor.recordPing();case h.confirmation:return this.subscriptions.notify(j,"connected");case h.rejection:return this.subscriptions.reject(j);default:return this.subscriptions.notify(j,"received",J)}}},open:function(){if(o.log("WebSocket onopen event, using '"+this.getProtocol()+"' subprotocol"),this.disconnected=!1,!this.isProtocolSupported())return o.log("Protocol is unsupported. Stopping monitor and disconnecting."),this.close({allowReconnect:!1})},close:function(N){if(o.log("WebSocket onclose event"),!this.disconnected)return this.disconnected=!0,this.monitor.recordDisconnect(),this.subscriptions.notifyAll("disconnected",{willAttemptReconnect:this.monitor.isRunning()})},error:function(){o.log("WebSocket onerror event")}};var C=function(N,q){if(q!=null)for(var j in q){var J=q[j];N[j]=J}return N},w=function(){function S(N){var q=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},j=arguments[2];n(this,S),this.consumer=N,this.identifier=JSON.stringify(q),C(this,j)}return S.prototype.perform=function(q){var j=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return j.action=q,this.send(j)},S.prototype.send=function(q){return this.consumer.send({command:"message",identifier:this.identifier,data:JSON.stringify(q)})},S.prototype.unsubscribe=function(){return this.consumer.subscriptions.remove(this)},S}(),v=function(){function S(N){n(this,S),this.consumer=N,this.subscriptions=[]}return S.prototype.create=function(q,j){var J=q,_=(typeof J>"u"?"undefined":i(J))==="object"?J:{channel:J},B=new w(this.consumer,_,j);return this.add(B)},S.prototype.add=function(q){return this.subscriptions.push(q),this.consumer.ensureActiveConnection(),this.notify(q,"initialized"),this.sendCommand(q,"subscribe"),q},S.prototype.remove=function(q){return this.forget(q),this.findAll(q.identifier).length||this.sendCommand(q,"unsubscribe"),q},S.prototype.reject=function(q){var j=this;return this.findAll(q).map(function(J){return j.forget(J),j.notify(J,"rejected"),J})},S.prototype.forget=function(q){return this.subscriptions=this.subscriptions.filter(function(j){return j!==q}),q},S.prototype.findAll=function(q){return this.subscriptions.filter(function(j){return j.identifier===q})},S.prototype.reload=function(){var q=this;return this.subscriptions.map(function(j){return q.sendCommand(j,"subscribe")})},S.prototype.notifyAll=function(q){for(var j=this,J=arguments.length,_=Array(J>1?J-1:0),B=1;B<J;B++)_[B-1]=arguments[B];return this.subscriptions.map(function(T){return j.notify.apply(j,[T,q].concat(_))})},S.prototype.notify=function(q,j){for(var J=arguments.length,_=Array(J>2?J-2:0),B=2;B<J;B++)_[B-2]=arguments[B];var T=void 0;return typeof q=="string"?T=this.findAll(q):T=[q],T.map(function(L){return typeof L[j]=="function"?L[j].apply(L,_):void 0})},S.prototype.sendCommand=function(q,j){var J=q.identifier;return this.consumer.send({command:j,identifier:J})},S}(),A=function(){function S(N){n(this,S),this._url=N,this.subscriptions=new v(this),this.connection=new k(this)}return S.prototype.send=function(q){return this.connection.send(q)},S.prototype.connect=function(){return this.connection.open()},S.prototype.disconnect=function(){return this.connection.close({allowReconnect:!1})},S.prototype.ensureActiveConnection=function(){if(!this.connection.isActive())return this.connection.open()},s(S,[{key:"url",get:function(){return E(this._url)}}]),S}();function E(S){if(typeof S=="function"&&(S=S()),S&&!/^wss?:/i.test(S)){var N=document.createElement("a");return N.href=S,N.href=N.href,N.protocol=N.protocol.replace("http","ws"),N.href}else return S}function M(){var S=arguments.length>0&&arguments[0]!==void 0?arguments[0]:P("url")||g.default_mount_path;return new A(S)}function P(S){var N=document.head.querySelector("meta[name='action-cable-"+S+"']");if(N)return N.getAttribute("content")}r.Connection=k,r.ConnectionMonitor=d,r.Consumer=A,r.INTERNAL=g,r.Subscription=w,r.Subscriptions=v,r.adapters=a,r.createWebSocketURL=E,r.logger=o,r.createConsumer=M,r.getConfig=P,Object.defineProperty(r,"__esModule",{value:!0})})})(Kp,Kp.exports);var sJe=Kp.exports;const lJe=2e4,cJe=1e3,Ml=class Ml{constructor(e,r,a=""){Ve(this,"clearReconnectTimer",()=>{this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null)});Ve(this,"initReconnectTimer",()=>{this.clearReconnectTimer(),this.reconnectTimer=setTimeout(()=>{this.checkConnection()},cJe)});Ve(this,"onReconnect",()=>{});Ve(this,"onDisconnected",()=>{});Ve(this,"onReceived",({event:e,data:r}={})=>{this.isAValidEvent(r)&&this.events[e]&&typeof this.events[e]=="function"&&this.events[e](r)});const o=a?`${a}/cable`:void 0;this.consumer=sJe.createConsumer(o),this.subscription=this.consumer.subscriptions.create({channel:"RoomChannel",pubsub_token:r,account_id:e.$store.getters.getCurrentAccountId,user_id:e.$store.getters.getCurrentUserID},{updatePresence(){this.perform("update_presence")},received:this.onReceived,disconnected:()=>{Ml.isDisconnected=!0,this.onDisconnected(),this.initReconnectTimer()}}),this.app=e,this.events={},this.reconnectTimer=null,this.isAValidEvent=()=>!0,this.triggerPresenceInterval=()=>{setTimeout(()=>{this.subscription.updatePresence(),this.triggerPresenceInterval()},lJe)},this.triggerPresenceInterval()}checkConnection(){const e=this.consumer.connection.isOpen();Ml.isDisconnected&&e?(this.clearReconnectTimer(),this.onReconnect(),Ml.isDisconnected=!1):this.initReconnectTimer()}disconnect(){this.consumer.disconnect()}};Ve(Ml,"isDisconnected",!1);let Wp=Ml;const Xk=()=>{document.querySelectorAll(".favicon").forEach(e=>{const r=`/favicon-badge-${e.sizes[[0]]}.png`;e.href=r})},uJe=()=>{const t=document.querySelectorAll(".favicon");document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"&&t.forEach(e=>{const r=`/favicon-${e.sizes[[0]]}.png`;e.href=r})})},P3={ASSIGNED:"assigned",NOTME:"notme",UNASSIGNED:"unassigned"},dJe=["agent","administrator"],gJe=["conversation_manage","conversation_unassigned_manage","conversation_participating_manage"];class hJe{constructor(e){Ve(this,"hasUnreadConversation",()=>this.store.getters.getMineChats({assigneeType:"me",status:"open"}).some(r=>r.unread_count>0));Ve(this,"isMessageFromPendingConversation",(e={})=>{const{conversation_id:r}=e||{};if(!r)return!1;const a=this.store.getters.getConversationById(r);return(a==null?void 0:a.status)===oc.STATUS_TYPE.PENDING});Ve(this,"isMessageFromCurrentConversation",e=>{var r;return((r=this.store.getters.getSelectedChat)==null?void 0:r.id)===e.conversation_id});Ve(this,"hasConversationPermission",e=>{const r=this.store.getters.getCurrentAccountId,a=Np(e,r);return[...dJe,...gJe].some(i=>a.includes(i))});this.store=e}}const RM=t=>{var e;return(e=t==null?void 0:t.conversation)==null?void 0:e.assignee_id},mJe=t=>!RM(t),pJe=(t,e)=>RM(t)===e,fJe=(t,e)=>{var r;return((r=t==null?void 0:t.sender)==null?void 0:r.id)===e};class wJe{constructor(){Ve(this,"initializeEvent",()=>{window.addEventListener("blur",()=>{this.isVisible=!1}),window.addEventListener("focus",()=>{this.isVisible=!0})});this.isVisible=!0,this.initializeEvent()}isWindowVisible(){return!document.hidden&&this.isVisible}}const Yk=new wJe,vJe=3e4,bJe=1e4,EJe="/audio/dashboard/",_k="ding",$k=["none"];class kJe{constructor(e){Ve(this,"intializeAudio",()=>{const e=`${EJe}${this.audioConfig.tone}.mp3`;return this.audioConfig.audio=new Audio(e),this.audioConfig.audio.load()});Ve(this,"playAudioAlert",async()=>{try{await this.audioConfig.audio.play()}catch(e){e.name==="NotAllowedError"&&!this.hasSentSoundPermissionsRequest&&(this.hasSentSoundPermissionsRequest=!0,It("PROFILE_SETTINGS.FORM.AUDIO_NOTIFICATIONS_SECTION.SOUND_PERMISSION_ERROR",{usei18n:!0,duration:bJe}))}});Ve(this,"set",({currentUser:e,alwaysPlayAudioAlert:r,alertIfUnreadConversationExist:a,audioAlertType:o=$k,audioAlertTone:i=_k})=>{this.notificationConfig={...this.notificationConfig,audioAlertType:o.split("+").filter(Boolean),playAlertOnlyWhenHidden:!r,alertIfUnreadConversationExist:a},this.currentUser=e;const n=this.audioConfig.tone;this.audioConfig={...this.audioConfig,tone:i},n!==i&&this.intializeAudio(),uJe(),this.clearRecurringTimer(),this.playAudioEvery30Seconds()});Ve(this,"shouldPlayAlert",()=>this.notificationConfig.playAlertOnlyWhenHidden?!Yk.isWindowVisible():!0);Ve(this,"executeRecurringNotification",()=>{this.store.hasUnreadConversation()&&this.shouldPlayAlert()&&(this.playAudioAlert(),Xk()),this.resetRecurringTimer()});Ve(this,"clearRecurringTimer",()=>{this.recurringNotificationTimer&&clearTimeout(this.recurringNotificationTimer)});Ve(this,"resetRecurringTimer",()=>{this.clearRecurringTimer(),this.recurringNotificationTimer=setTimeout(this.executeRecurringNotification,vJe)});Ve(this,"playAudioEvery30Seconds",()=>{const{audioAlertType:e,alertIfUnreadConversationExist:r}=this.notificationConfig;e.includes("none")||r&&this.resetRecurringTimer()});Ve(this,"shouldNotifyOnMessage",e=>{const{audioAlertType:r}=this.notificationConfig;if(r.includes("none"))return!1;if(r.includes("all"))return!0;const a=pJe(e,this.currentUser.id),o=mJe(e),i=[];return(r.includes(P3.ASSIGNED)||r.includes("mine"))&&i.push(a),r.includes(P3.UNASSIGNED)&&i.push(o),r.includes(P3.NOTME)&&i.push(!o&&!a),i.some(Boolean)});Ve(this,"onNewMessage",e=>{if(!this.store.hasConversationPermission(this.currentUser)||this.store.isMessageFromPendingConversation(e)||fJe(e,this.currentUser.id)||!this.shouldNotifyOnMessage(e))return;const{message_type:r,private:a}=e;r!==nc.INCOMING&&!a||Yk.isWindowVisible()&&(this.store.isMessageFromCurrentConversation(e)||this.notificationConfig.playAlertOnlyWhenHidden)||(this.playAudioAlert(),Xk(),this.playAudioEvery30Seconds())});if(!e)throw new Error("store is required");this.store=new hJe(e),this.notificationConfig={audioAlertType:$k,playAlertOnlyWhenHidden:!0,alertIfUnreadConversationExist:!1},this.recurringNotificationTimer=null,this.audioConfig={audio:null,tone:_k,hasSentSoundPermissionsRequest:!1},this.currentUser=null}}const CJe=new kJe(vd);function AJe(){return{isImpersonating:K(()=>rw.get(tw.IMPERSONATION_USER))}}const{isImpersonating:xJe}=AJe();class yJe extends Wp{constructor(r,a){const{websocketURL:o=""}=window.chatwootConfig||{},i=o||window.__WEBSOCKET_URL__||"";super(r,a,i);Ve(this,"onReconnect",()=>{yr.emit(Ri.WEBSOCKET_RECONNECT)});Ve(this,"onDisconnected",()=>{yr.emit(Ri.WEBSOCKET_DISCONNECT)});Ve(this,"isAValidEvent",r=>this.app.$store.getters.getCurrentAccountId===r.account_id);Ve(this,"onMessageUpdated",r=>{this.app.$store.dispatch("updateMessage",r)});Ve(this,"onPresenceUpdate",r=>{xJe.value||(this.app.$store.dispatch("contacts/updatePresence",r.contacts),this.app.$store.dispatch("agents/updatePresence",r.users),this.app.$store.dispatch("setCurrentUserAvailability",r.users))});Ve(this,"onConversationContactChange",r=>{const{meta:a={},id:o}=r,{sender:i}=a||{};o&&this.app.$store.dispatch("updateConversationContact",{conversationId:o,...i})});Ve(this,"onAssigneeChanged",r=>{const{id:a}=r;a&&this.app.$store.dispatch("updateConversation",r),this.fetchConversationStats()});Ve(this,"onConversationCreated",r=>{this.app.$store.dispatch("addConversation",r),this.fetchConversationStats()});Ve(this,"onConversationRead",r=>{this.app.$store.dispatch("updateConversation",r)});Ve(this,"onLogout",()=>Qa.logout());Ve(this,"onMessageCreated",r=>{const{conversation:{last_activity_at:a},conversation_id:o}=r;window.__WOOT_ISOLATED_SHELL__||CJe.onNewMessage(r),this.app.$store.dispatch("addMessage",r),this.app.$store.dispatch("updateConversationLastActivity",{lastActivityAt:a,conversationId:o})});Ve(this,"onReload",()=>window.location.reload());Ve(this,"onStatusChange",r=>{this.app.$store.dispatch("updateConversation",r),this.fetchConversationStats()});Ve(this,"onConversationUpdated",r=>{this.app.$store.dispatch("updateConversation",r),this.fetchConversationStats()});Ve(this,"onTypingOn",({conversation:r,user:a})=>{const o=r.id;this.clearTimer(o),this.app.$store.dispatch("conversationTypingStatus/create",{conversationId:o,user:a}),this.initTimer({conversation:r,user:a})});Ve(this,"onTypingOff",({conversation:r,user:a})=>{const o=r.id;this.clearTimer(o),this.app.$store.dispatch("conversationTypingStatus/destroy",{conversationId:o,user:a})});Ve(this,"onConversationMentioned",r=>{this.app.$store.dispatch("addMentions",r)});Ve(this,"clearTimer",r=>{const a=this.CancelTyping[r];a&&(clearTimeout(a),this.CancelTyping[r]=null)});Ve(this,"initTimer",({conversation:r,user:a})=>{const o=r.id;this.CancelTyping[o]=setTimeout(()=>{this.onTypingOff({conversation:r,user:a})},3e4)});Ve(this,"fetchConversationStats",()=>{yr.emit("fetch_conversation_stats")});Ve(this,"onContactDelete",r=>{this.app.$store.dispatch("contacts/deleteContactThroughConversations",r.id),this.fetchConversationStats()});Ve(this,"onContactUpdate",r=>{this.app.$store.dispatch("contacts/updateContact",r)});Ve(this,"onNotificationCreated",r=>{this.app.$store.dispatch("notifications/addNotification",r)});Ve(this,"onNotificationDeleted",r=>{this.app.$store.dispatch("notifications/deleteNotification",r)});Ve(this,"onNotificationUpdated",r=>{this.app.$store.dispatch("notifications/updateNotification",r)});Ve(this,"onCopilotMessageCreated",r=>{this.app.$store.dispatch("copilotMessages/upsert",r)});Ve(this,"onCacheInvalidate",r=>{const a=r.cache_keys;this.app.$store.dispatch("labels/revalidate",{newKey:a.label}),this.app.$store.dispatch("inboxes/revalidate",{newKey:a.inbox}),this.app.$store.dispatch("teams/revalidate",{newKey:a.team})});this.CancelTyping=[],this.events={"message.created":this.onMessageCreated,"message.updated":this.onMessageUpdated,"conversation.created":this.onConversationCreated,"conversation.status_changed":this.onStatusChange,"user:logout":this.onLogout,"page:reload":this.onReload,"assignee.changed":this.onAssigneeChanged,"conversation.typing_on":this.onTypingOn,"conversation.typing_off":this.onTypingOff,"conversation.contact_changed":this.onConversationContactChange,"presence.update":this.onPresenceUpdate,"contact.deleted":this.onContactDelete,"contact.updated":this.onContactUpdate,"conversation.mentioned":this.onConversationMentioned,"notification.created":this.onNotificationCreated,"notification.deleted":this.onNotificationDeleted,"notification.updated":this.onNotificationUpdated,"conversation.read":this.onConversationRead,"conversation.updated":this.onConversationUpdated,"account.cache_invalidated":this.onCacheInvalidate,"copilot.message.created":this.onCopilotMessageCreated}}}const TJe={init(t,e){return new yJe({$store:t},e)}},NM=kn.createContext(),SJe=({baseURL:t,accountId:e,userToken:r,websocketURL:a,pubsubToken:o,conversationId:i,disableUpload:n,children:s})=>{const l=kn.useRef(!1),[c,u]=kn.useState(!1);if(!t)throw new Error("ChatwootProvider: baseURL is required");if(!r)throw new Error("ChatwootProvider: userToken is required");const d={baseURL:t.replace(/\/$/,""),userToken:r,accountId:e,conversationId:i,disableUpload:n||!1,websocketURL:a,pubsubToken:o};function g(){MWe(),window.__WOOT_API_HOST__=d.baseURL,window.__WOOT_ACCOUNT_ID__=d.accountId,window.__WOOT_ACCESS_TOKEN__=d.userToken,window.__WEBSOCKET_URL__=d.websocketURL,window.__PUBSUB_TOKEN__=d.pubsubToken,window.__WOOT_CONVERSATION_ID__=d.conversationId,window.__EDITOR_DISABLE_UPLOAD__=d.disableUpload,window.__WOOT_ISOLATED_SHELL__=!0,cBe(),window.WootConstants=oc,window.axios=nJe(_t),vd.dispatch("setUser").then(()=>{TJe.init(vd,d.pubsubToken),u(!0)})}return kn.useEffect(()=>{l.current||(g(),l.current=!0)},[d.baseURL,d.userToken,d.websocketURL,d.pubsubToken]),c?pu.jsx(NM.Provider,{value:d,children:s}):null},DM=()=>{const t=kn.useContext(NM);if(!t)throw new Error("useChatwoot must be used within ChatwootProvider");return t},VM=({conversationId:t,className:e="",style:r={},onError:a=null,onLoad:o=null,...i})=>{const n=kn.useRef();return kn.useEffect(()=>{if(!n.current)return;const s=n.current;s.conversationId=t},[t]),kn.useEffect(()=>{if(!n.current)return;const s=n.current,l=()=>{o==null||o()},c=u=>{var g;const d=((g=u.detail)==null?void 0:g.message)||"Unknown error occurred";a==null||a(new Error(d))};return s.addEventListener("chatwoot:loaded",l),s.addEventListener("chatwoot:error",c),()=>{s.removeEventListener("chatwoot:loaded",l),s.removeEventListener("chatwoot:error",c)}},[o,a]),pu.jsx("chatwoot-message-list",{ref:n,className:e,style:r,...i})},IJe=({conversationId:t,className:e="",style:r={},...a})=>(DM(),pu.jsx("div",{className:`chatwoot-conversation ${e} text-n-slate-11`,style:{height:"100%",width:"100%",position:"relative",...r},children:pu.jsx(VM,{className:"h-full w-full",...a})}));function MJe(t){var e=t;return!!(e.ctrlKey||e.shiftKey||e.metaKey||e.button&&e.button==1)}function OJe(t,e){return!!(t.target==="_blank"&&e)}function LJe(t,e,r,a){var o=this,i=[];return t?(t instanceof Element?i=[t]:"toArray"in t?i=t.toArray():i=t,i.forEach(function(n){n.addEventListener("click",function(s){var l,c,u=e instanceof Function?e(n):e,d=r instanceof Function?r(n):r,g=n.getAttribute("href")||n.getAttributeNS("http://www.w3.org/1999/xlink","href")||n.getAttribute("xlink:href")||((l=n.getElementsByTagName("a")[0])===null||l===void 0?void 0:l.getAttribute("href")),h=O4(o.track(u,d,a??{}),(c=o.settings.timeout)!==null&&c!==void 0?c:500);!OJe(n,g)&&!MJe(s)&&g&&(s.preventDefault?s.preventDefault():s.returnValue=!1,h.catch(console.error).then(function(){window.location.href=g}).catch(console.error))},!1)}),this):this}function RJe(t,e,r,a){var o=this;if(!t)return this;t instanceof HTMLFormElement&&(t=[t]);var i=t;return i.forEach(function(n){if(!(n instanceof Element))throw new TypeError("Must pass HTMLElement to trackForm/trackSubmit.");var s=function(c){var u;c.preventDefault?c.preventDefault():c.returnValue=!1;var d=e instanceof Function?e(n):e,g=r instanceof Function?r(n):r,h=O4(o.track(d,g,a??{}),(u=o.settings.timeout)!==null&&u!==void 0?u:500);h.catch(console.error).then(function(){n.submit()}).catch(console.error)},l=window.jQuery||window.Zepto;l?l(n).submit(s):n.addEventListener("submit",s,!1)}),this}const H2=Object.freeze(Object.defineProperty({__proto__:null,form:RJe,link:LJe},Symbol.toStringTag,{value:"Module"}));function e7(t,e){return Object.keys(e).reduce(function(r,a){if(a.startsWith(t)){var o=a.substr(t.length);r[o]=e[a]}return r},{})}function NJe(t,e){var r=document.createElement("a");r.href=e;var a=r.search.slice(1),o=a.split("&").reduce(function(w,v){var A=v.split("="),E=A[0],M=A[1];return w[E]=_9(M),w},{}),i=[],n=o.ajs_uid,s=o.ajs_event,l=o.ajs_aid,c=ym(t.options.useQueryString)?t.options.useQueryString:{},u=c.aid,d=u===void 0?/.+/:u,g=c.uid,h=g===void 0?/.+/:g;if(l){var m=Array.isArray(o.ajs_aid)?o.ajs_aid[0]:o.ajs_aid;d.test(m)&&t.setAnonymousId(m)}if(n){var f=Array.isArray(o.ajs_uid)?o.ajs_uid[0]:o.ajs_uid;if(h.test(f)){var b=e7("ajs_trait_",o);i.push(t.identify(f,b))}}if(s){var k=Array.isArray(o.ajs_event)?o.ajs_event[0]:o.ajs_event,C=e7("ajs_prop_",o);i.push(t.track(k,C))}return Promise.all(i)}const DJe=Object.freeze(Object.defineProperty({__proto__:null,queryString:NJe},Symbol.toStringTag,{value:"Module"}));var mu={},lw={};for(var BM=[],fs=0;fs<64;)BM[fs]=0|4294967296*Math.sin(++fs%Math.PI);function VJe(t){var e,r,a,o=[e=1732584193,r=4023233417,~e,~r],i=[],n=unescape(encodeURI(t))+"€",s=n.length;for(t=--s/4+2|15,i[--t]=8*s;~s;)i[s>>2]|=n.charCodeAt(s)<<8*s--;for(fs=n=0;fs<t;fs+=16){for(s=o;n<64;s=[a=s[3],e+((a=s[0]+[e&r|~e&a,a&e|~a&r,e^r^a,r^(e|~a)][s=n>>4]+BM[n]+~~i[fs|15&[n,5*n+1,3*n+5,7*n][s]])<<(s=[7,12,17,22,5,9,14,20,4,11,16,23,6,10,15,21][4*s+n++%4])|a>>>-s),e,r])e=0|s[1],r=s[2];for(n=4;n;)o[--n]+=s[n]}for(t="";n<32;)t+=(o[n>>3]>>4*(1^n++)&15).toString(16);return t}const BJe=Object.freeze(Object.defineProperty({__proto__:null,default:VJe},Symbol.toStringTag,{value:"Module"})),PJe=Cd(BJe);var PM={exports:{}};(function(t,e){(function(r,a){t.exports=function(o,i,n,s,l){for(i=i.split?i.split("."):i,s=0;s<i.length;s++)o=o?o[i[s]]:l;return o===l?n:o}})()})(PM);var cw=PM.exports;/**
192
+ `+i):a.stack=i}catch{}}throw a}}_request(e,r){typeof e=="string"?(r=r||{},r.url=e):r=e||{},r=qs(this.defaults,r);const{transitional:a,paramsSerializer:o,headers:i}=r;a!==void 0&&hu.assertOptions(a,{silentJSONParsing:Po.transitional(Po.boolean),forcedJSONParsing:Po.transitional(Po.boolean),clarifyTimeoutError:Po.transitional(Po.boolean)},!1),o!=null&&(ne.isFunction(o)?r.paramsSerializer={serialize:o}:hu.assertOptions(o,{encode:Po.function,serialize:Po.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),hu.assertOptions(r,{baseUrl:Po.spelling("baseURL"),withXsrfToken:Po.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let n=i&&ne.merge(i.common,i[r.method]);i&&ne.forEach(["delete","get","head","post","put","patch","common"],m=>{delete i[m]}),r.headers=xa.concat(n,i);const s=[];let l=!0;this.interceptors.request.forEach(function(f){typeof f.runWhen=="function"&&f.runWhen(r)===!1||(l=l&&f.synchronous,s.unshift(f.fulfilled,f.rejected))});const c=[];this.interceptors.response.forEach(function(f){c.push(f.fulfilled,f.rejected)});let u,d=0,g;if(!l){const m=[Jk.bind(this),void 0];for(m.unshift.apply(m,s),m.push.apply(m,c),g=m.length,u=Promise.resolve(r);d<g;)u=u.then(m[d++],m[d++]);return u}g=s.length;let h=r;for(d=0;d<g;){const m=s[d++],f=s[d++];try{h=m(h)}catch(b){f.call(this,b);break}}try{u=Jk.call(this,h)}catch(m){return Promise.reject(m)}for(d=0,g=c.length;d<g;)u=u.then(c[d++],c[d++]);return u}getUri(e){e=qs(this.defaults,e);const r=xM(e.baseURL,e.url,e.allowAbsoluteUrls);return bM(r,e.params,e.paramsSerializer)}};ne.forEach(["delete","get","head","options"],function(e){Ls.prototype[e]=function(r,a){return this.request(qs(a||{},{method:e,url:r,data:(a||{}).data}))}});ne.forEach(["post","put","patch"],function(e){function r(a){return function(i,n,s){return this.request(qs(s||{},{method:e,headers:a?{"Content-Type":"multipart/form-data"}:{},url:i,data:n}))}}Ls.prototype[e]=r(),Ls.prototype[e+"Form"]=r(!0)});let rJe=class OM{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(i){r=i});const a=this;this.promise.then(o=>{if(!a._listeners)return;let i=a._listeners.length;for(;i-- >0;)a._listeners[i](o);a._listeners=null}),this.promise.then=o=>{let i;const n=new Promise(s=>{a.subscribe(s),i=s}).then(o);return n.cancel=function(){a.unsubscribe(i)},n},e(function(i,n,s){a.reason||(a.reason=new F0(i,n,s),r(a.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const r=this._listeners.indexOf(e);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const e=new AbortController,r=a=>{e.abort(a)};return this.subscribe(r),e.signal.unsubscribe=()=>this.unsubscribe(r),e.signal}static source(){let e;return{token:new OM(function(o){e=o}),cancel:e}}};function aJe(t){return function(r){return t.apply(null,r)}}function oJe(t){return ne.isObject(t)&&t.isAxiosError===!0}const Hp={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(Hp).forEach(([t,e])=>{Hp[e]=t});function LM(t){const e=new Ls(t),r=lM(Ls.prototype.request,e);return ne.extend(r,Ls.prototype,e,{allOwnKeys:!0}),ne.extend(r,e,null,{allOwnKeys:!0}),r.create=function(o){return LM(qs(t,o))},r}const _t=LM(Wc);_t.Axios=Ls;_t.CanceledError=F0;_t.CancelToken=rJe;_t.isCancel=CM;_t.VERSION=MM;_t.toFormData=Wg;_t.AxiosError=He;_t.Cancel=_t.CanceledError;_t.all=function(e){return Promise.all(e)};_t.spread=aJe;_t.isAxiosError=oJe;_t.mergeConfig=qs;_t.AxiosHeaders=xa;_t.formToJSON=t=>kM(ne.isHTMLForm(t)?new FormData(t):t);_t.getAdapter=IM.getAdapter;_t.HttpStatusCode=Hp;_t.default=_t;const{Axios:ket,AxiosError:Cet,CanceledError:Aet,isCancel:xet,CancelToken:yet,VERSION:Tet,all:Iet,Cancel:Met,isAxiosError:Oet,spread:Let,toFormData:Ret,AxiosHeaders:Net,HttpStatusCode:Det,formToJSON:Vet,getAdapter:Bet,mergeConfig:Pet}=_t,iJe=t=>Promise.reject(t),nJe=t=>{const e=window.__WOOT_API_HOST__,r=window.__WOOT_ACCESS_TOKEN__,a=t.create({baseURL:`${e}/`});return Object.assign(a.defaults.headers.common,{api_access_token:r}),a.interceptors.response.use(o=>o,o=>iJe(o)),a};var Kp={exports:{}};(function(t,e){(function(r,a){a(e)})(ct,function(r){var a={logger:self.console,WebSocket:self.WebSocket},o={log:function(){if(this.enabled){for(var N,q=arguments.length,j=Array(q),J=0;J<q;J++)j[J]=arguments[J];j.push(Date.now()),(N=a.logger).log.apply(N,["[ActionCable]"].concat(j))}}},i=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(S){return typeof S}:function(S){return S&&typeof Symbol=="function"&&S.constructor===Symbol&&S!==Symbol.prototype?"symbol":typeof S},n=function(S,N){if(!(S instanceof N))throw new TypeError("Cannot call a class as a function")},s=function(){function S(N,q){for(var j=0;j<q.length;j++){var J=q[j];J.enumerable=J.enumerable||!1,J.configurable=!0,"value"in J&&(J.writable=!0),Object.defineProperty(N,J.key,J)}}return function(N,q,j){return q&&S(N.prototype,q),j&&S(N,j),N}}(),l=function(){return new Date().getTime()},c=function(N){return(l()-N)/1e3},u=function(N,q,j){return Math.max(q,Math.min(j,N))},d=function(){function S(N){n(this,S),this.visibilityDidChange=this.visibilityDidChange.bind(this),this.connection=N,this.reconnectAttempts=0}return S.prototype.start=function(){this.isRunning()||(this.startedAt=l(),delete this.stoppedAt,this.startPolling(),addEventListener("visibilitychange",this.visibilityDidChange),o.log("ConnectionMonitor started. pollInterval = "+this.getPollInterval()+" ms"))},S.prototype.stop=function(){this.isRunning()&&(this.stoppedAt=l(),this.stopPolling(),removeEventListener("visibilitychange",this.visibilityDidChange),o.log("ConnectionMonitor stopped"))},S.prototype.isRunning=function(){return this.startedAt&&!this.stoppedAt},S.prototype.recordPing=function(){this.pingedAt=l()},S.prototype.recordConnect=function(){this.reconnectAttempts=0,this.recordPing(),delete this.disconnectedAt,o.log("ConnectionMonitor recorded connect")},S.prototype.recordDisconnect=function(){this.disconnectedAt=l(),o.log("ConnectionMonitor recorded disconnect")},S.prototype.startPolling=function(){this.stopPolling(),this.poll()},S.prototype.stopPolling=function(){clearTimeout(this.pollTimeout)},S.prototype.poll=function(){var q=this;this.pollTimeout=setTimeout(function(){q.reconnectIfStale(),q.poll()},this.getPollInterval())},S.prototype.getPollInterval=function(){var q=this.constructor.pollInterval,j=q.min,J=q.max,_=q.multiplier,B=_*Math.log(this.reconnectAttempts+1);return Math.round(u(B,j,J)*1e3)},S.prototype.reconnectIfStale=function(){this.connectionIsStale()&&(o.log("ConnectionMonitor detected stale connection. reconnectAttempts = "+this.reconnectAttempts+", pollInterval = "+this.getPollInterval()+" ms, time disconnected = "+c(this.disconnectedAt)+" s, stale threshold = "+this.constructor.staleThreshold+" s"),this.reconnectAttempts++,this.disconnectedRecently()?o.log("ConnectionMonitor skipping reopening recent disconnect"):(o.log("ConnectionMonitor reopening"),this.connection.reopen()))},S.prototype.connectionIsStale=function(){return c(this.pingedAt?this.pingedAt:this.startedAt)>this.constructor.staleThreshold},S.prototype.disconnectedRecently=function(){return this.disconnectedAt&&c(this.disconnectedAt)<this.constructor.staleThreshold},S.prototype.visibilityDidChange=function(){var q=this;document.visibilityState==="visible"&&setTimeout(function(){(q.connectionIsStale()||!q.connection.isOpen())&&(o.log("ConnectionMonitor reopening stale connection on visibilitychange. visibilityState = "+document.visibilityState),q.connection.reopen())},200)},S}();d.pollInterval={min:3,max:30,multiplier:5},d.staleThreshold=6;var g={message_types:{welcome:"welcome",disconnect:"disconnect",ping:"ping",confirmation:"confirm_subscription",rejection:"reject_subscription"},disconnect_reasons:{unauthorized:"unauthorized",invalid_request:"invalid_request",server_restart:"server_restart"},default_mount_path:"/cable",protocols:["actioncable-v1-json","actioncable-unsupported"]},h=g.message_types,m=g.protocols,f=m.slice(0,m.length-1),b=[].indexOf,k=function(){function S(N){n(this,S),this.open=this.open.bind(this),this.consumer=N,this.subscriptions=this.consumer.subscriptions,this.monitor=new d(this),this.disconnected=!0}return S.prototype.send=function(q){return this.isOpen()?(this.webSocket.send(JSON.stringify(q)),!0):!1},S.prototype.open=function(){return this.isActive()?(o.log("Attempted to open WebSocket, but existing socket is "+this.getState()),!1):(o.log("Opening WebSocket, current state is "+this.getState()+", subprotocols: "+m),this.webSocket&&this.uninstallEventHandlers(),this.webSocket=new a.WebSocket(this.consumer.url,m),this.installEventHandlers(),this.monitor.start(),!0)},S.prototype.close=function(){var q=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{allowReconnect:!0},j=q.allowReconnect;if(j||this.monitor.stop(),this.isActive())return this.webSocket.close()},S.prototype.reopen=function(){if(o.log("Reopening WebSocket, current state is "+this.getState()),this.isActive())try{return this.close()}catch(q){o.log("Failed to reopen WebSocket",q)}finally{o.log("Reopening WebSocket in "+this.constructor.reopenDelay+"ms"),setTimeout(this.open,this.constructor.reopenDelay)}else return this.open()},S.prototype.getProtocol=function(){if(this.webSocket)return this.webSocket.protocol},S.prototype.isOpen=function(){return this.isState("open")},S.prototype.isActive=function(){return this.isState("open","connecting")},S.prototype.isProtocolSupported=function(){return b.call(f,this.getProtocol())>=0},S.prototype.isState=function(){for(var q=arguments.length,j=Array(q),J=0;J<q;J++)j[J]=arguments[J];return b.call(j,this.getState())>=0},S.prototype.getState=function(){if(this.webSocket){for(var q in a.WebSocket)if(a.WebSocket[q]===this.webSocket.readyState)return q.toLowerCase()}return null},S.prototype.installEventHandlers=function(){for(var q in this.events){var j=this.events[q].bind(this);this.webSocket["on"+q]=j}},S.prototype.uninstallEventHandlers=function(){for(var q in this.events)this.webSocket["on"+q]=function(){}},S}();k.reopenDelay=500,k.prototype.events={message:function(N){if(this.isProtocolSupported()){var q=JSON.parse(N.data),j=q.identifier,J=q.message,_=q.reason,B=q.reconnect,T=q.type;switch(T){case h.welcome:return this.monitor.recordConnect(),this.subscriptions.reload();case h.disconnect:return o.log("Disconnecting. Reason: "+_),this.close({allowReconnect:B});case h.ping:return this.monitor.recordPing();case h.confirmation:return this.subscriptions.notify(j,"connected");case h.rejection:return this.subscriptions.reject(j);default:return this.subscriptions.notify(j,"received",J)}}},open:function(){if(o.log("WebSocket onopen event, using '"+this.getProtocol()+"' subprotocol"),this.disconnected=!1,!this.isProtocolSupported())return o.log("Protocol is unsupported. Stopping monitor and disconnecting."),this.close({allowReconnect:!1})},close:function(N){if(o.log("WebSocket onclose event"),!this.disconnected)return this.disconnected=!0,this.monitor.recordDisconnect(),this.subscriptions.notifyAll("disconnected",{willAttemptReconnect:this.monitor.isRunning()})},error:function(){o.log("WebSocket onerror event")}};var C=function(N,q){if(q!=null)for(var j in q){var J=q[j];N[j]=J}return N},w=function(){function S(N){var q=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},j=arguments[2];n(this,S),this.consumer=N,this.identifier=JSON.stringify(q),C(this,j)}return S.prototype.perform=function(q){var j=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return j.action=q,this.send(j)},S.prototype.send=function(q){return this.consumer.send({command:"message",identifier:this.identifier,data:JSON.stringify(q)})},S.prototype.unsubscribe=function(){return this.consumer.subscriptions.remove(this)},S}(),v=function(){function S(N){n(this,S),this.consumer=N,this.subscriptions=[]}return S.prototype.create=function(q,j){var J=q,_=(typeof J>"u"?"undefined":i(J))==="object"?J:{channel:J},B=new w(this.consumer,_,j);return this.add(B)},S.prototype.add=function(q){return this.subscriptions.push(q),this.consumer.ensureActiveConnection(),this.notify(q,"initialized"),this.sendCommand(q,"subscribe"),q},S.prototype.remove=function(q){return this.forget(q),this.findAll(q.identifier).length||this.sendCommand(q,"unsubscribe"),q},S.prototype.reject=function(q){var j=this;return this.findAll(q).map(function(J){return j.forget(J),j.notify(J,"rejected"),J})},S.prototype.forget=function(q){return this.subscriptions=this.subscriptions.filter(function(j){return j!==q}),q},S.prototype.findAll=function(q){return this.subscriptions.filter(function(j){return j.identifier===q})},S.prototype.reload=function(){var q=this;return this.subscriptions.map(function(j){return q.sendCommand(j,"subscribe")})},S.prototype.notifyAll=function(q){for(var j=this,J=arguments.length,_=Array(J>1?J-1:0),B=1;B<J;B++)_[B-1]=arguments[B];return this.subscriptions.map(function(T){return j.notify.apply(j,[T,q].concat(_))})},S.prototype.notify=function(q,j){for(var J=arguments.length,_=Array(J>2?J-2:0),B=2;B<J;B++)_[B-2]=arguments[B];var T=void 0;return typeof q=="string"?T=this.findAll(q):T=[q],T.map(function(L){return typeof L[j]=="function"?L[j].apply(L,_):void 0})},S.prototype.sendCommand=function(q,j){var J=q.identifier;return this.consumer.send({command:j,identifier:J})},S}(),A=function(){function S(N){n(this,S),this._url=N,this.subscriptions=new v(this),this.connection=new k(this)}return S.prototype.send=function(q){return this.connection.send(q)},S.prototype.connect=function(){return this.connection.open()},S.prototype.disconnect=function(){return this.connection.close({allowReconnect:!1})},S.prototype.ensureActiveConnection=function(){if(!this.connection.isActive())return this.connection.open()},s(S,[{key:"url",get:function(){return E(this._url)}}]),S}();function E(S){if(typeof S=="function"&&(S=S()),S&&!/^wss?:/i.test(S)){var N=document.createElement("a");return N.href=S,N.href=N.href,N.protocol=N.protocol.replace("http","ws"),N.href}else return S}function M(){var S=arguments.length>0&&arguments[0]!==void 0?arguments[0]:P("url")||g.default_mount_path;return new A(S)}function P(S){var N=document.head.querySelector("meta[name='action-cable-"+S+"']");if(N)return N.getAttribute("content")}r.Connection=k,r.ConnectionMonitor=d,r.Consumer=A,r.INTERNAL=g,r.Subscription=w,r.Subscriptions=v,r.adapters=a,r.createWebSocketURL=E,r.logger=o,r.createConsumer=M,r.getConfig=P,Object.defineProperty(r,"__esModule",{value:!0})})})(Kp,Kp.exports);var sJe=Kp.exports;const lJe=2e4,cJe=1e3,Ml=class Ml{constructor(e,r,a=""){Ve(this,"clearReconnectTimer",()=>{this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null)});Ve(this,"initReconnectTimer",()=>{this.clearReconnectTimer(),this.reconnectTimer=setTimeout(()=>{this.checkConnection()},cJe)});Ve(this,"onReconnect",()=>{});Ve(this,"onDisconnected",()=>{});Ve(this,"onReceived",({event:e,data:r}={})=>{this.isAValidEvent(r)&&this.events[e]&&typeof this.events[e]=="function"&&this.events[e](r)});const o=a?`${a}/cable`:void 0;this.consumer=sJe.createConsumer(o),this.subscription=this.consumer.subscriptions.create({channel:"RoomChannel",pubsub_token:r,account_id:e.$store.getters.getCurrentAccountId,user_id:e.$store.getters.getCurrentUserID},{updatePresence(){this.perform("update_presence")},received:this.onReceived,disconnected:()=>{Ml.isDisconnected=!0,this.onDisconnected(),this.initReconnectTimer()}}),this.app=e,this.events={},this.reconnectTimer=null,this.isAValidEvent=()=>!0,this.triggerPresenceInterval=()=>{setTimeout(()=>{this.subscription.updatePresence(),this.triggerPresenceInterval()},lJe)},this.triggerPresenceInterval()}checkConnection(){const e=this.consumer.connection.isOpen();Ml.isDisconnected&&e?(this.clearReconnectTimer(),this.onReconnect(),Ml.isDisconnected=!1):this.initReconnectTimer()}disconnect(){this.consumer.disconnect()}};Ve(Ml,"isDisconnected",!1);let Wp=Ml;const Xk=()=>{document.querySelectorAll(".favicon").forEach(e=>{const r=`/favicon-badge-${e.sizes[[0]]}.png`;e.href=r})},uJe=()=>{const t=document.querySelectorAll(".favicon");document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"&&t.forEach(e=>{const r=`/favicon-${e.sizes[[0]]}.png`;e.href=r})})},P3={ASSIGNED:"assigned",NOTME:"notme",UNASSIGNED:"unassigned"},dJe=["agent","administrator"],gJe=["conversation_manage","conversation_unassigned_manage","conversation_participating_manage"];class hJe{constructor(e){Ve(this,"hasUnreadConversation",()=>this.store.getters.getMineChats({assigneeType:"me",status:"open"}).some(r=>r.unread_count>0));Ve(this,"isMessageFromPendingConversation",(e={})=>{const{conversation_id:r}=e||{};if(!r)return!1;const a=this.store.getters.getConversationById(r);return(a==null?void 0:a.status)===oc.STATUS_TYPE.PENDING});Ve(this,"isMessageFromCurrentConversation",e=>{var r;return((r=this.store.getters.getSelectedChat)==null?void 0:r.id)===e.conversation_id});Ve(this,"hasConversationPermission",e=>{const r=this.store.getters.getCurrentAccountId,a=Np(e,r);return[...dJe,...gJe].some(i=>a.includes(i))});this.store=e}}const RM=t=>{var e;return(e=t==null?void 0:t.conversation)==null?void 0:e.assignee_id},mJe=t=>!RM(t),pJe=(t,e)=>RM(t)===e,fJe=(t,e)=>{var r;return((r=t==null?void 0:t.sender)==null?void 0:r.id)===e};class wJe{constructor(){Ve(this,"initializeEvent",()=>{window.addEventListener("blur",()=>{this.isVisible=!1}),window.addEventListener("focus",()=>{this.isVisible=!0})});this.isVisible=!0,this.initializeEvent()}isWindowVisible(){return!document.hidden&&this.isVisible}}const Yk=new wJe,vJe=3e4,bJe=1e4,EJe="/audio/dashboard/",_k="ding",$k=["none"];class kJe{constructor(e){Ve(this,"intializeAudio",()=>{const e=`${EJe}${this.audioConfig.tone}.mp3`;return this.audioConfig.audio=new Audio(e),this.audioConfig.audio.load()});Ve(this,"playAudioAlert",async()=>{try{await this.audioConfig.audio.play()}catch(e){e.name==="NotAllowedError"&&!this.hasSentSoundPermissionsRequest&&(this.hasSentSoundPermissionsRequest=!0,It("PROFILE_SETTINGS.FORM.AUDIO_NOTIFICATIONS_SECTION.SOUND_PERMISSION_ERROR",{usei18n:!0,duration:bJe}))}});Ve(this,"set",({currentUser:e,alwaysPlayAudioAlert:r,alertIfUnreadConversationExist:a,audioAlertType:o=$k,audioAlertTone:i=_k})=>{this.notificationConfig={...this.notificationConfig,audioAlertType:o.split("+").filter(Boolean),playAlertOnlyWhenHidden:!r,alertIfUnreadConversationExist:a},this.currentUser=e;const n=this.audioConfig.tone;this.audioConfig={...this.audioConfig,tone:i},n!==i&&this.intializeAudio(),uJe(),this.clearRecurringTimer(),this.playAudioEvery30Seconds()});Ve(this,"shouldPlayAlert",()=>this.notificationConfig.playAlertOnlyWhenHidden?!Yk.isWindowVisible():!0);Ve(this,"executeRecurringNotification",()=>{this.store.hasUnreadConversation()&&this.shouldPlayAlert()&&(this.playAudioAlert(),Xk()),this.resetRecurringTimer()});Ve(this,"clearRecurringTimer",()=>{this.recurringNotificationTimer&&clearTimeout(this.recurringNotificationTimer)});Ve(this,"resetRecurringTimer",()=>{this.clearRecurringTimer(),this.recurringNotificationTimer=setTimeout(this.executeRecurringNotification,vJe)});Ve(this,"playAudioEvery30Seconds",()=>{const{audioAlertType:e,alertIfUnreadConversationExist:r}=this.notificationConfig;e.includes("none")||r&&this.resetRecurringTimer()});Ve(this,"shouldNotifyOnMessage",e=>{const{audioAlertType:r}=this.notificationConfig;if(r.includes("none"))return!1;if(r.includes("all"))return!0;const a=pJe(e,this.currentUser.id),o=mJe(e),i=[];return(r.includes(P3.ASSIGNED)||r.includes("mine"))&&i.push(a),r.includes(P3.UNASSIGNED)&&i.push(o),r.includes(P3.NOTME)&&i.push(!o&&!a),i.some(Boolean)});Ve(this,"onNewMessage",e=>{if(!this.store.hasConversationPermission(this.currentUser)||this.store.isMessageFromPendingConversation(e)||fJe(e,this.currentUser.id)||!this.shouldNotifyOnMessage(e))return;const{message_type:r,private:a}=e;r!==nc.INCOMING&&!a||Yk.isWindowVisible()&&(this.store.isMessageFromCurrentConversation(e)||this.notificationConfig.playAlertOnlyWhenHidden)||(this.playAudioAlert(),Xk(),this.playAudioEvery30Seconds())});if(!e)throw new Error("store is required");this.store=new hJe(e),this.notificationConfig={audioAlertType:$k,playAlertOnlyWhenHidden:!0,alertIfUnreadConversationExist:!1},this.recurringNotificationTimer=null,this.audioConfig={audio:null,tone:_k,hasSentSoundPermissionsRequest:!1},this.currentUser=null}}const CJe=new kJe(vd);function AJe(){return{isImpersonating:K(()=>rw.get(tw.IMPERSONATION_USER))}}const{isImpersonating:xJe}=AJe();class yJe extends Wp{constructor(r,a){const{websocketURL:o=""}=window.chatwootConfig||{},i=o||window.__WEBSOCKET_URL__||"";super(r,a,i);Ve(this,"onReconnect",()=>{yr.emit(Ri.WEBSOCKET_RECONNECT)});Ve(this,"onDisconnected",()=>{yr.emit(Ri.WEBSOCKET_DISCONNECT)});Ve(this,"isAValidEvent",r=>this.app.$store.getters.getCurrentAccountId===r.account_id);Ve(this,"onMessageUpdated",r=>{this.app.$store.dispatch("updateMessage",r)});Ve(this,"onPresenceUpdate",r=>{xJe.value||(this.app.$store.dispatch("contacts/updatePresence",r.contacts),this.app.$store.dispatch("agents/updatePresence",r.users),this.app.$store.dispatch("setCurrentUserAvailability",r.users))});Ve(this,"onConversationContactChange",r=>{const{meta:a={},id:o}=r,{sender:i}=a||{};o&&this.app.$store.dispatch("updateConversationContact",{conversationId:o,...i})});Ve(this,"onAssigneeChanged",r=>{const{id:a}=r;a&&this.app.$store.dispatch("updateConversation",r),this.fetchConversationStats()});Ve(this,"onConversationCreated",r=>{this.app.$store.dispatch("addConversation",r),this.fetchConversationStats()});Ve(this,"onConversationRead",r=>{this.app.$store.dispatch("updateConversation",r)});Ve(this,"onLogout",()=>Qa.logout());Ve(this,"onMessageCreated",r=>{const{conversation:{last_activity_at:a},conversation_id:o}=r;window.__WOOT_ISOLATED_SHELL__||CJe.onNewMessage(r),this.app.$store.dispatch("addMessage",r),this.app.$store.dispatch("updateConversationLastActivity",{lastActivityAt:a,conversationId:o})});Ve(this,"onReload",()=>window.location.reload());Ve(this,"onStatusChange",r=>{this.app.$store.dispatch("updateConversation",r),this.fetchConversationStats()});Ve(this,"onConversationUpdated",r=>{this.app.$store.dispatch("updateConversation",r),this.fetchConversationStats()});Ve(this,"onTypingOn",({conversation:r,user:a})=>{const o=r.id;this.clearTimer(o),this.app.$store.dispatch("conversationTypingStatus/create",{conversationId:o,user:a}),this.initTimer({conversation:r,user:a})});Ve(this,"onTypingOff",({conversation:r,user:a})=>{const o=r.id;this.clearTimer(o),this.app.$store.dispatch("conversationTypingStatus/destroy",{conversationId:o,user:a})});Ve(this,"onConversationMentioned",r=>{this.app.$store.dispatch("addMentions",r)});Ve(this,"clearTimer",r=>{const a=this.CancelTyping[r];a&&(clearTimeout(a),this.CancelTyping[r]=null)});Ve(this,"initTimer",({conversation:r,user:a})=>{const o=r.id;this.CancelTyping[o]=setTimeout(()=>{this.onTypingOff({conversation:r,user:a})},3e4)});Ve(this,"fetchConversationStats",()=>{yr.emit("fetch_conversation_stats")});Ve(this,"onContactDelete",r=>{this.app.$store.dispatch("contacts/deleteContactThroughConversations",r.id),this.fetchConversationStats()});Ve(this,"onContactUpdate",r=>{this.app.$store.dispatch("contacts/updateContact",r)});Ve(this,"onNotificationCreated",r=>{this.app.$store.dispatch("notifications/addNotification",r)});Ve(this,"onNotificationDeleted",r=>{this.app.$store.dispatch("notifications/deleteNotification",r)});Ve(this,"onNotificationUpdated",r=>{this.app.$store.dispatch("notifications/updateNotification",r)});Ve(this,"onCopilotMessageCreated",r=>{this.app.$store.dispatch("copilotMessages/upsert",r)});Ve(this,"onCacheInvalidate",r=>{const a=r.cache_keys;this.app.$store.dispatch("labels/revalidate",{newKey:a.label}),this.app.$store.dispatch("inboxes/revalidate",{newKey:a.inbox}),this.app.$store.dispatch("teams/revalidate",{newKey:a.team})});this.CancelTyping=[],this.events={"message.created":this.onMessageCreated,"message.updated":this.onMessageUpdated,"conversation.created":this.onConversationCreated,"conversation.status_changed":this.onStatusChange,"user:logout":this.onLogout,"page:reload":this.onReload,"assignee.changed":this.onAssigneeChanged,"conversation.typing_on":this.onTypingOn,"conversation.typing_off":this.onTypingOff,"conversation.contact_changed":this.onConversationContactChange,"presence.update":this.onPresenceUpdate,"contact.deleted":this.onContactDelete,"contact.updated":this.onContactUpdate,"conversation.mentioned":this.onConversationMentioned,"notification.created":this.onNotificationCreated,"notification.deleted":this.onNotificationDeleted,"notification.updated":this.onNotificationUpdated,"conversation.read":this.onConversationRead,"conversation.updated":this.onConversationUpdated,"account.cache_invalidated":this.onCacheInvalidate,"copilot.message.created":this.onCopilotMessageCreated}}}const TJe={init(t,e){return new yJe({$store:t},e)}},NM=kn.createContext(),SJe=({baseURL:t,accountId:e,userToken:r,websocketURL:a,pubsubToken:o,conversationId:i,disableUpload:n,disableEditor:s,children:l})=>{const c=kn.useRef(!1),[u,d]=kn.useState(!1);if(!t)throw new Error("ChatwootProvider: baseURL is required");if(!r)throw new Error("ChatwootProvider: userToken is required");const g={baseURL:t.replace(/\/$/,""),userToken:r,accountId:e,conversationId:i,disableEditor:s||!1,disableUpload:n||!1,websocketURL:a,pubsubToken:o};function h(){MWe(),window.__WOOT_API_HOST__=g.baseURL,window.__WOOT_ACCOUNT_ID__=g.accountId,window.__WOOT_ACCESS_TOKEN__=g.userToken,window.__WEBSOCKET_URL__=g.websocketURL,window.__PUBSUB_TOKEN__=g.pubsubToken,window.__WOOT_CONVERSATION_ID__=g.conversationId,window.__EDITOR_DISABLE_UPLOAD__=g.disableUpload,window.__DISABLE_EDITOR__=g.disableEditor,window.__WOOT_ISOLATED_SHELL__=!0,cBe(),window.WootConstants=oc,window.axios=nJe(_t),vd.dispatch("setUser").then(()=>{TJe.init(vd,g.pubsubToken),d(!0)})}return kn.useEffect(()=>{c.current||(h(),c.current=!0)},[g.baseURL,g.userToken,g.websocketURL,g.pubsubToken]),u?pu.jsx(NM.Provider,{value:g,children:l}):null},DM=()=>{const t=kn.useContext(NM);if(!t)throw new Error("useChatwoot must be used within ChatwootProvider");return t},VM=({conversationId:t,className:e="",style:r={},onError:a=null,onLoad:o=null,...i})=>{const n=kn.useRef();return kn.useEffect(()=>{if(!n.current)return;const s=n.current;s.conversationId=t},[t]),kn.useEffect(()=>{if(!n.current)return;const s=n.current,l=()=>{o==null||o()},c=u=>{var g;const d=((g=u.detail)==null?void 0:g.message)||"Unknown error occurred";a==null||a(new Error(d))};return s.addEventListener("chatwoot:loaded",l),s.addEventListener("chatwoot:error",c),()=>{s.removeEventListener("chatwoot:loaded",l),s.removeEventListener("chatwoot:error",c)}},[o,a]),pu.jsx("chatwoot-message-list",{ref:n,className:e,style:r,...i})},IJe=({conversationId:t,className:e="",style:r={},...a})=>(DM(),pu.jsx("div",{className:`chatwoot-conversation ${e} text-n-slate-11`,style:{height:"100%",width:"100%",position:"relative",...r},children:pu.jsx(VM,{className:"h-full w-full",...a})}));function MJe(t){var e=t;return!!(e.ctrlKey||e.shiftKey||e.metaKey||e.button&&e.button==1)}function OJe(t,e){return!!(t.target==="_blank"&&e)}function LJe(t,e,r,a){var o=this,i=[];return t?(t instanceof Element?i=[t]:"toArray"in t?i=t.toArray():i=t,i.forEach(function(n){n.addEventListener("click",function(s){var l,c,u=e instanceof Function?e(n):e,d=r instanceof Function?r(n):r,g=n.getAttribute("href")||n.getAttributeNS("http://www.w3.org/1999/xlink","href")||n.getAttribute("xlink:href")||((l=n.getElementsByTagName("a")[0])===null||l===void 0?void 0:l.getAttribute("href")),h=O4(o.track(u,d,a??{}),(c=o.settings.timeout)!==null&&c!==void 0?c:500);!OJe(n,g)&&!MJe(s)&&g&&(s.preventDefault?s.preventDefault():s.returnValue=!1,h.catch(console.error).then(function(){window.location.href=g}).catch(console.error))},!1)}),this):this}function RJe(t,e,r,a){var o=this;if(!t)return this;t instanceof HTMLFormElement&&(t=[t]);var i=t;return i.forEach(function(n){if(!(n instanceof Element))throw new TypeError("Must pass HTMLElement to trackForm/trackSubmit.");var s=function(c){var u;c.preventDefault?c.preventDefault():c.returnValue=!1;var d=e instanceof Function?e(n):e,g=r instanceof Function?r(n):r,h=O4(o.track(d,g,a??{}),(u=o.settings.timeout)!==null&&u!==void 0?u:500);h.catch(console.error).then(function(){n.submit()}).catch(console.error)},l=window.jQuery||window.Zepto;l?l(n).submit(s):n.addEventListener("submit",s,!1)}),this}const H2=Object.freeze(Object.defineProperty({__proto__:null,form:RJe,link:LJe},Symbol.toStringTag,{value:"Module"}));function e7(t,e){return Object.keys(e).reduce(function(r,a){if(a.startsWith(t)){var o=a.substr(t.length);r[o]=e[a]}return r},{})}function NJe(t,e){var r=document.createElement("a");r.href=e;var a=r.search.slice(1),o=a.split("&").reduce(function(w,v){var A=v.split("="),E=A[0],M=A[1];return w[E]=_9(M),w},{}),i=[],n=o.ajs_uid,s=o.ajs_event,l=o.ajs_aid,c=ym(t.options.useQueryString)?t.options.useQueryString:{},u=c.aid,d=u===void 0?/.+/:u,g=c.uid,h=g===void 0?/.+/:g;if(l){var m=Array.isArray(o.ajs_aid)?o.ajs_aid[0]:o.ajs_aid;d.test(m)&&t.setAnonymousId(m)}if(n){var f=Array.isArray(o.ajs_uid)?o.ajs_uid[0]:o.ajs_uid;if(h.test(f)){var b=e7("ajs_trait_",o);i.push(t.identify(f,b))}}if(s){var k=Array.isArray(o.ajs_event)?o.ajs_event[0]:o.ajs_event,C=e7("ajs_prop_",o);i.push(t.track(k,C))}return Promise.all(i)}const DJe=Object.freeze(Object.defineProperty({__proto__:null,queryString:NJe},Symbol.toStringTag,{value:"Module"}));var mu={},lw={};for(var BM=[],fs=0;fs<64;)BM[fs]=0|4294967296*Math.sin(++fs%Math.PI);function VJe(t){var e,r,a,o=[e=1732584193,r=4023233417,~e,~r],i=[],n=unescape(encodeURI(t))+"€",s=n.length;for(t=--s/4+2|15,i[--t]=8*s;~s;)i[s>>2]|=n.charCodeAt(s)<<8*s--;for(fs=n=0;fs<t;fs+=16){for(s=o;n<64;s=[a=s[3],e+((a=s[0]+[e&r|~e&a,a&e|~a&r,e^r^a,r^(e|~a)][s=n>>4]+BM[n]+~~i[fs|15&[n,5*n+1,3*n+5,7*n][s]])<<(s=[7,12,17,22,5,9,14,20,4,11,16,23,6,10,15,21][4*s+n++%4])|a>>>-s),e,r])e=0|s[1],r=s[2];for(n=4;n;)o[--n]+=s[n]}for(t="";n<32;)t+=(o[n>>3]>>4*(1^n++)&15).toString(16);return t}const BJe=Object.freeze(Object.defineProperty({__proto__:null,default:VJe},Symbol.toStringTag,{value:"Module"})),PJe=Cd(BJe);var PM={exports:{}};(function(t,e){(function(r,a){t.exports=function(o,i,n,s,l){for(i=i.split?i.split("."):i,s=0;s<i.length;s++)o=o?o[i[s]]:l;return o===l?n:o}})()})(PM);var cw=PM.exports;/**
193
193
  * @license Apache-2.0
194
194
  *
195
195
  * Copyright (c) 2018 The Stdlib Authors.
package/index.js CHANGED
@@ -78241,36 +78241,38 @@ const IJe = {
78241
78241
  pubsubToken: o,
78242
78242
  conversationId: i,
78243
78243
  disableUpload: n,
78244
- children: s
78244
+ disableEditor: s,
78245
+ children: l
78245
78246
  }) => {
78246
- const l = m7(!1), [c, u] = kO(!1);
78247
+ const c = m7(!1), [u, d] = kO(!1);
78247
78248
  if (!t)
78248
78249
  throw new Error("ChatwootProvider: baseURL is required");
78249
78250
  if (!r)
78250
78251
  throw new Error("ChatwootProvider: userToken is required");
78251
- const d = {
78252
+ const g = {
78252
78253
  baseURL: t.replace(/\/$/, ""),
78253
78254
  // Remove trailing slash
78254
78255
  userToken: r,
78255
78256
  accountId: e,
78256
78257
  conversationId: i,
78258
+ disableEditor: s || !1,
78257
78259
  disableUpload: n || !1,
78258
78260
  websocketURL: a,
78259
78261
  pubsubToken: o
78260
78262
  };
78261
- function g() {
78262
- LWe(), window.__WOOT_API_HOST__ = d.baseURL, window.__WOOT_ACCOUNT_ID__ = d.accountId, window.__WOOT_ACCESS_TOKEN__ = d.userToken, window.__WEBSOCKET_URL__ = d.websocketURL, window.__PUBSUB_TOKEN__ = d.pubsubToken, window.__WOOT_CONVERSATION_ID__ = d.conversationId, window.__EDITOR_DISABLE_UPLOAD__ = d.disableUpload, window.__WOOT_ISOLATED_SHELL__ = !0, dBe(), window.WootConstants = ac, window.axios = lJe(_t), wd.dispatch("setUser").then(() => {
78263
- IJe.init(wd, d.pubsubToken), u(!0);
78263
+ function h() {
78264
+ LWe(), window.__WOOT_API_HOST__ = g.baseURL, window.__WOOT_ACCOUNT_ID__ = g.accountId, window.__WOOT_ACCESS_TOKEN__ = g.userToken, window.__WEBSOCKET_URL__ = g.websocketURL, window.__PUBSUB_TOKEN__ = g.pubsubToken, window.__WOOT_CONVERSATION_ID__ = g.conversationId, window.__EDITOR_DISABLE_UPLOAD__ = g.disableUpload, window.__DISABLE_EDITOR__ = g.disableEditor, window.__WOOT_ISOLATED_SHELL__ = !0, dBe(), window.WootConstants = ac, window.axios = lJe(_t), wd.dispatch("setUser").then(() => {
78265
+ IJe.init(wd, g.pubsubToken), d(!0);
78264
78266
  });
78265
78267
  }
78266
78268
  return H3(() => {
78267
- l.current || (g(), l.current = !0);
78269
+ c.current || (h(), c.current = !0);
78268
78270
  }, [
78269
- d.baseURL,
78270
- d.userToken,
78271
- d.websocketURL,
78272
- d.pubsubToken
78273
- ]), c ? /* @__PURE__ */ mu.jsx(DM.Provider, { value: d, children: s }) : null;
78271
+ g.baseURL,
78272
+ g.userToken,
78273
+ g.websocketURL,
78274
+ g.pubsubToken
78275
+ ]), u ? /* @__PURE__ */ mu.jsx(DM.Provider, { value: g, children: l }) : null;
78274
78276
  }, MJe = () => {
78275
78277
  const t = CO(DM);
78276
78278
  if (!t)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chatwoot/agent-react-components",
3
- "version": "4.2.0-dev.0b56add844",
3
+ "version": "4.2.0-dev.76e1643ccf",
4
4
  "description": "React components for Chatwoot messaging interface with Vue Web Components",
5
5
  "main": "index.cjs",
6
6
  "module": "index.js",
package/README.md DELETED
@@ -1,69 +0,0 @@
1
- # Chatwoot React Components
2
-
3
- React components for embedding Chatwoot messaging interface with Vue Web Components under the hood.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- npm install @chatwoot/agent-react-components
9
- # or
10
- yarn add @chatwoot/agent-react-components
11
- # or
12
- pnpm add @chatwoot/agent-react-components
13
- ```
14
-
15
- ## Usage
16
-
17
- ### Basic MessageList Integration
18
-
19
- ```jsx
20
- import React from 'react';
21
- import { ChatwootProvider, ChatwootConversation } from '@chatwoot/agent-react-components';
22
- import '@chatwoot/agent-react-components/style.css';
23
-
24
- function App() {
25
- return (
26
- <ChatwootProvider
27
- baseURL="https://your-chatwoot-instance.com"
28
- accountId="123"
29
- conversationId={123}
30
- userToken="your-auth-token"
31
- websocketURL="wss://your-chatwoot-instance.com"
32
- pubsubToken="your-pubsub-token"
33
- >
34
- <ChatwootConversation />
35
- </ChatwootProvider>
36
- );
37
- }
38
- ```
39
-
40
- ## Components
41
-
42
- ### ChatwootProvider
43
-
44
- Root provider component that manages global configuration and initialization.
45
-
46
- **Props:**
47
- - `baseURL` (string, required): Your Chatwoot instance URL
48
- - `accountId` (string|number, required): account identifier
49
- - `userToken` (string, required): Authentication token
50
- - `conversationId` (number, required): ID of the conversation to display
51
- - `websocketURL` (string, optional): WebSocket endpoint, defaults to baseURL/cable
52
- - `pubsubToken` (string, optional): PubSub token, defaults to userToken
53
-
54
- ### ChatwootConversation
55
-
56
- Component that renders a specific conversation interface.
57
-
58
- ### useChatwoot
59
-
60
- Hook to access the Chatwoot configuration within a ChatwootProvider.
61
-
62
- ```jsx
63
- import { useChatwoot } from '@chatwoot/agent-react-components';
64
-
65
- function MyComponent() {
66
- const { baseURL, userId, userToken } = useChatwoot();
67
- // Use configuration as needed
68
- }
69
- ```