@paramms/chat-widget 1.9.0 → 1.9.1

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/embed.js CHANGED
@@ -1,4 +1,4 @@
1
- var RelayEmbed=function(te){"use strict";var fi=Object.defineProperty;var wi=(te,J,pe)=>J in te?fi(te,J,{enumerable:!0,configurable:!0,writable:!0,value:pe}):te[J]=pe;var c=(te,J,pe)=>wi(te,typeof J!="symbol"?J+"":J,pe);const J="oc_uid";function pe(t){try{const e=document.cookie.match(new RegExp(`(?:^|; )${t}=([^;]*)`));return e?decodeURIComponent(e[1]):null}catch{return null}}function zt(t,e){try{const o=location.protocol==="https:"?"; Secure":"";document.cookie=`${t}=${encodeURIComponent(e)}; Max-Age=31536000; Path=/; SameSite=Lax${o}`}catch{}}function Mt(){return`g_${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`}function it(){let t=null;try{t=localStorage.getItem(J)}catch{}t||(t=pe(J));const e=t??Mt();try{localStorage.setItem(J,e)}catch{}return zt(J,e),e}function Kt(t){const e=t.length;let n=0,o=0;for(;o<e;){let i=t.charCodeAt(o++);if(i&4294967168)if(!(i&4294965248))n+=2;else{if(i>=55296&&i<=56319&&o<e){const s=t.charCodeAt(o);(s&64512)===56320&&(++o,i=((i&1023)<<10)+(s&1023)+65536)}i&4294901760?n+=4:n+=3}else{n++;continue}}return n}function $t(t,e,n){const o=t.length;let i=n,s=0;for(;s<o;){let r=t.charCodeAt(s++);if(r&4294967168)if(!(r&4294965248))e[i++]=r>>6&31|192;else{if(r>=55296&&r<=56319&&s<o){const p=t.charCodeAt(s);(p&64512)===56320&&(++s,r=((r&1023)<<10)+(p&1023)+65536)}r&4294901760?(e[i++]=r>>18&7|240,e[i++]=r>>12&63|128,e[i++]=r>>6&63|128):(e[i++]=r>>12&15|224,e[i++]=r>>6&63|128)}else{e[i++]=r;continue}e[i++]=r&63|128}}const Rt=new TextEncoder,Dt=50;function _t(t,e,n){Rt.encodeInto(t,e.subarray(n))}function jt(t,e,n){t.length>Dt?_t(t,e,n):$t(t,e,n)}const Nt=4096;function ot(t,e,n){let o=e;const i=o+n,s=[];let r="";for(;o<i;){const p=t[o++];if(!(p&128))s.push(p);else if((p&224)===192){const a=t[o++]&63;s.push((p&31)<<6|a)}else if((p&240)===224){const a=t[o++]&63,w=t[o++]&63;s.push((p&31)<<12|a<<6|w)}else if((p&248)===240){const a=t[o++]&63,w=t[o++]&63,f=t[o++]&63;let h=(p&7)<<18|a<<12|w<<6|f;h>65535&&(h-=65536,s.push(h>>>10&1023|55296),h=56320|h&1023),s.push(h)}else s.push(p);s.length>=Nt&&(r+=String.fromCharCode(...s),s.length=0)}return s.length>0&&(r+=String.fromCharCode(...s)),r}const qt=new TextDecoder,Ht=200;function Ot(t,e,n){const o=t.subarray(e,e+n);return qt.decode(o)}function Ft(t,e,n){return n>Ht?Ot(t,e,n):ot(t,e,n)}class Pe{constructor(e,n){c(this,"type");c(this,"data");this.type=e,this.data=n}}class G extends Error{constructor(e){super(e);const n=Object.create(G.prototype);Object.setPrototypeOf(this,n),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:G.name})}}const xe=4294967295;function Wt(t,e,n){const o=n/4294967296,i=n;t.setUint32(e,o),t.setUint32(e+4,i)}function st(t,e,n){const o=Math.floor(n/4294967296),i=n;t.setUint32(e,o),t.setUint32(e+4,i)}function rt(t,e){const n=t.getInt32(e),o=t.getUint32(e+4);return n*4294967296+o}function Vt(t,e){const n=t.getUint32(e),o=t.getUint32(e+4);return n*4294967296+o}const Xt=-1,Gt=4294967296-1,Yt=17179869184-1;function Jt({sec:t,nsec:e}){if(t>=0&&e>=0&&t<=Yt)if(e===0&&t<=Gt){const n=new Uint8Array(4);return new DataView(n.buffer).setUint32(0,t),n}else{const n=t/4294967296,o=t&4294967295,i=new Uint8Array(8),s=new DataView(i.buffer);return s.setUint32(0,e<<2|n&3),s.setUint32(4,o),i}else{const n=new Uint8Array(12),o=new DataView(n.buffer);return o.setUint32(0,e),st(o,4,t),n}}function Zt(t){const e=t.getTime(),n=Math.floor(e/1e3),o=(e-n*1e3)*1e6,i=Math.floor(o/1e9);return{sec:n+i,nsec:o-i*1e9}}function Qt(t){if(t instanceof Date){const e=Zt(t);return Jt(e)}else return null}function en(t){const e=new DataView(t.buffer,t.byteOffset,t.byteLength);switch(t.byteLength){case 4:return{sec:e.getUint32(0),nsec:0};case 8:{const n=e.getUint32(0),o=e.getUint32(4),i=(n&3)*4294967296+o,s=n>>>2;return{sec:i,nsec:s}}case 12:{const n=rt(e,4),o=e.getUint32(0);return{sec:n,nsec:o}}default:throw new G(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${t.length}`)}}function tn(t){const e=en(t);return new Date(e.sec*1e3+e.nsec/1e6)}const nn={type:Xt,encode:Qt,decode:tn},Ke=class Ke{constructor(){c(this,"__brand");c(this,"builtInEncoders",[]);c(this,"builtInDecoders",[]);c(this,"encoders",[]);c(this,"decoders",[]);this.register(nn)}register({type:e,encode:n,decode:o}){if(e>=0)this.encoders[e]=n,this.decoders[e]=o;else{const i=-1-e;this.builtInEncoders[i]=n,this.builtInDecoders[i]=o}}tryToEncode(e,n){for(let o=0;o<this.builtInEncoders.length;o++){const i=this.builtInEncoders[o];if(i!=null){const s=i(e,n);if(s!=null){const r=-1-o;return new Pe(r,s)}}}for(let o=0;o<this.encoders.length;o++){const i=this.encoders[o];if(i!=null){const s=i(e,n);if(s!=null){const r=o;return new Pe(r,s)}}}return e instanceof Pe?e:null}decode(e,n,o){const i=n<0?this.builtInDecoders[-1-n]:this.decoders[n];return i?i(e,n,o):new Pe(n,e)}};c(Ke,"defaultCodec",new Ke);let Be=Ke;function on(t){return t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer}function je(t){return t instanceof Uint8Array?t:ArrayBuffer.isView(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):on(t)?new Uint8Array(t):Uint8Array.from(t)}const sn=100,rn=2048;class Ne{constructor(e){c(this,"extensionCodec");c(this,"context");c(this,"useBigInt64");c(this,"maxDepth");c(this,"initialBufferSize");c(this,"sortKeys");c(this,"forceFloat32");c(this,"ignoreUndefined");c(this,"forceIntegerToFloat");c(this,"pos");c(this,"view");c(this,"bytes");c(this,"entered",!1);this.extensionCodec=(e==null?void 0:e.extensionCodec)??Be.defaultCodec,this.context=e==null?void 0:e.context,this.useBigInt64=(e==null?void 0:e.useBigInt64)??!1,this.maxDepth=(e==null?void 0:e.maxDepth)??sn,this.initialBufferSize=(e==null?void 0:e.initialBufferSize)??rn,this.sortKeys=(e==null?void 0:e.sortKeys)??!1,this.forceFloat32=(e==null?void 0:e.forceFloat32)??!1,this.ignoreUndefined=(e==null?void 0:e.ignoreUndefined)??!1,this.forceIntegerToFloat=(e==null?void 0:e.forceIntegerToFloat)??!1,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}clone(){return new Ne({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,maxDepth:this.maxDepth,initialBufferSize:this.initialBufferSize,sortKeys:this.sortKeys,forceFloat32:this.forceFloat32,ignoreUndefined:this.ignoreUndefined,forceIntegerToFloat:this.forceIntegerToFloat})}reinitializeState(){this.pos=0}encodeSharedRef(e){if(this.entered)return this.clone().encodeSharedRef(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.subarray(0,this.pos)}finally{this.entered=!1}}encode(e){if(this.entered)return this.clone().encode(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.slice(0,this.pos)}finally{this.entered=!1}}doEncode(e,n){if(n>this.maxDepth)throw new Error(`Too deep objects in depth ${n}`);e==null?this.encodeNil():typeof e=="boolean"?this.encodeBoolean(e):typeof e=="number"?this.forceIntegerToFloat?this.encodeNumberAsFloat(e):this.encodeNumber(e):typeof e=="string"?this.encodeString(e):this.useBigInt64&&typeof e=="bigint"?this.encodeBigInt64(e):this.encodeObject(e,n)}ensureBufferSizeToWrite(e){const n=this.pos+e;this.view.byteLength<n&&this.resizeBuffer(n*2)}resizeBuffer(e){const n=new ArrayBuffer(e),o=new Uint8Array(n),i=new DataView(n);o.set(this.bytes),this.view=i,this.bytes=o}encodeNil(){this.writeU8(192)}encodeBoolean(e){e===!1?this.writeU8(194):this.writeU8(195)}encodeNumber(e){!this.forceIntegerToFloat&&Number.isSafeInteger(e)?e>=0?e<128?this.writeU8(e):e<256?(this.writeU8(204),this.writeU8(e)):e<65536?(this.writeU8(205),this.writeU16(e)):e<4294967296?(this.writeU8(206),this.writeU32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(207),this.writeU64(e)):e>=-32?this.writeU8(224|e+32):e>=-128?(this.writeU8(208),this.writeI8(e)):e>=-32768?(this.writeU8(209),this.writeI16(e)):e>=-2147483648?(this.writeU8(210),this.writeI32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(211),this.writeI64(e)):this.encodeNumberAsFloat(e)}encodeNumberAsFloat(e){this.forceFloat32?(this.writeU8(202),this.writeF32(e)):(this.writeU8(203),this.writeF64(e))}encodeBigInt64(e){e>=BigInt(0)?(this.writeU8(207),this.writeBigUint64(e)):(this.writeU8(211),this.writeBigInt64(e))}writeStringHeader(e){if(e<32)this.writeU8(160+e);else if(e<256)this.writeU8(217),this.writeU8(e);else if(e<65536)this.writeU8(218),this.writeU16(e);else if(e<4294967296)this.writeU8(219),this.writeU32(e);else throw new Error(`Too long string: ${e} bytes in UTF-8`)}encodeString(e){const o=Kt(e);this.ensureBufferSizeToWrite(5+o),this.writeStringHeader(o),jt(e,this.bytes,this.pos),this.pos+=o}encodeObject(e,n){const o=this.extensionCodec.tryToEncode(e,this.context);if(o!=null)this.encodeExtension(o);else if(Array.isArray(e))this.encodeArray(e,n);else if(ArrayBuffer.isView(e))this.encodeBinary(e);else if(typeof e=="object")this.encodeMap(e,n);else throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(e)}`)}encodeBinary(e){const n=e.byteLength;if(n<256)this.writeU8(196),this.writeU8(n);else if(n<65536)this.writeU8(197),this.writeU16(n);else if(n<4294967296)this.writeU8(198),this.writeU32(n);else throw new Error(`Too large binary: ${n}`);const o=je(e);this.writeU8a(o)}encodeArray(e,n){const o=e.length;if(o<16)this.writeU8(144+o);else if(o<65536)this.writeU8(220),this.writeU16(o);else if(o<4294967296)this.writeU8(221),this.writeU32(o);else throw new Error(`Too large array: ${o}`);for(const i of e)this.doEncode(i,n+1)}countWithoutUndefined(e,n){let o=0;for(const i of n)e[i]!==void 0&&o++;return o}encodeMap(e,n){const o=Object.keys(e);this.sortKeys&&o.sort();const i=this.ignoreUndefined?this.countWithoutUndefined(e,o):o.length;if(i<16)this.writeU8(128+i);else if(i<65536)this.writeU8(222),this.writeU16(i);else if(i<4294967296)this.writeU8(223),this.writeU32(i);else throw new Error(`Too large map object: ${i}`);for(const s of o){const r=e[s];this.ignoreUndefined&&r===void 0||(this.encodeString(s),this.doEncode(r,n+1))}}encodeExtension(e){if(typeof e.data=="function"){const o=e.data(this.pos+6),i=o.length;if(i>=4294967296)throw new Error(`Too large extension object: ${i}`);this.writeU8(201),this.writeU32(i),this.writeI8(e.type),this.writeU8a(o);return}const n=e.data.length;if(n===1)this.writeU8(212);else if(n===2)this.writeU8(213);else if(n===4)this.writeU8(214);else if(n===8)this.writeU8(215);else if(n===16)this.writeU8(216);else if(n<256)this.writeU8(199),this.writeU8(n);else if(n<65536)this.writeU8(200),this.writeU16(n);else if(n<4294967296)this.writeU8(201),this.writeU32(n);else throw new Error(`Too large extension object: ${n}`);this.writeI8(e.type),this.writeU8a(e.data)}writeU8(e){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,e),this.pos++}writeU8a(e){const n=e.length;this.ensureBufferSizeToWrite(n),this.bytes.set(e,this.pos),this.pos+=n}writeI8(e){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,e),this.pos++}writeU16(e){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,e),this.pos+=2}writeI16(e){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,e),this.pos+=2}writeU32(e){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,e),this.pos+=4}writeI32(e){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,e),this.pos+=4}writeF32(e){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,e),this.pos+=4}writeF64(e){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,e),this.pos+=8}writeU64(e){this.ensureBufferSizeToWrite(8),Wt(this.view,this.pos,e),this.pos+=8}writeI64(e){this.ensureBufferSizeToWrite(8),st(this.view,this.pos,e),this.pos+=8}writeBigUint64(e){this.ensureBufferSizeToWrite(8),this.view.setBigUint64(this.pos,e),this.pos+=8}writeBigInt64(e){this.ensureBufferSizeToWrite(8),this.view.setBigInt64(this.pos,e),this.pos+=8}}function an(t,e){return new Ne(e).encodeSharedRef(t)}function qe(t){return`${t<0?"-":""}0x${Math.abs(t).toString(16).padStart(2,"0")}`}const cn=16,ln=16;class dn{constructor(e=cn,n=ln){c(this,"hit",0);c(this,"miss",0);c(this,"caches");c(this,"maxKeyLength");c(this,"maxLengthPerKey");this.maxKeyLength=e,this.maxLengthPerKey=n,this.caches=[];for(let o=0;o<this.maxKeyLength;o++)this.caches.push([])}canBeCached(e){return e>0&&e<=this.maxKeyLength}find(e,n,o){const i=this.caches[o-1];e:for(const s of i){const r=s.bytes;for(let p=0;p<o;p++)if(r[p]!==e[n+p])continue e;return s.str}return null}store(e,n){const o=this.caches[e.length-1],i={bytes:e,str:n};o.length>=this.maxLengthPerKey?o[Math.random()*o.length|0]=i:o.push(i)}decode(e,n,o){const i=this.find(e,n,o);if(i!=null)return this.hit++,i;this.miss++;const s=ot(e,n,o),r=Uint8Array.prototype.slice.call(e,n,n+o);return this.store(r,s),s}}const He="array",me="map_key",at="map_value",hn=t=>{if(typeof t=="string"||typeof t=="number")return t;throw new G("The type of key must be string or number but "+typeof t)};class pn{constructor(){c(this,"stack",[]);c(this,"stackHeadPosition",-1)}get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(e){const n=this.getUninitializedStateFromPool();n.type=He,n.position=0,n.size=e,n.array=new Array(e)}pushMapState(e){const n=this.getUninitializedStateFromPool();n.type=me,n.readCount=0,n.size=e,n.map={}}getUninitializedStateFromPool(){if(this.stackHeadPosition++,this.stackHeadPosition===this.stack.length){const e={type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null};this.stack.push(e)}return this.stack[this.stackHeadPosition]}release(e){if(this.stack[this.stackHeadPosition]!==e)throw new Error("Invalid stack state. Released state is not on top of the stack.");if(e.type===He){const o=e;o.size=0,o.array=void 0,o.position=0,o.type=void 0}if(e.type===me||e.type===at){const o=e;o.size=0,o.map=void 0,o.readCount=0,o.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}}const be=-1,Oe=new DataView(new ArrayBuffer(0)),un=new Uint8Array(Oe.buffer);try{Oe.getInt8(0)}catch(t){if(!(t instanceof RangeError))throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access")}const ct=new RangeError("Insufficient data"),fn=new dn;class Fe{constructor(e){c(this,"extensionCodec");c(this,"context");c(this,"useBigInt64");c(this,"rawStrings");c(this,"maxStrLength");c(this,"maxBinLength");c(this,"maxArrayLength");c(this,"maxMapLength");c(this,"maxExtLength");c(this,"keyDecoder");c(this,"mapKeyConverter");c(this,"totalPos",0);c(this,"pos",0);c(this,"view",Oe);c(this,"bytes",un);c(this,"headByte",be);c(this,"stack",new pn);c(this,"entered",!1);this.extensionCodec=(e==null?void 0:e.extensionCodec)??Be.defaultCodec,this.context=e==null?void 0:e.context,this.useBigInt64=(e==null?void 0:e.useBigInt64)??!1,this.rawStrings=(e==null?void 0:e.rawStrings)??!1,this.maxStrLength=(e==null?void 0:e.maxStrLength)??xe,this.maxBinLength=(e==null?void 0:e.maxBinLength)??xe,this.maxArrayLength=(e==null?void 0:e.maxArrayLength)??xe,this.maxMapLength=(e==null?void 0:e.maxMapLength)??xe,this.maxExtLength=(e==null?void 0:e.maxExtLength)??xe,this.keyDecoder=(e==null?void 0:e.keyDecoder)!==void 0?e.keyDecoder:fn,this.mapKeyConverter=(e==null?void 0:e.mapKeyConverter)??hn}clone(){return new Fe({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,rawStrings:this.rawStrings,maxStrLength:this.maxStrLength,maxBinLength:this.maxBinLength,maxArrayLength:this.maxArrayLength,maxMapLength:this.maxMapLength,maxExtLength:this.maxExtLength,keyDecoder:this.keyDecoder})}reinitializeState(){this.totalPos=0,this.headByte=be,this.stack.reset()}setBuffer(e){const n=je(e);this.bytes=n,this.view=new DataView(n.buffer,n.byteOffset,n.byteLength),this.pos=0}appendBuffer(e){if(this.headByte===be&&!this.hasRemaining(1))this.setBuffer(e);else{const n=this.bytes.subarray(this.pos),o=je(e),i=new Uint8Array(n.length+o.length);i.set(n),i.set(o,n.length),this.setBuffer(i)}}hasRemaining(e){return this.view.byteLength-this.pos>=e}createExtraByteError(e){const{view:n,pos:o}=this;return new RangeError(`Extra ${n.byteLength-o} of ${n.byteLength} byte(s) found at buffer[${e}]`)}decode(e){if(this.entered)return this.clone().decode(e);try{this.entered=!0,this.reinitializeState(),this.setBuffer(e);const n=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return n}finally{this.entered=!1}}*decodeMulti(e){if(this.entered){yield*this.clone().decodeMulti(e);return}try{for(this.entered=!0,this.reinitializeState(),this.setBuffer(e);this.hasRemaining(1);)yield this.doDecodeSync()}finally{this.entered=!1}}async decodeAsync(e){if(this.entered)return this.clone().decodeAsync(e);try{this.entered=!0;let n=!1,o;for await(const p of e){if(n)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(p);try{o=this.doDecodeSync(),n=!0}catch(a){if(!(a instanceof RangeError))throw a}this.totalPos+=this.pos}if(n){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return o}const{headByte:i,pos:s,totalPos:r}=this;throw new RangeError(`Insufficient data in parsing ${qe(i)} at ${r} (${s} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream(e){return this.decodeMultiAsync(e,!0)}decodeStream(e){return this.decodeMultiAsync(e,!1)}async*decodeMultiAsync(e,n){if(this.entered){yield*this.clone().decodeMultiAsync(e,n);return}try{this.entered=!0;let o=n,i=-1;for await(const s of e){if(n&&i===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(s),o&&(i=this.readArraySize(),o=!1,this.complete());try{for(;yield this.doDecodeSync(),--i!==0;);}catch(r){if(!(r instanceof RangeError))throw r}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){e:for(;;){const e=this.readHeadByte();let n;if(e>=224)n=e-256;else if(e<192)if(e<128)n=e;else if(e<144){const i=e-128;if(i!==0){this.pushMapState(i),this.complete();continue e}else n={}}else if(e<160){const i=e-144;if(i!==0){this.pushArrayState(i),this.complete();continue e}else n=[]}else{const i=e-160;n=this.decodeString(i,0)}else if(e===192)n=null;else if(e===194)n=!1;else if(e===195)n=!0;else if(e===202)n=this.readF32();else if(e===203)n=this.readF64();else if(e===204)n=this.readU8();else if(e===205)n=this.readU16();else if(e===206)n=this.readU32();else if(e===207)this.useBigInt64?n=this.readU64AsBigInt():n=this.readU64();else if(e===208)n=this.readI8();else if(e===209)n=this.readI16();else if(e===210)n=this.readI32();else if(e===211)this.useBigInt64?n=this.readI64AsBigInt():n=this.readI64();else if(e===217){const i=this.lookU8();n=this.decodeString(i,1)}else if(e===218){const i=this.lookU16();n=this.decodeString(i,2)}else if(e===219){const i=this.lookU32();n=this.decodeString(i,4)}else if(e===220){const i=this.readU16();if(i!==0){this.pushArrayState(i),this.complete();continue e}else n=[]}else if(e===221){const i=this.readU32();if(i!==0){this.pushArrayState(i),this.complete();continue e}else n=[]}else if(e===222){const i=this.readU16();if(i!==0){this.pushMapState(i),this.complete();continue e}else n={}}else if(e===223){const i=this.readU32();if(i!==0){this.pushMapState(i),this.complete();continue e}else n={}}else if(e===196){const i=this.lookU8();n=this.decodeBinary(i,1)}else if(e===197){const i=this.lookU16();n=this.decodeBinary(i,2)}else if(e===198){const i=this.lookU32();n=this.decodeBinary(i,4)}else if(e===212)n=this.decodeExtension(1,0);else if(e===213)n=this.decodeExtension(2,0);else if(e===214)n=this.decodeExtension(4,0);else if(e===215)n=this.decodeExtension(8,0);else if(e===216)n=this.decodeExtension(16,0);else if(e===199){const i=this.lookU8();n=this.decodeExtension(i,1)}else if(e===200){const i=this.lookU16();n=this.decodeExtension(i,2)}else if(e===201){const i=this.lookU32();n=this.decodeExtension(i,4)}else throw new G(`Unrecognized type byte: ${qe(e)}`);this.complete();const o=this.stack;for(;o.length>0;){const i=o.top();if(i.type===He)if(i.array[i.position]=n,i.position++,i.position===i.size)n=i.array,o.release(i);else continue e;else if(i.type===me){if(n==="__proto__")throw new G("The key __proto__ is not allowed");i.key=this.mapKeyConverter(n),i.type=at;continue e}else if(i.map[i.key]=n,i.readCount++,i.readCount===i.size)n=i.map,o.release(i);else{i.key=null,i.type=me;continue e}}return n}}readHeadByte(){return this.headByte===be&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=be}readArraySize(){const e=this.readHeadByte();switch(e){case 220:return this.readU16();case 221:return this.readU32();default:{if(e<160)return e-144;throw new G(`Unrecognized array type byte: ${qe(e)}`)}}}pushMapState(e){if(e>this.maxMapLength)throw new G(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(e)}pushArrayState(e){if(e>this.maxArrayLength)throw new G(`Max length exceeded: array length (${e}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState(e)}decodeString(e,n){return!this.rawStrings||this.stateIsMapKey()?this.decodeUtf8String(e,n):this.decodeBinary(e,n)}decodeUtf8String(e,n){var s;if(e>this.maxStrLength)throw new G(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+n+e)throw ct;const o=this.pos+n;let i;return this.stateIsMapKey()&&((s=this.keyDecoder)!=null&&s.canBeCached(e))?i=this.keyDecoder.decode(this.bytes,o,e):i=Ft(this.bytes,o,e),this.pos+=n+e,i}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===me:!1}decodeBinary(e,n){if(e>this.maxBinLength)throw new G(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(e+n))throw ct;const o=this.pos+n,i=this.bytes.subarray(o,o+e);return this.pos+=n+e,i}decodeExtension(e,n){if(e>this.maxExtLength)throw new G(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);const o=this.view.getInt8(this.pos+n),i=this.decodeBinary(e,n+1);return this.extensionCodec.decode(i,o,this.context)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){const e=this.view.getUint8(this.pos);return this.pos++,e}readI8(){const e=this.view.getInt8(this.pos);return this.pos++,e}readU16(){const e=this.view.getUint16(this.pos);return this.pos+=2,e}readI16(){const e=this.view.getInt16(this.pos);return this.pos+=2,e}readU32(){const e=this.view.getUint32(this.pos);return this.pos+=4,e}readI32(){const e=this.view.getInt32(this.pos);return this.pos+=4,e}readU64(){const e=Vt(this.view,this.pos);return this.pos+=8,e}readI64(){const e=rt(this.view,this.pos);return this.pos+=8,e}readU64AsBigInt(){const e=this.view.getBigUint64(this.pos);return this.pos+=8,e}readI64AsBigInt(){const e=this.view.getBigInt64(this.pos);return this.pos+=8,e}readF32(){const e=this.view.getFloat32(this.pos);return this.pos+=4,e}readF64(){const e=this.view.getFloat64(this.pos);return this.pos+=8,e}}function wn(t,e){return new Fe(e).decode(t)}const gn=new Set(["auth","open","send","sync","history","read","typing","react","edit","delete","invoke","pubkey","ping","uploadPrekeys","fetchPrekey","assign","tag","note","agent_status","subscribe_inbox","unsubscribe_inbox"]);function yn(t){return gn.has(t.type)}function We(t){return an(t)}function lt(t){let e;try{e=wn(t)}catch{return null}return typeof e!="object"||e===null||typeof e.type!="string"?null:e}class xn{constructor(e){c(this,"conversationId");c(this,"state","");c(this,"version",0);c(this,"hasMoreHistory",!1);c(this,"lastReadByOthers",0);c(this,"assignedAgentId");c(this,"accent");c(this,"subject");c(this,"name");c(this,"e2e",!1);c(this,"offline",!1);c(this,"offlineMessage","");c(this,"launcherMessage",null);c(this,"preChat",null);c(this,"whiteLabel",!1);c(this,"typing",new Set);c(this,"online",new Set);c(this,"sentiment");c(this,"sentimentScore");c(this,"actions",[]);c(this,"byId",new Map);c(this,"keyByClient",new Map);c(this,"_maxSeq",0);c(this,"_sorted",null);this.me=e}messages(){return this._sorted||(this._sorted=[...this.byId.values()].sort((e,n)=>{const o=e.status==="pending",i=n.status==="pending";return o!==i?o?1:-1:o&&i?e.ts-n.ts:e.seq-n.seq})),this._sorted}visibleActions(){return this.actions.filter(e=>!e.availableInStates||e.availableInStates.includes(this.state))}actionById(e){return this.actions.find(n=>n.id===e)}highestSeq(){return this._maxSeq}addOptimistic(e,n){const o={id:e,conversationId:this.conversationId,seq:0,senderId:this.me,senderRole:"guest",content:n,ts:Date.now(),clientMsgId:e,status:"pending"};return this.byId.set(e,o),this.keyByClient.set(e,e),this._sorted=null,o}apply(e){var n;switch(e.type){case"opened":this.conversationId=e.conversation.id,this.state=e.conversation.state,e.subject&&(this.subject=e.subject);return;case"manifest":this.actions=e.actions,this.version=e.version,e.name&&(this.name=e.name),(n=e.theme)!=null&&n.accent&&(this.accent=e.theme.accent),e.e2e&&(this.e2e=!0),this.offline=e.offline===!0,this.offlineMessage=e.offlineMessage??"",e.launcherMessage&&(this.launcherMessage=e.launcherMessage),e.whiteLabel&&(this.whiteLabel=!0),e.preChat&&(this.preChat=e.preChat);return;case"message":this.upsert({...e.message});return;case"ack":{const o=this.keyByClient.get(e.clientMsgId),i=o?this.byId.get(o):void 0;if(i&&o){this.byId.delete(o);const s={...i,id:e.messageId,seq:e.seq,ts:e.ts,status:"sent"};this.byId.set(e.messageId,s),this.keyByClient.set(e.clientMsgId,e.messageId),e.seq>this._maxSeq&&(this._maxSeq=e.seq)}this._sorted=null;return}case"delivered":this.markOwnStatus(e.seq,"delivered");return;case"read":e.by!==this.me&&(this.lastReadByOthers=Math.max(this.lastReadByOthers,e.seq),this.markOwnStatus(e.seq,"read"));return;case"sync":for(const o of e.messages)this.upsert({...o});return;case"history":for(const o of e.messages)this.upsert({...o});this.hasMoreHistory=e.hasMore;return;case"typing":e.userId!==this.me&&(e.isTyping?this.typing.add(e.userId):this.typing.delete(e.userId));return;case"reaction":{const o=this.byId.get(e.messageId);if(!o)return;const i={...o.reactions??{}},s=(i[e.emoji]??[]).filter(r=>r!==e.by);e.removed||s.push(e.by),s.length?i[e.emoji]=s:delete i[e.emoji],this.byId.set(e.messageId,{...o,reactions:i}),this._sorted=null;return}case"edited":{const o=this.byId.get(e.messageId);o&&(this.byId.set(e.messageId,{...o,content:e.content,editedAt:e.editedAt}),this._sorted=null);return}case"deleted":{const o=this.byId.get(e.messageId);o&&(this.byId.set(e.messageId,{...o,deletedAt:e.ts}),this._sorted=null);return}case"state":this.state=e.state;return;case"assigned":this.assignedAgentId=e.agentId??void 0;return;case"presence":e.status==="online"?this.online.add(e.userId):this.online.delete(e.userId);return;case"subjectState":case"invoked":case"authed":case"error":case"pong":return;case"sentiment":this.sentiment=e.label,this.sentimentScore=e.score;return;default:return}}upsert(e){const n=this.byId.get(e.id);this.byId.set(e.id,n?{...n,...e}:e),e.seq>this._maxSeq&&(this._maxSeq=e.seq),this._sorted=null}markOwnStatus(e,n){const o=dt(n);let i=!1;for(const[s,r]of this.byId)r.senderId!==this.me||r.seq<=0||r.seq>e||dt(r.status)>=o||(this.byId.set(s,{...r,status:n}),i=!0);i&&(this._sorted=null)}}function dt(t){switch(t){case"read":return 3;case"delivered":return 2;case"sent":return 1;default:return 0}}class mn{constructor(e){c(this,"socket",null);c(this,"state","idle");c(this,"authed",!1);c(this,"everAuthed",!1);c(this,"attempt",0);c(this,"outbox",[]);c(this,"stopped",!1);c(this,"timer",null);c(this,"refreshing",!1);this.opts=e}connect(){var o,i;if(this.state==="connecting"||this.state==="open")return;this.stopped=!1,this.state="connecting",this.authed=!1,(i=(o=this.opts).onStatusChange)==null||i.call(o,this.attempt>0?"reconnecting":"connecting");const n=(this.opts.socketFactory??kn)(this.opts.url);n.binaryType="arraybuffer",this.socket=n,n.onopen=()=>{this.raw({type:"auth",token:this.opts.token})},n.onmessage=s=>{const r=lt(new Uint8Array(s.data));!r||yn(r)||this.handle(r)},n.onclose=()=>this.onClosed(),n.onerror=()=>{try{n.close()}catch{}}}send(e){if(this.state==="open"&&this.authed){this.raw(e);return}this.queue(e)}pendingCount(){return this.outbox.length}close(){var e;this.stopped=!0,this.timer&&clearTimeout(this.timer),this.state="closed";try{(e=this.socket)==null||e.close()}catch{}}handle(e){var n,o,i,s;if(e.type==="authed"&&(this.attempt=0,this.state="open",this.authed=!0,this.everAuthed=!0,(o=(n=this.opts).onStatusChange)==null||o.call(n,"open"),this.raw(this.opts.open),this.opts.open.type!=="open"&&this.flush()),e.type==="opened"&&(this.raw({type:"sync",conversationId:e.conversation.id,sinceSeq:this.opts.getCursor()}),this.flush(e.conversation.id)),e.type==="error"&&bn.has(e.code)){if(e.code==="UNAUTHORIZED"&&this.opts.refreshToken&&!this.refreshing){this.refreshing=!0,(s=(i=this.opts).onStatusChange)==null||s.call(i,"reconnecting","Renewing session…"),this.opts.refreshToken().then(r=>{var p;if(this.refreshing=!1,!r){this.fatal(e);return}this.opts.token=r;try{(p=this.socket)==null||p.close()}catch{}}).catch(()=>{this.refreshing=!1,this.fatal(e)});return}this.fatal(e);return}this.opts.onFrame(e)}fatal(e){var n,o,i;this.stopped=!0;try{(n=this.socket)==null||n.close()}catch{}this.state="closed",(i=(o=this.opts).onStatusChange)==null||i.call(o,"error",vn(e.code)),this.opts.onFrame(e)}flush(e){const n=this.outbox;this.outbox=[];for(const o of n)this.raw(e&&o.type==="send"&&o.conversationId!==e?{...o,conversationId:e}:o)}queue(e){const n=this.opts.maxOutbox??1e3;this.outbox.length>=n&&(this.outbox=this.outbox.slice(this.outbox.length-(n>>1))),this.outbox.push(e)}raw(e){if(!this.socket){this.queue(e);return}try{this.socket.send(We(e))}catch{this.queue(e)}}onClosed(){var i,s;if(this.authed=!1,this.socket=null,this.stopped){this.state="closed";return}this.state="idle";const e=this.opts.backoffBaseMs??500,n=this.opts.backoffMaxMs??15e3,o=Math.min(n,e*2**this.attempt)*(.5+Math.random()*.5);this.attempt++,this.attempt>=3&&!this.everAuthed&&((s=(i=this.opts).onStatusChange)==null||s.call(i,"reconnecting","Can't reach chat — retrying…")),this.timer=setTimeout(()=>this.connect(),o)}}const bn=new Set(["UNAUTHORIZED"]);function vn(t){switch(t){case"UNAUTHORIZED":return"Chat unavailable — sign-in/token was rejected";default:return"Chat unavailable"}}function kn(t){return new WebSocket(t)}const ht=200,Sn=7*864e5;class In{constructor(e){c(this,"key");this.key=`ocw_outbox_${e}`}load(){try{const e=localStorage.getItem(this.key);if(!e)return[];const n=JSON.parse(e),o=Date.now()-Sn,i=n.filter(s=>s.ts>=o);return i.length!==n.length&&this.save(i),i}catch{return[]}}add(e){try{const n=this.load();n.push(e),this.save(n.length>ht?n.slice(n.length-ht):n)}catch{}}remove(e){try{const n=this.load().filter(o=>o.clientMsgId!==e);this.save(n)}catch{}}save(e){try{localStorage.setItem(this.key,JSON.stringify(e))}catch{}}}const D=()=>globalThis.crypto.subtle;function Ae(t){const e=t instanceof Uint8Array?t:new Uint8Array(t);let n="";for(const o of e)n+=String.fromCharCode(o);return btoa(n)}function Ve(t){const e=atob(t),n=new ArrayBuffer(e.length),o=new Uint8Array(n);for(let i=0;i<e.length;i++)o[i]=e.charCodeAt(i);return o}async function ve(){const t=await D().generateKey({name:"ECDH",namedCurve:"P-256"},!0,["deriveKey","deriveBits"]);return{publicKey:t.publicKey,privateKey:t.privateKey}}async function re(t){return Ae(await D().exportKey("raw",t))}async function ue(t){return D().importKey("raw",Ve(t),{name:"ECDH",namedCurve:"P-256"},!1,[])}async function Cn(t,e){const n=await ue(e);return D().deriveKey({name:"ECDH",public:n},t,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}async function Tn(t,e){const n=globalThis.crypto.getRandomValues(new Uint8Array(12)),o=new TextEncoder().encode(e),i=await D().encrypt({name:"AES-GCM",iv:n},t,o);return{ct:Ae(i),iv:Ae(n)}}async function En(t,e,n){const o=await D().decrypt({name:"AES-GCM",iv:Ve(n)},t,Ve(e));return new TextDecoder().decode(o)}async function Un(t){var n,o;try{const i=(n=globalThis.localStorage)==null?void 0:n.getItem(t);if(i){const{pub:s,priv:r}=JSON.parse(i),p=await D().importKey("jwk",s,{name:"ECDH",namedCurve:"P-256"},!0,[]),a=await D().importKey("jwk",r,{name:"ECDH",namedCurve:"P-256"},!0,["deriveKey","deriveBits"]);return{publicKey:p,privateKey:a}}}catch{}const e=await ve();try{const i=await D().exportKey("jwk",e.publicKey),s=await D().exportKey("jwk",e.privateKey);(o=globalThis.localStorage)==null||o.setItem(t,JSON.stringify({pub:i,priv:s}))}catch{}return e}async function Pn(t,e){const n=await D().exportKey("raw",e),o=await D().sign({name:"ECDSA",hash:"SHA-256"},t,n);return Ae(o)}async function Bn(){const t=await ve(),e=await D().generateKey({name:"ECDSA",namedCurve:"P-256"},!0,["sign","verify"]);return{ecdhKP:t,ecdsaKP:{publicKey:e.publicKey,privateKey:e.privateKey},publicKeyB64:await re(t.publicKey),sigPublicKeyB64:await re(e.publicKey)}}async function pt(t){var n,o;try{const i=(n=globalThis.localStorage)==null?void 0:n.getItem(`${t}-identity`);if(i){const s=JSON.parse(i),r=await D().importKey("jwk",s.ecdhPub,{name:"ECDH",namedCurve:"P-256"},!0,[]),p=await D().importKey("jwk",s.ecdhPriv,{name:"ECDH",namedCurve:"P-256"},!0,["deriveKey","deriveBits"]),a=await D().importKey("jwk",s.ecdsaPub,{name:"ECDSA",namedCurve:"P-256"},!0,["verify"]),w=await D().importKey("jwk",s.ecdsaPriv,{name:"ECDSA",namedCurve:"P-256"},!0,["sign"]);return{ecdhKP:{publicKey:r,privateKey:p},ecdsaKP:{publicKey:a,privateKey:w},publicKeyB64:await re(r),sigPublicKeyB64:await re(a)}}}catch{}const e=await Bn();try{const i=await D().exportKey("jwk",e.ecdhKP.publicKey),s=await D().exportKey("jwk",e.ecdhKP.privateKey),r=await D().exportKey("jwk",e.ecdsaKP.publicKey),p=await D().exportKey("jwk",e.ecdsaKP.privateKey);(o=globalThis.localStorage)==null||o.setItem(`${t}-identity`,JSON.stringify({ecdhPub:i,ecdhPriv:s,ecdsaPub:r,ecdsaPriv:p}))}catch{}return e}async function An(t,e){const n=await ve(),o=await re(n.publicKey),i=await ue(e.identityKey),s=await ue(e.signedPrekey),r=e.oneTimePrekey?await ue(e.oneTimePrekey):null,p=await ae(t.privateKey,s),a=await ae(n.privateKey,i),w=await ae(n.privateKey,s),f=r?await ae(n.privateKey,r):null,h=ut(p,a,w,...f?[f]:[]);return{sharedKey:await ft(h),ephemeralPublicKey:o}}async function Ln(t,e,n,o,i){const s=await ue(n),r=await ue(o),p=await ae(e.privateKey,s),a=await ae(t.privateKey,r),w=await ae(e.privateKey,r),f=i?await ae(i.privateKey,r):null,h=ut(p,a,w,...f?[f]:[]);return ft(h)}async function ae(t,e){return D().deriveBits({name:"ECDH",public:e},t,256)}function ut(...t){const e=t.reduce((i,s)=>i+s.byteLength,0),n=new Uint8Array(e);let o=0;for(const i of t)n.set(new Uint8Array(i),o),o+=i.byteLength;return n.buffer}async function ft(t){const e=await D().importKey("raw",t,"HKDF",!1,["deriveKey"]);return D().deriveKey({name:"HKDF",hash:"SHA-256",salt:new Uint8Array(32),info:new TextEncoder().encode("ObjectChat X3DH v1")},e,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}const zn=20;class Mn{constructor(e){c(this,"kp");c(this,"shared");c(this,"identityKP");c(this,"signedPreKP");c(this,"signedPrekeyId");c(this,"otpKeys",[]);c(this,"x3dhShared");c(this,"pendingX3DH");this.storageKey=e}get ready(){return!!(this.shared??this.x3dhShared)}async begin(){return this.kp=await Un(this.storageKey),re(this.kp.publicKey)}async onPeerKey(e){this.kp&&(this.shared=await Cn(this.kp.privateKey,e))}async initX3DH(){this.identityKP=await pt(this.storageKey),this.signedPreKP=await ve(),this.signedPrekeyId=`spk-${Date.now()}-${Math.random().toString(36).slice(2)}`;for(let i=0;i<zn;i++)this.otpKeys.push(await ve());const e=await re(this.signedPreKP.publicKey),n=await Pn(this.identityKP.ecdsaKP.privateKey,this.signedPreKP.publicKey),o=await Promise.all(this.otpKeys.map(i=>re(i.publicKey)));return{identityKey:this.identityKP.publicKeyB64,signedPrekey:e,signedPrekeyId:this.signedPrekeyId,signature:n,oneTimePrekeys:o}}async x3dhSendTo(e){this.identityKP||(this.identityKP=await pt(this.storageKey));const{sharedKey:n,ephemeralPublicKey:o}=await An(this.identityKP.ecdhKP,e);return this.x3dhShared=n,{ephemeralKey:o,spkId:e.signedPrekeyId,usedOTP:!!e.oneTimePrekey,senderIK:this.identityKP.publicKeyB64}}async x3dhReceiveFrom(e,n,o,i){if(!this.identityKP||!this.signedPreKP){this.pendingX3DH={senderIK:e,ephemeralKey:n,spkId:o,usedOTP:i};return}const s=i?this.otpKeys.shift():void 0;this.x3dhShared=await Ln(this.identityKP.ecdhKP,this.signedPreKP,e,n,s)}async flushPendingX3DH(){if(!this.pendingX3DH)return;const{senderIK:e,ephemeralKey:n,spkId:o,usedOTP:i}=this.pendingX3DH;this.pendingX3DH=void 0,await this.x3dhReceiveFrom(e,n,o,i)}async sealText(e,n){const o=this.x3dhShared??this.shared;if(!o)throw new Error("secure channel not ready");const{ct:i,iv:s}=await Tn(o,e);return{kind:"text",text:i,enc:!0,iv:s,...n?{x3dhEK:n.ephemeralKey,x3dhSPK:n.spkId,x3dhIK:n.senderIK,x3dhOTP:n.usedOTP}:{}}}async openContent(e){if(e.kind!=="text"||!e.enc||!e.iv)return e;const n=this.x3dhShared??this.shared;if(!n)return{kind:"text",text:"🔒 encrypted"};try{return{kind:"text",text:await En(n,e.text,e.iv)}}catch{return{kind:"text",text:"🔒 unable to decrypt"}}}async openFrame(e){if(e.type==="message")e.message.content=await this.openContent(e.message.content);else if(e.type==="sync")for(const n of e.messages)n.content=await this.openContent(n.content)}}function Kn(t){if(t.kind!=="text"||!t.enc)return null;const e=t;return!e.x3dhEK||!e.x3dhSPK||!e.x3dhIK?null:{x3dhEK:e.x3dhEK,x3dhSPK:e.x3dhSPK,x3dhIK:e.x3dhIK,x3dhOTP:e.x3dhOTP??!1}}const $n={accent:"#6c5ce7",accent2:"#4c6fff",bg:"#f4f3fb",card:"#fff",tint:"#eeecfb",line:"#e6e2f5",ink:"#221d3a",mut:"#8f8aa8",onaccent:"#fff",rowhover:"#e7e3f8",shadow:"0 12px 32px rgba(108,92,231,.14)"},Rn={accent:"#a99cf2",accent2:"#6f8cff",bg:"#221d3a",card:"#2b2550",tint:"#2f2853",line:"#3a3363",ink:"#eceafc",mut:"#9b93c9",onaccent:"#221d3a",rowhover:"#39325e",shadow:"0 12px 32px rgba(0,0,0,.4)"},Dn="'Nunito',-apple-system,BlinkMacSystemFont,'Segoe UI',system-ui,sans-serif";function wt(t,e){return Object.entries(e).map(([n,o])=>`--${t}-${n}:${o};`).join(" ")}function gt(t){return`${wt(t,$n)} --${t}-fb:${Dn}; --${t}-fh:'Baloo 2',var(--${t}-fb);`}function Le(t){return wt(t,Rn)}const _n=`
1
+ var RelayEmbed=function(te){"use strict";var fi=Object.defineProperty;var wi=(te,J,pe)=>J in te?fi(te,J,{enumerable:!0,configurable:!0,writable:!0,value:pe}):te[J]=pe;var c=(te,J,pe)=>wi(te,typeof J!="symbol"?J+"":J,pe);const J="oc_uid";function pe(t){try{const e=document.cookie.match(new RegExp(`(?:^|; )${t}=([^;]*)`));return e?decodeURIComponent(e[1]):null}catch{return null}}function Mt(t,e){try{const o=location.protocol==="https:"?"; Secure":"";document.cookie=`${t}=${encodeURIComponent(e)}; Max-Age=31536000; Path=/; SameSite=Lax${o}`}catch{}}function zt(){return`g_${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`}function it(){let t=null;try{t=localStorage.getItem(J)}catch{}t||(t=pe(J));const e=t??zt();try{localStorage.setItem(J,e)}catch{}return Mt(J,e),e}function Kt(t){const e=t.length;let n=0,o=0;for(;o<e;){let i=t.charCodeAt(o++);if(i&4294967168)if(!(i&4294965248))n+=2;else{if(i>=55296&&i<=56319&&o<e){const s=t.charCodeAt(o);(s&64512)===56320&&(++o,i=((i&1023)<<10)+(s&1023)+65536)}i&4294901760?n+=4:n+=3}else{n++;continue}}return n}function $t(t,e,n){const o=t.length;let i=n,s=0;for(;s<o;){let r=t.charCodeAt(s++);if(r&4294967168)if(!(r&4294965248))e[i++]=r>>6&31|192;else{if(r>=55296&&r<=56319&&s<o){const p=t.charCodeAt(s);(p&64512)===56320&&(++s,r=((r&1023)<<10)+(p&1023)+65536)}r&4294901760?(e[i++]=r>>18&7|240,e[i++]=r>>12&63|128,e[i++]=r>>6&63|128):(e[i++]=r>>12&15|224,e[i++]=r>>6&63|128)}else{e[i++]=r;continue}e[i++]=r&63|128}}const Rt=new TextEncoder,Dt=50;function _t(t,e,n){Rt.encodeInto(t,e.subarray(n))}function jt(t,e,n){t.length>Dt?_t(t,e,n):$t(t,e,n)}const Nt=4096;function ot(t,e,n){let o=e;const i=o+n,s=[];let r="";for(;o<i;){const p=t[o++];if(!(p&128))s.push(p);else if((p&224)===192){const a=t[o++]&63;s.push((p&31)<<6|a)}else if((p&240)===224){const a=t[o++]&63,w=t[o++]&63;s.push((p&31)<<12|a<<6|w)}else if((p&248)===240){const a=t[o++]&63,w=t[o++]&63,f=t[o++]&63;let h=(p&7)<<18|a<<12|w<<6|f;h>65535&&(h-=65536,s.push(h>>>10&1023|55296),h=56320|h&1023),s.push(h)}else s.push(p);s.length>=Nt&&(r+=String.fromCharCode(...s),s.length=0)}return s.length>0&&(r+=String.fromCharCode(...s)),r}const qt=new TextDecoder,Ht=200;function Ot(t,e,n){const o=t.subarray(e,e+n);return qt.decode(o)}function Ft(t,e,n){return n>Ht?Ot(t,e,n):ot(t,e,n)}class Pe{constructor(e,n){c(this,"type");c(this,"data");this.type=e,this.data=n}}class G extends Error{constructor(e){super(e);const n=Object.create(G.prototype);Object.setPrototypeOf(this,n),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:G.name})}}const xe=4294967295;function Wt(t,e,n){const o=n/4294967296,i=n;t.setUint32(e,o),t.setUint32(e+4,i)}function st(t,e,n){const o=Math.floor(n/4294967296),i=n;t.setUint32(e,o),t.setUint32(e+4,i)}function rt(t,e){const n=t.getInt32(e),o=t.getUint32(e+4);return n*4294967296+o}function Vt(t,e){const n=t.getUint32(e),o=t.getUint32(e+4);return n*4294967296+o}const Xt=-1,Gt=4294967296-1,Yt=17179869184-1;function Jt({sec:t,nsec:e}){if(t>=0&&e>=0&&t<=Yt)if(e===0&&t<=Gt){const n=new Uint8Array(4);return new DataView(n.buffer).setUint32(0,t),n}else{const n=t/4294967296,o=t&4294967295,i=new Uint8Array(8),s=new DataView(i.buffer);return s.setUint32(0,e<<2|n&3),s.setUint32(4,o),i}else{const n=new Uint8Array(12),o=new DataView(n.buffer);return o.setUint32(0,e),st(o,4,t),n}}function Zt(t){const e=t.getTime(),n=Math.floor(e/1e3),o=(e-n*1e3)*1e6,i=Math.floor(o/1e9);return{sec:n+i,nsec:o-i*1e9}}function Qt(t){if(t instanceof Date){const e=Zt(t);return Jt(e)}else return null}function en(t){const e=new DataView(t.buffer,t.byteOffset,t.byteLength);switch(t.byteLength){case 4:return{sec:e.getUint32(0),nsec:0};case 8:{const n=e.getUint32(0),o=e.getUint32(4),i=(n&3)*4294967296+o,s=n>>>2;return{sec:i,nsec:s}}case 12:{const n=rt(e,4),o=e.getUint32(0);return{sec:n,nsec:o}}default:throw new G(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${t.length}`)}}function tn(t){const e=en(t);return new Date(e.sec*1e3+e.nsec/1e6)}const nn={type:Xt,encode:Qt,decode:tn},Ke=class Ke{constructor(){c(this,"__brand");c(this,"builtInEncoders",[]);c(this,"builtInDecoders",[]);c(this,"encoders",[]);c(this,"decoders",[]);this.register(nn)}register({type:e,encode:n,decode:o}){if(e>=0)this.encoders[e]=n,this.decoders[e]=o;else{const i=-1-e;this.builtInEncoders[i]=n,this.builtInDecoders[i]=o}}tryToEncode(e,n){for(let o=0;o<this.builtInEncoders.length;o++){const i=this.builtInEncoders[o];if(i!=null){const s=i(e,n);if(s!=null){const r=-1-o;return new Pe(r,s)}}}for(let o=0;o<this.encoders.length;o++){const i=this.encoders[o];if(i!=null){const s=i(e,n);if(s!=null){const r=o;return new Pe(r,s)}}}return e instanceof Pe?e:null}decode(e,n,o){const i=n<0?this.builtInDecoders[-1-n]:this.decoders[n];return i?i(e,n,o):new Pe(n,e)}};c(Ke,"defaultCodec",new Ke);let Be=Ke;function on(t){return t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer}function je(t){return t instanceof Uint8Array?t:ArrayBuffer.isView(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):on(t)?new Uint8Array(t):Uint8Array.from(t)}const sn=100,rn=2048;class Ne{constructor(e){c(this,"extensionCodec");c(this,"context");c(this,"useBigInt64");c(this,"maxDepth");c(this,"initialBufferSize");c(this,"sortKeys");c(this,"forceFloat32");c(this,"ignoreUndefined");c(this,"forceIntegerToFloat");c(this,"pos");c(this,"view");c(this,"bytes");c(this,"entered",!1);this.extensionCodec=(e==null?void 0:e.extensionCodec)??Be.defaultCodec,this.context=e==null?void 0:e.context,this.useBigInt64=(e==null?void 0:e.useBigInt64)??!1,this.maxDepth=(e==null?void 0:e.maxDepth)??sn,this.initialBufferSize=(e==null?void 0:e.initialBufferSize)??rn,this.sortKeys=(e==null?void 0:e.sortKeys)??!1,this.forceFloat32=(e==null?void 0:e.forceFloat32)??!1,this.ignoreUndefined=(e==null?void 0:e.ignoreUndefined)??!1,this.forceIntegerToFloat=(e==null?void 0:e.forceIntegerToFloat)??!1,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}clone(){return new Ne({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,maxDepth:this.maxDepth,initialBufferSize:this.initialBufferSize,sortKeys:this.sortKeys,forceFloat32:this.forceFloat32,ignoreUndefined:this.ignoreUndefined,forceIntegerToFloat:this.forceIntegerToFloat})}reinitializeState(){this.pos=0}encodeSharedRef(e){if(this.entered)return this.clone().encodeSharedRef(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.subarray(0,this.pos)}finally{this.entered=!1}}encode(e){if(this.entered)return this.clone().encode(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.slice(0,this.pos)}finally{this.entered=!1}}doEncode(e,n){if(n>this.maxDepth)throw new Error(`Too deep objects in depth ${n}`);e==null?this.encodeNil():typeof e=="boolean"?this.encodeBoolean(e):typeof e=="number"?this.forceIntegerToFloat?this.encodeNumberAsFloat(e):this.encodeNumber(e):typeof e=="string"?this.encodeString(e):this.useBigInt64&&typeof e=="bigint"?this.encodeBigInt64(e):this.encodeObject(e,n)}ensureBufferSizeToWrite(e){const n=this.pos+e;this.view.byteLength<n&&this.resizeBuffer(n*2)}resizeBuffer(e){const n=new ArrayBuffer(e),o=new Uint8Array(n),i=new DataView(n);o.set(this.bytes),this.view=i,this.bytes=o}encodeNil(){this.writeU8(192)}encodeBoolean(e){e===!1?this.writeU8(194):this.writeU8(195)}encodeNumber(e){!this.forceIntegerToFloat&&Number.isSafeInteger(e)?e>=0?e<128?this.writeU8(e):e<256?(this.writeU8(204),this.writeU8(e)):e<65536?(this.writeU8(205),this.writeU16(e)):e<4294967296?(this.writeU8(206),this.writeU32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(207),this.writeU64(e)):e>=-32?this.writeU8(224|e+32):e>=-128?(this.writeU8(208),this.writeI8(e)):e>=-32768?(this.writeU8(209),this.writeI16(e)):e>=-2147483648?(this.writeU8(210),this.writeI32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(211),this.writeI64(e)):this.encodeNumberAsFloat(e)}encodeNumberAsFloat(e){this.forceFloat32?(this.writeU8(202),this.writeF32(e)):(this.writeU8(203),this.writeF64(e))}encodeBigInt64(e){e>=BigInt(0)?(this.writeU8(207),this.writeBigUint64(e)):(this.writeU8(211),this.writeBigInt64(e))}writeStringHeader(e){if(e<32)this.writeU8(160+e);else if(e<256)this.writeU8(217),this.writeU8(e);else if(e<65536)this.writeU8(218),this.writeU16(e);else if(e<4294967296)this.writeU8(219),this.writeU32(e);else throw new Error(`Too long string: ${e} bytes in UTF-8`)}encodeString(e){const o=Kt(e);this.ensureBufferSizeToWrite(5+o),this.writeStringHeader(o),jt(e,this.bytes,this.pos),this.pos+=o}encodeObject(e,n){const o=this.extensionCodec.tryToEncode(e,this.context);if(o!=null)this.encodeExtension(o);else if(Array.isArray(e))this.encodeArray(e,n);else if(ArrayBuffer.isView(e))this.encodeBinary(e);else if(typeof e=="object")this.encodeMap(e,n);else throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(e)}`)}encodeBinary(e){const n=e.byteLength;if(n<256)this.writeU8(196),this.writeU8(n);else if(n<65536)this.writeU8(197),this.writeU16(n);else if(n<4294967296)this.writeU8(198),this.writeU32(n);else throw new Error(`Too large binary: ${n}`);const o=je(e);this.writeU8a(o)}encodeArray(e,n){const o=e.length;if(o<16)this.writeU8(144+o);else if(o<65536)this.writeU8(220),this.writeU16(o);else if(o<4294967296)this.writeU8(221),this.writeU32(o);else throw new Error(`Too large array: ${o}`);for(const i of e)this.doEncode(i,n+1)}countWithoutUndefined(e,n){let o=0;for(const i of n)e[i]!==void 0&&o++;return o}encodeMap(e,n){const o=Object.keys(e);this.sortKeys&&o.sort();const i=this.ignoreUndefined?this.countWithoutUndefined(e,o):o.length;if(i<16)this.writeU8(128+i);else if(i<65536)this.writeU8(222),this.writeU16(i);else if(i<4294967296)this.writeU8(223),this.writeU32(i);else throw new Error(`Too large map object: ${i}`);for(const s of o){const r=e[s];this.ignoreUndefined&&r===void 0||(this.encodeString(s),this.doEncode(r,n+1))}}encodeExtension(e){if(typeof e.data=="function"){const o=e.data(this.pos+6),i=o.length;if(i>=4294967296)throw new Error(`Too large extension object: ${i}`);this.writeU8(201),this.writeU32(i),this.writeI8(e.type),this.writeU8a(o);return}const n=e.data.length;if(n===1)this.writeU8(212);else if(n===2)this.writeU8(213);else if(n===4)this.writeU8(214);else if(n===8)this.writeU8(215);else if(n===16)this.writeU8(216);else if(n<256)this.writeU8(199),this.writeU8(n);else if(n<65536)this.writeU8(200),this.writeU16(n);else if(n<4294967296)this.writeU8(201),this.writeU32(n);else throw new Error(`Too large extension object: ${n}`);this.writeI8(e.type),this.writeU8a(e.data)}writeU8(e){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,e),this.pos++}writeU8a(e){const n=e.length;this.ensureBufferSizeToWrite(n),this.bytes.set(e,this.pos),this.pos+=n}writeI8(e){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,e),this.pos++}writeU16(e){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,e),this.pos+=2}writeI16(e){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,e),this.pos+=2}writeU32(e){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,e),this.pos+=4}writeI32(e){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,e),this.pos+=4}writeF32(e){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,e),this.pos+=4}writeF64(e){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,e),this.pos+=8}writeU64(e){this.ensureBufferSizeToWrite(8),Wt(this.view,this.pos,e),this.pos+=8}writeI64(e){this.ensureBufferSizeToWrite(8),st(this.view,this.pos,e),this.pos+=8}writeBigUint64(e){this.ensureBufferSizeToWrite(8),this.view.setBigUint64(this.pos,e),this.pos+=8}writeBigInt64(e){this.ensureBufferSizeToWrite(8),this.view.setBigInt64(this.pos,e),this.pos+=8}}function an(t,e){return new Ne(e).encodeSharedRef(t)}function qe(t){return`${t<0?"-":""}0x${Math.abs(t).toString(16).padStart(2,"0")}`}const cn=16,ln=16;class dn{constructor(e=cn,n=ln){c(this,"hit",0);c(this,"miss",0);c(this,"caches");c(this,"maxKeyLength");c(this,"maxLengthPerKey");this.maxKeyLength=e,this.maxLengthPerKey=n,this.caches=[];for(let o=0;o<this.maxKeyLength;o++)this.caches.push([])}canBeCached(e){return e>0&&e<=this.maxKeyLength}find(e,n,o){const i=this.caches[o-1];e:for(const s of i){const r=s.bytes;for(let p=0;p<o;p++)if(r[p]!==e[n+p])continue e;return s.str}return null}store(e,n){const o=this.caches[e.length-1],i={bytes:e,str:n};o.length>=this.maxLengthPerKey?o[Math.random()*o.length|0]=i:o.push(i)}decode(e,n,o){const i=this.find(e,n,o);if(i!=null)return this.hit++,i;this.miss++;const s=ot(e,n,o),r=Uint8Array.prototype.slice.call(e,n,n+o);return this.store(r,s),s}}const He="array",me="map_key",at="map_value",hn=t=>{if(typeof t=="string"||typeof t=="number")return t;throw new G("The type of key must be string or number but "+typeof t)};class pn{constructor(){c(this,"stack",[]);c(this,"stackHeadPosition",-1)}get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(e){const n=this.getUninitializedStateFromPool();n.type=He,n.position=0,n.size=e,n.array=new Array(e)}pushMapState(e){const n=this.getUninitializedStateFromPool();n.type=me,n.readCount=0,n.size=e,n.map={}}getUninitializedStateFromPool(){if(this.stackHeadPosition++,this.stackHeadPosition===this.stack.length){const e={type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null};this.stack.push(e)}return this.stack[this.stackHeadPosition]}release(e){if(this.stack[this.stackHeadPosition]!==e)throw new Error("Invalid stack state. Released state is not on top of the stack.");if(e.type===He){const o=e;o.size=0,o.array=void 0,o.position=0,o.type=void 0}if(e.type===me||e.type===at){const o=e;o.size=0,o.map=void 0,o.readCount=0,o.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}}const be=-1,Oe=new DataView(new ArrayBuffer(0)),un=new Uint8Array(Oe.buffer);try{Oe.getInt8(0)}catch(t){if(!(t instanceof RangeError))throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access")}const ct=new RangeError("Insufficient data"),fn=new dn;class Fe{constructor(e){c(this,"extensionCodec");c(this,"context");c(this,"useBigInt64");c(this,"rawStrings");c(this,"maxStrLength");c(this,"maxBinLength");c(this,"maxArrayLength");c(this,"maxMapLength");c(this,"maxExtLength");c(this,"keyDecoder");c(this,"mapKeyConverter");c(this,"totalPos",0);c(this,"pos",0);c(this,"view",Oe);c(this,"bytes",un);c(this,"headByte",be);c(this,"stack",new pn);c(this,"entered",!1);this.extensionCodec=(e==null?void 0:e.extensionCodec)??Be.defaultCodec,this.context=e==null?void 0:e.context,this.useBigInt64=(e==null?void 0:e.useBigInt64)??!1,this.rawStrings=(e==null?void 0:e.rawStrings)??!1,this.maxStrLength=(e==null?void 0:e.maxStrLength)??xe,this.maxBinLength=(e==null?void 0:e.maxBinLength)??xe,this.maxArrayLength=(e==null?void 0:e.maxArrayLength)??xe,this.maxMapLength=(e==null?void 0:e.maxMapLength)??xe,this.maxExtLength=(e==null?void 0:e.maxExtLength)??xe,this.keyDecoder=(e==null?void 0:e.keyDecoder)!==void 0?e.keyDecoder:fn,this.mapKeyConverter=(e==null?void 0:e.mapKeyConverter)??hn}clone(){return new Fe({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,rawStrings:this.rawStrings,maxStrLength:this.maxStrLength,maxBinLength:this.maxBinLength,maxArrayLength:this.maxArrayLength,maxMapLength:this.maxMapLength,maxExtLength:this.maxExtLength,keyDecoder:this.keyDecoder})}reinitializeState(){this.totalPos=0,this.headByte=be,this.stack.reset()}setBuffer(e){const n=je(e);this.bytes=n,this.view=new DataView(n.buffer,n.byteOffset,n.byteLength),this.pos=0}appendBuffer(e){if(this.headByte===be&&!this.hasRemaining(1))this.setBuffer(e);else{const n=this.bytes.subarray(this.pos),o=je(e),i=new Uint8Array(n.length+o.length);i.set(n),i.set(o,n.length),this.setBuffer(i)}}hasRemaining(e){return this.view.byteLength-this.pos>=e}createExtraByteError(e){const{view:n,pos:o}=this;return new RangeError(`Extra ${n.byteLength-o} of ${n.byteLength} byte(s) found at buffer[${e}]`)}decode(e){if(this.entered)return this.clone().decode(e);try{this.entered=!0,this.reinitializeState(),this.setBuffer(e);const n=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return n}finally{this.entered=!1}}*decodeMulti(e){if(this.entered){yield*this.clone().decodeMulti(e);return}try{for(this.entered=!0,this.reinitializeState(),this.setBuffer(e);this.hasRemaining(1);)yield this.doDecodeSync()}finally{this.entered=!1}}async decodeAsync(e){if(this.entered)return this.clone().decodeAsync(e);try{this.entered=!0;let n=!1,o;for await(const p of e){if(n)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(p);try{o=this.doDecodeSync(),n=!0}catch(a){if(!(a instanceof RangeError))throw a}this.totalPos+=this.pos}if(n){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return o}const{headByte:i,pos:s,totalPos:r}=this;throw new RangeError(`Insufficient data in parsing ${qe(i)} at ${r} (${s} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream(e){return this.decodeMultiAsync(e,!0)}decodeStream(e){return this.decodeMultiAsync(e,!1)}async*decodeMultiAsync(e,n){if(this.entered){yield*this.clone().decodeMultiAsync(e,n);return}try{this.entered=!0;let o=n,i=-1;for await(const s of e){if(n&&i===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(s),o&&(i=this.readArraySize(),o=!1,this.complete());try{for(;yield this.doDecodeSync(),--i!==0;);}catch(r){if(!(r instanceof RangeError))throw r}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){e:for(;;){const e=this.readHeadByte();let n;if(e>=224)n=e-256;else if(e<192)if(e<128)n=e;else if(e<144){const i=e-128;if(i!==0){this.pushMapState(i),this.complete();continue e}else n={}}else if(e<160){const i=e-144;if(i!==0){this.pushArrayState(i),this.complete();continue e}else n=[]}else{const i=e-160;n=this.decodeString(i,0)}else if(e===192)n=null;else if(e===194)n=!1;else if(e===195)n=!0;else if(e===202)n=this.readF32();else if(e===203)n=this.readF64();else if(e===204)n=this.readU8();else if(e===205)n=this.readU16();else if(e===206)n=this.readU32();else if(e===207)this.useBigInt64?n=this.readU64AsBigInt():n=this.readU64();else if(e===208)n=this.readI8();else if(e===209)n=this.readI16();else if(e===210)n=this.readI32();else if(e===211)this.useBigInt64?n=this.readI64AsBigInt():n=this.readI64();else if(e===217){const i=this.lookU8();n=this.decodeString(i,1)}else if(e===218){const i=this.lookU16();n=this.decodeString(i,2)}else if(e===219){const i=this.lookU32();n=this.decodeString(i,4)}else if(e===220){const i=this.readU16();if(i!==0){this.pushArrayState(i),this.complete();continue e}else n=[]}else if(e===221){const i=this.readU32();if(i!==0){this.pushArrayState(i),this.complete();continue e}else n=[]}else if(e===222){const i=this.readU16();if(i!==0){this.pushMapState(i),this.complete();continue e}else n={}}else if(e===223){const i=this.readU32();if(i!==0){this.pushMapState(i),this.complete();continue e}else n={}}else if(e===196){const i=this.lookU8();n=this.decodeBinary(i,1)}else if(e===197){const i=this.lookU16();n=this.decodeBinary(i,2)}else if(e===198){const i=this.lookU32();n=this.decodeBinary(i,4)}else if(e===212)n=this.decodeExtension(1,0);else if(e===213)n=this.decodeExtension(2,0);else if(e===214)n=this.decodeExtension(4,0);else if(e===215)n=this.decodeExtension(8,0);else if(e===216)n=this.decodeExtension(16,0);else if(e===199){const i=this.lookU8();n=this.decodeExtension(i,1)}else if(e===200){const i=this.lookU16();n=this.decodeExtension(i,2)}else if(e===201){const i=this.lookU32();n=this.decodeExtension(i,4)}else throw new G(`Unrecognized type byte: ${qe(e)}`);this.complete();const o=this.stack;for(;o.length>0;){const i=o.top();if(i.type===He)if(i.array[i.position]=n,i.position++,i.position===i.size)n=i.array,o.release(i);else continue e;else if(i.type===me){if(n==="__proto__")throw new G("The key __proto__ is not allowed");i.key=this.mapKeyConverter(n),i.type=at;continue e}else if(i.map[i.key]=n,i.readCount++,i.readCount===i.size)n=i.map,o.release(i);else{i.key=null,i.type=me;continue e}}return n}}readHeadByte(){return this.headByte===be&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=be}readArraySize(){const e=this.readHeadByte();switch(e){case 220:return this.readU16();case 221:return this.readU32();default:{if(e<160)return e-144;throw new G(`Unrecognized array type byte: ${qe(e)}`)}}}pushMapState(e){if(e>this.maxMapLength)throw new G(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(e)}pushArrayState(e){if(e>this.maxArrayLength)throw new G(`Max length exceeded: array length (${e}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState(e)}decodeString(e,n){return!this.rawStrings||this.stateIsMapKey()?this.decodeUtf8String(e,n):this.decodeBinary(e,n)}decodeUtf8String(e,n){var s;if(e>this.maxStrLength)throw new G(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+n+e)throw ct;const o=this.pos+n;let i;return this.stateIsMapKey()&&((s=this.keyDecoder)!=null&&s.canBeCached(e))?i=this.keyDecoder.decode(this.bytes,o,e):i=Ft(this.bytes,o,e),this.pos+=n+e,i}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===me:!1}decodeBinary(e,n){if(e>this.maxBinLength)throw new G(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(e+n))throw ct;const o=this.pos+n,i=this.bytes.subarray(o,o+e);return this.pos+=n+e,i}decodeExtension(e,n){if(e>this.maxExtLength)throw new G(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);const o=this.view.getInt8(this.pos+n),i=this.decodeBinary(e,n+1);return this.extensionCodec.decode(i,o,this.context)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){const e=this.view.getUint8(this.pos);return this.pos++,e}readI8(){const e=this.view.getInt8(this.pos);return this.pos++,e}readU16(){const e=this.view.getUint16(this.pos);return this.pos+=2,e}readI16(){const e=this.view.getInt16(this.pos);return this.pos+=2,e}readU32(){const e=this.view.getUint32(this.pos);return this.pos+=4,e}readI32(){const e=this.view.getInt32(this.pos);return this.pos+=4,e}readU64(){const e=Vt(this.view,this.pos);return this.pos+=8,e}readI64(){const e=rt(this.view,this.pos);return this.pos+=8,e}readU64AsBigInt(){const e=this.view.getBigUint64(this.pos);return this.pos+=8,e}readI64AsBigInt(){const e=this.view.getBigInt64(this.pos);return this.pos+=8,e}readF32(){const e=this.view.getFloat32(this.pos);return this.pos+=4,e}readF64(){const e=this.view.getFloat64(this.pos);return this.pos+=8,e}}function wn(t,e){return new Fe(e).decode(t)}const gn=new Set(["auth","open","send","sync","history","read","typing","react","edit","delete","invoke","pubkey","ping","uploadPrekeys","fetchPrekey","assign","tag","note","agent_status","subscribe_inbox","unsubscribe_inbox"]);function yn(t){return gn.has(t.type)}function We(t){return an(t)}function lt(t){let e;try{e=wn(t)}catch{return null}return typeof e!="object"||e===null||typeof e.type!="string"?null:e}class xn{constructor(e){c(this,"conversationId");c(this,"state","");c(this,"version",0);c(this,"hasMoreHistory",!1);c(this,"lastReadByOthers",0);c(this,"assignedAgentId");c(this,"accent");c(this,"subject");c(this,"name");c(this,"e2e",!1);c(this,"offline",!1);c(this,"offlineMessage","");c(this,"launcherMessage",null);c(this,"preChat",null);c(this,"whiteLabel",!1);c(this,"typing",new Set);c(this,"online",new Set);c(this,"sentiment");c(this,"sentimentScore");c(this,"actions",[]);c(this,"byId",new Map);c(this,"keyByClient",new Map);c(this,"_maxSeq",0);c(this,"_sorted",null);this.me=e}messages(){return this._sorted||(this._sorted=[...this.byId.values()].sort((e,n)=>{const o=e.status==="pending",i=n.status==="pending";return o!==i?o?1:-1:o&&i?e.ts-n.ts:e.seq-n.seq})),this._sorted}visibleActions(){return this.actions.filter(e=>!e.availableInStates||e.availableInStates.includes(this.state))}actionById(e){return this.actions.find(n=>n.id===e)}highestSeq(){return this._maxSeq}addOptimistic(e,n){const o={id:e,conversationId:this.conversationId,seq:0,senderId:this.me,senderRole:"guest",content:n,ts:Date.now(),clientMsgId:e,status:"pending"};return this.byId.set(e,o),this.keyByClient.set(e,e),this._sorted=null,o}apply(e){var n;switch(e.type){case"opened":this.conversationId=e.conversation.id,this.state=e.conversation.state,e.subject&&(this.subject=e.subject);return;case"manifest":this.actions=e.actions,this.version=e.version,e.name&&(this.name=e.name),(n=e.theme)!=null&&n.accent&&(this.accent=e.theme.accent),e.e2e&&(this.e2e=!0),this.offline=e.offline===!0,this.offlineMessage=e.offlineMessage??"",e.launcherMessage&&(this.launcherMessage=e.launcherMessage),e.whiteLabel&&(this.whiteLabel=!0),e.preChat&&(this.preChat=e.preChat);return;case"message":this.upsert({...e.message});return;case"ack":{const o=this.keyByClient.get(e.clientMsgId),i=o?this.byId.get(o):void 0;if(i&&o){this.byId.delete(o);const s={...i,id:e.messageId,seq:e.seq,ts:e.ts,status:"sent"};this.byId.set(e.messageId,s),this.keyByClient.set(e.clientMsgId,e.messageId),e.seq>this._maxSeq&&(this._maxSeq=e.seq)}this._sorted=null;return}case"delivered":this.markOwnStatus(e.seq,"delivered");return;case"read":e.by!==this.me&&(this.lastReadByOthers=Math.max(this.lastReadByOthers,e.seq),this.markOwnStatus(e.seq,"read"));return;case"sync":for(const o of e.messages)this.upsert({...o});return;case"history":for(const o of e.messages)this.upsert({...o});this.hasMoreHistory=e.hasMore;return;case"typing":e.userId!==this.me&&(e.isTyping?this.typing.add(e.userId):this.typing.delete(e.userId));return;case"reaction":{const o=this.byId.get(e.messageId);if(!o)return;const i={...o.reactions??{}},s=(i[e.emoji]??[]).filter(r=>r!==e.by);e.removed||s.push(e.by),s.length?i[e.emoji]=s:delete i[e.emoji],this.byId.set(e.messageId,{...o,reactions:i}),this._sorted=null;return}case"edited":{const o=this.byId.get(e.messageId);o&&(this.byId.set(e.messageId,{...o,content:e.content,editedAt:e.editedAt}),this._sorted=null);return}case"deleted":{const o=this.byId.get(e.messageId);o&&(this.byId.set(e.messageId,{...o,deletedAt:e.ts}),this._sorted=null);return}case"state":this.state=e.state;return;case"assigned":this.assignedAgentId=e.agentId??void 0;return;case"presence":e.status==="online"?this.online.add(e.userId):this.online.delete(e.userId);return;case"subjectState":case"invoked":case"authed":case"error":case"pong":return;case"sentiment":this.sentiment=e.label,this.sentimentScore=e.score;return;default:return}}upsert(e){const n=this.byId.get(e.id);this.byId.set(e.id,n?{...n,...e}:e),e.seq>this._maxSeq&&(this._maxSeq=e.seq),this._sorted=null}markOwnStatus(e,n){const o=dt(n);let i=!1;for(const[s,r]of this.byId)r.senderId!==this.me||r.seq<=0||r.seq>e||dt(r.status)>=o||(this.byId.set(s,{...r,status:n}),i=!0);i&&(this._sorted=null)}}function dt(t){switch(t){case"read":return 3;case"delivered":return 2;case"sent":return 1;default:return 0}}class mn{constructor(e){c(this,"socket",null);c(this,"state","idle");c(this,"authed",!1);c(this,"everAuthed",!1);c(this,"attempt",0);c(this,"outbox",[]);c(this,"stopped",!1);c(this,"timer",null);c(this,"refreshing",!1);this.opts=e}connect(){var o,i;if(this.state==="connecting"||this.state==="open")return;this.stopped=!1,this.state="connecting",this.authed=!1,(i=(o=this.opts).onStatusChange)==null||i.call(o,this.attempt>0?"reconnecting":"connecting");const n=(this.opts.socketFactory??kn)(this.opts.url);n.binaryType="arraybuffer",this.socket=n,n.onopen=()=>{this.raw({type:"auth",token:this.opts.token})},n.onmessage=s=>{const r=lt(new Uint8Array(s.data));!r||yn(r)||this.handle(r)},n.onclose=()=>this.onClosed(),n.onerror=()=>{try{n.close()}catch{}}}send(e){if(this.state==="open"&&this.authed){this.raw(e);return}this.queue(e)}pendingCount(){return this.outbox.length}close(){var e;this.stopped=!0,this.timer&&clearTimeout(this.timer),this.state="closed";try{(e=this.socket)==null||e.close()}catch{}}handle(e){var n,o,i,s;if(e.type==="authed"&&(this.attempt=0,this.state="open",this.authed=!0,this.everAuthed=!0,(o=(n=this.opts).onStatusChange)==null||o.call(n,"open"),this.raw(this.opts.open),this.opts.open.type!=="open"&&this.flush()),e.type==="opened"&&(this.raw({type:"sync",conversationId:e.conversation.id,sinceSeq:this.opts.getCursor()}),this.flush(e.conversation.id)),e.type==="error"&&bn.has(e.code)){if(e.code==="UNAUTHORIZED"&&this.opts.refreshToken&&!this.refreshing){this.refreshing=!0,(s=(i=this.opts).onStatusChange)==null||s.call(i,"reconnecting","Renewing session…"),this.opts.refreshToken().then(r=>{var p;if(this.refreshing=!1,!r){this.fatal(e);return}this.opts.token=r;try{(p=this.socket)==null||p.close()}catch{}}).catch(()=>{this.refreshing=!1,this.fatal(e)});return}this.fatal(e);return}this.opts.onFrame(e)}fatal(e){var n,o,i;this.stopped=!0;try{(n=this.socket)==null||n.close()}catch{}this.state="closed",(i=(o=this.opts).onStatusChange)==null||i.call(o,"error",vn(e.code)),this.opts.onFrame(e)}flush(e){const n=this.outbox;this.outbox=[];for(const o of n)this.raw(e&&o.type==="send"&&o.conversationId!==e?{...o,conversationId:e}:o)}queue(e){const n=this.opts.maxOutbox??1e3;this.outbox.length>=n&&(this.outbox=this.outbox.slice(this.outbox.length-(n>>1))),this.outbox.push(e)}raw(e){if(!this.socket){this.queue(e);return}try{this.socket.send(We(e))}catch{this.queue(e)}}onClosed(){var i,s;if(this.authed=!1,this.socket=null,this.stopped){this.state="closed";return}this.state="idle";const e=this.opts.backoffBaseMs??500,n=this.opts.backoffMaxMs??15e3,o=Math.min(n,e*2**this.attempt)*(.5+Math.random()*.5);this.attempt++,this.attempt>=3&&!this.everAuthed&&((s=(i=this.opts).onStatusChange)==null||s.call(i,"reconnecting","Can't reach chat — retrying…")),this.timer=setTimeout(()=>this.connect(),o)}}const bn=new Set(["UNAUTHORIZED"]);function vn(t){switch(t){case"UNAUTHORIZED":return"Chat unavailable — sign-in/token was rejected";default:return"Chat unavailable"}}function kn(t){return new WebSocket(t)}const ht=200,Sn=7*864e5;class In{constructor(e){c(this,"key");this.key=`ocw_outbox_${e}`}load(){try{const e=localStorage.getItem(this.key);if(!e)return[];const n=JSON.parse(e),o=Date.now()-Sn,i=n.filter(s=>s.ts>=o);return i.length!==n.length&&this.save(i),i}catch{return[]}}add(e){try{const n=this.load();n.push(e),this.save(n.length>ht?n.slice(n.length-ht):n)}catch{}}remove(e){try{const n=this.load().filter(o=>o.clientMsgId!==e);this.save(n)}catch{}}save(e){try{localStorage.setItem(this.key,JSON.stringify(e))}catch{}}}const D=()=>globalThis.crypto.subtle;function Ae(t){const e=t instanceof Uint8Array?t:new Uint8Array(t);let n="";for(const o of e)n+=String.fromCharCode(o);return btoa(n)}function Ve(t){const e=atob(t),n=new ArrayBuffer(e.length),o=new Uint8Array(n);for(let i=0;i<e.length;i++)o[i]=e.charCodeAt(i);return o}async function ve(){const t=await D().generateKey({name:"ECDH",namedCurve:"P-256"},!0,["deriveKey","deriveBits"]);return{publicKey:t.publicKey,privateKey:t.privateKey}}async function re(t){return Ae(await D().exportKey("raw",t))}async function ue(t){return D().importKey("raw",Ve(t),{name:"ECDH",namedCurve:"P-256"},!1,[])}async function Cn(t,e){const n=await ue(e);return D().deriveKey({name:"ECDH",public:n},t,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}async function Tn(t,e){const n=globalThis.crypto.getRandomValues(new Uint8Array(12)),o=new TextEncoder().encode(e),i=await D().encrypt({name:"AES-GCM",iv:n},t,o);return{ct:Ae(i),iv:Ae(n)}}async function En(t,e,n){const o=await D().decrypt({name:"AES-GCM",iv:Ve(n)},t,Ve(e));return new TextDecoder().decode(o)}async function Un(t){var n,o;try{const i=(n=globalThis.localStorage)==null?void 0:n.getItem(t);if(i){const{pub:s,priv:r}=JSON.parse(i),p=await D().importKey("jwk",s,{name:"ECDH",namedCurve:"P-256"},!0,[]),a=await D().importKey("jwk",r,{name:"ECDH",namedCurve:"P-256"},!0,["deriveKey","deriveBits"]);return{publicKey:p,privateKey:a}}}catch{}const e=await ve();try{const i=await D().exportKey("jwk",e.publicKey),s=await D().exportKey("jwk",e.privateKey);(o=globalThis.localStorage)==null||o.setItem(t,JSON.stringify({pub:i,priv:s}))}catch{}return e}async function Pn(t,e){const n=await D().exportKey("raw",e),o=await D().sign({name:"ECDSA",hash:"SHA-256"},t,n);return Ae(o)}async function Bn(){const t=await ve(),e=await D().generateKey({name:"ECDSA",namedCurve:"P-256"},!0,["sign","verify"]);return{ecdhKP:t,ecdsaKP:{publicKey:e.publicKey,privateKey:e.privateKey},publicKeyB64:await re(t.publicKey),sigPublicKeyB64:await re(e.publicKey)}}async function pt(t){var n,o;try{const i=(n=globalThis.localStorage)==null?void 0:n.getItem(`${t}-identity`);if(i){const s=JSON.parse(i),r=await D().importKey("jwk",s.ecdhPub,{name:"ECDH",namedCurve:"P-256"},!0,[]),p=await D().importKey("jwk",s.ecdhPriv,{name:"ECDH",namedCurve:"P-256"},!0,["deriveKey","deriveBits"]),a=await D().importKey("jwk",s.ecdsaPub,{name:"ECDSA",namedCurve:"P-256"},!0,["verify"]),w=await D().importKey("jwk",s.ecdsaPriv,{name:"ECDSA",namedCurve:"P-256"},!0,["sign"]);return{ecdhKP:{publicKey:r,privateKey:p},ecdsaKP:{publicKey:a,privateKey:w},publicKeyB64:await re(r),sigPublicKeyB64:await re(a)}}}catch{}const e=await Bn();try{const i=await D().exportKey("jwk",e.ecdhKP.publicKey),s=await D().exportKey("jwk",e.ecdhKP.privateKey),r=await D().exportKey("jwk",e.ecdsaKP.publicKey),p=await D().exportKey("jwk",e.ecdsaKP.privateKey);(o=globalThis.localStorage)==null||o.setItem(`${t}-identity`,JSON.stringify({ecdhPub:i,ecdhPriv:s,ecdsaPub:r,ecdsaPriv:p}))}catch{}return e}async function An(t,e){const n=await ve(),o=await re(n.publicKey),i=await ue(e.identityKey),s=await ue(e.signedPrekey),r=e.oneTimePrekey?await ue(e.oneTimePrekey):null,p=await ae(t.privateKey,s),a=await ae(n.privateKey,i),w=await ae(n.privateKey,s),f=r?await ae(n.privateKey,r):null,h=ut(p,a,w,...f?[f]:[]);return{sharedKey:await ft(h),ephemeralPublicKey:o}}async function Ln(t,e,n,o,i){const s=await ue(n),r=await ue(o),p=await ae(e.privateKey,s),a=await ae(t.privateKey,r),w=await ae(e.privateKey,r),f=i?await ae(i.privateKey,r):null,h=ut(p,a,w,...f?[f]:[]);return ft(h)}async function ae(t,e){return D().deriveBits({name:"ECDH",public:e},t,256)}function ut(...t){const e=t.reduce((i,s)=>i+s.byteLength,0),n=new Uint8Array(e);let o=0;for(const i of t)n.set(new Uint8Array(i),o),o+=i.byteLength;return n.buffer}async function ft(t){const e=await D().importKey("raw",t,"HKDF",!1,["deriveKey"]);return D().deriveKey({name:"HKDF",hash:"SHA-256",salt:new Uint8Array(32),info:new TextEncoder().encode("ObjectChat X3DH v1")},e,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}const Mn=20;class zn{constructor(e){c(this,"kp");c(this,"shared");c(this,"identityKP");c(this,"signedPreKP");c(this,"signedPrekeyId");c(this,"otpKeys",[]);c(this,"x3dhShared");c(this,"pendingX3DH");this.storageKey=e}get ready(){return!!(this.shared??this.x3dhShared)}async begin(){return this.kp=await Un(this.storageKey),re(this.kp.publicKey)}async onPeerKey(e){this.kp&&(this.shared=await Cn(this.kp.privateKey,e))}async initX3DH(){this.identityKP=await pt(this.storageKey),this.signedPreKP=await ve(),this.signedPrekeyId=`spk-${Date.now()}-${Math.random().toString(36).slice(2)}`;for(let i=0;i<Mn;i++)this.otpKeys.push(await ve());const e=await re(this.signedPreKP.publicKey),n=await Pn(this.identityKP.ecdsaKP.privateKey,this.signedPreKP.publicKey),o=await Promise.all(this.otpKeys.map(i=>re(i.publicKey)));return{identityKey:this.identityKP.publicKeyB64,signedPrekey:e,signedPrekeyId:this.signedPrekeyId,signature:n,oneTimePrekeys:o}}async x3dhSendTo(e){this.identityKP||(this.identityKP=await pt(this.storageKey));const{sharedKey:n,ephemeralPublicKey:o}=await An(this.identityKP.ecdhKP,e);return this.x3dhShared=n,{ephemeralKey:o,spkId:e.signedPrekeyId,usedOTP:!!e.oneTimePrekey,senderIK:this.identityKP.publicKeyB64}}async x3dhReceiveFrom(e,n,o,i){if(!this.identityKP||!this.signedPreKP){this.pendingX3DH={senderIK:e,ephemeralKey:n,spkId:o,usedOTP:i};return}const s=i?this.otpKeys.shift():void 0;this.x3dhShared=await Ln(this.identityKP.ecdhKP,this.signedPreKP,e,n,s)}async flushPendingX3DH(){if(!this.pendingX3DH)return;const{senderIK:e,ephemeralKey:n,spkId:o,usedOTP:i}=this.pendingX3DH;this.pendingX3DH=void 0,await this.x3dhReceiveFrom(e,n,o,i)}async sealText(e,n){const o=this.x3dhShared??this.shared;if(!o)throw new Error("secure channel not ready");const{ct:i,iv:s}=await Tn(o,e);return{kind:"text",text:i,enc:!0,iv:s,...n?{x3dhEK:n.ephemeralKey,x3dhSPK:n.spkId,x3dhIK:n.senderIK,x3dhOTP:n.usedOTP}:{}}}async openContent(e){if(e.kind!=="text"||!e.enc||!e.iv)return e;const n=this.x3dhShared??this.shared;if(!n)return{kind:"text",text:"🔒 encrypted"};try{return{kind:"text",text:await En(n,e.text,e.iv)}}catch{return{kind:"text",text:"🔒 unable to decrypt"}}}async openFrame(e){if(e.type==="message")e.message.content=await this.openContent(e.message.content);else if(e.type==="sync")for(const n of e.messages)n.content=await this.openContent(n.content)}}function Kn(t){if(t.kind!=="text"||!t.enc)return null;const e=t;return!e.x3dhEK||!e.x3dhSPK||!e.x3dhIK?null:{x3dhEK:e.x3dhEK,x3dhSPK:e.x3dhSPK,x3dhIK:e.x3dhIK,x3dhOTP:e.x3dhOTP??!1}}const $n={accent:"#6c5ce7",accent2:"#4c6fff",bg:"#f4f3fb",card:"#fff",tint:"#eeecfb",line:"#e6e2f5",ink:"#221d3a",mut:"#8f8aa8",onaccent:"#fff",rowhover:"#e7e3f8",shadow:"0 12px 32px rgba(108,92,231,.14)"},Rn={accent:"#a99cf2",accent2:"#6f8cff",bg:"#221d3a",card:"#2b2550",tint:"#2f2853",line:"#3a3363",ink:"#eceafc",mut:"#9b93c9",onaccent:"#221d3a",rowhover:"#39325e",shadow:"0 12px 32px rgba(0,0,0,.4)"},Dn="'Nunito',-apple-system,BlinkMacSystemFont,'Segoe UI',system-ui,sans-serif";function wt(t,e){return Object.entries(e).map(([n,o])=>`--${t}-${n}:${o};`).join(" ")}function gt(t){return`${wt(t,$n)} --${t}-fb:${Dn}; --${t}-fh:'Baloo 2',var(--${t}-fb);`}function Le(t){return wt(t,Rn)}const _n=`
2
2
  .ocw { ${gt("ocw")}
3
3
  position:relative;
4
4
  display:flex; flex-direction:column; height:100%; min-height:320px; background:var(--ocw-bg);
@@ -184,12 +184,11 @@ var RelayEmbed=function(te){"use strict";var fi=Object.defineProperty;var wi=(te
184
184
  .ocw-sendbtn:disabled { opacity:.5; cursor:default; }
185
185
  .ocw-sendbtn:focus-visible, .ocw-back:focus-visible, .ocw-chip:focus-visible { outline:2px solid var(--ocw-accent); outline-offset:2px; }
186
186
 
187
- .ocw-translate-btn { position:absolute; bottom:2px; right:-26px; background:var(--ocw-card); border:1px solid var(--ocw-line); border-radius:50%; width:22px; height:22px; font-size:11px; cursor:pointer; color:var(--ocw-mut); display:flex; align-items:center; justify-content:center; opacity:0; transition:opacity .15s; padding:0; }
188
- .ocw-row.theirs .ocw-translate-btn { right:auto; left:-26px; }
189
- .ocw-bubble-wrap:hover .ocw-translate-btn { opacity:1; }
187
+ .ocw-translate-btn { display:inline-flex; align-items:center; gap:4px; margin-top:3px; background:none; border:none; padding:2px 0; font-size:11px; line-height:1; cursor:pointer; color:var(--ocw-mut); opacity:.85; }
188
+ .ocw-translate-btn:hover { opacity:1; text-decoration:underline; }
190
189
  .ocw-translation { margin-top:6px; padding-top:6px; border-top:1px solid var(--ocw-line); font-size:13px; line-height:1.45; }
191
190
  .ocw-translation::before { content:'🌐 '; opacity:.75; }
192
- `,yt="objectchat-widget-styles",jn=["👍","❤️","😂","😮","😢","🙏"],Nn=400,qn='<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path d="M22 2 11 13M22 2l-7 20-4-9-9-4 20-7z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>';function Hn(){if(typeof document>"u"||document.getElementById(yt))return;const t=document.createElement("style");t.id=yt,t.textContent=_n,document.head.appendChild(t)}const xt="ocw-webfont";function On(){if(typeof document>"u"||document.getElementById(xt))return;const t=document.createElement("link");t.id=xt,t.rel="stylesheet",t.href="https://fonts.googleapis.com/css2?family=Baloo+2:wght@500;600;700&family=Nunito:wght@400;500;600;700&display=swap",document.head.appendChild(t)}function l(t,e,n){const o=document.createElement(t);return e&&(o.className=e),n!==void 0&&(o.textContent=n),o}function Fn(t,e){const n=/(https?:\/\/[^\s]+)/g;let o=0,i=null,s;for(;(s=n.exec(e))!==null;){if(s.index>o){const h=document.createTextNode(e.slice(o,s.index));t.append(h),i??(i=h)}let p=s[0],a="";const w=/[).,!?;:]+$/.exec(p);w&&(a=w[0],p=p.slice(0,-a.length));const f=document.createElement("a");f.href=p,f.target="_blank",f.rel="noopener noreferrer",f.textContent=p,f.style.cssText="color:inherit;text-decoration:underline;word-break:break-all",t.append(f),a&&t.append(document.createTextNode(a)),o=s.index+s[0].length}const r=document.createTextNode(e.slice(o));return t.append(r),i??(i=r),i}function Wn(t){try{return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}}function Xe(t){var e;switch(t.kind){case"text":return t.text;case"system":return typeof((e=t.data)==null?void 0:e.message)=="string"?String(t.data.message):t.event;case"card":return[t.title,t.body].filter(Boolean).join(" — ");case"attachment":return t.name??t.url;case"form":return t.prompt;case"appointment":return`📅 ${t.title} — ${new Date(t.startIso).toLocaleString()}`}}class Vn{constructor(e,n,o,i={}){c(this,"scroll");c(this,"chips");c(this,"typing");c(this,"quick");c(this,"formHost");c(this,"csatPanel");c(this,"awayNotice");c(this,"headStatus");c(this,"reopenBtn");c(this,"preChatPanel");c(this,"deflectPanel");c(this,"preChatBuilt",!1);c(this,"preChatDone",!1);c(this,"footer");c(this,"input");c(this,"subjectCard");c(this,"e2eBadge");c(this,"statusBadge");c(this,"headerName");c(this,"connStatus");c(this,"typingTimer",null);c(this,"csatSubmitted",!1);c(this,"sendBtn");c(this,"compactObserver",null);c(this,"storeRef",null);c(this,"cfgAccent2");c(this,"scrollCleanup",null);c(this,"translationCache",new Map);c(this,"showingTranslation",new Set);c(this,"subjectBuilt",!1);var _,F,U,Z,B,g,u,b,m,C,T;this.root=e,this.me=n,this.h=o,this.cfg=i,Hn(),i.webfont!==!1&&On(),e.replaceChildren(),e.classList.add("ocw"),i.accent&&e.style.setProperty("--ocw-accent",i.accent);const s=i.accent2??i.accent;s&&e.style.setProperty("--ocw-accent2",s),this.cfgAccent2=i.accent2,e.dataset.theme=i.theme??"light";const r=l("div","ocw-head");if(this.h.onBack){const v=l("button","ocw-back","‹");v.type="button",v.setAttribute("aria-label","Back"),v.addEventListener("click",()=>this.h.onBack()),r.append(v)}const p=((_=i.subject)==null?void 0:_.ownerLabel)??((F=i.subject)==null?void 0:F.title)??"",a=l("div","ocw-avatar");p.trim()&&(a.textContent=p.trim()[0].toUpperCase(),r.append(a));const w=l("div","ocw-head-main");this.headerName=l("div","ocw-head-name",((U=i.subject)==null?void 0:U.ownerLabel)??((Z=i.subject)==null?void 0:Z.title)??""),w.append(this.headerName),this.headStatus=l("div","ocw-head-status"),this.headStatus.style.display="none",w.append(this.headStatus),(B=i.subject)!=null&&B.subtitle&&w.append(l("div","ocw-head-meta",i.subject.subtitle)),r.append(w),this.statusBadge=l("span","ocw-badge",((g=i.subject)==null?void 0:g.status)??""),(u=i.subject)!=null&&u.status||(this.statusBadge.style.display="none"),r.append(this.statusBadge),this.e2eBadge=l("span","ocw-e2e","🔒 E2E"),this.e2eBadge.style.display="none",r.append(this.e2eBadge),this.connStatus=l("span","ocw-conn-status"),this.connStatus.style.display="none",r.append(this.connStatus),r.append(l("button","ocw-menu","⋯")),this.chips=l("div","ocw-chiprow"),this.scroll=l("div","ocw-scroll"),this.subjectCard=l("div","ocw-subject"),this.typing=l("div","ocw-typing");const f=l("div","ocw-typing-bubble");f.append(l("div","ocw-typing-dot"),l("div","ocw-typing-dot"),l("div","ocw-typing-dot")),this.typing.append(f),this.quick=l("div","ocw-quick");for(const v of i.quickReplies??[]){const P=l("button",void 0,v);P.addEventListener("click",()=>{this.h.onSend(v),this.quick.style.display="none"}),this.quick.append(P)}this.formHost=l("div","ocw-form-host"),this.csatPanel=l("div","ocw-csat"),this.csatPanel.style.display="none",this.awayNotice=l("div","ocw-away"),this.awayNotice.style.display="none",this.preChatPanel=l("div","ocw-prechat"),this.preChatPanel.style.display="none",this.deflectPanel=l("div","ocw-deflect"),this.deflectPanel.style.display="none",this.input=l("textarea",void 0),this.input.rows=1,this.input.placeholder=((b=i.i18n)==null?void 0:b.placeholder)??"Message…";const h=l("button","ocw-sendbtn");h.type="button";const y=(m=i.i18n)==null?void 0:m.send;y?(h.textContent=y,h.classList.add("ocw-sendbtn-label"),h.setAttribute("aria-label",y)):(h.innerHTML=qn,h.setAttribute("aria-label","Send message")),h.disabled=!0,this.sendBtn=h,h.addEventListener("click",()=>this.flushSend()),this.input.addEventListener("input",()=>{var v,P;this.sendBtn.disabled=this.input.value.trim().length===0,this.autoGrowInput(),this.storeRef&&!this.storeRef.messages().some(A=>A.senderRole==="guest")?(P=(v=this.h).onDeflectQuery)==null||P.call(v,this.input.value):this.hideDeflection()}),this.input.addEventListener("keydown",v=>{v.isComposing||v.keyCode===229||(v.key==="Enter"&&!v.shiftKey?(v.preventDefault(),this.flushSend()):this.signalTyping())});const S=l("button","ocw-attach","📎");S.title="Attach image or file";const E=document.createElement("input");E.type="file",E.accept="image/*,.pdf,.txt,.doc,.docx",E.style.display="none",S.addEventListener("click",()=>E.click()),E.addEventListener("change",()=>{var v;(v=E.files)!=null&&v[0]&&this.h.onAttach&&this.h.onAttach(E.files[0]),E.value=""});const z=l("div","ocw-input");z.append(S,E,this.input,h);const K=l("div","ocw-footer");((C=i.i18n)==null?void 0:C.poweredBy)!==void 0?K.textContent=i.i18n.poweredBy:K.innerHTML='Powered by <a href="https://relay.paramms.com" target="_blank" rel="noopener">Relay</a>',this.footer=K,this.reopenBtn=l("button","ocw-reopen",((T=this.cfg.i18n)==null?void 0:T.reopen)??"Reopen conversation"),this.reopenBtn.type="button",this.reopenBtn.addEventListener("click",()=>{this.reopenBtn.style.display="none";const v=this.root.querySelector(".ocw-input textarea");v==null||v.focus()}),e.append(r,this.chips,this.scroll,this.typing,this.quick,this.formHost,this.csatPanel,this.preChatPanel,this.deflectPanel,this.awayNotice,z,this.reopenBtn,this.footer);const $=v=>{e.classList.toggle("ocw-compact",v>0&&v<Nn)};$(e.clientWidth),typeof ResizeObserver<"u"&&(this.compactObserver=new ResizeObserver(v=>{var A;const P=((A=v[0])==null?void 0:A.contentRect.width)??e.clientWidth;$(P)}),this.compactObserver.observe(e))}getScrollEl(){return this.scroll}setScrollCleanup(e){var n;(n=this.scrollCleanup)==null||n.call(this),this.scrollCleanup=e}destroy(){var e,n;(e=this.scrollCleanup)==null||e.call(this),this.scrollCleanup=null,this.typingTimer&&(clearTimeout(this.typingTimer),this.typingTimer=null),(n=this.compactObserver)==null||n.disconnect(),this.compactObserver=null}flushSend(){this.hideDeflection();const e=this.input.value.trim();e&&(this.input.value="",this.sendBtn.disabled=!0,this.autoGrowInput(),this.h.onTyping(!1),this.h.onSend(e))}autoGrowInput(){this.input.style.height="auto";const e=this.input.scrollHeight;e>0?this.input.style.height=`${Math.min(e,120)}px`:this.input.style.removeProperty("height")}signalTyping(){const e=this.input.value.trim().slice(0,100)||void 0;this.h.onTyping(!0,e),this.typingTimer&&clearTimeout(this.typingTimer),this.typingTimer=setTimeout(()=>this.h.onTyping(!1),2e3)}setBotName(e){this.cfg.i18n={...this.cfg.i18n??{},aiAssistant:e}}render(e){var E,z,K,$,_,F,U,Z;if(this.storeRef=e,e.accent&&(this.root.style.setProperty("--ocw-accent",e.accent),this.root.style.setProperty("--ocw-accent2",this.cfgAccent2??e.accent)),this.e2eBadge.style.display=e.e2e?"inline-flex":"none",this.buildSubjectCard(e),e.subject){const B=(E=this.cfg.subject)==null?void 0:E.ownerLabel;B&&(this.headerName.textContent=B)}this.quick.style.display=e.messages().length===0?"flex":"none",this.chips.replaceChildren();const n=e.visibleActions();this.chips.style.display=n.length?"flex":"none";for(const B of n)this.chips.append(this.chipEl(B));const o=this.scroll.scrollHeight,i=this.scroll.scrollTop;if(this.scroll.replaceChildren(),this.subjectCard.childNodes.length&&this.scroll.append(this.subjectCard),e.hasMoreHistory){const B=l("div","ocw-load-more");B.textContent="↑ Loading earlier messages…",B.style.pointerEvents="none",this.scroll.append(B)}let s=0,r=null;const p=[...e.messages()];for(let B=0;B<p.length;B++){const g=p[B],u=g.senderRole!=="system"&&g.senderId!==this.me&&!g.internal&&g.senderId!==r;this.scroll.append(this.messageEl(g,e,u,B===p.length-1)),g.senderRole!=="system"&&(r=g.senderId),g.senderId!==this.me&&g.seq>s&&(s=g.seq)}i>20?this.scroll.scrollTop=this.scroll.scrollHeight-o+i:this.scroll.scrollTop=this.scroll.scrollHeight,s>0&&this.h.onReadUpTo(s);const a=[...e.typing];this.typing.classList.toggle("active",a.length>0);const w=this.typing.querySelector(".ocw-typing-bubble");w&&w.setAttribute("aria-label",a.length?"typing":""),this.footer.style.display=e.whiteLabel?"none":"block";const f=e.messages().some(B=>B.senderRole==="guest");if(!!((z=e.preChat)!=null&&z.enabled)&&!this.preChatDone&&!f&&(e.preChat.showWhen!=="offline"||e.offline))this.preChatBuilt||this.buildPreChatPanel(e.preChat),this.preChatPanel.style.display="block",this.awayNotice.style.display="none",(K=this.root.querySelector(".ocw-input"))==null||K.style.setProperty("display","none");else{if(this.preChatPanel.style.display="none",e.offline){this.awayNotice.firstChild||this.awayNotice.append(l("span","ocw-away-icon","🌙"),l("span","",""));const B=this.awayNotice.lastChild;B.textContent=e.offlineMessage||(($=this.cfg.i18n)==null?void 0:$.offline)||"We're away right now — send your message and we'll reply as soon as we're back.",this.awayNotice.style.display="flex"}else this.awayNotice.style.display="none";(_=this.root.querySelector(".ocw-input"))==null||_.style.removeProperty("display")}const y=["resolved","closed","sold","issued","checked_out"];this.h.onCsat&&!this.csatSubmitted&&y.includes(e.state)&&e.messages().length>0&&(this.csatPanel.style.display==="none"&&this.buildCsatPanel(),this.csatPanel.style.display="block");const S=y.includes(e.state);if(e.offline?(this.headStatus.textContent=`● ${e.offlineMessage||((F=this.cfg.i18n)==null?void 0:F.away)||"Away"}`,this.headStatus.className="ocw-head-status away",this.headStatus.style.display=""):e.conversationId?(this.headStatus.textContent=`● ${((U=this.cfg.i18n)==null?void 0:U.online)??"Online"}`,this.headStatus.className="ocw-head-status online",this.headStatus.style.display=""):this.headStatus.style.display="none",S&&e.messages().length>0){const B=l("div","ocw-resolved-note",`— ${((Z=this.cfg.i18n)==null?void 0:Z.resolved)??"Marked as resolved"} —`);this.scroll.append(B),this.reopenBtn.style.display="block"}else this.reopenBtn.style.display="none"}setConnStatus(e,n){if(e==="open"){this.connStatus.style.display="none";return}this.connStatus.style.display="";const o=e==="error";this.connStatus.className=`ocw-conn-status${o?" err":e==="reconnecting"?" warn":""}`,this.connStatus.textContent=o?`⚠ ${n??"Chat unavailable"}`:e==="reconnecting"?n??"↻ reconnecting…":"● connecting…"}buildPreChatPanel(e){var a;this.preChatBuilt=!0,this.preChatPanel.replaceChildren(),this.preChatPanel.append(l("div","ocw-prechat-title",e.title??"Before we start…"));const n=l("div","ocw-offline-form"),o={};for(const w of e.fields??["name","email"]){const f=l("input","ocw-offline-input");f.type=w==="email"?"email":w==="phone"?"tel":"text",f.placeholder=w==="name"?"Your name":w==="email"?"Your email":"Your phone number",o[w]=f,n.append(f)}let i=null;if((a=e.topics)!=null&&a.length){i=l("select",void 0);const w=document.createElement("option");w.value="",w.textContent="What is this about?",i.append(w);for(const f of e.topics){const h=document.createElement("option");h.value=f,h.textContent=f,i.append(h)}n.append(i)}let s=null,r=null;if(e.callbackOption){const w=l("label","ocw-prechat-cb");s=document.createElement("input"),s.type="checkbox",w.append(s,document.createTextNode("📞 Request a call back")),n.append(w),o.phone||(r=l("input","ocw-offline-input"),r.type="tel",r.placeholder="Phone number for the call",r.style.display="none",s.addEventListener("change",()=>r.style.setProperty("display",s.checked?"block":"none")),n.append(r))}const p=l("button","ocw-offline-submit","Start chat");p.type="button",p.addEventListener("click",()=>{var y,S,E,z,K,$,_;const w=(y=o.email)==null?void 0:y.value.trim();if(o.email&&(!w||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(w))){o.email.focus();return}const f=!!(s!=null&&s.checked),h=(((S=o.phone)==null?void 0:S.value)??(r==null?void 0:r.value)??"").trim();if(f&&!h){(E=o.phone??r)==null||E.focus();return}if(i&&((z=e.topics)!=null&&z.length)&&!i.value){i.focus();return}p.disabled=!0,this.completePreChat(),(_=($=this.h).onPreChat)==null||_.call($,{...(K=o.name)!=null&&K.value.trim()?{name:o.name.value.trim()}:{},...w?{email:w}:{},...h?{phone:h}:{},...i!=null&&i.value?{topic:i.value}:{},...f?{callback:!0}:{}})}),n.append(p),this.preChatPanel.append(n)}completePreChat(){this.preChatDone=!0,this.preChatPanel.style.display="none",this.storeRef&&this.render(this.storeRef)}showDeflection(e){if(!e.length)return this.hideDeflection();this.deflectPanel.replaceChildren(),this.deflectPanel.append(l("div","ocw-deflect-hint","Instant answers — tap to expand"));for(const n of e.slice(0,3)){const o=l("button","ocw-deflect-card");o.append(l("div","ocw-deflect-q",n.title),l("div","ocw-deflect-a",n.answer)),o.addEventListener("click",()=>o.classList.toggle("open")),this.deflectPanel.append(o)}this.deflectPanel.style.display="flex"}hideDeflection(){this.deflectPanel.style.display="none",this.deflectPanel.replaceChildren()}buildCsatPanel(){this.csatPanel.replaceChildren(),this.csatPanel.append(l("div","ocw-csat-title","How did we do?"));const e=l("div","ocw-csat-stars"),n=[];for(let o=1;o<=5;o++){const i=l("button","ocw-csat-star","★");i.dataset.score=String(o),i.addEventListener("mouseenter",()=>n.forEach((s,r)=>s.classList.toggle("lit",r<o))),i.addEventListener("mouseleave",()=>n.forEach(s=>s.classList.remove("lit"))),i.addEventListener("click",()=>{var s,r;this.csatSubmitted=!0,this.csatPanel.replaceChildren(l("div","ocw-csat-done",`Thanks for your ${o}★ rating!`)),(r=(s=this.h).onCsat)==null||r.call(s,o)}),n.push(i),e.append(i)}this.csatPanel.append(e)}buildSubjectCard(e){if(this.subjectBuilt)return;const n=e.subject,o=this.cfg.subject,i=(n==null?void 0:n.title)??(o==null?void 0:o.title);if(!i)return;this.subjectBuilt=!0,this.subjectCard.replaceChildren(),this.subjectCard.append(l("div","ocw-subject-title",i)),o!=null&&o.subtitle&&this.subjectCard.append(l("div","ocw-subject-sub",o.subtitle));const s=l("div","ocw-tags");if(n)for(const[p,a]of Object.entries(n.fields))s.append(l("span","ocw-tag",`${p}: ${a}`));else for(const p of(o==null?void 0:o.tags)??[])s.append(l("span","ocw-tag",p));s.childNodes.length&&this.subjectCard.append(s);const r=(n==null?void 0:n.state)??(o==null?void 0:o.status);r&&(this.statusBadge.textContent=r,this.statusBadge.style.display="inline-flex")}chipEl(e){const n=l("button","ocw-chip",e.icon?`${e.icon} ${e.label}`:e.label);return n.dataset.actionId=e.id,n.addEventListener("click",async()=>{var o;e.confirm&&!await this.confirm(e.label)||((o=e.input)!=null&&o.length?this.openForm(e):this.h.onInvoke(e.id))}),n}confirm(e){return new Promise(n=>{const o=l("div","ocw-modal"),i=l("div","ocw-modal-card");i.append(l("div","ocw-modal-title",e)),i.append(l("div","ocw-modal-body",`Confirm “${e}”?`));const s=l("div","ocw-modal-actions"),r=l("button","ocw-modal-cancel","Cancel"),p=l("button","ocw-modal-ok","Confirm"),a=w=>{o.remove(),n(w)};r.addEventListener("click",()=>a(!1)),p.addEventListener("click",()=>a(!0)),o.addEventListener("click",w=>{w.target===o&&a(!1)}),s.append(r,p),i.append(s),o.append(i),this.root.append(o),p.focus()})}openForm(e,n){var a,w;this.formHost.replaceChildren();const o=l("div","ocw-form");o.append(l("div","ocw-form-title",e.icon?`${e.icon} ${e.label}`:e.label));const i=new Map;for(const f of e.input??[]){const h=n==null?void 0:n[f.name],y=l("label","ocw-form-row");if(y.append(l("span","ocw-form-lbl",f.label)),f.type==="select"&&((a=f.options)!=null&&a.length)){const S=l("select","ocw-form-input");f.required||S.append(l("option",void 0,"— select —"));for(const E of f.options){const z=l("option");z.value=E,z.textContent=E,S.append(z)}f.required&&(S.required=!0),h!=null&&f.options.includes(h)&&(S.value=h),y.append(S),i.set(f.name,S)}else{const S=l("input","ocw-form-input");S.type=f.type==="number"?"number":f.type==="date"?"datetime-local":"text",f.required&&(S.required=!0),h!=null&&h!==""&&(S.value=h),y.append(S),i.set(f.name,S)}o.append(y)}const s=l("div","ocw-form-actions"),r=l("button","ocw-form-cancel","Cancel"),p=l("button","ocw-form-submit","Send");r.addEventListener("click",()=>this.formHost.replaceChildren()),p.addEventListener("click",()=>{const f={};for(const[h,y]of i){if(y.required&&!y.value){y.style.borderColor="#e5484d";return}f[h]=y.type==="number"?Number(y.value):y.value}this.formHost.replaceChildren(),this.h.onInvoke(e.id,f)}),s.append(r,p),o.append(s),this.formHost.append(o),(w=i.values().next().value)==null||w.focus()}messageEl(e,n,o=!1,i=!1){var S,E,z,K,$,_,F,U,Z,B;if(e.senderRole==="system"){const g=l("div","ocw-sys");return g.textContent=e.deletedAt?"message deleted":Xe(e.content),g}const s=e.senderId===this.me,r=!!e.internal,p=l("div",`ocw-row ${r?"ocw-note mine":s?"mine":"theirs"} ${e.senderRole==="bot"?"ocw-bot":""}`),a=l("div");if(o){const g=e.senderRole==="bot"?((S=this.cfg.i18n)==null?void 0:S.aiAssistant)??"AI Assistant":((E=this.cfg.subject)==null?void 0:E.ownerLabel)??((z=this.cfg.subject)==null?void 0:z.title)??"Support";a.append(l("div","ocw-msg-sender",g))}const w=l("div","ocw-bubble-wrap");if(e.replyToId){const g=l("div","ocw-reply-to","↩ replying to a message");g.style.cssText="font-size:11px;color:var(--ocw-mut);margin-bottom:2px;font-style:italic",a.append(g)}const f=l("div","ocw-bubble");let h=null;if(e.deletedAt)f.append(l("span","ocw-deleted","message deleted"));else if(e.content.kind==="attachment"){const g=e.content;if((K=g.mime)!=null&&K.startsWith("image/")){const u=document.createElement("img");u.src=g.url,u.alt=g.name??"image",u.style.cssText="max-width:220px;max-height:160px;border-radius:10px;display:block;cursor:pointer",u.addEventListener("click",()=>window.open(g.url,"_blank")),f.append(u)}else if(($=g.mime)!=null&&$.startsWith("video/")){const u=document.createElement("video");u.src=g.url,u.controls=!0,u.style.cssText="max-width:240px;max-height:180px;border-radius:10px;display:block",f.append(u)}else{const u=document.createElement("a");u.href=g.url,u.target="_blank",u.rel="noopener",u.style.cssText="display:flex;align-items:center;gap:8px;color:inherit;text-decoration:none",u.append(l("span",void 0,"📄"),l("span",void 0,g.name??"file")),f.append(u)}}else if(e.content.kind==="appointment"){const g=e.content,u=l("div","ocw-appt");u.append(l("div","ocw-appt-title",`📅 ${g.title}`)),u.append(l("div","ocw-appt-time",new Date(g.startIso).toLocaleString()+" – "+new Date(g.endIso).toLocaleTimeString())),g.location&&u.append(l("div","ocw-appt-loc",`📍 ${g.location}`)),g.description&&u.append(l("div","ocw-appt-desc",g.description));const b=l("div","ocw-appt-links"),m=document.createElement("a");m.href=g.googleUrl,m.target="_blank",m.rel="noopener",m.className="ocw-appt-btn",m.textContent="📅 Add to Google Calendar";const C=document.createElement("a");C.href=g.icalUrl,C.download=`${g.title}.ics`,C.className="ocw-appt-btn ocw-appt-btn-sec",C.textContent="🍎 Apple / iCal",b.append(m,C),u.append(b),f.append(u)}else h=Fn(f,Xe(e.content)),e.editedAt&&f.append(l("span","ocw-edited","(edited)"));if(w.append(f),i&&!e.deletedAt&&e.content.kind==="text"&&((_=e.content.quickReplies)!=null&&_.length)){const g=l("div","ocw-flow-choices");g.style.cssText="display:flex;flex-wrap:wrap;gap:6px;margin-top:6px";for(const u of e.content.quickReplies){const b=l("button","ocw-flow-choice",u);b.type="button",b.style.cssText="border:1px solid var(--ocw-bd,rgba(0,0,0,.12));background:var(--ocw-bg,#fff);color:inherit;border-radius:14px;padding:5px 12px;font:inherit;font-size:13px;cursor:pointer",b.addEventListener("click",()=>{g.querySelectorAll("button").forEach(m=>m.disabled=!0),g.style.opacity="0.5",this.h.onSend(u)}),g.append(b)}w.append(g)}if(i&&!e.deletedAt&&e.content.kind==="form"){const g=e.content,u=n.actionById(g.actionId);if((F=u==null?void 0:u.input)!=null&&F.length){const b=l("button","ocw-chip",u.icon?`${u.icon} ${u.label}`:u.label);b.type="button",b.style.cssText="margin-top:6px",b.addEventListener("click",async()=>{u.confirm&&!await this.confirm(u.label)||this.openForm(u,g.prefill)}),w.append(b)}}if(!s&&!r&&this.h.onTranslate&&e.content.kind==="text"&&!e.deletedAt&&e.seq>0&&h){const g=e.content.text;if(g.trim()){const u=l("button","ocw-translate-btn","🌐");u.type="button",u.title="Translate";const b=l("div","ocw-translation");b.style.display="none",f.append(b);const m=v=>{b.textContent=v,b.style.display="",this.showingTranslation.add(e.id),u.textContent="↩",u.title="Show original"},C=()=>{b.style.display="none",this.showingTranslation.delete(e.id),u.textContent="🌐",u.title="Translate"};u.addEventListener("click",v=>{if(v.stopPropagation(),this.showingTranslation.has(e.id)){C();return}const P=this.translationCache.get(e.id);if(P!==void 0){m(P);return}u.textContent="⏳",this.h.onTranslate(g).then(A=>{if(A===null){u.textContent="⚠️",u.title="Translation unavailable",setTimeout(()=>{u.textContent="🌐",u.title="Translate"},1500);return}this.translationCache.set(e.id,A),m(A)})}),w.append(u);const T=this.translationCache.get(e.id);this.showingTranslation.has(e.id)&&T!==void 0&&m(T)}}if(s&&!e.deletedAt&&e.seq>0&&(this.h.onEdit??this.h.onDelete)){const g=l("div","ocw-msg-menu");if(this.h.onEdit){const u=l("button",void 0,"✏️");u.title="Edit",u.addEventListener("click",b=>{b.stopPropagation();const m=Xe(e.content),C=document.createElement("textarea");C.value=m,C.rows=Math.min(4,Math.ceil(m.length/40)+1),C.style.cssText="width:100%;resize:vertical;border:1px solid var(--ocw-accent);border-radius:8px;padding:6px 10px;font:inherit;font-size:14px;background:var(--ocw-card);color:#1c1b1a;box-sizing:border-box";const T=l("button","ocw-form-submit","Save");T.style.cssText="margin-top:6px;padding:5px 14px;font-size:13px";const v=l("button","ocw-form-cancel","Cancel");v.style.cssText="margin-top:6px;padding:5px 10px;font-size:13px";const P=l("div");P.style.cssText="display:flex;gap:6px;justify-content:flex-end",P.append(v,T);const A=l("div");A.append(C,P),f.replaceChildren(A),C.focus(),C.select();const Q=()=>f.replaceChildren(h??document.createTextNode(m));v.addEventListener("click",Q),T.addEventListener("click",()=>{const W=C.value.trim();W&&W!==m&&this.h.onEdit(e.id,W),Q()}),C.addEventListener("keydown",W=>{W.key==="Enter"&&!W.shiftKey&&(W.preventDefault(),T.click()),W.key==="Escape"&&Q()})}),g.append(u)}if(this.h.onDelete){const u=l("button","del","🗑");u.title="Delete",u.addEventListener("click",b=>{b.stopPropagation(),this.h.onDelete(e.id)}),g.append(u)}w.append(g)}if(a.append(w),e.senderRole==="bot"&&!e.deletedAt&&e.seq>0&&e.content.kind==="text"){const g=e.content.citations;if(g!=null&&g.length){const u=l("div","ocw-cites");u.style.cssText="margin-top:4px;font-size:11px;color:var(--ocw-mut,#667)",u.textContent=`${((U=this.cfg.i18n)==null?void 0:U.sources)??"Sources"}: ${g.map(b=>b.source).join(", ")}`,a.append(u)}if(this.h.onReact){const u=l("div","ocw-bot-feedback");u.style.cssText="display:flex;gap:6px;margin-top:4px";const b=(m,C)=>{const T=l("button","ocw-fb-btn",m);T.type="button",T.title=C,T.style.cssText="border:1px solid var(--ocw-bd,rgba(0,0,0,.12));background:transparent;border-radius:12px;padding:1px 8px;font-size:12px;cursor:pointer;opacity:.7";const v=()=>{var P,A;return!!((A=(P=e.reactions)==null?void 0:P[m])!=null&&A.includes(this.me))};return v()&&(T.style.opacity="1"),T.addEventListener("click",()=>{var P,A;(A=(P=this.h).onReact)==null||A.call(P,e.id,m,v()),T.style.opacity="1"}),T};u.append(b("👍",((Z=this.cfg.i18n)==null?void 0:Z.helpful)??"Helpful"),b("👎",((B=this.cfg.i18n)==null?void 0:B.notHelpful)??"Not helpful")),a.append(u)}}if(this.h.onReact&&!e.deletedAt&&e.seq>0){const g=l("div","ocw-react-wrap"),u=l("div","ocw-react");if(e.reactions&&Object.keys(e.reactions).length)for(const[C,T]of Object.entries(e.reactions)){const v=l("button",`ocw-react-pill${T.includes(this.me)?" mine":""}`,`${C} ${T.length}`);v.addEventListener("click",()=>{var P,A;return(A=(P=this.h).onReact)==null?void 0:A.call(P,e.id,C,T.includes(this.me))}),u.append(v)}const b=l("button","ocw-react-btn","+"),m=l("div","ocw-react-picker");for(const C of jn){const T=l("button",void 0,C);T.addEventListener("click",v=>{var A,Q,W,k;v.stopPropagation();const P=(Q=(A=e.reactions)==null?void 0:A[C])==null?void 0:Q.includes(this.me);(k=(W=this.h).onReact)==null||k.call(W,e.id,C,!!P),m.style.display="none"}),m.append(T)}m.style.display="none",b.addEventListener("click",C=>{C.stopPropagation();const T=m.style.display==="none";m.style.display=T?"flex":"none",T&&document.addEventListener("click",()=>{m.style.display="none"},{once:!0})}),u.append(b),g.append(u,m),a.append(g)}else e.reactions&&Object.keys(e.reactions).length&&a.append(l("div","ocw-react",Object.entries(e.reactions).map(([g,u])=>`${g}${u.length}`).join(" ")));const y=l("div","ocw-time ocw-meta",Wn(e.ts));if(s&&e.status){const g=l("span",`ocw-tick${e.status==="read"?" read":e.status==="delivered"?" delivered":""}`,Xn(e.status));y.append(g)}return s&&e.seq>0&&n.lastReadByOthers>=e.seq&&y.append(l("span","ocw-seen"," · Seen")),a.append(y),p.append(a),p}}function Xn(t){switch(t){case"read":return"✓✓";case"delivered":return"✓✓";case"sent":return"✓";default:return"🕓"}}const Gn=20;function Ge(t,e){var a;const n=t.trim().replace(/\/+$/,""),o=(a=n.match(/^(https|http|wss|ws):\/\//))==null?void 0:a[1],i=o?o==="https"||o==="wss":!0,s=(o?n.slice(o.length+3):n).replace(/\/ws$/,""),r=e?e.trim().replace(/\/+$/,""):`${i?"https":"http"}://${s}`;return{wsUrl:`${i?"wss":"ws"}://${s}/ws`,httpBase:r}}function Yn(t){return Ge(t).httpBase}function Jn(t,e,n,o){const i=`beforeSeq=${n}&limit=${o}`;return[`${t}/conversations/${e}/messages?${i}`,`${t}/conversations/${e}/history?${i}`]}async function mt(t,e,n,o,i=Gn){let s,r=!1;for(const p of Jn(t,e,o,i))try{const a=await fetch(p,{headers:{authorization:`Bearer ${n}`}});if(r=!0,!a.ok)continue;const w=await a.json();return{messages:w.messages??[],hasMore:w.hasMore??!1}}catch(a){s=a}return r?console.error(`[chat-widget] history request to ${t} was rejected for conversation ${e}.`):console.error(`[chat-widget] could not load history from ${t} — the request never reached the server. This is almost always CORS: add this site's origin to the chatroom's allowed origins (dashboard → chatroom → allowed origins) or to the server's CORS_ORIGINS.`,s),null}async function Zn(t,e,n,o,i,s){const r=s?s.replace(/\/+$/,""):Yn(t),p=await mt(r,n,e,Number.MAX_SAFE_INTEGER);if(!p||(p.messages.length?(o.apply({type:"sync",conversationId:n,messages:p.messages}),o.apply({type:"history",conversationId:n,messages:[],hasMore:p.hasMore}),i.render(o)):o.apply({type:"history",conversationId:n,messages:[],hasMore:!1}),!p.hasMore))return;let a=!1;const w=async()=>{if(a||!o.hasMoreHistory)return;a=!0;const S=o.messages()[0];if(!S){a=!1;return}const E=await mt(r,n,e,S.seq);E&&(o.apply({type:"history",conversationId:n,messages:E.messages,hasMore:E.hasMore}),i.render(o)),a=!1},f=i.getScrollEl();if(!f)return;let h=!1;setTimeout(()=>{h=!0},300);const y=()=>{h&&f.scrollTop<80&&o.hasMoreHistory&&!a&&w()};f.addEventListener("scroll",y,{passive:!0}),i.setScrollCleanup(()=>f.removeEventListener("scroll",y))}const Qn=`
191
+ `,yt="objectchat-widget-styles",jn=["👍","❤️","😂","😮","😢","🙏"],Nn=400,qn='<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path d="M22 2 11 13M22 2l-7 20-4-9-9-4 20-7z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>';function Hn(){if(typeof document>"u"||document.getElementById(yt))return;const t=document.createElement("style");t.id=yt,t.textContent=_n,document.head.appendChild(t)}const xt="ocw-webfont";function On(){if(typeof document>"u"||document.getElementById(xt))return;const t=document.createElement("link");t.id=xt,t.rel="stylesheet",t.href="https://fonts.googleapis.com/css2?family=Baloo+2:wght@500;600;700&family=Nunito:wght@400;500;600;700&display=swap",document.head.appendChild(t)}function l(t,e,n){const o=document.createElement(t);return e&&(o.className=e),n!==void 0&&(o.textContent=n),o}function Fn(t,e){const n=/(https?:\/\/[^\s]+)/g;let o=0,i=null,s;for(;(s=n.exec(e))!==null;){if(s.index>o){const h=document.createTextNode(e.slice(o,s.index));t.append(h),i??(i=h)}let p=s[0],a="";const w=/[).,!?;:]+$/.exec(p);w&&(a=w[0],p=p.slice(0,-a.length));const f=document.createElement("a");f.href=p,f.target="_blank",f.rel="noopener noreferrer",f.textContent=p,f.style.cssText="color:inherit;text-decoration:underline;word-break:break-all",t.append(f),a&&t.append(document.createTextNode(a)),o=s.index+s[0].length}const r=document.createTextNode(e.slice(o));return t.append(r),i??(i=r),i}function Wn(t){try{return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}}function Xe(t){var e;switch(t.kind){case"text":return t.text;case"system":return typeof((e=t.data)==null?void 0:e.message)=="string"?String(t.data.message):t.event;case"card":return[t.title,t.body].filter(Boolean).join(" — ");case"attachment":return t.name??t.url;case"form":return t.prompt;case"appointment":return`📅 ${t.title} — ${new Date(t.startIso).toLocaleString()}`}}class Vn{constructor(e,n,o,i={}){c(this,"scroll");c(this,"chips");c(this,"typing");c(this,"quick");c(this,"formHost");c(this,"csatPanel");c(this,"awayNotice");c(this,"headStatus");c(this,"reopenBtn");c(this,"preChatPanel");c(this,"deflectPanel");c(this,"preChatBuilt",!1);c(this,"preChatDone",!1);c(this,"footer");c(this,"input");c(this,"subjectCard");c(this,"e2eBadge");c(this,"statusBadge");c(this,"headerName");c(this,"connStatus");c(this,"typingTimer",null);c(this,"csatSubmitted",!1);c(this,"sendBtn");c(this,"compactObserver",null);c(this,"storeRef",null);c(this,"cfgAccent2");c(this,"scrollCleanup",null);c(this,"translationCache",new Map);c(this,"showingTranslation",new Set);c(this,"subjectBuilt",!1);var _,F,U,Z,B,g,u,b,m,C,T;this.root=e,this.me=n,this.h=o,this.cfg=i,Hn(),i.webfont!==!1&&On(),e.replaceChildren(),e.classList.add("ocw"),i.accent&&e.style.setProperty("--ocw-accent",i.accent);const s=i.accent2??i.accent;s&&e.style.setProperty("--ocw-accent2",s),this.cfgAccent2=i.accent2,e.dataset.theme=i.theme??"light";const r=l("div","ocw-head");if(this.h.onBack){const v=l("button","ocw-back","‹");v.type="button",v.setAttribute("aria-label","Back"),v.addEventListener("click",()=>this.h.onBack()),r.append(v)}const p=((_=i.subject)==null?void 0:_.ownerLabel)??((F=i.subject)==null?void 0:F.title)??"",a=l("div","ocw-avatar");p.trim()&&(a.textContent=p.trim()[0].toUpperCase(),r.append(a));const w=l("div","ocw-head-main");this.headerName=l("div","ocw-head-name",((U=i.subject)==null?void 0:U.ownerLabel)??((Z=i.subject)==null?void 0:Z.title)??""),w.append(this.headerName),this.headStatus=l("div","ocw-head-status"),this.headStatus.style.display="none",w.append(this.headStatus),(B=i.subject)!=null&&B.subtitle&&w.append(l("div","ocw-head-meta",i.subject.subtitle)),r.append(w),this.statusBadge=l("span","ocw-badge",((g=i.subject)==null?void 0:g.status)??""),(u=i.subject)!=null&&u.status||(this.statusBadge.style.display="none"),r.append(this.statusBadge),this.e2eBadge=l("span","ocw-e2e","🔒 E2E"),this.e2eBadge.style.display="none",r.append(this.e2eBadge),this.connStatus=l("span","ocw-conn-status"),this.connStatus.style.display="none",r.append(this.connStatus),r.append(l("button","ocw-menu","⋯")),this.chips=l("div","ocw-chiprow"),this.scroll=l("div","ocw-scroll"),this.subjectCard=l("div","ocw-subject"),this.typing=l("div","ocw-typing");const f=l("div","ocw-typing-bubble");f.append(l("div","ocw-typing-dot"),l("div","ocw-typing-dot"),l("div","ocw-typing-dot")),this.typing.append(f),this.quick=l("div","ocw-quick");for(const v of i.quickReplies??[]){const P=l("button",void 0,v);P.addEventListener("click",()=>{this.h.onSend(v),this.quick.style.display="none"}),this.quick.append(P)}this.formHost=l("div","ocw-form-host"),this.csatPanel=l("div","ocw-csat"),this.csatPanel.style.display="none",this.awayNotice=l("div","ocw-away"),this.awayNotice.style.display="none",this.preChatPanel=l("div","ocw-prechat"),this.preChatPanel.style.display="none",this.deflectPanel=l("div","ocw-deflect"),this.deflectPanel.style.display="none",this.input=l("textarea",void 0),this.input.rows=1,this.input.placeholder=((b=i.i18n)==null?void 0:b.placeholder)??"Message…";const h=l("button","ocw-sendbtn");h.type="button";const y=(m=i.i18n)==null?void 0:m.send;y?(h.textContent=y,h.classList.add("ocw-sendbtn-label"),h.setAttribute("aria-label",y)):(h.innerHTML=qn,h.setAttribute("aria-label","Send message")),h.disabled=!0,this.sendBtn=h,h.addEventListener("click",()=>this.flushSend()),this.input.addEventListener("input",()=>{var v,P;this.sendBtn.disabled=this.input.value.trim().length===0,this.autoGrowInput(),this.storeRef&&!this.storeRef.messages().some(A=>A.senderRole==="guest")?(P=(v=this.h).onDeflectQuery)==null||P.call(v,this.input.value):this.hideDeflection()}),this.input.addEventListener("keydown",v=>{v.isComposing||v.keyCode===229||(v.key==="Enter"&&!v.shiftKey?(v.preventDefault(),this.flushSend()):this.signalTyping())});const S=l("button","ocw-attach","📎");S.title="Attach image or file";const E=document.createElement("input");E.type="file",E.accept="image/*,.pdf,.txt,.doc,.docx",E.style.display="none",S.addEventListener("click",()=>E.click()),E.addEventListener("change",()=>{var v;(v=E.files)!=null&&v[0]&&this.h.onAttach&&this.h.onAttach(E.files[0]),E.value=""});const M=l("div","ocw-input");M.append(S,E,this.input,h);const K=l("div","ocw-footer");((C=i.i18n)==null?void 0:C.poweredBy)!==void 0?K.textContent=i.i18n.poweredBy:K.innerHTML='Powered by <a href="https://relay.paramms.com" target="_blank" rel="noopener">Relay</a>',this.footer=K,this.reopenBtn=l("button","ocw-reopen",((T=this.cfg.i18n)==null?void 0:T.reopen)??"Reopen conversation"),this.reopenBtn.type="button",this.reopenBtn.addEventListener("click",()=>{this.reopenBtn.style.display="none";const v=this.root.querySelector(".ocw-input textarea");v==null||v.focus()}),e.append(r,this.chips,this.scroll,this.typing,this.quick,this.formHost,this.csatPanel,this.preChatPanel,this.deflectPanel,this.awayNotice,M,this.reopenBtn,this.footer);const $=v=>{e.classList.toggle("ocw-compact",v>0&&v<Nn)};$(e.clientWidth),typeof ResizeObserver<"u"&&(this.compactObserver=new ResizeObserver(v=>{var A;const P=((A=v[0])==null?void 0:A.contentRect.width)??e.clientWidth;$(P)}),this.compactObserver.observe(e))}getScrollEl(){return this.scroll}setScrollCleanup(e){var n;(n=this.scrollCleanup)==null||n.call(this),this.scrollCleanup=e}destroy(){var e,n;(e=this.scrollCleanup)==null||e.call(this),this.scrollCleanup=null,this.typingTimer&&(clearTimeout(this.typingTimer),this.typingTimer=null),(n=this.compactObserver)==null||n.disconnect(),this.compactObserver=null}flushSend(){this.hideDeflection();const e=this.input.value.trim();e&&(this.input.value="",this.sendBtn.disabled=!0,this.autoGrowInput(),this.h.onTyping(!1),this.h.onSend(e))}autoGrowInput(){this.input.style.height="auto";const e=this.input.scrollHeight;e>0?this.input.style.height=`${Math.min(e,120)}px`:this.input.style.removeProperty("height")}signalTyping(){const e=this.input.value.trim().slice(0,100)||void 0;this.h.onTyping(!0,e),this.typingTimer&&clearTimeout(this.typingTimer),this.typingTimer=setTimeout(()=>this.h.onTyping(!1),2e3)}setBotName(e){this.cfg.i18n={...this.cfg.i18n??{},aiAssistant:e}}render(e){var E,M,K,$,_,F,U,Z;if(this.storeRef=e,e.accent&&(this.root.style.setProperty("--ocw-accent",e.accent),this.root.style.setProperty("--ocw-accent2",this.cfgAccent2??e.accent)),this.e2eBadge.style.display=e.e2e?"inline-flex":"none",this.buildSubjectCard(e),e.subject){const B=(E=this.cfg.subject)==null?void 0:E.ownerLabel;B&&(this.headerName.textContent=B)}this.quick.style.display=e.messages().length===0?"flex":"none",this.chips.replaceChildren();const n=e.visibleActions();this.chips.style.display=n.length?"flex":"none";for(const B of n)this.chips.append(this.chipEl(B));const o=this.scroll.scrollHeight,i=this.scroll.scrollTop;if(this.scroll.replaceChildren(),this.subjectCard.childNodes.length&&this.scroll.append(this.subjectCard),e.hasMoreHistory){const B=l("div","ocw-load-more");B.textContent="↑ Loading earlier messages…",B.style.pointerEvents="none",this.scroll.append(B)}let s=0,r=null;const p=[...e.messages()];for(let B=0;B<p.length;B++){const g=p[B],u=g.senderRole!=="system"&&g.senderId!==this.me&&!g.internal&&g.senderId!==r;this.scroll.append(this.messageEl(g,e,u,B===p.length-1)),g.senderRole!=="system"&&(r=g.senderId),g.senderId!==this.me&&g.seq>s&&(s=g.seq)}i>20?this.scroll.scrollTop=this.scroll.scrollHeight-o+i:this.scroll.scrollTop=this.scroll.scrollHeight,s>0&&this.h.onReadUpTo(s);const a=[...e.typing];this.typing.classList.toggle("active",a.length>0);const w=this.typing.querySelector(".ocw-typing-bubble");w&&w.setAttribute("aria-label",a.length?"typing":""),this.footer.style.display=e.whiteLabel?"none":"block";const f=e.messages().some(B=>B.senderRole==="guest");if(!!((M=e.preChat)!=null&&M.enabled)&&!this.preChatDone&&!f&&(e.preChat.showWhen!=="offline"||e.offline))this.preChatBuilt||this.buildPreChatPanel(e.preChat),this.preChatPanel.style.display="block",this.awayNotice.style.display="none",(K=this.root.querySelector(".ocw-input"))==null||K.style.setProperty("display","none");else{if(this.preChatPanel.style.display="none",e.offline){this.awayNotice.firstChild||this.awayNotice.append(l("span","ocw-away-icon","🌙"),l("span","",""));const B=this.awayNotice.lastChild;B.textContent=e.offlineMessage||(($=this.cfg.i18n)==null?void 0:$.offline)||"We're away right now — send your message and we'll reply as soon as we're back.",this.awayNotice.style.display="flex"}else this.awayNotice.style.display="none";(_=this.root.querySelector(".ocw-input"))==null||_.style.removeProperty("display")}const y=["resolved","closed","sold","issued","checked_out"];this.h.onCsat&&!this.csatSubmitted&&y.includes(e.state)&&e.messages().length>0&&(this.csatPanel.style.display==="none"&&this.buildCsatPanel(),this.csatPanel.style.display="block");const S=y.includes(e.state);if(e.offline?(this.headStatus.textContent=`● ${e.offlineMessage||((F=this.cfg.i18n)==null?void 0:F.away)||"Away"}`,this.headStatus.className="ocw-head-status away",this.headStatus.style.display=""):e.conversationId?(this.headStatus.textContent=`● ${((U=this.cfg.i18n)==null?void 0:U.online)??"Online"}`,this.headStatus.className="ocw-head-status online",this.headStatus.style.display=""):this.headStatus.style.display="none",S&&e.messages().length>0){const B=l("div","ocw-resolved-note",`— ${((Z=this.cfg.i18n)==null?void 0:Z.resolved)??"Marked as resolved"} —`);this.scroll.append(B),this.reopenBtn.style.display="block"}else this.reopenBtn.style.display="none"}setConnStatus(e,n){if(e==="open"){this.connStatus.style.display="none";return}this.connStatus.style.display="";const o=e==="error";this.connStatus.className=`ocw-conn-status${o?" err":e==="reconnecting"?" warn":""}`,this.connStatus.textContent=o?`⚠ ${n??"Chat unavailable"}`:e==="reconnecting"?n??"↻ reconnecting…":"● connecting…"}buildPreChatPanel(e){var a;this.preChatBuilt=!0,this.preChatPanel.replaceChildren(),this.preChatPanel.append(l("div","ocw-prechat-title",e.title??"Before we start…"));const n=l("div","ocw-offline-form"),o={};for(const w of e.fields??["name","email"]){const f=l("input","ocw-offline-input");f.type=w==="email"?"email":w==="phone"?"tel":"text",f.placeholder=w==="name"?"Your name":w==="email"?"Your email":"Your phone number",o[w]=f,n.append(f)}let i=null;if((a=e.topics)!=null&&a.length){i=l("select",void 0);const w=document.createElement("option");w.value="",w.textContent="What is this about?",i.append(w);for(const f of e.topics){const h=document.createElement("option");h.value=f,h.textContent=f,i.append(h)}n.append(i)}let s=null,r=null;if(e.callbackOption){const w=l("label","ocw-prechat-cb");s=document.createElement("input"),s.type="checkbox",w.append(s,document.createTextNode("📞 Request a call back")),n.append(w),o.phone||(r=l("input","ocw-offline-input"),r.type="tel",r.placeholder="Phone number for the call",r.style.display="none",s.addEventListener("change",()=>r.style.setProperty("display",s.checked?"block":"none")),n.append(r))}const p=l("button","ocw-offline-submit","Start chat");p.type="button",p.addEventListener("click",()=>{var y,S,E,M,K,$,_;const w=(y=o.email)==null?void 0:y.value.trim();if(o.email&&(!w||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(w))){o.email.focus();return}const f=!!(s!=null&&s.checked),h=(((S=o.phone)==null?void 0:S.value)??(r==null?void 0:r.value)??"").trim();if(f&&!h){(E=o.phone??r)==null||E.focus();return}if(i&&((M=e.topics)!=null&&M.length)&&!i.value){i.focus();return}p.disabled=!0,this.completePreChat(),(_=($=this.h).onPreChat)==null||_.call($,{...(K=o.name)!=null&&K.value.trim()?{name:o.name.value.trim()}:{},...w?{email:w}:{},...h?{phone:h}:{},...i!=null&&i.value?{topic:i.value}:{},...f?{callback:!0}:{}})}),n.append(p),this.preChatPanel.append(n)}completePreChat(){this.preChatDone=!0,this.preChatPanel.style.display="none",this.storeRef&&this.render(this.storeRef)}showDeflection(e){if(!e.length)return this.hideDeflection();this.deflectPanel.replaceChildren(),this.deflectPanel.append(l("div","ocw-deflect-hint","Instant answers — tap to expand"));for(const n of e.slice(0,3)){const o=l("button","ocw-deflect-card");o.append(l("div","ocw-deflect-q",n.title),l("div","ocw-deflect-a",n.answer)),o.addEventListener("click",()=>o.classList.toggle("open")),this.deflectPanel.append(o)}this.deflectPanel.style.display="flex"}hideDeflection(){this.deflectPanel.style.display="none",this.deflectPanel.replaceChildren()}buildCsatPanel(){this.csatPanel.replaceChildren(),this.csatPanel.append(l("div","ocw-csat-title","How did we do?"));const e=l("div","ocw-csat-stars"),n=[];for(let o=1;o<=5;o++){const i=l("button","ocw-csat-star","★");i.dataset.score=String(o),i.addEventListener("mouseenter",()=>n.forEach((s,r)=>s.classList.toggle("lit",r<o))),i.addEventListener("mouseleave",()=>n.forEach(s=>s.classList.remove("lit"))),i.addEventListener("click",()=>{var s,r;this.csatSubmitted=!0,this.csatPanel.replaceChildren(l("div","ocw-csat-done",`Thanks for your ${o}★ rating!`)),(r=(s=this.h).onCsat)==null||r.call(s,o)}),n.push(i),e.append(i)}this.csatPanel.append(e)}buildSubjectCard(e){if(this.subjectBuilt)return;const n=e.subject,o=this.cfg.subject,i=(n==null?void 0:n.title)??(o==null?void 0:o.title);if(!i)return;this.subjectBuilt=!0,this.subjectCard.replaceChildren(),this.subjectCard.append(l("div","ocw-subject-title",i)),o!=null&&o.subtitle&&this.subjectCard.append(l("div","ocw-subject-sub",o.subtitle));const s=l("div","ocw-tags");if(n)for(const[p,a]of Object.entries(n.fields))s.append(l("span","ocw-tag",`${p}: ${a}`));else for(const p of(o==null?void 0:o.tags)??[])s.append(l("span","ocw-tag",p));s.childNodes.length&&this.subjectCard.append(s);const r=(n==null?void 0:n.state)??(o==null?void 0:o.status);r&&(this.statusBadge.textContent=r,this.statusBadge.style.display="inline-flex")}chipEl(e){const n=l("button","ocw-chip",e.icon?`${e.icon} ${e.label}`:e.label);return n.dataset.actionId=e.id,n.addEventListener("click",async()=>{var o;e.confirm&&!await this.confirm(e.label)||((o=e.input)!=null&&o.length?this.openForm(e):this.h.onInvoke(e.id))}),n}confirm(e){return new Promise(n=>{const o=l("div","ocw-modal"),i=l("div","ocw-modal-card");i.append(l("div","ocw-modal-title",e)),i.append(l("div","ocw-modal-body",`Confirm “${e}”?`));const s=l("div","ocw-modal-actions"),r=l("button","ocw-modal-cancel","Cancel"),p=l("button","ocw-modal-ok","Confirm"),a=w=>{o.remove(),n(w)};r.addEventListener("click",()=>a(!1)),p.addEventListener("click",()=>a(!0)),o.addEventListener("click",w=>{w.target===o&&a(!1)}),s.append(r,p),i.append(s),o.append(i),this.root.append(o),p.focus()})}openForm(e,n){var a,w;this.formHost.replaceChildren();const o=l("div","ocw-form");o.append(l("div","ocw-form-title",e.icon?`${e.icon} ${e.label}`:e.label));const i=new Map;for(const f of e.input??[]){const h=n==null?void 0:n[f.name],y=l("label","ocw-form-row");if(y.append(l("span","ocw-form-lbl",f.label)),f.type==="select"&&((a=f.options)!=null&&a.length)){const S=l("select","ocw-form-input");f.required||S.append(l("option",void 0,"— select —"));for(const E of f.options){const M=l("option");M.value=E,M.textContent=E,S.append(M)}f.required&&(S.required=!0),h!=null&&f.options.includes(h)&&(S.value=h),y.append(S),i.set(f.name,S)}else{const S=l("input","ocw-form-input");S.type=f.type==="number"?"number":f.type==="date"?"datetime-local":"text",f.required&&(S.required=!0),h!=null&&h!==""&&(S.value=h),y.append(S),i.set(f.name,S)}o.append(y)}const s=l("div","ocw-form-actions"),r=l("button","ocw-form-cancel","Cancel"),p=l("button","ocw-form-submit","Send");r.addEventListener("click",()=>this.formHost.replaceChildren()),p.addEventListener("click",()=>{const f={};for(const[h,y]of i){if(y.required&&!y.value){y.style.borderColor="#e5484d";return}f[h]=y.type==="number"?Number(y.value):y.value}this.formHost.replaceChildren(),this.h.onInvoke(e.id,f)}),s.append(r,p),o.append(s),this.formHost.append(o),(w=i.values().next().value)==null||w.focus()}messageEl(e,n,o=!1,i=!1){var S,E,M,K,$,_,F,U,Z,B;if(e.senderRole==="system"){const g=l("div","ocw-sys");return g.textContent=e.deletedAt?"message deleted":Xe(e.content),g}const s=e.senderId===this.me,r=!!e.internal,p=l("div",`ocw-row ${r?"ocw-note mine":s?"mine":"theirs"} ${e.senderRole==="bot"?"ocw-bot":""}`),a=l("div");if(o){const g=e.senderRole==="bot"?((S=this.cfg.i18n)==null?void 0:S.aiAssistant)??"AI Assistant":((E=this.cfg.subject)==null?void 0:E.ownerLabel)??((M=this.cfg.subject)==null?void 0:M.title)??"Support";a.append(l("div","ocw-msg-sender",g))}const w=l("div","ocw-bubble-wrap");if(e.replyToId){const g=l("div","ocw-reply-to","↩ replying to a message");g.style.cssText="font-size:11px;color:var(--ocw-mut);margin-bottom:2px;font-style:italic",a.append(g)}const f=l("div","ocw-bubble");let h=null;if(e.deletedAt)f.append(l("span","ocw-deleted","message deleted"));else if(e.content.kind==="attachment"){const g=e.content;if((K=g.mime)!=null&&K.startsWith("image/")){const u=document.createElement("img");u.src=g.url,u.alt=g.name??"image",u.style.cssText="max-width:220px;max-height:160px;border-radius:10px;display:block;cursor:pointer",u.addEventListener("click",()=>window.open(g.url,"_blank")),f.append(u)}else if(($=g.mime)!=null&&$.startsWith("video/")){const u=document.createElement("video");u.src=g.url,u.controls=!0,u.style.cssText="max-width:240px;max-height:180px;border-radius:10px;display:block",f.append(u)}else{const u=document.createElement("a");u.href=g.url,u.target="_blank",u.rel="noopener",u.style.cssText="display:flex;align-items:center;gap:8px;color:inherit;text-decoration:none",u.append(l("span",void 0,"📄"),l("span",void 0,g.name??"file")),f.append(u)}}else if(e.content.kind==="appointment"){const g=e.content,u=l("div","ocw-appt");u.append(l("div","ocw-appt-title",`📅 ${g.title}`)),u.append(l("div","ocw-appt-time",new Date(g.startIso).toLocaleString()+" – "+new Date(g.endIso).toLocaleTimeString())),g.location&&u.append(l("div","ocw-appt-loc",`📍 ${g.location}`)),g.description&&u.append(l("div","ocw-appt-desc",g.description));const b=l("div","ocw-appt-links"),m=document.createElement("a");m.href=g.googleUrl,m.target="_blank",m.rel="noopener",m.className="ocw-appt-btn",m.textContent="📅 Add to Google Calendar";const C=document.createElement("a");C.href=g.icalUrl,C.download=`${g.title}.ics`,C.className="ocw-appt-btn ocw-appt-btn-sec",C.textContent="🍎 Apple / iCal",b.append(m,C),u.append(b),f.append(u)}else h=Fn(f,Xe(e.content)),e.editedAt&&f.append(l("span","ocw-edited","(edited)"));if(w.append(f),i&&!e.deletedAt&&e.content.kind==="text"&&((_=e.content.quickReplies)!=null&&_.length)){const g=l("div","ocw-flow-choices");g.style.cssText="display:flex;flex-wrap:wrap;gap:6px;margin-top:6px";for(const u of e.content.quickReplies){const b=l("button","ocw-flow-choice",u);b.type="button",b.style.cssText="border:1px solid var(--ocw-bd,rgba(0,0,0,.12));background:var(--ocw-bg,#fff);color:inherit;border-radius:14px;padding:5px 12px;font:inherit;font-size:13px;cursor:pointer",b.addEventListener("click",()=>{g.querySelectorAll("button").forEach(m=>m.disabled=!0),g.style.opacity="0.5",this.h.onSend(u)}),g.append(b)}w.append(g)}if(i&&!e.deletedAt&&e.content.kind==="form"){const g=e.content,u=n.actionById(g.actionId);if((F=u==null?void 0:u.input)!=null&&F.length){const b=l("button","ocw-chip",u.icon?`${u.icon} ${u.label}`:u.label);b.type="button",b.style.cssText="margin-top:6px",b.addEventListener("click",async()=>{u.confirm&&!await this.confirm(u.label)||this.openForm(u,g.prefill)}),w.append(b)}}if(!s&&!r&&this.h.onTranslate&&e.content.kind==="text"&&!e.deletedAt&&e.seq>0&&h){const g=e.content.text;if(g.trim()){const u=l("button","ocw-translate-btn");u.type="button",u.innerHTML='<span aria-hidden="true">🌐</span> Translate',u.title="Translate";const b=l("div","ocw-translation");b.style.display="none",f.append(b);const m=v=>{b.textContent=v,b.style.display="",this.showingTranslation.add(e.id),u.innerHTML='<span aria-hidden="true">↩</span> Original',u.title="Show original"},C=()=>{b.style.display="none",this.showingTranslation.delete(e.id),u.innerHTML='<span aria-hidden="true">🌐</span> Translate',u.title="Translate"};u.addEventListener("click",v=>{if(v.stopPropagation(),this.showingTranslation.has(e.id)){C();return}const P=this.translationCache.get(e.id);if(P!==void 0){m(P);return}u.textContent="⏳ …",this.h.onTranslate(g).then(A=>{if(A===null){u.textContent="⚠️ Unavailable",setTimeout(()=>C(),1500);return}this.translationCache.set(e.id,A),m(A)})}),w.append(u);const T=this.translationCache.get(e.id);this.showingTranslation.has(e.id)&&T!==void 0&&m(T)}}if(s&&!e.deletedAt&&e.seq>0&&(this.h.onEdit??this.h.onDelete)){const g=l("div","ocw-msg-menu");if(this.h.onEdit){const u=l("button",void 0,"✏️");u.title="Edit",u.addEventListener("click",b=>{b.stopPropagation();const m=Xe(e.content),C=document.createElement("textarea");C.value=m,C.rows=Math.min(4,Math.ceil(m.length/40)+1),C.style.cssText="width:100%;resize:vertical;border:1px solid var(--ocw-accent);border-radius:8px;padding:6px 10px;font:inherit;font-size:14px;background:var(--ocw-card);color:#1c1b1a;box-sizing:border-box";const T=l("button","ocw-form-submit","Save");T.style.cssText="margin-top:6px;padding:5px 14px;font-size:13px";const v=l("button","ocw-form-cancel","Cancel");v.style.cssText="margin-top:6px;padding:5px 10px;font-size:13px";const P=l("div");P.style.cssText="display:flex;gap:6px;justify-content:flex-end",P.append(v,T);const A=l("div");A.append(C,P),f.replaceChildren(A),C.focus(),C.select();const Q=()=>f.replaceChildren(h??document.createTextNode(m));v.addEventListener("click",Q),T.addEventListener("click",()=>{const W=C.value.trim();W&&W!==m&&this.h.onEdit(e.id,W),Q()}),C.addEventListener("keydown",W=>{W.key==="Enter"&&!W.shiftKey&&(W.preventDefault(),T.click()),W.key==="Escape"&&Q()})}),g.append(u)}if(this.h.onDelete){const u=l("button","del","🗑");u.title="Delete",u.addEventListener("click",b=>{b.stopPropagation(),this.h.onDelete(e.id)}),g.append(u)}w.append(g)}if(a.append(w),e.senderRole==="bot"&&!e.deletedAt&&e.seq>0&&e.content.kind==="text"){const g=e.content.citations;if(g!=null&&g.length){const u=l("div","ocw-cites");u.style.cssText="margin-top:4px;font-size:11px;color:var(--ocw-mut,#667)",u.textContent=`${((U=this.cfg.i18n)==null?void 0:U.sources)??"Sources"}: ${g.map(b=>b.source).join(", ")}`,a.append(u)}if(this.h.onReact){const u=l("div","ocw-bot-feedback");u.style.cssText="display:flex;gap:6px;margin-top:4px";const b=(m,C)=>{const T=l("button","ocw-fb-btn",m);T.type="button",T.title=C,T.style.cssText="border:1px solid var(--ocw-bd,rgba(0,0,0,.12));background:transparent;border-radius:12px;padding:1px 8px;font-size:12px;cursor:pointer;opacity:.7";const v=()=>{var P,A;return!!((A=(P=e.reactions)==null?void 0:P[m])!=null&&A.includes(this.me))};return v()&&(T.style.opacity="1"),T.addEventListener("click",()=>{var P,A;(A=(P=this.h).onReact)==null||A.call(P,e.id,m,v()),T.style.opacity="1"}),T};u.append(b("👍",((Z=this.cfg.i18n)==null?void 0:Z.helpful)??"Helpful"),b("👎",((B=this.cfg.i18n)==null?void 0:B.notHelpful)??"Not helpful")),a.append(u)}}if(this.h.onReact&&!e.deletedAt&&e.seq>0){const g=l("div","ocw-react-wrap"),u=l("div","ocw-react");if(e.reactions&&Object.keys(e.reactions).length)for(const[C,T]of Object.entries(e.reactions)){const v=l("button",`ocw-react-pill${T.includes(this.me)?" mine":""}`,`${C} ${T.length}`);v.addEventListener("click",()=>{var P,A;return(A=(P=this.h).onReact)==null?void 0:A.call(P,e.id,C,T.includes(this.me))}),u.append(v)}const b=l("button","ocw-react-btn","+"),m=l("div","ocw-react-picker");for(const C of jn){const T=l("button",void 0,C);T.addEventListener("click",v=>{var A,Q,W,k;v.stopPropagation();const P=(Q=(A=e.reactions)==null?void 0:A[C])==null?void 0:Q.includes(this.me);(k=(W=this.h).onReact)==null||k.call(W,e.id,C,!!P),m.style.display="none"}),m.append(T)}m.style.display="none",b.addEventListener("click",C=>{C.stopPropagation();const T=m.style.display==="none";m.style.display=T?"flex":"none",T&&document.addEventListener("click",()=>{m.style.display="none"},{once:!0})}),u.append(b),g.append(u,m),a.append(g)}else e.reactions&&Object.keys(e.reactions).length&&a.append(l("div","ocw-react",Object.entries(e.reactions).map(([g,u])=>`${g}${u.length}`).join(" ")));const y=l("div","ocw-time ocw-meta",Wn(e.ts));if(s&&e.status){const g=l("span",`ocw-tick${e.status==="read"?" read":e.status==="delivered"?" delivered":""}`,Xn(e.status));y.append(g)}return s&&e.seq>0&&n.lastReadByOthers>=e.seq&&y.append(l("span","ocw-seen"," · Seen")),a.append(y),p.append(a),p}}function Xn(t){switch(t){case"read":return"✓✓";case"delivered":return"✓✓";case"sent":return"✓";default:return"🕓"}}const Gn=20;function Ge(t,e){var a;const n=t.trim().replace(/\/+$/,""),o=(a=n.match(/^(https|http|wss|ws):\/\//))==null?void 0:a[1],i=o?o==="https"||o==="wss":!0,s=(o?n.slice(o.length+3):n).replace(/\/ws$/,""),r=e?e.trim().replace(/\/+$/,""):`${i?"https":"http"}://${s}`;return{wsUrl:`${i?"wss":"ws"}://${s}/ws`,httpBase:r}}function Yn(t){return Ge(t).httpBase}function Jn(t,e,n,o){const i=`beforeSeq=${n}&limit=${o}`;return[`${t}/conversations/${e}/messages?${i}`,`${t}/conversations/${e}/history?${i}`]}async function mt(t,e,n,o,i=Gn){let s,r=!1;for(const p of Jn(t,e,o,i))try{const a=await fetch(p,{headers:{authorization:`Bearer ${n}`}});if(r=!0,!a.ok)continue;const w=await a.json();return{messages:w.messages??[],hasMore:w.hasMore??!1}}catch(a){s=a}return r?console.error(`[chat-widget] history request to ${t} was rejected for conversation ${e}.`):console.error(`[chat-widget] could not load history from ${t} — the request never reached the server. This is almost always CORS: add this site's origin to the chatroom's allowed origins (dashboard → chatroom → allowed origins) or to the server's CORS_ORIGINS.`,s),null}async function Zn(t,e,n,o,i,s){const r=s?s.replace(/\/+$/,""):Yn(t),p=await mt(r,n,e,Number.MAX_SAFE_INTEGER);if(!p||(p.messages.length?(o.apply({type:"sync",conversationId:n,messages:p.messages}),o.apply({type:"history",conversationId:n,messages:[],hasMore:p.hasMore}),i.render(o)):o.apply({type:"history",conversationId:n,messages:[],hasMore:!1}),!p.hasMore))return;let a=!1;const w=async()=>{if(a||!o.hasMoreHistory)return;a=!0;const S=o.messages()[0];if(!S){a=!1;return}const E=await mt(r,n,e,S.seq);E&&(o.apply({type:"history",conversationId:n,messages:E.messages,hasMore:E.hasMore}),i.render(o)),a=!1},f=i.getScrollEl();if(!f)return;let h=!1;setTimeout(()=>{h=!0},300);const y=()=>{h&&f.scrollTop<80&&o.hasMoreHistory&&!a&&w()};f.addEventListener("scroll",y,{passive:!0}),i.setScrollCleanup(()=>f.removeEventListener("scroll",y))}const Qn=`
193
192
  .ocl { ${gt("ocl")}
194
193
  display:flex; flex-direction:column; height:100%; background:var(--ocl-bg);
195
194
  font-family:var(--ocl-fb); color:var(--ocl-ink); overflow:hidden; }
@@ -237,5 +236,5 @@ var RelayEmbed=function(te){"use strict";var fi=Object.defineProperty;var wi=(te
237
236
  .ocl-compact .ocl-search { font-size:16px; }
238
237
  .ocl-compact .ocl-compose { width:36px; height:36px; }
239
238
  .ocl-row:focus-visible, .ocl button:focus-visible, .ocl input:focus-visible { outline:2px solid var(--ocl-accent); outline-offset:2px; border-radius:12px; }
240
- `,ei={en:{placeholder:"Message…",offline:"We're offline right now",online:"Online",away:"Away",aiAssistant:"AI Assistant",resolved:"Marked as resolved",reopen:"Reopen conversation",sources:"Sources",helpful:"Helpful",notHelpful:"Not helpful",title:"Your conversations",newChat:"New conversation",startChat:"Start a conversation",all:"All conversations",empty:"No conversations yet.",error:"Could not load conversations.",retry:"Retry",search:"🔍 Search",unread:"Unread",close:"Close"},ko:{placeholder:"메시지…",offline:"지금은 오프라인입니다",online:"온라인",away:"자리 비움",aiAssistant:"AI 어시스턴트",resolved:"해결됨으로 표시됨",reopen:"대화 다시 열기",sources:"출처",helpful:"도움돼요",notHelpful:"도움 안돼요",title:"내 대화",newChat:"새 대화",startChat:"대화 시작하기",all:"전체 대화",empty:"아직 대화가 없습니다.",error:"대화를 불러오지 못했습니다.",retry:"다시 시도",search:"🔍 검색",unread:"읽지 않음",close:"닫기"}};function bt(t){const e=(t??(typeof navigator<"u"?navigator.language:"")??"").toLowerCase();return e.startsWith("ko")||e.includes("korean")||e.includes("한국")?"ko":"en"}function vt(t,e){const n=ei[bt(t)],o={};for(const[i,s]of Object.entries(e??{}))typeof s=="string"&&s!==""&&(o[i]=s);return{...n,...o}}function ti(t){switch(t){case"open":return{label:"Open",cls:"open"};case"awaiting_staff":return{label:"Waiting on you",cls:"waiting"};case"resolved":return{label:"Resolved",cls:"done"};case"closed":return{label:"Closed",cls:"done"};default:return null}}function ni(t){const e=Math.floor((Date.now()-t)/1e3);if(e<60)return"just now";if(e<3600)return`${Math.floor(e/60)}m`;if(e<86400)return`${Math.floor(e/3600)}h`;const n=Math.floor(e/86400);if(n<=7)return`${n}d`;try{return new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric"})}catch{return`${n}d`}}function M(t,e,n){const o=document.createElement(t);return e&&(o.className=e),n!==void 0&&(o.textContent=n),o}function kt(t){const e=t.token??t.userId??it(),{httpBase:n,wsUrl:o}=Ge(t.url,t.apiUrl),i=vt(t.locale,t.i18n),s=t.accent??"#6c5ce7";if(!document.getElementById("ocl-styles")){const k=document.createElement("style");k.id="ocl-styles",k.textContent=Qn,document.head.append(k)}if(t.webfont!==!1&&typeof document<"u"&&!document.getElementById("ocw-webfont")){const k=document.createElement("link");k.id="ocw-webfont",k.rel="stylesheet",k.href="https://fonts.googleapis.com/css2?family=Baloo+2:wght@500;600;700&family=Nunito:wght@400;500;600;700&display=swap",document.head.append(k)}const r=M("div","ocl");r.style.setProperty("--ocl-accent",s),r.dataset.theme=t.theme??"light",t.reserveCloseSpace&&r.classList.add("ocl-has-close");const p=M("div","ocl-head"),a=i.title??"Your conversations",w=M("span","ocl-title",a);if(w.setAttribute("aria-label",a),p.append(w),t.onNewChat){const k=M("button","ocl-compose","✎");k.title=i.newChat??"New conversation",k.addEventListener("click",()=>t.onNewChat()),p.append(k)}const f=M("div","ocl-search-wrap"),h=M("input","ocl-search");h.placeholder=i.search??"🔍 Search",h.type="search",f.append(h);const y=M("div","ocl-body");y.append(M("div","ocl-spinner","Loading…")),r.append(p,f,y),t.el.replaceChildren(r);const S=k=>{r.classList.toggle("ocl-compact",k>0&&k<400)};S(r.clientWidth);let E=null;if(typeof ResizeObserver<"u"&&(E=new ResizeObserver(k=>{var j;return S(((j=k[0])==null?void 0:j.contentRect.width)??r.clientWidth)}),E.observe(r)),!t.profileId&&!t.tenantId)throw new Error("[relay chatlist] provide profileId or tenantId");let z;const K=`ocl_seen_${t.profileId??`t_${t.tenantId}`}_${(t.userId??e).slice(-8)}`;let $={};try{$=JSON.parse(localStorage.getItem(K)??"{}")}catch{}const _=()=>{try{localStorage.setItem(K,JSON.stringify($))}catch{}};let F=[],U=!1;const Z=async()=>{const k=t.profileId?`profileId=${encodeURIComponent(t.profileId)}${t.scope==="tenant"?"&scope=tenant":""}`:`tenantId=${encodeURIComponent(t.tenantId)}`,j=`${n}/conversations/mine?${k}`,V={authorization:`Bearer ${e}`};let ee;try{ee=await fetch(j,{headers:V})}catch{ee=await fetch(j,{headers:V})}if(!ee.ok)return[];const X=await ee.json();return X.defaultProfileId&&(z=X.defaultProfileId),(X.conversations??[]).sort((R,L)=>L.updatedAt-R.updatedAt)},B=(k,j)=>{if(U)return;const V=j?k.filter(L=>g(L).toLowerCase().includes(j)||(L.lastMessage??"").toLowerCase().includes(j)):k;if(y.replaceChildren(),!V.length){const L=M("div","ocl-empty",j?"No results.":i.empty??"No conversations yet.");if(!j&&t.onNewChat){L.append(M("br"));const fe=M("button","ocl-start",i.startChat??"Start a conversation");fe.addEventListener("click",()=>t.onNewChat()),L.append(fe)}y.append(L);return}const ee=L=>(L.lastSeq??0)>($[L.id]??0),X=V.filter(ee),R=V.filter(L=>!ee(L));if(X.length){y.append(M("div","ocl-section",`${i.unread??"Unread"} (${X.length})`));for(const L of X)y.append(u(L,ee(L)))}if(R.length){y.append(M("div","ocl-section",X.length?i.all??"All conversations":""));for(const L of R)y.append(u(L,!1))}},g=k=>k.subjectTitle??(k.kind==="direct"?k.peerId??"Direct message":"General enquiry"),u=(k,j)=>{var Te;const V=g(k),ee=(((Te=V.match(new RegExp("\\p{L}","u")))==null?void 0:Te[0])??V.trim()[0]??"?").toUpperCase(),X=k.lastSeq??0,R=j?Math.max(1,X-($[k.id]??0)):0,L=M("button",`ocl-row${j?" unread":""}`),fe=M("div","ocl-av",ee);L.append(fe);const oe=M("div","ocl-info");oe.append(M("div","ocl-name",V));const we={open:"Open",awaiting_staff:"Waiting for reply…",resolved:"Resolved ✓",closed:"Closed"};oe.append(M("div","ocl-preview",k.lastMessage??we[k.state]??k.state)),L.append(oe);const de=M("div","ocl-right");de.append(M("div","ocl-time",ni(k.updatedAt)));const ge=ti(k.state);return ge&&de.append(M("div",`ocl-status ${ge.cls}`,ge.label)),R>0&&de.append(M("div","ocl-badge",String(R>99?"99+":R))),L.append(de),L.addEventListener("click",()=>{var Ee;X>0&&($[k.id]=X,_()),L.classList.remove("unread"),(Ee=de.querySelector(".ocl-badge"))==null||Ee.remove(),t.onSelect(k)}),L},b=()=>{U||Z().then(k=>{U||(F=k,B(k,h.value.trim().toLowerCase()))}).catch(k=>{if(U)return;console.error(`[chat-widget] failed to load conversations from ${n}/conversations/mine — check the apiUrl/CORS config.`,k);const j=M("div","ocl-empty",i.error??"Could not load conversations.");j.append(M("br"));const V=M("button","ocl-retry",i.retry??"Retry");V.addEventListener("click",()=>{y.replaceChildren(M("div","ocl-spinner","Loading…")),b()}),j.append(V),y.replaceChildren(j)})};h.addEventListener("input",()=>B(F,h.value.trim().toLowerCase())),b();let m=null,C,T,v=0,P=!1;const A=()=>{T||(T=setTimeout(()=>{T=void 0,b()},300))},Q=()=>{if(!U){try{m=new WebSocket(o)}catch{W();return}m.binaryType="arraybuffer",m.onopen=()=>{v=0,m.send(We({type:"auth",token:e})),m.send(We({type:"subscribe_inbox"})),P&&A(),P=!0},m.onmessage=k=>{const j=lt(new Uint8Array(k.data));j&&j.type==="inbox_event"&&A()},m.onclose=()=>{m=null,W()},m.onerror=()=>{try{m==null||m.close()}catch{}}}},W=()=>{if(U||C)return;const k=Math.min(15e3,500*2**v++)+Math.random()*250;C=setTimeout(()=>{C=void 0,Q()},k)};return Q(),{refresh:b,close(){U=!0,C&&clearTimeout(C),T&&clearTimeout(T),E==null||E.disconnect(),E=null;try{m==null||m.close()}catch{}m=null,t.el.replaceChildren()},defaultProfileId(){return t.profileId??z}}}const ii=Object.freeze(Object.defineProperty({__proto__:null,mountChatList:kt},Symbol.toStringTag,{value:"Module"})),ke=new WeakMap,ze=new Map;function St(t){return`relay-launcher::${t.profileId}::${t.subjectId??""}`}let Se=null;function oi(){if(Se&&Se.state!=="closed")return Se;try{return Se=new AudioContext,Se}catch{return null}}function si(t){const e=t.el;let n=null,o=null,i=!1;const s=()=>{n==null||n.close(),n=null,o==null||o.close(),o=null,e.innerHTML=""};function r(){i||(s(),o=kt({el:e,url:t.url,...t.apiUrl?{apiUrl:t.apiUrl}:{},...t.profileId?{profileId:t.profileId}:{},scope:t.inboxScope??"tenant",...t.token?{token:t.token}:{},...t.userId?{userId:t.userId}:{},...t.accent?{accent:t.accent}:{},...t.theme?{theme:t.theme}:{},...t.webfont===!1?{webfont:!1}:{},...t.locale?{locale:t.locale}:{},...t.i18n?{i18n:t.i18n}:{},onSelect:a=>p(a)}))}function p(a){if(i)return;s();const{subjectId:w,kind:f,peerId:h,...y}=t;n=Ye({...y,inbox:!1,launcher:!1,el:e,...a.profileId?{profileId:a.profileId}:{},...a.subjectId?{subjectId:a.subjectId}:{},...a.kind==="direct"&&a.peerId?{kind:"direct",peerId:a.peerId}:{},onBack:r})}return r(),{close(){i=!0,s()}}}function Ye(t){var de,ge,Te,Ee,Tt,Et,Ut,Pt;if(t.inbox)return si(t);ke.has(t.el)&&(ke.get(t.el).close(),ke.delete(t.el)),t.launcher&&((de=ze.get(St(t)))==null||de.close());const e=it();let n,o=!1;const i=t.token??t.userId??e,s=i!==e?e:void 0,{wsUrl:r,httpBase:p}=Ge(t.url,t.apiUrl);let a=new xn(i);const w=t.subjectId?`${i}::${t.subjectId}`:i,f=new In(w);let h,y=!1,S=null,E=null,z=null,K=null;!t.launcher&&!t.el.style.height&&t.el.clientHeight===0&&(t.el.style.width=t.el.style.width||"100%",t.el.style.height="600px");for(const d of f.load())a.addOptimistic(d.clientMsgId,d.content);let $=null,_=null,F=0,U=!t.launcher;if(t.launcher){const x=(t.position??"bottom-right").includes("right");$=document.createElement("div"),$.style.cssText=`position:fixed;${x?"right:20px":"left:20px"};bottom:20px;z-index:9999;display:flex;flex-direction:column;align-items:${x?"flex-end":"flex-start"};gap:12px`;const I=document.createElement("div"),N=typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(max-width: 479px)"):null,he=H=>{t.el.classList.toggle("ocw-fs",H),I.style.cssText=H?["position:fixed","inset:0","width:100%","height:100dvh","border-radius:0","overflow:hidden","box-shadow:none","display:none","flex-direction:column","background:#fff","transition:opacity .18s","opacity:0","z-index:9998"].join(";"):["width:min(380px, calc(100vw - 40px))","height:min(600px, calc(100dvh - 108px))","border-radius:28px","overflow:hidden","box-shadow:0 12px 32px rgba(108,92,231,.14)","display:none","flex-direction:column","background:#fff","transform-origin:bottom "+(x?"right":"left"),"transition:opacity .18s,transform .18s","opacity:0","transform:scale(.95)"].join(";")};he((N==null?void 0:N.matches)??!1);const Ue=H=>he(H.matches);N==null||N.addEventListener("change",Ue),S=N,E=Ue,t.el.style.cssText="width:100%;height:100%;overflow:hidden",I.append(t.el);const $e='<svg viewBox="0 0 24 24" width="26" height="26" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path d="M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z" fill="currentColor" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>',Re='<svg viewBox="0 0 24 24" width="22" height="22" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path d="M18 6 6 18M6 6l12 12" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"/></svg>',Y=document.createElement("button");Y.type="button",Y.style.cssText=["width:56px;height:56px;border-radius:50%",`background:${t.accent??"#6c5ce7"}`,"color:#fff;border:none;cursor:pointer","box-shadow:0 12px 32px rgba(108,92,231,.14)","position:relative;flex:none","display:flex;align-items:center;justify-content:center","transition:transform .15s"].join(";"),Y.onmouseenter=()=>{Y.style.transform="scale(1.08)"},Y.onmouseleave=()=>{Y.style.transform="scale(1)"},_=document.createElement("span"),_.style.cssText="position:absolute;top:-4px;right:-4px;background:#4c6fff;color:#fff;border-radius:50%;width:20px;height:20px;font-size:11px;font-weight:700;display:none;align-items:center;justify-content:center";const De=()=>{Y.innerHTML=U?Re:$e,Y.setAttribute("aria-label",U?"Close chat":"Open chat"),Y.setAttribute("aria-expanded",String(U)),Y.append(_)};De(),$.append(I,Y),document.body.append($);const Qe=`ocw-teaser-dismissed::${t.profileId}`,_e=typeof t.launcherMessage=="string"?{title:t.launcherMessage}:t.launcherMessage;let q=null;const pi=()=>{try{return sessionStorage.getItem(Qe)==="1"}catch{return!1}},ui='<svg viewBox="0 0 24 24" width="15" height="15" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path d="M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z" fill="currentColor" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>',Bt=()=>{const H=_e!=null&&_e.title?_e:a.launcherMessage??void 0;if(!(!!(H!=null&&H.title)&&!U&&!pi())){q&&(q.remove(),q=null);return}if(q)return;q=document.createElement("div"),q.setAttribute("role","button"),q.setAttribute("tabindex","0"),q.setAttribute("aria-label",H.title),q.style.cssText=["max-width:280px","background:#fff","border-radius:16px","box-shadow:0 12px 32px rgba(108,92,231,.14)","padding:14px 40px 14px 16px","position:relative","cursor:pointer","font-family:inherit",`align-self:${x?"flex-end":"flex-start"}`,"animation:ocw-teaser-in .22s ease-out"].join(";");const tt=document.createElement("div");if(tt.textContent=H.title,tt.style.cssText="font-size:15px;font-weight:600;color:#111;line-height:1.35",q.append(tt),H.subtitle){const se=document.createElement("div");se.style.cssText="display:flex;align-items:center;gap:6px;margin-top:6px;font-size:13px;color:#6b7280";const nt=document.createElement("span");nt.innerHTML=ui,nt.style.cssText=`color:${t.accent??"#6c5ce7"};display:inline-flex`;const Lt=document.createElement("span");Lt.textContent=H.subtitle,se.append(nt,Lt),q.append(se)}const ye=document.createElement("button");ye.type="button",ye.setAttribute("aria-label","Dismiss"),ye.innerHTML='<svg viewBox="0 0 24 24" width="14" height="14" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M18 6 6 18M6 6l12 12" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"/></svg>',ye.style.cssText="position:absolute;top:8px;right:8px;width:24px;height:24px;border:none;border-radius:50%;background:#f3f4f6;color:#6b7280;cursor:pointer;display:flex;align-items:center;justify-content:center;padding:0",ye.addEventListener("click",se=>{se.stopPropagation();try{sessionStorage.setItem(Qe,"1")}catch{}q&&(q.remove(),q=null)}),q.append(ye);const At=()=>{U||(U=!0,et(!0),De(),F=0,_&&(_.style.display="none"),q&&(q.remove(),q=null))};q.addEventListener("click",At),q.addEventListener("keydown",se=>{(se.key==="Enter"||se.key===" ")&&(se.preventDefault(),At())}),$.insertBefore(q,Y)};if(!document.getElementById("ocw-teaser-style")){const H=document.createElement("style");H.id="ocw-teaser-style",H.textContent="@keyframes ocw-teaser-in{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}",document.head.append(H)}K=Bt,Bt();const et=H=>{H?(I.style.display="flex",requestAnimationFrame(()=>{I.style.opacity="1",I.style.transform="scale(1)"})):(I.style.opacity="0",I.style.transform="scale(.95)",setTimeout(()=>{U||(I.style.display="none")},180))};Y.addEventListener("click",()=>{if(U=!U,et(U),De(),U){F=0,_&&(_.style.display="none");try{sessionStorage.setItem(Qe,"1")}catch{}}K==null||K()}),z=H=>{H.key==="Escape"&&U&&(U=!1,et(!1),De())},document.addEventListener("keydown",z)}const Z=()=>{U||(F++,_&&(_.textContent=String(F),_.style.display="flex"))},B=()=>{try{const d=oi();if(!d)return;d.state==="suspended"&&d.resume().catch(()=>{});const x=d.createOscillator(),I=d.createGain();x.connect(I),I.connect(d.destination),x.frequency.setValueAtTime(880,d.currentTime),x.frequency.exponentialRampToValueAtTime(440,d.currentTime+.15),I.gain.setValueAtTime(.3,d.currentTime),I.gain.exponentialRampToValueAtTime(.001,d.currentTime+.3),x.start(),x.stop(d.currentTime+.3)}catch{}},g=[],u=d=>{for(;g.length;){const x=g.shift();f.add({clientMsgId:x.clientMsgId,content:x.content,ts:Date.now()}),b.send({type:"send",conversationId:d,clientMsgId:x.clientMsgId,content:x.content})}};let b;const m=new Mn(`ocw-e2e-${t.profileId}`);let C=!1;const T=[],v=[];let P=!1;const A=(d,x)=>{m.sealText(x).then(I=>{h&&b.send({type:"send",conversationId:h,clientMsgId:d,content:I})})},Q=(d,x,I)=>{m.sealText(x,I).then(N=>{h&&b.send({type:"send",conversationId:h,clientMsgId:d,content:N})})},W=()=>{for(;T.length;){const d=T.shift();A(d.clientMsgId,d.text)}for(;v.length;){const d=v.shift();A(d.clientMsgId,d.text)}},k=d=>{b.send({type:"fetchPrekey",targetUserId:d})},j=vt(t.locale,t.i18n),V=["ar","he","fa","ur"],ee=typeof navigator<"u"?(navigator.language??"").slice(0,2).toLowerCase():"";V.includes(ee)&&!t.el.dir&&(t.el.dir="rtl",t.el.style.fontFamily=t.el.style.fontFamily||"Tahoma,Arial,system-ui,sans-serif");const X=`oc_prechat_${t.profileId}_${i.slice(-8)}`,R=new Vn(t.el,i,{onSend(d){const x=`cm_${Math.random().toString(36).slice(2)}`,I={kind:"text",text:d};a.addOptimistic(x,I),R.render(a),a.e2e?m.ready?A(x,d):P?v.push({clientMsgId:x,text:d}):(T.push({clientMsgId:x,text:d}),a.assignedAgentId&&k(a.assignedAgentId)):h?(f.add({clientMsgId:x,content:I,ts:Date.now()}),b.send({type:"send",conversationId:h,clientMsgId:x,content:I})):g.push({clientMsgId:x,content:I})},async onAttach(d){if(!h)return;const x=`${p}/upload?name=${encodeURIComponent(d.name)}`,I=`cm_${Math.random().toString(36).slice(2)}`;a.addOptimistic(I,{kind:"text",text:`📎 Uploading ${d.name}…`}),R.render(a);try{const N=await fetch(x,{method:"POST",headers:{"content-type":d.type,authorization:`Bearer ${i}`},body:d});if(!N.ok)throw new Error(`Upload failed: ${N.status}`);const{url:he,name:Ue,mime:$e,size:Re}=await N.json();a.addOptimistic(I,{kind:"attachment",url:he,name:Ue,mime:$e,size:Re}),R.render(a),b.send({type:"send",conversationId:h,clientMsgId:I,content:{kind:"attachment",url:he,name:Ue,mime:$e,size:Re}})}catch(N){a.addOptimistic(I,{kind:"text",text:`⚠️ Upload failed: ${N.message}`}),R.render(a)}},onInvoke(d,x){h&&b.send({type:"invoke",conversationId:h,actionId:d,clientInvokeId:`iv_${Math.random().toString(36).slice(2)}`,...x?{inputs:x}:{}})},onTyping(d,x){h&&b.send({type:"typing",conversationId:h,isTyping:d,...x?{preview:x}:{}})},onPreChat(d){try{localStorage.setItem(X,"1")}catch{}b.send({type:"open",profileId:t.profileId,...t.subjectId?{subjectId:t.subjectId}:{},userInfo:{...d.name?{name:d.name}:{},...d.email?{email:d.email}:{},...d.phone||d.topic?{meta:{...d.phone?{phone:d.phone}:{},...d.topic?{topic:d.topic}:{}}}:{}}});const x=d.callback?`📞 Call-back requested${d.phone?`: ${d.phone}`:""}${d.topic?` — ${d.topic}`:""}`:d.topic?`Topic: ${d.topic}`:"";x&&h&&!a.e2e&&b.send({type:"send",conversationId:h,clientMsgId:`pc_${Math.random().toString(36).slice(2,12)}`,content:{kind:"text",text:x}})},...((ge=t.features)==null?void 0:ge.deflection)!==!1?{onDeflectQuery(d){if(o)return;clearTimeout(n);const x=d.trim();if(x.length<3){R.hideDeflection();return}n=setTimeout(()=>{fetch(`${p}/kb/search?profileId=${encodeURIComponent(t.profileId)}&q=${encodeURIComponent(x.slice(0,200))}`).then(I=>I.ok?I.json():{articles:[]}).then(I=>R.showDeflection(I.articles??[])).catch(()=>R.hideDeflection())},350)}}:{},onReadUpTo(d){h&&b.send({type:"read",conversationId:h,seq:d})},onLoadMore(){if(!h||!a.e2e)return;const d=a.messages()[0];d&&b.send({type:"history",conversationId:h,beforeSeq:d.seq,limit:20})},onEdit(d,x){h&&b.send({type:"edit",conversationId:h,messageId:d,content:{kind:"text",text:x}})},onDelete(d){h&&b.send({type:"delete",conversationId:h,messageId:d})},...((Te=t.features)==null?void 0:Te.reactions)!==!1?{onReact(d,x,I){h&&b.send({type:"react",conversationId:h,messageId:d,emoji:x,remove:I})}}:{},...((Ee=t.features)==null?void 0:Ee.csat)!==!1?{onCsat(d){h&&fetch(`${p}/conversations/${h}/csat`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({score:d})}).catch(()=>{})}}:{},...(()=>{const d=t.locale??(typeof navigator<"u"?navigator.language:""),x=t.translateLang!==void 0?t.translateLang:d?d.split("-")[0]:bt();return x?{async onTranslate(I){try{const N=await fetch(`${p}/translate`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${i}`},body:JSON.stringify({text:I,targetLang:x})});if(!N.ok)return null;const{translated:he}=await N.json();return he}catch{return null}}}:{}})(),...t.onBack?{onBack:t.onBack}:{}},{...t.subject?{subject:t.subject}:{},...t.quickReplies?{quickReplies:t.quickReplies}:{},...t.accent?{accent:t.accent}:{},...t.accent2?{accent2:t.accent2}:{},...t.theme?{theme:t.theme}:{},...t.webfont===!1?{webfont:!1}:{},...(Tt=t.user)!=null&&Tt.name||(Et=t.user)!=null&&Et.avatar?{userInfo:{...t.user.name?{name:t.user.name}:{},...t.user.avatar?{avatar:t.user.avatar}:{}}}:{},i18n:j});try{localStorage.getItem(X)&&R.completePreChat()}catch{}const L=t.user&&(t.user.name||t.user.email||t.user.avatar||t.user.meta)?{...t.user.name?{name:t.user.name}:{},...t.user.email?{email:t.user.email}:{},...t.user.avatar?{avatar:t.user.avatar}:{},...t.user.meta?{meta:t.user.meta}:{}}:void 0,fe={type:"open",profileId:t.profileId,...t.kind==="direct"&&t.peerId?{kind:"direct",peerId:t.peerId}:t.subjectId?{subjectId:t.subjectId}:{},...s?{linkFrom:s}:{},...L?{userInfo:L}:{},...typeof location<"u"?{pageUrl:location.href}:{},...typeof document<"u"&&document.title?{pageTitle:document.title}:{},...(Ut=t.subject)!=null&&Ut.title?{subjectTitle:t.subject.title}:{},...(Pt=t.subject)!=null&&Pt.subtitle?{subjectMeta:t.subject.subtitle}:{}};b=new mn({...t.refreshToken?{refreshToken:t.refreshToken}:{},url:r,token:i,open:fe,getCursor:()=>a.highestSeq(),onStatusChange:(d,x)=>R.setConnStatus(d,x),onFrame(d){if(d.type==="opened"){if(h=d.conversation.id,!y){y=!0;for(const x of f.load())b.send({type:"send",conversationId:h,clientMsgId:x.clientMsgId,content:x.content})}Zn(r,i,h,a,R,p),g.length&&u(h)}if(d.type==="ack"&&f.remove(d.clientMsgId),d.type==="prekeyBundle"){d.bundle&&(P=!0,m.x3dhSendTo(d.bundle).then(x=>{const I=[...T.splice(0),...v.splice(0)];for(const N of I)Q(N.clientMsgId,N.text,x);R.render(a)}));return}if(d.type==="message"&&a.e2e){const x=Kn(d.message.content);if(x&&!m.ready){m.x3dhReceiveFrom(x.x3dhIK,x.x3dhEK,x.x3dhSPK,x.x3dhOTP).then(async()=>{await m.openFrame(d),a.apply(d),R.render(a)});return}}if(d.type==="peerkey"){m.onPeerKey(d.key).then(()=>{W(),R.render(a)});return}(async()=>{if(a.e2e&&await m.openFrame(d),a.apply(d),d.type==="manifest"){K==null||K();const x=d.botName;x&&R.setBotName(x)}if(d.type==="message"&&d.message.senderId!==i&&!d.message.internal&&(Z(),B()),a.e2e&&h&&!C){C=!0;const x=await m.initX3DH();b.send({type:"uploadPrekeys",...x});const I=await m.begin();b.send({type:"pubkey",conversationId:h,key:I})}R.render(a)})()}}),b.connect(),R.render(a);const oe=t.launcher?St(t):null,we={close:()=>{o=!0,clearTimeout(n),b.close(),$==null||$.remove(),R.destroy(),S&&E&&S.removeEventListener("change",E),z&&(document.removeEventListener("keydown",z),z=null),ke.delete(t.el),oe&&ze.get(oe)===we&&ze.delete(oe)}};return ke.set(t.el,we),oe&&ze.set(oe,we),we}const Je="wss://api.paramms.com/ws";function ri(t,e){const n=t.profileId??t.appId;if(!n)throw new Error("Relay: `profileId` is required (your chatroom id, e.g. 'p_...').");const o=t.subjectId??(t.listingId?`listing_${t.listingId}`:void 0),i=t.launcher??!0,s=t.contextTitle??t.listingTitle??t.subjectTitle,r=t.contextSubtitle??t.listingMeta??t.subjectMeta,p=t.contextStatus??t.listingStatus??t.subjectStatus,a=t.listingPrice??t.subjectPrice,w=s?{title:s,...r?{subtitle:r}:{},...a!=null?{tags:[`$${a.toLocaleString()}`]}:{},...p?{status:p}:{}}:void 0,f=t.subject??w,h=t.userName??t.name,y=t.userEmail??t.email,S=t.userAvatar??t.avatar,E=h||y||S?{...h?{name:h}:{},...y?{email:y}:{},...S?{avatar:S}:{}}:void 0,z=t.user??E,K=t.launcherMessage&&typeof t.launcherMessage=="object"?t.launcherMessage:t.launcherMessage?t.launcherSubtitle?{title:t.launcherMessage,subtitle:t.launcherSubtitle}:t.launcherMessage:void 0;return{el:e,url:t.url??Je,profileId:n,...t.apiUrl?{apiUrl:t.apiUrl}:{},...o?{subjectId:o}:{},...t.token?{token:t.token}:{},...t.refreshToken?{refreshToken:t.refreshToken}:{},...t.userId?{userId:t.userId}:{},...f?{subject:f}:{},...z?{user:z}:{},...t.quickReplies?{quickReplies:t.quickReplies}:{},...t.i18n?{i18n:t.i18n}:{},...t.features?{features:t.features}:{},...t.accent?{accent:t.accent}:{},...t.accent2?{accent2:t.accent2}:{},...t.theme?{theme:t.theme}:{},...t.locale?{locale:t.locale}:{},...t.webfont===!1?{webfont:!1}:{},...t.translateLang?{translateLang:t.translateLang}:{},...K?{launcherMessage:K}:{},...It(t)&&!i?{onBack:()=>{Ie=!0,Ce=!1,Me(le)}}:{},launcher:i,position:t.position??"bottom-right"}}let ne=null,O=null,ce=!1,le={},Ie=!1,Ce=!1;function It(t){return!!(t.inbox||t.inboxStart)}let ie=null;function ai(t,e){const n=!e&&!!t.el;if(ce&&!n&&(O.innerHTML="",O=null,ce=!1),n){const o=typeof t.el=="string"?document.querySelector(t.el):t.el;o instanceof HTMLElement?(O&&O!==o&&!ce&&O.remove(),O=o,ce=!0):console.error(`[Relay] \`el\` ("${String(t.el)}") did not match any element — falling back to an auto-created host.`)}return(!O||!ce&&!O.isConnected)&&(O=document.createElement("div"),O.id="relay-widget-root",document.body.appendChild(O),ce=!1),!e&&t.height&&(O.style.height=t.height,O.style.width||(O.style.width="100%")),O}function Me(t){try{const e=t.launcher??!0;ie==null||ie(),ie=null,ne==null||ne.close(),ne=null;const n=ai(t,e);if(It(t)&&!e&&Ie){ci(t,n);return}ne=Ye(ri(t,n))}catch(e){console.error("[Relay]",e instanceof Error?e.message:e)}}async function ci(t,e){const n=t.profileId??t.appId;if(!n&&!t.tenantId){console.error("[Relay] `inbox` requires `profileId` or `tenantId`.");return}e.innerHTML="";const o=document.createElement("div");o.style.cssText="position:relative;width:100%;height:100%;overflow:hidden;background:#fff";const i=document.createElement("div");i.style.cssText="position:absolute;inset:0";const s=document.createElement("div");s.style.cssText="position:absolute;inset:0;display:none";const r=document.createElement("button");r.type="button",r.setAttribute("aria-label","Close"),r.textContent="✕",r.style.cssText="position:absolute;top:8px;right:8px;z-index:20;width:32px;height:32px;border-radius:50%;display:flex;align-items:center;justify-content:center;background:rgba(0,0,0,.05);border:none;color:#1c1b1a;font-size:16px;line-height:1;cursor:pointer",r.onclick=()=>{Ie=!1,Me(le)},o.append(i,s);const p=!Ce&&!!n;p&&o.append(r),e.appendChild(o);let a=null,w=null;ie=()=>{w==null||w.close(),a==null||a.close(),e.innerHTML=""};let f;try{({mountChatList:f}=await Promise.resolve().then(()=>ii))}catch(y){console.error("[Relay] could not load the conversation list module.",y),i.isConnected&&(i.style.cssText+=";display:flex;align-items:center;justify-content:center;padding:16px;font:13px system-ui;color:#b91c1c;text-align:center",i.textContent="Could not load conversations.");return}if(!i.isConnected)return;const h=y=>{const S=y.profileId??n;if(!S){console.error("[Relay] conversation row has no chatroom; cannot open it.",y);return}r.style.display="none",w==null||w.close(),w=Ye({el:s,url:t.url??Je,...t.apiUrl?{apiUrl:t.apiUrl}:{},profileId:S,...y.kind==="direct"&&y.peerId?{kind:"direct",peerId:y.peerId}:y.subjectId?{subjectId:y.subjectId}:{},...t.token?{token:t.token}:{},...t.refreshToken?{refreshToken:t.refreshToken}:{},...t.userId?{userId:t.userId}:{},...t.userId||t.userName||t.userEmail||t.userAvatar?{user:{...t.userName?{name:t.userName}:{},...t.userEmail?{email:t.userEmail}:{},...t.userAvatar?{avatar:t.userAvatar}:{}}}:{},...y.subjectTitle?{subject:{title:y.subjectTitle,...y.subjectMeta?{subtitle:y.subjectMeta}:{}}}:{},...t.accent?{accent:t.accent}:{},launcher:!1,onBack:()=>{w==null||w.close(),w=null,s.style.display="none",i.style.display="",r.style.display="",a==null||a.refresh()}}),i.style.display="none",s.style.display=""};a=f({el:i,url:t.url??Je,...t.apiUrl?{apiUrl:t.apiUrl}:{},...n?{profileId:n}:{},...t.tenantId?{tenantId:t.tenantId}:{},scope:t.inboxScope??"tenant",...p?{reserveCloseSpace:!0}:{},onSelect:h,onNewChat:()=>{const y=n??(a==null?void 0:a.defaultProfileId());y&&h({id:"__new__",profileId:y,state:"open",updatedAt:Date.now()})},...t.token?{token:t.token}:{},...t.userId?{userId:t.userId}:{},...t.accent?{accent:t.accent}:{}})}function Ct(t){Ce=!!(t.inboxStart&&!(t.launcher??!0)),Ie=Ce,le={...t},Me(le)}function li(t){le={...le,...t},Me(le)}function di(){ie==null||ie(),ie=null,ne==null||ne.close(),ne=null,O&&!ce&&O.remove(),O=null,ce=!1,Ie=!1,Ce=!1,le={}}function Ze(t,e){switch(t){case"boot":Ct(e??{});break;case"update":case"identify":li(e??{});break;case"shutdown":di();break;default:console.warn("[Relay] unknown command:",t)}}function hi(){if(typeof document>"u")return null;const t=document.querySelector("script[data-relay-app]")??document.querySelector("script[data-relay-profile-id]")??document.querySelector("script[data-relay-tenant-id]"),e=t==null?void 0:t.dataset,n=(e==null?void 0:e.relayApp)??(e==null?void 0:e.relayProfileId),o=e==null?void 0:e.relayTenantId;if(!n&&!o)return null;const i=n?{profileId:n}:{};o&&(i.tenantId=o),e.relayUser&&(i.userId=e.relayUser),e.relayToken&&(i.token=e.relayToken),e.relayListing&&(i.listingId=e.relayListing),e.relayAccent&&(i.accent=e.relayAccent),e.relayAccent2&&(i.accent2=e.relayAccent2),e.relayTheme&&(i.theme=e.relayTheme),e.relayLocale&&(i.locale=e.relayLocale),e.relayWebfont==="false"&&(i.webfont=!1),e.relayUrl&&(i.url=e.relayUrl);const s=e.relayPosition;(s==="bottom-left"||s==="bottom-right")&&(i.position=s),e.relayLauncherMessage&&(i.launcherMessage=e.relayLauncherMessage),e.relayLauncherSubtitle&&(i.launcherSubtitle=e.relayLauncherSubtitle),e.relayLauncher==="false"&&(i.launcher=!1),e.relayUserName&&(i.userName=e.relayUserName),e.relayUserEmail&&(i.userEmail=e.relayUserEmail),e.relayUserAvatar&&(i.userAvatar=e.relayUserAvatar),e.relayContextTitle&&(i.contextTitle=e.relayContextTitle),e.relayContextSubtitle&&(i.contextSubtitle=e.relayContextSubtitle),e.relayContextStatus&&(i.contextStatus=e.relayContextStatus),e.relayListingTitle&&(i.listingTitle=e.relayListingTitle),e.relayListingMeta&&(i.listingMeta=e.relayListingMeta),e.relayListingPrice&&(i.listingPrice=Number(e.relayListingPrice)),e.relayListingStatus&&(i.listingStatus=e.relayListingStatus),e.relayTarget&&(i.el=e.relayTarget),e.relayHeight&&(i.height=e.relayHeight),e.relayInbox==="true"&&(i.inbox=!0),e.relayInbox==="false"&&(i.inbox=!1),e.relayInboxStart==="true"&&(i.inboxStart=!0),e.relayInboxStart==="false"&&(i.inboxStart=!1);const r=e.relayInboxScope;return(r==="tenant"||r==="profile")&&(i.inboxScope=r),e.relayTranslateLang&&(i.translateLang=e.relayTranslateLang),i}if(typeof window<"u"){const t=window,e=t.Relay&&t.Relay.q?t.Relay.q:[];t.Relay=Ze;let n=!1;for(const o of e){const[i,s]=o;i==="boot"&&(n=!0),Ze(i,s)}if(!n){const o=t.relaySettings??hi();o&&Ct(o)}}return te.Relay=Ze,Object.defineProperty(te,Symbol.toStringTag,{value:"Module"}),te}({});
239
+ `,ei={en:{placeholder:"Message…",offline:"We're offline right now",online:"Online",away:"Away",aiAssistant:"AI Assistant",resolved:"Marked as resolved",reopen:"Reopen conversation",sources:"Sources",helpful:"Helpful",notHelpful:"Not helpful",title:"Your conversations",newChat:"New conversation",startChat:"Start a conversation",all:"All conversations",empty:"No conversations yet.",error:"Could not load conversations.",retry:"Retry",search:"🔍 Search",unread:"Unread",close:"Close"},ko:{placeholder:"메시지…",offline:"지금은 오프라인입니다",online:"온라인",away:"자리 비움",aiAssistant:"AI 어시스턴트",resolved:"해결됨으로 표시됨",reopen:"대화 다시 열기",sources:"출처",helpful:"도움돼요",notHelpful:"도움 안돼요",title:"내 대화",newChat:"새 대화",startChat:"대화 시작하기",all:"전체 대화",empty:"아직 대화가 없습니다.",error:"대화를 불러오지 못했습니다.",retry:"다시 시도",search:"🔍 검색",unread:"읽지 않음",close:"닫기"}};function bt(t){const e=(t??(typeof navigator<"u"?navigator.language:"")??"").toLowerCase();return e.startsWith("ko")||e.includes("korean")||e.includes("한국")?"ko":"en"}function vt(t,e){const n=ei[bt(t)],o={};for(const[i,s]of Object.entries(e??{}))typeof s=="string"&&s!==""&&(o[i]=s);return{...n,...o}}function ti(t){switch(t){case"open":return{label:"Open",cls:"open"};case"awaiting_staff":return{label:"Waiting on you",cls:"waiting"};case"resolved":return{label:"Resolved",cls:"done"};case"closed":return{label:"Closed",cls:"done"};default:return null}}function ni(t){const e=Math.floor((Date.now()-t)/1e3);if(e<60)return"just now";if(e<3600)return`${Math.floor(e/60)}m`;if(e<86400)return`${Math.floor(e/3600)}h`;const n=Math.floor(e/86400);if(n<=7)return`${n}d`;try{return new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric"})}catch{return`${n}d`}}function z(t,e,n){const o=document.createElement(t);return e&&(o.className=e),n!==void 0&&(o.textContent=n),o}function kt(t){const e=t.token??t.userId??it(),{httpBase:n,wsUrl:o}=Ge(t.url,t.apiUrl),i=vt(t.locale,t.i18n),s=t.accent??"#6c5ce7";if(!document.getElementById("ocl-styles")){const k=document.createElement("style");k.id="ocl-styles",k.textContent=Qn,document.head.append(k)}if(t.webfont!==!1&&typeof document<"u"&&!document.getElementById("ocw-webfont")){const k=document.createElement("link");k.id="ocw-webfont",k.rel="stylesheet",k.href="https://fonts.googleapis.com/css2?family=Baloo+2:wght@500;600;700&family=Nunito:wght@400;500;600;700&display=swap",document.head.append(k)}const r=z("div","ocl");r.style.setProperty("--ocl-accent",s),r.dataset.theme=t.theme??"light",t.reserveCloseSpace&&r.classList.add("ocl-has-close");const p=z("div","ocl-head"),a=i.title??"Your conversations",w=z("span","ocl-title",a);if(w.setAttribute("aria-label",a),p.append(w),t.onNewChat){const k=z("button","ocl-compose","✎");k.title=i.newChat??"New conversation",k.addEventListener("click",()=>t.onNewChat()),p.append(k)}const f=z("div","ocl-search-wrap"),h=z("input","ocl-search");h.placeholder=i.search??"🔍 Search",h.type="search",f.append(h);const y=z("div","ocl-body");y.append(z("div","ocl-spinner","Loading…")),r.append(p,f,y),t.el.replaceChildren(r);const S=k=>{r.classList.toggle("ocl-compact",k>0&&k<400)};S(r.clientWidth);let E=null;if(typeof ResizeObserver<"u"&&(E=new ResizeObserver(k=>{var j;return S(((j=k[0])==null?void 0:j.contentRect.width)??r.clientWidth)}),E.observe(r)),!t.profileId&&!t.tenantId)throw new Error("[relay chatlist] provide profileId or tenantId");let M;const K=`ocl_seen_${t.profileId??`t_${t.tenantId}`}_${(t.userId??e).slice(-8)}`;let $={};try{$=JSON.parse(localStorage.getItem(K)??"{}")}catch{}const _=()=>{try{localStorage.setItem(K,JSON.stringify($))}catch{}};let F=[],U=!1;const Z=async()=>{const k=t.profileId?`profileId=${encodeURIComponent(t.profileId)}${t.scope==="tenant"?"&scope=tenant":""}`:`tenantId=${encodeURIComponent(t.tenantId)}`,j=`${n}/conversations/mine?${k}`,V={authorization:`Bearer ${e}`};let ee;try{ee=await fetch(j,{headers:V})}catch{ee=await fetch(j,{headers:V})}if(!ee.ok)return[];const X=await ee.json();return X.defaultProfileId&&(M=X.defaultProfileId),(X.conversations??[]).sort((R,L)=>L.updatedAt-R.updatedAt)},B=(k,j)=>{if(U)return;const V=j?k.filter(L=>g(L).toLowerCase().includes(j)||(L.lastMessage??"").toLowerCase().includes(j)):k;if(y.replaceChildren(),!V.length){const L=z("div","ocl-empty",j?"No results.":i.empty??"No conversations yet.");if(!j&&t.onNewChat){L.append(z("br"));const fe=z("button","ocl-start",i.startChat??"Start a conversation");fe.addEventListener("click",()=>t.onNewChat()),L.append(fe)}y.append(L);return}const ee=L=>(L.lastSeq??0)>($[L.id]??0),X=V.filter(ee),R=V.filter(L=>!ee(L));if(X.length){y.append(z("div","ocl-section",`${i.unread??"Unread"} (${X.length})`));for(const L of X)y.append(u(L,ee(L)))}if(R.length){y.append(z("div","ocl-section",X.length?i.all??"All conversations":""));for(const L of R)y.append(u(L,!1))}},g=k=>k.subjectTitle??(k.kind==="direct"?k.peerId??"Direct message":"General enquiry"),u=(k,j)=>{var Te;const V=g(k),ee=(((Te=V.match(new RegExp("\\p{L}","u")))==null?void 0:Te[0])??V.trim()[0]??"?").toUpperCase(),X=k.lastSeq??0,R=j?Math.max(1,X-($[k.id]??0)):0,L=z("button",`ocl-row${j?" unread":""}`),fe=z("div","ocl-av",ee);L.append(fe);const oe=z("div","ocl-info");oe.append(z("div","ocl-name",V));const we={open:"Open",awaiting_staff:"Waiting for reply…",resolved:"Resolved ✓",closed:"Closed"};oe.append(z("div","ocl-preview",k.lastMessage??we[k.state]??k.state)),L.append(oe);const de=z("div","ocl-right");de.append(z("div","ocl-time",ni(k.updatedAt)));const ge=ti(k.state);return ge&&de.append(z("div",`ocl-status ${ge.cls}`,ge.label)),R>0&&de.append(z("div","ocl-badge",String(R>99?"99+":R))),L.append(de),L.addEventListener("click",()=>{var Ee;X>0&&($[k.id]=X,_()),L.classList.remove("unread"),(Ee=de.querySelector(".ocl-badge"))==null||Ee.remove(),t.onSelect(k)}),L},b=()=>{U||Z().then(k=>{U||(F=k,B(k,h.value.trim().toLowerCase()))}).catch(k=>{if(U)return;console.error(`[chat-widget] failed to load conversations from ${n}/conversations/mine — check the apiUrl/CORS config.`,k);const j=z("div","ocl-empty",i.error??"Could not load conversations.");j.append(z("br"));const V=z("button","ocl-retry",i.retry??"Retry");V.addEventListener("click",()=>{y.replaceChildren(z("div","ocl-spinner","Loading…")),b()}),j.append(V),y.replaceChildren(j)})};h.addEventListener("input",()=>B(F,h.value.trim().toLowerCase())),b();let m=null,C,T,v=0,P=!1;const A=()=>{T||(T=setTimeout(()=>{T=void 0,b()},300))},Q=()=>{if(!U){try{m=new WebSocket(o)}catch{W();return}m.binaryType="arraybuffer",m.onopen=()=>{v=0,m.send(We({type:"auth",token:e})),m.send(We({type:"subscribe_inbox"})),P&&A(),P=!0},m.onmessage=k=>{const j=lt(new Uint8Array(k.data));j&&j.type==="inbox_event"&&A()},m.onclose=()=>{m=null,W()},m.onerror=()=>{try{m==null||m.close()}catch{}}}},W=()=>{if(U||C)return;const k=Math.min(15e3,500*2**v++)+Math.random()*250;C=setTimeout(()=>{C=void 0,Q()},k)};return Q(),{refresh:b,close(){U=!0,C&&clearTimeout(C),T&&clearTimeout(T),E==null||E.disconnect(),E=null;try{m==null||m.close()}catch{}m=null,t.el.replaceChildren()},defaultProfileId(){return t.profileId??M}}}const ii=Object.freeze(Object.defineProperty({__proto__:null,mountChatList:kt},Symbol.toStringTag,{value:"Module"})),ke=new WeakMap,Me=new Map;function St(t){return`relay-launcher::${t.profileId}::${t.subjectId??""}`}let Se=null;function oi(){if(Se&&Se.state!=="closed")return Se;try{return Se=new AudioContext,Se}catch{return null}}function si(t){const e=t.el;let n=null,o=null,i=!1;const s=()=>{n==null||n.close(),n=null,o==null||o.close(),o=null,e.innerHTML=""};function r(){i||(s(),o=kt({el:e,url:t.url,...t.apiUrl?{apiUrl:t.apiUrl}:{},...t.profileId?{profileId:t.profileId}:{},scope:t.inboxScope??"tenant",...t.token?{token:t.token}:{},...t.userId?{userId:t.userId}:{},...t.accent?{accent:t.accent}:{},...t.theme?{theme:t.theme}:{},...t.webfont===!1?{webfont:!1}:{},...t.locale?{locale:t.locale}:{},...t.i18n?{i18n:t.i18n}:{},onSelect:a=>p(a)}))}function p(a){if(i)return;s();const{subjectId:w,kind:f,peerId:h,...y}=t;n=Ye({...y,inbox:!1,launcher:!1,el:e,...a.profileId?{profileId:a.profileId}:{},...a.subjectId?{subjectId:a.subjectId}:{},...a.kind==="direct"&&a.peerId?{kind:"direct",peerId:a.peerId}:{},onBack:r})}return r(),{close(){i=!0,s()}}}function Ye(t){var de,ge,Te,Ee,Tt,Et,Ut,Pt;if(t.inbox)return si(t);ke.has(t.el)&&(ke.get(t.el).close(),ke.delete(t.el)),t.launcher&&((de=Me.get(St(t)))==null||de.close());const e=it();let n,o=!1;const i=t.token??t.userId??e,s=i!==e?e:void 0,{wsUrl:r,httpBase:p}=Ge(t.url,t.apiUrl);let a=new xn(i);const w=t.subjectId?`${i}::${t.subjectId}`:i,f=new In(w);let h,y=!1,S=null,E=null,M=null,K=null;!t.launcher&&!t.el.style.height&&t.el.clientHeight===0&&(t.el.style.width=t.el.style.width||"100%",t.el.style.height="600px");for(const d of f.load())a.addOptimistic(d.clientMsgId,d.content);let $=null,_=null,F=0,U=!t.launcher;if(t.launcher){const x=(t.position??"bottom-right").includes("right");$=document.createElement("div"),$.style.cssText=`position:fixed;${x?"right:20px":"left:20px"};bottom:20px;z-index:9999;display:flex;flex-direction:column;align-items:${x?"flex-end":"flex-start"};gap:12px`;const I=document.createElement("div"),N=typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(max-width: 479px)"):null,he=H=>{t.el.classList.toggle("ocw-fs",H),I.style.cssText=H?["position:fixed","inset:0","width:100%","height:100dvh","border-radius:0","overflow:hidden","box-shadow:none","display:none","flex-direction:column","background:#fff","transition:opacity .18s","opacity:0","z-index:9998"].join(";"):["width:min(380px, calc(100vw - 40px))","height:min(600px, calc(100dvh - 108px))","border-radius:28px","overflow:hidden","box-shadow:0 12px 32px rgba(108,92,231,.14)","display:none","flex-direction:column","background:#fff","transform-origin:bottom "+(x?"right":"left"),"transition:opacity .18s,transform .18s","opacity:0","transform:scale(.95)"].join(";")};he((N==null?void 0:N.matches)??!1);const Ue=H=>he(H.matches);N==null||N.addEventListener("change",Ue),S=N,E=Ue,t.el.style.cssText="width:100%;height:100%;overflow:hidden",I.append(t.el);const $e='<svg viewBox="0 0 24 24" width="26" height="26" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path d="M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z" fill="currentColor" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>',Re='<svg viewBox="0 0 24 24" width="22" height="22" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path d="M18 6 6 18M6 6l12 12" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"/></svg>',Y=document.createElement("button");Y.type="button",Y.style.cssText=["width:56px;height:56px;border-radius:50%",`background:${t.accent??"#6c5ce7"}`,"color:#fff;border:none;cursor:pointer","box-shadow:0 12px 32px rgba(108,92,231,.14)","position:relative;flex:none","display:flex;align-items:center;justify-content:center","transition:transform .15s"].join(";"),Y.onmouseenter=()=>{Y.style.transform="scale(1.08)"},Y.onmouseleave=()=>{Y.style.transform="scale(1)"},_=document.createElement("span"),_.style.cssText="position:absolute;top:-4px;right:-4px;background:#4c6fff;color:#fff;border-radius:50%;width:20px;height:20px;font-size:11px;font-weight:700;display:none;align-items:center;justify-content:center";const De=()=>{Y.innerHTML=U?Re:$e,Y.setAttribute("aria-label",U?"Close chat":"Open chat"),Y.setAttribute("aria-expanded",String(U)),Y.append(_)};De(),$.append(I,Y),document.body.append($);const Qe=`ocw-teaser-dismissed::${t.profileId}`,_e=typeof t.launcherMessage=="string"?{title:t.launcherMessage}:t.launcherMessage;let q=null;const pi=()=>{try{return sessionStorage.getItem(Qe)==="1"}catch{return!1}},ui='<svg viewBox="0 0 24 24" width="15" height="15" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path d="M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z" fill="currentColor" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>',Bt=()=>{const H=_e!=null&&_e.title?_e:a.launcherMessage??void 0;if(!(!!(H!=null&&H.title)&&!U&&!pi())){q&&(q.remove(),q=null);return}if(q)return;q=document.createElement("div"),q.setAttribute("role","button"),q.setAttribute("tabindex","0"),q.setAttribute("aria-label",H.title),q.style.cssText=["max-width:280px","background:#fff","border-radius:16px","box-shadow:0 12px 32px rgba(108,92,231,.14)","padding:14px 40px 14px 16px","position:relative","cursor:pointer","font-family:inherit",`align-self:${x?"flex-end":"flex-start"}`,"animation:ocw-teaser-in .22s ease-out"].join(";");const tt=document.createElement("div");if(tt.textContent=H.title,tt.style.cssText="font-size:15px;font-weight:600;color:#111;line-height:1.35",q.append(tt),H.subtitle){const se=document.createElement("div");se.style.cssText="display:flex;align-items:center;gap:6px;margin-top:6px;font-size:13px;color:#6b7280";const nt=document.createElement("span");nt.innerHTML=ui,nt.style.cssText=`color:${t.accent??"#6c5ce7"};display:inline-flex`;const Lt=document.createElement("span");Lt.textContent=H.subtitle,se.append(nt,Lt),q.append(se)}const ye=document.createElement("button");ye.type="button",ye.setAttribute("aria-label","Dismiss"),ye.innerHTML='<svg viewBox="0 0 24 24" width="14" height="14" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M18 6 6 18M6 6l12 12" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"/></svg>',ye.style.cssText="position:absolute;top:8px;right:8px;width:24px;height:24px;border:none;border-radius:50%;background:#f3f4f6;color:#6b7280;cursor:pointer;display:flex;align-items:center;justify-content:center;padding:0",ye.addEventListener("click",se=>{se.stopPropagation();try{sessionStorage.setItem(Qe,"1")}catch{}q&&(q.remove(),q=null)}),q.append(ye);const At=()=>{U||(U=!0,et(!0),De(),F=0,_&&(_.style.display="none"),q&&(q.remove(),q=null))};q.addEventListener("click",At),q.addEventListener("keydown",se=>{(se.key==="Enter"||se.key===" ")&&(se.preventDefault(),At())}),$.insertBefore(q,Y)};if(!document.getElementById("ocw-teaser-style")){const H=document.createElement("style");H.id="ocw-teaser-style",H.textContent="@keyframes ocw-teaser-in{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}",document.head.append(H)}K=Bt,Bt();const et=H=>{H?(I.style.display="flex",requestAnimationFrame(()=>{I.style.opacity="1",I.style.transform="scale(1)"})):(I.style.opacity="0",I.style.transform="scale(.95)",setTimeout(()=>{U||(I.style.display="none")},180))};Y.addEventListener("click",()=>{if(U=!U,et(U),De(),U){F=0,_&&(_.style.display="none");try{sessionStorage.setItem(Qe,"1")}catch{}}K==null||K()}),M=H=>{H.key==="Escape"&&U&&(U=!1,et(!1),De())},document.addEventListener("keydown",M)}const Z=()=>{U||(F++,_&&(_.textContent=String(F),_.style.display="flex"))},B=()=>{try{const d=oi();if(!d)return;d.state==="suspended"&&d.resume().catch(()=>{});const x=d.createOscillator(),I=d.createGain();x.connect(I),I.connect(d.destination),x.frequency.setValueAtTime(880,d.currentTime),x.frequency.exponentialRampToValueAtTime(440,d.currentTime+.15),I.gain.setValueAtTime(.3,d.currentTime),I.gain.exponentialRampToValueAtTime(.001,d.currentTime+.3),x.start(),x.stop(d.currentTime+.3)}catch{}},g=[],u=d=>{for(;g.length;){const x=g.shift();f.add({clientMsgId:x.clientMsgId,content:x.content,ts:Date.now()}),b.send({type:"send",conversationId:d,clientMsgId:x.clientMsgId,content:x.content})}};let b;const m=new zn(`ocw-e2e-${t.profileId}`);let C=!1;const T=[],v=[];let P=!1;const A=(d,x)=>{m.sealText(x).then(I=>{h&&b.send({type:"send",conversationId:h,clientMsgId:d,content:I})})},Q=(d,x,I)=>{m.sealText(x,I).then(N=>{h&&b.send({type:"send",conversationId:h,clientMsgId:d,content:N})})},W=()=>{for(;T.length;){const d=T.shift();A(d.clientMsgId,d.text)}for(;v.length;){const d=v.shift();A(d.clientMsgId,d.text)}},k=d=>{b.send({type:"fetchPrekey",targetUserId:d})},j=vt(t.locale,t.i18n),V=["ar","he","fa","ur"],ee=typeof navigator<"u"?(navigator.language??"").slice(0,2).toLowerCase():"";V.includes(ee)&&!t.el.dir&&(t.el.dir="rtl",t.el.style.fontFamily=t.el.style.fontFamily||"Tahoma,Arial,system-ui,sans-serif");const X=`oc_prechat_${t.profileId}_${i.slice(-8)}`,R=new Vn(t.el,i,{onSend(d){const x=`cm_${Math.random().toString(36).slice(2)}`,I={kind:"text",text:d};a.addOptimistic(x,I),R.render(a),a.e2e?m.ready?A(x,d):P?v.push({clientMsgId:x,text:d}):(T.push({clientMsgId:x,text:d}),a.assignedAgentId&&k(a.assignedAgentId)):h?(f.add({clientMsgId:x,content:I,ts:Date.now()}),b.send({type:"send",conversationId:h,clientMsgId:x,content:I})):g.push({clientMsgId:x,content:I})},async onAttach(d){if(!h)return;const x=`${p}/upload?name=${encodeURIComponent(d.name)}`,I=`cm_${Math.random().toString(36).slice(2)}`;a.addOptimistic(I,{kind:"text",text:`📎 Uploading ${d.name}…`}),R.render(a);try{const N=await fetch(x,{method:"POST",headers:{"content-type":d.type,authorization:`Bearer ${i}`},body:d});if(!N.ok)throw new Error(`Upload failed: ${N.status}`);const{url:he,name:Ue,mime:$e,size:Re}=await N.json();a.addOptimistic(I,{kind:"attachment",url:he,name:Ue,mime:$e,size:Re}),R.render(a),b.send({type:"send",conversationId:h,clientMsgId:I,content:{kind:"attachment",url:he,name:Ue,mime:$e,size:Re}})}catch(N){a.addOptimistic(I,{kind:"text",text:`⚠️ Upload failed: ${N.message}`}),R.render(a)}},onInvoke(d,x){h&&b.send({type:"invoke",conversationId:h,actionId:d,clientInvokeId:`iv_${Math.random().toString(36).slice(2)}`,...x?{inputs:x}:{}})},onTyping(d,x){h&&b.send({type:"typing",conversationId:h,isTyping:d,...x?{preview:x}:{}})},onPreChat(d){try{localStorage.setItem(X,"1")}catch{}b.send({type:"open",profileId:t.profileId,...t.subjectId?{subjectId:t.subjectId}:{},userInfo:{...d.name?{name:d.name}:{},...d.email?{email:d.email}:{},...d.phone||d.topic?{meta:{...d.phone?{phone:d.phone}:{},...d.topic?{topic:d.topic}:{}}}:{}}});const x=d.callback?`📞 Call-back requested${d.phone?`: ${d.phone}`:""}${d.topic?` — ${d.topic}`:""}`:d.topic?`Topic: ${d.topic}`:"";x&&h&&!a.e2e&&b.send({type:"send",conversationId:h,clientMsgId:`pc_${Math.random().toString(36).slice(2,12)}`,content:{kind:"text",text:x}})},...((ge=t.features)==null?void 0:ge.deflection)!==!1?{onDeflectQuery(d){if(o)return;clearTimeout(n);const x=d.trim();if(x.length<3){R.hideDeflection();return}n=setTimeout(()=>{fetch(`${p}/kb/search?profileId=${encodeURIComponent(t.profileId)}&q=${encodeURIComponent(x.slice(0,200))}`).then(I=>I.ok?I.json():{articles:[]}).then(I=>R.showDeflection(I.articles??[])).catch(()=>R.hideDeflection())},350)}}:{},onReadUpTo(d){h&&b.send({type:"read",conversationId:h,seq:d})},onLoadMore(){if(!h||!a.e2e)return;const d=a.messages()[0];d&&b.send({type:"history",conversationId:h,beforeSeq:d.seq,limit:20})},onEdit(d,x){h&&b.send({type:"edit",conversationId:h,messageId:d,content:{kind:"text",text:x}})},onDelete(d){h&&b.send({type:"delete",conversationId:h,messageId:d})},...((Te=t.features)==null?void 0:Te.reactions)!==!1?{onReact(d,x,I){h&&b.send({type:"react",conversationId:h,messageId:d,emoji:x,remove:I})}}:{},...((Ee=t.features)==null?void 0:Ee.csat)!==!1?{onCsat(d){h&&fetch(`${p}/conversations/${h}/csat`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({score:d})}).catch(()=>{})}}:{},...(()=>{const d=t.locale??(typeof navigator<"u"?navigator.language:""),x=t.translateLang!==void 0?t.translateLang:d?d.split("-")[0]:bt();return x?{async onTranslate(I){try{const N=await fetch(`${p}/translate`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${i}`},body:JSON.stringify({text:I,targetLang:x})});if(!N.ok)return null;const{translated:he}=await N.json();return he}catch{return null}}}:{}})(),...t.onBack?{onBack:t.onBack}:{}},{...t.subject?{subject:t.subject}:{},...t.quickReplies?{quickReplies:t.quickReplies}:{},...t.accent?{accent:t.accent}:{},...t.accent2?{accent2:t.accent2}:{},...t.theme?{theme:t.theme}:{},...t.webfont===!1?{webfont:!1}:{},...(Tt=t.user)!=null&&Tt.name||(Et=t.user)!=null&&Et.avatar?{userInfo:{...t.user.name?{name:t.user.name}:{},...t.user.avatar?{avatar:t.user.avatar}:{}}}:{},i18n:j});try{localStorage.getItem(X)&&R.completePreChat()}catch{}const L=t.user&&(t.user.name||t.user.email||t.user.avatar||t.user.meta)?{...t.user.name?{name:t.user.name}:{},...t.user.email?{email:t.user.email}:{},...t.user.avatar?{avatar:t.user.avatar}:{},...t.user.meta?{meta:t.user.meta}:{}}:void 0,fe={type:"open",profileId:t.profileId,...t.kind==="direct"&&t.peerId?{kind:"direct",peerId:t.peerId}:t.subjectId?{subjectId:t.subjectId}:{},...s?{linkFrom:s}:{},...L?{userInfo:L}:{},...typeof location<"u"?{pageUrl:location.href}:{},...typeof document<"u"&&document.title?{pageTitle:document.title}:{},...(Ut=t.subject)!=null&&Ut.title?{subjectTitle:t.subject.title}:{},...(Pt=t.subject)!=null&&Pt.subtitle?{subjectMeta:t.subject.subtitle}:{}};b=new mn({...t.refreshToken?{refreshToken:t.refreshToken}:{},url:r,token:i,open:fe,getCursor:()=>a.highestSeq(),onStatusChange:(d,x)=>R.setConnStatus(d,x),onFrame(d){if(d.type==="opened"){if(h=d.conversation.id,!y){y=!0;for(const x of f.load())b.send({type:"send",conversationId:h,clientMsgId:x.clientMsgId,content:x.content})}Zn(r,i,h,a,R,p),g.length&&u(h)}if(d.type==="ack"&&f.remove(d.clientMsgId),d.type==="prekeyBundle"){d.bundle&&(P=!0,m.x3dhSendTo(d.bundle).then(x=>{const I=[...T.splice(0),...v.splice(0)];for(const N of I)Q(N.clientMsgId,N.text,x);R.render(a)}));return}if(d.type==="message"&&a.e2e){const x=Kn(d.message.content);if(x&&!m.ready){m.x3dhReceiveFrom(x.x3dhIK,x.x3dhEK,x.x3dhSPK,x.x3dhOTP).then(async()=>{await m.openFrame(d),a.apply(d),R.render(a)});return}}if(d.type==="peerkey"){m.onPeerKey(d.key).then(()=>{W(),R.render(a)});return}(async()=>{if(a.e2e&&await m.openFrame(d),a.apply(d),d.type==="manifest"){K==null||K();const x=d.botName;x&&R.setBotName(x)}if(d.type==="message"&&d.message.senderId!==i&&!d.message.internal&&(Z(),B()),a.e2e&&h&&!C){C=!0;const x=await m.initX3DH();b.send({type:"uploadPrekeys",...x});const I=await m.begin();b.send({type:"pubkey",conversationId:h,key:I})}R.render(a)})()}}),b.connect(),R.render(a);const oe=t.launcher?St(t):null,we={close:()=>{o=!0,clearTimeout(n),b.close(),$==null||$.remove(),R.destroy(),S&&E&&S.removeEventListener("change",E),M&&(document.removeEventListener("keydown",M),M=null),ke.delete(t.el),oe&&Me.get(oe)===we&&Me.delete(oe)}};return ke.set(t.el,we),oe&&Me.set(oe,we),we}const Je="wss://api.paramms.com/ws";function ri(t,e){const n=t.profileId??t.appId;if(!n)throw new Error("Relay: `profileId` is required (your chatroom id, e.g. 'p_...').");const o=t.subjectId??(t.listingId?`listing_${t.listingId}`:void 0),i=t.launcher??!0,s=t.contextTitle??t.listingTitle??t.subjectTitle,r=t.contextSubtitle??t.listingMeta??t.subjectMeta,p=t.contextStatus??t.listingStatus??t.subjectStatus,a=t.listingPrice??t.subjectPrice,w=s?{title:s,...r?{subtitle:r}:{},...a!=null?{tags:[`$${a.toLocaleString()}`]}:{},...p?{status:p}:{}}:void 0,f=t.subject??w,h=t.userName??t.name,y=t.userEmail??t.email,S=t.userAvatar??t.avatar,E=h||y||S?{...h?{name:h}:{},...y?{email:y}:{},...S?{avatar:S}:{}}:void 0,M=t.user??E,K=t.launcherMessage&&typeof t.launcherMessage=="object"?t.launcherMessage:t.launcherMessage?t.launcherSubtitle?{title:t.launcherMessage,subtitle:t.launcherSubtitle}:t.launcherMessage:void 0;return{el:e,url:t.url??Je,profileId:n,...t.apiUrl?{apiUrl:t.apiUrl}:{},...o?{subjectId:o}:{},...t.token?{token:t.token}:{},...t.refreshToken?{refreshToken:t.refreshToken}:{},...t.userId?{userId:t.userId}:{},...f?{subject:f}:{},...M?{user:M}:{},...t.quickReplies?{quickReplies:t.quickReplies}:{},...t.i18n?{i18n:t.i18n}:{},...t.features?{features:t.features}:{},...t.accent?{accent:t.accent}:{},...t.accent2?{accent2:t.accent2}:{},...t.theme?{theme:t.theme}:{},...t.locale?{locale:t.locale}:{},...t.webfont===!1?{webfont:!1}:{},...t.translateLang?{translateLang:t.translateLang}:{},...K?{launcherMessage:K}:{},...It(t)&&!i?{onBack:()=>{Ie=!0,Ce=!1,ze(le)}}:{},launcher:i,position:t.position??"bottom-right"}}let ne=null,O=null,ce=!1,le={},Ie=!1,Ce=!1;function It(t){return!!(t.inbox||t.inboxStart)}let ie=null;function ai(t,e){const n=!e&&!!t.el;if(ce&&!n&&(O.innerHTML="",O=null,ce=!1),n){const o=typeof t.el=="string"?document.querySelector(t.el):t.el;o instanceof HTMLElement?(O&&O!==o&&!ce&&O.remove(),O=o,ce=!0):console.error(`[Relay] \`el\` ("${String(t.el)}") did not match any element — falling back to an auto-created host.`)}return(!O||!ce&&!O.isConnected)&&(O=document.createElement("div"),O.id="relay-widget-root",document.body.appendChild(O),ce=!1),!e&&t.height&&(O.style.height=t.height,O.style.width||(O.style.width="100%")),O}function ze(t){try{const e=t.launcher??!0;ie==null||ie(),ie=null,ne==null||ne.close(),ne=null;const n=ai(t,e);if(It(t)&&!e&&Ie){ci(t,n);return}ne=Ye(ri(t,n))}catch(e){console.error("[Relay]",e instanceof Error?e.message:e)}}async function ci(t,e){const n=t.profileId??t.appId;if(!n&&!t.tenantId){console.error("[Relay] `inbox` requires `profileId` or `tenantId`.");return}e.innerHTML="";const o=document.createElement("div");o.style.cssText="position:relative;width:100%;height:100%;overflow:hidden;background:#fff";const i=document.createElement("div");i.style.cssText="position:absolute;inset:0";const s=document.createElement("div");s.style.cssText="position:absolute;inset:0;display:none";const r=document.createElement("button");r.type="button",r.setAttribute("aria-label","Close"),r.textContent="✕",r.style.cssText="position:absolute;top:8px;right:8px;z-index:20;width:32px;height:32px;border-radius:50%;display:flex;align-items:center;justify-content:center;background:rgba(0,0,0,.05);border:none;color:#1c1b1a;font-size:16px;line-height:1;cursor:pointer",r.onclick=()=>{Ie=!1,ze(le)},o.append(i,s);const p=!Ce&&!!n;p&&o.append(r),e.appendChild(o);let a=null,w=null;ie=()=>{w==null||w.close(),a==null||a.close(),e.innerHTML=""};let f;try{({mountChatList:f}=await Promise.resolve().then(()=>ii))}catch(y){console.error("[Relay] could not load the conversation list module.",y),i.isConnected&&(i.style.cssText+=";display:flex;align-items:center;justify-content:center;padding:16px;font:13px system-ui;color:#b91c1c;text-align:center",i.textContent="Could not load conversations.");return}if(!i.isConnected)return;const h=y=>{const S=y.profileId??n;if(!S){console.error("[Relay] conversation row has no chatroom; cannot open it.",y);return}r.style.display="none",w==null||w.close(),w=Ye({el:s,url:t.url??Je,...t.apiUrl?{apiUrl:t.apiUrl}:{},profileId:S,...y.kind==="direct"&&y.peerId?{kind:"direct",peerId:y.peerId}:y.subjectId?{subjectId:y.subjectId}:{},...t.token?{token:t.token}:{},...t.refreshToken?{refreshToken:t.refreshToken}:{},...t.userId?{userId:t.userId}:{},...t.userId||t.userName||t.userEmail||t.userAvatar?{user:{...t.userName?{name:t.userName}:{},...t.userEmail?{email:t.userEmail}:{},...t.userAvatar?{avatar:t.userAvatar}:{}}}:{},...y.subjectTitle?{subject:{title:y.subjectTitle,...y.subjectMeta?{subtitle:y.subjectMeta}:{}}}:{},...t.accent?{accent:t.accent}:{},launcher:!1,onBack:()=>{w==null||w.close(),w=null,s.style.display="none",i.style.display="",r.style.display="",a==null||a.refresh()}}),i.style.display="none",s.style.display=""};a=f({el:i,url:t.url??Je,...t.apiUrl?{apiUrl:t.apiUrl}:{},...n?{profileId:n}:{},...t.tenantId?{tenantId:t.tenantId}:{},scope:t.inboxScope??"tenant",...p?{reserveCloseSpace:!0}:{},onSelect:h,onNewChat:()=>{const y=n??(a==null?void 0:a.defaultProfileId());y&&h({id:"__new__",profileId:y,state:"open",updatedAt:Date.now()})},...t.token?{token:t.token}:{},...t.userId?{userId:t.userId}:{},...t.accent?{accent:t.accent}:{}})}function Ct(t){Ce=!!(t.inboxStart&&!(t.launcher??!0)),Ie=Ce,le={...t},ze(le)}function li(t){le={...le,...t},ze(le)}function di(){ie==null||ie(),ie=null,ne==null||ne.close(),ne=null,O&&!ce&&O.remove(),O=null,ce=!1,Ie=!1,Ce=!1,le={}}function Ze(t,e){switch(t){case"boot":Ct(e??{});break;case"update":case"identify":li(e??{});break;case"shutdown":di();break;default:console.warn("[Relay] unknown command:",t)}}function hi(){if(typeof document>"u")return null;const t=document.querySelector("script[data-relay-app]")??document.querySelector("script[data-relay-profile-id]")??document.querySelector("script[data-relay-tenant-id]"),e=t==null?void 0:t.dataset,n=(e==null?void 0:e.relayApp)??(e==null?void 0:e.relayProfileId),o=e==null?void 0:e.relayTenantId;if(!n&&!o)return null;const i=n?{profileId:n}:{};o&&(i.tenantId=o),e.relayUser&&(i.userId=e.relayUser),e.relayToken&&(i.token=e.relayToken),e.relayListing&&(i.listingId=e.relayListing),e.relayAccent&&(i.accent=e.relayAccent),e.relayAccent2&&(i.accent2=e.relayAccent2),e.relayTheme&&(i.theme=e.relayTheme),e.relayLocale&&(i.locale=e.relayLocale),e.relayWebfont==="false"&&(i.webfont=!1),e.relayUrl&&(i.url=e.relayUrl);const s=e.relayPosition;(s==="bottom-left"||s==="bottom-right")&&(i.position=s),e.relayLauncherMessage&&(i.launcherMessage=e.relayLauncherMessage),e.relayLauncherSubtitle&&(i.launcherSubtitle=e.relayLauncherSubtitle),e.relayLauncher==="false"&&(i.launcher=!1),e.relayUserName&&(i.userName=e.relayUserName),e.relayUserEmail&&(i.userEmail=e.relayUserEmail),e.relayUserAvatar&&(i.userAvatar=e.relayUserAvatar),e.relayContextTitle&&(i.contextTitle=e.relayContextTitle),e.relayContextSubtitle&&(i.contextSubtitle=e.relayContextSubtitle),e.relayContextStatus&&(i.contextStatus=e.relayContextStatus),e.relayListingTitle&&(i.listingTitle=e.relayListingTitle),e.relayListingMeta&&(i.listingMeta=e.relayListingMeta),e.relayListingPrice&&(i.listingPrice=Number(e.relayListingPrice)),e.relayListingStatus&&(i.listingStatus=e.relayListingStatus),e.relayTarget&&(i.el=e.relayTarget),e.relayHeight&&(i.height=e.relayHeight),e.relayInbox==="true"&&(i.inbox=!0),e.relayInbox==="false"&&(i.inbox=!1),e.relayInboxStart==="true"&&(i.inboxStart=!0),e.relayInboxStart==="false"&&(i.inboxStart=!1);const r=e.relayInboxScope;return(r==="tenant"||r==="profile")&&(i.inboxScope=r),e.relayTranslateLang&&(i.translateLang=e.relayTranslateLang),i}if(typeof window<"u"){const t=window,e=t.Relay&&t.Relay.q?t.Relay.q:[];t.Relay=Ze;let n=!1;for(const o of e){const[i,s]=o;i==="boot"&&(n=!0),Ze(i,s)}if(!n){const o=t.relaySettings??hi();o&&Ct(o)}}return te.Relay=Ze,Object.defineProperty(te,Symbol.toStringTag,{value:"Module"}),te}({});
241
240
  //# sourceMappingURL=embed.js.map